aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.clang-format2
-rw-r--r--.clang_complete6
-rw-r--r--.github/CODEOWNERS7
-rw-r--r--.gitignore8
-rw-r--r--.gitmodules8
-rw-r--r--BUILD897
-rw-r--r--CMakeLists.txt9112
-rw-r--r--CONTRIBUTING.md83
-rw-r--r--INSTALL.md41
-rw-r--r--Makefile5126
-rw-r--r--OWNERS2
-rw-r--r--README.md25
-rwxr-xr-xRakefile15
-rw-r--r--WORKSPACE96
-rw-r--r--bazel/OWNERS3
-rw-r--r--bazel/cc_grpc_library.bzl4
-rw-r--r--bazel/grpc_build_system.bzl77
-rw-r--r--bazel/grpc_deps.bzl129
-rw-r--r--binding.gyp991
-rw-r--r--build.yaml1605
-rw-r--r--cmake/benchmark.cmake36
-rw-r--r--cmake/cares.cmake39
-rw-r--r--cmake/gflags.cmake35
-rw-r--r--cmake/msvc_static_runtime.cmake14
-rw-r--r--cmake/protobuf.cmake85
-rw-r--r--cmake/ssl.cmake38
-rw-r--r--cmake/zlib.cmake40
-rw-r--r--config.m4599
-rw-r--r--config.w32598
-rw-r--r--doc/PROTOCOL-HTTP2.md8
-rw-r--r--doc/PROTOCOL-WEB.md12
-rw-r--r--doc/command_line_tool.md156
-rw-r--r--doc/connectivity-semantics-and-api.md16
-rw-r--r--doc/core/moving-to-c++.md60
-rw-r--r--doc/core/transport_explainer.md197
-rw-r--r--doc/environment_variables.md26
-rw-r--r--doc/g_stands_for.md3
-rw-r--r--doc/load-balancing.md7
-rw-r--r--doc/service_config.md2
-rw-r--r--examples/BUILD4
-rw-r--r--examples/cpp/helloworld/CMakeLists.txt31
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj409
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h (renamed from src/node/health_check/node_modules/grpc.js)9
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm (renamed from src/node/test/math/node_modules/grpc.js)8
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json93
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard25
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard24
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist45
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h23
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm101
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m26
-rw-r--r--examples/cpp/helloworld/cocoapods/Podfile8
-rw-r--r--examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj9
-rw-r--r--examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs1
-rw-r--r--examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj1
-rw-r--r--examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj1
-rw-r--r--examples/csharp/helloworld-from-cli/generate_protos.bat4
-rw-r--r--examples/csharp/helloworld/Greeter/Greeter.csproj10
-rw-r--r--examples/csharp/helloworld/Greeter/HelloworldGrpc.cs1
-rw-r--r--examples/csharp/helloworld/Greeter/packages.config8
-rw-r--r--examples/csharp/helloworld/GreeterClient/GreeterClient.csproj10
-rw-r--r--examples/csharp/helloworld/GreeterClient/packages.config6
-rw-r--r--examples/csharp/helloworld/GreeterServer/GreeterServer.csproj10
-rw-r--r--examples/csharp/helloworld/GreeterServer/packages.config6
-rw-r--r--examples/csharp/helloworld/generate_protos.bat2
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuide.csproj10
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs1
-rw-r--r--examples/csharp/route_guide/RouteGuide/packages.config6
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj10
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/packages.config6
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj10
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/packages.config8
-rw-r--r--examples/csharp/route_guide/generate_protos.bat2
-rw-r--r--examples/node/dynamic_codegen/greeter_server.js2
-rw-r--r--examples/php/README.md3
-rw-r--r--examples/php/greeter_client.php10
-rwxr-xr-xexamples/php/greeter_proto_gen.sh17
-rw-r--r--examples/php/helloworld.pb.php58
-rw-r--r--examples/php/route_guide/route_guide.pb.php209
-rw-r--r--examples/php/route_guide/route_guide_client.php43
-rw-r--r--examples/php/route_guide/route_guide_grpc_pb.php101
-rwxr-xr-xexamples/php/route_guide/route_guide_proto_gen.sh (renamed from tools/run_tests/helper_scripts/pre_build_node.sh)14
-rw-r--r--examples/python/helloworld/greeter_client.py11
-rw-r--r--examples/python/helloworld/greeter_server.py26
-rw-r--r--examples/python/helloworld/helloworld_pb2.py145
-rw-r--r--examples/python/helloworld/helloworld_pb2_grpc.py3
-rw-r--r--examples/python/interceptors/default_value/default_value_client_interceptor.py68
-rw-r--r--examples/python/interceptors/default_value/greeter_client.py38
-rw-r--r--examples/python/interceptors/default_value/helloworld_pb2.py134
-rw-r--r--examples/python/interceptors/default_value/helloworld_pb2_grpc.py46
-rw-r--r--examples/python/interceptors/headers/generic_client_interceptor.py55
-rw-r--r--examples/python/interceptors/headers/greeter_client.py36
-rw-r--r--examples/python/interceptors/headers/greeter_server.py52
-rw-r--r--examples/python/interceptors/headers/header_manipulator_client_interceptor.py46
-rw-r--r--examples/python/interceptors/headers/helloworld_pb2.py134
-rw-r--r--examples/python/interceptors/headers/helloworld_pb2_grpc.py46
-rw-r--r--examples/python/interceptors/headers/request_header_validator_interceptor.py39
-rw-r--r--examples/python/multiplex/multiplex_client.py130
-rw-r--r--examples/python/multiplex/multiplex_server.py181
-rw-r--r--examples/python/multiplex/route_guide_resources.py23
-rw-r--r--examples/python/multiplex/run_codegen.py33
-rw-r--r--examples/python/route_guide/route_guide_client.py117
-rw-r--r--examples/python/route_guide/route_guide_pb2.py310
-rw-r--r--examples/python/route_guide/route_guide_pb2_grpc.py3
-rw-r--r--examples/python/route_guide/route_guide_resources.py23
-rw-r--r--examples/python/route_guide/route_guide_server.py175
-rw-r--r--examples/python/route_guide/run_codegen.py17
-rw-r--r--gRPC-C++.podspec685
-rw-r--r--gRPC-Core.podspec865
-rw-r--r--gRPC-ProtoRPC.podspec3
-rw-r--r--gRPC-RxLibrary.podspec6
-rw-r--r--gRPC.podspec6
-rw-r--r--grpc.def59
-rw-r--r--grpc.gemspec670
-rw-r--r--grpc.gyp2095
-rw-r--r--include/grpc++/alarm.h2
-rw-r--r--include/grpc++/channel.h16
-rw-r--r--include/grpc++/generic/async_generic_service.h17
-rw-r--r--include/grpc++/impl/channel_argument_option.h4
-rw-r--r--include/grpc++/impl/codegen/async_stream.h239
-rw-r--r--include/grpc++/impl/codegen/async_unary_call.h73
-rw-r--r--include/grpc++/impl/codegen/byte_buffer.h21
-rw-r--r--include/grpc++/impl/codegen/call.h65
-rw-r--r--include/grpc++/impl/codegen/call_hook.h2
-rw-r--r--include/grpc++/impl/codegen/channel_interface.h45
-rw-r--r--include/grpc++/impl/codegen/client_context.h37
-rw-r--r--include/grpc++/impl/codegen/client_unary_call.h74
-rw-r--r--include/grpc++/impl/codegen/completion_queue.h127
-rw-r--r--include/grpc++/impl/codegen/completion_queue_tag.h2
-rw-r--r--include/grpc++/impl/codegen/config_protobuf.h2
-rw-r--r--include/grpc++/impl/codegen/core_codegen.h4
-rw-r--r--include/grpc++/impl/codegen/core_codegen_interface.h12
-rw-r--r--include/grpc++/impl/codegen/metadata_map.h40
-rw-r--r--include/grpc++/impl/codegen/method_handler_impl.h39
-rw-r--r--include/grpc++/impl/codegen/proto_utils.h133
-rw-r--r--include/grpc++/impl/codegen/rpc_method.h3
-rw-r--r--include/grpc++/impl/codegen/rpc_service_method.h3
-rw-r--r--include/grpc++/impl/codegen/server_context.h27
-rw-r--r--include/grpc++/impl/codegen/server_interface.h42
-rw-r--r--include/grpc++/impl/codegen/service_type.h46
-rw-r--r--include/grpc++/impl/codegen/sync_stream.h327
-rw-r--r--include/grpc++/impl/codegen/time.h6
-rw-r--r--include/grpc++/server.h3
-rw-r--r--include/grpc++/server_builder.h147
-rw-r--r--include/grpc++/support/channel_arguments.h8
-rw-r--r--include/grpc/census.h433
-rw-r--r--include/grpc/compression.h47
-rw-r--r--include/grpc/compression_ruby.h48
-rw-r--r--include/grpc/fork.h24
-rw-r--r--include/grpc/grpc.h215
-rw-r--r--include/grpc/grpc_cronet.h6
-rw-r--r--include/grpc/grpc_posix.h8
-rw-r--r--include/grpc/grpc_security.h275
-rw-r--r--include/grpc/grpc_security_constants.h7
-rw-r--r--include/grpc/impl/codegen/atm.h10
-rw-r--r--include/grpc/impl/codegen/atm_gcc_atomic.h17
-rw-r--r--include/grpc/impl/codegen/atm_gcc_sync.h11
-rw-r--r--include/grpc/impl/codegen/atm_windows.h45
-rw-r--r--include/grpc/impl/codegen/byte_buffer.h28
-rw-r--r--include/grpc/impl/codegen/byte_buffer_reader.h4
-rw-r--r--include/grpc/impl/codegen/compression_types.h70
-rw-r--r--include/grpc/impl/codegen/connectivity_state.h2
-rw-r--r--include/grpc/impl/codegen/exec_ctx_fwd.h26
-rw-r--r--include/grpc/impl/codegen/fork.h48
-rw-r--r--include/grpc/impl/codegen/grpc_types.h74
-rw-r--r--include/grpc/impl/codegen/port_platform.h94
-rw-r--r--include/grpc/impl/codegen/slice.h21
-rw-r--r--include/grpc/impl/codegen/sync_generic.h12
-rw-r--r--include/grpc/module.modulemap77
-rw-r--r--include/grpc/slice.h33
-rw-r--r--include/grpc/slice_buffer.h43
-rw-r--r--include/grpc/support/alloc.h25
-rw-r--r--include/grpc/support/avl.h48
-rw-r--r--include/grpc/support/cmdline.h26
-rw-r--r--include/grpc/support/histogram.h64
-rw-r--r--include/grpc/support/host_port.h4
-rw-r--r--include/grpc/support/log.h24
-rw-r--r--include/grpc/support/log_windows.h2
-rw-r--r--include/grpc/support/string_util.h4
-rw-r--r--include/grpc/support/subprocess.h10
-rw-r--r--include/grpc/support/sync.h70
-rw-r--r--include/grpc/support/thd.h15
-rw-r--r--include/grpc/support/tls.h6
-rw-r--r--include/grpc/support/tls_gcc.h45
-rw-r--r--include/grpc/support/tls_msvc.h9
-rw-r--r--include/grpc/support/tls_pthread.h11
-rw-r--r--package.json103
-rw-r--r--package.xml677
-rw-r--r--requirements.txt2
-rw-r--r--setup.py17
-rwxr-xr-xsrc/c-ares/gen_build_yaml.py12
-rw-r--r--src/compiler/cpp_generator.cc316
-rw-r--r--src/compiler/cpp_generator.h68
-rw-r--r--src/compiler/cpp_generator_helpers.h12
-rw-r--r--src/compiler/cpp_plugin.cc18
-rw-r--r--src/compiler/csharp_generator.cc94
-rw-r--r--src/compiler/csharp_generator.h2
-rw-r--r--src/compiler/csharp_generator_helpers.h6
-rw-r--r--src/compiler/csharp_plugin.cc10
-rw-r--r--src/compiler/generator_helpers.h44
-rw-r--r--src/compiler/node_generator.cc58
-rw-r--r--src/compiler/node_generator.h2
-rw-r--r--src/compiler/node_plugin.cc10
-rw-r--r--src/compiler/objective_c_generator.cc56
-rw-r--r--src/compiler/objective_c_generator.h9
-rw-r--r--src/compiler/objective_c_generator_helpers.h8
-rw-r--r--src/compiler/objective_c_plugin.cc88
-rw-r--r--src/compiler/php_generator.cc32
-rw-r--r--src/compiler/php_generator.h6
-rw-r--r--src/compiler/php_generator_helpers.h16
-rw-r--r--src/compiler/php_plugin.cc12
-rw-r--r--src/compiler/protobuf_plugin.h31
-rw-r--r--src/compiler/python_generator.cc4
-rw-r--r--src/compiler/python_generator_helpers.h6
-rw-r--r--src/compiler/ruby_generator.cc36
-rw-r--r--src/compiler/ruby_generator.h2
-rw-r--r--src/compiler/ruby_generator_helpers-inl.h8
-rw-r--r--src/compiler/ruby_generator_map-inl.h2
-rw-r--r--src/compiler/ruby_generator_string-inl.h22
-rw-r--r--src/compiler/ruby_plugin.cc10
-rw-r--r--src/compiler/schema_interface.h13
-rw-r--r--src/core/ext/census/README.md61
-rw-r--r--src/core/ext/census/aggregation.h51
-rw-r--r--src/core/ext/census/base_resources.c56
-rw-r--r--src/core/ext/census/base_resources.h24
-rw-r--r--src/core/ext/census/census_interface.h61
-rw-r--r--src/core/ext/census/census_log.c588
-rw-r--r--src/core/ext/census/census_log.h76
-rw-r--r--src/core/ext/census/census_rpc_stats.c238
-rw-r--r--src/core/ext/census/census_rpc_stats.h86
-rw-r--r--src/core/ext/census/census_tracing.c226
-rw-r--r--src/core/ext/census/census_tracing.h81
-rw-r--r--src/core/ext/census/context.c496
-rw-r--r--src/core/ext/census/gen/README.md10
-rw-r--r--src/core/ext/census/gen/census.pb.c161
-rw-r--r--src/core/ext/census/gen/census.pb.h280
-rw-r--r--src/core/ext/census/gen/trace_context.pb.c39
-rw-r--r--src/core/ext/census/gen/trace_context.pb.h78
-rw-r--r--src/core/ext/census/grpc_context.cc (renamed from src/core/ext/census/grpc_context.c)13
-rw-r--r--src/core/ext/census/grpc_filter.c196
-rw-r--r--src/core/ext/census/grpc_plugin.c70
-rw-r--r--src/core/ext/census/hash_table.c288
-rw-r--r--src/core/ext/census/hash_table.h116
-rw-r--r--src/core/ext/census/initialize.c51
-rw-r--r--src/core/ext/census/intrusive_hash_map.c305
-rw-r--r--src/core/ext/census/intrusive_hash_map.h152
-rw-r--r--src/core/ext/census/intrusive_hash_map_internal.h48
-rw-r--r--src/core/ext/census/mlog.c586
-rw-r--r--src/core/ext/census/mlog.h80
-rw-r--r--src/core/ext/census/operation.c48
-rw-r--r--src/core/ext/census/placeholders.c49
-rw-r--r--src/core/ext/census/resource.c303
-rw-r--r--src/core/ext/census/resource.h48
-rw-r--r--src/core/ext/census/rpc_metric_id.h36
-rw-r--r--src/core/ext/census/trace_context.c71
-rw-r--r--src/core/ext/census/trace_context.h56
-rw-r--r--src/core/ext/census/trace_label.h46
-rw-r--r--src/core/ext/census/trace_propagation.h48
-rw-r--r--src/core/ext/census/trace_status.h30
-rw-r--r--src/core/ext/census/trace_string.h35
-rw-r--r--src/core/ext/census/tracing.c55
-rw-r--r--src/core/ext/census/tracing.h109
-rw-r--r--src/core/ext/census/window_stats.c301
-rw-r--r--src/core/ext/census/window_stats.h158
-rw-r--r--src/core/ext/filters/client_channel/OWNERS2
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.cc168
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.h (renamed from src/core/ext/census/grpc_filter.h)19
-rw-r--r--src/core/ext/filters/client_channel/channel_connectivity.cc (renamed from src/core/ext/filters/client_channel/channel_connectivity.c)119
-rw-r--r--src/core/ext/filters/client_channel/client_channel.cc (renamed from src/core/ext/filters/client_channel/client_channel.c)1300
-rw-r--r--src/core/ext/filters/client_channel/client_channel.h16
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.cc (renamed from src/core/ext/filters/client_channel/client_channel_factory.c)23
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.h37
-rw-r--r--src/core/ext/filters/client_channel/client_channel_plugin.cc (renamed from src/core/ext/filters/client_channel/client_channel_plugin.c)35
-rw-r--r--src/core/ext/filters/client_channel/connector.cc (renamed from src/core/ext/filters/client_channel/connector.c)13
-rw-r--r--src/core/ext/filters/client_channel/connector.h40
-rw-r--r--src/core/ext/filters/client_channel/http_connect_handshaker.cc (renamed from src/core/ext/filters/client_channel/http_connect_handshaker.c)108
-rw-r--r--src/core/ext/filters/client_channel/http_proxy.cc (renamed from src/core/ext/filters/client_channel/http_proxy.c)74
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.c164
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.cc141
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.h209
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c137
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc137
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h2
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c1915
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc1936
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h2
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc (renamed from src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c)24
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h18
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc (renamed from src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c)42
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc (renamed from src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c)6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h2
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc (renamed from src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c)140
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h50
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c7
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h21
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c714
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc577
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c924
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc656
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc259
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.h142
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_factory.cc (renamed from src/core/ext/filters/client_channel/lb_policy_factory.c)37
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_factory.h77
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_registry.cc (renamed from src/core/ext/filters/client_channel/lb_policy_registry.c)22
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_registry.h6
-rw-r--r--src/core/ext/filters/client_channel/parse_address.cc (renamed from src/core/ext/filters/client_channel/parse_address.c)50
-rw-r--r--src/core/ext/filters/client_channel/parse_address.h12
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper.cc (renamed from src/core/ext/filters/client_channel/proxy_mapper.c)14
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper.h14
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper_registry.cc (renamed from src/core/ext/filters/client_channel/proxy_mapper_registry.c)30
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper_registry.h6
-rw-r--r--src/core/ext/filters/client_channel/resolver.c83
-rw-r--r--src/core/ext/filters/client_channel/resolver.cc79
-rw-r--r--src/core/ext/filters/client_channel/resolver.h55
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc (renamed from src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c)299
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h17
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc (renamed from src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c)128
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc (renamed from src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c)263
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h28
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c60
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc58
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c310
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc303
-rw-r--r--src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc (renamed from src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c)78
-rw-r--r--src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h4
-rw-r--r--src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc (renamed from src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c)133
-rw-r--r--src/core/ext/filters/client_channel/resolver_factory.cc (renamed from src/core/ext/filters/client_channel/resolver_factory.c)9
-rw-r--r--src/core/ext/filters/client_channel/resolver_factory.h36
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.cc (renamed from src/core/ext/filters/client_channel/resolver_registry.c)85
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.h19
-rw-r--r--src/core/ext/filters/client_channel/retry_throttle.cc (renamed from src/core/ext/filters/client_channel/retry_throttle.c)20
-rw-r--r--src/core/ext/filters/client_channel/subchannel.c816
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc801
-rw-r--r--src/core/ext/filters/client_channel/subchannel.h177
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.cc (renamed from src/core/ext/filters/client_channel/subchannel_index.c)135
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.h24
-rw-r--r--src/core/ext/filters/client_channel/uri_parser.cc (renamed from src/core/ext/filters/client_channel/uri_parser.c)82
-rw-r--r--src/core/ext/filters/client_channel/uri_parser.h21
-rw-r--r--src/core/ext/filters/deadline/deadline_filter.cc (renamed from src/core/ext/filters/deadline/deadline_filter.c)133
-rw-r--r--src/core/ext/filters/deadline/deadline_filter.h15
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.cc (renamed from src/core/ext/filters/http/client/http_client_filter.c)247
-rw-r--r--src/core/ext/filters/http/http_filters_plugin.cc (renamed from src/core/ext/filters/http/http_filters_plugin.c)35
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.cc (renamed from src/core/ext/filters/http/message_compress/message_compress_filter.c)366
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.h2
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.cc (renamed from src/core/ext/filters/http/server/http_server_filter.c)232
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_filter.cc (renamed from src/core/ext/filters/load_reporting/server_load_reporting_filter.c)75
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_filter.h2
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc (renamed from src/core/ext/filters/load_reporting/server_load_reporting_plugin.c)18
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_plugin.h10
-rw-r--r--src/core/ext/filters/max_age/max_age_filter.cc (renamed from src/core/ext/filters/max_age/max_age_filter.c)189
-rw-r--r--src/core/ext/filters/message_size/message_size_filter.cc (renamed from src/core/ext/filters/message_size/message_size_filter.c)138
-rw-r--r--src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc (renamed from src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c)47
-rw-r--r--src/core/ext/filters/workarounds/workaround_utils.cc (renamed from src/core/ext/filters/workarounds/workaround_utils.c)14
-rw-r--r--src/core/ext/filters/workarounds/workaround_utils.h2
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.cc (renamed from src/core/ext/transport/chttp2/alpn/alpn.c)6
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.h4
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.c206
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.cc227
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc (renamed from src/core/ext/transport/chttp2/client/insecure/channel_create.c)69
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc (renamed from src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c)41
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc (renamed from src/core/ext/transport/chttp2/client/secure/secure_channel_create.c)163
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.c292
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc348
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.h5
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc (renamed from src/core/ext/transport/chttp2/server/insecure/server_chttp2.c)12
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc (renamed from src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c)34
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc (renamed from src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c)31
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.cc (renamed from src/core/ext/transport/chttp2/transport/bin_decoder.c)26
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.h15
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.cc (renamed from src/core/ext/transport/chttp2/transport/bin_encoder.c)22
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.h2
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_plugin.cc (renamed from src/core/ext/transport/chttp2/transport/chttp2_plugin.c)13
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc (renamed from src/core/ext/transport/chttp2/transport/chttp2_transport.c)2094
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.h23
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.c502
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.cc401
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.h480
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.cc (renamed from src/core/ext/transport/chttp2/transport/frame_data.c)124
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.h33
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.cc (renamed from src/core/ext/transport/chttp2/transport/frame_goaway.c)37
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.h19
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.cc (renamed from src/core/ext/transport/chttp2/transport/frame_ping.c)44
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.cc (renamed from src/core/ext/transport/chttp2/transport/frame_rst_stream.c)33
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.h13
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.cc (renamed from src/core/ext/transport/chttp2/transport/frame_settings.c)53
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.h17
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.cc (renamed from src/core/ext/transport/chttp2/transport/frame_window_update.c)56
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.h14
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc (renamed from src/core/ext/transport/chttp2/transport/hpack_encoder.c)411
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.h26
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.cc (renamed from src/core/ext/transport/chttp2/transport/hpack_parser.c)858
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.h39
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.cc (renamed from src/core/ext/transport/chttp2/transport/hpack_table.c)64
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.h19
-rw-r--r--src/core/ext/transport/chttp2/transport/http2_settings.cc (renamed from src/core/ext/transport/chttp2/transport/http2_settings.c)2
-rw-r--r--src/core/ext/transport/chttp2/transport/http2_settings.h5
-rw-r--r--src/core/ext/transport/chttp2/transport/huffsyms.cc (renamed from src/core/ext/transport/chttp2/transport/huffsyms.c)0
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.cc (renamed from src/core/ext/transport/chttp2/transport/incoming_metadata.c)34
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.h19
-rw-r--r--src/core/ext/transport/chttp2/transport/internal.h550
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc (renamed from src/core/ext/transport/chttp2/transport/parsing.c)371
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_lists.cc (renamed from src/core/ext/transport/chttp2/transport/stream_lists.c)108
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.cc (renamed from src/core/ext/transport/chttp2/transport/stream_map.c)69
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.h28
-rw-r--r--src/core/ext/transport/chttp2/transport/varint.cc (renamed from src/core/ext/transport/chttp2/transport/varint.c)0
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.c515
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc637
-rw-r--r--src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc (renamed from src/core/ext/transport/cronet/client/secure/cronet_channel_create.c)19
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_api_dummy.cc (renamed from src/core/ext/transport/cronet/transport/cronet_api_dummy.c)2
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.cc (renamed from src/core/ext/transport/cronet/transport/cronet_transport.c)483
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.h6
-rw-r--r--src/core/ext/transport/inproc/inproc_plugin.cc (renamed from src/core/ext/transport/inproc/inproc_plugin.c)7
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.c1299
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.cc1223
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.h16
-rw-r--r--src/core/lib/backoff/backoff.cc75
-rw-r--r--src/core/lib/backoff/backoff.h87
-rw-r--r--src/core/lib/channel/channel_args.cc (renamed from src/core/lib/channel/channel_args.c)252
-rw-r--r--src/core/lib/channel/channel_args.h94
-rw-r--r--src/core/lib/channel/channel_stack.cc (renamed from src/core/lib/channel/channel_stack.c)145
-rw-r--r--src/core/lib/channel/channel_stack.h165
-rw-r--r--src/core/lib/channel/channel_stack_builder.cc (renamed from src/core/lib/channel/channel_stack_builder.c)193
-rw-r--r--src/core/lib/channel/channel_stack_builder.h97
-rw-r--r--src/core/lib/channel/connected_channel.cc (renamed from src/core/lib/channel/connected_channel.c)157
-rw-r--r--src/core/lib/channel/connected_channel.h7
-rw-r--r--src/core/lib/channel/context.h4
-rw-r--r--src/core/lib/channel/handshaker.cc (renamed from src/core/lib/channel/handshaker.c)85
-rw-r--r--src/core/lib/channel/handshaker.h33
-rw-r--r--src/core/lib/channel/handshaker_factory.cc (renamed from src/core/lib/channel/handshaker_factory.c)20
-rw-r--r--src/core/lib/channel/handshaker_factory.h18
-rw-r--r--src/core/lib/channel/handshaker_registry.cc (renamed from src/core/lib/channel/handshaker_registry.c)22
-rw-r--r--src/core/lib/channel/handshaker_registry.h5
-rw-r--r--src/core/lib/compression/algorithm_metadata.h19
-rw-r--r--src/core/lib/compression/compression.c283
-rw-r--r--src/core/lib/compression/compression.cc175
-rw-r--r--src/core/lib/compression/compression_internal.cc273
-rw-r--r--src/core/lib/compression/compression_internal.h86
-rw-r--r--src/core/lib/compression/compression_ruby.cc66
-rw-r--r--src/core/lib/compression/message_compress.cc (renamed from src/core/lib/compression/message_compress.c)58
-rw-r--r--src/core/lib/compression/message_compress.h9
-rw-r--r--src/core/lib/compression/stream_compression.cc (renamed from src/core/lib/compression/stream_compression.c)22
-rw-r--r--src/core/lib/compression/stream_compression.h38
-rw-r--r--src/core/lib/compression/stream_compression_gzip.cc (renamed from src/core/lib/compression/stream_compression_gzip.c)94
-rw-r--r--src/core/lib/compression/stream_compression_identity.cc (renamed from src/core/lib/compression/stream_compression_identity.c)39
-rw-r--r--src/core/lib/debug/stats.cc (renamed from src/core/lib/debug/stats.c)42
-rw-r--r--src/core/lib/debug/stats.h34
-rw-r--r--src/core/lib/debug/stats_data.cc (renamed from src/core/lib/debug/stats_data.c)298
-rw-r--r--src/core/lib/debug/stats_data.h557
-rw-r--r--src/core/lib/debug/stats_data.yaml30
-rw-r--r--src/core/lib/debug/stats_data_bq_schema.sql12
-rw-r--r--src/core/lib/debug/trace.c146
-rw-r--r--src/core/lib/debug/trace.cc142
-rw-r--r--src/core/lib/debug/trace.h76
-rw-r--r--src/core/lib/gpr/README.md8
-rw-r--r--src/core/lib/gpr/alloc.cc (renamed from src/core/lib/support/alloc.c)46
-rw-r--r--src/core/lib/gpr/arena.cc (renamed from src/core/lib/support/arena.c)51
-rw-r--r--src/core/lib/gpr/arena.h (renamed from src/core/lib/support/arena.h)12
-rw-r--r--src/core/lib/gpr/atm.cc (renamed from src/core/lib/support/atm.c)2
-rw-r--r--src/core/lib/gpr/avl.cc (renamed from src/core/lib/support/avl.c)141
-rw-r--r--src/core/lib/gpr/cmdline.cc (renamed from src/core/lib/support/cmdline.c)126
-rw-r--r--src/core/lib/gpr/cpu_iphone.cc (renamed from src/core/lib/support/cpu_iphone.c)2
-rw-r--r--src/core/lib/gpr/cpu_linux.cc (renamed from src/core/lib/support/cpu_linux.c)10
-rw-r--r--src/core/lib/gpr/cpu_posix.cc (renamed from src/core/lib/support/cpu_posix.c)31
-rw-r--r--src/core/lib/gpr/cpu_windows.cc (renamed from src/core/lib/support/cpu_windows.c)1
-rw-r--r--src/core/lib/gpr/env.h (renamed from src/core/lib/support/env.h)20
-rw-r--r--src/core/lib/gpr/env_linux.cc (renamed from src/core/lib/support/env_linux.c)26
-rw-r--r--src/core/lib/gpr/env_posix.cc (renamed from src/core/lib/support/env_posix.c)16
-rw-r--r--src/core/lib/gpr/env_windows.cc (renamed from src/core/lib/support/env_windows.c)21
-rw-r--r--src/core/lib/gpr/fork.cc76
-rw-r--r--src/core/lib/gpr/fork.h35
-rw-r--r--src/core/lib/gpr/host_port.cc (renamed from src/core/lib/support/host_port.c)34
-rw-r--r--src/core/lib/gpr/log.cc (renamed from src/core/lib/support/log.c)20
-rw-r--r--src/core/lib/gpr/log_android.cc (renamed from src/core/lib/support/log_android.c)14
-rw-r--r--src/core/lib/gpr/log_linux.cc (renamed from src/core/lib/support/log_linux.c)16
-rw-r--r--src/core/lib/gpr/log_posix.cc (renamed from src/core/lib/support/log_posix.c)23
-rw-r--r--src/core/lib/gpr/log_windows.cc (renamed from src/core/lib/support/log_windows.c)18
-rw-r--r--src/core/lib/gpr/mpscq.cc114
-rw-r--r--src/core/lib/gpr/mpscq.h84
-rw-r--r--src/core/lib/gpr/murmur_hash.cc (renamed from src/core/lib/support/murmur_hash.c)23
-rw-r--r--src/core/lib/gpr/murmur_hash.h (renamed from src/core/lib/support/murmur_hash.h)8
-rw-r--r--src/core/lib/gpr/spinlock.h (renamed from src/core/lib/support/spinlock.h)15
-rw-r--r--src/core/lib/gpr/string.cc (renamed from src/core/lib/support/string.c)113
-rw-r--r--src/core/lib/gpr/string.h (renamed from src/core/lib/support/string.h)55
-rw-r--r--src/core/lib/gpr/string_posix.cc (renamed from src/core/lib/support/string_posix.c)9
-rw-r--r--src/core/lib/gpr/string_util_windows.cc (renamed from src/core/lib/support/string_util_windows.c)17
-rw-r--r--src/core/lib/gpr/string_windows.cc (renamed from src/core/lib/support/string_windows.c)7
-rw-r--r--src/core/lib/gpr/string_windows.h (renamed from src/core/lib/support/string_windows.h)6
-rw-r--r--src/core/lib/gpr/subprocess_posix.cc (renamed from src/core/lib/support/subprocess_posix.c)26
-rw-r--r--src/core/lib/gpr/subprocess_windows.cc (renamed from src/core/lib/support/subprocess_windows.c)22
-rw-r--r--src/core/lib/gpr/sync.cc (renamed from src/core/lib/support/sync.c)44
-rw-r--r--src/core/lib/gpr/sync_posix.cc (renamed from src/core/lib/support/sync_posix.c)17
-rw-r--r--src/core/lib/gpr/sync_windows.cc (renamed from src/core/lib/support/sync_windows.c)28
-rw-r--r--src/core/lib/gpr/thd.cc (renamed from src/core/lib/support/thd.c)0
-rw-r--r--src/core/lib/gpr/thd_internal.h30
-rw-r--r--src/core/lib/gpr/thd_posix.cc152
-rw-r--r--src/core/lib/gpr/thd_windows.cc (renamed from src/core/lib/support/thd_windows.c)23
-rw-r--r--src/core/lib/gpr/time.cc (renamed from src/core/lib/support/time.c)0
-rw-r--r--src/core/lib/gpr/time_posix.cc (renamed from src/core/lib/support/time_posix.c)13
-rw-r--r--src/core/lib/gpr/time_precise.cc (renamed from src/core/lib/support/time_precise.c)10
-rw-r--r--src/core/lib/gpr/time_precise.h (renamed from src/core/lib/support/time_precise.h)8
-rw-r--r--src/core/lib/gpr/time_windows.cc (renamed from src/core/lib/support/time_windows.c)5
-rw-r--r--src/core/lib/gpr/tls_pthread.cc (renamed from src/core/lib/support/tls_pthread.c)4
-rw-r--r--src/core/lib/gpr/tmpfile.h (renamed from src/core/lib/support/tmpfile.h)16
-rw-r--r--src/core/lib/gpr/tmpfile_msys.cc (renamed from src/core/lib/support/tmpfile_msys.c)8
-rw-r--r--src/core/lib/gpr/tmpfile_posix.cc (renamed from src/core/lib/support/tmpfile_posix.c)18
-rw-r--r--src/core/lib/gpr/tmpfile_windows.cc (renamed from src/core/lib/support/tmpfile_windows.c)8
-rw-r--r--src/core/lib/gpr/wrap_memcpy.cc (renamed from src/core/lib/support/wrap_memcpy.c)6
-rw-r--r--src/core/lib/gprpp/README.md16
-rw-r--r--src/core/lib/gprpp/abstract.h34
-rw-r--r--src/core/lib/gprpp/atomic.h (renamed from src/core/lib/support/atomic.h)10
-rw-r--r--src/core/lib/gprpp/atomic_with_atm.h (renamed from src/core/lib/support/atomic_with_atm.h)6
-rw-r--r--src/core/lib/gprpp/atomic_with_std.h (renamed from src/core/lib/support/atomic_with_std.h)6
-rw-r--r--src/core/lib/gprpp/debug_location.h52
-rw-r--r--src/core/lib/gprpp/inlined_vector.h134
-rw-r--r--src/core/lib/gprpp/manual_constructor.h211
-rw-r--r--src/core/lib/gprpp/memory.h (renamed from src/core/lib/support/memory.h)47
-rw-r--r--src/core/lib/gprpp/orphanable.h171
-rw-r--r--src/core/lib/gprpp/ref_counted.h133
-rw-r--r--src/core/lib/gprpp/ref_counted_ptr.h99
-rw-r--r--src/core/lib/http/format_request.cc (renamed from src/core/lib/http/format_request.c)22
-rw-r--r--src/core/lib/http/format_request.h8
-rw-r--r--src/core/lib/http/httpcli.c321
-rw-r--r--src/core/lib/http/httpcli.cc302
-rw-r--r--src/core/lib/http/httpcli.h67
-rw-r--r--src/core/lib/http/httpcli_security_connector.c185
-rw-r--r--src/core/lib/http/httpcli_security_connector.cc193
-rw-r--r--src/core/lib/http/parser.cc (renamed from src/core/lib/http/parser.c)84
-rw-r--r--src/core/lib/http/parser.h40
-rw-r--r--src/core/lib/iomgr/block_annotate.h (renamed from src/core/lib/support/block_annotate.h)34
-rw-r--r--src/core/lib/iomgr/call_combiner.cc (renamed from src/core/lib/iomgr/call_combiner.c)69
-rw-r--r--src/core/lib/iomgr/call_combiner.h44
-rw-r--r--src/core/lib/iomgr/closure.c219
-rw-r--r--src/core/lib/iomgr/closure.h297
-rw-r--r--src/core/lib/iomgr/combiner.cc (renamed from src/core/lib/iomgr/combiner.c)193
-rw-r--r--src/core/lib/iomgr/combiner.h24
-rw-r--r--src/core/lib/iomgr/endpoint.cc (renamed from src/core/lib/iomgr/endpoint.c)34
-rw-r--r--src/core/lib/iomgr/endpoint.h62
-rw-r--r--src/core/lib/iomgr/endpoint_pair.h8
-rw-r--r--src/core/lib/iomgr/endpoint_pair_posix.cc (renamed from src/core/lib/iomgr/endpoint_pair_posix.c)15
-rw-r--r--src/core/lib/iomgr/endpoint_pair_uv.cc (renamed from src/core/lib/iomgr/endpoint_pair_uv.c)4
-rw-r--r--src/core/lib/iomgr/endpoint_pair_windows.cc (renamed from src/core/lib/iomgr/endpoint_pair_windows.c)22
-rw-r--r--src/core/lib/iomgr/error.cc (renamed from src/core/lib/iomgr/error.c)255
-rw-r--r--src/core/lib/iomgr/error.h72
-rw-r--r--src/core/lib/iomgr/error_internal.h5
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.cc (renamed from src/core/lib/iomgr/ev_epoll1_linux.c)560
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.h2
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.c1461
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.cc1464
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.h2
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.cc (renamed from src/core/lib/iomgr/ev_epollsig_linux.c)671
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.h12
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.cc (renamed from src/core/lib/iomgr/ev_poll_posix.c)652
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.h4
-rw-r--r--src/core/lib/iomgr/ev_posix.c266
-rw-r--r--src/core/lib/iomgr/ev_posix.cc273
-rw-r--r--src/core/lib/iomgr/ev_posix.h116
-rw-r--r--src/core/lib/iomgr/ev_windows.cc (renamed from src/core/lib/iomgr/ev_windows.c)4
-rw-r--r--src/core/lib/iomgr/exec_ctx.c113
-rw-r--r--src/core/lib/iomgr/exec_ctx.cc145
-rw-r--r--src/core/lib/iomgr/exec_ctx.h183
-rw-r--r--src/core/lib/iomgr/executor.cc (renamed from src/core/lib/iomgr/executor.c)166
-rw-r--r--src/core/lib/iomgr/executor.h8
-rw-r--r--src/core/lib/iomgr/fork_posix.cc89
-rw-r--r--src/core/lib/iomgr/fork_windows.cc39
-rw-r--r--src/core/lib/iomgr/gethostname.h2
-rw-r--r--src/core/lib/iomgr/gethostname_fallback.cc (renamed from src/core/lib/iomgr/gethostname_fallback.c)3
-rw-r--r--src/core/lib/iomgr/gethostname_host_name_max.cc (renamed from src/core/lib/iomgr/gethostname_host_name_max.c)7
-rw-r--r--src/core/lib/iomgr/gethostname_sysconf.cc (renamed from src/core/lib/iomgr/gethostname_sysconf.c)7
-rw-r--r--src/core/lib/iomgr/iocp_windows.cc (renamed from src/core/lib/iomgr/iocp_windows.c)60
-rw-r--r--src/core/lib/iomgr/iocp_windows.h11
-rw-r--r--src/core/lib/iomgr/iomgr.cc (renamed from src/core/lib/iomgr/iomgr.c)133
-rw-r--r--src/core/lib/iomgr/iomgr.h7
-rw-r--r--src/core/lib/iomgr/iomgr_internal.h10
-rw-r--r--src/core/lib/iomgr/iomgr_posix.cc (renamed from src/core/lib/iomgr/iomgr_posix.c)1
-rw-r--r--src/core/lib/iomgr/iomgr_uv.cc (renamed from src/core/lib/iomgr/iomgr_uv.c)7
-rw-r--r--src/core/lib/iomgr/iomgr_windows.cc (renamed from src/core/lib/iomgr/iomgr_windows.c)0
-rw-r--r--src/core/lib/iomgr/is_epollexclusive_available.cc (renamed from src/core/lib/iomgr/is_epollexclusive_available.c)4
-rw-r--r--src/core/lib/iomgr/is_epollexclusive_available.h8
-rw-r--r--src/core/lib/iomgr/load_file.cc (renamed from src/core/lib/iomgr/load_file.c)26
-rw-r--r--src/core/lib/iomgr/load_file.h12
-rw-r--r--src/core/lib/iomgr/lockfree_event.cc (renamed from src/core/lib/iomgr/lockfree_event.c)147
-rw-r--r--src/core/lib/iomgr/lockfree_event.h41
-rw-r--r--src/core/lib/iomgr/network_status_tracker.cc (renamed from src/core/lib/iomgr/network_status_tracker.c)5
-rw-r--r--src/core/lib/iomgr/network_status_tracker.h4
-rw-r--r--src/core/lib/iomgr/polling_entity.cc (renamed from src/core/lib/iomgr/polling_entity.c)44
-rw-r--r--src/core/lib/iomgr/polling_entity.h25
-rw-r--r--src/core/lib/iomgr/pollset.h21
-rw-r--r--src/core/lib/iomgr/pollset_set.h25
-rw-r--r--src/core/lib/iomgr/pollset_set_uv.cc (renamed from src/core/lib/iomgr/pollset_set_uv.c)15
-rw-r--r--src/core/lib/iomgr/pollset_set_windows.cc (renamed from src/core/lib/iomgr/pollset_set_windows.c)15
-rw-r--r--src/core/lib/iomgr/pollset_uv.cc (renamed from src/core/lib/iomgr/pollset_uv.c)65
-rw-r--r--src/core/lib/iomgr/pollset_windows.cc (renamed from src/core/lib/iomgr/pollset_windows.c)63
-rw-r--r--src/core/lib/iomgr/pollset_windows.h13
-rw-r--r--src/core/lib/iomgr/port.h21
-rw-r--r--src/core/lib/iomgr/resolve_address.h19
-rw-r--r--src/core/lib/iomgr/resolve_address_posix.cc (renamed from src/core/lib/iomgr/resolve_address_posix.c)84
-rw-r--r--src/core/lib/iomgr/resolve_address_uv.cc (renamed from src/core/lib/iomgr/resolve_address_uv.c)126
-rw-r--r--src/core/lib/iomgr/resolve_address_windows.cc (renamed from src/core/lib/iomgr/resolve_address_windows.c)73
-rw-r--r--src/core/lib/iomgr/resource_quota.cc (renamed from src/core/lib/iomgr/resource_quota.c)465
-rw-r--r--src/core/lib/iomgr/resource_quota.h65
-rw-r--r--src/core/lib/iomgr/sockaddr_utils.cc (renamed from src/core/lib/iomgr/sockaddr_utils.c)124
-rw-r--r--src/core/lib/iomgr/sockaddr_utils.h30
-rw-r--r--src/core/lib/iomgr/sockaddr_windows.h6
-rw-r--r--src/core/lib/iomgr/socket_factory_posix.cc (renamed from src/core/lib/iomgr/socket_factory_posix.c)40
-rw-r--r--src/core/lib/iomgr/socket_factory_posix.h38
-rw-r--r--src/core/lib/iomgr/socket_mutator.cc (renamed from src/core/lib/iomgr/socket_mutator.c)36
-rw-r--r--src/core/lib/iomgr/socket_mutator.h32
-rw-r--r--src/core/lib/iomgr/socket_utils.h2
-rw-r--r--src/core/lib/iomgr/socket_utils_common_posix.cc (renamed from src/core/lib/iomgr/socket_utils_common_posix.c)58
-rw-r--r--src/core/lib/iomgr/socket_utils_linux.cc (renamed from src/core/lib/iomgr/socket_utils_linux.c)6
-rw-r--r--src/core/lib/iomgr/socket_utils_posix.cc (renamed from src/core/lib/iomgr/socket_utils_posix.c)6
-rw-r--r--src/core/lib/iomgr/socket_utils_posix.h36
-rw-r--r--src/core/lib/iomgr/socket_utils_uv.cc (renamed from src/core/lib/iomgr/socket_utils_uv.c)2
-rw-r--r--src/core/lib/iomgr/socket_utils_windows.cc (renamed from src/core/lib/iomgr/socket_utils_windows.c)8
-rw-r--r--src/core/lib/iomgr/socket_windows.cc (renamed from src/core/lib/iomgr/socket_windows.c)41
-rw-r--r--src/core/lib/iomgr/socket_windows.h28
-rw-r--r--src/core/lib/iomgr/tcp_client.h11
-rw-r--r--src/core/lib/iomgr/tcp_client_posix.cc (renamed from src/core/lib/iomgr/tcp_client_posix.c)257
-rw-r--r--src/core/lib/iomgr/tcp_client_posix.h42
-rw-r--r--src/core/lib/iomgr/tcp_client_uv.cc (renamed from src/core/lib/iomgr/tcp_client_uv.c)112
-rw-r--r--src/core/lib/iomgr/tcp_client_windows.cc (renamed from src/core/lib/iomgr/tcp_client_windows.c)112
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc (renamed from src/core/lib/iomgr/tcp_posix.c)533
-rw-r--r--src/core/lib/iomgr/tcp_posix.h13
-rw-r--r--src/core/lib/iomgr/tcp_server.h43
-rw-r--r--src/core/lib/iomgr/tcp_server_posix.cc (renamed from src/core/lib/iomgr/tcp_server_posix.c)189
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix.h38
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix_common.cc (renamed from src/core/lib/iomgr/tcp_server_utils_posix_common.c)56
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc (renamed from src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c)50
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc (renamed from src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c)4
-rw-r--r--src/core/lib/iomgr/tcp_server_uv.cc (renamed from src/core/lib/iomgr/tcp_server_uv.c)275
-rw-r--r--src/core/lib/iomgr/tcp_server_windows.cc (renamed from src/core/lib/iomgr/tcp_server_windows.c)180
-rw-r--r--src/core/lib/iomgr/tcp_uv.c381
-rw-r--r--src/core/lib/iomgr/tcp_uv.cc423
-rw-r--r--src/core/lib/iomgr/tcp_uv.h14
-rw-r--r--src/core/lib/iomgr/tcp_windows.cc (renamed from src/core/lib/iomgr/tcp_windows.c)221
-rw-r--r--src/core/lib/iomgr/tcp_windows.h13
-rw-r--r--src/core/lib/iomgr/time_averaged_stats.cc (renamed from src/core/lib/iomgr/time_averaged_stats.c)0
-rw-r--r--src/core/lib/iomgr/timer.h16
-rw-r--r--src/core/lib/iomgr/timer_generic.cc (renamed from src/core/lib/iomgr/timer_generic.c)414
-rw-r--r--src/core/lib/iomgr/timer_generic.h9
-rw-r--r--src/core/lib/iomgr/timer_heap.cc (renamed from src/core/lib/iomgr/timer_heap.c)41
-rw-r--r--src/core/lib/iomgr/timer_heap.h16
-rw-r--r--src/core/lib/iomgr/timer_manager.cc (renamed from src/core/lib/iomgr/timer_manager.c)120
-rw-r--r--src/core/lib/iomgr/timer_uv.cc (renamed from src/core/lib/iomgr/timer_uv.c)54
-rw-r--r--src/core/lib/iomgr/timer_uv.h4
-rw-r--r--src/core/lib/iomgr/udp_server.cc (renamed from src/core/lib/iomgr/udp_server.c)318
-rw-r--r--src/core/lib/iomgr/udp_server.h41
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix.cc (renamed from src/core/lib/iomgr/unix_sockets_posix.c)43
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix.h12
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix_noop.cc (renamed from src/core/lib/iomgr/unix_sockets_posix_noop.c)10
-rw-r--r--src/core/lib/iomgr/wakeup_fd_cv.cc (renamed from src/core/lib/iomgr/wakeup_fd_cv.c)12
-rw-r--r--src/core/lib/iomgr/wakeup_fd_cv.h26
-rw-r--r--src/core/lib/iomgr/wakeup_fd_eventfd.cc (renamed from src/core/lib/iomgr/wakeup_fd_eventfd.c)0
-rw-r--r--src/core/lib/iomgr/wakeup_fd_nospecial.cc (renamed from src/core/lib/iomgr/wakeup_fd_nospecial.c)2
-rw-r--r--src/core/lib/iomgr/wakeup_fd_pipe.cc (renamed from src/core/lib/iomgr/wakeup_fd_pipe.c)1
-rw-r--r--src/core/lib/iomgr/wakeup_fd_pipe.h2
-rw-r--r--src/core/lib/iomgr/wakeup_fd_posix.cc (renamed from src/core/lib/iomgr/wakeup_fd_posix.c)13
-rw-r--r--src/core/lib/json/json.cc (renamed from src/core/lib/json/json.c)0
-rw-r--r--src/core/lib/json/json_reader.cc (renamed from src/core/lib/json/json_reader.c)36
-rw-r--r--src/core/lib/json/json_reader.h36
-rw-r--r--src/core/lib/json/json_string.cc (renamed from src/core/lib/json/json_string.c)114
-rw-r--r--src/core/lib/json/json_writer.cc (renamed from src/core/lib/json/json_writer.c)40
-rw-r--r--src/core/lib/json/json_writer.h30
-rw-r--r--src/core/lib/profiling/basic_timers.cc (renamed from src/core/lib/profiling/basic_timers.c)73
-rw-r--r--src/core/lib/profiling/stap_timers.cc (renamed from src/core/lib/profiling/stap_timers.c)10
-rw-r--r--src/core/lib/profiling/timers.h20
-rw-r--r--src/core/lib/security/context/security_context.cc (renamed from src/core/lib/security/context/security_context.c)210
-rw-r--r--src/core/lib/security/context/security_context.h64
-rw-r--r--src/core/lib/security/credentials/composite/composite_credentials.cc (renamed from src/core/lib/security/credentials/composite/composite_credentials.c)189
-rw-r--r--src/core/lib/security/credentials/composite/composite_credentials.h18
-rw-r--r--src/core/lib/security/credentials/credentials.c287
-rw-r--r--src/core/lib/security/credentials/credentials.cc283
-rw-r--r--src/core/lib/security/credentials/credentials.h141
-rw-r--r--src/core/lib/security/credentials/credentials_metadata.cc (renamed from src/core/lib/security/credentials/credentials_metadata.c)15
-rw-r--r--src/core/lib/security/credentials/fake/fake_credentials.cc (renamed from src/core/lib/security/credentials/fake/fake_credentials.c)83
-rw-r--r--src/core/lib/security/credentials/fake/fake_credentials.h10
-rw-r--r--src/core/lib/security/credentials/google_default/credentials_generic.cc (renamed from src/core/lib/security/credentials/google_default/credentials_generic.c)16
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.cc (renamed from src/core/lib/security/credentials/google_default/google_default_credentials.c)154
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.h2
-rw-r--r--src/core/lib/security/credentials/iam/iam_credentials.cc (renamed from src/core/lib/security/credentials/iam/iam_credentials.c)47
-rw-r--r--src/core/lib/security/credentials/jwt/json_token.cc (renamed from src/core/lib/security/credentials/jwt/json_token.c)157
-rw-r--r--src/core/lib/security/credentials/jwt/json_token.h30
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.cc (renamed from src/core/lib/security/credentials/jwt/jwt_credentials.c)102
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.h7
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.cc (renamed from src/core/lib/security/credentials/jwt/jwt_verifier.c)572
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.h56
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.cc (renamed from src/core/lib/security/credentials/oauth2/oauth2_credentials.c)325
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.h43
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.c189
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.cc265
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.h14
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.c194
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.cc339
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.h19
-rw-r--r--src/core/lib/security/transport/auth_filters.h8
-rw-r--r--src/core/lib/security/transport/client_auth_filter.cc (renamed from src/core/lib/security/transport/client_auth_filter.c)301
-rw-r--r--src/core/lib/security/transport/lb_targets_info.cc (renamed from src/core/lib/security/transport/lb_targets_info.c)29
-rw-r--r--src/core/lib/security/transport/lb_targets_info.h6
-rw-r--r--src/core/lib/security/transport/secure_endpoint.cc (renamed from src/core/lib/security/transport/secure_endpoint.c)228
-rw-r--r--src/core/lib/security/transport/secure_endpoint.h10
-rw-r--r--src/core/lib/security/transport/security_connector.c914
-rw-r--r--src/core/lib/security/transport/security_connector.cc1097
-rw-r--r--src/core/lib/security/transport/security_connector.h169
-rw-r--r--src/core/lib/security/transport/security_handshaker.cc (renamed from src/core/lib/security/transport/security_handshaker.c)346
-rw-r--r--src/core/lib/security/transport/security_handshaker.h5
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc (renamed from src/core/lib/security/transport/server_auth_filter.c)171
-rw-r--r--src/core/lib/security/transport/tsi_error.cc (renamed from src/core/lib/security/transport/tsi_error.c)2
-rw-r--r--src/core/lib/security/transport/tsi_error.h2
-rw-r--r--src/core/lib/security/util/json_util.cc (renamed from src/core/lib/security/util/json_util.c)22
-rw-r--r--src/core/lib/security/util/json_util.h8
-rw-r--r--src/core/lib/slice/b64.cc (renamed from src/core/lib/slice/b64.c)37
-rw-r--r--src/core/lib/slice/b64.h11
-rw-r--r--src/core/lib/slice/percent_encoding.cc (renamed from src/core/lib/slice/percent_encoding.c)30
-rw-r--r--src/core/lib/slice/percent_encoding.h6
-rw-r--r--src/core/lib/slice/slice.cc (renamed from src/core/lib/slice/slice.c)135
-rw-r--r--src/core/lib/slice/slice_buffer.cc (renamed from src/core/lib/slice/slice_buffer.c)91
-rw-r--r--src/core/lib/slice/slice_hash_table.cc (renamed from src/core/lib/slice/slice_hash_table.c)26
-rw-r--r--src/core/lib/slice/slice_hash_table.h20
-rw-r--r--src/core/lib/slice/slice_intern.cc (renamed from src/core/lib/slice/slice_intern.c)72
-rw-r--r--src/core/lib/slice/slice_internal.h12
-rw-r--r--src/core/lib/slice/slice_string_helpers.cc (renamed from src/core/lib/slice/slice_string_helpers.c)63
-rw-r--r--src/core/lib/slice/slice_string_helpers.h20
-rw-r--r--src/core/lib/support/backoff.c72
-rw-r--r--src/core/lib/support/backoff.h56
-rw-r--r--src/core/lib/support/mpscq.c79
-rw-r--r--src/core/lib/support/mpscq.h53
-rw-r--r--src/core/lib/support/stack_lockfree.c137
-rw-r--r--src/core/lib/support/stack_lockfree.h38
-rw-r--r--src/core/lib/support/thd_posix.c80
-rw-r--r--src/core/lib/surface/alarm.cc (renamed from src/core/lib/surface/alarm.c)80
-rw-r--r--src/core/lib/surface/alarm_internal.h4
-rw-r--r--src/core/lib/surface/api_trace.cc (renamed from src/core/lib/surface/api_trace.c)2
-rw-r--r--src/core/lib/surface/api_trace.h4
-rw-r--r--src/core/lib/surface/byte_buffer.cc (renamed from src/core/lib/surface/byte_buffer.c)31
-rw-r--r--src/core/lib/surface/byte_buffer_reader.cc (renamed from src/core/lib/surface/byte_buffer_reader.c)41
-rw-r--r--src/core/lib/surface/call.cc (renamed from src/core/lib/surface/call.c)1242
-rw-r--r--src/core/lib/surface/call.h85
-rw-r--r--src/core/lib/surface/call_details.cc (renamed from src/core/lib/surface/call_details.c)7
-rw-r--r--src/core/lib/surface/call_log_batch.cc (renamed from src/core/lib/surface/call_log_batch.c)26
-rw-r--r--src/core/lib/surface/call_test_only.h28
-rw-r--r--src/core/lib/surface/channel.cc (renamed from src/core/lib/surface/channel.c)281
-rw-r--r--src/core/lib/surface/channel.h47
-rw-r--r--src/core/lib/surface/channel_init.cc (renamed from src/core/lib/surface/channel_init.c)27
-rw-r--r--src/core/lib/surface/channel_init.h18
-rw-r--r--src/core/lib/surface/channel_ping.cc (renamed from src/core/lib/surface/channel_ping.c)34
-rw-r--r--src/core/lib/surface/channel_stack_type.cc (renamed from src/core/lib/surface/channel_stack_type.c)2
-rw-r--r--src/core/lib/surface/channel_stack_type.h2
-rw-r--r--src/core/lib/surface/completion_queue.c1249
-rw-r--r--src/core/lib/surface/completion_queue.cc1268
-rw-r--r--src/core/lib/surface/completion_queue.h69
-rw-r--r--src/core/lib/surface/completion_queue_factory.cc (renamed from src/core/lib/surface/completion_queue_factory.c)2
-rw-r--r--src/core/lib/surface/event_string.cc (renamed from src/core/lib/surface/event_string.c)20
-rw-r--r--src/core/lib/surface/event_string.h2
-rw-r--r--src/core/lib/surface/init.cc (renamed from src/core/lib/surface/init.c)97
-rw-r--r--src/core/lib/surface/init_secure.cc (renamed from src/core/lib/surface/init_secure.c)33
-rw-r--r--src/core/lib/surface/init_unsecure.cc (renamed from src/core/lib/surface/init_unsecure.c)0
-rw-r--r--src/core/lib/surface/lame_client.cc105
-rw-r--r--src/core/lib/surface/metadata_array.cc (renamed from src/core/lib/surface/metadata_array.c)0
-rw-r--r--src/core/lib/surface/server.cc (renamed from src/core/lib/surface/server.c)918
-rw-r--r--src/core/lib/surface/server.h29
-rw-r--r--src/core/lib/surface/validate_metadata.cc (renamed from src/core/lib/surface/validate_metadata.c)19
-rw-r--r--src/core/lib/surface/validate_metadata.h4
-rw-r--r--src/core/lib/surface/version.cc (renamed from src/core/lib/surface/version.c)4
-rw-r--r--src/core/lib/transport/bdp_estimator.c110
-rw-r--r--src/core/lib/transport/bdp_estimator.cc84
-rw-r--r--src/core/lib/transport/bdp_estimator.h109
-rw-r--r--src/core/lib/transport/byte_stream.c187
-rw-r--r--src/core/lib/transport/byte_stream.cc173
-rw-r--r--src/core/lib/transport/byte_stream.h59
-rw-r--r--src/core/lib/transport/connectivity_state.cc (renamed from src/core/lib/transport/connectivity_state.c)86
-rw-r--r--src/core/lib/transport/connectivity_state.h40
-rw-r--r--src/core/lib/transport/error_utils.cc (renamed from src/core/lib/transport/error_utils.c)44
-rw-r--r--src/core/lib/transport/error_utils.h15
-rw-r--r--src/core/lib/transport/metadata.cc (renamed from src/core/lib/transport/metadata.c)204
-rw-r--r--src/core/lib/transport/metadata.h54
-rw-r--r--src/core/lib/transport/metadata_batch.c315
-rw-r--r--src/core/lib/transport/metadata_batch.cc303
-rw-r--r--src/core/lib/transport/metadata_batch.h93
-rw-r--r--src/core/lib/transport/pid_controller.c63
-rw-r--r--src/core/lib/transport/pid_controller.cc48
-rw-r--r--src/core/lib/transport/pid_controller.h116
-rw-r--r--src/core/lib/transport/service_config.cc (renamed from src/core/lib/transport/service_config.c)124
-rw-r--r--src/core/lib/transport/service_config.h9
-rw-r--r--src/core/lib/transport/static_metadata.cc (renamed from src/core/lib/transport/static_metadata.c)458
-rw-r--r--src/core/lib/transport/static_metadata.h197
-rw-r--r--src/core/lib/transport/status_conversion.cc (renamed from src/core/lib/transport/status_conversion.c)4
-rw-r--r--src/core/lib/transport/status_conversion.h3
-rw-r--r--src/core/lib/transport/timeout_encoding.cc (renamed from src/core/lib/transport/timeout_encoding.c)91
-rw-r--r--src/core/lib/transport/timeout_encoding.h7
-rw-r--r--src/core/lib/transport/transport.c289
-rw-r--r--src/core/lib/transport/transport.cc275
-rw-r--r--src/core/lib/transport/transport.h177
-rw-r--r--src/core/lib/transport/transport_impl.h35
-rw-r--r--src/core/lib/transport/transport_op_string.cc (renamed from src/core/lib/transport/transport_op_string.c)64
-rw-r--r--src/core/plugin_registry/grpc_cronet_plugin_registry.cc (renamed from src/core/plugin_registry/grpc_cronet_plugin_registry.c)28
-rw-r--r--src/core/plugin_registry/grpc_plugin_registry.cc (renamed from src/core/plugin_registry/grpc_unsecure_plugin_registry.c)88
-rw-r--r--src/core/plugin_registry/grpc_unsecure_plugin_registry.cc (renamed from src/core/plugin_registry/grpc_plugin_registry.c)88
-rw-r--r--src/core/tsi/alts_transport_security.cc (renamed from src/core/tsi/gts_transport_security.c)26
-rw-r--r--src/core/tsi/alts_transport_security.h (renamed from src/core/tsi/gts_transport_security.h)18
-rw-r--r--src/core/tsi/fake_transport_security.cc (renamed from src/core/tsi/fake_transport_security.c)276
-rw-r--r--src/core/tsi/fake_transport_security.h18
-rw-r--r--src/core/tsi/ssl_transport_security.cc (renamed from src/core/tsi/ssl_transport_security.c)656
-rw-r--r--src/core/tsi/ssl_transport_security.h58
-rw-r--r--src/core/tsi/transport_security.cc (renamed from src/core/tsi/transport_security.c)181
-rw-r--r--src/core/tsi/transport_security.h118
-rw-r--r--src/core/tsi/transport_security_adapter.cc (renamed from src/core/tsi/transport_security_adapter.c)113
-rw-r--r--src/core/tsi/transport_security_adapter.h12
-rw-r--r--src/core/tsi/transport_security_grpc.c71
-rw-r--r--src/core/tsi/transport_security_grpc.cc64
-rw-r--r--src/core/tsi/transport_security_grpc.h42
-rw-r--r--src/core/tsi/transport_security_interface.h90
-rw-r--r--src/cpp/client/channel_cc.cc224
-rw-r--r--src/cpp/client/client_context.cc2
-rw-r--r--src/cpp/client/create_channel.cc13
-rw-r--r--src/cpp/client/generic_stub.cc11
-rw-r--r--src/cpp/client/secure_credentials.cc90
-rw-r--r--src/cpp/client/secure_credentials.h17
-rw-r--r--src/cpp/common/channel_arguments.cc18
-rw-r--r--src/cpp/common/channel_filter.cc53
-rw-r--r--src/cpp/common/channel_filter.h195
-rw-r--r--src/cpp/common/completion_queue_cc.cc27
-rw-r--r--src/cpp/common/core_codegen.cc9
-rw-r--r--src/cpp/common/version_cc.cc4
-rw-r--r--src/cpp/ext/proto_server_reflection.cc10
-rw-r--r--src/cpp/server/channel_argument_option.cc16
-rw-r--r--src/cpp/server/health/default_health_check_service.cc9
-rw-r--r--src/cpp/server/health/default_health_check_service.h2
-rw-r--r--src/cpp/server/health/health_check_service.cc2
-rw-r--r--src/cpp/server/server_cc.cc76
-rw-r--r--src/cpp/server/server_context.cc16
-rw-r--r--src/cpp/server/server_posix.cc2
-rw-r--r--src/cpp/util/core_stats.h2
-rw-r--r--src/cpp/util/error_details.cc3
-rw-r--r--src/cpp/util/time_cc.cc2
-rwxr-xr-xsrc/csharp/Grpc.Auth/Grpc.Auth.csproj4
-rwxr-xr-xsrc/csharp/Grpc.Core.Testing/Grpc.Core.Testing.csproj4
-rw-r--r--src/csharp/Grpc.Core.Tests/CallCancellationTest.cs182
-rw-r--r--src/csharp/Grpc.Core.Tests/ChannelConnectivityTest.cs86
-rw-r--r--src/csharp/Grpc.Core.Tests/ClientServerTest.cs97
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs28
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs106
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs2
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/DefaultObjectPoolTest.cs95
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs58
-rw-r--r--src/csharp/Grpc.Core.Tests/PInvokeTest.cs4
-rw-r--r--src/csharp/Grpc.Core/AsyncClientStreamingCall.cs16
-rw-r--r--src/csharp/Grpc.Core/AsyncDuplexStreamingCall.cs16
-rw-r--r--src/csharp/Grpc.Core/AsyncServerStreamingCall.cs14
-rw-r--r--src/csharp/Grpc.Core/AsyncUnaryCall.cs15
-rw-r--r--src/csharp/Grpc.Core/Channel.cs59
-rwxr-xr-xsrc/csharp/Grpc.Core/Grpc.Core.csproj4
-rw-r--r--src/csharp/Grpc.Core/GrpcEnvironment.cs62
-rw-r--r--src/csharp/Grpc.Core/IAsyncStreamReader.cs7
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCall.cs68
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCallBase.cs20
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCallServer.cs42
-rw-r--r--src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs82
-rw-r--r--src/csharp/Grpc.Core/Internal/CallSafeHandle.cs72
-rw-r--r--src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs5
-rw-r--r--src/csharp/Grpc.Core/Internal/ClientResponseStream.cs20
-rw-r--r--src/csharp/Grpc.Core/Internal/CompletionRegistry.cs103
-rw-r--r--src/csharp/Grpc.Core/Internal/DefaultObjectPool.cs205
-rw-r--r--src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs14
-rw-r--r--src/csharp/Grpc.Core/Internal/INativeCall.cs57
-rw-r--r--src/csharp/Grpc.Core/Internal/IObjectPool.cs (renamed from src/node/test/test_service.proto)40
-rw-r--r--src/csharp/Grpc.Core/Internal/IPooledObject.cs (renamed from src/node/test/test_messages.proto)47
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs20
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeMethods.cs10
-rw-r--r--src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs52
-rw-r--r--src/csharp/Grpc.Core/Internal/ServerCallHandler.cs12
-rw-r--r--src/csharp/Grpc.Core/Internal/ServerRequestStream.cs11
-rw-r--r--src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs10
-rw-r--r--src/csharp/Grpc.Core/Server.cs3
-rwxr-xr-xsrc/csharp/Grpc.Core/SourceLink.csproj.include19
-rwxr-xr-xsrc/csharp/Grpc.Core/Version.csproj.include2
-rw-r--r--src/csharp/Grpc.Core/VersionInfo.cs4
-rw-r--r--src/csharp/Grpc.Examples/MathGrpc.cs6
-rwxr-xr-xsrc/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj4
-rw-r--r--src/csharp/Grpc.HealthCheck/HealthGrpc.cs6
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ClientRunners.cs28
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Control.cs30
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs43
-rw-r--r--src/csharp/Grpc.IntegrationTesting/CoreStats/Stats.cs623
-rw-r--r--src/csharp/Grpc.IntegrationTesting/EchoMessages.cs48
-rw-r--r--src/csharp/Grpc.IntegrationTesting/InteropClient.cs2
-rw-r--r--src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs61
-rw-r--r--src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs6
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Payloads.cs15
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ServerRunners.cs16
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Services.cs41
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs6
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Stats.cs110
-rw-r--r--src/csharp/Grpc.IntegrationTesting/StressTestClient.cs6
-rw-r--r--src/csharp/Grpc.IntegrationTesting/TestGrpc.cs6
-rw-r--r--src/csharp/Grpc.IntegrationTesting/TimeStats.cs90
-rw-r--r--src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs63
-rw-r--r--src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs78
-rw-r--r--src/csharp/Grpc.Microbenchmarks/GCStats.cs69
-rw-r--r--src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj4
-rw-r--r--src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs64
-rw-r--r--src/csharp/Grpc.Microbenchmarks/Program.cs70
-rw-r--r--src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs19
-rw-r--r--src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs3
-rwxr-xr-xsrc/csharp/Grpc.Reflection/Grpc.Reflection.csproj4
-rw-r--r--src/csharp/Grpc.Reflection/Reflection.cs25
-rw-r--r--src/csharp/Grpc.Reflection/ReflectionGrpc.cs6
-rwxr-xr-xsrc/csharp/build_packages_dotnetcli.bat2
-rwxr-xr-xsrc/csharp/build_packages_dotnetcli.sh4
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c395
-rwxr-xr-xsrc/csharp/generate_proto_csharp.sh5
-rw-r--r--src/csharp/tests.json3
-rw-r--r--src/node/.jshintignore1
-rw-r--r--src/node/README.md36
-rw-r--r--src/node/ext/byte_buffer.cc79
-rw-r--r--src/node/ext/byte_buffer.h41
-rw-r--r--src/node/ext/call.cc815
-rw-r--r--src/node/ext/call.h119
-rw-r--r--src/node/ext/call_credentials.cc272
-rw-r--r--src/node/ext/call_credentials.h91
-rw-r--r--src/node/ext/channel.cc272
-rw-r--r--src/node/ext/channel.h68
-rw-r--r--src/node/ext/channel_credentials.cc188
-rw-r--r--src/node/ext/channel_credentials.h64
-rw-r--r--src/node/ext/completion_queue.cc80
-rw-r--r--src/node/ext/completion_queue.h32
-rw-r--r--src/node/ext/node_grpc.cc311
-rw-r--r--src/node/ext/server.cc342
-rw-r--r--src/node/ext/server.h69
-rw-r--r--src/node/ext/server_credentials.cc190
-rw-r--r--src/node/ext/server_credentials.h62
-rw-r--r--src/node/ext/slice.cc90
-rw-r--r--src/node/ext/slice.h38
-rw-r--r--src/node/ext/timeval.cc53
-rw-r--r--src/node/health_check/LICENSE186
-rw-r--r--src/node/health_check/health.js52
-rw-r--r--src/node/health_check/package.json29
-rw-r--r--src/node/health_check/v1/health_grpc_pb.js59
-rw-r--r--src/node/health_check/v1/health_pb.js342
-rw-r--r--src/node/index.js255
-rw-r--r--src/node/interop/async_delay_queue.js64
-rw-r--r--src/node/interop/interop_client.js621
-rw-r--r--src/node/interop/interop_server.js241
-rw-r--r--src/node/jsdoc_conf.json22
-rw-r--r--src/node/performance/benchmark_client.js365
-rw-r--r--src/node/performance/benchmark_client_express.js287
-rw-r--r--src/node/performance/benchmark_server.js189
-rw-r--r--src/node/performance/benchmark_server_express.js96
-rw-r--r--src/node/performance/generic_service.js40
-rw-r--r--src/node/performance/histogram.js165
-rw-r--r--src/node/performance/worker.js50
-rw-r--r--src/node/performance/worker_service_impl.js183
-rw-r--r--src/node/src/client.js951
-rw-r--r--src/node/src/common.js172
-rw-r--r--src/node/src/constants.js236
-rw-r--r--src/node/src/credentials.js207
-rw-r--r--src/node/src/grpc_extension.js32
-rw-r--r--src/node/src/metadata.js172
-rw-r--r--src/node/src/protobuf_js_5_common.js171
-rw-r--r--src/node/src/protobuf_js_6_common.js160
-rw-r--r--src/node/src/server.js965
-rw-r--r--src/node/stress/metrics_client.js46
-rw-r--r--src/node/stress/metrics_server.js72
-rw-r--r--src/node/stress/stress_client.js111
-rw-r--r--src/node/test/async_test.js83
-rw-r--r--src/node/test/call_test.js339
-rw-r--r--src/node/test/channel_test.js181
-rw-r--r--src/node/test/common_test.js190
-rw-r--r--src/node/test/credentials_test.js452
-rw-r--r--src/node/test/data/README1
-rw-r--r--src/node/test/data/ca.pem15
-rw-r--r--src/node/test/data/server1.key16
-rw-r--r--src/node/test/data/server1.pem16
-rw-r--r--src/node/test/echo_service.proto24
-rw-r--r--src/node/test/end_to_end_test.js292
-rw-r--r--src/node/test/health_test.js103
-rw-r--r--src/node/test/interop_sanity_test.js94
-rw-r--r--src/node/test/math/math_grpc_pb.js125
-rw-r--r--src/node/test/math/math_pb.js866
-rw-r--r--src/node/test/math/math_server.js124
-rw-r--r--src/node/test/math_client_test.js140
-rw-r--r--src/node/test/metadata_test.js178
-rw-r--r--src/node/test/numbers.txt496
-rw-r--r--src/node/test/server_test.js138
-rw-r--r--src/node/test/surface_test.js1424
-rw-r--r--src/node/test/test_service.json55
-rwxr-xr-xsrc/node/tools/bin/protoc.js46
-rwxr-xr-xsrc/node/tools/bin/protoc_plugin.js43
-rw-r--r--src/node/tools/index.js26
-rw-r--r--src/node/tools/package.json41
-rw-r--r--src/objective-c/!ProtoCompiler-gRPCPlugin.podspec4
-rw-r--r--src/objective-c/!ProtoCompiler.podspec2
-rw-r--r--src/objective-c/BoringSSL.podspec20
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+ChannelArg.h10
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+ChannelArg.m21
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m17
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.h3
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m9
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h10
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m16
-rw-r--r--src/objective-c/GRPCClient/private/version.h2
-rw-r--r--src/objective-c/README.md12
-rw-r--r--src/objective-c/RxLibrary/GRXConcurrentWriteable.h2
-rw-r--r--src/objective-c/RxLibrary/GRXConcurrentWriteable.m2
-rw-r--r--src/objective-c/RxLibrary/GRXImmediateWriter.h2
-rw-r--r--src/objective-c/RxLibrary/GRXImmediateWriter.m2
-rw-r--r--src/objective-c/RxLibrary/GRXWriter+Immediate.h2
-rw-r--r--src/objective-c/RxLibrary/GRXWriter+Immediate.m2
-rw-r--r--src/objective-c/RxLibrary/NSEnumerator+GRXUtil.h2
-rw-r--r--src/objective-c/RxLibrary/NSEnumerator+GRXUtil.m2
-rw-r--r--src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.h2
-rw-r--r--src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m4
-rw-r--r--src/objective-c/examples/Sample/Podfile2
-rw-r--r--src/objective-c/examples/SwiftSample/Podfile2
-rw-r--r--src/objective-c/tests/Connectivity/Podfile2
-rw-r--r--src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm (renamed from src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m)107
-rw-r--r--src/objective-c/tests/CronetUnitTests/CronetUnitTests.m14
-rw-r--r--src/objective-c/tests/GRPCClientTests.m45
-rw-r--r--src/objective-c/tests/InteropTests.m35
-rw-r--r--src/objective-c/tests/Podfile2
-rw-r--r--src/objective-c/tests/RemoteTestClient/RemoteTest.podspec2
-rw-r--r--src/objective-c/tests/RemoteTestClient/messages.proto68
-rw-r--r--src/objective-c/tests/RxLibraryUnitTests.m4
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/project.pbxproj95
-rwxr-xr-xsrc/objective-c/tests/run_tests.sh55
-rw-r--r--src/objective-c/tests/version.h (renamed from src/core/ext/census/census_init.c)20
-rw-r--r--src/php/composer.json2
-rw-r--r--src/php/ext/grpc/call.c25
-rw-r--r--src/php/ext/grpc/call.h3
-rw-r--r--src/php/ext/grpc/call_credentials.c53
-rwxr-xr-xsrc/php/ext/grpc/call_credentials.h9
-rw-r--r--src/php/ext/grpc/channel.c137
-rwxr-xr-xsrc/php/ext/grpc/channel.h5
-rw-r--r--src/php/ext/grpc/channel_credentials.c22
-rw-r--r--src/php/ext/grpc/php7_wrapper.h2
-rw-r--r--src/php/ext/grpc/php_grpc.c3
-rw-r--r--src/php/ext/grpc/server.c4
-rw-r--r--src/php/ext/grpc/version.h2
-rw-r--r--src/php/lib/Grpc/BaseStub.php8
-rw-r--r--src/php/tests/qps/client.php56
-rw-r--r--src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php33
-rw-r--r--src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php215
-rw-r--r--src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php21
-rw-r--r--src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php53
-rw-r--r--src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php47
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Core/Bucket.php75
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Core/Histogram.php49
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Core/Metric.php102
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Core/Stats.php49
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php68
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php21
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php24
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php34
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php27
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php288
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php147
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php15
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php12
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php4
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php4
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php2
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php19
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php26
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php76
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php38
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php27
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/Mark.php21
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/Payload.php38
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php38
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php8
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php21
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php34
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php13
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php32
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php15
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php (renamed from examples/php/helloworld_grpc_pb.php)29
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php24
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php57
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php18
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php144
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php193
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php352
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php21
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php52
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php27
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php211
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php151
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php49
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php12
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php24
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php148
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php57
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php42
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php21
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php82
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php23
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/Void.php2
-rw-r--r--src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php40
-rw-r--r--src/php/tests/qps/histogram.php93
-rw-r--r--src/php/tests/unit_tests/CallCredentials2Test.php4
-rw-r--r--src/php/tests/unit_tests/ChannelTest.php10
-rw-r--r--src/proto/grpc/lb/v1/load_balancer.proto7
-rw-r--r--src/proto/grpc/testing/BUILD1
-rw-r--r--src/proto/grpc/testing/control.proto3
-rw-r--r--src/proto/grpc/testing/echo_messages.proto1
-rw-r--r--src/proto/grpc/testing/proxy-service.proto2
-rw-r--r--src/proto/grpc/testing/services.proto1
-rw-r--r--src/python/grpcio/commands.py24
-rw-r--r--src/python/grpcio/grpc/__init__.py1646
-rw-r--r--src/python/grpcio/grpc/_auth.py6
-rw-r--r--src/python/grpcio/grpc/_channel.py264
-rw-r--r--src/python/grpcio/grpc/_common.py27
-rw-r--r--src/python/grpcio/grpc/_credential_composition.py33
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi40
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi88
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi34
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi57
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi50
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi87
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi416
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi45
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi55
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi86
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi29
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi26
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi62
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi109
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi237
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi91
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi610
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi94
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi58
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi87
-rw-r--r--[-rwxr-xr-x]src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi (renamed from tools/run_tests/helper_scripts/pre_build_node_electron.sh)11
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi30
-rw-r--r--src/python/grpcio/grpc/_cython/cygrpc.pxd6
-rw-r--r--src/python/grpcio/grpc/_cython/cygrpc.pyx6
-rw-r--r--src/python/grpcio/grpc/_grpcio_metadata.py2
-rw-r--r--src/python/grpcio/grpc/_interceptor.py350
-rw-r--r--src/python/grpcio/grpc/_plugin_wrapping.py130
-rw-r--r--src/python/grpcio/grpc/_server.py246
-rw-r--r--src/python/grpcio/grpc/_utilities.py12
-rw-r--r--src/python/grpcio/grpc/beta/_client_adaptations.py138
-rw-r--r--src/python/grpcio/grpc/beta/_metadata.py52
-rw-r--r--src/python/grpcio/grpc/beta/_server_adaptations.py85
-rw-r--r--src/python/grpcio/grpc/beta/implementations.py18
-rw-r--r--src/python/grpcio/grpc/framework/foundation/callable_util.py4
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/base/utilities.py15
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/face/face.py15
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py1340
-rw-r--r--src/python/grpcio/grpc_version.py2
-rw-r--r--src/python/grpcio/support.py10
-rw-r--r--src/python/grpcio_health_checking/MANIFEST.in3
-rw-r--r--src/python/grpcio_health_checking/grpc_version.py2
-rw-r--r--src/python/grpcio_health_checking/health_commands.py6
-rw-r--r--src/python/grpcio_health_checking/setup.py51
-rw-r--r--src/python/grpcio_reflection/MANIFEST.in3
-rw-r--r--src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py29
-rw-r--r--src/python/grpcio_reflection/grpc_version.py2
-rw-r--r--src/python/grpcio_reflection/reflection_commands.py6
-rw-r--r--src/python/grpcio_reflection/setup.py51
-rw-r--r--src/python/grpcio_testing/grpc_testing/__init__.py16
-rw-r--r--src/python/grpcio_testing/grpc_testing/_channel/__init__.py2
-rw-r--r--src/python/grpcio_testing/grpc_testing/_channel/_channel.py26
-rw-r--r--src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py8
-rw-r--r--src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py9
-rw-r--r--src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py23
-rw-r--r--src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py25
-rw-r--r--src/python/grpcio_testing/grpc_testing/_common.py54
-rw-r--r--src/python/grpcio_testing/grpc_testing/_server/__init__.py4
-rw-r--r--src/python/grpcio_testing/grpc_testing/_server/_handler.py8
-rw-r--r--src/python/grpcio_testing/grpc_testing/_server/_rpc.py5
-rw-r--r--src/python/grpcio_testing/grpc_testing/_server/_server.py74
-rw-r--r--src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py3
-rw-r--r--src/python/grpcio_testing/grpc_testing/_time.py8
-rw-r--r--src/python/grpcio_testing/grpc_version.py2
-rw-r--r--src/python/grpcio_testing/setup.py6
-rw-r--r--src/python/grpcio_tests/grpc_version.py2
-rw-r--r--src/python/grpcio_tests/setup.py7
-rw-r--r--src/python/grpcio_tests/tests/_loader.py4
-rw-r--r--src/python/grpcio_tests/tests/_result.py31
-rw-r--r--src/python/grpcio_tests/tests/_runner.py8
-rw-r--r--src/python/grpcio_tests/tests/health_check/_health_servicer_test.py6
-rw-r--r--src/python/grpcio_tests/tests/http2/negative_http2_client.py8
-rw-r--r--src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py4
-rw-r--r--src/python/grpcio_tests/tests/interop/_intraop_test_case.py4
-rw-r--r--src/python/grpcio_tests/tests/interop/_secure_intraop_test.py15
-rw-r--r--src/python/grpcio_tests/tests/interop/client.py37
-rw-r--r--src/python/grpcio_tests/tests/interop/methods.py100
-rw-r--r--src/python/grpcio_tests/tests/interop/server.py14
-rw-r--r--src/python/grpcio_tests/tests/protoc_plugin/_python_plugin_test.py27
-rw-r--r--src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py55
-rw-r--r--src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py26
-rw-r--r--src/python/grpcio_tests/tests/qps/benchmark_client.py3
-rw-r--r--src/python/grpcio_tests/tests/qps/qps_worker.py4
-rw-r--r--src/python/grpcio_tests/tests/qps/worker_server.py20
-rw-r--r--src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py81
-rw-r--r--src/python/grpcio_tests/tests/stress/client.py6
-rw-r--r--src/python/grpcio_tests/tests/testing/_client_application.py8
-rw-r--r--src/python/grpcio_tests/tests/testing/_client_test.py6
-rw-r--r--src/python/grpcio_tests/tests/testing/_server_application.py6
-rw-r--r--src/python/grpcio_tests/tests/testing/_server_test.py11
-rw-r--r--src/python/grpcio_tests/tests/testing/_time_test.py4
-rw-r--r--src/python/grpcio_tests/tests/tests.json8
-rw-r--r--src/python/grpcio_tests/tests/unit/_api_test.py77
-rw-r--r--src/python/grpcio_tests/tests/unit/_auth_context_test.py27
-rw-r--r--src/python/grpcio_tests/tests/unit/_auth_test.py6
-rw-r--r--src/python/grpcio_tests/tests/unit/_channel_args_test.py9
-rw-r--r--src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py2
-rw-r--r--src/python/grpcio_tests/tests/unit/_compression_test.py14
-rw-r--r--src/python/grpcio_tests/tests/unit/_credentials_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py72
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_channel_test.py13
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_common.py32
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py81
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py79
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py78
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_server_test.py49
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py333
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/test_utilities.py2
-rw-r--r--src/python/grpcio_tests/tests/unit/_empty_message_test.py15
-rw-r--r--src/python/grpcio_tests/tests/unit/_exit_scenarios.py8
-rw-r--r--src/python/grpcio_tests/tests/unit/_interceptor_test.py601
-rw-r--r--src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py16
-rw-r--r--src/python/grpcio_tests/tests/unit/_invocation_defects_test.py52
-rw-r--r--src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py320
-rw-r--r--src/python/grpcio_tests/tests/unit/_metadata_test.py121
-rw-r--r--src/python/grpcio_tests/tests/unit/_reconnect_test.py45
-rw-r--r--src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py1
-rw-r--r--src/python/grpcio_tests/tests/unit/_rpc_test.py137
-rw-r--r--src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py521
-rw-r--r--src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py10
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py19
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/_implementations_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/beta/test_utilities.py6
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/README1
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/README.md15
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/certs/ca.cert.pem31
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem28
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem31
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem30
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/client.key.pem27
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem27
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/certs/ca.cert.pem31
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem28
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem31
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem30
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/client.key.pem27
-rw-r--r--src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem27
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py72
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py22
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py104
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py7
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py8
-rw-r--r--src/python/grpcio_tests/tests/unit/resources.py82
-rw-r--r--src/python/grpcio_tests/tests/unit/test_common.py35
-rw-r--r--src/ruby/README.md6
-rwxr-xr-xsrc/ruby/end2end/channel_closing_client.rb2
-rwxr-xr-xsrc/ruby/end2end/channel_closing_driver.rb6
-rwxr-xr-xsrc/ruby/end2end/channel_state_driver.rb7
-rwxr-xr-xsrc/ruby/end2end/end2end_common.rb9
-rwxr-xr-xsrc/ruby/end2end/forking_client_driver.rb6
-rwxr-xr-xsrc/ruby/end2end/grpc_class_init_client.rb2
-rwxr-xr-xsrc/ruby/end2end/killed_client_thread_driver.rb56
-rwxr-xr-xsrc/ruby/end2end/load_grpc_with_gc_stress_driver.rb32
-rwxr-xr-xsrc/ruby/end2end/multiple_killed_watching_threads_driver.rb25
-rwxr-xr-xsrc/ruby/end2end/sig_handling_client.rb30
-rwxr-xr-xsrc/ruby/end2end/sig_handling_driver.rb35
-rwxr-xr-xsrc/ruby/end2end/sig_int_during_channel_watch_driver.rb4
-rw-r--r--src/ruby/ext/grpc/extconf.rb6
-rw-r--r--src/ruby/ext/grpc/rb_byte_buffer.c10
-rw-r--r--src/ruby/ext/grpc/rb_byte_buffer.h4
-rw-r--r--src/ruby/ext/grpc/rb_call.c85
-rw-r--r--src/ruby/ext/grpc/rb_call.h12
-rw-r--r--src/ruby/ext/grpc/rb_call_credentials.c62
-rw-r--r--src/ruby/ext/grpc/rb_channel.c174
-rw-r--r--src/ruby/ext/grpc/rb_channel_credentials.c46
-rw-r--r--src/ruby/ext/grpc/rb_completion_queue.c22
-rw-r--r--src/ruby/ext/grpc/rb_completion_queue.h6
-rw-r--r--src/ruby/ext/grpc/rb_compression_options.c45
-rw-r--r--src/ruby/ext/grpc/rb_event_thread.c28
-rw-r--r--src/ruby/ext/grpc/rb_event_thread.h2
-rw-r--r--src/ruby/ext/grpc/rb_grpc.c16
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.c118
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h582
-rw-r--r--src/ruby/ext/grpc/rb_server.c46
-rw-r--r--src/ruby/ext/grpc/rb_server_credentials.c26
-rw-r--r--src/ruby/lib/grpc.rb1
-rw-r--r--src/ruby/lib/grpc/generic/active_call.rb43
-rw-r--r--src/ruby/lib/grpc/generic/bidi_call.rb29
-rw-r--r--src/ruby/lib/grpc/generic/client_stub.rb133
-rw-r--r--src/ruby/lib/grpc/generic/interceptor_registry.rb53
-rw-r--r--src/ruby/lib/grpc/generic/interceptors.rb186
-rw-r--r--src/ruby/lib/grpc/generic/rpc_desc.rb80
-rw-r--r--src/ruby/lib/grpc/generic/rpc_server.rb51
-rw-r--r--src/ruby/lib/grpc/google_rpc_status_utils.rb9
-rw-r--r--src/ruby/lib/grpc/version.rb2
-rw-r--r--src/ruby/pb/grpc/health/checker.rb14
-rw-r--r--src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb1
-rw-r--r--src/ruby/qps/histogram.rb15
-rwxr-xr-xsrc/ruby/qps/proxy-worker.rb58
-rw-r--r--src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb1
-rw-r--r--src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb1
-rwxr-xr-xsrc/ruby/qps/worker.rb12
-rw-r--r--src/ruby/spec/channel_connection_spec.rb38
-rw-r--r--src/ruby/spec/client_auth_spec.rb2
-rw-r--r--src/ruby/spec/client_server_spec.rb4
-rw-r--r--src/ruby/spec/generic/active_call_spec.rb21
-rw-r--r--src/ruby/spec/generic/client_interceptors_spec.rb153
-rw-r--r--src/ruby/spec/generic/client_stub_spec.rb8
-rw-r--r--src/ruby/spec/generic/interceptor_registry_spec.rb65
-rw-r--r--src/ruby/spec/generic/rpc_server_spec.rb59
-rw-r--r--src/ruby/spec/generic/server_interceptors_spec.rb218
-rw-r--r--src/ruby/spec/google_rpc_status_utils_spec.rb80
-rw-r--r--src/ruby/spec/pb/health/checker_spec.rb31
-rw-r--r--src/ruby/spec/server_spec.rb18
-rw-r--r--src/ruby/spec/spec_helper.rb4
-rw-r--r--src/ruby/spec/support/helpers.rb107
-rw-r--r--src/ruby/spec/support/services.rb147
-rw-r--r--src/ruby/tools/version.rb2
-rw-r--r--summerofcode/ideas.md46
-rw-r--r--templates/CMakeLists.txt.template224
-rw-r--r--templates/Makefile.template24
-rw-r--r--templates/binding.gyp.template371
-rw-r--r--templates/gRPC-C++.podspec.template193
-rw-r--r--templates/gRPC-Core.podspec.template82
-rw-r--r--templates/gRPC-ProtoRPC.podspec.template1
-rw-r--r--templates/gRPC-RxLibrary.podspec.template4
-rw-r--r--templates/gRPC.podspec.template4
-rw-r--r--templates/grpc.gemspec.template2
-rw-r--r--templates/include/grpc/module.modulemap.template58
-rw-r--r--templates/package.json.template105
-rw-r--r--templates/package.xml.template13
-rw-r--r--templates/src/core/lib/surface/version.cc.template (renamed from templates/src/core/lib/surface/version.c.template)4
-rw-r--r--templates/src/core/plugin_registry.template6
-rw-r--r--templates/src/cpp/common/version_cc.cc.template2
-rw-r--r--templates/src/node/health_check/package.json.template31
-rw-r--r--templates/src/node/tools/package.json.template43
-rw-r--r--templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template2
-rw-r--r--templates/src/objective-c/tests/version.h.template29
-rw-r--r--templates/src/python/grpcio/grpc_core_dependencies.py.template2
-rw-r--r--templates/src/python/grpcio/grpc_version.py.template2
-rw-r--r--templates/src/python/grpcio_health_checking/grpc_version.py.template2
-rw-r--r--templates/src/python/grpcio_reflection/grpc_version.py.template2
-rw-r--r--templates/src/python/grpcio_testing/grpc_version.py.template2
-rw-r--r--templates/src/python/grpcio_tests/grpc_version.py.template2
-rw-r--r--templates/test/core/end2end/end2end_nosec_tests.cc.template (renamed from templates/test/core/end2end/end2end_nosec_tests.c.template)0
-rw-r--r--templates/test/core/end2end/end2end_tests.cc.template (renamed from templates/test/core/end2end/end2end_tests.c.template)0
-rw-r--r--templates/test/core/surface/public_headers_must_be_c89.c.template14
-rw-r--r--templates/test/cpp/naming/create_private_dns_zone.sh.template4
-rw-r--r--templates/test/cpp/naming/create_private_dns_zone_defs.include32
-rw-r--r--templates/test/cpp/naming/private_dns_zone_init.sh.template4
-rw-r--r--templates/test/cpp/naming/private_dns_zone_init_defs.include40
-rw-r--r--templates/test/cpp/naming/resolver_gce_integration_tests_defs.include64
-rw-r--r--templates/test/cpp/naming/resolver_gce_integration_tests_runner.sh.template4
-rw-r--r--templates/tools/distrib/python/grpcio_tools/grpc_version.py.template2
-rw-r--r--templates/tools/dockerfile/clang5.include7
-rw-r--r--templates/tools/dockerfile/clang_format.include5
-rwxr-xr-xtemplates/tools/dockerfile/csharp_build_interop.sh.include32
-rw-r--r--templates/tools/dockerfile/grpc_clang_format/Dockerfile.template4
-rw-r--r--templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template24
-rw-r--r--templates/tools/dockerfile/interoptest/grpc_interop_csharp/build_interop.sh.template3
-rw-r--r--templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile.template26
-rw-r--r--templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh.template3
-rw-r--r--templates/tools/dockerfile/python_deps.include4
-rw-r--r--templates/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile.template26
-rw-r--r--templates/tools/dockerfile/test/multilang_jessie_x64/Dockerfile.template1
-rw-r--r--templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template3
-rw-r--r--templates/tools/dockerfile/test/sanity/Dockerfile.template6
-rw-r--r--templates/tools/run_tests/generated/tests.json.template4
-rw-r--r--[-rwxr-xr-x]test/core/backoff/BUILD (renamed from tools/run_tests/helper_scripts/build_node_electron.sh)37
-rw-r--r--test/core/backoff/backoff_test.cc176
-rw-r--r--test/core/bad_client/bad_client.cc (renamed from test/core/bad_client/bad_client.c)144
-rw-r--r--test/core/bad_client/bad_client.h11
-rwxr-xr-xtest/core/bad_client/gen_build_yaml.py6
-rwxr-xr-xtest/core/bad_client/generate_tests.bzl8
-rw-r--r--test/core/bad_client/tests/badreq.cc (renamed from test/core/bad_client/tests/badreq.c)27
-rw-r--r--test/core/bad_client/tests/connection_prefix.c60
-rw-r--r--test/core/bad_client/tests/connection_prefix.cc64
-rw-r--r--test/core/bad_client/tests/head_of_line_blocking.cc (renamed from test/core/bad_client/tests/head_of_line_blocking.c)27
-rw-r--r--test/core/bad_client/tests/headers.cc (renamed from test/core/bad_client/tests/headers.c)174
-rw-r--r--test/core/bad_client/tests/initial_settings_frame.cc (renamed from test/core/bad_client/tests/initial_settings_frame.c)64
-rw-r--r--test/core/bad_client/tests/large_metadata.cc (renamed from test/core/bad_client/tests/large_metadata.c)42
-rw-r--r--test/core/bad_client/tests/server_registered_method.cc (renamed from test/core/bad_client/tests/server_registered_method.c)49
-rw-r--r--test/core/bad_client/tests/simple_request.cc (renamed from test/core/bad_client/tests/simple_request.c)48
-rw-r--r--test/core/bad_client/tests/unknown_frame.cc (renamed from test/core/bad_client/tests/unknown_frame.c)12
-rw-r--r--test/core/bad_client/tests/window_overflow.cc (renamed from test/core/bad_client/tests/window_overflow.c)22
-rw-r--r--test/core/bad_ssl/bad_ssl_test.cc (renamed from test/core/bad_ssl/bad_ssl_test.c)63
-rwxr-xr-xtest/core/bad_ssl/gen_build_yaml.py6
-rwxr-xr-xtest/core/bad_ssl/generate_tests.bzl4
-rw-r--r--test/core/bad_ssl/server_common.cc (renamed from test/core/bad_ssl/server_common.c)41
-rw-r--r--test/core/bad_ssl/server_common.h4
-rw-r--r--test/core/bad_ssl/servers/alpn.cc (renamed from test/core/bad_ssl/servers/alpn.c)20
-rw-r--r--test/core/bad_ssl/servers/cert.cc (renamed from test/core/bad_ssl/servers/cert.c)18
-rw-r--r--test/core/census/BUILD82
-rw-r--r--test/core/census/README7
-rw-r--r--test/core/census/context_test.c363
-rw-r--r--test/core/census/data/context_empty.pb0
-rw-r--r--test/core/census/data/context_empty.txt0
-rw-r--r--test/core/census/data/context_full.pbbin32 -> 0 bytes
-rw-r--r--test/core/census/data/context_full.txt4
-rw-r--r--test/core/census/data/context_no_span_options.pbbin27 -> 0 bytes
-rw-r--r--test/core/census/data/context_no_span_options.txt3
-rw-r--r--test/core/census/data/context_span_only.pbbin14 -> 0 bytes
-rw-r--r--test/core/census/data/context_span_only.txt2
-rw-r--r--test/core/census/data/context_trace_only.pbbin23 -> 0 bytes
-rw-r--r--test/core/census/data/context_trace_only.txt3
-rw-r--r--test/core/census/data/resource_empty_name.pb1
-rw-r--r--test/core/census/data/resource_empty_name.txt5
-rw-r--r--test/core/census/data/resource_full.pb2
-rw-r--r--test/core/census/data/resource_full.txt9
-rw-r--r--test/core/census/data/resource_minimal_good.pb2
-rw-r--r--test/core/census/data/resource_minimal_good.txt5
-rw-r--r--test/core/census/data/resource_no_name.pb1
-rw-r--r--test/core/census/data/resource_no_name.txt4
-rw-r--r--test/core/census/data/resource_no_numerator.pb2
-rw-r--r--test/core/census/data/resource_no_numerator.txt6
-rw-r--r--test/core/census/data/resource_no_unit.pb2
-rw-r--r--test/core/census/data/resource_no_unit.txt2
-rw-r--r--test/core/census/intrusive_hash_map_test.c284
-rw-r--r--test/core/census/mlog_test.c574
-rw-r--r--test/core/census/resource_test.c154
-rw-r--r--test/core/census/trace_context_test.c215
-rw-r--r--test/core/channel/BUILD12
-rw-r--r--test/core/channel/channel_args_test.cc (renamed from test/core/channel/channel_args_test.c)72
-rw-r--r--test/core/channel/channel_stack_builder_test.cc (renamed from test/core/channel/channel_stack_builder_test.c)61
-rw-r--r--test/core/channel/channel_stack_test.c157
-rw-r--r--test/core/channel/channel_stack_test.cc155
-rw-r--r--test/core/channel/minimal_stack_is_minimal_test.cc (renamed from test/core/channel/minimal_stack_is_minimal_test.c)102
-rw-r--r--test/core/client_channel/BUILD8
-rw-r--r--test/core/client_channel/lb_policies_test.cc (renamed from test/core/client_channel/lb_policies_test.c)396
-rw-r--r--test/core/client_channel/parse_address_test.cc (renamed from test/core/client_channel/parse_address_test.c)43
-rw-r--r--test/core/client_channel/resolvers/BUILD16
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.c180
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc178
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.cc (renamed from test/core/client_channel/resolvers/dns_resolver_test.c)39
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc (renamed from test/core/client_channel/resolvers/fake_resolver_test.c)110
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc (renamed from test/core/client_channel/resolvers/sockaddr_resolver_test.c)54
-rw-r--r--test/core/client_channel/uri_fuzzer_test.cc (renamed from test/core/client_channel/uri_fuzzer_test.c)23
-rw-r--r--test/core/client_channel/uri_parser_test.cc (renamed from test/core/client_channel/uri_parser_test.c)59
-rw-r--r--test/core/compression/BUILD24
-rw-r--r--test/core/compression/algorithm_test.cc (renamed from test/core/compression/algorithm_test.c)52
-rw-r--r--test/core/compression/compression_test.cc (renamed from test/core/compression/compression_test.c)108
-rw-r--r--test/core/compression/message_compress_test.cc (renamed from test/core/compression/message_compress_test.c)115
-rw-r--r--test/core/compression/stream_compression_test.cc (renamed from test/core/compression/stream_compression_test.c)51
-rw-r--r--test/core/debug/stats_test.cc87
-rw-r--r--test/core/end2end/BUILD22
-rw-r--r--test/core/end2end/bad_server_response_test.cc (renamed from test/core/end2end/bad_server_response_test.c)129
-rw-r--r--test/core/end2end/connection_refused_test.cc (renamed from test/core/end2end/connection_refused_test.c)55
-rw-r--r--test/core/end2end/cq_verifier.cc (renamed from test/core/end2end/cq_verifier.c)111
-rw-r--r--test/core/end2end/cq_verifier.h22
-rw-r--r--test/core/end2end/cq_verifier_internal.h6
-rw-r--r--test/core/end2end/cq_verifier_native.cc (renamed from test/core/end2end/cq_verifier_native.c)23
-rw-r--r--test/core/end2end/cq_verifier_uv.cc (renamed from test/core/end2end/cq_verifier_uv.c)34
-rw-r--r--test/core/end2end/data/client_certs.cc (renamed from test/core/end2end/data/client_certs.c)8
-rw-r--r--test/core/end2end/data/server1_cert.cc (renamed from test/core/end2end/data/server1_cert.c)2
-rw-r--r--test/core/end2end/data/server1_key.cc (renamed from test/core/end2end/data/server1_key.c)2
-rw-r--r--test/core/end2end/data/ssl_test_data.h8
-rw-r--r--test/core/end2end/data/test_root_cert.cc (renamed from test/core/end2end/data/test_root_cert.c)2
-rw-r--r--test/core/end2end/dualstack_socket_test.cc (renamed from test/core/end2end/dualstack_socket_test.c)118
-rw-r--r--test/core/end2end/end2end_nosec_tests.cc (renamed from test/core/end2end/end2end_tests.c)16
-rw-r--r--test/core/end2end/end2end_test_utils.cc (renamed from test/core/end2end/end2end_test_utils.c)14
-rw-r--r--test/core/end2end/end2end_tests.cc (renamed from test/core/end2end/end2end_nosec_tests.c)16
-rw-r--r--test/core/end2end/end2end_tests.h34
-rw-r--r--test/core/end2end/fixtures/h2_census.cc (renamed from test/core/end2end/fixtures/h2_census.c)58
-rw-r--r--test/core/end2end/fixtures/h2_compress.cc (renamed from test/core/end2end/fixtures/h2_compress.c)78
-rw-r--r--test/core/end2end/fixtures/h2_fakesec.cc (renamed from test/core/end2end/fixtures/h2_fakesec.c)67
-rw-r--r--test/core/end2end/fixtures/h2_fd.cc (renamed from test/core/end2end/fixtures/h2_fd.c)45
-rw-r--r--test/core/end2end/fixtures/h2_full+pipe.cc (renamed from test/core/end2end/fixtures/h2_full+pipe.c)48
-rw-r--r--test/core/end2end/fixtures/h2_full+trace.cc (renamed from test/core/end2end/fixtures/h2_full+trace.c)48
-rw-r--r--test/core/end2end/fixtures/h2_full+workarounds.cc (renamed from test/core/end2end/fixtures/h2_full+workarounds.c)59
-rw-r--r--test/core/end2end/fixtures/h2_full.cc (renamed from test/core/end2end/fixtures/h2_full.c)46
-rw-r--r--test/core/end2end/fixtures/h2_http_proxy.cc (renamed from test/core/end2end/fixtures/h2_http_proxy.c)56
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.cc (renamed from test/core/end2end/fixtures/h2_load_reporting.c)45
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc (renamed from test/core/end2end/fixtures/h2_oauth2.c)140
-rw-r--r--test/core/end2end/fixtures/h2_proxy.cc (renamed from test/core/end2end/fixtures/h2_proxy.c)59
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc (renamed from test/core/end2end/fixtures/h2_sockpair+trace.c)84
-rw-r--r--test/core/end2end/fixtures/h2_sockpair.cc (renamed from test/core/end2end/fixtures/h2_sockpair.c)80
-rw-r--r--test/core/end2end/fixtures/h2_sockpair_1byte.cc (renamed from test/core/end2end/fixtures/h2_sockpair_1byte.c)101
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc (renamed from test/core/end2end/fixtures/h2_ssl.c)99
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc (renamed from test/core/end2end/fixtures/h2_ssl_proxy.c)135
-rw-r--r--test/core/end2end/fixtures/h2_uds.cc (renamed from test/core/end2end/fixtures/h2_uds.c)48
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc (renamed from test/core/end2end/fixtures/http_proxy_fixture.c)294
-rw-r--r--test/core/end2end/fixtures/inproc.cc (renamed from test/core/end2end/fixtures/inproc.c)29
-rw-r--r--test/core/end2end/fixtures/proxy.cc (renamed from test/core/end2end/fixtures/proxy.c)194
-rw-r--r--test/core/end2end/fixtures/proxy.h20
-rw-r--r--test/core/end2end/fuzzers/BUILD12
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc (renamed from test/core/end2end/fuzzers/api_fuzzer.c)623
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5bin0 -> 48866 bytes
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.c157
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc162
-rw-r--r--test/core/end2end/fuzzers/hpack.dictionary3
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.c123
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc127
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py37
-rwxr-xr-xtest/core/end2end/generate_tests.bzl32
-rw-r--r--test/core/end2end/goaway_server_test.cc (renamed from test/core/end2end/goaway_server_test.c)144
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc (renamed from test/core/end2end/fixtures/h2_ssl_cert.c)222
-rw-r--r--test/core/end2end/invalid_call_argument_test.cc (renamed from test/core/end2end/invalid_call_argument_test.c)236
-rw-r--r--test/core/end2end/multiple_server_queues_test.cc (renamed from test/core/end2end/multiple_server_queues_test.c)34
-rw-r--r--test/core/end2end/no_server_test.cc (renamed from test/core/end2end/no_server_test.c)37
-rw-r--r--test/core/end2end/tests/authority_not_supported.cc (renamed from test/core/end2end/tests/authority_not_supported.c)58
-rw-r--r--test/core/end2end/tests/bad_hostname.cc (renamed from test/core/end2end/tests/bad_hostname.c)48
-rw-r--r--test/core/end2end/tests/bad_ping.cc (renamed from test/core/end2end/tests/bad_ping.c)116
-rw-r--r--test/core/end2end/tests/binary_metadata.cc (renamed from test/core/end2end/tests/binary_metadata.c)85
-rw-r--r--test/core/end2end/tests/call_creds.cc (renamed from test/core/end2end/tests/call_creds.c)148
-rw-r--r--test/core/end2end/tests/cancel_after_accept.cc (renamed from test/core/end2end/tests/cancel_after_accept.c)88
-rw-r--r--test/core/end2end/tests/cancel_after_client_done.cc (renamed from test/core/end2end/tests/cancel_after_client_done.c)75
-rw-r--r--test/core/end2end/tests/cancel_after_invoke.cc (renamed from test/core/end2end/tests/cancel_after_invoke.c)56
-rw-r--r--test/core/end2end/tests/cancel_after_round_trip.cc (renamed from test/core/end2end/tests/cancel_after_round_trip.c)102
-rw-r--r--test/core/end2end/tests/cancel_before_invoke.cc (renamed from test/core/end2end/tests/cancel_before_invoke.c)56
-rw-r--r--test/core/end2end/tests/cancel_in_a_vacuum.cc (renamed from test/core/end2end/tests/cancel_in_a_vacuum.c)36
-rw-r--r--test/core/end2end/tests/cancel_test_helpers.h8
-rw-r--r--test/core/end2end/tests/cancel_with_status.cc (renamed from test/core/end2end/tests/cancel_with_status.c)53
-rw-r--r--test/core/end2end/tests/compressed_payload.cc (renamed from test/core/end2end/tests/compressed_payload.c)222
-rw-r--r--test/core/end2end/tests/connectivity.cc (renamed from test/core/end2end/tests/connectivity.c)26
-rw-r--r--test/core/end2end/tests/default_host.cc (renamed from test/core/end2end/tests/default_host.c)68
-rw-r--r--test/core/end2end/tests/disappearing_server.cc (renamed from test/core/end2end/tests/disappearing_server.c)58
-rw-r--r--test/core/end2end/tests/empty_batch.cc (renamed from test/core/end2end/tests/empty_batch.c)40
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.cc (renamed from test/core/end2end/tests/filter_call_init_fails.c)173
-rw-r--r--test/core/end2end/tests/filter_causes_close.cc (renamed from test/core/end2end/tests/filter_causes_close.c)106
-rw-r--r--test/core/end2end/tests/filter_latency.cc (renamed from test/core/end2end/tests/filter_latency.c)108
-rw-r--r--test/core/end2end/tests/filter_status_code.cc378
-rw-r--r--test/core/end2end/tests/graceful_server_shutdown.cc (renamed from test/core/end2end/tests/graceful_server_shutdown.c)59
-rw-r--r--test/core/end2end/tests/high_initial_seqno.cc (renamed from test/core/end2end/tests/high_initial_seqno.c)62
-rw-r--r--test/core/end2end/tests/hpack_size.cc (renamed from test/core/end2end/tests/hpack_size.c)70
-rw-r--r--test/core/end2end/tests/idempotent_request.cc (renamed from test/core/end2end/tests/idempotent_request.c)68
-rw-r--r--test/core/end2end/tests/invoke_large_request.cc (renamed from test/core/end2end/tests/invoke_large_request.c)78
-rw-r--r--test/core/end2end/tests/keepalive_timeout.cc (renamed from test/core/end2end/tests/keepalive_timeout.c)80
-rw-r--r--test/core/end2end/tests/large_metadata.cc (renamed from test/core/end2end/tests/large_metadata.c)71
-rw-r--r--test/core/end2end/tests/load_reporting_hook.cc (renamed from test/core/end2end/tests/load_reporting_hook.c)105
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.cc (renamed from test/core/end2end/tests/max_concurrent_streams.c)230
-rw-r--r--test/core/end2end/tests/max_connection_age.cc (renamed from test/core/end2end/tests/max_connection_age.c)139
-rw-r--r--test/core/end2end/tests/max_connection_idle.cc (renamed from test/core/end2end/tests/max_connection_idle.c)79
-rw-r--r--test/core/end2end/tests/max_message_length.cc (renamed from test/core/end2end/tests/max_message_length.c)184
-rw-r--r--test/core/end2end/tests/negative_deadline.cc (renamed from test/core/end2end/tests/negative_deadline.c)48
-rw-r--r--test/core/end2end/tests/network_status_change.cc (renamed from test/core/end2end/tests/network_status_change.c)66
-rw-r--r--test/core/end2end/tests/no_logging.cc (renamed from test/core/end2end/tests/no_logging.c)80
-rw-r--r--test/core/end2end/tests/no_op.cc (renamed from test/core/end2end/tests/no_op.c)26
-rw-r--r--test/core/end2end/tests/payload.cc (renamed from test/core/end2end/tests/payload.c)80
-rw-r--r--test/core/end2end/tests/ping.cc (renamed from test/core/end2end/tests/ping.c)52
-rw-r--r--test/core/end2end/tests/ping_pong_streaming.cc (renamed from test/core/end2end/tests/ping_pong_streaming.c)84
-rw-r--r--test/core/end2end/tests/proxy_auth.cc (renamed from test/core/end2end/tests/proxy_auth.c)75
-rw-r--r--test/core/end2end/tests/registered_call.cc (renamed from test/core/end2end/tests/registered_call.c)68
-rw-r--r--test/core/end2end/tests/request_with_flags.cc (renamed from test/core/end2end/tests/request_with_flags.c)54
-rw-r--r--test/core/end2end/tests/request_with_payload.cc (renamed from test/core/end2end/tests/request_with_payload.c)66
-rw-r--r--test/core/end2end/tests/resource_quota_server.cc (renamed from test/core/end2end/tests/resource_quota_server.c)114
-rw-r--r--test/core/end2end/tests/server_finishes_request.cc (renamed from test/core/end2end/tests/server_finishes_request.c)56
-rw-r--r--test/core/end2end/tests/shutdown_finishes_calls.cc (renamed from test/core/end2end/tests/shutdown_finishes_calls.c)55
-rw-r--r--test/core/end2end/tests/shutdown_finishes_tags.cc (renamed from test/core/end2end/tests/shutdown_finishes_tags.c)26
-rw-r--r--test/core/end2end/tests/simple_cacheable_request.cc (renamed from test/core/end2end/tests/simple_cacheable_request.c)84
-rw-r--r--test/core/end2end/tests/simple_delayed_request.cc (renamed from test/core/end2end/tests/simple_delayed_request.c)68
-rw-r--r--test/core/end2end/tests/simple_metadata.cc (renamed from test/core/end2end/tests/simple_metadata.c)85
-rw-r--r--test/core/end2end/tests/simple_request.cc (renamed from test/core/end2end/tests/simple_request.c)88
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc (renamed from test/core/end2end/tests/stream_compression_compressed_payload.c)295
-rw-r--r--test/core/end2end/tests/stream_compression_payload.cc (renamed from test/core/end2end/tests/stream_compression_payload.c)96
-rw-r--r--test/core/end2end/tests/stream_compression_ping_pong_streaming.cc (renamed from test/core/end2end/tests/stream_compression_ping_pong_streaming.c)99
-rw-r--r--test/core/end2end/tests/streaming_error_response.cc (renamed from test/core/end2end/tests/streaming_error_response.c)68
-rw-r--r--test/core/end2end/tests/trailing_metadata.cc (renamed from test/core/end2end/tests/trailing_metadata.c)89
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc (renamed from test/core/end2end/tests/workaround_cronet_compression.c)140
-rw-r--r--test/core/end2end/tests/write_buffering.cc (renamed from test/core/end2end/tests/write_buffering.c)74
-rw-r--r--test/core/end2end/tests/write_buffering_at_end.cc (renamed from test/core/end2end/tests/write_buffering_at_end.c)72
-rw-r--r--test/core/fling/BUILD12
-rw-r--r--test/core/fling/client.cc (renamed from test/core/fling/client.c)76
-rw-r--r--test/core/fling/fling_stream_test.cc (renamed from test/core/fling/fling_test.c)26
-rw-r--r--test/core/fling/fling_test.cc (renamed from test/core/fling/fling_stream_test.c)26
-rw-r--r--test/core/fling/server.cc (renamed from test/core/fling/server.c)95
-rw-r--r--test/core/gpr/BUILD (renamed from test/core/support/BUILD)96
-rw-r--r--test/core/gpr/alloc_test.cc (renamed from test/core/support/alloc_test.c)38
-rw-r--r--test/core/gpr/arena_test.cc (renamed from test/core/support/arena_test.c)33
-rw-r--r--test/core/gpr/avl_test.cc3659
-rw-r--r--test/core/gpr/cmdline_test.cc (renamed from test/core/support/cmdline_test.c)268
-rw-r--r--test/core/gpr/cpu_test.cc (renamed from test/core/support/cpu_test.c)20
-rw-r--r--test/core/gpr/env_test.cc (renamed from test/core/support/env_test.c)14
-rw-r--r--test/core/gpr/host_port_test.cc (renamed from test/core/support/host_port_test.c)8
-rw-r--r--test/core/gpr/log_test.cc (renamed from test/core/support/log_test.c)12
-rw-r--r--test/core/gpr/mpscq_test.cc (renamed from test/core/support/mpscq_test.c)57
-rw-r--r--test/core/gpr/murmur_hash_test.cc (renamed from test/core/support/murmur_hash_test.c)6
-rw-r--r--test/core/gpr/spinlock_test.cc (renamed from test/core/support/spinlock_test.c)38
-rw-r--r--test/core/gpr/string_test.cc (renamed from test/core/support/string_test.c)48
-rw-r--r--test/core/gpr/sync_test.cc (renamed from test/core/support/sync_test.c)118
-rw-r--r--test/core/gpr/thd_test.cc (renamed from test/core/support/thd_test.c)13
-rw-r--r--test/core/gpr/time_test.cc (renamed from test/core/support/time_test.c)25
-rw-r--r--test/core/gpr/tls_test.cc (renamed from test/core/support/tls_test.c)6
-rw-r--r--test/core/gpr/useful_test.cc (renamed from test/core/support/useful_test.c)2
-rw-r--r--test/core/gprpp/BUILD96
-rw-r--r--test/core/gprpp/inlined_vector_test.cc112
-rw-r--r--test/core/gprpp/manual_constructor_test.cc99
-rw-r--r--test/core/gprpp/memory_test.cc (renamed from test/core/support/memory_test.cc)2
-rw-r--r--test/core/gprpp/orphanable_test.cc114
-rw-r--r--test/core/gprpp/ref_counted_ptr_test.cc185
-rw-r--r--test/core/gprpp/ref_counted_test.cc74
-rw-r--r--test/core/handshake/BUILD39
-rw-r--r--test/core/handshake/client_ssl.cc (renamed from test/core/handshake/client_ssl.c)81
-rw-r--r--test/core/handshake/readahead_handshaker_server_ssl.cc99
-rw-r--r--test/core/handshake/server_ssl.cc57
-rw-r--r--test/core/handshake/server_ssl_common.cc (renamed from test/core/handshake/server_ssl.c)78
-rw-r--r--test/core/handshake/server_ssl_common.h36
-rw-r--r--test/core/http/BUILD35
-rw-r--r--test/core/http/format_request_test.cc (renamed from test/core/http/format_request_test.c)36
-rw-r--r--test/core/http/httpcli_test.c210
-rw-r--r--test/core/http/httpcli_test.cc215
-rw-r--r--test/core/http/httpscli_test.cc (renamed from test/core/http/httpscli_test.c)129
-rw-r--r--test/core/http/parser_test.cc (renamed from test/core/http/parser_test.c)68
l---------test/core/http/python_wrapper.sh1
-rw-r--r--test/core/http/request_fuzzer.cc (renamed from test/core/http/request_fuzzer.c)9
-rw-r--r--test/core/http/response_fuzzer.cc (renamed from test/core/http/response_fuzzer.c)9
-rw-r--r--test/core/iomgr/BUILD84
-rw-r--r--test/core/iomgr/combiner_test.cc (renamed from test/core/iomgr/combiner_test.c)87
-rw-r--r--test/core/iomgr/endpoint_pair_test.cc (renamed from test/core/iomgr/endpoint_pair_test.c)44
-rw-r--r--test/core/iomgr/endpoint_tests.cc (renamed from test/core/iomgr/endpoint_tests.c)161
-rw-r--r--test/core/iomgr/endpoint_tests.h8
-rw-r--r--test/core/iomgr/error_test.cc (renamed from test/core/iomgr/error_test.c)0
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc (renamed from test/core/iomgr/ev_epollsig_linux_test.c)176
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.cc (renamed from test/core/iomgr/fd_conservation_posix_test.c)39
-rw-r--r--test/core/iomgr/fd_posix_test.cc (renamed from test/core/iomgr/fd_posix_test.c)245
-rw-r--r--test/core/iomgr/load_file_test.cc (renamed from test/core/iomgr/load_file_test.c)57
-rw-r--r--test/core/iomgr/pollset_set_test.cc (renamed from test/core/iomgr/pollset_set_test.c)304
-rw-r--r--test/core/iomgr/resolve_address_posix_test.c172
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc168
-rw-r--r--test/core/iomgr/resolve_address_test.c270
-rw-r--r--test/core/iomgr/resolve_address_test.cc260
-rw-r--r--test/core/iomgr/resource_quota_test.cc (renamed from test/core/iomgr/resource_quota_test.c)559
-rw-r--r--test/core/iomgr/sockaddr_utils_test.cc (renamed from test/core/iomgr/sockaddr_utils_test.c)60
-rw-r--r--test/core/iomgr/socket_utils_test.cc (renamed from test/core/iomgr/socket_utils_test.c)30
-rw-r--r--test/core/iomgr/tcp_client_posix_test.cc (renamed from test/core/iomgr/tcp_client_posix_test.c)135
-rw-r--r--test/core/iomgr/tcp_client_uv_test.cc (renamed from test/core/iomgr/tcp_client_uv_test.c)117
-rw-r--r--test/core/iomgr/tcp_posix_test.cc (renamed from test/core/iomgr/tcp_posix_test.c)279
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc (renamed from test/core/iomgr/tcp_server_posix_test.c)294
-rw-r--r--test/core/iomgr/tcp_server_uv_test.cc (renamed from test/core/iomgr/tcp_server_uv_test.c)160
-rw-r--r--test/core/iomgr/time_averaged_stats_test.cc (renamed from test/core/iomgr/time_averaged_stats_test.c)2
-rw-r--r--test/core/iomgr/timer_heap_test.cc (renamed from test/core/iomgr/timer_heap_test.c)49
-rw-r--r--test/core/iomgr/timer_list_test.c182
-rw-r--r--test/core/iomgr/timer_list_test.cc167
-rw-r--r--test/core/iomgr/udp_server_test.cc (renamed from test/core/iomgr/udp_server_test.c)233
-rw-r--r--test/core/iomgr/wakeup_fd_cv_test.cc (renamed from test/core/iomgr/wakeup_fd_cv_test.c)24
-rw-r--r--test/core/json/BUILD20
-rw-r--r--test/core/json/fuzzer.cc (renamed from test/core/json/fuzzer.c)8
-rw-r--r--test/core/json/json_rewrite.cc (renamed from test/core/json/json_rewrite.c)100
-rw-r--r--test/core/json/json_rewrite_test.cc (renamed from test/core/json/json_rewrite_test.c)100
-rw-r--r--test/core/json/json_stream_error_test.cc (renamed from test/core/json/json_stream_error_test.c)12
-rw-r--r--test/core/json/json_test.cc (renamed from test/core/json/json_test.c)129
-rw-r--r--test/core/memory_usage/client.cc (renamed from test/core/memory_usage/client.c)85
-rw-r--r--test/core/memory_usage/memory_usage_test.cc (renamed from test/core/memory_usage/memory_usage_test.c)24
-rw-r--r--test/core/memory_usage/server.cc (renamed from test/core/memory_usage/server.c)92
-rw-r--r--test/core/nanopb/BUILD8
-rw-r--r--test/core/nanopb/fuzzer_response.cc (renamed from test/core/nanopb/fuzzer_response.c)11
-rw-r--r--test/core/nanopb/fuzzer_serverlist.cc (renamed from test/core/nanopb/fuzzer_serverlist.c)11
-rw-r--r--test/core/network_benchmarks/BUILD4
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.cc (renamed from test/core/network_benchmarks/low_level_ping_pong.c)137
-rw-r--r--test/core/security/BUILD48
-rw-r--r--test/core/security/auth_context_test.cc (renamed from test/core/security/auth_context_test.c)44
-rw-r--r--test/core/security/create_jwt.cc (renamed from test/core/security/create_jwt.c)35
-rw-r--r--test/core/security/credentials_test.cc (renamed from test/core/security/credentials_test.c)861
-rw-r--r--test/core/security/fetch_oauth2.cc (renamed from test/core/security/fetch_oauth2.c)37
-rw-r--r--test/core/security/json_token_test.cc (renamed from test/core/security/json_token_test.c)190
-rw-r--r--test/core/security/jwt_verifier_test.cc (renamed from test/core/security/jwt_verifier_test.c)372
-rw-r--r--test/core/security/oauth2_utils.cc (renamed from test/core/security/oauth2_utils.c)57
-rw-r--r--test/core/security/oauth2_utils.h12
-rw-r--r--test/core/security/print_google_default_creds_token.cc (renamed from test/core/security/print_google_default_creds_token.c)53
-rw-r--r--test/core/security/secure_endpoint_test.cc (renamed from test/core/security/secure_endpoint_test.c)122
-rw-r--r--test/core/security/security_connector_test.cc (renamed from test/core/security/security_connector_test.c)114
-rw-r--r--test/core/security/ssl_credentials_test.cc66
-rw-r--r--test/core/security/ssl_server_fuzzer.c126
-rw-r--r--test/core/security/ssl_server_fuzzer.cc129
-rw-r--r--test/core/security/verify_jwt.cc (renamed from test/core/security/verify_jwt.c)61
-rw-r--r--test/core/slice/BUILD42
-rw-r--r--test/core/slice/b64_test.cc (renamed from test/core/slice/b64_test.c)64
-rw-r--r--test/core/slice/percent_decode_fuzzer.cc (renamed from test/core/slice/percent_decode_fuzzer.c)7
-rw-r--r--test/core/slice/percent_encode_fuzzer.cc (renamed from test/core/slice/percent_encode_fuzzer.c)9
-rw-r--r--test/core/slice/percent_encoding_test.cc (renamed from test/core/slice/percent_encoding_test.c)33
-rw-r--r--test/core/slice/slice_buffer_test.cc (renamed from test/core/slice/slice_buffer_test.c)5
-rw-r--r--test/core/slice/slice_hash_table_test.cc (renamed from test/core/slice/slice_hash_table_test.c)59
-rw-r--r--test/core/slice/slice_string_helpers_test.cc (renamed from test/core/slice/slice_string_helpers_test.c)85
-rw-r--r--test/core/slice/slice_test.cc (renamed from test/core/slice/slice_test.c)24
-rw-r--r--test/core/statistics/census_log_tests.c576
-rw-r--r--test/core/statistics/census_stub_test.cc (renamed from test/core/statistics/census_stub_test.c)4
-rw-r--r--test/core/statistics/hash_table_test.c286
-rw-r--r--test/core/statistics/multiple_writers_circular_buffer_test.cc (renamed from test/core/statistics/multiple_writers_circular_buffer_test.c)2
-rw-r--r--test/core/statistics/multiple_writers_test.cc (renamed from test/core/statistics/multiple_writers_test.c)2
-rw-r--r--test/core/statistics/performance_test.cc (renamed from test/core/statistics/performance_test.c)2
-rw-r--r--test/core/statistics/quick_test.cc (renamed from test/core/statistics/quick_test.c)2
-rw-r--r--test/core/statistics/rpc_stats_test.cc (renamed from test/core/statistics/rpc_stats_test.c)6
-rw-r--r--test/core/statistics/small_log_test.cc (renamed from test/core/statistics/small_log_test.c)2
-rw-r--r--test/core/statistics/trace_test.c240
-rw-r--r--test/core/statistics/window_stats_test.c303
-rw-r--r--test/core/support/avl_test.c3659
-rw-r--r--test/core/support/backoff_test.c143
-rw-r--r--test/core/support/histogram_test.c163
-rw-r--r--test/core/support/stack_lockfree_test.c140
-rw-r--r--test/core/surface/BUILD48
-rw-r--r--test/core/surface/alarm_test.cc (renamed from test/core/surface/alarm_test.c)61
-rw-r--r--test/core/surface/byte_buffer_reader_test.cc (renamed from test/core/surface/byte_buffer_reader_test.c)49
-rw-r--r--test/core/surface/channel_create_test.cc (renamed from test/core/surface/channel_create_test.c)13
-rw-r--r--test/core/surface/completion_queue_test.cc (renamed from test/core/surface/completion_queue_test.c)174
-rw-r--r--test/core/surface/completion_queue_threading_test.cc (renamed from test/core/surface/completion_queue_threading_test.c)104
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc (renamed from test/core/surface/concurrent_connectivity_test.c)152
-rw-r--r--test/core/surface/init_test.cc (renamed from test/core/surface/init_test.c)4
-rw-r--r--test/core/surface/invalid_channel_args_test.cc (renamed from test/core/surface/invalid_channel_args_test.c)48
-rw-r--r--test/core/surface/lame_client_test.cc (renamed from test/core/surface/lame_client_test.c)60
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc (renamed from test/core/surface/num_external_connectivity_watchers_test.c)90
-rw-r--r--test/core/surface/public_headers_must_be_c89.c278
-rw-r--r--test/core/surface/secure_channel_create_test.cc (renamed from test/core/surface/secure_channel_create_test.c)41
-rw-r--r--test/core/surface/sequential_connectivity_test.cc (renamed from test/core/surface/sequential_connectivity_test.c)100
-rw-r--r--test/core/surface/server_chttp2_test.cc (renamed from test/core/surface/server_chttp2_test.c)22
-rw-r--r--test/core/surface/server_test.cc (renamed from test/core/surface/server_test.c)95
-rw-r--r--test/core/transport/BUILD38
-rw-r--r--test/core/transport/bdp_estimator_test.c144
-rw-r--r--test/core/transport/bdp_estimator_test.cc148
-rw-r--r--test/core/transport/byte_stream_test.cc (renamed from test/core/transport/byte_stream_test.c)127
-rw-r--r--test/core/transport/chttp2/BUILD49
-rw-r--r--test/core/transport/chttp2/alpn_test.cc (renamed from test/core/transport/chttp2/alpn_test.c)4
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.c143
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.cc137
-rw-r--r--test/core/transport/chttp2/bin_encoder_test.cc (renamed from test/core/transport/chttp2/bin_encoder_test.c)29
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc (renamed from test/core/transport/chttp2/hpack_encoder_test.c)179
-rw-r--r--test/core/transport/chttp2/hpack_parser_fuzzer_test.cc (renamed from test/core/transport/chttp2/hpack_parser_fuzzer_test.c)23
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.cc (renamed from test/core/transport/chttp2/hpack_parser_test.c)61
-rw-r--r--test/core/transport/chttp2/hpack_table_test.cc (renamed from test/core/transport/chttp2/hpack_table_test.c)94
-rw-r--r--test/core/transport/chttp2/settings_timeout_test.cc254
-rw-r--r--test/core/transport/chttp2/stream_map_test.cc (renamed from test/core/transport/chttp2/stream_map_test.c)53
-rw-r--r--test/core/transport/chttp2/varint_test.cc (renamed from test/core/transport/chttp2/varint_test.c)7
-rw-r--r--test/core/transport/connectivity_state_test.cc (renamed from test/core/transport/connectivity_state_test.c)66
-rw-r--r--test/core/transport/metadata_test.cc (renamed from test/core/transport/metadata_test.c)165
-rw-r--r--test/core/transport/pid_controller_test.c78
-rw-r--r--test/core/transport/pid_controller_test.cc91
-rw-r--r--test/core/transport/status_conversion_test.cc (renamed from test/core/transport/status_conversion_test.c)22
-rw-r--r--test/core/transport/stream_owned_slice_test.cc (renamed from test/core/transport/stream_owned_slice_test.c)9
-rw-r--r--test/core/transport/timeout_encoding_test.c148
-rw-r--r--test/core/transport/timeout_encoding_test.cc161
-rw-r--r--test/core/tsi/BUILD14
-rw-r--r--test/core/tsi/fake_transport_security_test.cc (renamed from test/core/tsi/fake_transport_security_test.c)41
-rw-r--r--test/core/tsi/ssl_transport_security_test.cc (renamed from test/core/tsi/ssl_transport_security_test.c)292
-rw-r--r--test/core/tsi/transport_security_test.cc (renamed from test/core/tsi/transport_security_test.c)251
-rw-r--r--test/core/tsi/transport_security_test_lib.cc (renamed from test/core/tsi/transport_security_test_lib.c)336
-rw-r--r--test/core/tsi/transport_security_test_lib.h51
-rw-r--r--test/core/util/BUILD81
-rw-r--r--test/core/util/debugger_macros.cc (renamed from test/core/util/debugger_macros.c)20
-rw-r--r--test/core/util/fuzzer_corpus_test.cc143
-rw-r--r--test/core/util/grpc_fuzzer.bzl19
-rw-r--r--test/core/util/grpc_profiler.cc (renamed from test/core/util/grpc_profiler.c)4
-rw-r--r--test/core/util/grpc_profiler.h10
-rw-r--r--test/core/util/histogram.cc (renamed from src/core/lib/support/histogram.c)73
-rw-r--r--test/core/util/histogram.h62
-rw-r--r--test/core/util/histogram_test.cc163
-rw-r--r--test/core/util/memory_counters.cc (renamed from test/core/util/memory_counters.c)30
-rw-r--r--test/core/util/mock_endpoint.cc (renamed from test/core/util/mock_endpoint.c)89
-rw-r--r--test/core/util/mock_endpoint.h7
-rw-r--r--test/core/util/one_corpus_entry_fuzzer.cc (renamed from test/core/util/one_corpus_entry_fuzzer.c)12
-rw-r--r--test/core/util/parse_hexstring.cc (renamed from test/core/util/parse_hexstring.c)6
-rw-r--r--test/core/util/parse_hexstring.h2
-rw-r--r--test/core/util/passthru_endpoint.cc (renamed from test/core/util/passthru_endpoint.c)126
-rw-r--r--test/core/util/passthru_endpoint.h14
-rw-r--r--test/core/util/port.cc (renamed from test/core/util/port.c)12
-rw-r--r--test/core/util/port.h8
-rw-r--r--test/core/util/port_isolated_runtime_environment.cc42
-rw-r--r--test/core/util/port_server_client.cc (renamed from test/core/util/port_server_client.c)168
-rw-r--r--test/core/util/reconnect_server.cc (renamed from test/core/util/reconnect_server.c)54
-rw-r--r--test/core/util/reconnect_server.h26
-rwxr-xr-xtest/core/util/run_with_poller.sh (renamed from tools/run_tests/performance/run_worker_node.sh)14
-rw-r--r--test/core/util/slice_splitter.cc (renamed from test/core/util/slice_splitter.c)30
-rw-r--r--test/core/util/slice_splitter.h18
-rw-r--r--test/core/util/test_config.cc (renamed from test/core/util/test_config.c)50
-rw-r--r--test/core/util/test_config.h12
-rw-r--r--test/core/util/test_tcp_server.cc (renamed from test/core/util/test_tcp_server.c)62
-rw-r--r--test/core/util/test_tcp_server.h18
-rw-r--r--test/core/util/tracer_util.cc31
-rw-r--r--test/core/util/tracer_util.h (renamed from src/node/ext/timeval.h)21
-rw-r--r--test/core/util/trickle_endpoint.cc (renamed from test/core/util/trickle_endpoint.c)128
-rw-r--r--test/core/util/trickle_endpoint.h7
-rw-r--r--test/cpp/client/BUILD51
-rw-r--r--test/cpp/client/client_channel_stress_test.cc328
-rw-r--r--test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj533
-rw-r--r--test/cpp/cocoapods/Podfile71
-rw-r--r--test/cpp/cocoapods/generic/Info.plist22
-rw-r--r--test/cpp/cocoapods/generic/generic.mm244
-rw-r--r--test/cpp/cocoapods/test/Info.plist22
-rw-r--r--test/cpp/cocoapods/test/server_context_test_spouse_test.mm100
-rw-r--r--test/cpp/codegen/BUILD22
-rw-r--r--test/cpp/codegen/compiler_test_golden17
-rw-r--r--test/cpp/codegen/golden_file_test.cc11
-rw-r--r--test/cpp/codegen/proto_utils_test.cc112
-rwxr-xr-xtest/cpp/codegen/run_golden_file_test.sh19
-rw-r--r--test/cpp/common/alarm_cpp_test.cc4
-rw-r--r--test/cpp/common/auth_property_iterator_test.cc4
-rw-r--r--test/cpp/common/channel_arguments_test.cc9
-rw-r--r--test/cpp/common/channel_filter_test.cc4
-rw-r--r--test/cpp/common/secure_auth_context_test.cc6
-rw-r--r--test/cpp/end2end/BUILD173
-rw-r--r--test/cpp/end2end/async_end2end_test.cc485
-rw-r--r--test/cpp/end2end/client_crash_test.cc3
-rw-r--r--test/cpp/end2end/client_crash_test_server.cc4
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc226
-rw-r--r--test/cpp/end2end/end2end_test.cc132
-rw-r--r--test/cpp/end2end/exception_test.cc119
-rw-r--r--test/cpp/end2end/filter_end2end_test.cc9
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc16
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc329
-rw-r--r--test/cpp/end2end/mock_test.cc18
-rw-r--r--test/cpp/end2end/server_builder_plugin_test.cc2
-rw-r--r--test/cpp/end2end/server_early_return_test.cc233
-rw-r--r--test/cpp/end2end/shutdown_test.cc2
-rw-r--r--test/cpp/end2end/test_service_impl.cc21
-rw-r--r--test/cpp/end2end/test_service_impl.h1
-rw-r--r--test/cpp/end2end/thread_stress_test.cc40
-rw-r--r--test/cpp/grpclb/grpclb_api_test.cc16
-rw-r--r--test/cpp/grpclb/grpclb_test.cc282
-rw-r--r--test/cpp/interop/client.cc2
-rw-r--r--test/cpp/interop/http2_client.cc4
-rw-r--r--test/cpp/interop/interop_client.cc73
-rw-r--r--test/cpp/interop/interop_client.h6
-rw-r--r--test/cpp/interop/interop_server.cc24
-rw-r--r--test/cpp/interop/interop_test.cc4
-rw-r--r--test/cpp/interop/reconnect_interop_server.cc2
-rw-r--r--test/cpp/interop/server_helper.h20
-rw-r--r--test/cpp/interop/stress_test.cc13
-rw-r--r--test/cpp/microbenchmarks/bm_arena.cc4
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc378
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc394
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc366
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc258
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc51
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc34
-rw-r--r--test/cpp/microbenchmarks/bm_error.cc42
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_trickle.cc86
-rw-r--r--test/cpp/microbenchmarks/bm_metadata.cc119
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc57
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h35
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h47
-rw-r--r--test/cpp/microbenchmarks/helpers.cc32
-rw-r--r--test/cpp/microbenchmarks/helpers.h13
-rw-r--r--test/cpp/naming/README.md43
-rwxr-xr-xtest/cpp/naming/create_private_dns_zone.sh (renamed from tools/run_tests/helper_scripts/run_node_electron.sh)17
-rwxr-xr-xtest/cpp/naming/gen_build_yaml.py110
-rwxr-xr-xtest/cpp/naming/private_dns_zone_init.sh215
-rw-r--r--test/cpp/naming/resolver_component_test.cc136
-rwxr-xr-xtest/cpp/naming/resolver_component_tests_runner.sh26
-rw-r--r--test/cpp/naming/resolver_component_tests_runner_invoker.cc18
-rwxr-xr-xtest/cpp/naming/resolver_gce_integration_tests_runner.sh359
-rw-r--r--test/cpp/naming/resolver_test_record_groups.yaml10
-rwxr-xr-xtest/cpp/naming/test_dns_server.py2
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc23
-rw-r--r--test/cpp/qps/BUILD14
-rw-r--r--test/cpp/qps/client.h93
-rw-r--r--test/cpp/qps/client_async.cc108
-rw-r--r--test/cpp/qps/client_sync.cc252
-rw-r--r--test/cpp/qps/driver.cc58
-rw-r--r--test/cpp/qps/driver.h2
-rwxr-xr-xtest/cpp/qps/gen_build_yaml.py40
-rw-r--r--test/cpp/qps/histogram.h40
-rw-r--r--test/cpp/qps/inproc_sync_unary_ping_pong_test.cc66
-rw-r--r--test/cpp/qps/interarrival.h4
-rw-r--r--test/cpp/qps/json_run_localhost.cc20
-rw-r--r--test/cpp/qps/parse_json.cc4
-rw-r--r--test/cpp/qps/parse_json.h4
-rw-r--r--test/cpp/qps/qps_interarrival_test.cc16
-rw-r--r--test/cpp/qps/qps_json_driver.cc9
-rw-r--r--test/cpp/qps/qps_openloop_test.cc6
-rw-r--r--test/cpp/qps/qps_worker.cc23
-rw-r--r--test/cpp/qps/qps_worker.h14
-rw-r--r--test/cpp/qps/secure_sync_unary_ping_pong_test.cc6
-rw-r--r--test/cpp/qps/server.h8
-rw-r--r--test/cpp/qps/server_async.cc192
-rw-r--r--test/cpp/qps/server_sync.cc20
-rw-r--r--test/cpp/qps/worker.cc3
-rw-r--r--test/cpp/server/server_builder_test.cc7
-rw-r--r--test/cpp/test/server_context_test_spouse_test.cc2
-rw-r--r--test/cpp/thread_manager/thread_manager_test.cc14
-rw-r--r--test/cpp/util/BUILD100
-rw-r--r--test/cpp/util/byte_buffer_test.cc6
-rw-r--r--test/cpp/util/cli_call.cc4
-rw-r--r--test/cpp/util/cli_credentials.cc30
-rw-r--r--test/cpp/util/create_test_channel.cc4
-rw-r--r--test/cpp/util/error_details_test.cc20
-rw-r--r--test/cpp/util/grpc_tool.cc168
-rw-r--r--test/cpp/util/grpc_tool.h4
-rw-r--r--test/cpp/util/grpc_tool_test.cc159
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.cc4
-rw-r--r--test/cpp/util/service_describer.h2
-rw-r--r--test/cpp/util/slice_test.cc6
-rw-r--r--test/cpp/util/test_config_cc.cc2
-rw-r--r--test/distrib/cpp/run_distrib_test_cmake.bat75
-rwxr-xr-xtest/distrib/cpp/run_distrib_test_cmake.sh1
-rwxr-xr-xtest/distrib/node/distrib_test.js42
-rw-r--r--test/distrib/node/package.json7
-rwxr-xr-xtest/distrib/node/run_distrib_test.sh48
-rw-r--r--test/distrib/ruby/distribtest.gemspec2
-rwxr-xr-xtest/distrib/ruby/run_distrib_test.sh8
-rw-r--r--third_party/BUILD6
m---------third_party/abseil-cpp0
m---------third_party/benchmark0
m---------third_party/bloaty0
-rw-r--r--third_party/cares/BUILD9
-rw-r--r--third_party/cares/cares.BUILD215
-rw-r--r--third_party/cares/config_android/ares_config.h458
-rw-r--r--third_party/cares/config_openbsd/ares_config.h502
m---------third_party/protobuf0
-rw-r--r--third_party/rake-compiler-dock/Dockerfile200
-rwxr-xr-xthird_party/rake-compiler-dock/build.sh7
-rw-r--r--third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff105
-rw-r--r--third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/without-exts.diff14
-rw-r--r--third_party/rake-compiler-dock/build/patches/ruby-1.8.7-p374/nop.patch2
-rw-r--r--third_party/rake-compiler-dock/build/patches/ruby-1.9.3/no_sendfile.patch13
-rw-r--r--third_party/rake-compiler-dock/build/patches/ruby-1.9.3/nop.patch2
-rw-r--r--third_party/rake-compiler-dock/build/patches/ruby-2.3.0/no_sendfile.patch12
-rw-r--r--third_party/rake-compiler-dock/build/patches/ruby-2.4.0/no_sendfile.patch12
-rwxr-xr-xthird_party/rake-compiler-dock/build/runas12
-rw-r--r--third_party/rake-compiler-dock/build/sigfw.c43
-rwxr-xr-xthird_party/rake-compiler-dock/build/strip_wrapper30
-rw-r--r--third_party/rake-compiler-dock/build/sudoers1
-rw-r--r--third_party/zlib.BUILD2
-rw-r--r--tools/bazel.rc49
-rwxr-xr-xtools/buildgen/build-cleaner.py100
-rwxr-xr-xtools/buildgen/bunch.py54
-rwxr-xr-xtools/buildgen/generate_projects.py77
-rwxr-xr-xtools/buildgen/mako_renderer.py278
-rwxr-xr-xtools/buildgen/plugins/expand_bin_attrs.py37
-rwxr-xr-xtools/buildgen/plugins/expand_filegroups.py221
-rwxr-xr-xtools/buildgen/plugins/expand_version.py153
-rwxr-xr-xtools/buildgen/plugins/generate_vsprojects.py105
-rwxr-xr-xtools/buildgen/plugins/list_api.py55
-rwxr-xr-xtools/buildgen/plugins/list_protos.py36
-rw-r--r--tools/buildgen/plugins/make_fuzzer_tests.py54
-rw-r--r--tools/buildgen/plugins/transitive_dependencies.py53
-rwxr-xr-xtools/codegen/core/gen_header_frame.py154
-rw-r--r--tools/codegen/core/gen_hpack_tables.cc (renamed from tools/codegen/core/gen_hpack_tables.c)2
-rw-r--r--tools/codegen/core/gen_legal_metadata_characters.cc (renamed from tools/codegen/core/gen_legal_metadata_characters.c)2
-rwxr-xr-xtools/codegen/core/gen_nano_proto.sh2
-rw-r--r--tools/codegen/core/gen_percent_encoding_tables.cc (renamed from tools/codegen/core/gen_percent_encoding_tables.c)2
-rwxr-xr-xtools/codegen/core/gen_server_registered_method_bad_client_test_body.py74
-rwxr-xr-xtools/codegen/core/gen_settings_ids.py192
-rwxr-xr-xtools/codegen/core/gen_static_metadata.py386
-rwxr-xr-xtools/codegen/core/gen_stats_data.py698
-rwxr-xr-xtools/debug/core/chttp2_ref_leak.py44
-rw-r--r--tools/debug/core/error_ref_leak.py47
-rw-r--r--tools/distrib/build_ruby_environment_macos.sh32
-rwxr-xr-xtools/distrib/c-ish/check_documentation.py61
-rwxr-xr-xtools/distrib/check_copyright.py193
-rwxr-xr-xtools/distrib/check_include_guards.py245
-rwxr-xr-xtools/distrib/check_nanopb_output.sh2
-rwxr-xr-xtools/distrib/check_windows_dlls.sh2
-rwxr-xr-xtools/distrib/clang_tidy_code.sh33
-rwxr-xr-xtools/distrib/pull_requests_interval.sh80
-rwxr-xr-xtools/distrib/pylint_code.sh2
-rwxr-xr-xtools/distrib/python/check_grpcio_tools.py17
-rwxr-xr-xtools/distrib/python/docgen.py135
-rw-r--r--tools/distrib/python/grpcio_tools/README.rst2
-rw-r--r--tools/distrib/python/grpcio_tools/grpc_tools/__init__.py1
-rw-r--r--tools/distrib/python/grpcio_tools/grpc_tools/command.py63
-rw-r--r--tools/distrib/python/grpcio_tools/grpc_tools/protoc.py12
-rw-r--r--tools/distrib/python/grpcio_tools/grpc_version.py2
-rw-r--r--tools/distrib/python/grpcio_tools/protoc_lib_deps.py6
-rw-r--r--tools/distrib/python/grpcio_tools/setup.py251
-rwxr-xr-xtools/distrib/python/make_grpcio_tools.py151
-rwxr-xr-xtools/distrib/python/submit.py67
-rwxr-xr-xtools/distrib/run_clang_tidy.py75
-rwxr-xr-xtools/distrib/yapf_code.sh15
-rw-r--r--tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile40
-rw-r--r--tools/dockerfile/grpc_clang_format/Dockerfile12
-rwxr-xr-xtools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh6
-rw-r--r--tools/dockerfile/grpc_clang_tidy/Dockerfile41
-rwxr-xr-xtools/dockerfile/grpc_clang_tidy/clang_tidy_all_the_things.sh24
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile5
-rw-r--r--[-rwxr-xr-x]tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_java/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_node/Dockerfile4
-rwxr-xr-xtools/dockerfile/interoptest/grpc_interop_node/build_interop.sh13
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_python/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile4
-rwxr-xr-xtools/dockerfile/push_testing_images.sh2
-rw-r--r--tools/dockerfile/test/csharp_jessie_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/cxx_alpine_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/cxx_jessie_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/cxx_jessie_x86/Dockerfile4
-rw-r--r--tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile88
-rw-r--r--tools/dockerfile/test/fuzzer/Dockerfile4
-rw-r--r--tools/dockerfile/test/multilang_jessie_x64/Dockerfile22
-rw-r--r--tools/dockerfile/test/node_jessie_x64/Dockerfile7
-rw-r--r--tools/dockerfile/test/php7_jessie_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/php_jessie_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/python_alpine_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/python_jessie_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/python_pyenv_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/ruby_jessie_x64/Dockerfile4
-rw-r--r--tools/dockerfile/test/sanity/Dockerfile23
-rw-r--r--tools/doxygen/Doxyfile.c++7
-rw-r--r--tools/doxygen/Doxyfile.c++.internal48
-rw-r--r--tools/doxygen/Doxyfile.core8
-rw-r--r--tools/doxygen/Doxyfile.core.internal670
-rw-r--r--tools/failures/detect_new_failures.py309
-rw-r--r--tools/failures/sql/new_failures_24h.sql62
-rw-r--r--tools/flakes/detect_flakes.py105
-rwxr-xr-xtools/gce/create_linux_kokoro_performance_worker.sh49
-rwxr-xr-xtools/gce/create_linux_performance_worker.sh2
-rwxr-xr-xtools/gce/create_windows_debug_worker.sh56
-rw-r--r--tools/gce/kokoro_performance.pub1
-rwxr-xr-xtools/gce/linux_kokoro_performance_worker_init.sh194
-rwxr-xr-xtools/gce/linux_performance_worker_init.sh1
-rwxr-xr-xtools/gcp/utils/big_query_utils.py276
-rw-r--r--tools/github/pr_latency.py203
-rwxr-xr-xtools/internal_ci/helper_scripts/gen_report_index.sh2
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_interop_rc1
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc40
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_linux_rc10
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_macos_interop_rc2
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_macos_rc21
-rw-r--r--tools/internal_ci/linux/grpc_bazel_on_foundry_dbg.sh56
-rw-r--r--tools/internal_ci/linux/grpc_bazel_on_foundry_opt.sh56
-rwxr-xr-xtools/internal_ci/linux/grpc_build_submodule_at_head.sh2
-rw-r--r--tools/internal_ci/linux/grpc_coverage.cfg (renamed from tools/internal_ci/linux/grpc_interop_badserver_java.cfg)6
-rwxr-xr-xtools/internal_ci/linux/grpc_coverage.sh (renamed from tools/internal_ci/linux/grpc_interop_badserver_python.sh)13
-rw-r--r--tools/internal_ci/linux/grpc_distribtests_standalone.cfg (renamed from tools/internal_ci/linux/grpc_interop_badserver_python.cfg)8
-rwxr-xr-xtools/internal_ci/linux/grpc_distribtests_standalone.sh (renamed from tools/internal_ci/linux/grpc_interop_tocloud.sh)9
-rw-r--r--tools/internal_ci/linux/grpc_full_performance_master.cfg25
-rwxr-xr-xtools/internal_ci/linux/grpc_full_performance_master.sh59
-rw-r--r--tools/internal_ci/linux/grpc_interop_matrix.cfg2
-rwxr-xr-xtools/internal_ci/linux/grpc_interop_matrix.sh2
-rw-r--r--tools/internal_ci/linux/grpc_interop_tocloud.cfg8
-rw-r--r--tools/internal_ci/linux/grpc_interop_toprod.cfg7
-rwxr-xr-xtools/internal_ci/linux/grpc_interop_toprod.sh32
-rwxr-xr-xtools/internal_ci/linux/grpc_microbenchmark_diff.sh2
-rwxr-xr-xtools/internal_ci/linux/grpc_performance_profile_daily.sh2
-rw-r--r--tools/internal_ci/linux/grpc_portability_build_only.cfg2
-rwxr-xr-xtools/internal_ci/linux/grpc_run_interop_tests.sh (renamed from tools/internal_ci/linux/grpc_interop_badserver_java.sh)5
-rwxr-xr-xtools/internal_ci/linux/grpc_run_tests_matrix.sh7
-rw-r--r--tools/internal_ci/linux/grpc_sanity.cfg2
-rw-r--r--tools/internal_ci/linux/grpc_tsan_on_foundry.sh61
-rw-r--r--tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg30
-rw-r--r--tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg30
-rwxr-xr-xtools/internal_ci/macos/grpc_build_artifacts.sh3
-rwxr-xr-xtools/internal_ci/macos/grpc_run_tests_matrix.sh3
-rw-r--r--tools/internal_ci/windows/grpc_basictests_dbg.cfg30
-rw-r--r--tools/internal_ci/windows/grpc_basictests_opt.cfg30
-rw-r--r--tools/internal_ci/windows/grpc_distribtests_standalone.bat (renamed from tools/run_tests/helper_scripts/build_node.bat)26
-rw-r--r--tools/internal_ci/windows/grpc_distribtests_standalone.cfg26
-rw-r--r--tools/interop_matrix/README.md27
-rw-r--r--tools/interop_matrix/client_matrix.py259
-rwxr-xr-xtools/interop_matrix/create_matrix_images.py453
-rwxr-xr-xtools/interop_matrix/create_testcases.sh30
-rw-r--r--tools/interop_matrix/patches/README.md38
-rw-r--r--tools/interop_matrix/patches/ruby_v1.0.1/git_repo.patch34
-rwxr-xr-xtools/interop_matrix/run_interop_matrix_tests.py309
-rw-r--r--tools/interop_matrix/testcases/csharp__master20
-rw-r--r--tools/interop_matrix/testcases/csharp__v1.1.420
-rw-r--r--tools/interop_matrix/testcases/csharp__v1.2.520
-rw-r--r--tools/interop_matrix/testcases/csharpcoreclr__master20
-rwxr-xr-xtools/interop_matrix/testcases/cxx__master11
-rwxr-xr-xtools/interop_matrix/testcases/go__master11
-rwxr-xr-xtools/interop_matrix/testcases/java__master11
-rwxr-xr-xtools/interop_matrix/testcases/node__master20
-rw-r--r--tools/interop_matrix/testcases/node__v1.0.121
-rwxr-xr-xtools/interop_matrix/testcases/php__master20
-rwxr-xr-xtools/interop_matrix/testcases/python__master20
-rwxr-xr-xtools/interop_matrix/testcases/ruby__master20
-rwxr-xr-xtools/interop_matrix/testcases/ruby__v1.0.120
-rwxr-xr-xtools/jenkins/run_full_performance.sh2
-rwxr-xr-xtools/jenkins/run_performance_profile_daily.sh2
-rwxr-xr-xtools/line_count/collect-history.py26
-rwxr-xr-xtools/line_count/summarize-history.py18
-rwxr-xr-xtools/line_count/yaml2csv.py25
-rwxr-xr-xtools/mkowners/mkowners.py313
-rwxr-xr-xtools/profiling/bloat/bloat_diff.py93
-rwxr-xr-xtools/profiling/latency_profile/profile_analyzer.py345
-rwxr-xr-xtools/profiling/microbenchmarks/bm2bq.py43
-rwxr-xr-xtools/profiling/microbenchmarks/bm_diff/bm_build.py89
-rw-r--r--tools/profiling/microbenchmarks/bm_diff/bm_constants.py24
-rwxr-xr-xtools/profiling/microbenchmarks/bm_diff/bm_diff.py336
-rwxr-xr-xtools/profiling/microbenchmarks/bm_diff/bm_main.py215
-rwxr-xr-xtools/profiling/microbenchmarks/bm_diff/bm_run.py160
-rwxr-xr-xtools/profiling/microbenchmarks/bm_diff/bm_speedup.py61
-rw-r--r--tools/profiling/microbenchmarks/bm_json.py363
-rwxr-xr-xtools/profiling/qps/qps_diff.py209
-rw-r--r--tools/profiling/qps/qps_scenarios.py6
-rw-r--r--tools/run_tests/artifacts/artifact_targets.py657
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_csharp.sh2
-rw-r--r--tools/run_tests/artifacts/build_artifact_node.bat48
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_node.sh51
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_php.sh3
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_protoc.sh2
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_python.sh30
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_ruby.sh9
-rwxr-xr-xtools/run_tests/artifacts/build_package_node.sh84
-rwxr-xr-xtools/run_tests/artifacts/build_package_php.sh4
-rwxr-xr-xtools/run_tests/artifacts/build_package_python.sh4
-rwxr-xr-xtools/run_tests/artifacts/build_package_ruby.sh18
-rw-r--r--tools/run_tests/artifacts/distribtest_targets.py579
-rw-r--r--tools/run_tests/artifacts/package_targets.py234
-rwxr-xr-xtools/run_tests/artifacts/run_in_workspace.sh8
-rwxr-xr-xtools/run_tests/dockerize/build_and_run_docker.sh18
-rwxr-xr-xtools/run_tests/dockerize/build_docker_and_run_tests.sh30
-rwxr-xr-xtools/run_tests/dockerize/build_interop_image.sh38
-rwxr-xr-xtools/run_tests/dockerize/docker_run.sh6
-rwxr-xr-xtools/run_tests/dockerize/docker_run_tests.sh10
-rw-r--r--tools/run_tests/generated/configs.json10
-rw-r--r--tools/run_tests/generated/sources_and_headers.json2097
-rw-r--r--tools/run_tests/generated/tests.json6290
-rwxr-xr-xtools/run_tests/helper_scripts/build_csharp.sh6
-rwxr-xr-xtools/run_tests/helper_scripts/build_php.sh8
-rwxr-xr-xtools/run_tests/helper_scripts/build_python.sh58
-rw-r--r--tools/run_tests/helper_scripts/build_python_msys2.sh4
-rwxr-xr-xtools/run_tests/helper_scripts/build_ruby.sh2
-rwxr-xr-xtools/run_tests/helper_scripts/bundle_install_wrapper.sh4
-rwxr-xr-xtools/run_tests/helper_scripts/post_tests_c.sh14
-rwxr-xr-xtools/run_tests/helper_scripts/post_tests_csharp.sh2
-rwxr-xr-xtools/run_tests/helper_scripts/post_tests_php.sh14
-rwxr-xr-xtools/run_tests/helper_scripts/post_tests_python.sh2
-rwxr-xr-xtools/run_tests/helper_scripts/post_tests_ruby.sh16
-rwxr-xr-xtools/run_tests/helper_scripts/pre_build_cmake.sh4
-rwxr-xr-xtools/run_tests/helper_scripts/pre_build_csharp.sh2
-rw-r--r--tools/run_tests/helper_scripts/pre_build_node.bat20
-rwxr-xr-xtools/run_tests/helper_scripts/pre_build_ruby.sh2
-rwxr-xr-xtools/run_tests/helper_scripts/run_grpc-node.sh28
-rwxr-xr-xtools/run_tests/helper_scripts/run_lcov.sh16
-rw-r--r--tools/run_tests/helper_scripts/run_node.bat18
-rwxr-xr-xtools/run_tests/helper_scripts/run_node.sh48
-rwxr-xr-xtools/run_tests/helper_scripts/run_python.sh14
-rwxr-xr-xtools/run_tests/helper_scripts/run_ruby.sh2
-rwxr-xr-xtools/run_tests/helper_scripts/run_ruby_end2end_tests.sh3
-rwxr-xr-xtools/run_tests/helper_scripts/run_tests_in_workspace.sh8
-rwxr-xr-xtools/run_tests/interop/android/android_interop_helper.sh2
-rwxr-xr-xtools/run_tests/interop/android/run_android_tests_on_firebase.sh2
-rwxr-xr-xtools/run_tests/interop/with_nvm.sh2
-rwxr-xr-xtools/run_tests/interop/with_rvm.sh2
-rw-r--r--tools/run_tests/performance/OWNERS9
-rwxr-xr-xtools/run_tests/performance/bq_upload_result.py219
-rwxr-xr-xtools/run_tests/performance/build_performance.sh19
-rwxr-xr-xtools/run_tests/performance/build_performance_go.sh6
-rwxr-xr-xtools/run_tests/performance/build_performance_php7.sh (renamed from tools/run_tests/helper_scripts/build_node.sh)26
-rwxr-xr-xtools/run_tests/performance/kill_workers.sh9
-rw-r--r--tools/run_tests/performance/massage_qps_stats.py629
-rw-r--r--tools/run_tests/performance/massage_qps_stats_helpers.py71
-rwxr-xr-xtools/run_tests/performance/patch_scenario_results_schema.py35
-rwxr-xr-xtools/run_tests/performance/process_local_perf_flamegraphs.sh10
-rwxr-xr-xtools/run_tests/performance/process_remote_perf_flamegraphs.sh15
-rwxr-xr-xtools/run_tests/performance/remote_host_build.sh3
-rwxr-xr-xtools/run_tests/performance/remote_host_prepare.sh5
-rwxr-xr-xtools/run_tests/performance/run_netperf.sh2
-rwxr-xr-xtools/run_tests/performance/run_qps_driver.sh2
-rwxr-xr-xtools/run_tests/performance/run_worker_csharp.sh4
-rwxr-xr-xtools/run_tests/performance/run_worker_go.sh4
-rwxr-xr-xtools/run_tests/performance/run_worker_java.sh4
-rwxr-xr-xtools/run_tests/performance/run_worker_php.sh9
-rwxr-xr-xtools/run_tests/performance/run_worker_python.sh4
-rwxr-xr-xtools/run_tests/performance/run_worker_ruby.sh4
-rw-r--r--tools/run_tests/performance/scenario_config.py1934
-rw-r--r--tools/run_tests/performance/scenario_result_schema.json126
-rwxr-xr-xtools/run_tests/python_utils/antagonist.py3
-rw-r--r--tools/run_tests/python_utils/comment_on_pr.py33
-rwxr-xr-xtools/run_tests/python_utils/dockerjob.py162
-rw-r--r--tools/run_tests/python_utils/filter_pull_request_tests.py205
-rwxr-xr-xtools/run_tests/python_utils/jobset.py816
-rwxr-xr-xtools/run_tests/python_utils/port_server.py253
-rw-r--r--tools/run_tests/python_utils/report_utils.py219
-rw-r--r--tools/run_tests/python_utils/start_port_server.py18
-rw-r--r--tools/run_tests/python_utils/upload_test_results.py196
-rwxr-xr-xtools/run_tests/python_utils/watch_dirs.py79
-rwxr-xr-xtools/run_tests/run_build_statistics.py305
-rwxr-xr-xtools/run_tests/run_interop_tests.py1994
-rwxr-xr-xtools/run_tests/run_microbenchmark.py354
-rwxr-xr-xtools/run_tests/run_performance_tests.py1139
-rwxr-xr-xtools/run_tests/run_tests.py2742
-rwxr-xr-xtools/run_tests/run_tests_matrix.py977
-rwxr-xr-xtools/run_tests/sanity/check_bazel_workspace.py129
-rwxr-xr-xtools/run_tests/sanity/check_owners.sh10
-rwxr-xr-xtools/run_tests/sanity/check_shellcheck.sh27
-rwxr-xr-xtools/run_tests/sanity/check_sources_and_headers.py132
-rwxr-xr-xtools/run_tests/sanity/check_submodules.sh20
-rwxr-xr-xtools/run_tests/sanity/check_test_filtering.py220
-rwxr-xr-xtools/run_tests/sanity/check_tracer_sanity.py21
-rwxr-xr-xtools/run_tests/sanity/check_unsecure.sh27
-rwxr-xr-xtools/run_tests/sanity/check_version.py76
-rwxr-xr-xtools/run_tests/sanity/core_banned_functions.py36
-rwxr-xr-xtools/run_tests/sanity/core_untyped_structs.sh2
-rw-r--r--tools/run_tests/sanity/sanity_tests.yaml6
-rwxr-xr-xtools/run_tests/start_port_server.py1
-rwxr-xr-xtools/run_tests/task_runner.py100
-rw-r--r--tools/ubsan_suppressions.txt6
2194 files changed, 115829 insertions, 119708 deletions
diff --git a/.clang-format b/.clang-format
index 4b3f13fa55..3b2451958b 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,5 +1,7 @@
---
Language: Cpp
BasedOnStyle: Google
+DerivePointerAlignment: false
+PointerAlignment: Left
...
diff --git a/.clang_complete b/.clang_complete
index 1818679705..aa77554f4e 100644
--- a/.clang_complete
+++ b/.clang_complete
@@ -9,3 +9,9 @@
-Ithird_party/benchmark/include
-Ithird_party/zlib
-Ithird_party/protobuf/src
+-Ithird_party/abseil-cpp
+-Ithird_party/cares/cares
+-Ithird_party/cares
+-Ithird_party/googletest/googletest/include
+-Ithird_party/googletest/googlemock/include
+
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 094e43e470..d45d545454 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,6 +1,7 @@
# Auto-generated by the tools/mkowners/mkowners.py tool
# Uses OWNERS files in different modules throughout the
# repository as the source of truth for module ownership.
-/**/OWNERS @markdroth @nicolasnoble @ctiller
-/bazel/** @nicolasnoble @dgquintas @ctiller
-/src/core/ext/filters/client_channel/** @markdroth @dgquintas @ctiller
+/**/OWNERS @markdroth @nicolasnoble @a11r
+/bazel/** @nicolasnoble @dgquintas @a11r @vjpai
+/src/core/ext/filters/client_channel/** @markdroth @dgquintas @a11r
+/tools/run_tests/performance/** @ncteisen @matt-kwong @ctiller
diff --git a/.gitignore b/.gitignore
index 5ccad2e4f2..0f3cd78947 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ Gemfile.lock
# Temporary test reports
report.xml
+*/sponge_log.xml
latency_trace.txt
latency_trace.*.txt
@@ -93,9 +94,9 @@ DerivedData
*.pbrpc.*
# Cocoapods artifacts
-# Podfile.lock and the workspace file are tracked, to ease deleting them. That's
-# needed to trigger "pod install" to rerun the preinstall commands.
Pods/
+Podfile.lock
+*.xcworkspace
# Artifacts directory
/artifacts/
@@ -120,6 +121,7 @@ gdb.txt
tags
# perf data
+memory_usage.csv
perf.data
perf.data.old
@@ -128,3 +130,5 @@ bm_diff_new/
bm_diff_old/
bm_*.json
+# cmake build files
+/cmake/build
diff --git a/.gitmodules b/.gitmodules
index 144fd080ac..c4b0d241dc 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -19,8 +19,14 @@
url = https://github.com/google/benchmark
[submodule "third_party/boringssl-with-bazel"]
path = third_party/boringssl-with-bazel
- url = https://boringssl.googlesource.com/boringssl
+ url = https://github.com/google/boringssl.git
[submodule "third_party/cares/cares"]
path = third_party/cares/cares
url = https://github.com/c-ares/c-ares.git
branch = cares-1_12_0
+[submodule "third_party/bloaty"]
+ path = third_party/bloaty
+ url = https://github.com/google/bloaty.git
+[submodule "third_party/abseil-cpp"]
+ path = third_party/abseil-cpp
+ url = https://github.com/abseil/abseil-cpp
diff --git a/BUILD b/BUILD
index dfcded2197..9b03685f5e 100644
--- a/BUILD
+++ b/BUILD
@@ -33,12 +33,32 @@ load(
"grpc_generate_one_off_targets",
)
+config_setting(
+ name = "grpc_no_ares",
+ values = {"define": "grpc_no_ares=true"},
+)
+
+config_setting(
+ name = "grpc_allow_exceptions",
+ values = {"define": "GRPC_ALLOW_EXCEPTIONS=1"},
+)
+
+config_setting(
+ name = "grpc_disallow_exceptions",
+ values = {"define": "GRPC_ALLOW_EXCEPTIONS=0"},
+)
+
+config_setting(
+ name = "remote_execution",
+ values = {"define": "GRPC_PORT_ISOLATED_RUNTIME=1"},
+)
+
# This should be updated along with build.yaml
-g_stands_for = "gambit"
+g_stands_for = "glamorous"
-core_version = "4.0.0-dev"
+core_version = "5.0.0-dev"
-version = "1.7.0-dev"
+version = "1.10.0-dev"
GPR_PUBLIC_HDRS = [
"include/grpc/support/alloc.h",
@@ -49,7 +69,6 @@ GPR_PUBLIC_HDRS = [
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
- "include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
@@ -74,10 +93,12 @@ GRPC_PUBLIC_HDRS = [
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
- "include/grpc/load_reporting.h",
+ "include/grpc/compression_ruby.h",
+ "include/grpc/fork.h",
"include/grpc/grpc.h",
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security_constants.h",
+ "include/grpc/load_reporting.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
@@ -187,7 +208,7 @@ GRPCXX_PUBLIC_HDRS = [
grpc_cc_library(
name = "gpr",
- language = "c",
+ language = "c++",
public_hdrs = GPR_PUBLIC_HDRS,
standalone = True,
deps = [
@@ -198,11 +219,11 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_unsecure",
srcs = [
- "src/core/lib/surface/init.c",
- "src/core/lib/surface/init_unsecure.c",
- "src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
+ "src/core/lib/surface/init.cc",
+ "src/core/lib/surface/init_unsecure.cc",
+ "src/core/plugin_registry/grpc_unsecure_plugin_registry.cc",
],
- language = "c",
+ language = "c++",
public_hdrs = GRPC_PUBLIC_HDRS,
standalone = True,
deps = [
@@ -214,10 +235,10 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc",
srcs = [
- "src/core/lib/surface/init.c",
- "src/core/plugin_registry/grpc_plugin_registry.c",
+ "src/core/lib/surface/init.cc",
+ "src/core/plugin_registry/grpc_plugin_registry.cc",
],
- language = "c",
+ language = "c++",
public_hdrs = GRPC_PUBLIC_HDRS + GRPC_SECURE_PUBLIC_HDRS,
standalone = True,
deps = [
@@ -232,10 +253,10 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_cronet",
srcs = [
- "src/core/lib/surface/init.c",
- "src/core/plugin_registry/grpc_cronet_plugin_registry.c",
+ "src/core/lib/surface/init.cc",
+ "src/core/plugin_registry/grpc_cronet_plugin_registry.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_http_filters",
@@ -245,6 +266,11 @@ grpc_cc_library(
)
grpc_cc_library(
+ name = "grpc++_public_hdrs",
+ hdrs = GRPCXX_PUBLIC_HDRS,
+)
+
+grpc_cc_library(
name = "grpc++",
srcs = [
"src/cpp/client/insecure_credentials.cc",
@@ -409,47 +435,12 @@ grpc_cc_library(
grpc_cc_library(
name = "census",
srcs = [
- "src/core/ext/census/base_resources.c",
- "src/core/ext/census/context.c",
- "src/core/ext/census/gen/census.pb.c",
- "src/core/ext/census/gen/trace_context.pb.c",
- "src/core/ext/census/grpc_context.c",
- "src/core/ext/census/grpc_filter.c",
- "src/core/ext/census/grpc_plugin.c",
- "src/core/ext/census/initialize.c",
- "src/core/ext/census/intrusive_hash_map.c",
- "src/core/ext/census/mlog.c",
- "src/core/ext/census/operation.c",
- "src/core/ext/census/placeholders.c",
- "src/core/ext/census/resource.c",
- "src/core/ext/census/trace_context.c",
- "src/core/ext/census/tracing.c",
- ],
- hdrs = [
- "src/core/ext/census/aggregation.h",
- "src/core/ext/census/base_resources.h",
- "src/core/ext/census/census_interface.h",
- "src/core/ext/census/census_rpc_stats.h",
- "src/core/ext/census/gen/census.pb.h",
- "src/core/ext/census/gen/trace_context.pb.h",
- "src/core/ext/census/grpc_filter.h",
- "src/core/ext/census/intrusive_hash_map.h",
- "src/core/ext/census/intrusive_hash_map_internal.h",
- "src/core/ext/census/mlog.h",
- "src/core/ext/census/resource.h",
- "src/core/ext/census/rpc_metric_id.h",
- "src/core/ext/census/trace_context.h",
- "src/core/ext/census/trace_label.h",
- "src/core/ext/census/trace_propagation.h",
- "src/core/ext/census/trace_status.h",
- "src/core/ext/census/trace_string.h",
- "src/core/ext/census/tracing.h",
+ "src/core/ext/census/grpc_context.cc",
],
external_deps = [
"nanopb",
- "libssl",
],
- language = "c",
+ language = "c++",
public_hdrs = [
"include/grpc/census.h",
],
@@ -461,73 +452,66 @@ grpc_cc_library(
grpc_cc_library(
name = "gpr_base",
srcs = [
- "src/core/lib/profiling/basic_timers.c",
- "src/core/lib/profiling/stap_timers.c",
- "src/core/lib/support/alloc.c",
- "src/core/lib/support/arena.c",
- "src/core/lib/support/atm.c",
- "src/core/lib/support/avl.c",
- "src/core/lib/support/backoff.c",
- "src/core/lib/support/cmdline.c",
- "src/core/lib/support/cpu_iphone.c",
- "src/core/lib/support/cpu_linux.c",
- "src/core/lib/support/cpu_posix.c",
- "src/core/lib/support/cpu_windows.c",
- "src/core/lib/support/env_linux.c",
- "src/core/lib/support/env_posix.c",
- "src/core/lib/support/env_windows.c",
- "src/core/lib/support/histogram.c",
- "src/core/lib/support/host_port.c",
- "src/core/lib/support/log.c",
- "src/core/lib/support/log_android.c",
- "src/core/lib/support/log_linux.c",
- "src/core/lib/support/log_posix.c",
- "src/core/lib/support/log_windows.c",
- "src/core/lib/support/mpscq.c",
- "src/core/lib/support/murmur_hash.c",
- "src/core/lib/support/stack_lockfree.c",
- "src/core/lib/support/string.c",
- "src/core/lib/support/string_posix.c",
- "src/core/lib/support/string_util_windows.c",
- "src/core/lib/support/string_windows.c",
- "src/core/lib/support/subprocess_posix.c",
- "src/core/lib/support/subprocess_windows.c",
- "src/core/lib/support/sync.c",
- "src/core/lib/support/sync_posix.c",
- "src/core/lib/support/sync_windows.c",
- "src/core/lib/support/thd.c",
- "src/core/lib/support/thd_posix.c",
- "src/core/lib/support/thd_windows.c",
- "src/core/lib/support/time.c",
- "src/core/lib/support/time_posix.c",
- "src/core/lib/support/time_precise.c",
- "src/core/lib/support/time_windows.c",
- "src/core/lib/support/tls_pthread.c",
- "src/core/lib/support/tmpfile_msys.c",
- "src/core/lib/support/tmpfile_posix.c",
- "src/core/lib/support/tmpfile_windows.c",
- "src/core/lib/support/wrap_memcpy.c",
+ "src/core/lib/profiling/basic_timers.cc",
+ "src/core/lib/profiling/stap_timers.cc",
+ "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",
+ "src/core/lib/gpr/cpu_posix.cc",
+ "src/core/lib/gpr/cpu_windows.cc",
+ "src/core/lib/gpr/env_linux.cc",
+ "src/core/lib/gpr/env_posix.cc",
+ "src/core/lib/gpr/env_windows.cc",
+ "src/core/lib/gpr/fork.cc",
+ "src/core/lib/gpr/host_port.cc",
+ "src/core/lib/gpr/log.cc",
+ "src/core/lib/gpr/log_android.cc",
+ "src/core/lib/gpr/log_linux.cc",
+ "src/core/lib/gpr/log_posix.cc",
+ "src/core/lib/gpr/log_windows.cc",
+ "src/core/lib/gpr/mpscq.cc",
+ "src/core/lib/gpr/murmur_hash.cc",
+ "src/core/lib/gpr/string.cc",
+ "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",
+ "src/core/lib/gpr/thd.cc",
+ "src/core/lib/gpr/thd_posix.cc",
+ "src/core/lib/gpr/thd_windows.cc",
+ "src/core/lib/gpr/time.cc",
+ "src/core/lib/gpr/time_posix.cc",
+ "src/core/lib/gpr/time_precise.cc",
+ "src/core/lib/gpr/time_windows.cc",
+ "src/core/lib/gpr/tls_pthread.cc",
+ "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/wrap_memcpy.cc",
],
hdrs = [
"src/core/lib/profiling/timers.h",
- "src/core/lib/support/arena.h",
- "src/core/lib/support/atomic.h",
- "src/core/lib/support/atomic_with_atm.h",
- "src/core/lib/support/atomic_with_std.h",
- "src/core/lib/support/backoff.h",
- "src/core/lib/support/block_annotate.h",
- "src/core/lib/support/env.h",
- "src/core/lib/support/memory.h",
- "src/core/lib/support/mpscq.h",
- "src/core/lib/support/murmur_hash.h",
- "src/core/lib/support/spinlock.h",
- "src/core/lib/support/stack_lockfree.h",
- "src/core/lib/support/string.h",
- "src/core/lib/support/string_windows.h",
- "src/core/lib/support/time_precise.h",
- "src/core/lib/support/tmpfile.h",
- ],
- language = "c",
+ "src/core/lib/gpr/arena.h",
+ "src/core/lib/gpr/env.h",
+ "src/core/lib/gpr/fork.h",
+ "src/core/lib/gpr/mpscq.h",
+ "src/core/lib/gpr/murmur_hash.h",
+ "src/core/lib/gpr/spinlock.h",
+ "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/tmpfile.h",
+ ],
+ language = "c++",
public_hdrs = GPR_PUBLIC_HDRS,
deps = [
"gpr_codegen",
@@ -536,12 +520,13 @@ grpc_cc_library(
grpc_cc_library(
name = "gpr_codegen",
- language = "c",
+ language = "c++",
public_hdrs = [
"include/grpc/impl/codegen/atm.h",
"include/grpc/impl/codegen/atm_gcc_atomic.h",
"include/grpc/impl/codegen/atm_gcc_sync.h",
"include/grpc/impl/codegen/atm_windows.h",
+ "include/grpc/impl/codegen/fork.h",
"include/grpc/impl/codegen/gpr_slice.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/port_platform.h",
@@ -555,147 +540,229 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_trace",
- srcs = ["src/core/lib/debug/trace.c"],
+ srcs = ["src/core/lib/debug/trace.cc"],
hdrs = ["src/core/lib/debug/trace.h"],
- language = "c",
- deps = [":gpr"],
+ language = "c++",
+ public_hdrs = GRPC_PUBLIC_HDRS,
+ deps = [
+ "grpc_codegen",
+ ":gpr",
+ ],
+)
+
+grpc_cc_library(
+ name = "gpr++_base",
+ language = "c++",
+ public_hdrs = [
+ "src/core/lib/gprpp/abstract.h",
+ "src/core/lib/gprpp/manual_constructor.h",
+ "src/core/lib/gprpp/memory.h",
+ ],
+)
+
+grpc_cc_library(
+ name = "atomic",
+ language = "c++",
+ public_hdrs = [
+ "src/core/lib/gprpp/atomic.h",
+ ],
+ hdrs = [
+ "src/core/lib/gprpp/atomic_with_atm.h",
+ "src/core/lib/gprpp/atomic_with_std.h",
+ ],
+ deps = [
+ "gpr",
+ ],
+)
+
+grpc_cc_library(
+ name = "inlined_vector",
+ language = "c++",
+ public_hdrs = [
+ "src/core/lib/gprpp/inlined_vector.h",
+ ],
+ deps = [
+ "gpr++_base",
+ ],
+)
+
+grpc_cc_library(
+ name = "debug_location",
+ language = "c++",
+ public_hdrs = ["src/core/lib/gprpp/debug_location.h"],
+)
+
+grpc_cc_library(
+ name = "orphanable",
+ language = "c++",
+ public_hdrs = ["src/core/lib/gprpp/orphanable.h"],
+ deps = [
+ "debug_location",
+ "gpr++_base",
+ "grpc_trace",
+ ],
+)
+
+grpc_cc_library(
+ name = "ref_counted",
+ language = "c++",
+ public_hdrs = ["src/core/lib/gprpp/ref_counted.h"],
+ deps = [
+ "debug_location",
+ "gpr++_base",
+ "grpc_trace",
+ ],
+)
+
+grpc_cc_library(
+ name = "ref_counted_ptr",
+ language = "c++",
+ public_hdrs = ["src/core/lib/gprpp/ref_counted_ptr.h"],
+ deps = [
+ "gpr++_base",
+ ],
)
grpc_cc_library(
name = "grpc_base_c",
srcs = [
- "src/core/lib/channel/channel_args.c",
- "src/core/lib/channel/channel_stack.c",
- "src/core/lib/channel/channel_stack_builder.c",
- "src/core/lib/channel/connected_channel.c",
- "src/core/lib/channel/handshaker.c",
- "src/core/lib/channel/handshaker_factory.c",
- "src/core/lib/channel/handshaker_registry.c",
- "src/core/lib/compression/compression.c",
- "src/core/lib/compression/message_compress.c",
- "src/core/lib/compression/stream_compression.c",
- "src/core/lib/compression/stream_compression_gzip.c",
- "src/core/lib/compression/stream_compression_identity.c",
- "src/core/lib/debug/stats.c",
- "src/core/lib/debug/stats_data.c",
- "src/core/lib/http/format_request.c",
- "src/core/lib/http/httpcli.c",
- "src/core/lib/http/parser.c",
- "src/core/lib/iomgr/call_combiner.c",
- "src/core/lib/iomgr/closure.c",
- "src/core/lib/iomgr/combiner.c",
- "src/core/lib/iomgr/endpoint.c",
- "src/core/lib/iomgr/endpoint_pair_posix.c",
- "src/core/lib/iomgr/endpoint_pair_uv.c",
- "src/core/lib/iomgr/endpoint_pair_windows.c",
- "src/core/lib/iomgr/error.c",
- "src/core/lib/iomgr/ev_epoll1_linux.c",
- "src/core/lib/iomgr/ev_epollex_linux.c",
- "src/core/lib/iomgr/ev_epollsig_linux.c",
- "src/core/lib/iomgr/ev_poll_posix.c",
- "src/core/lib/iomgr/ev_posix.c",
- "src/core/lib/iomgr/ev_windows.c",
- "src/core/lib/iomgr/exec_ctx.c",
- "src/core/lib/iomgr/executor.c",
- "src/core/lib/iomgr/gethostname_fallback.c",
- "src/core/lib/iomgr/gethostname_host_name_max.c",
- "src/core/lib/iomgr/gethostname_sysconf.c",
- "src/core/lib/iomgr/iocp_windows.c",
- "src/core/lib/iomgr/iomgr.c",
- "src/core/lib/iomgr/iomgr_posix.c",
- "src/core/lib/iomgr/iomgr_uv.c",
- "src/core/lib/iomgr/iomgr_windows.c",
- "src/core/lib/iomgr/is_epollexclusive_available.c",
- "src/core/lib/iomgr/load_file.c",
- "src/core/lib/iomgr/lockfree_event.c",
- "src/core/lib/iomgr/network_status_tracker.c",
- "src/core/lib/iomgr/polling_entity.c",
- "src/core/lib/iomgr/pollset_set_uv.c",
- "src/core/lib/iomgr/pollset_set_windows.c",
- "src/core/lib/iomgr/pollset_uv.c",
- "src/core/lib/iomgr/pollset_windows.c",
- "src/core/lib/iomgr/resolve_address_posix.c",
- "src/core/lib/iomgr/resolve_address_uv.c",
- "src/core/lib/iomgr/resolve_address_windows.c",
- "src/core/lib/iomgr/resource_quota.c",
- "src/core/lib/iomgr/sockaddr_utils.c",
- "src/core/lib/iomgr/socket_factory_posix.c",
- "src/core/lib/iomgr/socket_mutator.c",
- "src/core/lib/iomgr/socket_utils_common_posix.c",
- "src/core/lib/iomgr/socket_utils_linux.c",
- "src/core/lib/iomgr/socket_utils_posix.c",
- "src/core/lib/iomgr/socket_utils_uv.c",
- "src/core/lib/iomgr/socket_utils_windows.c",
- "src/core/lib/iomgr/socket_windows.c",
- "src/core/lib/iomgr/tcp_client_posix.c",
- "src/core/lib/iomgr/tcp_client_uv.c",
- "src/core/lib/iomgr/tcp_client_windows.c",
- "src/core/lib/iomgr/tcp_posix.c",
- "src/core/lib/iomgr/tcp_server_posix.c",
- "src/core/lib/iomgr/tcp_server_utils_posix_common.c",
- "src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c",
- "src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c",
- "src/core/lib/iomgr/tcp_server_uv.c",
- "src/core/lib/iomgr/tcp_server_windows.c",
- "src/core/lib/iomgr/tcp_uv.c",
- "src/core/lib/iomgr/tcp_windows.c",
- "src/core/lib/iomgr/time_averaged_stats.c",
- "src/core/lib/iomgr/timer_generic.c",
- "src/core/lib/iomgr/timer_heap.c",
- "src/core/lib/iomgr/timer_manager.c",
- "src/core/lib/iomgr/timer_uv.c",
- "src/core/lib/iomgr/udp_server.c",
- "src/core/lib/iomgr/unix_sockets_posix.c",
- "src/core/lib/iomgr/unix_sockets_posix_noop.c",
- "src/core/lib/iomgr/wakeup_fd_cv.c",
- "src/core/lib/iomgr/wakeup_fd_eventfd.c",
- "src/core/lib/iomgr/wakeup_fd_nospecial.c",
- "src/core/lib/iomgr/wakeup_fd_pipe.c",
- "src/core/lib/iomgr/wakeup_fd_posix.c",
- "src/core/lib/json/json.c",
- "src/core/lib/json/json_reader.c",
- "src/core/lib/json/json_string.c",
- "src/core/lib/json/json_writer.c",
- "src/core/lib/slice/b64.c",
- "src/core/lib/slice/percent_encoding.c",
- "src/core/lib/slice/slice.c",
- "src/core/lib/slice/slice_buffer.c",
- "src/core/lib/slice/slice_hash_table.c",
- "src/core/lib/slice/slice_intern.c",
- "src/core/lib/slice/slice_string_helpers.c",
- "src/core/lib/surface/alarm.c",
- "src/core/lib/surface/api_trace.c",
- "src/core/lib/surface/byte_buffer.c",
- "src/core/lib/surface/byte_buffer_reader.c",
- "src/core/lib/surface/call.c",
- "src/core/lib/surface/call_details.c",
- "src/core/lib/surface/call_log_batch.c",
- "src/core/lib/surface/channel.c",
- "src/core/lib/surface/channel_init.c",
- "src/core/lib/surface/channel_ping.c",
- "src/core/lib/surface/channel_stack_type.c",
- "src/core/lib/surface/completion_queue.c",
- "src/core/lib/surface/completion_queue_factory.c",
- "src/core/lib/surface/event_string.c",
- "src/core/lib/surface/metadata_array.c",
- "src/core/lib/surface/server.c",
- "src/core/lib/surface/validate_metadata.c",
- "src/core/lib/surface/version.c",
- "src/core/lib/transport/bdp_estimator.c",
- "src/core/lib/transport/byte_stream.c",
- "src/core/lib/transport/connectivity_state.c",
- "src/core/lib/transport/error_utils.c",
- "src/core/lib/transport/metadata.c",
- "src/core/lib/transport/metadata_batch.c",
- "src/core/lib/transport/pid_controller.c",
- "src/core/lib/transport/service_config.c",
- "src/core/lib/transport/static_metadata.c",
- "src/core/lib/transport/status_conversion.c",
- "src/core/lib/transport/timeout_encoding.c",
- "src/core/lib/transport/transport.c",
- "src/core/lib/transport/transport_op_string.c",
+ "src/core/lib/backoff/backoff.cc",
+ "src/core/lib/channel/channel_args.cc",
+ "src/core/lib/channel/channel_stack.cc",
+ "src/core/lib/channel/channel_stack_builder.cc",
+ "src/core/lib/channel/connected_channel.cc",
+ "src/core/lib/channel/handshaker.cc",
+ "src/core/lib/channel/handshaker_factory.cc",
+ "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",
+ "src/core/lib/compression/stream_compression_identity.cc",
+ "src/core/lib/debug/stats.cc",
+ "src/core/lib/debug/stats_data.cc",
+ "src/core/lib/http/format_request.cc",
+ "src/core/lib/http/httpcli.cc",
+ "src/core/lib/http/parser.cc",
+ "src/core/lib/iomgr/call_combiner.cc",
+ "src/core/lib/iomgr/combiner.cc",
+ "src/core/lib/iomgr/endpoint.cc",
+ "src/core/lib/iomgr/endpoint_pair_posix.cc",
+ "src/core/lib/iomgr/endpoint_pair_uv.cc",
+ "src/core/lib/iomgr/endpoint_pair_windows.cc",
+ "src/core/lib/iomgr/error.cc",
+ "src/core/lib/iomgr/ev_epoll1_linux.cc",
+ "src/core/lib/iomgr/ev_epollex_linux.cc",
+ "src/core/lib/iomgr/ev_epollsig_linux.cc",
+ "src/core/lib/iomgr/ev_poll_posix.cc",
+ "src/core/lib/iomgr/ev_posix.cc",
+ "src/core/lib/iomgr/ev_windows.cc",
+ "src/core/lib/iomgr/exec_ctx.cc",
+ "src/core/lib/iomgr/executor.cc",
+ "src/core/lib/iomgr/fork_posix.cc",
+ "src/core/lib/iomgr/fork_windows.cc",
+ "src/core/lib/iomgr/gethostname_fallback.cc",
+ "src/core/lib/iomgr/gethostname_host_name_max.cc",
+ "src/core/lib/iomgr/gethostname_sysconf.cc",
+ "src/core/lib/iomgr/iocp_windows.cc",
+ "src/core/lib/iomgr/iomgr.cc",
+ "src/core/lib/iomgr/iomgr_posix.cc",
+ "src/core/lib/iomgr/iomgr_uv.cc",
+ "src/core/lib/iomgr/iomgr_windows.cc",
+ "src/core/lib/iomgr/is_epollexclusive_available.cc",
+ "src/core/lib/iomgr/load_file.cc",
+ "src/core/lib/iomgr/lockfree_event.cc",
+ "src/core/lib/iomgr/network_status_tracker.cc",
+ "src/core/lib/iomgr/polling_entity.cc",
+ "src/core/lib/iomgr/pollset_set_uv.cc",
+ "src/core/lib/iomgr/pollset_set_windows.cc",
+ "src/core/lib/iomgr/pollset_uv.cc",
+ "src/core/lib/iomgr/pollset_windows.cc",
+ "src/core/lib/iomgr/resolve_address_posix.cc",
+ "src/core/lib/iomgr/resolve_address_uv.cc",
+ "src/core/lib/iomgr/resolve_address_windows.cc",
+ "src/core/lib/iomgr/resource_quota.cc",
+ "src/core/lib/iomgr/sockaddr_utils.cc",
+ "src/core/lib/iomgr/socket_factory_posix.cc",
+ "src/core/lib/iomgr/socket_mutator.cc",
+ "src/core/lib/iomgr/socket_utils_common_posix.cc",
+ "src/core/lib/iomgr/socket_utils_linux.cc",
+ "src/core/lib/iomgr/socket_utils_posix.cc",
+ "src/core/lib/iomgr/socket_utils_uv.cc",
+ "src/core/lib/iomgr/socket_utils_windows.cc",
+ "src/core/lib/iomgr/socket_windows.cc",
+ "src/core/lib/iomgr/tcp_client_posix.cc",
+ "src/core/lib/iomgr/tcp_client_uv.cc",
+ "src/core/lib/iomgr/tcp_client_windows.cc",
+ "src/core/lib/iomgr/tcp_posix.cc",
+ "src/core/lib/iomgr/tcp_server_posix.cc",
+ "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
+ "src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc",
+ "src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc",
+ "src/core/lib/iomgr/tcp_server_uv.cc",
+ "src/core/lib/iomgr/tcp_server_windows.cc",
+ "src/core/lib/iomgr/tcp_uv.cc",
+ "src/core/lib/iomgr/tcp_windows.cc",
+ "src/core/lib/iomgr/time_averaged_stats.cc",
+ "src/core/lib/iomgr/timer_generic.cc",
+ "src/core/lib/iomgr/timer_heap.cc",
+ "src/core/lib/iomgr/timer_manager.cc",
+ "src/core/lib/iomgr/timer_uv.cc",
+ "src/core/lib/iomgr/udp_server.cc",
+ "src/core/lib/iomgr/unix_sockets_posix.cc",
+ "src/core/lib/iomgr/unix_sockets_posix_noop.cc",
+ "src/core/lib/iomgr/wakeup_fd_cv.cc",
+ "src/core/lib/iomgr/wakeup_fd_eventfd.cc",
+ "src/core/lib/iomgr/wakeup_fd_nospecial.cc",
+ "src/core/lib/iomgr/wakeup_fd_pipe.cc",
+ "src/core/lib/iomgr/wakeup_fd_posix.cc",
+ "src/core/lib/json/json.cc",
+ "src/core/lib/json/json_reader.cc",
+ "src/core/lib/json/json_string.cc",
+ "src/core/lib/json/json_writer.cc",
+ "src/core/lib/slice/b64.cc",
+ "src/core/lib/slice/percent_encoding.cc",
+ "src/core/lib/slice/slice.cc",
+ "src/core/lib/slice/slice_buffer.cc",
+ "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",
+ "src/core/lib/surface/call.cc",
+ "src/core/lib/surface/call_details.cc",
+ "src/core/lib/surface/call_log_batch.cc",
+ "src/core/lib/surface/channel.cc",
+ "src/core/lib/surface/channel_init.cc",
+ "src/core/lib/surface/channel_ping.cc",
+ "src/core/lib/surface/channel_stack_type.cc",
+ "src/core/lib/surface/completion_queue.cc",
+ "src/core/lib/surface/completion_queue_factory.cc",
+ "src/core/lib/surface/event_string.cc",
+ "src/core/lib/surface/metadata_array.cc",
+ "src/core/lib/surface/server.cc",
+ "src/core/lib/surface/validate_metadata.cc",
+ "src/core/lib/surface/version.cc",
+ "src/core/lib/transport/bdp_estimator.cc",
+ "src/core/lib/transport/byte_stream.cc",
+ "src/core/lib/transport/connectivity_state.cc",
+ "src/core/lib/transport/error_utils.cc",
+ "src/core/lib/transport/metadata.cc",
+ "src/core/lib/transport/metadata_batch.cc",
+ "src/core/lib/transport/pid_controller.cc",
+ "src/core/lib/transport/service_config.cc",
+ "src/core/lib/transport/static_metadata.cc",
+ "src/core/lib/transport/status_conversion.cc",
+ "src/core/lib/transport/timeout_encoding.cc",
+ "src/core/lib/transport/transport.cc",
+ "src/core/lib/transport/transport_op_string.cc",
],
hdrs = [
+ "src/core/lib/backoff/backoff.h",
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
"src/core/lib/channel/channel_stack_builder.h",
@@ -705,6 +772,7 @@ grpc_cc_library(
"src/core/lib/channel/handshaker_factory.h",
"src/core/lib/channel/handshaker_registry.h",
"src/core/lib/compression/algorithm_metadata.h",
+ "src/core/lib/compression/compression_internal.h",
"src/core/lib/compression/message_compress.h",
"src/core/lib/compression/stream_compression.h",
"src/core/lib/compression/stream_compression_gzip.h",
@@ -714,6 +782,7 @@ grpc_cc_library(
"src/core/lib/http/format_request.h",
"src/core/lib/http/httpcli.h",
"src/core/lib/http/parser.h",
+ "src/core/lib/iomgr/block_annotate.h",
"src/core/lib/iomgr/call_combiner.h",
"src/core/lib/iomgr/closure.h",
"src/core/lib/iomgr/combiner.h",
@@ -817,10 +886,11 @@ grpc_cc_library(
external_deps = [
"zlib",
],
- language = "c",
+ language = "c++",
public_hdrs = GRPC_PUBLIC_HDRS,
deps = [
"gpr_base",
+ "gpr++_base",
"grpc_codegen",
"grpc_trace",
],
@@ -833,13 +903,14 @@ grpc_cc_library(
],
language = "c++",
deps = [
+ "atomic",
"grpc_base_c",
],
)
grpc_cc_library(
name = "grpc_common",
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
# standard plugins
@@ -865,28 +936,30 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_client_channel",
srcs = [
- "src/core/ext/filters/client_channel/channel_connectivity.c",
- "src/core/ext/filters/client_channel/client_channel.c",
- "src/core/ext/filters/client_channel/client_channel_factory.c",
- "src/core/ext/filters/client_channel/client_channel_plugin.c",
- "src/core/ext/filters/client_channel/connector.c",
- "src/core/ext/filters/client_channel/http_connect_handshaker.c",
- "src/core/ext/filters/client_channel/http_proxy.c",
- "src/core/ext/filters/client_channel/lb_policy.c",
- "src/core/ext/filters/client_channel/lb_policy_factory.c",
- "src/core/ext/filters/client_channel/lb_policy_registry.c",
- "src/core/ext/filters/client_channel/parse_address.c",
- "src/core/ext/filters/client_channel/proxy_mapper.c",
- "src/core/ext/filters/client_channel/proxy_mapper_registry.c",
- "src/core/ext/filters/client_channel/resolver.c",
- "src/core/ext/filters/client_channel/resolver_factory.c",
- "src/core/ext/filters/client_channel/resolver_registry.c",
- "src/core/ext/filters/client_channel/retry_throttle.c",
- "src/core/ext/filters/client_channel/subchannel.c",
- "src/core/ext/filters/client_channel/subchannel_index.c",
- "src/core/ext/filters/client_channel/uri_parser.c",
+ "src/core/ext/filters/client_channel/backup_poller.cc",
+ "src/core/ext/filters/client_channel/channel_connectivity.cc",
+ "src/core/ext/filters/client_channel/client_channel.cc",
+ "src/core/ext/filters/client_channel/client_channel_factory.cc",
+ "src/core/ext/filters/client_channel/client_channel_plugin.cc",
+ "src/core/ext/filters/client_channel/connector.cc",
+ "src/core/ext/filters/client_channel/http_connect_handshaker.cc",
+ "src/core/ext/filters/client_channel/http_proxy.cc",
+ "src/core/ext/filters/client_channel/lb_policy.cc",
+ "src/core/ext/filters/client_channel/lb_policy_factory.cc",
+ "src/core/ext/filters/client_channel/lb_policy_registry.cc",
+ "src/core/ext/filters/client_channel/parse_address.cc",
+ "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",
+ "src/core/ext/filters/client_channel/subchannel_index.cc",
+ "src/core/ext/filters/client_channel/uri_parser.cc",
],
hdrs = [
+ "src/core/ext/filters/client_channel/backup_poller.h",
"src/core/ext/filters/client_channel/client_channel.h",
"src/core/ext/filters/client_channel/client_channel_factory.h",
"src/core/ext/filters/client_channel/connector.h",
@@ -906,22 +979,24 @@ grpc_cc_library(
"src/core/ext/filters/client_channel/subchannel_index.h",
"src/core/ext/filters/client_channel/uri_parser.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_deadline_filter",
+ "ref_counted",
+ "ref_counted_ptr",
],
)
grpc_cc_library(
name = "grpc_max_age_filter",
srcs = [
- "src/core/ext/filters/max_age/max_age_filter.c",
+ "src/core/ext/filters/max_age/max_age_filter.cc",
],
hdrs = [
"src/core/ext/filters/max_age/max_age_filter.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
@@ -930,12 +1005,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_deadline_filter",
srcs = [
- "src/core/ext/filters/deadline/deadline_filter.c",
+ "src/core/ext/filters/deadline/deadline_filter.cc",
],
hdrs = [
"src/core/ext/filters/deadline/deadline_filter.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
@@ -944,12 +1019,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_message_size_filter",
srcs = [
- "src/core/ext/filters/message_size/message_size_filter.c",
+ "src/core/ext/filters/message_size/message_size_filter.cc",
],
hdrs = [
"src/core/ext/filters/message_size/message_size_filter.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
@@ -958,17 +1033,17 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_http_filters",
srcs = [
- "src/core/ext/filters/http/client/http_client_filter.c",
- "src/core/ext/filters/http/http_filters_plugin.c",
- "src/core/ext/filters/http/message_compress/message_compress_filter.c",
- "src/core/ext/filters/http/server/http_server_filter.c",
+ "src/core/ext/filters/http/client/http_client_filter.cc",
+ "src/core/ext/filters/http/http_filters_plugin.cc",
+ "src/core/ext/filters/http/message_compress/message_compress_filter.cc",
+ "src/core/ext/filters/http/server/http_server_filter.cc",
],
hdrs = [
"src/core/ext/filters/http/client/http_client_filter.h",
"src/core/ext/filters/http/message_compress/message_compress_filter.h",
"src/core/ext/filters/http/server/http_server_filter.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
@@ -977,12 +1052,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_workaround_cronet_compression_filter",
srcs = [
- "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c",
+ "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc",
],
hdrs = [
"src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_server_backward_compatibility",
@@ -991,13 +1066,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_codegen",
- language = "c",
+ language = "c++",
public_hdrs = [
"include/grpc/impl/codegen/byte_buffer.h",
"include/grpc/impl/codegen/byte_buffer_reader.h",
"include/grpc/impl/codegen/compression_types.h",
"include/grpc/impl/codegen/connectivity_state.h",
- "include/grpc/impl/codegen/exec_ctx_fwd.h",
"include/grpc/impl/codegen/grpc_types.h",
"include/grpc/impl/codegen/propagation_bits.h",
"include/grpc/impl/codegen/status.h",
@@ -1011,11 +1085,11 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_lb_policy_grpclb",
srcs = [
- "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
],
hdrs = [
@@ -1029,7 +1103,7 @@ grpc_cc_library(
external_deps = [
"nanopb",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1040,11 +1114,11 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_lb_policy_grpclb_secure",
srcs = [
- "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
],
hdrs = [
@@ -1058,7 +1132,7 @@ grpc_cc_library(
external_deps = [
"nanopb",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1068,40 +1142,57 @@ grpc_cc_library(
)
grpc_cc_library(
+ name = "grpc_lb_subchannel_list",
+ srcs = [
+ "src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc",
+ ],
+ hdrs = [
+ "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h",
+ ],
+ language = "c++",
+ deps = [
+ "grpc_base",
+ "grpc_client_channel",
+ ],
+)
+
+grpc_cc_library(
name = "grpc_lb_policy_pick_first",
srcs = [
- "src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c",
+ "src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
+ "grpc_lb_subchannel_list",
],
)
grpc_cc_library(
name = "grpc_lb_policy_round_robin",
srcs = [
- "src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c",
+ "src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
+ "grpc_lb_subchannel_list",
],
)
grpc_cc_library(
name = "grpc_server_load_reporting",
srcs = [
- "src/core/ext/filters/load_reporting/server_load_reporting_filter.c",
- "src/core/ext/filters/load_reporting/server_load_reporting_plugin.c",
+ "src/core/ext/filters/load_reporting/server_load_reporting_filter.cc",
+ "src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc",
],
hdrs = [
"src/core/ext/filters/load_reporting/server_load_reporting_filter.h",
"src/core/ext/filters/load_reporting/server_load_reporting_plugin.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
@@ -1110,9 +1201,9 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_resolver_dns_native",
srcs = [
- "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c",
+ "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1122,10 +1213,10 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_resolver_dns_ares",
srcs = [
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c",
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c",
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c",
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc",
],
hdrs = [
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h",
@@ -1134,7 +1225,7 @@ grpc_cc_library(
external_deps = [
"cares",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1144,9 +1235,9 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_resolver_sockaddr",
srcs = [
- "src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c",
+ "src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1155,9 +1246,9 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_resolver_fake",
- srcs = ["src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c"],
+ srcs = ["src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc"],
hdrs = ["src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"],
- language = "c",
+ language = "c++",
visibility = ["//test:__subpackages__"],
deps = [
"grpc_base",
@@ -1168,30 +1259,30 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_secure",
srcs = [
- "src/core/lib/http/httpcli_security_connector.c",
- "src/core/lib/security/context/security_context.c",
- "src/core/lib/security/credentials/composite/composite_credentials.c",
- "src/core/lib/security/credentials/credentials.c",
- "src/core/lib/security/credentials/credentials_metadata.c",
- "src/core/lib/security/credentials/fake/fake_credentials.c",
- "src/core/lib/security/credentials/google_default/credentials_generic.c",
- "src/core/lib/security/credentials/google_default/google_default_credentials.c",
- "src/core/lib/security/credentials/iam/iam_credentials.c",
- "src/core/lib/security/credentials/jwt/json_token.c",
- "src/core/lib/security/credentials/jwt/jwt_credentials.c",
- "src/core/lib/security/credentials/jwt/jwt_verifier.c",
- "src/core/lib/security/credentials/oauth2/oauth2_credentials.c",
- "src/core/lib/security/credentials/plugin/plugin_credentials.c",
- "src/core/lib/security/credentials/ssl/ssl_credentials.c",
- "src/core/lib/security/transport/client_auth_filter.c",
- "src/core/lib/security/transport/lb_targets_info.c",
- "src/core/lib/security/transport/secure_endpoint.c",
- "src/core/lib/security/transport/security_connector.c",
- "src/core/lib/security/transport/security_handshaker.c",
- "src/core/lib/security/transport/server_auth_filter.c",
- "src/core/lib/security/transport/tsi_error.c",
- "src/core/lib/security/util/json_util.c",
- "src/core/lib/surface/init_secure.c",
+ "src/core/lib/http/httpcli_security_connector.cc",
+ "src/core/lib/security/context/security_context.cc",
+ "src/core/lib/security/credentials/composite/composite_credentials.cc",
+ "src/core/lib/security/credentials/credentials.cc",
+ "src/core/lib/security/credentials/credentials_metadata.cc",
+ "src/core/lib/security/credentials/fake/fake_credentials.cc",
+ "src/core/lib/security/credentials/google_default/credentials_generic.cc",
+ "src/core/lib/security/credentials/google_default/google_default_credentials.cc",
+ "src/core/lib/security/credentials/iam/iam_credentials.cc",
+ "src/core/lib/security/credentials/jwt/json_token.cc",
+ "src/core/lib/security/credentials/jwt/jwt_credentials.cc",
+ "src/core/lib/security/credentials/jwt/jwt_verifier.cc",
+ "src/core/lib/security/credentials/oauth2/oauth2_credentials.cc",
+ "src/core/lib/security/credentials/plugin/plugin_credentials.cc",
+ "src/core/lib/security/credentials/ssl/ssl_credentials.cc",
+ "src/core/lib/security/transport/client_auth_filter.cc",
+ "src/core/lib/security/transport/lb_targets_info.cc",
+ "src/core/lib/security/transport/secure_endpoint.cc",
+ "src/core/lib/security/transport/security_connector.cc",
+ "src/core/lib/security/transport/security_handshaker.cc",
+ "src/core/lib/security/transport/server_auth_filter.cc",
+ "src/core/lib/security/transport/tsi_error.cc",
+ "src/core/lib/security/util/json_util.cc",
+ "src/core/lib/surface/init_secure.cc",
],
hdrs = [
"src/core/lib/security/context/security_context.h",
@@ -1214,7 +1305,7 @@ grpc_cc_library(
"src/core/lib/security/transport/tsi_error.h",
"src/core/lib/security/util/json_util.h",
],
- language = "c",
+ language = "c++",
public_hdrs = GRPC_SECURE_PUBLIC_HDRS,
deps = [
"grpc_base",
@@ -1226,33 +1317,34 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2",
srcs = [
- "src/core/ext/transport/chttp2/transport/bin_decoder.c",
- "src/core/ext/transport/chttp2/transport/bin_encoder.c",
- "src/core/ext/transport/chttp2/transport/chttp2_plugin.c",
- "src/core/ext/transport/chttp2/transport/chttp2_transport.c",
- "src/core/ext/transport/chttp2/transport/flow_control.c",
- "src/core/ext/transport/chttp2/transport/frame_data.c",
- "src/core/ext/transport/chttp2/transport/frame_goaway.c",
- "src/core/ext/transport/chttp2/transport/frame_ping.c",
- "src/core/ext/transport/chttp2/transport/frame_rst_stream.c",
- "src/core/ext/transport/chttp2/transport/frame_settings.c",
- "src/core/ext/transport/chttp2/transport/frame_window_update.c",
- "src/core/ext/transport/chttp2/transport/hpack_encoder.c",
- "src/core/ext/transport/chttp2/transport/hpack_parser.c",
- "src/core/ext/transport/chttp2/transport/hpack_table.c",
- "src/core/ext/transport/chttp2/transport/http2_settings.c",
- "src/core/ext/transport/chttp2/transport/huffsyms.c",
- "src/core/ext/transport/chttp2/transport/incoming_metadata.c",
- "src/core/ext/transport/chttp2/transport/parsing.c",
- "src/core/ext/transport/chttp2/transport/stream_lists.c",
- "src/core/ext/transport/chttp2/transport/stream_map.c",
- "src/core/ext/transport/chttp2/transport/varint.c",
- "src/core/ext/transport/chttp2/transport/writing.c",
+ "src/core/ext/transport/chttp2/transport/bin_decoder.cc",
+ "src/core/ext/transport/chttp2/transport/bin_encoder.cc",
+ "src/core/ext/transport/chttp2/transport/chttp2_plugin.cc",
+ "src/core/ext/transport/chttp2/transport/chttp2_transport.cc",
+ "src/core/ext/transport/chttp2/transport/flow_control.cc",
+ "src/core/ext/transport/chttp2/transport/frame_data.cc",
+ "src/core/ext/transport/chttp2/transport/frame_goaway.cc",
+ "src/core/ext/transport/chttp2/transport/frame_ping.cc",
+ "src/core/ext/transport/chttp2/transport/frame_rst_stream.cc",
+ "src/core/ext/transport/chttp2/transport/frame_settings.cc",
+ "src/core/ext/transport/chttp2/transport/frame_window_update.cc",
+ "src/core/ext/transport/chttp2/transport/hpack_encoder.cc",
+ "src/core/ext/transport/chttp2/transport/hpack_parser.cc",
+ "src/core/ext/transport/chttp2/transport/hpack_table.cc",
+ "src/core/ext/transport/chttp2/transport/http2_settings.cc",
+ "src/core/ext/transport/chttp2/transport/huffsyms.cc",
+ "src/core/ext/transport/chttp2/transport/incoming_metadata.cc",
+ "src/core/ext/transport/chttp2/transport/parsing.cc",
+ "src/core/ext/transport/chttp2/transport/stream_lists.cc",
+ "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",
],
hdrs = [
"src/core/ext/transport/chttp2/transport/bin_decoder.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
+ "src/core/ext/transport/chttp2/transport/flow_control.h",
"src/core/ext/transport/chttp2/transport/frame.h",
"src/core/ext/transport/chttp2/transport/frame_data.h",
"src/core/ext/transport/chttp2/transport/frame_goaway.h",
@@ -1270,8 +1362,9 @@ grpc_cc_library(
"src/core/ext/transport/chttp2/transport/stream_map.h",
"src/core/ext/transport/chttp2/transport/varint.h",
],
- language = "c",
+ language = "c++",
deps = [
+ "gpr++_base",
"grpc_base",
"grpc_http_filters",
"grpc_transport_chttp2_alpn",
@@ -1281,12 +1374,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_alpn",
srcs = [
- "src/core/ext/transport/chttp2/alpn/alpn.c",
+ "src/core/ext/transport/chttp2/alpn/alpn.cc",
],
hdrs = [
"src/core/ext/transport/chttp2/alpn/alpn.h",
],
- language = "c",
+ language = "c++",
deps = [
"gpr",
],
@@ -1295,12 +1388,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_client_connector",
srcs = [
- "src/core/ext/transport/chttp2/client/chttp2_connector.c",
+ "src/core/ext/transport/chttp2/client/chttp2_connector.cc",
],
hdrs = [
"src/core/ext/transport/chttp2/client/chttp2_connector.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1311,10 +1404,10 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_client_insecure",
srcs = [
- "src/core/ext/transport/chttp2/client/insecure/channel_create.c",
- "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c",
+ "src/core/ext/transport/chttp2/client/insecure/channel_create.cc",
+ "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1326,9 +1419,9 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_client_secure",
srcs = [
- "src/core/ext/transport/chttp2/client/secure/secure_channel_create.c",
+ "src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_client_channel",
@@ -1341,12 +1434,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_server",
srcs = [
- "src/core/ext/transport/chttp2/server/chttp2_server.c",
+ "src/core/ext/transport/chttp2/server/chttp2_server.cc",
],
hdrs = [
"src/core/ext/transport/chttp2/server/chttp2_server.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_transport_chttp2",
@@ -1356,10 +1449,10 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_server_insecure",
srcs = [
- "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
- "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c",
+ "src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc",
+ "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_transport_chttp2",
@@ -1370,9 +1463,9 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_chttp2_server_secure",
srcs = [
- "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c",
+ "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"grpc_secure",
@@ -1384,15 +1477,15 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_cronet_client_secure",
srcs = [
- "src/core/ext/transport/cronet/client/secure/cronet_channel_create.c",
- "src/core/ext/transport/cronet/transport/cronet_api_dummy.c",
- "src/core/ext/transport/cronet/transport/cronet_transport.c",
+ "src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc",
+ "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc",
+ "src/core/ext/transport/cronet/transport/cronet_transport.cc",
],
hdrs = [
"src/core/ext/transport/cronet/transport/cronet_transport.h",
"third_party/objective_c/Cronet/bidirectional_stream_c.h",
],
- language = "c",
+ language = "c++",
public_hdrs = [
"include/grpc/grpc_cronet.h",
"include/grpc/grpc_security.h",
@@ -1407,13 +1500,13 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_inproc",
srcs = [
- "src/core/ext/transport/inproc/inproc_plugin.c",
- "src/core/ext/transport/inproc/inproc_transport.c",
+ "src/core/ext/transport/inproc/inproc_plugin.cc",
+ "src/core/ext/transport/inproc/inproc_transport.cc",
],
hdrs = [
"src/core/ext/transport/inproc/inproc_transport.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
@@ -1422,15 +1515,15 @@ grpc_cc_library(
grpc_cc_library(
name = "tsi_interface",
srcs = [
- "src/core/tsi/transport_security.c",
- "src/core/tsi/transport_security_adapter.c",
+ "src/core/tsi/transport_security.cc",
+ "src/core/tsi/transport_security_adapter.cc",
],
hdrs = [
"src/core/tsi/transport_security.h",
"src/core/tsi/transport_security_adapter.h",
"src/core/tsi/transport_security_interface.h",
],
- language = "c",
+ language = "c++",
deps = [
"gpr",
"grpc_trace",
@@ -1440,14 +1533,14 @@ grpc_cc_library(
grpc_cc_library(
name = "tsi",
srcs = [
- "src/core/tsi/fake_transport_security.c",
- "src/core/tsi/gts_transport_security.c",
- "src/core/tsi/ssl_transport_security.c",
- "src/core/tsi/transport_security_grpc.c",
+ "src/core/tsi/alts_transport_security.cc",
+ "src/core/tsi/fake_transport_security.cc",
+ "src/core/tsi/ssl_transport_security.cc",
+ "src/core/tsi/transport_security_grpc.cc",
],
hdrs = [
+ "src/core/tsi/alts_transport_security.h",
"src/core/tsi/fake_transport_security.h",
- "src/core/tsi/gts_transport_security.h",
"src/core/tsi/ssl_transport_security.h",
"src/core/tsi/ssl_types.h",
"src/core/tsi/transport_security_grpc.h",
@@ -1455,7 +1548,7 @@ grpc_cc_library(
external_deps = [
"libssl",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
"tsi_interface",
@@ -1552,7 +1645,7 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc++_config_proto",
external_deps = [
- "protobuf",
+ "protobuf_headers",
],
language = "c++",
public_hdrs = [
@@ -1594,12 +1687,12 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_server_backward_compatibility",
srcs = [
- "src/core/ext/filters/workarounds/workaround_utils.c",
+ "src/core/ext/filters/workarounds/workaround_utils.cc",
],
hdrs = [
"src/core/ext/filters/workarounds/workaround_utils.h",
],
- language = "c",
+ language = "c++",
deps = [
"grpc_base",
],
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e448c92b6..6e9ed42276 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@
cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME "grpc")
-set(PACKAGE_VERSION "1.7.0-dev")
+set(PACKAGE_VERSION "1.10.0-dev")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
@@ -46,6 +46,10 @@ endif()
set(gRPC_INSTALL ${gRPC_INSTALL_default} CACHE BOOL
"Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"")
+# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
+# "module": build the dependency using sources from git submodule (under third_party)
+# "package": use cmake's find_package functionality to locate a pre-installed dependency
+
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@@ -102,181 +106,12 @@ else()
set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf")
endif()
-if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
- if(NOT ZLIB_ROOT_DIR)
- set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
- endif()
- set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}")
- if(EXISTS "${ZLIB_ROOT_DIR}/CMakeLists.txt")
- # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218
- include_directories(${ZLIB_INCLUDE_DIR})
-
- add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib)
- if(TARGET zlibstatic)
- set(_gRPC_ZLIB_LIBRARIES zlibstatic)
- endif()
- else()
- message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
-elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package")
- find_package(ZLIB REQUIRED)
- set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
- set(_gRPC_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
-endif()
-
-if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
- if(NOT CARES_ROOT_DIR)
- set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares)
- endif()
- set(CARES_SHARED OFF CACHE BOOL "disable shared library")
- set(CARES_STATIC ON CACHE BOOL "link cares statically")
- set(CARES_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares")
- add_subdirectory(third_party/cares/cares)
- if(TARGET c-ares)
- set(_gRPC_CARES_LIBRARIES c-ares)
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
-elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package")
- find_package(c-ares REQUIRED CONFIG)
- if(TARGET c-ares::cares)
- set(_gRPC_CARES_LIBRARIES c-ares::cares)
- endif()
- set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
-endif()
-
-if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
- # Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
- # Disable them unless they are explicitly requested from the cmake command line (when we assume
- # gmock is downloaded to the right location inside protobuf).
- if(NOT protobuf_BUILD_TESTS)
- set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
- endif()
- # Disable building protobuf with zlib. Building protobuf with zlib breaks
- # the build if zlib is not installed on the system.
- if(NOT protobuf_WITH_ZLIB)
- set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.")
- endif()
- if(NOT PROTOBUF_ROOT_DIR)
- set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf)
- endif()
- set(PROTOBUF_WELLKNOWN_IMPORT_DIR ${PROTOBUF_ROOT_DIR}/src)
- if(EXISTS "${PROTOBUF_ROOT_DIR}/cmake/CMakeLists.txt")
- set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
- add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf)
- if(TARGET ${_gRPC_PROTOBUF_LIBRARY_NAME})
- set(_gRPC_PROTOBUF_LIBRARIES ${_gRPC_PROTOBUF_LIBRARY_NAME})
- endif()
- if(TARGET libprotoc)
- set(_gRPC_PROTOBUF_PROTOC_LIBRARIES libprotoc)
- endif()
- if(TARGET protoc)
- set(_gRPC_PROTOBUF_PROTOC protoc)
- set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
- endif()
- else()
- message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
-elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package")
- find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE})
- if(Protobuf_FOUND OR PROTOBUF_FOUND)
- if(TARGET protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME})
- set(_gRPC_PROTOBUF_LIBRARIES protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME})
- else()
- set(_gRPC_PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARIES})
- endif()
- if(TARGET protobuf::libprotoc)
- set(_gRPC_PROTOBUF_PROTOC_LIBRARIES protobuf::libprotoc)
- else()
- set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ${PROTOBUF_PROTOC_LIBRARIES})
- endif()
- if(TARGET protobuf::protoc)
- set(_gRPC_PROTOBUF_PROTOC protobuf::protoc)
- set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protobuf::protoc>)
- else()
- set(_gRPC_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE})
- set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
- endif()
- set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()")
- endif()
- if(PROTOBUF_FOUND)
- include_directories(${PROTOBUF_INCLUDE_DIRS})
- endif()
- set(PROTOBUF_WELLKNOWN_IMPORT_DIR /usr/local/include)
-endif()
-
-if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
- if(NOT BORINGSSL_ROOT_DIR)
- set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
- endif()
- if(EXISTS "${BORINGSSL_ROOT_DIR}/CMakeLists.txt")
- set(OPENSSL_NO_ASM ON) # make boringssl buildable with Visual Studio
- add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl)
- if(TARGET ssl)
- set(_gRPC_SSL_LIBRARIES ssl)
- endif()
- else()
- message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
-elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package")
- find_package(OpenSSL REQUIRED)
- set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES})
- set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()")
-endif()
-
-if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
- if(NOT GFLAGS_ROOT_DIR)
- set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
- endif()
- if(EXISTS "${GFLAGS_ROOT_DIR}/CMakeLists.txt")
- add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags)
- if(TARGET gflags_static)
- set(_gRPC_GFLAGS_LIBRARIES gflags_static)
- endif()
- else()
- message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
- endif()
-elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package")
- find_package(gflags)
- if(TARGET gflags::gflags)
- set(_gRPC_GFLAGS_LIBRARIES gflags::gflags)
- endif()
- set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags)\nendif()")
-endif()
-
-if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module")
- if(NOT BENCHMARK_ROOT_DIR)
- set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
- endif()
- if(EXISTS "${BENCHMARK_ROOT_DIR}/CMakeLists.txt")
- add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
- if(TARGET benchmark)
- set(_gRPC_BENCHMARK_LIBRARIES benchmark)
- endif()
- else()
- message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
- endif()
-elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package")
- find_package(benchmark)
- if(TARGET benchmark::benchmark)
- set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark)
- endif()
- set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark)\nendif()")
-endif()
+include(cmake/zlib.cmake)
+include(cmake/cares.cmake)
+include(cmake/protobuf.cmake)
+include(cmake/ssl.cmake)
+include(cmake/gflags.cmake)
+include(cmake/benchmark.cmake)
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
@@ -314,7 +149,7 @@ function(protobuf_generate_grpc_cpp)
return()
endif()
- set(_protobuf_include_path -I . -I ${PROTOBUF_WELLKNOWN_IMPORT_DIR})
+ set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
@@ -357,12 +192,12 @@ add_custom_target(plugins
add_custom_target(tools_c
DEPENDS
check_epollexclusive
- gen_hpack_tables
- gen_legal_metadata_characters
- gen_percent_encoding_tables
grpc_create_jwt
grpc_print_google_default_creds_token
grpc_verify_jwt
+ gen_hpack_tables
+ gen_legal_metadata_characters
+ gen_percent_encoding_tables
)
add_custom_target(tools_cxx
@@ -380,14 +215,9 @@ add_dependencies(buildtests_c alloc_test)
add_dependencies(buildtests_c alpn_test)
add_dependencies(buildtests_c arena_test)
add_dependencies(buildtests_c bad_server_response_test)
-add_dependencies(buildtests_c bdp_estimator_test)
add_dependencies(buildtests_c bin_decoder_test)
add_dependencies(buildtests_c bin_encoder_test)
add_dependencies(buildtests_c byte_stream_test)
-add_dependencies(buildtests_c census_context_test)
-add_dependencies(buildtests_c census_intrusive_hash_map_test)
-add_dependencies(buildtests_c census_resource_test)
-add_dependencies(buildtests_c census_trace_context_test)
add_dependencies(buildtests_c channel_create_test)
add_dependencies(buildtests_c chttp2_hpack_encoder_test)
add_dependencies(buildtests_c chttp2_stream_map_test)
@@ -428,16 +258,14 @@ 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_backoff_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_histogram_test)
add_dependencies(buildtests_c gpr_host_port_test)
add_dependencies(buildtests_c gpr_log_test)
+add_dependencies(buildtests_c gpr_manual_constructor_test)
add_dependencies(buildtests_c gpr_mpscq_test)
add_dependencies(buildtests_c gpr_spinlock_test)
-add_dependencies(buildtests_c gpr_stack_lockfree_test)
add_dependencies(buildtests_c gpr_string_test)
add_dependencies(buildtests_c gpr_sync_test)
add_dependencies(buildtests_c gpr_thd_test)
@@ -460,12 +288,17 @@ add_dependencies(buildtests_c grpc_json_token_test)
endif()
add_dependencies(buildtests_c grpc_jwt_verifier_test)
add_dependencies(buildtests_c grpc_security_connector_test)
+add_dependencies(buildtests_c grpc_ssl_credentials_test)
if(_gRPC_PLATFORM_LINUX)
add_dependencies(buildtests_c handshake_client)
endif()
if(_gRPC_PLATFORM_LINUX)
add_dependencies(buildtests_c handshake_server)
endif()
+if(_gRPC_PLATFORM_LINUX)
+add_dependencies(buildtests_c handshake_server_with_readahead_handshaker)
+endif()
+add_dependencies(buildtests_c histogram_test)
add_dependencies(buildtests_c hpack_parser_test)
add_dependencies(buildtests_c hpack_table_test)
add_dependencies(buildtests_c http_parser_test)
@@ -492,7 +325,6 @@ add_dependencies(buildtests_c memory_profile_test)
endif()
add_dependencies(buildtests_c message_compress_test)
add_dependencies(buildtests_c minimal_stack_is_minimal_test)
-add_dependencies(buildtests_c mlog_test)
add_dependencies(buildtests_c multiple_server_queues_test)
add_dependencies(buildtests_c murmur_hash_test)
add_dependencies(buildtests_c no_server_test)
@@ -544,7 +376,6 @@ add_dependencies(buildtests_c timer_heap_test)
add_dependencies(buildtests_c timer_list_test)
add_dependencies(buildtests_c transport_connectivity_state_test)
add_dependencies(buildtests_c transport_metadata_test)
-add_dependencies(buildtests_c transport_pid_controller_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c transport_security_test)
endif()
@@ -561,7 +392,6 @@ add_dependencies(buildtests_c connection_prefix_bad_client_test)
add_dependencies(buildtests_c head_of_line_blocking_bad_client_test)
add_dependencies(buildtests_c headers_bad_client_test)
add_dependencies(buildtests_c initial_settings_frame_bad_client_test)
-add_dependencies(buildtests_c large_metadata_bad_client_test)
add_dependencies(buildtests_c server_registered_method_bad_client_test)
add_dependencies(buildtests_c simple_request_bad_client_test)
add_dependencies(buildtests_c unknown_frame_bad_client_test)
@@ -592,7 +422,6 @@ add_dependencies(buildtests_c h2_sockpair_test)
add_dependencies(buildtests_c h2_sockpair+trace_test)
add_dependencies(buildtests_c h2_sockpair_1byte_test)
add_dependencies(buildtests_c h2_ssl_test)
-add_dependencies(buildtests_c h2_ssl_cert_test)
add_dependencies(buildtests_c h2_ssl_proxy_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c h2_uds_test)
@@ -637,6 +466,8 @@ add_custom_target(buildtests_cxx)
add_dependencies(buildtests_cxx alarm_cpp_test)
add_dependencies(buildtests_cxx async_end2end_test)
add_dependencies(buildtests_cxx auth_property_iterator_test)
+add_dependencies(buildtests_cxx backoff_test)
+add_dependencies(buildtests_cxx bdp_estimator_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx bm_arena)
endif()
@@ -681,7 +512,9 @@ add_dependencies(buildtests_cxx bm_pollset)
endif()
add_dependencies(buildtests_cxx channel_arguments_test)
add_dependencies(buildtests_cxx channel_filter_test)
+add_dependencies(buildtests_cxx chttp2_settings_timeout_test)
add_dependencies(buildtests_cxx cli_call_test)
+add_dependencies(buildtests_cxx client_channel_stress_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx client_crash_test)
endif()
@@ -696,6 +529,7 @@ add_dependencies(buildtests_cxx cxx_string_ref_test)
add_dependencies(buildtests_cxx cxx_time_test)
add_dependencies(buildtests_cxx end2end_test)
add_dependencies(buildtests_cxx error_details_test)
+add_dependencies(buildtests_cxx exception_test)
add_dependencies(buildtests_cxx filter_end2end_test)
add_dependencies(buildtests_cxx generic_end2end_test)
add_dependencies(buildtests_cxx golden_file_test)
@@ -704,11 +538,16 @@ add_dependencies(buildtests_cxx grpc_tool_test)
add_dependencies(buildtests_cxx grpclb_api_test)
add_dependencies(buildtests_cxx grpclb_end2end_test)
add_dependencies(buildtests_cxx grpclb_test)
+add_dependencies(buildtests_cxx h2_ssl_cert_test)
add_dependencies(buildtests_cxx health_service_end2end_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx http2_client)
endif()
add_dependencies(buildtests_cxx hybrid_end2end_test)
+add_dependencies(buildtests_cxx inlined_vector_test)
+if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
+add_dependencies(buildtests_cxx inproc_sync_unary_ping_pong_test)
+endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx interop_client)
endif()
@@ -725,6 +564,7 @@ add_dependencies(buildtests_cxx memory_test)
add_dependencies(buildtests_cxx metrics_client)
add_dependencies(buildtests_cxx mock_test)
add_dependencies(buildtests_cxx noop-benchmark)
+add_dependencies(buildtests_cxx orphanable_test)
add_dependencies(buildtests_cxx proto_server_reflection_test)
add_dependencies(buildtests_cxx proto_utils_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@@ -737,6 +577,8 @@ endif()
add_dependencies(buildtests_cxx qps_worker)
add_dependencies(buildtests_cxx reconnect_interop_client)
add_dependencies(buildtests_cxx reconnect_interop_server)
+add_dependencies(buildtests_cxx ref_counted_ptr_test)
+add_dependencies(buildtests_cxx ref_counted_test)
add_dependencies(buildtests_cxx secure_auth_context_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx secure_sync_unary_ping_pong_test)
@@ -748,6 +590,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx server_crash_test)
endif()
add_dependencies(buildtests_cxx server_crash_test_client)
+add_dependencies(buildtests_cxx server_early_return_test)
add_dependencies(buildtests_cxx server_request_call_test)
add_dependencies(buildtests_cxx shutdown_test)
add_dependencies(buildtests_cxx stats_test)
@@ -758,6 +601,7 @@ endif()
add_dependencies(buildtests_cxx stress_test)
add_dependencies(buildtests_cxx thread_manager_test)
add_dependencies(buildtests_cxx thread_stress_test)
+add_dependencies(buildtests_cxx transport_pid_controller_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx writes_per_rpc_test)
endif()
@@ -780,52 +624,50 @@ endif (gRPC_BUILD_TESTS)
add_library(gpr
- src/core/lib/profiling/basic_timers.c
- src/core/lib/profiling/stap_timers.c
- src/core/lib/support/alloc.c
- src/core/lib/support/arena.c
- src/core/lib/support/atm.c
- src/core/lib/support/avl.c
- src/core/lib/support/backoff.c
- src/core/lib/support/cmdline.c
- src/core/lib/support/cpu_iphone.c
- src/core/lib/support/cpu_linux.c
- src/core/lib/support/cpu_posix.c
- src/core/lib/support/cpu_windows.c
- src/core/lib/support/env_linux.c
- src/core/lib/support/env_posix.c
- src/core/lib/support/env_windows.c
- src/core/lib/support/histogram.c
- src/core/lib/support/host_port.c
- src/core/lib/support/log.c
- src/core/lib/support/log_android.c
- src/core/lib/support/log_linux.c
- src/core/lib/support/log_posix.c
- src/core/lib/support/log_windows.c
- src/core/lib/support/mpscq.c
- src/core/lib/support/murmur_hash.c
- src/core/lib/support/stack_lockfree.c
- src/core/lib/support/string.c
- src/core/lib/support/string_posix.c
- src/core/lib/support/string_util_windows.c
- src/core/lib/support/string_windows.c
- src/core/lib/support/subprocess_posix.c
- src/core/lib/support/subprocess_windows.c
- src/core/lib/support/sync.c
- src/core/lib/support/sync_posix.c
- src/core/lib/support/sync_windows.c
- src/core/lib/support/thd.c
- src/core/lib/support/thd_posix.c
- src/core/lib/support/thd_windows.c
- src/core/lib/support/time.c
- src/core/lib/support/time_posix.c
- src/core/lib/support/time_precise.c
- src/core/lib/support/time_windows.c
- src/core/lib/support/tls_pthread.c
- src/core/lib/support/tmpfile_msys.c
- src/core/lib/support/tmpfile_posix.c
- src/core/lib/support/tmpfile_windows.c
- src/core/lib/support/wrap_memcpy.c
+ 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
+ src/core/lib/gpr/cpu_posix.cc
+ src/core/lib/gpr/cpu_windows.cc
+ src/core/lib/gpr/env_linux.cc
+ src/core/lib/gpr/env_posix.cc
+ src/core/lib/gpr/env_windows.cc
+ src/core/lib/gpr/fork.cc
+ src/core/lib/gpr/host_port.cc
+ src/core/lib/gpr/log.cc
+ src/core/lib/gpr/log_android.cc
+ src/core/lib/gpr/log_linux.cc
+ src/core/lib/gpr/log_posix.cc
+ src/core/lib/gpr/log_windows.cc
+ src/core/lib/gpr/mpscq.cc
+ src/core/lib/gpr/murmur_hash.cc
+ src/core/lib/gpr/string.cc
+ 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
+ src/core/lib/gpr/thd.cc
+ src/core/lib/gpr/thd_posix.cc
+ src/core/lib/gpr/thd_windows.cc
+ src/core/lib/gpr/time.cc
+ src/core/lib/gpr/time_posix.cc
+ src/core/lib/gpr/time_precise.cc
+ src/core/lib/gpr/time_windows.cc
+ src/core/lib/gpr/tls_pthread.cc
+ 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/wrap_memcpy.cc
+ src/core/lib/profiling/basic_timers.cc
+ src/core/lib/profiling/stap_timers.cc
)
if(WIN32 AND MSVC)
@@ -843,14 +685,12 @@ endif()
target_include_directories(gpr
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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
@@ -866,7 +706,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -889,6 +728,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -917,7 +757,7 @@ endif()
if (gRPC_BUILD_TESTS)
add_library(gpr_test_util
- test/core/util/test_config.c
+ test/core/util/test_config.cc
)
if(WIN32 AND MSVC)
@@ -935,14 +775,12 @@ endif()
target_include_directories(gpr_test_util
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_test_util
@@ -954,267 +792,259 @@ target_link_libraries(gpr_test_util
endif (gRPC_BUILD_TESTS)
add_library(grpc
- src/core/lib/surface/init.c
- src/core/lib/channel/channel_args.c
- src/core/lib/channel/channel_stack.c
- src/core/lib/channel/channel_stack_builder.c
- src/core/lib/channel/connected_channel.c
- src/core/lib/channel/handshaker.c
- src/core/lib/channel/handshaker_factory.c
- src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/compression/stream_compression_gzip.c
- src/core/lib/compression/stream_compression_identity.c
- src/core/lib/debug/stats.c
- src/core/lib/debug/stats_data.c
- src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c
- src/core/lib/iomgr/call_combiner.c
- src/core/lib/iomgr/closure.c
- src/core/lib/iomgr/combiner.c
- src/core/lib/iomgr/endpoint.c
- src/core/lib/iomgr/endpoint_pair_posix.c
- src/core/lib/iomgr/endpoint_pair_uv.c
- src/core/lib/iomgr/endpoint_pair_windows.c
- src/core/lib/iomgr/error.c
- src/core/lib/iomgr/ev_epoll1_linux.c
- src/core/lib/iomgr/ev_epollex_linux.c
- src/core/lib/iomgr/ev_epollsig_linux.c
- src/core/lib/iomgr/ev_poll_posix.c
- src/core/lib/iomgr/ev_posix.c
- src/core/lib/iomgr/ev_windows.c
- src/core/lib/iomgr/exec_ctx.c
- src/core/lib/iomgr/executor.c
- src/core/lib/iomgr/gethostname_fallback.c
- src/core/lib/iomgr/gethostname_host_name_max.c
- src/core/lib/iomgr/gethostname_sysconf.c
- src/core/lib/iomgr/iocp_windows.c
- src/core/lib/iomgr/iomgr.c
- src/core/lib/iomgr/iomgr_posix.c
- src/core/lib/iomgr/iomgr_uv.c
- src/core/lib/iomgr/iomgr_windows.c
- src/core/lib/iomgr/is_epollexclusive_available.c
- src/core/lib/iomgr/load_file.c
- src/core/lib/iomgr/lockfree_event.c
- src/core/lib/iomgr/network_status_tracker.c
- src/core/lib/iomgr/polling_entity.c
- src/core/lib/iomgr/pollset_set_uv.c
- src/core/lib/iomgr/pollset_set_windows.c
- src/core/lib/iomgr/pollset_uv.c
- src/core/lib/iomgr/pollset_windows.c
- src/core/lib/iomgr/resolve_address_posix.c
- src/core/lib/iomgr/resolve_address_uv.c
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
- src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_uv.c
- src/core/lib/iomgr/socket_utils_windows.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_uv.c
- src/core/lib/iomgr/tcp_client_windows.c
- src/core/lib/iomgr/tcp_posix.c
- src/core/lib/iomgr/tcp_server_posix.c
- src/core/lib/iomgr/tcp_server_utils_posix_common.c
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- src/core/lib/iomgr/tcp_server_uv.c
- src/core/lib/iomgr/tcp_server_windows.c
- src/core/lib/iomgr/tcp_uv.c
- src/core/lib/iomgr/tcp_windows.c
- src/core/lib/iomgr/time_averaged_stats.c
- src/core/lib/iomgr/timer_generic.c
- src/core/lib/iomgr/timer_heap.c
- src/core/lib/iomgr/timer_manager.c
- src/core/lib/iomgr/timer_uv.c
- src/core/lib/iomgr/udp_server.c
- src/core/lib/iomgr/unix_sockets_posix.c
- src/core/lib/iomgr/unix_sockets_posix_noop.c
- src/core/lib/iomgr/wakeup_fd_cv.c
- src/core/lib/iomgr/wakeup_fd_eventfd.c
- src/core/lib/iomgr/wakeup_fd_nospecial.c
- src/core/lib/iomgr/wakeup_fd_pipe.c
- src/core/lib/iomgr/wakeup_fd_posix.c
- src/core/lib/json/json.c
- src/core/lib/json/json_reader.c
- src/core/lib/json/json_string.c
- src/core/lib/json/json_writer.c
- src/core/lib/slice/b64.c
- src/core/lib/slice/percent_encoding.c
- src/core/lib/slice/slice.c
- src/core/lib/slice/slice_buffer.c
- src/core/lib/slice/slice_hash_table.c
- src/core/lib/slice/slice_intern.c
- src/core/lib/slice/slice_string_helpers.c
- src/core/lib/surface/alarm.c
- src/core/lib/surface/api_trace.c
- src/core/lib/surface/byte_buffer.c
- src/core/lib/surface/byte_buffer_reader.c
- src/core/lib/surface/call.c
- src/core/lib/surface/call_details.c
- src/core/lib/surface/call_log_batch.c
- src/core/lib/surface/channel.c
- src/core/lib/surface/channel_init.c
- src/core/lib/surface/channel_ping.c
- src/core/lib/surface/channel_stack_type.c
- src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c
+ src/core/lib/surface/init.cc
+ src/core/lib/backoff/backoff.cc
+ src/core/lib/channel/channel_args.cc
+ src/core/lib/channel/channel_stack.cc
+ src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/connected_channel.cc
+ src/core/lib/channel/handshaker.cc
+ src/core/lib/channel/handshaker_factory.cc
+ 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
+ src/core/lib/compression/stream_compression_identity.cc
+ src/core/lib/debug/stats.cc
+ src/core/lib/debug/stats_data.cc
+ src/core/lib/http/format_request.cc
+ src/core/lib/http/httpcli.cc
+ src/core/lib/http/parser.cc
+ src/core/lib/iomgr/call_combiner.cc
+ src/core/lib/iomgr/combiner.cc
+ src/core/lib/iomgr/endpoint.cc
+ src/core/lib/iomgr/endpoint_pair_posix.cc
+ src/core/lib/iomgr/endpoint_pair_uv.cc
+ src/core/lib/iomgr/endpoint_pair_windows.cc
+ src/core/lib/iomgr/error.cc
+ src/core/lib/iomgr/ev_epoll1_linux.cc
+ src/core/lib/iomgr/ev_epollex_linux.cc
+ src/core/lib/iomgr/ev_epollsig_linux.cc
+ src/core/lib/iomgr/ev_poll_posix.cc
+ src/core/lib/iomgr/ev_posix.cc
+ src/core/lib/iomgr/ev_windows.cc
+ src/core/lib/iomgr/exec_ctx.cc
+ src/core/lib/iomgr/executor.cc
+ src/core/lib/iomgr/fork_posix.cc
+ src/core/lib/iomgr/fork_windows.cc
+ src/core/lib/iomgr/gethostname_fallback.cc
+ src/core/lib/iomgr/gethostname_host_name_max.cc
+ src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/iocp_windows.cc
+ src/core/lib/iomgr/iomgr.cc
+ src/core/lib/iomgr/iomgr_posix.cc
+ src/core/lib/iomgr/iomgr_uv.cc
+ src/core/lib/iomgr/iomgr_windows.cc
+ src/core/lib/iomgr/is_epollexclusive_available.cc
+ src/core/lib/iomgr/load_file.cc
+ src/core/lib/iomgr/lockfree_event.cc
+ src/core/lib/iomgr/network_status_tracker.cc
+ src/core/lib/iomgr/polling_entity.cc
+ src/core/lib/iomgr/pollset_set_uv.cc
+ src/core/lib/iomgr/pollset_set_windows.cc
+ src/core/lib/iomgr/pollset_uv.cc
+ src/core/lib/iomgr/pollset_windows.cc
+ src/core/lib/iomgr/resolve_address_posix.cc
+ src/core/lib/iomgr/resolve_address_uv.cc
+ src/core/lib/iomgr/resolve_address_windows.cc
+ src/core/lib/iomgr/resource_quota.cc
+ src/core/lib/iomgr/sockaddr_utils.cc
+ src/core/lib/iomgr/socket_factory_posix.cc
+ src/core/lib/iomgr/socket_mutator.cc
+ src/core/lib/iomgr/socket_utils_common_posix.cc
+ src/core/lib/iomgr/socket_utils_linux.cc
+ src/core/lib/iomgr/socket_utils_posix.cc
+ src/core/lib/iomgr/socket_utils_uv.cc
+ src/core/lib/iomgr/socket_utils_windows.cc
+ src/core/lib/iomgr/socket_windows.cc
+ src/core/lib/iomgr/tcp_client_posix.cc
+ src/core/lib/iomgr/tcp_client_uv.cc
+ src/core/lib/iomgr/tcp_client_windows.cc
+ src/core/lib/iomgr/tcp_posix.cc
+ src/core/lib/iomgr/tcp_server_posix.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ src/core/lib/iomgr/tcp_server_uv.cc
+ src/core/lib/iomgr/tcp_server_windows.cc
+ src/core/lib/iomgr/tcp_uv.cc
+ src/core/lib/iomgr/tcp_windows.cc
+ src/core/lib/iomgr/time_averaged_stats.cc
+ src/core/lib/iomgr/timer_generic.cc
+ src/core/lib/iomgr/timer_heap.cc
+ src/core/lib/iomgr/timer_manager.cc
+ src/core/lib/iomgr/timer_uv.cc
+ src/core/lib/iomgr/udp_server.cc
+ src/core/lib/iomgr/unix_sockets_posix.cc
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ src/core/lib/iomgr/wakeup_fd_cv.cc
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ src/core/lib/iomgr/wakeup_fd_pipe.cc
+ src/core/lib/iomgr/wakeup_fd_posix.cc
+ src/core/lib/json/json.cc
+ src/core/lib/json/json_reader.cc
+ src/core/lib/json/json_string.cc
+ src/core/lib/json/json_writer.cc
+ src/core/lib/slice/b64.cc
+ src/core/lib/slice/percent_encoding.cc
+ src/core/lib/slice/slice.cc
+ src/core/lib/slice/slice_buffer.cc
+ 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
+ src/core/lib/surface/call.cc
+ src/core/lib/surface/call_details.cc
+ src/core/lib/surface/call_log_batch.cc
+ src/core/lib/surface/channel.cc
+ src/core/lib/surface/channel_init.cc
+ src/core/lib/surface/channel_ping.cc
+ src/core/lib/surface/channel_stack_type.cc
+ src/core/lib/surface/completion_queue.cc
+ src/core/lib/surface/completion_queue_factory.cc
+ src/core/lib/surface/event_string.cc
src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c
- src/core/lib/surface/version.c
- src/core/lib/transport/bdp_estimator.c
- src/core/lib/transport/byte_stream.c
- src/core/lib/transport/connectivity_state.c
- src/core/lib/transport/error_utils.c
- src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/service_config.c
- src/core/lib/transport/static_metadata.c
- src/core/lib/transport/status_conversion.c
- src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c
- src/core/lib/transport/transport_op_string.c
- src/core/lib/debug/trace.c
- src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
- src/core/ext/transport/chttp2/transport/bin_decoder.c
- src/core/ext/transport/chttp2/transport/bin_encoder.c
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- src/core/ext/transport/chttp2/transport/chttp2_transport.c
- src/core/ext/transport/chttp2/transport/flow_control.c
- src/core/ext/transport/chttp2/transport/frame_data.c
- src/core/ext/transport/chttp2/transport/frame_goaway.c
- src/core/ext/transport/chttp2/transport/frame_ping.c
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- src/core/ext/transport/chttp2/transport/frame_settings.c
- src/core/ext/transport/chttp2/transport/frame_window_update.c
- src/core/ext/transport/chttp2/transport/hpack_encoder.c
- src/core/ext/transport/chttp2/transport/hpack_parser.c
- src/core/ext/transport/chttp2/transport/hpack_table.c
- src/core/ext/transport/chttp2/transport/http2_settings.c
- src/core/ext/transport/chttp2/transport/huffsyms.c
- src/core/ext/transport/chttp2/transport/incoming_metadata.c
- src/core/ext/transport/chttp2/transport/parsing.c
- src/core/ext/transport/chttp2/transport/stream_lists.c
- src/core/ext/transport/chttp2/transport/stream_map.c
- src/core/ext/transport/chttp2/transport/varint.c
- src/core/ext/transport/chttp2/transport/writing.c
- src/core/ext/transport/chttp2/alpn/alpn.c
- src/core/ext/filters/http/client/http_client_filter.c
- src/core/ext/filters/http/http_filters_plugin.c
- src/core/ext/filters/http/message_compress/message_compress_filter.c
- src/core/ext/filters/http/server/http_server_filter.c
- src/core/lib/http/httpcli_security_connector.c
- src/core/lib/security/context/security_context.c
- src/core/lib/security/credentials/composite/composite_credentials.c
- src/core/lib/security/credentials/credentials.c
- src/core/lib/security/credentials/credentials_metadata.c
- src/core/lib/security/credentials/fake/fake_credentials.c
- src/core/lib/security/credentials/google_default/credentials_generic.c
- src/core/lib/security/credentials/google_default/google_default_credentials.c
- src/core/lib/security/credentials/iam/iam_credentials.c
- src/core/lib/security/credentials/jwt/json_token.c
- src/core/lib/security/credentials/jwt/jwt_credentials.c
- src/core/lib/security/credentials/jwt/jwt_verifier.c
- src/core/lib/security/credentials/oauth2/oauth2_credentials.c
- src/core/lib/security/credentials/plugin/plugin_credentials.c
- src/core/lib/security/credentials/ssl/ssl_credentials.c
- src/core/lib/security/transport/client_auth_filter.c
- src/core/lib/security/transport/lb_targets_info.c
- src/core/lib/security/transport/secure_endpoint.c
- src/core/lib/security/transport/security_connector.c
- src/core/lib/security/transport/security_handshaker.c
- src/core/lib/security/transport/server_auth_filter.c
- src/core/lib/security/transport/tsi_error.c
- src/core/lib/security/util/json_util.c
- src/core/lib/surface/init_secure.c
- src/core/tsi/fake_transport_security.c
- src/core/tsi/gts_transport_security.c
- src/core/tsi/ssl_transport_security.c
- src/core/tsi/transport_security_grpc.c
- src/core/tsi/transport_security.c
- src/core/tsi/transport_security_adapter.c
- src/core/ext/transport/chttp2/server/chttp2_server.c
- src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
- src/core/ext/filters/client_channel/channel_connectivity.c
- src/core/ext/filters/client_channel/client_channel.c
- src/core/ext/filters/client_channel/client_channel_factory.c
- src/core/ext/filters/client_channel/client_channel_plugin.c
- src/core/ext/filters/client_channel/connector.c
- src/core/ext/filters/client_channel/http_connect_handshaker.c
- src/core/ext/filters/client_channel/http_proxy.c
- src/core/ext/filters/client_channel/lb_policy.c
- src/core/ext/filters/client_channel/lb_policy_factory.c
- src/core/ext/filters/client_channel/lb_policy_registry.c
- src/core/ext/filters/client_channel/parse_address.c
- src/core/ext/filters/client_channel/proxy_mapper.c
- src/core/ext/filters/client_channel/proxy_mapper_registry.c
- src/core/ext/filters/client_channel/resolver.c
- src/core/ext/filters/client_channel/resolver_factory.c
- src/core/ext/filters/client_channel/resolver_registry.c
- src/core/ext/filters/client_channel/retry_throttle.c
- src/core/ext/filters/client_channel/subchannel.c
- src/core/ext/filters/client_channel/subchannel_index.c
- src/core/ext/filters/client_channel/uri_parser.c
- src/core/ext/filters/deadline/deadline_filter.c
- src/core/ext/transport/chttp2/client/chttp2_connector.c
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
- src/core/ext/transport/chttp2/client/insecure/channel_create.c
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
- src/core/ext/transport/inproc/inproc_plugin.c
- src/core/ext/transport/inproc/inproc_transport.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
+ src/core/lib/surface/metadata_array.cc
+ src/core/lib/surface/server.cc
+ src/core/lib/surface/validate_metadata.cc
+ src/core/lib/surface/version.cc
+ src/core/lib/transport/bdp_estimator.cc
+ src/core/lib/transport/byte_stream.cc
+ src/core/lib/transport/connectivity_state.cc
+ src/core/lib/transport/error_utils.cc
+ src/core/lib/transport/metadata.cc
+ src/core/lib/transport/metadata_batch.cc
+ src/core/lib/transport/pid_controller.cc
+ src/core/lib/transport/service_config.cc
+ src/core/lib/transport/static_metadata.cc
+ src/core/lib/transport/status_conversion.cc
+ src/core/lib/transport/timeout_encoding.cc
+ src/core/lib/transport/transport.cc
+ src/core/lib/transport/transport_op_string.cc
+ src/core/lib/debug/trace.cc
+ src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ src/core/ext/transport/chttp2/transport/flow_control.cc
+ src/core/ext/transport/chttp2/transport/frame_data.cc
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ src/core/ext/transport/chttp2/transport/frame_ping.cc
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ src/core/ext/transport/chttp2/transport/frame_settings.cc
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ src/core/ext/transport/chttp2/transport/hpack_table.cc
+ src/core/ext/transport/chttp2/transport/http2_settings.cc
+ src/core/ext/transport/chttp2/transport/huffsyms.cc
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ src/core/ext/transport/chttp2/transport/parsing.cc
+ src/core/ext/transport/chttp2/transport/stream_lists.cc
+ 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/ext/transport/chttp2/alpn/alpn.cc
+ src/core/ext/filters/http/client/http_client_filter.cc
+ src/core/ext/filters/http/http_filters_plugin.cc
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ src/core/ext/filters/http/server/http_server_filter.cc
+ src/core/lib/http/httpcli_security_connector.cc
+ src/core/lib/security/context/security_context.cc
+ src/core/lib/security/credentials/composite/composite_credentials.cc
+ src/core/lib/security/credentials/credentials.cc
+ src/core/lib/security/credentials/credentials_metadata.cc
+ src/core/lib/security/credentials/fake/fake_credentials.cc
+ src/core/lib/security/credentials/google_default/credentials_generic.cc
+ src/core/lib/security/credentials/google_default/google_default_credentials.cc
+ src/core/lib/security/credentials/iam/iam_credentials.cc
+ src/core/lib/security/credentials/jwt/json_token.cc
+ src/core/lib/security/credentials/jwt/jwt_credentials.cc
+ src/core/lib/security/credentials/jwt/jwt_verifier.cc
+ src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+ src/core/lib/security/credentials/plugin/plugin_credentials.cc
+ src/core/lib/security/credentials/ssl/ssl_credentials.cc
+ src/core/lib/security/transport/client_auth_filter.cc
+ src/core/lib/security/transport/lb_targets_info.cc
+ src/core/lib/security/transport/secure_endpoint.cc
+ src/core/lib/security/transport/security_connector.cc
+ src/core/lib/security/transport/security_handshaker.cc
+ src/core/lib/security/transport/server_auth_filter.cc
+ src/core/lib/security/transport/tsi_error.cc
+ src/core/lib/security/util/json_util.cc
+ src/core/lib/surface/init_secure.cc
+ src/core/tsi/alts_transport_security.cc
+ src/core/tsi/fake_transport_security.cc
+ src/core/tsi/ssl_transport_security.cc
+ src/core/tsi/transport_security_grpc.cc
+ src/core/tsi/transport_security.cc
+ src/core/tsi/transport_security_adapter.cc
+ src/core/ext/transport/chttp2/server/chttp2_server.cc
+ src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+ src/core/ext/filters/client_channel/backup_poller.cc
+ src/core/ext/filters/client_channel/channel_connectivity.cc
+ src/core/ext/filters/client_channel/client_channel.cc
+ src/core/ext/filters/client_channel/client_channel_factory.cc
+ src/core/ext/filters/client_channel/client_channel_plugin.cc
+ src/core/ext/filters/client_channel/connector.cc
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ src/core/ext/filters/client_channel/http_proxy.cc
+ src/core/ext/filters/client_channel/lb_policy.cc
+ src/core/ext/filters/client_channel/lb_policy_factory.cc
+ src/core/ext/filters/client_channel/lb_policy_registry.cc
+ src/core/ext/filters/client_channel/parse_address.cc
+ 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
+ src/core/ext/filters/client_channel/subchannel_index.cc
+ src/core/ext/filters/client_channel/uri_parser.cc
+ src/core/ext/filters/deadline/deadline_filter.cc
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+ src/core/ext/transport/inproc/inproc_plugin.cc
+ src/core/ext/transport/inproc/inproc_transport.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
third_party/nanopb/pb_common.c
third_party/nanopb/pb_decode.c
third_party/nanopb/pb_encode.c
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
- src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
- src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c
- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c
- src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c
- src/core/ext/census/base_resources.c
- src/core/ext/census/context.c
- src/core/ext/census/gen/census.pb.c
- src/core/ext/census/gen/trace_context.pb.c
- src/core/ext/census/grpc_context.c
- src/core/ext/census/grpc_filter.c
- src/core/ext/census/grpc_plugin.c
- src/core/ext/census/initialize.c
- src/core/ext/census/intrusive_hash_map.c
- src/core/ext/census/mlog.c
- src/core/ext/census/operation.c
- src/core/ext/census/placeholders.c
- src/core/ext/census/resource.c
- src/core/ext/census/trace_context.c
- src/core/ext/census/tracing.c
- src/core/ext/filters/max_age/max_age_filter.c
- src/core/ext/filters/message_size/message_size_filter.c
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c
- src/core/ext/filters/workarounds/workaround_utils.c
- src/core/plugin_registry/grpc_plugin_registry.c
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
+ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
+ src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
+ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
+ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
+ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
+ src/core/ext/census/grpc_context.cc
+ src/core/ext/filters/max_age/max_age_filter.cc
+ src/core/ext/filters/message_size/message_size_filter.cc
+ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
+ src/core/ext/filters/workarounds/workaround_utils.cc
+ src/core/plugin_registry/grpc_plugin_registry.cc
)
if(WIN32 AND MSVC)
@@ -1232,14 +1062,12 @@ endif()
target_include_directories(grpc
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc
@@ -1256,7 +1084,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -1265,6 +1092,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -1277,6 +1105,8 @@ foreach(_hdr
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
include/grpc/grpc_security_constants.h
@@ -1305,225 +1135,230 @@ endif()
add_library(grpc_cronet
- src/core/lib/surface/init.c
- src/core/lib/channel/channel_args.c
- src/core/lib/channel/channel_stack.c
- src/core/lib/channel/channel_stack_builder.c
- src/core/lib/channel/connected_channel.c
- src/core/lib/channel/handshaker.c
- src/core/lib/channel/handshaker_factory.c
- src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/compression/stream_compression_gzip.c
- src/core/lib/compression/stream_compression_identity.c
- src/core/lib/debug/stats.c
- src/core/lib/debug/stats_data.c
- src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c
- src/core/lib/iomgr/call_combiner.c
- src/core/lib/iomgr/closure.c
- src/core/lib/iomgr/combiner.c
- src/core/lib/iomgr/endpoint.c
- src/core/lib/iomgr/endpoint_pair_posix.c
- src/core/lib/iomgr/endpoint_pair_uv.c
- src/core/lib/iomgr/endpoint_pair_windows.c
- src/core/lib/iomgr/error.c
- src/core/lib/iomgr/ev_epoll1_linux.c
- src/core/lib/iomgr/ev_epollex_linux.c
- src/core/lib/iomgr/ev_epollsig_linux.c
- src/core/lib/iomgr/ev_poll_posix.c
- src/core/lib/iomgr/ev_posix.c
- src/core/lib/iomgr/ev_windows.c
- src/core/lib/iomgr/exec_ctx.c
- src/core/lib/iomgr/executor.c
- src/core/lib/iomgr/gethostname_fallback.c
- src/core/lib/iomgr/gethostname_host_name_max.c
- src/core/lib/iomgr/gethostname_sysconf.c
- src/core/lib/iomgr/iocp_windows.c
- src/core/lib/iomgr/iomgr.c
- src/core/lib/iomgr/iomgr_posix.c
- src/core/lib/iomgr/iomgr_uv.c
- src/core/lib/iomgr/iomgr_windows.c
- src/core/lib/iomgr/is_epollexclusive_available.c
- src/core/lib/iomgr/load_file.c
- src/core/lib/iomgr/lockfree_event.c
- src/core/lib/iomgr/network_status_tracker.c
- src/core/lib/iomgr/polling_entity.c
- src/core/lib/iomgr/pollset_set_uv.c
- src/core/lib/iomgr/pollset_set_windows.c
- src/core/lib/iomgr/pollset_uv.c
- src/core/lib/iomgr/pollset_windows.c
- src/core/lib/iomgr/resolve_address_posix.c
- src/core/lib/iomgr/resolve_address_uv.c
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
- src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_uv.c
- src/core/lib/iomgr/socket_utils_windows.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_uv.c
- src/core/lib/iomgr/tcp_client_windows.c
- src/core/lib/iomgr/tcp_posix.c
- src/core/lib/iomgr/tcp_server_posix.c
- src/core/lib/iomgr/tcp_server_utils_posix_common.c
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- src/core/lib/iomgr/tcp_server_uv.c
- src/core/lib/iomgr/tcp_server_windows.c
- src/core/lib/iomgr/tcp_uv.c
- src/core/lib/iomgr/tcp_windows.c
- src/core/lib/iomgr/time_averaged_stats.c
- src/core/lib/iomgr/timer_generic.c
- src/core/lib/iomgr/timer_heap.c
- src/core/lib/iomgr/timer_manager.c
- src/core/lib/iomgr/timer_uv.c
- src/core/lib/iomgr/udp_server.c
- src/core/lib/iomgr/unix_sockets_posix.c
- src/core/lib/iomgr/unix_sockets_posix_noop.c
- src/core/lib/iomgr/wakeup_fd_cv.c
- src/core/lib/iomgr/wakeup_fd_eventfd.c
- src/core/lib/iomgr/wakeup_fd_nospecial.c
- src/core/lib/iomgr/wakeup_fd_pipe.c
- src/core/lib/iomgr/wakeup_fd_posix.c
- src/core/lib/json/json.c
- src/core/lib/json/json_reader.c
- src/core/lib/json/json_string.c
- src/core/lib/json/json_writer.c
- src/core/lib/slice/b64.c
- src/core/lib/slice/percent_encoding.c
- src/core/lib/slice/slice.c
- src/core/lib/slice/slice_buffer.c
- src/core/lib/slice/slice_hash_table.c
- src/core/lib/slice/slice_intern.c
- src/core/lib/slice/slice_string_helpers.c
- src/core/lib/surface/alarm.c
- src/core/lib/surface/api_trace.c
- src/core/lib/surface/byte_buffer.c
- src/core/lib/surface/byte_buffer_reader.c
- src/core/lib/surface/call.c
- src/core/lib/surface/call_details.c
- src/core/lib/surface/call_log_batch.c
- src/core/lib/surface/channel.c
- src/core/lib/surface/channel_init.c
- src/core/lib/surface/channel_ping.c
- src/core/lib/surface/channel_stack_type.c
- src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c
+ src/core/lib/surface/init.cc
+ src/core/lib/backoff/backoff.cc
+ src/core/lib/channel/channel_args.cc
+ src/core/lib/channel/channel_stack.cc
+ src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/connected_channel.cc
+ src/core/lib/channel/handshaker.cc
+ src/core/lib/channel/handshaker_factory.cc
+ 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
+ src/core/lib/compression/stream_compression_identity.cc
+ src/core/lib/debug/stats.cc
+ src/core/lib/debug/stats_data.cc
+ src/core/lib/http/format_request.cc
+ src/core/lib/http/httpcli.cc
+ src/core/lib/http/parser.cc
+ src/core/lib/iomgr/call_combiner.cc
+ src/core/lib/iomgr/combiner.cc
+ src/core/lib/iomgr/endpoint.cc
+ src/core/lib/iomgr/endpoint_pair_posix.cc
+ src/core/lib/iomgr/endpoint_pair_uv.cc
+ src/core/lib/iomgr/endpoint_pair_windows.cc
+ src/core/lib/iomgr/error.cc
+ src/core/lib/iomgr/ev_epoll1_linux.cc
+ src/core/lib/iomgr/ev_epollex_linux.cc
+ src/core/lib/iomgr/ev_epollsig_linux.cc
+ src/core/lib/iomgr/ev_poll_posix.cc
+ src/core/lib/iomgr/ev_posix.cc
+ src/core/lib/iomgr/ev_windows.cc
+ src/core/lib/iomgr/exec_ctx.cc
+ src/core/lib/iomgr/executor.cc
+ src/core/lib/iomgr/fork_posix.cc
+ src/core/lib/iomgr/fork_windows.cc
+ src/core/lib/iomgr/gethostname_fallback.cc
+ src/core/lib/iomgr/gethostname_host_name_max.cc
+ src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/iocp_windows.cc
+ src/core/lib/iomgr/iomgr.cc
+ src/core/lib/iomgr/iomgr_posix.cc
+ src/core/lib/iomgr/iomgr_uv.cc
+ src/core/lib/iomgr/iomgr_windows.cc
+ src/core/lib/iomgr/is_epollexclusive_available.cc
+ src/core/lib/iomgr/load_file.cc
+ src/core/lib/iomgr/lockfree_event.cc
+ src/core/lib/iomgr/network_status_tracker.cc
+ src/core/lib/iomgr/polling_entity.cc
+ src/core/lib/iomgr/pollset_set_uv.cc
+ src/core/lib/iomgr/pollset_set_windows.cc
+ src/core/lib/iomgr/pollset_uv.cc
+ src/core/lib/iomgr/pollset_windows.cc
+ src/core/lib/iomgr/resolve_address_posix.cc
+ src/core/lib/iomgr/resolve_address_uv.cc
+ src/core/lib/iomgr/resolve_address_windows.cc
+ src/core/lib/iomgr/resource_quota.cc
+ src/core/lib/iomgr/sockaddr_utils.cc
+ src/core/lib/iomgr/socket_factory_posix.cc
+ src/core/lib/iomgr/socket_mutator.cc
+ src/core/lib/iomgr/socket_utils_common_posix.cc
+ src/core/lib/iomgr/socket_utils_linux.cc
+ src/core/lib/iomgr/socket_utils_posix.cc
+ src/core/lib/iomgr/socket_utils_uv.cc
+ src/core/lib/iomgr/socket_utils_windows.cc
+ src/core/lib/iomgr/socket_windows.cc
+ src/core/lib/iomgr/tcp_client_posix.cc
+ src/core/lib/iomgr/tcp_client_uv.cc
+ src/core/lib/iomgr/tcp_client_windows.cc
+ src/core/lib/iomgr/tcp_posix.cc
+ src/core/lib/iomgr/tcp_server_posix.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ src/core/lib/iomgr/tcp_server_uv.cc
+ src/core/lib/iomgr/tcp_server_windows.cc
+ src/core/lib/iomgr/tcp_uv.cc
+ src/core/lib/iomgr/tcp_windows.cc
+ src/core/lib/iomgr/time_averaged_stats.cc
+ src/core/lib/iomgr/timer_generic.cc
+ src/core/lib/iomgr/timer_heap.cc
+ src/core/lib/iomgr/timer_manager.cc
+ src/core/lib/iomgr/timer_uv.cc
+ src/core/lib/iomgr/udp_server.cc
+ src/core/lib/iomgr/unix_sockets_posix.cc
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ src/core/lib/iomgr/wakeup_fd_cv.cc
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ src/core/lib/iomgr/wakeup_fd_pipe.cc
+ src/core/lib/iomgr/wakeup_fd_posix.cc
+ src/core/lib/json/json.cc
+ src/core/lib/json/json_reader.cc
+ src/core/lib/json/json_string.cc
+ src/core/lib/json/json_writer.cc
+ src/core/lib/slice/b64.cc
+ src/core/lib/slice/percent_encoding.cc
+ src/core/lib/slice/slice.cc
+ src/core/lib/slice/slice_buffer.cc
+ 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
+ src/core/lib/surface/call.cc
+ src/core/lib/surface/call_details.cc
+ src/core/lib/surface/call_log_batch.cc
+ src/core/lib/surface/channel.cc
+ src/core/lib/surface/channel_init.cc
+ src/core/lib/surface/channel_ping.cc
+ src/core/lib/surface/channel_stack_type.cc
+ src/core/lib/surface/completion_queue.cc
+ src/core/lib/surface/completion_queue_factory.cc
+ src/core/lib/surface/event_string.cc
src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c
- src/core/lib/surface/version.c
- src/core/lib/transport/bdp_estimator.c
- src/core/lib/transport/byte_stream.c
- src/core/lib/transport/connectivity_state.c
- src/core/lib/transport/error_utils.c
- src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/service_config.c
- src/core/lib/transport/static_metadata.c
- src/core/lib/transport/status_conversion.c
- src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c
- src/core/lib/transport/transport_op_string.c
- src/core/lib/debug/trace.c
- src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
- src/core/ext/transport/cronet/transport/cronet_api_dummy.c
- src/core/ext/transport/cronet/transport/cronet_transport.c
- src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
- src/core/ext/transport/chttp2/transport/bin_decoder.c
- src/core/ext/transport/chttp2/transport/bin_encoder.c
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- src/core/ext/transport/chttp2/transport/chttp2_transport.c
- src/core/ext/transport/chttp2/transport/flow_control.c
- src/core/ext/transport/chttp2/transport/frame_data.c
- src/core/ext/transport/chttp2/transport/frame_goaway.c
- src/core/ext/transport/chttp2/transport/frame_ping.c
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- src/core/ext/transport/chttp2/transport/frame_settings.c
- src/core/ext/transport/chttp2/transport/frame_window_update.c
- src/core/ext/transport/chttp2/transport/hpack_encoder.c
- src/core/ext/transport/chttp2/transport/hpack_parser.c
- src/core/ext/transport/chttp2/transport/hpack_table.c
- src/core/ext/transport/chttp2/transport/http2_settings.c
- src/core/ext/transport/chttp2/transport/huffsyms.c
- src/core/ext/transport/chttp2/transport/incoming_metadata.c
- src/core/ext/transport/chttp2/transport/parsing.c
- src/core/ext/transport/chttp2/transport/stream_lists.c
- src/core/ext/transport/chttp2/transport/stream_map.c
- src/core/ext/transport/chttp2/transport/varint.c
- src/core/ext/transport/chttp2/transport/writing.c
- src/core/ext/transport/chttp2/alpn/alpn.c
- src/core/ext/filters/http/client/http_client_filter.c
- src/core/ext/filters/http/http_filters_plugin.c
- src/core/ext/filters/http/message_compress/message_compress_filter.c
- src/core/ext/filters/http/server/http_server_filter.c
- src/core/ext/filters/client_channel/channel_connectivity.c
- src/core/ext/filters/client_channel/client_channel.c
- src/core/ext/filters/client_channel/client_channel_factory.c
- src/core/ext/filters/client_channel/client_channel_plugin.c
- src/core/ext/filters/client_channel/connector.c
- src/core/ext/filters/client_channel/http_connect_handshaker.c
- src/core/ext/filters/client_channel/http_proxy.c
- src/core/ext/filters/client_channel/lb_policy.c
- src/core/ext/filters/client_channel/lb_policy_factory.c
- src/core/ext/filters/client_channel/lb_policy_registry.c
- src/core/ext/filters/client_channel/parse_address.c
- src/core/ext/filters/client_channel/proxy_mapper.c
- src/core/ext/filters/client_channel/proxy_mapper_registry.c
- src/core/ext/filters/client_channel/resolver.c
- src/core/ext/filters/client_channel/resolver_factory.c
- src/core/ext/filters/client_channel/resolver_registry.c
- src/core/ext/filters/client_channel/retry_throttle.c
- src/core/ext/filters/client_channel/subchannel.c
- src/core/ext/filters/client_channel/subchannel_index.c
- src/core/ext/filters/client_channel/uri_parser.c
- src/core/ext/filters/deadline/deadline_filter.c
- src/core/lib/http/httpcli_security_connector.c
- src/core/lib/security/context/security_context.c
- src/core/lib/security/credentials/composite/composite_credentials.c
- src/core/lib/security/credentials/credentials.c
- src/core/lib/security/credentials/credentials_metadata.c
- src/core/lib/security/credentials/fake/fake_credentials.c
- src/core/lib/security/credentials/google_default/credentials_generic.c
- src/core/lib/security/credentials/google_default/google_default_credentials.c
- src/core/lib/security/credentials/iam/iam_credentials.c
- src/core/lib/security/credentials/jwt/json_token.c
- src/core/lib/security/credentials/jwt/jwt_credentials.c
- src/core/lib/security/credentials/jwt/jwt_verifier.c
- src/core/lib/security/credentials/oauth2/oauth2_credentials.c
- src/core/lib/security/credentials/plugin/plugin_credentials.c
- src/core/lib/security/credentials/ssl/ssl_credentials.c
- src/core/lib/security/transport/client_auth_filter.c
- src/core/lib/security/transport/lb_targets_info.c
- src/core/lib/security/transport/secure_endpoint.c
- src/core/lib/security/transport/security_connector.c
- src/core/lib/security/transport/security_handshaker.c
- src/core/lib/security/transport/server_auth_filter.c
- src/core/lib/security/transport/tsi_error.c
- src/core/lib/security/util/json_util.c
- src/core/lib/surface/init_secure.c
- src/core/tsi/fake_transport_security.c
- src/core/tsi/gts_transport_security.c
- src/core/tsi/ssl_transport_security.c
- src/core/tsi/transport_security_grpc.c
- src/core/tsi/transport_security.c
- src/core/tsi/transport_security_adapter.c
- src/core/ext/transport/chttp2/client/chttp2_connector.c
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c
- src/core/plugin_registry/grpc_cronet_plugin_registry.c
+ src/core/lib/surface/metadata_array.cc
+ src/core/lib/surface/server.cc
+ src/core/lib/surface/validate_metadata.cc
+ src/core/lib/surface/version.cc
+ src/core/lib/transport/bdp_estimator.cc
+ src/core/lib/transport/byte_stream.cc
+ src/core/lib/transport/connectivity_state.cc
+ src/core/lib/transport/error_utils.cc
+ src/core/lib/transport/metadata.cc
+ src/core/lib/transport/metadata_batch.cc
+ src/core/lib/transport/pid_controller.cc
+ src/core/lib/transport/service_config.cc
+ src/core/lib/transport/static_metadata.cc
+ src/core/lib/transport/status_conversion.cc
+ src/core/lib/transport/timeout_encoding.cc
+ src/core/lib/transport/transport.cc
+ src/core/lib/transport/transport_op_string.cc
+ src/core/lib/debug/trace.cc
+ src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
+ src/core/ext/transport/cronet/transport/cronet_api_dummy.cc
+ src/core/ext/transport/cronet/transport/cronet_transport.cc
+ src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ src/core/ext/transport/chttp2/transport/flow_control.cc
+ src/core/ext/transport/chttp2/transport/frame_data.cc
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ src/core/ext/transport/chttp2/transport/frame_ping.cc
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ src/core/ext/transport/chttp2/transport/frame_settings.cc
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ src/core/ext/transport/chttp2/transport/hpack_table.cc
+ src/core/ext/transport/chttp2/transport/http2_settings.cc
+ src/core/ext/transport/chttp2/transport/huffsyms.cc
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ src/core/ext/transport/chttp2/transport/parsing.cc
+ src/core/ext/transport/chttp2/transport/stream_lists.cc
+ 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/ext/transport/chttp2/alpn/alpn.cc
+ src/core/ext/filters/http/client/http_client_filter.cc
+ src/core/ext/filters/http/http_filters_plugin.cc
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ src/core/ext/filters/http/server/http_server_filter.cc
+ src/core/ext/filters/client_channel/backup_poller.cc
+ src/core/ext/filters/client_channel/channel_connectivity.cc
+ src/core/ext/filters/client_channel/client_channel.cc
+ src/core/ext/filters/client_channel/client_channel_factory.cc
+ src/core/ext/filters/client_channel/client_channel_plugin.cc
+ src/core/ext/filters/client_channel/connector.cc
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ src/core/ext/filters/client_channel/http_proxy.cc
+ src/core/ext/filters/client_channel/lb_policy.cc
+ src/core/ext/filters/client_channel/lb_policy_factory.cc
+ src/core/ext/filters/client_channel/lb_policy_registry.cc
+ src/core/ext/filters/client_channel/parse_address.cc
+ 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
+ src/core/ext/filters/client_channel/subchannel_index.cc
+ src/core/ext/filters/client_channel/uri_parser.cc
+ src/core/ext/filters/deadline/deadline_filter.cc
+ src/core/lib/http/httpcli_security_connector.cc
+ src/core/lib/security/context/security_context.cc
+ src/core/lib/security/credentials/composite/composite_credentials.cc
+ src/core/lib/security/credentials/credentials.cc
+ src/core/lib/security/credentials/credentials_metadata.cc
+ src/core/lib/security/credentials/fake/fake_credentials.cc
+ src/core/lib/security/credentials/google_default/credentials_generic.cc
+ src/core/lib/security/credentials/google_default/google_default_credentials.cc
+ src/core/lib/security/credentials/iam/iam_credentials.cc
+ src/core/lib/security/credentials/jwt/json_token.cc
+ src/core/lib/security/credentials/jwt/jwt_credentials.cc
+ src/core/lib/security/credentials/jwt/jwt_verifier.cc
+ src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+ src/core/lib/security/credentials/plugin/plugin_credentials.cc
+ src/core/lib/security/credentials/ssl/ssl_credentials.cc
+ src/core/lib/security/transport/client_auth_filter.cc
+ src/core/lib/security/transport/lb_targets_info.cc
+ src/core/lib/security/transport/secure_endpoint.cc
+ src/core/lib/security/transport/security_connector.cc
+ src/core/lib/security/transport/security_handshaker.cc
+ src/core/lib/security/transport/server_auth_filter.cc
+ src/core/lib/security/transport/tsi_error.cc
+ src/core/lib/security/util/json_util.cc
+ src/core/lib/surface/init_secure.cc
+ src/core/tsi/alts_transport_security.cc
+ src/core/tsi/fake_transport_security.cc
+ src/core/tsi/ssl_transport_security.cc
+ src/core/tsi/transport_security_grpc.cc
+ src/core/tsi/transport_security.cc
+ src/core/tsi/transport_security_adapter.cc
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
+ src/core/plugin_registry/grpc_cronet_plugin_registry.cc
)
if(WIN32 AND MSVC)
@@ -1541,14 +1376,12 @@ endif()
target_include_directories(grpc_cronet
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_cronet
@@ -1565,7 +1398,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -1574,6 +1406,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -1605,206 +1438,214 @@ endif()
if (gRPC_BUILD_TESTS)
add_library(grpc_test_util
- test/core/end2end/data/client_certs.c
- test/core/end2end/data/server1_cert.c
- test/core/end2end/data/server1_key.c
- test/core/end2end/data/test_root_cert.c
- test/core/security/oauth2_utils.c
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
- test/core/end2end/cq_verifier.c
- test/core/end2end/fixtures/http_proxy_fixture.c
- test/core/end2end/fixtures/proxy.c
- test/core/iomgr/endpoint_tests.c
- test/core/util/debugger_macros.c
- test/core/util/grpc_profiler.c
- test/core/util/memory_counters.c
- test/core/util/mock_endpoint.c
- test/core/util/parse_hexstring.c
- test/core/util/passthru_endpoint.c
- test/core/util/port.c
- test/core/util/port_server_client.c
- test/core/util/slice_splitter.c
- test/core/util/trickle_endpoint.c
- src/core/lib/channel/channel_args.c
- src/core/lib/channel/channel_stack.c
- src/core/lib/channel/channel_stack_builder.c
- src/core/lib/channel/connected_channel.c
- src/core/lib/channel/handshaker.c
- src/core/lib/channel/handshaker_factory.c
- src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/compression/stream_compression_gzip.c
- src/core/lib/compression/stream_compression_identity.c
- src/core/lib/debug/stats.c
- src/core/lib/debug/stats_data.c
- src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c
- src/core/lib/iomgr/call_combiner.c
- src/core/lib/iomgr/closure.c
- src/core/lib/iomgr/combiner.c
- src/core/lib/iomgr/endpoint.c
- src/core/lib/iomgr/endpoint_pair_posix.c
- src/core/lib/iomgr/endpoint_pair_uv.c
- src/core/lib/iomgr/endpoint_pair_windows.c
- src/core/lib/iomgr/error.c
- src/core/lib/iomgr/ev_epoll1_linux.c
- src/core/lib/iomgr/ev_epollex_linux.c
- src/core/lib/iomgr/ev_epollsig_linux.c
- src/core/lib/iomgr/ev_poll_posix.c
- src/core/lib/iomgr/ev_posix.c
- src/core/lib/iomgr/ev_windows.c
- src/core/lib/iomgr/exec_ctx.c
- src/core/lib/iomgr/executor.c
- src/core/lib/iomgr/gethostname_fallback.c
- src/core/lib/iomgr/gethostname_host_name_max.c
- src/core/lib/iomgr/gethostname_sysconf.c
- src/core/lib/iomgr/iocp_windows.c
- src/core/lib/iomgr/iomgr.c
- src/core/lib/iomgr/iomgr_posix.c
- src/core/lib/iomgr/iomgr_uv.c
- src/core/lib/iomgr/iomgr_windows.c
- src/core/lib/iomgr/is_epollexclusive_available.c
- src/core/lib/iomgr/load_file.c
- src/core/lib/iomgr/lockfree_event.c
- src/core/lib/iomgr/network_status_tracker.c
- src/core/lib/iomgr/polling_entity.c
- src/core/lib/iomgr/pollset_set_uv.c
- src/core/lib/iomgr/pollset_set_windows.c
- src/core/lib/iomgr/pollset_uv.c
- src/core/lib/iomgr/pollset_windows.c
- src/core/lib/iomgr/resolve_address_posix.c
- src/core/lib/iomgr/resolve_address_uv.c
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
- src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_uv.c
- src/core/lib/iomgr/socket_utils_windows.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_uv.c
- src/core/lib/iomgr/tcp_client_windows.c
- src/core/lib/iomgr/tcp_posix.c
- src/core/lib/iomgr/tcp_server_posix.c
- src/core/lib/iomgr/tcp_server_utils_posix_common.c
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- src/core/lib/iomgr/tcp_server_uv.c
- src/core/lib/iomgr/tcp_server_windows.c
- src/core/lib/iomgr/tcp_uv.c
- src/core/lib/iomgr/tcp_windows.c
- src/core/lib/iomgr/time_averaged_stats.c
- src/core/lib/iomgr/timer_generic.c
- src/core/lib/iomgr/timer_heap.c
- src/core/lib/iomgr/timer_manager.c
- src/core/lib/iomgr/timer_uv.c
- src/core/lib/iomgr/udp_server.c
- src/core/lib/iomgr/unix_sockets_posix.c
- src/core/lib/iomgr/unix_sockets_posix_noop.c
- src/core/lib/iomgr/wakeup_fd_cv.c
- src/core/lib/iomgr/wakeup_fd_eventfd.c
- src/core/lib/iomgr/wakeup_fd_nospecial.c
- src/core/lib/iomgr/wakeup_fd_pipe.c
- src/core/lib/iomgr/wakeup_fd_posix.c
- src/core/lib/json/json.c
- src/core/lib/json/json_reader.c
- src/core/lib/json/json_string.c
- src/core/lib/json/json_writer.c
- src/core/lib/slice/b64.c
- src/core/lib/slice/percent_encoding.c
- src/core/lib/slice/slice.c
- src/core/lib/slice/slice_buffer.c
- src/core/lib/slice/slice_hash_table.c
- src/core/lib/slice/slice_intern.c
- src/core/lib/slice/slice_string_helpers.c
- src/core/lib/surface/alarm.c
- src/core/lib/surface/api_trace.c
- src/core/lib/surface/byte_buffer.c
- src/core/lib/surface/byte_buffer_reader.c
- src/core/lib/surface/call.c
- src/core/lib/surface/call_details.c
- src/core/lib/surface/call_log_batch.c
- src/core/lib/surface/channel.c
- src/core/lib/surface/channel_init.c
- src/core/lib/surface/channel_ping.c
- src/core/lib/surface/channel_stack_type.c
- src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c
+ test/core/end2end/data/client_certs.cc
+ test/core/end2end/data/server1_cert.cc
+ test/core/end2end/data/server1_key.cc
+ test/core/end2end/data/test_root_cert.cc
+ test/core/security/oauth2_utils.cc
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
+ test/core/end2end/cq_verifier.cc
+ test/core/end2end/fixtures/http_proxy_fixture.cc
+ test/core/end2end/fixtures/proxy.cc
+ test/core/iomgr/endpoint_tests.cc
+ test/core/util/debugger_macros.cc
+ test/core/util/grpc_profiler.cc
+ test/core/util/histogram.cc
+ test/core/util/memory_counters.cc
+ test/core/util/mock_endpoint.cc
+ test/core/util/parse_hexstring.cc
+ test/core/util/passthru_endpoint.cc
+ test/core/util/port.cc
+ test/core/util/port_isolated_runtime_environment.cc
+ test/core/util/port_server_client.cc
+ test/core/util/slice_splitter.cc
+ test/core/util/tracer_util.cc
+ test/core/util/trickle_endpoint.cc
+ src/core/lib/backoff/backoff.cc
+ src/core/lib/channel/channel_args.cc
+ src/core/lib/channel/channel_stack.cc
+ src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/connected_channel.cc
+ src/core/lib/channel/handshaker.cc
+ src/core/lib/channel/handshaker_factory.cc
+ 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
+ src/core/lib/compression/stream_compression_identity.cc
+ src/core/lib/debug/stats.cc
+ src/core/lib/debug/stats_data.cc
+ src/core/lib/http/format_request.cc
+ src/core/lib/http/httpcli.cc
+ src/core/lib/http/parser.cc
+ src/core/lib/iomgr/call_combiner.cc
+ src/core/lib/iomgr/combiner.cc
+ src/core/lib/iomgr/endpoint.cc
+ src/core/lib/iomgr/endpoint_pair_posix.cc
+ src/core/lib/iomgr/endpoint_pair_uv.cc
+ src/core/lib/iomgr/endpoint_pair_windows.cc
+ src/core/lib/iomgr/error.cc
+ src/core/lib/iomgr/ev_epoll1_linux.cc
+ src/core/lib/iomgr/ev_epollex_linux.cc
+ src/core/lib/iomgr/ev_epollsig_linux.cc
+ src/core/lib/iomgr/ev_poll_posix.cc
+ src/core/lib/iomgr/ev_posix.cc
+ src/core/lib/iomgr/ev_windows.cc
+ src/core/lib/iomgr/exec_ctx.cc
+ src/core/lib/iomgr/executor.cc
+ src/core/lib/iomgr/fork_posix.cc
+ src/core/lib/iomgr/fork_windows.cc
+ src/core/lib/iomgr/gethostname_fallback.cc
+ src/core/lib/iomgr/gethostname_host_name_max.cc
+ src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/iocp_windows.cc
+ src/core/lib/iomgr/iomgr.cc
+ src/core/lib/iomgr/iomgr_posix.cc
+ src/core/lib/iomgr/iomgr_uv.cc
+ src/core/lib/iomgr/iomgr_windows.cc
+ src/core/lib/iomgr/is_epollexclusive_available.cc
+ src/core/lib/iomgr/load_file.cc
+ src/core/lib/iomgr/lockfree_event.cc
+ src/core/lib/iomgr/network_status_tracker.cc
+ src/core/lib/iomgr/polling_entity.cc
+ src/core/lib/iomgr/pollset_set_uv.cc
+ src/core/lib/iomgr/pollset_set_windows.cc
+ src/core/lib/iomgr/pollset_uv.cc
+ src/core/lib/iomgr/pollset_windows.cc
+ src/core/lib/iomgr/resolve_address_posix.cc
+ src/core/lib/iomgr/resolve_address_uv.cc
+ src/core/lib/iomgr/resolve_address_windows.cc
+ src/core/lib/iomgr/resource_quota.cc
+ src/core/lib/iomgr/sockaddr_utils.cc
+ src/core/lib/iomgr/socket_factory_posix.cc
+ src/core/lib/iomgr/socket_mutator.cc
+ src/core/lib/iomgr/socket_utils_common_posix.cc
+ src/core/lib/iomgr/socket_utils_linux.cc
+ src/core/lib/iomgr/socket_utils_posix.cc
+ src/core/lib/iomgr/socket_utils_uv.cc
+ src/core/lib/iomgr/socket_utils_windows.cc
+ src/core/lib/iomgr/socket_windows.cc
+ src/core/lib/iomgr/tcp_client_posix.cc
+ src/core/lib/iomgr/tcp_client_uv.cc
+ src/core/lib/iomgr/tcp_client_windows.cc
+ src/core/lib/iomgr/tcp_posix.cc
+ src/core/lib/iomgr/tcp_server_posix.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ src/core/lib/iomgr/tcp_server_uv.cc
+ src/core/lib/iomgr/tcp_server_windows.cc
+ src/core/lib/iomgr/tcp_uv.cc
+ src/core/lib/iomgr/tcp_windows.cc
+ src/core/lib/iomgr/time_averaged_stats.cc
+ src/core/lib/iomgr/timer_generic.cc
+ src/core/lib/iomgr/timer_heap.cc
+ src/core/lib/iomgr/timer_manager.cc
+ src/core/lib/iomgr/timer_uv.cc
+ src/core/lib/iomgr/udp_server.cc
+ src/core/lib/iomgr/unix_sockets_posix.cc
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ src/core/lib/iomgr/wakeup_fd_cv.cc
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ src/core/lib/iomgr/wakeup_fd_pipe.cc
+ src/core/lib/iomgr/wakeup_fd_posix.cc
+ src/core/lib/json/json.cc
+ src/core/lib/json/json_reader.cc
+ src/core/lib/json/json_string.cc
+ src/core/lib/json/json_writer.cc
+ src/core/lib/slice/b64.cc
+ src/core/lib/slice/percent_encoding.cc
+ src/core/lib/slice/slice.cc
+ src/core/lib/slice/slice_buffer.cc
+ 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
+ src/core/lib/surface/call.cc
+ src/core/lib/surface/call_details.cc
+ src/core/lib/surface/call_log_batch.cc
+ src/core/lib/surface/channel.cc
+ src/core/lib/surface/channel_init.cc
+ src/core/lib/surface/channel_ping.cc
+ src/core/lib/surface/channel_stack_type.cc
+ src/core/lib/surface/completion_queue.cc
+ src/core/lib/surface/completion_queue_factory.cc
+ src/core/lib/surface/event_string.cc
src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c
- src/core/lib/surface/version.c
- src/core/lib/transport/bdp_estimator.c
- src/core/lib/transport/byte_stream.c
- src/core/lib/transport/connectivity_state.c
- src/core/lib/transport/error_utils.c
- src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/service_config.c
- src/core/lib/transport/static_metadata.c
- src/core/lib/transport/status_conversion.c
- src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c
- src/core/lib/transport/transport_op_string.c
- src/core/lib/debug/trace.c
- src/core/ext/filters/client_channel/channel_connectivity.c
- src/core/ext/filters/client_channel/client_channel.c
- src/core/ext/filters/client_channel/client_channel_factory.c
- src/core/ext/filters/client_channel/client_channel_plugin.c
- src/core/ext/filters/client_channel/connector.c
- src/core/ext/filters/client_channel/http_connect_handshaker.c
- src/core/ext/filters/client_channel/http_proxy.c
- src/core/ext/filters/client_channel/lb_policy.c
- src/core/ext/filters/client_channel/lb_policy_factory.c
- src/core/ext/filters/client_channel/lb_policy_registry.c
- src/core/ext/filters/client_channel/parse_address.c
- src/core/ext/filters/client_channel/proxy_mapper.c
- src/core/ext/filters/client_channel/proxy_mapper_registry.c
- src/core/ext/filters/client_channel/resolver.c
- src/core/ext/filters/client_channel/resolver_factory.c
- src/core/ext/filters/client_channel/resolver_registry.c
- src/core/ext/filters/client_channel/retry_throttle.c
- src/core/ext/filters/client_channel/subchannel.c
- src/core/ext/filters/client_channel/subchannel_index.c
- src/core/ext/filters/client_channel/uri_parser.c
- src/core/ext/filters/deadline/deadline_filter.c
- src/core/ext/transport/chttp2/transport/bin_decoder.c
- src/core/ext/transport/chttp2/transport/bin_encoder.c
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- src/core/ext/transport/chttp2/transport/chttp2_transport.c
- src/core/ext/transport/chttp2/transport/flow_control.c
- src/core/ext/transport/chttp2/transport/frame_data.c
- src/core/ext/transport/chttp2/transport/frame_goaway.c
- src/core/ext/transport/chttp2/transport/frame_ping.c
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- src/core/ext/transport/chttp2/transport/frame_settings.c
- src/core/ext/transport/chttp2/transport/frame_window_update.c
- src/core/ext/transport/chttp2/transport/hpack_encoder.c
- src/core/ext/transport/chttp2/transport/hpack_parser.c
- src/core/ext/transport/chttp2/transport/hpack_table.c
- src/core/ext/transport/chttp2/transport/http2_settings.c
- src/core/ext/transport/chttp2/transport/huffsyms.c
- src/core/ext/transport/chttp2/transport/incoming_metadata.c
- src/core/ext/transport/chttp2/transport/parsing.c
- src/core/ext/transport/chttp2/transport/stream_lists.c
- src/core/ext/transport/chttp2/transport/stream_map.c
- src/core/ext/transport/chttp2/transport/varint.c
- src/core/ext/transport/chttp2/transport/writing.c
- src/core/ext/transport/chttp2/alpn/alpn.c
- src/core/ext/filters/http/client/http_client_filter.c
- src/core/ext/filters/http/http_filters_plugin.c
- src/core/ext/filters/http/message_compress/message_compress_filter.c
- src/core/ext/filters/http/server/http_server_filter.c
+ src/core/lib/surface/metadata_array.cc
+ src/core/lib/surface/server.cc
+ src/core/lib/surface/validate_metadata.cc
+ src/core/lib/surface/version.cc
+ src/core/lib/transport/bdp_estimator.cc
+ src/core/lib/transport/byte_stream.cc
+ src/core/lib/transport/connectivity_state.cc
+ src/core/lib/transport/error_utils.cc
+ src/core/lib/transport/metadata.cc
+ src/core/lib/transport/metadata_batch.cc
+ src/core/lib/transport/pid_controller.cc
+ src/core/lib/transport/service_config.cc
+ src/core/lib/transport/static_metadata.cc
+ src/core/lib/transport/status_conversion.cc
+ src/core/lib/transport/timeout_encoding.cc
+ src/core/lib/transport/transport.cc
+ src/core/lib/transport/transport_op_string.cc
+ src/core/lib/debug/trace.cc
+ src/core/ext/filters/client_channel/backup_poller.cc
+ src/core/ext/filters/client_channel/channel_connectivity.cc
+ src/core/ext/filters/client_channel/client_channel.cc
+ src/core/ext/filters/client_channel/client_channel_factory.cc
+ src/core/ext/filters/client_channel/client_channel_plugin.cc
+ src/core/ext/filters/client_channel/connector.cc
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ src/core/ext/filters/client_channel/http_proxy.cc
+ src/core/ext/filters/client_channel/lb_policy.cc
+ src/core/ext/filters/client_channel/lb_policy_factory.cc
+ src/core/ext/filters/client_channel/lb_policy_registry.cc
+ src/core/ext/filters/client_channel/parse_address.cc
+ 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
+ src/core/ext/filters/client_channel/subchannel_index.cc
+ src/core/ext/filters/client_channel/uri_parser.cc
+ src/core/ext/filters/deadline/deadline_filter.cc
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ src/core/ext/transport/chttp2/transport/flow_control.cc
+ src/core/ext/transport/chttp2/transport/frame_data.cc
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ src/core/ext/transport/chttp2/transport/frame_ping.cc
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ src/core/ext/transport/chttp2/transport/frame_settings.cc
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ src/core/ext/transport/chttp2/transport/hpack_table.cc
+ src/core/ext/transport/chttp2/transport/http2_settings.cc
+ src/core/ext/transport/chttp2/transport/huffsyms.cc
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ src/core/ext/transport/chttp2/transport/parsing.cc
+ src/core/ext/transport/chttp2/transport/stream_lists.cc
+ 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/ext/transport/chttp2/alpn/alpn.cc
+ src/core/ext/filters/http/client/http_client_filter.cc
+ src/core/ext/filters/http/http_filters_plugin.cc
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ src/core/ext/filters/http/server/http_server_filter.cc
)
if(WIN32 AND MSVC)
@@ -1822,14 +1663,12 @@ endif()
target_include_directories(grpc_test_util
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_test_util
@@ -1844,7 +1683,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -1853,6 +1691,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -1873,201 +1712,209 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_library(grpc_test_util_unsecure
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
- test/core/end2end/cq_verifier.c
- test/core/end2end/fixtures/http_proxy_fixture.c
- test/core/end2end/fixtures/proxy.c
- test/core/iomgr/endpoint_tests.c
- test/core/util/debugger_macros.c
- test/core/util/grpc_profiler.c
- test/core/util/memory_counters.c
- test/core/util/mock_endpoint.c
- test/core/util/parse_hexstring.c
- test/core/util/passthru_endpoint.c
- test/core/util/port.c
- test/core/util/port_server_client.c
- test/core/util/slice_splitter.c
- test/core/util/trickle_endpoint.c
- src/core/lib/channel/channel_args.c
- src/core/lib/channel/channel_stack.c
- src/core/lib/channel/channel_stack_builder.c
- src/core/lib/channel/connected_channel.c
- src/core/lib/channel/handshaker.c
- src/core/lib/channel/handshaker_factory.c
- src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/compression/stream_compression_gzip.c
- src/core/lib/compression/stream_compression_identity.c
- src/core/lib/debug/stats.c
- src/core/lib/debug/stats_data.c
- src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c
- src/core/lib/iomgr/call_combiner.c
- src/core/lib/iomgr/closure.c
- src/core/lib/iomgr/combiner.c
- src/core/lib/iomgr/endpoint.c
- src/core/lib/iomgr/endpoint_pair_posix.c
- src/core/lib/iomgr/endpoint_pair_uv.c
- src/core/lib/iomgr/endpoint_pair_windows.c
- src/core/lib/iomgr/error.c
- src/core/lib/iomgr/ev_epoll1_linux.c
- src/core/lib/iomgr/ev_epollex_linux.c
- src/core/lib/iomgr/ev_epollsig_linux.c
- src/core/lib/iomgr/ev_poll_posix.c
- src/core/lib/iomgr/ev_posix.c
- src/core/lib/iomgr/ev_windows.c
- src/core/lib/iomgr/exec_ctx.c
- src/core/lib/iomgr/executor.c
- src/core/lib/iomgr/gethostname_fallback.c
- src/core/lib/iomgr/gethostname_host_name_max.c
- src/core/lib/iomgr/gethostname_sysconf.c
- src/core/lib/iomgr/iocp_windows.c
- src/core/lib/iomgr/iomgr.c
- src/core/lib/iomgr/iomgr_posix.c
- src/core/lib/iomgr/iomgr_uv.c
- src/core/lib/iomgr/iomgr_windows.c
- src/core/lib/iomgr/is_epollexclusive_available.c
- src/core/lib/iomgr/load_file.c
- src/core/lib/iomgr/lockfree_event.c
- src/core/lib/iomgr/network_status_tracker.c
- src/core/lib/iomgr/polling_entity.c
- src/core/lib/iomgr/pollset_set_uv.c
- src/core/lib/iomgr/pollset_set_windows.c
- src/core/lib/iomgr/pollset_uv.c
- src/core/lib/iomgr/pollset_windows.c
- src/core/lib/iomgr/resolve_address_posix.c
- src/core/lib/iomgr/resolve_address_uv.c
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
- src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_uv.c
- src/core/lib/iomgr/socket_utils_windows.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_uv.c
- src/core/lib/iomgr/tcp_client_windows.c
- src/core/lib/iomgr/tcp_posix.c
- src/core/lib/iomgr/tcp_server_posix.c
- src/core/lib/iomgr/tcp_server_utils_posix_common.c
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- src/core/lib/iomgr/tcp_server_uv.c
- src/core/lib/iomgr/tcp_server_windows.c
- src/core/lib/iomgr/tcp_uv.c
- src/core/lib/iomgr/tcp_windows.c
- src/core/lib/iomgr/time_averaged_stats.c
- src/core/lib/iomgr/timer_generic.c
- src/core/lib/iomgr/timer_heap.c
- src/core/lib/iomgr/timer_manager.c
- src/core/lib/iomgr/timer_uv.c
- src/core/lib/iomgr/udp_server.c
- src/core/lib/iomgr/unix_sockets_posix.c
- src/core/lib/iomgr/unix_sockets_posix_noop.c
- src/core/lib/iomgr/wakeup_fd_cv.c
- src/core/lib/iomgr/wakeup_fd_eventfd.c
- src/core/lib/iomgr/wakeup_fd_nospecial.c
- src/core/lib/iomgr/wakeup_fd_pipe.c
- src/core/lib/iomgr/wakeup_fd_posix.c
- src/core/lib/json/json.c
- src/core/lib/json/json_reader.c
- src/core/lib/json/json_string.c
- src/core/lib/json/json_writer.c
- src/core/lib/slice/b64.c
- src/core/lib/slice/percent_encoding.c
- src/core/lib/slice/slice.c
- src/core/lib/slice/slice_buffer.c
- src/core/lib/slice/slice_hash_table.c
- src/core/lib/slice/slice_intern.c
- src/core/lib/slice/slice_string_helpers.c
- src/core/lib/surface/alarm.c
- src/core/lib/surface/api_trace.c
- src/core/lib/surface/byte_buffer.c
- src/core/lib/surface/byte_buffer_reader.c
- src/core/lib/surface/call.c
- src/core/lib/surface/call_details.c
- src/core/lib/surface/call_log_batch.c
- src/core/lib/surface/channel.c
- src/core/lib/surface/channel_init.c
- src/core/lib/surface/channel_ping.c
- src/core/lib/surface/channel_stack_type.c
- src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
+ test/core/end2end/cq_verifier.cc
+ test/core/end2end/fixtures/http_proxy_fixture.cc
+ test/core/end2end/fixtures/proxy.cc
+ test/core/iomgr/endpoint_tests.cc
+ test/core/util/debugger_macros.cc
+ test/core/util/grpc_profiler.cc
+ test/core/util/histogram.cc
+ test/core/util/memory_counters.cc
+ test/core/util/mock_endpoint.cc
+ test/core/util/parse_hexstring.cc
+ test/core/util/passthru_endpoint.cc
+ test/core/util/port.cc
+ test/core/util/port_isolated_runtime_environment.cc
+ test/core/util/port_server_client.cc
+ test/core/util/slice_splitter.cc
+ test/core/util/tracer_util.cc
+ test/core/util/trickle_endpoint.cc
+ src/core/lib/backoff/backoff.cc
+ src/core/lib/channel/channel_args.cc
+ src/core/lib/channel/channel_stack.cc
+ src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/connected_channel.cc
+ src/core/lib/channel/handshaker.cc
+ src/core/lib/channel/handshaker_factory.cc
+ 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
+ src/core/lib/compression/stream_compression_identity.cc
+ src/core/lib/debug/stats.cc
+ src/core/lib/debug/stats_data.cc
+ src/core/lib/http/format_request.cc
+ src/core/lib/http/httpcli.cc
+ src/core/lib/http/parser.cc
+ src/core/lib/iomgr/call_combiner.cc
+ src/core/lib/iomgr/combiner.cc
+ src/core/lib/iomgr/endpoint.cc
+ src/core/lib/iomgr/endpoint_pair_posix.cc
+ src/core/lib/iomgr/endpoint_pair_uv.cc
+ src/core/lib/iomgr/endpoint_pair_windows.cc
+ src/core/lib/iomgr/error.cc
+ src/core/lib/iomgr/ev_epoll1_linux.cc
+ src/core/lib/iomgr/ev_epollex_linux.cc
+ src/core/lib/iomgr/ev_epollsig_linux.cc
+ src/core/lib/iomgr/ev_poll_posix.cc
+ src/core/lib/iomgr/ev_posix.cc
+ src/core/lib/iomgr/ev_windows.cc
+ src/core/lib/iomgr/exec_ctx.cc
+ src/core/lib/iomgr/executor.cc
+ src/core/lib/iomgr/fork_posix.cc
+ src/core/lib/iomgr/fork_windows.cc
+ src/core/lib/iomgr/gethostname_fallback.cc
+ src/core/lib/iomgr/gethostname_host_name_max.cc
+ src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/iocp_windows.cc
+ src/core/lib/iomgr/iomgr.cc
+ src/core/lib/iomgr/iomgr_posix.cc
+ src/core/lib/iomgr/iomgr_uv.cc
+ src/core/lib/iomgr/iomgr_windows.cc
+ src/core/lib/iomgr/is_epollexclusive_available.cc
+ src/core/lib/iomgr/load_file.cc
+ src/core/lib/iomgr/lockfree_event.cc
+ src/core/lib/iomgr/network_status_tracker.cc
+ src/core/lib/iomgr/polling_entity.cc
+ src/core/lib/iomgr/pollset_set_uv.cc
+ src/core/lib/iomgr/pollset_set_windows.cc
+ src/core/lib/iomgr/pollset_uv.cc
+ src/core/lib/iomgr/pollset_windows.cc
+ src/core/lib/iomgr/resolve_address_posix.cc
+ src/core/lib/iomgr/resolve_address_uv.cc
+ src/core/lib/iomgr/resolve_address_windows.cc
+ src/core/lib/iomgr/resource_quota.cc
+ src/core/lib/iomgr/sockaddr_utils.cc
+ src/core/lib/iomgr/socket_factory_posix.cc
+ src/core/lib/iomgr/socket_mutator.cc
+ src/core/lib/iomgr/socket_utils_common_posix.cc
+ src/core/lib/iomgr/socket_utils_linux.cc
+ src/core/lib/iomgr/socket_utils_posix.cc
+ src/core/lib/iomgr/socket_utils_uv.cc
+ src/core/lib/iomgr/socket_utils_windows.cc
+ src/core/lib/iomgr/socket_windows.cc
+ src/core/lib/iomgr/tcp_client_posix.cc
+ src/core/lib/iomgr/tcp_client_uv.cc
+ src/core/lib/iomgr/tcp_client_windows.cc
+ src/core/lib/iomgr/tcp_posix.cc
+ src/core/lib/iomgr/tcp_server_posix.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ src/core/lib/iomgr/tcp_server_uv.cc
+ src/core/lib/iomgr/tcp_server_windows.cc
+ src/core/lib/iomgr/tcp_uv.cc
+ src/core/lib/iomgr/tcp_windows.cc
+ src/core/lib/iomgr/time_averaged_stats.cc
+ src/core/lib/iomgr/timer_generic.cc
+ src/core/lib/iomgr/timer_heap.cc
+ src/core/lib/iomgr/timer_manager.cc
+ src/core/lib/iomgr/timer_uv.cc
+ src/core/lib/iomgr/udp_server.cc
+ src/core/lib/iomgr/unix_sockets_posix.cc
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ src/core/lib/iomgr/wakeup_fd_cv.cc
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ src/core/lib/iomgr/wakeup_fd_pipe.cc
+ src/core/lib/iomgr/wakeup_fd_posix.cc
+ src/core/lib/json/json.cc
+ src/core/lib/json/json_reader.cc
+ src/core/lib/json/json_string.cc
+ src/core/lib/json/json_writer.cc
+ src/core/lib/slice/b64.cc
+ src/core/lib/slice/percent_encoding.cc
+ src/core/lib/slice/slice.cc
+ src/core/lib/slice/slice_buffer.cc
+ 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
+ src/core/lib/surface/call.cc
+ src/core/lib/surface/call_details.cc
+ src/core/lib/surface/call_log_batch.cc
+ src/core/lib/surface/channel.cc
+ src/core/lib/surface/channel_init.cc
+ src/core/lib/surface/channel_ping.cc
+ src/core/lib/surface/channel_stack_type.cc
+ src/core/lib/surface/completion_queue.cc
+ src/core/lib/surface/completion_queue_factory.cc
+ src/core/lib/surface/event_string.cc
src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c
- src/core/lib/surface/version.c
- src/core/lib/transport/bdp_estimator.c
- src/core/lib/transport/byte_stream.c
- src/core/lib/transport/connectivity_state.c
- src/core/lib/transport/error_utils.c
- src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/service_config.c
- src/core/lib/transport/static_metadata.c
- src/core/lib/transport/status_conversion.c
- src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c
- src/core/lib/transport/transport_op_string.c
- src/core/lib/debug/trace.c
- src/core/ext/filters/client_channel/channel_connectivity.c
- src/core/ext/filters/client_channel/client_channel.c
- src/core/ext/filters/client_channel/client_channel_factory.c
- src/core/ext/filters/client_channel/client_channel_plugin.c
- src/core/ext/filters/client_channel/connector.c
- src/core/ext/filters/client_channel/http_connect_handshaker.c
- src/core/ext/filters/client_channel/http_proxy.c
- src/core/ext/filters/client_channel/lb_policy.c
- src/core/ext/filters/client_channel/lb_policy_factory.c
- src/core/ext/filters/client_channel/lb_policy_registry.c
- src/core/ext/filters/client_channel/parse_address.c
- src/core/ext/filters/client_channel/proxy_mapper.c
- src/core/ext/filters/client_channel/proxy_mapper_registry.c
- src/core/ext/filters/client_channel/resolver.c
- src/core/ext/filters/client_channel/resolver_factory.c
- src/core/ext/filters/client_channel/resolver_registry.c
- src/core/ext/filters/client_channel/retry_throttle.c
- src/core/ext/filters/client_channel/subchannel.c
- src/core/ext/filters/client_channel/subchannel_index.c
- src/core/ext/filters/client_channel/uri_parser.c
- src/core/ext/filters/deadline/deadline_filter.c
- src/core/ext/transport/chttp2/transport/bin_decoder.c
- src/core/ext/transport/chttp2/transport/bin_encoder.c
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- src/core/ext/transport/chttp2/transport/chttp2_transport.c
- src/core/ext/transport/chttp2/transport/flow_control.c
- src/core/ext/transport/chttp2/transport/frame_data.c
- src/core/ext/transport/chttp2/transport/frame_goaway.c
- src/core/ext/transport/chttp2/transport/frame_ping.c
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- src/core/ext/transport/chttp2/transport/frame_settings.c
- src/core/ext/transport/chttp2/transport/frame_window_update.c
- src/core/ext/transport/chttp2/transport/hpack_encoder.c
- src/core/ext/transport/chttp2/transport/hpack_parser.c
- src/core/ext/transport/chttp2/transport/hpack_table.c
- src/core/ext/transport/chttp2/transport/http2_settings.c
- src/core/ext/transport/chttp2/transport/huffsyms.c
- src/core/ext/transport/chttp2/transport/incoming_metadata.c
- src/core/ext/transport/chttp2/transport/parsing.c
- src/core/ext/transport/chttp2/transport/stream_lists.c
- src/core/ext/transport/chttp2/transport/stream_map.c
- src/core/ext/transport/chttp2/transport/varint.c
- src/core/ext/transport/chttp2/transport/writing.c
- src/core/ext/transport/chttp2/alpn/alpn.c
- src/core/ext/filters/http/client/http_client_filter.c
- src/core/ext/filters/http/http_filters_plugin.c
- src/core/ext/filters/http/message_compress/message_compress_filter.c
- src/core/ext/filters/http/server/http_server_filter.c
+ src/core/lib/surface/metadata_array.cc
+ src/core/lib/surface/server.cc
+ src/core/lib/surface/validate_metadata.cc
+ src/core/lib/surface/version.cc
+ src/core/lib/transport/bdp_estimator.cc
+ src/core/lib/transport/byte_stream.cc
+ src/core/lib/transport/connectivity_state.cc
+ src/core/lib/transport/error_utils.cc
+ src/core/lib/transport/metadata.cc
+ src/core/lib/transport/metadata_batch.cc
+ src/core/lib/transport/pid_controller.cc
+ src/core/lib/transport/service_config.cc
+ src/core/lib/transport/static_metadata.cc
+ src/core/lib/transport/status_conversion.cc
+ src/core/lib/transport/timeout_encoding.cc
+ src/core/lib/transport/transport.cc
+ src/core/lib/transport/transport_op_string.cc
+ src/core/lib/debug/trace.cc
+ src/core/ext/filters/client_channel/backup_poller.cc
+ src/core/ext/filters/client_channel/channel_connectivity.cc
+ src/core/ext/filters/client_channel/client_channel.cc
+ src/core/ext/filters/client_channel/client_channel_factory.cc
+ src/core/ext/filters/client_channel/client_channel_plugin.cc
+ src/core/ext/filters/client_channel/connector.cc
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ src/core/ext/filters/client_channel/http_proxy.cc
+ src/core/ext/filters/client_channel/lb_policy.cc
+ src/core/ext/filters/client_channel/lb_policy_factory.cc
+ src/core/ext/filters/client_channel/lb_policy_registry.cc
+ src/core/ext/filters/client_channel/parse_address.cc
+ 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
+ src/core/ext/filters/client_channel/subchannel_index.cc
+ src/core/ext/filters/client_channel/uri_parser.cc
+ src/core/ext/filters/deadline/deadline_filter.cc
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ src/core/ext/transport/chttp2/transport/flow_control.cc
+ src/core/ext/transport/chttp2/transport/frame_data.cc
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ src/core/ext/transport/chttp2/transport/frame_ping.cc
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ src/core/ext/transport/chttp2/transport/frame_settings.cc
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ src/core/ext/transport/chttp2/transport/hpack_table.cc
+ src/core/ext/transport/chttp2/transport/http2_settings.cc
+ src/core/ext/transport/chttp2/transport/huffsyms.cc
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ src/core/ext/transport/chttp2/transport/parsing.cc
+ src/core/ext/transport/chttp2/transport/stream_lists.cc
+ 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/ext/transport/chttp2/alpn/alpn.cc
+ src/core/ext/filters/http/client/http_client_filter.cc
+ src/core/ext/filters/http/http_filters_plugin.cc
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ src/core/ext/filters/http/server/http_server_filter.cc
)
if(WIN32 AND MSVC)
@@ -2085,14 +1932,12 @@ endif()
target_include_directories(grpc_test_util_unsecure
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_test_util_unsecure
@@ -2107,7 +1952,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -2116,6 +1960,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -2135,236 +1980,228 @@ endforeach()
endif (gRPC_BUILD_TESTS)
add_library(grpc_unsecure
- src/core/lib/surface/init.c
- src/core/lib/surface/init_unsecure.c
- src/core/lib/channel/channel_args.c
- src/core/lib/channel/channel_stack.c
- src/core/lib/channel/channel_stack_builder.c
- src/core/lib/channel/connected_channel.c
- src/core/lib/channel/handshaker.c
- src/core/lib/channel/handshaker_factory.c
- src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/compression/stream_compression_gzip.c
- src/core/lib/compression/stream_compression_identity.c
- src/core/lib/debug/stats.c
- src/core/lib/debug/stats_data.c
- src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c
- src/core/lib/iomgr/call_combiner.c
- src/core/lib/iomgr/closure.c
- src/core/lib/iomgr/combiner.c
- src/core/lib/iomgr/endpoint.c
- src/core/lib/iomgr/endpoint_pair_posix.c
- src/core/lib/iomgr/endpoint_pair_uv.c
- src/core/lib/iomgr/endpoint_pair_windows.c
- src/core/lib/iomgr/error.c
- src/core/lib/iomgr/ev_epoll1_linux.c
- src/core/lib/iomgr/ev_epollex_linux.c
- src/core/lib/iomgr/ev_epollsig_linux.c
- src/core/lib/iomgr/ev_poll_posix.c
- src/core/lib/iomgr/ev_posix.c
- src/core/lib/iomgr/ev_windows.c
- src/core/lib/iomgr/exec_ctx.c
- src/core/lib/iomgr/executor.c
- src/core/lib/iomgr/gethostname_fallback.c
- src/core/lib/iomgr/gethostname_host_name_max.c
- src/core/lib/iomgr/gethostname_sysconf.c
- src/core/lib/iomgr/iocp_windows.c
- src/core/lib/iomgr/iomgr.c
- src/core/lib/iomgr/iomgr_posix.c
- src/core/lib/iomgr/iomgr_uv.c
- src/core/lib/iomgr/iomgr_windows.c
- src/core/lib/iomgr/is_epollexclusive_available.c
- src/core/lib/iomgr/load_file.c
- src/core/lib/iomgr/lockfree_event.c
- src/core/lib/iomgr/network_status_tracker.c
- src/core/lib/iomgr/polling_entity.c
- src/core/lib/iomgr/pollset_set_uv.c
- src/core/lib/iomgr/pollset_set_windows.c
- src/core/lib/iomgr/pollset_uv.c
- src/core/lib/iomgr/pollset_windows.c
- src/core/lib/iomgr/resolve_address_posix.c
- src/core/lib/iomgr/resolve_address_uv.c
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
- src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_uv.c
- src/core/lib/iomgr/socket_utils_windows.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_uv.c
- src/core/lib/iomgr/tcp_client_windows.c
- src/core/lib/iomgr/tcp_posix.c
- src/core/lib/iomgr/tcp_server_posix.c
- src/core/lib/iomgr/tcp_server_utils_posix_common.c
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- src/core/lib/iomgr/tcp_server_uv.c
- src/core/lib/iomgr/tcp_server_windows.c
- src/core/lib/iomgr/tcp_uv.c
- src/core/lib/iomgr/tcp_windows.c
- src/core/lib/iomgr/time_averaged_stats.c
- src/core/lib/iomgr/timer_generic.c
- src/core/lib/iomgr/timer_heap.c
- src/core/lib/iomgr/timer_manager.c
- src/core/lib/iomgr/timer_uv.c
- src/core/lib/iomgr/udp_server.c
- src/core/lib/iomgr/unix_sockets_posix.c
- src/core/lib/iomgr/unix_sockets_posix_noop.c
- src/core/lib/iomgr/wakeup_fd_cv.c
- src/core/lib/iomgr/wakeup_fd_eventfd.c
- src/core/lib/iomgr/wakeup_fd_nospecial.c
- src/core/lib/iomgr/wakeup_fd_pipe.c
- src/core/lib/iomgr/wakeup_fd_posix.c
- src/core/lib/json/json.c
- src/core/lib/json/json_reader.c
- src/core/lib/json/json_string.c
- src/core/lib/json/json_writer.c
- src/core/lib/slice/b64.c
- src/core/lib/slice/percent_encoding.c
- src/core/lib/slice/slice.c
- src/core/lib/slice/slice_buffer.c
- src/core/lib/slice/slice_hash_table.c
- src/core/lib/slice/slice_intern.c
- src/core/lib/slice/slice_string_helpers.c
- src/core/lib/surface/alarm.c
- src/core/lib/surface/api_trace.c
- src/core/lib/surface/byte_buffer.c
- src/core/lib/surface/byte_buffer_reader.c
- src/core/lib/surface/call.c
- src/core/lib/surface/call_details.c
- src/core/lib/surface/call_log_batch.c
- src/core/lib/surface/channel.c
- src/core/lib/surface/channel_init.c
- src/core/lib/surface/channel_ping.c
- src/core/lib/surface/channel_stack_type.c
- src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c
+ src/core/lib/surface/init.cc
+ src/core/lib/surface/init_unsecure.cc
+ src/core/lib/backoff/backoff.cc
+ src/core/lib/channel/channel_args.cc
+ src/core/lib/channel/channel_stack.cc
+ src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/connected_channel.cc
+ src/core/lib/channel/handshaker.cc
+ src/core/lib/channel/handshaker_factory.cc
+ 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
+ src/core/lib/compression/stream_compression_identity.cc
+ src/core/lib/debug/stats.cc
+ src/core/lib/debug/stats_data.cc
+ src/core/lib/http/format_request.cc
+ src/core/lib/http/httpcli.cc
+ src/core/lib/http/parser.cc
+ src/core/lib/iomgr/call_combiner.cc
+ src/core/lib/iomgr/combiner.cc
+ src/core/lib/iomgr/endpoint.cc
+ src/core/lib/iomgr/endpoint_pair_posix.cc
+ src/core/lib/iomgr/endpoint_pair_uv.cc
+ src/core/lib/iomgr/endpoint_pair_windows.cc
+ src/core/lib/iomgr/error.cc
+ src/core/lib/iomgr/ev_epoll1_linux.cc
+ src/core/lib/iomgr/ev_epollex_linux.cc
+ src/core/lib/iomgr/ev_epollsig_linux.cc
+ src/core/lib/iomgr/ev_poll_posix.cc
+ src/core/lib/iomgr/ev_posix.cc
+ src/core/lib/iomgr/ev_windows.cc
+ src/core/lib/iomgr/exec_ctx.cc
+ src/core/lib/iomgr/executor.cc
+ src/core/lib/iomgr/fork_posix.cc
+ src/core/lib/iomgr/fork_windows.cc
+ src/core/lib/iomgr/gethostname_fallback.cc
+ src/core/lib/iomgr/gethostname_host_name_max.cc
+ src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/iocp_windows.cc
+ src/core/lib/iomgr/iomgr.cc
+ src/core/lib/iomgr/iomgr_posix.cc
+ src/core/lib/iomgr/iomgr_uv.cc
+ src/core/lib/iomgr/iomgr_windows.cc
+ src/core/lib/iomgr/is_epollexclusive_available.cc
+ src/core/lib/iomgr/load_file.cc
+ src/core/lib/iomgr/lockfree_event.cc
+ src/core/lib/iomgr/network_status_tracker.cc
+ src/core/lib/iomgr/polling_entity.cc
+ src/core/lib/iomgr/pollset_set_uv.cc
+ src/core/lib/iomgr/pollset_set_windows.cc
+ src/core/lib/iomgr/pollset_uv.cc
+ src/core/lib/iomgr/pollset_windows.cc
+ src/core/lib/iomgr/resolve_address_posix.cc
+ src/core/lib/iomgr/resolve_address_uv.cc
+ src/core/lib/iomgr/resolve_address_windows.cc
+ src/core/lib/iomgr/resource_quota.cc
+ src/core/lib/iomgr/sockaddr_utils.cc
+ src/core/lib/iomgr/socket_factory_posix.cc
+ src/core/lib/iomgr/socket_mutator.cc
+ src/core/lib/iomgr/socket_utils_common_posix.cc
+ src/core/lib/iomgr/socket_utils_linux.cc
+ src/core/lib/iomgr/socket_utils_posix.cc
+ src/core/lib/iomgr/socket_utils_uv.cc
+ src/core/lib/iomgr/socket_utils_windows.cc
+ src/core/lib/iomgr/socket_windows.cc
+ src/core/lib/iomgr/tcp_client_posix.cc
+ src/core/lib/iomgr/tcp_client_uv.cc
+ src/core/lib/iomgr/tcp_client_windows.cc
+ src/core/lib/iomgr/tcp_posix.cc
+ src/core/lib/iomgr/tcp_server_posix.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ src/core/lib/iomgr/tcp_server_uv.cc
+ src/core/lib/iomgr/tcp_server_windows.cc
+ src/core/lib/iomgr/tcp_uv.cc
+ src/core/lib/iomgr/tcp_windows.cc
+ src/core/lib/iomgr/time_averaged_stats.cc
+ src/core/lib/iomgr/timer_generic.cc
+ src/core/lib/iomgr/timer_heap.cc
+ src/core/lib/iomgr/timer_manager.cc
+ src/core/lib/iomgr/timer_uv.cc
+ src/core/lib/iomgr/udp_server.cc
+ src/core/lib/iomgr/unix_sockets_posix.cc
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ src/core/lib/iomgr/wakeup_fd_cv.cc
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ src/core/lib/iomgr/wakeup_fd_pipe.cc
+ src/core/lib/iomgr/wakeup_fd_posix.cc
+ src/core/lib/json/json.cc
+ src/core/lib/json/json_reader.cc
+ src/core/lib/json/json_string.cc
+ src/core/lib/json/json_writer.cc
+ src/core/lib/slice/b64.cc
+ src/core/lib/slice/percent_encoding.cc
+ src/core/lib/slice/slice.cc
+ src/core/lib/slice/slice_buffer.cc
+ 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
+ src/core/lib/surface/call.cc
+ src/core/lib/surface/call_details.cc
+ src/core/lib/surface/call_log_batch.cc
+ src/core/lib/surface/channel.cc
+ src/core/lib/surface/channel_init.cc
+ src/core/lib/surface/channel_ping.cc
+ src/core/lib/surface/channel_stack_type.cc
+ src/core/lib/surface/completion_queue.cc
+ src/core/lib/surface/completion_queue_factory.cc
+ src/core/lib/surface/event_string.cc
src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c
- src/core/lib/surface/version.c
- src/core/lib/transport/bdp_estimator.c
- src/core/lib/transport/byte_stream.c
- src/core/lib/transport/connectivity_state.c
- src/core/lib/transport/error_utils.c
- src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/service_config.c
- src/core/lib/transport/static_metadata.c
- src/core/lib/transport/status_conversion.c
- src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c
- src/core/lib/transport/transport_op_string.c
- src/core/lib/debug/trace.c
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
- src/core/ext/transport/chttp2/transport/bin_decoder.c
- src/core/ext/transport/chttp2/transport/bin_encoder.c
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- src/core/ext/transport/chttp2/transport/chttp2_transport.c
- src/core/ext/transport/chttp2/transport/flow_control.c
- src/core/ext/transport/chttp2/transport/frame_data.c
- src/core/ext/transport/chttp2/transport/frame_goaway.c
- src/core/ext/transport/chttp2/transport/frame_ping.c
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- src/core/ext/transport/chttp2/transport/frame_settings.c
- src/core/ext/transport/chttp2/transport/frame_window_update.c
- src/core/ext/transport/chttp2/transport/hpack_encoder.c
- src/core/ext/transport/chttp2/transport/hpack_parser.c
- src/core/ext/transport/chttp2/transport/hpack_table.c
- src/core/ext/transport/chttp2/transport/http2_settings.c
- src/core/ext/transport/chttp2/transport/huffsyms.c
- src/core/ext/transport/chttp2/transport/incoming_metadata.c
- src/core/ext/transport/chttp2/transport/parsing.c
- src/core/ext/transport/chttp2/transport/stream_lists.c
- src/core/ext/transport/chttp2/transport/stream_map.c
- src/core/ext/transport/chttp2/transport/varint.c
- src/core/ext/transport/chttp2/transport/writing.c
- src/core/ext/transport/chttp2/alpn/alpn.c
- src/core/ext/filters/http/client/http_client_filter.c
- src/core/ext/filters/http/http_filters_plugin.c
- src/core/ext/filters/http/message_compress/message_compress_filter.c
- src/core/ext/filters/http/server/http_server_filter.c
- src/core/ext/transport/chttp2/server/chttp2_server.c
- src/core/ext/transport/chttp2/client/insecure/channel_create.c
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
- src/core/ext/transport/chttp2/client/chttp2_connector.c
- src/core/ext/filters/client_channel/channel_connectivity.c
- src/core/ext/filters/client_channel/client_channel.c
- src/core/ext/filters/client_channel/client_channel_factory.c
- src/core/ext/filters/client_channel/client_channel_plugin.c
- src/core/ext/filters/client_channel/connector.c
- src/core/ext/filters/client_channel/http_connect_handshaker.c
- src/core/ext/filters/client_channel/http_proxy.c
- src/core/ext/filters/client_channel/lb_policy.c
- src/core/ext/filters/client_channel/lb_policy_factory.c
- src/core/ext/filters/client_channel/lb_policy_registry.c
- src/core/ext/filters/client_channel/parse_address.c
- src/core/ext/filters/client_channel/proxy_mapper.c
- src/core/ext/filters/client_channel/proxy_mapper_registry.c
- src/core/ext/filters/client_channel/resolver.c
- src/core/ext/filters/client_channel/resolver_factory.c
- src/core/ext/filters/client_channel/resolver_registry.c
- src/core/ext/filters/client_channel/retry_throttle.c
- src/core/ext/filters/client_channel/subchannel.c
- src/core/ext/filters/client_channel/subchannel_index.c
- src/core/ext/filters/client_channel/uri_parser.c
- src/core/ext/filters/deadline/deadline_filter.c
- src/core/ext/transport/inproc/inproc_plugin.c
- src/core/ext/transport/inproc/inproc_transport.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c
- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c
- src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
+ src/core/lib/surface/metadata_array.cc
+ src/core/lib/surface/server.cc
+ src/core/lib/surface/validate_metadata.cc
+ src/core/lib/surface/version.cc
+ src/core/lib/transport/bdp_estimator.cc
+ src/core/lib/transport/byte_stream.cc
+ src/core/lib/transport/connectivity_state.cc
+ src/core/lib/transport/error_utils.cc
+ src/core/lib/transport/metadata.cc
+ src/core/lib/transport/metadata_batch.cc
+ src/core/lib/transport/pid_controller.cc
+ src/core/lib/transport/service_config.cc
+ src/core/lib/transport/static_metadata.cc
+ src/core/lib/transport/status_conversion.cc
+ src/core/lib/transport/timeout_encoding.cc
+ src/core/lib/transport/transport.cc
+ src/core/lib/transport/transport_op_string.cc
+ src/core/lib/debug/trace.cc
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ src/core/ext/transport/chttp2/transport/flow_control.cc
+ src/core/ext/transport/chttp2/transport/frame_data.cc
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ src/core/ext/transport/chttp2/transport/frame_ping.cc
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ src/core/ext/transport/chttp2/transport/frame_settings.cc
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ src/core/ext/transport/chttp2/transport/hpack_table.cc
+ src/core/ext/transport/chttp2/transport/http2_settings.cc
+ src/core/ext/transport/chttp2/transport/huffsyms.cc
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ src/core/ext/transport/chttp2/transport/parsing.cc
+ src/core/ext/transport/chttp2/transport/stream_lists.cc
+ 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/ext/transport/chttp2/alpn/alpn.cc
+ src/core/ext/filters/http/client/http_client_filter.cc
+ src/core/ext/filters/http/http_filters_plugin.cc
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ src/core/ext/filters/http/server/http_server_filter.cc
+ src/core/ext/transport/chttp2/server/chttp2_server.cc
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc
+ src/core/ext/filters/client_channel/backup_poller.cc
+ src/core/ext/filters/client_channel/channel_connectivity.cc
+ src/core/ext/filters/client_channel/client_channel.cc
+ src/core/ext/filters/client_channel/client_channel_factory.cc
+ src/core/ext/filters/client_channel/client_channel_plugin.cc
+ src/core/ext/filters/client_channel/connector.cc
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ src/core/ext/filters/client_channel/http_proxy.cc
+ src/core/ext/filters/client_channel/lb_policy.cc
+ src/core/ext/filters/client_channel/lb_policy_factory.cc
+ src/core/ext/filters/client_channel/lb_policy_registry.cc
+ src/core/ext/filters/client_channel/parse_address.cc
+ 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
+ src/core/ext/filters/client_channel/subchannel_index.cc
+ src/core/ext/filters/client_channel/uri_parser.cc
+ src/core/ext/filters/deadline/deadline_filter.cc
+ src/core/ext/transport/inproc/inproc_plugin.cc
+ src/core/ext/transport/inproc/inproc_transport.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
+ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
+ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
+ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
third_party/nanopb/pb_common.c
third_party/nanopb/pb_decode.c
third_party/nanopb/pb_encode.c
- src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
- src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
- src/core/ext/census/base_resources.c
- src/core/ext/census/context.c
- src/core/ext/census/gen/census.pb.c
- src/core/ext/census/gen/trace_context.pb.c
- src/core/ext/census/grpc_context.c
- src/core/ext/census/grpc_filter.c
- src/core/ext/census/grpc_plugin.c
- src/core/ext/census/initialize.c
- src/core/ext/census/intrusive_hash_map.c
- src/core/ext/census/mlog.c
- src/core/ext/census/operation.c
- src/core/ext/census/placeholders.c
- src/core/ext/census/resource.c
- src/core/ext/census/trace_context.c
- src/core/ext/census/tracing.c
- src/core/ext/filters/max_age/max_age_filter.c
- src/core/ext/filters/message_size/message_size_filter.c
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c
- src/core/ext/filters/workarounds/workaround_utils.c
- src/core/plugin_registry/grpc_unsecure_plugin_registry.c
+ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
+ src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
+ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
+ src/core/ext/census/grpc_context.cc
+ src/core/ext/filters/max_age/max_age_filter.cc
+ src/core/ext/filters/message_size/message_size_filter.cc
+ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
+ src/core/ext/filters/workarounds/workaround_utils.cc
+ src/core/plugin_registry/grpc_unsecure_plugin_registry.cc
)
if(WIN32 AND MSVC)
@@ -2382,14 +2219,12 @@ endif()
target_include_directories(grpc_unsecure
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_unsecure
@@ -2405,7 +2240,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -2414,6 +2248,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -2425,6 +2260,8 @@ foreach(_hdr
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
include/grpc/grpc_security_constants.h
@@ -2454,7 +2291,7 @@ endif()
if (gRPC_BUILD_TESTS)
add_library(reconnect_server
- test/core/util/reconnect_server.c
+ test/core/util/reconnect_server.cc
)
if(WIN32 AND MSVC)
@@ -2472,14 +2309,12 @@ endif()
target_include_directories(reconnect_server
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(reconnect_server
@@ -2496,7 +2331,7 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_library(test_tcp_server
- test/core/util/test_tcp_server.c
+ test/core/util/test_tcp_server.cc
)
if(WIN32 AND MSVC)
@@ -2514,14 +2349,12 @@ endif()
target_include_directories(test_tcp_server
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(test_tcp_server
@@ -2595,14 +2428,12 @@ endif()
target_include_directories(grpc++
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -2669,7 +2500,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -2692,6 +2522,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -2703,6 +2534,8 @@ foreach(_hdr
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
include/grpc/grpc_security_constants.h
@@ -2715,7 +2548,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -2797,14 +2629,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc++_core_stats
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -2869,207 +2699,198 @@ add_library(grpc++_cronet
src/cpp/util/string_ref.cc
src/cpp/util/time_cc.cc
src/cpp/codegen/codegen_init.cc
- src/core/ext/transport/chttp2/client/insecure/channel_create.c
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
- src/core/ext/transport/chttp2/client/chttp2_connector.c
- src/core/ext/transport/chttp2/transport/bin_decoder.c
- src/core/ext/transport/chttp2/transport/bin_encoder.c
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- src/core/ext/transport/chttp2/transport/chttp2_transport.c
- src/core/ext/transport/chttp2/transport/flow_control.c
- src/core/ext/transport/chttp2/transport/frame_data.c
- src/core/ext/transport/chttp2/transport/frame_goaway.c
- src/core/ext/transport/chttp2/transport/frame_ping.c
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- src/core/ext/transport/chttp2/transport/frame_settings.c
- src/core/ext/transport/chttp2/transport/frame_window_update.c
- src/core/ext/transport/chttp2/transport/hpack_encoder.c
- src/core/ext/transport/chttp2/transport/hpack_parser.c
- src/core/ext/transport/chttp2/transport/hpack_table.c
- src/core/ext/transport/chttp2/transport/http2_settings.c
- src/core/ext/transport/chttp2/transport/huffsyms.c
- src/core/ext/transport/chttp2/transport/incoming_metadata.c
- src/core/ext/transport/chttp2/transport/parsing.c
- src/core/ext/transport/chttp2/transport/stream_lists.c
- src/core/ext/transport/chttp2/transport/stream_map.c
- src/core/ext/transport/chttp2/transport/varint.c
- src/core/ext/transport/chttp2/transport/writing.c
- src/core/lib/channel/channel_args.c
- src/core/lib/channel/channel_stack.c
- src/core/lib/channel/channel_stack_builder.c
- src/core/lib/channel/connected_channel.c
- src/core/lib/channel/handshaker.c
- src/core/lib/channel/handshaker_factory.c
- src/core/lib/channel/handshaker_registry.c
- src/core/lib/compression/compression.c
- src/core/lib/compression/message_compress.c
- src/core/lib/compression/stream_compression.c
- src/core/lib/compression/stream_compression_gzip.c
- src/core/lib/compression/stream_compression_identity.c
- src/core/lib/debug/stats.c
- src/core/lib/debug/stats_data.c
- src/core/lib/http/format_request.c
- src/core/lib/http/httpcli.c
- src/core/lib/http/parser.c
- src/core/lib/iomgr/call_combiner.c
- src/core/lib/iomgr/closure.c
- src/core/lib/iomgr/combiner.c
- src/core/lib/iomgr/endpoint.c
- src/core/lib/iomgr/endpoint_pair_posix.c
- src/core/lib/iomgr/endpoint_pair_uv.c
- src/core/lib/iomgr/endpoint_pair_windows.c
- src/core/lib/iomgr/error.c
- src/core/lib/iomgr/ev_epoll1_linux.c
- src/core/lib/iomgr/ev_epollex_linux.c
- src/core/lib/iomgr/ev_epollsig_linux.c
- src/core/lib/iomgr/ev_poll_posix.c
- src/core/lib/iomgr/ev_posix.c
- src/core/lib/iomgr/ev_windows.c
- src/core/lib/iomgr/exec_ctx.c
- src/core/lib/iomgr/executor.c
- src/core/lib/iomgr/gethostname_fallback.c
- src/core/lib/iomgr/gethostname_host_name_max.c
- src/core/lib/iomgr/gethostname_sysconf.c
- src/core/lib/iomgr/iocp_windows.c
- src/core/lib/iomgr/iomgr.c
- src/core/lib/iomgr/iomgr_posix.c
- src/core/lib/iomgr/iomgr_uv.c
- src/core/lib/iomgr/iomgr_windows.c
- src/core/lib/iomgr/is_epollexclusive_available.c
- src/core/lib/iomgr/load_file.c
- src/core/lib/iomgr/lockfree_event.c
- src/core/lib/iomgr/network_status_tracker.c
- src/core/lib/iomgr/polling_entity.c
- src/core/lib/iomgr/pollset_set_uv.c
- src/core/lib/iomgr/pollset_set_windows.c
- src/core/lib/iomgr/pollset_uv.c
- src/core/lib/iomgr/pollset_windows.c
- src/core/lib/iomgr/resolve_address_posix.c
- src/core/lib/iomgr/resolve_address_uv.c
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
- src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_uv.c
- src/core/lib/iomgr/socket_utils_windows.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_uv.c
- src/core/lib/iomgr/tcp_client_windows.c
- src/core/lib/iomgr/tcp_posix.c
- src/core/lib/iomgr/tcp_server_posix.c
- src/core/lib/iomgr/tcp_server_utils_posix_common.c
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- src/core/lib/iomgr/tcp_server_uv.c
- src/core/lib/iomgr/tcp_server_windows.c
- src/core/lib/iomgr/tcp_uv.c
- src/core/lib/iomgr/tcp_windows.c
- src/core/lib/iomgr/time_averaged_stats.c
- src/core/lib/iomgr/timer_generic.c
- src/core/lib/iomgr/timer_heap.c
- src/core/lib/iomgr/timer_manager.c
- src/core/lib/iomgr/timer_uv.c
- src/core/lib/iomgr/udp_server.c
- src/core/lib/iomgr/unix_sockets_posix.c
- src/core/lib/iomgr/unix_sockets_posix_noop.c
- src/core/lib/iomgr/wakeup_fd_cv.c
- src/core/lib/iomgr/wakeup_fd_eventfd.c
- src/core/lib/iomgr/wakeup_fd_nospecial.c
- src/core/lib/iomgr/wakeup_fd_pipe.c
- src/core/lib/iomgr/wakeup_fd_posix.c
- src/core/lib/json/json.c
- src/core/lib/json/json_reader.c
- src/core/lib/json/json_string.c
- src/core/lib/json/json_writer.c
- src/core/lib/slice/b64.c
- src/core/lib/slice/percent_encoding.c
- src/core/lib/slice/slice.c
- src/core/lib/slice/slice_buffer.c
- src/core/lib/slice/slice_hash_table.c
- src/core/lib/slice/slice_intern.c
- src/core/lib/slice/slice_string_helpers.c
- src/core/lib/surface/alarm.c
- src/core/lib/surface/api_trace.c
- src/core/lib/surface/byte_buffer.c
- src/core/lib/surface/byte_buffer_reader.c
- src/core/lib/surface/call.c
- src/core/lib/surface/call_details.c
- src/core/lib/surface/call_log_batch.c
- src/core/lib/surface/channel.c
- src/core/lib/surface/channel_init.c
- src/core/lib/surface/channel_ping.c
- src/core/lib/surface/channel_stack_type.c
- src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ src/core/ext/transport/chttp2/transport/flow_control.cc
+ src/core/ext/transport/chttp2/transport/frame_data.cc
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ src/core/ext/transport/chttp2/transport/frame_ping.cc
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ src/core/ext/transport/chttp2/transport/frame_settings.cc
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ src/core/ext/transport/chttp2/transport/hpack_table.cc
+ src/core/ext/transport/chttp2/transport/http2_settings.cc
+ src/core/ext/transport/chttp2/transport/huffsyms.cc
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ src/core/ext/transport/chttp2/transport/parsing.cc
+ src/core/ext/transport/chttp2/transport/stream_lists.cc
+ 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/backoff/backoff.cc
+ src/core/lib/channel/channel_args.cc
+ src/core/lib/channel/channel_stack.cc
+ src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/connected_channel.cc
+ src/core/lib/channel/handshaker.cc
+ src/core/lib/channel/handshaker_factory.cc
+ 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
+ src/core/lib/compression/stream_compression_identity.cc
+ src/core/lib/debug/stats.cc
+ src/core/lib/debug/stats_data.cc
+ src/core/lib/http/format_request.cc
+ src/core/lib/http/httpcli.cc
+ src/core/lib/http/parser.cc
+ src/core/lib/iomgr/call_combiner.cc
+ src/core/lib/iomgr/combiner.cc
+ src/core/lib/iomgr/endpoint.cc
+ src/core/lib/iomgr/endpoint_pair_posix.cc
+ src/core/lib/iomgr/endpoint_pair_uv.cc
+ src/core/lib/iomgr/endpoint_pair_windows.cc
+ src/core/lib/iomgr/error.cc
+ src/core/lib/iomgr/ev_epoll1_linux.cc
+ src/core/lib/iomgr/ev_epollex_linux.cc
+ src/core/lib/iomgr/ev_epollsig_linux.cc
+ src/core/lib/iomgr/ev_poll_posix.cc
+ src/core/lib/iomgr/ev_posix.cc
+ src/core/lib/iomgr/ev_windows.cc
+ src/core/lib/iomgr/exec_ctx.cc
+ src/core/lib/iomgr/executor.cc
+ src/core/lib/iomgr/fork_posix.cc
+ src/core/lib/iomgr/fork_windows.cc
+ src/core/lib/iomgr/gethostname_fallback.cc
+ src/core/lib/iomgr/gethostname_host_name_max.cc
+ src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/iocp_windows.cc
+ src/core/lib/iomgr/iomgr.cc
+ src/core/lib/iomgr/iomgr_posix.cc
+ src/core/lib/iomgr/iomgr_uv.cc
+ src/core/lib/iomgr/iomgr_windows.cc
+ src/core/lib/iomgr/is_epollexclusive_available.cc
+ src/core/lib/iomgr/load_file.cc
+ src/core/lib/iomgr/lockfree_event.cc
+ src/core/lib/iomgr/network_status_tracker.cc
+ src/core/lib/iomgr/polling_entity.cc
+ src/core/lib/iomgr/pollset_set_uv.cc
+ src/core/lib/iomgr/pollset_set_windows.cc
+ src/core/lib/iomgr/pollset_uv.cc
+ src/core/lib/iomgr/pollset_windows.cc
+ src/core/lib/iomgr/resolve_address_posix.cc
+ src/core/lib/iomgr/resolve_address_uv.cc
+ src/core/lib/iomgr/resolve_address_windows.cc
+ src/core/lib/iomgr/resource_quota.cc
+ src/core/lib/iomgr/sockaddr_utils.cc
+ src/core/lib/iomgr/socket_factory_posix.cc
+ src/core/lib/iomgr/socket_mutator.cc
+ src/core/lib/iomgr/socket_utils_common_posix.cc
+ src/core/lib/iomgr/socket_utils_linux.cc
+ src/core/lib/iomgr/socket_utils_posix.cc
+ src/core/lib/iomgr/socket_utils_uv.cc
+ src/core/lib/iomgr/socket_utils_windows.cc
+ src/core/lib/iomgr/socket_windows.cc
+ src/core/lib/iomgr/tcp_client_posix.cc
+ src/core/lib/iomgr/tcp_client_uv.cc
+ src/core/lib/iomgr/tcp_client_windows.cc
+ src/core/lib/iomgr/tcp_posix.cc
+ src/core/lib/iomgr/tcp_server_posix.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ src/core/lib/iomgr/tcp_server_uv.cc
+ src/core/lib/iomgr/tcp_server_windows.cc
+ src/core/lib/iomgr/tcp_uv.cc
+ src/core/lib/iomgr/tcp_windows.cc
+ src/core/lib/iomgr/time_averaged_stats.cc
+ src/core/lib/iomgr/timer_generic.cc
+ src/core/lib/iomgr/timer_heap.cc
+ src/core/lib/iomgr/timer_manager.cc
+ src/core/lib/iomgr/timer_uv.cc
+ src/core/lib/iomgr/udp_server.cc
+ src/core/lib/iomgr/unix_sockets_posix.cc
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ src/core/lib/iomgr/wakeup_fd_cv.cc
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ src/core/lib/iomgr/wakeup_fd_pipe.cc
+ src/core/lib/iomgr/wakeup_fd_posix.cc
+ src/core/lib/json/json.cc
+ src/core/lib/json/json_reader.cc
+ src/core/lib/json/json_string.cc
+ src/core/lib/json/json_writer.cc
+ src/core/lib/slice/b64.cc
+ src/core/lib/slice/percent_encoding.cc
+ src/core/lib/slice/slice.cc
+ src/core/lib/slice/slice_buffer.cc
+ 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
+ src/core/lib/surface/call.cc
+ src/core/lib/surface/call_details.cc
+ src/core/lib/surface/call_log_batch.cc
+ src/core/lib/surface/channel.cc
+ src/core/lib/surface/channel_init.cc
+ src/core/lib/surface/channel_ping.cc
+ src/core/lib/surface/channel_stack_type.cc
+ src/core/lib/surface/completion_queue.cc
+ src/core/lib/surface/completion_queue_factory.cc
+ src/core/lib/surface/event_string.cc
src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c
- src/core/lib/surface/version.c
- src/core/lib/transport/bdp_estimator.c
- src/core/lib/transport/byte_stream.c
- src/core/lib/transport/connectivity_state.c
- src/core/lib/transport/error_utils.c
- src/core/lib/transport/metadata.c
- src/core/lib/transport/metadata_batch.c
- src/core/lib/transport/pid_controller.c
- src/core/lib/transport/service_config.c
- src/core/lib/transport/static_metadata.c
- src/core/lib/transport/status_conversion.c
- src/core/lib/transport/timeout_encoding.c
- src/core/lib/transport/transport.c
- src/core/lib/transport/transport_op_string.c
- src/core/lib/debug/trace.c
- src/core/ext/transport/chttp2/alpn/alpn.c
- src/core/ext/filters/http/client/http_client_filter.c
- src/core/ext/filters/http/http_filters_plugin.c
- src/core/ext/filters/http/message_compress/message_compress_filter.c
- src/core/ext/filters/http/server/http_server_filter.c
- src/core/ext/filters/client_channel/channel_connectivity.c
- src/core/ext/filters/client_channel/client_channel.c
- src/core/ext/filters/client_channel/client_channel_factory.c
- src/core/ext/filters/client_channel/client_channel_plugin.c
- src/core/ext/filters/client_channel/connector.c
- src/core/ext/filters/client_channel/http_connect_handshaker.c
- src/core/ext/filters/client_channel/http_proxy.c
- src/core/ext/filters/client_channel/lb_policy.c
- src/core/ext/filters/client_channel/lb_policy_factory.c
- src/core/ext/filters/client_channel/lb_policy_registry.c
- src/core/ext/filters/client_channel/parse_address.c
- src/core/ext/filters/client_channel/proxy_mapper.c
- src/core/ext/filters/client_channel/proxy_mapper_registry.c
- src/core/ext/filters/client_channel/resolver.c
- src/core/ext/filters/client_channel/resolver_factory.c
- src/core/ext/filters/client_channel/resolver_registry.c
- src/core/ext/filters/client_channel/retry_throttle.c
- src/core/ext/filters/client_channel/subchannel.c
- src/core/ext/filters/client_channel/subchannel_index.c
- src/core/ext/filters/client_channel/uri_parser.c
- src/core/ext/filters/deadline/deadline_filter.c
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
- src/core/ext/transport/chttp2/server/chttp2_server.c
- src/core/ext/census/base_resources.c
- src/core/ext/census/context.c
- src/core/ext/census/gen/census.pb.c
- src/core/ext/census/gen/trace_context.pb.c
- src/core/ext/census/grpc_context.c
- src/core/ext/census/grpc_filter.c
- src/core/ext/census/grpc_plugin.c
- src/core/ext/census/initialize.c
- src/core/ext/census/intrusive_hash_map.c
- src/core/ext/census/mlog.c
- src/core/ext/census/operation.c
- src/core/ext/census/placeholders.c
- src/core/ext/census/resource.c
- src/core/ext/census/trace_context.c
- src/core/ext/census/tracing.c
+ src/core/lib/surface/metadata_array.cc
+ src/core/lib/surface/server.cc
+ src/core/lib/surface/validate_metadata.cc
+ src/core/lib/surface/version.cc
+ src/core/lib/transport/bdp_estimator.cc
+ src/core/lib/transport/byte_stream.cc
+ src/core/lib/transport/connectivity_state.cc
+ src/core/lib/transport/error_utils.cc
+ src/core/lib/transport/metadata.cc
+ src/core/lib/transport/metadata_batch.cc
+ src/core/lib/transport/pid_controller.cc
+ src/core/lib/transport/service_config.cc
+ src/core/lib/transport/static_metadata.cc
+ src/core/lib/transport/status_conversion.cc
+ src/core/lib/transport/timeout_encoding.cc
+ src/core/lib/transport/transport.cc
+ src/core/lib/transport/transport_op_string.cc
+ src/core/lib/debug/trace.cc
+ src/core/ext/transport/chttp2/alpn/alpn.cc
+ src/core/ext/filters/http/client/http_client_filter.cc
+ src/core/ext/filters/http/http_filters_plugin.cc
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ src/core/ext/filters/http/server/http_server_filter.cc
+ src/core/ext/filters/client_channel/backup_poller.cc
+ src/core/ext/filters/client_channel/channel_connectivity.cc
+ src/core/ext/filters/client_channel/client_channel.cc
+ src/core/ext/filters/client_channel/client_channel_factory.cc
+ src/core/ext/filters/client_channel/client_channel_plugin.cc
+ src/core/ext/filters/client_channel/connector.cc
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ src/core/ext/filters/client_channel/http_proxy.cc
+ src/core/ext/filters/client_channel/lb_policy.cc
+ src/core/ext/filters/client_channel/lb_policy_factory.cc
+ src/core/ext/filters/client_channel/lb_policy_registry.cc
+ src/core/ext/filters/client_channel/parse_address.cc
+ 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
+ src/core/ext/filters/client_channel/subchannel_index.cc
+ src/core/ext/filters/client_channel/uri_parser.cc
+ src/core/ext/filters/deadline/deadline_filter.cc
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+ src/core/ext/transport/chttp2/server/chttp2_server.cc
+ src/core/ext/census/grpc_context.cc
third_party/nanopb/pb_common.c
third_party/nanopb/pb_decode.c
third_party/nanopb/pb_encode.c
@@ -3090,14 +2911,12 @@ endif()
target_include_directories(grpc++_cronet
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3165,7 +2984,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -3188,6 +3006,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -3199,6 +3018,8 @@ foreach(_hdr
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
include/grpc/grpc_security_constants.h
@@ -3211,7 +3032,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -3291,14 +3111,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc++_error_details
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3356,14 +3174,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc++_proto_reflection_desc_db
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3417,14 +3233,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc++_reflection
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3475,14 +3289,12 @@ endif()
target_include_directories(grpc++_test_config
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3553,14 +3365,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc++_test_util
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3611,7 +3421,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -3620,6 +3429,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -3693,14 +3503,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc++_test_util_unsecure
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3751,7 +3559,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -3760,6 +3567,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -3835,14 +3643,12 @@ endif()
target_include_directories(grpc++_unsecure
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3908,7 +3714,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -3931,6 +3736,7 @@ foreach(_hdr
include/grpc/impl/codegen/atm_gcc_atomic.h
include/grpc/impl/codegen/atm_gcc_sync.h
include/grpc/impl/codegen/atm_windows.h
+ include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/port_platform.h
@@ -3942,6 +3748,8 @@ foreach(_hdr
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
include/grpc/grpc_security_constants.h
@@ -3954,7 +3762,6 @@ foreach(_hdr
include/grpc/impl/codegen/byte_buffer_reader.h
include/grpc/impl/codegen/compression_types.h
include/grpc/impl/codegen/connectivity_state.h
- include/grpc/impl/codegen/exec_ctx_fwd.h
include/grpc/impl/codegen/grpc_types.h
include/grpc/impl/codegen/propagation_bits.h
include/grpc/impl/codegen/slice.h
@@ -4027,14 +3834,12 @@ endif()
target_include_directories(grpc_benchmark
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4045,7 +3850,7 @@ target_include_directories(grpc_benchmark
target_link_libraries(grpc_benchmark
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_unsecure
grpc_test_util_unsecure
grpc_unsecure
@@ -4086,14 +3891,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc_cli_libs
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4146,14 +3949,12 @@ endif()
target_include_directories(grpc_plugin_support
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -4224,14 +4025,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(http2_client_main
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4279,14 +4078,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(interop_client_helper
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4349,14 +4146,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(interop_client_main
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4400,14 +4195,12 @@ endif()
target_include_directories(interop_server_helper
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4469,14 +4262,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(interop_server_lib
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4520,14 +4311,12 @@ endif()
target_include_directories(interop_server_main
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4608,14 +4397,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(qps
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4655,14 +4442,12 @@ endif()
target_include_directories(grpc_csharp_ext
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_csharp_ext
@@ -4683,94 +4468,8 @@ endif()
if (gRPC_BUILD_TESTS)
-add_library(ares
- third_party/cares/cares/ares__close_sockets.c
- third_party/cares/cares/ares__get_hostent.c
- third_party/cares/cares/ares__read_line.c
- third_party/cares/cares/ares__timeval.c
- third_party/cares/cares/ares_cancel.c
- third_party/cares/cares/ares_create_query.c
- third_party/cares/cares/ares_data.c
- third_party/cares/cares/ares_destroy.c
- third_party/cares/cares/ares_expand_name.c
- third_party/cares/cares/ares_expand_string.c
- third_party/cares/cares/ares_fds.c
- third_party/cares/cares/ares_free_hostent.c
- third_party/cares/cares/ares_free_string.c
- third_party/cares/cares/ares_getenv.c
- third_party/cares/cares/ares_gethostbyaddr.c
- third_party/cares/cares/ares_gethostbyname.c
- third_party/cares/cares/ares_getnameinfo.c
- third_party/cares/cares/ares_getopt.c
- third_party/cares/cares/ares_getsock.c
- third_party/cares/cares/ares_init.c
- third_party/cares/cares/ares_library_init.c
- third_party/cares/cares/ares_llist.c
- third_party/cares/cares/ares_mkquery.c
- third_party/cares/cares/ares_nowarn.c
- third_party/cares/cares/ares_options.c
- third_party/cares/cares/ares_parse_a_reply.c
- third_party/cares/cares/ares_parse_aaaa_reply.c
- third_party/cares/cares/ares_parse_mx_reply.c
- third_party/cares/cares/ares_parse_naptr_reply.c
- third_party/cares/cares/ares_parse_ns_reply.c
- third_party/cares/cares/ares_parse_ptr_reply.c
- third_party/cares/cares/ares_parse_soa_reply.c
- third_party/cares/cares/ares_parse_srv_reply.c
- third_party/cares/cares/ares_parse_txt_reply.c
- third_party/cares/cares/ares_platform.c
- third_party/cares/cares/ares_process.c
- third_party/cares/cares/ares_query.c
- third_party/cares/cares/ares_search.c
- third_party/cares/cares/ares_send.c
- third_party/cares/cares/ares_strcasecmp.c
- third_party/cares/cares/ares_strdup.c
- third_party/cares/cares/ares_strerror.c
- third_party/cares/cares/ares_timeout.c
- third_party/cares/cares/ares_version.c
- third_party/cares/cares/ares_writev.c
- third_party/cares/cares/bitncmp.c
- third_party/cares/cares/inet_net_pton.c
- third_party/cares/cares/inet_ntop.c
- third_party/cares/cares/windows_port.c
-)
-
-if(WIN32 AND MSVC)
- set_target_properties(ares PROPERTIES COMPILE_PDB_NAME "ares"
- COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
- )
- if (gRPC_INSTALL)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ares.pdb
- DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL
- )
- endif()
-endif()
-
-
-target_include_directories(ares
- PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(ares
- ${_gRPC_SSL_LIBRARIES}
- ${_gRPC_ALLTARGETS_LIBRARIES}
-)
-
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_library(bad_client_test
- test/core/bad_client/bad_client.c
+ test/core/bad_client/bad_client.cc
)
if(WIN32 AND MSVC)
@@ -4788,14 +4487,12 @@ endif()
target_include_directories(bad_client_test
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bad_client_test
@@ -4811,7 +4508,7 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_library(bad_ssl_test_server
- test/core/bad_ssl/server_common.c
+ test/core/bad_ssl/server_common.cc
)
if(WIN32 AND MSVC)
@@ -4829,14 +4526,12 @@ endif()
target_include_directories(bad_ssl_test_server
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bad_ssl_test_server
@@ -4852,67 +4547,68 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_library(end2end_tests
- test/core/end2end/end2end_tests.c
- test/core/end2end/end2end_test_utils.c
- test/core/end2end/tests/authority_not_supported.c
- test/core/end2end/tests/bad_hostname.c
- test/core/end2end/tests/bad_ping.c
- test/core/end2end/tests/binary_metadata.c
- test/core/end2end/tests/call_creds.c
- test/core/end2end/tests/cancel_after_accept.c
- test/core/end2end/tests/cancel_after_client_done.c
- test/core/end2end/tests/cancel_after_invoke.c
- test/core/end2end/tests/cancel_after_round_trip.c
- test/core/end2end/tests/cancel_before_invoke.c
- test/core/end2end/tests/cancel_in_a_vacuum.c
- test/core/end2end/tests/cancel_with_status.c
- test/core/end2end/tests/compressed_payload.c
- test/core/end2end/tests/connectivity.c
- test/core/end2end/tests/default_host.c
- test/core/end2end/tests/disappearing_server.c
- test/core/end2end/tests/empty_batch.c
- test/core/end2end/tests/filter_call_init_fails.c
- test/core/end2end/tests/filter_causes_close.c
- test/core/end2end/tests/filter_latency.c
- test/core/end2end/tests/graceful_server_shutdown.c
- test/core/end2end/tests/high_initial_seqno.c
- test/core/end2end/tests/hpack_size.c
- test/core/end2end/tests/idempotent_request.c
- test/core/end2end/tests/invoke_large_request.c
- test/core/end2end/tests/keepalive_timeout.c
- test/core/end2end/tests/large_metadata.c
- test/core/end2end/tests/load_reporting_hook.c
- test/core/end2end/tests/max_concurrent_streams.c
- test/core/end2end/tests/max_connection_age.c
- test/core/end2end/tests/max_connection_idle.c
- test/core/end2end/tests/max_message_length.c
- test/core/end2end/tests/negative_deadline.c
- test/core/end2end/tests/network_status_change.c
- test/core/end2end/tests/no_logging.c
- test/core/end2end/tests/no_op.c
- test/core/end2end/tests/payload.c
- test/core/end2end/tests/ping.c
- test/core/end2end/tests/ping_pong_streaming.c
- test/core/end2end/tests/proxy_auth.c
- test/core/end2end/tests/registered_call.c
- test/core/end2end/tests/request_with_flags.c
- test/core/end2end/tests/request_with_payload.c
- test/core/end2end/tests/resource_quota_server.c
- test/core/end2end/tests/server_finishes_request.c
- test/core/end2end/tests/shutdown_finishes_calls.c
- test/core/end2end/tests/shutdown_finishes_tags.c
- test/core/end2end/tests/simple_cacheable_request.c
- test/core/end2end/tests/simple_delayed_request.c
- test/core/end2end/tests/simple_metadata.c
- test/core/end2end/tests/simple_request.c
- test/core/end2end/tests/stream_compression_compressed_payload.c
- test/core/end2end/tests/stream_compression_payload.c
- test/core/end2end/tests/stream_compression_ping_pong_streaming.c
- test/core/end2end/tests/streaming_error_response.c
- test/core/end2end/tests/trailing_metadata.c
- test/core/end2end/tests/workaround_cronet_compression.c
- test/core/end2end/tests/write_buffering.c
- test/core/end2end/tests/write_buffering_at_end.c
+ test/core/end2end/end2end_tests.cc
+ test/core/end2end/end2end_test_utils.cc
+ test/core/end2end/tests/authority_not_supported.cc
+ test/core/end2end/tests/bad_hostname.cc
+ test/core/end2end/tests/bad_ping.cc
+ test/core/end2end/tests/binary_metadata.cc
+ test/core/end2end/tests/call_creds.cc
+ test/core/end2end/tests/cancel_after_accept.cc
+ test/core/end2end/tests/cancel_after_client_done.cc
+ test/core/end2end/tests/cancel_after_invoke.cc
+ test/core/end2end/tests/cancel_after_round_trip.cc
+ test/core/end2end/tests/cancel_before_invoke.cc
+ test/core/end2end/tests/cancel_in_a_vacuum.cc
+ test/core/end2end/tests/cancel_with_status.cc
+ test/core/end2end/tests/compressed_payload.cc
+ test/core/end2end/tests/connectivity.cc
+ test/core/end2end/tests/default_host.cc
+ test/core/end2end/tests/disappearing_server.cc
+ test/core/end2end/tests/empty_batch.cc
+ test/core/end2end/tests/filter_call_init_fails.cc
+ test/core/end2end/tests/filter_causes_close.cc
+ test/core/end2end/tests/filter_latency.cc
+ test/core/end2end/tests/filter_status_code.cc
+ test/core/end2end/tests/graceful_server_shutdown.cc
+ test/core/end2end/tests/high_initial_seqno.cc
+ test/core/end2end/tests/hpack_size.cc
+ test/core/end2end/tests/idempotent_request.cc
+ test/core/end2end/tests/invoke_large_request.cc
+ test/core/end2end/tests/keepalive_timeout.cc
+ test/core/end2end/tests/large_metadata.cc
+ test/core/end2end/tests/load_reporting_hook.cc
+ test/core/end2end/tests/max_concurrent_streams.cc
+ test/core/end2end/tests/max_connection_age.cc
+ test/core/end2end/tests/max_connection_idle.cc
+ test/core/end2end/tests/max_message_length.cc
+ test/core/end2end/tests/negative_deadline.cc
+ test/core/end2end/tests/network_status_change.cc
+ test/core/end2end/tests/no_logging.cc
+ test/core/end2end/tests/no_op.cc
+ test/core/end2end/tests/payload.cc
+ test/core/end2end/tests/ping.cc
+ test/core/end2end/tests/ping_pong_streaming.cc
+ test/core/end2end/tests/proxy_auth.cc
+ test/core/end2end/tests/registered_call.cc
+ test/core/end2end/tests/request_with_flags.cc
+ test/core/end2end/tests/request_with_payload.cc
+ test/core/end2end/tests/resource_quota_server.cc
+ test/core/end2end/tests/server_finishes_request.cc
+ test/core/end2end/tests/shutdown_finishes_calls.cc
+ test/core/end2end/tests/shutdown_finishes_tags.cc
+ test/core/end2end/tests/simple_cacheable_request.cc
+ test/core/end2end/tests/simple_delayed_request.cc
+ test/core/end2end/tests/simple_metadata.cc
+ test/core/end2end/tests/simple_request.cc
+ test/core/end2end/tests/stream_compression_compressed_payload.cc
+ test/core/end2end/tests/stream_compression_payload.cc
+ test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+ test/core/end2end/tests/streaming_error_response.cc
+ test/core/end2end/tests/trailing_metadata.cc
+ test/core/end2end/tests/workaround_cronet_compression.cc
+ test/core/end2end/tests/write_buffering.cc
+ test/core/end2end/tests/write_buffering_at_end.cc
)
if(WIN32 AND MSVC)
@@ -4930,14 +4626,12 @@ endif()
target_include_directories(end2end_tests
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(end2end_tests
@@ -4954,66 +4648,67 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_library(end2end_nosec_tests
- test/core/end2end/end2end_nosec_tests.c
- test/core/end2end/end2end_test_utils.c
- test/core/end2end/tests/authority_not_supported.c
- test/core/end2end/tests/bad_hostname.c
- test/core/end2end/tests/bad_ping.c
- test/core/end2end/tests/binary_metadata.c
- test/core/end2end/tests/cancel_after_accept.c
- test/core/end2end/tests/cancel_after_client_done.c
- test/core/end2end/tests/cancel_after_invoke.c
- test/core/end2end/tests/cancel_after_round_trip.c
- test/core/end2end/tests/cancel_before_invoke.c
- test/core/end2end/tests/cancel_in_a_vacuum.c
- test/core/end2end/tests/cancel_with_status.c
- test/core/end2end/tests/compressed_payload.c
- test/core/end2end/tests/connectivity.c
- test/core/end2end/tests/default_host.c
- test/core/end2end/tests/disappearing_server.c
- test/core/end2end/tests/empty_batch.c
- test/core/end2end/tests/filter_call_init_fails.c
- test/core/end2end/tests/filter_causes_close.c
- test/core/end2end/tests/filter_latency.c
- test/core/end2end/tests/graceful_server_shutdown.c
- test/core/end2end/tests/high_initial_seqno.c
- test/core/end2end/tests/hpack_size.c
- test/core/end2end/tests/idempotent_request.c
- test/core/end2end/tests/invoke_large_request.c
- test/core/end2end/tests/keepalive_timeout.c
- test/core/end2end/tests/large_metadata.c
- test/core/end2end/tests/load_reporting_hook.c
- test/core/end2end/tests/max_concurrent_streams.c
- test/core/end2end/tests/max_connection_age.c
- test/core/end2end/tests/max_connection_idle.c
- test/core/end2end/tests/max_message_length.c
- test/core/end2end/tests/negative_deadline.c
- test/core/end2end/tests/network_status_change.c
- test/core/end2end/tests/no_logging.c
- test/core/end2end/tests/no_op.c
- test/core/end2end/tests/payload.c
- test/core/end2end/tests/ping.c
- test/core/end2end/tests/ping_pong_streaming.c
- test/core/end2end/tests/proxy_auth.c
- test/core/end2end/tests/registered_call.c
- test/core/end2end/tests/request_with_flags.c
- test/core/end2end/tests/request_with_payload.c
- test/core/end2end/tests/resource_quota_server.c
- test/core/end2end/tests/server_finishes_request.c
- test/core/end2end/tests/shutdown_finishes_calls.c
- test/core/end2end/tests/shutdown_finishes_tags.c
- test/core/end2end/tests/simple_cacheable_request.c
- test/core/end2end/tests/simple_delayed_request.c
- test/core/end2end/tests/simple_metadata.c
- test/core/end2end/tests/simple_request.c
- test/core/end2end/tests/stream_compression_compressed_payload.c
- test/core/end2end/tests/stream_compression_payload.c
- test/core/end2end/tests/stream_compression_ping_pong_streaming.c
- test/core/end2end/tests/streaming_error_response.c
- test/core/end2end/tests/trailing_metadata.c
- test/core/end2end/tests/workaround_cronet_compression.c
- test/core/end2end/tests/write_buffering.c
- test/core/end2end/tests/write_buffering_at_end.c
+ test/core/end2end/end2end_nosec_tests.cc
+ test/core/end2end/end2end_test_utils.cc
+ test/core/end2end/tests/authority_not_supported.cc
+ test/core/end2end/tests/bad_hostname.cc
+ test/core/end2end/tests/bad_ping.cc
+ test/core/end2end/tests/binary_metadata.cc
+ test/core/end2end/tests/cancel_after_accept.cc
+ test/core/end2end/tests/cancel_after_client_done.cc
+ test/core/end2end/tests/cancel_after_invoke.cc
+ test/core/end2end/tests/cancel_after_round_trip.cc
+ test/core/end2end/tests/cancel_before_invoke.cc
+ test/core/end2end/tests/cancel_in_a_vacuum.cc
+ test/core/end2end/tests/cancel_with_status.cc
+ test/core/end2end/tests/compressed_payload.cc
+ test/core/end2end/tests/connectivity.cc
+ test/core/end2end/tests/default_host.cc
+ test/core/end2end/tests/disappearing_server.cc
+ test/core/end2end/tests/empty_batch.cc
+ test/core/end2end/tests/filter_call_init_fails.cc
+ test/core/end2end/tests/filter_causes_close.cc
+ test/core/end2end/tests/filter_latency.cc
+ test/core/end2end/tests/filter_status_code.cc
+ test/core/end2end/tests/graceful_server_shutdown.cc
+ test/core/end2end/tests/high_initial_seqno.cc
+ test/core/end2end/tests/hpack_size.cc
+ test/core/end2end/tests/idempotent_request.cc
+ test/core/end2end/tests/invoke_large_request.cc
+ test/core/end2end/tests/keepalive_timeout.cc
+ test/core/end2end/tests/large_metadata.cc
+ test/core/end2end/tests/load_reporting_hook.cc
+ test/core/end2end/tests/max_concurrent_streams.cc
+ test/core/end2end/tests/max_connection_age.cc
+ test/core/end2end/tests/max_connection_idle.cc
+ test/core/end2end/tests/max_message_length.cc
+ test/core/end2end/tests/negative_deadline.cc
+ test/core/end2end/tests/network_status_change.cc
+ test/core/end2end/tests/no_logging.cc
+ test/core/end2end/tests/no_op.cc
+ test/core/end2end/tests/payload.cc
+ test/core/end2end/tests/ping.cc
+ test/core/end2end/tests/ping_pong_streaming.cc
+ test/core/end2end/tests/proxy_auth.cc
+ test/core/end2end/tests/registered_call.cc
+ test/core/end2end/tests/request_with_flags.cc
+ test/core/end2end/tests/request_with_payload.cc
+ test/core/end2end/tests/resource_quota_server.cc
+ test/core/end2end/tests/server_finishes_request.cc
+ test/core/end2end/tests/shutdown_finishes_calls.cc
+ test/core/end2end/tests/shutdown_finishes_tags.cc
+ test/core/end2end/tests/simple_cacheable_request.cc
+ test/core/end2end/tests/simple_delayed_request.cc
+ test/core/end2end/tests/simple_metadata.cc
+ test/core/end2end/tests/simple_request.cc
+ test/core/end2end/tests/stream_compression_compressed_payload.cc
+ test/core/end2end/tests/stream_compression_payload.cc
+ test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+ test/core/end2end/tests/streaming_error_response.cc
+ test/core/end2end/tests/trailing_metadata.cc
+ test/core/end2end/tests/workaround_cronet_compression.cc
+ test/core/end2end/tests/write_buffering.cc
+ test/core/end2end/tests/write_buffering_at_end.cc
)
if(WIN32 AND MSVC)
@@ -5031,14 +4726,12 @@ endif()
target_include_directories(end2end_nosec_tests
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${ZLIB_INCLUDE_DIR}
- PRIVATE ${BENCHMARK}/include
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(end2end_nosec_tests
@@ -5055,21 +4748,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(alarm_test
- test/core/surface/alarm_test.c
+ test/core/surface/alarm_test.cc
)
target_include_directories(alarm_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(alarm_test
@@ -5084,21 +4775,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(algorithm_test
- test/core/compression/algorithm_test.c
+ test/core/compression/algorithm_test.cc
)
target_include_directories(algorithm_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(algorithm_test
@@ -5113,21 +4802,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(alloc_test
- test/core/support/alloc_test.c
+ test/core/gpr/alloc_test.cc
)
target_include_directories(alloc_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(alloc_test
@@ -5140,21 +4827,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(alpn_test
- test/core/transport/chttp2/alpn_test.c
+ test/core/transport/chttp2/alpn_test.cc
)
target_include_directories(alpn_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(alpn_test
@@ -5169,21 +4854,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(arena_test
- test/core/support/arena_test.c
+ test/core/gpr/arena_test.cc
)
target_include_directories(arena_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(arena_test
@@ -5196,21 +4879,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(bad_server_response_test
- test/core/end2end/bad_server_response_test.c
+ test/core/end2end/bad_server_response_test.cc
)
target_include_directories(bad_server_response_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bad_server_response_test
@@ -5225,51 +4906,20 @@ target_link_libraries(bad_server_response_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(bdp_estimator_test
- test/core/transport/bdp_estimator_test.c
-)
-
-
-target_include_directories(bdp_estimator_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(bdp_estimator_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(bin_decoder_test
- test/core/transport/chttp2/bin_decoder_test.c
+ test/core/transport/chttp2/bin_decoder_test.cc
)
target_include_directories(bin_decoder_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bin_decoder_test
@@ -5282,21 +4932,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(bin_encoder_test
- test/core/transport/chttp2/bin_encoder_test.c
+ test/core/transport/chttp2/bin_encoder_test.cc
)
target_include_directories(bin_encoder_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bin_encoder_test
@@ -5309,21 +4957,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(byte_stream_test
- test/core/transport/byte_stream_test.c
+ test/core/transport/byte_stream_test.cc
)
target_include_directories(byte_stream_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(byte_stream_test
@@ -5337,138 +4983,20 @@ target_link_libraries(byte_stream_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(census_context_test
- test/core/census/context_test.c
-)
-
-
-target_include_directories(census_context_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(census_context_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
-add_executable(census_intrusive_hash_map_test
- test/core/census/intrusive_hash_map_test.c
-)
-
-
-target_include_directories(census_intrusive_hash_map_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(census_intrusive_hash_map_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
-add_executable(census_resource_test
- test/core/census/resource_test.c
-)
-
-
-target_include_directories(census_resource_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(census_resource_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
-add_executable(census_trace_context_test
- test/core/census/trace_context_test.c
-)
-
-
-target_include_directories(census_trace_context_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(census_trace_context_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(channel_create_test
- test/core/surface/channel_create_test.c
+ test/core/surface/channel_create_test.cc
)
target_include_directories(channel_create_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(channel_create_test
@@ -5489,14 +5017,12 @@ add_executable(check_epollexclusive
target_include_directories(check_epollexclusive
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(check_epollexclusive
@@ -5517,21 +5043,19 @@ endif()
if (gRPC_BUILD_TESTS)
add_executable(chttp2_hpack_encoder_test
- test/core/transport/chttp2/hpack_encoder_test.c
+ test/core/transport/chttp2/hpack_encoder_test.cc
)
target_include_directories(chttp2_hpack_encoder_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(chttp2_hpack_encoder_test
@@ -5546,21 +5070,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(chttp2_stream_map_test
- test/core/transport/chttp2/stream_map_test.c
+ test/core/transport/chttp2/stream_map_test.cc
)
target_include_directories(chttp2_stream_map_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(chttp2_stream_map_test
@@ -5575,21 +5097,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(chttp2_varint_test
- test/core/transport/chttp2/varint_test.c
+ test/core/transport/chttp2/varint_test.cc
)
target_include_directories(chttp2_varint_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(chttp2_varint_test
@@ -5604,21 +5124,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(combiner_test
- test/core/iomgr/combiner_test.c
+ test/core/iomgr/combiner_test.cc
)
target_include_directories(combiner_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(combiner_test
@@ -5633,21 +5151,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(compression_test
- test/core/compression/compression_test.c
+ test/core/compression/compression_test.cc
)
target_include_directories(compression_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(compression_test
@@ -5662,21 +5178,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(concurrent_connectivity_test
- test/core/surface/concurrent_connectivity_test.c
+ test/core/surface/concurrent_connectivity_test.cc
)
target_include_directories(concurrent_connectivity_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(concurrent_connectivity_test
@@ -5691,21 +5205,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(connection_refused_test
- test/core/end2end/connection_refused_test.c
+ test/core/end2end/connection_refused_test.cc
)
target_include_directories(connection_refused_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(connection_refused_test
@@ -5720,21 +5232,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(dns_resolver_connectivity_test
- test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+ test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
)
target_include_directories(dns_resolver_connectivity_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(dns_resolver_connectivity_test
@@ -5749,21 +5259,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(dns_resolver_test
- test/core/client_channel/resolvers/dns_resolver_test.c
+ test/core/client_channel/resolvers/dns_resolver_test.cc
)
target_include_directories(dns_resolver_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(dns_resolver_test
@@ -5779,21 +5287,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(dualstack_socket_test
- test/core/end2end/dualstack_socket_test.c
+ test/core/end2end/dualstack_socket_test.cc
)
target_include_directories(dualstack_socket_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(dualstack_socket_test
@@ -5809,21 +5315,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(endpoint_pair_test
- test/core/iomgr/endpoint_pair_test.c
+ test/core/iomgr/endpoint_pair_test.cc
)
target_include_directories(endpoint_pair_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(endpoint_pair_test
@@ -5838,21 +5342,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(error_test
- test/core/iomgr/error_test.c
+ test/core/iomgr/error_test.cc
)
target_include_directories(error_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(error_test
@@ -5868,21 +5370,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(ev_epollsig_linux_test
- test/core/iomgr/ev_epollsig_linux_test.c
+ test/core/iomgr/ev_epollsig_linux_test.cc
)
target_include_directories(ev_epollsig_linux_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(ev_epollsig_linux_test
@@ -5898,21 +5398,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(fake_resolver_test
- test/core/client_channel/resolvers/fake_resolver_test.c
+ test/core/client_channel/resolvers/fake_resolver_test.cc
)
target_include_directories(fake_resolver_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fake_resolver_test
@@ -5928,22 +5426,20 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(fake_transport_security_test
- test/core/tsi/fake_transport_security_test.c
- test/core/tsi/transport_security_test_lib.c
+ test/core/tsi/fake_transport_security_test.cc
+ test/core/tsi/transport_security_test_lib.cc
)
target_include_directories(fake_transport_security_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fake_transport_security_test
@@ -5959,21 +5455,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(fd_conservation_posix_test
- test/core/iomgr/fd_conservation_posix_test.c
+ test/core/iomgr/fd_conservation_posix_test.cc
)
target_include_directories(fd_conservation_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fd_conservation_posix_test
@@ -5990,21 +5484,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(fd_posix_test
- test/core/iomgr/fd_posix_test.c
+ test/core/iomgr/fd_posix_test.cc
)
target_include_directories(fd_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fd_posix_test
@@ -6020,21 +5512,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(fling_client
- test/core/fling/client.c
+ test/core/fling/client.cc
)
target_include_directories(fling_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fling_client
@@ -6049,21 +5539,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(fling_server
- test/core/fling/server.c
+ test/core/fling/server.cc
)
target_include_directories(fling_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fling_server
@@ -6079,21 +5567,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(fling_stream_test
- test/core/fling/fling_stream_test.c
+ test/core/fling/fling_stream_test.cc
)
target_include_directories(fling_stream_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fling_stream_test
@@ -6110,21 +5596,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(fling_test
- test/core/fling/fling_test.c
+ test/core/fling/fling_test.cc
)
target_include_directories(fling_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(fling_test
@@ -6137,123 +5621,23 @@ target_link_libraries(fling_test
endif()
endif (gRPC_BUILD_TESTS)
-
-add_executable(gen_hpack_tables
- tools/codegen/core/gen_hpack_tables.c
-)
-
-
-target_include_directories(gen_hpack_tables
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(gen_hpack_tables
- ${_gRPC_ALLTARGETS_LIBRARIES}
- gpr
- grpc
-)
-
-
-if (gRPC_INSTALL)
- install(TARGETS gen_hpack_tables EXPORT gRPCTargets
- RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
- LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
- )
-endif()
-
-
-add_executable(gen_legal_metadata_characters
- tools/codegen/core/gen_legal_metadata_characters.c
-)
-
-
-target_include_directories(gen_legal_metadata_characters
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(gen_legal_metadata_characters
- ${_gRPC_ALLTARGETS_LIBRARIES}
-)
-
-
-if (gRPC_INSTALL)
- install(TARGETS gen_legal_metadata_characters EXPORT gRPCTargets
- RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
- LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
- )
-endif()
-
-
-add_executable(gen_percent_encoding_tables
- tools/codegen/core/gen_percent_encoding_tables.c
-)
-
-
-target_include_directories(gen_percent_encoding_tables
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(gen_percent_encoding_tables
- ${_gRPC_ALLTARGETS_LIBRARIES}
-)
-
-
-if (gRPC_INSTALL)
- install(TARGETS gen_percent_encoding_tables EXPORT gRPCTargets
- RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
- LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
- )
-endif()
-
if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(goaway_server_test
- test/core/end2end/goaway_server_test.c
+ test/core/end2end/goaway_server_test.cc
)
target_include_directories(goaway_server_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(goaway_server_test
@@ -6269,21 +5653,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_avl_test
- test/core/support/avl_test.c
+ test/core/gpr/avl_test.cc
)
target_include_directories(gpr_avl_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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
@@ -6295,49 +5677,20 @@ target_link_libraries(gpr_avl_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_backoff_test
- test/core/support/backoff_test.c
-)
-
-
-target_include_directories(gpr_backoff_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(gpr_backoff_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(gpr_cmdline_test
- test/core/support/cmdline_test.c
+ test/core/gpr/cmdline_test.cc
)
target_include_directories(gpr_cmdline_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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
@@ -6350,21 +5703,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_cpu_test
- test/core/support/cpu_test.c
+ test/core/gpr/cpu_test.cc
)
target_include_directories(gpr_cpu_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_cpu_test
@@ -6377,21 +5728,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_env_test
- test/core/support/env_test.c
+ test/core/gpr/env_test.cc
)
target_include_directories(gpr_env_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_env_test
@@ -6403,49 +5752,20 @@ target_link_libraries(gpr_env_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_histogram_test
- test/core/support/histogram_test.c
-)
-
-
-target_include_directories(gpr_histogram_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(gpr_histogram_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(gpr_host_port_test
- test/core/support/host_port_test.c
+ test/core/gpr/host_port_test.cc
)
target_include_directories(gpr_host_port_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_host_port_test
@@ -6458,21 +5778,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_log_test
- test/core/support/log_test.c
+ test/core/gpr/log_test.cc
)
target_include_directories(gpr_log_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_log_test
@@ -6484,25 +5802,23 @@ target_link_libraries(gpr_log_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_mpscq_test
- test/core/support/mpscq_test.c
+add_executable(gpr_manual_constructor_test
+ test/core/gprpp/manual_constructor_test.cc
)
-target_include_directories(gpr_mpscq_test
+target_include_directories(gpr_manual_constructor_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_mpscq_test
+target_link_libraries(gpr_manual_constructor_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
@@ -6511,25 +5827,23 @@ target_link_libraries(gpr_mpscq_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_spinlock_test
- test/core/support/spinlock_test.c
+add_executable(gpr_mpscq_test
+ test/core/gpr/mpscq_test.cc
)
-target_include_directories(gpr_spinlock_test
+target_include_directories(gpr_mpscq_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_spinlock_test
+target_link_libraries(gpr_mpscq_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
@@ -6538,25 +5852,23 @@ target_link_libraries(gpr_spinlock_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_stack_lockfree_test
- test/core/support/stack_lockfree_test.c
+add_executable(gpr_spinlock_test
+ test/core/gpr/spinlock_test.cc
)
-target_include_directories(gpr_stack_lockfree_test
+target_include_directories(gpr_spinlock_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_stack_lockfree_test
+target_link_libraries(gpr_spinlock_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
@@ -6566,21 +5878,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_string_test
- test/core/support/string_test.c
+ test/core/gpr/string_test.cc
)
target_include_directories(gpr_string_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_string_test
@@ -6593,21 +5903,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_sync_test
- test/core/support/sync_test.c
+ test/core/gpr/sync_test.cc
)
target_include_directories(gpr_sync_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_sync_test
@@ -6620,21 +5928,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_thd_test
- test/core/support/thd_test.c
+ test/core/gpr/thd_test.cc
)
target_include_directories(gpr_thd_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_thd_test
@@ -6647,21 +5953,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_time_test
- test/core/support/time_test.c
+ test/core/gpr/time_test.cc
)
target_include_directories(gpr_time_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_time_test
@@ -6674,21 +5978,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_tls_test
- test/core/support/tls_test.c
+ test/core/gpr/tls_test.cc
)
target_include_directories(gpr_tls_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_tls_test
@@ -6701,21 +6003,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_useful_test
- test/core/support/useful_test.c
+ test/core/gpr/useful_test.cc
)
target_include_directories(gpr_useful_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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_useful_test
@@ -6728,21 +6028,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_auth_context_test
- test/core/security/auth_context_test.c
+ test/core/security/auth_context_test.cc
)
target_include_directories(grpc_auth_context_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_auth_context_test
@@ -6757,21 +6055,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_b64_test
- test/core/slice/b64_test.c
+ test/core/slice/b64_test.cc
)
target_include_directories(grpc_b64_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_b64_test
@@ -6786,21 +6082,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_byte_buffer_reader_test
- test/core/surface/byte_buffer_reader_test.c
+ test/core/surface/byte_buffer_reader_test.cc
)
target_include_directories(grpc_byte_buffer_reader_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_byte_buffer_reader_test
@@ -6815,21 +6109,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_channel_args_test
- test/core/channel/channel_args_test.c
+ test/core/channel/channel_args_test.cc
)
target_include_directories(grpc_channel_args_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_channel_args_test
@@ -6844,21 +6136,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_channel_stack_builder_test
- test/core/channel/channel_stack_builder_test.c
+ test/core/channel/channel_stack_builder_test.cc
)
target_include_directories(grpc_channel_stack_builder_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_channel_stack_builder_test
@@ -6873,21 +6163,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_channel_stack_test
- test/core/channel/channel_stack_test.c
+ test/core/channel/channel_stack_test.cc
)
target_include_directories(grpc_channel_stack_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_channel_stack_test
@@ -6902,21 +6190,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_completion_queue_test
- test/core/surface/completion_queue_test.c
+ test/core/surface/completion_queue_test.cc
)
target_include_directories(grpc_completion_queue_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_completion_queue_test
@@ -6931,21 +6217,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_completion_queue_threading_test
- test/core/surface/completion_queue_threading_test.c
+ test/core/surface/completion_queue_threading_test.cc
)
target_include_directories(grpc_completion_queue_threading_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_completion_queue_threading_test
@@ -6959,21 +6243,19 @@ target_link_libraries(grpc_completion_queue_threading_test
endif (gRPC_BUILD_TESTS)
add_executable(grpc_create_jwt
- test/core/security/create_jwt.c
+ test/core/security/create_jwt.cc
)
target_include_directories(grpc_create_jwt
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_create_jwt
@@ -6995,21 +6277,19 @@ endif()
if (gRPC_BUILD_TESTS)
add_executable(grpc_credentials_test
- test/core/security/credentials_test.c
+ test/core/security/credentials_test.cc
)
target_include_directories(grpc_credentials_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_credentials_test
@@ -7024,21 +6304,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_fetch_oauth2
- test/core/security/fetch_oauth2.c
+ test/core/security/fetch_oauth2.cc
)
target_include_directories(grpc_fetch_oauth2
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_fetch_oauth2
@@ -7053,21 +6331,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_invalid_channel_args_test
- test/core/surface/invalid_channel_args_test.c
+ test/core/surface/invalid_channel_args_test.cc
)
target_include_directories(grpc_invalid_channel_args_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_invalid_channel_args_test
@@ -7083,21 +6359,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(grpc_json_token_test
- test/core/security/json_token_test.c
+ test/core/security/json_token_test.cc
)
target_include_directories(grpc_json_token_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_json_token_test
@@ -7113,21 +6387,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_jwt_verifier_test
- test/core/security/jwt_verifier_test.c
+ test/core/security/jwt_verifier_test.cc
)
target_include_directories(grpc_jwt_verifier_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_jwt_verifier_test
@@ -7141,21 +6413,19 @@ target_link_libraries(grpc_jwt_verifier_test
endif (gRPC_BUILD_TESTS)
add_executable(grpc_print_google_default_creds_token
- test/core/security/print_google_default_creds_token.c
+ test/core/security/print_google_default_creds_token.cc
)
target_include_directories(grpc_print_google_default_creds_token
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_print_google_default_creds_token
@@ -7176,21 +6446,19 @@ endif()
if (gRPC_BUILD_TESTS)
add_executable(grpc_security_connector_test
- test/core/security/security_connector_test.c
+ test/core/security/security_connector_test.cc
)
target_include_directories(grpc_security_connector_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_security_connector_test
@@ -7202,23 +6470,48 @@ target_link_libraries(grpc_security_connector_test
)
endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
+add_executable(grpc_ssl_credentials_test
+ test/core/security/ssl_credentials_test.cc
+)
+
+
+target_include_directories(grpc_ssl_credentials_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(grpc_ssl_credentials_test
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+)
+
+endif (gRPC_BUILD_TESTS)
add_executable(grpc_verify_jwt
- test/core/security/verify_jwt.c
+ test/core/security/verify_jwt.cc
)
target_include_directories(grpc_verify_jwt
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(grpc_verify_jwt
@@ -7240,21 +6533,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(handshake_client
- test/core/handshake/client_ssl.c
+ test/core/handshake/client_ssl.cc
)
target_include_directories(handshake_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(handshake_client
@@ -7272,21 +6563,20 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(handshake_server
- test/core/handshake/server_ssl.c
+ test/core/handshake/server_ssl.cc
+ test/core/handshake/server_ssl_common.cc
)
target_include_directories(handshake_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(handshake_server
@@ -7301,23 +6591,77 @@ target_link_libraries(handshake_server
endif()
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+if(_gRPC_PLATFORM_LINUX)
+
+add_executable(handshake_server_with_readahead_handshaker
+ test/core/handshake/readahead_handshaker_server_ssl.cc
+ test/core/handshake/server_ssl_common.cc
+)
+
+
+target_include_directories(handshake_server_with_readahead_handshaker
+ 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(handshake_server_with_readahead_handshaker
+ ${_gRPC_SSL_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+)
+
+endif()
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
+add_executable(histogram_test
+ test/core/util/histogram_test.cc
+)
+
+
+target_include_directories(histogram_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(histogram_test
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ gpr
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
add_executable(hpack_parser_test
- test/core/transport/chttp2/hpack_parser_test.c
+ test/core/transport/chttp2/hpack_parser_test.cc
)
target_include_directories(hpack_parser_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(hpack_parser_test
@@ -7332,21 +6676,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(hpack_table_test
- test/core/transport/chttp2/hpack_table_test.c
+ test/core/transport/chttp2/hpack_table_test.cc
)
target_include_directories(hpack_table_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(hpack_table_test
@@ -7361,21 +6703,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(http_parser_test
- test/core/http/parser_test.c
+ test/core/http/parser_test.cc
)
target_include_directories(http_parser_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(http_parser_test
@@ -7390,21 +6730,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(httpcli_format_request_test
- test/core/http/format_request_test.c
+ test/core/http/format_request_test.cc
)
target_include_directories(httpcli_format_request_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(httpcli_format_request_test
@@ -7420,21 +6758,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(httpcli_test
- test/core/http/httpcli_test.c
+ test/core/http/httpcli_test.cc
)
target_include_directories(httpcli_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(httpcli_test
@@ -7451,21 +6787,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(httpscli_test
- test/core/http/httpscli_test.c
+ test/core/http/httpscli_test.cc
)
target_include_directories(httpscli_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(httpscli_test
@@ -7481,21 +6815,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(init_test
- test/core/surface/init_test.c
+ test/core/surface/init_test.cc
)
target_include_directories(init_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(init_test
@@ -7510,21 +6842,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(invalid_call_argument_test
- test/core/end2end/invalid_call_argument_test.c
+ test/core/end2end/invalid_call_argument_test.cc
)
target_include_directories(invalid_call_argument_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(invalid_call_argument_test
@@ -7539,21 +6869,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(json_rewrite
- test/core/json/json_rewrite.c
+ test/core/json/json_rewrite.cc
)
target_include_directories(json_rewrite
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(json_rewrite
@@ -7566,21 +6894,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(json_rewrite_test
- test/core/json/json_rewrite_test.c
+ test/core/json/json_rewrite_test.cc
)
target_include_directories(json_rewrite_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(json_rewrite_test
@@ -7595,21 +6921,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(json_stream_error_test
- test/core/json/json_stream_error_test.c
+ test/core/json/json_stream_error_test.cc
)
target_include_directories(json_stream_error_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(json_stream_error_test
@@ -7624,21 +6948,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(json_test
- test/core/json/json_test.c
+ test/core/json/json_test.cc
)
target_include_directories(json_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(json_test
@@ -7653,21 +6975,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(lame_client_test
- test/core/surface/lame_client_test.c
+ test/core/surface/lame_client_test.cc
)
target_include_directories(lame_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(lame_client_test
@@ -7682,21 +7002,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(lb_policies_test
- test/core/client_channel/lb_policies_test.c
+ test/core/client_channel/lb_policies_test.cc
)
target_include_directories(lb_policies_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(lb_policies_test
@@ -7711,21 +7029,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(load_file_test
- test/core/iomgr/load_file_test.c
+ test/core/iomgr/load_file_test.cc
)
target_include_directories(load_file_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(load_file_test
@@ -7740,21 +7056,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(memory_profile_client
- test/core/memory_usage/client.c
+ test/core/memory_usage/client.cc
)
target_include_directories(memory_profile_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(memory_profile_client
@@ -7769,21 +7083,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(memory_profile_server
- test/core/memory_usage/server.c
+ test/core/memory_usage/server.cc
)
target_include_directories(memory_profile_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(memory_profile_server
@@ -7799,21 +7111,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(memory_profile_test
- test/core/memory_usage/memory_usage_test.c
+ test/core/memory_usage/memory_usage_test.cc
)
target_include_directories(memory_profile_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(memory_profile_test
@@ -7829,21 +7139,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(message_compress_test
- test/core/compression/message_compress_test.c
+ test/core/compression/message_compress_test.cc
)
target_include_directories(message_compress_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(message_compress_test
@@ -7858,21 +7166,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(minimal_stack_is_minimal_test
- test/core/channel/minimal_stack_is_minimal_test.c
+ test/core/channel/minimal_stack_is_minimal_test.cc
)
target_include_directories(minimal_stack_is_minimal_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(minimal_stack_is_minimal_test
@@ -7886,51 +7192,20 @@ target_link_libraries(minimal_stack_is_minimal_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(mlog_test
- test/core/census/mlog_test.c
-)
-
-
-target_include_directories(mlog_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(mlog_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(multiple_server_queues_test
- test/core/end2end/multiple_server_queues_test.c
+ test/core/end2end/multiple_server_queues_test.cc
)
target_include_directories(multiple_server_queues_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(multiple_server_queues_test
@@ -7945,21 +7220,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(murmur_hash_test
- test/core/support/murmur_hash_test.c
+ test/core/gpr/murmur_hash_test.cc
)
target_include_directories(murmur_hash_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(murmur_hash_test
@@ -7972,21 +7245,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(no_server_test
- test/core/end2end/no_server_test.c
+ test/core/end2end/no_server_test.cc
)
target_include_directories(no_server_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(no_server_test
@@ -8001,21 +7272,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(num_external_connectivity_watchers_test
- test/core/surface/num_external_connectivity_watchers_test.c
+ test/core/surface/num_external_connectivity_watchers_test.cc
)
target_include_directories(num_external_connectivity_watchers_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(num_external_connectivity_watchers_test
@@ -8030,21 +7299,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(parse_address_test
- test/core/client_channel/parse_address_test.c
+ test/core/client_channel/parse_address_test.cc
)
target_include_directories(parse_address_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(parse_address_test
@@ -8059,21 +7326,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(percent_encoding_test
- test/core/slice/percent_encoding_test.c
+ test/core/slice/percent_encoding_test.cc
)
target_include_directories(percent_encoding_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(percent_encoding_test
@@ -8089,21 +7354,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(pollset_set_test
- test/core/iomgr/pollset_set_test.c
+ test/core/iomgr/pollset_set_test.cc
)
target_include_directories(pollset_set_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(pollset_set_test
@@ -8120,21 +7383,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(resolve_address_posix_test
- test/core/iomgr/resolve_address_posix_test.c
+ test/core/iomgr/resolve_address_posix_test.cc
)
target_include_directories(resolve_address_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(resolve_address_posix_test
@@ -8150,21 +7411,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(resolve_address_test
- test/core/iomgr/resolve_address_test.c
+ test/core/iomgr/resolve_address_test.cc
)
target_include_directories(resolve_address_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(resolve_address_test
@@ -8179,21 +7438,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(resource_quota_test
- test/core/iomgr/resource_quota_test.c
+ test/core/iomgr/resource_quota_test.cc
)
target_include_directories(resource_quota_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(resource_quota_test
@@ -8208,21 +7465,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(secure_channel_create_test
- test/core/surface/secure_channel_create_test.c
+ test/core/surface/secure_channel_create_test.cc
)
target_include_directories(secure_channel_create_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(secure_channel_create_test
@@ -8237,21 +7492,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(secure_endpoint_test
- test/core/security/secure_endpoint_test.c
+ test/core/security/secure_endpoint_test.cc
)
target_include_directories(secure_endpoint_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(secure_endpoint_test
@@ -8266,21 +7519,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(sequential_connectivity_test
- test/core/surface/sequential_connectivity_test.c
+ test/core/surface/sequential_connectivity_test.cc
)
target_include_directories(sequential_connectivity_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(sequential_connectivity_test
@@ -8295,21 +7546,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(server_chttp2_test
- test/core/surface/server_chttp2_test.c
+ test/core/surface/server_chttp2_test.cc
)
target_include_directories(server_chttp2_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(server_chttp2_test
@@ -8324,21 +7573,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(server_test
- test/core/surface/server_test.c
+ test/core/surface/server_test.cc
)
target_include_directories(server_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(server_test
@@ -8353,21 +7600,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(slice_buffer_test
- test/core/slice/slice_buffer_test.c
+ test/core/slice/slice_buffer_test.cc
)
target_include_directories(slice_buffer_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(slice_buffer_test
@@ -8382,21 +7627,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(slice_hash_table_test
- test/core/slice/slice_hash_table_test.c
+ test/core/slice/slice_hash_table_test.cc
)
target_include_directories(slice_hash_table_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(slice_hash_table_test
@@ -8411,21 +7654,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(slice_string_helpers_test
- test/core/slice/slice_string_helpers_test.c
+ test/core/slice/slice_string_helpers_test.cc
)
target_include_directories(slice_string_helpers_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(slice_string_helpers_test
@@ -8440,21 +7681,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(slice_test
- test/core/slice/slice_test.c
+ test/core/slice/slice_test.cc
)
target_include_directories(slice_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(slice_test
@@ -8469,21 +7708,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(sockaddr_resolver_test
- test/core/client_channel/resolvers/sockaddr_resolver_test.c
+ test/core/client_channel/resolvers/sockaddr_resolver_test.cc
)
target_include_directories(sockaddr_resolver_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(sockaddr_resolver_test
@@ -8498,21 +7735,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(sockaddr_utils_test
- test/core/iomgr/sockaddr_utils_test.c
+ test/core/iomgr/sockaddr_utils_test.cc
)
target_include_directories(sockaddr_utils_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(sockaddr_utils_test
@@ -8528,21 +7763,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(socket_utils_test
- test/core/iomgr/socket_utils_test.c
+ test/core/iomgr/socket_utils_test.cc
)
target_include_directories(socket_utils_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(socket_utils_test
@@ -8559,22 +7792,20 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(ssl_transport_security_test
- test/core/tsi/ssl_transport_security_test.c
- test/core/tsi/transport_security_test_lib.c
+ test/core/tsi/ssl_transport_security_test.cc
+ test/core/tsi/transport_security_test_lib.cc
)
target_include_directories(ssl_transport_security_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(ssl_transport_security_test
@@ -8589,21 +7820,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(status_conversion_test
- test/core/transport/status_conversion_test.c
+ test/core/transport/status_conversion_test.cc
)
target_include_directories(status_conversion_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(status_conversion_test
@@ -8618,21 +7847,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(stream_compression_test
- test/core/compression/stream_compression_test.c
+ test/core/compression/stream_compression_test.cc
)
target_include_directories(stream_compression_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(stream_compression_test
@@ -8647,21 +7874,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(stream_owned_slice_test
- test/core/transport/stream_owned_slice_test.c
+ test/core/transport/stream_owned_slice_test.cc
)
target_include_directories(stream_owned_slice_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(stream_owned_slice_test
@@ -8677,21 +7902,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(tcp_client_posix_test
- test/core/iomgr/tcp_client_posix_test.c
+ test/core/iomgr/tcp_client_posix_test.cc
)
target_include_directories(tcp_client_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(tcp_client_posix_test
@@ -8707,21 +7930,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(tcp_client_uv_test
- test/core/iomgr/tcp_client_uv_test.c
+ test/core/iomgr/tcp_client_uv_test.cc
)
target_include_directories(tcp_client_uv_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(tcp_client_uv_test
@@ -8737,21 +7958,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(tcp_posix_test
- test/core/iomgr/tcp_posix_test.c
+ test/core/iomgr/tcp_posix_test.cc
)
target_include_directories(tcp_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(tcp_posix_test
@@ -8768,21 +7987,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(tcp_server_posix_test
- test/core/iomgr/tcp_server_posix_test.c
+ test/core/iomgr/tcp_server_posix_test.cc
)
target_include_directories(tcp_server_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(tcp_server_posix_test
@@ -8798,21 +8015,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(tcp_server_uv_test
- test/core/iomgr/tcp_server_uv_test.c
+ test/core/iomgr/tcp_server_uv_test.cc
)
target_include_directories(tcp_server_uv_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(tcp_server_uv_test
@@ -8827,21 +8042,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(time_averaged_stats_test
- test/core/iomgr/time_averaged_stats_test.c
+ test/core/iomgr/time_averaged_stats_test.cc
)
target_include_directories(time_averaged_stats_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(time_averaged_stats_test
@@ -8856,21 +8069,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(timeout_encoding_test
- test/core/transport/timeout_encoding_test.c
+ test/core/transport/timeout_encoding_test.cc
)
target_include_directories(timeout_encoding_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(timeout_encoding_test
@@ -8885,21 +8096,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(timer_heap_test
- test/core/iomgr/timer_heap_test.c
+ test/core/iomgr/timer_heap_test.cc
)
target_include_directories(timer_heap_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(timer_heap_test
@@ -8914,21 +8123,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(timer_list_test
- test/core/iomgr/timer_list_test.c
+ test/core/iomgr/timer_list_test.cc
)
target_include_directories(timer_list_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(timer_list_test
@@ -8943,21 +8150,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(transport_connectivity_state_test
- test/core/transport/connectivity_state_test.c
+ test/core/transport/connectivity_state_test.cc
)
target_include_directories(transport_connectivity_state_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(transport_connectivity_state_test
@@ -8972,21 +8177,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(transport_metadata_test
- test/core/transport/metadata_test.c
+ test/core/transport/metadata_test.cc
)
target_include_directories(transport_metadata_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(transport_metadata_test
@@ -8999,53 +8202,22 @@ target_link_libraries(transport_metadata_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-
-add_executable(transport_pid_controller_test
- test/core/transport/pid_controller_test.c
-)
-
-
-target_include_directories(transport_pid_controller_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(transport_pid_controller_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(transport_security_test
- test/core/tsi/transport_security_test.c
+ test/core/tsi/transport_security_test.cc
)
target_include_directories(transport_security_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(transport_security_test
@@ -9062,21 +8234,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(udp_server_test
- test/core/iomgr/udp_server_test.c
+ test/core/iomgr/udp_server_test.cc
)
target_include_directories(udp_server_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(udp_server_test
@@ -9092,21 +8262,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(uri_parser_test
- test/core/client_channel/uri_parser_test.c
+ test/core/client_channel/uri_parser_test.cc
)
target_include_directories(uri_parser_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(uri_parser_test
@@ -9122,21 +8290,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(wakeup_fd_cv_test
- test/core/iomgr/wakeup_fd_cv_test.c
+ test/core/iomgr/wakeup_fd_cv_test.cc
)
target_include_directories(wakeup_fd_cv_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(wakeup_fd_cv_test
@@ -9161,14 +8327,12 @@ add_executable(alarm_cpp_test
target_include_directories(alarm_cpp_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9201,14 +8365,12 @@ add_executable(async_end2end_test
target_include_directories(async_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9241,14 +8403,12 @@ add_executable(auth_property_iterator_test
target_include_directories(auth_property_iterator_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9270,6 +8430,80 @@ target_link_libraries(auth_property_iterator_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+
+add_executable(backoff_test
+ test/core/backoff/backoff_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(backoff_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(backoff_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
+add_executable(bdp_estimator_test
+ test/core/transport/bdp_estimator_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(bdp_estimator_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(bdp_estimator_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc++_test_util
+ grpc++
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(bm_arena
@@ -9282,14 +8516,12 @@ add_executable(bm_arena
target_include_directories(bm_arena
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9301,7 +8533,7 @@ target_link_libraries(bm_arena
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9326,14 +8558,12 @@ add_executable(bm_call_create
target_include_directories(bm_call_create
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9345,7 +8575,7 @@ target_link_libraries(bm_call_create
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9370,14 +8600,12 @@ add_executable(bm_chttp2_hpack
target_include_directories(bm_chttp2_hpack
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9389,7 +8617,7 @@ target_link_libraries(bm_chttp2_hpack
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9414,14 +8642,12 @@ add_executable(bm_chttp2_transport
target_include_directories(bm_chttp2_transport
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9433,7 +8659,7 @@ target_link_libraries(bm_chttp2_transport
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9458,14 +8684,12 @@ add_executable(bm_closure
target_include_directories(bm_closure
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9477,7 +8701,7 @@ target_link_libraries(bm_closure
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9502,14 +8726,12 @@ add_executable(bm_cq
target_include_directories(bm_cq
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9521,7 +8743,7 @@ target_link_libraries(bm_cq
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9546,14 +8768,12 @@ add_executable(bm_cq_multiple_threads
target_include_directories(bm_cq_multiple_threads
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9565,7 +8785,7 @@ target_link_libraries(bm_cq_multiple_threads
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9590,14 +8810,12 @@ add_executable(bm_error
target_include_directories(bm_error
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9609,7 +8827,7 @@ target_link_libraries(bm_error
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9634,14 +8852,12 @@ add_executable(bm_fullstack_streaming_ping_pong
target_include_directories(bm_fullstack_streaming_ping_pong
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9653,7 +8869,7 @@ target_link_libraries(bm_fullstack_streaming_ping_pong
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9678,14 +8894,12 @@ add_executable(bm_fullstack_streaming_pump
target_include_directories(bm_fullstack_streaming_pump
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9697,7 +8911,7 @@ target_link_libraries(bm_fullstack_streaming_pump
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9722,14 +8936,12 @@ add_executable(bm_fullstack_trickle
target_include_directories(bm_fullstack_trickle
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9741,7 +8953,7 @@ target_link_libraries(bm_fullstack_trickle
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9767,14 +8979,12 @@ add_executable(bm_fullstack_unary_ping_pong
target_include_directories(bm_fullstack_unary_ping_pong
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9786,7 +8996,7 @@ target_link_libraries(bm_fullstack_unary_ping_pong
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9811,14 +9021,12 @@ add_executable(bm_metadata
target_include_directories(bm_metadata
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9830,7 +9038,7 @@ target_link_libraries(bm_metadata
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9855,14 +9063,12 @@ add_executable(bm_pollset
target_include_directories(bm_pollset
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9874,7 +9080,7 @@ target_link_libraries(bm_pollset
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_benchmark
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_test_util_unsecure
grpc_test_util_unsecure
grpc++_unsecure
@@ -9898,14 +9104,12 @@ add_executable(channel_arguments_test
target_include_directories(channel_arguments_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9935,14 +9139,12 @@ add_executable(channel_filter_test
target_include_directories(channel_filter_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9962,6 +9164,42 @@ target_link_libraries(channel_filter_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(chttp2_settings_timeout_test
+ test/core/transport/chttp2/settings_timeout_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(chttp2_settings_timeout_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(chttp2_settings_timeout_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(cli_call_test
test/cpp/util/cli_call_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@@ -9972,14 +9210,12 @@ add_executable(cli_call_test
target_include_directories(cli_call_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10002,6 +9238,51 @@ target_link_libraries(cli_call_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+
+add_executable(client_channel_stress_test
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.h
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.h
+ test/cpp/client/client_channel_stress_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+protobuf_generate_grpc_cpp(
+ src/proto/grpc/lb/v1/load_balancer.proto
+)
+
+target_include_directories(client_channel_stress_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(client_channel_stress_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc++_test_util
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(client_crash_test
@@ -10014,14 +9295,12 @@ add_executable(client_crash_test
target_include_directories(client_crash_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10055,14 +9334,12 @@ add_executable(client_crash_test_server
target_include_directories(client_crash_test_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10095,14 +9372,12 @@ add_executable(client_lb_end2end_test
target_include_directories(client_lb_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10170,14 +9445,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(codegen_test_full
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10244,14 +9517,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(codegen_test_minimal
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10281,14 +9552,12 @@ add_executable(credentials_test
target_include_directories(credentials_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10318,14 +9587,12 @@ add_executable(cxx_byte_buffer_test
target_include_directories(cxx_byte_buffer_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10357,14 +9624,12 @@ add_executable(cxx_slice_test
target_include_directories(cxx_slice_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10396,14 +9661,12 @@ add_executable(cxx_string_ref_test
target_include_directories(cxx_string_ref_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10432,14 +9695,12 @@ add_executable(cxx_time_test
target_include_directories(cxx_time_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10471,14 +9732,12 @@ add_executable(end2end_test
target_include_directories(end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10518,14 +9777,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(error_details_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10544,6 +9801,44 @@ target_link_libraries(error_details_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(exception_test
+ test/cpp/end2end/exception_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(exception_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(exception_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc++_test_util
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(filter_end2end_test
test/cpp/end2end/filter_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@@ -10554,14 +9849,12 @@ add_executable(filter_end2end_test
target_include_directories(filter_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10594,14 +9887,12 @@ add_executable(generic_end2end_test
target_include_directories(generic_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10641,14 +9932,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(golden_file_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10678,14 +9967,12 @@ add_executable(grpc_cli
target_include_directories(grpc_cli
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10715,14 +10002,12 @@ add_executable(grpc_cpp_plugin
target_include_directories(grpc_cpp_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10751,14 +10036,12 @@ add_executable(grpc_csharp_plugin
target_include_directories(grpc_csharp_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10787,14 +10070,12 @@ add_executable(grpc_node_plugin
target_include_directories(grpc_node_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10823,14 +10104,12 @@ add_executable(grpc_objective_c_plugin
target_include_directories(grpc_objective_c_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10859,14 +10138,12 @@ add_executable(grpc_php_plugin
target_include_directories(grpc_php_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10895,14 +10172,12 @@ add_executable(grpc_python_plugin
target_include_directories(grpc_python_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10931,14 +10206,12 @@ add_executable(grpc_ruby_plugin
target_include_directories(grpc_ruby_plugin
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10984,14 +10257,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpc_tool_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11034,14 +10305,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpclb_api_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11079,14 +10348,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpclb_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11126,14 +10393,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(grpclb_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11156,6 +10421,43 @@ target_link_libraries(grpclb_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(h2_ssl_cert_test
+ test/core/end2end/h2_ssl_cert_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(h2_ssl_cert_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(h2_ssl_cert_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(health_service_end2end_test
test/cpp/end2end/health_service_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@@ -11166,14 +10468,12 @@ add_executable(health_service_end2end_test
target_include_directories(health_service_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11206,14 +10506,12 @@ add_executable(http2_client
target_include_directories(http2_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11247,14 +10545,12 @@ add_executable(hybrid_end2end_test
target_include_directories(hybrid_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11276,6 +10572,86 @@ target_link_libraries(hybrid_end2end_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+
+add_executable(inlined_vector_test
+ test/core/gprpp/inlined_vector_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(inlined_vector_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(inlined_vector_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
+
+add_executable(inproc_sync_unary_ping_pong_test
+ test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(inproc_sync_unary_ping_pong_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(inproc_sync_unary_ping_pong_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ qps
+ grpc++_core_stats
+ grpc++_test_util
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ grpc++_test_config
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif()
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(interop_client
@@ -11287,14 +10663,12 @@ add_executable(interop_client
target_include_directories(interop_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11331,14 +10705,12 @@ add_executable(interop_server
target_include_directories(interop_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11377,14 +10749,12 @@ add_executable(interop_test
target_include_directories(interop_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11418,14 +10788,12 @@ add_executable(json_run_localhost
target_include_directories(json_run_localhost
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11451,7 +10819,7 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(memory_test
- test/core/support/memory_test.cc
+ test/core/gprpp/memory_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
@@ -11460,14 +10828,12 @@ add_executable(memory_test
target_include_directories(memory_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11506,14 +10872,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(metrics_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11544,14 +10908,12 @@ add_executable(mock_test
target_include_directories(mock_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11584,14 +10946,12 @@ add_executable(noop-benchmark
target_include_directories(noop-benchmark
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11602,7 +10962,44 @@ target_include_directories(noop-benchmark
target_link_libraries(noop-benchmark
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
- benchmark
+ ${_gRPC_BENCHMARK_LIBRARIES}
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
+add_executable(orphanable_test
+ test/core/gprpp/orphanable_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(orphanable_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(orphanable_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
${_gRPC_GFLAGS_LIBRARIES}
)
@@ -11619,14 +11016,12 @@ add_executable(proto_server_reflection_test
target_include_directories(proto_server_reflection_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11661,14 +11056,12 @@ add_executable(proto_utils_test
target_include_directories(proto_utils_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11698,14 +11091,12 @@ add_executable(qps_interarrival_test
target_include_directories(qps_interarrival_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11741,14 +11132,12 @@ add_executable(qps_json_driver
target_include_directories(qps_json_driver
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11785,14 +11174,12 @@ add_executable(qps_openloop_test
target_include_directories(qps_openloop_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11829,14 +11216,12 @@ add_executable(qps_worker
target_include_directories(qps_worker
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11893,14 +11278,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(reconnect_interop_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11955,14 +11338,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(reconnect_interop_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11988,6 +11369,80 @@ target_link_libraries(reconnect_interop_server
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(ref_counted_ptr_test
+ test/core/gprpp/ref_counted_ptr_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(ref_counted_ptr_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(ref_counted_ptr_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
+add_executable(ref_counted_test
+ test/core/gprpp/ref_counted_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(ref_counted_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(ref_counted_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(secure_auth_context_test
test/cpp/common/secure_auth_context_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@@ -11998,14 +11453,12 @@ add_executable(secure_auth_context_test
target_include_directories(secure_auth_context_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12039,14 +11492,12 @@ add_executable(secure_sync_unary_ping_pong_test
target_include_directories(secure_sync_unary_ping_pong_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12083,14 +11534,12 @@ add_executable(server_builder_plugin_test
target_include_directories(server_builder_plugin_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12137,14 +11586,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(server_builder_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12177,14 +11624,12 @@ add_executable(server_context_test_spouse_test
target_include_directories(server_context_test_spouse_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12217,14 +11662,12 @@ add_executable(server_crash_test
target_include_directories(server_crash_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12258,14 +11701,12 @@ add_executable(server_crash_test_client
target_include_directories(server_crash_test_client
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12288,6 +11729,44 @@ target_link_libraries(server_crash_test_client
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(server_early_return_test
+ test/cpp/end2end/server_early_return_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(server_early_return_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(server_early_return_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc++_test_util
+ grpc_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(server_request_call_test
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.grpc.pb.cc
@@ -12312,14 +11791,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(server_request_call_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12352,14 +11829,12 @@ add_executable(shutdown_test
target_include_directories(shutdown_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12392,14 +11867,12 @@ add_executable(stats_test
target_include_directories(stats_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12431,14 +11904,12 @@ add_executable(status_test
target_include_directories(status_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12471,14 +11942,12 @@ add_executable(streaming_throughput_test
target_include_directories(streaming_throughput_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12543,14 +12012,12 @@ protobuf_generate_grpc_cpp(
target_include_directories(stress_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12584,14 +12051,12 @@ add_executable(thread_manager_test
target_include_directories(thread_manager_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12622,14 +12087,12 @@ add_executable(thread_stress_test
target_include_directories(thread_stress_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12651,6 +12114,44 @@ target_link_libraries(thread_stress_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+
+add_executable(transport_pid_controller_test
+ test/core/transport/pid_controller_test.cc
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+
+target_include_directories(transport_pid_controller_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(transport_pid_controller_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc++_test_util
+ grpc++
+ grpc_test_util
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(writes_per_rpc_test
@@ -12663,14 +12164,12 @@ add_executable(writes_per_rpc_test
target_include_directories(writes_per_rpc_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12702,14 +12201,12 @@ add_executable(public_headers_must_be_c89
target_include_directories(public_headers_must_be_c89
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(public_headers_must_be_c89
@@ -12719,24 +12216,114 @@ target_link_libraries(public_headers_must_be_c89
)
endif (gRPC_BUILD_TESTS)
+
+add_executable(gen_hpack_tables
+ tools/codegen/core/gen_hpack_tables.cc
+)
+
+
+target_include_directories(gen_hpack_tables
+ 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(gen_hpack_tables
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ gpr
+ grpc
+)
+
+
+if (gRPC_INSTALL)
+ install(TARGETS gen_hpack_tables EXPORT gRPCTargets
+ RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+ )
+endif()
+
+
+add_executable(gen_legal_metadata_characters
+ tools/codegen/core/gen_legal_metadata_characters.cc
+)
+
+
+target_include_directories(gen_legal_metadata_characters
+ 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(gen_legal_metadata_characters
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+)
+
+
+if (gRPC_INSTALL)
+ install(TARGETS gen_legal_metadata_characters EXPORT gRPCTargets
+ RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+ )
+endif()
+
+
+add_executable(gen_percent_encoding_tables
+ tools/codegen/core/gen_percent_encoding_tables.cc
+)
+
+
+target_include_directories(gen_percent_encoding_tables
+ 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(gen_percent_encoding_tables
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+)
+
+
+if (gRPC_INSTALL)
+ install(TARGETS gen_percent_encoding_tables EXPORT gRPCTargets
+ RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+ )
+endif()
+
if (gRPC_BUILD_TESTS)
add_executable(badreq_bad_client_test
- test/core/bad_client/tests/badreq.c
+ test/core/bad_client/tests/badreq.cc
)
target_include_directories(badreq_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(badreq_bad_client_test
@@ -12753,21 +12340,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(connection_prefix_bad_client_test
- test/core/bad_client/tests/connection_prefix.c
+ test/core/bad_client/tests/connection_prefix.cc
)
target_include_directories(connection_prefix_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(connection_prefix_bad_client_test
@@ -12784,21 +12369,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(head_of_line_blocking_bad_client_test
- test/core/bad_client/tests/head_of_line_blocking.c
+ test/core/bad_client/tests/head_of_line_blocking.cc
)
target_include_directories(head_of_line_blocking_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(head_of_line_blocking_bad_client_test
@@ -12815,21 +12398,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(headers_bad_client_test
- test/core/bad_client/tests/headers.c
+ test/core/bad_client/tests/headers.cc
)
target_include_directories(headers_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(headers_bad_client_test
@@ -12846,21 +12427,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(initial_settings_frame_bad_client_test
- test/core/bad_client/tests/initial_settings_frame.c
+ test/core/bad_client/tests/initial_settings_frame.cc
)
target_include_directories(initial_settings_frame_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(initial_settings_frame_bad_client_test
@@ -12876,53 +12455,20 @@ target_link_libraries(initial_settings_frame_bad_client_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(large_metadata_bad_client_test
- test/core/bad_client/tests/large_metadata.c
-)
-
-
-target_include_directories(large_metadata_bad_client_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(large_metadata_bad_client_test
- ${_gRPC_SSL_LIBRARIES}
- ${_gRPC_ALLTARGETS_LIBRARIES}
- bad_client_test
- grpc_test_util_unsecure
- grpc_unsecure
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(server_registered_method_bad_client_test
- test/core/bad_client/tests/server_registered_method.c
+ test/core/bad_client/tests/server_registered_method.cc
)
target_include_directories(server_registered_method_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(server_registered_method_bad_client_test
@@ -12939,21 +12485,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(simple_request_bad_client_test
- test/core/bad_client/tests/simple_request.c
+ test/core/bad_client/tests/simple_request.cc
)
target_include_directories(simple_request_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(simple_request_bad_client_test
@@ -12970,21 +12514,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(unknown_frame_bad_client_test
- test/core/bad_client/tests/unknown_frame.c
+ test/core/bad_client/tests/unknown_frame.cc
)
target_include_directories(unknown_frame_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(unknown_frame_bad_client_test
@@ -13001,21 +12543,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(window_overflow_bad_client_test
- test/core/bad_client/tests/window_overflow.c
+ test/core/bad_client/tests/window_overflow.cc
)
target_include_directories(window_overflow_bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(window_overflow_bad_client_test
@@ -13033,21 +12573,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(bad_ssl_cert_server
- test/core/bad_ssl/servers/cert.c
+ test/core/bad_ssl/servers/cert.cc
)
target_include_directories(bad_ssl_cert_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bad_ssl_cert_server
@@ -13065,21 +12603,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(bad_ssl_cert_test
- test/core/bad_ssl/bad_ssl_test.c
+ test/core/bad_ssl/bad_ssl_test.cc
)
target_include_directories(bad_ssl_cert_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(bad_ssl_cert_test
@@ -13095,21 +12631,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_census_test
- test/core/end2end/fixtures/h2_census.c
+ test/core/end2end/fixtures/h2_census.cc
)
target_include_directories(h2_census_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_census_test
@@ -13125,21 +12659,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_compress_test
- test/core/end2end/fixtures/h2_compress.c
+ test/core/end2end/fixtures/h2_compress.cc
)
target_include_directories(h2_compress_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_compress_test
@@ -13155,21 +12687,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_fakesec_test
- test/core/end2end/fixtures/h2_fakesec.c
+ test/core/end2end/fixtures/h2_fakesec.cc
)
target_include_directories(h2_fakesec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_fakesec_test
@@ -13186,21 +12716,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(h2_fd_test
- test/core/end2end/fixtures/h2_fd.c
+ test/core/end2end/fixtures/h2_fd.cc
)
target_include_directories(h2_fd_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_fd_test
@@ -13217,21 +12745,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_full_test
- test/core/end2end/fixtures/h2_full.c
+ test/core/end2end/fixtures/h2_full.cc
)
target_include_directories(h2_full_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full_test
@@ -13248,21 +12774,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(h2_full+pipe_test
- test/core/end2end/fixtures/h2_full+pipe.c
+ test/core/end2end/fixtures/h2_full+pipe.cc
)
target_include_directories(h2_full+pipe_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full+pipe_test
@@ -13279,21 +12803,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_full+trace_test
- test/core/end2end/fixtures/h2_full+trace.c
+ test/core/end2end/fixtures/h2_full+trace.cc
)
target_include_directories(h2_full+trace_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full+trace_test
@@ -13309,21 +12831,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_full+workarounds_test
- test/core/end2end/fixtures/h2_full+workarounds.c
+ test/core/end2end/fixtures/h2_full+workarounds.cc
)
target_include_directories(h2_full+workarounds_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full+workarounds_test
@@ -13339,21 +12859,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_http_proxy_test
- test/core/end2end/fixtures/h2_http_proxy.c
+ test/core/end2end/fixtures/h2_http_proxy.cc
)
target_include_directories(h2_http_proxy_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_http_proxy_test
@@ -13369,21 +12887,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_load_reporting_test
- test/core/end2end/fixtures/h2_load_reporting.c
+ test/core/end2end/fixtures/h2_load_reporting.cc
)
target_include_directories(h2_load_reporting_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_load_reporting_test
@@ -13399,21 +12915,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_oauth2_test
- test/core/end2end/fixtures/h2_oauth2.c
+ test/core/end2end/fixtures/h2_oauth2.cc
)
target_include_directories(h2_oauth2_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_oauth2_test
@@ -13429,21 +12943,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_proxy_test
- test/core/end2end/fixtures/h2_proxy.c
+ test/core/end2end/fixtures/h2_proxy.cc
)
target_include_directories(h2_proxy_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_proxy_test
@@ -13459,21 +12971,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_sockpair_test
- test/core/end2end/fixtures/h2_sockpair.c
+ test/core/end2end/fixtures/h2_sockpair.cc
)
target_include_directories(h2_sockpair_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_sockpair_test
@@ -13489,21 +12999,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_sockpair+trace_test
- test/core/end2end/fixtures/h2_sockpair+trace.c
+ test/core/end2end/fixtures/h2_sockpair+trace.cc
)
target_include_directories(h2_sockpair+trace_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_sockpair+trace_test
@@ -13519,21 +13027,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_sockpair_1byte_test
- test/core/end2end/fixtures/h2_sockpair_1byte.c
+ test/core/end2end/fixtures/h2_sockpair_1byte.cc
)
target_include_directories(h2_sockpair_1byte_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_sockpair_1byte_test
@@ -13549,21 +13055,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_ssl_test
- test/core/end2end/fixtures/h2_ssl.c
+ test/core/end2end/fixtures/h2_ssl.cc
)
target_include_directories(h2_ssl_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_ssl_test
@@ -13578,52 +13082,20 @@ target_link_libraries(h2_ssl_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(h2_ssl_cert_test
- test/core/end2end/fixtures/h2_ssl_cert.c
-)
-
-
-target_include_directories(h2_ssl_cert_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(h2_ssl_cert_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- end2end_tests
- grpc_test_util
- grpc
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(h2_ssl_proxy_test
- test/core/end2end/fixtures/h2_ssl_proxy.c
+ test/core/end2end/fixtures/h2_ssl_proxy.cc
)
target_include_directories(h2_ssl_proxy_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_ssl_proxy_test
@@ -13640,21 +13112,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(h2_uds_test
- test/core/end2end/fixtures/h2_uds.c
+ test/core/end2end/fixtures/h2_uds.cc
)
target_include_directories(h2_uds_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_uds_test
@@ -13671,21 +13141,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(inproc_test
- test/core/end2end/fixtures/inproc.c
+ test/core/end2end/fixtures/inproc.cc
)
target_include_directories(inproc_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(inproc_test
@@ -13701,21 +13169,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_census_nosec_test
- test/core/end2end/fixtures/h2_census.c
+ test/core/end2end/fixtures/h2_census.cc
)
target_include_directories(h2_census_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_census_nosec_test
@@ -13731,21 +13197,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_compress_nosec_test
- test/core/end2end/fixtures/h2_compress.c
+ test/core/end2end/fixtures/h2_compress.cc
)
target_include_directories(h2_compress_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_compress_nosec_test
@@ -13762,21 +13226,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(h2_fd_nosec_test
- test/core/end2end/fixtures/h2_fd.c
+ test/core/end2end/fixtures/h2_fd.cc
)
target_include_directories(h2_fd_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_fd_nosec_test
@@ -13793,21 +13255,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_full_nosec_test
- test/core/end2end/fixtures/h2_full.c
+ test/core/end2end/fixtures/h2_full.cc
)
target_include_directories(h2_full_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full_nosec_test
@@ -13824,21 +13284,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX)
add_executable(h2_full+pipe_nosec_test
- test/core/end2end/fixtures/h2_full+pipe.c
+ test/core/end2end/fixtures/h2_full+pipe.cc
)
target_include_directories(h2_full+pipe_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full+pipe_nosec_test
@@ -13855,21 +13313,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_full+trace_nosec_test
- test/core/end2end/fixtures/h2_full+trace.c
+ test/core/end2end/fixtures/h2_full+trace.cc
)
target_include_directories(h2_full+trace_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full+trace_nosec_test
@@ -13885,21 +13341,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_full+workarounds_nosec_test
- test/core/end2end/fixtures/h2_full+workarounds.c
+ test/core/end2end/fixtures/h2_full+workarounds.cc
)
target_include_directories(h2_full+workarounds_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_full+workarounds_nosec_test
@@ -13915,21 +13369,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_http_proxy_nosec_test
- test/core/end2end/fixtures/h2_http_proxy.c
+ test/core/end2end/fixtures/h2_http_proxy.cc
)
target_include_directories(h2_http_proxy_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_http_proxy_nosec_test
@@ -13945,21 +13397,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_load_reporting_nosec_test
- test/core/end2end/fixtures/h2_load_reporting.c
+ test/core/end2end/fixtures/h2_load_reporting.cc
)
target_include_directories(h2_load_reporting_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_load_reporting_nosec_test
@@ -13975,21 +13425,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_proxy_nosec_test
- test/core/end2end/fixtures/h2_proxy.c
+ test/core/end2end/fixtures/h2_proxy.cc
)
target_include_directories(h2_proxy_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_proxy_nosec_test
@@ -14005,21 +13453,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_sockpair_nosec_test
- test/core/end2end/fixtures/h2_sockpair.c
+ test/core/end2end/fixtures/h2_sockpair.cc
)
target_include_directories(h2_sockpair_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_sockpair_nosec_test
@@ -14035,21 +13481,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_sockpair+trace_nosec_test
- test/core/end2end/fixtures/h2_sockpair+trace.c
+ test/core/end2end/fixtures/h2_sockpair+trace.cc
)
target_include_directories(h2_sockpair+trace_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_sockpair+trace_nosec_test
@@ -14065,21 +13509,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_sockpair_1byte_nosec_test
- test/core/end2end/fixtures/h2_sockpair_1byte.c
+ test/core/end2end/fixtures/h2_sockpair_1byte.cc
)
target_include_directories(h2_sockpair_1byte_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_sockpair_1byte_nosec_test
@@ -14096,21 +13538,19 @@ if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(h2_uds_nosec_test
- test/core/end2end/fixtures/h2_uds.c
+ test/core/end2end/fixtures/h2_uds.cc
)
target_include_directories(h2_uds_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(h2_uds_nosec_test
@@ -14127,21 +13567,19 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(inproc_nosec_test
- test/core/end2end/fixtures/inproc.c
+ test/core/end2end/fixtures/inproc.cc
)
target_include_directories(inproc_nosec_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(inproc_nosec_test
@@ -14167,14 +13605,12 @@ add_executable(resolver_component_test_unsecure
target_include_directories(resolver_component_test_unsecure
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14210,14 +13646,12 @@ add_executable(resolver_component_test
target_include_directories(resolver_component_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14253,14 +13687,12 @@ add_executable(resolver_component_tests_runner_invoker_unsecure
target_include_directories(resolver_component_tests_runner_invoker_unsecure
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14296,14 +13728,12 @@ add_executable(resolver_component_tests_runner_invoker
target_include_directories(resolver_component_tests_runner_invoker
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14329,22 +13759,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(api_fuzzer_one_entry
- test/core/end2end/fuzzers/api_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/end2end/fuzzers/api_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(api_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(api_fuzzer_one_entry
@@ -14359,22 +13787,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(client_fuzzer_one_entry
- test/core/end2end/fuzzers/client_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/end2end/fuzzers/client_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(client_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(client_fuzzer_one_entry
@@ -14389,22 +13815,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(hpack_parser_fuzzer_test_one_entry
- test/core/transport/chttp2/hpack_parser_fuzzer_test.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(hpack_parser_fuzzer_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(hpack_parser_fuzzer_test_one_entry
@@ -14419,22 +13843,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(http_request_fuzzer_test_one_entry
- test/core/http/request_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/http/request_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(http_request_fuzzer_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(http_request_fuzzer_test_one_entry
@@ -14449,22 +13871,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(http_response_fuzzer_test_one_entry
- test/core/http/response_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/http/response_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(http_response_fuzzer_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(http_response_fuzzer_test_one_entry
@@ -14479,22 +13899,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(json_fuzzer_test_one_entry
- test/core/json/fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/json/fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(json_fuzzer_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(json_fuzzer_test_one_entry
@@ -14509,22 +13927,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(nanopb_fuzzer_response_test_one_entry
- test/core/nanopb/fuzzer_response.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/nanopb/fuzzer_response.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(nanopb_fuzzer_response_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(nanopb_fuzzer_response_test_one_entry
@@ -14539,22 +13955,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(nanopb_fuzzer_serverlist_test_one_entry
- test/core/nanopb/fuzzer_serverlist.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/nanopb/fuzzer_serverlist.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(nanopb_fuzzer_serverlist_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(nanopb_fuzzer_serverlist_test_one_entry
@@ -14569,22 +13983,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(percent_decode_fuzzer_one_entry
- test/core/slice/percent_decode_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/slice/percent_decode_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(percent_decode_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(percent_decode_fuzzer_one_entry
@@ -14599,22 +14011,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(percent_encode_fuzzer_one_entry
- test/core/slice/percent_encode_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/slice/percent_encode_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(percent_encode_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(percent_encode_fuzzer_one_entry
@@ -14629,22 +14039,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(server_fuzzer_one_entry
- test/core/end2end/fuzzers/server_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/end2end/fuzzers/server_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(server_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(server_fuzzer_one_entry
@@ -14659,22 +14067,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(ssl_server_fuzzer_one_entry
- test/core/security/ssl_server_fuzzer.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/security/ssl_server_fuzzer.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(ssl_server_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(ssl_server_fuzzer_one_entry
@@ -14689,22 +14095,20 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(uri_fuzzer_test_one_entry
- test/core/client_channel/uri_fuzzer_test.c
- test/core/util/one_corpus_entry_fuzzer.c
+ test/core/client_channel/uri_fuzzer_test.cc
+ test/core/util/one_corpus_entry_fuzzer.cc
)
target_include_directories(uri_fuzzer_test_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/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(uri_fuzzer_test_one_entry
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e9c5fe2014..2f90ccf281 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,53 +2,92 @@
We definitely welcome your patches and contributions to gRPC!
-If you are new to github, please start by reading [Pull Request howto](https://help.github.com/articles/about-pull-requests/)
+If you are new to github, please start by reading [Pull Request
+howto](https://help.github.com/articles/about-pull-requests/)
## Legal requirements
In order to protect both you and ourselves, you will need to sign the
-[Contributor License Agreement](https://cla.developers.google.com/clas).
+[Contributor License
+Agreement](https://identity.linuxfoundation.org/projects/cncf).
## Running tests
-Use `tools/run_tests/run_tests.py` script to run the unit tests.
-See [tools/run_tests](tools/run_tests) for how to run tests for a given language.
+Use `tools/run_tests/run_tests.py` script to run the unit tests. See
+[tools/run_tests](tools/run_tests) for how to run tests for a given language.
-Prerequisites for building and running tests are listed in [INSTALL.md](INSTALL.md)
-and in `src/YOUR-LANGUAGE` (e.g. `src/csharp`)
+Prerequisites for building and running tests are listed in
+[INSTALL.md](INSTALL.md) and in `src/YOUR-LANGUAGE` (e.g. `src/csharp`)
## Generated project files
-To ease maintenance of language- and platform- specific build systems,
-many projects files are generated using templates and should not be edited
-by hand.
-Run `tools/buildgen/generate_projects.sh` to regenerate.
-See [templates](templates) for details.
+To ease maintenance of language- and platform- specific build systems, many
+projects files are generated using templates and should not be edited by hand.
+Run `tools/buildgen/generate_projects.sh` to regenerate. See
+[templates](templates) for details.
-As a rule of thumb, if you see the "sanity tests" failing you've most likely edited generated files or you didn't regenerate the projects properly (or your code formatting doesn't match our code style).
+As a rule of thumb, if you see the "sanity tests" failing you've most likely
+edited generated files or you didn't regenerate the projects properly (or your
+code formatting doesn't match our code style).
## Guidelines for Pull Requests
How to get your contributions merged smoothly and quickly.
-- Create **small PRs** that are narrowly focused on **addressing a single concern**. We often times receive PRs that are trying to fix several things at a time, but only one fix is considered acceptable, nothing gets merged and both author's & review's time is wasted. Create more PRs to address different concerns and everyone will be happy.
+- Create **small PRs** that are narrowly focused on **addressing a single
+ concern**. We often times receive PRs that are trying to fix several things
+ at a time, but only one fix is considered acceptable, nothing gets merged and
+ both author's & review's time is wasted. Create more PRs to address different
+ concerns and everyone will be happy.
-- For speculative changes, consider opening an issue and discussing it first. If you are suggesting a behavioral or API change, consider starting with a [gRFC proposal](https://github.com/grpc/proposal).
+- For speculative changes, consider opening an issue and discussing it first.
+ If you are suggesting a behavioral or API change, consider starting with a
+ [gRFC proposal](https://github.com/grpc/proposal).
-- Provide a good **PR description** as a record of **what** change is being made and **why** it was made. Link to a github issue if it exists.
+- Provide a good **PR description** as a record of **what** change is being made
+ and **why** it was made. Link to a GitHub issue if it exists.
-- Don't fix code style and formatting unless you are already changing that line to address an issue. PRs with irrelevant changes won't be merged. If you do want to fix formatting or style, do that in a separate PR.
+- Don't fix code style and formatting unless you are already changing that line
+ to address an issue. PRs with irrelevant changes won't be merged. If you do
+ want to fix formatting or style, do that in a separate PR.
-- Unless your PR is trivial, you should expect there will be reviewer comments that you'll need to address before merging. We expect you to be reasonably responsive to those comments, otherwise the PR will be closed after 2-3 weeks of inactivity.
+- Unless your PR is trivial, you should expect there will be reviewer comments
+ that you'll need to address before merging. We expect you to be reasonably
+ responsive to those comments, otherwise the PR will be closed after 2-3 weeks
+ of inactivity.
+
+- If you have non-trivial contributions, please consider adding an entry to [the
+ AUTHORS file](https://github.com/grpc/grpc/blob/master/AUTHORS) listing the
+ copyright holder for the contribution (yourself, if you are signing the
+ individual CLA, or your company, for corporate CLAs) in the same PR as your
+ contribution. This needs to be done only once, for each company, or
+ individual.
-- Maintain **clean commit history** and use **meaningful commit messages**. PRs with messy commit history are difficult to review and won't be merged. Use `rebase -i upstream/master` to curate your commit history and/or to bring in latest changes from master (but avoid rebasing in the middle of a code review).
+- Maintain **clean commit history** and use **meaningful commit messages**.
+ PRs with messy commit history are difficult to review and won't be merged.
+ Use `rebase -i upstream/master` to curate your commit history and/or to
+ bring in latest changes from master (but avoid rebasing in the middle of
+ a code review).
-- Keep your PR up to date with upstream/master (if there are merge conflicts, we can't really merge your change).
+- Keep your PR up to date with upstream/master (if there are merge conflicts,
+ we can't really merge your change).
-- if you are regenerating the projects using `tools/buildgen/generate_projects.sh`, make changes to generated files a separate commit with commit message `regenerate projects`. Mixing changes to generated and hand-written files make your PR difficult to review.
+- If you are regenerating the projects using
+ `tools/buildgen/generate_projects.sh`, make changes to generated files a
+ separate commit with commit message `regenerate projects`. Mixing changes
+ to generated and hand-written files make your PR difficult to review.
+ Note that running this script requires the installation of Python packages
+ `pyyaml` and `mako` (typically installed using `pip`) as well as a recent
+ version of [`go`](https://golang.org/doc/install#install).
-- **All tests need to be passing** before your change can be merged. We recommend you **run tests locally** before creating your PR to catch breakages early on (see [tools/run_tests](tools/run_tests). Ultimately, the green signal will be provided by our testing infrastructure. The reviewer will help you if there are test failures that seem not related to the change you are making.
+- **All tests need to be passing** before your change can be merged.
+ We recommend you **run tests locally** before creating your PR to catch
+ breakages early on (see [tools/run_tests](tools/run_tests). Ultimately, the
+ green signal will be provided by our testing infrastructure. The reviewer
+ will help you if there are test failures that seem not related to the change
+ you are making.
-- Exceptions to the rules can be made if there's a compelling reason for doing so.
+- Exceptions to the rules can be made if there's a compelling reason for doing
+ so.
diff --git a/INSTALL.md b/INSTALL.md
index ea613f321d..430fd71989 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -94,28 +94,49 @@ on experience with the tools involved.
### Building using CMake (RECOMMENDED)
Builds gRPC C and C++ with boringssl.
+- Install Visual Studio 2015 or 2017 (Visual C++ compiler will be used).
+- Install [Git](https://git-scm.com/).
- Install [CMake](https://cmake.org/download/).
-- Install [Active State Perl](https://www.activestate.com/activeperl/) (`choco install activeperl`)
-- Install [Ninja](https://ninja-build.org/) (`choco install ninja`)
-- Install [Go](https://golang.org/dl/) (`choco install golang`)
-- Install [yasm](http://yasm.tortall.net/) and add it to `PATH` (`choco install yasm`)
-- Run these commands in the repo root directory
+- Install [Active State Perl](https://www.activestate.com/activeperl/) (`choco install activeperl`) - *required by boringssl*
+- Install [Go](https://golang.org/dl/) (`choco install golang`) - *required by boringssl*
+- Install [yasm](http://yasm.tortall.net/) and add it to `PATH` (`choco install yasm`) - *required by boringssl*
+- (Optional) Install [Ninja](https://ninja-build.org/) (`choco install ninja`)
+
+#### Clone grpc sources including submodules
+Before building, you need to clone the gRPC github repository and download submodules containing source code
+for gRPC's dependencies (that's done by the `submodule` command).
+```
+> @rem You can also do just "git clone --recursive -b THE_BRANCH_YOU_WANT https://github.com/grpc/grpc"
+> powershell git clone --recursive -b ((New-Object System.Net.WebClient).DownloadString(\"https://grpc.io/release\").Trim()) https://github.com/grpc/grpc
+> cd grpc
+> @rem To update submodules at later time, run "git submodule update --init"
+```
-Using Ninja (faster build, supports boringssl's assembly optimizations)
+#### cmake: Using Visual Studio 2015 or 2017 (can only build with OPENSSL_NO_ASM).
+When using the "Visual Studio" generator,
+cmake will generate a solution (`grpc.sln`) that contains a VS project for
+every target defined in `CMakeLists.txt` (+ few extra convenience projects
+added automatically by cmake). After opening the solution with Visual Studio
+you will be able to browse and build the code as usual.
```
+> @rem Run from grpc directory after cloning the repo with --recursive or updating submodules.
> md .build
> cd .build
-> call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64
-> cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release
+> cmake .. -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=Release
> cmake --build .
```
-Using Visual Studio 2015 (can only build with OPENSSL_NO_ASM)
+#### cmake: Using Ninja (faster build, supports boringssl's assembly optimizations).
+Please note that when using Ninja, you'll still need Visual C++ (part of Visual Studio)
+installed to be able to compile the C/C++ sources.
```
+> @rem Run from grpc directory after cloning the repo with --recursive or updating submodules.
> md .build
> cd .build
-> cmake .. -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=Release
+> call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64
+> cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release
> cmake --build .
+> ninja
```
### msys2 (with mingw)
diff --git a/Makefile b/Makefile
index 517ddfd90e..aff6412a64 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,6 @@ CC_opt = $(DEFAULT_CC)
CXX_opt = $(DEFAULT_CXX)
LD_opt = $(DEFAULT_CC)
LDXX_opt = $(DEFAULT_CXX)
-CXXFLAGS_opt = -fno-exceptions
CPPFLAGS_opt = -O2
DEFINES_opt = NDEBUG
@@ -95,7 +94,6 @@ CC_dbg = $(DEFAULT_CC)
CXX_dbg = $(DEFAULT_CXX)
LD_dbg = $(DEFAULT_CC)
LDXX_dbg = $(DEFAULT_CXX)
-CXXFLAGS_dbg = -fno-exceptions
CPPFLAGS_dbg = -O0
DEFINES_dbg = _DEBUG DEBUG
@@ -114,7 +112,7 @@ CC_msan = clang
CXX_msan = clang++
LD_msan = clang++
LDXX_msan = clang++
-CPPFLAGS_msan = -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
+CPPFLAGS_msan = -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
DEFINES_msan = NDEBUG
@@ -144,14 +142,14 @@ LDXX_asan-noleaks = clang++
CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan-noleaks = -fsanitize=address
-VALID_CONFIG_c++-compat = 1
-CC_c++-compat = $(DEFAULT_CC)
-CXX_c++-compat = $(DEFAULT_CXX)
-LD_c++-compat = $(DEFAULT_CC)
-LDXX_c++-compat = $(DEFAULT_CXX)
-CFLAGS_c++-compat = -Wc++-compat
-CPPFLAGS_c++-compat = -O0
-DEFINES_c++-compat = _DEBUG DEBUG
+VALID_CONFIG_noexcept = 1
+CC_noexcept = $(DEFAULT_CC)
+CXX_noexcept = $(DEFAULT_CXX)
+LD_noexcept = $(DEFAULT_CC)
+LDXX_noexcept = $(DEFAULT_CXX)
+CXXFLAGS_noexcept = -fno-exceptions
+CPPFLAGS_noexcept = -O2
+DEFINES_noexcept = NDEBUG
VALID_CONFIG_ubsan = 1
REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
@@ -187,7 +185,7 @@ CXX_gcov = g++
LD_gcov = gcc
LDXX_gcov = g++
CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage -Wno-return-type
-LDFLAGS_gcov = -fprofile-arcs -ftest-coverage -rdynamic
+LDFLAGS_gcov = -fprofile-arcs -ftest-coverage -rdynamic -lstdc++
DEFINES_gcov = _DEBUG DEBUG GPR_GCOV
VALID_CONFIG_memcheck = 1
@@ -207,6 +205,15 @@ LDXX_lto = $(DEFAULT_CXX)
CPPFLAGS_lto = -O2
DEFINES_lto = NDEBUG
+VALID_CONFIG_c++-compat = 1
+CC_c++-compat = $(DEFAULT_CC)
+CXX_c++-compat = $(DEFAULT_CXX)
+LD_c++-compat = $(DEFAULT_CC)
+LDXX_c++-compat = $(DEFAULT_CXX)
+CFLAGS_c++-compat = -Wc++-compat
+CPPFLAGS_c++-compat = -O0
+DEFINES_c++-compat = _DEBUG DEBUG
+
VALID_CONFIG_mutrace = 1
CC_mutrace = $(DEFAULT_CC)
CXX_mutrace = $(DEFAULT_CXX)
@@ -327,7 +334,8 @@ CXXFLAGS += -std=c++11
ifeq ($(SYSTEM),Darwin)
CXXFLAGS += -stdlib=libc++
endif
-CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1
+CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1 -Wno-deprecated-declarations
+COREFLAGS += -fno-rtti -fno-exceptions
LDFLAGS += -g
CPPFLAGS += $(CPPFLAGS_$(CONFIG))
@@ -411,8 +419,8 @@ Q = @
endif
CORE_VERSION = 5.0.0-dev
-CPP_VERSION = 1.7.0-dev
-CSHARP_VERSION = 1.7.0-dev
+CPP_VERSION = 1.10.0-dev
+CSHARP_VERSION = 1.10.0-dev
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@@ -505,7 +513,7 @@ endif
OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
OPENSSL_NPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
-BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI) -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS)
+BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS)
ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
CARES_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/c-ares.c -lcares $(LDFLAGS)
@@ -642,7 +650,6 @@ ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
ZLIB_MERGE_OBJS = $(LIBZ_OBJS)
CPPFLAGS += -Ithird_party/zlib
-LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
else
ifeq ($(HAS_PKG_CONFIG),true)
CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
@@ -673,7 +680,6 @@ CARES_DEP = $(LIBDIR)/$(CONFIG)/libares.a
CARES_MERGE_OBJS = $(LIBARES_OBJS)
CARES_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libares.a
CPPFLAGS := -Ithird_party/cares -Ithird_party/cares/cares $(CPPFLAGS)
-LDFLAGS := -L$(LIBDIR)/$(CONFIG)/c-ares $(LDFLAGS)
else
ifeq ($(HAS_PKG_CONFIG),true)
PC_REQUIRES_GRPC += libcares
@@ -951,14 +957,9 @@ alpn_test: $(BINDIR)/$(CONFIG)/alpn_test
api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer
arena_test: $(BINDIR)/$(CONFIG)/arena_test
bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test
-bdp_estimator_test: $(BINDIR)/$(CONFIG)/bdp_estimator_test
bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test
bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test
byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test
-census_context_test: $(BINDIR)/$(CONFIG)/census_context_test
-census_intrusive_hash_map_test: $(BINDIR)/$(CONFIG)/census_intrusive_hash_map_test
-census_resource_test: $(BINDIR)/$(CONFIG)/census_resource_test
-census_trace_context_test: $(BINDIR)/$(CONFIG)/census_trace_context_test
channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test
check_epollexclusive: $(BINDIR)/$(CONFIG)/check_epollexclusive
chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test
@@ -983,21 +984,16 @@ fling_client: $(BINDIR)/$(CONFIG)/fling_client
fling_server: $(BINDIR)/$(CONFIG)/fling_server
fling_stream_test: $(BINDIR)/$(CONFIG)/fling_stream_test
fling_test: $(BINDIR)/$(CONFIG)/fling_test
-gen_hpack_tables: $(BINDIR)/$(CONFIG)/gen_hpack_tables
-gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters
-gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables
goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test
gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test
-gpr_backoff_test: $(BINDIR)/$(CONFIG)/gpr_backoff_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_histogram_test: $(BINDIR)/$(CONFIG)/gpr_histogram_test
gpr_host_port_test: $(BINDIR)/$(CONFIG)/gpr_host_port_test
gpr_log_test: $(BINDIR)/$(CONFIG)/gpr_log_test
+gpr_manual_constructor_test: $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test
gpr_mpscq_test: $(BINDIR)/$(CONFIG)/gpr_mpscq_test
gpr_spinlock_test: $(BINDIR)/$(CONFIG)/gpr_spinlock_test
-gpr_stack_lockfree_test: $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test
gpr_string_test: $(BINDIR)/$(CONFIG)/gpr_string_test
gpr_sync_test: $(BINDIR)/$(CONFIG)/gpr_sync_test
gpr_thd_test: $(BINDIR)/$(CONFIG)/gpr_thd_test
@@ -1020,9 +1016,12 @@ grpc_json_token_test: $(BINDIR)/$(CONFIG)/grpc_json_token_test
grpc_jwt_verifier_test: $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test
grpc_print_google_default_creds_token: $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token
grpc_security_connector_test: $(BINDIR)/$(CONFIG)/grpc_security_connector_test
+grpc_ssl_credentials_test: $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test
grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
handshake_client: $(BINDIR)/$(CONFIG)/handshake_client
handshake_server: $(BINDIR)/$(CONFIG)/handshake_server
+handshake_server_with_readahead_handshaker: $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker
+histogram_test: $(BINDIR)/$(CONFIG)/histogram_test
hpack_parser_fuzzer_test: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
@@ -1048,7 +1047,6 @@ memory_profile_server: $(BINDIR)/$(CONFIG)/memory_profile_server
memory_profile_test: $(BINDIR)/$(CONFIG)/memory_profile_test
message_compress_test: $(BINDIR)/$(CONFIG)/message_compress_test
minimal_stack_is_minimal_test: $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test
-mlog_test: $(BINDIR)/$(CONFIG)/mlog_test
multiple_server_queues_test: $(BINDIR)/$(CONFIG)/multiple_server_queues_test
murmur_hash_test: $(BINDIR)/$(CONFIG)/murmur_hash_test
nanopb_fuzzer_response_test: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test
@@ -1092,7 +1090,6 @@ timer_heap_test: $(BINDIR)/$(CONFIG)/timer_heap_test
timer_list_test: $(BINDIR)/$(CONFIG)/timer_list_test
transport_connectivity_state_test: $(BINDIR)/$(CONFIG)/transport_connectivity_state_test
transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test
-transport_pid_controller_test: $(BINDIR)/$(CONFIG)/transport_pid_controller_test
transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test
udp_server_test: $(BINDIR)/$(CONFIG)/udp_server_test
uri_fuzzer_test: $(BINDIR)/$(CONFIG)/uri_fuzzer_test
@@ -1101,6 +1098,8 @@ wakeup_fd_cv_test: $(BINDIR)/$(CONFIG)/wakeup_fd_cv_test
alarm_cpp_test: $(BINDIR)/$(CONFIG)/alarm_cpp_test
async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test
auth_property_iterator_test: $(BINDIR)/$(CONFIG)/auth_property_iterator_test
+backoff_test: $(BINDIR)/$(CONFIG)/backoff_test
+bdp_estimator_test: $(BINDIR)/$(CONFIG)/bdp_estimator_test
bm_arena: $(BINDIR)/$(CONFIG)/bm_arena
bm_call_create: $(BINDIR)/$(CONFIG)/bm_call_create
bm_chttp2_hpack: $(BINDIR)/$(CONFIG)/bm_chttp2_hpack
@@ -1117,7 +1116,9 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata
bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset
channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test
channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test
+chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test
cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test
+client_channel_stress_test: $(BINDIR)/$(CONFIG)/client_channel_stress_test
client_crash_test: $(BINDIR)/$(CONFIG)/client_crash_test
client_crash_test_server: $(BINDIR)/$(CONFIG)/client_crash_test_server
client_lb_end2end_test: $(BINDIR)/$(CONFIG)/client_lb_end2end_test
@@ -1130,6 +1131,7 @@ cxx_string_ref_test: $(BINDIR)/$(CONFIG)/cxx_string_ref_test
cxx_time_test: $(BINDIR)/$(CONFIG)/cxx_time_test
end2end_test: $(BINDIR)/$(CONFIG)/end2end_test
error_details_test: $(BINDIR)/$(CONFIG)/error_details_test
+exception_test: $(BINDIR)/$(CONFIG)/exception_test
filter_end2end_test: $(BINDIR)/$(CONFIG)/filter_end2end_test
generic_end2end_test: $(BINDIR)/$(CONFIG)/generic_end2end_test
golden_file_test: $(BINDIR)/$(CONFIG)/golden_file_test
@@ -1145,9 +1147,12 @@ grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test
grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test
grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test
grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test
+h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test
http2_client: $(BINDIR)/$(CONFIG)/http2_client
hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test
+inlined_vector_test: $(BINDIR)/$(CONFIG)/inlined_vector_test
+inproc_sync_unary_ping_pong_test: $(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test
interop_client: $(BINDIR)/$(CONFIG)/interop_client
interop_server: $(BINDIR)/$(CONFIG)/interop_server
interop_test: $(BINDIR)/$(CONFIG)/interop_test
@@ -1156,6 +1161,7 @@ memory_test: $(BINDIR)/$(CONFIG)/memory_test
metrics_client: $(BINDIR)/$(CONFIG)/metrics_client
mock_test: $(BINDIR)/$(CONFIG)/mock_test
noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark
+orphanable_test: $(BINDIR)/$(CONFIG)/orphanable_test
proto_server_reflection_test: $(BINDIR)/$(CONFIG)/proto_server_reflection_test
proto_utils_test: $(BINDIR)/$(CONFIG)/proto_utils_test
qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test
@@ -1164,6 +1170,8 @@ qps_openloop_test: $(BINDIR)/$(CONFIG)/qps_openloop_test
qps_worker: $(BINDIR)/$(CONFIG)/qps_worker
reconnect_interop_client: $(BINDIR)/$(CONFIG)/reconnect_interop_client
reconnect_interop_server: $(BINDIR)/$(CONFIG)/reconnect_interop_server
+ref_counted_ptr_test: $(BINDIR)/$(CONFIG)/ref_counted_ptr_test
+ref_counted_test: $(BINDIR)/$(CONFIG)/ref_counted_test
secure_auth_context_test: $(BINDIR)/$(CONFIG)/secure_auth_context_test
secure_sync_unary_ping_pong_test: $(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test
server_builder_plugin_test: $(BINDIR)/$(CONFIG)/server_builder_plugin_test
@@ -1171,6 +1179,7 @@ server_builder_test: $(BINDIR)/$(CONFIG)/server_builder_test
server_context_test_spouse_test: $(BINDIR)/$(CONFIG)/server_context_test_spouse_test
server_crash_test: $(BINDIR)/$(CONFIG)/server_crash_test
server_crash_test_client: $(BINDIR)/$(CONFIG)/server_crash_test_client
+server_early_return_test: $(BINDIR)/$(CONFIG)/server_early_return_test
server_request_call_test: $(BINDIR)/$(CONFIG)/server_request_call_test
shutdown_test: $(BINDIR)/$(CONFIG)/shutdown_test
stats_test: $(BINDIR)/$(CONFIG)/stats_test
@@ -1179,8 +1188,12 @@ streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test
stress_test: $(BINDIR)/$(CONFIG)/stress_test
thread_manager_test: $(BINDIR)/$(CONFIG)/thread_manager_test
thread_stress_test: $(BINDIR)/$(CONFIG)/thread_stress_test
+transport_pid_controller_test: $(BINDIR)/$(CONFIG)/transport_pid_controller_test
writes_per_rpc_test: $(BINDIR)/$(CONFIG)/writes_per_rpc_test
public_headers_must_be_c89: $(BINDIR)/$(CONFIG)/public_headers_must_be_c89
+gen_hpack_tables: $(BINDIR)/$(CONFIG)/gen_hpack_tables
+gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters
+gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables
boringssl_aes_test: $(BINDIR)/$(CONFIG)/boringssl_aes_test
boringssl_asn1_test: $(BINDIR)/$(CONFIG)/boringssl_asn1_test
boringssl_base64_test: $(BINDIR)/$(CONFIG)/boringssl_base64_test
@@ -1224,7 +1237,6 @@ connection_prefix_bad_client_test: $(BINDIR)/$(CONFIG)/connection_prefix_bad_cli
head_of_line_blocking_bad_client_test: $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test
headers_bad_client_test: $(BINDIR)/$(CONFIG)/headers_bad_client_test
initial_settings_frame_bad_client_test: $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test
-large_metadata_bad_client_test: $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test
server_registered_method_bad_client_test: $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test
simple_request_bad_client_test: $(BINDIR)/$(CONFIG)/simple_request_bad_client_test
unknown_frame_bad_client_test: $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test
@@ -1247,7 +1259,6 @@ h2_sockpair_test: $(BINDIR)/$(CONFIG)/h2_sockpair_test
h2_sockpair+trace_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test
h2_sockpair_1byte_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test
h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test
-h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test
h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test
inproc_test: $(BINDIR)/$(CONFIG)/inproc_test
@@ -1299,10 +1310,10 @@ third_party/protobuf/configure:
$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
$(E) "[MAKE] Building protobuf"
+ $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
$(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g $(PROTOBUF_LDFLAGS_EXTRA)" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g $(PROTOBUF_CPPFLAGS_EXTRA)" ./configure --disable-shared --enable-static $(PROTOBUF_CONFIG_OPTS))
$(Q)$(MAKE) -C third_party/protobuf clean
$(Q)$(MAKE) -C third_party/protobuf
- $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
$(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
$(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
$(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
@@ -1351,14 +1362,9 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/alpn_test \
$(BINDIR)/$(CONFIG)/arena_test \
$(BINDIR)/$(CONFIG)/bad_server_response_test \
- $(BINDIR)/$(CONFIG)/bdp_estimator_test \
$(BINDIR)/$(CONFIG)/bin_decoder_test \
$(BINDIR)/$(CONFIG)/bin_encoder_test \
$(BINDIR)/$(CONFIG)/byte_stream_test \
- $(BINDIR)/$(CONFIG)/census_context_test \
- $(BINDIR)/$(CONFIG)/census_intrusive_hash_map_test \
- $(BINDIR)/$(CONFIG)/census_resource_test \
- $(BINDIR)/$(CONFIG)/census_trace_context_test \
$(BINDIR)/$(CONFIG)/channel_create_test \
$(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \
$(BINDIR)/$(CONFIG)/chttp2_stream_map_test \
@@ -1383,16 +1389,14 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/fling_test \
$(BINDIR)/$(CONFIG)/goaway_server_test \
$(BINDIR)/$(CONFIG)/gpr_avl_test \
- $(BINDIR)/$(CONFIG)/gpr_backoff_test \
$(BINDIR)/$(CONFIG)/gpr_cmdline_test \
$(BINDIR)/$(CONFIG)/gpr_cpu_test \
$(BINDIR)/$(CONFIG)/gpr_env_test \
- $(BINDIR)/$(CONFIG)/gpr_histogram_test \
$(BINDIR)/$(CONFIG)/gpr_host_port_test \
$(BINDIR)/$(CONFIG)/gpr_log_test \
+ $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test \
$(BINDIR)/$(CONFIG)/gpr_mpscq_test \
$(BINDIR)/$(CONFIG)/gpr_spinlock_test \
- $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test \
$(BINDIR)/$(CONFIG)/gpr_string_test \
$(BINDIR)/$(CONFIG)/gpr_sync_test \
$(BINDIR)/$(CONFIG)/gpr_thd_test \
@@ -1413,8 +1417,11 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/grpc_json_token_test \
$(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test \
$(BINDIR)/$(CONFIG)/grpc_security_connector_test \
+ $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test \
$(BINDIR)/$(CONFIG)/handshake_client \
$(BINDIR)/$(CONFIG)/handshake_server \
+ $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker \
+ $(BINDIR)/$(CONFIG)/histogram_test \
$(BINDIR)/$(CONFIG)/hpack_parser_test \
$(BINDIR)/$(CONFIG)/hpack_table_test \
$(BINDIR)/$(CONFIG)/http_parser_test \
@@ -1435,7 +1442,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/memory_profile_test \
$(BINDIR)/$(CONFIG)/message_compress_test \
$(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test \
- $(BINDIR)/$(CONFIG)/mlog_test \
$(BINDIR)/$(CONFIG)/multiple_server_queues_test \
$(BINDIR)/$(CONFIG)/murmur_hash_test \
$(BINDIR)/$(CONFIG)/no_server_test \
@@ -1473,7 +1479,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/timer_list_test \
$(BINDIR)/$(CONFIG)/transport_connectivity_state_test \
$(BINDIR)/$(CONFIG)/transport_metadata_test \
- $(BINDIR)/$(CONFIG)/transport_pid_controller_test \
$(BINDIR)/$(CONFIG)/transport_security_test \
$(BINDIR)/$(CONFIG)/udp_server_test \
$(BINDIR)/$(CONFIG)/uri_parser_test \
@@ -1484,7 +1489,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test \
$(BINDIR)/$(CONFIG)/headers_bad_client_test \
$(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \
- $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test \
$(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test \
$(BINDIR)/$(CONFIG)/simple_request_bad_client_test \
$(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \
@@ -1507,7 +1511,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_sockpair+trace_test \
$(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test \
$(BINDIR)/$(CONFIG)/h2_ssl_test \
- $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \
$(BINDIR)/$(CONFIG)/h2_uds_test \
$(BINDIR)/$(CONFIG)/inproc_test \
@@ -1546,6 +1549,8 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/alarm_cpp_test \
$(BINDIR)/$(CONFIG)/async_end2end_test \
$(BINDIR)/$(CONFIG)/auth_property_iterator_test \
+ $(BINDIR)/$(CONFIG)/backoff_test \
+ $(BINDIR)/$(CONFIG)/bdp_estimator_test \
$(BINDIR)/$(CONFIG)/bm_arena \
$(BINDIR)/$(CONFIG)/bm_call_create \
$(BINDIR)/$(CONFIG)/bm_chttp2_hpack \
@@ -1562,7 +1567,9 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/bm_pollset \
$(BINDIR)/$(CONFIG)/channel_arguments_test \
$(BINDIR)/$(CONFIG)/channel_filter_test \
+ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \
$(BINDIR)/$(CONFIG)/cli_call_test \
+ $(BINDIR)/$(CONFIG)/client_channel_stress_test \
$(BINDIR)/$(CONFIG)/client_crash_test \
$(BINDIR)/$(CONFIG)/client_crash_test_server \
$(BINDIR)/$(CONFIG)/client_lb_end2end_test \
@@ -1575,6 +1582,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/cxx_time_test \
$(BINDIR)/$(CONFIG)/end2end_test \
$(BINDIR)/$(CONFIG)/error_details_test \
+ $(BINDIR)/$(CONFIG)/exception_test \
$(BINDIR)/$(CONFIG)/filter_end2end_test \
$(BINDIR)/$(CONFIG)/generic_end2end_test \
$(BINDIR)/$(CONFIG)/golden_file_test \
@@ -1583,9 +1591,12 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/grpclb_end2end_test \
$(BINDIR)/$(CONFIG)/grpclb_test \
+ $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/health_service_end2end_test \
$(BINDIR)/$(CONFIG)/http2_client \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
+ $(BINDIR)/$(CONFIG)/inlined_vector_test \
+ $(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/interop_client \
$(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \
@@ -1594,6 +1605,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \
+ $(BINDIR)/$(CONFIG)/orphanable_test \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \
$(BINDIR)/$(CONFIG)/proto_utils_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \
@@ -1602,6 +1614,8 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
+ $(BINDIR)/$(CONFIG)/ref_counted_ptr_test \
+ $(BINDIR)/$(CONFIG)/ref_counted_test \
$(BINDIR)/$(CONFIG)/secure_auth_context_test \
$(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/server_builder_plugin_test \
@@ -1609,6 +1623,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/server_context_test_spouse_test \
$(BINDIR)/$(CONFIG)/server_crash_test \
$(BINDIR)/$(CONFIG)/server_crash_test_client \
+ $(BINDIR)/$(CONFIG)/server_early_return_test \
$(BINDIR)/$(CONFIG)/server_request_call_test \
$(BINDIR)/$(CONFIG)/shutdown_test \
$(BINDIR)/$(CONFIG)/stats_test \
@@ -1617,6 +1632,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/stress_test \
$(BINDIR)/$(CONFIG)/thread_manager_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \
+ $(BINDIR)/$(CONFIG)/transport_pid_controller_test \
$(BINDIR)/$(CONFIG)/writes_per_rpc_test \
$(BINDIR)/$(CONFIG)/boringssl_aes_test \
$(BINDIR)/$(CONFIG)/boringssl_asn1_test \
@@ -1666,6 +1682,8 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/alarm_cpp_test \
$(BINDIR)/$(CONFIG)/async_end2end_test \
$(BINDIR)/$(CONFIG)/auth_property_iterator_test \
+ $(BINDIR)/$(CONFIG)/backoff_test \
+ $(BINDIR)/$(CONFIG)/bdp_estimator_test \
$(BINDIR)/$(CONFIG)/bm_arena \
$(BINDIR)/$(CONFIG)/bm_call_create \
$(BINDIR)/$(CONFIG)/bm_chttp2_hpack \
@@ -1682,7 +1700,9 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/bm_pollset \
$(BINDIR)/$(CONFIG)/channel_arguments_test \
$(BINDIR)/$(CONFIG)/channel_filter_test \
+ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \
$(BINDIR)/$(CONFIG)/cli_call_test \
+ $(BINDIR)/$(CONFIG)/client_channel_stress_test \
$(BINDIR)/$(CONFIG)/client_crash_test \
$(BINDIR)/$(CONFIG)/client_crash_test_server \
$(BINDIR)/$(CONFIG)/client_lb_end2end_test \
@@ -1695,6 +1715,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/cxx_time_test \
$(BINDIR)/$(CONFIG)/end2end_test \
$(BINDIR)/$(CONFIG)/error_details_test \
+ $(BINDIR)/$(CONFIG)/exception_test \
$(BINDIR)/$(CONFIG)/filter_end2end_test \
$(BINDIR)/$(CONFIG)/generic_end2end_test \
$(BINDIR)/$(CONFIG)/golden_file_test \
@@ -1703,9 +1724,12 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/grpclb_end2end_test \
$(BINDIR)/$(CONFIG)/grpclb_test \
+ $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/health_service_end2end_test \
$(BINDIR)/$(CONFIG)/http2_client \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
+ $(BINDIR)/$(CONFIG)/inlined_vector_test \
+ $(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/interop_client \
$(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \
@@ -1714,6 +1738,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \
+ $(BINDIR)/$(CONFIG)/orphanable_test \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \
$(BINDIR)/$(CONFIG)/proto_utils_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \
@@ -1722,6 +1747,8 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
+ $(BINDIR)/$(CONFIG)/ref_counted_ptr_test \
+ $(BINDIR)/$(CONFIG)/ref_counted_test \
$(BINDIR)/$(CONFIG)/secure_auth_context_test \
$(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/server_builder_plugin_test \
@@ -1729,6 +1756,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/server_context_test_spouse_test \
$(BINDIR)/$(CONFIG)/server_crash_test \
$(BINDIR)/$(CONFIG)/server_crash_test_client \
+ $(BINDIR)/$(CONFIG)/server_early_return_test \
$(BINDIR)/$(CONFIG)/server_request_call_test \
$(BINDIR)/$(CONFIG)/shutdown_test \
$(BINDIR)/$(CONFIG)/stats_test \
@@ -1737,6 +1765,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/stress_test \
$(BINDIR)/$(CONFIG)/thread_manager_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \
+ $(BINDIR)/$(CONFIG)/transport_pid_controller_test \
$(BINDIR)/$(CONFIG)/writes_per_rpc_test \
$(BINDIR)/$(CONFIG)/resolver_component_test_unsecure \
$(BINDIR)/$(CONFIG)/resolver_component_test \
@@ -1763,22 +1792,12 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/arena_test || ( echo test arena_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 bdp_estimator_test"
- $(Q) $(BINDIR)/$(CONFIG)/bdp_estimator_test || ( echo test bdp_estimator_test failed ; exit 1 )
$(E) "[RUN] Testing bin_decoder_test"
$(Q) $(BINDIR)/$(CONFIG)/bin_decoder_test || ( echo test bin_decoder_test failed ; exit 1 )
$(E) "[RUN] Testing bin_encoder_test"
$(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 )
$(E) "[RUN] Testing byte_stream_test"
$(Q) $(BINDIR)/$(CONFIG)/byte_stream_test || ( echo test byte_stream_test failed ; exit 1 )
- $(E) "[RUN] Testing census_context_test"
- $(Q) $(BINDIR)/$(CONFIG)/census_context_test || ( echo test census_context_test failed ; exit 1 )
- $(E) "[RUN] Testing census_intrusive_hash_map_test"
- $(Q) $(BINDIR)/$(CONFIG)/census_intrusive_hash_map_test || ( echo test census_intrusive_hash_map_test failed ; exit 1 )
- $(E) "[RUN] Testing census_resource_test"
- $(Q) $(BINDIR)/$(CONFIG)/census_resource_test || ( echo test census_resource_test failed ; exit 1 )
- $(E) "[RUN] Testing census_trace_context_test"
- $(Q) $(BINDIR)/$(CONFIG)/census_trace_context_test || ( echo test census_trace_context_test failed ; exit 1 )
$(E) "[RUN] Testing channel_create_test"
$(Q) $(BINDIR)/$(CONFIG)/channel_create_test || ( echo test channel_create_test failed ; exit 1 )
$(E) "[RUN] Testing chttp2_hpack_encoder_test"
@@ -1823,26 +1842,22 @@ 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_backoff_test"
- $(Q) $(BINDIR)/$(CONFIG)/gpr_backoff_test || ( echo test gpr_backoff_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"
$(Q) $(BINDIR)/$(CONFIG)/gpr_env_test || ( echo test gpr_env_test failed ; exit 1 )
- $(E) "[RUN] Testing gpr_histogram_test"
- $(Q) $(BINDIR)/$(CONFIG)/gpr_histogram_test || ( echo test gpr_histogram_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_host_port_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_host_port_test || ( echo test gpr_host_port_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_log_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_log_test || ( echo test gpr_log_test failed ; exit 1 )
+ $(E) "[RUN] Testing gpr_manual_constructor_test"
+ $(Q) $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test || ( echo test gpr_manual_constructor_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_mpscq_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_mpscq_test || ( echo test gpr_mpscq_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_spinlock_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_spinlock_test || ( echo test gpr_spinlock_test failed ; exit 1 )
- $(E) "[RUN] Testing gpr_stack_lockfree_test"
- $(Q) $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test || ( echo test gpr_stack_lockfree_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_string_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_string_test || ( echo test gpr_string_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_sync_test"
@@ -1881,10 +1896,16 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test || ( echo test grpc_jwt_verifier_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_security_connector_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_security_connector_test || ( echo test grpc_security_connector_test failed ; exit 1 )
+ $(E) "[RUN] Testing grpc_ssl_credentials_test"
+ $(Q) $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test || ( echo test grpc_ssl_credentials_test failed ; exit 1 )
$(E) "[RUN] Testing handshake_client"
$(Q) $(BINDIR)/$(CONFIG)/handshake_client || ( echo test handshake_client failed ; exit 1 )
$(E) "[RUN] Testing handshake_server"
$(Q) $(BINDIR)/$(CONFIG)/handshake_server || ( echo test handshake_server failed ; exit 1 )
+ $(E) "[RUN] Testing handshake_server_with_readahead_handshaker"
+ $(Q) $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker || ( echo test handshake_server_with_readahead_handshaker failed ; exit 1 )
+ $(E) "[RUN] Testing histogram_test"
+ $(Q) $(BINDIR)/$(CONFIG)/histogram_test || ( echo test histogram_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/hpack_parser_test || ( echo test hpack_parser_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_table_test"
@@ -1991,8 +2012,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/transport_connectivity_state_test || ( echo test transport_connectivity_state_test failed ; exit 1 )
$(E) "[RUN] Testing transport_metadata_test"
$(Q) $(BINDIR)/$(CONFIG)/transport_metadata_test || ( echo test transport_metadata_test failed ; exit 1 )
- $(E) "[RUN] Testing transport_pid_controller_test"
- $(Q) $(BINDIR)/$(CONFIG)/transport_pid_controller_test || ( echo test transport_pid_controller_test failed ; exit 1 )
$(E) "[RUN] Testing transport_security_test"
$(Q) $(BINDIR)/$(CONFIG)/transport_security_test || ( echo test transport_security_test failed ; exit 1 )
$(E) "[RUN] Testing udp_server_test"
@@ -2013,8 +2032,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/headers_bad_client_test || ( echo test headers_bad_client_test failed ; exit 1 )
$(E) "[RUN] Testing initial_settings_frame_bad_client_test"
$(Q) $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test || ( echo test initial_settings_frame_bad_client_test failed ; exit 1 )
- $(E) "[RUN] Testing large_metadata_bad_client_test"
- $(Q) $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test || ( echo test large_metadata_bad_client_test failed ; exit 1 )
$(E) "[RUN] Testing server_registered_method_bad_client_test"
$(Q) $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test || ( echo test server_registered_method_bad_client_test failed ; exit 1 )
$(E) "[RUN] Testing simple_request_bad_client_test"
@@ -2028,8 +2045,6 @@ test_c: buildtests_c
flaky_test_c: buildtests_c
- $(E) "[RUN] Testing mlog_test"
- $(Q) $(BINDIR)/$(CONFIG)/mlog_test || ( echo test mlog_test failed ; exit 1 )
test_cxx: buildtests_cxx
@@ -2039,6 +2054,10 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/async_end2end_test || ( echo test async_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing auth_property_iterator_test"
$(Q) $(BINDIR)/$(CONFIG)/auth_property_iterator_test || ( echo test auth_property_iterator_test failed ; exit 1 )
+ $(E) "[RUN] Testing backoff_test"
+ $(Q) $(BINDIR)/$(CONFIG)/backoff_test || ( echo test backoff_test failed ; exit 1 )
+ $(E) "[RUN] Testing bdp_estimator_test"
+ $(Q) $(BINDIR)/$(CONFIG)/bdp_estimator_test || ( echo test bdp_estimator_test failed ; exit 1 )
$(E) "[RUN] Testing bm_arena"
$(Q) $(BINDIR)/$(CONFIG)/bm_arena || ( echo test bm_arena failed ; exit 1 )
$(E) "[RUN] Testing bm_call_create"
@@ -2071,8 +2090,12 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 )
$(E) "[RUN] Testing channel_filter_test"
$(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 )
+ $(E) "[RUN] Testing chttp2_settings_timeout_test"
+ $(Q) $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test || ( echo test chttp2_settings_timeout_test failed ; exit 1 )
$(E) "[RUN] Testing cli_call_test"
$(Q) $(BINDIR)/$(CONFIG)/cli_call_test || ( echo test cli_call_test failed ; exit 1 )
+ $(E) "[RUN] Testing client_channel_stress_test"
+ $(Q) $(BINDIR)/$(CONFIG)/client_channel_stress_test || ( echo test client_channel_stress_test failed ; exit 1 )
$(E) "[RUN] Testing client_crash_test"
$(Q) $(BINDIR)/$(CONFIG)/client_crash_test || ( echo test client_crash_test failed ; exit 1 )
$(E) "[RUN] Testing client_lb_end2end_test"
@@ -2095,6 +2118,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/end2end_test || ( echo test end2end_test failed ; exit 1 )
$(E) "[RUN] Testing error_details_test"
$(Q) $(BINDIR)/$(CONFIG)/error_details_test || ( echo test error_details_test failed ; exit 1 )
+ $(E) "[RUN] Testing exception_test"
+ $(Q) $(BINDIR)/$(CONFIG)/exception_test || ( echo test exception_test failed ; exit 1 )
$(E) "[RUN] Testing filter_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/filter_end2end_test || ( echo test filter_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing generic_end2end_test"
@@ -2109,8 +2134,14 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing grpclb_test"
$(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 )
+ $(E) "[RUN] Testing h2_ssl_cert_test"
+ $(Q) $(BINDIR)/$(CONFIG)/h2_ssl_cert_test || ( echo test h2_ssl_cert_test failed ; exit 1 )
$(E) "[RUN] Testing health_service_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/health_service_end2end_test || ( echo test health_service_end2end_test failed ; exit 1 )
+ $(E) "[RUN] Testing inlined_vector_test"
+ $(Q) $(BINDIR)/$(CONFIG)/inlined_vector_test || ( echo test inlined_vector_test failed ; exit 1 )
+ $(E) "[RUN] Testing inproc_sync_unary_ping_pong_test"
+ $(Q) $(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test || ( echo test inproc_sync_unary_ping_pong_test failed ; exit 1 )
$(E) "[RUN] Testing interop_test"
$(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 )
$(E) "[RUN] Testing memory_test"
@@ -2119,12 +2150,18 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 )
$(E) "[RUN] Testing noop-benchmark"
$(Q) $(BINDIR)/$(CONFIG)/noop-benchmark || ( echo test noop-benchmark failed ; exit 1 )
+ $(E) "[RUN] Testing orphanable_test"
+ $(Q) $(BINDIR)/$(CONFIG)/orphanable_test || ( echo test orphanable_test failed ; exit 1 )
$(E) "[RUN] Testing proto_server_reflection_test"
$(Q) $(BINDIR)/$(CONFIG)/proto_server_reflection_test || ( echo test proto_server_reflection_test failed ; exit 1 )
$(E) "[RUN] Testing proto_utils_test"
$(Q) $(BINDIR)/$(CONFIG)/proto_utils_test || ( echo test proto_utils_test failed ; exit 1 )
$(E) "[RUN] Testing qps_openloop_test"
$(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 )
+ $(E) "[RUN] Testing ref_counted_ptr_test"
+ $(Q) $(BINDIR)/$(CONFIG)/ref_counted_ptr_test || ( echo test ref_counted_ptr_test failed ; exit 1 )
+ $(E) "[RUN] Testing ref_counted_test"
+ $(Q) $(BINDIR)/$(CONFIG)/ref_counted_test || ( echo test ref_counted_test failed ; exit 1 )
$(E) "[RUN] Testing secure_auth_context_test"
$(Q) $(BINDIR)/$(CONFIG)/secure_auth_context_test || ( echo test secure_auth_context_test failed ; exit 1 )
$(E) "[RUN] Testing secure_sync_unary_ping_pong_test"
@@ -2137,6 +2174,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/server_context_test_spouse_test || ( echo test server_context_test_spouse_test failed ; exit 1 )
$(E) "[RUN] Testing server_crash_test"
$(Q) $(BINDIR)/$(CONFIG)/server_crash_test || ( echo test server_crash_test failed ; exit 1 )
+ $(E) "[RUN] Testing server_early_return_test"
+ $(Q) $(BINDIR)/$(CONFIG)/server_early_return_test || ( echo test server_early_return_test failed ; exit 1 )
$(E) "[RUN] Testing server_request_call_test"
$(Q) $(BINDIR)/$(CONFIG)/server_request_call_test || ( echo test server_request_call_test failed ; exit 1 )
$(E) "[RUN] Testing shutdown_test"
@@ -2151,6 +2190,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/thread_manager_test || ( echo test thread_manager_test failed ; exit 1 )
$(E) "[RUN] Testing thread_stress_test"
$(Q) $(BINDIR)/$(CONFIG)/thread_stress_test || ( echo test thread_stress_test failed ; exit 1 )
+ $(E) "[RUN] Testing transport_pid_controller_test"
+ $(Q) $(BINDIR)/$(CONFIG)/transport_pid_controller_test || ( echo test transport_pid_controller_test failed ; exit 1 )
$(E) "[RUN] Testing writes_per_rpc_test"
$(Q) $(BINDIR)/$(CONFIG)/writes_per_rpc_test || ( echo test writes_per_rpc_test failed ; exit 1 )
$(E) "[RUN] Testing resolver_component_tests_runner_invoker_unsecure"
@@ -2172,7 +2213,7 @@ test_python: static_c
tools: tools_c tools_cxx
-tools_c: privatelibs_c $(BINDIR)/$(CONFIG)/check_epollexclusive $(BINDIR)/$(CONFIG)/gen_hpack_tables $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables $(BINDIR)/$(CONFIG)/grpc_create_jwt $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token $(BINDIR)/$(CONFIG)/grpc_verify_jwt
+tools_c: privatelibs_c $(BINDIR)/$(CONFIG)/check_epollexclusive $(BINDIR)/$(CONFIG)/grpc_create_jwt $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token $(BINDIR)/$(CONFIG)/grpc_verify_jwt $(BINDIR)/$(CONFIG)/gen_hpack_tables $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables
tools_cxx: privatelibs_cxx
@@ -2504,12 +2545,12 @@ $(GENDIR)/src/proto/grpc/testing/services.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc: protoc_dep_error
else
-$(GENDIR)/src/proto/grpc/testing/services.pb.cc: src/proto/grpc/testing/services.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc
+$(GENDIR)/src/proto/grpc/testing/services.pb.cc: src/proto/grpc/testing/services.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $<
-$(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc: src/proto/grpc/testing/services.proto $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc
+$(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc: src/proto/grpc/testing/services.proto $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc
$(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
@@ -2575,6 +2616,16 @@ $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
$(Q) mkdir -p `dirname $@`
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
+$(OBJDIR)/$(CONFIG)/src/core/%.o : src/core/%.cc
+ $(E) "[CXX] Compiling $<"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
+
+$(OBJDIR)/$(CONFIG)/test/core/%.o : test/core/%.cc
+ $(E) "[CXX] Compiling $<"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
+
$(OBJDIR)/$(CONFIG)/%.o : %.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
@@ -2771,14 +2822,14 @@ install-plugins: $(PROTOC_PLUGINS)
install-pkg-config_c: pc_c pc_c_unsecure
$(E) "[INSTALL] Installing C pkg-config files"
$(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
$(E) "[INSTALL] Installing C++ pkg-config files"
$(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
install-certs: etc/roots.pem
$(E) "[INSTALL] Installing root certificates"
@@ -2794,52 +2845,50 @@ clean:
LIBGPR_SRC = \
- src/core/lib/profiling/basic_timers.c \
- src/core/lib/profiling/stap_timers.c \
- src/core/lib/support/alloc.c \
- src/core/lib/support/arena.c \
- src/core/lib/support/atm.c \
- src/core/lib/support/avl.c \
- src/core/lib/support/backoff.c \
- src/core/lib/support/cmdline.c \
- src/core/lib/support/cpu_iphone.c \
- src/core/lib/support/cpu_linux.c \
- src/core/lib/support/cpu_posix.c \
- src/core/lib/support/cpu_windows.c \
- src/core/lib/support/env_linux.c \
- src/core/lib/support/env_posix.c \
- src/core/lib/support/env_windows.c \
- src/core/lib/support/histogram.c \
- src/core/lib/support/host_port.c \
- src/core/lib/support/log.c \
- src/core/lib/support/log_android.c \
- src/core/lib/support/log_linux.c \
- src/core/lib/support/log_posix.c \
- src/core/lib/support/log_windows.c \
- src/core/lib/support/mpscq.c \
- src/core/lib/support/murmur_hash.c \
- src/core/lib/support/stack_lockfree.c \
- src/core/lib/support/string.c \
- src/core/lib/support/string_posix.c \
- src/core/lib/support/string_util_windows.c \
- src/core/lib/support/string_windows.c \
- src/core/lib/support/subprocess_posix.c \
- src/core/lib/support/subprocess_windows.c \
- src/core/lib/support/sync.c \
- src/core/lib/support/sync_posix.c \
- src/core/lib/support/sync_windows.c \
- src/core/lib/support/thd.c \
- src/core/lib/support/thd_posix.c \
- src/core/lib/support/thd_windows.c \
- src/core/lib/support/time.c \
- src/core/lib/support/time_posix.c \
- src/core/lib/support/time_precise.c \
- src/core/lib/support/time_windows.c \
- src/core/lib/support/tls_pthread.c \
- src/core/lib/support/tmpfile_msys.c \
- src/core/lib/support/tmpfile_posix.c \
- src/core/lib/support/tmpfile_windows.c \
- src/core/lib/support/wrap_memcpy.c \
+ 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 \
+ src/core/lib/gpr/cpu_posix.cc \
+ src/core/lib/gpr/cpu_windows.cc \
+ src/core/lib/gpr/env_linux.cc \
+ src/core/lib/gpr/env_posix.cc \
+ src/core/lib/gpr/env_windows.cc \
+ src/core/lib/gpr/fork.cc \
+ src/core/lib/gpr/host_port.cc \
+ src/core/lib/gpr/log.cc \
+ src/core/lib/gpr/log_android.cc \
+ src/core/lib/gpr/log_linux.cc \
+ src/core/lib/gpr/log_posix.cc \
+ src/core/lib/gpr/log_windows.cc \
+ src/core/lib/gpr/mpscq.cc \
+ src/core/lib/gpr/murmur_hash.cc \
+ src/core/lib/gpr/string.cc \
+ 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 \
+ src/core/lib/gpr/thd.cc \
+ src/core/lib/gpr/thd_posix.cc \
+ src/core/lib/gpr/thd_windows.cc \
+ src/core/lib/gpr/time.cc \
+ src/core/lib/gpr/time_posix.cc \
+ src/core/lib/gpr/time_precise.cc \
+ src/core/lib/gpr/time_windows.cc \
+ src/core/lib/gpr/tls_pthread.cc \
+ 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/wrap_memcpy.cc \
+ src/core/lib/profiling/basic_timers.cc \
+ src/core/lib/profiling/stap_timers.cc \
PUBLIC_HEADERS_C += \
include/grpc/support/alloc.h \
@@ -2850,7 +2899,6 @@ PUBLIC_HEADERS_C += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -2873,6 +2921,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -2920,7 +2969,7 @@ endif
LIBGPR_TEST_UTIL_SRC = \
- test/core/util/test_config.c \
+ test/core/util/test_config.cc \
PUBLIC_HEADERS_C += \
@@ -2945,274 +2994,265 @@ endif
LIBGRPC_SRC = \
- src/core/lib/surface/init.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ src/core/lib/surface/init.cc \
+ src/core/lib/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
- src/core/lib/http/httpcli_security_connector.c \
- src/core/lib/security/context/security_context.c \
- src/core/lib/security/credentials/composite/composite_credentials.c \
- src/core/lib/security/credentials/credentials.c \
- src/core/lib/security/credentials/credentials_metadata.c \
- src/core/lib/security/credentials/fake/fake_credentials.c \
- src/core/lib/security/credentials/google_default/credentials_generic.c \
- src/core/lib/security/credentials/google_default/google_default_credentials.c \
- src/core/lib/security/credentials/iam/iam_credentials.c \
- src/core/lib/security/credentials/jwt/json_token.c \
- src/core/lib/security/credentials/jwt/jwt_credentials.c \
- src/core/lib/security/credentials/jwt/jwt_verifier.c \
- src/core/lib/security/credentials/oauth2/oauth2_credentials.c \
- src/core/lib/security/credentials/plugin/plugin_credentials.c \
- src/core/lib/security/credentials/ssl/ssl_credentials.c \
- src/core/lib/security/transport/client_auth_filter.c \
- src/core/lib/security/transport/lb_targets_info.c \
- src/core/lib/security/transport/secure_endpoint.c \
- src/core/lib/security/transport/security_connector.c \
- src/core/lib/security/transport/security_handshaker.c \
- src/core/lib/security/transport/server_auth_filter.c \
- src/core/lib/security/transport/tsi_error.c \
- src/core/lib/security/util/json_util.c \
- src/core/lib/surface/init_secure.c \
- src/core/tsi/fake_transport_security.c \
- src/core/tsi/gts_transport_security.c \
- src/core/tsi/ssl_transport_security.c \
- src/core/tsi/transport_security_grpc.c \
- src/core/tsi/transport_security.c \
- src/core/tsi/transport_security_adapter.c \
- src/core/ext/transport/chttp2/server/chttp2_server.c \
- src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/ext/transport/chttp2/client/chttp2_connector.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
- src/core/ext/transport/inproc/inproc_plugin.c \
- src/core/ext/transport/inproc/inproc_transport.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
+ src/core/lib/http/httpcli_security_connector.cc \
+ src/core/lib/security/context/security_context.cc \
+ src/core/lib/security/credentials/composite/composite_credentials.cc \
+ src/core/lib/security/credentials/credentials.cc \
+ src/core/lib/security/credentials/credentials_metadata.cc \
+ src/core/lib/security/credentials/fake/fake_credentials.cc \
+ src/core/lib/security/credentials/google_default/credentials_generic.cc \
+ src/core/lib/security/credentials/google_default/google_default_credentials.cc \
+ src/core/lib/security/credentials/iam/iam_credentials.cc \
+ src/core/lib/security/credentials/jwt/json_token.cc \
+ src/core/lib/security/credentials/jwt/jwt_credentials.cc \
+ src/core/lib/security/credentials/jwt/jwt_verifier.cc \
+ src/core/lib/security/credentials/oauth2/oauth2_credentials.cc \
+ src/core/lib/security/credentials/plugin/plugin_credentials.cc \
+ src/core/lib/security/credentials/ssl/ssl_credentials.cc \
+ src/core/lib/security/transport/client_auth_filter.cc \
+ src/core/lib/security/transport/lb_targets_info.cc \
+ src/core/lib/security/transport/secure_endpoint.cc \
+ src/core/lib/security/transport/security_connector.cc \
+ src/core/lib/security/transport/security_handshaker.cc \
+ src/core/lib/security/transport/server_auth_filter.cc \
+ src/core/lib/security/transport/tsi_error.cc \
+ src/core/lib/security/util/json_util.cc \
+ src/core/lib/surface/init_secure.cc \
+ src/core/tsi/alts_transport_security.cc \
+ src/core/tsi/fake_transport_security.cc \
+ src/core/tsi/ssl_transport_security.cc \
+ src/core/tsi/transport_security_grpc.cc \
+ src/core/tsi/transport_security.cc \
+ src/core/tsi/transport_security_adapter.cc \
+ src/core/ext/transport/chttp2/server/chttp2_server.cc \
+ src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
+ src/core/ext/transport/inproc/inproc_plugin.cc \
+ src/core/ext/transport/inproc/inproc_transport.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \
- src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c \
- src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c \
- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \
- src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c \
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \
- src/core/ext/census/base_resources.c \
- src/core/ext/census/context.c \
- src/core/ext/census/gen/census.pb.c \
- src/core/ext/census/gen/trace_context.pb.c \
- src/core/ext/census/grpc_context.c \
- src/core/ext/census/grpc_filter.c \
- src/core/ext/census/grpc_plugin.c \
- src/core/ext/census/initialize.c \
- src/core/ext/census/intrusive_hash_map.c \
- src/core/ext/census/mlog.c \
- src/core/ext/census/operation.c \
- src/core/ext/census/placeholders.c \
- src/core/ext/census/resource.c \
- src/core/ext/census/trace_context.c \
- src/core/ext/census/tracing.c \
- src/core/ext/filters/max_age/max_age_filter.c \
- src/core/ext/filters/message_size/message_size_filter.c \
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c \
- src/core/ext/filters/workarounds/workaround_utils.c \
- src/core/plugin_registry/grpc_plugin_registry.c \
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
+ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \
+ src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc \
+ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
+ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
+ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc \
+ src/core/ext/census/grpc_context.cc \
+ src/core/ext/filters/max_age/max_age_filter.cc \
+ src/core/ext/filters/message_size/message_size_filter.cc \
+ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \
+ src/core/ext/filters/workarounds/workaround_utils.cc \
+ src/core/plugin_registry/grpc_plugin_registry.cc \
PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -3221,6 +3261,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -3233,6 +3274,8 @@ PUBLIC_HEADERS_C += \
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 \
include/grpc/grpc_security_constants.h \
@@ -3296,232 +3339,236 @@ endif
LIBGRPC_CRONET_SRC = \
- src/core/lib/surface/init.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ src/core/lib/surface/init.cc \
+ src/core/lib/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/transport/cronet/client/secure/cronet_channel_create.c \
- src/core/ext/transport/cronet/transport/cronet_api_dummy.c \
- src/core/ext/transport/cronet/transport/cronet_transport.c \
- src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/lib/http/httpcli_security_connector.c \
- src/core/lib/security/context/security_context.c \
- src/core/lib/security/credentials/composite/composite_credentials.c \
- src/core/lib/security/credentials/credentials.c \
- src/core/lib/security/credentials/credentials_metadata.c \
- src/core/lib/security/credentials/fake/fake_credentials.c \
- src/core/lib/security/credentials/google_default/credentials_generic.c \
- src/core/lib/security/credentials/google_default/google_default_credentials.c \
- src/core/lib/security/credentials/iam/iam_credentials.c \
- src/core/lib/security/credentials/jwt/json_token.c \
- src/core/lib/security/credentials/jwt/jwt_credentials.c \
- src/core/lib/security/credentials/jwt/jwt_verifier.c \
- src/core/lib/security/credentials/oauth2/oauth2_credentials.c \
- src/core/lib/security/credentials/plugin/plugin_credentials.c \
- src/core/lib/security/credentials/ssl/ssl_credentials.c \
- src/core/lib/security/transport/client_auth_filter.c \
- src/core/lib/security/transport/lb_targets_info.c \
- src/core/lib/security/transport/secure_endpoint.c \
- src/core/lib/security/transport/security_connector.c \
- src/core/lib/security/transport/security_handshaker.c \
- src/core/lib/security/transport/server_auth_filter.c \
- src/core/lib/security/transport/tsi_error.c \
- src/core/lib/security/util/json_util.c \
- src/core/lib/surface/init_secure.c \
- src/core/tsi/fake_transport_security.c \
- src/core/tsi/gts_transport_security.c \
- src/core/tsi/ssl_transport_security.c \
- src/core/tsi/transport_security_grpc.c \
- src/core/tsi/transport_security.c \
- src/core/tsi/transport_security_adapter.c \
- src/core/ext/transport/chttp2/client/chttp2_connector.c \
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c \
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \
- src/core/plugin_registry/grpc_cronet_plugin_registry.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc \
+ src/core/ext/transport/cronet/transport/cronet_api_dummy.cc \
+ src/core/ext/transport/cronet/transport/cronet_transport.cc \
+ src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/lib/http/httpcli_security_connector.cc \
+ src/core/lib/security/context/security_context.cc \
+ src/core/lib/security/credentials/composite/composite_credentials.cc \
+ src/core/lib/security/credentials/credentials.cc \
+ src/core/lib/security/credentials/credentials_metadata.cc \
+ src/core/lib/security/credentials/fake/fake_credentials.cc \
+ src/core/lib/security/credentials/google_default/credentials_generic.cc \
+ src/core/lib/security/credentials/google_default/google_default_credentials.cc \
+ src/core/lib/security/credentials/iam/iam_credentials.cc \
+ src/core/lib/security/credentials/jwt/json_token.cc \
+ src/core/lib/security/credentials/jwt/jwt_credentials.cc \
+ src/core/lib/security/credentials/jwt/jwt_verifier.cc \
+ src/core/lib/security/credentials/oauth2/oauth2_credentials.cc \
+ src/core/lib/security/credentials/plugin/plugin_credentials.cc \
+ src/core/lib/security/credentials/ssl/ssl_credentials.cc \
+ src/core/lib/security/transport/client_auth_filter.cc \
+ src/core/lib/security/transport/lb_targets_info.cc \
+ src/core/lib/security/transport/secure_endpoint.cc \
+ src/core/lib/security/transport/security_connector.cc \
+ src/core/lib/security/transport/security_handshaker.cc \
+ src/core/lib/security/transport/server_auth_filter.cc \
+ src/core/lib/security/transport/tsi_error.cc \
+ src/core/lib/security/util/json_util.cc \
+ src/core/lib/surface/init_secure.cc \
+ src/core/tsi/alts_transport_security.cc \
+ src/core/tsi/fake_transport_security.cc \
+ src/core/tsi/ssl_transport_security.cc \
+ src/core/tsi/transport_security_grpc.cc \
+ src/core/tsi/transport_security.cc \
+ src/core/tsi/transport_security_adapter.cc \
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc \
+ src/core/plugin_registry/grpc_cronet_plugin_registry.cc \
PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -3530,6 +3577,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -3595,213 +3643,220 @@ endif
LIBGRPC_TEST_UTIL_SRC = \
- test/core/end2end/data/client_certs.c \
- test/core/end2end/data/server1_cert.c \
- test/core/end2end/data/server1_key.c \
- test/core/end2end/data/test_root_cert.c \
- test/core/security/oauth2_utils.c \
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \
- test/core/end2end/cq_verifier.c \
- test/core/end2end/fixtures/http_proxy_fixture.c \
- test/core/end2end/fixtures/proxy.c \
- test/core/iomgr/endpoint_tests.c \
- test/core/util/debugger_macros.c \
- test/core/util/grpc_profiler.c \
- test/core/util/memory_counters.c \
- test/core/util/mock_endpoint.c \
- test/core/util/parse_hexstring.c \
- test/core/util/passthru_endpoint.c \
- test/core/util/port.c \
- test/core/util/port_server_client.c \
- test/core/util/slice_splitter.c \
- test/core/util/trickle_endpoint.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ test/core/end2end/data/client_certs.cc \
+ test/core/end2end/data/server1_cert.cc \
+ test/core/end2end/data/server1_key.cc \
+ test/core/end2end/data/test_root_cert.cc \
+ test/core/security/oauth2_utils.cc \
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
+ test/core/end2end/cq_verifier.cc \
+ test/core/end2end/fixtures/http_proxy_fixture.cc \
+ test/core/end2end/fixtures/proxy.cc \
+ test/core/iomgr/endpoint_tests.cc \
+ test/core/util/debugger_macros.cc \
+ test/core/util/grpc_profiler.cc \
+ test/core/util/histogram.cc \
+ test/core/util/memory_counters.cc \
+ test/core/util/mock_endpoint.cc \
+ test/core/util/parse_hexstring.cc \
+ test/core/util/passthru_endpoint.cc \
+ test/core/util/port.cc \
+ test/core/util/port_isolated_runtime_environment.cc \
+ test/core/util/port_server_client.cc \
+ test/core/util/slice_splitter.cc \
+ test/core/util/tracer_util.cc \
+ test/core/util/trickle_endpoint.cc \
+ src/core/lib/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -3810,6 +3865,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -3854,208 +3910,215 @@ endif
LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \
- test/core/end2end/cq_verifier.c \
- test/core/end2end/fixtures/http_proxy_fixture.c \
- test/core/end2end/fixtures/proxy.c \
- test/core/iomgr/endpoint_tests.c \
- test/core/util/debugger_macros.c \
- test/core/util/grpc_profiler.c \
- test/core/util/memory_counters.c \
- test/core/util/mock_endpoint.c \
- test/core/util/parse_hexstring.c \
- test/core/util/passthru_endpoint.c \
- test/core/util/port.c \
- test/core/util/port_server_client.c \
- test/core/util/slice_splitter.c \
- test/core/util/trickle_endpoint.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
+ test/core/end2end/cq_verifier.cc \
+ test/core/end2end/fixtures/http_proxy_fixture.cc \
+ test/core/end2end/fixtures/proxy.cc \
+ test/core/iomgr/endpoint_tests.cc \
+ test/core/util/debugger_macros.cc \
+ test/core/util/grpc_profiler.cc \
+ test/core/util/histogram.cc \
+ test/core/util/memory_counters.cc \
+ test/core/util/mock_endpoint.cc \
+ test/core/util/parse_hexstring.cc \
+ test/core/util/passthru_endpoint.cc \
+ test/core/util/port.cc \
+ test/core/util/port_isolated_runtime_environment.cc \
+ test/core/util/port_server_client.cc \
+ test/core/util/slice_splitter.cc \
+ test/core/util/tracer_util.cc \
+ test/core/util/trickle_endpoint.cc \
+ src/core/lib/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -4064,6 +4127,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -4094,243 +4158,234 @@ endif
LIBGRPC_UNSECURE_SRC = \
- src/core/lib/surface/init.c \
- src/core/lib/surface/init_unsecure.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ src/core/lib/surface/init.cc \
+ src/core/lib/surface/init_unsecure.cc \
+ src/core/lib/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
- src/core/ext/transport/chttp2/server/chttp2_server.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
- src/core/ext/transport/chttp2/client/chttp2_connector.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/ext/transport/inproc/inproc_plugin.c \
- src/core/ext/transport/inproc/inproc_transport.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c \
- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \
- src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c \
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
+ src/core/ext/transport/chttp2/server/chttp2_server.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/ext/transport/inproc/inproc_plugin.cc \
+ src/core/ext/transport/inproc/inproc_transport.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
+ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
+ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
- src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c \
- src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c \
- src/core/ext/census/base_resources.c \
- src/core/ext/census/context.c \
- src/core/ext/census/gen/census.pb.c \
- src/core/ext/census/gen/trace_context.pb.c \
- src/core/ext/census/grpc_context.c \
- src/core/ext/census/grpc_filter.c \
- src/core/ext/census/grpc_plugin.c \
- src/core/ext/census/initialize.c \
- src/core/ext/census/intrusive_hash_map.c \
- src/core/ext/census/mlog.c \
- src/core/ext/census/operation.c \
- src/core/ext/census/placeholders.c \
- src/core/ext/census/resource.c \
- src/core/ext/census/trace_context.c \
- src/core/ext/census/tracing.c \
- src/core/ext/filters/max_age/max_age_filter.c \
- src/core/ext/filters/message_size/message_size_filter.c \
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c \
- src/core/ext/filters/workarounds/workaround_utils.c \
- src/core/plugin_registry/grpc_unsecure_plugin_registry.c \
+ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \
+ src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc \
+ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \
+ src/core/ext/census/grpc_context.cc \
+ src/core/ext/filters/max_age/max_age_filter.cc \
+ src/core/ext/filters/message_size/message_size_filter.cc \
+ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \
+ src/core/ext/filters/workarounds/workaround_utils.cc \
+ src/core/plugin_registry/grpc_unsecure_plugin_registry.cc \
PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -4339,6 +4394,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -4350,6 +4406,8 @@ PUBLIC_HEADERS_C += \
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 \
include/grpc/grpc_security_constants.h \
@@ -4398,7 +4456,7 @@ endif
LIBRECONNECT_SERVER_SRC = \
- test/core/util/reconnect_server.c \
+ test/core/util/reconnect_server.cc \
PUBLIC_HEADERS_C += \
@@ -4437,7 +4495,7 @@ endif
LIBTEST_TCP_SERVER_SRC = \
- test/core/util/test_tcp_server.c \
+ test/core/util/test_tcp_server.cc \
PUBLIC_HEADERS_C += \
@@ -4573,7 +4631,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -4596,6 +4653,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -4607,6 +4665,8 @@ PUBLIC_HEADERS_CXX += \
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 \
include/grpc/grpc_security_constants.h \
@@ -4619,7 +4679,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -4811,207 +4870,198 @@ LIBGRPC++_CRONET_SRC = \
src/cpp/util/string_ref.cc \
src/cpp/util/time_cc.cc \
src/cpp/codegen/codegen_init.cc \
- src/core/ext/transport/chttp2/client/insecure/channel_create.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
- src/core/ext/transport/chttp2/client/chttp2_connector.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
- src/core/ext/transport/chttp2/server/chttp2_server.c \
- src/core/ext/census/base_resources.c \
- src/core/ext/census/context.c \
- src/core/ext/census/gen/census.pb.c \
- src/core/ext/census/gen/trace_context.pb.c \
- src/core/ext/census/grpc_context.c \
- src/core/ext/census/grpc_filter.c \
- src/core/ext/census/grpc_plugin.c \
- src/core/ext/census/initialize.c \
- src/core/ext/census/intrusive_hash_map.c \
- src/core/ext/census/mlog.c \
- src/core/ext/census/operation.c \
- src/core/ext/census/placeholders.c \
- src/core/ext/census/resource.c \
- src/core/ext/census/trace_context.c \
- src/core/ext/census/tracing.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc \
+ src/core/ext/transport/chttp2/server/chttp2_server.cc \
+ src/core/ext/census/grpc_context.cc \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
@@ -5070,7 +5120,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -5093,6 +5142,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -5104,6 +5154,8 @@ PUBLIC_HEADERS_CXX += \
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 \
include/grpc/grpc_security_constants.h \
@@ -5116,7 +5168,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -5509,7 +5560,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -5518,6 +5568,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -5626,7 +5677,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -5635,6 +5685,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -5788,7 +5839,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -5811,6 +5861,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/atm_gcc_atomic.h \
include/grpc/impl/codegen/atm_gcc_sync.h \
include/grpc/impl/codegen/atm_windows.h \
+ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/port_platform.h \
@@ -5822,6 +5873,8 @@ PUBLIC_HEADERS_CXX += \
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 \
include/grpc/grpc_security_constants.h \
@@ -5834,7 +5887,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
- include/grpc/impl/codegen/exec_ctx_fwd.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@@ -6823,7 +6875,7 @@ PUBLIC_HEADERS_C += \
LIBBORINGSSL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_SRC))))
$(LIBBORINGSSL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
$(LIBDIR)/$(CONFIG)/libboringssl.a: $(ZLIB_DEP) $(CARES_DEP) $(LIBBORINGSSL_OBJS)
$(E) "[AR] Creating $@"
@@ -6852,7 +6904,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_TEST_UTIL_SRC))))
$(LIBBORINGSSL_TEST_UTIL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_TEST_UTIL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_TEST_UTIL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -6890,7 +6942,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_AES_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_AES_TEST_LIB_SRC))))
$(LIBBORINGSSL_AES_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_AES_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_AES_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -6928,7 +6980,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_ASN1_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ASN1_TEST_LIB_SRC))))
$(LIBBORINGSSL_ASN1_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_ASN1_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_ASN1_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -6966,7 +7018,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_BASE64_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_BASE64_TEST_LIB_SRC))))
$(LIBBORINGSSL_BASE64_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_BASE64_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_BASE64_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7004,7 +7056,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_BIO_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_BIO_TEST_LIB_SRC))))
$(LIBBORINGSSL_BIO_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_BIO_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_BIO_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7042,7 +7094,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_BN_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_BN_TEST_LIB_SRC))))
$(LIBBORINGSSL_BN_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_BN_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_BN_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7080,7 +7132,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_BYTESTRING_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_BYTESTRING_TEST_LIB_SRC))))
$(LIBBORINGSSL_BYTESTRING_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_BYTESTRING_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_BYTESTRING_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7118,7 +7170,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_AEAD_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_AEAD_TEST_LIB_SRC))))
$(LIBBORINGSSL_AEAD_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_AEAD_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_AEAD_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7156,7 +7208,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_CIPHER_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_CIPHER_TEST_LIB_SRC))))
$(LIBBORINGSSL_CIPHER_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_CIPHER_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_CIPHER_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7194,7 +7246,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_CMAC_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_CMAC_TEST_LIB_SRC))))
$(LIBBORINGSSL_CMAC_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_CMAC_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_CMAC_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7232,7 +7284,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_CONSTANT_TIME_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_CONSTANT_TIME_TEST_LIB_SRC))))
$(LIBBORINGSSL_CONSTANT_TIME_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_CONSTANT_TIME_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_CONSTANT_TIME_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7270,7 +7322,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_ED25519_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ED25519_TEST_LIB_SRC))))
$(LIBBORINGSSL_ED25519_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_ED25519_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_ED25519_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7308,7 +7360,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_SPAKE25519_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_SPAKE25519_TEST_LIB_SRC))))
$(LIBBORINGSSL_SPAKE25519_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_SPAKE25519_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_SPAKE25519_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7346,7 +7398,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_X25519_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_X25519_TEST_LIB_SRC))))
$(LIBBORINGSSL_X25519_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_X25519_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_X25519_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7384,7 +7436,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_DIGEST_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_DIGEST_TEST_LIB_SRC))))
$(LIBBORINGSSL_DIGEST_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_DIGEST_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_DIGEST_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7422,7 +7474,7 @@ PUBLIC_HEADERS_C += \
LIBBORINGSSL_EXAMPLE_MUL_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_EXAMPLE_MUL_LIB_SRC))))
$(LIBBORINGSSL_EXAMPLE_MUL_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_EXAMPLE_MUL_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_EXAMPLE_MUL_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
$(LIBDIR)/$(CONFIG)/libboringssl_example_mul_lib.a: $(ZLIB_DEP) $(CARES_DEP) $(LIBBORINGSSL_EXAMPLE_MUL_LIB_OBJS)
$(E) "[AR] Creating $@"
@@ -7449,7 +7501,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_P256-X86_64_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_P256-X86_64_TEST_LIB_SRC))))
$(LIBBORINGSSL_P256-X86_64_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_P256-X86_64_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_P256-X86_64_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7487,7 +7539,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_ECDH_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ECDH_TEST_LIB_SRC))))
$(LIBBORINGSSL_ECDH_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_ECDH_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_ECDH_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7525,7 +7577,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_ECDSA_SIGN_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ECDSA_SIGN_TEST_LIB_SRC))))
$(LIBBORINGSSL_ECDSA_SIGN_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_ECDSA_SIGN_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_ECDSA_SIGN_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7563,7 +7615,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_ECDSA_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ECDSA_TEST_LIB_SRC))))
$(LIBBORINGSSL_ECDSA_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_ECDSA_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_ECDSA_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7601,7 +7653,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_ECDSA_VERIFY_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ECDSA_VERIFY_TEST_LIB_SRC))))
$(LIBBORINGSSL_ECDSA_VERIFY_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_ECDSA_VERIFY_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_ECDSA_VERIFY_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7639,7 +7691,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_EVP_EXTRA_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_EVP_EXTRA_TEST_LIB_SRC))))
$(LIBBORINGSSL_EVP_EXTRA_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_EVP_EXTRA_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_EVP_EXTRA_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7677,7 +7729,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_EVP_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_EVP_TEST_LIB_SRC))))
$(LIBBORINGSSL_EVP_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_EVP_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_EVP_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7715,7 +7767,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_PBKDF_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_PBKDF_TEST_LIB_SRC))))
$(LIBBORINGSSL_PBKDF_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_PBKDF_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_PBKDF_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7753,7 +7805,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_HKDF_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_HKDF_TEST_LIB_SRC))))
$(LIBBORINGSSL_HKDF_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_HKDF_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_HKDF_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7791,7 +7843,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_HMAC_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_HMAC_TEST_LIB_SRC))))
$(LIBBORINGSSL_HMAC_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_HMAC_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_HMAC_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7829,7 +7881,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_LHASH_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_LHASH_TEST_LIB_SRC))))
$(LIBBORINGSSL_LHASH_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_LHASH_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_LHASH_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7867,7 +7919,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_GCM_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_GCM_TEST_LIB_SRC))))
$(LIBBORINGSSL_GCM_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_GCM_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_GCM_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7905,7 +7957,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_OBJ_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_OBJ_TEST_LIB_SRC))))
$(LIBBORINGSSL_OBJ_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_OBJ_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_OBJ_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7943,7 +7995,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_PKCS12_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_PKCS12_TEST_LIB_SRC))))
$(LIBBORINGSSL_PKCS12_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_PKCS12_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_PKCS12_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -7981,7 +8033,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_PKCS8_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_PKCS8_TEST_LIB_SRC))))
$(LIBBORINGSSL_PKCS8_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_PKCS8_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_PKCS8_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -8019,7 +8071,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_POLY1305_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_POLY1305_TEST_LIB_SRC))))
$(LIBBORINGSSL_POLY1305_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_POLY1305_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_POLY1305_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -8057,7 +8109,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_POOL_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_POOL_TEST_LIB_SRC))))
$(LIBBORINGSSL_POOL_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_POOL_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_POOL_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -8095,7 +8147,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_REFCOUNT_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_REFCOUNT_TEST_LIB_SRC))))
$(LIBBORINGSSL_REFCOUNT_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_REFCOUNT_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_REFCOUNT_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -8133,7 +8185,7 @@ PUBLIC_HEADERS_C += \
LIBBORINGSSL_THREAD_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_THREAD_TEST_LIB_SRC))))
$(LIBBORINGSSL_THREAD_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_THREAD_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_THREAD_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
$(LIBDIR)/$(CONFIG)/libboringssl_thread_test_lib.a: $(ZLIB_DEP) $(CARES_DEP) $(LIBBORINGSSL_THREAD_TEST_LIB_OBJS)
$(E) "[AR] Creating $@"
@@ -8160,7 +8212,7 @@ PUBLIC_HEADERS_C += \
LIBBORINGSSL_PKCS7_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_PKCS7_TEST_LIB_SRC))))
$(LIBBORINGSSL_PKCS7_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_PKCS7_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_PKCS7_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
$(LIBDIR)/$(CONFIG)/libboringssl_pkcs7_test_lib.a: $(ZLIB_DEP) $(CARES_DEP) $(LIBBORINGSSL_PKCS7_TEST_LIB_OBJS)
$(E) "[AR] Creating $@"
@@ -8187,7 +8239,7 @@ PUBLIC_HEADERS_CXX += \
LIBBORINGSSL_X509_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_X509_TEST_LIB_SRC))))
$(LIBBORINGSSL_X509_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_X509_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_X509_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
ifeq ($(NO_PROTOBUF),true)
@@ -8225,7 +8277,7 @@ PUBLIC_HEADERS_C += \
LIBBORINGSSL_TAB_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_TAB_TEST_LIB_SRC))))
$(LIBBORINGSSL_TAB_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_TAB_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_TAB_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
$(LIBDIR)/$(CONFIG)/libboringssl_tab_test_lib.a: $(ZLIB_DEP) $(CARES_DEP) $(LIBBORINGSSL_TAB_TEST_LIB_OBJS)
$(E) "[AR] Creating $@"
@@ -8252,7 +8304,7 @@ PUBLIC_HEADERS_C += \
LIBBORINGSSL_V3NAME_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_V3NAME_TEST_LIB_SRC))))
$(LIBBORINGSSL_V3NAME_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(LIBBORINGSSL_V3NAME_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(LIBBORINGSSL_V3NAME_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
$(LIBDIR)/$(CONFIG)/libboringssl_v3name_test_lib.a: $(ZLIB_DEP) $(CARES_DEP) $(LIBBORINGSSL_V3NAME_TEST_LIB_OBJS)
$(E) "[AR] Creating $@"
@@ -8278,6 +8330,7 @@ LIBBENCHMARK_SRC = \
third_party/benchmark/src/commandlineflags.cc \
third_party/benchmark/src/complexity.cc \
third_party/benchmark/src/console_reporter.cc \
+ third_party/benchmark/src/counter.cc \
third_party/benchmark/src/csv_reporter.cc \
third_party/benchmark/src/json_reporter.cc \
third_party/benchmark/src/reporter.cc \
@@ -8341,7 +8394,7 @@ PUBLIC_HEADERS_C += \
LIBZ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBZ_SRC))))
-$(LIBZ_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden
+$(LIBZ_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden
$(LIBDIR)/$(CONFIG)/libz.a: $(CARES_DEP) $(LIBZ_OBJS)
$(E) "[AR] Creating $@"
@@ -8415,7 +8468,7 @@ PUBLIC_HEADERS_C += \
LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC))))
-$(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
+$(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares -fvisibility=hidden -D_GNU_SOURCE $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) $(if $(subst FreeBSD,,$(SYSTEM)),,-Ithird_party/cares/config_freebsd) $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst OpenBSD,,$(SYSTEM)),,-Ithird_party/cares/config_openbsd) -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32) $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
$(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) $(LIBARES_OBJS)
@@ -8436,7 +8489,7 @@ endif
LIBBAD_CLIENT_TEST_SRC = \
- test/core/bad_client/bad_client.c \
+ test/core/bad_client/bad_client.cc \
PUBLIC_HEADERS_C += \
@@ -8475,7 +8528,7 @@ endif
LIBBAD_SSL_TEST_SERVER_SRC = \
- test/core/bad_ssl/server_common.c \
+ test/core/bad_ssl/server_common.cc \
PUBLIC_HEADERS_C += \
@@ -8514,67 +8567,68 @@ endif
LIBEND2END_TESTS_SRC = \
- test/core/end2end/end2end_tests.c \
- test/core/end2end/end2end_test_utils.c \
- test/core/end2end/tests/authority_not_supported.c \
- test/core/end2end/tests/bad_hostname.c \
- test/core/end2end/tests/bad_ping.c \
- test/core/end2end/tests/binary_metadata.c \
- test/core/end2end/tests/call_creds.c \
- test/core/end2end/tests/cancel_after_accept.c \
- test/core/end2end/tests/cancel_after_client_done.c \
- test/core/end2end/tests/cancel_after_invoke.c \
- test/core/end2end/tests/cancel_after_round_trip.c \
- test/core/end2end/tests/cancel_before_invoke.c \
- test/core/end2end/tests/cancel_in_a_vacuum.c \
- test/core/end2end/tests/cancel_with_status.c \
- test/core/end2end/tests/compressed_payload.c \
- test/core/end2end/tests/connectivity.c \
- test/core/end2end/tests/default_host.c \
- test/core/end2end/tests/disappearing_server.c \
- test/core/end2end/tests/empty_batch.c \
- test/core/end2end/tests/filter_call_init_fails.c \
- test/core/end2end/tests/filter_causes_close.c \
- test/core/end2end/tests/filter_latency.c \
- test/core/end2end/tests/graceful_server_shutdown.c \
- test/core/end2end/tests/high_initial_seqno.c \
- test/core/end2end/tests/hpack_size.c \
- test/core/end2end/tests/idempotent_request.c \
- test/core/end2end/tests/invoke_large_request.c \
- test/core/end2end/tests/keepalive_timeout.c \
- test/core/end2end/tests/large_metadata.c \
- test/core/end2end/tests/load_reporting_hook.c \
- test/core/end2end/tests/max_concurrent_streams.c \
- test/core/end2end/tests/max_connection_age.c \
- test/core/end2end/tests/max_connection_idle.c \
- test/core/end2end/tests/max_message_length.c \
- test/core/end2end/tests/negative_deadline.c \
- test/core/end2end/tests/network_status_change.c \
- test/core/end2end/tests/no_logging.c \
- test/core/end2end/tests/no_op.c \
- test/core/end2end/tests/payload.c \
- test/core/end2end/tests/ping.c \
- test/core/end2end/tests/ping_pong_streaming.c \
- test/core/end2end/tests/proxy_auth.c \
- test/core/end2end/tests/registered_call.c \
- test/core/end2end/tests/request_with_flags.c \
- test/core/end2end/tests/request_with_payload.c \
- test/core/end2end/tests/resource_quota_server.c \
- test/core/end2end/tests/server_finishes_request.c \
- test/core/end2end/tests/shutdown_finishes_calls.c \
- test/core/end2end/tests/shutdown_finishes_tags.c \
- test/core/end2end/tests/simple_cacheable_request.c \
- test/core/end2end/tests/simple_delayed_request.c \
- test/core/end2end/tests/simple_metadata.c \
- test/core/end2end/tests/simple_request.c \
- test/core/end2end/tests/stream_compression_compressed_payload.c \
- test/core/end2end/tests/stream_compression_payload.c \
- test/core/end2end/tests/stream_compression_ping_pong_streaming.c \
- test/core/end2end/tests/streaming_error_response.c \
- test/core/end2end/tests/trailing_metadata.c \
- test/core/end2end/tests/workaround_cronet_compression.c \
- test/core/end2end/tests/write_buffering.c \
- test/core/end2end/tests/write_buffering_at_end.c \
+ test/core/end2end/end2end_tests.cc \
+ test/core/end2end/end2end_test_utils.cc \
+ test/core/end2end/tests/authority_not_supported.cc \
+ test/core/end2end/tests/bad_hostname.cc \
+ test/core/end2end/tests/bad_ping.cc \
+ test/core/end2end/tests/binary_metadata.cc \
+ test/core/end2end/tests/call_creds.cc \
+ test/core/end2end/tests/cancel_after_accept.cc \
+ test/core/end2end/tests/cancel_after_client_done.cc \
+ test/core/end2end/tests/cancel_after_invoke.cc \
+ test/core/end2end/tests/cancel_after_round_trip.cc \
+ test/core/end2end/tests/cancel_before_invoke.cc \
+ test/core/end2end/tests/cancel_in_a_vacuum.cc \
+ test/core/end2end/tests/cancel_with_status.cc \
+ test/core/end2end/tests/compressed_payload.cc \
+ test/core/end2end/tests/connectivity.cc \
+ test/core/end2end/tests/default_host.cc \
+ test/core/end2end/tests/disappearing_server.cc \
+ test/core/end2end/tests/empty_batch.cc \
+ test/core/end2end/tests/filter_call_init_fails.cc \
+ test/core/end2end/tests/filter_causes_close.cc \
+ test/core/end2end/tests/filter_latency.cc \
+ test/core/end2end/tests/filter_status_code.cc \
+ test/core/end2end/tests/graceful_server_shutdown.cc \
+ test/core/end2end/tests/high_initial_seqno.cc \
+ test/core/end2end/tests/hpack_size.cc \
+ test/core/end2end/tests/idempotent_request.cc \
+ test/core/end2end/tests/invoke_large_request.cc \
+ test/core/end2end/tests/keepalive_timeout.cc \
+ test/core/end2end/tests/large_metadata.cc \
+ test/core/end2end/tests/load_reporting_hook.cc \
+ test/core/end2end/tests/max_concurrent_streams.cc \
+ test/core/end2end/tests/max_connection_age.cc \
+ test/core/end2end/tests/max_connection_idle.cc \
+ test/core/end2end/tests/max_message_length.cc \
+ test/core/end2end/tests/negative_deadline.cc \
+ test/core/end2end/tests/network_status_change.cc \
+ test/core/end2end/tests/no_logging.cc \
+ test/core/end2end/tests/no_op.cc \
+ test/core/end2end/tests/payload.cc \
+ test/core/end2end/tests/ping.cc \
+ test/core/end2end/tests/ping_pong_streaming.cc \
+ test/core/end2end/tests/proxy_auth.cc \
+ test/core/end2end/tests/registered_call.cc \
+ test/core/end2end/tests/request_with_flags.cc \
+ test/core/end2end/tests/request_with_payload.cc \
+ test/core/end2end/tests/resource_quota_server.cc \
+ test/core/end2end/tests/server_finishes_request.cc \
+ test/core/end2end/tests/shutdown_finishes_calls.cc \
+ test/core/end2end/tests/shutdown_finishes_tags.cc \
+ test/core/end2end/tests/simple_cacheable_request.cc \
+ test/core/end2end/tests/simple_delayed_request.cc \
+ test/core/end2end/tests/simple_metadata.cc \
+ test/core/end2end/tests/simple_request.cc \
+ test/core/end2end/tests/stream_compression_compressed_payload.cc \
+ test/core/end2end/tests/stream_compression_payload.cc \
+ test/core/end2end/tests/stream_compression_ping_pong_streaming.cc \
+ test/core/end2end/tests/streaming_error_response.cc \
+ test/core/end2end/tests/trailing_metadata.cc \
+ test/core/end2end/tests/workaround_cronet_compression.cc \
+ test/core/end2end/tests/write_buffering.cc \
+ test/core/end2end/tests/write_buffering_at_end.cc \
PUBLIC_HEADERS_C += \
@@ -8613,66 +8667,67 @@ endif
LIBEND2END_NOSEC_TESTS_SRC = \
- test/core/end2end/end2end_nosec_tests.c \
- test/core/end2end/end2end_test_utils.c \
- test/core/end2end/tests/authority_not_supported.c \
- test/core/end2end/tests/bad_hostname.c \
- test/core/end2end/tests/bad_ping.c \
- test/core/end2end/tests/binary_metadata.c \
- test/core/end2end/tests/cancel_after_accept.c \
- test/core/end2end/tests/cancel_after_client_done.c \
- test/core/end2end/tests/cancel_after_invoke.c \
- test/core/end2end/tests/cancel_after_round_trip.c \
- test/core/end2end/tests/cancel_before_invoke.c \
- test/core/end2end/tests/cancel_in_a_vacuum.c \
- test/core/end2end/tests/cancel_with_status.c \
- test/core/end2end/tests/compressed_payload.c \
- test/core/end2end/tests/connectivity.c \
- test/core/end2end/tests/default_host.c \
- test/core/end2end/tests/disappearing_server.c \
- test/core/end2end/tests/empty_batch.c \
- test/core/end2end/tests/filter_call_init_fails.c \
- test/core/end2end/tests/filter_causes_close.c \
- test/core/end2end/tests/filter_latency.c \
- test/core/end2end/tests/graceful_server_shutdown.c \
- test/core/end2end/tests/high_initial_seqno.c \
- test/core/end2end/tests/hpack_size.c \
- test/core/end2end/tests/idempotent_request.c \
- test/core/end2end/tests/invoke_large_request.c \
- test/core/end2end/tests/keepalive_timeout.c \
- test/core/end2end/tests/large_metadata.c \
- test/core/end2end/tests/load_reporting_hook.c \
- test/core/end2end/tests/max_concurrent_streams.c \
- test/core/end2end/tests/max_connection_age.c \
- test/core/end2end/tests/max_connection_idle.c \
- test/core/end2end/tests/max_message_length.c \
- test/core/end2end/tests/negative_deadline.c \
- test/core/end2end/tests/network_status_change.c \
- test/core/end2end/tests/no_logging.c \
- test/core/end2end/tests/no_op.c \
- test/core/end2end/tests/payload.c \
- test/core/end2end/tests/ping.c \
- test/core/end2end/tests/ping_pong_streaming.c \
- test/core/end2end/tests/proxy_auth.c \
- test/core/end2end/tests/registered_call.c \
- test/core/end2end/tests/request_with_flags.c \
- test/core/end2end/tests/request_with_payload.c \
- test/core/end2end/tests/resource_quota_server.c \
- test/core/end2end/tests/server_finishes_request.c \
- test/core/end2end/tests/shutdown_finishes_calls.c \
- test/core/end2end/tests/shutdown_finishes_tags.c \
- test/core/end2end/tests/simple_cacheable_request.c \
- test/core/end2end/tests/simple_delayed_request.c \
- test/core/end2end/tests/simple_metadata.c \
- test/core/end2end/tests/simple_request.c \
- test/core/end2end/tests/stream_compression_compressed_payload.c \
- test/core/end2end/tests/stream_compression_payload.c \
- test/core/end2end/tests/stream_compression_ping_pong_streaming.c \
- test/core/end2end/tests/streaming_error_response.c \
- test/core/end2end/tests/trailing_metadata.c \
- test/core/end2end/tests/workaround_cronet_compression.c \
- test/core/end2end/tests/write_buffering.c \
- test/core/end2end/tests/write_buffering_at_end.c \
+ test/core/end2end/end2end_nosec_tests.cc \
+ test/core/end2end/end2end_test_utils.cc \
+ test/core/end2end/tests/authority_not_supported.cc \
+ test/core/end2end/tests/bad_hostname.cc \
+ test/core/end2end/tests/bad_ping.cc \
+ test/core/end2end/tests/binary_metadata.cc \
+ test/core/end2end/tests/cancel_after_accept.cc \
+ test/core/end2end/tests/cancel_after_client_done.cc \
+ test/core/end2end/tests/cancel_after_invoke.cc \
+ test/core/end2end/tests/cancel_after_round_trip.cc \
+ test/core/end2end/tests/cancel_before_invoke.cc \
+ test/core/end2end/tests/cancel_in_a_vacuum.cc \
+ test/core/end2end/tests/cancel_with_status.cc \
+ test/core/end2end/tests/compressed_payload.cc \
+ test/core/end2end/tests/connectivity.cc \
+ test/core/end2end/tests/default_host.cc \
+ test/core/end2end/tests/disappearing_server.cc \
+ test/core/end2end/tests/empty_batch.cc \
+ test/core/end2end/tests/filter_call_init_fails.cc \
+ test/core/end2end/tests/filter_causes_close.cc \
+ test/core/end2end/tests/filter_latency.cc \
+ test/core/end2end/tests/filter_status_code.cc \
+ test/core/end2end/tests/graceful_server_shutdown.cc \
+ test/core/end2end/tests/high_initial_seqno.cc \
+ test/core/end2end/tests/hpack_size.cc \
+ test/core/end2end/tests/idempotent_request.cc \
+ test/core/end2end/tests/invoke_large_request.cc \
+ test/core/end2end/tests/keepalive_timeout.cc \
+ test/core/end2end/tests/large_metadata.cc \
+ test/core/end2end/tests/load_reporting_hook.cc \
+ test/core/end2end/tests/max_concurrent_streams.cc \
+ test/core/end2end/tests/max_connection_age.cc \
+ test/core/end2end/tests/max_connection_idle.cc \
+ test/core/end2end/tests/max_message_length.cc \
+ test/core/end2end/tests/negative_deadline.cc \
+ test/core/end2end/tests/network_status_change.cc \
+ test/core/end2end/tests/no_logging.cc \
+ test/core/end2end/tests/no_op.cc \
+ test/core/end2end/tests/payload.cc \
+ test/core/end2end/tests/ping.cc \
+ test/core/end2end/tests/ping_pong_streaming.cc \
+ test/core/end2end/tests/proxy_auth.cc \
+ test/core/end2end/tests/registered_call.cc \
+ test/core/end2end/tests/request_with_flags.cc \
+ test/core/end2end/tests/request_with_payload.cc \
+ test/core/end2end/tests/resource_quota_server.cc \
+ test/core/end2end/tests/server_finishes_request.cc \
+ test/core/end2end/tests/shutdown_finishes_calls.cc \
+ test/core/end2end/tests/shutdown_finishes_tags.cc \
+ test/core/end2end/tests/simple_cacheable_request.cc \
+ test/core/end2end/tests/simple_delayed_request.cc \
+ test/core/end2end/tests/simple_metadata.cc \
+ test/core/end2end/tests/simple_request.cc \
+ test/core/end2end/tests/stream_compression_compressed_payload.cc \
+ test/core/end2end/tests/stream_compression_payload.cc \
+ test/core/end2end/tests/stream_compression_ping_pong_streaming.cc \
+ test/core/end2end/tests/streaming_error_response.cc \
+ test/core/end2end/tests/trailing_metadata.cc \
+ test/core/end2end/tests/workaround_cronet_compression.cc \
+ test/core/end2end/tests/write_buffering.cc \
+ test/core/end2end/tests/write_buffering_at_end.cc \
PUBLIC_HEADERS_C += \
@@ -8701,7 +8756,7 @@ endif
ALARM_TEST_SRC = \
- test/core/surface/alarm_test.c \
+ test/core/surface/alarm_test.cc \
ALARM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALARM_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8733,7 +8788,7 @@ endif
ALGORITHM_TEST_SRC = \
- test/core/compression/algorithm_test.c \
+ test/core/compression/algorithm_test.cc \
ALGORITHM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALGORITHM_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8765,7 +8820,7 @@ endif
ALLOC_TEST_SRC = \
- test/core/support/alloc_test.c \
+ test/core/gpr/alloc_test.cc \
ALLOC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALLOC_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8785,7 +8840,7 @@ $(BINDIR)/$(CONFIG)/alloc_test: $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_te
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/alloc_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/alloc_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_alloc_test: $(ALLOC_TEST_OBJS:.o=.dep)
@@ -8797,7 +8852,7 @@ endif
ALPN_TEST_SRC = \
- test/core/transport/chttp2/alpn_test.c \
+ test/core/transport/chttp2/alpn_test.cc \
ALPN_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALPN_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8829,7 +8884,7 @@ endif
API_FUZZER_SRC = \
- test/core/end2end/fuzzers/api_fuzzer.c \
+ test/core/end2end/fuzzers/api_fuzzer.cc \
API_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(API_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8861,7 +8916,7 @@ endif
ARENA_TEST_SRC = \
- test/core/support/arena_test.c \
+ test/core/gpr/arena_test.cc \
ARENA_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ARENA_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8881,7 +8936,7 @@ $(BINDIR)/$(CONFIG)/arena_test: $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_te
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/arena_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/arena_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_arena_test: $(ARENA_TEST_OBJS:.o=.dep)
@@ -8893,7 +8948,7 @@ endif
BAD_SERVER_RESPONSE_TEST_SRC = \
- test/core/end2end/bad_server_response_test.c \
+ test/core/end2end/bad_server_response_test.cc \
BAD_SERVER_RESPONSE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BAD_SERVER_RESPONSE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8924,40 +8979,8 @@ endif
endif
-BDP_ESTIMATOR_TEST_SRC = \
- test/core/transport/bdp_estimator_test.c \
-
-BDP_ESTIMATOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BDP_ESTIMATOR_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/bdp_estimator_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/bdp_estimator_test: $(BDP_ESTIMATOR_TEST_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) $(BDP_ESTIMATOR_TEST_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)/bdp_estimator_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/transport/bdp_estimator_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_bdp_estimator_test: $(BDP_ESTIMATOR_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(BDP_ESTIMATOR_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
BIN_DECODER_TEST_SRC = \
- test/core/transport/chttp2/bin_decoder_test.c \
+ test/core/transport/chttp2/bin_decoder_test.cc \
BIN_DECODER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BIN_DECODER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -8989,7 +9012,7 @@ endif
BIN_ENCODER_TEST_SRC = \
- test/core/transport/chttp2/bin_encoder_test.c \
+ test/core/transport/chttp2/bin_encoder_test.cc \
BIN_ENCODER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BIN_ENCODER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9021,7 +9044,7 @@ endif
BYTE_STREAM_TEST_SRC = \
- test/core/transport/byte_stream_test.c \
+ test/core/transport/byte_stream_test.cc \
BYTE_STREAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BYTE_STREAM_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9052,136 +9075,8 @@ endif
endif
-CENSUS_CONTEXT_TEST_SRC = \
- test/core/census/context_test.c \
-
-CENSUS_CONTEXT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_CONTEXT_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/census_context_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/census_context_test: $(CENSUS_CONTEXT_TEST_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) $(CENSUS_CONTEXT_TEST_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)/census_context_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/census/context_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_census_context_test: $(CENSUS_CONTEXT_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(CENSUS_CONTEXT_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
-CENSUS_INTRUSIVE_HASH_MAP_TEST_SRC = \
- test/core/census/intrusive_hash_map_test.c \
-
-CENSUS_INTRUSIVE_HASH_MAP_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_INTRUSIVE_HASH_MAP_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/census_intrusive_hash_map_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/census_intrusive_hash_map_test: $(CENSUS_INTRUSIVE_HASH_MAP_TEST_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) $(CENSUS_INTRUSIVE_HASH_MAP_TEST_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)/census_intrusive_hash_map_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/census/intrusive_hash_map_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_census_intrusive_hash_map_test: $(CENSUS_INTRUSIVE_HASH_MAP_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(CENSUS_INTRUSIVE_HASH_MAP_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
-CENSUS_RESOURCE_TEST_SRC = \
- test/core/census/resource_test.c \
-
-CENSUS_RESOURCE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_RESOURCE_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/census_resource_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/census_resource_test: $(CENSUS_RESOURCE_TEST_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) $(CENSUS_RESOURCE_TEST_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)/census_resource_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/census/resource_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_census_resource_test: $(CENSUS_RESOURCE_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(CENSUS_RESOURCE_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
-CENSUS_TRACE_CONTEXT_TEST_SRC = \
- test/core/census/trace_context_test.c \
-
-CENSUS_TRACE_CONTEXT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_TRACE_CONTEXT_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/census_trace_context_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/census_trace_context_test: $(CENSUS_TRACE_CONTEXT_TEST_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) $(CENSUS_TRACE_CONTEXT_TEST_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)/census_trace_context_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/census/trace_context_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_census_trace_context_test: $(CENSUS_TRACE_CONTEXT_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(CENSUS_TRACE_CONTEXT_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
CHANNEL_CREATE_TEST_SRC = \
- test/core/surface/channel_create_test.c \
+ test/core/surface/channel_create_test.cc \
CHANNEL_CREATE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_CREATE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9245,7 +9140,7 @@ endif
CHTTP2_HPACK_ENCODER_TEST_SRC = \
- test/core/transport/chttp2/hpack_encoder_test.c \
+ test/core/transport/chttp2/hpack_encoder_test.cc \
CHTTP2_HPACK_ENCODER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHTTP2_HPACK_ENCODER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9277,7 +9172,7 @@ endif
CHTTP2_STREAM_MAP_TEST_SRC = \
- test/core/transport/chttp2/stream_map_test.c \
+ test/core/transport/chttp2/stream_map_test.cc \
CHTTP2_STREAM_MAP_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHTTP2_STREAM_MAP_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9309,7 +9204,7 @@ endif
CHTTP2_VARINT_TEST_SRC = \
- test/core/transport/chttp2/varint_test.c \
+ test/core/transport/chttp2/varint_test.cc \
CHTTP2_VARINT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHTTP2_VARINT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9341,7 +9236,7 @@ endif
CLIENT_FUZZER_SRC = \
- test/core/end2end/fuzzers/client_fuzzer.c \
+ test/core/end2end/fuzzers/client_fuzzer.cc \
CLIENT_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CLIENT_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9373,7 +9268,7 @@ endif
COMBINER_TEST_SRC = \
- test/core/iomgr/combiner_test.c \
+ test/core/iomgr/combiner_test.cc \
COMBINER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(COMBINER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9405,7 +9300,7 @@ endif
COMPRESSION_TEST_SRC = \
- test/core/compression/compression_test.c \
+ test/core/compression/compression_test.cc \
COMPRESSION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(COMPRESSION_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9437,7 +9332,7 @@ endif
CONCURRENT_CONNECTIVITY_TEST_SRC = \
- test/core/surface/concurrent_connectivity_test.c \
+ test/core/surface/concurrent_connectivity_test.cc \
CONCURRENT_CONNECTIVITY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CONCURRENT_CONNECTIVITY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9469,7 +9364,7 @@ endif
CONNECTION_REFUSED_TEST_SRC = \
- test/core/end2end/connection_refused_test.c \
+ test/core/end2end/connection_refused_test.cc \
CONNECTION_REFUSED_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CONNECTION_REFUSED_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9501,7 +9396,7 @@ endif
DNS_RESOLVER_CONNECTIVITY_TEST_SRC = \
- test/core/client_channel/resolvers/dns_resolver_connectivity_test.c \
+ test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc \
DNS_RESOLVER_CONNECTIVITY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DNS_RESOLVER_CONNECTIVITY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9533,7 +9428,7 @@ endif
DNS_RESOLVER_TEST_SRC = \
- test/core/client_channel/resolvers/dns_resolver_test.c \
+ test/core/client_channel/resolvers/dns_resolver_test.cc \
DNS_RESOLVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DNS_RESOLVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9565,7 +9460,7 @@ endif
DUALSTACK_SOCKET_TEST_SRC = \
- test/core/end2end/dualstack_socket_test.c \
+ test/core/end2end/dualstack_socket_test.cc \
DUALSTACK_SOCKET_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DUALSTACK_SOCKET_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9597,7 +9492,7 @@ endif
ENDPOINT_PAIR_TEST_SRC = \
- test/core/iomgr/endpoint_pair_test.c \
+ test/core/iomgr/endpoint_pair_test.cc \
ENDPOINT_PAIR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ENDPOINT_PAIR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9629,7 +9524,7 @@ endif
ERROR_TEST_SRC = \
- test/core/iomgr/error_test.c \
+ test/core/iomgr/error_test.cc \
ERROR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ERROR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9661,7 +9556,7 @@ endif
EV_EPOLLSIG_LINUX_TEST_SRC = \
- test/core/iomgr/ev_epollsig_linux_test.c \
+ test/core/iomgr/ev_epollsig_linux_test.cc \
EV_EPOLLSIG_LINUX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(EV_EPOLLSIG_LINUX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9693,7 +9588,7 @@ endif
FAKE_RESOLVER_TEST_SRC = \
- test/core/client_channel/resolvers/fake_resolver_test.c \
+ test/core/client_channel/resolvers/fake_resolver_test.cc \
FAKE_RESOLVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FAKE_RESOLVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9725,8 +9620,8 @@ endif
FAKE_TRANSPORT_SECURITY_TEST_SRC = \
- test/core/tsi/fake_transport_security_test.c \
- test/core/tsi/transport_security_test_lib.c \
+ test/core/tsi/fake_transport_security_test.cc \
+ test/core/tsi/transport_security_test_lib.cc \
FAKE_TRANSPORT_SECURITY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FAKE_TRANSPORT_SECURITY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9760,7 +9655,7 @@ endif
FD_CONSERVATION_POSIX_TEST_SRC = \
- test/core/iomgr/fd_conservation_posix_test.c \
+ test/core/iomgr/fd_conservation_posix_test.cc \
FD_CONSERVATION_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FD_CONSERVATION_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9792,7 +9687,7 @@ endif
FD_POSIX_TEST_SRC = \
- test/core/iomgr/fd_posix_test.c \
+ test/core/iomgr/fd_posix_test.cc \
FD_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FD_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9824,7 +9719,7 @@ endif
FLING_CLIENT_SRC = \
- test/core/fling/client.c \
+ test/core/fling/client.cc \
FLING_CLIENT_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FLING_CLIENT_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9856,7 +9751,7 @@ endif
FLING_SERVER_SRC = \
- test/core/fling/server.c \
+ test/core/fling/server.cc \
FLING_SERVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FLING_SERVER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9888,7 +9783,7 @@ endif
FLING_STREAM_TEST_SRC = \
- test/core/fling/fling_stream_test.c \
+ test/core/fling/fling_stream_test.cc \
FLING_STREAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FLING_STREAM_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9920,7 +9815,7 @@ endif
FLING_TEST_SRC = \
- test/core/fling/fling_test.c \
+ test/core/fling/fling_test.cc \
FLING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(FLING_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -9951,104 +9846,8 @@ endif
endif
-GEN_HPACK_TABLES_SRC = \
- tools/codegen/core/gen_hpack_tables.c \
-
-GEN_HPACK_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_HPACK_TABLES_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/gen_hpack_tables: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_hpack_tables
-
-endif
-
-$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_hpack_tables.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
-
-deps_gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(GEN_HPACK_TABLES_OBJS:.o=.dep)
-endif
-endif
-
-
-GEN_LEGAL_METADATA_CHARACTERS_SRC = \
- tools/codegen/core/gen_legal_metadata_characters.c \
-
-GEN_LEGAL_METADATA_CHARACTERS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_LEGAL_METADATA_CHARACTERS_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS)
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GEN_LEGAL_METADATA_CHARACTERS_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters
-
-endif
-
-$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_legal_metadata_characters.o:
-
-deps_gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep)
-endif
-endif
-
-
-GEN_PERCENT_ENCODING_TABLES_SRC = \
- tools/codegen/core/gen_percent_encoding_tables.c \
-
-GEN_PERCENT_ENCODING_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_PERCENT_ENCODING_TABLES_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS)
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GEN_PERCENT_ENCODING_TABLES_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables
-
-endif
-
-$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_percent_encoding_tables.o:
-
-deps_gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep)
-endif
-endif
-
-
GOAWAY_SERVER_TEST_SRC = \
- test/core/end2end/goaway_server_test.c \
+ test/core/end2end/goaway_server_test.cc \
GOAWAY_SERVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GOAWAY_SERVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10080,7 +9879,7 @@ endif
GPR_AVL_TEST_SRC = \
- test/core/support/avl_test.c \
+ test/core/gpr/avl_test.cc \
GPR_AVL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_AVL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10100,7 +9899,7 @@ $(BINDIR)/$(CONFIG)/gpr_avl_test: $(GPR_AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgp
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/avl_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(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)
@@ -10111,40 +9910,8 @@ endif
endif
-GPR_BACKOFF_TEST_SRC = \
- test/core/support/backoff_test.c \
-
-GPR_BACKOFF_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_BACKOFF_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/gpr_backoff_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/gpr_backoff_test: $(GPR_BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_backoff_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/support/backoff_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_gpr_backoff_test: $(GPR_BACKOFF_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(GPR_BACKOFF_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
GPR_CMDLINE_TEST_SRC = \
- test/core/support/cmdline_test.c \
+ test/core/gpr/cmdline_test.cc \
GPR_CMDLINE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_CMDLINE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10164,7 +9931,7 @@ $(BINDIR)/$(CONFIG)/gpr_cmdline_test: $(GPR_CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFI
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/cmdline_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(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)
@@ -10176,7 +9943,7 @@ endif
GPR_CPU_TEST_SRC = \
- test/core/support/cpu_test.c \
+ test/core/gpr/cpu_test.cc \
GPR_CPU_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_CPU_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10196,7 +9963,7 @@ $(BINDIR)/$(CONFIG)/gpr_cpu_test: $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgp
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/cpu_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/cpu_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_cpu_test: $(GPR_CPU_TEST_OBJS:.o=.dep)
@@ -10208,7 +9975,7 @@ endif
GPR_ENV_TEST_SRC = \
- test/core/support/env_test.c \
+ test/core/gpr/env_test.cc \
GPR_ENV_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_ENV_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10228,7 +9995,7 @@ $(BINDIR)/$(CONFIG)/gpr_env_test: $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgp
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/env_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/env_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_env_test: $(GPR_ENV_TEST_OBJS:.o=.dep)
@@ -10239,40 +10006,8 @@ endif
endif
-GPR_HISTOGRAM_TEST_SRC = \
- test/core/support/histogram_test.c \
-
-GPR_HISTOGRAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_HISTOGRAM_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/gpr_histogram_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/gpr_histogram_test: $(GPR_HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_histogram_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/support/histogram_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_gpr_histogram_test: $(GPR_HISTOGRAM_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(GPR_HISTOGRAM_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
GPR_HOST_PORT_TEST_SRC = \
- test/core/support/host_port_test.c \
+ test/core/gpr/host_port_test.cc \
GPR_HOST_PORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_HOST_PORT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10292,7 +10027,7 @@ $(BINDIR)/$(CONFIG)/gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(C
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS:.o=.dep)
@@ -10304,7 +10039,7 @@ endif
GPR_LOG_TEST_SRC = \
- test/core/support/log_test.c \
+ test/core/gpr/log_test.cc \
GPR_LOG_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_LOG_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10324,7 +10059,7 @@ $(BINDIR)/$(CONFIG)/gpr_log_test: $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgp
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/log_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/log_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_log_test: $(GPR_LOG_TEST_OBJS:.o=.dep)
@@ -10335,104 +10070,104 @@ endif
endif
-GPR_MPSCQ_TEST_SRC = \
- test/core/support/mpscq_test.c \
+GPR_MANUAL_CONSTRUCTOR_TEST_SRC = \
+ test/core/gprpp/manual_constructor_test.cc \
-GPR_MPSCQ_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_MPSCQ_TEST_SRC))))
+GPR_MANUAL_CONSTRUCTOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_MANUAL_CONSTRUCTOR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
-$(BINDIR)/$(CONFIG)/gpr_mpscq_test: openssl_dep_error
+$(BINDIR)/$(CONFIG)/gpr_manual_constructor_test: openssl_dep_error
else
-$(BINDIR)/$(CONFIG)/gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/gpr_manual_constructor_test: $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test
+ $(Q) $(LD) $(LDFLAGS) $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/mpscq_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gprpp/manual_constructor_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-deps_gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS:.o=.dep)
+deps_gpr_manual_constructor_test: $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
--include $(GPR_MPSCQ_TEST_OBJS:.o=.dep)
+-include $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS:.o=.dep)
endif
endif
-GPR_SPINLOCK_TEST_SRC = \
- test/core/support/spinlock_test.c \
+GPR_MPSCQ_TEST_SRC = \
+ test/core/gpr/mpscq_test.cc \
-GPR_SPINLOCK_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_SPINLOCK_TEST_SRC))))
+GPR_MPSCQ_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_MPSCQ_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
-$(BINDIR)/$(CONFIG)/gpr_spinlock_test: openssl_dep_error
+$(BINDIR)/$(CONFIG)/gpr_mpscq_test: openssl_dep_error
else
-$(BINDIR)/$(CONFIG)/gpr_spinlock_test: $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_spinlock_test
+ $(Q) $(LD) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/spinlock_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/mpscq_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-deps_gpr_spinlock_test: $(GPR_SPINLOCK_TEST_OBJS:.o=.dep)
+deps_gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
--include $(GPR_SPINLOCK_TEST_OBJS:.o=.dep)
+-include $(GPR_MPSCQ_TEST_OBJS:.o=.dep)
endif
endif
-GPR_STACK_LOCKFREE_TEST_SRC = \
- test/core/support/stack_lockfree_test.c \
+GPR_SPINLOCK_TEST_SRC = \
+ test/core/gpr/spinlock_test.cc \
-GPR_STACK_LOCKFREE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_STACK_LOCKFREE_TEST_SRC))))
+GPR_SPINLOCK_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_SPINLOCK_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
-$(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test: openssl_dep_error
+$(BINDIR)/$(CONFIG)/gpr_spinlock_test: openssl_dep_error
else
-$(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test: $(GPR_STACK_LOCKFREE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/gpr_spinlock_test: $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_STACK_LOCKFREE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test
+ $(Q) $(LD) $(LDFLAGS) $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_spinlock_test
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/stack_lockfree_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/spinlock_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-deps_gpr_stack_lockfree_test: $(GPR_STACK_LOCKFREE_TEST_OBJS:.o=.dep)
+deps_gpr_spinlock_test: $(GPR_SPINLOCK_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
--include $(GPR_STACK_LOCKFREE_TEST_OBJS:.o=.dep)
+-include $(GPR_SPINLOCK_TEST_OBJS:.o=.dep)
endif
endif
GPR_STRING_TEST_SRC = \
- test/core/support/string_test.c \
+ test/core/gpr/string_test.cc \
GPR_STRING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_STRING_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10452,7 +10187,7 @@ $(BINDIR)/$(CONFIG)/gpr_string_test: $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/string_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/string_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_string_test: $(GPR_STRING_TEST_OBJS:.o=.dep)
@@ -10464,7 +10199,7 @@ endif
GPR_SYNC_TEST_SRC = \
- test/core/support/sync_test.c \
+ test/core/gpr/sync_test.cc \
GPR_SYNC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_SYNC_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10484,7 +10219,7 @@ $(BINDIR)/$(CONFIG)/gpr_sync_test: $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/lib
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/sync_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/sync_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_sync_test: $(GPR_SYNC_TEST_OBJS:.o=.dep)
@@ -10496,7 +10231,7 @@ endif
GPR_THD_TEST_SRC = \
- test/core/support/thd_test.c \
+ test/core/gpr/thd_test.cc \
GPR_THD_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_THD_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10516,7 +10251,7 @@ $(BINDIR)/$(CONFIG)/gpr_thd_test: $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgp
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/thd_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/thd_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_thd_test: $(GPR_THD_TEST_OBJS:.o=.dep)
@@ -10528,7 +10263,7 @@ endif
GPR_TIME_TEST_SRC = \
- test/core/support/time_test.c \
+ test/core/gpr/time_test.cc \
GPR_TIME_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_TIME_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10548,7 +10283,7 @@ $(BINDIR)/$(CONFIG)/gpr_time_test: $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/lib
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/time_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/time_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_time_test: $(GPR_TIME_TEST_OBJS:.o=.dep)
@@ -10560,7 +10295,7 @@ endif
GPR_TLS_TEST_SRC = \
- test/core/support/tls_test.c \
+ test/core/gpr/tls_test.cc \
GPR_TLS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_TLS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10580,7 +10315,7 @@ $(BINDIR)/$(CONFIG)/gpr_tls_test: $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgp
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/tls_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/tls_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_tls_test: $(GPR_TLS_TEST_OBJS:.o=.dep)
@@ -10592,7 +10327,7 @@ endif
GPR_USEFUL_TEST_SRC = \
- test/core/support/useful_test.c \
+ test/core/gpr/useful_test.cc \
GPR_USEFUL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_USEFUL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10612,7 +10347,7 @@ $(BINDIR)/$(CONFIG)/gpr_useful_test: $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/useful_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/useful_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_useful_test: $(GPR_USEFUL_TEST_OBJS:.o=.dep)
@@ -10624,7 +10359,7 @@ endif
GRPC_AUTH_CONTEXT_TEST_SRC = \
- test/core/security/auth_context_test.c \
+ test/core/security/auth_context_test.cc \
GRPC_AUTH_CONTEXT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_AUTH_CONTEXT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10656,7 +10391,7 @@ endif
GRPC_B64_TEST_SRC = \
- test/core/slice/b64_test.c \
+ test/core/slice/b64_test.cc \
GRPC_B64_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_B64_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10688,7 +10423,7 @@ endif
GRPC_BYTE_BUFFER_READER_TEST_SRC = \
- test/core/surface/byte_buffer_reader_test.c \
+ test/core/surface/byte_buffer_reader_test.cc \
GRPC_BYTE_BUFFER_READER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_BYTE_BUFFER_READER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10720,7 +10455,7 @@ endif
GRPC_CHANNEL_ARGS_TEST_SRC = \
- test/core/channel/channel_args_test.c \
+ test/core/channel/channel_args_test.cc \
GRPC_CHANNEL_ARGS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CHANNEL_ARGS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10752,7 +10487,7 @@ endif
GRPC_CHANNEL_STACK_BUILDER_TEST_SRC = \
- test/core/channel/channel_stack_builder_test.c \
+ test/core/channel/channel_stack_builder_test.cc \
GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CHANNEL_STACK_BUILDER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10784,7 +10519,7 @@ endif
GRPC_CHANNEL_STACK_TEST_SRC = \
- test/core/channel/channel_stack_test.c \
+ test/core/channel/channel_stack_test.cc \
GRPC_CHANNEL_STACK_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CHANNEL_STACK_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10816,7 +10551,7 @@ endif
GRPC_COMPLETION_QUEUE_TEST_SRC = \
- test/core/surface/completion_queue_test.c \
+ test/core/surface/completion_queue_test.cc \
GRPC_COMPLETION_QUEUE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_COMPLETION_QUEUE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10848,7 +10583,7 @@ endif
GRPC_COMPLETION_QUEUE_THREADING_TEST_SRC = \
- test/core/surface/completion_queue_threading_test.c \
+ test/core/surface/completion_queue_threading_test.cc \
GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_COMPLETION_QUEUE_THREADING_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10880,7 +10615,7 @@ endif
GRPC_CREATE_JWT_SRC = \
- test/core/security/create_jwt.c \
+ test/core/security/create_jwt.cc \
GRPC_CREATE_JWT_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CREATE_JWT_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10912,7 +10647,7 @@ endif
GRPC_CREDENTIALS_TEST_SRC = \
- test/core/security/credentials_test.c \
+ test/core/security/credentials_test.cc \
GRPC_CREDENTIALS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CREDENTIALS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10944,7 +10679,7 @@ endif
GRPC_FETCH_OAUTH2_SRC = \
- test/core/security/fetch_oauth2.c \
+ test/core/security/fetch_oauth2.cc \
GRPC_FETCH_OAUTH2_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_FETCH_OAUTH2_SRC))))
ifeq ($(NO_SECURE),true)
@@ -10976,7 +10711,7 @@ endif
GRPC_INVALID_CHANNEL_ARGS_TEST_SRC = \
- test/core/surface/invalid_channel_args_test.c \
+ test/core/surface/invalid_channel_args_test.cc \
GRPC_INVALID_CHANNEL_ARGS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_INVALID_CHANNEL_ARGS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11008,7 +10743,7 @@ endif
GRPC_JSON_TOKEN_TEST_SRC = \
- test/core/security/json_token_test.c \
+ test/core/security/json_token_test.cc \
GRPC_JSON_TOKEN_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_JSON_TOKEN_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11040,7 +10775,7 @@ endif
GRPC_JWT_VERIFIER_TEST_SRC = \
- test/core/security/jwt_verifier_test.c \
+ test/core/security/jwt_verifier_test.cc \
GRPC_JWT_VERIFIER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_JWT_VERIFIER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11072,7 +10807,7 @@ endif
GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_SRC = \
- test/core/security/print_google_default_creds_token.c \
+ test/core/security/print_google_default_creds_token.cc \
GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11104,7 +10839,7 @@ endif
GRPC_SECURITY_CONNECTOR_TEST_SRC = \
- test/core/security/security_connector_test.c \
+ test/core/security/security_connector_test.cc \
GRPC_SECURITY_CONNECTOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_SECURITY_CONNECTOR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11135,8 +10870,40 @@ endif
endif
+GRPC_SSL_CREDENTIALS_TEST_SRC = \
+ test/core/security/ssl_credentials_test.cc \
+
+GRPC_SSL_CREDENTIALS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_SSL_CREDENTIALS_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test: $(GRPC_SSL_CREDENTIALS_TEST_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_SSL_CREDENTIALS_TEST_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_ssl_credentials_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/security/ssl_credentials_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_grpc_ssl_credentials_test: $(GRPC_SSL_CREDENTIALS_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(GRPC_SSL_CREDENTIALS_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
GRPC_VERIFY_JWT_SRC = \
- test/core/security/verify_jwt.c \
+ test/core/security/verify_jwt.cc \
GRPC_VERIFY_JWT_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_VERIFY_JWT_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11168,7 +10935,7 @@ endif
HANDSHAKE_CLIENT_SRC = \
- test/core/handshake/client_ssl.c \
+ test/core/handshake/client_ssl.cc \
HANDSHAKE_CLIENT_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HANDSHAKE_CLIENT_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11200,7 +10967,8 @@ endif
HANDSHAKE_SERVER_SRC = \
- test/core/handshake/server_ssl.c \
+ test/core/handshake/server_ssl.cc \
+ test/core/handshake/server_ssl_common.cc \
HANDSHAKE_SERVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HANDSHAKE_SERVER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11222,6 +10990,8 @@ endif
$(OBJDIR)/$(CONFIG)/test/core/handshake/server_ssl.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/handshake/server_ssl_common.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
deps_handshake_server: $(HANDSHAKE_SERVER_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
@@ -11231,8 +11001,75 @@ endif
endif
+HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_SRC = \
+ test/core/handshake/readahead_handshaker_server_ssl.cc \
+ test/core/handshake/server_ssl_common.cc \
+
+HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker: $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_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) $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_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)/handshake_server_with_readahead_handshaker
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/handshake/readahead_handshaker_server_ssl.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+$(OBJDIR)/$(CONFIG)/test/core/handshake/server_ssl_common.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_handshake_server_with_readahead_handshaker: $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS:.o=.dep)
+endif
+endif
+
+
+HISTOGRAM_TEST_SRC = \
+ test/core/util/histogram_test.cc \
+
+HISTOGRAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HISTOGRAM_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/histogram_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/histogram_test: $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/histogram_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/util/histogram_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_histogram_test: $(HISTOGRAM_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(HISTOGRAM_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
HPACK_PARSER_FUZZER_TEST_SRC = \
- test/core/transport/chttp2/hpack_parser_fuzzer_test.c \
+ test/core/transport/chttp2/hpack_parser_fuzzer_test.cc \
HPACK_PARSER_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HPACK_PARSER_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11264,7 +11101,7 @@ endif
HPACK_PARSER_TEST_SRC = \
- test/core/transport/chttp2/hpack_parser_test.c \
+ test/core/transport/chttp2/hpack_parser_test.cc \
HPACK_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HPACK_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11296,7 +11133,7 @@ endif
HPACK_TABLE_TEST_SRC = \
- test/core/transport/chttp2/hpack_table_test.c \
+ test/core/transport/chttp2/hpack_table_test.cc \
HPACK_TABLE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HPACK_TABLE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11328,7 +11165,7 @@ endif
HTTP_PARSER_TEST_SRC = \
- test/core/http/parser_test.c \
+ test/core/http/parser_test.cc \
HTTP_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11360,7 +11197,7 @@ endif
HTTP_REQUEST_FUZZER_TEST_SRC = \
- test/core/http/request_fuzzer.c \
+ test/core/http/request_fuzzer.cc \
HTTP_REQUEST_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_REQUEST_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11392,7 +11229,7 @@ endif
HTTP_RESPONSE_FUZZER_TEST_SRC = \
- test/core/http/response_fuzzer.c \
+ test/core/http/response_fuzzer.cc \
HTTP_RESPONSE_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_RESPONSE_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11424,7 +11261,7 @@ endif
HTTPCLI_FORMAT_REQUEST_TEST_SRC = \
- test/core/http/format_request_test.c \
+ test/core/http/format_request_test.cc \
HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11456,7 +11293,7 @@ endif
HTTPCLI_TEST_SRC = \
- test/core/http/httpcli_test.c \
+ test/core/http/httpcli_test.cc \
HTTPCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11488,7 +11325,7 @@ endif
HTTPSCLI_TEST_SRC = \
- test/core/http/httpscli_test.c \
+ test/core/http/httpscli_test.cc \
HTTPSCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPSCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11520,7 +11357,7 @@ endif
INIT_TEST_SRC = \
- test/core/surface/init_test.c \
+ test/core/surface/init_test.cc \
INIT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INIT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11552,7 +11389,7 @@ endif
INVALID_CALL_ARGUMENT_TEST_SRC = \
- test/core/end2end/invalid_call_argument_test.c \
+ test/core/end2end/invalid_call_argument_test.cc \
INVALID_CALL_ARGUMENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INVALID_CALL_ARGUMENT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11584,7 +11421,7 @@ endif
JSON_FUZZER_TEST_SRC = \
- test/core/json/fuzzer.c \
+ test/core/json/fuzzer.cc \
JSON_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11616,7 +11453,7 @@ endif
JSON_REWRITE_SRC = \
- test/core/json/json_rewrite.c \
+ test/core/json/json_rewrite.cc \
JSON_REWRITE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_REWRITE_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11648,7 +11485,7 @@ endif
JSON_REWRITE_TEST_SRC = \
- test/core/json/json_rewrite_test.c \
+ test/core/json/json_rewrite_test.cc \
JSON_REWRITE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_REWRITE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11680,7 +11517,7 @@ endif
JSON_STREAM_ERROR_TEST_SRC = \
- test/core/json/json_stream_error_test.c \
+ test/core/json/json_stream_error_test.cc \
JSON_STREAM_ERROR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_STREAM_ERROR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11712,7 +11549,7 @@ endif
JSON_TEST_SRC = \
- test/core/json/json_test.c \
+ test/core/json/json_test.cc \
JSON_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11744,7 +11581,7 @@ endif
LAME_CLIENT_TEST_SRC = \
- test/core/surface/lame_client_test.c \
+ test/core/surface/lame_client_test.cc \
LAME_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LAME_CLIENT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11776,7 +11613,7 @@ endif
LB_POLICIES_TEST_SRC = \
- test/core/client_channel/lb_policies_test.c \
+ test/core/client_channel/lb_policies_test.cc \
LB_POLICIES_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LB_POLICIES_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11808,7 +11645,7 @@ endif
LOAD_FILE_TEST_SRC = \
- test/core/iomgr/load_file_test.c \
+ test/core/iomgr/load_file_test.cc \
LOAD_FILE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LOAD_FILE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11840,7 +11677,7 @@ endif
LOW_LEVEL_PING_PONG_BENCHMARK_SRC = \
- test/core/network_benchmarks/low_level_ping_pong.c \
+ test/core/network_benchmarks/low_level_ping_pong.cc \
LOW_LEVEL_PING_PONG_BENCHMARK_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LOW_LEVEL_PING_PONG_BENCHMARK_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11872,7 +11709,7 @@ endif
MEMORY_PROFILE_CLIENT_SRC = \
- test/core/memory_usage/client.c \
+ test/core/memory_usage/client.cc \
MEMORY_PROFILE_CLIENT_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MEMORY_PROFILE_CLIENT_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11904,7 +11741,7 @@ endif
MEMORY_PROFILE_SERVER_SRC = \
- test/core/memory_usage/server.c \
+ test/core/memory_usage/server.cc \
MEMORY_PROFILE_SERVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MEMORY_PROFILE_SERVER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11936,7 +11773,7 @@ endif
MEMORY_PROFILE_TEST_SRC = \
- test/core/memory_usage/memory_usage_test.c \
+ test/core/memory_usage/memory_usage_test.cc \
MEMORY_PROFILE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MEMORY_PROFILE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -11968,7 +11805,7 @@ endif
MESSAGE_COMPRESS_TEST_SRC = \
- test/core/compression/message_compress_test.c \
+ test/core/compression/message_compress_test.cc \
MESSAGE_COMPRESS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MESSAGE_COMPRESS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12000,7 +11837,7 @@ endif
MINIMAL_STACK_IS_MINIMAL_TEST_SRC = \
- test/core/channel/minimal_stack_is_minimal_test.c \
+ test/core/channel/minimal_stack_is_minimal_test.cc \
MINIMAL_STACK_IS_MINIMAL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MINIMAL_STACK_IS_MINIMAL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12031,40 +11868,8 @@ endif
endif
-MLOG_TEST_SRC = \
- test/core/census/mlog_test.c \
-
-MLOG_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MLOG_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/mlog_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/mlog_test: $(MLOG_TEST_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) $(MLOG_TEST_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)/mlog_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/census/mlog_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_mlog_test: $(MLOG_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(MLOG_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
MULTIPLE_SERVER_QUEUES_TEST_SRC = \
- test/core/end2end/multiple_server_queues_test.c \
+ test/core/end2end/multiple_server_queues_test.cc \
MULTIPLE_SERVER_QUEUES_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MULTIPLE_SERVER_QUEUES_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12096,7 +11901,7 @@ endif
MURMUR_HASH_TEST_SRC = \
- test/core/support/murmur_hash_test.c \
+ test/core/gpr/murmur_hash_test.cc \
MURMUR_HASH_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MURMUR_HASH_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12116,7 +11921,7 @@ $(BINDIR)/$(CONFIG)/murmur_hash_test: $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFI
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/murmur_hash_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gpr/murmur_hash_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_murmur_hash_test: $(MURMUR_HASH_TEST_OBJS:.o=.dep)
@@ -12128,7 +11933,7 @@ endif
NANOPB_FUZZER_RESPONSE_TEST_SRC = \
- test/core/nanopb/fuzzer_response.c \
+ test/core/nanopb/fuzzer_response.cc \
NANOPB_FUZZER_RESPONSE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NANOPB_FUZZER_RESPONSE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12160,7 +11965,7 @@ endif
NANOPB_FUZZER_SERVERLIST_TEST_SRC = \
- test/core/nanopb/fuzzer_serverlist.c \
+ test/core/nanopb/fuzzer_serverlist.cc \
NANOPB_FUZZER_SERVERLIST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NANOPB_FUZZER_SERVERLIST_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12192,7 +11997,7 @@ endif
NO_SERVER_TEST_SRC = \
- test/core/end2end/no_server_test.c \
+ test/core/end2end/no_server_test.cc \
NO_SERVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NO_SERVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12224,7 +12029,7 @@ endif
NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_SRC = \
- test/core/surface/num_external_connectivity_watchers_test.c \
+ test/core/surface/num_external_connectivity_watchers_test.cc \
NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12256,7 +12061,7 @@ endif
PARSE_ADDRESS_TEST_SRC = \
- test/core/client_channel/parse_address_test.c \
+ test/core/client_channel/parse_address_test.cc \
PARSE_ADDRESS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PARSE_ADDRESS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12288,7 +12093,7 @@ endif
PERCENT_DECODE_FUZZER_SRC = \
- test/core/slice/percent_decode_fuzzer.c \
+ test/core/slice/percent_decode_fuzzer.cc \
PERCENT_DECODE_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PERCENT_DECODE_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12320,7 +12125,7 @@ endif
PERCENT_ENCODE_FUZZER_SRC = \
- test/core/slice/percent_encode_fuzzer.c \
+ test/core/slice/percent_encode_fuzzer.cc \
PERCENT_ENCODE_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PERCENT_ENCODE_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12352,7 +12157,7 @@ endif
PERCENT_ENCODING_TEST_SRC = \
- test/core/slice/percent_encoding_test.c \
+ test/core/slice/percent_encoding_test.cc \
PERCENT_ENCODING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PERCENT_ENCODING_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12384,7 +12189,7 @@ endif
POLLSET_SET_TEST_SRC = \
- test/core/iomgr/pollset_set_test.c \
+ test/core/iomgr/pollset_set_test.cc \
POLLSET_SET_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(POLLSET_SET_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12416,7 +12221,7 @@ endif
RESOLVE_ADDRESS_POSIX_TEST_SRC = \
- test/core/iomgr/resolve_address_posix_test.c \
+ test/core/iomgr/resolve_address_posix_test.cc \
RESOLVE_ADDRESS_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RESOLVE_ADDRESS_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12448,7 +12253,7 @@ endif
RESOLVE_ADDRESS_TEST_SRC = \
- test/core/iomgr/resolve_address_test.c \
+ test/core/iomgr/resolve_address_test.cc \
RESOLVE_ADDRESS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RESOLVE_ADDRESS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12480,7 +12285,7 @@ endif
RESOURCE_QUOTA_TEST_SRC = \
- test/core/iomgr/resource_quota_test.c \
+ test/core/iomgr/resource_quota_test.cc \
RESOURCE_QUOTA_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RESOURCE_QUOTA_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12512,7 +12317,7 @@ endif
SECURE_CHANNEL_CREATE_TEST_SRC = \
- test/core/surface/secure_channel_create_test.c \
+ test/core/surface/secure_channel_create_test.cc \
SECURE_CHANNEL_CREATE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SECURE_CHANNEL_CREATE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12544,7 +12349,7 @@ endif
SECURE_ENDPOINT_TEST_SRC = \
- test/core/security/secure_endpoint_test.c \
+ test/core/security/secure_endpoint_test.cc \
SECURE_ENDPOINT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SECURE_ENDPOINT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12576,7 +12381,7 @@ endif
SEQUENTIAL_CONNECTIVITY_TEST_SRC = \
- test/core/surface/sequential_connectivity_test.c \
+ test/core/surface/sequential_connectivity_test.cc \
SEQUENTIAL_CONNECTIVITY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SEQUENTIAL_CONNECTIVITY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12608,7 +12413,7 @@ endif
SERVER_CHTTP2_TEST_SRC = \
- test/core/surface/server_chttp2_test.c \
+ test/core/surface/server_chttp2_test.cc \
SERVER_CHTTP2_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_CHTTP2_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12640,7 +12445,7 @@ endif
SERVER_FUZZER_SRC = \
- test/core/end2end/fuzzers/server_fuzzer.c \
+ test/core/end2end/fuzzers/server_fuzzer.cc \
SERVER_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12672,7 +12477,7 @@ endif
SERVER_TEST_SRC = \
- test/core/surface/server_test.c \
+ test/core/surface/server_test.cc \
SERVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12704,7 +12509,7 @@ endif
SLICE_BUFFER_TEST_SRC = \
- test/core/slice/slice_buffer_test.c \
+ test/core/slice/slice_buffer_test.cc \
SLICE_BUFFER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SLICE_BUFFER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12736,7 +12541,7 @@ endif
SLICE_HASH_TABLE_TEST_SRC = \
- test/core/slice/slice_hash_table_test.c \
+ test/core/slice/slice_hash_table_test.cc \
SLICE_HASH_TABLE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SLICE_HASH_TABLE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12768,7 +12573,7 @@ endif
SLICE_STRING_HELPERS_TEST_SRC = \
- test/core/slice/slice_string_helpers_test.c \
+ test/core/slice/slice_string_helpers_test.cc \
SLICE_STRING_HELPERS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SLICE_STRING_HELPERS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12800,7 +12605,7 @@ endif
SLICE_TEST_SRC = \
- test/core/slice/slice_test.c \
+ test/core/slice/slice_test.cc \
SLICE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SLICE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12832,7 +12637,7 @@ endif
SOCKADDR_RESOLVER_TEST_SRC = \
- test/core/client_channel/resolvers/sockaddr_resolver_test.c \
+ test/core/client_channel/resolvers/sockaddr_resolver_test.cc \
SOCKADDR_RESOLVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SOCKADDR_RESOLVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12864,7 +12669,7 @@ endif
SOCKADDR_UTILS_TEST_SRC = \
- test/core/iomgr/sockaddr_utils_test.c \
+ test/core/iomgr/sockaddr_utils_test.cc \
SOCKADDR_UTILS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SOCKADDR_UTILS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12896,7 +12701,7 @@ endif
SOCKET_UTILS_TEST_SRC = \
- test/core/iomgr/socket_utils_test.c \
+ test/core/iomgr/socket_utils_test.cc \
SOCKET_UTILS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SOCKET_UTILS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12928,7 +12733,7 @@ endif
SSL_SERVER_FUZZER_SRC = \
- test/core/security/ssl_server_fuzzer.c \
+ test/core/security/ssl_server_fuzzer.cc \
SSL_SERVER_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SSL_SERVER_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12960,8 +12765,8 @@ endif
SSL_TRANSPORT_SECURITY_TEST_SRC = \
- test/core/tsi/ssl_transport_security_test.c \
- test/core/tsi/transport_security_test_lib.c \
+ test/core/tsi/ssl_transport_security_test.cc \
+ test/core/tsi/transport_security_test_lib.cc \
SSL_TRANSPORT_SECURITY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SSL_TRANSPORT_SECURITY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -12995,7 +12800,7 @@ endif
STATUS_CONVERSION_TEST_SRC = \
- test/core/transport/status_conversion_test.c \
+ test/core/transport/status_conversion_test.cc \
STATUS_CONVERSION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_CONVERSION_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13027,7 +12832,7 @@ endif
STREAM_COMPRESSION_TEST_SRC = \
- test/core/compression/stream_compression_test.c \
+ test/core/compression/stream_compression_test.cc \
STREAM_COMPRESSION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STREAM_COMPRESSION_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13059,7 +12864,7 @@ endif
STREAM_OWNED_SLICE_TEST_SRC = \
- test/core/transport/stream_owned_slice_test.c \
+ test/core/transport/stream_owned_slice_test.cc \
STREAM_OWNED_SLICE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STREAM_OWNED_SLICE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13091,7 +12896,7 @@ endif
TCP_CLIENT_POSIX_TEST_SRC = \
- test/core/iomgr/tcp_client_posix_test.c \
+ test/core/iomgr/tcp_client_posix_test.cc \
TCP_CLIENT_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TCP_CLIENT_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13123,7 +12928,7 @@ endif
TCP_CLIENT_UV_TEST_SRC = \
- test/core/iomgr/tcp_client_uv_test.c \
+ test/core/iomgr/tcp_client_uv_test.cc \
TCP_CLIENT_UV_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TCP_CLIENT_UV_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13155,7 +12960,7 @@ endif
TCP_POSIX_TEST_SRC = \
- test/core/iomgr/tcp_posix_test.c \
+ test/core/iomgr/tcp_posix_test.cc \
TCP_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TCP_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13187,7 +12992,7 @@ endif
TCP_SERVER_POSIX_TEST_SRC = \
- test/core/iomgr/tcp_server_posix_test.c \
+ test/core/iomgr/tcp_server_posix_test.cc \
TCP_SERVER_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TCP_SERVER_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13219,7 +13024,7 @@ endif
TCP_SERVER_UV_TEST_SRC = \
- test/core/iomgr/tcp_server_uv_test.c \
+ test/core/iomgr/tcp_server_uv_test.cc \
TCP_SERVER_UV_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TCP_SERVER_UV_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13251,7 +13056,7 @@ endif
TIME_AVERAGED_STATS_TEST_SRC = \
- test/core/iomgr/time_averaged_stats_test.c \
+ test/core/iomgr/time_averaged_stats_test.cc \
TIME_AVERAGED_STATS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TIME_AVERAGED_STATS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13283,7 +13088,7 @@ endif
TIMEOUT_ENCODING_TEST_SRC = \
- test/core/transport/timeout_encoding_test.c \
+ test/core/transport/timeout_encoding_test.cc \
TIMEOUT_ENCODING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TIMEOUT_ENCODING_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13315,7 +13120,7 @@ endif
TIMER_HEAP_TEST_SRC = \
- test/core/iomgr/timer_heap_test.c \
+ test/core/iomgr/timer_heap_test.cc \
TIMER_HEAP_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TIMER_HEAP_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13347,7 +13152,7 @@ endif
TIMER_LIST_TEST_SRC = \
- test/core/iomgr/timer_list_test.c \
+ test/core/iomgr/timer_list_test.cc \
TIMER_LIST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TIMER_LIST_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13379,7 +13184,7 @@ endif
TRANSPORT_CONNECTIVITY_STATE_TEST_SRC = \
- test/core/transport/connectivity_state_test.c \
+ test/core/transport/connectivity_state_test.cc \
TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TRANSPORT_CONNECTIVITY_STATE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13411,7 +13216,7 @@ endif
TRANSPORT_METADATA_TEST_SRC = \
- test/core/transport/metadata_test.c \
+ test/core/transport/metadata_test.cc \
TRANSPORT_METADATA_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TRANSPORT_METADATA_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13442,40 +13247,8 @@ endif
endif
-TRANSPORT_PID_CONTROLLER_TEST_SRC = \
- test/core/transport/pid_controller_test.c \
-
-TRANSPORT_PID_CONTROLLER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TRANSPORT_PID_CONTROLLER_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/transport_pid_controller_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/transport_pid_controller_test: $(TRANSPORT_PID_CONTROLLER_TEST_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) $(TRANSPORT_PID_CONTROLLER_TEST_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)/transport_pid_controller_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/transport/pid_controller_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_transport_pid_controller_test: $(TRANSPORT_PID_CONTROLLER_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(TRANSPORT_PID_CONTROLLER_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
TRANSPORT_SECURITY_TEST_SRC = \
- test/core/tsi/transport_security_test.c \
+ test/core/tsi/transport_security_test.cc \
TRANSPORT_SECURITY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TRANSPORT_SECURITY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13507,7 +13280,7 @@ endif
UDP_SERVER_TEST_SRC = \
- test/core/iomgr/udp_server_test.c \
+ test/core/iomgr/udp_server_test.cc \
UDP_SERVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(UDP_SERVER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13539,7 +13312,7 @@ endif
URI_FUZZER_TEST_SRC = \
- test/core/client_channel/uri_fuzzer_test.c \
+ test/core/client_channel/uri_fuzzer_test.cc \
URI_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(URI_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13571,7 +13344,7 @@ endif
URI_PARSER_TEST_SRC = \
- test/core/client_channel/uri_parser_test.c \
+ test/core/client_channel/uri_parser_test.cc \
URI_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(URI_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13603,7 +13376,7 @@ endif
WAKEUP_FD_CV_TEST_SRC = \
- test/core/iomgr/wakeup_fd_cv_test.c \
+ test/core/iomgr/wakeup_fd_cv_test.cc \
WAKEUP_FD_CV_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(WAKEUP_FD_CV_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -13763,6 +13536,92 @@ endif
endif
+BACKOFF_TEST_SRC = \
+ test/core/backoff/backoff_test.cc \
+
+BACKOFF_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BACKOFF_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/backoff_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/backoff_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/backoff_test: $(PROTOBUF_DEP) $(BACKOFF_TEST_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) $(LDXX) $(LDFLAGS) $(BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/backoff_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/backoff/backoff_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_backoff_test: $(BACKOFF_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(BACKOFF_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
+BDP_ESTIMATOR_TEST_SRC = \
+ test/core/transport/bdp_estimator_test.cc \
+
+BDP_ESTIMATOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BDP_ESTIMATOR_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/bdp_estimator_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/bdp_estimator_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/bdp_estimator_test: $(PROTOBUF_DEP) $(BDP_ESTIMATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(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) $(LDXX) $(LDFLAGS) $(BDP_ESTIMATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bdp_estimator_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/transport/bdp_estimator_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_bdp_estimator_test: $(BDP_ESTIMATOR_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(BDP_ESTIMATOR_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
BM_ARENA_SRC = \
test/cpp/microbenchmarks/bm_arena.cc \
@@ -14465,6 +14324,49 @@ endif
endif
+CHTTP2_SETTINGS_TIMEOUT_TEST_SRC = \
+ test/core/transport/chttp2/settings_timeout_test.cc \
+
+CHTTP2_SETTINGS_TIMEOUT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHTTP2_SETTINGS_TIMEOUT_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test: $(PROTOBUF_DEP) $(CHTTP2_SETTINGS_TIMEOUT_TEST_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) $(LDXX) $(LDFLAGS) $(CHTTP2_SETTINGS_TIMEOUT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/transport/chttp2/settings_timeout_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_chttp2_settings_timeout_test: $(CHTTP2_SETTINGS_TIMEOUT_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(CHTTP2_SETTINGS_TIMEOUT_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
CLI_CALL_TEST_SRC = \
test/cpp/util/cli_call_test.cc \
@@ -14508,6 +14410,53 @@ endif
endif
+CLIENT_CHANNEL_STRESS_TEST_SRC = \
+ $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \
+ test/cpp/client/client_channel_stress_test.cc \
+
+CLIENT_CHANNEL_STRESS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CLIENT_CHANNEL_STRESS_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/client_channel_stress_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/client_channel_stress_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/client_channel_stress_test: $(PROTOBUF_DEP) $(CLIENT_CHANNEL_STRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(CLIENT_CHANNEL_STRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/client_channel_stress_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v1/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+$(OBJDIR)/$(CONFIG)/test/cpp/client/client_channel_stress_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_client_channel_stress_test: $(CLIENT_CHANNEL_STRESS_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(CLIENT_CHANNEL_STRESS_TEST_OBJS:.o=.dep)
+endif
+endif
+$(OBJDIR)/$(CONFIG)/test/cpp/client/client_channel_stress_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
+
+
CLIENT_CRASH_TEST_SRC = \
test/cpp/end2end/client_crash_test.cc \
@@ -15064,6 +15013,49 @@ endif
$(OBJDIR)/$(CONFIG)/test/cpp/util/error_details_test.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc
+EXCEPTION_TEST_SRC = \
+ test/cpp/end2end/exception_test.cc \
+
+EXCEPTION_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(EXCEPTION_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/exception_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/exception_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/exception_test: $(PROTOBUF_DEP) $(EXCEPTION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(EXCEPTION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/exception_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/cpp/end2end/exception_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_exception_test: $(EXCEPTION_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(EXCEPTION_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
FILTER_END2END_TEST_SRC = \
test/cpp/end2end/filter_end2end_test.cc \
@@ -15648,6 +15640,49 @@ endif
$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
+H2_SSL_CERT_TEST_SRC = \
+ test/core/end2end/h2_ssl_cert_test.cc \
+
+H2_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_CERT_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: $(PROTOBUF_DEP) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/end2end/h2_ssl_cert_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
HEALTH_SERVICE_END2END_TEST_SRC = \
test/cpp/end2end/health_service_end2end_test.cc \
@@ -15765,6 +15800,92 @@ endif
endif
+INLINED_VECTOR_TEST_SRC = \
+ test/core/gprpp/inlined_vector_test.cc \
+
+INLINED_VECTOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INLINED_VECTOR_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/inlined_vector_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/inlined_vector_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/inlined_vector_test: $(PROTOBUF_DEP) $(INLINED_VECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(INLINED_VECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/inlined_vector_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/gprpp/inlined_vector_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_inlined_vector_test: $(INLINED_VECTOR_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(INLINED_VECTOR_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
+INPROC_SYNC_UNARY_PING_PONG_TEST_SRC = \
+ test/cpp/qps/inproc_sync_unary_ping_pong_test.cc \
+
+INPROC_SYNC_UNARY_PING_PONG_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INPROC_SYNC_UNARY_PING_PONG_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(INPROC_SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(INPROC_SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/cpp/qps/inproc_sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
+
+deps_inproc_sync_unary_ping_pong_test: $(INPROC_SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(INPROC_SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
@@ -15914,7 +16035,7 @@ endif
MEMORY_TEST_SRC = \
- test/core/support/memory_test.cc \
+ test/core/gprpp/memory_test.cc \
MEMORY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MEMORY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -15945,7 +16066,7 @@ endif
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/memory_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/gprpp/memory_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_memory_test: $(MEMORY_TEST_OBJS:.o=.dep)
@@ -16090,6 +16211,49 @@ endif
endif
+ORPHANABLE_TEST_SRC = \
+ test/core/gprpp/orphanable_test.cc \
+
+ORPHANABLE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ORPHANABLE_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/orphanable_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/orphanable_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/orphanable_test: $(PROTOBUF_DEP) $(ORPHANABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(ORPHANABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/orphanable_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/gprpp/orphanable_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_orphanable_test: $(ORPHANABLE_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(ORPHANABLE_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
PROTO_SERVER_REFLECTION_TEST_SRC = \
test/cpp/end2end/proto_server_reflection_test.cc \
@@ -16454,6 +16618,92 @@ endif
$(OBJDIR)/$(CONFIG)/test/cpp/interop/reconnect_interop_server.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc
+REF_COUNTED_PTR_TEST_SRC = \
+ test/core/gprpp/ref_counted_ptr_test.cc \
+
+REF_COUNTED_PTR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(REF_COUNTED_PTR_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/ref_counted_ptr_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/ref_counted_ptr_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/ref_counted_ptr_test: $(PROTOBUF_DEP) $(REF_COUNTED_PTR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(REF_COUNTED_PTR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/ref_counted_ptr_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/gprpp/ref_counted_ptr_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_ref_counted_ptr_test: $(REF_COUNTED_PTR_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(REF_COUNTED_PTR_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
+REF_COUNTED_TEST_SRC = \
+ test/core/gprpp/ref_counted_test.cc \
+
+REF_COUNTED_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(REF_COUNTED_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/ref_counted_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/ref_counted_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/ref_counted_test: $(PROTOBUF_DEP) $(REF_COUNTED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(REF_COUNTED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/ref_counted_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/gprpp/ref_counted_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_ref_counted_test: $(REF_COUNTED_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(REF_COUNTED_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
SECURE_AUTH_CONTEXT_TEST_SRC = \
test/cpp/common/secure_auth_context_test.cc \
@@ -16762,6 +17012,49 @@ endif
endif
+SERVER_EARLY_RETURN_TEST_SRC = \
+ test/cpp/end2end/server_early_return_test.cc \
+
+SERVER_EARLY_RETURN_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_EARLY_RETURN_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/server_early_return_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/server_early_return_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/server_early_return_test: $(PROTOBUF_DEP) $(SERVER_EARLY_RETURN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(SERVER_EARLY_RETURN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/server_early_return_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/cpp/end2end/server_early_return_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_server_early_return_test: $(SERVER_EARLY_RETURN_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(SERVER_EARLY_RETURN_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
SERVER_REQUEST_CALL_TEST_SRC = \
$(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \
@@ -17138,6 +17431,49 @@ endif
endif
+TRANSPORT_PID_CONTROLLER_TEST_SRC = \
+ test/core/transport/pid_controller_test.cc \
+
+TRANSPORT_PID_CONTROLLER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TRANSPORT_PID_CONTROLLER_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/transport_pid_controller_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/transport_pid_controller_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/transport_pid_controller_test: $(PROTOBUF_DEP) $(TRANSPORT_PID_CONTROLLER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(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) $(LDXX) $(LDFLAGS) $(TRANSPORT_PID_CONTROLLER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/transport_pid_controller_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/transport/pid_controller_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_transport_pid_controller_test: $(TRANSPORT_PID_CONTROLLER_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(TRANSPORT_PID_CONTROLLER_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
WRITES_PER_RPC_TEST_SRC = \
test/cpp/performance/writes_per_rpc_test.cc \
@@ -17217,6 +17553,102 @@ endif
endif
+GEN_HPACK_TABLES_SRC = \
+ tools/codegen/core/gen_hpack_tables.cc \
+
+GEN_HPACK_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_HPACK_TABLES_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/gen_hpack_tables: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_hpack_tables
+
+endif
+
+$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_hpack_tables.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
+
+deps_gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(GEN_HPACK_TABLES_OBJS:.o=.dep)
+endif
+endif
+
+
+GEN_LEGAL_METADATA_CHARACTERS_SRC = \
+ tools/codegen/core/gen_legal_metadata_characters.cc \
+
+GEN_LEGAL_METADATA_CHARACTERS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_LEGAL_METADATA_CHARACTERS_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS)
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(GEN_LEGAL_METADATA_CHARACTERS_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters
+
+endif
+
+$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_legal_metadata_characters.o:
+
+deps_gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep)
+endif
+endif
+
+
+GEN_PERCENT_ENCODING_TABLES_SRC = \
+ tools/codegen/core/gen_percent_encoding_tables.cc \
+
+GEN_PERCENT_ENCODING_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_PERCENT_ENCODING_TABLES_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS)
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(GEN_PERCENT_ENCODING_TABLES_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables
+
+endif
+
+$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_percent_encoding_tables.o:
+
+deps_gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep)
+endif
+endif
+
+
# boringssl needs an override to ensure that it does not include
# system openssl headers regardless of other configuration
@@ -17242,7 +17674,7 @@ $(BINDIR)/$(CONFIG)/boringssl_aes_test: $(LIBDIR)/$(CONFIG)/libboringssl_aes_te
endif
$(BORINGSSL_AES_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_AES_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_AES_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17271,7 +17703,7 @@ $(BINDIR)/$(CONFIG)/boringssl_asn1_test: $(LIBDIR)/$(CONFIG)/libboringssl_asn1_
endif
$(BORINGSSL_ASN1_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_ASN1_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_ASN1_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17300,7 +17732,7 @@ $(BINDIR)/$(CONFIG)/boringssl_base64_test: $(LIBDIR)/$(CONFIG)/libboringssl_bas
endif
$(BORINGSSL_BASE64_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_BASE64_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_BASE64_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17329,7 +17761,7 @@ $(BINDIR)/$(CONFIG)/boringssl_bio_test: $(LIBDIR)/$(CONFIG)/libboringssl_bio_te
endif
$(BORINGSSL_BIO_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_BIO_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_BIO_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17358,7 +17790,7 @@ $(BINDIR)/$(CONFIG)/boringssl_bn_test: $(LIBDIR)/$(CONFIG)/libboringssl_bn_test
endif
$(BORINGSSL_BN_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_BN_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_BN_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17387,7 +17819,7 @@ $(BINDIR)/$(CONFIG)/boringssl_bytestring_test: $(LIBDIR)/$(CONFIG)/libboringssl
endif
$(BORINGSSL_BYTESTRING_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_BYTESTRING_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_BYTESTRING_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17416,7 +17848,7 @@ $(BINDIR)/$(CONFIG)/boringssl_aead_test: $(LIBDIR)/$(CONFIG)/libboringssl_aead_
endif
$(BORINGSSL_AEAD_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_AEAD_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_AEAD_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17445,7 +17877,7 @@ $(BINDIR)/$(CONFIG)/boringssl_cipher_test: $(LIBDIR)/$(CONFIG)/libboringssl_cip
endif
$(BORINGSSL_CIPHER_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_CIPHER_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_CIPHER_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17474,7 +17906,7 @@ $(BINDIR)/$(CONFIG)/boringssl_cmac_test: $(LIBDIR)/$(CONFIG)/libboringssl_cmac_
endif
$(BORINGSSL_CMAC_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_CMAC_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_CMAC_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17503,7 +17935,7 @@ $(BINDIR)/$(CONFIG)/boringssl_constant_time_test: $(LIBDIR)/$(CONFIG)/libboring
endif
$(BORINGSSL_CONSTANT_TIME_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_CONSTANT_TIME_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_CONSTANT_TIME_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17532,7 +17964,7 @@ $(BINDIR)/$(CONFIG)/boringssl_ed25519_test: $(LIBDIR)/$(CONFIG)/libboringssl_ed
endif
$(BORINGSSL_ED25519_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_ED25519_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_ED25519_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17561,7 +17993,7 @@ $(BINDIR)/$(CONFIG)/boringssl_spake25519_test: $(LIBDIR)/$(CONFIG)/libboringssl
endif
$(BORINGSSL_SPAKE25519_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_SPAKE25519_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_SPAKE25519_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17590,7 +18022,7 @@ $(BINDIR)/$(CONFIG)/boringssl_x25519_test: $(LIBDIR)/$(CONFIG)/libboringssl_x25
endif
$(BORINGSSL_X25519_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_X25519_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_X25519_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17619,7 +18051,7 @@ $(BINDIR)/$(CONFIG)/boringssl_digest_test: $(LIBDIR)/$(CONFIG)/libboringssl_dig
endif
$(BORINGSSL_DIGEST_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_DIGEST_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_DIGEST_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17648,7 +18080,7 @@ $(BINDIR)/$(CONFIG)/boringssl_example_mul: $(LIBDIR)/$(CONFIG)/libboringssl_exa
endif
$(BORINGSSL_EXAMPLE_MUL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_EXAMPLE_MUL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_EXAMPLE_MUL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17677,7 +18109,7 @@ $(BINDIR)/$(CONFIG)/boringssl_p256-x86_64_test: $(LIBDIR)/$(CONFIG)/libboringss
endif
$(BORINGSSL_P256-X86_64_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_P256-X86_64_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_P256-X86_64_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17706,7 +18138,7 @@ $(BINDIR)/$(CONFIG)/boringssl_ecdh_test: $(LIBDIR)/$(CONFIG)/libboringssl_ecdh_
endif
$(BORINGSSL_ECDH_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_ECDH_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_ECDH_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17735,7 +18167,7 @@ $(BINDIR)/$(CONFIG)/boringssl_ecdsa_sign_test: $(LIBDIR)/$(CONFIG)/libboringssl
endif
$(BORINGSSL_ECDSA_SIGN_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_ECDSA_SIGN_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_ECDSA_SIGN_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17764,7 +18196,7 @@ $(BINDIR)/$(CONFIG)/boringssl_ecdsa_test: $(LIBDIR)/$(CONFIG)/libboringssl_ecds
endif
$(BORINGSSL_ECDSA_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_ECDSA_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_ECDSA_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17793,7 +18225,7 @@ $(BINDIR)/$(CONFIG)/boringssl_ecdsa_verify_test: $(LIBDIR)/$(CONFIG)/libborings
endif
$(BORINGSSL_ECDSA_VERIFY_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_ECDSA_VERIFY_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_ECDSA_VERIFY_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17822,7 +18254,7 @@ $(BINDIR)/$(CONFIG)/boringssl_evp_extra_test: $(LIBDIR)/$(CONFIG)/libboringssl_
endif
$(BORINGSSL_EVP_EXTRA_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_EVP_EXTRA_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_EVP_EXTRA_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17851,7 +18283,7 @@ $(BINDIR)/$(CONFIG)/boringssl_evp_test: $(LIBDIR)/$(CONFIG)/libboringssl_evp_te
endif
$(BORINGSSL_EVP_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_EVP_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_EVP_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17880,7 +18312,7 @@ $(BINDIR)/$(CONFIG)/boringssl_pbkdf_test: $(LIBDIR)/$(CONFIG)/libboringssl_pbkd
endif
$(BORINGSSL_PBKDF_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_PBKDF_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_PBKDF_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17909,7 +18341,7 @@ $(BINDIR)/$(CONFIG)/boringssl_hkdf_test: $(LIBDIR)/$(CONFIG)/libboringssl_hkdf_
endif
$(BORINGSSL_HKDF_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_HKDF_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_HKDF_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17938,7 +18370,7 @@ $(BINDIR)/$(CONFIG)/boringssl_hmac_test: $(LIBDIR)/$(CONFIG)/libboringssl_hmac_
endif
$(BORINGSSL_HMAC_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_HMAC_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_HMAC_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17967,7 +18399,7 @@ $(BINDIR)/$(CONFIG)/boringssl_lhash_test: $(LIBDIR)/$(CONFIG)/libboringssl_lhas
endif
$(BORINGSSL_LHASH_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_LHASH_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_LHASH_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -17996,7 +18428,7 @@ $(BINDIR)/$(CONFIG)/boringssl_gcm_test: $(LIBDIR)/$(CONFIG)/libboringssl_gcm_te
endif
$(BORINGSSL_GCM_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_GCM_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_GCM_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18025,7 +18457,7 @@ $(BINDIR)/$(CONFIG)/boringssl_obj_test: $(LIBDIR)/$(CONFIG)/libboringssl_obj_te
endif
$(BORINGSSL_OBJ_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_OBJ_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_OBJ_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18054,7 +18486,7 @@ $(BINDIR)/$(CONFIG)/boringssl_pkcs12_test: $(LIBDIR)/$(CONFIG)/libboringssl_pkc
endif
$(BORINGSSL_PKCS12_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_PKCS12_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_PKCS12_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18083,7 +18515,7 @@ $(BINDIR)/$(CONFIG)/boringssl_pkcs8_test: $(LIBDIR)/$(CONFIG)/libboringssl_pkcs
endif
$(BORINGSSL_PKCS8_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_PKCS8_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_PKCS8_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18112,7 +18544,7 @@ $(BINDIR)/$(CONFIG)/boringssl_poly1305_test: $(LIBDIR)/$(CONFIG)/libboringssl_p
endif
$(BORINGSSL_POLY1305_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_POLY1305_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_POLY1305_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18141,7 +18573,7 @@ $(BINDIR)/$(CONFIG)/boringssl_pool_test: $(LIBDIR)/$(CONFIG)/libboringssl_pool_
endif
$(BORINGSSL_POOL_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_POOL_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_POOL_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18170,7 +18602,7 @@ $(BINDIR)/$(CONFIG)/boringssl_refcount_test: $(LIBDIR)/$(CONFIG)/libboringssl_r
endif
$(BORINGSSL_REFCOUNT_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_REFCOUNT_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_REFCOUNT_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18199,7 +18631,7 @@ $(BINDIR)/$(CONFIG)/boringssl_thread_test: $(LIBDIR)/$(CONFIG)/libboringssl_thr
endif
$(BORINGSSL_THREAD_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_THREAD_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_THREAD_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18228,7 +18660,7 @@ $(BINDIR)/$(CONFIG)/boringssl_pkcs7_test: $(LIBDIR)/$(CONFIG)/libboringssl_pkcs
endif
$(BORINGSSL_PKCS7_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_PKCS7_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_PKCS7_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18257,7 +18689,7 @@ $(BINDIR)/$(CONFIG)/boringssl_x509_test: $(LIBDIR)/$(CONFIG)/libboringssl_x509_
endif
$(BORINGSSL_X509_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_X509_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_X509_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18286,7 +18718,7 @@ $(BINDIR)/$(CONFIG)/boringssl_tab_test: $(LIBDIR)/$(CONFIG)/libboringssl_tab_te
endif
$(BORINGSSL_TAB_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_TAB_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_TAB_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
@@ -18315,12 +18747,12 @@ $(BINDIR)/$(CONFIG)/boringssl_v3name_test: $(LIBDIR)/$(CONFIG)/libboringssl_v3n
endif
$(BORINGSSL_V3NAME_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
-$(BORINGSSL_V3NAME_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+$(BORINGSSL_V3NAME_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI)
BADREQ_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/badreq.c \
+ test/core/bad_client/tests/badreq.cc \
BADREQ_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BADREQ_BAD_CLIENT_TEST_SRC))))
@@ -18340,7 +18772,7 @@ endif
CONNECTION_PREFIX_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/connection_prefix.c \
+ test/core/bad_client/tests/connection_prefix.cc \
CONNECTION_PREFIX_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CONNECTION_PREFIX_BAD_CLIENT_TEST_SRC))))
@@ -18360,7 +18792,7 @@ endif
HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/head_of_line_blocking.c \
+ test/core/bad_client/tests/head_of_line_blocking.cc \
HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_SRC))))
@@ -18380,7 +18812,7 @@ endif
HEADERS_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/headers.c \
+ test/core/bad_client/tests/headers.cc \
HEADERS_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HEADERS_BAD_CLIENT_TEST_SRC))))
@@ -18400,7 +18832,7 @@ endif
INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/initial_settings_frame.c \
+ test/core/bad_client/tests/initial_settings_frame.cc \
INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_SRC))))
@@ -18419,28 +18851,8 @@ ifneq ($(NO_DEPS),true)
endif
-LARGE_METADATA_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/large_metadata.c \
-
-LARGE_METADATA_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LARGE_METADATA_BAD_CLIENT_TEST_SRC))))
-
-
-$(BINDIR)/$(CONFIG)/large_metadata_bad_client_test: $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test
-
-$(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/large_metadata.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_large_metadata_bad_client_test: $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_DEPS),true)
--include $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS:.o=.dep)
-endif
-
-
SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/server_registered_method.c \
+ test/core/bad_client/tests/server_registered_method.cc \
SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_SRC))))
@@ -18460,7 +18872,7 @@ endif
SIMPLE_REQUEST_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/simple_request.c \
+ test/core/bad_client/tests/simple_request.cc \
SIMPLE_REQUEST_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SIMPLE_REQUEST_BAD_CLIENT_TEST_SRC))))
@@ -18480,7 +18892,7 @@ endif
UNKNOWN_FRAME_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/unknown_frame.c \
+ test/core/bad_client/tests/unknown_frame.cc \
UNKNOWN_FRAME_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(UNKNOWN_FRAME_BAD_CLIENT_TEST_SRC))))
@@ -18500,7 +18912,7 @@ endif
WINDOW_OVERFLOW_BAD_CLIENT_TEST_SRC = \
- test/core/bad_client/tests/window_overflow.c \
+ test/core/bad_client/tests/window_overflow.cc \
WINDOW_OVERFLOW_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(WINDOW_OVERFLOW_BAD_CLIENT_TEST_SRC))))
@@ -18520,7 +18932,7 @@ endif
BAD_SSL_CERT_SERVER_SRC = \
- test/core/bad_ssl/servers/cert.c \
+ test/core/bad_ssl/servers/cert.cc \
BAD_SSL_CERT_SERVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BAD_SSL_CERT_SERVER_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18552,7 +18964,7 @@ endif
BAD_SSL_CERT_TEST_SRC = \
- test/core/bad_ssl/bad_ssl_test.c \
+ test/core/bad_ssl/bad_ssl_test.cc \
BAD_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BAD_SSL_CERT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18584,7 +18996,7 @@ endif
H2_CENSUS_TEST_SRC = \
- test/core/end2end/fixtures/h2_census.c \
+ test/core/end2end/fixtures/h2_census.cc \
H2_CENSUS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_CENSUS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18616,7 +19028,7 @@ endif
H2_COMPRESS_TEST_SRC = \
- test/core/end2end/fixtures/h2_compress.c \
+ test/core/end2end/fixtures/h2_compress.cc \
H2_COMPRESS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_COMPRESS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18648,7 +19060,7 @@ endif
H2_FAKESEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_fakesec.c \
+ test/core/end2end/fixtures/h2_fakesec.cc \
H2_FAKESEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FAKESEC_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18680,7 +19092,7 @@ endif
H2_FD_TEST_SRC = \
- test/core/end2end/fixtures/h2_fd.c \
+ test/core/end2end/fixtures/h2_fd.cc \
H2_FD_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FD_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18712,7 +19124,7 @@ endif
H2_FULL_TEST_SRC = \
- test/core/end2end/fixtures/h2_full.c \
+ test/core/end2end/fixtures/h2_full.cc \
H2_FULL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18744,7 +19156,7 @@ endif
H2_FULL+PIPE_TEST_SRC = \
- test/core/end2end/fixtures/h2_full+pipe.c \
+ test/core/end2end/fixtures/h2_full+pipe.cc \
H2_FULL+PIPE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL+PIPE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18776,7 +19188,7 @@ endif
H2_FULL+TRACE_TEST_SRC = \
- test/core/end2end/fixtures/h2_full+trace.c \
+ test/core/end2end/fixtures/h2_full+trace.cc \
H2_FULL+TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL+TRACE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18808,7 +19220,7 @@ endif
H2_FULL+WORKAROUNDS_TEST_SRC = \
- test/core/end2end/fixtures/h2_full+workarounds.c \
+ test/core/end2end/fixtures/h2_full+workarounds.cc \
H2_FULL+WORKAROUNDS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL+WORKAROUNDS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18840,7 +19252,7 @@ endif
H2_HTTP_PROXY_TEST_SRC = \
- test/core/end2end/fixtures/h2_http_proxy.c \
+ test/core/end2end/fixtures/h2_http_proxy.cc \
H2_HTTP_PROXY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_HTTP_PROXY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18872,7 +19284,7 @@ endif
H2_LOAD_REPORTING_TEST_SRC = \
- test/core/end2end/fixtures/h2_load_reporting.c \
+ test/core/end2end/fixtures/h2_load_reporting.cc \
H2_LOAD_REPORTING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_LOAD_REPORTING_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18904,7 +19316,7 @@ endif
H2_OAUTH2_TEST_SRC = \
- test/core/end2end/fixtures/h2_oauth2.c \
+ test/core/end2end/fixtures/h2_oauth2.cc \
H2_OAUTH2_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_OAUTH2_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18936,7 +19348,7 @@ endif
H2_PROXY_TEST_SRC = \
- test/core/end2end/fixtures/h2_proxy.c \
+ test/core/end2end/fixtures/h2_proxy.cc \
H2_PROXY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_PROXY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -18968,7 +19380,7 @@ endif
H2_SOCKPAIR_TEST_SRC = \
- test/core/end2end/fixtures/h2_sockpair.c \
+ test/core/end2end/fixtures/h2_sockpair.cc \
H2_SOCKPAIR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SOCKPAIR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19000,7 +19412,7 @@ endif
H2_SOCKPAIR+TRACE_TEST_SRC = \
- test/core/end2end/fixtures/h2_sockpair+trace.c \
+ test/core/end2end/fixtures/h2_sockpair+trace.cc \
H2_SOCKPAIR+TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SOCKPAIR+TRACE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19032,7 +19444,7 @@ endif
H2_SOCKPAIR_1BYTE_TEST_SRC = \
- test/core/end2end/fixtures/h2_sockpair_1byte.c \
+ test/core/end2end/fixtures/h2_sockpair_1byte.cc \
H2_SOCKPAIR_1BYTE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SOCKPAIR_1BYTE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19064,7 +19476,7 @@ endif
H2_SSL_TEST_SRC = \
- test/core/end2end/fixtures/h2_ssl.c \
+ test/core/end2end/fixtures/h2_ssl.cc \
H2_SSL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19095,40 +19507,8 @@ endif
endif
-H2_SSL_CERT_TEST_SRC = \
- test/core/end2end/fixtures/h2_ssl_cert.c \
-
-H2_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_CERT_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(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) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(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)/h2_ssl_cert_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_ssl_cert.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
H2_SSL_PROXY_TEST_SRC = \
- test/core/end2end/fixtures/h2_ssl_proxy.c \
+ test/core/end2end/fixtures/h2_ssl_proxy.cc \
H2_SSL_PROXY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_PROXY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19160,7 +19540,7 @@ endif
H2_UDS_TEST_SRC = \
- test/core/end2end/fixtures/h2_uds.c \
+ test/core/end2end/fixtures/h2_uds.cc \
H2_UDS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_UDS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19192,7 +19572,7 @@ endif
INPROC_TEST_SRC = \
- test/core/end2end/fixtures/inproc.c \
+ test/core/end2end/fixtures/inproc.cc \
INPROC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INPROC_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19224,7 +19604,7 @@ endif
H2_CENSUS_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_census.c \
+ test/core/end2end/fixtures/h2_census.cc \
H2_CENSUS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_CENSUS_NOSEC_TEST_SRC))))
@@ -19244,7 +19624,7 @@ endif
H2_COMPRESS_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_compress.c \
+ test/core/end2end/fixtures/h2_compress.cc \
H2_COMPRESS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_COMPRESS_NOSEC_TEST_SRC))))
@@ -19264,7 +19644,7 @@ endif
H2_FD_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_fd.c \
+ test/core/end2end/fixtures/h2_fd.cc \
H2_FD_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FD_NOSEC_TEST_SRC))))
@@ -19284,7 +19664,7 @@ endif
H2_FULL_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_full.c \
+ test/core/end2end/fixtures/h2_full.cc \
H2_FULL_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL_NOSEC_TEST_SRC))))
@@ -19304,7 +19684,7 @@ endif
H2_FULL+PIPE_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_full+pipe.c \
+ test/core/end2end/fixtures/h2_full+pipe.cc \
H2_FULL+PIPE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL+PIPE_NOSEC_TEST_SRC))))
@@ -19324,7 +19704,7 @@ endif
H2_FULL+TRACE_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_full+trace.c \
+ test/core/end2end/fixtures/h2_full+trace.cc \
H2_FULL+TRACE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL+TRACE_NOSEC_TEST_SRC))))
@@ -19344,7 +19724,7 @@ endif
H2_FULL+WORKAROUNDS_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_full+workarounds.c \
+ test/core/end2end/fixtures/h2_full+workarounds.cc \
H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_FULL+WORKAROUNDS_NOSEC_TEST_SRC))))
@@ -19364,7 +19744,7 @@ endif
H2_HTTP_PROXY_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_http_proxy.c \
+ test/core/end2end/fixtures/h2_http_proxy.cc \
H2_HTTP_PROXY_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_HTTP_PROXY_NOSEC_TEST_SRC))))
@@ -19384,7 +19764,7 @@ endif
H2_LOAD_REPORTING_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_load_reporting.c \
+ test/core/end2end/fixtures/h2_load_reporting.cc \
H2_LOAD_REPORTING_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_LOAD_REPORTING_NOSEC_TEST_SRC))))
@@ -19404,7 +19784,7 @@ endif
H2_PROXY_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_proxy.c \
+ test/core/end2end/fixtures/h2_proxy.cc \
H2_PROXY_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_PROXY_NOSEC_TEST_SRC))))
@@ -19424,7 +19804,7 @@ endif
H2_SOCKPAIR_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_sockpair.c \
+ test/core/end2end/fixtures/h2_sockpair.cc \
H2_SOCKPAIR_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SOCKPAIR_NOSEC_TEST_SRC))))
@@ -19444,7 +19824,7 @@ endif
H2_SOCKPAIR+TRACE_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_sockpair+trace.c \
+ test/core/end2end/fixtures/h2_sockpair+trace.cc \
H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SOCKPAIR+TRACE_NOSEC_TEST_SRC))))
@@ -19464,7 +19844,7 @@ endif
H2_SOCKPAIR_1BYTE_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_sockpair_1byte.c \
+ test/core/end2end/fixtures/h2_sockpair_1byte.cc \
H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_SRC))))
@@ -19484,7 +19864,7 @@ endif
H2_UDS_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/h2_uds.c \
+ test/core/end2end/fixtures/h2_uds.cc \
H2_UDS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_UDS_NOSEC_TEST_SRC))))
@@ -19504,7 +19884,7 @@ endif
INPROC_NOSEC_TEST_SRC = \
- test/core/end2end/fixtures/inproc.c \
+ test/core/end2end/fixtures/inproc.cc \
INPROC_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INPROC_NOSEC_TEST_SRC))))
@@ -19696,8 +20076,8 @@ endif
API_FUZZER_ONE_ENTRY_SRC = \
- test/core/end2end/fuzzers/api_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/end2end/fuzzers/api_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
API_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(API_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19731,8 +20111,8 @@ endif
CLIENT_FUZZER_ONE_ENTRY_SRC = \
- test/core/end2end/fuzzers/client_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/end2end/fuzzers/client_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
CLIENT_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CLIENT_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19766,8 +20146,8 @@ endif
HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_SRC = \
- test/core/transport/chttp2/hpack_parser_fuzzer_test.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/transport/chttp2/hpack_parser_fuzzer_test.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19801,8 +20181,8 @@ endif
HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_SRC = \
- test/core/http/request_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/http/request_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19836,8 +20216,8 @@ endif
HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_SRC = \
- test/core/http/response_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/http/response_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19871,8 +20251,8 @@ endif
JSON_FUZZER_TEST_ONE_ENTRY_SRC = \
- test/core/json/fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/json/fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
JSON_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(JSON_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19906,8 +20286,8 @@ endif
NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_SRC = \
- test/core/nanopb/fuzzer_response.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/nanopb/fuzzer_response.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19941,8 +20321,8 @@ endif
NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_SRC = \
- test/core/nanopb/fuzzer_serverlist.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/nanopb/fuzzer_serverlist.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19976,8 +20356,8 @@ endif
PERCENT_DECODE_FUZZER_ONE_ENTRY_SRC = \
- test/core/slice/percent_decode_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/slice/percent_decode_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PERCENT_DECODE_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -20011,8 +20391,8 @@ endif
PERCENT_ENCODE_FUZZER_ONE_ENTRY_SRC = \
- test/core/slice/percent_encode_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/slice/percent_encode_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -20046,8 +20426,8 @@ endif
SERVER_FUZZER_ONE_ENTRY_SRC = \
- test/core/end2end/fuzzers/server_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/end2end/fuzzers/server_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
SERVER_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -20081,8 +20461,8 @@ endif
SSL_SERVER_FUZZER_ONE_ENTRY_SRC = \
- test/core/security/ssl_server_fuzzer.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/security/ssl_server_fuzzer.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
SSL_SERVER_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SSL_SERVER_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -20116,8 +20496,8 @@ endif
URI_FUZZER_TEST_ONE_ENTRY_SRC = \
- test/core/client_channel/uri_fuzzer_test.c \
- test/core/util/one_corpus_entry_fuzzer.c \
+ test/core/client_channel/uri_fuzzer_test.cc \
+ test/core/util/one_corpus_entry_fuzzer.cc \
URI_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(URI_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
@@ -20158,44 +20538,44 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first.
-src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c: $(OPENSSL_DEP)
-src/core/ext/transport/chttp2/client/secure/secure_channel_create.c: $(OPENSSL_DEP)
-src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c: $(OPENSSL_DEP)
-src/core/ext/transport/cronet/client/secure/cronet_channel_create.c: $(OPENSSL_DEP)
-src/core/ext/transport/cronet/transport/cronet_api_dummy.c: $(OPENSSL_DEP)
-src/core/ext/transport/cronet/transport/cronet_transport.c: $(OPENSSL_DEP)
-src/core/lib/http/httpcli_security_connector.c: $(OPENSSL_DEP)
-src/core/lib/security/context/security_context.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/composite/composite_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/credentials_metadata.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/fake/fake_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/google_default/credentials_generic.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/google_default/google_default_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/iam/iam_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/jwt/json_token.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/jwt/jwt_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/jwt/jwt_verifier.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/oauth2/oauth2_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/plugin/plugin_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/credentials/ssl/ssl_credentials.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/client_auth_filter.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/lb_targets_info.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/secure_endpoint.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/security_connector.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/security_handshaker.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/server_auth_filter.c: $(OPENSSL_DEP)
-src/core/lib/security/transport/tsi_error.c: $(OPENSSL_DEP)
-src/core/lib/security/util/json_util.c: $(OPENSSL_DEP)
-src/core/lib/surface/init_secure.c: $(OPENSSL_DEP)
-src/core/plugin_registry/grpc_cronet_plugin_registry.c: $(OPENSSL_DEP)
-src/core/plugin_registry/grpc_plugin_registry.c: $(OPENSSL_DEP)
-src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP)
-src/core/tsi/gts_transport_security.c: $(OPENSSL_DEP)
-src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP)
-src/core/tsi/transport_security.c: $(OPENSSL_DEP)
-src/core/tsi/transport_security_adapter.c: $(OPENSSL_DEP)
-src/core/tsi/transport_security_grpc.c: $(OPENSSL_DEP)
+src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc: $(OPENSSL_DEP)
+src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc: $(OPENSSL_DEP)
+src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc: $(OPENSSL_DEP)
+src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc: $(OPENSSL_DEP)
+src/core/ext/transport/cronet/transport/cronet_api_dummy.cc: $(OPENSSL_DEP)
+src/core/ext/transport/cronet/transport/cronet_transport.cc: $(OPENSSL_DEP)
+src/core/lib/http/httpcli_security_connector.cc: $(OPENSSL_DEP)
+src/core/lib/security/context/security_context.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/composite/composite_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/credentials_metadata.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/fake/fake_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/google_default/credentials_generic.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/google_default/google_default_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/iam/iam_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/jwt/json_token.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/jwt/jwt_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/jwt/jwt_verifier.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/oauth2/oauth2_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/plugin/plugin_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/credentials/ssl/ssl_credentials.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/client_auth_filter.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/lb_targets_info.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/secure_endpoint.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/security_connector.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/security_handshaker.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/server_auth_filter.cc: $(OPENSSL_DEP)
+src/core/lib/security/transport/tsi_error.cc: $(OPENSSL_DEP)
+src/core/lib/security/util/json_util.cc: $(OPENSSL_DEP)
+src/core/lib/surface/init_secure.cc: $(OPENSSL_DEP)
+src/core/plugin_registry/grpc_cronet_plugin_registry.cc: $(OPENSSL_DEP)
+src/core/plugin_registry/grpc_plugin_registry.cc: $(OPENSSL_DEP)
+src/core/tsi/alts_transport_security.cc: $(OPENSSL_DEP)
+src/core/tsi/fake_transport_security.cc: $(OPENSSL_DEP)
+src/core/tsi/ssl_transport_security.cc: $(OPENSSL_DEP)
+src/core/tsi/transport_security.cc: $(OPENSSL_DEP)
+src/core/tsi/transport_security_adapter.cc: $(OPENSSL_DEP)
+src/core/tsi/transport_security_grpc.cc: $(OPENSSL_DEP)
src/cpp/client/cronet_credentials.cc: $(OPENSSL_DEP)
src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP)
src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP)
@@ -20208,17 +20588,17 @@ src/cpp/server/secure_server_credentials.cc: $(OPENSSL_DEP)
src/cpp/util/core_stats.cc: $(OPENSSL_DEP)
src/cpp/util/error_details.cc: $(OPENSSL_DEP)
src/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP)
-test/core/bad_client/bad_client.c: $(OPENSSL_DEP)
-test/core/bad_ssl/server_common.c: $(OPENSSL_DEP)
-test/core/end2end/data/client_certs.c: $(OPENSSL_DEP)
-test/core/end2end/data/server1_cert.c: $(OPENSSL_DEP)
-test/core/end2end/data/server1_key.c: $(OPENSSL_DEP)
-test/core/end2end/data/test_root_cert.c: $(OPENSSL_DEP)
-test/core/end2end/end2end_tests.c: $(OPENSSL_DEP)
-test/core/end2end/tests/call_creds.c: $(OPENSSL_DEP)
-test/core/security/oauth2_utils.c: $(OPENSSL_DEP)
-test/core/util/reconnect_server.c: $(OPENSSL_DEP)
-test/core/util/test_tcp_server.c: $(OPENSSL_DEP)
+test/core/bad_client/bad_client.cc: $(OPENSSL_DEP)
+test/core/bad_ssl/server_common.cc: $(OPENSSL_DEP)
+test/core/end2end/data/client_certs.cc: $(OPENSSL_DEP)
+test/core/end2end/data/server1_cert.cc: $(OPENSSL_DEP)
+test/core/end2end/data/server1_key.cc: $(OPENSSL_DEP)
+test/core/end2end/data/test_root_cert.cc: $(OPENSSL_DEP)
+test/core/end2end/end2end_tests.cc: $(OPENSSL_DEP)
+test/core/end2end/tests/call_creds.cc: $(OPENSSL_DEP)
+test/core/security/oauth2_utils.cc: $(OPENSSL_DEP)
+test/core/util/reconnect_server.cc: $(OPENSSL_DEP)
+test/core/util/test_tcp_server.cc: $(OPENSSL_DEP)
test/cpp/end2end/test_service_impl.cc: $(OPENSSL_DEP)
test/cpp/interop/client.cc: $(OPENSSL_DEP)
test/cpp/interop/client_helper.cc: $(OPENSSL_DEP)
diff --git a/OWNERS b/OWNERS
index 650d58f42c..33f319803b 100644
--- a/OWNERS
+++ b/OWNERS
@@ -13,5 +13,5 @@
# lead to a bus factor of one to changes to that code
@markdroth **/OWNERS
@nicolasnoble **/OWNERS
-@ctiller **/OWNERS
+@a11r **/OWNERS
diff --git a/README.md b/README.md
index 61479f34aa..fc72c7c1ba 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,8 @@
[![Join the chat at https://gitter.im/grpc/grpc](https://badges.gitter.im/grpc/grpc.svg)](https://gitter.im/grpc/grpc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-Copyright 2015 Google Inc.
+Copyright 2015
+[The gRPC Authors](https://github.com/grpc/grpc/blob/master/AUTHORS)
# Documentation
@@ -25,20 +26,20 @@ This repository contains source code for gRPC libraries for multiple languages w
Libraries in different languages may be in different states of development. We are seeking contributions for all of these libraries.
-| Language | Source | Status |
-|-------------------------|-------------------------------------|---------|
-| Shared C [core library] | [src/core](src/core) | 1.6 |
-| C++ | [src/cpp](src/cpp) | 1.6 |
-| Ruby | [src/ruby](src/ruby) | 1.6 |
-| NodeJS | [src/node](src/node) | 1.6 |
-| Python | [src/python](src/python) | 1.6 |
-| PHP | [src/php](src/php) | 1.6 |
-| C# | [src/csharp](src/csharp) | 1.6 |
-| Objective-C | [src/objective-c](src/objective-c) | 1.6 |
+| Language | Source |
+|-------------------------|-------------------------------------|
+| Shared C [core library] | [src/core](src/core) |
+| C++ | [src/cpp](src/cpp) |
+| Ruby | [src/ruby](src/ruby) |
+| Python | [src/python](src/python) |
+| PHP | [src/php](src/php) |
+| C# | [src/csharp](src/csharp) |
+| Objective-C | [src/objective-c](src/objective-c) |
Java source code is in the [grpc-java](http://github.com/grpc/grpc-java)
repository. Go source code is in the
-[grpc-go](http://github.com/grpc/grpc-go) repository.
+[grpc-go](http://github.com/grpc/grpc-go) repository. NodeJS source code is in the
+[grpc-node](https://github.com/grpc/grpc-node) repository.
See [MANIFEST.md](MANIFEST.md) for a listing of top-level items in the
repository.
diff --git a/Rakefile b/Rakefile
index 1e8960eab8..1eac37dc55 100755
--- a/Rakefile
+++ b/Rakefile
@@ -80,7 +80,9 @@ task 'dlls' do
grpc_config = ENV['GRPC_CONFIG'] || 'opt'
verbose = ENV['V'] || '0'
- env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result -DCARES_STATICLIB -Wno-error=conversion -Wno-incompatible-pointer-types -Wno-sign-compare -Wno-parentheses" '
+ env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DNTDDI_VERSION=0x06000000 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result -DCARES_STATICLIB -Wno-error=conversion -Wno-sign-compare -Wno-parentheses -Wno-format -DWIN32_LEAN_AND_MEAN" '
+ env += 'CFLAGS="-Wno-incompatible-pointer-types" '
+ env += 'CXXFLAGS="-std=c++11" '
env += 'LDFLAGS=-static '
env += 'SYSTEM=MINGW32 '
env += 'EMBED_ZLIB=true '
@@ -97,7 +99,7 @@ task 'dlls' do
env_comp = "CC=#{opt[:cross]}-gcc "
env_comp += "CXX=#{opt[:cross]}-g++ "
env_comp += "LD=#{opt[:cross]}-gcc "
- docker_for_windows "gem update --system && #{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}"
+ docker_for_windows "gem update --system --no-ri --no-doc && #{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}"
end
end
@@ -111,10 +113,15 @@ task 'gem:native' do
if RUBY_PLATFORM =~ /darwin/
FileUtils.touch 'grpc_c.32.ruby'
FileUtils.touch 'grpc_c.64.ruby'
- system "rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
+ unless '2.5' == /(\d+\.\d+)/.match(RUBY_VERSION).to_s
+ fail "rake gem:native (the rake task to build the binary packages) is being " \
+ "invoked on macos with ruby #{RUBY_VERSION}. The ruby macos artifact " \
+ "build should be running on ruby 2.5."
+ end
+ system "rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
else
Rake::Task['dlls'].execute
- docker_for_windows "gem update --system && bundle && rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
+ docker_for_windows "gem update --system --no-ri --no-doc && bundle && rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
end
end
diff --git a/WORKSPACE b/WORKSPACE
index bfb3a8c903..adce809162 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,94 +1,4 @@
-bind(
- name = "nanopb",
- actual = "//third_party/nanopb",
-)
+workspace(name = "com_github_grpc_grpc")
-bind(
- name = "libssl",
- actual = "@boringssl//:ssl",
-)
-
-bind(
- name = "zlib",
- actual = "@submodule_zlib//:z",
-)
-
-bind(
- name = "protobuf",
- actual = "@com_google_protobuf//:protobuf",
-)
-
-bind(
- name = "protobuf_clib",
- actual = "@com_google_protobuf//:protoc_lib",
-)
-
-bind(
- name = "protocol_compiler",
- actual = "@com_google_protobuf//:protoc",
-)
-
-bind(
- name = "cares",
- actual = "@submodule_cares//:ares",
-)
-
-bind(
- name = "gtest",
- actual = "@submodule_gtest//:gtest",
-)
-
-bind(
- name = "gmock",
- actual = "@submodule_gtest//:gmock",
-)
-
-bind(
- name = "benchmark",
- actual = "@submodule_benchmark//:benchmark",
-)
-
-bind(
- name = "gflags",
- actual = "@com_github_gflags_gflags//:gflags",
-)
-
-local_repository(
- name = "boringssl",
- path = "third_party/boringssl-with-bazel",
-)
-
-new_local_repository(
- name = "submodule_zlib",
- build_file = "third_party/zlib.BUILD",
- path = "third_party/zlib",
-)
-
-new_local_repository(
- name = "com_google_protobuf",
- build_file = "third_party/protobuf/BUILD",
- path = "third_party/protobuf",
-)
-
-new_local_repository(
- name = "submodule_gtest",
- build_file = "third_party/gtest.BUILD",
- path = "third_party/googletest",
-)
-
-local_repository(
- name = "com_github_gflags_gflags",
- path = "third_party/gflags",
-)
-
-new_local_repository(
- name = "submodule_benchmark",
- path = "third_party/benchmark",
- build_file = "third_party/benchmark.BUILD",
-)
-
-new_local_repository(
- name = "submodule_cares",
- path = "third_party/cares",
- build_file = "third_party/cares/cares.BUILD",
-)
+load("//bazel:grpc_deps.bzl", "grpc_deps")
+grpc_deps()
diff --git a/bazel/OWNERS b/bazel/OWNERS
index 8fc7502a91..613ba36be8 100644
--- a/bazel/OWNERS
+++ b/bazel/OWNERS
@@ -1,5 +1,6 @@
set noparent
@nicolasnoble
@dgquintas
-@ctiller
+@a11r
+@vjpai
diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl
index afc5543795..94781ed7ae 100644
--- a/bazel/cc_grpc_library.bzl
+++ b/bazel/cc_grpc_library.bzl
@@ -60,10 +60,10 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mo
if use_external:
# when this file is used by non-grpc projects
- grpc_deps = ["//external:grpc++", "//external:grpc++_codegen_proto",
+ grpc_deps = ["//external:grpc++_codegen_proto",
"//external:protobuf"]
else:
- grpc_deps = ["//:grpc++", "//:grpc++_codegen_proto", "//external:protobuf"]
+ grpc_deps = ["//:grpc++_codegen_proto", "//external:protobuf"]
native.cc_library(
name = name,
diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
index 6cfed6b0e7..3d3f738610 100644
--- a/bazel/grpc_build_system.bzl
+++ b/bazel/grpc_build_system.bzl
@@ -23,6 +23,33 @@
# each change must be ported from one to the other.
#
+# The set of pollers to test against if a test exercises polling
+POLLERS = ['epollex', 'epollsig', 'epoll1', 'poll', 'poll-cv']
+
+def _get_external_deps(external_deps):
+ ret = []
+ for dep in external_deps:
+ if dep == "nanopb":
+ ret += ["//third_party/nanopb"]
+ elif dep == "cares":
+ ret += select({"//:grpc_no_ares": [],
+ "//conditions:default": ["//external:cares"],})
+ else:
+ ret += ["//external:" + dep]
+ return ret
+
+def _maybe_update_cc_library_hdrs(hdrs):
+ ret = []
+ hdrs_to_update = {
+ "third_party/objective_c/Cronet/bidirectional_stream_c.h": "//third_party:objective_c/Cronet/bidirectional_stream_c.h",
+ }
+ for h in hdrs:
+ if h in hdrs_to_update.keys():
+ ret.append(hdrs_to_update[h])
+ else:
+ ret.append(h)
+ return ret
+
def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
external_deps = [], deps = [], standalone = False,
language = "C++", testonly = False, visibility = None,
@@ -33,8 +60,16 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
native.cc_library(
name = name,
srcs = srcs,
- hdrs = hdrs + public_hdrs,
- deps = deps + ["//external:" + dep for dep in external_deps],
+ defines = select({"//:grpc_no_ares": ["GRPC_ARES=0"],
+ "//conditions:default": [],}) +
+ select({"//:remote_execution": ["GRPC_PORT_ISOLATED_RUNTIME=1"],
+ "//conditions:default": [],}) +
+ select({"//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"],
+ "//:grpc_disallow_exceptions":
+ ["GRPC_ALLOW_EXCEPTIONS=0"],
+ "//conditions:default": [],}),
+ hdrs = _maybe_update_cc_library_hdrs(hdrs + public_hdrs),
+ deps = deps + _get_external_deps(external_deps),
copts = copts,
visibility = visibility,
testonly = testonly,
@@ -66,19 +101,35 @@ def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False,
generate_mock = generate_mock,
)
-def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++"):
+def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++"):
copts = []
if language.upper() == "C":
copts = ["-std=c99"]
- native.cc_test(
- name = name,
- srcs = srcs,
- args = args,
- data = data,
- deps = deps + ["//external:" + dep for dep in external_deps],
- copts = copts,
- linkopts = ["-pthread"],
- )
+ args = {
+ 'name': name,
+ 'srcs': srcs,
+ 'args': args,
+ 'data': data,
+ 'deps': deps + _get_external_deps(external_deps),
+ 'copts': copts,
+ 'linkopts': ["-pthread"],
+ }
+ if uses_polling:
+ native.cc_test(testonly=True, tags=['manual'], **args)
+ for poller in POLLERS:
+ native.sh_test(
+ name = name + '@poller=' + poller,
+ data = [name],
+ srcs = [
+ '//test/core/util:run_with_poller_sh',
+ ],
+ args = [
+ poller,
+ '$(location %s)' % name
+ ] + args['args'],
+ )
+ else:
+ native.cc_test(**args)
def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = []):
copts = []
@@ -91,7 +142,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da
data = data,
testonly = testonly,
linkshared = linkshared,
- deps = deps + ["//external:" + dep for dep in external_deps],
+ deps = deps + _get_external_deps(external_deps),
copts = copts,
linkopts = ["-pthread"] + linkopts,
)
diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl
new file mode 100644
index 0000000000..e465312a40
--- /dev/null
+++ b/bazel/grpc_deps.bzl
@@ -0,0 +1,129 @@
+"""Load dependencies needed to compile and test the grpc library as a 3rd-party consumer."""
+
+def grpc_deps():
+ """Loads dependencies need to compile and test the grpc library."""
+ native.bind(
+ name = "libssl",
+ actual = "@boringssl//:ssl",
+ )
+
+ native.bind(
+ name = "zlib",
+ actual = "@com_github_madler_zlib//:z",
+ )
+
+ native.bind(
+ name = "protobuf",
+ actual = "@com_google_protobuf//:protobuf",
+ )
+
+ native.bind(
+ name = "protobuf_clib",
+ actual = "@com_google_protobuf//:protoc_lib",
+ )
+
+ native.bind(
+ name = "protobuf_headers",
+ actual = "@com_google_protobuf//:protobuf_headers",
+ )
+
+ native.bind(
+ name = "protocol_compiler",
+ actual = "@com_google_protobuf//:protoc",
+ )
+
+ native.bind(
+ name = "cares",
+ actual = "@com_github_cares_cares//:ares",
+ )
+
+ native.bind(
+ name = "gtest",
+ actual = "@com_github_google_googletest//:gtest",
+ )
+
+ native.bind(
+ name = "gmock",
+ actual = "@com_github_google_googletest//:gmock",
+ )
+
+ native.bind(
+ name = "benchmark",
+ actual = "@com_github_google_benchmark//:benchmark",
+ )
+
+ native.bind(
+ name = "gflags",
+ actual = "@com_github_gflags_gflags//:gflags",
+ )
+
+ if "boringssl" not in native.existing_rules():
+ native.http_archive(
+ name = "boringssl",
+ # on the master-with-bazel branch
+ url = "https://boringssl.googlesource.com/boringssl/+archive/886e7d75368e3f4fab3f4d0d3584e4abfc557755.tar.gz",
+ )
+
+ if "com_github_madler_zlib" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_madler_zlib",
+ build_file = "@com_github_grpc_grpc//third_party:zlib.BUILD",
+ strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f",
+ url = "https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
+ )
+
+ if "com_google_protobuf" not in native.existing_rules():
+ native.http_archive(
+ name = "com_google_protobuf",
+ strip_prefix = "protobuf-2761122b810fe8861004ae785cc3ab39f384d342",
+ url = "https://github.com/google/protobuf/archive/2761122b810fe8861004ae785cc3ab39f384d342.tar.gz",
+ )
+
+ if "com_github_google_googletest" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_google_googletest",
+ build_file = "@com_github_grpc_grpc//third_party:gtest.BUILD",
+ strip_prefix = "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780",
+ url = "https://github.com/google/googletest/archive/ec44c6c1675c25b9827aacd08c02433cccde7780.tar.gz",
+ )
+
+ if "com_github_gflags_gflags" not in native.existing_rules():
+ native.http_archive(
+ name = "com_github_gflags_gflags",
+ strip_prefix = "gflags-30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e",
+ url = "https://github.com/gflags/gflags/archive/30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e.tar.gz",
+ )
+
+ if "com_github_google_benchmark" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_google_benchmark",
+ build_file = "@com_github_grpc_grpc//third_party:benchmark.BUILD",
+ strip_prefix = "benchmark-5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8",
+ url = "https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz",
+ )
+
+ if "com_github_cares_cares" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_cares_cares",
+ build_file = "@com_github_grpc_grpc//third_party:cares/cares.BUILD",
+ strip_prefix = "c-ares-3be1924221e1326df520f8498d704a5c4c8d0cce",
+ url = "https://github.com/c-ares/c-ares/archive/3be1924221e1326df520f8498d704a5c4c8d0cce.tar.gz",
+ )
+
+ if "com_google_absl" not in native.existing_rules():
+ native.http_archive(
+ name = "com_google_absl",
+ strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610",
+ url = "https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
+ )
+
+ if "com_github_bazelbuild_bazeltoolchains" not in native.existing_rules():
+ native.http_archive(
+ name = "com_github_bazelbuild_bazeltoolchains",
+ strip_prefix = "bazel-toolchains-af4681c3d19f063f090222ec3d04108c4e0ca255",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz",
+ "https://github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz",
+ ],
+ sha256 = "d58bb2d6c8603f600d522b6104d6192a65339aa26cbba9f11ff5c4b36dedb928",
+ )
diff --git a/binding.gyp b/binding.gyp
deleted file mode 100644
index b4f9038210..0000000000
--- a/binding.gyp
+++ /dev/null
@@ -1,991 +0,0 @@
-# GRPC Node gyp file
-# This currently builds the Node extension and dependencies
-# This file has been automatically generated from a template file.
-# Please look at the templates directory instead.
-# This file can be regenerated from the template by running
-# tools/buildgen/generate_projects.sh
-
-# 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.
-
-# Some of this file is built with the help of
-# https://n8.io/converting-a-c-library-to-gyp/
-{
- 'variables': {
- 'runtime%': 'node',
- # Some Node installations use the system installation of OpenSSL, and on
- # some systems, the system OpenSSL still does not have ALPN support. This
- # will let users recompile gRPC to work without ALPN.
- 'grpc_alpn%': 'true',
- # Indicates that the library should be built with gcov.
- 'grpc_gcov%': 'false',
- # Indicates that the library should be built with compatibility for musl
- # libc, so that it can run on Alpine Linux. This is only necessary if not
- # building on Alpine Linux
- 'grpc_alpine%': 'false'
- },
- 'target_defaults': {
- 'configurations': {
- 'Release': {
- 'cflags': [
- '-O2',
- ],
- 'defines': [
- 'NDEBUG',
- ],
- },
- 'Debug': {
- 'cflags': [
- '-O0',
- ],
- 'defines': [
- '_DEBUG',
- 'DEBUG',
- ],
- },
- },
- 'cflags': [
- '-g',
- '-Wall',
- '-Wextra',
- '-Werror',
- '-Wno-long-long',
- '-Wno-unused-parameter',
- '-DOSATOMIC_USE_INLINED=1',
- ],
- 'ldflags': [
- '-g',
- ],
- 'cflags_c': [
- '-Werror',
- '-std=c99'
- ],
- 'cflags_cc': [
- '-Werror',
- '-std=c++11'
- ],
- 'include_dirs': [
- '.',
- 'include'
- ],
- 'defines': [
- 'GPR_BACKWARDS_COMPATIBILITY_MODE',
- 'GRPC_ARES=0',
- 'GRPC_UV'
- ],
- 'conditions': [
- ['grpc_gcov=="true"', {
- 'cflags': [
- '-O0',
- '-fprofile-arcs',
- '-ftest-coverage',
- '-Wno-return-type',
- ],
- 'defines': [
- '_DEBUG',
- 'DEBUG',
- 'GPR_GCOV',
- ],
- 'ldflags': [
- '-fprofile-arcs',
- '-ftest-coverage',
- '-rdynamic',
- ],
- }],
- ['grpc_alpine=="true"', {
- 'defines': [
- 'GPR_MUSL_LIBC_COMPAT'
- ]
- }],
- ['OS!="win" and runtime=="electron"', {
- "defines": [
- 'OPENSSL_NO_THREADS'
- ]
- }],
- # This is the condition for using boringssl
- ['OS=="win" or runtime=="electron"', {
- "include_dirs": [
- "third_party/boringssl/include"
- ],
- "defines": [
- 'OPENSSL_NO_ASM'
- ]
- }, {
- 'conditions': [
- ["target_arch=='ia32'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
- }],
- ["target_arch=='x64'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
- }],
- ["target_arch=='arm'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
- }],
- ['grpc_alpn=="true"', {
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=1'
- ],
- }, {
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=0'
- ],
- }]
- ],
- 'include_dirs': [
- '<(node_root_dir)/deps/openssl/openssl/include',
- ]
- }],
- ['OS == "win"', {
- "include_dirs": [
- "third_party/zlib",
- "third_party/cares/cares"
- ],
- "defines": [
- '_WIN32_WINNT=0x0600',
- 'WIN32_LEAN_AND_MEAN',
- '_HAS_EXCEPTIONS=0',
- 'UNICODE',
- '_UNICODE',
- 'NOMINMAX',
- ],
- "msvs_settings": {
- 'VCCLCompilerTool': {
- 'RuntimeLibrary': 1, # static debug
- }
- },
- "libraries": [
- "ws2_32"
- ]
- }, { # OS != "win"
- 'include_dirs': [
- '<(node_root_dir)/deps/zlib',
- '<(node_root_dir)/deps/cares/include'
- ]
- }],
- ['OS == "mac"', {
- 'xcode_settings': {
- 'OTHER_CFLAGS': [
- '-g',
- '-Wall',
- '-Wextra',
- '-Werror',
- '-Wno-long-long',
- '-Wno-unused-parameter',
- '-DOSATOMIC_USE_INLINED=1',
- ],
- 'OTHER_CPLUSPLUSFLAGS': [
- '-g',
- '-Wall',
- '-Wextra',
- '-Werror',
- '-Wno-long-long',
- '-Wno-unused-parameter',
- '-DOSATOMIC_USE_INLINED=1',
- '-stdlib=libc++',
- '-std=c++11',
- '-Wno-error=deprecated-declarations'
- ],
- },
- }]
- ]
- },
- 'conditions': [
- ['OS=="win" or runtime=="electron"', {
- 'targets': [
- {
- 'target_name': 'boringssl',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- ],
- 'sources': [
- 'src/boringssl/err_data.c',
- 'third_party/boringssl/crypto/aes/aes.c',
- 'third_party/boringssl/crypto/aes/key_wrap.c',
- 'third_party/boringssl/crypto/aes/mode_wrappers.c',
- 'third_party/boringssl/crypto/asn1/a_bitstr.c',
- 'third_party/boringssl/crypto/asn1/a_bool.c',
- 'third_party/boringssl/crypto/asn1/a_d2i_fp.c',
- 'third_party/boringssl/crypto/asn1/a_dup.c',
- 'third_party/boringssl/crypto/asn1/a_enum.c',
- 'third_party/boringssl/crypto/asn1/a_gentm.c',
- 'third_party/boringssl/crypto/asn1/a_i2d_fp.c',
- 'third_party/boringssl/crypto/asn1/a_int.c',
- 'third_party/boringssl/crypto/asn1/a_mbstr.c',
- 'third_party/boringssl/crypto/asn1/a_object.c',
- 'third_party/boringssl/crypto/asn1/a_octet.c',
- 'third_party/boringssl/crypto/asn1/a_print.c',
- 'third_party/boringssl/crypto/asn1/a_strnid.c',
- 'third_party/boringssl/crypto/asn1/a_time.c',
- 'third_party/boringssl/crypto/asn1/a_type.c',
- 'third_party/boringssl/crypto/asn1/a_utctm.c',
- 'third_party/boringssl/crypto/asn1/a_utf8.c',
- 'third_party/boringssl/crypto/asn1/asn1_lib.c',
- 'third_party/boringssl/crypto/asn1/asn1_par.c',
- 'third_party/boringssl/crypto/asn1/asn_pack.c',
- 'third_party/boringssl/crypto/asn1/f_enum.c',
- 'third_party/boringssl/crypto/asn1/f_int.c',
- 'third_party/boringssl/crypto/asn1/f_string.c',
- 'third_party/boringssl/crypto/asn1/t_bitst.c',
- 'third_party/boringssl/crypto/asn1/tasn_dec.c',
- 'third_party/boringssl/crypto/asn1/tasn_enc.c',
- 'third_party/boringssl/crypto/asn1/tasn_fre.c',
- 'third_party/boringssl/crypto/asn1/tasn_new.c',
- 'third_party/boringssl/crypto/asn1/tasn_typ.c',
- 'third_party/boringssl/crypto/asn1/tasn_utl.c',
- 'third_party/boringssl/crypto/asn1/time_support.c',
- 'third_party/boringssl/crypto/asn1/x_bignum.c',
- 'third_party/boringssl/crypto/asn1/x_long.c',
- 'third_party/boringssl/crypto/base64/base64.c',
- 'third_party/boringssl/crypto/bio/bio.c',
- 'third_party/boringssl/crypto/bio/bio_mem.c',
- 'third_party/boringssl/crypto/bio/connect.c',
- 'third_party/boringssl/crypto/bio/fd.c',
- 'third_party/boringssl/crypto/bio/file.c',
- 'third_party/boringssl/crypto/bio/hexdump.c',
- 'third_party/boringssl/crypto/bio/pair.c',
- 'third_party/boringssl/crypto/bio/printf.c',
- 'third_party/boringssl/crypto/bio/socket.c',
- 'third_party/boringssl/crypto/bio/socket_helper.c',
- 'third_party/boringssl/crypto/bn/add.c',
- 'third_party/boringssl/crypto/bn/asm/x86_64-gcc.c',
- 'third_party/boringssl/crypto/bn/bn.c',
- 'third_party/boringssl/crypto/bn/bn_asn1.c',
- 'third_party/boringssl/crypto/bn/cmp.c',
- 'third_party/boringssl/crypto/bn/convert.c',
- 'third_party/boringssl/crypto/bn/ctx.c',
- 'third_party/boringssl/crypto/bn/div.c',
- 'third_party/boringssl/crypto/bn/exponentiation.c',
- 'third_party/boringssl/crypto/bn/gcd.c',
- 'third_party/boringssl/crypto/bn/generic.c',
- 'third_party/boringssl/crypto/bn/kronecker.c',
- 'third_party/boringssl/crypto/bn/montgomery.c',
- 'third_party/boringssl/crypto/bn/montgomery_inv.c',
- 'third_party/boringssl/crypto/bn/mul.c',
- 'third_party/boringssl/crypto/bn/prime.c',
- 'third_party/boringssl/crypto/bn/random.c',
- 'third_party/boringssl/crypto/bn/rsaz_exp.c',
- 'third_party/boringssl/crypto/bn/shift.c',
- 'third_party/boringssl/crypto/bn/sqrt.c',
- 'third_party/boringssl/crypto/buf/buf.c',
- 'third_party/boringssl/crypto/bytestring/asn1_compat.c',
- 'third_party/boringssl/crypto/bytestring/ber.c',
- 'third_party/boringssl/crypto/bytestring/cbb.c',
- 'third_party/boringssl/crypto/bytestring/cbs.c',
- 'third_party/boringssl/crypto/chacha/chacha.c',
- 'third_party/boringssl/crypto/cipher/aead.c',
- 'third_party/boringssl/crypto/cipher/cipher.c',
- 'third_party/boringssl/crypto/cipher/derive_key.c',
- 'third_party/boringssl/crypto/cipher/e_aes.c',
- 'third_party/boringssl/crypto/cipher/e_chacha20poly1305.c',
- 'third_party/boringssl/crypto/cipher/e_des.c',
- 'third_party/boringssl/crypto/cipher/e_null.c',
- 'third_party/boringssl/crypto/cipher/e_rc2.c',
- 'third_party/boringssl/crypto/cipher/e_rc4.c',
- 'third_party/boringssl/crypto/cipher/e_ssl3.c',
- 'third_party/boringssl/crypto/cipher/e_tls.c',
- 'third_party/boringssl/crypto/cipher/tls_cbc.c',
- 'third_party/boringssl/crypto/cmac/cmac.c',
- 'third_party/boringssl/crypto/conf/conf.c',
- 'third_party/boringssl/crypto/cpu-aarch64-linux.c',
- 'third_party/boringssl/crypto/cpu-arm-linux.c',
- 'third_party/boringssl/crypto/cpu-arm.c',
- 'third_party/boringssl/crypto/cpu-intel.c',
- 'third_party/boringssl/crypto/cpu-ppc64le.c',
- 'third_party/boringssl/crypto/crypto.c',
- 'third_party/boringssl/crypto/curve25519/curve25519.c',
- 'third_party/boringssl/crypto/curve25519/spake25519.c',
- 'third_party/boringssl/crypto/curve25519/x25519-x86_64.c',
- 'third_party/boringssl/crypto/des/des.c',
- 'third_party/boringssl/crypto/dh/check.c',
- 'third_party/boringssl/crypto/dh/dh.c',
- 'third_party/boringssl/crypto/dh/dh_asn1.c',
- 'third_party/boringssl/crypto/dh/params.c',
- 'third_party/boringssl/crypto/digest/digest.c',
- 'third_party/boringssl/crypto/digest/digests.c',
- 'third_party/boringssl/crypto/dsa/dsa.c',
- 'third_party/boringssl/crypto/dsa/dsa_asn1.c',
- 'third_party/boringssl/crypto/ec/ec.c',
- 'third_party/boringssl/crypto/ec/ec_asn1.c',
- 'third_party/boringssl/crypto/ec/ec_key.c',
- 'third_party/boringssl/crypto/ec/ec_montgomery.c',
- 'third_party/boringssl/crypto/ec/oct.c',
- 'third_party/boringssl/crypto/ec/p224-64.c',
- 'third_party/boringssl/crypto/ec/p256-64.c',
- 'third_party/boringssl/crypto/ec/p256-x86_64.c',
- 'third_party/boringssl/crypto/ec/simple.c',
- 'third_party/boringssl/crypto/ec/util-64.c',
- 'third_party/boringssl/crypto/ec/wnaf.c',
- 'third_party/boringssl/crypto/ecdh/ecdh.c',
- 'third_party/boringssl/crypto/ecdsa/ecdsa.c',
- 'third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c',
- 'third_party/boringssl/crypto/engine/engine.c',
- 'third_party/boringssl/crypto/err/err.c',
- 'third_party/boringssl/crypto/evp/digestsign.c',
- 'third_party/boringssl/crypto/evp/evp.c',
- 'third_party/boringssl/crypto/evp/evp_asn1.c',
- 'third_party/boringssl/crypto/evp/evp_ctx.c',
- 'third_party/boringssl/crypto/evp/p_dsa_asn1.c',
- 'third_party/boringssl/crypto/evp/p_ec.c',
- 'third_party/boringssl/crypto/evp/p_ec_asn1.c',
- 'third_party/boringssl/crypto/evp/p_rsa.c',
- 'third_party/boringssl/crypto/evp/p_rsa_asn1.c',
- 'third_party/boringssl/crypto/evp/pbkdf.c',
- 'third_party/boringssl/crypto/evp/print.c',
- 'third_party/boringssl/crypto/evp/sign.c',
- 'third_party/boringssl/crypto/ex_data.c',
- 'third_party/boringssl/crypto/hkdf/hkdf.c',
- 'third_party/boringssl/crypto/hmac/hmac.c',
- 'third_party/boringssl/crypto/lhash/lhash.c',
- 'third_party/boringssl/crypto/md4/md4.c',
- 'third_party/boringssl/crypto/md5/md5.c',
- 'third_party/boringssl/crypto/mem.c',
- 'third_party/boringssl/crypto/modes/cbc.c',
- 'third_party/boringssl/crypto/modes/cfb.c',
- 'third_party/boringssl/crypto/modes/ctr.c',
- 'third_party/boringssl/crypto/modes/gcm.c',
- 'third_party/boringssl/crypto/modes/ofb.c',
- 'third_party/boringssl/crypto/modes/polyval.c',
- 'third_party/boringssl/crypto/obj/obj.c',
- 'third_party/boringssl/crypto/obj/obj_xref.c',
- 'third_party/boringssl/crypto/pem/pem_all.c',
- 'third_party/boringssl/crypto/pem/pem_info.c',
- 'third_party/boringssl/crypto/pem/pem_lib.c',
- 'third_party/boringssl/crypto/pem/pem_oth.c',
- 'third_party/boringssl/crypto/pem/pem_pk8.c',
- 'third_party/boringssl/crypto/pem/pem_pkey.c',
- 'third_party/boringssl/crypto/pem/pem_x509.c',
- 'third_party/boringssl/crypto/pem/pem_xaux.c',
- 'third_party/boringssl/crypto/pkcs8/p5_pbev2.c',
- 'third_party/boringssl/crypto/pkcs8/p8_pkey.c',
- 'third_party/boringssl/crypto/pkcs8/pkcs8.c',
- 'third_party/boringssl/crypto/poly1305/poly1305.c',
- 'third_party/boringssl/crypto/poly1305/poly1305_arm.c',
- 'third_party/boringssl/crypto/poly1305/poly1305_vec.c',
- 'third_party/boringssl/crypto/pool/pool.c',
- 'third_party/boringssl/crypto/rand/deterministic.c',
- 'third_party/boringssl/crypto/rand/fuchsia.c',
- 'third_party/boringssl/crypto/rand/rand.c',
- 'third_party/boringssl/crypto/rand/urandom.c',
- 'third_party/boringssl/crypto/rand/windows.c',
- 'third_party/boringssl/crypto/rc4/rc4.c',
- 'third_party/boringssl/crypto/refcount_c11.c',
- 'third_party/boringssl/crypto/refcount_lock.c',
- 'third_party/boringssl/crypto/rsa/blinding.c',
- 'third_party/boringssl/crypto/rsa/padding.c',
- 'third_party/boringssl/crypto/rsa/rsa.c',
- 'third_party/boringssl/crypto/rsa/rsa_asn1.c',
- 'third_party/boringssl/crypto/rsa/rsa_impl.c',
- 'third_party/boringssl/crypto/sha/sha1-altivec.c',
- 'third_party/boringssl/crypto/sha/sha1.c',
- 'third_party/boringssl/crypto/sha/sha256.c',
- 'third_party/boringssl/crypto/sha/sha512.c',
- 'third_party/boringssl/crypto/stack/stack.c',
- 'third_party/boringssl/crypto/thread.c',
- 'third_party/boringssl/crypto/thread_none.c',
- 'third_party/boringssl/crypto/thread_pthread.c',
- 'third_party/boringssl/crypto/thread_win.c',
- 'third_party/boringssl/crypto/x509/a_digest.c',
- 'third_party/boringssl/crypto/x509/a_sign.c',
- 'third_party/boringssl/crypto/x509/a_strex.c',
- 'third_party/boringssl/crypto/x509/a_verify.c',
- 'third_party/boringssl/crypto/x509/algorithm.c',
- 'third_party/boringssl/crypto/x509/asn1_gen.c',
- 'third_party/boringssl/crypto/x509/by_dir.c',
- 'third_party/boringssl/crypto/x509/by_file.c',
- 'third_party/boringssl/crypto/x509/i2d_pr.c',
- 'third_party/boringssl/crypto/x509/pkcs7.c',
- 'third_party/boringssl/crypto/x509/rsa_pss.c',
- 'third_party/boringssl/crypto/x509/t_crl.c',
- 'third_party/boringssl/crypto/x509/t_req.c',
- 'third_party/boringssl/crypto/x509/t_x509.c',
- 'third_party/boringssl/crypto/x509/t_x509a.c',
- 'third_party/boringssl/crypto/x509/x509.c',
- 'third_party/boringssl/crypto/x509/x509_att.c',
- 'third_party/boringssl/crypto/x509/x509_cmp.c',
- 'third_party/boringssl/crypto/x509/x509_d2.c',
- 'third_party/boringssl/crypto/x509/x509_def.c',
- 'third_party/boringssl/crypto/x509/x509_ext.c',
- 'third_party/boringssl/crypto/x509/x509_lu.c',
- 'third_party/boringssl/crypto/x509/x509_obj.c',
- 'third_party/boringssl/crypto/x509/x509_r2x.c',
- 'third_party/boringssl/crypto/x509/x509_req.c',
- 'third_party/boringssl/crypto/x509/x509_set.c',
- 'third_party/boringssl/crypto/x509/x509_trs.c',
- 'third_party/boringssl/crypto/x509/x509_txt.c',
- 'third_party/boringssl/crypto/x509/x509_v3.c',
- 'third_party/boringssl/crypto/x509/x509_vfy.c',
- 'third_party/boringssl/crypto/x509/x509_vpm.c',
- 'third_party/boringssl/crypto/x509/x509cset.c',
- 'third_party/boringssl/crypto/x509/x509name.c',
- 'third_party/boringssl/crypto/x509/x509rset.c',
- 'third_party/boringssl/crypto/x509/x509spki.c',
- 'third_party/boringssl/crypto/x509/x509type.c',
- 'third_party/boringssl/crypto/x509/x_algor.c',
- 'third_party/boringssl/crypto/x509/x_all.c',
- 'third_party/boringssl/crypto/x509/x_attrib.c',
- 'third_party/boringssl/crypto/x509/x_crl.c',
- 'third_party/boringssl/crypto/x509/x_exten.c',
- 'third_party/boringssl/crypto/x509/x_info.c',
- 'third_party/boringssl/crypto/x509/x_name.c',
- 'third_party/boringssl/crypto/x509/x_pkey.c',
- 'third_party/boringssl/crypto/x509/x_pubkey.c',
- 'third_party/boringssl/crypto/x509/x_req.c',
- 'third_party/boringssl/crypto/x509/x_sig.c',
- 'third_party/boringssl/crypto/x509/x_spki.c',
- 'third_party/boringssl/crypto/x509/x_val.c',
- 'third_party/boringssl/crypto/x509/x_x509.c',
- 'third_party/boringssl/crypto/x509/x_x509a.c',
- 'third_party/boringssl/crypto/x509v3/pcy_cache.c',
- 'third_party/boringssl/crypto/x509v3/pcy_data.c',
- 'third_party/boringssl/crypto/x509v3/pcy_lib.c',
- 'third_party/boringssl/crypto/x509v3/pcy_map.c',
- 'third_party/boringssl/crypto/x509v3/pcy_node.c',
- 'third_party/boringssl/crypto/x509v3/pcy_tree.c',
- 'third_party/boringssl/crypto/x509v3/v3_akey.c',
- 'third_party/boringssl/crypto/x509v3/v3_akeya.c',
- 'third_party/boringssl/crypto/x509v3/v3_alt.c',
- 'third_party/boringssl/crypto/x509v3/v3_bcons.c',
- 'third_party/boringssl/crypto/x509v3/v3_bitst.c',
- 'third_party/boringssl/crypto/x509v3/v3_conf.c',
- 'third_party/boringssl/crypto/x509v3/v3_cpols.c',
- 'third_party/boringssl/crypto/x509v3/v3_crld.c',
- 'third_party/boringssl/crypto/x509v3/v3_enum.c',
- 'third_party/boringssl/crypto/x509v3/v3_extku.c',
- 'third_party/boringssl/crypto/x509v3/v3_genn.c',
- 'third_party/boringssl/crypto/x509v3/v3_ia5.c',
- 'third_party/boringssl/crypto/x509v3/v3_info.c',
- 'third_party/boringssl/crypto/x509v3/v3_int.c',
- 'third_party/boringssl/crypto/x509v3/v3_lib.c',
- 'third_party/boringssl/crypto/x509v3/v3_ncons.c',
- 'third_party/boringssl/crypto/x509v3/v3_pci.c',
- 'third_party/boringssl/crypto/x509v3/v3_pcia.c',
- 'third_party/boringssl/crypto/x509v3/v3_pcons.c',
- 'third_party/boringssl/crypto/x509v3/v3_pku.c',
- 'third_party/boringssl/crypto/x509v3/v3_pmaps.c',
- 'third_party/boringssl/crypto/x509v3/v3_prn.c',
- 'third_party/boringssl/crypto/x509v3/v3_purp.c',
- 'third_party/boringssl/crypto/x509v3/v3_skey.c',
- 'third_party/boringssl/crypto/x509v3/v3_sxnet.c',
- 'third_party/boringssl/crypto/x509v3/v3_utl.c',
- 'third_party/boringssl/ssl/bio_ssl.c',
- 'third_party/boringssl/ssl/custom_extensions.c',
- 'third_party/boringssl/ssl/d1_both.c',
- 'third_party/boringssl/ssl/d1_lib.c',
- 'third_party/boringssl/ssl/d1_pkt.c',
- 'third_party/boringssl/ssl/d1_srtp.c',
- 'third_party/boringssl/ssl/dtls_method.c',
- 'third_party/boringssl/ssl/dtls_record.c',
- 'third_party/boringssl/ssl/handshake_client.c',
- 'third_party/boringssl/ssl/handshake_server.c',
- 'third_party/boringssl/ssl/s3_both.c',
- 'third_party/boringssl/ssl/s3_lib.c',
- 'third_party/boringssl/ssl/s3_pkt.c',
- 'third_party/boringssl/ssl/ssl_aead_ctx.c',
- 'third_party/boringssl/ssl/ssl_asn1.c',
- 'third_party/boringssl/ssl/ssl_buffer.c',
- 'third_party/boringssl/ssl/ssl_cert.c',
- 'third_party/boringssl/ssl/ssl_cipher.c',
- 'third_party/boringssl/ssl/ssl_ecdh.c',
- 'third_party/boringssl/ssl/ssl_file.c',
- 'third_party/boringssl/ssl/ssl_lib.c',
- 'third_party/boringssl/ssl/ssl_privkey.c',
- 'third_party/boringssl/ssl/ssl_privkey_cc.cc',
- 'third_party/boringssl/ssl/ssl_session.c',
- 'third_party/boringssl/ssl/ssl_stat.c',
- 'third_party/boringssl/ssl/ssl_transcript.c',
- 'third_party/boringssl/ssl/ssl_x509.c',
- 'third_party/boringssl/ssl/t1_enc.c',
- 'third_party/boringssl/ssl/t1_lib.c',
- 'third_party/boringssl/ssl/tls13_both.c',
- 'third_party/boringssl/ssl/tls13_client.c',
- 'third_party/boringssl/ssl/tls13_enc.c',
- 'third_party/boringssl/ssl/tls13_server.c',
- 'third_party/boringssl/ssl/tls_method.c',
- 'third_party/boringssl/ssl/tls_record.c',
- ],
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ]
- },
- ],
- }],
- ['OS == "win" and runtime!="electron"', {
- 'targets': [
- {
- # IMPORTANT WINDOWS BUILD INFORMATION
- # This library does not build on Windows without modifying the Node
- # development packages that node-gyp downloads in order to build.
- # Due to https://github.com/nodejs/node/issues/4932, the headers for
- # BoringSSL conflict with the OpenSSL headers included by default
- # when including the Node headers. The remedy for this is to remove
- # the OpenSSL headers, from the downloaded Node development package,
- # which is typically located in `.node-gyp` in your home directory.
- #
- # This is not true of Electron, which does not have OpenSSL headers.
- 'target_name': 'WINDOWS_BUILD_WARNING',
- 'rules': [
- {
- 'rule_name': 'WINDOWS_BUILD_WARNING',
- 'extension': 'S',
- 'inputs': [
- 'package.json'
- ],
- 'outputs': [
- 'ignore_this_part'
- ],
- 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
- }
- ]
- },
- ]
- }],
- ['OS == "win"', {
- 'targets': [
- # Only want to compile zlib under Windows
- {
- 'target_name': 'z',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- ],
- 'sources': [
- 'third_party/zlib/adler32.c',
- 'third_party/zlib/compress.c',
- 'third_party/zlib/crc32.c',
- 'third_party/zlib/deflate.c',
- 'third_party/zlib/gzclose.c',
- 'third_party/zlib/gzlib.c',
- 'third_party/zlib/gzread.c',
- 'third_party/zlib/gzwrite.c',
- 'third_party/zlib/infback.c',
- 'third_party/zlib/inffast.c',
- 'third_party/zlib/inflate.c',
- 'third_party/zlib/inftrees.c',
- 'third_party/zlib/trees.c',
- 'third_party/zlib/uncompr.c',
- 'third_party/zlib/zutil.c',
- ]
- },
- ]
- }]
- ],
- 'targets': [
- {
- 'target_name': 'gpr',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- ],
- 'sources': [
- 'src/core/lib/profiling/basic_timers.c',
- 'src/core/lib/profiling/stap_timers.c',
- 'src/core/lib/support/alloc.c',
- 'src/core/lib/support/arena.c',
- 'src/core/lib/support/atm.c',
- 'src/core/lib/support/avl.c',
- 'src/core/lib/support/backoff.c',
- 'src/core/lib/support/cmdline.c',
- 'src/core/lib/support/cpu_iphone.c',
- 'src/core/lib/support/cpu_linux.c',
- 'src/core/lib/support/cpu_posix.c',
- 'src/core/lib/support/cpu_windows.c',
- 'src/core/lib/support/env_linux.c',
- 'src/core/lib/support/env_posix.c',
- 'src/core/lib/support/env_windows.c',
- 'src/core/lib/support/histogram.c',
- 'src/core/lib/support/host_port.c',
- 'src/core/lib/support/log.c',
- 'src/core/lib/support/log_android.c',
- 'src/core/lib/support/log_linux.c',
- 'src/core/lib/support/log_posix.c',
- 'src/core/lib/support/log_windows.c',
- 'src/core/lib/support/mpscq.c',
- 'src/core/lib/support/murmur_hash.c',
- 'src/core/lib/support/stack_lockfree.c',
- 'src/core/lib/support/string.c',
- 'src/core/lib/support/string_posix.c',
- 'src/core/lib/support/string_util_windows.c',
- 'src/core/lib/support/string_windows.c',
- 'src/core/lib/support/subprocess_posix.c',
- 'src/core/lib/support/subprocess_windows.c',
- 'src/core/lib/support/sync.c',
- 'src/core/lib/support/sync_posix.c',
- 'src/core/lib/support/sync_windows.c',
- 'src/core/lib/support/thd.c',
- 'src/core/lib/support/thd_posix.c',
- 'src/core/lib/support/thd_windows.c',
- 'src/core/lib/support/time.c',
- 'src/core/lib/support/time_posix.c',
- 'src/core/lib/support/time_precise.c',
- 'src/core/lib/support/time_windows.c',
- 'src/core/lib/support/tls_pthread.c',
- 'src/core/lib/support/tmpfile_msys.c',
- 'src/core/lib/support/tmpfile_posix.c',
- 'src/core/lib/support/tmpfile_windows.c',
- 'src/core/lib/support/wrap_memcpy.c',
- ],
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ]
- },
- {
- 'target_name': 'grpc',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- 'gpr',
- ],
- 'sources': [
- 'src/core/lib/surface/init.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
- 'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
- 'src/core/lib/http/httpcli_security_connector.c',
- 'src/core/lib/security/context/security_context.c',
- 'src/core/lib/security/credentials/composite/composite_credentials.c',
- 'src/core/lib/security/credentials/credentials.c',
- 'src/core/lib/security/credentials/credentials_metadata.c',
- 'src/core/lib/security/credentials/fake/fake_credentials.c',
- 'src/core/lib/security/credentials/google_default/credentials_generic.c',
- 'src/core/lib/security/credentials/google_default/google_default_credentials.c',
- 'src/core/lib/security/credentials/iam/iam_credentials.c',
- 'src/core/lib/security/credentials/jwt/json_token.c',
- 'src/core/lib/security/credentials/jwt/jwt_credentials.c',
- 'src/core/lib/security/credentials/jwt/jwt_verifier.c',
- 'src/core/lib/security/credentials/oauth2/oauth2_credentials.c',
- 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
- 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
- 'src/core/lib/security/transport/client_auth_filter.c',
- 'src/core/lib/security/transport/lb_targets_info.c',
- 'src/core/lib/security/transport/secure_endpoint.c',
- 'src/core/lib/security/transport/security_connector.c',
- 'src/core/lib/security/transport/security_handshaker.c',
- 'src/core/lib/security/transport/server_auth_filter.c',
- 'src/core/lib/security/transport/tsi_error.c',
- 'src/core/lib/security/util/json_util.c',
- 'src/core/lib/surface/init_secure.c',
- 'src/core/tsi/fake_transport_security.c',
- 'src/core/tsi/gts_transport_security.c',
- 'src/core/tsi/ssl_transport_security.c',
- 'src/core/tsi/transport_security_grpc.c',
- 'src/core/tsi/transport_security.c',
- 'src/core/tsi/transport_security_adapter.c',
- 'src/core/ext/transport/chttp2/server/chttp2_server.c',
- 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/chttp2/client/chttp2_connector.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
- 'src/core/ext/transport/inproc/inproc_plugin.c',
- 'src/core/ext/transport/inproc/inproc_transport.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
- 'third_party/nanopb/pb_common.c',
- 'third_party/nanopb/pb_decode.c',
- 'third_party/nanopb/pb_encode.c',
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c',
- 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c',
- 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c',
- 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c',
- 'src/core/ext/census/base_resources.c',
- 'src/core/ext/census/context.c',
- 'src/core/ext/census/gen/census.pb.c',
- 'src/core/ext/census/gen/trace_context.pb.c',
- 'src/core/ext/census/grpc_context.c',
- 'src/core/ext/census/grpc_filter.c',
- 'src/core/ext/census/grpc_plugin.c',
- 'src/core/ext/census/initialize.c',
- 'src/core/ext/census/intrusive_hash_map.c',
- 'src/core/ext/census/mlog.c',
- 'src/core/ext/census/operation.c',
- 'src/core/ext/census/placeholders.c',
- 'src/core/ext/census/resource.c',
- 'src/core/ext/census/trace_context.c',
- 'src/core/ext/census/tracing.c',
- 'src/core/ext/filters/max_age/max_age_filter.c',
- 'src/core/ext/filters/message_size/message_size_filter.c',
- 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c',
- 'src/core/ext/filters/workarounds/workaround_utils.c',
- 'src/core/plugin_registry/grpc_plugin_registry.c',
- ],
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ]
- },
- {
- 'include_dirs': [
- "<!(node -e \"require('nan')\")"
- ],
- 'cflags': [
- '-pthread',
- '-zdefs',
- '-Wno-error=deprecated-declarations'
- ],
- "conditions": [
- ['OS=="win" or runtime=="electron"', {
- 'dependencies': [
- "boringssl",
- ]
- }],
- ['OS=="win"', {
- 'dependencies': [
- "z",
- ]
- }],
- ['OS=="linux"', {
- 'ldflags': [
- '-Wl,-wrap,memcpy'
- ]
- }],
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ],
- "target_name": "grpc_node",
- "sources": [
- "src/node/ext/byte_buffer.cc",
- "src/node/ext/call.cc",
- "src/node/ext/call_credentials.cc",
- "src/node/ext/channel.cc",
- "src/node/ext/channel_credentials.cc",
- "src/node/ext/completion_queue.cc",
- "src/node/ext/node_grpc.cc",
- "src/node/ext/server.cc",
- "src/node/ext/server_credentials.cc",
- "src/node/ext/slice.cc",
- "src/node/ext/timeval.cc",
- ],
- "dependencies": [
- "grpc",
- "gpr",
- ]
- },
- {
- "target_name": "action_after_build",
- "type": "none",
- "dependencies": [ "<(module_name)" ],
- "copies": [
- {
- "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
- "destination": "<(module_path)"
- }
- ]
- }
- ]
-}
diff --git a/build.yaml b/build.yaml
index 9b5aacc4c8..ab21875b39 100644
--- a/build.yaml
+++ b/build.yaml
@@ -13,99 +13,63 @@ settings:
'#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: gambit
- version: 1.7.0-dev
+ g_stands_for: glamorous
+ version: 1.10.0-dev
filegroups:
- name: census
public_headers:
- include/grpc/census.h
- headers:
- - src/core/ext/census/aggregation.h
- - src/core/ext/census/base_resources.h
- - src/core/ext/census/census_interface.h
- - src/core/ext/census/census_rpc_stats.h
- - src/core/ext/census/gen/census.pb.h
- - src/core/ext/census/gen/trace_context.pb.h
- - src/core/ext/census/grpc_filter.h
- - src/core/ext/census/intrusive_hash_map.h
- - src/core/ext/census/intrusive_hash_map_internal.h
- - src/core/ext/census/mlog.h
- - src/core/ext/census/resource.h
- - src/core/ext/census/rpc_metric_id.h
- - src/core/ext/census/trace_context.h
- - src/core/ext/census/trace_label.h
- - src/core/ext/census/trace_propagation.h
- - src/core/ext/census/trace_status.h
- - src/core/ext/census/trace_string.h
- - src/core/ext/census/tracing.h
- src:
- - src/core/ext/census/base_resources.c
- - src/core/ext/census/context.c
- - src/core/ext/census/gen/census.pb.c
- - src/core/ext/census/gen/trace_context.pb.c
- - src/core/ext/census/grpc_context.c
- - src/core/ext/census/grpc_filter.c
- - src/core/ext/census/grpc_plugin.c
- - src/core/ext/census/initialize.c
- - src/core/ext/census/intrusive_hash_map.c
- - src/core/ext/census/mlog.c
- - src/core/ext/census/operation.c
- - src/core/ext/census/placeholders.c
- - src/core/ext/census/resource.c
- - src/core/ext/census/trace_context.c
- - src/core/ext/census/tracing.c
- plugin: census_grpc_plugin
+ src:
+ - src/core/ext/census/grpc_context.cc
uses:
- grpc_base
- nanopb
- name: gpr_base
src:
- - src/core/lib/profiling/basic_timers.c
- - src/core/lib/profiling/stap_timers.c
- - src/core/lib/support/alloc.c
- - src/core/lib/support/arena.c
- - src/core/lib/support/atm.c
- - src/core/lib/support/avl.c
- - src/core/lib/support/backoff.c
- - src/core/lib/support/cmdline.c
- - src/core/lib/support/cpu_iphone.c
- - src/core/lib/support/cpu_linux.c
- - src/core/lib/support/cpu_posix.c
- - src/core/lib/support/cpu_windows.c
- - src/core/lib/support/env_linux.c
- - src/core/lib/support/env_posix.c
- - src/core/lib/support/env_windows.c
- - src/core/lib/support/histogram.c
- - src/core/lib/support/host_port.c
- - src/core/lib/support/log.c
- - src/core/lib/support/log_android.c
- - src/core/lib/support/log_linux.c
- - src/core/lib/support/log_posix.c
- - src/core/lib/support/log_windows.c
- - src/core/lib/support/mpscq.c
- - src/core/lib/support/murmur_hash.c
- - src/core/lib/support/stack_lockfree.c
- - src/core/lib/support/string.c
- - src/core/lib/support/string_posix.c
- - src/core/lib/support/string_util_windows.c
- - src/core/lib/support/string_windows.c
- - src/core/lib/support/subprocess_posix.c
- - src/core/lib/support/subprocess_windows.c
- - src/core/lib/support/sync.c
- - src/core/lib/support/sync_posix.c
- - src/core/lib/support/sync_windows.c
- - src/core/lib/support/thd.c
- - src/core/lib/support/thd_posix.c
- - src/core/lib/support/thd_windows.c
- - src/core/lib/support/time.c
- - src/core/lib/support/time_posix.c
- - src/core/lib/support/time_precise.c
- - src/core/lib/support/time_windows.c
- - src/core/lib/support/tls_pthread.c
- - src/core/lib/support/tmpfile_msys.c
- - src/core/lib/support/tmpfile_posix.c
- - src/core/lib/support/tmpfile_windows.c
- - src/core/lib/support/wrap_memcpy.c
+ - 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
+ - src/core/lib/gpr/cpu_posix.cc
+ - src/core/lib/gpr/cpu_windows.cc
+ - src/core/lib/gpr/env_linux.cc
+ - src/core/lib/gpr/env_posix.cc
+ - src/core/lib/gpr/env_windows.cc
+ - src/core/lib/gpr/fork.cc
+ - src/core/lib/gpr/host_port.cc
+ - src/core/lib/gpr/log.cc
+ - src/core/lib/gpr/log_android.cc
+ - src/core/lib/gpr/log_linux.cc
+ - src/core/lib/gpr/log_posix.cc
+ - src/core/lib/gpr/log_windows.cc
+ - src/core/lib/gpr/mpscq.cc
+ - src/core/lib/gpr/murmur_hash.cc
+ - src/core/lib/gpr/string.cc
+ - 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
+ - src/core/lib/gpr/thd.cc
+ - src/core/lib/gpr/thd_posix.cc
+ - src/core/lib/gpr/thd_windows.cc
+ - src/core/lib/gpr/time.cc
+ - src/core/lib/gpr/time_posix.cc
+ - src/core/lib/gpr/time_precise.cc
+ - src/core/lib/gpr/time_windows.cc
+ - src/core/lib/gpr/tls_pthread.cc
+ - 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/wrap_memcpy.cc
+ - src/core/lib/profiling/basic_timers.cc
+ - src/core/lib/profiling/stap_timers.cc
uses:
- gpr_base_headers
- name: gpr_base_headers
@@ -118,7 +82,6 @@ filegroups:
- include/grpc/support/avl.h
- include/grpc/support/cmdline.h
- include/grpc/support/cpu.h
- - include/grpc/support/histogram.h
- include/grpc/support/host_port.h
- include/grpc/support/log.h
- include/grpc/support/log_windows.h
@@ -138,23 +101,24 @@ filegroups:
- include/grpc/support/tls_pthread.h
- include/grpc/support/useful.h
headers:
+ - src/core/lib/gpr/arena.h
+ - src/core/lib/gpr/env.h
+ - src/core/lib/gpr/fork.h
+ - src/core/lib/gpr/mpscq.h
+ - src/core/lib/gpr/murmur_hash.h
+ - src/core/lib/gpr/spinlock.h
+ - 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/tmpfile.h
+ - src/core/lib/gprpp/abstract.h
+ - src/core/lib/gprpp/atomic.h
+ - src/core/lib/gprpp/atomic_with_atm.h
+ - src/core/lib/gprpp/atomic_with_std.h
+ - src/core/lib/gprpp/manual_constructor.h
+ - src/core/lib/gprpp/memory.h
- src/core/lib/profiling/timers.h
- - src/core/lib/support/arena.h
- - src/core/lib/support/atomic.h
- - src/core/lib/support/atomic_with_atm.h
- - src/core/lib/support/atomic_with_std.h
- - src/core/lib/support/backoff.h
- - src/core/lib/support/block_annotate.h
- - src/core/lib/support/env.h
- - src/core/lib/support/memory.h
- - src/core/lib/support/mpscq.h
- - src/core/lib/support/murmur_hash.h
- - src/core/lib/support/spinlock.h
- - src/core/lib/support/stack_lockfree.h
- - src/core/lib/support/string.h
- - src/core/lib/support/string_windows.h
- - src/core/lib/support/time_precise.h
- - src/core/lib/support/tmpfile.h
uses:
- gpr_codegen
- name: gpr_codegen
@@ -163,6 +127,7 @@ filegroups:
- include/grpc/impl/codegen/atm_gcc_atomic.h
- include/grpc/impl/codegen/atm_gcc_sync.h
- include/grpc/impl/codegen/atm_windows.h
+ - include/grpc/impl/codegen/fork.h
- include/grpc/impl/codegen/gpr_slice.h
- include/grpc/impl/codegen/gpr_types.h
- include/grpc/impl/codegen/port_platform.h
@@ -185,137 +150,141 @@ filegroups:
- grpc++_codegen_base
- name: grpc_base
src:
- - src/core/lib/channel/channel_args.c
- - src/core/lib/channel/channel_stack.c
- - src/core/lib/channel/channel_stack_builder.c
- - src/core/lib/channel/connected_channel.c
- - src/core/lib/channel/handshaker.c
- - src/core/lib/channel/handshaker_factory.c
- - src/core/lib/channel/handshaker_registry.c
- - src/core/lib/compression/compression.c
- - src/core/lib/compression/message_compress.c
- - src/core/lib/compression/stream_compression.c
- - src/core/lib/compression/stream_compression_gzip.c
- - src/core/lib/compression/stream_compression_identity.c
- - src/core/lib/debug/stats.c
- - src/core/lib/debug/stats_data.c
- - src/core/lib/http/format_request.c
- - src/core/lib/http/httpcli.c
- - src/core/lib/http/parser.c
- - src/core/lib/iomgr/call_combiner.c
- - src/core/lib/iomgr/closure.c
- - src/core/lib/iomgr/combiner.c
- - src/core/lib/iomgr/endpoint.c
- - src/core/lib/iomgr/endpoint_pair_posix.c
- - src/core/lib/iomgr/endpoint_pair_uv.c
- - src/core/lib/iomgr/endpoint_pair_windows.c
- - src/core/lib/iomgr/error.c
- - src/core/lib/iomgr/ev_epoll1_linux.c
- - src/core/lib/iomgr/ev_epollex_linux.c
- - src/core/lib/iomgr/ev_epollsig_linux.c
- - src/core/lib/iomgr/ev_poll_posix.c
- - src/core/lib/iomgr/ev_posix.c
- - src/core/lib/iomgr/ev_windows.c
- - src/core/lib/iomgr/exec_ctx.c
- - src/core/lib/iomgr/executor.c
- - src/core/lib/iomgr/gethostname_fallback.c
- - src/core/lib/iomgr/gethostname_host_name_max.c
- - src/core/lib/iomgr/gethostname_sysconf.c
- - src/core/lib/iomgr/iocp_windows.c
- - src/core/lib/iomgr/iomgr.c
- - src/core/lib/iomgr/iomgr_posix.c
- - src/core/lib/iomgr/iomgr_uv.c
- - src/core/lib/iomgr/iomgr_windows.c
- - src/core/lib/iomgr/is_epollexclusive_available.c
- - src/core/lib/iomgr/load_file.c
- - src/core/lib/iomgr/lockfree_event.c
- - src/core/lib/iomgr/network_status_tracker.c
- - src/core/lib/iomgr/polling_entity.c
- - src/core/lib/iomgr/pollset_set_uv.c
- - src/core/lib/iomgr/pollset_set_windows.c
- - src/core/lib/iomgr/pollset_uv.c
- - src/core/lib/iomgr/pollset_windows.c
- - src/core/lib/iomgr/resolve_address_posix.c
- - src/core/lib/iomgr/resolve_address_uv.c
- - src/core/lib/iomgr/resolve_address_windows.c
- - src/core/lib/iomgr/resource_quota.c
- - src/core/lib/iomgr/sockaddr_utils.c
- - src/core/lib/iomgr/socket_factory_posix.c
- - src/core/lib/iomgr/socket_mutator.c
- - src/core/lib/iomgr/socket_utils_common_posix.c
- - src/core/lib/iomgr/socket_utils_linux.c
- - src/core/lib/iomgr/socket_utils_posix.c
- - src/core/lib/iomgr/socket_utils_uv.c
- - src/core/lib/iomgr/socket_utils_windows.c
- - src/core/lib/iomgr/socket_windows.c
- - src/core/lib/iomgr/tcp_client_posix.c
- - src/core/lib/iomgr/tcp_client_uv.c
- - src/core/lib/iomgr/tcp_client_windows.c
- - src/core/lib/iomgr/tcp_posix.c
- - src/core/lib/iomgr/tcp_server_posix.c
- - src/core/lib/iomgr/tcp_server_utils_posix_common.c
- - src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
- - src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
- - src/core/lib/iomgr/tcp_server_uv.c
- - src/core/lib/iomgr/tcp_server_windows.c
- - src/core/lib/iomgr/tcp_uv.c
- - src/core/lib/iomgr/tcp_windows.c
- - src/core/lib/iomgr/time_averaged_stats.c
- - src/core/lib/iomgr/timer_generic.c
- - src/core/lib/iomgr/timer_heap.c
- - src/core/lib/iomgr/timer_manager.c
- - src/core/lib/iomgr/timer_uv.c
- - src/core/lib/iomgr/udp_server.c
- - src/core/lib/iomgr/unix_sockets_posix.c
- - src/core/lib/iomgr/unix_sockets_posix_noop.c
- - src/core/lib/iomgr/wakeup_fd_cv.c
- - src/core/lib/iomgr/wakeup_fd_eventfd.c
- - src/core/lib/iomgr/wakeup_fd_nospecial.c
- - src/core/lib/iomgr/wakeup_fd_pipe.c
- - src/core/lib/iomgr/wakeup_fd_posix.c
- - src/core/lib/json/json.c
- - src/core/lib/json/json_reader.c
- - src/core/lib/json/json_string.c
- - src/core/lib/json/json_writer.c
- - src/core/lib/slice/b64.c
- - src/core/lib/slice/percent_encoding.c
- - src/core/lib/slice/slice.c
- - src/core/lib/slice/slice_buffer.c
- - src/core/lib/slice/slice_hash_table.c
- - src/core/lib/slice/slice_intern.c
- - src/core/lib/slice/slice_string_helpers.c
- - src/core/lib/surface/alarm.c
- - src/core/lib/surface/api_trace.c
- - src/core/lib/surface/byte_buffer.c
- - src/core/lib/surface/byte_buffer_reader.c
- - src/core/lib/surface/call.c
- - src/core/lib/surface/call_details.c
- - src/core/lib/surface/call_log_batch.c
- - src/core/lib/surface/channel.c
- - src/core/lib/surface/channel_init.c
- - src/core/lib/surface/channel_ping.c
- - src/core/lib/surface/channel_stack_type.c
- - src/core/lib/surface/completion_queue.c
- - src/core/lib/surface/completion_queue_factory.c
- - src/core/lib/surface/event_string.c
+ - src/core/lib/backoff/backoff.cc
+ - src/core/lib/channel/channel_args.cc
+ - src/core/lib/channel/channel_stack.cc
+ - src/core/lib/channel/channel_stack_builder.cc
+ - src/core/lib/channel/connected_channel.cc
+ - src/core/lib/channel/handshaker.cc
+ - src/core/lib/channel/handshaker_factory.cc
+ - 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
+ - src/core/lib/compression/stream_compression_identity.cc
+ - src/core/lib/debug/stats.cc
+ - src/core/lib/debug/stats_data.cc
+ - src/core/lib/http/format_request.cc
+ - src/core/lib/http/httpcli.cc
+ - src/core/lib/http/parser.cc
+ - src/core/lib/iomgr/call_combiner.cc
+ - src/core/lib/iomgr/combiner.cc
+ - src/core/lib/iomgr/endpoint.cc
+ - src/core/lib/iomgr/endpoint_pair_posix.cc
+ - src/core/lib/iomgr/endpoint_pair_uv.cc
+ - src/core/lib/iomgr/endpoint_pair_windows.cc
+ - src/core/lib/iomgr/error.cc
+ - src/core/lib/iomgr/ev_epoll1_linux.cc
+ - src/core/lib/iomgr/ev_epollex_linux.cc
+ - src/core/lib/iomgr/ev_epollsig_linux.cc
+ - src/core/lib/iomgr/ev_poll_posix.cc
+ - src/core/lib/iomgr/ev_posix.cc
+ - src/core/lib/iomgr/ev_windows.cc
+ - src/core/lib/iomgr/exec_ctx.cc
+ - src/core/lib/iomgr/executor.cc
+ - src/core/lib/iomgr/fork_posix.cc
+ - src/core/lib/iomgr/fork_windows.cc
+ - src/core/lib/iomgr/gethostname_fallback.cc
+ - src/core/lib/iomgr/gethostname_host_name_max.cc
+ - src/core/lib/iomgr/gethostname_sysconf.cc
+ - src/core/lib/iomgr/iocp_windows.cc
+ - src/core/lib/iomgr/iomgr.cc
+ - src/core/lib/iomgr/iomgr_posix.cc
+ - src/core/lib/iomgr/iomgr_uv.cc
+ - src/core/lib/iomgr/iomgr_windows.cc
+ - src/core/lib/iomgr/is_epollexclusive_available.cc
+ - src/core/lib/iomgr/load_file.cc
+ - src/core/lib/iomgr/lockfree_event.cc
+ - src/core/lib/iomgr/network_status_tracker.cc
+ - src/core/lib/iomgr/polling_entity.cc
+ - src/core/lib/iomgr/pollset_set_uv.cc
+ - src/core/lib/iomgr/pollset_set_windows.cc
+ - src/core/lib/iomgr/pollset_uv.cc
+ - src/core/lib/iomgr/pollset_windows.cc
+ - src/core/lib/iomgr/resolve_address_posix.cc
+ - src/core/lib/iomgr/resolve_address_uv.cc
+ - src/core/lib/iomgr/resolve_address_windows.cc
+ - src/core/lib/iomgr/resource_quota.cc
+ - src/core/lib/iomgr/sockaddr_utils.cc
+ - src/core/lib/iomgr/socket_factory_posix.cc
+ - src/core/lib/iomgr/socket_mutator.cc
+ - src/core/lib/iomgr/socket_utils_common_posix.cc
+ - src/core/lib/iomgr/socket_utils_linux.cc
+ - src/core/lib/iomgr/socket_utils_posix.cc
+ - src/core/lib/iomgr/socket_utils_uv.cc
+ - src/core/lib/iomgr/socket_utils_windows.cc
+ - src/core/lib/iomgr/socket_windows.cc
+ - src/core/lib/iomgr/tcp_client_posix.cc
+ - src/core/lib/iomgr/tcp_client_uv.cc
+ - src/core/lib/iomgr/tcp_client_windows.cc
+ - src/core/lib/iomgr/tcp_posix.cc
+ - src/core/lib/iomgr/tcp_server_posix.cc
+ - src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+ - src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+ - src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
+ - src/core/lib/iomgr/tcp_server_uv.cc
+ - src/core/lib/iomgr/tcp_server_windows.cc
+ - src/core/lib/iomgr/tcp_uv.cc
+ - src/core/lib/iomgr/tcp_windows.cc
+ - src/core/lib/iomgr/time_averaged_stats.cc
+ - src/core/lib/iomgr/timer_generic.cc
+ - src/core/lib/iomgr/timer_heap.cc
+ - src/core/lib/iomgr/timer_manager.cc
+ - src/core/lib/iomgr/timer_uv.cc
+ - src/core/lib/iomgr/udp_server.cc
+ - src/core/lib/iomgr/unix_sockets_posix.cc
+ - src/core/lib/iomgr/unix_sockets_posix_noop.cc
+ - src/core/lib/iomgr/wakeup_fd_cv.cc
+ - src/core/lib/iomgr/wakeup_fd_eventfd.cc
+ - src/core/lib/iomgr/wakeup_fd_nospecial.cc
+ - src/core/lib/iomgr/wakeup_fd_pipe.cc
+ - src/core/lib/iomgr/wakeup_fd_posix.cc
+ - src/core/lib/json/json.cc
+ - src/core/lib/json/json_reader.cc
+ - src/core/lib/json/json_string.cc
+ - src/core/lib/json/json_writer.cc
+ - src/core/lib/slice/b64.cc
+ - src/core/lib/slice/percent_encoding.cc
+ - src/core/lib/slice/slice.cc
+ - src/core/lib/slice/slice_buffer.cc
+ - 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
+ - src/core/lib/surface/call.cc
+ - src/core/lib/surface/call_details.cc
+ - src/core/lib/surface/call_log_batch.cc
+ - src/core/lib/surface/channel.cc
+ - src/core/lib/surface/channel_init.cc
+ - src/core/lib/surface/channel_ping.cc
+ - src/core/lib/surface/channel_stack_type.cc
+ - src/core/lib/surface/completion_queue.cc
+ - src/core/lib/surface/completion_queue_factory.cc
+ - src/core/lib/surface/event_string.cc
- src/core/lib/surface/lame_client.cc
- - src/core/lib/surface/metadata_array.c
- - src/core/lib/surface/server.c
- - src/core/lib/surface/validate_metadata.c
- - src/core/lib/surface/version.c
- - src/core/lib/transport/bdp_estimator.c
- - src/core/lib/transport/byte_stream.c
- - src/core/lib/transport/connectivity_state.c
- - src/core/lib/transport/error_utils.c
- - src/core/lib/transport/metadata.c
- - src/core/lib/transport/metadata_batch.c
- - src/core/lib/transport/pid_controller.c
- - src/core/lib/transport/service_config.c
- - src/core/lib/transport/static_metadata.c
- - src/core/lib/transport/status_conversion.c
- - src/core/lib/transport/timeout_encoding.c
- - src/core/lib/transport/transport.c
- - src/core/lib/transport/transport_op_string.c
+ - src/core/lib/surface/metadata_array.cc
+ - src/core/lib/surface/server.cc
+ - src/core/lib/surface/validate_metadata.cc
+ - src/core/lib/surface/version.cc
+ - src/core/lib/transport/bdp_estimator.cc
+ - src/core/lib/transport/byte_stream.cc
+ - src/core/lib/transport/connectivity_state.cc
+ - src/core/lib/transport/error_utils.cc
+ - src/core/lib/transport/metadata.cc
+ - src/core/lib/transport/metadata_batch.cc
+ - src/core/lib/transport/pid_controller.cc
+ - src/core/lib/transport/service_config.cc
+ - src/core/lib/transport/static_metadata.cc
+ - src/core/lib/transport/status_conversion.cc
+ - src/core/lib/transport/timeout_encoding.cc
+ - src/core/lib/transport/transport.cc
+ - src/core/lib/transport/transport_op_string.cc
deps:
- gpr
filegroups:
@@ -328,6 +297,8 @@ 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
- include/grpc/grpc_security_constants.h
@@ -337,6 +308,7 @@ filegroups:
- include/grpc/status.h
- include/grpc/support/workaround_list.h
headers:
+ - src/core/lib/backoff/backoff.h
- src/core/lib/channel/channel_args.h
- src/core/lib/channel/channel_stack.h
- src/core/lib/channel/channel_stack_builder.h
@@ -346,15 +318,22 @@ filegroups:
- src/core/lib/channel/handshaker_factory.h
- src/core/lib/channel/handshaker_registry.h
- src/core/lib/compression/algorithm_metadata.h
+ - src/core/lib/compression/compression_internal.h
- src/core/lib/compression/message_compress.h
- src/core/lib/compression/stream_compression.h
- src/core/lib/compression/stream_compression_gzip.h
- src/core/lib/compression/stream_compression_identity.h
- src/core/lib/debug/stats.h
- src/core/lib/debug/stats_data.h
+ - src/core/lib/gprpp/debug_location.h
+ - src/core/lib/gprpp/inlined_vector.h
+ - src/core/lib/gprpp/orphanable.h
+ - src/core/lib/gprpp/ref_counted.h
+ - src/core/lib/gprpp/ref_counted_ptr.h
- src/core/lib/http/format_request.h
- src/core/lib/http/httpcli.h
- src/core/lib/http/parser.h
+ - src/core/lib/iomgr/block_annotate.h
- src/core/lib/iomgr/call_combiner.h
- src/core/lib/iomgr/closure.h
- src/core/lib/iomgr/combiner.h
@@ -461,6 +440,7 @@ filegroups:
- grpc_trace_headers
- name: grpc_client_channel
headers:
+ - src/core/ext/filters/client_channel/backup_poller.h
- src/core/ext/filters/client_channel/client_channel.h
- src/core/ext/filters/client_channel/client_channel_factory.h
- src/core/ext/filters/client_channel/connector.h
@@ -480,26 +460,27 @@ filegroups:
- src/core/ext/filters/client_channel/subchannel_index.h
- src/core/ext/filters/client_channel/uri_parser.h
src:
- - src/core/ext/filters/client_channel/channel_connectivity.c
- - src/core/ext/filters/client_channel/client_channel.c
- - src/core/ext/filters/client_channel/client_channel_factory.c
- - src/core/ext/filters/client_channel/client_channel_plugin.c
- - src/core/ext/filters/client_channel/connector.c
- - src/core/ext/filters/client_channel/http_connect_handshaker.c
- - src/core/ext/filters/client_channel/http_proxy.c
- - src/core/ext/filters/client_channel/lb_policy.c
- - src/core/ext/filters/client_channel/lb_policy_factory.c
- - src/core/ext/filters/client_channel/lb_policy_registry.c
- - src/core/ext/filters/client_channel/parse_address.c
- - src/core/ext/filters/client_channel/proxy_mapper.c
- - src/core/ext/filters/client_channel/proxy_mapper_registry.c
- - src/core/ext/filters/client_channel/resolver.c
- - src/core/ext/filters/client_channel/resolver_factory.c
- - src/core/ext/filters/client_channel/resolver_registry.c
- - src/core/ext/filters/client_channel/retry_throttle.c
- - src/core/ext/filters/client_channel/subchannel.c
- - src/core/ext/filters/client_channel/subchannel_index.c
- - src/core/ext/filters/client_channel/uri_parser.c
+ - src/core/ext/filters/client_channel/backup_poller.cc
+ - src/core/ext/filters/client_channel/channel_connectivity.cc
+ - src/core/ext/filters/client_channel/client_channel.cc
+ - src/core/ext/filters/client_channel/client_channel_factory.cc
+ - src/core/ext/filters/client_channel/client_channel_plugin.cc
+ - src/core/ext/filters/client_channel/connector.cc
+ - src/core/ext/filters/client_channel/http_connect_handshaker.cc
+ - src/core/ext/filters/client_channel/http_proxy.cc
+ - src/core/ext/filters/client_channel/lb_policy.cc
+ - src/core/ext/filters/client_channel/lb_policy_factory.cc
+ - src/core/ext/filters/client_channel/lb_policy_registry.cc
+ - src/core/ext/filters/client_channel/parse_address.cc
+ - 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
+ - src/core/ext/filters/client_channel/subchannel_index.cc
+ - src/core/ext/filters/client_channel/uri_parser.cc
plugin: grpc_client_channel
uses:
- grpc_base
@@ -510,7 +491,6 @@ filegroups:
- include/grpc/impl/codegen/byte_buffer_reader.h
- include/grpc/impl/codegen/compression_types.h
- include/grpc/impl/codegen/connectivity_state.h
- - include/grpc/impl/codegen/exec_ctx_fwd.h
- include/grpc/impl/codegen/grpc_types.h
- include/grpc/impl/codegen/propagation_bits.h
- include/grpc/impl/codegen/slice.h
@@ -521,7 +501,7 @@ filegroups:
headers:
- src/core/ext/filters/deadline/deadline_filter.h
src:
- - src/core/ext/filters/deadline/deadline_filter.c
+ - src/core/ext/filters/deadline/deadline_filter.cc
plugin: grpc_deadline_filter
uses:
- grpc_base
@@ -531,10 +511,10 @@ filegroups:
- src/core/ext/filters/http/message_compress/message_compress_filter.h
- src/core/ext/filters/http/server/http_server_filter.h
src:
- - src/core/ext/filters/http/client/http_client_filter.c
- - src/core/ext/filters/http/http_filters_plugin.c
- - src/core/ext/filters/http/message_compress/message_compress_filter.c
- - src/core/ext/filters/http/server/http_server_filter.c
+ - src/core/ext/filters/http/client/http_client_filter.cc
+ - src/core/ext/filters/http/http_filters_plugin.cc
+ - src/core/ext/filters/http/message_compress/message_compress_filter.cc
+ - src/core/ext/filters/http/server/http_server_filter.cc
plugin: grpc_http_filters
uses:
- grpc_base
@@ -547,11 +527,11 @@ filegroups:
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src:
- - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb
uses:
@@ -568,11 +548,11 @@ filegroups:
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src:
- - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
- - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
+ - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb
uses:
@@ -583,23 +563,33 @@ filegroups:
- grpc_resolver_fake
- name: grpc_lb_policy_pick_first
src:
- - src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
+ - src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
plugin: grpc_lb_policy_pick_first
uses:
- grpc_base
- grpc_client_channel
+ - grpc_lb_subchannel_list
- name: grpc_lb_policy_round_robin
src:
- - src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
+ - src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
plugin: grpc_lb_policy_round_robin
uses:
- grpc_base
- grpc_client_channel
+ - grpc_lb_subchannel_list
+- name: grpc_lb_subchannel_list
+ headers:
+ - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
+ src:
+ - src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
+ uses:
+ - grpc_base
+ - grpc_client_channel
- name: grpc_max_age_filter
headers:
- src/core/ext/filters/max_age/max_age_filter.h
src:
- - src/core/ext/filters/max_age/max_age_filter.c
+ - src/core/ext/filters/max_age/max_age_filter.cc
plugin: grpc_max_age_filter
uses:
- grpc_base
@@ -607,7 +597,7 @@ filegroups:
headers:
- src/core/ext/filters/message_size/message_size_filter.h
src:
- - src/core/ext/filters/message_size/message_size_filter.c
+ - src/core/ext/filters/message_size/message_size_filter.cc
plugin: grpc_message_size_filter
uses:
- grpc_base
@@ -616,17 +606,17 @@ filegroups:
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
src:
- - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c
- - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
- - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c
- - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c
+ - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
+ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
+ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
+ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
plugin: grpc_resolver_dns_ares
uses:
- grpc_base
- grpc_client_channel
- name: grpc_resolver_dns_native
src:
- - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c
+ - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
plugin: grpc_resolver_dns_native
uses:
- grpc_base
@@ -635,14 +625,14 @@ filegroups:
headers:
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h
src:
- - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
+ - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
plugin: grpc_resolver_fake
uses:
- grpc_base
- grpc_client_channel
- name: grpc_resolver_sockaddr
src:
- - src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c
+ - src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
plugin: grpc_resolver_sockaddr
uses:
- grpc_base
@@ -671,30 +661,30 @@ filegroups:
- src/core/lib/security/transport/tsi_error.h
- src/core/lib/security/util/json_util.h
src:
- - src/core/lib/http/httpcli_security_connector.c
- - src/core/lib/security/context/security_context.c
- - src/core/lib/security/credentials/composite/composite_credentials.c
- - src/core/lib/security/credentials/credentials.c
- - src/core/lib/security/credentials/credentials_metadata.c
- - src/core/lib/security/credentials/fake/fake_credentials.c
- - src/core/lib/security/credentials/google_default/credentials_generic.c
- - src/core/lib/security/credentials/google_default/google_default_credentials.c
- - src/core/lib/security/credentials/iam/iam_credentials.c
- - src/core/lib/security/credentials/jwt/json_token.c
- - src/core/lib/security/credentials/jwt/jwt_credentials.c
- - src/core/lib/security/credentials/jwt/jwt_verifier.c
- - src/core/lib/security/credentials/oauth2/oauth2_credentials.c
- - src/core/lib/security/credentials/plugin/plugin_credentials.c
- - src/core/lib/security/credentials/ssl/ssl_credentials.c
- - src/core/lib/security/transport/client_auth_filter.c
- - src/core/lib/security/transport/lb_targets_info.c
- - src/core/lib/security/transport/secure_endpoint.c
- - src/core/lib/security/transport/security_connector.c
- - src/core/lib/security/transport/security_handshaker.c
- - src/core/lib/security/transport/server_auth_filter.c
- - src/core/lib/security/transport/tsi_error.c
- - src/core/lib/security/util/json_util.c
- - src/core/lib/surface/init_secure.c
+ - src/core/lib/http/httpcli_security_connector.cc
+ - src/core/lib/security/context/security_context.cc
+ - src/core/lib/security/credentials/composite/composite_credentials.cc
+ - src/core/lib/security/credentials/credentials.cc
+ - src/core/lib/security/credentials/credentials_metadata.cc
+ - src/core/lib/security/credentials/fake/fake_credentials.cc
+ - src/core/lib/security/credentials/google_default/credentials_generic.cc
+ - src/core/lib/security/credentials/google_default/google_default_credentials.cc
+ - src/core/lib/security/credentials/iam/iam_credentials.cc
+ - src/core/lib/security/credentials/jwt/json_token.cc
+ - src/core/lib/security/credentials/jwt/jwt_credentials.cc
+ - src/core/lib/security/credentials/jwt/jwt_verifier.cc
+ - src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+ - src/core/lib/security/credentials/plugin/plugin_credentials.cc
+ - src/core/lib/security/credentials/ssl/ssl_credentials.cc
+ - src/core/lib/security/transport/client_auth_filter.cc
+ - src/core/lib/security/transport/lb_targets_info.cc
+ - src/core/lib/security/transport/secure_endpoint.cc
+ - src/core/lib/security/transport/security_connector.cc
+ - src/core/lib/security/transport/security_handshaker.cc
+ - src/core/lib/security/transport/server_auth_filter.cc
+ - src/core/lib/security/transport/tsi_error.cc
+ - src/core/lib/security/util/json_util.cc
+ - src/core/lib/surface/init_secure.cc
secure: true
uses:
- grpc_base
@@ -704,7 +694,7 @@ filegroups:
headers:
- src/core/ext/filters/workarounds/workaround_utils.h
src:
- - src/core/ext/filters/workarounds/workaround_utils.c
+ - src/core/ext/filters/workarounds/workaround_utils.cc
uses:
- grpc_base
- name: grpc_server_load_reporting
@@ -712,8 +702,8 @@ filegroups:
- src/core/ext/filters/load_reporting/server_load_reporting_filter.h
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.h
src:
- - src/core/ext/filters/load_reporting/server_load_reporting_filter.c
- - src/core/ext/filters/load_reporting/server_load_reporting_plugin.c
+ - src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
+ - src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
plugin: grpc_server_load_reporting_plugin
uses:
- grpc_base
@@ -727,6 +717,7 @@ filegroups:
- test/core/iomgr/endpoint_tests.h
- test/core/util/debugger_macros.h
- test/core/util/grpc_profiler.h
+ - test/core/util/histogram.h
- test/core/util/memory_counters.h
- test/core/util/mock_endpoint.h
- test/core/util/parse_hexstring.h
@@ -734,23 +725,27 @@ filegroups:
- test/core/util/port.h
- test/core/util/port_server_client.h
- test/core/util/slice_splitter.h
+ - test/core/util/tracer_util.h
- test/core/util/trickle_endpoint.h
src:
- - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
- - test/core/end2end/cq_verifier.c
- - test/core/end2end/fixtures/http_proxy_fixture.c
- - test/core/end2end/fixtures/proxy.c
- - test/core/iomgr/endpoint_tests.c
- - test/core/util/debugger_macros.c
- - test/core/util/grpc_profiler.c
- - test/core/util/memory_counters.c
- - test/core/util/mock_endpoint.c
- - test/core/util/parse_hexstring.c
- - test/core/util/passthru_endpoint.c
- - test/core/util/port.c
- - test/core/util/port_server_client.c
- - test/core/util/slice_splitter.c
- - test/core/util/trickle_endpoint.c
+ - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
+ - test/core/end2end/cq_verifier.cc
+ - test/core/end2end/fixtures/http_proxy_fixture.cc
+ - test/core/end2end/fixtures/proxy.cc
+ - test/core/iomgr/endpoint_tests.cc
+ - test/core/util/debugger_macros.cc
+ - test/core/util/grpc_profiler.cc
+ - test/core/util/histogram.cc
+ - test/core/util/memory_counters.cc
+ - test/core/util/mock_endpoint.cc
+ - test/core/util/parse_hexstring.cc
+ - test/core/util/passthru_endpoint.cc
+ - test/core/util/port.cc
+ - test/core/util/port_isolated_runtime_environment.cc
+ - test/core/util/port_server_client.cc
+ - test/core/util/slice_splitter.cc
+ - test/core/util/tracer_util.cc
+ - test/core/util/trickle_endpoint.cc
deps:
- gpr_test_util
- gpr
@@ -760,11 +755,12 @@ filegroups:
- grpc_transport_chttp2
- name: grpc_trace
src:
- - src/core/lib/debug/trace.c
+ - src/core/lib/debug/trace.cc
deps:
- gpr
filegroups:
- grpc_trace_headers
+ - grpc_base_headers
- name: grpc_trace_headers
headers:
- src/core/lib/debug/trace.h
@@ -775,6 +771,7 @@ filegroups:
- src/core/ext/transport/chttp2/transport/bin_decoder.h
- src/core/ext/transport/chttp2/transport/bin_encoder.h
- src/core/ext/transport/chttp2/transport/chttp2_transport.h
+ - src/core/ext/transport/chttp2/transport/flow_control.h
- src/core/ext/transport/chttp2/transport/frame.h
- src/core/ext/transport/chttp2/transport/frame_data.h
- src/core/ext/transport/chttp2/transport/frame_goaway.h
@@ -792,28 +789,28 @@ filegroups:
- src/core/ext/transport/chttp2/transport/stream_map.h
- src/core/ext/transport/chttp2/transport/varint.h
src:
- - src/core/ext/transport/chttp2/transport/bin_decoder.c
- - src/core/ext/transport/chttp2/transport/bin_encoder.c
- - src/core/ext/transport/chttp2/transport/chttp2_plugin.c
- - src/core/ext/transport/chttp2/transport/chttp2_transport.c
- - src/core/ext/transport/chttp2/transport/flow_control.c
- - src/core/ext/transport/chttp2/transport/frame_data.c
- - src/core/ext/transport/chttp2/transport/frame_goaway.c
- - src/core/ext/transport/chttp2/transport/frame_ping.c
- - src/core/ext/transport/chttp2/transport/frame_rst_stream.c
- - src/core/ext/transport/chttp2/transport/frame_settings.c
- - src/core/ext/transport/chttp2/transport/frame_window_update.c
- - src/core/ext/transport/chttp2/transport/hpack_encoder.c
- - src/core/ext/transport/chttp2/transport/hpack_parser.c
- - src/core/ext/transport/chttp2/transport/hpack_table.c
- - src/core/ext/transport/chttp2/transport/http2_settings.c
- - src/core/ext/transport/chttp2/transport/huffsyms.c
- - src/core/ext/transport/chttp2/transport/incoming_metadata.c
- - src/core/ext/transport/chttp2/transport/parsing.c
- - src/core/ext/transport/chttp2/transport/stream_lists.c
- - src/core/ext/transport/chttp2/transport/stream_map.c
- - src/core/ext/transport/chttp2/transport/varint.c
- - src/core/ext/transport/chttp2/transport/writing.c
+ - src/core/ext/transport/chttp2/transport/bin_decoder.cc
+ - src/core/ext/transport/chttp2/transport/bin_encoder.cc
+ - src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+ - src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+ - src/core/ext/transport/chttp2/transport/flow_control.cc
+ - src/core/ext/transport/chttp2/transport/frame_data.cc
+ - src/core/ext/transport/chttp2/transport/frame_goaway.cc
+ - src/core/ext/transport/chttp2/transport/frame_ping.cc
+ - src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+ - src/core/ext/transport/chttp2/transport/frame_settings.cc
+ - src/core/ext/transport/chttp2/transport/frame_window_update.cc
+ - src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+ - src/core/ext/transport/chttp2/transport/hpack_parser.cc
+ - src/core/ext/transport/chttp2/transport/hpack_table.cc
+ - src/core/ext/transport/chttp2/transport/http2_settings.cc
+ - src/core/ext/transport/chttp2/transport/huffsyms.cc
+ - src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+ - src/core/ext/transport/chttp2/transport/parsing.cc
+ - src/core/ext/transport/chttp2/transport/stream_lists.cc
+ - 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
plugin: grpc_chttp2_plugin
uses:
- grpc_base
@@ -823,22 +820,22 @@ filegroups:
headers:
- src/core/ext/transport/chttp2/alpn/alpn.h
src:
- - src/core/ext/transport/chttp2/alpn/alpn.c
+ - src/core/ext/transport/chttp2/alpn/alpn.cc
deps:
- gpr
- name: grpc_transport_chttp2_client_connector
headers:
- src/core/ext/transport/chttp2/client/chttp2_connector.h
src:
- - src/core/ext/transport/chttp2/client/chttp2_connector.c
+ - src/core/ext/transport/chttp2/client/chttp2_connector.cc
uses:
- grpc_transport_chttp2
- grpc_base
- grpc_client_channel
- name: grpc_transport_chttp2_client_insecure
src:
- - src/core/ext/transport/chttp2/client/insecure/channel_create.c
- - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
+ - src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+ - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
uses:
- grpc_transport_chttp2_client_connector
- grpc_transport_chttp2
@@ -846,7 +843,7 @@ filegroups:
- grpc_client_channel
- name: grpc_transport_chttp2_client_secure
src:
- - src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
+ - src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
uses:
- grpc_transport_chttp2
- grpc_base
@@ -857,21 +854,21 @@ filegroups:
headers:
- src/core/ext/transport/chttp2/server/chttp2_server.h
src:
- - src/core/ext/transport/chttp2/server/chttp2_server.c
+ - src/core/ext/transport/chttp2/server/chttp2_server.cc
uses:
- grpc_transport_chttp2
- grpc_base
- name: grpc_transport_chttp2_server_insecure
src:
- - src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
- - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
+ - src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+ - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
uses:
- grpc_transport_chttp2
- grpc_base
- grpc_transport_chttp2_server
- name: grpc_transport_chttp2_server_secure
src:
- - src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
+ - src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
uses:
- grpc_transport_chttp2
- grpc_base
@@ -886,17 +883,17 @@ filegroups:
- src/core/ext/transport/cronet/transport/cronet_transport.h
- third_party/objective_c/Cronet/bidirectional_stream_c.h
src:
- - src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
- - src/core/ext/transport/cronet/transport/cronet_api_dummy.c
- - src/core/ext/transport/cronet/transport/cronet_transport.c
+ - src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
+ - src/core/ext/transport/cronet/transport/cronet_api_dummy.cc
+ - src/core/ext/transport/cronet/transport/cronet_transport.cc
filegroups:
- grpc_base
- grpc_transport_chttp2
- grpc_http_filters
- name: grpc_transport_inproc
src:
- - src/core/ext/transport/inproc/inproc_plugin.c
- - src/core/ext/transport/inproc/inproc_transport.c
+ - src/core/ext/transport/inproc/inproc_plugin.cc
+ - src/core/ext/transport/inproc/inproc_transport.cc
plugin: grpc_inproc_plugin
uses:
- grpc_transport_inproc_headers
@@ -910,7 +907,7 @@ filegroups:
headers:
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h
src:
- - src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c
+ - src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
plugin: grpc_workaround_cronet_compression_filter
uses:
- grpc_base
@@ -933,24 +930,24 @@ filegroups:
headers:
- test/core/tsi/transport_security_test_lib.h
src:
- - test/core/tsi/transport_security_test_lib.c
+ - test/core/tsi/transport_security_test_lib.cc
deps:
- grpc
- name: tsi
headers:
+ - src/core/tsi/alts_transport_security.h
- src/core/tsi/fake_transport_security.h
- - src/core/tsi/gts_transport_security.h
- src/core/tsi/ssl_transport_security.h
- src/core/tsi/ssl_types.h
- src/core/tsi/transport_security_grpc.h
src:
- - src/core/tsi/fake_transport_security.c
- - src/core/tsi/gts_transport_security.c
- - src/core/tsi/ssl_transport_security.c
- - src/core/tsi/transport_security_grpc.c
+ - src/core/tsi/alts_transport_security.cc
+ - src/core/tsi/fake_transport_security.cc
+ - src/core/tsi/ssl_transport_security.cc
+ - src/core/tsi/transport_security_grpc.cc
deps:
- gpr
- plugin: grpc_tsi_gts
+ plugin: grpc_tsi_alts
secure: true
uses:
- tsi_interface
@@ -962,8 +959,8 @@ filegroups:
- src/core/tsi/transport_security_adapter.h
- src/core/tsi/transport_security_interface.h
src:
- - src/core/tsi/transport_security.c
- - src/core/tsi/transport_security_adapter.c
+ - src/core/tsi/transport_security.cc
+ - src/core/tsi/transport_security_adapter.cc
deps:
- gpr
secure: true
@@ -1143,7 +1140,7 @@ libs:
headers:
- test/core/util/test_config.h
src:
- - test/core/util/test_config.c
+ - test/core/util/test_config.cc
deps:
- gpr
secure: false
@@ -1152,7 +1149,7 @@ libs:
build: all
language: c
src:
- - src/core/lib/surface/init.c
+ - src/core/lib/surface/init.cc
baselib: true
deps_linkage: static
dll: true
@@ -1188,7 +1185,7 @@ libs:
build: all
language: c
src:
- - src/core/lib/surface/init.c
+ - src/core/lib/surface/init.cc
baselib: true
deps_linkage: static
dll: true
@@ -1229,11 +1226,11 @@ libs:
- test/core/end2end/data/ssl_test_data.h
- test/core/security/oauth2_utils.h
src:
- - test/core/end2end/data/client_certs.c
- - test/core/end2end/data/server1_cert.c
- - test/core/end2end/data/server1_key.c
- - test/core/end2end/data/test_root_cert.c
- - test/core/security/oauth2_utils.c
+ - test/core/end2end/data/client_certs.cc
+ - test/core/end2end/data/server1_cert.cc
+ - test/core/end2end/data/server1_key.cc
+ - test/core/end2end/data/test_root_cert.cc
+ - test/core/security/oauth2_utils.cc
deps:
- gpr_test_util
- gpr
@@ -1256,8 +1253,8 @@ libs:
build: all
language: c
src:
- - src/core/lib/surface/init.c
- - src/core/lib/surface/init_unsecure.c
+ - src/core/lib/surface/init.cc
+ - src/core/lib/surface/init_unsecure.cc
baselib: true
deps_linkage: static
dll: true
@@ -1289,7 +1286,7 @@ libs:
headers:
- test/core/util/reconnect_server.h
src:
- - test/core/util/reconnect_server.c
+ - test/core/util/reconnect_server.cc
deps:
- test_tcp_server
- grpc_test_util
@@ -1302,7 +1299,7 @@ libs:
headers:
- test/core/util/test_tcp_server.h
src:
- - test/core/util/test_tcp_server.c
+ - test/core/util/test_tcp_server.cc
deps:
- grpc_test_util
- grpc
@@ -1718,7 +1715,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/alarm_test.c
+ - test/core/surface/alarm_test.cc
deps:
- grpc_test_util
- grpc
@@ -1728,25 +1725,27 @@ targets:
build: test
language: c
src:
- - test/core/compression/algorithm_test.c
+ - test/core/compression/algorithm_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: alloc_test
build: test
language: c
src:
- - test/core/support/alloc_test.c
+ - test/core/gpr/alloc_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: alpn_test
build: test
language: c
src:
- - test/core/transport/chttp2/alpn_test.c
+ - test/core/transport/chttp2/alpn_test.cc
deps:
- grpc_test_util
- grpc
@@ -1756,7 +1755,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/end2end/fuzzers/api_fuzzer.c
+ - test/core/end2end/fuzzers/api_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -1770,15 +1769,16 @@ targets:
build: test
language: c
src:
- - test/core/support/arena_test.c
+ - test/core/gpr/arena_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: bad_server_response_test
build: test
language: c
src:
- - test/core/end2end/bad_server_response_test.c
+ - test/core/end2end/bad_server_response_test.cc
deps:
- test_tcp_server
- grpc_test_util
@@ -1787,87 +1787,40 @@ targets:
- gpr
exclude_iomgrs:
- uv
-- name: bdp_estimator_test
- build: test
- language: c
- src:
- - test/core/transport/bdp_estimator_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
- name: bin_decoder_test
build: test
language: c
src:
- - test/core/transport/chttp2/bin_decoder_test.c
+ - test/core/transport/chttp2/bin_decoder_test.cc
deps:
- grpc_test_util
- grpc
+ uses_polling: false
- name: bin_encoder_test
build: test
language: c
src:
- - test/core/transport/chttp2/bin_encoder_test.c
+ - test/core/transport/chttp2/bin_encoder_test.cc
deps:
- grpc_test_util
- grpc
+ uses_polling: false
- name: byte_stream_test
build: test
language: c
src:
- - test/core/transport/byte_stream_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
-- name: census_context_test
- build: test
- language: c
- src:
- - test/core/census/context_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
-- name: census_intrusive_hash_map_test
- build: test
- language: c
- src:
- - test/core/census/intrusive_hash_map_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
-- name: census_resource_test
- build: test
- language: c
- src:
- - test/core/census/resource_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
-- name: census_trace_context_test
- build: test
- language: c
- src:
- - test/core/census/trace_context_test.c
+ - test/core/transport/byte_stream_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: channel_create_test
build: test
language: c
src:
- - test/core/surface/channel_create_test.c
+ - test/core/surface/channel_create_test.cc
deps:
- grpc_test_util
- grpc
@@ -1885,37 +1838,40 @@ targets:
build: test
language: c
src:
- - test/core/transport/chttp2/hpack_encoder_test.c
+ - test/core/transport/chttp2/hpack_encoder_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: chttp2_stream_map_test
build: test
language: c
src:
- - test/core/transport/chttp2/stream_map_test.c
+ - test/core/transport/chttp2/stream_map_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: chttp2_varint_test
build: test
language: c
src:
- - test/core/transport/chttp2/varint_test.c
+ - test/core/transport/chttp2/varint_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: client_fuzzer
build: fuzzer
language: c
src:
- - test/core/end2end/fuzzers/client_fuzzer.c
+ - test/core/end2end/fuzzers/client_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -1930,7 +1886,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/combiner_test.c
+ - test/core/iomgr/combiner_test.cc
deps:
- grpc_test_util
- grpc
@@ -1940,18 +1896,19 @@ targets:
build: test
language: c
src:
- - test/core/compression/compression_test.c
+ - test/core/compression/compression_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: concurrent_connectivity_test
cpu_cost: 2.0
build: test
language: c
src:
- - test/core/surface/concurrent_connectivity_test.c
+ - test/core/surface/concurrent_connectivity_test.cc
deps:
- grpc_test_util
- grpc
@@ -1964,7 +1921,7 @@ targets:
build: test
language: c
src:
- - test/core/end2end/connection_refused_test.c
+ - test/core/end2end/connection_refused_test.cc
deps:
- grpc_test_util
- grpc
@@ -1975,7 +1932,7 @@ targets:
build: test
language: c
src:
- - test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+ - test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
deps:
- grpc_test_util
- grpc
@@ -1987,7 +1944,7 @@ targets:
build: test
language: c
src:
- - test/core/client_channel/resolvers/dns_resolver_test.c
+ - test/core/client_channel/resolvers/dns_resolver_test.cc
deps:
- grpc_test_util
- grpc
@@ -1998,7 +1955,7 @@ targets:
build: test
language: c
src:
- - test/core/end2end/dualstack_socket_test.c
+ - test/core/end2end/dualstack_socket_test.cc
deps:
- grpc_test_util
- grpc
@@ -2014,7 +1971,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/endpoint_pair_test.c
+ - test/core/iomgr/endpoint_pair_test.cc
deps:
- grpc_test_util
- grpc
@@ -2027,18 +1984,19 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/error_test.c
+ - test/core/iomgr/error_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: ev_epollsig_linux_test
cpu_cost: 3
build: test
language: c
src:
- - test/core/iomgr/ev_epollsig_linux_test.c
+ - test/core/iomgr/ev_epollsig_linux_test.cc
deps:
- grpc_test_util
- grpc
@@ -2052,7 +2010,7 @@ targets:
build: test
language: c
src:
- - test/core/client_channel/resolvers/fake_resolver_test.c
+ - test/core/client_channel/resolvers/fake_resolver_test.cc
deps:
- grpc_test_util
- grpc
@@ -2062,7 +2020,7 @@ targets:
build: test
language: c
src:
- - test/core/tsi/fake_transport_security_test.c
+ - test/core/tsi/fake_transport_security_test.cc
deps:
- gpr_test_util
- gpr
@@ -2077,7 +2035,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/fd_conservation_posix_test.c
+ - test/core/iomgr/fd_conservation_posix_test.cc
deps:
- grpc_test_util
- grpc
@@ -2093,7 +2051,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/fd_posix_test.c
+ - test/core/iomgr/fd_posix_test.cc
deps:
- grpc_test_util
- grpc
@@ -2110,7 +2068,7 @@ targets:
run: false
language: c
src:
- - test/core/fling/client.c
+ - test/core/fling/client.cc
deps:
- grpc_test_util
- grpc
@@ -2121,7 +2079,7 @@ targets:
run: false
language: c
src:
- - test/core/fling/server.c
+ - test/core/fling/server.cc
deps:
- grpc_test_util
- grpc
@@ -2132,7 +2090,7 @@ targets:
build: test
language: c
src:
- - test/core/fling/fling_stream_test.c
+ - test/core/fling/fling_stream_test.cc
deps:
- grpc_test_util
- grpc
@@ -2147,7 +2105,7 @@ targets:
build: test
language: c
src:
- - test/core/fling/fling_test.c
+ - test/core/fling/fling_test.cc
deps:
- grpc_test_util
- grpc
@@ -2157,32 +2115,12 @@ targets:
- mac
- linux
- posix
-- name: gen_hpack_tables
- build: tool
- language: c
- src:
- - tools/codegen/core/gen_hpack_tables.c
- deps:
- - gpr
- - grpc
-- name: gen_legal_metadata_characters
- build: tool
- language: c
- src:
- - tools/codegen/core/gen_legal_metadata_characters.c
- deps: []
-- name: gen_percent_encoding_tables
- build: tool
- language: c
- src:
- - tools/codegen/core/gen_percent_encoding_tables.c
- deps: []
- name: goaway_server_test
cpu_cost: 0.1
build: test
language: c
src:
- - test/core/end2end/goaway_server_test.c
+ - test/core/end2end/goaway_server_test.cc
deps:
- grpc_test_util
- grpc
@@ -2198,189 +2136,192 @@ targets:
build: test
language: c
src:
- - test/core/support/avl_test.c
- deps:
- - gpr_test_util
- - gpr
-- name: gpr_backoff_test
- build: test
- language: c
- src:
- - test/core/support/backoff_test.c
+ - test/core/gpr/avl_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_cmdline_test
build: test
language: c
src:
- - test/core/support/cmdline_test.c
+ - test/core/gpr/cmdline_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_cpu_test
cpu_cost: 30
build: test
language: c
src:
- - test/core/support/cpu_test.c
+ - test/core/gpr/cpu_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_env_test
build: test
language: c
src:
- - test/core/support/env_test.c
+ - test/core/gpr/env_test.cc
deps:
- gpr_test_util
- gpr
-- name: gpr_histogram_test
+ uses_polling: false
+- name: gpr_host_port_test
build: test
language: c
src:
- - test/core/support/histogram_test.c
+ - test/core/gpr/host_port_test.cc
deps:
- gpr_test_util
- gpr
-- name: gpr_host_port_test
+ uses_polling: false
+- name: gpr_log_test
build: test
language: c
src:
- - test/core/support/host_port_test.c
+ - test/core/gpr/log_test.cc
deps:
- gpr_test_util
- gpr
-- name: gpr_log_test
+ uses_polling: false
+- name: gpr_manual_constructor_test
+ cpu_cost: 3
build: test
language: c
src:
- - test/core/support/log_test.c
+ - test/core/gprpp/manual_constructor_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_mpscq_test
cpu_cost: 30
build: test
language: c
src:
- - test/core/support/mpscq_test.c
+ - test/core/gpr/mpscq_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_spinlock_test
cpu_cost: 3
build: test
language: c
src:
- - test/core/support/spinlock_test.c
- deps:
- - gpr_test_util
- - gpr
-- name: gpr_stack_lockfree_test
- cpu_cost: 7
- build: test
- language: c
- src:
- - test/core/support/stack_lockfree_test.c
+ - test/core/gpr/spinlock_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_string_test
build: test
language: c
src:
- - test/core/support/string_test.c
+ - test/core/gpr/string_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_sync_test
cpu_cost: 10
build: test
language: c
src:
- - test/core/support/sync_test.c
+ - test/core/gpr/sync_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_thd_test
cpu_cost: 10
build: test
language: c
src:
- - test/core/support/thd_test.c
+ - test/core/gpr/thd_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_time_test
build: test
language: c
src:
- - test/core/support/time_test.c
+ - test/core/gpr/time_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_tls_test
build: test
language: c
src:
- - test/core/support/tls_test.c
+ - test/core/gpr/tls_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: gpr_useful_test
build: test
language: c
src:
- - test/core/support/useful_test.c
+ - test/core/gpr/useful_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_auth_context_test
build: test
language: c
src:
- - test/core/security/auth_context_test.c
+ - test/core/security/auth_context_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_b64_test
build: test
language: c
src:
- - test/core/slice/b64_test.c
+ - test/core/slice/b64_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_byte_buffer_reader_test
build: test
language: c
src:
- - test/core/surface/byte_buffer_reader_test.c
+ - test/core/surface/byte_buffer_reader_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_channel_args_test
build: test
language: c
src:
- - test/core/channel/channel_args_test.c
+ - test/core/channel/channel_args_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_channel_stack_builder_test
build: test
language: c
src:
- - test/core/channel/channel_stack_builder_test.c
+ - test/core/channel/channel_stack_builder_test.cc
deps:
- grpc_test_util
- grpc
@@ -2390,17 +2331,18 @@ targets:
build: test
language: c
src:
- - test/core/channel/channel_stack_test.c
+ - test/core/channel/channel_stack_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_completion_queue_test
build: test
language: c
src:
- - test/core/surface/completion_queue_test.c
+ - test/core/surface/completion_queue_test.cc
deps:
- grpc_test_util
- grpc
@@ -2410,7 +2352,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/completion_queue_threading_test.c
+ - test/core/surface/completion_queue_threading_test.cc
deps:
- grpc_test_util
- grpc
@@ -2422,16 +2364,17 @@ targets:
build: tool
language: c
src:
- - test/core/security/create_jwt.c
+ - test/core/security/create_jwt.cc
deps:
- grpc
- gpr
secure: true
+ uses_polling: false
- name: grpc_credentials_test
build: test
language: c
src:
- - test/core/security/credentials_test.c
+ - test/core/security/credentials_test.cc
deps:
- grpc_test_util
- grpc
@@ -2442,7 +2385,7 @@ targets:
run: false
language: c
src:
- - test/core/security/fetch_oauth2.c
+ - test/core/security/fetch_oauth2.cc
deps:
- grpc_test_util
- grpc
@@ -2452,17 +2395,18 @@ targets:
build: test
language: c
src:
- - test/core/surface/invalid_channel_args_test.c
+ - test/core/surface/invalid_channel_args_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_json_token_test
build: test
language: c
src:
- - test/core/security/json_token_test.c
+ - test/core/security/json_token_test.cc
deps:
- grpc_test_util
- grpc
@@ -2472,29 +2416,42 @@ targets:
- linux
- posix
- mac
+ uses_polling: false
- name: grpc_jwt_verifier_test
build: test
language: c
src:
- - test/core/security/jwt_verifier_test.c
+ - test/core/security/jwt_verifier_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: grpc_print_google_default_creds_token
build: tool
language: c
src:
- - test/core/security/print_google_default_creds_token.c
+ - test/core/security/print_google_default_creds_token.cc
deps:
- grpc
- gpr
+ uses_polling: false
- name: grpc_security_connector_test
build: test
language: c
src:
- - test/core/security/security_connector_test.c
+ - test/core/security/security_connector_test.cc
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
+- name: grpc_ssl_credentials_test
+ build: test
+ language: c
+ src:
+ - test/core/security/ssl_credentials_test.cc
deps:
- grpc_test_util
- grpc
@@ -2504,15 +2461,16 @@ targets:
build: tool
language: c
src:
- - test/core/security/verify_jwt.c
+ - test/core/security/verify_jwt.cc
deps:
- grpc
- gpr
+ uses_polling: false
- name: handshake_client
build: test
language: c
src:
- - test/core/handshake/client_ssl.c
+ - test/core/handshake/client_ssl.cc
deps:
- grpc_test_util
- grpc
@@ -2526,8 +2484,29 @@ targets:
- name: handshake_server
build: test
language: c
+ headers:
+ - test/core/handshake/server_ssl_common.h
+ src:
+ - test/core/handshake/server_ssl.cc
+ - test/core/handshake/server_ssl_common.cc
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
+ exclude_iomgrs:
+ - uv
+ platforms:
+ - linux
+ secure: true
+- name: handshake_server_with_readahead_handshaker
+ build: test
+ language: c
+ headers:
+ - test/core/handshake/server_ssl_common.h
src:
- - test/core/handshake/server_ssl.c
+ - test/core/handshake/readahead_handshaker_server_ssl.cc
+ - test/core/handshake/server_ssl_common.cc
deps:
- grpc_test_util
- grpc
@@ -2538,11 +2517,20 @@ targets:
platforms:
- linux
secure: true
+- name: histogram_test
+ build: test
+ language: c
+ src:
+ - test/core/util/histogram_test.cc
+ deps:
+ - grpc_test_util
+ - gpr
+ uses_polling: false
- name: hpack_parser_fuzzer_test
build: fuzzer
language: c
src:
- - test/core/transport/chttp2/hpack_parser_fuzzer_test.c
+ - test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
deps:
- grpc_test_util
- grpc
@@ -2556,37 +2544,40 @@ targets:
build: test
language: c
src:
- - test/core/transport/chttp2/hpack_parser_test.c
+ - test/core/transport/chttp2/hpack_parser_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: hpack_table_test
build: test
language: c
src:
- - test/core/transport/chttp2/hpack_table_test.c
+ - test/core/transport/chttp2/hpack_table_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: http_parser_test
build: test
language: c
src:
- - test/core/http/parser_test.c
+ - test/core/http/parser_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: http_request_fuzzer_test
build: fuzzer
language: c
src:
- - test/core/http/request_fuzzer.c
+ - test/core/http/request_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -2599,7 +2590,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/http/response_fuzzer.c
+ - test/core/http/response_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -2612,7 +2603,7 @@ targets:
build: test
language: c
src:
- - test/core/http/format_request_test.c
+ - test/core/http/format_request_test.cc
deps:
- grpc_test_util
- grpc
@@ -2623,7 +2614,7 @@ targets:
build: test
language: c
src:
- - test/core/http/httpcli_test.c
+ - test/core/http/httpcli_test.cc
deps:
- grpc_test_util
- grpc
@@ -2638,7 +2629,7 @@ targets:
build: test
language: c
src:
- - test/core/http/httpscli_test.c
+ - test/core/http/httpscli_test.cc
deps:
- grpc_test_util
- grpc
@@ -2650,18 +2641,19 @@ targets:
build: test
language: c
src:
- - test/core/surface/init_test.c
+ - test/core/surface/init_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: invalid_call_argument_test
cpu_cost: 0.1
build: test
language: c
src:
- - test/core/end2end/invalid_call_argument_test.c
+ - test/core/end2end/invalid_call_argument_test.cc
deps:
- grpc_test_util
- grpc
@@ -2671,7 +2663,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/json/fuzzer.c
+ - test/core/json/fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -2685,45 +2677,49 @@ targets:
run: false
language: c
src:
- - test/core/json/json_rewrite.c
+ - test/core/json/json_rewrite.cc
deps:
- grpc
- gpr
+ uses_polling: false
- name: json_rewrite_test
build: test
language: c
src:
- - test/core/json/json_rewrite_test.c
+ - test/core/json/json_rewrite_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: json_stream_error_test
build: test
language: c
src:
- - test/core/json/json_stream_error_test.c
+ - test/core/json/json_stream_error_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: json_test
build: test
language: c
src:
- - test/core/json/json_test.c
+ - test/core/json/json_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: lame_client_test
build: test
language: c
src:
- - test/core/surface/lame_client_test.c
+ - test/core/surface/lame_client_test.cc
deps:
- grpc_test_util
- grpc
@@ -2735,27 +2731,29 @@ targets:
run: false
language: c
src:
- - test/core/client_channel/lb_policies_test.c
+ - test/core/client_channel/lb_policies_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: load_file_test
build: test
language: c
src:
- - test/core/iomgr/load_file_test.c
+ - test/core/iomgr/load_file_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: low_level_ping_pong_benchmark
build: benchmark
language: c
src:
- - test/core/network_benchmarks/low_level_ping_pong.c
+ - test/core/network_benchmarks/low_level_ping_pong.cc
deps:
- grpc_test_util
- grpc
@@ -2770,18 +2768,19 @@ targets:
run: false
language: c
src:
- - test/core/memory_usage/client.c
+ - test/core/memory_usage/client.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: memory_profile_server
build: test
run: false
language: c
src:
- - test/core/memory_usage/server.c
+ - test/core/memory_usage/server.cc
deps:
- grpc_test_util
- grpc
@@ -2792,7 +2791,7 @@ targets:
build: test
language: c
src:
- - test/core/memory_usage/memory_usage_test.c
+ - test/core/memory_usage/memory_usage_test.cc
deps:
- grpc_test_util
- grpc
@@ -2806,38 +2805,29 @@ targets:
build: test
language: c
src:
- - test/core/compression/message_compress_test.c
+ - test/core/compression/message_compress_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: minimal_stack_is_minimal_test
build: test
language: c
src:
- - test/core/channel/minimal_stack_is_minimal_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
-- name: mlog_test
- flaky: true
- build: test
- language: c
- src:
- - test/core/census/mlog_test.c
+ - test/core/channel/minimal_stack_is_minimal_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: multiple_server_queues_test
build: test
language: c
src:
- - test/core/end2end/multiple_server_queues_test.c
+ - test/core/end2end/multiple_server_queues_test.cc
deps:
- grpc_test_util
- grpc
@@ -2847,15 +2837,16 @@ targets:
build: test
language: c
src:
- - test/core/support/murmur_hash_test.c
+ - test/core/gpr/murmur_hash_test.cc
deps:
- gpr_test_util
- gpr
+ uses_polling: false
- name: nanopb_fuzzer_response_test
build: fuzzer
language: c
src:
- - test/core/nanopb/fuzzer_response.c
+ - test/core/nanopb/fuzzer_response.cc
deps:
- grpc_test_util
- grpc
@@ -2868,7 +2859,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/nanopb/fuzzer_serverlist.c
+ - test/core/nanopb/fuzzer_serverlist.cc
deps:
- grpc_test_util
- grpc
@@ -2882,7 +2873,7 @@ targets:
build: test
language: c
src:
- - test/core/end2end/no_server_test.c
+ - test/core/end2end/no_server_test.cc
deps:
- grpc_test_util
- grpc
@@ -2892,7 +2883,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/num_external_connectivity_watchers_test.c
+ - test/core/surface/num_external_connectivity_watchers_test.cc
deps:
- grpc_test_util
- grpc
@@ -2904,17 +2895,18 @@ targets:
build: test
language: c
src:
- - test/core/client_channel/parse_address_test.c
+ - test/core/client_channel/parse_address_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: percent_decode_fuzzer
build: fuzzer
language: c
src:
- - test/core/slice/percent_decode_fuzzer.c
+ - test/core/slice/percent_decode_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -2927,7 +2919,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/slice/percent_encode_fuzzer.c
+ - test/core/slice/percent_encode_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -2940,17 +2932,18 @@ targets:
build: test
language: c
src:
- - test/core/slice/percent_encoding_test.c
+ - test/core/slice/percent_encoding_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: pollset_set_test
build: test
language: c
src:
- - test/core/iomgr/pollset_set_test.c
+ - test/core/iomgr/pollset_set_test.cc
deps:
- grpc_test_util
- grpc
@@ -2964,7 +2957,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/resolve_address_posix_test.c
+ - test/core/iomgr/resolve_address_posix_test.cc
deps:
- grpc_test_util
- grpc
@@ -2980,7 +2973,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/resolve_address_test.c
+ - test/core/iomgr/resolve_address_test.cc
deps:
- grpc_test_util
- grpc
@@ -2991,7 +2984,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/resource_quota_test.c
+ - test/core/iomgr/resource_quota_test.cc
deps:
- grpc_test_util
- grpc
@@ -3001,7 +2994,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/secure_channel_create_test.c
+ - test/core/surface/secure_channel_create_test.cc
deps:
- grpc_test_util
- grpc
@@ -3011,7 +3004,7 @@ targets:
build: test
language: c
src:
- - test/core/security/secure_endpoint_test.c
+ - test/core/security/secure_endpoint_test.cc
deps:
- grpc_test_util
- grpc
@@ -3023,7 +3016,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/sequential_connectivity_test.c
+ - test/core/surface/sequential_connectivity_test.cc
deps:
- grpc_test_util
- grpc
@@ -3035,7 +3028,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/server_chttp2_test.c
+ - test/core/surface/server_chttp2_test.cc
deps:
- grpc_test_util
- grpc
@@ -3045,7 +3038,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/end2end/fuzzers/server_fuzzer.c
+ - test/core/end2end/fuzzers/server_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -3059,7 +3052,7 @@ targets:
build: test
language: c
src:
- - test/core/surface/server_test.c
+ - test/core/surface/server_test.cc
deps:
- grpc_test_util
- grpc
@@ -3069,47 +3062,51 @@ targets:
build: test
language: c
src:
- - test/core/slice/slice_buffer_test.c
+ - test/core/slice/slice_buffer_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: slice_hash_table_test
build: test
language: c
src:
- - test/core/slice/slice_hash_table_test.c
+ - test/core/slice/slice_hash_table_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: slice_string_helpers_test
build: test
language: c
src:
- - test/core/slice/slice_string_helpers_test.c
+ - test/core/slice/slice_string_helpers_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: slice_test
build: test
language: c
src:
- - test/core/slice/slice_test.c
+ - test/core/slice/slice_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: sockaddr_resolver_test
build: test
language: c
src:
- - test/core/client_channel/resolvers/sockaddr_resolver_test.c
+ - test/core/client_channel/resolvers/sockaddr_resolver_test.cc
deps:
- grpc_test_util
- grpc
@@ -3119,7 +3116,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/sockaddr_utils_test.c
+ - test/core/iomgr/sockaddr_utils_test.cc
deps:
- grpc_test_util
- grpc
@@ -3129,7 +3126,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/socket_utils_test.c
+ - test/core/iomgr/socket_utils_test.cc
deps:
- grpc_test_util
- grpc
@@ -3145,7 +3142,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/security/ssl_server_fuzzer.c
+ - test/core/security/ssl_server_fuzzer.cc
deps:
- grpc_test_util
- grpc
@@ -3158,7 +3155,7 @@ targets:
build: test
language: c
src:
- - test/core/tsi/ssl_transport_security_test.c
+ - test/core/tsi/ssl_transport_security_test.cc
deps:
- gpr_test_util
- gpr
@@ -3173,38 +3170,41 @@ targets:
build: test
language: c
src:
- - test/core/transport/status_conversion_test.c
+ - test/core/transport/status_conversion_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: stream_compression_test
build: test
language: c
src:
- - test/core/compression/stream_compression_test.c
+ - test/core/compression/stream_compression_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: stream_owned_slice_test
build: test
language: c
src:
- - test/core/transport/stream_owned_slice_test.c
+ - test/core/transport/stream_owned_slice_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: tcp_client_posix_test
cpu_cost: 0.5
build: test
language: c
src:
- - test/core/iomgr/tcp_client_posix_test.c
+ - test/core/iomgr/tcp_client_posix_test.cc
deps:
- grpc_test_util
- grpc
@@ -3221,7 +3221,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/tcp_client_uv_test.c
+ - test/core/iomgr/tcp_client_uv_test.cc
deps:
- grpc_test_util
- grpc
@@ -3234,7 +3234,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/tcp_posix_test.c
+ - test/core/iomgr/tcp_posix_test.cc
deps:
- grpc_test_util
- grpc
@@ -3250,7 +3250,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/tcp_server_posix_test.c
+ - test/core/iomgr/tcp_server_posix_test.cc
deps:
- grpc_test_util
- grpc
@@ -3266,7 +3266,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/tcp_server_uv_test.c
+ - test/core/iomgr/tcp_server_uv_test.cc
deps:
- grpc_test_util
- grpc
@@ -3278,27 +3278,29 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/time_averaged_stats_test.c
+ - test/core/iomgr/time_averaged_stats_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: timeout_encoding_test
build: test
language: c
src:
- - test/core/transport/timeout_encoding_test.c
+ - test/core/transport/timeout_encoding_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: timer_heap_test
build: test
language: c
src:
- - test/core/iomgr/timer_heap_test.c
+ - test/core/iomgr/timer_heap_test.cc
deps:
- grpc_test_util
- grpc
@@ -3306,11 +3308,12 @@ targets:
- gpr
exclude_iomgrs:
- uv
+ uses_polling: false
- name: timer_list_test
build: test
language: c
src:
- - test/core/iomgr/timer_list_test.c
+ - test/core/iomgr/timer_list_test.cc
deps:
- grpc_test_util
- grpc
@@ -3318,11 +3321,12 @@ targets:
- gpr
exclude_iomgrs:
- uv
+ uses_polling: false
- name: transport_connectivity_state_test
build: test
language: c
src:
- - test/core/transport/connectivity_state_test.c
+ - test/core/transport/connectivity_state_test.cc
deps:
- grpc_test_util
- grpc
@@ -3332,17 +3336,7 @@ targets:
build: test
language: c
src:
- - test/core/transport/metadata_test.c
- deps:
- - grpc_test_util
- - grpc
- - gpr_test_util
- - gpr
-- name: transport_pid_controller_test
- build: test
- language: c
- src:
- - test/core/transport/pid_controller_test.c
+ - test/core/transport/metadata_test.cc
deps:
- grpc_test_util
- grpc
@@ -3352,7 +3346,7 @@ targets:
build: test
language: c
src:
- - test/core/tsi/transport_security_test.c
+ - test/core/tsi/transport_security_test.cc
deps:
- grpc_test_util
- grpc
@@ -3366,7 +3360,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/udp_server_test.c
+ - test/core/iomgr/udp_server_test.cc
deps:
- grpc_test_util
- grpc
@@ -3382,7 +3376,7 @@ targets:
build: fuzzer
language: c
src:
- - test/core/client_channel/uri_fuzzer_test.c
+ - test/core/client_channel/uri_fuzzer_test.cc
deps:
- grpc_test_util
- grpc
@@ -3395,7 +3389,7 @@ targets:
build: test
language: c
src:
- - test/core/client_channel/uri_parser_test.c
+ - test/core/client_channel/uri_parser_test.cc
deps:
- grpc_test_util
- grpc
@@ -3405,7 +3399,7 @@ targets:
build: test
language: c
src:
- - test/core/iomgr/wakeup_fd_cv_test.c
+ - test/core/iomgr/wakeup_fd_cv_test.cc
deps:
- grpc_test_util
- grpc
@@ -3456,6 +3450,31 @@ targets:
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
+- name: backoff_test
+ build: test
+ language: c++
+ src:
+ - test/core/backoff/backoff_test.cc
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses_polling: false
+- name: bdp_estimator_test
+ build: test
+ language: c++
+ src:
+ - test/core/transport/bdp_estimator_test.cc
+ deps:
+ - grpc++_test_util
+ - grpc++
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses_polling: false
- name: bm_arena
build: test
language: c++
@@ -3470,13 +3489,13 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
- linux
- posix
+ uses_polling: false
- name: bm_call_create
build: test
language: c++
@@ -3491,13 +3510,13 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
- linux
- posix
+ uses_polling: false
- name: bm_chttp2_hpack
build: test
language: c++
@@ -3512,13 +3531,13 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
- linux
- posix
+ uses_polling: false
- name: bm_chttp2_transport
build: test
language: c++
@@ -3533,8 +3552,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3554,8 +3572,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3575,8 +3592,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3596,8 +3612,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=4
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3617,13 +3632,13 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
- linux
- posix
+ uses_polling: false
- name: bm_fullstack_streaming_ping_pong
build: test
language: c++
@@ -3640,8 +3655,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3667,8 +3681,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3693,9 +3706,10 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
+ exclude_configs:
+ - tsan
excluded_poll_engines:
- poll
- poll-cv
@@ -3720,8 +3734,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3745,13 +3758,13 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
- linux
- posix
+ uses_polling: false
- name: bm_pollset
build: test
language: c++
@@ -3766,8 +3779,7 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- args:
- - --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3783,6 +3795,7 @@ targets:
- grpc++
- grpc
- gpr
+ uses_polling: false
- name: channel_filter_test
gtest: true
build: test
@@ -3793,6 +3806,19 @@ targets:
- grpc++
- grpc
- gpr
+ uses_polling: false
+- name: chttp2_settings_timeout_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/transport/chttp2/settings_timeout_test.cc
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses_polling: true
- name: cli_call_test
gtest: true
build: test
@@ -3807,6 +3833,20 @@ targets:
- grpc
- gpr_test_util
- gpr
+- name: client_channel_stress_test
+ gtest: false
+ build: test
+ language: c++
+ src:
+ - src/proto/grpc/lb/v1/load_balancer.proto
+ - test/cpp/client/client_channel_stress_test.cc
+ deps:
+ - grpc++_test_util
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
- name: client_crash_test
gtest: true
cpu_cost: 0.1
@@ -3851,9 +3891,6 @@ targets:
- grpc
- gpr_test_util
- gpr
- excluded_poll_engines:
- - poll
- - poll-cv
- name: codegen_test_full
gtest: true
build: test
@@ -3872,6 +3909,7 @@ targets:
- gpr
filegroups:
- grpc++_codegen_base
+ uses_polling: false
- name: codegen_test_minimal
gtest: true
build: test
@@ -3890,6 +3928,7 @@ targets:
filegroups:
- grpc++_codegen_base
- grpc++_codegen_base_src
+ uses_polling: false
- name: credentials_test
gtest: true
build: test
@@ -3912,6 +3951,7 @@ targets:
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: cxx_slice_test
gtest: true
build: test
@@ -3924,6 +3964,7 @@ targets:
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: cxx_string_ref_test
gtest: true
build: test
@@ -3933,6 +3974,7 @@ targets:
deps:
- grpc++
- grpc
+ uses_polling: false
- name: cxx_time_test
gtest: true
build: test
@@ -3945,6 +3987,7 @@ targets:
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: end2end_test
gtest: true
cpu_cost: 0.5
@@ -3969,6 +4012,19 @@ targets:
deps:
- grpc++_error_details
- grpc++
+- name: exception_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/cpp/end2end/exception_test.cc
+ deps:
+ - grpc++_test_util
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
- name: filter_end2end_test
gtest: true
build: test
@@ -4008,6 +4064,7 @@ targets:
- gpr
args:
- --generated_file_path=gens/src/proto/grpc/testing/
+ uses_polling: false
- name: grpc_cli
build: test
run: false
@@ -4135,9 +4192,6 @@ targets:
- grpc
- gpr_test_util
- gpr
- excluded_poll_engines:
- - poll
- - poll-cv
- name: grpclb_test
gtest: false
build: test
@@ -4152,9 +4206,22 @@ targets:
- grpc
- gpr_test_util
- gpr
- excluded_poll_engines:
- - poll
- - poll-cv
+- name: h2_ssl_cert_test
+ gtest: true
+ build: test
+ language: c++
+ headers:
+ - test/core/end2end/end2end_tests.h
+ src:
+ - test/core/end2end/h2_ssl_cert_test.cc
+ deps:
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses:
+ - grpc++_test
- name: health_service_end2end_test
gtest: true
build: test
@@ -4197,6 +4264,39 @@ targets:
- grpc
- gpr_test_util
- gpr
+- name: inlined_vector_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/gprpp/inlined_vector_test.cc
+ deps:
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses:
+ - grpc++_test
+- name: inproc_sync_unary_ping_pong_test
+ build: test
+ language: c++
+ src:
+ - test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
+ deps:
+ - qps
+ - grpc++_core_stats
+ - grpc++_test_util
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ - grpc++_test_config
+ platforms:
+ - mac
+ - linux
+ - posix
- name: interop_client
build: test
run: false
@@ -4275,7 +4375,7 @@ targets:
build: test
language: c++
src:
- - test/core/support/memory_test.cc
+ - test/core/gprpp/memory_test.cc
deps:
- grpc_test_util
- grpc++
@@ -4284,6 +4384,7 @@ targets:
- gpr
uses:
- grpc++_test
+ uses_polling: false
- name: metrics_client
build: test
run: false
@@ -4321,6 +4422,20 @@ targets:
deps:
- benchmark
defaults: benchmark
+- name: orphanable_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/gprpp/orphanable_test.cc
+ deps:
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses:
+ - grpc++_test
- name: proto_server_reflection_test
gtest: true
build: test
@@ -4348,6 +4463,7 @@ targets:
filegroups:
- grpc++_codegen_base
- grpc++_codegen_proto
+ uses_polling: false
- name: qps_interarrival_test
build: test
run: false
@@ -4367,6 +4483,7 @@ targets:
- mac
- linux
- posix
+ uses_polling: false
- name: qps_json_driver
build: test
run: false
@@ -4458,6 +4575,34 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
+- name: ref_counted_ptr_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/gprpp/ref_counted_ptr_test.cc
+ deps:
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses:
+ - grpc++_test
+- name: ref_counted_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/gprpp/ref_counted_test.cc
+ deps:
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ uses:
+ - grpc++_test
- name: secure_auth_context_test
gtest: true
build: test
@@ -4563,6 +4708,19 @@ targets:
- grpc
- gpr_test_util
- gpr
+- name: server_early_return_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/cpp/end2end/server_early_return_test.cc
+ deps:
+ - grpc++_test_util
+ - grpc_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
- name: server_request_call_test
gtest: true
build: test
@@ -4603,6 +4761,10 @@ targets:
- grpc
- gpr_test_util
- gpr
+ exclude_configs:
+ - tsan
+ timeout_seconds: 1200
+ uses_polling: false
- name: status_test
build: test
language: c++
@@ -4614,6 +4776,7 @@ targets:
- grpc
- gpr_test_util
- gpr
+ uses_polling: false
- name: streaming_throughput_test
gtest: true
build: test
@@ -4682,7 +4845,18 @@ targets:
- grpc_unsecure
- gpr_test_util
- gpr
- timeout_seconds: 1200
+- name: transport_pid_controller_test
+ build: test
+ language: c++
+ src:
+ - test/core/transport/pid_controller_test.cc
+ deps:
+ - grpc++_test_util
+ - grpc++
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
- name: writes_per_rpc_test
gtest: true
cpu_cost: 0.5
@@ -4709,6 +4883,28 @@ targets:
deps:
- grpc
- gpr
+- name: gen_hpack_tables
+ build: tool
+ language: cc
+ src:
+ - tools/codegen/core/gen_hpack_tables.cc
+ deps:
+ - gpr
+ - grpc
+ uses_polling: false
+- name: gen_legal_metadata_characters
+ build: tool
+ language: cc
+ src:
+ - tools/codegen/core/gen_legal_metadata_characters.cc
+ deps: []
+- name: gen_percent_encoding_tables
+ build: tool
+ language: cc
+ src:
+ - tools/codegen/core/gen_percent_encoding_tables.cc
+ deps: []
+ uses_polling: false
vspackages:
- linkage: static
name: grpc.dependencies.zlib
@@ -4776,7 +4972,6 @@ configs:
DEFINES: NDEBUG
dbg:
CPPFLAGS: -O0
- CXXFLAGS: -fno-exceptions
DEFINES: _DEBUG DEBUG
gcov:
CC: gcc
@@ -4784,7 +4979,7 @@ configs:
CXX: g++
DEFINES: _DEBUG DEBUG GPR_GCOV
LD: gcc
- LDFLAGS: -fprofile-arcs -ftest-coverage -rdynamic
+ LDFLAGS: -fprofile-arcs -ftest-coverage -rdynamic -lstdc++
LDXX: g++
helgrind:
CPPFLAGS: -O0
@@ -4802,8 +4997,8 @@ configs:
msan:
CC: clang
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins
- -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
- -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
+ -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0
+ -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++
DEFINES: NDEBUG
LD: clang++
@@ -4811,14 +5006,19 @@ configs:
-fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
LDXX: clang++
compile_the_world: true
+ test_environ:
+ MSAN_OPTIONS: poison_in_dtor=1
mutrace:
CPPFLAGS: -O3 -fno-omit-frame-pointer
DEFINES: NDEBUG
LDFLAGS: -rdynamic
- opt:
+ noexcept:
CPPFLAGS: -O2
CXXFLAGS: -fno-exceptions
DEFINES: NDEBUG
+ opt:
+ CPPFLAGS: -O2
+ DEFINES: NDEBUG
stapprof:
CPPFLAGS: -O2 -DGRPC_STAP_PROFILER
DEFINES: NDEBUG
@@ -4850,62 +5050,27 @@ defaults:
ares:
CFLAGS: -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32)
$(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
- CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux)
- $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden
- -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst
- MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
+ CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares -fvisibility=hidden -D_GNU_SOURCE
+ $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) $(if $(subst
+ FreeBSD,,$(SYSTEM)),,-Ithird_party/cares/config_freebsd) $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux)
+ $(if $(subst OpenBSD,,$(SYSTEM)),,-Ithird_party/cares/config_openbsd) -DWIN32_LEAN_AND_MEAN
+ -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
benchmark:
CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX
boringssl:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas
- -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
+ -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough
+ $(NO_W_EXTRA_SEMI)
CPPFLAGS: -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM
-D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
global:
+ COREFLAGS: -fno-rtti -fno-exceptions
CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1
+ -Wno-deprecated-declarations
LDFLAGS: -g
zlib:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration
- $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden
-node_modules:
-- deps:
- - grpc
- - gpr
- - boringssl
- - z
- headers:
- - src/node/ext/byte_buffer.h
- - src/node/ext/call.h
- - src/node/ext/call_credentials.h
- - src/node/ext/channel.h
- - src/node/ext/channel_credentials.h
- - src/node/ext/completion_queue.h
- - src/node/ext/server.h
- - src/node/ext/server_credentials.h
- - src/node/ext/slice.h
- - src/node/ext/timeval.h
- js:
- - src/node/index.js
- - src/node/src/client.js
- - src/node/src/common.js
- - src/node/src/credentials.js
- - src/node/src/constants.js
- - src/node/src/grpc_extension.js
- - src/node/src/metadata.js
- - src/node/src/server.js
- name: grpc_node
- src:
- - src/node/ext/byte_buffer.cc
- - src/node/ext/call.cc
- - src/node/ext/call_credentials.cc
- - src/node/ext/channel.cc
- - src/node/ext/channel_credentials.cc
- - src/node/ext/completion_queue.cc
- - src/node/ext/node_grpc.cc
- - src/node/ext/server.cc
- - src/node/ext/server_credentials.cc
- - src/node/ext/slice.cc
- - src/node/ext/timeval.cc
+ -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden
openssl_fallback:
base_uri: https://openssl.org/source/old/1.0.2/
extraction_dir: openssl-1.0.2f
diff --git a/cmake/benchmark.cmake b/cmake/benchmark.cmake
new file mode 100644
index 0000000000..753dc0696f
--- /dev/null
+++ b/cmake/benchmark.cmake
@@ -0,0 +1,36 @@
+# 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.
+
+if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module")
+ if(NOT BENCHMARK_ROOT_DIR)
+ set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
+ endif()
+ if(EXISTS "${BENCHMARK_ROOT_DIR}/CMakeLists.txt")
+ add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
+ if(TARGET benchmark)
+ set(_gRPC_BENCHMARK_LIBRARIES benchmark)
+ set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
+ endif()
+ else()
+ message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
+ endif()
+elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package")
+ find_package(benchmark REQUIRED)
+ if(TARGET benchmark::benchmark)
+ set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark)
+ # extract the include dir from target's properties
+ get_target_property(_gRPC_BENCHMARK_INCLUDE_DIR benchmark::benchmark INTERFACE_INCLUDE_DIRECTORIES)
+ endif()
+ set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark)\nendif()")
+endif()
diff --git a/cmake/cares.cmake b/cmake/cares.cmake
new file mode 100644
index 0000000000..53d7582f6f
--- /dev/null
+++ b/cmake/cares.cmake
@@ -0,0 +1,39 @@
+# 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.
+
+if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
+ if(NOT CARES_ROOT_DIR)
+ set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares)
+ endif()
+ set(CARES_SHARED OFF CACHE BOOL "disable shared library")
+ set(CARES_STATIC ON CACHE BOOL "link cares statically")
+ add_subdirectory(third_party/cares/cares)
+
+ if(TARGET c-ares)
+ set(_gRPC_CARES_LIBRARIES c-ares)
+ set(_gRPC_CARES_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares" "${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares")
+ endif()
+
+ if(gRPC_INSTALL)
+ message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
+elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package")
+ find_package(c-ares REQUIRED CONFIG)
+ if(TARGET c-ares::cares)
+ set(_gRPC_CARES_LIBRARIES c-ares::cares)
+ set(_gRPC_CARES_INCLUDE_DIR ${c-ares_INCLUDE_DIR})
+ endif()
+ set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
+endif()
diff --git a/cmake/gflags.cmake b/cmake/gflags.cmake
new file mode 100644
index 0000000000..f86a141c1d
--- /dev/null
+++ b/cmake/gflags.cmake
@@ -0,0 +1,35 @@
+# 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.
+
+if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
+ if(NOT GFLAGS_ROOT_DIR)
+ set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
+ endif()
+ if(EXISTS "${GFLAGS_ROOT_DIR}/CMakeLists.txt")
+ add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags)
+ if(TARGET gflags_static)
+ set(_gRPC_GFLAGS_LIBRARIES gflags_static)
+ set(_gRPC_GFLAGS_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
+ endif()
+ else()
+ message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
+ endif()
+elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package")
+ find_package(gflags REQUIRED)
+ if(TARGET gflags::gflags)
+ set(_gRPC_GFLAGS_LIBRARIES gflags::gflags)
+ set(_gRPC_GFLAGS_INCLUDE_DIR ${GFLAGS_INCLUDE_DIR})
+ endif()
+ set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags)\nendif()")
+endif()
diff --git a/cmake/msvc_static_runtime.cmake b/cmake/msvc_static_runtime.cmake
index fc6d1d62d3..844bd02653 100644
--- a/cmake/msvc_static_runtime.cmake
+++ b/cmake/msvc_static_runtime.cmake
@@ -1,3 +1,17 @@
+# 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.
+
option(gRPC_MSVC_STATIC_RUNTIME "Link with static msvc runtime libraries" OFF)
if(gRPC_MSVC_STATIC_RUNTIME)
diff --git a/cmake/protobuf.cmake b/cmake/protobuf.cmake
new file mode 100644
index 0000000000..cb799b5295
--- /dev/null
+++ b/cmake/protobuf.cmake
@@ -0,0 +1,85 @@
+# 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.
+
+if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
+ # Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
+ # Disable them unless they are explicitly requested from the cmake command line (when we assume
+ # gmock is downloaded to the right location inside protobuf).
+ if(NOT protobuf_BUILD_TESTS)
+ set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
+ endif()
+ # Disable building protobuf with zlib. Building protobuf with zlib breaks
+ # the build if zlib is not installed on the system.
+ if(NOT protobuf_WITH_ZLIB)
+ set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.")
+ endif()
+ if(NOT PROTOBUF_ROOT_DIR)
+ set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf)
+ endif()
+
+ if(EXISTS "${PROTOBUF_ROOT_DIR}/cmake/CMakeLists.txt")
+ set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
+ add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake third_party/protobuf)
+ if(TARGET ${_gRPC_PROTOBUF_LIBRARY_NAME})
+ set(_gRPC_PROTOBUF_LIBRARIES ${_gRPC_PROTOBUF_LIBRARY_NAME})
+ endif()
+ if(TARGET libprotoc)
+ set(_gRPC_PROTOBUF_PROTOC_LIBRARIES libprotoc)
+ endif()
+ if(TARGET protoc)
+ set(_gRPC_PROTOBUF_PROTOC protoc)
+ set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
+ endif()
+ set(_gRPC_PROTOBUF_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}")
+ # For well-known .proto files distributed with protobuf
+ set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src")
+ else()
+ message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
+ endif()
+ if(gRPC_INSTALL)
+ message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
+elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package")
+ find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE})
+
+ # {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG").
+ # For "MODULE", the case has also changed between cmake 3.5 and 3.6.
+ # We use the legacy uppercase version for *_LIBRARIES AND *_INCLUDE_DIRS variables
+ # as newer cmake versions provide them too for backward compatibility.
+ if(Protobuf_FOUND OR PROTOBUF_FOUND)
+ if(TARGET protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME})
+ set(_gRPC_PROTOBUF_LIBRARIES protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME})
+ else()
+ set(_gRPC_PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARIES})
+ endif()
+ if(TARGET protobuf::libprotoc)
+ set(_gRPC_PROTOBUF_PROTOC_LIBRARIES protobuf::libprotoc)
+ # extract the include dir from target's properties
+ get_target_property(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR protobuf::libprotoc INTERFACE_INCLUDE_DIRECTORIES)
+ else()
+ set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ${PROTOBUF_PROTOC_LIBRARIES})
+ set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIRS})
+ endif()
+ if(TARGET protobuf::protoc)
+ set(_gRPC_PROTOBUF_PROTOC protobuf::protoc)
+ set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protobuf::protoc>)
+ else()
+ set(_gRPC_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE})
+ set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
+ endif()
+ set(_gRPC_PROTOBUF_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIRS})
+ set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()")
+ endif()
+endif()
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
new file mode 100644
index 0000000000..75ce069fe6
--- /dev/null
+++ b/cmake/ssl.cmake
@@ -0,0 +1,38 @@
+# 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.
+
+if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
+ if(NOT BORINGSSL_ROOT_DIR)
+ set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
+ endif()
+ if(EXISTS "${BORINGSSL_ROOT_DIR}/CMakeLists.txt")
+ set(OPENSSL_NO_ASM ON) # make boringssl buildable with Visual Studio
+ add_subdirectory(${BORINGSSL_ROOT_DIR} third_party/boringssl)
+ if(TARGET ssl)
+ set(_gRPC_SSL_LIBRARIES ssl)
+ set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)
+ endif()
+ else()
+ message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
+ endif()
+ if(gRPC_INSTALL)
+ message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
+elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package")
+ find_package(OpenSSL REQUIRED)
+ set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES})
+ set(_gRPC_SSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
+ set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()")
+endif()
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake
new file mode 100644
index 0000000000..4a9d2f011b
--- /dev/null
+++ b/cmake/zlib.cmake
@@ -0,0 +1,40 @@
+# 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.
+
+if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
+ if(NOT ZLIB_ROOT_DIR)
+ set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
+ endif()
+ if(EXISTS "${ZLIB_ROOT_DIR}/CMakeLists.txt")
+ # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218
+ include_directories("${ZLIB_ROOT_DIR}")
+ add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib)
+
+ if(TARGET zlibstatic)
+ set(_gRPC_ZLIB_LIBRARIES zlibstatic)
+ set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib")
+ endif()
+ else()
+ message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
+ endif()
+ if(gRPC_INSTALL)
+ message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
+ set(gRPC_INSTALL FALSE)
+ endif()
+elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package")
+ find_package(ZLIB REQUIRED)
+ set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
+ set(_gRPC_ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS})
+ set(_gRPC_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
+endif()
diff --git a/config.m4 b/config.m4
index 72f8a1e710..1453d63987 100644
--- a/config.m4
+++ b/config.m4
@@ -39,313 +39,303 @@ if test "$PHP_GRPC" != "no"; then
src/php/ext/grpc/server.c \
src/php/ext/grpc/server_credentials.c \
src/php/ext/grpc/timeval.c \
- src/core/lib/profiling/basic_timers.c \
- src/core/lib/profiling/stap_timers.c \
- src/core/lib/support/alloc.c \
- src/core/lib/support/arena.c \
- src/core/lib/support/atm.c \
- src/core/lib/support/avl.c \
- src/core/lib/support/backoff.c \
- src/core/lib/support/cmdline.c \
- src/core/lib/support/cpu_iphone.c \
- src/core/lib/support/cpu_linux.c \
- src/core/lib/support/cpu_posix.c \
- src/core/lib/support/cpu_windows.c \
- src/core/lib/support/env_linux.c \
- src/core/lib/support/env_posix.c \
- src/core/lib/support/env_windows.c \
- src/core/lib/support/histogram.c \
- src/core/lib/support/host_port.c \
- src/core/lib/support/log.c \
- src/core/lib/support/log_android.c \
- src/core/lib/support/log_linux.c \
- src/core/lib/support/log_posix.c \
- src/core/lib/support/log_windows.c \
- src/core/lib/support/mpscq.c \
- src/core/lib/support/murmur_hash.c \
- src/core/lib/support/stack_lockfree.c \
- src/core/lib/support/string.c \
- src/core/lib/support/string_posix.c \
- src/core/lib/support/string_util_windows.c \
- src/core/lib/support/string_windows.c \
- src/core/lib/support/subprocess_posix.c \
- src/core/lib/support/subprocess_windows.c \
- src/core/lib/support/sync.c \
- src/core/lib/support/sync_posix.c \
- src/core/lib/support/sync_windows.c \
- src/core/lib/support/thd.c \
- src/core/lib/support/thd_posix.c \
- src/core/lib/support/thd_windows.c \
- src/core/lib/support/time.c \
- src/core/lib/support/time_posix.c \
- src/core/lib/support/time_precise.c \
- src/core/lib/support/time_windows.c \
- src/core/lib/support/tls_pthread.c \
- src/core/lib/support/tmpfile_msys.c \
- src/core/lib/support/tmpfile_posix.c \
- src/core/lib/support/tmpfile_windows.c \
- src/core/lib/support/wrap_memcpy.c \
- src/core/lib/surface/init.c \
- src/core/lib/channel/channel_args.c \
- src/core/lib/channel/channel_stack.c \
- src/core/lib/channel/channel_stack_builder.c \
- src/core/lib/channel/connected_channel.c \
- src/core/lib/channel/handshaker.c \
- src/core/lib/channel/handshaker_factory.c \
- src/core/lib/channel/handshaker_registry.c \
- src/core/lib/compression/compression.c \
- src/core/lib/compression/message_compress.c \
- src/core/lib/compression/stream_compression.c \
- src/core/lib/compression/stream_compression_gzip.c \
- src/core/lib/compression/stream_compression_identity.c \
- src/core/lib/debug/stats.c \
- src/core/lib/debug/stats_data.c \
- src/core/lib/http/format_request.c \
- src/core/lib/http/httpcli.c \
- src/core/lib/http/parser.c \
- src/core/lib/iomgr/call_combiner.c \
- src/core/lib/iomgr/closure.c \
- src/core/lib/iomgr/combiner.c \
- src/core/lib/iomgr/endpoint.c \
- src/core/lib/iomgr/endpoint_pair_posix.c \
- src/core/lib/iomgr/endpoint_pair_uv.c \
- src/core/lib/iomgr/endpoint_pair_windows.c \
- src/core/lib/iomgr/error.c \
- src/core/lib/iomgr/ev_epoll1_linux.c \
- src/core/lib/iomgr/ev_epollex_linux.c \
- src/core/lib/iomgr/ev_epollsig_linux.c \
- src/core/lib/iomgr/ev_poll_posix.c \
- src/core/lib/iomgr/ev_posix.c \
- src/core/lib/iomgr/ev_windows.c \
- src/core/lib/iomgr/exec_ctx.c \
- src/core/lib/iomgr/executor.c \
- src/core/lib/iomgr/gethostname_fallback.c \
- src/core/lib/iomgr/gethostname_host_name_max.c \
- src/core/lib/iomgr/gethostname_sysconf.c \
- src/core/lib/iomgr/iocp_windows.c \
- src/core/lib/iomgr/iomgr.c \
- src/core/lib/iomgr/iomgr_posix.c \
- src/core/lib/iomgr/iomgr_uv.c \
- src/core/lib/iomgr/iomgr_windows.c \
- src/core/lib/iomgr/is_epollexclusive_available.c \
- src/core/lib/iomgr/load_file.c \
- src/core/lib/iomgr/lockfree_event.c \
- src/core/lib/iomgr/network_status_tracker.c \
- src/core/lib/iomgr/polling_entity.c \
- src/core/lib/iomgr/pollset_set_uv.c \
- src/core/lib/iomgr/pollset_set_windows.c \
- src/core/lib/iomgr/pollset_uv.c \
- src/core/lib/iomgr/pollset_windows.c \
- src/core/lib/iomgr/resolve_address_posix.c \
- src/core/lib/iomgr/resolve_address_uv.c \
- src/core/lib/iomgr/resolve_address_windows.c \
- src/core/lib/iomgr/resource_quota.c \
- src/core/lib/iomgr/sockaddr_utils.c \
- src/core/lib/iomgr/socket_factory_posix.c \
- src/core/lib/iomgr/socket_mutator.c \
- src/core/lib/iomgr/socket_utils_common_posix.c \
- src/core/lib/iomgr/socket_utils_linux.c \
- src/core/lib/iomgr/socket_utils_posix.c \
- src/core/lib/iomgr/socket_utils_uv.c \
- src/core/lib/iomgr/socket_utils_windows.c \
- src/core/lib/iomgr/socket_windows.c \
- src/core/lib/iomgr/tcp_client_posix.c \
- src/core/lib/iomgr/tcp_client_uv.c \
- src/core/lib/iomgr/tcp_client_windows.c \
- src/core/lib/iomgr/tcp_posix.c \
- src/core/lib/iomgr/tcp_server_posix.c \
- src/core/lib/iomgr/tcp_server_utils_posix_common.c \
- src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
- src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
- src/core/lib/iomgr/tcp_server_uv.c \
- src/core/lib/iomgr/tcp_server_windows.c \
- src/core/lib/iomgr/tcp_uv.c \
- src/core/lib/iomgr/tcp_windows.c \
- src/core/lib/iomgr/time_averaged_stats.c \
- src/core/lib/iomgr/timer_generic.c \
- src/core/lib/iomgr/timer_heap.c \
- src/core/lib/iomgr/timer_manager.c \
- src/core/lib/iomgr/timer_uv.c \
- src/core/lib/iomgr/udp_server.c \
- src/core/lib/iomgr/unix_sockets_posix.c \
- src/core/lib/iomgr/unix_sockets_posix_noop.c \
- src/core/lib/iomgr/wakeup_fd_cv.c \
- src/core/lib/iomgr/wakeup_fd_eventfd.c \
- src/core/lib/iomgr/wakeup_fd_nospecial.c \
- src/core/lib/iomgr/wakeup_fd_pipe.c \
- src/core/lib/iomgr/wakeup_fd_posix.c \
- src/core/lib/json/json.c \
- src/core/lib/json/json_reader.c \
- src/core/lib/json/json_string.c \
- src/core/lib/json/json_writer.c \
- src/core/lib/slice/b64.c \
- src/core/lib/slice/percent_encoding.c \
- src/core/lib/slice/slice.c \
- src/core/lib/slice/slice_buffer.c \
- src/core/lib/slice/slice_hash_table.c \
- src/core/lib/slice/slice_intern.c \
- src/core/lib/slice/slice_string_helpers.c \
- src/core/lib/surface/alarm.c \
- src/core/lib/surface/api_trace.c \
- src/core/lib/surface/byte_buffer.c \
- src/core/lib/surface/byte_buffer_reader.c \
- src/core/lib/surface/call.c \
- src/core/lib/surface/call_details.c \
- src/core/lib/surface/call_log_batch.c \
- src/core/lib/surface/channel.c \
- src/core/lib/surface/channel_init.c \
- src/core/lib/surface/channel_ping.c \
- src/core/lib/surface/channel_stack_type.c \
- src/core/lib/surface/completion_queue.c \
- src/core/lib/surface/completion_queue_factory.c \
- src/core/lib/surface/event_string.c \
+ 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 \
+ src/core/lib/gpr/cpu_posix.cc \
+ src/core/lib/gpr/cpu_windows.cc \
+ src/core/lib/gpr/env_linux.cc \
+ src/core/lib/gpr/env_posix.cc \
+ src/core/lib/gpr/env_windows.cc \
+ src/core/lib/gpr/fork.cc \
+ src/core/lib/gpr/host_port.cc \
+ src/core/lib/gpr/log.cc \
+ src/core/lib/gpr/log_android.cc \
+ src/core/lib/gpr/log_linux.cc \
+ src/core/lib/gpr/log_posix.cc \
+ src/core/lib/gpr/log_windows.cc \
+ src/core/lib/gpr/mpscq.cc \
+ src/core/lib/gpr/murmur_hash.cc \
+ src/core/lib/gpr/string.cc \
+ 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 \
+ src/core/lib/gpr/thd.cc \
+ src/core/lib/gpr/thd_posix.cc \
+ src/core/lib/gpr/thd_windows.cc \
+ src/core/lib/gpr/time.cc \
+ src/core/lib/gpr/time_posix.cc \
+ src/core/lib/gpr/time_precise.cc \
+ src/core/lib/gpr/time_windows.cc \
+ src/core/lib/gpr/tls_pthread.cc \
+ 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/wrap_memcpy.cc \
+ src/core/lib/profiling/basic_timers.cc \
+ src/core/lib/profiling/stap_timers.cc \
+ src/core/lib/surface/init.cc \
+ src/core/lib/backoff/backoff.cc \
+ src/core/lib/channel/channel_args.cc \
+ src/core/lib/channel/channel_stack.cc \
+ src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/connected_channel.cc \
+ src/core/lib/channel/handshaker.cc \
+ src/core/lib/channel/handshaker_factory.cc \
+ 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 \
+ src/core/lib/compression/stream_compression_identity.cc \
+ src/core/lib/debug/stats.cc \
+ src/core/lib/debug/stats_data.cc \
+ src/core/lib/http/format_request.cc \
+ src/core/lib/http/httpcli.cc \
+ src/core/lib/http/parser.cc \
+ src/core/lib/iomgr/call_combiner.cc \
+ src/core/lib/iomgr/combiner.cc \
+ src/core/lib/iomgr/endpoint.cc \
+ src/core/lib/iomgr/endpoint_pair_posix.cc \
+ src/core/lib/iomgr/endpoint_pair_uv.cc \
+ src/core/lib/iomgr/endpoint_pair_windows.cc \
+ src/core/lib/iomgr/error.cc \
+ src/core/lib/iomgr/ev_epoll1_linux.cc \
+ src/core/lib/iomgr/ev_epollex_linux.cc \
+ src/core/lib/iomgr/ev_epollsig_linux.cc \
+ src/core/lib/iomgr/ev_poll_posix.cc \
+ src/core/lib/iomgr/ev_posix.cc \
+ src/core/lib/iomgr/ev_windows.cc \
+ src/core/lib/iomgr/exec_ctx.cc \
+ src/core/lib/iomgr/executor.cc \
+ src/core/lib/iomgr/fork_posix.cc \
+ src/core/lib/iomgr/fork_windows.cc \
+ src/core/lib/iomgr/gethostname_fallback.cc \
+ src/core/lib/iomgr/gethostname_host_name_max.cc \
+ src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/iocp_windows.cc \
+ src/core/lib/iomgr/iomgr.cc \
+ src/core/lib/iomgr/iomgr_posix.cc \
+ src/core/lib/iomgr/iomgr_uv.cc \
+ src/core/lib/iomgr/iomgr_windows.cc \
+ src/core/lib/iomgr/is_epollexclusive_available.cc \
+ src/core/lib/iomgr/load_file.cc \
+ src/core/lib/iomgr/lockfree_event.cc \
+ src/core/lib/iomgr/network_status_tracker.cc \
+ src/core/lib/iomgr/polling_entity.cc \
+ src/core/lib/iomgr/pollset_set_uv.cc \
+ src/core/lib/iomgr/pollset_set_windows.cc \
+ src/core/lib/iomgr/pollset_uv.cc \
+ src/core/lib/iomgr/pollset_windows.cc \
+ src/core/lib/iomgr/resolve_address_posix.cc \
+ src/core/lib/iomgr/resolve_address_uv.cc \
+ src/core/lib/iomgr/resolve_address_windows.cc \
+ src/core/lib/iomgr/resource_quota.cc \
+ src/core/lib/iomgr/sockaddr_utils.cc \
+ src/core/lib/iomgr/socket_factory_posix.cc \
+ src/core/lib/iomgr/socket_mutator.cc \
+ src/core/lib/iomgr/socket_utils_common_posix.cc \
+ src/core/lib/iomgr/socket_utils_linux.cc \
+ src/core/lib/iomgr/socket_utils_posix.cc \
+ src/core/lib/iomgr/socket_utils_uv.cc \
+ src/core/lib/iomgr/socket_utils_windows.cc \
+ src/core/lib/iomgr/socket_windows.cc \
+ src/core/lib/iomgr/tcp_client_posix.cc \
+ src/core/lib/iomgr/tcp_client_uv.cc \
+ src/core/lib/iomgr/tcp_client_windows.cc \
+ src/core/lib/iomgr/tcp_posix.cc \
+ src/core/lib/iomgr/tcp_server_posix.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+ src/core/lib/iomgr/tcp_server_uv.cc \
+ src/core/lib/iomgr/tcp_server_windows.cc \
+ src/core/lib/iomgr/tcp_uv.cc \
+ src/core/lib/iomgr/tcp_windows.cc \
+ src/core/lib/iomgr/time_averaged_stats.cc \
+ src/core/lib/iomgr/timer_generic.cc \
+ src/core/lib/iomgr/timer_heap.cc \
+ src/core/lib/iomgr/timer_manager.cc \
+ src/core/lib/iomgr/timer_uv.cc \
+ src/core/lib/iomgr/udp_server.cc \
+ src/core/lib/iomgr/unix_sockets_posix.cc \
+ src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+ src/core/lib/iomgr/wakeup_fd_cv.cc \
+ src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+ src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+ src/core/lib/iomgr/wakeup_fd_pipe.cc \
+ src/core/lib/iomgr/wakeup_fd_posix.cc \
+ src/core/lib/json/json.cc \
+ src/core/lib/json/json_reader.cc \
+ src/core/lib/json/json_string.cc \
+ src/core/lib/json/json_writer.cc \
+ src/core/lib/slice/b64.cc \
+ src/core/lib/slice/percent_encoding.cc \
+ src/core/lib/slice/slice.cc \
+ src/core/lib/slice/slice_buffer.cc \
+ 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 \
+ src/core/lib/surface/call.cc \
+ src/core/lib/surface/call_details.cc \
+ src/core/lib/surface/call_log_batch.cc \
+ src/core/lib/surface/channel.cc \
+ src/core/lib/surface/channel_init.cc \
+ src/core/lib/surface/channel_ping.cc \
+ src/core/lib/surface/channel_stack_type.cc \
+ src/core/lib/surface/completion_queue.cc \
+ src/core/lib/surface/completion_queue_factory.cc \
+ src/core/lib/surface/event_string.cc \
src/core/lib/surface/lame_client.cc \
- src/core/lib/surface/metadata_array.c \
- src/core/lib/surface/server.c \
- src/core/lib/surface/validate_metadata.c \
- src/core/lib/surface/version.c \
- src/core/lib/transport/bdp_estimator.c \
- src/core/lib/transport/byte_stream.c \
- src/core/lib/transport/connectivity_state.c \
- src/core/lib/transport/error_utils.c \
- src/core/lib/transport/metadata.c \
- src/core/lib/transport/metadata_batch.c \
- src/core/lib/transport/pid_controller.c \
- src/core/lib/transport/service_config.c \
- src/core/lib/transport/static_metadata.c \
- src/core/lib/transport/status_conversion.c \
- src/core/lib/transport/timeout_encoding.c \
- src/core/lib/transport/transport.c \
- src/core/lib/transport/transport_op_string.c \
- src/core/lib/debug/trace.c \
- src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \
- src/core/ext/transport/chttp2/transport/bin_decoder.c \
- src/core/ext/transport/chttp2/transport/bin_encoder.c \
- src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
- src/core/ext/transport/chttp2/transport/chttp2_transport.c \
- src/core/ext/transport/chttp2/transport/flow_control.c \
- src/core/ext/transport/chttp2/transport/frame_data.c \
- src/core/ext/transport/chttp2/transport/frame_goaway.c \
- src/core/ext/transport/chttp2/transport/frame_ping.c \
- src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
- src/core/ext/transport/chttp2/transport/frame_settings.c \
- src/core/ext/transport/chttp2/transport/frame_window_update.c \
- src/core/ext/transport/chttp2/transport/hpack_encoder.c \
- src/core/ext/transport/chttp2/transport/hpack_parser.c \
- src/core/ext/transport/chttp2/transport/hpack_table.c \
- src/core/ext/transport/chttp2/transport/http2_settings.c \
- src/core/ext/transport/chttp2/transport/huffsyms.c \
- src/core/ext/transport/chttp2/transport/incoming_metadata.c \
- src/core/ext/transport/chttp2/transport/parsing.c \
- src/core/ext/transport/chttp2/transport/stream_lists.c \
- src/core/ext/transport/chttp2/transport/stream_map.c \
- src/core/ext/transport/chttp2/transport/varint.c \
- src/core/ext/transport/chttp2/transport/writing.c \
- src/core/ext/transport/chttp2/alpn/alpn.c \
- src/core/ext/filters/http/client/http_client_filter.c \
- src/core/ext/filters/http/http_filters_plugin.c \
- src/core/ext/filters/http/message_compress/message_compress_filter.c \
- src/core/ext/filters/http/server/http_server_filter.c \
- src/core/lib/http/httpcli_security_connector.c \
- src/core/lib/security/context/security_context.c \
- src/core/lib/security/credentials/composite/composite_credentials.c \
- src/core/lib/security/credentials/credentials.c \
- src/core/lib/security/credentials/credentials_metadata.c \
- src/core/lib/security/credentials/fake/fake_credentials.c \
- src/core/lib/security/credentials/google_default/credentials_generic.c \
- src/core/lib/security/credentials/google_default/google_default_credentials.c \
- src/core/lib/security/credentials/iam/iam_credentials.c \
- src/core/lib/security/credentials/jwt/json_token.c \
- src/core/lib/security/credentials/jwt/jwt_credentials.c \
- src/core/lib/security/credentials/jwt/jwt_verifier.c \
- src/core/lib/security/credentials/oauth2/oauth2_credentials.c \
- src/core/lib/security/credentials/plugin/plugin_credentials.c \
- src/core/lib/security/credentials/ssl/ssl_credentials.c \
- src/core/lib/security/transport/client_auth_filter.c \
- src/core/lib/security/transport/lb_targets_info.c \
- src/core/lib/security/transport/secure_endpoint.c \
- src/core/lib/security/transport/security_connector.c \
- src/core/lib/security/transport/security_handshaker.c \
- src/core/lib/security/transport/server_auth_filter.c \
- src/core/lib/security/transport/tsi_error.c \
- src/core/lib/security/util/json_util.c \
- src/core/lib/surface/init_secure.c \
- src/core/tsi/fake_transport_security.c \
- src/core/tsi/gts_transport_security.c \
- src/core/tsi/ssl_transport_security.c \
- src/core/tsi/transport_security_grpc.c \
- src/core/tsi/transport_security.c \
- src/core/tsi/transport_security_adapter.c \
- src/core/ext/transport/chttp2/server/chttp2_server.c \
- src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \
- src/core/ext/filters/client_channel/channel_connectivity.c \
- src/core/ext/filters/client_channel/client_channel.c \
- src/core/ext/filters/client_channel/client_channel_factory.c \
- src/core/ext/filters/client_channel/client_channel_plugin.c \
- src/core/ext/filters/client_channel/connector.c \
- src/core/ext/filters/client_channel/http_connect_handshaker.c \
- src/core/ext/filters/client_channel/http_proxy.c \
- src/core/ext/filters/client_channel/lb_policy.c \
- src/core/ext/filters/client_channel/lb_policy_factory.c \
- src/core/ext/filters/client_channel/lb_policy_registry.c \
- src/core/ext/filters/client_channel/parse_address.c \
- src/core/ext/filters/client_channel/proxy_mapper.c \
- src/core/ext/filters/client_channel/proxy_mapper_registry.c \
- src/core/ext/filters/client_channel/resolver.c \
- src/core/ext/filters/client_channel/resolver_factory.c \
- src/core/ext/filters/client_channel/resolver_registry.c \
- src/core/ext/filters/client_channel/retry_throttle.c \
- src/core/ext/filters/client_channel/subchannel.c \
- src/core/ext/filters/client_channel/subchannel_index.c \
- src/core/ext/filters/client_channel/uri_parser.c \
- src/core/ext/filters/deadline/deadline_filter.c \
- src/core/ext/transport/chttp2/client/chttp2_connector.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \
- src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create.c \
- src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
- src/core/ext/transport/inproc/inproc_plugin.c \
- src/core/ext/transport/inproc/inproc_transport.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
+ src/core/lib/surface/metadata_array.cc \
+ src/core/lib/surface/server.cc \
+ src/core/lib/surface/validate_metadata.cc \
+ src/core/lib/surface/version.cc \
+ src/core/lib/transport/bdp_estimator.cc \
+ src/core/lib/transport/byte_stream.cc \
+ src/core/lib/transport/connectivity_state.cc \
+ src/core/lib/transport/error_utils.cc \
+ src/core/lib/transport/metadata.cc \
+ src/core/lib/transport/metadata_batch.cc \
+ src/core/lib/transport/pid_controller.cc \
+ src/core/lib/transport/service_config.cc \
+ src/core/lib/transport/static_metadata.cc \
+ src/core/lib/transport/status_conversion.cc \
+ src/core/lib/transport/timeout_encoding.cc \
+ src/core/lib/transport/transport.cc \
+ src/core/lib/transport/transport_op_string.cc \
+ src/core/lib/debug/trace.cc \
+ src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc \
+ src/core/ext/transport/chttp2/transport/bin_decoder.cc \
+ src/core/ext/transport/chttp2/transport/bin_encoder.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+ src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
+ src/core/ext/transport/chttp2/transport/flow_control.cc \
+ src/core/ext/transport/chttp2/transport/frame_data.cc \
+ src/core/ext/transport/chttp2/transport/frame_goaway.cc \
+ src/core/ext/transport/chttp2/transport/frame_ping.cc \
+ src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
+ src/core/ext/transport/chttp2/transport/frame_settings.cc \
+ src/core/ext/transport/chttp2/transport/frame_window_update.cc \
+ src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
+ src/core/ext/transport/chttp2/transport/hpack_parser.cc \
+ src/core/ext/transport/chttp2/transport/hpack_table.cc \
+ src/core/ext/transport/chttp2/transport/http2_settings.cc \
+ src/core/ext/transport/chttp2/transport/huffsyms.cc \
+ src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
+ src/core/ext/transport/chttp2/transport/parsing.cc \
+ src/core/ext/transport/chttp2/transport/stream_lists.cc \
+ 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/ext/transport/chttp2/alpn/alpn.cc \
+ src/core/ext/filters/http/client/http_client_filter.cc \
+ src/core/ext/filters/http/http_filters_plugin.cc \
+ src/core/ext/filters/http/message_compress/message_compress_filter.cc \
+ src/core/ext/filters/http/server/http_server_filter.cc \
+ src/core/lib/http/httpcli_security_connector.cc \
+ src/core/lib/security/context/security_context.cc \
+ src/core/lib/security/credentials/composite/composite_credentials.cc \
+ src/core/lib/security/credentials/credentials.cc \
+ src/core/lib/security/credentials/credentials_metadata.cc \
+ src/core/lib/security/credentials/fake/fake_credentials.cc \
+ src/core/lib/security/credentials/google_default/credentials_generic.cc \
+ src/core/lib/security/credentials/google_default/google_default_credentials.cc \
+ src/core/lib/security/credentials/iam/iam_credentials.cc \
+ src/core/lib/security/credentials/jwt/json_token.cc \
+ src/core/lib/security/credentials/jwt/jwt_credentials.cc \
+ src/core/lib/security/credentials/jwt/jwt_verifier.cc \
+ src/core/lib/security/credentials/oauth2/oauth2_credentials.cc \
+ src/core/lib/security/credentials/plugin/plugin_credentials.cc \
+ src/core/lib/security/credentials/ssl/ssl_credentials.cc \
+ src/core/lib/security/transport/client_auth_filter.cc \
+ src/core/lib/security/transport/lb_targets_info.cc \
+ src/core/lib/security/transport/secure_endpoint.cc \
+ src/core/lib/security/transport/security_connector.cc \
+ src/core/lib/security/transport/security_handshaker.cc \
+ src/core/lib/security/transport/server_auth_filter.cc \
+ src/core/lib/security/transport/tsi_error.cc \
+ src/core/lib/security/util/json_util.cc \
+ src/core/lib/surface/init_secure.cc \
+ src/core/tsi/alts_transport_security.cc \
+ src/core/tsi/fake_transport_security.cc \
+ src/core/tsi/ssl_transport_security.cc \
+ src/core/tsi/transport_security_grpc.cc \
+ src/core/tsi/transport_security.cc \
+ src/core/tsi/transport_security_adapter.cc \
+ src/core/ext/transport/chttp2/server/chttp2_server.cc \
+ src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc \
+ src/core/ext/filters/client_channel/backup_poller.cc \
+ src/core/ext/filters/client_channel/channel_connectivity.cc \
+ src/core/ext/filters/client_channel/client_channel.cc \
+ src/core/ext/filters/client_channel/client_channel_factory.cc \
+ src/core/ext/filters/client_channel/client_channel_plugin.cc \
+ src/core/ext/filters/client_channel/connector.cc \
+ src/core/ext/filters/client_channel/http_connect_handshaker.cc \
+ src/core/ext/filters/client_channel/http_proxy.cc \
+ src/core/ext/filters/client_channel/lb_policy.cc \
+ src/core/ext/filters/client_channel/lb_policy_factory.cc \
+ src/core/ext/filters/client_channel/lb_policy_registry.cc \
+ src/core/ext/filters/client_channel/parse_address.cc \
+ 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 \
+ src/core/ext/filters/client_channel/subchannel_index.cc \
+ src/core/ext/filters/client_channel/uri_parser.cc \
+ src/core/ext/filters/deadline/deadline_filter.cc \
+ src/core/ext/transport/chttp2/client/chttp2_connector.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc \
+ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \
+ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
+ src/core/ext/transport/inproc/inproc_plugin.cc \
+ src/core/ext/transport/inproc/inproc_transport.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \
+ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \
third_party/nanopb/pb_decode.c \
third_party/nanopb/pb_encode.c \
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \
- src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c \
- src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c \
- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \
- src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \
- src/core/ext/filters/load_reporting/server_load_reporting_filter.c \
- src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \
- src/core/ext/census/base_resources.c \
- src/core/ext/census/context.c \
- src/core/ext/census/gen/census.pb.c \
- src/core/ext/census/gen/trace_context.pb.c \
- src/core/ext/census/grpc_context.c \
- src/core/ext/census/grpc_filter.c \
- src/core/ext/census/grpc_plugin.c \
- src/core/ext/census/initialize.c \
- src/core/ext/census/intrusive_hash_map.c \
- src/core/ext/census/mlog.c \
- src/core/ext/census/operation.c \
- src/core/ext/census/placeholders.c \
- src/core/ext/census/resource.c \
- src/core/ext/census/trace_context.c \
- src/core/ext/census/tracing.c \
- src/core/ext/filters/max_age/max_age_filter.c \
- src/core/ext/filters/message_size/message_size_filter.c \
- src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c \
- src/core/ext/filters/workarounds/workaround_utils.c \
- src/core/plugin_registry/grpc_plugin_registry.c \
+ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
+ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \
+ src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc \
+ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
+ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
+ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
+ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_filter.cc \
+ src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc \
+ src/core/ext/census/grpc_context.cc \
+ src/core/ext/filters/max_age/max_age_filter.cc \
+ src/core/ext/filters/message_size/message_size_filter.cc \
+ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \
+ src/core/ext/filters/workarounds/workaround_utils.cc \
+ src/core/plugin_registry/grpc_plugin_registry.cc \
src/boringssl/err_data.c \
third_party/boringssl/crypto/aes/aes.c \
third_party/boringssl/crypto/aes/key_wrap.c \
@@ -658,8 +648,8 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/boringssl)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/census)
- PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/census/gen)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel)
+ PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/grpclb)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/pick_first)
@@ -686,9 +676,11 @@ 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/backoff)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/debug)
+ PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/gpr)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/http)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/iomgr)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/json)
@@ -706,7 +698,6 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/security/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/security/util)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/slice)
- PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/support)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/surface)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/plugin_registry)
diff --git a/config.w32 b/config.w32
index 5347baedc2..2d87e46c62 100644
--- a/config.w32
+++ b/config.w32
@@ -16,313 +16,303 @@ if (PHP_GRPC != "no") {
"src\\php\\ext\\grpc\\server.c " +
"src\\php\\ext\\grpc\\server_credentials.c " +
"src\\php\\ext\\grpc\\timeval.c " +
- "src\\core\\lib\\profiling\\basic_timers.c " +
- "src\\core\\lib\\profiling\\stap_timers.c " +
- "src\\core\\lib\\support\\alloc.c " +
- "src\\core\\lib\\support\\arena.c " +
- "src\\core\\lib\\support\\atm.c " +
- "src\\core\\lib\\support\\avl.c " +
- "src\\core\\lib\\support\\backoff.c " +
- "src\\core\\lib\\support\\cmdline.c " +
- "src\\core\\lib\\support\\cpu_iphone.c " +
- "src\\core\\lib\\support\\cpu_linux.c " +
- "src\\core\\lib\\support\\cpu_posix.c " +
- "src\\core\\lib\\support\\cpu_windows.c " +
- "src\\core\\lib\\support\\env_linux.c " +
- "src\\core\\lib\\support\\env_posix.c " +
- "src\\core\\lib\\support\\env_windows.c " +
- "src\\core\\lib\\support\\histogram.c " +
- "src\\core\\lib\\support\\host_port.c " +
- "src\\core\\lib\\support\\log.c " +
- "src\\core\\lib\\support\\log_android.c " +
- "src\\core\\lib\\support\\log_linux.c " +
- "src\\core\\lib\\support\\log_posix.c " +
- "src\\core\\lib\\support\\log_windows.c " +
- "src\\core\\lib\\support\\mpscq.c " +
- "src\\core\\lib\\support\\murmur_hash.c " +
- "src\\core\\lib\\support\\stack_lockfree.c " +
- "src\\core\\lib\\support\\string.c " +
- "src\\core\\lib\\support\\string_posix.c " +
- "src\\core\\lib\\support\\string_util_windows.c " +
- "src\\core\\lib\\support\\string_windows.c " +
- "src\\core\\lib\\support\\subprocess_posix.c " +
- "src\\core\\lib\\support\\subprocess_windows.c " +
- "src\\core\\lib\\support\\sync.c " +
- "src\\core\\lib\\support\\sync_posix.c " +
- "src\\core\\lib\\support\\sync_windows.c " +
- "src\\core\\lib\\support\\thd.c " +
- "src\\core\\lib\\support\\thd_posix.c " +
- "src\\core\\lib\\support\\thd_windows.c " +
- "src\\core\\lib\\support\\time.c " +
- "src\\core\\lib\\support\\time_posix.c " +
- "src\\core\\lib\\support\\time_precise.c " +
- "src\\core\\lib\\support\\time_windows.c " +
- "src\\core\\lib\\support\\tls_pthread.c " +
- "src\\core\\lib\\support\\tmpfile_msys.c " +
- "src\\core\\lib\\support\\tmpfile_posix.c " +
- "src\\core\\lib\\support\\tmpfile_windows.c " +
- "src\\core\\lib\\support\\wrap_memcpy.c " +
- "src\\core\\lib\\surface\\init.c " +
- "src\\core\\lib\\channel\\channel_args.c " +
- "src\\core\\lib\\channel\\channel_stack.c " +
- "src\\core\\lib\\channel\\channel_stack_builder.c " +
- "src\\core\\lib\\channel\\connected_channel.c " +
- "src\\core\\lib\\channel\\handshaker.c " +
- "src\\core\\lib\\channel\\handshaker_factory.c " +
- "src\\core\\lib\\channel\\handshaker_registry.c " +
- "src\\core\\lib\\compression\\compression.c " +
- "src\\core\\lib\\compression\\message_compress.c " +
- "src\\core\\lib\\compression\\stream_compression.c " +
- "src\\core\\lib\\compression\\stream_compression_gzip.c " +
- "src\\core\\lib\\compression\\stream_compression_identity.c " +
- "src\\core\\lib\\debug\\stats.c " +
- "src\\core\\lib\\debug\\stats_data.c " +
- "src\\core\\lib\\http\\format_request.c " +
- "src\\core\\lib\\http\\httpcli.c " +
- "src\\core\\lib\\http\\parser.c " +
- "src\\core\\lib\\iomgr\\call_combiner.c " +
- "src\\core\\lib\\iomgr\\closure.c " +
- "src\\core\\lib\\iomgr\\combiner.c " +
- "src\\core\\lib\\iomgr\\endpoint.c " +
- "src\\core\\lib\\iomgr\\endpoint_pair_posix.c " +
- "src\\core\\lib\\iomgr\\endpoint_pair_uv.c " +
- "src\\core\\lib\\iomgr\\endpoint_pair_windows.c " +
- "src\\core\\lib\\iomgr\\error.c " +
- "src\\core\\lib\\iomgr\\ev_epoll1_linux.c " +
- "src\\core\\lib\\iomgr\\ev_epollex_linux.c " +
- "src\\core\\lib\\iomgr\\ev_epollsig_linux.c " +
- "src\\core\\lib\\iomgr\\ev_poll_posix.c " +
- "src\\core\\lib\\iomgr\\ev_posix.c " +
- "src\\core\\lib\\iomgr\\ev_windows.c " +
- "src\\core\\lib\\iomgr\\exec_ctx.c " +
- "src\\core\\lib\\iomgr\\executor.c " +
- "src\\core\\lib\\iomgr\\gethostname_fallback.c " +
- "src\\core\\lib\\iomgr\\gethostname_host_name_max.c " +
- "src\\core\\lib\\iomgr\\gethostname_sysconf.c " +
- "src\\core\\lib\\iomgr\\iocp_windows.c " +
- "src\\core\\lib\\iomgr\\iomgr.c " +
- "src\\core\\lib\\iomgr\\iomgr_posix.c " +
- "src\\core\\lib\\iomgr\\iomgr_uv.c " +
- "src\\core\\lib\\iomgr\\iomgr_windows.c " +
- "src\\core\\lib\\iomgr\\is_epollexclusive_available.c " +
- "src\\core\\lib\\iomgr\\load_file.c " +
- "src\\core\\lib\\iomgr\\lockfree_event.c " +
- "src\\core\\lib\\iomgr\\network_status_tracker.c " +
- "src\\core\\lib\\iomgr\\polling_entity.c " +
- "src\\core\\lib\\iomgr\\pollset_set_uv.c " +
- "src\\core\\lib\\iomgr\\pollset_set_windows.c " +
- "src\\core\\lib\\iomgr\\pollset_uv.c " +
- "src\\core\\lib\\iomgr\\pollset_windows.c " +
- "src\\core\\lib\\iomgr\\resolve_address_posix.c " +
- "src\\core\\lib\\iomgr\\resolve_address_uv.c " +
- "src\\core\\lib\\iomgr\\resolve_address_windows.c " +
- "src\\core\\lib\\iomgr\\resource_quota.c " +
- "src\\core\\lib\\iomgr\\sockaddr_utils.c " +
- "src\\core\\lib\\iomgr\\socket_factory_posix.c " +
- "src\\core\\lib\\iomgr\\socket_mutator.c " +
- "src\\core\\lib\\iomgr\\socket_utils_common_posix.c " +
- "src\\core\\lib\\iomgr\\socket_utils_linux.c " +
- "src\\core\\lib\\iomgr\\socket_utils_posix.c " +
- "src\\core\\lib\\iomgr\\socket_utils_uv.c " +
- "src\\core\\lib\\iomgr\\socket_utils_windows.c " +
- "src\\core\\lib\\iomgr\\socket_windows.c " +
- "src\\core\\lib\\iomgr\\tcp_client_posix.c " +
- "src\\core\\lib\\iomgr\\tcp_client_uv.c " +
- "src\\core\\lib\\iomgr\\tcp_client_windows.c " +
- "src\\core\\lib\\iomgr\\tcp_posix.c " +
- "src\\core\\lib\\iomgr\\tcp_server_posix.c " +
- "src\\core\\lib\\iomgr\\tcp_server_utils_posix_common.c " +
- "src\\core\\lib\\iomgr\\tcp_server_utils_posix_ifaddrs.c " +
- "src\\core\\lib\\iomgr\\tcp_server_utils_posix_noifaddrs.c " +
- "src\\core\\lib\\iomgr\\tcp_server_uv.c " +
- "src\\core\\lib\\iomgr\\tcp_server_windows.c " +
- "src\\core\\lib\\iomgr\\tcp_uv.c " +
- "src\\core\\lib\\iomgr\\tcp_windows.c " +
- "src\\core\\lib\\iomgr\\time_averaged_stats.c " +
- "src\\core\\lib\\iomgr\\timer_generic.c " +
- "src\\core\\lib\\iomgr\\timer_heap.c " +
- "src\\core\\lib\\iomgr\\timer_manager.c " +
- "src\\core\\lib\\iomgr\\timer_uv.c " +
- "src\\core\\lib\\iomgr\\udp_server.c " +
- "src\\core\\lib\\iomgr\\unix_sockets_posix.c " +
- "src\\core\\lib\\iomgr\\unix_sockets_posix_noop.c " +
- "src\\core\\lib\\iomgr\\wakeup_fd_cv.c " +
- "src\\core\\lib\\iomgr\\wakeup_fd_eventfd.c " +
- "src\\core\\lib\\iomgr\\wakeup_fd_nospecial.c " +
- "src\\core\\lib\\iomgr\\wakeup_fd_pipe.c " +
- "src\\core\\lib\\iomgr\\wakeup_fd_posix.c " +
- "src\\core\\lib\\json\\json.c " +
- "src\\core\\lib\\json\\json_reader.c " +
- "src\\core\\lib\\json\\json_string.c " +
- "src\\core\\lib\\json\\json_writer.c " +
- "src\\core\\lib\\slice\\b64.c " +
- "src\\core\\lib\\slice\\percent_encoding.c " +
- "src\\core\\lib\\slice\\slice.c " +
- "src\\core\\lib\\slice\\slice_buffer.c " +
- "src\\core\\lib\\slice\\slice_hash_table.c " +
- "src\\core\\lib\\slice\\slice_intern.c " +
- "src\\core\\lib\\slice\\slice_string_helpers.c " +
- "src\\core\\lib\\surface\\alarm.c " +
- "src\\core\\lib\\surface\\api_trace.c " +
- "src\\core\\lib\\surface\\byte_buffer.c " +
- "src\\core\\lib\\surface\\byte_buffer_reader.c " +
- "src\\core\\lib\\surface\\call.c " +
- "src\\core\\lib\\surface\\call_details.c " +
- "src\\core\\lib\\surface\\call_log_batch.c " +
- "src\\core\\lib\\surface\\channel.c " +
- "src\\core\\lib\\surface\\channel_init.c " +
- "src\\core\\lib\\surface\\channel_ping.c " +
- "src\\core\\lib\\surface\\channel_stack_type.c " +
- "src\\core\\lib\\surface\\completion_queue.c " +
- "src\\core\\lib\\surface\\completion_queue_factory.c " +
- "src\\core\\lib\\surface\\event_string.c " +
+ "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 " +
+ "src\\core\\lib\\gpr\\cpu_posix.cc " +
+ "src\\core\\lib\\gpr\\cpu_windows.cc " +
+ "src\\core\\lib\\gpr\\env_linux.cc " +
+ "src\\core\\lib\\gpr\\env_posix.cc " +
+ "src\\core\\lib\\gpr\\env_windows.cc " +
+ "src\\core\\lib\\gpr\\fork.cc " +
+ "src\\core\\lib\\gpr\\host_port.cc " +
+ "src\\core\\lib\\gpr\\log.cc " +
+ "src\\core\\lib\\gpr\\log_android.cc " +
+ "src\\core\\lib\\gpr\\log_linux.cc " +
+ "src\\core\\lib\\gpr\\log_posix.cc " +
+ "src\\core\\lib\\gpr\\log_windows.cc " +
+ "src\\core\\lib\\gpr\\mpscq.cc " +
+ "src\\core\\lib\\gpr\\murmur_hash.cc " +
+ "src\\core\\lib\\gpr\\string.cc " +
+ "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 " +
+ "src\\core\\lib\\gpr\\thd.cc " +
+ "src\\core\\lib\\gpr\\thd_posix.cc " +
+ "src\\core\\lib\\gpr\\thd_windows.cc " +
+ "src\\core\\lib\\gpr\\time.cc " +
+ "src\\core\\lib\\gpr\\time_posix.cc " +
+ "src\\core\\lib\\gpr\\time_precise.cc " +
+ "src\\core\\lib\\gpr\\time_windows.cc " +
+ "src\\core\\lib\\gpr\\tls_pthread.cc " +
+ "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\\wrap_memcpy.cc " +
+ "src\\core\\lib\\profiling\\basic_timers.cc " +
+ "src\\core\\lib\\profiling\\stap_timers.cc " +
+ "src\\core\\lib\\surface\\init.cc " +
+ "src\\core\\lib\\backoff\\backoff.cc " +
+ "src\\core\\lib\\channel\\channel_args.cc " +
+ "src\\core\\lib\\channel\\channel_stack.cc " +
+ "src\\core\\lib\\channel\\channel_stack_builder.cc " +
+ "src\\core\\lib\\channel\\connected_channel.cc " +
+ "src\\core\\lib\\channel\\handshaker.cc " +
+ "src\\core\\lib\\channel\\handshaker_factory.cc " +
+ "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 " +
+ "src\\core\\lib\\compression\\stream_compression_identity.cc " +
+ "src\\core\\lib\\debug\\stats.cc " +
+ "src\\core\\lib\\debug\\stats_data.cc " +
+ "src\\core\\lib\\http\\format_request.cc " +
+ "src\\core\\lib\\http\\httpcli.cc " +
+ "src\\core\\lib\\http\\parser.cc " +
+ "src\\core\\lib\\iomgr\\call_combiner.cc " +
+ "src\\core\\lib\\iomgr\\combiner.cc " +
+ "src\\core\\lib\\iomgr\\endpoint.cc " +
+ "src\\core\\lib\\iomgr\\endpoint_pair_posix.cc " +
+ "src\\core\\lib\\iomgr\\endpoint_pair_uv.cc " +
+ "src\\core\\lib\\iomgr\\endpoint_pair_windows.cc " +
+ "src\\core\\lib\\iomgr\\error.cc " +
+ "src\\core\\lib\\iomgr\\ev_epoll1_linux.cc " +
+ "src\\core\\lib\\iomgr\\ev_epollex_linux.cc " +
+ "src\\core\\lib\\iomgr\\ev_epollsig_linux.cc " +
+ "src\\core\\lib\\iomgr\\ev_poll_posix.cc " +
+ "src\\core\\lib\\iomgr\\ev_posix.cc " +
+ "src\\core\\lib\\iomgr\\ev_windows.cc " +
+ "src\\core\\lib\\iomgr\\exec_ctx.cc " +
+ "src\\core\\lib\\iomgr\\executor.cc " +
+ "src\\core\\lib\\iomgr\\fork_posix.cc " +
+ "src\\core\\lib\\iomgr\\fork_windows.cc " +
+ "src\\core\\lib\\iomgr\\gethostname_fallback.cc " +
+ "src\\core\\lib\\iomgr\\gethostname_host_name_max.cc " +
+ "src\\core\\lib\\iomgr\\gethostname_sysconf.cc " +
+ "src\\core\\lib\\iomgr\\iocp_windows.cc " +
+ "src\\core\\lib\\iomgr\\iomgr.cc " +
+ "src\\core\\lib\\iomgr\\iomgr_posix.cc " +
+ "src\\core\\lib\\iomgr\\iomgr_uv.cc " +
+ "src\\core\\lib\\iomgr\\iomgr_windows.cc " +
+ "src\\core\\lib\\iomgr\\is_epollexclusive_available.cc " +
+ "src\\core\\lib\\iomgr\\load_file.cc " +
+ "src\\core\\lib\\iomgr\\lockfree_event.cc " +
+ "src\\core\\lib\\iomgr\\network_status_tracker.cc " +
+ "src\\core\\lib\\iomgr\\polling_entity.cc " +
+ "src\\core\\lib\\iomgr\\pollset_set_uv.cc " +
+ "src\\core\\lib\\iomgr\\pollset_set_windows.cc " +
+ "src\\core\\lib\\iomgr\\pollset_uv.cc " +
+ "src\\core\\lib\\iomgr\\pollset_windows.cc " +
+ "src\\core\\lib\\iomgr\\resolve_address_posix.cc " +
+ "src\\core\\lib\\iomgr\\resolve_address_uv.cc " +
+ "src\\core\\lib\\iomgr\\resolve_address_windows.cc " +
+ "src\\core\\lib\\iomgr\\resource_quota.cc " +
+ "src\\core\\lib\\iomgr\\sockaddr_utils.cc " +
+ "src\\core\\lib\\iomgr\\socket_factory_posix.cc " +
+ "src\\core\\lib\\iomgr\\socket_mutator.cc " +
+ "src\\core\\lib\\iomgr\\socket_utils_common_posix.cc " +
+ "src\\core\\lib\\iomgr\\socket_utils_linux.cc " +
+ "src\\core\\lib\\iomgr\\socket_utils_posix.cc " +
+ "src\\core\\lib\\iomgr\\socket_utils_uv.cc " +
+ "src\\core\\lib\\iomgr\\socket_utils_windows.cc " +
+ "src\\core\\lib\\iomgr\\socket_windows.cc " +
+ "src\\core\\lib\\iomgr\\tcp_client_posix.cc " +
+ "src\\core\\lib\\iomgr\\tcp_client_uv.cc " +
+ "src\\core\\lib\\iomgr\\tcp_client_windows.cc " +
+ "src\\core\\lib\\iomgr\\tcp_posix.cc " +
+ "src\\core\\lib\\iomgr\\tcp_server_posix.cc " +
+ "src\\core\\lib\\iomgr\\tcp_server_utils_posix_common.cc " +
+ "src\\core\\lib\\iomgr\\tcp_server_utils_posix_ifaddrs.cc " +
+ "src\\core\\lib\\iomgr\\tcp_server_utils_posix_noifaddrs.cc " +
+ "src\\core\\lib\\iomgr\\tcp_server_uv.cc " +
+ "src\\core\\lib\\iomgr\\tcp_server_windows.cc " +
+ "src\\core\\lib\\iomgr\\tcp_uv.cc " +
+ "src\\core\\lib\\iomgr\\tcp_windows.cc " +
+ "src\\core\\lib\\iomgr\\time_averaged_stats.cc " +
+ "src\\core\\lib\\iomgr\\timer_generic.cc " +
+ "src\\core\\lib\\iomgr\\timer_heap.cc " +
+ "src\\core\\lib\\iomgr\\timer_manager.cc " +
+ "src\\core\\lib\\iomgr\\timer_uv.cc " +
+ "src\\core\\lib\\iomgr\\udp_server.cc " +
+ "src\\core\\lib\\iomgr\\unix_sockets_posix.cc " +
+ "src\\core\\lib\\iomgr\\unix_sockets_posix_noop.cc " +
+ "src\\core\\lib\\iomgr\\wakeup_fd_cv.cc " +
+ "src\\core\\lib\\iomgr\\wakeup_fd_eventfd.cc " +
+ "src\\core\\lib\\iomgr\\wakeup_fd_nospecial.cc " +
+ "src\\core\\lib\\iomgr\\wakeup_fd_pipe.cc " +
+ "src\\core\\lib\\iomgr\\wakeup_fd_posix.cc " +
+ "src\\core\\lib\\json\\json.cc " +
+ "src\\core\\lib\\json\\json_reader.cc " +
+ "src\\core\\lib\\json\\json_string.cc " +
+ "src\\core\\lib\\json\\json_writer.cc " +
+ "src\\core\\lib\\slice\\b64.cc " +
+ "src\\core\\lib\\slice\\percent_encoding.cc " +
+ "src\\core\\lib\\slice\\slice.cc " +
+ "src\\core\\lib\\slice\\slice_buffer.cc " +
+ "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 " +
+ "src\\core\\lib\\surface\\call.cc " +
+ "src\\core\\lib\\surface\\call_details.cc " +
+ "src\\core\\lib\\surface\\call_log_batch.cc " +
+ "src\\core\\lib\\surface\\channel.cc " +
+ "src\\core\\lib\\surface\\channel_init.cc " +
+ "src\\core\\lib\\surface\\channel_ping.cc " +
+ "src\\core\\lib\\surface\\channel_stack_type.cc " +
+ "src\\core\\lib\\surface\\completion_queue.cc " +
+ "src\\core\\lib\\surface\\completion_queue_factory.cc " +
+ "src\\core\\lib\\surface\\event_string.cc " +
"src\\core\\lib\\surface\\lame_client.cc " +
- "src\\core\\lib\\surface\\metadata_array.c " +
- "src\\core\\lib\\surface\\server.c " +
- "src\\core\\lib\\surface\\validate_metadata.c " +
- "src\\core\\lib\\surface\\version.c " +
- "src\\core\\lib\\transport\\bdp_estimator.c " +
- "src\\core\\lib\\transport\\byte_stream.c " +
- "src\\core\\lib\\transport\\connectivity_state.c " +
- "src\\core\\lib\\transport\\error_utils.c " +
- "src\\core\\lib\\transport\\metadata.c " +
- "src\\core\\lib\\transport\\metadata_batch.c " +
- "src\\core\\lib\\transport\\pid_controller.c " +
- "src\\core\\lib\\transport\\service_config.c " +
- "src\\core\\lib\\transport\\static_metadata.c " +
- "src\\core\\lib\\transport\\status_conversion.c " +
- "src\\core\\lib\\transport\\timeout_encoding.c " +
- "src\\core\\lib\\transport\\transport.c " +
- "src\\core\\lib\\transport\\transport_op_string.c " +
- "src\\core\\lib\\debug\\trace.c " +
- "src\\core\\ext\\transport\\chttp2\\server\\secure\\server_secure_chttp2.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\bin_decoder.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\bin_encoder.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\chttp2_plugin.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\chttp2_transport.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\flow_control.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\frame_data.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\frame_goaway.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\frame_ping.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\frame_rst_stream.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\frame_settings.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\frame_window_update.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\hpack_encoder.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\hpack_parser.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\hpack_table.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\http2_settings.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\huffsyms.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\incoming_metadata.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\parsing.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\stream_lists.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\stream_map.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\varint.c " +
- "src\\core\\ext\\transport\\chttp2\\transport\\writing.c " +
- "src\\core\\ext\\transport\\chttp2\\alpn\\alpn.c " +
- "src\\core\\ext\\filters\\http\\client\\http_client_filter.c " +
- "src\\core\\ext\\filters\\http\\http_filters_plugin.c " +
- "src\\core\\ext\\filters\\http\\message_compress\\message_compress_filter.c " +
- "src\\core\\ext\\filters\\http\\server\\http_server_filter.c " +
- "src\\core\\lib\\http\\httpcli_security_connector.c " +
- "src\\core\\lib\\security\\context\\security_context.c " +
- "src\\core\\lib\\security\\credentials\\composite\\composite_credentials.c " +
- "src\\core\\lib\\security\\credentials\\credentials.c " +
- "src\\core\\lib\\security\\credentials\\credentials_metadata.c " +
- "src\\core\\lib\\security\\credentials\\fake\\fake_credentials.c " +
- "src\\core\\lib\\security\\credentials\\google_default\\credentials_generic.c " +
- "src\\core\\lib\\security\\credentials\\google_default\\google_default_credentials.c " +
- "src\\core\\lib\\security\\credentials\\iam\\iam_credentials.c " +
- "src\\core\\lib\\security\\credentials\\jwt\\json_token.c " +
- "src\\core\\lib\\security\\credentials\\jwt\\jwt_credentials.c " +
- "src\\core\\lib\\security\\credentials\\jwt\\jwt_verifier.c " +
- "src\\core\\lib\\security\\credentials\\oauth2\\oauth2_credentials.c " +
- "src\\core\\lib\\security\\credentials\\plugin\\plugin_credentials.c " +
- "src\\core\\lib\\security\\credentials\\ssl\\ssl_credentials.c " +
- "src\\core\\lib\\security\\transport\\client_auth_filter.c " +
- "src\\core\\lib\\security\\transport\\lb_targets_info.c " +
- "src\\core\\lib\\security\\transport\\secure_endpoint.c " +
- "src\\core\\lib\\security\\transport\\security_connector.c " +
- "src\\core\\lib\\security\\transport\\security_handshaker.c " +
- "src\\core\\lib\\security\\transport\\server_auth_filter.c " +
- "src\\core\\lib\\security\\transport\\tsi_error.c " +
- "src\\core\\lib\\security\\util\\json_util.c " +
- "src\\core\\lib\\surface\\init_secure.c " +
- "src\\core\\tsi\\fake_transport_security.c " +
- "src\\core\\tsi\\gts_transport_security.c " +
- "src\\core\\tsi\\ssl_transport_security.c " +
- "src\\core\\tsi\\transport_security_grpc.c " +
- "src\\core\\tsi\\transport_security.c " +
- "src\\core\\tsi\\transport_security_adapter.c " +
- "src\\core\\ext\\transport\\chttp2\\server\\chttp2_server.c " +
- "src\\core\\ext\\transport\\chttp2\\client\\secure\\secure_channel_create.c " +
- "src\\core\\ext\\filters\\client_channel\\channel_connectivity.c " +
- "src\\core\\ext\\filters\\client_channel\\client_channel.c " +
- "src\\core\\ext\\filters\\client_channel\\client_channel_factory.c " +
- "src\\core\\ext\\filters\\client_channel\\client_channel_plugin.c " +
- "src\\core\\ext\\filters\\client_channel\\connector.c " +
- "src\\core\\ext\\filters\\client_channel\\http_connect_handshaker.c " +
- "src\\core\\ext\\filters\\client_channel\\http_proxy.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy_factory.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy_registry.c " +
- "src\\core\\ext\\filters\\client_channel\\parse_address.c " +
- "src\\core\\ext\\filters\\client_channel\\proxy_mapper.c " +
- "src\\core\\ext\\filters\\client_channel\\proxy_mapper_registry.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver_factory.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver_registry.c " +
- "src\\core\\ext\\filters\\client_channel\\retry_throttle.c " +
- "src\\core\\ext\\filters\\client_channel\\subchannel.c " +
- "src\\core\\ext\\filters\\client_channel\\subchannel_index.c " +
- "src\\core\\ext\\filters\\client_channel\\uri_parser.c " +
- "src\\core\\ext\\filters\\deadline\\deadline_filter.c " +
- "src\\core\\ext\\transport\\chttp2\\client\\chttp2_connector.c " +
- "src\\core\\ext\\transport\\chttp2\\server\\insecure\\server_chttp2.c " +
- "src\\core\\ext\\transport\\chttp2\\server\\insecure\\server_chttp2_posix.c " +
- "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create.c " +
- "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.c " +
- "src\\core\\ext\\transport\\inproc\\inproc_plugin.c " +
- "src\\core\\ext\\transport\\inproc\\inproc_transport.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\client_load_reporting_filter.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.c " +
+ "src\\core\\lib\\surface\\metadata_array.cc " +
+ "src\\core\\lib\\surface\\server.cc " +
+ "src\\core\\lib\\surface\\validate_metadata.cc " +
+ "src\\core\\lib\\surface\\version.cc " +
+ "src\\core\\lib\\transport\\bdp_estimator.cc " +
+ "src\\core\\lib\\transport\\byte_stream.cc " +
+ "src\\core\\lib\\transport\\connectivity_state.cc " +
+ "src\\core\\lib\\transport\\error_utils.cc " +
+ "src\\core\\lib\\transport\\metadata.cc " +
+ "src\\core\\lib\\transport\\metadata_batch.cc " +
+ "src\\core\\lib\\transport\\pid_controller.cc " +
+ "src\\core\\lib\\transport\\service_config.cc " +
+ "src\\core\\lib\\transport\\static_metadata.cc " +
+ "src\\core\\lib\\transport\\status_conversion.cc " +
+ "src\\core\\lib\\transport\\timeout_encoding.cc " +
+ "src\\core\\lib\\transport\\transport.cc " +
+ "src\\core\\lib\\transport\\transport_op_string.cc " +
+ "src\\core\\lib\\debug\\trace.cc " +
+ "src\\core\\ext\\transport\\chttp2\\server\\secure\\server_secure_chttp2.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\bin_decoder.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\bin_encoder.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\chttp2_plugin.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\chttp2_transport.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\flow_control.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\frame_data.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\frame_goaway.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\frame_ping.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\frame_rst_stream.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\frame_settings.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\frame_window_update.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\hpack_encoder.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\hpack_parser.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\hpack_table.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\http2_settings.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\huffsyms.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\incoming_metadata.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\parsing.cc " +
+ "src\\core\\ext\\transport\\chttp2\\transport\\stream_lists.cc " +
+ "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\\ext\\transport\\chttp2\\alpn\\alpn.cc " +
+ "src\\core\\ext\\filters\\http\\client\\http_client_filter.cc " +
+ "src\\core\\ext\\filters\\http\\http_filters_plugin.cc " +
+ "src\\core\\ext\\filters\\http\\message_compress\\message_compress_filter.cc " +
+ "src\\core\\ext\\filters\\http\\server\\http_server_filter.cc " +
+ "src\\core\\lib\\http\\httpcli_security_connector.cc " +
+ "src\\core\\lib\\security\\context\\security_context.cc " +
+ "src\\core\\lib\\security\\credentials\\composite\\composite_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\credentials_metadata.cc " +
+ "src\\core\\lib\\security\\credentials\\fake\\fake_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\google_default\\credentials_generic.cc " +
+ "src\\core\\lib\\security\\credentials\\google_default\\google_default_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\iam\\iam_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\jwt\\json_token.cc " +
+ "src\\core\\lib\\security\\credentials\\jwt\\jwt_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\jwt\\jwt_verifier.cc " +
+ "src\\core\\lib\\security\\credentials\\oauth2\\oauth2_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\plugin\\plugin_credentials.cc " +
+ "src\\core\\lib\\security\\credentials\\ssl\\ssl_credentials.cc " +
+ "src\\core\\lib\\security\\transport\\client_auth_filter.cc " +
+ "src\\core\\lib\\security\\transport\\lb_targets_info.cc " +
+ "src\\core\\lib\\security\\transport\\secure_endpoint.cc " +
+ "src\\core\\lib\\security\\transport\\security_connector.cc " +
+ "src\\core\\lib\\security\\transport\\security_handshaker.cc " +
+ "src\\core\\lib\\security\\transport\\server_auth_filter.cc " +
+ "src\\core\\lib\\security\\transport\\tsi_error.cc " +
+ "src\\core\\lib\\security\\util\\json_util.cc " +
+ "src\\core\\lib\\surface\\init_secure.cc " +
+ "src\\core\\tsi\\alts_transport_security.cc " +
+ "src\\core\\tsi\\fake_transport_security.cc " +
+ "src\\core\\tsi\\ssl_transport_security.cc " +
+ "src\\core\\tsi\\transport_security_grpc.cc " +
+ "src\\core\\tsi\\transport_security.cc " +
+ "src\\core\\tsi\\transport_security_adapter.cc " +
+ "src\\core\\ext\\transport\\chttp2\\server\\chttp2_server.cc " +
+ "src\\core\\ext\\transport\\chttp2\\client\\secure\\secure_channel_create.cc " +
+ "src\\core\\ext\\filters\\client_channel\\backup_poller.cc " +
+ "src\\core\\ext\\filters\\client_channel\\channel_connectivity.cc " +
+ "src\\core\\ext\\filters\\client_channel\\client_channel.cc " +
+ "src\\core\\ext\\filters\\client_channel\\client_channel_factory.cc " +
+ "src\\core\\ext\\filters\\client_channel\\client_channel_plugin.cc " +
+ "src\\core\\ext\\filters\\client_channel\\connector.cc " +
+ "src\\core\\ext\\filters\\client_channel\\http_connect_handshaker.cc " +
+ "src\\core\\ext\\filters\\client_channel\\http_proxy.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy_factory.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy_registry.cc " +
+ "src\\core\\ext\\filters\\client_channel\\parse_address.cc " +
+ "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 " +
+ "src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " +
+ "src\\core\\ext\\filters\\client_channel\\uri_parser.cc " +
+ "src\\core\\ext\\filters\\deadline\\deadline_filter.cc " +
+ "src\\core\\ext\\transport\\chttp2\\client\\chttp2_connector.cc " +
+ "src\\core\\ext\\transport\\chttp2\\server\\insecure\\server_chttp2.cc " +
+ "src\\core\\ext\\transport\\chttp2\\server\\insecure\\server_chttp2_posix.cc " +
+ "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create.cc " +
+ "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.cc " +
+ "src\\core\\ext\\transport\\inproc\\inproc_plugin.cc " +
+ "src\\core\\ext\\transport\\inproc\\inproc_transport.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\client_load_reporting_filter.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.cc " +
"src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\load_balancer.pb.c " +
"third_party\\nanopb\\pb_common.c " +
"third_party\\nanopb\\pb_decode.c " +
"third_party\\nanopb\\pb_encode.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\pick_first\\pick_first.c " +
- "src\\core\\ext\\filters\\client_channel\\lb_policy\\round_robin\\round_robin.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver_posix.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.c " +
- "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.c " +
- "src\\core\\ext\\filters\\load_reporting\\server_load_reporting_filter.c " +
- "src\\core\\ext\\filters\\load_reporting\\server_load_reporting_plugin.c " +
- "src\\core\\ext\\census\\base_resources.c " +
- "src\\core\\ext\\census\\context.c " +
- "src\\core\\ext\\census\\gen\\census.pb.c " +
- "src\\core\\ext\\census\\gen\\trace_context.pb.c " +
- "src\\core\\ext\\census\\grpc_context.c " +
- "src\\core\\ext\\census\\grpc_filter.c " +
- "src\\core\\ext\\census\\grpc_plugin.c " +
- "src\\core\\ext\\census\\initialize.c " +
- "src\\core\\ext\\census\\intrusive_hash_map.c " +
- "src\\core\\ext\\census\\mlog.c " +
- "src\\core\\ext\\census\\operation.c " +
- "src\\core\\ext\\census\\placeholders.c " +
- "src\\core\\ext\\census\\resource.c " +
- "src\\core\\ext\\census\\trace_context.c " +
- "src\\core\\ext\\census\\tracing.c " +
- "src\\core\\ext\\filters\\max_age\\max_age_filter.c " +
- "src\\core\\ext\\filters\\message_size\\message_size_filter.c " +
- "src\\core\\ext\\filters\\workarounds\\workaround_cronet_compression_filter.c " +
- "src\\core\\ext\\filters\\workarounds\\workaround_utils.c " +
- "src\\core\\plugin_registry\\grpc_plugin_registry.c " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\pick_first\\pick_first.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\subchannel_list.cc " +
+ "src\\core\\ext\\filters\\client_channel\\lb_policy\\round_robin\\round_robin.cc " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.cc " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver_posix.cc " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " +
+ "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " +
+ "src\\core\\ext\\filters\\load_reporting\\server_load_reporting_filter.cc " +
+ "src\\core\\ext\\filters\\load_reporting\\server_load_reporting_plugin.cc " +
+ "src\\core\\ext\\census\\grpc_context.cc " +
+ "src\\core\\ext\\filters\\max_age\\max_age_filter.cc " +
+ "src\\core\\ext\\filters\\message_size\\message_size_filter.cc " +
+ "src\\core\\ext\\filters\\workarounds\\workaround_cronet_compression_filter.cc " +
+ "src\\core\\ext\\filters\\workarounds\\workaround_utils.cc " +
+ "src\\core\\plugin_registry\\grpc_plugin_registry.cc " +
"src\\boringssl\\err_data.c " +
"third_party\\boringssl\\crypto\\aes\\aes.c " +
"third_party\\boringssl\\crypto\\aes\\key_wrap.c " +
@@ -661,7 +651,6 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\census");
- FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\census\\gen");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy");
@@ -699,9 +688,11 @@ 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\\backoff");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\debug");
+ FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\gpr");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\http");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\iomgr");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\json");
@@ -720,7 +711,6 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\security\\transport");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\security\\util");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\slice");
- FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\support");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\surface");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\transport");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\plugin_registry");
diff --git a/doc/PROTOCOL-HTTP2.md b/doc/PROTOCOL-HTTP2.md
index 29d3cc2e76..107a8e8824 100644
--- a/doc/PROTOCOL-HTTP2.md
+++ b/doc/PROTOCOL-HTTP2.md
@@ -1,7 +1,7 @@
# gRPC over HTTP2
## Introduction
-This document serves as a detailed description for an implementation of gRPC carried over HTTP2 draft 17 framing. It assumes familiarity with the HTTP2 specification.
+This document serves as a detailed description for an implementation of gRPC carried over <a href="https://tools.ietf.org/html/rfc7540">HTTP2 framing</a>. It assumes familiarity with the HTTP2 specification.
## Protocol
Production rules are using <a href="http://tools.ietf.org/html/rfc5234">ABNF syntax</a>.
@@ -24,7 +24,7 @@ Request-Headers are delivered as HTTP2 headers in HEADERS + CONTINUATION frames.
* **Call-Definition** → Method Scheme Path TE [Authority] [Timeout] Content-Type [Message-Type] [Message-Encoding] [Message-Accept-Encoding] [User-Agent]
* **Method** → ":method POST"
* **Scheme** → ":scheme " ("http" / "https")
-* **Path** → ":path" "/" Service-Name "/" {_method name_}
+* **Path** → ":path" "/" Service-Name "/" {_method name_} # But see note below.
* **Service-Name** → {_IDL-specific service name_}
* **Authority** → ":authority" {_virtual host name of authority_}
* **TE** → "te" "trailers" # Used to detect incompatible proxies
@@ -170,6 +170,7 @@ HEADERS (flags = END_STREAM, END_HEADERS)
grpc-status = 0 # OK
trace-proto-bin = jher831yy13JHy3hc
```
+
#### User Agents
While the protocol does not require a user-agent to function it is recommended that clients provide a structured user-agent string that provides a basic description of the calling library, version & platform to facilitate issue diagnosis in heterogeneous environments. The following structure is recommended to library developers
@@ -197,7 +198,7 @@ Unless explicitly defined to be, gRPC Calls are not assumed to be idempotent. S
#### HTTP2 Transport Mapping
##### Stream Identification
-All GRPC calls need to specify an internal ID. We will use HTTP2 stream-ids as call identifiers in this scheme. NOTE: These id’s are contextual to an open HTTP2 session and will not be unique within a given process that is handling more than one HTTP2 session nor can they be used as GUIDs.
+All GRPC calls need to specify an internal ID. We will use HTTP2 stream-ids as call identifiers in this scheme. NOTE: These ids are contextual to an open HTTP2 session and will not be unique within a given process that is handling more than one HTTP2 session nor can they be used as GUIDs.
##### Data Frames
DATA frame boundaries have no relation to **Length-Prefixed-Message** boundaries and implementations should make no assumptions about their alignment.
@@ -232,6 +233,7 @@ INADEQUATE_SECURITY| PERMISSION_DENIED … with additional detail indicating tha
The HTTP2 specification mandates the use of TLS 1.2 or higher when TLS is used with HTTP2. It also places some additional constraints on the allowed ciphers in deployments to avoid known-problems as well as requiring SNI support. It is also expected that HTTP2 will be used in conjunction with proprietary transport security mechanisms about which the specification can make no meaningful recommendations.
##### Connection Management
+
###### GOAWAY Frame
Sent by servers to clients to indicate that they will no longer accept any new streams on the associated connections. This frame includes the id of the last successfully accepted stream by the server. Clients should consider any stream initiated after the last successfully accepted stream as UNAVAILABLE and retry the call elsewhere. Clients are free to continue working with the already accepted streams until they complete or the connection is terminated.
diff --git a/doc/PROTOCOL-WEB.md b/doc/PROTOCOL-WEB.md
index 226871d7ae..c31a048a7c 100644
--- a/doc/PROTOCOL-WEB.md
+++ b/doc/PROTOCOL-WEB.md
@@ -3,14 +3,14 @@
gRPC-Web provides a JS client library that supports the same API
as gRPC-Node to access a gRPC service. Due to browser limitation,
the Web client library implements a different protocol than the
-[native gRPC protocol](https://grpc.io/docs/guides/wire.html).
+[native gRPC protocol](PROTOCOL-HTTP2.md).
This protocol is designed to make it easy for a proxy to translate
between the protocols as this is the most likely deployment model.
This document lists the differences between the two protocols.
To help tracking future revisions, this document describes a delta
with the protocol details specified in the
-[native gRPC protocol](https://grpc.io/docs/guides/wire.html).
+[native gRPC protocol](PROTOCOL-HTTP2.md).
# Design goals
@@ -31,7 +31,7 @@ web-specific features such as CORS, XSRF
* become optional (in 1-2 years) when browsers are able to speak the native
gRPC protocol via the new [whatwg fetch/streams API](https://github.com/whatwg/fetch)
-# Protocol differences vs [gRPC over HTTP2](https://grpc.io/docs/guides/wire.html)
+# Protocol differences vs [gRPC over HTTP2](PROTOCOL-HTTP2.md)
Content-Type
@@ -53,14 +53,14 @@ HTTP wire protocols
---
-HTTP/2 related behavior (specified in [gRPC over HTTP2](https://grpc.io/docs/guides/wire.html))
+HTTP/2 related behavior (specified in [gRPC over HTTP2](PROTOCOL-HTTP2.md))
1. stream-id is not supported or used
2. go-away is not supported or used
---
-Message framing (vs. [http2-transport-mapping](https://grpc.io/docs/guides/wire.html#http2-transport-mapping))
+Message framing (vs. [http2-transport-mapping](PROTOCOL-HTTP2.md#http2-transport-mapping))
1. Response status encoded as part of the response body
* Key-value pairs encoded as a HTTP/1 headers block (without the terminating newline), per https://tools.ietf.org/html/rfc7230#section-3.2
@@ -86,7 +86,7 @@ in the body.
User Agent
* Do NOT use User-Agent header (which is to be set by browsers, by default)
-* Use X-User-Agent: grpc-web-javascript/0.1 (follow the same format as specified in [gRPC over HTTP2](https://grpc.io/docs/guides/wire.html))
+* Use X-User-Agent: grpc-web-javascript/0.1 (follow the same format as specified in [gRPC over HTTP2](PROTOCOL-HTTP2.md))
---
diff --git a/doc/command_line_tool.md b/doc/command_line_tool.md
index 77c3d078ad..5465005027 100644
--- a/doc/command_line_tool.md
+++ b/doc/command_line_tool.md
@@ -58,50 +58,140 @@ $ make grpc_cli
The main file can be found at
https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc
+## Prerequisites
+
+Most `grpc_cli` commands need the server to support server reflection. See
+guides for
+[Java](https://github.com/grpc/grpc-java/blob/master/documentation/server-reflection-tutorial.md#enable-server-reflection)
+, [C++](https://github.com/grpc/grpc/blob/master/doc/server_reflection_tutorial.md)
+and [Go](https://github.com/grpc/grpc-go/blob/master/Documentation/server-reflection-tutorial.md)
+
## Usage
-### Basic usage
+### List services
-Send a rpc to a helloworld server at `localhost:50051`:
+`grpc_cli ls` command lists services and methods exposed at a given port
-```
-$ bins/opt/grpc_cli call localhost:50051 SayHello "name: 'world'" \
- --enable_ssl=false
-```
+- List all the services exposed at a given port
-On success, the tool will print out
+ ```sh
+ $ grpc_cli ls localhost:50051
+ ```
-```
-Rpc succeeded with OK status
-Response:
- message: "Hello world"
-```
+ output:
-The `localhost:50051` part indicates the server you are connecting to. `SayHello` is (part of) the
-gRPC method string. Then `"name: 'world'"` is the text format of the request proto message. We are
-not using ssl here by `--enable_ssl=false`. For information on more flags, look at the comments of `grpc_cli.cc`.
+ ```none
+ helloworld.Greeter
+ grpc.reflection.v1alpha.ServerReflection
+ ```
-### Use local proto files
+ The `localhost:50051` part indicates the server you are connecting to.
-If the server does not have the server reflection service, you will need to provide local proto
-files containing the service definition. The tool will try to find request/response types from
-them.
+- List one service with details
-```
-$ bins/opt/grpc_cli call localhost:50051 SayHello "name: 'world'" \
- --protofiles=examples/protos/helloworld.proto --enable_ssl=false
-```
+ `grpc_cli ls` command inspects a service given its full name (in the format
+ of \<package\>.\<service\>). It can print information with a long listing
+ format when `-l` flag is set. This flag can be used to get more details
+ about a service.
-If the proto files is not under current directory, you can use `--proto_path` to specify a new
-search root.
+ ```sh
+ $ grpc_cli ls localhost:50051 helloworld.Greeter -l
+ ```
-### Send non-proto rpc
+ `helloworld.Greeter` is full name of the service.
-For using gRPC with protocols other than probobuf, you will need the exact method name string
-and a file containing the raw bytes to be sent on the wire
+ output:
-```
-$ bins/opt/grpc_cli call localhost:50051 /helloworld.Greeter/SayHello --input_binary_file=input.bin \
- --output_binary_file=output.bin
-```
-On success, you will need to read or decode the response from the `output.bin` file.
+ ```proto
+ filename: helloworld.proto
+ package: helloworld;
+ service Greeter {
+ rpc SayHello(helloworld.HelloRequest) returns (helloworld.HelloReply) {}
+ }
+
+ ```
+
+### List methods
+
+- List one method with details
+
+ `grpc_cli ls` command also inspects a method given its full name (in the
+ format of \<package\>.\<service\>.\<method\>).
+
+ ```sh
+ $ grpc_cli ls localhost:50051 helloworld.Greeter.SayHello -l
+ ```
+
+ `helloworld.Greeter.SayHello` is full name of the method.
+
+ output:
+
+ ```proto
+ rpc SayHello(helloworld.HelloRequest) returns (helloworld.HelloReply) {}
+ ```
+
+### Inspect message types
+
+We can use `grpc_cli type` command to inspect request/response types given the
+full name of the type (in the format of \<package\>.\<type\>).
+
+- Get information about the request type
+
+ ```sh
+ $ grpc_cli type localhost:50051 helloworld.HelloRequest
+ ```
+
+ `helloworld.HelloRequest` is the full name of the request type.
+
+ output:
+
+ ```proto
+ message HelloRequest {
+ optional string name = 1;
+ }
+ ```
+
+### Call a remote method
+
+We can send RPCs to a server and get responses using `grpc_cli call` command.
+
+- Call a unary method Send a rpc to a helloworld server at `localhost:50051`:
+
+ ```sh
+ $ grpc_cli call localhost:50051 SayHello "name: 'gRPC CLI'"
+ ```
+
+ output: `sh message: "Hello gRPC CLI"`
+
+ `SayHello` is (part of) the gRPC method string. Then `"name: 'world'"` is
+ the text format of the request proto message. For information on more flags,
+ look at the comments of `grpc_cli.cc`.
+
+- Use local proto files
+
+ If the server does not have the server reflection service, you will need to
+ provide local proto files containing the service definition. The tool will
+ try to find request/response types from them.
+
+ ```sh
+ $ grpc_cli call localhost:50051 SayHello "name: 'world'" \
+ --protofiles=examples/protos/helloworld.proto
+ ```
+
+ If the proto file is not under the current directory, you can use
+ `--proto_path` to specify a new search root.
+
+- Send non-proto rpc
+
+ For using gRPC with protocols other than probobuf, you will need the exact
+ method name string and a file containing the raw bytes to be sent on the
+ wire.
+
+ ```bash
+ $ grpc_cli call localhost:50051 /helloworld.Greeter/SayHello \
+ --input_binary_file=input.bin \
+ --output_binary_file=output.bin
+ ```
+
+ On success, you will need to read or decode the response from the
+ `output.bin` file.
diff --git a/doc/connectivity-semantics-and-api.md b/doc/connectivity-semantics-and-api.md
index 6d39619d65..dc30fe5348 100644
--- a/doc/connectivity-semantics-and-api.md
+++ b/doc/connectivity-semantics-and-api.md
@@ -115,8 +115,14 @@ Channel State API
-----------------
All gRPC libraries will expose a channel-level API method to poll the current
-state of a channel. In C++, this method is called GetCurrentState and returns
-an enum for one of the five legal states.
+state of a channel. In C++, this method is called GetState and returns an enum
+for one of the five legal states. It also accepts a boolean `try_to_connect` to
+transition to CONNECTING if the channel is currently IDLE. The boolean should
+act as if an RPC occurred, so it should also reset IDLE_TIMEOUT.
+
+```cpp
+grpc_connectivity_state GetState(bool try_to_connect);
+```
All libraries should also expose an API that enables the application (user of
the gRPC API) to be notified when the channel state changes. Since state
@@ -127,11 +133,11 @@ the user to poll the channel for the current state.
The synchronous version of this API is:
```cpp
-bool WaitForStateChange(gpr_timespec deadline, ChannelState source_state);
+bool WaitForStateChange(grpc_connectivity_state source_state, gpr_timespec deadline);
```
-which returns true when the state changes to something other than the
-source_state and false if the deadline expires. Asynchronous and futures based
+which returns `true` when the state is something other than the
+`source_state` and `false` if the deadline expires. Asynchronous- and futures-based
APIs should have a corresponding method that allows the application to be
notified when the state of a channel changes.
diff --git a/doc/core/moving-to-c++.md b/doc/core/moving-to-c++.md
new file mode 100644
index 0000000000..4c745b38a9
--- /dev/null
+++ b/doc/core/moving-to-c++.md
@@ -0,0 +1,60 @@
+# Moving gRPC core to C++
+
+October 2017
+
+ctiller, markdroth, vjpai
+
+## Background and Goal
+
+gRPC core was originally written in C89 for several reasons
+(possibility of kernel integration, ease of wrapping, compiler
+support, etc). Over time, this was changed to C99 as all relevant
+compilers in active use came to support C99 effectively.
+[Now, gRPC core is C++](https://github.com/grpc/proposal/blob/master/L6-allow-c%2B%2B-in-grpc-core.md)
+(although the code is still idiomatically C code) with C linkage for
+public functions. Throughout all of these transitions, the public
+header files are committed to remain in C89.
+
+The goal now is to make the gRPC core implementation true idiomatic
+C++ compatible with
+[Google's C++ style guide](https://google.github.io/styleguide/cppguide.html).
+
+## Constraints
+
+- No use of standard library
+ - Standard library makes wrapping difficult/impossible and also reduces platform portability
+ - This takes precedence over using C++ style guide
+- But lambdas are ok
+- As are third-party libraries that meet our build requirements (such as many parts of abseil)
+- There will be some C++ features that don't work
+ - `new` and `delete`
+ - pure virtual functions are not allowed because the message that prints out "Pure Virtual Function called" is part of the standard library
+ - Make a `#define GRPC_ABSTRACT {GPR_ASSERT(false);}` instead of `= 0;`
+- The sanity for making sure that we don't depend on libstdc++ is that at least some tests should explicitly not include it
+ - Most tests can migrate to use gtest
+ - There are tremendous # of code paths that can now be exposed to unit tests because of the use of gtest and C++
+ - But at least some tests should not use gtest
+
+
+## Roadmap
+
+- What should be the phases of getting code converted to idiomatic C++
+ - Opportunistically do leaf code that other parts don't depend on
+ - Spend a little time deciding how to do non-leaf stuff that isn't central or polymorphic (e.g., timer, call combiner)
+ - For big central or polymorphic interfaces, actually do an API review (for things like transport, filter API, endpoint, closure, exec_ctx, ...) .
+ - Core internal changes don't need a gRFC, but core surface changes do
+ - But an API review should include at least a PR with the header change and tests to use it before it gets used more broadly
+ - iomgr polling for POSIX is a gray area whether it's a leaf or central
+- What is the schedule?
+ - In Q4 2017, if some stuff happens opportunistically, great; otherwise ¯\\\_(ツ)\_/¯
+ - More updates as team time becomes available and committed to this project
+
+## Implications for C++ API and wrapped languages
+
+- For C++ structs, switch to `using` when possible (e.g., Slice,
+ByteBuffer, ...)
+- The C++ API implementation might directly start using
+`grpc_transport_stream_op_batch` rather than the core surface `grpc_op`.
+- Can we get wrapped languages to a point where we can statically link C++? This will take a year in probability but that would allow the use of `std::`
+ - Are there other environments that don't support std library, like maybe Android NDK?
+ - Probably, that might push things out to 18 months
diff --git a/doc/core/transport_explainer.md b/doc/core/transport_explainer.md
new file mode 100644
index 0000000000..f48fa0f3b1
--- /dev/null
+++ b/doc/core/transport_explainer.md
@@ -0,0 +1,197 @@
+# Transport Explainer
+
+@vjpai
+
+## Existing Transports
+
+[gRPC
+transports](https://github.com/grpc/grpc/tree/master/src/core/ext/transport)
+plug in below the core API (one level below the C++ or other wrapped-language
+API). You can write your transport in C or C++ though; currently (Nov 2017) all
+the transports are nominally written in C++ though they are idiomatically C. The
+existing transports are:
+
+* [HTTP/2](https://github.com/grpc/grpc/tree/master/src/core/ext/transport/chttp2)
+* [Cronet](https://github.com/grpc/grpc/tree/master/src/core/ext/transport/cronet)
+* [In-process](https://github.com/grpc/grpc/tree/master/src/core/ext/transport/inproc)
+
+Among these, the in-process is likely the easiest to understand, though arguably
+also the least similar to a "real" sockets-based transport since it is only used
+in a single process.
+
+## Transport stream ops
+
+In the gRPC core implementation, a fundamental struct is the
+`grpc_transport_stream_op_batch` which represents a collection of stream
+operations sent to a transport. (Note that in gRPC, _stream_ and _RPC_ are used
+synonymously since all RPCs are actually streams internally.) The ops in a batch
+can include:
+
+* send\_initial\_metadata
+ - Client: initate an RPC
+ - Server: supply response headers
+* recv\_initial\_metadata
+ - Client: get response headers
+ - Server: accept an RPC
+* send\_message (zero or more) : send a data buffer
+* recv\_message (zero or more) : receive a data buffer
+* send\_trailing\_metadata
+ - Client: half-close indicating that no more messages will be coming
+ - Server: full-close providing final status for the RPC
+* recv\_trailing\_metadata: get final status for the RPC
+ - Server extra: This op shouldn't actually be considered complete until the
+ server has also sent trailing metadata to provide the other side with final
+ status
+* cancel\_stream: Attempt to cancel an RPC
+* collect\_stats: Get stats
+
+The fundamental responsibility of the transport is to transform between this
+internal format and an actual wire format, so the processing of these operations
+is largely transport-specific.
+
+One or more of these ops are grouped into a batch. Applications can start all of
+a call's ops in a single batch, or they can split them up into multiple
+batches. Results of each batch are returned asynchronously via a completion
+queue.
+
+Internally, we use callbacks to indicate completion. The surface layer creates a
+callback when starting a new batch and sends it down the filter stack along with
+the batch. The transport must invoke this callback when the batch is complete,
+and then the surface layer returns an event to the application via the
+completion queue. Each batch can have up to 3 callbacks:
+
+* recv\_initial\_metadata\_ready (called by the transport when the
+ recv\_initial\_metadata op is complete)
+* recv\_message\_ready (called by the transport when the recv_message op is
+ complete)
+* on\_complete (called by the transport when the entire batch is complete)
+
+## Timelines of transport stream op batches
+
+The transport's job is to sequence and interpret various possible interleavings
+of the basic stream ops. For example, a sample timeline of batches would be:
+
+1. Client send\_initial\_metadata: Initiate an RPC with a path (method) and authority
+1. Server recv\_initial\_metadata: accept an RPC
+1. Client send\_message: Supply the input proto for the RPC
+1. Server recv\_message: Get the input proto from the RPC
+1. Client send\_trailing\_metadata: This is a half-close indicating that the
+ client will not be sending any more messages
+1. Server recv\_trailing\_metadata: The server sees this from the client and
+ knows that it will not get any more messages. This won't complete yet though,
+ as described above.
+1. Server send\_initial\_metadata, send\_message, send\_trailing\_metadata: A
+ batch can contain multiple ops, and this batch provides the RPC response
+ headers, response content, and status. Note that sending the trailing
+ metadata will also complete the server's receive of trailing metadata.
+1. Client recv\_initial\_metadata: The number of ops in one side of the batch
+ has no relation with the number of ops on the other side of the batch. In
+ this case, the client is just collecting the response headers.
+1. Client recv\_message, recv\_trailing\_metadata: Get the data response and
+ status
+
+
+There are other possible sample timelines. For example, for client-side streaming, a "typical" sequence would be:
+
+1. Server: recv\_initial\_metadata
+ - At API-level, that would be the server requesting an RPC
+1. Server: recv\_trailing\_metadata
+ - This is for when the server wants to know the final completion of the RPC
+ through an `AsyncNotifyWhenDone` API in C++
+1. Client: send\_initial\_metadata, recv\_message, recv\_trailing\_metadata
+ - At API-level, that's a client invoking a client-side streaming call. The
+ send\_initial\_metadata is the call invocation, the recv\_message colects
+ the final response from the server, and the recv\_trailing\_metadata gets
+ the `grpc::Status` value that will be returned from the call
+1. Client: send\_message / Server: recv\_message
+ - Repeat the above step numerous times; these correspond to a client issuing
+ `Write` in a loop and a server doing `Read` in a loop until `Read` fails
+1. Client: send\_trailing\_metadata / Server: recv\_message that indicates doneness (NULL)
+ - These correspond to a client issuing `WritesDone` which causes the server's
+ `Read` to fail
+1. Server: send\_message, send\_trailing\_metadata
+ - These correpond to the server doing `Finish`
+
+The sends on one side will call their own callbacks when complete, and they will
+in turn trigger actions that cause the other side's recv operations to
+complete. In some transports, a send can sometimes complete before the recv on
+the other side (e.g., in HTTP/2 if there is sufficient flow-control buffer space
+available)
+
+## Other transport duties
+
+In addition to these basic stream ops, the transport must handle cancellations
+of a stream at any time and pass their effects to the other side. For example,
+in HTTP/2, this triggers a `RST_STREAM` being sent on the wire. The transport
+must perform operations like pings and statistics that are used to shape
+transport-level characteristics like flow control (see, for example, their use
+in the HTTP/2 transport).
+
+## Putting things together with detail: Sending Metadata
+
+* API layer: `map<string, string>` that is specific to this RPC
+* Core surface layer: array of `{slice, slice}` pairs where each slice
+ references an underlying string
+* [Core transport
+ layer](https://github.com/grpc/grpc/tree/master/src/core/lib/transport): list
+ of `{slice, slice}` pairs that includes the above plus possibly some general
+ metadata (e.g., Method and Authority for initial metadata)
+* [Specific transport
+ layer](https://github.com/grpc/grpc/tree/master/src/core/ext/transport):
+ - Either send it to the other side using transport-specific API (e.g., Cronet)
+ - Or have it sent through the [iomgr/endpoint
+ layer](https://github.com/grpc/grpc/tree/master/src/core/lib/iomgr) (e.g.,
+ HTTP/2)
+ - Or just manipulate pointers to get it from one side to the other (e.g.,
+ In-process)
+
+## Requirements for any transport
+
+Each transport implements several operations in a vtbl (may change to actual
+virtual functions as transport moves to idiomatic C++).
+
+The most important and common one is `perform_stream_op`. This function
+processes a single stream op batch on a specific stream that is associated with
+a specific transport:
+
+* Gets the 6 ops/cancel passed down from the surface
+* Pass metadata from one side to the other as described above
+* Transform messages between slice buffer structure and stream of bytes to pass
+ to other side
+ - May require insertion of extra bytes (e.g., per-message headers in HTTP/2)
+* React to metadata to preserve expected orderings (*)
+* Schedule invocation of completion callbacks
+
+There are other functions in the vtbl as well.
+
+* `perform_transport_op`
+ - Configure the transport instance for the connectivity state change notifier
+ or the server-side accept callback
+ - Disconnect transport or set up a goaway for later streams
+* `init_stream`
+ - Starts a stream from the client-side
+ - (*) Server-side of the transport must call `accept_stream_cb` when a new
+ stream is available
+ * Triggers request-matcher
+* `destroy_stream`, `destroy_transport`
+ - Free up data related to a stream or transport
+* `set_pollset`, `set_pollset_set`, `get_endpoint`
+ - Map each specific instance of the transport to FDs being used by iomgr (for
+ HTTP/2)
+ - Get a pointer to the endpoint structure that actually moves the data
+ (wrapper around a socket for HTTP/2)
+
+## Book-keeping responsibilities of the transport layer
+
+A given transport must keep all of its transport and streams ref-counted. This
+is essential to make sure that no struct disappears before it is done being
+used.
+
+A transport must also preserve relevant orders for the different categories of
+ops on a stream, as described above. A transport must also make sure that all
+relevant batch operations have completed before scheduling the `on_complete`
+closure for a batch. Further examples include the idea that the server logic
+expects to not complete recv\_trailing\_metadata until after it actually sends
+trailing metadata since it would have already found this out by seeing a NULL’ed
+recv\_message. This is considered part of the transport's duties in preserving
+orders.
diff --git a/doc/environment_variables.md b/doc/environment_variables.md
index f90f1d5b10..4796ad067d 100644
--- a/doc/environment_variables.md
+++ b/doc/environment_variables.md
@@ -49,6 +49,7 @@ some configuration as environment variables that can be set.
- connectivity_state - traces connectivity state changes to channels
- channel_stack_builder - traces information about channel stacks being built
- executor - traces grpc's internal thread pool ('the executor')
+ - glb - traces the grpclb load balancer
- http - traces state in the http2 transport engine
- http2_stream_state - traces all http2 stream state mutations.
- http1 - traces HTTP/1.x operations performed by gRPC
@@ -56,10 +57,12 @@ some configuration as environment variables that can be set.
- flowctl - traces http2 flow control
- op_failure - traces error information when failure is pushed onto a
completion queue
- - round_robin - traces the round_robin load balancing policy
- pick_first - traces the pick first load balancing policy
+ - plugin_credentials - traces plugin credentials
+ - pollable_refcount - traces reference counting of 'pollable' objects (only
+ in DEBUG)
- resource_quota - trace resource quota objects internals
- - glb - traces the grpclb load balancer
+ - round_robin - traces the round_robin load balancing policy
- queue_pluck
- queue_timeout
- server_channel - lightweight trace of significant server channel events
@@ -117,10 +120,15 @@ some configuration as environment variables that can be set.
perform name resolution
- ares - a DNS resolver based around the c-ares library
-* GRPC_DISABLE_CHANNEL_CONNECTIVITY_WATCHER
- The channel connectivity watcher uses one extra thread to check the channel
- state every 500 ms on the client side. It can help reconnect disconnected
- client channels (mostly due to idleness), so that the next RPC on this channel
- won't fail. Set to 1 to turn off this watcher and save a thread. Please note
- this is a temporary work-around, it will be removed in the future once we have
- support for automatically reestablishing failed connections.
+* GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS
+ Default: 5000
+ Declares the interval between two backup polls on client channels. These polls
+ are run in the timer thread so that gRPC can process connection failures while
+ there is no active polling thread. They help reconnect disconnected client
+ channels (mostly due to idleness), so that the next RPC on this channel won't
+ fail. Set to 0 to turn off the backup polls.
+
+* GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL
+ if set, flow control will be effectively disabled. Max out all values and
+ assume the remote peer does the same. Thus we can ignore any flow control
+ bookkeeping, error checking, and decision making
diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md
index 9a161d67a3..19875c36a0 100644
--- a/doc/g_stands_for.md
+++ b/doc/g_stands_for.md
@@ -11,3 +11,6 @@ future), and the corresponding version numbers that used them:
- 1.4 'g' stands for 'gregarious'
- 1.6 'g' stands for 'garcia'
- 1.7 'g' stands for 'gambit'
+- 1.8 'g' stands for 'generous'
+- 1.9 'g' stands for 'glossy'
+- 1.10 'g' stands for 'glamorous'
diff --git a/doc/load-balancing.md b/doc/load-balancing.md
index 88ff35496f..8ff94075b5 100644
--- a/doc/load-balancing.md
+++ b/doc/load-balancing.md
@@ -129,10 +129,9 @@ works:
by the resolver. It asks the balancer for the server addresses to
use for the server name originally requested by the client (i.e.,
the same one originally passed to the name resolver).
- - Note: The `grpclb` policy currently ignores any non-balancer
- addresses returned by the resolver. However, in the future, it
- may be changed to use these addresses as a fallback in case no
- balancers can be contacted.
+ - Note: In the `grpclb` policy, the non-balancer addresses returned
+ by the resolver are used as a fallback in case no balancers can be
+ contacted when the LB policy is started.
2. The gRPC servers to which the load balancer is directing the client
may report load to the load balancers, if that information is needed
by the load balancer's configuration.
diff --git a/doc/service_config.md b/doc/service_config.md
index 0abbd7f324..dd1cbc5630 100644
--- a/doc/service_config.md
+++ b/doc/service_config.md
@@ -12,7 +12,7 @@ The service config is a JSON string of the following form:
```
{
- // Load balancing policy name.
+ // Load balancing policy name (case insensitive).
// Currently, the only selectable client-side policy provided with gRPC
// is 'round_robin', but third parties may add their own policies.
// This field is optional; if unset, the default behavior is to pick
diff --git a/examples/BUILD b/examples/BUILD
index 3e9e508ec2..0f18cfa9ba 100644
--- a/examples/BUILD
+++ b/examples/BUILD
@@ -42,12 +42,12 @@ cc_binary(
name = "greeter_client",
srcs = ["cpp/helloworld/greeter_client.cc"],
defines = ["BAZEL_BUILD"],
- deps = [":helloworld"],
+ deps = [":helloworld", "//:grpc++"],
)
cc_binary(
name = "greeter_server",
srcs = ["cpp/helloworld/greeter_server.cc"],
defines = ["BAZEL_BUILD"],
- deps = [":helloworld"],
+ deps = [":helloworld", "//:grpc++"],
)
diff --git a/examples/cpp/helloworld/CMakeLists.txt b/examples/cpp/helloworld/CMakeLists.txt
index 71a8db4f24..c3ce4d5ba6 100644
--- a/examples/cpp/helloworld/CMakeLists.txt
+++ b/examples/cpp/helloworld/CMakeLists.txt
@@ -6,13 +6,36 @@ project(HelloWorld C CXX)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+else()
+ add_definitions(-D_WIN32_WINNT=0x600)
endif()
# Protobuf
-set(protobuf_MODULE_COMPATIBLE TRUE)
-find_package(protobuf CONFIG REQUIRED)
+# NOTE: we cannot use "CONFIG" mode here because protobuf-config.cmake
+# is broken when used with CMAKE_INSTALL_PREFIX
+find_package(Protobuf REQUIRED)
message(STATUS "Using protobuf ${protobuf_VERSION}")
+# {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG").
+# For "MODULE", the case has also changed between cmake 3.5 and 3.6.
+# We use the legacy uppercase version for *_LIBRARIES AND *_INCLUDE_DIRS variables
+# as newer cmake versions provide them too for backward compatibility.
+if(Protobuf_FOUND OR PROTOBUF_FOUND)
+ if(TARGET protobuf::libprotobuf)
+ set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
+ else()
+ set(_PROTOBUF_LIBPROTOBUF ${PROTOBUF_LIBRARIES})
+ include_directories(${PROTOBUF_INCLUDE_DIRS})
+ endif()
+ if(TARGET protobuf::protoc)
+ set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
+ else()
+ set(_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE})
+ endif()
+else()
+ message(WARNING "Failed to locate libprotobuf and protoc!")
+endif()
+
# gRPC
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
@@ -31,7 +54,7 @@ set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
add_custom_command(
OUTPUT "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
- COMMAND protobuf::protoc
+ COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" -I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${gRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
@@ -48,6 +71,6 @@ foreach(_target
${hw_proto_srcs}
${hw_grpc_srcs})
target_link_libraries(${_target}
- protobuf::libprotobuf
+ ${_PROTOBUF_LIBPROTOBUF}
gRPC::grpc++_unsecure)
endforeach()
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj b/examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..b722b80400
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj
@@ -0,0 +1,409 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 48;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 3DC71E95B8670DC619CF8693 /* libPods-HelloWorldCpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E3077D82811A6434769B437 /* libPods-HelloWorldCpp.a */; };
+ 5E9D65611FFD689B00C955D4 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E9D65601FFD689B00C955D4 /* AppDelegate.mm */; };
+ 5E9D65641FFD689B00C955D4 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E9D65631FFD689B00C955D4 /* ViewController.mm */; };
+ 5E9D65671FFD689B00C955D4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E9D65651FFD689B00C955D4 /* Main.storyboard */; };
+ 5E9D65691FFD689B00C955D4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E9D65681FFD689B00C955D4 /* Assets.xcassets */; };
+ 5E9D656C1FFD689B00C955D4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E9D656A1FFD689B00C955D4 /* LaunchScreen.storyboard */; };
+ 5E9D656F1FFD689C00C955D4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9D656E1FFD689C00C955D4 /* main.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 0A6137606FDBA874FCF64753 /* Pods-HelloWorldCpp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorldCpp.release.xcconfig"; path = "Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp.release.xcconfig"; sourceTree = "<group>"; };
+ 5E9D655C1FFD689B00C955D4 /* HelloWorldCpp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorldCpp.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E9D655F1FFD689B00C955D4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ 5E9D65601FFD689B00C955D4 /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; };
+ 5E9D65621FFD689B00C955D4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
+ 5E9D65631FFD689B00C955D4 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = "<group>"; };
+ 5E9D65661FFD689B00C955D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
+ 5E9D65681FFD689B00C955D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
+ 5E9D656B1FFD689B00C955D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
+ 5E9D656D1FFD689C00C955D4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5E9D656E1FFD689C00C955D4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 8E3077D82811A6434769B437 /* libPods-HelloWorldCpp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorldCpp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ AF0FF6EB66DA2C30CFC575EA /* Pods-HelloWorldCpp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorldCpp.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp.debug.xcconfig"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 5E9D65591FFD689B00C955D4 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 3DC71E95B8670DC619CF8693 /* libPods-HelloWorldCpp.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 08FBFA5AB49E037A86EA64D7 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 8E3077D82811A6434769B437 /* libPods-HelloWorldCpp.a */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 5E9D65531FFD689B00C955D4 = {
+ isa = PBXGroup;
+ children = (
+ 5E9D655E1FFD689B00C955D4 /* HelloWorldCpp */,
+ 5E9D655D1FFD689B00C955D4 /* Products */,
+ E40B264856595518D408CF3E /* Pods */,
+ 08FBFA5AB49E037A86EA64D7 /* Frameworks */,
+ );
+ sourceTree = "<group>";
+ };
+ 5E9D655D1FFD689B00C955D4 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 5E9D655C1FFD689B00C955D4 /* HelloWorldCpp.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 5E9D655E1FFD689B00C955D4 /* HelloWorldCpp */ = {
+ isa = PBXGroup;
+ children = (
+ 5E9D655F1FFD689B00C955D4 /* AppDelegate.h */,
+ 5E9D65601FFD689B00C955D4 /* AppDelegate.mm */,
+ 5E9D65621FFD689B00C955D4 /* ViewController.h */,
+ 5E9D65631FFD689B00C955D4 /* ViewController.mm */,
+ 5E9D65651FFD689B00C955D4 /* Main.storyboard */,
+ 5E9D65681FFD689B00C955D4 /* Assets.xcassets */,
+ 5E9D656A1FFD689B00C955D4 /* LaunchScreen.storyboard */,
+ 5E9D656D1FFD689C00C955D4 /* Info.plist */,
+ 5E9D656E1FFD689C00C955D4 /* main.m */,
+ );
+ path = HelloWorldCpp;
+ sourceTree = "<group>";
+ };
+ E40B264856595518D408CF3E /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ AF0FF6EB66DA2C30CFC575EA /* Pods-HelloWorldCpp.debug.xcconfig */,
+ 0A6137606FDBA874FCF64753 /* Pods-HelloWorldCpp.release.xcconfig */,
+ );
+ name = Pods;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 5E9D655B1FFD689B00C955D4 /* HelloWorldCpp */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5E9D65721FFD689C00C955D4 /* Build configuration list for PBXNativeTarget "HelloWorldCpp" */;
+ buildPhases = (
+ 4D66D60BD88AA4D5813859A9 /* [CP] Check Pods Manifest.lock */,
+ 5E9D65581FFD689B00C955D4 /* Sources */,
+ 5E9D65591FFD689B00C955D4 /* Frameworks */,
+ 5E9D655A1FFD689B00C955D4 /* Resources */,
+ CA89B315EACC5A6F8816FD26 /* [CP] Embed Pods Frameworks */,
+ 6C4D930C765719D03893663B /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = HelloWorldCpp;
+ productName = HelloWorldCpp;
+ productReference = 5E9D655C1FFD689B00C955D4 /* HelloWorldCpp.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 5E9D65541FFD689B00C955D4 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0920;
+ ORGANIZATIONNAME = gRPC;
+ TargetAttributes = {
+ 5E9D655B1FFD689B00C955D4 = {
+ CreatedOnToolsVersion = 9.2;
+ ProvisioningStyle = Automatic;
+ };
+ };
+ };
+ buildConfigurationList = 5E9D65571FFD689B00C955D4 /* Build configuration list for PBXProject "HelloWorldCpp" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 5E9D65531FFD689B00C955D4;
+ productRefGroup = 5E9D655D1FFD689B00C955D4 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 5E9D655B1FFD689B00C955D4 /* HelloWorldCpp */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 5E9D655A1FFD689B00C955D4 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E9D656C1FFD689B00C955D4 /* LaunchScreen.storyboard in Resources */,
+ 5E9D65691FFD689B00C955D4 /* Assets.xcassets in Resources */,
+ 5E9D65671FFD689B00C955D4 /* Main.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 4D66D60BD88AA4D5813859A9 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-HelloWorldCpp-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 6C4D930C765719D03893663B /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ CA89B315EACC5A6F8816FD26 /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 5E9D65581FFD689B00C955D4 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E9D65641FFD689B00C955D4 /* ViewController.mm in Sources */,
+ 5E9D656F1FFD689C00C955D4 /* main.m in Sources */,
+ 5E9D65611FFD689B00C955D4 /* AppDelegate.mm in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 5E9D65651FFD689B00C955D4 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 5E9D65661FFD689B00C955D4 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "<group>";
+ };
+ 5E9D656A1FFD689B00C955D4 /* LaunchScreen.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 5E9D656B1FFD689B00C955D4 /* Base */,
+ );
+ name = LaunchScreen.storyboard;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 5E9D65701FFD689C00C955D4 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 5E9D65711FFD689C00C955D4 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 5E9D65731FFD689C00C955D4 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = AF0FF6EB66DA2C30CFC575EA /* Pods-HelloWorldCpp.debug.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ INFOPLIST_FILE = HelloWorldCpp/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.HelloWorldCpp;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5E9D65741FFD689C00C955D4 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 0A6137606FDBA874FCF64753 /* Pods-HelloWorldCpp.release.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ INFOPLIST_FILE = HelloWorldCpp/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.HelloWorldCpp;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 5E9D65571FFD689B00C955D4 /* Build configuration list for PBXProject "HelloWorldCpp" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E9D65701FFD689C00C955D4 /* Debug */,
+ 5E9D65711FFD689C00C955D4 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5E9D65721FFD689C00C955D4 /* Build configuration list for PBXNativeTarget "HelloWorldCpp" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E9D65731FFD689C00C955D4 /* Debug */,
+ 5E9D65741FFD689C00C955D4 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 5E9D65541FFD689B00C955D4 /* Project object */;
+}
diff --git a/src/node/health_check/node_modules/grpc.js b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h
index 83f1982107..91ba988c4a 100644
--- a/src/node/health_check/node_modules/grpc.js
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2016 gRPC authors.
+ * 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.
@@ -16,7 +16,8 @@
*
*/
-/* This exists solely to allow the generated code to import the grpc module
- * without using a relative path */
+#import <UIKit/UIKit.h>
-module.exports = require('../..');
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+@property (strong, nonatomic) UIWindow *window;
+@end
diff --git a/src/node/test/math/node_modules/grpc.js b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm
index b824d8ddc6..5c60aec65b 100644
--- a/src/node/test/math/node_modules/grpc.js
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2016 gRPC authors.
+ * 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.
@@ -16,7 +16,7 @@
*
*/
-/* This exists solely to allow the generated code to import the grpc module
- * without using a relative path */
+#import "AppDelegate.h"
-module.exports = require('../../..');
+@implementation AppDelegate
+@end
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000000..1d060ed288
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,93 @@
+{
+ "images" : [
+ {
+ "idiom" : "iphone",
+ "size" : "20x20",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "20x20",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "20x20",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "20x20",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "29x29",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "29x29",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "40x40",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "40x40",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "76x76",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "76x76",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "83.5x83.5",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard
new file mode 100644
index 0000000000..f83f6fd581
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="EHf-IW-A2E">
+ <objects>
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="53" y="375"/>
+ </scene>
+ </scenes>
+</document>
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard
new file mode 100644
index 0000000000..d7c78a1255
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="tne-QT-ifu">
+ <objects>
+ <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
+ </objects>
+ </scene>
+ </scenes>
+</document>
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist
new file mode 100644
index 0000000000..16be3b6811
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UILaunchStoryboardName</key>
+ <string>LaunchScreen</string>
+ <key>UIMainStoryboardFile</key>
+ <string>Main</string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h
new file mode 100644
index 0000000000..28d4ca0961
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h
@@ -0,0 +1,23 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <UIKit/UIKit.h>
+
+@interface ViewController : UIViewController
+@end
+
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm
new file mode 100644
index 0000000000..6ff1ca593d
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm
@@ -0,0 +1,101 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import "ViewController.h"
+#import <grpc++/grpc++.h>
+#include <grpc++/generic/generic_stub.h>
+#include <grpc++/generic/async_generic_service.h>
+
+static void* tag(int i) { return (void*)(intptr_t)i; }
+
+// Serialized Proto bytes of Hello World example
+const uint8_t kMessage[] =
+ {0x0A, 0x0B, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2D, 0x43};
+
+@interface ViewController ()
+
+@end
+
+@implementation ViewController {
+ grpc::CompletionQueue cq_;
+ std::unique_ptr<grpc::GenericStub> generic_stub_;
+}
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ // Setup call stub
+ std::shared_ptr<grpc::Channel> channel =
+ CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
+ generic_stub_.reset(new grpc::GenericStub(channel));
+
+ const grpc::string kMethodName("/helloworld.Greeter/SayHello");
+ void* got_tag;
+ bool ok;
+
+ grpc::ClientContext cli_ctx;
+ std::unique_ptr<grpc::GenericClientAsyncReaderWriter> call =
+ generic_stub_->Call(&cli_ctx, kMethodName, &cq_, tag(1));
+ cq_.Next(&got_tag, &ok);
+ if (!ok || got_tag != tag(1)) {
+ NSLog(@"Failed to create call.");
+ abort();
+ }
+ grpc::Slice send_slice = grpc::Slice(kMessage, sizeof(kMessage) / sizeof(kMessage[0]));
+ std::unique_ptr<grpc::ByteBuffer> send_buffer(new grpc::ByteBuffer(&send_slice, 1));
+ call->Write(*send_buffer, tag(2));
+ cq_.Next(&got_tag, &ok);
+ if (!ok || got_tag != tag(2)) {
+ NSLog(@"Failed to send message.");
+ abort();
+ }
+ grpc::ByteBuffer recv_buffer;
+ call->Read(&recv_buffer, tag(3));
+ cq_.Next(&got_tag, &ok);
+ if (!ok || got_tag != tag(3)) {
+ NSLog(@"Failed to receive message.");
+ abort();
+ }
+
+ grpc::Status status;
+ call->Finish(&status, tag(4));
+ cq_.Next(&got_tag, &ok);
+ if (!ok || got_tag != tag(4)) {
+ NSLog(@"Failed to finish call.");
+ abort();
+ }
+ if (!status.ok()) {
+ NSLog(@"Received unsuccessful status code: %d", status.error_code());
+ abort();
+ }
+ std::vector<grpc::Slice> slices;
+ recv_buffer.Dump(&slices);
+ NSString *recvBytes = [[NSString alloc] init];
+ for (auto slice : slices) {
+ auto p = slice.begin();
+ while (p != slice.end()) {
+ recvBytes =
+ [recvBytes stringByAppendingString:[NSString stringWithFormat:@"%02x ", *p]];
+ p++;
+ }
+ }
+ NSLog(@"Hello World succeeded.\nReceived bytes: %@\n"
+ "Expected bytes: 0a 11 48 65 6c 6c 6f 20 4f 62 6a 65 63 74 69 76 65 2d 43", recvBytes);
+}
+
+@end
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m
new file mode 100644
index 0000000000..a3a2225806
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <UIKit/UIKit.h>
+#import "AppDelegate.h"
+
+int main(int argc, char * argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}
diff --git a/examples/cpp/helloworld/cocoapods/Podfile b/examples/cpp/helloworld/cocoapods/Podfile
new file mode 100644
index 0000000000..5467f97080
--- /dev/null
+++ b/examples/cpp/helloworld/cocoapods/Podfile
@@ -0,0 +1,8 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+target 'HelloWorldCpp' do
+ pod 'gRPC-C++'
+end
diff --git a/examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj b/examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj
index 6b26be1c9c..3bff4a576b 100644
--- a/examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj
+++ b/examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj
@@ -6,14 +6,13 @@
<DebugType>portable</DebugType>
<AssemblyName>Greeter</AssemblyName>
<PackageId>Greeter</PackageId>
- <RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Google.Protobuf" Version="3.2.0" />
- <PackageReference Include="Google.Protobuf.Tools" Version="3.2.0" />
- <PackageReference Include="Grpc" Version="1.2.2" />
- <PackageReference Include="Grpc.Tools" Version="1.2.2" />
+ <PackageReference Include="Google.Protobuf" Version="3.5.0" />
+ <PackageReference Include="Google.Protobuf.Tools" Version="3.5.0" />
+ <PackageReference Include="Grpc" Version="1.8.0" />
+ <PackageReference Include="Grpc.Tools" Version="1.8.0" />
</ItemGroup>
</Project>
diff --git a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
index 8168b287b4..c808884e57 100644
--- a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
+++ b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
@@ -15,6 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
+#pragma warning disable 1591
#region Designer generated code
using System;
diff --git a/examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj
index 24cacfc021..d1ed040411 100644
--- a/examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj
+++ b/examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj
@@ -7,7 +7,6 @@
<AssemblyName>GreeterClient</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>GreeterClient</PackageId>
- <RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
diff --git a/examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj
index f7980fa728..159fbd8a23 100644
--- a/examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj
+++ b/examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj
@@ -7,7 +7,6 @@
<AssemblyName>GreeterServer</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>GreeterServer</PackageId>
- <RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
diff --git a/examples/csharp/helloworld-from-cli/generate_protos.bat b/examples/csharp/helloworld-from-cli/generate_protos.bat
index e290be63c9..dcf60848f7 100644
--- a/examples/csharp/helloworld-from-cli/generate_protos.bat
+++ b/examples/csharp/helloworld-from-cli/generate_protos.bat
@@ -19,8 +19,8 @@ setlocal
@rem enter this directory
cd /d %~dp0
-set PROTOC=%UserProfile%\.nuget\packages\Google.Protobuf.Tools\3.2.0\tools\windows_x64\protoc.exe
-set PLUGIN=%UserProfile%\.nuget\packages\Grpc.Tools\1.2.2\tools\windows_x64\grpc_csharp_plugin.exe
+set PROTOC=%UserProfile%\.nuget\packages\Google.Protobuf.Tools\3.5.0\tools\windows_x64\protoc.exe
+set PLUGIN=%UserProfile%\.nuget\packages\Grpc.Tools\1.8.0\tools\windows_x64\grpc_csharp_plugin.exe
%PROTOC% -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=%PLUGIN%
diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj
index 8dcd2d9066..d2597f13b5 100644
--- a/examples/csharp/helloworld/Greeter/Greeter.csproj
+++ b/examples/csharp/helloworld/Greeter/Greeter.csproj
@@ -32,12 +32,12 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+ <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
@@ -62,11 +62,11 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
- <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
+ <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
+ <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
</Target>
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
index 8168b287b4..c808884e57 100644
--- a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
+++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
@@ -15,6 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
+#pragma warning disable 1591
#region Designer generated code
using System;
diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config
index ec83cd8300..38297f8d61 100644
--- a/examples/csharp/helloworld/Greeter/packages.config
+++ b/examples/csharp/helloworld/Greeter/packages.config
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
- <package id="Grpc" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Tools" version="1.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
+ <package id="Grpc" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Tools" version="1.8.0" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
index 4b6b1b3e12..470749a2b2 100644
--- a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
+++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
@@ -32,12 +32,12 @@
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+ <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
@@ -60,11 +60,11 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
- <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
+ <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
+ <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
</Target>
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config
index b912fd4958..4b3684edfd 100644
--- a/examples/csharp/helloworld/GreeterClient/packages.config
+++ b/examples/csharp/helloworld/GreeterClient/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
- <package id="Grpc" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
+ <package id="Grpc" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
index 97978fa7ac..82e2961cad 100644
--- a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
+++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
@@ -32,12 +32,12 @@
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+ <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
@@ -60,11 +60,11 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
- <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
+ <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
+ <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
</Target>
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config
index b912fd4958..4b3684edfd 100644
--- a/examples/csharp/helloworld/GreeterServer/packages.config
+++ b/examples/csharp/helloworld/GreeterServer/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
- <package id="Grpc" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
+ <package id="Grpc" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/generate_protos.bat b/examples/csharp/helloworld/generate_protos.bat
index f955470d66..45b097e837 100644
--- a/examples/csharp/helloworld/generate_protos.bat
+++ b/examples/csharp/helloworld/generate_protos.bat
@@ -19,7 +19,7 @@ setlocal
@rem enter this directory
cd /d %~dp0
-set TOOLS_PATH=packages\Grpc.Tools.1.2.2\tools\windows_x86
+set TOOLS_PATH=packages\Grpc.Tools.1.8.0\tools\windows_x86
%TOOLS_PATH%\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
index 360444e491..e66e986f71 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
@@ -32,12 +32,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+ <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -75,12 +75,12 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
+ <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
+ <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
index 26278eaade..765d5d520b 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
@@ -15,6 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
+#pragma warning disable 1591
#region Designer generated code
using System;
diff --git a/examples/csharp/route_guide/RouteGuide/packages.config b/examples/csharp/route_guide/RouteGuide/packages.config
index 2dde11f1dd..fe2c995f26 100644
--- a/examples/csharp/route_guide/RouteGuide/packages.config
+++ b/examples/csharp/route_guide/RouteGuide/packages.config
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
- <package id="Grpc" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
+ <package id="Grpc" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
index 162eaeddc1..612f60cba5 100644
--- a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
+++ b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
@@ -34,12 +34,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+ <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -72,12 +72,12 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
+ <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
+ <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/examples/csharp/route_guide/RouteGuideClient/packages.config b/examples/csharp/route_guide/RouteGuideClient/packages.config
index 2dde11f1dd..fe2c995f26 100644
--- a/examples/csharp/route_guide/RouteGuideClient/packages.config
+++ b/examples/csharp/route_guide/RouteGuideClient/packages.config
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
- <package id="Grpc" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
+ <package id="Grpc" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
index b6f2f351aa..4d9d9d74f2 100644
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
+++ b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
@@ -34,12 +34,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+ <Reference Include="Google.Protobuf, Version=3.5.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
- <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -73,12 +73,12 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
+ <Import Project="..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
- <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
+ <Error Condition="!Exists('..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.8.0\build\net45\Grpc.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/examples/csharp/route_guide/RouteGuideServer/packages.config b/examples/csharp/route_guide/RouteGuideServer/packages.config
index 46df6453da..2bb1f0d0bf 100644
--- a/examples/csharp/route_guide/RouteGuideServer/packages.config
+++ b/examples/csharp/route_guide/RouteGuideServer/packages.config
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
- <package id="Grpc" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
- <package id="Grpc.Tools" version="1.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.5.0" targetFramework="net45" />
+ <package id="Grpc" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="1.8.0" targetFramework="net45" />
+ <package id="Grpc.Tools" version="1.8.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/generate_protos.bat b/examples/csharp/route_guide/generate_protos.bat
index 731168334d..a8c9cb505a 100644
--- a/examples/csharp/route_guide/generate_protos.bat
+++ b/examples/csharp/route_guide/generate_protos.bat
@@ -19,7 +19,7 @@ setlocal
@rem enter this directory
cd /d %~dp0
-set TOOLS_PATH=packages\Grpc.Tools.1.2.2\tools\windows_x86
+set TOOLS_PATH=packages\Grpc.Tools.1.8.0\tools\windows_x86
%TOOLS_PATH%\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe
diff --git a/examples/node/dynamic_codegen/greeter_server.js b/examples/node/dynamic_codegen/greeter_server.js
index f9cb1b13d6..180f96c28b 100644
--- a/examples/node/dynamic_codegen/greeter_server.js
+++ b/examples/node/dynamic_codegen/greeter_server.js
@@ -34,7 +34,7 @@ function sayHello(call, callback) {
*/
function main() {
var server = new grpc.Server();
- server.addProtoService(hello_proto.Greeter.service, {sayHello: sayHello});
+ server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}
diff --git a/examples/php/README.md b/examples/php/README.md
index d30cbdafd0..49703ce172 100644
--- a/examples/php/README.md
+++ b/examples/php/README.md
@@ -41,10 +41,11 @@ TRY IT!
$ node greeter_server.js
```
- - Run the client
+ - Generate proto files and run the client
```
$ cd examples/php
+ $ ./greeter_proto_gen.sh
$ ./run_greeter_client.sh
```
diff --git a/examples/php/greeter_client.php b/examples/php/greeter_client.php
index 981319a451..bb94a08527 100644
--- a/examples/php/greeter_client.php
+++ b/examples/php/greeter_client.php
@@ -17,12 +17,14 @@
*
*/
+// php:generate protoc --proto_path=./../protos --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=./../../bins/opt/grpc_php_plugin ./../protos/helloworld.proto
+
require dirname(__FILE__).'/vendor/autoload.php';
-// The following includes are needed when using protobuf 3.1.0
-// and will suppress warnings when using protobuf 3.2.0+
-@include_once dirname(__FILE__).'/helloworld.pb.php';
-@include_once dirname(__FILE__).'/helloworld_grpc_pb.php';
+@include_once dirname(__FILE__).'/Helloworld/GreeterClient.php';
+@include_once dirname(__FILE__).'/Helloworld/HelloReply.php';
+@include_once dirname(__FILE__).'/Helloworld/HelloRequest.php';
+@include_once dirname(__FILE__).'/GPBMetadata/Helloworld.php';
function greet($name)
{
diff --git a/examples/php/greeter_proto_gen.sh b/examples/php/greeter_proto_gen.sh
new file mode 100755
index 0000000000..a0d7b29c86
--- /dev/null
+++ b/examples/php/greeter_proto_gen.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# 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.
+
+protoc --proto_path=./../protos --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=./../../bins/opt/grpc_php_plugin ./../protos/helloworld.proto
+
diff --git a/examples/php/helloworld.pb.php b/examples/php/helloworld.pb.php
deleted file mode 100644
index 757a4a58f5..0000000000
--- a/examples/php/helloworld.pb.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: helloworld.proto
-
-namespace Helloworld;
-
-use Google\Protobuf\Internal\DescriptorPool;
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\GPBUtil;
-
-class HelloRequest extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- }
-
-}
-
-class HelloReply extends \Google\Protobuf\Internal\Message
-{
- private $message = '';
-
- public function getMessage()
- {
- return $this->message;
- }
-
- public function setMessage($var)
- {
- GPBUtil::checkString($var, True);
- $this->message = $var;
- }
-
-}
-
-$pool = DescriptorPool::getGeneratedPool();
-
-$pool->internalAddGeneratedFile(hex2bin(
- "0ae6010a1068656c6c6f776f726c642e70726f746f120a68656c6c6f776f" .
- "726c64221c0a0c48656c6c6f52657175657374120c0a046e616d65180120" .
- "012809221d0a0a48656c6c6f5265706c79120f0a076d6573736167651801" .
- "2001280932490a0747726565746572123e0a0853617948656c6c6f12182e" .
- "68656c6c6f776f726c642e48656c6c6f526571756573741a162e68656c6c" .
- "6f776f726c642e48656c6c6f5265706c79220042360a1b696f2e67727063" .
- "2e6578616d706c65732e68656c6c6f776f726c64420f48656c6c6f576f72" .
- "6c6450726f746f5001a20203484c57620670726f746f33"
-));
-
diff --git a/examples/php/route_guide/route_guide.pb.php b/examples/php/route_guide/route_guide.pb.php
deleted file mode 100644
index 78f3ea6e2a..0000000000
--- a/examples/php/route_guide/route_guide.pb.php
+++ /dev/null
@@ -1,209 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: route_guide.proto
-
-namespace Routeguide;
-
-use Google\Protobuf\Internal\DescriptorPool;
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\GPBUtil;
-
-class Point extends \Google\Protobuf\Internal\Message
-{
- private $latitude = 0;
- private $longitude = 0;
-
- public function getLatitude()
- {
- return $this->latitude;
- }
-
- public function setLatitude($var)
- {
- GPBUtil::checkInt32($var);
- $this->latitude = $var;
- }
-
- public function getLongitude()
- {
- return $this->longitude;
- }
-
- public function setLongitude($var)
- {
- GPBUtil::checkInt32($var);
- $this->longitude = $var;
- }
-
-}
-
-class Rectangle extends \Google\Protobuf\Internal\Message
-{
- private $lo = null;
- private $hi = null;
-
- public function getLo()
- {
- return $this->lo;
- }
-
- public function setLo(&$var)
- {
- GPBUtil::checkMessage($var, \Routeguide\Point::class);
- $this->lo = $var;
- }
-
- public function getHi()
- {
- return $this->hi;
- }
-
- public function setHi(&$var)
- {
- GPBUtil::checkMessage($var, \Routeguide\Point::class);
- $this->hi = $var;
- }
-
-}
-
-class Feature extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $location = null;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- }
-
- public function getLocation()
- {
- return $this->location;
- }
-
- public function setLocation(&$var)
- {
- GPBUtil::checkMessage($var, \Routeguide\Point::class);
- $this->location = $var;
- }
-
-}
-
-class RouteNote extends \Google\Protobuf\Internal\Message
-{
- private $location = null;
- private $message = '';
-
- public function getLocation()
- {
- return $this->location;
- }
-
- public function setLocation(&$var)
- {
- GPBUtil::checkMessage($var, \Routeguide\Point::class);
- $this->location = $var;
- }
-
- public function getMessage()
- {
- return $this->message;
- }
-
- public function setMessage($var)
- {
- GPBUtil::checkString($var, True);
- $this->message = $var;
- }
-
-}
-
-class RouteSummary extends \Google\Protobuf\Internal\Message
-{
- private $point_count = 0;
- private $feature_count = 0;
- private $distance = 0;
- private $elapsed_time = 0;
-
- public function getPointCount()
- {
- return $this->point_count;
- }
-
- public function setPointCount($var)
- {
- GPBUtil::checkInt32($var);
- $this->point_count = $var;
- }
-
- public function getFeatureCount()
- {
- return $this->feature_count;
- }
-
- public function setFeatureCount($var)
- {
- GPBUtil::checkInt32($var);
- $this->feature_count = $var;
- }
-
- public function getDistance()
- {
- return $this->distance;
- }
-
- public function setDistance($var)
- {
- GPBUtil::checkInt32($var);
- $this->distance = $var;
- }
-
- public function getElapsedTime()
- {
- return $this->elapsed_time;
- }
-
- public function setElapsedTime($var)
- {
- GPBUtil::checkInt32($var);
- $this->elapsed_time = $var;
- }
-
-}
-
-$pool = DescriptorPool::getGeneratedPool();
-
-$pool->internalAddGeneratedFile(hex2bin(
- "0ac5050a11726f7574655f67756964652e70726f746f120a726f75746567" .
- "75696465222c0a05506f696e7412100a086c617469747564651801200128" .
- "0512110a096c6f6e67697475646518022001280522490a0952656374616e" .
- "676c65121d0a026c6f18012001280b32112e726f75746567756964652e50" .
- "6f696e74121d0a02686918022001280b32112e726f75746567756964652e" .
- "506f696e74223c0a0746656174757265120c0a046e616d65180120012809" .
- "12230a086c6f636174696f6e18022001280b32112e726f75746567756964" .
- "652e506f696e7422410a09526f7574654e6f746512230a086c6f63617469" .
- "6f6e18012001280b32112e726f75746567756964652e506f696e74120f0a" .
- "076d65737361676518022001280922620a0c526f75746553756d6d617279" .
- "12130a0b706f696e745f636f756e7418012001280512150a0d6665617475" .
- "72655f636f756e7418022001280512100a0864697374616e636518032001" .
- "280512140a0c656c61707365645f74696d651804200128053285020a0a52" .
- "6f757465477569646512360a0a4765744665617475726512112e726f7574" .
- "6567756964652e506f696e741a132e726f75746567756964652e46656174" .
- "7572652200123e0a0c4c697374466561747572657312152e726f75746567" .
- "756964652e52656374616e676c651a132e726f75746567756964652e4665" .
- "617475726522003001123e0a0b5265636f7264526f75746512112e726f75" .
- "746567756964652e506f696e741a182e726f75746567756964652e526f75" .
- "746553756d6d61727922002801123f0a09526f7574654368617412152e72" .
- "6f75746567756964652e526f7574654e6f74651a152e726f757465677569" .
- "64652e526f7574654e6f746522002801300142360a1b696f2e677270632e" .
- "6578616d706c65732e726f7574656775696465420f526f75746547756964" .
- "6550726f746f5001a20203525447620670726f746f33"
-));
-
diff --git a/examples/php/route_guide/route_guide_client.php b/examples/php/route_guide/route_guide_client.php
index 8ac797722c..92b2bacecd 100644
--- a/examples/php/route_guide/route_guide_client.php
+++ b/examples/php/route_guide/route_guide_client.php
@@ -17,12 +17,9 @@
*
*/
-require dirname(__FILE__).'/../vendor/autoload.php';
+// php:generate protoc --proto_path=./../../protos --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=./../../../bins/opt/grpc_php_plugin ./../../protos/route_guide.proto
-// The following includes are needed when using protobuf 3.1.0
-// and will suppress warnings when using protobuf 3.2.0+
-@include_once dirname(__FILE__).'/route_guide.pb.php';
-@include_once dirname(__FILE__).'/route_guide_grpc_pb.php';
+require dirname(__FILE__).'/../vendor/autoload.php';
define('COORD_FACTOR', 1e7);
@@ -38,9 +35,12 @@ function printFeature($feature)
} else {
$name_str = "feature called $name";
}
- echo sprintf("Found %s \n at %f, %f\n", $name_str,
+ echo sprintf(
+ "Found %s \n at %f, %f\n",
+ $name_str,
$feature->getLocation()->getLatitude() / COORD_FACTOR,
- $feature->getLocation()->getLongitude() / COORD_FACTOR);
+ $feature->getLocation()->getLongitude() / COORD_FACTOR
+ );
}
/**
@@ -122,19 +122,24 @@ function runRecordRoute()
$feature_name = $db[$index]['name'];
$point->setLatitude($lat);
$point->setLongitude($long);
- echo sprintf("Visiting point %f, %f,\n with feature name: %s\n",
- $lat / COORD_FACTOR, $long / COORD_FACTOR,
- $feature_name ? $feature_name : '<empty>');
+ echo sprintf(
+ "Visiting point %f, %f,\n with feature name: %s\n",
+ $lat / COORD_FACTOR,
+ $long / COORD_FACTOR,
+ $feature_name ? $feature_name : '<empty>'
+ );
usleep(rand(300000, 800000));
$call->write($point);
}
list($route_summary, $status) = $call->wait();
- echo sprintf("Finished trip with %d points\nPassed %d features\n".
+ echo sprintf(
+ "Finished trip with %d points\nPassed %d features\n".
"Travelled %d meters\nIt took %d seconds\n",
$route_summary->getPointCount(),
$route_summary->getFeatureCount(),
$route_summary->getDistance(),
- $route_summary->getElapsedTime());
+ $route_summary->getElapsedTime()
+ );
}
/**
@@ -166,8 +171,12 @@ function runRouteChat()
$route_note->setLocation($point);
$route_note->setMessage($message = $n[2]);
- echo sprintf("Sending message: '%s' at (%d, %d)\n",
- $message, $lat, $long);
+ echo sprintf(
+ "Sending message: '%s' at (%d, %d)\n",
+ $message,
+ $lat,
+ $long
+ );
// send a bunch of messages to the server
$call->write($route_note);
}
@@ -175,10 +184,12 @@ function runRouteChat()
// read from the server until there's no more
while ($route_note_reply = $call->read()) {
- echo sprintf("Previous left message at (%d, %d): '%s'\n",
+ echo sprintf(
+ "Previous left message at (%d, %d): '%s'\n",
$route_note_reply->getLocation()->getLatitude(),
$route_note_reply->getLocation()->getLongitude(),
- $route_note_reply->getMessage());
+ $route_note_reply->getMessage()
+ );
}
}
diff --git a/examples/php/route_guide/route_guide_grpc_pb.php b/examples/php/route_guide/route_guide_grpc_pb.php
deleted file mode 100644
index e7a9cd39cd..0000000000
--- a/examples/php/route_guide/route_guide_grpc_pb.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-// GENERATED CODE -- DO NOT EDIT!
-
-// Original file comments:
-// 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.
-//
-namespace Routeguide {
-
- // Interface exported by the server.
- class RouteGuideClient extends \Grpc\BaseStub {
-
- /**
- * @param string $hostname hostname
- * @param array $opts channel options
- * @param Grpc\Channel $channel (optional) re-use channel object
- */
- public function __construct($hostname, $opts, $channel = null) {
- parent::__construct($hostname, $opts, $channel);
- }
-
- /**
- * A simple RPC.
- *
- * Obtains the feature at a given position.
- *
- * A feature with an empty name is returned if there's no feature at the given
- * position.
- * @param \Routeguide\Point $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- */
- public function GetFeature(\Routeguide\Point $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/routeguide.RouteGuide/GetFeature',
- $argument,
- ['\Routeguide\Feature', 'decode'],
- $metadata, $options);
- }
-
- /**
- * A server-to-client streaming RPC.
- *
- * Obtains the Features available within the given Rectangle. Results are
- * streamed rather than returned at once (e.g. in a response message with a
- * repeated field), as the rectangle may cover a large area and contain a
- * huge number of features.
- * @param \Routeguide\Rectangle $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- */
- public function ListFeatures(\Routeguide\Rectangle $argument,
- $metadata = [], $options = []) {
- return $this->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures',
- $argument,
- ['\Routeguide\Feature', 'decode'],
- $metadata, $options);
- }
-
- /**
- * A client-to-server streaming RPC.
- *
- * Accepts a stream of Points on a route being traversed, returning a
- * RouteSummary when traversal is completed.
- * @param array $metadata metadata
- * @param array $options call options
- */
- public function RecordRoute($metadata = [], $options = []) {
- return $this->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute',
- ['\Routeguide\RouteSummary','decode'],
- $metadata, $options);
- }
-
- /**
- * A Bidirectional streaming RPC.
- *
- * Accepts a stream of RouteNotes sent while a route is being traversed,
- * while receiving other RouteNotes (e.g. from other users).
- * @param array $metadata metadata
- * @param array $options call options
- */
- public function RouteChat($metadata = [], $options = []) {
- return $this->_bidiRequest('/routeguide.RouteGuide/RouteChat',
- ['\Routeguide\RouteNote','decode'],
- $metadata, $options);
- }
-
- }
-
-}
diff --git a/tools/run_tests/helper_scripts/pre_build_node.sh b/examples/php/route_guide/route_guide_proto_gen.sh
index d4702b8705..bfd7cdb725 100755
--- a/tools/run_tests/helper_scripts/pre_build_node.sh
+++ b/examples/php/route_guide/route_guide_proto_gen.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,15 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-NODE_VERSION=$1
-source ~/.nvm/nvm.sh
-
-nvm install $NODE_VERSION
-set -ex
-
-export GRPC_CONFIG=${CONFIG:-opt}
-
-npm update --prefer-online
-
-npm install node-gyp-install
-./node_modules/.bin/node-gyp-install
+protoc --proto_path=./../../protos --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=./../../../bins/opt/grpc_php_plugin ./../../protos/route_guide.proto
diff --git a/examples/python/helloworld/greeter_client.py b/examples/python/helloworld/greeter_client.py
index d9b2bdfd07..a0aeb47bd7 100644
--- a/examples/python/helloworld/greeter_client.py
+++ b/examples/python/helloworld/greeter_client.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
@@ -23,11 +22,11 @@ import helloworld_pb2_grpc
def run():
- channel = grpc.insecure_channel('localhost:50051')
- stub = helloworld_pb2_grpc.GreeterStub(channel)
- response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
- print("Greeter client received: " + response.message)
+ channel = grpc.insecure_channel('localhost:50051')
+ stub = helloworld_pb2_grpc.GreeterStub(channel)
+ response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
+ print("Greeter client received: " + response.message)
if __name__ == '__main__':
- run()
+ run()
diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py
index be61695616..c355662ef8 100644
--- a/examples/python/helloworld/greeter_server.py
+++ b/examples/python/helloworld/greeter_server.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the GRPC helloworld.Greeter server."""
from concurrent import futures
@@ -27,20 +26,21 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24
class Greeter(helloworld_pb2_grpc.GreeterServicer):
- def SayHello(self, request, context):
- return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
+ def SayHello(self, request, context):
+ return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
def serve():
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
- helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
- server.add_insecure_port('[::]:50051')
- server.start()
- try:
- while True:
- time.sleep(_ONE_DAY_IN_SECONDS)
- except KeyboardInterrupt:
- server.stop(0)
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
+
if __name__ == '__main__':
- serve()
+ serve()
diff --git a/examples/python/helloworld/helloworld_pb2.py b/examples/python/helloworld/helloworld_pb2.py
index 6665b1f687..e18ab9acc7 100644
--- a/examples/python/helloworld/helloworld_pb2.py
+++ b/examples/python/helloworld/helloworld_pb2.py
@@ -21,7 +21,6 @@ DESCRIPTOR = _descriptor.FileDescriptor(
syntax='proto3',
serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3')
)
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
@@ -89,6 +88,7 @@ _HELLOREPLY = _descriptor.Descriptor(
DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST
DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict(
DESCRIPTOR = _HELLOREQUEST,
@@ -107,123 +107,28 @@ _sym_db.RegisterMessage(HelloReply)
DESCRIPTOR.has_options = True
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW'))
-try:
- # THESE ELEMENTS WILL BE DEPRECATED.
- # Please use the generated *_pb2_grpc.py files instead.
- import grpc
- from grpc.framework.common import cardinality
- from grpc.framework.interfaces.face import utilities as face_utilities
- from grpc.beta import implementations as beta_implementations
- from grpc.beta import interfaces as beta_interfaces
-
-
- class GreeterStub(object):
- """The greeting service definition.
- """
-
- def __init__(self, channel):
- """Constructor.
-
- Args:
- channel: A grpc.Channel.
- """
- self.SayHello = channel.unary_unary(
- '/helloworld.Greeter/SayHello',
- request_serializer=HelloRequest.SerializeToString,
- response_deserializer=HelloReply.FromString,
- )
-
-
- class GreeterServicer(object):
- """The greeting service definition.
- """
-
- def SayHello(self, request, context):
- """Sends a greeting
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
-
- def add_GreeterServicer_to_server(servicer, server):
- rpc_method_handlers = {
- 'SayHello': grpc.unary_unary_rpc_method_handler(
- servicer.SayHello,
- request_deserializer=HelloRequest.FromString,
- response_serializer=HelloReply.SerializeToString,
- ),
- }
- generic_handler = grpc.method_handlers_generic_handler(
- 'helloworld.Greeter', rpc_method_handlers)
- server.add_generic_rpc_handlers((generic_handler,))
-
-
- class BetaGreeterServicer(object):
- """The Beta API is deprecated for 0.15.0 and later.
-
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This class was generated
- only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0."""
- """The greeting service definition.
- """
- def SayHello(self, request, context):
- """Sends a greeting
- """
- context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
-
-
- class BetaGreeterStub(object):
- """The Beta API is deprecated for 0.15.0 and later.
-
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This class was generated
- only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0."""
- """The greeting service definition.
- """
- def SayHello(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
- """Sends a greeting
- """
- raise NotImplementedError()
- SayHello.future = None
-
-
- def beta_create_Greeter_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
- """The Beta API is deprecated for 0.15.0 and later.
-
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This function was
- generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"""
- request_deserializers = {
- ('helloworld.Greeter', 'SayHello'): HelloRequest.FromString,
- }
- response_serializers = {
- ('helloworld.Greeter', 'SayHello'): HelloReply.SerializeToString,
- }
- method_implementations = {
- ('helloworld.Greeter', 'SayHello'): face_utilities.unary_unary_inline(servicer.SayHello),
- }
- server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
- return beta_implementations.server(method_implementations, options=server_options)
-
-
- def beta_create_Greeter_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
- """The Beta API is deprecated for 0.15.0 and later.
-
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This function was
- generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"""
- request_serializers = {
- ('helloworld.Greeter', 'SayHello'): HelloRequest.SerializeToString,
- }
- response_deserializers = {
- ('helloworld.Greeter', 'SayHello'): HelloReply.FromString,
- }
- cardinalities = {
- 'SayHello': cardinality.Cardinality.UNARY_UNARY,
- }
- stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size)
- return beta_implementations.dynamic_stub(channel, 'helloworld.Greeter', cardinalities, options=stub_options)
-except ImportError:
- pass
+
+_GREETER = _descriptor.ServiceDescriptor(
+ name='Greeter',
+ full_name='helloworld.Greeter',
+ file=DESCRIPTOR,
+ index=0,
+ options=None,
+ serialized_start=93,
+ serialized_end=166,
+ methods=[
+ _descriptor.MethodDescriptor(
+ name='SayHello',
+ full_name='helloworld.Greeter.SayHello',
+ index=0,
+ containing_service=None,
+ input_type=_HELLOREQUEST,
+ output_type=_HELLOREPLY,
+ options=None,
+ ),
+])
+_sym_db.RegisterServiceDescriptor(_GREETER)
+
+DESCRIPTOR.services_by_name['Greeter'] = _GREETER
+
# @@protoc_insertion_point(module_scope)
diff --git a/examples/python/helloworld/helloworld_pb2_grpc.py b/examples/python/helloworld/helloworld_pb2_grpc.py
index 682dc36cd8..18e07d1679 100644
--- a/examples/python/helloworld/helloworld_pb2_grpc.py
+++ b/examples/python/helloworld/helloworld_pb2_grpc.py
@@ -1,6 +1,5 @@
+# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
-from grpc.framework.common import cardinality
-from grpc.framework.interfaces.face import utilities as face_utilities
import helloworld_pb2 as helloworld__pb2
diff --git a/examples/python/interceptors/default_value/default_value_client_interceptor.py b/examples/python/interceptors/default_value/default_value_client_interceptor.py
new file mode 100644
index 0000000000..c549f2b861
--- /dev/null
+++ b/examples/python/interceptors/default_value/default_value_client_interceptor.py
@@ -0,0 +1,68 @@
+# 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.
+"""Interceptor that adds headers to outgoing requests."""
+
+import collections
+
+import grpc
+
+
+class _ConcreteValue(grpc.Future):
+
+ def __init__(self, result):
+ self._result = result
+
+ def cancel(self):
+ return False
+
+ def cancelled(self):
+ return False
+
+ def running(self):
+ return False
+
+ def done(self):
+ return True
+
+ def result(self, timeout=None):
+ return self._result
+
+ def exception(self, timeout=None):
+ return None
+
+ def traceback(self, timeout=None):
+ return None
+
+ def add_done_callback(self, fn):
+ fn(self._result)
+
+
+class DefaultValueClientInterceptor(grpc.UnaryUnaryClientInterceptor,
+ grpc.StreamUnaryClientInterceptor):
+
+ def __init__(self, value):
+ self._default = _ConcreteValue(value)
+
+ def _intercept_call(self, continuation, client_call_details,
+ request_or_iterator):
+ response = continuation(client_call_details, request_or_iterator)
+ return self._default if response.exception() else response
+
+ def intercept_unary_unary(self, continuation, client_call_details, request):
+ return self._intercept_call(continuation, client_call_details, request)
+
+ def intercept_stream_unary(self, continuation, client_call_details,
+ request_iterator):
+ return self._intercept_call(continuation, client_call_details,
+ request_iterator)
diff --git a/examples/python/interceptors/default_value/greeter_client.py b/examples/python/interceptors/default_value/greeter_client.py
new file mode 100644
index 0000000000..aba7571d83
--- /dev/null
+++ b/examples/python/interceptors/default_value/greeter_client.py
@@ -0,0 +1,38 @@
+# 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.
+"""The Python implementation of the gRPC helloworld.Greeter client."""
+
+from __future__ import print_function
+
+import grpc
+
+import helloworld_pb2
+import helloworld_pb2_grpc
+import default_value_client_interceptor
+
+
+def run():
+ default_value = helloworld_pb2.HelloReply(
+ message='Hello from your local interceptor!')
+ default_value_interceptor = default_value_client_interceptor.DefaultValueClientInterceptor(
+ default_value)
+ channel = grpc.insecure_channel('localhost:50051')
+ channel = grpc.intercept_channel(channel, default_value_interceptor)
+ stub = helloworld_pb2_grpc.GreeterStub(channel)
+ response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
+ print("Greeter client received: " + response.message)
+
+
+if __name__ == '__main__':
+ run()
diff --git a/examples/python/interceptors/default_value/helloworld_pb2.py b/examples/python/interceptors/default_value/helloworld_pb2.py
new file mode 100644
index 0000000000..e18ab9acc7
--- /dev/null
+++ b/examples/python/interceptors/default_value/helloworld_pb2.py
@@ -0,0 +1,134 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: helloworld.proto
+
+import sys
+_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+ name='helloworld.proto',
+ package='helloworld',
+ syntax='proto3',
+ serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3')
+)
+
+
+
+
+_HELLOREQUEST = _descriptor.Descriptor(
+ name='HelloRequest',
+ full_name='helloworld.HelloRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='name', full_name='helloworld.HelloRequest.name', index=0,
+ number=1, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=_b("").decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=32,
+ serialized_end=60,
+)
+
+
+_HELLOREPLY = _descriptor.Descriptor(
+ name='HelloReply',
+ full_name='helloworld.HelloReply',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='message', full_name='helloworld.HelloReply.message', index=0,
+ number=1, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=_b("").decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=62,
+ serialized_end=91,
+)
+
+DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST
+DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict(
+ DESCRIPTOR = _HELLOREQUEST,
+ __module__ = 'helloworld_pb2'
+ # @@protoc_insertion_point(class_scope:helloworld.HelloRequest)
+ ))
+_sym_db.RegisterMessage(HelloRequest)
+
+HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict(
+ DESCRIPTOR = _HELLOREPLY,
+ __module__ = 'helloworld_pb2'
+ # @@protoc_insertion_point(class_scope:helloworld.HelloReply)
+ ))
+_sym_db.RegisterMessage(HelloReply)
+
+
+DESCRIPTOR.has_options = True
+DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW'))
+
+_GREETER = _descriptor.ServiceDescriptor(
+ name='Greeter',
+ full_name='helloworld.Greeter',
+ file=DESCRIPTOR,
+ index=0,
+ options=None,
+ serialized_start=93,
+ serialized_end=166,
+ methods=[
+ _descriptor.MethodDescriptor(
+ name='SayHello',
+ full_name='helloworld.Greeter.SayHello',
+ index=0,
+ containing_service=None,
+ input_type=_HELLOREQUEST,
+ output_type=_HELLOREPLY,
+ options=None,
+ ),
+])
+_sym_db.RegisterServiceDescriptor(_GREETER)
+
+DESCRIPTOR.services_by_name['Greeter'] = _GREETER
+
+# @@protoc_insertion_point(module_scope)
diff --git a/examples/python/interceptors/default_value/helloworld_pb2_grpc.py b/examples/python/interceptors/default_value/helloworld_pb2_grpc.py
new file mode 100644
index 0000000000..18e07d1679
--- /dev/null
+++ b/examples/python/interceptors/default_value/helloworld_pb2_grpc.py
@@ -0,0 +1,46 @@
+# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
+import grpc
+
+import helloworld_pb2 as helloworld__pb2
+
+
+class GreeterStub(object):
+ """The greeting service definition.
+ """
+
+ def __init__(self, channel):
+ """Constructor.
+
+ Args:
+ channel: A grpc.Channel.
+ """
+ self.SayHello = channel.unary_unary(
+ '/helloworld.Greeter/SayHello',
+ request_serializer=helloworld__pb2.HelloRequest.SerializeToString,
+ response_deserializer=helloworld__pb2.HelloReply.FromString,
+ )
+
+
+class GreeterServicer(object):
+ """The greeting service definition.
+ """
+
+ def SayHello(self, request, context):
+ """Sends a greeting
+ """
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
+
+def add_GreeterServicer_to_server(servicer, server):
+ rpc_method_handlers = {
+ 'SayHello': grpc.unary_unary_rpc_method_handler(
+ servicer.SayHello,
+ request_deserializer=helloworld__pb2.HelloRequest.FromString,
+ response_serializer=helloworld__pb2.HelloReply.SerializeToString,
+ ),
+ }
+ generic_handler = grpc.method_handlers_generic_handler(
+ 'helloworld.Greeter', rpc_method_handlers)
+ server.add_generic_rpc_handlers((generic_handler,))
diff --git a/examples/python/interceptors/headers/generic_client_interceptor.py b/examples/python/interceptors/headers/generic_client_interceptor.py
new file mode 100644
index 0000000000..30b0755aaf
--- /dev/null
+++ b/examples/python/interceptors/headers/generic_client_interceptor.py
@@ -0,0 +1,55 @@
+# 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.
+"""Base class for interceptors that operate on all RPC types."""
+
+import grpc
+
+
+class _GenericClientInterceptor(
+ grpc.UnaryUnaryClientInterceptor, grpc.UnaryStreamClientInterceptor,
+ grpc.StreamUnaryClientInterceptor, grpc.StreamStreamClientInterceptor):
+
+ def __init__(self, interceptor_function):
+ self._fn = interceptor_function
+
+ def intercept_unary_unary(self, continuation, client_call_details, request):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, iter((request,)), False, False)
+ response = continuation(new_details, next(new_request_iterator))
+ return postprocess(response) if postprocess else response
+
+ def intercept_unary_stream(self, continuation, client_call_details,
+ request):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, iter((request,)), False, True)
+ response_it = continuation(new_details, new_request_iterator)
+ return postprocess(response_it) if postprocess else response_it
+
+ def intercept_stream_unary(self, continuation, client_call_details,
+ request_iterator):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, request_iterator, True, False)
+ response = continuation(new_details, next(new_request_iterator))
+ return postprocess(response) if postprocess else response
+
+ def intercept_stream_stream(self, continuation, client_call_details,
+ request_iterator):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, request_iterator, True, True)
+ response_it = continuation(new_details, new_request_iterator)
+ return postprocess(response_it) if postprocess else response_it
+
+
+def create(intercept_call):
+ return _GenericClientInterceptor(intercept_call)
diff --git a/examples/python/interceptors/headers/greeter_client.py b/examples/python/interceptors/headers/greeter_client.py
new file mode 100644
index 0000000000..2b0dd3e177
--- /dev/null
+++ b/examples/python/interceptors/headers/greeter_client.py
@@ -0,0 +1,36 @@
+# 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.
+"""The Python implementation of the GRPC helloworld.Greeter client."""
+
+from __future__ import print_function
+
+import grpc
+
+import helloworld_pb2
+import helloworld_pb2_grpc
+import header_manipulator_client_interceptor
+
+
+def run():
+ header_adder_interceptor = header_manipulator_client_interceptor.header_adder_interceptor(
+ 'one-time-password', '42')
+ channel = grpc.insecure_channel('localhost:50051')
+ channel = grpc.intercept_channel(channel, header_adder_interceptor)
+ stub = helloworld_pb2_grpc.GreeterStub(channel)
+ response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
+ print("Greeter client received: " + response.message)
+
+
+if __name__ == '__main__':
+ run()
diff --git a/examples/python/interceptors/headers/greeter_server.py b/examples/python/interceptors/headers/greeter_server.py
new file mode 100644
index 0000000000..01968609b5
--- /dev/null
+++ b/examples/python/interceptors/headers/greeter_server.py
@@ -0,0 +1,52 @@
+# 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.
+"""The Python implementation of the GRPC helloworld.Greeter server."""
+
+from concurrent import futures
+import time
+
+import grpc
+
+import helloworld_pb2
+import helloworld_pb2_grpc
+from request_header_validator_interceptor import RequestHeaderValidatorInterceptor
+
+_ONE_DAY_IN_SECONDS = 60 * 60 * 24
+
+
+class Greeter(helloworld_pb2_grpc.GreeterServicer):
+
+ def SayHello(self, request, context):
+ return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
+
+
+def serve():
+ header_validator = RequestHeaderValidatorInterceptor(
+ 'one-time-password', '42', grpc.StatusCode.UNAUTHENTICATED,
+ 'Access denied!')
+ server = grpc.server(
+ futures.ThreadPoolExecutor(max_workers=10),
+ interceptors=(header_validator,))
+ helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
+
+
+if __name__ == '__main__':
+ serve()
diff --git a/examples/python/interceptors/headers/header_manipulator_client_interceptor.py b/examples/python/interceptors/headers/header_manipulator_client_interceptor.py
new file mode 100644
index 0000000000..89b1bef05f
--- /dev/null
+++ b/examples/python/interceptors/headers/header_manipulator_client_interceptor.py
@@ -0,0 +1,46 @@
+# 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.
+"""Interceptor that adds headers to outgoing requests."""
+
+import collections
+
+import grpc
+import generic_client_interceptor
+
+
+class _ClientCallDetails(
+ collections.namedtuple(
+ '_ClientCallDetails',
+ ('method', 'timeout', 'metadata', 'credentials')),
+ grpc.ClientCallDetails):
+ pass
+
+
+def header_adder_interceptor(header, value):
+
+ def intercept_call(client_call_details, request_iterator, request_streaming,
+ response_streaming):
+ metadata = []
+ if client_call_details.metadata is not None:
+ metadata = list(client_call_details.metadata)
+ metadata.append((
+ header,
+ value,
+ ))
+ client_call_details = _ClientCallDetails(
+ client_call_details.method, client_call_details.timeout, metadata,
+ client_call_details.credentials)
+ return client_call_details, request_iterator, None
+
+ return generic_client_interceptor.create(intercept_call)
diff --git a/examples/python/interceptors/headers/helloworld_pb2.py b/examples/python/interceptors/headers/helloworld_pb2.py
new file mode 100644
index 0000000000..e18ab9acc7
--- /dev/null
+++ b/examples/python/interceptors/headers/helloworld_pb2.py
@@ -0,0 +1,134 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: helloworld.proto
+
+import sys
+_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+ name='helloworld.proto',
+ package='helloworld',
+ syntax='proto3',
+ serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3')
+)
+
+
+
+
+_HELLOREQUEST = _descriptor.Descriptor(
+ name='HelloRequest',
+ full_name='helloworld.HelloRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='name', full_name='helloworld.HelloRequest.name', index=0,
+ number=1, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=_b("").decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=32,
+ serialized_end=60,
+)
+
+
+_HELLOREPLY = _descriptor.Descriptor(
+ name='HelloReply',
+ full_name='helloworld.HelloReply',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='message', full_name='helloworld.HelloReply.message', index=0,
+ number=1, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=_b("").decode('utf-8'),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=62,
+ serialized_end=91,
+)
+
+DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST
+DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict(
+ DESCRIPTOR = _HELLOREQUEST,
+ __module__ = 'helloworld_pb2'
+ # @@protoc_insertion_point(class_scope:helloworld.HelloRequest)
+ ))
+_sym_db.RegisterMessage(HelloRequest)
+
+HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict(
+ DESCRIPTOR = _HELLOREPLY,
+ __module__ = 'helloworld_pb2'
+ # @@protoc_insertion_point(class_scope:helloworld.HelloReply)
+ ))
+_sym_db.RegisterMessage(HelloReply)
+
+
+DESCRIPTOR.has_options = True
+DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW'))
+
+_GREETER = _descriptor.ServiceDescriptor(
+ name='Greeter',
+ full_name='helloworld.Greeter',
+ file=DESCRIPTOR,
+ index=0,
+ options=None,
+ serialized_start=93,
+ serialized_end=166,
+ methods=[
+ _descriptor.MethodDescriptor(
+ name='SayHello',
+ full_name='helloworld.Greeter.SayHello',
+ index=0,
+ containing_service=None,
+ input_type=_HELLOREQUEST,
+ output_type=_HELLOREPLY,
+ options=None,
+ ),
+])
+_sym_db.RegisterServiceDescriptor(_GREETER)
+
+DESCRIPTOR.services_by_name['Greeter'] = _GREETER
+
+# @@protoc_insertion_point(module_scope)
diff --git a/examples/python/interceptors/headers/helloworld_pb2_grpc.py b/examples/python/interceptors/headers/helloworld_pb2_grpc.py
new file mode 100644
index 0000000000..18e07d1679
--- /dev/null
+++ b/examples/python/interceptors/headers/helloworld_pb2_grpc.py
@@ -0,0 +1,46 @@
+# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
+import grpc
+
+import helloworld_pb2 as helloworld__pb2
+
+
+class GreeterStub(object):
+ """The greeting service definition.
+ """
+
+ def __init__(self, channel):
+ """Constructor.
+
+ Args:
+ channel: A grpc.Channel.
+ """
+ self.SayHello = channel.unary_unary(
+ '/helloworld.Greeter/SayHello',
+ request_serializer=helloworld__pb2.HelloRequest.SerializeToString,
+ response_deserializer=helloworld__pb2.HelloReply.FromString,
+ )
+
+
+class GreeterServicer(object):
+ """The greeting service definition.
+ """
+
+ def SayHello(self, request, context):
+ """Sends a greeting
+ """
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
+
+def add_GreeterServicer_to_server(servicer, server):
+ rpc_method_handlers = {
+ 'SayHello': grpc.unary_unary_rpc_method_handler(
+ servicer.SayHello,
+ request_deserializer=helloworld__pb2.HelloRequest.FromString,
+ response_serializer=helloworld__pb2.HelloReply.SerializeToString,
+ ),
+ }
+ generic_handler = grpc.method_handlers_generic_handler(
+ 'helloworld.Greeter', rpc_method_handlers)
+ server.add_generic_rpc_handlers((generic_handler,))
diff --git a/examples/python/interceptors/headers/request_header_validator_interceptor.py b/examples/python/interceptors/headers/request_header_validator_interceptor.py
new file mode 100644
index 0000000000..95af4177ba
--- /dev/null
+++ b/examples/python/interceptors/headers/request_header_validator_interceptor.py
@@ -0,0 +1,39 @@
+# 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.
+"""Interceptor that ensures a specific header is present."""
+
+import grpc
+
+
+def _unary_unary_rpc_terminator(code, details):
+
+ def terminate(ignored_request, context):
+ context.abort(code, details)
+
+ return grpc.unary_unary_rpc_method_handler(terminate)
+
+
+class RequestHeaderValidatorInterceptor(grpc.ServerInterceptor):
+
+ def __init__(self, header, value, code, details):
+ self._header = header
+ self._value = value
+ self._terminator = _unary_unary_rpc_terminator(code, details)
+
+ def intercept_service(self, continuation, handler_call_details):
+ if (self._header,
+ self._value) in handler_call_details.invocation_metadata:
+ return continuation(handler_call_details)
+ else:
+ return self._terminator
diff --git a/examples/python/multiplex/multiplex_client.py b/examples/python/multiplex/multiplex_client.py
index c8c700afcd..9baa10247d 100644
--- a/examples/python/multiplex/multiplex_client.py
+++ b/examples/python/multiplex/multiplex_client.py
@@ -11,7 +11,6 @@
# 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.
-
"""A client that makes both Greeter and RouteGuide RPCs."""
from __future__ import print_function
@@ -29,98 +28,99 @@ import route_guide_resources
def make_route_note(message, latitude, longitude):
- return route_guide_pb2.RouteNote(
- message=message,
- location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
+ return route_guide_pb2.RouteNote(
+ message=message,
+ location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
def guide_get_one_feature(route_guide_stub, point):
- feature = route_guide_stub.GetFeature(point)
- if not feature.location:
- print("Server returned incomplete feature")
- return
+ feature = route_guide_stub.GetFeature(point)
+ if not feature.location:
+ print("Server returned incomplete feature")
+ return
- if feature.name:
- print("Feature called %s at %s" % (feature.name, feature.location))
- else:
- print("Found no feature at %s" % feature.location)
+ if feature.name:
+ print("Feature called %s at %s" % (feature.name, feature.location))
+ else:
+ print("Found no feature at %s" % feature.location)
def guide_get_feature(route_guide_stub):
- guide_get_one_feature(
- route_guide_stub,
- route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
- guide_get_one_feature(
- route_guide_stub, route_guide_pb2.Point(latitude=0, longitude=0))
+ guide_get_one_feature(route_guide_stub,
+ route_guide_pb2.Point(
+ latitude=409146138, longitude=-746188906))
+ guide_get_one_feature(route_guide_stub,
+ route_guide_pb2.Point(latitude=0, longitude=0))
def guide_list_features(route_guide_stub):
- rectangle = route_guide_pb2.Rectangle(
- lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
- hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
- print("Looking for features between 40, -75 and 42, -73")
+ rectangle = route_guide_pb2.Rectangle(
+ lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
+ hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
+ print("Looking for features between 40, -75 and 42, -73")
- features = route_guide_stub.ListFeatures(rectangle)
+ features = route_guide_stub.ListFeatures(rectangle)
- for feature in features:
- print("Feature called %s at %s" % (feature.name, feature.location))
+ for feature in features:
+ print("Feature called %s at %s" % (feature.name, feature.location))
def generate_route(feature_list):
- for _ in range(0, 10):
- random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
- print("Visiting point %s" % random_feature.location)
- yield random_feature.location
- time.sleep(random.uniform(0.5, 1.5))
+ for _ in range(0, 10):
+ random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
+ print("Visiting point %s" % random_feature.location)
+ yield random_feature.location
+ time.sleep(random.uniform(0.5, 1.5))
def guide_record_route(route_guide_stub):
- feature_list = route_guide_resources.read_route_guide_database()
+ feature_list = route_guide_resources.read_route_guide_database()
- route_iterator = generate_route(feature_list)
- route_summary = route_guide_stub.RecordRoute(route_iterator)
- print("Finished trip with %s points " % route_summary.point_count)
- print("Passed %s features " % route_summary.feature_count)
- print("Travelled %s meters " % route_summary.distance)
- print("It took %s seconds " % route_summary.elapsed_time)
+ route_iterator = generate_route(feature_list)
+ route_summary = route_guide_stub.RecordRoute(route_iterator)
+ print("Finished trip with %s points " % route_summary.point_count)
+ print("Passed %s features " % route_summary.feature_count)
+ print("Travelled %s meters " % route_summary.distance)
+ print("It took %s seconds " % route_summary.elapsed_time)
def generate_messages():
- messages = [
- make_route_note("First message", 0, 0),
- make_route_note("Second message", 0, 1),
- make_route_note("Third message", 1, 0),
- make_route_note("Fourth message", 0, 0),
- make_route_note("Fifth message", 1, 0),
- ]
- for msg in messages:
- print("Sending %s at %s" % (msg.message, msg.location))
- yield msg
- time.sleep(random.uniform(0.5, 1.0))
+ messages = [
+ make_route_note("First message", 0, 0),
+ make_route_note("Second message", 0, 1),
+ make_route_note("Third message", 1, 0),
+ make_route_note("Fourth message", 0, 0),
+ make_route_note("Fifth message", 1, 0),
+ ]
+ for msg in messages:
+ print("Sending %s at %s" % (msg.message, msg.location))
+ yield msg
+ time.sleep(random.uniform(0.5, 1.0))
def guide_route_chat(route_guide_stub):
- responses = route_guide_stub.RouteChat(generate_messages())
- for response in responses:
- print("Received message %s at %s" % (response.message, response.location))
+ responses = route_guide_stub.RouteChat(generate_messages())
+ for response in responses:
+ print("Received message %s at %s" % (response.message,
+ response.location))
def run():
- channel = grpc.insecure_channel('localhost:50051')
- greeter_stub = helloworld_pb2_grpc.GreeterStub(channel)
- route_guide_stub = route_guide_pb2_grpc.RouteGuideStub(channel)
- greeter_response = greeter_stub.SayHello(
- helloworld_pb2.HelloRequest(name='you'))
- print("Greeter client received: " + greeter_response.message)
- print("-------------- GetFeature --------------")
- guide_get_feature(route_guide_stub)
- print("-------------- ListFeatures --------------")
- guide_list_features(route_guide_stub)
- print("-------------- RecordRoute --------------")
- guide_record_route(route_guide_stub)
- print("-------------- RouteChat --------------")
- guide_route_chat(route_guide_stub)
+ channel = grpc.insecure_channel('localhost:50051')
+ greeter_stub = helloworld_pb2_grpc.GreeterStub(channel)
+ route_guide_stub = route_guide_pb2_grpc.RouteGuideStub(channel)
+ greeter_response = greeter_stub.SayHello(
+ helloworld_pb2.HelloRequest(name='you'))
+ print("Greeter client received: " + greeter_response.message)
+ print("-------------- GetFeature --------------")
+ guide_get_feature(route_guide_stub)
+ print("-------------- ListFeatures --------------")
+ guide_list_features(route_guide_stub)
+ print("-------------- RecordRoute --------------")
+ guide_record_route(route_guide_stub)
+ print("-------------- RouteChat --------------")
+ guide_route_chat(route_guide_stub)
if __name__ == '__main__':
- run()
+ run()
diff --git a/examples/python/multiplex/multiplex_server.py b/examples/python/multiplex/multiplex_server.py
index 9a6e835bed..70dec3c939 100644
--- a/examples/python/multiplex/multiplex_server.py
+++ b/examples/python/multiplex/multiplex_server.py
@@ -11,7 +11,6 @@
# 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.
-
"""A gRPC server servicing both Greeter and RouteGuide RPCs."""
from concurrent import futures
@@ -30,107 +29,111 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24
def _get_feature(feature_db, point):
- """Returns Feature at given location or None."""
- for feature in feature_db:
- if feature.location == point:
- return feature
- return None
+ """Returns Feature at given location or None."""
+ for feature in feature_db:
+ if feature.location == point:
+ return feature
+ return None
def _get_distance(start, end):
- """Distance between two points."""
- coord_factor = 10000000.0
- lat_1 = start.latitude / coord_factor
- lat_2 = end.latitude / coord_factor
- lon_1 = start.longitude / coord_factor
- lon_2 = end.longitude / coord_factor
- lat_rad_1 = math.radians(lat_1)
- lat_rad_2 = math.radians(lat_2)
- delta_lat_rad = math.radians(lat_2 - lat_1)
- delta_lon_rad = math.radians(lon_2 - lon_1)
-
- a = (pow(math.sin(delta_lat_rad / 2), 2) +
- (math.cos(lat_rad_1) * math.cos(lat_rad_2) *
- pow(math.sin(delta_lon_rad / 2), 2)))
- c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
- R = 6371000; # metres
- return R * c;
+ """Distance between two points."""
+ coord_factor = 10000000.0
+ lat_1 = start.latitude / coord_factor
+ lat_2 = end.latitude / coord_factor
+ lon_1 = start.longitude / coord_factor
+ lon_2 = end.longitude / coord_factor
+ lat_rad_1 = math.radians(lat_1)
+ lat_rad_2 = math.radians(lat_2)
+ delta_lat_rad = math.radians(lat_2 - lat_1)
+ delta_lon_rad = math.radians(lon_2 - lon_1)
+
+ a = (pow(math.sin(delta_lat_rad / 2), 2) +
+ (math.cos(lat_rad_1) * math.cos(lat_rad_2) * pow(
+ math.sin(delta_lon_rad / 2), 2)))
+ c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
+ R = 6371000
+ # metres
+ return R * c
class _GreeterServicer(helloworld_pb2_grpc.GreeterServicer):
- def SayHello(self, request, context):
- return helloworld_pb2.HelloReply(message='Hello, {}!'.format(request.name))
+ def SayHello(self, request, context):
+ return helloworld_pb2.HelloReply(
+ message='Hello, {}!'.format(request.name))
class _RouteGuideServicer(route_guide_pb2_grpc.RouteGuideServicer):
- """Provides methods that implement functionality of route guide server."""
-
- def __init__(self):
- self.db = route_guide_resources.read_route_guide_database()
-
- def GetFeature(self, request, context):
- feature = _get_feature(self.db, request)
- if feature is None:
- return route_guide_pb2.Feature(name="", location=request)
- else:
- return feature
-
- def ListFeatures(self, request, context):
- left = min(request.lo.longitude, request.hi.longitude)
- right = max(request.lo.longitude, request.hi.longitude)
- top = max(request.lo.latitude, request.hi.latitude)
- bottom = min(request.lo.latitude, request.hi.latitude)
- for feature in self.db:
- if (feature.location.longitude >= left and
- feature.location.longitude <= right and
- feature.location.latitude >= bottom and
- feature.location.latitude <= top):
- yield feature
-
- def RecordRoute(self, request_iterator, context):
- point_count = 0
- feature_count = 0
- distance = 0.0
- prev_point = None
-
- start_time = time.time()
- for point in request_iterator:
- point_count += 1
- if _get_feature(self.db, point):
- feature_count += 1
- if prev_point:
- distance += _get_distance(prev_point, point)
- prev_point = point
-
- elapsed_time = time.time() - start_time
- return route_guide_pb2.RouteSummary(point_count=point_count,
- feature_count=feature_count,
- distance=int(distance),
- elapsed_time=int(elapsed_time))
-
- def RouteChat(self, request_iterator, context):
- prev_notes = []
- for new_note in request_iterator:
- for prev_note in prev_notes:
- if prev_note.location == new_note.location:
- yield prev_note
- prev_notes.append(new_note)
+ """Provides methods that implement functionality of route guide server."""
+
+ def __init__(self):
+ self.db = route_guide_resources.read_route_guide_database()
+
+ def GetFeature(self, request, context):
+ feature = _get_feature(self.db, request)
+ if feature is None:
+ return route_guide_pb2.Feature(name="", location=request)
+ else:
+ return feature
+
+ def ListFeatures(self, request, context):
+ left = min(request.lo.longitude, request.hi.longitude)
+ right = max(request.lo.longitude, request.hi.longitude)
+ top = max(request.lo.latitude, request.hi.latitude)
+ bottom = min(request.lo.latitude, request.hi.latitude)
+ for feature in self.db:
+ if (feature.location.longitude >= left and
+ feature.location.longitude <= right and
+ feature.location.latitude >= bottom and
+ feature.location.latitude <= top):
+ yield feature
+
+ def RecordRoute(self, request_iterator, context):
+ point_count = 0
+ feature_count = 0
+ distance = 0.0
+ prev_point = None
+
+ start_time = time.time()
+ for point in request_iterator:
+ point_count += 1
+ if _get_feature(self.db, point):
+ feature_count += 1
+ if prev_point:
+ distance += _get_distance(prev_point, point)
+ prev_point = point
+
+ elapsed_time = time.time() - start_time
+ return route_guide_pb2.RouteSummary(
+ point_count=point_count,
+ feature_count=feature_count,
+ distance=int(distance),
+ elapsed_time=int(elapsed_time))
+
+ def RouteChat(self, request_iterator, context):
+ prev_notes = []
+ for new_note in request_iterator:
+ for prev_note in prev_notes:
+ if prev_note.location == new_note.location:
+ yield prev_note
+ prev_notes.append(new_note)
def serve():
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
- helloworld_pb2_grpc.add_GreeterServicer_to_server(_GreeterServicer(), server)
- route_guide_pb2_grpc.add_RouteGuideServicer_to_server(
- _RouteGuideServicer(), server)
- server.add_insecure_port('[::]:50051')
- server.start()
- try:
- while True:
- time.sleep(_ONE_DAY_IN_SECONDS)
- except KeyboardInterrupt:
- server.stop(0)
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ helloworld_pb2_grpc.add_GreeterServicer_to_server(_GreeterServicer(),
+ server)
+ route_guide_pb2_grpc.add_RouteGuideServicer_to_server(
+ _RouteGuideServicer(), server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
if __name__ == '__main__':
- serve()
+ serve()
diff --git a/examples/python/multiplex/route_guide_resources.py b/examples/python/multiplex/route_guide_resources.py
index 0887863660..ace85d6f9d 100644
--- a/examples/python/multiplex/route_guide_resources.py
+++ b/examples/python/multiplex/route_guide_resources.py
@@ -11,7 +11,6 @@
# 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.
-
"""Common resources used in the gRPC route guide example."""
import json
@@ -20,19 +19,19 @@ import route_guide_pb2
def read_route_guide_database():
- """Reads the route guide database.
+ """Reads the route guide database.
Returns:
The full contents of the route guide database as a sequence of
route_guide_pb2.Features.
"""
- feature_list = []
- with open("route_guide_db.json") as route_guide_db_file:
- for item in json.load(route_guide_db_file):
- feature = route_guide_pb2.Feature(
- name=item["name"],
- location=route_guide_pb2.Point(
- latitude=item["location"]["latitude"],
- longitude=item["location"]["longitude"]))
- feature_list.append(feature)
- return feature_list
+ feature_list = []
+ with open("route_guide_db.json") as route_guide_db_file:
+ for item in json.load(route_guide_db_file):
+ feature = route_guide_pb2.Feature(
+ name=item["name"],
+ location=route_guide_pb2.Point(
+ latitude=item["location"]["latitude"],
+ longitude=item["location"]["longitude"]))
+ feature_list.append(feature)
+ return feature_list
diff --git a/examples/python/multiplex/run_codegen.py b/examples/python/multiplex/run_codegen.py
index f38d86cf43..be8915fe20 100644
--- a/examples/python/multiplex/run_codegen.py
+++ b/examples/python/multiplex/run_codegen.py
@@ -11,26 +11,21 @@
# 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.
-
"""Generates protocol messages and gRPC stubs."""
from grpc_tools import protoc
-protoc.main(
- (
- '',
- '-I../../protos',
- '--python_out=.',
- '--grpc_python_out=.',
- '../../protos/helloworld.proto',
- )
-)
-protoc.main(
- (
- '',
- '-I../../protos',
- '--python_out=.',
- '--grpc_python_out=.',
- '../../protos/route_guide.proto',
- )
-)
+protoc.main((
+ '',
+ '-I../../protos',
+ '--python_out=.',
+ '--grpc_python_out=.',
+ '../../protos/helloworld.proto',
+))
+protoc.main((
+ '',
+ '-I../../protos',
+ '--python_out=.',
+ '--grpc_python_out=.',
+ '../../protos/route_guide.proto',
+))
diff --git a/examples/python/route_guide/route_guide_client.py b/examples/python/route_guide/route_guide_client.py
index 653f0d02c6..f2d4317ef1 100644
--- a/examples/python/route_guide/route_guide_client.py
+++ b/examples/python/route_guide/route_guide_client.py
@@ -11,13 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the gRPC route guide client."""
from __future__ import print_function
import random
-import time
import grpc
@@ -27,91 +25,92 @@ import route_guide_resources
def make_route_note(message, latitude, longitude):
- return route_guide_pb2.RouteNote(
- message=message,
- location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
+ return route_guide_pb2.RouteNote(
+ message=message,
+ location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
def guide_get_one_feature(stub, point):
- feature = stub.GetFeature(point)
- if not feature.location:
- print("Server returned incomplete feature")
- return
+ feature = stub.GetFeature(point)
+ if not feature.location:
+ print("Server returned incomplete feature")
+ return
- if feature.name:
- print("Feature called %s at %s" % (feature.name, feature.location))
- else:
- print("Found no feature at %s" % feature.location)
+ if feature.name:
+ print("Feature called %s at %s" % (feature.name, feature.location))
+ else:
+ print("Found no feature at %s" % feature.location)
def guide_get_feature(stub):
- guide_get_one_feature(stub, route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
- guide_get_one_feature(stub, route_guide_pb2.Point(latitude=0, longitude=0))
+ guide_get_one_feature(stub,
+ route_guide_pb2.Point(
+ latitude=409146138, longitude=-746188906))
+ guide_get_one_feature(stub, route_guide_pb2.Point(latitude=0, longitude=0))
def guide_list_features(stub):
- rectangle = route_guide_pb2.Rectangle(
- lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
- hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
- print("Looking for features between 40, -75 and 42, -73")
+ rectangle = route_guide_pb2.Rectangle(
+ lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
+ hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
+ print("Looking for features between 40, -75 and 42, -73")
- features = stub.ListFeatures(rectangle)
+ features = stub.ListFeatures(rectangle)
- for feature in features:
- print("Feature called %s at %s" % (feature.name, feature.location))
+ for feature in features:
+ print("Feature called %s at %s" % (feature.name, feature.location))
def generate_route(feature_list):
- for _ in range(0, 10):
- random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
- print("Visiting point %s" % random_feature.location)
- yield random_feature.location
- time.sleep(random.uniform(0.5, 1.5))
+ for _ in range(0, 10):
+ random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
+ print("Visiting point %s" % random_feature.location)
+ yield random_feature.location
def guide_record_route(stub):
- feature_list = route_guide_resources.read_route_guide_database()
+ feature_list = route_guide_resources.read_route_guide_database()
- route_iterator = generate_route(feature_list)
- route_summary = stub.RecordRoute(route_iterator)
- print("Finished trip with %s points " % route_summary.point_count)
- print("Passed %s features " % route_summary.feature_count)
- print("Travelled %s meters " % route_summary.distance)
- print("It took %s seconds " % route_summary.elapsed_time)
+ route_iterator = generate_route(feature_list)
+ route_summary = stub.RecordRoute(route_iterator)
+ print("Finished trip with %s points " % route_summary.point_count)
+ print("Passed %s features " % route_summary.feature_count)
+ print("Travelled %s meters " % route_summary.distance)
+ print("It took %s seconds " % route_summary.elapsed_time)
def generate_messages():
- messages = [
- make_route_note("First message", 0, 0),
- make_route_note("Second message", 0, 1),
- make_route_note("Third message", 1, 0),
- make_route_note("Fourth message", 0, 0),
- make_route_note("Fifth message", 1, 0),
- ]
- for msg in messages:
- print("Sending %s at %s" % (msg.message, msg.location))
- yield msg
- time.sleep(random.uniform(0.5, 1.0))
+ messages = [
+ make_route_note("First message", 0, 0),
+ make_route_note("Second message", 0, 1),
+ make_route_note("Third message", 1, 0),
+ make_route_note("Fourth message", 0, 0),
+ make_route_note("Fifth message", 1, 0),
+ ]
+ for msg in messages:
+ print("Sending %s at %s" % (msg.message, msg.location))
+ yield msg
def guide_route_chat(stub):
- responses = stub.RouteChat(generate_messages())
- for response in responses:
- print("Received message %s at %s" % (response.message, response.location))
+ responses = stub.RouteChat(generate_messages())
+ for response in responses:
+ print("Received message %s at %s" % (response.message,
+ response.location))
def run():
- channel = grpc.insecure_channel('localhost:50051')
- stub = route_guide_pb2_grpc.RouteGuideStub(channel)
- print("-------------- GetFeature --------------")
- guide_get_feature(stub)
- print("-------------- ListFeatures --------------")
- guide_list_features(stub)
- print("-------------- RecordRoute --------------")
- guide_record_route(stub)
- print("-------------- RouteChat --------------")
- guide_route_chat(stub)
+ channel = grpc.insecure_channel('localhost:50051')
+ stub = route_guide_pb2_grpc.RouteGuideStub(channel)
+ print("-------------- GetFeature --------------")
+ guide_get_feature(stub)
+ print("-------------- ListFeatures --------------")
+ guide_list_features(stub)
+ print("-------------- RecordRoute --------------")
+ guide_record_route(stub)
+ print("-------------- RouteChat --------------")
+ guide_route_chat(stub)
if __name__ == '__main__':
- run()
+ run()
diff --git a/examples/python/route_guide/route_guide_pb2.py b/examples/python/route_guide/route_guide_pb2.py
index e6775eb814..fbbc194a58 100644
--- a/examples/python/route_guide/route_guide_pb2.py
+++ b/examples/python/route_guide/route_guide_pb2.py
@@ -21,7 +21,6 @@ DESCRIPTOR = _descriptor.FileDescriptor(
syntax='proto3',
serialized_pb=_b('\n\x11route_guide.proto\x12\nrouteguide\",\n\x05Point\x12\x10\n\x08latitude\x18\x01 \x01(\x05\x12\x11\n\tlongitude\x18\x02 \x01(\x05\"I\n\tRectangle\x12\x1d\n\x02lo\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x1d\n\x02hi\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"<\n\x07\x46\x65\x61ture\x12\x0c\n\x04name\x18\x01 \x01(\t\x12#\n\x08location\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"A\n\tRouteNote\x12#\n\x08location\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x0f\n\x07message\x18\x02 \x01(\t\"b\n\x0cRouteSummary\x12\x13\n\x0bpoint_count\x18\x01 \x01(\x05\x12\x15\n\rfeature_count\x18\x02 \x01(\x05\x12\x10\n\x08\x64istance\x18\x03 \x01(\x05\x12\x14\n\x0c\x65lapsed_time\x18\x04 \x01(\x05\x32\x85\x02\n\nRouteGuide\x12\x36\n\nGetFeature\x12\x11.routeguide.Point\x1a\x13.routeguide.Feature\"\x00\x12>\n\x0cListFeatures\x12\x15.routeguide.Rectangle\x1a\x13.routeguide.Feature\"\x00\x30\x01\x12>\n\x0bRecordRoute\x12\x11.routeguide.Point\x1a\x18.routeguide.RouteSummary\"\x00(\x01\x12?\n\tRouteChat\x12\x15.routeguide.RouteNote\x1a\x15.routeguide.RouteNote\"\x00(\x01\x30\x01\x42\x36\n\x1bio.grpc.examples.routeguideB\x0fRouteGuideProtoP\x01\xa2\x02\x03RTGb\x06proto3')
)
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
@@ -238,6 +237,7 @@ DESCRIPTOR.message_types_by_name['Rectangle'] = _RECTANGLE
DESCRIPTOR.message_types_by_name['Feature'] = _FEATURE
DESCRIPTOR.message_types_by_name['RouteNote'] = _ROUTENOTE
DESCRIPTOR.message_types_by_name['RouteSummary'] = _ROUTESUMMARY
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), dict(
DESCRIPTOR = _POINT,
@@ -277,265 +277,55 @@ _sym_db.RegisterMessage(RouteSummary)
DESCRIPTOR.has_options = True
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.routeguideB\017RouteGuideProtoP\001\242\002\003RTG'))
-try:
- # THESE ELEMENTS WILL BE DEPRECATED.
- # Please use the generated *_pb2_grpc.py files instead.
- import grpc
- from grpc.framework.common import cardinality
- from grpc.framework.interfaces.face import utilities as face_utilities
- from grpc.beta import implementations as beta_implementations
- from grpc.beta import interfaces as beta_interfaces
-
-
- class RouteGuideStub(object):
- """Interface exported by the server.
- """
-
- def __init__(self, channel):
- """Constructor.
-
- Args:
- channel: A grpc.Channel.
- """
- self.GetFeature = channel.unary_unary(
- '/routeguide.RouteGuide/GetFeature',
- request_serializer=Point.SerializeToString,
- response_deserializer=Feature.FromString,
- )
- self.ListFeatures = channel.unary_stream(
- '/routeguide.RouteGuide/ListFeatures',
- request_serializer=Rectangle.SerializeToString,
- response_deserializer=Feature.FromString,
- )
- self.RecordRoute = channel.stream_unary(
- '/routeguide.RouteGuide/RecordRoute',
- request_serializer=Point.SerializeToString,
- response_deserializer=RouteSummary.FromString,
- )
- self.RouteChat = channel.stream_stream(
- '/routeguide.RouteGuide/RouteChat',
- request_serializer=RouteNote.SerializeToString,
- response_deserializer=RouteNote.FromString,
- )
-
-
- class RouteGuideServicer(object):
- """Interface exported by the server.
- """
-
- def GetFeature(self, request, context):
- """A simple RPC.
-
- Obtains the feature at a given position.
-
- A feature with an empty name is returned if there's no feature at the given
- position.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
- def ListFeatures(self, request, context):
- """A server-to-client streaming RPC.
-
- Obtains the Features available within the given Rectangle. Results are
- streamed rather than returned at once (e.g. in a response message with a
- repeated field), as the rectangle may cover a large area and contain a
- huge number of features.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
- def RecordRoute(self, request_iterator, context):
- """A client-to-server streaming RPC.
-
- Accepts a stream of Points on a route being traversed, returning a
- RouteSummary when traversal is completed.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
- def RouteChat(self, request_iterator, context):
- """A Bidirectional streaming RPC.
-
- Accepts a stream of RouteNotes sent while a route is being traversed,
- while receiving other RouteNotes (e.g. from other users).
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details('Method not implemented!')
- raise NotImplementedError('Method not implemented!')
-
-
- def add_RouteGuideServicer_to_server(servicer, server):
- rpc_method_handlers = {
- 'GetFeature': grpc.unary_unary_rpc_method_handler(
- servicer.GetFeature,
- request_deserializer=Point.FromString,
- response_serializer=Feature.SerializeToString,
- ),
- 'ListFeatures': grpc.unary_stream_rpc_method_handler(
- servicer.ListFeatures,
- request_deserializer=Rectangle.FromString,
- response_serializer=Feature.SerializeToString,
- ),
- 'RecordRoute': grpc.stream_unary_rpc_method_handler(
- servicer.RecordRoute,
- request_deserializer=Point.FromString,
- response_serializer=RouteSummary.SerializeToString,
- ),
- 'RouteChat': grpc.stream_stream_rpc_method_handler(
- servicer.RouteChat,
- request_deserializer=RouteNote.FromString,
- response_serializer=RouteNote.SerializeToString,
- ),
- }
- generic_handler = grpc.method_handlers_generic_handler(
- 'routeguide.RouteGuide', rpc_method_handlers)
- server.add_generic_rpc_handlers((generic_handler,))
-
-
- class BetaRouteGuideServicer(object):
- """The Beta API is deprecated for 0.15.0 and later.
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This class was generated
- only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0."""
- """Interface exported by the server.
- """
- def GetFeature(self, request, context):
- """A simple RPC.
-
- Obtains the feature at a given position.
-
- A feature with an empty name is returned if there's no feature at the given
- position.
- """
- context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
- def ListFeatures(self, request, context):
- """A server-to-client streaming RPC.
-
- Obtains the Features available within the given Rectangle. Results are
- streamed rather than returned at once (e.g. in a response message with a
- repeated field), as the rectangle may cover a large area and contain a
- huge number of features.
- """
- context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
- def RecordRoute(self, request_iterator, context):
- """A client-to-server streaming RPC.
-
- Accepts a stream of Points on a route being traversed, returning a
- RouteSummary when traversal is completed.
- """
- context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
- def RouteChat(self, request_iterator, context):
- """A Bidirectional streaming RPC.
-
- Accepts a stream of RouteNotes sent while a route is being traversed,
- while receiving other RouteNotes (e.g. from other users).
- """
- context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
-
-
- class BetaRouteGuideStub(object):
- """The Beta API is deprecated for 0.15.0 and later.
-
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This class was generated
- only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0."""
- """Interface exported by the server.
- """
- def GetFeature(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
- """A simple RPC.
-
- Obtains the feature at a given position.
-
- A feature with an empty name is returned if there's no feature at the given
- position.
- """
- raise NotImplementedError()
- GetFeature.future = None
- def ListFeatures(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
- """A server-to-client streaming RPC.
-
- Obtains the Features available within the given Rectangle. Results are
- streamed rather than returned at once (e.g. in a response message with a
- repeated field), as the rectangle may cover a large area and contain a
- huge number of features.
- """
- raise NotImplementedError()
- def RecordRoute(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
- """A client-to-server streaming RPC.
-
- Accepts a stream of Points on a route being traversed, returning a
- RouteSummary when traversal is completed.
- """
- raise NotImplementedError()
- RecordRoute.future = None
- def RouteChat(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
- """A Bidirectional streaming RPC.
-
- Accepts a stream of RouteNotes sent while a route is being traversed,
- while receiving other RouteNotes (e.g. from other users).
- """
- raise NotImplementedError()
-
-
- def beta_create_RouteGuide_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
- """The Beta API is deprecated for 0.15.0 and later.
-
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This function was
- generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"""
- request_deserializers = {
- ('routeguide.RouteGuide', 'GetFeature'): Point.FromString,
- ('routeguide.RouteGuide', 'ListFeatures'): Rectangle.FromString,
- ('routeguide.RouteGuide', 'RecordRoute'): Point.FromString,
- ('routeguide.RouteGuide', 'RouteChat'): RouteNote.FromString,
- }
- response_serializers = {
- ('routeguide.RouteGuide', 'GetFeature'): Feature.SerializeToString,
- ('routeguide.RouteGuide', 'ListFeatures'): Feature.SerializeToString,
- ('routeguide.RouteGuide', 'RecordRoute'): RouteSummary.SerializeToString,
- ('routeguide.RouteGuide', 'RouteChat'): RouteNote.SerializeToString,
- }
- method_implementations = {
- ('routeguide.RouteGuide', 'GetFeature'): face_utilities.unary_unary_inline(servicer.GetFeature),
- ('routeguide.RouteGuide', 'ListFeatures'): face_utilities.unary_stream_inline(servicer.ListFeatures),
- ('routeguide.RouteGuide', 'RecordRoute'): face_utilities.stream_unary_inline(servicer.RecordRoute),
- ('routeguide.RouteGuide', 'RouteChat'): face_utilities.stream_stream_inline(servicer.RouteChat),
- }
- server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
- return beta_implementations.server(method_implementations, options=server_options)
-
-
- def beta_create_RouteGuide_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
- """The Beta API is deprecated for 0.15.0 and later.
+_ROUTEGUIDE = _descriptor.ServiceDescriptor(
+ name='RouteGuide',
+ full_name='routeguide.RouteGuide',
+ file=DESCRIPTOR,
+ index=0,
+ options=None,
+ serialized_start=384,
+ serialized_end=645,
+ methods=[
+ _descriptor.MethodDescriptor(
+ name='GetFeature',
+ full_name='routeguide.RouteGuide.GetFeature',
+ index=0,
+ containing_service=None,
+ input_type=_POINT,
+ output_type=_FEATURE,
+ options=None,
+ ),
+ _descriptor.MethodDescriptor(
+ name='ListFeatures',
+ full_name='routeguide.RouteGuide.ListFeatures',
+ index=1,
+ containing_service=None,
+ input_type=_RECTANGLE,
+ output_type=_FEATURE,
+ options=None,
+ ),
+ _descriptor.MethodDescriptor(
+ name='RecordRoute',
+ full_name='routeguide.RouteGuide.RecordRoute',
+ index=2,
+ containing_service=None,
+ input_type=_POINT,
+ output_type=_ROUTESUMMARY,
+ options=None,
+ ),
+ _descriptor.MethodDescriptor(
+ name='RouteChat',
+ full_name='routeguide.RouteGuide.RouteChat',
+ index=3,
+ containing_service=None,
+ input_type=_ROUTENOTE,
+ output_type=_ROUTENOTE,
+ options=None,
+ ),
+])
+_sym_db.RegisterServiceDescriptor(_ROUTEGUIDE)
+
+DESCRIPTOR.services_by_name['RouteGuide'] = _ROUTEGUIDE
- It is recommended to use the GA API (classes and functions in this
- file not marked beta) for all further purposes. This function was
- generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"""
- request_serializers = {
- ('routeguide.RouteGuide', 'GetFeature'): Point.SerializeToString,
- ('routeguide.RouteGuide', 'ListFeatures'): Rectangle.SerializeToString,
- ('routeguide.RouteGuide', 'RecordRoute'): Point.SerializeToString,
- ('routeguide.RouteGuide', 'RouteChat'): RouteNote.SerializeToString,
- }
- response_deserializers = {
- ('routeguide.RouteGuide', 'GetFeature'): Feature.FromString,
- ('routeguide.RouteGuide', 'ListFeatures'): Feature.FromString,
- ('routeguide.RouteGuide', 'RecordRoute'): RouteSummary.FromString,
- ('routeguide.RouteGuide', 'RouteChat'): RouteNote.FromString,
- }
- cardinalities = {
- 'GetFeature': cardinality.Cardinality.UNARY_UNARY,
- 'ListFeatures': cardinality.Cardinality.UNARY_STREAM,
- 'RecordRoute': cardinality.Cardinality.STREAM_UNARY,
- 'RouteChat': cardinality.Cardinality.STREAM_STREAM,
- }
- stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size)
- return beta_implementations.dynamic_stub(channel, 'routeguide.RouteGuide', cardinalities, options=stub_options)
-except ImportError:
- pass
# @@protoc_insertion_point(module_scope)
diff --git a/examples/python/route_guide/route_guide_pb2_grpc.py b/examples/python/route_guide/route_guide_pb2_grpc.py
index 27b24c747d..05c1b79312 100644
--- a/examples/python/route_guide/route_guide_pb2_grpc.py
+++ b/examples/python/route_guide/route_guide_pb2_grpc.py
@@ -1,6 +1,5 @@
+# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
-from grpc.framework.common import cardinality
-from grpc.framework.interfaces.face import utilities as face_utilities
import route_guide_pb2 as route__guide__pb2
diff --git a/examples/python/route_guide/route_guide_resources.py b/examples/python/route_guide/route_guide_resources.py
index 0887863660..ace85d6f9d 100644
--- a/examples/python/route_guide/route_guide_resources.py
+++ b/examples/python/route_guide/route_guide_resources.py
@@ -11,7 +11,6 @@
# 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.
-
"""Common resources used in the gRPC route guide example."""
import json
@@ -20,19 +19,19 @@ import route_guide_pb2
def read_route_guide_database():
- """Reads the route guide database.
+ """Reads the route guide database.
Returns:
The full contents of the route guide database as a sequence of
route_guide_pb2.Features.
"""
- feature_list = []
- with open("route_guide_db.json") as route_guide_db_file:
- for item in json.load(route_guide_db_file):
- feature = route_guide_pb2.Feature(
- name=item["name"],
- location=route_guide_pb2.Point(
- latitude=item["location"]["latitude"],
- longitude=item["location"]["longitude"]))
- feature_list.append(feature)
- return feature_list
+ feature_list = []
+ with open("route_guide_db.json") as route_guide_db_file:
+ for item in json.load(route_guide_db_file):
+ feature = route_guide_pb2.Feature(
+ name=item["name"],
+ location=route_guide_pb2.Point(
+ latitude=item["location"]["latitude"],
+ longitude=item["location"]["longitude"]))
+ feature_list.append(feature)
+ return feature_list
diff --git a/examples/python/route_guide/route_guide_server.py b/examples/python/route_guide/route_guide_server.py
index a0aa5fdb83..f10008fdec 100644
--- a/examples/python/route_guide/route_guide_server.py
+++ b/examples/python/route_guide/route_guide_server.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the gRPC route guide server."""
from concurrent import futures
@@ -28,98 +27,102 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24
def get_feature(feature_db, point):
- """Returns Feature at given location or None."""
- for feature in feature_db:
- if feature.location == point:
- return feature
- return None
+ """Returns Feature at given location or None."""
+ for feature in feature_db:
+ if feature.location == point:
+ return feature
+ return None
def get_distance(start, end):
- """Distance between two points."""
- coord_factor = 10000000.0
- lat_1 = start.latitude / coord_factor
- lat_2 = end.latitude / coord_factor
- lon_1 = start.longitude / coord_factor
- lon_2 = end.longitude / coord_factor
- lat_rad_1 = math.radians(lat_1)
- lat_rad_2 = math.radians(lat_2)
- delta_lat_rad = math.radians(lat_2 - lat_1)
- delta_lon_rad = math.radians(lon_2 - lon_1)
-
- a = (pow(math.sin(delta_lat_rad / 2), 2) +
- (math.cos(lat_rad_1) * math.cos(lat_rad_2) *
- pow(math.sin(delta_lon_rad / 2), 2)))
- c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
- R = 6371000; # metres
- return R * c;
+ """Distance between two points."""
+ coord_factor = 10000000.0
+ lat_1 = start.latitude / coord_factor
+ lat_2 = end.latitude / coord_factor
+ lon_1 = start.longitude / coord_factor
+ lon_2 = end.longitude / coord_factor
+ lat_rad_1 = math.radians(lat_1)
+ lat_rad_2 = math.radians(lat_2)
+ delta_lat_rad = math.radians(lat_2 - lat_1)
+ delta_lon_rad = math.radians(lon_2 - lon_1)
+
+ a = (pow(math.sin(delta_lat_rad / 2), 2) +
+ (math.cos(lat_rad_1) * math.cos(lat_rad_2) * pow(
+ math.sin(delta_lon_rad / 2), 2)))
+ c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
+ R = 6371000
+ # metres
+ return R * c
+
class RouteGuideServicer(route_guide_pb2_grpc.RouteGuideServicer):
- """Provides methods that implement functionality of route guide server."""
-
- def __init__(self):
- self.db = route_guide_resources.read_route_guide_database()
-
- def GetFeature(self, request, context):
- feature = get_feature(self.db, request)
- if feature is None:
- return route_guide_pb2.Feature(name="", location=request)
- else:
- return feature
-
- def ListFeatures(self, request, context):
- left = min(request.lo.longitude, request.hi.longitude)
- right = max(request.lo.longitude, request.hi.longitude)
- top = max(request.lo.latitude, request.hi.latitude)
- bottom = min(request.lo.latitude, request.hi.latitude)
- for feature in self.db:
- if (feature.location.longitude >= left and
- feature.location.longitude <= right and
- feature.location.latitude >= bottom and
- feature.location.latitude <= top):
- yield feature
-
- def RecordRoute(self, request_iterator, context):
- point_count = 0
- feature_count = 0
- distance = 0.0
- prev_point = None
-
- start_time = time.time()
- for point in request_iterator:
- point_count += 1
- if get_feature(self.db, point):
- feature_count += 1
- if prev_point:
- distance += get_distance(prev_point, point)
- prev_point = point
-
- elapsed_time = time.time() - start_time
- return route_guide_pb2.RouteSummary(point_count=point_count,
- feature_count=feature_count,
- distance=int(distance),
- elapsed_time=int(elapsed_time))
-
- def RouteChat(self, request_iterator, context):
- prev_notes = []
- for new_note in request_iterator:
- for prev_note in prev_notes:
- if prev_note.location == new_note.location:
- yield prev_note
- prev_notes.append(new_note)
+ """Provides methods that implement functionality of route guide server."""
+
+ def __init__(self):
+ self.db = route_guide_resources.read_route_guide_database()
+
+ def GetFeature(self, request, context):
+ feature = get_feature(self.db, request)
+ if feature is None:
+ return route_guide_pb2.Feature(name="", location=request)
+ else:
+ return feature
+
+ def ListFeatures(self, request, context):
+ left = min(request.lo.longitude, request.hi.longitude)
+ right = max(request.lo.longitude, request.hi.longitude)
+ top = max(request.lo.latitude, request.hi.latitude)
+ bottom = min(request.lo.latitude, request.hi.latitude)
+ for feature in self.db:
+ if (feature.location.longitude >= left and
+ feature.location.longitude <= right and
+ feature.location.latitude >= bottom and
+ feature.location.latitude <= top):
+ yield feature
+
+ def RecordRoute(self, request_iterator, context):
+ point_count = 0
+ feature_count = 0
+ distance = 0.0
+ prev_point = None
+
+ start_time = time.time()
+ for point in request_iterator:
+ point_count += 1
+ if get_feature(self.db, point):
+ feature_count += 1
+ if prev_point:
+ distance += get_distance(prev_point, point)
+ prev_point = point
+
+ elapsed_time = time.time() - start_time
+ return route_guide_pb2.RouteSummary(
+ point_count=point_count,
+ feature_count=feature_count,
+ distance=int(distance),
+ elapsed_time=int(elapsed_time))
+
+ def RouteChat(self, request_iterator, context):
+ prev_notes = []
+ for new_note in request_iterator:
+ for prev_note in prev_notes:
+ if prev_note.location == new_note.location:
+ yield prev_note
+ prev_notes.append(new_note)
def serve():
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
- route_guide_pb2_grpc.add_RouteGuideServicer_to_server(
- RouteGuideServicer(), server)
- server.add_insecure_port('[::]:50051')
- server.start()
- try:
- while True:
- time.sleep(_ONE_DAY_IN_SECONDS)
- except KeyboardInterrupt:
- server.stop(0)
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ route_guide_pb2_grpc.add_RouteGuideServicer_to_server(
+ RouteGuideServicer(), server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
+
if __name__ == '__main__':
- serve()
+ serve()
diff --git a/examples/python/route_guide/run_codegen.py b/examples/python/route_guide/run_codegen.py
index 4b61cf4faa..8df562d349 100644
--- a/examples/python/route_guide/run_codegen.py
+++ b/examples/python/route_guide/run_codegen.py
@@ -11,17 +11,14 @@
# 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.
-
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs."""
from grpc_tools import protoc
-protoc.main(
- (
- '',
- '-I../../protos',
- '--python_out=.',
- '--grpc_python_out=.',
- '../../protos/route_guide.proto',
- )
-)
+protoc.main((
+ '',
+ '-I../../protos',
+ '--python_out=.',
+ '--grpc_python_out=.',
+ '../../protos/route_guide.proto',
+))
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
new file mode 100644
index 0000000000..45cee35335
--- /dev/null
+++ b/gRPC-C++.podspec
@@ -0,0 +1,685 @@
+# This file has been automatically generated from a template file.
+# Please make modifications to `templates/gRPC-C++.podspec.template`
+# instead. This file can be regenerated from the template by running
+# `tools/buildgen/generate_projects.sh`.
+
+# gRPC C++ CocoaPods podspec
+#
+# 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.
+
+
+Pod::Spec.new do |s|
+ s.name = 'gRPC-C++'
+ # TODO (mxyan): use version that match gRPC version when pod is stabilized
+ # version = '1.10.0-dev'
+ version = '0.0.1'
+ s.version = version
+ s.summary = 'gRPC C++ library'
+ s.homepage = 'https://grpc.io'
+ s.license = 'Apache License, Version 2.0'
+ s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
+
+ grpc_version = '1.10.0-dev'
+
+ s.source = {
+ :git => 'https://github.com/grpc/grpc.git',
+ :tag => "v#{grpc_version}",
+ }
+
+ s.ios.deployment_target = '7.0'
+ s.osx.deployment_target = '10.9'
+ s.requires_arc = false
+
+ # Add include prefix `grpc++` (i.e. `#include <grpc++/xxx.h>`).
+ s.header_dir = 'grpc++'
+
+ s.pod_target_xcconfig = {
+ 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
+ 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
+ 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
+ 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
+
+ # If we don't set these two settings, `include/grpc/support/time.h` and
+ # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # build.
+ 'USE_HEADERMAP' => 'NO',
+ 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ }
+
+ s.libraries = 'c++'
+
+ s.default_subspecs = 'Interface', 'Implementation'
+
+ s.subspec 'Interface' do |ss|
+ ss.header_mappings_dir = 'include/grpc++'
+
+ ss.source_files = 'include/grpc++/alarm.h',
+ 'include/grpc++/channel.h',
+ 'include/grpc++/client_context.h',
+ 'include/grpc++/completion_queue.h',
+ 'include/grpc++/create_channel.h',
+ 'include/grpc++/create_channel_posix.h',
+ 'include/grpc++/ext/health_check_service_server_builder_option.h',
+ 'include/grpc++/generic/async_generic_service.h',
+ 'include/grpc++/generic/generic_stub.h',
+ 'include/grpc++/grpc++.h',
+ 'include/grpc++/health_check_service_interface.h',
+ 'include/grpc++/impl/call.h',
+ 'include/grpc++/impl/channel_argument_option.h',
+ 'include/grpc++/impl/client_unary_call.h',
+ 'include/grpc++/impl/codegen/core_codegen.h',
+ 'include/grpc++/impl/grpc_library.h',
+ 'include/grpc++/impl/method_handler_impl.h',
+ 'include/grpc++/impl/rpc_method.h',
+ 'include/grpc++/impl/rpc_service_method.h',
+ 'include/grpc++/impl/serialization_traits.h',
+ 'include/grpc++/impl/server_builder_option.h',
+ 'include/grpc++/impl/server_builder_plugin.h',
+ 'include/grpc++/impl/server_initializer.h',
+ 'include/grpc++/impl/service_type.h',
+ 'include/grpc++/resource_quota.h',
+ 'include/grpc++/security/auth_context.h',
+ 'include/grpc++/security/auth_metadata_processor.h',
+ 'include/grpc++/security/credentials.h',
+ 'include/grpc++/security/server_credentials.h',
+ 'include/grpc++/server.h',
+ 'include/grpc++/server_builder.h',
+ 'include/grpc++/server_context.h',
+ 'include/grpc++/server_posix.h',
+ 'include/grpc++/support/async_stream.h',
+ 'include/grpc++/support/async_unary_call.h',
+ 'include/grpc++/support/byte_buffer.h',
+ 'include/grpc++/support/channel_arguments.h',
+ 'include/grpc++/support/config.h',
+ 'include/grpc++/support/slice.h',
+ 'include/grpc++/support/status.h',
+ 'include/grpc++/support/status_code_enum.h',
+ 'include/grpc++/support/string_ref.h',
+ 'include/grpc++/support/stub_options.h',
+ 'include/grpc++/support/sync_stream.h',
+ 'include/grpc++/support/time.h',
+ 'include/grpc++/impl/codegen/async_stream.h',
+ 'include/grpc++/impl/codegen/async_unary_call.h',
+ 'include/grpc++/impl/codegen/byte_buffer.h',
+ 'include/grpc++/impl/codegen/call.h',
+ 'include/grpc++/impl/codegen/call_hook.h',
+ 'include/grpc++/impl/codegen/channel_interface.h',
+ 'include/grpc++/impl/codegen/client_context.h',
+ 'include/grpc++/impl/codegen/client_unary_call.h',
+ 'include/grpc++/impl/codegen/completion_queue.h',
+ 'include/grpc++/impl/codegen/completion_queue_tag.h',
+ 'include/grpc++/impl/codegen/config.h',
+ 'include/grpc++/impl/codegen/core_codegen_interface.h',
+ 'include/grpc++/impl/codegen/create_auth_context.h',
+ 'include/grpc++/impl/codegen/grpc_library.h',
+ 'include/grpc++/impl/codegen/metadata_map.h',
+ 'include/grpc++/impl/codegen/method_handler_impl.h',
+ 'include/grpc++/impl/codegen/rpc_method.h',
+ 'include/grpc++/impl/codegen/rpc_service_method.h',
+ 'include/grpc++/impl/codegen/security/auth_context.h',
+ 'include/grpc++/impl/codegen/serialization_traits.h',
+ 'include/grpc++/impl/codegen/server_context.h',
+ 'include/grpc++/impl/codegen/server_interface.h',
+ 'include/grpc++/impl/codegen/service_type.h',
+ 'include/grpc++/impl/codegen/slice.h',
+ 'include/grpc++/impl/codegen/status.h',
+ 'include/grpc++/impl/codegen/status_code_enum.h',
+ 'include/grpc++/impl/codegen/string_ref.h',
+ 'include/grpc++/impl/codegen/stub_options.h',
+ 'include/grpc++/impl/codegen/sync_stream.h',
+ 'include/grpc++/impl/codegen/time.h'
+ end
+
+ s.subspec 'Implementation' do |ss|
+ ss.header_mappings_dir = '.'
+ ss.dependency "#{s.name}/Interface", version
+ ss.dependency 'gRPC-Core', grpc_version
+ ss.dependency 'nanopb', '~> 0.3'
+
+ ss.source_files = 'include/grpc++/impl/codegen/core_codegen.h',
+ 'src/cpp/client/secure_credentials.h',
+ 'src/cpp/common/secure_auth_context.h',
+ 'src/cpp/server/secure_server_credentials.h',
+ 'src/cpp/client/create_channel_internal.h',
+ 'src/cpp/common/channel_filter.h',
+ 'src/cpp/server/dynamic_thread_pool.h',
+ 'src/cpp/server/health/default_health_check_service.h',
+ 'src/cpp/server/health/health.pb.h',
+ 'src/cpp/server/thread_pool_interface.h',
+ 'src/cpp/thread_manager/thread_manager.h',
+ 'src/cpp/client/insecure_credentials.cc',
+ 'src/cpp/client/secure_credentials.cc',
+ 'src/cpp/common/auth_property_iterator.cc',
+ 'src/cpp/common/secure_auth_context.cc',
+ 'src/cpp/common/secure_channel_arguments.cc',
+ 'src/cpp/common/secure_create_auth_context.cc',
+ 'src/cpp/server/insecure_server_credentials.cc',
+ 'src/cpp/server/secure_server_credentials.cc',
+ 'src/cpp/client/channel_cc.cc',
+ 'src/cpp/client/client_context.cc',
+ 'src/cpp/client/create_channel.cc',
+ 'src/cpp/client/create_channel_internal.cc',
+ 'src/cpp/client/create_channel_posix.cc',
+ 'src/cpp/client/credentials_cc.cc',
+ 'src/cpp/client/generic_stub.cc',
+ 'src/cpp/common/channel_arguments.cc',
+ 'src/cpp/common/channel_filter.cc',
+ 'src/cpp/common/completion_queue_cc.cc',
+ 'src/cpp/common/core_codegen.cc',
+ 'src/cpp/common/resource_quota_cc.cc',
+ 'src/cpp/common/rpc_method.cc',
+ 'src/cpp/common/version_cc.cc',
+ 'src/cpp/server/async_generic_service.cc',
+ 'src/cpp/server/channel_argument_option.cc',
+ 'src/cpp/server/create_default_thread_pool.cc',
+ 'src/cpp/server/dynamic_thread_pool.cc',
+ 'src/cpp/server/health/default_health_check_service.cc',
+ 'src/cpp/server/health/health.pb.c',
+ 'src/cpp/server/health/health_check_service.cc',
+ 'src/cpp/server/health/health_check_service_server_builder_option.cc',
+ 'src/cpp/server/server_builder.cc',
+ 'src/cpp/server/server_cc.cc',
+ 'src/cpp/server/server_context.cc',
+ 'src/cpp/server/server_credentials.cc',
+ 'src/cpp/server/server_posix.cc',
+ 'src/cpp/thread_manager/thread_manager.cc',
+ 'src/cpp/util/byte_buffer_cc.cc',
+ 'src/cpp/util/slice_cc.cc',
+ 'src/cpp/util/status.cc',
+ 'src/cpp/util/string_ref.cc',
+ 'src/cpp/util/time_cc.cc',
+ 'src/cpp/codegen/codegen_init.cc',
+ 'src/core/lib/gpr/arena.h',
+ 'src/core/lib/gpr/env.h',
+ 'src/core/lib/gpr/fork.h',
+ 'src/core/lib/gpr/mpscq.h',
+ 'src/core/lib/gpr/murmur_hash.h',
+ 'src/core/lib/gpr/spinlock.h',
+ '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/tmpfile.h',
+ 'src/core/lib/gprpp/abstract.h',
+ 'src/core/lib/gprpp/atomic.h',
+ 'src/core/lib/gprpp/atomic_with_atm.h',
+ 'src/core/lib/gprpp/atomic_with_std.h',
+ 'src/core/lib/gprpp/manual_constructor.h',
+ 'src/core/lib/gprpp/memory.h',
+ 'src/core/lib/profiling/timers.h',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.h',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.h',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.h',
+ 'src/core/ext/transport/chttp2/transport/flow_control.h',
+ 'src/core/ext/transport/chttp2/transport/frame.h',
+ 'src/core/ext/transport/chttp2/transport/frame_data.h',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.h',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.h',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.h',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.h',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.h',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.h',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.h',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.h',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.h',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.h',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.h',
+ 'src/core/ext/transport/chttp2/transport/internal.h',
+ 'src/core/ext/transport/chttp2/transport/stream_map.h',
+ 'src/core/ext/transport/chttp2/transport/varint.h',
+ 'src/core/ext/transport/chttp2/alpn/alpn.h',
+ 'src/core/ext/filters/http/client/http_client_filter.h',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.h',
+ 'src/core/ext/filters/http/server/http_server_filter.h',
+ 'src/core/lib/security/context/security_context.h',
+ 'src/core/lib/security/credentials/composite/composite_credentials.h',
+ 'src/core/lib/security/credentials/credentials.h',
+ 'src/core/lib/security/credentials/fake/fake_credentials.h',
+ 'src/core/lib/security/credentials/google_default/google_default_credentials.h',
+ 'src/core/lib/security/credentials/iam/iam_credentials.h',
+ 'src/core/lib/security/credentials/jwt/json_token.h',
+ 'src/core/lib/security/credentials/jwt/jwt_credentials.h',
+ 'src/core/lib/security/credentials/jwt/jwt_verifier.h',
+ 'src/core/lib/security/credentials/oauth2/oauth2_credentials.h',
+ 'src/core/lib/security/credentials/plugin/plugin_credentials.h',
+ 'src/core/lib/security/credentials/ssl/ssl_credentials.h',
+ 'src/core/lib/security/transport/auth_filters.h',
+ 'src/core/lib/security/transport/lb_targets_info.h',
+ 'src/core/lib/security/transport/secure_endpoint.h',
+ 'src/core/lib/security/transport/security_connector.h',
+ 'src/core/lib/security/transport/security_handshaker.h',
+ 'src/core/lib/security/transport/tsi_error.h',
+ 'src/core/lib/security/util/json_util.h',
+ 'src/core/tsi/alts_transport_security.h',
+ 'src/core/tsi/fake_transport_security.h',
+ 'src/core/tsi/ssl_transport_security.h',
+ 'src/core/tsi/ssl_types.h',
+ 'src/core/tsi/transport_security_grpc.h',
+ 'src/core/tsi/transport_security.h',
+ 'src/core/tsi/transport_security_adapter.h',
+ 'src/core/tsi/transport_security_interface.h',
+ 'src/core/ext/transport/chttp2/server/chttp2_server.h',
+ 'src/core/ext/filters/client_channel/backup_poller.h',
+ 'src/core/ext/filters/client_channel/client_channel.h',
+ 'src/core/ext/filters/client_channel/client_channel_factory.h',
+ 'src/core/ext/filters/client_channel/connector.h',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.h',
+ 'src/core/ext/filters/client_channel/http_proxy.h',
+ 'src/core/ext/filters/client_channel/lb_policy.h',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.h',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.h',
+ 'src/core/ext/filters/client_channel/parse_address.h',
+ 'src/core/ext/filters/client_channel/proxy_mapper.h',
+ 'src/core/ext/filters/client_channel/proxy_mapper_registry.h',
+ 'src/core/ext/filters/client_channel/resolver.h',
+ 'src/core/ext/filters/client_channel/resolver_factory.h',
+ 'src/core/ext/filters/client_channel/resolver_registry.h',
+ 'src/core/ext/filters/client_channel/retry_throttle.h',
+ 'src/core/ext/filters/client_channel/subchannel.h',
+ 'src/core/ext/filters/client_channel/subchannel_index.h',
+ 'src/core/ext/filters/client_channel/uri_parser.h',
+ '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/backoff/backoff.h',
+ 'src/core/lib/channel/channel_args.h',
+ 'src/core/lib/channel/channel_stack.h',
+ 'src/core/lib/channel/channel_stack_builder.h',
+ 'src/core/lib/channel/connected_channel.h',
+ 'src/core/lib/channel/context.h',
+ 'src/core/lib/channel/handshaker.h',
+ 'src/core/lib/channel/handshaker_factory.h',
+ 'src/core/lib/channel/handshaker_registry.h',
+ 'src/core/lib/compression/algorithm_metadata.h',
+ 'src/core/lib/compression/compression_internal.h',
+ 'src/core/lib/compression/message_compress.h',
+ 'src/core/lib/compression/stream_compression.h',
+ 'src/core/lib/compression/stream_compression_gzip.h',
+ 'src/core/lib/compression/stream_compression_identity.h',
+ 'src/core/lib/debug/stats.h',
+ 'src/core/lib/debug/stats_data.h',
+ 'src/core/lib/gprpp/debug_location.h',
+ 'src/core/lib/gprpp/inlined_vector.h',
+ 'src/core/lib/gprpp/orphanable.h',
+ 'src/core/lib/gprpp/ref_counted.h',
+ 'src/core/lib/gprpp/ref_counted_ptr.h',
+ 'src/core/lib/http/format_request.h',
+ 'src/core/lib/http/httpcli.h',
+ 'src/core/lib/http/parser.h',
+ 'src/core/lib/iomgr/block_annotate.h',
+ 'src/core/lib/iomgr/call_combiner.h',
+ 'src/core/lib/iomgr/closure.h',
+ 'src/core/lib/iomgr/combiner.h',
+ 'src/core/lib/iomgr/endpoint.h',
+ 'src/core/lib/iomgr/endpoint_pair.h',
+ 'src/core/lib/iomgr/error.h',
+ 'src/core/lib/iomgr/error_internal.h',
+ 'src/core/lib/iomgr/ev_epoll1_linux.h',
+ 'src/core/lib/iomgr/ev_epollex_linux.h',
+ 'src/core/lib/iomgr/ev_epollsig_linux.h',
+ 'src/core/lib/iomgr/ev_poll_posix.h',
+ 'src/core/lib/iomgr/ev_posix.h',
+ 'src/core/lib/iomgr/exec_ctx.h',
+ 'src/core/lib/iomgr/executor.h',
+ 'src/core/lib/iomgr/gethostname.h',
+ 'src/core/lib/iomgr/iocp_windows.h',
+ 'src/core/lib/iomgr/iomgr.h',
+ 'src/core/lib/iomgr/iomgr_internal.h',
+ 'src/core/lib/iomgr/iomgr_posix.h',
+ 'src/core/lib/iomgr/iomgr_uv.h',
+ 'src/core/lib/iomgr/is_epollexclusive_available.h',
+ 'src/core/lib/iomgr/load_file.h',
+ 'src/core/lib/iomgr/lockfree_event.h',
+ 'src/core/lib/iomgr/nameser.h',
+ 'src/core/lib/iomgr/network_status_tracker.h',
+ 'src/core/lib/iomgr/polling_entity.h',
+ 'src/core/lib/iomgr/pollset.h',
+ 'src/core/lib/iomgr/pollset_set.h',
+ 'src/core/lib/iomgr/pollset_set_windows.h',
+ 'src/core/lib/iomgr/pollset_uv.h',
+ 'src/core/lib/iomgr/pollset_windows.h',
+ 'src/core/lib/iomgr/port.h',
+ 'src/core/lib/iomgr/resolve_address.h',
+ 'src/core/lib/iomgr/resource_quota.h',
+ 'src/core/lib/iomgr/sockaddr.h',
+ 'src/core/lib/iomgr/sockaddr_posix.h',
+ 'src/core/lib/iomgr/sockaddr_utils.h',
+ 'src/core/lib/iomgr/sockaddr_windows.h',
+ 'src/core/lib/iomgr/socket_factory_posix.h',
+ 'src/core/lib/iomgr/socket_mutator.h',
+ 'src/core/lib/iomgr/socket_utils.h',
+ 'src/core/lib/iomgr/socket_utils_posix.h',
+ 'src/core/lib/iomgr/socket_windows.h',
+ 'src/core/lib/iomgr/sys_epoll_wrapper.h',
+ 'src/core/lib/iomgr/tcp_client.h',
+ 'src/core/lib/iomgr/tcp_client_posix.h',
+ 'src/core/lib/iomgr/tcp_posix.h',
+ 'src/core/lib/iomgr/tcp_server.h',
+ 'src/core/lib/iomgr/tcp_server_utils_posix.h',
+ 'src/core/lib/iomgr/tcp_uv.h',
+ 'src/core/lib/iomgr/tcp_windows.h',
+ 'src/core/lib/iomgr/time_averaged_stats.h',
+ 'src/core/lib/iomgr/timer.h',
+ 'src/core/lib/iomgr/timer_generic.h',
+ 'src/core/lib/iomgr/timer_heap.h',
+ 'src/core/lib/iomgr/timer_manager.h',
+ 'src/core/lib/iomgr/timer_uv.h',
+ 'src/core/lib/iomgr/udp_server.h',
+ 'src/core/lib/iomgr/unix_sockets_posix.h',
+ 'src/core/lib/iomgr/wakeup_fd_cv.h',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.h',
+ 'src/core/lib/iomgr/wakeup_fd_posix.h',
+ 'src/core/lib/json/json.h',
+ 'src/core/lib/json/json_common.h',
+ 'src/core/lib/json/json_reader.h',
+ 'src/core/lib/json/json_writer.h',
+ 'src/core/lib/slice/b64.h',
+ 'src/core/lib/slice/percent_encoding.h',
+ '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',
+ 'src/core/lib/surface/channel.h',
+ 'src/core/lib/surface/channel_init.h',
+ 'src/core/lib/surface/channel_stack_type.h',
+ 'src/core/lib/surface/completion_queue.h',
+ 'src/core/lib/surface/completion_queue_factory.h',
+ 'src/core/lib/surface/event_string.h',
+ 'src/core/lib/surface/init.h',
+ 'src/core/lib/surface/lame_client.h',
+ 'src/core/lib/surface/server.h',
+ 'src/core/lib/surface/validate_metadata.h',
+ 'src/core/lib/transport/bdp_estimator.h',
+ 'src/core/lib/transport/byte_stream.h',
+ 'src/core/lib/transport/connectivity_state.h',
+ 'src/core/lib/transport/error_utils.h',
+ 'src/core/lib/transport/http2_errors.h',
+ 'src/core/lib/transport/metadata.h',
+ 'src/core/lib/transport/metadata_batch.h',
+ 'src/core/lib/transport/pid_controller.h',
+ 'src/core/lib/transport/service_config.h',
+ 'src/core/lib/transport/static_metadata.h',
+ 'src/core/lib/transport/status_conversion.h',
+ 'src/core/lib/transport/timeout_encoding.h',
+ 'src/core/lib/transport/transport.h',
+ 'src/core/lib/transport/transport_impl.h',
+ 'src/core/lib/debug/trace.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_filter.h',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h',
+ 'src/core/ext/filters/max_age/max_age_filter.h',
+ 'src/core/ext/filters/message_size/message_size_filter.h',
+ 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h',
+ 'src/core/ext/filters/workarounds/workaround_utils.h'
+
+ ss.private_header_files = 'include/grpc++/impl/codegen/core_codegen.h',
+ 'src/cpp/client/secure_credentials.h',
+ 'src/cpp/common/secure_auth_context.h',
+ 'src/cpp/server/secure_server_credentials.h',
+ 'src/cpp/client/create_channel_internal.h',
+ 'src/cpp/common/channel_filter.h',
+ 'src/cpp/server/dynamic_thread_pool.h',
+ 'src/cpp/server/health/default_health_check_service.h',
+ 'src/cpp/server/health/health.pb.h',
+ 'src/cpp/server/thread_pool_interface.h',
+ 'src/cpp/thread_manager/thread_manager.h',
+ 'src/core/lib/gpr/arena.h',
+ 'src/core/lib/gpr/env.h',
+ 'src/core/lib/gpr/fork.h',
+ 'src/core/lib/gpr/mpscq.h',
+ 'src/core/lib/gpr/murmur_hash.h',
+ 'src/core/lib/gpr/spinlock.h',
+ '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/tmpfile.h',
+ 'src/core/lib/gprpp/abstract.h',
+ 'src/core/lib/gprpp/atomic.h',
+ 'src/core/lib/gprpp/atomic_with_atm.h',
+ 'src/core/lib/gprpp/atomic_with_std.h',
+ 'src/core/lib/gprpp/manual_constructor.h',
+ 'src/core/lib/gprpp/memory.h',
+ 'src/core/lib/profiling/timers.h',
+ 'src/core/lib/backoff/backoff.h',
+ 'src/core/lib/channel/channel_args.h',
+ 'src/core/lib/channel/channel_stack.h',
+ 'src/core/lib/channel/channel_stack_builder.h',
+ 'src/core/lib/channel/connected_channel.h',
+ 'src/core/lib/channel/context.h',
+ 'src/core/lib/channel/handshaker.h',
+ 'src/core/lib/channel/handshaker_factory.h',
+ 'src/core/lib/channel/handshaker_registry.h',
+ 'src/core/lib/compression/algorithm_metadata.h',
+ 'src/core/lib/compression/compression_internal.h',
+ 'src/core/lib/compression/message_compress.h',
+ 'src/core/lib/compression/stream_compression.h',
+ 'src/core/lib/compression/stream_compression_gzip.h',
+ 'src/core/lib/compression/stream_compression_identity.h',
+ 'src/core/lib/debug/stats.h',
+ 'src/core/lib/debug/stats_data.h',
+ 'src/core/lib/gprpp/debug_location.h',
+ 'src/core/lib/gprpp/inlined_vector.h',
+ 'src/core/lib/gprpp/orphanable.h',
+ 'src/core/lib/gprpp/ref_counted.h',
+ 'src/core/lib/gprpp/ref_counted_ptr.h',
+ 'src/core/lib/http/format_request.h',
+ 'src/core/lib/http/httpcli.h',
+ 'src/core/lib/http/parser.h',
+ 'src/core/lib/iomgr/block_annotate.h',
+ 'src/core/lib/iomgr/call_combiner.h',
+ 'src/core/lib/iomgr/closure.h',
+ 'src/core/lib/iomgr/combiner.h',
+ 'src/core/lib/iomgr/endpoint.h',
+ 'src/core/lib/iomgr/endpoint_pair.h',
+ 'src/core/lib/iomgr/error.h',
+ 'src/core/lib/iomgr/error_internal.h',
+ 'src/core/lib/iomgr/ev_epoll1_linux.h',
+ 'src/core/lib/iomgr/ev_epollex_linux.h',
+ 'src/core/lib/iomgr/ev_epollsig_linux.h',
+ 'src/core/lib/iomgr/ev_poll_posix.h',
+ 'src/core/lib/iomgr/ev_posix.h',
+ 'src/core/lib/iomgr/exec_ctx.h',
+ 'src/core/lib/iomgr/executor.h',
+ 'src/core/lib/iomgr/gethostname.h',
+ 'src/core/lib/iomgr/iocp_windows.h',
+ 'src/core/lib/iomgr/iomgr.h',
+ 'src/core/lib/iomgr/iomgr_internal.h',
+ 'src/core/lib/iomgr/iomgr_posix.h',
+ 'src/core/lib/iomgr/iomgr_uv.h',
+ 'src/core/lib/iomgr/is_epollexclusive_available.h',
+ 'src/core/lib/iomgr/load_file.h',
+ 'src/core/lib/iomgr/lockfree_event.h',
+ 'src/core/lib/iomgr/nameser.h',
+ 'src/core/lib/iomgr/network_status_tracker.h',
+ 'src/core/lib/iomgr/polling_entity.h',
+ 'src/core/lib/iomgr/pollset.h',
+ 'src/core/lib/iomgr/pollset_set.h',
+ 'src/core/lib/iomgr/pollset_set_windows.h',
+ 'src/core/lib/iomgr/pollset_uv.h',
+ 'src/core/lib/iomgr/pollset_windows.h',
+ 'src/core/lib/iomgr/port.h',
+ 'src/core/lib/iomgr/resolve_address.h',
+ 'src/core/lib/iomgr/resource_quota.h',
+ 'src/core/lib/iomgr/sockaddr.h',
+ 'src/core/lib/iomgr/sockaddr_posix.h',
+ 'src/core/lib/iomgr/sockaddr_utils.h',
+ 'src/core/lib/iomgr/sockaddr_windows.h',
+ 'src/core/lib/iomgr/socket_factory_posix.h',
+ 'src/core/lib/iomgr/socket_mutator.h',
+ 'src/core/lib/iomgr/socket_utils.h',
+ 'src/core/lib/iomgr/socket_utils_posix.h',
+ 'src/core/lib/iomgr/socket_windows.h',
+ 'src/core/lib/iomgr/sys_epoll_wrapper.h',
+ 'src/core/lib/iomgr/tcp_client.h',
+ 'src/core/lib/iomgr/tcp_client_posix.h',
+ 'src/core/lib/iomgr/tcp_posix.h',
+ 'src/core/lib/iomgr/tcp_server.h',
+ 'src/core/lib/iomgr/tcp_server_utils_posix.h',
+ 'src/core/lib/iomgr/tcp_uv.h',
+ 'src/core/lib/iomgr/tcp_windows.h',
+ 'src/core/lib/iomgr/time_averaged_stats.h',
+ 'src/core/lib/iomgr/timer.h',
+ 'src/core/lib/iomgr/timer_generic.h',
+ 'src/core/lib/iomgr/timer_heap.h',
+ 'src/core/lib/iomgr/timer_manager.h',
+ 'src/core/lib/iomgr/timer_uv.h',
+ 'src/core/lib/iomgr/udp_server.h',
+ 'src/core/lib/iomgr/unix_sockets_posix.h',
+ 'src/core/lib/iomgr/wakeup_fd_cv.h',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.h',
+ 'src/core/lib/iomgr/wakeup_fd_posix.h',
+ 'src/core/lib/json/json.h',
+ 'src/core/lib/json/json_common.h',
+ 'src/core/lib/json/json_reader.h',
+ 'src/core/lib/json/json_writer.h',
+ 'src/core/lib/slice/b64.h',
+ 'src/core/lib/slice/percent_encoding.h',
+ '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',
+ 'src/core/lib/surface/channel.h',
+ 'src/core/lib/surface/channel_init.h',
+ 'src/core/lib/surface/channel_stack_type.h',
+ 'src/core/lib/surface/completion_queue.h',
+ 'src/core/lib/surface/completion_queue_factory.h',
+ 'src/core/lib/surface/event_string.h',
+ 'src/core/lib/surface/init.h',
+ 'src/core/lib/surface/lame_client.h',
+ 'src/core/lib/surface/server.h',
+ 'src/core/lib/surface/validate_metadata.h',
+ 'src/core/lib/transport/bdp_estimator.h',
+ 'src/core/lib/transport/byte_stream.h',
+ 'src/core/lib/transport/connectivity_state.h',
+ 'src/core/lib/transport/error_utils.h',
+ 'src/core/lib/transport/http2_errors.h',
+ 'src/core/lib/transport/metadata.h',
+ 'src/core/lib/transport/metadata_batch.h',
+ 'src/core/lib/transport/pid_controller.h',
+ 'src/core/lib/transport/service_config.h',
+ 'src/core/lib/transport/static_metadata.h',
+ 'src/core/lib/transport/status_conversion.h',
+ 'src/core/lib/transport/timeout_encoding.h',
+ 'src/core/lib/transport/transport.h',
+ 'src/core/lib/transport/transport_impl.h',
+ 'src/core/lib/debug/trace.h',
+ 'src/core/ext/transport/inproc/inproc_transport.h'
+ end
+
+ s.subspec 'Tests' do |ss|
+ ss.header_mappings_dir = '.'
+
+ ss.dependency "#{s.name}/Interface", version
+ ss.dependency "#{s.name}/Implementation", version
+ ss.dependency "gRPC-Core/Tests", grpc_version
+
+ ss.source_files = 'test/cpp/util/create_test_channel.cc',
+ 'test/cpp/util/string_ref_helper.cc',
+ 'test/cpp/util/subprocess.cc',
+ 'test/cpp/util/test_credentials_provider.cc',
+ 'test/cpp/util/create_test_channel.h',
+ 'test/cpp/util/string_ref_helper.h',
+ 'test/cpp/util/subprocess.h',
+ 'test/cpp/util/test_credentials_provider.h',
+ 'test/core/util/test_config.h',
+ 'test/core/end2end/data/ssl_test_data.h',
+ 'test/core/security/oauth2_utils.h',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h',
+ 'test/core/end2end/cq_verifier.h',
+ 'test/core/end2end/fixtures/http_proxy_fixture.h',
+ 'test/core/end2end/fixtures/proxy.h',
+ 'test/core/iomgr/endpoint_tests.h',
+ 'test/core/util/debugger_macros.h',
+ 'test/core/util/grpc_profiler.h',
+ 'test/core/util/histogram.h',
+ 'test/core/util/memory_counters.h',
+ 'test/core/util/mock_endpoint.h',
+ 'test/core/util/parse_hexstring.h',
+ 'test/core/util/passthru_endpoint.h',
+ 'test/core/util/port.h',
+ 'test/core/util/port_server_client.h',
+ 'test/core/util/slice_splitter.h',
+ 'test/core/util/tracer_util.h',
+ 'test/core/util/trickle_endpoint.h',
+ 'src/core/ext/filters/client_channel/backup_poller.h',
+ 'src/core/ext/filters/client_channel/client_channel.h',
+ 'src/core/ext/filters/client_channel/client_channel_factory.h',
+ 'src/core/ext/filters/client_channel/connector.h',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.h',
+ 'src/core/ext/filters/client_channel/http_proxy.h',
+ 'src/core/ext/filters/client_channel/lb_policy.h',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.h',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.h',
+ 'src/core/ext/filters/client_channel/parse_address.h',
+ 'src/core/ext/filters/client_channel/proxy_mapper.h',
+ 'src/core/ext/filters/client_channel/proxy_mapper_registry.h',
+ 'src/core/ext/filters/client_channel/resolver.h',
+ 'src/core/ext/filters/client_channel/resolver_factory.h',
+ 'src/core/ext/filters/client_channel/resolver_registry.h',
+ 'src/core/ext/filters/client_channel/retry_throttle.h',
+ 'src/core/ext/filters/client_channel/subchannel.h',
+ 'src/core/ext/filters/client_channel/subchannel_index.h',
+ 'src/core/ext/filters/client_channel/uri_parser.h',
+ 'src/core/ext/filters/deadline/deadline_filter.h',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.h',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.h',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.h',
+ 'src/core/ext/transport/chttp2/transport/flow_control.h',
+ 'src/core/ext/transport/chttp2/transport/frame.h',
+ 'src/core/ext/transport/chttp2/transport/frame_data.h',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.h',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.h',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.h',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.h',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.h',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.h',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.h',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.h',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.h',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.h',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.h',
+ 'src/core/ext/transport/chttp2/transport/internal.h',
+ 'src/core/ext/transport/chttp2/transport/stream_map.h',
+ 'src/core/ext/transport/chttp2/transport/varint.h',
+ 'src/core/ext/transport/chttp2/alpn/alpn.h',
+ 'src/core/ext/filters/http/client/http_client_filter.h',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.h',
+ 'src/core/ext/filters/http/server/http_server_filter.h'
+ end
+
+ s.prepare_command = <<-END_OF_COMMAND
+ find src/cpp/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/cpp/ -name "*.back" -type f -delete
+ find src/core/ -regex ".*\.h" -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/core/ -name "*.back" -type f -delete
+ END_OF_COMMAND
+end
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index c76b9a3f4b..c57fd36ea3 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -22,7 +22,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-Core'
- version = '1.7.0-dev'
+ version = '1.10.0-dev'
s.version = version
s.summary = 'Core cross-platform gRPC library, written in C'
s.homepage = 'https://grpc.io'
@@ -34,6 +34,10 @@ Pod::Spec.new do |s|
:tag => "v#{version}",
}
+ # gRPC podspecs depend on fix for https://github.com/CocoaPods/CocoaPods/issues/6024,
+ # which was released in Cocoapods v1.2.0.
+ s.cocoapods_version = '>= 1.2.0'
+
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.requires_arc = false
@@ -80,14 +84,17 @@ Pod::Spec.new do |s|
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
- # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
}
s.default_subspecs = 'Interface', 'Implementation'
s.compiler_flags = '-DGRPC_ARES=0'
+ s.libraries = 'c++'
# Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its
# sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't
@@ -110,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/histogram.h',
'include/grpc/support/host_port.h',
'include/grpc/support/log.h',
'include/grpc/support/log_windows.h',
@@ -133,6 +139,7 @@ Pod::Spec.new do |s|
'include/grpc/impl/codegen/atm_gcc_atomic.h',
'include/grpc/impl/codegen/atm_gcc_sync.h',
'include/grpc/impl/codegen/atm_windows.h',
+ 'include/grpc/impl/codegen/fork.h',
'include/grpc/impl/codegen/gpr_slice.h',
'include/grpc/impl/codegen/gpr_types.h',
'include/grpc/impl/codegen/port_platform.h',
@@ -145,7 +152,6 @@ Pod::Spec.new do |s|
'include/grpc/impl/codegen/byte_buffer_reader.h',
'include/grpc/impl/codegen/compression_types.h',
'include/grpc/impl/codegen/connectivity_state.h',
- 'include/grpc/impl/codegen/exec_ctx_fwd.h',
'include/grpc/impl/codegen/grpc_types.h',
'include/grpc/impl/codegen/propagation_bits.h',
'include/grpc/impl/codegen/slice.h',
@@ -154,6 +160,7 @@ Pod::Spec.new do |s|
'include/grpc/impl/codegen/atm_gcc_atomic.h',
'include/grpc/impl/codegen/atm_gcc_sync.h',
'include/grpc/impl/codegen/atm_windows.h',
+ 'include/grpc/impl/codegen/fork.h',
'include/grpc/impl/codegen/gpr_slice.h',
'include/grpc/impl/codegen/gpr_types.h',
'include/grpc/impl/codegen/port_platform.h',
@@ -166,6 +173,8 @@ Pod::Spec.new do |s|
'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',
'include/grpc/grpc_security_constants.h',
@@ -184,72 +193,72 @@ Pod::Spec.new do |s|
ss.dependency 'nanopb', '~> 0.3'
# To save you from scrolling, this is the last part of the podspec.
- ss.source_files = 'src/core/lib/profiling/timers.h',
- 'src/core/lib/support/arena.h',
- 'src/core/lib/support/atomic.h',
- 'src/core/lib/support/atomic_with_atm.h',
- 'src/core/lib/support/atomic_with_std.h',
- 'src/core/lib/support/backoff.h',
- 'src/core/lib/support/block_annotate.h',
- 'src/core/lib/support/env.h',
- 'src/core/lib/support/memory.h',
- 'src/core/lib/support/mpscq.h',
- 'src/core/lib/support/murmur_hash.h',
- 'src/core/lib/support/spinlock.h',
- 'src/core/lib/support/stack_lockfree.h',
- 'src/core/lib/support/string.h',
- 'src/core/lib/support/string_windows.h',
- 'src/core/lib/support/time_precise.h',
- 'src/core/lib/support/tmpfile.h',
- 'src/core/lib/profiling/basic_timers.c',
- 'src/core/lib/profiling/stap_timers.c',
- 'src/core/lib/support/alloc.c',
- 'src/core/lib/support/arena.c',
- 'src/core/lib/support/atm.c',
- 'src/core/lib/support/avl.c',
- 'src/core/lib/support/backoff.c',
- 'src/core/lib/support/cmdline.c',
- 'src/core/lib/support/cpu_iphone.c',
- 'src/core/lib/support/cpu_linux.c',
- 'src/core/lib/support/cpu_posix.c',
- 'src/core/lib/support/cpu_windows.c',
- 'src/core/lib/support/env_linux.c',
- 'src/core/lib/support/env_posix.c',
- 'src/core/lib/support/env_windows.c',
- 'src/core/lib/support/histogram.c',
- 'src/core/lib/support/host_port.c',
- 'src/core/lib/support/log.c',
- 'src/core/lib/support/log_android.c',
- 'src/core/lib/support/log_linux.c',
- 'src/core/lib/support/log_posix.c',
- 'src/core/lib/support/log_windows.c',
- 'src/core/lib/support/mpscq.c',
- 'src/core/lib/support/murmur_hash.c',
- 'src/core/lib/support/stack_lockfree.c',
- 'src/core/lib/support/string.c',
- 'src/core/lib/support/string_posix.c',
- 'src/core/lib/support/string_util_windows.c',
- 'src/core/lib/support/string_windows.c',
- 'src/core/lib/support/subprocess_posix.c',
- 'src/core/lib/support/subprocess_windows.c',
- 'src/core/lib/support/sync.c',
- 'src/core/lib/support/sync_posix.c',
- 'src/core/lib/support/sync_windows.c',
- 'src/core/lib/support/thd.c',
- 'src/core/lib/support/thd_posix.c',
- 'src/core/lib/support/thd_windows.c',
- 'src/core/lib/support/time.c',
- 'src/core/lib/support/time_posix.c',
- 'src/core/lib/support/time_precise.c',
- 'src/core/lib/support/time_windows.c',
- 'src/core/lib/support/tls_pthread.c',
- 'src/core/lib/support/tmpfile_msys.c',
- 'src/core/lib/support/tmpfile_posix.c',
- 'src/core/lib/support/tmpfile_windows.c',
- 'src/core/lib/support/wrap_memcpy.c',
+ 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/mpscq.h',
+ 'src/core/lib/gpr/murmur_hash.h',
+ 'src/core/lib/gpr/spinlock.h',
+ '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/tmpfile.h',
+ 'src/core/lib/gprpp/abstract.h',
+ 'src/core/lib/gprpp/atomic.h',
+ 'src/core/lib/gprpp/atomic_with_atm.h',
+ 'src/core/lib/gprpp/atomic_with_std.h',
+ 'src/core/lib/gprpp/manual_constructor.h',
+ 'src/core/lib/gprpp/memory.h',
+ 'src/core/lib/profiling/timers.h',
+ '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',
+ 'src/core/lib/gpr/cpu_posix.cc',
+ 'src/core/lib/gpr/cpu_windows.cc',
+ 'src/core/lib/gpr/env_linux.cc',
+ 'src/core/lib/gpr/env_posix.cc',
+ 'src/core/lib/gpr/env_windows.cc',
+ 'src/core/lib/gpr/fork.cc',
+ 'src/core/lib/gpr/host_port.cc',
+ 'src/core/lib/gpr/log.cc',
+ 'src/core/lib/gpr/log_android.cc',
+ 'src/core/lib/gpr/log_linux.cc',
+ 'src/core/lib/gpr/log_posix.cc',
+ 'src/core/lib/gpr/log_windows.cc',
+ 'src/core/lib/gpr/mpscq.cc',
+ 'src/core/lib/gpr/murmur_hash.cc',
+ 'src/core/lib/gpr/string.cc',
+ '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',
+ 'src/core/lib/gpr/thd.cc',
+ 'src/core/lib/gpr/thd_posix.cc',
+ 'src/core/lib/gpr/thd_windows.cc',
+ 'src/core/lib/gpr/time.cc',
+ 'src/core/lib/gpr/time_posix.cc',
+ 'src/core/lib/gpr/time_precise.cc',
+ 'src/core/lib/gpr/time_windows.cc',
+ 'src/core/lib/gpr/tls_pthread.cc',
+ '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/wrap_memcpy.cc',
+ 'src/core/lib/profiling/basic_timers.cc',
+ 'src/core/lib/profiling/stap_timers.cc',
'src/core/ext/transport/chttp2/transport/bin_decoder.h',
'src/core/ext/transport/chttp2/transport/bin_encoder.h',
'src/core/ext/transport/chttp2/transport/chttp2_transport.h',
+ 'src/core/ext/transport/chttp2/transport/flow_control.h',
'src/core/ext/transport/chttp2/transport/frame.h',
'src/core/ext/transport/chttp2/transport/frame_data.h',
'src/core/ext/transport/chttp2/transport/frame_goaway.h',
@@ -289,8 +298,8 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/security_handshaker.h',
'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h',
+ 'src/core/tsi/alts_transport_security.h',
'src/core/tsi/fake_transport_security.h',
- 'src/core/tsi/gts_transport_security.h',
'src/core/tsi/ssl_transport_security.h',
'src/core/tsi/ssl_types.h',
'src/core/tsi/transport_security_grpc.h',
@@ -298,6 +307,7 @@ Pod::Spec.new do |s|
'src/core/tsi/transport_security_adapter.h',
'src/core/tsi/transport_security_interface.h',
'src/core/ext/transport/chttp2/server/chttp2_server.h',
+ 'src/core/ext/filters/client_channel/backup_poller.h',
'src/core/ext/filters/client_channel/client_channel.h',
'src/core/ext/filters/client_channel/client_channel_factory.h',
'src/core/ext/filters/client_channel/connector.h',
@@ -319,6 +329,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/backoff/backoff.h',
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
@@ -328,15 +339,22 @@ Pod::Spec.new do |s|
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/compression/algorithm_metadata.h',
+ 'src/core/lib/compression/compression_internal.h',
'src/core/lib/compression/message_compress.h',
'src/core/lib/compression/stream_compression.h',
'src/core/lib/compression/stream_compression_gzip.h',
'src/core/lib/compression/stream_compression_identity.h',
'src/core/lib/debug/stats.h',
'src/core/lib/debug/stats_data.h',
+ 'src/core/lib/gprpp/debug_location.h',
+ 'src/core/lib/gprpp/inlined_vector.h',
+ 'src/core/lib/gprpp/orphanable.h',
+ 'src/core/lib/gprpp/ref_counted.h',
+ 'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/http/format_request.h',
'src/core/lib/http/httpcli.h',
'src/core/lib/http/parser.h',
+ 'src/core/lib/iomgr/block_annotate.h',
'src/core/lib/iomgr/call_combiner.h',
'src/core/lib/iomgr/closure.h',
'src/core/lib/iomgr/combiner.h',
@@ -444,311 +462,288 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h',
'src/core/ext/filters/load_reporting/server_load_reporting_filter.h',
'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h',
- 'src/core/ext/census/aggregation.h',
- 'src/core/ext/census/base_resources.h',
- 'src/core/ext/census/census_interface.h',
- 'src/core/ext/census/census_rpc_stats.h',
- 'src/core/ext/census/gen/census.pb.h',
- 'src/core/ext/census/gen/trace_context.pb.h',
- 'src/core/ext/census/grpc_filter.h',
- 'src/core/ext/census/intrusive_hash_map.h',
- 'src/core/ext/census/intrusive_hash_map_internal.h',
- 'src/core/ext/census/mlog.h',
- 'src/core/ext/census/resource.h',
- 'src/core/ext/census/rpc_metric_id.h',
- 'src/core/ext/census/trace_context.h',
- 'src/core/ext/census/trace_label.h',
- 'src/core/ext/census/trace_propagation.h',
- 'src/core/ext/census/trace_status.h',
- 'src/core/ext/census/trace_string.h',
- 'src/core/ext/census/tracing.h',
'src/core/ext/filters/max_age/max_age_filter.h',
'src/core/ext/filters/message_size/message_size_filter.h',
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h',
'src/core/ext/filters/workarounds/workaround_utils.h',
- 'src/core/lib/surface/init.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
+ 'src/core/lib/surface/init.cc',
+ 'src/core/lib/backoff/backoff.cc',
+ 'src/core/lib/channel/channel_args.cc',
+ 'src/core/lib/channel/channel_stack.cc',
+ 'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/connected_channel.cc',
+ 'src/core/lib/channel/handshaker.cc',
+ 'src/core/lib/channel/handshaker_factory.cc',
+ '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',
+ 'src/core/lib/compression/stream_compression_identity.cc',
+ 'src/core/lib/debug/stats.cc',
+ 'src/core/lib/debug/stats_data.cc',
+ 'src/core/lib/http/format_request.cc',
+ 'src/core/lib/http/httpcli.cc',
+ 'src/core/lib/http/parser.cc',
+ 'src/core/lib/iomgr/call_combiner.cc',
+ 'src/core/lib/iomgr/combiner.cc',
+ 'src/core/lib/iomgr/endpoint.cc',
+ 'src/core/lib/iomgr/endpoint_pair_posix.cc',
+ 'src/core/lib/iomgr/endpoint_pair_uv.cc',
+ 'src/core/lib/iomgr/endpoint_pair_windows.cc',
+ 'src/core/lib/iomgr/error.cc',
+ 'src/core/lib/iomgr/ev_epoll1_linux.cc',
+ 'src/core/lib/iomgr/ev_epollex_linux.cc',
+ 'src/core/lib/iomgr/ev_epollsig_linux.cc',
+ 'src/core/lib/iomgr/ev_poll_posix.cc',
+ 'src/core/lib/iomgr/ev_posix.cc',
+ 'src/core/lib/iomgr/ev_windows.cc',
+ 'src/core/lib/iomgr/exec_ctx.cc',
+ 'src/core/lib/iomgr/executor.cc',
+ 'src/core/lib/iomgr/fork_posix.cc',
+ 'src/core/lib/iomgr/fork_windows.cc',
+ 'src/core/lib/iomgr/gethostname_fallback.cc',
+ 'src/core/lib/iomgr/gethostname_host_name_max.cc',
+ 'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/iocp_windows.cc',
+ 'src/core/lib/iomgr/iomgr.cc',
+ 'src/core/lib/iomgr/iomgr_posix.cc',
+ 'src/core/lib/iomgr/iomgr_uv.cc',
+ 'src/core/lib/iomgr/iomgr_windows.cc',
+ 'src/core/lib/iomgr/is_epollexclusive_available.cc',
+ 'src/core/lib/iomgr/load_file.cc',
+ 'src/core/lib/iomgr/lockfree_event.cc',
+ 'src/core/lib/iomgr/network_status_tracker.cc',
+ 'src/core/lib/iomgr/polling_entity.cc',
+ 'src/core/lib/iomgr/pollset_set_uv.cc',
+ 'src/core/lib/iomgr/pollset_set_windows.cc',
+ 'src/core/lib/iomgr/pollset_uv.cc',
+ 'src/core/lib/iomgr/pollset_windows.cc',
+ 'src/core/lib/iomgr/resolve_address_posix.cc',
+ 'src/core/lib/iomgr/resolve_address_uv.cc',
+ 'src/core/lib/iomgr/resolve_address_windows.cc',
+ 'src/core/lib/iomgr/resource_quota.cc',
+ 'src/core/lib/iomgr/sockaddr_utils.cc',
+ 'src/core/lib/iomgr/socket_factory_posix.cc',
+ 'src/core/lib/iomgr/socket_mutator.cc',
+ 'src/core/lib/iomgr/socket_utils_common_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_linux.cc',
+ 'src/core/lib/iomgr/socket_utils_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_uv.cc',
+ 'src/core/lib/iomgr/socket_utils_windows.cc',
+ 'src/core/lib/iomgr/socket_windows.cc',
+ 'src/core/lib/iomgr/tcp_client_posix.cc',
+ 'src/core/lib/iomgr/tcp_client_uv.cc',
+ 'src/core/lib/iomgr/tcp_client_windows.cc',
+ 'src/core/lib/iomgr/tcp_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_uv.cc',
+ 'src/core/lib/iomgr/tcp_server_windows.cc',
+ 'src/core/lib/iomgr/tcp_uv.cc',
+ 'src/core/lib/iomgr/tcp_windows.cc',
+ 'src/core/lib/iomgr/time_averaged_stats.cc',
+ 'src/core/lib/iomgr/timer_generic.cc',
+ 'src/core/lib/iomgr/timer_heap.cc',
+ 'src/core/lib/iomgr/timer_manager.cc',
+ 'src/core/lib/iomgr/timer_uv.cc',
+ 'src/core/lib/iomgr/udp_server.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.cc',
+ 'src/core/lib/iomgr/wakeup_fd_cv.cc',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.cc',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.cc',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.cc',
+ 'src/core/lib/iomgr/wakeup_fd_posix.cc',
+ 'src/core/lib/json/json.cc',
+ 'src/core/lib/json/json_reader.cc',
+ 'src/core/lib/json/json_string.cc',
+ 'src/core/lib/json/json_writer.cc',
+ 'src/core/lib/slice/b64.cc',
+ 'src/core/lib/slice/percent_encoding.cc',
+ 'src/core/lib/slice/slice.cc',
+ 'src/core/lib/slice/slice_buffer.cc',
+ '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',
+ 'src/core/lib/surface/call.cc',
+ 'src/core/lib/surface/call_details.cc',
+ 'src/core/lib/surface/call_log_batch.cc',
+ 'src/core/lib/surface/channel.cc',
+ 'src/core/lib/surface/channel_init.cc',
+ 'src/core/lib/surface/channel_ping.cc',
+ 'src/core/lib/surface/channel_stack_type.cc',
+ 'src/core/lib/surface/completion_queue.cc',
+ 'src/core/lib/surface/completion_queue_factory.cc',
+ 'src/core/lib/surface/event_string.cc',
'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
- 'src/core/lib/http/httpcli_security_connector.c',
- 'src/core/lib/security/context/security_context.c',
- 'src/core/lib/security/credentials/composite/composite_credentials.c',
- 'src/core/lib/security/credentials/credentials.c',
- 'src/core/lib/security/credentials/credentials_metadata.c',
- 'src/core/lib/security/credentials/fake/fake_credentials.c',
- 'src/core/lib/security/credentials/google_default/credentials_generic.c',
- 'src/core/lib/security/credentials/google_default/google_default_credentials.c',
- 'src/core/lib/security/credentials/iam/iam_credentials.c',
- 'src/core/lib/security/credentials/jwt/json_token.c',
- 'src/core/lib/security/credentials/jwt/jwt_credentials.c',
- 'src/core/lib/security/credentials/jwt/jwt_verifier.c',
- 'src/core/lib/security/credentials/oauth2/oauth2_credentials.c',
- 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
- 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
- 'src/core/lib/security/transport/client_auth_filter.c',
- 'src/core/lib/security/transport/lb_targets_info.c',
- 'src/core/lib/security/transport/secure_endpoint.c',
- 'src/core/lib/security/transport/security_connector.c',
- 'src/core/lib/security/transport/security_handshaker.c',
- 'src/core/lib/security/transport/server_auth_filter.c',
- 'src/core/lib/security/transport/tsi_error.c',
- 'src/core/lib/security/util/json_util.c',
- 'src/core/lib/surface/init_secure.c',
- 'src/core/tsi/fake_transport_security.c',
- 'src/core/tsi/gts_transport_security.c',
- 'src/core/tsi/ssl_transport_security.c',
- 'src/core/tsi/transport_security_grpc.c',
- 'src/core/tsi/transport_security.c',
- 'src/core/tsi/transport_security_adapter.c',
- 'src/core/ext/transport/chttp2/server/chttp2_server.c',
- 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/chttp2/client/chttp2_connector.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
- 'src/core/ext/transport/inproc/inproc_plugin.c',
- 'src/core/ext/transport/inproc/inproc_transport.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
+ 'src/core/lib/surface/metadata_array.cc',
+ 'src/core/lib/surface/server.cc',
+ 'src/core/lib/surface/validate_metadata.cc',
+ 'src/core/lib/surface/version.cc',
+ 'src/core/lib/transport/bdp_estimator.cc',
+ 'src/core/lib/transport/byte_stream.cc',
+ 'src/core/lib/transport/connectivity_state.cc',
+ 'src/core/lib/transport/error_utils.cc',
+ 'src/core/lib/transport/metadata.cc',
+ 'src/core/lib/transport/metadata_batch.cc',
+ 'src/core/lib/transport/pid_controller.cc',
+ 'src/core/lib/transport/service_config.cc',
+ 'src/core/lib/transport/static_metadata.cc',
+ 'src/core/lib/transport/status_conversion.cc',
+ 'src/core/lib/transport/timeout_encoding.cc',
+ 'src/core/lib/transport/transport.cc',
+ 'src/core/lib/transport/transport_op_string.cc',
+ 'src/core/lib/debug/trace.cc',
+ 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc',
+ 'src/core/ext/transport/chttp2/transport/flow_control.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_data.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.cc',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.cc',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.cc',
+ 'src/core/ext/transport/chttp2/transport/parsing.cc',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.cc',
+ '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/ext/transport/chttp2/alpn/alpn.cc',
+ 'src/core/ext/filters/http/client/http_client_filter.cc',
+ 'src/core/ext/filters/http/http_filters_plugin.cc',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
+ 'src/core/ext/filters/http/server/http_server_filter.cc',
+ 'src/core/lib/http/httpcli_security_connector.cc',
+ 'src/core/lib/security/context/security_context.cc',
+ 'src/core/lib/security/credentials/composite/composite_credentials.cc',
+ 'src/core/lib/security/credentials/credentials.cc',
+ 'src/core/lib/security/credentials/credentials_metadata.cc',
+ 'src/core/lib/security/credentials/fake/fake_credentials.cc',
+ 'src/core/lib/security/credentials/google_default/credentials_generic.cc',
+ 'src/core/lib/security/credentials/google_default/google_default_credentials.cc',
+ 'src/core/lib/security/credentials/iam/iam_credentials.cc',
+ 'src/core/lib/security/credentials/jwt/json_token.cc',
+ 'src/core/lib/security/credentials/jwt/jwt_credentials.cc',
+ 'src/core/lib/security/credentials/jwt/jwt_verifier.cc',
+ 'src/core/lib/security/credentials/oauth2/oauth2_credentials.cc',
+ 'src/core/lib/security/credentials/plugin/plugin_credentials.cc',
+ 'src/core/lib/security/credentials/ssl/ssl_credentials.cc',
+ 'src/core/lib/security/transport/client_auth_filter.cc',
+ 'src/core/lib/security/transport/lb_targets_info.cc',
+ 'src/core/lib/security/transport/secure_endpoint.cc',
+ 'src/core/lib/security/transport/security_connector.cc',
+ 'src/core/lib/security/transport/security_handshaker.cc',
+ 'src/core/lib/security/transport/server_auth_filter.cc',
+ 'src/core/lib/security/transport/tsi_error.cc',
+ 'src/core/lib/security/util/json_util.cc',
+ 'src/core/lib/surface/init_secure.cc',
+ 'src/core/tsi/alts_transport_security.cc',
+ 'src/core/tsi/fake_transport_security.cc',
+ 'src/core/tsi/ssl_transport_security.cc',
+ 'src/core/tsi/transport_security_grpc.cc',
+ 'src/core/tsi/transport_security.cc',
+ 'src/core/tsi/transport_security_adapter.cc',
+ 'src/core/ext/transport/chttp2/server/chttp2_server.cc',
+ 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc',
+ 'src/core/ext/filters/client_channel/backup_poller.cc',
+ 'src/core/ext/filters/client_channel/channel_connectivity.cc',
+ 'src/core/ext/filters/client_channel/client_channel.cc',
+ 'src/core/ext/filters/client_channel/client_channel_factory.cc',
+ 'src/core/ext/filters/client_channel/client_channel_plugin.cc',
+ 'src/core/ext/filters/client_channel/connector.cc',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
+ 'src/core/ext/filters/client_channel/http_proxy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.cc',
+ 'src/core/ext/filters/client_channel/parse_address.cc',
+ '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',
+ 'src/core/ext/filters/client_channel/subchannel_index.cc',
+ 'src/core/ext/filters/client_channel/uri_parser.cc',
+ 'src/core/ext/filters/deadline/deadline_filter.cc',
+ 'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc',
+ 'src/core/ext/transport/inproc/inproc_plugin.cc',
+ 'src/core/ext/transport/inproc/inproc_transport.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c',
- 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c',
- 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c',
- 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c',
- 'src/core/ext/census/base_resources.c',
- 'src/core/ext/census/context.c',
- 'src/core/ext/census/gen/census.pb.c',
- 'src/core/ext/census/gen/trace_context.pb.c',
- 'src/core/ext/census/grpc_context.c',
- 'src/core/ext/census/grpc_filter.c',
- 'src/core/ext/census/grpc_plugin.c',
- 'src/core/ext/census/initialize.c',
- 'src/core/ext/census/intrusive_hash_map.c',
- 'src/core/ext/census/mlog.c',
- 'src/core/ext/census/operation.c',
- 'src/core/ext/census/placeholders.c',
- 'src/core/ext/census/resource.c',
- 'src/core/ext/census/trace_context.c',
- 'src/core/ext/census/tracing.c',
- 'src/core/ext/filters/max_age/max_age_filter.c',
- 'src/core/ext/filters/message_size/message_size_filter.c',
- 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c',
- 'src/core/ext/filters/workarounds/workaround_utils.c',
- 'src/core/plugin_registry/grpc_plugin_registry.c'
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
+ 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_filter.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc',
+ 'src/core/ext/census/grpc_context.cc',
+ 'src/core/ext/filters/max_age/max_age_filter.cc',
+ 'src/core/ext/filters/message_size/message_size_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_utils.cc',
+ 'src/core/plugin_registry/grpc_plugin_registry.cc'
- ss.private_header_files = 'src/core/lib/profiling/timers.h',
- 'src/core/lib/support/arena.h',
- 'src/core/lib/support/atomic.h',
- 'src/core/lib/support/atomic_with_atm.h',
- 'src/core/lib/support/atomic_with_std.h',
- 'src/core/lib/support/backoff.h',
- 'src/core/lib/support/block_annotate.h',
- 'src/core/lib/support/env.h',
- 'src/core/lib/support/memory.h',
- 'src/core/lib/support/mpscq.h',
- 'src/core/lib/support/murmur_hash.h',
- 'src/core/lib/support/spinlock.h',
- 'src/core/lib/support/stack_lockfree.h',
- 'src/core/lib/support/string.h',
- 'src/core/lib/support/string_windows.h',
- 'src/core/lib/support/time_precise.h',
- 'src/core/lib/support/tmpfile.h',
+ 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/mpscq.h',
+ 'src/core/lib/gpr/murmur_hash.h',
+ 'src/core/lib/gpr/spinlock.h',
+ '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/tmpfile.h',
+ 'src/core/lib/gprpp/abstract.h',
+ 'src/core/lib/gprpp/atomic.h',
+ 'src/core/lib/gprpp/atomic_with_atm.h',
+ 'src/core/lib/gprpp/atomic_with_std.h',
+ 'src/core/lib/gprpp/manual_constructor.h',
+ 'src/core/lib/gprpp/memory.h',
+ 'src/core/lib/profiling/timers.h',
'src/core/ext/transport/chttp2/transport/bin_decoder.h',
'src/core/ext/transport/chttp2/transport/bin_encoder.h',
'src/core/ext/transport/chttp2/transport/chttp2_transport.h',
+ 'src/core/ext/transport/chttp2/transport/flow_control.h',
'src/core/ext/transport/chttp2/transport/frame.h',
'src/core/ext/transport/chttp2/transport/frame_data.h',
'src/core/ext/transport/chttp2/transport/frame_goaway.h',
@@ -788,8 +783,8 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/security_handshaker.h',
'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h',
+ 'src/core/tsi/alts_transport_security.h',
'src/core/tsi/fake_transport_security.h',
- 'src/core/tsi/gts_transport_security.h',
'src/core/tsi/ssl_transport_security.h',
'src/core/tsi/ssl_types.h',
'src/core/tsi/transport_security_grpc.h',
@@ -797,6 +792,7 @@ Pod::Spec.new do |s|
'src/core/tsi/transport_security_adapter.h',
'src/core/tsi/transport_security_interface.h',
'src/core/ext/transport/chttp2/server/chttp2_server.h',
+ 'src/core/ext/filters/client_channel/backup_poller.h',
'src/core/ext/filters/client_channel/client_channel.h',
'src/core/ext/filters/client_channel/client_channel_factory.h',
'src/core/ext/filters/client_channel/connector.h',
@@ -818,6 +814,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/backoff/backoff.h',
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
@@ -827,15 +824,22 @@ Pod::Spec.new do |s|
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/compression/algorithm_metadata.h',
+ 'src/core/lib/compression/compression_internal.h',
'src/core/lib/compression/message_compress.h',
'src/core/lib/compression/stream_compression.h',
'src/core/lib/compression/stream_compression_gzip.h',
'src/core/lib/compression/stream_compression_identity.h',
'src/core/lib/debug/stats.h',
'src/core/lib/debug/stats_data.h',
+ 'src/core/lib/gprpp/debug_location.h',
+ 'src/core/lib/gprpp/inlined_vector.h',
+ 'src/core/lib/gprpp/orphanable.h',
+ 'src/core/lib/gprpp/ref_counted.h',
+ 'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/http/format_request.h',
'src/core/lib/http/httpcli.h',
'src/core/lib/http/parser.h',
+ 'src/core/lib/iomgr/block_annotate.h',
'src/core/lib/iomgr/call_combiner.h',
'src/core/lib/iomgr/closure.h',
'src/core/lib/iomgr/combiner.h',
@@ -943,28 +947,11 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h',
'src/core/ext/filters/load_reporting/server_load_reporting_filter.h',
'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h',
- 'src/core/ext/census/aggregation.h',
- 'src/core/ext/census/base_resources.h',
- 'src/core/ext/census/census_interface.h',
- 'src/core/ext/census/census_rpc_stats.h',
- 'src/core/ext/census/gen/census.pb.h',
- 'src/core/ext/census/gen/trace_context.pb.h',
- 'src/core/ext/census/grpc_filter.h',
- 'src/core/ext/census/intrusive_hash_map.h',
- 'src/core/ext/census/intrusive_hash_map_internal.h',
- 'src/core/ext/census/mlog.h',
- 'src/core/ext/census/resource.h',
- 'src/core/ext/census/rpc_metric_id.h',
- 'src/core/ext/census/trace_context.h',
- 'src/core/ext/census/trace_label.h',
- 'src/core/ext/census/trace_propagation.h',
- 'src/core/ext/census/trace_status.h',
- 'src/core/ext/census/trace_string.h',
- 'src/core/ext/census/tracing.h',
'src/core/ext/filters/max_age/max_age_filter.h',
'src/core/ext/filters/message_size/message_size_filter.h',
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h',
@@ -983,8 +970,9 @@ Pod::Spec.new do |s|
ss.dependency "#{s.name}/Implementation", version
ss.dependency "#{s.name}/Cronet-Interface", version
- ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c',
- 'src/core/ext/transport/cronet/transport/cronet_transport.{c,h}',
+ ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc',
+ 'src/core/ext/transport/cronet/transport/cronet_transport.cc',
+ 'src/core/ext/transport/cronet/transport/cronet_transport.h',
'third_party/objective_c/Cronet/bidirectional_stream_c.h'
end
@@ -994,21 +982,116 @@ Pod::Spec.new do |s|
ss.dependency "#{s.name}/Interface", version
ss.dependency "#{s.name}/Implementation", version
- ss.source_files = 'test/core/end2end/cq_verifier.{c,h}',
- 'test/core/end2end/end2end_tests.{c,h}',
- 'test/core/end2end/end2end_test_utils.c',
- 'test/core/end2end/tests/*.{c,h}',
- 'test/core/end2end/fixtures/*.h',
- 'test/core/end2end/data/*.{c,h}',
- 'test/core/util/debugger_macros.{c,h}',
- 'test/core/util/test_config.{c,h}',
+ ss.source_files = 'test/core/util/test_config.cc',
+ 'test/core/util/test_config.h',
+ 'test/core/end2end/data/client_certs.cc',
+ 'test/core/end2end/data/server1_cert.cc',
+ 'test/core/end2end/data/server1_key.cc',
+ 'test/core/end2end/data/test_root_cert.cc',
+ 'test/core/security/oauth2_utils.cc',
+ 'test/core/end2end/cq_verifier.cc',
+ 'test/core/end2end/fixtures/http_proxy_fixture.cc',
+ 'test/core/end2end/fixtures/proxy.cc',
+ 'test/core/iomgr/endpoint_tests.cc',
+ 'test/core/util/debugger_macros.cc',
+ 'test/core/util/grpc_profiler.cc',
+ 'test/core/util/histogram.cc',
+ 'test/core/util/memory_counters.cc',
+ 'test/core/util/mock_endpoint.cc',
+ 'test/core/util/parse_hexstring.cc',
+ 'test/core/util/passthru_endpoint.cc',
+ 'test/core/util/port.cc',
+ 'test/core/util/port_isolated_runtime_environment.cc',
+ 'test/core/util/port_server_client.cc',
+ 'test/core/util/slice_splitter.cc',
+ 'test/core/util/tracer_util.cc',
+ 'test/core/util/trickle_endpoint.cc',
+ 'test/core/end2end/data/ssl_test_data.h',
+ 'test/core/security/oauth2_utils.h',
+ 'test/core/end2end/cq_verifier.h',
+ 'test/core/end2end/fixtures/http_proxy_fixture.h',
+ 'test/core/end2end/fixtures/proxy.h',
+ 'test/core/iomgr/endpoint_tests.h',
+ 'test/core/util/debugger_macros.h',
+ 'test/core/util/grpc_profiler.h',
+ 'test/core/util/histogram.h',
+ 'test/core/util/memory_counters.h',
+ 'test/core/util/mock_endpoint.h',
+ 'test/core/util/parse_hexstring.h',
+ 'test/core/util/passthru_endpoint.h',
'test/core/util/port.h',
- 'test/core/util/port.c',
- 'test/core/util/port_server_client.{c,h}'
+ 'test/core/util/port_server_client.h',
+ 'test/core/util/slice_splitter.h',
+ 'test/core/util/tracer_util.h',
+ 'test/core/util/trickle_endpoint.h',
+ 'test/core/end2end/end2end_tests.cc',
+ 'test/core/end2end/end2end_test_utils.cc',
+ 'test/core/end2end/tests/authority_not_supported.cc',
+ 'test/core/end2end/tests/bad_hostname.cc',
+ 'test/core/end2end/tests/bad_ping.cc',
+ 'test/core/end2end/tests/binary_metadata.cc',
+ 'test/core/end2end/tests/call_creds.cc',
+ 'test/core/end2end/tests/cancel_after_accept.cc',
+ 'test/core/end2end/tests/cancel_after_client_done.cc',
+ 'test/core/end2end/tests/cancel_after_invoke.cc',
+ 'test/core/end2end/tests/cancel_after_round_trip.cc',
+ 'test/core/end2end/tests/cancel_before_invoke.cc',
+ 'test/core/end2end/tests/cancel_in_a_vacuum.cc',
+ 'test/core/end2end/tests/cancel_with_status.cc',
+ 'test/core/end2end/tests/compressed_payload.cc',
+ 'test/core/end2end/tests/connectivity.cc',
+ 'test/core/end2end/tests/default_host.cc',
+ 'test/core/end2end/tests/disappearing_server.cc',
+ 'test/core/end2end/tests/empty_batch.cc',
+ 'test/core/end2end/tests/filter_call_init_fails.cc',
+ 'test/core/end2end/tests/filter_causes_close.cc',
+ 'test/core/end2end/tests/filter_latency.cc',
+ 'test/core/end2end/tests/filter_status_code.cc',
+ 'test/core/end2end/tests/graceful_server_shutdown.cc',
+ 'test/core/end2end/tests/high_initial_seqno.cc',
+ 'test/core/end2end/tests/hpack_size.cc',
+ 'test/core/end2end/tests/idempotent_request.cc',
+ 'test/core/end2end/tests/invoke_large_request.cc',
+ 'test/core/end2end/tests/keepalive_timeout.cc',
+ 'test/core/end2end/tests/large_metadata.cc',
+ 'test/core/end2end/tests/load_reporting_hook.cc',
+ 'test/core/end2end/tests/max_concurrent_streams.cc',
+ 'test/core/end2end/tests/max_connection_age.cc',
+ 'test/core/end2end/tests/max_connection_idle.cc',
+ 'test/core/end2end/tests/max_message_length.cc',
+ 'test/core/end2end/tests/negative_deadline.cc',
+ 'test/core/end2end/tests/network_status_change.cc',
+ 'test/core/end2end/tests/no_logging.cc',
+ 'test/core/end2end/tests/no_op.cc',
+ 'test/core/end2end/tests/payload.cc',
+ 'test/core/end2end/tests/ping.cc',
+ 'test/core/end2end/tests/ping_pong_streaming.cc',
+ 'test/core/end2end/tests/proxy_auth.cc',
+ 'test/core/end2end/tests/registered_call.cc',
+ 'test/core/end2end/tests/request_with_flags.cc',
+ 'test/core/end2end/tests/request_with_payload.cc',
+ 'test/core/end2end/tests/resource_quota_server.cc',
+ 'test/core/end2end/tests/server_finishes_request.cc',
+ 'test/core/end2end/tests/shutdown_finishes_calls.cc',
+ 'test/core/end2end/tests/shutdown_finishes_tags.cc',
+ 'test/core/end2end/tests/simple_cacheable_request.cc',
+ 'test/core/end2end/tests/simple_delayed_request.cc',
+ 'test/core/end2end/tests/simple_metadata.cc',
+ 'test/core/end2end/tests/simple_request.cc',
+ 'test/core/end2end/tests/stream_compression_compressed_payload.cc',
+ 'test/core/end2end/tests/stream_compression_payload.cc',
+ 'test/core/end2end/tests/stream_compression_ping_pong_streaming.cc',
+ 'test/core/end2end/tests/streaming_error_response.cc',
+ 'test/core/end2end/tests/trailing_metadata.cc',
+ 'test/core/end2end/tests/workaround_cronet_compression.cc',
+ 'test/core/end2end/tests/write_buffering.cc',
+ 'test/core/end2end/tests/write_buffering_at_end.cc',
+ 'test/core/end2end/tests/cancel_test_helpers.h',
+ 'test/core/end2end/end2end_tests.h'
end
# TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path?
s.prepare_command = <<-END_OF_COMMAND
- find src/core/ -type f -exec sed -E -i '.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/core/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
END_OF_COMMAND
end
diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec
index cb40330dab..a0375bd0b8 100644
--- a/gRPC-ProtoRPC.podspec
+++ b/gRPC-ProtoRPC.podspec
@@ -21,7 +21,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-ProtoRPC'
- version = '1.7.0-dev'
+ version = '1.10.0-dev'
s.version = version
s.summary = 'RPC library for Protocol Buffers, based on gRPC'
s.homepage = 'https://grpc.io'
@@ -52,5 +52,6 @@ Pod::Spec.new do |s|
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
}
end
diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec
index 52bd8ed0ae..280aafefb6 100644
--- a/gRPC-RxLibrary.podspec
+++ b/gRPC-RxLibrary.podspec
@@ -21,7 +21,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-RxLibrary'
- version = '1.7.0-dev'
+ version = '1.10.0-dev'
s.version = version
s.summary = 'Reactive Extensions library for iOS/OSX.'
s.homepage = 'https://grpc.io'
@@ -44,4 +44,8 @@ Pod::Spec.new do |s|
s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
s.private_header_files = "#{src_dir}/private/*.h"
s.header_mappings_dir = "#{src_dir}"
+
+ s.pod_target_xcconfig = {
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
+ }
end
diff --git a/gRPC.podspec b/gRPC.podspec
index 79315e46f3..930d991a6c 100644
--- a/gRPC.podspec
+++ b/gRPC.podspec
@@ -20,7 +20,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC'
- version = '1.7.0-dev'
+ version = '1.10.0-dev'
s.version = version
s.summary = 'gRPC client library for iOS/OSX'
s.homepage = 'https://grpc.io'
@@ -50,6 +50,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
}
s.subspec 'Main' do |ss|
@@ -63,10 +64,13 @@ Pod::Spec.new do |s|
end
s.subspec 'GID' do |ss|
+ ss.ios.deployment_target = '7.0'
+
ss.header_mappings_dir = "#{src_dir}"
ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}"
+ ss.dependency "#{s.name}/Main", version
ss.dependency 'Google/SignIn'
end
end
diff --git a/grpc.def b/grpc.def
index 558be60c3c..2bec47480a 100644
--- a/grpc.def
+++ b/grpc.def
@@ -1,42 +1,15 @@
EXPORTS
- census_initialize
- census_shutdown
- census_supported
- census_enabled
- census_context_create
- census_context_destroy
- census_context_get_status
- census_context_initialize_iterator
- census_context_next_tag
- census_context_get_tag
- census_context_encode
- census_context_decode
- census_trace_mask
- census_set_trace_mask
- census_start_rpc_op_timestamp
- census_start_client_rpc_op
- census_set_rpc_client_peer
- census_start_server_rpc_op
- census_start_op
- census_end_op
- census_trace_print
- census_trace_scan_start
- census_get_trace_record
- census_trace_scan_end
- census_define_resource
- census_delete_resource
- census_resource_id
- census_record_values
+ grpc_compression_algorithm_is_message
+ grpc_compression_algorithm_is_stream
grpc_compression_algorithm_parse
grpc_compression_algorithm_name
- grpc_stream_compression_algorithm_name
grpc_compression_algorithm_for_level
- grpc_stream_compression_algorithm_for_level
grpc_compression_options_init
grpc_compression_options_enable_algorithm
grpc_compression_options_disable_algorithm
grpc_compression_options_is_algorithm_enabled
- grpc_compression_options_is_stream_compression_algorithm_enabled
+ grpc_compression_algorithm_parse_ruby
+ grpc_compression_algorithm_name_ruby
grpc_metadata_array_init
grpc_metadata_array_destroy
grpc_call_details_init
@@ -54,6 +27,8 @@ EXPORTS
grpc_completion_queue_pluck
grpc_completion_queue_shutdown
grpc_completion_queue_destroy
+ grpc_completion_queue_thread_local_cache_init
+ grpc_completion_queue_thread_local_cache_flush
grpc_alarm_create
grpc_alarm_set
grpc_alarm_cancel
@@ -130,8 +105,14 @@ EXPORTS
grpc_metadata_credentials_create_from_plugin
grpc_secure_channel_create
grpc_server_credentials_release
+ grpc_ssl_server_certificate_config_create
+ grpc_ssl_server_certificate_config_destroy
grpc_ssl_server_credentials_create
grpc_ssl_server_credentials_create_ex
+ grpc_ssl_server_credentials_create_options_using_config
+ grpc_ssl_server_credentials_create_options_using_config_fetcher
+ grpc_ssl_server_credentials_options_destroy
+ grpc_ssl_server_credentials_create_with_options
grpc_server_add_secure_http2_port
grpc_call_set_credentials
grpc_server_credentials_set_auth_metadata_processor
@@ -169,7 +150,6 @@ EXPORTS
grpc_slice_eq
grpc_slice_cmp
grpc_slice_str_cmp
- grpc_slice_buf_cmp
grpc_slice_buf_start_eq
grpc_slice_rchr
grpc_slice_chr
@@ -221,21 +201,6 @@ EXPORTS
gpr_cmdline_usage_string
gpr_cpu_num_cores
gpr_cpu_current_cpu
- gpr_histogram_create
- gpr_histogram_destroy
- gpr_histogram_add
- gpr_histogram_merge
- gpr_histogram_percentile
- gpr_histogram_mean
- gpr_histogram_stddev
- gpr_histogram_variance
- gpr_histogram_maximum
- gpr_histogram_minimum
- gpr_histogram_count
- gpr_histogram_sum
- gpr_histogram_sum_of_squares
- gpr_histogram_get_contents
- gpr_histogram_merge_contents
gpr_join_host_port
gpr_split_host_port
gpr_log_severity_string
diff --git a/grpc.gemspec b/grpc.gemspec
index acf71cab78..43f5148add 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.add_dependency 'google-protobuf', '~> 3.1'
- s.add_dependency 'googleauth', '~> 0.5.1'
+ s.add_dependency 'googleauth', '>= 0.5.1', '< 0.7'
s.add_dependency 'googleapis-common-protos-types', '~> 1.0.0'
s.add_development_dependency 'bundler', '~> 1.9'
@@ -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/histogram.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 )
@@ -75,6 +74,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h )
s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h )
s.files += %w( include/grpc/impl/codegen/atm_windows.h )
+ s.files += %w( include/grpc/impl/codegen/fork.h )
s.files += %w( include/grpc/impl/codegen/gpr_slice.h )
s.files += %w( include/grpc/impl/codegen/gpr_types.h )
s.files += %w( include/grpc/impl/codegen/port_platform.h )
@@ -83,74 +83,72 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/sync_generic.h )
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/env.h )
+ s.files += %w( src/core/lib/gpr/fork.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 )
+ s.files += %w( src/core/lib/gpr/string.h )
+ 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/tmpfile.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 )
+ s.files += %w( src/core/lib/gprpp/atomic_with_std.h )
+ s.files += %w( src/core/lib/gprpp/manual_constructor.h )
+ s.files += %w( src/core/lib/gprpp/memory.h )
s.files += %w( src/core/lib/profiling/timers.h )
- s.files += %w( src/core/lib/support/arena.h )
- s.files += %w( src/core/lib/support/atomic.h )
- s.files += %w( src/core/lib/support/atomic_with_atm.h )
- s.files += %w( src/core/lib/support/atomic_with_std.h )
- s.files += %w( src/core/lib/support/backoff.h )
- s.files += %w( src/core/lib/support/block_annotate.h )
- s.files += %w( src/core/lib/support/env.h )
- s.files += %w( src/core/lib/support/memory.h )
- s.files += %w( src/core/lib/support/mpscq.h )
- s.files += %w( src/core/lib/support/murmur_hash.h )
- s.files += %w( src/core/lib/support/spinlock.h )
- s.files += %w( src/core/lib/support/stack_lockfree.h )
- s.files += %w( src/core/lib/support/string.h )
- s.files += %w( src/core/lib/support/string_windows.h )
- s.files += %w( src/core/lib/support/time_precise.h )
- s.files += %w( src/core/lib/support/tmpfile.h )
- s.files += %w( src/core/lib/profiling/basic_timers.c )
- s.files += %w( src/core/lib/profiling/stap_timers.c )
- s.files += %w( src/core/lib/support/alloc.c )
- s.files += %w( src/core/lib/support/arena.c )
- s.files += %w( src/core/lib/support/atm.c )
- s.files += %w( src/core/lib/support/avl.c )
- s.files += %w( src/core/lib/support/backoff.c )
- s.files += %w( src/core/lib/support/cmdline.c )
- s.files += %w( src/core/lib/support/cpu_iphone.c )
- s.files += %w( src/core/lib/support/cpu_linux.c )
- s.files += %w( src/core/lib/support/cpu_posix.c )
- s.files += %w( src/core/lib/support/cpu_windows.c )
- s.files += %w( src/core/lib/support/env_linux.c )
- s.files += %w( src/core/lib/support/env_posix.c )
- s.files += %w( src/core/lib/support/env_windows.c )
- s.files += %w( src/core/lib/support/histogram.c )
- s.files += %w( src/core/lib/support/host_port.c )
- s.files += %w( src/core/lib/support/log.c )
- s.files += %w( src/core/lib/support/log_android.c )
- s.files += %w( src/core/lib/support/log_linux.c )
- s.files += %w( src/core/lib/support/log_posix.c )
- s.files += %w( src/core/lib/support/log_windows.c )
- s.files += %w( src/core/lib/support/mpscq.c )
- s.files += %w( src/core/lib/support/murmur_hash.c )
- s.files += %w( src/core/lib/support/stack_lockfree.c )
- s.files += %w( src/core/lib/support/string.c )
- s.files += %w( src/core/lib/support/string_posix.c )
- s.files += %w( src/core/lib/support/string_util_windows.c )
- s.files += %w( src/core/lib/support/string_windows.c )
- s.files += %w( src/core/lib/support/subprocess_posix.c )
- s.files += %w( src/core/lib/support/subprocess_windows.c )
- s.files += %w( src/core/lib/support/sync.c )
- s.files += %w( src/core/lib/support/sync_posix.c )
- s.files += %w( src/core/lib/support/sync_windows.c )
- s.files += %w( src/core/lib/support/thd.c )
- s.files += %w( src/core/lib/support/thd_posix.c )
- s.files += %w( src/core/lib/support/thd_windows.c )
- s.files += %w( src/core/lib/support/time.c )
- s.files += %w( src/core/lib/support/time_posix.c )
- s.files += %w( src/core/lib/support/time_precise.c )
- s.files += %w( src/core/lib/support/time_windows.c )
- s.files += %w( src/core/lib/support/tls_pthread.c )
- s.files += %w( src/core/lib/support/tmpfile_msys.c )
- s.files += %w( src/core/lib/support/tmpfile_posix.c )
- s.files += %w( src/core/lib/support/tmpfile_windows.c )
- s.files += %w( src/core/lib/support/wrap_memcpy.c )
+ 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 )
+ s.files += %w( src/core/lib/gpr/cpu_posix.cc )
+ s.files += %w( src/core/lib/gpr/cpu_windows.cc )
+ s.files += %w( src/core/lib/gpr/env_linux.cc )
+ s.files += %w( src/core/lib/gpr/env_posix.cc )
+ s.files += %w( src/core/lib/gpr/env_windows.cc )
+ s.files += %w( src/core/lib/gpr/fork.cc )
+ s.files += %w( src/core/lib/gpr/host_port.cc )
+ s.files += %w( src/core/lib/gpr/log.cc )
+ s.files += %w( src/core/lib/gpr/log_android.cc )
+ s.files += %w( src/core/lib/gpr/log_linux.cc )
+ s.files += %w( src/core/lib/gpr/log_posix.cc )
+ s.files += %w( src/core/lib/gpr/log_windows.cc )
+ s.files += %w( src/core/lib/gpr/mpscq.cc )
+ s.files += %w( src/core/lib/gpr/murmur_hash.cc )
+ s.files += %w( src/core/lib/gpr/string.cc )
+ 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 )
+ s.files += %w( src/core/lib/gpr/thd.cc )
+ s.files += %w( src/core/lib/gpr/thd_posix.cc )
+ s.files += %w( src/core/lib/gpr/thd_windows.cc )
+ s.files += %w( src/core/lib/gpr/time.cc )
+ s.files += %w( src/core/lib/gpr/time_posix.cc )
+ s.files += %w( src/core/lib/gpr/time_precise.cc )
+ s.files += %w( src/core/lib/gpr/time_windows.cc )
+ s.files += %w( src/core/lib/gpr/tls_pthread.cc )
+ s.files += %w( src/core/lib/gpr/tmpfile_msys.cc )
+ s.files += %w( src/core/lib/gpr/tmpfile_posix.cc )
+ s.files += %w( src/core/lib/gpr/tmpfile_windows.cc )
+ s.files += %w( src/core/lib/gpr/wrap_memcpy.cc )
+ s.files += %w( src/core/lib/profiling/basic_timers.cc )
+ s.files += %w( src/core/lib/profiling/stap_timers.cc )
s.files += %w( include/grpc/impl/codegen/byte_buffer.h )
s.files += %w( include/grpc/impl/codegen/byte_buffer_reader.h )
s.files += %w( include/grpc/impl/codegen/compression_types.h )
s.files += %w( include/grpc/impl/codegen/connectivity_state.h )
- s.files += %w( include/grpc/impl/codegen/exec_ctx_fwd.h )
s.files += %w( include/grpc/impl/codegen/grpc_types.h )
s.files += %w( include/grpc/impl/codegen/propagation_bits.h )
s.files += %w( include/grpc/impl/codegen/slice.h )
@@ -159,6 +157,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h )
s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h )
s.files += %w( include/grpc/impl/codegen/atm_windows.h )
+ s.files += %w( include/grpc/impl/codegen/fork.h )
s.files += %w( include/grpc/impl/codegen/gpr_slice.h )
s.files += %w( include/grpc/impl/codegen/gpr_types.h )
s.files += %w( include/grpc/impl/codegen/port_platform.h )
@@ -171,6 +170,8 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/byte_buffer.h )
s.files += %w( include/grpc/byte_buffer_reader.h )
s.files += %w( include/grpc/compression.h )
+ s.files += %w( include/grpc/compression_ruby.h )
+ s.files += %w( include/grpc/fork.h )
s.files += %w( include/grpc/grpc.h )
s.files += %w( include/grpc/grpc_posix.h )
s.files += %w( include/grpc/grpc_security_constants.h )
@@ -183,6 +184,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/transport/bin_decoder.h )
s.files += %w( src/core/ext/transport/chttp2/transport/bin_encoder.h )
s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_transport.h )
+ s.files += %w( src/core/ext/transport/chttp2/transport/flow_control.h )
s.files += %w( src/core/ext/transport/chttp2/transport/frame.h )
s.files += %w( src/core/ext/transport/chttp2/transport/frame_data.h )
s.files += %w( src/core/ext/transport/chttp2/transport/frame_goaway.h )
@@ -222,8 +224,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/transport/security_handshaker.h )
s.files += %w( src/core/lib/security/transport/tsi_error.h )
s.files += %w( src/core/lib/security/util/json_util.h )
+ s.files += %w( src/core/tsi/alts_transport_security.h )
s.files += %w( src/core/tsi/fake_transport_security.h )
- s.files += %w( src/core/tsi/gts_transport_security.h )
s.files += %w( src/core/tsi/ssl_transport_security.h )
s.files += %w( src/core/tsi/ssl_types.h )
s.files += %w( src/core/tsi/transport_security_grpc.h )
@@ -231,6 +233,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/tsi/transport_security_adapter.h )
s.files += %w( src/core/tsi/transport_security_interface.h )
s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.h )
+ s.files += %w( src/core/ext/filters/client_channel/backup_poller.h )
s.files += %w( src/core/ext/filters/client_channel/client_channel.h )
s.files += %w( src/core/ext/filters/client_channel/client_channel_factory.h )
s.files += %w( src/core/ext/filters/client_channel/connector.h )
@@ -252,6 +255,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/backoff/backoff.h )
s.files += %w( src/core/lib/channel/channel_args.h )
s.files += %w( src/core/lib/channel/channel_stack.h )
s.files += %w( src/core/lib/channel/channel_stack_builder.h )
@@ -261,15 +265,22 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/handshaker_factory.h )
s.files += %w( src/core/lib/channel/handshaker_registry.h )
s.files += %w( src/core/lib/compression/algorithm_metadata.h )
+ s.files += %w( src/core/lib/compression/compression_internal.h )
s.files += %w( src/core/lib/compression/message_compress.h )
s.files += %w( src/core/lib/compression/stream_compression.h )
s.files += %w( src/core/lib/compression/stream_compression_gzip.h )
s.files += %w( src/core/lib/compression/stream_compression_identity.h )
s.files += %w( src/core/lib/debug/stats.h )
s.files += %w( src/core/lib/debug/stats_data.h )
+ s.files += %w( src/core/lib/gprpp/debug_location.h )
+ s.files += %w( src/core/lib/gprpp/inlined_vector.h )
+ s.files += %w( src/core/lib/gprpp/orphanable.h )
+ s.files += %w( src/core/lib/gprpp/ref_counted.h )
+ s.files += %w( src/core/lib/gprpp/ref_counted_ptr.h )
s.files += %w( src/core/lib/http/format_request.h )
s.files += %w( src/core/lib/http/httpcli.h )
s.files += %w( src/core/lib/http/parser.h )
+ s.files += %w( src/core/lib/iomgr/block_annotate.h )
s.files += %w( src/core/lib/iomgr/call_combiner.h )
s.files += %w( src/core/lib/iomgr/closure.h )
s.files += %w( src/core/lib/iomgr/combiner.h )
@@ -381,293 +392,268 @@ Gem::Specification.new do |s|
s.files += %w( third_party/nanopb/pb_decode.h )
s.files += %w( third_party/nanopb/pb_encode.h )
s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h )
s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_filter.h )
s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.h )
- s.files += %w( src/core/ext/census/aggregation.h )
- s.files += %w( src/core/ext/census/base_resources.h )
- s.files += %w( src/core/ext/census/census_interface.h )
- s.files += %w( src/core/ext/census/census_rpc_stats.h )
- s.files += %w( src/core/ext/census/gen/census.pb.h )
- s.files += %w( src/core/ext/census/gen/trace_context.pb.h )
- s.files += %w( src/core/ext/census/grpc_filter.h )
- s.files += %w( src/core/ext/census/intrusive_hash_map.h )
- s.files += %w( src/core/ext/census/intrusive_hash_map_internal.h )
- s.files += %w( src/core/ext/census/mlog.h )
- s.files += %w( src/core/ext/census/resource.h )
- s.files += %w( src/core/ext/census/rpc_metric_id.h )
- s.files += %w( src/core/ext/census/trace_context.h )
- s.files += %w( src/core/ext/census/trace_label.h )
- s.files += %w( src/core/ext/census/trace_propagation.h )
- s.files += %w( src/core/ext/census/trace_status.h )
- s.files += %w( src/core/ext/census/trace_string.h )
- s.files += %w( src/core/ext/census/tracing.h )
s.files += %w( src/core/ext/filters/max_age/max_age_filter.h )
s.files += %w( src/core/ext/filters/message_size/message_size_filter.h )
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.c )
- s.files += %w( src/core/lib/channel/channel_args.c )
- s.files += %w( src/core/lib/channel/channel_stack.c )
- s.files += %w( src/core/lib/channel/channel_stack_builder.c )
- s.files += %w( src/core/lib/channel/connected_channel.c )
- s.files += %w( src/core/lib/channel/handshaker.c )
- s.files += %w( src/core/lib/channel/handshaker_factory.c )
- s.files += %w( src/core/lib/channel/handshaker_registry.c )
- s.files += %w( src/core/lib/compression/compression.c )
- s.files += %w( src/core/lib/compression/message_compress.c )
- s.files += %w( src/core/lib/compression/stream_compression.c )
- s.files += %w( src/core/lib/compression/stream_compression_gzip.c )
- s.files += %w( src/core/lib/compression/stream_compression_identity.c )
- s.files += %w( src/core/lib/debug/stats.c )
- s.files += %w( src/core/lib/debug/stats_data.c )
- s.files += %w( src/core/lib/http/format_request.c )
- s.files += %w( src/core/lib/http/httpcli.c )
- s.files += %w( src/core/lib/http/parser.c )
- s.files += %w( src/core/lib/iomgr/call_combiner.c )
- s.files += %w( src/core/lib/iomgr/closure.c )
- s.files += %w( src/core/lib/iomgr/combiner.c )
- s.files += %w( src/core/lib/iomgr/endpoint.c )
- s.files += %w( src/core/lib/iomgr/endpoint_pair_posix.c )
- s.files += %w( src/core/lib/iomgr/endpoint_pair_uv.c )
- s.files += %w( src/core/lib/iomgr/endpoint_pair_windows.c )
- s.files += %w( src/core/lib/iomgr/error.c )
- s.files += %w( src/core/lib/iomgr/ev_epoll1_linux.c )
- s.files += %w( src/core/lib/iomgr/ev_epollex_linux.c )
- s.files += %w( src/core/lib/iomgr/ev_epollsig_linux.c )
- s.files += %w( src/core/lib/iomgr/ev_poll_posix.c )
- s.files += %w( src/core/lib/iomgr/ev_posix.c )
- s.files += %w( src/core/lib/iomgr/ev_windows.c )
- s.files += %w( src/core/lib/iomgr/exec_ctx.c )
- s.files += %w( src/core/lib/iomgr/executor.c )
- s.files += %w( src/core/lib/iomgr/gethostname_fallback.c )
- s.files += %w( src/core/lib/iomgr/gethostname_host_name_max.c )
- s.files += %w( src/core/lib/iomgr/gethostname_sysconf.c )
- s.files += %w( src/core/lib/iomgr/iocp_windows.c )
- s.files += %w( src/core/lib/iomgr/iomgr.c )
- s.files += %w( src/core/lib/iomgr/iomgr_posix.c )
- s.files += %w( src/core/lib/iomgr/iomgr_uv.c )
- s.files += %w( src/core/lib/iomgr/iomgr_windows.c )
- s.files += %w( src/core/lib/iomgr/is_epollexclusive_available.c )
- s.files += %w( src/core/lib/iomgr/load_file.c )
- s.files += %w( src/core/lib/iomgr/lockfree_event.c )
- s.files += %w( src/core/lib/iomgr/network_status_tracker.c )
- s.files += %w( src/core/lib/iomgr/polling_entity.c )
- s.files += %w( src/core/lib/iomgr/pollset_set_uv.c )
- s.files += %w( src/core/lib/iomgr/pollset_set_windows.c )
- s.files += %w( src/core/lib/iomgr/pollset_uv.c )
- s.files += %w( src/core/lib/iomgr/pollset_windows.c )
- s.files += %w( src/core/lib/iomgr/resolve_address_posix.c )
- s.files += %w( src/core/lib/iomgr/resolve_address_uv.c )
- s.files += %w( src/core/lib/iomgr/resolve_address_windows.c )
- s.files += %w( src/core/lib/iomgr/resource_quota.c )
- s.files += %w( src/core/lib/iomgr/sockaddr_utils.c )
- s.files += %w( src/core/lib/iomgr/socket_factory_posix.c )
- s.files += %w( src/core/lib/iomgr/socket_mutator.c )
- s.files += %w( src/core/lib/iomgr/socket_utils_common_posix.c )
- s.files += %w( src/core/lib/iomgr/socket_utils_linux.c )
- s.files += %w( src/core/lib/iomgr/socket_utils_posix.c )
- s.files += %w( src/core/lib/iomgr/socket_utils_uv.c )
- s.files += %w( src/core/lib/iomgr/socket_utils_windows.c )
- s.files += %w( src/core/lib/iomgr/socket_windows.c )
- s.files += %w( src/core/lib/iomgr/tcp_client_posix.c )
- s.files += %w( src/core/lib/iomgr/tcp_client_uv.c )
- s.files += %w( src/core/lib/iomgr/tcp_client_windows.c )
- s.files += %w( src/core/lib/iomgr/tcp_posix.c )
- s.files += %w( src/core/lib/iomgr/tcp_server_posix.c )
- s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix_common.c )
- s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c )
- s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c )
- s.files += %w( src/core/lib/iomgr/tcp_server_uv.c )
- s.files += %w( src/core/lib/iomgr/tcp_server_windows.c )
- s.files += %w( src/core/lib/iomgr/tcp_uv.c )
- s.files += %w( src/core/lib/iomgr/tcp_windows.c )
- s.files += %w( src/core/lib/iomgr/time_averaged_stats.c )
- s.files += %w( src/core/lib/iomgr/timer_generic.c )
- s.files += %w( src/core/lib/iomgr/timer_heap.c )
- s.files += %w( src/core/lib/iomgr/timer_manager.c )
- s.files += %w( src/core/lib/iomgr/timer_uv.c )
- s.files += %w( src/core/lib/iomgr/udp_server.c )
- s.files += %w( src/core/lib/iomgr/unix_sockets_posix.c )
- s.files += %w( src/core/lib/iomgr/unix_sockets_posix_noop.c )
- s.files += %w( src/core/lib/iomgr/wakeup_fd_cv.c )
- s.files += %w( src/core/lib/iomgr/wakeup_fd_eventfd.c )
- s.files += %w( src/core/lib/iomgr/wakeup_fd_nospecial.c )
- s.files += %w( src/core/lib/iomgr/wakeup_fd_pipe.c )
- s.files += %w( src/core/lib/iomgr/wakeup_fd_posix.c )
- s.files += %w( src/core/lib/json/json.c )
- s.files += %w( src/core/lib/json/json_reader.c )
- s.files += %w( src/core/lib/json/json_string.c )
- s.files += %w( src/core/lib/json/json_writer.c )
- s.files += %w( src/core/lib/slice/b64.c )
- s.files += %w( src/core/lib/slice/percent_encoding.c )
- s.files += %w( src/core/lib/slice/slice.c )
- s.files += %w( src/core/lib/slice/slice_buffer.c )
- s.files += %w( src/core/lib/slice/slice_hash_table.c )
- s.files += %w( src/core/lib/slice/slice_intern.c )
- s.files += %w( src/core/lib/slice/slice_string_helpers.c )
- s.files += %w( src/core/lib/surface/alarm.c )
- s.files += %w( src/core/lib/surface/api_trace.c )
- s.files += %w( src/core/lib/surface/byte_buffer.c )
- s.files += %w( src/core/lib/surface/byte_buffer_reader.c )
- s.files += %w( src/core/lib/surface/call.c )
- s.files += %w( src/core/lib/surface/call_details.c )
- s.files += %w( src/core/lib/surface/call_log_batch.c )
- s.files += %w( src/core/lib/surface/channel.c )
- s.files += %w( src/core/lib/surface/channel_init.c )
- s.files += %w( src/core/lib/surface/channel_ping.c )
- s.files += %w( src/core/lib/surface/channel_stack_type.c )
- s.files += %w( src/core/lib/surface/completion_queue.c )
- s.files += %w( src/core/lib/surface/completion_queue_factory.c )
- s.files += %w( src/core/lib/surface/event_string.c )
+ s.files += %w( src/core/lib/surface/init.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 )
+ s.files += %w( src/core/lib/channel/channel_stack_builder.cc )
+ s.files += %w( src/core/lib/channel/connected_channel.cc )
+ s.files += %w( src/core/lib/channel/handshaker.cc )
+ s.files += %w( src/core/lib/channel/handshaker_factory.cc )
+ s.files += %w( src/core/lib/channel/handshaker_registry.cc )
+ s.files += %w( src/core/lib/compression/compression.cc )
+ s.files += %w( src/core/lib/compression/compression_internal.cc )
+ s.files += %w( src/core/lib/compression/compression_ruby.cc )
+ s.files += %w( src/core/lib/compression/message_compress.cc )
+ s.files += %w( src/core/lib/compression/stream_compression.cc )
+ s.files += %w( src/core/lib/compression/stream_compression_gzip.cc )
+ s.files += %w( src/core/lib/compression/stream_compression_identity.cc )
+ s.files += %w( src/core/lib/debug/stats.cc )
+ s.files += %w( src/core/lib/debug/stats_data.cc )
+ s.files += %w( src/core/lib/http/format_request.cc )
+ s.files += %w( src/core/lib/http/httpcli.cc )
+ s.files += %w( src/core/lib/http/parser.cc )
+ s.files += %w( src/core/lib/iomgr/call_combiner.cc )
+ s.files += %w( src/core/lib/iomgr/combiner.cc )
+ s.files += %w( src/core/lib/iomgr/endpoint.cc )
+ s.files += %w( src/core/lib/iomgr/endpoint_pair_posix.cc )
+ s.files += %w( src/core/lib/iomgr/endpoint_pair_uv.cc )
+ s.files += %w( src/core/lib/iomgr/endpoint_pair_windows.cc )
+ s.files += %w( src/core/lib/iomgr/error.cc )
+ s.files += %w( src/core/lib/iomgr/ev_epoll1_linux.cc )
+ s.files += %w( src/core/lib/iomgr/ev_epollex_linux.cc )
+ s.files += %w( src/core/lib/iomgr/ev_epollsig_linux.cc )
+ s.files += %w( src/core/lib/iomgr/ev_poll_posix.cc )
+ s.files += %w( src/core/lib/iomgr/ev_posix.cc )
+ s.files += %w( src/core/lib/iomgr/ev_windows.cc )
+ s.files += %w( src/core/lib/iomgr/exec_ctx.cc )
+ s.files += %w( src/core/lib/iomgr/executor.cc )
+ s.files += %w( src/core/lib/iomgr/fork_posix.cc )
+ s.files += %w( src/core/lib/iomgr/fork_windows.cc )
+ s.files += %w( src/core/lib/iomgr/gethostname_fallback.cc )
+ s.files += %w( src/core/lib/iomgr/gethostname_host_name_max.cc )
+ s.files += %w( src/core/lib/iomgr/gethostname_sysconf.cc )
+ s.files += %w( src/core/lib/iomgr/iocp_windows.cc )
+ s.files += %w( src/core/lib/iomgr/iomgr.cc )
+ s.files += %w( src/core/lib/iomgr/iomgr_posix.cc )
+ s.files += %w( src/core/lib/iomgr/iomgr_uv.cc )
+ s.files += %w( src/core/lib/iomgr/iomgr_windows.cc )
+ s.files += %w( src/core/lib/iomgr/is_epollexclusive_available.cc )
+ s.files += %w( src/core/lib/iomgr/load_file.cc )
+ s.files += %w( src/core/lib/iomgr/lockfree_event.cc )
+ s.files += %w( src/core/lib/iomgr/network_status_tracker.cc )
+ s.files += %w( src/core/lib/iomgr/polling_entity.cc )
+ s.files += %w( src/core/lib/iomgr/pollset_set_uv.cc )
+ s.files += %w( src/core/lib/iomgr/pollset_set_windows.cc )
+ s.files += %w( src/core/lib/iomgr/pollset_uv.cc )
+ s.files += %w( src/core/lib/iomgr/pollset_windows.cc )
+ s.files += %w( src/core/lib/iomgr/resolve_address_posix.cc )
+ s.files += %w( src/core/lib/iomgr/resolve_address_uv.cc )
+ s.files += %w( src/core/lib/iomgr/resolve_address_windows.cc )
+ s.files += %w( src/core/lib/iomgr/resource_quota.cc )
+ s.files += %w( src/core/lib/iomgr/sockaddr_utils.cc )
+ s.files += %w( src/core/lib/iomgr/socket_factory_posix.cc )
+ s.files += %w( src/core/lib/iomgr/socket_mutator.cc )
+ s.files += %w( src/core/lib/iomgr/socket_utils_common_posix.cc )
+ s.files += %w( src/core/lib/iomgr/socket_utils_linux.cc )
+ s.files += %w( src/core/lib/iomgr/socket_utils_posix.cc )
+ s.files += %w( src/core/lib/iomgr/socket_utils_uv.cc )
+ s.files += %w( src/core/lib/iomgr/socket_utils_windows.cc )
+ s.files += %w( src/core/lib/iomgr/socket_windows.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_client_posix.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_client_uv.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_client_windows.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_posix.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_server_posix.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix_common.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_server_uv.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_server_windows.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_uv.cc )
+ s.files += %w( src/core/lib/iomgr/tcp_windows.cc )
+ s.files += %w( src/core/lib/iomgr/time_averaged_stats.cc )
+ s.files += %w( src/core/lib/iomgr/timer_generic.cc )
+ s.files += %w( src/core/lib/iomgr/timer_heap.cc )
+ s.files += %w( src/core/lib/iomgr/timer_manager.cc )
+ s.files += %w( src/core/lib/iomgr/timer_uv.cc )
+ s.files += %w( src/core/lib/iomgr/udp_server.cc )
+ s.files += %w( src/core/lib/iomgr/unix_sockets_posix.cc )
+ s.files += %w( src/core/lib/iomgr/unix_sockets_posix_noop.cc )
+ s.files += %w( src/core/lib/iomgr/wakeup_fd_cv.cc )
+ s.files += %w( src/core/lib/iomgr/wakeup_fd_eventfd.cc )
+ s.files += %w( src/core/lib/iomgr/wakeup_fd_nospecial.cc )
+ s.files += %w( src/core/lib/iomgr/wakeup_fd_pipe.cc )
+ s.files += %w( src/core/lib/iomgr/wakeup_fd_posix.cc )
+ s.files += %w( src/core/lib/json/json.cc )
+ s.files += %w( src/core/lib/json/json_reader.cc )
+ s.files += %w( src/core/lib/json/json_string.cc )
+ s.files += %w( src/core/lib/json/json_writer.cc )
+ s.files += %w( src/core/lib/slice/b64.cc )
+ s.files += %w( src/core/lib/slice/percent_encoding.cc )
+ s.files += %w( src/core/lib/slice/slice.cc )
+ s.files += %w( src/core/lib/slice/slice_buffer.cc )
+ s.files += %w( src/core/lib/slice/slice_hash_table.cc )
+ s.files += %w( src/core/lib/slice/slice_intern.cc )
+ s.files += %w( src/core/lib/slice/slice_string_helpers.cc )
+ s.files += %w( src/core/lib/surface/alarm.cc )
+ s.files += %w( src/core/lib/surface/api_trace.cc )
+ s.files += %w( src/core/lib/surface/byte_buffer.cc )
+ s.files += %w( src/core/lib/surface/byte_buffer_reader.cc )
+ s.files += %w( src/core/lib/surface/call.cc )
+ s.files += %w( src/core/lib/surface/call_details.cc )
+ s.files += %w( src/core/lib/surface/call_log_batch.cc )
+ s.files += %w( src/core/lib/surface/channel.cc )
+ s.files += %w( src/core/lib/surface/channel_init.cc )
+ s.files += %w( src/core/lib/surface/channel_ping.cc )
+ s.files += %w( src/core/lib/surface/channel_stack_type.cc )
+ s.files += %w( src/core/lib/surface/completion_queue.cc )
+ s.files += %w( src/core/lib/surface/completion_queue_factory.cc )
+ s.files += %w( src/core/lib/surface/event_string.cc )
s.files += %w( src/core/lib/surface/lame_client.cc )
- s.files += %w( src/core/lib/surface/metadata_array.c )
- s.files += %w( src/core/lib/surface/server.c )
- s.files += %w( src/core/lib/surface/validate_metadata.c )
- s.files += %w( src/core/lib/surface/version.c )
- s.files += %w( src/core/lib/transport/bdp_estimator.c )
- s.files += %w( src/core/lib/transport/byte_stream.c )
- s.files += %w( src/core/lib/transport/connectivity_state.c )
- s.files += %w( src/core/lib/transport/error_utils.c )
- s.files += %w( src/core/lib/transport/metadata.c )
- s.files += %w( src/core/lib/transport/metadata_batch.c )
- s.files += %w( src/core/lib/transport/pid_controller.c )
- s.files += %w( src/core/lib/transport/service_config.c )
- s.files += %w( src/core/lib/transport/static_metadata.c )
- s.files += %w( src/core/lib/transport/status_conversion.c )
- s.files += %w( src/core/lib/transport/timeout_encoding.c )
- s.files += %w( src/core/lib/transport/transport.c )
- s.files += %w( src/core/lib/transport/transport_op_string.c )
- s.files += %w( src/core/lib/debug/trace.c )
- s.files += %w( src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/bin_decoder.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/bin_encoder.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_plugin.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_transport.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/flow_control.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/frame_data.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/frame_goaway.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/frame_ping.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/frame_rst_stream.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/frame_settings.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/frame_window_update.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/hpack_encoder.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/hpack_parser.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/hpack_table.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/http2_settings.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/huffsyms.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/incoming_metadata.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/parsing.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/stream_lists.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/stream_map.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/varint.c )
- s.files += %w( src/core/ext/transport/chttp2/transport/writing.c )
- s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.c )
- s.files += %w( src/core/ext/filters/http/client/http_client_filter.c )
- s.files += %w( src/core/ext/filters/http/http_filters_plugin.c )
- s.files += %w( src/core/ext/filters/http/message_compress/message_compress_filter.c )
- s.files += %w( src/core/ext/filters/http/server/http_server_filter.c )
- s.files += %w( src/core/lib/http/httpcli_security_connector.c )
- s.files += %w( src/core/lib/security/context/security_context.c )
- s.files += %w( src/core/lib/security/credentials/composite/composite_credentials.c )
- s.files += %w( src/core/lib/security/credentials/credentials.c )
- s.files += %w( src/core/lib/security/credentials/credentials_metadata.c )
- s.files += %w( src/core/lib/security/credentials/fake/fake_credentials.c )
- s.files += %w( src/core/lib/security/credentials/google_default/credentials_generic.c )
- s.files += %w( src/core/lib/security/credentials/google_default/google_default_credentials.c )
- s.files += %w( src/core/lib/security/credentials/iam/iam_credentials.c )
- s.files += %w( src/core/lib/security/credentials/jwt/json_token.c )
- s.files += %w( src/core/lib/security/credentials/jwt/jwt_credentials.c )
- s.files += %w( src/core/lib/security/credentials/jwt/jwt_verifier.c )
- s.files += %w( src/core/lib/security/credentials/oauth2/oauth2_credentials.c )
- s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.c )
- s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.c )
- s.files += %w( src/core/lib/security/transport/client_auth_filter.c )
- s.files += %w( src/core/lib/security/transport/lb_targets_info.c )
- s.files += %w( src/core/lib/security/transport/secure_endpoint.c )
- s.files += %w( src/core/lib/security/transport/security_connector.c )
- s.files += %w( src/core/lib/security/transport/security_handshaker.c )
- s.files += %w( src/core/lib/security/transport/server_auth_filter.c )
- s.files += %w( src/core/lib/security/transport/tsi_error.c )
- s.files += %w( src/core/lib/security/util/json_util.c )
- s.files += %w( src/core/lib/surface/init_secure.c )
- s.files += %w( src/core/tsi/fake_transport_security.c )
- s.files += %w( src/core/tsi/gts_transport_security.c )
- s.files += %w( src/core/tsi/ssl_transport_security.c )
- s.files += %w( src/core/tsi/transport_security_grpc.c )
- s.files += %w( src/core/tsi/transport_security.c )
- s.files += %w( src/core/tsi/transport_security_adapter.c )
- s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.c )
- s.files += %w( src/core/ext/transport/chttp2/client/secure/secure_channel_create.c )
- s.files += %w( src/core/ext/filters/client_channel/channel_connectivity.c )
- s.files += %w( src/core/ext/filters/client_channel/client_channel.c )
- s.files += %w( src/core/ext/filters/client_channel/client_channel_factory.c )
- s.files += %w( src/core/ext/filters/client_channel/client_channel_plugin.c )
- s.files += %w( src/core/ext/filters/client_channel/connector.c )
- s.files += %w( src/core/ext/filters/client_channel/http_connect_handshaker.c )
- s.files += %w( src/core/ext/filters/client_channel/http_proxy.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy_factory.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy_registry.c )
- s.files += %w( src/core/ext/filters/client_channel/parse_address.c )
- s.files += %w( src/core/ext/filters/client_channel/proxy_mapper.c )
- s.files += %w( src/core/ext/filters/client_channel/proxy_mapper_registry.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver_factory.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver_registry.c )
- s.files += %w( src/core/ext/filters/client_channel/retry_throttle.c )
- s.files += %w( src/core/ext/filters/client_channel/subchannel.c )
- s.files += %w( src/core/ext/filters/client_channel/subchannel_index.c )
- s.files += %w( src/core/ext/filters/client_channel/uri_parser.c )
- s.files += %w( src/core/ext/filters/deadline/deadline_filter.c )
- s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.c )
- s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2.c )
- s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c )
- s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c )
- s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c )
- s.files += %w( src/core/ext/transport/inproc/inproc_plugin.c )
- s.files += %w( src/core/ext/transport/inproc/inproc_transport.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c )
+ s.files += %w( src/core/lib/surface/metadata_array.cc )
+ s.files += %w( src/core/lib/surface/server.cc )
+ s.files += %w( src/core/lib/surface/validate_metadata.cc )
+ s.files += %w( src/core/lib/surface/version.cc )
+ s.files += %w( src/core/lib/transport/bdp_estimator.cc )
+ s.files += %w( src/core/lib/transport/byte_stream.cc )
+ s.files += %w( src/core/lib/transport/connectivity_state.cc )
+ s.files += %w( src/core/lib/transport/error_utils.cc )
+ s.files += %w( src/core/lib/transport/metadata.cc )
+ s.files += %w( src/core/lib/transport/metadata_batch.cc )
+ s.files += %w( src/core/lib/transport/pid_controller.cc )
+ s.files += %w( src/core/lib/transport/service_config.cc )
+ s.files += %w( src/core/lib/transport/static_metadata.cc )
+ s.files += %w( src/core/lib/transport/status_conversion.cc )
+ s.files += %w( src/core/lib/transport/timeout_encoding.cc )
+ s.files += %w( src/core/lib/transport/transport.cc )
+ s.files += %w( src/core/lib/transport/transport_op_string.cc )
+ s.files += %w( src/core/lib/debug/trace.cc )
+ s.files += %w( src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/bin_decoder.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/bin_encoder.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_plugin.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/chttp2_transport.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/flow_control.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/frame_data.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/frame_goaway.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/frame_ping.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/frame_rst_stream.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/frame_settings.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/frame_window_update.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/hpack_encoder.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/hpack_parser.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/hpack_table.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/http2_settings.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/huffsyms.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/incoming_metadata.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/parsing.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/stream_lists.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/stream_map.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/varint.cc )
+ s.files += %w( src/core/ext/transport/chttp2/transport/writing.cc )
+ s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.cc )
+ s.files += %w( src/core/ext/filters/http/client/http_client_filter.cc )
+ s.files += %w( src/core/ext/filters/http/http_filters_plugin.cc )
+ s.files += %w( src/core/ext/filters/http/message_compress/message_compress_filter.cc )
+ s.files += %w( src/core/ext/filters/http/server/http_server_filter.cc )
+ s.files += %w( src/core/lib/http/httpcli_security_connector.cc )
+ s.files += %w( src/core/lib/security/context/security_context.cc )
+ s.files += %w( src/core/lib/security/credentials/composite/composite_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/credentials_metadata.cc )
+ s.files += %w( src/core/lib/security/credentials/fake/fake_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/google_default/credentials_generic.cc )
+ s.files += %w( src/core/lib/security/credentials/google_default/google_default_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/iam/iam_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/jwt/json_token.cc )
+ s.files += %w( src/core/lib/security/credentials/jwt/jwt_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/jwt/jwt_verifier.cc )
+ s.files += %w( src/core/lib/security/credentials/oauth2/oauth2_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/plugin/plugin_credentials.cc )
+ s.files += %w( src/core/lib/security/credentials/ssl/ssl_credentials.cc )
+ s.files += %w( src/core/lib/security/transport/client_auth_filter.cc )
+ s.files += %w( src/core/lib/security/transport/lb_targets_info.cc )
+ s.files += %w( src/core/lib/security/transport/secure_endpoint.cc )
+ s.files += %w( src/core/lib/security/transport/security_connector.cc )
+ s.files += %w( src/core/lib/security/transport/security_handshaker.cc )
+ s.files += %w( src/core/lib/security/transport/server_auth_filter.cc )
+ s.files += %w( src/core/lib/security/transport/tsi_error.cc )
+ s.files += %w( src/core/lib/security/util/json_util.cc )
+ s.files += %w( src/core/lib/surface/init_secure.cc )
+ s.files += %w( src/core/tsi/alts_transport_security.cc )
+ s.files += %w( src/core/tsi/fake_transport_security.cc )
+ s.files += %w( src/core/tsi/ssl_transport_security.cc )
+ s.files += %w( src/core/tsi/transport_security_grpc.cc )
+ s.files += %w( src/core/tsi/transport_security.cc )
+ s.files += %w( src/core/tsi/transport_security_adapter.cc )
+ s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.cc )
+ s.files += %w( src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc )
+ s.files += %w( src/core/ext/filters/client_channel/backup_poller.cc )
+ s.files += %w( src/core/ext/filters/client_channel/channel_connectivity.cc )
+ s.files += %w( src/core/ext/filters/client_channel/client_channel.cc )
+ s.files += %w( src/core/ext/filters/client_channel/client_channel_factory.cc )
+ s.files += %w( src/core/ext/filters/client_channel/client_channel_plugin.cc )
+ s.files += %w( src/core/ext/filters/client_channel/connector.cc )
+ s.files += %w( src/core/ext/filters/client_channel/http_connect_handshaker.cc )
+ s.files += %w( src/core/ext/filters/client_channel/http_proxy.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy_factory.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy_registry.cc )
+ s.files += %w( src/core/ext/filters/client_channel/parse_address.cc )
+ 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 )
+ s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc )
+ s.files += %w( src/core/ext/filters/client_channel/uri_parser.cc )
+ s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc )
+ s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.cc )
+ s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc )
+ s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc )
+ s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.cc )
+ s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc )
+ s.files += %w( src/core/ext/transport/inproc/inproc_plugin.cc )
+ s.files += %w( src/core/ext/transport/inproc/inproc_transport.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c )
s.files += %w( third_party/nanopb/pb_common.c )
s.files += %w( third_party/nanopb/pb_decode.c )
s.files += %w( third_party/nanopb/pb_encode.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c )
- s.files += %w( src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c )
- s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c )
- s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_filter.c )
- s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.c )
- s.files += %w( src/core/ext/census/base_resources.c )
- s.files += %w( src/core/ext/census/context.c )
- s.files += %w( src/core/ext/census/gen/census.pb.c )
- s.files += %w( src/core/ext/census/gen/trace_context.pb.c )
- s.files += %w( src/core/ext/census/grpc_context.c )
- s.files += %w( src/core/ext/census/grpc_filter.c )
- s.files += %w( src/core/ext/census/grpc_plugin.c )
- s.files += %w( src/core/ext/census/initialize.c )
- s.files += %w( src/core/ext/census/intrusive_hash_map.c )
- s.files += %w( src/core/ext/census/mlog.c )
- s.files += %w( src/core/ext/census/operation.c )
- s.files += %w( src/core/ext/census/placeholders.c )
- s.files += %w( src/core/ext/census/resource.c )
- s.files += %w( src/core/ext/census/trace_context.c )
- s.files += %w( src/core/ext/census/tracing.c )
- s.files += %w( src/core/ext/filters/max_age/max_age_filter.c )
- s.files += %w( src/core/ext/filters/message_size/message_size_filter.c )
- s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c )
- s.files += %w( src/core/ext/filters/workarounds/workaround_utils.c )
- s.files += %w( src/core/plugin_registry/grpc_plugin_registry.c )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc )
+ s.files += %w( src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc )
+ s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc )
+ s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_filter.cc )
+ s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc )
+ s.files += %w( src/core/ext/census/grpc_context.cc )
+ s.files += %w( src/core/ext/filters/max_age/max_age_filter.cc )
+ s.files += %w( src/core/ext/filters/message_size/message_size_filter.cc )
+ s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc )
+ s.files += %w( src/core/ext/filters/workarounds/workaround_utils.cc )
+ s.files += %w( src/core/plugin_registry/grpc_plugin_registry.cc )
s.files += %w( third_party/boringssl/crypto/aes/internal.h )
s.files += %w( third_party/boringssl/crypto/asn1/asn1_locl.h )
s.files += %w( third_party/boringssl/crypto/bio/internal.h )
@@ -1123,8 +1109,10 @@ Gem::Specification.new do |s|
s.files += %w( third_party/cares/cares/config-win32.h )
s.files += %w( third_party/cares/cares/setup_once.h )
s.files += %w( third_party/cares/ares_build.h )
- s.files += %w( third_party/cares/config_linux/ares_config.h )
s.files += %w( third_party/cares/config_darwin/ares_config.h )
+ s.files += %w( third_party/cares/config_freebsd/ares_config.h )
+ s.files += %w( third_party/cares/config_linux/ares_config.h )
+ s.files += %w( third_party/cares/config_openbsd/ares_config.h )
s.files += %w( third_party/cares/cares/ares__close_sockets.c )
s.files += %w( third_party/cares/cares/ares__get_hostent.c )
s.files += %w( third_party/cares/cares/ares__read_line.c )
diff --git a/grpc.gyp b/grpc.gyp
index 6331b76f47..e074bb159a 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -57,6 +57,7 @@
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
+ '-Wno-deprecated-declarations',
],
'ldflags': [
'-g',
@@ -98,6 +99,7 @@
'-fprofile-arcs',
'-ftest-coverage',
'-rdynamic',
+ '-lstdc++',
],
}],
['grpc_alpine=="true"', {
@@ -133,6 +135,7 @@
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
+ '-Wno-deprecated-declarations',
],
'OTHER_CPLUSPLUSFLAGS': [
'-g',
@@ -142,6 +145,7 @@
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
+ '-Wno-deprecated-declarations',
'-stdlib=libc++',
'-std=c++11',
'-Wno-error=deprecated-declarations'
@@ -157,52 +161,50 @@
'dependencies': [
],
'sources': [
- 'src/core/lib/profiling/basic_timers.c',
- 'src/core/lib/profiling/stap_timers.c',
- 'src/core/lib/support/alloc.c',
- 'src/core/lib/support/arena.c',
- 'src/core/lib/support/atm.c',
- 'src/core/lib/support/avl.c',
- 'src/core/lib/support/backoff.c',
- 'src/core/lib/support/cmdline.c',
- 'src/core/lib/support/cpu_iphone.c',
- 'src/core/lib/support/cpu_linux.c',
- 'src/core/lib/support/cpu_posix.c',
- 'src/core/lib/support/cpu_windows.c',
- 'src/core/lib/support/env_linux.c',
- 'src/core/lib/support/env_posix.c',
- 'src/core/lib/support/env_windows.c',
- 'src/core/lib/support/histogram.c',
- 'src/core/lib/support/host_port.c',
- 'src/core/lib/support/log.c',
- 'src/core/lib/support/log_android.c',
- 'src/core/lib/support/log_linux.c',
- 'src/core/lib/support/log_posix.c',
- 'src/core/lib/support/log_windows.c',
- 'src/core/lib/support/mpscq.c',
- 'src/core/lib/support/murmur_hash.c',
- 'src/core/lib/support/stack_lockfree.c',
- 'src/core/lib/support/string.c',
- 'src/core/lib/support/string_posix.c',
- 'src/core/lib/support/string_util_windows.c',
- 'src/core/lib/support/string_windows.c',
- 'src/core/lib/support/subprocess_posix.c',
- 'src/core/lib/support/subprocess_windows.c',
- 'src/core/lib/support/sync.c',
- 'src/core/lib/support/sync_posix.c',
- 'src/core/lib/support/sync_windows.c',
- 'src/core/lib/support/thd.c',
- 'src/core/lib/support/thd_posix.c',
- 'src/core/lib/support/thd_windows.c',
- 'src/core/lib/support/time.c',
- 'src/core/lib/support/time_posix.c',
- 'src/core/lib/support/time_precise.c',
- 'src/core/lib/support/time_windows.c',
- 'src/core/lib/support/tls_pthread.c',
- 'src/core/lib/support/tmpfile_msys.c',
- 'src/core/lib/support/tmpfile_posix.c',
- 'src/core/lib/support/tmpfile_windows.c',
- 'src/core/lib/support/wrap_memcpy.c',
+ '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',
+ 'src/core/lib/gpr/cpu_posix.cc',
+ 'src/core/lib/gpr/cpu_windows.cc',
+ 'src/core/lib/gpr/env_linux.cc',
+ 'src/core/lib/gpr/env_posix.cc',
+ 'src/core/lib/gpr/env_windows.cc',
+ 'src/core/lib/gpr/fork.cc',
+ 'src/core/lib/gpr/host_port.cc',
+ 'src/core/lib/gpr/log.cc',
+ 'src/core/lib/gpr/log_android.cc',
+ 'src/core/lib/gpr/log_linux.cc',
+ 'src/core/lib/gpr/log_posix.cc',
+ 'src/core/lib/gpr/log_windows.cc',
+ 'src/core/lib/gpr/mpscq.cc',
+ 'src/core/lib/gpr/murmur_hash.cc',
+ 'src/core/lib/gpr/string.cc',
+ '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',
+ 'src/core/lib/gpr/thd.cc',
+ 'src/core/lib/gpr/thd_posix.cc',
+ 'src/core/lib/gpr/thd_windows.cc',
+ 'src/core/lib/gpr/time.cc',
+ 'src/core/lib/gpr/time_posix.cc',
+ 'src/core/lib/gpr/time_precise.cc',
+ 'src/core/lib/gpr/time_windows.cc',
+ 'src/core/lib/gpr/tls_pthread.cc',
+ '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/wrap_memcpy.cc',
+ 'src/core/lib/profiling/basic_timers.cc',
+ 'src/core/lib/profiling/stap_timers.cc',
],
},
{
@@ -212,7 +214,7 @@
'gpr',
],
'sources': [
- 'test/core/util/test_config.c',
+ 'test/core/util/test_config.cc',
],
},
{
@@ -222,267 +224,259 @@
'gpr',
],
'sources': [
- 'src/core/lib/surface/init.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
+ 'src/core/lib/surface/init.cc',
+ 'src/core/lib/backoff/backoff.cc',
+ 'src/core/lib/channel/channel_args.cc',
+ 'src/core/lib/channel/channel_stack.cc',
+ 'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/connected_channel.cc',
+ 'src/core/lib/channel/handshaker.cc',
+ 'src/core/lib/channel/handshaker_factory.cc',
+ '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',
+ 'src/core/lib/compression/stream_compression_identity.cc',
+ 'src/core/lib/debug/stats.cc',
+ 'src/core/lib/debug/stats_data.cc',
+ 'src/core/lib/http/format_request.cc',
+ 'src/core/lib/http/httpcli.cc',
+ 'src/core/lib/http/parser.cc',
+ 'src/core/lib/iomgr/call_combiner.cc',
+ 'src/core/lib/iomgr/combiner.cc',
+ 'src/core/lib/iomgr/endpoint.cc',
+ 'src/core/lib/iomgr/endpoint_pair_posix.cc',
+ 'src/core/lib/iomgr/endpoint_pair_uv.cc',
+ 'src/core/lib/iomgr/endpoint_pair_windows.cc',
+ 'src/core/lib/iomgr/error.cc',
+ 'src/core/lib/iomgr/ev_epoll1_linux.cc',
+ 'src/core/lib/iomgr/ev_epollex_linux.cc',
+ 'src/core/lib/iomgr/ev_epollsig_linux.cc',
+ 'src/core/lib/iomgr/ev_poll_posix.cc',
+ 'src/core/lib/iomgr/ev_posix.cc',
+ 'src/core/lib/iomgr/ev_windows.cc',
+ 'src/core/lib/iomgr/exec_ctx.cc',
+ 'src/core/lib/iomgr/executor.cc',
+ 'src/core/lib/iomgr/fork_posix.cc',
+ 'src/core/lib/iomgr/fork_windows.cc',
+ 'src/core/lib/iomgr/gethostname_fallback.cc',
+ 'src/core/lib/iomgr/gethostname_host_name_max.cc',
+ 'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/iocp_windows.cc',
+ 'src/core/lib/iomgr/iomgr.cc',
+ 'src/core/lib/iomgr/iomgr_posix.cc',
+ 'src/core/lib/iomgr/iomgr_uv.cc',
+ 'src/core/lib/iomgr/iomgr_windows.cc',
+ 'src/core/lib/iomgr/is_epollexclusive_available.cc',
+ 'src/core/lib/iomgr/load_file.cc',
+ 'src/core/lib/iomgr/lockfree_event.cc',
+ 'src/core/lib/iomgr/network_status_tracker.cc',
+ 'src/core/lib/iomgr/polling_entity.cc',
+ 'src/core/lib/iomgr/pollset_set_uv.cc',
+ 'src/core/lib/iomgr/pollset_set_windows.cc',
+ 'src/core/lib/iomgr/pollset_uv.cc',
+ 'src/core/lib/iomgr/pollset_windows.cc',
+ 'src/core/lib/iomgr/resolve_address_posix.cc',
+ 'src/core/lib/iomgr/resolve_address_uv.cc',
+ 'src/core/lib/iomgr/resolve_address_windows.cc',
+ 'src/core/lib/iomgr/resource_quota.cc',
+ 'src/core/lib/iomgr/sockaddr_utils.cc',
+ 'src/core/lib/iomgr/socket_factory_posix.cc',
+ 'src/core/lib/iomgr/socket_mutator.cc',
+ 'src/core/lib/iomgr/socket_utils_common_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_linux.cc',
+ 'src/core/lib/iomgr/socket_utils_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_uv.cc',
+ 'src/core/lib/iomgr/socket_utils_windows.cc',
+ 'src/core/lib/iomgr/socket_windows.cc',
+ 'src/core/lib/iomgr/tcp_client_posix.cc',
+ 'src/core/lib/iomgr/tcp_client_uv.cc',
+ 'src/core/lib/iomgr/tcp_client_windows.cc',
+ 'src/core/lib/iomgr/tcp_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_uv.cc',
+ 'src/core/lib/iomgr/tcp_server_windows.cc',
+ 'src/core/lib/iomgr/tcp_uv.cc',
+ 'src/core/lib/iomgr/tcp_windows.cc',
+ 'src/core/lib/iomgr/time_averaged_stats.cc',
+ 'src/core/lib/iomgr/timer_generic.cc',
+ 'src/core/lib/iomgr/timer_heap.cc',
+ 'src/core/lib/iomgr/timer_manager.cc',
+ 'src/core/lib/iomgr/timer_uv.cc',
+ 'src/core/lib/iomgr/udp_server.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.cc',
+ 'src/core/lib/iomgr/wakeup_fd_cv.cc',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.cc',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.cc',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.cc',
+ 'src/core/lib/iomgr/wakeup_fd_posix.cc',
+ 'src/core/lib/json/json.cc',
+ 'src/core/lib/json/json_reader.cc',
+ 'src/core/lib/json/json_string.cc',
+ 'src/core/lib/json/json_writer.cc',
+ 'src/core/lib/slice/b64.cc',
+ 'src/core/lib/slice/percent_encoding.cc',
+ 'src/core/lib/slice/slice.cc',
+ 'src/core/lib/slice/slice_buffer.cc',
+ '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',
+ 'src/core/lib/surface/call.cc',
+ 'src/core/lib/surface/call_details.cc',
+ 'src/core/lib/surface/call_log_batch.cc',
+ 'src/core/lib/surface/channel.cc',
+ 'src/core/lib/surface/channel_init.cc',
+ 'src/core/lib/surface/channel_ping.cc',
+ 'src/core/lib/surface/channel_stack_type.cc',
+ 'src/core/lib/surface/completion_queue.cc',
+ 'src/core/lib/surface/completion_queue_factory.cc',
+ 'src/core/lib/surface/event_string.cc',
'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
- 'src/core/lib/http/httpcli_security_connector.c',
- 'src/core/lib/security/context/security_context.c',
- 'src/core/lib/security/credentials/composite/composite_credentials.c',
- 'src/core/lib/security/credentials/credentials.c',
- 'src/core/lib/security/credentials/credentials_metadata.c',
- 'src/core/lib/security/credentials/fake/fake_credentials.c',
- 'src/core/lib/security/credentials/google_default/credentials_generic.c',
- 'src/core/lib/security/credentials/google_default/google_default_credentials.c',
- 'src/core/lib/security/credentials/iam/iam_credentials.c',
- 'src/core/lib/security/credentials/jwt/json_token.c',
- 'src/core/lib/security/credentials/jwt/jwt_credentials.c',
- 'src/core/lib/security/credentials/jwt/jwt_verifier.c',
- 'src/core/lib/security/credentials/oauth2/oauth2_credentials.c',
- 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
- 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
- 'src/core/lib/security/transport/client_auth_filter.c',
- 'src/core/lib/security/transport/lb_targets_info.c',
- 'src/core/lib/security/transport/secure_endpoint.c',
- 'src/core/lib/security/transport/security_connector.c',
- 'src/core/lib/security/transport/security_handshaker.c',
- 'src/core/lib/security/transport/server_auth_filter.c',
- 'src/core/lib/security/transport/tsi_error.c',
- 'src/core/lib/security/util/json_util.c',
- 'src/core/lib/surface/init_secure.c',
- 'src/core/tsi/fake_transport_security.c',
- 'src/core/tsi/gts_transport_security.c',
- 'src/core/tsi/ssl_transport_security.c',
- 'src/core/tsi/transport_security_grpc.c',
- 'src/core/tsi/transport_security.c',
- 'src/core/tsi/transport_security_adapter.c',
- 'src/core/ext/transport/chttp2/server/chttp2_server.c',
- 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/chttp2/client/chttp2_connector.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
- 'src/core/ext/transport/inproc/inproc_plugin.c',
- 'src/core/ext/transport/inproc/inproc_transport.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
+ 'src/core/lib/surface/metadata_array.cc',
+ 'src/core/lib/surface/server.cc',
+ 'src/core/lib/surface/validate_metadata.cc',
+ 'src/core/lib/surface/version.cc',
+ 'src/core/lib/transport/bdp_estimator.cc',
+ 'src/core/lib/transport/byte_stream.cc',
+ 'src/core/lib/transport/connectivity_state.cc',
+ 'src/core/lib/transport/error_utils.cc',
+ 'src/core/lib/transport/metadata.cc',
+ 'src/core/lib/transport/metadata_batch.cc',
+ 'src/core/lib/transport/pid_controller.cc',
+ 'src/core/lib/transport/service_config.cc',
+ 'src/core/lib/transport/static_metadata.cc',
+ 'src/core/lib/transport/status_conversion.cc',
+ 'src/core/lib/transport/timeout_encoding.cc',
+ 'src/core/lib/transport/transport.cc',
+ 'src/core/lib/transport/transport_op_string.cc',
+ 'src/core/lib/debug/trace.cc',
+ 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc',
+ 'src/core/ext/transport/chttp2/transport/flow_control.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_data.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.cc',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.cc',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.cc',
+ 'src/core/ext/transport/chttp2/transport/parsing.cc',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.cc',
+ '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/ext/transport/chttp2/alpn/alpn.cc',
+ 'src/core/ext/filters/http/client/http_client_filter.cc',
+ 'src/core/ext/filters/http/http_filters_plugin.cc',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
+ 'src/core/ext/filters/http/server/http_server_filter.cc',
+ 'src/core/lib/http/httpcli_security_connector.cc',
+ 'src/core/lib/security/context/security_context.cc',
+ 'src/core/lib/security/credentials/composite/composite_credentials.cc',
+ 'src/core/lib/security/credentials/credentials.cc',
+ 'src/core/lib/security/credentials/credentials_metadata.cc',
+ 'src/core/lib/security/credentials/fake/fake_credentials.cc',
+ 'src/core/lib/security/credentials/google_default/credentials_generic.cc',
+ 'src/core/lib/security/credentials/google_default/google_default_credentials.cc',
+ 'src/core/lib/security/credentials/iam/iam_credentials.cc',
+ 'src/core/lib/security/credentials/jwt/json_token.cc',
+ 'src/core/lib/security/credentials/jwt/jwt_credentials.cc',
+ 'src/core/lib/security/credentials/jwt/jwt_verifier.cc',
+ 'src/core/lib/security/credentials/oauth2/oauth2_credentials.cc',
+ 'src/core/lib/security/credentials/plugin/plugin_credentials.cc',
+ 'src/core/lib/security/credentials/ssl/ssl_credentials.cc',
+ 'src/core/lib/security/transport/client_auth_filter.cc',
+ 'src/core/lib/security/transport/lb_targets_info.cc',
+ 'src/core/lib/security/transport/secure_endpoint.cc',
+ 'src/core/lib/security/transport/security_connector.cc',
+ 'src/core/lib/security/transport/security_handshaker.cc',
+ 'src/core/lib/security/transport/server_auth_filter.cc',
+ 'src/core/lib/security/transport/tsi_error.cc',
+ 'src/core/lib/security/util/json_util.cc',
+ 'src/core/lib/surface/init_secure.cc',
+ 'src/core/tsi/alts_transport_security.cc',
+ 'src/core/tsi/fake_transport_security.cc',
+ 'src/core/tsi/ssl_transport_security.cc',
+ 'src/core/tsi/transport_security_grpc.cc',
+ 'src/core/tsi/transport_security.cc',
+ 'src/core/tsi/transport_security_adapter.cc',
+ 'src/core/ext/transport/chttp2/server/chttp2_server.cc',
+ 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc',
+ 'src/core/ext/filters/client_channel/backup_poller.cc',
+ 'src/core/ext/filters/client_channel/channel_connectivity.cc',
+ 'src/core/ext/filters/client_channel/client_channel.cc',
+ 'src/core/ext/filters/client_channel/client_channel_factory.cc',
+ 'src/core/ext/filters/client_channel/client_channel_plugin.cc',
+ 'src/core/ext/filters/client_channel/connector.cc',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
+ 'src/core/ext/filters/client_channel/http_proxy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.cc',
+ 'src/core/ext/filters/client_channel/parse_address.cc',
+ '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',
+ 'src/core/ext/filters/client_channel/subchannel_index.cc',
+ 'src/core/ext/filters/client_channel/uri_parser.cc',
+ 'src/core/ext/filters/deadline/deadline_filter.cc',
+ 'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc',
+ 'src/core/ext/transport/inproc/inproc_plugin.cc',
+ 'src/core/ext/transport/inproc/inproc_transport.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c',
- 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c',
- 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c',
- 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c',
- 'src/core/ext/census/base_resources.c',
- 'src/core/ext/census/context.c',
- 'src/core/ext/census/gen/census.pb.c',
- 'src/core/ext/census/gen/trace_context.pb.c',
- 'src/core/ext/census/grpc_context.c',
- 'src/core/ext/census/grpc_filter.c',
- 'src/core/ext/census/grpc_plugin.c',
- 'src/core/ext/census/initialize.c',
- 'src/core/ext/census/intrusive_hash_map.c',
- 'src/core/ext/census/mlog.c',
- 'src/core/ext/census/operation.c',
- 'src/core/ext/census/placeholders.c',
- 'src/core/ext/census/resource.c',
- 'src/core/ext/census/trace_context.c',
- 'src/core/ext/census/tracing.c',
- 'src/core/ext/filters/max_age/max_age_filter.c',
- 'src/core/ext/filters/message_size/message_size_filter.c',
- 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c',
- 'src/core/ext/filters/workarounds/workaround_utils.c',
- 'src/core/plugin_registry/grpc_plugin_registry.c',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
+ 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_filter.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc',
+ 'src/core/ext/census/grpc_context.cc',
+ 'src/core/ext/filters/max_age/max_age_filter.cc',
+ 'src/core/ext/filters/message_size/message_size_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_utils.cc',
+ 'src/core/plugin_registry/grpc_plugin_registry.cc',
],
},
{
@@ -504,206 +498,214 @@
'grpc',
],
'sources': [
- 'test/core/end2end/data/client_certs.c',
- 'test/core/end2end/data/server1_cert.c',
- 'test/core/end2end/data/server1_key.c',
- 'test/core/end2end/data/test_root_cert.c',
- 'test/core/security/oauth2_utils.c',
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'test/core/end2end/cq_verifier.c',
- 'test/core/end2end/fixtures/http_proxy_fixture.c',
- 'test/core/end2end/fixtures/proxy.c',
- 'test/core/iomgr/endpoint_tests.c',
- 'test/core/util/debugger_macros.c',
- 'test/core/util/grpc_profiler.c',
- 'test/core/util/memory_counters.c',
- 'test/core/util/mock_endpoint.c',
- 'test/core/util/parse_hexstring.c',
- 'test/core/util/passthru_endpoint.c',
- 'test/core/util/port.c',
- 'test/core/util/port_server_client.c',
- 'test/core/util/slice_splitter.c',
- 'test/core/util/trickle_endpoint.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
+ 'test/core/end2end/data/client_certs.cc',
+ 'test/core/end2end/data/server1_cert.cc',
+ 'test/core/end2end/data/server1_key.cc',
+ 'test/core/end2end/data/test_root_cert.cc',
+ 'test/core/security/oauth2_utils.cc',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
+ 'test/core/end2end/cq_verifier.cc',
+ 'test/core/end2end/fixtures/http_proxy_fixture.cc',
+ 'test/core/end2end/fixtures/proxy.cc',
+ 'test/core/iomgr/endpoint_tests.cc',
+ 'test/core/util/debugger_macros.cc',
+ 'test/core/util/grpc_profiler.cc',
+ 'test/core/util/histogram.cc',
+ 'test/core/util/memory_counters.cc',
+ 'test/core/util/mock_endpoint.cc',
+ 'test/core/util/parse_hexstring.cc',
+ 'test/core/util/passthru_endpoint.cc',
+ 'test/core/util/port.cc',
+ 'test/core/util/port_isolated_runtime_environment.cc',
+ 'test/core/util/port_server_client.cc',
+ 'test/core/util/slice_splitter.cc',
+ 'test/core/util/tracer_util.cc',
+ 'test/core/util/trickle_endpoint.cc',
+ 'src/core/lib/backoff/backoff.cc',
+ 'src/core/lib/channel/channel_args.cc',
+ 'src/core/lib/channel/channel_stack.cc',
+ 'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/connected_channel.cc',
+ 'src/core/lib/channel/handshaker.cc',
+ 'src/core/lib/channel/handshaker_factory.cc',
+ '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',
+ 'src/core/lib/compression/stream_compression_identity.cc',
+ 'src/core/lib/debug/stats.cc',
+ 'src/core/lib/debug/stats_data.cc',
+ 'src/core/lib/http/format_request.cc',
+ 'src/core/lib/http/httpcli.cc',
+ 'src/core/lib/http/parser.cc',
+ 'src/core/lib/iomgr/call_combiner.cc',
+ 'src/core/lib/iomgr/combiner.cc',
+ 'src/core/lib/iomgr/endpoint.cc',
+ 'src/core/lib/iomgr/endpoint_pair_posix.cc',
+ 'src/core/lib/iomgr/endpoint_pair_uv.cc',
+ 'src/core/lib/iomgr/endpoint_pair_windows.cc',
+ 'src/core/lib/iomgr/error.cc',
+ 'src/core/lib/iomgr/ev_epoll1_linux.cc',
+ 'src/core/lib/iomgr/ev_epollex_linux.cc',
+ 'src/core/lib/iomgr/ev_epollsig_linux.cc',
+ 'src/core/lib/iomgr/ev_poll_posix.cc',
+ 'src/core/lib/iomgr/ev_posix.cc',
+ 'src/core/lib/iomgr/ev_windows.cc',
+ 'src/core/lib/iomgr/exec_ctx.cc',
+ 'src/core/lib/iomgr/executor.cc',
+ 'src/core/lib/iomgr/fork_posix.cc',
+ 'src/core/lib/iomgr/fork_windows.cc',
+ 'src/core/lib/iomgr/gethostname_fallback.cc',
+ 'src/core/lib/iomgr/gethostname_host_name_max.cc',
+ 'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/iocp_windows.cc',
+ 'src/core/lib/iomgr/iomgr.cc',
+ 'src/core/lib/iomgr/iomgr_posix.cc',
+ 'src/core/lib/iomgr/iomgr_uv.cc',
+ 'src/core/lib/iomgr/iomgr_windows.cc',
+ 'src/core/lib/iomgr/is_epollexclusive_available.cc',
+ 'src/core/lib/iomgr/load_file.cc',
+ 'src/core/lib/iomgr/lockfree_event.cc',
+ 'src/core/lib/iomgr/network_status_tracker.cc',
+ 'src/core/lib/iomgr/polling_entity.cc',
+ 'src/core/lib/iomgr/pollset_set_uv.cc',
+ 'src/core/lib/iomgr/pollset_set_windows.cc',
+ 'src/core/lib/iomgr/pollset_uv.cc',
+ 'src/core/lib/iomgr/pollset_windows.cc',
+ 'src/core/lib/iomgr/resolve_address_posix.cc',
+ 'src/core/lib/iomgr/resolve_address_uv.cc',
+ 'src/core/lib/iomgr/resolve_address_windows.cc',
+ 'src/core/lib/iomgr/resource_quota.cc',
+ 'src/core/lib/iomgr/sockaddr_utils.cc',
+ 'src/core/lib/iomgr/socket_factory_posix.cc',
+ 'src/core/lib/iomgr/socket_mutator.cc',
+ 'src/core/lib/iomgr/socket_utils_common_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_linux.cc',
+ 'src/core/lib/iomgr/socket_utils_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_uv.cc',
+ 'src/core/lib/iomgr/socket_utils_windows.cc',
+ 'src/core/lib/iomgr/socket_windows.cc',
+ 'src/core/lib/iomgr/tcp_client_posix.cc',
+ 'src/core/lib/iomgr/tcp_client_uv.cc',
+ 'src/core/lib/iomgr/tcp_client_windows.cc',
+ 'src/core/lib/iomgr/tcp_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_uv.cc',
+ 'src/core/lib/iomgr/tcp_server_windows.cc',
+ 'src/core/lib/iomgr/tcp_uv.cc',
+ 'src/core/lib/iomgr/tcp_windows.cc',
+ 'src/core/lib/iomgr/time_averaged_stats.cc',
+ 'src/core/lib/iomgr/timer_generic.cc',
+ 'src/core/lib/iomgr/timer_heap.cc',
+ 'src/core/lib/iomgr/timer_manager.cc',
+ 'src/core/lib/iomgr/timer_uv.cc',
+ 'src/core/lib/iomgr/udp_server.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.cc',
+ 'src/core/lib/iomgr/wakeup_fd_cv.cc',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.cc',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.cc',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.cc',
+ 'src/core/lib/iomgr/wakeup_fd_posix.cc',
+ 'src/core/lib/json/json.cc',
+ 'src/core/lib/json/json_reader.cc',
+ 'src/core/lib/json/json_string.cc',
+ 'src/core/lib/json/json_writer.cc',
+ 'src/core/lib/slice/b64.cc',
+ 'src/core/lib/slice/percent_encoding.cc',
+ 'src/core/lib/slice/slice.cc',
+ 'src/core/lib/slice/slice_buffer.cc',
+ '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',
+ 'src/core/lib/surface/call.cc',
+ 'src/core/lib/surface/call_details.cc',
+ 'src/core/lib/surface/call_log_batch.cc',
+ 'src/core/lib/surface/channel.cc',
+ 'src/core/lib/surface/channel_init.cc',
+ 'src/core/lib/surface/channel_ping.cc',
+ 'src/core/lib/surface/channel_stack_type.cc',
+ 'src/core/lib/surface/completion_queue.cc',
+ 'src/core/lib/surface/completion_queue_factory.cc',
+ 'src/core/lib/surface/event_string.cc',
'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
+ 'src/core/lib/surface/metadata_array.cc',
+ 'src/core/lib/surface/server.cc',
+ 'src/core/lib/surface/validate_metadata.cc',
+ 'src/core/lib/surface/version.cc',
+ 'src/core/lib/transport/bdp_estimator.cc',
+ 'src/core/lib/transport/byte_stream.cc',
+ 'src/core/lib/transport/connectivity_state.cc',
+ 'src/core/lib/transport/error_utils.cc',
+ 'src/core/lib/transport/metadata.cc',
+ 'src/core/lib/transport/metadata_batch.cc',
+ 'src/core/lib/transport/pid_controller.cc',
+ 'src/core/lib/transport/service_config.cc',
+ 'src/core/lib/transport/static_metadata.cc',
+ 'src/core/lib/transport/status_conversion.cc',
+ 'src/core/lib/transport/timeout_encoding.cc',
+ 'src/core/lib/transport/transport.cc',
+ 'src/core/lib/transport/transport_op_string.cc',
+ 'src/core/lib/debug/trace.cc',
+ 'src/core/ext/filters/client_channel/backup_poller.cc',
+ 'src/core/ext/filters/client_channel/channel_connectivity.cc',
+ 'src/core/ext/filters/client_channel/client_channel.cc',
+ 'src/core/ext/filters/client_channel/client_channel_factory.cc',
+ 'src/core/ext/filters/client_channel/client_channel_plugin.cc',
+ 'src/core/ext/filters/client_channel/connector.cc',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
+ 'src/core/ext/filters/client_channel/http_proxy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.cc',
+ 'src/core/ext/filters/client_channel/parse_address.cc',
+ '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',
+ 'src/core/ext/filters/client_channel/subchannel_index.cc',
+ 'src/core/ext/filters/client_channel/uri_parser.cc',
+ 'src/core/ext/filters/deadline/deadline_filter.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc',
+ 'src/core/ext/transport/chttp2/transport/flow_control.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_data.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.cc',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.cc',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.cc',
+ 'src/core/ext/transport/chttp2/transport/parsing.cc',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.cc',
+ '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/ext/transport/chttp2/alpn/alpn.cc',
+ 'src/core/ext/filters/http/client/http_client_filter.cc',
+ 'src/core/ext/filters/http/http_filters_plugin.cc',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
+ 'src/core/ext/filters/http/server/http_server_filter.cc',
],
},
{
@@ -715,201 +717,209 @@
'grpc_unsecure',
],
'sources': [
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'test/core/end2end/cq_verifier.c',
- 'test/core/end2end/fixtures/http_proxy_fixture.c',
- 'test/core/end2end/fixtures/proxy.c',
- 'test/core/iomgr/endpoint_tests.c',
- 'test/core/util/debugger_macros.c',
- 'test/core/util/grpc_profiler.c',
- 'test/core/util/memory_counters.c',
- 'test/core/util/mock_endpoint.c',
- 'test/core/util/parse_hexstring.c',
- 'test/core/util/passthru_endpoint.c',
- 'test/core/util/port.c',
- 'test/core/util/port_server_client.c',
- 'test/core/util/slice_splitter.c',
- 'test/core/util/trickle_endpoint.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
+ 'test/core/end2end/cq_verifier.cc',
+ 'test/core/end2end/fixtures/http_proxy_fixture.cc',
+ 'test/core/end2end/fixtures/proxy.cc',
+ 'test/core/iomgr/endpoint_tests.cc',
+ 'test/core/util/debugger_macros.cc',
+ 'test/core/util/grpc_profiler.cc',
+ 'test/core/util/histogram.cc',
+ 'test/core/util/memory_counters.cc',
+ 'test/core/util/mock_endpoint.cc',
+ 'test/core/util/parse_hexstring.cc',
+ 'test/core/util/passthru_endpoint.cc',
+ 'test/core/util/port.cc',
+ 'test/core/util/port_isolated_runtime_environment.cc',
+ 'test/core/util/port_server_client.cc',
+ 'test/core/util/slice_splitter.cc',
+ 'test/core/util/tracer_util.cc',
+ 'test/core/util/trickle_endpoint.cc',
+ 'src/core/lib/backoff/backoff.cc',
+ 'src/core/lib/channel/channel_args.cc',
+ 'src/core/lib/channel/channel_stack.cc',
+ 'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/connected_channel.cc',
+ 'src/core/lib/channel/handshaker.cc',
+ 'src/core/lib/channel/handshaker_factory.cc',
+ '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',
+ 'src/core/lib/compression/stream_compression_identity.cc',
+ 'src/core/lib/debug/stats.cc',
+ 'src/core/lib/debug/stats_data.cc',
+ 'src/core/lib/http/format_request.cc',
+ 'src/core/lib/http/httpcli.cc',
+ 'src/core/lib/http/parser.cc',
+ 'src/core/lib/iomgr/call_combiner.cc',
+ 'src/core/lib/iomgr/combiner.cc',
+ 'src/core/lib/iomgr/endpoint.cc',
+ 'src/core/lib/iomgr/endpoint_pair_posix.cc',
+ 'src/core/lib/iomgr/endpoint_pair_uv.cc',
+ 'src/core/lib/iomgr/endpoint_pair_windows.cc',
+ 'src/core/lib/iomgr/error.cc',
+ 'src/core/lib/iomgr/ev_epoll1_linux.cc',
+ 'src/core/lib/iomgr/ev_epollex_linux.cc',
+ 'src/core/lib/iomgr/ev_epollsig_linux.cc',
+ 'src/core/lib/iomgr/ev_poll_posix.cc',
+ 'src/core/lib/iomgr/ev_posix.cc',
+ 'src/core/lib/iomgr/ev_windows.cc',
+ 'src/core/lib/iomgr/exec_ctx.cc',
+ 'src/core/lib/iomgr/executor.cc',
+ 'src/core/lib/iomgr/fork_posix.cc',
+ 'src/core/lib/iomgr/fork_windows.cc',
+ 'src/core/lib/iomgr/gethostname_fallback.cc',
+ 'src/core/lib/iomgr/gethostname_host_name_max.cc',
+ 'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/iocp_windows.cc',
+ 'src/core/lib/iomgr/iomgr.cc',
+ 'src/core/lib/iomgr/iomgr_posix.cc',
+ 'src/core/lib/iomgr/iomgr_uv.cc',
+ 'src/core/lib/iomgr/iomgr_windows.cc',
+ 'src/core/lib/iomgr/is_epollexclusive_available.cc',
+ 'src/core/lib/iomgr/load_file.cc',
+ 'src/core/lib/iomgr/lockfree_event.cc',
+ 'src/core/lib/iomgr/network_status_tracker.cc',
+ 'src/core/lib/iomgr/polling_entity.cc',
+ 'src/core/lib/iomgr/pollset_set_uv.cc',
+ 'src/core/lib/iomgr/pollset_set_windows.cc',
+ 'src/core/lib/iomgr/pollset_uv.cc',
+ 'src/core/lib/iomgr/pollset_windows.cc',
+ 'src/core/lib/iomgr/resolve_address_posix.cc',
+ 'src/core/lib/iomgr/resolve_address_uv.cc',
+ 'src/core/lib/iomgr/resolve_address_windows.cc',
+ 'src/core/lib/iomgr/resource_quota.cc',
+ 'src/core/lib/iomgr/sockaddr_utils.cc',
+ 'src/core/lib/iomgr/socket_factory_posix.cc',
+ 'src/core/lib/iomgr/socket_mutator.cc',
+ 'src/core/lib/iomgr/socket_utils_common_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_linux.cc',
+ 'src/core/lib/iomgr/socket_utils_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_uv.cc',
+ 'src/core/lib/iomgr/socket_utils_windows.cc',
+ 'src/core/lib/iomgr/socket_windows.cc',
+ 'src/core/lib/iomgr/tcp_client_posix.cc',
+ 'src/core/lib/iomgr/tcp_client_uv.cc',
+ 'src/core/lib/iomgr/tcp_client_windows.cc',
+ 'src/core/lib/iomgr/tcp_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_uv.cc',
+ 'src/core/lib/iomgr/tcp_server_windows.cc',
+ 'src/core/lib/iomgr/tcp_uv.cc',
+ 'src/core/lib/iomgr/tcp_windows.cc',
+ 'src/core/lib/iomgr/time_averaged_stats.cc',
+ 'src/core/lib/iomgr/timer_generic.cc',
+ 'src/core/lib/iomgr/timer_heap.cc',
+ 'src/core/lib/iomgr/timer_manager.cc',
+ 'src/core/lib/iomgr/timer_uv.cc',
+ 'src/core/lib/iomgr/udp_server.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.cc',
+ 'src/core/lib/iomgr/wakeup_fd_cv.cc',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.cc',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.cc',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.cc',
+ 'src/core/lib/iomgr/wakeup_fd_posix.cc',
+ 'src/core/lib/json/json.cc',
+ 'src/core/lib/json/json_reader.cc',
+ 'src/core/lib/json/json_string.cc',
+ 'src/core/lib/json/json_writer.cc',
+ 'src/core/lib/slice/b64.cc',
+ 'src/core/lib/slice/percent_encoding.cc',
+ 'src/core/lib/slice/slice.cc',
+ 'src/core/lib/slice/slice_buffer.cc',
+ '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',
+ 'src/core/lib/surface/call.cc',
+ 'src/core/lib/surface/call_details.cc',
+ 'src/core/lib/surface/call_log_batch.cc',
+ 'src/core/lib/surface/channel.cc',
+ 'src/core/lib/surface/channel_init.cc',
+ 'src/core/lib/surface/channel_ping.cc',
+ 'src/core/lib/surface/channel_stack_type.cc',
+ 'src/core/lib/surface/completion_queue.cc',
+ 'src/core/lib/surface/completion_queue_factory.cc',
+ 'src/core/lib/surface/event_string.cc',
'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
+ 'src/core/lib/surface/metadata_array.cc',
+ 'src/core/lib/surface/server.cc',
+ 'src/core/lib/surface/validate_metadata.cc',
+ 'src/core/lib/surface/version.cc',
+ 'src/core/lib/transport/bdp_estimator.cc',
+ 'src/core/lib/transport/byte_stream.cc',
+ 'src/core/lib/transport/connectivity_state.cc',
+ 'src/core/lib/transport/error_utils.cc',
+ 'src/core/lib/transport/metadata.cc',
+ 'src/core/lib/transport/metadata_batch.cc',
+ 'src/core/lib/transport/pid_controller.cc',
+ 'src/core/lib/transport/service_config.cc',
+ 'src/core/lib/transport/static_metadata.cc',
+ 'src/core/lib/transport/status_conversion.cc',
+ 'src/core/lib/transport/timeout_encoding.cc',
+ 'src/core/lib/transport/transport.cc',
+ 'src/core/lib/transport/transport_op_string.cc',
+ 'src/core/lib/debug/trace.cc',
+ 'src/core/ext/filters/client_channel/backup_poller.cc',
+ 'src/core/ext/filters/client_channel/channel_connectivity.cc',
+ 'src/core/ext/filters/client_channel/client_channel.cc',
+ 'src/core/ext/filters/client_channel/client_channel_factory.cc',
+ 'src/core/ext/filters/client_channel/client_channel_plugin.cc',
+ 'src/core/ext/filters/client_channel/connector.cc',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
+ 'src/core/ext/filters/client_channel/http_proxy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.cc',
+ 'src/core/ext/filters/client_channel/parse_address.cc',
+ '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',
+ 'src/core/ext/filters/client_channel/subchannel_index.cc',
+ 'src/core/ext/filters/client_channel/uri_parser.cc',
+ 'src/core/ext/filters/deadline/deadline_filter.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc',
+ 'src/core/ext/transport/chttp2/transport/flow_control.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_data.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.cc',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.cc',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.cc',
+ 'src/core/ext/transport/chttp2/transport/parsing.cc',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.cc',
+ '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/ext/transport/chttp2/alpn/alpn.cc',
+ 'src/core/ext/filters/http/client/http_client_filter.cc',
+ 'src/core/ext/filters/http/http_filters_plugin.cc',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
+ 'src/core/ext/filters/http/server/http_server_filter.cc',
],
},
{
@@ -919,236 +929,228 @@
'gpr',
],
'sources': [
- 'src/core/lib/surface/init.c',
- 'src/core/lib/surface/init_unsecure.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
+ 'src/core/lib/surface/init.cc',
+ 'src/core/lib/surface/init_unsecure.cc',
+ 'src/core/lib/backoff/backoff.cc',
+ 'src/core/lib/channel/channel_args.cc',
+ 'src/core/lib/channel/channel_stack.cc',
+ 'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/connected_channel.cc',
+ 'src/core/lib/channel/handshaker.cc',
+ 'src/core/lib/channel/handshaker_factory.cc',
+ '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',
+ 'src/core/lib/compression/stream_compression_identity.cc',
+ 'src/core/lib/debug/stats.cc',
+ 'src/core/lib/debug/stats_data.cc',
+ 'src/core/lib/http/format_request.cc',
+ 'src/core/lib/http/httpcli.cc',
+ 'src/core/lib/http/parser.cc',
+ 'src/core/lib/iomgr/call_combiner.cc',
+ 'src/core/lib/iomgr/combiner.cc',
+ 'src/core/lib/iomgr/endpoint.cc',
+ 'src/core/lib/iomgr/endpoint_pair_posix.cc',
+ 'src/core/lib/iomgr/endpoint_pair_uv.cc',
+ 'src/core/lib/iomgr/endpoint_pair_windows.cc',
+ 'src/core/lib/iomgr/error.cc',
+ 'src/core/lib/iomgr/ev_epoll1_linux.cc',
+ 'src/core/lib/iomgr/ev_epollex_linux.cc',
+ 'src/core/lib/iomgr/ev_epollsig_linux.cc',
+ 'src/core/lib/iomgr/ev_poll_posix.cc',
+ 'src/core/lib/iomgr/ev_posix.cc',
+ 'src/core/lib/iomgr/ev_windows.cc',
+ 'src/core/lib/iomgr/exec_ctx.cc',
+ 'src/core/lib/iomgr/executor.cc',
+ 'src/core/lib/iomgr/fork_posix.cc',
+ 'src/core/lib/iomgr/fork_windows.cc',
+ 'src/core/lib/iomgr/gethostname_fallback.cc',
+ 'src/core/lib/iomgr/gethostname_host_name_max.cc',
+ 'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/iocp_windows.cc',
+ 'src/core/lib/iomgr/iomgr.cc',
+ 'src/core/lib/iomgr/iomgr_posix.cc',
+ 'src/core/lib/iomgr/iomgr_uv.cc',
+ 'src/core/lib/iomgr/iomgr_windows.cc',
+ 'src/core/lib/iomgr/is_epollexclusive_available.cc',
+ 'src/core/lib/iomgr/load_file.cc',
+ 'src/core/lib/iomgr/lockfree_event.cc',
+ 'src/core/lib/iomgr/network_status_tracker.cc',
+ 'src/core/lib/iomgr/polling_entity.cc',
+ 'src/core/lib/iomgr/pollset_set_uv.cc',
+ 'src/core/lib/iomgr/pollset_set_windows.cc',
+ 'src/core/lib/iomgr/pollset_uv.cc',
+ 'src/core/lib/iomgr/pollset_windows.cc',
+ 'src/core/lib/iomgr/resolve_address_posix.cc',
+ 'src/core/lib/iomgr/resolve_address_uv.cc',
+ 'src/core/lib/iomgr/resolve_address_windows.cc',
+ 'src/core/lib/iomgr/resource_quota.cc',
+ 'src/core/lib/iomgr/sockaddr_utils.cc',
+ 'src/core/lib/iomgr/socket_factory_posix.cc',
+ 'src/core/lib/iomgr/socket_mutator.cc',
+ 'src/core/lib/iomgr/socket_utils_common_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_linux.cc',
+ 'src/core/lib/iomgr/socket_utils_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_uv.cc',
+ 'src/core/lib/iomgr/socket_utils_windows.cc',
+ 'src/core/lib/iomgr/socket_windows.cc',
+ 'src/core/lib/iomgr/tcp_client_posix.cc',
+ 'src/core/lib/iomgr/tcp_client_uv.cc',
+ 'src/core/lib/iomgr/tcp_client_windows.cc',
+ 'src/core/lib/iomgr/tcp_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_uv.cc',
+ 'src/core/lib/iomgr/tcp_server_windows.cc',
+ 'src/core/lib/iomgr/tcp_uv.cc',
+ 'src/core/lib/iomgr/tcp_windows.cc',
+ 'src/core/lib/iomgr/time_averaged_stats.cc',
+ 'src/core/lib/iomgr/timer_generic.cc',
+ 'src/core/lib/iomgr/timer_heap.cc',
+ 'src/core/lib/iomgr/timer_manager.cc',
+ 'src/core/lib/iomgr/timer_uv.cc',
+ 'src/core/lib/iomgr/udp_server.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.cc',
+ 'src/core/lib/iomgr/wakeup_fd_cv.cc',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.cc',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.cc',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.cc',
+ 'src/core/lib/iomgr/wakeup_fd_posix.cc',
+ 'src/core/lib/json/json.cc',
+ 'src/core/lib/json/json_reader.cc',
+ 'src/core/lib/json/json_string.cc',
+ 'src/core/lib/json/json_writer.cc',
+ 'src/core/lib/slice/b64.cc',
+ 'src/core/lib/slice/percent_encoding.cc',
+ 'src/core/lib/slice/slice.cc',
+ 'src/core/lib/slice/slice_buffer.cc',
+ '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',
+ 'src/core/lib/surface/call.cc',
+ 'src/core/lib/surface/call_details.cc',
+ 'src/core/lib/surface/call_log_batch.cc',
+ 'src/core/lib/surface/channel.cc',
+ 'src/core/lib/surface/channel_init.cc',
+ 'src/core/lib/surface/channel_ping.cc',
+ 'src/core/lib/surface/channel_stack_type.cc',
+ 'src/core/lib/surface/completion_queue.cc',
+ 'src/core/lib/surface/completion_queue_factory.cc',
+ 'src/core/lib/surface/event_string.cc',
'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
- 'src/core/ext/transport/chttp2/server/chttp2_server.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
- 'src/core/ext/transport/chttp2/client/chttp2_connector.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/inproc/inproc_plugin.c',
- 'src/core/ext/transport/inproc/inproc_transport.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c',
- 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c',
- 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c',
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
+ 'src/core/lib/surface/metadata_array.cc',
+ 'src/core/lib/surface/server.cc',
+ 'src/core/lib/surface/validate_metadata.cc',
+ 'src/core/lib/surface/version.cc',
+ 'src/core/lib/transport/bdp_estimator.cc',
+ 'src/core/lib/transport/byte_stream.cc',
+ 'src/core/lib/transport/connectivity_state.cc',
+ 'src/core/lib/transport/error_utils.cc',
+ 'src/core/lib/transport/metadata.cc',
+ 'src/core/lib/transport/metadata_batch.cc',
+ 'src/core/lib/transport/pid_controller.cc',
+ 'src/core/lib/transport/service_config.cc',
+ 'src/core/lib/transport/static_metadata.cc',
+ 'src/core/lib/transport/status_conversion.cc',
+ 'src/core/lib/transport/timeout_encoding.cc',
+ 'src/core/lib/transport/transport.cc',
+ 'src/core/lib/transport/transport_op_string.cc',
+ 'src/core/lib/debug/trace.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc',
+ 'src/core/ext/transport/chttp2/transport/flow_control.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_data.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.cc',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.cc',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.cc',
+ 'src/core/ext/transport/chttp2/transport/parsing.cc',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.cc',
+ '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/ext/transport/chttp2/alpn/alpn.cc',
+ 'src/core/ext/filters/http/client/http_client_filter.cc',
+ 'src/core/ext/filters/http/http_filters_plugin.cc',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
+ 'src/core/ext/filters/http/server/http_server_filter.cc',
+ 'src/core/ext/transport/chttp2/server/chttp2_server.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc',
+ 'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
+ 'src/core/ext/filters/client_channel/backup_poller.cc',
+ 'src/core/ext/filters/client_channel/channel_connectivity.cc',
+ 'src/core/ext/filters/client_channel/client_channel.cc',
+ 'src/core/ext/filters/client_channel/client_channel_factory.cc',
+ 'src/core/ext/filters/client_channel/client_channel_plugin.cc',
+ 'src/core/ext/filters/client_channel/connector.cc',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
+ 'src/core/ext/filters/client_channel/http_proxy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.cc',
+ 'src/core/ext/filters/client_channel/parse_address.cc',
+ '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',
+ 'src/core/ext/filters/client_channel/subchannel_index.cc',
+ 'src/core/ext/filters/client_channel/uri_parser.cc',
+ 'src/core/ext/filters/deadline/deadline_filter.cc',
+ 'src/core/ext/transport/inproc/inproc_plugin.cc',
+ 'src/core/ext/transport/inproc/inproc_transport.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
+ 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_filter.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
- 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c',
- 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c',
- 'src/core/ext/census/base_resources.c',
- 'src/core/ext/census/context.c',
- 'src/core/ext/census/gen/census.pb.c',
- 'src/core/ext/census/gen/trace_context.pb.c',
- 'src/core/ext/census/grpc_context.c',
- 'src/core/ext/census/grpc_filter.c',
- 'src/core/ext/census/grpc_plugin.c',
- 'src/core/ext/census/initialize.c',
- 'src/core/ext/census/intrusive_hash_map.c',
- 'src/core/ext/census/mlog.c',
- 'src/core/ext/census/operation.c',
- 'src/core/ext/census/placeholders.c',
- 'src/core/ext/census/resource.c',
- 'src/core/ext/census/trace_context.c',
- 'src/core/ext/census/tracing.c',
- 'src/core/ext/filters/max_age/max_age_filter.c',
- 'src/core/ext/filters/message_size/message_size_filter.c',
- 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c',
- 'src/core/ext/filters/workarounds/workaround_utils.c',
- 'src/core/plugin_registry/grpc_unsecure_plugin_registry.c',
+ 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc',
+ 'src/core/ext/census/grpc_context.cc',
+ 'src/core/ext/filters/max_age/max_age_filter.cc',
+ 'src/core/ext/filters/message_size/message_size_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_utils.cc',
+ 'src/core/plugin_registry/grpc_unsecure_plugin_registry.cc',
],
},
{
@@ -1162,7 +1164,7 @@
'gpr',
],
'sources': [
- 'test/core/util/reconnect_server.c',
+ 'test/core/util/reconnect_server.cc',
],
},
{
@@ -1175,7 +1177,7 @@
'gpr',
],
'sources': [
- 'test/core/util/test_tcp_server.c',
+ 'test/core/util/test_tcp_server.cc',
],
},
{
@@ -2309,6 +2311,7 @@
'third_party/benchmark/src/commandlineflags.cc',
'third_party/benchmark/src/complexity.cc',
'third_party/benchmark/src/console_reporter.cc',
+ 'third_party/benchmark/src/counter.cc',
'third_party/benchmark/src/csv_reporter.cc',
'third_party/benchmark/src/json_reporter.cc',
'third_party/benchmark/src/reporter.cc',
@@ -2351,7 +2354,7 @@
'gpr',
],
'sources': [
- 'test/core/bad_client/bad_client.c',
+ 'test/core/bad_client/bad_client.cc',
],
},
{
@@ -2364,67 +2367,68 @@
'gpr',
],
'sources': [
- 'test/core/end2end/end2end_tests.c',
- 'test/core/end2end/end2end_test_utils.c',
- 'test/core/end2end/tests/authority_not_supported.c',
- 'test/core/end2end/tests/bad_hostname.c',
- 'test/core/end2end/tests/bad_ping.c',
- 'test/core/end2end/tests/binary_metadata.c',
- 'test/core/end2end/tests/call_creds.c',
- 'test/core/end2end/tests/cancel_after_accept.c',
- 'test/core/end2end/tests/cancel_after_client_done.c',
- 'test/core/end2end/tests/cancel_after_invoke.c',
- 'test/core/end2end/tests/cancel_after_round_trip.c',
- 'test/core/end2end/tests/cancel_before_invoke.c',
- 'test/core/end2end/tests/cancel_in_a_vacuum.c',
- 'test/core/end2end/tests/cancel_with_status.c',
- 'test/core/end2end/tests/compressed_payload.c',
- 'test/core/end2end/tests/connectivity.c',
- 'test/core/end2end/tests/default_host.c',
- 'test/core/end2end/tests/disappearing_server.c',
- 'test/core/end2end/tests/empty_batch.c',
- 'test/core/end2end/tests/filter_call_init_fails.c',
- 'test/core/end2end/tests/filter_causes_close.c',
- 'test/core/end2end/tests/filter_latency.c',
- 'test/core/end2end/tests/graceful_server_shutdown.c',
- 'test/core/end2end/tests/high_initial_seqno.c',
- 'test/core/end2end/tests/hpack_size.c',
- 'test/core/end2end/tests/idempotent_request.c',
- 'test/core/end2end/tests/invoke_large_request.c',
- 'test/core/end2end/tests/keepalive_timeout.c',
- 'test/core/end2end/tests/large_metadata.c',
- 'test/core/end2end/tests/load_reporting_hook.c',
- 'test/core/end2end/tests/max_concurrent_streams.c',
- 'test/core/end2end/tests/max_connection_age.c',
- 'test/core/end2end/tests/max_connection_idle.c',
- 'test/core/end2end/tests/max_message_length.c',
- 'test/core/end2end/tests/negative_deadline.c',
- 'test/core/end2end/tests/network_status_change.c',
- 'test/core/end2end/tests/no_logging.c',
- 'test/core/end2end/tests/no_op.c',
- 'test/core/end2end/tests/payload.c',
- 'test/core/end2end/tests/ping.c',
- 'test/core/end2end/tests/ping_pong_streaming.c',
- 'test/core/end2end/tests/proxy_auth.c',
- 'test/core/end2end/tests/registered_call.c',
- 'test/core/end2end/tests/request_with_flags.c',
- 'test/core/end2end/tests/request_with_payload.c',
- 'test/core/end2end/tests/resource_quota_server.c',
- 'test/core/end2end/tests/server_finishes_request.c',
- 'test/core/end2end/tests/shutdown_finishes_calls.c',
- 'test/core/end2end/tests/shutdown_finishes_tags.c',
- 'test/core/end2end/tests/simple_cacheable_request.c',
- 'test/core/end2end/tests/simple_delayed_request.c',
- 'test/core/end2end/tests/simple_metadata.c',
- 'test/core/end2end/tests/simple_request.c',
- 'test/core/end2end/tests/stream_compression_compressed_payload.c',
- 'test/core/end2end/tests/stream_compression_payload.c',
- 'test/core/end2end/tests/stream_compression_ping_pong_streaming.c',
- 'test/core/end2end/tests/streaming_error_response.c',
- 'test/core/end2end/tests/trailing_metadata.c',
- 'test/core/end2end/tests/workaround_cronet_compression.c',
- 'test/core/end2end/tests/write_buffering.c',
- 'test/core/end2end/tests/write_buffering_at_end.c',
+ 'test/core/end2end/end2end_tests.cc',
+ 'test/core/end2end/end2end_test_utils.cc',
+ 'test/core/end2end/tests/authority_not_supported.cc',
+ 'test/core/end2end/tests/bad_hostname.cc',
+ 'test/core/end2end/tests/bad_ping.cc',
+ 'test/core/end2end/tests/binary_metadata.cc',
+ 'test/core/end2end/tests/call_creds.cc',
+ 'test/core/end2end/tests/cancel_after_accept.cc',
+ 'test/core/end2end/tests/cancel_after_client_done.cc',
+ 'test/core/end2end/tests/cancel_after_invoke.cc',
+ 'test/core/end2end/tests/cancel_after_round_trip.cc',
+ 'test/core/end2end/tests/cancel_before_invoke.cc',
+ 'test/core/end2end/tests/cancel_in_a_vacuum.cc',
+ 'test/core/end2end/tests/cancel_with_status.cc',
+ 'test/core/end2end/tests/compressed_payload.cc',
+ 'test/core/end2end/tests/connectivity.cc',
+ 'test/core/end2end/tests/default_host.cc',
+ 'test/core/end2end/tests/disappearing_server.cc',
+ 'test/core/end2end/tests/empty_batch.cc',
+ 'test/core/end2end/tests/filter_call_init_fails.cc',
+ 'test/core/end2end/tests/filter_causes_close.cc',
+ 'test/core/end2end/tests/filter_latency.cc',
+ 'test/core/end2end/tests/filter_status_code.cc',
+ 'test/core/end2end/tests/graceful_server_shutdown.cc',
+ 'test/core/end2end/tests/high_initial_seqno.cc',
+ 'test/core/end2end/tests/hpack_size.cc',
+ 'test/core/end2end/tests/idempotent_request.cc',
+ 'test/core/end2end/tests/invoke_large_request.cc',
+ 'test/core/end2end/tests/keepalive_timeout.cc',
+ 'test/core/end2end/tests/large_metadata.cc',
+ 'test/core/end2end/tests/load_reporting_hook.cc',
+ 'test/core/end2end/tests/max_concurrent_streams.cc',
+ 'test/core/end2end/tests/max_connection_age.cc',
+ 'test/core/end2end/tests/max_connection_idle.cc',
+ 'test/core/end2end/tests/max_message_length.cc',
+ 'test/core/end2end/tests/negative_deadline.cc',
+ 'test/core/end2end/tests/network_status_change.cc',
+ 'test/core/end2end/tests/no_logging.cc',
+ 'test/core/end2end/tests/no_op.cc',
+ 'test/core/end2end/tests/payload.cc',
+ 'test/core/end2end/tests/ping.cc',
+ 'test/core/end2end/tests/ping_pong_streaming.cc',
+ 'test/core/end2end/tests/proxy_auth.cc',
+ 'test/core/end2end/tests/registered_call.cc',
+ 'test/core/end2end/tests/request_with_flags.cc',
+ 'test/core/end2end/tests/request_with_payload.cc',
+ 'test/core/end2end/tests/resource_quota_server.cc',
+ 'test/core/end2end/tests/server_finishes_request.cc',
+ 'test/core/end2end/tests/shutdown_finishes_calls.cc',
+ 'test/core/end2end/tests/shutdown_finishes_tags.cc',
+ 'test/core/end2end/tests/simple_cacheable_request.cc',
+ 'test/core/end2end/tests/simple_delayed_request.cc',
+ 'test/core/end2end/tests/simple_metadata.cc',
+ 'test/core/end2end/tests/simple_request.cc',
+ 'test/core/end2end/tests/stream_compression_compressed_payload.cc',
+ 'test/core/end2end/tests/stream_compression_payload.cc',
+ 'test/core/end2end/tests/stream_compression_ping_pong_streaming.cc',
+ 'test/core/end2end/tests/streaming_error_response.cc',
+ 'test/core/end2end/tests/trailing_metadata.cc',
+ 'test/core/end2end/tests/workaround_cronet_compression.cc',
+ 'test/core/end2end/tests/write_buffering.cc',
+ 'test/core/end2end/tests/write_buffering_at_end.cc',
],
},
{
@@ -2437,66 +2441,67 @@
'gpr',
],
'sources': [
- 'test/core/end2end/end2end_nosec_tests.c',
- 'test/core/end2end/end2end_test_utils.c',
- 'test/core/end2end/tests/authority_not_supported.c',
- 'test/core/end2end/tests/bad_hostname.c',
- 'test/core/end2end/tests/bad_ping.c',
- 'test/core/end2end/tests/binary_metadata.c',
- 'test/core/end2end/tests/cancel_after_accept.c',
- 'test/core/end2end/tests/cancel_after_client_done.c',
- 'test/core/end2end/tests/cancel_after_invoke.c',
- 'test/core/end2end/tests/cancel_after_round_trip.c',
- 'test/core/end2end/tests/cancel_before_invoke.c',
- 'test/core/end2end/tests/cancel_in_a_vacuum.c',
- 'test/core/end2end/tests/cancel_with_status.c',
- 'test/core/end2end/tests/compressed_payload.c',
- 'test/core/end2end/tests/connectivity.c',
- 'test/core/end2end/tests/default_host.c',
- 'test/core/end2end/tests/disappearing_server.c',
- 'test/core/end2end/tests/empty_batch.c',
- 'test/core/end2end/tests/filter_call_init_fails.c',
- 'test/core/end2end/tests/filter_causes_close.c',
- 'test/core/end2end/tests/filter_latency.c',
- 'test/core/end2end/tests/graceful_server_shutdown.c',
- 'test/core/end2end/tests/high_initial_seqno.c',
- 'test/core/end2end/tests/hpack_size.c',
- 'test/core/end2end/tests/idempotent_request.c',
- 'test/core/end2end/tests/invoke_large_request.c',
- 'test/core/end2end/tests/keepalive_timeout.c',
- 'test/core/end2end/tests/large_metadata.c',
- 'test/core/end2end/tests/load_reporting_hook.c',
- 'test/core/end2end/tests/max_concurrent_streams.c',
- 'test/core/end2end/tests/max_connection_age.c',
- 'test/core/end2end/tests/max_connection_idle.c',
- 'test/core/end2end/tests/max_message_length.c',
- 'test/core/end2end/tests/negative_deadline.c',
- 'test/core/end2end/tests/network_status_change.c',
- 'test/core/end2end/tests/no_logging.c',
- 'test/core/end2end/tests/no_op.c',
- 'test/core/end2end/tests/payload.c',
- 'test/core/end2end/tests/ping.c',
- 'test/core/end2end/tests/ping_pong_streaming.c',
- 'test/core/end2end/tests/proxy_auth.c',
- 'test/core/end2end/tests/registered_call.c',
- 'test/core/end2end/tests/request_with_flags.c',
- 'test/core/end2end/tests/request_with_payload.c',
- 'test/core/end2end/tests/resource_quota_server.c',
- 'test/core/end2end/tests/server_finishes_request.c',
- 'test/core/end2end/tests/shutdown_finishes_calls.c',
- 'test/core/end2end/tests/shutdown_finishes_tags.c',
- 'test/core/end2end/tests/simple_cacheable_request.c',
- 'test/core/end2end/tests/simple_delayed_request.c',
- 'test/core/end2end/tests/simple_metadata.c',
- 'test/core/end2end/tests/simple_request.c',
- 'test/core/end2end/tests/stream_compression_compressed_payload.c',
- 'test/core/end2end/tests/stream_compression_payload.c',
- 'test/core/end2end/tests/stream_compression_ping_pong_streaming.c',
- 'test/core/end2end/tests/streaming_error_response.c',
- 'test/core/end2end/tests/trailing_metadata.c',
- 'test/core/end2end/tests/workaround_cronet_compression.c',
- 'test/core/end2end/tests/write_buffering.c',
- 'test/core/end2end/tests/write_buffering_at_end.c',
+ 'test/core/end2end/end2end_nosec_tests.cc',
+ 'test/core/end2end/end2end_test_utils.cc',
+ 'test/core/end2end/tests/authority_not_supported.cc',
+ 'test/core/end2end/tests/bad_hostname.cc',
+ 'test/core/end2end/tests/bad_ping.cc',
+ 'test/core/end2end/tests/binary_metadata.cc',
+ 'test/core/end2end/tests/cancel_after_accept.cc',
+ 'test/core/end2end/tests/cancel_after_client_done.cc',
+ 'test/core/end2end/tests/cancel_after_invoke.cc',
+ 'test/core/end2end/tests/cancel_after_round_trip.cc',
+ 'test/core/end2end/tests/cancel_before_invoke.cc',
+ 'test/core/end2end/tests/cancel_in_a_vacuum.cc',
+ 'test/core/end2end/tests/cancel_with_status.cc',
+ 'test/core/end2end/tests/compressed_payload.cc',
+ 'test/core/end2end/tests/connectivity.cc',
+ 'test/core/end2end/tests/default_host.cc',
+ 'test/core/end2end/tests/disappearing_server.cc',
+ 'test/core/end2end/tests/empty_batch.cc',
+ 'test/core/end2end/tests/filter_call_init_fails.cc',
+ 'test/core/end2end/tests/filter_causes_close.cc',
+ 'test/core/end2end/tests/filter_latency.cc',
+ 'test/core/end2end/tests/filter_status_code.cc',
+ 'test/core/end2end/tests/graceful_server_shutdown.cc',
+ 'test/core/end2end/tests/high_initial_seqno.cc',
+ 'test/core/end2end/tests/hpack_size.cc',
+ 'test/core/end2end/tests/idempotent_request.cc',
+ 'test/core/end2end/tests/invoke_large_request.cc',
+ 'test/core/end2end/tests/keepalive_timeout.cc',
+ 'test/core/end2end/tests/large_metadata.cc',
+ 'test/core/end2end/tests/load_reporting_hook.cc',
+ 'test/core/end2end/tests/max_concurrent_streams.cc',
+ 'test/core/end2end/tests/max_connection_age.cc',
+ 'test/core/end2end/tests/max_connection_idle.cc',
+ 'test/core/end2end/tests/max_message_length.cc',
+ 'test/core/end2end/tests/negative_deadline.cc',
+ 'test/core/end2end/tests/network_status_change.cc',
+ 'test/core/end2end/tests/no_logging.cc',
+ 'test/core/end2end/tests/no_op.cc',
+ 'test/core/end2end/tests/payload.cc',
+ 'test/core/end2end/tests/ping.cc',
+ 'test/core/end2end/tests/ping_pong_streaming.cc',
+ 'test/core/end2end/tests/proxy_auth.cc',
+ 'test/core/end2end/tests/registered_call.cc',
+ 'test/core/end2end/tests/request_with_flags.cc',
+ 'test/core/end2end/tests/request_with_payload.cc',
+ 'test/core/end2end/tests/resource_quota_server.cc',
+ 'test/core/end2end/tests/server_finishes_request.cc',
+ 'test/core/end2end/tests/shutdown_finishes_calls.cc',
+ 'test/core/end2end/tests/shutdown_finishes_tags.cc',
+ 'test/core/end2end/tests/simple_cacheable_request.cc',
+ 'test/core/end2end/tests/simple_delayed_request.cc',
+ 'test/core/end2end/tests/simple_metadata.cc',
+ 'test/core/end2end/tests/simple_request.cc',
+ 'test/core/end2end/tests/stream_compression_compressed_payload.cc',
+ 'test/core/end2end/tests/stream_compression_payload.cc',
+ 'test/core/end2end/tests/stream_compression_ping_pong_streaming.cc',
+ 'test/core/end2end/tests/streaming_error_response.cc',
+ 'test/core/end2end/tests/trailing_metadata.cc',
+ 'test/core/end2end/tests/workaround_cronet_compression.cc',
+ 'test/core/end2end/tests/write_buffering.cc',
+ 'test/core/end2end/tests/write_buffering_at_end.cc',
],
},
]
diff --git a/include/grpc++/alarm.h b/include/grpc++/alarm.h
index 2d88d868e5..b43425e224 100644
--- a/include/grpc++/alarm.h
+++ b/include/grpc++/alarm.h
@@ -92,7 +92,7 @@ class Alarm : private GrpcLibraryCodegen {
}
private:
- class AlarmEntry : public CompletionQueueTag {
+ class AlarmEntry : public internal::CompletionQueueTag {
public:
AlarmEntry(void* tag) : tag_(tag) {}
void Set(void* tag) { tag_ = tag; }
diff --git a/include/grpc++/channel.h b/include/grpc++/channel.h
index c50091d6ac..e9fb5a5d09 100644
--- a/include/grpc++/channel.h
+++ b/include/grpc++/channel.h
@@ -32,7 +32,7 @@ struct grpc_channel;
namespace grpc {
/// Channels represent a connection to an endpoint. Created by \a CreateChannel.
class Channel final : public ChannelInterface,
- public CallHook,
+ public internal::CallHook,
public std::enable_shared_from_this<Channel>,
private GrpcLibraryCodegen {
public:
@@ -51,18 +51,16 @@ class Channel final : public ChannelInterface,
private:
template <class InputMessage, class OutputMessage>
- friend Status BlockingUnaryCall(ChannelInterface* channel,
- const RpcMethod& method,
- ClientContext* context,
- const InputMessage& request,
- OutputMessage* result);
+ friend class internal::BlockingUnaryCallImpl;
friend std::shared_ptr<Channel> CreateChannelInternal(
const grpc::string& host, grpc_channel* c_channel);
Channel(const grpc::string& host, grpc_channel* c_channel);
- Call CreateCall(const RpcMethod& method, ClientContext* context,
- CompletionQueue* cq) override;
- void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override;
+ internal::Call CreateCall(const internal::RpcMethod& method,
+ ClientContext* context,
+ CompletionQueue* cq) override;
+ void PerformOpsOnCall(internal::CallOpSetInterface* ops,
+ internal::Call* call) override;
void* RegisterMethod(const char* method) override;
void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
diff --git a/include/grpc++/generic/async_generic_service.h b/include/grpc++/generic/async_generic_service.h
index cd9a65e3cb..b1ea4f3909 100644
--- a/include/grpc++/generic/async_generic_service.h
+++ b/include/grpc++/generic/async_generic_service.h
@@ -42,6 +42,23 @@ class GenericServerContext final : public ServerContext {
grpc::string host_;
};
+// A generic service at the server side accepts all RPC methods and hosts. It is
+// typically used in proxies. The generic service can be registered to a server
+// which also has other services.
+// Sample usage:
+// ServerBuilder builder;
+// auto cq = builder.AddCompletionQueue();
+// AsyncGenericService generic_service;
+// builder.RegisterAsyncGeneicService(&generic_service);
+// auto server = builder.BuildAndStart();
+//
+// // request a new call
+// GenericServerContext context;
+// GenericAsyncReaderWriter stream;
+// generic_service.RequestCall(&context, &stream, cq.get(), cq.get(), tag);
+//
+// When tag is retrieved from cq->Next(), context.method() can be used to look
+// at the method and the RPC can be handled accordingly.
class AsyncGenericService final {
public:
AsyncGenericService() : server_(nullptr) {}
diff --git a/include/grpc++/impl/channel_argument_option.h b/include/grpc++/impl/channel_argument_option.h
index e918f57e92..f157ec1d7e 100644
--- a/include/grpc++/impl/channel_argument_option.h
+++ b/include/grpc++/impl/channel_argument_option.h
@@ -28,9 +28,9 @@
namespace grpc {
std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
- const grpc::string &name, const grpc::string &value);
+ const grpc::string& name, const grpc::string& value);
std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
- const grpc::string &name, int value);
+ const grpc::string& name, int value);
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/async_stream.h b/include/grpc++/impl/codegen/async_stream.h
index e60572fc93..4476033463 100644
--- a/include/grpc++/impl/codegen/async_stream.h
+++ b/include/grpc++/impl/codegen/async_stream.h
@@ -30,6 +30,7 @@ namespace grpc {
class CompletionQueue;
+namespace internal {
/// Common interface for all client side asynchronous streaming.
class ClientAsyncStreamingInterface {
public:
@@ -151,15 +152,16 @@ class AsyncWriterInterface {
}
};
+} // namespace internal
+
template <class R>
-class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface,
- public AsyncReaderInterface<R> {};
+class ClientAsyncReaderInterface
+ : public internal::ClientAsyncStreamingInterface,
+ public internal::AsyncReaderInterface<R> {};
-/// Async client-side API for doing server-streaming RPCs,
-/// where the incoming message stream coming from the server has
-/// messages of type \a R.
+namespace internal {
template <class R>
-class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
+class ClientAsyncReaderFactory {
public:
/// Create a stream object.
/// Write the first request out if \a start is set.
@@ -169,16 +171,25 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
/// Note that \a context will be used to fill in custom initial metadata
/// used to send to the server when starting the call.
template <class W>
- static ClientAsyncReader* Create(ChannelInterface* channel,
- CompletionQueue* cq, const RpcMethod& method,
- ClientContext* context, const W& request,
- bool start, void* tag) {
- Call call = channel->CreateCall(method, context, cq);
+ static ClientAsyncReader<R>* Create(ChannelInterface* channel,
+ CompletionQueue* cq,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context, const W& request,
+ bool start, void* tag) {
+ ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
- call.call(), sizeof(ClientAsyncReader)))
- ClientAsyncReader(call, context, request, start, tag);
+ call.call(), sizeof(ClientAsyncReader<R>)))
+ ClientAsyncReader<R>(call, context, request, start, tag);
}
+};
+} // namespace internal
+/// Async client-side API for doing server-streaming RPCs,
+/// where the incoming message stream coming from the server has
+/// messages of type \a R.
+template <class R>
+class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
+ public:
// always allocated against a call arena, no memory free required
static void operator delete(void* ptr, std::size_t size) {
assert(size == sizeof(ClientAsyncReader));
@@ -233,9 +244,10 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
}
private:
+ friend class internal::ClientAsyncReaderFactory<R>;
template <class W>
- ClientAsyncReader(Call call, ClientContext* context, const W& request,
- bool start, void* tag)
+ ClientAsyncReader(::grpc::internal::Call call, ClientContext* context,
+ const W& request, bool start, void* tag)
: context_(context), call_(call), started_(start) {
// TODO(ctiller): don't assert
GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
@@ -255,19 +267,27 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
}
ClientContext* context_;
- Call call_;
+ ::grpc::internal::Call call_;
bool started_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
init_ops_;
- CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
- CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
- CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ meta_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpRecvMessage<R>>
+ read_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpClientRecvStatus>
+ finish_ops_;
};
/// Common interface for client side asynchronous writing.
template <class W>
-class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface,
- public AsyncWriterInterface<W> {
+class ClientAsyncWriterInterface
+ : public internal::ClientAsyncStreamingInterface,
+ public internal::AsyncWriterInterface<W> {
public:
/// Signal the client is done with the writes (half-close the client stream).
/// Thread-safe with respect to \a AsyncReaderInterface::Read
@@ -276,11 +296,9 @@ class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface,
virtual void WritesDone(void* tag) = 0;
};
-/// Async API on the client side for doing client-streaming RPCs,
-/// where the outgoing message stream going to the server contains
-/// messages of type \a W.
+namespace internal {
template <class W>
-class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
+class ClientAsyncWriterFactory {
public:
/// Create a stream object.
/// Start the RPC if \a start is set
@@ -294,16 +312,25 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
/// message from the server upon a successful call to the \a Finish
/// method of this instance.
template <class R>
- static ClientAsyncWriter* Create(ChannelInterface* channel,
- CompletionQueue* cq, const RpcMethod& method,
- ClientContext* context, R* response,
- bool start, void* tag) {
- Call call = channel->CreateCall(method, context, cq);
+ static ClientAsyncWriter<W>* Create(ChannelInterface* channel,
+ CompletionQueue* cq,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context, R* response,
+ bool start, void* tag) {
+ ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
- call.call(), sizeof(ClientAsyncWriter)))
- ClientAsyncWriter(call, context, response, start, tag);
+ call.call(), sizeof(ClientAsyncWriter<W>)))
+ ClientAsyncWriter<W>(call, context, response, start, tag);
}
+};
+} // namespace internal
+/// Async API on the client side for doing client-streaming RPCs,
+/// where the outgoing message stream going to the server contains
+/// messages of type \a W.
+template <class W>
+class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
+ public:
// always allocated against a call arena, no memory free required
static void operator delete(void* ptr, std::size_t size) {
assert(size == sizeof(ClientAsyncWriter));
@@ -376,9 +403,10 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
}
private:
+ friend class internal::ClientAsyncWriterFactory<W>;
template <class R>
- ClientAsyncWriter(Call call, ClientContext* context, R* response, bool start,
- void* tag)
+ ClientAsyncWriter(::grpc::internal::Call call, ClientContext* context,
+ R* response, bool start, void* tag)
: context_(context), call_(call), started_(start) {
finish_ops_.RecvMessage(response);
finish_ops_.AllowNoMessage();
@@ -401,13 +429,17 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
}
ClientContext* context_;
- Call call_;
+ ::grpc::internal::Call call_;
bool started_;
- CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ meta_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
write_ops_;
- CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
- CallOpClientRecvStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpGenericRecvMessage,
+ ::grpc::internal::CallOpClientRecvStatus>
finish_ops_;
};
@@ -415,9 +447,10 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
/// where the client-to-server message stream has messages of type \a W,
/// and the server-to-client message stream has messages of type \a R.
template <class W, class R>
-class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface,
- public AsyncWriterInterface<W>,
- public AsyncReaderInterface<R> {
+class ClientAsyncReaderWriterInterface
+ : public internal::ClientAsyncStreamingInterface,
+ public internal::AsyncWriterInterface<W>,
+ public internal::AsyncReaderInterface<R> {
public:
/// Signal the client is done with the writes (half-close the client stream).
/// Thread-safe with respect to \a AsyncReaderInterface::Read
@@ -426,13 +459,9 @@ class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface,
virtual void WritesDone(void* tag) = 0;
};
-/// Async client-side interface for bi-directional streaming,
-/// where the outgoing message stream going to the server
-/// has messages of type \a W, and the incoming message stream coming
-/// from the server has messages of type \a R.
+namespace internal {
template <class W, class R>
-class ClientAsyncReaderWriter final
- : public ClientAsyncReaderWriterInterface<W, R> {
+class ClientAsyncReaderWriterFactory {
public:
/// Create a stream object.
/// Start the RPC request if \a start is set.
@@ -441,18 +470,27 @@ class ClientAsyncReaderWriter final
/// nullptr and the actual call must be initiated by StartCall
/// Note that \a context will be used to fill in custom initial metadata
/// used to send to the server when starting the call.
- static ClientAsyncReaderWriter* Create(ChannelInterface* channel,
- CompletionQueue* cq,
- const RpcMethod& method,
- ClientContext* context, bool start,
- void* tag) {
- Call call = channel->CreateCall(method, context, cq);
+ static ClientAsyncReaderWriter<W, R>* Create(
+ ChannelInterface* channel, CompletionQueue* cq,
+ const ::grpc::internal::RpcMethod& method, ClientContext* context,
+ bool start, void* tag) {
+ ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
- call.call(), sizeof(ClientAsyncReaderWriter)))
- ClientAsyncReaderWriter(call, context, start, tag);
+ call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
+ ClientAsyncReaderWriter<W, R>(call, context, start, tag);
}
+};
+} // namespace internal
+/// Async client-side interface for bi-directional streaming,
+/// where the outgoing message stream going to the server
+/// has messages of type \a W, and the incoming message stream coming
+/// from the server has messages of type \a R.
+template <class W, class R>
+class ClientAsyncReaderWriter final
+ : public ClientAsyncReaderWriterInterface<W, R> {
+ public:
// always allocated against a call arena, no memory free required
static void operator delete(void* ptr, std::size_t size) {
assert(size == sizeof(ClientAsyncReaderWriter));
@@ -532,8 +570,9 @@ class ClientAsyncReaderWriter final
}
private:
- ClientAsyncReaderWriter(Call call, ClientContext* context, bool start,
- void* tag)
+ friend class internal::ClientAsyncReaderWriterFactory<W, R>;
+ ClientAsyncReaderWriter(::grpc::internal::Call call, ClientContext* context,
+ bool start, void* tag)
: context_(context), call_(call), started_(start) {
if (start) {
StartCallInternal(tag);
@@ -554,18 +593,26 @@ class ClientAsyncReaderWriter final
}
ClientContext* context_;
- Call call_;
+ ::grpc::internal::Call call_;
bool started_;
- CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
- CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ meta_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpRecvMessage<R>>
+ read_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
write_ops_;
- CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpClientRecvStatus>
+ finish_ops_;
};
template <class W, class R>
-class ServerAsyncReaderInterface : public ServerAsyncStreamingInterface,
- public AsyncReaderInterface<R> {
+class ServerAsyncReaderInterface
+ : public internal::ServerAsyncStreamingInterface,
+ public internal::AsyncReaderInterface<R> {
public:
/// Indicate that the stream is to be finished with a certain status code
/// and also send out \a msg response to the client.
@@ -692,20 +739,23 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
}
private:
- void BindCall(Call* call) override { call_ = *call; }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
- Call call_;
+ ::grpc::internal::Call call_;
ServerContext* ctx_;
- CallOpSet<CallOpSendInitialMetadata> meta_ops_;
- CallOpSet<CallOpRecvMessage<R>> read_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpServerSendStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
+ meta_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage<R>> read_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpServerSendStatus>
finish_ops_;
};
template <class W>
-class ServerAsyncWriterInterface : public ServerAsyncStreamingInterface,
- public AsyncWriterInterface<W> {
+class ServerAsyncWriterInterface
+ : public internal::ServerAsyncStreamingInterface,
+ public internal::AsyncWriterInterface<W> {
public:
/// Indicate that the stream is to be finished with a certain status code.
/// Request notification for when the server has sent the appropriate
@@ -823,7 +873,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
}
private:
- void BindCall(Call* call) override { call_ = *call; }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
template <class T>
void EnsureInitialMetadataSent(T* ops) {
@@ -837,20 +887,25 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
}
}
- Call call_;
+ ::grpc::internal::Call call_;
ServerContext* ctx_;
- CallOpSet<CallOpSendInitialMetadata> meta_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpServerSendStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
+ meta_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpServerSendStatus>
write_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpServerSendStatus>
+ finish_ops_;
};
/// Server-side interface for asynchronous bi-directional streaming.
template <class W, class R>
-class ServerAsyncReaderWriterInterface : public ServerAsyncStreamingInterface,
- public AsyncWriterInterface<W>,
- public AsyncReaderInterface<R> {
+class ServerAsyncReaderWriterInterface
+ : public internal::ServerAsyncStreamingInterface,
+ public internal::AsyncWriterInterface<W>,
+ public internal::AsyncReaderInterface<R> {
public:
/// Indicate that the stream is to be finished with a certain status code.
/// Request notification for when the server has sent the appropriate
@@ -980,7 +1035,7 @@ class ServerAsyncReaderWriter final
private:
friend class ::grpc::Server;
- void BindCall(Call* call) override { call_ = *call; }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
template <class T>
void EnsureInitialMetadataSent(T* ops) {
@@ -994,14 +1049,18 @@ class ServerAsyncReaderWriter final
}
}
- Call call_;
+ ::grpc::internal::Call call_;
ServerContext* ctx_;
- CallOpSet<CallOpSendInitialMetadata> meta_ops_;
- CallOpSet<CallOpRecvMessage<R>> read_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpServerSendStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
+ meta_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage<R>> read_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpServerSendStatus>
write_ops_;
- CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpServerSendStatus>
+ finish_ops_;
};
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h
index e472f04f56..fb573004cb 100644
--- a/include/grpc++/impl/codegen/async_unary_call.h
+++ b/include/grpc++/impl/codegen/async_unary_call.h
@@ -69,11 +69,9 @@ class ClientAsyncResponseReaderInterface {
virtual void Finish(R* msg, Status* status, void* tag) = 0;
};
-/// Async API for client-side unary RPCs, where the message response
-/// received from the server is of type \a R.
+namespace internal {
template <class R>
-class ClientAsyncResponseReader final
- : public ClientAsyncResponseReaderInterface<R> {
+class ClientAsyncResponseReaderFactory {
public:
/// Start a call and write the request out if \a start is set.
/// \a tag will be notified on \a cq when the call has been started (i.e.
@@ -82,22 +80,36 @@ class ClientAsyncResponseReader final
/// Note that \a context will be used to fill in custom initial metadata
/// used to send to the server when starting the call.
template <class W>
- static ClientAsyncResponseReader* Create(ChannelInterface* channel,
- CompletionQueue* cq,
- const RpcMethod& method,
- ClientContext* context,
- const W& request, bool start) {
- Call call = channel->CreateCall(method, context, cq);
+ static ClientAsyncResponseReader<R>* Create(
+ ChannelInterface* channel, CompletionQueue* cq,
+ const ::grpc::internal::RpcMethod& method, ClientContext* context,
+ const W& request, bool start) {
+ ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
- call.call(), sizeof(ClientAsyncResponseReader)))
- ClientAsyncResponseReader(call, context, request, start);
+ call.call(), sizeof(ClientAsyncResponseReader<R>)))
+ ClientAsyncResponseReader<R>(call, context, request, start);
}
+};
+} // namespace internal
+/// Async API for client-side unary RPCs, where the message response
+/// received from the server is of type \a R.
+template <class R>
+class ClientAsyncResponseReader final
+ : public ClientAsyncResponseReaderInterface<R> {
+ public:
// always allocated against a call arena, no memory free required
static void operator delete(void* ptr, std::size_t size) {
assert(size == sizeof(ClientAsyncResponseReader));
}
+ // This operator should never be called as the memory should be freed as part
+ // of the arena destruction. It only exists to provide a matching operator
+ // delete to the operator new so that some compilers will not complain (see
+ // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
+ // there are no tests catching the compiler warning.
+ static void operator delete(void*, void*) { assert(0); }
+
void StartCall() override {
assert(!started_);
started_ = true;
@@ -137,13 +149,14 @@ class ClientAsyncResponseReader final
}
private:
+ friend class internal::ClientAsyncResponseReaderFactory<R>;
ClientContext* const context_;
- Call call_;
+ ::grpc::internal::Call call_;
bool started_;
template <class W>
- ClientAsyncResponseReader(Call call, ClientContext* context, const W& request,
- bool start)
+ ClientAsyncResponseReader(::grpc::internal::Call call, ClientContext* context,
+ const W& request, bool start)
: context_(context), call_(call), started_(start) {
// Bind the metadata at time of StartCallInternal but set up the rest here
// TODO(ctiller): don't assert
@@ -162,19 +175,23 @@ class ClientAsyncResponseReader final
static void* operator new(std::size_t size);
static void* operator new(std::size_t size, void* p) { return p; }
- SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpClientSendClose>
+ ::grpc::internal::SneakyCallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
init_buf;
- CallOpSet<CallOpRecvInitialMetadata> meta_buf;
- CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>,
- CallOpClientRecvStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ meta_buf;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpRecvMessage<R>,
+ ::grpc::internal::CallOpClientRecvStatus>
finish_buf;
};
/// Async server-side API for handling unary calls, where the single
/// response message sent to the client is of type \a W.
template <class W>
-class ServerAsyncResponseWriter final : public ServerAsyncStreamingInterface {
+class ServerAsyncResponseWriter final
+ : public internal::ServerAsyncStreamingInterface {
public:
explicit ServerAsyncResponseWriter(ServerContext* ctx)
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
@@ -262,13 +279,15 @@ class ServerAsyncResponseWriter final : public ServerAsyncStreamingInterface {
}
private:
- void BindCall(Call* call) override { call_ = *call; }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
- Call call_;
+ ::grpc::internal::Call call_;
ServerContext* ctx_;
- CallOpSet<CallOpSendInitialMetadata> meta_buf_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpServerSendStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
+ meta_buf_;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpServerSendStatus>
finish_buf_;
};
@@ -285,6 +304,6 @@ class default_delete<grpc::ClientAsyncResponseReaderInterface<R>> {
public:
void operator()(void* p) {}
};
-}
+} // namespace std
#endif // GRPCXX_IMPL_CODEGEN_ASYNC_UNARY_CALL_H
diff --git a/include/grpc++/impl/codegen/byte_buffer.h b/include/grpc++/impl/codegen/byte_buffer.h
index 57d731be18..fe73ce7a83 100644
--- a/include/grpc++/impl/codegen/byte_buffer.h
+++ b/include/grpc++/impl/codegen/byte_buffer.h
@@ -31,18 +31,19 @@
namespace grpc {
+namespace internal {
+class CallOpSendMessage;
template <class R>
class CallOpRecvMessage;
+class CallOpGenericRecvMessage;
class MethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
class RpcMethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler;
-namespace CallOpGenericRecvMessageHelper {
template <class R>
class DeserializeFuncType;
-} // namespace CallOpGenericRecvMessageHelper
-
+} // namespace internal
/// A sequence of bytes.
class ByteBuffer final {
public:
@@ -97,17 +98,17 @@ class ByteBuffer final {
private:
friend class SerializationTraits<ByteBuffer, void>;
- friend class CallOpSendMessage;
+ friend class internal::CallOpSendMessage;
template <class R>
- friend class CallOpRecvMessage;
- friend class CallOpGenericRecvMessage;
- friend class MethodHandler;
+ friend class internal::CallOpRecvMessage;
+ friend class internal::CallOpGenericRecvMessage;
+ friend class internal::MethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
- friend class RpcMethodHandler;
+ friend class internal::RpcMethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
- friend class ServerStreamingHandler;
+ friend class internal::ServerStreamingHandler;
template <class R>
- friend class CallOpGenericRecvMessageHelper::DeserializeFuncType;
+ friend class internal::DeserializeFuncType;
grpc_byte_buffer* buffer_;
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h
index d9988e51fc..c04526c59b 100644
--- a/include/grpc++/impl/codegen/call.h
+++ b/include/grpc++/impl/codegen/call.h
@@ -43,11 +43,13 @@
namespace grpc {
class ByteBuffer;
-class Call;
-class CallHook;
class CompletionQueue;
extern CoreCodegenInterface* g_core_codegen_interface;
+namespace internal {
+class Call;
+class CallHook;
+
const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin";
// TODO(yangg) if the map is changed before we send, the pointers will be a
@@ -75,6 +77,7 @@ inline grpc_metadata* FillMetadataArray(
}
return metadata_array;
}
+} // namespace internal
/// Per-message write options.
class WriteOptions {
@@ -163,7 +166,7 @@ class WriteOptions {
/// Clears flag indicating that this is the last message in a stream,
/// disabling coalescing.
- inline WriteOptions& clear_last_messsage() {
+ inline WriteOptions& clear_last_message() {
last_message_ = false;
return *this;
}
@@ -199,6 +202,7 @@ class WriteOptions {
bool last_message_;
};
+namespace internal {
/// Default argument for CallOpSet. I is unused by the class, but can be
/// used for generating multiple names for the same thing.
template <int I>
@@ -212,14 +216,12 @@ class CallOpSendInitialMetadata {
public:
CallOpSendInitialMetadata() : send_(false) {
maybe_compression_level_.is_set = false;
- maybe_stream_compression_level_.is_set = false;
}
void SendInitialMetadata(
const std::multimap<grpc::string, grpc::string>& metadata,
uint32_t flags) {
maybe_compression_level_.is_set = false;
- maybe_stream_compression_level_.is_set = false;
send_ = true;
flags_ = flags;
initial_metadata_ =
@@ -231,11 +233,6 @@ class CallOpSendInitialMetadata {
maybe_compression_level_.level = level;
}
- void set_stream_compression_level(grpc_stream_compression_level level) {
- maybe_stream_compression_level_.is_set = true;
- maybe_stream_compression_level_.level = level;
- }
-
protected:
void AddOp(grpc_op* ops, size_t* nops) {
if (!send_) return;
@@ -251,12 +248,6 @@ class CallOpSendInitialMetadata {
op->data.send_initial_metadata.maybe_compression_level.level =
maybe_compression_level_.level;
}
- op->data.send_initial_metadata.maybe_stream_compression_level.is_set =
- maybe_stream_compression_level_.is_set;
- if (maybe_stream_compression_level_.is_set) {
- op->data.send_initial_metadata.maybe_stream_compression_level.level =
- maybe_stream_compression_level_.level;
- }
}
void FinishOp(bool* status) {
if (!send_) return;
@@ -272,10 +263,6 @@ class CallOpSendInitialMetadata {
bool is_set;
grpc_compression_level level;
} maybe_compression_level_;
- struct {
- bool is_set;
- grpc_stream_compression_level level;
- } maybe_stream_compression_level_;
};
class CallOpSendMessage {
@@ -309,16 +296,15 @@ class CallOpSendMessage {
WriteOptions write_options_;
};
-namespace internal {
-template <class T>
-T Example();
-} // namespace internal
-
template <class M>
Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) {
write_options_ = options;
bool own_buf;
- Status result = SerializationTraits<M>::Serialize(
+ // TODO(vjpai): Remove the void below when possible
+ // The void in the template parameter below should not be needed
+ // (since it should be implicit) but is needed due to an observed
+ // difference in behavior between clang and gcc for certain internal users
+ Status result = SerializationTraits<M, void>::Serialize(
message, send_buf_.bbuf_ptr(), &own_buf);
if (!own_buf) {
send_buf_.Duplicate();
@@ -383,7 +369,6 @@ class CallOpRecvMessage {
bool allow_not_getting_message_;
};
-namespace CallOpGenericRecvMessageHelper {
class DeserializeFunc {
public:
virtual Status Deserialize(ByteBuffer* buf) = 0;
@@ -403,7 +388,6 @@ class DeserializeFuncType final : public DeserializeFunc {
private:
R* message_; // Not a managed pointer because management is external to this
};
-} // namespace CallOpGenericRecvMessageHelper
class CallOpGenericRecvMessage {
public:
@@ -414,8 +398,7 @@ class CallOpGenericRecvMessage {
void RecvMessage(R* message) {
// Use an explicit base class pointer to avoid resolution error in the
// following unique_ptr::reset for some old implementations.
- CallOpGenericRecvMessageHelper::DeserializeFunc* func =
- new CallOpGenericRecvMessageHelper::DeserializeFuncType<R>(message);
+ DeserializeFunc* func = new DeserializeFuncType<R>(message);
deserialize_.reset(func);
}
@@ -455,7 +438,7 @@ class CallOpGenericRecvMessage {
}
private:
- std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_;
+ std::unique_ptr<DeserializeFunc> deserialize_;
ByteBuffer recv_buf_;
bool allow_not_getting_message_;
};
@@ -558,10 +541,12 @@ class CallOpRecvInitialMetadata {
class CallOpClientRecvStatus {
public:
- CallOpClientRecvStatus() : recv_status_(nullptr) {}
+ CallOpClientRecvStatus()
+ : recv_status_(nullptr), debug_error_string_(nullptr) {}
void ClientRecvStatus(ClientContext* context, Status* status) {
- metadata_map_ = &context->trailing_metadata_;
+ client_context_ = context;
+ metadata_map_ = &client_context_->trailing_metadata_;
recv_status_ = status;
error_message_ = g_core_codegen_interface->grpc_empty_slice();
}
@@ -574,6 +559,7 @@ class CallOpClientRecvStatus {
op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
op->data.recv_status_on_client.status = &status_code_;
op->data.recv_status_on_client.status_details = &error_message_;
+ op->data.recv_status_on_client.error_string = &debug_error_string_;
op->flags = 0;
op->reserved = NULL;
}
@@ -591,13 +577,20 @@ class CallOpClientRecvStatus {
grpc::string(GRPC_SLICE_START_PTR(error_message_),
GRPC_SLICE_END_PTR(error_message_)),
binary_error_details);
+ client_context_->set_debug_error_string(
+ debug_error_string_ != nullptr ? debug_error_string_ : "");
g_core_codegen_interface->grpc_slice_unref(error_message_);
+ if (debug_error_string_ != nullptr) {
+ g_core_codegen_interface->gpr_free((void*)debug_error_string_);
+ }
recv_status_ = nullptr;
}
private:
+ ClientContext* client_context_;
MetadataMap* metadata_map_;
Status* recv_status_;
+ const char* debug_error_string_;
grpc_status_code status_code_;
grpc_slice error_message_;
};
@@ -614,7 +607,7 @@ class CallOpSetInterface : public CompletionQueueTag {
virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0;
};
-/// Primary implementaiton of CallOpSetInterface.
+/// Primary implementation of CallOpSetInterface.
/// Since we cannot use variadic templates, we declare slots up to
/// the maximum count of ops we'll need in a set. We leverage the
/// empty base class optimization to slim this class (especially
@@ -631,7 +624,7 @@ class CallOpSet : public CallOpSetInterface,
public Op5,
public Op6 {
public:
- CallOpSet() : return_tag_(this) {}
+ CallOpSet() : return_tag_(this), call_(nullptr) {}
void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) override {
this->Op1::AddOp(ops, nops);
this->Op2::AddOp(ops, nops);
@@ -710,7 +703,7 @@ class Call final {
grpc_call* call_;
int max_receive_message_size_;
};
-
+} // namespace internal
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_CALL_H
diff --git a/include/grpc++/impl/codegen/call_hook.h b/include/grpc++/impl/codegen/call_hook.h
index d026cc8b58..44e9de220e 100644
--- a/include/grpc++/impl/codegen/call_hook.h
+++ b/include/grpc++/impl/codegen/call_hook.h
@@ -21,6 +21,7 @@
namespace grpc {
+namespace internal {
class CallOpSetInterface;
class Call;
@@ -31,6 +32,7 @@ class CallHook {
virtual ~CallHook() {}
virtual void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) = 0;
};
+} // namespace internal
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/channel_interface.h b/include/grpc++/impl/codegen/channel_interface.h
index 1b7590bf0c..769f853974 100644
--- a/include/grpc++/impl/codegen/channel_interface.h
+++ b/include/grpc++/impl/codegen/channel_interface.h
@@ -24,10 +24,8 @@
#include <grpc/impl/codegen/connectivity_state.h>
namespace grpc {
-class Call;
+class ChannelInterface;
class ClientContext;
-class RpcMethod;
-class CallOpSetInterface;
class CompletionQueue;
template <class R>
@@ -36,14 +34,22 @@ template <class W>
class ClientWriter;
template <class W, class R>
class ClientReaderWriter;
+
+namespace internal {
+class Call;
+class CallOpSetInterface;
+class RpcMethod;
+template <class InputMessage, class OutputMessage>
+class BlockingUnaryCallImpl;
template <class R>
-class ClientAsyncReader;
+class ClientAsyncReaderFactory;
template <class W>
-class ClientAsyncWriter;
+class ClientAsyncWriterFactory;
template <class W, class R>
-class ClientAsyncReaderWriter;
+class ClientAsyncReaderWriterFactory;
template <class R>
-class ClientAsyncResponseReader;
+class ClientAsyncResponseReaderFactory;
+} // namespace internal
/// Codegen interface for \a grpc::Channel.
class ChannelInterface {
@@ -88,23 +94,21 @@ class ChannelInterface {
template <class W, class R>
friend class ::grpc::ClientReaderWriter;
template <class R>
- friend class ::grpc::ClientAsyncReader;
+ friend class ::grpc::internal::ClientAsyncReaderFactory;
template <class W>
- friend class ::grpc::ClientAsyncWriter;
+ friend class ::grpc::internal::ClientAsyncWriterFactory;
template <class W, class R>
- friend class ::grpc::ClientAsyncReaderWriter;
+ friend class ::grpc::internal::ClientAsyncReaderWriterFactory;
template <class R>
- friend class ::grpc::ClientAsyncResponseReader;
+ friend class ::grpc::internal::ClientAsyncResponseReaderFactory;
template <class InputMessage, class OutputMessage>
- friend Status BlockingUnaryCall(ChannelInterface* channel,
- const RpcMethod& method,
- ClientContext* context,
- const InputMessage& request,
- OutputMessage* result);
- friend class ::grpc::RpcMethod;
- virtual Call CreateCall(const RpcMethod& method, ClientContext* context,
- CompletionQueue* cq) = 0;
- virtual void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) = 0;
+ friend class ::grpc::internal::BlockingUnaryCallImpl;
+ friend class ::grpc::internal::RpcMethod;
+ virtual internal::Call CreateCall(const internal::RpcMethod& method,
+ ClientContext* context,
+ CompletionQueue* cq) = 0;
+ virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops,
+ internal::Call* call) = 0;
virtual void* RegisterMethod(const char* method) = 0;
virtual void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline,
@@ -112,7 +116,6 @@ class ChannelInterface {
virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline) = 0;
};
-
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_CHANNEL_INTERFACE_H
diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h
index 6d7e13bbf2..61d97ce818 100644
--- a/include/grpc++/impl/codegen/client_context.h
+++ b/include/grpc++/impl/codegen/client_context.h
@@ -60,7 +60,16 @@ class Channel;
class ChannelInterface;
class CompletionQueue;
class CallCredentials;
+class ClientContext;
+
+namespace internal {
class RpcMethod;
+class CallOpClientRecvStatus;
+class CallOpRecvInitialMetadata;
+template <class InputMessage, class OutputMessage>
+class BlockingUnaryCallImpl;
+} // namespace internal
+
template <class R>
class ClientReader;
template <class W>
@@ -339,14 +348,21 @@ class ClientContext {
/// Applications never need to call this method.
grpc_call* c_call() { return call_; }
+ /// EXPERIMENTAL debugging API
+ ///
+ /// if status is not ok() for an RPC, this will return a detailed string
+ /// of the gRPC Core error that led to the failure. It should not be relied
+ /// upon for anything other than gaining more debug data in failure cases.
+ grpc::string debug_error_string() const { return debug_error_string_; }
+
private:
// Disallow copy and assign.
ClientContext(const ClientContext&);
ClientContext& operator=(const ClientContext&);
friend class ::grpc::testing::InteropClientContextInspector;
- friend class CallOpClientRecvStatus;
- friend class CallOpRecvInitialMetadata;
+ friend class ::grpc::internal::CallOpClientRecvStatus;
+ friend class ::grpc::internal::CallOpRecvInitialMetadata;
friend class Channel;
template <class R>
friend class ::grpc::ClientReader;
@@ -363,11 +379,12 @@ class ClientContext {
template <class R>
friend class ::grpc::ClientAsyncResponseReader;
template <class InputMessage, class OutputMessage>
- friend Status BlockingUnaryCall(ChannelInterface* channel,
- const RpcMethod& method,
- ClientContext* context,
- const InputMessage& request,
- OutputMessage* result);
+ friend class ::grpc::internal::BlockingUnaryCallImpl;
+
+ // Used by friend class CallOpClientRecvStatus
+ void set_debug_error_string(const grpc::string& debug_error_string) {
+ debug_error_string_ = debug_error_string;
+ }
grpc_call* call() const { return call_; }
void set_call(grpc_call* call, const std::shared_ptr<Channel>& channel);
@@ -399,14 +416,16 @@ class ClientContext {
mutable std::shared_ptr<const AuthContext> auth_context_;
struct census_context* census_context_;
std::multimap<grpc::string, grpc::string> send_initial_metadata_;
- MetadataMap recv_initial_metadata_;
- MetadataMap trailing_metadata_;
+ internal::MetadataMap recv_initial_metadata_;
+ internal::MetadataMap trailing_metadata_;
grpc_call* propagate_from_call_;
PropagationOptions propagation_options_;
grpc_compression_algorithm compression_algorithm_;
bool initial_metadata_corked_;
+
+ grpc::string debug_error_string_;
};
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h
index 7c540fade9..543e54b972 100644
--- a/include/grpc++/impl/codegen/client_unary_call.h
+++ b/include/grpc++/impl/codegen/client_unary_call.h
@@ -30,43 +30,61 @@ namespace grpc {
class Channel;
class ClientContext;
class CompletionQueue;
-class RpcMethod;
+namespace internal {
+class RpcMethod;
/// Wrapper that performs a blocking unary call
template <class InputMessage, class OutputMessage>
Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method,
ClientContext* context, const InputMessage& request,
OutputMessage* result) {
- CompletionQueue cq(grpc_completion_queue_attributes{
- GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
- GRPC_CQ_DEFAULT_POLLING}); // Pluckable completion queue
- Call call(channel->CreateCall(method, context, &cq));
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,
- CallOpClientSendClose, CallOpClientRecvStatus>
- ops;
- Status status = ops.SendMessage(request);
- if (!status.ok()) {
- return status;
- }
- ops.SendInitialMetadata(context->send_initial_metadata_,
- context->initial_metadata_flags());
- ops.RecvInitialMetadata(context);
- ops.RecvMessage(result);
- ops.ClientSendClose();
- ops.ClientRecvStatus(context, &status);
- call.PerformOps(&ops);
- if (cq.Pluck(&ops)) {
- if (!ops.got_message && status.ok()) {
- return Status(StatusCode::UNIMPLEMENTED,
- "No message returned for unary request");
+ return BlockingUnaryCallImpl<InputMessage, OutputMessage>(
+ channel, method, context, request, result)
+ .status();
+}
+
+template <class InputMessage, class OutputMessage>
+class BlockingUnaryCallImpl {
+ public:
+ BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method,
+ ClientContext* context, const InputMessage& request,
+ OutputMessage* result) {
+ CompletionQueue cq(grpc_completion_queue_attributes{
+ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
+ GRPC_CQ_DEFAULT_POLLING}); // Pluckable completion queue
+ Call call(channel->CreateCall(method, context, &cq));
+ CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
+ CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,
+ CallOpClientSendClose, CallOpClientRecvStatus>
+ ops;
+ status_ = ops.SendMessage(request);
+ if (!status_.ok()) {
+ return;
+ }
+ ops.SendInitialMetadata(context->send_initial_metadata_,
+ context->initial_metadata_flags());
+ ops.RecvInitialMetadata(context);
+ ops.RecvMessage(result);
+ ops.AllowNoMessage();
+ ops.ClientSendClose();
+ ops.ClientRecvStatus(context, &status_);
+ call.PerformOps(&ops);
+ if (cq.Pluck(&ops)) {
+ if (!ops.got_message && status_.ok()) {
+ status_ = Status(StatusCode::UNIMPLEMENTED,
+ "No message returned for unary request");
+ }
+ } else {
+ GPR_CODEGEN_ASSERT(!status_.ok());
}
- } else {
- GPR_CODEGEN_ASSERT(!status.ok());
}
- return status;
-}
+ Status status() { return status_; }
+
+ private:
+ Status status_;
+};
+} // namespace internal
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_CLIENT_UNARY_CALL_H
diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h
index ca757e2a9c..b8a7862578 100644
--- a/include/grpc++/impl/codegen/completion_queue.h
+++ b/include/grpc++/impl/codegen/completion_queue.h
@@ -56,7 +56,20 @@ class ServerWriter;
namespace internal {
template <class W, class R>
class ServerReaderWriterBody;
-}
+} // namespace internal
+
+class Channel;
+class ChannelInterface;
+class ClientContext;
+class CompletionQueue;
+class Server;
+class ServerBuilder;
+class ServerContext;
+class ServerInterface;
+
+namespace internal {
+class CompletionQueueTag;
+class RpcMethod;
template <class ServiceType, class RequestType, class ResponseType>
class RpcMethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
@@ -66,16 +79,11 @@ class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
class BidiStreamingHandler;
class UnknownMethodHandler;
-
-class Channel;
-class ChannelInterface;
-class ClientContext;
-class CompletionQueueTag;
-class CompletionQueue;
-class RpcMethod;
-class Server;
-class ServerBuilder;
-class ServerContext;
+template <class Streamer, bool WriteNeeded>
+class TemplatedBidiStreamingHandler;
+template <class InputMessage, class OutputMessage>
+class BlockingUnaryCallImpl;
+} // namespace internal
extern CoreCodegenInterface* g_core_codegen_interface;
@@ -109,6 +117,30 @@ class CompletionQueue : private GrpcLibraryCodegen {
TIMEOUT ///< deadline was reached.
};
+ /// EXPERIMENTAL
+ /// First executes \a F, then reads from the queue, blocking up to
+ /// \a deadline (or the queue's shutdown).
+ /// Both \a tag and \a ok are updated upon success (if an event is available
+ /// within the \a deadline). A \a tag points to an arbitrary location usually
+ /// employed to uniquely identify an event.
+ ///
+ /// \param F[in] Function to execute before calling AsyncNext on this queue.
+ /// \param tag[out] Upon sucess, updated to point to the event's tag.
+ /// \param ok[out] Upon sucess, true if read a regular event, false otherwise.
+ /// \param deadline[in] How long to block in wait for an event.
+ ///
+ /// \return The type of event read.
+ template <typename T, typename F>
+ NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) {
+ CompletionQueueTLSCache cache = CompletionQueueTLSCache(this);
+ f();
+ if (cache.Flush(tag, ok)) {
+ return GOT_EVENT;
+ } else {
+ return AsyncNext(tag, ok, deadline);
+ }
+ }
+
/// Read from the queue, blocking up to \a deadline (or the queue's shutdown).
/// Both \a tag and \a ok are updated upon success (if an event is available
/// within the \a deadline). A \a tag points to an arbitrary location usually
@@ -133,8 +165,9 @@ class CompletionQueue : private GrpcLibraryCodegen {
///
/// \return true if read a regular event, false if the queue is shutting down.
bool Next(void** tag, bool* ok) {
- return (AsyncNextInternal(tag, ok, g_core_codegen_interface->gpr_inf_future(
- GPR_CLOCK_REALTIME)) != SHUTDOWN);
+ return (AsyncNextInternal(tag, ok,
+ g_core_codegen_interface->gpr_inf_future(
+ GPR_CLOCK_REALTIME)) != SHUTDOWN);
}
/// Request the shutdown of the queue.
@@ -155,21 +188,6 @@ class CompletionQueue : private GrpcLibraryCodegen {
/// owership is performed.
grpc_completion_queue* cq() { return cq_; }
- /// Manage state of avalanching operations : completion queue tags that
- /// trigger other completion queue operations. The underlying core completion
- /// queue should not really shutdown until all avalanching operations have
- /// been finalized. Note that we maintain the requirement that an avalanche
- /// registration must take place before CQ shutdown (which must be maintained
- /// elsehwere)
- void InitialAvalanching() {
- gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1));
- }
- void RegisterAvalanching() {
- gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_,
- static_cast<gpr_atm>(1));
- }
- void CompleteAvalanching();
-
protected:
/// Private constructor of CompletionQueue only visible to friend classes
CompletionQueue(const grpc_completion_queue_attributes& attributes) {
@@ -196,28 +214,40 @@ class CompletionQueue : private GrpcLibraryCodegen {
template <class W, class R>
friend class ::grpc::internal::ServerReaderWriterBody;
template <class ServiceType, class RequestType, class ResponseType>
- friend class RpcMethodHandler;
+ friend class ::grpc::internal::RpcMethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
- friend class ClientStreamingHandler;
+ friend class ::grpc::internal::ClientStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
- friend class ServerStreamingHandler;
+ friend class ::grpc::internal::ServerStreamingHandler;
template <class Streamer, bool WriteNeeded>
- friend class TemplatedBidiStreamingHandler;
- friend class UnknownMethodHandler;
+ friend class ::grpc::internal::TemplatedBidiStreamingHandler;
+ friend class ::grpc::internal::UnknownMethodHandler;
friend class ::grpc::Server;
friend class ::grpc::ServerContext;
+ friend class ::grpc::ServerInterface;
template <class InputMessage, class OutputMessage>
- friend Status BlockingUnaryCall(ChannelInterface* channel,
- const RpcMethod& method,
- ClientContext* context,
- const InputMessage& request,
- OutputMessage* result);
+ friend class ::grpc::internal::BlockingUnaryCallImpl;
+
+ /// EXPERIMENTAL
+ /// Creates a Thread Local cache to store the first event
+ /// On this completion queue queued from this thread. Once
+ /// initialized, it must be flushed on the same thread.
+ class CompletionQueueTLSCache {
+ public:
+ CompletionQueueTLSCache(CompletionQueue* cq);
+ ~CompletionQueueTLSCache();
+ bool Flush(void** tag, bool* ok);
+
+ private:
+ CompletionQueue* cq_;
+ bool flushed_;
+ };
NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline);
/// Wraps \a grpc_completion_queue_pluck.
/// \warning Must not be mixed with calls to \a Next.
- bool Pluck(CompletionQueueTag* tag) {
+ bool Pluck(internal::CompletionQueueTag* tag) {
auto deadline =
g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME);
auto ev = g_core_codegen_interface->grpc_completion_queue_pluck(
@@ -238,7 +268,7 @@ class CompletionQueue : private GrpcLibraryCodegen {
/// implementation to simple call the other TryPluck function with a zero
/// timeout. i.e:
/// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME))
- void TryPluck(CompletionQueueTag* tag) {
+ void TryPluck(internal::CompletionQueueTag* tag) {
auto deadline = g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME);
auto ev = g_core_codegen_interface->grpc_completion_queue_pluck(
cq_, tag, deadline, nullptr);
@@ -254,7 +284,7 @@ class CompletionQueue : private GrpcLibraryCodegen {
///
/// This exects tag->FinalizeResult (if called) to return 'false' i.e expects
/// that the tag is internal not something that is returned to the user.
- void TryPluck(CompletionQueueTag* tag, gpr_timespec deadline) {
+ void TryPluck(internal::CompletionQueueTag* tag, gpr_timespec deadline) {
auto ev = g_core_codegen_interface->grpc_completion_queue_pluck(
cq_, tag, deadline, nullptr);
if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) {
@@ -266,6 +296,21 @@ class CompletionQueue : private GrpcLibraryCodegen {
GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok));
}
+ /// Manage state of avalanching operations : completion queue tags that
+ /// trigger other completion queue operations. The underlying core completion
+ /// queue should not really shutdown until all avalanching operations have
+ /// been finalized. Note that we maintain the requirement that an avalanche
+ /// registration must take place before CQ shutdown (which must be maintained
+ /// elsehwere)
+ void InitialAvalanching() {
+ gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1));
+ }
+ void RegisterAvalanching() {
+ gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_,
+ static_cast<gpr_atm>(1));
+ }
+ void CompleteAvalanching();
+
grpc_completion_queue* cq_; // owned
gpr_atm avalanches_in_flight_;
diff --git a/include/grpc++/impl/codegen/completion_queue_tag.h b/include/grpc++/impl/codegen/completion_queue_tag.h
index 4d7d3a98dd..cb16bcf9ff 100644
--- a/include/grpc++/impl/codegen/completion_queue_tag.h
+++ b/include/grpc++/impl/codegen/completion_queue_tag.h
@@ -21,6 +21,7 @@
namespace grpc {
+namespace internal {
/// An interface allowing implementors to process and filter event tags.
class CompletionQueueTag {
public:
@@ -31,6 +32,7 @@ class CompletionQueueTag {
/// queue
virtual bool FinalizeResult(void** tag, bool* status) = 0;
};
+} // namespace internal
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/config_protobuf.h b/include/grpc++/impl/codegen/config_protobuf.h
index c5e5bdf0db..7387fa25c6 100644
--- a/include/grpc++/impl/codegen/config_protobuf.h
+++ b/include/grpc++/impl/codegen/config_protobuf.h
@@ -19,6 +19,8 @@
#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H
#define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H
+#define GRPC_OPEN_SOURCE_PROTO
+
#ifndef GRPC_CUSTOM_PROTOBUF_INT64
#include <google/protobuf/stubs/common.h>
#define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64
diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h
index c751c1e734..d7c57bebb9 100644
--- a/include/grpc++/impl/codegen/core_codegen.h
+++ b/include/grpc++/impl/codegen/core_codegen.h
@@ -50,6 +50,9 @@ class CoreCodegen final : public CoreCodegenInterface {
void* gpr_malloc(size_t size) override;
void gpr_free(void* p) override;
+ void grpc_init() override;
+ void grpc_shutdown() override;
+
void gpr_mu_init(gpr_mu* mu) override;
void gpr_mu_destroy(gpr_mu* mu) override;
void gpr_mu_lock(gpr_mu* mu) override;
@@ -89,6 +92,7 @@ class CoreCodegen final : public CoreCodegenInterface {
grpc_slice grpc_slice_ref(grpc_slice slice) override;
grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) override;
grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) override;
+ grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) override;
void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) override;
void grpc_slice_buffer_pop(grpc_slice_buffer* sb) override;
grpc_slice grpc_slice_from_static_buffer(const void* buffer,
diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h
index a4c50dab87..d7ad7a4b57 100644
--- a/include/grpc++/impl/codegen/core_codegen_interface.h
+++ b/include/grpc++/impl/codegen/core_codegen_interface.h
@@ -25,10 +25,6 @@
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/sync.h>
-extern "C" {
-struct grpc_byte_buffer;
-}
-
namespace grpc {
/// Interface between the codegen library and the minimal subset of core
@@ -63,6 +59,13 @@ class CoreCodegenInterface {
virtual void* gpr_malloc(size_t size) = 0;
virtual void gpr_free(void* p) = 0;
+ // These are only to be used to fix edge cases involving grpc_init and
+ // grpc_shutdown. Calling grpc_init from the codegen interface before
+ // the real grpc_init is called will cause a crash, so if you use this
+ // function, ensure that it is not the first call to grpc_init.
+ virtual void grpc_init() = 0;
+ virtual void grpc_shutdown() = 0;
+
virtual void gpr_mu_init(gpr_mu* mu) = 0;
virtual void gpr_mu_destroy(gpr_mu* mu) = 0;
virtual void gpr_mu_lock(gpr_mu* mu) = 0;
@@ -103,6 +106,7 @@ class CoreCodegenInterface {
virtual grpc_slice grpc_slice_ref(grpc_slice slice) = 0;
virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0;
virtual grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) = 0;
+ virtual grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) = 0;
virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb,
grpc_slice slice) = 0;
virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0;
diff --git a/include/grpc++/impl/codegen/metadata_map.h b/include/grpc++/impl/codegen/metadata_map.h
index b73985967d..8dc7211ba8 100644
--- a/include/grpc++/impl/codegen/metadata_map.h
+++ b/include/grpc++/impl/codegen/metadata_map.h
@@ -1,20 +1,20 @@
/*
-*
-* 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.
-*
-*/
+ *
+ * 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 GRPCXX_IMPL_CODEGEN_METADATA_MAP_H
#define GRPCXX_IMPL_CODEGEN_METADATA_MAP_H
@@ -23,6 +23,7 @@
namespace grpc {
+namespace internal {
class MetadataMap {
public:
MetadataMap() { memset(&arr_, 0, sizeof(arr_)); }
@@ -40,16 +41,17 @@ class MetadataMap {
}
}
- std::multimap<grpc::string_ref, grpc::string_ref> *map() { return &map_; }
- const std::multimap<grpc::string_ref, grpc::string_ref> *map() const {
+ std::multimap<grpc::string_ref, grpc::string_ref>* map() { return &map_; }
+ const std::multimap<grpc::string_ref, grpc::string_ref>* map() const {
return &map_;
}
- grpc_metadata_array *arr() { return &arr_; }
+ grpc_metadata_array* arr() { return &arr_; }
private:
grpc_metadata_array arr_;
std::multimap<grpc::string_ref, grpc::string_ref> map_;
};
+} // namespace internal
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h
index e14cb0e926..daf090f86c 100644
--- a/include/grpc++/impl/codegen/method_handler_impl.h
+++ b/include/grpc++/impl/codegen/method_handler_impl.h
@@ -26,6 +26,28 @@
namespace grpc {
+namespace internal {
+
+// Invoke the method handler, fill in the status, and
+// return whether or not we finished safely (without an exception).
+// Note that exception handling is 0-cost in most compiler/library
+// implementations (except when an exception is actually thrown),
+// so this process doesn't require additional overhead in the common case.
+// Additionally, we don't need to return if we caught an exception or not;
+// the handling is the same in either case.
+template <class Callable>
+Status CatchingFunctionHandler(Callable&& handler) {
+#if GRPC_ALLOW_EXCEPTIONS
+ try {
+ return handler();
+ } catch (...) {
+ return Status(StatusCode::UNKNOWN, "Unexpected error in RPC handling");
+ }
+#else // GRPC_ALLOW_EXCEPTIONS
+ return handler();
+#endif // GRPC_ALLOW_EXCEPTIONS
+}
+
/// A wrapper class of an application provided rpc method handler.
template <class ServiceType, class RequestType, class ResponseType>
class RpcMethodHandler : public MethodHandler {
@@ -42,7 +64,9 @@ class RpcMethodHandler : public MethodHandler {
param.request.bbuf_ptr(), &req);
ResponseType rsp;
if (status.ok()) {
- status = func_(service_, param.server_context, &req, &rsp);
+ status = CatchingFunctionHandler([this, &param, &req, &rsp] {
+ return func_(service_, param.server_context, &req, &rsp);
+ });
}
GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_);
@@ -85,7 +109,9 @@ class ClientStreamingHandler : public MethodHandler {
void RunHandler(const HandlerParameter& param) final {
ServerReader<RequestType> reader(param.call, param.server_context);
ResponseType rsp;
- Status status = func_(service_, param.server_context, &reader, &rsp);
+ Status status = CatchingFunctionHandler([this, &param, &reader, &rsp] {
+ return func_(service_, param.server_context, &reader, &rsp);
+ });
GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
@@ -129,7 +155,9 @@ class ServerStreamingHandler : public MethodHandler {
if (status.ok()) {
ServerWriter<ResponseType> writer(param.call, param.server_context);
- status = func_(service_, param.server_context, &req, &writer);
+ status = CatchingFunctionHandler([this, &param, &req, &writer] {
+ return func_(service_, param.server_context, &req, &writer);
+ });
}
CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops;
@@ -171,7 +199,9 @@ class TemplatedBidiStreamingHandler : public MethodHandler {
void RunHandler(const HandlerParameter& param) final {
Streamer stream(param.call, param.server_context);
- Status status = func_(param.server_context, &stream);
+ Status status = CatchingFunctionHandler([this, &param, &stream] {
+ return func_(param.server_context, &stream);
+ });
CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops;
if (!param.server_context->sent_initial_metadata_) {
@@ -266,6 +296,7 @@ class UnknownMethodHandler : public MethodHandler {
}
};
+} // namespace internal
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H
diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h
index 67e8f71a89..b7636034d4 100644
--- a/include/grpc++/impl/codegen/proto_utils.h
+++ b/include/grpc++/impl/codegen/proto_utils.h
@@ -39,11 +39,13 @@ class GrpcBufferWriterPeer;
const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024;
-class GrpcBufferWriter final
- : public ::grpc::protobuf::io::ZeroCopyOutputStream {
+class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
public:
- explicit GrpcBufferWriter(grpc_byte_buffer** bp, int block_size)
- : block_size_(block_size), byte_count_(0), have_backup_(false) {
+ GrpcBufferWriter(grpc_byte_buffer** bp, int block_size, int total_size)
+ : block_size_(block_size),
+ total_size_(total_size),
+ byte_count_(0),
+ have_backup_(false) {
*bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(NULL, 0);
slice_buffer_ = &(*bp)->data.raw.slice_buffer;
}
@@ -55,11 +57,20 @@ class GrpcBufferWriter final
}
bool Next(void** data, int* size) override {
+ // Protobuf should not ask for more memory than total_size_.
+ GPR_CODEGEN_ASSERT(byte_count_ < total_size_);
if (have_backup_) {
slice_ = backup_slice_;
have_backup_ = false;
} else {
- slice_ = g_core_codegen_interface->grpc_slice_malloc(block_size_);
+ // When less than a whole block is needed, only allocate that much.
+ // But make sure the allocated slice is not inlined.
+ size_t remain = total_size_ - byte_count_ > block_size_
+ ? block_size_
+ : total_size_ - byte_count_;
+ slice_ = g_core_codegen_interface->grpc_slice_malloc(
+ remain > GRPC_SLICE_INLINED_SIZE ? remain
+ : GRPC_SLICE_INLINED_SIZE + 1);
}
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
@@ -71,7 +82,7 @@ class GrpcBufferWriter final
void BackUp(int count) override {
g_core_codegen_interface->grpc_slice_buffer_pop(slice_buffer_);
- if (count == block_size_) {
+ if ((size_t)count == GRPC_SLICE_LENGTH(slice_)) {
backup_slice_ = slice_;
} else {
backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail(
@@ -88,9 +99,10 @@ class GrpcBufferWriter final
grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
- private:
+ protected:
friend class GrpcBufferWriterPeer;
const int block_size_;
+ const int total_size_;
int64_t byte_count_;
grpc_slice_buffer* slice_buffer_;
bool have_backup_;
@@ -98,8 +110,7 @@ class GrpcBufferWriter final
grpc_slice slice_;
};
-class GrpcBufferReader final
- : public ::grpc::protobuf::io::ZeroCopyInputStream {
+class GrpcBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream {
public:
explicit GrpcBufferReader(grpc_byte_buffer* buffer)
: byte_count_(0), backup_count_(0), status_() {
@@ -160,7 +171,7 @@ class GrpcBufferReader final
return byte_count_ - backup_count_;
}
- private:
+ protected:
int64_t byte_count_;
int64_t backup_count_;
grpc_byte_buffer_reader reader_;
@@ -168,57 +179,85 @@ class GrpcBufferReader final
Status status_;
};
+// BufferWriter must be a subclass of io::ZeroCopyOutputStream.
+template <class BufferWriter, class T>
+Status GenericSerialize(const grpc::protobuf::Message& msg,
+ grpc_byte_buffer** bp, bool* own_buffer) {
+ static_assert(
+ std::is_base_of<protobuf::io::ZeroCopyOutputStream, BufferWriter>::value,
+ "BufferWriter must be a subclass of io::ZeroCopyOutputStream");
+ *own_buffer = true;
+ int byte_size = msg.ByteSize();
+ if ((size_t)byte_size <= GRPC_SLICE_INLINED_SIZE) {
+ grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size);
+ GPR_CODEGEN_ASSERT(
+ GRPC_SLICE_END_PTR(slice) ==
+ msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice)));
+ *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1);
+ g_core_codegen_interface->grpc_slice_unref(slice);
+
+ return g_core_codegen_interface->ok();
+ }
+ BufferWriter writer(bp, kGrpcBufferWriterMaxBufferLength, byte_size);
+ return msg.SerializeToZeroCopyStream(&writer)
+ ? g_core_codegen_interface->ok()
+ : Status(StatusCode::INTERNAL, "Failed to serialize message");
+}
+
+// BufferReader must be a subclass of io::ZeroCopyInputStream.
+template <class BufferReader, class T>
+Status GenericDeserialize(grpc_byte_buffer* buffer,
+ grpc::protobuf::Message* msg) {
+ static_assert(
+ std::is_base_of<protobuf::io::ZeroCopyInputStream, BufferReader>::value,
+ "BufferReader must be a subclass of io::ZeroCopyInputStream");
+ if (buffer == nullptr) {
+ return Status(StatusCode::INTERNAL, "No payload");
+ }
+ Status result = g_core_codegen_interface->ok();
+ {
+ BufferReader reader(buffer);
+ if (!reader.status().ok()) {
+ return reader.status();
+ }
+ ::grpc::protobuf::io::CodedInputStream decoder(&reader);
+ decoder.SetTotalBytesLimit(INT_MAX, INT_MAX);
+ if (!msg->ParseFromCodedStream(&decoder)) {
+ result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
+ }
+ if (!decoder.ConsumedEntireMessage()) {
+ result = Status(StatusCode::INTERNAL, "Did not read entire message");
+ }
+ }
+ g_core_codegen_interface->grpc_byte_buffer_destroy(buffer);
+ return result;
+}
+
} // namespace internal
+// this is needed so the following class does not conflict with protobuf
+// serializers that utilize internal-only tools.
+#ifdef GRPC_OPEN_SOURCE_PROTO
+// This class provides a protobuf serializer. It translates between protobuf
+// objects and grpc_byte_buffers. More information about SerializationTraits can
+// be found in include/grpc++/impl/codegen/serialization_traits.h.
template <class T>
class SerializationTraits<T, typename std::enable_if<std::is_base_of<
grpc::protobuf::Message, T>::value>::type> {
public:
static Status Serialize(const grpc::protobuf::Message& msg,
grpc_byte_buffer** bp, bool* own_buffer) {
- *own_buffer = true;
- int byte_size = msg.ByteSize();
- if (byte_size <= internal::kGrpcBufferWriterMaxBufferLength) {
- grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size);
- GPR_CODEGEN_ASSERT(
- GRPC_SLICE_END_PTR(slice) ==
- msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice)));
- *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1);
- g_core_codegen_interface->grpc_slice_unref(slice);
- return g_core_codegen_interface->ok();
- } else {
- internal::GrpcBufferWriter writer(
- bp, internal::kGrpcBufferWriterMaxBufferLength);
- return msg.SerializeToZeroCopyStream(&writer)
- ? g_core_codegen_interface->ok()
- : Status(StatusCode::INTERNAL, "Failed to serialize message");
- }
+ return internal::GenericSerialize<internal::GrpcBufferWriter, T>(
+ msg, bp, own_buffer);
}
static Status Deserialize(grpc_byte_buffer* buffer,
grpc::protobuf::Message* msg) {
- if (buffer == nullptr) {
- return Status(StatusCode::INTERNAL, "No payload");
- }
- Status result = g_core_codegen_interface->ok();
- {
- internal::GrpcBufferReader reader(buffer);
- if (!reader.status().ok()) {
- return reader.status();
- }
- ::grpc::protobuf::io::CodedInputStream decoder(&reader);
- decoder.SetTotalBytesLimit(INT_MAX, INT_MAX);
- if (!msg->ParseFromCodedStream(&decoder)) {
- result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
- }
- if (!decoder.ConsumedEntireMessage()) {
- result = Status(StatusCode::INTERNAL, "Did not read entire message");
- }
- }
- g_core_codegen_interface->grpc_byte_buffer_destroy(buffer);
- return result;
+ return internal::GenericDeserialize<internal::GrpcBufferReader, T>(buffer,
+ msg);
}
};
+#endif
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h
index ac13ac56c7..54e52364ef 100644
--- a/include/grpc++/impl/codegen/rpc_method.h
+++ b/include/grpc++/impl/codegen/rpc_method.h
@@ -24,7 +24,7 @@
#include <grpc++/impl/codegen/channel_interface.h>
namespace grpc {
-
+namespace internal {
/// Descriptor of an RPC method
class RpcMethod {
public:
@@ -55,6 +55,7 @@ class RpcMethod {
void* const channel_tag_;
};
+} // namespace internal
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_RPC_METHOD_H
diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h
index d356012ad6..5ba11e8559 100644
--- a/include/grpc++/impl/codegen/rpc_service_method.h
+++ b/include/grpc++/impl/codegen/rpc_service_method.h
@@ -32,8 +32,8 @@
namespace grpc {
class ServerContext;
-class StreamContextInterface;
+namespace internal {
/// Base class for running an RPC handler.
class MethodHandler {
public:
@@ -71,6 +71,7 @@ class RpcServiceMethod : public RpcMethod {
void* server_tag_;
std::unique_ptr<MethodHandler> handler_;
};
+} // namespace internal
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h
index b5e37fd12b..a2d6967bf8 100644
--- a/include/grpc++/impl/codegen/server_context.h
+++ b/include/grpc++/impl/codegen/server_context.h
@@ -55,7 +55,6 @@ class ServerWriter;
namespace internal {
template <class W, class R>
class ServerReaderWriterBody;
-}
template <class ServiceType, class RequestType, class ResponseType>
class RpcMethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
@@ -65,9 +64,11 @@ class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
class BidiStreamingHandler;
class UnknownMethodHandler;
-
+template <class Streamer, bool WriteNeeded>
+class TemplatedBidiStreamingHandler;
class Call;
-class CallOpBuffer;
+} // namespace internal
+
class CompletionQueue;
class Server;
class ServerInterface;
@@ -247,14 +248,14 @@ class ServerContext {
template <class W, class R>
friend class ::grpc::internal::ServerReaderWriterBody;
template <class ServiceType, class RequestType, class ResponseType>
- friend class RpcMethodHandler;
+ friend class ::grpc::internal::RpcMethodHandler;
template <class ServiceType, class RequestType, class ResponseType>
- friend class ClientStreamingHandler;
+ friend class ::grpc::internal::ClientStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
- friend class ServerStreamingHandler;
+ friend class ::grpc::internal::ServerStreamingHandler;
template <class Streamer, bool WriteNeeded>
- friend class TemplatedBidiStreamingHandler;
- friend class UnknownMethodHandler;
+ friend class ::grpc::internal::TemplatedBidiStreamingHandler;
+ friend class ::grpc::internal::UnknownMethodHandler;
friend class ::grpc::ClientContext;
/// Prevent copying.
@@ -263,9 +264,9 @@ class ServerContext {
class CompletionOp;
- void BeginCompletionOp(Call* call);
+ void BeginCompletionOp(internal::Call* call);
/// Return the tag queued by BeginCompletionOp()
- CompletionQueueTag* GetCompletionOpTag();
+ internal::CompletionQueueTag* GetCompletionOpTag();
ServerContext(gpr_timespec deadline, grpc_metadata_array* arr);
@@ -282,7 +283,7 @@ class ServerContext {
CompletionQueue* cq_;
bool sent_initial_metadata_;
mutable std::shared_ptr<const AuthContext> auth_context_;
- MetadataMap client_metadata_;
+ internal::MetadataMap client_metadata_;
std::multimap<grpc::string, grpc::string> initial_metadata_;
std::multimap<grpc::string, grpc::string> trailing_metadata_;
@@ -290,7 +291,9 @@ class ServerContext {
grpc_compression_level compression_level_;
grpc_compression_algorithm compression_algorithm_;
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> pending_ops_;
+ internal::CallOpSet<internal::CallOpSendInitialMetadata,
+ internal::CallOpSendMessage>
+ pending_ops_;
bool has_pending_ops_;
};
diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h
index 55937f19d7..3bcf4c87e7 100644
--- a/include/grpc++/impl/codegen/server_interface.h
+++ b/include/grpc++/impl/codegen/server_interface.h
@@ -30,20 +30,21 @@ namespace grpc {
class AsyncGenericService;
class Channel;
class GenericServerContext;
-class RpcService;
-class ServerAsyncStreamingInterface;
class ServerCompletionQueue;
class ServerContext;
class ServerCredentials;
class Service;
-class ThreadPoolInterface;
extern CoreCodegenInterface* g_core_codegen_interface;
/// Models a gRPC server.
///
/// Servers are configured and started via \a grpc::ServerBuilder.
-class ServerInterface : public CallHook {
+namespace internal {
+class ServerAsyncStreamingInterface;
+} // namespace internal
+
+class ServerInterface : public internal::CallHook {
public:
virtual ~ServerInterface() {}
@@ -78,7 +79,7 @@ class ServerInterface : public CallHook {
virtual void Wait() = 0;
protected:
- friend class Service;
+ friend class ::grpc::Service;
/// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the Server instance.
@@ -116,12 +117,13 @@ class ServerInterface : public CallHook {
virtual grpc_server* server() = 0;
- virtual void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) = 0;
+ virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops,
+ internal::Call* call) = 0;
- class BaseAsyncRequest : public CompletionQueueTag {
+ class BaseAsyncRequest : public internal::CompletionQueueTag {
public:
BaseAsyncRequest(ServerInterface* server, ServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq, void* tag,
bool delete_on_finalize);
virtual ~BaseAsyncRequest();
@@ -131,7 +133,7 @@ class ServerInterface : public CallHook {
protected:
ServerInterface* const server_;
ServerContext* const context_;
- ServerAsyncStreamingInterface* const stream_;
+ internal::ServerAsyncStreamingInterface* const stream_;
CompletionQueue* const call_cq_;
void* const tag_;
const bool delete_on_finalize_;
@@ -141,7 +143,7 @@ class ServerInterface : public CallHook {
class RegisteredAsyncRequest : public BaseAsyncRequest {
public:
RegisteredAsyncRequest(ServerInterface* server, ServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq, void* tag);
// uses BaseAsyncRequest::FinalizeResult
@@ -155,7 +157,7 @@ class ServerInterface : public CallHook {
public:
NoPayloadAsyncRequest(void* registered_method, ServerInterface* server,
ServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag)
: RegisteredAsyncRequest(server, context, stream, call_cq, tag) {
@@ -170,7 +172,7 @@ class ServerInterface : public CallHook {
public:
PayloadAsyncRequest(void* registered_method, ServerInterface* server,
ServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag,
Message* request)
@@ -212,7 +214,7 @@ class ServerInterface : public CallHook {
void* const registered_method_;
ServerInterface* const server_;
ServerContext* const context_;
- ServerAsyncStreamingInterface* const stream_;
+ internal::ServerAsyncStreamingInterface* const stream_;
CompletionQueue* const call_cq_;
ServerCompletionQueue* const notification_cq_;
void* const tag_;
@@ -223,7 +225,7 @@ class ServerInterface : public CallHook {
class GenericAsyncRequest : public BaseAsyncRequest {
public:
GenericAsyncRequest(ServerInterface* server, GenericServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag,
bool delete_on_finalize);
@@ -235,8 +237,9 @@ class ServerInterface : public CallHook {
};
template <class Message>
- void RequestAsyncCall(RpcServiceMethod* method, ServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ void RequestAsyncCall(internal::RpcServiceMethod* method,
+ ServerContext* context,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag,
Message* message) {
@@ -246,8 +249,9 @@ class ServerInterface : public CallHook {
message);
}
- void RequestAsyncCall(RpcServiceMethod* method, ServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ void RequestAsyncCall(internal::RpcServiceMethod* method,
+ ServerContext* context,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag) {
GPR_CODEGEN_ASSERT(method);
@@ -256,7 +260,7 @@ class ServerInterface : public CallHook {
}
void RequestAsyncGenericCall(GenericServerContext* context,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq,
void* tag) {
diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h
index 2dc4ea0ea6..71c3d99d5c 100644
--- a/include/grpc++/impl/codegen/service_type.h
+++ b/include/grpc++/impl/codegen/service_type.h
@@ -28,13 +28,14 @@
namespace grpc {
-class Call;
class CompletionQueue;
class Server;
class ServerInterface;
class ServerCompletionQueue;
class ServerContext;
+namespace internal {
+class Call;
class ServerAsyncStreamingInterface {
public:
virtual ~ServerAsyncStreamingInterface() {}
@@ -48,9 +49,10 @@ class ServerAsyncStreamingInterface {
virtual void SendInitialMetadata(void* tag) = 0;
private:
- friend class ServerInterface;
+ friend class ::grpc::ServerInterface;
virtual void BindCall(Call* call) = 0;
};
+} // namespace internal
/// Desriptor of an RPC service and its various RPC methods
class Service {
@@ -88,40 +90,38 @@ class Service {
protected:
template <class Message>
void RequestAsyncUnary(int index, ServerContext* context, Message* request,
- ServerAsyncStreamingInterface* stream,
+ internal::ServerAsyncStreamingInterface* stream,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag) {
server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq,
notification_cq, tag, request);
}
- void RequestAsyncClientStreaming(int index, ServerContext* context,
- ServerAsyncStreamingInterface* stream,
- CompletionQueue* call_cq,
- ServerCompletionQueue* notification_cq,
- void* tag) {
+ void RequestAsyncClientStreaming(
+ int index, ServerContext* context,
+ internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
+ ServerCompletionQueue* notification_cq, void* tag) {
server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq,
notification_cq, tag);
}
template <class Message>
- void RequestAsyncServerStreaming(int index, ServerContext* context,
- Message* request,
- ServerAsyncStreamingInterface* stream,
- CompletionQueue* call_cq,
- ServerCompletionQueue* notification_cq,
- void* tag) {
+ void RequestAsyncServerStreaming(
+ int index, ServerContext* context, Message* request,
+ internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
+ ServerCompletionQueue* notification_cq, void* tag) {
server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq,
notification_cq, tag, request);
}
- void RequestAsyncBidiStreaming(int index, ServerContext* context,
- ServerAsyncStreamingInterface* stream,
- CompletionQueue* call_cq,
- ServerCompletionQueue* notification_cq,
- void* tag) {
+ void RequestAsyncBidiStreaming(
+ int index, ServerContext* context,
+ internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
+ ServerCompletionQueue* notification_cq, void* tag) {
server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq,
notification_cq, tag);
}
- void AddMethod(RpcServiceMethod* method) { methods_.emplace_back(method); }
+ void AddMethod(internal::RpcServiceMethod* method) {
+ methods_.emplace_back(method);
+ }
void MarkMethodAsync(int index) {
GPR_CODEGEN_ASSERT(
@@ -139,7 +139,7 @@ class Service {
methods_[index].reset();
}
- void MarkMethodStreamed(int index, MethodHandler* streamed_method) {
+ void MarkMethodStreamed(int index, internal::MethodHandler* streamed_method) {
GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() &&
"Cannot mark an async or generic method Streamed");
methods_[index]->SetHandler(streamed_method);
@@ -148,14 +148,14 @@ class Service {
// case of BIDI_STREAMING that has 1 read and 1 write, in that order,
// and split server-side streaming is BIDI_STREAMING with 1 read and
// any number of writes, in that order.
- methods_[index]->SetMethodType(::grpc::RpcMethod::BIDI_STREAMING);
+ methods_[index]->SetMethodType(internal::RpcMethod::BIDI_STREAMING);
}
private:
friend class Server;
friend class ServerInterface;
ServerInterface* server_;
- std::vector<std::unique_ptr<RpcServiceMethod>> methods_;
+ std::vector<std::unique_ptr<internal::RpcServiceMethod>> methods_;
};
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h
index c1784f1820..a6dd26fb00 100644
--- a/include/grpc++/impl/codegen/sync_stream.h
+++ b/include/grpc++/impl/codegen/sync_stream.h
@@ -30,6 +30,7 @@
namespace grpc {
+namespace internal {
/// Common interface for all synchronous client side streaming.
class ClientStreamingInterface {
public:
@@ -141,10 +142,12 @@ class WriterInterface {
}
};
+} // namespace internal
+
/// Client-side interface for streaming reads of message of type \a R.
template <class R>
-class ClientReaderInterface : public ClientStreamingInterface,
- public ReaderInterface<R> {
+class ClientReaderInterface : public internal::ClientStreamingInterface,
+ public internal::ReaderInterface<R> {
public:
/// Block to wait for initial metadata from server. The received metadata
/// can only be accessed after this call returns. Should only be called before
@@ -153,35 +156,25 @@ class ClientReaderInterface : public ClientStreamingInterface,
virtual void WaitForInitialMetadata() = 0;
};
+namespace internal {
+template <class R>
+class ClientReaderFactory {
+ public:
+ template <class W>
+ static ClientReader<R>* Create(ChannelInterface* channel,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context, const W& request) {
+ return new ClientReader<R>(channel, method, context, request);
+ }
+};
+} // namespace internal
+
/// Synchronous (blocking) client-side API for doing server-streaming RPCs,
/// where the stream of messages coming from the server has messages
/// of type \a R.
template <class R>
class ClientReader final : public ClientReaderInterface<R> {
public:
- /// Block to create a stream and write the initial metadata and \a request
- /// out. Note that \a context will be used to fill in custom initial
- /// metadata used to send to the server when starting the call.
- template <class W>
- ClientReader(ChannelInterface* channel, const RpcMethod& method,
- ClientContext* context, const W& request)
- : context_(context),
- cq_(grpc_completion_queue_attributes{
- GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
- GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
- call_(channel->CreateCall(method, context, &cq_)) {
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpClientSendClose>
- ops;
- ops.SendInitialMetadata(context->send_initial_metadata_,
- context->initial_metadata_flags());
- // TODO(ctiller): don't assert
- GPR_CODEGEN_ASSERT(ops.SendMessage(request).ok());
- ops.ClientSendClose();
- call_.PerformOps(&ops);
- cq_.Pluck(&ops);
- }
-
/// See the \a ClientStreamingInterface.WaitForInitialMetadata method for
/// semantics.
///
@@ -192,7 +185,8 @@ class ClientReader final : public ClientReaderInterface<R> {
void WaitForInitialMetadata() override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
- CallOpSet<CallOpRecvInitialMetadata> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ ops;
ops.RecvInitialMetadata(context_);
call_.PerformOps(&ops);
cq_.Pluck(&ops); /// status ignored
@@ -209,7 +203,9 @@ class ClientReader final : public ClientReaderInterface<R> {
/// already received (if initial metadata is received, it can be then
/// accessed through the \a ClientContext associated with this call).
bool Read(R* msg) override {
- CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpRecvMessage<R>>
+ ops;
if (!context_->initial_metadata_received_) {
ops.RecvInitialMetadata(context_);
}
@@ -224,7 +220,7 @@ class ClientReader final : public ClientReaderInterface<R> {
/// The \a ClientContext associated with this call is updated with
/// possible metadata received from the server.
Status Finish() override {
- CallOpSet<CallOpClientRecvStatus> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientRecvStatus> ops;
Status status;
ops.ClientRecvStatus(context_, &status);
call_.PerformOps(&ops);
@@ -233,15 +229,41 @@ class ClientReader final : public ClientReaderInterface<R> {
}
private:
+ friend class internal::ClientReaderFactory<R>;
ClientContext* context_;
CompletionQueue cq_;
- Call call_;
+ ::grpc::internal::Call call_;
+
+ /// Block to create a stream and write the initial metadata and \a request
+ /// out. Note that \a context will be used to fill in custom initial
+ /// metadata used to send to the server when starting the call.
+ template <class W>
+ ClientReader(::grpc::ChannelInterface* channel,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context, const W& request)
+ : context_(context),
+ cq_(grpc_completion_queue_attributes{
+ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
+ GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
+ call_(channel->CreateCall(method, context, &cq_)) {
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
+ ops;
+ ops.SendInitialMetadata(context->send_initial_metadata_,
+ context->initial_metadata_flags());
+ // TODO(ctiller): don't assert
+ GPR_CODEGEN_ASSERT(ops.SendMessage(request).ok());
+ ops.ClientSendClose();
+ call_.PerformOps(&ops);
+ cq_.Pluck(&ops);
+ }
};
/// Client-side interface for streaming writes of message type \a W.
template <class W>
-class ClientWriterInterface : public ClientStreamingInterface,
- public WriterInterface<W> {
+class ClientWriterInterface : public internal::ClientStreamingInterface,
+ public internal::WriterInterface<W> {
public:
/// Half close writing from the client. (signal that the stream of messages
/// coming from the client is complete).
@@ -252,37 +274,25 @@ class ClientWriterInterface : public ClientStreamingInterface,
virtual bool WritesDone() = 0;
};
+namespace internal {
+template <class W>
+class ClientWriterFactory {
+ public:
+ template <class R>
+ static ClientWriter<W>* Create(::grpc::ChannelInterface* channel,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context, R* response) {
+ return new ClientWriter<W>(channel, method, context, response);
+ }
+};
+} // namespace internal
+
/// Synchronous (blocking) client-side API for doing client-streaming RPCs,
/// where the outgoing message stream coming from the client has messages of
/// type \a W.
template <class W>
class ClientWriter : public ClientWriterInterface<W> {
public:
- /// Block to create a stream (i.e. send request headers and other initial
- /// metadata to the server). Note that \a context will be used to fill
- /// in custom initial metadata. \a response will be filled in with the
- /// single expected response message from the server upon a successful
- /// call to the \a Finish method of this instance.
- template <class R>
- ClientWriter(ChannelInterface* channel, const RpcMethod& method,
- ClientContext* context, R* response)
- : context_(context),
- cq_(grpc_completion_queue_attributes{
- GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
- GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
- call_(channel->CreateCall(method, context, &cq_)) {
- finish_ops_.RecvMessage(response);
- finish_ops_.AllowNoMessage();
-
- if (!context_->initial_metadata_corked_) {
- CallOpSet<CallOpSendInitialMetadata> ops;
- ops.SendInitialMetadata(context->send_initial_metadata_,
- context->initial_metadata_flags());
- call_.PerformOps(&ops);
- cq_.Pluck(&ops);
- }
- }
-
/// See the \a ClientStreamingInterface.WaitForInitialMetadata method for
/// semantics.
///
@@ -292,7 +302,8 @@ class ClientWriter : public ClientWriterInterface<W> {
void WaitForInitialMetadata() {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
- CallOpSet<CallOpRecvInitialMetadata> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ ops;
ops.RecvInitialMetadata(context_);
call_.PerformOps(&ops);
cq_.Pluck(&ops); // status ignored
@@ -304,10 +315,11 @@ class ClientWriter : public ClientWriterInterface<W> {
/// Side effect:
/// Also sends initial metadata if not already sent (using the
/// \a ClientContext associated with this call).
- using WriterInterface<W>::Write;
+ using ::grpc::internal::WriterInterface<W>::Write;
bool Write(const W& msg, WriteOptions options) override {
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpClientSendClose>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
ops;
if (options.is_last_message()) {
@@ -328,7 +340,7 @@ class ClientWriter : public ClientWriterInterface<W> {
}
bool WritesDone() override {
- CallOpSet<CallOpClientSendClose> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops;
ops.ClientSendClose();
call_.PerformOps(&ops);
return cq_.Pluck(&ops);
@@ -352,21 +364,51 @@ class ClientWriter : public ClientWriterInterface<W> {
}
private:
+ friend class internal::ClientWriterFactory<W>;
+
+ /// Block to create a stream (i.e. send request headers and other initial
+ /// metadata to the server). Note that \a context will be used to fill
+ /// in custom initial metadata. \a response will be filled in with the
+ /// single expected response message from the server upon a successful
+ /// call to the \a Finish method of this instance.
+ template <class R>
+ ClientWriter(ChannelInterface* channel,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context, R* response)
+ : context_(context),
+ cq_(grpc_completion_queue_attributes{
+ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
+ GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
+ call_(channel->CreateCall(method, context, &cq_)) {
+ finish_ops_.RecvMessage(response);
+ finish_ops_.AllowNoMessage();
+
+ if (!context_->initial_metadata_corked_) {
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
+ ops;
+ ops.SendInitialMetadata(context->send_initial_metadata_,
+ context->initial_metadata_flags());
+ call_.PerformOps(&ops);
+ cq_.Pluck(&ops);
+ }
+ }
+
ClientContext* context_;
- CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
- CallOpClientRecvStatus>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpGenericRecvMessage,
+ ::grpc::internal::CallOpClientRecvStatus>
finish_ops_;
CompletionQueue cq_;
- Call call_;
+ ::grpc::internal::Call call_;
};
/// Client-side interface for bi-directional streaming with
/// client-to-server stream messages of type \a W and
/// server-to-client stream messages of type \a R.
template <class W, class R>
-class ClientReaderWriterInterface : public ClientStreamingInterface,
- public WriterInterface<W>,
- public ReaderInterface<R> {
+class ClientReaderWriterInterface : public internal::ClientStreamingInterface,
+ public internal::WriterInterface<W>,
+ public internal::ReaderInterface<R> {
public:
/// Block to wait for initial metadata from server. The received metadata
/// can only be accessed after this call returns. Should only be called before
@@ -375,7 +417,7 @@ class ClientReaderWriterInterface : public ClientStreamingInterface,
virtual void WaitForInitialMetadata() = 0;
/// Half close writing from the client. (signal that the stream of messages
- /// coming from the client is complete).
+ /// coming from the clinet is complete).
/// Blocks until currently-pending writes are completed.
/// Thread-safe with respect to \a ReaderInterface::Read
///
@@ -383,6 +425,18 @@ class ClientReaderWriterInterface : public ClientStreamingInterface,
virtual bool WritesDone() = 0;
};
+namespace internal {
+template <class W, class R>
+class ClientReaderWriterFactory {
+ public:
+ static ClientReaderWriter<W, R>* Create(
+ ::grpc::ChannelInterface* channel,
+ const ::grpc::internal::RpcMethod& method, ClientContext* context) {
+ return new ClientReaderWriter<W, R>(channel, method, context);
+ }
+};
+} // namespace internal
+
/// Synchronous (blocking) client-side API for bi-directional streaming RPCs,
/// where the outgoing message stream coming from the client has messages of
/// type \a W, and the incoming messages stream coming from the server has
@@ -390,25 +444,6 @@ class ClientReaderWriterInterface : public ClientStreamingInterface,
template <class W, class R>
class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
public:
- /// Block to create a stream and write the initial metadata and \a request
- /// out. Note that \a context will be used to fill in custom initial metadata
- /// used to send to the server when starting the call.
- ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method,
- ClientContext* context)
- : context_(context),
- cq_(grpc_completion_queue_attributes{
- GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
- GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
- call_(channel->CreateCall(method, context, &cq_)) {
- if (!context_->initial_metadata_corked_) {
- CallOpSet<CallOpSendInitialMetadata> ops;
- ops.SendInitialMetadata(context->send_initial_metadata_,
- context->initial_metadata_flags());
- call_.PerformOps(&ops);
- cq_.Pluck(&ops);
- }
- }
-
/// Block waiting to read initial metadata from the server.
/// This call is optional, but if it is used, it cannot be used concurrently
/// with or after the \a Finish method.
@@ -418,7 +453,8 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
void WaitForInitialMetadata() override {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
- CallOpSet<CallOpRecvInitialMetadata> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
+ ops;
ops.RecvInitialMetadata(context_);
call_.PerformOps(&ops);
cq_.Pluck(&ops); // status ignored
@@ -434,7 +470,9 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
/// Also receives initial metadata if not already received (updates the \a
/// ClientContext associated with this call in that case).
bool Read(R* msg) override {
- CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpRecvMessage<R>>
+ ops;
if (!context_->initial_metadata_received_) {
ops.RecvInitialMetadata(context_);
}
@@ -448,10 +486,11 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
/// Side effect:
/// Also sends initial metadata if not already sent (using the
/// \a ClientContext associated with this call to fill in values).
- using WriterInterface<W>::Write;
+ using ::grpc::internal::WriterInterface<W>::Write;
bool Write(const W& msg, WriteOptions options) override {
- CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
- CallOpClientSendClose>
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
+ ::grpc::internal::CallOpSendMessage,
+ ::grpc::internal::CallOpClientSendClose>
ops;
if (options.is_last_message()) {
@@ -472,7 +511,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
}
bool WritesDone() override {
- CallOpSet<CallOpClientSendClose> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops;
ops.ClientSendClose();
call_.PerformOps(&ops);
return cq_.Pluck(&ops);
@@ -484,7 +523,9 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
/// - the \a ClientContext associated with this call is updated with
/// possible trailing metadata sent from the server.
Status Finish() override {
- CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> ops;
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
+ ::grpc::internal::CallOpClientRecvStatus>
+ ops;
if (!context_->initial_metadata_received_) {
ops.RecvInitialMetadata(context_);
}
@@ -496,15 +537,38 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
}
private:
+ friend class internal::ClientReaderWriterFactory<W, R>;
+
ClientContext* context_;
CompletionQueue cq_;
- Call call_;
+ ::grpc::internal::Call call_;
+
+ /// Block to create a stream and write the initial metadata and \a request
+ /// out. Note that \a context will be used to fill in custom initial metadata
+ /// used to send to the server when starting the call.
+ ClientReaderWriter(::grpc::ChannelInterface* channel,
+ const ::grpc::internal::RpcMethod& method,
+ ClientContext* context)
+ : context_(context),
+ cq_(grpc_completion_queue_attributes{
+ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
+ GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
+ call_(channel->CreateCall(method, context, &cq_)) {
+ if (!context_->initial_metadata_corked_) {
+ ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
+ ops;
+ ops.SendInitialMetadata(context->send_initial_metadata_,
+ context->initial_metadata_flags());
+ call_.PerformOps(&ops);
+ cq_.Pluck(&ops);
+ }
+ }
};
/// Server-side interface for streaming reads of message of type \a R.
template <class R>
-class ServerReaderInterface : public ServerStreamingInterface,
- public ReaderInterface<R> {};
+class ServerReaderInterface : public internal::ServerStreamingInterface,
+ public internal::ReaderInterface<R> {};
/// Synchronous (blocking) server-side API for doing client-streaming RPCs,
/// where the incoming message stream coming from the client has messages of
@@ -512,15 +576,13 @@ class ServerReaderInterface : public ServerStreamingInterface,
template <class R>
class ServerReader final : public ServerReaderInterface<R> {
public:
- ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
-
/// See the \a ServerStreamingInterface.SendInitialMetadata method
/// for semantics. Note that initial metadata will be affected by the
/// \a ServerContext associated with this call.
void SendInitialMetadata() override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
- CallOpSet<CallOpSendInitialMetadata> ops;
+ internal::CallOpSet<internal::CallOpSendInitialMetadata> ops;
ops.SendInitialMetadata(ctx_->initial_metadata_,
ctx_->initial_metadata_flags());
if (ctx_->compression_level_set()) {
@@ -537,21 +599,27 @@ class ServerReader final : public ServerReaderInterface<R> {
}
bool Read(R* msg) override {
- CallOpSet<CallOpRecvMessage<R>> ops;
+ internal::CallOpSet<internal::CallOpRecvMessage<R>> ops;
ops.RecvMessage(msg);
call_->PerformOps(&ops);
return call_->cq()->Pluck(&ops) && ops.got_message;
}
private:
- Call* const call_;
+ internal::Call* const call_;
ServerContext* const ctx_;
+
+ template <class ServiceType, class RequestType, class ResponseType>
+ friend class internal::ClientStreamingHandler;
+
+ ServerReader(internal::Call* call, ServerContext* ctx)
+ : call_(call), ctx_(ctx) {}
};
/// Server-side interface for streaming writes of message of type \a W.
template <class W>
-class ServerWriterInterface : public ServerStreamingInterface,
- public WriterInterface<W> {};
+class ServerWriterInterface : public internal::ServerStreamingInterface,
+ public internal::WriterInterface<W> {};
/// Synchronous (blocking) server-side API for doing for doing a
/// server-streaming RPCs, where the outgoing message stream coming from the
@@ -559,8 +627,6 @@ class ServerWriterInterface : public ServerStreamingInterface,
template <class W>
class ServerWriter final : public ServerWriterInterface<W> {
public:
- ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
-
/// See the \a ServerStreamingInterface.SendInitialMetadata method
/// for semantics.
/// Note that initial metadata will be affected by the
@@ -568,7 +634,7 @@ class ServerWriter final : public ServerWriterInterface<W> {
void SendInitialMetadata() override {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
- CallOpSet<CallOpSendInitialMetadata> ops;
+ internal::CallOpSet<internal::CallOpSendInitialMetadata> ops;
ops.SendInitialMetadata(ctx_->initial_metadata_,
ctx_->initial_metadata_flags());
if (ctx_->compression_level_set()) {
@@ -584,11 +650,12 @@ class ServerWriter final : public ServerWriterInterface<W> {
/// Side effect:
/// Also sends initial metadata if not already sent (using the
/// \a ClientContext associated with this call to fill in values).
- using WriterInterface<W>::Write;
+ using internal::WriterInterface<W>::Write;
bool Write(const W& msg, WriteOptions options) override {
if (options.is_last_message()) {
options.set_buffer_hint();
}
+
if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
return false;
}
@@ -613,15 +680,21 @@ class ServerWriter final : public ServerWriterInterface<W> {
}
private:
- Call* const call_;
+ internal::Call* const call_;
ServerContext* const ctx_;
+
+ template <class ServiceType, class RequestType, class ResponseType>
+ friend class internal::ServerStreamingHandler;
+
+ ServerWriter(internal::Call* call, ServerContext* ctx)
+ : call_(call), ctx_(ctx) {}
};
/// Server-side interface for bi-directional streaming.
template <class W, class R>
-class ServerReaderWriterInterface : public ServerStreamingInterface,
- public WriterInterface<W>,
- public ReaderInterface<R> {};
+class ServerReaderWriterInterface : public internal::ServerStreamingInterface,
+ public internal::WriterInterface<W>,
+ public internal::ReaderInterface<R> {};
/// Actual implementation of bi-directional streaming
namespace internal {
@@ -688,6 +761,7 @@ class ServerReaderWriterBody final {
Call* const call_;
ServerContext* const ctx_;
};
+
} // namespace internal
/// Synchronous (blocking) server-side API for a bidirectional
@@ -697,8 +771,6 @@ class ServerReaderWriterBody final {
template <class W, class R>
class ServerReaderWriter final : public ServerReaderWriterInterface<W, R> {
public:
- ServerReaderWriter(Call* call, ServerContext* ctx) : body_(call, ctx) {}
-
/// See the \a ServerStreamingInterface.SendInitialMetadata method
/// for semantics. Note that initial metadata will be affected by the
/// \a ServerContext associated with this call.
@@ -715,13 +787,18 @@ class ServerReaderWriter final : public ServerReaderWriterInterface<W, R> {
/// Side effect:
/// Also sends initial metadata if not already sent (using the \a
/// ServerContext associated with this call).
- using WriterInterface<W>::Write;
+ using internal::WriterInterface<W>::Write;
bool Write(const W& msg, WriteOptions options) override {
return body_.Write(msg, options);
}
private:
internal::ServerReaderWriterBody<W, R> body_;
+
+ friend class internal::TemplatedBidiStreamingHandler<ServerReaderWriter<W, R>,
+ false>;
+ ServerReaderWriter(internal::Call* call, ServerContext* ctx)
+ : body_(call, ctx) {}
};
/// A class to represent a flow-controlled unary call. This is something
@@ -736,9 +813,6 @@ template <class RequestType, class ResponseType>
class ServerUnaryStreamer final
: public ServerReaderWriterInterface<ResponseType, RequestType> {
public:
- ServerUnaryStreamer(Call* call, ServerContext* ctx)
- : body_(call, ctx), read_done_(false), write_done_(false) {}
-
/// Block to send initial metadata to client.
/// Implicit input parameter:
/// - the \a ServerContext associated with this call will be used for
@@ -775,7 +849,7 @@ class ServerUnaryStreamer final
/// \param options The WriteOptions affecting the write operation.
///
/// \return \a true on success, \a false when the stream has been closed.
- using WriterInterface<ResponseType>::Write;
+ using internal::WriterInterface<ResponseType>::Write;
bool Write(const ResponseType& response, WriteOptions options) override {
if (write_done_ || !read_done_) {
return false;
@@ -788,6 +862,11 @@ class ServerUnaryStreamer final
internal::ServerReaderWriterBody<ResponseType, RequestType> body_;
bool read_done_;
bool write_done_;
+
+ friend class internal::TemplatedBidiStreamingHandler<
+ ServerUnaryStreamer<RequestType, ResponseType>, true>;
+ ServerUnaryStreamer(internal::Call* call, ServerContext* ctx)
+ : body_(call, ctx), read_done_(false), write_done_(false) {}
};
/// A class to represent a flow-controlled server-side streaming call.
@@ -799,9 +878,6 @@ template <class RequestType, class ResponseType>
class ServerSplitStreamer final
: public ServerReaderWriterInterface<ResponseType, RequestType> {
public:
- ServerSplitStreamer(Call* call, ServerContext* ctx)
- : body_(call, ctx), read_done_(false) {}
-
/// Block to send initial metadata to client.
/// Implicit input parameter:
/// - the \a ServerContext associated with this call will be used for
@@ -838,7 +914,7 @@ class ServerSplitStreamer final
/// \param options The WriteOptions affecting the write operation.
///
/// \return \a true on success, \a false when the stream has been closed.
- using WriterInterface<ResponseType>::Write;
+ using internal::WriterInterface<ResponseType>::Write;
bool Write(const ResponseType& response, WriteOptions options) override {
return read_done_ && body_.Write(response, options);
}
@@ -846,6 +922,11 @@ class ServerSplitStreamer final
private:
internal::ServerReaderWriterBody<ResponseType, RequestType> body_;
bool read_done_;
+
+ friend class internal::TemplatedBidiStreamingHandler<
+ ServerSplitStreamer<RequestType, ResponseType>, false>;
+ ServerSplitStreamer(internal::Call* call, ServerContext* ctx)
+ : body_(call, ctx), read_done_(false) {}
};
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/time.h b/include/grpc++/impl/codegen/time.h
index 589deb4f03..d464d6ea13 100644
--- a/include/grpc++/impl/codegen/time.h
+++ b/include/grpc++/impl/codegen/time.h
@@ -19,6 +19,8 @@
#ifndef GRPCXX_IMPL_CODEGEN_TIME_H
#define GRPCXX_IMPL_CODEGEN_TIME_H
+#include <chrono>
+
#include <grpc++/impl/codegen/config.h>
#include <grpc/impl/codegen/grpc_types.h>
@@ -59,10 +61,6 @@ class TimePoint<gpr_timespec> {
} // namespace grpc
-#include <chrono>
-
-#include <grpc/impl/codegen/grpc_types.h>
-
namespace grpc {
// from and to should be absolute time.
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index 0a3aae8241..01c4a60d21 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -175,7 +175,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
/// \param num_cqs How many completion queues does \a cqs hold.
void Start(ServerCompletionQueue** cqs, size_t num_cqs) override;
- void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override;
+ void PerformOpsOnCall(internal::CallOpSetInterface* ops,
+ internal::Call* call) override;
void ShutdownInternal(gpr_timespec deadline) override;
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index bbf45b3e74..e2bae4b41f 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -40,7 +40,6 @@ namespace grpc {
class AsyncGenericService;
class ResourceQuota;
class CompletionQueue;
-class RpcService;
class Server;
class ServerCompletionQueue;
class ServerCredentials;
@@ -56,13 +55,18 @@ class ServerBuilder {
ServerBuilder();
~ServerBuilder();
- /// Options for synchronous servers.
- enum SyncServerOption {
- NUM_CQS, ///< Number of completion queues.
- MIN_POLLERS, ///< Minimum number of polling threads.
- MAX_POLLERS, ///< Maximum number of polling threads.
- CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds.
- };
+ //////////////////////////////////////////////////////////////////////////////
+ // Primary API's
+
+ /// Return a running server which is ready for processing calls.
+ /// Before calling, one typically needs to ensure that:
+ /// 1. a service is registered - so that the server knows what to serve
+ /// (via RegisterService, or RegisterAsyncGenericService)
+ /// 2. a listening port has been added - so the server knows where to receive
+ /// traffic (via AddListeningPort)
+ /// 3. [for async api only] completion queues have been added via
+ /// AddCompletionQueue
+ std::unique_ptr<Server> BuildAndStart();
/// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the \a Server instance returned
@@ -70,9 +74,60 @@ class ServerBuilder {
/// Matches requests with any :authority
ServerBuilder& RegisterService(Service* service);
- /// Register a generic service.
- /// Matches requests with any :authority
- ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service);
+ /// Enlists an endpoint \a addr (port with an optional IP address) to
+ /// bind the \a grpc::Server object to be created to.
+ ///
+ /// It can be invoked multiple times.
+ ///
+ /// \param addr_uri The address to try to bind to the server in URI form. If
+ /// the scheme name is omitted, "dns:///" is assumed. To bind to any address,
+ /// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4
+ /// connections. Valid values include dns:///localhost:1234, /
+ /// 192.168.1.1:31416, dns:///[::1]:27182, etc.).
+ /// \param creds The credentials associated with the server.
+ /// \param selected_port[out] If not `nullptr`, gets populated with the port
+ /// number bound to the \a grpc::Server for the corresponding endpoint after
+ /// it is successfully bound, 0 otherwise.
+ ///
+ ServerBuilder& AddListeningPort(const grpc::string& addr_uri,
+ std::shared_ptr<ServerCredentials> creds,
+ int* selected_port = nullptr);
+
+ /// Add a completion queue for handling asynchronous services.
+ ///
+ /// Best performance is typically obtained by using one thread per polling
+ /// completion queue.
+ ///
+ /// Caller is required to shutdown the server prior to shutting down the
+ /// returned completion queue. Caller is also required to drain the
+ /// completion queue after shutting it down. A typical usage scenario:
+ ///
+ /// // While building the server:
+ /// ServerBuilder builder;
+ /// ...
+ /// cq_ = builder.AddCompletionQueue();
+ /// server_ = builder.BuildAndStart();
+ ///
+ /// // While shutting down the server;
+ /// server_->Shutdown();
+ /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()!
+ /// // Drain the cq_ that was created
+ /// void* ignored_tag;
+ /// bool ignored_ok;
+ /// while (cq_->Next(&ignored_tag, &ignored_ok)) { }
+ ///
+ /// \param is_frequently_polled This is an optional parameter to inform gRPC
+ /// library about whether this completion queue would be frequently polled
+ /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is
+ /// 'true' and is the recommended setting. Setting this to 'false' (i.e.
+ /// not polling the completion queue frequently) will have a significantly
+ /// negative performance impact and hence should not be used in production
+ /// use cases.
+ std::unique_ptr<ServerCompletionQueue> AddCompletionQueue(
+ bool is_frequently_polled = true);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Less commonly used RegisterService variants
/// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the \a Server instance returned
@@ -80,6 +135,15 @@ class ServerBuilder {
/// Only matches requests with :authority \a host
ServerBuilder& RegisterService(const grpc::string& host, Service* service);
+ /// Register a generic service.
+ /// Matches requests with any :authority
+ /// This is mostly useful for writing generic gRPC Proxies where the exact
+ /// serialization format is unknown
+ ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Fine control knobs
+
/// Set max receive message size in bytes.
ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) {
max_receive_message_size_ = max_receive_message_size;
@@ -120,6 +184,14 @@ class ServerBuilder {
ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option);
+ /// Options for synchronous servers.
+ enum SyncServerOption {
+ NUM_CQS, ///< Number of completion queues.
+ MIN_POLLERS, ///< Minimum number of polling threads.
+ MAX_POLLERS, ///< Maximum number of polling threads.
+ CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds.
+ };
+
/// Only useful if this is a Synchronous server.
ServerBuilder& SetSyncServerOption(SyncServerOption option, int value);
@@ -130,59 +202,6 @@ class ServerBuilder {
return SetOption(MakeChannelArgumentOption(arg, value));
}
- /// Enlists an endpoint \a addr (port with an optional IP address) to
- /// bind the \a grpc::Server object to be created to.
- ///
- /// It can be invoked multiple times.
- ///
- /// \param addr_uri The address to try to bind to the server in URI form. If
- /// the scheme name is omitted, "dns:///" is assumed. To bind to any address,
- /// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4
- /// connections. Valid values include dns:///localhost:1234, /
- /// 192.168.1.1:31416, dns:///[::1]:27182, etc.).
- /// \params creds The credentials associated with the server.
- /// \param selected_port[out] If not `nullptr`, gets populated with the port
- /// number bound to the \a grpc::Server for the corresponding endpoint after
- /// it is successfully bound, 0 otherwise.
- ///
- // TODO(dgq): the "port" part seems to be a misnomer.
- ServerBuilder& AddListeningPort(const grpc::string& addr_uri,
- std::shared_ptr<ServerCredentials> creds,
- int* selected_port = nullptr);
-
- /// Add a completion queue for handling asynchronous services.
- ///
- /// Caller is required to shutdown the server prior to shutting down the
- /// returned completion queue. Caller is also required to drain the
- /// completion queue after shutting it down. A typical usage scenario:
- ///
- /// // While building the server:
- /// ServerBuilder builder;
- /// ...
- /// cq_ = builder.AddCompletionQueue();
- /// server_ = builder.BuildAndStart();
- ///
- /// // While shutting down the server;
- /// server_->Shutdown();
- /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()!
- /// // Drain the cq_ that was created
- /// void* ignored_tag;
- /// bool ignored_ok;
- /// while (cq_->Next(&ignored_tag, &ignored_ok)) { }
- ///
- /// \param is_frequently_polled This is an optional parameter to inform gRPC
- /// library about whether this completion queue would be frequently polled
- /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is
- /// 'true' and is the recommended setting. Setting this to 'false' (i.e.
- /// not polling the completion queue frequently) will have a significantly
- /// negative performance impact and hence should not be used in production
- /// use cases.
- std::unique_ptr<ServerCompletionQueue> AddCompletionQueue(
- bool is_frequently_polled = true);
-
- /// Return a running server which is ready for processing calls.
- std::unique_ptr<Server> BuildAndStart();
-
/// For internal use only: Register a ServerBuilderPlugin factory function.
static void InternalAddPluginFactory(
std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)());
diff --git a/include/grpc++/support/channel_arguments.h b/include/grpc++/support/channel_arguments.h
index 7b6befeaf1..c9879d8a28 100644
--- a/include/grpc++/support/channel_arguments.h
+++ b/include/grpc++/support/channel_arguments.h
@@ -64,6 +64,12 @@ class ChannelArguments {
/// Set the compression algorithm for the channel.
void SetCompressionAlgorithm(grpc_compression_algorithm algorithm);
+ /// Set the grpclb fallback timeout (in ms) for the channel. If this amount
+ /// of time has passed but we have not gotten any non-empty \a serverlist from
+ /// the balancer, we will fall back to use the backend address(es) returned by
+ /// the resolver.
+ void SetGrpclbFallbackTimeout(int fallback_timeout);
+
/// Set the socket mutator for the channel.
void SetSocketMutator(grpc_socket_mutator* mutator);
@@ -116,7 +122,7 @@ class ChannelArguments {
/// Default pointer argument operations.
struct PointerVtableMembers {
static void* Copy(void* in) { return in; }
- static void Destroy(grpc_exec_ctx* exec_ctx, void* in) {}
+ static void Destroy(void* in) {}
static int Compare(void* a, void* b) {
if (a < b) return -1;
if (a > b) return 1;
diff --git a/include/grpc/census.h b/include/grpc/census.h
index de8e7a6617..2258af8898 100644
--- a/include/grpc/census.h
+++ b/include/grpc/census.h
@@ -16,10 +16,6 @@
*
*/
-/** RPC-internal Census API's. These are designed to be generic enough that
- * they can (ultimately) be used in many different RPC systems (with differing
- * implementations). */
-
#ifndef GRPC_CENSUS_H
#define GRPC_CENSUS_H
@@ -29,439 +25,12 @@
extern "C" {
#endif
-/** Identify census features that can be enabled via census_initialize(). */
-enum census_features {
- CENSUS_FEATURE_NONE = 0, /** Do not enable census. */
- CENSUS_FEATURE_TRACING = 1, /** Enable census tracing. */
- CENSUS_FEATURE_STATS = 2, /** Enable Census stats collection. */
- CENSUS_FEATURE_CPU = 4, /** Enable Census CPU usage collection. */
- CENSUS_FEATURE_ALL =
- CENSUS_FEATURE_TRACING | CENSUS_FEATURE_STATS | CENSUS_FEATURE_CPU
-};
-
-/** Shutdown and startup census subsystem. The 'features' argument should be
- * the OR (|) of census_features values. If census fails to initialize, then
- * census_initialize() will return -1, otherwise the set of enabled features
- * (which may be smaller than that provided in the `features` argument, see
- * census_supported()) is returned. It is an error to call census_initialize()
- * more than once (without an intervening census_shutdown()). These functions
- * are not thread-safe. */
-CENSUSAPI int census_initialize(int features);
-CENSUSAPI void census_shutdown(void);
-
-/** Return the features supported by the current census implementation (not all
- * features will be available on all platforms). */
-CENSUSAPI int census_supported(void);
-
-/** Return the census features currently enabled. */
-CENSUSAPI int census_enabled(void);
-
/**
A Census Context is a handle used by Census to represent the current tracing
and stats collection information. Contexts should be propagated across RPC's
- (this is the responsibility of the local RPC system). A context is typically
- used as the first argument to most census functions. Conceptually, they
- should be thought of as specific to a single RPC/thread. The user visible
- context representation is that of a collection of key:value string pairs,
- each of which is termed a 'tag'; these form the basis against which Census
- metrics will be recorded. Keys are unique within a context. */
+ (this is the responsibility of the local RPC system). */
typedef struct census_context census_context;
-/** A tag is a key:value pair. Both keys and values are nil-terminated strings,
- containing printable ASCII characters (decimal 32-126). Keys must be at
- least one character in length. Both keys and values can have at most
- CENSUS_MAX_TAG_KB_LEN characters (including the terminating nil). The
- maximum number of tags that can be propagated is
- CENSUS_MAX_PROPAGATED_TAGS. Users should also remember that some systems
- may have limits on, e.g., the number of bytes that can be transmitted as
- metadata, and that larger tags means more memory consumed and time in
- processing. */
-typedef struct {
- const char *key;
- const char *value;
- uint8_t flags;
-} census_tag;
-
-/** Maximum length of a tag's key or value. */
-#define CENSUS_MAX_TAG_KV_LEN 255
-/** Maximum number of propagatable tags. */
-#define CENSUS_MAX_PROPAGATED_TAGS 255
-
-/** Tag flags. */
-#define CENSUS_TAG_PROPAGATE 1 /** Tag should be propagated over RPC */
-#define CENSUS_TAG_STATS 2 /** Tag will be used for statistics aggregation */
-#define CENSUS_TAG_RESERVED 4 /** Reserved for internal use. */
-/** Flag values 4,8,16,32,64,128 are reserved for future/internal use. Clients
- should not use or rely on their values. */
-
-#define CENSUS_TAG_IS_PROPAGATED(flags) (flags & CENSUS_TAG_PROPAGATE)
-#define CENSUS_TAG_IS_STATS(flags) (flags & CENSUS_TAG_STATS)
-
-/** An instance of this structure is kept by every context, and records the
- basic information associated with the creation of that context. */
-typedef struct {
- int n_propagated_tags; /** number of propagated tags */
- int n_local_tags; /** number of non-propagated (local) tags */
- int n_deleted_tags; /** number of tags that were deleted */
- int n_added_tags; /** number of tags that were added */
- int n_modified_tags; /** number of tags that were modified */
- int n_invalid_tags; /** number of tags with bad keys or values (e.g.
- longer than CENSUS_MAX_TAG_KV_LEN) */
- int n_ignored_tags; /** number of tags ignored because of
- CENSUS_MAX_PROPAGATED_TAGS limit. */
-} census_context_status;
-
-/** Create a new context, adding and removing tags from an existing context.
- This will copy all tags from the 'tags' input, so it is recommended
- to add as many tags in a single operation as is practical for the client.
- @param base Base context to build upon. Can be NULL.
- @param tags A set of tags to be added/changed/deleted. Tags with keys that
- are in 'tags', but not 'base', are added to the context. Keys that are in
- both 'tags' and 'base' will have their value/flags modified. Tags with keys
- in both, but with NULL values, will be deleted from the context. Tags with
- invalid (too long or short) keys or values will be ignored.
- If adding a tag will result in more than CENSUS_MAX_PROPAGATED_TAGS in either
- binary or non-binary tags, they will be ignored, as will deletions of
- tags that don't exist.
- @param ntags number of tags in 'tags'
- @param status If not NULL, will return a pointer to a census_context_status
- structure containing information about the new context and status of the
- tags used in its creation.
- @return A new, valid census_context.
-*/
-CENSUSAPI census_context *census_context_create(
- const census_context *base, const census_tag *tags, int ntags,
- census_context_status const **status);
-
-/** Destroy a context. Once this function has been called, the context cannot
- be reused. */
-CENSUSAPI void census_context_destroy(census_context *context);
-
-/** Get a pointer to the original status from the context creation. */
-CENSUSAPI const census_context_status *census_context_get_status(
- const census_context *context);
-
-/** Structure used for iterating over the tags in a context. API clients should
- not use or reference internal fields - neither their contents or
- presence/absence are guaranteed. */
-typedef struct {
- const census_context *context;
- int base;
- int index;
- char *kvm;
-} census_context_iterator;
-
-/** Initialize a census_tag_iterator. Must be called before first use. */
-CENSUSAPI void census_context_initialize_iterator(
- const census_context *context, census_context_iterator *iterator);
-
-/** Get the contents of the "next" tag in the context. If there are no more
- tags, returns 0 (and 'tag' contents will be unchanged), otherwise returns 1.
- */
-CENSUSAPI int census_context_next_tag(census_context_iterator *iterator,
- census_tag *tag);
-
-/** Get a context tag by key. Returns 0 if the key is not present. */
-CENSUSAPI int census_context_get_tag(const census_context *context,
- const char *key, census_tag *tag);
-
-/** Tag set encode/decode functionality. These functions are intended
- for use by RPC systems only, for purposes of transmitting/receiving contexts.
- */
-
-/** Encode a context into a buffer.
- @param context context to be encoded
- @param buffer buffer into which the context will be encoded.
- @param buf_size number of available bytes in buffer.
- @return The number of buffer bytes consumed for the encoded context, or
- zero if the buffer was of insufficient size. */
-CENSUSAPI size_t census_context_encode(const census_context *context,
- char *buffer, size_t buf_size);
-
-/** Decode context buffer encoded with census_context_encode(). Returns NULL
- if there is an error in parsing either buffer. */
-CENSUSAPI census_context *census_context_decode(const char *buffer,
- size_t size);
-
-/** Distributed traces can have a number of options. */
-enum census_trace_mask_values {
- CENSUS_TRACE_MASK_NONE = 0, /** Default, empty flags */
- CENSUS_TRACE_MASK_IS_SAMPLED = 1 /** RPC tracing enabled for this context. */
-};
-
-/** Get the current trace mask associated with this context. The value returned
- will be the logical OR of census_trace_mask_values values. */
-CENSUSAPI int census_trace_mask(const census_context *context);
-
-/** Set the trace mask associated with a context. */
-CENSUSAPI void census_set_trace_mask(int trace_mask);
-
-/** The concept of "operation" is a fundamental concept for Census. In an RPC
- system, an operation typically represents a single RPC, or a significant
- sub-part thereof (e.g. a single logical "read" RPC to a distributed storage
- system might do several other actions in parallel, from looking up metadata
- indices to making requests of other services - each of these could be a
- sub-operation with the larger RPC operation). Census uses operations for the
- following:
-
- CPU accounting: If enabled, census will measure the thread CPU time
- consumed between operation start and end times.
-
- Active operations: Census will maintain information on all currently
- active operations.
-
- Distributed tracing: Each operation serves as a logical trace span.
-
- Stats collection: Stats are broken down by operation (e.g. latency
- breakdown for each unique RPC path).
-
- The following functions serve to delineate the start and stop points for
- each logical operation. */
-
-/**
- This structure represents a timestamp as used by census to record the time
- at which an operation begins.
-*/
-typedef struct {
- /** Use gpr_timespec for default implementation. High performance
- * implementations should use a cycle-counter based timestamp. */
- gpr_timespec ts;
-} census_timestamp;
-
-/**
- Mark the beginning of an RPC operation. The information required to call the
- functions to record the start of RPC operations (both client and server) may
- not be callable at the true start time of the operation, due to information
- not being available (e.g. the census context data will not be available in a
- server RPC until at least initial metadata has been processed). To ensure
- correct CPU accounting and latency recording, RPC systems can call this
- function to get the timestamp of operation beginning. This can later be used
- as an argument to census_start_{client,server}_rpc_op(). NB: for correct
- CPU accounting, the system must guarantee that the same thread is used
- for all request processing after this function is called.
-
- @return A timestamp representing the operation start time.
-*/
-CENSUSAPI census_timestamp census_start_rpc_op_timestamp(void);
-
-/**
- Represent functions to map RPC name ID to service/method names. Census
- breaks down all RPC stats by service and method names. We leave the
- definition and format of these to the RPC system. For efficiency purposes,
- we encode these as a single 64 bit identifier, and allow the RPC system to
- provide a structure for functions that can convert these to service and
- method strings.
-
- TODO(aveitch): Instead of providing this as an argument to the rpc_start_op()
- functions, maybe it should be set once at census initialization.
-*/
-typedef struct {
- const char *(*get_rpc_service_name)(int64_t id);
- const char *(*get_rpc_method_name)(int64_t id);
-} census_rpc_name_info;
-
-/**
- Start a client rpc operation. This function should be called as early in the
- client RPC path as possible. This function will create a new context. If
- the context argument is non-null, then the new context will inherit all
- its properties, with the following changes:
- - create a new operation ID for the new context, marking it as a child of
- the previous operation.
- - use the new RPC path and peer information for tracing and stats
- collection purposes, rather than those from the original context
-
- If the context argument is NULL, then a new root context is created. This
- is particularly important for tracing purposes (the trace spans generated
- will be unassociated with any other trace spans, except those
- downstream). The trace_mask will be used for tracing operations associated
- with the new context.
-
- In some RPC systems (e.g. where load balancing is used), peer information
- may not be available at the time the operation starts. In this case, use a
- NULL value for peer, and set it later using the
- census_set_rpc_client_peer() function.
-
- @param context The parent context. Can be NULL.
- @param rpc_name_id The rpc name identifier to be associated with this RPC.
- @param rpc_name_info Used to decode rpc_name_id.
- @param peer RPC peer. If not available at the time, NULL can be used,
- and a later census_set_rpc_client_peer() call made.
- @param trace_mask An OR of census_trace_mask_values values. Only used in
- the creation of a new root context (context == NULL).
- @param start_time A timestamp returned from census_start_rpc_op_timestamp().
- Can be NULL. Used to set the true time the operation
- begins.
-
- @return A new census context.
- */
-CENSUSAPI census_context *census_start_client_rpc_op(
- const census_context *context, int64_t rpc_name_id,
- const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
- const census_timestamp *start_time);
-
-/**
- Add peer information to a context representing a client RPC operation.
-*/
-CENSUSAPI void census_set_rpc_client_peer(census_context *context,
- const char *peer);
-
-/**
- Start a server RPC operation. Returns a new context to be used in future
- census calls. If buffer is non-NULL, then the buffer contents should
- represent the client context, as generated by census_context_serialize().
- If buffer is NULL, a new root context is created.
-
- @param buffer Buffer containing bytes output from census_context_serialize().
- @param rpc_name_id The rpc name identifier to be associated with this RPC.
- @param rpc_name_info Used to decode rpc_name_id.
- @param peer RPC peer.
- @param trace_mask An OR of census_trace_mask_values values. Only used in
- the creation of a new root context (buffer == NULL).
- @param start_time A timestamp returned from census_start_rpc_op_timestamp().
- Can be NULL. Used to set the true time the operation
- begins.
-
- @return A new census context.
- */
-CENSUSAPI census_context *census_start_server_rpc_op(
- const char *buffer, int64_t rpc_name_id,
- const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
- census_timestamp *start_time);
-
-/**
- Start a new, non-RPC operation. In general, this function works very
- similarly to census_start_client_rpc_op, with the primary difference being
- the replacement of host/path information with the more generic family/name
- tags. If the context argument is non-null, then the new context will
- inherit all its properties, with the following changes:
- - create a new operation ID for the new context, marking it as a child of
- the previous operation.
- - use the family and name information for tracing and stats collection
- purposes, rather than those from the original context
-
- If the context argument is NULL, then a new root context is created. This
- is particularly important for tracing purposes (the trace spans generated
- will be unassociated with any other trace spans, except those
- downstream). The trace_mask will be used for tracing
- operations associated with the new context.
-
- @param context The base context. Can be NULL.
- @param family Family name to associate with the trace
- @param name Name within family to associate with traces/stats
- @param trace_mask An OR of census_trace_mask_values values. Only used if
- context is NULL.
-
- @return A new census context.
- */
-CENSUSAPI census_context *census_start_op(census_context *context,
- const char *family, const char *name,
- int trace_mask);
-
-/**
- End an operation started by any of the census_start_*_op*() calls. The
- context used in this call will no longer be valid once this function
- completes.
-
- @param context Context associated with operation which is ending.
- @param status status associated with the operation. Not interpreted by
- census.
-*/
-CENSUSAPI void census_end_op(census_context *context, int status);
-
-#define CENSUS_TRACE_RECORD_START_OP ((uint32_t)0)
-#define CENSUS_TRACE_RECORD_END_OP ((uint32_t)1)
-
-/** Insert a trace record into the trace stream. The record consists of an
- arbitrary size buffer, the size of which is provided in 'n'.
- @param context Trace context
- @param type User-defined type to associate with trace entry.
- @param buffer Pointer to buffer to use
- @param n Number of bytes in buffer
-*/
-CENSUSAPI void census_trace_print(census_context *context, uint32_t type,
- const char *buffer, size_t n);
-
-/** Trace record. */
-typedef struct {
- census_timestamp timestamp; /** Time of record creation */
- uint64_t trace_id; /** Trace ID associated with record */
- uint64_t op_id; /** Operation ID associated with record */
- uint32_t type; /** Type (as used in census_trace_print() */
- const char *buffer; /** Buffer (from census_trace_print() */
- size_t buf_size; /** Number of bytes inside buffer */
-} census_trace_record;
-
-/** Start a scan of existing trace records. While a scan is ongoing, addition
- of new trace records will be blocked if the underlying trace buffers
- fill up, so trace processing systems should endeavor to complete
- reading as soon as possible.
- @param consume if non-zero, indicates that reading records also "consumes"
- the previously read record - i.e. releases space in the trace log
- while scanning is ongoing.
- @returns 0 on success, non-zero on failure (e.g. if a scan is already ongoing)
-*/
-CENSUSAPI int census_trace_scan_start(int consume);
-
-/** Get a trace record. The data pointed to by the trace buffer is guaranteed
- stable until the next census_get_trace_record() call (if the consume
- argument to census_trace_scan_start was non-zero) or census_trace_scan_end()
- is called (otherwise).
- @param trace_record structure that will be filled in with oldest trace record.
- @returns -1 if an error occurred (e.g. no previous call to
- census_trace_scan_start()), 0 if there is no more trace data (and
- trace_record will not be modified) or 1 otherwise.
-*/
-CENSUSAPI int census_get_trace_record(census_trace_record *trace_record);
-
-/** End a scan previously started by census_trace_scan_start() */
-CENSUSAPI void census_trace_scan_end();
-
-/** Core stats collection API's. The following concepts are used:
- * Resource: Users record measurements for a single resource. Examples
- include RPC latency, CPU seconds consumed, and bytes transmitted.
- * Aggregation: An aggregation of a set of measurements. Census supports the
- following aggregation types:
- * Distribution - statistical distribution information, used for
- recording average, standard deviation etc. Can include a histogram.
- * Interval - a count of events that happen in a rolling time window.
- * View: A view is a combination of a Resource, a set of tag keys and an
- Aggregation. When a measurement for a Resource matches the View tags, it is
- recorded (for each unique set of tag values) using the Aggregation type.
- Each resource can have an arbitrary number of views by which it will be
- broken down.
-
- Census uses protos to define each of the above, and output results. This
- ensures unification across the different language and runtime
- implementations. The proto definitions can be found in src/proto/census.
-*/
-
-/** Define a new resource. `resource_pb` should contain an encoded Resource
- protobuf, `resource_pb_size` being the size of the buffer. Returns a -ve
- value on error, or a positive (>= 0) resource id (for use in
- census_delete_resource() and census_record_values()). In order to be valid, a
- resource must have a name, and at least one numerator in its unit type. The
- resource name must be unique, and an error will be returned if it is not. */
-CENSUSAPI int32_t census_define_resource(const uint8_t *resource_pb,
- size_t resource_pb_size);
-
-/** Delete a resource created by census_define_resource(). */
-CENSUSAPI void census_delete_resource(int32_t resource_id);
-
-/** Determine the id of a resource, given its name. returns -1 if the resource
- does not exist. */
-CENSUSAPI int32_t census_resource_id(const char *name);
-
-/** A single value to be recorded comprises two parts: an ID for the particular
- * resource and the value to be recorded against it. */
-typedef struct {
- int32_t resource_id;
- double value;
-} census_value;
-
-/** Record new usage values against the given context. */
-CENSUSAPI void census_record_values(census_context *context,
- census_value *values, size_t nvalues);
-
#ifdef __cplusplus
}
#endif
diff --git a/include/grpc/compression.h b/include/grpc/compression.h
index 13a8dd66ad..a4f6a8faf2 100644
--- a/include/grpc/compression.h
+++ b/include/grpc/compression.h
@@ -30,60 +30,43 @@
extern "C" {
#endif
+/** Return if an algorithm is message compression algorithm. */
+GRPCAPI int grpc_compression_algorithm_is_message(
+ grpc_compression_algorithm algorithm);
+
+/** Return if an algorithm is stream compression algorithm. */
+GRPCAPI int grpc_compression_algorithm_is_stream(
+ grpc_compression_algorithm algorithm);
+
/** Parses the \a slice as a grpc_compression_algorithm instance and updating \a
* algorithm. Returns 1 upon success, 0 otherwise. */
GRPCAPI int grpc_compression_algorithm_parse(
- grpc_slice value, grpc_compression_algorithm *algorithm);
-
-/** Parses the \a slice as a grpc_stream_compression_algorithm instance and
- * updating \a algorithm. Returns 1 upon success, 0 otherwise. */
-int grpc_stream_compression_algorithm_parse(
- grpc_slice name, grpc_stream_compression_algorithm *algorithm);
+ grpc_slice value, grpc_compression_algorithm* algorithm);
/** Updates \a name with the encoding name corresponding to a valid \a
* algorithm. Note that \a name is statically allocated and must *not* be freed.
* Returns 1 upon success, 0 otherwise. */
GRPCAPI int grpc_compression_algorithm_name(
- grpc_compression_algorithm algorithm, const char **name);
-
-/** Updates \a name with the encoding name corresponding to a valid \a
- * algorithm. Note that \a name is statically allocated and must *not* be freed.
- * Returns 1 upon success, 0 otherwise. */
-GRPCAPI int grpc_stream_compression_algorithm_name(
- grpc_stream_compression_algorithm algorithm, const char **name);
+ grpc_compression_algorithm algorithm, const char** name);
/** Returns the compression algorithm corresponding to \a level for the
- * compression algorithms encoded in the \a accepted_encodings bitset.
- *
- * It abort()s for unknown levels. */
+ * compression algorithms encoded in the \a accepted_encodings bitset.*/
GRPCAPI grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level, uint32_t accepted_encodings);
-/** Returns the stream compression algorithm corresponding to \a level for the
- * compression algorithms encoded in the \a accepted_stream_encodings bitset.
- * It abort()s for unknown levels. */
-GRPCAPI grpc_stream_compression_algorithm
-grpc_stream_compression_algorithm_for_level(grpc_stream_compression_level level,
- uint32_t accepted_stream_encodings);
-
-GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts);
+GRPCAPI void grpc_compression_options_init(grpc_compression_options* opts);
/** Mark \a algorithm as enabled in \a opts. */
GRPCAPI void grpc_compression_options_enable_algorithm(
- grpc_compression_options *opts, grpc_compression_algorithm algorithm);
+ grpc_compression_options* opts, grpc_compression_algorithm algorithm);
/** Mark \a algorithm as disabled in \a opts. */
GRPCAPI void grpc_compression_options_disable_algorithm(
- grpc_compression_options *opts, grpc_compression_algorithm algorithm);
+ grpc_compression_options* opts, grpc_compression_algorithm algorithm);
/** Returns true if \a algorithm is marked as enabled in \a opts. */
GRPCAPI int grpc_compression_options_is_algorithm_enabled(
- const grpc_compression_options *opts, grpc_compression_algorithm algorithm);
-
-/** Returns true if \a algorithm is marked as enabled in \a opts. */
-GRPCAPI int grpc_compression_options_is_stream_compression_algorithm_enabled(
- const grpc_compression_options *opts,
- grpc_stream_compression_algorithm algorithm);
+ const grpc_compression_options* opts, grpc_compression_algorithm algorithm);
#ifdef __cplusplus
}
diff --git a/include/grpc/compression_ruby.h b/include/grpc/compression_ruby.h
new file mode 100644
index 0000000000..b063b2b529
--- /dev/null
+++ b/include/grpc/compression_ruby.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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 <grpc/impl/codegen/port_platform.h>
+
+#include <grpc/impl/codegen/compression_types.h>
+#include <grpc/slice.h>
+
+#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/include/grpc/fork.h b/include/grpc/fork.h
new file mode 100644
index 0000000000..ca45e1139c
--- /dev/null
+++ b/include/grpc/fork.h
@@ -0,0 +1,24 @@
+/*
+ *
+ * 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_FORK_H
+#define GRPC_FORK_H
+
+#include <grpc/impl/codegen/fork.h>
+
+#endif /* GRPC_FORK_H */
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index fab7d438aa..f083bc591e 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -40,11 +40,11 @@ extern "C" {
* functionality lives in grpc_security.h.
*/
-GRPCAPI void grpc_metadata_array_init(grpc_metadata_array *array);
-GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array *array);
+GRPCAPI void grpc_metadata_array_init(grpc_metadata_array* array);
+GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array* array);
-GRPCAPI void grpc_call_details_init(grpc_call_details *details);
-GRPCAPI void grpc_call_details_destroy(grpc_call_details *details);
+GRPCAPI void grpc_call_details_init(grpc_call_details* details);
+GRPCAPI void grpc_call_details_destroy(grpc_call_details* details);
/** Registers a plugin to be initialized and destroyed with the library.
@@ -73,31 +73,31 @@ GRPCAPI void grpc_init(void);
GRPCAPI void grpc_shutdown(void);
/** Return a string representing the current version of grpc */
-GRPCAPI const char *grpc_version_string(void);
+GRPCAPI const char* grpc_version_string(void);
/** Return a string specifying what the 'g' in gRPC stands for */
-GRPCAPI const char *grpc_g_stands_for(void);
+GRPCAPI const char* grpc_g_stands_for(void);
/** Returns the completion queue factory based on the attributes. MAY return a
NULL if no factory can be found */
-GRPCAPI const grpc_completion_queue_factory *
+GRPCAPI const grpc_completion_queue_factory*
grpc_completion_queue_factory_lookup(
- const grpc_completion_queue_attributes *attributes);
+ const grpc_completion_queue_attributes* attributes);
/** Helper function to create a completion queue with grpc_cq_completion_type
of GRPC_CQ_NEXT and grpc_cq_polling_type of GRPC_CQ_DEFAULT_POLLING */
-GRPCAPI grpc_completion_queue *grpc_completion_queue_create_for_next(
- void *reserved);
+GRPCAPI grpc_completion_queue* grpc_completion_queue_create_for_next(
+ void* reserved);
/** Helper function to create a completion queue with grpc_cq_completion_type
of GRPC_CQ_PLUCK and grpc_cq_polling_type of GRPC_CQ_DEFAULT_POLLING */
-GRPCAPI grpc_completion_queue *grpc_completion_queue_create_for_pluck(
- void *reserved);
+GRPCAPI grpc_completion_queue* grpc_completion_queue_create_for_pluck(
+ void* reserved);
/** Create a completion queue */
-GRPCAPI grpc_completion_queue *grpc_completion_queue_create(
- const grpc_completion_queue_factory *factory,
- const grpc_completion_queue_attributes *attributes, void *reserved);
+GRPCAPI grpc_completion_queue* grpc_completion_queue_create(
+ const grpc_completion_queue_factory* factory,
+ const grpc_completion_queue_attributes* attributes, void* reserved);
/** Blocks until an event is available, the completion queue is being shut down,
or deadline is reached.
@@ -107,9 +107,9 @@ GRPCAPI grpc_completion_queue *grpc_completion_queue_create(
Callers must not call grpc_completion_queue_next and
grpc_completion_queue_pluck simultaneously on the same completion queue. */
-GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
+GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue* cq,
gpr_timespec deadline,
- void *reserved);
+ void* reserved);
/** Blocks until an event with tag 'tag' is available, the completion queue is
being shutdown or deadline is reached.
@@ -122,9 +122,9 @@ GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
Completion queues support a maximum of GRPC_MAX_COMPLETION_QUEUE_PLUCKERS
concurrently executing plucks at any time. */
-GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq,
- void *tag, gpr_timespec deadline,
- void *reserved);
+GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq,
+ void* tag, gpr_timespec deadline,
+ void* reserved);
/** Maximum number of outstanding grpc_completion_queue_pluck executions per
completion queue */
@@ -137,14 +137,31 @@ GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq,
After calling this function applications should ensure that no
NEW work is added to be published on this completion queue. */
-GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq);
+GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue* cq);
/** Destroy a completion queue. The caller must ensure that the queue is
drained and no threads are executing grpc_completion_queue_next */
-GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq);
+GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue* cq);
+
+/*********** EXPERIMENTAL API ************/
+/** Initializes a thread local cache for \a cq.
+ * grpc_flush_cq_tls_cache() MUST be called on the same thread,
+ * with the same cq.
+ */
+GRPCAPI void grpc_completion_queue_thread_local_cache_init(
+ grpc_completion_queue* cq);
+
+/*********** EXPERIMENTAL API ************/
+/** Flushes the thread local cache for \a cq.
+ * Returns 1 if there was contents in the cache. If there was an event
+ * in \a cq tls cache, its tag is placed in tag, and ok is set to the
+ * event success.
+ */
+GRPCAPI int grpc_completion_queue_thread_local_cache_flush(
+ grpc_completion_queue* cq, void** tag, int* ok);
/** Create a completion queue alarm instance */
-GRPCAPI grpc_alarm *grpc_alarm_create(void *reserved);
+GRPCAPI grpc_alarm* grpc_alarm_create(void* reserved);
/** Set a completion queue alarm instance associated to \a cq.
*
@@ -152,25 +169,25 @@ GRPCAPI grpc_alarm *grpc_alarm_create(void *reserved);
* grpc_alarm_cancel), an event with tag \a tag will be added to \a cq. If the
* alarm expired, the event's success bit will be true, false otherwise (ie,
* upon cancellation). */
-GRPCAPI void grpc_alarm_set(grpc_alarm *alarm, grpc_completion_queue *cq,
- gpr_timespec deadline, void *tag, void *reserved);
+GRPCAPI void grpc_alarm_set(grpc_alarm* alarm, grpc_completion_queue* cq,
+ gpr_timespec deadline, void* tag, void* reserved);
/** Cancel a completion queue alarm. Calling this function over an alarm that
* has already fired has no effect. */
-GRPCAPI void grpc_alarm_cancel(grpc_alarm *alarm, void *reserved);
+GRPCAPI void grpc_alarm_cancel(grpc_alarm* alarm, void* reserved);
/** Destroy the given completion queue alarm, cancelling it in the process. */
-GRPCAPI void grpc_alarm_destroy(grpc_alarm *alarm, void *reserved);
+GRPCAPI void grpc_alarm_destroy(grpc_alarm* alarm, void* reserved);
/** Check the connectivity state of a channel. */
GRPCAPI grpc_connectivity_state grpc_channel_check_connectivity_state(
- grpc_channel *channel, int try_to_connect);
+ grpc_channel* channel, int try_to_connect);
/** Number of active "external connectivity state watchers" attached to a
* channel.
* Useful for testing. **/
GRPCAPI int grpc_channel_num_external_connectivity_watchers(
- grpc_channel *channel);
+ grpc_channel* channel);
/** Watch for a change in connectivity state.
Once the channel connectivity state is different from last_observed_state,
@@ -178,11 +195,11 @@ GRPCAPI int grpc_channel_num_external_connectivity_watchers(
If deadline expires BEFORE the state is changed, tag will be enqueued on cq
with success=0. */
GRPCAPI void grpc_channel_watch_connectivity_state(
- grpc_channel *channel, grpc_connectivity_state last_observed_state,
- gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
+ grpc_channel* channel, grpc_connectivity_state last_observed_state,
+ gpr_timespec deadline, grpc_completion_queue* cq, void* tag);
/** Check whether a grpc channel supports connectivity watcher */
-GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel *channel);
+GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel* channel);
/** Create a call given a grpc_channel, in order to call 'method'. All
completions are sent to 'completion_queue'. 'method' and 'host' need only
@@ -191,31 +208,31 @@ GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel *channel);
to propagate properties from the server call to this new client call,
depending on the value of \a propagation_mask (see propagation_bits.h for
possible values). */
-GRPCAPI grpc_call *grpc_channel_create_call(
- grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
- grpc_completion_queue *completion_queue, grpc_slice method,
- const grpc_slice *host, gpr_timespec deadline, void *reserved);
+GRPCAPI grpc_call* grpc_channel_create_call(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_completion_queue* completion_queue, grpc_slice method,
+ const grpc_slice* host, gpr_timespec deadline, void* reserved);
/** Ping the channels peer (load balanced channels will select one sub-channel
to ping); if the channel is not connected, posts a failed. */
-GRPCAPI void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
- void *tag, void *reserved);
+GRPCAPI void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
+ void* tag, void* reserved);
/** Pre-register a method/host pair on a channel. */
-GRPCAPI void *grpc_channel_register_call(grpc_channel *channel,
- const char *method, const char *host,
- void *reserved);
+GRPCAPI void* grpc_channel_register_call(grpc_channel* channel,
+ const char* method, const char* host,
+ void* reserved);
/** Create a call given a handle returned from grpc_channel_register_call.
\sa grpc_channel_create_call. */
-GRPCAPI grpc_call *grpc_channel_create_registered_call(
- grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
- grpc_completion_queue *completion_queue, void *registered_call_handle,
- gpr_timespec deadline, void *reserved);
+GRPCAPI grpc_call* grpc_channel_create_registered_call(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_completion_queue* completion_queue, void* registered_call_handle,
+ gpr_timespec deadline, void* reserved);
/** Allocate memory in the grpc_call arena: this memory is automatically
discarded at call completion */
-GRPCAPI void *grpc_call_arena_alloc(grpc_call *call, size_t size);
+GRPCAPI void* grpc_call_arena_alloc(grpc_call* call, size_t size);
/** Start a batch of operations defined in the array ops; when complete, post a
completion of type 'tag' to the completion queue bound to the call.
@@ -234,9 +251,9 @@ GRPCAPI void *grpc_call_arena_alloc(grpc_call *call, size_t size);
needs to be synchronized. As an optimization, you may synchronize batches
containing just send operations independently from batches containing just
receive operations. */
-GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call,
- const grpc_op *ops, size_t nops,
- void *tag, void *reserved);
+GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call* call,
+ const grpc_op* ops, size_t nops,
+ void* tag, void* reserved);
/** Returns a newly allocated string representing the endpoint to which this
call is communicating with. The string is in the uri format accepted by
@@ -246,43 +263,43 @@ GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call,
WARNING: this value is never authenticated or subject to any security
related code. It must not be used for any authentication related
functionality. Instead, use grpc_auth_context. */
-GRPCAPI char *grpc_call_get_peer(grpc_call *call);
+GRPCAPI char* grpc_call_get_peer(grpc_call* call);
struct census_context;
/** Set census context for a call; Must be called before first call to
grpc_call_start_batch(). */
-GRPCAPI void grpc_census_call_set_context(grpc_call *call,
- struct census_context *context);
+GRPCAPI void grpc_census_call_set_context(grpc_call* call,
+ struct census_context* context);
/** Retrieve the calls current census context. */
-GRPCAPI struct census_context *grpc_census_call_get_context(grpc_call *call);
+GRPCAPI struct census_context* grpc_census_call_get_context(grpc_call* call);
/** Return a newly allocated string representing the target a channel was
created for. */
-GRPCAPI char *grpc_channel_get_target(grpc_channel *channel);
+GRPCAPI char* grpc_channel_get_target(grpc_channel* channel);
/** Request info about the channel.
\a channel_info indicates what information is being requested and
how that information will be returned.
\a channel_info is owned by the caller. */
-GRPCAPI void grpc_channel_get_info(grpc_channel *channel,
- const grpc_channel_info *channel_info);
+GRPCAPI void grpc_channel_get_info(grpc_channel* channel,
+ const grpc_channel_info* channel_info);
/** Create a client channel to 'target'. Additional channel level configuration
MAY be provided by grpc_channel_args, though the expectation is that most
clients will want to simply pass NULL. See grpc_channel_args definition for
more on this. The data in 'args' need only live through the invocation of
this function. */
-GRPCAPI grpc_channel *grpc_insecure_channel_create(
- const char *target, const grpc_channel_args *args, void *reserved);
+GRPCAPI grpc_channel* grpc_insecure_channel_create(
+ const char* target, const grpc_channel_args* args, void* reserved);
/** Create a lame client: this client fails every operation attempted on it. */
-GRPCAPI grpc_channel *grpc_lame_client_channel_create(
- const char *target, grpc_status_code error_code, const char *error_message);
+GRPCAPI grpc_channel* grpc_lame_client_channel_create(
+ const char* target, grpc_status_code error_code, const char* error_message);
/** Close and destroy a grpc channel */
-GRPCAPI void grpc_channel_destroy(grpc_channel *channel);
+GRPCAPI void grpc_channel_destroy(grpc_channel* channel);
/** Error handling for grpc_call
Most grpc_call functions return a grpc_error. If the error is not GRPC_OK
@@ -295,7 +312,7 @@ GRPCAPI void grpc_channel_destroy(grpc_channel *channel);
THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status
are thread-safe, and can be called at any point before grpc_call_unref
is called.*/
-GRPCAPI grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
+GRPCAPI grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved);
/** Called by clients to cancel an RPC on the server.
Can be called multiple times, from any thread.
@@ -307,18 +324,18 @@ GRPCAPI grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
It doesn't need to be alive after the call to
grpc_call_cancel_with_status completes.
*/
-GRPCAPI grpc_call_error grpc_call_cancel_with_status(grpc_call *call,
+GRPCAPI grpc_call_error grpc_call_cancel_with_status(grpc_call* call,
grpc_status_code status,
- const char *description,
- void *reserved);
+ const char* description,
+ void* reserved);
/** Ref a call.
- THREAD SAFETY: grpc_call_unref is thread-compatible */
-GRPCAPI void grpc_call_ref(grpc_call *call);
+ THREAD SAFETY: grpc_call_ref is thread-compatible */
+GRPCAPI void grpc_call_ref(grpc_call* call);
/** Unref a call.
THREAD SAFETY: grpc_call_unref is thread-compatible */
-GRPCAPI void grpc_call_unref(grpc_call *call);
+GRPCAPI void grpc_call_unref(grpc_call* call);
/** Request notification of a new call.
Once a call is received, a notification tagged with \a tag_new is added to
@@ -329,10 +346,10 @@ GRPCAPI void grpc_call_unref(grpc_call *call);
Note that \a cq_for_notification must have been registered to the server via
\a grpc_server_register_completion_queue. */
GRPCAPI grpc_call_error grpc_server_request_call(
- grpc_server *server, grpc_call **call, grpc_call_details *details,
- grpc_metadata_array *request_metadata,
- grpc_completion_queue *cq_bound_to_call,
- grpc_completion_queue *cq_for_notification, void *tag_new);
+ grpc_server* server, grpc_call** call, grpc_call_details* details,
+ grpc_metadata_array* request_metadata,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification, void* tag_new);
/** How to handle payloads for a registered method */
typedef enum {
@@ -349,8 +366,8 @@ typedef enum {
registered_method (as returned by this function).
Must be called before grpc_server_start.
Returns NULL on failure. */
-GRPCAPI void *grpc_server_register_method(
- grpc_server *server, const char *method, const char *host,
+GRPCAPI void* grpc_server_register_method(
+ grpc_server* server, const char* method, const char* host,
grpc_server_register_method_payload_handling payload_handling,
uint32_t flags);
@@ -358,35 +375,35 @@ GRPCAPI void *grpc_server_register_method(
must have been registered to the server via
grpc_server_register_completion_queue. */
GRPCAPI grpc_call_error grpc_server_request_registered_call(
- grpc_server *server, void *registered_method, grpc_call **call,
- gpr_timespec *deadline, grpc_metadata_array *request_metadata,
- grpc_byte_buffer **optional_payload,
- grpc_completion_queue *cq_bound_to_call,
- grpc_completion_queue *cq_for_notification, void *tag_new);
+ grpc_server* server, void* registered_method, grpc_call** call,
+ gpr_timespec* deadline, grpc_metadata_array* request_metadata,
+ grpc_byte_buffer** optional_payload,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification, void* tag_new);
/** Create a server. Additional configuration for each incoming channel can
be specified with args. If no additional configuration is needed, args can
be NULL. See grpc_channel_args for more. The data in 'args' need only live
through the invocation of this function. */
-GRPCAPI grpc_server *grpc_server_create(const grpc_channel_args *args,
- void *reserved);
+GRPCAPI grpc_server* grpc_server_create(const grpc_channel_args* args,
+ void* reserved);
/** Register a completion queue with the server. Must be done for any
notification completion queue that is passed to grpc_server_request_*_call
and to grpc_server_shutdown_and_notify. Must be performed prior to
grpc_server_start. */
-GRPCAPI void grpc_server_register_completion_queue(grpc_server *server,
- grpc_completion_queue *cq,
- void *reserved);
+GRPCAPI void grpc_server_register_completion_queue(grpc_server* server,
+ grpc_completion_queue* cq,
+ void* reserved);
/** Add a HTTP2 over plaintext over tcp listener.
Returns bound port number on success, 0 on failure.
REQUIRES: server not started */
-GRPCAPI int grpc_server_add_insecure_http2_port(grpc_server *server,
- const char *addr);
+GRPCAPI int grpc_server_add_insecure_http2_port(grpc_server* server,
+ const char* addr);
/** Start a server - tells all listeners to start listening */
-GRPCAPI void grpc_server_start(grpc_server *server);
+GRPCAPI void grpc_server_start(grpc_server* server);
/** Begin shutting down a server.
After completion, no new calls or connections will be admitted.
@@ -395,19 +412,19 @@ GRPCAPI void grpc_server_start(grpc_server *server);
Shutdown is idempotent, and all tags will be notified at once if multiple
grpc_server_shutdown_and_notify calls are made. 'cq' must have been
registered to this server via grpc_server_register_completion_queue. */
-GRPCAPI void grpc_server_shutdown_and_notify(grpc_server *server,
- grpc_completion_queue *cq,
- void *tag);
+GRPCAPI void grpc_server_shutdown_and_notify(grpc_server* server,
+ grpc_completion_queue* cq,
+ void* tag);
/** Cancel all in-progress calls.
Only usable after shutdown. */
-GRPCAPI void grpc_server_cancel_all_calls(grpc_server *server);
+GRPCAPI void grpc_server_cancel_all_calls(grpc_server* server);
/** Destroy a server.
Shutdown must have completed beforehand (i.e. all tags generated by
grpc_server_shutdown_and_notify must have been received, and at least
one call to grpc_server_shutdown_and_notify must have been made). */
-GRPCAPI void grpc_server_destroy(grpc_server *server);
+GRPCAPI void grpc_server_destroy(grpc_server* server);
/** Enable or disable a tracer.
@@ -417,7 +434,7 @@ GRPCAPI void grpc_server_destroy(grpc_server *server);
Use of this function is not strictly thread-safe, but the
thread-safety issues raised by it should not be of concern. */
-GRPCAPI int grpc_tracer_set_enabled(const char *name, int enabled);
+GRPCAPI int grpc_tracer_set_enabled(const char* name, int enabled);
/** Check whether a metadata key is legal (will be accepted by core) */
GRPCAPI int grpc_header_key_is_legal(grpc_slice slice);
@@ -430,24 +447,24 @@ GRPCAPI int grpc_header_nonbin_value_is_legal(grpc_slice slice);
GRPCAPI int grpc_is_binary_header(grpc_slice slice);
/** Convert grpc_call_error values to a string */
-GRPCAPI const char *grpc_call_error_to_string(grpc_call_error error);
+GRPCAPI const char* grpc_call_error_to_string(grpc_call_error error);
/** Create a buffer pool */
-GRPCAPI grpc_resource_quota *grpc_resource_quota_create(const char *trace_name);
+GRPCAPI grpc_resource_quota* grpc_resource_quota_create(const char* trace_name);
/** Add a reference to a buffer pool */
-GRPCAPI void grpc_resource_quota_ref(grpc_resource_quota *resource_quota);
+GRPCAPI void grpc_resource_quota_ref(grpc_resource_quota* resource_quota);
/** Drop a reference to a buffer pool */
-GRPCAPI void grpc_resource_quota_unref(grpc_resource_quota *resource_quota);
+GRPCAPI void grpc_resource_quota_unref(grpc_resource_quota* resource_quota);
/** Update the size of a buffer pool */
-GRPCAPI void grpc_resource_quota_resize(grpc_resource_quota *resource_quota,
+GRPCAPI void grpc_resource_quota_resize(grpc_resource_quota* resource_quota,
size_t new_size);
/** Fetch a vtable for a grpc_channel_arg that points to a grpc_resource_quota
*/
-GRPCAPI const grpc_arg_pointer_vtable *grpc_resource_quota_arg_vtable(void);
+GRPCAPI const grpc_arg_pointer_vtable* grpc_resource_quota_arg_vtable(void);
#ifdef __cplusplus
}
diff --git a/include/grpc/grpc_cronet.h b/include/grpc/grpc_cronet.h
index 44330c6e11..127d5d038d 100644
--- a/include/grpc/grpc_cronet.h
+++ b/include/grpc/grpc_cronet.h
@@ -25,9 +25,9 @@
extern "C" {
#endif
-GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
- void *engine, const char *target, const grpc_channel_args *args,
- void *reserved);
+GRPCAPI grpc_channel* grpc_cronet_secure_channel_create(
+ void* engine, const char* target, const grpc_channel_args* args,
+ void* reserved);
#ifdef __cplusplus
}
diff --git a/include/grpc/grpc_posix.h b/include/grpc/grpc_posix.h
index c7429eaea0..fa7ebced3f 100644
--- a/include/grpc/grpc_posix.h
+++ b/include/grpc/grpc_posix.h
@@ -37,8 +37,8 @@ extern "C" {
/** Create a client channel to 'target' using file descriptor 'fd'. The 'target'
argument will be used to indicate the name for this channel. See the comment
for grpc_insecure_channel_create for description of 'args' argument. */
-GRPCAPI grpc_channel *grpc_insecure_channel_create_from_fd(
- const char *target, int fd, const grpc_channel_args *args);
+GRPCAPI grpc_channel* grpc_insecure_channel_create_from_fd(
+ const char* target, int fd, const grpc_channel_args* args);
/** Add the connected communication channel based on file descriptor 'fd' to the
'server'. The 'fd' must be an open file descriptor corresponding to a
@@ -48,8 +48,8 @@ GRPCAPI grpc_channel *grpc_insecure_channel_create_from_fd(
The 'reserved' pointer MUST be NULL.
*/
-GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
- void *reserved, int fd);
+GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
+ void* reserved, int fd);
/** GRPC Core POSIX library may internally use signals to optimize some work.
The library uses (SIGRTMIN + 6) signal by default. Use this API to instruct
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index 2005e25df2..bae07ac309 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -32,51 +32,51 @@ extern "C" {
typedef struct grpc_auth_context grpc_auth_context;
typedef struct grpc_auth_property_iterator {
- const grpc_auth_context *ctx;
+ const grpc_auth_context* ctx;
size_t index;
- const char *name;
+ const char* name;
} grpc_auth_property_iterator;
/** value, if not NULL, is guaranteed to be NULL terminated. */
typedef struct grpc_auth_property {
- char *name;
- char *value;
+ char* name;
+ char* value;
size_t value_length;
} grpc_auth_property;
/** Returns NULL when the iterator is at the end. */
-GRPCAPI const grpc_auth_property *grpc_auth_property_iterator_next(
- grpc_auth_property_iterator *it);
+GRPCAPI const grpc_auth_property* grpc_auth_property_iterator_next(
+ grpc_auth_property_iterator* it);
/** Iterates over the auth context. */
GRPCAPI grpc_auth_property_iterator
-grpc_auth_context_property_iterator(const grpc_auth_context *ctx);
+grpc_auth_context_property_iterator(const grpc_auth_context* ctx);
/** Gets the peer identity. Returns an empty iterator (first _next will return
NULL) if the peer is not authenticated. */
GRPCAPI grpc_auth_property_iterator
-grpc_auth_context_peer_identity(const grpc_auth_context *ctx);
+grpc_auth_context_peer_identity(const grpc_auth_context* ctx);
/** Finds a property in the context. May return an empty iterator (first _next
will return NULL) if no property with this name was found in the context. */
GRPCAPI grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
- const grpc_auth_context *ctx, const char *name);
+ const grpc_auth_context* ctx, const char* name);
/** Gets the name of the property that indicates the peer identity. Will return
NULL if the peer is not authenticated. */
-GRPCAPI const char *grpc_auth_context_peer_identity_property_name(
- const grpc_auth_context *ctx);
+GRPCAPI const char* grpc_auth_context_peer_identity_property_name(
+ const grpc_auth_context* ctx);
/** Returns 1 if the peer is authenticated, 0 otherwise. */
GRPCAPI int grpc_auth_context_peer_is_authenticated(
- const grpc_auth_context *ctx);
+ const grpc_auth_context* ctx);
/** Gets the auth context from the call. Caller needs to call
grpc_auth_context_release on the returned context. */
-GRPCAPI grpc_auth_context *grpc_call_auth_context(grpc_call *call);
+GRPCAPI grpc_auth_context* grpc_call_auth_context(grpc_call* call);
/** Releases the auth context returned from grpc_call_auth_context. */
-GRPCAPI void grpc_auth_context_release(grpc_auth_context *context);
+GRPCAPI void grpc_auth_context_release(grpc_auth_context* context);
/** --
The following auth context methods should only be called by a server metadata
@@ -84,19 +84,19 @@ GRPCAPI void grpc_auth_context_release(grpc_auth_context *context);
-- */
/** Add a property. */
-GRPCAPI void grpc_auth_context_add_property(grpc_auth_context *ctx,
- const char *name, const char *value,
+GRPCAPI void grpc_auth_context_add_property(grpc_auth_context* ctx,
+ const char* name, const char* value,
size_t value_length);
/** Add a C string property. */
-GRPCAPI void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
- const char *name,
- const char *value);
+GRPCAPI void grpc_auth_context_add_cstring_property(grpc_auth_context* ctx,
+ const char* name,
+ const char* value);
/** Sets the property name. Returns 1 if successful or 0 in case of failure
(which means that no property with this name exists). */
GRPCAPI int grpc_auth_context_set_peer_identity_property_name(
- grpc_auth_context *ctx, const char *name);
+ grpc_auth_context* ctx, const char* name);
/** --- grpc_channel_credentials object. ---
@@ -107,12 +107,12 @@ typedef struct grpc_channel_credentials grpc_channel_credentials;
/** Releases a channel credentials object.
The creator of the credentials object is responsible for its release. */
-GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds);
+GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials* creds);
/** Creates default credentials to connect to a google gRPC service.
WARNING: Do NOT use this credentials to connect to a non-google service as
this could result in an oauth2 token leak. */
-GRPCAPI grpc_channel_credentials *grpc_google_default_credentials_create(void);
+GRPCAPI grpc_channel_credentials* grpc_google_default_credentials_create(void);
/** Callback for getting the SSL roots override from the application.
In case of success, *pem_roots_certs must be set to a NULL terminated string
@@ -121,7 +121,7 @@ GRPCAPI grpc_channel_credentials *grpc_google_default_credentials_create(void);
If this function fails and GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is
set to a valid path, it will override the roots specified this func */
typedef grpc_ssl_roots_override_result (*grpc_ssl_roots_override_callback)(
- char **pem_root_certs);
+ char** pem_root_certs);
/** Setup a callback to override the default TLS/SSL roots.
This function is not thread-safe and must be called at initialization time
@@ -135,11 +135,11 @@ GRPCAPI void grpc_set_ssl_roots_override_callback(
typedef struct {
/** private_key is the NULL-terminated string containing the PEM encoding of
the client's private key. */
- const char *private_key;
+ const char* private_key;
/** cert_chain is the NULL-terminated string containing the PEM encoding of
the client's certificate chain. */
- const char *cert_chain;
+ const char* cert_chain;
} grpc_ssl_pem_key_cert_pair;
/** Creates an SSL credentials object.
@@ -153,9 +153,9 @@ typedef struct {
- pem_key_cert_pair is a pointer on the object containing client's private
key and certificate chain. This parameter can be NULL if the client does
not have such a key/cert pair. */
-GRPCAPI grpc_channel_credentials *grpc_ssl_credentials_create(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
- void *reserved);
+GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
+ void* reserved);
/** --- grpc_call_credentials object.
@@ -167,35 +167,35 @@ typedef struct grpc_call_credentials grpc_call_credentials;
/** Releases a call credentials object.
The creator of the credentials object is responsible for its release. */
-GRPCAPI void grpc_call_credentials_release(grpc_call_credentials *creds);
+GRPCAPI void grpc_call_credentials_release(grpc_call_credentials* creds);
/** Creates a composite channel credentials object. */
-GRPCAPI grpc_channel_credentials *grpc_composite_channel_credentials_create(
- grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds,
- void *reserved);
+GRPCAPI grpc_channel_credentials* grpc_composite_channel_credentials_create(
+ grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds,
+ void* reserved);
/** Creates a composite call credentials object. */
-GRPCAPI grpc_call_credentials *grpc_composite_call_credentials_create(
- grpc_call_credentials *creds1, grpc_call_credentials *creds2,
- void *reserved);
+GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create(
+ grpc_call_credentials* creds1, grpc_call_credentials* creds2,
+ void* reserved);
/** Creates a compute engine credentials object for connecting to Google.
WARNING: Do NOT use this credentials to connect to a non-google service as
this could result in an oauth2 token leak. */
-GRPCAPI grpc_call_credentials *grpc_google_compute_engine_credentials_create(
- void *reserved);
+GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create(
+ void* reserved);
-GRPCAPI gpr_timespec grpc_max_auth_token_lifetime();
+GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(void);
/** Creates a JWT credentials object. May return NULL if the input is invalid.
- json_key is the JSON key string containing the client's private key.
- token_lifetime is the lifetime of each Json Web Token (JWT) created with
this credentials. It should not exceed grpc_max_auth_token_lifetime or
will be cropped to this value. */
-GRPCAPI grpc_call_credentials *
-grpc_service_account_jwt_access_credentials_create(const char *json_key,
+GRPCAPI grpc_call_credentials*
+grpc_service_account_jwt_access_credentials_create(const char* json_key,
gpr_timespec token_lifetime,
- void *reserved);
+ void* reserved);
/** Creates an Oauth2 Refresh Token credentials object for connecting to Google.
May return NULL if the input is invalid.
@@ -203,18 +203,18 @@ grpc_service_account_jwt_access_credentials_create(const char *json_key,
this could result in an oauth2 token leak.
- json_refresh_token is the JSON string containing the refresh token itself
along with a client_id and client_secret. */
-GRPCAPI grpc_call_credentials *grpc_google_refresh_token_credentials_create(
- const char *json_refresh_token, void *reserved);
+GRPCAPI grpc_call_credentials* grpc_google_refresh_token_credentials_create(
+ const char* json_refresh_token, void* reserved);
/** Creates an Oauth2 Access Token credentials with an access token that was
aquired by an out of band mechanism. */
-GRPCAPI grpc_call_credentials *grpc_access_token_credentials_create(
- const char *access_token, void *reserved);
+GRPCAPI grpc_call_credentials* grpc_access_token_credentials_create(
+ const char* access_token, void* reserved);
/** Creates an IAM credentials object for connecting to Google. */
-GRPCAPI grpc_call_credentials *grpc_google_iam_credentials_create(
- const char *authorization_token, const char *authority_selector,
- void *reserved);
+GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create(
+ const char* authorization_token, const char* authority_selector,
+ void* reserved);
/** Callback function to be called by the metadata credentials plugin
implementation when the metadata is ready.
@@ -228,61 +228,82 @@ GRPCAPI grpc_call_credentials *grpc_google_iam_credentials_create(
- error_details contains details about the error if any. In case of success
it should be NULL and will be otherwise ignored. */
typedef void (*grpc_credentials_plugin_metadata_cb)(
- void *user_data, const grpc_metadata *creds_md, size_t num_creds_md,
- grpc_status_code status, const char *error_details);
+ void* user_data, const grpc_metadata* creds_md, size_t num_creds_md,
+ grpc_status_code status, const char* error_details);
/** Context that can be used by metadata credentials plugin in order to create
auth related metadata. */
typedef struct {
/** The fully qualifed service url. */
- const char *service_url;
+ const char* service_url;
/** The method name of the RPC being called (not fully qualified).
The fully qualified method name can be built from the service_url:
full_qualified_method_name = ctx->service_url + '/' + ctx->method_name. */
- const char *method_name;
+ const char* method_name;
/** The auth_context of the channel which gives the server's identity. */
- const grpc_auth_context *channel_auth_context;
+ const grpc_auth_context* channel_auth_context;
/** Reserved for future use. */
- void *reserved;
+ void* reserved;
} grpc_auth_metadata_context;
+/** Maximum number of metadata entries returnable by a credentials plugin via
+ a synchronous return. */
+#define GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX 4
+
/** grpc_metadata_credentials plugin is an API user provided structure used to
create grpc_credentials objects that can be set on a channel (composed) or
a call. See grpc_credentials_metadata_create_from_plugin below.
The grpc client stack will call the get_metadata method of the plugin for
every call in scope for the credentials created from it. */
typedef struct {
- /** The implementation of this method has to be non-blocking.
- - context is the information that can be used by the plugin to create auth
- metadata.
- - cb is the callback that needs to be called when the metadata is ready.
- - user_data needs to be passed as the first parameter of the callback. */
- void (*get_metadata)(void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data);
+ /** The implementation of this method has to be non-blocking, but can
+ be performed synchronously or asynchronously.
+
+ If processing occurs synchronously, returns non-zero and populates
+ creds_md, num_creds_md, status, and error_details. In this case,
+ the caller takes ownership of the entries in creds_md and of
+ error_details. Note that if the plugin needs to return more than
+ GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX entries in creds_md, it must
+ return asynchronously.
+
+ If processing occurs asynchronously, returns zero and invokes \a cb
+ when processing is completed. \a user_data will be passed as the
+ first parameter of the callback. NOTE: \a cb MUST be invoked in a
+ different thread, not from the thread in which \a get_metadata() is
+ invoked.
+
+ \a context is the information that can be used by the plugin to create
+ auth metadata. */
+ int (*get_metadata)(
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details);
/** Destroys the plugin state. */
- void (*destroy)(void *state);
+ void (*destroy)(void* state);
/** State that will be set as the first parameter of the methods above. */
- void *state;
+ void* state;
/** Type of credentials that this plugin is implementing. */
- const char *type;
+ const char* type;
} grpc_metadata_credentials_plugin;
/** Creates a credentials object from a plugin. */
-GRPCAPI grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
- grpc_metadata_credentials_plugin plugin, void *reserved);
+GRPCAPI grpc_call_credentials* grpc_metadata_credentials_create_from_plugin(
+ grpc_metadata_credentials_plugin plugin, void* reserved);
/** --- Secure channel creation. --- */
/** Creates a secure channel using the passed-in credentials. */
-GRPCAPI grpc_channel *grpc_secure_channel_create(
- grpc_channel_credentials *creds, const char *target,
- const grpc_channel_args *args, void *reserved);
+GRPCAPI grpc_channel* grpc_secure_channel_create(
+ grpc_channel_credentials* creds, const char* target,
+ const grpc_channel_args* args, void* reserved);
/** --- grpc_server_credentials object. ---
@@ -293,7 +314,44 @@ typedef struct grpc_server_credentials grpc_server_credentials;
/** Releases a server_credentials object.
The creator of the server_credentials object is responsible for its release.
*/
-GRPCAPI void grpc_server_credentials_release(grpc_server_credentials *creds);
+GRPCAPI void grpc_server_credentials_release(grpc_server_credentials* creds);
+
+/** Server certificate config object holds the server's public certificates and
+ associated private keys, as well as any CA certificates needed for client
+ certificate validation (if applicable). Create using
+ grpc_ssl_server_certificate_config_create(). */
+typedef struct grpc_ssl_server_certificate_config
+ grpc_ssl_server_certificate_config;
+
+/** Creates a grpc_ssl_server_certificate_config object.
+ - pem_roots_cert is the NULL-terminated string containing the PEM encoding of
+ the client root certificates. This parameter may be NULL if the server does
+ not want the client to be authenticated with SSL.
+ - pem_key_cert_pairs is an array private key / certificate chains of the
+ server. This parameter cannot be NULL.
+ - num_key_cert_pairs indicates the number of items in the private_key_files
+ and cert_chain_files parameters. It must be at least 1.
+ - It is the caller's responsibility to free this object via
+ grpc_ssl_server_certificate_config_destroy(). */
+GRPCAPI grpc_ssl_server_certificate_config*
+grpc_ssl_server_certificate_config_create(
+ const char* pem_root_certs,
+ const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs);
+
+/** Destroys a grpc_ssl_server_certificate_config object. */
+GRPCAPI void grpc_ssl_server_certificate_config_destroy(
+ grpc_ssl_server_certificate_config* config);
+
+/** Callback to retrieve updated SSL server certificates, private keys, and
+ trusted CAs (for client authentication).
+ - user_data parameter, if not NULL, contains opaque data to be used by the
+ callback.
+ - Use grpc_ssl_server_certificate_config_create to create the config.
+ - The caller assumes ownership of the config. */
+typedef grpc_ssl_certificate_config_reload_status (
+ *grpc_ssl_server_certificate_config_callback)(
+ void* user_data, grpc_ssl_server_certificate_config** config);
/** Deprecated in favor of grpc_ssl_server_credentials_create_ex.
Creates an SSL server_credentials object.
@@ -307,34 +365,69 @@ GRPCAPI void grpc_server_credentials_release(grpc_server_credentials *creds);
- force_client_auth, if set to non-zero will force the client to authenticate
with an SSL cert. Note that this option is ignored if pem_root_certs is
NULL. */
-GRPCAPI grpc_server_credentials *grpc_ssl_server_credentials_create(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, int force_client_auth, void *reserved);
+GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs, int force_client_auth, void* reserved);
-/** Same as grpc_ssl_server_credentials_create method except uses
+/** Deprecated in favor of grpc_ssl_server_credentials_create_with_options.
+ Same as grpc_ssl_server_credentials_create method except uses
grpc_ssl_client_certificate_request_type enum to support more ways to
authenticate client cerificates.*/
-GRPCAPI grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
+GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_ex(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
size_t num_key_cert_pairs,
grpc_ssl_client_certificate_request_type client_certificate_request,
- void *reserved);
+ void* reserved);
+
+typedef struct grpc_ssl_server_credentials_options
+ grpc_ssl_server_credentials_options;
+
+/** Creates an options object using a certificate config. Use this method when
+ the certificates and keys of the SSL server will not change during the
+ server's lifetime.
+ - Takes ownership of the certificate_config parameter. */
+GRPCAPI grpc_ssl_server_credentials_options*
+grpc_ssl_server_credentials_create_options_using_config(
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_certificate_config* certificate_config);
+
+/** Creates an options object using a certificate config fetcher. Use this
+ method to reload the certificates and keys of the SSL server without
+ interrupting the operation of the server. Initial certificate config will be
+ fetched during server initialization.
+ - user_data parameter, if not NULL, contains opaque data which will be passed
+ to the fetcher (see definition of
+ grpc_ssl_server_certificate_config_callback). */
+GRPCAPI grpc_ssl_server_credentials_options*
+grpc_ssl_server_credentials_create_options_using_config_fetcher(
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_certificate_config_callback cb, void* user_data);
+
+/** Destroys a grpc_ssl_server_credentials_options object. */
+GRPCAPI void grpc_ssl_server_credentials_options_destroy(
+ grpc_ssl_server_credentials_options* options);
+
+/** Creates an SSL server_credentials object using the provided options struct.
+ - Takes ownership of the options parameter. */
+GRPCAPI grpc_server_credentials*
+grpc_ssl_server_credentials_create_with_options(
+ grpc_ssl_server_credentials_options* options);
/** --- Server-side secure ports. --- */
/** Add a HTTP2 over an encrypted link over tcp listener.
Returns bound port number on success, 0 on failure.
REQUIRES: server not started */
-GRPCAPI int grpc_server_add_secure_http2_port(grpc_server *server,
- const char *addr,
- grpc_server_credentials *creds);
+GRPCAPI int grpc_server_add_secure_http2_port(grpc_server* server,
+ const char* addr,
+ grpc_server_credentials* creds);
/** --- Call specific credentials. --- */
/** Sets a credentials to a call. Can only be called on the client side before
grpc_call_start_batch. */
-GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call *call,
- grpc_call_credentials *creds);
+GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call* call,
+ grpc_call_credentials* creds);
/** --- Auth Metadata Processing --- */
@@ -348,9 +441,9 @@ GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call *call,
GRPC_STATUS PERMISSION_DENIED in case of an authorization failure.
- error_details gives details about the error. May be NULL. */
typedef void (*grpc_process_auth_metadata_done_cb)(
- void *user_data, const grpc_metadata *consumed_md, size_t num_consumed_md,
- const grpc_metadata *response_md, size_t num_response_md,
- grpc_status_code status, const char *error_details);
+ void* user_data, const grpc_metadata* consumed_md, size_t num_consumed_md,
+ const grpc_metadata* response_md, size_t num_response_md,
+ grpc_status_code status, const char* error_details);
/** Pluggable server-side metadata processor object. */
typedef struct {
@@ -358,15 +451,15 @@ typedef struct {
channel peer and it is the job of the process function to augment it with
properties derived from the passed-in metadata.
The lifetime of these objects is guaranteed until cb is invoked. */
- void (*process)(void *state, grpc_auth_context *context,
- const grpc_metadata *md, size_t num_md,
- grpc_process_auth_metadata_done_cb cb, void *user_data);
- void (*destroy)(void *state);
- void *state;
+ void (*process)(void* state, grpc_auth_context* context,
+ const grpc_metadata* md, size_t num_md,
+ grpc_process_auth_metadata_done_cb cb, void* user_data);
+ void (*destroy)(void* state);
+ void* state;
} grpc_auth_metadata_processor;
GRPCAPI void grpc_server_credentials_set_auth_metadata_processor(
- grpc_server_credentials *creds, grpc_auth_metadata_processor processor);
+ grpc_server_credentials* creds, grpc_auth_metadata_processor processor);
#ifdef __cplusplus
}
diff --git a/include/grpc/grpc_security_constants.h b/include/grpc/grpc_security_constants.h
index fde300dfb1..60e167eb88 100644
--- a/include/grpc/grpc_security_constants.h
+++ b/include/grpc/grpc_security_constants.h
@@ -48,6 +48,13 @@ typedef enum {
GRPC_SSL_ROOTS_OVERRIDE_FAIL
} grpc_ssl_roots_override_result;
+/** Callback results for dynamically loading a SSL certificate config. */
+typedef enum {
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED,
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW,
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL
+} grpc_ssl_certificate_config_reload_status;
+
typedef enum {
/** Server does not request client certificate. A client can present a self
signed or signed certificates if it wishes to do so and they would be
diff --git a/include/grpc/impl/codegen/atm.h b/include/grpc/impl/codegen/atm.h
index 764bee5272..00d83f0604 100644
--- a/include/grpc/impl/codegen/atm.h
+++ b/include/grpc/impl/codegen/atm.h
@@ -79,9 +79,17 @@
#error could not determine platform for atm
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/** Adds \a delta to \a *value, clamping the result to the range specified
by \a min and \a max. Returns the new value. */
-gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm *value, gpr_atm delta,
+gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm* value, gpr_atm delta,
gpr_atm min, gpr_atm max);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_IMPL_CODEGEN_ATM_H */
diff --git a/include/grpc/impl/codegen/atm_gcc_atomic.h b/include/grpc/impl/codegen/atm_gcc_atomic.h
index 1793ec22b8..5879708548 100644
--- a/include/grpc/impl/codegen/atm_gcc_atomic.h
+++ b/include/grpc/impl/codegen/atm_gcc_atomic.h
@@ -23,8 +23,13 @@
__atomic_* interface. */
#include <grpc/impl/codegen/port_platform.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef intptr_t gpr_atm;
#define GPR_ATM_MAX INTPTR_MAX
+#define GPR_ATM_MIN INTPTR_MIN
#ifdef GPR_LOW_LEVEL_COUNTERS
extern gpr_atm gpr_counter_atm_cas;
@@ -56,22 +61,22 @@ extern gpr_atm gpr_counter_atm_add;
GPR_ATM_INC_ADD_THEN( \
__atomic_fetch_add((p), (intptr_t)(delta), __ATOMIC_ACQ_REL))
-static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_no_barrier_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n(
p, &o, n, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED));
}
-static __inline int gpr_atm_acq_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_acq_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n(
p, &o, n, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED));
}
-static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_rel_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n(
p, &o, n, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED));
}
-static __inline int gpr_atm_full_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_full_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n(
p, &o, n, 0, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED));
}
@@ -79,4 +84,8 @@ static __inline int gpr_atm_full_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
#define gpr_atm_full_xchg(p, n) \
GPR_ATM_INC_CAS_THEN(__atomic_exchange_n((p), (n), __ATOMIC_ACQ_REL))
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_IMPL_CODEGEN_ATM_GCC_ATOMIC_H */
diff --git a/include/grpc/impl/codegen/atm_gcc_sync.h b/include/grpc/impl/codegen/atm_gcc_sync.h
index 27ae0f63d5..c0010a3469 100644
--- a/include/grpc/impl/codegen/atm_gcc_sync.h
+++ b/include/grpc/impl/codegen/atm_gcc_sync.h
@@ -25,6 +25,7 @@
typedef intptr_t gpr_atm;
#define GPR_ATM_MAX INTPTR_MAX
+#define GPR_ATM_MIN INTPTR_MIN
#define GPR_ATM_COMPILE_BARRIER_() __asm__ __volatile__("" : : : "memory")
@@ -37,24 +38,24 @@ typedef intptr_t gpr_atm;
#define gpr_atm_full_barrier() (__sync_synchronize())
-static __inline gpr_atm gpr_atm_acq_load(const gpr_atm *p) {
+static __inline gpr_atm gpr_atm_acq_load(const gpr_atm* p) {
gpr_atm value = *p;
GPR_ATM_LS_BARRIER_();
return value;
}
-static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm *p) {
+static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm* p) {
gpr_atm value = *p;
GPR_ATM_COMPILE_BARRIER_();
return value;
}
-static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {
+static __inline void gpr_atm_rel_store(gpr_atm* p, gpr_atm value) {
GPR_ATM_LS_BARRIER_();
*p = value;
}
-static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
+static __inline void gpr_atm_no_barrier_store(gpr_atm* p, gpr_atm value) {
GPR_ATM_COMPILE_BARRIER_();
*p = value;
}
@@ -71,7 +72,7 @@ static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
#define gpr_atm_rel_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n))
#define gpr_atm_full_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n))
-static __inline gpr_atm gpr_atm_full_xchg(gpr_atm *p, gpr_atm n) {
+static __inline gpr_atm gpr_atm_full_xchg(gpr_atm* p, gpr_atm n) {
gpr_atm cur;
do {
cur = gpr_atm_acq_load(p);
diff --git a/include/grpc/impl/codegen/atm_windows.h b/include/grpc/impl/codegen/atm_windows.h
index dfcaa4cc37..f6b27e5df7 100644
--- a/include/grpc/impl/codegen/atm_windows.h
+++ b/include/grpc/impl/codegen/atm_windows.h
@@ -24,73 +24,74 @@
typedef intptr_t gpr_atm;
#define GPR_ATM_MAX INTPTR_MAX
+#define GPR_ATM_MIN INTPTR_MIN
#define gpr_atm_full_barrier MemoryBarrier
-static __inline gpr_atm gpr_atm_acq_load(const gpr_atm *p) {
+static __inline gpr_atm gpr_atm_acq_load(const gpr_atm* p) {
gpr_atm result = *p;
gpr_atm_full_barrier();
return result;
}
-static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm *p) {
+static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm* p) {
/* TODO(dklempner): Can we implement something better here? */
return gpr_atm_acq_load(p);
}
-static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {
+static __inline void gpr_atm_rel_store(gpr_atm* p, gpr_atm value) {
gpr_atm_full_barrier();
*p = value;
}
-static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
+static __inline void gpr_atm_no_barrier_store(gpr_atm* p, gpr_atm value) {
/* TODO(ctiller): Can we implement something better here? */
gpr_atm_rel_store(p, value);
}
-static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_no_barrier_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
/** InterlockedCompareExchangePointerNoFence() not available on vista or
windows7 */
#ifdef GPR_ARCH_64
return o == (gpr_atm)InterlockedCompareExchangeAcquire64(
- (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o);
+ (volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *)p,
+ return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG*)p,
(LONG)n, (LONG)o);
#endif
}
-static __inline int gpr_atm_acq_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_acq_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
#ifdef GPR_ARCH_64
return o == (gpr_atm)InterlockedCompareExchangeAcquire64(
- (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o);
+ (volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *)p,
+ return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG*)p,
(LONG)n, (LONG)o);
#endif
}
-static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_rel_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
#ifdef GPR_ARCH_64
return o == (gpr_atm)InterlockedCompareExchangeRelease64(
- (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o);
+ (volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG *)p,
+ return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG*)p,
(LONG)n, (LONG)o);
#endif
}
-static __inline int gpr_atm_full_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
+static __inline int gpr_atm_full_cas(gpr_atm* p, gpr_atm o, gpr_atm n) {
#ifdef GPR_ARCH_64
- return o == (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *)p,
+ return o == (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG*)p,
(LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchange((volatile LONG *)p, (LONG)n,
+ return o == (gpr_atm)InterlockedCompareExchange((volatile LONG*)p, (LONG)n,
(LONG)o);
#endif
}
-static __inline gpr_atm gpr_atm_no_barrier_fetch_add(gpr_atm *p,
+static __inline gpr_atm gpr_atm_no_barrier_fetch_add(gpr_atm* p,
gpr_atm delta) {
/** Use the CAS operation to get pointer-sized fetch and add */
gpr_atm old;
@@ -100,26 +101,26 @@ static __inline gpr_atm gpr_atm_no_barrier_fetch_add(gpr_atm *p,
return old;
}
-static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm *p, gpr_atm delta) {
+static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm* p, gpr_atm delta) {
/** Use a CAS operation to get pointer-sized fetch and add */
gpr_atm old;
#ifdef GPR_ARCH_64
do {
old = *p;
- } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *)p,
+ } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG*)p,
(LONGLONG)old + delta,
(LONGLONG)old));
#else
do {
old = *p;
} while (old != (gpr_atm)InterlockedCompareExchange(
- (volatile LONG *)p, (LONG)old + delta, (LONG)old));
+ (volatile LONG*)p, (LONG)old + delta, (LONG)old));
#endif
return old;
}
-static __inline gpr_atm gpr_atm_full_xchg(gpr_atm *p, gpr_atm n) {
- return (gpr_atm)InterlockedExchangePointer((PVOID *)p, (PVOID)n);
+static __inline gpr_atm gpr_atm_full_xchg(gpr_atm* p, gpr_atm n) {
+ return (gpr_atm)InterlockedExchangePointer((PVOID*)p, (PVOID)n);
}
#endif /* GRPC_IMPL_CODEGEN_ATM_WINDOWS_H */
diff --git a/include/grpc/impl/codegen/byte_buffer.h b/include/grpc/impl/codegen/byte_buffer.h
index fc33305713..f8dfbd1d7d 100644
--- a/include/grpc/impl/codegen/byte_buffer.h
+++ b/include/grpc/impl/codegen/byte_buffer.h
@@ -29,7 +29,7 @@ extern "C" {
*
* Increases the reference count for all \a slices processed. The user is
* responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
-GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices,
+GRPCAPI grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slices,
size_t nslices);
/** Returns a *compressed* RAW byte buffer instance over the given slices (up to
@@ -38,20 +38,20 @@ GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices,
*
* Increases the reference count for all \a slices processed. The user is
* responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
-GRPCAPI grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
- grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression);
+GRPCAPI grpc_byte_buffer* grpc_raw_compressed_byte_buffer_create(
+ grpc_slice* slices, size_t nslices, grpc_compression_algorithm compression);
/** Copies input byte buffer \a bb.
*
* Increases the reference count of all the source slices. The user is
* responsible for calling grpc_byte_buffer_destroy over the returned copy. */
-GRPCAPI grpc_byte_buffer *grpc_byte_buffer_copy(grpc_byte_buffer *bb);
+GRPCAPI grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb);
/** Returns the size of the given byte buffer, in bytes. */
-GRPCAPI size_t grpc_byte_buffer_length(grpc_byte_buffer *bb);
+GRPCAPI size_t grpc_byte_buffer_length(grpc_byte_buffer* bb);
/** Destroys \a byte_buffer deallocating all its memory. */
-GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer);
+GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer* byte_buffer);
/** Reader for byte buffers. Iterates over slices in the byte buffer */
struct grpc_byte_buffer_reader;
@@ -59,25 +59,25 @@ typedef struct grpc_byte_buffer_reader grpc_byte_buffer_reader;
/** Initialize \a reader to read over \a buffer.
* Returns 1 upon success, 0 otherwise. */
-GRPCAPI int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
- grpc_byte_buffer *buffer);
+GRPCAPI int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
+ grpc_byte_buffer* buffer);
/** Cleanup and destroy \a reader */
-GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader);
+GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader);
/** Updates \a slice with the next piece of data from from \a reader and returns
* 1. Returns 0 at the end of the stream. Caller is responsible for calling
* grpc_slice_unref on the result. */
-GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
- grpc_slice *slice);
+GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
+ grpc_slice* slice);
/** Merge all data from \a reader into single slice */
GRPCAPI grpc_slice
-grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader);
+grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader);
/** Returns a RAW byte buffer instance from the output of \a reader. */
-GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(
- grpc_byte_buffer_reader *reader);
+GRPCAPI grpc_byte_buffer* grpc_raw_byte_buffer_from_reader(
+ grpc_byte_buffer_reader* reader);
#ifdef __cplusplus
}
diff --git a/include/grpc/impl/codegen/byte_buffer_reader.h b/include/grpc/impl/codegen/byte_buffer_reader.h
index dc0f15496f..e06e19558a 100644
--- a/include/grpc/impl/codegen/byte_buffer_reader.h
+++ b/include/grpc/impl/codegen/byte_buffer_reader.h
@@ -26,8 +26,8 @@ extern "C" {
struct grpc_byte_buffer;
struct grpc_byte_buffer_reader {
- struct grpc_byte_buffer *buffer_in;
- struct grpc_byte_buffer *buffer_out;
+ struct grpc_byte_buffer* buffer_in;
+ struct grpc_byte_buffer* buffer_out;
/** Different current objects correspond to different types of byte buffers */
union grpc_byte_buffer_reader_current {
/** Index into a slice buffer's array of slices */
diff --git a/include/grpc/impl/codegen/compression_types.h b/include/grpc/impl/codegen/compression_types.h
index 4419e2a447..ddc667fcdb 100644
--- a/include/grpc/impl/codegen/compression_types.h
+++ b/include/grpc/impl/codegen/compression_types.h
@@ -29,11 +29,6 @@ extern "C" {
* algorithm */
#define GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \
"grpc-internal-encoding-request"
-/** To be used as initial metadata key for the request of a concrete stream
- * compression
- * algorithm */
-#define GRPC_STREAM_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \
- "grpc-internal-stream-encoding-request"
/** To be used in channel arguments.
*
@@ -43,17 +38,9 @@ extern "C" {
* Its value is an int from the \a grpc_compression_algorithm enum. */
#define GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM \
"grpc.default_compression_algorithm"
-/** Default stream compression algorithm for the channel.
- * Its value is an int from the \a grpc_stream_compression_algorithm enum. */
-#define GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM \
- "grpc.default_stream_compression_algorithm"
/** Default compression level for the channel.
* Its value is an int from the \a grpc_compression_level enum. */
#define GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL "grpc.default_compression_level"
-/** Default stream compression level for the channel.
- * Its value is an int from the \a grpc_stream_compression_level enum. */
-#define GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_LEVEL \
- "grpc.default_stream_compression_level"
/** Compression algorithms supported by the channel.
* Its value is a bitset (an int). Bits correspond to algorithms in \a
* grpc_compression_algorithm. For example, its LSB corresponds to
@@ -63,33 +50,18 @@ extern "C" {
* be ignored). */
#define GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET \
"grpc.compression_enabled_algorithms_bitset"
-/** Stream compression algorithms supported by the channel.
- * Its value is a bitset (an int). Bits correspond to algorithms in \a
- * grpc_stream_compression_algorithm. For example, its LSB corresponds to
- * GRPC_STREAM_COMPRESS_NONE, the next bit to GRPC_STREAM_COMPRESS_DEFLATE, etc.
- * Unset bits disable support for the algorithm. By default all algorithms are
- * supported. It's not possible to disable GRPC_STREAM_COMPRESS_NONE (the
- * attempt will be ignored). */
-#define GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET \
- "grpc.stream_compression_enabled_algorithms_bitset"
/** \} */
/** The various compression algorithms supported by gRPC */
typedef enum {
GRPC_COMPRESS_NONE = 0,
- GRPC_COMPRESS_DEFLATE,
- GRPC_COMPRESS_GZIP,
+ GRPC_COMPRESS_MESSAGE_DEFLATE,
+ GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_STREAM_GZIP,
/* TODO(ctiller): snappy */
GRPC_COMPRESS_ALGORITHMS_COUNT
} grpc_compression_algorithm;
-/** Stream compresssion algorithms supported by gRPC */
-typedef enum {
- GRPC_STREAM_COMPRESS_NONE = 0,
- GRPC_STREAM_COMPRESS_GZIP,
- GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT
-} grpc_stream_compression_algorithm;
-
/** Compression levels allow a party with knowledge of its peer's accepted
* encodings to request compression in an abstract way. The level-algorithm
* mapping is performed internally and depends on the peer's supported
@@ -102,41 +74,22 @@ typedef enum {
GRPC_COMPRESS_LEVEL_COUNT
} grpc_compression_level;
-/** Compression levels for stream compression algorithms */
-typedef enum {
- GRPC_STREAM_COMPRESS_LEVEL_NONE = 0,
- GRPC_STREAM_COMPRESS_LEVEL_LOW,
- GRPC_STREAM_COMPRESS_LEVEL_MED,
- GRPC_STREAM_COMPRESS_LEVEL_HIGH,
- GRPC_STREAM_COMPRESS_LEVEL_COUNT
-} grpc_stream_compression_level;
-
typedef struct grpc_compression_options {
/** All algs are enabled by default. This option corresponds to the channel
* argument key behind \a GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET
*/
uint32_t enabled_algorithms_bitset;
- uint32_t enabled_stream_compression_algorithms_bitset;
- /** The default message-wise compression level. It'll be used in the absence
- * of * call specific settings. This option corresponds to the channel
+ /** The default compression level. It'll be used in the absence of call
+ * specific settings. This option corresponds to the channel
* argument key behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL. If present,
- * takes precedence over \a default_algorithm and \a
- * default_stream_compression_algorithm.
+ * takes precedence over \a default_algorithm.
* TODO(dgq): currently only available for server channels. */
struct grpc_compression_options_default_level {
int is_set;
grpc_compression_level level;
} default_level;
- /** The default stream compression level. It'll be used in the absence of call
- * specefic settings. If present, takes precedence over \a default_level,
- * \a default_algorithm and \a default_stream_compression_algorithm. */
- struct grpc_stream_compression_options_default_level {
- int is_set;
- grpc_stream_compression_level level;
- } default_stream_compression_level;
-
/** The default message compression algorithm. It'll be used in the absence of
* call specific settings. This option corresponds to the channel argument key
* behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM. */
@@ -144,17 +97,6 @@ typedef struct grpc_compression_options {
int is_set;
grpc_compression_algorithm algorithm;
} default_algorithm;
-
- /** The default stream compression algorithm. It'll be used in the absence of
- * call specific settings. If present, takes precedence over \a
- * default_algorithm. This option corresponds to the channel
- * argument key behind \a GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM.
- */
- struct grpc_stream_compression_options_default_algorithm {
- int is_set;
- grpc_stream_compression_algorithm algorithm;
- } default_stream_compression_algorithm;
-
} grpc_compression_options;
#ifdef __cplusplus
diff --git a/include/grpc/impl/codegen/connectivity_state.h b/include/grpc/impl/codegen/connectivity_state.h
index 545b4fdbcc..b70dbef356 100644
--- a/include/grpc/impl/codegen/connectivity_state.h
+++ b/include/grpc/impl/codegen/connectivity_state.h
@@ -25,8 +25,6 @@ extern "C" {
/** Connectivity state of a channel. */
typedef enum {
- /** channel has just been initialized */
- GRPC_CHANNEL_INIT = -1,
/** channel is idle */
GRPC_CHANNEL_IDLE,
/** channel is connecting */
diff --git a/include/grpc/impl/codegen/exec_ctx_fwd.h b/include/grpc/impl/codegen/exec_ctx_fwd.h
deleted file mode 100644
index 005ff14e7e..0000000000
--- a/include/grpc/impl/codegen/exec_ctx_fwd.h
+++ /dev/null
@@ -1,26 +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.
- *
- */
-
-#ifndef GRPC_IMPL_CODEGEN_EXEC_CTX_FWD_H
-#define GRPC_IMPL_CODEGEN_EXEC_CTX_FWD_H
-
-/* forward declaration for exec_ctx.h */
-struct grpc_exec_ctx;
-typedef struct grpc_exec_ctx grpc_exec_ctx;
-
-#endif /* GRPC_IMPL_CODEGEN_EXEC_CTX_FWD_H */
diff --git a/include/grpc/impl/codegen/fork.h b/include/grpc/impl/codegen/fork.h
new file mode 100644
index 0000000000..baec7a2f10
--- /dev/null
+++ b/include/grpc/impl/codegen/fork.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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_IMPL_CODEGEN_FORK_H
+#define GRPC_IMPL_CODEGEN_FORK_H
+
+/**
+ * gRPC applications should call this before calling fork(). There should be no
+ * active gRPC function calls between calling grpc_prefork() and
+ * grpc_postfork_parent()/grpc_postfork_child().
+ *
+ *
+ * Typical use:
+ * grpc_prefork();
+ * int pid = fork();
+ * if (pid) {
+ * grpc_postfork_parent();
+ * // Parent process..
+ * } else {
+ * grpc_postfork_child();
+ * // Child process...
+ * }
+ */
+
+void grpc_prefork();
+
+void grpc_postfork_parent();
+
+void grpc_postfork_child();
+
+void grpc_fork_handlers_auto_register();
+
+#endif /* GRPC_IMPL_CODEGEN_FORK_H */
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index 90f03f49a3..e5aa29b88a 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -22,7 +22,6 @@
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/impl/codegen/compression_types.h>
-#include <grpc/impl/codegen/exec_ctx_fwd.h>
#include <grpc/impl/codegen/gpr_types.h>
#include <grpc/impl/codegen/slice.h>
#include <grpc/impl/codegen/status.h>
@@ -39,11 +38,11 @@ typedef enum {
} grpc_byte_buffer_type;
typedef struct grpc_byte_buffer {
- void *reserved;
+ void* reserved;
grpc_byte_buffer_type type;
union grpc_byte_buffer_data {
struct /* internal */ {
- void *reserved[8];
+ void* reserved[8];
} reserved;
struct grpc_compressed_buffer {
grpc_compression_algorithm compression;
@@ -84,9 +83,9 @@ typedef enum {
} grpc_arg_type;
typedef struct grpc_arg_pointer_vtable {
- void *(*copy)(void *p);
- void (*destroy)(grpc_exec_ctx *exec_ctx, void *p);
- int (*cmp)(void *p, void *q);
+ void* (*copy)(void* p);
+ void (*destroy)(void* p);
+ int (*cmp)(void* p, void* q);
} grpc_arg_pointer_vtable;
/** A single argument... each argument has a key and a value
@@ -103,13 +102,13 @@ typedef struct grpc_arg_pointer_vtable {
their keys so that it's possible to change them in the future. */
typedef struct {
grpc_arg_type type;
- char *key;
+ char* key;
union grpc_arg_value {
- char *string;
+ char* string;
int integer;
struct grpc_arg_pointer {
- void *p;
- const grpc_arg_pointer_vtable *vtable;
+ void* p;
+ const grpc_arg_pointer_vtable* vtable;
} pointer;
} value;
} grpc_arg;
@@ -127,7 +126,7 @@ typedef struct {
details. */
typedef struct {
size_t num_args;
- grpc_arg *args;
+ grpc_arg* args;
} grpc_channel_args;
/** \defgroup grpc_arg_keys
@@ -240,6 +239,9 @@ typedef struct {
/** The time between the first and second connection attempts, in ms */
#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \
"grpc.initial_reconnect_backoff_ms"
+/** The timeout used on servers for finishing handshaking on an incoming
+ connection. Defaults to 120 seconds. */
+#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms"
/** This *should* be used for testing only.
The caller of the secure_channel_create functions may override the target
name used for SSL host name checking using this channel argument which is of
@@ -288,7 +290,11 @@ typedef struct {
"grpc.experimental.tcp_max_read_chunk_size"
/* Timeout in milliseconds to use for calls to the grpclb load balancer.
If 0 or unset, the balancer calls will have no deadline. */
-#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_timeout_ms"
+#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms"
+/* Timeout in milliseconds to wait for the serverlist from the grpclb load
+ balancer before using fallback backend addresses from the resolver.
+ If 0, fallback will never be used. */
+#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms"
/** If non-zero, grpc server's cronet compression workaround will be enabled */
#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \
"grpc.workaround.cronet_compression"
@@ -396,7 +402,7 @@ typedef struct grpc_metadata {
There is no need to initialize them, and they will be set to garbage
during calls to grpc. */
struct /* internal */ {
- void *obfuscated[4];
+ void* obfuscated[4];
} internal_data;
} grpc_metadata;
@@ -424,13 +430,13 @@ typedef struct grpc_event {
int success;
/** The tag passed to grpc_call_start_batch etc to start this operation.
Only GRPC_OP_COMPLETE has a tag. */
- void *tag;
+ void* tag;
} grpc_event;
typedef struct {
size_t count;
size_t capacity;
- grpc_metadata *metadata;
+ grpc_metadata* metadata;
} grpc_metadata_array;
typedef struct {
@@ -438,7 +444,7 @@ typedef struct {
grpc_slice host;
gpr_timespec deadline;
uint32_t flags;
- void *reserved;
+ void* reserved;
} grpc_call_details;
typedef enum {
@@ -494,25 +500,21 @@ typedef struct grpc_op {
/** Write flags bitset for grpc_begin_messages */
uint32_t flags;
/** Reserved for future usage */
- void *reserved;
+ void* reserved;
union grpc_op_data {
/** Reserved for future usage */
struct /* internal */ {
- void *reserved[8];
+ void* reserved[8];
} reserved;
struct grpc_op_send_initial_metadata {
size_t count;
- grpc_metadata *metadata;
+ grpc_metadata* metadata;
/** If \a is_set, \a compression_level will be used for the call.
* Otherwise, \a compression_level won't be considered */
struct grpc_op_send_initial_metadata_maybe_compression_level {
uint8_t is_set;
grpc_compression_level level;
} maybe_compression_level;
- struct grpc_op_send_initial_metadata_maybe_stream_compression_level {
- uint8_t is_set;
- grpc_stream_compression_level level;
- } maybe_stream_compression_level;
} send_initial_metadata;
struct grpc_op_send_message {
/** This op takes ownership of the slices in send_message. After
@@ -520,16 +522,16 @@ typedef struct grpc_op {
* and likely empty. The original owner should still call
* grpc_byte_buffer_destroy() on this object however.
*/
- struct grpc_byte_buffer *send_message;
+ struct grpc_byte_buffer* send_message;
} send_message;
struct grpc_op_send_status_from_server {
size_t trailing_metadata_count;
- grpc_metadata *trailing_metadata;
+ grpc_metadata* trailing_metadata;
grpc_status_code status;
/** optional: set to NULL if no details need sending, non-NULL if they do
* pointer will not be retained past the start_batch call
*/
- grpc_slice *status_details;
+ grpc_slice* status_details;
} send_status_from_server;
/** ownership of the array is with the caller, but ownership of the elements
stays with the call object (ie key, value members are owned by the call
@@ -537,13 +539,13 @@ typedef struct grpc_op {
After the operation completes, call grpc_metadata_array_destroy on this
value, or reuse it in a future op. */
struct grpc_op_recv_initial_metadata {
- grpc_metadata_array *recv_initial_metadata;
+ grpc_metadata_array* recv_initial_metadata;
} recv_initial_metadata;
/** ownership of the byte buffer is moved to the caller; the caller must
call grpc_byte_buffer_destroy on this value, or reuse it in a future op.
*/
struct grpc_op_recv_message {
- struct grpc_byte_buffer **recv_message;
+ struct grpc_byte_buffer** recv_message;
} recv_message;
struct grpc_op_recv_status_on_client {
/** ownership of the array is with the caller, but ownership of the
@@ -551,14 +553,18 @@ typedef struct grpc_op {
by the call object, trailing_metadata->array is owned by the caller).
After the operation completes, call grpc_metadata_array_destroy on
this value, or reuse it in a future op. */
- grpc_metadata_array *trailing_metadata;
- grpc_status_code *status;
- grpc_slice *status_details;
+ grpc_metadata_array* trailing_metadata;
+ grpc_status_code* status;
+ grpc_slice* status_details;
+ /** If this is not nullptr, it will be populated with the full fidelity
+ * error string for debugging purposes. The application is responsible
+ * for freeing the data by using gpr_free(). */
+ const char** error_string;
} recv_status_on_client;
struct grpc_op_recv_close_on_server {
/** out argument, set to 1 if the call failed in any way (seen as a
cancellation on the server), or 0 if the call succeeded */
- int *cancelled;
+ int* cancelled;
} recv_close_on_server;
} data;
} grpc_op;
@@ -567,10 +573,10 @@ typedef struct grpc_op {
typedef struct {
/** If non-NULL, will be set to point to a string indicating the LB
* policy name. Caller takes ownership. */
- char **lb_policy_name;
+ char** lb_policy_name;
/** If non-NULL, will be set to point to a string containing the
* service config used by the channel in JSON form. */
- char **service_config_json;
+ char** service_config_json;
} grpc_channel_info;
typedef struct grpc_resource_quota grpc_resource_quota;
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index 1904c636f7..819d17ce2a 100644
--- a/include/grpc/impl/codegen/port_platform.h
+++ b/include/grpc/impl/codegen/port_platform.h
@@ -173,6 +173,7 @@
#endif /* _LP64 */
#ifdef __GLIBC__
#define GPR_POSIX_CRASH_HANDLER 1
+#define GPR_LINUX_PTHREAD_NAME 1
#else /* musl libc */
#define GPR_MUSL_LIBC_COMPAT 1
#endif
@@ -183,7 +184,6 @@
#define _BSD_SOURCE
#endif
#if TARGET_OS_IPHONE
-#define GPR_FORBID_UNREACHABLE_CODE 1
#define GPR_PLATFORM_STRING "ios"
#define GPR_CPU_IPHONE 1
#define GPR_PTHREAD_TLS 1
@@ -195,11 +195,25 @@
#define GPR_PTHREAD_TLS 1
#else /* __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7 */
#define GPR_CPU_POSIX 1
+/* TODO(vjpai): there is a reported issue in bazel build for Mac where __thread
+ in a header is currently not working (bazelbuild/bazel#4341). Remove
+ the following conditional and use GPR_GCC_TLS when that is fixed */
+#ifndef GRPC_BAZEL_BUILD
#define GPR_GCC_TLS 1
+#else /* GRPC_BAZEL_BUILD */
+#define GPR_PTHREAD_TLS 1
+#endif /* GRPC_BAZEL_BUILD */
+#define GPR_APPLE_PTHREAD_NAME 1
#endif
#else /* __MAC_OS_X_VERSION_MIN_REQUIRED */
#define GPR_CPU_POSIX 1
+/* TODO(vjpai): Remove the following conditional and use only GPR_GCC_TLS
+ when bazelbuild/bazel#4341 is fixed */
+#ifndef GRPC_BAZEL_BUILD
#define GPR_GCC_TLS 1
+#else /* GRPC_BAZEL_BUILD */
+#define GPR_PTHREAD_TLS 1
+#endif /* GRPC_BAZEL_BUILD */
#endif
#define GPR_POSIX_CRASH_HANDLER 1
#endif
@@ -242,6 +256,29 @@
#else /* _LP64 */
#define GPR_ARCH_32 1
#endif /* _LP64 */
+#elif defined(__OpenBSD__)
+#define GPR_PLATFORM_STRING "openbsd"
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define GPR_OPENBSD 1
+#define GPR_CPU_POSIX 1
+#define GPR_GCC_ATOMIC 1
+#define GPR_GCC_TLS 1
+#define GPR_POSIX_LOG 1
+#define GPR_POSIX_ENV 1
+#define GPR_POSIX_TMPFILE 1
+#define GPR_POSIX_STRING 1
+#define GPR_POSIX_SUBPROCESS 1
+#define GPR_POSIX_SYNC 1
+#define GPR_POSIX_TIME 1
+#define GPR_GETPID_IN_UNISTD_H 1
+#define GPR_SUPPORT_CHANNELS_FROM_FD 1
+#ifdef _LP64
+#define GPR_ARCH_64 1
+#else /* _LP64 */
+#define GPR_ARCH_32 1
+#endif /* _LP64 */
#elif defined(__native_client__)
#define GPR_PLATFORM_STRING "nacl"
#ifndef _BSD_SOURCE
@@ -275,6 +312,30 @@
#endif
#endif /* GPR_NO_AUTODETECT_PLATFORM */
+/*
+ * There are platforms for which TLS should not be used even though the
+ * compiler makes it seem like it's supported (Android NDK < r12b for example).
+ * This is primarily because of linker problems and toolchain misconfiguration:
+ * TLS isn't supported until NDK r12b per
+ * https://developer.android.com/ndk/downloads/revision_history.html
+ * TLS also does not work with Android NDK if GCC is being used as the compiler
+ * instead of Clang.
+ * Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in
+ * <android/ndk-version.h>. For NDK < r16, users should define these macros,
+ * e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11. */
+#if defined(__ANDROID__) && defined(GPR_GCC_TLS)
+#if __has_include(<android/ndk-version.h>)
+#include <android/ndk-version.h>
+#endif /* __has_include(<android/ndk-version.h>) */
+#if (defined(__clang__) && defined(__NDK_MAJOR__) && defined(__NDK_MINOR__) && \
+ ((__NDK_MAJOR__ < 12) || \
+ ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))) || \
+ (defined(__GNUC__) && !defined(__clang__))
+#undef GPR_GCC_TLS
+#define GPR_PTHREAD_TLS 1
+#endif
+#endif /*defined(__ANDROID__) && defined(GPR_GCC_TLS) */
+
#if defined(__has_include)
#if __has_include(<atomic>)
#define GRPC_HAS_CXX11_ATOMIC
@@ -292,10 +353,6 @@
#endif
#ifdef _MSC_VER
-#ifdef _PYTHON_MSVC
-// The Python 3.5 Windows runtime is missing InetNtop
-#define GPR_WIN_INET_NTOP
-#endif // _PYTHON_MSVC
#if _MSC_VER < 1700
typedef __int8 int8_t;
typedef __int16 int16_t;
@@ -377,6 +434,14 @@ typedef unsigned __int64 uint64_t;
#endif
#endif
+#ifndef GRPC_UNUSED
+#if defined(__GNUC__) && !defined(__MINGW32__)
+#define GRPC_UNUSED __attribute__((unused))
+#else
+#define GRPC_UNUSED
+#endif
+#endif
+
#ifndef GPR_PRINT_FORMAT_CHECK
#ifdef __GNUC__
#define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS) \
@@ -420,4 +485,23 @@ typedef unsigned __int64 uint64_t;
#endif /* GPR_ATTRIBUTE_NO_TSAN (2) */
#endif /* GPR_ATTRIBUTE_NO_TSAN (1) */
+/* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */
+#ifndef GRPC_ALLOW_EXCEPTIONS
+/* If not already set, set to 1 on Windows (style guide standard) but to
+ * 0 on non-Windows platforms unless the compiler defines __EXCEPTIONS */
+#ifdef GPR_WINDOWS
+#define GRPC_ALLOW_EXCEPTIONS 1
+#else /* GPR_WINDOWS */
+#ifdef __EXCEPTIONS
+#define GRPC_ALLOW_EXCEPTIONS 1
+#else /* __EXCEPTIONS */
+#define GRPC_ALLOW_EXCEPTIONS 0
+#endif /* __EXCEPTIONS */
+#endif /* __GPR_WINDOWS */
+#endif /* GRPC_ALLOW_EXCEPTIONS */
+
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
#endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */
diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h
index 128fa8e121..a3cd1f1bbe 100644
--- a/include/grpc/impl/codegen/slice.h
+++ b/include/grpc/impl/codegen/slice.h
@@ -23,7 +23,6 @@
#include <stddef.h>
-#include <grpc/impl/codegen/exec_ctx_fwd.h>
#include <grpc/impl/codegen/gpr_slice.h>
typedef struct grpc_slice grpc_slice;
@@ -42,8 +41,8 @@ typedef struct grpc_slice grpc_slice;
constraints (is the callee allowed to modify the slice?) */
typedef struct grpc_slice_refcount_vtable {
- void (*ref)(void *);
- void (*unref)(grpc_exec_ctx *exec_ctx, void *);
+ void (*ref)(void*);
+ void (*unref)(void*);
int (*eq)(grpc_slice a, grpc_slice b);
uint32_t (*hash)(grpc_slice slice);
} grpc_slice_refcount_vtable;
@@ -54,20 +53,20 @@ typedef struct grpc_slice_refcount_vtable {
Typically client code should not touch this, and use grpc_slice_malloc,
grpc_slice_new, or grpc_slice_new_with_len instead. */
typedef struct grpc_slice_refcount {
- const grpc_slice_refcount_vtable *vtable;
+ const grpc_slice_refcount_vtable* vtable;
/** If a subset of this slice is taken, use this pointer for the refcount.
Typically points back to the refcount itself, however iterning
implementations can use this to avoid a verification step on each hash
or equality check */
- struct grpc_slice_refcount *sub_refcount;
+ struct grpc_slice_refcount* sub_refcount;
} grpc_slice_refcount;
/* Inlined half of grpc_slice is allowed to expand the size of the overall type
by this many bytes */
-#define GRPC_SLICE_INLINE_EXTRA_SIZE sizeof(void *)
+#define GRPC_SLICE_INLINE_EXTRA_SIZE sizeof(void*)
#define GRPC_SLICE_INLINED_SIZE \
- (sizeof(size_t) + sizeof(uint8_t *) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE)
+ (sizeof(size_t) + sizeof(uint8_t*) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE)
/** A grpc_slice s, if initialized, represents the byte range
s.bytes[0..s.length-1].
@@ -79,10 +78,10 @@ typedef struct grpc_slice_refcount {
If the slice does not have a refcount, it represents an inlined small piece
of data that is copied by value. */
struct grpc_slice {
- struct grpc_slice_refcount *refcount;
+ struct grpc_slice_refcount* refcount;
union grpc_slice_data {
struct grpc_slice_refcounted {
- uint8_t *bytes;
+ uint8_t* bytes;
size_t length;
} refcounted;
struct grpc_slice_inlined {
@@ -99,10 +98,10 @@ struct grpc_slice {
typedef struct {
/** This is for internal use only. External users (i.e any code outside grpc
* core) MUST NOT use this field */
- grpc_slice *base_slices;
+ grpc_slice* base_slices;
/** slices in the array (Points to the first valid grpc_slice in the array) */
- grpc_slice *slices;
+ grpc_slice* slices;
/** the number of slices in the array */
size_t count;
/** the number of slices allocated in the array. External users (i.e any code
diff --git a/include/grpc/impl/codegen/sync_generic.h b/include/grpc/impl/codegen/sync_generic.h
index e1eea54298..83f905e120 100644
--- a/include/grpc/impl/codegen/sync_generic.h
+++ b/include/grpc/impl/codegen/sync_generic.h
@@ -23,16 +23,22 @@
#include <grpc/impl/codegen/atm.h>
/* gpr_event */
-typedef struct { gpr_atm state; } gpr_event;
+typedef struct {
+ gpr_atm state;
+} gpr_event;
#define GPR_EVENT_INIT \
{ 0 }
/* gpr_refcount */
-typedef struct { gpr_atm count; } gpr_refcount;
+typedef struct {
+ gpr_atm count;
+} gpr_refcount;
/* gpr_stats_counter */
-typedef struct { gpr_atm value; } gpr_stats_counter;
+typedef struct {
+ gpr_atm value;
+} gpr_stats_counter;
#define GPR_STATS_INIT \
{ 0 }
diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap
index 51bfef2cc9..d23072f556 100644
--- a/include/grpc/module.modulemap
+++ b/include/grpc/module.modulemap
@@ -1,12 +1,83 @@
+
framework module grpc {
umbrella header "grpc.h"
- header "byte_buffer_reader.h"
- header "grpc_security.h"
- header "grpc_security_constants.h"
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"
+ 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"
+ header "impl/codegen/gpr_types.h"
+ header "impl/codegen/port_platform.h"
+ header "impl/codegen/sync.h"
+ header "impl/codegen/sync_generic.h"
+ header "impl/codegen/byte_buffer.h"
+ header "impl/codegen/byte_buffer_reader.h"
+ header "impl/codegen/compression_types.h"
+ header "impl/codegen/connectivity_state.h"
+ header "impl/codegen/grpc_types.h"
+ header "impl/codegen/propagation_bits.h"
+ header "impl/codegen/slice.h"
+ header "impl/codegen/status.h"
+ header "impl/codegen/atm.h"
+ header "impl/codegen/fork.h"
+ header "impl/codegen/gpr_slice.h"
+ header "impl/codegen/gpr_types.h"
+ header "impl/codegen/port_platform.h"
+ header "impl/codegen/sync.h"
+ header "impl/codegen/sync_generic.h"
+ header "grpc_security.h"
+ header "byte_buffer.h"
+ header "byte_buffer_reader.h"
+ header "compression.h"
+ header "compression_ruby.h"
+ header "fork.h"
+ header "grpc.h"
+ header "grpc_posix.h"
+ header "grpc_security_constants.h"
+ header "load_reporting.h"
+ header "slice.h"
+ header "slice_buffer.h"
+ header "status.h"
+ header "support/workaround_list.h"
+ header "census.h"
+
+ textual header "support/atm_gcc_atomic.h"
+ textual header "support/atm_gcc_sync.h"
+ textual header "support/atm_windows.h"
+ 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"
+ textual header "impl/codegen/sync_custom.h"
+ textual header "impl/codegen/sync_posix.h"
+ textual header "impl/codegen/sync_windows.h"
+ textual header "impl/codegen/atm_gcc_atomic.h"
+ textual header "impl/codegen/atm_gcc_sync.h"
+ textual header "impl/codegen/atm_windows.h"
+ textual header "impl/codegen/sync_custom.h"
+ textual header "impl/codegen/sync_posix.h"
+ textual header "impl/codegen/sync_windows.h"
export *
module * { export * }
diff --git a/include/grpc/slice.h b/include/grpc/slice.h
index 3f3cff1408..10b6a624b3 100644
--- a/include/grpc/slice.h
+++ b/include/grpc/slice.h
@@ -44,20 +44,20 @@ GPRAPI grpc_slice grpc_slice_copy(grpc_slice s);
/** Create a slice pointing at some data. Calls malloc to allocate a refcount
for the object, and arranges that destroy will be called with the pointer
passed in at destruction. */
-GPRAPI grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *));
+GPRAPI grpc_slice grpc_slice_new(void* p, size_t len, void (*destroy)(void*));
/** Equivalent to grpc_slice_new, but with a separate pointer that is
passed to the destroy function. This function can be useful when
the data is part of a larger structure that must be destroyed when
the data is no longer needed. */
-GPRAPI grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
- void (*destroy)(void *),
- void *user_data);
+GPRAPI grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
+ void (*destroy)(void*),
+ void* user_data);
/** Equivalent to grpc_slice_new, but with a two argument destroy function that
also takes the slice length. */
-GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len,
- void (*destroy)(void *, size_t));
+GPRAPI grpc_slice grpc_slice_new_with_len(void* p, size_t len,
+ void (*destroy)(void*, size_t));
/** Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc()
call.
@@ -79,19 +79,19 @@ GPRAPI grpc_slice grpc_slice_intern(grpc_slice slice);
size_t len = strlen(source);
grpc_slice slice = grpc_slice_malloc(len);
memcpy(slice->data, source, len); */
-GPRAPI grpc_slice grpc_slice_from_copied_string(const char *source);
+GPRAPI grpc_slice grpc_slice_from_copied_string(const char* source);
/** Create a slice by copying a buffer.
Equivalent to:
grpc_slice slice = grpc_slice_malloc(len);
memcpy(slice->data, source, len); */
-GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len);
+GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char* source, size_t len);
/** Create a slice pointing to constant memory */
-GPRAPI grpc_slice grpc_slice_from_static_string(const char *source);
+GPRAPI grpc_slice grpc_slice_from_static_string(const char* source);
/** Create a slice pointing to constant memory */
-GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len);
+GPRAPI grpc_slice grpc_slice_from_static_buffer(const void* source, size_t len);
/** Return a result slice derived from s, which shares a ref count with \a s,
where result.data==s.data+begin, and result.length==end-begin. The ref count
@@ -106,7 +106,7 @@ GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end);
/** Splits s into two: modifies s to be s[0:split], and returns a new slice,
sharing a refcount with s, that contains s[split:s.length].
Requires s intialized, split <= s.length */
-GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split);
+GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split);
typedef enum {
GRPC_SLICE_REF_TAIL = 1,
@@ -117,13 +117,13 @@ typedef enum {
/** The same as grpc_slice_split_tail, but with an option to skip altering
* refcounts (grpc_slice_split_tail_maybe_ref(..., true) is equivalent to
* grpc_slice_split_tail(...)) */
-GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *s, size_t split,
+GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* s, size_t split,
grpc_slice_ref_whom ref_whom);
/** Splits s into two: modifies s to be s[split:s.length], and returns a new
slice, sharing a refcount with s, that contains s[0:split].
Requires s intialized, split <= s.length */
-GPRAPI grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split);
+GPRAPI grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split);
GPRAPI grpc_slice grpc_empty_slice(void);
@@ -136,11 +136,10 @@ GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b);
The order is arbitrary, and is not guaranteed to be stable across different
versions of the API. */
GPRAPI int grpc_slice_cmp(grpc_slice a, grpc_slice b);
-GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char *b);
-GPRAPI int grpc_slice_buf_cmp(grpc_slice a, const void *b, size_t blen);
+GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char* b);
/** return non-zero if the first blen bytes of a are equal to b */
-GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void *b, size_t blen);
+GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void* b, size_t blen);
/** return the index of the last instance of \a c in \a s, or -1 if not found */
GPRAPI int grpc_slice_rchr(grpc_slice s, char c);
@@ -162,7 +161,7 @@ GPRAPI grpc_slice grpc_slice_dup(grpc_slice a);
/** Return a copy of slice as a C string. Offers no protection against embedded
NULL's. Returned string must be freed with gpr_free. */
-GPRAPI char *grpc_slice_to_c_string(grpc_slice s);
+GPRAPI char* grpc_slice_to_c_string(grpc_slice s);
#ifdef __cplusplus
}
diff --git a/include/grpc/slice_buffer.h b/include/grpc/slice_buffer.h
index de4b86f777..30833d02db 100644
--- a/include/grpc/slice_buffer.h
+++ b/include/grpc/slice_buffer.h
@@ -26,13 +26,13 @@ extern "C" {
#endif
/** initialize a slice buffer */
-GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb);
+GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer* sb);
/** destroy a slice buffer - unrefs any held elements */
-GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer *sb);
+GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer* sb);
/** Add an element to a slice buffer - takes ownership of the slice.
This function is allowed to concatenate the passed in slice to the end of
some other slice if desired by the slice buffer. */
-GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice);
+GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice);
/** add an element to a slice buffer - takes ownership of the slice and returns
the index of the slice.
Guarantees that the slice will not be concatenated at the end of another
@@ -40,40 +40,39 @@ GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice);
slice at the returned index in sb->slices)
The implementation MAY decide to concatenate data at the end of a small
slice added in this fashion. */
-GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb,
+GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer* sb,
grpc_slice slice);
-GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices,
+GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer* sb, grpc_slice* slices,
size_t n);
/** add a very small (less than 8 bytes) amount of data to the end of a slice
buffer: returns a pointer into which to add the data */
-GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len);
+GPRAPI uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t len);
/** pop the last buffer, but don't unref it */
-GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer *sb);
+GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer* sb);
/** clear a slice buffer, unref all elements */
-GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb);
+GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb);
/** swap the contents of two slice buffers */
-GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b);
+GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b);
/** move all of the elements of src into dst */
-GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src,
- grpc_slice_buffer *dst);
+GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer* src,
+ grpc_slice_buffer* dst);
/** remove n bytes from the end of a slice buffer */
-GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *garbage);
+GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* garbage);
/** move the first n bytes of src into dst */
-GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst);
+GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst);
/** move the first n bytes of src into dst without adding references */
-GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src,
+GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src,
size_t n,
- grpc_slice_buffer *dst);
+ grpc_slice_buffer* dst);
/** move the first n bytes of src into dst (copying them) */
-GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *src,
- size_t n, void *dst);
+GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src,
+ size_t n, void* dst);
/** take the first slice in the slice buffer */
-GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src);
+GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* src);
/** undo the above with (a possibly different) \a slice */
-GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *src,
+GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* src,
grpc_slice slice);
#ifdef __cplusplus
diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h
index 4b59e137f2..577d4f0069 100644
--- a/include/grpc/support/alloc.h
+++ b/include/grpc/support/alloc.h
@@ -28,10 +28,10 @@ extern "C" {
#endif
typedef struct gpr_allocation_functions {
- void *(*malloc_fn)(size_t size);
- void *(*zalloc_fn)(size_t size); /** if NULL, uses malloc_fn then memset */
- void *(*realloc_fn)(void *ptr, size_t size);
- void (*free_fn)(void *ptr);
+ void* (*malloc_fn)(size_t size);
+ void* (*zalloc_fn)(size_t size); /** if NULL, uses malloc_fn then memset */
+ void* (*realloc_fn)(void* ptr, size_t size);
+ void (*free_fn)(void* ptr);
} gpr_allocation_functions;
/** malloc.
@@ -39,17 +39,18 @@ typedef struct gpr_allocation_functions {
* The pointer returned is suitably aligned for any kind of variable it could
* contain.
*/
-GPRAPI void *gpr_malloc(size_t size);
+GPRAPI void* gpr_malloc(size_t size);
/** like malloc, but zero all bytes before returning them */
-GPRAPI void *gpr_zalloc(size_t size);
+GPRAPI void* gpr_zalloc(size_t size);
/** free */
-GPRAPI void gpr_free(void *ptr);
+GPRAPI void gpr_free(void* ptr);
/** realloc, never returns NULL */
-GPRAPI void *gpr_realloc(void *p, size_t size);
-/** aligned malloc, never returns NULL, will align to 1 << alignment_log */
-GPRAPI void *gpr_malloc_aligned(size_t size, size_t alignment_log);
+GPRAPI void* gpr_realloc(void* p, size_t size);
+/** aligned malloc, never returns NULL, will align to alignment, which
+ * must be a power of 2. */
+GPRAPI void* gpr_malloc_aligned(size_t size, size_t alignment);
/** free memory allocated by gpr_malloc_aligned */
-GPRAPI void gpr_free_aligned(void *ptr);
+GPRAPI void gpr_free_aligned(void* ptr);
/** Request the family of allocation functions in \a functions be used. NOTE
* that this request will be honored in a *best effort* basis and that no
@@ -58,7 +59,7 @@ GPRAPI void gpr_free_aligned(void *ptr);
GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions);
/** Return the family of allocation functions currently in effect. */
-GPRAPI gpr_allocation_functions gpr_get_allocation_functions();
+GPRAPI gpr_allocation_functions gpr_get_allocation_functions(void);
#ifdef __cplusplus
}
diff --git a/include/grpc/support/avl.h b/include/grpc/support/avl.h
index d53ff5d904..b5a8c0ffa1 100644
--- a/include/grpc/support/avl.h
+++ b/include/grpc/support/avl.h
@@ -21,13 +21,17 @@
#include <grpc/support/sync.h>
+#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;
+ void* key;
+ void* value;
+ struct gpr_avl_node* left;
+ struct gpr_avl_node* right;
long height;
} gpr_avl_node;
@@ -38,57 +42,61 @@ typedef struct gpr_avl_node {
*/
typedef struct gpr_avl_vtable {
/** destroy a key */
- void (*destroy_key)(void *key, void *user_data);
+ void (*destroy_key)(void* key, void* user_data);
/** copy a key, returning new value */
- void *(*copy_key)(void *key, void *user_data);
+ 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);
+ long (*compare_keys)(void* key1, void* key2, void* user_data);
/** destroy a value */
- void (*destroy_value)(void *value, void *user_data);
+ void (*destroy_value)(void* value, void* user_data);
/** copy a value */
- void *(*copy_value)(void *value, void *user_data);
+ 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;
+ 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);
+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);
+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);
+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);
+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);
+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);
+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);
+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/cmdline.h b/include/grpc/support/cmdline.h
index 9f46491b38..c34a109fbd 100644
--- a/include/grpc/support/cmdline.h
+++ b/include/grpc/support/cmdline.h
@@ -55,31 +55,31 @@ 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);
+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);
+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);
+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, char **value);
+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);
+ 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);
+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);
+GPRAPI int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv);
/** Destroy the parser */
-GPRAPI void gpr_cmdline_destroy(gpr_cmdline *cl);
+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);
+GPRAPI char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0);
#ifdef __cplusplus
}
diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h
deleted file mode 100644
index 8489daa27e..0000000000
--- a/include/grpc/support/histogram.h
+++ /dev/null
@@ -1,64 +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_HISTOGRAM_H
-#define GRPC_SUPPORT_HISTOGRAM_H
-
-#include <grpc/support/port_platform.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct gpr_histogram gpr_histogram;
-
-GPRAPI gpr_histogram *gpr_histogram_create(double resolution,
- double max_bucket_start);
-GPRAPI void gpr_histogram_destroy(gpr_histogram *h);
-GPRAPI void gpr_histogram_add(gpr_histogram *h, double x);
-
-/** The following merges the second histogram into the first. It only works
- if they have the same buckets and resolution. Returns 0 on failure, 1
- on success */
-GPRAPI int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src);
-
-GPRAPI double gpr_histogram_percentile(gpr_histogram *histogram,
- double percentile);
-GPRAPI double gpr_histogram_mean(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_stddev(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_variance(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_maximum(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_minimum(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_count(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_sum(gpr_histogram *histogram);
-GPRAPI double gpr_histogram_sum_of_squares(gpr_histogram *histogram);
-
-GPRAPI const uint32_t *gpr_histogram_get_contents(gpr_histogram *histogram,
- size_t *count);
-GPRAPI void gpr_histogram_merge_contents(gpr_histogram *histogram,
- const uint32_t *data,
- size_t data_count, double min_seen,
- double max_seen, double sum,
- double sum_of_squares, double count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GRPC_SUPPORT_HISTOGRAM_H */
diff --git a/include/grpc/support/host_port.h b/include/grpc/support/host_port.h
index 41592dfe26..9805811bfb 100644
--- a/include/grpc/support/host_port.h
+++ b/include/grpc/support/host_port.h
@@ -35,14 +35,14 @@ extern "C" {
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);
+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);
+GPRAPI int gpr_split_host_port(const char* name, char** host, char** port);
#ifdef __cplusplus
}
diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h
index a22fb6a6e2..a8371cbd48 100644
--- a/include/grpc/support/log.h
+++ b/include/grpc/support/log.h
@@ -50,7 +50,7 @@ typedef enum gpr_log_severity {
#define GPR_LOG_VERBOSITY_UNSET -1
/** Returns a string representation of the log severity */
-GPRAPI const char *gpr_log_severity_string(gpr_log_severity severity);
+GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity);
/** Macros to build log contexts at various severity levels */
#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
@@ -59,28 +59,30 @@ GPRAPI const char *gpr_log_severity_string(gpr_log_severity severity);
/** Log a message. It's advised to use GPR_xxx above to generate the context
* for each message */
-GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
+GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity,
+ const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
-GPRAPI void gpr_log_message(const char *file, int line,
- gpr_log_severity severity, const char *message);
+GPRAPI void gpr_log_message(const char* file, int line,
+ gpr_log_severity severity, const char* message);
/** Set global log verbosity */
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
-GPRAPI void gpr_log_verbosity_init();
+GPRAPI void gpr_log_verbosity_init(void);
/** Log overrides: applications can use this API to intercept logging calls
and use their own implementations */
-typedef struct {
- const char *file;
+struct gpr_log_func_args {
+ const char* file;
int line;
gpr_log_severity severity;
- const char *message;
-} gpr_log_func_args;
+ const char* message;
+};
-typedef void (*gpr_log_func)(gpr_log_func_args *args);
+typedef struct gpr_log_func_args gpr_log_func_args;
+
+typedef void (*gpr_log_func)(gpr_log_func_args* args);
GPRAPI void gpr_set_log_function(gpr_log_func func);
/** abort() the process if x is zero, having written a line to the log.
diff --git a/include/grpc/support/log_windows.h b/include/grpc/support/log_windows.h
index b530fd50d6..e833f9d9df 100644
--- a/include/grpc/support/log_windows.h
+++ b/include/grpc/support/log_windows.h
@@ -29,7 +29,7 @@ extern "C" {
* formatted error message, corresponding to the error messageid.
* Use in conjunction with GetLastError() et al.
*/
-GPRAPI char *gpr_format_message(int messageid);
+GPRAPI char* gpr_format_message(int messageid);
#ifdef __cplusplus
}
diff --git a/include/grpc/support/string_util.h b/include/grpc/support/string_util.h
index c4fc159d05..2c7460fa15 100644
--- a/include/grpc/support/string_util.h
+++ b/include/grpc/support/string_util.h
@@ -29,7 +29,7 @@ extern "C" {
/** Returns a copy of src that can be passed to gpr_free().
If allocation fails or if src is NULL, returns NULL. */
-GPRAPI char *gpr_strdup(const char *src);
+GPRAPI char* gpr_strdup(const char* src);
/** printf to a newly-allocated string. The set of supported formats may vary
between platforms.
@@ -39,7 +39,7 @@ GPRAPI char *gpr_strdup(const char *src);
On error, returns -1 and sets *strp to NULL. If the format string is bad,
the result is undefined. */
-GPRAPI int gpr_asprintf(char **strp, const char *format, ...)
+GPRAPI int gpr_asprintf(char** strp, const char* format, ...)
GPR_PRINT_FORMAT_CHECK(2, 3);
#ifdef __cplusplus
diff --git a/include/grpc/support/subprocess.h b/include/grpc/support/subprocess.h
index c06e629637..175f7b50eb 100644
--- a/include/grpc/support/subprocess.h
+++ b/include/grpc/support/subprocess.h
@@ -28,14 +28,14 @@ extern "C" {
typedef struct gpr_subprocess gpr_subprocess;
/** .exe on windows, empty on unices */
-GPRAPI const char *gpr_subprocess_binary_extension();
+GPRAPI const char* gpr_subprocess_binary_extension();
-GPRAPI gpr_subprocess *gpr_subprocess_create(int argc, const char **argv);
+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);
+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);
+GPRAPI int gpr_subprocess_join(gpr_subprocess* p);
+GPRAPI void gpr_subprocess_interrupt(gpr_subprocess* p);
#ifdef __cplusplus
} // extern "C"
diff --git a/include/grpc/support/sync.h b/include/grpc/support/sync.h
index fe8a59a5d6..75192673a6 100644
--- a/include/grpc/support/sync.h
+++ b/include/grpc/support/sync.h
@@ -34,26 +34,26 @@ extern "C" {
gpr_mu are uninitialized when first declared. */
/** Initialize *mu. Requires: *mu uninitialized. */
-GPRAPI void gpr_mu_init(gpr_mu *mu);
+GPRAPI void gpr_mu_init(gpr_mu* mu);
/** Cause *mu no longer to be initialized, freeing any memory in use. Requires:
- *mu initialized; no other concurrent operation on *mu. */
-GPRAPI void gpr_mu_destroy(gpr_mu *mu);
+ *mu initialized; no other concurrent operation on *mu. */
+GPRAPI void gpr_mu_destroy(gpr_mu* mu);
/** Wait until no thread has a lock on *mu, cause the calling thread to own an
exclusive lock on *mu, then return. May block indefinitely or crash if the
calling thread has a lock on *mu. Requires: *mu initialized. */
-GPRAPI void gpr_mu_lock(gpr_mu *mu);
+GPRAPI void gpr_mu_lock(gpr_mu* mu);
/** Release an exclusive lock on *mu held by the calling thread. Requires: *mu
initialized; the calling thread holds an exclusive lock on *mu. */
-GPRAPI void gpr_mu_unlock(gpr_mu *mu);
+GPRAPI void gpr_mu_unlock(gpr_mu* mu);
/** Without blocking, attempt to acquire an exclusive lock on *mu for the
calling thread, then return non-zero iff success. Fail, if any thread holds
the lock; succeeds with high probability if no thread holds the lock.
Requires: *mu initialized. */
-GPRAPI int gpr_mu_trylock(gpr_mu *mu);
+GPRAPI int gpr_mu_trylock(gpr_mu* mu);
/** --- Condition variable interface ---
@@ -62,11 +62,11 @@ GPRAPI int gpr_mu_trylock(gpr_mu *mu);
uninitialized when first declared. */
/** Initialize *cv. Requires: *cv uninitialized. */
-GPRAPI void gpr_cv_init(gpr_cv *cv);
+GPRAPI void gpr_cv_init(gpr_cv* cv);
/** Cause *cv no longer to be initialized, freeing any memory in use. Requires:
- *cv initialized; no other concurrent operation on *cv.*/
-GPRAPI void gpr_cv_destroy(gpr_cv *cv);
+ *cv initialized; no other concurrent operation on *cv.*/
+GPRAPI void gpr_cv_destroy(gpr_cv* cv);
/** Atomically release *mu and wait on *cv. When the calling thread is woken
from *cv or the deadline abs_deadline is exceeded, execute gpr_mu_lock(mu)
@@ -75,16 +75,16 @@ GPRAPI void gpr_cv_destroy(gpr_cv *cv);
an absolute deadline, or a GPR_TIMESPAN. May return even when not
woken explicitly. Requires: *mu and *cv initialized; the calling thread
holds an exclusive lock on *mu. */
-GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline);
+GPRAPI int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline);
/** If any threads are waiting on *cv, wake at least one.
Clients may treat this as an optimization of gpr_cv_broadcast()
for use in the case where waking more than one waiter is not useful.
Requires: *cv initialized. */
-GPRAPI void gpr_cv_signal(gpr_cv *cv);
+GPRAPI void gpr_cv_signal(gpr_cv* cv);
/** Wake all threads waiting on *cv. Requires: *cv initialized. */
-GPRAPI void gpr_cv_broadcast(gpr_cv *cv);
+GPRAPI void gpr_cv_broadcast(gpr_cv* cv);
/** --- One-time initialization ---
@@ -97,7 +97,7 @@ GPRAPI void gpr_cv_broadcast(gpr_cv *cv);
If multiple threads call gpr_once() on the same gpr_once instance, one of
them will call (*init_routine)(), and the others will block until that call
finishes.*/
-GPRAPI void gpr_once_init(gpr_once *once, void (*init_routine)(void));
+GPRAPI void gpr_once_init(gpr_once* once, void (*init_routine)(void));
/** --- One-time event notification ---
@@ -107,51 +107,51 @@ GPRAPI void gpr_once_init(gpr_once *once, void (*init_routine)(void));
It requires no destruction. */
/** Initialize *ev. */
-GPRAPI void gpr_event_init(gpr_event *ev);
+GPRAPI void gpr_event_init(gpr_event* ev);
/** Set *ev so that gpr_event_get() and gpr_event_wait() will return value.
Requires: *ev initialized; value != NULL; no prior or concurrent calls to
gpr_event_set(ev, ...) since initialization. */
-GPRAPI void gpr_event_set(gpr_event *ev, void *value);
+GPRAPI void gpr_event_set(gpr_event* ev, void* value);
/** Return the value set by gpr_event_set(ev, ...), or NULL if no such call has
completed. If the result is non-NULL, all operations that occurred prior to
the gpr_event_set(ev, ...) set will be visible after this call returns.
Requires: *ev initialized. This operation is faster than acquiring a mutex
on most platforms. */
-GPRAPI void *gpr_event_get(gpr_event *ev);
+GPRAPI void* gpr_event_get(gpr_event* ev);
/** Wait until *ev is set by gpr_event_set(ev, ...), or abs_deadline is
exceeded, then return gpr_event_get(ev). Requires: *ev initialized. Use
abs_deadline==gpr_inf_future for no deadline. When the event has been
signalled before the call, this operation is faster than acquiring a mutex
on most platforms. */
-GPRAPI void *gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline);
+GPRAPI void* gpr_event_wait(gpr_event* ev, gpr_timespec abs_deadline);
/** --- Reference counting ---
These calls act on the type gpr_refcount. It requires no destruction. */
/** Initialize *r to value n. */
-GPRAPI void gpr_ref_init(gpr_refcount *r, int n);
+GPRAPI void gpr_ref_init(gpr_refcount* r, int n);
/** Increment the reference count *r. Requires *r initialized. */
-GPRAPI void gpr_ref(gpr_refcount *r);
+GPRAPI void gpr_ref(gpr_refcount* r);
/** Increment the reference count *r. Requires *r initialized.
Crashes if refcount is zero */
-GPRAPI void gpr_ref_non_zero(gpr_refcount *r);
+GPRAPI void gpr_ref_non_zero(gpr_refcount* r);
/** Increment the reference count *r by n. Requires *r initialized, n > 0. */
-GPRAPI void gpr_refn(gpr_refcount *r, int n);
+GPRAPI void gpr_refn(gpr_refcount* r, int n);
/** Decrement the reference count *r and return non-zero iff it has reached
zero. . Requires *r initialized. */
-GPRAPI int gpr_unref(gpr_refcount *r);
+GPRAPI int gpr_unref(gpr_refcount* r);
/** Return non-zero iff the reference count of *r is one, and thus is owned
by exactly one object. */
-GPRAPI int gpr_ref_is_unique(gpr_refcount *r);
+GPRAPI int gpr_ref_is_unique(gpr_refcount* r);
/** --- Stats counters ---
@@ -162,13 +162,13 @@ GPRAPI int gpr_ref_is_unique(gpr_refcount *r);
synchronize other events. */
/** Initialize *c to the value n. */
-GPRAPI void gpr_stats_init(gpr_stats_counter *c, intptr_t n);
+GPRAPI void gpr_stats_init(gpr_stats_counter* c, intptr_t n);
/** *c += inc. Requires: *c initialized. */
-GPRAPI void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc);
+GPRAPI void gpr_stats_inc(gpr_stats_counter* c, intptr_t inc);
/** Return *c. Requires: *c initialized. */
-GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter *c);
+GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter* c);
/** ==================Example use of interface===================
A producer-consumer queue of up to N integers,
@@ -274,7 +274,23 @@ GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter *c);
#endif /* 0 */
#ifdef __cplusplus
-}
+} // extern "C"
+
+namespace grpc_core {
+
+class mu_guard {
+ public:
+ mu_guard(gpr_mu* mu) : mu_(mu) { gpr_mu_lock(mu); }
+ ~mu_guard() { gpr_mu_unlock(mu_); }
+
+ mu_guard(const mu_guard&) = delete;
+ mu_guard& operator=(const mu_guard&) = delete;
+
+ private:
+ gpr_mu* const mu_;
+};
+
+} // namespace grpc_core
#endif
#endif /* GRPC_SUPPORT_SYNC_H */
diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h
index 25bd8f1238..e9444e88c9 100644
--- a/include/grpc/support/thd.h
+++ b/include/grpc/support/thd.h
@@ -42,25 +42,28 @@ typedef struct {
/** Create a new thread running (*thd_body)(arg) and place its thread identifier
in *t, and return true. If there are insufficient resources, return false.
+ thd_name is the name of the thread for identification purposes on platforms
+ that support thread naming.
If options==NULL, default options are used.
The thread is immediately runnable, and exits when (*thd_body)() returns. */
-GPRAPI int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
- const gpr_thd_options *options);
+GPRAPI int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
+ void (*thd_body)(void* arg), void* arg,
+ const gpr_thd_options* options);
/** Return a gpr_thd_options struct with all fields set to defaults. */
GPRAPI gpr_thd_options gpr_thd_options_default(void);
/** Set the thread to become detached on startup - this is the default. */
-GPRAPI void gpr_thd_options_set_detached(gpr_thd_options *options);
+GPRAPI void gpr_thd_options_set_detached(gpr_thd_options* options);
/** Set the thread to become joinable - mutually exclusive with detached. */
-GPRAPI void gpr_thd_options_set_joinable(gpr_thd_options *options);
+GPRAPI void gpr_thd_options_set_joinable(gpr_thd_options* options);
/** Returns non-zero if the option detached is set. */
-GPRAPI int gpr_thd_options_is_detached(const gpr_thd_options *options);
+GPRAPI int gpr_thd_options_is_detached(const gpr_thd_options* options);
/** Returns non-zero if the option joinable is set. */
-GPRAPI int gpr_thd_options_is_joinable(const gpr_thd_options *options);
+GPRAPI int gpr_thd_options_is_joinable(const gpr_thd_options* options);
/** Returns the identifier of the current thread. */
GPRAPI gpr_thd_id gpr_thd_currentid(void);
diff --git a/include/grpc/support/tls.h b/include/grpc/support/tls.h
index 8519a8350b..4c9e79b6cf 100644
--- a/include/grpc/support/tls.h
+++ b/include/grpc/support/tls.h
@@ -32,6 +32,12 @@
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);
diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h
index e6d8c01447..b44f0f1c8c 100644
--- a/include/grpc/support/tls_gcc.h
+++ b/include/grpc/support/tls_gcc.h
@@ -26,44 +26,6 @@
/** Thread local storage based on gcc compiler primitives.
#include tls.h to use this - and see that file for documentation */
-#ifndef NDEBUG
-
-struct gpr_gcc_thread_local {
- intptr_t value;
- bool *inited;
-};
-
-#define GPR_TLS_DECL(name) \
- static bool name##_inited = false; \
- static __thread struct gpr_gcc_thread_local name = {0, &(name##_inited)}
-
-#define gpr_tls_init(tls) \
- do { \
- GPR_ASSERT(*((tls)->inited) == false); \
- *((tls)->inited) = true; \
- } while (0)
-
-/** It is allowed to call gpr_tls_init after gpr_tls_destroy is called. */
-#define gpr_tls_destroy(tls) \
- do { \
- GPR_ASSERT(*((tls)->inited)); \
- *((tls)->inited) = false; \
- } while (0)
-
-#define gpr_tls_set(tls, new_value) \
- do { \
- GPR_ASSERT(*((tls)->inited)); \
- (tls)->value = (new_value); \
- } while (0)
-
-#define gpr_tls_get(tls) \
- ({ \
- GPR_ASSERT(*((tls)->inited)); \
- (tls)->value; \
- })
-
-#else /* NDEBUG */
-
struct gpr_gcc_thread_local {
intptr_t value;
};
@@ -71,6 +33,11 @@ struct gpr_gcc_thread_local {
#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)
@@ -80,6 +47,4 @@ struct gpr_gcc_thread_local {
#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value))
#define gpr_tls_get(tls) ((tls)->value)
-#endif /* NDEBUG */
-
#endif /* GRPC_SUPPORT_TLS_GCC_H */
diff --git a/include/grpc/support/tls_msvc.h b/include/grpc/support/tls_msvc.h
index e5f2205fc1..68a411f5d4 100644
--- a/include/grpc/support/tls_msvc.h
+++ b/include/grpc/support/tls_msvc.h
@@ -26,9 +26,18 @@ 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)
diff --git a/include/grpc/support/tls_pthread.h b/include/grpc/support/tls_pthread.h
index a68b45569a..249c8b16f8 100644
--- a/include/grpc/support/tls_pthread.h
+++ b/include/grpc/support/tls_pthread.h
@@ -29,15 +29,24 @@ 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);
+intptr_t gpr_tls_set(struct gpr_pthread_thread_local* tls, intptr_t value);
#ifdef __cplusplus
}
#endif
diff --git a/package.json b/package.json
deleted file mode 100644
index 2e31275bf0..0000000000
--- a/package.json
+++ /dev/null
@@ -1,103 +0,0 @@
-{
- "name": "grpc",
- "version": "1.7.0-dev",
- "author": "Google Inc.",
- "description": "gRPC Library for Node",
- "homepage": "https://grpc.io/",
- "repository": {
- "type": "git",
- "url": "https://github.com/grpc/grpc.git"
- },
- "bugs": "https://github.com/grpc/grpc/issues",
- "contributors": [
- {
- "name": "Michael Lumish",
- "email": "mlumish@google.com"
- }
- ],
- "directories": {
- "lib": "src/node/src"
- },
- "scripts": {
- "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore",
- "test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
- "electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
- "gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
- "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
- "install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build --library=static_library"
- },
- "bundledDependencies": [
- "node-pre-gyp"
- ],
- "dependencies": {
- "arguejs": "^0.2.3",
- "lodash": "^4.15.0",
- "nan": "^2.0.0",
- "node-pre-gyp": "^0.6.35",
- "protobufjs": "^5.0.0"
- },
- "devDependencies": {
- "async": "^2.0.1",
- "body-parser": "^1.15.2",
- "electron-mocha": "^3.1.1",
- "express": "^4.14.0",
- "google-auth-library": "^0.9.2",
- "google-protobuf": "^3.0.0",
- "istanbul": "^0.4.4",
- "jsdoc": "^3.3.2",
- "jshint": "^2.5.0",
- "minimist": "^1.1.0",
- "mocha": "^3.0.2",
- "mocha-jenkins-reporter": "^0.2.3",
- "poisson-process": "^0.2.1"
- },
- "engines": {
- "node": ">=4"
- },
- "binary": {
- "module_name": "grpc_node",
- "module_path": "src/node/extension_binary/{node_abi}-{platform}-{arch}",
- "host": "https://storage.googleapis.com/",
- "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
- "package_name": "{node_abi}-{platform}-{arch}.tar.gz"
- },
- "files": [
- "LICENSE",
- "src/node/README.md",
- "src/proto",
- "etc",
- "src/node/index.js",
- "src/node/src",
- "src/node/ext",
- "include/grpc",
- "src/core",
- "src/boringssl",
- "src/zlib",
- "third_party/nanopb",
- "third_party/zlib",
- "third_party/boringssl",
- "binding.gyp"
- ],
- "main": "src/node/index.js",
- "license": "Apache-2.0",
- "jshintConfig": {
- "bitwise": true,
- "curly": true,
- "eqeqeq": true,
- "esnext": true,
- "freeze": true,
- "immed": true,
- "indent": 2,
- "latedef": "nofunc",
- "maxlen": 80,
- "mocha": true,
- "newcap": true,
- "node": true,
- "noarg": true,
- "quotmark": "single",
- "strict": true,
- "trailing": true,
- "undef": true,
- "unused": "vars"
- }
-}
diff --git a/package.xml b/package.xml
index 0eea122b24..b0814247c5 100644
--- a/package.xml
+++ b/package.xml
@@ -10,11 +10,11 @@
<email>grpc-packages@google.com</email>
<active>yes</active>
</lead>
- <date>2017-08-24</date>
+ <date>2018-01-19</date>
<time>16:06:07</time>
<version>
- <release>1.7.0dev</release>
- <api>1.7.0dev</api>
+ <release>1.10.0dev</release>
+ <api>1.10.0dev</api>
</version>
<stability>
<release>beta</release>
@@ -22,12 +22,7 @@
</stability>
<license>Apache 2.0</license>
<notes>
-- Channel are now by default persistent #11878
-- Some bug fixes from 1.4 branch #12109, #12123
-- Fixed hang bug when fork() was used #11814
-- License changed to Apache 2.0
-- Added support for php_namespace option in codegen plugin #11886
-- Updated gRPC C Core library version 1.6
+- TBD
</notes>
<contents>
<dir baseinstalldir="/" name="/">
@@ -64,7 +59,6 @@
<file baseinstalldir="/" name="include/grpc/support/avl.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/cmdline.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/cpu.h" role="src" />
- <file baseinstalldir="/" name="include/grpc/support/histogram.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/host_port.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/log.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/log_windows.h" role="src" />
@@ -87,6 +81,7 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_gcc_atomic.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_gcc_sync.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_windows.h" role="src" />
+ <file baseinstalldir="/" name="include/grpc/impl/codegen/fork.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_slice.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_types.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/port_platform.h" role="src" />
@@ -95,74 +90,72 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_generic.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_posix.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_windows.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/arena.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/env.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/fork.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/mpscq.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/murmur_hash.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/spinlock.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/string.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/string_windows.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/thd_internal.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/time_precise.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/tmpfile.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/abstract.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/atomic.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/atomic_with_atm.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/atomic_with_std.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/manual_constructor.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/memory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/arena.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/atomic.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/atomic_with_atm.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/atomic_with_std.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/backoff.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/block_annotate.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/env.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/memory.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/mpscq.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/murmur_hash.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/spinlock.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/stack_lockfree.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/string.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/string_windows.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/time_precise.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/tmpfile.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/profiling/basic_timers.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/profiling/stap_timers.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/alloc.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/arena.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/atm.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/avl.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/backoff.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/cmdline.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/cpu_iphone.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/cpu_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/cpu_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/cpu_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/env_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/env_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/env_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/histogram.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/host_port.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/log.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/log_android.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/log_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/log_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/log_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/mpscq.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/murmur_hash.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/stack_lockfree.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/string.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/string_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/string_util_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/string_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/subprocess_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/subprocess_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/sync.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/sync_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/sync_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/thd.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/thd_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/thd_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/time.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/time_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/time_precise.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/time_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/tls_pthread.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/tmpfile_msys.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/tmpfile_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/tmpfile_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/wrap_memcpy.c" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/alloc.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/arena.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/atm.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/avl.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/cmdline.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/cpu_iphone.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/cpu_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/cpu_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/cpu_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/env_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/env_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/env_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/fork.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/host_port.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/log.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/log_android.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/log_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/log_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/log_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/mpscq.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/murmur_hash.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/string.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/string_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/string_util_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/string_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/subprocess_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/subprocess_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/sync.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/sync_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/sync_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/thd.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/thd_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/thd_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/time.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/time_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/time_precise.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/time_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/tls_pthread.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/tmpfile_msys.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/tmpfile_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/tmpfile_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gpr/wrap_memcpy.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/profiling/basic_timers.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/profiling/stap_timers.cc" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/byte_buffer.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/byte_buffer_reader.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/compression_types.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/connectivity_state.h" role="src" />
- <file baseinstalldir="/" name="include/grpc/impl/codegen/exec_ctx_fwd.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/grpc_types.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/propagation_bits.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/slice.h" role="src" />
@@ -171,6 +164,7 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_gcc_atomic.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_gcc_sync.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_windows.h" role="src" />
+ <file baseinstalldir="/" name="include/grpc/impl/codegen/fork.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_slice.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_types.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/port_platform.h" role="src" />
@@ -183,6 +177,8 @@
<file baseinstalldir="/" name="include/grpc/byte_buffer.h" role="src" />
<file baseinstalldir="/" name="include/grpc/byte_buffer_reader.h" role="src" />
<file baseinstalldir="/" name="include/grpc/compression.h" role="src" />
+ <file baseinstalldir="/" name="include/grpc/compression_ruby.h" role="src" />
+ <file baseinstalldir="/" name="include/grpc/fork.h" role="src" />
<file baseinstalldir="/" name="include/grpc/grpc.h" role="src" />
<file baseinstalldir="/" name="include/grpc/grpc_posix.h" role="src" />
<file baseinstalldir="/" name="include/grpc/grpc_security_constants.h" role="src" />
@@ -195,6 +191,7 @@
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_decoder.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_encoder.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/chttp2_transport.h" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/flow_control.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_data.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_goaway.h" role="src" />
@@ -234,8 +231,8 @@
<file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/transport/tsi_error.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/util/json_util.h" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/alts_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/fake_transport_security.h" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/gts_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_types.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_grpc.h" role="src" />
@@ -243,6 +240,7 @@
<file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.h" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/backup_poller.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel_factory.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/connector.h" role="src" />
@@ -264,6 +262,7 @@
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/backoff/backoff.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.h" role="src" />
@@ -273,15 +272,22 @@
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_factory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/algorithm_metadata.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/compression_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/message_compress.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/stream_compression.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/stream_compression_gzip.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/stream_compression_identity.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/stats.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/stats_data.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/debug_location.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/inlined_vector.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/orphanable.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/ref_counted.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/gprpp/ref_counted_ptr.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/format_request.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/httpcli.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/http/parser.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/block_annotate.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/call_combiner.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/closure.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/combiner.h" role="src" />
@@ -393,293 +399,268 @@
<file baseinstalldir="/" name="third_party/nanopb/pb_decode.h" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_encode.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/subchannel_list.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/load_reporting/server_load_reporting_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/aggregation.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/base_resources.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/census_interface.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/census_rpc_stats.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/gen/trace_context.pb.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/grpc_filter.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/intrusive_hash_map.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/intrusive_hash_map_internal.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/mlog.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/resource.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/rpc_metric_id.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/trace_context.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/trace_label.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/trace_propagation.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/trace_status.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/trace_string.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/tracing.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/max_age/max_age_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/message_size/message_size_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_utils.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/init.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/channel_args.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/channel_stack.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/connected_channel.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/handshaker.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/handshaker_factory.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/compression/compression.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/compression/message_compress.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/compression/stream_compression.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/compression/stream_compression_gzip.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/compression/stream_compression_identity.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/debug/stats.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/debug/stats_data.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/http/format_request.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/http/httpcli.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/http/parser.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/call_combiner.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/closure.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/combiner.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/error.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/ev_epoll1_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/ev_epollex_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/ev_epollsig_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/ev_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/ev_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/exec_ctx.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/executor.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_fallback.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_host_name_max.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_sysconf.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/iocp_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/is_epollexclusive_available.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/load_file.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/lockfree_event.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/network_status_tracker.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/polling_entity.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_set_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_set_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/resource_quota.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/sockaddr_utils.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_factory_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_mutator.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_common_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_linux.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/socket_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_utils_posix_common.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_windows.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/time_averaged_stats.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/timer_generic.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/timer_heap.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/timer_manager.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/timer_uv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/udp_server.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/unix_sockets_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/unix_sockets_posix_noop.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_cv.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_eventfd.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_nospecial.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_pipe.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/json/json.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/json/json_reader.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/json/json_string.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/json/json_writer.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/b64.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/percent_encoding.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/slice.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/slice_buffer.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/slice_hash_table.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/slice_intern.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/alarm.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/api_trace.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/byte_buffer.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/byte_buffer_reader.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/call.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/call_details.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/call_log_batch.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/channel.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/channel_init.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/channel_ping.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/channel_stack_type.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/completion_queue.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/completion_queue_factory.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/event_string.c" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/init.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/backoff/backoff.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_args.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_stack.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/connected_channel.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/handshaker.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/handshaker_factory.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/compression.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/compression_internal.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/compression_ruby.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/message_compress.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/stream_compression.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/stream_compression_gzip.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/compression/stream_compression_identity.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/debug/stats.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/debug/stats_data.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/http/format_request.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/http/httpcli.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/http/parser.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/call_combiner.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/combiner.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/error.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/ev_epoll1_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/ev_epollex_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/ev_epollsig_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/ev_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/ev_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/exec_ctx.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/executor.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/fork_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/fork_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_fallback.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_host_name_max.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_sysconf.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/iocp_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/iomgr_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/is_epollexclusive_available.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/load_file.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/lockfree_event.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/network_status_tracker.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/polling_entity.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_set_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_set_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/pollset_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/resource_quota.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/sockaddr_utils.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_factory_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_mutator.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_common_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_linux.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_utils_posix_common.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_windows.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/time_averaged_stats.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/timer_generic.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/timer_heap.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/timer_manager.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/timer_uv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/udp_server.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/unix_sockets_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/unix_sockets_posix_noop.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_cv.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_eventfd.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_nospecial.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_pipe.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/wakeup_fd_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/json/json.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/json/json_reader.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/json/json_string.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/json/json_writer.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/b64.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/percent_encoding.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/slice.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/slice_buffer.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/slice_hash_table.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/slice_intern.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/alarm.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/api_trace.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/byte_buffer.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/byte_buffer_reader.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/call.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/call_details.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/call_log_batch.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/channel.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/channel_init.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/channel_ping.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/channel_stack_type.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/completion_queue.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/completion_queue_factory.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/event_string.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/lame_client.cc" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/metadata_array.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/server.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/validate_metadata.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/version.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/bdp_estimator.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/byte_stream.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/connectivity_state.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/error_utils.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/metadata.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/pid_controller.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/service_config.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/static_metadata.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/status_conversion.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/transport.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/transport/transport_op_string.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/debug/trace.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_decoder.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_encoder.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/chttp2_plugin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/chttp2_transport.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/flow_control.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_data.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_goaway.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_ping.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_rst_stream.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_settings.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_window_update.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_encoder.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_parser.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_table.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/http2_settings.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/huffsyms.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/incoming_metadata.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/parsing.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_lists.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_map.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/varint.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/writing.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/alpn/alpn.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/http/client/http_client_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/http/http_filters_plugin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/http/message_compress/message_compress_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/http/server/http_server_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/http/httpcli_security_connector.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/context/security_context.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/composite/composite_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/credentials_metadata.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/fake/fake_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/google_default/credentials_generic.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/google_default/google_default_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/iam/iam_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/jwt/json_token.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/jwt/jwt_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/jwt/jwt_verifier.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/oauth2/oauth2_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/plugin/plugin_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/credentials/ssl/ssl_credentials.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/client_auth_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/lb_targets_info.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/secure_endpoint.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/security_connector.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/server_auth_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/transport/tsi_error.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/security/util/json_util.c" role="src" />
- <file baseinstalldir="/" name="src/core/lib/surface/init_secure.c" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.c" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/gts_transport_security.c" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.c" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/transport_security_grpc.c" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/transport_security.c" role="src" />
- <file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/secure/secure_channel_create.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/channel_connectivity.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel_factory.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel_plugin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/connector.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_connect_handshaker.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_proxy.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy_factory.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy_registry.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/parse_address.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/proxy_mapper.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/proxy_mapper_registry.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_factory.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_registry.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/retry_throttle.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_plugin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/metadata_array.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/server.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/validate_metadata.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/version.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/bdp_estimator.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/byte_stream.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/connectivity_state.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/error_utils.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/metadata.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/pid_controller.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/service_config.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/static_metadata.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/status_conversion.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/transport.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/transport/transport_op_string.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/debug/trace.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_decoder.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_encoder.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/chttp2_plugin.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/chttp2_transport.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/flow_control.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_data.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_goaway.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_ping.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_rst_stream.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_settings.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/frame_window_update.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_encoder.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_parser.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_table.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/http2_settings.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/huffsyms.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/incoming_metadata.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/parsing.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_lists.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_map.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/varint.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/writing.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/alpn/alpn.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/http/client/http_client_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/http/http_filters_plugin.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/http/message_compress/message_compress_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/http/server/http_server_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/http/httpcli_security_connector.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/context/security_context.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/composite/composite_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/credentials_metadata.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/fake/fake_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/google_default/credentials_generic.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/google_default/google_default_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/iam/iam_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/jwt/json_token.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/jwt/jwt_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/jwt/jwt_verifier.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/oauth2/oauth2_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/plugin/plugin_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/credentials/ssl/ssl_credentials.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/client_auth_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/lb_targets_info.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/secure_endpoint.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/security_connector.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/security_handshaker.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/server_auth_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/transport/tsi_error.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/security/util/json_util.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/surface/init_secure.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/alts_transport_security.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/transport_security_grpc.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/transport_security.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/backup_poller.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/channel_connectivity.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel_factory.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel_plugin.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/connector.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_connect_handshaker.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_proxy.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy_factory.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy_registry.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/parse_address.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/proxy_mapper.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/proxy_mapper_registry.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_factory.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_registry.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/retry_throttle.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_plugin.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_decode.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_encode.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/load_reporting/server_load_reporting_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/load_reporting/server_load_reporting_plugin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/base_resources.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/context.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/gen/trace_context.pb.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/grpc_context.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/grpc_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/grpc_plugin.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/initialize.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/intrusive_hash_map.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/mlog.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/operation.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/placeholders.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/resource.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/trace_context.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/census/tracing.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/max_age/max_age_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/message_size/message_size_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_utils.c" role="src" />
- <file baseinstalldir="/" name="src/core/plugin_registry/grpc_plugin_registry.c" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/load_reporting/server_load_reporting_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/census/grpc_context.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/max_age/max_age_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/message_size/message_size_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_utils.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/plugin_registry/grpc_plugin_registry.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/aes/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/asn1/asn1_locl.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/bio/internal.h" role="src" />
diff --git a/requirements.txt b/requirements.txt
index 12969958ae..c976cef4cb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,6 @@ coverage>=4.0
cython>=0.23
enum34>=1.0.4
futures>=2.2.0
-protobuf>=3.2.0
+protobuf>=3.5.0.post1
six>=1.10
wheel>=0.29
diff --git a/setup.py b/setup.py
index 12882413ce..73af9ebc4a 100644
--- a/setup.py
+++ b/setup.py
@@ -40,10 +40,14 @@ ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),)
CARES_INCLUDE = (
os.path.join('third_party', 'cares'),
os.path.join('third_party', 'cares', 'cares'),)
-if 'linux' in sys.platform:
- CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_linux'),)
if 'darwin' in sys.platform:
CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_darwin'),)
+if 'freebsd' in sys.platform:
+ CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_freebsd'),)
+if 'linux' in sys.platform:
+ CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_linux'),)
+if 'openbsd' in sys.platform:
+ CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_openbsd'),)
README = os.path.join(PYTHON_STEM, 'README.rst')
# Ensure we're in the proper directory whether or not we're being used by pip.
@@ -110,8 +114,6 @@ if EXTRA_ENV_COMPILE_ARGS is None:
EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime32 -D_timeb=__timeb32 -D_ftime_s=_ftime32_s'
else:
EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime64 -D_timeb=__timeb64'
- elif 'win32' in sys.platform:
- EXTRA_ENV_COMPILE_ARGS += ' -D_PYTHON_MSVC'
elif "linux" in sys.platform:
EXTRA_ENV_COMPILE_ARGS += ' -std=c++11 -std=gnu99 -fvisibility=hidden -fno-wrapv -fno-exceptions'
elif "darwin" in sys.platform:
@@ -163,7 +165,7 @@ if "win32" in sys.platform:
# TODO(zyc): Re-enble c-ares on x64 and x86 windows after fixing the
# ares_library_init compilation issue
DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1), ('CARES_STATICLIB', 1),
- ('GRPC_ARES', 0),)
+ ('GRPC_ARES', 0), ('NTDDI_VERSION', 0x06000000),)
if '64bit' in platform.architecture()[0]:
DEFINE_MACROS += (('MS_WIN64', 1),)
elif sys.version_info >= (3, 5):
@@ -171,7 +173,7 @@ if "win32" in sys.platform:
# on msvc, but only for 32 bits
DEFINE_MACROS += (('NTDDI_VERSION', 0x06000000),)
else:
- DEFINE_MACROS += (('HAVE_CONFIG_H', 1),)
+ DEFINE_MACROS += (('HAVE_CONFIG_H', 1), ('GRPC_ENABLE_FORK_SUPPORT', 1),)
LDFLAGS = tuple(EXTRA_LINK_ARGS)
CFLAGS = tuple(EXTRA_COMPILE_ARGS)
@@ -179,6 +181,7 @@ if "linux" in sys.platform or "darwin" in sys.platform:
pymodinit_type = 'PyObject*' if PY3 else 'void'
pymodinit = '__attribute__((visibility ("default"))) {}'.format(pymodinit_type)
DEFINE_MACROS += (('PyMODINIT_FUNC', pymodinit),)
+ DEFINE_MACROS += (('GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK', 1),)
# By default, Python3 distutils enforces compatibility of
# c plugins (.so files) with the OSX version Python3 was built with.
@@ -235,7 +238,7 @@ INSTALL_REQUIRES = (
'six>=1.5.2',
# TODO(atash): eventually split the grpcio package into a metapackage
# depending on protobuf and the runtime component (independent of protobuf)
- 'protobuf>=3.3.0',
+ 'protobuf>=3.5.0.post1',
)
if not PY3:
diff --git a/src/c-ares/gen_build_yaml.py b/src/c-ares/gen_build_yaml.py
index 6f8b7485ac..4600d8d224 100755
--- a/src/c-ares/gen_build_yaml.py
+++ b/src/c-ares/gen_build_yaml.py
@@ -29,10 +29,14 @@ try:
subprocess.call("third_party/cares/cares/configure", shell=True)
def config_platform(x):
- if 'linux' in sys.platform:
- return 'src/cares/cares/config_linux/ares_config.h'
if 'darwin' in sys.platform:
return 'src/cares/cares/config_darwin/ares_config.h'
+ if 'freebsd' in sys.platform:
+ return 'src/cares/cares/config_freebsd/ares_config.h'
+ if 'linux' in sys.platform:
+ return 'src/cares/cares/config_linux/ares_config.h'
+ if 'openbsd' in sys.platform:
+ return 'src/cares/cares/config_openbsd/ares_config.h'
if not os.path.isfile('third_party/cares/cares/ares_config.h'):
gen_ares_build(x)
return 'third_party/cares/cares/ares_config.h'
@@ -124,8 +128,10 @@ try:
"third_party/cares/cares/config-win32.h",
"third_party/cares/cares/setup_once.h",
"third_party/cares/ares_build.h",
+ "third_party/cares/config_darwin/ares_config.h",
+ "third_party/cares/config_freebsd/ares_config.h",
"third_party/cares/config_linux/ares_config.h",
- "third_party/cares/config_darwin/ares_config.h"
+ "third_party/cares/config_openbsd/ares_config.h"
],
}]
except:
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index c2db8eff71..f35bfd9ab9 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -32,15 +32,15 @@ grpc::string as_string(T x) {
return out.str();
}
-inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
+inline bool ClientOnlyStreaming(const grpc_generator::Method* method) {
return method->ClientStreaming() && !method->ServerStreaming();
}
-inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
+inline bool ServerOnlyStreaming(const grpc_generator::Method* method) {
return !method->ClientStreaming() && method->ServerStreaming();
}
-grpc::string FilenameIdentifier(const grpc::string &filename) {
+grpc::string FilenameIdentifier(const grpc::string& filename) {
grpc::string result;
for (unsigned i = 0; i < filename.size(); i++) {
char c = filename[i];
@@ -58,19 +58,19 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
} // namespace
template <class T, size_t N>
-T *array_end(T (&array)[N]) {
+T* array_end(T (&array)[N]) {
return array + N;
}
-void PrintIncludes(grpc_generator::Printer *printer,
- const std::vector<grpc::string> &headers,
- const Parameters &params) {
+void PrintIncludes(grpc_generator::Printer* printer,
+ const std::vector<grpc::string>& headers,
+ const Parameters& params) {
std::map<grpc::string, grpc::string> vars;
vars["l"] = params.use_system_headers ? '<' : '"';
vars["r"] = params.use_system_headers ? '>' : '"';
- auto &s = params.grpc_search_path;
+ auto& s = params.grpc_search_path;
if (!s.empty()) {
vars["l"] += s;
if (s[s.size() - 1] != '/') {
@@ -84,8 +84,8 @@ void PrintIncludes(grpc_generator::Printer *printer,
}
}
-grpc::string GetHeaderPrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetHeaderPrologue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -104,7 +104,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File *file,
grpc::string leading_comments = file->GetLeadingComments("//");
if (!leading_comments.empty()) {
printer->Print(vars, "// Original file comments:\n");
- printer->Print(leading_comments.c_str());
+ printer->PrintRaw(leading_comments.c_str());
}
printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n");
printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");
@@ -116,15 +116,15 @@ grpc::string GetHeaderPrologue(grpc_generator::File *file,
return output;
}
-grpc::string GetHeaderIncludes(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetHeaderIncludes(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- static const char *headers_strs[] = {
+ static const char* headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/async_unary_call.h",
"grpc++/impl/codegen/method_handler_impl.h",
@@ -140,7 +140,6 @@ grpc::string GetHeaderIncludes(grpc_generator::File *file,
printer->Print(vars, "namespace grpc {\n");
printer->Print(vars, "class CompletionQueue;\n");
printer->Print(vars, "class Channel;\n");
- printer->Print(vars, "class RpcService;\n");
printer->Print(vars, "class ServerCompletionQueue;\n");
printer->Print(vars, "class ServerContext;\n");
printer->Print(vars, "} // namespace grpc\n\n");
@@ -159,8 +158,8 @@ grpc::string GetHeaderIncludes(grpc_generator::File *file,
}
void PrintHeaderClientMethodInterfaces(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars, bool is_public) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars, bool is_public) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -324,7 +323,8 @@ void PrintHeaderClientMethodInterfaces(
} else if (ServerOnlyStreaming(method)) {
printer->Print(
*vars,
- "virtual ::grpc::ClientReaderInterface< $Response$>* $Method$Raw("
+ "virtual ::grpc::ClientReaderInterface< $Response$>* "
+ "$Method$Raw("
"::grpc::ClientContext* context, const $Request$& request) = 0;\n");
for (auto async_prefix : async_prefixes) {
(*vars)["AsyncPrefix"] = async_prefix.prefix;
@@ -355,9 +355,9 @@ void PrintHeaderClientMethodInterfaces(
}
}
-void PrintHeaderClientMethod(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars,
+void PrintHeaderClientMethod(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars,
bool is_public) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
@@ -542,16 +542,17 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
}
}
-void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderClientMethodData(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
- printer->Print(*vars, "const ::grpc::RpcMethod rpcmethod_$Method$_;\n");
+ printer->Print(*vars,
+ "const ::grpc::internal::RpcMethod rpcmethod_$Method$_;\n");
}
-void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderServerMethodSync(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -583,9 +584,9 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
printer->Print(method->GetTrailingComments("//").c_str());
}
-void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -699,8 +700,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
}
void PrintHeaderServerMethodStreamedUnary(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -718,7 +719,7 @@ void PrintHeaderServerMethodStreamedUnary(
printer->Print(*vars,
"WithStreamedUnaryMethod_$Method$() {\n"
" ::grpc::Service::MarkMethodStreamed($Idx$,\n"
- " new ::grpc::StreamedUnaryHandler< $Request$, "
+ " new ::grpc::internal::StreamedUnaryHandler< $Request$, "
"$Response$>(std::bind"
"(&WithStreamedUnaryMethod_$Method$<BaseClass>::"
"Streamed$Method$, this, std::placeholders::_1, "
@@ -750,8 +751,8 @@ void PrintHeaderServerMethodStreamedUnary(
}
void PrintHeaderServerMethodSplitStreaming(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -766,15 +767,16 @@ void PrintHeaderServerMethodSplitStreaming(
"{}\n");
printer->Print(" public:\n");
printer->Indent();
- printer->Print(*vars,
- "WithSplitStreamingMethod_$Method$() {\n"
- " ::grpc::Service::MarkMethodStreamed($Idx$,\n"
- " new ::grpc::SplitServerStreamingHandler< $Request$, "
- "$Response$>(std::bind"
- "(&WithSplitStreamingMethod_$Method$<BaseClass>::"
- "Streamed$Method$, this, std::placeholders::_1, "
- "std::placeholders::_2)));\n"
- "}\n");
+ printer->Print(
+ *vars,
+ "WithSplitStreamingMethod_$Method$() {\n"
+ " ::grpc::Service::MarkMethodStreamed($Idx$,\n"
+ " new ::grpc::internal::SplitServerStreamingHandler< $Request$, "
+ "$Response$>(std::bind"
+ "(&WithSplitStreamingMethod_$Method$<BaseClass>::"
+ "Streamed$Method$, this, std::placeholders::_1, "
+ "std::placeholders::_2)));\n"
+ "}\n");
printer->Print(*vars,
"~WithSplitStreamingMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n"
@@ -802,8 +804,8 @@ void PrintHeaderServerMethodSplitStreaming(
}
void PrintHeaderServerMethodGeneric(
- grpc_generator::Printer *printer, const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+ grpc_generator::Printer* printer, const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -871,9 +873,9 @@ void PrintHeaderServerMethodGeneric(
printer->Print(*vars, "};\n");
}
-void PrintHeaderService(grpc_generator::Printer *printer,
- const grpc_generator::Service *service,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintHeaderService(grpc_generator::Printer* printer,
+ const grpc_generator::Service* service,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Service"] = service->name();
printer->Print(service->GetLeadingComments("//").c_str());
@@ -914,7 +916,8 @@ void PrintHeaderService(grpc_generator::Printer *printer,
" {\n public:\n");
printer->Indent();
printer->Print(
- "Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);\n");
+ "Stub(const std::shared_ptr< ::grpc::ChannelInterface>& "
+ "channel);\n");
for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderClientMethod(printer, service->method(i).get(), vars, true);
}
@@ -1047,8 +1050,8 @@ void PrintHeaderService(grpc_generator::Printer *printer,
printer->Print(service->GetTrailingComments("//").c_str());
}
-grpc::string GetHeaderServices(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetHeaderServices(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1078,8 +1081,8 @@ grpc::string GetHeaderServices(grpc_generator::File *file,
return output;
}
-grpc::string GetHeaderEpilogue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetHeaderEpilogue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1107,8 +1110,8 @@ grpc::string GetHeaderEpilogue(grpc_generator::File *file,
return output;
}
-grpc::string GetSourcePrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetSourcePrologue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1132,15 +1135,15 @@ grpc::string GetSourcePrologue(grpc_generator::File *file,
return output;
}
-grpc::string GetSourceIncludes(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetSourceIncludes(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- static const char *headers_strs[] = {
+ static const char* headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/async_unary_call.h",
"grpc++/impl/codegen/channel_interface.h",
@@ -1166,9 +1169,9 @@ grpc::string GetSourceIncludes(grpc_generator::File *file,
return output;
}
-void PrintSourceClientMethod(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintSourceClientMethod(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -1185,10 +1188,9 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response) {\n");
printer->Print(*vars,
- " return ::grpc::BlockingUnaryCall(channel_.get(), "
- "rpcmethod_$Method$_, "
- "context, request, response);\n"
- "}\n\n");
+ " return ::grpc::internal::BlockingUnaryCall"
+ "(channel_.get(), rpcmethod_$Method$_, "
+ "context, request, response);\n}\n\n");
for (auto async_prefix : async_prefixes) {
(*vars)["AsyncPrefix"] = async_prefix.prefix;
(*vars)["AsyncStart"] = async_prefix.start;
@@ -1198,25 +1200,27 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"ClientContext* context, "
"const $Request$& request, "
"::grpc::CompletionQueue* cq) {\n");
- printer->Print(*vars,
- " return "
- "::grpc::ClientAsyncResponseReader< $Response$>::Create("
- "channel_.get(), cq, "
- "rpcmethod_$Method$_, "
- "context, request, $AsyncStart$);\n"
- "}\n\n");
+ printer->Print(
+ *vars,
+ " return "
+ "::grpc::internal::ClientAsyncResponseReaderFactory< $Response$>"
+ "::Create(channel_.get(), cq, "
+ "rpcmethod_$Method$_, "
+ "context, request, $AsyncStart$);\n"
+ "}\n\n");
}
} else if (ClientOnlyStreaming(method)) {
printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* "
"$ns$$Service$::Stub::$Method$Raw("
"::grpc::ClientContext* context, $Response$* response) {\n");
- printer->Print(*vars,
- " return new ::grpc::ClientWriter< $Request$>("
- "channel_.get(), "
- "rpcmethod_$Method$_, "
- "context, response);\n"
- "}\n\n");
+ printer->Print(
+ *vars,
+ " return ::grpc::internal::ClientWriterFactory< $Request$>::Create("
+ "channel_.get(), "
+ "rpcmethod_$Method$_, "
+ "context, response);\n"
+ "}\n\n");
for (auto async_prefix : async_prefixes) {
(*vars)["AsyncPrefix"] = async_prefix.prefix;
(*vars)["AsyncStart"] = async_prefix.start;
@@ -1227,12 +1231,13 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw("
"::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n");
- printer->Print(*vars,
- " return ::grpc::ClientAsyncWriter< $Request$>::Create("
- "channel_.get(), cq, "
- "rpcmethod_$Method$_, "
- "context, response, $AsyncStart$$AsyncCreateArgs$);\n"
- "}\n\n");
+ printer->Print(
+ *vars,
+ " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>"
+ "::Create(channel_.get(), cq, "
+ "rpcmethod_$Method$_, "
+ "context, response, $AsyncStart$$AsyncCreateArgs$);\n"
+ "}\n\n");
}
} else if (ServerOnlyStreaming(method)) {
printer->Print(
@@ -1240,12 +1245,13 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"::grpc::ClientReader< $Response$>* "
"$ns$$Service$::Stub::$Method$Raw("
"::grpc::ClientContext* context, const $Request$& request) {\n");
- printer->Print(*vars,
- " return new ::grpc::ClientReader< $Response$>("
- "channel_.get(), "
- "rpcmethod_$Method$_, "
- "context, request);\n"
- "}\n\n");
+ printer->Print(
+ *vars,
+ " return ::grpc::internal::ClientReaderFactory< $Response$>::Create("
+ "channel_.get(), "
+ "rpcmethod_$Method$_, "
+ "context, request);\n"
+ "}\n\n");
for (auto async_prefix : async_prefixes) {
(*vars)["AsyncPrefix"] = async_prefix.prefix;
(*vars)["AsyncStart"] = async_prefix.start;
@@ -1257,12 +1263,13 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw("
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n");
- printer->Print(*vars,
- " return ::grpc::ClientAsyncReader< $Response$>::Create("
- "channel_.get(), cq, "
- "rpcmethod_$Method$_, "
- "context, request, $AsyncStart$$AsyncCreateArgs$);\n"
- "}\n\n");
+ printer->Print(
+ *vars,
+ " return ::grpc::internal::ClientAsyncReaderFactory< $Response$>"
+ "::Create(channel_.get(), cq, "
+ "rpcmethod_$Method$_, "
+ "context, request, $AsyncStart$$AsyncCreateArgs$);\n"
+ "}\n\n");
}
} else if (method->BidiStreaming()) {
printer->Print(
@@ -1270,8 +1277,8 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"::grpc::ClientReaderWriter< $Request$, $Response$>* "
"$ns$$Service$::Stub::$Method$Raw(::grpc::ClientContext* context) {\n");
printer->Print(*vars,
- " return new ::grpc::ClientReaderWriter< "
- "$Request$, $Response$>("
+ " return ::grpc::internal::ClientReaderWriterFactory< "
+ "$Request$, $Response$>::Create("
"channel_.get(), "
"rpcmethod_$Method$_, "
"context);\n"
@@ -1286,21 +1293,21 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
"$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(::grpc::"
"ClientContext* context, "
"::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n");
- printer->Print(
- *vars,
- " return "
- "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>::Create("
- "channel_.get(), cq, "
- "rpcmethod_$Method$_, "
- "context, $AsyncStart$$AsyncCreateArgs$);\n"
- "}\n\n");
+ printer->Print(*vars,
+ " return "
+ "::grpc::internal::ClientAsyncReaderWriterFactory< "
+ "$Request$, $Response$>::Create("
+ "channel_.get(), cq, "
+ "rpcmethod_$Method$_, "
+ "context, $AsyncStart$$AsyncCreateArgs$);\n"
+ "}\n\n");
}
}
}
-void PrintSourceServerMethod(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintSourceServerMethod(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -1357,9 +1364,9 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer,
}
}
-void PrintSourceService(grpc_generator::Printer *printer,
- const grpc_generator::Service *service,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintSourceService(grpc_generator::Printer* printer,
+ const grpc_generator::Service* service,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Service"] = service->name();
if (service->method_count() > 0) {
@@ -1376,6 +1383,7 @@ void PrintSourceService(grpc_generator::Printer *printer,
"std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub("
"const std::shared_ptr< ::grpc::ChannelInterface>& channel, "
"const ::grpc::StubOptions& options) {\n"
+ " (void)options;\n"
" std::unique_ptr< $ns$$Service$::Stub> stub(new "
"$ns$$Service$::Stub(channel));\n"
" return stub;\n"
@@ -1404,7 +1412,7 @@ void PrintSourceService(grpc_generator::Printer *printer,
printer->Print(*vars,
", rpcmethod_$Method$_("
"$prefix$$Service$_method_names[$Idx$], "
- "::grpc::RpcMethod::$StreamingType$, "
+ "::grpc::internal::RpcMethod::$StreamingType$, "
"channel"
")\n");
}
@@ -1427,38 +1435,38 @@ void PrintSourceService(grpc_generator::Printer *printer,
if (method->NoStreaming()) {
printer->Print(
*vars,
- "AddMethod(new ::grpc::RpcServiceMethod(\n"
+ "AddMethod(new ::grpc::internal::RpcServiceMethod(\n"
" $prefix$$Service$_method_names[$Idx$],\n"
- " ::grpc::RpcMethod::NORMAL_RPC,\n"
- " new ::grpc::RpcMethodHandler< $ns$$Service$::Service, "
+ " ::grpc::internal::RpcMethod::NORMAL_RPC,\n"
+ " new ::grpc::internal::RpcMethodHandler< $ns$$Service$::Service, "
"$Request$, "
"$Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
} else if (ClientOnlyStreaming(method.get())) {
printer->Print(
*vars,
- "AddMethod(new ::grpc::RpcServiceMethod(\n"
+ "AddMethod(new ::grpc::internal::RpcServiceMethod(\n"
" $prefix$$Service$_method_names[$Idx$],\n"
- " ::grpc::RpcMethod::CLIENT_STREAMING,\n"
- " new ::grpc::ClientStreamingHandler< "
+ " ::grpc::internal::RpcMethod::CLIENT_STREAMING,\n"
+ " new ::grpc::internal::ClientStreamingHandler< "
"$ns$$Service$::Service, $Request$, $Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
} else if (ServerOnlyStreaming(method.get())) {
printer->Print(
*vars,
- "AddMethod(new ::grpc::RpcServiceMethod(\n"
+ "AddMethod(new ::grpc::internal::RpcServiceMethod(\n"
" $prefix$$Service$_method_names[$Idx$],\n"
- " ::grpc::RpcMethod::SERVER_STREAMING,\n"
- " new ::grpc::ServerStreamingHandler< "
+ " ::grpc::internal::RpcMethod::SERVER_STREAMING,\n"
+ " new ::grpc::internal::ServerStreamingHandler< "
"$ns$$Service$::Service, $Request$, $Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
} else if (method->BidiStreaming()) {
printer->Print(
*vars,
- "AddMethod(new ::grpc::RpcServiceMethod(\n"
+ "AddMethod(new ::grpc::internal::RpcServiceMethod(\n"
" $prefix$$Service$_method_names[$Idx$],\n"
- " ::grpc::RpcMethod::BIDI_STREAMING,\n"
- " new ::grpc::BidiStreamingHandler< "
+ " ::grpc::internal::RpcMethod::BIDI_STREAMING,\n"
+ " new ::grpc::internal::BidiStreamingHandler< "
"$ns$$Service$::Service, $Request$, $Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
}
@@ -1474,8 +1482,8 @@ void PrintSourceService(grpc_generator::Printer *printer,
}
}
-grpc::string GetSourceServices(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetSourceServices(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1503,8 +1511,8 @@ grpc::string GetSourceServices(grpc_generator::File *file,
return output;
}
-grpc::string GetSourceEpilogue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetSourceEpilogue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string temp;
if (!file->package().empty()) {
@@ -1522,8 +1530,8 @@ grpc::string GetSourceEpilogue(grpc_generator::File *file,
}
// TODO(mmukhi): Make sure we need parameters or not.
-grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetMockPrologue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1549,21 +1557,35 @@ grpc::string GetMockPrologue(grpc_generator::File *file,
}
// TODO(mmukhi): Add client-stream and completion-queue headers.
-grpc::string GetMockIncludes(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetMockIncludes(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- static const char *headers_strs[] = {
+ static const char* headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
- "grpc++/impl/codegen/sync_stream.h", "gmock/gmock.h",
+ "grpc++/impl/codegen/sync_stream.h",
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(printer.get(), headers, params);
+ std::vector<grpc::string> gmock_header;
+ if (params.gmock_search_path.empty()) {
+ gmock_header.push_back("gmock/gmock.h");
+ PrintIncludes(printer.get(), gmock_header, params);
+ } else {
+ gmock_header.push_back("gmock.h");
+ // Copy a params to generate gmock header.
+ Parameters gmock_params(params);
+ // We use local includes when a gmock_search_path is given
+ gmock_params.use_system_headers = false;
+ gmock_params.grpc_search_path = params.gmock_search_path;
+ PrintIncludes(printer.get(), gmock_header, gmock_params);
+ }
+
if (!file->package().empty()) {
std::vector<grpc::string> parts = file->package_parts();
@@ -1578,9 +1600,9 @@ grpc::string GetMockIncludes(grpc_generator::File *file,
return output;
}
-void PrintMockClientMethods(grpc_generator::Printer *printer,
- const grpc_generator::Method *method,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintMockClientMethods(grpc_generator::Printer* printer,
+ const grpc_generator::Method* method,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
@@ -1661,9 +1683,9 @@ void PrintMockClientMethods(grpc_generator::Printer *printer,
}
}
-void PrintMockService(grpc_generator::Printer *printer,
- const grpc_generator::Service *service,
- std::map<grpc::string, grpc::string> *vars) {
+void PrintMockService(grpc_generator::Printer* printer,
+ const grpc_generator::Service* service,
+ std::map<grpc::string, grpc::string>* vars) {
(*vars)["Service"] = service->name();
printer->Print(*vars,
@@ -1677,8 +1699,8 @@ void PrintMockService(grpc_generator::Printer *printer,
printer->Print("};\n");
}
-grpc::string GetMockServices(grpc_generator::File *file,
- const Parameters &params) {
+grpc::string GetMockServices(grpc_generator::File* file,
+ const Parameters& params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1708,8 +1730,8 @@ grpc::string GetMockServices(grpc_generator::File *file,
return output;
}
-grpc::string GetMockEpilogue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+grpc::string GetMockEpilogue(grpc_generator::File* file,
+ const Parameters& /*params*/) {
grpc::string temp;
if (!file->package().empty()) {
diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h
index 73f9fc662c..300a27c589 100644
--- a/src/compiler/cpp_generator.h
+++ b/src/compiler/cpp_generator.h
@@ -50,73 +50,75 @@ struct Parameters {
bool use_system_headers;
// Prefix to any grpc include
grpc::string grpc_search_path;
- // Generate GMOCK code to facilitate unit testing.
+ // Generate Google Mock code to facilitate unit testing.
bool generate_mock_code;
+ // Google Mock search path, when non-empty, local includes will be used.
+ grpc::string gmock_search_path;
};
// Return the prologue of the generated header file.
-grpc::string GetHeaderPrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderPrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated header file.
-grpc::string GetHeaderIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated source file.
-grpc::string GetSourceIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourceIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of the generated header file.
-grpc::string GetHeaderEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderEpilogue(grpc_generator::File* file,
+ const Parameters& params);
// Return the prologue of the generated source file.
-grpc::string GetSourcePrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourcePrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated header file.
-grpc::string GetHeaderServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetHeaderServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated source file.
-grpc::string GetSourceServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourceServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of the generated source file.
-grpc::string GetSourceEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetSourceEpilogue(grpc_generator::File* file,
+ const Parameters& params);
// Return the prologue of the generated mock file.
-grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockPrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated mock file.
-grpc::string GetMockIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated mock file.
-grpc::string GetMockServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of generated mock file.
-grpc::string GetMockEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockEpilogue(grpc_generator::File* file,
+ const Parameters& params);
// Return the prologue of the generated mock file.
-grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockPrologue(grpc_generator::File* file,
+ const Parameters& params);
// Return the includes needed for generated mock file.
-grpc::string GetMockIncludes(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockIncludes(grpc_generator::File* file,
+ const Parameters& params);
// Return the services for generated mock file.
-grpc::string GetMockServices(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockServices(grpc_generator::File* file,
+ const Parameters& params);
// Return the epilogue of generated mock file.
-grpc::string GetMockEpilogue(grpc_generator::File *file,
- const Parameters &params);
+grpc::string GetMockEpilogue(grpc_generator::File* file,
+ const Parameters& params);
} // namespace grpc_cpp_generator
diff --git a/src/compiler/cpp_generator_helpers.h b/src/compiler/cpp_generator_helpers.h
index 28606d46b8..b8efcbdb84 100644
--- a/src/compiler/cpp_generator_helpers.h
+++ b/src/compiler/cpp_generator_helpers.h
@@ -26,22 +26,22 @@
namespace grpc_cpp_generator {
-inline grpc::string DotsToColons(const grpc::string &name) {
+inline grpc::string DotsToColons(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "::");
}
-inline grpc::string DotsToUnderscores(const grpc::string &name) {
+inline grpc::string DotsToUnderscores(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "_");
}
-inline grpc::string ClassName(const grpc::protobuf::Descriptor *descriptor,
+inline grpc::string ClassName(const grpc::protobuf::Descriptor* descriptor,
bool qualified) {
// Find "outer", the descriptor of the top-level message in which
// "descriptor" is embedded.
- const grpc::protobuf::Descriptor *outer = descriptor;
+ const grpc::protobuf::Descriptor* outer = descriptor;
while (outer->containing_type() != NULL) outer = outer->containing_type();
- const grpc::string &outer_name = outer->full_name();
+ const grpc::string& outer_name = outer->full_name();
grpc::string inner_name = descriptor->full_name().substr(outer_name.size());
if (qualified) {
@@ -54,7 +54,7 @@ inline grpc::string ClassName(const grpc::protobuf::Descriptor *descriptor,
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetCppComments(const DescriptorType *desc, bool leading) {
+inline grpc::string GetCppComments(const DescriptorType* desc, bool leading) {
return grpc_generator::GetPrefixedComments(desc, leading, "//");
}
diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc
index ebe3aa3860..661282f880 100644
--- a/src/compiler/cpp_plugin.cc
+++ b/src/compiler/cpp_plugin.cc
@@ -33,10 +33,10 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
CppGrpcGenerator() {}
virtual ~CppGrpcGenerator() {}
- virtual bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ virtual bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
if (file->options().cc_generic_services()) {
*error =
"cpp grpc proto compiler plugin does not work with generic "
@@ -78,6 +78,8 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
*error = grpc::string("Invalid parameter: ") + *parameter_string;
return false;
}
+ } else if (param[0] == "gmock_search_path") {
+ generator_parameters.gmock_search_path = param[1];
} else {
*error = grpc::string("Unknown parameter: ") + *parameter_string;
return false;
@@ -125,9 +127,9 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
private:
// Insert the given code into the given file at the given insertion point.
- void Insert(grpc::protobuf::compiler::GeneratorContext *context,
- const grpc::string &filename, const grpc::string &insertion_point,
- const grpc::string &code) const {
+ void Insert(grpc::protobuf::compiler::GeneratorContext* context,
+ const grpc::string& filename, const grpc::string& insertion_point,
+ const grpc::string& code) const {
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->OpenForInsert(filename, insertion_point));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
@@ -135,7 +137,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
CppGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index bc3b0f24cd..7c97056402 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -23,24 +23,23 @@
#include "src/compiler/config.h"
#include "src/compiler/csharp_generator.h"
-#include "src/compiler/csharp_generator.h"
#include "src/compiler/csharp_generator_helpers.h"
-using google::protobuf::compiler::csharp::GetFileNamespace;
using google::protobuf::compiler::csharp::GetClassName;
+using google::protobuf::compiler::csharp::GetFileNamespace;
using google::protobuf::compiler::csharp::GetReflectionClassName;
-using grpc::protobuf::FileDescriptor;
using grpc::protobuf::Descriptor;
-using grpc::protobuf::ServiceDescriptor;
+using grpc::protobuf::FileDescriptor;
using grpc::protobuf::MethodDescriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
-using grpc_generator::MethodType;
using grpc_generator::GetMethodType;
-using grpc_generator::METHODTYPE_NO_STREAMING;
+using grpc_generator::METHODTYPE_BIDI_STREAMING;
using grpc_generator::METHODTYPE_CLIENT_STREAMING;
+using grpc_generator::METHODTYPE_NO_STREAMING;
using grpc_generator::METHODTYPE_SERVER_STREAMING;
-using grpc_generator::METHODTYPE_BIDI_STREAMING;
+using grpc_generator::MethodType;
using grpc_generator::StringReplace;
using std::map;
using std::vector;
@@ -53,7 +52,7 @@ namespace {
// Currently, we cannot easily reuse the functionality as
// google/protobuf/compiler/csharp/csharp_doc_comment.h is not a public header.
// TODO(jtattermusch): reuse the functionality from google/protobuf.
-bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer *printer,
+bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer* printer,
grpc::protobuf::SourceLocation location) {
grpc::string comments = location.leading_comments.empty()
? location.trailing_comments
@@ -100,8 +99,8 @@ bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer *printer,
}
template <typename DescriptorType>
-bool GenerateDocCommentBody(grpc::protobuf::io::Printer *printer,
- const DescriptorType *descriptor) {
+bool GenerateDocCommentBody(grpc::protobuf::io::Printer* printer,
+ const DescriptorType* descriptor) {
grpc::protobuf::SourceLocation location;
if (!descriptor->GetSourceLocation(&location)) {
return false;
@@ -109,8 +108,8 @@ bool GenerateDocCommentBody(grpc::protobuf::io::Printer *printer,
return GenerateDocCommentBodyImpl(printer, location);
}
-void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer *printer,
- const MethodDescriptor *method) {
+void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer* printer,
+ const MethodDescriptor* method) {
if (GenerateDocCommentBody(printer, method)) {
if (method->client_streaming()) {
printer->Print(
@@ -141,8 +140,8 @@ void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer *printer,
}
}
-void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer *printer,
- const MethodDescriptor *method,
+void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer* printer,
+ const MethodDescriptor* method,
bool is_sync, bool use_call_options) {
if (GenerateDocCommentBody(printer, method)) {
if (!method->client_streaming()) {
@@ -173,15 +172,15 @@ void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer *printer,
}
}
-std::string GetServiceClassName(const ServiceDescriptor *service) {
+std::string GetServiceClassName(const ServiceDescriptor* service) {
return service->name();
}
-std::string GetClientClassName(const ServiceDescriptor *service) {
+std::string GetClientClassName(const ServiceDescriptor* service) {
return service->name() + "Client";
}
-std::string GetServerClassName(const ServiceDescriptor *service) {
+std::string GetServerClassName(const ServiceDescriptor* service) {
return service->name() + "Base";
}
@@ -202,15 +201,15 @@ std::string GetCSharpMethodType(MethodType method_type) {
std::string GetServiceNameFieldName() { return "__ServiceName"; }
-std::string GetMarshallerFieldName(const Descriptor *message) {
+std::string GetMarshallerFieldName(const Descriptor* message) {
return "__Marshaller_" + message->name();
}
-std::string GetMethodFieldName(const MethodDescriptor *method) {
+std::string GetMethodFieldName(const MethodDescriptor* method) {
return "__Method_" + method->name();
}
-std::string GetMethodRequestParamMaybe(const MethodDescriptor *method,
+std::string GetMethodRequestParamMaybe(const MethodDescriptor* method,
bool invocation_param = false) {
if (method->client_streaming()) {
return "";
@@ -225,7 +224,7 @@ std::string GetAccessLevel(bool internal_access) {
return internal_access ? "internal" : "public";
}
-std::string GetMethodReturnTypeClient(const MethodDescriptor *method) {
+std::string GetMethodReturnTypeClient(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
return "grpc::AsyncUnaryCall<" + GetClassName(method->output_type()) +
@@ -246,7 +245,7 @@ std::string GetMethodReturnTypeClient(const MethodDescriptor *method) {
return "";
}
-std::string GetMethodRequestParamServer(const MethodDescriptor *method) {
+std::string GetMethodRequestParamServer(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
case METHODTYPE_SERVER_STREAMING:
@@ -260,7 +259,7 @@ std::string GetMethodRequestParamServer(const MethodDescriptor *method) {
return "";
}
-std::string GetMethodReturnTypeServer(const MethodDescriptor *method) {
+std::string GetMethodReturnTypeServer(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
case METHODTYPE_CLIENT_STREAMING:
@@ -274,7 +273,7 @@ std::string GetMethodReturnTypeServer(const MethodDescriptor *method) {
return "";
}
-std::string GetMethodResponseStreamMaybe(const MethodDescriptor *method) {
+std::string GetMethodResponseStreamMaybe(const MethodDescriptor* method) {
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
case METHODTYPE_CLIENT_STREAMING:
@@ -289,13 +288,13 @@ std::string GetMethodResponseStreamMaybe(const MethodDescriptor *method) {
}
// Gets vector of all messages used as input or output types.
-std::vector<const Descriptor *> GetUsedMessages(
- const ServiceDescriptor *service) {
- std::set<const Descriptor *> descriptor_set;
- std::vector<const Descriptor *>
+std::vector<const Descriptor*> GetUsedMessages(
+ const ServiceDescriptor* service) {
+ std::set<const Descriptor*> descriptor_set;
+ std::vector<const Descriptor*>
result; // vector is to maintain stable ordering
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
if (descriptor_set.find(method->input_type()) == descriptor_set.end()) {
descriptor_set.insert(method->input_type());
result.push_back(method->input_type());
@@ -308,10 +307,10 @@ std::vector<const Descriptor *> GetUsedMessages(
return result;
}
-void GenerateMarshallerFields(Printer *out, const ServiceDescriptor *service) {
- std::vector<const Descriptor *> used_messages = GetUsedMessages(service);
+void GenerateMarshallerFields(Printer* out, const ServiceDescriptor* service) {
+ std::vector<const Descriptor*> used_messages = GetUsedMessages(service);
for (size_t i = 0; i < used_messages.size(); i++) {
- const Descriptor *message = used_messages[i];
+ const Descriptor* message = used_messages[i];
out->Print(
"static readonly grpc::Marshaller<$type$> $fieldname$ = "
"grpc::Marshallers.Create((arg) => "
@@ -323,7 +322,7 @@ void GenerateMarshallerFields(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateStaticMethodField(Printer *out, const MethodDescriptor *method) {
+void GenerateStaticMethodField(Printer* out, const MethodDescriptor* method) {
out->Print(
"static readonly grpc::Method<$request$, $response$> $fieldname$ = new "
"grpc::Method<$request$, $response$>(\n",
@@ -346,8 +345,8 @@ void GenerateStaticMethodField(Printer *out, const MethodDescriptor *method) {
out->Outdent();
}
-void GenerateServiceDescriptorProperty(Printer *out,
- const ServiceDescriptor *service) {
+void GenerateServiceDescriptorProperty(Printer* out,
+ const ServiceDescriptor* service) {
std::ostringstream index;
index << service->index();
out->Print("/// <summary>Service descriptor</summary>\n");
@@ -362,7 +361,7 @@ void GenerateServiceDescriptorProperty(Printer *out,
out->Print("\n");
}
-void GenerateServerClass(Printer *out, const ServiceDescriptor *service) {
+void GenerateServerClass(Printer* out, const ServiceDescriptor* service) {
out->Print(
"/// <summary>Base class for server-side implementations of "
"$servicename$</summary>\n",
@@ -372,7 +371,7 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) {
out->Print("{\n");
out->Indent();
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
GenerateDocCommentServerMethod(out, method);
out->Print(
"public virtual $returntype$ "
@@ -395,7 +394,7 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateClientStub(Printer *out, const ServiceDescriptor *service) {
+void GenerateClientStub(Printer* out, const ServiceDescriptor* service) {
out->Print("/// <summary>Client for $servicename$</summary>\n", "servicename",
GetServiceClassName(service));
out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name",
@@ -443,7 +442,7 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) {
out->Print("}\n\n");
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
MethodType method_type = GetMethodType(method);
if (method_type == METHODTYPE_NO_STREAMING) {
@@ -573,7 +572,7 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) {
+void GenerateBindServiceMethod(Printer* out, const ServiceDescriptor* service) {
out->Print(
"/// <summary>Creates service definition that can be registered with a "
"server</summary>\n");
@@ -591,7 +590,7 @@ void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) {
out->Indent();
out->Indent();
for (int i = 0; i < service->method_count(); i++) {
- const MethodDescriptor *method = service->method(i);
+ const MethodDescriptor* method = service->method(i);
out->Print(".AddMethod($methodfield$, serviceImpl.$methodname$)",
"methodfield", GetMethodFieldName(method), "methodname",
method->name());
@@ -608,7 +607,7 @@ void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateService(Printer *out, const ServiceDescriptor *service,
+void GenerateService(Printer* out, const ServiceDescriptor* service,
bool generate_client, bool generate_server,
bool internal_access) {
GenerateDocCommentBody(out, service);
@@ -644,7 +643,7 @@ void GenerateService(Printer *out, const ServiceDescriptor *service,
} // anonymous namespace
-grpc::string GetServices(const FileDescriptor *file, bool generate_client,
+grpc::string GetServices(const FileDescriptor* file, bool generate_client,
bool generate_server, bool internal_access) {
grpc::string output;
{
@@ -660,14 +659,17 @@ grpc::string GetServices(const FileDescriptor *file, bool generate_client,
}
// Write out a file header.
- out.Print("// Generated by the protocol buffer compiler. DO NOT EDIT!\n");
- out.Print("// source: $filename$\n", "filename", file->name());
+ out.Print("// <auto-generated>\n");
+ out.Print(
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n");
+ out.Print("// source: $filename$\n", "filename", file->name());
+ out.Print("// </auto-generated>\n");
// use C++ style as there are no file-level XML comments in .NET
grpc::string leading_comments = GetCsharpComments(file, true);
if (!leading_comments.empty()) {
out.Print("// Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
out.Print("#pragma warning disable 1591\n");
diff --git a/src/compiler/csharp_generator.h b/src/compiler/csharp_generator.h
index 0eca292870..fd36e11851 100644
--- a/src/compiler/csharp_generator.h
+++ b/src/compiler/csharp_generator.h
@@ -25,7 +25,7 @@
namespace grpc_csharp_generator {
-grpc::string GetServices(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetServices(const grpc::protobuf::FileDescriptor* file,
bool generate_client, bool generate_server,
bool internal_access);
diff --git a/src/compiler/csharp_generator_helpers.h b/src/compiler/csharp_generator_helpers.h
index bdf10dfc74..8c89925551 100644
--- a/src/compiler/csharp_generator_helpers.h
+++ b/src/compiler/csharp_generator_helpers.h
@@ -24,8 +24,8 @@
namespace grpc_csharp_generator {
-inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
- grpc::string *file_name_or_error) {
+inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file,
+ grpc::string* file_name_or_error) {
*file_name_or_error =
grpc_generator::FileNameInUpperCamel(file, false) + "Grpc.cs";
return true;
@@ -34,7 +34,7 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetCsharpComments(const DescriptorType *desc,
+inline grpc::string GetCsharpComments(const DescriptorType* desc,
bool leading) {
return grpc_generator::GetPrefixedComments(desc, leading, "//");
}
diff --git a/src/compiler/csharp_plugin.cc b/src/compiler/csharp_plugin.cc
index 224a89c0d9..5f13aa6749 100644
--- a/src/compiler/csharp_plugin.cc
+++ b/src/compiler/csharp_plugin.cc
@@ -29,10 +29,10 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
CSharpGrpcGenerator() {}
~CSharpGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
std::vector<std::pair<grpc::string, grpc::string> > options;
grpc::protobuf::compiler::ParseGeneratorParameter(parameter, &options);
@@ -71,7 +71,7 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
CSharpGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index e7005d84b0..747096f065 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -29,7 +29,7 @@
namespace grpc_generator {
-inline bool StripSuffix(grpc::string *filename, const grpc::string &suffix) {
+inline bool StripSuffix(grpc::string* filename, const grpc::string& suffix) {
if (filename->length() >= suffix.length()) {
size_t suffix_pos = filename->length() - suffix.length();
if (filename->compare(suffix_pos, grpc::string::npos, suffix) == 0) {
@@ -41,7 +41,7 @@ inline bool StripSuffix(grpc::string *filename, const grpc::string &suffix) {
return false;
}
-inline bool StripPrefix(grpc::string *name, const grpc::string &prefix) {
+inline bool StripPrefix(grpc::string* name, const grpc::string& prefix) {
if (name->length() >= prefix.length()) {
if (name->substr(0, prefix.size()) == prefix) {
*name = name->substr(prefix.size());
@@ -58,8 +58,8 @@ inline grpc::string StripProto(grpc::string filename) {
return filename;
}
-inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
- const grpc::string &to, bool replace_all) {
+inline grpc::string StringReplace(grpc::string str, const grpc::string& from,
+ const grpc::string& to, bool replace_all) {
size_t pos = 0;
do {
@@ -74,13 +74,13 @@ inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
return str;
}
-inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
- const grpc::string &to) {
+inline grpc::string StringReplace(grpc::string str, const grpc::string& from,
+ const grpc::string& to) {
return StringReplace(str, from, to, true);
}
-inline std::vector<grpc::string> tokenize(const grpc::string &input,
- const grpc::string &delimiters) {
+inline std::vector<grpc::string> tokenize(const grpc::string& input,
+ const grpc::string& delimiters) {
std::vector<grpc::string> tokens;
size_t pos, last_pos = 0;
@@ -125,7 +125,7 @@ inline grpc::string LowerUnderscoreToUpperCamel(grpc::string str) {
}
inline grpc::string FileNameInUpperCamel(
- const grpc::protobuf::FileDescriptor *file, bool include_package_path) {
+ const grpc::protobuf::FileDescriptor* file, bool include_package_path) {
std::vector<grpc::string> tokens = tokenize(StripProto(file->name()), "/");
grpc::string result = "";
if (include_package_path) {
@@ -138,7 +138,7 @@ inline grpc::string FileNameInUpperCamel(
}
inline grpc::string FileNameInUpperCamel(
- const grpc::protobuf::FileDescriptor *file) {
+ const grpc::protobuf::FileDescriptor* file) {
return FileNameInUpperCamel(file, true);
}
@@ -150,7 +150,7 @@ enum MethodType {
};
inline MethodType GetMethodType(
- const grpc::protobuf::MethodDescriptor *method) {
+ const grpc::protobuf::MethodDescriptor* method) {
if (method->client_streaming()) {
if (method->server_streaming()) {
return METHODTYPE_BIDI_STREAMING;
@@ -166,8 +166,8 @@ inline MethodType GetMethodType(
}
}
-inline void Split(const grpc::string &s, char delim,
- std::vector<grpc::string> *append_to) {
+inline void Split(const grpc::string& s, char delim,
+ std::vector<grpc::string>* append_to) {
std::istringstream iss(s);
grpc::string piece;
while (std::getline(iss, piece)) {
@@ -183,14 +183,14 @@ enum CommentType {
// Get all the raw comments and append each line without newline to out.
template <typename DescriptorType>
-inline void GetComment(const DescriptorType *desc, CommentType type,
- std::vector<grpc::string> *out) {
+inline void GetComment(const DescriptorType* desc, CommentType type,
+ std::vector<grpc::string>* out) {
grpc::protobuf::SourceLocation location;
if (!desc->GetSourceLocation(&location)) {
return;
}
if (type == COMMENTTYPE_LEADING || type == COMMENTTYPE_TRAILING) {
- const grpc::string &comments = type == COMMENTTYPE_LEADING
+ const grpc::string& comments = type == COMMENTTYPE_LEADING
? location.leading_comments
: location.trailing_comments;
Split(comments, '\n', out);
@@ -210,8 +210,8 @@ inline void GetComment(const DescriptorType *desc, CommentType type,
// For file level leading and detached leading comments, we return comments
// above syntax line. Return nothing for trailing comments.
template <>
-inline void GetComment(const grpc::protobuf::FileDescriptor *desc,
- CommentType type, std::vector<grpc::string> *out) {
+inline void GetComment(const grpc::protobuf::FileDescriptor* desc,
+ CommentType type, std::vector<grpc::string>* out) {
if (type == COMMENTTYPE_TRAILING) {
return;
}
@@ -238,10 +238,10 @@ inline void GetComment(const grpc::protobuf::FileDescriptor *desc,
// Add prefix and newline to each comment line and concatenate them together.
// Make sure there is a space after the prefix unless the line is empty.
inline grpc::string GenerateCommentsWithPrefix(
- const std::vector<grpc::string> &in, const grpc::string &prefix) {
+ const std::vector<grpc::string>& in, const grpc::string& prefix) {
std::ostringstream oss;
for (auto it = in.begin(); it != in.end(); it++) {
- const grpc::string &elem = *it;
+ const grpc::string& elem = *it;
if (elem.empty()) {
oss << prefix << "\n";
} else if (elem[0] == ' ') {
@@ -254,9 +254,9 @@ inline grpc::string GenerateCommentsWithPrefix(
}
template <typename DescriptorType>
-inline grpc::string GetPrefixedComments(const DescriptorType *desc,
+inline grpc::string GetPrefixedComments(const DescriptorType* desc,
bool leading,
- const grpc::string &prefix) {
+ const grpc::string& prefix) {
std::vector<grpc::string> out;
if (leading) {
grpc_generator::GetComment(
diff --git a/src/compiler/node_generator.cc b/src/compiler/node_generator.cc
index c0fef9128f..661587cbd6 100644
--- a/src/compiler/node_generator.cc
+++ b/src/compiler/node_generator.cc
@@ -22,10 +22,10 @@
#include "src/compiler/generator_helpers.h"
#include "src/compiler/node_generator_helpers.h"
+using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
-using grpc::protobuf::Descriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -53,15 +53,15 @@ grpc::string ModuleAlias(const grpc::string filename) {
// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript
// message file foo/bar/baz.js
-grpc::string GetJSMessageFilename(const grpc::string &filename) {
+grpc::string GetJSMessageFilename(const grpc::string& filename) {
grpc::string name = filename;
return grpc_generator::StripProto(name) + "_pb.js";
}
// Given a filename like foo/bar/baz.proto, returns the root directory
// path ../../
-grpc::string GetRootPath(const grpc::string &from_filename,
- const grpc::string &to_filename) {
+grpc::string GetRootPath(const grpc::string& from_filename,
+ const grpc::string& to_filename) {
if (to_filename.find("google/protobuf") == 0) {
// Well-known types (.proto files in the google/protobuf directory) are
// assumed to come from the 'google-protobuf' npm package. We may want to
@@ -82,24 +82,24 @@ grpc::string GetRootPath(const grpc::string &from_filename,
// Return the relative path to load to_file from the directory containing
// from_file, assuming that both paths are relative to the same directory
-grpc::string GetRelativePath(const grpc::string &from_file,
- const grpc::string &to_file) {
+grpc::string GetRelativePath(const grpc::string& from_file,
+ const grpc::string& to_file) {
return GetRootPath(from_file, to_file) + to_file;
}
/* Finds all message types used in all services in the file, and returns them
* as a map of fully qualified message type name to message descriptor */
-map<grpc::string, const Descriptor *> GetAllMessages(
- const FileDescriptor *file) {
- map<grpc::string, const Descriptor *> message_types;
+map<grpc::string, const Descriptor*> GetAllMessages(
+ const FileDescriptor* file) {
+ map<grpc::string, const Descriptor*> message_types;
for (int service_num = 0; service_num < file->service_count();
service_num++) {
- const ServiceDescriptor *service = file->service(service_num);
+ const ServiceDescriptor* service = file->service(service_num);
for (int method_num = 0; method_num < service->method_count();
method_num++) {
- const MethodDescriptor *method = service->method(method_num);
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+ const MethodDescriptor* method = service->method(method_num);
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
message_types[input_type->full_name()] = input_type;
message_types[output_type->full_name()] = output_type;
}
@@ -107,11 +107,11 @@ map<grpc::string, const Descriptor *> GetAllMessages(
return message_types;
}
-grpc::string MessageIdentifierName(const grpc::string &name) {
+grpc::string MessageIdentifierName(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "_");
}
-grpc::string NodeObjectPath(const Descriptor *descriptor) {
+grpc::string NodeObjectPath(const Descriptor* descriptor) {
grpc::string module_alias = ModuleAlias(descriptor->file()->name());
grpc::string name = descriptor->full_name();
grpc_generator::StripPrefix(&name, descriptor->file()->package() + ".");
@@ -119,7 +119,7 @@ grpc::string NodeObjectPath(const Descriptor *descriptor) {
}
// Prints out the message serializer and deserializer functions
-void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) {
+void PrintMessageTransformer(const Descriptor* descriptor, Printer* out) {
map<grpc::string, grpc::string> template_vars;
grpc::string full_name = descriptor->full_name();
template_vars["identifier_name"] = MessageIdentifierName(full_name);
@@ -149,9 +149,9 @@ void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) {
out->Print("}\n\n");
}
-void PrintMethod(const MethodDescriptor *method, Printer *out) {
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+void PrintMethod(const MethodDescriptor* method, Printer* out) {
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
map<grpc::string, grpc::string> vars;
vars["service_name"] = method->service()->full_name();
vars["name"] = method->name();
@@ -177,7 +177,7 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) {
}
// Prints out the service descriptor object
-void PrintService(const ServiceDescriptor *service, Printer *out) {
+void PrintService(const ServiceDescriptor* service, Printer* out) {
map<grpc::string, grpc::string> template_vars;
out->Print(GetNodeComments(service, true).c_str());
template_vars["name"] = service->name();
@@ -200,7 +200,7 @@ void PrintService(const ServiceDescriptor *service, Printer *out) {
out->Print(GetNodeComments(service, false).c_str());
}
-void PrintImports(const FileDescriptor *file, Printer *out) {
+void PrintImports(const FileDescriptor* file, Printer* out) {
out->Print("var grpc = require('grpc');\n");
if (file->message_type_count() > 0) {
grpc::string file_path =
@@ -219,9 +219,9 @@ void PrintImports(const FileDescriptor *file, Printer *out) {
out->Print("\n");
}
-void PrintTransformers(const FileDescriptor *file, Printer *out) {
- map<grpc::string, const Descriptor *> messages = GetAllMessages(file);
- for (std::map<grpc::string, const Descriptor *>::iterator it =
+void PrintTransformers(const FileDescriptor* file, Printer* out) {
+ map<grpc::string, const Descriptor*> messages = GetAllMessages(file);
+ for (std::map<grpc::string, const Descriptor*>::iterator it =
messages.begin();
it != messages.end(); it++) {
PrintMessageTransformer(it->second, out);
@@ -229,14 +229,14 @@ void PrintTransformers(const FileDescriptor *file, Printer *out) {
out->Print("\n");
}
-void PrintServices(const FileDescriptor *file, Printer *out) {
+void PrintServices(const FileDescriptor* file, Printer* out) {
for (int i = 0; i < file->service_count(); i++) {
PrintService(file->service(i), out);
}
}
-}
+} // namespace
-grpc::string GenerateFile(const FileDescriptor *file) {
+grpc::string GenerateFile(const FileDescriptor* file) {
grpc::string output;
{
StringOutputStream output_stream(&output);
@@ -250,7 +250,7 @@ grpc::string GenerateFile(const FileDescriptor *file) {
grpc::string leading_comments = GetNodeComments(file, true);
if (!leading_comments.empty()) {
out.Print("// Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
out.Print("'use strict';\n");
diff --git a/src/compiler/node_generator.h b/src/compiler/node_generator.h
index 7b0335b8d2..a9ffe75fc8 100644
--- a/src/compiler/node_generator.h
+++ b/src/compiler/node_generator.h
@@ -23,7 +23,7 @@
namespace grpc_node_generator {
-grpc::string GenerateFile(const grpc::protobuf::FileDescriptor *file);
+grpc::string GenerateFile(const grpc::protobuf::FileDescriptor* file);
} // namespace grpc_node_generator
diff --git a/src/compiler/node_plugin.cc b/src/compiler/node_plugin.cc
index f4334c96ab..bc38e9018a 100644
--- a/src/compiler/node_plugin.cc
+++ b/src/compiler/node_plugin.cc
@@ -32,10 +32,10 @@ class NodeGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
NodeGrpcGenerator() {}
~NodeGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
grpc::string code = GenerateFile(file);
if (code.size() == 0) {
return true;
@@ -52,7 +52,7 @@ class NodeGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
NodeGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index c05d15375b..ab7d869758 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -17,6 +17,7 @@
*/
#include <map>
+#include <set>
#include <sstream>
#include "src/compiler/config.h"
@@ -26,16 +27,19 @@
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
using ::google::protobuf::compiler::objectivec::ClassName;
-using ::grpc::protobuf::io::Printer;
+using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::MethodDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
+using ::grpc::protobuf::io::Printer;
using ::std::map;
+using ::std::set;
namespace grpc_objective_c_generator {
namespace {
void PrintProtoRpcDeclarationAsPragma(
- Printer *printer, const MethodDescriptor *method,
+ Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
vars["client_stream"] = method->client_streaming() ? "stream " : "";
vars["server_stream"] = method->server_streaming() ? "stream " : "";
@@ -46,7 +50,7 @@ void PrintProtoRpcDeclarationAsPragma(
}
template <typename DescriptorType>
-static void PrintAllComments(const DescriptorType *desc, Printer *printer) {
+static void PrintAllComments(const DescriptorType* desc, Printer* printer) {
std::vector<grpc::string> comments;
grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED,
&comments);
@@ -62,15 +66,15 @@ static void PrintAllComments(const DescriptorType *desc, Printer *printer) {
printer->Print(" * ");
size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) {
- printer->Print(it->c_str() + start_pos);
+ printer->PrintRaw(it->c_str() + start_pos);
}
printer->Print("\n");
}
printer->Print(" */\n");
}
-void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
- const map< ::grpc::string, ::grpc::string> &vars) {
+void PrintMethodSignature(Printer* printer, const MethodDescriptor* method,
+ const map< ::grpc::string, ::grpc::string>& vars) {
// Print comment
PrintAllComments(method, printer);
@@ -94,7 +98,7 @@ void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
}
}
-void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
+void PrintSimpleSignature(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
vars["method_name"] =
grpc_generator::LowercaseFirstLetter(vars["method_name"]);
@@ -102,7 +106,7 @@ void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
PrintMethodSignature(printer, method, vars);
}
-void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method,
+void PrintAdvancedSignature(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
vars["method_name"] = "RPCTo" + vars["method_name"];
vars["return_type"] = "GRPCProtoCall *";
@@ -110,7 +114,7 @@ void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method,
}
inline map< ::grpc::string, ::grpc::string> GetMethodVars(
- const MethodDescriptor *method) {
+ const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> res;
res["method_name"] = method->name();
res["request_type"] = method->input_type()->name();
@@ -120,7 +124,7 @@ inline map< ::grpc::string, ::grpc::string> GetMethodVars(
return res;
}
-void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
+void PrintMethodDeclarations(Printer* printer, const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -131,7 +135,7 @@ void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
printer->Print(";\n\n\n");
}
-void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
+void PrintSimpleImplementation(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
printer->Print(vars, " [[self RPCTo$method_name$With");
@@ -148,8 +152,8 @@ void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
printer->Print("}\n");
}
-void PrintAdvancedImplementation(Printer *printer,
- const MethodDescriptor *method,
+void PrintAdvancedImplementation(Printer* printer,
+ const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n");
@@ -173,8 +177,8 @@ void PrintAdvancedImplementation(Printer *printer,
printer->Print("}\n");
}
-void PrintMethodImplementations(Printer *printer,
- const MethodDescriptor *method) {
+void PrintMethodImplementations(Printer* printer,
+ const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -190,7 +194,25 @@ void PrintMethodImplementations(Printer *printer,
} // namespace
-::grpc::string GetHeader(const ServiceDescriptor *service) {
+::grpc::string GetAllMessageClasses(const FileDescriptor* file) {
+ ::grpc::string output;
+ set< ::grpc::string> classes;
+ for (int i = 0; i < file->service_count(); i++) {
+ const auto service = file->service(i);
+ for (int i = 0; i < service->method_count(); i++) {
+ const auto method = service->method(i);
+ classes.insert(ClassName(method->input_type()));
+ classes.insert(ClassName(method->output_type()));
+ }
+ }
+ for (auto one_class : classes) {
+ output += " @class " + one_class + ";\n";
+ }
+
+ return output;
+}
+
+::grpc::string GetHeader(const ServiceDescriptor* service) {
::grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -224,7 +246,7 @@ void PrintMethodImplementations(Printer *printer,
return output;
}
-::grpc::string GetSource(const ServiceDescriptor *service) {
+::grpc::string GetSource(const ServiceDescriptor* service) {
::grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h
index edbee7ff52..d3aed76c4f 100644
--- a/src/compiler/objective_c_generator.h
+++ b/src/compiler/objective_c_generator.h
@@ -23,16 +23,21 @@
namespace grpc_objective_c_generator {
+using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
+// Returns forward declaration of classes in the generated header file.
+string GetAllMessageClasses(const FileDescriptor* file);
+
// Returns the content to be included in the "global_scope" insertion point of
// the generated header file.
-string GetHeader(const ServiceDescriptor *service);
+string GetHeader(const ServiceDescriptor* service);
// Returns the content to be included in the "global_scope" insertion point of
// the generated implementation file.
-string GetSource(const ServiceDescriptor *service);
+string GetSource(const ServiceDescriptor* service);
} // namespace grpc_objective_c_generator
diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h
index 9c9589e1db..4004e6aef8 100644
--- a/src/compiler/objective_c_generator_helpers.h
+++ b/src/compiler/objective_c_generator_helpers.h
@@ -31,14 +31,14 @@ using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
-inline string MessageHeaderName(const FileDescriptor *file) {
+inline string MessageHeaderName(const FileDescriptor* file) {
return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h";
}
-inline string ServiceClassName(const ServiceDescriptor *service) {
- const FileDescriptor *file = service->file();
+inline string ServiceClassName(const ServiceDescriptor* service) {
+ const FileDescriptor* file = service->file();
string prefix = file->options().objc_class_prefix();
return prefix + service->name();
}
-}
+} // namespace grpc_objective_c_generator
#endif // GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H
diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc
index 96a3375e96..d5d488e84d 100644
--- a/src/compiler/objective_c_plugin.cc
+++ b/src/compiler/objective_c_plugin.cc
@@ -26,19 +26,19 @@
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
-using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName;
using ::google::protobuf::compiler::objectivec::
IsProtobufLibraryBundledProtoFile;
+using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName;
class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
ObjectiveCGrpcGenerator() {}
virtual ~ObjectiveCGrpcGenerator() {}
- virtual bool Generate(const grpc::protobuf::FileDescriptor *file,
- const ::grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- ::grpc::string *error) const {
+ virtual bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const ::grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ ::grpc::string* error) const {
if (file->service_count() == 0) {
// No services. Do nothing.
return true;
@@ -51,42 +51,47 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
{
// Generate .pbrpc.h
- ::grpc::string imports = ::grpc::string("#import \"") + file_name +
- ".pbobjc.h\"\n\n"
- "#import <ProtoRPC/ProtoService.h>\n"
- "#import <ProtoRPC/ProtoRPC.h>\n"
- "#import <RxLibrary/GRXWriteable.h>\n"
- "#import <RxLibrary/GRXWriter.h>\n";
+ ::grpc::string imports =
+ ::grpc::string("#if !GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO\n") +
+ "#import \"" + file_name +
+ ".pbobjc.h\"\n"
+ "#endif\n\n"
+ "#import <ProtoRPC/ProtoService.h>\n"
+ "#import <ProtoRPC/ProtoRPC.h>\n"
+ "#import <RxLibrary/GRXWriteable.h>\n"
+ "#import <RxLibrary/GRXWriter.h>\n";
- // TODO(jcanizales): Instead forward-declare the input and output types
- // and import the files in the .pbrpc.m
::grpc::string proto_imports;
+ proto_imports += "#if GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO\n" +
+ grpc_objective_c_generator::GetAllMessageClasses(file) +
+ "#else\n";
for (int i = 0; i < file->dependency_count(); i++) {
::grpc::string header =
grpc_objective_c_generator::MessageHeaderName(file->dependency(i));
- const grpc::protobuf::FileDescriptor *dependency = file->dependency(i);
+ const grpc::protobuf::FileDescriptor* dependency = file->dependency(i);
if (IsProtobufLibraryBundledProtoFile(dependency)) {
::grpc::string base_name = header;
grpc_generator::StripPrefix(&base_name, "google/protobuf/");
// create the import code snippet
proto_imports +=
- "#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n"
- " #import <" +
+ " #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n"
+ " #import <" +
::grpc::string(ProtobufLibraryFrameworkName) + "/" + base_name +
">\n"
- "#else\n"
- " #import \"" +
+ " #else\n"
+ " #import \"" +
header +
"\"\n"
- "#endif\n";
+ " #endif\n";
} else {
- proto_imports += ::grpc::string("#import \"") + header + "\"\n";
+ proto_imports += ::grpc::string(" #import \"") + header + "\"\n";
}
}
+ proto_imports += "#endif\n";
::grpc::string declarations;
for (int i = 0; i < file->service_count(); i++) {
- const grpc::protobuf::ServiceDescriptor *service = file->service(i);
+ const grpc::protobuf::ServiceDescriptor* service = file->service(i);
declarations += grpc_objective_c_generator::GetHeader(service);
}
@@ -94,22 +99,47 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
"\nNS_ASSUME_NONNULL_BEGIN\n\n";
static const ::grpc::string kNonNullEnd = "\nNS_ASSUME_NONNULL_END\n";
- Write(context, file_name + ".pbrpc.h", imports + '\n' + proto_imports +
- '\n' + kNonNullBegin +
- declarations + kNonNullEnd);
+ Write(context, file_name + ".pbrpc.h",
+ imports + '\n' + proto_imports + '\n' + kNonNullBegin +
+ declarations + kNonNullEnd);
}
{
// Generate .pbrpc.m
::grpc::string imports = ::grpc::string("#import \"") + file_name +
- ".pbrpc.h\"\n\n"
+ ".pbrpc.h\"\n"
+ "#import \"" +
+ file_name +
+ ".pbobjc.h\"\n\n"
"#import <ProtoRPC/ProtoRPC.h>\n"
"#import <RxLibrary/GRXWriter+Immediate.h>\n";
+ for (int i = 0; i < file->dependency_count(); i++) {
+ ::grpc::string header =
+ grpc_objective_c_generator::MessageHeaderName(file->dependency(i));
+ const grpc::protobuf::FileDescriptor* dependency = file->dependency(i);
+ if (IsProtobufLibraryBundledProtoFile(dependency)) {
+ ::grpc::string base_name = header;
+ grpc_generator::StripPrefix(&base_name, "google/protobuf/");
+ // create the import code snippet
+ imports +=
+ "#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n"
+ " #import <" +
+ ::grpc::string(ProtobufLibraryFrameworkName) + "/" + base_name +
+ ">\n"
+ "#else\n"
+ " #import \"" +
+ header +
+ "\"\n"
+ "#endif\n";
+ } else {
+ imports += ::grpc::string("#import \"") + header + "\"\n";
+ }
+ }
::grpc::string definitions;
for (int i = 0; i < file->service_count(); i++) {
- const grpc::protobuf::ServiceDescriptor *service = file->service(i);
+ const grpc::protobuf::ServiceDescriptor* service = file->service(i);
definitions += grpc_objective_c_generator::GetSource(service);
}
@@ -121,8 +151,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
private:
// Write the given code into the given file.
- void Write(grpc::protobuf::compiler::GeneratorContext *context,
- const ::grpc::string &filename, const ::grpc::string &code) const {
+ void Write(grpc::protobuf::compiler::GeneratorContext* context,
+ const ::grpc::string& filename, const ::grpc::string& code) const {
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->Open(filename));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
@@ -130,7 +160,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
ObjectiveCGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/php_generator.cc b/src/compiler/php_generator.cc
index 6d9ff3a29c..d9705e8077 100644
--- a/src/compiler/php_generator.cc
+++ b/src/compiler/php_generator.cc
@@ -22,10 +22,10 @@
#include "src/compiler/generator_helpers.h"
#include "src/compiler/php_generator_helpers.h"
+using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
-using grpc::protobuf::Descriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -33,7 +33,7 @@ using std::map;
namespace grpc_php_generator {
namespace {
-grpc::string ConvertToPhpNamespace(const grpc::string &name) {
+grpc::string ConvertToPhpNamespace(const grpc::string& name) {
std::vector<grpc::string> tokens = grpc_generator::tokenize(name, ".");
std::ostringstream oss;
for (unsigned int i = 0; i < tokens.size(); i++) {
@@ -43,7 +43,7 @@ grpc::string ConvertToPhpNamespace(const grpc::string &name) {
return oss.str();
}
-grpc::string PackageName(const FileDescriptor *file) {
+grpc::string PackageName(const FileDescriptor* file) {
if (file->options().has_php_namespace()) {
return file->options().php_namespace();
} else {
@@ -51,8 +51,8 @@ grpc::string PackageName(const FileDescriptor *file) {
}
}
-grpc::string MessageIdentifierName(const grpc::string &name,
- const FileDescriptor *file) {
+grpc::string MessageIdentifierName(const grpc::string& name,
+ const FileDescriptor* file) {
std::vector<grpc::string> tokens = grpc_generator::tokenize(name, ".");
std::ostringstream oss;
oss << PackageName(file) << "\\"
@@ -60,9 +60,9 @@ grpc::string MessageIdentifierName(const grpc::string &name,
return oss.str();
}
-void PrintMethod(const MethodDescriptor *method, Printer *out) {
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+void PrintMethod(const MethodDescriptor* method, Printer* out) {
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
map<grpc::string, grpc::string> vars;
vars["service_name"] = method->service()->full_name();
vars["name"] = method->name();
@@ -116,8 +116,8 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) {
}
// Prints out the service descriptor object
-void PrintService(const ServiceDescriptor *service,
- const grpc::string &class_suffix, Printer *out) {
+void PrintService(const ServiceDescriptor* service,
+ const grpc::string& class_suffix, Printer* out) {
map<grpc::string, grpc::string> vars;
out->Print("/**\n");
out->Print(GetPHPComments(service, " *").c_str());
@@ -148,11 +148,11 @@ void PrintService(const ServiceDescriptor *service,
out->Outdent();
out->Print("}\n");
}
-}
+} // namespace
-grpc::string GenerateFile(const FileDescriptor *file,
- const ServiceDescriptor *service,
- const grpc::string &class_suffix) {
+grpc::string GenerateFile(const FileDescriptor* file,
+ const ServiceDescriptor* service,
+ const grpc::string& class_suffix) {
grpc::string output;
{
StringOutputStream output_stream(&output);
@@ -164,7 +164,7 @@ grpc::string GenerateFile(const FileDescriptor *file,
grpc::string leading_comments = GetPHPComments(file, "//");
if (!leading_comments.empty()) {
out.Print("// Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
map<grpc::string, grpc::string> vars;
diff --git a/src/compiler/php_generator.h b/src/compiler/php_generator.h
index 5412d774a9..46222b3d8e 100644
--- a/src/compiler/php_generator.h
+++ b/src/compiler/php_generator.h
@@ -23,9 +23,9 @@
namespace grpc_php_generator {
-grpc::string GenerateFile(const grpc::protobuf::FileDescriptor *file,
- const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string &class_suffix);
+grpc::string GenerateFile(const grpc::protobuf::FileDescriptor* file,
+ const grpc::protobuf::ServiceDescriptor* service,
+ const grpc::string& class_suffix);
} // namespace grpc_php_generator
diff --git a/src/compiler/php_generator_helpers.h b/src/compiler/php_generator_helpers.h
index 3c886794b8..3ad1997764 100644
--- a/src/compiler/php_generator_helpers.h
+++ b/src/compiler/php_generator_helpers.h
@@ -27,14 +27,14 @@
namespace grpc_php_generator {
inline grpc::string GetPHPServiceClassname(
- const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string &class_suffix) {
+ const grpc::protobuf::ServiceDescriptor* service,
+ const grpc::string& class_suffix) {
return service->name() + (class_suffix == "" ? "Client" : class_suffix);
}
// ReplaceAll replaces all instances of search with replace in s.
-inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
- const grpc::string &replace) {
+inline grpc::string ReplaceAll(grpc::string s, const grpc::string& search,
+ const grpc::string& replace) {
size_t pos = 0;
while ((pos = s.find(search, pos)) != grpc::string::npos) {
s.replace(pos, search.length(), replace);
@@ -44,9 +44,9 @@ inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
}
inline grpc::string GetPHPServiceFilename(
- const grpc::protobuf::FileDescriptor *file,
- const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string &class_suffix) {
+ const grpc::protobuf::FileDescriptor* file,
+ const grpc::protobuf::ServiceDescriptor* service,
+ const grpc::string& class_suffix) {
std::ostringstream oss;
if (file->options().has_php_namespace()) {
oss << ReplaceAll(file->options().php_namespace(), "\\", "/");
@@ -65,7 +65,7 @@ inline grpc::string GetPHPServiceFilename(
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetPHPComments(const DescriptorType *desc,
+inline grpc::string GetPHPComments(const DescriptorType* desc,
grpc::string prefix) {
return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix),
"*/", "&#42;/");
diff --git a/src/compiler/php_plugin.cc b/src/compiler/php_plugin.cc
index 7b0da87eb2..d01cbf87a0 100644
--- a/src/compiler/php_plugin.cc
+++ b/src/compiler/php_plugin.cc
@@ -24,19 +24,19 @@
#include "src/compiler/php_generator.h"
#include "src/compiler/php_generator_helpers.h"
+using google::protobuf::compiler::ParseGeneratorParameter;
using grpc_php_generator::GenerateFile;
using grpc_php_generator::GetPHPServiceFilename;
-using google::protobuf::compiler::ParseGeneratorParameter;
class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
PHPGrpcGenerator() {}
~PHPGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
if (file->service_count() == 0) {
return true;
}
@@ -71,7 +71,7 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
PHPGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/protobuf_plugin.h b/src/compiler/protobuf_plugin.h
index e14740cc0c..b971af1310 100644
--- a/src/compiler/protobuf_plugin.h
+++ b/src/compiler/protobuf_plugin.h
@@ -29,14 +29,14 @@
// Get leading or trailing comments in a string.
template <typename DescriptorType>
-inline grpc::string GetCommentsHelper(const DescriptorType *desc, bool leading,
- const grpc::string &prefix) {
+inline grpc::string GetCommentsHelper(const DescriptorType* desc, bool leading,
+ const grpc::string& prefix) {
return grpc_generator::GetPrefixedComments(desc, leading, prefix);
}
class ProtoBufMethod : public grpc_generator::Method {
public:
- ProtoBufMethod(const grpc::protobuf::MethodDescriptor *method)
+ ProtoBufMethod(const grpc::protobuf::MethodDescriptor* method)
: method_(method) {}
grpc::string name() const { return method_->name(); }
@@ -55,7 +55,7 @@ class ProtoBufMethod : public grpc_generator::Method {
return method_->output_type()->file()->name();
}
- bool get_module_and_message_path_input(grpc::string *str,
+ bool get_module_and_message_path_input(grpc::string* str,
grpc::string generator_file_name,
bool generate_in_pb2_grpc,
grpc::string import_prefix) const {
@@ -64,7 +64,7 @@ class ProtoBufMethod : public grpc_generator::Method {
import_prefix);
}
- bool get_module_and_message_path_output(grpc::string *str,
+ bool get_module_and_message_path_output(grpc::string* str,
grpc::string generator_file_name,
bool generate_in_pb2_grpc,
grpc::string import_prefix) const {
@@ -98,12 +98,12 @@ class ProtoBufMethod : public grpc_generator::Method {
}
private:
- const grpc::protobuf::MethodDescriptor *method_;
+ const grpc::protobuf::MethodDescriptor* method_;
};
class ProtoBufService : public grpc_generator::Service {
public:
- ProtoBufService(const grpc::protobuf::ServiceDescriptor *service)
+ ProtoBufService(const grpc::protobuf::ServiceDescriptor* service)
: service_(service) {}
grpc::string name() const { return service_->name(); }
@@ -127,20 +127,21 @@ class ProtoBufService : public grpc_generator::Service {
}
private:
- const grpc::protobuf::ServiceDescriptor *service_;
+ const grpc::protobuf::ServiceDescriptor* service_;
};
class ProtoBufPrinter : public grpc_generator::Printer {
public:
- ProtoBufPrinter(grpc::string *str)
+ ProtoBufPrinter(grpc::string* str)
: output_stream_(str), printer_(&output_stream_, '$') {}
- void Print(const std::map<grpc::string, grpc::string> &vars,
- const char *string_template) {
+ void Print(const std::map<grpc::string, grpc::string>& vars,
+ const char* string_template) {
printer_.Print(vars, string_template);
}
- void Print(const char *string) { printer_.Print(string); }
+ void Print(const char* string) { printer_.Print(string); }
+ void PrintRaw(const char* string) { printer_.PrintRaw(string); }
void Indent() { printer_.Indent(); }
void Outdent() { printer_.Outdent(); }
@@ -151,7 +152,7 @@ class ProtoBufPrinter : public grpc_generator::Printer {
class ProtoBufFile : public grpc_generator::File {
public:
- ProtoBufFile(const grpc::protobuf::FileDescriptor *file) : file_(file) {}
+ ProtoBufFile(const grpc::protobuf::FileDescriptor* file) : file_(file) {}
grpc::string filename() const { return file_->name(); }
grpc::string filename_without_ext() const {
@@ -172,7 +173,7 @@ class ProtoBufFile : public grpc_generator::File {
}
std::unique_ptr<grpc_generator::Printer> CreatePrinter(
- grpc::string *str) const {
+ grpc::string* str) const {
return std::unique_ptr<grpc_generator::Printer>(new ProtoBufPrinter(str));
}
@@ -189,7 +190,7 @@ class ProtoBufFile : public grpc_generator::File {
}
private:
- const grpc::protobuf::FileDescriptor *file_;
+ const grpc::protobuf::FileDescriptor* file_;
};
#endif // GRPC_INTERNAL_COMPILER_PROTOBUF_PLUGIN_H
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index ef2d90de9e..8a0b889454 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -45,9 +45,9 @@ using std::make_pair;
using std::map;
using std::pair;
using std::replace;
+using std::set;
using std::tuple;
using std::vector;
-using std::set;
namespace grpc_python_generator {
@@ -101,7 +101,7 @@ void PrivateGenerator::PrintAllComments(StringVector comments,
++it) {
size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) {
- out->Print(it->c_str() + start_pos);
+ out->PrintRaw(it->c_str() + start_pos);
}
out->Print("\n");
}
diff --git a/src/compiler/python_generator_helpers.h b/src/compiler/python_generator_helpers.h
index fb3e860d3e..b1b58befdf 100644
--- a/src/compiler/python_generator_helpers.h
+++ b/src/compiler/python_generator_helpers.h
@@ -29,9 +29,6 @@
#include "src/compiler/python_generator.h"
#include "src/compiler/python_private_generator.h"
-using std::vector;
-using grpc_generator::StringReplace;
-using grpc_generator::StripProto;
using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
using grpc::protobuf::MethodDescriptor;
@@ -41,6 +38,9 @@ using grpc::protobuf::io::CodedOutputStream;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using grpc::protobuf::io::ZeroCopyOutputStream;
+using grpc_generator::StringReplace;
+using grpc_generator::StripProto;
+using std::vector;
namespace grpc_python_generator {
diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc
index 54d8a42597..e81dea603b 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -27,8 +27,8 @@
#include "src/compiler/ruby_generator_string-inl.h"
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -38,8 +38,8 @@ namespace grpc_ruby_generator {
namespace {
// Prints out the method using the ruby gRPC DSL.
-void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
- Printer *out) {
+void PrintMethod(const MethodDescriptor* method, const grpc::string& package,
+ Printer* out) {
grpc::string input_type =
RubyTypeOf(method->input_type()->full_name(), package);
if (method->client_streaming()) {
@@ -51,7 +51,11 @@ void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
output_type = "stream(" + output_type + ")";
}
std::map<grpc::string, grpc::string> method_vars = ListToDict({
- "mth.name", method->name(), "input.type", input_type, "output.type",
+ "mth.name",
+ method->name(),
+ "input.type",
+ input_type,
+ "output.type",
output_type,
});
out->Print(GetRubyComments(method, true).c_str());
@@ -60,15 +64,16 @@ void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
}
// Prints out the service using the ruby gRPC DSL.
-void PrintService(const ServiceDescriptor *service, const grpc::string &package,
- Printer *out) {
+void PrintService(const ServiceDescriptor* service, const grpc::string& package,
+ Printer* out) {
if (service->method_count() == 0) {
return;
}
// Begin the service module
std::map<grpc::string, grpc::string> module_vars = ListToDict({
- "module.name", CapitalizeFirst(service->name()),
+ "module.name",
+ CapitalizeFirst(service->name()),
});
out->Print(module_vars, "module $module.name$\n");
out->Indent();
@@ -119,7 +124,7 @@ char ToUpper(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; }
// names must be PascalCased.
//
// foo_bar_baz -> FooBarBaz
-grpc::string PackageToModule(const grpc::string &name) {
+grpc::string PackageToModule(const grpc::string& name) {
bool next_upper = true;
grpc::string result;
result.reserve(name.size());
@@ -141,7 +146,7 @@ grpc::string PackageToModule(const grpc::string &name) {
}
// end copying of protoc generator for ruby code
-grpc::string GetServices(const FileDescriptor *file) {
+grpc::string GetServices(const FileDescriptor* file) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -157,7 +162,10 @@ grpc::string GetServices(const FileDescriptor *file) {
// Write out a file header.
std::map<grpc::string, grpc::string> header_comment_vars = ListToDict({
- "file.name", file->name(), "file.package", file->package(),
+ "file.name",
+ file->name(),
+ "file.package",
+ file->package(),
});
out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n");
out.Print(header_comment_vars,
@@ -166,7 +174,7 @@ grpc::string GetServices(const FileDescriptor *file) {
grpc::string leading_comments = GetRubyComments(file, true);
if (!leading_comments.empty()) {
out.Print("# Original file comments:\n");
- out.Print(leading_comments.c_str());
+ out.PrintRaw(leading_comments.c_str());
}
out.Print("\n");
@@ -175,7 +183,8 @@ grpc::string GetServices(const FileDescriptor *file) {
// that defines the messages used by the service. This is generated by the
// main ruby plugin.
std::map<grpc::string, grpc::string> dep_vars = ListToDict({
- "dep.name", MessagesRequireName(file),
+ "dep.name",
+ MessagesRequireName(file),
});
out.Print(dep_vars, "require '$dep.name$'\n");
@@ -184,7 +193,8 @@ grpc::string GetServices(const FileDescriptor *file) {
std::vector<grpc::string> modules = Split(file->package(), '.');
for (size_t i = 0; i < modules.size(); ++i) {
std::map<grpc::string, grpc::string> module_vars = ListToDict({
- "module.name", PackageToModule(modules[i]),
+ "module.name",
+ PackageToModule(modules[i]),
});
out.Print(module_vars, "module $module.name$\n");
out.Indent();
diff --git a/src/compiler/ruby_generator.h b/src/compiler/ruby_generator.h
index cdc03aa0d4..9a03e0d139 100644
--- a/src/compiler/ruby_generator.h
+++ b/src/compiler/ruby_generator.h
@@ -23,7 +23,7 @@
namespace grpc_ruby_generator {
-grpc::string GetServices(const grpc::protobuf::FileDescriptor *file);
+grpc::string GetServices(const grpc::protobuf::FileDescriptor* file);
} // namespace grpc_ruby_generator
diff --git a/src/compiler/ruby_generator_helpers-inl.h b/src/compiler/ruby_generator_helpers-inl.h
index ac09f8dcdb..2323770425 100644
--- a/src/compiler/ruby_generator_helpers-inl.h
+++ b/src/compiler/ruby_generator_helpers-inl.h
@@ -25,8 +25,8 @@
namespace grpc_ruby_generator {
-inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
- grpc::string *file_name_or_error) {
+inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file,
+ grpc::string* file_name_or_error) {
// Get output file name.
static const unsigned proto_suffix_length = 6; // length of ".proto"
if (file->name().size() > proto_suffix_length &&
@@ -42,14 +42,14 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
}
inline grpc::string MessagesRequireName(
- const grpc::protobuf::FileDescriptor *file) {
+ const grpc::protobuf::FileDescriptor* file) {
return Replace(file->name(), ".proto", "_pb");
}
// Get leading or trailing comments in a string. Comment lines start with "# ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
-inline grpc::string GetRubyComments(const DescriptorType *desc, bool leading) {
+inline grpc::string GetRubyComments(const DescriptorType* desc, bool leading) {
return grpc_generator::GetPrefixedComments(desc, leading, "#");
}
diff --git a/src/compiler/ruby_generator_map-inl.h b/src/compiler/ruby_generator_map-inl.h
index 12973e4fb4..89a74b1d41 100644
--- a/src/compiler/ruby_generator_map-inl.h
+++ b/src/compiler/ruby_generator_map-inl.h
@@ -36,7 +36,7 @@ namespace grpc_ruby_generator {
// Converts an initializer list of the form { key0, value0, key1, value1, ... }
// into a map of key* to value*. Is merely a readability helper for later code.
inline std::map<grpc::string, grpc::string> ListToDict(
- const initializer_list<grpc::string> &values) {
+ const initializer_list<grpc::string>& values) {
if (values.size() % 2 != 0) {
std::cerr << "Not every 'key' has a value in `values`." << std::endl;
}
diff --git a/src/compiler/ruby_generator_string-inl.h b/src/compiler/ruby_generator_string-inl.h
index def92edec6..fb429784bb 100644
--- a/src/compiler/ruby_generator_string-inl.h
+++ b/src/compiler/ruby_generator_string-inl.h
@@ -31,8 +31,8 @@ using std::transform;
namespace grpc_ruby_generator {
// Split splits a string using char into elems.
-inline std::vector<grpc::string> &Split(const grpc::string &s, char delim,
- std::vector<grpc::string> *elems) {
+inline std::vector<grpc::string>& Split(const grpc::string& s, char delim,
+ std::vector<grpc::string>* elems) {
std::stringstream ss(s);
grpc::string item;
while (getline(ss, item, delim)) {
@@ -42,15 +42,15 @@ inline std::vector<grpc::string> &Split(const grpc::string &s, char delim,
}
// Split splits a string using char, returning the result in a vector.
-inline std::vector<grpc::string> Split(const grpc::string &s, char delim) {
+inline std::vector<grpc::string> Split(const grpc::string& s, char delim) {
std::vector<grpc::string> elems;
Split(s, delim, &elems);
return elems;
}
// Replace replaces from with to in s.
-inline grpc::string Replace(grpc::string s, const grpc::string &from,
- const grpc::string &to) {
+inline grpc::string Replace(grpc::string s, const grpc::string& from,
+ const grpc::string& to) {
size_t start_pos = s.find(from);
if (start_pos == grpc::string::npos) {
return s;
@@ -60,8 +60,8 @@ inline grpc::string Replace(grpc::string s, const grpc::string &from,
}
// ReplaceAll replaces all instances of search with replace in s.
-inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
- const grpc::string &replace) {
+inline grpc::string ReplaceAll(grpc::string s, const grpc::string& search,
+ const grpc::string& replace) {
size_t pos = 0;
while ((pos = s.find(search, pos)) != grpc::string::npos) {
s.replace(pos, search.length(), replace);
@@ -71,8 +71,8 @@ inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
}
// ReplacePrefix replaces from with to in s if search is a prefix of s.
-inline bool ReplacePrefix(grpc::string *s, const grpc::string &from,
- const grpc::string &to) {
+inline bool ReplacePrefix(grpc::string* s, const grpc::string& from,
+ const grpc::string& to) {
size_t start_pos = s->find(from);
if (start_pos == grpc::string::npos || start_pos != 0) {
return false;
@@ -91,8 +91,8 @@ inline grpc::string CapitalizeFirst(grpc::string s) {
}
// RubyTypeOf updates a proto type to the required ruby equivalent.
-inline grpc::string RubyTypeOf(const grpc::string &a_type,
- const grpc::string &package) {
+inline grpc::string RubyTypeOf(const grpc::string& a_type,
+ const grpc::string& package) {
grpc::string res(a_type);
ReplacePrefix(&res, package, ""); // remove the leading package if present
ReplacePrefix(&res, ".", ""); // remove the leading . (no package)
diff --git a/src/compiler/ruby_plugin.cc b/src/compiler/ruby_plugin.cc
index f1b1d0182a..9c234bd7cb 100644
--- a/src/compiler/ruby_plugin.cc
+++ b/src/compiler/ruby_plugin.cc
@@ -29,10 +29,10 @@ class RubyGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
RubyGrpcGenerator() {}
~RubyGrpcGenerator() {}
- bool Generate(const grpc::protobuf::FileDescriptor *file,
- const grpc::string &parameter,
- grpc::protobuf::compiler::GeneratorContext *context,
- grpc::string *error) const {
+ bool Generate(const grpc::protobuf::FileDescriptor* file,
+ const grpc::string& parameter,
+ grpc::protobuf::compiler::GeneratorContext* context,
+ grpc::string* error) const {
grpc::string code = grpc_ruby_generator::GetServices(file);
if (code.size() == 0) {
return true; // don't generate a file if there are no services
@@ -51,7 +51,7 @@ class RubyGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
};
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
RubyGrpcGenerator generator;
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator);
}
diff --git a/src/compiler/schema_interface.h b/src/compiler/schema_interface.h
index 828c7753df..c000478e68 100644
--- a/src/compiler/schema_interface.h
+++ b/src/compiler/schema_interface.h
@@ -56,10 +56,10 @@ struct Method : public CommentHolder {
virtual grpc::string output_type_name() const = 0;
virtual bool get_module_and_message_path_input(
- grpc::string *str, grpc::string generator_file_name,
+ grpc::string* str, grpc::string generator_file_name,
bool generate_in_pb2_grpc, grpc::string import_prefix) const = 0;
virtual bool get_module_and_message_path_output(
- grpc::string *str, grpc::string generator_file_name,
+ grpc::string* str, grpc::string generator_file_name,
bool generate_in_pb2_grpc, grpc::string import_prefix) const = 0;
virtual grpc::string get_input_type_name() const = 0;
@@ -83,9 +83,10 @@ struct Service : public CommentHolder {
struct Printer {
virtual ~Printer() {}
- virtual void Print(const std::map<grpc::string, grpc::string> &vars,
- const char *template_string) = 0;
- virtual void Print(const char *string) = 0;
+ virtual void Print(const std::map<grpc::string, grpc::string>& vars,
+ const char* template_string) = 0;
+ virtual void Print(const char* string) = 0;
+ virtual void PrintRaw(const char* string) = 0;
virtual void Indent() = 0;
virtual void Outdent() = 0;
};
@@ -104,7 +105,7 @@ struct File : public CommentHolder {
virtual int service_count() const = 0;
virtual std::unique_ptr<const Service> service(int i) const = 0;
- virtual std::unique_ptr<Printer> CreatePrinter(grpc::string *str) const = 0;
+ virtual std::unique_ptr<Printer> CreatePrinter(grpc::string* str) const = 0;
};
} // namespace grpc_generator
diff --git a/src/core/ext/census/README.md b/src/core/ext/census/README.md
deleted file mode 100644
index a9826fe889..0000000000
--- a/src/core/ext/census/README.md
+++ /dev/null
@@ -1,61 +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.
--->
-
-# Census - a resource measurement and tracing system
-
-This directory contains code for Census, which will ultimately provide the
-following features for any gRPC-using system:
-* A [dapper](http://research.google.com/pubs/pub36356.html)-like tracing
- system, enabling tracing across a distributed infrastructure.
-* RPC statistics and measurements for key metrics, such as latency, bytes
- transferred, number of errors etc.
-* Resource measurement framework which can be used for measuring custom
- metrics. Through the use of [tags](#Tags), these can be broken down across
- the entire distributed stack.
-* Easy integration of the above with
- [Google Cloud Trace](https://cloud.google.com/tools/cloud-trace) and
- [Google Cloud Monitoring](https://cloud.google.com/monitoring/).
-
-## Concepts
-
-### Context
-
-### Operations
-
-### Tags
-
-### Metrics
-
-## API
-
-### Internal/RPC API
-
-### External/Client API
-
-### RPC API
-
-## Files in this directory
-
-Note that files and functions in this directory can be split into two
-categories:
-* Files that define core census library functions. Functions etc. in these
- files are named census\_\*, and constitute the core census library
- functionality. At some time in the future, these will become a standalone
- library.
-* Files that define functions etc. that provide a convenient interface between
- grpc and the core census functionality. These files are all named
- grpc\_\*.{c,h}, and define function names beginning with grpc\_census\_\*.
-
diff --git a/src/core/ext/census/aggregation.h b/src/core/ext/census/aggregation.h
deleted file mode 100644
index 1ba7953ecc..0000000000
--- a/src/core/ext/census/aggregation.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.
- *
- */
-
-#include <stddef.h>
-
-#ifndef GRPC_CORE_EXT_CENSUS_AGGREGATION_H
-#define GRPC_CORE_EXT_CENSUS_AGGREGATION_H
-
-/** Structure used to describe an aggregation type. */
-struct census_aggregation_ops {
- /* Create a new aggregation. The pointer returned can be used in future calls
- to clone(), free(), record(), data() and reset(). */
- void *(*create)(const void *create_arg);
- /* Make a copy of an aggregation created by create() */
- void *(*clone)(const void *aggregation);
- /* Destroy an aggregation created by create() */
- void (*free)(void *aggregation);
- /* Record a new value against aggregation. */
- void (*record)(void *aggregation, double value);
- /* Return current aggregation data. The caller must cast this object into
- the correct type for the aggregation result. The object returned can be
- freed by using free_data(). */
- void *(*data)(const void *aggregation);
- /* free data returned by data() */
- void (*free_data)(void *data);
- /* Reset an aggregation to default (zero) values. */
- void (*reset)(void *aggregation);
- /* Merge 'from' aggregation into 'to'. Both aggregations must be compatible */
- void (*merge)(void *to, const void *from);
- /* Fill buffer with printable string version of aggregation contents. For
- debugging only. Returns the number of bytes added to buffer (a value == n
- implies the buffer was of insufficient size). */
- size_t (*print)(const void *aggregation, char *buffer, size_t n);
-};
-
-#endif /* GRPC_CORE_EXT_CENSUS_AGGREGATION_H */
diff --git a/src/core/ext/census/base_resources.c b/src/core/ext/census/base_resources.c
deleted file mode 100644
index 1f2bb39fe0..0000000000
--- a/src/core/ext/census/base_resources.c
+++ /dev/null
@@ -1,56 +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 "src/core/ext/census/base_resources.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <grpc/census.h>
-#include <grpc/support/log.h>
-
-#include "src/core/ext/census/resource.h"
-
-// Add base RPC resource definitions for use by RPC runtime.
-//
-// TODO(aveitch): All of these are currently hardwired definitions encoded in
-// the code in this file. These should be converted to use an external
-// configuration mechanism, in which these resources are defined in a text
-// file, which is compiled to .pb format and read by still-to-be-written
-// configuration functions.
-
-// Define all base resources. This should be called by census initialization.
-void define_base_resources() {
- google_census_Resource_BasicUnit numerator =
- google_census_Resource_BasicUnit_SECS;
- resource r = {(char *)"client_rpc_latency", // name
- (char *)"Client RPC latency in seconds", // description
- 0, // prefix
- 1, // n_numerators
- &numerator, // numerators
- 0, // n_denominators
- NULL}; // denominators
- define_resource(&r);
- r = (resource){(char *)"server_rpc_latency", // name
- (char *)"Server RPC latency in seconds", // description
- 0, // prefix
- 1, // n_numerators
- &numerator, // numerators
- 0, // n_denominators
- NULL}; // denominators
- define_resource(&r);
-}
diff --git a/src/core/ext/census/base_resources.h b/src/core/ext/census/base_resources.h
deleted file mode 100644
index 78a4d1fae5..0000000000
--- a/src/core/ext/census/base_resources.h
+++ /dev/null
@@ -1,24 +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.
- *
- */
-
-#ifndef GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H
-#define GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H
-
-/* Define all base resources. This should be called by census initialization. */
-void define_base_resources();
-
-#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */
diff --git a/src/core/ext/census/census_interface.h b/src/core/ext/census/census_interface.h
deleted file mode 100644
index a42b68ad65..0000000000
--- a/src/core/ext/census/census_interface.h
+++ /dev/null
@@ -1,61 +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_EXT_CENSUS_CENSUS_INTERFACE_H
-#define GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H
-
-#include <grpc/support/port_platform.h>
-
-/* Maximum length of an individual census trace annotation. */
-#define CENSUS_MAX_ANNOTATION_LENGTH 200
-
-/* Structure of a census op id. Define as structure because 64bit integer is not
- available on every platform for C89. */
-typedef struct census_op_id {
- uint32_t upper;
- uint32_t lower;
-} census_op_id;
-
-typedef struct census_rpc_stats census_rpc_stats;
-
-/* Initializes Census library. No-op if Census is already initialized. */
-void census_init(void);
-
-/* Shutdown Census Library. */
-void census_shutdown(void);
-
-/* Annotates grpc method name on a census_op_id. The method name has the format
- of <full quantified rpc service name>/<rpc function name>. Returns 0 iff
- op_id and method_name are all valid. op_id is valid after its creation and
- before calling census_tracing_end_op().
-
- TODO(hongyu): Figure out valid characters set for service name and command
- name and document requirements here.*/
-int census_add_method_tag(census_op_id op_id, const char *method_name);
-
-/* Annotates tracing information to a specific op_id.
- Up to CENSUS_MAX_ANNOTATION_LENGTH bytes are recorded. */
-void census_tracing_print(census_op_id op_id, const char *annotation);
-
-/* Starts tracing for an RPC. Returns a locally unique census_op_id */
-census_op_id census_tracing_start_op(void);
-
-/* Ends tracing. Calling this function will invalidate the input op_id. */
-void census_tracing_end_op(census_op_id op_id);
-
-#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H */
diff --git a/src/core/ext/census/census_log.c b/src/core/ext/census/census_log.c
deleted file mode 100644
index 100047f12b..0000000000
--- a/src/core/ext/census/census_log.c
+++ /dev/null
@@ -1,588 +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.
- *
- */
-
-/* Available log space is divided up in blocks of
- CENSUS_LOG_2_MAX_RECORD_SIZE bytes. A block can be in one of the
- following three data structures:
- - Free blocks (free_block_list)
- - Blocks with unread data (dirty_block_list)
- - Blocks currently attached to cores (core_local_blocks[])
-
- census_log_start_write() moves a block from core_local_blocks[] to the
- end of dirty_block_list when block:
- - is out-of-space OR
- - has an incomplete record (an incomplete record occurs when a thread calls
- census_log_start_write() and is context-switched before calling
- census_log_end_write()
- So, blocks in dirty_block_list are ordered, from oldest to newest, by time
- when block is detached from the core.
-
- census_log_read_next() first iterates over dirty_block_list and then
- core_local_blocks[]. It moves completely read blocks from dirty_block_list
- to free_block_list. Blocks in core_local_blocks[] are not freed, even when
- completely read.
-
- If log is configured to discard old records and free_block_list is empty,
- census_log_start_write() iterates over dirty_block_list to allocate a
- new block. It moves the oldest available block (no pending read/write) to
- core_local_blocks[].
-
- core_local_block_struct is used to implement a map from core id to the block
- associated with that core. This mapping is advisory. It is possible that the
- block returned by this mapping is no longer associated with that core. This
- mapping is updated, lazily, by census_log_start_write().
-
- Locking in block struct:
-
- Exclusive g_log.lock must be held before calling any functions operatong on
- block structs except census_log_start_write() and
- census_log_end_write().
-
- Writes to a block are serialized via writer_lock.
- census_log_start_write() acquires this lock and
- census_log_end_write() releases it. On failure to acquire the lock,
- writer allocates a new block for the current core and updates
- core_local_block accordingly.
-
- Simultaneous read and write access is allowed. Reader can safely read up to
- committed bytes (bytes_committed).
-
- reader_lock protects the block, currently being read, from getting recycled.
- start_read() acquires reader_lock and end_read() releases the lock.
-
- Read/write access to a block is disabled via try_disable_access(). It returns
- with both writer_lock and reader_lock held. These locks are subsequently
- released by enable_access() to enable access to the block.
-
- A note on naming: Most function/struct names are prepended by cl_
- (shorthand for census_log). Further, functions that manipulate structures
- include the name of the structure, which will be passed as the first
- argument. E.g. cl_block_initialize() will initialize a cl_block.
-*/
-#include "src/core/ext/census/census_log.h"
-#include <grpc/support/alloc.h>
-#include <grpc/support/atm.h>
-#include <grpc/support/cpu.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/useful.h>
-#include <string.h>
-
-/* End of platform specific code */
-
-typedef struct census_log_block_list_struct {
- struct census_log_block_list_struct *next;
- struct census_log_block_list_struct *prev;
- struct census_log_block *block;
-} cl_block_list_struct;
-
-typedef struct census_log_block {
- /* Pointer to underlying buffer */
- char *buffer;
- gpr_atm writer_lock;
- gpr_atm reader_lock;
- /* Keeps completely written bytes. Declared atomic because accessed
- simultaneously by reader and writer. */
- gpr_atm bytes_committed;
- /* Bytes already read */
- int32_t bytes_read;
- /* Links for list */
- cl_block_list_struct link;
-/* We want this structure to be cacheline aligned. We assume the following
- sizes for the various parts on 32/64bit systems:
- type 32b size 64b size
- char* 4 8
- 3x gpr_atm 12 24
- int32_t 4 8 (assumes padding)
- cl_block_list_struct 12 24
- TOTAL 32 64
-
- Depending on the size of our cacheline and the architecture, we
- selectively add char buffering to this structure. The size is checked
- via assert in census_log_initialize(). */
-#if defined(GPR_ARCH_64)
-#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 64)
-#else
-#if defined(GPR_ARCH_32)
-#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 32)
-#else
-#error "Unknown architecture"
-#endif
-#endif
-#if CL_BLOCK_PAD_SIZE > 0
- char padding[CL_BLOCK_PAD_SIZE];
-#endif
-} cl_block;
-
-/* A list of cl_blocks, doubly-linked through cl_block::link. */
-typedef struct census_log_block_list {
- int32_t count; /* Number of items in list. */
- cl_block_list_struct ht; /* head/tail of linked list. */
-} cl_block_list;
-
-/* Cacheline aligned block pointers to avoid false sharing. Block pointer must
- be initialized via set_block(), before calling other functions */
-typedef struct census_log_core_local_block {
- gpr_atm block;
-/* Ensure cachline alignment: we assume sizeof(gpr_atm) == 4 or 8 */
-#if defined(GPR_ARCH_64)
-#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 8)
-#else
-#if defined(GPR_ARCH_32)
-#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 4)
-#else
-#error "Unknown architecture"
-#endif
-#endif
-#if CL_CORE_LOCAL_BLOCK_PAD_SIZE > 0
- char padding[CL_CORE_LOCAL_BLOCK_PAD_SIZE];
-#endif
-} cl_core_local_block;
-
-struct census_log {
- int discard_old_records;
- /* Number of cores (aka hardware-contexts) */
- unsigned num_cores;
- /* number of CENSUS_LOG_2_MAX_RECORD_SIZE blocks in log */
- int32_t num_blocks;
- cl_block *blocks; /* Block metadata. */
- cl_core_local_block *core_local_blocks; /* Keeps core to block mappings. */
- gpr_mu lock;
- int initialized; /* has log been initialized? */
- /* Keeps the state of the reader iterator. A value of 0 indicates that
- iterator has reached the end. census_log_init_reader() resets the
- value to num_core to restart iteration. */
- uint32_t read_iterator_state;
- /* Points to the block being read. If non-NULL, the block is locked for
- reading (block_being_read_->reader_lock is held). */
- cl_block *block_being_read;
- /* A non-zero value indicates that log is full. */
- gpr_atm is_full;
- char *buffer;
- cl_block_list free_block_list;
- cl_block_list dirty_block_list;
- gpr_atm out_of_space_count;
-};
-
-/* Single internal log */
-static struct census_log g_log;
-
-/* Functions that operate on an atomic memory location used as a lock */
-
-/* Returns non-zero if lock is acquired */
-static int cl_try_lock(gpr_atm *lock) { return gpr_atm_acq_cas(lock, 0, 1); }
-
-static void cl_unlock(gpr_atm *lock) { gpr_atm_rel_store(lock, 0); }
-
-/* Functions that operate on cl_core_local_block's */
-
-static void cl_core_local_block_set_block(cl_core_local_block *clb,
- cl_block *block) {
- gpr_atm_rel_store(&clb->block, (gpr_atm)block);
-}
-
-static cl_block *cl_core_local_block_get_block(cl_core_local_block *clb) {
- return (cl_block *)gpr_atm_acq_load(&clb->block);
-}
-
-/* Functions that operate on cl_block_list_struct's */
-
-static void cl_block_list_struct_initialize(cl_block_list_struct *bls,
- cl_block *block) {
- bls->next = bls->prev = bls;
- bls->block = block;
-}
-
-/* Functions that operate on cl_block_list's */
-
-static void cl_block_list_initialize(cl_block_list *list) {
- list->count = 0;
- cl_block_list_struct_initialize(&list->ht, NULL);
-}
-
-/* Returns head of *this, or NULL if empty. */
-static cl_block *cl_block_list_head(cl_block_list *list) {
- return list->ht.next->block;
-}
-
-/* Insert element *e after *pos. */
-static void cl_block_list_insert(cl_block_list *list, cl_block_list_struct *pos,
- cl_block_list_struct *e) {
- list->count++;
- e->next = pos->next;
- e->prev = pos;
- e->next->prev = e;
- e->prev->next = e;
-}
-
-/* Insert block at the head of the list */
-static void cl_block_list_insert_at_head(cl_block_list *list, cl_block *block) {
- cl_block_list_insert(list, &list->ht, &block->link);
-}
-
-/* Insert block at the tail of the list */
-static void cl_block_list_insert_at_tail(cl_block_list *list, cl_block *block) {
- cl_block_list_insert(list, list->ht.prev, &block->link);
-}
-
-/* Removes block *b. Requires *b be in the list. */
-static void cl_block_list_remove(cl_block_list *list, cl_block *b) {
- list->count--;
- b->link.next->prev = b->link.prev;
- b->link.prev->next = b->link.next;
-}
-
-/* Functions that operate on cl_block's */
-
-static void cl_block_initialize(cl_block *block, char *buffer) {
- block->buffer = buffer;
- gpr_atm_rel_store(&block->writer_lock, 0);
- gpr_atm_rel_store(&block->reader_lock, 0);
- gpr_atm_rel_store(&block->bytes_committed, 0);
- block->bytes_read = 0;
- cl_block_list_struct_initialize(&block->link, block);
-}
-
-/* Guards against exposing partially written buffer to the reader. */
-static void cl_block_set_bytes_committed(cl_block *block,
- int32_t bytes_committed) {
- gpr_atm_rel_store(&block->bytes_committed, bytes_committed);
-}
-
-static int32_t cl_block_get_bytes_committed(cl_block *block) {
- return gpr_atm_acq_load(&block->bytes_committed);
-}
-
-/* Tries to disable future read/write access to this block. Succeeds if:
- - no in-progress write AND
- - no in-progress read AND
- - 'discard_data' set to true OR no unread data
- On success, clears the block state and returns with writer_lock_ and
- reader_lock_ held. These locks are released by a subsequent
- cl_block_access_enable() call. */
-static int cl_block_try_disable_access(cl_block *block, int discard_data) {
- if (!cl_try_lock(&block->writer_lock)) {
- return 0;
- }
- if (!cl_try_lock(&block->reader_lock)) {
- cl_unlock(&block->writer_lock);
- return 0;
- }
- if (!discard_data &&
- (block->bytes_read != cl_block_get_bytes_committed(block))) {
- cl_unlock(&block->reader_lock);
- cl_unlock(&block->writer_lock);
- return 0;
- }
- cl_block_set_bytes_committed(block, 0);
- block->bytes_read = 0;
- return 1;
-}
-
-static void cl_block_enable_access(cl_block *block) {
- cl_unlock(&block->reader_lock);
- cl_unlock(&block->writer_lock);
-}
-
-/* Returns with writer_lock held. */
-static void *cl_block_start_write(cl_block *block, size_t size) {
- int32_t bytes_committed;
- if (!cl_try_lock(&block->writer_lock)) {
- return NULL;
- }
- bytes_committed = cl_block_get_bytes_committed(block);
- if (bytes_committed + size > CENSUS_LOG_MAX_RECORD_SIZE) {
- cl_unlock(&block->writer_lock);
- return NULL;
- }
- return block->buffer + bytes_committed;
-}
-
-/* Releases writer_lock and increments committed bytes by 'bytes_written'.
- 'bytes_written' must be <= 'size' specified in the corresponding
- StartWrite() call. This function is thread-safe. */
-static void cl_block_end_write(cl_block *block, size_t bytes_written) {
- cl_block_set_bytes_committed(
- block, cl_block_get_bytes_committed(block) + bytes_written);
- cl_unlock(&block->writer_lock);
-}
-
-/* Returns a pointer to the first unread byte in buffer. The number of bytes
- available are returned in 'bytes_available'. Acquires reader lock that is
- released by a subsequent cl_block_end_read() call. Returns NULL if:
- - read in progress
- - no data available */
-static void *cl_block_start_read(cl_block *block, size_t *bytes_available) {
- void *record;
- if (!cl_try_lock(&block->reader_lock)) {
- return NULL;
- }
- /* bytes_committed may change from under us. Use bytes_available to update
- bytes_read below. */
- *bytes_available = cl_block_get_bytes_committed(block) - block->bytes_read;
- if (*bytes_available == 0) {
- cl_unlock(&block->reader_lock);
- return NULL;
- }
- record = block->buffer + block->bytes_read;
- block->bytes_read += *bytes_available;
- return record;
-}
-
-static void cl_block_end_read(cl_block *block) {
- cl_unlock(&block->reader_lock);
-}
-
-/* Internal functions operating on g_log */
-
-/* Allocates a new free block (or recycles an available dirty block if log is
- configured to discard old records). Returns NULL if out-of-space. */
-static cl_block *cl_allocate_block(void) {
- cl_block *block = cl_block_list_head(&g_log.free_block_list);
- if (block != NULL) {
- cl_block_list_remove(&g_log.free_block_list, block);
- return block;
- }
- if (!g_log.discard_old_records) {
- /* No free block and log is configured to keep old records. */
- return NULL;
- }
- /* Recycle dirty block. Start from the oldest. */
- for (block = cl_block_list_head(&g_log.dirty_block_list); block != NULL;
- block = block->link.next->block) {
- if (cl_block_try_disable_access(block, 1 /* discard data */)) {
- cl_block_list_remove(&g_log.dirty_block_list, block);
- return block;
- }
- }
- return NULL;
-}
-
-/* Allocates a new block and updates core id => block mapping. 'old_block'
- points to the block that the caller thinks is attached to
- 'core_id'. 'old_block' may be NULL. Returns non-zero if:
- - allocated a new block OR
- - 'core_id' => 'old_block' mapping changed (another thread allocated a
- block before lock was acquired). */
-static int cl_allocate_core_local_block(int32_t core_id, cl_block *old_block) {
- /* Now that we have the lock, check if core-local mapping has changed. */
- cl_core_local_block *core_local_block = &g_log.core_local_blocks[core_id];
- cl_block *block = cl_core_local_block_get_block(core_local_block);
- if ((block != NULL) && (block != old_block)) {
- return 1;
- }
- if (block != NULL) {
- cl_core_local_block_set_block(core_local_block, NULL);
- cl_block_list_insert_at_tail(&g_log.dirty_block_list, block);
- }
- block = cl_allocate_block();
- if (block == NULL) {
- gpr_atm_rel_store(&g_log.is_full, 1);
- return 0;
- }
- cl_core_local_block_set_block(core_local_block, block);
- cl_block_enable_access(block);
- return 1;
-}
-
-static cl_block *cl_get_block(void *record) {
- uintptr_t p = (uintptr_t)((char *)record - g_log.buffer);
- uintptr_t index = p >> CENSUS_LOG_2_MAX_RECORD_SIZE;
- return &g_log.blocks[index];
-}
-
-/* Gets the next block to read and tries to free 'prev' block (if not NULL).
- Returns NULL if reached the end. */
-static cl_block *cl_next_block_to_read(cl_block *prev) {
- cl_block *block = NULL;
- if (g_log.read_iterator_state == g_log.num_cores) {
- /* We are traversing dirty list; find the next dirty block. */
- if (prev != NULL) {
- /* Try to free the previous block if there is no unread data. This block
- may have unread data if previously incomplete record completed between
- read_next() calls. */
- block = prev->link.next->block;
- if (cl_block_try_disable_access(prev, 0 /* do not discard data */)) {
- cl_block_list_remove(&g_log.dirty_block_list, prev);
- cl_block_list_insert_at_head(&g_log.free_block_list, prev);
- gpr_atm_rel_store(&g_log.is_full, 0);
- }
- } else {
- block = cl_block_list_head(&g_log.dirty_block_list);
- }
- if (block != NULL) {
- return block;
- }
- /* We are done with the dirty list; moving on to core-local blocks. */
- }
- while (g_log.read_iterator_state > 0) {
- g_log.read_iterator_state--;
- block = cl_core_local_block_get_block(
- &g_log.core_local_blocks[g_log.read_iterator_state]);
- if (block != NULL) {
- return block;
- }
- }
- return NULL;
-}
-
-/* External functions: primary stats_log interface */
-void census_log_initialize(size_t size_in_mb, int discard_old_records) {
- int32_t ix;
- /* Check cacheline alignment. */
- GPR_ASSERT(sizeof(cl_block) % GPR_CACHELINE_SIZE == 0);
- GPR_ASSERT(sizeof(cl_core_local_block) % GPR_CACHELINE_SIZE == 0);
- GPR_ASSERT(!g_log.initialized);
- g_log.discard_old_records = discard_old_records;
- g_log.num_cores = gpr_cpu_num_cores();
- /* Ensure at least as many blocks as there are cores. */
- g_log.num_blocks = GPR_MAX(
- g_log.num_cores, (size_in_mb << 20) >> CENSUS_LOG_2_MAX_RECORD_SIZE);
- gpr_mu_init(&g_log.lock);
- g_log.read_iterator_state = 0;
- g_log.block_being_read = NULL;
- gpr_atm_rel_store(&g_log.is_full, 0);
- g_log.core_local_blocks = (cl_core_local_block *)gpr_malloc_aligned(
- g_log.num_cores * sizeof(cl_core_local_block), GPR_CACHELINE_SIZE_LOG);
- memset(g_log.core_local_blocks, 0,
- g_log.num_cores * sizeof(cl_core_local_block));
- g_log.blocks = (cl_block *)gpr_malloc_aligned(
- g_log.num_blocks * sizeof(cl_block), GPR_CACHELINE_SIZE_LOG);
- memset(g_log.blocks, 0, g_log.num_blocks * sizeof(cl_block));
- g_log.buffer = gpr_malloc(g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE);
- memset(g_log.buffer, 0, g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE);
- cl_block_list_initialize(&g_log.free_block_list);
- cl_block_list_initialize(&g_log.dirty_block_list);
- for (ix = 0; ix < g_log.num_blocks; ++ix) {
- cl_block *block = g_log.blocks + ix;
- cl_block_initialize(block,
- g_log.buffer + (CENSUS_LOG_MAX_RECORD_SIZE * ix));
- cl_block_try_disable_access(block, 1 /* discard data */);
- cl_block_list_insert_at_tail(&g_log.free_block_list, block);
- }
- gpr_atm_rel_store(&g_log.out_of_space_count, 0);
- g_log.initialized = 1;
-}
-
-void census_log_shutdown(void) {
- GPR_ASSERT(g_log.initialized);
- gpr_mu_destroy(&g_log.lock);
- gpr_free_aligned(g_log.core_local_blocks);
- g_log.core_local_blocks = NULL;
- gpr_free_aligned(g_log.blocks);
- g_log.blocks = NULL;
- gpr_free(g_log.buffer);
- g_log.buffer = NULL;
- g_log.initialized = 0;
-}
-
-void *census_log_start_write(size_t size) {
- /* Used to bound number of times block allocation is attempted. */
- int32_t attempts_remaining = g_log.num_blocks;
- /* TODO(aveitch): move this inside the do loop when current_cpu is fixed */
- int32_t core_id = gpr_cpu_current_cpu();
- GPR_ASSERT(g_log.initialized);
- if (size > CENSUS_LOG_MAX_RECORD_SIZE) {
- return NULL;
- }
- do {
- int allocated;
- void *record = NULL;
- cl_block *block =
- cl_core_local_block_get_block(&g_log.core_local_blocks[core_id]);
- if (block && (record = cl_block_start_write(block, size))) {
- return record;
- }
- /* Need to allocate a new block. We are here if:
- - No block associated with the core OR
- - Write in-progress on the block OR
- - block is out of space */
- if (gpr_atm_acq_load(&g_log.is_full)) {
- gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
- return NULL;
- }
- gpr_mu_lock(&g_log.lock);
- allocated = cl_allocate_core_local_block(core_id, block);
- gpr_mu_unlock(&g_log.lock);
- if (!allocated) {
- gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
- return NULL;
- }
- } while (attempts_remaining--);
- /* Give up. */
- gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
- return NULL;
-}
-
-void census_log_end_write(void *record, size_t bytes_written) {
- GPR_ASSERT(g_log.initialized);
- cl_block_end_write(cl_get_block(record), bytes_written);
-}
-
-void census_log_init_reader(void) {
- GPR_ASSERT(g_log.initialized);
- gpr_mu_lock(&g_log.lock);
- /* If a block is locked for reading unlock it. */
- if (g_log.block_being_read != NULL) {
- cl_block_end_read(g_log.block_being_read);
- g_log.block_being_read = NULL;
- }
- g_log.read_iterator_state = g_log.num_cores;
- gpr_mu_unlock(&g_log.lock);
-}
-
-const void *census_log_read_next(size_t *bytes_available) {
- GPR_ASSERT(g_log.initialized);
- gpr_mu_lock(&g_log.lock);
- if (g_log.block_being_read != NULL) {
- cl_block_end_read(g_log.block_being_read);
- }
- do {
- g_log.block_being_read = cl_next_block_to_read(g_log.block_being_read);
- if (g_log.block_being_read != NULL) {
- void *record =
- cl_block_start_read(g_log.block_being_read, bytes_available);
- if (record != NULL) {
- gpr_mu_unlock(&g_log.lock);
- return record;
- }
- }
- } while (g_log.block_being_read != NULL);
- gpr_mu_unlock(&g_log.lock);
- return NULL;
-}
-
-size_t census_log_remaining_space(void) {
- size_t space;
- GPR_ASSERT(g_log.initialized);
- gpr_mu_lock(&g_log.lock);
- if (g_log.discard_old_records) {
- /* Remaining space is not meaningful; just return the entire log space. */
- space = g_log.num_blocks << CENSUS_LOG_2_MAX_RECORD_SIZE;
- } else {
- space = g_log.free_block_list.count * CENSUS_LOG_MAX_RECORD_SIZE;
- }
- gpr_mu_unlock(&g_log.lock);
- return space;
-}
-
-int census_log_out_of_space_count(void) {
- GPR_ASSERT(g_log.initialized);
- return gpr_atm_acq_load(&g_log.out_of_space_count);
-}
diff --git a/src/core/ext/census/census_log.h b/src/core/ext/census/census_log.h
deleted file mode 100644
index 6b68b6bd37..0000000000
--- a/src/core/ext/census/census_log.h
+++ /dev/null
@@ -1,76 +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_EXT_CENSUS_CENSUS_LOG_H
-#define GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H
-
-#include <stddef.h>
-
-/* Maximum record size, in bytes. */
-#define CENSUS_LOG_2_MAX_RECORD_SIZE 14 /* 2^14 = 16KB */
-#define CENSUS_LOG_MAX_RECORD_SIZE (1 << CENSUS_LOG_2_MAX_RECORD_SIZE)
-
-/* Initialize the statistics logging subsystem with the given log size. A log
- size of 0 will result in the smallest possible log for the platform
- (approximately CENSUS_LOG_MAX_RECORD_SIZE * gpr_cpu_num_cores()). If
- discard_old_records is non-zero, then new records will displace older ones
- when the log is full. This function must be called before any other
- census_log functions.
-*/
-void census_log_initialize(size_t size_in_mb, int discard_old_records);
-
-/* Shutdown the logging subsystem. Caller must ensure that:
- - no in progress or future call to any census_log functions
- - no incomplete records
-*/
-void census_log_shutdown(void);
-
-/* Allocates and returns a 'size' bytes record and marks it in use. A
- subsequent census_log_end_write() marks the record complete. The
- 'bytes_written' census_log_end_write() argument must be <=
- 'size'. Returns NULL if out-of-space AND:
- - log is configured to keep old records OR
- - all blocks are pinned by incomplete records.
-*/
-void *census_log_start_write(size_t size);
-
-void census_log_end_write(void *record, size_t bytes_written);
-
-/* census_log_read_next() iterates over blocks with data and for each block
- returns a pointer to the first unread byte. The number of bytes that can be
- read are returned in 'bytes_available'. Reader is expected to read all
- available data. Reading the data consumes it i.e. it cannot be read again.
- census_log_read_next() returns NULL if the end is reached i.e last block
- is read. census_log_init_reader() starts the iteration or aborts the
- current iteration.
-*/
-void census_log_init_reader(void);
-const void *census_log_read_next(size_t *bytes_available);
-
-/* Returns estimated remaining space across all blocks, in bytes. If log is
- configured to discard old records, returns total log space. Otherwise,
- returns space available in empty blocks (partially filled blocks are
- treated as full).
-*/
-size_t census_log_remaining_space(void);
-
-/* Returns the number of times grpc_stats_log_start_write() failed due to
- out-of-space. */
-int census_log_out_of_space_count(void);
-
-#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H */
diff --git a/src/core/ext/census/census_rpc_stats.c b/src/core/ext/census/census_rpc_stats.c
deleted file mode 100644
index 0aca1f109e..0000000000
--- a/src/core/ext/census/census_rpc_stats.c
+++ /dev/null
@@ -1,238 +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 <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include "src/core/ext/census/census_interface.h"
-#include "src/core/ext/census/census_rpc_stats.h"
-#include "src/core/ext/census/census_tracing.h"
-#include "src/core/ext/census/hash_table.h"
-#include "src/core/ext/census/window_stats.h"
-#include "src/core/lib/support/murmur_hash.h"
-#include "src/core/lib/support/string.h"
-
-#define NUM_INTERVALS 3
-#define MINUTE_INTERVAL 0
-#define HOUR_INTERVAL 1
-#define TOTAL_INTERVAL 2
-
-/* for easier typing */
-typedef census_per_method_rpc_stats per_method_stats;
-
-/* Ensure mu is only initialized once. */
-static gpr_once g_stats_store_mu_init = GPR_ONCE_INIT;
-/* Guards two stats stores. */
-static gpr_mu g_mu;
-static census_ht *g_client_stats_store = NULL;
-static census_ht *g_server_stats_store = NULL;
-
-static void init_mutex(void) { gpr_mu_init(&g_mu); }
-
-static void init_mutex_once(void) {
- gpr_once_init(&g_stats_store_mu_init, init_mutex);
-}
-
-static int cmp_str_keys(const void *k1, const void *k2) {
- return strcmp((const char *)k1, (const char *)k2);
-}
-
-/* TODO(hongyu): replace it with cityhash64 */
-static uint64_t simple_hash(const void *k) {
- size_t len = strlen(k);
- uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0);
- return higher << 32 |
- gpr_murmur_hash3((const char *)k + len / 2, len - len / 2, 0);
-}
-
-static void delete_stats(void *stats) {
- census_window_stats_destroy((struct census_window_stats *)stats);
-}
-
-static void delete_key(void *key) { gpr_free(key); }
-
-static const census_ht_option ht_opt = {
- CENSUS_HT_POINTER /* key type */, 1999 /* n_of_buckets */,
- simple_hash /* hash function */, cmp_str_keys /* key comparator */,
- delete_stats /* data deleter */, delete_key /* key deleter */
-};
-
-static void init_rpc_stats(void *stats) {
- memset(stats, 0, sizeof(census_rpc_stats));
-}
-
-static void stat_add_proportion(double p, void *base, const void *addme) {
- census_rpc_stats *b = (census_rpc_stats *)base;
- census_rpc_stats *a = (census_rpc_stats *)addme;
- b->cnt += p * a->cnt;
- b->rpc_error_cnt += p * a->rpc_error_cnt;
- b->app_error_cnt += p * a->app_error_cnt;
- b->elapsed_time_ms += p * a->elapsed_time_ms;
- b->api_request_bytes += p * a->api_request_bytes;
- b->wire_request_bytes += p * a->wire_request_bytes;
- b->api_response_bytes += p * a->api_response_bytes;
- b->wire_response_bytes += p * a->wire_response_bytes;
-}
-
-static void stat_add(void *base, const void *addme) {
- stat_add_proportion(1.0, base, addme);
-}
-
-static gpr_timespec min_hour_total_intervals[3] = {
- {60, 0}, {3600, 0}, {36000000, 0}};
-
-static const census_window_stats_stat_info window_stats_settings = {
- sizeof(census_rpc_stats), init_rpc_stats, stat_add, stat_add_proportion};
-
-census_rpc_stats *census_rpc_stats_create_empty(void) {
- census_rpc_stats *ret =
- (census_rpc_stats *)gpr_malloc(sizeof(census_rpc_stats));
- memset(ret, 0, sizeof(census_rpc_stats));
- return ret;
-}
-
-void census_aggregated_rpc_stats_set_empty(census_aggregated_rpc_stats *data) {
- int i = 0;
- for (i = 0; i < data->num_entries; i++) {
- if (data->stats[i].method != NULL) {
- gpr_free((void *)data->stats[i].method);
- }
- }
- if (data->stats != NULL) {
- gpr_free(data->stats);
- }
- data->num_entries = 0;
- data->stats = NULL;
-}
-
-static void record_stats(census_ht *store, census_op_id op_id,
- const census_rpc_stats *stats) {
- gpr_mu_lock(&g_mu);
- if (store != NULL) {
- census_trace_obj *trace = NULL;
- census_internal_lock_trace_store();
- trace = census_get_trace_obj_locked(op_id);
- if (trace != NULL) {
- const char *method_name = census_get_trace_method_name(trace);
- struct census_window_stats *window_stats = NULL;
- census_ht_key key;
- key.ptr = (void *)method_name;
- window_stats = census_ht_find(store, key);
- census_internal_unlock_trace_store();
- if (window_stats == NULL) {
- window_stats = census_window_stats_create(3, min_hour_total_intervals,
- 30, &window_stats_settings);
- key.ptr = gpr_strdup(key.ptr);
- census_ht_insert(store, key, (void *)window_stats);
- }
- census_window_stats_add(window_stats, gpr_now(GPR_CLOCK_REALTIME), stats);
- } else {
- census_internal_unlock_trace_store();
- }
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_record_rpc_client_stats(census_op_id op_id,
- const census_rpc_stats *stats) {
- record_stats(g_client_stats_store, op_id, stats);
-}
-
-void census_record_rpc_server_stats(census_op_id op_id,
- const census_rpc_stats *stats) {
- record_stats(g_server_stats_store, op_id, stats);
-}
-
-/* Get stats from input stats store */
-static void get_stats(census_ht *store, census_aggregated_rpc_stats *data) {
- GPR_ASSERT(data != NULL);
- if (data->num_entries != 0) {
- census_aggregated_rpc_stats_set_empty(data);
- }
- gpr_mu_lock(&g_mu);
- if (store != NULL) {
- size_t n;
- unsigned i, j;
- gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
- census_ht_kv *kv = census_ht_get_all_elements(store, &n);
- if (kv != NULL) {
- data->num_entries = n;
- data->stats =
- (per_method_stats *)gpr_malloc(sizeof(per_method_stats) * n);
- for (i = 0; i < n; i++) {
- census_window_stats_sums sums[NUM_INTERVALS];
- for (j = 0; j < NUM_INTERVALS; j++) {
- sums[j].statistic = (void *)census_rpc_stats_create_empty();
- }
- data->stats[i].method = gpr_strdup(kv[i].k.ptr);
- census_window_stats_get_sums(kv[i].v, now, sums);
- data->stats[i].minute_stats =
- *(census_rpc_stats *)sums[MINUTE_INTERVAL].statistic;
- data->stats[i].hour_stats =
- *(census_rpc_stats *)sums[HOUR_INTERVAL].statistic;
- data->stats[i].total_stats =
- *(census_rpc_stats *)sums[TOTAL_INTERVAL].statistic;
- for (j = 0; j < NUM_INTERVALS; j++) {
- gpr_free(sums[j].statistic);
- }
- }
- gpr_free(kv);
- }
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_get_client_stats(census_aggregated_rpc_stats *data) {
- get_stats(g_client_stats_store, data);
-}
-
-void census_get_server_stats(census_aggregated_rpc_stats *data) {
- get_stats(g_server_stats_store, data);
-}
-
-void census_stats_store_init(void) {
- init_mutex_once();
- gpr_mu_lock(&g_mu);
- if (g_client_stats_store == NULL && g_server_stats_store == NULL) {
- g_client_stats_store = census_ht_create(&ht_opt);
- g_server_stats_store = census_ht_create(&ht_opt);
- } else {
- gpr_log(GPR_ERROR, "Census stats store already initialized.");
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_stats_store_shutdown(void) {
- init_mutex_once();
- gpr_mu_lock(&g_mu);
- if (g_client_stats_store != NULL) {
- census_ht_destroy(g_client_stats_store);
- g_client_stats_store = NULL;
- } else {
- gpr_log(GPR_ERROR, "Census server stats store not initialized.");
- }
- if (g_server_stats_store != NULL) {
- census_ht_destroy(g_server_stats_store);
- g_server_stats_store = NULL;
- } else {
- gpr_log(GPR_ERROR, "Census client stats store not initialized.");
- }
- gpr_mu_unlock(&g_mu);
-}
diff --git a/src/core/ext/census/census_rpc_stats.h b/src/core/ext/census/census_rpc_stats.h
deleted file mode 100644
index 8004ade37d..0000000000
--- a/src/core/ext/census/census_rpc_stats.h
+++ /dev/null
@@ -1,86 +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_EXT_CENSUS_CENSUS_RPC_STATS_H
-#define GRPC_CORE_EXT_CENSUS_CENSUS_RPC_STATS_H
-
-#include <grpc/support/port_platform.h>
-#include "src/core/ext/census/census_interface.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct census_rpc_stats {
- uint64_t cnt;
- uint64_t rpc_error_cnt;
- uint64_t app_error_cnt;
- double elapsed_time_ms;
- double api_request_bytes;
- double wire_request_bytes;
- double api_response_bytes;
- double wire_response_bytes;
-};
-
-/* Creates an empty rpc stats object on heap. */
-census_rpc_stats *census_rpc_stats_create_empty(void);
-
-typedef struct census_per_method_rpc_stats {
- const char *method;
- census_rpc_stats minute_stats; /* cumulative stats in the past minute */
- census_rpc_stats hour_stats; /* cumulative stats in the past hour */
- census_rpc_stats total_stats; /* cumulative stats from last gc */
-} census_per_method_rpc_stats;
-
-typedef struct census_aggregated_rpc_stats {
- int num_entries;
- census_per_method_rpc_stats *stats;
-} census_aggregated_rpc_stats;
-
-/* Initializes an aggregated rpc stats object to an empty state. */
-void census_aggregated_rpc_stats_set_empty(census_aggregated_rpc_stats *data);
-
-/* Records client side stats of a rpc. */
-void census_record_rpc_client_stats(census_op_id op_id,
- const census_rpc_stats *stats);
-
-/* Records server side stats of a rpc. */
-void census_record_rpc_server_stats(census_op_id op_id,
- const census_rpc_stats *stats);
-
-/* The following two functions are intended for inprocess query of
- per-service per-method stats from grpc implementations. */
-
-/* Populates *data_map with server side aggregated per-service per-method
- stats.
- DO NOT CALL from outside of grpc code. */
-void census_get_server_stats(census_aggregated_rpc_stats *data_map);
-
-/* Populates *data_map with client side aggregated per-service per-method
- stats.
- DO NOT CALL from outside of grpc code. */
-void census_get_client_stats(census_aggregated_rpc_stats *data_map);
-
-void census_stats_store_init(void);
-void census_stats_store_shutdown(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_RPC_STATS_H */
diff --git a/src/core/ext/census/census_tracing.c b/src/core/ext/census/census_tracing.c
deleted file mode 100644
index 199b260dd1..0000000000
--- a/src/core/ext/census/census_tracing.c
+++ /dev/null
@@ -1,226 +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/census/census_tracing.h"
-#include "src/core/ext/census/census_interface.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/sync.h>
-#include "src/core/ext/census/hash_table.h"
-#include "src/core/lib/support/string.h"
-
-void census_trace_obj_destroy(census_trace_obj *obj) {
- census_trace_annotation *p = obj->annotations;
- while (p != NULL) {
- census_trace_annotation *next = p->next;
- gpr_free(p);
- p = next;
- }
- gpr_free(obj->method);
- gpr_free(obj);
-}
-
-static void delete_trace_obj(void *obj) {
- census_trace_obj_destroy((census_trace_obj *)obj);
-}
-
-static const census_ht_option ht_opt = {
- CENSUS_HT_UINT64 /* key type */,
- 571 /* n_of_buckets */,
- NULL /* hash */,
- NULL /* compare_keys */,
- delete_trace_obj /* delete data */,
- NULL /* delete key */
-};
-
-static gpr_once g_init_mutex_once = GPR_ONCE_INIT;
-static gpr_mu g_mu; /* Guards following two static variables. */
-static census_ht *g_trace_store = NULL;
-static uint64_t g_id = 0;
-
-static census_ht_key op_id_as_key(census_op_id *id) {
- return *(census_ht_key *)id;
-}
-
-static uint64_t op_id_2_uint64(census_op_id *id) {
- uint64_t ret;
- memcpy(&ret, id, sizeof(census_op_id));
- return ret;
-}
-
-static void init_mutex(void) { gpr_mu_init(&g_mu); }
-
-static void init_mutex_once(void) {
- gpr_once_init(&g_init_mutex_once, init_mutex);
-}
-
-census_op_id census_tracing_start_op(void) {
- gpr_mu_lock(&g_mu);
- {
- census_trace_obj *ret = gpr_malloc(sizeof(census_trace_obj));
- memset(ret, 0, sizeof(census_trace_obj));
- g_id++;
- memcpy(&ret->id, &g_id, sizeof(census_op_id));
- ret->rpc_stats.cnt = 1;
- ret->ts = gpr_now(GPR_CLOCK_REALTIME);
- census_ht_insert(g_trace_store, op_id_as_key(&ret->id), (void *)ret);
- gpr_log(GPR_DEBUG, "Start tracing for id %lu", g_id);
- gpr_mu_unlock(&g_mu);
- return ret->id;
- }
-}
-
-int census_add_method_tag(census_op_id op_id, const char *method) {
- int ret = 0;
- census_trace_obj *trace = NULL;
- gpr_mu_lock(&g_mu);
- trace = census_ht_find(g_trace_store, op_id_as_key(&op_id));
- if (trace == NULL) {
- ret = 1;
- } else {
- trace->method = gpr_strdup(method);
- }
- gpr_mu_unlock(&g_mu);
- return ret;
-}
-
-void census_tracing_print(census_op_id op_id, const char *anno_txt) {
- census_trace_obj *trace = NULL;
- gpr_mu_lock(&g_mu);
- trace = census_ht_find(g_trace_store, op_id_as_key(&op_id));
- if (trace != NULL) {
- census_trace_annotation *anno = gpr_malloc(sizeof(census_trace_annotation));
- anno->ts = gpr_now(GPR_CLOCK_REALTIME);
- {
- char *d = anno->txt;
- const char *s = anno_txt;
- int n = 0;
- for (; n < CENSUS_MAX_ANNOTATION_LENGTH && *s != '\0'; ++n) {
- *d++ = *s++;
- }
- *d = '\0';
- }
- anno->next = trace->annotations;
- trace->annotations = anno;
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_tracing_end_op(census_op_id op_id) {
- census_trace_obj *trace = NULL;
- gpr_mu_lock(&g_mu);
- trace = census_ht_find(g_trace_store, op_id_as_key(&op_id));
- if (trace != NULL) {
- trace->rpc_stats.elapsed_time_ms = gpr_timespec_to_micros(
- gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), trace->ts));
- gpr_log(GPR_DEBUG, "End tracing for id %lu, method %s, latency %f us",
- op_id_2_uint64(&op_id), trace->method,
- trace->rpc_stats.elapsed_time_ms);
- census_ht_erase(g_trace_store, op_id_as_key(&op_id));
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_tracing_init(void) {
- init_mutex_once();
- gpr_mu_lock(&g_mu);
- if (g_trace_store == NULL) {
- g_id = 1;
- g_trace_store = census_ht_create(&ht_opt);
- } else {
- gpr_log(GPR_ERROR, "Census trace store already initialized.");
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_tracing_shutdown(void) {
- gpr_mu_lock(&g_mu);
- if (g_trace_store != NULL) {
- census_ht_destroy(g_trace_store);
- g_trace_store = NULL;
- } else {
- gpr_log(GPR_ERROR, "Census trace store is not initialized.");
- }
- gpr_mu_unlock(&g_mu);
-}
-
-void census_internal_lock_trace_store(void) { gpr_mu_lock(&g_mu); }
-
-void census_internal_unlock_trace_store(void) { gpr_mu_unlock(&g_mu); }
-
-census_trace_obj *census_get_trace_obj_locked(census_op_id op_id) {
- if (g_trace_store == NULL) {
- gpr_log(GPR_ERROR, "Census trace store is not initialized.");
- return NULL;
- }
- return (census_trace_obj *)census_ht_find(g_trace_store,
- op_id_as_key(&op_id));
-}
-
-const char *census_get_trace_method_name(const census_trace_obj *trace) {
- return trace->method;
-}
-
-static census_trace_annotation *dup_annotation_chain(
- census_trace_annotation *from) {
- census_trace_annotation *ret = NULL;
- census_trace_annotation **to = &ret;
- for (; from != NULL; from = from->next) {
- *to = gpr_malloc(sizeof(census_trace_annotation));
- memcpy(*to, from, sizeof(census_trace_annotation));
- to = &(*to)->next;
- }
- return ret;
-}
-
-static census_trace_obj *trace_obj_dup(census_trace_obj *from) {
- census_trace_obj *to = NULL;
- GPR_ASSERT(from != NULL);
- to = gpr_malloc(sizeof(census_trace_obj));
- to->id = from->id;
- to->ts = from->ts;
- to->rpc_stats = from->rpc_stats;
- to->method = gpr_strdup(from->method);
- to->annotations = dup_annotation_chain(from->annotations);
- return to;
-}
-
-census_trace_obj **census_get_active_ops(int *num_active_ops) {
- census_trace_obj **ret = NULL;
- gpr_mu_lock(&g_mu);
- if (g_trace_store != NULL) {
- size_t n = 0;
- census_ht_kv *all_kvs = census_ht_get_all_elements(g_trace_store, &n);
- *num_active_ops = (int)n;
- if (n != 0) {
- size_t i = 0;
- ret = gpr_malloc(sizeof(census_trace_obj *) * n);
- for (i = 0; i < n; i++) {
- ret[i] = trace_obj_dup((census_trace_obj *)all_kvs[i].v);
- }
- }
- gpr_free(all_kvs);
- }
- gpr_mu_unlock(&g_mu);
- return ret;
-}
diff --git a/src/core/ext/census/census_tracing.h b/src/core/ext/census/census_tracing.h
deleted file mode 100644
index ccb767fcd0..0000000000
--- a/src/core/ext/census/census_tracing.h
+++ /dev/null
@@ -1,81 +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_EXT_CENSUS_CENSUS_TRACING_H
-#define GRPC_CORE_EXT_CENSUS_CENSUS_TRACING_H
-
-#include <grpc/support/time.h>
-#include "src/core/ext/census/census_rpc_stats.h"
-
-/* WARNING: The data structures and APIs provided by this file are for GRPC
- library's internal use ONLY. They might be changed in backward-incompatible
- ways and are not subject to any deprecation policy.
- They are not recommended for external use.
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Struct for a trace annotation. */
-typedef struct census_trace_annotation {
- gpr_timespec ts; /* timestamp of the annotation */
- char txt[CENSUS_MAX_ANNOTATION_LENGTH + 1]; /* actual txt annotation */
- struct census_trace_annotation *next;
-} census_trace_annotation;
-
-typedef struct census_trace_obj {
- census_op_id id;
- gpr_timespec ts;
- census_rpc_stats rpc_stats;
- char *method;
- census_trace_annotation *annotations;
-} census_trace_obj;
-
-/* Deletes trace object. */
-void census_trace_obj_destroy(census_trace_obj *obj);
-
-/* Initializes trace store. This function is thread safe. */
-void census_tracing_init(void);
-
-/* Shutsdown trace store. This function is thread safe. */
-void census_tracing_shutdown(void);
-
-/* Gets trace obj corresponding to the input op_id. Returns NULL if trace store
- is not initialized or trace obj is not found. Requires trace store being
- locked before calling this function. */
-census_trace_obj *census_get_trace_obj_locked(census_op_id op_id);
-
-/* The following two functions acquire and release the trace store global lock.
- They are for census internal use only. */
-void census_internal_lock_trace_store(void);
-void census_internal_unlock_trace_store(void);
-
-/* Gets method name associated with the input trace object. */
-const char *census_get_trace_method_name(const census_trace_obj *trace);
-
-/* Returns an array of pointers to trace objects of currently active operations
- and fills in number of active operations. Returns NULL if there are no active
- operations.
- Caller owns the returned objects. */
-census_trace_obj **census_get_active_ops(int *num_active_ops);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_TRACING_H */
diff --git a/src/core/ext/census/context.c b/src/core/ext/census/context.c
deleted file mode 100644
index 9b25a32e36..0000000000
--- a/src/core/ext/census/context.c
+++ /dev/null
@@ -1,496 +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 <grpc/census.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/useful.h>
-#include <stdbool.h>
-#include <string.h>
-#include "src/core/lib/support/string.h"
-
-// Functions in this file support the public context API, including
-// encoding/decoding as part of context propagation across RPC's. The overall
-// requirements (in approximate priority order) for the
-// context representation:
-// 1. Efficient conversion to/from wire format
-// 2. Minimal bytes used on-wire
-// 3. Efficient context creation
-// 4. Efficient lookup of tag value for a key
-// 5. Efficient iteration over tags
-// 6. Minimal memory footprint
-//
-// Notes on tradeoffs/decisions:
-// * tag includes 1 byte length of key, as well as nil-terminating byte. These
-// are to aid in efficient parsing and the ability to directly return key
-// strings. This is more important than saving a single byte/tag on the wire.
-// * The wire encoding uses only single byte values. This eliminates the need
-// to handle endian-ness conversions. It also means there is a hard upper
-// limit of 255 for both CENSUS_MAX_TAG_KV_LEN and CENSUS_MAX_PROPAGATED_TAGS.
-// * Keep all tag information (keys/values/flags) in a single memory buffer,
-// that can be directly copied to the wire.
-
-// min and max valid chars in tag keys and values. All printable ASCII is OK.
-#define MIN_VALID_TAG_CHAR 32 // ' '
-#define MAX_VALID_TAG_CHAR 126 // '~'
-
-// Structure representing a set of tags. Essentially a count of number of tags
-// present, and pointer to a chunk of memory that contains the per-tag details.
-struct tag_set {
- int ntags; // number of tags.
- int ntags_alloc; // ntags + number of deleted tags (total number of tags
- // in all of kvm). This will always be == ntags, except during the process
- // of building a new tag set.
- size_t kvm_size; // number of bytes allocated for key/value storage.
- size_t kvm_used; // number of bytes of used key/value memory
- char *kvm; // key/value memory. Consists of repeated entries of:
- // Offset Size Description
- // 0 1 Key length, including trailing 0. (K)
- // 1 1 Value length, including trailing 0 (V)
- // 2 1 Flags
- // 3 K Key bytes
- // 3 + K V Value bytes
- //
- // We refer to the first 3 entries as the 'tag header'. If extra values are
- // introduced in the header, you will need to modify the TAG_HEADER_SIZE
- // constant, the raw_tag structure (and everything that uses it) and the
- // encode/decode functions appropriately.
-};
-
-// Number of bytes in tag header.
-#define TAG_HEADER_SIZE 3 // key length (1) + value length (1) + flags (1)
-// Offsets to tag header entries.
-#define KEY_LEN_OFFSET 0
-#define VALUE_LEN_OFFSET 1
-#define FLAG_OFFSET 2
-
-// raw_tag represents the raw-storage form of a tag in the kvm of a tag_set.
-struct raw_tag {
- uint8_t key_len;
- uint8_t value_len;
- uint8_t flags;
- char *key;
- char *value;
-};
-
-// Use a reserved flag bit for indication of deleted tag.
-#define CENSUS_TAG_DELETED CENSUS_TAG_RESERVED
-#define CENSUS_TAG_IS_DELETED(flags) (flags & CENSUS_TAG_DELETED)
-
-// Primary representation of a context. Composed of 2 underlying tag_set
-// structs, one each for propagated and local (non-propagated) tags. This is
-// to efficiently support tag encoding/decoding.
-// TODO(aveitch): need to add tracing id's/structure.
-struct census_context {
- struct tag_set tags[2];
- census_context_status status;
-};
-
-// Indices into the tags member of census_context
-#define PROPAGATED_TAGS 0
-#define LOCAL_TAGS 1
-
-// Validate (check all characters are in range and size is less than limit) a
-// key or value string. Returns 0 if the string is invalid, or the length
-// (including terminator) if valid.
-static size_t validate_tag(const char *kv) {
- size_t len = 1;
- char ch;
- while ((ch = *kv++) != 0) {
- if (ch < MIN_VALID_TAG_CHAR || ch > MAX_VALID_TAG_CHAR) {
- return 0;
- }
- len++;
- }
- if (len > CENSUS_MAX_TAG_KV_LEN) {
- return 0;
- }
- return len;
-}
-
-// Extract a raw tag given a pointer (raw) to the tag header. Allow for some
-// extra bytes in the tag header (see encode/decode functions for usage: this
-// allows for future expansion of the tag header).
-static char *decode_tag(struct raw_tag *tag, char *header, int offset) {
- tag->key_len = (uint8_t)(*header++);
- tag->value_len = (uint8_t)(*header++);
- tag->flags = (uint8_t)(*header++);
- header += offset;
- tag->key = header;
- header += tag->key_len;
- tag->value = header;
- return header + tag->value_len;
-}
-
-// Make a copy (in 'to') of an existing tag_set.
-static void tag_set_copy(struct tag_set *to, const struct tag_set *from) {
- memcpy(to, from, sizeof(struct tag_set));
- to->kvm = (char *)gpr_malloc(to->kvm_size);
- memcpy(to->kvm, from->kvm, from->kvm_used);
-}
-
-// Delete a tag from a tag_set, if it exists (returns true if it did).
-static bool tag_set_delete_tag(struct tag_set *tags, const char *key,
- size_t key_len) {
- char *kvp = tags->kvm;
- for (int i = 0; i < tags->ntags_alloc; i++) {
- uint8_t *flags = (uint8_t *)(kvp + FLAG_OFFSET);
- struct raw_tag tag;
- kvp = decode_tag(&tag, kvp, 0);
- if (CENSUS_TAG_IS_DELETED(tag.flags)) continue;
- if ((key_len == tag.key_len) && (memcmp(key, tag.key, key_len) == 0)) {
- *flags |= CENSUS_TAG_DELETED;
- tags->ntags--;
- return true;
- }
- }
- return false;
-}
-
-// Delete a tag from a context, return true if it existed.
-static bool context_delete_tag(census_context *context, const census_tag *tag,
- size_t key_len) {
- return (
- tag_set_delete_tag(&context->tags[LOCAL_TAGS], tag->key, key_len) ||
- tag_set_delete_tag(&context->tags[PROPAGATED_TAGS], tag->key, key_len));
-}
-
-// Add a tag to a tag_set. Return true on success, false if the tag could
-// not be added because of constraints on tag set size. This function should
-// not be called if the tag may already exist (in a non-deleted state) in
-// the tag_set, as that would result in two tags with the same key.
-static bool tag_set_add_tag(struct tag_set *tags, const census_tag *tag,
- size_t key_len, size_t value_len) {
- if (tags->ntags == CENSUS_MAX_PROPAGATED_TAGS) {
- return false;
- }
- const size_t tag_size = key_len + value_len + TAG_HEADER_SIZE;
- if (tags->kvm_used + tag_size > tags->kvm_size) {
- // allocate new memory if needed
- tags->kvm_size += 2 * CENSUS_MAX_TAG_KV_LEN + TAG_HEADER_SIZE;
- char *new_kvm = (char *)gpr_malloc(tags->kvm_size);
- if (tags->kvm_used > 0) memcpy(new_kvm, tags->kvm, tags->kvm_used);
- gpr_free(tags->kvm);
- tags->kvm = new_kvm;
- }
- char *kvp = tags->kvm + tags->kvm_used;
- *kvp++ = (char)key_len;
- *kvp++ = (char)value_len;
- // ensure reserved flags are not used.
- *kvp++ = (char)(tag->flags & (CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS));
- memcpy(kvp, tag->key, key_len);
- kvp += key_len;
- memcpy(kvp, tag->value, value_len);
- tags->kvm_used += tag_size;
- tags->ntags++;
- tags->ntags_alloc++;
- return true;
-}
-
-// Add/modify/delete a tag to/in a context. Caller must validate that tag key
-// etc. are valid.
-static void context_modify_tag(census_context *context, const census_tag *tag,
- size_t key_len, size_t value_len) {
- // First delete the tag if it is already present.
- bool deleted = context_delete_tag(context, tag, key_len);
- bool added = false;
- if (CENSUS_TAG_IS_PROPAGATED(tag->flags)) {
- added = tag_set_add_tag(&context->tags[PROPAGATED_TAGS], tag, key_len,
- value_len);
- } else {
- added =
- tag_set_add_tag(&context->tags[LOCAL_TAGS], tag, key_len, value_len);
- }
-
- if (deleted) {
- context->status.n_modified_tags++;
- } else {
- if (added) {
- context->status.n_added_tags++;
- } else {
- context->status.n_ignored_tags++;
- }
- }
-}
-
-// Remove memory used for deleted tags from a tag set. Basic algorithm:
-// 1) Walk through tag set to find first deleted tag. Record where it is.
-// 2) Find the next not-deleted tag. Copy all of kvm from there to the end
-// "over" the deleted tags
-// 3) repeat #1 and #2 until we have seen all tags
-// 4) if we are still looking for a not-deleted tag, then all the end portion
-// of the kvm is deleted. Just reduce the used amount of memory by the
-// appropriate amount.
-static void tag_set_flatten(struct tag_set *tags) {
- if (tags->ntags == tags->ntags_alloc) return;
- bool found_deleted = false; // found a deleted tag.
- char *kvp = tags->kvm;
- char *dbase = NULL; // record location of deleted tag
- for (int i = 0; i < tags->ntags_alloc; i++) {
- struct raw_tag tag;
- char *next_kvp = decode_tag(&tag, kvp, 0);
- if (found_deleted) {
- if (!CENSUS_TAG_IS_DELETED(tag.flags)) {
- ptrdiff_t reduce = kvp - dbase; // #bytes in deleted tags
- GPR_ASSERT(reduce > 0);
- ptrdiff_t copy_size = tags->kvm + tags->kvm_used - kvp;
- GPR_ASSERT(copy_size > 0);
- memmove(dbase, kvp, (size_t)copy_size);
- tags->kvm_used -= (size_t)reduce;
- next_kvp -= reduce;
- found_deleted = false;
- }
- } else {
- if (CENSUS_TAG_IS_DELETED(tag.flags)) {
- dbase = kvp;
- found_deleted = true;
- }
- }
- kvp = next_kvp;
- }
- if (found_deleted) {
- GPR_ASSERT(dbase > tags->kvm);
- tags->kvm_used = (size_t)(dbase - tags->kvm);
- }
- tags->ntags_alloc = tags->ntags;
-}
-
-census_context *census_context_create(const census_context *base,
- const census_tag *tags, int ntags,
- census_context_status const **status) {
- census_context *context =
- (census_context *)gpr_malloc(sizeof(census_context));
- // If we are given a base, copy it into our new tag set. Otherwise set it
- // to zero/NULL everything.
- if (base == NULL) {
- memset(context, 0, sizeof(census_context));
- } else {
- tag_set_copy(&context->tags[PROPAGATED_TAGS], &base->tags[PROPAGATED_TAGS]);
- tag_set_copy(&context->tags[LOCAL_TAGS], &base->tags[LOCAL_TAGS]);
- memset(&context->status, 0, sizeof(context->status));
- }
- // Walk over the additional tags and, for those that aren't invalid, modify
- // the context to add/replace/delete as required.
- for (int i = 0; i < ntags; i++) {
- const census_tag *tag = &tags[i];
- size_t key_len = validate_tag(tag->key);
- // ignore the tag if it is invalid or too short.
- if (key_len <= 1) {
- context->status.n_invalid_tags++;
- } else {
- if (tag->value != NULL) {
- size_t value_len = validate_tag(tag->value);
- if (value_len != 0) {
- context_modify_tag(context, tag, key_len, value_len);
- } else {
- context->status.n_invalid_tags++;
- }
- } else {
- if (context_delete_tag(context, tag, key_len)) {
- context->status.n_deleted_tags++;
- }
- }
- }
- }
- // Remove any deleted tags, update status if needed, and return.
- tag_set_flatten(&context->tags[PROPAGATED_TAGS]);
- tag_set_flatten(&context->tags[LOCAL_TAGS]);
- context->status.n_propagated_tags = context->tags[PROPAGATED_TAGS].ntags;
- context->status.n_local_tags = context->tags[LOCAL_TAGS].ntags;
- if (status) {
- *status = &context->status;
- }
- return context;
-}
-
-const census_context_status *census_context_get_status(
- const census_context *context) {
- return &context->status;
-}
-
-void census_context_destroy(census_context *context) {
- gpr_free(context->tags[PROPAGATED_TAGS].kvm);
- gpr_free(context->tags[LOCAL_TAGS].kvm);
- gpr_free(context);
-}
-
-void census_context_initialize_iterator(const census_context *context,
- census_context_iterator *iterator) {
- iterator->context = context;
- iterator->index = 0;
- if (context->tags[PROPAGATED_TAGS].ntags != 0) {
- iterator->base = PROPAGATED_TAGS;
- iterator->kvm = context->tags[PROPAGATED_TAGS].kvm;
- } else if (context->tags[LOCAL_TAGS].ntags != 0) {
- iterator->base = LOCAL_TAGS;
- iterator->kvm = context->tags[LOCAL_TAGS].kvm;
- } else {
- iterator->base = -1;
- }
-}
-
-int census_context_next_tag(census_context_iterator *iterator,
- census_tag *tag) {
- if (iterator->base < 0) {
- return 0;
- }
- struct raw_tag raw;
- iterator->kvm = decode_tag(&raw, iterator->kvm, 0);
- tag->key = raw.key;
- tag->value = raw.value;
- tag->flags = raw.flags;
- if (++iterator->index == iterator->context->tags[iterator->base].ntags) {
- do {
- if (iterator->base == LOCAL_TAGS) {
- iterator->base = -1;
- return 1;
- }
- } while (iterator->context->tags[++iterator->base].ntags == 0);
- iterator->index = 0;
- iterator->kvm = iterator->context->tags[iterator->base].kvm;
- }
- return 1;
-}
-
-// Find a tag in a tag_set by key. Return true if found, false otherwise.
-static bool tag_set_get_tag(const struct tag_set *tags, const char *key,
- size_t key_len, census_tag *tag) {
- char *kvp = tags->kvm;
- for (int i = 0; i < tags->ntags; i++) {
- struct raw_tag raw;
- kvp = decode_tag(&raw, kvp, 0);
- if (key_len == raw.key_len && memcmp(raw.key, key, key_len) == 0) {
- tag->key = raw.key;
- tag->value = raw.value;
- tag->flags = raw.flags;
- return true;
- }
- }
- return false;
-}
-
-int census_context_get_tag(const census_context *context, const char *key,
- census_tag *tag) {
- size_t key_len = strlen(key) + 1;
- if (key_len == 1) {
- return 0;
- }
- if (tag_set_get_tag(&context->tags[PROPAGATED_TAGS], key, key_len, tag) ||
- tag_set_get_tag(&context->tags[LOCAL_TAGS], key, key_len, tag)) {
- return 1;
- }
- return 0;
-}
-
-// Context encoding and decoding functions.
-//
-// Wire format for tag_set's on the wire:
-//
-// First, a tag set header:
-//
-// offset bytes description
-// 0 1 version number
-// 1 1 number of bytes in this header. This allows for future
-// expansion.
-// 2 1 number of bytes in each tag header.
-// 3 1 ntags value from tag set.
-//
-// This is followed by the key/value memory from struct tag_set.
-
-#define ENCODED_VERSION 0 // Version number
-#define ENCODED_HEADER_SIZE 4 // size of tag set header
-
-// Encode a tag set. Returns 0 if buffer is too small.
-static size_t tag_set_encode(const struct tag_set *tags, char *buffer,
- size_t buf_size) {
- if (buf_size < ENCODED_HEADER_SIZE + tags->kvm_used) {
- return 0;
- }
- buf_size -= ENCODED_HEADER_SIZE;
- *buffer++ = (char)ENCODED_VERSION;
- *buffer++ = (char)ENCODED_HEADER_SIZE;
- *buffer++ = (char)TAG_HEADER_SIZE;
- *buffer++ = (char)tags->ntags;
- if (tags->ntags == 0) {
- return ENCODED_HEADER_SIZE;
- }
- memcpy(buffer, tags->kvm, tags->kvm_used);
- return ENCODED_HEADER_SIZE + tags->kvm_used;
-}
-
-size_t census_context_encode(const census_context *context, char *buffer,
- size_t buf_size) {
- return tag_set_encode(&context->tags[PROPAGATED_TAGS], buffer, buf_size);
-}
-
-// Decode a tag set.
-static void tag_set_decode(struct tag_set *tags, const char *buffer,
- size_t size) {
- uint8_t version = (uint8_t)(*buffer++);
- uint8_t header_size = (uint8_t)(*buffer++);
- uint8_t tag_header_size = (uint8_t)(*buffer++);
- tags->ntags = tags->ntags_alloc = (int)(*buffer++);
- if (tags->ntags == 0) {
- tags->ntags_alloc = 0;
- tags->kvm_size = 0;
- tags->kvm_used = 0;
- tags->kvm = NULL;
- return;
- }
- if (header_size != ENCODED_HEADER_SIZE) {
- GPR_ASSERT(version != ENCODED_VERSION);
- GPR_ASSERT(ENCODED_HEADER_SIZE < header_size);
- buffer += (header_size - ENCODED_HEADER_SIZE);
- }
- tags->kvm_used = size - header_size;
- tags->kvm_size = tags->kvm_used + CENSUS_MAX_TAG_KV_LEN;
- tags->kvm = (char *)gpr_malloc(tags->kvm_size);
- if (tag_header_size != TAG_HEADER_SIZE) {
- // something new in the tag information. I don't understand it, so
- // don't copy it over.
- GPR_ASSERT(version != ENCODED_VERSION);
- GPR_ASSERT(tag_header_size > TAG_HEADER_SIZE);
- char *kvp = tags->kvm;
- for (int i = 0; i < tags->ntags; i++) {
- memcpy(kvp, buffer, TAG_HEADER_SIZE);
- kvp += header_size;
- struct raw_tag raw;
- buffer =
- decode_tag(&raw, (char *)buffer, tag_header_size - TAG_HEADER_SIZE);
- memcpy(kvp, raw.key, (size_t)raw.key_len + raw.value_len);
- kvp += raw.key_len + raw.value_len;
- }
- } else {
- memcpy(tags->kvm, buffer, tags->kvm_used);
- }
-}
-
-census_context *census_context_decode(const char *buffer, size_t size) {
- census_context *context =
- (census_context *)gpr_malloc(sizeof(census_context));
- memset(&context->tags[LOCAL_TAGS], 0, sizeof(struct tag_set));
- if (buffer == NULL) {
- memset(&context->tags[PROPAGATED_TAGS], 0, sizeof(struct tag_set));
- } else {
- tag_set_decode(&context->tags[PROPAGATED_TAGS], buffer, size);
- }
- memset(&context->status, 0, sizeof(context->status));
- context->status.n_propagated_tags = context->tags[PROPAGATED_TAGS].ntags;
- return context;
-}
diff --git a/src/core/ext/census/gen/README.md b/src/core/ext/census/gen/README.md
deleted file mode 100644
index d4612bc7c8..0000000000
--- a/src/core/ext/census/gen/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-Files generated for use by Census stats and trace recording subsystem.
-
-# Files
-* census.pb.{h,c} - Generated from src/core/ext/census/census.proto, using the
- script `tools/codegen/core/gen_nano_proto.sh src/proto/census/census.proto
- $PWD/src/core/ext/census/gen src/core/ext/census/gen`
-* trace_context.pb.{h,c} - Generated from
- src/core/ext/census/trace_context.proto, using the script
- `tools/codegen/core/gen_nano_proto.sh src/proto/census/trace_context.proto
- $PWD/src/core/ext/census/gen src/core/ext/census/gen`
diff --git a/src/core/ext/census/gen/census.pb.c b/src/core/ext/census/gen/census.pb.c
deleted file mode 100644
index 88efa73661..0000000000
--- a/src/core/ext/census/gen/census.pb.c
+++ /dev/null
@@ -1,161 +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.
- *
- */
-/* Automatically generated nanopb constant definitions */
-/* Generated by nanopb-0.3.5-dev */
-
-#include "src/core/ext/census/gen/census.pb.h"
-
-#if PB_PROTO_HEADER_VERSION != 30
-#error Regenerate this file with the current version of nanopb generator.
-#endif
-
-
-
-const pb_field_t google_census_Duration_fields[3] = {
- PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Duration, seconds, seconds, 0),
- PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Duration, nanos, seconds, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Timestamp_fields[3] = {
- PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Timestamp, seconds, seconds, 0),
- PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Timestamp, nanos, seconds, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Resource_fields[4] = {
- PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Resource, name, name, 0),
- PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Resource, description, name, 0),
- PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Resource, unit, description, &google_census_Resource_MeasurementUnit_fields),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Resource_MeasurementUnit_fields[4] = {
- PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Resource_MeasurementUnit, prefix, prefix, 0),
- PB_FIELD( 2, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, numerator, prefix, 0),
- PB_FIELD( 3, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, denominator, numerator, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_AggregationDescriptor_fields[4] = {
- PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_AggregationDescriptor, type, type, 0),
- PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, bucket_boundaries, type, &google_census_AggregationDescriptor_BucketBoundaries_fields),
- PB_ONEOF_FIELD(options, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, interval_boundaries, type, &google_census_AggregationDescriptor_IntervalBoundaries_fields),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2] = {
- PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_BucketBoundaries, bounds, bounds, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2] = {
- PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_IntervalBoundaries, window_size, window_size, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Distribution_fields[5] = {
- PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Distribution, count, count, 0),
- PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution, mean, count, 0),
- PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Distribution, range, mean, &google_census_Distribution_Range_fields),
- PB_FIELD( 4, INT64 , REPEATED, CALLBACK, OTHER, google_census_Distribution, bucket_count, range, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Distribution_Range_fields[3] = {
- PB_FIELD( 1, DOUBLE , OPTIONAL, STATIC , FIRST, google_census_Distribution_Range, min, min, 0),
- PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution_Range, max, min, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_IntervalStats_fields[2] = {
- PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_IntervalStats, window, window, &google_census_IntervalStats_Window_fields),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_IntervalStats_Window_fields[4] = {
- PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, google_census_IntervalStats_Window, window_size, window_size, &google_census_Duration_fields),
- PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, count, window_size, 0),
- PB_FIELD( 3, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, mean, count, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Tag_fields[3] = {
- PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, google_census_Tag, key, key, 0),
- PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, google_census_Tag, value, key, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_View_fields[6] = {
- PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0),
- PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0),
- PB_FIELD( 3, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, resource_name, description, 0),
- PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, resource_name, &google_census_AggregationDescriptor_fields),
- PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Aggregation_fields[7] = {
- PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0),
- PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0),
- PB_ONEOF_FIELD(data, 3, UINT64 , ONEOF, STATIC , OTHER, google_census_Aggregation, count, description, 0),
- PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields),
- PB_ONEOF_FIELD(data, 5, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields),
- PB_FIELD( 6, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields),
- PB_LAST_FIELD
-};
-
-const pb_field_t google_census_Metric_fields[5] = {
- PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, view_name, view_name, 0),
- PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric, aggregation, view_name, &google_census_Aggregation_fields),
- PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, start, aggregation, &google_census_Timestamp_fields),
- PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, end, start, &google_census_Timestamp_fields),
- PB_LAST_FIELD
-};
-
-
-/* Check that field information fits in pb_field_t */
-#if !defined(PB_FIELD_32BIT)
-/* If you get an error here, it means that you need to define PB_FIELD_32BIT
- * compile-time option. You can do that in pb.h or on compiler command line.
- *
- * The reason you need to do this is that some of your messages contain tag
- * numbers or field sizes that are larger than what can fit in 8 or 16 bit
- * field descriptors.
- */
-PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_Metric, aggregation) < 65536 && pb_membersize(google_census_Metric, start) < 65536 && pb_membersize(google_census_Metric, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric)
-#endif
-
-#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
-/* If you get an error here, it means that you need to define PB_FIELD_16BIT
- * compile-time option. You can do that in pb.h or on compiler command line.
- *
- * The reason you need to do this is that some of your messages contain tag
- * numbers or field sizes that are larger than what can fit in the default
- * 8 bit descriptors.
- */
-PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_Metric, aggregation) < 256 && pb_membersize(google_census_Metric, start) < 256 && pb_membersize(google_census_Metric, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric)
-#endif
-
-
-/* On some platforms (such as AVR), double is really float.
- * These are not directly supported by nanopb, but see example_avr_double.
- * To get rid of this error, remove any double fields from your .proto.
- */
-PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)
-
diff --git a/src/core/ext/census/gen/census.pb.h b/src/core/ext/census/gen/census.pb.h
deleted file mode 100644
index 5f28335664..0000000000
--- a/src/core/ext/census/gen/census.pb.h
+++ /dev/null
@@ -1,280 +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.
- *
- */
-/* Automatically generated nanopb header */
-/* Generated by nanopb-0.3.5-dev */
-
-#ifndef GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H
-#define GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H
-#include "third_party/nanopb/pb.h"
-#if PB_PROTO_HEADER_VERSION != 30
-#error Regenerate this file with the current version of nanopb generator.
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Enum definitions */
-typedef enum _google_census_Resource_BasicUnit {
- google_census_Resource_BasicUnit_UNKNOWN = 0,
- google_census_Resource_BasicUnit_BITS = 1,
- google_census_Resource_BasicUnit_BYTES = 2,
- google_census_Resource_BasicUnit_SECS = 3,
- google_census_Resource_BasicUnit_CORES = 4,
- google_census_Resource_BasicUnit_MAX_UNITS = 5
-} google_census_Resource_BasicUnit;
-
-typedef enum _google_census_AggregationDescriptor_AggregationType {
- google_census_AggregationDescriptor_AggregationType_UNKNOWN = 0,
- google_census_AggregationDescriptor_AggregationType_COUNT = 1,
- google_census_AggregationDescriptor_AggregationType_DISTRIBUTION = 2,
- google_census_AggregationDescriptor_AggregationType_INTERVAL = 3
-} google_census_AggregationDescriptor_AggregationType;
-
-/* Struct definitions */
-typedef struct _google_census_AggregationDescriptor_BucketBoundaries {
- pb_callback_t bounds;
-} google_census_AggregationDescriptor_BucketBoundaries;
-
-typedef struct _google_census_AggregationDescriptor_IntervalBoundaries {
- pb_callback_t window_size;
-} google_census_AggregationDescriptor_IntervalBoundaries;
-
-typedef struct _google_census_IntervalStats {
- pb_callback_t window;
-} google_census_IntervalStats;
-
-typedef struct _google_census_AggregationDescriptor {
- bool has_type;
- google_census_AggregationDescriptor_AggregationType type;
- pb_size_t which_options;
- union {
- google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries;
- google_census_AggregationDescriptor_IntervalBoundaries interval_boundaries;
- } options;
-} google_census_AggregationDescriptor;
-
-typedef struct _google_census_Distribution_Range {
- bool has_min;
- double min;
- bool has_max;
- double max;
-} google_census_Distribution_Range;
-
-typedef struct _google_census_Duration {
- bool has_seconds;
- int64_t seconds;
- bool has_nanos;
- int32_t nanos;
-} google_census_Duration;
-
-typedef struct _google_census_Resource_MeasurementUnit {
- bool has_prefix;
- int32_t prefix;
- pb_callback_t numerator;
- pb_callback_t denominator;
-} google_census_Resource_MeasurementUnit;
-
-typedef struct _google_census_Tag {
- bool has_key;
- char key[255];
- bool has_value;
- char value[255];
-} google_census_Tag;
-
-typedef struct _google_census_Timestamp {
- bool has_seconds;
- int64_t seconds;
- bool has_nanos;
- int32_t nanos;
-} google_census_Timestamp;
-
-typedef struct _google_census_Distribution {
- bool has_count;
- int64_t count;
- bool has_mean;
- double mean;
- bool has_range;
- google_census_Distribution_Range range;
- pb_callback_t bucket_count;
-} google_census_Distribution;
-
-typedef struct _google_census_IntervalStats_Window {
- bool has_window_size;
- google_census_Duration window_size;
- bool has_count;
- int64_t count;
- bool has_mean;
- double mean;
-} google_census_IntervalStats_Window;
-
-typedef struct _google_census_Metric {
- pb_callback_t view_name;
- pb_callback_t aggregation;
- bool has_start;
- google_census_Timestamp start;
- bool has_end;
- google_census_Timestamp end;
-} google_census_Metric;
-
-typedef struct _google_census_Resource {
- pb_callback_t name;
- pb_callback_t description;
- bool has_unit;
- google_census_Resource_MeasurementUnit unit;
-} google_census_Resource;
-
-typedef struct _google_census_View {
- pb_callback_t name;
- pb_callback_t description;
- pb_callback_t resource_name;
- bool has_aggregation;
- google_census_AggregationDescriptor aggregation;
- pb_callback_t tag_key;
-} google_census_View;
-
-typedef struct _google_census_Aggregation {
- pb_callback_t name;
- pb_callback_t description;
- pb_size_t which_data;
- union {
- uint64_t count;
- google_census_Distribution distribution;
- google_census_IntervalStats interval_stats;
- } data;
- pb_callback_t tag;
-} google_census_Aggregation;
-
-/* Default values for struct fields */
-
-/* Initializer values for message structs */
-#define google_census_Duration_init_default {false, 0, false, 0}
-#define google_census_Timestamp_init_default {false, 0, false, 0}
-#define google_census_Resource_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_default}
-#define google_census_Resource_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
-#define google_census_AggregationDescriptor_init_default {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}}
-#define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}}
-#define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}}
-#define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}}
-#define google_census_Distribution_Range_init_default {false, 0, false, 0}
-#define google_census_IntervalStats_init_default {{{NULL}, NULL}}
-#define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0}
-#define google_census_Tag_init_default {false, "", false, ""}
-#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}}
-#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}}
-#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default}
-#define google_census_Duration_init_zero {false, 0, false, 0}
-#define google_census_Timestamp_init_zero {false, 0, false, 0}
-#define google_census_Resource_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_zero}
-#define google_census_Resource_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
-#define google_census_AggregationDescriptor_init_zero {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}}
-#define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}}
-#define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}}
-#define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}}
-#define google_census_Distribution_Range_init_zero {false, 0, false, 0}
-#define google_census_IntervalStats_init_zero {{{NULL}, NULL}}
-#define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0}
-#define google_census_Tag_init_zero {false, "", false, ""}
-#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}}
-#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}}
-#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero}
-
-/* Field tags (for use in manual encoding/decoding) */
-#define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1
-#define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1
-#define google_census_IntervalStats_window_tag 1
-#define google_census_AggregationDescriptor_bucket_boundaries_tag 2
-
-#define google_census_AggregationDescriptor_interval_boundaries_tag 3
-#define google_census_AggregationDescriptor_type_tag 1
-#define google_census_Distribution_Range_min_tag 1
-#define google_census_Distribution_Range_max_tag 2
-#define google_census_Duration_seconds_tag 1
-#define google_census_Duration_nanos_tag 2
-#define google_census_Resource_MeasurementUnit_prefix_tag 1
-#define google_census_Resource_MeasurementUnit_numerator_tag 2
-#define google_census_Resource_MeasurementUnit_denominator_tag 3
-#define google_census_Tag_key_tag 1
-#define google_census_Tag_value_tag 2
-#define google_census_Timestamp_seconds_tag 1
-#define google_census_Timestamp_nanos_tag 2
-#define google_census_Distribution_count_tag 1
-#define google_census_Distribution_mean_tag 2
-#define google_census_Distribution_range_tag 3
-#define google_census_Distribution_bucket_count_tag 4
-#define google_census_IntervalStats_Window_window_size_tag 1
-#define google_census_IntervalStats_Window_count_tag 2
-#define google_census_IntervalStats_Window_mean_tag 3
-#define google_census_Metric_view_name_tag 1
-#define google_census_Metric_aggregation_tag 2
-#define google_census_Metric_start_tag 3
-#define google_census_Metric_end_tag 4
-#define google_census_Resource_name_tag 1
-#define google_census_Resource_description_tag 2
-#define google_census_Resource_unit_tag 3
-#define google_census_View_name_tag 1
-#define google_census_View_description_tag 2
-#define google_census_View_resource_name_tag 3
-#define google_census_View_aggregation_tag 4
-#define google_census_View_tag_key_tag 5
-#define google_census_Aggregation_count_tag 3
-
-#define google_census_Aggregation_distribution_tag 4
-
-#define google_census_Aggregation_interval_stats_tag 5
-#define google_census_Aggregation_name_tag 1
-#define google_census_Aggregation_description_tag 2
-#define google_census_Aggregation_tag_tag 6
-
-/* Struct field encoding specification for nanopb */
-extern const pb_field_t google_census_Duration_fields[3];
-extern const pb_field_t google_census_Timestamp_fields[3];
-extern const pb_field_t google_census_Resource_fields[4];
-extern const pb_field_t google_census_Resource_MeasurementUnit_fields[4];
-extern const pb_field_t google_census_AggregationDescriptor_fields[4];
-extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2];
-extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2];
-extern const pb_field_t google_census_Distribution_fields[5];
-extern const pb_field_t google_census_Distribution_Range_fields[3];
-extern const pb_field_t google_census_IntervalStats_fields[2];
-extern const pb_field_t google_census_IntervalStats_Window_fields[4];
-extern const pb_field_t google_census_Tag_fields[3];
-extern const pb_field_t google_census_View_fields[6];
-extern const pb_field_t google_census_Aggregation_fields[7];
-extern const pb_field_t google_census_Metric_fields[5];
-
-/* Maximum encoded size of messages (where known) */
-#define google_census_Duration_size 22
-#define google_census_Timestamp_size 22
-#define google_census_Distribution_Range_size 18
-#define google_census_IntervalStats_Window_size 44
-#define google_census_Tag_size 516
-
-/* Message IDs (where set with "msgid" option) */
-#ifdef PB_MSGID
-
-#define CENSUS_MESSAGES \
-
-
-#endif
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H */
diff --git a/src/core/ext/census/gen/trace_context.pb.c b/src/core/ext/census/gen/trace_context.pb.c
deleted file mode 100644
index b5c3d52a71..0000000000
--- a/src/core/ext/census/gen/trace_context.pb.c
+++ /dev/null
@@ -1,39 +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.
- *
- */
-/* Automatically generated nanopb constant definitions */
-/* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */
-
-#include "src/core/ext/census/gen/trace_context.pb.h"
-
-/* @@protoc_insertion_point(includes) */
-#if PB_PROTO_HEADER_VERSION != 30
-#error Regenerate this file with the current version of nanopb generator.
-#endif
-
-
-
-const pb_field_t google_trace_TraceContext_fields[5] = {
- PB_FIELD( 1, FIXED64 , OPTIONAL, STATIC , FIRST, google_trace_TraceContext, trace_id_hi, trace_id_hi, 0),
- PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, trace_id_lo, trace_id_hi, 0),
- PB_FIELD( 3, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_id, trace_id_lo, 0),
- PB_FIELD( 4, FIXED32 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_options, span_id, 0),
- PB_LAST_FIELD
-};
-
-
-/* @@protoc_insertion_point(eof) */
diff --git a/src/core/ext/census/gen/trace_context.pb.h b/src/core/ext/census/gen/trace_context.pb.h
deleted file mode 100644
index 181925dc9a..0000000000
--- a/src/core/ext/census/gen/trace_context.pb.h
+++ /dev/null
@@ -1,78 +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.
- *
- */
-/* Automatically generated nanopb header */
-/* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */
-
-#ifndef GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H
-#define GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H
-#include "third_party/nanopb/pb.h"
-
-/* @@protoc_insertion_point(includes) */
-#if PB_PROTO_HEADER_VERSION != 30
-#error Regenerate this file with the current version of nanopb generator.
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Struct definitions */
-typedef struct _google_trace_TraceContext {
- bool has_trace_id_hi;
- uint64_t trace_id_hi;
- bool has_trace_id_lo;
- uint64_t trace_id_lo;
- bool has_span_id;
- uint64_t span_id;
- bool has_span_options;
- uint32_t span_options;
-/* @@protoc_insertion_point(struct:google_trace_TraceContext) */
-} google_trace_TraceContext;
-
-/* Default values for struct fields */
-
-/* Initializer values for message structs */
-#define google_trace_TraceContext_init_default {false, 0, false, 0, false, 0, false, 0}
-#define google_trace_TraceContext_init_zero {false, 0, false, 0, false, 0, false, 0}
-
-/* Field tags (for use in manual encoding/decoding) */
-#define google_trace_TraceContext_trace_id_hi_tag 1
-#define google_trace_TraceContext_trace_id_lo_tag 2
-#define google_trace_TraceContext_span_id_tag 3
-#define google_trace_TraceContext_span_options_tag 4
-
-/* Struct field encoding specification for nanopb */
-extern const pb_field_t google_trace_TraceContext_fields[5];
-
-/* Maximum encoded size of messages (where known) */
-#define google_trace_TraceContext_size 32
-
-/* Message IDs (where set with "msgid" option) */
-#ifdef PB_MSGID
-
-#define TRACE_CONTEXT_MESSAGES \
-
-
-#endif
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-/* @@protoc_insertion_point(eof) */
-
-#endif /* GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H */
diff --git a/src/core/ext/census/grpc_context.c b/src/core/ext/census/grpc_context.cc
index 0bfba63a5e..ffe7c51ff8 100644
--- a/src/core/ext/census/grpc_context.c
+++ b/src/core/ext/census/grpc_context.cc
@@ -21,18 +21,15 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
-void grpc_census_call_set_context(grpc_call *call, census_context *context) {
+void grpc_census_call_set_context(grpc_call* call, census_context* context) {
GRPC_API_TRACE("grpc_census_call_set_context(call=%p, census_context=%p)", 2,
(call, context));
- if (census_enabled() == CENSUS_FEATURE_NONE) {
- return;
- }
- if (context != NULL) {
- grpc_call_context_set(call, GRPC_CONTEXT_TRACING, context, NULL);
+ if (context != nullptr) {
+ grpc_call_context_set(call, GRPC_CONTEXT_TRACING, context, nullptr);
}
}
-census_context *grpc_census_call_get_context(grpc_call *call) {
+census_context* grpc_census_call_get_context(grpc_call* call) {
GRPC_API_TRACE("grpc_census_call_get_context(call=%p)", 1, (call));
- return (census_context *)grpc_call_context_get(call, GRPC_CONTEXT_TRACING);
+ return (census_context*)grpc_call_context_get(call, GRPC_CONTEXT_TRACING);
}
diff --git a/src/core/ext/census/grpc_filter.c b/src/core/ext/census/grpc_filter.c
deleted file mode 100644
index b37ab90389..0000000000
--- a/src/core/ext/census/grpc_filter.c
+++ /dev/null
@@ -1,196 +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/census/grpc_filter.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <grpc/census.h>
-#include <grpc/slice.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/time.h>
-
-#include "src/core/ext/census/census_interface.h"
-#include "src/core/ext/census/census_rpc_stats.h"
-#include "src/core/lib/channel/channel_stack.h"
-#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/transport/static_metadata.h"
-
-typedef struct call_data {
- census_op_id op_id;
- census_context *ctxt;
- gpr_timespec start_ts;
- int error;
-
- /* recv callback */
- grpc_metadata_batch *recv_initial_metadata;
- grpc_closure *on_done_recv;
- grpc_closure finish_recv;
-} call_data;
-
-typedef struct channel_data { uint8_t unused; } channel_data;
-
-static void extract_and_annotate_method_tag(grpc_metadata_batch *md,
- call_data *calld,
- channel_data *chand) {
- grpc_linked_mdelem *m;
- for (m = md->list.head; m != NULL; m = m->next) {
- if (grpc_slice_eq(GRPC_MDKEY(m->md), GRPC_MDSTR_PATH)) {
- /* Add method tag here */
- }
- }
-}
-
-static void client_mutate_op(grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
- if (op->send_initial_metadata) {
- extract_and_annotate_method_tag(
- op->payload->send_initial_metadata.send_initial_metadata, calld, chand);
- }
-}
-
-static void client_start_transport_op(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- client_mutate_op(elem, op);
- grpc_call_next_op(exec_ctx, elem, op);
-}
-
-static void server_on_done_recv(grpc_exec_ctx *exec_ctx, void *ptr,
- grpc_error *error) {
- GPR_TIMER_BEGIN("census-server:server_on_done_recv", 0);
- grpc_call_element *elem = (grpc_call_element *)ptr;
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
- if (error == GRPC_ERROR_NONE) {
- extract_and_annotate_method_tag(calld->recv_initial_metadata, calld, chand);
- }
- calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg, error);
- GPR_TIMER_END("census-server:server_on_done_recv", 0);
-}
-
-static void server_mutate_op(grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- call_data *calld = (call_data *)elem->call_data;
- if (op->recv_initial_metadata) {
- /* substitute our callback for the op callback */
- calld->recv_initial_metadata =
- op->payload->recv_initial_metadata.recv_initial_metadata;
- calld->on_done_recv =
- op->payload->recv_initial_metadata.recv_initial_metadata_ready;
- op->payload->recv_initial_metadata.recv_initial_metadata_ready =
- &calld->finish_recv;
- }
-}
-
-static void server_start_transport_op(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- /* TODO(ctiller): this code fails. I don't know why. I expect it's
- incomplete, and someone should look at it soon.
-
- call_data *calld = elem->call_data;
- GPR_ASSERT((calld->op_id.upper != 0) || (calld->op_id.lower != 0)); */
- server_mutate_op(elem, op);
- grpc_call_next_op(exec_ctx, elem, op);
-}
-
-static grpc_error *client_init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *d = (call_data *)elem->call_data;
- GPR_ASSERT(d != NULL);
- memset(d, 0, sizeof(*d));
- d->start_ts = args->start_time;
- return GRPC_ERROR_NONE;
-}
-
-static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *d = (call_data *)elem->call_data;
- GPR_ASSERT(d != NULL);
- /* TODO(hongyu): record rpc client stats and census_rpc_end_op here */
-}
-
-static grpc_error *server_init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *d = (call_data *)elem->call_data;
- GPR_ASSERT(d != NULL);
- memset(d, 0, sizeof(*d));
- d->start_ts = args->start_time;
- /* TODO(hongyu): call census_tracing_start_op here. */
- GRPC_CLOSURE_INIT(&d->finish_recv, server_on_done_recv, elem,
- grpc_schedule_on_exec_ctx);
- return GRPC_ERROR_NONE;
-}
-
-static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *d = (call_data *)elem->call_data;
- GPR_ASSERT(d != NULL);
- /* TODO(hongyu): record rpc server stats and census_tracing_end_op here */
-}
-
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- channel_data *chand = (channel_data *)elem->channel_data;
- GPR_ASSERT(chand != NULL);
- return GRPC_ERROR_NONE;
-}
-
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- GPR_ASSERT(chand != NULL);
-}
-
-const grpc_channel_filter grpc_client_census_filter = {
- client_start_transport_op,
- grpc_channel_next_op,
- sizeof(call_data),
- client_init_call_elem,
- grpc_call_stack_ignore_set_pollset_or_pollset_set,
- client_destroy_call_elem,
- sizeof(channel_data),
- init_channel_elem,
- destroy_channel_elem,
- grpc_channel_next_get_info,
- "census-client"};
-
-const grpc_channel_filter grpc_server_census_filter = {
- server_start_transport_op,
- grpc_channel_next_op,
- sizeof(call_data),
- server_init_call_elem,
- grpc_call_stack_ignore_set_pollset_or_pollset_set,
- server_destroy_call_elem,
- sizeof(channel_data),
- init_channel_elem,
- destroy_channel_elem,
- grpc_channel_next_get_info,
- "census-server"};
diff --git a/src/core/ext/census/grpc_plugin.c b/src/core/ext/census/grpc_plugin.c
deleted file mode 100644
index c0efe5afb8..0000000000
--- a/src/core/ext/census/grpc_plugin.c
+++ /dev/null
@@ -1,70 +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 <grpc/support/port_platform.h>
-
-#include <limits.h>
-#include <string.h>
-
-#include <grpc/census.h>
-
-#include "src/core/ext/census/grpc_filter.h"
-#include "src/core/lib/channel/channel_stack_builder.h"
-#include "src/core/lib/surface/channel_init.h"
-
-static bool is_census_enabled(const grpc_channel_args *a) {
- size_t i;
- if (a == NULL) return 0;
- for (i = 0; i < a->num_args; i++) {
- if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) {
- return a->args[i].value.integer != 0 && census_enabled();
- }
- }
- return census_enabled() && !grpc_channel_args_want_minimal_stack(a);
-}
-
-static bool maybe_add_census_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
- const grpc_channel_args *args =
- grpc_channel_stack_builder_get_channel_arguments(builder);
- if (is_census_enabled(args)) {
- return grpc_channel_stack_builder_prepend_filter(
- builder, (const grpc_channel_filter *)arg, NULL, NULL);
- }
- return true;
-}
-
-void census_grpc_plugin_init(void) {
- /* Only initialize census if no one else has and some features are
- * available. */
- if (census_enabled() == CENSUS_FEATURE_NONE &&
- census_supported() != CENSUS_FEATURE_NONE) {
- if (census_initialize(census_supported())) { /* enable all features. */
- gpr_log(GPR_ERROR, "Could not initialize census.");
- }
- }
- grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
- maybe_add_census_filter,
- (void *)&grpc_client_census_filter);
- grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
- maybe_add_census_filter,
- (void *)&grpc_server_census_filter);
-}
-
-void census_grpc_plugin_shutdown(void) { census_shutdown(); }
diff --git a/src/core/ext/census/hash_table.c b/src/core/ext/census/hash_table.c
deleted file mode 100644
index 545b0857c7..0000000000
--- a/src/core/ext/census/hash_table.c
+++ /dev/null
@@ -1,288 +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/census/hash_table.h"
-
-#include <stddef.h>
-#include <stdio.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-
-#define CENSUS_HT_NUM_BUCKETS 1999
-
-/* A single hash table data entry */
-typedef struct ht_entry {
- census_ht_key key;
- void *data;
- struct ht_entry *next;
-} ht_entry;
-
-/* hash table bucket */
-typedef struct bucket {
- /* NULL if bucket is empty */
- ht_entry *next;
- /* -1 if all buckets are empty. */
- int32_t prev_non_empty_bucket;
- /* -1 if all buckets are empty. */
- int32_t next_non_empty_bucket;
-} bucket;
-
-struct unresizable_hash_table {
- /* Number of entries in the table */
- size_t size;
- /* Number of buckets */
- uint32_t num_buckets;
- /* Array of buckets initialized at creation time. Memory consumption is
- 16 bytes per bucket on a 64-bit platform. */
- bucket *buckets;
- /* Index of the first non-empty bucket. -1 iff size == 0. */
- int32_t first_non_empty_bucket;
- /* Index of the last non_empty bucket. -1 iff size == 0. */
- int32_t last_non_empty_bucket;
- /* Immutable options of this hash table, initialized at creation time. */
- census_ht_option options;
-};
-
-typedef struct entry_locator {
- int32_t bucket_idx;
- int is_first_in_chain;
- int found;
- ht_entry *prev_entry;
-} entry_locator;
-
-/* Asserts if option is not valid. */
-void check_options(const census_ht_option *option) {
- GPR_ASSERT(option != NULL);
- GPR_ASSERT(option->num_buckets > 0);
- GPR_ASSERT(option->key_type == CENSUS_HT_UINT64 ||
- option->key_type == CENSUS_HT_POINTER);
- if (option->key_type == CENSUS_HT_UINT64) {
- GPR_ASSERT(option->hash == NULL);
- } else if (option->key_type == CENSUS_HT_POINTER) {
- GPR_ASSERT(option->hash != NULL);
- GPR_ASSERT(option->compare_keys != NULL);
- }
-}
-
-#define REMOVE_NEXT(options, ptr) \
- do { \
- ht_entry *tmp = (ptr)->next; \
- (ptr)->next = tmp->next; \
- delete_entry(options, tmp); \
- } while (0)
-
-static void delete_entry(const census_ht_option *opt, ht_entry *p) {
- if (opt->delete_data != NULL) {
- opt->delete_data(p->data);
- }
- if (opt->delete_key != NULL) {
- opt->delete_key(p->key.ptr);
- }
- gpr_free(p);
-}
-
-static uint64_t hash(const census_ht_option *opt, census_ht_key key) {
- return opt->key_type == CENSUS_HT_UINT64 ? key.val : opt->hash(key.ptr);
-}
-
-census_ht *census_ht_create(const census_ht_option *option) {
- int i;
- census_ht *ret = NULL;
- check_options(option);
- ret = (census_ht *)gpr_malloc(sizeof(census_ht));
- ret->size = 0;
- ret->num_buckets = option->num_buckets;
- ret->buckets = (bucket *)gpr_malloc(sizeof(bucket) * ret->num_buckets);
- ret->options = *option;
- /* initialize each bucket */
- for (i = 0; i < ret->options.num_buckets; i++) {
- ret->buckets[i].prev_non_empty_bucket = -1;
- ret->buckets[i].next_non_empty_bucket = -1;
- ret->buckets[i].next = NULL;
- }
- return ret;
-}
-
-static int32_t find_bucket_idx(const census_ht *ht, census_ht_key key) {
- return hash(&ht->options, key) % ht->num_buckets;
-}
-
-static int keys_match(const census_ht_option *opt, const ht_entry *p,
- const census_ht_key key) {
- GPR_ASSERT(opt->key_type == CENSUS_HT_UINT64 ||
- opt->key_type == CENSUS_HT_POINTER);
- if (opt->key_type == CENSUS_HT_UINT64) return p->key.val == key.val;
- return !opt->compare_keys((p->key).ptr, key.ptr);
-}
-
-static entry_locator ht_find(const census_ht *ht, census_ht_key key) {
- entry_locator loc = {0, 0, 0, NULL};
- int32_t idx = 0;
- ht_entry *ptr = NULL;
- GPR_ASSERT(ht != NULL);
- idx = find_bucket_idx(ht, key);
- ptr = ht->buckets[idx].next;
- if (ptr == NULL) {
- /* bucket is empty */
- return loc;
- }
- if (keys_match(&ht->options, ptr, key)) {
- loc.bucket_idx = idx;
- loc.is_first_in_chain = 1;
- loc.found = 1;
- return loc;
- } else {
- for (; ptr->next != NULL; ptr = ptr->next) {
- if (keys_match(&ht->options, ptr->next, key)) {
- loc.bucket_idx = idx;
- loc.is_first_in_chain = 0;
- loc.found = 1;
- loc.prev_entry = ptr;
- return loc;
- }
- }
- }
- /* Could not find the key */
- return loc;
-}
-
-void *census_ht_find(const census_ht *ht, census_ht_key key) {
- entry_locator loc = ht_find(ht, key);
- if (loc.found == 0) {
- return NULL;
- }
- return loc.is_first_in_chain ? ht->buckets[loc.bucket_idx].next->data
- : loc.prev_entry->next->data;
-}
-
-void census_ht_insert(census_ht *ht, census_ht_key key, void *data) {
- int32_t idx = find_bucket_idx(ht, key);
- ht_entry *ptr = NULL;
- entry_locator loc = ht_find(ht, key);
- if (loc.found) {
- /* Replace old value with new value. */
- ptr = loc.is_first_in_chain ? ht->buckets[loc.bucket_idx].next
- : loc.prev_entry->next;
- if (ht->options.delete_data != NULL) {
- ht->options.delete_data(ptr->data);
- }
- ptr->data = data;
- return;
- }
-
- /* first entry in the table. */
- if (ht->size == 0) {
- ht->buckets[idx].next_non_empty_bucket = -1;
- ht->buckets[idx].prev_non_empty_bucket = -1;
- ht->first_non_empty_bucket = idx;
- ht->last_non_empty_bucket = idx;
- } else if (ht->buckets[idx].next == NULL) {
- /* first entry in the bucket. */
- ht->buckets[ht->last_non_empty_bucket].next_non_empty_bucket = idx;
- ht->buckets[idx].prev_non_empty_bucket = ht->last_non_empty_bucket;
- ht->buckets[idx].next_non_empty_bucket = -1;
- ht->last_non_empty_bucket = idx;
- }
- ptr = (ht_entry *)gpr_malloc(sizeof(ht_entry));
- ptr->key = key;
- ptr->data = data;
- ptr->next = ht->buckets[idx].next;
- ht->buckets[idx].next = ptr;
- ht->size++;
-}
-
-void census_ht_erase(census_ht *ht, census_ht_key key) {
- entry_locator loc = ht_find(ht, key);
- if (loc.found == 0) {
- /* noop if not found */
- return;
- }
- ht->size--;
- if (loc.is_first_in_chain) {
- bucket *b = &ht->buckets[loc.bucket_idx];
- GPR_ASSERT(b->next != NULL);
- /* The only entry in the bucket */
- if (b->next->next == NULL) {
- int prev = b->prev_non_empty_bucket;
- int next = b->next_non_empty_bucket;
- if (prev != -1) {
- ht->buckets[prev].next_non_empty_bucket = next;
- } else {
- ht->first_non_empty_bucket = next;
- }
- if (next != -1) {
- ht->buckets[next].prev_non_empty_bucket = prev;
- } else {
- ht->last_non_empty_bucket = prev;
- }
- }
- REMOVE_NEXT(&ht->options, b);
- } else {
- GPR_ASSERT(loc.prev_entry->next != NULL);
- REMOVE_NEXT(&ht->options, loc.prev_entry);
- }
-}
-
-/* Returns NULL if input table is empty. */
-census_ht_kv *census_ht_get_all_elements(const census_ht *ht, size_t *num) {
- census_ht_kv *ret = NULL;
- int i = 0;
- int32_t idx = -1;
- GPR_ASSERT(ht != NULL && num != NULL);
- *num = ht->size;
- if (*num == 0) {
- return NULL;
- }
-
- ret = (census_ht_kv *)gpr_malloc(sizeof(census_ht_kv) * ht->size);
- idx = ht->first_non_empty_bucket;
- while (idx >= 0) {
- ht_entry *ptr = ht->buckets[idx].next;
- for (; ptr != NULL; ptr = ptr->next) {
- ret[i].k = ptr->key;
- ret[i].v = ptr->data;
- i++;
- }
- idx = ht->buckets[idx].next_non_empty_bucket;
- }
- return ret;
-}
-
-static void ht_delete_entry_chain(const census_ht_option *options,
- ht_entry *first) {
- if (first == NULL) {
- return;
- }
- if (first->next != NULL) {
- ht_delete_entry_chain(options, first->next);
- }
- delete_entry(options, first);
-}
-
-void census_ht_destroy(census_ht *ht) {
- unsigned i;
- for (i = 0; i < ht->num_buckets; ++i) {
- ht_delete_entry_chain(&ht->options, ht->buckets[i].next);
- }
- gpr_free(ht->buckets);
- gpr_free(ht);
-}
-
-size_t census_ht_get_size(const census_ht *ht) { return ht->size; }
diff --git a/src/core/ext/census/hash_table.h b/src/core/ext/census/hash_table.h
deleted file mode 100644
index 75770641c5..0000000000
--- a/src/core/ext/census/hash_table.h
+++ /dev/null
@@ -1,116 +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_EXT_CENSUS_HASH_TABLE_H
-#define GRPC_CORE_EXT_CENSUS_HASH_TABLE_H
-
-#include <stddef.h>
-
-#include <grpc/support/port_platform.h>
-
-/* A chain based hash table with fixed number of buckets.
- Your probably shouldn't use this code directly. It is implemented for the
- use case in census trace store and stats store, where number of entries in
- the table is in the scale of upto several thousands, entries are added and
- removed from the table very frequently (~100k/s), the frequency of find()
- operations is roughly several times of the frequency of insert() and erase()
- Comparing to find(), the insert(), erase() and get_all_entries() operations
- are much less freqent (<1/s).
-
- Per bucket memory overhead is about (8 + sizeof(intptr_t) bytes.
- Per entry memory overhead is about (8 + 2 * sizeof(intptr_t) bytes.
-
- All functions are not thread-safe. Synchronization will be provided in the
- upper layer (in trace store and stats store).
-*/
-
-/* Opaque hash table struct */
-typedef struct unresizable_hash_table census_ht;
-
-/* Currently, the hash_table can take two types of keys. (uint64 for trace
- store and const char* for stats store). */
-typedef union {
- uint64_t val;
- void *ptr;
-} census_ht_key;
-
-typedef enum census_ht_key_type {
- CENSUS_HT_UINT64 = 0,
- CENSUS_HT_POINTER = 1
-} census_ht_key_type;
-
-typedef struct census_ht_option {
- /* Type of hash key */
- census_ht_key_type key_type;
- /* Desired number of buckets, preferably a prime number */
- int32_t num_buckets;
- /* Fucntion to calculate uint64 hash value of the key. Only takes effect if
- key_type is POINTER. */
- uint64_t (*hash)(const void *);
- /* Function to compare two keys, returns 0 iff equal. Only takes effect if
- key_type is POINTER */
- int (*compare_keys)(const void *k1, const void *k2);
- /* Value deleter. NULL if no specialized delete function is needed. */
- void (*delete_data)(void *);
- /* Key deleter. NULL if table does not own the key. (e.g. key is part of the
- value or key is not owned by the table.) */
- void (*delete_key)(void *);
-} census_ht_option;
-
-/* Creates a hashtable with fixed number of buckets according to the settings
- specified in 'options' arg. Function pointers "hash" and "compare_keys" must
- be provided if key_type is POINTER. Asserts if fail to create. */
-census_ht *census_ht_create(const census_ht_option *options);
-
-/* Deletes hash table instance. Frees all dynamic memory owned by ht.*/
-void census_ht_destroy(census_ht *ht);
-
-/* Inserts the input key-val pair into hash_table. If an entry with the same key
- exists in the table, the corresponding value will be overwritten by the input
- val. */
-void census_ht_insert(census_ht *ht, census_ht_key key, void *val);
-
-/* Returns pointer to data, returns NULL if not found. */
-void *census_ht_find(const census_ht *ht, census_ht_key key);
-
-/* Erase hash table entry with input key. Noop if key is not found. */
-void census_ht_erase(census_ht *ht, census_ht_key key);
-
-typedef struct census_ht_kv {
- census_ht_key k;
- void *v;
-} census_ht_kv;
-
-/* Returns an array of pointers to all values in the hash table. Order of the
- elements can be arbitrary. Sets 'num' to the size of returned array. Caller
- owns returned array. */
-census_ht_kv *census_ht_get_all_elements(const census_ht *ht, size_t *num);
-
-/* Returns number of elements kept. */
-size_t census_ht_get_size(const census_ht *ht);
-
-/* Functor applied on each key-value pair while iterating through entries in the
- table. The functor should not mutate data. */
-typedef void (*census_ht_itr_cb)(census_ht_key key, const void *val_ptr,
- void *state);
-
-/* Iterates through all key-value pairs in the hash_table. The callback function
- should not invalidate data entries. */
-uint64_t census_ht_for_all(const census_ht *ht, census_ht_itr_cb);
-
-#endif /* GRPC_CORE_EXT_CENSUS_HASH_TABLE_H */
diff --git a/src/core/ext/census/initialize.c b/src/core/ext/census/initialize.c
deleted file mode 100644
index 165a1221d4..0000000000
--- a/src/core/ext/census/initialize.c
+++ /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.
- *
- */
-
-#include <grpc/census.h>
-#include "src/core/ext/census/base_resources.h"
-#include "src/core/ext/census/resource.h"
-
-static int features_enabled = CENSUS_FEATURE_NONE;
-
-int census_initialize(int features) {
- if (features_enabled != CENSUS_FEATURE_NONE) {
- // Must have been a previous call to census_initialize; return error
- return -1;
- }
- features_enabled = features & CENSUS_FEATURE_ALL;
- if (features & CENSUS_FEATURE_STATS) {
- initialize_resources();
- define_base_resources();
- }
-
- return features_enabled;
-}
-
-void census_shutdown(void) {
- if (features_enabled & CENSUS_FEATURE_STATS) {
- shutdown_resources();
- }
- features_enabled = CENSUS_FEATURE_NONE;
-}
-
-int census_supported(void) {
- /* TODO(aveitch): improve this as we implement features... */
- return CENSUS_FEATURE_NONE;
-}
-
-int census_enabled(void) { return features_enabled; }
diff --git a/src/core/ext/census/intrusive_hash_map.c b/src/core/ext/census/intrusive_hash_map.c
deleted file mode 100644
index 7930486963..0000000000
--- a/src/core/ext/census/intrusive_hash_map.c
+++ /dev/null
@@ -1,305 +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 "src/core/ext/census/intrusive_hash_map.h"
-#include <string.h>
-
-extern bool hm_index_compare(const hm_index *A, const hm_index *B);
-
-/* Simple hashing function that takes lower 32 bits. */
-static __inline uint32_t chunked_vector_hasher(uint64_t key) {
- return (uint32_t)key;
-}
-
-/* Vector chunks are 1MiB divided by pointer size. */
-static const size_t VECTOR_CHUNK_SIZE = (1 << 20) / sizeof(void *);
-
-/* Helper functions which return buckets from the chunked vector. */
-static __inline void **get_mutable_bucket(const chunked_vector *buckets,
- uint32_t index) {
- if (index < VECTOR_CHUNK_SIZE) {
- return &buckets->first_[index];
- }
- size_t rest_index = (index - VECTOR_CHUNK_SIZE) / VECTOR_CHUNK_SIZE;
- return &buckets->rest_[rest_index][index % VECTOR_CHUNK_SIZE];
-}
-
-static __inline void *get_bucket(const chunked_vector *buckets,
- uint32_t index) {
- if (index < VECTOR_CHUNK_SIZE) {
- return buckets->first_[index];
- }
- size_t rest_index = (index - VECTOR_CHUNK_SIZE) / VECTOR_CHUNK_SIZE;
- return buckets->rest_[rest_index][index % VECTOR_CHUNK_SIZE];
-}
-
-/* Helper function. */
-static __inline size_t RestSize(const chunked_vector *vec) {
- return (vec->size_ <= VECTOR_CHUNK_SIZE)
- ? 0
- : (vec->size_ - VECTOR_CHUNK_SIZE - 1) / VECTOR_CHUNK_SIZE + 1;
-}
-
-/* Initialize chunked vector to size of 0. */
-static void chunked_vector_init(chunked_vector *vec) {
- vec->size_ = 0;
- vec->first_ = NULL;
- vec->rest_ = NULL;
-}
-
-/* Clear chunked vector and free all memory that has been allocated then
- initialize chunked vector. */
-static void chunked_vector_clear(chunked_vector *vec) {
- if (vec->first_ != NULL) {
- gpr_free(vec->first_);
- }
- if (vec->rest_ != NULL) {
- size_t rest_size = RestSize(vec);
- for (size_t i = 0; i < rest_size; ++i) {
- if (vec->rest_[i] != NULL) {
- gpr_free(vec->rest_[i]);
- }
- }
- gpr_free(vec->rest_);
- }
- chunked_vector_init(vec);
-}
-
-/* Clear chunked vector and then resize it to n entries. Allow the first 1MB to
- be read w/o an extra cache miss. The rest of the elements are stored in an
- array of arrays to avoid large mallocs. */
-static void chunked_vector_reset(chunked_vector *vec, size_t n) {
- chunked_vector_clear(vec);
- vec->size_ = n;
- if (n <= VECTOR_CHUNK_SIZE) {
- vec->first_ = (void **)gpr_malloc(sizeof(void *) * n);
- memset(vec->first_, 0, sizeof(void *) * n);
- } else {
- vec->first_ = (void **)gpr_malloc(sizeof(void *) * VECTOR_CHUNK_SIZE);
- memset(vec->first_, 0, sizeof(void *) * VECTOR_CHUNK_SIZE);
- size_t rest_size = RestSize(vec);
- vec->rest_ = (void ***)gpr_malloc(sizeof(void **) * rest_size);
- memset(vec->rest_, 0, sizeof(void **) * rest_size);
- int i = 0;
- n -= VECTOR_CHUNK_SIZE;
- while (n > 0) {
- size_t this_size = GPR_MIN(n, VECTOR_CHUNK_SIZE);
- vec->rest_[i] = (void **)gpr_malloc(sizeof(void *) * this_size);
- memset(vec->rest_[i], 0, sizeof(void *) * this_size);
- n -= this_size;
- ++i;
- }
- }
-}
-
-void intrusive_hash_map_init(intrusive_hash_map *hash_map,
- uint32_t initial_log2_table_size) {
- hash_map->log2_num_buckets = initial_log2_table_size;
- hash_map->num_items = 0;
- uint32_t num_buckets = (uint32_t)1 << hash_map->log2_num_buckets;
- hash_map->extend_threshold = num_buckets >> 1;
- chunked_vector_init(&hash_map->buckets);
- chunked_vector_reset(&hash_map->buckets, num_buckets);
- hash_map->hash_mask = num_buckets - 1;
-}
-
-bool intrusive_hash_map_empty(const intrusive_hash_map *hash_map) {
- return hash_map->num_items == 0;
-}
-
-size_t intrusive_hash_map_size(const intrusive_hash_map *hash_map) {
- return hash_map->num_items;
-}
-
-void intrusive_hash_map_end(const intrusive_hash_map *hash_map, hm_index *idx) {
- idx->bucket_index = (uint32_t)hash_map->buckets.size_;
- GPR_ASSERT(idx->bucket_index <= UINT32_MAX);
- idx->item = NULL;
-}
-
-void intrusive_hash_map_next(const intrusive_hash_map *hash_map,
- hm_index *idx) {
- idx->item = idx->item->hash_link;
- while (idx->item == NULL) {
- idx->bucket_index++;
- if (idx->bucket_index >= hash_map->buckets.size_) {
- /* Reached end of table. */
- idx->item = NULL;
- return;
- }
- idx->item = (hm_item *)get_bucket(&hash_map->buckets, idx->bucket_index);
- }
-}
-
-void intrusive_hash_map_begin(const intrusive_hash_map *hash_map,
- hm_index *idx) {
- for (uint32_t i = 0; i < hash_map->buckets.size_; ++i) {
- if (get_bucket(&hash_map->buckets, i) != NULL) {
- idx->bucket_index = i;
- idx->item = (hm_item *)get_bucket(&hash_map->buckets, i);
- return;
- }
- }
- intrusive_hash_map_end(hash_map, idx);
-}
-
-hm_item *intrusive_hash_map_find(const intrusive_hash_map *hash_map,
- uint64_t key) {
- uint32_t index = chunked_vector_hasher(key) & hash_map->hash_mask;
-
- hm_item *p = (hm_item *)get_bucket(&hash_map->buckets, index);
- while (p != NULL) {
- if (key == p->key) {
- return p;
- }
- p = p->hash_link;
- }
- return NULL;
-}
-
-hm_item *intrusive_hash_map_erase(intrusive_hash_map *hash_map, uint64_t key) {
- uint32_t index = chunked_vector_hasher(key) & hash_map->hash_mask;
-
- hm_item **slot = (hm_item **)get_mutable_bucket(&hash_map->buckets, index);
- hm_item *p = *slot;
- if (p == NULL) {
- return NULL;
- }
-
- if (key == p->key) {
- *slot = p->hash_link;
- p->hash_link = NULL;
- hash_map->num_items--;
- return p;
- }
-
- hm_item *prev = p;
- p = p->hash_link;
-
- while (p) {
- if (key == p->key) {
- prev->hash_link = p->hash_link;
- p->hash_link = NULL;
- hash_map->num_items--;
- return p;
- }
- prev = p;
- p = p->hash_link;
- }
- return NULL;
-}
-
-/* Insert an hm_item* into the underlying chunked vector. hash_mask is
- * array_size-1. Returns true if it is a new hm_item and false if the hm_item
- * already existed.
- */
-static __inline bool intrusive_hash_map_internal_insert(chunked_vector *buckets,
- uint32_t hash_mask,
- hm_item *item) {
- const uint64_t key = item->key;
- uint32_t index = chunked_vector_hasher(key) & hash_mask;
- hm_item **slot = (hm_item **)get_mutable_bucket(buckets, index);
- hm_item *p = *slot;
- item->hash_link = p;
-
- /* Check to see if key already exists. */
- while (p) {
- if (p->key == key) {
- return false;
- }
- p = p->hash_link;
- }
-
- /* Otherwise add new entry. */
- *slot = item;
- return true;
-}
-
-/* Extend the allocated number of elements in the hash map by a factor of 2. */
-void intrusive_hash_map_extend(intrusive_hash_map *hash_map) {
- uint32_t new_log2_num_buckets = 1 + hash_map->log2_num_buckets;
- uint32_t new_num_buckets = (uint32_t)1 << new_log2_num_buckets;
- GPR_ASSERT(new_num_buckets <= UINT32_MAX && new_num_buckets > 0);
- chunked_vector new_buckets;
- chunked_vector_init(&new_buckets);
- chunked_vector_reset(&new_buckets, new_num_buckets);
- uint32_t new_hash_mask = new_num_buckets - 1;
-
- hm_index cur_idx;
- hm_index end_idx;
- intrusive_hash_map_end(hash_map, &end_idx);
- intrusive_hash_map_begin(hash_map, &cur_idx);
- while (!hm_index_compare(&cur_idx, &end_idx)) {
- hm_item *new_item = cur_idx.item;
- intrusive_hash_map_next(hash_map, &cur_idx);
- intrusive_hash_map_internal_insert(&new_buckets, new_hash_mask, new_item);
- }
-
- /* Set values for new chunked_vector. extend_threshold is set to half of
- * new_num_buckets. */
- hash_map->log2_num_buckets = new_log2_num_buckets;
- chunked_vector_clear(&hash_map->buckets);
- hash_map->buckets = new_buckets;
- hash_map->hash_mask = new_hash_mask;
- hash_map->extend_threshold = new_num_buckets >> 1;
-}
-
-/* Insert a hm_item. The hm_item must remain live until it is removed from the
- table. This object does not take the ownership of hm_item. The caller must
- remove this hm_item from the table and delete it before this table is
- deleted. If hm_item exists already num_items is not changed. */
-bool intrusive_hash_map_insert(intrusive_hash_map *hash_map, hm_item *item) {
- if (hash_map->num_items >= hash_map->extend_threshold) {
- intrusive_hash_map_extend(hash_map);
- }
- if (intrusive_hash_map_internal_insert(&hash_map->buckets,
- hash_map->hash_mask, item)) {
- hash_map->num_items++;
- return true;
- }
- return false;
-}
-
-void intrusive_hash_map_clear(intrusive_hash_map *hash_map,
- void (*free_object)(void *)) {
- hm_index cur;
- hm_index end;
- intrusive_hash_map_end(hash_map, &end);
- intrusive_hash_map_begin(hash_map, &cur);
-
- while (!hm_index_compare(&cur, &end)) {
- hm_index next = cur;
- intrusive_hash_map_next(hash_map, &next);
- if (cur.item != NULL) {
- hm_item *item = intrusive_hash_map_erase(hash_map, cur.item->key);
- (*free_object)((void *)item);
- gpr_free(item);
- }
- cur = next;
- }
-}
-
-void intrusive_hash_map_free(intrusive_hash_map *hash_map,
- void (*free_object)(void *)) {
- intrusive_hash_map_clear(hash_map, (*free_object));
- hash_map->num_items = 0;
- hash_map->extend_threshold = 0;
- hash_map->log2_num_buckets = 0;
- hash_map->hash_mask = 0;
- chunked_vector_clear(&hash_map->buckets);
-}
diff --git a/src/core/ext/census/intrusive_hash_map.h b/src/core/ext/census/intrusive_hash_map.h
deleted file mode 100644
index f50de4fab4..0000000000
--- a/src/core/ext/census/intrusive_hash_map.h
+++ /dev/null
@@ -1,152 +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_CORE_EXT_CENSUS_INTRUSIVE_HASH_MAP_H
-#define GRPC_CORE_EXT_CENSUS_INTRUSIVE_HASH_MAP_H
-
-#include "src/core/ext/census/intrusive_hash_map_internal.h"
-
-/* intrusive_hash_map is a fast chained hash table. This hash map is faster than
- * a dense hash map when the application calls insert and erase more often than
- * find. When the workload is dominated by find() a dense hash map may be
- * faster.
- *
- * intrusive_hash_map uses an intrusive header placed within a user defined
- * struct. The header field IHM_key MUST be set to a valid value before
- * insertion into the hash map or undefined behavior may occur. The header field
- * IHM_hash_link MUST to be set to NULL initially.
- *
- * EXAMPLE USAGE:
- *
- * typedef struct string_item {
- * INTRUSIVE_HASH_MAP_HEADER;
- * // User data.
- * char *str_buf;
- * uint16_t len;
- * } string_item;
- *
- * static string_item *make_string_item(uint64_t key, const char *buf,
- * uint16_t len) {
- * string_item *item = (string_item *)gpr_malloc(sizeof(string_item));
- * item->IHM_key = key;
- * item->IHM_hash_link = NULL;
- * item->len = len;
- * item->str_buf = (char *)malloc(len);
- * memcpy(item->str_buf, buf, len);
- * return item;
- * }
- *
- * intrusive_hash_map hash_map;
- * intrusive_hash_map_init(&hash_map, 4);
- * string_item *new_item1 = make_string_item(10, "test1", 5);
- * bool ok = intrusive_hash_map_insert(&hash_map, (hm_item *)new_item1);
- *
- * string_item *item1 =
- * (string_item *)intrusive_hash_map_find(&hash_map, 10);
- */
-
-/* Hash map item. Stores key and a pointer to the actual object. A user defined
- * version of this can be passed in provided the first 2 entries (key and
- * hash_link) are the same. These entries must be first in the user defined
- * struct. Pointer to struct will need to be cast as (hm_item *) when passed to
- * hash map. This allows it to be intrusive. */
-typedef struct hm_item {
- uint64_t key;
- struct hm_item *hash_link;
- /* Optional user defined data after this. */
-} hm_item;
-
-/* Macro provided for ease of use. This must be first in the user defined
- * struct (i.e. uint64_t key and hm_item * must be the first two elements in
- * that order). */
-#define INTRUSIVE_HASH_MAP_HEADER \
- uint64_t IHM_key; \
- struct hm_item *IHM_hash_link
-
-/* Index struct which acts as a pseudo-iterator within the hash map. */
-typedef struct hm_index {
- uint32_t bucket_index; // hash map bucket index.
- hm_item *item; // Pointer to hm_item within the hash map.
-} hm_index;
-
-/* Returns true if two hm_indices point to the same object within the hash map
- * and false otherwise. */
-__inline bool hm_index_compare(const hm_index *A, const hm_index *B) {
- return (A->item == B->item && A->bucket_index == B->bucket_index);
-}
-
-/*
- * Helper functions for iterating over the hash map.
- */
-
-/* On return idx will contain an invalid index which is always equal to
- * hash_map->buckets.size_ */
-void intrusive_hash_map_end(const intrusive_hash_map *hash_map, hm_index *idx);
-
-/* Iterates index to the next valid entry in the hash map and stores the
- * index within idx. If end of table is reached, idx will contain the same
- * values as if intrusive_hash_map_end() was called. */
-void intrusive_hash_map_next(const intrusive_hash_map *hash_map, hm_index *idx);
-
-/* On return, idx will contain the index of the first non-null entry in the hash
- * map. If the hash map is empty, idx will contain the same values as if
- * intrusive_hash_map_end() was called. */
-void intrusive_hash_map_begin(const intrusive_hash_map *hash_map,
- hm_index *idx);
-
-/* Initialize intrusive hash map data structure. This must be called before
- * the hash map can be used. The initial size of an intrusive hash map will be
- * 2^initial_log2_map_size (valid range is [0, 31]). */
-void intrusive_hash_map_init(intrusive_hash_map *hash_map,
- uint32_t initial_log2_map_size);
-
-/* Returns true if the hash map is empty and false otherwise. */
-bool intrusive_hash_map_empty(const intrusive_hash_map *hash_map);
-
-/* Returns the number of elements currently in the hash map. */
-size_t intrusive_hash_map_size(const intrusive_hash_map *hash_map);
-
-/* Find a hm_item within the hash map by key. Returns NULL if item was not
- * found. */
-hm_item *intrusive_hash_map_find(const intrusive_hash_map *hash_map,
- uint64_t key);
-
-/* Erase the hm_item that corresponds with key. If the hm_item is found, return
- * the pointer to the hm_item. Else returns NULL. */
-hm_item *intrusive_hash_map_erase(intrusive_hash_map *hash_map, uint64_t key);
-
-/* Attempts to insert a new hm_item into the hash map. If an element with the
- * same key already exists, it will not insert the new item and return false.
- * Otherwise, it will insert the new item and return true. */
-bool intrusive_hash_map_insert(intrusive_hash_map *hash_map, hm_item *item);
-
-/* Clears entire contents of the hash map, but leaves internal data structure
- * untouched. Second argument takes a function pointer to a function that will
- * free the object designated by the user and pointed to by hash_map->value. */
-void intrusive_hash_map_clear(intrusive_hash_map *hash_map,
- void (*free_object)(void *));
-
-/* Erase all contents of hash map and free the memory. Hash map is invalid
- * after calling this function and cannot be used until it has been
- * reinitialized (intrusive_hash_map_init()). This function takes a function
- * pointer to a function that will free the object designated by the user and
- * pointed to by hash_map->value. */
-void intrusive_hash_map_free(intrusive_hash_map *hash_map,
- void (*free_object)(void *));
-
-#endif /* GRPC_CORE_EXT_CENSUS_INTRUSIVE_HASH_MAP_H */
diff --git a/src/core/ext/census/intrusive_hash_map_internal.h b/src/core/ext/census/intrusive_hash_map_internal.h
deleted file mode 100644
index e9c81fc85c..0000000000
--- a/src/core/ext/census/intrusive_hash_map_internal.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_CORE_EXT_CENSUS_INTRUSIVE_HASH_MAP_INTERNAL_H
-#define GRPC_CORE_EXT_CENSUS_INTRUSIVE_HASH_MAP_INTERNAL_H
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/useful.h>
-#include <stdbool.h>
-
-/* The chunked vector is a data structure that allocates buckets for use in the
- * hash map. ChunkedVector is logically equivalent to T*[N] (cast void* as
- * T*). It's internally implemented as an array of 1MB arrays to avoid
- * allocating large consecutive memory chunks. This is an internal data
- * structure that should never be accessed directly. */
-typedef struct chunked_vector {
- size_t size_;
- void **first_;
- void ***rest_;
-} chunked_vector;
-
-/* Core intrusive hash map data structure. All internal elements are managed by
- * functions and should not be altered manually. */
-typedef struct intrusive_hash_map {
- uint32_t num_items;
- uint32_t extend_threshold;
- uint32_t log2_num_buckets;
- uint32_t hash_mask;
- chunked_vector buckets;
-} intrusive_hash_map;
-
-#endif /* GRPC_CORE_EXT_CENSUS_INTRUSIVE_HASH_MAP_INTERNAL_H */
diff --git a/src/core/ext/census/mlog.c b/src/core/ext/census/mlog.c
deleted file mode 100644
index 4b8c8466b3..0000000000
--- a/src/core/ext/census/mlog.c
+++ /dev/null
@@ -1,586 +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.
- *
- */
-
-// Implements an efficient in-memory log, optimized for multiple writers and
-// a single reader. Available log space is divided up in blocks of
-// CENSUS_LOG_2_MAX_RECORD_SIZE bytes. A block can be in one of the following
-// three data structures:
-// - Free blocks (free_block_list)
-// - Blocks with unread data (dirty_block_list)
-// - Blocks currently attached to cores (core_local_blocks[])
-//
-// census_log_start_write() moves a block from core_local_blocks[] to the end of
-// dirty_block_list when block:
-// - is out-of-space OR
-// - has an incomplete record (an incomplete record occurs when a thread calls
-// census_log_start_write() and is context-switched before calling
-// census_log_end_write()
-// So, blocks in dirty_block_list are ordered, from oldest to newest, by the
-// time when block is detached from the core.
-//
-// census_log_read_next() first iterates over dirty_block_list and then
-// core_local_blocks[]. It moves completely read blocks from dirty_block_list
-// to free_block_list. Blocks in core_local_blocks[] are not freed, even when
-// completely read.
-//
-// If the log is configured to discard old records and free_block_list is empty,
-// census_log_start_write() iterates over dirty_block_list to allocate a
-// new block. It moves the oldest available block (no pending read/write) to
-// core_local_blocks[].
-//
-// core_local_block_struct is used to implement a map from core id to the block
-// associated with that core. This mapping is advisory. It is possible that the
-// block returned by this mapping is no longer associated with that core. This
-// mapping is updated, lazily, by census_log_start_write().
-//
-// Locking in block struct:
-//
-// Exclusive g_log.lock must be held before calling any functions operating on
-// block structs except census_log_start_write() and census_log_end_write().
-//
-// Writes to a block are serialized via writer_lock. census_log_start_write()
-// acquires this lock and census_log_end_write() releases it. On failure to
-// acquire the lock, writer allocates a new block for the current core and
-// updates core_local_block accordingly.
-//
-// Simultaneous read and write access is allowed. Readers can safely read up to
-// committed bytes (bytes_committed).
-//
-// reader_lock protects the block, currently being read, from getting recycled.
-// start_read() acquires reader_lock and end_read() releases the lock.
-//
-// Read/write access to a block is disabled via try_disable_access(). It returns
-// with both writer_lock and reader_lock held. These locks are subsequently
-// released by enable_access() to enable access to the block.
-//
-// A note on naming: Most function/struct names are prepended by cl_
-// (shorthand for census_log). Further, functions that manipulate structures
-// include the name of the structure, which will be passed as the first
-// argument. E.g. cl_block_initialize() will initialize a cl_block.
-
-#include "src/core/ext/census/mlog.h"
-#include <grpc/support/alloc.h>
-#include <grpc/support/atm.h>
-#include <grpc/support/cpu.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/useful.h>
-#include <stdbool.h>
-#include <string.h>
-
-// End of platform specific code
-
-typedef struct census_log_block_list_struct {
- struct census_log_block_list_struct* next;
- struct census_log_block_list_struct* prev;
- struct census_log_block* block;
-} cl_block_list_struct;
-
-typedef struct census_log_block {
- // Pointer to underlying buffer.
- char* buffer;
- gpr_atm writer_lock;
- gpr_atm reader_lock;
- // Keeps completely written bytes. Declared atomic because accessed
- // simultaneously by reader and writer.
- gpr_atm bytes_committed;
- // Bytes already read.
- size_t bytes_read;
- // Links for list.
- cl_block_list_struct link;
-// We want this structure to be cacheline aligned. We assume the following
-// sizes for the various parts on 32/64bit systems:
-// type 32b size 64b size
-// char* 4 8
-// 3x gpr_atm 12 24
-// size_t 4 8
-// cl_block_list_struct 12 24
-// TOTAL 32 64
-//
-// Depending on the size of our cacheline and the architecture, we
-// selectively add char buffering to this structure. The size is checked
-// via assert in census_log_initialize().
-#if defined(GPR_ARCH_64)
-#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 64)
-#else
-#if defined(GPR_ARCH_32)
-#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 32)
-#else
-#error "Unknown architecture"
-#endif
-#endif
-#if CL_BLOCK_PAD_SIZE > 0
- char padding[CL_BLOCK_PAD_SIZE];
-#endif
-} cl_block;
-
-// A list of cl_blocks, doubly-linked through cl_block::link.
-typedef struct census_log_block_list {
- int32_t count; // Number of items in list.
- cl_block_list_struct ht; // head/tail of linked list.
-} cl_block_list;
-
-// Cacheline aligned block pointers to avoid false sharing. Block pointer must
-// be initialized via set_block(), before calling other functions
-typedef struct census_log_core_local_block {
- gpr_atm block;
-// Ensure cachline alignment: we assume sizeof(gpr_atm) == 4 or 8
-#if defined(GPR_ARCH_64)
-#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 8)
-#else
-#if defined(GPR_ARCH_32)
-#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 4)
-#else
-#error "Unknown architecture"
-#endif
-#endif
-#if CL_CORE_LOCAL_BLOCK_PAD_SIZE > 0
- char padding[CL_CORE_LOCAL_BLOCK_PAD_SIZE];
-#endif
-} cl_core_local_block;
-
-struct census_log {
- int discard_old_records;
- // Number of cores (aka hardware-contexts)
- unsigned num_cores;
- // number of CENSUS_LOG_2_MAX_RECORD_SIZE blocks in log
- uint32_t num_blocks;
- cl_block* blocks; // Block metadata.
- cl_core_local_block* core_local_blocks; // Keeps core to block mappings.
- gpr_mu lock;
- int initialized; // has log been initialized?
- // Keeps the state of the reader iterator. A value of 0 indicates that
- // iterator has reached the end. census_log_init_reader() resets the value
- // to num_core to restart iteration.
- uint32_t read_iterator_state;
- // Points to the block being read. If non-NULL, the block is locked for
- // reading(block_being_read_->reader_lock is held).
- cl_block* block_being_read;
- char* buffer;
- cl_block_list free_block_list;
- cl_block_list dirty_block_list;
- gpr_atm out_of_space_count;
-};
-
-// Single internal log.
-static struct census_log g_log;
-
-// Functions that operate on an atomic memory location used as a lock.
-
-// Returns non-zero if lock is acquired.
-static int cl_try_lock(gpr_atm* lock) { return gpr_atm_acq_cas(lock, 0, 1); }
-
-static void cl_unlock(gpr_atm* lock) { gpr_atm_rel_store(lock, 0); }
-
-// Functions that operate on cl_core_local_block's.
-
-static void cl_core_local_block_set_block(cl_core_local_block* clb,
- cl_block* block) {
- gpr_atm_rel_store(&clb->block, (gpr_atm)block);
-}
-
-static cl_block* cl_core_local_block_get_block(cl_core_local_block* clb) {
- return (cl_block*)gpr_atm_acq_load(&clb->block);
-}
-
-// Functions that operate on cl_block_list_struct's.
-
-static void cl_block_list_struct_initialize(cl_block_list_struct* bls,
- cl_block* block) {
- bls->next = bls->prev = bls;
- bls->block = block;
-}
-
-// Functions that operate on cl_block_list's.
-
-static void cl_block_list_initialize(cl_block_list* list) {
- list->count = 0;
- cl_block_list_struct_initialize(&list->ht, NULL);
-}
-
-// Returns head of *this, or NULL if empty.
-static cl_block* cl_block_list_head(cl_block_list* list) {
- return list->ht.next->block;
-}
-
-// Insert element *e after *pos.
-static void cl_block_list_insert(cl_block_list* list, cl_block_list_struct* pos,
- cl_block_list_struct* e) {
- list->count++;
- e->next = pos->next;
- e->prev = pos;
- e->next->prev = e;
- e->prev->next = e;
-}
-
-// Insert block at the head of the list
-static void cl_block_list_insert_at_head(cl_block_list* list, cl_block* block) {
- cl_block_list_insert(list, &list->ht, &block->link);
-}
-
-// Insert block at the tail of the list.
-static void cl_block_list_insert_at_tail(cl_block_list* list, cl_block* block) {
- cl_block_list_insert(list, list->ht.prev, &block->link);
-}
-
-// Removes block *b. Requires *b be in the list.
-static void cl_block_list_remove(cl_block_list* list, cl_block* b) {
- list->count--;
- b->link.next->prev = b->link.prev;
- b->link.prev->next = b->link.next;
-}
-
-// Functions that operate on cl_block's
-
-static void cl_block_initialize(cl_block* block, char* buffer) {
- block->buffer = buffer;
- gpr_atm_rel_store(&block->writer_lock, 0);
- gpr_atm_rel_store(&block->reader_lock, 0);
- gpr_atm_rel_store(&block->bytes_committed, 0);
- block->bytes_read = 0;
- cl_block_list_struct_initialize(&block->link, block);
-}
-
-// Guards against exposing partially written buffer to the reader.
-static void cl_block_set_bytes_committed(cl_block* block,
- size_t bytes_committed) {
- gpr_atm_rel_store(&block->bytes_committed, (gpr_atm)bytes_committed);
-}
-
-static size_t cl_block_get_bytes_committed(cl_block* block) {
- return (size_t)gpr_atm_acq_load(&block->bytes_committed);
-}
-
-// Tries to disable future read/write access to this block. Succeeds if:
-// - no in-progress write AND
-// - no in-progress read AND
-// - 'discard_data' set to true OR no unread data
-// On success, clears the block state and returns with writer_lock_ and
-// reader_lock_ held. These locks are released by a subsequent
-// cl_block_access_enable() call.
-static bool cl_block_try_disable_access(cl_block* block, int discard_data) {
- if (!cl_try_lock(&block->writer_lock)) {
- return false;
- }
- if (!cl_try_lock(&block->reader_lock)) {
- cl_unlock(&block->writer_lock);
- return false;
- }
- if (!discard_data &&
- (block->bytes_read != cl_block_get_bytes_committed(block))) {
- cl_unlock(&block->reader_lock);
- cl_unlock(&block->writer_lock);
- return false;
- }
- cl_block_set_bytes_committed(block, 0);
- block->bytes_read = 0;
- return true;
-}
-
-static void cl_block_enable_access(cl_block* block) {
- cl_unlock(&block->reader_lock);
- cl_unlock(&block->writer_lock);
-}
-
-// Returns with writer_lock held.
-static void* cl_block_start_write(cl_block* block, size_t size) {
- if (!cl_try_lock(&block->writer_lock)) {
- return NULL;
- }
- size_t bytes_committed = cl_block_get_bytes_committed(block);
- if (bytes_committed + size > CENSUS_LOG_MAX_RECORD_SIZE) {
- cl_unlock(&block->writer_lock);
- return NULL;
- }
- return block->buffer + bytes_committed;
-}
-
-// Releases writer_lock and increments committed bytes by 'bytes_written'.
-// 'bytes_written' must be <= 'size' specified in the corresponding
-// StartWrite() call. This function is thread-safe.
-static void cl_block_end_write(cl_block* block, size_t bytes_written) {
- cl_block_set_bytes_committed(
- block, cl_block_get_bytes_committed(block) + bytes_written);
- cl_unlock(&block->writer_lock);
-}
-
-// Returns a pointer to the first unread byte in buffer. The number of bytes
-// available are returned in 'bytes_available'. Acquires reader lock that is
-// released by a subsequent cl_block_end_read() call. Returns NULL if:
-// - read in progress
-// - no data available
-static void* cl_block_start_read(cl_block* block, size_t* bytes_available) {
- if (!cl_try_lock(&block->reader_lock)) {
- return NULL;
- }
- // bytes_committed may change from under us. Use bytes_available to update
- // bytes_read below.
- size_t bytes_committed = cl_block_get_bytes_committed(block);
- GPR_ASSERT(bytes_committed >= block->bytes_read);
- *bytes_available = bytes_committed - block->bytes_read;
- if (*bytes_available == 0) {
- cl_unlock(&block->reader_lock);
- return NULL;
- }
- void* record = block->buffer + block->bytes_read;
- block->bytes_read += *bytes_available;
- return record;
-}
-
-static void cl_block_end_read(cl_block* block) {
- cl_unlock(&block->reader_lock);
-}
-
-// Internal functions operating on g_log
-
-// Allocates a new free block (or recycles an available dirty block if log is
-// configured to discard old records). Returns NULL if out-of-space.
-static cl_block* cl_allocate_block(void) {
- cl_block* block = cl_block_list_head(&g_log.free_block_list);
- if (block != NULL) {
- cl_block_list_remove(&g_log.free_block_list, block);
- return block;
- }
- if (!g_log.discard_old_records) {
- // No free block and log is configured to keep old records.
- return NULL;
- }
- // Recycle dirty block. Start from the oldest.
- for (block = cl_block_list_head(&g_log.dirty_block_list); block != NULL;
- block = block->link.next->block) {
- if (cl_block_try_disable_access(block, 1 /* discard data */)) {
- cl_block_list_remove(&g_log.dirty_block_list, block);
- return block;
- }
- }
- return NULL;
-}
-
-// Allocates a new block and updates core id => block mapping. 'old_block'
-// points to the block that the caller thinks is attached to
-// 'core_id'. 'old_block' may be NULL. Returns true if:
-// - allocated a new block OR
-// - 'core_id' => 'old_block' mapping changed (another thread allocated a
-// block before lock was acquired).
-static bool cl_allocate_core_local_block(uint32_t core_id,
- cl_block* old_block) {
- // Now that we have the lock, check if core-local mapping has changed.
- cl_core_local_block* core_local_block = &g_log.core_local_blocks[core_id];
- cl_block* block = cl_core_local_block_get_block(core_local_block);
- if ((block != NULL) && (block != old_block)) {
- return true;
- }
- if (block != NULL) {
- cl_core_local_block_set_block(core_local_block, NULL);
- cl_block_list_insert_at_tail(&g_log.dirty_block_list, block);
- }
- block = cl_allocate_block();
- if (block == NULL) {
- return false;
- }
- cl_core_local_block_set_block(core_local_block, block);
- cl_block_enable_access(block);
- return true;
-}
-
-static cl_block* cl_get_block(void* record) {
- uintptr_t p = (uintptr_t)((char*)record - g_log.buffer);
- uintptr_t index = p >> CENSUS_LOG_2_MAX_RECORD_SIZE;
- return &g_log.blocks[index];
-}
-
-// Gets the next block to read and tries to free 'prev' block (if not NULL).
-// Returns NULL if reached the end.
-static cl_block* cl_next_block_to_read(cl_block* prev) {
- cl_block* block = NULL;
- if (g_log.read_iterator_state == g_log.num_cores) {
- // We are traversing dirty list; find the next dirty block.
- if (prev != NULL) {
- // Try to free the previous block if there is no unread data. This
- // block
- // may have unread data if previously incomplete record completed
- // between
- // read_next() calls.
- block = prev->link.next->block;
- if (cl_block_try_disable_access(prev, 0 /* do not discard data */)) {
- cl_block_list_remove(&g_log.dirty_block_list, prev);
- cl_block_list_insert_at_head(&g_log.free_block_list, prev);
- }
- } else {
- block = cl_block_list_head(&g_log.dirty_block_list);
- }
- if (block != NULL) {
- return block;
- }
- // We are done with the dirty list; moving on to core-local blocks.
- }
- while (g_log.read_iterator_state > 0) {
- g_log.read_iterator_state--;
- block = cl_core_local_block_get_block(
- &g_log.core_local_blocks[g_log.read_iterator_state]);
- if (block != NULL) {
- return block;
- }
- }
- return NULL;
-}
-
-#define CL_LOG_2_MB 20 // 2^20 = 1MB
-
-// External functions: primary stats_log interface
-void census_log_initialize(size_t size_in_mb, int discard_old_records) {
- // Check cacheline alignment.
- GPR_ASSERT(sizeof(cl_block) % GPR_CACHELINE_SIZE == 0);
- GPR_ASSERT(sizeof(cl_core_local_block) % GPR_CACHELINE_SIZE == 0);
- GPR_ASSERT(!g_log.initialized);
- g_log.discard_old_records = discard_old_records;
- g_log.num_cores = gpr_cpu_num_cores();
- // Ensure that we will not get any overflow in calaculating num_blocks
- GPR_ASSERT(CL_LOG_2_MB >= CENSUS_LOG_2_MAX_RECORD_SIZE);
- GPR_ASSERT(size_in_mb < 1000);
- // Ensure at least 2x as many blocks as there are cores.
- g_log.num_blocks =
- (uint32_t)GPR_MAX(2 * g_log.num_cores, (size_in_mb << CL_LOG_2_MB) >>
- CENSUS_LOG_2_MAX_RECORD_SIZE);
- gpr_mu_init(&g_log.lock);
- g_log.read_iterator_state = 0;
- g_log.block_being_read = NULL;
- g_log.core_local_blocks = (cl_core_local_block*)gpr_malloc_aligned(
- g_log.num_cores * sizeof(cl_core_local_block), GPR_CACHELINE_SIZE_LOG);
- memset(g_log.core_local_blocks, 0,
- g_log.num_cores * sizeof(cl_core_local_block));
- g_log.blocks = (cl_block*)gpr_malloc_aligned(
- g_log.num_blocks * sizeof(cl_block), GPR_CACHELINE_SIZE_LOG);
- memset(g_log.blocks, 0, g_log.num_blocks * sizeof(cl_block));
- g_log.buffer =
- (char*)gpr_malloc(g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE);
- memset(g_log.buffer, 0, g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE);
- cl_block_list_initialize(&g_log.free_block_list);
- cl_block_list_initialize(&g_log.dirty_block_list);
- for (uint32_t i = 0; i < g_log.num_blocks; ++i) {
- cl_block* block = g_log.blocks + i;
- cl_block_initialize(block, g_log.buffer + (CENSUS_LOG_MAX_RECORD_SIZE * i));
- cl_block_try_disable_access(block, 1 /* discard data */);
- cl_block_list_insert_at_tail(&g_log.free_block_list, block);
- }
- gpr_atm_rel_store(&g_log.out_of_space_count, 0);
- g_log.initialized = 1;
-}
-
-void census_log_shutdown(void) {
- GPR_ASSERT(g_log.initialized);
- gpr_mu_destroy(&g_log.lock);
- gpr_free_aligned(g_log.core_local_blocks);
- g_log.core_local_blocks = NULL;
- gpr_free_aligned(g_log.blocks);
- g_log.blocks = NULL;
- gpr_free(g_log.buffer);
- g_log.buffer = NULL;
- g_log.initialized = 0;
-}
-
-void* census_log_start_write(size_t size) {
- // Used to bound number of times block allocation is attempted.
- GPR_ASSERT(size > 0);
- GPR_ASSERT(g_log.initialized);
- if (size > CENSUS_LOG_MAX_RECORD_SIZE) {
- return NULL;
- }
- uint32_t attempts_remaining = g_log.num_blocks;
- uint32_t core_id = gpr_cpu_current_cpu();
- do {
- void* record = NULL;
- cl_block* block =
- cl_core_local_block_get_block(&g_log.core_local_blocks[core_id]);
- if (block && (record = cl_block_start_write(block, size))) {
- return record;
- }
- // Need to allocate a new block. We are here if:
- // - No block associated with the core OR
- // - Write in-progress on the block OR
- // - block is out of space
- gpr_mu_lock(&g_log.lock);
- bool allocated = cl_allocate_core_local_block(core_id, block);
- gpr_mu_unlock(&g_log.lock);
- if (!allocated) {
- gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
- return NULL;
- }
- } while (attempts_remaining--);
- // Give up.
- gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
- return NULL;
-}
-
-void census_log_end_write(void* record, size_t bytes_written) {
- GPR_ASSERT(g_log.initialized);
- cl_block_end_write(cl_get_block(record), bytes_written);
-}
-
-void census_log_init_reader(void) {
- GPR_ASSERT(g_log.initialized);
- gpr_mu_lock(&g_log.lock);
- // If a block is locked for reading unlock it.
- if (g_log.block_being_read != NULL) {
- cl_block_end_read(g_log.block_being_read);
- g_log.block_being_read = NULL;
- }
- g_log.read_iterator_state = g_log.num_cores;
- gpr_mu_unlock(&g_log.lock);
-}
-
-const void* census_log_read_next(size_t* bytes_available) {
- GPR_ASSERT(g_log.initialized);
- gpr_mu_lock(&g_log.lock);
- if (g_log.block_being_read != NULL) {
- cl_block_end_read(g_log.block_being_read);
- }
- do {
- g_log.block_being_read = cl_next_block_to_read(g_log.block_being_read);
- if (g_log.block_being_read != NULL) {
- void* record =
- cl_block_start_read(g_log.block_being_read, bytes_available);
- if (record != NULL) {
- gpr_mu_unlock(&g_log.lock);
- return record;
- }
- }
- } while (g_log.block_being_read != NULL);
- gpr_mu_unlock(&g_log.lock);
- return NULL;
-}
-
-size_t census_log_remaining_space(void) {
- GPR_ASSERT(g_log.initialized);
- size_t space = 0;
- gpr_mu_lock(&g_log.lock);
- if (g_log.discard_old_records) {
- // Remaining space is not meaningful; just return the entire log space.
- space = g_log.num_blocks << CENSUS_LOG_2_MAX_RECORD_SIZE;
- } else {
- GPR_ASSERT(g_log.free_block_list.count >= 0);
- space = (size_t)g_log.free_block_list.count * CENSUS_LOG_MAX_RECORD_SIZE;
- }
- gpr_mu_unlock(&g_log.lock);
- return space;
-}
-
-int64_t census_log_out_of_space_count(void) {
- GPR_ASSERT(g_log.initialized);
- return gpr_atm_acq_load(&g_log.out_of_space_count);
-}
diff --git a/src/core/ext/census/mlog.h b/src/core/ext/census/mlog.h
deleted file mode 100644
index 6f3125944f..0000000000
--- a/src/core/ext/census/mlog.h
+++ /dev/null
@@ -1,80 +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.
- *
- */
-
-/* A very fast in-memory log, optimized for multiple writers. */
-
-#ifndef GRPC_CORE_EXT_CENSUS_MLOG_H
-#define GRPC_CORE_EXT_CENSUS_MLOG_H
-
-#include <grpc/support/port_platform.h>
-#include <stddef.h>
-
-/* Maximum record size, in bytes. */
-#define CENSUS_LOG_2_MAX_RECORD_SIZE 14 /* 2^14 = 16KB */
-#define CENSUS_LOG_MAX_RECORD_SIZE (1 << CENSUS_LOG_2_MAX_RECORD_SIZE)
-
-/* Initialize the statistics logging subsystem with the given log size. A log
- size of 0 will result in the smallest possible log for the platform
- (approximately CENSUS_LOG_MAX_RECORD_SIZE * gpr_cpu_num_cores()). If
- discard_old_records is non-zero, then new records will displace older ones
- when the log is full. This function must be called before any other
- census_log functions.
-*/
-void census_log_initialize(size_t size_in_mb, int discard_old_records);
-
-/* Shutdown the logging subsystem. Caller must ensure that:
- - no in progress or future call to any census_log functions
- - no incomplete records
-*/
-void census_log_shutdown(void);
-
-/* Allocates and returns a 'size' bytes record and marks it in use. A
- subsequent census_log_end_write() marks the record complete. The
- 'bytes_written' census_log_end_write() argument must be <=
- 'size'. Returns NULL if out-of-space AND:
- - log is configured to keep old records OR
- - all blocks are pinned by incomplete records.
-*/
-void* census_log_start_write(size_t size);
-
-void census_log_end_write(void* record, size_t bytes_written);
-
-void census_log_init_reader(void);
-
-/* census_log_read_next() iterates over blocks with data and for each block
- returns a pointer to the first unread byte. The number of bytes that can be
- read are returned in 'bytes_available'. Reader is expected to read all
- available data. Reading the data consumes it i.e. it cannot be read again.
- census_log_read_next() returns NULL if the end is reached i.e last block
- is read. census_log_init_reader() starts the iteration or aborts the
- current iteration.
-*/
-const void* census_log_read_next(size_t* bytes_available);
-
-/* Returns estimated remaining space across all blocks, in bytes. If log is
- configured to discard old records, returns total log space. Otherwise,
- returns space available in empty blocks (partially filled blocks are
- treated as full).
-*/
-size_t census_log_remaining_space(void);
-
-/* Returns the number of times grpc_stats_log_start_write() failed due to
- out-of-space. */
-int64_t census_log_out_of_space_count(void);
-
-#endif /* GRPC_CORE_EXT_CENSUS_MLOG_H */
diff --git a/src/core/ext/census/operation.c b/src/core/ext/census/operation.c
deleted file mode 100644
index be88ac74e6..0000000000
--- a/src/core/ext/census/operation.c
+++ /dev/null
@@ -1,48 +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 <grpc/census.h>
-
-/* TODO(aveitch): These are all placeholder implementations. */
-
-census_timestamp census_start_rpc_op_timestamp(void) {
- census_timestamp ct;
- /* TODO(aveitch): assumes gpr_timespec implementation of census_timestamp. */
- ct.ts = gpr_now(GPR_CLOCK_MONOTONIC);
- return ct;
-}
-
-census_context *census_start_client_rpc_op(
- const census_context *context, int64_t rpc_name_id,
- const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
- const census_timestamp *start_time) {
- return NULL;
-}
-
-census_context *census_start_server_rpc_op(
- const char *buffer, int64_t rpc_name_id,
- const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
- census_timestamp *start_time) {
- return NULL;
-}
-
-census_context *census_start_op(census_context *context, const char *family,
- const char *name, int trace_mask) {
- return NULL;
-}
-
-void census_end_op(census_context *context, int status) {}
diff --git a/src/core/ext/census/placeholders.c b/src/core/ext/census/placeholders.c
deleted file mode 100644
index bed9837ee3..0000000000
--- a/src/core/ext/census/placeholders.c
+++ /dev/null
@@ -1,49 +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 <grpc/census.h>
-
-#include <grpc/support/log.h>
-
-/* Placeholders for the pending APIs */
-
-int census_get_trace_record(census_trace_record *trace_record) {
- (void)trace_record;
- abort();
-}
-
-void census_record_values(census_context *context, census_value *values,
- size_t nvalues) {
- (void)context;
- (void)values;
- (void)nvalues;
- abort();
-}
-
-void census_set_rpc_client_peer(census_context *context, const char *peer) {
- (void)context;
- (void)peer;
- abort();
-}
-
-void census_trace_scan_end() { abort(); }
-
-int census_trace_scan_start(int consume) {
- (void)consume;
- abort();
-}
diff --git a/src/core/ext/census/resource.c b/src/core/ext/census/resource.c
deleted file mode 100644
index 44a887231c..0000000000
--- a/src/core/ext/census/resource.c
+++ /dev/null
@@ -1,303 +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 "src/core/ext/census/resource.h"
-#include "third_party/nanopb/pb_decode.h"
-
-#include <grpc/census.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-
-#include <stdbool.h>
-#include <string.h>
-
-// Protect local resource data structures.
-static gpr_mu resource_lock;
-
-// Deleteing and creating resources are relatively rare events, and should not
-// be done in the critical path of performance sensitive code. We record
-// current resource id's used in a simple array, and just search it each time
-// we need to assign a new id, or look up a resource.
-static resource **resources = NULL;
-
-// Number of entries in *resources
-static size_t n_resources = 0;
-
-// Number of defined resources
-static size_t n_defined_resources = 0;
-
-void initialize_resources(void) {
- gpr_mu_init(&resource_lock);
- gpr_mu_lock(&resource_lock);
- GPR_ASSERT(resources == NULL && n_resources == 0 && n_defined_resources == 0);
- gpr_mu_unlock(&resource_lock);
-}
-
-// Delete a resource given it's ID. The ID must be a valid resource ID. Must be
-// called with resource_lock held.
-static void delete_resource_locked(size_t rid) {
- GPR_ASSERT(resources[rid] != NULL);
- gpr_free(resources[rid]->name);
- gpr_free(resources[rid]->description);
- gpr_free(resources[rid]->numerators);
- gpr_free(resources[rid]->denominators);
- gpr_free(resources[rid]);
- resources[rid] = NULL;
- n_defined_resources--;
-}
-
-void shutdown_resources(void) {
- gpr_mu_lock(&resource_lock);
- for (size_t i = 0; i < n_resources; i++) {
- if (resources[i] != NULL) {
- delete_resource_locked(i);
- }
- }
- GPR_ASSERT(n_defined_resources == 0);
- gpr_free(resources);
- resources = NULL;
- n_resources = 0;
- gpr_mu_unlock(&resource_lock);
-}
-
-// Check the contents of string fields in a resource proto.
-static bool validate_string(pb_istream_t *stream, const pb_field_t *field,
- void **arg) {
- resource *vresource = (resource *)*arg;
- switch (field->tag) {
- case google_census_Resource_name_tag:
- // Name must have at least one character
- if (stream->bytes_left == 0) {
- gpr_log(GPR_INFO, "Zero-length Resource name.");
- return false;
- }
- vresource->name = (char *)gpr_malloc(stream->bytes_left + 1);
- vresource->name[stream->bytes_left] = '\0';
- if (!pb_read(stream, (uint8_t *)vresource->name, stream->bytes_left)) {
- return false;
- }
- // Can't have same name as an existing resource.
- for (size_t i = 0; i < n_resources; i++) {
- resource *compare = resources[i];
- if (compare == vresource || compare == NULL) continue;
- if (strcmp(compare->name, vresource->name) == 0) {
- gpr_log(GPR_INFO, "Duplicate Resource name %s.", vresource->name);
- return false;
- }
- }
- break;
- case google_census_Resource_description_tag:
- if (stream->bytes_left == 0) {
- return true;
- }
- vresource->description = (char *)gpr_malloc(stream->bytes_left + 1);
- vresource->description[stream->bytes_left] = '\0';
- if (!pb_read(stream, (uint8_t *)vresource->description,
- stream->bytes_left)) {
- return false;
- }
- break;
- default:
- // No other string fields in Resource. Print warning and skip.
- gpr_log(GPR_INFO, "Unknown string field type in Resource protobuf.");
- if (!pb_read(stream, NULL, stream->bytes_left)) {
- return false;
- }
- break;
- }
- return true;
-}
-
-// Decode numerators/denominators in a stream. The `count` and `bup`
-// (BasicUnit pointer) are pointers to the approriate fields in a resource
-// struct.
-static bool validate_units_helper(pb_istream_t *stream, int *count,
- google_census_Resource_BasicUnit **bup) {
- while (stream->bytes_left) {
- (*count)++;
- // Have to allocate a new array of values. Normal case is 0 or 1, so
- // this should normally not be an issue.
- google_census_Resource_BasicUnit *new_bup =
- (google_census_Resource_BasicUnit *)gpr_malloc(
- (size_t)*count * sizeof(google_census_Resource_BasicUnit));
- if (*count != 1) {
- memcpy(new_bup, *bup,
- (size_t)(*count - 1) * sizeof(google_census_Resource_BasicUnit));
- gpr_free(*bup);
- }
- *bup = new_bup;
- uint64_t value;
- if (!pb_decode_varint(stream, &value)) {
- return false;
- }
- *(*bup + *count - 1) = (google_census_Resource_BasicUnit)value;
- }
- return true;
-}
-
-// Validate units field of a Resource proto.
-static bool validate_units(pb_istream_t *stream, const pb_field_t *field,
- void **arg) {
- resource *vresource = (resource *)(*arg);
- switch (field->tag) {
- case google_census_Resource_MeasurementUnit_numerator_tag:
- return validate_units_helper(stream, &vresource->n_numerators,
- &vresource->numerators);
- break;
- case google_census_Resource_MeasurementUnit_denominator_tag:
- return validate_units_helper(stream, &vresource->n_denominators,
- &vresource->denominators);
- break;
- default:
- gpr_log(GPR_ERROR, "Unknown field type.");
- return false;
- break;
- }
- return true;
-}
-
-// Validate the contents of a Resource proto. `id` is the intended resource id.
-static bool validate_resource_pb(const uint8_t *resource_pb,
- size_t resource_pb_size, size_t id) {
- GPR_ASSERT(id < n_resources);
- if (resource_pb == NULL) {
- return false;
- }
- google_census_Resource vresource;
- vresource.name.funcs.decode = &validate_string;
- vresource.name.arg = resources[id];
- vresource.description.funcs.decode = &validate_string;
- vresource.description.arg = resources[id];
- vresource.unit.numerator.funcs.decode = &validate_units;
- vresource.unit.numerator.arg = resources[id];
- vresource.unit.denominator.funcs.decode = &validate_units;
- vresource.unit.denominator.arg = resources[id];
-
- pb_istream_t stream =
- pb_istream_from_buffer((uint8_t *)resource_pb, resource_pb_size);
- if (!pb_decode(&stream, google_census_Resource_fields, &vresource)) {
- return false;
- }
- // A Resource must have a name, a unit, with at least one numerator.
- return (resources[id]->name != NULL && vresource.has_unit &&
- resources[id]->n_numerators > 0);
-}
-
-// Allocate a blank resource, and return associated ID. Must be called with
-// resource_lock held.
-size_t allocate_resource(void) {
- // use next_id to optimize expected placement of next new resource.
- static size_t next_id = 0;
- size_t id = n_resources; // resource ID - initialize to invalid value.
- // Expand resources if needed.
- if (n_resources == n_defined_resources) {
- size_t new_n_resources = n_resources ? n_resources * 2 : 2;
- resource **new_resources =
- (resource **)gpr_malloc(new_n_resources * sizeof(resource *));
- if (n_resources != 0) {
- memcpy(new_resources, resources, n_resources * sizeof(resource *));
- }
- memset(new_resources + n_resources, 0,
- (new_n_resources - n_resources) * sizeof(resource *));
- gpr_free(resources);
- resources = new_resources;
- n_resources = new_n_resources;
- id = n_defined_resources;
- } else {
- GPR_ASSERT(n_defined_resources < n_resources);
- // Find a free id.
- for (size_t base = 0; base < n_resources; base++) {
- id = (next_id + base) % n_resources;
- if (resources[id] == NULL) break;
- }
- }
- GPR_ASSERT(id < n_resources && resources[id] == NULL);
- resources[id] = (resource *)gpr_malloc(sizeof(resource));
- memset(resources[id], 0, sizeof(resource));
- n_defined_resources++;
- next_id = (id + 1) % n_resources;
- return id;
-}
-
-int32_t census_define_resource(const uint8_t *resource_pb,
- size_t resource_pb_size) {
- if (resource_pb == NULL) {
- return -1;
- }
- gpr_mu_lock(&resource_lock);
- size_t id = allocate_resource();
- // Validate pb, extract name.
- if (!validate_resource_pb(resource_pb, resource_pb_size, id)) {
- delete_resource_locked(id);
- gpr_mu_unlock(&resource_lock);
- return -1;
- }
- gpr_mu_unlock(&resource_lock);
- return (int32_t)id;
-}
-
-void census_delete_resource(int32_t rid) {
- gpr_mu_lock(&resource_lock);
- if (rid >= 0 && (size_t)rid < n_resources && resources[rid] != NULL) {
- delete_resource_locked((size_t)rid);
- }
- gpr_mu_unlock(&resource_lock);
-}
-
-int32_t census_resource_id(const char *name) {
- gpr_mu_lock(&resource_lock);
- for (int32_t id = 0; (size_t)id < n_resources; id++) {
- if (resources[id] != NULL && strcmp(resources[id]->name, name) == 0) {
- gpr_mu_unlock(&resource_lock);
- return id;
- }
- }
- gpr_mu_unlock(&resource_lock);
- return -1;
-}
-
-int32_t define_resource(const resource *base) {
- GPR_ASSERT(base != NULL && base->name != NULL && base->n_numerators > 0 &&
- base->numerators != NULL);
- gpr_mu_lock(&resource_lock);
- size_t id = allocate_resource();
- size_t len = strlen(base->name) + 1;
- resources[id]->name = (char *)gpr_malloc(len);
- memcpy(resources[id]->name, base->name, len);
- if (base->description) {
- len = strlen(base->description) + 1;
- resources[id]->description = (char *)gpr_malloc(len);
- memcpy(resources[id]->description, base->description, len);
- }
- resources[id]->prefix = base->prefix;
- resources[id]->n_numerators = base->n_numerators;
- len = (size_t)base->n_numerators * sizeof(*base->numerators);
- resources[id]->numerators =
- (google_census_Resource_BasicUnit *)gpr_malloc(len);
- memcpy(resources[id]->numerators, base->numerators, len);
- resources[id]->n_denominators = base->n_denominators;
- if (base->n_denominators != 0) {
- len = (size_t)base->n_denominators * sizeof(*base->denominators);
- resources[id]->denominators =
- (google_census_Resource_BasicUnit *)gpr_malloc(len);
- memcpy(resources[id]->denominators, base->denominators, len);
- }
- gpr_mu_unlock(&resource_lock);
- return (int32_t)id;
-}
diff --git a/src/core/ext/census/resource.h b/src/core/ext/census/resource.h
deleted file mode 100644
index b8bda2c72e..0000000000
--- a/src/core/ext/census/resource.h
+++ /dev/null
@@ -1,48 +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.
- *
- */
-
-/* Census-internal resource definition and manipluation functions. */
-#ifndef GRPC_CORE_EXT_CENSUS_RESOURCE_H
-#define GRPC_CORE_EXT_CENSUS_RESOURCE_H
-
-#include <grpc/grpc.h>
-#include "src/core/ext/census/gen/census.pb.h"
-
-/* Internal representation of a resource. */
-typedef struct {
- char *name;
- char *description;
- int32_t prefix;
- int n_numerators;
- google_census_Resource_BasicUnit *numerators;
- int n_denominators;
- google_census_Resource_BasicUnit *denominators;
-} resource;
-
-/* Initialize and shutdown the resources subsystem. */
-void initialize_resources(void);
-void shutdown_resources(void);
-
-/* Add a new resource, given a proposed resource structure. Returns the
- resource ID, or -ve on failure.
- TODO(aveitch): this function exists to support addition of the base
- resources. It should be removed when we have the ability to add resources
- from configuration files. */
-int32_t define_resource(const resource *base);
-
-#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */
diff --git a/src/core/ext/census/rpc_metric_id.h b/src/core/ext/census/rpc_metric_id.h
deleted file mode 100644
index ea493d7288..0000000000
--- a/src/core/ext/census/rpc_metric_id.h
+++ /dev/null
@@ -1,36 +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_EXT_CENSUS_RPC_METRIC_ID_H
-#define GRPC_CORE_EXT_CENSUS_RPC_METRIC_ID_H
-
-/* Metric ID's used for RPC measurements. */
-/* Count of client requests sent. */
-#define CENSUS_METRIC_RPC_CLIENT_REQUESTS ((uint32_t)0)
-/* Count of server requests sent. */
-#define CENSUS_METRIC_RPC_SERVER_REQUESTS ((uint32_t)1)
-/* Client error counts. */
-#define CENSUS_METRIC_RPC_CLIENT_ERRORS ((uint32_t)2)
-/* Server error counts. */
-#define CENSUS_METRIC_RPC_SERVER_ERRORS ((uint32_t)3)
-/* Client side request latency. */
-#define CENSUS_METRIC_RPC_CLIENT_LATENCY ((uint32_t)4)
-/* Server side request latency. */
-#define CENSUS_METRIC_RPC_SERVER_LATENCY ((uint32_t)5)
-
-#endif /* GRPC_CORE_EXT_CENSUS_RPC_METRIC_ID_H */
diff --git a/src/core/ext/census/trace_context.c b/src/core/ext/census/trace_context.c
deleted file mode 100644
index af92ae6d9e..0000000000
--- a/src/core/ext/census/trace_context.c
+++ /dev/null
@@ -1,71 +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 "src/core/ext/census/trace_context.h"
-
-#include <grpc/census.h>
-#include <grpc/support/log.h>
-#include <stdbool.h>
-
-#include "third_party/nanopb/pb_decode.h"
-#include "third_party/nanopb/pb_encode.h"
-
-// This function assumes the TraceContext is valid.
-size_t encode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer,
- const size_t buf_size) {
- // Create a stream that will write to our buffer.
- pb_ostream_t stream = pb_ostream_from_buffer(buffer, buf_size);
-
- // encode message
- bool status = pb_encode(&stream, google_trace_TraceContext_fields, ctxt);
-
- if (!status) {
- gpr_log(GPR_DEBUG, "TraceContext encoding failed: %s",
- PB_GET_ERROR(&stream));
- return 0;
- }
-
- return stream.bytes_written;
-}
-
-bool decode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer,
- const size_t nbytes) {
- // Create a stream that reads nbytes from the buffer.
- pb_istream_t stream = pb_istream_from_buffer(buffer, nbytes);
-
- // decode message
- bool status = pb_decode(&stream, google_trace_TraceContext_fields, ctxt);
-
- if (!status) {
- gpr_log(GPR_DEBUG, "TraceContext decoding failed: %s",
- PB_GET_ERROR(&stream));
- return false;
- }
-
- // check fields
- if (!ctxt->has_trace_id_hi || !ctxt->has_trace_id_lo) {
- gpr_log(GPR_DEBUG, "Invalid TraceContext: missing trace_id");
- return false;
- }
- if (!ctxt->has_span_id) {
- gpr_log(GPR_DEBUG, "Invalid TraceContext: missing span_id");
- return false;
- }
-
- return true;
-}
diff --git a/src/core/ext/census/trace_context.h b/src/core/ext/census/trace_context.h
deleted file mode 100644
index a7233e6a2b..0000000000
--- a/src/core/ext/census/trace_context.h
+++ /dev/null
@@ -1,56 +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.
- *
- */
-
-/* Functions for manipulating trace contexts as defined in
- src/proto/census/trace.proto */
-#ifndef GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H
-#define GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H
-
-#include "src/core/ext/census/gen/trace_context.pb.h"
-
-/* Span option flags. */
-#define SPAN_OPTIONS_IS_SAMPLED 0x01
-
-/* Maximum number of bytes required to encode a TraceContext (31)
-1 byte for trace_id field
-1 byte for trace_id length
-1 byte for trace_id.hi field
-8 bytes for trace_id.hi (uint64_t)
-1 byte for trace_id.lo field
-8 bytes for trace_id.lo (uint64_t)
-1 byte for span_id field
-8 bytes for span_id (uint64_t)
-1 byte for is_sampled field
-1 byte for is_sampled (bool) */
-#define TRACE_MAX_CONTEXT_SIZE 31
-
-/* Encode a trace context (ctxt) into proto format to the buffer provided. The
-size of buffer must be at least TRACE_MAX_CONTEXT_SIZE. On success, returns the
-number of bytes successfully encoded into buffer. On failure, returns 0. */
-size_t encode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer,
- const size_t buf_size);
-
-/* Decode a proto-encoded TraceContext from the provided buffer into the
-TraceContext structure (ctxt). The function expects to be supplied the number
-of bytes to be read from buffer (nbytes). This function will also validate that
-the TraceContext has a span_id and a trace_id, and will return false if either
-of these do not exist. On success, returns true and false otherwise. */
-bool decode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer,
- const size_t nbytes);
-
-#endif /* GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H */
diff --git a/src/core/ext/census/trace_label.h b/src/core/ext/census/trace_label.h
deleted file mode 100644
index 97ce399eb5..0000000000
--- a/src/core/ext/census/trace_label.h
+++ /dev/null
@@ -1,46 +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.
- *
- */
-
-#ifndef GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
-#define GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
-
-#include "src/core/ext/census/trace_string.h"
-
-/* Trace label (key/value pair) stores a label name and the label value. The
- value can be one of trace_string/int64_t/bool. */
-typedef struct trace_label {
- trace_string key;
- enum label_type {
- /* Unknown value for debugging/error purposes */
- LABEL_UNKNOWN = 0,
- /* A string value */
- LABEL_STRING = 1,
- /* An integer value. */
- LABEL_INT = 2,
- /* A boolean value. */
- LABEL_BOOL = 3,
- } value_type;
-
- union value {
- trace_string label_str;
- int64_t label_int;
- bool label_bool;
- } value;
-} trace_label;
-
-#endif /* GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H */
diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h
deleted file mode 100644
index eecfcb7d01..0000000000
--- a/src/core/ext/census/trace_propagation.h
+++ /dev/null
@@ -1,48 +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.
- *
- */
-
-#ifndef GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
-#define GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
-
-#include "src/core/ext/census/tracing.h"
-
-/* Encoding and decoding functions for receiving and sending trace contexts
- over the wire. Only RPC libraries should be calling these
- functions. These functions return the number of bytes encoded/decoded
- (0 if a failure has occurred). buf_size indicates the size of the
- input/output buffer. trace_span_context is a struct that includes the
- trace ID, span ID, and a set of option flags (is_sampled, etc.). */
-
-/* Converts a span context to a binary byte buffer. */
-size_t trace_span_context_to_binary(const trace_span_context *ctxt,
- uint8_t *buf, size_t buf_size);
-
-/* Reads a binary byte buffer and populates a span context structure. */
-size_t binary_to_trace_span_context(const uint8_t *buf, size_t buf_size,
- trace_span_context *ctxt);
-
-/* Converts a span context to an http metadata compatible string. */
-size_t trace_span_context_to_http_format(const trace_span_context *ctxt,
- char *buf, size_t buf_size);
-
-/* Reads an http metadata compatible string and populates a span context
- structure. */
-size_t http_format_to_trace_span_context(const char *buf, size_t buf_size,
- trace_span_context *ctxt);
-
-#endif /* GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H */
diff --git a/src/core/ext/census/trace_status.h b/src/core/ext/census/trace_status.h
deleted file mode 100644
index dd83d3f729..0000000000
--- a/src/core/ext/census/trace_status.h
+++ /dev/null
@@ -1,30 +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.
- *
- */
-
-#ifndef GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
-#define GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
-
-#include "src/core/ext/census/trace_string.h"
-
-/* Stores a status code and status message for a trace. */
-typedef struct trace_status {
- int64_t errorCode;
- trace_string errorMessage;
-} trace_status;
-
-#endif /* GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H */
diff --git a/src/core/ext/census/trace_string.h b/src/core/ext/census/trace_string.h
deleted file mode 100644
index e4da3f590d..0000000000
--- a/src/core/ext/census/trace_string.h
+++ /dev/null
@@ -1,35 +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.
- *
- */
-
-#ifndef GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
-#define GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
-
-#include <grpc/slice.h>
-
-/* String struct for tracing messages. Since this is a C API, we do not have
- access to a string class. This is intended for use by higher level
- languages which wrap around the C API, as most of them have a string class.
- This will also be more efficient when copying, as we have an explicitly
- specified length. Also, grpc_slice has reference counting which allows for
- interning. */
-typedef struct trace_string {
- char *string;
- size_t length;
-} trace_string;
-
-#endif /* GRPC_CORE_EXT_CENSUS_TRACE_STRING_H */
diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c
deleted file mode 100644
index 823c681abf..0000000000
--- a/src/core/ext/census/tracing.c
+++ /dev/null
@@ -1,55 +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 "src/core/ext/census/tracing.h"
-
-#include <grpc/census.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include "src/core/ext/census/mlog.h"
-
-void trace_start_span(const trace_span_context *span_ctxt,
- const trace_string name, const start_span_options *opts,
- trace_span_context *new_span_ctxt,
- bool has_remote_parent) {
- // Noop implementation.
-}
-
-void trace_add_span_annotation(const trace_string description,
- const trace_label *labels, const size_t n_labels,
- trace_span_context *span_ctxt) {
- // Noop implementation.
-}
-
-void trace_add_span_network_event_annotation(const trace_string description,
- const trace_label *labels,
- const size_t n_labels,
- const gpr_timespec timestamp,
- bool sent, uint64_t id,
- trace_span_context *span_ctxt) {
- // Noop implementation.
-}
-
-void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
- trace_span_context *span_ctxt) {
- // Noop implementation.
-}
-
-void trace_end_span(const trace_status *status, trace_span_context *span_ctxt) {
- // Noop implementation.
-}
diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h
deleted file mode 100644
index 038c9e2790..0000000000
--- a/src/core/ext/census/tracing.h
+++ /dev/null
@@ -1,109 +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.
- *
- */
-
-#ifndef GRPC_CORE_EXT_CENSUS_TRACING_H
-#define GRPC_CORE_EXT_CENSUS_TRACING_H
-
-#include <grpc/support/time.h>
-#include <stdbool.h>
-#include "src/core/ext/census/trace_context.h"
-#include "src/core/ext/census/trace_label.h"
-#include "src/core/ext/census/trace_status.h"
-
-/* This is the low level tracing API that other languages will interface with.
- This is not intended to be accessed by the end-user, therefore it has been
- designed with performance in mind rather than ease of use. */
-
-/* The tracing level. */
-enum TraceLevel {
- /* Annotations on this context will be silently discarded. */
- NO_TRACING = 0,
- /* Annotations will not be saved to a persistent store. They will be
- available via local APIs only. This setting is not propagated to child
- spans. */
- TRANSIENT_TRACING = 1,
- /* Annotations are recorded for the entire distributed trace and they are
- saved to a persistent store. This setting is propagated to child spans. */
- PERSISTENT_TRACING = 2,
-};
-
-typedef struct trace_span_context {
- /* Trace span context stores Span ID, Trace ID, and option flags. */
- /* Trace ID is 128 bits split into 2 64-bit chunks (hi and lo). */
- uint64_t trace_id_hi;
- uint64_t trace_id_lo;
- /* Span ID is 64 bits. */
- uint64_t span_id;
- /* Span-options is 32-bit value which contains flag options. */
- uint32_t span_options;
-} trace_span_context;
-
-typedef struct start_span_options {
- /* If set, this will override the Span.local_start_time for the Span. */
- gpr_timespec local_start_timestamp;
-
- /* Linked spans can be used to identify spans that are linked to this span in
- a different trace. This can be used (for example) in batching operations,
- where a single batch handler processes multiple requests from different
- traces. If set, points to a list of Spans are linked to the created Span.*/
- trace_span_context *linked_spans;
- /* The number of linked spans. */
- size_t n_linked_spans;
-} start_span_options;
-
-/* Create a new child Span (or root if parent is NULL), with parent being the
- designated Span. The child span will have the provided name and starting
- span options (optional). The bool has_remote_parent marks whether the
- context refers to a remote parent span or not. */
-void trace_start_span(const trace_span_context *span_ctxt,
- const trace_string name, const start_span_options *opts,
- trace_span_context *new_span_ctxt,
- bool has_remote_parent);
-
-/* Add a new Annotation to the Span. Annotations consist of a description
- (trace_string) and a set of n labels (trace_label). This can be populated
- with arbitrary user data. */
-void trace_add_span_annotation(const trace_string description,
- const trace_label *labels, const size_t n_labels,
- trace_span_context *span_ctxt);
-
-/* Add a new NetworkEvent annotation to a Span. This function is only intended
- to be used by RPC systems (either client or server), not by higher level
- applications. The timestamp type will be system-defined, the sent argument
- designates whether this is a network send event (client request, server
- reply)or receive (server request, client reply). The id argument corresponds
- to Span.Annotation.NetworkEvent.id from the data model, and serves to uniquely
- identify each network message. */
-void trace_add_span_network_event(const trace_string description,
- const trace_label *labels,
- const size_t n_labels,
- const gpr_timespec timestamp, bool sent,
- uint64_t id, trace_span_context *span_ctxt);
-
-/* Add a set of labels to the Span. These will correspond to the field
-Span.labels in the data model. */
-void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
- trace_span_context *span_ctxt);
-
-/* Mark the end of Span Execution with the given status. Only the timing of the
-first EndSpan call for a given Span will be recorded, and implementations are
-free to ignore all further calls using the Span. EndSpanOptions can
-optionally be NULL. */
-void trace_end_span(const trace_status *status, trace_span_context *span_ctxt);
-
-#endif /* GRPC_CORE_EXT_CENSUS_TRACING_H */
diff --git a/src/core/ext/census/window_stats.c b/src/core/ext/census/window_stats.c
deleted file mode 100644
index 0058e4bf9c..0000000000
--- a/src/core/ext/census/window_stats.c
+++ /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/ext/census/window_stats.h"
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/time.h>
-#include <grpc/support/useful.h>
-#include <math.h>
-#include <stddef.h>
-#include <string.h>
-
-/* typedefs make typing long names easier. Use cws (for census_window_stats) */
-typedef census_window_stats_stat_info cws_stat_info;
-typedef struct census_window_stats_sum cws_sum;
-
-/* Each interval is composed of a number of buckets, which hold a count of
- entries and a single statistic */
-typedef struct census_window_stats_bucket {
- int64_t count;
- void *statistic;
-} cws_bucket;
-
-/* Each interval has a set of buckets, and the variables needed to keep
- track of their current state */
-typedef struct census_window_stats_interval_stats {
- /* The buckets. There will be 'granularity' + 1 of these. */
- cws_bucket *buckets;
- /* Index of the bucket containing the smallest time interval. */
- int bottom_bucket;
- /* The smallest time storable in the current window. */
- int64_t bottom;
- /* The largest time storable in the current window + 1ns */
- int64_t top;
- /* The width of each bucket in ns. */
- int64_t width;
-} cws_interval_stats;
-
-typedef struct census_window_stats {
- /* Number of intervals. */
- int nintervals;
- /* Number of buckets in each interval. 'granularity' + 1. */
- int nbuckets;
- /* Record of stat_info. */
- cws_stat_info stat_info;
- /* Stats for each interval. */
- cws_interval_stats *interval_stats;
- /* The time the newset stat was recorded. */
- int64_t newest_time;
-} window_stats;
-
-/* Calculate an actual bucket index from a logical index 'IDX'. Other
- parameters supply information on the interval struct and overall stats. */
-#define BUCKET_IDX(IS, IDX, WSTATS) \
- ((IS->bottom_bucket + (IDX)) % WSTATS->nbuckets)
-
-/* The maximum seconds value we can have in a valid timespec. More than this
- will result in overflow in timespec_to_ns(). This works out to ~292 years.
- TODO: consider using doubles instead of int64. */
-static int64_t max_seconds = (GPR_INT64_MAX - GPR_NS_PER_SEC) / GPR_NS_PER_SEC;
-
-static int64_t timespec_to_ns(const gpr_timespec ts) {
- if (ts.tv_sec > max_seconds) {
- return GPR_INT64_MAX - 1;
- }
- return ts.tv_sec * GPR_NS_PER_SEC + ts.tv_nsec;
-}
-
-static void cws_initialize_statistic(void *statistic,
- const cws_stat_info *stat_info) {
- if (stat_info->stat_initialize == NULL) {
- memset(statistic, 0, stat_info->stat_size);
- } else {
- stat_info->stat_initialize(statistic);
- }
-}
-
-/* Create and initialize a statistic */
-static void *cws_create_statistic(const cws_stat_info *stat_info) {
- void *stat = gpr_malloc(stat_info->stat_size);
- cws_initialize_statistic(stat, stat_info);
- return stat;
-}
-
-window_stats *census_window_stats_create(int nintervals,
- const gpr_timespec intervals[],
- int granularity,
- const cws_stat_info *stat_info) {
- window_stats *ret;
- int i;
- /* validate inputs */
- GPR_ASSERT(nintervals > 0 && granularity > 2 && intervals != NULL &&
- stat_info != NULL);
- for (i = 0; i < nintervals; i++) {
- int64_t ns = timespec_to_ns(intervals[i]);
- GPR_ASSERT(intervals[i].tv_sec >= 0 && intervals[i].tv_nsec >= 0 &&
- intervals[i].tv_nsec < GPR_NS_PER_SEC && ns >= 100 &&
- granularity * 10 <= ns);
- }
- /* Allocate and initialize relevant data structures */
- ret = (window_stats *)gpr_malloc(sizeof(window_stats));
- ret->nintervals = nintervals;
- ret->nbuckets = granularity + 1;
- ret->stat_info = *stat_info;
- ret->interval_stats =
- (cws_interval_stats *)gpr_malloc(nintervals * sizeof(cws_interval_stats));
- for (i = 0; i < nintervals; i++) {
- int64_t size_ns = timespec_to_ns(intervals[i]);
- cws_interval_stats *is = ret->interval_stats + i;
- cws_bucket *buckets = is->buckets =
- (cws_bucket *)gpr_malloc(ret->nbuckets * sizeof(cws_bucket));
- int b;
- for (b = 0; b < ret->nbuckets; b++) {
- buckets[b].statistic = cws_create_statistic(stat_info);
- buckets[b].count = 0;
- }
- is->bottom_bucket = 0;
- is->bottom = 0;
- is->width = size_ns / granularity;
- /* Check for possible overflow issues, and maximize interval size if the
- user requested something large enough. */
- if ((GPR_INT64_MAX - is->width) > size_ns) {
- is->top = size_ns + is->width;
- } else {
- is->top = GPR_INT64_MAX;
- is->width = GPR_INT64_MAX / (granularity + 1);
- }
- /* If size doesn't divide evenly, we can have a width slightly too small;
- better to have it slightly large. */
- if ((size_ns - (granularity + 1) * is->width) > 0) {
- is->width += 1;
- }
- }
- ret->newest_time = 0;
- return ret;
-}
-
-/* When we try adding a measurement above the current interval range, we
- need to "shift" the buckets sufficiently to cover the new range. */
-static void cws_shift_buckets(const window_stats *wstats,
- cws_interval_stats *is, int64_t when_ns) {
- int i;
- /* number of bucket time widths to "shift" */
- int shift;
- /* number of buckets to clear */
- int nclear;
- GPR_ASSERT(when_ns >= is->top);
- /* number of bucket time widths to "shift" */
- shift = ((when_ns - is->top) / is->width) + 1;
- /* number of buckets to clear - limited by actual number of buckets */
- nclear = GPR_MIN(shift, wstats->nbuckets);
- for (i = 0; i < nclear; i++) {
- int b = BUCKET_IDX(is, i, wstats);
- is->buckets[b].count = 0;
- cws_initialize_statistic(is->buckets[b].statistic, &wstats->stat_info);
- }
- /* adjust top/bottom times and current bottom bucket */
- is->bottom_bucket = BUCKET_IDX(is, shift, wstats);
- is->top += shift * is->width;
- is->bottom += shift * is->width;
-}
-
-void census_window_stats_add(window_stats *wstats, const gpr_timespec when,
- const void *stat_value) {
- int i;
- int64_t when_ns = timespec_to_ns(when);
- GPR_ASSERT(wstats->interval_stats != NULL);
- for (i = 0; i < wstats->nintervals; i++) {
- cws_interval_stats *is = wstats->interval_stats + i;
- cws_bucket *bucket;
- if (when_ns < is->bottom) { /* Below smallest time in interval: drop */
- continue;
- }
- if (when_ns >= is->top) { /* above limit: shift buckets */
- cws_shift_buckets(wstats, is, when_ns);
- }
- /* Add the stat. */
- GPR_ASSERT(is->bottom <= when_ns && when_ns < is->top);
- bucket = is->buckets +
- BUCKET_IDX(is, (when_ns - is->bottom) / is->width, wstats);
- bucket->count++;
- wstats->stat_info.stat_add(bucket->statistic, stat_value);
- }
- if (when_ns > wstats->newest_time) {
- wstats->newest_time = when_ns;
- }
-}
-
-/* Add a specific bucket contents to an accumulating total. */
-static void cws_add_bucket_to_sum(cws_sum *sum, const cws_bucket *bucket,
- const cws_stat_info *stat_info) {
- sum->count += bucket->count;
- stat_info->stat_add(sum->statistic, bucket->statistic);
-}
-
-/* Add a proportion to an accumulating sum. */
-static void cws_add_proportion_to_sum(double p, cws_sum *sum,
- const cws_bucket *bucket,
- const cws_stat_info *stat_info) {
- sum->count += p * bucket->count;
- stat_info->stat_add_proportion(p, sum->statistic, bucket->statistic);
-}
-
-void census_window_stats_get_sums(const window_stats *wstats,
- const gpr_timespec when, cws_sum sums[]) {
- int i;
- int64_t when_ns = timespec_to_ns(when);
- GPR_ASSERT(wstats->interval_stats != NULL);
- for (i = 0; i < wstats->nintervals; i++) {
- int when_bucket;
- int new_bucket;
- double last_proportion = 1.0;
- double bottom_proportion;
- cws_interval_stats *is = wstats->interval_stats + i;
- cws_sum *sum = sums + i;
- sum->count = 0;
- cws_initialize_statistic(sum->statistic, &wstats->stat_info);
- if (when_ns < is->bottom) {
- continue;
- }
- if (when_ns >= is->top) {
- cws_shift_buckets(wstats, is, when_ns);
- }
- /* Calculating the appropriate amount of which buckets to use can get
- complicated. Essentially there are two cases:
- 1) if the "top" bucket (new_bucket, where the newest additions to the
- stats recorded are entered) corresponds to 'when', then we need
- to take a proportion of it - (if when < newest_time) or the full
- thing. We also (possibly) need to take a corresponding
- proportion of the bottom bucket.
- 2) Other cases, we just take a straight proportion.
- */
- when_bucket = (when_ns - is->bottom) / is->width;
- new_bucket = (wstats->newest_time - is->bottom) / is->width;
- if (new_bucket == when_bucket) {
- int64_t bottom_bucket_time = is->bottom + when_bucket * is->width;
- if (when_ns < wstats->newest_time) {
- last_proportion = (double)(when_ns - bottom_bucket_time) /
- (double)(wstats->newest_time - bottom_bucket_time);
- bottom_proportion =
- (double)(is->width - (when_ns - bottom_bucket_time)) / is->width;
- } else {
- bottom_proportion =
- (double)(is->width - (wstats->newest_time - bottom_bucket_time)) /
- is->width;
- }
- } else {
- last_proportion =
- (double)(when_ns + 1 - is->bottom - when_bucket * is->width) /
- is->width;
- bottom_proportion = 1.0 - last_proportion;
- }
- cws_add_proportion_to_sum(last_proportion, sum,
- is->buckets + BUCKET_IDX(is, when_bucket, wstats),
- &wstats->stat_info);
- if (when_bucket != 0) { /* last bucket isn't also bottom bucket */
- int b;
- /* Add all of "bottom" bucket if we are looking at a subset of the
- full interval, or a proportion if we are adding full interval. */
- cws_add_proportion_to_sum(
- (when_bucket == wstats->nbuckets - 1 ? bottom_proportion : 1.0), sum,
- is->buckets + is->bottom_bucket, &wstats->stat_info);
- /* Add all the remaining buckets (everything but top and bottom). */
- for (b = 1; b < when_bucket; b++) {
- cws_add_bucket_to_sum(sum, is->buckets + BUCKET_IDX(is, b, wstats),
- &wstats->stat_info);
- }
- }
- }
-}
-
-void census_window_stats_destroy(window_stats *wstats) {
- int i;
- GPR_ASSERT(wstats->interval_stats != NULL);
- for (i = 0; i < wstats->nintervals; i++) {
- int b;
- for (b = 0; b < wstats->nbuckets; b++) {
- gpr_free(wstats->interval_stats[i].buckets[b].statistic);
- }
- gpr_free(wstats->interval_stats[i].buckets);
- }
- gpr_free(wstats->interval_stats);
- /* Ensure any use-after free triggers assert. */
- wstats->interval_stats = NULL;
- gpr_free(wstats);
-}
diff --git a/src/core/ext/census/window_stats.h b/src/core/ext/census/window_stats.h
deleted file mode 100644
index ebe3732008..0000000000
--- a/src/core/ext/census/window_stats.h
+++ /dev/null
@@ -1,158 +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_EXT_CENSUS_WINDOW_STATS_H
-#define GRPC_CORE_EXT_CENSUS_WINDOW_STATS_H
-
-#include <grpc/support/time.h>
-
-/* Keep rolling sums of a user-defined statistic (containing a number of
- measurements) over a a number of time intervals ("windows"). For example,
- you can use a window_stats object to answer questions such as
- "Approximately how many RPCs/s did I receive over the past minute, and
- approximately how many bytes did I send out over that period?".
-
- The type of data to record, and the time intervals to keep are specified
- when creating the object via a call to census_window_stats_create().
-
- A window's interval is divided into one or more "buckets"; the interval
- must be divisible by the number of buckets. Internally, these buckets
- control the granularity of window_stats' measurements. Increasing the
- number of buckets lets the object respond more quickly to changes in the
- overall rate of data added into the object, at the cost of additional
- memory usage.
-
- Here's some code which keeps one minute/hour measurements for two values
- (latency in seconds and bytes transferred), with each interval divided into
- 4 buckets.
-
- typedef struct my_stat {
- double latency;
- int bytes;
- } my_stat;
-
- void add_my_stat(void* base, const void* addme) {
- my_stat* b = (my_stat*)base;
- const my_stat* a = (const my_stat*)addme;
- b->latency += a->latency;
- b->bytes += a->bytes;
- }
-
- void add_proportion_my_stat(double p, void* base, const void* addme) {
- (my_stat*)result->latency += p * (const my_stat*)base->latency;
- (my_stat*)result->bytes += p * (const my_stat*)base->bytes;
- }
-
- #define kNumIntervals 2
- #define kMinInterval 0
- #define kHourInterval 1
- #define kNumBuckets 4
-
- const struct census_window_stats_stat_info kMyStatInfo
- = { sizeof(my_stat), NULL, add_my_stat, add_proportion_my_stat };
- gpr_timespec intervals[kNumIntervals] = {{60, 0}, {3600, 0}};
- my_stat stat;
- my_stat sums[kNumIntervals];
- census_window_stats_sums result[kNumIntervals];
- struct census_window_stats* stats
- = census_window_stats_create(kNumIntervals, intervals, kNumBuckets,
- &kMyStatInfo);
- // Record a new event, taking 15.3ms, transferring 1784 bytes.
- stat.latency = 0.153;
- stat.bytes = 1784;
- census_window_stats_add(stats, gpr_now(GPR_CLOCK_REALTIME), &stat);
- // Get sums and print them out
- result[kMinInterval].statistic = &sums[kMinInterval];
- result[kHourInterval].statistic = &sums[kHourInterval];
- census_window_stats_get_sums(stats, gpr_now(GPR_CLOCK_REALTIME), result);
- printf("%d events/min, average time %gs, average bytes %g\n",
- result[kMinInterval].count,
- (my_stat*)result[kMinInterval].statistic->latency /
- result[kMinInterval].count,
- (my_stat*)result[kMinInterval].statistic->bytes /
- result[kMinInterval].count
- );
- printf("%d events/hr, average time %gs, average bytes %g\n",
- result[kHourInterval].count,
- (my_stat*)result[kHourInterval].statistic->latency /
- result[kHourInterval].count,
- (my_stat*)result[kHourInterval].statistic->bytes /
- result[kHourInterval].count
- );
-*/
-
-/* Opaque structure for representing window_stats object */
-struct census_window_stats;
-
-/* Information provided by API user on the information they want to record */
-typedef struct census_window_stats_stat_info {
- /* Number of bytes in user-defined object. */
- size_t stat_size;
- /* Function to initialize a user-defined statistics object. If this is set
- * to NULL, then the object will be zero-initialized. */
- void (*stat_initialize)(void *stat);
- /* Function to add one user-defined statistics object ('addme') to 'base' */
- void (*stat_add)(void *base, const void *addme);
- /* As for previous function, but only add a proportion 'p'. This API will
- currently only use 'p' values in the range [0,1], but other values are
- possible in the future, and should be supported. */
- void (*stat_add_proportion)(double p, void *base, const void *addme);
-} census_window_stats_stat_info;
-
-/* Create a new window_stats object. 'nintervals' is the number of
- 'intervals', and must be >=1. 'granularity' is the number of buckets, with
- a larger number using more memory, but providing greater accuracy of
- results. 'granularity should be > 2. We also require that each interval be
- at least 10 * 'granularity' nanoseconds in size. 'stat_info' contains
- information about the statistic to be gathered. Intervals greater than ~192
- years will be treated as essentially infinite in size. This function will
- GPR_ASSERT() if the object cannot be created or any of the parameters have
- invalid values. This function is thread-safe. */
-struct census_window_stats *census_window_stats_create(
- int nintervals, const gpr_timespec intervals[], int granularity,
- const census_window_stats_stat_info *stat_info);
-
-/* Add a new measurement (in 'stat_value'), as of a given time ('when').
- This function is thread-compatible. */
-void census_window_stats_add(struct census_window_stats *wstats,
- const gpr_timespec when, const void *stat_value);
-
-/* Structure used to record a single intervals sum for a given statistic */
-typedef struct census_window_stats_sum {
- /* Total count of samples. Note that because some internal interpolation
- is performed, the count of samples returned for each interval may not be an
- integral value. */
- double count;
- /* Sum for statistic */
- void *statistic;
-} census_window_stats_sums;
-
-/* Retrieve a set of all values stored in a window_stats object 'wstats'. The
- number of 'sums' MUST be the same as the number 'nintervals' used in
- census_window_stats_create(). This function is thread-compatible. */
-void census_window_stats_get_sums(const struct census_window_stats *wstats,
- const gpr_timespec when,
- struct census_window_stats_sum sums[]);
-
-/* Destroy a window_stats object. Once this function has been called, the
- object will no longer be usable from any of the above functions (and
- calling them will most likely result in a NULL-pointer dereference or
- assertion failure). This function is thread-compatible. */
-void census_window_stats_destroy(struct census_window_stats *wstats);
-
-#endif /* GRPC_CORE_EXT_CENSUS_WINDOW_STATS_H */
diff --git a/src/core/ext/filters/client_channel/OWNERS b/src/core/ext/filters/client_channel/OWNERS
index 773bc73179..8f5e92808e 100644
--- a/src/core/ext/filters/client_channel/OWNERS
+++ b/src/core/ext/filters/client_channel/OWNERS
@@ -1,4 +1,4 @@
set noparent
@markdroth
@dgquintas
-@ctiller
+@a11r
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc
new file mode 100644
index 0000000000..906a72b662
--- /dev/null
+++ b/src/core/ext/filters/client_channel/backup_poller.cc
@@ -0,0 +1,168 @@
+/*
+ *
+ * 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/backup_poller.h"
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include "src/core/ext/filters/client_channel/client_channel.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/iomgr/pollset.h"
+#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/completion_queue.h"
+
+#define DEFAULT_POLL_INTERVAL_MS 5000
+
+namespace {
+struct backup_poller {
+ grpc_timer polling_timer;
+ grpc_closure run_poller_closure;
+ grpc_closure shutdown_closure;
+ gpr_mu* pollset_mu;
+ grpc_pollset* pollset; // guarded by pollset_mu
+ bool shutting_down; // guarded by pollset_mu
+ gpr_refcount refs;
+ gpr_refcount shutdown_refs;
+};
+} // namespace
+
+static gpr_once g_once = GPR_ONCE_INIT;
+static gpr_mu g_poller_mu;
+static backup_poller* g_poller = nullptr; // guarded by g_poller_mu
+// g_poll_interval_ms is set only once at the first time
+// grpc_client_channel_start_backup_polling() is called, after that it is
+// treated as const.
+static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS;
+
+static void init_globals() {
+ gpr_mu_init(&g_poller_mu);
+ char* env = gpr_getenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS");
+ if (env != nullptr) {
+ int poll_interval_ms = gpr_parse_nonnegative_int(env);
+ if (poll_interval_ms == -1) {
+ gpr_log(GPR_ERROR,
+ "Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %s, "
+ "default value %d will be used.",
+ env, g_poll_interval_ms);
+ } else {
+ g_poll_interval_ms = poll_interval_ms;
+ }
+ }
+ gpr_free(env);
+}
+
+static void backup_poller_shutdown_unref(backup_poller* p) {
+ if (gpr_unref(&p->shutdown_refs)) {
+ grpc_pollset_destroy(p->pollset);
+ gpr_free(p->pollset);
+ gpr_free(p);
+ }
+}
+
+static void done_poller(void* arg, grpc_error* error) {
+ backup_poller_shutdown_unref((backup_poller*)arg);
+}
+
+static void g_poller_unref() {
+ gpr_mu_lock(&g_poller_mu);
+ if (gpr_unref(&g_poller->refs)) {
+ backup_poller* p = g_poller;
+ g_poller = nullptr;
+ gpr_mu_unlock(&g_poller_mu);
+ gpr_mu_lock(p->pollset_mu);
+ p->shutting_down = true;
+ grpc_pollset_shutdown(
+ p->pollset, GRPC_CLOSURE_INIT(&p->shutdown_closure, done_poller, p,
+ grpc_schedule_on_exec_ctx));
+ gpr_mu_unlock(p->pollset_mu);
+ grpc_timer_cancel(&p->polling_timer);
+ } else {
+ gpr_mu_unlock(&g_poller_mu);
+ }
+}
+
+static void run_poller(void* arg, grpc_error* error) {
+ backup_poller* p = (backup_poller*)arg;
+ if (error != GRPC_ERROR_NONE) {
+ if (error != GRPC_ERROR_CANCELLED) {
+ GRPC_LOG_IF_ERROR("run_poller", GRPC_ERROR_REF(error));
+ }
+ backup_poller_shutdown_unref(p);
+ return;
+ }
+ gpr_mu_lock(p->pollset_mu);
+ if (p->shutting_down) {
+ gpr_mu_unlock(p->pollset_mu);
+ backup_poller_shutdown_unref(p);
+ return;
+ }
+ grpc_error* err =
+ grpc_pollset_work(p->pollset, nullptr, grpc_core::ExecCtx::Get()->Now());
+ gpr_mu_unlock(p->pollset_mu);
+ GRPC_LOG_IF_ERROR("Run client channel backup poller", err);
+ grpc_timer_init(&p->polling_timer,
+ grpc_core::ExecCtx::Get()->Now() + g_poll_interval_ms,
+ &p->run_poller_closure);
+}
+
+void grpc_client_channel_start_backup_polling(
+ grpc_pollset_set* interested_parties) {
+ gpr_once_init(&g_once, init_globals);
+ if (g_poll_interval_ms == 0) {
+ return;
+ }
+ gpr_mu_lock(&g_poller_mu);
+ if (g_poller == nullptr) {
+ g_poller = (backup_poller*)gpr_zalloc(sizeof(backup_poller));
+ g_poller->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ g_poller->shutting_down = false;
+ grpc_pollset_init(g_poller->pollset, &g_poller->pollset_mu);
+ gpr_ref_init(&g_poller->refs, 0);
+ // one for timer cancellation, one for pollset shutdown
+ gpr_ref_init(&g_poller->shutdown_refs, 2);
+ GRPC_CLOSURE_INIT(&g_poller->run_poller_closure, run_poller, g_poller,
+ grpc_schedule_on_exec_ctx);
+ grpc_timer_init(&g_poller->polling_timer,
+ grpc_core::ExecCtx::Get()->Now() + g_poll_interval_ms,
+ &g_poller->run_poller_closure);
+ }
+
+ gpr_ref(&g_poller->refs);
+ /* Get a reference to g_poller->pollset before releasing g_poller_mu to make
+ * TSAN happy. Otherwise, reading from g_poller (i.e g_poller->pollset) after
+ * releasing the lock and setting g_poller to NULL in g_poller_unref() is
+ * being flagged as a data-race by TSAN */
+ grpc_pollset* pollset = g_poller->pollset;
+ gpr_mu_unlock(&g_poller_mu);
+
+ grpc_pollset_set_add_pollset(interested_parties, pollset);
+}
+
+void grpc_client_channel_stop_backup_polling(
+ grpc_pollset_set* interested_parties) {
+ if (g_poll_interval_ms == 0) {
+ return;
+ }
+ grpc_pollset_set_del_pollset(interested_parties, g_poller->pollset);
+ g_poller_unref();
+}
diff --git a/src/core/ext/census/grpc_filter.h b/src/core/ext/filters/client_channel/backup_poller.h
index baa7bb931a..551e0331dc 100644
--- a/src/core/ext/census/grpc_filter.h
+++ b/src/core/ext/filters/client_channel/backup_poller.h
@@ -16,14 +16,19 @@
*
*/
-#ifndef GRPC_CORE_EXT_CENSUS_GRPC_FILTER_H
-#define GRPC_CORE_EXT_CENSUS_GRPC_FILTER_H
+#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H
+#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H
+#include <grpc/grpc.h>
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
-/* Census filters: provides tracing and stats collection functionalities. It
- needs to reside right below the surface filter in the channel stack. */
-extern const grpc_channel_filter grpc_client_census_filter;
-extern const grpc_channel_filter grpc_server_census_filter;
+/* Start polling \a interested_parties periodically in the timer thread */
+void grpc_client_channel_start_backup_polling(
+ grpc_pollset_set* interested_parties);
-#endif /* GRPC_CORE_EXT_CENSUS_GRPC_FILTER_H */
+/* Stop polling \a interested_parties */
+void grpc_client_channel_stop_backup_polling(
+ grpc_pollset_set* interested_parties);
+
+#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H */
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.cc
index 3844b98021..a827aa30ec 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.c
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -18,6 +18,8 @@
#include "src/core/lib/surface/channel.h"
+#include <inttypes.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -27,26 +29,26 @@
#include "src/core/lib/surface/completion_queue.h"
grpc_connectivity_state grpc_channel_check_connectivity_state(
- grpc_channel *channel, int try_to_connect) {
+ grpc_channel* channel, int try_to_connect) {
/* forward through to the underlying client channel */
- grpc_channel_element *client_channel_elem =
+ grpc_channel_element* client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_connectivity_state state;
GRPC_API_TRACE(
"grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
(channel, try_to_connect));
if (client_channel_elem->filter == &grpc_client_channel_filter) {
- state = grpc_client_channel_check_connectivity_state(
- &exec_ctx, client_channel_elem, try_to_connect);
- grpc_exec_ctx_finish(&exec_ctx);
+ state = grpc_client_channel_check_connectivity_state(client_channel_elem,
+ try_to_connect);
+
return state;
}
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
"not a client channel, but '%s'",
client_channel_elem->filter->name);
- grpc_exec_ctx_finish(&exec_ctx);
+
return GRPC_CHANNEL_SHUTDOWN;
}
@@ -56,7 +58,8 @@ typedef enum {
CALLING_BACK_AND_FINISHED,
} callback_phase;
-typedef struct {
+namespace {
+struct state_watcher {
gpr_mu mu;
callback_phase phase;
grpc_closure on_complete;
@@ -64,19 +67,19 @@ typedef struct {
grpc_closure watcher_timer_init;
grpc_timer alarm;
grpc_connectivity_state state;
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
grpc_cq_completion completion_storage;
- grpc_channel *channel;
- grpc_error *error;
- void *tag;
-} state_watcher;
-
-static void delete_state_watcher(grpc_exec_ctx *exec_ctx, state_watcher *w) {
- grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element(
+ grpc_channel* channel;
+ grpc_error* error;
+ void* tag;
+};
+} // namespace
+
+static void delete_state_watcher(state_watcher* w) {
+ grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
grpc_channel_get_channel_stack(w->channel));
if (client_channel_elem->filter == &grpc_client_channel_filter) {
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
- "watch_channel_connectivity");
+ GRPC_CHANNEL_INTERNAL_UNREF(w->channel, "watch_channel_connectivity");
} else {
abort();
}
@@ -84,10 +87,9 @@ static void delete_state_watcher(grpc_exec_ctx *exec_ctx, state_watcher *w) {
gpr_free(w);
}
-static void finished_completion(grpc_exec_ctx *exec_ctx, void *pw,
- grpc_cq_completion *ignored) {
+static void finished_completion(void* pw, grpc_cq_completion* ignored) {
bool should_delete = false;
- state_watcher *w = (state_watcher *)pw;
+ state_watcher* w = (state_watcher*)pw;
gpr_mu_lock(&w->mu);
switch (w->phase) {
case WAITING:
@@ -100,27 +102,27 @@ static void finished_completion(grpc_exec_ctx *exec_ctx, void *pw,
gpr_mu_unlock(&w->mu);
if (should_delete) {
- delete_state_watcher(exec_ctx, w);
+ delete_state_watcher(w);
}
}
-static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
- bool due_to_completion, grpc_error *error) {
+static void partly_done(state_watcher* w, bool due_to_completion,
+ grpc_error* error) {
if (due_to_completion) {
- grpc_timer_cancel(exec_ctx, &w->alarm);
+ grpc_timer_cancel(&w->alarm);
} else {
- grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element(
+ grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
grpc_channel_get_channel_stack(w->channel));
grpc_client_channel_watch_connectivity_state(
- exec_ctx, client_channel_elem,
- grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)), NULL,
- &w->on_complete, NULL);
+ client_channel_elem,
+ grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)),
+ nullptr, &w->on_complete, nullptr);
}
gpr_mu_lock(&w->mu);
if (due_to_completion) {
- if (GRPC_TRACER_ON(grpc_trace_operation_failures)) {
+ if (grpc_trace_operation_failures.enabled()) {
GRPC_LOG_IF_ERROR("watch_completion_error", GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
@@ -147,7 +149,7 @@ static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
w->error = error;
}
w->phase = CALLING_BACK_AND_FINISHED;
- grpc_cq_end_op(exec_ctx, w->cq, w->tag, w->error, finished_completion, w,
+ grpc_cq_end_op(w->cq, w->tag, w->error, finished_completion, w,
&w->completion_storage);
break;
case CALLING_BACK_AND_FINISHED:
@@ -159,51 +161,47 @@ static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
GRPC_ERROR_UNREF(error);
}
-static void watch_complete(grpc_exec_ctx *exec_ctx, void *pw,
- grpc_error *error) {
- partly_done(exec_ctx, (state_watcher *)pw, true, GRPC_ERROR_REF(error));
+static void watch_complete(void* pw, grpc_error* error) {
+ partly_done((state_watcher*)pw, true, GRPC_ERROR_REF(error));
}
-static void timeout_complete(grpc_exec_ctx *exec_ctx, void *pw,
- grpc_error *error) {
- partly_done(exec_ctx, (state_watcher *)pw, false, GRPC_ERROR_REF(error));
+static void timeout_complete(void* pw, grpc_error* error) {
+ partly_done((state_watcher*)pw, false, GRPC_ERROR_REF(error));
}
-int grpc_channel_num_external_connectivity_watchers(grpc_channel *channel) {
- grpc_channel_element *client_channel_elem =
+int grpc_channel_num_external_connectivity_watchers(grpc_channel* channel) {
+ grpc_channel_element* client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
return grpc_client_channel_num_external_connectivity_watchers(
client_channel_elem);
}
typedef struct watcher_timer_init_arg {
- state_watcher *w;
+ state_watcher* w;
gpr_timespec deadline;
} watcher_timer_init_arg;
-static void watcher_timer_init(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error_ignored) {
- watcher_timer_init_arg *wa = (watcher_timer_init_arg *)arg;
+static void watcher_timer_init(void* arg, grpc_error* error_ignored) {
+ watcher_timer_init_arg* wa = (watcher_timer_init_arg*)arg;
- grpc_timer_init(exec_ctx, &wa->w->alarm,
- gpr_convert_clock_type(wa->deadline, GPR_CLOCK_MONOTONIC),
- &wa->w->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&wa->w->alarm, grpc_timespec_to_millis_round_up(wa->deadline),
+ &wa->w->on_timeout);
gpr_free(wa);
}
-int grpc_channel_support_connectivity_watcher(grpc_channel *channel) {
- grpc_channel_element *client_channel_elem =
+int grpc_channel_support_connectivity_watcher(grpc_channel* channel) {
+ grpc_channel_element* client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
return client_channel_elem->filter != &grpc_client_channel_filter ? 0 : 1;
}
void grpc_channel_watch_connectivity_state(
- grpc_channel *channel, grpc_connectivity_state last_observed_state,
- gpr_timespec deadline, grpc_completion_queue *cq, void *tag) {
- grpc_channel_element *client_channel_elem =
+ grpc_channel* channel, grpc_connectivity_state last_observed_state,
+ gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
+ grpc_channel_element* client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- state_watcher *w = (state_watcher *)gpr_malloc(sizeof(*w));
+ grpc_core::ExecCtx exec_ctx;
+ state_watcher* w = (state_watcher*)gpr_malloc(sizeof(*w));
GRPC_API_TRACE(
"grpc_channel_watch_connectivity_state("
@@ -211,8 +209,9 @@ void grpc_channel_watch_connectivity_state(
"deadline=gpr_timespec { tv_sec: %" PRId64
", tv_nsec: %d, clock_type: %d }, "
"cq=%p, tag=%p)",
- 7, (channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
- (int)deadline.clock_type, cq, tag));
+ 7,
+ (channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
+ (int)deadline.clock_type, cq, tag));
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
@@ -226,10 +225,10 @@ void grpc_channel_watch_connectivity_state(
w->cq = cq;
w->tag = tag;
w->channel = channel;
- w->error = NULL;
+ w->error = nullptr;
- watcher_timer_init_arg *wa =
- (watcher_timer_init_arg *)gpr_malloc(sizeof(watcher_timer_init_arg));
+ watcher_timer_init_arg* wa =
+ (watcher_timer_init_arg*)gpr_malloc(sizeof(watcher_timer_init_arg));
wa->w = w;
wa->deadline = deadline;
GRPC_CLOSURE_INIT(&w->watcher_timer_init, watcher_timer_init, wa,
@@ -238,12 +237,10 @@ void grpc_channel_watch_connectivity_state(
if (client_channel_elem->filter == &grpc_client_channel_filter) {
GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity");
grpc_client_channel_watch_connectivity_state(
- &exec_ctx, client_channel_elem,
+ client_channel_elem,
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &w->state,
&w->on_complete, &w->watcher_timer_init);
} else {
abort();
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.cc
index 016199b1f4..a8a7a37be0 100644
--- a/src/core/ext/filters/client_channel/client_channel.c
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -16,8 +16,11 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include "src/core/ext/filters/client_channel/client_channel.h"
+#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -28,6 +31,7 @@
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
+#include "src/core/ext/filters/client_channel/backup_poller.h"
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
@@ -37,12 +41,12 @@
#include "src/core/ext/filters/deadline/deadline_filter.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/connected_channel.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/metadata.h"
@@ -52,8 +56,7 @@
/* Client channel implementation */
-grpc_tracer_flag grpc_client_channel_trace =
- GRPC_TRACER_INITIALIZER(false, "client_channel");
+grpc_core::TraceFlag grpc_client_channel_trace(false, "client_channel");
/*************************************************************************
* METHOD-CONFIG TABLE
@@ -68,28 +71,32 @@ typedef enum {
typedef struct {
gpr_refcount refs;
- gpr_timespec timeout;
+ grpc_millis timeout;
wait_for_ready_value wait_for_ready;
} method_parameters;
-static method_parameters *method_parameters_ref(
- method_parameters *method_params) {
+static method_parameters* method_parameters_ref(
+ method_parameters* method_params) {
gpr_ref(&method_params->refs);
return method_params;
}
-static void method_parameters_unref(method_parameters *method_params) {
+static void method_parameters_unref(method_parameters* method_params) {
if (gpr_unref(&method_params->refs)) {
gpr_free(method_params);
}
}
-static void method_parameters_free(grpc_exec_ctx *exec_ctx, void *value) {
- method_parameters_unref((method_parameters *)value);
+// Wrappers to pass to grpc_service_config_create_method_config_table().
+static void* method_parameters_ref_wrapper(void* value) {
+ return method_parameters_ref((method_parameters*)value);
+}
+static void method_parameters_unref_wrapper(void* value) {
+ method_parameters_unref((method_parameters*)value);
}
-static bool parse_wait_for_ready(grpc_json *field,
- wait_for_ready_value *wait_for_ready) {
+static bool parse_wait_for_ready(grpc_json* field,
+ wait_for_ready_value* wait_for_ready) {
if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) {
return false;
}
@@ -98,58 +105,52 @@ static bool parse_wait_for_ready(grpc_json *field,
return true;
}
-static bool parse_timeout(grpc_json *field, gpr_timespec *timeout) {
+static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
if (field->type != GRPC_JSON_STRING) return false;
size_t len = strlen(field->value);
if (field->value[len - 1] != 's') return false;
- char *buf = gpr_strdup(field->value);
+ char* buf = gpr_strdup(field->value);
buf[len - 1] = '\0'; // Remove trailing 's'.
- char *decimal_point = strchr(buf, '.');
- if (decimal_point != NULL) {
+ char* decimal_point = strchr(buf, '.');
+ int nanos = 0;
+ if (decimal_point != nullptr) {
*decimal_point = '\0';
- timeout->tv_nsec = gpr_parse_nonnegative_int(decimal_point + 1);
- if (timeout->tv_nsec == -1) {
+ nanos = gpr_parse_nonnegative_int(decimal_point + 1);
+ if (nanos == -1) {
+ gpr_free(buf);
+ return false;
+ }
+ int num_digits = (int)strlen(decimal_point + 1);
+ if (num_digits > 9) { // We don't accept greater precision than nanos.
gpr_free(buf);
return false;
}
- // There should always be exactly 3, 6, or 9 fractional digits.
- int multiplier = 1;
- switch (strlen(decimal_point + 1)) {
- case 9:
- break;
- case 6:
- multiplier *= 1000;
- break;
- case 3:
- multiplier *= 1000000;
- break;
- default: // Unsupported number of digits.
- gpr_free(buf);
- return false;
+ for (int i = 0; i < (9 - num_digits); ++i) {
+ nanos *= 10;
}
- timeout->tv_nsec *= multiplier;
}
- timeout->tv_sec = gpr_parse_nonnegative_int(buf);
+ int seconds = decimal_point == buf ? 0 : gpr_parse_nonnegative_int(buf);
gpr_free(buf);
- if (timeout->tv_sec == -1) return false;
+ if (seconds == -1) return false;
+ *timeout = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS;
return true;
}
-static void *method_parameters_create_from_json(const grpc_json *json) {
+static void* method_parameters_create_from_json(const grpc_json* json) {
wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET;
- gpr_timespec timeout = {0, 0, GPR_TIMESPAN};
- for (grpc_json *field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) continue;
+ grpc_millis timeout = 0;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) continue;
if (strcmp(field->key, "waitForReady") == 0) {
- if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate.
- if (!parse_wait_for_ready(field, &wait_for_ready)) return NULL;
+ if (wait_for_ready != WAIT_FOR_READY_UNSET) return nullptr; // Duplicate.
+ if (!parse_wait_for_ready(field, &wait_for_ready)) return nullptr;
} else if (strcmp(field->key, "timeout") == 0) {
- if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate.
- if (!parse_timeout(field, &timeout)) return NULL;
+ if (timeout > 0) return nullptr; // Duplicate.
+ if (!parse_timeout(field, &timeout)) return nullptr;
}
}
- method_parameters *value =
- (method_parameters *)gpr_malloc(sizeof(method_parameters));
+ method_parameters* value =
+ (method_parameters*)gpr_malloc(sizeof(method_parameters));
gpr_ref_init(&value->refs, 1);
value->timeout = timeout;
value->wait_for_ready = wait_for_ready;
@@ -164,24 +165,24 @@ struct external_connectivity_watcher;
typedef struct client_channel_channel_data {
/** resolver for this channel */
- grpc_resolver *resolver;
+ grpc_resolver* resolver;
/** have we started resolving this channel */
bool started_resolving;
/** is deadline checking enabled? */
bool deadline_checking_enabled;
/** client channel factory */
- grpc_client_channel_factory *client_channel_factory;
+ grpc_client_channel_factory* client_channel_factory;
/** combiner protecting all variables below in this data structure */
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
/** currently active load balancer */
- grpc_lb_policy *lb_policy;
+ grpc_lb_policy* lb_policy;
/** retry throttle data */
- grpc_server_retry_throttle_data *retry_throttle_data;
+ grpc_server_retry_throttle_data* retry_throttle_data;
/** maps method names to method_parameters structs */
- grpc_slice_hash_table *method_params_table;
+ grpc_slice_hash_table* method_params_table;
/** incoming resolver result - set by resolver.next() */
- grpc_channel_args *resolver_result;
+ grpc_channel_args* resolver_result;
/** a list of closures that are all waiting for resolver result to come in */
grpc_closure_list waiting_for_resolver_result_closures;
/** resolver callback */
@@ -191,137 +192,134 @@ typedef struct client_channel_channel_data {
/** when an lb_policy arrives, should we try to exit idle */
bool exit_idle_when_lb_policy_arrives;
/** owning stack */
- grpc_channel_stack *owning_stack;
+ grpc_channel_stack* owning_stack;
/** interested parties (owned) */
- grpc_pollset_set *interested_parties;
+ grpc_pollset_set* interested_parties;
/* external_connectivity_watcher_list head is guarded by its own mutex, since
* counts need to be grabbed immediately without polling on a cq */
gpr_mu external_connectivity_watcher_list_mu;
- struct external_connectivity_watcher *external_connectivity_watcher_list_head;
+ struct external_connectivity_watcher* external_connectivity_watcher_list_head;
/* the following properties are guarded by a mutex since API's require them
to be instantaneously available */
gpr_mu info_mu;
- char *info_lb_policy_name;
+ char* info_lb_policy_name;
/** service config in JSON form */
- char *info_service_config_json;
+ char* info_service_config_json;
} channel_data;
+typedef struct {
+ channel_data* chand;
+ /** used as an identifier, don't dereference it because the LB policy may be
+ * non-existing when the callback is run */
+ grpc_lb_policy* lb_policy;
+ grpc_closure closure;
+} reresolution_request_args;
+
/** We create one watcher for each new lb_policy that is returned from a
resolver, to watch for state changes from the lb_policy. When a state
change is seen, we update the channel, and create a new watcher. */
typedef struct {
- channel_data *chand;
+ channel_data* chand;
grpc_closure on_changed;
grpc_connectivity_state state;
- grpc_lb_policy *lb_policy;
+ grpc_lb_policy* lb_policy;
} lb_policy_connectivity_watcher;
-static void watch_lb_policy_locked(grpc_exec_ctx *exec_ctx, channel_data *chand,
- grpc_lb_policy *lb_policy,
+static void watch_lb_policy_locked(channel_data* chand,
+ grpc_lb_policy* lb_policy,
grpc_connectivity_state current_state);
-static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx,
- channel_data *chand,
+static void set_channel_connectivity_state_locked(channel_data* chand,
grpc_connectivity_state state,
- grpc_error *error,
- const char *reason) {
+ grpc_error* error,
+ const char* reason) {
/* TODO: Improve failure handling:
* - Make it possible for policies to return GRPC_CHANNEL_TRANSIENT_FAILURE.
* - Hand over pending picks from old policies during the switch that happens
* when resolver provides an update. */
- if (chand->lb_policy != NULL) {
+ if (chand->lb_policy != nullptr) {
if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
/* cancel picks with wait_for_ready=false */
grpc_lb_policy_cancel_picks_locked(
- exec_ctx, chand->lb_policy,
+ chand->lb_policy,
/* mask= */ GRPC_INITIAL_METADATA_WAIT_FOR_READY,
/* check= */ 0, GRPC_ERROR_REF(error));
} else if (state == GRPC_CHANNEL_SHUTDOWN) {
/* cancel all picks */
- grpc_lb_policy_cancel_picks_locked(exec_ctx, chand->lb_policy,
+ grpc_lb_policy_cancel_picks_locked(chand->lb_policy,
/* mask= */ 0, /* check= */ 0,
GRPC_ERROR_REF(error));
}
}
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: setting connectivity state to %s", chand,
grpc_connectivity_state_name(state));
}
- grpc_connectivity_state_set(exec_ctx, &chand->state_tracker, state, error,
- reason);
+ grpc_connectivity_state_set(&chand->state_tracker, state, error, reason);
}
-static void on_lb_policy_state_changed_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- lb_policy_connectivity_watcher *w = (lb_policy_connectivity_watcher *)arg;
- grpc_connectivity_state publish_state = w->state;
+static void on_lb_policy_state_changed_locked(void* arg, grpc_error* error) {
+ lb_policy_connectivity_watcher* w = (lb_policy_connectivity_watcher*)arg;
/* check if the notification is for the latest policy */
if (w->lb_policy == w->chand->lb_policy) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: lb_policy=%p state changed to %s", w->chand,
w->lb_policy, grpc_connectivity_state_name(w->state));
}
- if (publish_state == GRPC_CHANNEL_SHUTDOWN && w->chand->resolver != NULL) {
- publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
- grpc_resolver_channel_saw_error_locked(exec_ctx, w->chand->resolver);
- GRPC_LB_POLICY_UNREF(exec_ctx, w->chand->lb_policy, "channel");
- w->chand->lb_policy = NULL;
- }
- set_channel_connectivity_state_locked(exec_ctx, w->chand, publish_state,
+ set_channel_connectivity_state_locked(w->chand, w->state,
GRPC_ERROR_REF(error), "lb_changed");
if (w->state != GRPC_CHANNEL_SHUTDOWN) {
- watch_lb_policy_locked(exec_ctx, w->chand, w->lb_policy, w->state);
+ watch_lb_policy_locked(w->chand, w->lb_policy, w->state);
}
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack, "watch_lb_policy");
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack, "watch_lb_policy");
gpr_free(w);
}
-static void watch_lb_policy_locked(grpc_exec_ctx *exec_ctx, channel_data *chand,
- grpc_lb_policy *lb_policy,
+static void watch_lb_policy_locked(channel_data* chand,
+ grpc_lb_policy* lb_policy,
grpc_connectivity_state current_state) {
- lb_policy_connectivity_watcher *w =
- (lb_policy_connectivity_watcher *)gpr_malloc(sizeof(*w));
+ lb_policy_connectivity_watcher* w =
+ (lb_policy_connectivity_watcher*)gpr_malloc(sizeof(*w));
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "watch_lb_policy");
w->chand = chand;
GRPC_CLOSURE_INIT(&w->on_changed, on_lb_policy_state_changed_locked, w,
grpc_combiner_scheduler(chand->combiner));
w->state = current_state;
w->lb_policy = lb_policy;
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, lb_policy, &w->state,
+ grpc_lb_policy_notify_on_state_change_locked(lb_policy, &w->state,
&w->on_changed);
}
-static void start_resolving_locked(grpc_exec_ctx *exec_ctx,
- channel_data *chand) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void start_resolving_locked(channel_data* chand) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand);
}
GPR_ASSERT(!chand->started_resolving);
chand->started_resolving = true;
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
- grpc_resolver_next_locked(exec_ctx, chand->resolver, &chand->resolver_result,
+ grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
&chand->on_resolver_result_changed);
}
typedef struct {
- char *server_name;
- grpc_server_retry_throttle_data *retry_throttle_data;
+ char* server_name;
+ grpc_server_retry_throttle_data* retry_throttle_data;
} service_config_parsing_state;
-static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
- service_config_parsing_state *parsing_state =
- (service_config_parsing_state *)arg;
+static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
+ service_config_parsing_state* parsing_state =
+ (service_config_parsing_state*)arg;
if (strcmp(field->key, "retryThrottling") == 0) {
- if (parsing_state->retry_throttle_data != NULL) return; // Duplicate.
+ if (parsing_state->retry_throttle_data != nullptr) return; // Duplicate.
if (field->type != GRPC_JSON_OBJECT) return;
int max_milli_tokens = 0;
int milli_token_ratio = 0;
- for (grpc_json *sub_field = field->child; sub_field != NULL;
+ for (grpc_json* sub_field = field->child; sub_field != nullptr;
sub_field = sub_field->next) {
- if (sub_field->key == NULL) return;
+ if (sub_field->key == nullptr) return;
if (strcmp(sub_field->key, "maxTokens") == 0) {
if (max_milli_tokens != 0) return; // Duplicate.
if (sub_field->type != GRPC_JSON_NUMBER) return;
@@ -335,8 +333,8 @@ static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
size_t whole_len = strlen(sub_field->value);
uint32_t multiplier = 1;
uint32_t decimal_value = 0;
- const char *decimal_point = strchr(sub_field->value, '.');
- if (decimal_point != NULL) {
+ const char* decimal_point = strchr(sub_field->value, '.');
+ if (decimal_point != nullptr) {
whole_len = (size_t)(decimal_point - sub_field->value);
multiplier = 1000;
size_t decimal_len = strlen(decimal_point + 1);
@@ -366,119 +364,149 @@ static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
}
}
-static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- channel_data *chand = (channel_data *)arg;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void request_reresolution_locked(void* arg, grpc_error* error) {
+ reresolution_request_args* args = (reresolution_request_args*)arg;
+ channel_data* chand = args->chand;
+ // If this invocation is for a stale LB policy, treat it as an LB shutdown
+ // signal.
+ if (args->lb_policy != chand->lb_policy || error != GRPC_ERROR_NONE ||
+ chand->resolver == nullptr) {
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "re-resolution");
+ gpr_free(args);
+ return;
+ }
+ 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);
+ // Give back the closure to the LB policy.
+ grpc_lb_policy_set_reresolve_closure_locked(chand->lb_policy, &args->closure);
+}
+
+static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
+ channel_data* chand = (channel_data*)arg;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: got resolver result: error=%s", chand,
grpc_error_string(error));
}
// Extract the following fields from the resolver result, if non-NULL.
bool lb_policy_updated = false;
- char *lb_policy_name_dup = NULL;
+ char* lb_policy_name_dup = nullptr;
bool lb_policy_name_changed = false;
- grpc_lb_policy *new_lb_policy = NULL;
- char *service_config_json = NULL;
- grpc_server_retry_throttle_data *retry_throttle_data = NULL;
- grpc_slice_hash_table *method_params_table = NULL;
- if (chand->resolver_result != NULL) {
- // Find LB policy name.
- const char *lb_policy_name = NULL;
- const grpc_arg *channel_arg =
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
- if (channel_arg != NULL) {
- GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
- lb_policy_name = channel_arg->value.string;
- }
- // Special case: If at least one balancer address is present, we use
- // the grpclb policy, regardless of what the resolver actually specified.
- channel_arg =
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
- if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) {
- grpc_lb_addresses *addresses =
- (grpc_lb_addresses *)channel_arg->value.pointer.p;
- bool found_balancer_address = false;
- for (size_t i = 0; i < addresses->num_addresses; ++i) {
- if (addresses->addresses[i].is_balancer) {
- found_balancer_address = true;
- break;
+ grpc_lb_policy* new_lb_policy = nullptr;
+ char* service_config_json = nullptr;
+ grpc_server_retry_throttle_data* retry_throttle_data = nullptr;
+ grpc_slice_hash_table* method_params_table = nullptr;
+ if (chand->resolver_result != nullptr) {
+ if (chand->resolver != nullptr) {
+ // Find LB policy name.
+ const char* lb_policy_name = nullptr;
+ const grpc_arg* channel_arg = grpc_channel_args_find(
+ chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
+ if (channel_arg != nullptr) {
+ GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
+ lb_policy_name = channel_arg->value.string;
+ }
+ // Special case: If at least one balancer address is present, we use
+ // the grpclb policy, regardless of what the resolver actually specified.
+ channel_arg =
+ grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
+ if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
+ grpc_lb_addresses* addresses =
+ (grpc_lb_addresses*)channel_arg->value.pointer.p;
+ bool found_balancer_address = false;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (addresses->addresses[i].is_balancer) {
+ found_balancer_address = true;
+ break;
+ }
+ }
+ if (found_balancer_address) {
+ if (lb_policy_name != nullptr &&
+ strcmp(lb_policy_name, "grpclb") != 0) {
+ gpr_log(GPR_INFO,
+ "resolver requested LB policy %s but provided at least one "
+ "balancer address -- forcing use of grpclb LB policy",
+ lb_policy_name);
+ }
+ lb_policy_name = "grpclb";
}
}
- if (found_balancer_address) {
- if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) {
- gpr_log(GPR_INFO,
- "resolver requested LB policy %s but provided at least one "
- "balancer address -- forcing use of grpclb LB policy",
+ // Use pick_first if nothing was specified and we didn't select grpclb
+ // above.
+ if (lb_policy_name == nullptr) lb_policy_name = "pick_first";
+ grpc_lb_policy_args lb_policy_args;
+ lb_policy_args.args = chand->resolver_result;
+ lb_policy_args.client_channel_factory = chand->client_channel_factory;
+ lb_policy_args.combiner = chand->combiner;
+ // Check to see if we're already using the right LB policy.
+ // Note: It's safe to use chand->info_lb_policy_name here without
+ // taking a lock on chand->info_mu, because this function is the
+ // only thing that modifies its value, and it can only be invoked
+ // once at any given time.
+ lb_policy_name_changed =
+ chand->info_lb_policy_name == nullptr ||
+ gpr_stricmp(chand->info_lb_policy_name, lb_policy_name) != 0;
+ if (chand->lb_policy != nullptr && !lb_policy_name_changed) {
+ // Continue using the same LB policy. Update with new addresses.
+ lb_policy_updated = true;
+ grpc_lb_policy_update_locked(chand->lb_policy, &lb_policy_args);
+ } else {
+ // Instantiate new LB policy.
+ new_lb_policy = grpc_lb_policy_create(lb_policy_name, &lb_policy_args);
+ if (new_lb_policy == nullptr) {
+ gpr_log(GPR_ERROR, "could not create LB policy \"%s\"",
lb_policy_name);
+ } else {
+ reresolution_request_args* args =
+ (reresolution_request_args*)gpr_zalloc(sizeof(*args));
+ args->chand = chand;
+ args->lb_policy = new_lb_policy;
+ GRPC_CLOSURE_INIT(&args->closure, request_reresolution_locked, args,
+ grpc_combiner_scheduler(chand->combiner));
+ GRPC_CHANNEL_STACK_REF(chand->owning_stack, "re-resolution");
+ grpc_lb_policy_set_reresolve_closure_locked(new_lb_policy,
+ &args->closure);
}
- lb_policy_name = "grpclb";
}
- }
- // Use pick_first if nothing was specified and we didn't select grpclb
- // above.
- if (lb_policy_name == NULL) lb_policy_name = "pick_first";
- grpc_lb_policy_args lb_policy_args;
- lb_policy_args.args = chand->resolver_result;
- lb_policy_args.client_channel_factory = chand->client_channel_factory;
- lb_policy_args.combiner = chand->combiner;
- // Check to see if we're already using the right LB policy.
- // Note: It's safe to use chand->info_lb_policy_name here without
- // taking a lock on chand->info_mu, because this function is the
- // only thing that modifies its value, and it can only be invoked
- // once at any given time.
- lb_policy_name_changed =
- chand->info_lb_policy_name == NULL ||
- strcmp(chand->info_lb_policy_name, lb_policy_name) != 0;
- if (chand->lb_policy != NULL && !lb_policy_name_changed) {
- // Continue using the same LB policy. Update with new addresses.
- lb_policy_updated = true;
- grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args);
- } else {
- // Instantiate new LB policy.
- new_lb_policy =
- grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args);
- if (new_lb_policy == NULL) {
- gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
- }
- }
- // Find service config.
- channel_arg =
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVICE_CONFIG);
- if (channel_arg != NULL) {
- GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
- service_config_json = gpr_strdup(channel_arg->value.string);
- grpc_service_config *service_config =
- grpc_service_config_create(service_config_json);
- if (service_config != NULL) {
- channel_arg =
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVER_URI);
- GPR_ASSERT(channel_arg != NULL);
+ // Find service config.
+ channel_arg = grpc_channel_args_find(chand->resolver_result,
+ GRPC_ARG_SERVICE_CONFIG);
+ if (channel_arg != nullptr) {
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
- grpc_uri *uri =
- grpc_uri_parse(exec_ctx, channel_arg->value.string, true);
- GPR_ASSERT(uri->path[0] != '\0');
- service_config_parsing_state parsing_state;
- memset(&parsing_state, 0, sizeof(parsing_state));
- parsing_state.server_name =
- uri->path[0] == '/' ? uri->path + 1 : uri->path;
- grpc_service_config_parse_global_params(
- service_config, parse_retry_throttle_params, &parsing_state);
- grpc_uri_destroy(uri);
- retry_throttle_data = parsing_state.retry_throttle_data;
- method_params_table = grpc_service_config_create_method_config_table(
- exec_ctx, service_config, method_parameters_create_from_json,
- method_parameters_free);
- grpc_service_config_destroy(service_config);
+ service_config_json = gpr_strdup(channel_arg->value.string);
+ grpc_service_config* service_config =
+ grpc_service_config_create(service_config_json);
+ if (service_config != nullptr) {
+ channel_arg = grpc_channel_args_find(chand->resolver_result,
+ GRPC_ARG_SERVER_URI);
+ GPR_ASSERT(channel_arg != nullptr);
+ GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
+ grpc_uri* uri = grpc_uri_parse(channel_arg->value.string, true);
+ GPR_ASSERT(uri->path[0] != '\0');
+ service_config_parsing_state parsing_state;
+ memset(&parsing_state, 0, sizeof(parsing_state));
+ parsing_state.server_name =
+ uri->path[0] == '/' ? uri->path + 1 : uri->path;
+ grpc_service_config_parse_global_params(
+ service_config, parse_retry_throttle_params, &parsing_state);
+ grpc_uri_destroy(uri);
+ retry_throttle_data = parsing_state.retry_throttle_data;
+ method_params_table = grpc_service_config_create_method_config_table(
+ service_config, method_parameters_create_from_json,
+ method_parameters_ref_wrapper, method_parameters_unref_wrapper);
+ grpc_service_config_destroy(service_config);
+ }
}
+ // Before we clean up, save a copy of lb_policy_name, since it might
+ // be pointing to data inside chand->resolver_result.
+ // The copy will be saved in chand->lb_policy_name below.
+ lb_policy_name_dup = gpr_strdup(lb_policy_name);
}
- // Before we clean up, save a copy of lb_policy_name, since it might
- // be pointing to data inside chand->resolver_result.
- // The copy will be saved in chand->lb_policy_name below.
- lb_policy_name_dup = gpr_strdup(lb_policy_name);
- grpc_channel_args_destroy(exec_ctx, chand->resolver_result);
- chand->resolver_result = NULL;
- }
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ grpc_channel_args_destroy(chand->resolver_result);
+ chand->resolver_result = nullptr;
+ }
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p: resolver result: lb_policy_name=\"%s\"%s, "
"service_config=\"%s\"",
@@ -491,204 +519,197 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
//
// First, swap out the data used by cc_get_channel_info().
gpr_mu_lock(&chand->info_mu);
- if (lb_policy_name_dup != NULL) {
+ if (lb_policy_name_dup != nullptr) {
gpr_free(chand->info_lb_policy_name);
chand->info_lb_policy_name = lb_policy_name_dup;
}
- if (service_config_json != NULL) {
+ if (service_config_json != nullptr) {
gpr_free(chand->info_service_config_json);
chand->info_service_config_json = service_config_json;
}
gpr_mu_unlock(&chand->info_mu);
// Swap out the retry throttle data.
- if (chand->retry_throttle_data != NULL) {
+ if (chand->retry_throttle_data != nullptr) {
grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
}
chand->retry_throttle_data = retry_throttle_data;
// Swap out the method params table.
- if (chand->method_params_table != NULL) {
- grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
+ if (chand->method_params_table != nullptr) {
+ grpc_slice_hash_table_unref(chand->method_params_table);
}
chand->method_params_table = method_params_table;
// If we have a new LB policy or are shutting down (in which case
- // new_lb_policy will be NULL), swap out the LB policy, unreffing the
- // old one and removing its fds from chand->interested_parties.
- // Note that we do NOT do this if either (a) we updated the existing
- // LB policy above or (b) we failed to create the new LB policy (in
- // which case we want to continue using the most recent one we had).
- if (new_lb_policy != NULL || error != GRPC_ERROR_NONE ||
- chand->resolver == NULL) {
- if (chand->lb_policy != NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ // new_lb_policy will be NULL), swap out the LB policy, unreffing the old one
+ // and removing its fds from chand->interested_parties. Note that we do NOT do
+ // this if either (a) we updated the existing LB policy above or (b) we failed
+ // to create the new LB policy (in which case we want to continue using the
+ // most recent one we had).
+ if (new_lb_policy != nullptr || error != GRPC_ERROR_NONE ||
+ chand->resolver == nullptr) {
+ if (chand->lb_policy != nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand,
chand->lb_policy);
}
- grpc_pollset_set_del_pollset_set(exec_ctx,
- chand->lb_policy->interested_parties,
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
chand->interested_parties);
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
+ grpc_lb_policy_shutdown_locked(chand->lb_policy, new_lb_policy);
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
}
chand->lb_policy = new_lb_policy;
}
// Now that we've swapped out the relevant fields of chand, check for
// error or shutdown.
- if (error != GRPC_ERROR_NONE || chand->resolver == NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (error != GRPC_ERROR_NONE || chand->resolver == nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: shutting down", chand);
}
- if (chand->resolver != NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (chand->resolver != nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand);
}
- grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
- GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
- chand->resolver = NULL;
+ grpc_resolver_shutdown_locked(chand->resolver);
+ GRPC_RESOLVER_UNREF(chand->resolver, "channel");
+ chand->resolver = nullptr;
}
set_channel_connectivity_state_locked(
- exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
+ chand, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Got resolver result after disconnection", &error, 1),
"resolver_gone");
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "resolver");
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "resolver");
grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Channel disconnected", &error, 1));
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
- &chand->waiting_for_resolver_result_closures);
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
} else { // Not shutting down.
grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
- grpc_error *state_error =
+ grpc_error* state_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy");
- if (new_lb_policy != NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (new_lb_policy != nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand);
}
GRPC_ERROR_UNREF(state_error);
- state = grpc_lb_policy_check_connectivity_locked(exec_ctx, new_lb_policy,
- &state_error);
- grpc_pollset_set_add_pollset_set(exec_ctx,
- new_lb_policy->interested_parties,
+ state =
+ grpc_lb_policy_check_connectivity_locked(new_lb_policy, &state_error);
+ grpc_pollset_set_add_pollset_set(new_lb_policy->interested_parties,
chand->interested_parties);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
- &chand->waiting_for_resolver_result_closures);
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
if (chand->exit_idle_when_lb_policy_arrives) {
- grpc_lb_policy_exit_idle_locked(exec_ctx, new_lb_policy);
+ grpc_lb_policy_exit_idle_locked(new_lb_policy);
chand->exit_idle_when_lb_policy_arrives = false;
}
- watch_lb_policy_locked(exec_ctx, chand, new_lb_policy, state);
+ watch_lb_policy_locked(chand, new_lb_policy, state);
}
if (!lb_policy_updated) {
- set_channel_connectivity_state_locked(exec_ctx, chand, state,
- GRPC_ERROR_REF(state_error),
- "new_lb+resolver");
+ set_channel_connectivity_state_locked(
+ chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver");
}
- grpc_resolver_next_locked(exec_ctx, chand->resolver,
- &chand->resolver_result,
+ grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
&chand->on_resolver_result_changed);
GRPC_ERROR_UNREF(state_error);
}
}
-static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error_ignored) {
- grpc_transport_op *op = (grpc_transport_op *)arg;
- grpc_channel_element *elem =
- (grpc_channel_element *)op->handler_private.extra_arg;
- channel_data *chand = (channel_data *)elem->channel_data;
+static void start_transport_op_locked(void* arg, grpc_error* error_ignored) {
+ grpc_transport_op* op = (grpc_transport_op*)arg;
+ grpc_channel_element* elem =
+ (grpc_channel_element*)op->handler_private.extra_arg;
+ channel_data* chand = (channel_data*)elem->channel_data;
- if (op->on_connectivity_state_change != NULL) {
+ if (op->on_connectivity_state_change != nullptr) {
grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &chand->state_tracker, op->connectivity_state,
+ &chand->state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
- op->on_connectivity_state_change = NULL;
- op->connectivity_state = NULL;
+ op->on_connectivity_state_change = nullptr;
+ op->connectivity_state = nullptr;
}
- if (op->send_ping != NULL) {
- if (chand->lb_policy == NULL) {
+ if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
+ if (chand->lb_policy == nullptr) {
GRPC_CLOSURE_SCHED(
- exec_ctx, op->send_ping,
+ op->send_ping.on_initiate,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
+ GRPC_CLOSURE_SCHED(
+ op->send_ping.on_ack,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
} else {
- grpc_lb_policy_ping_one_locked(exec_ctx, chand->lb_policy, op->send_ping);
- op->bind_pollset = NULL;
+ grpc_lb_policy_ping_one_locked(
+ chand->lb_policy, op->send_ping.on_initiate, op->send_ping.on_ack);
+ op->bind_pollset = nullptr;
}
- op->send_ping = NULL;
+ op->send_ping.on_initiate = nullptr;
+ op->send_ping.on_ack = nullptr;
}
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
- if (chand->resolver != NULL) {
+ if (chand->resolver != nullptr) {
set_channel_connectivity_state_locked(
- exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
+ chand, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
- grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
- GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
- chand->resolver = NULL;
+ grpc_resolver_shutdown_locked(chand->resolver);
+ GRPC_RESOLVER_UNREF(chand->resolver, "channel");
+ chand->resolver = nullptr;
if (!chand->started_resolving) {
grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
GRPC_ERROR_REF(op->disconnect_with_error));
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
- &chand->waiting_for_resolver_result_closures);
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
}
- if (chand->lb_policy != NULL) {
- grpc_pollset_set_del_pollset_set(exec_ctx,
- chand->lb_policy->interested_parties,
+ if (chand->lb_policy != nullptr) {
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
chand->interested_parties);
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
- chand->lb_policy = NULL;
+ grpc_lb_policy_shutdown_locked(chand->lb_policy, nullptr);
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
+ chand->lb_policy = nullptr;
}
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "start_transport_op");
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "start_transport_op");
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
-static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_transport_op *op) {
- channel_data *chand = (channel_data *)elem->channel_data;
+static void cc_start_transport_op(grpc_channel_element* elem,
+ grpc_transport_op* op) {
+ channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(op->set_accept_stream == false);
- if (op->bind_pollset != NULL) {
- grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties,
- op->bind_pollset);
+ if (op->bind_pollset != nullptr) {
+ grpc_pollset_set_add_pollset(chand->interested_parties, op->bind_pollset);
}
op->handler_private.extra_arg = elem;
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "start_transport_op");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&op->handler_private.closure, start_transport_op_locked,
op, grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
-static void cc_get_channel_info(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- const grpc_channel_info *info) {
- channel_data *chand = (channel_data *)elem->channel_data;
+static void cc_get_channel_info(grpc_channel_element* elem,
+ const grpc_channel_info* info) {
+ channel_data* chand = (channel_data*)elem->channel_data;
gpr_mu_lock(&chand->info_mu);
- if (info->lb_policy_name != NULL) {
- *info->lb_policy_name = chand->info_lb_policy_name == NULL
- ? NULL
+ if (info->lb_policy_name != nullptr) {
+ *info->lb_policy_name = chand->info_lb_policy_name == nullptr
+ ? nullptr
: gpr_strdup(chand->info_lb_policy_name);
}
- if (info->service_config_json != NULL) {
+ if (info->service_config_json != nullptr) {
*info->service_config_json =
- chand->info_service_config_json == NULL
- ? NULL
+ chand->info_service_config_json == nullptr
+ ? nullptr
: gpr_strdup(chand->info_service_config_json);
}
gpr_mu_unlock(&chand->info_mu);
}
/* Constructor for channel_data */
-static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- channel_data *chand = (channel_data *)elem->channel_data;
+static grpc_error* cc_init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(args->is_last);
GPR_ASSERT(elem->filter == &grpc_client_channel_filter);
// Initialize data members.
@@ -697,7 +718,7 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
gpr_mu_init(&chand->external_connectivity_watcher_list_mu);
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
- chand->external_connectivity_watcher_list_head = NULL;
+ chand->external_connectivity_watcher_list_head = nullptr;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
chand->owning_stack = args->channel_stack;
@@ -707,10 +728,11 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
chand->interested_parties = grpc_pollset_set_create();
grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
"client_channel");
+ grpc_client_channel_start_backup_polling(chand->interested_parties);
// Record client channel factory.
- const grpc_arg *arg = grpc_channel_args_find(args->channel_args,
+ const grpc_arg* arg = grpc_channel_args_find(args->channel_args,
GRPC_ARG_CLIENT_CHANNEL_FACTORY);
- if (arg == NULL) {
+ if (arg == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Missing client channel factory in args for client channel filter");
}
@@ -719,12 +741,12 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
"client channel factory arg must be a pointer");
}
grpc_client_channel_factory_ref(
- (grpc_client_channel_factory *)arg->value.pointer.p);
+ (grpc_client_channel_factory*)arg->value.pointer.p);
chand->client_channel_factory =
- (grpc_client_channel_factory *)arg->value.pointer.p;
+ (grpc_client_channel_factory*)arg->value.pointer.p;
// Get server name to resolve, using proxy mapper if needed.
arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
- if (arg == NULL) {
+ if (arg == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Missing server uri in args for client channel filter");
}
@@ -732,18 +754,18 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"server uri arg must be a string");
}
- char *proxy_name = NULL;
- grpc_channel_args *new_args = NULL;
- grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
+ char* proxy_name = nullptr;
+ grpc_channel_args* new_args = nullptr;
+ grpc_proxy_mappers_map_name(arg->value.string, args->channel_args,
&proxy_name, &new_args);
// Instantiate resolver.
chand->resolver = grpc_resolver_create(
- exec_ctx, proxy_name != NULL ? proxy_name : arg->value.string,
- new_args != NULL ? new_args : args->channel_args,
+ proxy_name != nullptr ? proxy_name : arg->value.string,
+ new_args != nullptr ? new_args : args->channel_args,
chand->interested_parties, chand->combiner);
- if (proxy_name != NULL) gpr_free(proxy_name);
- if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
- if (chand->resolver == NULL) {
+ if (proxy_name != nullptr) gpr_free(proxy_name);
+ if (new_args != nullptr) grpc_channel_args_destroy(new_args);
+ if (chand->resolver == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
}
chand->deadline_checking_enabled =
@@ -751,43 +773,42 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static void shutdown_resolver_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_resolver *resolver = (grpc_resolver *)arg;
- grpc_resolver_shutdown_locked(exec_ctx, resolver);
- GRPC_RESOLVER_UNREF(exec_ctx, resolver, "channel");
+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");
}
/* Destructor for channel_data */
-static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- if (chand->resolver != NULL) {
+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(
- exec_ctx, GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
- grpc_combiner_scheduler(chand->combiner)),
+ GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
+ grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
- if (chand->client_channel_factory != NULL) {
- grpc_client_channel_factory_unref(exec_ctx, chand->client_channel_factory);
+ if (chand->client_channel_factory != nullptr) {
+ grpc_client_channel_factory_unref(chand->client_channel_factory);
}
- if (chand->lb_policy != NULL) {
- grpc_pollset_set_del_pollset_set(exec_ctx,
- chand->lb_policy->interested_parties,
+ if (chand->lb_policy != nullptr) {
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
chand->interested_parties);
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
+ grpc_lb_policy_shutdown_locked(chand->lb_policy, nullptr);
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
}
gpr_free(chand->info_lb_policy_name);
gpr_free(chand->info_service_config_json);
- if (chand->retry_throttle_data != NULL) {
+ if (chand->retry_throttle_data != nullptr) {
grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
}
- if (chand->method_params_table != NULL) {
- grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
+ if (chand->method_params_table != nullptr) {
+ grpc_slice_hash_table_unref(chand->method_params_table);
}
- grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker);
- grpc_pollset_set_destroy(exec_ctx, chand->interested_parties);
- GRPC_COMBINER_UNREF(exec_ctx, chand->combiner, "client_channel");
+ grpc_client_channel_stop_backup_polling(chand->interested_parties);
+ grpc_connectivity_state_destroy(&chand->state_tracker);
+ grpc_pollset_set_destroy(chand->interested_parties);
+ GRPC_COMBINER_UNREF(chand->combiner, "client_channel");
gpr_mu_destroy(&chand->info_mu);
gpr_mu_destroy(&chand->external_connectivity_watcher_list_mu);
}
@@ -823,48 +844,44 @@ typedef struct client_channel_call_data {
grpc_slice path; // Request path.
gpr_timespec call_start_time;
- gpr_timespec deadline;
- gpr_arena *arena;
- grpc_call_stack *owning_call;
- grpc_call_combiner *call_combiner;
+ grpc_millis deadline;
+ gpr_arena* arena;
+ grpc_call_stack* owning_call;
+ grpc_call_combiner* call_combiner;
- grpc_server_retry_throttle_data *retry_throttle_data;
- method_parameters *method_params;
+ grpc_server_retry_throttle_data* retry_throttle_data;
+ method_parameters* method_params;
- grpc_subchannel_call *subchannel_call;
- grpc_error *error;
+ grpc_subchannel_call* subchannel_call;
+ grpc_error* error;
- grpc_lb_policy *lb_policy; // Holds ref while LB pick is pending.
+ grpc_lb_policy_pick_state pick;
grpc_closure lb_pick_closure;
grpc_closure lb_pick_cancel_closure;
- grpc_connected_subchannel *connected_subchannel;
- grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
- grpc_polling_entity *pollent;
+ grpc_polling_entity* pollent;
- grpc_transport_stream_op_batch *waiting_for_pick_batches[MAX_WAITING_BATCHES];
+ grpc_transport_stream_op_batch* waiting_for_pick_batches[MAX_WAITING_BATCHES];
size_t waiting_for_pick_batches_count;
grpc_closure handle_pending_batch_in_call_combiner[MAX_WAITING_BATCHES];
- grpc_transport_stream_op_batch *initial_metadata_batch;
-
- grpc_linked_mdelem lb_token_mdelem;
+ grpc_transport_stream_op_batch* initial_metadata_batch;
grpc_closure on_complete;
- grpc_closure *original_on_complete;
+ grpc_closure* original_on_complete;
} call_data;
-grpc_subchannel_call *grpc_client_channel_get_subchannel_call(
- grpc_call_element *elem) {
- call_data *calld = (call_data *)elem->call_data;
+grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
+ grpc_call_element* elem) {
+ call_data* calld = (call_data*)elem->call_data;
return calld->subchannel_call;
}
// This is called via the call combiner, so access to calld is synchronized.
static void waiting_for_pick_batches_add(
- call_data *calld, grpc_transport_stream_op_batch *batch) {
+ call_data* calld, grpc_transport_stream_op_batch* batch) {
if (batch->send_initial_metadata) {
- GPR_ASSERT(calld->initial_metadata_batch == NULL);
+ GPR_ASSERT(calld->initial_metadata_batch == nullptr);
calld->initial_metadata_batch = batch;
} else {
GPR_ASSERT(calld->waiting_for_pick_batches_count < MAX_WAITING_BATCHES);
@@ -874,26 +891,23 @@ static void waiting_for_pick_batches_add(
}
// This is called via the call combiner, so access to calld is synchronized.
-static void fail_pending_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- call_data *calld = (call_data *)arg;
+static void fail_pending_batch_in_call_combiner(void* arg, grpc_error* error) {
+ call_data* calld = (call_data*)arg;
if (calld->waiting_for_pick_batches_count > 0) {
--calld->waiting_for_pick_batches_count;
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx,
calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count],
GRPC_ERROR_REF(error), calld->call_combiner);
}
}
// This is called via the call combiner, so access to calld is synchronized.
-static void waiting_for_pick_batches_fail(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_error *error) {
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void waiting_for_pick_batches_fail(grpc_call_element* elem,
+ grpc_error* error) {
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
- "chand=%p calld=%p: failing %" PRIdPTR " pending batches: %s",
+ "chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s",
elem->channel_data, calld, calld->waiting_for_pick_batches_count,
grpc_error_string(error));
}
@@ -901,42 +915,40 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx *exec_ctx,
GRPC_CLOSURE_INIT(&calld->handle_pending_batch_in_call_combiner[i],
fail_pending_batch_in_call_combiner, calld,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
- &calld->handle_pending_batch_in_call_combiner[i],
- GRPC_ERROR_REF(error),
- "waiting_for_pick_batches_fail");
+ GRPC_CALL_COMBINER_START(
+ calld->call_combiner, &calld->handle_pending_batch_in_call_combiner[i],
+ GRPC_ERROR_REF(error), "waiting_for_pick_batches_fail");
}
- if (calld->initial_metadata_batch != NULL) {
+ if (calld->initial_metadata_batch != nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->initial_metadata_batch, GRPC_ERROR_REF(error),
+ calld->initial_metadata_batch, GRPC_ERROR_REF(error),
calld->call_combiner);
} else {
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
"waiting_for_pick_batches_fail");
}
GRPC_ERROR_UNREF(error);
}
// This is called via the call combiner, so access to calld is synchronized.
-static void run_pending_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *ignored) {
- call_data *calld = (call_data *)arg;
+static void run_pending_batch_in_call_combiner(void* arg, grpc_error* ignored) {
+ call_data* calld = (call_data*)arg;
if (calld->waiting_for_pick_batches_count > 0) {
--calld->waiting_for_pick_batches_count;
grpc_subchannel_call_process_op(
- exec_ctx, calld->subchannel_call,
+ calld->subchannel_call,
calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count]);
}
}
// This is called via the call combiner, so access to calld is synchronized.
-static void waiting_for_pick_batches_resume(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
- gpr_log(GPR_DEBUG, "chand=%p calld=%p: sending %" PRIdPTR
- " pending batches to subchannel_call=%p",
+static void waiting_for_pick_batches_resume(grpc_call_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "chand=%p calld=%p: sending %" PRIuPTR
+ " pending batches to subchannel_call=%p",
chand, calld, calld->waiting_for_pick_batches_count,
calld->subchannel_call);
}
@@ -944,86 +956,82 @@ static void waiting_for_pick_batches_resume(grpc_exec_ctx *exec_ctx,
GRPC_CLOSURE_INIT(&calld->handle_pending_batch_in_call_combiner[i],
run_pending_batch_in_call_combiner, calld,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
- &calld->handle_pending_batch_in_call_combiner[i],
- GRPC_ERROR_NONE,
- "waiting_for_pick_batches_resume");
+ GRPC_CALL_COMBINER_START(
+ calld->call_combiner, &calld->handle_pending_batch_in_call_combiner[i],
+ GRPC_ERROR_NONE, "waiting_for_pick_batches_resume");
}
- GPR_ASSERT(calld->initial_metadata_batch != NULL);
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call,
+ GPR_ASSERT(calld->initial_metadata_batch != nullptr);
+ grpc_subchannel_call_process_op(calld->subchannel_call,
calld->initial_metadata_batch);
}
// Applies service config to the call. Must be invoked once we know
// that the resolver has returned results to the channel.
-static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void apply_service_config_to_call_locked(grpc_call_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: applying service config to call",
chand, calld);
}
- if (chand->retry_throttle_data != NULL) {
+ if (chand->retry_throttle_data != nullptr) {
calld->retry_throttle_data =
grpc_server_retry_throttle_data_ref(chand->retry_throttle_data);
}
- if (chand->method_params_table != NULL) {
- calld->method_params = (method_parameters *)grpc_method_config_table_get(
- exec_ctx, chand->method_params_table, calld->path);
- if (calld->method_params != NULL) {
+ if (chand->method_params_table != nullptr) {
+ calld->method_params = (method_parameters*)grpc_method_config_table_get(
+ chand->method_params_table, calld->path);
+ if (calld->method_params != nullptr) {
method_parameters_ref(calld->method_params);
// If the deadline from the service config is shorter than the one
// from the client API, reset the deadline timer.
if (chand->deadline_checking_enabled &&
- gpr_time_cmp(calld->method_params->timeout,
- gpr_time_0(GPR_TIMESPAN)) != 0) {
- const gpr_timespec per_method_deadline =
- gpr_time_add(calld->call_start_time, calld->method_params->timeout);
- if (gpr_time_cmp(per_method_deadline, calld->deadline) < 0) {
+ calld->method_params->timeout != 0) {
+ const grpc_millis per_method_deadline =
+ grpc_timespec_to_millis_round_up(calld->call_start_time) +
+ calld->method_params->timeout;
+ if (per_method_deadline < calld->deadline) {
calld->deadline = per_method_deadline;
- grpc_deadline_state_reset(exec_ctx, elem, calld->deadline);
+ grpc_deadline_state_reset(elem, calld->deadline);
}
}
}
}
}
-static void create_subchannel_call_locked(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_error *error) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- const grpc_connected_subchannel_call_args call_args = {
- .pollent = calld->pollent,
- .path = calld->path,
- .start_time = calld->call_start_time,
- .deadline = calld->deadline,
- .arena = calld->arena,
- .context = calld->subchannel_call_context,
- .call_combiner = calld->call_combiner};
- grpc_error *new_error = grpc_connected_subchannel_create_call(
- exec_ctx, calld->connected_subchannel, &call_args,
- &calld->subchannel_call);
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void create_subchannel_call_locked(grpc_call_element* elem,
+ grpc_error* error) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ const grpc_core::ConnectedSubchannel::CallArgs call_args = {
+ calld->pollent, // pollent
+ calld->path, // path
+ calld->call_start_time, // start_time
+ calld->deadline, // deadline
+ calld->arena, // arena
+ calld->pick.subchannel_call_context, // context
+ calld->call_combiner // call_combiner
+ };
+ grpc_error* new_error = calld->pick.connected_subchannel->CreateCall(
+ call_args, &calld->subchannel_call);
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
chand, calld, calld->subchannel_call, grpc_error_string(new_error));
}
if (new_error != GRPC_ERROR_NONE) {
new_error = grpc_error_add_child(new_error, error);
- waiting_for_pick_batches_fail(exec_ctx, elem, new_error);
+ waiting_for_pick_batches_fail(elem, new_error);
} else {
- waiting_for_pick_batches_resume(exec_ctx, elem);
+ waiting_for_pick_batches_resume(elem);
}
GRPC_ERROR_UNREF(error);
}
// Invoked when a pick is completed, on both success or failure.
-static void pick_done_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_error *error) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
- if (calld->connected_subchannel == NULL) {
+static void pick_done_locked(grpc_call_element* elem, grpc_error* error) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ if (calld->pick.connected_subchannel == nullptr) {
// Failed to create subchannel.
GRPC_ERROR_UNREF(calld->error);
calld->error = error == GRPC_ERROR_NONE
@@ -1031,15 +1039,15 @@ static void pick_done_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
"Call dropped by load balancing policy")
: GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to create subchannel", &error, 1);
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: failed to create subchannel: error=%s", chand,
calld, grpc_error_string(calld->error));
}
- waiting_for_pick_batches_fail(exec_ctx, elem, GRPC_ERROR_REF(calld->error));
+ waiting_for_pick_batches_fail(elem, GRPC_ERROR_REF(calld->error));
} else {
/* Create call on subchannel. */
- create_subchannel_call_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
+ create_subchannel_call_locked(elem, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
@@ -1048,63 +1056,58 @@ static void pick_done_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
// either (a) the pick was deferred pending a resolver result or (b) the
// pick was done asynchronously. Removes the call's polling entity from
// chand->interested_parties before invoking pick_done_locked().
-static void async_pick_done_locked(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem, grpc_error *error) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent,
+static void async_pick_done_locked(grpc_call_element* elem, grpc_error* error) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_polling_entity_del_from_pollset_set(calld->pollent,
chand->interested_parties);
- pick_done_locked(exec_ctx, elem, error);
+ pick_done_locked(elem, error);
}
// Note: This runs under the client_channel combiner, but will NOT be
// holding the call combiner.
-static void pick_callback_cancel_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (calld->lb_policy != NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void pick_callback_cancel_locked(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ // Note: chand->lb_policy may have changed since we started our pick,
+ // in which case we will be cancelling the pick on a policy other than
+ // the one we started it on. However, this will just be a no-op.
+ if (error != GRPC_ERROR_NONE && chand->lb_policy != nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p",
- chand, calld, calld->lb_policy);
+ chand, calld, chand->lb_policy);
}
- grpc_lb_policy_cancel_pick_locked(exec_ctx, calld->lb_policy,
- &calld->connected_subchannel,
+ grpc_lb_policy_cancel_pick_locked(chand->lb_policy, &calld->pick,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_callback_cancel");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "pick_callback_cancel");
}
// Callback invoked by grpc_lb_policy_pick_locked() for async picks.
// Unrefs the LB policy and invokes async_pick_done_locked().
-static void pick_callback_done_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void pick_callback_done_locked(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously",
chand, calld);
}
- GPR_ASSERT(calld->lb_policy != NULL);
- GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
- calld->lb_policy = NULL;
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
+ async_pick_done_locked(elem, GRPC_ERROR_REF(error));
}
// Takes a ref to chand->lb_policy and calls grpc_lb_policy_pick_locked().
// If the pick was completed synchronously, unrefs the LB policy and
// returns true.
-static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static bool pick_callback_start_locked(grpc_call_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p",
chand, calld, chand->lb_policy);
}
- apply_service_config_to_call_locked(exec_ctx, elem);
+ apply_service_config_to_call_locked(elem);
// If the application explicitly set wait_for_ready, use that.
// Otherwise, if the service config specified a value for this
// method, use that.
@@ -1115,7 +1118,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
initial_metadata_flags &
GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
const bool wait_for_ready_set_from_service_config =
- calld->method_params != NULL &&
+ calld->method_params != nullptr &&
calld->method_params->wait_for_ready != WAIT_FOR_READY_UNSET;
if (!wait_for_ready_set_from_api && wait_for_ready_set_from_service_config) {
if (calld->method_params->wait_for_ready == WAIT_FOR_READY_TRUE) {
@@ -1124,30 +1127,25 @@ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
initial_metadata_flags &= ~GRPC_INITIAL_METADATA_WAIT_FOR_READY;
}
}
- const grpc_lb_policy_pick_args inputs = {
+ calld->pick.initial_metadata =
calld->initial_metadata_batch->payload->send_initial_metadata
- .send_initial_metadata,
- initial_metadata_flags, &calld->lb_token_mdelem};
- // Keep a ref to the LB policy in calld while the pick is pending.
- GRPC_LB_POLICY_REF(chand->lb_policy, "pick_subchannel");
- calld->lb_policy = chand->lb_policy;
+ .send_initial_metadata;
+ calld->pick.initial_metadata_flags = initial_metadata_flags;
GRPC_CLOSURE_INIT(&calld->lb_pick_closure, pick_callback_done_locked, elem,
grpc_combiner_scheduler(chand->combiner));
- const bool pick_done = grpc_lb_policy_pick_locked(
- exec_ctx, chand->lb_policy, &inputs, &calld->connected_subchannel,
- calld->subchannel_call_context, NULL, &calld->lb_pick_closure);
+ calld->pick.on_complete = &calld->lb_pick_closure;
+ const bool pick_done =
+ grpc_lb_policy_pick_locked(chand->lb_policy, &calld->pick);
if (pick_done) {
/* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed synchronously",
chand, calld);
}
- GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
- calld->lb_policy = NULL;
} else {
GRPC_CALL_STACK_REF(calld->owning_call, "pick_callback_cancel");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->lb_pick_cancel_closure,
pick_callback_cancel_locked, elem,
grpc_combiner_scheduler(chand->combiner)));
@@ -1156,7 +1154,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
}
typedef struct {
- grpc_call_element *elem;
+ grpc_call_element* elem;
bool finished;
grpc_closure closure;
grpc_closure cancel_closure;
@@ -1164,11 +1162,9 @@ typedef struct {
// Note: This runs under the client_channel combiner, but will NOT be
// holding the call combiner.
-static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_error *error) {
- pick_after_resolver_result_args *args =
- (pick_after_resolver_result_args *)arg;
+static void pick_after_resolver_result_cancel_locked(void* arg,
+ grpc_error* error) {
+ pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
if (args->finished) {
gpr_free(args);
return;
@@ -1181,10 +1177,10 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
// is called, it will be a no-op. We also immediately invoke
// async_pick_done_locked() to propagate the error back to the caller.
args->finished = true;
- grpc_call_element *elem = args->elem;
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ grpc_call_element* elem = args->elem;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: cancelling pick waiting for resolver result",
chand, calld);
@@ -1194,111 +1190,132 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
// it's safe to call async_pick_done_locked() here -- we are
// essentially calling it here instead of calling it in
// pick_after_resolver_result_done_locked().
- async_pick_done_locked(exec_ctx, elem,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick cancelled", &error, 1));
+ async_pick_done_locked(elem, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick cancelled", &error, 1));
}
-static void pick_after_resolver_result_done_locked(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_error *error) {
- pick_after_resolver_result_args *args =
- (pick_after_resolver_result_args *)arg;
+static void pick_after_resolver_result_start_locked(grpc_call_element* elem);
+
+static void pick_after_resolver_result_done_locked(void* arg,
+ grpc_error* error) {
+ pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
if (args->finished) {
/* cancelled, do nothing */
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "call cancelled before resolver result");
}
gpr_free(args);
return;
}
args->finished = true;
- grpc_call_element *elem = args->elem;
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
+ grpc_call_element* elem = args->elem;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver failed to return data",
chand, calld);
}
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
- } else {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ async_pick_done_locked(elem, GRPC_ERROR_REF(error));
+ } else if (chand->lb_policy != nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick",
chand, calld);
}
- if (pick_callback_start_locked(exec_ctx, elem)) {
+ if (pick_callback_start_locked(elem)) {
// Even if the LB policy returns a result synchronously, we have
// already added our polling entity to chand->interested_parties
// in order to wait for the resolver result, so we need to
// remove it here. Therefore, we call async_pick_done_locked()
// instead of pick_done_locked().
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
+ async_pick_done_locked(elem, GRPC_ERROR_NONE);
+ }
+ }
+ // TODO(roth): It should be impossible for chand->lb_policy to be NULL
+ // here, so the rest of this code should never actually be executed.
+ // However, we have reports of a crash on iOS that triggers this case,
+ // so we are temporarily adding this to restore branches that were
+ // removed in https://github.com/grpc/grpc/pull/12297. Need to figure
+ // out what is actually causing this to occur and then figure out the
+ // right way to deal with it.
+ else if (chand->resolver != nullptr) {
+ // No LB policy, so try again.
+ if (grpc_client_channel_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "chand=%p calld=%p: resolver returned but no LB policy, "
+ "trying again",
+ chand, calld);
}
+ pick_after_resolver_result_start_locked(elem);
+ } else {
+ if (grpc_client_channel_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver disconnected", chand,
+ calld);
+ }
+ async_pick_done_locked(
+ elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
}
}
-static void pick_after_resolver_result_start_locked(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+static void pick_after_resolver_result_start_locked(grpc_call_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: deferring pick pending resolver result", chand,
calld);
}
- pick_after_resolver_result_args *args =
- (pick_after_resolver_result_args *)gpr_zalloc(sizeof(*args));
+ pick_after_resolver_result_args* args =
+ (pick_after_resolver_result_args*)gpr_zalloc(sizeof(*args));
args->elem = elem;
GRPC_CLOSURE_INIT(&args->closure, pick_after_resolver_result_done_locked,
args, grpc_combiner_scheduler(chand->combiner));
grpc_closure_list_append(&chand->waiting_for_resolver_result_closures,
&args->closure, GRPC_ERROR_NONE);
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&args->cancel_closure,
pick_after_resolver_result_cancel_locked, args,
grpc_combiner_scheduler(chand->combiner)));
}
-static void start_pick_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *ignored) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
- GPR_ASSERT(calld->connected_subchannel == NULL);
- if (chand->lb_policy != NULL) {
+static void start_pick_locked(void* arg, grpc_error* ignored) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ GPR_ASSERT(calld->pick.connected_subchannel == nullptr);
+ if (chand->lb_policy != nullptr) {
// We already have an LB policy, so ask it for a pick.
- if (pick_callback_start_locked(exec_ctx, elem)) {
+ if (pick_callback_start_locked(elem)) {
// Pick completed synchronously.
- pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
+ pick_done_locked(elem, GRPC_ERROR_NONE);
return;
}
} else {
// We do not yet have an LB policy, so wait for a resolver result.
- if (chand->resolver == NULL) {
- pick_done_locked(exec_ctx, elem,
+ if (chand->resolver == nullptr) {
+ pick_done_locked(elem,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
return;
}
if (!chand->started_resolving) {
- start_resolving_locked(exec_ctx, chand);
+ start_resolving_locked(chand);
}
- pick_after_resolver_result_start_locked(exec_ctx, elem);
+ pick_after_resolver_result_start_locked(elem);
}
// We need to wait for either a resolver result or for an async result
// from the LB policy. Add the polling entity from call_data to the
// channel_data's interested_parties, so that the I/O of the LB policy
// and resolver can be done under it. The polling entity will be
// removed in async_pick_done_locked().
- grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent,
+ grpc_polling_entity_add_to_pollset_set(calld->pollent,
chand->interested_parties);
}
-static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
- if (calld->retry_throttle_data != NULL) {
+static void on_complete(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
+ if (calld->retry_throttle_data != nullptr) {
if (error == GRPC_ERROR_NONE) {
grpc_server_retry_throttle_data_record_success(
calld->retry_throttle_data);
@@ -1311,28 +1328,25 @@ static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
calld->retry_throttle_data);
}
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_on_complete,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(calld->original_on_complete, GRPC_ERROR_REF(error));
}
static void cc_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
if (chand->deadline_checking_enabled) {
- grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
- batch);
+ grpc_deadline_state_client_start_transport_stream_op_batch(elem, batch);
}
GPR_TIMER_BEGIN("cc_start_transport_stream_op_batch", 0);
// If we've previously been cancelled, immediately fail any new batches.
if (calld->error != GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: failing batch with error: %s",
chand, calld, grpc_error_string(calld->error));
}
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch, GRPC_ERROR_REF(calld->error), calld->call_combiner);
+ batch, GRPC_ERROR_REF(calld->error), calld->call_combiner);
goto done;
}
if (batch->cancel_stream) {
@@ -1343,25 +1357,24 @@ static void cc_start_transport_stream_op_batch(
// error to the caller when the first batch does get passed down.
GRPC_ERROR_UNREF(calld->error);
calld->error = GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error);
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: recording cancel_error=%s", chand,
calld, grpc_error_string(calld->error));
}
// If we have a subchannel call, send the cancellation batch down.
// Otherwise, fail all pending batches.
- if (calld->subchannel_call != NULL) {
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
+ if (calld->subchannel_call != nullptr) {
+ grpc_subchannel_call_process_op(calld->subchannel_call, batch);
} else {
waiting_for_pick_batches_add(calld, batch);
- waiting_for_pick_batches_fail(exec_ctx, elem,
- GRPC_ERROR_REF(calld->error));
+ waiting_for_pick_batches_fail(elem, GRPC_ERROR_REF(calld->error));
}
goto done;
}
// Intercept on_complete for recv_trailing_metadata so that we can
// check retry throttle status.
if (batch->recv_trailing_metadata) {
- GPR_ASSERT(batch->on_complete != NULL);
+ GPR_ASSERT(batch->on_complete != nullptr);
calld->original_on_complete = batch->on_complete;
GRPC_CLOSURE_INIT(&calld->on_complete, on_complete, elem,
grpc_schedule_on_exec_ctx);
@@ -1371,13 +1384,13 @@ static void cc_start_transport_stream_op_batch(
// Note that once we have completed the pick, we do not need to enter
// the channel combiner, which is more efficient (especially for
// streaming calls).
- if (calld->subchannel_call != NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (calld->subchannel_call != nullptr) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
calld, calld->subchannel_call);
}
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
+ grpc_subchannel_call_process_op(calld->subchannel_call, batch);
goto done;
}
// We do not yet have a subchannel call.
@@ -1386,23 +1399,22 @@ static void cc_start_transport_stream_op_batch(
// For batches containing a send_initial_metadata op, enter the channel
// combiner to start a pick.
if (batch->send_initial_metadata) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: entering client_channel combiner",
chand, calld);
}
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&batch->handler_private.closure, start_pick_locked,
elem, grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
} else {
// For all other batches, release the call combiner.
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: saved batch, yeilding call combiner", chand,
calld);
}
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
"batch does not include send_initial_metadata");
}
done:
@@ -1410,66 +1422,61 @@ done:
}
/* Constructor for call_data */
-static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+static grpc_error* cc_init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
// Initialize data members.
calld->path = grpc_slice_ref_internal(args->path);
calld->call_start_time = args->start_time;
- calld->deadline = gpr_convert_clock_type(args->deadline, GPR_CLOCK_MONOTONIC);
+ calld->deadline = args->deadline;
calld->arena = args->arena;
calld->owning_call = args->call_stack;
calld->call_combiner = args->call_combiner;
if (chand->deadline_checking_enabled) {
- grpc_deadline_state_init(exec_ctx, elem, args->call_stack,
- args->call_combiner, calld->deadline);
+ grpc_deadline_state_init(elem, args->call_stack, args->call_combiner,
+ calld->deadline);
}
return GRPC_ERROR_NONE;
}
/* Destructor for call_data */
-static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_schedule_closure) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+static void cc_destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_schedule_closure) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
if (chand->deadline_checking_enabled) {
- grpc_deadline_state_destroy(exec_ctx, elem);
+ grpc_deadline_state_destroy(elem);
}
- grpc_slice_unref_internal(exec_ctx, calld->path);
- if (calld->method_params != NULL) {
+ grpc_slice_unref_internal(calld->path);
+ if (calld->method_params != nullptr) {
method_parameters_unref(calld->method_params);
}
GRPC_ERROR_UNREF(calld->error);
- if (calld->subchannel_call != NULL) {
+ if (calld->subchannel_call != nullptr) {
grpc_subchannel_call_set_cleanup_closure(calld->subchannel_call,
then_schedule_closure);
- then_schedule_closure = NULL;
- GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, calld->subchannel_call,
+ then_schedule_closure = nullptr;
+ GRPC_SUBCHANNEL_CALL_UNREF(calld->subchannel_call,
"client_channel_destroy_call");
}
- GPR_ASSERT(calld->lb_policy == NULL);
GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
- if (calld->connected_subchannel != NULL) {
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
- "picked");
+ if (calld->pick.connected_subchannel != nullptr) {
+ calld->pick.connected_subchannel.reset();
}
for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
- if (calld->subchannel_call_context[i].value != NULL) {
- calld->subchannel_call_context[i].destroy(
- calld->subchannel_call_context[i].value);
+ if (calld->pick.subchannel_call_context[i].value != nullptr) {
+ calld->pick.subchannel_call_context[i].destroy(
+ calld->pick.subchannel_call_context[i].value);
}
}
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
}
-static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {
- call_data *calld = (call_data *)elem->call_data;
+static void cc_set_pollset_or_pollset_set(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {
+ call_data* calld = (call_data*)elem->call_data;
calld->pollent = pollent;
}
@@ -1491,51 +1498,50 @@ const grpc_channel_filter grpc_client_channel_filter = {
"client-channel",
};
-static void try_to_connect_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error_ignored) {
- channel_data *chand = (channel_data *)arg;
- if (chand->lb_policy != NULL) {
- grpc_lb_policy_exit_idle_locked(exec_ctx, chand->lb_policy);
+static void try_to_connect_locked(void* arg, grpc_error* error_ignored) {
+ channel_data* chand = (channel_data*)arg;
+ if (chand->lb_policy != nullptr) {
+ grpc_lb_policy_exit_idle_locked(chand->lb_policy);
} else {
chand->exit_idle_when_lb_policy_arrives = true;
- if (!chand->started_resolving && chand->resolver != NULL) {
- start_resolving_locked(exec_ctx, chand);
+ if (!chand->started_resolving && chand->resolver != nullptr) {
+ start_resolving_locked(chand);
}
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "try_to_connect");
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "try_to_connect");
}
grpc_connectivity_state grpc_client_channel_check_connectivity_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect) {
- channel_data *chand = (channel_data *)elem->channel_data;
+ grpc_channel_element* elem, int try_to_connect) {
+ channel_data* chand = (channel_data*)elem->channel_data;
grpc_connectivity_state out =
grpc_connectivity_state_check(&chand->state_tracker);
if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "try_to_connect");
GRPC_CLOSURE_SCHED(
- exec_ctx, GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
- grpc_combiner_scheduler(chand->combiner)),
+ GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
+ grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
return out;
}
typedef struct external_connectivity_watcher {
- channel_data *chand;
+ channel_data* chand;
grpc_polling_entity pollent;
- grpc_closure *on_complete;
- grpc_closure *watcher_timer_init;
- grpc_connectivity_state *state;
+ grpc_closure* on_complete;
+ grpc_closure* watcher_timer_init;
+ grpc_connectivity_state* state;
grpc_closure my_closure;
- struct external_connectivity_watcher *next;
+ struct external_connectivity_watcher* next;
} external_connectivity_watcher;
-static external_connectivity_watcher *lookup_external_connectivity_watcher(
- channel_data *chand, grpc_closure *on_complete) {
+static external_connectivity_watcher* lookup_external_connectivity_watcher(
+ channel_data* chand, grpc_closure* on_complete) {
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
- external_connectivity_watcher *w =
+ external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
- while (w != NULL && w->on_complete != on_complete) {
+ while (w != nullptr && w->on_complete != on_complete) {
w = w->next;
}
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
@@ -1543,7 +1549,7 @@ static external_connectivity_watcher *lookup_external_connectivity_watcher(
}
static void external_connectivity_watcher_list_append(
- channel_data *chand, external_connectivity_watcher *w) {
+ channel_data* chand, external_connectivity_watcher* w) {
GPR_ASSERT(!lookup_external_connectivity_watcher(chand, w->on_complete));
gpr_mu_lock(&w->chand->external_connectivity_watcher_list_mu);
@@ -1554,7 +1560,7 @@ static void external_connectivity_watcher_list_append(
}
static void external_connectivity_watcher_list_remove(
- channel_data *chand, external_connectivity_watcher *too_remove) {
+ channel_data* chand, external_connectivity_watcher* too_remove) {
GPR_ASSERT(
lookup_external_connectivity_watcher(chand, too_remove->on_complete));
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
@@ -1563,9 +1569,9 @@ static void external_connectivity_watcher_list_remove(
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
return;
}
- external_connectivity_watcher *w =
+ external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
- while (w != NULL) {
+ while (w != nullptr) {
if (w->next == too_remove) {
w->next = w->next->next;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
@@ -1577,14 +1583,14 @@ static void external_connectivity_watcher_list_remove(
}
int grpc_client_channel_num_external_connectivity_watchers(
- grpc_channel_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
+ grpc_channel_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
int count = 0;
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
- external_connectivity_watcher *w =
+ external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
- while (w != NULL) {
+ while (w != nullptr) {
count++;
w = w->next;
}
@@ -1593,64 +1599,62 @@ int grpc_client_channel_num_external_connectivity_watchers(
return count;
}
-static void on_external_watch_complete(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- external_connectivity_watcher *w = (external_connectivity_watcher *)arg;
- grpc_closure *follow_up = w->on_complete;
- grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
+static void on_external_watch_complete_locked(void* arg, grpc_error* error) {
+ external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
+ grpc_closure* follow_up = w->on_complete;
+ grpc_polling_entity_del_from_pollset_set(&w->pollent,
w->chand->interested_parties);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
"external_connectivity_watcher");
external_connectivity_watcher_list_remove(w->chand, w);
gpr_free(w);
- GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(follow_up, GRPC_ERROR_REF(error));
}
-static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error_ignored) {
- external_connectivity_watcher *w = (external_connectivity_watcher *)arg;
- external_connectivity_watcher *found = NULL;
- if (w->state != NULL) {
+static void watch_connectivity_state_locked(void* arg,
+ grpc_error* error_ignored) {
+ external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
+ external_connectivity_watcher* found = nullptr;
+ if (w->state != nullptr) {
external_connectivity_watcher_list_append(w->chand, w);
- GRPC_CLOSURE_RUN(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
- GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete, w,
- grpc_schedule_on_exec_ctx);
- grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &w->chand->state_tracker, w->state, &w->my_closure);
+ GRPC_CLOSURE_RUN(w->watcher_timer_init, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete_locked, w,
+ grpc_combiner_scheduler(w->chand->combiner));
+ grpc_connectivity_state_notify_on_state_change(&w->chand->state_tracker,
+ w->state, &w->my_closure);
} else {
- GPR_ASSERT(w->watcher_timer_init == NULL);
+ GPR_ASSERT(w->watcher_timer_init == nullptr);
found = lookup_external_connectivity_watcher(w->chand, w->on_complete);
if (found) {
GPR_ASSERT(found->on_complete == w->on_complete);
grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &found->chand->state_tracker, NULL, &found->my_closure);
+ &found->chand->state_tracker, nullptr, &found->my_closure);
}
- grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
+ grpc_polling_entity_del_from_pollset_set(&w->pollent,
w->chand->interested_parties);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
"external_connectivity_watcher");
gpr_free(w);
}
}
void grpc_client_channel_watch_connectivity_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_polling_entity pollent, grpc_connectivity_state *state,
- grpc_closure *closure, grpc_closure *watcher_timer_init) {
- channel_data *chand = (channel_data *)elem->channel_data;
- external_connectivity_watcher *w =
- (external_connectivity_watcher *)gpr_zalloc(sizeof(*w));
+ grpc_channel_element* elem, grpc_polling_entity pollent,
+ grpc_connectivity_state* state, grpc_closure* closure,
+ grpc_closure* watcher_timer_init) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ external_connectivity_watcher* w =
+ (external_connectivity_watcher*)gpr_zalloc(sizeof(*w));
w->chand = chand;
w->pollent = pollent;
w->on_complete = closure;
w->state = state;
w->watcher_timer_init = watcher_timer_init;
- grpc_polling_entity_add_to_pollset_set(exec_ctx, &w->pollent,
+ grpc_polling_entity_add_to_pollset_set(&w->pollent,
chand->interested_parties);
GRPC_CHANNEL_STACK_REF(w->chand->owning_stack,
"external_connectivity_watcher");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&w->my_closure, watch_connectivity_state_locked, w,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h
index c99f0092e9..9670405cbe 100644
--- a/src/core/ext/filters/client_channel/client_channel.h
+++ b/src/core/ext/filters/client_channel/client_channel.h
@@ -23,7 +23,7 @@
#include "src/core/ext/filters/client_channel/resolver.h"
#include "src/core/lib/channel/channel_stack.h"
-extern grpc_tracer_flag grpc_client_channel_trace;
+extern grpc_core::TraceFlag grpc_client_channel_trace;
// Channel arg key for server URI string.
#define GRPC_ARG_SERVER_URI "grpc.server_uri"
@@ -38,18 +38,18 @@ extern grpc_tracer_flag grpc_client_channel_trace;
extern const grpc_channel_filter grpc_client_channel_filter;
grpc_connectivity_state grpc_client_channel_check_connectivity_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect);
+ grpc_channel_element* elem, int try_to_connect);
int grpc_client_channel_num_external_connectivity_watchers(
- grpc_channel_element *elem);
+ grpc_channel_element* elem);
void grpc_client_channel_watch_connectivity_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_polling_entity pollent, grpc_connectivity_state *state,
- grpc_closure *on_complete, grpc_closure *watcher_timer_init);
+ grpc_channel_element* elem, grpc_polling_entity pollent,
+ grpc_connectivity_state* state, grpc_closure* on_complete,
+ grpc_closure* watcher_timer_init);
/* Debug helper: pull the subchannel call from a call stack element */
-grpc_subchannel_call *grpc_client_channel_get_subchannel_call(
- grpc_call_element *elem);
+grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
+ grpc_call_element* elem);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.c b/src/core/ext/filters/client_channel/client_channel_factory.cc
index 57eac8f875..60c95d7dc9 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.c
+++ b/src/core/ext/filters/client_channel/client_channel_factory.cc
@@ -23,23 +23,19 @@ void grpc_client_channel_factory_ref(grpc_client_channel_factory* factory) {
factory->vtable->ref(factory);
}
-void grpc_client_channel_factory_unref(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory) {
- factory->vtable->unref(exec_ctx, factory);
+void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory) {
+ factory->vtable->unref(factory);
}
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
- const grpc_subchannel_args* args) {
- return factory->vtable->create_subchannel(exec_ctx, factory, args);
+ grpc_client_channel_factory* factory, const grpc_subchannel_args* args) {
+ return factory->vtable->create_subchannel(factory, args);
}
grpc_channel* grpc_client_channel_factory_create_channel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
- const char* target, grpc_client_channel_type type,
- const grpc_channel_args* args) {
- return factory->vtable->create_client_channel(exec_ctx, factory, target, type,
- args);
+ grpc_client_channel_factory* factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args) {
+ return factory->vtable->create_client_channel(factory, target, type, args);
}
static void* factory_arg_copy(void* factory) {
@@ -47,9 +43,8 @@ static void* factory_arg_copy(void* factory) {
return factory;
}
-static void factory_arg_destroy(grpc_exec_ctx* exec_ctx, void* factory) {
- grpc_client_channel_factory_unref(exec_ctx,
- (grpc_client_channel_factory*)factory);
+static void factory_arg_destroy(void* factory) {
+ grpc_client_channel_factory_unref((grpc_client_channel_factory*)factory);
}
static int factory_arg_cmp(void* factory1, void* factory2) {
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h
index ce6266c769..766ebb9389 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.h
+++ b/src/core/ext/filters/client_channel/client_channel_factory.h
@@ -40,38 +40,33 @@ typedef enum {
/** Constructor for new configured channels.
Creating decorators around this type is encouraged to adapt behavior. */
struct grpc_client_channel_factory {
- const grpc_client_channel_factory_vtable *vtable;
+ const grpc_client_channel_factory_vtable* vtable;
};
struct grpc_client_channel_factory_vtable {
- void (*ref)(grpc_client_channel_factory *factory);
- void (*unref)(grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *factory);
- grpc_subchannel *(*create_subchannel)(grpc_exec_ctx *exec_ctx,
- grpc_client_channel_factory *factory,
- const grpc_subchannel_args *args);
- grpc_channel *(*create_client_channel)(grpc_exec_ctx *exec_ctx,
- grpc_client_channel_factory *factory,
- const char *target,
+ void (*ref)(grpc_client_channel_factory* factory);
+ void (*unref)(grpc_client_channel_factory* factory);
+ grpc_subchannel* (*create_subchannel)(grpc_client_channel_factory* factory,
+ const grpc_subchannel_args* args);
+ grpc_channel* (*create_client_channel)(grpc_client_channel_factory* factory,
+ const char* target,
grpc_client_channel_type type,
- const grpc_channel_args *args);
+ const grpc_channel_args* args);
};
-void grpc_client_channel_factory_ref(grpc_client_channel_factory *factory);
-void grpc_client_channel_factory_unref(grpc_exec_ctx *exec_ctx,
- grpc_client_channel_factory *factory);
+void grpc_client_channel_factory_ref(grpc_client_channel_factory* factory);
+void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory);
/** Create a new grpc_subchannel */
-grpc_subchannel *grpc_client_channel_factory_create_subchannel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *factory,
- const grpc_subchannel_args *args);
+grpc_subchannel* grpc_client_channel_factory_create_subchannel(
+ grpc_client_channel_factory* factory, const grpc_subchannel_args* args);
/** Create a new grpc_channel */
-grpc_channel *grpc_client_channel_factory_create_channel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *factory,
- const char *target, grpc_client_channel_type type,
- const grpc_channel_args *args);
+grpc_channel* grpc_client_channel_factory_create_channel(
+ grpc_client_channel_factory* factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args);
grpc_arg grpc_client_channel_factory_create_channel_arg(
- grpc_client_channel_factory *factory);
+ grpc_client_channel_factory* factory);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_FACTORY_H */
diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.c b/src/core/ext/filters/client_channel/client_channel_plugin.cc
index 1f71c5a7f9..ea630d2917 100644
--- a/src/core/ext/filters/client_channel/client_channel_plugin.c
+++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc
@@ -34,16 +34,14 @@
#include "src/core/ext/filters/client_channel/subchannel_index.h"
#include "src/core/lib/surface/channel_init.h"
-static bool append_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder, void *arg) {
+static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_append_filter(
- builder, (const grpc_channel_filter *)arg, NULL, NULL);
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
-static bool set_default_host_if_unset(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *unused) {
- const grpc_channel_args *args =
+static bool set_default_host_if_unset(grpc_channel_stack_builder* builder,
+ void* unused) {
+ const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
for (size_t i = 0; i < args->num_args; i++) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY) ||
@@ -51,16 +49,15 @@ static bool set_default_host_if_unset(grpc_exec_ctx *exec_ctx,
return true;
}
}
- char *default_authority = grpc_get_default_authority(
- exec_ctx, grpc_channel_stack_builder_get_target(builder));
- if (default_authority != NULL) {
+ char* default_authority = grpc_get_default_authority(
+ grpc_channel_stack_builder_get_target(builder));
+ if (default_authority != nullptr) {
grpc_arg arg = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_DEFAULT_AUTHORITY, default_authority);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
- grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
- new_args);
+ (char*)GRPC_ARG_DEFAULT_AUTHORITY, default_authority);
+ 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(exec_ctx, new_args);
+ grpc_channel_args_destroy(new_args);
}
return true;
}
@@ -73,15 +70,11 @@ void grpc_client_channel_init(void) {
grpc_register_http_proxy_mapper();
grpc_subchannel_index_init();
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN,
- set_default_host_if_unset, NULL);
+ set_default_host_if_unset, nullptr);
grpc_channel_init_register_stage(
GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter,
- (void *)&grpc_client_channel_filter);
+ (void*)&grpc_client_channel_filter);
grpc_http_connect_register_handshaker_factory();
- grpc_register_tracer(&grpc_client_channel_trace);
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_resolver_refcount);
-#endif
}
void grpc_client_channel_shutdown(void) {
diff --git a/src/core/ext/filters/client_channel/connector.c b/src/core/ext/filters/client_channel/connector.cc
index c258468e58..c8bf2f3e1c 100644
--- a/src/core/ext/filters/client_channel/connector.c
+++ b/src/core/ext/filters/client_channel/connector.cc
@@ -23,18 +23,17 @@ grpc_connector* grpc_connector_ref(grpc_connector* connector) {
return connector;
}
-void grpc_connector_unref(grpc_exec_ctx* exec_ctx, grpc_connector* connector) {
- connector->vtable->unref(exec_ctx, connector);
+void grpc_connector_unref(grpc_connector* connector) {
+ connector->vtable->unref(connector);
}
-void grpc_connector_connect(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
+void grpc_connector_connect(grpc_connector* connector,
const grpc_connect_in_args* in_args,
grpc_connect_out_args* out_args,
grpc_closure* notify) {
- connector->vtable->connect(exec_ctx, connector, in_args, out_args, notify);
+ connector->vtable->connect(connector, in_args, out_args, notify);
}
-void grpc_connector_shutdown(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
- grpc_error* why) {
- connector->vtable->shutdown(exec_ctx, connector, why);
+void grpc_connector_shutdown(grpc_connector* connector, grpc_error* why) {
+ connector->vtable->shutdown(connector, why);
}
diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h
index 7f3d4a1cc0..d657658d67 100644
--- a/src/core/ext/filters/client_channel/connector.h
+++ b/src/core/ext/filters/client_channel/connector.h
@@ -27,47 +27,45 @@ typedef struct grpc_connector grpc_connector;
typedef struct grpc_connector_vtable grpc_connector_vtable;
struct grpc_connector {
- const grpc_connector_vtable *vtable;
+ const grpc_connector_vtable* vtable;
};
typedef struct {
/** set of pollsets interested in this connection */
- grpc_pollset_set *interested_parties;
+ grpc_pollset_set* interested_parties;
/** deadline for connection */
- gpr_timespec deadline;
+ grpc_millis deadline;
/** channel arguments (to be passed to transport) */
- const grpc_channel_args *channel_args;
+ const grpc_channel_args* channel_args;
} grpc_connect_in_args;
typedef struct {
/** the connected transport */
- grpc_transport *transport;
+ grpc_transport* transport;
/** channel arguments (to be passed to the filters) */
- grpc_channel_args *channel_args;
+ grpc_channel_args* channel_args;
} grpc_connect_out_args;
struct grpc_connector_vtable {
- void (*ref)(grpc_connector *connector);
- void (*unref)(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
+ void (*ref)(grpc_connector* connector);
+ void (*unref)(grpc_connector* connector);
/** Implementation of grpc_connector_shutdown */
- void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
- grpc_error *why);
+ void (*shutdown)(grpc_connector* connector, grpc_error* why);
/** Implementation of grpc_connector_connect */
- void (*connect)(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
- const grpc_connect_in_args *in_args,
- grpc_connect_out_args *out_args, grpc_closure *notify);
+ void (*connect)(grpc_connector* connector,
+ const grpc_connect_in_args* in_args,
+ grpc_connect_out_args* out_args, grpc_closure* notify);
};
-grpc_connector *grpc_connector_ref(grpc_connector *connector);
-void grpc_connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
+grpc_connector* grpc_connector_ref(grpc_connector* connector);
+void grpc_connector_unref(grpc_connector* connector);
/** Connect using the connector: max one outstanding call at a time */
-void grpc_connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
- const grpc_connect_in_args *in_args,
- grpc_connect_out_args *out_args,
- grpc_closure *notify);
+void grpc_connector_connect(grpc_connector* connector,
+ const grpc_connect_in_args* in_args,
+ grpc_connect_out_args* out_args,
+ grpc_closure* notify);
/** Cancel any pending connection */
-void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
- grpc_error *why);
+void grpc_connector_shutdown(grpc_connector* connector, grpc_error* why);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */
diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.c b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
index 418bb41ef6..6bfd038887 100644
--- a/src/core/ext/filters/client_channel/http_connect_handshaker.c
+++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
@@ -30,11 +30,11 @@
#include "src/core/ext/filters/client_channel/uri_parser.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker_registry.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/http/format_request.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
typedef struct http_connect_handshaker {
// Base class. Must be first.
@@ -61,41 +61,38 @@ typedef struct http_connect_handshaker {
} http_connect_handshaker;
// Unref and clean up handshaker.
-static void http_connect_handshaker_unref(grpc_exec_ctx* exec_ctx,
- http_connect_handshaker* handshaker) {
+static void http_connect_handshaker_unref(http_connect_handshaker* handshaker) {
if (gpr_unref(&handshaker->refcount)) {
gpr_mu_destroy(&handshaker->mu);
- if (handshaker->endpoint_to_destroy != NULL) {
- grpc_endpoint_destroy(exec_ctx, handshaker->endpoint_to_destroy);
+ if (handshaker->endpoint_to_destroy != nullptr) {
+ grpc_endpoint_destroy(handshaker->endpoint_to_destroy);
}
- if (handshaker->read_buffer_to_destroy != NULL) {
- grpc_slice_buffer_destroy_internal(exec_ctx,
- handshaker->read_buffer_to_destroy);
+ if (handshaker->read_buffer_to_destroy != nullptr) {
+ grpc_slice_buffer_destroy_internal(handshaker->read_buffer_to_destroy);
gpr_free(handshaker->read_buffer_to_destroy);
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &handshaker->write_buffer);
+ grpc_slice_buffer_destroy_internal(&handshaker->write_buffer);
grpc_http_parser_destroy(&handshaker->http_parser);
grpc_http_response_destroy(&handshaker->http_response);
gpr_free(handshaker);
}
}
-// Set args fields to NULL, saving the endpoint and read buffer for
+// Set args fields to nullptr, saving the endpoint and read buffer for
// later destruction.
static void cleanup_args_for_failure_locked(
- grpc_exec_ctx* exec_ctx, http_connect_handshaker* handshaker) {
+ http_connect_handshaker* handshaker) {
handshaker->endpoint_to_destroy = handshaker->args->endpoint;
- handshaker->args->endpoint = NULL;
+ handshaker->args->endpoint = nullptr;
handshaker->read_buffer_to_destroy = handshaker->args->read_buffer;
- handshaker->args->read_buffer = NULL;
- grpc_channel_args_destroy(exec_ctx, handshaker->args->args);
- handshaker->args->args = NULL;
+ handshaker->args->read_buffer = nullptr;
+ grpc_channel_args_destroy(handshaker->args->args);
+ handshaker->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
// callback with the error.
-static void handshake_failed_locked(grpc_exec_ctx* exec_ctx,
- http_connect_handshaker* handshaker,
+static void handshake_failed_locked(http_connect_handshaker* handshaker,
grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
// If we were shut down after an endpoint operation succeeded but
@@ -108,34 +105,32 @@ static void handshake_failed_locked(grpc_exec_ctx* exec_ctx,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, handshaker->args->endpoint,
- GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(handshaker->args->endpoint, GRPC_ERROR_REF(error));
// Not shutting down, so the handshake failed. Clean up before
// invoking the callback.
- cleanup_args_for_failure_locked(exec_ctx, handshaker);
+ cleanup_args_for_failure_locked(handshaker);
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
handshaker->shutdown = true;
}
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, handshaker->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(handshaker->on_handshake_done, error);
}
// Callback invoked when finished writing HTTP CONNECT request.
-static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_write_done(void* arg, grpc_error* error) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)arg;
gpr_mu_lock(&handshaker->mu);
if (error != GRPC_ERROR_NONE || handshaker->shutdown) {
// If the write failed or we're shutting down, clean up and invoke the
// callback with the error.
- handshake_failed_locked(exec_ctx, handshaker, GRPC_ERROR_REF(error));
+ handshake_failed_locked(handshaker, GRPC_ERROR_REF(error));
gpr_mu_unlock(&handshaker->mu);
- http_connect_handshaker_unref(exec_ctx, handshaker);
+ http_connect_handshaker_unref(handshaker);
} else {
// Otherwise, read the response.
// The read callback inherits our ref to the handshaker.
- grpc_endpoint_read(exec_ctx, handshaker->args->endpoint,
+ grpc_endpoint_read(handshaker->args->endpoint,
handshaker->args->read_buffer,
&handshaker->response_read_closure);
gpr_mu_unlock(&handshaker->mu);
@@ -143,14 +138,13 @@ static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg,
}
// Callback invoked for reading HTTP CONNECT response.
-static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_read_done(void* arg, grpc_error* error) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)arg;
gpr_mu_lock(&handshaker->mu);
if (error != GRPC_ERROR_NONE || handshaker->shutdown) {
// If the read failed or we're shutting down, clean up and invoke the
// callback with the error.
- handshake_failed_locked(exec_ctx, handshaker, GRPC_ERROR_REF(error));
+ handshake_failed_locked(handshaker, GRPC_ERROR_REF(error));
goto done;
}
// Add buffer to parser.
@@ -161,7 +155,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
handshaker->args->read_buffer->slices[i],
&body_start_offset);
if (error != GRPC_ERROR_NONE) {
- handshake_failed_locked(exec_ctx, handshaker, error);
+ handshake_failed_locked(handshaker, error);
goto done;
}
if (handshaker->http_parser.state == GRPC_HTTP_BODY) {
@@ -180,7 +174,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
&handshaker->args->read_buffer->slices[i + 1],
handshaker->args->read_buffer->count - i - 1);
grpc_slice_buffer_swap(handshaker->args->read_buffer, &tmp_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &tmp_buffer);
+ grpc_slice_buffer_destroy_internal(&tmp_buffer);
break;
}
}
@@ -197,9 +191,8 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
// complete (e.g., handling chunked transfer encoding or looking
// at the Content-Length: header).
if (handshaker->http_parser.state != GRPC_HTTP_BODY) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- handshaker->args->read_buffer);
- grpc_endpoint_read(exec_ctx, handshaker->args->endpoint,
+ grpc_slice_buffer_reset_and_unref_internal(handshaker->args->read_buffer);
+ grpc_endpoint_read(handshaker->args->endpoint,
handshaker->args->read_buffer,
&handshaker->response_read_closure);
gpr_mu_unlock(&handshaker->mu);
@@ -213,71 +206,67 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
handshaker->http_response.status);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- handshake_failed_locked(exec_ctx, handshaker, error);
+ handshake_failed_locked(handshaker, error);
goto done;
}
// Success. Invoke handshake-done callback.
- GRPC_CLOSURE_SCHED(exec_ctx, handshaker->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(handshaker->on_handshake_done, error);
done:
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
handshaker->shutdown = true;
gpr_mu_unlock(&handshaker->mu);
- http_connect_handshaker_unref(exec_ctx, handshaker);
+ http_connect_handshaker_unref(handshaker);
}
//
// Public handshaker methods
//
-static void http_connect_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker_in) {
+static void http_connect_handshaker_destroy(grpc_handshaker* handshaker_in) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
- http_connect_handshaker_unref(exec_ctx, handshaker);
+ http_connect_handshaker_unref(handshaker);
}
-static void http_connect_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker_in,
+static void http_connect_handshaker_shutdown(grpc_handshaker* handshaker_in,
grpc_error* why) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
gpr_mu_lock(&handshaker->mu);
if (!handshaker->shutdown) {
handshaker->shutdown = true;
- grpc_endpoint_shutdown(exec_ctx, handshaker->args->endpoint,
- GRPC_ERROR_REF(why));
- cleanup_args_for_failure_locked(exec_ctx, handshaker);
+ grpc_endpoint_shutdown(handshaker->args->endpoint, GRPC_ERROR_REF(why));
+ cleanup_args_for_failure_locked(handshaker);
}
gpr_mu_unlock(&handshaker->mu);
GRPC_ERROR_UNREF(why);
}
static void http_connect_handshaker_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker_in,
- grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done,
- grpc_handshaker_args* args) {
+ grpc_handshaker* handshaker_in, grpc_tcp_server_acceptor* acceptor,
+ grpc_closure* on_handshake_done, grpc_handshaker_args* args) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
// Check for HTTP CONNECT channel arg.
// If not found, invoke on_handshake_done without doing anything.
const grpc_arg* arg =
grpc_channel_args_find(args->args, GRPC_ARG_HTTP_CONNECT_SERVER);
- if (arg == NULL) {
+ if (arg == nullptr) {
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
gpr_mu_lock(&handshaker->mu);
handshaker->shutdown = true;
gpr_mu_unlock(&handshaker->mu);
- GRPC_CLOSURE_SCHED(exec_ctx, on_handshake_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_handshake_done, GRPC_ERROR_NONE);
return;
}
GPR_ASSERT(arg->type == GRPC_ARG_STRING);
char* server_name = arg->value.string;
// Get headers from channel args.
arg = grpc_channel_args_find(args->args, GRPC_ARG_HTTP_CONNECT_HEADERS);
- grpc_http_header* headers = NULL;
+ grpc_http_header* headers = nullptr;
size_t num_headers = 0;
- char** header_strings = NULL;
+ char** header_strings = nullptr;
size_t num_header_strings = 0;
- if (arg != NULL) {
+ if (arg != nullptr) {
GPR_ASSERT(arg->type == GRPC_ARG_STRING);
gpr_string_split(arg->value.string, "\n", &header_strings,
&num_header_strings);
@@ -285,7 +274,7 @@ static void http_connect_handshaker_do_handshake(
num_header_strings);
for (size_t i = 0; i < num_header_strings; ++i) {
char* sep = strchr(header_strings[i], ':');
- if (sep == NULL) {
+ if (sep == nullptr) {
gpr_log(GPR_ERROR, "skipping unparseable HTTP CONNECT header: %s",
header_strings[i]);
continue;
@@ -324,7 +313,7 @@ static void http_connect_handshaker_do_handshake(
gpr_free(header_strings);
// Take a new ref to be held by the write callback.
gpr_ref(&handshaker->refcount);
- grpc_endpoint_write(exec_ctx, args->endpoint, &handshaker->write_buffer,
+ grpc_endpoint_write(args->endpoint, &handshaker->write_buffer,
&handshaker->request_done_closure);
gpr_mu_unlock(&handshaker->mu);
}
@@ -355,14 +344,13 @@ static grpc_handshaker* grpc_http_connect_handshaker_create() {
//
static void handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* factory,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(handshake_mgr,
grpc_http_connect_handshaker_create());
}
-static void handshaker_factory_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_factory* factory) {}
+static void handshaker_factory_destroy(grpc_handshaker_factory* factory) {}
static const grpc_handshaker_factory_vtable handshaker_factory_vtable = {
handshaker_factory_add_handshakers, handshaker_factory_destroy};
diff --git a/src/core/ext/filters/client_channel/http_proxy.c b/src/core/ext/filters/client_channel/http_proxy.cc
index c507a2750e..7c5f79fb30 100644
--- a/src/core/ext/filters/client_channel/http_proxy.c
+++ b/src/core/ext/filters/client_channel/http_proxy.cc
@@ -30,26 +30,25 @@
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
#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/string.h"
#include "src/core/lib/slice/b64.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
/**
* Parses the 'http_proxy' env var and returns the proxy hostname to resolve or
- * NULL on error. Also sets 'user_cred' to user credentials if present in the
+ * nullptr on error. Also sets 'user_cred' to user credentials if present in the
* 'http_proxy' env var, otherwise leaves it unchanged. It is caller's
* responsibility to gpr_free user_cred.
*/
-static char* get_http_proxy_server(grpc_exec_ctx* exec_ctx, char** user_cred) {
- GPR_ASSERT(user_cred != NULL);
- char* proxy_name = NULL;
+static char* get_http_proxy_server(char** user_cred) {
+ GPR_ASSERT(user_cred != nullptr);
+ char* proxy_name = nullptr;
char* uri_str = gpr_getenv("http_proxy");
- char** authority_strs = NULL;
+ char** authority_strs = nullptr;
size_t authority_nstrs;
- if (uri_str == NULL) return NULL;
- grpc_uri* uri =
- grpc_uri_parse(exec_ctx, uri_str, false /* suppress_errors */);
- if (uri == NULL || uri->authority == NULL) {
+ if (uri_str == nullptr) return nullptr;
+ grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
+ if (uri == nullptr || uri->authority == nullptr) {
gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var");
goto done;
}
@@ -73,7 +72,7 @@ static char* get_http_proxy_server(grpc_exec_ctx* exec_ctx, char** user_cred) {
for (size_t i = 0; i < authority_nstrs; i++) {
gpr_free(authority_strs[i]);
}
- proxy_name = NULL;
+ proxy_name = nullptr;
}
gpr_free(authority_strs);
done:
@@ -82,37 +81,30 @@ done:
return proxy_name;
}
-static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
- char* user_cred = NULL;
- *name_to_resolve = get_http_proxy_server(exec_ctx, &user_cred);
- if (*name_to_resolve == NULL) return false;
- grpc_uri* uri =
- grpc_uri_parse(exec_ctx, server_uri, false /* suppress_errors */);
- if (uri == NULL || uri->path[0] == '\0') {
+ char* user_cred = nullptr;
+ *name_to_resolve = get_http_proxy_server(&user_cred);
+ if (*name_to_resolve == nullptr) return false;
+ char* no_proxy_str = nullptr;
+ grpc_uri* uri = grpc_uri_parse(server_uri, false /* suppress_errors */);
+ if (uri == nullptr || uri->path[0] == '\0') {
gpr_log(GPR_ERROR,
"'http_proxy' environment variable set, but cannot "
"parse server URI '%s' -- not using proxy",
server_uri);
- if (uri != NULL) {
- gpr_free(user_cred);
- grpc_uri_destroy(uri);
- }
- return false;
+ goto no_use_proxy;
}
if (strcmp(uri->scheme, "unix") == 0) {
gpr_log(GPR_INFO, "not using proxy for Unix domain socket '%s'",
server_uri);
- gpr_free(user_cred);
- grpc_uri_destroy(uri);
- return false;
+ goto no_use_proxy;
}
- char* no_proxy_str = gpr_getenv("no_proxy");
- if (no_proxy_str != NULL) {
+ no_proxy_str = gpr_getenv("no_proxy");
+ if (no_proxy_str != nullptr) {
static const char* NO_PROXY_SEPARATOR = ",";
bool use_proxy = true;
char* server_host;
@@ -123,6 +115,7 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
"unable to split host and port, not checking no_proxy list for "
"host '%s'",
server_uri);
+ gpr_free(no_proxy_str);
} else {
size_t uri_len = strlen(server_host);
char** no_proxy_hosts;
@@ -147,19 +140,15 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
gpr_free(no_proxy_hosts);
gpr_free(server_host);
gpr_free(server_port);
- if (!use_proxy) {
- grpc_uri_destroy(uri);
- gpr_free(*name_to_resolve);
- *name_to_resolve = NULL;
- return false;
- }
+ gpr_free(no_proxy_str);
+ if (!use_proxy) goto no_use_proxy;
}
}
grpc_arg args_to_add[2];
args_to_add[0] = grpc_channel_arg_string_create(
(char*)GRPC_ARG_HTTP_CONNECT_SERVER,
uri->path[0] == '/' ? uri->path + 1 : uri->path);
- if (user_cred != NULL) {
+ if (user_cred != nullptr) {
/* Use base64 encoding for user credentials as stated in RFC 7617 */
char* encoded_user_cred =
grpc_base64_encode(user_cred, strlen(user_cred), 0, 0);
@@ -173,13 +162,18 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
} else {
*new_args = grpc_channel_args_copy_and_add(args, args_to_add, 1);
}
- gpr_free(user_cred);
grpc_uri_destroy(uri);
+ gpr_free(user_cred);
return true;
+no_use_proxy:
+ if (uri != nullptr) grpc_uri_destroy(uri);
+ gpr_free(*name_to_resolve);
+ *name_to_resolve = nullptr;
+ gpr_free(user_cred);
+ return false;
}
-static bool proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+static bool proxy_mapper_map_address(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
diff --git a/src/core/ext/filters/client_channel/lb_policy.c b/src/core/ext/filters/client_channel/lb_policy.c
deleted file mode 100644
index 8e6673d737..0000000000
--- a/src/core/ext/filters/client_channel/lb_policy.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- *
- * Copyright 2015 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "src/core/ext/filters/client_channel/lb_policy.h"
-#include "src/core/lib/iomgr/combiner.h"
-
-#define WEAK_REF_BITS 16
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_lb_policy_refcount =
- GRPC_TRACER_INITIALIZER(false, "lb_policy_refcount");
-#endif
-
-void grpc_lb_policy_init(grpc_lb_policy *policy,
- const grpc_lb_policy_vtable *vtable,
- grpc_combiner *combiner) {
- policy->vtable = vtable;
- gpr_atm_no_barrier_store(&policy->ref_pair, 1 << WEAK_REF_BITS);
- policy->interested_parties = grpc_pollset_set_create();
- policy->combiner = GRPC_COMBINER_REF(combiner, "lb_policy");
-}
-
-#ifndef NDEBUG
-#define REF_FUNC_EXTRA_ARGS , const char *file, int line, const char *reason
-#define REF_MUTATE_EXTRA_ARGS REF_FUNC_EXTRA_ARGS, const char *purpose
-#define REF_FUNC_PASS_ARGS(new_reason) , file, line, new_reason
-#define REF_MUTATE_PASS_ARGS(purpose) , file, line, reason, purpose
-#else
-#define REF_FUNC_EXTRA_ARGS
-#define REF_MUTATE_EXTRA_ARGS
-#define REF_FUNC_PASS_ARGS(new_reason)
-#define REF_MUTATE_PASS_ARGS(x)
-#endif
-
-static gpr_atm ref_mutate(grpc_lb_policy *c, gpr_atm delta,
- int barrier REF_MUTATE_EXTRA_ARGS) {
- gpr_atm old_val = barrier ? gpr_atm_full_fetch_add(&c->ref_pair, delta)
- : gpr_atm_no_barrier_fetch_add(&c->ref_pair, delta);
-#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_lb_policy_refcount)) {
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "LB_POLICY: %p %12s 0x%" PRIxPTR " -> 0x%" PRIxPTR " [%s]", c,
- purpose, old_val, old_val + delta, reason);
- }
-#endif
- return old_val;
-}
-
-void grpc_lb_policy_ref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
- ref_mutate(policy, 1 << WEAK_REF_BITS, 0 REF_MUTATE_PASS_ARGS("STRONG_REF"));
-}
-
-static void shutdown_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_lb_policy *policy = (grpc_lb_policy *)arg;
- policy->vtable->shutdown_locked(exec_ctx, policy);
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, policy, "strong-unref");
-}
-
-void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
- gpr_atm old_val =
- ref_mutate(policy, (gpr_atm)1 - (gpr_atm)(1 << WEAK_REF_BITS),
- 1 REF_MUTATE_PASS_ARGS("STRONG_UNREF"));
- gpr_atm mask = ~(gpr_atm)((1 << WEAK_REF_BITS) - 1);
- gpr_atm check = 1 << WEAK_REF_BITS;
- if ((old_val & mask) == check) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(
- shutdown_locked, policy,
- grpc_combiner_scheduler(policy->combiner)),
- GRPC_ERROR_NONE);
- } else {
- grpc_lb_policy_weak_unref(exec_ctx,
- policy REF_FUNC_PASS_ARGS("strong-unref"));
- }
-}
-
-void grpc_lb_policy_weak_ref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
- ref_mutate(policy, 1, 0 REF_MUTATE_PASS_ARGS("WEAK_REF"));
-}
-
-void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
- gpr_atm old_val =
- ref_mutate(policy, -(gpr_atm)1, 1 REF_MUTATE_PASS_ARGS("WEAK_UNREF"));
- if (old_val == 1) {
- grpc_pollset_set_destroy(exec_ctx, policy->interested_parties);
- grpc_combiner *combiner = policy->combiner;
- policy->vtable->destroy(exec_ctx, policy);
- GRPC_COMBINER_UNREF(exec_ctx, combiner, "lb_policy");
- }
-}
-
-int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context,
- void **user_data, grpc_closure *on_complete) {
- return policy->vtable->pick_locked(exec_ctx, policy, pick_args, target,
- context, user_data, on_complete);
-}
-
-void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- grpc_connected_subchannel **target,
- grpc_error *error) {
- policy->vtable->cancel_pick_locked(exec_ctx, policy, target, error);
-}
-
-void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- uint32_t initial_metadata_flags_mask,
- uint32_t initial_metadata_flags_eq,
- grpc_error *error) {
- policy->vtable->cancel_picks_locked(exec_ctx, policy,
- initial_metadata_flags_mask,
- initial_metadata_flags_eq, error);
-}
-
-void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy) {
- policy->vtable->exit_idle_locked(exec_ctx, policy);
-}
-
-void grpc_lb_policy_ping_one_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- grpc_closure *closure) {
- policy->vtable->ping_one_locked(exec_ctx, policy, closure);
-}
-
-void grpc_lb_policy_notify_on_state_change_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_connectivity_state *state, grpc_closure *closure) {
- policy->vtable->notify_on_state_change_locked(exec_ctx, policy, state,
- closure);
-}
-
-grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_error **connectivity_error) {
- return policy->vtable->check_connectivity_locked(exec_ctx, policy,
- connectivity_error);
-}
-
-void grpc_lb_policy_update_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- const grpc_lb_policy_args *lb_policy_args) {
- policy->vtable->update_locked(exec_ctx, policy, lb_policy_args);
-}
diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc
new file mode 100644
index 0000000000..cc4fe7ec62
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy.cc
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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/lb_policy.h"
+#include "src/core/lib/iomgr/combiner.h"
+
+grpc_core::DebugOnlyTraceFlag grpc_trace_lb_policy_refcount(
+ false, "lb_policy_refcount");
+
+void grpc_lb_policy_init(grpc_lb_policy* policy,
+ const grpc_lb_policy_vtable* vtable,
+ grpc_combiner* combiner) {
+ policy->vtable = vtable;
+ gpr_ref_init(&policy->refs, 1);
+ policy->interested_parties = grpc_pollset_set_create();
+ policy->combiner = GRPC_COMBINER_REF(combiner, "lb_policy");
+}
+
+#ifndef NDEBUG
+void grpc_lb_policy_ref(grpc_lb_policy* lb_policy, const char* file, int line,
+ const char* reason) {
+ if (grpc_trace_lb_policy_refcount.enabled()) {
+ gpr_atm old_refs = gpr_atm_no_barrier_load(&lb_policy->refs.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "LB_POLICY:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", lb_policy,
+ old_refs, old_refs + 1, reason);
+ }
+#else
+void grpc_lb_policy_ref(grpc_lb_policy* lb_policy) {
+#endif
+ gpr_ref(&lb_policy->refs);
+}
+
+#ifndef NDEBUG
+void grpc_lb_policy_unref(grpc_lb_policy* lb_policy, const char* file, int line,
+ const char* reason) {
+ if (grpc_trace_lb_policy_refcount.enabled()) {
+ gpr_atm old_refs = gpr_atm_no_barrier_load(&lb_policy->refs.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "LB_POLICY:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", lb_policy,
+ old_refs, old_refs - 1, reason);
+ }
+#else
+void grpc_lb_policy_unref(grpc_lb_policy* lb_policy) {
+#endif
+ if (gpr_unref(&lb_policy->refs)) {
+ grpc_pollset_set_destroy(lb_policy->interested_parties);
+ grpc_combiner* combiner = lb_policy->combiner;
+ lb_policy->vtable->destroy(lb_policy);
+ GRPC_COMBINER_UNREF(combiner, "lb_policy");
+ }
+}
+
+void grpc_lb_policy_shutdown_locked(grpc_lb_policy* policy,
+ grpc_lb_policy* new_policy) {
+ policy->vtable->shutdown_locked(policy, new_policy);
+}
+
+int grpc_lb_policy_pick_locked(grpc_lb_policy* policy,
+ grpc_lb_policy_pick_state* pick) {
+ return policy->vtable->pick_locked(policy, pick);
+}
+
+void grpc_lb_policy_cancel_pick_locked(grpc_lb_policy* policy,
+ grpc_lb_policy_pick_state* pick,
+ grpc_error* error) {
+ policy->vtable->cancel_pick_locked(policy, pick, error);
+}
+
+void grpc_lb_policy_cancel_picks_locked(grpc_lb_policy* policy,
+ uint32_t initial_metadata_flags_mask,
+ uint32_t initial_metadata_flags_eq,
+ grpc_error* error) {
+ policy->vtable->cancel_picks_locked(policy, initial_metadata_flags_mask,
+ initial_metadata_flags_eq, error);
+}
+
+void grpc_lb_policy_exit_idle_locked(grpc_lb_policy* policy) {
+ policy->vtable->exit_idle_locked(policy);
+}
+
+void grpc_lb_policy_ping_one_locked(grpc_lb_policy* policy,
+ grpc_closure* on_initiate,
+ grpc_closure* on_ack) {
+ policy->vtable->ping_one_locked(policy, on_initiate, on_ack);
+}
+
+void grpc_lb_policy_notify_on_state_change_locked(
+ grpc_lb_policy* policy, grpc_connectivity_state* state,
+ grpc_closure* closure) {
+ policy->vtable->notify_on_state_change_locked(policy, state, closure);
+}
+
+grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
+ grpc_lb_policy* policy, grpc_error** connectivity_error) {
+ return policy->vtable->check_connectivity_locked(policy, connectivity_error);
+}
+
+void grpc_lb_policy_update_locked(grpc_lb_policy* policy,
+ const grpc_lb_policy_args* lb_policy_args) {
+ policy->vtable->update_locked(policy, lb_policy_args);
+}
+
+void grpc_lb_policy_set_reresolve_closure_locked(
+ grpc_lb_policy* policy, grpc_closure* request_reresolution) {
+ policy->vtable->set_reresolve_closure_locked(policy, request_reresolution);
+}
+
+void grpc_lb_policy_try_reresolve(grpc_lb_policy* policy,
+ grpc_core::TraceFlag* grpc_lb_trace,
+ grpc_error* error) {
+ if (policy->request_reresolution != nullptr) {
+ GRPC_CLOSURE_SCHED(policy->request_reresolution, error);
+ policy->request_reresolution = nullptr;
+ if (grpc_lb_trace->enabled()) {
+ gpr_log(GPR_DEBUG,
+ "%s %p: scheduling re-resolution closure with error=%s.",
+ grpc_lb_trace->name(), policy, grpc_error_string(error));
+ }
+ } else {
+ if (grpc_lb_trace->enabled() && error == GRPC_ERROR_NONE) {
+ gpr_log(GPR_DEBUG, "%s %p: re-resolution already in progress.",
+ grpc_lb_trace->name(), policy);
+ }
+ }
+}
diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h
index 645d51e138..30660cb83d 100644
--- a/src/core/ext/filters/client_channel/lb_policy.h
+++ b/src/core/ext/filters/client_channel/lb_policy.h
@@ -20,6 +20,7 @@
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_H
#include "src/core/ext/filters/client_channel/subchannel.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/transport/connectivity_state.h"
@@ -29,179 +30,175 @@ typedef struct grpc_lb_policy grpc_lb_policy;
typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable;
typedef struct grpc_lb_policy_args grpc_lb_policy_args;
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_lb_policy_refcount;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_lb_policy_refcount;
struct grpc_lb_policy {
- const grpc_lb_policy_vtable *vtable;
- gpr_atm ref_pair;
+ const grpc_lb_policy_vtable* vtable;
+ gpr_refcount refs;
/* owned pointer to interested parties in load balancing decisions */
- grpc_pollset_set *interested_parties;
+ grpc_pollset_set* interested_parties;
/* combiner under which lb_policy actions take place */
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
+ /* callback to force a re-resolution */
+ grpc_closure* request_reresolution;
};
-/** Extra arguments for an LB pick */
-typedef struct grpc_lb_policy_pick_args {
- /** Initial metadata associated with the picking call. */
- grpc_metadata_batch *initial_metadata;
- /** Bitmask used for selective cancelling. See \a
- * grpc_lb_policy_cancel_picks() and \a GRPC_INITIAL_METADATA_* in
- * grpc_types.h */
+/// State used for an LB pick.
+typedef struct grpc_lb_policy_pick_state {
+ /// Initial metadata associated with the picking call.
+ grpc_metadata_batch* initial_metadata;
+ /// Bitmask used for selective cancelling. See \a
+ /// grpc_lb_policy_cancel_picks() and \a GRPC_INITIAL_METADATA_* in
+ /// grpc_types.h.
uint32_t initial_metadata_flags;
- /** Storage for LB token in \a initial_metadata, or NULL if not used */
- grpc_linked_mdelem *lb_token_mdelem_storage;
-} grpc_lb_policy_pick_args;
+ /// Storage for LB token in \a initial_metadata, or NULL if not used.
+ grpc_linked_mdelem lb_token_mdelem_storage;
+ /// Closure to run when pick is complete, if not completed synchronously.
+ grpc_closure* on_complete;
+ /// Will be set to the selected subchannel, or nullptr on failure or when
+ /// the LB policy decides to drop the call.
+ grpc_core::RefCountedPtr<grpc_core::ConnectedSubchannel> connected_subchannel;
+ /// Will be populated with context to pass to the subchannel call, if needed.
+ grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
+ /// Upon success, \a *user_data will be set to whatever opaque information
+ /// may need to be propagated from the LB policy, or NULL if not needed.
+ void** user_data;
+ /// Next pointer. For internal use by LB policy.
+ struct grpc_lb_policy_pick_state* next;
+} grpc_lb_policy_pick_state;
struct grpc_lb_policy_vtable {
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
- void (*shutdown_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
+ void (*destroy)(grpc_lb_policy* policy);
+
+ /// \see grpc_lb_policy_shutdown_locked().
+ void (*shutdown_locked)(grpc_lb_policy* policy, grpc_lb_policy* new_policy);
/** \see grpc_lb_policy_pick */
- int (*pick_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context, void **user_data,
- grpc_closure *on_complete);
+ int (*pick_locked)(grpc_lb_policy* policy, grpc_lb_policy_pick_state* pick);
/** \see grpc_lb_policy_cancel_pick */
- void (*cancel_pick_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_connected_subchannel **target,
- grpc_error *error);
+ void (*cancel_pick_locked)(grpc_lb_policy* policy,
+ grpc_lb_policy_pick_state* pick,
+ grpc_error* error);
/** \see grpc_lb_policy_cancel_picks */
- void (*cancel_picks_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
+ void (*cancel_picks_locked)(grpc_lb_policy* policy,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
- grpc_error *error);
+ grpc_error* error);
/** \see grpc_lb_policy_ping_one */
- void (*ping_one_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_closure *closure);
+ void (*ping_one_locked)(grpc_lb_policy* policy, grpc_closure* on_initiate,
+ grpc_closure* on_ack);
/** Try to enter a READY connectivity state */
- void (*exit_idle_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
+ void (*exit_idle_locked)(grpc_lb_policy* policy);
/** check the current connectivity of the lb_policy */
grpc_connectivity_state (*check_connectivity_locked)(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_error **connectivity_error);
+ grpc_lb_policy* policy, grpc_error** connectivity_error);
/** call notify when the connectivity state of a channel changes from *state.
Updates *state with the new state of the policy. Calling with a NULL \a
state cancels the subscription. */
- void (*notify_on_state_change_locked)(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- grpc_connectivity_state *state,
- grpc_closure *closure);
+ void (*notify_on_state_change_locked)(grpc_lb_policy* policy,
+ grpc_connectivity_state* state,
+ grpc_closure* closure);
- void (*update_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_args *args);
+ void (*update_locked)(grpc_lb_policy* policy,
+ const grpc_lb_policy_args* args);
+
+ /** \see grpc_lb_policy_set_reresolve_closure */
+ void (*set_reresolve_closure_locked)(grpc_lb_policy* policy,
+ grpc_closure* request_reresolution);
};
#ifndef NDEBUG
-
-/* Strong references: the policy will shutdown when they reach zero */
#define GRPC_LB_POLICY_REF(p, r) \
grpc_lb_policy_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_LB_POLICY_UNREF(exec_ctx, p, r) \
- grpc_lb_policy_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
-
-/* Weak references: they don't prevent the shutdown of the LB policy. When no
- * strong references are left but there are still weak ones, shutdown is called.
- * Once the weak reference also reaches zero, the LB policy is destroyed. */
-#define GRPC_LB_POLICY_WEAK_REF(p, r) \
- grpc_lb_policy_weak_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, p, r) \
- grpc_lb_policy_weak_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
-void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line,
- const char *reason);
-void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const char *file, int line, const char *reason);
-void grpc_lb_policy_weak_ref(grpc_lb_policy *policy, const char *file, int line,
- const char *reason);
-void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const char *file, int line, const char *reason);
-#else
+#define GRPC_LB_POLICY_UNREF(p, r) \
+ grpc_lb_policy_unref((p), __FILE__, __LINE__, (r))
+void grpc_lb_policy_ref(grpc_lb_policy* policy, const char* file, int line,
+ const char* reason);
+void grpc_lb_policy_unref(grpc_lb_policy* policy, const char* file, int line,
+ const char* reason);
+#else // !NDEBUG
#define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p))
-#define GRPC_LB_POLICY_UNREF(cl, p, r) grpc_lb_policy_unref((cl), (p))
-#define GRPC_LB_POLICY_WEAK_REF(p, r) grpc_lb_policy_weak_ref((p))
-#define GRPC_LB_POLICY_WEAK_UNREF(cl, p, r) grpc_lb_policy_weak_unref((cl), (p))
-void grpc_lb_policy_ref(grpc_lb_policy *policy);
-void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
-void grpc_lb_policy_weak_ref(grpc_lb_policy *policy);
-void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
+#define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p))
+void grpc_lb_policy_ref(grpc_lb_policy* policy);
+void grpc_lb_policy_unref(grpc_lb_policy* policy);
#endif
/** called by concrete implementations to initialize the base struct */
-void grpc_lb_policy_init(grpc_lb_policy *policy,
- const grpc_lb_policy_vtable *vtable,
- grpc_combiner *combiner);
-
-/** Finds an appropriate subchannel for a call, based on \a pick_args.
+void grpc_lb_policy_init(grpc_lb_policy* policy,
+ const grpc_lb_policy_vtable* vtable,
+ grpc_combiner* combiner);
- \a target will be set to the selected subchannel, or NULL on failure
- or when the LB policy decides to drop the call.
+/// Shuts down \a policy.
+/// If \a new_policy is non-null, any pending picks will be restarted
+/// on that policy; otherwise, they will be failed.
+void grpc_lb_policy_shutdown_locked(grpc_lb_policy* policy,
+ grpc_lb_policy* new_policy);
- Upon success, \a user_data will be set to whatever opaque information
- may need to be propagated from the LB policy, or NULL if not needed.
- \a context will be populated with context to pass to the subchannel
- call, if needed.
+/** Finds an appropriate subchannel for a call, based on data in \a pick.
+ \a pick must remain alive until the pick is complete.
If the pick succeeds and a result is known immediately, a non-zero
- value will be returned. Otherwise, \a on_complete will be invoked
+ value will be returned. Otherwise, \a pick->on_complete will be invoked
once the pick is complete with its error argument set to indicate
success or failure.
Any IO should be done under the \a interested_parties \a grpc_pollset_set
in the \a grpc_lb_policy struct. */
-int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context,
- void **user_data, grpc_closure *on_complete);
+int grpc_lb_policy_pick_locked(grpc_lb_policy* policy,
+ grpc_lb_policy_pick_state* pick);
-/** Perform a connected subchannel ping (see \a grpc_connected_subchannel_ping)
+/** Perform a connected subchannel ping (see \a
+ grpc_core::ConnectedSubchannel::Ping)
against one of the connected subchannels managed by \a policy. */
-void grpc_lb_policy_ping_one_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- grpc_closure *closure);
+void grpc_lb_policy_ping_one_locked(grpc_lb_policy* policy,
+ grpc_closure* on_initiate,
+ grpc_closure* on_ack);
-/** Cancel picks for \a target.
+/** Cancel picks for \a pick.
The \a on_complete callback of the pending picks will be invoked with \a
*target set to NULL. */
-void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- grpc_connected_subchannel **target,
- grpc_error *error);
+void grpc_lb_policy_cancel_pick_locked(grpc_lb_policy* policy,
+ grpc_lb_policy_pick_state* pick,
+ grpc_error* error);
/** Cancel all pending picks for which their \a initial_metadata_flags (as given
in the call to \a grpc_lb_policy_pick) matches \a initial_metadata_flags_eq
when AND'd with \a initial_metadata_flags_mask */
-void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
+void grpc_lb_policy_cancel_picks_locked(grpc_lb_policy* policy,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
- grpc_error *error);
+ grpc_error* error);
/** Try to enter a READY connectivity state */
-void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy);
+void grpc_lb_policy_exit_idle_locked(grpc_lb_policy* policy);
/* Call notify when the connectivity state of a channel changes from \a *state.
* Updates \a *state with the new state of the policy */
void grpc_lb_policy_notify_on_state_change_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_connectivity_state *state, grpc_closure *closure);
+ grpc_lb_policy* policy, grpc_connectivity_state* state,
+ grpc_closure* closure);
grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_error **connectivity_error);
+ grpc_lb_policy* policy, grpc_error** connectivity_error);
/** Update \a policy with \a lb_policy_args. */
-void grpc_lb_policy_update_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
- const grpc_lb_policy_args *lb_policy_args);
+void grpc_lb_policy_update_locked(grpc_lb_policy* policy,
+ const grpc_lb_policy_args* lb_policy_args);
+
+/** Set the re-resolution closure to \a request_reresolution. */
+void grpc_lb_policy_set_reresolve_closure_locked(
+ grpc_lb_policy* policy, grpc_closure* request_reresolution);
+
+/** Try to request a re-resolution. It's NOT a public API; it's only for use by
+ the LB policy implementations. */
+void grpc_lb_policy_try_reresolve(grpc_lb_policy* policy,
+ grpc_core::TraceFlag* grpc_lb_trace,
+ grpc_error* error);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
deleted file mode 100644
index 7ad322902b..0000000000
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
+++ /dev/null
@@ -1,137 +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 "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
-
-#include <grpc/support/atm.h>
-#include <grpc/support/log.h>
-
-#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
-#include "src/core/lib/iomgr/error.h"
-#include "src/core/lib/profiling/timers.h"
-
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- return GRPC_ERROR_NONE;
-}
-
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
-
-typedef struct {
- // Stats object to update.
- grpc_grpclb_client_stats *client_stats;
- // State for intercepting send_initial_metadata.
- grpc_closure on_complete_for_send;
- grpc_closure *original_on_complete_for_send;
- bool send_initial_metadata_succeeded;
- // State for intercepting recv_initial_metadata.
- grpc_closure recv_initial_metadata_ready;
- grpc_closure *original_recv_initial_metadata_ready;
- bool recv_initial_metadata_succeeded;
-} call_data;
-
-static void on_complete_for_send(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- call_data *calld = (call_data *)arg;
- if (error == GRPC_ERROR_NONE) {
- calld->send_initial_metadata_succeeded = true;
- }
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_on_complete_for_send,
- GRPC_ERROR_REF(error));
-}
-
-static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- call_data *calld = (call_data *)arg;
- if (error == GRPC_ERROR_NONE) {
- calld->recv_initial_metadata_succeeded = true;
- }
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
- GRPC_ERROR_REF(error));
-}
-
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
- // Get stats object from context and take a ref.
- GPR_ASSERT(args->context != NULL);
- GPR_ASSERT(args->context[GRPC_GRPCLB_CLIENT_STATS].value != NULL);
- calld->client_stats = grpc_grpclb_client_stats_ref(
- (grpc_grpclb_client_stats *)args->context[GRPC_GRPCLB_CLIENT_STATS]
- .value);
- // Record call started.
- grpc_grpclb_client_stats_add_call_started(calld->client_stats);
- return GRPC_ERROR_NONE;
-}
-
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *calld = (call_data *)elem->call_data;
- // Record call finished, optionally setting client_failed_to_send and
- // received.
- grpc_grpclb_client_stats_add_call_finished(
- !calld->send_initial_metadata_succeeded /* client_failed_to_send */,
- calld->recv_initial_metadata_succeeded /* known_received */,
- calld->client_stats);
- // All done, so unref the stats object.
- grpc_grpclb_client_stats_unref(calld->client_stats);
-}
-
-static void start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = (call_data *)elem->call_data;
- GPR_TIMER_BEGIN("clr_start_transport_stream_op_batch", 0);
- // Intercept send_initial_metadata.
- if (batch->send_initial_metadata) {
- calld->original_on_complete_for_send = batch->on_complete;
- GRPC_CLOSURE_INIT(&calld->on_complete_for_send, on_complete_for_send, calld,
- grpc_schedule_on_exec_ctx);
- batch->on_complete = &calld->on_complete_for_send;
- }
- // Intercept recv_initial_metadata.
- if (batch->recv_initial_metadata) {
- calld->original_recv_initial_metadata_ready =
- batch->payload->recv_initial_metadata.recv_initial_metadata_ready;
- GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
- recv_initial_metadata_ready, calld,
- grpc_schedule_on_exec_ctx);
- batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
- &calld->recv_initial_metadata_ready;
- }
- // Chain to next filter.
- grpc_call_next_op(exec_ctx, elem, batch);
- GPR_TIMER_END("clr_start_transport_stream_op_batch", 0);
-}
-
-const grpc_channel_filter grpc_client_load_reporting_filter = {
- start_transport_stream_op_batch,
- grpc_channel_next_op,
- sizeof(call_data),
- init_call_elem,
- grpc_call_stack_ignore_set_pollset_or_pollset_set,
- destroy_call_elem,
- 0, // sizeof(channel_data)
- init_channel_elem,
- destroy_channel_elem,
- grpc_channel_next_get_info,
- "client_load_reporting"};
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
new file mode 100644
index 0000000000..4596f90745
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
@@ -0,0 +1,137 @@
+/*
+ *
+ * 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 "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
+
+#include <grpc/support/atm.h>
+#include <grpc/support/log.h>
+
+#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/profiling/timers.h"
+
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ return GRPC_ERROR_NONE;
+}
+
+static void destroy_channel_elem(grpc_channel_element* elem) {}
+
+namespace {
+struct call_data {
+ // Stats object to update.
+ grpc_grpclb_client_stats* client_stats;
+ // State for intercepting send_initial_metadata.
+ grpc_closure on_complete_for_send;
+ grpc_closure* original_on_complete_for_send;
+ bool send_initial_metadata_succeeded;
+ // State for intercepting recv_initial_metadata.
+ grpc_closure recv_initial_metadata_ready;
+ grpc_closure* original_recv_initial_metadata_ready;
+ bool recv_initial_metadata_succeeded;
+};
+} // namespace
+
+static void on_complete_for_send(void* arg, grpc_error* error) {
+ call_data* calld = (call_data*)arg;
+ if (error == GRPC_ERROR_NONE) {
+ calld->send_initial_metadata_succeeded = true;
+ }
+ GRPC_CLOSURE_RUN(calld->original_on_complete_for_send, GRPC_ERROR_REF(error));
+}
+
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
+ call_data* calld = (call_data*)arg;
+ if (error == GRPC_ERROR_NONE) {
+ calld->recv_initial_metadata_succeeded = true;
+ }
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready,
+ GRPC_ERROR_REF(error));
+}
+
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
+ // Get stats object from context and take a ref.
+ GPR_ASSERT(args->context != nullptr);
+ if (args->context[GRPC_GRPCLB_CLIENT_STATS].value != nullptr) {
+ calld->client_stats = grpc_grpclb_client_stats_ref(
+ (grpc_grpclb_client_stats*)args->context[GRPC_GRPCLB_CLIENT_STATS]
+ .value);
+ // Record call started.
+ grpc_grpclb_client_stats_add_call_started(calld->client_stats);
+ }
+ return GRPC_ERROR_NONE;
+}
+
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ call_data* calld = (call_data*)elem->call_data;
+ if (calld->client_stats != nullptr) {
+ // Record call finished, optionally setting client_failed_to_send and
+ // received.
+ grpc_grpclb_client_stats_add_call_finished(
+ !calld->send_initial_metadata_succeeded /* client_failed_to_send */,
+ calld->recv_initial_metadata_succeeded /* known_received */,
+ calld->client_stats);
+ // All done, so unref the stats object.
+ grpc_grpclb_client_stats_unref(calld->client_stats);
+ }
+}
+
+static void start_transport_stream_op_batch(
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
+ GPR_TIMER_BEGIN("clr_start_transport_stream_op_batch", 0);
+ if (calld->client_stats != nullptr) {
+ // Intercept send_initial_metadata.
+ if (batch->send_initial_metadata) {
+ calld->original_on_complete_for_send = batch->on_complete;
+ GRPC_CLOSURE_INIT(&calld->on_complete_for_send, on_complete_for_send,
+ calld, grpc_schedule_on_exec_ctx);
+ batch->on_complete = &calld->on_complete_for_send;
+ }
+ // Intercept recv_initial_metadata.
+ if (batch->recv_initial_metadata) {
+ calld->original_recv_initial_metadata_ready =
+ batch->payload->recv_initial_metadata.recv_initial_metadata_ready;
+ GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
+ recv_initial_metadata_ready, calld,
+ grpc_schedule_on_exec_ctx);
+ batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
+ &calld->recv_initial_metadata_ready;
+ }
+ }
+ // Chain to next filter.
+ grpc_call_next_op(elem, batch);
+ GPR_TIMER_END("clr_start_transport_stream_op_batch", 0);
+}
+
+const grpc_channel_filter grpc_client_load_reporting_filter = {
+ start_transport_stream_op_batch,
+ grpc_channel_next_op,
+ sizeof(call_data),
+ init_call_elem,
+ grpc_call_stack_ignore_set_pollset_or_pollset_set,
+ destroy_call_elem,
+ 0, // sizeof(channel_data)
+ init_channel_elem,
+ destroy_channel_elem,
+ grpc_channel_next_get_info,
+ "client_load_reporting"};
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
index 51e30b20b8..04de7a04df 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
@@ -24,4 +24,4 @@
extern const grpc_channel_filter grpc_client_load_reporting_filter;
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H \
- */
+ */
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
deleted file mode 100644
index 85ef7894ea..0000000000
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
+++ /dev/null
@@ -1,1915 +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.
- *
- */
-
-/** Implementation of the gRPC LB policy.
- *
- * This policy takes as input a set of resolved addresses {a1..an} for which the
- * LB set was set (it's the resolver's responsibility to ensure this). That is
- * to say, {a1..an} represent a collection of LB servers.
- *
- * An internal channel (\a glb_lb_policy.lb_channel) is created over {a1..an}.
- * This channel behaves just like a regular channel. In particular, the
- * constructed URI over the addresses a1..an will use the default pick first
- * policy to select from this list of LB server backends.
- *
- * The first time the policy gets a request for a pick, a ping, or to exit the
- * idle state, \a query_for_backends_locked() is called. This function sets up
- * and initiates the internal communication with the LB server. In particular,
- * it's responsible for instantiating the internal *streaming* call to the LB
- * server (whichever address from {a1..an} pick-first chose). This call is
- * serviced by two callbacks, \a lb_on_server_status_received and \a
- * lb_on_response_received. The former will be called when the call to the LB
- * server completes. This can happen if the LB server closes the connection or
- * if this policy itself cancels the call (for example because it's shutting
- * down). If the internal call times out, the usual behavior of pick-first
- * applies, continuing to pick from the list {a1..an}.
- *
- * Upon sucesss, the incoming \a LoadBalancingResponse is processed by \a
- * res_recv. An invalid one results in the termination of the streaming call. A
- * new streaming call should be created if possible, failing the original call
- * otherwise. For a valid \a LoadBalancingResponse, the server list of actual
- * backends is extracted. A Round Robin policy will be created from this list.
- * There are two possible scenarios:
- *
- * 1. This is the first server list received. There was no previous instance of
- * the Round Robin policy. \a rr_handover_locked() will instantiate the RR
- * policy and perform all the pending operations over it.
- * 2. There's already a RR policy instance active. We need to introduce the new
- * one build from the new serverlist, but taking care not to disrupt the
- * operations in progress over the old RR instance. This is done by
- * decreasing the reference count on the old policy. The moment no more
- * references are held on the old RR policy, it'll be destroyed and \a
- * glb_rr_connectivity_changed notified with a \a GRPC_CHANNEL_SHUTDOWN
- * state. At this point we can transition to a new RR instance safely, which
- * is done once again via \a rr_handover_locked().
- *
- *
- * Once a RR policy instance is in place (and getting updated as described),
- * calls to for a pick, a ping or a cancellation will be serviced right away by
- * forwarding them to the RR instance. Any time there's no RR policy available
- * (ie, right after the creation of the gRPCLB policy, if an empty serverlist is
- * received, etc), pick/ping requests are added to a list of pending picks/pings
- * to be flushed and serviced as part of \a rr_handover_locked() the moment the
- * RR policy instance becomes available.
- *
- * \see https://github.com/grpc/grpc/blob/master/doc/load-balancing.md for the
- * high level design and details. */
-
-/* TODO(dgq):
- * - Implement LB service forwarding (point 2c. in the doc's diagram).
- */
-
-/* With the addition of a libuv endpoint, sockaddr.h now includes uv.h when
- using that endpoint. Because of various transitive includes in uv.h,
- including windows.h on Windows, uv.h must be included before other system
- headers. Therefore, sockaddr.h must always be included first */
-#include "src/core/lib/iomgr/sockaddr.h"
-
-#include <limits.h>
-#include <string.h>
-
-#include <grpc/byte_buffer_reader.h>
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/host_port.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/time.h>
-
-#include "src/core/ext/filters/client_channel/client_channel.h"
-#include "src/core/ext/filters/client_channel/client_channel_factory.h"
-#include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
-#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
-#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
-#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
-#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
-#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
-#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
-#include "src/core/ext/filters/client_channel/parse_address.h"
-#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
-#include "src/core/ext/filters/client_channel/subchannel_index.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/channel/channel_stack.h"
-#include "src/core/lib/iomgr/combiner.h"
-#include "src/core/lib/iomgr/sockaddr.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/slice/slice_hash_table.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/backoff.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/surface/call.h"
-#include "src/core/lib/surface/channel.h"
-#include "src/core/lib/surface/channel_init.h"
-#include "src/core/lib/transport/static_metadata.h"
-
-#define GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS 20
-#define GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS 1
-#define GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER 1.6
-#define GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS 120
-#define GRPC_GRPCLB_RECONNECT_JITTER 0.2
-
-grpc_tracer_flag grpc_lb_glb_trace = GRPC_TRACER_INITIALIZER(false, "glb");
-
-/* add lb_token of selected subchannel (address) to the call's initial
- * metadata */
-static grpc_error *initial_metadata_add_lb_token(
- grpc_exec_ctx *exec_ctx, grpc_metadata_batch *initial_metadata,
- grpc_linked_mdelem *lb_token_mdelem_storage, grpc_mdelem lb_token) {
- GPR_ASSERT(lb_token_mdelem_storage != NULL);
- GPR_ASSERT(!GRPC_MDISNULL(lb_token));
- return grpc_metadata_batch_add_tail(exec_ctx, initial_metadata,
- lb_token_mdelem_storage, lb_token);
-}
-
-static void destroy_client_stats(void *arg) {
- grpc_grpclb_client_stats_unref((grpc_grpclb_client_stats *)arg);
-}
-
-typedef struct wrapped_rr_closure_arg {
- /* the closure instance using this struct as argument */
- grpc_closure wrapper_closure;
-
- /* the original closure. Usually a on_complete/notify cb for pick() and ping()
- * calls against the internal RR instance, respectively. */
- grpc_closure *wrapped_closure;
-
- /* the pick's initial metadata, kept in order to append the LB token for the
- * pick */
- grpc_metadata_batch *initial_metadata;
-
- /* the picked target, used to determine which LB token to add to the pick's
- * initial metadata */
- grpc_connected_subchannel **target;
-
- /* the context to be populated for the subchannel call */
- grpc_call_context_element *context;
-
- /* Stats for client-side load reporting. Note that this holds a
- * reference, which must be either passed on via context or unreffed. */
- grpc_grpclb_client_stats *client_stats;
-
- /* the LB token associated with the pick */
- grpc_mdelem lb_token;
-
- /* storage for the lb token initial metadata mdelem */
- grpc_linked_mdelem *lb_token_mdelem_storage;
-
- /* The RR instance related to the closure */
- grpc_lb_policy *rr_policy;
-
- /* heap memory to be freed upon closure execution. */
- void *free_when_done;
-} wrapped_rr_closure_arg;
-
-/* The \a on_complete closure passed as part of the pick requires keeping a
- * reference to its associated round robin instance. We wrap this closure in
- * order to unref the round robin instance upon its invocation */
-static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- wrapped_rr_closure_arg *wc_arg = (wrapped_rr_closure_arg *)arg;
-
- GPR_ASSERT(wc_arg->wrapped_closure != NULL);
- GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error));
-
- if (wc_arg->rr_policy != NULL) {
- /* if *target is NULL, no pick has been made by the RR policy (eg, all
- * addresses failed to connect). There won't be any user_data/token
- * available */
- if (*wc_arg->target != NULL) {
- if (!GRPC_MDISNULL(wc_arg->lb_token)) {
- initial_metadata_add_lb_token(exec_ctx, wc_arg->initial_metadata,
- wc_arg->lb_token_mdelem_storage,
- GRPC_MDELEM_REF(wc_arg->lb_token));
- } else {
- gpr_log(GPR_ERROR,
- "No LB token for connected subchannel pick %p (from RR "
- "instance %p).",
- (void *)*wc_arg->target, (void *)wc_arg->rr_policy);
- abort();
- }
- // Pass on client stats via context. Passes ownership of the reference.
- GPR_ASSERT(wc_arg->client_stats != NULL);
- wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].value = wc_arg->client_stats;
- wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats;
- } else {
- grpc_grpclb_client_stats_unref(wc_arg->client_stats);
- }
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Unreffing RR %p", (void *)wc_arg->rr_policy);
- }
- GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "wrapped_rr_closure");
- }
- GPR_ASSERT(wc_arg->free_when_done != NULL);
- gpr_free(wc_arg->free_when_done);
-}
-
-/* Linked list of pending pick requests. It stores all information needed to
- * eventually call (Round Robin's) pick() on them. They mainly stay pending
- * waiting for the RR policy to be created/updated.
- *
- * One particularity is the wrapping of the user-provided \a on_complete closure
- * (in \a wrapped_on_complete and \a wrapped_on_complete_arg). This is needed in
- * order to correctly unref the RR policy instance upon completion of the pick.
- * See \a wrapped_rr_closure for details. */
-typedef struct pending_pick {
- struct pending_pick *next;
-
- /* original pick()'s arguments */
- grpc_lb_policy_pick_args pick_args;
-
- /* output argument where to store the pick()ed connected subchannel, or NULL
- * upon error. */
- grpc_connected_subchannel **target;
-
- /* args for wrapped_on_complete */
- wrapped_rr_closure_arg wrapped_on_complete_arg;
-} pending_pick;
-
-static void add_pending_pick(pending_pick **root,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context,
- grpc_closure *on_complete) {
- pending_pick *pp = (pending_pick *)gpr_zalloc(sizeof(*pp));
- pp->next = *root;
- pp->pick_args = *pick_args;
- pp->target = target;
- pp->wrapped_on_complete_arg.wrapped_closure = on_complete;
- pp->wrapped_on_complete_arg.target = target;
- pp->wrapped_on_complete_arg.context = context;
- pp->wrapped_on_complete_arg.initial_metadata = pick_args->initial_metadata;
- pp->wrapped_on_complete_arg.lb_token_mdelem_storage =
- pick_args->lb_token_mdelem_storage;
- pp->wrapped_on_complete_arg.free_when_done = pp;
- GRPC_CLOSURE_INIT(&pp->wrapped_on_complete_arg.wrapper_closure,
- wrapped_rr_closure, &pp->wrapped_on_complete_arg,
- grpc_schedule_on_exec_ctx);
- *root = pp;
-}
-
-/* Same as the \a pending_pick struct but for ping operations */
-typedef struct pending_ping {
- struct pending_ping *next;
-
- /* args for wrapped_notify */
- wrapped_rr_closure_arg wrapped_notify_arg;
-} pending_ping;
-
-static void add_pending_ping(pending_ping **root, grpc_closure *notify) {
- pending_ping *pping = (pending_ping *)gpr_zalloc(sizeof(*pping));
- pping->wrapped_notify_arg.wrapped_closure = notify;
- pping->wrapped_notify_arg.free_when_done = pping;
- pping->next = *root;
- GRPC_CLOSURE_INIT(&pping->wrapped_notify_arg.wrapper_closure,
- wrapped_rr_closure, &pping->wrapped_notify_arg,
- grpc_schedule_on_exec_ctx);
- *root = pping;
-}
-
-/*
- * glb_lb_policy
- */
-typedef struct rr_connectivity_data rr_connectivity_data;
-
-typedef struct glb_lb_policy {
- /** base policy: must be first */
- grpc_lb_policy base;
-
- /** who the client is trying to communicate with */
- const char *server_name;
- grpc_client_channel_factory *cc_factory;
- grpc_channel_args *args;
-
- /** timeout in milliseconds for the LB call. 0 means no deadline. */
- int lb_call_timeout_ms;
-
- /** for communicating with the LB server */
- grpc_channel *lb_channel;
-
- /** response generator to inject address updates into \a lb_channel */
- grpc_fake_resolver_response_generator *response_generator;
-
- /** the RR policy to use of the backend servers returned by the LB server */
- grpc_lb_policy *rr_policy;
-
- bool started_picking;
-
- /** our connectivity state tracker */
- grpc_connectivity_state_tracker state_tracker;
-
- /** connectivity state of the LB channel */
- grpc_connectivity_state lb_channel_connectivity;
-
- /** stores the deserialized response from the LB. May be NULL until one such
- * response has arrived. */
- grpc_grpclb_serverlist *serverlist;
-
- /** Index into serverlist for next pick.
- * If the server at this index is a drop, we return a drop.
- * Otherwise, we delegate to the RR policy. */
- size_t serverlist_index;
-
- /** list of picks that are waiting on RR's policy connectivity */
- pending_pick *pending_picks;
-
- /** list of pings that are waiting on RR's policy connectivity */
- pending_ping *pending_pings;
-
- bool shutting_down;
-
- /** are we currently updating lb_call? */
- bool updating_lb_call;
-
- /** are we currently updating lb_channel? */
- bool updating_lb_channel;
-
- /** are we already watching the LB channel's connectivity? */
- bool watching_lb_channel;
-
- /** is \a lb_call_retry_timer active? */
- bool retry_timer_active;
-
- /** called upon changes to the LB channel's connectivity. */
- grpc_closure lb_channel_on_connectivity_changed;
-
- /** args from the latest update received while already updating, or NULL */
- grpc_lb_policy_args *pending_update_args;
-
- /************************************************************/
- /* client data associated with the LB server communication */
- /************************************************************/
- /* Finished sending initial request. */
- grpc_closure lb_on_sent_initial_request;
-
- /* Status from the LB server has been received. This signals the end of the LB
- * call. */
- grpc_closure lb_on_server_status_received;
-
- /* A response from the LB server has been received. Process it */
- grpc_closure lb_on_response_received;
-
- /* LB call retry timer callback. */
- grpc_closure lb_on_call_retry;
-
- grpc_call *lb_call; /* streaming call to the LB server, */
-
- grpc_metadata_array lb_initial_metadata_recv; /* initial MD from LB server */
- grpc_metadata_array
- lb_trailing_metadata_recv; /* trailing MD from LB server */
-
- /* what's being sent to the LB server. Note that its value may vary if the LB
- * server indicates a redirect. */
- grpc_byte_buffer *lb_request_payload;
-
- /* response the LB server, if any. Processed in lb_on_response_received() */
- grpc_byte_buffer *lb_response_payload;
-
- /* call status code and details, set in lb_on_server_status_received() */
- grpc_status_code lb_call_status;
- grpc_slice lb_call_status_details;
-
- /** LB call retry backoff state */
- gpr_backoff lb_call_backoff_state;
-
- /** LB call retry timer */
- grpc_timer lb_call_retry_timer;
-
- bool initial_request_sent;
- bool seen_initial_response;
-
- /* Stats for client-side load reporting. Should be unreffed and
- * recreated whenever lb_call is replaced. */
- grpc_grpclb_client_stats *client_stats;
- /* Interval and timer for next client load report. */
- gpr_timespec client_stats_report_interval;
- grpc_timer client_load_report_timer;
- bool client_load_report_timer_pending;
- bool last_client_load_report_counters_were_zero;
- /* Closure used for either the load report timer or the callback for
- * completion of sending the load report. */
- grpc_closure client_load_report_closure;
- /* Client load report message payload. */
- grpc_byte_buffer *client_load_report_payload;
-} glb_lb_policy;
-
-/* Keeps track and reacts to changes in connectivity of the RR instance */
-struct rr_connectivity_data {
- grpc_closure on_change;
- grpc_connectivity_state state;
- glb_lb_policy *glb_policy;
-};
-
-static bool is_server_valid(const grpc_grpclb_server *server, size_t idx,
- bool log) {
- if (server->drop) return false;
- const grpc_grpclb_ip_address *ip = &server->ip_address;
- if (server->port >> 16 != 0) {
- if (log) {
- gpr_log(GPR_ERROR,
- "Invalid port '%d' at index %lu of serverlist. Ignoring.",
- server->port, (unsigned long)idx);
- }
- return false;
- }
- if (ip->size != 4 && ip->size != 16) {
- if (log) {
- gpr_log(GPR_ERROR,
- "Expected IP to be 4 or 16 bytes, got %d at index %lu of "
- "serverlist. Ignoring",
- ip->size, (unsigned long)idx);
- }
- return false;
- }
- return true;
-}
-
-/* vtable for LB tokens in grpc_lb_addresses. */
-static void *lb_token_copy(void *token) {
- return token == NULL
- ? NULL
- : (void *)GRPC_MDELEM_REF((grpc_mdelem){(uintptr_t)token}).payload;
-}
-static void lb_token_destroy(grpc_exec_ctx *exec_ctx, void *token) {
- if (token != NULL) {
- GRPC_MDELEM_UNREF(exec_ctx, (grpc_mdelem){(uintptr_t)token});
- }
-}
-static int lb_token_cmp(void *token1, void *token2) {
- if (token1 > token2) return 1;
- if (token1 < token2) return -1;
- return 0;
-}
-static const grpc_lb_user_data_vtable lb_token_vtable = {
- lb_token_copy, lb_token_destroy, lb_token_cmp};
-
-static void parse_server(const grpc_grpclb_server *server,
- grpc_resolved_address *addr) {
- memset(addr, 0, sizeof(*addr));
- if (server->drop) return;
- const uint16_t netorder_port = htons((uint16_t)server->port);
- /* the addresses are given in binary format (a in(6)_addr struct) in
- * server->ip_address.bytes. */
- const grpc_grpclb_ip_address *ip = &server->ip_address;
- if (ip->size == 4) {
- addr->len = sizeof(struct sockaddr_in);
- struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr->addr;
- addr4->sin_family = AF_INET;
- memcpy(&addr4->sin_addr, ip->bytes, ip->size);
- addr4->sin_port = netorder_port;
- } else if (ip->size == 16) {
- addr->len = sizeof(struct sockaddr_in6);
- struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr->addr;
- addr6->sin6_family = AF_INET6;
- memcpy(&addr6->sin6_addr, ip->bytes, ip->size);
- addr6->sin6_port = netorder_port;
- }
-}
-
-/* Returns addresses extracted from \a serverlist. */
-static grpc_lb_addresses *process_serverlist_locked(
- grpc_exec_ctx *exec_ctx, const grpc_grpclb_serverlist *serverlist) {
- size_t num_valid = 0;
- /* first pass: count how many are valid in order to allocate the necessary
- * memory in a single block */
- for (size_t i = 0; i < serverlist->num_servers; ++i) {
- if (is_server_valid(serverlist->servers[i], i, true)) ++num_valid;
- }
- grpc_lb_addresses *lb_addresses =
- grpc_lb_addresses_create(num_valid, &lb_token_vtable);
- /* second pass: actually populate the addresses and LB tokens (aka user data
- * to the outside world) to be read by the RR policy during its creation.
- * Given that the validity tests are very cheap, they are performed again
- * instead of marking the valid ones during the first pass, as this would
- * incurr in an allocation due to the arbitrary number of server */
- size_t addr_idx = 0;
- for (size_t sl_idx = 0; sl_idx < serverlist->num_servers; ++sl_idx) {
- const grpc_grpclb_server *server = serverlist->servers[sl_idx];
- if (!is_server_valid(serverlist->servers[sl_idx], sl_idx, false)) continue;
- GPR_ASSERT(addr_idx < num_valid);
- /* address processing */
- grpc_resolved_address addr;
- parse_server(server, &addr);
- /* lb token processing */
- void *user_data;
- if (server->has_load_balance_token) {
- const size_t lb_token_max_length =
- GPR_ARRAY_SIZE(server->load_balance_token);
- const size_t lb_token_length =
- strnlen(server->load_balance_token, lb_token_max_length);
- grpc_slice lb_token_mdstr = grpc_slice_from_copied_buffer(
- server->load_balance_token, lb_token_length);
- user_data = (void *)grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_LB_TOKEN,
- lb_token_mdstr)
- .payload;
- } else {
- char *uri = grpc_sockaddr_to_uri(&addr);
- gpr_log(GPR_INFO,
- "Missing LB token for backend address '%s'. The empty token will "
- "be used instead",
- uri);
- gpr_free(uri);
- user_data = (void *)GRPC_MDELEM_LB_TOKEN_EMPTY.payload;
- }
-
- grpc_lb_addresses_set_address(lb_addresses, addr_idx, &addr.addr, addr.len,
- false /* is_balancer */,
- NULL /* balancer_name */, user_data);
- ++addr_idx;
- }
- GPR_ASSERT(addr_idx == num_valid);
- return lb_addresses;
-}
-
-static void update_lb_connectivity_status_locked(
- grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy,
- grpc_connectivity_state rr_state, grpc_error *rr_state_error) {
- const grpc_connectivity_state curr_glb_state =
- grpc_connectivity_state_check(&glb_policy->state_tracker);
-
- /* The new connectivity status is a function of the previous one and the new
- * input coming from the status of the RR policy.
- *
- * current state (grpclb's)
- * |
- * v || I | C | R | TF | SD | <- new state (RR's)
- * ===++====+=====+=====+======+======+
- * I || I | C | R | [I] | [I] |
- * ---++----+-----+-----+------+------+
- * C || I | C | R | [C] | [C] |
- * ---++----+-----+-----+------+------+
- * R || I | C | R | [R] | [R] |
- * ---++----+-----+-----+------+------+
- * TF || I | C | R | [TF] | [TF] |
- * ---++----+-----+-----+------+------+
- * SD || NA | NA | NA | NA | NA | (*)
- * ---++----+-----+-----+------+------+
- *
- * A [STATE] indicates that the old RR policy is kept. In those cases, STATE
- * is the current state of grpclb, which is left untouched.
- *
- * In summary, if the new state is TRANSIENT_FAILURE or SHUTDOWN, stick to
- * the previous RR instance.
- *
- * Note that the status is never updated to SHUTDOWN as a result of calling
- * this function. Only glb_shutdown() has the power to set that state.
- *
- * (*) This function mustn't be called during shutting down. */
- GPR_ASSERT(curr_glb_state != GRPC_CHANNEL_SHUTDOWN);
-
- switch (rr_state) {
- case GRPC_CHANNEL_TRANSIENT_FAILURE:
- case GRPC_CHANNEL_SHUTDOWN:
- GPR_ASSERT(rr_state_error != GRPC_ERROR_NONE);
- break;
- case GRPC_CHANNEL_INIT:
- case GRPC_CHANNEL_IDLE:
- case GRPC_CHANNEL_CONNECTING:
- case GRPC_CHANNEL_READY:
- GPR_ASSERT(rr_state_error == GRPC_ERROR_NONE);
- }
-
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(
- GPR_INFO, "Setting grpclb's state to %s from new RR policy %p state.",
- grpc_connectivity_state_name(rr_state), (void *)glb_policy->rr_policy);
- }
- grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker, rr_state,
- rr_state_error,
- "update_lb_connectivity_status_locked");
-}
-
-/* Perform a pick over \a glb_policy->rr_policy. Given that a pick can return
- * immediately (ignoring its completion callback), we need to perform the
- * cleanups this callback would otherwise be resposible for.
- * If \a force_async is true, then we will manually schedule the
- * completion callback even if the pick is available immediately. */
-static bool pick_from_internal_rr_locked(
- grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy,
- const grpc_lb_policy_pick_args *pick_args, bool force_async,
- grpc_connected_subchannel **target, wrapped_rr_closure_arg *wc_arg) {
- // Look at the index into the serverlist to see if we should drop this call.
- grpc_grpclb_server *server =
- glb_policy->serverlist->servers[glb_policy->serverlist_index++];
- if (glb_policy->serverlist_index == glb_policy->serverlist->num_servers) {
- glb_policy->serverlist_index = 0; // Wrap-around.
- }
- if (server->drop) {
- // Not using the RR policy, so unref it.
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Unreffing RR for drop (0x%" PRIxPTR ")",
- (intptr_t)wc_arg->rr_policy);
- }
- GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync");
- // Update client load reporting stats to indicate the number of
- // dropped calls. Note that we have to do this here instead of in
- // the client_load_reporting filter, because we do not create a
- // subchannel call (and therefore no client_load_reporting filter)
- // for dropped calls.
- grpc_grpclb_client_stats_add_call_dropped_locked(server->load_balance_token,
- wc_arg->client_stats);
- grpc_grpclb_client_stats_unref(wc_arg->client_stats);
- if (force_async) {
- GPR_ASSERT(wc_arg->wrapped_closure != NULL);
- GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE);
- gpr_free(wc_arg->free_when_done);
- return false;
- }
- gpr_free(wc_arg->free_when_done);
- return true;
- }
- // Pick via the RR policy.
- const bool pick_done = grpc_lb_policy_pick_locked(
- exec_ctx, wc_arg->rr_policy, pick_args, target, wc_arg->context,
- (void **)&wc_arg->lb_token, &wc_arg->wrapper_closure);
- if (pick_done) {
- /* synchronous grpc_lb_policy_pick call. Unref the RR policy. */
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")",
- (intptr_t)wc_arg->rr_policy);
- }
- GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync");
- /* add the load reporting initial metadata */
- initial_metadata_add_lb_token(exec_ctx, pick_args->initial_metadata,
- pick_args->lb_token_mdelem_storage,
- GRPC_MDELEM_REF(wc_arg->lb_token));
- // Pass on client stats via context. Passes ownership of the reference.
- GPR_ASSERT(wc_arg->client_stats != NULL);
- wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].value = wc_arg->client_stats;
- wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats;
- if (force_async) {
- GPR_ASSERT(wc_arg->wrapped_closure != NULL);
- GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE);
- gpr_free(wc_arg->free_when_done);
- return false;
- }
- gpr_free(wc_arg->free_when_done);
- }
- /* else, the pending pick will be registered and taken care of by the
- * pending pick list inside the RR policy (glb_policy->rr_policy).
- * Eventually, wrapped_on_complete will be called, which will -among other
- * things- add the LB token to the call's initial metadata */
- return pick_done;
-}
-
-static grpc_lb_policy_args *lb_policy_args_create(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- grpc_lb_addresses *addresses =
- process_serverlist_locked(exec_ctx, glb_policy->serverlist);
- GPR_ASSERT(addresses != NULL);
- grpc_lb_policy_args *args = (grpc_lb_policy_args *)gpr_zalloc(sizeof(*args));
- args->client_channel_factory = glb_policy->cc_factory;
- args->combiner = glb_policy->base.combiner;
- // Replace the LB addresses in the channel args that we pass down to
- // the subchannel.
- static const char *keys_to_remove[] = {GRPC_ARG_LB_ADDRESSES};
- const grpc_arg arg = grpc_lb_addresses_create_channel_arg(addresses);
- args->args = grpc_channel_args_copy_and_add_and_remove(
- glb_policy->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &arg,
- 1);
- grpc_lb_addresses_destroy(exec_ctx, addresses);
- return args;
-}
-
-static void lb_policy_args_destroy(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy_args *args) {
- grpc_channel_args_destroy(exec_ctx, args->args);
- gpr_free(args);
-}
-
-static void glb_rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error);
-static void create_rr_locked(grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy,
- grpc_lb_policy_args *args) {
- GPR_ASSERT(glb_policy->rr_policy == NULL);
-
- grpc_lb_policy *new_rr_policy =
- grpc_lb_policy_create(exec_ctx, "round_robin", args);
- if (new_rr_policy == NULL) {
- gpr_log(GPR_ERROR,
- "Failure creating a RoundRobin policy for serverlist update with "
- "%lu entries. The previous RR instance (%p), if any, will continue "
- "to be used. Future updates from the LB will attempt to create new "
- "instances.",
- (unsigned long)glb_policy->serverlist->num_servers,
- (void *)glb_policy->rr_policy);
- return;
- }
- glb_policy->rr_policy = new_rr_policy;
- grpc_error *rr_state_error = NULL;
- const grpc_connectivity_state rr_state =
- grpc_lb_policy_check_connectivity_locked(exec_ctx, glb_policy->rr_policy,
- &rr_state_error);
- /* Connectivity state is a function of the RR policy updated/created */
- update_lb_connectivity_status_locked(exec_ctx, glb_policy, rr_state,
- rr_state_error);
- /* Add the gRPC LB's interested_parties pollset_set to that of the newly
- * created RR policy. This will make the RR policy progress upon activity on
- * gRPC LB, which in turn is tied to the application's call */
- grpc_pollset_set_add_pollset_set(exec_ctx,
- glb_policy->rr_policy->interested_parties,
- glb_policy->base.interested_parties);
-
- /* Allocate the data for the tracking of the new RR policy's connectivity.
- * It'll be deallocated in glb_rr_connectivity_changed() */
- rr_connectivity_data *rr_connectivity =
- (rr_connectivity_data *)gpr_zalloc(sizeof(rr_connectivity_data));
- GRPC_CLOSURE_INIT(&rr_connectivity->on_change,
- glb_rr_connectivity_changed_locked, rr_connectivity,
- grpc_combiner_scheduler(glb_policy->base.combiner));
- rr_connectivity->glb_policy = glb_policy;
- rr_connectivity->state = rr_state;
-
- /* Subscribe to changes to the connectivity of the new RR */
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "glb_rr_connectivity_cb");
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, glb_policy->rr_policy,
- &rr_connectivity->state,
- &rr_connectivity->on_change);
- grpc_lb_policy_exit_idle_locked(exec_ctx, glb_policy->rr_policy);
-
- /* Update picks and pings in wait */
- pending_pick *pp;
- while ((pp = glb_policy->pending_picks)) {
- glb_policy->pending_picks = pp->next;
- GRPC_LB_POLICY_REF(glb_policy->rr_policy, "rr_handover_pending_pick");
- pp->wrapped_on_complete_arg.rr_policy = glb_policy->rr_policy;
- pp->wrapped_on_complete_arg.client_stats =
- grpc_grpclb_client_stats_ref(glb_policy->client_stats);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Pending pick about to (async) PICK from %p",
- (void *)glb_policy->rr_policy);
- }
- pick_from_internal_rr_locked(exec_ctx, glb_policy, &pp->pick_args,
- true /* force_async */, pp->target,
- &pp->wrapped_on_complete_arg);
- }
-
- pending_ping *pping;
- while ((pping = glb_policy->pending_pings)) {
- glb_policy->pending_pings = pping->next;
- GRPC_LB_POLICY_REF(glb_policy->rr_policy, "rr_handover_pending_ping");
- pping->wrapped_notify_arg.rr_policy = glb_policy->rr_policy;
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Pending ping about to PING from 0x%" PRIxPTR "",
- (intptr_t)glb_policy->rr_policy);
- }
- grpc_lb_policy_ping_one_locked(exec_ctx, glb_policy->rr_policy,
- &pping->wrapped_notify_arg.wrapper_closure);
- }
-}
-
-/* glb_policy->rr_policy may be NULL (initial handover) */
-static void rr_handover_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- GPR_ASSERT(glb_policy->serverlist != NULL &&
- glb_policy->serverlist->num_servers > 0);
- if (glb_policy->shutting_down) return;
- grpc_lb_policy_args *args = lb_policy_args_create(exec_ctx, glb_policy);
- GPR_ASSERT(args != NULL);
- if (glb_policy->rr_policy != NULL) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_DEBUG, "Updating Round Robin policy (%p)",
- (void *)glb_policy->rr_policy);
- }
- grpc_lb_policy_update_locked(exec_ctx, glb_policy->rr_policy, args);
- } else {
- create_rr_locked(exec_ctx, glb_policy, args);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_DEBUG, "Created new Round Robin policy (%p)",
- (void *)glb_policy->rr_policy);
- }
- }
- lb_policy_args_destroy(exec_ctx, args);
-}
-
-static void glb_rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- rr_connectivity_data *rr_connectivity = (rr_connectivity_data *)arg;
- glb_lb_policy *glb_policy = rr_connectivity->glb_policy;
- if (glb_policy->shutting_down) {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "glb_rr_connectivity_cb");
- gpr_free(rr_connectivity);
- return;
- }
- if (rr_connectivity->state == GRPC_CHANNEL_SHUTDOWN) {
- /* An RR policy that has transitioned into the SHUTDOWN connectivity state
- * should not be considered for picks or updates: the SHUTDOWN state is a
- * sink, policies can't transition back from it. .*/
- GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy,
- "rr_connectivity_shutdown");
- glb_policy->rr_policy = NULL;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "glb_rr_connectivity_cb");
- gpr_free(rr_connectivity);
- return;
- }
- /* rr state != SHUTDOWN && !glb_policy->shutting down: biz as usual */
- update_lb_connectivity_status_locked(
- exec_ctx, glb_policy, rr_connectivity->state, GRPC_ERROR_REF(error));
- /* Resubscribe. Reuse the "glb_rr_connectivity_cb" weak ref. */
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, glb_policy->rr_policy,
- &rr_connectivity->state,
- &rr_connectivity->on_change);
-}
-
-static void destroy_balancer_name(grpc_exec_ctx *exec_ctx,
- void *balancer_name) {
- gpr_free(balancer_name);
-}
-
-static grpc_slice_hash_table_entry targets_info_entry_create(
- const char *address, const char *balancer_name) {
- grpc_slice_hash_table_entry entry;
- entry.key = grpc_slice_from_copied_string(address);
- entry.value = gpr_strdup(balancer_name);
- return entry;
-}
-
-static int balancer_name_cmp_fn(void *a, void *b) {
- const char *a_str = (const char *)a;
- const char *b_str = (const char *)b;
- return strcmp(a_str, b_str);
-}
-
-/* Returns the channel args for the LB channel, used to create a bidirectional
- * stream for the reception of load balancing updates.
- *
- * Inputs:
- * - \a addresses: corresponding to the balancers.
- * - \a response_generator: in order to propagate updates from the resolver
- * above the grpclb policy.
- * - \a args: other args inherited from the grpclb policy. */
-static grpc_channel_args *build_lb_channel_args(
- grpc_exec_ctx *exec_ctx, const grpc_lb_addresses *addresses,
- grpc_fake_resolver_response_generator *response_generator,
- const grpc_channel_args *args) {
- size_t num_grpclb_addrs = 0;
- for (size_t i = 0; i < addresses->num_addresses; ++i) {
- if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
- }
- /* All input addresses come from a resolver that claims they are LB services.
- * It's the resolver's responsibility to make sure this policy is only
- * instantiated and used in that case. Otherwise, something has gone wrong. */
- GPR_ASSERT(num_grpclb_addrs > 0);
- grpc_lb_addresses *lb_addresses =
- grpc_lb_addresses_create(num_grpclb_addrs, NULL);
- grpc_slice_hash_table_entry *targets_info_entries =
- (grpc_slice_hash_table_entry *)gpr_zalloc(sizeof(*targets_info_entries) *
- num_grpclb_addrs);
-
- size_t lb_addresses_idx = 0;
- for (size_t i = 0; i < addresses->num_addresses; ++i) {
- if (!addresses->addresses[i].is_balancer) continue;
- if (addresses->addresses[i].user_data != NULL) {
- gpr_log(GPR_ERROR,
- "This LB policy doesn't support user data. It will be ignored");
- }
- char *addr_str;
- GPR_ASSERT(grpc_sockaddr_to_string(
- &addr_str, &addresses->addresses[i].address, true) > 0);
- targets_info_entries[lb_addresses_idx] = targets_info_entry_create(
- addr_str, addresses->addresses[i].balancer_name);
- gpr_free(addr_str);
-
- grpc_lb_addresses_set_address(
- lb_addresses, lb_addresses_idx++, addresses->addresses[i].address.addr,
- addresses->addresses[i].address.len, false /* is balancer */,
- addresses->addresses[i].balancer_name, NULL /* user data */);
- }
- GPR_ASSERT(num_grpclb_addrs == lb_addresses_idx);
- grpc_slice_hash_table *targets_info =
- grpc_slice_hash_table_create(num_grpclb_addrs, targets_info_entries,
- destroy_balancer_name, balancer_name_cmp_fn);
- gpr_free(targets_info_entries);
-
- grpc_channel_args *lb_channel_args =
- grpc_lb_policy_grpclb_build_lb_channel_args(exec_ctx, targets_info,
- response_generator, args);
-
- grpc_arg lb_channel_addresses_arg =
- grpc_lb_addresses_create_channel_arg(lb_addresses);
-
- grpc_channel_args *result = grpc_channel_args_copy_and_add(
- lb_channel_args, &lb_channel_addresses_arg, 1);
- grpc_slice_hash_table_unref(exec_ctx, targets_info);
- grpc_channel_args_destroy(exec_ctx, lb_channel_args);
- grpc_lb_addresses_destroy(exec_ctx, lb_addresses);
- return result;
-}
-
-static void glb_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- GPR_ASSERT(glb_policy->pending_picks == NULL);
- GPR_ASSERT(glb_policy->pending_pings == NULL);
- gpr_free((void *)glb_policy->server_name);
- grpc_channel_args_destroy(exec_ctx, glb_policy->args);
- if (glb_policy->client_stats != NULL) {
- grpc_grpclb_client_stats_unref(glb_policy->client_stats);
- }
- grpc_connectivity_state_destroy(exec_ctx, &glb_policy->state_tracker);
- if (glb_policy->serverlist != NULL) {
- grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
- }
- grpc_fake_resolver_response_generator_unref(glb_policy->response_generator);
- grpc_subchannel_index_unref();
- if (glb_policy->pending_update_args != NULL) {
- grpc_channel_args_destroy(exec_ctx, glb_policy->pending_update_args->args);
- gpr_free(glb_policy->pending_update_args);
- }
- gpr_free(glb_policy);
-}
-
-static void glb_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- glb_policy->shutting_down = true;
-
- /* We need a copy of the lb_call pointer because we can't cancell the call
- * while holding glb_policy->mu: lb_on_server_status_received, invoked due to
- * the cancel, needs to acquire that same lock */
- grpc_call *lb_call = glb_policy->lb_call;
-
- /* glb_policy->lb_call and this local lb_call must be consistent at this point
- * because glb_policy->lb_call is only assigned in lb_call_init_locked as part
- * of query_for_backends_locked, which can only be invoked while
- * glb_policy->shutting_down is false. */
- if (lb_call != NULL) {
- grpc_call_cancel(lb_call, NULL);
- /* lb_on_server_status_received will pick up the cancel and clean up */
- }
- if (glb_policy->retry_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
- glb_policy->retry_timer_active = false;
- }
-
- pending_pick *pp = glb_policy->pending_picks;
- glb_policy->pending_picks = NULL;
- pending_ping *pping = glb_policy->pending_pings;
- glb_policy->pending_pings = NULL;
- if (glb_policy->rr_policy != NULL) {
- GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "glb_shutdown");
- }
- // We destroy the LB channel here because
- // glb_lb_channel_on_connectivity_changed_cb needs a valid glb_policy
- // instance. Destroying the lb channel in glb_destroy would likely result in
- // a callback invocation without a valid glb_policy arg.
- if (glb_policy->lb_channel != NULL) {
- grpc_channel_destroy(glb_policy->lb_channel);
- glb_policy->lb_channel = NULL;
- }
- grpc_connectivity_state_set(
- exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "glb_shutdown");
-
- while (pp != NULL) {
- pending_pick *next = pp->next;
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
- GRPC_ERROR_NONE);
- pp = next;
- }
-
- while (pping != NULL) {
- pending_ping *next = pping->next;
- GRPC_CLOSURE_SCHED(exec_ctx, &pping->wrapped_notify_arg.wrapper_closure,
- GRPC_ERROR_NONE);
- pping = next;
- }
-}
-
-// Cancel a specific pending pick.
-//
-// A grpclb pick progresses as follows:
-// - If there's a Round Robin policy (glb_policy->rr_policy) available, it'll be
-// handed over to the RR policy (in create_rr_locked()). From that point
-// onwards, it'll be RR's responsibility. For cancellations, that implies the
-// pick needs also be cancelled by the RR instance.
-// - Otherwise, without an RR instance, picks stay pending at this policy's
-// level (grpclb), inside the glb_policy->pending_picks list. To cancel these,
-// we invoke the completion closure and set *target to NULL right here.
-static void glb_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_connected_subchannel **target,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- pending_pick *pp = glb_policy->pending_picks;
- glb_policy->pending_picks = NULL;
- while (pp != NULL) {
- pending_pick *next = pp->next;
- if (pp->target == target) {
- *target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick Cancelled", &error, 1));
- } else {
- pp->next = glb_policy->pending_picks;
- glb_policy->pending_picks = pp;
- }
- pp = next;
- }
- if (glb_policy->rr_policy != NULL) {
- grpc_lb_policy_cancel_pick_locked(exec_ctx, glb_policy->rr_policy, target,
- GRPC_ERROR_REF(error));
- }
- GRPC_ERROR_UNREF(error);
-}
-
-// Cancel all pending picks.
-//
-// A grpclb pick progresses as follows:
-// - If there's a Round Robin policy (glb_policy->rr_policy) available, it'll be
-// handed over to the RR policy (in create_rr_locked()). From that point
-// onwards, it'll be RR's responsibility. For cancellations, that implies the
-// pick needs also be cancelled by the RR instance.
-// - Otherwise, without an RR instance, picks stay pending at this policy's
-// level (grpclb), inside the glb_policy->pending_picks list. To cancel these,
-// we invoke the completion closure and set *target to NULL right here.
-static void glb_cancel_picks_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *pol,
- uint32_t initial_metadata_flags_mask,
- uint32_t initial_metadata_flags_eq,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- pending_pick *pp = glb_policy->pending_picks;
- glb_policy->pending_picks = NULL;
- while (pp != NULL) {
- pending_pick *next = pp->next;
- if ((pp->pick_args.initial_metadata_flags & initial_metadata_flags_mask) ==
- initial_metadata_flags_eq) {
- GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick Cancelled", &error, 1));
- } else {
- pp->next = glb_policy->pending_picks;
- glb_policy->pending_picks = pp;
- }
- pp = next;
- }
- if (glb_policy->rr_policy != NULL) {
- grpc_lb_policy_cancel_picks_locked(
- exec_ctx, glb_policy->rr_policy, initial_metadata_flags_mask,
- initial_metadata_flags_eq, GRPC_ERROR_REF(error));
- }
- GRPC_ERROR_UNREF(error);
-}
-
-static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy);
-static void start_picking_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- glb_policy->started_picking = true;
- gpr_backoff_reset(&glb_policy->lb_call_backoff_state);
- query_for_backends_locked(exec_ctx, glb_policy);
-}
-
-static void glb_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- if (!glb_policy->started_picking) {
- start_picking_locked(exec_ctx, glb_policy);
- }
-}
-
-static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context, void **user_data,
- grpc_closure *on_complete) {
- if (pick_args->lb_token_mdelem_storage == NULL) {
- *target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, on_complete,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "No mdelem storage for the LB token. Load reporting "
- "won't work without it. Failing"));
- return 0;
- }
-
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- bool pick_done;
-
- if (glb_policy->rr_policy != NULL) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "grpclb %p about to PICK from RR %p",
- (void *)glb_policy, (void *)glb_policy->rr_policy);
- }
- GRPC_LB_POLICY_REF(glb_policy->rr_policy, "glb_pick");
-
- wrapped_rr_closure_arg *wc_arg =
- (wrapped_rr_closure_arg *)gpr_zalloc(sizeof(wrapped_rr_closure_arg));
-
- GRPC_CLOSURE_INIT(&wc_arg->wrapper_closure, wrapped_rr_closure, wc_arg,
- grpc_schedule_on_exec_ctx);
- wc_arg->rr_policy = glb_policy->rr_policy;
- wc_arg->target = target;
- wc_arg->context = context;
- GPR_ASSERT(glb_policy->client_stats != NULL);
- wc_arg->client_stats =
- grpc_grpclb_client_stats_ref(glb_policy->client_stats);
- wc_arg->wrapped_closure = on_complete;
- wc_arg->lb_token_mdelem_storage = pick_args->lb_token_mdelem_storage;
- wc_arg->initial_metadata = pick_args->initial_metadata;
- wc_arg->free_when_done = wc_arg;
- pick_done =
- pick_from_internal_rr_locked(exec_ctx, glb_policy, pick_args,
- false /* force_async */, target, wc_arg);
- } else {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_DEBUG,
- "No RR policy in grpclb instance %p. Adding to grpclb's pending "
- "picks",
- (void *)(glb_policy));
- }
- add_pending_pick(&glb_policy->pending_picks, pick_args, target, context,
- on_complete);
-
- if (!glb_policy->started_picking) {
- start_picking_locked(exec_ctx, glb_policy);
- }
- pick_done = false;
- }
- return pick_done;
-}
-
-static grpc_connectivity_state glb_check_connectivity_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_error **connectivity_error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- return grpc_connectivity_state_get(&glb_policy->state_tracker,
- connectivity_error);
-}
-
-static void glb_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_closure *closure) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- if (glb_policy->rr_policy) {
- grpc_lb_policy_ping_one_locked(exec_ctx, glb_policy->rr_policy, closure);
- } else {
- add_pending_ping(&glb_policy->pending_pings, closure);
- if (!glb_policy->started_picking) {
- start_picking_locked(exec_ctx, glb_policy);
- }
- }
-}
-
-static void glb_notify_on_state_change_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *pol,
- grpc_connectivity_state *current,
- grpc_closure *notify) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
- grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &glb_policy->state_tracker, current, notify);
-}
-
-static void send_client_load_report_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-
-static void schedule_next_client_load_report(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- const gpr_timespec next_client_load_report_time =
- gpr_time_add(now, glb_policy->client_stats_report_interval);
- GRPC_CLOSURE_INIT(&glb_policy->client_load_report_closure,
- send_client_load_report_locked, glb_policy,
- grpc_combiner_scheduler(glb_policy->base.combiner));
- grpc_timer_init(exec_ctx, &glb_policy->client_load_report_timer,
- next_client_load_report_time,
- &glb_policy->client_load_report_closure, now);
-}
-
-static void client_load_report_done_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- grpc_byte_buffer_destroy(glb_policy->client_load_report_payload);
- glb_policy->client_load_report_payload = NULL;
- if (error != GRPC_ERROR_NONE || glb_policy->lb_call == NULL) {
- glb_policy->client_load_report_timer_pending = false;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "client_load_report");
- return;
- }
- schedule_next_client_load_report(exec_ctx, glb_policy);
-}
-
-static void do_send_client_load_report_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- grpc_op op;
- memset(&op, 0, sizeof(op));
- op.op = GRPC_OP_SEND_MESSAGE;
- op.data.send_message.send_message = glb_policy->client_load_report_payload;
- GRPC_CLOSURE_INIT(&glb_policy->client_load_report_closure,
- client_load_report_done_locked, glb_policy,
- grpc_combiner_scheduler(glb_policy->base.combiner));
- grpc_call_error call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, &op, 1,
- &glb_policy->client_load_report_closure);
- GPR_ASSERT(GRPC_CALL_OK == call_error);
-}
-
-static bool load_report_counters_are_zero(grpc_grpclb_request *request) {
- grpc_grpclb_dropped_call_counts *drop_entries =
- (grpc_grpclb_dropped_call_counts *)
- request->client_stats.calls_finished_with_drop.arg;
- return request->client_stats.num_calls_started == 0 &&
- request->client_stats.num_calls_finished == 0 &&
- request->client_stats.num_calls_finished_with_client_failed_to_send ==
- 0 &&
- request->client_stats.num_calls_finished_known_received == 0 &&
- (drop_entries == NULL || drop_entries->num_entries == 0);
-}
-
-static void send_client_load_report_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- if (error == GRPC_ERROR_CANCELLED || glb_policy->lb_call == NULL) {
- glb_policy->client_load_report_timer_pending = false;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "client_load_report");
- return;
- }
- // Construct message payload.
- GPR_ASSERT(glb_policy->client_load_report_payload == NULL);
- grpc_grpclb_request *request =
- grpc_grpclb_load_report_request_create_locked(glb_policy->client_stats);
- // Skip client load report if the counters were all zero in the last
- // report and they are still zero in this one.
- if (load_report_counters_are_zero(request)) {
- if (glb_policy->last_client_load_report_counters_were_zero) {
- grpc_grpclb_request_destroy(request);
- schedule_next_client_load_report(exec_ctx, glb_policy);
- return;
- }
- glb_policy->last_client_load_report_counters_were_zero = true;
- } else {
- glb_policy->last_client_load_report_counters_were_zero = false;
- }
- grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
- glb_policy->client_load_report_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_slice_unref_internal(exec_ctx, request_payload_slice);
- grpc_grpclb_request_destroy(request);
- // If we've already sent the initial request, then we can go ahead and
- // sent the load report. Otherwise, we need to wait until the initial
- // request has been sent to send this
- // (see lb_on_sent_initial_request_locked() below).
- if (glb_policy->initial_request_sent) {
- do_send_client_load_report_locked(exec_ctx, glb_policy);
- }
-}
-
-static void lb_on_sent_initial_request_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error);
-static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error);
-static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void lb_call_init_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- GPR_ASSERT(glb_policy->server_name != NULL);
- GPR_ASSERT(glb_policy->server_name[0] != '\0');
- GPR_ASSERT(glb_policy->lb_call == NULL);
- GPR_ASSERT(!glb_policy->shutting_down);
-
- /* Note the following LB call progresses every time there's activity in \a
- * glb_policy->base.interested_parties, which is comprised of the polling
- * entities from \a client_channel. */
- grpc_slice host = grpc_slice_from_copied_string(glb_policy->server_name);
- gpr_timespec deadline =
- glb_policy->lb_call_timeout_ms == 0
- ? gpr_inf_future(GPR_CLOCK_MONOTONIC)
- : gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_millis(glb_policy->lb_call_timeout_ms,
- GPR_TIMESPAN));
- glb_policy->lb_call = grpc_channel_create_pollset_set_call(
- exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS,
- glb_policy->base.interested_parties,
- GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD,
- &host, deadline, NULL);
- grpc_slice_unref_internal(exec_ctx, host);
-
- if (glb_policy->client_stats != NULL) {
- grpc_grpclb_client_stats_unref(glb_policy->client_stats);
- }
- glb_policy->client_stats = grpc_grpclb_client_stats_create();
-
- grpc_metadata_array_init(&glb_policy->lb_initial_metadata_recv);
- grpc_metadata_array_init(&glb_policy->lb_trailing_metadata_recv);
-
- grpc_grpclb_request *request =
- grpc_grpclb_request_create(glb_policy->server_name);
- grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
- glb_policy->lb_request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_slice_unref_internal(exec_ctx, request_payload_slice);
- grpc_grpclb_request_destroy(request);
-
- GRPC_CLOSURE_INIT(&glb_policy->lb_on_sent_initial_request,
- lb_on_sent_initial_request_locked, glb_policy,
- grpc_combiner_scheduler(glb_policy->base.combiner));
- GRPC_CLOSURE_INIT(&glb_policy->lb_on_server_status_received,
- lb_on_server_status_received_locked, glb_policy,
- grpc_combiner_scheduler(glb_policy->base.combiner));
- GRPC_CLOSURE_INIT(&glb_policy->lb_on_response_received,
- lb_on_response_received_locked, glb_policy,
- grpc_combiner_scheduler(glb_policy->base.combiner));
-
- gpr_backoff_init(&glb_policy->lb_call_backoff_state,
- GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS,
- GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER,
- GRPC_GRPCLB_RECONNECT_JITTER,
- GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
- GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
-
- glb_policy->initial_request_sent = false;
- glb_policy->seen_initial_response = false;
- glb_policy->last_client_load_report_counters_were_zero = false;
-}
-
-static void lb_call_destroy_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- GPR_ASSERT(glb_policy->lb_call != NULL);
- grpc_call_unref(glb_policy->lb_call);
- glb_policy->lb_call = NULL;
-
- grpc_metadata_array_destroy(&glb_policy->lb_initial_metadata_recv);
- grpc_metadata_array_destroy(&glb_policy->lb_trailing_metadata_recv);
-
- grpc_byte_buffer_destroy(glb_policy->lb_request_payload);
- grpc_slice_unref_internal(exec_ctx, glb_policy->lb_call_status_details);
-
- if (!glb_policy->client_load_report_timer_pending) {
- grpc_timer_cancel(exec_ctx, &glb_policy->client_load_report_timer);
- }
-}
-
-/*
- * Auxiliary functions and LB client callbacks.
- */
-static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
- glb_lb_policy *glb_policy) {
- GPR_ASSERT(glb_policy->lb_channel != NULL);
- if (glb_policy->shutting_down) return;
-
- lb_call_init_locked(exec_ctx, glb_policy);
-
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO,
- "Query for backends (grpclb: %p, lb_channel: %p, lb_call: %p)",
- (void *)glb_policy, (void *)glb_policy->lb_channel,
- (void *)glb_policy->lb_call);
- }
- GPR_ASSERT(glb_policy->lb_call != NULL);
-
- grpc_call_error call_error;
- grpc_op ops[4];
- memset(ops, 0, sizeof(ops));
-
- grpc_op *op = ops;
- op->op = GRPC_OP_SEND_INITIAL_METADATA;
- op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_INITIAL_METADATA;
- op->data.recv_initial_metadata.recv_initial_metadata =
- &glb_policy->lb_initial_metadata_recv;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- GPR_ASSERT(glb_policy->lb_request_payload != NULL);
- op->op = GRPC_OP_SEND_MESSAGE;
- op->data.send_message.send_message = glb_policy->lb_request_payload;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- /* take a weak ref (won't prevent calling of \a glb_shutdown if the strong ref
- * count goes to zero) to be unref'd in lb_on_sent_initial_request_locked() */
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base,
- "lb_on_sent_initial_request_locked");
- call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
- &glb_policy->lb_on_sent_initial_request);
- GPR_ASSERT(GRPC_CALL_OK == call_error);
-
- op = ops;
- op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
- op->data.recv_status_on_client.trailing_metadata =
- &glb_policy->lb_trailing_metadata_recv;
- op->data.recv_status_on_client.status = &glb_policy->lb_call_status;
- op->data.recv_status_on_client.status_details =
- &glb_policy->lb_call_status_details;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- /* take a weak ref (won't prevent calling of \a glb_shutdown if the strong ref
- * count goes to zero) to be unref'd in lb_on_server_status_received_locked */
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base,
- "lb_on_server_status_received_locked");
- call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
- &glb_policy->lb_on_server_status_received);
- GPR_ASSERT(GRPC_CALL_OK == call_error);
-
- op = ops;
- op->op = GRPC_OP_RECV_MESSAGE;
- op->data.recv_message.recv_message = &glb_policy->lb_response_payload;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- /* take another weak ref to be unref'd/reused in
- * lb_on_response_received_locked */
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "lb_on_response_received_locked");
- call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
- &glb_policy->lb_on_response_received);
- GPR_ASSERT(GRPC_CALL_OK == call_error);
-}
-
-static void lb_on_sent_initial_request_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- glb_policy->initial_request_sent = true;
- // If we attempted to send a client load report before the initial
- // request was sent, send the load report now.
- if (glb_policy->client_load_report_payload != NULL) {
- do_send_client_load_report_locked(exec_ctx, glb_policy);
- }
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "lb_on_sent_initial_request_locked");
-}
-
-static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- grpc_op ops[2];
- memset(ops, 0, sizeof(ops));
- grpc_op *op = ops;
- if (glb_policy->lb_response_payload != NULL) {
- gpr_backoff_reset(&glb_policy->lb_call_backoff_state);
- /* Received data from the LB server. Look inside
- * glb_policy->lb_response_payload, for a serverlist. */
- grpc_byte_buffer_reader bbr;
- grpc_byte_buffer_reader_init(&bbr, glb_policy->lb_response_payload);
- grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
- grpc_byte_buffer_reader_destroy(&bbr);
- grpc_byte_buffer_destroy(glb_policy->lb_response_payload);
-
- grpc_grpclb_initial_response *response = NULL;
- if (!glb_policy->seen_initial_response &&
- (response = grpc_grpclb_initial_response_parse(response_slice)) !=
- NULL) {
- if (response->has_client_stats_report_interval) {
- glb_policy->client_stats_report_interval =
- gpr_time_max(gpr_time_from_seconds(1, GPR_TIMESPAN),
- grpc_grpclb_duration_to_timespec(
- &response->client_stats_report_interval));
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO,
- "received initial LB response message; "
- "client load reporting interval = %" PRId64 ".%09d sec",
- glb_policy->client_stats_report_interval.tv_sec,
- glb_policy->client_stats_report_interval.tv_nsec);
- }
- /* take a weak ref (won't prevent calling of \a glb_shutdown() if the
- * strong ref count goes to zero) to be unref'd in
- * send_client_load_report_locked() */
- glb_policy->client_load_report_timer_pending = true;
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "client_load_report");
- schedule_next_client_load_report(exec_ctx, glb_policy);
- } else if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO,
- "received initial LB response message; "
- "client load reporting NOT enabled");
- }
- grpc_grpclb_initial_response_destroy(response);
- glb_policy->seen_initial_response = true;
- } else {
- grpc_grpclb_serverlist *serverlist =
- grpc_grpclb_response_parse_serverlist(response_slice);
- if (serverlist != NULL) {
- GPR_ASSERT(glb_policy->lb_call != NULL);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Serverlist with %lu servers received",
- (unsigned long)serverlist->num_servers);
- for (size_t i = 0; i < serverlist->num_servers; ++i) {
- grpc_resolved_address addr;
- parse_server(serverlist->servers[i], &addr);
- char *ipport;
- grpc_sockaddr_to_string(&ipport, &addr, false);
- gpr_log(GPR_INFO, "Serverlist[%lu]: %s", (unsigned long)i, ipport);
- gpr_free(ipport);
- }
- }
- /* update serverlist */
- if (serverlist->num_servers > 0) {
- if (grpc_grpclb_serverlist_equals(glb_policy->serverlist,
- serverlist)) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO,
- "Incoming server list identical to current, ignoring.");
- }
- grpc_grpclb_destroy_serverlist(serverlist);
- } else { /* new serverlist */
- if (glb_policy->serverlist != NULL) {
- /* dispose of the old serverlist */
- grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
- }
- /* and update the copy in the glb_lb_policy instance. This
- * serverlist instance will be destroyed either upon the next
- * update or in glb_destroy() */
- glb_policy->serverlist = serverlist;
- glb_policy->serverlist_index = 0;
- rr_handover_locked(exec_ctx, glb_policy);
- }
- } else {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO,
- "Received empty server list. Picks will stay pending until "
- "a response with > 0 servers is received");
- }
- grpc_grpclb_destroy_serverlist(serverlist);
- }
- } else { /* serverlist == NULL */
- gpr_log(GPR_ERROR, "Invalid LB response received: '%s'. Ignoring.",
- grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX));
- }
- }
- grpc_slice_unref_internal(exec_ctx, response_slice);
- if (!glb_policy->shutting_down) {
- /* keep listening for serverlist updates */
- op->op = GRPC_OP_RECV_MESSAGE;
- op->data.recv_message.recv_message = &glb_policy->lb_response_payload;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- /* reuse the "lb_on_response_received_locked" weak ref taken in
- * query_for_backends_locked() */
- const grpc_call_error call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
- &glb_policy->lb_on_response_received); /* loop */
- GPR_ASSERT(GRPC_CALL_OK == call_error);
- } else {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "lb_on_response_received_locked_shutdown");
- }
- } else { /* empty payload: call cancelled. */
- /* dispose of the "lb_on_response_received_locked" weak ref taken in
- * query_for_backends_locked() and reused in every reception loop */
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "lb_on_response_received_locked_empty_payload");
- }
-}
-
-static void lb_call_on_retry_timer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- glb_policy->retry_timer_active = false;
- if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Restaring call to LB server (grpclb %p)",
- (void *)glb_policy);
- }
- GPR_ASSERT(glb_policy->lb_call == NULL);
- query_for_backends_locked(exec_ctx, glb_policy);
- }
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base, "grpclb_retry_timer");
-}
-
-static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- GPR_ASSERT(glb_policy->lb_call != NULL);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- char *status_details =
- grpc_slice_to_c_string(glb_policy->lb_call_status_details);
- gpr_log(GPR_INFO,
- "Status from LB server received. Status = %d, Details = '%s', "
- "(call: %p), error %p",
- glb_policy->lb_call_status, status_details,
- (void *)glb_policy->lb_call, (void *)error);
- gpr_free(status_details);
- }
- /* We need to perform cleanups no matter what. */
- lb_call_destroy_locked(exec_ctx, glb_policy);
- if (glb_policy->started_picking && glb_policy->updating_lb_call) {
- if (glb_policy->retry_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
- }
- if (!glb_policy->shutting_down) start_picking_locked(exec_ctx, glb_policy);
- glb_policy->updating_lb_call = false;
- } else if (!glb_policy->shutting_down) {
- /* if we aren't shutting down, restart the LB client call after some time */
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec next_try =
- gpr_backoff_step(&glb_policy->lb_call_backoff_state, now);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_DEBUG, "Connection to LB server lost (grpclb: %p)...",
- (void *)glb_policy);
- gpr_timespec timeout = gpr_time_sub(next_try, now);
- if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
- gpr_log(GPR_DEBUG,
- "... retry_timer_active in %" PRId64 ".%09d seconds.",
- timeout.tv_sec, timeout.tv_nsec);
- } else {
- gpr_log(GPR_DEBUG, "... retry_timer_active immediately.");
- }
- }
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "grpclb_retry_timer");
- GRPC_CLOSURE_INIT(&glb_policy->lb_on_call_retry,
- lb_call_on_retry_timer_locked, glb_policy,
- grpc_combiner_scheduler(glb_policy->base.combiner));
- glb_policy->retry_timer_active = true;
- grpc_timer_init(exec_ctx, &glb_policy->lb_call_retry_timer, next_try,
- &glb_policy->lb_on_call_retry, now);
- }
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "lb_on_server_status_received_locked");
-}
-
-static void glb_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_args *args) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)policy;
- if (glb_policy->updating_lb_channel) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO,
- "Update already in progress for grpclb %p. Deferring update.",
- (void *)glb_policy);
- }
- if (glb_policy->pending_update_args != NULL) {
- grpc_channel_args_destroy(exec_ctx,
- glb_policy->pending_update_args->args);
- gpr_free(glb_policy->pending_update_args);
- }
- glb_policy->pending_update_args = (grpc_lb_policy_args *)gpr_zalloc(
- sizeof(*glb_policy->pending_update_args));
- glb_policy->pending_update_args->client_channel_factory =
- args->client_channel_factory;
- glb_policy->pending_update_args->args = grpc_channel_args_copy(args->args);
- glb_policy->pending_update_args->combiner = args->combiner;
- return;
- }
-
- glb_policy->updating_lb_channel = true;
- // Propagate update to lb_channel (pick first).
- const grpc_arg *arg =
- grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
- if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
- if (glb_policy->lb_channel == NULL) {
- // If we don't have a current channel to the LB, go into TRANSIENT
- // FAILURE.
- grpc_connectivity_state_set(
- exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
- "glb_update_missing");
- } else {
- // otherwise, keep using the current LB channel (ignore this update).
- gpr_log(GPR_ERROR,
- "No valid LB addresses channel arg for grpclb %p update, "
- "ignoring.",
- (void *)glb_policy);
- }
- }
- const grpc_lb_addresses *addresses =
- (const grpc_lb_addresses *)arg->value.pointer.p;
- GPR_ASSERT(glb_policy->lb_channel != NULL);
- grpc_channel_args *lb_channel_args = build_lb_channel_args(
- exec_ctx, addresses, glb_policy->response_generator, args->args);
- /* Propagate updates to the LB channel through the fake resolver */
- grpc_fake_resolver_response_generator_set_response(
- exec_ctx, glb_policy->response_generator, lb_channel_args);
- grpc_channel_args_destroy(exec_ctx, lb_channel_args);
-
- if (!glb_policy->watching_lb_channel) {
- // Watch the LB channel connectivity for connection.
- glb_policy->lb_channel_connectivity = grpc_channel_check_connectivity_state(
- glb_policy->lb_channel, true /* try to connect */);
- grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element(
- grpc_channel_get_channel_stack(glb_policy->lb_channel));
- GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
- glb_policy->watching_lb_channel = true;
- GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "watch_lb_channel_connectivity");
- grpc_client_channel_watch_connectivity_state(
- exec_ctx, client_channel_elem,
- grpc_polling_entity_create_from_pollset_set(
- glb_policy->base.interested_parties),
- &glb_policy->lb_channel_connectivity,
- &glb_policy->lb_channel_on_connectivity_changed, NULL);
- }
-}
-
-// Invoked as part of the update process. It continues watching the LB channel
-// until it shuts down or becomes READY. It's invoked even if the LB channel
-// stayed READY throughout the update (for example if the update is identical).
-static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_error *error) {
- glb_lb_policy *glb_policy = (glb_lb_policy *)arg;
- if (glb_policy->shutting_down) goto done;
- // Re-initialize the lb_call. This should also take care of updating the
- // embedded RR policy. Note that the current RR policy, if any, will stay in
- // effect until an update from the new lb_call is received.
- switch (glb_policy->lb_channel_connectivity) {
- case GRPC_CHANNEL_INIT:
- case GRPC_CHANNEL_CONNECTING:
- case GRPC_CHANNEL_TRANSIENT_FAILURE: {
- /* resub. */
- grpc_channel_element *client_channel_elem =
- grpc_channel_stack_last_element(
- grpc_channel_get_channel_stack(glb_policy->lb_channel));
- GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
- grpc_client_channel_watch_connectivity_state(
- exec_ctx, client_channel_elem,
- grpc_polling_entity_create_from_pollset_set(
- glb_policy->base.interested_parties),
- &glb_policy->lb_channel_connectivity,
- &glb_policy->lb_channel_on_connectivity_changed, NULL);
- break;
- }
- case GRPC_CHANNEL_IDLE:
- // lb channel inactive (probably shutdown prior to update). Restart lb
- // call to kick the lb channel into gear.
- GPR_ASSERT(glb_policy->lb_call == NULL);
- /* fallthrough */
- case GRPC_CHANNEL_READY:
- if (glb_policy->lb_call != NULL) {
- glb_policy->updating_lb_channel = false;
- glb_policy->updating_lb_call = true;
- grpc_call_cancel(glb_policy->lb_call, NULL);
- // lb_on_server_status_received will pick up the cancel and reinit
- // lb_call.
- if (glb_policy->pending_update_args != NULL) {
- grpc_lb_policy_args *args = glb_policy->pending_update_args;
- glb_policy->pending_update_args = NULL;
- glb_update_locked(exec_ctx, &glb_policy->base, args);
- grpc_channel_args_destroy(exec_ctx, args->args);
- gpr_free(args);
- }
- } else if (glb_policy->started_picking && !glb_policy->shutting_down) {
- if (glb_policy->retry_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
- glb_policy->retry_timer_active = false;
- }
- start_picking_locked(exec_ctx, glb_policy);
- }
- /* fallthrough */
- case GRPC_CHANNEL_SHUTDOWN:
- done:
- glb_policy->watching_lb_channel = false;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "watch_lb_channel_connectivity_cb_shutdown");
- break;
- }
-}
-
-/* Code wiring the policy with the rest of the core */
-static const grpc_lb_policy_vtable glb_lb_policy_vtable = {
- glb_destroy,
- glb_shutdown_locked,
- glb_pick_locked,
- glb_cancel_pick_locked,
- glb_cancel_picks_locked,
- glb_ping_one_locked,
- glb_exit_idle_locked,
- glb_check_connectivity_locked,
- glb_notify_on_state_change_locked,
- glb_update_locked};
-
-static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy_factory *factory,
- grpc_lb_policy_args *args) {
- /* Count the number of gRPC-LB addresses. There must be at least one.
- * TODO(roth): For now, we ignore non-balancer addresses, but in the
- * future, we may change the behavior such that we fall back to using
- * the non-balancer addresses if we cannot reach any balancers. In the
- * fallback case, we should use the LB policy indicated by
- * GRPC_ARG_LB_POLICY_NAME (although if that specifies grpclb or is
- * unset, we should default to pick_first). */
- const grpc_arg *arg =
- grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
- if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
- return NULL;
- }
- grpc_lb_addresses *addresses = (grpc_lb_addresses *)arg->value.pointer.p;
- size_t num_grpclb_addrs = 0;
- for (size_t i = 0; i < addresses->num_addresses; ++i) {
- if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
- }
- if (num_grpclb_addrs == 0) return NULL;
-
- glb_lb_policy *glb_policy = (glb_lb_policy *)gpr_zalloc(sizeof(*glb_policy));
-
- /* Get server name. */
- arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
- GPR_ASSERT(arg != NULL);
- GPR_ASSERT(arg->type == GRPC_ARG_STRING);
- grpc_uri *uri = grpc_uri_parse(exec_ctx, arg->value.string, true);
- GPR_ASSERT(uri->path[0] != '\0');
- glb_policy->server_name =
- gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
- gpr_log(GPR_INFO, "Will use '%s' as the server name for LB request.",
- glb_policy->server_name);
- }
- grpc_uri_destroy(uri);
-
- glb_policy->cc_factory = args->client_channel_factory;
- GPR_ASSERT(glb_policy->cc_factory != NULL);
-
- arg = grpc_channel_args_find(args->args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS);
- glb_policy->lb_call_timeout_ms =
- grpc_channel_arg_get_integer(arg, (grpc_integer_options){0, 0, INT_MAX});
-
- // Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
- // since we use this to trigger the client_load_reporting filter.
- grpc_arg new_arg = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_LB_POLICY_NAME, (char *)"grpclb");
- static const char *args_to_remove[] = {GRPC_ARG_LB_POLICY_NAME};
- glb_policy->args = grpc_channel_args_copy_and_add_and_remove(
- args->args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1);
-
- /* Create a client channel over them to communicate with a LB service */
- glb_policy->response_generator =
- grpc_fake_resolver_response_generator_create();
- grpc_channel_args *lb_channel_args = build_lb_channel_args(
- exec_ctx, addresses, glb_policy->response_generator, 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(
- exec_ctx, uri_str, args->client_channel_factory, lb_channel_args);
-
- /* Propagate initial resolution */
- grpc_fake_resolver_response_generator_set_response(
- exec_ctx, glb_policy->response_generator, lb_channel_args);
- grpc_channel_args_destroy(exec_ctx, lb_channel_args);
- gpr_free(uri_str);
- if (glb_policy->lb_channel == NULL) {
- gpr_free((void *)glb_policy->server_name);
- grpc_channel_args_destroy(exec_ctx, glb_policy->args);
- gpr_free(glb_policy);
- return NULL;
- }
- grpc_subchannel_index_ref();
- GRPC_CLOSURE_INIT(&glb_policy->lb_channel_on_connectivity_changed,
- glb_lb_channel_on_connectivity_changed_cb, glb_policy,
- grpc_combiner_scheduler(args->combiner));
- grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable, args->combiner);
- grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE,
- "grpclb");
- return &glb_policy->base;
-}
-
-static void glb_factory_ref(grpc_lb_policy_factory *factory) {}
-
-static void glb_factory_unref(grpc_lb_policy_factory *factory) {}
-
-static const grpc_lb_policy_factory_vtable glb_factory_vtable = {
- glb_factory_ref, glb_factory_unref, glb_create, "grpclb"};
-
-static grpc_lb_policy_factory glb_lb_policy_factory = {&glb_factory_vtable};
-
-grpc_lb_policy_factory *grpc_glb_lb_factory_create() {
- return &glb_lb_policy_factory;
-}
-
-/* Plugin registration */
-
-// Only add client_load_reporting filter if the grpclb LB policy is used.
-static bool maybe_add_client_load_reporting_filter(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
- const grpc_channel_args *args =
- grpc_channel_stack_builder_get_channel_arguments(builder);
- const grpc_arg *channel_arg =
- grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME);
- if (channel_arg != NULL && channel_arg->type == GRPC_ARG_STRING &&
- strcmp(channel_arg->value.string, "grpclb") == 0) {
- return grpc_channel_stack_builder_append_filter(
- builder, (const grpc_channel_filter *)arg, NULL, NULL);
- }
- return true;
-}
-
-void grpc_lb_policy_grpclb_init() {
- grpc_register_lb_policy(grpc_glb_lb_factory_create());
- grpc_register_tracer(&grpc_lb_glb_trace);
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_lb_policy_refcount);
-#endif
- grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
- GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_client_load_reporting_filter,
- (void *)&grpc_client_load_reporting_filter);
-}
-
-void grpc_lb_policy_grpclb_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
new file mode 100644
index 0000000000..1709e5622e
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
@@ -0,0 +1,1936 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+/** Implementation of the gRPC LB policy.
+ *
+ * This policy takes as input a set of resolved addresses {a1..an} for which the
+ * LB set was set (it's the resolver's responsibility to ensure this). That is
+ * to say, {a1..an} represent a collection of LB servers.
+ *
+ * An internal channel (\a glb_lb_policy.lb_channel) is created over {a1..an}.
+ * This channel behaves just like a regular channel. In particular, the
+ * constructed URI over the addresses a1..an will use the default pick first
+ * policy to select from this list of LB server backends.
+ *
+ * The first time the policy gets a request for a pick, a ping, or to exit the
+ * idle state, \a query_for_backends_locked() is called. This function sets up
+ * and initiates the internal communication with the LB server. In particular,
+ * it's responsible for instantiating the internal *streaming* call to the LB
+ * server (whichever address from {a1..an} pick-first chose). This call is
+ * serviced by two callbacks, \a lb_on_server_status_received and \a
+ * lb_on_response_received. The former will be called when the call to the LB
+ * server completes. This can happen if the LB server closes the connection or
+ * if this policy itself cancels the call (for example because it's shutting
+ * down). If the internal call times out, the usual behavior of pick-first
+ * applies, continuing to pick from the list {a1..an}.
+ *
+ * Upon sucesss, the incoming \a LoadBalancingResponse is processed by \a
+ * res_recv. An invalid one results in the termination of the streaming call. A
+ * new streaming call should be created if possible, failing the original call
+ * otherwise. For a valid \a LoadBalancingResponse, the server list of actual
+ * backends is extracted. A Round Robin policy will be created from this list.
+ * There are two possible scenarios:
+ *
+ * 1. This is the first server list received. There was no previous instance of
+ * the Round Robin policy. \a rr_handover_locked() will instantiate the RR
+ * policy and perform all the pending operations over it.
+ * 2. There's already a RR policy instance active. We need to introduce the new
+ * one build from the new serverlist, but taking care not to disrupt the
+ * operations in progress over the old RR instance. This is done by
+ * decreasing the reference count on the old policy. The moment no more
+ * references are held on the old RR policy, it'll be destroyed and \a
+ * on_rr_connectivity_changed notified with a \a GRPC_CHANNEL_SHUTDOWN
+ * state. At this point we can transition to a new RR instance safely, which
+ * is done once again via \a rr_handover_locked().
+ *
+ *
+ * Once a RR policy instance is in place (and getting updated as described),
+ * calls to for a pick, a ping or a cancellation will be serviced right away by
+ * forwarding them to the RR instance. Any time there's no RR policy available
+ * (ie, right after the creation of the gRPCLB policy, if an empty serverlist is
+ * received, etc), pick/ping requests are added to a list of pending picks/pings
+ * to be flushed and serviced as part of \a rr_handover_locked() the moment the
+ * RR policy instance becomes available.
+ *
+ * \see https://github.com/grpc/grpc/blob/master/doc/load-balancing.md for the
+ * high level design and details. */
+
+/* TODO(dgq):
+ * - Implement LB service forwarding (point 2c. in the doc's diagram).
+ */
+
+/* With the addition of a libuv endpoint, sockaddr.h now includes uv.h when
+ using that endpoint. Because of various transitive includes in uv.h,
+ including windows.h on Windows, uv.h must be included before other system
+ headers. Therefore, sockaddr.h must always be included first */
+#include "src/core/lib/iomgr/sockaddr.h"
+
+#include <inttypes.h>
+#include <limits.h>
+#include <string.h>
+
+#include <grpc/byte_buffer_reader.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/time.h>
+
+#include "src/core/ext/filters/client_channel/client_channel.h"
+#include "src/core/ext/filters/client_channel/client_channel_factory.h"
+#include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
+#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
+#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
+#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
+#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
+#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
+#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
+#include "src/core/ext/filters/client_channel/parse_address.h"
+#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
+#include "src/core/ext/filters/client_channel/subchannel_index.h"
+#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/string.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/slice/slice_hash_table.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+#include "src/core/lib/surface/call.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/channel_init.h"
+#include "src/core/lib/transport/static_metadata.h"
+
+#define GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS 1
+#define GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER 1.6
+#define GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS 120
+#define GRPC_GRPCLB_RECONNECT_JITTER 0.2
+#define GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS 10000
+
+grpc_core::TraceFlag grpc_lb_glb_trace(false, "glb");
+
+struct glb_lb_policy;
+
+namespace {
+
+/// Linked list of pending pick requests. It stores all information needed to
+/// eventually call (Round Robin's) pick() on them. They mainly stay pending
+/// waiting for the RR policy to be created.
+///
+/// Note that when a pick is sent to the RR policy, we inject our own
+/// on_complete callback, so that we can intercept the result before
+/// invoking the original on_complete callback. This allows us to set the
+/// LB token metadata and add client_stats to the call context.
+/// See \a pending_pick_complete() for details.
+struct pending_pick {
+ // Our on_complete closure and the original one.
+ grpc_closure on_complete;
+ grpc_closure* original_on_complete;
+ // The original pick.
+ grpc_lb_policy_pick_state* pick;
+ // Stats for client-side load reporting. Note that this holds a
+ // reference, which must be either passed on via context or unreffed.
+ grpc_grpclb_client_stats* client_stats;
+ // The LB token associated with the pick. This is set via user_data in
+ // the pick.
+ grpc_mdelem lb_token;
+ // The grpclb instance that created the wrapping. This instance is not owned,
+ // reference counts are untouched. It's used only for logging purposes.
+ glb_lb_policy* glb_policy;
+ // Next pending pick.
+ struct pending_pick* next;
+};
+
+/// A linked list of pending pings waiting for the RR policy to be created.
+struct pending_ping {
+ grpc_closure* on_initiate;
+ grpc_closure* on_ack;
+ struct pending_ping* next;
+};
+
+} // namespace
+
+typedef struct glb_lb_call_data {
+ struct glb_lb_policy* glb_policy;
+ // TODO(juanlishen): c++ize this struct.
+ gpr_refcount refs;
+
+ /** The streaming call to the LB server. Always non-NULL. */
+ grpc_call* lb_call;
+
+ /** The initial metadata received from the LB server. */
+ grpc_metadata_array lb_initial_metadata_recv;
+
+ /** The message sent to the LB server. It's used to query for backends (the
+ * value may vary if the LB server indicates a redirect) or send client load
+ * report. */
+ grpc_byte_buffer* send_message_payload;
+ /** The callback after the initial request is sent. */
+ grpc_closure lb_on_sent_initial_request;
+
+ /** The response received from the LB server, if any. */
+ grpc_byte_buffer* recv_message_payload;
+ /** The callback to process the response received from the LB server. */
+ grpc_closure lb_on_response_received;
+ bool seen_initial_response;
+
+ /** The callback to process the status received from the LB server, which
+ * signals the end of the LB call. */
+ grpc_closure lb_on_server_status_received;
+ /** The trailing metadata from the LB server. */
+ grpc_metadata_array lb_trailing_metadata_recv;
+ /** The call status code and details. */
+ grpc_status_code lb_call_status;
+ grpc_slice lb_call_status_details;
+
+ /** The stats for client-side load reporting associated with this LB call.
+ * Created after the first serverlist is received. */
+ grpc_grpclb_client_stats* client_stats;
+ /** The interval and timer for next client load report. */
+ grpc_millis client_stats_report_interval;
+ grpc_timer client_load_report_timer;
+ bool client_load_report_timer_callback_pending;
+ bool last_client_load_report_counters_were_zero;
+ bool client_load_report_is_due;
+ /** The closure used for either the load report timer or the callback for
+ * completion of sending the load report. */
+ grpc_closure client_load_report_closure;
+} glb_lb_call_data;
+
+typedef struct glb_lb_policy {
+ /** Base policy: must be first. */
+ grpc_lb_policy base;
+
+ /** Who the client is trying to communicate with. */
+ const char* server_name;
+
+ /** Channel related data that will be propagated to the internal RR policy. */
+ grpc_client_channel_factory* cc_factory;
+ grpc_channel_args* args;
+
+ /** Timeout in milliseconds for before using fallback backend addresses.
+ * 0 means not using fallback. */
+ int lb_fallback_timeout_ms;
+
+ /** The channel for communicating with the LB server. */
+ grpc_channel* lb_channel;
+
+ /** The data associated with the current LB call. It holds a ref to this LB
+ * policy. It's initialized every time we query for backends. It's reset to
+ * NULL whenever the current LB call is no longer needed (e.g., the LB policy
+ * is shutting down, or the LB call has ended). A non-NULL lb_calld always
+ * contains a non-NULL lb_call. */
+ glb_lb_call_data* lb_calld;
+
+ /** response generator to inject address updates into \a lb_channel */
+ grpc_fake_resolver_response_generator* response_generator;
+
+ /** the RR policy to use of the backend servers returned by the LB server */
+ grpc_lb_policy* rr_policy;
+
+ grpc_closure on_rr_connectivity_changed;
+ grpc_connectivity_state rr_connectivity_state;
+
+ bool started_picking;
+
+ /** our connectivity state tracker */
+ grpc_connectivity_state_tracker state_tracker;
+
+ /** connectivity state of the LB channel */
+ grpc_connectivity_state lb_channel_connectivity;
+
+ /** stores the deserialized response from the LB. May be nullptr until one
+ * such response has arrived. */
+ grpc_grpclb_serverlist* serverlist;
+
+ /** Index into serverlist for next pick.
+ * If the server at this index is a drop, we return a drop.
+ * Otherwise, we delegate to the RR policy. */
+ size_t serverlist_index;
+
+ /** stores the backend addresses from the resolver */
+ grpc_lb_addresses* fallback_backend_addresses;
+
+ /** list of picks that are waiting on RR's policy connectivity */
+ pending_pick* pending_picks;
+
+ /** list of pings that are waiting on RR's policy connectivity */
+ pending_ping* pending_pings;
+
+ bool shutting_down;
+
+ /** are we already watching the LB channel's connectivity? */
+ bool watching_lb_channel;
+
+ /** is the callback associated with \a lb_call_retry_timer pending? */
+ bool retry_timer_callback_pending;
+
+ /** is the callback associated with \a lb_fallback_timer pending? */
+ bool fallback_timer_callback_pending;
+
+ /** called upon changes to the LB channel's connectivity. */
+ grpc_closure lb_channel_on_connectivity_changed;
+
+ /************************************************************/
+ /* client data associated with the LB server communication */
+ /************************************************************/
+
+ /** LB call retry backoff state */
+ grpc_core::ManualConstructor<grpc_core::BackOff> lb_call_backoff;
+
+ /** timeout in milliseconds for the LB call. 0 means no deadline. */
+ int lb_call_timeout_ms;
+
+ /** LB call retry timer */
+ grpc_timer lb_call_retry_timer;
+ /** LB call retry timer callback */
+ grpc_closure lb_on_call_retry;
+
+ /** LB fallback timer */
+ grpc_timer lb_fallback_timer;
+ /** LB fallback timer callback */
+ grpc_closure lb_on_fallback;
+} glb_lb_policy;
+
+static void glb_lb_call_data_ref(glb_lb_call_data* lb_calld,
+ const char* reason) {
+ gpr_ref_non_zero(&lb_calld->refs);
+ if (grpc_lb_glb_trace.enabled()) {
+ const gpr_atm count = gpr_atm_acq_load(&lb_calld->refs.count);
+ gpr_log(GPR_DEBUG, "[%s %p] lb_calld %p REF %lu->%lu (%s)",
+ grpc_lb_glb_trace.name(), lb_calld->glb_policy, lb_calld,
+ (unsigned long)(count - 1), (unsigned long)count, reason);
+ }
+}
+
+static void glb_lb_call_data_unref(glb_lb_call_data* lb_calld,
+ const char* reason) {
+ const bool done = gpr_unref(&lb_calld->refs);
+ if (grpc_lb_glb_trace.enabled()) {
+ const gpr_atm count = gpr_atm_acq_load(&lb_calld->refs.count);
+ gpr_log(GPR_DEBUG, "[%s %p] lb_calld %p UNREF %lu->%lu (%s)",
+ grpc_lb_glb_trace.name(), lb_calld->glb_policy, lb_calld,
+ (unsigned long)(count + 1), (unsigned long)count, reason);
+ }
+ if (done) {
+ GPR_ASSERT(lb_calld->lb_call != nullptr);
+ grpc_call_unref(lb_calld->lb_call);
+ grpc_metadata_array_destroy(&lb_calld->lb_initial_metadata_recv);
+ grpc_metadata_array_destroy(&lb_calld->lb_trailing_metadata_recv);
+ grpc_byte_buffer_destroy(lb_calld->send_message_payload);
+ grpc_byte_buffer_destroy(lb_calld->recv_message_payload);
+ grpc_slice_unref_internal(lb_calld->lb_call_status_details);
+ if (lb_calld->client_stats != nullptr) {
+ grpc_grpclb_client_stats_unref(lb_calld->client_stats);
+ }
+ GRPC_LB_POLICY_UNREF(&lb_calld->glb_policy->base, "lb_calld");
+ gpr_free(lb_calld);
+ }
+}
+
+static void lb_call_data_shutdown(glb_lb_policy* glb_policy) {
+ GPR_ASSERT(glb_policy->lb_calld != nullptr);
+ GPR_ASSERT(glb_policy->lb_calld->lb_call != nullptr);
+ // lb_on_server_status_received will complete the cancellation and clean up.
+ grpc_call_cancel(glb_policy->lb_calld->lb_call, nullptr);
+ if (glb_policy->lb_calld->client_load_report_timer_callback_pending) {
+ grpc_timer_cancel(&glb_policy->lb_calld->client_load_report_timer);
+ }
+ glb_policy->lb_calld = nullptr;
+}
+
+/* add lb_token of selected subchannel (address) to the call's initial
+ * metadata */
+static grpc_error* initial_metadata_add_lb_token(
+ grpc_metadata_batch* initial_metadata,
+ grpc_linked_mdelem* lb_token_mdelem_storage, grpc_mdelem lb_token) {
+ GPR_ASSERT(lb_token_mdelem_storage != nullptr);
+ GPR_ASSERT(!GRPC_MDISNULL(lb_token));
+ return grpc_metadata_batch_add_tail(initial_metadata, lb_token_mdelem_storage,
+ lb_token);
+}
+
+static void destroy_client_stats(void* arg) {
+ grpc_grpclb_client_stats_unref((grpc_grpclb_client_stats*)arg);
+}
+
+static void pending_pick_set_metadata_and_context(pending_pick* pp) {
+ /* if connected_subchannel is nullptr, no pick has been made by the RR
+ * policy (e.g., all addresses failed to connect). There won't be any
+ * user_data/token available */
+ if (pp->pick->connected_subchannel != nullptr) {
+ if (!GRPC_MDISNULL(pp->lb_token)) {
+ initial_metadata_add_lb_token(pp->pick->initial_metadata,
+ &pp->pick->lb_token_mdelem_storage,
+ GRPC_MDELEM_REF(pp->lb_token));
+ } else {
+ gpr_log(GPR_ERROR,
+ "[grpclb %p] No LB token for connected subchannel pick %p",
+ pp->glb_policy, pp->pick);
+ abort();
+ }
+ // Pass on client stats via context. Passes ownership of the reference.
+ if (pp->client_stats != nullptr) {
+ pp->pick->subchannel_call_context[GRPC_GRPCLB_CLIENT_STATS].value =
+ pp->client_stats;
+ pp->pick->subchannel_call_context[GRPC_GRPCLB_CLIENT_STATS].destroy =
+ destroy_client_stats;
+ }
+ } else {
+ if (pp->client_stats != nullptr) {
+ grpc_grpclb_client_stats_unref(pp->client_stats);
+ }
+ }
+}
+
+/* The \a on_complete closure passed as part of the pick requires keeping a
+ * reference to its associated round robin instance. We wrap this closure in
+ * order to unref the round robin instance upon its invocation */
+static void pending_pick_complete(void* arg, grpc_error* error) {
+ pending_pick* pp = (pending_pick*)arg;
+ pending_pick_set_metadata_and_context(pp);
+ GRPC_CLOSURE_SCHED(pp->original_on_complete, GRPC_ERROR_REF(error));
+ gpr_free(pp);
+}
+
+static pending_pick* pending_pick_create(glb_lb_policy* glb_policy,
+ grpc_lb_policy_pick_state* pick) {
+ pending_pick* pp = (pending_pick*)gpr_zalloc(sizeof(*pp));
+ pp->pick = pick;
+ pp->glb_policy = glb_policy;
+ GRPC_CLOSURE_INIT(&pp->on_complete, pending_pick_complete, pp,
+ grpc_schedule_on_exec_ctx);
+ pp->original_on_complete = pick->on_complete;
+ pp->pick->on_complete = &pp->on_complete;
+ return pp;
+}
+
+static void pending_pick_add(pending_pick** root, pending_pick* new_pp) {
+ new_pp->next = *root;
+ *root = new_pp;
+}
+
+static void pending_ping_add(pending_ping** root, grpc_closure* on_initiate,
+ grpc_closure* on_ack) {
+ pending_ping* pping = (pending_ping*)gpr_zalloc(sizeof(*pping));
+ pping->on_initiate = on_initiate;
+ pping->on_ack = on_ack;
+ pping->next = *root;
+ *root = pping;
+}
+
+static bool is_server_valid(const grpc_grpclb_server* server, size_t idx,
+ bool log) {
+ if (server->drop) return false;
+ const grpc_grpclb_ip_address* ip = &server->ip_address;
+ if (server->port >> 16 != 0) {
+ if (log) {
+ gpr_log(GPR_ERROR,
+ "Invalid port '%d' at index %lu of serverlist. Ignoring.",
+ server->port, (unsigned long)idx);
+ }
+ return false;
+ }
+ if (ip->size != 4 && ip->size != 16) {
+ if (log) {
+ gpr_log(GPR_ERROR,
+ "Expected IP to be 4 or 16 bytes, got %d at index %lu of "
+ "serverlist. Ignoring",
+ ip->size, (unsigned long)idx);
+ }
+ return false;
+ }
+ return true;
+}
+
+/* vtable for LB tokens in grpc_lb_addresses. */
+static void* lb_token_copy(void* token) {
+ return token == nullptr
+ ? nullptr
+ : (void*)GRPC_MDELEM_REF(grpc_mdelem{(uintptr_t)token}).payload;
+}
+static void lb_token_destroy(void* token) {
+ if (token != nullptr) {
+ GRPC_MDELEM_UNREF(grpc_mdelem{(uintptr_t)token});
+ }
+}
+static int lb_token_cmp(void* token1, void* token2) {
+ if (token1 > token2) return 1;
+ if (token1 < token2) return -1;
+ return 0;
+}
+static const grpc_lb_user_data_vtable lb_token_vtable = {
+ lb_token_copy, lb_token_destroy, lb_token_cmp};
+
+static void parse_server(const grpc_grpclb_server* server,
+ grpc_resolved_address* addr) {
+ memset(addr, 0, sizeof(*addr));
+ if (server->drop) return;
+ const uint16_t netorder_port = htons((uint16_t)server->port);
+ /* the addresses are given in binary format (a in(6)_addr struct) in
+ * server->ip_address.bytes. */
+ const grpc_grpclb_ip_address* ip = &server->ip_address;
+ if (ip->size == 4) {
+ addr->len = sizeof(struct sockaddr_in);
+ struct sockaddr_in* addr4 = (struct sockaddr_in*)&addr->addr;
+ addr4->sin_family = AF_INET;
+ memcpy(&addr4->sin_addr, ip->bytes, ip->size);
+ addr4->sin_port = netorder_port;
+ } else if (ip->size == 16) {
+ addr->len = sizeof(struct sockaddr_in6);
+ struct sockaddr_in6* addr6 = (struct sockaddr_in6*)&addr->addr;
+ addr6->sin6_family = AF_INET6;
+ memcpy(&addr6->sin6_addr, ip->bytes, ip->size);
+ addr6->sin6_port = netorder_port;
+ }
+}
+
+/* Returns addresses extracted from \a serverlist. */
+static grpc_lb_addresses* process_serverlist_locked(
+ const grpc_grpclb_serverlist* serverlist) {
+ size_t num_valid = 0;
+ /* first pass: count how many are valid in order to allocate the necessary
+ * memory in a single block */
+ for (size_t i = 0; i < serverlist->num_servers; ++i) {
+ if (is_server_valid(serverlist->servers[i], i, true)) ++num_valid;
+ }
+ grpc_lb_addresses* lb_addresses =
+ grpc_lb_addresses_create(num_valid, &lb_token_vtable);
+ /* second pass: actually populate the addresses and LB tokens (aka user data
+ * to the outside world) to be read by the RR policy during its creation.
+ * Given that the validity tests are very cheap, they are performed again
+ * instead of marking the valid ones during the first pass, as this would
+ * incurr in an allocation due to the arbitrary number of server */
+ size_t addr_idx = 0;
+ for (size_t sl_idx = 0; sl_idx < serverlist->num_servers; ++sl_idx) {
+ const grpc_grpclb_server* server = serverlist->servers[sl_idx];
+ if (!is_server_valid(serverlist->servers[sl_idx], sl_idx, false)) continue;
+ GPR_ASSERT(addr_idx < num_valid);
+ /* address processing */
+ grpc_resolved_address addr;
+ parse_server(server, &addr);
+ /* lb token processing */
+ void* user_data;
+ if (server->has_load_balance_token) {
+ const size_t lb_token_max_length =
+ GPR_ARRAY_SIZE(server->load_balance_token);
+ const size_t lb_token_length =
+ strnlen(server->load_balance_token, lb_token_max_length);
+ grpc_slice lb_token_mdstr = grpc_slice_from_copied_buffer(
+ server->load_balance_token, lb_token_length);
+ user_data =
+ (void*)grpc_mdelem_from_slices(GRPC_MDSTR_LB_TOKEN, lb_token_mdstr)
+ .payload;
+ } else {
+ char* uri = grpc_sockaddr_to_uri(&addr);
+ gpr_log(GPR_INFO,
+ "Missing LB token for backend address '%s'. The empty token will "
+ "be used instead",
+ uri);
+ gpr_free(uri);
+ user_data = (void*)GRPC_MDELEM_LB_TOKEN_EMPTY.payload;
+ }
+ grpc_lb_addresses_set_address(lb_addresses, addr_idx, &addr.addr, addr.len,
+ false /* is_balancer */,
+ nullptr /* balancer_name */, user_data);
+ ++addr_idx;
+ }
+ GPR_ASSERT(addr_idx == num_valid);
+ return lb_addresses;
+}
+
+/* Returns the backend addresses extracted from the given addresses */
+static grpc_lb_addresses* extract_backend_addresses_locked(
+ const grpc_lb_addresses* addresses) {
+ /* first pass: count the number of backend addresses */
+ size_t num_backends = 0;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (!addresses->addresses[i].is_balancer) {
+ ++num_backends;
+ }
+ }
+ /* second pass: actually populate the addresses and (empty) LB tokens */
+ grpc_lb_addresses* backend_addresses =
+ grpc_lb_addresses_create(num_backends, &lb_token_vtable);
+ size_t num_copied = 0;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (addresses->addresses[i].is_balancer) continue;
+ const grpc_resolved_address* addr = &addresses->addresses[i].address;
+ grpc_lb_addresses_set_address(backend_addresses, num_copied, &addr->addr,
+ addr->len, false /* is_balancer */,
+ nullptr /* balancer_name */,
+ (void*)GRPC_MDELEM_LB_TOKEN_EMPTY.payload);
+ ++num_copied;
+ }
+ return backend_addresses;
+}
+
+static void update_lb_connectivity_status_locked(
+ glb_lb_policy* glb_policy, grpc_connectivity_state rr_state,
+ grpc_error* rr_state_error) {
+ const grpc_connectivity_state curr_glb_state =
+ grpc_connectivity_state_check(&glb_policy->state_tracker);
+ /* The new connectivity status is a function of the previous one and the new
+ * input coming from the status of the RR policy.
+ *
+ * current state (grpclb's)
+ * |
+ * v || I | C | R | TF | SD | <- new state (RR's)
+ * ===++====+=====+=====+======+======+
+ * I || I | C | R | [I] | [I] |
+ * ---++----+-----+-----+------+------+
+ * C || I | C | R | [C] | [C] |
+ * ---++----+-----+-----+------+------+
+ * R || I | C | R | [R] | [R] |
+ * ---++----+-----+-----+------+------+
+ * TF || I | C | R | [TF] | [TF] |
+ * ---++----+-----+-----+------+------+
+ * SD || NA | NA | NA | NA | NA | (*)
+ * ---++----+-----+-----+------+------+
+ *
+ * A [STATE] indicates that the old RR policy is kept. In those cases, STATE
+ * is the current state of grpclb, which is left untouched.
+ *
+ * In summary, if the new state is TRANSIENT_FAILURE or SHUTDOWN, stick to
+ * the previous RR instance.
+ *
+ * Note that the status is never updated to SHUTDOWN as a result of calling
+ * this function. Only glb_shutdown() has the power to set that state.
+ *
+ * (*) This function mustn't be called during shutting down. */
+ GPR_ASSERT(curr_glb_state != GRPC_CHANNEL_SHUTDOWN);
+ switch (rr_state) {
+ case GRPC_CHANNEL_TRANSIENT_FAILURE:
+ case GRPC_CHANNEL_SHUTDOWN:
+ GPR_ASSERT(rr_state_error != GRPC_ERROR_NONE);
+ break;
+ case GRPC_CHANNEL_IDLE:
+ case GRPC_CHANNEL_CONNECTING:
+ case GRPC_CHANNEL_READY:
+ GPR_ASSERT(rr_state_error == GRPC_ERROR_NONE);
+ }
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(
+ GPR_INFO,
+ "[grpclb %p] Setting grpclb's state to %s from new RR policy %p state.",
+ glb_policy, grpc_connectivity_state_name(rr_state),
+ glb_policy->rr_policy);
+ }
+ grpc_connectivity_state_set(&glb_policy->state_tracker, rr_state,
+ rr_state_error,
+ "update_lb_connectivity_status_locked");
+}
+
+/* Perform a pick over \a glb_policy->rr_policy. Given that a pick can return
+ * immediately (ignoring its completion callback), we need to perform the
+ * cleanups this callback would otherwise be responsible for.
+ * If \a force_async is true, then we will manually schedule the
+ * completion callback even if the pick is available immediately. */
+static bool pick_from_internal_rr_locked(glb_lb_policy* glb_policy,
+ bool force_async, pending_pick* pp) {
+ // Check for drops if we are not using fallback backend addresses.
+ if (glb_policy->serverlist != nullptr) {
+ // Look at the index into the serverlist to see if we should drop this call.
+ grpc_grpclb_server* server =
+ glb_policy->serverlist->servers[glb_policy->serverlist_index++];
+ if (glb_policy->serverlist_index == glb_policy->serverlist->num_servers) {
+ glb_policy->serverlist_index = 0; // Wrap-around.
+ }
+ if (server->drop) {
+ // Update client load reporting stats to indicate the number of
+ // dropped calls. Note that we have to do this here instead of in
+ // the client_load_reporting filter, because we do not create a
+ // subchannel call (and therefore no client_load_reporting filter)
+ // for dropped calls.
+ if (glb_policy->lb_calld != nullptr &&
+ glb_policy->lb_calld->client_stats != nullptr) {
+ grpc_grpclb_client_stats_add_call_dropped_locked(
+ server->load_balance_token, glb_policy->lb_calld->client_stats);
+ }
+ if (force_async) {
+ GRPC_CLOSURE_SCHED(pp->original_on_complete, GRPC_ERROR_NONE);
+ gpr_free(pp);
+ return false;
+ }
+ gpr_free(pp);
+ return true;
+ }
+ }
+ // Set client_stats and user_data.
+ if (glb_policy->lb_calld != nullptr &&
+ glb_policy->lb_calld->client_stats != nullptr) {
+ pp->client_stats =
+ grpc_grpclb_client_stats_ref(glb_policy->lb_calld->client_stats);
+ }
+ GPR_ASSERT(pp->pick->user_data == nullptr);
+ pp->pick->user_data = (void**)&pp->lb_token;
+ // Pick via the RR policy.
+ bool pick_done = grpc_lb_policy_pick_locked(glb_policy->rr_policy, pp->pick);
+ if (pick_done) {
+ pending_pick_set_metadata_and_context(pp);
+ if (force_async) {
+ GRPC_CLOSURE_SCHED(pp->original_on_complete, GRPC_ERROR_NONE);
+ pick_done = false;
+ }
+ gpr_free(pp);
+ }
+ /* else, the pending pick will be registered and taken care of by the
+ * pending pick list inside the RR policy (glb_policy->rr_policy).
+ * Eventually, wrapped_on_complete will be called, which will -among other
+ * things- add the LB token to the call's initial metadata */
+ return pick_done;
+}
+
+static grpc_lb_policy_args* lb_policy_args_create(glb_lb_policy* glb_policy) {
+ grpc_lb_addresses* addresses;
+ if (glb_policy->serverlist != nullptr) {
+ GPR_ASSERT(glb_policy->serverlist->num_servers > 0);
+ addresses = process_serverlist_locked(glb_policy->serverlist);
+ } else {
+ // If rr_handover_locked() is invoked when we haven't received any
+ // serverlist from the balancer, we use the fallback backends returned by
+ // the resolver. Note that the fallback backend list may be empty, in which
+ // case the new round_robin policy will keep the requested picks pending.
+ GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
+ addresses = grpc_lb_addresses_copy(glb_policy->fallback_backend_addresses);
+ }
+ GPR_ASSERT(addresses != nullptr);
+ grpc_lb_policy_args* args = (grpc_lb_policy_args*)gpr_zalloc(sizeof(*args));
+ args->client_channel_factory = glb_policy->cc_factory;
+ args->combiner = glb_policy->base.combiner;
+ // Replace the LB addresses in the channel args that we pass down to
+ // the subchannel.
+ static const char* keys_to_remove[] = {GRPC_ARG_LB_ADDRESSES};
+ const grpc_arg arg = grpc_lb_addresses_create_channel_arg(addresses);
+ args->args = grpc_channel_args_copy_and_add_and_remove(
+ glb_policy->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &arg,
+ 1);
+ grpc_lb_addresses_destroy(addresses);
+ return args;
+}
+
+static void lb_policy_args_destroy(grpc_lb_policy_args* args) {
+ grpc_channel_args_destroy(args->args);
+ gpr_free(args);
+}
+
+static void on_rr_connectivity_changed_locked(void* arg, grpc_error* error);
+static void create_rr_locked(glb_lb_policy* glb_policy,
+ grpc_lb_policy_args* args) {
+ GPR_ASSERT(glb_policy->rr_policy == nullptr);
+
+ grpc_lb_policy* new_rr_policy = grpc_lb_policy_create("round_robin", args);
+ if (new_rr_policy == nullptr) {
+ gpr_log(GPR_ERROR,
+ "[grpclb %p] Failure creating a RoundRobin policy for serverlist "
+ "update with %" PRIuPTR
+ " entries. The previous RR instance (%p), if any, will continue to "
+ "be used. Future updates from the LB will attempt to create new "
+ "instances.",
+ glb_policy, glb_policy->serverlist->num_servers,
+ glb_policy->rr_policy);
+ return;
+ }
+ grpc_lb_policy_set_reresolve_closure_locked(
+ new_rr_policy, glb_policy->base.request_reresolution);
+ glb_policy->base.request_reresolution = nullptr;
+ glb_policy->rr_policy = new_rr_policy;
+ grpc_error* rr_state_error = nullptr;
+ glb_policy->rr_connectivity_state = grpc_lb_policy_check_connectivity_locked(
+ glb_policy->rr_policy, &rr_state_error);
+ /* Connectivity state is a function of the RR policy updated/created */
+ update_lb_connectivity_status_locked(
+ glb_policy, glb_policy->rr_connectivity_state, rr_state_error);
+ /* Add the gRPC LB's interested_parties pollset_set to that of the newly
+ * created RR policy. This will make the RR policy progress upon activity on
+ * gRPC LB, which in turn is tied to the application's call */
+ grpc_pollset_set_add_pollset_set(glb_policy->rr_policy->interested_parties,
+ glb_policy->base.interested_parties);
+ GRPC_CLOSURE_INIT(&glb_policy->on_rr_connectivity_changed,
+ on_rr_connectivity_changed_locked, glb_policy,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ /* Subscribe to changes to the connectivity of the new RR */
+ GRPC_LB_POLICY_REF(&glb_policy->base, "glb_rr_connectivity_cb");
+ grpc_lb_policy_notify_on_state_change_locked(
+ glb_policy->rr_policy, &glb_policy->rr_connectivity_state,
+ &glb_policy->on_rr_connectivity_changed);
+ grpc_lb_policy_exit_idle_locked(glb_policy->rr_policy);
+ // Send pending picks to RR policy.
+ pending_pick* pp;
+ while ((pp = glb_policy->pending_picks)) {
+ glb_policy->pending_picks = pp->next;
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Pending pick about to (async) PICK from RR %p",
+ glb_policy, glb_policy->rr_policy);
+ }
+ pick_from_internal_rr_locked(glb_policy, true /* force_async */, pp);
+ }
+ // Send pending pings to RR policy.
+ pending_ping* pping;
+ while ((pping = glb_policy->pending_pings)) {
+ glb_policy->pending_pings = pping->next;
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO, "[grpclb %p] Pending ping about to PING from RR %p",
+ glb_policy, glb_policy->rr_policy);
+ }
+ grpc_lb_policy_ping_one_locked(glb_policy->rr_policy, pping->on_initiate,
+ pping->on_ack);
+ gpr_free(pping);
+ }
+}
+
+/* glb_policy->rr_policy may be nullptr (initial handover) */
+static void rr_handover_locked(glb_lb_policy* glb_policy) {
+ if (glb_policy->shutting_down) return;
+ grpc_lb_policy_args* args = lb_policy_args_create(glb_policy);
+ GPR_ASSERT(args != nullptr);
+ if (glb_policy->rr_policy != nullptr) {
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[grpclb %p] Updating RR policy %p", glb_policy,
+ glb_policy->rr_policy);
+ }
+ grpc_lb_policy_update_locked(glb_policy->rr_policy, args);
+ } else {
+ create_rr_locked(glb_policy, args);
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[grpclb %p] Created new RR policy %p", glb_policy,
+ glb_policy->rr_policy);
+ }
+ }
+ lb_policy_args_destroy(args);
+}
+
+static void on_rr_connectivity_changed_locked(void* arg, grpc_error* error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
+ if (glb_policy->shutting_down) {
+ GRPC_LB_POLICY_UNREF(&glb_policy->base, "glb_rr_connectivity_cb");
+ return;
+ }
+ if (glb_policy->rr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
+ /* An RR policy that has transitioned into the SHUTDOWN connectivity state
+ * should not be considered for picks or updates: the SHUTDOWN state is a
+ * sink, policies can't transition back from it. .*/
+ GRPC_LB_POLICY_UNREF(glb_policy->rr_policy, "rr_connectivity_shutdown");
+ glb_policy->rr_policy = nullptr;
+ GRPC_LB_POLICY_UNREF(&glb_policy->base, "glb_rr_connectivity_cb");
+ return;
+ }
+ /* rr state != SHUTDOWN && !glb_policy->shutting down: biz as usual */
+ update_lb_connectivity_status_locked(
+ glb_policy, glb_policy->rr_connectivity_state, GRPC_ERROR_REF(error));
+ /* Resubscribe. Reuse the "glb_rr_connectivity_cb" ref. */
+ grpc_lb_policy_notify_on_state_change_locked(
+ glb_policy->rr_policy, &glb_policy->rr_connectivity_state,
+ &glb_policy->on_rr_connectivity_changed);
+}
+
+static void destroy_balancer_name(void* balancer_name) {
+ gpr_free(balancer_name);
+}
+
+static grpc_slice_hash_table_entry targets_info_entry_create(
+ const char* address, const char* balancer_name) {
+ grpc_slice_hash_table_entry entry;
+ entry.key = grpc_slice_from_copied_string(address);
+ entry.value = gpr_strdup(balancer_name);
+ return entry;
+}
+
+static int balancer_name_cmp_fn(void* a, void* b) {
+ const char* a_str = (const char*)a;
+ const char* b_str = (const char*)b;
+ return strcmp(a_str, b_str);
+}
+
+/* Returns the channel args for the LB channel, used to create a bidirectional
+ * stream for the reception of load balancing updates.
+ *
+ * Inputs:
+ * - \a addresses: corresponding to the balancers.
+ * - \a response_generator: in order to propagate updates from the resolver
+ * above the grpclb policy.
+ * - \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,
+ const grpc_channel_args* args) {
+ size_t num_grpclb_addrs = 0;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
+ }
+ /* All input addresses come from a resolver that claims they are LB services.
+ * It's the resolver's responsibility to make sure this policy is only
+ * instantiated and used in that case. Otherwise, something has gone wrong. */
+ GPR_ASSERT(num_grpclb_addrs > 0);
+ grpc_lb_addresses* lb_addresses =
+ grpc_lb_addresses_create(num_grpclb_addrs, nullptr);
+ grpc_slice_hash_table_entry* targets_info_entries =
+ (grpc_slice_hash_table_entry*)gpr_zalloc(sizeof(*targets_info_entries) *
+ num_grpclb_addrs);
+
+ size_t lb_addresses_idx = 0;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (!addresses->addresses[i].is_balancer) continue;
+ if (addresses->addresses[i].user_data != nullptr) {
+ gpr_log(GPR_ERROR,
+ "This LB policy doesn't support user data. It will be ignored");
+ }
+ char* addr_str;
+ GPR_ASSERT(grpc_sockaddr_to_string(
+ &addr_str, &addresses->addresses[i].address, true) > 0);
+ targets_info_entries[lb_addresses_idx] = targets_info_entry_create(
+ addr_str, addresses->addresses[i].balancer_name);
+ gpr_free(addr_str);
+
+ grpc_lb_addresses_set_address(
+ lb_addresses, lb_addresses_idx++, addresses->addresses[i].address.addr,
+ addresses->addresses[i].address.len, false /* is balancer */,
+ addresses->addresses[i].balancer_name, nullptr /* user data */);
+ }
+ GPR_ASSERT(num_grpclb_addrs == lb_addresses_idx);
+ grpc_slice_hash_table* targets_info =
+ grpc_slice_hash_table_create(num_grpclb_addrs, targets_info_entries,
+ destroy_balancer_name, balancer_name_cmp_fn);
+ gpr_free(targets_info_entries);
+
+ grpc_channel_args* lb_channel_args =
+ grpc_lb_policy_grpclb_build_lb_channel_args(targets_info,
+ response_generator, args);
+
+ grpc_arg lb_channel_addresses_arg =
+ grpc_lb_addresses_create_channel_arg(lb_addresses);
+
+ grpc_channel_args* result = grpc_channel_args_copy_and_add(
+ lb_channel_args, &lb_channel_addresses_arg, 1);
+ grpc_slice_hash_table_unref(targets_info);
+ grpc_channel_args_destroy(lb_channel_args);
+ grpc_lb_addresses_destroy(lb_addresses);
+ return result;
+}
+
+static void glb_destroy(grpc_lb_policy* pol) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ GPR_ASSERT(glb_policy->pending_picks == nullptr);
+ GPR_ASSERT(glb_policy->pending_pings == nullptr);
+ gpr_free((void*)glb_policy->server_name);
+ grpc_channel_args_destroy(glb_policy->args);
+ grpc_connectivity_state_destroy(&glb_policy->state_tracker);
+ if (glb_policy->serverlist != nullptr) {
+ grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
+ }
+ 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);
+ grpc_subchannel_index_unref();
+ gpr_free(glb_policy);
+}
+
+static void glb_shutdown_locked(grpc_lb_policy* pol,
+ grpc_lb_policy* new_policy) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown");
+ glb_policy->shutting_down = true;
+ if (glb_policy->lb_calld != nullptr) {
+ lb_call_data_shutdown(glb_policy);
+ }
+ if (glb_policy->retry_timer_callback_pending) {
+ grpc_timer_cancel(&glb_policy->lb_call_retry_timer);
+ }
+ if (glb_policy->fallback_timer_callback_pending) {
+ grpc_timer_cancel(&glb_policy->lb_fallback_timer);
+ }
+ if (glb_policy->rr_policy != nullptr) {
+ grpc_lb_policy_shutdown_locked(glb_policy->rr_policy, nullptr);
+ GRPC_LB_POLICY_UNREF(glb_policy->rr_policy, "glb_shutdown");
+ } else {
+ grpc_lb_policy_try_reresolve(pol, &grpc_lb_glb_trace, GRPC_ERROR_CANCELLED);
+ }
+ // We destroy the LB channel here because
+ // glb_lb_channel_on_connectivity_changed_cb needs a valid glb_policy
+ // instance. Destroying the lb channel in glb_destroy would likely result in
+ // a callback invocation without a valid glb_policy arg.
+ if (glb_policy->lb_channel != nullptr) {
+ grpc_channel_destroy(glb_policy->lb_channel);
+ glb_policy->lb_channel = nullptr;
+ }
+ grpc_connectivity_state_set(&glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN,
+ GRPC_ERROR_REF(error), "glb_shutdown");
+ // Clear pending picks.
+ pending_pick* pp = glb_policy->pending_picks;
+ glb_policy->pending_picks = nullptr;
+ while (pp != nullptr) {
+ pending_pick* next = pp->next;
+ if (new_policy != nullptr) {
+ // Hand pick over to new policy.
+ if (pp->client_stats != nullptr) {
+ grpc_grpclb_client_stats_unref(pp->client_stats);
+ }
+ pp->pick->on_complete = pp->original_on_complete;
+ if (grpc_lb_policy_pick_locked(new_policy, pp->pick)) {
+ // Synchronous return; schedule callback.
+ GRPC_CLOSURE_SCHED(pp->pick->on_complete, GRPC_ERROR_NONE);
+ }
+ gpr_free(pp);
+ } else {
+ pp->pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(&pp->on_complete, GRPC_ERROR_REF(error));
+ }
+ pp = next;
+ }
+ // Clear pending pings.
+ pending_ping* pping = glb_policy->pending_pings;
+ glb_policy->pending_pings = nullptr;
+ while (pping != nullptr) {
+ pending_ping* next = pping->next;
+ GRPC_CLOSURE_SCHED(pping->on_initiate, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(pping->on_ack, GRPC_ERROR_REF(error));
+ gpr_free(pping);
+ pping = next;
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+// Cancel a specific pending pick.
+//
+// A grpclb pick progresses as follows:
+// - If there's a Round Robin policy (glb_policy->rr_policy) available, it'll be
+// handed over to the RR policy (in create_rr_locked()). From that point
+// onwards, it'll be RR's responsibility. For cancellations, that implies the
+// pick needs also be cancelled by the RR instance.
+// - Otherwise, without an RR instance, picks stay pending at this policy's
+// level (grpclb), inside the glb_policy->pending_picks list. To cancel these,
+// we invoke the completion closure and set *target to nullptr right here.
+static void glb_cancel_pick_locked(grpc_lb_policy* pol,
+ grpc_lb_policy_pick_state* pick,
+ grpc_error* error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ pending_pick* pp = glb_policy->pending_picks;
+ glb_policy->pending_picks = nullptr;
+ while (pp != nullptr) {
+ pending_pick* next = pp->next;
+ if (pp->pick == pick) {
+ pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(&pp->on_complete,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick Cancelled", &error, 1));
+ } else {
+ pp->next = glb_policy->pending_picks;
+ glb_policy->pending_picks = pp;
+ }
+ pp = next;
+ }
+ if (glb_policy->rr_policy != nullptr) {
+ grpc_lb_policy_cancel_pick_locked(glb_policy->rr_policy, pick,
+ GRPC_ERROR_REF(error));
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+// Cancel all pending picks.
+//
+// A grpclb pick progresses as follows:
+// - If there's a Round Robin policy (glb_policy->rr_policy) available, it'll be
+// handed over to the RR policy (in create_rr_locked()). From that point
+// onwards, it'll be RR's responsibility. For cancellations, that implies the
+// pick needs also be cancelled by the RR instance.
+// - Otherwise, without an RR instance, picks stay pending at this policy's
+// level (grpclb), inside the glb_policy->pending_picks list. To cancel these,
+// we invoke the completion closure and set *target to nullptr right here.
+static void glb_cancel_picks_locked(grpc_lb_policy* pol,
+ uint32_t initial_metadata_flags_mask,
+ uint32_t initial_metadata_flags_eq,
+ grpc_error* error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ pending_pick* pp = glb_policy->pending_picks;
+ glb_policy->pending_picks = nullptr;
+ while (pp != nullptr) {
+ pending_pick* next = pp->next;
+ if ((pp->pick->initial_metadata_flags & initial_metadata_flags_mask) ==
+ initial_metadata_flags_eq) {
+ GRPC_CLOSURE_SCHED(&pp->on_complete,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick Cancelled", &error, 1));
+ } else {
+ pp->next = glb_policy->pending_picks;
+ glb_policy->pending_picks = pp;
+ }
+ pp = next;
+ }
+ if (glb_policy->rr_policy != nullptr) {
+ grpc_lb_policy_cancel_picks_locked(
+ glb_policy->rr_policy, initial_metadata_flags_mask,
+ initial_metadata_flags_eq, GRPC_ERROR_REF(error));
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void lb_on_fallback_timer_locked(void* arg, grpc_error* error);
+static void query_for_backends_locked(glb_lb_policy* glb_policy);
+static void start_picking_locked(glb_lb_policy* glb_policy) {
+ /* start a timer to fall back */
+ if (glb_policy->lb_fallback_timeout_ms > 0 &&
+ glb_policy->serverlist == nullptr &&
+ !glb_policy->fallback_timer_callback_pending) {
+ grpc_millis deadline =
+ grpc_core::ExecCtx::Get()->Now() + glb_policy->lb_fallback_timeout_ms;
+ GRPC_LB_POLICY_REF(&glb_policy->base, "grpclb_fallback_timer");
+ GRPC_CLOSURE_INIT(&glb_policy->lb_on_fallback, lb_on_fallback_timer_locked,
+ glb_policy,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ glb_policy->fallback_timer_callback_pending = true;
+ grpc_timer_init(&glb_policy->lb_fallback_timer, deadline,
+ &glb_policy->lb_on_fallback);
+ }
+ glb_policy->started_picking = true;
+ glb_policy->lb_call_backoff->Reset();
+ query_for_backends_locked(glb_policy);
+}
+
+static void glb_exit_idle_locked(grpc_lb_policy* pol) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ if (!glb_policy->started_picking) {
+ start_picking_locked(glb_policy);
+ }
+}
+
+static int glb_pick_locked(grpc_lb_policy* pol,
+ grpc_lb_policy_pick_state* pick) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ pending_pick* pp = pending_pick_create(glb_policy, pick);
+ bool pick_done = false;
+ if (glb_policy->rr_policy != nullptr) {
+ const grpc_connectivity_state rr_connectivity_state =
+ grpc_lb_policy_check_connectivity_locked(glb_policy->rr_policy,
+ nullptr);
+ // The glb_policy->rr_policy may have transitioned to SHUTDOWN but the
+ // callback registered to capture this event
+ // (on_rr_connectivity_changed_locked) may not have been invoked yet. We
+ // need to make sure we aren't trying to pick from a RR policy instance
+ // that's in shutdown.
+ if (rr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] NOT picking from from RR %p: RR conn state=%s",
+ glb_policy, glb_policy->rr_policy,
+ grpc_connectivity_state_name(rr_connectivity_state));
+ }
+ pending_pick_add(&glb_policy->pending_picks, pp);
+ pick_done = false;
+ } else { // RR not in shutdown
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO, "[grpclb %p] about to PICK from RR %p", glb_policy,
+ glb_policy->rr_policy);
+ }
+ pick_done =
+ pick_from_internal_rr_locked(glb_policy, false /* force_async */, pp);
+ }
+ } else { // glb_policy->rr_policy == NULL
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[grpclb %p] No RR policy. Adding to grpclb's pending picks",
+ glb_policy);
+ }
+ pending_pick_add(&glb_policy->pending_picks, pp);
+ if (!glb_policy->started_picking) {
+ start_picking_locked(glb_policy);
+ }
+ pick_done = false;
+ }
+ return pick_done;
+}
+
+static grpc_connectivity_state glb_check_connectivity_locked(
+ grpc_lb_policy* pol, grpc_error** connectivity_error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ return grpc_connectivity_state_get(&glb_policy->state_tracker,
+ connectivity_error);
+}
+
+static void glb_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
+ grpc_closure* on_ack) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ if (glb_policy->rr_policy) {
+ grpc_lb_policy_ping_one_locked(glb_policy->rr_policy, on_initiate, on_ack);
+ } else {
+ pending_ping_add(&glb_policy->pending_pings, on_initiate, on_ack);
+ if (!glb_policy->started_picking) {
+ start_picking_locked(glb_policy);
+ }
+ }
+}
+
+static void glb_notify_on_state_change_locked(grpc_lb_policy* pol,
+ grpc_connectivity_state* current,
+ grpc_closure* notify) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
+ grpc_connectivity_state_notify_on_state_change(&glb_policy->state_tracker,
+ current, notify);
+}
+
+static void lb_call_on_retry_timer_locked(void* arg, grpc_error* error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
+ glb_policy->retry_timer_callback_pending = false;
+ if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE &&
+ glb_policy->lb_calld == nullptr) {
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", glb_policy);
+ }
+ query_for_backends_locked(glb_policy);
+ }
+ GRPC_LB_POLICY_UNREF(&glb_policy->base, "grpclb_retry_timer");
+}
+
+static void start_lb_call_retry_timer_locked(glb_lb_policy* glb_policy) {
+ grpc_millis next_try = glb_policy->lb_call_backoff->NextAttemptTime();
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[grpclb %p] Connection to LB server lost...",
+ glb_policy);
+ grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now();
+ if (timeout > 0) {
+ gpr_log(GPR_DEBUG,
+ "[grpclb %p] ... retry_timer_active in %" PRIuPTR "ms.",
+ glb_policy, timeout);
+ } else {
+ gpr_log(GPR_DEBUG, "[grpclb %p] ... retry_timer_active immediately.",
+ glb_policy);
+ }
+ }
+ GRPC_LB_POLICY_REF(&glb_policy->base, "grpclb_retry_timer");
+ GRPC_CLOSURE_INIT(&glb_policy->lb_on_call_retry,
+ lb_call_on_retry_timer_locked, glb_policy,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ glb_policy->retry_timer_callback_pending = true;
+ grpc_timer_init(&glb_policy->lb_call_retry_timer, next_try,
+ &glb_policy->lb_on_call_retry);
+}
+
+static void maybe_send_client_load_report_locked(void* arg, grpc_error* error);
+
+static void schedule_next_client_load_report(glb_lb_call_data* lb_calld) {
+ const grpc_millis next_client_load_report_time =
+ grpc_core::ExecCtx::Get()->Now() + lb_calld->client_stats_report_interval;
+ GRPC_CLOSURE_INIT(
+ &lb_calld->client_load_report_closure,
+ maybe_send_client_load_report_locked, lb_calld,
+ grpc_combiner_scheduler(lb_calld->glb_policy->base.combiner));
+ grpc_timer_init(&lb_calld->client_load_report_timer,
+ next_client_load_report_time,
+ &lb_calld->client_load_report_closure);
+ lb_calld->client_load_report_timer_callback_pending = true;
+}
+
+static void client_load_report_done_locked(void* arg, grpc_error* error) {
+ glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
+ glb_lb_policy* glb_policy = lb_calld->glb_policy;
+ grpc_byte_buffer_destroy(lb_calld->send_message_payload);
+ lb_calld->send_message_payload = nullptr;
+ if (error != GRPC_ERROR_NONE || lb_calld != glb_policy->lb_calld) {
+ glb_lb_call_data_unref(lb_calld, "client_load_report");
+ return;
+ }
+ schedule_next_client_load_report(lb_calld);
+}
+
+static bool load_report_counters_are_zero(grpc_grpclb_request* request) {
+ grpc_grpclb_dropped_call_counts* drop_entries =
+ (grpc_grpclb_dropped_call_counts*)
+ request->client_stats.calls_finished_with_drop.arg;
+ return request->client_stats.num_calls_started == 0 &&
+ request->client_stats.num_calls_finished == 0 &&
+ request->client_stats.num_calls_finished_with_client_failed_to_send ==
+ 0 &&
+ request->client_stats.num_calls_finished_known_received == 0 &&
+ (drop_entries == nullptr || drop_entries->num_entries == 0);
+}
+
+static void send_client_load_report_locked(glb_lb_call_data* lb_calld) {
+ glb_lb_policy* glb_policy = lb_calld->glb_policy;
+ // Construct message payload.
+ GPR_ASSERT(lb_calld->send_message_payload == nullptr);
+ grpc_grpclb_request* request =
+ grpc_grpclb_load_report_request_create_locked(lb_calld->client_stats);
+ // Skip client load report if the counters were all zero in the last
+ // report and they are still zero in this one.
+ if (load_report_counters_are_zero(request)) {
+ if (lb_calld->last_client_load_report_counters_were_zero) {
+ grpc_grpclb_request_destroy(request);
+ schedule_next_client_load_report(lb_calld);
+ return;
+ }
+ lb_calld->last_client_load_report_counters_were_zero = true;
+ } else {
+ lb_calld->last_client_load_report_counters_were_zero = false;
+ }
+ grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
+ lb_calld->send_message_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ grpc_slice_unref_internal(request_payload_slice);
+ grpc_grpclb_request_destroy(request);
+ // Send the report.
+ grpc_op op;
+ memset(&op, 0, sizeof(op));
+ op.op = GRPC_OP_SEND_MESSAGE;
+ op.data.send_message.send_message = lb_calld->send_message_payload;
+ GRPC_CLOSURE_INIT(&lb_calld->client_load_report_closure,
+ client_load_report_done_locked, lb_calld,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ grpc_call_error call_error = grpc_call_start_batch_and_execute(
+ lb_calld->lb_call, &op, 1, &lb_calld->client_load_report_closure);
+ if (call_error != GRPC_CALL_OK) {
+ gpr_log(GPR_ERROR, "[grpclb %p] call_error=%d", glb_policy, call_error);
+ GPR_ASSERT(GRPC_CALL_OK == call_error);
+ }
+}
+
+static void maybe_send_client_load_report_locked(void* arg, grpc_error* error) {
+ glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
+ glb_lb_policy* glb_policy = lb_calld->glb_policy;
+ lb_calld->client_load_report_timer_callback_pending = false;
+ if (error != GRPC_ERROR_NONE || lb_calld != glb_policy->lb_calld) {
+ glb_lb_call_data_unref(lb_calld, "client_load_report");
+ return;
+ }
+ // If we've already sent the initial request, then we can go ahead and send
+ // the load report. Otherwise, we need to wait until the initial request has
+ // been sent to send this (see lb_on_sent_initial_request_locked()).
+ if (lb_calld->send_message_payload == nullptr) {
+ send_client_load_report_locked(lb_calld);
+ } else {
+ lb_calld->client_load_report_is_due = true;
+ }
+}
+
+static void lb_on_sent_initial_request_locked(void* arg, grpc_error* error);
+static void lb_on_server_status_received_locked(void* arg, grpc_error* error);
+static void lb_on_response_received_locked(void* arg, grpc_error* error);
+static glb_lb_call_data* lb_call_data_create_locked(glb_lb_policy* glb_policy) {
+ GPR_ASSERT(!glb_policy->shutting_down);
+ // Init the LB call. Note that the LB call will progress every time there's
+ // activity in glb_policy->base.interested_parties, which is comprised of the
+ // polling entities from client_channel.
+ GPR_ASSERT(glb_policy->server_name != nullptr);
+ GPR_ASSERT(glb_policy->server_name[0] != '\0');
+ grpc_slice host = grpc_slice_from_copied_string(glb_policy->server_name);
+ grpc_millis deadline =
+ glb_policy->lb_call_timeout_ms == 0
+ ? GRPC_MILLIS_INF_FUTURE
+ : grpc_core::ExecCtx::Get()->Now() + glb_policy->lb_call_timeout_ms;
+ glb_lb_call_data* lb_calld = (glb_lb_call_data*)gpr_zalloc(sizeof(*lb_calld));
+ lb_calld->lb_call = grpc_channel_create_pollset_set_call(
+ glb_policy->lb_channel, nullptr, GRPC_PROPAGATE_DEFAULTS,
+ glb_policy->base.interested_parties,
+ GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD,
+ &host, deadline, nullptr);
+ grpc_slice_unref_internal(host);
+ // Init the LB call request payload.
+ grpc_grpclb_request* request =
+ grpc_grpclb_request_create(glb_policy->server_name);
+ grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
+ lb_calld->send_message_payload =
+ grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ grpc_slice_unref_internal(request_payload_slice);
+ grpc_grpclb_request_destroy(request);
+ // Init other data associated with the LB call.
+ lb_calld->glb_policy = glb_policy;
+ gpr_ref_init(&lb_calld->refs, 1);
+ grpc_metadata_array_init(&lb_calld->lb_initial_metadata_recv);
+ grpc_metadata_array_init(&lb_calld->lb_trailing_metadata_recv);
+ GRPC_CLOSURE_INIT(&lb_calld->lb_on_sent_initial_request,
+ lb_on_sent_initial_request_locked, lb_calld,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ GRPC_CLOSURE_INIT(&lb_calld->lb_on_response_received,
+ lb_on_response_received_locked, lb_calld,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ GRPC_CLOSURE_INIT(&lb_calld->lb_on_server_status_received,
+ lb_on_server_status_received_locked, lb_calld,
+ grpc_combiner_scheduler(glb_policy->base.combiner));
+ // Hold a ref to the glb_policy.
+ GRPC_LB_POLICY_REF(&glb_policy->base, "lb_calld");
+ return lb_calld;
+}
+
+/*
+ * Auxiliary functions and LB client callbacks.
+ */
+
+static void query_for_backends_locked(glb_lb_policy* glb_policy) {
+ GPR_ASSERT(glb_policy->lb_channel != nullptr);
+ if (glb_policy->shutting_down) return;
+ // Init the LB call data.
+ GPR_ASSERT(glb_policy->lb_calld == nullptr);
+ glb_policy->lb_calld = lb_call_data_create_locked(glb_policy);
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Query for backends (lb_channel: %p, lb_calld: %p, "
+ "lb_call: %p)",
+ glb_policy, glb_policy->lb_channel, glb_policy->lb_calld,
+ glb_policy->lb_calld->lb_call);
+ }
+ GPR_ASSERT(glb_policy->lb_calld->lb_call != nullptr);
+ // Create the ops.
+ grpc_call_error call_error;
+ grpc_op ops[3];
+ memset(ops, 0, sizeof(ops));
+ // Op: send initial metadata.
+ grpc_op* op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ // Op: send request message.
+ GPR_ASSERT(glb_policy->lb_calld->send_message_payload != nullptr);
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message.send_message =
+ glb_policy->lb_calld->send_message_payload;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ glb_lb_call_data_ref(glb_policy->lb_calld,
+ "lb_on_sent_initial_request_locked");
+ call_error = grpc_call_start_batch_and_execute(
+ glb_policy->lb_calld->lb_call, ops, (size_t)(op - ops),
+ &glb_policy->lb_calld->lb_on_sent_initial_request);
+ GPR_ASSERT(GRPC_CALL_OK == call_error);
+ // Op: recv initial metadata.
+ op = ops;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata =
+ &glb_policy->lb_calld->lb_initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ // Op: recv response.
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message =
+ &glb_policy->lb_calld->recv_message_payload;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ glb_lb_call_data_ref(glb_policy->lb_calld, "lb_on_response_received_locked");
+ call_error = grpc_call_start_batch_and_execute(
+ glb_policy->lb_calld->lb_call, ops, (size_t)(op - ops),
+ &glb_policy->lb_calld->lb_on_response_received);
+ GPR_ASSERT(GRPC_CALL_OK == call_error);
+ // Op: recv server status.
+ op = ops;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata =
+ &glb_policy->lb_calld->lb_trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &glb_policy->lb_calld->lb_call_status;
+ op->data.recv_status_on_client.status_details =
+ &glb_policy->lb_calld->lb_call_status_details;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ // This callback signals the end of the LB call, so it relies on the initial
+ // ref instead of a new ref. When it's invoked, it's the initial ref that is
+ // unreffed.
+ call_error = grpc_call_start_batch_and_execute(
+ glb_policy->lb_calld->lb_call, ops, (size_t)(op - ops),
+ &glb_policy->lb_calld->lb_on_server_status_received);
+ GPR_ASSERT(GRPC_CALL_OK == call_error);
+}
+
+static void lb_on_sent_initial_request_locked(void* arg, grpc_error* error) {
+ glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
+ grpc_byte_buffer_destroy(lb_calld->send_message_payload);
+ lb_calld->send_message_payload = nullptr;
+ // If we attempted to send a client load report before the initial request was
+ // sent (and this lb_calld is still in use), send the load report now.
+ if (lb_calld->client_load_report_is_due &&
+ lb_calld == lb_calld->glb_policy->lb_calld) {
+ send_client_load_report_locked(lb_calld);
+ lb_calld->client_load_report_is_due = false;
+ }
+ glb_lb_call_data_unref(lb_calld, "lb_on_sent_initial_request_locked");
+}
+
+static void lb_on_response_received_locked(void* arg, grpc_error* error) {
+ glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
+ glb_lb_policy* glb_policy = lb_calld->glb_policy;
+ // Empty payload means the LB call was cancelled.
+ if (lb_calld != glb_policy->lb_calld ||
+ lb_calld->recv_message_payload == nullptr) {
+ glb_lb_call_data_unref(lb_calld, "lb_on_response_received_locked");
+ return;
+ }
+ grpc_op ops[2];
+ memset(ops, 0, sizeof(ops));
+ grpc_op* op = ops;
+ glb_policy->lb_call_backoff->Reset();
+ grpc_byte_buffer_reader bbr;
+ grpc_byte_buffer_reader_init(&bbr, lb_calld->recv_message_payload);
+ grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
+ grpc_byte_buffer_reader_destroy(&bbr);
+ grpc_byte_buffer_destroy(lb_calld->recv_message_payload);
+ lb_calld->recv_message_payload = nullptr;
+ grpc_grpclb_initial_response* initial_response;
+ grpc_grpclb_serverlist* serverlist;
+ if (!lb_calld->seen_initial_response &&
+ (initial_response = grpc_grpclb_initial_response_parse(response_slice)) !=
+ nullptr) {
+ // Have NOT seen initial response, look for initial response.
+ if (initial_response->has_client_stats_report_interval) {
+ lb_calld->client_stats_report_interval = GPR_MAX(
+ GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis(
+ &initial_response->client_stats_report_interval));
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Received initial LB response message; "
+ "client load reporting interval = %" PRIdPTR " milliseconds",
+ glb_policy, lb_calld->client_stats_report_interval);
+ }
+ } else if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Received initial LB response message; client load "
+ "reporting NOT enabled",
+ glb_policy);
+ }
+ grpc_grpclb_initial_response_destroy(initial_response);
+ lb_calld->seen_initial_response = true;
+ } else if ((serverlist = grpc_grpclb_response_parse_serverlist(
+ response_slice)) != nullptr) {
+ // Have seen initial response, look for serverlist.
+ GPR_ASSERT(lb_calld->lb_call != nullptr);
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Serverlist with %" PRIuPTR " servers received",
+ glb_policy, serverlist->num_servers);
+ for (size_t i = 0; i < serverlist->num_servers; ++i) {
+ grpc_resolved_address addr;
+ parse_server(serverlist->servers[i], &addr);
+ char* ipport;
+ grpc_sockaddr_to_string(&ipport, &addr, false);
+ gpr_log(GPR_INFO, "[grpclb %p] Serverlist[%" PRIuPTR "]: %s",
+ glb_policy, i, ipport);
+ gpr_free(ipport);
+ }
+ }
+ /* update serverlist */
+ if (serverlist->num_servers > 0) {
+ // Start sending client load report only after we start using the
+ // serverlist returned from the current LB call.
+ if (lb_calld->client_stats_report_interval > 0 &&
+ lb_calld->client_stats == nullptr) {
+ lb_calld->client_stats = grpc_grpclb_client_stats_create();
+ glb_lb_call_data_ref(lb_calld, "client_load_report");
+ schedule_next_client_load_report(lb_calld);
+ }
+ if (grpc_grpclb_serverlist_equals(glb_policy->serverlist, serverlist)) {
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Incoming server list identical to current, "
+ "ignoring.",
+ glb_policy);
+ }
+ grpc_grpclb_destroy_serverlist(serverlist);
+ } else { /* new serverlist */
+ if (glb_policy->serverlist != nullptr) {
+ /* dispose of the old serverlist */
+ grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
+ } else {
+ /* or dispose of the fallback */
+ grpc_lb_addresses_destroy(glb_policy->fallback_backend_addresses);
+ glb_policy->fallback_backend_addresses = nullptr;
+ if (glb_policy->fallback_timer_callback_pending) {
+ grpc_timer_cancel(&glb_policy->lb_fallback_timer);
+ glb_policy->fallback_timer_callback_pending = false;
+ }
+ }
+ /* and update the copy in the glb_lb_policy instance. This
+ * serverlist instance will be destroyed either upon the next
+ * update or in glb_destroy() */
+ glb_policy->serverlist = serverlist;
+ glb_policy->serverlist_index = 0;
+ rr_handover_locked(glb_policy);
+ }
+ } else {
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO, "[grpclb %p] Received empty server list, ignoring.",
+ glb_policy);
+ }
+ grpc_grpclb_destroy_serverlist(serverlist);
+ }
+ } else {
+ // No valid initial response or serverlist found.
+ gpr_log(GPR_ERROR,
+ "[grpclb %p] Invalid LB response received: '%s'. Ignoring.",
+ glb_policy,
+ grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX));
+ }
+ grpc_slice_unref_internal(response_slice);
+ if (!glb_policy->shutting_down) {
+ // Keep listening for serverlist updates.
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message = &lb_calld->recv_message_payload;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ // Reuse the "lb_on_response_received_locked" ref taken in
+ // query_for_backends_locked().
+ const grpc_call_error call_error = grpc_call_start_batch_and_execute(
+ lb_calld->lb_call, ops, (size_t)(op - ops),
+ &lb_calld->lb_on_response_received);
+ GPR_ASSERT(GRPC_CALL_OK == call_error);
+ } else {
+ glb_lb_call_data_unref(lb_calld,
+ "lb_on_response_received_locked+glb_shutdown");
+ }
+}
+
+static void lb_on_server_status_received_locked(void* arg, grpc_error* error) {
+ glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
+ glb_lb_policy* glb_policy = lb_calld->glb_policy;
+ GPR_ASSERT(lb_calld->lb_call != nullptr);
+ if (grpc_lb_glb_trace.enabled()) {
+ char* status_details =
+ grpc_slice_to_c_string(lb_calld->lb_call_status_details);
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Status from LB server received. Status = %d, details "
+ "= '%s', (lb_calld: %p, lb_call: %p), error '%s'",
+ lb_calld->glb_policy, lb_calld->lb_call_status, status_details,
+ lb_calld, lb_calld->lb_call, grpc_error_string(error));
+ gpr_free(status_details);
+ }
+ // If this lb_calld is still in use, this call ended because of a failure so
+ // we want to retry connecting. Otherwise, we have deliberately ended this
+ // call and no further action is required.
+ if (lb_calld == glb_policy->lb_calld) {
+ glb_policy->lb_calld = nullptr;
+ if (lb_calld->client_load_report_timer_callback_pending) {
+ grpc_timer_cancel(&lb_calld->client_load_report_timer);
+ }
+ GPR_ASSERT(!glb_policy->shutting_down);
+ if (lb_calld->seen_initial_response) {
+ // If we lose connection to the LB server, reset the backoff and restart
+ // the LB call immediately.
+ glb_policy->lb_call_backoff->Reset();
+ query_for_backends_locked(glb_policy);
+ } else {
+ // If this LB call fails establishing any connection to the LB server,
+ // retry later.
+ start_lb_call_retry_timer_locked(glb_policy);
+ }
+ }
+ glb_lb_call_data_unref(lb_calld, "lb_call_ended");
+}
+
+static void lb_on_fallback_timer_locked(void* arg, grpc_error* error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
+ glb_policy->fallback_timer_callback_pending = false;
+ /* If we receive a serverlist after the timer fires but before this callback
+ * actually runs, don't fall back. */
+ if (glb_policy->serverlist == nullptr) {
+ if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) {
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Falling back to use backends from resolver",
+ glb_policy);
+ }
+ GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
+ rr_handover_locked(glb_policy);
+ }
+ }
+ GRPC_LB_POLICY_UNREF(&glb_policy->base, "grpclb_fallback_timer");
+}
+
+static void fallback_update_locked(glb_lb_policy* glb_policy,
+ const grpc_lb_addresses* addresses) {
+ GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
+ grpc_lb_addresses_destroy(glb_policy->fallback_backend_addresses);
+ glb_policy->fallback_backend_addresses =
+ extract_backend_addresses_locked(addresses);
+ if (glb_policy->lb_fallback_timeout_ms > 0 &&
+ glb_policy->rr_policy != nullptr) {
+ rr_handover_locked(glb_policy);
+ }
+}
+
+static void glb_update_locked(grpc_lb_policy* policy,
+ const grpc_lb_policy_args* args) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)policy;
+ const grpc_arg* arg =
+ grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
+ if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
+ if (glb_policy->lb_channel == nullptr) {
+ // If we don't have a current channel to the LB, go into TRANSIENT
+ // FAILURE.
+ grpc_connectivity_state_set(
+ &glb_policy->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
+ "glb_update_missing");
+ } else {
+ // otherwise, keep using the current LB channel (ignore this update).
+ gpr_log(
+ GPR_ERROR,
+ "[grpclb %p] No valid LB addresses channel arg in update, ignoring.",
+ glb_policy);
+ }
+ return;
+ }
+ const grpc_lb_addresses* addresses =
+ (const grpc_lb_addresses*)arg->value.pointer.p;
+ // If a non-empty serverlist hasn't been received from the balancer,
+ // propagate the update to fallback_backend_addresses.
+ if (glb_policy->serverlist == nullptr) {
+ fallback_update_locked(glb_policy, addresses);
+ }
+ GPR_ASSERT(glb_policy->lb_channel != nullptr);
+ // 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);
+ grpc_channel_args_destroy(lb_channel_args);
+ // Start watching the LB channel connectivity for connection, if not
+ // already doing so.
+ if (!glb_policy->watching_lb_channel) {
+ glb_policy->lb_channel_connectivity = grpc_channel_check_connectivity_state(
+ glb_policy->lb_channel, true /* try to connect */);
+ grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
+ grpc_channel_get_channel_stack(glb_policy->lb_channel));
+ GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
+ glb_policy->watching_lb_channel = true;
+ GRPC_LB_POLICY_REF(&glb_policy->base, "watch_lb_channel_connectivity");
+ grpc_client_channel_watch_connectivity_state(
+ client_channel_elem,
+ grpc_polling_entity_create_from_pollset_set(
+ glb_policy->base.interested_parties),
+ &glb_policy->lb_channel_connectivity,
+ &glb_policy->lb_channel_on_connectivity_changed, nullptr);
+ }
+}
+
+// Invoked as part of the update process. It continues watching the LB channel
+// until it shuts down or becomes READY. It's invoked even if the LB channel
+// stayed READY throughout the update (for example if the update is identical).
+static void glb_lb_channel_on_connectivity_changed_cb(void* arg,
+ grpc_error* error) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
+ if (glb_policy->shutting_down) goto done;
+ // Re-initialize the lb_call. This should also take care of updating the
+ // embedded RR policy. Note that the current RR policy, if any, will stay in
+ // effect until an update from the new lb_call is received.
+ switch (glb_policy->lb_channel_connectivity) {
+ case GRPC_CHANNEL_CONNECTING:
+ case GRPC_CHANNEL_TRANSIENT_FAILURE: {
+ // Keep watching the LB channel.
+ grpc_channel_element* client_channel_elem =
+ grpc_channel_stack_last_element(
+ grpc_channel_get_channel_stack(glb_policy->lb_channel));
+ GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
+ grpc_client_channel_watch_connectivity_state(
+ client_channel_elem,
+ grpc_polling_entity_create_from_pollset_set(
+ glb_policy->base.interested_parties),
+ &glb_policy->lb_channel_connectivity,
+ &glb_policy->lb_channel_on_connectivity_changed, nullptr);
+ break;
+ }
+ // The LB channel may be IDLE because it's shut down before the update.
+ // Restart the LB call to kick the LB channel into gear.
+ case GRPC_CHANNEL_IDLE:
+ case GRPC_CHANNEL_READY:
+ if (glb_policy->lb_calld != nullptr) {
+ lb_call_data_shutdown(glb_policy);
+ }
+ if (glb_policy->started_picking) {
+ if (glb_policy->retry_timer_callback_pending) {
+ grpc_timer_cancel(&glb_policy->lb_call_retry_timer);
+ }
+ glb_policy->lb_call_backoff->Reset();
+ query_for_backends_locked(glb_policy);
+ }
+ // Fall through.
+ case GRPC_CHANNEL_SHUTDOWN:
+ done:
+ glb_policy->watching_lb_channel = false;
+ GRPC_LB_POLICY_UNREF(&glb_policy->base,
+ "watch_lb_channel_connectivity_cb_shutdown");
+ }
+}
+
+static void glb_set_reresolve_closure_locked(
+ grpc_lb_policy* policy, grpc_closure* request_reresolution) {
+ glb_lb_policy* glb_policy = (glb_lb_policy*)policy;
+ GPR_ASSERT(!glb_policy->shutting_down);
+ GPR_ASSERT(glb_policy->base.request_reresolution == nullptr);
+ if (glb_policy->rr_policy != nullptr) {
+ grpc_lb_policy_set_reresolve_closure_locked(glb_policy->rr_policy,
+ request_reresolution);
+ } else {
+ glb_policy->base.request_reresolution = request_reresolution;
+ }
+}
+
+/* Code wiring the policy with the rest of the core */
+static const grpc_lb_policy_vtable glb_lb_policy_vtable = {
+ glb_destroy,
+ glb_shutdown_locked,
+ glb_pick_locked,
+ glb_cancel_pick_locked,
+ glb_cancel_picks_locked,
+ glb_ping_one_locked,
+ glb_exit_idle_locked,
+ glb_check_connectivity_locked,
+ glb_notify_on_state_change_locked,
+ glb_update_locked,
+ glb_set_reresolve_closure_locked};
+
+static grpc_lb_policy* glb_create(grpc_lb_policy_factory* factory,
+ grpc_lb_policy_args* args) {
+ /* Count the number of gRPC-LB addresses. There must be at least one. */
+ const grpc_arg* arg =
+ grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
+ if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
+ return nullptr;
+ }
+ grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p;
+ size_t num_grpclb_addrs = 0;
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
+ if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
+ }
+ if (num_grpclb_addrs == 0) return nullptr;
+
+ glb_lb_policy* glb_policy = (glb_lb_policy*)gpr_zalloc(sizeof(*glb_policy));
+
+ /* Get server name. */
+ arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
+ GPR_ASSERT(arg != nullptr);
+ GPR_ASSERT(arg->type == GRPC_ARG_STRING);
+ grpc_uri* uri = grpc_uri_parse(arg->value.string, true);
+ GPR_ASSERT(uri->path[0] != '\0');
+ glb_policy->server_name =
+ gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
+ if (grpc_lb_glb_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[grpclb %p] Will use '%s' as the server name for LB request.",
+ glb_policy, glb_policy->server_name);
+ }
+ grpc_uri_destroy(uri);
+
+ glb_policy->cc_factory = args->client_channel_factory;
+ GPR_ASSERT(glb_policy->cc_factory != nullptr);
+
+ arg = grpc_channel_args_find(args->args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS);
+ glb_policy->lb_call_timeout_ms =
+ grpc_channel_arg_get_integer(arg, {0, 0, INT_MAX});
+
+ arg = grpc_channel_args_find(args->args, GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS);
+ glb_policy->lb_fallback_timeout_ms = grpc_channel_arg_get_integer(
+ arg, {GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX});
+
+ // Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
+ // since we use this to trigger the client_load_reporting filter.
+ grpc_arg new_arg = grpc_channel_arg_string_create(
+ (char*)GRPC_ARG_LB_POLICY_NAME, (char*)"grpclb");
+ static const char* args_to_remove[] = {GRPC_ARG_LB_POLICY_NAME};
+ glb_policy->args = grpc_channel_args_copy_and_add_and_remove(
+ args->args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1);
+
+ /* Extract the backend addresses (may be empty) from the resolver for
+ * fallback. */
+ glb_policy->fallback_backend_addresses =
+ extract_backend_addresses_locked(addresses);
+
+ /* Create a client channel over them to communicate with a LB service */
+ glb_policy->response_generator =
+ grpc_fake_resolver_response_generator_create();
+ grpc_channel_args* lb_channel_args = build_lb_channel_args(
+ addresses, glb_policy->response_generator, 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);
+ grpc_channel_args_destroy(lb_channel_args);
+ gpr_free(uri_str);
+ if (glb_policy->lb_channel == nullptr) {
+ gpr_free((void*)glb_policy->server_name);
+ grpc_channel_args_destroy(glb_policy->args);
+ gpr_free(glb_policy);
+ return nullptr;
+ }
+ grpc_subchannel_index_ref();
+ GRPC_CLOSURE_INIT(&glb_policy->lb_channel_on_connectivity_changed,
+ glb_lb_channel_on_connectivity_changed_cb, glb_policy,
+ grpc_combiner_scheduler(args->combiner));
+ grpc_lb_policy_init(&glb_policy->base, &glb_lb_policy_vtable, args->combiner);
+ grpc_connectivity_state_init(&glb_policy->state_tracker, GRPC_CHANNEL_IDLE,
+ "grpclb");
+ // Init LB call backoff option.
+ grpc_core::BackOff::Options backoff_options;
+ backoff_options
+ .set_initial_backoff(GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS * 1000)
+ .set_multiplier(GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER)
+ .set_jitter(GRPC_GRPCLB_RECONNECT_JITTER)
+ .set_max_backoff(GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
+ glb_policy->lb_call_backoff.Init(backoff_options);
+ return &glb_policy->base;
+}
+
+static void glb_factory_ref(grpc_lb_policy_factory* factory) {}
+
+static void glb_factory_unref(grpc_lb_policy_factory* factory) {}
+
+static const grpc_lb_policy_factory_vtable glb_factory_vtable = {
+ glb_factory_ref, glb_factory_unref, glb_create, "grpclb"};
+
+static grpc_lb_policy_factory glb_lb_policy_factory = {&glb_factory_vtable};
+
+grpc_lb_policy_factory* grpc_glb_lb_factory_create() {
+ return &glb_lb_policy_factory;
+}
+
+/* Plugin registration */
+
+// Only add client_load_reporting filter if the grpclb LB policy is used.
+static bool maybe_add_client_load_reporting_filter(
+ grpc_channel_stack_builder* builder, void* arg) {
+ const grpc_channel_args* args =
+ grpc_channel_stack_builder_get_channel_arguments(builder);
+ const grpc_arg* channel_arg =
+ grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME);
+ if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_STRING &&
+ strcmp(channel_arg->value.string, "grpclb") == 0) {
+ return grpc_channel_stack_builder_append_filter(
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
+ }
+ return true;
+}
+
+void grpc_lb_policy_grpclb_init() {
+ grpc_register_lb_policy(grpc_glb_lb_factory_create());
+ grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
+ GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
+ maybe_add_client_load_reporting_filter,
+ (void*)&grpc_client_load_reporting_filter);
+}
+
+void grpc_lb_policy_grpclb_shutdown() {}
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h
index 63ad66c5e9..0a2edb0e3d 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h
@@ -24,6 +24,6 @@
/** Returns a load balancing factory for the glb policy, which tries to connect
* to a load balancing server to decide the next successfully connected
* subchannel to pick. */
-grpc_lb_policy_factory *grpc_glb_lb_factory_create();
+grpc_lb_policy_factory* grpc_glb_lb_factory_create();
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
index f2967182e2..1e7f34bdc7 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
@@ -22,23 +22,23 @@
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/string.h"
-grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
- grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
- grpc_client_channel_factory *client_channel_factory,
- grpc_channel_args *args) {
- grpc_channel *lb_channel = grpc_client_channel_factory_create_channel(
- exec_ctx, client_channel_factory, lb_service_target_addresses,
+grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
+ const char* lb_service_target_addresses,
+ grpc_client_channel_factory* client_channel_factory,
+ grpc_channel_args* args) {
+ grpc_channel* lb_channel = grpc_client_channel_factory_create_channel(
+ client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, args);
return lb_channel;
}
-grpc_channel_args *grpc_lb_policy_grpclb_build_lb_channel_args(
- grpc_exec_ctx *exec_ctx, grpc_slice_hash_table *targets_info,
- grpc_fake_resolver_response_generator *response_generator,
- const grpc_channel_args *args) {
+grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
+ grpc_slice_hash_table* targets_info,
+ grpc_fake_resolver_response_generator* response_generator,
+ const grpc_channel_args* args) {
const grpc_arg to_add[] = {
grpc_fake_resolver_response_generator_arg(response_generator)};
/* We remove:
@@ -62,7 +62,7 @@ grpc_channel_args *grpc_lb_policy_grpclb_build_lb_channel_args(
*
* - The fake resolver generator, because we are replacing it with the one
* from the grpclb policy, used to propagate updates to the LB channel. */
- static const char *keys_to_remove[] = {
+ static const char* keys_to_remove[] = {
GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI,
GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR};
return grpc_channel_args_copy_and_add_and_remove(
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 6120bf53f7..56104b2ec0 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
@@ -30,15 +30,15 @@
* from resolving the LB service's name (eg, ipv4:10.0.0.1:1234,10.2.3.4:9876).
* \a client_channel_factory will be used for the creation of the LB channel,
* alongside the channel args passed in \a args. */
-grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
- grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
- grpc_client_channel_factory *client_channel_factory,
- grpc_channel_args *args);
+grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
+ const char* lb_service_target_addresses,
+ grpc_client_channel_factory* client_channel_factory,
+ grpc_channel_args* args);
-grpc_channel_args *grpc_lb_policy_grpclb_build_lb_channel_args(
- grpc_exec_ctx *exec_ctx, grpc_slice_hash_table *targets_info,
- grpc_fake_resolver_response_generator *response_generator,
- const grpc_channel_args *args);
+grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
+ grpc_slice_hash_table* targets_info,
+ grpc_fake_resolver_response_generator* 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.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
index 2681b2a079..15233d371c 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
@@ -22,49 +22,49 @@
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/transport/lb_targets_info.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
-grpc_channel *grpc_lb_policy_grpclb_create_lb_channel(
- grpc_exec_ctx *exec_ctx, const char *lb_service_target_addresses,
- grpc_client_channel_factory *client_channel_factory,
- grpc_channel_args *args) {
- grpc_channel_args *new_args = args;
- grpc_channel_credentials *channel_credentials =
+grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
+ const char* lb_service_target_addresses,
+ grpc_client_channel_factory* client_channel_factory,
+ grpc_channel_args* args) {
+ grpc_channel_args* new_args = args;
+ grpc_channel_credentials* channel_credentials =
grpc_channel_credentials_find_in_args(args);
- if (channel_credentials != NULL) {
+ if (channel_credentials != nullptr) {
/* Substitute the channel credentials with a version without call
* credentials: the load balancer is not necessarily trusted to handle
* bearer token credentials */
- static const char *keys_to_remove[] = {GRPC_ARG_CHANNEL_CREDENTIALS};
- grpc_channel_credentials *creds_sans_call_creds =
+ static const char* keys_to_remove[] = {GRPC_ARG_CHANNEL_CREDENTIALS};
+ grpc_channel_credentials* creds_sans_call_creds =
grpc_channel_credentials_duplicate_without_call_credentials(
channel_credentials);
- GPR_ASSERT(creds_sans_call_creds != NULL);
+ GPR_ASSERT(creds_sans_call_creds != nullptr);
grpc_arg args_to_add[] = {
grpc_channel_credentials_to_arg(creds_sans_call_creds)};
/* Create the new set of channel args */
new_args = grpc_channel_args_copy_and_add_and_remove(
args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add,
GPR_ARRAY_SIZE(args_to_add));
- grpc_channel_credentials_unref(exec_ctx, creds_sans_call_creds);
+ grpc_channel_credentials_unref(creds_sans_call_creds);
}
- grpc_channel *lb_channel = grpc_client_channel_factory_create_channel(
- exec_ctx, client_channel_factory, lb_service_target_addresses,
+ grpc_channel* lb_channel = grpc_client_channel_factory_create_channel(
+ client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
- if (channel_credentials != NULL) {
- grpc_channel_args_destroy(exec_ctx, new_args);
+ if (channel_credentials != nullptr) {
+ grpc_channel_args_destroy(new_args);
}
return lb_channel;
}
-grpc_channel_args *grpc_lb_policy_grpclb_build_lb_channel_args(
- grpc_exec_ctx *exec_ctx, grpc_slice_hash_table *targets_info,
- grpc_fake_resolver_response_generator *response_generator,
- const grpc_channel_args *args) {
+grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
+ grpc_slice_hash_table* targets_info,
+ grpc_fake_resolver_response_generator* 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)};
@@ -89,7 +89,7 @@ grpc_channel_args *grpc_lb_policy_grpclb_build_lb_channel_args(
*
* - The fake resolver generator, because we are replacing it with the one
* from the grpclb policy, used to propagate updates to the LB channel. */
- static const char *keys_to_remove[] = {
+ static const char* keys_to_remove[] = {
GRPC_ARG_LB_POLICY_NAME, GRPC_ARG_LB_ADDRESSES, GRPC_ARG_SERVER_URI,
GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR};
/* Add the targets info table to be used for secure naming */
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
index 903120ca7d..e19a6a71aa 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
@@ -87,7 +87,7 @@ void grpc_grpclb_client_stats_add_call_dropped_locked(
gpr_atm_full_fetch_add(&client_stats->num_calls_started, (gpr_atm)1);
gpr_atm_full_fetch_add(&client_stats->num_calls_finished, (gpr_atm)1);
// Record the drop.
- if (client_stats->drop_token_counts == NULL) {
+ if (client_stats->drop_token_counts == nullptr) {
client_stats->drop_token_counts =
(grpc_grpclb_dropped_call_counts*)gpr_zalloc(
sizeof(grpc_grpclb_dropped_call_counts));
@@ -136,12 +136,12 @@ void grpc_grpclb_client_stats_get_locked(
num_calls_finished_known_received,
&client_stats->num_calls_finished_known_received);
*drop_token_counts = client_stats->drop_token_counts;
- client_stats->drop_token_counts = NULL;
+ client_stats->drop_token_counts = nullptr;
}
void grpc_grpclb_dropped_call_counts_destroy(
grpc_grpclb_dropped_call_counts* drop_entries) {
- if (drop_entries != NULL) {
+ if (drop_entries != nullptr) {
for (size_t i = 0; i < drop_entries->num_entries; ++i) {
gpr_free(drop_entries->token_counts[i].token);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
index c51e2a431a..d4b9d06848 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
@@ -62,4 +62,4 @@ void grpc_grpclb_dropped_call_counts_destroy(
grpc_grpclb_dropped_call_counts* drop_entries);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CLIENT_STATS_H \
- */
+ */
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
index 8ef6dfc6f4..fc781da330 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
@@ -23,9 +23,9 @@
#include <grpc/support/alloc.h>
/* invoked once for every Server in ServerList */
-static bool count_serverlist(pb_istream_t *stream, const pb_field_t *field,
- void **arg) {
- grpc_grpclb_serverlist *sl = (grpc_grpclb_serverlist *)*arg;
+static bool count_serverlist(pb_istream_t* stream, const pb_field_t* field,
+ void** arg) {
+ grpc_grpclb_serverlist* sl = (grpc_grpclb_serverlist*)*arg;
grpc_grpclb_server server;
if (!pb_decode(stream, grpc_lb_v1_Server_fields, &server)) {
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
@@ -40,16 +40,16 @@ typedef struct decode_serverlist_arg {
* which index of the serverlist are we currently decoding */
size_t decoding_idx;
/* The decoded serverlist */
- grpc_grpclb_serverlist *serverlist;
+ grpc_grpclb_serverlist* serverlist;
} decode_serverlist_arg;
/* invoked once for every Server in ServerList */
-static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
- void **arg) {
- decode_serverlist_arg *dec_arg = (decode_serverlist_arg *)*arg;
+static bool decode_serverlist(pb_istream_t* stream, const pb_field_t* field,
+ void** arg) {
+ decode_serverlist_arg* dec_arg = (decode_serverlist_arg*)*arg;
GPR_ASSERT(dec_arg->serverlist->num_servers >= dec_arg->decoding_idx);
- grpc_grpclb_server *server =
- (grpc_grpclb_server *)gpr_zalloc(sizeof(grpc_grpclb_server));
+ grpc_grpclb_server* server =
+ (grpc_grpclb_server*)gpr_zalloc(sizeof(grpc_grpclb_server));
if (!pb_decode(stream, grpc_lb_v1_Server_fields, server)) {
gpr_free(server);
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
@@ -59,9 +59,9 @@ static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
return true;
}
-grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) {
- grpc_grpclb_request *req =
- (grpc_grpclb_request *)gpr_malloc(sizeof(grpc_grpclb_request));
+grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name) {
+ grpc_grpclb_request* req =
+ (grpc_grpclb_request*)gpr_malloc(sizeof(grpc_grpclb_request));
req->has_client_stats = false;
req->has_initial_request = true;
req->initial_request.has_name = true;
@@ -71,25 +71,25 @@ grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) {
}
static void populate_timestamp(gpr_timespec timestamp,
- struct _grpc_lb_v1_Timestamp *timestamp_pb) {
+ struct _grpc_lb_v1_Timestamp* timestamp_pb) {
timestamp_pb->has_seconds = true;
timestamp_pb->seconds = timestamp.tv_sec;
timestamp_pb->has_nanos = true;
timestamp_pb->nanos = timestamp.tv_nsec;
}
-static bool encode_string(pb_ostream_t *stream, const pb_field_t *field,
- void *const *arg) {
- char *str = (char *)*arg;
+static bool encode_string(pb_ostream_t* stream, const pb_field_t* field,
+ void* const* arg) {
+ char* str = (char*)*arg;
if (!pb_encode_tag_for_field(stream, field)) return false;
- return pb_encode_string(stream, (uint8_t *)str, strlen(str));
+ return pb_encode_string(stream, (uint8_t*)str, strlen(str));
}
-static bool encode_drops(pb_ostream_t *stream, const pb_field_t *field,
- void *const *arg) {
- grpc_grpclb_dropped_call_counts *drop_entries =
- (grpc_grpclb_dropped_call_counts *)*arg;
- if (drop_entries == NULL) return true;
+static bool encode_drops(pb_ostream_t* stream, const pb_field_t* field,
+ void* const* arg) {
+ grpc_grpclb_dropped_call_counts* drop_entries =
+ (grpc_grpclb_dropped_call_counts*)*arg;
+ if (drop_entries == nullptr) return true;
for (size_t i = 0; i < drop_entries->num_entries; ++i) {
if (!pb_encode_tag_for_field(stream, field)) return false;
grpc_lb_v1_ClientStatsPerToken drop_message;
@@ -105,10 +105,10 @@ static bool encode_drops(pb_ostream_t *stream, const pb_field_t *field,
return true;
}
-grpc_grpclb_request *grpc_grpclb_load_report_request_create_locked(
- grpc_grpclb_client_stats *client_stats) {
- grpc_grpclb_request *req =
- (grpc_grpclb_request *)gpr_zalloc(sizeof(grpc_grpclb_request));
+grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked(
+ grpc_grpclb_client_stats* client_stats) {
+ grpc_grpclb_request* req =
+ (grpc_grpclb_request*)gpr_zalloc(sizeof(grpc_grpclb_request));
req->has_client_stats = true;
req->client_stats.has_timestamp = true;
populate_timestamp(gpr_now(GPR_CLOCK_REALTIME), &req->client_stats.timestamp);
@@ -123,12 +123,12 @@ grpc_grpclb_request *grpc_grpclb_load_report_request_create_locked(
&req->client_stats.num_calls_finished,
&req->client_stats.num_calls_finished_with_client_failed_to_send,
&req->client_stats.num_calls_finished_known_received,
- (grpc_grpclb_dropped_call_counts **)&req->client_stats
+ (grpc_grpclb_dropped_call_counts**)&req->client_stats
.calls_finished_with_drop.arg);
return req;
}
-grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
+grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request) {
size_t encoded_length;
pb_ostream_t sizestream;
pb_ostream_t outputstream;
@@ -145,10 +145,10 @@ grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
return slice;
}
-void grpc_grpclb_request_destroy(grpc_grpclb_request *request) {
+void grpc_grpclb_request_destroy(grpc_grpclb_request* request) {
if (request->has_client_stats) {
- grpc_grpclb_dropped_call_counts *drop_entries =
- (grpc_grpclb_dropped_call_counts *)
+ grpc_grpclb_dropped_call_counts* drop_entries =
+ (grpc_grpclb_dropped_call_counts*)
request->client_stats.calls_finished_with_drop.arg;
grpc_grpclb_dropped_call_counts_destroy(drop_entries);
}
@@ -156,7 +156,7 @@ void grpc_grpclb_request_destroy(grpc_grpclb_request *request) {
}
typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response;
-grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
+grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse(
grpc_slice encoded_grpc_grpclb_response) {
pb_istream_t stream =
pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response),
@@ -165,13 +165,13 @@ grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
memset(&res, 0, sizeof(grpc_grpclb_response));
if (!pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res)) {
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
- return NULL;
+ return nullptr;
}
- if (!res.has_initial_response) return NULL;
+ if (!res.has_initial_response) return nullptr;
- grpc_grpclb_initial_response *initial_res =
- (grpc_grpclb_initial_response *)gpr_malloc(
+ grpc_grpclb_initial_response* initial_res =
+ (grpc_grpclb_initial_response*)gpr_malloc(
sizeof(grpc_grpclb_initial_response));
memcpy(initial_res, &res.initial_response,
sizeof(grpc_grpclb_initial_response));
@@ -179,14 +179,14 @@ grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
return initial_res;
}
-grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
+grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
grpc_slice encoded_grpc_grpclb_response) {
pb_istream_t stream =
pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response),
GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response));
pb_istream_t stream_at_start = stream;
- grpc_grpclb_serverlist *sl =
- (grpc_grpclb_serverlist *)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
+ grpc_grpclb_serverlist* sl =
+ (grpc_grpclb_serverlist*)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
grpc_grpclb_response res;
memset(&res, 0, sizeof(grpc_grpclb_response));
// First pass: count number of servers.
@@ -196,12 +196,12 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
if (!status) {
gpr_free(sl);
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
- return NULL;
+ return nullptr;
}
// Second pass: populate servers.
if (sl->num_servers > 0) {
- sl->servers = (grpc_grpclb_server **)gpr_zalloc(
- sizeof(grpc_grpclb_server *) * sl->num_servers);
+ sl->servers = (grpc_grpclb_server**)gpr_zalloc(sizeof(grpc_grpclb_server*) *
+ sl->num_servers);
decode_serverlist_arg decode_arg;
memset(&decode_arg, 0, sizeof(decode_arg));
decode_arg.serverlist = sl;
@@ -212,17 +212,14 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
if (!status) {
grpc_grpclb_destroy_serverlist(sl);
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
- return NULL;
+ return nullptr;
}
}
- if (res.server_list.has_expiration_interval) {
- sl->expiration_interval = res.server_list.expiration_interval;
- }
return sl;
}
-void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist) {
- if (serverlist == NULL) {
+void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist) {
+ if (serverlist == nullptr) {
return;
}
for (size_t i = 0; i < serverlist->num_servers; i++) {
@@ -232,35 +229,29 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist) {
gpr_free(serverlist);
}
-grpc_grpclb_serverlist *grpc_grpclb_serverlist_copy(
- const grpc_grpclb_serverlist *sl) {
- grpc_grpclb_serverlist *copy =
- (grpc_grpclb_serverlist *)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
+grpc_grpclb_serverlist* grpc_grpclb_serverlist_copy(
+ const grpc_grpclb_serverlist* sl) {
+ grpc_grpclb_serverlist* copy =
+ (grpc_grpclb_serverlist*)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
copy->num_servers = sl->num_servers;
- memcpy(&copy->expiration_interval, &sl->expiration_interval,
- sizeof(grpc_grpclb_duration));
- copy->servers = (grpc_grpclb_server **)gpr_malloc(
- sizeof(grpc_grpclb_server *) * sl->num_servers);
+ copy->servers = (grpc_grpclb_server**)gpr_malloc(sizeof(grpc_grpclb_server*) *
+ sl->num_servers);
for (size_t i = 0; i < sl->num_servers; i++) {
copy->servers[i] =
- (grpc_grpclb_server *)gpr_malloc(sizeof(grpc_grpclb_server));
+ (grpc_grpclb_server*)gpr_malloc(sizeof(grpc_grpclb_server));
memcpy(copy->servers[i], sl->servers[i], sizeof(grpc_grpclb_server));
}
return copy;
}
-bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist *lhs,
- const grpc_grpclb_serverlist *rhs) {
- if (lhs == NULL || rhs == NULL) {
+bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist* lhs,
+ const grpc_grpclb_serverlist* rhs) {
+ if (lhs == nullptr || rhs == nullptr) {
return false;
}
if (lhs->num_servers != rhs->num_servers) {
return false;
}
- if (grpc_grpclb_duration_compare(&lhs->expiration_interval,
- &rhs->expiration_interval) != 0) {
- return false;
- }
for (size_t i = 0; i < lhs->num_servers; i++) {
if (!grpc_grpclb_server_equals(lhs->servers[i], rhs->servers[i])) {
return false;
@@ -269,13 +260,13 @@ bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist *lhs,
return true;
}
-bool grpc_grpclb_server_equals(const grpc_grpclb_server *lhs,
- const grpc_grpclb_server *rhs) {
+bool grpc_grpclb_server_equals(const grpc_grpclb_server* lhs,
+ const grpc_grpclb_server* rhs) {
return memcmp(lhs, rhs, sizeof(grpc_grpclb_server)) == 0;
}
-int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
- const grpc_grpclb_duration *rhs) {
+int grpc_grpclb_duration_compare(const grpc_grpclb_duration* lhs,
+ const grpc_grpclb_duration* rhs) {
GPR_ASSERT(lhs && rhs);
if (lhs->has_seconds && rhs->has_seconds) {
if (lhs->seconds < rhs->seconds) return -1;
@@ -299,16 +290,13 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
return 0;
}
-gpr_timespec grpc_grpclb_duration_to_timespec(
- grpc_grpclb_duration *duration_pb) {
- gpr_timespec duration;
- duration.tv_sec = duration_pb->has_seconds ? duration_pb->seconds : 0;
- duration.tv_nsec = duration_pb->has_nanos ? duration_pb->nanos : 0;
- duration.clock_type = GPR_TIMESPAN;
- return duration;
+grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration* duration_pb) {
+ return (grpc_millis)(
+ (duration_pb->has_seconds ? duration_pb->seconds : 0) * GPR_MS_PER_SEC +
+ (duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS);
}
void grpc_grpclb_initial_response_destroy(
- grpc_grpclb_initial_response *response) {
+ grpc_grpclb_initial_response* response) {
gpr_free(response);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
index c4a98492c9..ccb0212643 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
@@ -25,10 +25,6 @@
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128
typedef grpc_lb_v1_Server_ip_address_t grpc_grpclb_ip_address;
@@ -37,60 +33,54 @@ typedef grpc_lb_v1_InitialLoadBalanceResponse grpc_grpclb_initial_response;
typedef grpc_lb_v1_Server grpc_grpclb_server;
typedef grpc_lb_v1_Duration grpc_grpclb_duration;
typedef struct {
- grpc_grpclb_server **servers;
+ grpc_grpclb_server** servers;
size_t num_servers;
- grpc_grpclb_duration expiration_interval;
} grpc_grpclb_serverlist;
/** Create a request for a gRPC LB service under \a lb_service_name */
-grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name);
-grpc_grpclb_request *grpc_grpclb_load_report_request_create_locked(
- grpc_grpclb_client_stats *client_stats);
+grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name);
+grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked(
+ grpc_grpclb_client_stats* client_stats);
/** Protocol Buffers v3-encode \a request */
-grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request);
+grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request);
/** Destroy \a request */
-void grpc_grpclb_request_destroy(grpc_grpclb_request *request);
+void grpc_grpclb_request_destroy(grpc_grpclb_request* request);
/** Parse (ie, decode) the bytes in \a encoded_grpc_grpclb_response as a \a
* grpc_grpclb_initial_response */
-grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
+grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse(
grpc_slice encoded_grpc_grpclb_response);
/** Parse the list of servers from an encoded \a grpc_grpclb_response */
-grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
+grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
grpc_slice encoded_grpc_grpclb_response);
/** Return a copy of \a sl. The caller is responsible for calling \a
* grpc_grpclb_destroy_serverlist on the returned copy. */
-grpc_grpclb_serverlist *grpc_grpclb_serverlist_copy(
- const grpc_grpclb_serverlist *sl);
+grpc_grpclb_serverlist* grpc_grpclb_serverlist_copy(
+ const grpc_grpclb_serverlist* sl);
-bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist *lhs,
- const grpc_grpclb_serverlist *rhs);
+bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist* lhs,
+ const grpc_grpclb_serverlist* rhs);
-bool grpc_grpclb_server_equals(const grpc_grpclb_server *lhs,
- const grpc_grpclb_server *rhs);
+bool grpc_grpclb_server_equals(const grpc_grpclb_server* lhs,
+ const grpc_grpclb_server* rhs);
/** Destroy \a serverlist */
-void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist);
+void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist);
/** Compare \a lhs against \a rhs and return 0 if \a lhs and \a rhs are equal,
* < 0 if \a lhs represents a duration shorter than \a rhs and > 0 otherwise */
-int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
- const grpc_grpclb_duration *rhs);
+int grpc_grpclb_duration_compare(const grpc_grpclb_duration* lhs,
+ const grpc_grpclb_duration* rhs);
-gpr_timespec grpc_grpclb_duration_to_timespec(
- grpc_grpclb_duration *duration_pb);
+grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration* duration_pb);
/** Destroy \a initial_response */
void grpc_grpclb_initial_response_destroy(
- grpc_grpclb_initial_response *response);
-
-#ifdef __cplusplus
-}
-#endif
+ grpc_grpclb_initial_response* response);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H \
- */
+ */
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
index 6a5d54c82a..4e6c5cc832 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
@@ -61,9 +61,8 @@ const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3] = {
PB_LAST_FIELD
};
-const pb_field_t grpc_lb_v1_ServerList_fields[3] = {
+const pb_field_t grpc_lb_v1_ServerList_fields[2] = {
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, grpc_lb_v1_ServerList, servers, servers, &grpc_lb_v1_Server_fields),
- PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ServerList, expiration_interval, servers, &grpc_lb_v1_Duration_fields),
PB_LAST_FIELD
};
@@ -85,7 +84,7 @@ const pb_field_t grpc_lb_v1_Server_fields[5] = {
* numbers or field sizes that are larger than what can fit in 8 or 16 bit
* field descriptors.
*/
-PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v1_ServerList, servers) < 65536 && pb_membersize(grpc_lb_v1_ServerList, expiration_interval) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
+PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v1_ServerList, servers) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
#endif
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
@@ -96,7 +95,7 @@ PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request)
* numbers or field sizes that are larger than what can fit in the default
* 8 bit descriptors.
*/
-PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 256 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v1_ServerList, servers) < 256 && pb_membersize(grpc_lb_v1_ServerList, expiration_interval) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
+PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 256 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v1_ServerList, servers) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
#endif
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
index 93333d1aed..066c076202 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
@@ -14,6 +14,11 @@ extern "C" {
#endif
/* Struct definitions */
+typedef struct _grpc_lb_v1_ServerList {
+ pb_callback_t servers;
+/* @@protoc_insertion_point(struct:grpc_lb_v1_ServerList) */
+} grpc_lb_v1_ServerList;
+
typedef struct _grpc_lb_v1_ClientStatsPerToken {
pb_callback_t load_balance_token;
bool has_num_calls;
@@ -79,13 +84,6 @@ typedef struct _grpc_lb_v1_InitialLoadBalanceResponse {
/* @@protoc_insertion_point(struct:grpc_lb_v1_InitialLoadBalanceResponse) */
} grpc_lb_v1_InitialLoadBalanceResponse;
-typedef struct _grpc_lb_v1_ServerList {
- pb_callback_t servers;
- bool has_expiration_interval;
- grpc_lb_v1_Duration expiration_interval;
-/* @@protoc_insertion_point(struct:grpc_lb_v1_ServerList) */
-} grpc_lb_v1_ServerList;
-
typedef struct _grpc_lb_v1_LoadBalanceRequest {
bool has_initial_request;
grpc_lb_v1_InitialLoadBalanceRequest initial_request;
@@ -113,7 +111,7 @@ typedef struct _grpc_lb_v1_LoadBalanceResponse {
#define grpc_lb_v1_ClientStats_init_default {false, grpc_lb_v1_Timestamp_init_default, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}}
#define grpc_lb_v1_LoadBalanceResponse_init_default {false, grpc_lb_v1_InitialLoadBalanceResponse_init_default, false, grpc_lb_v1_ServerList_init_default}
#define grpc_lb_v1_InitialLoadBalanceResponse_init_default {false, "", false, grpc_lb_v1_Duration_init_default}
-#define grpc_lb_v1_ServerList_init_default {{{NULL}, NULL}, false, grpc_lb_v1_Duration_init_default}
+#define grpc_lb_v1_ServerList_init_default {{{NULL}, NULL}}
#define grpc_lb_v1_Server_init_default {false, {0, {0}}, false, 0, false, "", false, 0}
#define grpc_lb_v1_Duration_init_zero {false, 0, false, 0}
#define grpc_lb_v1_Timestamp_init_zero {false, 0, false, 0}
@@ -123,10 +121,11 @@ typedef struct _grpc_lb_v1_LoadBalanceResponse {
#define grpc_lb_v1_ClientStats_init_zero {false, grpc_lb_v1_Timestamp_init_zero, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}}
#define grpc_lb_v1_LoadBalanceResponse_init_zero {false, grpc_lb_v1_InitialLoadBalanceResponse_init_zero, false, grpc_lb_v1_ServerList_init_zero}
#define grpc_lb_v1_InitialLoadBalanceResponse_init_zero {false, "", false, grpc_lb_v1_Duration_init_zero}
-#define grpc_lb_v1_ServerList_init_zero {{{NULL}, NULL}, false, grpc_lb_v1_Duration_init_zero}
+#define grpc_lb_v1_ServerList_init_zero {{{NULL}, NULL}}
#define grpc_lb_v1_Server_init_zero {false, {0, {0}}, false, 0, false, "", false, 0}
/* Field tags (for use in manual encoding/decoding) */
+#define grpc_lb_v1_ServerList_servers_tag 1
#define grpc_lb_v1_ClientStatsPerToken_load_balance_token_tag 1
#define grpc_lb_v1_ClientStatsPerToken_num_calls_tag 2
#define grpc_lb_v1_Duration_seconds_tag 1
@@ -146,8 +145,6 @@ typedef struct _grpc_lb_v1_LoadBalanceResponse {
#define grpc_lb_v1_ClientStats_calls_finished_with_drop_tag 8
#define grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate_tag 1
#define grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval_tag 2
-#define grpc_lb_v1_ServerList_servers_tag 1
-#define grpc_lb_v1_ServerList_expiration_interval_tag 3
#define grpc_lb_v1_LoadBalanceRequest_initial_request_tag 1
#define grpc_lb_v1_LoadBalanceRequest_client_stats_tag 2
#define grpc_lb_v1_LoadBalanceResponse_initial_response_tag 1
@@ -162,7 +159,7 @@ extern const pb_field_t grpc_lb_v1_ClientStatsPerToken_fields[3];
extern const pb_field_t grpc_lb_v1_ClientStats_fields[7];
extern const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3];
extern const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3];
-extern const pb_field_t grpc_lb_v1_ServerList_fields[3];
+extern const pb_field_t grpc_lb_v1_ServerList_fields[2];
extern const pb_field_t grpc_lb_v1_Server_fields[5];
/* Maximum encoded size of messages (where known) */
diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
deleted file mode 100644
index d20cbb8388..0000000000
--- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
+++ /dev/null
@@ -1,714 +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 <string.h>
-
-#include <grpc/support/alloc.h>
-
-#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
-#include "src/core/ext/filters/client_channel/subchannel.h"
-#include "src/core/ext/filters/client_channel/subchannel_index.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/iomgr/combiner.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/transport/connectivity_state.h"
-
-grpc_tracer_flag grpc_lb_pick_first_trace =
- GRPC_TRACER_INITIALIZER(false, "pick_first");
-
-typedef struct pending_pick {
- struct pending_pick *next;
- uint32_t initial_metadata_flags;
- grpc_connected_subchannel **target;
- grpc_closure *on_complete;
-} pending_pick;
-
-typedef struct {
- /** base policy: must be first */
- grpc_lb_policy base;
- /** all our subchannels */
- grpc_subchannel **subchannels;
- grpc_subchannel **new_subchannels;
- size_t num_subchannels;
- size_t num_new_subchannels;
-
- grpc_closure connectivity_changed;
-
- /** remaining members are protected by the combiner */
-
- /** the selected channel */
- grpc_connected_subchannel *selected;
-
- /** the subchannel key for \a selected, or NULL if \a selected not set */
- const grpc_subchannel_key *selected_key;
-
- /** have we started picking? */
- bool started_picking;
- /** are we shut down? */
- bool shutdown;
- /** are we updating the selected subchannel? */
- bool updating_selected;
- /** are we updating the subchannel candidates? */
- bool updating_subchannels;
- /** args from the latest update received while already updating, or NULL */
- grpc_lb_policy_args *pending_update_args;
- /** which subchannel are we watching? */
- size_t checking_subchannel;
- /** what is the connectivity of that channel? */
- grpc_connectivity_state checking_connectivity;
- /** list of picks that are waiting on connectivity */
- pending_pick *pending_picks;
-
- /** our connectivity state tracker */
- grpc_connectivity_state_tracker state_tracker;
-} pick_first_lb_policy;
-
-static void pf_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- GPR_ASSERT(p->pending_picks == NULL);
- for (size_t i = 0; i < p->num_subchannels; i++) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[i], "pick_first_destroy");
- }
- if (p->selected != NULL) {
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, p->selected,
- "picked_first_destroy");
- }
- grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
- grpc_subchannel_index_unref();
- if (p->pending_update_args != NULL) {
- grpc_channel_args_destroy(exec_ctx, p->pending_update_args->args);
- gpr_free(p->pending_update_args);
- }
- gpr_free(p->subchannels);
- gpr_free(p->new_subchannels);
- gpr_free(p);
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_DEBUG, "Pick First %p destroyed.", (void *)p);
- }
-}
-
-static void pf_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- pending_pick *pp;
- p->shutdown = true;
- pp = p->pending_picks;
- p->pending_picks = NULL;
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown"), "shutdown");
- /* cancel subscription */
- if (p->selected != NULL) {
- grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, p->selected, NULL, NULL, &p->connectivity_changed);
- } else if (p->num_subchannels > 0 && p->started_picking) {
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel], NULL, NULL,
- &p->connectivity_changed);
- }
- while (pp != NULL) {
- pending_pick *next = pp->next;
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
- gpr_free(pp);
- pp = next;
- }
-}
-
-static void pf_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_connected_subchannel **target,
- grpc_error *error) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- pending_pick *pp;
- pp = p->pending_picks;
- p->pending_picks = NULL;
- while (pp != NULL) {
- pending_pick *next = pp->next;
- if (pp->target == target) {
- *target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick Cancelled", &error, 1));
- gpr_free(pp);
- } else {
- pp->next = p->pending_picks;
- p->pending_picks = pp;
- }
- pp = next;
- }
- GRPC_ERROR_UNREF(error);
-}
-
-static void pf_cancel_picks_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- uint32_t initial_metadata_flags_mask,
- uint32_t initial_metadata_flags_eq,
- grpc_error *error) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- pending_pick *pp;
- pp = p->pending_picks;
- p->pending_picks = NULL;
- while (pp != NULL) {
- pending_pick *next = pp->next;
- if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
- initial_metadata_flags_eq) {
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick Cancelled", &error, 1));
- gpr_free(pp);
- } else {
- pp->next = p->pending_picks;
- p->pending_picks = pp;
- }
- pp = next;
- }
- GRPC_ERROR_UNREF(error);
-}
-
-static void start_picking_locked(grpc_exec_ctx *exec_ctx,
- pick_first_lb_policy *p) {
- p->started_picking = true;
- if (p->subchannels != NULL) {
- GPR_ASSERT(p->num_subchannels > 0);
- p->checking_subchannel = 0;
- p->checking_connectivity = GRPC_CHANNEL_IDLE;
- GRPC_LB_POLICY_WEAK_REF(&p->base, "pick_first_connectivity");
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel],
- p->base.interested_parties, &p->checking_connectivity,
- &p->connectivity_changed);
- }
-}
-
-static void pf_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
- }
-}
-
-static int pf_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context, void **user_data,
- grpc_closure *on_complete) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- pending_pick *pp;
-
- /* Check atomically for a selected channel */
- if (p->selected != NULL) {
- *target = GRPC_CONNECTED_SUBCHANNEL_REF(p->selected, "picked");
- return 1;
- }
-
- /* No subchannel selected yet, so try again */
- if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
- }
- pp = (pending_pick *)gpr_malloc(sizeof(*pp));
- pp->next = p->pending_picks;
- pp->target = target;
- pp->initial_metadata_flags = pick_args->initial_metadata_flags;
- pp->on_complete = on_complete;
- p->pending_picks = pp;
- return 0;
-}
-
-static void destroy_subchannels_locked(grpc_exec_ctx *exec_ctx,
- pick_first_lb_policy *p) {
- size_t num_subchannels = p->num_subchannels;
- grpc_subchannel **subchannels = p->subchannels;
-
- p->num_subchannels = 0;
- p->subchannels = NULL;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "destroy_subchannels");
-
- for (size_t i = 0; i < num_subchannels; i++) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, subchannels[i], "pick_first");
- }
- gpr_free(subchannels);
-}
-
-static grpc_connectivity_state pf_check_connectivity_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_error **error) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- return grpc_connectivity_state_get(&p->state_tracker, error);
-}
-
-static void pf_notify_on_state_change_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *pol,
- grpc_connectivity_state *current,
- grpc_closure *notify) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- grpc_connectivity_state_notify_on_state_change(exec_ctx, &p->state_tracker,
- current, notify);
-}
-
-static void pf_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_closure *closure) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
- if (p->selected) {
- grpc_connected_subchannel_ping(exec_ctx, p->selected, closure);
- } else {
- GRPC_CLOSURE_SCHED(exec_ctx, closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Not connected"));
- }
-}
-
-/* unsubscribe all subchannels */
-static void stop_connectivity_watchers(grpc_exec_ctx *exec_ctx,
- pick_first_lb_policy *p) {
- if (p->num_subchannels > 0) {
- GPR_ASSERT(p->selected == NULL);
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_DEBUG, "Pick First %p unsubscribing from subchannel %p",
- (void *)p, (void *)p->subchannels[p->checking_subchannel]);
- }
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel], NULL, NULL,
- &p->connectivity_changed);
- p->updating_subchannels = true;
- } else if (p->selected != NULL) {
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_DEBUG,
- "Pick First %p unsubscribing from selected subchannel %p",
- (void *)p, (void *)p->selected);
- }
- grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, p->selected, NULL, NULL, &p->connectivity_changed);
- p->updating_selected = true;
- }
-}
-
-/* true upon success */
-static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_args *args) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)policy;
- const grpc_arg *arg =
- grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
- if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
- if (p->subchannels == NULL) {
- // If we don't have a current subchannel list, go into TRANSIENT FAILURE.
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
- "pf_update_missing");
- } else {
- // otherwise, keep using the current subchannel list (ignore this update).
- gpr_log(GPR_ERROR,
- "No valid LB addresses channel arg for Pick First %p update, "
- "ignoring.",
- (void *)p);
- }
- return;
- }
- const grpc_lb_addresses *addresses =
- (const grpc_lb_addresses *)arg->value.pointer.p;
- if (addresses->num_addresses == 0) {
- // Empty update. Unsubscribe from all current subchannels and put the
- // channel in TRANSIENT_FAILURE.
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
- "pf_update_empty");
- stop_connectivity_watchers(exec_ctx, p);
- return;
- }
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_INFO, "Pick First %p received update with %lu addresses",
- (void *)p, (unsigned long)addresses->num_addresses);
- }
- grpc_subchannel_args *sc_args = (grpc_subchannel_args *)gpr_zalloc(
- sizeof(*sc_args) * addresses->num_addresses);
- /* We remove the following keys in order for subchannel keys belonging to
- * subchannels point to the same address to match. */
- static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
- GRPC_ARG_LB_ADDRESSES};
- size_t sc_args_count = 0;
-
- /* Create list of subchannel args for new addresses in \a args. */
- for (size_t i = 0; i < addresses->num_addresses; i++) {
- // If there were any balancer, we would have chosen grpclb policy instead.
- GPR_ASSERT(!addresses->addresses[i].is_balancer);
- if (addresses->addresses[i].user_data != NULL) {
- gpr_log(GPR_ERROR,
- "This LB policy doesn't support user data. It will be ignored");
- }
- grpc_arg addr_arg =
- grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add_and_remove(
- args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
- 1);
- gpr_free(addr_arg.value.string);
- sc_args[sc_args_count++].args = new_args;
- }
-
- /* Check if p->selected is amongst them. If so, we are done. */
- if (p->selected != NULL) {
- GPR_ASSERT(p->selected_key != NULL);
- for (size_t i = 0; i < sc_args_count; i++) {
- grpc_subchannel_key *ith_sc_key = grpc_subchannel_key_create(&sc_args[i]);
- const bool found_selected =
- grpc_subchannel_key_compare(p->selected_key, ith_sc_key) == 0;
- grpc_subchannel_key_destroy(exec_ctx, ith_sc_key);
- if (found_selected) {
- // The currently selected subchannel is in the update: we are done.
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_INFO,
- "Pick First %p found already selected subchannel %p amongst "
- "updates. Update done.",
- (void *)p, (void *)p->selected);
- }
- for (size_t j = 0; j < sc_args_count; j++) {
- grpc_channel_args_destroy(exec_ctx,
- (grpc_channel_args *)sc_args[j].args);
- }
- gpr_free(sc_args);
- return;
- }
- }
- }
- // We only check for already running updates here because if the previous
- // steps were successful, the update can be considered done without any
- // interference (ie, no callbacks were scheduled).
- if (p->updating_selected || p->updating_subchannels) {
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_INFO,
- "Update already in progress for pick first %p. Deferring update.",
- (void *)p);
- }
- if (p->pending_update_args != NULL) {
- grpc_channel_args_destroy(exec_ctx, p->pending_update_args->args);
- gpr_free(p->pending_update_args);
- }
- p->pending_update_args =
- (grpc_lb_policy_args *)gpr_zalloc(sizeof(*p->pending_update_args));
- p->pending_update_args->client_channel_factory =
- args->client_channel_factory;
- p->pending_update_args->args = grpc_channel_args_copy(args->args);
- p->pending_update_args->combiner = args->combiner;
- return;
- }
- /* Create the subchannels for the new subchannel args/addresses. */
- grpc_subchannel **new_subchannels =
- (grpc_subchannel **)gpr_zalloc(sizeof(*new_subchannels) * sc_args_count);
- size_t num_new_subchannels = 0;
- for (size_t i = 0; i < sc_args_count; i++) {
- grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
- exec_ctx, args->client_channel_factory, &sc_args[i]);
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- char *address_uri =
- grpc_sockaddr_to_uri(&addresses->addresses[i].address);
- gpr_log(GPR_INFO,
- "Pick First %p created subchannel %p for address uri %s",
- (void *)p, (void *)subchannel, address_uri);
- gpr_free(address_uri);
- }
- grpc_channel_args_destroy(exec_ctx, (grpc_channel_args *)sc_args[i].args);
- if (subchannel != NULL) new_subchannels[num_new_subchannels++] = subchannel;
- }
- gpr_free(sc_args);
- if (num_new_subchannels == 0) {
- gpr_free(new_subchannels);
- // Empty update. Unsubscribe from all current subchannels and put the
- // channel in TRANSIENT_FAILURE.
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid addresses in update"),
- "pf_update_no_valid_addresses");
- stop_connectivity_watchers(exec_ctx, p);
- return;
- }
-
- /* Destroy the current subchannels. Repurpose pf_shutdown/destroy. */
- stop_connectivity_watchers(exec_ctx, p);
-
- /* Save new subchannels. The switch over will happen in
- * pf_connectivity_changed_locked */
- if (p->updating_selected || p->updating_subchannels) {
- p->num_new_subchannels = num_new_subchannels;
- p->new_subchannels = new_subchannels;
- } else { /* nothing is updating. Get things moving from here */
- p->num_subchannels = num_new_subchannels;
- p->subchannels = new_subchannels;
- p->new_subchannels = NULL;
- p->num_new_subchannels = 0;
- if (p->started_picking) {
- p->checking_subchannel = 0;
- p->checking_connectivity = GRPC_CHANNEL_IDLE;
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel],
- p->base.interested_parties, &p->checking_connectivity,
- &p->connectivity_changed);
- }
- }
-}
-
-static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- pick_first_lb_policy *p = (pick_first_lb_policy *)arg;
- grpc_subchannel *selected_subchannel;
- pending_pick *pp;
-
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(
- GPR_DEBUG,
- "Pick First %p connectivity changed. Updating selected: %d; Updating "
- "subchannels: %d; Checking %lu index (%lu total); State: %d; ",
- (void *)p, p->updating_selected, p->updating_subchannels,
- (unsigned long)p->checking_subchannel,
- (unsigned long)p->num_subchannels, p->checking_connectivity);
- }
- bool restart = false;
- if (p->updating_selected && error != GRPC_ERROR_NONE) {
- /* Captured the unsubscription for p->selected */
- GPR_ASSERT(p->selected != NULL);
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, p->selected,
- "pf_update_connectivity");
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_DEBUG, "Pick First %p unreffing selected subchannel %p",
- (void *)p, (void *)p->selected);
- }
- p->updating_selected = false;
- if (p->num_new_subchannels == 0) {
- p->selected = NULL;
- return;
- }
- restart = true;
- }
- if (p->updating_subchannels && error != GRPC_ERROR_NONE) {
- /* Captured the unsubscription for the checking subchannel */
- GPR_ASSERT(p->selected == NULL);
- for (size_t i = 0; i < p->num_subchannels; i++) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[i],
- "pf_update_connectivity");
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_DEBUG, "Pick First %p unreffing subchannel %p", (void *)p,
- (void *)p->subchannels[i]);
- }
- }
- gpr_free(p->subchannels);
- p->subchannels = NULL;
- p->num_subchannels = 0;
- p->updating_subchannels = false;
- if (p->num_new_subchannels == 0) return;
- restart = true;
- }
- if (restart) {
- p->selected = NULL;
- p->selected_key = NULL;
- GPR_ASSERT(p->new_subchannels != NULL);
- GPR_ASSERT(p->num_new_subchannels > 0);
- p->num_subchannels = p->num_new_subchannels;
- p->subchannels = p->new_subchannels;
- p->num_new_subchannels = 0;
- p->new_subchannels = NULL;
- if (p->started_picking) {
- /* If we were picking, continue to do so over the new subchannels,
- * starting from the 0th index. */
- p->checking_subchannel = 0;
- p->checking_connectivity = GRPC_CHANNEL_IDLE;
- /* reuses the weak ref from start_picking_locked */
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel],
- p->base.interested_parties, &p->checking_connectivity,
- &p->connectivity_changed);
- }
- if (p->pending_update_args != NULL) {
- const grpc_lb_policy_args *args = p->pending_update_args;
- p->pending_update_args = NULL;
- pf_update_locked(exec_ctx, &p->base, args);
- }
- return;
- }
- GRPC_ERROR_REF(error);
- if (p->shutdown) {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pick_first_connectivity");
- GRPC_ERROR_UNREF(error);
- return;
- } else if (p->selected != NULL) {
- if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
- /* if the selected channel goes bad, we're done */
- p->checking_connectivity = GRPC_CHANNEL_SHUTDOWN;
- }
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- p->checking_connectivity, GRPC_ERROR_REF(error),
- "selected_changed");
- if (p->checking_connectivity != GRPC_CHANNEL_SHUTDOWN) {
- grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, p->selected, p->base.interested_parties,
- &p->checking_connectivity, &p->connectivity_changed);
- } else {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pick_first_connectivity");
- }
- } else {
- loop:
- switch (p->checking_connectivity) {
- case GRPC_CHANNEL_INIT:
- GPR_UNREACHABLE_CODE(return );
- case GRPC_CHANNEL_READY:
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_READY, GRPC_ERROR_NONE,
- "connecting_ready");
- selected_subchannel = p->subchannels[p->checking_subchannel];
- p->selected = GRPC_CONNECTED_SUBCHANNEL_REF(
- grpc_subchannel_get_connected_subchannel(selected_subchannel),
- "picked_first");
-
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_INFO,
- "Pick First %p selected subchannel %p (connected %p)",
- (void *)p, (void *)selected_subchannel, (void *)p->selected);
- }
- p->selected_key = grpc_subchannel_get_key(selected_subchannel);
- /* drop the pick list: we are connected now */
- GRPC_LB_POLICY_WEAK_REF(&p->base, "destroy_subchannels");
- destroy_subchannels_locked(exec_ctx, p);
- /* update any calls that were waiting for a pick */
- while ((pp = p->pending_picks)) {
- p->pending_picks = pp->next;
- *pp->target = GRPC_CONNECTED_SUBCHANNEL_REF(p->selected, "picked");
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_INFO,
- "Servicing pending pick with selected subchannel %p",
- (void *)p->selected);
- }
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
- gpr_free(pp);
- }
- grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, p->selected, p->base.interested_parties,
- &p->checking_connectivity, &p->connectivity_changed);
- break;
- case GRPC_CHANNEL_TRANSIENT_FAILURE:
- p->checking_subchannel =
- (p->checking_subchannel + 1) % p->num_subchannels;
- if (p->checking_subchannel == 0) {
- /* only trigger transient failure when we've tried all alternatives
- */
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_REF(error), "connecting_transient_failure");
- }
- GRPC_ERROR_UNREF(error);
- p->checking_connectivity = grpc_subchannel_check_connectivity(
- p->subchannels[p->checking_subchannel], &error);
- if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel],
- p->base.interested_parties, &p->checking_connectivity,
- &p->connectivity_changed);
- } else {
- goto loop;
- }
- break;
- case GRPC_CHANNEL_CONNECTING:
- case GRPC_CHANNEL_IDLE:
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_CONNECTING,
- GRPC_ERROR_REF(error), "connecting_changed");
- grpc_subchannel_notify_on_state_change(
- exec_ctx, p->subchannels[p->checking_subchannel],
- p->base.interested_parties, &p->checking_connectivity,
- &p->connectivity_changed);
- break;
- case GRPC_CHANNEL_SHUTDOWN:
- p->num_subchannels--;
- GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel],
- p->subchannels[p->num_subchannels]);
- GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[p->num_subchannels],
- "pick_first");
- if (p->num_subchannels == 0) {
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick first exhausted channels", &error, 1),
- "no_more_channels");
- while ((pp = p->pending_picks)) {
- p->pending_picks = pp->next;
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
- gpr_free(pp);
- }
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base,
- "pick_first_connectivity");
- } else {
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_REF(error), "subchannel_failed");
- p->checking_subchannel %= p->num_subchannels;
- GRPC_ERROR_UNREF(error);
- p->checking_connectivity = grpc_subchannel_check_connectivity(
- p->subchannels[p->checking_subchannel], &error);
- goto loop;
- }
- }
- }
-
- GRPC_ERROR_UNREF(error);
-}
-
-static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = {
- pf_destroy,
- pf_shutdown_locked,
- pf_pick_locked,
- pf_cancel_pick_locked,
- pf_cancel_picks_locked,
- pf_ping_one_locked,
- pf_exit_idle_locked,
- pf_check_connectivity_locked,
- pf_notify_on_state_change_locked,
- pf_update_locked};
-
-static void pick_first_factory_ref(grpc_lb_policy_factory *factory) {}
-
-static void pick_first_factory_unref(grpc_lb_policy_factory *factory) {}
-
-static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy_factory *factory,
- grpc_lb_policy_args *args) {
- GPR_ASSERT(args->client_channel_factory != NULL);
- pick_first_lb_policy *p = (pick_first_lb_policy *)gpr_zalloc(sizeof(*p));
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
- gpr_log(GPR_DEBUG, "Pick First %p created.", (void *)p);
- }
- pf_update_locked(exec_ctx, &p->base, args);
- grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable, args->combiner);
- grpc_subchannel_index_ref();
- GRPC_CLOSURE_INIT(&p->connectivity_changed, pf_connectivity_changed_locked, p,
- grpc_combiner_scheduler(args->combiner));
- return &p->base;
-}
-
-static const grpc_lb_policy_factory_vtable pick_first_factory_vtable = {
- pick_first_factory_ref, pick_first_factory_unref, create_pick_first,
- "pick_first"};
-
-static grpc_lb_policy_factory pick_first_lb_policy_factory = {
- &pick_first_factory_vtable};
-
-static grpc_lb_policy_factory *pick_first_lb_factory_create() {
- return &pick_first_lb_policy_factory;
-}
-
-/* Plugin registration */
-
-void grpc_lb_policy_pick_first_init() {
- grpc_register_lb_policy(pick_first_lb_factory_create());
- grpc_register_tracer(&grpc_lb_pick_first_trace);
-}
-
-void grpc_lb_policy_pick_first_shutdown() {}
diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
new file mode 100644
index 0000000000..725b78d478
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
@@ -0,0 +1,577 @@
+/*
+ *
+ * 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 <string.h>
+
+#include <grpc/support/alloc.h>
+
+#include "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
+#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
+#include "src/core/ext/filters/client_channel/subchannel.h"
+#include "src/core/ext/filters/client_channel/subchannel_index.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/transport/connectivity_state.h"
+
+grpc_core::TraceFlag grpc_lb_pick_first_trace(false, "pick_first");
+
+typedef struct {
+ /** base policy: must be first */
+ grpc_lb_policy base;
+ /** all our subchannels */
+ grpc_lb_subchannel_list* subchannel_list;
+ /** latest pending subchannel list */
+ grpc_lb_subchannel_list* latest_pending_subchannel_list;
+ /** selected subchannel in \a subchannel_list */
+ grpc_lb_subchannel_data* selected;
+ /** have we started picking? */
+ bool started_picking;
+ /** are we shut down? */
+ bool shutdown;
+ /** list of picks that are waiting on connectivity */
+ grpc_lb_policy_pick_state* pending_picks;
+ /** our connectivity state tracker */
+ grpc_connectivity_state_tracker state_tracker;
+} pick_first_lb_policy;
+
+static void pf_destroy(grpc_lb_policy* pol) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ GPR_ASSERT(p->subchannel_list == nullptr);
+ GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
+ GPR_ASSERT(p->pending_picks == nullptr);
+ grpc_connectivity_state_destroy(&p->state_tracker);
+ gpr_free(p);
+ grpc_subchannel_index_unref();
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "Pick First %p destroyed.", (void*)p);
+ }
+}
+
+static void pf_shutdown_locked(grpc_lb_policy* pol,
+ grpc_lb_policy* new_policy) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown");
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "Pick First %p Shutting down", p);
+ }
+ p->shutdown = true;
+ grpc_lb_policy_pick_state* pick;
+ while ((pick = p->pending_picks) != nullptr) {
+ p->pending_picks = pick->next;
+ if (new_policy != nullptr) {
+ // Hand off to new LB policy.
+ if (grpc_lb_policy_pick_locked(new_policy, pick)) {
+ // Synchronous return, schedule closure.
+ GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_NONE);
+ }
+ } else {
+ pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_REF(error));
+ }
+ }
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
+ GRPC_ERROR_REF(error), "shutdown");
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "pf_shutdown");
+ p->subchannel_list = nullptr;
+ }
+ if (p->latest_pending_subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->latest_pending_subchannel_list, "pf_shutdown");
+ p->latest_pending_subchannel_list = nullptr;
+ }
+ grpc_lb_policy_try_reresolve(&p->base, &grpc_lb_pick_first_trace,
+ GRPC_ERROR_CANCELLED);
+ GRPC_ERROR_UNREF(error);
+}
+
+static void pf_cancel_pick_locked(grpc_lb_policy* pol,
+ grpc_lb_policy_pick_state* pick,
+ grpc_error* error) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ grpc_lb_policy_pick_state* pp = p->pending_picks;
+ p->pending_picks = nullptr;
+ while (pp != nullptr) {
+ grpc_lb_policy_pick_state* next = pp->next;
+ if (pp == pick) {
+ pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(pick->on_complete,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick Cancelled", &error, 1));
+ } else {
+ pp->next = p->pending_picks;
+ p->pending_picks = pp;
+ }
+ pp = next;
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void pf_cancel_picks_locked(grpc_lb_policy* pol,
+ uint32_t initial_metadata_flags_mask,
+ uint32_t initial_metadata_flags_eq,
+ grpc_error* error) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ grpc_lb_policy_pick_state* pick = p->pending_picks;
+ p->pending_picks = nullptr;
+ while (pick != nullptr) {
+ grpc_lb_policy_pick_state* next = pick->next;
+ if ((pick->initial_metadata_flags & initial_metadata_flags_mask) ==
+ initial_metadata_flags_eq) {
+ GRPC_CLOSURE_SCHED(pick->on_complete,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick Cancelled", &error, 1));
+ } else {
+ pick->next = p->pending_picks;
+ p->pending_picks = pick;
+ }
+ pick = next;
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void start_picking_locked(pick_first_lb_policy* p) {
+ p->started_picking = true;
+ if (p->subchannel_list != nullptr &&
+ p->subchannel_list->num_subchannels > 0) {
+ p->subchannel_list->checking_subchannel = 0;
+ for (size_t i = 0; i < p->subchannel_list->num_subchannels; ++i) {
+ if (p->subchannel_list->subchannels[i].subchannel != nullptr) {
+ grpc_lb_subchannel_list_ref_for_connectivity_watch(
+ p->subchannel_list, "connectivity_watch+start_picking");
+ grpc_lb_subchannel_data_start_connectivity_watch(
+ &p->subchannel_list->subchannels[i]);
+ break;
+ }
+ }
+ }
+}
+
+static void pf_exit_idle_locked(grpc_lb_policy* pol) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ if (!p->started_picking) {
+ start_picking_locked(p);
+ }
+}
+
+static int pf_pick_locked(grpc_lb_policy* pol,
+ grpc_lb_policy_pick_state* pick) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ // If we have a selected subchannel already, return synchronously.
+ if (p->selected != nullptr) {
+ pick->connected_subchannel = p->selected->connected_subchannel;
+ return 1;
+ }
+ // No subchannel selected yet, so handle asynchronously.
+ if (!p->started_picking) {
+ start_picking_locked(p);
+ }
+ pick->next = p->pending_picks;
+ p->pending_picks = pick;
+ return 0;
+}
+
+static void destroy_unselected_subchannels_locked(pick_first_lb_policy* p) {
+ for (size_t i = 0; i < p->subchannel_list->num_subchannels; ++i) {
+ grpc_lb_subchannel_data* sd = &p->subchannel_list->subchannels[i];
+ if (p->selected != sd) {
+ grpc_lb_subchannel_data_unref_subchannel(sd,
+ "selected_different_subchannel");
+ }
+ }
+}
+
+static grpc_connectivity_state pf_check_connectivity_locked(
+ grpc_lb_policy* pol, grpc_error** error) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ return grpc_connectivity_state_get(&p->state_tracker, error);
+}
+
+static void pf_notify_on_state_change_locked(grpc_lb_policy* pol,
+ grpc_connectivity_state* current,
+ grpc_closure* notify) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current,
+ notify);
+}
+
+static void pf_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
+ grpc_closure* on_ack) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
+ if (p->selected) {
+ p->selected->connected_subchannel->Ping(on_initiate, on_ack);
+ } else {
+ GRPC_CLOSURE_SCHED(on_initiate,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Not connected"));
+ GRPC_CLOSURE_SCHED(on_ack,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Not connected"));
+ }
+}
+
+static void pf_connectivity_changed_locked(void* arg, grpc_error* error);
+
+static void pf_update_locked(grpc_lb_policy* policy,
+ const grpc_lb_policy_args* args) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)policy;
+ const grpc_arg* arg =
+ grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
+ if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
+ if (p->subchannel_list == nullptr) {
+ // If we don't have a current subchannel list, go into TRANSIENT FAILURE.
+ grpc_connectivity_state_set(
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
+ "pf_update_missing");
+ } else {
+ // otherwise, keep using the current subchannel list (ignore this update).
+ gpr_log(GPR_ERROR,
+ "No valid LB addresses channel arg for Pick First %p update, "
+ "ignoring.",
+ (void*)p);
+ }
+ return;
+ }
+ const grpc_lb_addresses* addresses =
+ (const grpc_lb_addresses*)arg->value.pointer.p;
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_INFO, "Pick First %p received update with %lu addresses",
+ (void*)p, (unsigned long)addresses->num_addresses);
+ }
+ grpc_lb_subchannel_list* subchannel_list = grpc_lb_subchannel_list_create(
+ &p->base, &grpc_lb_pick_first_trace, addresses, args,
+ pf_connectivity_changed_locked);
+ if (subchannel_list->num_subchannels == 0) {
+ // Empty update or no valid subchannels. Unsubscribe from all current
+ // subchannels and put the channel in TRANSIENT_FAILURE.
+ grpc_connectivity_state_set(
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
+ "pf_update_empty");
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "sl_shutdown_empty_update");
+ }
+ p->subchannel_list = subchannel_list; // Empty list.
+ p->selected = nullptr;
+ return;
+ }
+ if (p->selected == nullptr) {
+ // We don't yet have a selected subchannel, so replace the current
+ // subchannel list immediately.
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "pf_update_before_selected");
+ }
+ p->subchannel_list = subchannel_list;
+ } else {
+ // We do have a selected subchannel.
+ // Check if it's present in the new list. If so, we're done.
+ for (size_t i = 0; i < subchannel_list->num_subchannels; ++i) {
+ grpc_lb_subchannel_data* sd = &subchannel_list->subchannels[i];
+ if (sd->subchannel == p->selected->subchannel) {
+ // The currently selected subchannel is in the update: we are done.
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "Pick First %p found already selected subchannel %p "
+ "at update index %" PRIuPTR " of %" PRIuPTR "; update done",
+ p, p->selected->subchannel, i,
+ subchannel_list->num_subchannels);
+ }
+ if (p->selected->connected_subchannel != nullptr) {
+ sd->connected_subchannel = p->selected->connected_subchannel;
+ }
+ p->selected = sd;
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->subchannel_list, "pf_update_includes_selected");
+ }
+ p->subchannel_list = subchannel_list;
+ destroy_unselected_subchannels_locked(p);
+ grpc_lb_subchannel_list_ref_for_connectivity_watch(
+ subchannel_list, "connectivity_watch+replace_selected");
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
+ // If there was a previously pending update (which may or may
+ // not have contained the currently selected subchannel), drop
+ // it, so that it doesn't override what we've done here.
+ if (p->latest_pending_subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->latest_pending_subchannel_list,
+ "pf_update_includes_selected+outdated");
+ p->latest_pending_subchannel_list = nullptr;
+ }
+ return;
+ }
+ }
+ // Not keeping the previous selected subchannel, so set the latest
+ // pending subchannel list to the new subchannel list. We will wait
+ // for it to report READY before swapping it into the current
+ // subchannel list.
+ if (p->latest_pending_subchannel_list != nullptr) {
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "Pick First %p Shutting down latest pending subchannel list "
+ "%p, about to be replaced by newer latest %p",
+ (void*)p, (void*)p->latest_pending_subchannel_list,
+ (void*)subchannel_list);
+ }
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->latest_pending_subchannel_list, "sl_outdated_dont_smash");
+ }
+ p->latest_pending_subchannel_list = subchannel_list;
+ }
+ // If we've started picking, start trying to connect to the first
+ // subchannel in the new list.
+ if (p->started_picking) {
+ grpc_lb_subchannel_list_ref_for_connectivity_watch(
+ subchannel_list, "connectivity_watch+update");
+ grpc_lb_subchannel_data_start_connectivity_watch(
+ &subchannel_list->subchannels[0]);
+ }
+}
+
+static void pf_connectivity_changed_locked(void* arg, grpc_error* error) {
+ grpc_lb_subchannel_data* sd = (grpc_lb_subchannel_data*)arg;
+ pick_first_lb_policy* p = (pick_first_lb_policy*)sd->subchannel_list->policy;
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "Pick First %p connectivity changed for subchannel %p (%" PRIuPTR
+ " of %" PRIuPTR
+ "), subchannel_list %p: state=%s p->shutdown=%d "
+ "sd->subchannel_list->shutting_down=%d error=%s",
+ (void*)p, (void*)sd->subchannel,
+ sd->subchannel_list->checking_subchannel,
+ sd->subchannel_list->num_subchannels, (void*)sd->subchannel_list,
+ grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe),
+ p->shutdown, sd->subchannel_list->shutting_down,
+ grpc_error_string(error));
+ }
+ // If the policy is shutting down, unref and return.
+ if (p->shutdown) {
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "pf_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "pf_shutdown");
+ return;
+ }
+ // If the subchannel list is shutting down, stop watching.
+ if (sd->subchannel_list->shutting_down || error == GRPC_ERROR_CANCELLED) {
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "pf_sl_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "pf_sl_shutdown");
+ return;
+ }
+ // If we're still here, the notification must be for a subchannel in
+ // either the current or latest pending subchannel lists.
+ GPR_ASSERT(sd->subchannel_list == p->subchannel_list ||
+ sd->subchannel_list == p->latest_pending_subchannel_list);
+ // Update state.
+ sd->curr_connectivity_state = sd->pending_connectivity_state_unsafe;
+ // Handle updates for the currently selected subchannel.
+ if (p->selected == sd) {
+ // If the new state is anything other than READY and there is a
+ // pending update, switch to the pending update.
+ if (sd->curr_connectivity_state != GRPC_CHANNEL_READY &&
+ p->latest_pending_subchannel_list != nullptr) {
+ p->selected = nullptr;
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(
+ sd->subchannel_list, "selected_not_ready+switch_to_update");
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->subchannel_list, "selected_not_ready+switch_to_update");
+ p->subchannel_list = p->latest_pending_subchannel_list;
+ p->latest_pending_subchannel_list = nullptr;
+ grpc_connectivity_state_set(
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(error), "selected_not_ready+switch_to_update");
+ } else {
+ // TODO(juanlishen): we re-resolve when the selected subchannel goes to
+ // TRANSIENT_FAILURE because we used to shut down in this case before
+ // re-resolution is introduced. But we need to investigate whether we
+ // really want to take any action instead of waiting for the selected
+ // subchannel reconnecting.
+ GPR_ASSERT(sd->curr_connectivity_state != GRPC_CHANNEL_SHUTDOWN);
+ if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
+ // If the selected channel goes bad, request a re-resolution.
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_IDLE,
+ GRPC_ERROR_NONE,
+ "selected_changed+reresolve");
+ p->started_picking = false;
+ grpc_lb_policy_try_reresolve(&p->base, &grpc_lb_pick_first_trace,
+ GRPC_ERROR_NONE);
+ // in transient failure. Rely on re-resolution to recover.
+ p->selected = nullptr;
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(
+ sd->subchannel_list, "pf_selected_shutdown");
+ grpc_lb_subchannel_data_unref_subchannel(
+ sd, "pf_selected_shutdown"); // Unrefs connected subchannel
+ } else {
+ grpc_connectivity_state_set(&p->state_tracker,
+ sd->curr_connectivity_state,
+ GRPC_ERROR_REF(error), "selected_changed");
+ // Renew notification.
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
+ }
+ }
+ return;
+ }
+ // If we get here, there are two possible cases:
+ // 1. We do not currently have a selected subchannel, and the update is
+ // for a subchannel in p->subchannel_list that we're trying to
+ // connect to. The goal here is to find a subchannel that we can
+ // select.
+ // 2. We do currently have a selected subchannel, and the update is
+ // for a subchannel in p->latest_pending_subchannel_list. The
+ // goal here is to find a subchannel from the update that we can
+ // select in place of the current one.
+ switch (sd->curr_connectivity_state) {
+ case GRPC_CHANNEL_READY: {
+ // Case 2. Promote p->latest_pending_subchannel_list to
+ // p->subchannel_list.
+ sd->connected_subchannel =
+ grpc_subchannel_get_connected_subchannel(sd->subchannel);
+ if (sd->subchannel_list == p->latest_pending_subchannel_list) {
+ GPR_ASSERT(p->subchannel_list != nullptr);
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "finish_update");
+ p->subchannel_list = p->latest_pending_subchannel_list;
+ p->latest_pending_subchannel_list = nullptr;
+ }
+ // Cases 1 and 2.
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_READY,
+ GRPC_ERROR_NONE, "connecting_ready");
+ p->selected = sd;
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", (void*)p,
+ (void*)sd->subchannel);
+ }
+ // Drop all other subchannels, since we are now connected.
+ destroy_unselected_subchannels_locked(p);
+ // Update any calls that were waiting for a pick.
+ grpc_lb_policy_pick_state* pick;
+ while ((pick = p->pending_picks)) {
+ p->pending_picks = pick->next;
+ pick->connected_subchannel = p->selected->connected_subchannel;
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "Servicing pending pick with selected subchannel %p",
+ (void*)p->selected);
+ }
+ GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_NONE);
+ }
+ // Renew notification.
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
+ break;
+ }
+ case GRPC_CHANNEL_TRANSIENT_FAILURE: {
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ do {
+ sd->subchannel_list->checking_subchannel =
+ (sd->subchannel_list->checking_subchannel + 1) %
+ sd->subchannel_list->num_subchannels;
+ sd = &sd->subchannel_list
+ ->subchannels[sd->subchannel_list->checking_subchannel];
+ } while (sd->subchannel == nullptr);
+ // Case 1: Only set state to TRANSIENT_FAILURE if we've tried
+ // all subchannels.
+ if (sd->subchannel_list->checking_subchannel == 0 &&
+ sd->subchannel_list == p->subchannel_list) {
+ grpc_connectivity_state_set(
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(error), "connecting_transient_failure");
+ }
+ // Reuses the connectivity refs from the previous watch.
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
+ break;
+ }
+ case GRPC_CHANNEL_CONNECTING:
+ case GRPC_CHANNEL_IDLE: {
+ // Only update connectivity state in case 1.
+ if (sd->subchannel_list == p->subchannel_list) {
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_CONNECTING,
+ GRPC_ERROR_REF(error),
+ "connecting_changed");
+ }
+ // Renew notification.
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
+ break;
+ }
+ case GRPC_CHANNEL_SHUTDOWN:
+ GPR_UNREACHABLE_CODE(break);
+ }
+}
+
+static void pf_set_reresolve_closure_locked(
+ grpc_lb_policy* policy, grpc_closure* request_reresolution) {
+ pick_first_lb_policy* p = (pick_first_lb_policy*)policy;
+ GPR_ASSERT(!p->shutdown);
+ GPR_ASSERT(policy->request_reresolution == nullptr);
+ policy->request_reresolution = request_reresolution;
+}
+
+static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = {
+ pf_destroy,
+ pf_shutdown_locked,
+ pf_pick_locked,
+ pf_cancel_pick_locked,
+ pf_cancel_picks_locked,
+ pf_ping_one_locked,
+ pf_exit_idle_locked,
+ pf_check_connectivity_locked,
+ pf_notify_on_state_change_locked,
+ pf_update_locked,
+ pf_set_reresolve_closure_locked};
+
+static void pick_first_factory_ref(grpc_lb_policy_factory* factory) {}
+
+static void pick_first_factory_unref(grpc_lb_policy_factory* factory) {}
+
+static grpc_lb_policy* create_pick_first(grpc_lb_policy_factory* factory,
+ grpc_lb_policy_args* args) {
+ GPR_ASSERT(args->client_channel_factory != nullptr);
+ pick_first_lb_policy* p = (pick_first_lb_policy*)gpr_zalloc(sizeof(*p));
+ if (grpc_lb_pick_first_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "Pick First %p created.", (void*)p);
+ }
+ pf_update_locked(&p->base, args);
+ grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable, args->combiner);
+ grpc_subchannel_index_ref();
+ return &p->base;
+}
+
+static const grpc_lb_policy_factory_vtable pick_first_factory_vtable = {
+ pick_first_factory_ref, pick_first_factory_unref, create_pick_first,
+ "pick_first"};
+
+static grpc_lb_policy_factory pick_first_lb_policy_factory = {
+ &pick_first_factory_vtable};
+
+static grpc_lb_policy_factory* pick_first_lb_factory_create() {
+ return &pick_first_lb_policy_factory;
+}
+
+/* Plugin registration */
+
+void grpc_lb_policy_pick_first_init() {
+ grpc_register_lb_policy(pick_first_lb_factory_create());
+}
+
+void grpc_lb_policy_pick_first_shutdown() {}
diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
deleted file mode 100644
index a3a62e9f3c..0000000000
--- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
+++ /dev/null
@@ -1,924 +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.
- *
- */
-
-/** Round Robin Policy.
- *
- * Before every pick, the \a get_next_ready_subchannel_index_locked function
- * returns the p->subchannel_list->subchannels index for next subchannel,
- * respecting the relative
- * order of the addresses provided upon creation or updates. Note however that
- * updates will start picking from the beginning of the updated list. */
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-
-#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
-#include "src/core/ext/filters/client_channel/subchannel.h"
-#include "src/core/ext/filters/client_channel/subchannel_index.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/debug/trace.h"
-#include "src/core/lib/iomgr/combiner.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/transport/connectivity_state.h"
-#include "src/core/lib/transport/static_metadata.h"
-
-grpc_tracer_flag grpc_lb_round_robin_trace =
- GRPC_TRACER_INITIALIZER(false, "round_robin");
-
-/** List of entities waiting for a pick.
- *
- * Once a pick is available, \a target is updated and \a on_complete called. */
-typedef struct pending_pick {
- struct pending_pick *next;
-
- /* output argument where to store the pick()ed user_data. It'll be NULL if no
- * such data is present or there's an error (the definite test for errors is
- * \a target being NULL). */
- void **user_data;
-
- /* bitmask passed to pick() and used for selective cancelling. See
- * grpc_lb_policy_cancel_picks() */
- uint32_t initial_metadata_flags;
-
- /* output argument where to store the pick()ed connected subchannel, or NULL
- * upon error. */
- grpc_connected_subchannel **target;
-
- /* to be invoked once the pick() has completed (regardless of success) */
- grpc_closure *on_complete;
-} pending_pick;
-
-typedef struct rr_subchannel_list rr_subchannel_list;
-typedef struct round_robin_lb_policy {
- /** base policy: must be first */
- grpc_lb_policy base;
-
- rr_subchannel_list *subchannel_list;
-
- /** have we started picking? */
- bool started_picking;
- /** are we shutting down? */
- bool shutdown;
- /** List of picks that are waiting on connectivity */
- pending_pick *pending_picks;
-
- /** our connectivity state tracker */
- grpc_connectivity_state_tracker state_tracker;
-
- /** Index into subchannels for last pick. */
- size_t last_ready_subchannel_index;
-
- /** Latest version of the subchannel list.
- * Subchannel connectivity callbacks will only promote updated subchannel
- * lists if they equal \a latest_pending_subchannel_list. In other words,
- * racing callbacks that reference outdated subchannel lists won't perform any
- * update. */
- rr_subchannel_list *latest_pending_subchannel_list;
-} round_robin_lb_policy;
-
-typedef struct {
- /** backpointer to owning subchannel list */
- rr_subchannel_list *subchannel_list;
- /** subchannel itself */
- grpc_subchannel *subchannel;
- /** notification that connectivity has changed on subchannel */
- grpc_closure connectivity_changed_closure;
- /** last observed connectivity. Not updated by
- * \a grpc_subchannel_notify_on_state_change. Used to determine the previous
- * state while processing the new state in \a rr_connectivity_changed */
- grpc_connectivity_state prev_connectivity_state;
- /** current connectivity state. Updated by \a
- * grpc_subchannel_notify_on_state_change */
- grpc_connectivity_state curr_connectivity_state;
- /** connectivity state to be updated by the watcher, not guarded by
- * the combiner. Will be moved to curr_connectivity_state inside of
- * the combiner by rr_connectivity_changed_locked(). */
- grpc_connectivity_state pending_connectivity_state_unsafe;
- /** the subchannel's target user data */
- void *user_data;
- /** vtable to operate over \a user_data */
- const grpc_lb_user_data_vtable *user_data_vtable;
-} subchannel_data;
-
-struct rr_subchannel_list {
- /** backpointer to owning policy */
- round_robin_lb_policy *policy;
-
- /** all our subchannels */
- size_t num_subchannels;
- subchannel_data *subchannels;
-
- /** how many subchannels are in state READY */
- size_t num_ready;
- /** how many subchannels are in state TRANSIENT_FAILURE */
- size_t num_transient_failures;
- /** how many subchannels are in state SHUTDOWN */
- size_t num_shutdown;
- /** how many subchannels are in state IDLE */
- size_t num_idle;
-
- /** There will be one ref for each entry in subchannels for which there is a
- * pending connectivity state watcher callback. */
- gpr_refcount refcount;
-
- /** Is this list shutting down? This may be true due to the shutdown of the
- * policy itself or because a newer update has arrived while this one hadn't
- * finished processing. */
- bool shutting_down;
-};
-
-static rr_subchannel_list *rr_subchannel_list_create(round_robin_lb_policy *p,
- size_t num_subchannels) {
- rr_subchannel_list *subchannel_list =
- (rr_subchannel_list *)gpr_zalloc(sizeof(*subchannel_list));
- subchannel_list->policy = p;
- subchannel_list->subchannels =
- (subchannel_data *)gpr_zalloc(sizeof(subchannel_data) * num_subchannels);
- subchannel_list->num_subchannels = num_subchannels;
- gpr_ref_init(&subchannel_list->refcount, 1);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_INFO, "[RR %p] Created subchannel list %p for %lu subchannels",
- (void *)p, (void *)subchannel_list, (unsigned long)num_subchannels);
- }
- return subchannel_list;
-}
-
-static void rr_subchannel_list_destroy(grpc_exec_ctx *exec_ctx,
- rr_subchannel_list *subchannel_list) {
- GPR_ASSERT(subchannel_list->shutting_down);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_INFO, "[RR %p] Destroying subchannel_list %p",
- (void *)subchannel_list->policy, (void *)subchannel_list);
- }
- for (size_t i = 0; i < subchannel_list->num_subchannels; i++) {
- subchannel_data *sd = &subchannel_list->subchannels[i];
- if (sd->subchannel != NULL) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, sd->subchannel,
- "rr_subchannel_list_destroy");
- }
- sd->subchannel = NULL;
- if (sd->user_data != NULL) {
- GPR_ASSERT(sd->user_data_vtable != NULL);
- sd->user_data_vtable->destroy(exec_ctx, sd->user_data);
- sd->user_data = NULL;
- }
- }
- gpr_free(subchannel_list->subchannels);
- gpr_free(subchannel_list);
-}
-
-static void rr_subchannel_list_ref(rr_subchannel_list *subchannel_list,
- const char *reason) {
- gpr_ref_non_zero(&subchannel_list->refcount);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
- gpr_log(GPR_INFO, "[RR %p] subchannel_list %p REF %lu->%lu (%s)",
- (void *)subchannel_list->policy, (void *)subchannel_list,
- (unsigned long)(count - 1), (unsigned long)count, reason);
- }
-}
-
-static void rr_subchannel_list_unref(grpc_exec_ctx *exec_ctx,
- rr_subchannel_list *subchannel_list,
- const char *reason) {
- const bool done = gpr_unref(&subchannel_list->refcount);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
- gpr_log(GPR_INFO, "[RR %p] subchannel_list %p UNREF %lu->%lu (%s)",
- (void *)subchannel_list->policy, (void *)subchannel_list,
- (unsigned long)(count + 1), (unsigned long)count, reason);
- }
- if (done) {
- rr_subchannel_list_destroy(exec_ctx, subchannel_list);
- }
-}
-
-/** Mark \a subchannel_list as discarded. Unsubscribes all its subchannels. The
- * watcher's callback will ultimately unref \a subchannel_list. */
-static void rr_subchannel_list_shutdown_and_unref(
- grpc_exec_ctx *exec_ctx, rr_subchannel_list *subchannel_list,
- const char *reason) {
- GPR_ASSERT(!subchannel_list->shutting_down);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG, "[RR %p] Shutting down subchannel_list %p (%s)",
- (void *)subchannel_list->policy, (void *)subchannel_list, reason);
- }
- GPR_ASSERT(!subchannel_list->shutting_down);
- subchannel_list->shutting_down = true;
- for (size_t i = 0; i < subchannel_list->num_subchannels; i++) {
- subchannel_data *sd = &subchannel_list->subchannels[i];
- if (sd->subchannel != NULL) { // if subchannel isn't shutdown, unsubscribe.
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(
- GPR_DEBUG,
- "[RR %p] Unsubscribing from subchannel %p as part of shutting down "
- "subchannel_list %p",
- (void *)subchannel_list->policy, (void *)sd->subchannel,
- (void *)subchannel_list);
- }
- grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL,
- NULL,
- &sd->connectivity_changed_closure);
- }
- }
- rr_subchannel_list_unref(exec_ctx, subchannel_list, reason);
-}
-
-/** Returns the index into p->subchannel_list->subchannels of the next
- * subchannel in READY state, or p->subchannel_list->num_subchannels if no
- * subchannel is READY.
- *
- * Note that this function does *not* update p->last_ready_subchannel_index.
- * The caller must do that if it returns a pick. */
-static size_t get_next_ready_subchannel_index_locked(
- const round_robin_lb_policy *p) {
- GPR_ASSERT(p->subchannel_list != NULL);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_INFO,
- "[RR %p] getting next ready subchannel (out of %lu), "
- "last_ready_subchannel_index=%lu",
- (void *)p, (unsigned long)p->subchannel_list->num_subchannels,
- (unsigned long)p->last_ready_subchannel_index);
- }
- for (size_t i = 0; i < p->subchannel_list->num_subchannels; ++i) {
- const size_t index = (i + p->last_ready_subchannel_index + 1) %
- p->subchannel_list->num_subchannels;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(
- GPR_DEBUG,
- "[RR %p] checking subchannel %p, subchannel_list %p, index %lu: "
- "state=%s",
- (void *)p, (void *)p->subchannel_list->subchannels[index].subchannel,
- (void *)p->subchannel_list, (unsigned long)index,
- grpc_connectivity_state_name(
- p->subchannel_list->subchannels[index].curr_connectivity_state));
- }
- if (p->subchannel_list->subchannels[index].curr_connectivity_state ==
- GRPC_CHANNEL_READY) {
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG,
- "[RR %p] found next ready subchannel (%p) at index %lu of "
- "subchannel_list %p",
- (void *)p,
- (void *)p->subchannel_list->subchannels[index].subchannel,
- (unsigned long)index, (void *)p->subchannel_list);
- }
- return index;
- }
- }
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG, "[RR %p] no subchannels in ready state", (void *)p);
- }
- return p->subchannel_list->num_subchannels;
-}
-
-// Sets p->last_ready_subchannel_index to last_ready_index.
-static void update_last_ready_subchannel_index_locked(round_robin_lb_policy *p,
- size_t last_ready_index) {
- GPR_ASSERT(last_ready_index < p->subchannel_list->num_subchannels);
- p->last_ready_subchannel_index = last_ready_index;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(
- GPR_DEBUG,
- "[RR %p] setting last_ready_subchannel_index=%lu (SC %p, CSC %p)",
- (void *)p, (unsigned long)last_ready_index,
- (void *)p->subchannel_list->subchannels[last_ready_index].subchannel,
- (void *)grpc_subchannel_get_connected_subchannel(
- p->subchannel_list->subchannels[last_ready_index].subchannel));
- }
-}
-
-static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy at %p",
- (void *)pol, (void *)pol);
- }
- grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
- grpc_subchannel_index_unref();
- gpr_free(p);
-}
-
-static void rr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG, "[RR %p] Shutting down Round Robin policy at %p",
- (void *)pol, (void *)pol);
- }
- p->shutdown = true;
- pending_pick *pp;
- while ((pp = p->pending_picks)) {
- p->pending_picks = pp->next;
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(
- exec_ctx, pp->on_complete,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
- gpr_free(pp);
- }
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "rr_shutdown");
- const bool latest_is_current =
- p->subchannel_list == p->latest_pending_subchannel_list;
- rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
- "sl_shutdown_rr_shutdown");
- p->subchannel_list = NULL;
- if (!latest_is_current && p->latest_pending_subchannel_list != NULL &&
- !p->latest_pending_subchannel_list->shutting_down) {
- rr_subchannel_list_shutdown_and_unref(exec_ctx,
- p->latest_pending_subchannel_list,
- "sl_shutdown_pending_rr_shutdown");
- p->latest_pending_subchannel_list = NULL;
- }
-}
-
-static void rr_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_connected_subchannel **target,
- grpc_error *error) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- pending_pick *pp = p->pending_picks;
- p->pending_picks = NULL;
- while (pp != NULL) {
- pending_pick *next = pp->next;
- if (pp->target == target) {
- *target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick cancelled", &error, 1));
- gpr_free(pp);
- } else {
- pp->next = p->pending_picks;
- p->pending_picks = pp;
- }
- pp = next;
- }
- GRPC_ERROR_UNREF(error);
-}
-
-static void rr_cancel_picks_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- uint32_t initial_metadata_flags_mask,
- uint32_t initial_metadata_flags_eq,
- grpc_error *error) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- pending_pick *pp = p->pending_picks;
- p->pending_picks = NULL;
- while (pp != NULL) {
- pending_pick *next = pp->next;
- if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
- initial_metadata_flags_eq) {
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick cancelled", &error, 1));
- gpr_free(pp);
- } else {
- pp->next = p->pending_picks;
- p->pending_picks = pp;
- }
- pp = next;
- }
- GRPC_ERROR_UNREF(error);
-}
-
-static void start_picking_locked(grpc_exec_ctx *exec_ctx,
- round_robin_lb_policy *p) {
- p->started_picking = true;
- for (size_t i = 0; i < p->subchannel_list->num_subchannels; i++) {
- subchannel_data *sd = &p->subchannel_list->subchannels[i];
- GRPC_LB_POLICY_WEAK_REF(&p->base, "start_picking_locked");
- rr_subchannel_list_ref(sd->subchannel_list, "started_picking");
- grpc_subchannel_notify_on_state_change(
- exec_ctx, sd->subchannel, p->base.interested_parties,
- &sd->pending_connectivity_state_unsafe,
- &sd->connectivity_changed_closure);
- }
-}
-
-static void rr_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
- }
-}
-
-static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
- grpc_call_context_element *context, void **user_data,
- grpc_closure *on_complete) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- GPR_ASSERT(!p->shutdown);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_INFO, "[RR %p] Trying to pick", (void *)pol);
- }
- if (p->subchannel_list != NULL) {
- const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
- if (next_ready_index < p->subchannel_list->num_subchannels) {
- /* readily available, report right away */
- subchannel_data *sd = &p->subchannel_list->subchannels[next_ready_index];
- *target = GRPC_CONNECTED_SUBCHANNEL_REF(
- grpc_subchannel_get_connected_subchannel(sd->subchannel),
- "rr_picked");
- if (user_data != NULL) {
- *user_data = sd->user_data;
- }
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(
- GPR_DEBUG,
- "[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, "
- "index %lu)",
- (void *)p, (void *)sd->subchannel, (void *)*target,
- (void *)sd->subchannel_list, (unsigned long)next_ready_index);
- }
- /* only advance the last picked pointer if the selection was used */
- update_last_ready_subchannel_index_locked(p, next_ready_index);
- return 1;
- }
- }
- /* no pick currently available. Save for later in list of pending picks */
- if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
- }
- pending_pick *pp = (pending_pick *)gpr_malloc(sizeof(*pp));
- pp->next = p->pending_picks;
- pp->target = target;
- pp->on_complete = on_complete;
- pp->initial_metadata_flags = pick_args->initial_metadata_flags;
- pp->user_data = user_data;
- p->pending_picks = pp;
- return 0;
-}
-
-static void update_state_counters_locked(subchannel_data *sd) {
- rr_subchannel_list *subchannel_list = sd->subchannel_list;
- if (sd->prev_connectivity_state == GRPC_CHANNEL_READY) {
- GPR_ASSERT(subchannel_list->num_ready > 0);
- --subchannel_list->num_ready;
- } else if (sd->prev_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
- GPR_ASSERT(subchannel_list->num_transient_failures > 0);
- --subchannel_list->num_transient_failures;
- } else if (sd->prev_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- GPR_ASSERT(subchannel_list->num_shutdown > 0);
- --subchannel_list->num_shutdown;
- } else if (sd->prev_connectivity_state == GRPC_CHANNEL_IDLE) {
- GPR_ASSERT(subchannel_list->num_idle > 0);
- --subchannel_list->num_idle;
- }
- if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) {
- ++subchannel_list->num_ready;
- } else if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
- ++subchannel_list->num_transient_failures;
- } else if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- ++subchannel_list->num_shutdown;
- } else if (sd->curr_connectivity_state == GRPC_CHANNEL_IDLE) {
- ++subchannel_list->num_idle;
- }
-}
-
-/** Sets the policy's connectivity status based on that of the passed-in \a sd
- * (the subchannel_data associted with the updated subchannel) and the
- * subchannel list \a sd belongs to (sd->subchannel_list). \a error will only be
- * used upon policy transition to TRANSIENT_FAILURE or SHUTDOWN. Returns the
- * connectivity status set. */
-static grpc_connectivity_state update_lb_connectivity_status_locked(
- grpc_exec_ctx *exec_ctx, subchannel_data *sd, grpc_error *error) {
- /* In priority order. The first rule to match terminates the search (ie, if we
- * are on rule n, all previous rules were unfulfilled).
- *
- * 1) RULE: ANY subchannel is READY => policy is READY.
- * CHECK: At least one subchannel is ready iff p->ready_list is NOT empty.
- *
- * 2) RULE: ANY subchannel is CONNECTING => policy is CONNECTING.
- * CHECK: sd->curr_connectivity_state == CONNECTING.
- *
- * 3) RULE: ALL subchannels are SHUTDOWN => policy is SHUTDOWN.
- * CHECK: p->subchannel_list->num_shutdown ==
- * p->subchannel_list->num_subchannels.
- *
- * 4) RULE: ALL subchannels are TRANSIENT_FAILURE => policy is
- * TRANSIENT_FAILURE.
- * CHECK: p->num_transient_failures == p->subchannel_list->num_subchannels.
- *
- * 5) RULE: ALL subchannels are IDLE => policy is IDLE.
- * CHECK: p->num_idle == p->subchannel_list->num_subchannels.
- */
- grpc_connectivity_state new_state = sd->curr_connectivity_state;
- rr_subchannel_list *subchannel_list = sd->subchannel_list;
- round_robin_lb_policy *p = subchannel_list->policy;
- if (subchannel_list->num_ready > 0) { /* 1) READY */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_READY,
- GRPC_ERROR_NONE, "rr_ready");
- new_state = GRPC_CHANNEL_READY;
- } else if (sd->curr_connectivity_state ==
- GRPC_CHANNEL_CONNECTING) { /* 2) CONNECTING */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE,
- "rr_connecting");
- new_state = GRPC_CHANNEL_CONNECTING;
- } else if (p->subchannel_list->num_shutdown ==
- p->subchannel_list->num_subchannels) { /* 3) SHUTDOWN */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
- "rr_shutdown");
- p->shutdown = true;
- new_state = GRPC_CHANNEL_SHUTDOWN;
- } else if (subchannel_list->num_transient_failures ==
- p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_REF(error), "rr_transient_failure");
- new_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
- } else if (subchannel_list->num_idle ==
- p->subchannel_list->num_subchannels) { /* 5) IDLE */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_IDLE,
- GRPC_ERROR_NONE, "rr_idle");
- new_state = GRPC_CHANNEL_IDLE;
- }
- GRPC_ERROR_UNREF(error);
- return new_state;
-}
-
-static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- subchannel_data *sd = (subchannel_data *)arg;
- round_robin_lb_policy *p = sd->subchannel_list->policy;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(
- GPR_DEBUG,
- "[RR %p] connectivity changed for subchannel %p, subchannel_list %p: "
- "prev_state=%s new_state=%s p->shutdown=%d "
- "sd->subchannel_list->shutting_down=%d error=%s",
- (void *)p, (void *)sd->subchannel, (void *)sd->subchannel_list,
- grpc_connectivity_state_name(sd->prev_connectivity_state),
- grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe),
- p->shutdown, sd->subchannel_list->shutting_down,
- grpc_error_string(error));
- }
- // If the policy is shutting down, unref and return.
- if (p->shutdown) {
- rr_subchannel_list_unref(exec_ctx, sd->subchannel_list,
- "pol_shutdown+started_picking");
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pol_shutdown");
- return;
- }
- if (sd->subchannel_list->shutting_down && error == GRPC_ERROR_CANCELLED) {
- // the subchannel list associated with sd has been discarded. This callback
- // corresponds to the unsubscription. The unrefs correspond to the picking
- // ref (start_picking_locked or update_started_picking).
- rr_subchannel_list_unref(exec_ctx, sd->subchannel_list,
- "sl_shutdown+started_picking");
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "sl_shutdown+picking");
- return;
- }
- // Dispose of outdated subchannel lists.
- if (sd->subchannel_list != p->subchannel_list &&
- sd->subchannel_list != p->latest_pending_subchannel_list) {
- const char *reason = NULL;
- if (sd->subchannel_list->shutting_down) {
- reason = "sl_outdated_straggler";
- rr_subchannel_list_unref(exec_ctx, sd->subchannel_list, reason);
- } else {
- reason = "sl_outdated";
- rr_subchannel_list_shutdown_and_unref(exec_ctx, sd->subchannel_list,
- reason);
- }
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, reason);
- return;
- }
- // Now that we're inside the combiner, copy the pending connectivity
- // state (which was set by the connectivity state watcher) to
- // curr_connectivity_state, which is what we use inside of the combiner.
- sd->curr_connectivity_state = sd->pending_connectivity_state_unsafe;
- // Update state counters and determine new overall state.
- update_state_counters_locked(sd);
- sd->prev_connectivity_state = sd->curr_connectivity_state;
- const grpc_connectivity_state new_policy_connectivity_state =
- update_lb_connectivity_status_locked(exec_ctx, sd, GRPC_ERROR_REF(error));
- // If the sd's new state is SHUTDOWN, unref the subchannel, and if the new
- // policy's state is SHUTDOWN, clean up.
- if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, sd->subchannel, "rr_subchannel_shutdown");
- sd->subchannel = NULL;
- if (sd->user_data != NULL) {
- GPR_ASSERT(sd->user_data_vtable != NULL);
- sd->user_data_vtable->destroy(exec_ctx, sd->user_data);
- sd->user_data = NULL;
- }
- if (new_policy_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- // the policy is shutting down. Flush all the pending picks...
- pending_pick *pp;
- while ((pp = p->pending_picks)) {
- p->pending_picks = pp->next;
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
- gpr_free(pp);
- }
- }
- rr_subchannel_list_unref(exec_ctx, sd->subchannel_list,
- "sd_shutdown+started_picking");
- // unref the "rr_connectivity_update" weak ref from start_picking.
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base,
- "rr_connectivity_sd_shutdown");
- } else { // sd not in SHUTDOWN
- if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) {
- if (sd->subchannel_list != p->subchannel_list) {
- // promote sd->subchannel_list to p->subchannel_list.
- // sd->subchannel_list must be equal to
- // p->latest_pending_subchannel_list because we have already filtered
- // for sds belonging to outdated subchannel lists.
- GPR_ASSERT(sd->subchannel_list == p->latest_pending_subchannel_list);
- GPR_ASSERT(!sd->subchannel_list->shutting_down);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- const unsigned long num_subchannels =
- p->subchannel_list != NULL
- ? (unsigned long)p->subchannel_list->num_subchannels
- : 0;
- gpr_log(GPR_DEBUG,
- "[RR %p] phasing out subchannel list %p (size %lu) in favor "
- "of %p (size %lu)",
- (void *)p, (void *)p->subchannel_list, num_subchannels,
- (void *)sd->subchannel_list, num_subchannels);
- }
- if (p->subchannel_list != NULL) {
- // dispose of the current subchannel_list
- rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
- "sl_phase_out_shutdown");
- }
- p->subchannel_list = p->latest_pending_subchannel_list;
- p->latest_pending_subchannel_list = NULL;
- }
- /* at this point we know there's at least one suitable subchannel. Go
- * ahead and pick one and notify the pending suitors in
- * p->pending_picks. This preemtively replicates rr_pick()'s actions. */
- const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
- GPR_ASSERT(next_ready_index < p->subchannel_list->num_subchannels);
- subchannel_data *selected =
- &p->subchannel_list->subchannels[next_ready_index];
- if (p->pending_picks != NULL) {
- // if the selected subchannel is going to be used for the pending
- // picks, update the last picked pointer
- update_last_ready_subchannel_index_locked(p, next_ready_index);
- }
- pending_pick *pp;
- while ((pp = p->pending_picks)) {
- p->pending_picks = pp->next;
- *pp->target = GRPC_CONNECTED_SUBCHANNEL_REF(
- grpc_subchannel_get_connected_subchannel(selected->subchannel),
- "rr_picked");
- if (pp->user_data != NULL) {
- *pp->user_data = selected->user_data;
- }
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG,
- "[RR %p] Fulfilling pending pick. Target <-- subchannel %p "
- "(subchannel_list %p, index %lu)",
- (void *)p, (void *)selected->subchannel,
- (void *)p->subchannel_list, (unsigned long)next_ready_index);
- }
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
- gpr_free(pp);
- }
- }
- /* renew notification: reuses the "rr_connectivity_update" weak ref on the
- * policy as well as the sd->subchannel_list ref. */
- grpc_subchannel_notify_on_state_change(
- exec_ctx, sd->subchannel, p->base.interested_parties,
- &sd->pending_connectivity_state_unsafe,
- &sd->connectivity_changed_closure);
- }
-}
-
-static grpc_connectivity_state rr_check_connectivity_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_error **error) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- return grpc_connectivity_state_get(&p->state_tracker, error);
-}
-
-static void rr_notify_on_state_change_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *pol,
- grpc_connectivity_state *current,
- grpc_closure *notify) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- grpc_connectivity_state_notify_on_state_change(exec_ctx, &p->state_tracker,
- current, notify);
-}
-
-static void rr_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
- grpc_closure *closure) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
- const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
- if (next_ready_index < p->subchannel_list->num_subchannels) {
- subchannel_data *selected =
- &p->subchannel_list->subchannels[next_ready_index];
- grpc_connected_subchannel *target = GRPC_CONNECTED_SUBCHANNEL_REF(
- grpc_subchannel_get_connected_subchannel(selected->subchannel),
- "rr_picked");
- grpc_connected_subchannel_ping(exec_ctx, target, closure);
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "rr_picked");
- } else {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Round Robin not connected"));
- }
-}
-
-static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- const grpc_lb_policy_args *args) {
- round_robin_lb_policy *p = (round_robin_lb_policy *)policy;
- const grpc_arg *arg =
- grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
- if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
- if (p->subchannel_list == NULL) {
- // If we don't have a current subchannel list, go into TRANSIENT FAILURE.
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
- "rr_update_missing");
- } else {
- // otherwise, keep using the current subchannel list (ignore this update).
- gpr_log(GPR_ERROR,
- "[RR %p] No valid LB addresses channel arg for update, ignoring.",
- (void *)p);
- }
- return;
- }
- grpc_lb_addresses *addresses = (grpc_lb_addresses *)arg->value.pointer.p;
- rr_subchannel_list *subchannel_list =
- rr_subchannel_list_create(p, addresses->num_addresses);
- if (addresses->num_addresses == 0) {
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
- "rr_update_empty");
- if (p->subchannel_list != NULL) {
- rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
- "sl_shutdown_empty_update");
- }
- p->subchannel_list = subchannel_list; // empty list
- return;
- }
- size_t subchannel_index = 0;
- if (p->latest_pending_subchannel_list != NULL && p->started_picking) {
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG,
- "[RR %p] Shutting down latest pending subchannel list %p, about "
- "to be replaced by newer latest %p",
- (void *)p, (void *)p->latest_pending_subchannel_list,
- (void *)subchannel_list);
- }
- rr_subchannel_list_shutdown_and_unref(
- exec_ctx, p->latest_pending_subchannel_list, "sl_outdated_dont_smash");
- }
- p->latest_pending_subchannel_list = subchannel_list;
- grpc_subchannel_args sc_args;
- /* We need to remove the LB addresses in order to be able to compare the
- * subchannel keys of subchannels from a different batch of addresses. */
- static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
- GRPC_ARG_LB_ADDRESSES};
- /* Create subchannels for addresses in the update. */
- for (size_t i = 0; i < addresses->num_addresses; i++) {
- // If there were any balancer, we would have chosen grpclb policy instead.
- GPR_ASSERT(!addresses->addresses[i].is_balancer);
- memset(&sc_args, 0, sizeof(grpc_subchannel_args));
- grpc_arg addr_arg =
- grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add_and_remove(
- args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
- 1);
- gpr_free(addr_arg.value.string);
- sc_args.args = new_args;
- grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
- exec_ctx, args->client_channel_factory, &sc_args);
- grpc_channel_args_destroy(exec_ctx, new_args);
- grpc_error *error;
- // Get the connectivity state of the subchannel. Already existing ones may
- // be in a state other than INIT.
- const grpc_connectivity_state subchannel_connectivity_state =
- grpc_subchannel_check_connectivity(subchannel, &error);
- if (error != GRPC_ERROR_NONE) {
- // The subchannel is in error (e.g. shutting down). Ignore it.
- GRPC_SUBCHANNEL_UNREF(exec_ctx, subchannel, "new_sc_connectivity_error");
- GRPC_ERROR_UNREF(error);
- continue;
- }
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- char *address_uri =
- grpc_sockaddr_to_uri(&addresses->addresses[i].address);
- gpr_log(
- GPR_DEBUG,
- "[RR %p] index %lu: Created subchannel %p for address uri %s into "
- "subchannel_list %p. Connectivity state %s",
- (void *)p, (unsigned long)subchannel_index, (void *)subchannel,
- address_uri, (void *)subchannel_list,
- grpc_connectivity_state_name(subchannel_connectivity_state));
- gpr_free(address_uri);
- }
- subchannel_data *sd = &subchannel_list->subchannels[subchannel_index++];
- sd->subchannel_list = subchannel_list;
- sd->subchannel = subchannel;
- GRPC_CLOSURE_INIT(&sd->connectivity_changed_closure,
- rr_connectivity_changed_locked, sd,
- grpc_combiner_scheduler(args->combiner));
- /* use some sentinel value outside of the range of
- * grpc_connectivity_state to signal an undefined previous state. We
- * won't be referring to this value again and it'll be overwritten after
- * the first call to rr_connectivity_changed_locked */
- sd->prev_connectivity_state = GRPC_CHANNEL_INIT;
- sd->curr_connectivity_state = subchannel_connectivity_state;
- sd->user_data_vtable = addresses->user_data_vtable;
- if (sd->user_data_vtable != NULL) {
- sd->user_data =
- sd->user_data_vtable->copy(addresses->addresses[i].user_data);
- }
- if (p->started_picking) {
- rr_subchannel_list_ref(sd->subchannel_list, "update_started_picking");
- GRPC_LB_POLICY_WEAK_REF(&p->base, "rr_connectivity_update");
- /* 2. Watch every new subchannel. A subchannel list becomes active the
- * moment one of its subchannels is READY. At that moment, we swap
- * p->subchannel_list for sd->subchannel_list, provided the subchannel
- * list is still valid (ie, isn't shutting down) */
- grpc_subchannel_notify_on_state_change(
- exec_ctx, sd->subchannel, p->base.interested_parties,
- &sd->pending_connectivity_state_unsafe,
- &sd->connectivity_changed_closure);
- }
- }
- if (!p->started_picking) {
- // The policy isn't picking yet. Save the update for later, disposing of
- // previous version if any.
- if (p->subchannel_list != NULL) {
- rr_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
- "rr_update_before_started_picking");
- }
- p->subchannel_list = subchannel_list;
- p->latest_pending_subchannel_list = NULL;
- }
-}
-
-static const grpc_lb_policy_vtable round_robin_lb_policy_vtable = {
- rr_destroy,
- rr_shutdown_locked,
- rr_pick_locked,
- rr_cancel_pick_locked,
- rr_cancel_picks_locked,
- rr_ping_one_locked,
- rr_exit_idle_locked,
- rr_check_connectivity_locked,
- rr_notify_on_state_change_locked,
- rr_update_locked};
-
-static void round_robin_factory_ref(grpc_lb_policy_factory *factory) {}
-
-static void round_robin_factory_unref(grpc_lb_policy_factory *factory) {}
-
-static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy_factory *factory,
- grpc_lb_policy_args *args) {
- GPR_ASSERT(args->client_channel_factory != NULL);
- round_robin_lb_policy *p = (round_robin_lb_policy *)gpr_zalloc(sizeof(*p));
- grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable, args->combiner);
- grpc_subchannel_index_ref();
- grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
- "round_robin");
- rr_update_locked(exec_ctx, &p->base, args);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_DEBUG, "[RR %p] Created with %lu subchannels", (void *)p,
- (unsigned long)p->subchannel_list->num_subchannels);
- }
- return &p->base;
-}
-
-static const grpc_lb_policy_factory_vtable round_robin_factory_vtable = {
- round_robin_factory_ref, round_robin_factory_unref, round_robin_create,
- "round_robin"};
-
-static grpc_lb_policy_factory round_robin_lb_policy_factory = {
- &round_robin_factory_vtable};
-
-static grpc_lb_policy_factory *round_robin_lb_factory_create() {
- return &round_robin_lb_policy_factory;
-}
-
-/* Plugin registration */
-
-void grpc_lb_policy_round_robin_init() {
- grpc_register_lb_policy(round_robin_lb_factory_create());
- grpc_register_tracer(&grpc_lb_round_robin_trace);
-}
-
-void grpc_lb_policy_round_robin_shutdown() {}
diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
new file mode 100644
index 0000000000..24c381a46d
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
@@ -0,0 +1,656 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+/** Round Robin Policy.
+ *
+ * Before every pick, the \a get_next_ready_subchannel_index_locked function
+ * returns the p->subchannel_list->subchannels index for next subchannel,
+ * respecting the relative order of the addresses provided upon creation or
+ * updates. Note however that updates will start picking from the beginning of
+ * the updated list. */
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+
+#include "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
+#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
+#include "src/core/ext/filters/client_channel/subchannel.h"
+#include "src/core/ext/filters/client_channel/subchannel_index.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/transport/connectivity_state.h"
+#include "src/core/lib/transport/static_metadata.h"
+
+grpc_core::TraceFlag grpc_lb_round_robin_trace(false, "round_robin");
+
+typedef struct round_robin_lb_policy {
+ /** base policy: must be first */
+ grpc_lb_policy base;
+
+ grpc_lb_subchannel_list* subchannel_list;
+
+ /** have we started picking? */
+ bool started_picking;
+ /** are we shutting down? */
+ bool shutdown;
+ /** List of picks that are waiting on connectivity */
+ grpc_lb_policy_pick_state* pending_picks;
+
+ /** our connectivity state tracker */
+ grpc_connectivity_state_tracker state_tracker;
+
+ /** Index into subchannels for last pick. */
+ size_t last_ready_subchannel_index;
+
+ /** Latest version of the subchannel list.
+ * Subchannel connectivity callbacks will only promote updated subchannel
+ * lists if they equal \a latest_pending_subchannel_list. In other words,
+ * racing callbacks that reference outdated subchannel lists won't perform any
+ * update. */
+ grpc_lb_subchannel_list* latest_pending_subchannel_list;
+} round_robin_lb_policy;
+
+/** Returns the index into p->subchannel_list->subchannels of the next
+ * subchannel in READY state, or p->subchannel_list->num_subchannels if no
+ * subchannel is READY.
+ *
+ * Note that this function does *not* update p->last_ready_subchannel_index.
+ * The caller must do that if it returns a pick. */
+static size_t get_next_ready_subchannel_index_locked(
+ const round_robin_lb_policy* p) {
+ GPR_ASSERT(p->subchannel_list != nullptr);
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "[RR %p] getting next ready subchannel (out of %lu), "
+ "last_ready_subchannel_index=%lu",
+ (void*)p, (unsigned long)p->subchannel_list->num_subchannels,
+ (unsigned long)p->last_ready_subchannel_index);
+ }
+ for (size_t i = 0; i < p->subchannel_list->num_subchannels; ++i) {
+ const size_t index = (i + p->last_ready_subchannel_index + 1) %
+ p->subchannel_list->num_subchannels;
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(
+ GPR_DEBUG,
+ "[RR %p] checking subchannel %p, subchannel_list %p, index %lu: "
+ "state=%s",
+ (void*)p, (void*)p->subchannel_list->subchannels[index].subchannel,
+ (void*)p->subchannel_list, (unsigned long)index,
+ grpc_connectivity_state_name(
+ p->subchannel_list->subchannels[index].curr_connectivity_state));
+ }
+ if (p->subchannel_list->subchannels[index].curr_connectivity_state ==
+ GRPC_CHANNEL_READY) {
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[RR %p] found next ready subchannel (%p) at index %lu of "
+ "subchannel_list %p",
+ (void*)p,
+ (void*)p->subchannel_list->subchannels[index].subchannel,
+ (unsigned long)index, (void*)p->subchannel_list);
+ }
+ return index;
+ }
+ }
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[RR %p] no subchannels in ready state", (void*)p);
+ }
+ return p->subchannel_list->num_subchannels;
+}
+
+// Sets p->last_ready_subchannel_index to last_ready_index.
+static void update_last_ready_subchannel_index_locked(round_robin_lb_policy* p,
+ size_t last_ready_index) {
+ GPR_ASSERT(last_ready_index < p->subchannel_list->num_subchannels);
+ p->last_ready_subchannel_index = last_ready_index;
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[RR %p] setting last_ready_subchannel_index=%lu (SC %p, CSC %p)",
+ (void*)p, (unsigned long)last_ready_index,
+ (void*)p->subchannel_list->subchannels[last_ready_index].subchannel,
+ (void*)p->subchannel_list->subchannels[last_ready_index]
+ .connected_subchannel.get());
+ }
+}
+
+static void rr_destroy(grpc_lb_policy* pol) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy at %p",
+ (void*)pol, (void*)pol);
+ }
+ GPR_ASSERT(p->subchannel_list == nullptr);
+ GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
+ grpc_connectivity_state_destroy(&p->state_tracker);
+ grpc_subchannel_index_unref();
+ gpr_free(p);
+}
+
+static void rr_shutdown_locked(grpc_lb_policy* pol,
+ grpc_lb_policy* new_policy) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown");
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[RR %p] Shutting down", p);
+ }
+ p->shutdown = true;
+ grpc_lb_policy_pick_state* pick;
+ while ((pick = p->pending_picks) != nullptr) {
+ p->pending_picks = pick->next;
+ if (new_policy != nullptr) {
+ // Hand off to new LB policy.
+ if (grpc_lb_policy_pick_locked(new_policy, pick)) {
+ // Synchronous return; schedule callback.
+ GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_NONE);
+ }
+ } else {
+ pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_REF(error));
+ }
+ }
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
+ GRPC_ERROR_REF(error), "rr_shutdown");
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "sl_shutdown_rr_shutdown");
+ p->subchannel_list = nullptr;
+ }
+ if (p->latest_pending_subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->latest_pending_subchannel_list, "sl_shutdown_pending_rr_shutdown");
+ p->latest_pending_subchannel_list = nullptr;
+ }
+ grpc_lb_policy_try_reresolve(&p->base, &grpc_lb_round_robin_trace,
+ GRPC_ERROR_CANCELLED);
+ GRPC_ERROR_UNREF(error);
+}
+
+static void rr_cancel_pick_locked(grpc_lb_policy* pol,
+ grpc_lb_policy_pick_state* pick,
+ grpc_error* error) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ grpc_lb_policy_pick_state* pp = p->pending_picks;
+ p->pending_picks = nullptr;
+ while (pp != nullptr) {
+ grpc_lb_policy_pick_state* next = pp->next;
+ if (pp == pick) {
+ pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(pick->on_complete,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick cancelled", &error, 1));
+ } else {
+ pp->next = p->pending_picks;
+ p->pending_picks = pp;
+ }
+ pp = next;
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void rr_cancel_picks_locked(grpc_lb_policy* pol,
+ uint32_t initial_metadata_flags_mask,
+ uint32_t initial_metadata_flags_eq,
+ grpc_error* error) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ grpc_lb_policy_pick_state* pick = p->pending_picks;
+ p->pending_picks = nullptr;
+ while (pick != nullptr) {
+ grpc_lb_policy_pick_state* next = pick->next;
+ if ((pick->initial_metadata_flags & initial_metadata_flags_mask) ==
+ initial_metadata_flags_eq) {
+ pick->connected_subchannel.reset();
+ GRPC_CLOSURE_SCHED(pick->on_complete,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick cancelled", &error, 1));
+ } else {
+ pick->next = p->pending_picks;
+ p->pending_picks = pick;
+ }
+ pick = next;
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void start_picking_locked(round_robin_lb_policy* p) {
+ p->started_picking = true;
+ for (size_t i = 0; i < p->subchannel_list->num_subchannels; i++) {
+ if (p->subchannel_list->subchannels[i].subchannel != nullptr) {
+ grpc_lb_subchannel_list_ref_for_connectivity_watch(p->subchannel_list,
+ "connectivity_watch");
+ grpc_lb_subchannel_data_start_connectivity_watch(
+ &p->subchannel_list->subchannels[i]);
+ }
+ }
+}
+
+static void rr_exit_idle_locked(grpc_lb_policy* pol) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ if (!p->started_picking) {
+ start_picking_locked(p);
+ }
+}
+
+static int rr_pick_locked(grpc_lb_policy* pol,
+ grpc_lb_policy_pick_state* pick) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_INFO, "[RR %p] Trying to pick (shutdown: %d)", pol,
+ p->shutdown);
+ }
+ GPR_ASSERT(!p->shutdown);
+ if (p->subchannel_list != nullptr) {
+ const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
+ if (next_ready_index < p->subchannel_list->num_subchannels) {
+ /* readily available, report right away */
+ grpc_lb_subchannel_data* sd =
+ &p->subchannel_list->subchannels[next_ready_index];
+ pick->connected_subchannel = sd->connected_subchannel;
+ if (pick->user_data != nullptr) {
+ *pick->user_data = sd->user_data;
+ }
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(
+ GPR_DEBUG,
+ "[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, "
+ "index %" PRIuPTR ")",
+ p, sd->subchannel, pick->connected_subchannel.get(),
+ sd->subchannel_list, next_ready_index);
+ }
+ /* only advance the last picked pointer if the selection was used */
+ update_last_ready_subchannel_index_locked(p, next_ready_index);
+ return 1;
+ }
+ }
+ /* no pick currently available. Save for later in list of pending picks */
+ if (!p->started_picking) {
+ start_picking_locked(p);
+ }
+ pick->next = p->pending_picks;
+ p->pending_picks = pick;
+ return 0;
+}
+
+static void update_state_counters_locked(grpc_lb_subchannel_data* sd) {
+ grpc_lb_subchannel_list* subchannel_list = sd->subchannel_list;
+ GPR_ASSERT(sd->prev_connectivity_state != GRPC_CHANNEL_SHUTDOWN);
+ GPR_ASSERT(sd->curr_connectivity_state != GRPC_CHANNEL_SHUTDOWN);
+ if (sd->prev_connectivity_state == GRPC_CHANNEL_READY) {
+ GPR_ASSERT(subchannel_list->num_ready > 0);
+ --subchannel_list->num_ready;
+ } else if (sd->prev_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
+ GPR_ASSERT(subchannel_list->num_transient_failures > 0);
+ --subchannel_list->num_transient_failures;
+ } else if (sd->prev_connectivity_state == GRPC_CHANNEL_IDLE) {
+ GPR_ASSERT(subchannel_list->num_idle > 0);
+ --subchannel_list->num_idle;
+ }
+ sd->prev_connectivity_state = sd->curr_connectivity_state;
+ if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) {
+ ++subchannel_list->num_ready;
+ } else if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
+ ++subchannel_list->num_transient_failures;
+ } else if (sd->curr_connectivity_state == GRPC_CHANNEL_IDLE) {
+ ++subchannel_list->num_idle;
+ }
+}
+
+/** Sets the policy's connectivity status based on that of the passed-in \a sd
+ * (the grpc_lb_subchannel_data associated with the updated subchannel) and the
+ * subchannel list \a sd belongs to (sd->subchannel_list). \a error will be used
+ * only if the policy transitions to state TRANSIENT_FAILURE. */
+static void update_lb_connectivity_status_locked(grpc_lb_subchannel_data* sd,
+ grpc_error* error) {
+ /* In priority order. The first rule to match terminates the search (ie, if we
+ * are on rule n, all previous rules were unfulfilled).
+ *
+ * 1) RULE: ANY subchannel is READY => policy is READY.
+ * CHECK: subchannel_list->num_ready > 0.
+ *
+ * 2) RULE: ANY subchannel is CONNECTING => policy is CONNECTING.
+ * CHECK: sd->curr_connectivity_state == CONNECTING.
+ *
+ * 3) RULE: ALL subchannels are SHUTDOWN => policy is IDLE (and requests
+ * re-resolution).
+ * CHECK: subchannel_list->num_shutdown ==
+ * subchannel_list->num_subchannels.
+ *
+ * 4) RULE: ALL subchannels are SHUTDOWN or TRANSIENT_FAILURE => policy is
+ * TRANSIENT_FAILURE.
+ * CHECK: subchannel_list->num_shutdown +
+ * subchannel_list->num_transient_failures ==
+ * subchannel_list->num_subchannels.
+ */
+ // TODO(juanlishen): For rule 4, we may want to re-resolve instead.
+ grpc_lb_subchannel_list* subchannel_list = sd->subchannel_list;
+ round_robin_lb_policy* p = (round_robin_lb_policy*)subchannel_list->policy;
+ GPR_ASSERT(sd->curr_connectivity_state != GRPC_CHANNEL_IDLE);
+ if (subchannel_list->num_ready > 0) {
+ /* 1) READY */
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_READY,
+ GRPC_ERROR_NONE, "rr_ready");
+ } else if (sd->curr_connectivity_state == GRPC_CHANNEL_CONNECTING) {
+ /* 2) CONNECTING */
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_CONNECTING,
+ GRPC_ERROR_NONE, "rr_connecting");
+ } else if (subchannel_list->num_shutdown ==
+ subchannel_list->num_subchannels) {
+ /* 3) IDLE and re-resolve */
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_IDLE,
+ GRPC_ERROR_NONE,
+ "rr_exhausted_subchannels+reresolve");
+ p->started_picking = false;
+ grpc_lb_policy_try_reresolve(&p->base, &grpc_lb_round_robin_trace,
+ GRPC_ERROR_NONE);
+ } else if (subchannel_list->num_shutdown +
+ subchannel_list->num_transient_failures ==
+ subchannel_list->num_subchannels) {
+ /* 4) TRANSIENT_FAILURE */
+ grpc_connectivity_state_set(&p->state_tracker,
+ GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(error), "rr_transient_failure");
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void rr_connectivity_changed_locked(void* arg, grpc_error* error) {
+ grpc_lb_subchannel_data* sd = (grpc_lb_subchannel_data*)arg;
+ round_robin_lb_policy* p =
+ (round_robin_lb_policy*)sd->subchannel_list->policy;
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(
+ GPR_DEBUG,
+ "[RR %p] connectivity changed for subchannel %p, subchannel_list %p: "
+ "prev_state=%s new_state=%s p->shutdown=%d "
+ "sd->subchannel_list->shutting_down=%d error=%s",
+ (void*)p, (void*)sd->subchannel, (void*)sd->subchannel_list,
+ grpc_connectivity_state_name(sd->prev_connectivity_state),
+ grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe),
+ p->shutdown, sd->subchannel_list->shutting_down,
+ grpc_error_string(error));
+ }
+ // If the policy is shutting down, unref and return.
+ if (p->shutdown) {
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "rr_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "rr_shutdown");
+ return;
+ }
+ // If the subchannel list is shutting down, stop watching.
+ if (sd->subchannel_list->shutting_down || error == GRPC_ERROR_CANCELLED) {
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "rr_sl_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "rr_sl_shutdown");
+ return;
+ }
+ // If we're still here, the notification must be for a subchannel in
+ // either the current or latest pending subchannel lists.
+ GPR_ASSERT(sd->subchannel_list == p->subchannel_list ||
+ sd->subchannel_list == p->latest_pending_subchannel_list);
+ GPR_ASSERT(sd->pending_connectivity_state_unsafe != GRPC_CHANNEL_SHUTDOWN);
+ // Now that we're inside the combiner, copy the pending connectivity
+ // state (which was set by the connectivity state watcher) to
+ // curr_connectivity_state, which is what we use inside of the combiner.
+ sd->curr_connectivity_state = sd->pending_connectivity_state_unsafe;
+ // Update state counters and new overall state.
+ update_state_counters_locked(sd);
+ update_lb_connectivity_status_locked(sd, GRPC_ERROR_REF(error));
+ // If the sd's new state is TRANSIENT_FAILURE, unref the *connected*
+ // subchannel, if any.
+ switch (sd->curr_connectivity_state) {
+ case GRPC_CHANNEL_TRANSIENT_FAILURE: {
+ sd->connected_subchannel.reset();
+ break;
+ }
+ case GRPC_CHANNEL_READY: {
+ if (sd->connected_subchannel == nullptr) {
+ sd->connected_subchannel =
+ grpc_subchannel_get_connected_subchannel(sd->subchannel);
+ }
+ if (sd->subchannel_list != p->subchannel_list) {
+ // promote sd->subchannel_list to p->subchannel_list.
+ // sd->subchannel_list must be equal to
+ // p->latest_pending_subchannel_list because we have already filtered
+ // for sds belonging to outdated subchannel lists.
+ GPR_ASSERT(sd->subchannel_list == p->latest_pending_subchannel_list);
+ GPR_ASSERT(!sd->subchannel_list->shutting_down);
+ if (grpc_lb_round_robin_trace.enabled()) {
+ const unsigned long num_subchannels =
+ p->subchannel_list != nullptr
+ ? (unsigned long)p->subchannel_list->num_subchannels
+ : 0;
+ gpr_log(GPR_DEBUG,
+ "[RR %p] phasing out subchannel list %p (size %lu) in favor "
+ "of %p (size %lu)",
+ (void*)p, (void*)p->subchannel_list, num_subchannels,
+ (void*)sd->subchannel_list, num_subchannels);
+ }
+ if (p->subchannel_list != nullptr) {
+ // dispose of the current subchannel_list
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "sl_phase_out_shutdown");
+ }
+ p->subchannel_list = p->latest_pending_subchannel_list;
+ p->latest_pending_subchannel_list = nullptr;
+ }
+ /* at this point we know there's at least one suitable subchannel. Go
+ * ahead and pick one and notify the pending suitors in
+ * p->pending_picks. This preemptively replicates rr_pick()'s actions. */
+ const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
+ GPR_ASSERT(next_ready_index < p->subchannel_list->num_subchannels);
+ grpc_lb_subchannel_data* selected =
+ &p->subchannel_list->subchannels[next_ready_index];
+ if (p->pending_picks != nullptr) {
+ // if the selected subchannel is going to be used for the pending
+ // picks, update the last picked pointer
+ update_last_ready_subchannel_index_locked(p, next_ready_index);
+ }
+ grpc_lb_policy_pick_state* pick;
+ while ((pick = p->pending_picks)) {
+ p->pending_picks = pick->next;
+ pick->connected_subchannel = selected->connected_subchannel;
+ if (pick->user_data != nullptr) {
+ *pick->user_data = selected->user_data;
+ }
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[RR %p] Fulfilling pending pick. Target <-- subchannel %p "
+ "(subchannel_list %p, index %lu)",
+ (void*)p, (void*)selected->subchannel,
+ (void*)p->subchannel_list, (unsigned long)next_ready_index);
+ }
+ GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_NONE);
+ }
+ break;
+ }
+ case GRPC_CHANNEL_SHUTDOWN:
+ GPR_UNREACHABLE_CODE(return );
+ case GRPC_CHANNEL_CONNECTING:
+ case GRPC_CHANNEL_IDLE:; // fallthrough
+ }
+ // Renew notification.
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
+}
+
+static grpc_connectivity_state rr_check_connectivity_locked(
+ grpc_lb_policy* pol, grpc_error** error) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ return grpc_connectivity_state_get(&p->state_tracker, error);
+}
+
+static void rr_notify_on_state_change_locked(grpc_lb_policy* pol,
+ grpc_connectivity_state* current,
+ grpc_closure* notify) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current,
+ notify);
+}
+
+static void rr_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
+ grpc_closure* on_ack) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
+ const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
+ if (next_ready_index < p->subchannel_list->num_subchannels) {
+ grpc_lb_subchannel_data* selected =
+ &p->subchannel_list->subchannels[next_ready_index];
+ grpc_core::RefCountedPtr<grpc_core::ConnectedSubchannel> target =
+ selected->connected_subchannel;
+ target->Ping(on_initiate, on_ack);
+ } else {
+ GRPC_CLOSURE_SCHED(on_initiate, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Round Robin not connected"));
+ GRPC_CLOSURE_SCHED(on_ack, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Round Robin not connected"));
+ }
+}
+
+static void rr_update_locked(grpc_lb_policy* policy,
+ const grpc_lb_policy_args* args) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)policy;
+ const grpc_arg* arg =
+ grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
+ if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
+ gpr_log(GPR_ERROR, "[RR %p] update provided no addresses; ignoring", p);
+ // If we don't have a current subchannel list, go into TRANSIENT_FAILURE.
+ // Otherwise, keep using the current subchannel list (ignore this update).
+ if (p->subchannel_list == nullptr) {
+ grpc_connectivity_state_set(
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
+ "rr_update_missing");
+ }
+ return;
+ }
+ grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p;
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[RR %p] received update with %" PRIuPTR " addresses", p,
+ addresses->num_addresses);
+ }
+ grpc_lb_subchannel_list* subchannel_list = grpc_lb_subchannel_list_create(
+ &p->base, &grpc_lb_round_robin_trace, addresses, args,
+ rr_connectivity_changed_locked);
+ if (subchannel_list->num_subchannels == 0) {
+ grpc_connectivity_state_set(
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
+ "rr_update_empty");
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "sl_shutdown_empty_update");
+ }
+ p->subchannel_list = subchannel_list; // empty list
+ return;
+ }
+ if (p->started_picking) {
+ if (p->latest_pending_subchannel_list != nullptr) {
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[RR %p] Shutting down latest pending subchannel list %p, "
+ "about to be replaced by newer latest %p",
+ (void*)p, (void*)p->latest_pending_subchannel_list,
+ (void*)subchannel_list);
+ }
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->latest_pending_subchannel_list, "sl_outdated");
+ }
+ p->latest_pending_subchannel_list = subchannel_list;
+ for (size_t i = 0; i < subchannel_list->num_subchannels; ++i) {
+ /* Watch every new subchannel. A subchannel list becomes active the
+ * moment one of its subchannels is READY. At that moment, we swap
+ * p->subchannel_list for sd->subchannel_list, provided the subchannel
+ * list is still valid (ie, isn't shutting down) */
+ grpc_lb_subchannel_list_ref_for_connectivity_watch(subchannel_list,
+ "connectivity_watch");
+ grpc_lb_subchannel_data_start_connectivity_watch(
+ &subchannel_list->subchannels[i]);
+ }
+ } else {
+ // The policy isn't picking yet. Save the update for later, disposing of
+ // previous version if any.
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ p->subchannel_list, "rr_update_before_started_picking");
+ }
+ p->subchannel_list = subchannel_list;
+ }
+}
+
+static void rr_set_reresolve_closure_locked(
+ grpc_lb_policy* policy, grpc_closure* request_reresolution) {
+ round_robin_lb_policy* p = (round_robin_lb_policy*)policy;
+ GPR_ASSERT(!p->shutdown);
+ GPR_ASSERT(policy->request_reresolution == nullptr);
+ policy->request_reresolution = request_reresolution;
+}
+
+static const grpc_lb_policy_vtable round_robin_lb_policy_vtable = {
+ rr_destroy,
+ rr_shutdown_locked,
+ rr_pick_locked,
+ rr_cancel_pick_locked,
+ rr_cancel_picks_locked,
+ rr_ping_one_locked,
+ rr_exit_idle_locked,
+ rr_check_connectivity_locked,
+ rr_notify_on_state_change_locked,
+ rr_update_locked,
+ rr_set_reresolve_closure_locked};
+
+static void round_robin_factory_ref(grpc_lb_policy_factory* factory) {}
+
+static void round_robin_factory_unref(grpc_lb_policy_factory* factory) {}
+
+static grpc_lb_policy* round_robin_create(grpc_lb_policy_factory* factory,
+ grpc_lb_policy_args* args) {
+ GPR_ASSERT(args->client_channel_factory != nullptr);
+ round_robin_lb_policy* p = (round_robin_lb_policy*)gpr_zalloc(sizeof(*p));
+ grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable, args->combiner);
+ grpc_subchannel_index_ref();
+ grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
+ "round_robin");
+ rr_update_locked(&p->base, args);
+ if (grpc_lb_round_robin_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "[RR %p] Created with %lu subchannels", (void*)p,
+ (unsigned long)p->subchannel_list->num_subchannels);
+ }
+ return &p->base;
+}
+
+static const grpc_lb_policy_factory_vtable round_robin_factory_vtable = {
+ round_robin_factory_ref, round_robin_factory_unref, round_robin_create,
+ "round_robin"};
+
+static grpc_lb_policy_factory round_robin_lb_policy_factory = {
+ &round_robin_factory_vtable};
+
+static grpc_lb_policy_factory* round_robin_lb_factory_create() {
+ return &round_robin_lb_policy_factory;
+}
+
+/* Plugin registration */
+
+void grpc_lb_policy_round_robin_init() {
+ grpc_register_lb_policy(round_robin_lb_factory_create());
+}
+
+void grpc_lb_policy_round_robin_shutdown() {}
diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
new file mode 100644
index 0000000000..fa2ffcc796
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
@@ -0,0 +1,259 @@
+/*
+ *
+ * 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 <string.h>
+
+#include <grpc/support/alloc.h>
+
+#include "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/iomgr/closure.h"
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/transport/connectivity_state.h"
+
+void grpc_lb_subchannel_data_unref_subchannel(grpc_lb_subchannel_data* sd,
+ const char* reason) {
+ if (sd->subchannel != nullptr) {
+ if (sd->subchannel_list->tracer->enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
+ " (subchannel %p): unreffing subchannel",
+ sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
+ sd->subchannel_list,
+ (size_t)(sd - sd->subchannel_list->subchannels),
+ sd->subchannel_list->num_subchannels, sd->subchannel);
+ }
+ GRPC_SUBCHANNEL_UNREF(sd->subchannel, reason);
+ sd->subchannel = nullptr;
+ sd->connected_subchannel.reset();
+ if (sd->user_data != nullptr) {
+ GPR_ASSERT(sd->user_data_vtable != nullptr);
+ sd->user_data_vtable->destroy(sd->user_data);
+ sd->user_data = nullptr;
+ }
+ }
+}
+
+void grpc_lb_subchannel_data_start_connectivity_watch(
+ grpc_lb_subchannel_data* sd) {
+ if (sd->subchannel_list->tracer->enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
+ " (subchannel %p): requesting connectivity change notification",
+ sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
+ sd->subchannel_list,
+ (size_t)(sd - sd->subchannel_list->subchannels),
+ sd->subchannel_list->num_subchannels, sd->subchannel);
+ }
+ sd->connectivity_notification_pending = true;
+ grpc_subchannel_notify_on_state_change(
+ sd->subchannel, sd->subchannel_list->policy->interested_parties,
+ &sd->pending_connectivity_state_unsafe,
+ &sd->connectivity_changed_closure);
+}
+
+void grpc_lb_subchannel_data_stop_connectivity_watch(
+ grpc_lb_subchannel_data* sd) {
+ if (sd->subchannel_list->tracer->enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
+ " (subchannel %p): stopping connectivity watch",
+ sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
+ sd->subchannel_list,
+ (size_t)(sd - sd->subchannel_list->subchannels),
+ sd->subchannel_list->num_subchannels, sd->subchannel);
+ }
+ GPR_ASSERT(sd->connectivity_notification_pending);
+ sd->connectivity_notification_pending = false;
+}
+
+grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
+ grpc_lb_policy* p, grpc_core::TraceFlag* tracer,
+ const grpc_lb_addresses* addresses, const grpc_lb_policy_args* args,
+ grpc_iomgr_cb_func connectivity_changed_cb) {
+ grpc_lb_subchannel_list* subchannel_list =
+ (grpc_lb_subchannel_list*)gpr_zalloc(sizeof(*subchannel_list));
+ if (tracer->enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels",
+ tracer->name(), p, subchannel_list, addresses->num_addresses);
+ }
+ subchannel_list->policy = p;
+ subchannel_list->tracer = tracer;
+ gpr_ref_init(&subchannel_list->refcount, 1);
+ subchannel_list->subchannels = (grpc_lb_subchannel_data*)gpr_zalloc(
+ sizeof(grpc_lb_subchannel_data) * addresses->num_addresses);
+ // We need to remove the LB addresses in order to be able to compare the
+ // subchannel keys of subchannels from a different batch of addresses.
+ static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
+ GRPC_ARG_LB_ADDRESSES};
+ // Create a subchannel for each address.
+ grpc_subchannel_args sc_args;
+ size_t subchannel_index = 0;
+ for (size_t i = 0; i < addresses->num_addresses; i++) {
+ // If there were any balancer, we would have chosen grpclb policy instead.
+ GPR_ASSERT(!addresses->addresses[i].is_balancer);
+ memset(&sc_args, 0, sizeof(grpc_subchannel_args));
+ grpc_arg addr_arg =
+ grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
+ args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
+ 1);
+ gpr_free(addr_arg.value.string);
+ sc_args.args = new_args;
+ grpc_subchannel* subchannel = grpc_client_channel_factory_create_subchannel(
+ args->client_channel_factory, &sc_args);
+ grpc_channel_args_destroy(new_args);
+ if (subchannel == nullptr) {
+ // Subchannel could not be created.
+ if (tracer->enabled()) {
+ char* address_uri =
+ grpc_sockaddr_to_uri(&addresses->addresses[i].address);
+ gpr_log(GPR_DEBUG,
+ "[%s %p] could not create subchannel for address uri %s, "
+ "ignoring",
+ tracer->name(), subchannel_list->policy, address_uri);
+ gpr_free(address_uri);
+ }
+ continue;
+ }
+ if (tracer->enabled()) {
+ char* address_uri =
+ grpc_sockaddr_to_uri(&addresses->addresses[i].address);
+ gpr_log(GPR_DEBUG,
+ "[%s %p] subchannel list %p index %" PRIuPTR
+ ": Created subchannel %p for address uri %s",
+ tracer->name(), p, subchannel_list, subchannel_index, subchannel,
+ address_uri);
+ gpr_free(address_uri);
+ }
+ grpc_lb_subchannel_data* sd =
+ &subchannel_list->subchannels[subchannel_index++];
+ sd->subchannel_list = subchannel_list;
+ sd->subchannel = subchannel;
+ GRPC_CLOSURE_INIT(&sd->connectivity_changed_closure,
+ connectivity_changed_cb, sd,
+ grpc_combiner_scheduler(args->combiner));
+ // We assume that the current state is IDLE. If not, we'll get a
+ // callback telling us that.
+ sd->prev_connectivity_state = GRPC_CHANNEL_IDLE;
+ sd->curr_connectivity_state = GRPC_CHANNEL_IDLE;
+ sd->pending_connectivity_state_unsafe = GRPC_CHANNEL_IDLE;
+ sd->user_data_vtable = addresses->user_data_vtable;
+ if (sd->user_data_vtable != nullptr) {
+ sd->user_data =
+ sd->user_data_vtable->copy(addresses->addresses[i].user_data);
+ }
+ }
+ subchannel_list->num_subchannels = subchannel_index;
+ subchannel_list->num_idle = subchannel_index;
+ return subchannel_list;
+}
+
+static void subchannel_list_destroy(grpc_lb_subchannel_list* subchannel_list) {
+ if (subchannel_list->tracer->enabled()) {
+ gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p",
+ subchannel_list->tracer->name(), subchannel_list->policy,
+ subchannel_list);
+ }
+ for (size_t i = 0; i < subchannel_list->num_subchannels; i++) {
+ grpc_lb_subchannel_data* sd = &subchannel_list->subchannels[i];
+ grpc_lb_subchannel_data_unref_subchannel(sd, "subchannel_list_destroy");
+ }
+ gpr_free(subchannel_list->subchannels);
+ gpr_free(subchannel_list);
+}
+
+void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list,
+ const char* reason) {
+ gpr_ref_non_zero(&subchannel_list->refcount);
+ if (subchannel_list->tracer->enabled()) {
+ const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
+ gpr_log(GPR_DEBUG, "[%s %p] subchannel_list %p REF %lu->%lu (%s)",
+ subchannel_list->tracer->name(), subchannel_list->policy,
+ subchannel_list, (unsigned long)(count - 1), (unsigned long)count,
+ reason);
+ }
+}
+
+void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list,
+ const char* reason) {
+ const bool done = gpr_unref(&subchannel_list->refcount);
+ if (subchannel_list->tracer->enabled()) {
+ const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
+ gpr_log(GPR_DEBUG, "[%s %p] subchannel_list %p UNREF %lu->%lu (%s)",
+ subchannel_list->tracer->name(), subchannel_list->policy,
+ subchannel_list, (unsigned long)(count + 1), (unsigned long)count,
+ reason);
+ }
+ if (done) {
+ subchannel_list_destroy(subchannel_list);
+ }
+}
+
+void grpc_lb_subchannel_list_ref_for_connectivity_watch(
+ grpc_lb_subchannel_list* subchannel_list, const char* reason) {
+ GRPC_LB_POLICY_REF(subchannel_list->policy, reason);
+ grpc_lb_subchannel_list_ref(subchannel_list, reason);
+}
+
+void grpc_lb_subchannel_list_unref_for_connectivity_watch(
+ grpc_lb_subchannel_list* subchannel_list, const char* reason) {
+ GRPC_LB_POLICY_UNREF(subchannel_list->policy, reason);
+ grpc_lb_subchannel_list_unref(subchannel_list, reason);
+}
+
+static void subchannel_data_cancel_connectivity_watch(
+ grpc_lb_subchannel_data* sd, const char* reason) {
+ if (sd->subchannel_list->tracer->enabled()) {
+ gpr_log(GPR_DEBUG,
+ "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
+ " (subchannel %p): canceling connectivity watch (%s)",
+ sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
+ sd->subchannel_list,
+ (size_t)(sd - sd->subchannel_list->subchannels),
+ sd->subchannel_list->num_subchannels, sd->subchannel, reason);
+ }
+ grpc_subchannel_notify_on_state_change(sd->subchannel, nullptr, nullptr,
+ &sd->connectivity_changed_closure);
+}
+
+void grpc_lb_subchannel_list_shutdown_and_unref(
+ grpc_lb_subchannel_list* subchannel_list, const char* reason) {
+ if (subchannel_list->tracer->enabled()) {
+ gpr_log(GPR_DEBUG, "[%s %p] Shutting down subchannel_list %p (%s)",
+ subchannel_list->tracer->name(), subchannel_list->policy,
+ subchannel_list, reason);
+ }
+ GPR_ASSERT(!subchannel_list->shutting_down);
+ subchannel_list->shutting_down = true;
+ for (size_t i = 0; i < subchannel_list->num_subchannels; i++) {
+ grpc_lb_subchannel_data* sd = &subchannel_list->subchannels[i];
+ // If there's a pending notification for this subchannel, cancel it;
+ // the callback is responsible for unreffing the subchannel.
+ // Otherwise, unref the subchannel directly.
+ if (sd->connectivity_notification_pending) {
+ subchannel_data_cancel_connectivity_watch(sd, reason);
+ } else if (sd->subchannel != nullptr) {
+ grpc_lb_subchannel_data_unref_subchannel(sd, reason);
+ }
+ }
+ grpc_lb_subchannel_list_unref(subchannel_list, reason);
+}
diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
new file mode 100644
index 0000000000..3377605263
--- /dev/null
+++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
@@ -0,0 +1,142 @@
+/*
+ *
+ * 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_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_SUBCHANNEL_LIST_H
+#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_SUBCHANNEL_LIST_H
+
+#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
+#include "src/core/ext/filters/client_channel/subchannel.h"
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
+#include "src/core/lib/transport/connectivity_state.h"
+
+// TODO(roth): This code is intended to be shared between pick_first and
+// round_robin. However, the interface needs more work to provide clean
+// encapsulation. For example, the structs here have some fields that are
+// only used in one of the two (e.g., the state counters in
+// grpc_lb_subchannel_list and the prev_connectivity_state field in
+// grpc_lb_subchannel_data are only used in round_robin, and the
+// checking_subchannel field in grpc_lb_subchannel_list is only used by
+// pick_first). Also, there is probably some code duplication between the
+// connectivity state notification callback code in both pick_first and
+// round_robin that could be refactored and moved here. In a future PR,
+// need to clean this up.
+
+typedef struct grpc_lb_subchannel_list grpc_lb_subchannel_list;
+
+typedef struct {
+ /** backpointer to owning subchannel list */
+ grpc_lb_subchannel_list* subchannel_list;
+ /** subchannel itself */
+ grpc_subchannel* subchannel;
+ grpc_core::RefCountedPtr<grpc_core::ConnectedSubchannel> connected_subchannel;
+ /** Is a connectivity notification pending? */
+ bool connectivity_notification_pending;
+ /** notification that connectivity has changed on subchannel */
+ grpc_closure connectivity_changed_closure;
+ /** previous and current connectivity states. Updated by \a
+ * \a connectivity_changed_closure based on
+ * \a pending_connectivity_state_unsafe. */
+ grpc_connectivity_state prev_connectivity_state;
+ grpc_connectivity_state curr_connectivity_state;
+ /** connectivity state to be updated by
+ * grpc_subchannel_notify_on_state_change(), not guarded by
+ * the combiner. To be copied to \a curr_connectivity_state by
+ * \a connectivity_changed_closure. */
+ grpc_connectivity_state pending_connectivity_state_unsafe;
+ /** the subchannel's target user data */
+ void* user_data;
+ /** vtable to operate over \a user_data */
+ const grpc_lb_user_data_vtable* user_data_vtable;
+} grpc_lb_subchannel_data;
+
+/// Unrefs the subchannel contained in sd.
+void grpc_lb_subchannel_data_unref_subchannel(grpc_lb_subchannel_data* sd,
+ const char* reason);
+
+/// Starts watching the connectivity state of the subchannel.
+/// The connectivity_changed_cb callback must invoke either
+/// grpc_lb_subchannel_data_stop_connectivity_watch() or again call
+/// grpc_lb_subchannel_data_start_connectivity_watch().
+void grpc_lb_subchannel_data_start_connectivity_watch(
+ grpc_lb_subchannel_data* sd);
+
+/// Stops watching the connectivity state of the subchannel.
+void grpc_lb_subchannel_data_stop_connectivity_watch(
+ grpc_lb_subchannel_data* sd);
+
+struct grpc_lb_subchannel_list {
+ /** backpointer to owning policy */
+ grpc_lb_policy* policy;
+
+ grpc_core::TraceFlag* tracer;
+
+ /** all our subchannels */
+ size_t num_subchannels;
+ grpc_lb_subchannel_data* subchannels;
+
+ /** Index into subchannels of the one we're currently checking.
+ * Used when connecting to subchannels serially instead of in parallel. */
+ // TODO(roth): When we have time, we can probably make this go away
+ // and compute the index dynamically by subtracting
+ // subchannel_list->subchannels from the subchannel_data pointer.
+ size_t checking_subchannel;
+
+ /** how many subchannels are in state READY */
+ size_t num_ready;
+ /** how many subchannels are in state TRANSIENT_FAILURE */
+ size_t num_transient_failures;
+ /** how many subchannels are in state SHUTDOWN */
+ size_t num_shutdown;
+ /** how many subchannels are in state IDLE */
+ size_t num_idle;
+
+ /** There will be one ref for each entry in subchannels for which there is a
+ * pending connectivity state watcher callback. */
+ gpr_refcount refcount;
+
+ /** Is this list shutting down? This may be true due to the shutdown of the
+ * policy itself or because a newer update has arrived while this one hadn't
+ * finished processing. */
+ bool shutting_down;
+};
+
+grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
+ grpc_lb_policy* p, grpc_core::TraceFlag* tracer,
+ const grpc_lb_addresses* addresses, const grpc_lb_policy_args* args,
+ grpc_iomgr_cb_func connectivity_changed_cb);
+
+void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list,
+ const char* reason);
+
+void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list,
+ const char* reason);
+
+/// Takes and releases refs needed for a connectivity notification.
+/// This includes a ref to subchannel_list and a weak ref to the LB policy.
+void grpc_lb_subchannel_list_ref_for_connectivity_watch(
+ grpc_lb_subchannel_list* subchannel_list, const char* reason);
+void grpc_lb_subchannel_list_unref_for_connectivity_watch(
+ grpc_lb_subchannel_list* subchannel_list, const char* reason);
+
+/// Mark subchannel_list as discarded. Unsubscribes all its subchannels. The
+/// connectivity state notification callback will ultimately unref it.
+void grpc_lb_subchannel_list_shutdown_and_unref(
+ grpc_lb_subchannel_list* subchannel_list, const char* reason);
+
+#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_SUBCHANNEL_LIST_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.c b/src/core/ext/filters/client_channel/lb_policy_factory.cc
index 4d1405454c..dbf69fdcba 100644
--- a/src/core/ext/filters/client_channel/lb_policy_factory.c
+++ b/src/core/ext/filters/client_channel/lb_policy_factory.cc
@@ -43,11 +43,11 @@ grpc_lb_addresses* grpc_lb_addresses_copy(const grpc_lb_addresses* addresses) {
memcpy(new_addresses->addresses, addresses->addresses,
sizeof(grpc_lb_address) * addresses->num_addresses);
for (size_t i = 0; i < addresses->num_addresses; ++i) {
- if (new_addresses->addresses[i].balancer_name != NULL) {
+ if (new_addresses->addresses[i].balancer_name != nullptr) {
new_addresses->addresses[i].balancer_name =
gpr_strdup(new_addresses->addresses[i].balancer_name);
}
- if (new_addresses->addresses[i].user_data != NULL) {
+ if (new_addresses->addresses[i].user_data != nullptr) {
new_addresses->addresses[i].user_data = addresses->user_data_vtable->copy(
new_addresses->addresses[i].user_data);
}
@@ -56,11 +56,11 @@ grpc_lb_addresses* grpc_lb_addresses_copy(const grpc_lb_addresses* addresses) {
}
void grpc_lb_addresses_set_address(grpc_lb_addresses* addresses, size_t index,
- void* address, size_t address_len,
+ const void* address, size_t address_len,
bool is_balancer, const char* balancer_name,
void* user_data) {
GPR_ASSERT(index < addresses->num_addresses);
- if (user_data != NULL) GPR_ASSERT(addresses->user_data_vtable != NULL);
+ if (user_data != nullptr) GPR_ASSERT(addresses->user_data_vtable != nullptr);
grpc_lb_address* target = &addresses->addresses[index];
memcpy(target->address.addr, address, address_len);
target->address.len = address_len;
@@ -98,12 +98,12 @@ int grpc_lb_addresses_cmp(const grpc_lb_addresses* addresses1,
if (target1->is_balancer > target2->is_balancer) return 1;
if (target1->is_balancer < target2->is_balancer) return -1;
const char* balancer_name1 =
- target1->balancer_name != NULL ? target1->balancer_name : "";
+ target1->balancer_name != nullptr ? target1->balancer_name : "";
const char* balancer_name2 =
- target2->balancer_name != NULL ? target2->balancer_name : "";
+ target2->balancer_name != nullptr ? target2->balancer_name : "";
retval = strcmp(balancer_name1, balancer_name2);
if (retval != 0) return retval;
- if (addresses1->user_data_vtable != NULL) {
+ if (addresses1->user_data_vtable != nullptr) {
retval = addresses1->user_data_vtable->cmp(target1->user_data,
target2->user_data);
if (retval != 0) return retval;
@@ -112,13 +112,11 @@ int grpc_lb_addresses_cmp(const grpc_lb_addresses* addresses1,
return 0;
}
-void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
- grpc_lb_addresses* addresses) {
+void grpc_lb_addresses_destroy(grpc_lb_addresses* addresses) {
for (size_t i = 0; i < addresses->num_addresses; ++i) {
gpr_free(addresses->addresses[i].balancer_name);
- if (addresses->addresses[i].user_data != NULL) {
- addresses->user_data_vtable->destroy(exec_ctx,
- addresses->addresses[i].user_data);
+ if (addresses->addresses[i].user_data != nullptr) {
+ addresses->user_data_vtable->destroy(addresses->addresses[i].user_data);
}
}
gpr_free(addresses->addresses);
@@ -128,8 +126,8 @@ void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
static void* lb_addresses_copy(void* addresses) {
return grpc_lb_addresses_copy((grpc_lb_addresses*)addresses);
}
-static void lb_addresses_destroy(grpc_exec_ctx* exec_ctx, void* addresses) {
- grpc_lb_addresses_destroy(exec_ctx, (grpc_lb_addresses*)addresses);
+static void lb_addresses_destroy(void* addresses) {
+ grpc_lb_addresses_destroy((grpc_lb_addresses*)addresses);
}
static int lb_addresses_cmp(void* addresses1, void* addresses2) {
return grpc_lb_addresses_cmp((grpc_lb_addresses*)addresses1,
@@ -148,8 +146,8 @@ grpc_lb_addresses* grpc_lb_addresses_find_channel_arg(
const grpc_channel_args* channel_args) {
const grpc_arg* lb_addresses_arg =
grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES);
- if (lb_addresses_arg == NULL || lb_addresses_arg->type != GRPC_ARG_POINTER)
- return NULL;
+ if (lb_addresses_arg == nullptr || lb_addresses_arg->type != GRPC_ARG_POINTER)
+ return nullptr;
return (grpc_lb_addresses*)lb_addresses_arg->value.pointer.p;
}
@@ -162,8 +160,7 @@ void grpc_lb_policy_factory_unref(grpc_lb_policy_factory* factory) {
}
grpc_lb_policy* grpc_lb_policy_factory_create_lb_policy(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy_factory* factory,
- grpc_lb_policy_args* args) {
- if (factory == NULL) return NULL;
- return factory->vtable->create_lb_policy(exec_ctx, factory, args);
+ grpc_lb_policy_factory* factory, grpc_lb_policy_args* args) {
+ if (factory == nullptr) return nullptr;
+ return factory->vtable->create_lb_policy(factory, args);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h
index 9d9fb143df..9da231b657 100644
--- a/src/core/ext/filters/client_channel/lb_policy_factory.h
+++ b/src/core/ext/filters/client_channel/lb_policy_factory.h
@@ -33,7 +33,7 @@ typedef struct grpc_lb_policy_factory grpc_lb_policy_factory;
typedef struct grpc_lb_policy_factory_vtable grpc_lb_policy_factory_vtable;
struct grpc_lb_policy_factory {
- const grpc_lb_policy_factory_vtable *vtable;
+ const grpc_lb_policy_factory_vtable* vtable;
};
/** A resolved address alongside any LB related information associated with it.
@@ -44,90 +44,87 @@ struct grpc_lb_policy_factory {
typedef struct grpc_lb_address {
grpc_resolved_address address;
bool is_balancer;
- char *balancer_name; /* For secure naming. */
- void *user_data;
+ char* balancer_name; /* For secure naming. */
+ void* user_data;
} grpc_lb_address;
typedef struct grpc_lb_user_data_vtable {
- void *(*copy)(void *);
- void (*destroy)(grpc_exec_ctx *exec_ctx, void *);
- int (*cmp)(void *, void *);
+ void* (*copy)(void*);
+ void (*destroy)(void*);
+ int (*cmp)(void*, void*);
} grpc_lb_user_data_vtable;
typedef struct grpc_lb_addresses {
size_t num_addresses;
- grpc_lb_address *addresses;
- const grpc_lb_user_data_vtable *user_data_vtable;
+ grpc_lb_address* addresses;
+ const grpc_lb_user_data_vtable* user_data_vtable;
} grpc_lb_addresses;
/** Returns a grpc_addresses struct with enough space for
\a num_addresses addresses. The \a user_data_vtable argument may be
NULL if no user data will be added. */
-grpc_lb_addresses *grpc_lb_addresses_create(
- size_t num_addresses, const grpc_lb_user_data_vtable *user_data_vtable);
+grpc_lb_addresses* grpc_lb_addresses_create(
+ size_t num_addresses, const grpc_lb_user_data_vtable* user_data_vtable);
/** Creates a copy of \a addresses. */
-grpc_lb_addresses *grpc_lb_addresses_copy(const grpc_lb_addresses *addresses);
+grpc_lb_addresses* grpc_lb_addresses_copy(const grpc_lb_addresses* addresses);
/** Sets the value of the address at index \a index of \a addresses.
* \a address is a socket address of length \a address_len.
* Takes ownership of \a balancer_name. */
-void grpc_lb_addresses_set_address(grpc_lb_addresses *addresses, size_t index,
- void *address, size_t address_len,
- bool is_balancer, const char *balancer_name,
- void *user_data);
+void grpc_lb_addresses_set_address(grpc_lb_addresses* addresses, size_t index,
+ const void* address, size_t address_len,
+ bool is_balancer, const char* balancer_name,
+ void* user_data);
/** Sets the value of the address at index \a index of \a addresses from \a uri.
* Returns true upon success, false otherwise. Takes ownership of \a
* balancer_name. */
-bool grpc_lb_addresses_set_address_from_uri(grpc_lb_addresses *addresses,
- size_t index, const grpc_uri *uri,
+bool grpc_lb_addresses_set_address_from_uri(grpc_lb_addresses* addresses,
+ size_t index, const grpc_uri* uri,
bool is_balancer,
- const char *balancer_name,
- void *user_data);
+ const char* balancer_name,
+ void* user_data);
/** Compares \a addresses1 and \a addresses2. */
-int grpc_lb_addresses_cmp(const grpc_lb_addresses *addresses1,
- const grpc_lb_addresses *addresses2);
+int grpc_lb_addresses_cmp(const grpc_lb_addresses* addresses1,
+ const grpc_lb_addresses* addresses2);
/** Destroys \a addresses. */
-void grpc_lb_addresses_destroy(grpc_exec_ctx *exec_ctx,
- grpc_lb_addresses *addresses);
+void grpc_lb_addresses_destroy(grpc_lb_addresses* addresses);
/** Returns a channel arg containing \a addresses. */
grpc_arg grpc_lb_addresses_create_channel_arg(
- const grpc_lb_addresses *addresses);
+ const grpc_lb_addresses* addresses);
/** Returns the \a grpc_lb_addresses instance in \a channel_args or NULL */
-grpc_lb_addresses *grpc_lb_addresses_find_channel_arg(
- const grpc_channel_args *channel_args);
+grpc_lb_addresses* grpc_lb_addresses_find_channel_arg(
+ const grpc_channel_args* channel_args);
/** Arguments passed to LB policies. */
struct grpc_lb_policy_args {
- grpc_client_channel_factory *client_channel_factory;
- grpc_channel_args *args;
- grpc_combiner *combiner;
+ grpc_client_channel_factory* client_channel_factory;
+ grpc_channel_args* args;
+ grpc_combiner* combiner;
};
struct grpc_lb_policy_factory_vtable {
- void (*ref)(grpc_lb_policy_factory *factory);
- void (*unref)(grpc_lb_policy_factory *factory);
+ void (*ref)(grpc_lb_policy_factory* factory);
+ void (*unref)(grpc_lb_policy_factory* factory);
/** Implementation of grpc_lb_policy_factory_create_lb_policy */
- grpc_lb_policy *(*create_lb_policy)(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy_factory *factory,
- grpc_lb_policy_args *args);
+ grpc_lb_policy* (*create_lb_policy)(grpc_lb_policy_factory* factory,
+ grpc_lb_policy_args* args);
/** Name for the LB policy this factory implements */
- const char *name;
+ const char* name;
};
-void grpc_lb_policy_factory_ref(grpc_lb_policy_factory *factory);
-void grpc_lb_policy_factory_unref(grpc_lb_policy_factory *factory);
+void grpc_lb_policy_factory_ref(grpc_lb_policy_factory* factory);
+void grpc_lb_policy_factory_unref(grpc_lb_policy_factory* factory);
/** Create a lb_policy instance. */
-grpc_lb_policy *grpc_lb_policy_factory_create_lb_policy(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy_factory *factory,
- grpc_lb_policy_args *args);
+grpc_lb_policy* grpc_lb_policy_factory_create_lb_policy(
+ grpc_lb_policy_factory* factory, grpc_lb_policy_args* args);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.c b/src/core/ext/filters/client_channel/lb_policy_registry.cc
index f2460f8304..8414504e8f 100644
--- a/src/core/ext/filters/client_channel/lb_policy_registry.c
+++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc
@@ -20,11 +20,11 @@
#include <string.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#define MAX_POLICIES 10
-static grpc_lb_policy_factory *g_all_of_the_lb_policies[MAX_POLICIES];
+static grpc_lb_policy_factory* g_all_of_the_lb_policies[MAX_POLICIES];
static int g_number_of_lb_policies = 0;
void grpc_lb_policy_registry_init(void) { g_number_of_lb_policies = 0; }
@@ -36,7 +36,7 @@ void grpc_lb_policy_registry_shutdown(void) {
}
}
-void grpc_register_lb_policy(grpc_lb_policy_factory *factory) {
+void grpc_register_lb_policy(grpc_lb_policy_factory* factory) {
int i;
for (i = 0; i < g_number_of_lb_policies; i++) {
GPR_ASSERT(0 != gpr_stricmp(factory->vtable->name,
@@ -47,10 +47,10 @@ void grpc_register_lb_policy(grpc_lb_policy_factory *factory) {
g_all_of_the_lb_policies[g_number_of_lb_policies++] = factory;
}
-static grpc_lb_policy_factory *lookup_factory(const char *name) {
+static grpc_lb_policy_factory* lookup_factory(const char* name) {
int i;
- if (name == NULL) return NULL;
+ if (name == nullptr) return nullptr;
for (i = 0; i < g_number_of_lb_policies; i++) {
if (0 == gpr_stricmp(name, g_all_of_the_lb_policies[i]->vtable->name)) {
@@ -58,13 +58,13 @@ static grpc_lb_policy_factory *lookup_factory(const char *name) {
}
}
- return NULL;
+ return nullptr;
}
-grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name,
- grpc_lb_policy_args *args) {
- grpc_lb_policy_factory *factory = lookup_factory(name);
- grpc_lb_policy *lb_policy =
- grpc_lb_policy_factory_create_lb_policy(exec_ctx, factory, args);
+grpc_lb_policy* grpc_lb_policy_create(const char* name,
+ grpc_lb_policy_args* args) {
+ grpc_lb_policy_factory* factory = lookup_factory(name);
+ grpc_lb_policy* lb_policy =
+ grpc_lb_policy_factory_create_lb_policy(factory, args);
return lb_policy;
}
diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h
index f5995687cf..5aff79376b 100644
--- a/src/core/ext/filters/client_channel/lb_policy_registry.h
+++ b/src/core/ext/filters/client_channel/lb_policy_registry.h
@@ -28,13 +28,13 @@ void grpc_lb_policy_registry_init(void);
void grpc_lb_policy_registry_shutdown(void);
/** Register a LB policy factory. */
-void grpc_register_lb_policy(grpc_lb_policy_factory *factory);
+void grpc_register_lb_policy(grpc_lb_policy_factory* factory);
/** Create a \a grpc_lb_policy instance.
*
* If \a name is NULL, the default factory from \a grpc_lb_policy_registry_init
* will be returned. */
-grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name,
- grpc_lb_policy_args *args);
+grpc_lb_policy* grpc_lb_policy_create(const char* name,
+ grpc_lb_policy_args* args);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */
diff --git a/src/core/ext/filters/client_channel/parse_address.c b/src/core/ext/filters/client_channel/parse_address.cc
index 2152b5a1e9..c3309e36a3 100644
--- a/src/core/ext/filters/client_channel/parse_address.c
+++ b/src/core/ext/filters/client_channel/parse_address.cc
@@ -29,17 +29,17 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#ifdef GRPC_HAVE_UNIX_SOCKET
-bool grpc_parse_unix(const grpc_uri *uri,
- grpc_resolved_address *resolved_addr) {
+bool grpc_parse_unix(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
if (strcmp("unix", uri->scheme) != 0) {
gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'", uri->scheme);
return false;
}
- struct sockaddr_un *un = (struct sockaddr_un *)resolved_addr->addr;
+ struct sockaddr_un* un = (struct sockaddr_un*)resolved_addr->addr;
const size_t maxlen = sizeof(un->sun_path);
const size_t path_len = strnlen(uri->path, maxlen);
if (path_len == maxlen) return false;
@@ -51,31 +51,31 @@ bool grpc_parse_unix(const grpc_uri *uri,
#else /* GRPC_HAVE_UNIX_SOCKET */
-bool grpc_parse_unix(const grpc_uri *uri,
- grpc_resolved_address *resolved_addr) {
+bool grpc_parse_unix(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
abort();
}
#endif /* GRPC_HAVE_UNIX_SOCKET */
-bool grpc_parse_ipv4_hostport(const char *hostport, grpc_resolved_address *addr,
+bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors) {
bool success = false;
// Split host and port.
- char *host;
- char *port;
+ char* host;
+ char* port;
if (!gpr_split_host_port(hostport, &host, &port)) return false;
// Parse IP address.
memset(addr, 0, sizeof(*addr));
addr->len = sizeof(struct sockaddr_in);
- struct sockaddr_in *in = (struct sockaddr_in *)addr->addr;
+ struct sockaddr_in* in = (struct sockaddr_in*)addr->addr;
in->sin_family = AF_INET;
if (inet_pton(AF_INET, host, &in->sin_addr) == 0) {
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host);
goto done;
}
// Parse port.
- if (port == NULL) {
+ if (port == nullptr) {
if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
goto done;
}
@@ -92,33 +92,33 @@ done:
return success;
}
-bool grpc_parse_ipv4(const grpc_uri *uri,
- grpc_resolved_address *resolved_addr) {
+bool grpc_parse_ipv4(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
if (strcmp("ipv4", uri->scheme) != 0) {
gpr_log(GPR_ERROR, "Expected 'ipv4' scheme, got '%s'", uri->scheme);
return false;
}
- const char *host_port = uri->path;
+ const char* host_port = uri->path;
if (*host_port == '/') ++host_port;
return grpc_parse_ipv4_hostport(host_port, resolved_addr,
true /* log_errors */);
}
-bool grpc_parse_ipv6_hostport(const char *hostport, grpc_resolved_address *addr,
+bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors) {
bool success = false;
// Split host and port.
- char *host;
- char *port;
+ char* host;
+ char* port;
if (!gpr_split_host_port(hostport, &host, &port)) return false;
// Parse IP address.
memset(addr, 0, sizeof(*addr));
addr->len = sizeof(struct sockaddr_in6);
- struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr->addr;
+ struct sockaddr_in6* in6 = (struct sockaddr_in6*)addr->addr;
in6->sin6_family = AF_INET6;
// Handle the RFC6874 syntax for IPv6 zone identifiers.
- char *host_end = (char *)gpr_memrchr(host, '%', strlen(host));
- if (host_end != NULL) {
+ char* host_end = (char*)gpr_memrchr(host, '%', strlen(host));
+ if (host_end != nullptr) {
GPR_ASSERT(host_end >= host);
char host_without_scope[INET6_ADDRSTRLEN];
size_t host_without_scope_len = (size_t)(host_end - host);
@@ -144,7 +144,7 @@ bool grpc_parse_ipv6_hostport(const char *hostport, grpc_resolved_address *addr,
}
}
// Parse port.
- if (port == NULL) {
+ if (port == nullptr) {
if (log_errors) gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
goto done;
}
@@ -161,19 +161,19 @@ done:
return success;
}
-bool grpc_parse_ipv6(const grpc_uri *uri,
- grpc_resolved_address *resolved_addr) {
+bool grpc_parse_ipv6(const grpc_uri* uri,
+ grpc_resolved_address* resolved_addr) {
if (strcmp("ipv6", uri->scheme) != 0) {
gpr_log(GPR_ERROR, "Expected 'ipv6' scheme, got '%s'", uri->scheme);
return false;
}
- const char *host_port = uri->path;
+ const char* host_port = uri->path;
if (*host_port == '/') ++host_port;
return grpc_parse_ipv6_hostport(host_port, resolved_addr,
true /* log_errors */);
}
-bool grpc_parse_uri(const grpc_uri *uri, grpc_resolved_address *resolved_addr) {
+bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr) {
if (strcmp("unix", uri->scheme) == 0) {
return grpc_parse_unix(uri, resolved_addr);
} else if (strcmp("ipv4", uri->scheme) == 0) {
diff --git a/src/core/ext/filters/client_channel/parse_address.h b/src/core/ext/filters/client_channel/parse_address.h
index c90a827da5..ca0a0d18f0 100644
--- a/src/core/ext/filters/client_channel/parse_address.h
+++ b/src/core/ext/filters/client_channel/parse_address.h
@@ -26,23 +26,23 @@
/** Populate \a resolved_addr from \a uri, whose path is expected to contain a
* unix socket path. Returns true upon success. */
-bool grpc_parse_unix(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
+bool grpc_parse_unix(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
* IPv4 host:port pair. Returns true upon success. */
-bool grpc_parse_ipv4(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
+bool grpc_parse_ipv4(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
* IPv6 host:port pair. Returns true upon success. */
-bool grpc_parse_ipv6(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
+bool grpc_parse_ipv6(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
/** Populate \a resolved_addr from \a uri. Returns true upon success. */
-bool grpc_parse_uri(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
+bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr);
/** Parse bare IPv4 or IPv6 "IP:port" strings. */
-bool grpc_parse_ipv4_hostport(const char *hostport, grpc_resolved_address *addr,
+bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors);
-bool grpc_parse_ipv6_hostport(const char *hostport, grpc_resolved_address *addr,
+bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */
diff --git a/src/core/ext/filters/client_channel/proxy_mapper.c b/src/core/ext/filters/client_channel/proxy_mapper.cc
index c6ea5fc680..be85cfcced 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper.c
+++ b/src/core/ext/filters/client_channel/proxy_mapper.cc
@@ -23,24 +23,22 @@ void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
mapper->vtable = vtable;
}
-bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
- return mapper->vtable->map_name(exec_ctx, mapper, server_uri, args,
- name_to_resolve, new_args);
+ return mapper->vtable->map_name(mapper, server_uri, args, name_to_resolve,
+ new_args);
}
-bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_address(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
- return mapper->vtable->map_address(exec_ctx, mapper, address, args,
- new_address, new_args);
+ return mapper->vtable->map_address(mapper, address, args, new_address,
+ new_args);
}
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper) {
diff --git a/src/core/ext/filters/client_channel/proxy_mapper.h b/src/core/ext/filters/client_channel/proxy_mapper.h
index a13861ccaf..ce3e65ee46 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper.h
+++ b/src/core/ext/filters/client_channel/proxy_mapper.h
@@ -32,14 +32,14 @@ typedef struct {
/// If no proxy is needed, returns false.
/// Otherwise, sets \a name_to_resolve, optionally sets \a new_args,
/// and returns true.
- bool (*map_name)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
- const char* server_uri, const grpc_channel_args* args,
- char** name_to_resolve, grpc_channel_args** new_args);
+ bool (*map_name)(grpc_proxy_mapper* mapper, const char* server_uri,
+ const grpc_channel_args* args, char** name_to_resolve,
+ grpc_channel_args** new_args);
/// Determines the proxy address to use to contact \a address.
/// If no proxy is needed, returns false.
/// Otherwise, sets \a new_address, optionally sets \a new_args, and
/// returns true.
- bool (*map_address)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
+ bool (*map_address)(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
@@ -55,15 +55,13 @@ struct grpc_proxy_mapper {
void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
grpc_proxy_mapper* mapper);
-bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args);
-bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_address(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
diff --git a/src/core/ext/filters/client_channel/proxy_mapper_registry.c b/src/core/ext/filters/client_channel/proxy_mapper_registry.cc
index 09967eea3c..51778a20cc 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper_registry.c
+++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.cc
@@ -46,14 +46,13 @@ static void grpc_proxy_mapper_list_register(grpc_proxy_mapper_list* list,
++list->num_mappers;
}
-static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper_list* list,
+static bool grpc_proxy_mapper_list_map_name(grpc_proxy_mapper_list* list,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) {
- if (grpc_proxy_mapper_map_name(exec_ctx, list->list[i], server_uri, args,
+ if (grpc_proxy_mapper_map_name(list->list[i], server_uri, args,
name_to_resolve, new_args)) {
return true;
}
@@ -62,12 +61,12 @@ static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
}
static bool grpc_proxy_mapper_list_map_address(
- grpc_exec_ctx* exec_ctx, grpc_proxy_mapper_list* list,
- const grpc_resolved_address* address, const grpc_channel_args* args,
- grpc_resolved_address** new_address, grpc_channel_args** new_args) {
+ grpc_proxy_mapper_list* list, const grpc_resolved_address* address,
+ const grpc_channel_args* args, grpc_resolved_address** new_address,
+ grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) {
- if (grpc_proxy_mapper_map_address(exec_ctx, list->list[i], address, args,
- new_address, new_args)) {
+ if (grpc_proxy_mapper_map_address(list->list[i], address, args, new_address,
+ new_args)) {
return true;
}
}
@@ -105,20 +104,17 @@ void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper) {
grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper);
}
-bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
- const char* server_uri,
+bool grpc_proxy_mappers_map_name(const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
- return grpc_proxy_mapper_list_map_name(exec_ctx, &g_proxy_mapper_list,
- server_uri, args, name_to_resolve,
- new_args);
+ return grpc_proxy_mapper_list_map_name(&g_proxy_mapper_list, server_uri, args,
+ name_to_resolve, new_args);
}
-bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
- const grpc_resolved_address* address,
+bool grpc_proxy_mappers_map_address(const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
- return grpc_proxy_mapper_list_map_address(
- exec_ctx, &g_proxy_mapper_list, address, args, new_address, new_args);
+ return grpc_proxy_mapper_list_map_address(&g_proxy_mapper_list, address, args,
+ new_address, new_args);
}
diff --git a/src/core/ext/filters/client_channel/proxy_mapper_registry.h b/src/core/ext/filters/client_channel/proxy_mapper_registry.h
index 99e54d1a78..2ad6c04e1d 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper_registry.h
+++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.h
@@ -29,14 +29,12 @@ void grpc_proxy_mapper_registry_shutdown();
/// the list. Otherwise, it will be added to the end.
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper);
-bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
- const char* server_uri,
+bool grpc_proxy_mappers_map_name(const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args);
-bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
- const grpc_resolved_address* address,
+bool grpc_proxy_mappers_map_address(const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args);
diff --git a/src/core/ext/filters/client_channel/resolver.c b/src/core/ext/filters/client_channel/resolver.c
deleted file mode 100644
index 8401504fcf..0000000000
--- a/src/core/ext/filters/client_channel/resolver.c
+++ /dev/null
@@ -1,83 +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.h"
-#include "src/core/lib/iomgr/combiner.h"
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_resolver_refcount =
- GRPC_TRACER_INITIALIZER(false, "resolver_refcount");
-#endif
-
-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);
-}
-
-#ifndef NDEBUG
-void grpc_resolver_ref(grpc_resolver *resolver, const char *file, int line,
- const char *reason) {
- if (GRPC_TRACER_ON(grpc_trace_resolver_refcount)) {
- 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);
-}
-
-#ifndef NDEBUG
-void grpc_resolver_unref(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
- const char *file, int line, const char *reason) {
- if (GRPC_TRACER_ON(grpc_trace_resolver_refcount)) {
- 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_exec_ctx *exec_ctx, grpc_resolver *resolver) {
-#endif
- if (gpr_unref(&resolver->refs)) {
- grpc_combiner *combiner = resolver->combiner;
- resolver->vtable->destroy(exec_ctx, resolver);
- GRPC_COMBINER_UNREF(exec_ctx, combiner, "resolver");
- }
-}
-
-void grpc_resolver_shutdown_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- resolver->vtable->shutdown_locked(exec_ctx, resolver);
-}
-
-void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- resolver->vtable->channel_saw_error_locked(exec_ctx, resolver);
-}
-
-void grpc_resolver_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
- grpc_channel_args **result,
- grpc_closure *on_complete) {
- resolver->vtable->next_locked(exec_ctx, resolver, result, on_complete);
-}
diff --git a/src/core/ext/filters/client_channel/resolver.cc b/src/core/ext/filters/client_channel/resolver.cc
new file mode 100644
index 0000000000..ff54e7179d
--- /dev/null
+++ b/src/core/ext/filters/client_channel/resolver.cc
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.h"
+#include "src/core/lib/iomgr/combiner.h"
+
+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);
+}
+
+#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);
+}
+
+#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");
+ }
+}
+
+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);
+}
diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h
index ae9c8f66fe..f6a4af01d6 100644
--- a/src/core/ext/filters/client_channel/resolver.h
+++ b/src/core/ext/filters/client_channel/resolver.h
@@ -25,55 +25,50 @@
typedef struct grpc_resolver grpc_resolver;
typedef struct grpc_resolver_vtable grpc_resolver_vtable;
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_resolver_refcount;
-#endif
+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;
+ const grpc_resolver_vtable* vtable;
gpr_refcount refs;
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
};
struct grpc_resolver_vtable {
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
- void (*shutdown_locked)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
- void (*channel_saw_error_locked)(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver);
- void (*next_locked)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
- grpc_channel_args **result, grpc_closure *on_complete);
+ 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);
};
#ifndef NDEBUG
#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_RESOLVER_UNREF(e, p, r) \
- grpc_resolver_unref((e), (p), __FILE__, __LINE__, (r))
-void grpc_resolver_ref(grpc_resolver *policy, const char *file, int line,
- const char *reason);
-void grpc_resolver_unref(grpc_exec_ctx *exec_ctx, grpc_resolver *policy,
- const char *file, int line, const char *reason);
+#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(e, p, r) grpc_resolver_unref((e), (p))
-void grpc_resolver_ref(grpc_resolver *policy);
-void grpc_resolver_unref(grpc_exec_ctx *exec_ctx, grpc_resolver *policy);
+#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_init(grpc_resolver* resolver,
+ const grpc_resolver_vtable* vtable,
+ grpc_combiner* combiner);
-void grpc_resolver_shutdown_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver);
+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_exec_ctx *exec_ctx,
- grpc_resolver *resolver);
+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.
@@ -83,8 +78,8 @@ void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
Must be called from the combiner passed as a resolver_arg at construction
time.*/
-void grpc_resolver_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
- grpc_channel_args **result,
- grpc_closure *on_complete);
+void grpc_resolver_next_locked(grpc_resolver* resolver,
+ grpc_channel_args** result,
+ grpc_closure* on_complete);
#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.c b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
index 9bb229ad95..6ba5f932f0 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
@@ -32,18 +32,18 @@
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#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/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/gethostname.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/json/json.h"
-#include "src/core/lib/support/backoff.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/service_config.h"
-#define GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS 1
#define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
#define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
#define GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS 120
@@ -53,109 +53,102 @@ typedef struct {
/** base class: must be first */
grpc_resolver base;
/** DNS server to use (if not system default) */
- char *dns_server;
+ char* dns_server;
/** name to resolve (usually the same as target_name) */
- char *name_to_resolve;
+ char* name_to_resolve;
/** default port to use */
- char *default_port;
+ char* default_port;
/** channel args. */
- grpc_channel_args *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;
+ grpc_pollset_set* interested_parties;
/** Closures used by the combiner */
grpc_closure dns_ares_on_retry_timer_locked;
grpc_closure dns_ares_on_resolved_locked;
/** Combiner guarding the rest of the state */
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
/** are we currently resolving? */
bool resolving;
/** the pending resolving request */
- grpc_ares_request *pending_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;
+ grpc_closure* next_completion;
/** target result address for next completion */
- grpc_channel_args **target_result;
+ grpc_channel_args** target_result;
/** current (fully resolved) result */
- grpc_channel_args *resolved_result;
+ grpc_channel_args* resolved_result;
/** retry timer */
bool have_retry_timer;
grpc_timer retry_timer;
/** retry backoff state */
- gpr_backoff backoff_state;
+ grpc_core::ManualConstructor<grpc_core::BackOff> backoff;
/** currently resolving addresses */
- grpc_lb_addresses *lb_addresses;
+ grpc_lb_addresses* lb_addresses;
/** currently resolving service config */
- char *service_config_json;
+ char* service_config_json;
} ares_dns_resolver;
-static void dns_ares_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
+static void dns_ares_destroy(grpc_resolver* r);
-static void dns_ares_start_resolving_locked(grpc_exec_ctx *exec_ctx,
- ares_dns_resolver *r);
-static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
- ares_dns_resolver *r);
+static void dns_ares_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_exec_ctx *exec_ctx, grpc_resolver *r);
-static void dns_ares_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *r);
-static void dns_ares_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r,
- grpc_channel_args **target_result,
- grpc_closure *on_complete);
+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_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- ares_dns_resolver *r = (ares_dns_resolver *)resolver;
+static void dns_ares_shutdown_locked(grpc_resolver* resolver) {
+ ares_dns_resolver* r = (ares_dns_resolver*)resolver;
if (r->have_retry_timer) {
- grpc_timer_cancel(exec_ctx, &r->retry_timer);
+ grpc_timer_cancel(&r->retry_timer);
}
- if (r->pending_request != NULL) {
- grpc_cancel_ares_request(exec_ctx, r->pending_request);
+ if (r->pending_request != nullptr) {
+ grpc_cancel_ares_request(r->pending_request);
}
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->next_completion,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+ 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;
}
}
-static void dns_ares_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- ares_dns_resolver *r = (ares_dns_resolver *)resolver;
+static void dns_ares_channel_saw_error_locked(grpc_resolver* resolver) {
+ ares_dns_resolver* r = (ares_dns_resolver*)resolver;
if (!r->resolving) {
- gpr_backoff_reset(&r->backoff_state);
- dns_ares_start_resolving_locked(exec_ctx, r);
+ r->backoff->Reset();
+ dns_ares_start_resolving_locked(r);
}
}
-static void dns_ares_on_retry_timer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- ares_dns_resolver *r = (ares_dns_resolver *)arg;
+static void dns_ares_on_retry_timer_locked(void* arg, grpc_error* error) {
+ ares_dns_resolver* r = (ares_dns_resolver*)arg;
r->have_retry_timer = false;
if (error == GRPC_ERROR_NONE) {
if (!r->resolving) {
- dns_ares_start_resolving_locked(exec_ctx, r);
+ dns_ares_start_resolving_locked(r);
}
}
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "retry-timer");
+ GRPC_RESOLVER_UNREF(&r->base, "retry-timer");
}
-static bool value_in_json_array(grpc_json *array, const char *value) {
- for (grpc_json *entry = array->child; entry != NULL; entry = entry->next) {
+static bool value_in_json_array(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;
}
@@ -163,49 +156,50 @@ static bool value_in_json_array(grpc_json *array, const char *value) {
return false;
}
-static char *choose_service_config(char *service_config_choice_json) {
- grpc_json *choices_json = grpc_json_parse_string(service_config_choice_json);
- if (choices_json == NULL || choices_json->type != GRPC_JSON_ARRAY) {
+static char* choose_service_config(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");
- return NULL;
+ return nullptr;
}
- char *service_config = NULL;
- for (grpc_json *choice = choices_json->child; choice != NULL;
+ char* service_config = nullptr;
+ for (grpc_json* choice = choices_json->child; choice != nullptr;
choice = choice->next) {
if (choice->type != GRPC_JSON_OBJECT) {
gpr_log(GPR_ERROR, "cannot parse service config JSON string");
break;
}
- grpc_json *service_config_json = NULL;
- for (grpc_json *field = choice->child; field != NULL; field = field->next) {
+ grpc_json* service_config_json = nullptr;
+ for (grpc_json* field = choice->child; field != nullptr;
+ 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++")) {
- service_config_json = NULL;
+ service_config_json = nullptr;
break;
}
}
// Check client hostname, if specified.
if (strcmp(field->key, "clientHostname") == 0) {
- char *hostname = grpc_gethostname();
- if (hostname == NULL || field->type != GRPC_JSON_ARRAY ||
+ char* hostname = grpc_gethostname();
+ if (hostname == nullptr || field->type != GRPC_JSON_ARRAY ||
!value_in_json_array(field, hostname)) {
- service_config_json = NULL;
+ service_config_json = nullptr;
break;
}
}
// Check percentage, if specified.
if (strcmp(field->key, "percentage") == 0) {
if (field->type != GRPC_JSON_NUMBER) {
- service_config_json = NULL;
+ service_config_json = nullptr;
break;
}
int random_pct = rand() % 100;
int percentage;
if (sscanf(field->value, "%d", &percentage) != 1 ||
random_pct > percentage || percentage == 0) {
- service_config_json = NULL;
+ service_config_json = nullptr;
break;
}
}
@@ -216,7 +210,7 @@ static char *choose_service_config(char *service_config_choice_json) {
}
}
}
- if (service_config_json != NULL) {
+ if (service_config_json != nullptr) {
service_config = grpc_json_dump_to_string(service_config_json, 0);
break;
}
@@ -225,39 +219,38 @@ static char *choose_service_config(char *service_config_choice_json) {
return service_config;
}
-static void dns_ares_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- ares_dns_resolver *r = (ares_dns_resolver *)arg;
- grpc_channel_args *result = NULL;
+static void dns_ares_on_resolved_locked(void* arg, grpc_error* error) {
+ ares_dns_resolver* r = (ares_dns_resolver*)arg;
+ grpc_channel_args* result = nullptr;
GPR_ASSERT(r->resolving);
r->resolving = false;
- r->pending_request = NULL;
- if (r->lb_addresses != NULL) {
- static const char *args_to_remove[2];
+ 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_service_config *service_config = NULL;
- char *service_config_string = NULL;
- if (r->service_config_json != NULL) {
+ 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 (service_config_string != NULL) {
+ if (service_config_string != nullptr) {
gpr_log(GPR_INFO, "selected service config choice: %s",
service_config_string);
args_to_remove[num_args_to_remove++] = GRPC_ARG_SERVICE_CONFIG;
new_args[num_args_to_add++] = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_SERVICE_CONFIG, service_config_string);
+ (char*)GRPC_ARG_SERVICE_CONFIG, service_config_string);
service_config = grpc_service_config_create(service_config_string);
- if (service_config != NULL) {
- const char *lb_policy_name =
+ if (service_config != nullptr) {
+ const char* lb_policy_name =
grpc_service_config_get_lb_policy_name(service_config);
- if (lb_policy_name != NULL) {
+ if (lb_policy_name != nullptr) {
args_to_remove[num_args_to_remove++] = GRPC_ARG_LB_POLICY_NAME;
new_args[num_args_to_add++] = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_LB_POLICY_NAME, (char *)lb_policy_name);
+ (char*)GRPC_ARG_LB_POLICY_NAME, (char*)lb_policy_name);
}
}
}
@@ -265,106 +258,100 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
result = grpc_channel_args_copy_and_add_and_remove(
r->channel_args, args_to_remove, num_args_to_remove, new_args,
num_args_to_add);
- if (service_config != NULL) grpc_service_config_destroy(service_config);
+ if (service_config != nullptr) grpc_service_config_destroy(service_config);
gpr_free(service_config_string);
- grpc_lb_addresses_destroy(exec_ctx, r->lb_addresses);
+ grpc_lb_addresses_destroy(r->lb_addresses);
} else {
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg);
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
- gpr_timespec timeout = gpr_time_sub(next_try, now);
+ grpc_millis next_try = r->backoff->NextAttemptTime();
+ grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true;
GRPC_RESOLVER_REF(&r->base, "retry-timer");
- if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
- gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec,
- timeout.tv_nsec);
+ if (timeout > 0) {
+ gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout);
} else {
gpr_log(GPR_DEBUG, "retrying immediately");
}
- grpc_timer_init(exec_ctx, &r->retry_timer, next_try,
- &r->dns_ares_on_retry_timer_locked, now);
+ grpc_timer_init(&r->retry_timer, next_try,
+ &r->dns_ares_on_retry_timer_locked);
}
- if (r->resolved_result != NULL) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
+ if (r->resolved_result != nullptr) {
+ grpc_channel_args_destroy(r->resolved_result);
}
r->resolved_result = result;
r->resolved_version++;
- dns_ares_maybe_finish_next_locked(exec_ctx, r);
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving");
+ dns_ares_maybe_finish_next_locked(r);
+ GRPC_RESOLVER_UNREF(&r->base, "dns-resolving");
}
-static void dns_ares_next_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver,
- grpc_channel_args **target_result,
- grpc_closure *on_complete) {
+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;
+ 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) {
- gpr_backoff_reset(&r->backoff_state);
- dns_ares_start_resolving_locked(exec_ctx, r);
+ r->backoff->Reset();
+ dns_ares_start_resolving_locked(r);
} else {
- dns_ares_maybe_finish_next_locked(exec_ctx, r);
+ dns_ares_maybe_finish_next_locked(r);
}
}
-static void dns_ares_start_resolving_locked(grpc_exec_ctx *exec_ctx,
- ares_dns_resolver *r) {
+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 = NULL;
- r->service_config_json = NULL;
+ r->lb_addresses = nullptr;
+ r->service_config_json = nullptr;
r->pending_request = grpc_dns_lookup_ares(
- exec_ctx, r->dns_server, r->name_to_resolve, r->default_port,
- r->interested_parties, &r->dns_ares_on_resolved_locked, &r->lb_addresses,
+ r->dns_server, r->name_to_resolve, r->default_port, r->interested_parties,
+ &r->dns_ares_on_resolved_locked, &r->lb_addresses,
true /* check_grpclb */,
- r->request_service_config ? &r->service_config_json : NULL);
+ r->request_service_config ? &r->service_config_json : nullptr);
}
-static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
- ares_dns_resolver *r) {
- if (r->next_completion != NULL &&
+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 == NULL
- ? NULL
+ *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(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
- r->next_completion = NULL;
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
+ r->next_completion = nullptr;
r->published_version = r->resolved_version;
}
}
-static void dns_ares_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
+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 != NULL) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
+ ares_dns_resolver* r = (ares_dns_resolver*)gr;
+ if (r->resolved_result != nullptr) {
+ grpc_channel_args_destroy(r->resolved_result);
}
- grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
+ 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(exec_ctx, r->channel_args);
+ grpc_channel_args_destroy(r->channel_args);
gpr_free(r);
}
-static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx,
- grpc_resolver_args *args,
- const char *default_port) {
+static grpc_resolver* dns_ares_create(grpc_resolver_args* args,
+ const char* default_port) {
/* Get name from args. */
- const char *path = args->uri->path;
+ 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));
+ 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);
@@ -372,20 +359,21 @@ static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx,
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(
+ 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 != NULL) {
- grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
- args->pollset_set);
+ if (args->pollset_set != nullptr) {
+ grpc_pollset_set_add_pollset_set(r->interested_parties, args->pollset_set);
}
- gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
- GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
- GRPC_DNS_RECONNECT_JITTER,
- GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
- GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
+ 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_retry_timer_locked,
dns_ares_on_retry_timer_locked, r,
grpc_combiner_scheduler(r->base.combiner));
@@ -399,19 +387,18 @@ static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx,
* FACTORY
*/
-static void dns_ares_factory_ref(grpc_resolver_factory *factory) {}
+static void dns_ares_factory_ref(grpc_resolver_factory* factory) {}
-static void dns_ares_factory_unref(grpc_resolver_factory *factory) {}
+static void dns_ares_factory_unref(grpc_resolver_factory* factory) {}
-static grpc_resolver *dns_factory_create_resolver(
- grpc_exec_ctx *exec_ctx, grpc_resolver_factory *factory,
- grpc_resolver_args *args) {
- return dns_ares_create(exec_ctx, args, "https");
+static grpc_resolver* dns_factory_create_resolver(
+ grpc_resolver_factory* factory, grpc_resolver_args* args) {
+ return dns_ares_create(args, "https");
}
-static char *dns_ares_factory_get_default_host_name(
- grpc_resolver_factory *factory, grpc_uri *uri) {
- const char *path = uri->path;
+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);
}
@@ -421,16 +408,16 @@ static const grpc_resolver_factory_vtable dns_ares_factory_vtable = {
dns_ares_factory_get_default_host_name, "dns"};
static grpc_resolver_factory dns_resolver_factory = {&dns_ares_factory_vtable};
-static grpc_resolver_factory *dns_ares_resolver_factory_create() {
+static grpc_resolver_factory* dns_ares_resolver_factory_create() {
return &dns_resolver_factory;
}
void grpc_resolver_dns_ares_init(void) {
- char *resolver = gpr_getenv("GRPC_DNS_RESOLVER");
+ char* resolver = 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 != NULL && gpr_stricmp(resolver, "ares") == 0) {
- grpc_error *error = grpc_ares_init();
+ if (resolver != nullptr && gpr_stricmp(resolver, "ares") == 0) {
+ grpc_error* error = grpc_ares_init();
if (error != GRPC_ERROR_NONE) {
GRPC_LOG_IF_ERROR("ares_library_init() failed", error);
return;
@@ -442,8 +429,8 @@ void grpc_resolver_dns_ares_init(void) {
}
void grpc_resolver_dns_ares_shutdown(void) {
- char *resolver = gpr_getenv("GRPC_DNS_RESOLVER");
- if (resolver != NULL && gpr_stricmp(resolver, "ares") == 0) {
+ char* resolver = gpr_getenv("GRPC_DNS_RESOLVER");
+ if (resolver != nullptr && gpr_stricmp(resolver, "ares") == 0) {
grpc_ares_cleanup();
}
gpr_free(resolver);
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h
index 386012d2ed..ba7dad63cf 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h
@@ -19,6 +19,7 @@
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
+#include <ares.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/pollset_set.h"
@@ -27,27 +28,25 @@ typedef struct grpc_ares_ev_driver grpc_ares_ev_driver;
/* Start \a ev_driver. It will keep working until all IO on its ares_channel is
done, or grpc_ares_ev_driver_destroy() is called. It may notify the callbacks
bound to its ares_channel when necessary. */
-void grpc_ares_ev_driver_start(grpc_exec_ctx *exec_ctx,
- grpc_ares_ev_driver *ev_driver);
+void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver);
/* Returns the ares_channel owned by \a ev_driver. To bind a c-ares query to
\a ev_driver, use the ares_channel owned by \a ev_driver as the arg of the
query. */
-ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver);
+ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver);
/* Creates a new grpc_ares_ev_driver. Returns GRPC_ERROR_NONE if \a ev_driver is
created successfully. */
-grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
- grpc_pollset_set *pollset_set);
+grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver,
+ grpc_pollset_set* pollset_set);
/* Destroys \a ev_driver asynchronously. Pending lookups made on \a ev_driver
will be cancelled and their on_done callbacks will be invoked with a status
of ARES_ECANCELLED. */
-void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver);
+void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver);
/* Shutdown all the grpc_fds used by \a ev_driver */
-void grpc_ares_ev_driver_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_ares_ev_driver *ev_driver);
+void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H \
- */
+ */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
index c30cc93b6f..2eb2a9b59d 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
@@ -30,14 +30,14 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#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"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/string.h"
typedef struct fd_node {
/** the owner of this fd node */
- grpc_ares_ev_driver *ev_driver;
+ grpc_ares_ev_driver* ev_driver;
/** a closure wrapping on_readable_cb, which should be invoked when the
grpc_fd in this node becomes readable. */
grpc_closure read_closure;
@@ -45,12 +45,12 @@ typedef struct fd_node {
grpc_fd in this node becomes writable. */
grpc_closure write_closure;
/** next fd node in the list */
- struct fd_node *next;
+ struct fd_node* next;
/** mutex guarding the rest of the state */
gpr_mu mu;
/** the grpc_fd owned by this fd node */
- grpc_fd *fd;
+ grpc_fd* fd;
/** if the readable closure has been registered */
bool readable_registered;
/** if the writable closure has been registered */
@@ -63,42 +63,41 @@ struct grpc_ares_ev_driver {
/** the ares_channel owned by this event driver */
ares_channel channel;
/** pollset set for driving the IO events of the channel */
- grpc_pollset_set *pollset_set;
+ grpc_pollset_set* pollset_set;
/** refcount of the event driver */
gpr_refcount refs;
/** mutex guarding the rest of the state */
gpr_mu mu;
/** a list of grpc_fd that this event driver is currently using. */
- fd_node *fds;
+ fd_node* fds;
/** is this event driver currently working? */
bool working;
/** is this event driver being shut down */
bool shutting_down;
};
-static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
- grpc_ares_ev_driver *ev_driver);
+static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver);
-static grpc_ares_ev_driver *grpc_ares_ev_driver_ref(
- grpc_ares_ev_driver *ev_driver) {
+static grpc_ares_ev_driver* grpc_ares_ev_driver_ref(
+ grpc_ares_ev_driver* ev_driver) {
gpr_log(GPR_DEBUG, "Ref ev_driver %" PRIuPTR, (uintptr_t)ev_driver);
gpr_ref(&ev_driver->refs);
return ev_driver;
}
-static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver *ev_driver) {
+static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) {
gpr_log(GPR_DEBUG, "Unref ev_driver %" PRIuPTR, (uintptr_t)ev_driver);
if (gpr_unref(&ev_driver->refs)) {
gpr_log(GPR_DEBUG, "destroy ev_driver %" PRIuPTR, (uintptr_t)ev_driver);
- GPR_ASSERT(ev_driver->fds == NULL);
+ GPR_ASSERT(ev_driver->fds == nullptr);
gpr_mu_destroy(&ev_driver->mu);
ares_destroy(ev_driver->channel);
gpr_free(ev_driver);
}
}
-static void fd_node_destroy(grpc_exec_ctx *exec_ctx, fd_node *fdn) {
+static void fd_node_destroy(fd_node* fdn) {
gpr_log(GPR_DEBUG, "delete fd: %d", grpc_fd_wrapped_fd(fdn->fd));
GPR_ASSERT(!fdn->readable_registered);
GPR_ASSERT(!fdn->writable_registered);
@@ -106,34 +105,34 @@ static void fd_node_destroy(grpc_exec_ctx *exec_ctx, fd_node *fdn) {
/* c-ares library has closed the fd inside grpc_fd. This fd may be picked up
immediately by another thread, and should not be closed by the following
grpc_fd_orphan. */
- grpc_fd_orphan(exec_ctx, fdn->fd, NULL, NULL, true /* already_closed */,
+ grpc_fd_orphan(fdn->fd, nullptr, nullptr, true /* already_closed */,
"c-ares query finished");
gpr_free(fdn);
}
-static void fd_node_shutdown(grpc_exec_ctx *exec_ctx, fd_node *fdn) {
+static void fd_node_shutdown(fd_node* fdn) {
gpr_mu_lock(&fdn->mu);
fdn->shutting_down = true;
if (!fdn->readable_registered && !fdn->writable_registered) {
gpr_mu_unlock(&fdn->mu);
- fd_node_destroy(exec_ctx, fdn);
+ fd_node_destroy(fdn);
} else {
- grpc_fd_shutdown(exec_ctx, fdn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "c-ares fd shutdown"));
+ grpc_fd_shutdown(
+ fdn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("c-ares fd shutdown"));
gpr_mu_unlock(&fdn->mu);
}
}
-grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
- grpc_pollset_set *pollset_set) {
- *ev_driver = (grpc_ares_ev_driver *)gpr_malloc(sizeof(grpc_ares_ev_driver));
+grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver,
+ grpc_pollset_set* pollset_set) {
+ *ev_driver = (grpc_ares_ev_driver*)gpr_malloc(sizeof(grpc_ares_ev_driver));
int status = ares_init(&(*ev_driver)->channel);
gpr_log(GPR_DEBUG, "grpc_ares_ev_driver_create");
if (status != ARES_SUCCESS) {
- char *err_msg;
+ char* err_msg;
gpr_asprintf(&err_msg, "Failed to init ares channel. C-ares error: %s",
ares_strerror(status));
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_msg);
gpr_free(err_msg);
gpr_free(*ev_driver);
return err;
@@ -141,13 +140,13 @@ grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
gpr_mu_init(&(*ev_driver)->mu);
gpr_ref_init(&(*ev_driver)->refs, 1);
(*ev_driver)->pollset_set = pollset_set;
- (*ev_driver)->fds = NULL;
+ (*ev_driver)->fds = nullptr;
(*ev_driver)->working = false;
(*ev_driver)->shutting_down = false;
return GRPC_ERROR_NONE;
}
-void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver) {
+void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver) {
// It's not safe to shut down remaining fds here directly, becauses
// ares_host_callback does not provide an exec_ctx. We mark the event driver
// as being shut down. If the event driver is working,
@@ -159,14 +158,13 @@ void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver) {
grpc_ares_ev_driver_unref(ev_driver);
}
-void grpc_ares_ev_driver_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_ares_ev_driver *ev_driver) {
+void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver) {
gpr_mu_lock(&ev_driver->mu);
ev_driver->shutting_down = true;
- fd_node *fn = ev_driver->fds;
- while (fn != NULL) {
- grpc_fd_shutdown(exec_ctx, fn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "grpc_ares_ev_driver_shutdown"));
+ fd_node* fn = ev_driver->fds;
+ while (fn != nullptr) {
+ grpc_fd_shutdown(fn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "grpc_ares_ev_driver_shutdown"));
fn = fn->next;
}
gpr_mu_unlock(&ev_driver->mu);
@@ -174,39 +172,38 @@ void grpc_ares_ev_driver_shutdown(grpc_exec_ctx *exec_ctx,
// Search fd in the fd_node list head. This is an O(n) search, the max possible
// value of n is ARES_GETSOCK_MAXNUM (16). n is typically 1 - 2 in our tests.
-static fd_node *pop_fd_node(fd_node **head, int fd) {
+static fd_node* pop_fd_node(fd_node** head, int fd) {
fd_node dummy_head;
dummy_head.next = *head;
- fd_node *node = &dummy_head;
- while (node->next != NULL) {
+ fd_node* node = &dummy_head;
+ while (node->next != nullptr) {
if (grpc_fd_wrapped_fd(node->next->fd) == fd) {
- fd_node *ret = node->next;
+ fd_node* ret = node->next;
node->next = node->next->next;
*head = dummy_head.next;
return ret;
}
node = node->next;
}
- return NULL;
+ return nullptr;
}
/* Check if \a fd is still readable */
-static bool grpc_ares_is_fd_still_readable(grpc_ares_ev_driver *ev_driver,
+static bool grpc_ares_is_fd_still_readable(grpc_ares_ev_driver* ev_driver,
int fd) {
size_t bytes_available = 0;
return ioctl(fd, FIONREAD, &bytes_available) == 0 && bytes_available > 0;
}
-static void on_readable_cb(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- fd_node *fdn = (fd_node *)arg;
- grpc_ares_ev_driver *ev_driver = fdn->ev_driver;
+static void on_readable_cb(void* arg, grpc_error* error) {
+ fd_node* fdn = (fd_node*)arg;
+ grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
gpr_mu_lock(&fdn->mu);
const int fd = grpc_fd_wrapped_fd(fdn->fd);
fdn->readable_registered = false;
if (fdn->shutting_down && !fdn->writable_registered) {
gpr_mu_unlock(&fdn->mu);
- fd_node_destroy(exec_ctx, fdn);
+ fd_node_destroy(fdn);
grpc_ares_ev_driver_unref(ev_driver);
return;
}
@@ -227,21 +224,20 @@ static void on_readable_cb(grpc_exec_ctx *exec_ctx, void *arg,
ares_cancel(ev_driver->channel);
}
gpr_mu_lock(&ev_driver->mu);
- grpc_ares_notify_on_event_locked(exec_ctx, ev_driver);
+ grpc_ares_notify_on_event_locked(ev_driver);
gpr_mu_unlock(&ev_driver->mu);
grpc_ares_ev_driver_unref(ev_driver);
}
-static void on_writable_cb(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- fd_node *fdn = (fd_node *)arg;
- grpc_ares_ev_driver *ev_driver = fdn->ev_driver;
+static void on_writable_cb(void* arg, grpc_error* error) {
+ fd_node* fdn = (fd_node*)arg;
+ grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
gpr_mu_lock(&fdn->mu);
const int fd = grpc_fd_wrapped_fd(fdn->fd);
fdn->writable_registered = false;
if (fdn->shutting_down && !fdn->readable_registered) {
gpr_mu_unlock(&fdn->mu);
- fd_node_destroy(exec_ctx, fdn);
+ fd_node_destroy(fdn);
grpc_ares_ev_driver_unref(ev_driver);
return;
}
@@ -260,20 +256,19 @@ static void on_writable_cb(grpc_exec_ctx *exec_ctx, void *arg,
ares_cancel(ev_driver->channel);
}
gpr_mu_lock(&ev_driver->mu);
- grpc_ares_notify_on_event_locked(exec_ctx, ev_driver);
+ grpc_ares_notify_on_event_locked(ev_driver);
gpr_mu_unlock(&ev_driver->mu);
grpc_ares_ev_driver_unref(ev_driver);
}
-ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver) {
+ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver) {
return &ev_driver->channel;
}
// Get the file descriptors used by the ev_driver's ares channel, register
// driver_closure with these filedescriptors.
-static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
- grpc_ares_ev_driver *ev_driver) {
- fd_node *new_list = NULL;
+static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
+ fd_node* new_list = nullptr;
if (!ev_driver->shutting_down) {
ares_socket_t socks[ARES_GETSOCK_MAXNUM];
int socks_bitmask =
@@ -281,12 +276,12 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
for (size_t i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
if (ARES_GETSOCK_READABLE(socks_bitmask, i) ||
ARES_GETSOCK_WRITABLE(socks_bitmask, i)) {
- fd_node *fdn = pop_fd_node(&ev_driver->fds, socks[i]);
+ fd_node* fdn = pop_fd_node(&ev_driver->fds, socks[i]);
// Create a new fd_node if sock[i] is not in the fd_node list.
- if (fdn == NULL) {
- char *fd_name;
+ if (fdn == nullptr) {
+ char* fd_name;
gpr_asprintf(&fd_name, "ares_ev_driver-%" PRIuPTR, i);
- fdn = (fd_node *)gpr_malloc(sizeof(fd_node));
+ fdn = (fd_node*)gpr_malloc(sizeof(fd_node));
gpr_log(GPR_DEBUG, "new fd: %d", socks[i]);
fdn->fd = grpc_fd_create(socks[i], fd_name);
fdn->ev_driver = ev_driver;
@@ -298,7 +293,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_cb, fdn,
grpc_schedule_on_exec_ctx);
- grpc_pollset_set_add_fd(exec_ctx, ev_driver->pollset_set, fdn->fd);
+ grpc_pollset_set_add_fd(ev_driver->pollset_set, fdn->fd);
gpr_free(fd_name);
}
fdn->next = new_list;
@@ -310,7 +305,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
!fdn->readable_registered) {
grpc_ares_ev_driver_ref(ev_driver);
gpr_log(GPR_DEBUG, "notify read on: %d", grpc_fd_wrapped_fd(fdn->fd));
- grpc_fd_notify_on_read(exec_ctx, fdn->fd, &fdn->read_closure);
+ grpc_fd_notify_on_read(fdn->fd, &fdn->read_closure);
fdn->readable_registered = true;
}
// Register write_closure if the socket is writable and write_closure
@@ -320,7 +315,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
gpr_log(GPR_DEBUG, "notify write on: %d",
grpc_fd_wrapped_fd(fdn->fd));
grpc_ares_ev_driver_ref(ev_driver);
- grpc_fd_notify_on_write(exec_ctx, fdn->fd, &fdn->write_closure);
+ grpc_fd_notify_on_write(fdn->fd, &fdn->write_closure);
fdn->writable_registered = true;
}
gpr_mu_unlock(&fdn->mu);
@@ -330,25 +325,24 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
// Any remaining fds in ev_driver->fds were not returned by ares_getsock() and
// are therefore no longer in use, so they can be shut down and removed from
// the list.
- while (ev_driver->fds != NULL) {
- fd_node *cur = ev_driver->fds;
+ while (ev_driver->fds != nullptr) {
+ fd_node* cur = ev_driver->fds;
ev_driver->fds = ev_driver->fds->next;
- fd_node_shutdown(exec_ctx, cur);
+ fd_node_shutdown(cur);
}
ev_driver->fds = new_list;
// If the ev driver has no working fd, all the tasks are done.
- if (new_list == NULL) {
+ if (new_list == nullptr) {
ev_driver->working = false;
gpr_log(GPR_DEBUG, "ev driver stop working");
}
}
-void grpc_ares_ev_driver_start(grpc_exec_ctx *exec_ctx,
- grpc_ares_ev_driver *ev_driver) {
+void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver) {
gpr_mu_lock(&ev_driver->mu);
if (!ev_driver->working) {
ev_driver->working = true;
- grpc_ares_notify_on_event_locked(exec_ctx, ev_driver);
+ grpc_ares_notify_on_event_locked(ev_driver);
}
gpr_mu_unlock(&ev_driver->mu);
}
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
index 04379975e1..2b35bdb605 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
@@ -36,12 +36,12 @@
#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/string.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/nameser.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/string.h"
static gpr_once g_basic_init = GPR_ONCE_INIT;
static gpr_mu g_init_mu;
@@ -51,13 +51,13 @@ struct grpc_ares_request {
struct ares_addr_port_node dns_server_addr;
/** following members are set in grpc_resolve_address_ares_impl */
/** closure to call when the request completes */
- grpc_closure *on_done;
+ grpc_closure* on_done;
/** the pointer to receive the resolved addresses */
- grpc_lb_addresses **lb_addrs_out;
+ grpc_lb_addresses** lb_addrs_out;
/** the pointer to receive the service config in JSON */
- char **service_config_json_out;
+ char** service_config_json_out;
/** the evernt driver used by this request */
- grpc_ares_ev_driver *ev_driver;
+ grpc_ares_ev_driver* ev_driver;
/** number of ongoing queries */
gpr_refcount pending_queries;
@@ -66,15 +66,15 @@ struct grpc_ares_request {
/** is there at least one successful query, set in on_done_cb */
bool success;
/** the errors explaining the request failure, set in on_done_cb */
- grpc_error *error;
+ grpc_error* error;
};
typedef struct grpc_ares_hostbyname_request {
/** following members are set in create_hostbyname_request */
/** the top-level request instance */
- grpc_ares_request *parent_request;
+ grpc_ares_request* parent_request;
/** host to resolve, parsed from the name to resolve */
- char *host;
+ char* host;
/** port to fill in sockaddr_in, parsed from the name to resolve */
uint16_t port;
/** is it a grpclb address */
@@ -83,7 +83,7 @@ typedef struct grpc_ares_hostbyname_request {
static void do_basic_init(void) { gpr_mu_init(&g_init_mu); }
-static uint16_t strhtons(const char *port) {
+static uint16_t strhtons(const char* port) {
if (strcmp(port, "http") == 0) {
return htons(80);
} else if (strcmp(port, "https") == 0) {
@@ -92,38 +92,26 @@ static uint16_t strhtons(const char *port) {
return htons((unsigned short)atoi(port));
}
-static void grpc_ares_request_ref(grpc_ares_request *r) {
+static void grpc_ares_request_ref(grpc_ares_request* r) {
gpr_ref(&r->pending_queries);
}
-static void grpc_ares_request_unref(grpc_exec_ctx *exec_ctx,
- grpc_ares_request *r) {
+static void grpc_ares_request_unref(grpc_ares_request* r) {
/* If there are no pending queries, invoke on_done callback and destroy the
request */
if (gpr_unref(&r->pending_queries)) {
/* TODO(zyc): Sort results with RFC6724 before invoking on_done. */
- if (exec_ctx == NULL) {
- /* A new exec_ctx is created here, as the c-ares interface does not
- provide one in ares_host_callback. It's safe to schedule on_done with
- the newly created exec_ctx, since the caller has been warned not to
- acquire locks in on_done. ares_dns_resolver is using combiner to
- protect resources needed by on_done. */
- grpc_exec_ctx new_exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_SCHED(&new_exec_ctx, r->on_done, r->error);
- grpc_exec_ctx_finish(&new_exec_ctx);
- } else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, r->error);
- }
+ GRPC_CLOSURE_SCHED(r->on_done, r->error);
gpr_mu_destroy(&r->mu);
grpc_ares_ev_driver_destroy(r->ev_driver);
gpr_free(r);
}
}
-static grpc_ares_hostbyname_request *create_hostbyname_request(
- grpc_ares_request *parent_request, char *host, uint16_t port,
+static grpc_ares_hostbyname_request* create_hostbyname_request(
+ grpc_ares_request* parent_request, char* host, uint16_t port,
bool is_balancer) {
- grpc_ares_hostbyname_request *hr = (grpc_ares_hostbyname_request *)gpr_zalloc(
+ grpc_ares_hostbyname_request* hr = (grpc_ares_hostbyname_request*)gpr_zalloc(
sizeof(grpc_ares_hostbyname_request));
hr->parent_request = parent_request;
hr->host = gpr_strdup(host);
@@ -133,32 +121,31 @@ static grpc_ares_hostbyname_request *create_hostbyname_request(
return hr;
}
-static void destroy_hostbyname_request(grpc_exec_ctx *exec_ctx,
- grpc_ares_hostbyname_request *hr) {
- grpc_ares_request_unref(exec_ctx, hr->parent_request);
+static void destroy_hostbyname_request(grpc_ares_hostbyname_request* hr) {
+ grpc_ares_request_unref(hr->parent_request);
gpr_free(hr->host);
gpr_free(hr);
}
-static void on_hostbyname_done_cb(void *arg, int status, int timeouts,
- struct hostent *hostent) {
- grpc_ares_hostbyname_request *hr = (grpc_ares_hostbyname_request *)arg;
- grpc_ares_request *r = hr->parent_request;
+static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
+ struct hostent* hostent) {
+ grpc_ares_hostbyname_request* hr = (grpc_ares_hostbyname_request*)arg;
+ grpc_ares_request* r = hr->parent_request;
gpr_mu_lock(&r->mu);
if (status == ARES_SUCCESS) {
GRPC_ERROR_UNREF(r->error);
r->error = GRPC_ERROR_NONE;
r->success = true;
- grpc_lb_addresses **lb_addresses = r->lb_addrs_out;
- if (*lb_addresses == NULL) {
- *lb_addresses = grpc_lb_addresses_create(0, NULL);
+ grpc_lb_addresses** lb_addresses = r->lb_addrs_out;
+ if (*lb_addresses == nullptr) {
+ *lb_addresses = grpc_lb_addresses_create(0, nullptr);
}
size_t prev_naddr = (*lb_addresses)->num_addresses;
size_t i;
- for (i = 0; hostent->h_addr_list[i] != NULL; i++) {
+ for (i = 0; hostent->h_addr_list[i] != nullptr; i++) {
}
(*lb_addresses)->num_addresses += i;
- (*lb_addresses)->addresses = (grpc_lb_address *)gpr_realloc(
+ (*lb_addresses)->addresses = (grpc_lb_address*)gpr_realloc(
(*lb_addresses)->addresses,
sizeof(grpc_lb_address) * (*lb_addresses)->num_addresses);
for (i = prev_naddr; i < (*lb_addresses)->num_addresses; i++) {
@@ -174,8 +161,8 @@ static void on_hostbyname_done_cb(void *arg, int status, int timeouts,
grpc_lb_addresses_set_address(
*lb_addresses, i, &addr, addr_len,
hr->is_balancer /* is_balancer */,
- hr->is_balancer ? hr->host : NULL /* balancer_name */,
- NULL /* user_data */);
+ hr->is_balancer ? hr->host : nullptr /* balancer_name */,
+ nullptr /* user_data */);
char output[INET6_ADDRSTRLEN];
ares_inet_ntop(AF_INET6, &addr.sin6_addr, output, INET6_ADDRSTRLEN);
gpr_log(GPR_DEBUG,
@@ -195,8 +182,8 @@ static void on_hostbyname_done_cb(void *arg, int status, int timeouts,
grpc_lb_addresses_set_address(
*lb_addresses, i, &addr, addr_len,
hr->is_balancer /* is_balancer */,
- hr->is_balancer ? hr->host : NULL /* balancer_name */,
- NULL /* user_data */);
+ hr->is_balancer ? hr->host : nullptr /* balancer_name */,
+ nullptr /* user_data */);
char output[INET_ADDRSTRLEN];
ares_inet_ntop(AF_INET, &addr.sin_addr, output, INET_ADDRSTRLEN);
gpr_log(GPR_DEBUG,
@@ -208,10 +195,10 @@ static void on_hostbyname_done_cb(void *arg, int status, int timeouts,
}
}
} else if (!r->success) {
- char *error_msg;
+ char* error_msg;
gpr_asprintf(&error_msg, "C-ares status is not ARES_SUCCESS: %s",
ares_strerror(status));
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
gpr_free(error_msg);
if (r->error == GRPC_ERROR_NONE) {
r->error = error;
@@ -220,43 +207,43 @@ static void on_hostbyname_done_cb(void *arg, int status, int timeouts,
}
}
gpr_mu_unlock(&r->mu);
- destroy_hostbyname_request(NULL, hr);
+ destroy_hostbyname_request(hr);
}
-static void on_srv_query_done_cb(void *arg, int status, int timeouts,
- unsigned char *abuf, int alen) {
- grpc_ares_request *r = (grpc_ares_request *)arg;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+static void on_srv_query_done_cb(void* arg, int status, int timeouts,
+ unsigned char* abuf, int alen) {
+ grpc_ares_request* r = (grpc_ares_request*)arg;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "on_query_srv_done_cb");
if (status == ARES_SUCCESS) {
gpr_log(GPR_DEBUG, "on_query_srv_done_cb ARES_SUCCESS");
- struct ares_srv_reply *reply;
+ struct ares_srv_reply* reply;
const int parse_status = ares_parse_srv_reply(abuf, alen, &reply);
if (parse_status == ARES_SUCCESS) {
- ares_channel *channel = grpc_ares_ev_driver_get_channel(r->ev_driver);
- for (struct ares_srv_reply *srv_it = reply; srv_it != NULL;
+ ares_channel* channel = grpc_ares_ev_driver_get_channel(r->ev_driver);
+ for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr;
srv_it = srv_it->next) {
if (grpc_ipv6_loopback_available()) {
- grpc_ares_hostbyname_request *hr = create_hostbyname_request(
+ grpc_ares_hostbyname_request* hr = create_hostbyname_request(
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET6,
on_hostbyname_done_cb, hr);
}
- grpc_ares_hostbyname_request *hr = create_hostbyname_request(
+ grpc_ares_hostbyname_request* hr = create_hostbyname_request(
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb,
hr);
- grpc_ares_ev_driver_start(&exec_ctx, r->ev_driver);
+ grpc_ares_ev_driver_start(r->ev_driver);
}
}
- if (reply != NULL) {
+ if (reply != nullptr) {
ares_free_data(reply);
}
} else if (!r->success) {
- char *error_msg;
+ char* error_msg;
gpr_asprintf(&error_msg, "C-ares status is not ARES_SUCCESS: %s",
ares_strerror(status));
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
gpr_free(error_msg);
if (r->error == GRPC_ERROR_NONE) {
r->error = error;
@@ -264,27 +251,26 @@ static void on_srv_query_done_cb(void *arg, int status, int timeouts,
r->error = grpc_error_add_child(error, r->error);
}
}
- grpc_ares_request_unref(&exec_ctx, r);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_ares_request_unref(r);
}
static const char g_service_config_attribute_prefix[] = "grpc_config=";
-static void on_txt_done_cb(void *arg, int status, int timeouts,
- unsigned char *buf, int len) {
+static void on_txt_done_cb(void* arg, int status, int timeouts,
+ unsigned char* buf, int len) {
gpr_log(GPR_DEBUG, "on_txt_done_cb");
- char *error_msg;
- grpc_ares_request *r = (grpc_ares_request *)arg;
+ char* error_msg;
+ grpc_ares_request* r = (grpc_ares_request*)arg;
const size_t prefix_len = sizeof(g_service_config_attribute_prefix) - 1;
- struct ares_txt_ext *result = NULL;
- struct ares_txt_ext *reply = NULL;
- grpc_error *error = GRPC_ERROR_NONE;
+ struct ares_txt_ext* result = nullptr;
+ struct ares_txt_ext* reply = nullptr;
+ grpc_error* error = GRPC_ERROR_NONE;
gpr_mu_lock(&r->mu);
if (status != ARES_SUCCESS) goto fail;
status = ares_parse_txt_reply_ext(buf, len, &reply);
if (status != ARES_SUCCESS) goto fail;
// Find service config in TXT record.
- for (result = reply; result != NULL; result = result->next) {
+ for (result = reply; result != nullptr; result = result->next) {
if (result->record_start &&
memcmp(result->txt, g_service_config_attribute_prefix, prefix_len) ==
0) {
@@ -292,14 +278,14 @@ static void on_txt_done_cb(void *arg, int status, int timeouts,
}
}
// Found a service config record.
- if (result != NULL) {
+ if (result != nullptr) {
size_t service_config_len = result->length - prefix_len;
- *r->service_config_json_out = (char *)gpr_malloc(service_config_len + 1);
+ *r->service_config_json_out = (char*)gpr_malloc(service_config_len + 1);
memcpy(*r->service_config_json_out, result->txt + prefix_len,
service_config_len);
- for (result = result->next; result != NULL && !result->record_start;
+ for (result = result->next; result != nullptr && !result->record_start;
result = result->next) {
- *r->service_config_json_out = (char *)gpr_realloc(
+ *r->service_config_json_out = (char*)gpr_realloc(
*r->service_config_json_out, service_config_len + result->length + 1);
memcpy(*r->service_config_json_out + service_config_len, result->txt,
result->length);
@@ -323,18 +309,17 @@ fail:
}
done:
gpr_mu_unlock(&r->mu);
- grpc_ares_request_unref(NULL, r);
+ grpc_ares_request_unref(r);
}
-static grpc_ares_request *grpc_dns_lookup_ares_impl(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addrs, bool check_grpclb,
- char **service_config_json) {
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_ares_hostbyname_request *hr = NULL;
- grpc_ares_request *r = NULL;
- ares_channel *channel = NULL;
+static grpc_ares_request* grpc_dns_lookup_ares_impl(
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_ares_hostbyname_request* hr = nullptr;
+ grpc_ares_request* r = nullptr;
+ ares_channel* channel = nullptr;
/* TODO(zyc): Enable tracing after #9603 is checked in */
/* if (grpc_dns_trace) {
gpr_log(GPR_DEBUG, "resolve_address (blocking): name=%s, default_port=%s",
@@ -342,16 +327,16 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
} */
/* parse name, splitting it into host and port parts */
- char *host;
- char *port;
+ char* host;
+ char* port;
gpr_split_host_port(name, &host, &port);
- if (host == NULL) {
+ if (host == nullptr) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
goto error_cleanup;
- } else if (port == NULL) {
- if (default_port == NULL) {
+ } else if (port == nullptr) {
+ if (default_port == nullptr) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
@@ -360,11 +345,11 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
port = gpr_strdup(default_port);
}
- grpc_ares_ev_driver *ev_driver;
+ grpc_ares_ev_driver* ev_driver;
error = grpc_ares_ev_driver_create(&ev_driver, interested_parties);
if (error != GRPC_ERROR_NONE) goto error_cleanup;
- r = (grpc_ares_request *)gpr_zalloc(sizeof(grpc_ares_request));
+ r = (grpc_ares_request*)gpr_zalloc(sizeof(grpc_ares_request));
gpr_mu_init(&r->mu);
r->ev_driver = ev_driver;
r->on_done = on_done;
@@ -375,12 +360,12 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
channel = grpc_ares_ev_driver_get_channel(r->ev_driver);
// If dns_server is specified, use it.
- if (dns_server != NULL) {
+ if (dns_server != nullptr) {
gpr_log(GPR_INFO, "Using DNS server %s", dns_server);
grpc_resolved_address addr;
if (grpc_parse_ipv4_hostport(dns_server, &addr, false /* log_errors */)) {
r->dns_server_addr.family = AF_INET;
- struct sockaddr_in *in = (struct sockaddr_in *)addr.addr;
+ struct sockaddr_in* in = (struct sockaddr_in*)addr.addr;
memcpy(&r->dns_server_addr.addr.addr4, &in->sin_addr,
sizeof(struct in_addr));
r->dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr);
@@ -388,7 +373,7 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
} else if (grpc_parse_ipv6_hostport(dns_server, &addr,
false /* log_errors */)) {
r->dns_server_addr.family = AF_INET6;
- struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr.addr;
+ struct sockaddr_in6* in6 = (struct sockaddr_in6*)addr.addr;
memcpy(&r->dns_server_addr.addr.addr6, &in6->sin6_addr,
sizeof(struct in6_addr));
r->dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr);
@@ -402,7 +387,7 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
}
int status = ares_set_servers_ports(*channel, &r->dns_server_addr);
if (status != ARES_SUCCESS) {
- char *error_msg;
+ char* error_msg;
gpr_asprintf(&error_msg, "C-ares status is not ARES_SUCCESS: %s",
ares_strerror(status));
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
@@ -423,53 +408,56 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
if (check_grpclb) {
/* Query the SRV record */
grpc_ares_request_ref(r);
- char *service_name;
+ char* service_name;
gpr_asprintf(&service_name, "_grpclb._tcp.%s", host);
ares_query(*channel, service_name, ns_c_in, ns_t_srv, on_srv_query_done_cb,
r);
gpr_free(service_name);
}
- if (service_config_json != NULL) {
+ if (service_config_json != nullptr) {
grpc_ares_request_ref(r);
- ares_search(*channel, hr->host, ns_c_in, ns_t_txt, on_txt_done_cb, r);
+ char* config_name;
+ gpr_asprintf(&config_name, "_grpc_config.%s", host);
+ ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_cb, r);
+ gpr_free(config_name);
}
/* TODO(zyc): Handle CNAME records here. */
- grpc_ares_ev_driver_start(exec_ctx, r->ev_driver);
- grpc_ares_request_unref(exec_ctx, r);
+ grpc_ares_ev_driver_start(r->ev_driver);
+ grpc_ares_request_unref(r);
gpr_free(host);
gpr_free(port);
return r;
error_cleanup:
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
gpr_free(host);
gpr_free(port);
- return NULL;
+ return nullptr;
}
-grpc_ares_request *(*grpc_dns_lookup_ares)(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addrs, bool check_grpclb,
- char **service_config_json) = grpc_dns_lookup_ares_impl;
+grpc_ares_request* (*grpc_dns_lookup_ares)(
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb,
+ char** service_config_json) = grpc_dns_lookup_ares_impl;
-void grpc_cancel_ares_request(grpc_exec_ctx *exec_ctx, grpc_ares_request *r) {
+void grpc_cancel_ares_request(grpc_ares_request* r) {
if (grpc_dns_lookup_ares == grpc_dns_lookup_ares_impl) {
- grpc_ares_ev_driver_shutdown(exec_ctx, r->ev_driver);
+ grpc_ares_ev_driver_shutdown(r->ev_driver);
}
}
-grpc_error *grpc_ares_init(void) {
+grpc_error* grpc_ares_init(void) {
gpr_once_init(&g_basic_init, do_basic_init);
gpr_mu_lock(&g_init_mu);
int status = ares_library_init(ARES_LIB_INIT_ALL);
gpr_mu_unlock(&g_init_mu);
if (status != ARES_SUCCESS) {
- char *error_msg;
+ char* error_msg;
gpr_asprintf(&error_msg, "ares_library_init failed: %s",
ares_strerror(status));
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
gpr_free(error_msg);
return error;
}
@@ -488,28 +476,27 @@ void grpc_ares_cleanup(void) {
typedef struct grpc_resolve_address_ares_request {
/** the pointer to receive the resolved addresses */
- grpc_resolved_addresses **addrs_out;
+ grpc_resolved_addresses** addrs_out;
/** currently resolving lb addresses */
- grpc_lb_addresses *lb_addrs;
+ grpc_lb_addresses* lb_addrs;
/** closure to call when the resolve_address_ares request completes */
- grpc_closure *on_resolve_address_done;
+ grpc_closure* on_resolve_address_done;
/** a closure wrapping on_dns_lookup_done_cb, which should be invoked when the
grpc_dns_lookup_ares operation is done. */
grpc_closure on_dns_lookup_done;
} grpc_resolve_address_ares_request;
-static void on_dns_lookup_done_cb(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_resolve_address_ares_request *r =
- (grpc_resolve_address_ares_request *)arg;
- grpc_resolved_addresses **resolved_addresses = r->addrs_out;
- if (r->lb_addrs == NULL || r->lb_addrs->num_addresses == 0) {
- *resolved_addresses = NULL;
+static void on_dns_lookup_done_cb(void* arg, grpc_error* error) {
+ grpc_resolve_address_ares_request* r =
+ (grpc_resolve_address_ares_request*)arg;
+ grpc_resolved_addresses** resolved_addresses = r->addrs_out;
+ if (r->lb_addrs == nullptr || r->lb_addrs->num_addresses == 0) {
+ *resolved_addresses = nullptr;
} else {
*resolved_addresses =
- (grpc_resolved_addresses *)gpr_zalloc(sizeof(grpc_resolved_addresses));
+ (grpc_resolved_addresses*)gpr_zalloc(sizeof(grpc_resolved_addresses));
(*resolved_addresses)->naddrs = r->lb_addrs->num_addresses;
- (*resolved_addresses)->addrs = (grpc_resolved_address *)gpr_zalloc(
+ (*resolved_addresses)->addrs = (grpc_resolved_address*)gpr_zalloc(
sizeof(grpc_resolved_address) * (*resolved_addresses)->naddrs);
for (size_t i = 0; i < (*resolved_addresses)->naddrs; i++) {
GPR_ASSERT(!r->lb_addrs->addresses[i].is_balancer);
@@ -517,34 +504,32 @@ static void on_dns_lookup_done_cb(grpc_exec_ctx *exec_ctx, void *arg,
&r->lb_addrs->addresses[i].address, sizeof(grpc_resolved_address));
}
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_resolve_address_done,
- GRPC_ERROR_REF(error));
- grpc_lb_addresses_destroy(exec_ctx, r->lb_addrs);
+ GRPC_CLOSURE_SCHED(r->on_resolve_address_done, GRPC_ERROR_REF(error));
+ grpc_lb_addresses_destroy(r->lb_addrs);
gpr_free(r);
}
-static void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx,
- const char *name,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {
- grpc_resolve_address_ares_request *r =
- (grpc_resolve_address_ares_request *)gpr_zalloc(
+static void grpc_resolve_address_ares_impl(const char* name,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) {
+ grpc_resolve_address_ares_request* r =
+ (grpc_resolve_address_ares_request*)gpr_zalloc(
sizeof(grpc_resolve_address_ares_request));
r->addrs_out = addrs;
r->on_resolve_address_done = on_done;
GRPC_CLOSURE_INIT(&r->on_dns_lookup_done, on_dns_lookup_done_cb, r,
grpc_schedule_on_exec_ctx);
- grpc_dns_lookup_ares(exec_ctx, NULL /* dns_server */, name, default_port,
+ grpc_dns_lookup_ares(nullptr /* dns_server */, name, default_port,
interested_parties, &r->on_dns_lookup_done, &r->lb_addrs,
false /* check_grpclb */,
- NULL /* service_config_json */);
+ nullptr /* service_config_json */);
}
void (*grpc_resolve_address_ares)(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
- grpc_pollset_set *interested_parties, grpc_closure *on_done,
- grpc_resolved_addresses **addrs) = grpc_resolve_address_ares_impl;
+ const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) = grpc_resolve_address_ares_impl;
#endif /* GRPC_ARES == 1 && !defined(GRPC_UV) */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
index 108333047d..86d870e0a6 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
@@ -32,12 +32,11 @@ typedef struct grpc_ares_request grpc_ares_request;
must be called at least once before this function. \a on_done may be
called directly in this function without being scheduled with \a exec_ctx,
so it must not try to acquire locks that are being held by the caller. */
-extern void (*grpc_resolve_address_ares)(grpc_exec_ctx *exec_ctx,
- const char *name,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addresses);
+extern void (*grpc_resolve_address_ares)(const char* name,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addresses);
/* Asynchronously resolve \a name. It will try to resolve grpclb SRV records in
addition to the normal address records. For normal address records, it uses
@@ -46,19 +45,18 @@ extern void (*grpc_resolve_address_ares)(grpc_exec_ctx *exec_ctx,
function. \a on_done may be called directly in this function without being
scheduled with \a exec_ctx, so it must not try to acquire locks that are
being held by the caller. */
-extern grpc_ares_request *(*grpc_dns_lookup_ares)(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addresses, bool check_grpclb,
- char **service_config_json);
+extern grpc_ares_request* (*grpc_dns_lookup_ares)(
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addresses, bool check_grpclb,
+ char** service_config_json);
/* Cancel the pending grpc_ares_request \a request */
-void grpc_cancel_ares_request(grpc_exec_ctx *exec_ctx,
- grpc_ares_request *request);
+void grpc_cancel_ares_request(grpc_ares_request* request);
/* Initialize gRPC ares wrapper. Must be called at least once before
grpc_resolve_address_ares(). */
-grpc_error *grpc_ares_init(void);
+grpc_error* grpc_ares_init(void);
/* Uninitialized gRPC ares wrapper. If there was more than one previous call to
grpc_ares_init(), this function uninitializes the gRPC ares wrapper only if
@@ -66,4 +64,4 @@ grpc_error *grpc_ares_init(void);
void grpc_ares_cleanup(void);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H \
- */
+ */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c
deleted file mode 100644
index f2587c4520..0000000000
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * Copyright 2016-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 <grpc/support/port_platform.h>
-#if GRPC_ARES != 1 || defined(GRPC_UV)
-
-#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
-
-struct grpc_ares_request {
- char val;
-};
-
-static grpc_ares_request *grpc_dns_lookup_ares_impl(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addrs, bool check_grpclb,
- char **service_config_json) {
- return NULL;
-}
-
-grpc_ares_request *(*grpc_dns_lookup_ares)(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addrs, bool check_grpclb,
- char **service_config_json) = grpc_dns_lookup_ares_impl;
-
-void grpc_cancel_ares_request(grpc_exec_ctx *exec_ctx, grpc_ares_request *r) {}
-
-grpc_error *grpc_ares_init(void) { return GRPC_ERROR_NONE; }
-
-void grpc_ares_cleanup(void) {}
-
-static void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx,
- const char *name,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {}
-
-void (*grpc_resolve_address_ares)(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
- grpc_pollset_set *interested_parties, grpc_closure *on_done,
- grpc_resolved_addresses **addrs) = grpc_resolve_address_ares_impl;
-
-#endif /* GRPC_ARES != 1 || defined(GRPC_UV) */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
new file mode 100644
index 0000000000..a184cf2d57
--- /dev/null
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
@@ -0,0 +1,58 @@
+/*
+ *
+ * Copyright 2016-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 <grpc/support/port_platform.h>
+#if GRPC_ARES != 1 || defined(GRPC_UV)
+
+#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
+
+struct grpc_ares_request {
+ char val;
+};
+
+static grpc_ares_request* grpc_dns_lookup_ares_impl(
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) {
+ return NULL;
+}
+
+grpc_ares_request* (*grpc_dns_lookup_ares)(
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb,
+ char** service_config_json) = grpc_dns_lookup_ares_impl;
+
+void grpc_cancel_ares_request(grpc_ares_request* r) {}
+
+grpc_error* grpc_ares_init(void) { return GRPC_ERROR_NONE; }
+
+void grpc_ares_cleanup(void) {}
+
+static void grpc_resolve_address_ares_impl(const char* name,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) {}
+
+void (*grpc_resolve_address_ares)(
+ const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) = grpc_resolve_address_ares_impl;
+
+#endif /* GRPC_ARES != 1 || defined(GRPC_UV) */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c
deleted file mode 100644
index 5ea75f0554..0000000000
--- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c
+++ /dev/null
@@ -1,310 +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 <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/host_port.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
-#include "src/core/ext/filters/client_channel/resolver_registry.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/iomgr/combiner.h"
-#include "src/core/lib/iomgr/resolve_address.h"
-#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/support/backoff.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-
-#define GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS 1
-#define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
-#define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
-#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;
- /** retry timer */
- bool have_retry_timer;
- grpc_timer retry_timer;
- grpc_closure on_retry;
- /** retry backoff state */
- gpr_backoff backoff_state;
-
- /** currently resolving addresses */
- grpc_resolved_addresses *addresses;
-} dns_resolver;
-
-static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
-
-static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx,
- dns_resolver *r);
-static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
- dns_resolver *r);
-
-static void dns_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
-static void dns_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *r);
-static void dns_next_locked(grpc_exec_ctx *exec_ctx, 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_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- dns_resolver *r = (dns_resolver *)resolver;
- if (r->have_retry_timer) {
- grpc_timer_cancel(exec_ctx, &r->retry_timer);
- }
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->next_completion,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
- }
-}
-
-static void dns_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- dns_resolver *r = (dns_resolver *)resolver;
- if (!r->resolving) {
- gpr_backoff_reset(&r->backoff_state);
- dns_start_resolving_locked(exec_ctx, r);
- }
-}
-
-static void dns_next_locked(grpc_exec_ctx *exec_ctx, 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) {
- gpr_backoff_reset(&r->backoff_state);
- dns_start_resolving_locked(exec_ctx, r);
- } else {
- dns_maybe_finish_next_locked(exec_ctx, r);
- }
-}
-
-static void dns_on_retry_timer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- dns_resolver *r = (dns_resolver *)arg;
-
- r->have_retry_timer = false;
- if (error == GRPC_ERROR_NONE) {
- if (!r->resolving) {
- dns_start_resolving_locked(exec_ctx, r);
- }
- }
-
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "retry-timer");
-}
-
-static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- dns_resolver *r = (dns_resolver *)arg;
- grpc_channel_args *result = NULL;
- GPR_ASSERT(r->resolving);
- r->resolving = false;
- if (r->addresses != NULL) {
- grpc_lb_addresses *addresses = grpc_lb_addresses_create(
- r->addresses->naddrs, NULL /* 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 */,
- NULL /* balancer_name */, NULL /* 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);
- grpc_lb_addresses_destroy(exec_ctx, addresses);
- } else {
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
- gpr_timespec timeout = gpr_time_sub(next_try, now);
- gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
- grpc_error_string(error));
- GPR_ASSERT(!r->have_retry_timer);
- r->have_retry_timer = true;
- GRPC_RESOLVER_REF(&r->base, "retry-timer");
- if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
- gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec,
- timeout.tv_nsec);
- } else {
- gpr_log(GPR_DEBUG, "retrying immediately");
- }
- GRPC_CLOSURE_INIT(&r->on_retry, dns_on_retry_timer_locked, r,
- grpc_combiner_scheduler(r->base.combiner));
- grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry, now);
- }
- if (r->resolved_result != NULL) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
- }
- r->resolved_result = result;
- r->resolved_version++;
- dns_maybe_finish_next_locked(exec_ctx, r);
-
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving");
-}
-
-static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx,
- dns_resolver *r) {
- GRPC_RESOLVER_REF(&r->base, "dns-resolving");
- GPR_ASSERT(!r->resolving);
- r->resolving = true;
- r->addresses = NULL;
- grpc_resolve_address(
- exec_ctx, 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);
-}
-
-static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
- dns_resolver *r) {
- if (r->next_completion != NULL &&
- r->resolved_version != r->published_version) {
- *r->target_result = r->resolved_result == NULL
- ? NULL
- : grpc_channel_args_copy(r->resolved_result);
- GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
- r->next_completion = NULL;
- r->published_version = r->resolved_version;
- }
-}
-
-static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
- dns_resolver *r = (dns_resolver *)gr;
- if (r->resolved_result != NULL) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
- }
- grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
- gpr_free(r->name_to_resolve);
- gpr_free(r->default_port);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
- gpr_free(r);
-}
-
-static grpc_resolver *dns_create(grpc_exec_ctx *exec_ctx,
- 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 NULL;
- }
- // 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 != NULL) {
- grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
- args->pollset_set);
- }
- gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
- GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
- GRPC_DNS_RECONNECT_JITTER,
- GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
- GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
- return &r->base;
-}
-
-/*
- * FACTORY
- */
-
-static void dns_factory_ref(grpc_resolver_factory *factory) {}
-
-static void dns_factory_unref(grpc_resolver_factory *factory) {}
-
-static grpc_resolver *dns_factory_create_resolver(
- grpc_exec_ctx *exec_ctx, grpc_resolver_factory *factory,
- grpc_resolver_args *args) {
- return dns_create(exec_ctx, 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 != NULL && gpr_stricmp(resolver, "native") == 0) {
- gpr_log(GPR_DEBUG, "Using native dns resolver");
- grpc_register_resolver_type(dns_resolver_factory_create());
- } else {
- grpc_resolver_factory *existing_factory =
- grpc_resolver_factory_lookup("dns");
- if (existing_factory == NULL) {
- gpr_log(GPR_DEBUG, "Using native dns resolver");
- grpc_register_resolver_type(dns_resolver_factory_create());
- } else {
- grpc_resolver_factory_unref(existing_factory);
- }
- }
- gpr_free(resolver);
-}
-
-void grpc_resolver_dns_native_shutdown(void) {}
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
new file mode 100644
index 0000000000..62f03d52c0
--- /dev/null
+++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
@@ -0,0 +1,303 @@
+/*
+ *
+ * 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 <grpc/support/port_platform.h>
+
+#include <inttypes.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
+#include "src/core/ext/filters/client_channel/resolver_registry.h"
+#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/string.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/timer.h"
+
+#define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
+#define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
+#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;
+ /** retry timer */
+ bool have_retry_timer;
+ grpc_timer retry_timer;
+ grpc_closure on_retry;
+ /** retry backoff state */
+ grpc_core::ManualConstructor<grpc_core::BackOff> backoff;
+
+ /** 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 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_retry_timer) {
+ grpc_timer_cancel(&r->retry_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;
+ }
+}
+
+static void dns_channel_saw_error_locked(grpc_resolver* resolver) {
+ dns_resolver* r = (dns_resolver*)resolver;
+ if (!r->resolving) {
+ r->backoff->Reset();
+ dns_start_resolving_locked(r);
+ }
+}
+
+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) {
+ r->backoff->Reset();
+ dns_start_resolving_locked(r);
+ } else {
+ dns_maybe_finish_next_locked(r);
+ }
+}
+
+static void dns_on_retry_timer_locked(void* arg, grpc_error* error) {
+ dns_resolver* r = (dns_resolver*)arg;
+
+ r->have_retry_timer = false;
+ if (error == GRPC_ERROR_NONE) {
+ if (!r->resolving) {
+ dns_start_resolving_locked(r);
+ }
+ }
+
+ GRPC_RESOLVER_UNREF(&r->base, "retry-timer");
+}
+
+static void dns_on_resolved_locked(void* arg, grpc_error* error) {
+ dns_resolver* r = (dns_resolver*)arg;
+ grpc_channel_args* result = nullptr;
+ 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) {
+ 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) {
+ grpc_lb_addresses_set_address(
+ 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);
+ grpc_lb_addresses_destroy(addresses);
+ } else {
+ grpc_millis next_try = r->backoff->NextAttemptTime();
+ grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now();
+ gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
+ grpc_error_string(error));
+ GPR_ASSERT(!r->have_retry_timer);
+ r->have_retry_timer = true;
+ GRPC_RESOLVER_REF(&r->base, "retry-timer");
+ if (timeout > 0) {
+ gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout);
+ } else {
+ gpr_log(GPR_DEBUG, "retrying immediately");
+ }
+ GRPC_CLOSURE_INIT(&r->on_retry, dns_on_retry_timer_locked, r,
+ grpc_combiner_scheduler(r->base.combiner));
+ grpc_timer_init(&r->retry_timer, next_try, &r->on_retry);
+ }
+ 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);
+ GRPC_ERROR_UNREF(error);
+
+ GRPC_RESOLVER_UNREF(&r->base, "dns-resolving");
+}
+
+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);
+}
+
+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;
+ }
+}
+
+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);
+}
+
+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);
+ }
+ 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));
+ return &r->base;
+}
+
+/*
+ * FACTORY
+ */
+
+static void dns_factory_ref(grpc_resolver_factory* factory) {}
+
+static void dns_factory_unref(grpc_resolver_factory* factory) {}
+
+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) {
+ gpr_log(GPR_DEBUG, "Using native dns resolver");
+ grpc_register_resolver_type(dns_resolver_factory_create());
+ } else {
+ grpc_resolver_factory* existing_factory =
+ grpc_resolver_factory_lookup("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);
+ }
+ }
+ gpr_free(resolver);
+}
+
+void grpc_resolver_dns_native_shutdown(void) {}
diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
index 69ea440ae6..eaa5e6ac49 100644
--- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
+++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
@@ -32,13 +32,13 @@
#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/string.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
@@ -67,57 +67,52 @@ typedef struct {
grpc_channel_args** target_result;
} fake_resolver;
-static void fake_resolver_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
+static void fake_resolver_destroy(grpc_resolver* gr) {
fake_resolver* r = (fake_resolver*)gr;
- grpc_channel_args_destroy(exec_ctx, r->next_results);
- grpc_channel_args_destroy(exec_ctx, r->results_upon_error);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
+ grpc_channel_args_destroy(r->next_results);
+ grpc_channel_args_destroy(r->results_upon_error);
+ grpc_channel_args_destroy(r->channel_args);
gpr_free(r);
}
-static void fake_resolver_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void fake_resolver_shutdown_locked(grpc_resolver* resolver) {
fake_resolver* r = (fake_resolver*)resolver;
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->next_completion,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+ 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;
}
}
-static void fake_resolver_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- fake_resolver* r) {
- if (r->next_completion != NULL && r->next_results != NULL) {
+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(exec_ctx, r->next_results);
- r->next_results = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
- r->next_completion = NULL;
+ grpc_channel_args_destroy(r->next_results);
+ r->next_results = nullptr;
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
+ r->next_completion = nullptr;
}
}
-static void fake_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void fake_resolver_channel_saw_error_locked(grpc_resolver* resolver) {
fake_resolver* r = (fake_resolver*)resolver;
- if (r->next_results == NULL && r->results_upon_error != NULL) {
+ if (r->next_results == nullptr && r->results_upon_error != nullptr) {
// Pretend we re-resolved.
r->next_results = grpc_channel_args_copy(r->results_upon_error);
}
- fake_resolver_maybe_finish_next_locked(exec_ctx, r);
+ fake_resolver_maybe_finish_next_locked(r);
}
-static void fake_resolver_next_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver,
+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(exec_ctx, r);
+ fake_resolver_maybe_finish_next_locked(r);
}
static const grpc_resolver_vtable fake_resolver_vtable = {
@@ -157,33 +152,31 @@ typedef struct set_response_closure_arg {
grpc_channel_args* next_response;
} set_response_closure_arg;
-static void set_response_closure_fn(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void set_response_closure_fn(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 (r->next_results != NULL) {
- grpc_channel_args_destroy(exec_ctx, r->next_results);
+ if (r->next_results != nullptr) {
+ grpc_channel_args_destroy(r->next_results);
}
r->next_results = closure_arg->next_response;
- if (r->results_upon_error != NULL) {
- grpc_channel_args_destroy(exec_ctx, r->results_upon_error);
+ if (r->results_upon_error != nullptr) {
+ grpc_channel_args_destroy(r->results_upon_error);
}
r->results_upon_error = grpc_channel_args_copy(closure_arg->next_response);
gpr_free(closure_arg);
- fake_resolver_maybe_finish_next_locked(exec_ctx, r);
+ fake_resolver_maybe_finish_next_locked(r);
}
void grpc_fake_resolver_response_generator_set_response(
- grpc_exec_ctx* exec_ctx, grpc_fake_resolver_response_generator* generator,
+ grpc_fake_resolver_response_generator* generator,
grpc_channel_args* next_response) {
- GPR_ASSERT(generator->resolver != NULL);
+ GPR_ASSERT(generator->resolver != nullptr);
set_response_closure_arg* closure_arg =
(set_response_closure_arg*)gpr_zalloc(sizeof(*closure_arg));
closure_arg->generator = generator;
closure_arg->next_response = grpc_channel_args_copy(next_response);
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
set_response_closure_fn, closure_arg,
grpc_combiner_scheduler(
generator->resolver->base.combiner)),
@@ -195,7 +188,7 @@ static void* response_generator_arg_copy(void* p) {
(grpc_fake_resolver_response_generator*)p);
}
-static void response_generator_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
+static void response_generator_arg_destroy(void* p) {
grpc_fake_resolver_response_generator_unref(
(grpc_fake_resolver_response_generator*)p);
}
@@ -220,7 +213,7 @@ grpc_fake_resolver_response_generator*
grpc_fake_resolver_get_response_generator(const grpc_channel_args* args) {
const grpc_arg* arg =
grpc_channel_args_find(args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR);
- if (arg == NULL || arg->type != GRPC_ARG_POINTER) return NULL;
+ if (arg == nullptr || arg->type != GRPC_ARG_POINTER) return nullptr;
return (grpc_fake_resolver_response_generator*)arg->value.pointer.p;
}
@@ -232,15 +225,14 @@ static void fake_resolver_factory_ref(grpc_resolver_factory* factory) {}
static void fake_resolver_factory_unref(grpc_resolver_factory* factory) {}
-static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
- grpc_resolver_factory* factory,
+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 != NULL) response_generator->resolver = r;
+ if (response_generator != nullptr) response_generator->resolver = r;
return &r->base;
}
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 c084ef2a58..a8977e5980 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
@@ -39,7 +39,7 @@ grpc_fake_resolver_response_generator_create();
// Instruct the fake resolver associated with the \a response_generator instance
// to trigger a new resolution for \a uri and \a args.
void grpc_fake_resolver_response_generator_set_response(
- grpc_exec_ctx* exec_ctx, grpc_fake_resolver_response_generator* generator,
+ grpc_fake_resolver_response_generator* generator,
grpc_channel_args* next_response);
// Return a \a grpc_arg for a \a grpc_fake_resolver_response_generator instance.
@@ -57,4 +57,4 @@ void grpc_fake_resolver_response_generator_unref(
grpc_fake_resolver_response_generator* generator);
#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.c b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
index 7ceb8f40a1..99ad78e23c 100644
--- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c
+++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
@@ -30,126 +30,118 @@
#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/string.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
typedef struct {
/** base class: must be first */
grpc_resolver base;
/** the addresses that we've 'resolved' */
- grpc_lb_addresses *addresses;
+ grpc_lb_addresses* addresses;
/** channel args */
- grpc_channel_args *channel_args;
+ grpc_channel_args* channel_args;
/** have we published? */
bool published;
/** pending next completion, or NULL */
- grpc_closure *next_completion;
+ grpc_closure* next_completion;
/** target result address for next completion */
- grpc_channel_args **target_result;
+ grpc_channel_args** target_result;
} sockaddr_resolver;
-static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
+static void sockaddr_destroy(grpc_resolver* r);
-static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
- sockaddr_resolver *r);
+static void sockaddr_maybe_finish_next_locked(sockaddr_resolver* r);
-static void sockaddr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
-static void sockaddr_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *r);
-static void sockaddr_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r,
- grpc_channel_args **target_result,
- grpc_closure *on_complete);
+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_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- sockaddr_resolver *r = (sockaddr_resolver *)resolver;
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->next_completion,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+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;
}
}
-static void sockaddr_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver) {
- sockaddr_resolver *r = (sockaddr_resolver *)resolver;
+static void sockaddr_channel_saw_error_locked(grpc_resolver* resolver) {
+ sockaddr_resolver* r = (sockaddr_resolver*)resolver;
r->published = false;
- sockaddr_maybe_finish_next_locked(exec_ctx, r);
+ sockaddr_maybe_finish_next_locked(r);
}
-static void sockaddr_next_locked(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver,
- grpc_channel_args **target_result,
- grpc_closure *on_complete) {
- sockaddr_resolver *r = (sockaddr_resolver *)resolver;
+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(exec_ctx, r);
+ sockaddr_maybe_finish_next_locked(r);
}
-static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
- sockaddr_resolver *r) {
- if (r->next_completion != NULL && !r->published) {
+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(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
- r->next_completion = NULL;
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
+ r->next_completion = nullptr;
}
}
-static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
- sockaddr_resolver *r = (sockaddr_resolver *)gr;
- grpc_lb_addresses_destroy(exec_ctx, r->addresses);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
+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);
}
-static char *ip_get_default_authority(grpc_uri *uri) {
- const char *path = uri->path;
+static char* ip_get_default_authority(grpc_uri* uri) {
+ const char* path = uri->path;
if (path[0] == '/') ++path;
return gpr_strdup(path);
}
-static char *ipv4_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {
+static char* ipv4_get_default_authority(grpc_resolver_factory* factory,
+ grpc_uri* uri) {
return ip_get_default_authority(uri);
}
-static char *ipv6_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {
+static char* ipv6_get_default_authority(grpc_resolver_factory* factory,
+ grpc_uri* uri) {
return ip_get_default_authority(uri);
}
#ifdef GRPC_HAVE_UNIX_SOCKET
-char *unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {
+char* unix_get_default_authority(grpc_resolver_factory* factory,
+ grpc_uri* uri) {
return gpr_strdup("localhost");
}
#endif
-static void do_nothing(void *ignored) {}
+static void do_nothing(void* ignored) {}
-static grpc_resolver *sockaddr_create(grpc_exec_ctx *exec_ctx,
- grpc_resolver_args *args,
- bool parse(const grpc_uri *uri,
- grpc_resolved_address *dst)) {
+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 NULL;
+ return nullptr;
}
/* Construct addresses. */
grpc_slice path_slice =
@@ -157,12 +149,12 @@ static grpc_resolver *sockaddr_create(grpc_exec_ctx *exec_ctx,
grpc_slice_buffer path_parts;
grpc_slice_buffer_init(&path_parts);
grpc_slice_split(path_slice, ",", &path_parts);
- grpc_lb_addresses *addresses =
- grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */);
+ grpc_lb_addresses* addresses = grpc_lb_addresses_create(
+ 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;
- char *part_str = grpc_slice_to_c_string(path_parts.slices[i]);
+ 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)) {
errors_found = true; /* GPR_TRUE */
@@ -170,15 +162,15 @@ static grpc_resolver *sockaddr_create(grpc_exec_ctx *exec_ctx,
gpr_free(part_str);
if (errors_found) break;
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts);
- grpc_slice_unref_internal(exec_ctx, path_slice);
+ grpc_slice_buffer_destroy_internal(&path_parts);
+ grpc_slice_unref_internal(path_slice);
if (errors_found) {
- grpc_lb_addresses_destroy(exec_ctx, addresses);
- return NULL;
+ grpc_lb_addresses_destroy(addresses);
+ return nullptr;
}
/* Instantiate resolver. */
- sockaddr_resolver *r =
- (sockaddr_resolver *)gpr_zalloc(sizeof(sockaddr_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);
@@ -189,15 +181,14 @@ static grpc_resolver *sockaddr_create(grpc_exec_ctx *exec_ctx,
* FACTORY
*/
-static void sockaddr_factory_ref(grpc_resolver_factory *factory) {}
+static void sockaddr_factory_ref(grpc_resolver_factory* factory) {}
-static void sockaddr_factory_unref(grpc_resolver_factory *factory) {}
+static void sockaddr_factory_unref(grpc_resolver_factory* factory) {}
#define DECL_FACTORY(name) \
- static grpc_resolver *name##_factory_create_resolver( \
- grpc_exec_ctx *exec_ctx, grpc_resolver_factory *factory, \
- grpc_resolver_args *args) { \
- return sockaddr_create(exec_ctx, args, grpc_parse_##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, \
diff --git a/src/core/ext/filters/client_channel/resolver_factory.c b/src/core/ext/filters/client_channel/resolver_factory.cc
index 6f0a7c1e36..9b3ec2f1c4 100644
--- a/src/core/ext/filters/client_channel/resolver_factory.c
+++ b/src/core/ext/filters/client_channel/resolver_factory.cc
@@ -28,14 +28,13 @@ void grpc_resolver_factory_unref(grpc_resolver_factory* factory) {
/** Create a resolver instance for a name */
grpc_resolver* grpc_resolver_factory_create_resolver(
- grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory,
- grpc_resolver_args* args) {
- if (factory == NULL) return NULL;
- return factory->vtable->create_resolver(exec_ctx, factory, args);
+ 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 == NULL) return NULL;
+ 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 6bd7929d4e..170ecc0b48 100644
--- a/src/core/ext/filters/client_channel/resolver_factory.h
+++ b/src/core/ext/filters/client_channel/resolver_factory.h
@@ -28,43 +28,41 @@ typedef struct grpc_resolver_factory grpc_resolver_factory;
typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable;
struct grpc_resolver_factory {
- const grpc_resolver_factory_vtable *vtable;
+ const grpc_resolver_factory_vtable* vtable;
};
typedef struct grpc_resolver_args {
- grpc_uri *uri;
- const grpc_channel_args *args;
- grpc_pollset_set *pollset_set;
- grpc_combiner *combiner;
+ grpc_uri* uri;
+ const grpc_channel_args* args;
+ grpc_pollset_set* pollset_set;
+ grpc_combiner* combiner;
} grpc_resolver_args;
struct grpc_resolver_factory_vtable {
- void (*ref)(grpc_resolver_factory *factory);
- void (*unref)(grpc_resolver_factory *factory);
+ void (*ref)(grpc_resolver_factory* factory);
+ void (*unref)(grpc_resolver_factory* factory);
/** Implementation of grpc_resolver_factory_create_resolver */
- grpc_resolver *(*create_resolver)(grpc_exec_ctx *exec_ctx,
- grpc_resolver_factory *factory,
- grpc_resolver_args *args);
+ grpc_resolver* (*create_resolver)(grpc_resolver_factory* factory,
+ grpc_resolver_args* args);
/** Implementation of grpc_resolver_factory_get_default_authority */
- char *(*get_default_authority)(grpc_resolver_factory *factory, grpc_uri *uri);
+ char* (*get_default_authority)(grpc_resolver_factory* factory, grpc_uri* uri);
/** URI scheme that this factory implements */
- const char *scheme;
+ const char* scheme;
};
-void grpc_resolver_factory_ref(grpc_resolver_factory *resolver);
-void grpc_resolver_factory_unref(grpc_resolver_factory *resolver);
+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_exec_ctx *exec_ctx, grpc_resolver_factory *factory,
- grpc_resolver_args *args);
+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);
+char* grpc_resolver_factory_get_default_authority(
+ grpc_resolver_factory* factory, grpc_uri* uri);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */
diff --git a/src/core/ext/filters/client_channel/resolver_registry.c b/src/core/ext/filters/client_channel/resolver_registry.cc
index 1a0fb0bc3c..3f8451de6b 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.c
+++ b/src/core/ext/filters/client_channel/resolver_registry.cc
@@ -27,7 +27,7 @@
#define MAX_RESOLVERS 10
#define DEFAULT_RESOLVER_PREFIX_MAX_LENGTH 32
-static grpc_resolver_factory *g_all_of_the_resolvers[MAX_RESOLVERS];
+static grpc_resolver_factory* g_all_of_the_resolvers[MAX_RESOLVERS];
static int g_number_of_resolvers = 0;
static char g_default_resolver_prefix[DEFAULT_RESOLVER_PREFIX_MAX_LENGTH] =
@@ -49,7 +49,7 @@ void grpc_resolver_registry_shutdown(void) {
}
void grpc_resolver_registry_set_default_prefix(
- const char *default_resolver_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");
@@ -59,7 +59,7 @@ void grpc_resolver_registry_set_default_prefix(
strcpy(g_default_resolver_prefix, default_resolver_prefix);
}
-void grpc_register_resolver_type(grpc_resolver_factory *factory) {
+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,
@@ -70,7 +70,7 @@ void grpc_register_resolver_type(grpc_resolver_factory *factory) {
g_all_of_the_resolvers[g_number_of_resolvers++] = factory;
}
-static grpc_resolver_factory *lookup_factory(const char *name) {
+static grpc_resolver_factory* lookup_factory(const char* name) {
int i;
for (i = 0; i < g_number_of_resolvers; i++) {
@@ -78,37 +78,36 @@ static grpc_resolver_factory *lookup_factory(const char *name) {
return g_all_of_the_resolvers[i];
}
}
- return NULL;
+ return nullptr;
}
-grpc_resolver_factory *grpc_resolver_factory_lookup(const char *name) {
- grpc_resolver_factory *f = lookup_factory(name);
+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;
}
-static grpc_resolver_factory *lookup_factory_by_uri(grpc_uri *uri) {
- if (!uri) return NULL;
+static grpc_resolver_factory* lookup_factory_by_uri(grpc_uri* uri) {
+ if (!uri) return nullptr;
return lookup_factory(uri->scheme);
}
-static grpc_resolver_factory *resolve_factory(grpc_exec_ctx *exec_ctx,
- const char *target,
- grpc_uri **uri,
- char **canonical_target) {
- grpc_resolver_factory *factory = NULL;
+static grpc_resolver_factory* resolve_factory(const char* target,
+ grpc_uri** uri,
+ char** canonical_target) {
+ grpc_resolver_factory* factory = nullptr;
- GPR_ASSERT(uri != NULL);
- *uri = grpc_uri_parse(exec_ctx, target, 1);
+ GPR_ASSERT(uri != nullptr);
+ *uri = grpc_uri_parse(target, 1);
factory = lookup_factory_by_uri(*uri);
- if (factory == NULL) {
+ if (factory == nullptr) {
grpc_uri_destroy(*uri);
gpr_asprintf(canonical_target, "%s%s", g_default_resolver_prefix, target);
- *uri = grpc_uri_parse(exec_ctx, *canonical_target, 1);
+ *uri = grpc_uri_parse(*canonical_target, 1);
factory = lookup_factory_by_uri(*uri);
- if (factory == NULL) {
- grpc_uri_destroy(grpc_uri_parse(exec_ctx, target, 0));
- grpc_uri_destroy(grpc_uri_parse(exec_ctx, *canonical_target, 0));
+ 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);
}
@@ -116,44 +115,42 @@ static grpc_resolver_factory *resolve_factory(grpc_exec_ctx *exec_ctx,
return factory;
}
-grpc_resolver *grpc_resolver_create(grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_args *args,
- grpc_pollset_set *pollset_set,
- grpc_combiner *combiner) {
- grpc_uri *uri = NULL;
- char *canonical_target = NULL;
- grpc_resolver_factory *factory =
- resolve_factory(exec_ctx, target, &uri, &canonical_target);
- grpc_resolver *resolver;
+grpc_resolver* grpc_resolver_create(const char* target,
+ const grpc_channel_args* args,
+ grpc_pollset_set* pollset_set,
+ grpc_combiner* combiner) {
+ 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));
resolver_args.uri = uri;
resolver_args.args = args;
resolver_args.pollset_set = pollset_set;
resolver_args.combiner = combiner;
- resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &resolver_args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &resolver_args);
grpc_uri_destroy(uri);
gpr_free(canonical_target);
return resolver;
}
-char *grpc_get_default_authority(grpc_exec_ctx *exec_ctx, const char *target) {
- grpc_uri *uri = NULL;
- char *canonical_target = NULL;
- grpc_resolver_factory *factory =
- resolve_factory(exec_ctx, target, &uri, &canonical_target);
- char *authority = grpc_resolver_factory_get_default_authority(factory, uri);
+char* grpc_get_default_authority(const char* target) {
+ 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);
grpc_uri_destroy(uri);
gpr_free(canonical_target);
return authority;
}
-char *grpc_resolver_factory_add_default_prefix_if_needed(
- grpc_exec_ctx *exec_ctx, const char *target) {
- grpc_uri *uri = NULL;
- char *canonical_target = NULL;
- resolve_factory(exec_ctx, target, &uri, &canonical_target);
+char* grpc_resolver_factory_add_default_prefix_if_needed(const char* target) {
+ grpc_uri* uri = nullptr;
+ char* canonical_target = nullptr;
+ resolve_factory(target, &uri, &canonical_target);
grpc_uri_destroy(uri);
- return canonical_target == NULL ? gpr_strdup(target) : canonical_target;
+ return canonical_target == nullptr ? gpr_strdup(target) : canonical_target;
}
diff --git a/src/core/ext/filters/client_channel/resolver_registry.h b/src/core/ext/filters/client_channel/resolver_registry.h
index 692490543d..bbd30df8da 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.h
+++ b/src/core/ext/filters/client_channel/resolver_registry.h
@@ -26,14 +26,14 @@ void grpc_resolver_registry_init();
void grpc_resolver_registry_shutdown(void);
/** Set the default URI prefix to \a default_prefix. */
-void grpc_resolver_registry_set_default_prefix(const char *default_prefix);
+void grpc_resolver_registry_set_default_prefix(const char* default_prefix);
/** 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);
+void grpc_register_resolver_type(grpc_resolver_factory* factory);
/** Create a resolver given \a target.
First tries to parse \a target as a URI. If this succeeds, tries
@@ -48,22 +48,21 @@ void grpc_register_resolver_type(grpc_resolver_factory *factory);
(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(grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_args *args,
- grpc_pollset_set *pollset_set,
- grpc_combiner *combiner);
+grpc_resolver* grpc_resolver_create(const char* target,
+ const grpc_channel_args* args,
+ grpc_pollset_set* pollset_set,
+ grpc_combiner* combiner);
/** 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);
+grpc_resolver_factory* grpc_resolver_factory_lookup(const char* name);
/** 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(grpc_exec_ctx *exec_ctx, const char *target);
+char* grpc_get_default_authority(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(
- grpc_exec_ctx *exec_ctx, const char *target);
+char* grpc_resolver_factory_add_default_prefix_if_needed(const char* target);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */
diff --git a/src/core/ext/filters/client_channel/retry_throttle.c b/src/core/ext/filters/client_channel/retry_throttle.cc
index 09dcade089..867d775151 100644
--- a/src/core/ext/filters/client_channel/retry_throttle.c
+++ b/src/core/ext/filters/client_channel/retry_throttle.cc
@@ -48,7 +48,7 @@ static void get_replacement_throttle_data_if_needed(
grpc_server_retry_throttle_data* new_throttle_data =
(grpc_server_retry_throttle_data*)gpr_atm_acq_load(
&(*throttle_data)->replacement);
- if (new_throttle_data == NULL) return;
+ if (new_throttle_data == nullptr) return;
*throttle_data = new_throttle_data;
}
}
@@ -88,7 +88,7 @@ void grpc_server_retry_throttle_data_unref(
grpc_server_retry_throttle_data* replacement =
(grpc_server_retry_throttle_data*)gpr_atm_acq_load(
&throttle_data->replacement);
- if (replacement != NULL) {
+ if (replacement != nullptr) {
grpc_server_retry_throttle_data_unref(replacement);
}
gpr_free(throttle_data);
@@ -109,7 +109,7 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
// the token count by scaling proportionately to the old data. This
// ensures that if we're already throttling retries on the old scale,
// we will start out doing the same thing on the new one.
- if (old_throttle_data != NULL) {
+ if (old_throttle_data != nullptr) {
double token_fraction =
(int)gpr_atm_acq_load(&old_throttle_data->milli_tokens) /
(double)old_throttle_data->max_milli_tokens;
@@ -119,7 +119,7 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
(gpr_atm)initial_milli_tokens);
// If there was a pre-existing entry, mark it as stale and give it a
// pointer to the new entry, which is its replacement.
- if (old_throttle_data != NULL) {
+ if (old_throttle_data != nullptr) {
grpc_server_retry_throttle_data_ref(throttle_data);
gpr_atm_rel_store(&old_throttle_data->replacement, (gpr_atm)throttle_data);
}
@@ -170,7 +170,7 @@ void grpc_retry_throttle_map_init() {
void grpc_retry_throttle_map_shutdown() {
gpr_mu_destroy(&g_mu);
- gpr_avl_unref(g_avl, NULL);
+ gpr_avl_unref(g_avl, nullptr);
}
grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
@@ -178,12 +178,12 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
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,
- NULL);
- if (throttle_data == NULL) {
+ 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, NULL);
- g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data, NULL);
+ max_milli_tokens, milli_token_ratio, nullptr);
+ g_avl = gpr_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) {
@@ -191,7 +191,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, NULL);
+ g_avl = gpr_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.c b/src/core/ext/filters/client_channel/subchannel.c
deleted file mode 100644
index 40a51c72d6..0000000000
--- a/src/core/ext/filters/client_channel/subchannel.c
+++ /dev/null
@@ -1,816 +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/subchannel.h"
-
-#include <limits.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/avl.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/ext/filters/client_channel/client_channel.h"
-#include "src/core/ext/filters/client_channel/parse_address.h"
-#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
-#include "src/core/ext/filters/client_channel/subchannel_index.h"
-#include "src/core/ext/filters/client_channel/uri_parser.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/channel/connected_channel.h"
-#include "src/core/lib/debug/stats.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/backoff.h"
-#include "src/core/lib/surface/channel.h"
-#include "src/core/lib/surface/channel_init.h"
-#include "src/core/lib/transport/connectivity_state.h"
-
-#define INTERNAL_REF_BITS 16
-#define STRONG_REF_MASK (~(gpr_atm)((1 << INTERNAL_REF_BITS) - 1))
-
-#define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1
-#define GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER 1.6
-#define GRPC_SUBCHANNEL_RECONNECT_MIN_BACKOFF_SECONDS 20
-#define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120
-#define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2
-
-#define GET_CONNECTED_SUBCHANNEL(subchannel, barrier) \
- ((grpc_connected_subchannel *)(gpr_atm_##barrier##_load( \
- &(subchannel)->connected_subchannel)))
-
-typedef struct {
- grpc_closure closure;
- grpc_subchannel *subchannel;
- grpc_connectivity_state connectivity_state;
-} state_watcher;
-
-typedef struct external_state_watcher {
- grpc_subchannel *subchannel;
- grpc_pollset_set *pollset_set;
- grpc_closure *notify;
- grpc_closure closure;
- struct external_state_watcher *next;
- struct external_state_watcher *prev;
-} external_state_watcher;
-
-struct grpc_subchannel {
- grpc_connector *connector;
-
- /** refcount
- - lower INTERNAL_REF_BITS bits are for internal references:
- these do not keep the subchannel open.
- - upper remaining bits are for public references: these do
- keep the subchannel open */
- gpr_atm ref_pair;
-
- /** non-transport related channel filters */
- const grpc_channel_filter **filters;
- size_t num_filters;
- /** channel arguments */
- grpc_channel_args *args;
-
- grpc_subchannel_key *key;
-
- /** set during connection */
- grpc_connect_out_args connecting_result;
-
- /** callback for connection finishing */
- grpc_closure connected;
-
- /** callback for our alarm */
- grpc_closure on_alarm;
-
- /** pollset_set tracking who's interested in a connection
- being setup */
- grpc_pollset_set *pollset_set;
-
- /** active connection, or null; of type grpc_connected_subchannel */
- gpr_atm connected_subchannel;
-
- /** mutex protecting remaining elements */
- gpr_mu mu;
-
- /** have we seen a disconnection? */
- bool disconnected;
- /** are we connecting */
- bool connecting;
- /** connectivity state tracking */
- grpc_connectivity_state_tracker state_tracker;
-
- external_state_watcher root_external_state_watcher;
-
- /** next connect attempt time */
- gpr_timespec next_attempt;
- /** backoff state */
- gpr_backoff backoff_state;
- /** do we have an active alarm? */
- bool have_alarm;
- /** have we started the backoff loop */
- bool backoff_begun;
- /** our alarm */
- grpc_timer alarm;
-};
-
-struct grpc_subchannel_call {
- grpc_connected_subchannel *connection;
- grpc_closure *schedule_closure_after_destroy;
-};
-
-#define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack *)((call) + 1))
-#define CHANNEL_STACK_FROM_CONNECTION(con) ((grpc_channel_stack *)(con))
-#define CALLSTACK_TO_SUBCHANNEL_CALL(callstack) \
- (((grpc_subchannel_call *)(callstack)) - 1)
-
-static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *subchannel,
- grpc_error *error);
-
-#ifndef NDEBUG
-#define REF_REASON reason
-#define REF_MUTATE_EXTRA_ARGS \
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS, const char *purpose
-#define REF_MUTATE_PURPOSE(x) , file, line, reason, x
-#else
-#define REF_REASON ""
-#define REF_MUTATE_EXTRA_ARGS
-#define REF_MUTATE_PURPOSE(x)
-#endif
-
-/*
- * connection implementation
- */
-
-static void connection_destroy(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_connected_subchannel *c = (grpc_connected_subchannel *)arg;
- grpc_channel_stack_destroy(exec_ctx, CHANNEL_STACK_FROM_CONNECTION(c));
- gpr_free(c);
-}
-
-grpc_connected_subchannel *grpc_connected_subchannel_ref(
- grpc_connected_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CONNECTION(c), REF_REASON);
- return c;
-}
-
-void grpc_connected_subchannel_unref(grpc_exec_ctx *exec_ctx,
- grpc_connected_subchannel *c
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CONNECTION(c),
- REF_REASON);
-}
-
-/*
- * grpc_subchannel implementation
- */
-
-static void subchannel_destroy(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_subchannel *c = (grpc_subchannel *)arg;
- gpr_free((void *)c->filters);
- grpc_channel_args_destroy(exec_ctx, c->args);
- grpc_connectivity_state_destroy(exec_ctx, &c->state_tracker);
- grpc_connector_unref(exec_ctx, c->connector);
- grpc_pollset_set_destroy(exec_ctx, c->pollset_set);
- grpc_subchannel_key_destroy(exec_ctx, c->key);
- gpr_mu_destroy(&c->mu);
- gpr_free(c);
-}
-
-static gpr_atm ref_mutate(grpc_subchannel *c, gpr_atm delta,
- int barrier REF_MUTATE_EXTRA_ARGS) {
- gpr_atm old_val = barrier ? gpr_atm_full_fetch_add(&c->ref_pair, delta)
- : gpr_atm_no_barrier_fetch_add(&c->ref_pair, delta);
-#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_stream_refcount)) {
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "SUBCHANNEL: %p %12s 0x%" PRIxPTR " -> 0x%" PRIxPTR " [%s]", c,
- purpose, old_val, old_val + delta, reason);
- }
-#endif
- return old_val;
-}
-
-grpc_subchannel *grpc_subchannel_ref(
- grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- gpr_atm old_refs;
- old_refs = ref_mutate(c, (1 << INTERNAL_REF_BITS),
- 0 REF_MUTATE_PURPOSE("STRONG_REF"));
- GPR_ASSERT((old_refs & STRONG_REF_MASK) != 0);
- return c;
-}
-
-grpc_subchannel *grpc_subchannel_weak_ref(
- grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- gpr_atm old_refs;
- old_refs = ref_mutate(c, 1, 0 REF_MUTATE_PURPOSE("WEAK_REF"));
- GPR_ASSERT(old_refs != 0);
- return c;
-}
-
-grpc_subchannel *grpc_subchannel_ref_from_weak_ref(
- grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- if (!c) return NULL;
- for (;;) {
- gpr_atm old_refs = gpr_atm_acq_load(&c->ref_pair);
- if (old_refs >= (1 << INTERNAL_REF_BITS)) {
- gpr_atm new_refs = old_refs + (1 << INTERNAL_REF_BITS);
- if (gpr_atm_rel_cas(&c->ref_pair, old_refs, new_refs)) {
- return c;
- }
- } else {
- return NULL;
- }
- }
-}
-
-static void disconnect(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) {
- grpc_connected_subchannel *con;
- grpc_subchannel_index_unregister(exec_ctx, c->key, c);
- gpr_mu_lock(&c->mu);
- GPR_ASSERT(!c->disconnected);
- c->disconnected = true;
- grpc_connector_shutdown(
- exec_ctx, c->connector,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Subchannel disconnected"));
- con = GET_CONNECTED_SUBCHANNEL(c, no_barrier);
- if (con != NULL) {
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, con, "connection");
- gpr_atm_no_barrier_store(&c->connected_subchannel, (gpr_atm)0xdeadbeef);
- }
- gpr_mu_unlock(&c->mu);
-}
-
-void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- gpr_atm old_refs;
- // add a weak ref and subtract a strong ref (atomically)
- old_refs = ref_mutate(c, (gpr_atm)1 - (gpr_atm)(1 << INTERNAL_REF_BITS),
- 1 REF_MUTATE_PURPOSE("STRONG_UNREF"));
- if ((old_refs & STRONG_REF_MASK) == (1 << INTERNAL_REF_BITS)) {
- disconnect(exec_ctx, c);
- }
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "strong-unref");
-}
-
-void grpc_subchannel_weak_unref(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *c
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- gpr_atm old_refs;
- old_refs = ref_mutate(c, -(gpr_atm)1, 1 REF_MUTATE_PURPOSE("WEAK_UNREF"));
- if (old_refs == 1) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(subchannel_destroy, c,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
- }
-}
-
-grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
- grpc_connector *connector,
- const grpc_subchannel_args *args) {
- grpc_subchannel_key *key = grpc_subchannel_key_create(args);
- grpc_subchannel *c = grpc_subchannel_index_find(exec_ctx, key);
- if (c) {
- grpc_subchannel_key_destroy(exec_ctx, key);
- return c;
- }
-
- GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(exec_ctx);
- c = (grpc_subchannel *)gpr_zalloc(sizeof(*c));
- c->key = key;
- gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS);
- c->connector = connector;
- grpc_connector_ref(c->connector);
- c->num_filters = args->filter_count;
- if (c->num_filters > 0) {
- c->filters = (const grpc_channel_filter **)gpr_malloc(
- sizeof(grpc_channel_filter *) * c->num_filters);
- memcpy((void *)c->filters, args->filters,
- sizeof(grpc_channel_filter *) * c->num_filters);
- } else {
- c->filters = NULL;
- }
- c->pollset_set = grpc_pollset_set_create();
- grpc_resolved_address *addr =
- (grpc_resolved_address *)gpr_malloc(sizeof(*addr));
- grpc_get_subchannel_address_arg(exec_ctx, args->args, addr);
- grpc_resolved_address *new_address = NULL;
- grpc_channel_args *new_args = NULL;
- if (grpc_proxy_mappers_map_address(exec_ctx, addr, args->args, &new_address,
- &new_args)) {
- GPR_ASSERT(new_address != NULL);
- gpr_free(addr);
- addr = new_address;
- }
- static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS};
- grpc_arg new_arg = grpc_create_subchannel_address_arg(addr);
- gpr_free(addr);
- c->args = grpc_channel_args_copy_and_add_and_remove(
- new_args != NULL ? new_args : args->args, keys_to_remove,
- GPR_ARRAY_SIZE(keys_to_remove), &new_arg, 1);
- gpr_free(new_arg.value.string);
- if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
- c->root_external_state_watcher.next = c->root_external_state_watcher.prev =
- &c->root_external_state_watcher;
- GRPC_CLOSURE_INIT(&c->connected, subchannel_connected, c,
- grpc_schedule_on_exec_ctx);
- grpc_connectivity_state_init(&c->state_tracker, GRPC_CHANNEL_IDLE,
- "subchannel");
- int initial_backoff_ms =
- GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS * 1000;
- int min_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MIN_BACKOFF_SECONDS * 1000;
- int max_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000;
- bool fixed_reconnect_backoff = false;
- if (c->args) {
- for (size_t i = 0; i < c->args->num_args; i++) {
- if (0 == strcmp(c->args->args[i].key,
- "grpc.testing.fixed_reconnect_backoff_ms")) {
- fixed_reconnect_backoff = true;
- initial_backoff_ms = min_backoff_ms = max_backoff_ms =
- grpc_channel_arg_get_integer(
- &c->args->args[i],
- (grpc_integer_options){initial_backoff_ms, 100, INT_MAX});
- } else if (0 == strcmp(c->args->args[i].key,
- GRPC_ARG_MIN_RECONNECT_BACKOFF_MS)) {
- fixed_reconnect_backoff = false;
- min_backoff_ms = grpc_channel_arg_get_integer(
- &c->args->args[i],
- (grpc_integer_options){min_backoff_ms, 100, INT_MAX});
- } else if (0 == strcmp(c->args->args[i].key,
- GRPC_ARG_MAX_RECONNECT_BACKOFF_MS)) {
- fixed_reconnect_backoff = false;
- max_backoff_ms = grpc_channel_arg_get_integer(
- &c->args->args[i],
- (grpc_integer_options){max_backoff_ms, 100, INT_MAX});
- } else if (0 == strcmp(c->args->args[i].key,
- GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS)) {
- fixed_reconnect_backoff = false;
- initial_backoff_ms = grpc_channel_arg_get_integer(
- &c->args->args[i],
- (grpc_integer_options){initial_backoff_ms, 100, INT_MAX});
- }
- }
- }
- gpr_backoff_init(
- &c->backoff_state, initial_backoff_ms,
- fixed_reconnect_backoff ? 1.0
- : GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER,
- fixed_reconnect_backoff ? 0.0 : GRPC_SUBCHANNEL_RECONNECT_JITTER,
- min_backoff_ms, max_backoff_ms);
- gpr_mu_init(&c->mu);
-
- return grpc_subchannel_index_register(exec_ctx, key, c);
-}
-
-static void continue_connect_locked(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *c) {
- grpc_connect_in_args args;
-
- args.interested_parties = c->pollset_set;
- args.deadline = c->next_attempt;
- args.channel_args = c->args;
-
- grpc_connectivity_state_set(exec_ctx, &c->state_tracker,
- GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE,
- "state_change");
- grpc_connector_connect(exec_ctx, c->connector, &args, &c->connecting_result,
- &c->connected);
-}
-
-grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel *c,
- grpc_error **error) {
- grpc_connectivity_state state;
- gpr_mu_lock(&c->mu);
- state = grpc_connectivity_state_get(&c->state_tracker, error);
- gpr_mu_unlock(&c->mu);
- return state;
-}
-
-static void on_external_state_watcher_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- external_state_watcher *w = (external_state_watcher *)arg;
- grpc_closure *follow_up = w->notify;
- if (w->pollset_set != NULL) {
- grpc_pollset_set_del_pollset_set(exec_ctx, w->subchannel->pollset_set,
- w->pollset_set);
- }
- gpr_mu_lock(&w->subchannel->mu);
- w->next->prev = w->prev;
- w->prev->next = w->next;
- gpr_mu_unlock(&w->subchannel->mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, w->subchannel, "external_state_watcher");
- gpr_free(w);
- GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
-}
-
-static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_subchannel *c = (grpc_subchannel *)arg;
- gpr_mu_lock(&c->mu);
- c->have_alarm = false;
- if (c->disconnected) {
- error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Disconnected",
- &error, 1);
- } else {
- GRPC_ERROR_REF(error);
- }
- if (error == GRPC_ERROR_NONE) {
- gpr_log(GPR_INFO, "Failed to connect to channel, retrying");
- c->next_attempt =
- gpr_backoff_step(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC));
- continue_connect_locked(exec_ctx, c);
- gpr_mu_unlock(&c->mu);
- } else {
- gpr_mu_unlock(&c->mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
- }
- GRPC_ERROR_UNREF(error);
-}
-
-static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *c) {
- if (c->disconnected) {
- /* Don't try to connect if we're already disconnected */
- return;
- }
-
- if (c->connecting) {
- /* Already connecting: don't restart */
- return;
- }
-
- if (GET_CONNECTED_SUBCHANNEL(c, no_barrier) != NULL) {
- /* Already connected: don't restart */
- return;
- }
-
- if (!grpc_connectivity_state_has_watchers(&c->state_tracker)) {
- /* Nobody is interested in connecting: so don't just yet */
- return;
- }
-
- c->connecting = true;
- GRPC_SUBCHANNEL_WEAK_REF(c, "connecting");
-
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- if (!c->backoff_begun) {
- c->backoff_begun = true;
- c->next_attempt = gpr_backoff_begin(&c->backoff_state, now);
- continue_connect_locked(exec_ctx, c);
- } else {
- GPR_ASSERT(!c->have_alarm);
- c->have_alarm = true;
- gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now);
- if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <=
- 0) {
- gpr_log(GPR_INFO, "Retry immediately");
- } else {
- gpr_log(GPR_INFO, "Retry in %" PRId64 ".%09d seconds",
- time_til_next.tv_sec, time_til_next.tv_nsec);
- }
- GRPC_CLOSURE_INIT(&c->on_alarm, on_alarm, c, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, &c->on_alarm, now);
- }
-}
-
-void grpc_subchannel_notify_on_state_change(
- grpc_exec_ctx *exec_ctx, grpc_subchannel *c,
- grpc_pollset_set *interested_parties, grpc_connectivity_state *state,
- grpc_closure *notify) {
- external_state_watcher *w;
-
- if (state == NULL) {
- gpr_mu_lock(&c->mu);
- for (w = c->root_external_state_watcher.next;
- w != &c->root_external_state_watcher; w = w->next) {
- if (w->notify == notify) {
- grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &c->state_tracker, NULL, &w->closure);
- }
- }
- gpr_mu_unlock(&c->mu);
- } else {
- w = (external_state_watcher *)gpr_malloc(sizeof(*w));
- w->subchannel = c;
- w->pollset_set = interested_parties;
- w->notify = notify;
- GRPC_CLOSURE_INIT(&w->closure, on_external_state_watcher_done, w,
- grpc_schedule_on_exec_ctx);
- if (interested_parties != NULL) {
- grpc_pollset_set_add_pollset_set(exec_ctx, c->pollset_set,
- interested_parties);
- }
- GRPC_SUBCHANNEL_WEAK_REF(c, "external_state_watcher");
- gpr_mu_lock(&c->mu);
- w->next = &c->root_external_state_watcher;
- w->prev = w->next->prev;
- w->next->prev = w->prev->next = w;
- grpc_connectivity_state_notify_on_state_change(exec_ctx, &c->state_tracker,
- state, &w->closure);
- maybe_start_connecting_locked(exec_ctx, c);
- gpr_mu_unlock(&c->mu);
- }
-}
-
-void grpc_connected_subchannel_process_transport_op(
- grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *con,
- grpc_transport_op *op) {
- grpc_channel_stack *channel_stack = CHANNEL_STACK_FROM_CONNECTION(con);
- grpc_channel_element *top_elem = grpc_channel_stack_element(channel_stack, 0);
- top_elem->filter->start_transport_op(exec_ctx, top_elem, op);
-}
-
-static void subchannel_on_child_state_changed(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- state_watcher *sw = (state_watcher *)p;
- grpc_subchannel *c = sw->subchannel;
- gpr_mu *mu = &c->mu;
-
- gpr_mu_lock(mu);
-
- /* if we failed just leave this closure */
- if (sw->connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
- /* any errors on a subchannel ==> we're done, create a new one */
- sw->connectivity_state = GRPC_CHANNEL_SHUTDOWN;
- }
- grpc_connectivity_state_set(exec_ctx, &c->state_tracker,
- sw->connectivity_state, GRPC_ERROR_REF(error),
- "reflect_child");
- if (sw->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
- grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, GET_CONNECTED_SUBCHANNEL(c, no_barrier), NULL,
- &sw->connectivity_state, &sw->closure);
- GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
- sw = NULL;
- }
-
- gpr_mu_unlock(mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "state_watcher");
- gpr_free(sw);
-}
-
-static void connected_subchannel_state_op(grpc_exec_ctx *exec_ctx,
- grpc_connected_subchannel *con,
- grpc_pollset_set *interested_parties,
- grpc_connectivity_state *state,
- grpc_closure *closure) {
- grpc_transport_op *op = grpc_make_transport_op(NULL);
- grpc_channel_element *elem;
- op->connectivity_state = state;
- op->on_connectivity_state_change = closure;
- op->bind_pollset_set = interested_parties;
- elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(con), 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
-}
-
-void grpc_connected_subchannel_notify_on_state_change(
- grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *con,
- grpc_pollset_set *interested_parties, grpc_connectivity_state *state,
- grpc_closure *closure) {
- connected_subchannel_state_op(exec_ctx, con, interested_parties, state,
- closure);
-}
-
-void grpc_connected_subchannel_ping(grpc_exec_ctx *exec_ctx,
- grpc_connected_subchannel *con,
- grpc_closure *closure) {
- grpc_transport_op *op = grpc_make_transport_op(NULL);
- grpc_channel_element *elem;
- op->send_ping = closure;
- elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(con), 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
-}
-
-static bool publish_transport_locked(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *c) {
- grpc_connected_subchannel *con;
- grpc_channel_stack *stk;
- state_watcher *sw_subchannel;
-
- /* construct channel stack */
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
- grpc_channel_stack_builder_set_channel_arguments(
- exec_ctx, builder, c->connecting_result.channel_args);
- grpc_channel_stack_builder_set_transport(builder,
- c->connecting_result.transport);
-
- if (!grpc_channel_init_create_stack(exec_ctx, builder,
- GRPC_CLIENT_SUBCHANNEL)) {
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
- return false;
- }
- grpc_error *error = grpc_channel_stack_builder_finish(
- exec_ctx, builder, 0, 1, connection_destroy, NULL, (void **)&con);
- if (error != GRPC_ERROR_NONE) {
- grpc_transport_destroy(exec_ctx, c->connecting_result.transport);
- gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
- grpc_error_string(error));
- GRPC_ERROR_UNREF(error);
- return false;
- }
- stk = CHANNEL_STACK_FROM_CONNECTION(con);
- memset(&c->connecting_result, 0, sizeof(c->connecting_result));
-
- /* initialize state watcher */
- sw_subchannel = (state_watcher *)gpr_malloc(sizeof(*sw_subchannel));
- sw_subchannel->subchannel = c;
- sw_subchannel->connectivity_state = GRPC_CHANNEL_READY;
- GRPC_CLOSURE_INIT(&sw_subchannel->closure, subchannel_on_child_state_changed,
- sw_subchannel, grpc_schedule_on_exec_ctx);
-
- if (c->disconnected) {
- gpr_free(sw_subchannel);
- grpc_channel_stack_destroy(exec_ctx, stk);
- gpr_free(con);
- return false;
- }
-
- /* publish */
- /* TODO(ctiller): this full barrier seems to clear up a TSAN failure.
- I'd have expected the rel_cas below to be enough, but
- seemingly it's not.
- Re-evaluate if we really need this. */
- gpr_atm_full_barrier();
- GPR_ASSERT(gpr_atm_rel_cas(&c->connected_subchannel, 0, (gpr_atm)con));
-
- /* setup subchannel watching connected subchannel for changes; subchannel
- ref for connecting is donated to the state watcher */
- GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
- grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, con, c->pollset_set, &sw_subchannel->connectivity_state,
- &sw_subchannel->closure);
-
- /* signal completion */
- grpc_connectivity_state_set(exec_ctx, &c->state_tracker, GRPC_CHANNEL_READY,
- GRPC_ERROR_NONE, "connected");
- return true;
-}
-
-static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_subchannel *c = (grpc_subchannel *)arg;
- grpc_channel_args *delete_channel_args = c->connecting_result.channel_args;
-
- GRPC_SUBCHANNEL_WEAK_REF(c, "connected");
- gpr_mu_lock(&c->mu);
- c->connecting = false;
- if (c->connecting_result.transport != NULL &&
- publish_transport_locked(exec_ctx, c)) {
- /* do nothing, transport was published */
- } else if (c->disconnected) {
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
- } else {
- grpc_connectivity_state_set(
- exec_ctx, &c->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
- grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Connect Failed", &error, 1),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
- "connect_failed");
-
- const char *errmsg = grpc_error_string(error);
- gpr_log(GPR_INFO, "Connect failed: %s", errmsg);
-
- maybe_start_connecting_locked(exec_ctx, c);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
- }
- gpr_mu_unlock(&c->mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connected");
- grpc_channel_args_destroy(exec_ctx, delete_channel_args);
-}
-
-/*
- * grpc_subchannel_call implementation
- */
-
-static void subchannel_call_destroy(grpc_exec_ctx *exec_ctx, void *call,
- grpc_error *error) {
- grpc_subchannel_call *c = (grpc_subchannel_call *)call;
- GPR_ASSERT(c->schedule_closure_after_destroy != NULL);
- GPR_TIMER_BEGIN("grpc_subchannel_call_unref.destroy", 0);
- grpc_connected_subchannel *connection = c->connection;
- grpc_call_stack_destroy(exec_ctx, SUBCHANNEL_CALL_TO_CALL_STACK(c), NULL,
- c->schedule_closure_after_destroy);
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, connection, "subchannel_call");
- GPR_TIMER_END("grpc_subchannel_call_unref.destroy", 0);
-}
-
-void grpc_subchannel_call_set_cleanup_closure(grpc_subchannel_call *call,
- grpc_closure *closure) {
- GPR_ASSERT(call->schedule_closure_after_destroy == NULL);
- GPR_ASSERT(closure != NULL);
- call->schedule_closure_after_destroy = closure;
-}
-
-void grpc_subchannel_call_ref(
- grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
-}
-
-void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_call *c
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- GRPC_CALL_STACK_UNREF(exec_ctx, SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
-}
-
-void grpc_subchannel_call_process_op(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_call *call,
- grpc_transport_stream_op_batch *batch) {
- GPR_TIMER_BEGIN("grpc_subchannel_call_process_op", 0);
- grpc_call_stack *call_stack = SUBCHANNEL_CALL_TO_CALL_STACK(call);
- grpc_call_element *top_elem = grpc_call_stack_element(call_stack, 0);
- GRPC_CALL_LOG_OP(GPR_INFO, top_elem, batch);
- top_elem->filter->start_transport_stream_op_batch(exec_ctx, top_elem, batch);
- GPR_TIMER_END("grpc_subchannel_call_process_op", 0);
-}
-
-grpc_connected_subchannel *grpc_subchannel_get_connected_subchannel(
- grpc_subchannel *c) {
- return GET_CONNECTED_SUBCHANNEL(c, acq);
-}
-
-const grpc_subchannel_key *grpc_subchannel_get_key(
- const grpc_subchannel *subchannel) {
- return subchannel->key;
-}
-
-grpc_error *grpc_connected_subchannel_create_call(
- grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *con,
- const grpc_connected_subchannel_call_args *args,
- grpc_subchannel_call **call) {
- grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con);
- *call = (grpc_subchannel_call *)gpr_arena_alloc(
- args->arena, sizeof(grpc_subchannel_call) + chanstk->call_stack_size);
- grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(*call);
- (*call)->connection = GRPC_CONNECTED_SUBCHANNEL_REF(con, "subchannel_call");
- const grpc_call_element_args call_args = {
- .call_stack = callstk,
- .server_transport_data = NULL,
- .context = args->context,
- .path = args->path,
- .start_time = args->start_time,
- .deadline = args->deadline,
- .arena = args->arena,
- .call_combiner = args->call_combiner};
- grpc_error *error = grpc_call_stack_init(
- exec_ctx, chanstk, 1, subchannel_call_destroy, *call, &call_args);
- if (error != GRPC_ERROR_NONE) {
- const char *error_string = grpc_error_string(error);
- gpr_log(GPR_ERROR, "error: %s", error_string);
- return error;
- }
- grpc_call_stack_set_pollset_or_pollset_set(exec_ctx, callstk, args->pollent);
- return GRPC_ERROR_NONE;
-}
-
-grpc_call_stack *grpc_subchannel_call_get_call_stack(
- grpc_subchannel_call *subchannel_call) {
- return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call);
-}
-
-static void grpc_uri_to_sockaddr(grpc_exec_ctx *exec_ctx, const char *uri_str,
- grpc_resolved_address *addr) {
- grpc_uri *uri = grpc_uri_parse(exec_ctx, uri_str, 0 /* suppress_errors */);
- GPR_ASSERT(uri != NULL);
- if (!grpc_parse_uri(uri, addr)) memset(addr, 0, sizeof(*addr));
- grpc_uri_destroy(uri);
-}
-
-void grpc_get_subchannel_address_arg(grpc_exec_ctx *exec_ctx,
- const grpc_channel_args *args,
- grpc_resolved_address *addr) {
- const char *addr_uri_str = grpc_get_subchannel_address_uri_arg(args);
- memset(addr, 0, sizeof(*addr));
- if (*addr_uri_str != '\0') {
- grpc_uri_to_sockaddr(exec_ctx, addr_uri_str, addr);
- }
-}
-
-const char *grpc_get_subchannel_address_uri_arg(const grpc_channel_args *args) {
- const grpc_arg *addr_arg =
- grpc_channel_args_find(args, GRPC_ARG_SUBCHANNEL_ADDRESS);
- GPR_ASSERT(addr_arg != NULL); // Should have been set by LB policy.
- GPR_ASSERT(addr_arg->type == GRPC_ARG_STRING);
- return addr_arg->value.string;
-}
-
-grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr) {
- return grpc_channel_arg_string_create(
- (char *)GRPC_ARG_SUBCHANNEL_ADDRESS,
- addr->len > 0 ? grpc_sockaddr_to_uri(addr) : gpr_strdup(""));
-}
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
new file mode 100644
index 0000000000..cad8578511
--- /dev/null
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -0,0 +1,801 @@
+/*
+ *
+ * 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/subchannel.h"
+
+#include <inttypes.h>
+#include <limits.h>
+
+#include <algorithm>
+#include <cstring>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/avl.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/ext/filters/client_channel/client_channel.h"
+#include "src/core/ext/filters/client_channel/parse_address.h"
+#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
+#include "src/core/ext/filters/client_channel/subchannel_index.h"
+#include "src/core/ext/filters/client_channel/uri_parser.h"
+#include "src/core/lib/backoff/backoff.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/channel/connected_channel.h"
+#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gprpp/debug_location.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/profiling/timers.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/channel_init.h"
+#include "src/core/lib/transport/connectivity_state.h"
+
+#define INTERNAL_REF_BITS 16
+#define STRONG_REF_MASK (~(gpr_atm)((1 << INTERNAL_REF_BITS) - 1))
+
+#define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1
+#define GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER 1.6
+#define GRPC_SUBCHANNEL_RECONNECT_MIN_TIMEOUT_SECONDS 20
+#define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120
+#define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2
+
+namespace {
+struct state_watcher {
+ grpc_closure closure;
+ grpc_subchannel* subchannel;
+ grpc_connectivity_state connectivity_state;
+};
+} // namespace
+
+typedef struct external_state_watcher {
+ grpc_subchannel* subchannel;
+ grpc_pollset_set* pollset_set;
+ grpc_closure* notify;
+ grpc_closure closure;
+ struct external_state_watcher* next;
+ struct external_state_watcher* prev;
+} external_state_watcher;
+
+struct grpc_subchannel {
+ grpc_connector* connector;
+
+ /** refcount
+ - lower INTERNAL_REF_BITS bits are for internal references:
+ these do not keep the subchannel open.
+ - upper remaining bits are for public references: these do
+ keep the subchannel open */
+ gpr_atm ref_pair;
+
+ /** non-transport related channel filters */
+ const grpc_channel_filter** filters;
+ size_t num_filters;
+ /** channel arguments */
+ grpc_channel_args* args;
+
+ grpc_subchannel_key* key;
+
+ /** set during connection */
+ grpc_connect_out_args connecting_result;
+
+ /** callback for connection finishing */
+ grpc_closure on_connected;
+
+ /** callback for our alarm */
+ grpc_closure on_alarm;
+
+ /** pollset_set tracking who's interested in a connection
+ being setup */
+ grpc_pollset_set* pollset_set;
+
+ /** mutex protecting remaining elements */
+ gpr_mu mu;
+
+ /** active connection, or null; of type grpc_core::ConnectedSubchannel
+ */
+ grpc_core::RefCountedPtr<grpc_core::ConnectedSubchannel> connected_subchannel;
+
+ /** have we seen a disconnection? */
+ bool disconnected;
+ /** are we connecting */
+ bool connecting;
+ /** connectivity state tracking */
+ grpc_connectivity_state_tracker state_tracker;
+
+ external_state_watcher root_external_state_watcher;
+
+ /** backoff state */
+ grpc_core::ManualConstructor<grpc_core::BackOff> backoff;
+ grpc_millis next_attempt_deadline;
+ grpc_millis min_connect_timeout_ms;
+
+ /** do we have an active alarm? */
+ bool have_alarm;
+ /** have we started the backoff loop */
+ bool backoff_begun;
+ /** our alarm */
+ grpc_timer alarm;
+};
+
+struct grpc_subchannel_call {
+ grpc_core::ConnectedSubchannel* connection;
+ grpc_closure* schedule_closure_after_destroy;
+};
+
+#define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack*)((call) + 1))
+#define CALLSTACK_TO_SUBCHANNEL_CALL(callstack) \
+ (((grpc_subchannel_call*)(callstack)) - 1)
+
+static void on_subchannel_connected(void* subchannel, grpc_error* error);
+
+#ifndef NDEBUG
+#define REF_REASON reason
+#define REF_MUTATE_EXTRA_ARGS \
+ GRPC_SUBCHANNEL_REF_EXTRA_ARGS, const char* purpose
+#define REF_MUTATE_PURPOSE(x) , file, line, reason, x
+#else
+#define REF_REASON ""
+#define REF_MUTATE_EXTRA_ARGS
+#define REF_MUTATE_PURPOSE(x)
+#endif
+
+/*
+ * connection implementation
+ */
+
+static void connection_destroy(void* arg, grpc_error* error) {
+ grpc_channel_stack* stk = (grpc_channel_stack*)arg;
+ grpc_channel_stack_destroy(stk);
+ gpr_free(stk);
+}
+
+/*
+ * grpc_subchannel implementation
+ */
+
+static void subchannel_destroy(void* arg, grpc_error* error) {
+ grpc_subchannel* c = (grpc_subchannel*)arg;
+ gpr_free((void*)c->filters);
+ grpc_channel_args_destroy(c->args);
+ grpc_connectivity_state_destroy(&c->state_tracker);
+ grpc_connector_unref(c->connector);
+ grpc_pollset_set_destroy(c->pollset_set);
+ grpc_subchannel_key_destroy(c->key);
+ gpr_mu_destroy(&c->mu);
+ gpr_free(c);
+}
+
+static gpr_atm ref_mutate(grpc_subchannel* c, gpr_atm delta,
+ int barrier REF_MUTATE_EXTRA_ARGS) {
+ gpr_atm old_val = barrier ? gpr_atm_full_fetch_add(&c->ref_pair, delta)
+ : gpr_atm_no_barrier_fetch_add(&c->ref_pair, delta);
+#ifndef NDEBUG
+ if (grpc_trace_stream_refcount.enabled()) {
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "SUBCHANNEL: %p %12s 0x%" PRIxPTR " -> 0x%" PRIxPTR " [%s]", c,
+ purpose, old_val, old_val + delta, reason);
+ }
+#endif
+ return old_val;
+}
+
+grpc_subchannel* grpc_subchannel_ref(
+ grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ gpr_atm old_refs;
+ old_refs = ref_mutate(c, (1 << INTERNAL_REF_BITS),
+ 0 REF_MUTATE_PURPOSE("STRONG_REF"));
+ GPR_ASSERT((old_refs & STRONG_REF_MASK) != 0);
+ return c;
+}
+
+grpc_subchannel* grpc_subchannel_weak_ref(
+ grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ gpr_atm old_refs;
+ old_refs = ref_mutate(c, 1, 0 REF_MUTATE_PURPOSE("WEAK_REF"));
+ GPR_ASSERT(old_refs != 0);
+ return c;
+}
+
+grpc_subchannel* grpc_subchannel_ref_from_weak_ref(
+ grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ if (!c) return nullptr;
+ for (;;) {
+ gpr_atm old_refs = gpr_atm_acq_load(&c->ref_pair);
+ if (old_refs >= (1 << INTERNAL_REF_BITS)) {
+ gpr_atm new_refs = old_refs + (1 << INTERNAL_REF_BITS);
+ if (gpr_atm_rel_cas(&c->ref_pair, old_refs, new_refs)) {
+ return c;
+ }
+ } else {
+ return nullptr;
+ }
+ }
+}
+
+static void disconnect(grpc_subchannel* c) {
+ grpc_subchannel_index_unregister(c->key, c);
+ gpr_mu_lock(&c->mu);
+ GPR_ASSERT(!c->disconnected);
+ c->disconnected = true;
+ grpc_connector_shutdown(c->connector, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Subchannel disconnected"));
+ c->connected_subchannel.reset();
+ gpr_mu_unlock(&c->mu);
+}
+
+void grpc_subchannel_unref(grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ gpr_atm old_refs;
+ // add a weak ref and subtract a strong ref (atomically)
+ old_refs = ref_mutate(c, (gpr_atm)1 - (gpr_atm)(1 << INTERNAL_REF_BITS),
+ 1 REF_MUTATE_PURPOSE("STRONG_UNREF"));
+ if ((old_refs & STRONG_REF_MASK) == (1 << INTERNAL_REF_BITS)) {
+ disconnect(c);
+ }
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "strong-unref");
+}
+
+void grpc_subchannel_weak_unref(
+ grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ gpr_atm old_refs;
+ old_refs = ref_mutate(c, -(gpr_atm)1, 1 REF_MUTATE_PURPOSE("WEAK_UNREF"));
+ if (old_refs == 1) {
+ GRPC_CLOSURE_SCHED(
+ GRPC_CLOSURE_CREATE(subchannel_destroy, c, grpc_schedule_on_exec_ctx),
+ GRPC_ERROR_NONE);
+ }
+}
+
+static void parse_args_for_backoff_values(
+ const grpc_channel_args* args, grpc_core::BackOff::Options* backoff_options,
+ grpc_millis* min_connect_timeout_ms) {
+ grpc_millis initial_backoff_ms =
+ GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS * 1000;
+ *min_connect_timeout_ms =
+ GRPC_SUBCHANNEL_RECONNECT_MIN_TIMEOUT_SECONDS * 1000;
+ grpc_millis max_backoff_ms =
+ GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000;
+ bool fixed_reconnect_backoff = false;
+ if (args != nullptr) {
+ for (size_t i = 0; i < args->num_args; i++) {
+ if (0 == strcmp(args->args[i].key,
+ "grpc.testing.fixed_reconnect_backoff_ms")) {
+ fixed_reconnect_backoff = true;
+ initial_backoff_ms = *min_connect_timeout_ms = max_backoff_ms =
+ grpc_channel_arg_get_integer(
+ &args->args[i],
+ {static_cast<int>(initial_backoff_ms), 100, INT_MAX});
+ } else if (0 ==
+ strcmp(args->args[i].key, GRPC_ARG_MIN_RECONNECT_BACKOFF_MS)) {
+ fixed_reconnect_backoff = false;
+ *min_connect_timeout_ms = grpc_channel_arg_get_integer(
+ &args->args[i],
+ {static_cast<int>(*min_connect_timeout_ms), 100, INT_MAX});
+ } else if (0 ==
+ strcmp(args->args[i].key, GRPC_ARG_MAX_RECONNECT_BACKOFF_MS)) {
+ fixed_reconnect_backoff = false;
+ max_backoff_ms = grpc_channel_arg_get_integer(
+ &args->args[i], {static_cast<int>(max_backoff_ms), 100, INT_MAX});
+ } else if (0 == strcmp(args->args[i].key,
+ GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS)) {
+ fixed_reconnect_backoff = false;
+ initial_backoff_ms = grpc_channel_arg_get_integer(
+ &args->args[i],
+ {static_cast<int>(initial_backoff_ms), 100, INT_MAX});
+ }
+ }
+ }
+ backoff_options->set_initial_backoff(initial_backoff_ms)
+ .set_multiplier(fixed_reconnect_backoff
+ ? 1.0
+ : GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER)
+ .set_jitter(fixed_reconnect_backoff ? 0.0
+ : GRPC_SUBCHANNEL_RECONNECT_JITTER)
+ .set_max_backoff(max_backoff_ms);
+}
+
+grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
+ const grpc_subchannel_args* args) {
+ grpc_subchannel_key* key = grpc_subchannel_key_create(args);
+ grpc_subchannel* c = grpc_subchannel_index_find(key);
+ if (c) {
+ grpc_subchannel_key_destroy(key);
+ return c;
+ }
+
+ GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED();
+ c = (grpc_subchannel*)gpr_zalloc(sizeof(*c));
+ c->key = key;
+ gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS);
+ c->connector = connector;
+ grpc_connector_ref(c->connector);
+ c->num_filters = args->filter_count;
+ if (c->num_filters > 0) {
+ c->filters = (const grpc_channel_filter**)gpr_malloc(
+ sizeof(grpc_channel_filter*) * c->num_filters);
+ memcpy((void*)c->filters, args->filters,
+ sizeof(grpc_channel_filter*) * c->num_filters);
+ } else {
+ c->filters = nullptr;
+ }
+ c->pollset_set = grpc_pollset_set_create();
+ grpc_resolved_address* addr =
+ (grpc_resolved_address*)gpr_malloc(sizeof(*addr));
+ grpc_get_subchannel_address_arg(args->args, addr);
+ grpc_resolved_address* new_address = nullptr;
+ grpc_channel_args* new_args = nullptr;
+ if (grpc_proxy_mappers_map_address(addr, args->args, &new_address,
+ &new_args)) {
+ GPR_ASSERT(new_address != nullptr);
+ gpr_free(addr);
+ addr = new_address;
+ }
+ static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS};
+ grpc_arg new_arg = grpc_create_subchannel_address_arg(addr);
+ gpr_free(addr);
+ c->args = grpc_channel_args_copy_and_add_and_remove(
+ new_args != nullptr ? new_args : args->args, keys_to_remove,
+ GPR_ARRAY_SIZE(keys_to_remove), &new_arg, 1);
+ gpr_free(new_arg.value.string);
+ if (new_args != nullptr) grpc_channel_args_destroy(new_args);
+ c->root_external_state_watcher.next = c->root_external_state_watcher.prev =
+ &c->root_external_state_watcher;
+ GRPC_CLOSURE_INIT(&c->on_connected, on_subchannel_connected, c,
+ grpc_schedule_on_exec_ctx);
+ grpc_connectivity_state_init(&c->state_tracker, GRPC_CHANNEL_IDLE,
+ "subchannel");
+ grpc_core::BackOff::Options backoff_options;
+ parse_args_for_backoff_values(args->args, &backoff_options,
+ &c->min_connect_timeout_ms);
+ c->backoff.Init(backoff_options);
+ gpr_mu_init(&c->mu);
+
+ return grpc_subchannel_index_register(key, c);
+}
+
+static void continue_connect_locked(grpc_subchannel* c) {
+ grpc_connect_in_args args;
+ args.interested_parties = c->pollset_set;
+ const grpc_millis min_deadline =
+ c->min_connect_timeout_ms + grpc_core::ExecCtx::Get()->Now();
+ c->next_attempt_deadline = c->backoff->NextAttemptTime();
+ args.deadline = std::max(c->next_attempt_deadline, min_deadline);
+ args.channel_args = c->args;
+ grpc_connectivity_state_set(&c->state_tracker, GRPC_CHANNEL_CONNECTING,
+ GRPC_ERROR_NONE, "state_change");
+ grpc_connector_connect(c->connector, &args, &c->connecting_result,
+ &c->on_connected);
+}
+
+grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel* c,
+ grpc_error** error) {
+ grpc_connectivity_state state;
+ gpr_mu_lock(&c->mu);
+ state = grpc_connectivity_state_get(&c->state_tracker, error);
+ gpr_mu_unlock(&c->mu);
+ return state;
+}
+
+static void on_external_state_watcher_done(void* arg, grpc_error* error) {
+ external_state_watcher* w = (external_state_watcher*)arg;
+ grpc_closure* follow_up = w->notify;
+ if (w->pollset_set != nullptr) {
+ grpc_pollset_set_del_pollset_set(w->subchannel->pollset_set,
+ w->pollset_set);
+ }
+ gpr_mu_lock(&w->subchannel->mu);
+ w->next->prev = w->prev;
+ w->prev->next = w->next;
+ gpr_mu_unlock(&w->subchannel->mu);
+ GRPC_SUBCHANNEL_WEAK_UNREF(w->subchannel, "external_state_watcher");
+ gpr_free(w);
+ GRPC_CLOSURE_RUN(follow_up, GRPC_ERROR_REF(error));
+}
+
+static void on_alarm(void* arg, grpc_error* error) {
+ grpc_subchannel* c = (grpc_subchannel*)arg;
+ gpr_mu_lock(&c->mu);
+ c->have_alarm = false;
+ if (c->disconnected) {
+ error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Disconnected",
+ &error, 1);
+ } else {
+ GRPC_ERROR_REF(error);
+ }
+ if (error == GRPC_ERROR_NONE) {
+ gpr_log(GPR_INFO, "Failed to connect to channel, retrying");
+ continue_connect_locked(c);
+ gpr_mu_unlock(&c->mu);
+ } else {
+ gpr_mu_unlock(&c->mu);
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
+ }
+ GRPC_ERROR_UNREF(error);
+}
+
+static void maybe_start_connecting_locked(grpc_subchannel* c) {
+ if (c->disconnected) {
+ /* Don't try to connect if we're already disconnected */
+ return;
+ }
+
+ if (c->connecting) {
+ /* Already connecting: don't restart */
+ return;
+ }
+
+ if (c->connected_subchannel != nullptr) {
+ /* Already connected: don't restart */
+ return;
+ }
+
+ if (!grpc_connectivity_state_has_watchers(&c->state_tracker)) {
+ /* Nobody is interested in connecting: so don't just yet */
+ return;
+ }
+
+ c->connecting = true;
+ GRPC_SUBCHANNEL_WEAK_REF(c, "connecting");
+
+ if (!c->backoff_begun) {
+ c->backoff_begun = true;
+ continue_connect_locked(c);
+ } else {
+ GPR_ASSERT(!c->have_alarm);
+ c->have_alarm = true;
+ const grpc_millis time_til_next =
+ c->next_attempt_deadline - grpc_core::ExecCtx::Get()->Now();
+ if (time_til_next <= 0) {
+ gpr_log(GPR_INFO, "Subchannel %p: Retry immediately", c);
+ } else {
+ gpr_log(GPR_INFO, "Subchannel %p: Retry in %" PRIdPTR " milliseconds", c,
+ time_til_next);
+ }
+ GRPC_CLOSURE_INIT(&c->on_alarm, on_alarm, c, grpc_schedule_on_exec_ctx);
+ grpc_timer_init(&c->alarm, c->next_attempt_deadline, &c->on_alarm);
+ }
+}
+
+void grpc_subchannel_notify_on_state_change(
+ grpc_subchannel* c, grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state, grpc_closure* notify) {
+ external_state_watcher* w;
+
+ if (state == nullptr) {
+ gpr_mu_lock(&c->mu);
+ for (w = c->root_external_state_watcher.next;
+ w != &c->root_external_state_watcher; w = w->next) {
+ if (w->notify == notify) {
+ grpc_connectivity_state_notify_on_state_change(&c->state_tracker,
+ nullptr, &w->closure);
+ }
+ }
+ gpr_mu_unlock(&c->mu);
+ } else {
+ w = (external_state_watcher*)gpr_malloc(sizeof(*w));
+ w->subchannel = c;
+ w->pollset_set = interested_parties;
+ w->notify = notify;
+ GRPC_CLOSURE_INIT(&w->closure, on_external_state_watcher_done, w,
+ grpc_schedule_on_exec_ctx);
+ if (interested_parties != nullptr) {
+ grpc_pollset_set_add_pollset_set(c->pollset_set, interested_parties);
+ }
+ GRPC_SUBCHANNEL_WEAK_REF(c, "external_state_watcher");
+ gpr_mu_lock(&c->mu);
+ w->next = &c->root_external_state_watcher;
+ w->prev = w->next->prev;
+ w->next->prev = w->prev->next = w;
+ grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state,
+ &w->closure);
+ maybe_start_connecting_locked(c);
+ gpr_mu_unlock(&c->mu);
+ }
+}
+
+static void on_connected_subchannel_connectivity_changed(void* p,
+ grpc_error* error) {
+ state_watcher* connected_subchannel_watcher = (state_watcher*)p;
+ grpc_subchannel* c = connected_subchannel_watcher->subchannel;
+ gpr_mu* mu = &c->mu;
+
+ gpr_mu_lock(mu);
+
+ switch (connected_subchannel_watcher->connectivity_state) {
+ case GRPC_CHANNEL_TRANSIENT_FAILURE:
+ case GRPC_CHANNEL_SHUTDOWN: {
+ if (!c->disconnected && c->connected_subchannel != nullptr) {
+ if (grpc_trace_stream_refcount.enabled()) {
+ gpr_log(GPR_INFO,
+ "Connected subchannel %p of subchannel %p has gone into %s. "
+ "Attempting to reconnect.",
+ c->connected_subchannel.get(), c,
+ grpc_connectivity_state_name(
+ connected_subchannel_watcher->connectivity_state));
+ }
+ c->connected_subchannel.reset();
+ grpc_connectivity_state_set(&c->state_tracker,
+ GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(error), "reflect_child");
+ c->backoff_begun = false;
+ c->backoff->Reset();
+ maybe_start_connecting_locked(c);
+ } else {
+ connected_subchannel_watcher->connectivity_state =
+ GRPC_CHANNEL_SHUTDOWN;
+ }
+ break;
+ }
+ default: {
+ grpc_connectivity_state_set(
+ &c->state_tracker, connected_subchannel_watcher->connectivity_state,
+ GRPC_ERROR_REF(error), "reflect_child");
+ GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
+ c->connected_subchannel->NotifyOnStateChange(
+ nullptr, &connected_subchannel_watcher->connectivity_state,
+ &connected_subchannel_watcher->closure);
+ connected_subchannel_watcher = nullptr;
+ }
+ }
+ gpr_mu_unlock(mu);
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "state_watcher");
+ gpr_free(connected_subchannel_watcher);
+}
+
+static bool publish_transport_locked(grpc_subchannel* c) {
+ /* construct channel stack */
+ grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder_set_channel_arguments(
+ builder, c->connecting_result.channel_args);
+ grpc_channel_stack_builder_set_transport(builder,
+ c->connecting_result.transport);
+
+ if (!grpc_channel_init_create_stack(builder, GRPC_CLIENT_SUBCHANNEL)) {
+ grpc_channel_stack_builder_destroy(builder);
+ return false;
+ }
+ grpc_channel_stack* stk;
+ grpc_error* error = grpc_channel_stack_builder_finish(
+ builder, 0, 1, connection_destroy, nullptr, (void**)&stk);
+ if (error != GRPC_ERROR_NONE) {
+ grpc_transport_destroy(c->connecting_result.transport);
+ gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
+ grpc_error_string(error));
+ GRPC_ERROR_UNREF(error);
+ return false;
+ }
+ memset(&c->connecting_result, 0, sizeof(c->connecting_result));
+
+ /* initialize state watcher */
+ state_watcher* connected_subchannel_watcher =
+ (state_watcher*)gpr_zalloc(sizeof(*connected_subchannel_watcher));
+ connected_subchannel_watcher->subchannel = c;
+ connected_subchannel_watcher->connectivity_state = GRPC_CHANNEL_READY;
+ GRPC_CLOSURE_INIT(&connected_subchannel_watcher->closure,
+ on_connected_subchannel_connectivity_changed,
+ connected_subchannel_watcher, grpc_schedule_on_exec_ctx);
+
+ if (c->disconnected) {
+ gpr_free(connected_subchannel_watcher);
+ grpc_channel_stack_destroy(stk);
+ gpr_free(stk);
+ return false;
+ }
+
+ /* publish */
+ c->connected_subchannel.reset(
+ grpc_core::New<grpc_core::ConnectedSubchannel>(stk));
+ gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p",
+ c->connected_subchannel.get(), c);
+
+ /* setup subchannel watching connected subchannel for changes; subchannel
+ ref for connecting is donated to the state watcher */
+ GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
+ c->connected_subchannel->NotifyOnStateChange(
+ c->pollset_set, &connected_subchannel_watcher->connectivity_state,
+ &connected_subchannel_watcher->closure);
+
+ /* signal completion */
+ grpc_connectivity_state_set(&c->state_tracker, GRPC_CHANNEL_READY,
+ GRPC_ERROR_NONE, "connected");
+ return true;
+}
+
+static void on_subchannel_connected(void* arg, grpc_error* error) {
+ grpc_subchannel* c = (grpc_subchannel*)arg;
+ grpc_channel_args* delete_channel_args = c->connecting_result.channel_args;
+
+ GRPC_SUBCHANNEL_WEAK_REF(c, "on_subchannel_connected");
+ gpr_mu_lock(&c->mu);
+ c->connecting = false;
+ if (c->connecting_result.transport != nullptr &&
+ publish_transport_locked(c)) {
+ /* do nothing, transport was published */
+ } else if (c->disconnected) {
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
+ } else {
+ grpc_connectivity_state_set(
+ &c->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Connect Failed", &error, 1),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
+ "connect_failed");
+
+ const char* errmsg = grpc_error_string(error);
+ gpr_log(GPR_INFO, "Connect failed: %s", errmsg);
+
+ maybe_start_connecting_locked(c);
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
+ }
+ gpr_mu_unlock(&c->mu);
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connected");
+ grpc_channel_args_destroy(delete_channel_args);
+}
+
+/*
+ * grpc_subchannel_call implementation
+ */
+
+static void subchannel_call_destroy(void* call, grpc_error* error) {
+ grpc_subchannel_call* c = (grpc_subchannel_call*)call;
+ GPR_ASSERT(c->schedule_closure_after_destroy != nullptr);
+ GPR_TIMER_BEGIN("grpc_subchannel_call_unref.destroy", 0);
+ grpc_core::ConnectedSubchannel* connection = c->connection;
+ grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c), nullptr,
+ c->schedule_closure_after_destroy);
+ connection->Unref(DEBUG_LOCATION, "subchannel_call");
+ GPR_TIMER_END("grpc_subchannel_call_unref.destroy", 0);
+}
+
+void grpc_subchannel_call_set_cleanup_closure(grpc_subchannel_call* call,
+ grpc_closure* closure) {
+ GPR_ASSERT(call->schedule_closure_after_destroy == nullptr);
+ GPR_ASSERT(closure != nullptr);
+ call->schedule_closure_after_destroy = closure;
+}
+
+void grpc_subchannel_call_ref(
+ grpc_subchannel_call* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
+}
+
+void grpc_subchannel_call_unref(
+ grpc_subchannel_call* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ GRPC_CALL_STACK_UNREF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
+}
+
+void grpc_subchannel_call_process_op(grpc_subchannel_call* call,
+ grpc_transport_stream_op_batch* batch) {
+ GPR_TIMER_BEGIN("grpc_subchannel_call_process_op", 0);
+ grpc_call_stack* call_stack = SUBCHANNEL_CALL_TO_CALL_STACK(call);
+ grpc_call_element* top_elem = grpc_call_stack_element(call_stack, 0);
+ GRPC_CALL_LOG_OP(GPR_INFO, top_elem, batch);
+ top_elem->filter->start_transport_stream_op_batch(top_elem, batch);
+ GPR_TIMER_END("grpc_subchannel_call_process_op", 0);
+}
+
+grpc_core::RefCountedPtr<grpc_core::ConnectedSubchannel>
+grpc_subchannel_get_connected_subchannel(grpc_subchannel* c) {
+ gpr_mu_lock(&c->mu);
+ auto copy = c->connected_subchannel;
+ gpr_mu_unlock(&c->mu);
+ return copy;
+}
+
+const grpc_subchannel_key* grpc_subchannel_get_key(
+ const grpc_subchannel* subchannel) {
+ return subchannel->key;
+}
+
+grpc_call_stack* grpc_subchannel_call_get_call_stack(
+ grpc_subchannel_call* subchannel_call) {
+ return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call);
+}
+
+static void grpc_uri_to_sockaddr(const char* uri_str,
+ grpc_resolved_address* addr) {
+ grpc_uri* uri = grpc_uri_parse(uri_str, 0 /* suppress_errors */);
+ GPR_ASSERT(uri != nullptr);
+ if (!grpc_parse_uri(uri, addr)) memset(addr, 0, sizeof(*addr));
+ grpc_uri_destroy(uri);
+}
+
+void grpc_get_subchannel_address_arg(const grpc_channel_args* args,
+ grpc_resolved_address* addr) {
+ const char* addr_uri_str = grpc_get_subchannel_address_uri_arg(args);
+ memset(addr, 0, sizeof(*addr));
+ if (*addr_uri_str != '\0') {
+ grpc_uri_to_sockaddr(addr_uri_str, addr);
+ }
+}
+
+const char* grpc_get_subchannel_address_uri_arg(const grpc_channel_args* args) {
+ const grpc_arg* addr_arg =
+ grpc_channel_args_find(args, GRPC_ARG_SUBCHANNEL_ADDRESS);
+ GPR_ASSERT(addr_arg != nullptr); // Should have been set by LB policy.
+ GPR_ASSERT(addr_arg->type == GRPC_ARG_STRING);
+ return addr_arg->value.string;
+}
+
+grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address* addr) {
+ return grpc_channel_arg_string_create(
+ (char*)GRPC_ARG_SUBCHANNEL_ADDRESS,
+ addr->len > 0 ? grpc_sockaddr_to_uri(addr) : gpr_strdup(""));
+}
+
+namespace grpc_core {
+ConnectedSubchannel::ConnectedSubchannel(grpc_channel_stack* channel_stack)
+ : grpc_core::RefCountedWithTracing(&grpc_trace_stream_refcount),
+ channel_stack_(channel_stack) {}
+
+ConnectedSubchannel::~ConnectedSubchannel() {
+ GRPC_CHANNEL_STACK_UNREF(channel_stack_, "connected_subchannel_dtor");
+}
+
+void ConnectedSubchannel::NotifyOnStateChange(
+ grpc_pollset_set* interested_parties, grpc_connectivity_state* state,
+ grpc_closure* closure) {
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ grpc_channel_element* elem;
+ op->connectivity_state = state;
+ op->on_connectivity_state_change = closure;
+ op->bind_pollset_set = interested_parties;
+ elem = grpc_channel_stack_element(channel_stack_, 0);
+ elem->filter->start_transport_op(elem, op);
+}
+
+void ConnectedSubchannel::Ping(grpc_closure* on_initiate,
+ grpc_closure* on_ack) {
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ grpc_channel_element* elem;
+ op->send_ping.on_initiate = on_initiate;
+ op->send_ping.on_ack = on_ack;
+ elem = grpc_channel_stack_element(channel_stack_, 0);
+ elem->filter->start_transport_op(elem, op);
+}
+
+grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args,
+ grpc_subchannel_call** call) {
+ *call = (grpc_subchannel_call*)gpr_arena_alloc(
+ 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");
+ (*call)->connection = this;
+ const grpc_call_element_args call_args = {
+ callstk, /* call_stack */
+ nullptr, /* server_transport_data */
+ args.context, /* context */
+ args.path, /* path */
+ args.start_time, /* start_time */
+ args.deadline, /* deadline */
+ args.arena, /* arena */
+ args.call_combiner /* call_combiner */
+ };
+ grpc_error* error = grpc_call_stack_init(
+ channel_stack_, 1, subchannel_call_destroy, *call, &call_args);
+ if (error != GRPC_ERROR_NONE) {
+ const char* error_string = grpc_error_string(error);
+ gpr_log(GPR_ERROR, "error: %s", error_string);
+ return error;
+ }
+ 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 51d712f6a7..b7593ec911 100644
--- a/src/core/ext/filters/client_channel/subchannel.h
+++ b/src/core/ext/filters/client_channel/subchannel.h
@@ -21,8 +21,10 @@
#include "src/core/ext/filters/client_channel/connector.h"
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/gpr/arena.h"
+#include "src/core/lib/gprpp/ref_counted.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/polling_entity.h"
-#include "src/core/lib/support/arena.h"
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/metadata.h"
@@ -32,7 +34,6 @@
/** A (sub-)channel that knows how to connect to exactly one target
address. Provides a target for load balancing. */
typedef struct grpc_subchannel grpc_subchannel;
-typedef struct grpc_connected_subchannel grpc_connected_subchannel;
typedef struct grpc_subchannel_call grpc_subchannel_call;
typedef struct grpc_subchannel_args grpc_subchannel_args;
typedef struct grpc_subchannel_key grpc_subchannel_key;
@@ -42,150 +43,130 @@ typedef struct grpc_subchannel_key grpc_subchannel_key;
grpc_subchannel_ref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(p, r) \
grpc_subchannel_ref_from_weak_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SUBCHANNEL_UNREF(cl, p, r) \
- grpc_subchannel_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_SUBCHANNEL_UNREF(p, r) \
+ grpc_subchannel_unref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_WEAK_REF(p, r) \
grpc_subchannel_weak_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SUBCHANNEL_WEAK_UNREF(cl, p, r) \
- grpc_subchannel_weak_unref((cl), (p), __FILE__, __LINE__, (r))
-#define GRPC_CONNECTED_SUBCHANNEL_REF(p, r) \
- grpc_connected_subchannel_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_CONNECTED_SUBCHANNEL_UNREF(cl, p, r) \
- grpc_connected_subchannel_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_SUBCHANNEL_WEAK_UNREF(p, r) \
+ grpc_subchannel_weak_unref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_CALL_REF(p, r) \
grpc_subchannel_call_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SUBCHANNEL_CALL_UNREF(cl, p, r) \
- grpc_subchannel_call_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) \
+ grpc_subchannel_call_unref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS \
, const char *file, int line, const char *reason
#else
#define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p))
#define GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(p, r) \
grpc_subchannel_ref_from_weak_ref((p))
-#define GRPC_SUBCHANNEL_UNREF(cl, p, r) grpc_subchannel_unref((cl), (p))
+#define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p))
#define GRPC_SUBCHANNEL_WEAK_REF(p, r) grpc_subchannel_weak_ref((p))
-#define GRPC_SUBCHANNEL_WEAK_UNREF(cl, p, r) \
- grpc_subchannel_weak_unref((cl), (p))
-#define GRPC_CONNECTED_SUBCHANNEL_REF(p, r) grpc_connected_subchannel_ref((p))
-#define GRPC_CONNECTED_SUBCHANNEL_UNREF(cl, p, r) \
- grpc_connected_subchannel_unref((cl), (p))
+#define GRPC_SUBCHANNEL_WEAK_UNREF(p, r) grpc_subchannel_weak_unref((p))
#define GRPC_SUBCHANNEL_CALL_REF(p, r) grpc_subchannel_call_ref((p))
-#define GRPC_SUBCHANNEL_CALL_UNREF(cl, p, r) \
- grpc_subchannel_call_unref((cl), (p))
+#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) grpc_subchannel_call_unref((p))
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS
#endif
-grpc_subchannel *grpc_subchannel_ref(
- grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-grpc_subchannel *grpc_subchannel_ref_from_weak_ref(
- grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-grpc_subchannel *grpc_subchannel_weak_ref(
- grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_weak_unref(grpc_exec_ctx *exec_ctx,
- grpc_subchannel *channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-grpc_connected_subchannel *grpc_connected_subchannel_ref(
- grpc_connected_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_connected_subchannel_unref(grpc_exec_ctx *exec_ctx,
- grpc_connected_subchannel *channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+namespace grpc_core {
+class ConnectedSubchannel : public grpc_core::RefCountedWithTracing {
+ public:
+ struct CallArgs {
+ grpc_polling_entity* pollent;
+ grpc_slice path;
+ gpr_timespec start_time;
+ grpc_millis deadline;
+ gpr_arena* arena;
+ grpc_call_context_element* context;
+ grpc_call_combiner* call_combiner;
+ };
+
+ explicit ConnectedSubchannel(grpc_channel_stack* channel_stack);
+ ~ConnectedSubchannel();
+
+ grpc_channel_stack* channel_stack() { return channel_stack_; }
+ void NotifyOnStateChange(grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state,
+ grpc_closure* closure);
+ void Ping(grpc_closure* on_initiate, grpc_closure* on_ack);
+ grpc_error* CreateCall(const CallArgs& args, grpc_subchannel_call** call);
+
+ private:
+ grpc_channel_stack* channel_stack_;
+};
+} // namespace grpc_core
+
+grpc_subchannel* grpc_subchannel_ref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+grpc_subchannel* grpc_subchannel_ref_from_weak_ref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_unref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+grpc_subchannel* grpc_subchannel_weak_ref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_weak_unref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_call_ref(
- grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_call *call
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-
-/** construct a subchannel call */
-typedef struct {
- grpc_polling_entity *pollent;
- grpc_slice path;
- gpr_timespec start_time;
- gpr_timespec deadline;
- gpr_arena *arena;
- grpc_call_context_element *context;
- grpc_call_combiner *call_combiner;
-} grpc_connected_subchannel_call_args;
-
-grpc_error *grpc_connected_subchannel_create_call(
- grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *connected_subchannel,
- const grpc_connected_subchannel_call_args *args,
- grpc_subchannel_call **subchannel_call);
-
-/** process a transport level op */
-void grpc_connected_subchannel_process_transport_op(
- grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *subchannel,
- grpc_transport_op *op);
+ grpc_subchannel_call* call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_call_unref(
+ grpc_subchannel_call* call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
/** poll the current connectivity state of a channel */
grpc_connectivity_state grpc_subchannel_check_connectivity(
- grpc_subchannel *channel, grpc_error **error);
+ grpc_subchannel* channel, grpc_error** error);
-/** call notify when the connectivity state of a channel changes from *state.
- Updates *state with the new state of the channel */
+/** Calls notify when the connectivity state of a channel becomes different
+ from *state. Updates *state with the new state of the channel. */
void grpc_subchannel_notify_on_state_change(
- grpc_exec_ctx *exec_ctx, grpc_subchannel *channel,
- grpc_pollset_set *interested_parties, grpc_connectivity_state *state,
- grpc_closure *notify);
-void grpc_connected_subchannel_notify_on_state_change(
- grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *channel,
- grpc_pollset_set *interested_parties, grpc_connectivity_state *state,
- grpc_closure *notify);
-void grpc_connected_subchannel_ping(grpc_exec_ctx *exec_ctx,
- grpc_connected_subchannel *channel,
- grpc_closure *notify);
-
-/** retrieve the grpc_connected_subchannel - or NULL if called before
- the subchannel becomes connected */
-grpc_connected_subchannel *grpc_subchannel_get_connected_subchannel(
- grpc_subchannel *subchannel);
+ grpc_subchannel* channel, grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state, grpc_closure* notify);
+
+/** retrieve the grpc_core::ConnectedSubchannel - or nullptr if not connected
+ * (which may happen before it initially connects or during transient failures)
+ * */
+grpc_core::RefCountedPtr<grpc_core::ConnectedSubchannel>
+grpc_subchannel_get_connected_subchannel(grpc_subchannel* c);
/** return the subchannel index key for \a subchannel */
-const grpc_subchannel_key *grpc_subchannel_get_key(
- const grpc_subchannel *subchannel);
+const grpc_subchannel_key* grpc_subchannel_get_key(
+ const grpc_subchannel* subchannel);
/** continue processing a transport op */
-void grpc_subchannel_call_process_op(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_call *subchannel_call,
- grpc_transport_stream_op_batch *op);
+void grpc_subchannel_call_process_op(grpc_subchannel_call* subchannel_call,
+ grpc_transport_stream_op_batch* op);
/** Must be called once per call. Sets the 'then_schedule_closure' argument for
call stack destruction. */
void grpc_subchannel_call_set_cleanup_closure(
- grpc_subchannel_call *subchannel_call, grpc_closure *closure);
+ grpc_subchannel_call* subchannel_call, grpc_closure* closure);
-grpc_call_stack *grpc_subchannel_call_get_call_stack(
- grpc_subchannel_call *subchannel_call);
+grpc_call_stack* grpc_subchannel_call_get_call_stack(
+ grpc_subchannel_call* subchannel_call);
struct grpc_subchannel_args {
/* When updating this struct, also update subchannel_index.c */
/** Channel filters for this channel - wrapped factories will likely
want to mutate this */
- const grpc_channel_filter **filters;
+ const grpc_channel_filter** filters;
/** The number of filters in the above array */
size_t filter_count;
/** Channel arguments to be supplied to the newly created channel */
- const grpc_channel_args *args;
+ const grpc_channel_args* args;
};
/** create a subchannel given a connector */
-grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
- grpc_connector *connector,
- const grpc_subchannel_args *args);
+grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
+ const grpc_subchannel_args* args);
/// Sets \a addr from \a args.
-void grpc_get_subchannel_address_arg(grpc_exec_ctx *exec_ctx,
- const grpc_channel_args *args,
- grpc_resolved_address *addr);
+void grpc_get_subchannel_address_arg(const grpc_channel_args* args,
+ grpc_resolved_address* addr);
/// Returns the URI string for the address to connect to.
-const char *grpc_get_subchannel_address_uri_arg(const grpc_channel_args *args);
+const char* grpc_get_subchannel_address_uri_arg(const grpc_channel_args* args);
/// Returns a new channel arg encoding the subchannel address as a string.
/// Caller is responsible for freeing the string.
-grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address *addr);
+grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address* addr);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_H */
diff --git a/src/core/ext/filters/client_channel/subchannel_index.c b/src/core/ext/filters/client_channel/subchannel_index.cc
index d7a51f3899..052b047f43 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.c
+++ b/src/core/ext/filters/client_channel/subchannel_index.cc
@@ -42,34 +42,34 @@ struct grpc_subchannel_key {
static bool g_force_creation = false;
-static grpc_subchannel_key *create_key(
- const grpc_subchannel_args *args,
- grpc_channel_args *(*copy_channel_args)(const grpc_channel_args *args)) {
- grpc_subchannel_key *k = (grpc_subchannel_key *)gpr_malloc(sizeof(*k));
+static grpc_subchannel_key* create_key(
+ const grpc_subchannel_args* args,
+ grpc_channel_args* (*copy_channel_args)(const grpc_channel_args* args)) {
+ grpc_subchannel_key* k = (grpc_subchannel_key*)gpr_malloc(sizeof(*k));
k->args.filter_count = args->filter_count;
if (k->args.filter_count > 0) {
- k->args.filters = (const grpc_channel_filter **)gpr_malloc(
+ k->args.filters = (const grpc_channel_filter**)gpr_malloc(
sizeof(*k->args.filters) * k->args.filter_count);
- memcpy((grpc_channel_filter *)k->args.filters, args->filters,
+ memcpy((grpc_channel_filter*)k->args.filters, args->filters,
sizeof(*k->args.filters) * k->args.filter_count);
} else {
- k->args.filters = NULL;
+ k->args.filters = nullptr;
}
k->args.args = copy_channel_args(args->args);
return k;
}
-grpc_subchannel_key *grpc_subchannel_key_create(
- const grpc_subchannel_args *args) {
+grpc_subchannel_key* grpc_subchannel_key_create(
+ const grpc_subchannel_args* args) {
return create_key(args, grpc_channel_args_normalize);
}
-static grpc_subchannel_key *subchannel_key_copy(grpc_subchannel_key *k) {
+static grpc_subchannel_key* subchannel_key_copy(grpc_subchannel_key* k) {
return create_key(&k->args, grpc_channel_args_copy);
}
-int grpc_subchannel_key_compare(const grpc_subchannel_key *a,
- const grpc_subchannel_key *b) {
+int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
+ const grpc_subchannel_key* b) {
if (g_force_creation) return false;
int c = GPR_ICMP(a->args.filter_count, b->args.filter_count);
if (c != 0) return c;
@@ -81,44 +81,41 @@ int grpc_subchannel_key_compare(const grpc_subchannel_key *a,
return grpc_channel_args_compare(a->args.args, b->args.args);
}
-void grpc_subchannel_key_destroy(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *k) {
- gpr_free((grpc_channel_args *)k->args.filters);
- grpc_channel_args_destroy(exec_ctx, (grpc_channel_args *)k->args.args);
+void grpc_subchannel_key_destroy(grpc_subchannel_key* k) {
+ gpr_free((grpc_channel_args*)k->args.filters);
+ grpc_channel_args_destroy((grpc_channel_args*)k->args.args);
gpr_free(k);
}
-static void sck_avl_destroy(void *p, void *user_data) {
- grpc_exec_ctx *exec_ctx = (grpc_exec_ctx *)user_data;
- grpc_subchannel_key_destroy(exec_ctx, (grpc_subchannel_key *)p);
+static void sck_avl_destroy(void* p, void* user_data) {
+ grpc_subchannel_key_destroy((grpc_subchannel_key*)p);
}
-static void *sck_avl_copy(void *p, void *unused) {
- return subchannel_key_copy((grpc_subchannel_key *)p);
+static void* sck_avl_copy(void* p, void* unused) {
+ return subchannel_key_copy((grpc_subchannel_key*)p);
}
-static long sck_avl_compare(void *a, void *b, void *unused) {
- return grpc_subchannel_key_compare((grpc_subchannel_key *)a,
- (grpc_subchannel_key *)b);
+static long sck_avl_compare(void* a, void* b, void* unused) {
+ return grpc_subchannel_key_compare((grpc_subchannel_key*)a,
+ (grpc_subchannel_key*)b);
}
-static void scv_avl_destroy(void *p, void *user_data) {
- grpc_exec_ctx *exec_ctx = (grpc_exec_ctx *)user_data;
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, (grpc_subchannel *)p,
- "subchannel_index");
+static void scv_avl_destroy(void* p, void* user_data) {
+ GRPC_SUBCHANNEL_WEAK_UNREF((grpc_subchannel*)p, "subchannel_index");
}
-static void *scv_avl_copy(void *p, void *unused) {
- GRPC_SUBCHANNEL_WEAK_REF((grpc_subchannel *)p, "subchannel_index");
+static void* scv_avl_copy(void* p, void* unused) {
+ GRPC_SUBCHANNEL_WEAK_REF((grpc_subchannel*)p, "subchannel_index");
return p;
}
static const gpr_avl_vtable subchannel_avl_vtable = {
- .destroy_key = sck_avl_destroy,
- .copy_key = sck_avl_copy,
- .compare_keys = sck_avl_compare,
- .destroy_value = scv_avl_destroy,
- .copy_value = scv_avl_copy};
+ sck_avl_destroy, // destroy_key
+ sck_avl_copy, // copy_key
+ sck_avl_compare, // compare_keys
+ scv_avl_destroy, // destroy_value
+ scv_avl_copy // copy_value
+};
void grpc_subchannel_index_init(void) {
g_subchannel_index = gpr_avl_create(&subchannel_avl_vtable);
@@ -135,58 +132,57 @@ void grpc_subchannel_index_shutdown(void) {
void grpc_subchannel_index_unref(void) {
if (gpr_unref(&g_refcount)) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_destroy(&g_mu);
- gpr_avl_unref(g_subchannel_index, &exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ gpr_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get());
}
}
void grpc_subchannel_index_ref(void) { gpr_ref_non_zero(&g_refcount); }
-grpc_subchannel *grpc_subchannel_index_find(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key) {
+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, exec_ctx);
+ gpr_avl index = gpr_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, exec_ctx), "index_find");
- gpr_avl_unref(index, exec_ctx);
+ grpc_subchannel* c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(
+ (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get()),
+ "index_find");
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
return c;
}
-grpc_subchannel *grpc_subchannel_index_register(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key,
- grpc_subchannel *constructed) {
- grpc_subchannel *c = NULL;
- bool need_to_unref_constructed;
+grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
+ grpc_subchannel* constructed) {
+ grpc_subchannel* c = nullptr;
+ bool need_to_unref_constructed = false;
- while (c == NULL) {
+ while (c == nullptr) {
need_to_unref_constructed = false;
// 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, exec_ctx);
+ gpr_avl index = gpr_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, exec_ctx);
- if (c != NULL) {
+ c = (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get());
+ if (c != nullptr) {
c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register");
}
- if (c != NULL) {
+ if (c != nullptr) {
// yes -> we're done
need_to_unref_constructed = true;
} else {
// no -> update the avl and compare/swap
- gpr_avl updated = gpr_avl_add(
- gpr_avl_ref(index, exec_ctx), subchannel_key_copy(key),
- GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"), exec_ctx);
+ gpr_avl updated =
+ gpr_avl_add(gpr_avl_ref(index, grpc_core::ExecCtx::Get()),
+ subchannel_key_copy(key),
+ GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"),
+ grpc_core::ExecCtx::Get());
// it may happen (but it's expected to be unlikely)
// that some other thread has changed the index:
@@ -198,41 +194,42 @@ grpc_subchannel *grpc_subchannel_index_register(grpc_exec_ctx *exec_ctx,
}
gpr_mu_unlock(&g_mu);
- gpr_avl_unref(updated, exec_ctx);
+ gpr_avl_unref(updated, grpc_core::ExecCtx::Get());
}
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
}
if (need_to_unref_constructed) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, constructed, "index_register");
+ GRPC_SUBCHANNEL_UNREF(constructed, "index_register");
}
return c;
}
-void grpc_subchannel_index_unregister(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key,
- grpc_subchannel *constructed) {
+void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
+ grpc_subchannel* constructed) {
bool done = false;
while (!done) {
// 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, exec_ctx);
+ gpr_avl index = gpr_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, exec_ctx);
+ grpc_subchannel* c =
+ (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get());
if (c != constructed) {
- gpr_avl_unref(index, exec_ctx);
+ gpr_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, exec_ctx), key, exec_ctx);
+ gpr_avl_remove(gpr_avl_ref(index, grpc_core::ExecCtx::Get()), key,
+ grpc_core::ExecCtx::Get());
gpr_mu_lock(&g_mu);
if (index.root == g_subchannel_index.root) {
@@ -241,8 +238,8 @@ void grpc_subchannel_index_unregister(grpc_exec_ctx *exec_ctx,
}
gpr_mu_unlock(&g_mu);
- gpr_avl_unref(updated, exec_ctx);
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(updated, grpc_core::ExecCtx::Get());
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
}
}
diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h
index 92e36d5283..bd160a3b13 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.h
+++ b/src/core/ext/filters/client_channel/subchannel_index.h
@@ -25,34 +25,30 @@
shared amongst channels */
/** Create a key that can be used to uniquely identify a subchannel */
-grpc_subchannel_key *grpc_subchannel_key_create(
- const grpc_subchannel_args *args);
+grpc_subchannel_key* grpc_subchannel_key_create(
+ const grpc_subchannel_args* args);
/** Destroy a subchannel key */
-void grpc_subchannel_key_destroy(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key);
+void grpc_subchannel_key_destroy(grpc_subchannel_key* key);
/** Given a subchannel key, find the subchannel registered for it.
Returns NULL if no such channel exists.
Thread-safe. */
-grpc_subchannel *grpc_subchannel_index_find(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key);
+grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key);
/** Register a subchannel against a key.
Takes ownership of \a constructed.
Returns the registered subchannel. This may be different from
\a constructed in the case of a registration race. */
-grpc_subchannel *grpc_subchannel_index_register(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key,
- grpc_subchannel *constructed);
+grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
+ grpc_subchannel* constructed);
/** Remove \a constructed as the registered subchannel for \a key. */
-void grpc_subchannel_index_unregister(grpc_exec_ctx *exec_ctx,
- grpc_subchannel_key *key,
- grpc_subchannel *constructed);
+void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
+ grpc_subchannel* constructed);
-int grpc_subchannel_key_compare(const grpc_subchannel_key *a,
- const grpc_subchannel_key *b);
+int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
+ const grpc_subchannel_key* b);
/** Initialize the subchannel index (global) */
void grpc_subchannel_index_init(void);
diff --git a/src/core/ext/filters/client_channel/uri_parser.c b/src/core/ext/filters/client_channel/uri_parser.cc
index fb4fb8e694..c5f2d6822c 100644
--- a/src/core/ext/filters/client_channel/uri_parser.c
+++ b/src/core/ext/filters/client_channel/uri_parser.cc
@@ -26,17 +26,17 @@
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/percent_encoding.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
/** a size_t default value... maps to all 1's */
#define NOT_SET (~(size_t)0)
-static grpc_uri *bad_uri(const char *uri_text, size_t pos, const char *section,
+static grpc_uri* bad_uri(const char* uri_text, size_t pos, const char* section,
bool suppress_errors) {
- char *line_prefix;
+ char* line_prefix;
size_t pfx_len;
if (!suppress_errors) {
@@ -45,26 +45,28 @@ static grpc_uri *bad_uri(const char *uri_text, size_t pos, const char *section,
gpr_log(GPR_ERROR, "%s%s'", line_prefix, uri_text);
gpr_free(line_prefix);
- line_prefix = (char *)gpr_malloc(pfx_len + 1);
+ line_prefix = (char*)gpr_malloc(pfx_len + 1);
memset(line_prefix, ' ', pfx_len);
line_prefix[pfx_len] = 0;
gpr_log(GPR_ERROR, "%s^ here", line_prefix);
gpr_free(line_prefix);
}
- return NULL;
+ return nullptr;
}
/** Returns a copy of percent decoded \a src[begin, end) */
-static char *decode_and_copy_component(grpc_exec_ctx *exec_ctx, const char *src,
- size_t begin, size_t end) {
+static char* decode_and_copy_component(const char* src, size_t begin,
+ size_t end) {
grpc_slice component =
- grpc_slice_from_copied_buffer(src + begin, end - begin);
+ (begin == NOT_SET || end == NOT_SET)
+ ? grpc_empty_slice()
+ : grpc_slice_from_copied_buffer(src + begin, end - begin);
grpc_slice decoded_component =
grpc_permissive_percent_decode_slice(component);
- char *out = grpc_dump_slice(decoded_component, GPR_DUMP_ASCII);
- grpc_slice_unref_internal(exec_ctx, component);
- grpc_slice_unref_internal(exec_ctx, decoded_component);
+ char* out = grpc_dump_slice(decoded_component, GPR_DUMP_ASCII);
+ grpc_slice_unref_internal(component);
+ grpc_slice_unref_internal(decoded_component);
return out;
}
@@ -76,7 +78,7 @@ static bool valid_hex(char c) {
/** Returns how many chars to advance if \a uri_text[i] begins a valid \a pchar
* production. If \a uri_text[i] introduces an invalid \a pchar (such as percent
* sign not followed by two hex digits), NOT_SET is returned. */
-static size_t parse_pchar(const char *uri_text, size_t i) {
+static size_t parse_pchar(const char* uri_text, size_t i) {
/* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
* pct-encoded = "%" HEXDIG HEXDIG
@@ -118,7 +120,7 @@ static size_t parse_pchar(const char *uri_text, size_t i) {
}
/* *( pchar / "?" / "/" ) */
-static int parse_fragment_or_query(const char *uri_text, size_t *i) {
+static int parse_fragment_or_query(const char* uri_text, size_t* i) {
char c;
while ((c = uri_text[*i]) != 0) {
const size_t advance = parse_pchar(uri_text, *i); /* pchar */
@@ -143,13 +145,13 @@ static int parse_fragment_or_query(const char *uri_text, size_t *i) {
return 1;
}
-static void parse_query_parts(grpc_uri *uri) {
- static const char *QUERY_PARTS_SEPARATOR = "&";
- static const char *QUERY_PARTS_VALUE_SEPARATOR = "=";
- GPR_ASSERT(uri->query != NULL);
+static void parse_query_parts(grpc_uri* uri) {
+ static const char* QUERY_PARTS_SEPARATOR = "&";
+ static const char* QUERY_PARTS_VALUE_SEPARATOR = "=";
+ GPR_ASSERT(uri->query != nullptr);
if (uri->query[0] == '\0') {
- uri->query_parts = NULL;
- uri->query_parts_values = NULL;
+ uri->query_parts = nullptr;
+ uri->query_parts_values = nullptr;
uri->num_query_parts = 0;
return;
}
@@ -157,11 +159,11 @@ static void parse_query_parts(grpc_uri *uri) {
gpr_string_split(uri->query, QUERY_PARTS_SEPARATOR, &uri->query_parts,
&uri->num_query_parts);
uri->query_parts_values =
- (char **)gpr_malloc(uri->num_query_parts * sizeof(char **));
+ (char**)gpr_malloc(uri->num_query_parts * sizeof(char**));
for (size_t i = 0; i < uri->num_query_parts; i++) {
- char **query_param_parts;
+ char** query_param_parts;
size_t num_query_param_parts;
- char *full = uri->query_parts[i];
+ char* full = uri->query_parts[i];
gpr_string_split(full, QUERY_PARTS_VALUE_SEPARATOR, &query_param_parts,
&num_query_param_parts);
GPR_ASSERT(num_query_param_parts > 0);
@@ -172,7 +174,7 @@ static void parse_query_parts(grpc_uri *uri) {
* be included, even if they include the separator. */
uri->query_parts_values[i] = query_param_parts[1];
} else {
- uri->query_parts_values[i] = NULL;
+ uri->query_parts_values[i] = nullptr;
}
for (size_t j = 2; j < num_query_param_parts; j++) {
gpr_free(query_param_parts[j]);
@@ -182,9 +184,8 @@ static void parse_query_parts(grpc_uri *uri) {
}
}
-grpc_uri *grpc_uri_parse(grpc_exec_ctx *exec_ctx, const char *uri_text,
- bool suppress_errors) {
- grpc_uri *uri;
+grpc_uri* grpc_uri_parse(const char* uri_text, bool suppress_errors) {
+ grpc_uri* uri;
size_t scheme_begin = 0;
size_t scheme_end = NOT_SET;
size_t authority_begin = NOT_SET;
@@ -270,35 +271,32 @@ grpc_uri *grpc_uri_parse(grpc_exec_ctx *exec_ctx, const char *uri_text,
fragment_end = i;
}
- uri = (grpc_uri *)gpr_zalloc(sizeof(*uri));
- uri->scheme =
- decode_and_copy_component(exec_ctx, uri_text, scheme_begin, scheme_end);
- uri->authority = decode_and_copy_component(exec_ctx, uri_text,
- authority_begin, authority_end);
- uri->path =
- decode_and_copy_component(exec_ctx, uri_text, path_begin, path_end);
- uri->query =
- decode_and_copy_component(exec_ctx, uri_text, query_begin, query_end);
- uri->fragment = decode_and_copy_component(exec_ctx, uri_text, fragment_begin,
- fragment_end);
+ uri = (grpc_uri*)gpr_zalloc(sizeof(*uri));
+ uri->scheme = decode_and_copy_component(uri_text, scheme_begin, scheme_end);
+ uri->authority =
+ decode_and_copy_component(uri_text, authority_begin, authority_end);
+ uri->path = decode_and_copy_component(uri_text, path_begin, path_end);
+ uri->query = decode_and_copy_component(uri_text, query_begin, query_end);
+ uri->fragment =
+ decode_and_copy_component(uri_text, fragment_begin, fragment_end);
parse_query_parts(uri);
return uri;
}
-const char *grpc_uri_get_query_arg(const grpc_uri *uri, const char *key) {
- GPR_ASSERT(key != NULL);
- if (key[0] == '\0') return NULL;
+const char* grpc_uri_get_query_arg(const grpc_uri* uri, const char* key) {
+ GPR_ASSERT(key != nullptr);
+ if (key[0] == '\0') return nullptr;
for (size_t i = 0; i < uri->num_query_parts; ++i) {
if (0 == strcmp(key, uri->query_parts[i])) {
return uri->query_parts_values[i];
}
}
- return NULL;
+ return nullptr;
}
-void grpc_uri_destroy(grpc_uri *uri) {
+void grpc_uri_destroy(grpc_uri* uri) {
if (!uri) return;
gpr_free(uri->scheme);
gpr_free(uri->authority);
diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h
index 05ca2e00e4..24ff06c0b5 100644
--- a/src/core/ext/filters/client_channel/uri_parser.h
+++ b/src/core/ext/filters/client_channel/uri_parser.h
@@ -23,28 +23,27 @@
#include "src/core/lib/iomgr/exec_ctx.h"
typedef struct {
- char *scheme;
- char *authority;
- char *path;
- char *query;
+ char* scheme;
+ char* authority;
+ char* path;
+ char* query;
/** Query substrings separated by '&' */
- char **query_parts;
+ char** query_parts;
/** Number of elements in \a query_parts and \a query_parts_values */
size_t num_query_parts;
/** Split each query part by '='. NULL if not present. */
- char **query_parts_values;
- char *fragment;
+ char** query_parts_values;
+ char* fragment;
} grpc_uri;
/** parse a uri, return NULL on failure */
-grpc_uri *grpc_uri_parse(grpc_exec_ctx *exec_ctx, const char *uri_text,
- bool suppress_errors);
+grpc_uri* grpc_uri_parse(const char* uri_text, bool suppress_errors);
/** return the part of a query string after the '=' in "?key=xxx&...", or NULL
* if key is not present */
-const char *grpc_uri_get_query_arg(const grpc_uri *uri, const char *key);
+const char* grpc_uri_get_query_arg(const grpc_uri* uri, const char* key);
/** destroy a uri */
-void grpc_uri_destroy(grpc_uri *uri);
+void grpc_uri_destroy(grpc_uri* uri);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_URI_PARSER_H */
diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.cc
index 1aed488077..c430f3d2d4 100644
--- a/src/core/ext/filters/deadline/deadline_filter.c
+++ b/src/core/ext/filters/deadline/deadline_filter.cc
@@ -36,18 +36,16 @@
// The on_complete callback used when sending a cancel_error batch down the
// filter stack. Yields the call combiner when the batch returns.
-static void yield_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* ignored) {
+static void yield_call_combiner(void* arg, grpc_error* ignored) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)arg;
- GRPC_CALL_COMBINER_STOP(exec_ctx, deadline_state->call_combiner,
+ GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner,
"got on_complete from cancel_stream batch");
- GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer");
+ GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "deadline_timer");
}
// This is called via the call combiner, so access to deadline_state is
// synchronized.
-static void send_cancel_op_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void send_cancel_op_in_call_combiner(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
grpc_transport_stream_op_batch* batch = grpc_make_transport_stream_op(
@@ -55,44 +53,40 @@ static void send_cancel_op_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
deadline_state, grpc_schedule_on_exec_ctx));
batch->cancel_stream = true;
batch->payload->cancel_stream.cancel_error = GRPC_ERROR_REF(error);
- elem->filter->start_transport_stream_op_batch(exec_ctx, elem, batch);
+ elem->filter->start_transport_stream_op_batch(elem, batch);
}
// Timer callback.
-static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void timer_callback(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
if (error != GRPC_ERROR_CANCELLED) {
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED);
- grpc_call_combiner_cancel(exec_ctx, deadline_state->call_combiner,
+ grpc_call_combiner_cancel(deadline_state->call_combiner,
GRPC_ERROR_REF(error));
GRPC_CLOSURE_INIT(&deadline_state->timer_callback,
send_cancel_op_in_call_combiner, elem,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, deadline_state->call_combiner,
+ GRPC_CALL_COMBINER_START(deadline_state->call_combiner,
&deadline_state->timer_callback, error,
"deadline exceeded -- sending cancel_stream op");
} else {
- GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack,
- "deadline_timer");
+ GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "deadline_timer");
}
}
// Starts the deadline timer.
// This is called via the call combiner, so access to deadline_state is
// synchronized.
-static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
- gpr_timespec deadline) {
- deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
- if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) == 0) {
+static void start_timer_if_needed(grpc_call_element* elem,
+ grpc_millis deadline) {
+ if (deadline == GRPC_MILLIS_INF_FUTURE) {
return;
}
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
- grpc_closure* closure = NULL;
+ grpc_closure* closure = nullptr;
switch (deadline_state->timer_state) {
case GRPC_DEADLINE_STATE_PENDING:
// Note: We do not start the timer if there is already a timer
@@ -112,20 +106,18 @@ static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
elem, grpc_schedule_on_exec_ctx);
break;
}
- GPR_ASSERT(closure != NULL);
+ GPR_ASSERT(closure != nullptr);
GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer");
- grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure,
- gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&deadline_state->timer, deadline, closure);
}
// Cancels the deadline timer.
// This is called via the call combiner, so access to deadline_state is
// synchronized.
-static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx,
- grpc_deadline_state* deadline_state) {
+static void cancel_timer_if_needed(grpc_deadline_state* deadline_state) {
if (deadline_state->timer_state == GRPC_DEADLINE_STATE_PENDING) {
deadline_state->timer_state = GRPC_DEADLINE_STATE_FINISHED;
- grpc_timer_cancel(exec_ctx, &deadline_state->timer);
+ grpc_timer_cancel(&deadline_state->timer);
} else {
// timer was either in STATE_INITAL (nothing to cancel)
// OR in STATE_FINISHED (again nothing to cancel)
@@ -133,12 +125,11 @@ static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx,
}
// Callback run when the call is complete.
-static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_complete(void* arg, grpc_error* error) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)arg;
- cancel_timer_if_needed(exec_ctx, deadline_state);
+ cancel_timer_if_needed(deadline_state);
// Invoke the next callback.
- GRPC_CLOSURE_RUN(exec_ctx, deadline_state->next_on_complete,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(deadline_state->next_on_complete, GRPC_ERROR_REF(error));
}
// Inject our own on_complete callback into op.
@@ -155,11 +146,10 @@ static void inject_on_complete_cb(grpc_deadline_state* deadline_state,
struct start_timer_after_init_state {
bool in_call_combiner;
grpc_call_element* elem;
- gpr_timespec deadline;
+ grpc_millis deadline;
grpc_closure closure;
};
-static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_timer_after_init(void* arg, grpc_error* error) {
struct start_timer_after_init_state* state =
(struct start_timer_after_init_state*)arg;
grpc_deadline_state* deadline_state =
@@ -168,28 +158,27 @@ static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
// We are initially called without holding the call combiner, so we
// need to bounce ourselves into it.
state->in_call_combiner = true;
- GRPC_CALL_COMBINER_START(exec_ctx, deadline_state->call_combiner,
- &state->closure, GRPC_ERROR_REF(error),
+ GRPC_CALL_COMBINER_START(deadline_state->call_combiner, &state->closure,
+ GRPC_ERROR_REF(error),
"scheduling deadline timer");
return;
}
- start_timer_if_needed(exec_ctx, state->elem, state->deadline);
+ start_timer_if_needed(state->elem, state->deadline);
gpr_free(state);
- GRPC_CALL_COMBINER_STOP(exec_ctx, deadline_state->call_combiner,
+ GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner,
"done scheduling deadline timer");
}
-void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_deadline_state_init(grpc_call_element* elem,
grpc_call_stack* call_stack,
grpc_call_combiner* call_combiner,
- gpr_timespec deadline) {
+ grpc_millis deadline) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
deadline_state->call_stack = call_stack;
deadline_state->call_combiner = call_combiner;
// Deadline will always be infinite on servers, so the timer will only be
// set on clients with a finite deadline.
- deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
- if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) {
+ if (deadline != GRPC_MILLIS_INF_FUTURE) {
// When the deadline passes, we indicate the failure by sending down
// an op with cancel_error set. However, we can't send down any ops
// until after the call stack is fully initialized. If we start the
@@ -203,29 +192,27 @@ void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
state->deadline = deadline;
GRPC_CLOSURE_INIT(&state->closure, start_timer_after_init, state,
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &state->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&state->closure, GRPC_ERROR_NONE);
}
}
-void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+void grpc_deadline_state_destroy(grpc_call_element* elem) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
- cancel_timer_if_needed(exec_ctx, deadline_state);
+ cancel_timer_if_needed(deadline_state);
}
-void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- gpr_timespec new_deadline) {
+void grpc_deadline_state_reset(grpc_call_element* elem,
+ grpc_millis new_deadline) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
- cancel_timer_if_needed(exec_ctx, deadline_state);
- start_timer_if_needed(exec_ctx, elem, new_deadline);
+ cancel_timer_if_needed(deadline_state);
+ start_timer_if_needed(elem, new_deadline);
}
void grpc_deadline_state_client_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
if (op->cancel_stream) {
- cancel_timer_if_needed(exec_ctx, deadline_state);
+ cancel_timer_if_needed(deadline_state);
} else {
// Make sure we know when the call is complete, so that we can cancel
// the timer.
@@ -240,16 +227,14 @@ void grpc_deadline_state_client_start_transport_stream_op_batch(
//
// Constructor for channel_data. Used for both client and server filters.
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
return GRPC_ERROR_NONE;
}
// Destructor for channel_data. Used for both client and server filters.
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
// Call data used for both client and server filter.
typedef struct base_call_data {
@@ -269,50 +254,45 @@ typedef struct server_call_data {
} server_call_data;
// Constructor for call_data. Used for both client and server filters.
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
- grpc_deadline_state_init(exec_ctx, elem, args->call_stack,
- args->call_combiner, args->deadline);
+ grpc_deadline_state_init(elem, args->call_stack, args->call_combiner,
+ args->deadline);
return GRPC_ERROR_NONE;
}
// Destructor for call_data. Used for both client and server filters.
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
- grpc_deadline_state_destroy(exec_ctx, elem);
+ grpc_deadline_state_destroy(elem);
}
// Method for starting a call op for client filter.
static void client_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
- grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
- op);
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
+ grpc_deadline_state_client_start_transport_stream_op_batch(elem, op);
// Chain to next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
// Callback for receiving initial metadata on the server.
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
server_call_data* calld = (server_call_data*)elem->call_data;
// Get deadline from metadata and start the timer if needed.
- start_timer_if_needed(exec_ctx, elem, calld->recv_initial_metadata->deadline);
+ start_timer_if_needed(elem, calld->recv_initial_metadata->deadline);
// Invoke the next callback.
calld->next_recv_initial_metadata_ready->cb(
- exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error);
+ calld->next_recv_initial_metadata_ready->cb_arg, error);
}
// Method for starting a call op for server filter.
static void server_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
server_call_data* calld = (server_call_data*)elem->call_data;
if (op->cancel_stream) {
- cancel_timer_if_needed(exec_ctx, &calld->base.deadline_state);
+ cancel_timer_if_needed(&calld->base.deadline_state);
} else {
// If we're receiving initial metadata, we need to get the deadline
// from the recv_initial_metadata_ready callback. So we inject our
@@ -338,7 +318,7 @@ static void server_start_transport_stream_op_batch(
}
}
// Chain to next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
const grpc_channel_filter grpc_client_deadline_filter = {
@@ -375,13 +355,12 @@ bool grpc_deadline_checking_enabled(const grpc_channel_args* channel_args) {
!grpc_channel_args_want_minimal_stack(channel_args));
}
-static bool maybe_add_deadline_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_deadline_filter(grpc_channel_stack_builder* builder,
void* arg) {
return grpc_deadline_checking_enabled(
grpc_channel_stack_builder_get_channel_arguments(builder))
? grpc_channel_stack_builder_prepend_filter(
- builder, (const grpc_channel_filter*)arg, NULL, NULL)
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr)
: true;
}
diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h
index 3eb102ad28..4de817ef54 100644
--- a/src/core/ext/filters/deadline/deadline_filter.h
+++ b/src/core/ext/filters/deadline/deadline_filter.h
@@ -49,12 +49,12 @@ typedef struct grpc_deadline_state {
//
// assumes elem->call_data is zero'd
-void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_deadline_state_init(grpc_call_element* elem,
grpc_call_stack* call_stack,
grpc_call_combiner* call_combiner,
- gpr_timespec deadline);
-void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem);
+ grpc_millis deadline);
+
+void grpc_deadline_state_destroy(grpc_call_element* elem);
// Cancels the existing timer and starts a new one with new_deadline.
//
@@ -65,8 +65,8 @@ void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
// deadline may result in the timer being called twice.
//
// Note: Must be called while holding the call combiner.
-void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- gpr_timespec new_deadline);
+void grpc_deadline_state_reset(grpc_call_element* elem,
+ grpc_millis new_deadline);
// To be called from the client-side filter's start_transport_stream_op_batch()
// method. Ensures that the deadline timer is cancelled when the call
@@ -77,8 +77,7 @@ void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
//
// Note: Must be called while holding the call combiner.
void grpc_deadline_state_client_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op);
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op);
// Should deadline checking be performed (according to channel args)
bool grpc_deadline_checking_enabled(const grpc_channel_args* args);
diff --git a/src/core/ext/filters/http/client/http_client_filter.c b/src/core/ext/filters/http/client/http_client_filter.cc
index 6208089f2e..5584d50018 100644
--- a/src/core/ext/filters/http/client/http_client_filter.c
+++ b/src/core/ext/filters/http/client/http_client_filter.cc
@@ -20,12 +20,12 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <string.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/percent_encoding.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h"
#include "src/core/lib/transport/transport_impl.h"
@@ -35,8 +35,9 @@
/* default maximum size of payload eligable for GET request */
static const size_t kMaxPayloadSizeForGet = 2048;
-typedef struct call_data {
- grpc_call_combiner *call_combiner;
+namespace {
+struct call_data {
+ grpc_call_combiner* call_combiner;
// State for handling send_initial_metadata ops.
grpc_linked_mdelem method;
grpc_linked_mdelem scheme;
@@ -45,41 +46,41 @@ typedef struct call_data {
grpc_linked_mdelem content_type;
grpc_linked_mdelem user_agent;
// State for handling recv_initial_metadata ops.
- grpc_metadata_batch *recv_initial_metadata;
- grpc_closure *original_recv_initial_metadata_ready;
+ grpc_metadata_batch* recv_initial_metadata;
+ grpc_closure* original_recv_initial_metadata_ready;
grpc_closure recv_initial_metadata_ready;
// State for handling recv_trailing_metadata ops.
- grpc_metadata_batch *recv_trailing_metadata;
- grpc_closure *original_recv_trailing_metadata_on_complete;
+ grpc_metadata_batch* recv_trailing_metadata;
+ grpc_closure* original_recv_trailing_metadata_on_complete;
grpc_closure recv_trailing_metadata_on_complete;
// State for handling send_message ops.
- grpc_transport_stream_op_batch *send_message_batch;
+ grpc_transport_stream_op_batch* send_message_batch;
size_t send_message_bytes_read;
grpc_byte_stream_cache send_message_cache;
grpc_caching_byte_stream send_message_caching_stream;
grpc_closure on_send_message_next_done;
- grpc_closure *original_send_message_on_complete;
+ grpc_closure* original_send_message_on_complete;
grpc_closure send_message_on_complete;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
grpc_mdelem static_scheme;
grpc_mdelem user_agent;
size_t max_payload_size_for_get;
-} channel_data;
+};
+} // namespace
-static grpc_error *client_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_metadata_batch *b) {
- if (b->idx.named.status != NULL) {
+static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem,
+ grpc_metadata_batch* b) {
+ if (b->idx.named.status != nullptr) {
if (grpc_mdelem_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) {
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.status);
+ grpc_metadata_batch_remove(b, b->idx.named.status);
} else {
- char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md),
+ char* val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md),
GPR_DUMP_ASCII);
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Received http2 header with status: %s", val);
- grpc_error *e = grpc_error_set_str(
+ grpc_error* e = grpc_error_set_str(
grpc_error_set_int(
grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -93,19 +94,18 @@ static grpc_error *client_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
}
}
- if (b->idx.named.grpc_message != NULL) {
+ if (b->idx.named.grpc_message != nullptr) {
grpc_slice pct_decoded_msg = grpc_permissive_percent_decode_slice(
GRPC_MDVALUE(b->idx.named.grpc_message->md));
if (grpc_slice_is_equivalent(pct_decoded_msg,
GRPC_MDVALUE(b->idx.named.grpc_message->md))) {
- grpc_slice_unref_internal(exec_ctx, pct_decoded_msg);
+ grpc_slice_unref_internal(pct_decoded_msg);
} else {
- grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message,
- pct_decoded_msg);
+ grpc_metadata_batch_set_value(b->idx.named.grpc_message, pct_decoded_msg);
}
}
- if (b->idx.named.content_type != NULL) {
+ if (b->idx.named.content_type != nullptr) {
if (!grpc_mdelem_eq(b->idx.named.content_type->md,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) {
if (grpc_slice_buf_start_eq(GRPC_MDVALUE(b->idx.named.content_type->md),
@@ -125,66 +125,59 @@ static grpc_error *client_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
} else {
/* TODO(klempner): We're currently allowing this, but we shouldn't
see it without a proxy so log for now. */
- char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md),
+ char* val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md),
GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "Unexpected content-type '%s'", val);
gpr_free(val);
}
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type);
+ grpc_metadata_batch_remove(b, b->idx.named.content_type);
}
return GRPC_ERROR_NONE;
}
-static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
- void *user_data, grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- error = client_filter_incoming_metadata(exec_ctx, elem,
- calld->recv_initial_metadata);
+ error = client_filter_incoming_metadata(elem, calld->recv_initial_metadata);
} else {
GRPC_ERROR_REF(error);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
- error);
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready, error);
}
-static void recv_trailing_metadata_on_complete(grpc_exec_ctx *exec_ctx,
- void *user_data,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+static void recv_trailing_metadata_on_complete(void* user_data,
+ grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- error = client_filter_incoming_metadata(exec_ctx, elem,
- calld->recv_trailing_metadata);
+ error =
+ client_filter_incoming_metadata(elem, calld->recv_trailing_metadata);
} else {
GRPC_ERROR_REF(error);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_trailing_metadata_on_complete,
- error);
+ GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_on_complete, error);
}
-static void send_message_on_complete(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
- grpc_byte_stream_cache_destroy(exec_ctx, &calld->send_message_cache);
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_send_message_on_complete,
+static void send_message_on_complete(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_byte_stream_cache_destroy(&calld->send_message_cache);
+ GRPC_CLOSURE_RUN(calld->original_send_message_on_complete,
GRPC_ERROR_REF(error));
}
// Pulls a slice from the send_message byte stream, updating
// calld->send_message_bytes_read.
-static grpc_error *pull_slice_from_send_message(grpc_exec_ctx *exec_ctx,
- call_data *calld) {
+static grpc_error* pull_slice_from_send_message(call_data* calld) {
grpc_slice incoming_slice;
- grpc_error *error = grpc_byte_stream_pull(
- exec_ctx, &calld->send_message_caching_stream.base, &incoming_slice);
+ grpc_error* error = grpc_byte_stream_pull(
+ &calld->send_message_caching_stream.base, &incoming_slice);
if (error == GRPC_ERROR_NONE) {
calld->send_message_bytes_read += GRPC_SLICE_LENGTH(incoming_slice);
- grpc_slice_unref_internal(exec_ctx, incoming_slice);
+ grpc_slice_unref_internal(incoming_slice);
}
return error;
}
@@ -194,12 +187,10 @@ static grpc_error *pull_slice_from_send_message(grpc_exec_ctx *exec_ctx,
// calld->send_message_caching_stream.base.length, then we have completed
// reading from the byte stream; otherwise, an async read has been dispatched
// and on_send_message_next_done() will be invoked when it is complete.
-static grpc_error *read_all_available_send_message_data(grpc_exec_ctx *exec_ctx,
- call_data *calld) {
- while (grpc_byte_stream_next(exec_ctx,
- &calld->send_message_caching_stream.base,
+static grpc_error* read_all_available_send_message_data(call_data* calld) {
+ while (grpc_byte_stream_next(&calld->send_message_caching_stream.base,
~(size_t)0, &calld->on_send_message_next_done)) {
- grpc_error *error = pull_slice_from_send_message(exec_ctx, calld);
+ grpc_error* error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) return error;
if (calld->send_message_bytes_read ==
calld->send_message_caching_stream.base.length) {
@@ -210,19 +201,18 @@ static grpc_error *read_all_available_send_message_data(grpc_exec_ctx *exec_ctx,
}
// Async callback for grpc_byte_stream_next().
-static void on_send_message_next_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
+static void on_send_message_next_done(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, error, calld->call_combiner);
+ calld->send_message_batch, error, calld->call_combiner);
return;
}
- error = pull_slice_from_send_message(exec_ctx, calld);
+ error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, error, calld->call_combiner);
+ calld->send_message_batch, error, calld->call_combiner);
return;
}
// There may or may not be more to read, but we don't care. If we got
@@ -230,11 +220,11 @@ static void on_send_message_next_done(grpc_exec_ctx *exec_ctx, void *arg,
// synchronously, so we were not able to do a cached call. Instead,
// we just reset the byte stream and then send down the batch as-is.
grpc_caching_byte_stream_reset(&calld->send_message_caching_stream);
- grpc_call_next_op(exec_ctx, elem, calld->send_message_batch);
+ grpc_call_next_op(elem, calld->send_message_batch);
}
-static char *slice_buffer_to_string(grpc_slice_buffer *slice_buffer) {
- char *payload_bytes = (char *)gpr_malloc(slice_buffer->length + 1);
+static char* slice_buffer_to_string(grpc_slice_buffer* slice_buffer) {
+ char* payload_bytes = (char*)gpr_malloc(slice_buffer->length + 1);
size_t offset = 0;
for (size_t i = 0; i < slice_buffer->count; ++i) {
memcpy(payload_bytes + offset,
@@ -248,10 +238,9 @@ static char *slice_buffer_to_string(grpc_slice_buffer *slice_buffer) {
// Modifies the path entry in the batch's send_initial_metadata to
// append the base64-encoded query for a GET request.
-static grpc_error *update_path_for_get(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = (call_data *)elem->call_data;
+static grpc_error* update_path_for_get(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
grpc_slice path_slice =
GRPC_MDVALUE(batch->payload->send_initial_metadata.send_initial_metadata
->idx.named.path->md);
@@ -264,44 +253,42 @@ static grpc_error *update_path_for_get(grpc_exec_ctx *exec_ctx,
false /* multi_line */);
grpc_slice path_with_query_slice = GRPC_SLICE_MALLOC(estimated_len);
/* memcopy individual pieces into this slice */
- char *write_ptr = (char *)GRPC_SLICE_START_PTR(path_with_query_slice);
- char *original_path = (char *)GRPC_SLICE_START_PTR(path_slice);
+ char* write_ptr = (char*)GRPC_SLICE_START_PTR(path_with_query_slice);
+ char* original_path = (char*)GRPC_SLICE_START_PTR(path_slice);
memcpy(write_ptr, original_path, GRPC_SLICE_LENGTH(path_slice));
write_ptr += GRPC_SLICE_LENGTH(path_slice);
*write_ptr++ = '?';
- char *payload_bytes =
+ char* payload_bytes =
slice_buffer_to_string(&calld->send_message_cache.cache_buffer);
- grpc_base64_encode_core((char *)write_ptr, payload_bytes,
+ grpc_base64_encode_core((char*)write_ptr, payload_bytes,
batch->payload->send_message.send_message->length,
true /* url_safe */, false /* multi_line */);
gpr_free(payload_bytes);
/* remove trailing unused memory and add trailing 0 to terminate string */
- char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice);
+ char* t = (char*)GRPC_SLICE_START_PTR(path_with_query_slice);
/* safe to use strlen since base64_encode will always add '\0' */
path_with_query_slice =
grpc_slice_sub_no_ref(path_with_query_slice, 0, strlen(t));
/* substitute previous path with the new path+query */
grpc_mdelem mdelem_path_and_query =
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH, path_with_query_slice);
- grpc_metadata_batch *b =
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH, path_with_query_slice);
+ grpc_metadata_batch* b =
batch->payload->send_initial_metadata.send_initial_metadata;
- return grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path,
+ return grpc_metadata_batch_substitute(b, b->idx.named.path,
mdelem_path_and_query);
}
-static void remove_if_present(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
+static void remove_if_present(grpc_metadata_batch* batch,
grpc_metadata_batch_callouts_index idx) {
- if (batch->idx.array[idx] != NULL) {
- grpc_metadata_batch_remove(exec_ctx, batch, batch->idx.array[idx]);
+ if (batch->idx.array[idx] != nullptr) {
+ grpc_metadata_batch_remove(batch, batch->idx.array[idx]);
}
}
static void hc_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *channeld = (channel_data *)elem->channel_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* channeld = (channel_data*)elem->channel_data;
GPR_TIMER_BEGIN("hc_start_transport_stream_op_batch", 0);
if (batch->recv_initial_metadata) {
@@ -322,7 +309,7 @@ static void hc_start_transport_stream_op_batch(
batch->on_complete = &calld->recv_trailing_metadata_on_complete;
}
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
bool batch_will_be_handled_asynchronously = false;
if (batch->send_initial_metadata) {
// Decide which HTTP VERB to use. We use GET if the request is marked
@@ -345,17 +332,16 @@ static void hc_start_transport_stream_op_batch(
calld->original_send_message_on_complete = batch->on_complete;
batch->on_complete = &calld->send_message_on_complete;
calld->send_message_batch = batch;
- error = read_all_available_send_message_data(exec_ctx, calld);
+ error = read_all_available_send_message_data(calld);
if (error != GRPC_ERROR_NONE) goto done;
// If all the data has been read, then we can use GET.
if (calld->send_message_bytes_read ==
calld->send_message_caching_stream.base.length) {
method = GRPC_MDELEM_METHOD_GET;
- error = update_path_for_get(exec_ctx, elem, batch);
+ error = update_path_for_get(elem, batch);
if (error != GRPC_ERROR_NONE) goto done;
batch->send_message = false;
- grpc_byte_stream_destroy(exec_ctx,
- &calld->send_message_caching_stream.base);
+ grpc_byte_stream_destroy(&calld->send_message_caching_stream.base);
} else {
// Not all data is available. The batch will be sent down
// asynchronously in on_send_message_next_done().
@@ -372,41 +358,41 @@ static void hc_start_transport_stream_op_batch(
}
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_METHOD);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_SCHEME);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_TE);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_CONTENT_TYPE);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_USER_AGENT);
/* Send : prefixed headers, which have to be before any application
layer headers. */
error = grpc_metadata_batch_add_head(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->method, method);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_head(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->scheme, channeld->static_scheme);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_tail(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->te_trailers, GRPC_MDELEM_TE_TRAILERS);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_tail(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->content_type, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_tail(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->user_agent, GRPC_MDELEM_REF(channeld->user_agent));
if (error != GRPC_ERROR_NONE) goto done;
}
@@ -414,18 +400,17 @@ static void hc_start_transport_stream_op_batch(
done:
if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, error, calld->call_combiner);
+ calld->send_message_batch, error, calld->call_combiner);
} else if (!batch_will_be_handled_asynchronously) {
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
GPR_TIMER_END("hc_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
calld->call_combiner = args->call_combiner;
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
recv_initial_metadata_ready, elem,
@@ -441,16 +426,16 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {}
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {}
-static grpc_mdelem scheme_from_args(const grpc_channel_args *args) {
+static grpc_mdelem scheme_from_args(const grpc_channel_args* args) {
unsigned i;
size_t j;
grpc_mdelem valid_schemes[] = {GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_SCHEME_HTTPS};
- if (args != NULL) {
+ if (args != nullptr) {
for (i = 0; i < args->num_args; ++i) {
if (args->args[i].type == GRPC_ARG_STRING &&
strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) {
@@ -466,8 +451,8 @@ static grpc_mdelem scheme_from_args(const grpc_channel_args *args) {
return GRPC_MDELEM_SCHEME_HTTP;
}
-static size_t max_payload_size_from_args(const grpc_channel_args *args) {
- if (args != NULL) {
+static size_t max_payload_size_from_args(const grpc_channel_args* args) {
+ if (args != nullptr) {
for (size_t i = 0; i < args->num_args; ++i) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET)) {
if (args->args[i].type != GRPC_ARG_INTEGER) {
@@ -482,12 +467,12 @@ static size_t max_payload_size_from_args(const grpc_channel_args *args) {
return kMaxPayloadSizeForGet;
}
-static grpc_slice user_agent_from_args(const grpc_channel_args *args,
- const char *transport_name) {
+static grpc_slice user_agent_from_args(const grpc_channel_args* args,
+ const char* transport_name) {
gpr_strvec v;
size_t i;
int is_first = 1;
- char *tmp;
+ char* tmp;
grpc_slice result;
gpr_strvec_init(&v);
@@ -524,7 +509,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args *args,
}
}
- tmp = gpr_strvec_flatten(&v, NULL);
+ tmp = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
result = grpc_slice_intern(grpc_slice_from_static_string(tmp));
gpr_free(tmp);
@@ -533,27 +518,25 @@ static grpc_slice user_agent_from_args(const grpc_channel_args *args,
}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- channel_data *chand = (channel_data *)elem->channel_data;
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(!args->is_last);
- GPR_ASSERT(args->optional_transport != NULL);
+ GPR_ASSERT(args->optional_transport != nullptr);
chand->static_scheme = scheme_from_args(args->channel_args);
chand->max_payload_size_for_get =
max_payload_size_from_args(args->channel_args);
chand->user_agent = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
user_agent_from_args(args->channel_args,
args->optional_transport->vtable->name));
return GRPC_ERROR_NONE;
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- GRPC_MDELEM_UNREF(exec_ctx, chand->user_agent);
+static void destroy_channel_elem(grpc_channel_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ GRPC_MDELEM_UNREF(chand->user_agent);
}
const grpc_channel_filter grpc_http_client_filter = {
diff --git a/src/core/ext/filters/http/http_filters_plugin.c b/src/core/ext/filters/http/http_filters_plugin.cc
index 88bd2250f9..deec77c96f 100644
--- a/src/core/ext/filters/http/http_filters_plugin.c
+++ b/src/core/ext/filters/http/http_filters_plugin.cc
@@ -27,45 +27,42 @@
#include "src/core/lib/transport/transport_impl.h"
typedef struct {
- const grpc_channel_filter *filter;
- const char *control_channel_arg;
+ const grpc_channel_filter* filter;
+ const char* control_channel_arg;
} optional_filter;
static optional_filter compress_filter = {
&grpc_message_compress_filter, GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION};
static bool is_building_http_like_transport(
- grpc_channel_stack_builder *builder) {
- grpc_transport *t = grpc_channel_stack_builder_get_transport(builder);
- return t != NULL && strstr(t->vtable->name, "http");
+ grpc_channel_stack_builder* builder) {
+ grpc_transport* t = grpc_channel_stack_builder_get_transport(builder);
+ return t != nullptr && strstr(t->vtable->name, "http");
}
-static bool maybe_add_optional_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
+static bool maybe_add_optional_filter(grpc_channel_stack_builder* builder,
+ void* arg) {
if (!is_building_http_like_transport(builder)) return true;
- optional_filter *filtarg = (optional_filter *)arg;
- const grpc_channel_args *channel_args =
+ optional_filter* filtarg = (optional_filter*)arg;
+ const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
bool enable = grpc_channel_arg_get_bool(
grpc_channel_args_find(channel_args, filtarg->control_channel_arg),
!grpc_channel_args_want_minimal_stack(channel_args));
return enable ? grpc_channel_stack_builder_prepend_filter(
- builder, filtarg->filter, NULL, NULL)
+ builder, filtarg->filter, nullptr, nullptr)
: true;
}
-static bool maybe_add_required_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
+static bool maybe_add_required_filter(grpc_channel_stack_builder* builder,
+ void* arg) {
return is_building_http_like_transport(builder)
? grpc_channel_stack_builder_prepend_filter(
- builder, (const grpc_channel_filter *)arg, NULL, NULL)
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr)
: true;
}
void grpc_http_filters_init(void) {
- grpc_register_tracer(&grpc_compression_trace);
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_optional_filter, &compress_filter);
@@ -77,13 +74,13 @@ void grpc_http_filters_init(void) {
maybe_add_optional_filter, &compress_filter);
grpc_channel_init_register_stage(
GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_required_filter, (void *)&grpc_http_client_filter);
+ maybe_add_required_filter, (void*)&grpc_http_client_filter);
grpc_channel_init_register_stage(
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_required_filter, (void *)&grpc_http_client_filter);
+ maybe_add_required_filter, (void*)&grpc_http_client_filter);
grpc_channel_init_register_stage(
GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_required_filter, (void *)&grpc_http_server_filter);
+ maybe_add_required_filter, (void*)&grpc_http_server_filter);
}
void grpc_http_filters_shutdown(void) {}
diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
index f785e1355d..0218ec6e40 100644
--- a/src/core/ext/filters/http/message_compress/message_compress_filter.c
+++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
@@ -27,69 +27,67 @@
#include "src/core/ext/filters/http/message_compress/message_compress_filter.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/compression/algorithm_metadata.h"
+#include "src/core/lib/compression/compression_internal.h"
#include "src/core/lib/compression/message_compress.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/transport/static_metadata.h"
-typedef enum {
+namespace {
+enum initial_metadata_state {
// Initial metadata not yet seen.
INITIAL_METADATA_UNSEEN = 0,
// Initial metadata seen; compression algorithm set.
HAS_COMPRESSION_ALGORITHM,
// Initial metadata seen; no compression algorithm set.
NO_COMPRESSION_ALGORITHM,
-} initial_metadata_state;
+};
-typedef struct call_data {
- grpc_call_combiner *call_combiner;
+struct call_data {
+ grpc_call_combiner* call_combiner;
grpc_linked_mdelem compression_algorithm_storage;
grpc_linked_mdelem stream_compression_algorithm_storage;
grpc_linked_mdelem accept_encoding_storage;
grpc_linked_mdelem accept_stream_encoding_storage;
/** Compression algorithm we'll try to use. It may be given by incoming
* metadata, or by the channel's default compression settings. */
- grpc_compression_algorithm compression_algorithm;
+ grpc_message_compression_algorithm message_compression_algorithm;
initial_metadata_state send_initial_metadata_state;
- grpc_error *cancel_error;
+ grpc_error* cancel_error;
grpc_closure start_send_message_batch_in_call_combiner;
- grpc_transport_stream_op_batch *send_message_batch;
+ grpc_transport_stream_op_batch* send_message_batch;
grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */
grpc_slice_buffer_stream replacement_stream;
- grpc_closure *original_send_message_on_complete;
+ grpc_closure* original_send_message_on_complete;
grpc_closure send_message_on_complete;
grpc_closure on_send_message_next_done;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
/** The default, channel-level, compression algorithm */
grpc_compression_algorithm default_compression_algorithm;
- /** Bitset of enabled algorithms */
+ /** Bitset of enabled compression algorithms */
uint32_t enabled_algorithms_bitset;
/** Supported compression algorithms */
- uint32_t supported_compression_algorithms;
-
- /** The default, channel-level, stream compression algorithm */
- grpc_stream_compression_algorithm default_stream_compression_algorithm;
- /** Bitset of enabled stream compression algorithms */
- uint32_t enabled_stream_compression_algorithms_bitset;
+ uint32_t supported_message_compression_algorithms;
/** Supported stream compression algorithms */
uint32_t supported_stream_compression_algorithms;
-} channel_data;
+};
+} // namespace
-static bool skip_compression(grpc_call_element *elem, uint32_t flags,
+static bool skip_compression(grpc_call_element* elem, uint32_t flags,
bool has_compression_algorithm) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *channeld = (channel_data *)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* channeld = (channel_data*)elem->channel_data;
if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) {
return true;
}
if (has_compression_algorithm) {
- if (calld->compression_algorithm == GRPC_COMPRESS_NONE) {
+ if (calld->message_compression_algorithm == GRPC_MESSAGE_COMPRESS_NONE) {
return true;
}
return false; /* we have an actual call-specific algorithm */
@@ -99,111 +97,95 @@ static bool skip_compression(grpc_call_element *elem, uint32_t flags,
}
/** Filter initial metadata */
-static grpc_error *process_send_initial_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_metadata_batch *initial_metadata,
- bool *has_compression_algorithm) GRPC_MUST_USE_RESULT;
-static grpc_error *process_send_initial_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_metadata_batch *initial_metadata, bool *has_compression_algorithm) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *channeld = (channel_data *)elem->channel_data;
+static grpc_error* process_send_initial_metadata(
+ grpc_call_element* elem, grpc_metadata_batch* initial_metadata,
+ bool* has_compression_algorithm) GRPC_MUST_USE_RESULT;
+static grpc_error* process_send_initial_metadata(
+ grpc_call_element* elem, grpc_metadata_batch* initial_metadata,
+ bool* has_compression_algorithm) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* channeld = (channel_data*)elem->channel_data;
*has_compression_algorithm = false;
+ grpc_compression_algorithm compression_algorithm;
grpc_stream_compression_algorithm stream_compression_algorithm =
GRPC_STREAM_COMPRESS_NONE;
- if (initial_metadata->idx.named.grpc_internal_stream_encoding_request !=
- NULL) {
+ if (initial_metadata->idx.named.grpc_internal_encoding_request != nullptr) {
grpc_mdelem md =
- initial_metadata->idx.named.grpc_internal_stream_encoding_request->md;
- if (!grpc_stream_compression_algorithm_parse(
- GRPC_MDVALUE(md), &stream_compression_algorithm)) {
- char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ initial_metadata->idx.named.grpc_internal_encoding_request->md;
+ if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md),
+ &compression_algorithm)) {
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR,
- "Invalid stream compression algorithm: '%s' (unknown). Ignoring.",
- val);
- gpr_free(val);
- stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE;
- }
- if (!GPR_BITGET(channeld->enabled_stream_compression_algorithms_bitset,
- stream_compression_algorithm)) {
- char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
- gpr_log(
- GPR_ERROR,
- "Invalid stream compression algorithm: '%s' (previously disabled). "
- "Ignoring.",
- val);
+ "Invalid compression algorithm: '%s' (unknown). Ignoring.", val);
gpr_free(val);
+ calld->message_compression_algorithm = GRPC_MESSAGE_COMPRESS_NONE;
stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE;
}
- *has_compression_algorithm = true;
- grpc_metadata_batch_remove(
- exec_ctx, initial_metadata,
- initial_metadata->idx.named.grpc_internal_stream_encoding_request);
- /* Disable message-wise compression */
- calld->compression_algorithm = GRPC_COMPRESS_NONE;
- if (initial_metadata->idx.named.grpc_internal_encoding_request != NULL) {
- grpc_metadata_batch_remove(
- exec_ctx, initial_metadata,
- initial_metadata->idx.named.grpc_internal_encoding_request);
- }
- } else if (initial_metadata->idx.named.grpc_internal_encoding_request !=
- NULL) {
- grpc_mdelem md =
- initial_metadata->idx.named.grpc_internal_encoding_request->md;
- if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md),
- &calld->compression_algorithm)) {
- char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ if (!GPR_BITGET(channeld->enabled_algorithms_bitset,
+ compression_algorithm)) {
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR,
- "Invalid compression algorithm: '%s' (unknown). Ignoring.", val);
+ "Invalid compression algorithm: '%s' (previously disabled). "
+ "Ignoring.",
+ val);
gpr_free(val);
- calld->compression_algorithm = GRPC_COMPRESS_NONE;
+ calld->message_compression_algorithm = GRPC_MESSAGE_COMPRESS_NONE;
+ stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE;
}
*has_compression_algorithm = true;
grpc_metadata_batch_remove(
- exec_ctx, initial_metadata,
+ initial_metadata,
initial_metadata->idx.named.grpc_internal_encoding_request);
+ calld->message_compression_algorithm =
+ grpc_compression_algorithm_to_message_compression_algorithm(
+ compression_algorithm);
+ stream_compression_algorithm =
+ grpc_compression_algorithm_to_stream_compression_algorithm(
+ compression_algorithm);
} else {
/* If no algorithm was found in the metadata and we aren't
* exceptionally skipping compression, fall back to the channel
* default */
- if (channeld->default_stream_compression_algorithm !=
- GRPC_STREAM_COMPRESS_NONE) {
+ if (channeld->default_compression_algorithm != GRPC_COMPRESS_NONE) {
+ calld->message_compression_algorithm =
+ grpc_compression_algorithm_to_message_compression_algorithm(
+ channeld->default_compression_algorithm);
stream_compression_algorithm =
- channeld->default_stream_compression_algorithm;
- calld->compression_algorithm = GRPC_COMPRESS_NONE;
- } else {
- calld->compression_algorithm = channeld->default_compression_algorithm;
+ grpc_compression_algorithm_to_stream_compression_algorithm(
+ channeld->default_compression_algorithm);
}
*has_compression_algorithm = true;
}
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
/* hint compression algorithm */
if (stream_compression_algorithm != GRPC_STREAM_COMPRESS_NONE) {
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata,
- &calld->stream_compression_algorithm_storage,
+ initial_metadata, &calld->stream_compression_algorithm_storage,
grpc_stream_compression_encoding_mdelem(stream_compression_algorithm));
- } else if (calld->compression_algorithm != GRPC_COMPRESS_NONE) {
+ } else if (calld->message_compression_algorithm !=
+ GRPC_MESSAGE_COMPRESS_NONE) {
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->compression_algorithm_storage,
- grpc_compression_encoding_mdelem(calld->compression_algorithm));
+ initial_metadata, &calld->compression_algorithm_storage,
+ grpc_message_compression_encoding_mdelem(
+ calld->message_compression_algorithm));
}
if (error != GRPC_ERROR_NONE) return error;
/* convey supported compression algorithms */
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->accept_encoding_storage,
+ initial_metadata, &calld->accept_encoding_storage,
GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(
- channeld->supported_compression_algorithms));
+ channeld->supported_message_compression_algorithms));
if (error != GRPC_ERROR_NONE) return error;
- /* Do not overwrite accept-encoding header if it already presents. */
+ /* Do not overwrite accept-encoding header if it already presents (e.g. added
+ * by some proxy). */
if (!initial_metadata->idx.named.accept_encoding) {
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->accept_stream_encoding_storage,
+ initial_metadata, &calld->accept_stream_encoding_storage,
GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(
channeld->supported_stream_compression_algorithms));
}
@@ -211,67 +193,65 @@ static grpc_error *process_send_initial_metadata(
return error;
}
-static void send_message_on_complete(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices);
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_send_message_on_complete,
+static void send_message_on_complete(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_slice_buffer_reset_and_unref_internal(&calld->slices);
+ GRPC_CLOSURE_RUN(calld->original_send_message_on_complete,
GRPC_ERROR_REF(error));
}
-static void send_message_batch_continue(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- call_data *calld = (call_data *)elem->call_data;
+static void send_message_batch_continue(grpc_call_element* elem) {
+ call_data* calld = (call_data*)elem->call_data;
// Note: The call to grpc_call_next_op() results in yielding the
// call combiner, so we need to clear calld->send_message_batch
// before we do that.
- grpc_transport_stream_op_batch *send_message_batch =
+ grpc_transport_stream_op_batch* send_message_batch =
calld->send_message_batch;
- calld->send_message_batch = NULL;
- grpc_call_next_op(exec_ctx, elem, send_message_batch);
+ calld->send_message_batch = nullptr;
+ grpc_call_next_op(elem, send_message_batch);
}
-static void finish_send_message(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- call_data *calld = (call_data *)elem->call_data;
+static void finish_send_message(grpc_call_element* elem) {
+ call_data* calld = (call_data*)elem->call_data;
// Compress the data if appropriate.
grpc_slice_buffer tmp;
grpc_slice_buffer_init(&tmp);
uint32_t send_flags =
calld->send_message_batch->payload->send_message.send_message->flags;
- bool did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm,
+ bool did_compress = grpc_msg_compress(calld->message_compression_algorithm,
&calld->slices, &tmp);
if (did_compress) {
- if (GRPC_TRACER_ON(grpc_compression_trace)) {
- const char *algo_name;
+ if (grpc_compression_trace.enabled()) {
+ const char* algo_name;
const size_t before_size = calld->slices.length;
const size_t after_size = tmp.length;
const float savings_ratio = 1.0f - (float)after_size / (float)before_size;
- GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm,
- &algo_name));
- gpr_log(GPR_DEBUG, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR
- " bytes (%.2f%% savings)",
+ GPR_ASSERT(grpc_message_compression_algorithm_name(
+ calld->message_compression_algorithm, &algo_name));
+ gpr_log(GPR_DEBUG,
+ "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR
+ " bytes (%.2f%% savings)",
algo_name, before_size, after_size, 100 * savings_ratio);
}
grpc_slice_buffer_swap(&calld->slices, &tmp);
send_flags |= GRPC_WRITE_INTERNAL_COMPRESS;
} else {
- if (GRPC_TRACER_ON(grpc_compression_trace)) {
- const char *algo_name;
- GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm,
- &algo_name));
+ if (grpc_compression_trace.enabled()) {
+ const char* algo_name;
+ GPR_ASSERT(grpc_message_compression_algorithm_name(
+ calld->message_compression_algorithm, &algo_name));
gpr_log(GPR_DEBUG,
"Algorithm '%s' enabled but decided not to compress. Input size: "
"%" PRIuPTR,
algo_name, calld->slices.length);
}
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &tmp);
+ grpc_slice_buffer_destroy_internal(&tmp);
// Swap out the original byte stream with our new one and send the
// batch down.
grpc_byte_stream_destroy(
- exec_ctx, calld->send_message_batch->payload->send_message.send_message);
+ calld->send_message_batch->payload->send_message.send_message);
grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices,
send_flags);
calld->send_message_batch->payload->send_message.send_message =
@@ -279,27 +259,24 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx,
calld->original_send_message_on_complete =
calld->send_message_batch->on_complete;
calld->send_message_batch->on_complete = &calld->send_message_on_complete;
- send_message_batch_continue(exec_ctx, elem);
+ send_message_batch_continue(elem);
}
-static void fail_send_message_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_error *error) {
- call_data *calld = (call_data *)arg;
- if (calld->send_message_batch != NULL) {
+static void fail_send_message_batch_in_call_combiner(void* arg,
+ grpc_error* error) {
+ call_data* calld = (call_data*)arg;
+ if (calld->send_message_batch != nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, GRPC_ERROR_REF(error),
- calld->call_combiner);
- calld->send_message_batch = NULL;
+ calld->send_message_batch, GRPC_ERROR_REF(error), calld->call_combiner);
+ calld->send_message_batch = nullptr;
}
}
// Pulls a slice from the send_message byte stream and adds it to calld->slices.
-static grpc_error *pull_slice_from_send_message(grpc_exec_ctx *exec_ctx,
- call_data *calld) {
+static grpc_error* pull_slice_from_send_message(call_data* calld) {
grpc_slice incoming_slice;
- grpc_error *error = grpc_byte_stream_pull(
- exec_ctx, calld->send_message_batch->payload->send_message.send_message,
+ grpc_error* error = grpc_byte_stream_pull(
+ calld->send_message_batch->payload->send_message.send_message,
&incoming_slice);
if (error == GRPC_ERROR_NONE) {
grpc_slice_buffer_add(&calld->slices, incoming_slice);
@@ -311,106 +288,100 @@ static grpc_error *pull_slice_from_send_message(grpc_exec_ctx *exec_ctx,
// If all data has been read, invokes finish_send_message(). Otherwise,
// an async call to grpc_byte_stream_next() has been started, which will
// eventually result in calling on_send_message_next_done().
-static void continue_reading_send_message(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem) {
- call_data *calld = (call_data *)elem->call_data;
+static void continue_reading_send_message(grpc_call_element* elem) {
+ call_data* calld = (call_data*)elem->call_data;
while (grpc_byte_stream_next(
- exec_ctx, calld->send_message_batch->payload->send_message.send_message,
- ~(size_t)0, &calld->on_send_message_next_done)) {
- grpc_error *error = pull_slice_from_send_message(exec_ctx, calld);
+ calld->send_message_batch->payload->send_message.send_message, ~(size_t)0,
+ &calld->on_send_message_next_done)) {
+ grpc_error* error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) {
// Closure callback; does not take ownership of error.
- fail_send_message_batch_in_call_combiner(exec_ctx, calld, error);
+ fail_send_message_batch_in_call_combiner(calld, error);
GRPC_ERROR_UNREF(error);
return;
}
if (calld->slices.length ==
calld->send_message_batch->payload->send_message.send_message->length) {
- finish_send_message(exec_ctx, elem);
+ finish_send_message(elem);
break;
}
}
}
// Async callback for grpc_byte_stream_next().
-static void on_send_message_next_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
+static void on_send_message_next_done(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
// Closure callback; does not take ownership of error.
- fail_send_message_batch_in_call_combiner(exec_ctx, calld, error);
+ fail_send_message_batch_in_call_combiner(calld, error);
return;
}
- error = pull_slice_from_send_message(exec_ctx, calld);
+ error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) {
// Closure callback; does not take ownership of error.
- fail_send_message_batch_in_call_combiner(exec_ctx, calld, error);
+ fail_send_message_batch_in_call_combiner(calld, error);
GRPC_ERROR_UNREF(error);
return;
}
if (calld->slices.length ==
calld->send_message_batch->payload->send_message.send_message->length) {
- finish_send_message(exec_ctx, elem);
+ finish_send_message(elem);
} else {
- continue_reading_send_message(exec_ctx, elem);
+ continue_reading_send_message(elem);
}
}
-static void start_send_message_batch(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *unused) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
+static void start_send_message_batch(void* arg, grpc_error* unused) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
if (skip_compression(
elem,
calld->send_message_batch->payload->send_message.send_message->flags,
calld->send_initial_metadata_state == HAS_COMPRESSION_ALGORITHM)) {
- send_message_batch_continue(exec_ctx, elem);
+ send_message_batch_continue(elem);
} else {
- continue_reading_send_message(exec_ctx, elem);
+ continue_reading_send_message(elem);
}
}
static void compress_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = (call_data *)elem->call_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0);
// Handle cancel_stream.
if (batch->cancel_stream) {
GRPC_ERROR_UNREF(calld->cancel_error);
calld->cancel_error =
GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error);
- if (calld->send_message_batch != NULL) {
+ if (calld->send_message_batch != nullptr) {
if (calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_CREATE(fail_send_message_batch_in_call_combiner, calld,
grpc_schedule_on_exec_ctx),
GRPC_ERROR_REF(calld->cancel_error), "failing send_message op");
} else {
grpc_byte_stream_shutdown(
- exec_ctx,
+
calld->send_message_batch->payload->send_message.send_message,
GRPC_ERROR_REF(calld->cancel_error));
}
}
} else if (calld->cancel_error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch, GRPC_ERROR_REF(calld->cancel_error),
- calld->call_combiner);
+ batch, GRPC_ERROR_REF(calld->cancel_error), calld->call_combiner);
goto done;
}
// Handle send_initial_metadata.
if (batch->send_initial_metadata) {
GPR_ASSERT(calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN);
bool has_compression_algorithm;
- grpc_error *error = process_send_initial_metadata(
- exec_ctx, elem,
- batch->payload->send_initial_metadata.send_initial_metadata,
+ grpc_error* error = process_send_initial_metadata(
+ elem, batch->payload->send_initial_metadata.send_initial_metadata,
&has_compression_algorithm);
if (error != GRPC_ERROR_NONE) {
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error,
+ grpc_transport_stream_op_batch_finish_with_failure(batch, error,
calld->call_combiner);
goto done;
}
@@ -422,16 +393,16 @@ static void compress_start_transport_stream_op_batch(
// for this, since we can't send two batches down while holding the
// call combiner, since the connected_channel filter (at the bottom of
// the call stack) will release the call combiner for each batch it sees.
- if (calld->send_message_batch != NULL) {
+ if (calld->send_message_batch != nullptr) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
&calld->start_send_message_batch_in_call_combiner, GRPC_ERROR_NONE,
"starting send_message after send_initial_metadata");
}
}
// Handle send_message.
if (batch->send_message) {
- GPR_ASSERT(calld->send_message_batch == NULL);
+ GPR_ASSERT(calld->send_message_batch == nullptr);
calld->send_message_batch = batch;
// If we have not yet seen send_initial_metadata, then we have to
// wait. We save the batch in calld and then drop the call
@@ -439,24 +410,23 @@ static void compress_start_transport_stream_op_batch(
// send_initial_metadata.
if (calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN) {
GRPC_CALL_COMBINER_STOP(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
"send_message batch pending send_initial_metadata");
goto done;
}
- start_send_message_batch(exec_ctx, elem, GRPC_ERROR_NONE);
+ start_send_message_batch(elem, GRPC_ERROR_NONE);
} else {
// Pass control down the stack.
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
done:
GPR_TIMER_END("compress_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
calld->call_combiner = args->call_combiner;
calld->cancel_error = GRPC_ERROR_NONE;
grpc_slice_buffer_init(&calld->slices);
@@ -470,26 +440,24 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *calld = (call_data *)elem->call_data;
- grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices);
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_slice_buffer_destroy_internal(&calld->slices);
GRPC_ERROR_UNREF(calld->cancel_error);
}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- channel_data *channeld = (channel_data *)elem->channel_data;
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ channel_data* channeld = (channel_data*)elem->channel_data;
- /* Configuration for message compression */
channeld->enabled_algorithms_bitset =
grpc_channel_args_compression_algorithm_get_states(args->channel_args);
-
channeld->default_compression_algorithm =
grpc_channel_args_get_compression_algorithm(args->channel_args);
+
/* Make sure the default isn't disabled. */
if (!GPR_BITGET(channeld->enabled_algorithms_bitset,
channeld->default_compression_algorithm)) {
@@ -499,39 +467,25 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
channeld->default_compression_algorithm = GRPC_COMPRESS_NONE;
}
- channeld->supported_compression_algorithms =
+ uint32_t supported_compression_algorithms =
(((1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1) &
channeld->enabled_algorithms_bitset) |
1u;
- /* Configuration for stream compression */
- channeld->enabled_stream_compression_algorithms_bitset =
- grpc_channel_args_stream_compression_algorithm_get_states(
- args->channel_args);
-
- channeld->default_stream_compression_algorithm =
- grpc_channel_args_get_stream_compression_algorithm(args->channel_args);
-
- if (!GPR_BITGET(channeld->enabled_stream_compression_algorithms_bitset,
- channeld->default_stream_compression_algorithm)) {
- gpr_log(GPR_DEBUG,
- "stream compression algorithm %d not enabled: switching to none",
- channeld->default_stream_compression_algorithm);
- channeld->default_stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE;
- }
+ channeld->supported_message_compression_algorithms =
+ grpc_compression_bitset_to_message_bitset(
+ supported_compression_algorithms);
channeld->supported_stream_compression_algorithms =
- (((1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1) &
- channeld->enabled_stream_compression_algorithms_bitset) |
- 1u;
+ grpc_compression_bitset_to_stream_bitset(
+ supported_compression_algorithms);
GPR_ASSERT(!args->is_last);
return GRPC_ERROR_NONE;
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
const grpc_channel_filter grpc_message_compress_filter = {
compress_start_transport_stream_op_batch,
diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.h b/src/core/ext/filters/http/message_compress/message_compress_filter.h
index c121a391eb..62207911c7 100644
--- a/src/core/ext/filters/http/message_compress/message_compress_filter.h
+++ b/src/core/ext/filters/http/message_compress/message_compress_filter.h
@@ -48,4 +48,4 @@
extern const grpc_channel_filter grpc_message_compress_filter;
#endif /* GRPC_CORE_EXT_FILTERS_HTTP_MESSAGE_COMPRESS_MESSAGE_COMPRESS_FILTER_H \
- */
+ */
diff --git a/src/core/ext/filters/http/server/http_server_filter.c b/src/core/ext/filters/http/server/http_server_filter.cc
index 03958136b4..508a3bf9fc 100644
--- a/src/core/ext/filters/http/server/http_server_filter.c
+++ b/src/core/ext/filters/http/server/http_server_filter.cc
@@ -31,8 +31,9 @@
#define EXPECTED_CONTENT_TYPE "application/grpc"
#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1
-typedef struct call_data {
- grpc_call_combiner *call_combiner;
+namespace {
+struct call_data {
+ grpc_call_combiner* call_combiner;
grpc_linked_mdelem status;
grpc_linked_mdelem content_type;
@@ -42,15 +43,15 @@ typedef struct call_data {
/* flag to ensure payload_bin is delivered only once */
bool payload_bin_delivered;
- grpc_metadata_batch *recv_initial_metadata;
- uint32_t *recv_initial_metadata_flags;
+ grpc_metadata_batch* recv_initial_metadata;
+ uint32_t* recv_initial_metadata_flags;
/** Closure to call when finished with the hs_on_recv hook */
- grpc_closure *on_done_recv;
+ grpc_closure* on_done_recv;
/** Closure to call when we retrieve read message from the path URI
*/
- grpc_closure *recv_message_ready;
- grpc_closure *on_complete;
- grpc_byte_stream **pp_recv_message;
+ grpc_closure* recv_message_ready;
+ grpc_closure* on_complete;
+ grpc_byte_stream** pp_recv_message;
grpc_slice_buffer read_slice_buffer;
grpc_slice_buffer_stream read_stream;
@@ -60,30 +61,31 @@ typedef struct call_data {
grpc_closure hs_on_recv;
grpc_closure hs_on_complete;
grpc_closure hs_recv_message_ready;
-} call_data;
+};
-typedef struct channel_data { uint8_t unused; } channel_data;
+struct channel_data {
+ uint8_t unused;
+};
+} // namespace
-static grpc_error *server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_metadata_batch *b) {
- if (b->idx.named.grpc_message != NULL) {
+static grpc_error* server_filter_outgoing_metadata(grpc_call_element* elem,
+ grpc_metadata_batch* b) {
+ if (b->idx.named.grpc_message != nullptr) {
grpc_slice pct_encoded_msg = grpc_percent_encode_slice(
GRPC_MDVALUE(b->idx.named.grpc_message->md),
grpc_compatible_percent_encoding_unreserved_bytes);
if (grpc_slice_is_equivalent(pct_encoded_msg,
GRPC_MDVALUE(b->idx.named.grpc_message->md))) {
- grpc_slice_unref_internal(exec_ctx, pct_encoded_msg);
+ grpc_slice_unref_internal(pct_encoded_msg);
} else {
- grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message,
- pct_encoded_msg);
+ grpc_metadata_batch_set_value(b->idx.named.grpc_message, pct_encoded_msg);
}
}
return GRPC_ERROR_NONE;
}
-static void add_error(const char *error_name, grpc_error **cumulative,
- grpc_error *new_err) {
+static void add_error(const char* error_name, grpc_error** cumulative,
+ grpc_error* new_err) {
if (new_err == GRPC_ERROR_NONE) return;
if (*cumulative == GRPC_ERROR_NONE) {
*cumulative = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_name);
@@ -91,14 +93,13 @@ static void add_error(const char *error_name, grpc_error **cumulative,
*cumulative = grpc_error_add_child(*cumulative, new_err);
}
-static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_metadata_batch *b) {
- call_data *calld = (call_data *)elem->call_data;
- grpc_error *error = GRPC_ERROR_NONE;
- static const char *error_name = "Failed processing incoming headers";
+static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
+ grpc_metadata_batch* b) {
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* error_name = "Failed processing incoming headers";
- if (b->idx.named.method != NULL) {
+ if (b->idx.named.method != nullptr) {
if (grpc_mdelem_eq(b->idx.named.method->md, GRPC_MDELEM_METHOD_POST)) {
*calld->recv_initial_metadata_flags &=
~(GRPC_INITIAL_METADATA_CACHEABLE_REQUEST |
@@ -121,7 +122,7 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
b->idx.named.method->md));
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.method);
+ grpc_metadata_batch_remove(b, b->idx.named.method);
} else {
add_error(
error_name, &error,
@@ -130,14 +131,14 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":method")));
}
- if (b->idx.named.te != NULL) {
+ if (b->idx.named.te != nullptr) {
if (!grpc_mdelem_eq(b->idx.named.te->md, GRPC_MDELEM_TE_TRAILERS)) {
add_error(error_name, &error,
grpc_attach_md_to_error(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
b->idx.named.te->md));
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.te);
+ grpc_metadata_batch_remove(b, b->idx.named.te);
} else {
add_error(error_name, &error,
grpc_error_set_str(
@@ -145,7 +146,7 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_STR_KEY, grpc_slice_from_static_string("te")));
}
- if (b->idx.named.scheme != NULL) {
+ if (b->idx.named.scheme != nullptr) {
if (!grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTP) &&
!grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTPS) &&
!grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_GRPC)) {
@@ -154,7 +155,7 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
b->idx.named.scheme->md));
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.scheme);
+ grpc_metadata_batch_remove(b, b->idx.named.scheme);
} else {
add_error(
error_name, &error,
@@ -163,7 +164,7 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":scheme")));
}
- if (b->idx.named.content_type != NULL) {
+ if (b->idx.named.content_type != nullptr) {
if (!grpc_mdelem_eq(b->idx.named.content_type->md,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) {
if (grpc_slice_buf_start_eq(GRPC_MDVALUE(b->idx.named.content_type->md),
@@ -183,16 +184,16 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
} else {
/* TODO(klempner): We're currently allowing this, but we shouldn't
see it without a proxy so log for now. */
- char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md),
+ char* val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md),
GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "Unexpected content-type '%s'", val);
gpr_free(val);
}
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type);
+ grpc_metadata_batch_remove(b, b->idx.named.content_type);
}
- if (b->idx.named.path == NULL) {
+ if (b->idx.named.path == nullptr) {
add_error(error_name, &error,
grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"),
@@ -203,7 +204,7 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
* query parameter which is base64 encoded request payload. */
const char k_query_separator = '?';
grpc_slice path_slice = GRPC_MDVALUE(b->idx.named.path->md);
- uint8_t *path_ptr = (uint8_t *)GRPC_SLICE_START_PTR(path_slice);
+ uint8_t* path_ptr = (uint8_t*)GRPC_SLICE_START_PTR(path_slice);
size_t path_length = GRPC_SLICE_LENGTH(path_slice);
/* offset of the character '?' */
size_t offset = 0;
@@ -216,41 +217,40 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
/* substitute path metadata with just the path (not query) */
grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset));
+ GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset));
- grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path,
+ grpc_metadata_batch_substitute(b, b->idx.named.path,
mdelem_path_without_query);
/* decode payload from query and add to the slice buffer to be returned */
const int k_url_safe = 1;
- grpc_slice_buffer_add(
- &calld->read_slice_buffer,
- grpc_base64_decode_with_len(
- exec_ctx, (const char *)GRPC_SLICE_START_PTR(query_slice),
- GRPC_SLICE_LENGTH(query_slice), k_url_safe));
+ grpc_slice_buffer_add(&calld->read_slice_buffer,
+ grpc_base64_decode_with_len(
+ (const char*)GRPC_SLICE_START_PTR(query_slice),
+ GRPC_SLICE_LENGTH(query_slice), k_url_safe));
grpc_slice_buffer_stream_init(&calld->read_stream,
&calld->read_slice_buffer, 0);
calld->seen_path_with_query = true;
- grpc_slice_unref_internal(exec_ctx, query_slice);
+ grpc_slice_unref_internal(query_slice);
} else {
gpr_log(GPR_ERROR, "GET request without QUERY");
}
}
- if (b->idx.named.host != NULL && b->idx.named.authority == NULL) {
- grpc_linked_mdelem *el = b->idx.named.host;
+ if (b->idx.named.host != nullptr && b->idx.named.authority == nullptr) {
+ grpc_linked_mdelem* el = b->idx.named.host;
grpc_mdelem md = GRPC_MDELEM_REF(el->md);
- grpc_metadata_batch_remove(exec_ctx, b, el);
- add_error(
- error_name, &error,
- grpc_metadata_batch_add_head(
- exec_ctx, b, el, grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_AUTHORITY,
- grpc_slice_ref_internal(GRPC_MDVALUE(md)))));
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ grpc_metadata_batch_remove(b, el);
+ add_error(error_name, &error,
+ grpc_metadata_batch_add_head(
+ b, el,
+ grpc_mdelem_from_slices(
+ GRPC_MDSTR_AUTHORITY,
+ grpc_slice_ref_internal(GRPC_MDVALUE(md)))));
+ GRPC_MDELEM_UNREF(md);
}
- if (b->idx.named.authority == NULL) {
+ if (b->idx.named.authority == nullptr) {
add_error(
error_name, &error,
grpc_error_set_str(
@@ -261,85 +261,78 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
return error;
}
-static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *err) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+static void hs_on_recv(void* user_data, grpc_error* err) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
if (err == GRPC_ERROR_NONE) {
- err = server_filter_incoming_metadata(exec_ctx, elem,
- calld->recv_initial_metadata);
+ err = server_filter_incoming_metadata(elem, calld->recv_initial_metadata);
} else {
GRPC_ERROR_REF(err);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->on_done_recv, err);
+ GRPC_CLOSURE_RUN(calld->on_done_recv, err);
}
-static void hs_on_complete(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *err) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+static void hs_on_complete(void* user_data, grpc_error* err) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
/* Call recv_message_ready if we got the payload via the path field */
- if (calld->seen_path_with_query && calld->recv_message_ready != NULL) {
+ if (calld->seen_path_with_query && calld->recv_message_ready != nullptr) {
*calld->pp_recv_message = calld->payload_bin_delivered
- ? NULL
- : (grpc_byte_stream *)&calld->read_stream;
+ ? nullptr
+ : (grpc_byte_stream*)&calld->read_stream;
// Re-enter call combiner for recv_message_ready, since the surface
// code will release the call combiner for each callback it receives.
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
- calld->recv_message_ready, GRPC_ERROR_REF(err),
+ GRPC_CALL_COMBINER_START(calld->call_combiner, calld->recv_message_ready,
+ GRPC_ERROR_REF(err),
"resuming recv_message_ready from on_complete");
- calld->recv_message_ready = NULL;
+ calld->recv_message_ready = nullptr;
calld->payload_bin_delivered = true;
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->on_complete, GRPC_ERROR_REF(err));
+ GRPC_CLOSURE_RUN(calld->on_complete, GRPC_ERROR_REF(err));
}
-static void hs_recv_message_ready(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *err) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+static void hs_recv_message_ready(void* user_data, grpc_error* err) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
if (calld->seen_path_with_query) {
// Do nothing. This is probably a GET request, and payload will be
// returned in hs_on_complete callback.
// Note that we release the call combiner here, so that other
// callbacks can run.
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
"pausing recv_message_ready until on_complete");
} else {
- GRPC_CLOSURE_RUN(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err));
+ GRPC_CLOSURE_RUN(calld->recv_message_ready, GRPC_ERROR_REF(err));
}
}
-static grpc_error *hs_mutate_op(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
+static grpc_error* hs_mutate_op(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
/* grab pointers to our data from the call element */
- call_data *calld = (call_data *)elem->call_data;
+ call_data* calld = (call_data*)elem->call_data;
if (op->send_initial_metadata) {
- grpc_error *error = GRPC_ERROR_NONE;
- static const char *error_name = "Failed sending initial metadata";
- add_error(
- error_name, &error,
- grpc_metadata_batch_add_head(
- exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
- &calld->status, GRPC_MDELEM_STATUS_200));
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* error_name = "Failed sending initial metadata";
+ add_error(error_name, &error,
+ grpc_metadata_batch_add_head(
+ op->payload->send_initial_metadata.send_initial_metadata,
+ &calld->status, GRPC_MDELEM_STATUS_200));
+ add_error(error_name, &error,
+ grpc_metadata_batch_add_tail(
+ op->payload->send_initial_metadata.send_initial_metadata,
+ &calld->content_type,
+ GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC));
add_error(
error_name, &error,
- grpc_metadata_batch_add_tail(
- exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
- &calld->content_type,
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC));
- add_error(error_name, &error,
- server_filter_outgoing_metadata(
- exec_ctx, elem,
- op->payload->send_initial_metadata.send_initial_metadata));
+ server_filter_outgoing_metadata(
+ elem, op->payload->send_initial_metadata.send_initial_metadata));
if (error != GRPC_ERROR_NONE) return error;
}
if (op->recv_initial_metadata) {
/* substitute our callback for the higher callback */
- GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags != NULL);
+ GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags != nullptr);
calld->recv_initial_metadata =
op->payload->recv_initial_metadata.recv_initial_metadata;
calld->recv_initial_metadata_flags =
@@ -364,9 +357,8 @@ static grpc_error *hs_mutate_op(grpc_exec_ctx *exec_ctx,
}
if (op->send_trailing_metadata) {
- grpc_error *error = server_filter_outgoing_metadata(
- exec_ctx, elem,
- op->payload->send_trailing_metadata.send_trailing_metadata);
+ grpc_error* error = server_filter_outgoing_metadata(
+ elem, op->payload->send_trailing_metadata.send_trailing_metadata);
if (error != GRPC_ERROR_NONE) return error;
}
@@ -374,26 +366,24 @@ static grpc_error *hs_mutate_op(grpc_exec_ctx *exec_ctx,
}
static void hs_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- call_data *calld = (call_data *)elem->call_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
+ call_data* calld = (call_data*)elem->call_data;
GPR_TIMER_BEGIN("hs_start_transport_stream_op_batch", 0);
- grpc_error *error = hs_mutate_op(exec_ctx, elem, op);
+ grpc_error* error = hs_mutate_op(elem, op);
if (error != GRPC_ERROR_NONE) {
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error,
+ grpc_transport_stream_op_batch_finish_with_failure(op, error,
calld->call_combiner);
} else {
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
GPR_TIMER_END("hs_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
/* grab pointers to our data from the call element */
- call_data *calld = (call_data *)elem->call_data;
+ call_data* calld = (call_data*)elem->call_data;
/* initialize members */
calld->call_combiner = args->call_combiner;
GRPC_CLOSURE_INIT(&calld->hs_on_recv, hs_on_recv, elem,
@@ -407,24 +397,22 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *calld = (call_data *)elem->call_data;
- grpc_slice_buffer_destroy_internal(exec_ctx, &calld->read_slice_buffer);
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_slice_buffer_destroy_internal(&calld->read_slice_buffer);
}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
return GRPC_ERROR_NONE;
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
const grpc_channel_filter grpc_http_server_filter = {
hs_start_transport_stream_op_batch,
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.c b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
index ca8a3b2a13..a414229768 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.c
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
@@ -31,7 +31,8 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/static_metadata.h"
-typedef struct call_data {
+namespace {
+struct call_data {
intptr_t id; /**< an id unique to the call */
bool have_trailing_md_string;
grpc_slice trailing_md_string;
@@ -43,24 +44,24 @@ typedef struct call_data {
/* stores the recv_initial_metadata op's ready closure, which we wrap with our
* own (on_initial_md_ready) in order to capture the incoming initial metadata
* */
- grpc_closure *ops_recv_initial_metadata_ready;
+ grpc_closure* ops_recv_initial_metadata_ready;
/* to get notified of the availability of the incoming initial metadata. */
grpc_closure on_initial_md_ready;
- grpc_metadata_batch *recv_initial_metadata;
-} call_data;
+ grpc_metadata_batch* recv_initial_metadata;
+};
-typedef struct channel_data {
+struct channel_data {
intptr_t id; /**< an id unique to the channel */
-} channel_data;
+};
+} // namespace
-static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *err) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+static void on_initial_md_ready(void* user_data, grpc_error* err) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
if (err == GRPC_ERROR_NONE) {
- if (calld->recv_initial_metadata->idx.named.path != NULL) {
+ if (calld->recv_initial_metadata->idx.named.path != nullptr) {
calld->service_method = grpc_slice_ref_internal(
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md));
calld->have_service_method = true;
@@ -68,27 +69,26 @@ static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data,
err = grpc_error_add_child(
err, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing :path header"));
}
- if (calld->recv_initial_metadata->idx.named.lb_token != NULL) {
+ if (calld->recv_initial_metadata->idx.named.lb_token != nullptr) {
calld->initial_md_string = grpc_slice_ref_internal(
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.lb_token->md));
calld->have_initial_md_string = true;
grpc_metadata_batch_remove(
- exec_ctx, calld->recv_initial_metadata,
+ calld->recv_initial_metadata,
calld->recv_initial_metadata->idx.named.lb_token);
}
} else {
GRPC_ERROR_REF(err);
}
calld->ops_recv_initial_metadata_ready->cb(
- exec_ctx, calld->ops_recv_initial_metadata_ready->cb_arg, err);
+ calld->ops_recv_initial_metadata_ready->cb_arg, err);
GRPC_ERROR_UNREF(err);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
calld->id = (intptr_t)args->call_stack;
GRPC_CLOSURE_INIT(&calld->on_initial_md_ready, on_initial_md_ready, elem,
grpc_schedule_on_exec_ctx);
@@ -108,10 +108,10 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *calld = (call_data *)elem->call_data;
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ call_data* calld = (call_data*)elem->call_data;
/* TODO(dgq): do something with the data
channel_data *chand = elem->channel_data;
@@ -125,23 +125,22 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
*/
if (calld->have_initial_md_string) {
- grpc_slice_unref_internal(exec_ctx, calld->initial_md_string);
+ grpc_slice_unref_internal(calld->initial_md_string);
}
if (calld->have_trailing_md_string) {
- grpc_slice_unref_internal(exec_ctx, calld->trailing_md_string);
+ grpc_slice_unref_internal(calld->trailing_md_string);
}
if (calld->have_service_method) {
- grpc_slice_unref_internal(exec_ctx, calld->service_method);
+ grpc_slice_unref_internal(calld->service_method);
}
}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
- channel_data *chand = (channel_data *)elem->channel_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
chand->id = (intptr_t)args->channel_stack;
/* TODO(dgq): do something with the data
@@ -158,8 +157,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
/* TODO(dgq): do something with the data
channel_data *chand = elem->channel_data;
grpc_load_reporting_call_data lr_call_data = {
@@ -173,11 +171,10 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
*/
}
-static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx,
- void *user_data,
+static grpc_filtered_mdelem lr_trailing_md_filter(void* user_data,
grpc_mdelem md) {
- grpc_call_element *elem = (grpc_call_element *)user_data;
- call_data *calld = (call_data *)elem->call_data;
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_COST_BIN)) {
calld->trailing_md_string = GRPC_MDVALUE(md);
return GRPC_FILTERED_REMOVE();
@@ -186,10 +183,9 @@ static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx,
}
static void lr_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
GPR_TIMER_BEGIN("lr_start_transport_stream_op_batch", 0);
- call_data *calld = (call_data *)elem->call_data;
+ call_data* calld = (call_data*)elem->call_data;
if (op->recv_initial_metadata) {
/* substitute our callback for the higher callback */
@@ -203,12 +199,11 @@ static void lr_start_transport_stream_op_batch(
GRPC_LOG_IF_ERROR(
"grpc_metadata_batch_filter",
grpc_metadata_batch_filter(
- exec_ctx,
op->payload->send_trailing_metadata.send_trailing_metadata,
lr_trailing_md_filter, elem,
"LR trailing metadata filtering error"));
}
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
GPR_TIMER_END("lr_start_transport_stream_op_batch", 0);
}
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.h b/src/core/ext/filters/load_reporting/server_load_reporting_filter.h
index 9527868c9f..1baee5e7cd 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.h
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.h
@@ -25,4 +25,4 @@
extern const grpc_channel_filter grpc_server_load_reporting_filter;
#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H \
- */
+ */
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.c b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
index 2486ead427..9d1dfcbb4c 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.c
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
@@ -32,30 +32,30 @@
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel_init.h"
-static bool is_load_reporting_enabled(const grpc_channel_args *a) {
+static bool is_load_reporting_enabled(const grpc_channel_args* a) {
return grpc_channel_arg_get_bool(
grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false);
}
static bool maybe_add_server_load_reporting_filter(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
- const grpc_channel_args *args =
+ grpc_channel_stack_builder* builder, void* arg) {
+ const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
- const grpc_channel_filter *filter = (const grpc_channel_filter *)arg;
- grpc_channel_stack_builder_iterator *it =
+ const grpc_channel_filter* filter = (const grpc_channel_filter*)arg;
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_iterator_find(builder, filter->name);
const bool already_has_load_reporting_filter =
!grpc_channel_stack_builder_iterator_is_end(it);
grpc_channel_stack_builder_iterator_destroy(it);
if (is_load_reporting_enabled(args) && !already_has_load_reporting_filter) {
- return grpc_channel_stack_builder_prepend_filter(builder, filter, NULL,
- NULL);
+ return grpc_channel_stack_builder_prepend_filter(builder, filter, nullptr,
+ nullptr);
}
return true;
}
grpc_arg grpc_load_reporting_enable_arg() {
- return grpc_channel_arg_integer_create((char *)GRPC_ARG_ENABLE_LOAD_REPORTING,
+ return grpc_channel_arg_integer_create((char*)GRPC_ARG_ENABLE_LOAD_REPORTING,
1);
}
@@ -64,7 +64,7 @@ grpc_arg grpc_load_reporting_enable_arg() {
void grpc_server_load_reporting_plugin_init(void) {
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
maybe_add_server_load_reporting_filter,
- (void *)&grpc_server_load_reporting_filter);
+ (void*)&grpc_server_load_reporting_filter);
}
void grpc_server_load_reporting_plugin_shutdown() {}
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h
index 65a6d0900e..4b694d336d 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h
@@ -45,15 +45,15 @@ typedef struct grpc_load_reporting_call_data {
/** Only valid when \a source is \a GRPC_LR_POINT_CALL_DESTRUCTION, that is,
* once the call has completed */
- const grpc_call_final_info *final_info;
+ const grpc_call_final_info* final_info;
- const char *initial_md_string; /**< value string for LR's initial md key */
- const char *trailing_md_string; /**< value string for LR's trailing md key */
- const char *method_name; /**< Corresponds to :path header */
+ const char* initial_md_string; /**< value string for LR's initial md key */
+ const char* trailing_md_string; /**< value string for LR's trailing md key */
+ const char* method_name; /**< Corresponds to :path header */
} grpc_load_reporting_call_data;
/** Return a \a grpc_arg enabling load reporting */
grpc_arg grpc_load_reporting_enable_arg();
#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H \
- */
+ */
diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.cc
index 0ac803ed41..7b86e4cd6c 100644
--- a/src/core/ext/filters/max_age/max_age_filter.c
+++ b/src/core/ext/filters/max_age/max_age_filter.cc
@@ -33,11 +33,12 @@
#define MAX_CONNECTION_AGE_JITTER 0.1
#define MAX_CONNECTION_AGE_INTEGER_OPTIONS \
- (grpc_integer_options) { DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX }
+ { DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX }
#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \
- (grpc_integer_options) { DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
+ { DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
-typedef struct channel_data {
+namespace {
+struct channel_data {
/* We take a reference to the channel stack for the timer callback */
grpc_channel_stack* channel_stack;
/* Guards access to max_age_timer, max_age_timer_pending, max_age_grace_timer
@@ -56,11 +57,11 @@ typedef struct channel_data {
max_connection_idle */
grpc_timer max_idle_timer;
/* Allowed max time a channel may have no outstanding rpcs */
- gpr_timespec max_connection_idle;
+ grpc_millis max_connection_idle;
/* Allowed max time a channel may exist */
- gpr_timespec max_connection_age;
+ grpc_millis max_connection_age;
/* Allowed grace period after the channel reaches its max age */
- gpr_timespec max_connection_age_grace;
+ grpc_millis max_connection_age_grace;
/* Closure to run when the channel's idle duration reaches max_connection_idle
and should be closed gracefully */
grpc_closure close_max_idle_channel;
@@ -84,98 +85,92 @@ typedef struct channel_data {
grpc_connectivity_state connectivity_state;
/* Number of active calls */
gpr_atm call_count;
-} channel_data;
+};
+} // namespace
/* Increase the nubmer of active calls. Before the increasement, if there are no
calls, the max_idle_timer should be cancelled. */
-static void increase_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
+static void increase_call_count(channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, 1) == 0) {
- grpc_timer_cancel(exec_ctx, &chand->max_idle_timer);
+ grpc_timer_cancel(&chand->max_idle_timer);
}
}
/* Decrease the nubmer of active calls. After the decrement, if there are no
calls, the max_idle_timer should be started. */
-static void decrease_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
+static void decrease_call_count(channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_idle_timer");
grpc_timer_init(
- exec_ctx, &chand->max_idle_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_idle),
- &chand->close_max_idle_channel, gpr_now(GPR_CLOCK_MONOTONIC));
+ &chand->max_idle_timer,
+ grpc_core::ExecCtx::Get()->Now() + chand->max_connection_idle,
+ &chand->close_max_idle_channel);
}
}
-static void start_max_idle_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_max_idle_timer_after_init(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
/* Decrease call_count. If there are no active calls at this time,
max_idle_timer will start here. If the number of active calls is not 0,
max_idle_timer will start after all the active calls end. */
- decrease_call_count(exec_ctx, chand);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
+ decrease_call_count(chand);
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
}
-static void start_max_age_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_max_age_timer_after_init(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
- grpc_timer_init(
- exec_ctx, &chand->max_age_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_age),
- &chand->close_max_age_channel, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&chand->max_age_timer,
+ grpc_core::ExecCtx::Get()->Now() + chand->max_connection_age,
+ &chand->close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
- grpc_transport_op* op = grpc_make_transport_op(NULL);
- op->on_connectivity_state_change = &chand->channel_connectivity_changed,
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ op->on_connectivity_state_change = &chand->channel_connectivity_changed;
op->connectivity_state = &chand->connectivity_state;
- grpc_channel_next_op(exec_ctx,
- grpc_channel_stack_element(chand->channel_stack, 0), op);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
+ grpc_channel_next_op(grpc_channel_stack_element(chand->channel_stack, 0), op);
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
}
-static void start_max_age_grace_timer_after_goaway_op(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void start_max_age_grace_timer_after_goaway_op(void* arg,
grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer");
- grpc_timer_init(exec_ctx, &chand->max_age_grace_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- chand->max_connection_age_grace),
- &chand->force_close_max_age_channel,
- gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(
+ &chand->max_age_grace_timer,
+ chand->max_connection_age_grace == GRPC_MILLIS_INF_FUTURE
+ ? GRPC_MILLIS_INF_FUTURE
+ : grpc_core::ExecCtx::Get()->Now() + chand->max_connection_age_grace,
+ &chand->force_close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
}
-static void close_max_idle_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void close_max_idle_channel(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
if (error == GRPC_ERROR_NONE) {
/* Prevent the max idle timer from being set again */
gpr_atm_no_barrier_fetch_add(&chand->call_count, 1);
- grpc_transport_op* op = grpc_make_transport_op(NULL);
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->goaway_error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_idle"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_idle_channel", error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
- "max_age max_idle_timer");
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_idle_timer");
}
-static void close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void close_max_age_channel(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = false;
@@ -190,58 +185,54 @@ static void close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_age_channel", error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
- "max_age max_age_timer");
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_age_timer");
}
-static void force_close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void force_close_max_age_channel(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = false;
gpr_mu_unlock(&chand->max_age_timer_mu);
if (error == GRPC_ERROR_NONE) {
- grpc_transport_op* op = grpc_make_transport_op(NULL);
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel reaches max age");
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("force_close_max_age_channel", error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
- "max_age max_age_grace_timer");
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_age_grace_timer");
}
-static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void channel_connectivity_changed(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
- grpc_transport_op* op = grpc_make_transport_op(NULL);
- op->on_connectivity_state_change = &chand->channel_connectivity_changed,
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ op->on_connectivity_state_change = &chand->channel_connectivity_changed;
op->connectivity_state = &chand->connectivity_state;
- grpc_channel_next_op(
- exec_ctx, grpc_channel_stack_element(chand->channel_stack, 0), op);
+ grpc_channel_next_op(grpc_channel_stack_element(chand->channel_stack, 0),
+ op);
} else {
gpr_mu_lock(&chand->max_age_timer_mu);
if (chand->max_age_timer_pending) {
- grpc_timer_cancel(exec_ctx, &chand->max_age_timer);
+ grpc_timer_cancel(&chand->max_age_timer);
chand->max_age_timer_pending = false;
}
if (chand->max_age_grace_timer_pending) {
- grpc_timer_cancel(exec_ctx, &chand->max_age_grace_timer);
+ grpc_timer_cancel(&chand->max_age_grace_timer);
chand->max_age_grace_timer_pending = false;
}
gpr_mu_unlock(&chand->max_age_timer_mu);
/* If there are no active calls, this increasement will cancel
max_idle_timer, and prevent max_idle_timer from being started in the
future. */
- increase_call_count(exec_ctx, chand);
+ increase_call_count(chand);
}
}
@@ -249,7 +240,8 @@ static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* arg,
connection storms. Note that the MAX_CONNECTION_AGE option without jitter
would not create connection storms by itself, but if there happened to be a
connection storm it could cause it to repeat at a fixed period. */
-static int add_random_max_connection_age_jitter(int value) {
+static grpc_millis
+add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) {
/* generate a random number between 1 - MAX_CONNECTION_AGE_JITTER and
1 + MAX_CONNECTION_AGE_JITTER */
double multiplier = rand() * MAX_CONNECTION_AGE_JITTER * 2.0 / RAND_MAX +
@@ -257,29 +249,29 @@ static int add_random_max_connection_age_jitter(int value) {
double result = multiplier * value;
/* INT_MAX - 0.5 converts the value to float, so that result will not be
cast to int implicitly before the comparison. */
- return result > INT_MAX - 0.5 ? INT_MAX : (int)result;
+ return result > ((double)GRPC_MILLIS_INF_FUTURE) - 0.5
+ ? GRPC_MILLIS_INF_FUTURE
+ : (grpc_millis)result;
}
/* Constructor for call_data. */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
- increase_call_count(exec_ctx, chand);
+ increase_call_count(chand);
return GRPC_ERROR_NONE;
}
/* Destructor for call_data. */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
channel_data* chand = (channel_data*)elem->channel_data;
- decrease_call_count(exec_ctx, chand);
+ decrease_call_count(chand);
}
/* Constructor for channel_data. */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
gpr_mu_init(&chand->max_age_timer_mu);
@@ -287,46 +279,36 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
chand->max_age_grace_timer_pending = false;
chand->channel_stack = args->channel_stack;
chand->max_connection_age =
- DEFAULT_MAX_CONNECTION_AGE_MS == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(add_random_max_connection_age_jitter(
- DEFAULT_MAX_CONNECTION_AGE_MS),
- GPR_TIMESPAN);
+ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(
+ DEFAULT_MAX_CONNECTION_AGE_MS);
chand->max_connection_age_grace =
DEFAULT_MAX_CONNECTION_AGE_GRACE_MS == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(DEFAULT_MAX_CONNECTION_AGE_GRACE_MS,
- GPR_TIMESPAN);
- chand->max_connection_idle =
- DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(DEFAULT_MAX_CONNECTION_IDLE_MS, GPR_TIMESPAN);
+ ? GRPC_MILLIS_INF_FUTURE
+ : DEFAULT_MAX_CONNECTION_AGE_GRACE_MS;
+ chand->max_connection_idle = DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
+ ? GRPC_MILLIS_INF_FUTURE
+ : DEFAULT_MAX_CONNECTION_IDLE_MS;
for (size_t i = 0; i < args->channel_args->num_args; ++i) {
if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS);
chand->max_connection_age =
- value == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(
- add_random_max_connection_age_jitter(value), GPR_TIMESPAN);
+ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(
+ value);
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i],
- (grpc_integer_options){DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0,
- INT_MAX});
+ {DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0, INT_MAX});
chand->max_connection_age_grace =
- value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(value, GPR_TIMESPAN);
+ value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_IDLE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_IDLE_INTEGER_OPTIONS);
chand->max_connection_idle =
- value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(value, GPR_TIMESPAN);
+ value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
}
}
GRPC_CLOSURE_INIT(&chand->close_max_idle_channel, close_max_idle_channel,
@@ -349,8 +331,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
channel_connectivity_changed, chand,
grpc_schedule_on_exec_ctx);
- if (gpr_time_cmp(chand->max_connection_age, gpr_inf_future(GPR_TIMESPAN)) !=
- 0) {
+ if (chand->max_connection_age != GRPC_MILLIS_INF_FUTURE) {
/* When the channel reaches its max age, we send down an op with
goaway_error set. However, we can't send down any ops until after the
channel stack is fully initialized. If we start the timer here, we have
@@ -360,26 +341,23 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
initialization is done. */
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
- GRPC_CLOSURE_SCHED(exec_ctx, &chand->start_max_age_timer_after_init,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&chand->start_max_age_timer_after_init, GRPC_ERROR_NONE);
}
/* Initialize the number of calls as 1, so that the max_idle_timer will not
start until start_max_idle_timer_after_init is invoked. */
gpr_atm_rel_store(&chand->call_count, 1);
- if (gpr_time_cmp(chand->max_connection_idle, gpr_inf_future(GPR_TIMESPAN)) !=
- 0) {
+ if (chand->max_connection_idle != GRPC_MILLIS_INF_FUTURE) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
- GRPC_CLOSURE_SCHED(exec_ctx, &chand->start_max_idle_timer_after_init,
+ GRPC_CLOSURE_SCHED(&chand->start_max_idle_timer_after_init,
GRPC_ERROR_NONE);
}
return GRPC_ERROR_NONE;
}
/* Destructor for channel_data. */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
const grpc_channel_filter grpc_max_age_filter = {
grpc_call_next_op,
@@ -394,8 +372,7 @@ const grpc_channel_filter grpc_max_age_filter = {
grpc_channel_next_get_info,
"max_age"};
-static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_max_age_filter(grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
@@ -408,7 +385,7 @@ static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx,
MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX;
if (enable) {
return grpc_channel_stack_builder_prepend_filter(
- builder, &grpc_max_age_filter, NULL, NULL);
+ builder, &grpc_max_age_filter, nullptr, nullptr);
} else {
return true;
}
@@ -417,7 +394,7 @@ static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx,
void grpc_max_age_filter_init(void) {
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_max_age_filter, NULL);
+ maybe_add_max_age_filter, nullptr);
}
void grpc_max_age_filter_shutdown(void) {}
diff --git a/src/core/ext/filters/message_size/message_size_filter.c b/src/core/ext/filters/message_size/message_size_filter.cc
index 47763b1deb..8d76c4a837 100644
--- a/src/core/ext/filters/message_size/message_size_filter.c
+++ b/src/core/ext/filters/message_size/message_size_filter.cc
@@ -26,48 +26,68 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/service_config.h"
-typedef struct message_size_limits {
+typedef struct {
int max_send_size;
int max_recv_size;
} message_size_limits;
-static void message_size_limits_free(grpc_exec_ctx* exec_ctx, void* value) {
- gpr_free(value);
+typedef struct {
+ gpr_refcount refs;
+ message_size_limits limits;
+} refcounted_message_size_limits;
+
+static void* refcounted_message_size_limits_ref(void* value) {
+ refcounted_message_size_limits* limits =
+ (refcounted_message_size_limits*)value;
+ gpr_ref(&limits->refs);
+ return value;
+}
+
+static void refcounted_message_size_limits_unref(void* value) {
+ refcounted_message_size_limits* limits =
+ (refcounted_message_size_limits*)value;
+ if (gpr_unref(&limits->refs)) {
+ gpr_free(value);
+ }
}
-static void* message_size_limits_create_from_json(const grpc_json* json) {
+static void* refcounted_message_size_limits_create_from_json(
+ const grpc_json* json) {
int max_request_message_bytes = -1;
int max_response_message_bytes = -1;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) continue;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) continue;
if (strcmp(field->key, "maxRequestMessageBytes") == 0) {
- if (max_request_message_bytes >= 0) return NULL; // Duplicate.
+ if (max_request_message_bytes >= 0) return nullptr; // Duplicate.
if (field->type != GRPC_JSON_STRING && field->type != GRPC_JSON_NUMBER) {
- return NULL;
+ return nullptr;
}
max_request_message_bytes = gpr_parse_nonnegative_int(field->value);
- if (max_request_message_bytes == -1) return NULL;
+ if (max_request_message_bytes == -1) return nullptr;
} else if (strcmp(field->key, "maxResponseMessageBytes") == 0) {
- if (max_response_message_bytes >= 0) return NULL; // Duplicate.
+ if (max_response_message_bytes >= 0) return nullptr; // Duplicate.
if (field->type != GRPC_JSON_STRING && field->type != GRPC_JSON_NUMBER) {
- return NULL;
+ return nullptr;
}
max_response_message_bytes = gpr_parse_nonnegative_int(field->value);
- if (max_response_message_bytes == -1) return NULL;
+ if (max_response_message_bytes == -1) return nullptr;
}
}
- message_size_limits* value =
- (message_size_limits*)gpr_malloc(sizeof(message_size_limits));
- value->max_send_size = max_request_message_bytes;
- value->max_recv_size = max_response_message_bytes;
+ refcounted_message_size_limits* value =
+ (refcounted_message_size_limits*)gpr_malloc(
+ sizeof(refcounted_message_size_limits));
+ gpr_ref_init(&value->refs, 1);
+ value->limits.max_send_size = max_request_message_bytes;
+ value->limits.max_recv_size = max_response_message_bytes;
return value;
}
-typedef struct call_data {
+namespace {
+struct call_data {
grpc_call_combiner* call_combiner;
message_size_limits limits;
// Receive closures are chained: we inject this closure as the
@@ -78,21 +98,21 @@ typedef struct call_data {
grpc_byte_stream** recv_message;
// Original recv_message_ready callback, invoked after our own.
grpc_closure* next_recv_message_ready;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
message_size_limits limits;
- // Maps path names to message_size_limits structs.
+ // Maps path names to refcounted_message_size_limits structs.
grpc_slice_hash_table* method_limit_table;
-} channel_data;
+};
+} // namespace
// Callback invoked when we receive a message. Here we check the max
// receive message size.
-static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void recv_message_ready(void* user_data, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
- if (*calld->recv_message != NULL && calld->limits.max_recv_size >= 0 &&
+ if (*calld->recv_message != nullptr && calld->limits.max_recv_size >= 0 &&
(*calld->recv_message)->length > (size_t)calld->limits.max_recv_size) {
char* message_string;
gpr_asprintf(&message_string,
@@ -112,13 +132,12 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
GRPC_ERROR_REF(error);
}
// Invoke the next callback.
- GRPC_CLOSURE_RUN(exec_ctx, calld->next_recv_message_ready, error);
+ GRPC_CLOSURE_RUN(calld->next_recv_message_ready, error);
}
// Start transport stream op.
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
// Check max send message size.
if (op->send_message && calld->limits.max_send_size >= 0 &&
@@ -129,7 +148,7 @@ static void start_transport_stream_op_batch(
op->payload->send_message.send_message->length,
calld->limits.max_send_size);
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, op,
+ op,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_RESOURCE_EXHAUSTED),
@@ -145,17 +164,16 @@ static void start_transport_stream_op_batch(
op->payload->recv_message.recv_message_ready = &calld->recv_message_ready;
}
// Chain to the next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
// Constructor for call_data.
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
calld->call_combiner = args->call_combiner;
- calld->next_recv_message_ready = NULL;
+ calld->next_recv_message_ready = nullptr;
GRPC_CLOSURE_INIT(&calld->recv_message_ready, recv_message_ready, elem,
grpc_schedule_on_exec_ctx);
// Get max sizes from channel data, then merge in per-method config values.
@@ -163,20 +181,20 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
// apply the max request size to the send limit and the max response
// size to the receive limit.
calld->limits = chand->limits;
- if (chand->method_limit_table != NULL) {
- message_size_limits* limits =
- (message_size_limits*)grpc_method_config_table_get(
- exec_ctx, chand->method_limit_table, args->path);
- if (limits != NULL) {
- if (limits->max_send_size >= 0 &&
- (limits->max_send_size < calld->limits.max_send_size ||
+ if (chand->method_limit_table != nullptr) {
+ refcounted_message_size_limits* limits =
+ (refcounted_message_size_limits*)grpc_method_config_table_get(
+ chand->method_limit_table, args->path);
+ if (limits != nullptr) {
+ if (limits->limits.max_send_size >= 0 &&
+ (limits->limits.max_send_size < calld->limits.max_send_size ||
calld->limits.max_send_size < 0)) {
- calld->limits.max_send_size = limits->max_send_size;
+ calld->limits.max_send_size = limits->limits.max_send_size;
}
- if (limits->max_recv_size >= 0 &&
- (limits->max_recv_size < calld->limits.max_recv_size ||
+ if (limits->limits.max_recv_size >= 0 &&
+ (limits->limits.max_recv_size < calld->limits.max_recv_size ||
calld->limits.max_recv_size < 0)) {
- calld->limits.max_recv_size = limits->max_recv_size;
+ calld->limits.max_recv_size = limits->limits.max_recv_size;
}
}
}
@@ -184,7 +202,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
// Destructor for call_data.
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
@@ -221,8 +239,7 @@ message_size_limits get_message_size_limits(
}
// Constructor for channel_data.
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
channel_data* chand = (channel_data*)elem->channel_data;
@@ -230,15 +247,16 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
// Get method config table from channel args.
const grpc_arg* channel_arg =
grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG);
- if (channel_arg != NULL) {
+ if (channel_arg != nullptr) {
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
grpc_service_config* service_config =
grpc_service_config_create(channel_arg->value.string);
- if (service_config != NULL) {
+ if (service_config != nullptr) {
chand->method_limit_table =
grpc_service_config_create_method_config_table(
- exec_ctx, service_config, message_size_limits_create_from_json,
- message_size_limits_free);
+ service_config, refcounted_message_size_limits_create_from_json,
+ refcounted_message_size_limits_ref,
+ refcounted_message_size_limits_unref);
grpc_service_config_destroy(service_config);
}
}
@@ -246,10 +264,9 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
// Destructor for channel_data.
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
- grpc_slice_hash_table_unref(exec_ctx, chand->method_limit_table);
+ grpc_slice_hash_table_unref(chand->method_limit_table);
}
const grpc_channel_filter grpc_message_size_filter = {
@@ -265,8 +282,7 @@ const grpc_channel_filter grpc_message_size_filter = {
grpc_channel_next_get_info,
"message_size"};
-static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_message_size_filter(grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
@@ -277,12 +293,12 @@ static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx,
}
const grpc_arg* a =
grpc_channel_args_find(channel_args, GRPC_ARG_SERVICE_CONFIG);
- if (a != NULL) {
+ if (a != nullptr) {
enable = true;
}
if (enable) {
return grpc_channel_stack_builder_prepend_filter(
- builder, &grpc_message_size_filter, NULL, NULL);
+ builder, &grpc_message_size_filter, nullptr, nullptr);
} else {
return true;
}
@@ -291,13 +307,13 @@ static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx,
void grpc_message_size_filter_init(void) {
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_message_size_filter, NULL);
+ maybe_add_message_size_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_message_size_filter, NULL);
+ maybe_add_message_size_filter, nullptr);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- maybe_add_message_size_filter, NULL);
+ maybe_add_message_size_filter, nullptr);
}
void grpc_message_size_filter_shutdown(void) {}
diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
index c8b2fe5f99..88bb8c71cc 100644
--- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c
+++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
@@ -25,7 +25,8 @@
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/metadata.h"
-typedef struct call_data {
+namespace {
+struct call_data {
// Receive closures are chained: we inject this closure as the
// recv_initial_metadata_ready up-call on transport_stream_op, and remember to
// call our next_recv_initial_metadata_ready member after handling it.
@@ -37,12 +38,13 @@ typedef struct call_data {
// Marks whether the workaround is active
bool workaround_active;
-} call_data;
+};
+} // namespace
// Find the user agent metadata element in the batch
static bool get_user_agent_mdelem(const grpc_metadata_batch* batch,
grpc_mdelem* md) {
- if (batch->idx.named.user_agent != NULL) {
+ if (batch->idx.named.user_agent != nullptr) {
*md = batch->idx.named.user_agent->md;
return true;
}
@@ -50,8 +52,7 @@ static bool get_user_agent_mdelem(const grpc_metadata_batch* batch,
}
// Callback invoked when we receive an initial metadata.
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
- void* user_data, grpc_error* error) {
+static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
@@ -67,14 +68,13 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
}
// Invoke the next callback.
- GRPC_CLOSURE_RUN(exec_ctx, calld->next_recv_initial_metadata_ready,
+ GRPC_CLOSURE_RUN(calld->next_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
// Start transport stream op.
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
// Inject callback for receiving initial metadata
@@ -96,15 +96,14 @@ static void start_transport_stream_op_batch(
}
// Chain to the next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
// Constructor for call_data.
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
- calld->next_recv_initial_metadata_ready = NULL;
+ calld->next_recv_initial_metadata_ready = nullptr;
calld->workaround_active = false;
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
recv_initial_metadata_ready, elem,
@@ -113,20 +112,18 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
// Destructor for call_data.
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
// Constructor for channel_data.
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
// Destructor for channel_data.
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
// Parse the user agent
static bool parse_user_agent(grpc_mdelem md) {
@@ -139,10 +136,10 @@ static bool parse_user_agent(grpc_mdelem md) {
bool grpc_objc_specifier_seen = false;
bool cronet_specifier_seen = false;
char *major_version_str = user_agent_str, *minor_version_str;
- long major_version, minor_version;
+ long major_version = 0, minor_version = 0;
char* head = strtok(user_agent_str, " ");
- while (head != NULL) {
+ while (head != nullptr) {
if (!grpc_objc_specifier_seen &&
0 == strncmp(head, grpc_objc_specifier, grpc_objc_specifier_len)) {
major_version_str = head + grpc_objc_specifier_len;
@@ -153,11 +150,11 @@ static bool parse_user_agent(grpc_mdelem md) {
break;
}
- head = strtok(NULL, " ");
+ head = strtok(nullptr, " ");
}
if (grpc_objc_specifier_seen) {
major_version_str = strtok(major_version_str, ".");
- minor_version_str = strtok(NULL, ".");
+ minor_version_str = strtok(nullptr, ".");
major_version = atol(major_version_str);
minor_version = atol(minor_version_str);
}
@@ -181,25 +178,25 @@ const grpc_channel_filter grpc_workaround_cronet_compression_filter = {
"workaround_cronet_compression"};
static bool register_workaround_cronet_compression(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
const grpc_arg* a = grpc_channel_args_find(
channel_args, GRPC_ARG_WORKAROUND_CRONET_COMPRESSION);
- if (a == NULL) {
+ if (a == nullptr) {
return true;
}
if (grpc_channel_arg_get_bool(a, false) == false) {
return true;
}
return grpc_channel_stack_builder_prepend_filter(
- builder, &grpc_workaround_cronet_compression_filter, NULL, NULL);
+ builder, &grpc_workaround_cronet_compression_filter, nullptr, nullptr);
}
void grpc_workaround_cronet_compression_filter_init(void) {
grpc_channel_init_register_stage(
GRPC_SERVER_CHANNEL, GRPC_WORKAROUND_PRIORITY_HIGH,
- register_workaround_cronet_compression, NULL);
+ register_workaround_cronet_compression, nullptr);
grpc_register_workaround(GRPC_WORKAROUND_ID_CRONET_COMPRESSION,
parse_user_agent);
}
diff --git a/src/core/ext/filters/workarounds/workaround_utils.c b/src/core/ext/filters/workarounds/workaround_utils.cc
index e600fbee67..9d76582ea2 100644
--- a/src/core/ext/filters/workarounds/workaround_utils.c
+++ b/src/core/ext/filters/workarounds/workaround_utils.cc
@@ -21,26 +21,26 @@
user_agent_parser ua_parser[GRPC_MAX_WORKAROUND_ID];
-static void destroy_user_agent_md(void *user_agent_md) {
+static void destroy_user_agent_md(void* user_agent_md) {
gpr_free(user_agent_md);
}
-grpc_workaround_user_agent_md *grpc_parse_user_agent(grpc_mdelem md) {
- grpc_workaround_user_agent_md *user_agent_md =
- (grpc_workaround_user_agent_md *)grpc_mdelem_get_user_data(
+grpc_workaround_user_agent_md* grpc_parse_user_agent(grpc_mdelem md) {
+ grpc_workaround_user_agent_md* user_agent_md =
+ (grpc_workaround_user_agent_md*)grpc_mdelem_get_user_data(
md, destroy_user_agent_md);
- if (NULL != user_agent_md) {
+ if (nullptr != user_agent_md) {
return user_agent_md;
}
- user_agent_md = (grpc_workaround_user_agent_md *)gpr_malloc(
+ user_agent_md = (grpc_workaround_user_agent_md*)gpr_malloc(
sizeof(grpc_workaround_user_agent_md));
for (int i = 0; i < GRPC_MAX_WORKAROUND_ID; i++) {
if (ua_parser[i]) {
user_agent_md->workaround_active[i] = ua_parser[i](md);
}
}
- grpc_mdelem_set_user_data(md, destroy_user_agent_md, (void *)user_agent_md);
+ grpc_mdelem_set_user_data(md, destroy_user_agent_md, (void*)user_agent_md);
return user_agent_md;
}
diff --git a/src/core/ext/filters/workarounds/workaround_utils.h b/src/core/ext/filters/workarounds/workaround_utils.h
index 2ad7a876d5..d6ef5e84fa 100644
--- a/src/core/ext/filters/workarounds/workaround_utils.h
+++ b/src/core/ext/filters/workarounds/workaround_utils.h
@@ -28,7 +28,7 @@ typedef struct grpc_workaround_user_agent_md {
bool workaround_active[GRPC_MAX_WORKAROUND_ID];
} grpc_workaround_user_agent_md;
-grpc_workaround_user_agent_md *grpc_parse_user_agent(grpc_mdelem md);
+grpc_workaround_user_agent_md* grpc_parse_user_agent(grpc_mdelem md);
typedef bool (*user_agent_parser)(grpc_mdelem);
diff --git a/src/core/ext/transport/chttp2/alpn/alpn.c b/src/core/ext/transport/chttp2/alpn/alpn.cc
index ca2e801ec8..89892457d6 100644
--- a/src/core/ext/transport/chttp2/alpn/alpn.c
+++ b/src/core/ext/transport/chttp2/alpn/alpn.cc
@@ -21,9 +21,9 @@
#include <grpc/support/useful.h>
/* in order of preference */
-static const char *const supported_versions[] = {"grpc-exp", "h2"};
+static const char* const supported_versions[] = {"grpc-exp", "h2"};
-int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
+int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size) {
size_t i;
for (i = 0; i < GPR_ARRAY_SIZE(supported_versions); i++) {
if (!strncmp(version, supported_versions[i], size)) return 1;
@@ -35,7 +35,7 @@ size_t grpc_chttp2_num_alpn_versions(void) {
return GPR_ARRAY_SIZE(supported_versions);
}
-const char *grpc_chttp2_get_alpn_version_index(size_t i) {
+const char* grpc_chttp2_get_alpn_version_index(size_t i) {
GPR_ASSERT(i < GPR_ARRAY_SIZE(supported_versions));
return supported_versions[i];
}
diff --git a/src/core/ext/transport/chttp2/alpn/alpn.h b/src/core/ext/transport/chttp2/alpn/alpn.h
index 379af4b24c..fd7513c665 100644
--- a/src/core/ext/transport/chttp2/alpn/alpn.h
+++ b/src/core/ext/transport/chttp2/alpn/alpn.h
@@ -22,13 +22,13 @@
#include <string.h>
/* Retuns 1 if the version is supported, 0 otherwise. */
-int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size);
+int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size);
/* Returns the number of protocol versions to advertise */
size_t grpc_chttp2_num_alpn_versions(void);
/* Returns the protocol version at index i (0 <= i <
* grpc_chttp2_num_alpn_versions()) */
-const char *grpc_chttp2_get_alpn_version_index(size_t i);
+const char* grpc_chttp2_get_alpn_version_index(size_t i);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.c b/src/core/ext/transport/chttp2/client/chttp2_connector.c
deleted file mode 100644
index 202bcd47f5..0000000000
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.c
+++ /dev/null
@@ -1,206 +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/transport/chttp2/client/chttp2_connector.h"
-
-#include <grpc/grpc.h>
-
-#include <string.h>
-
-#include <grpc/slice_buffer.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/ext/filters/client_channel/connector.h"
-#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
-#include "src/core/ext/filters/client_channel/subchannel.h"
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/channel/handshaker.h"
-#include "src/core/lib/channel/handshaker_registry.h"
-#include "src/core/lib/iomgr/tcp_client.h"
-#include "src/core/lib/slice/slice_internal.h"
-
-typedef struct {
- grpc_connector base;
-
- gpr_mu mu;
- gpr_refcount refs;
-
- bool shutdown;
- bool connecting;
-
- grpc_closure *notify;
- grpc_connect_in_args args;
- grpc_connect_out_args *result;
-
- grpc_endpoint *endpoint; // Non-NULL until handshaking starts.
-
- grpc_closure connected;
-
- grpc_handshake_manager *handshake_mgr;
-} chttp2_connector;
-
-static void chttp2_connector_ref(grpc_connector *con) {
- chttp2_connector *c = (chttp2_connector *)con;
- gpr_ref(&c->refs);
-}
-
-static void chttp2_connector_unref(grpc_exec_ctx *exec_ctx,
- grpc_connector *con) {
- chttp2_connector *c = (chttp2_connector *)con;
- if (gpr_unref(&c->refs)) {
- gpr_mu_destroy(&c->mu);
- // If handshaking is not yet in progress, destroy the endpoint.
- // Otherwise, the handshaker will do this for us.
- if (c->endpoint != NULL) grpc_endpoint_destroy(exec_ctx, c->endpoint);
- gpr_free(c);
- }
-}
-
-static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_connector *con, grpc_error *why) {
- chttp2_connector *c = (chttp2_connector *)con;
- gpr_mu_lock(&c->mu);
- c->shutdown = true;
- if (c->handshake_mgr != NULL) {
- grpc_handshake_manager_shutdown(exec_ctx, c->handshake_mgr,
- GRPC_ERROR_REF(why));
- }
- // If handshaking is not yet in progress, shutdown the endpoint.
- // Otherwise, the handshaker will do this for us.
- if (!c->connecting && c->endpoint != NULL) {
- grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(why));
- }
- gpr_mu_unlock(&c->mu);
- GRPC_ERROR_UNREF(why);
-}
-
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = (grpc_handshaker_args *)arg;
- chttp2_connector *c = (chttp2_connector *)args->user_data;
- gpr_mu_lock(&c->mu);
- if (error != GRPC_ERROR_NONE || c->shutdown) {
- if (error == GRPC_ERROR_NONE) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown");
- // We were shut down after handshaking completed successfully, so
- // destroy the endpoint here.
- // TODO(ctiller): It is currently necessary to shutdown endpoints
- // before destroying them, even if we know that there are no
- // pending read/write callbacks. This should be fixed, at which
- // point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, args->endpoint, GRPC_ERROR_REF(error));
- grpc_endpoint_destroy(exec_ctx, args->endpoint);
- grpc_channel_args_destroy(exec_ctx, args->args);
- grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
- gpr_free(args->read_buffer);
- } else {
- error = GRPC_ERROR_REF(error);
- }
- memset(c->result, 0, sizeof(*c->result));
- } else {
- c->result->transport =
- grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 1);
- GPR_ASSERT(c->result->transport);
- grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport,
- args->read_buffer);
- c->result->channel_args = args->args;
- }
- grpc_closure *notify = c->notify;
- c->notify = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
- grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
- c->handshake_mgr = NULL;
- gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector *)c);
-}
-
-static void start_handshake_locked(grpc_exec_ctx *exec_ctx,
- chttp2_connector *c) {
- c->handshake_mgr = grpc_handshake_manager_create();
- grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, c->args.channel_args,
- c->handshake_mgr);
- grpc_handshake_manager_do_handshake(
- exec_ctx, c->handshake_mgr, c->endpoint, c->args.channel_args,
- c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
- c->endpoint = NULL; // Endpoint handed off to handshake manager.
-}
-
-static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- chttp2_connector *c = (chttp2_connector *)arg;
- gpr_mu_lock(&c->mu);
- GPR_ASSERT(c->connecting);
- c->connecting = false;
- if (error != GRPC_ERROR_NONE || c->shutdown) {
- if (error == GRPC_ERROR_NONE) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown");
- } else {
- error = GRPC_ERROR_REF(error);
- }
- memset(c->result, 0, sizeof(*c->result));
- grpc_closure *notify = c->notify;
- c->notify = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
- if (c->endpoint != NULL) {
- grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(error));
- }
- gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector *)arg);
- } else {
- GPR_ASSERT(c->endpoint != NULL);
- start_handshake_locked(exec_ctx, c);
- gpr_mu_unlock(&c->mu);
- }
-}
-
-static void chttp2_connector_connect(grpc_exec_ctx *exec_ctx,
- grpc_connector *con,
- const grpc_connect_in_args *args,
- grpc_connect_out_args *result,
- grpc_closure *notify) {
- chttp2_connector *c = (chttp2_connector *)con;
- grpc_resolved_address addr;
- grpc_get_subchannel_address_arg(exec_ctx, args->channel_args, &addr);
- gpr_mu_lock(&c->mu);
- GPR_ASSERT(c->notify == NULL);
- c->notify = notify;
- c->args = *args;
- c->result = result;
- GPR_ASSERT(c->endpoint == NULL);
- chttp2_connector_ref(con); // Ref taken for callback.
- GRPC_CLOSURE_INIT(&c->connected, connected, c, grpc_schedule_on_exec_ctx);
- GPR_ASSERT(!c->connecting);
- c->connecting = true;
- grpc_tcp_client_connect(exec_ctx, &c->connected, &c->endpoint,
- args->interested_parties, args->channel_args, &addr,
- args->deadline);
- gpr_mu_unlock(&c->mu);
-}
-
-static const grpc_connector_vtable chttp2_connector_vtable = {
- chttp2_connector_ref, chttp2_connector_unref, chttp2_connector_shutdown,
- chttp2_connector_connect};
-
-grpc_connector *grpc_chttp2_connector_create() {
- chttp2_connector *c = (chttp2_connector *)gpr_zalloc(sizeof(*c));
- c->base.vtable = &chttp2_connector_vtable;
- gpr_mu_init(&c->mu);
- gpr_ref_init(&c->refs, 1);
- return &c->base;
-}
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
new file mode 100644
index 0000000000..db5962e7fd
--- /dev/null
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
@@ -0,0 +1,227 @@
+/*
+ *
+ * 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/transport/chttp2/client/chttp2_connector.h"
+
+#include <grpc/grpc.h>
+
+#include <string.h>
+
+#include <grpc/slice_buffer.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/ext/filters/client_channel/connector.h"
+#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
+#include "src/core/ext/filters/client_channel/subchannel.h"
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/channel/handshaker.h"
+#include "src/core/lib/channel/handshaker_registry.h"
+#include "src/core/lib/iomgr/tcp_client.h"
+#include "src/core/lib/slice/slice_internal.h"
+
+typedef struct {
+ grpc_connector base;
+
+ gpr_mu mu;
+ gpr_refcount refs;
+
+ bool shutdown;
+ bool connecting;
+
+ grpc_closure* notify;
+ grpc_connect_in_args args;
+ grpc_connect_out_args* result;
+
+ grpc_endpoint* endpoint; // Non-NULL until handshaking starts.
+
+ grpc_closure connected;
+
+ grpc_handshake_manager* handshake_mgr;
+} chttp2_connector;
+
+static void chttp2_connector_ref(grpc_connector* con) {
+ chttp2_connector* c = (chttp2_connector*)con;
+ gpr_ref(&c->refs);
+}
+
+static void chttp2_connector_unref(grpc_connector* con) {
+ chttp2_connector* c = (chttp2_connector*)con;
+ if (gpr_unref(&c->refs)) {
+ gpr_mu_destroy(&c->mu);
+ // If handshaking is not yet in progress, destroy the endpoint.
+ // Otherwise, the handshaker will do this for us.
+ if (c->endpoint != nullptr) grpc_endpoint_destroy(c->endpoint);
+ gpr_free(c);
+ }
+}
+
+static void chttp2_connector_shutdown(grpc_connector* con, grpc_error* why) {
+ chttp2_connector* c = (chttp2_connector*)con;
+ gpr_mu_lock(&c->mu);
+ c->shutdown = true;
+ if (c->handshake_mgr != nullptr) {
+ grpc_handshake_manager_shutdown(c->handshake_mgr, GRPC_ERROR_REF(why));
+ }
+ // If handshaking is not yet in progress, shutdown the endpoint.
+ // Otherwise, the handshaker will do this for us.
+ if (!c->connecting && c->endpoint != nullptr) {
+ grpc_endpoint_shutdown(c->endpoint, GRPC_ERROR_REF(why));
+ }
+ gpr_mu_unlock(&c->mu);
+ GRPC_ERROR_UNREF(why);
+}
+
+static void on_handshake_done(void* arg, grpc_error* error) {
+ grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
+ chttp2_connector* c = (chttp2_connector*)args->user_data;
+ gpr_mu_lock(&c->mu);
+ if (error != GRPC_ERROR_NONE || c->shutdown) {
+ if (error == GRPC_ERROR_NONE) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown");
+ // We were shut down after handshaking completed successfully, so
+ // destroy the endpoint here.
+ // TODO(ctiller): It is currently necessary to shutdown endpoints
+ // before destroying them, even if we know that there are no
+ // pending read/write callbacks. This should be fixed, at which
+ // point this can be removed.
+ grpc_endpoint_shutdown(args->endpoint, GRPC_ERROR_REF(error));
+ grpc_endpoint_destroy(args->endpoint);
+ grpc_channel_args_destroy(args->args);
+ grpc_slice_buffer_destroy_internal(args->read_buffer);
+ gpr_free(args->read_buffer);
+ } else {
+ error = GRPC_ERROR_REF(error);
+ }
+ memset(c->result, 0, sizeof(*c->result));
+ } else {
+ grpc_endpoint_delete_from_pollset_set(args->endpoint,
+ c->args.interested_parties);
+ c->result->transport =
+ grpc_create_chttp2_transport(args->args, args->endpoint, true);
+ GPR_ASSERT(c->result->transport);
+ // TODO(roth): We ideally want to wait until we receive HTTP/2
+ // settings from the server before we consider the connection
+ // established. If that doesn't happen before the connection
+ // timeout expires, then we should consider the connection attempt a
+ // failure and feed that information back into the backoff code.
+ // We could pass a notify_on_receive_settings callback to
+ // grpc_chttp2_transport_start_reading() to let us know when
+ // settings are received, but we would need to figure out how to use
+ // that information here.
+ //
+ // Unfortunately, we don't currently have a way to split apart the two
+ // effects of scheduling c->notify: we start sending RPCs immediately
+ // (which we want to do) and we consider the connection attempt successful
+ // (which we don't want to do until we get the notify_on_receive_settings
+ // callback from the transport). If we could split those things
+ // apart, then we could start sending RPCs but then wait for our
+ // timeout before deciding if the connection attempt is successful.
+ // If the attempt is not successful, then we would tear down the
+ // transport and feed the failure back into the backoff code.
+ //
+ // In addition, even if we did that, we would probably not want to do
+ // so until after transparent retries is implemented. Otherwise, any
+ // RPC that we attempt to send on the connection before the timeout
+ // would fail instead of being retried on a subsequent attempt.
+ grpc_chttp2_transport_start_reading(c->result->transport, args->read_buffer,
+ nullptr);
+ c->result->channel_args = args->args;
+ }
+ grpc_closure* notify = c->notify;
+ c->notify = nullptr;
+ GRPC_CLOSURE_SCHED(notify, error);
+ grpc_handshake_manager_destroy(c->handshake_mgr);
+ c->handshake_mgr = nullptr;
+ gpr_mu_unlock(&c->mu);
+ chttp2_connector_unref((grpc_connector*)c);
+}
+
+static void start_handshake_locked(chttp2_connector* c) {
+ c->handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshakers_add(HANDSHAKER_CLIENT, c->args.channel_args,
+ c->handshake_mgr);
+ grpc_endpoint_add_to_pollset_set(c->endpoint, c->args.interested_parties);
+ grpc_handshake_manager_do_handshake(
+ c->handshake_mgr, c->args.interested_parties, c->endpoint,
+ c->args.channel_args, c->args.deadline, nullptr /* acceptor */,
+ on_handshake_done, c);
+ c->endpoint = nullptr; // Endpoint handed off to handshake manager.
+}
+
+static void connected(void* arg, grpc_error* error) {
+ chttp2_connector* c = (chttp2_connector*)arg;
+ gpr_mu_lock(&c->mu);
+ GPR_ASSERT(c->connecting);
+ c->connecting = false;
+ if (error != GRPC_ERROR_NONE || c->shutdown) {
+ if (error == GRPC_ERROR_NONE) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown");
+ } else {
+ error = GRPC_ERROR_REF(error);
+ }
+ memset(c->result, 0, sizeof(*c->result));
+ grpc_closure* notify = c->notify;
+ c->notify = nullptr;
+ GRPC_CLOSURE_SCHED(notify, error);
+ if (c->endpoint != nullptr) {
+ grpc_endpoint_shutdown(c->endpoint, GRPC_ERROR_REF(error));
+ }
+ gpr_mu_unlock(&c->mu);
+ chttp2_connector_unref((grpc_connector*)arg);
+ } else {
+ GPR_ASSERT(c->endpoint != nullptr);
+ start_handshake_locked(c);
+ gpr_mu_unlock(&c->mu);
+ }
+}
+
+static void chttp2_connector_connect(grpc_connector* con,
+ const grpc_connect_in_args* args,
+ grpc_connect_out_args* result,
+ grpc_closure* notify) {
+ chttp2_connector* c = (chttp2_connector*)con;
+ grpc_resolved_address addr;
+ grpc_get_subchannel_address_arg(args->channel_args, &addr);
+ gpr_mu_lock(&c->mu);
+ GPR_ASSERT(c->notify == nullptr);
+ c->notify = notify;
+ c->args = *args;
+ c->result = result;
+ GPR_ASSERT(c->endpoint == nullptr);
+ chttp2_connector_ref(con); // Ref taken for callback.
+ GRPC_CLOSURE_INIT(&c->connected, connected, c, grpc_schedule_on_exec_ctx);
+ GPR_ASSERT(!c->connecting);
+ c->connecting = true;
+ grpc_tcp_client_connect(&c->connected, &c->endpoint, args->interested_parties,
+ args->channel_args, &addr, args->deadline);
+ gpr_mu_unlock(&c->mu);
+}
+
+static const grpc_connector_vtable chttp2_connector_vtable = {
+ chttp2_connector_ref, chttp2_connector_unref, chttp2_connector_shutdown,
+ chttp2_connector_connect};
+
+grpc_connector* grpc_chttp2_connector_create() {
+ chttp2_connector* c = (chttp2_connector*)gpr_zalloc(sizeof(*c));
+ c->base.vtable = &chttp2_connector_vtable;
+ gpr_mu_init(&c->mu);
+ gpr_ref_init(&c->refs, 1);
+ return &c->base;
+}
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index 6410a6043d..6a1b70964d 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -31,39 +31,37 @@
#include "src/core/lib/surface/channel.h"
static void client_channel_factory_ref(
- grpc_client_channel_factory *cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
static void client_channel_factory_unref(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
-static grpc_subchannel *client_channel_factory_create_subchannel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const grpc_subchannel_args *args) {
- grpc_connector *connector = grpc_chttp2_connector_create();
- grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args);
- grpc_connector_unref(exec_ctx, connector);
+static grpc_subchannel* client_channel_factory_create_subchannel(
+ grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
+ grpc_connector* connector = grpc_chttp2_connector_create();
+ grpc_subchannel* s = grpc_subchannel_create(connector, args);
+ grpc_connector_unref(connector);
return s;
}
-static grpc_channel *client_channel_factory_create_channel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const char *target, grpc_client_channel_type type,
- const grpc_channel_args *args) {
- if (target == NULL) {
+static grpc_channel* client_channel_factory_create_channel(
+ grpc_client_channel_factory* cc_factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args) {
+ if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
- return NULL;
+ 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(exec_ctx, target));
- const char *to_remove[] = {GRPC_ARG_SERVER_URI};
- grpc_channel_args *new_args =
+ (char*)GRPC_ARG_SERVER_URI,
+ grpc_resolver_factory_add_default_prefix_if_needed(target));
+ 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(exec_ctx, target, new_args,
- GRPC_CLIENT_CHANNEL, NULL);
- grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_channel* channel =
+ grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr);
+ grpc_channel_args_destroy(new_args);
return channel;
}
@@ -79,26 +77,27 @@ static grpc_client_channel_factory client_channel_factory = {
Asynchronously: - resolve target
- connect to it (trying alternatives as presented)
- perform handshakes */
-grpc_channel *grpc_insecure_channel_create(const char *target,
- const grpc_channel_args *args,
- void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+grpc_channel* grpc_insecure_channel_create(const char* target,
+ const grpc_channel_args* args,
+ void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_insecure_channel_create(target=%s, args=%p, reserved=%p)", 3,
(target, args, reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
// Add channel arg containing the client channel factory.
grpc_arg arg =
grpc_client_channel_factory_create_channel_arg(&client_channel_factory);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
// Create channel.
- grpc_channel *channel = client_channel_factory_create_channel(
- &exec_ctx, &client_channel_factory, target,
- GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
+ grpc_channel* channel = client_channel_factory_create_channel(
+ &client_channel_factory, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR,
+ new_args);
// Clean up.
- grpc_channel_args_destroy(&exec_ctx, new_args);
- grpc_exec_ctx_finish(&exec_ctx);
- return channel != NULL ? channel : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create client channel");
+ grpc_channel_args_destroy(new_args);
+
+ return channel != nullptr ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create client channel");
}
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
index dd88136f7b..0cdea5a94e 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
@@ -35,44 +35,45 @@
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/transport.h"
-grpc_channel *grpc_insecure_channel_create_from_fd(
- const char *target, int fd, const grpc_channel_args *args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+grpc_channel* grpc_insecure_channel_create_from_fd(
+ const char* target, int fd, const grpc_channel_args* args) {
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3,
(target, fd, args));
grpc_arg default_authority_arg = grpc_channel_arg_string_create(
- (char *)GRPC_ARG_DEFAULT_AUTHORITY, (char *)"test.authority");
- grpc_channel_args *final_args =
+ (char*)GRPC_ARG_DEFAULT_AUTHORITY, (char*)"test.authority");
+ grpc_channel_args* final_args =
grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
int flags = fcntl(fd, F_GETFL, 0);
GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0);
- grpc_endpoint *client = grpc_tcp_client_create_from_fd(
- &exec_ctx, grpc_fd_create(fd, "client"), args, "fd-client");
+ grpc_endpoint* client = grpc_tcp_client_create_from_fd(
+ grpc_fd_create(fd, "client"), args, "fd-client");
- grpc_transport *transport =
- grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1);
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(final_args, client, true);
GPR_ASSERT(transport);
- grpc_channel *channel = grpc_channel_create(
- &exec_ctx, target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
- grpc_channel_args_destroy(&exec_ctx, final_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_channel* channel = grpc_channel_create(
+ target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_channel_args_destroy(final_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- return channel != NULL ? channel : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create client channel");
+ return channel != nullptr ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create client channel");
}
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
-grpc_channel *grpc_insecure_channel_create_from_fd(
- const char *target, int fd, const grpc_channel_args *args) {
+grpc_channel* grpc_insecure_channel_create_from_fd(
+ const char* target, int fd, const grpc_channel_args* args) {
GPR_ASSERT(0);
- return NULL;
+ return nullptr;
}
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index d4580f15f5..27c5b96a4c 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -38,59 +38,60 @@
#include "src/core/lib/surface/channel.h"
static void client_channel_factory_ref(
- grpc_client_channel_factory *cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
static void client_channel_factory_unref(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
-static grpc_subchannel_args *get_secure_naming_subchannel_args(
- grpc_exec_ctx *exec_ctx, const grpc_subchannel_args *args) {
- grpc_channel_credentials *channel_credentials =
+static grpc_subchannel_args* get_secure_naming_subchannel_args(
+ const grpc_subchannel_args* args) {
+ grpc_channel_credentials* channel_credentials =
grpc_channel_credentials_find_in_args(args->args);
- if (channel_credentials == NULL) {
+ if (channel_credentials == nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: channel credentials missing for secure "
"channel.");
- return NULL;
+ return nullptr;
}
// Make sure security connector does not already exist in args.
- if (grpc_security_connector_find_in_args(args->args) != NULL) {
+ if (grpc_security_connector_find_in_args(args->args) != nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: security connector already present in "
"channel args.");
- return NULL;
+ return nullptr;
}
// To which address are we connecting? By default, use the server URI.
- const grpc_arg *server_uri_arg =
+ const grpc_arg* server_uri_arg =
grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
- GPR_ASSERT(server_uri_arg != NULL);
+ GPR_ASSERT(server_uri_arg != nullptr);
GPR_ASSERT(server_uri_arg->type == GRPC_ARG_STRING);
- const char *server_uri_str = server_uri_arg->value.string;
- GPR_ASSERT(server_uri_str != NULL);
- grpc_uri *server_uri =
- grpc_uri_parse(exec_ctx, server_uri_str, true /* supress errors */);
- GPR_ASSERT(server_uri != NULL);
- const char *server_uri_path;
+ const char* server_uri_str = server_uri_arg->value.string;
+ GPR_ASSERT(server_uri_str != nullptr);
+ grpc_uri* server_uri =
+ grpc_uri_parse(server_uri_str, true /* supress errors */);
+ GPR_ASSERT(server_uri != nullptr);
+ const char* server_uri_path;
server_uri_path =
server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path;
- const grpc_slice_hash_table *targets_info =
+ const grpc_slice_hash_table* targets_info =
grpc_lb_targets_info_find_in_args(args->args);
- char *target_name_to_check = NULL;
- if (targets_info != NULL) { // LB channel
+ char* target_name_to_check = nullptr;
+ if (targets_info != nullptr) { // LB channel
// Find the balancer name for the target.
- const char *target_uri_str =
+ const char* target_uri_str =
grpc_get_subchannel_address_uri_arg(args->args);
- grpc_uri *target_uri =
- grpc_uri_parse(exec_ctx, target_uri_str, false /* suppress errors */);
- GPR_ASSERT(target_uri != NULL);
+ grpc_uri* target_uri =
+ grpc_uri_parse(target_uri_str, false /* suppress errors */);
+ GPR_ASSERT(target_uri != nullptr);
if (target_uri->path[0] != '\0') { // "path" may be empty
const grpc_slice key = grpc_slice_from_static_string(
target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
- const char *value = grpc_slice_hash_table_get(targets_info, key);
- if (value != NULL) target_name_to_check = gpr_strdup(value);
- grpc_slice_unref_internal(exec_ctx, key);
+ const char* value =
+ (const char*)grpc_slice_hash_table_get(targets_info, key);
+ if (value != nullptr) target_name_to_check = gpr_strdup(value);
+ grpc_slice_unref_internal(key);
}
- if (target_name_to_check == NULL) {
+ if (target_name_to_check == nullptr) {
// If the target name to check hasn't already been set, fall back to using
// SERVER_URI
target_name_to_check = gpr_strdup(server_uri_path);
@@ -100,79 +101,76 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
target_name_to_check = gpr_strdup(server_uri_path);
}
grpc_uri_destroy(server_uri);
- GPR_ASSERT(target_name_to_check != NULL);
- grpc_channel_security_connector *subchannel_security_connector = NULL;
+ GPR_ASSERT(target_name_to_check != nullptr);
+ grpc_channel_security_connector* subchannel_security_connector = nullptr;
// Create the security connector using the credentials and target name.
- grpc_channel_args *new_args_from_connector = NULL;
+ grpc_channel_args* new_args_from_connector = nullptr;
const grpc_security_status security_status =
grpc_channel_credentials_create_security_connector(
- exec_ctx, channel_credentials, target_name_to_check, args->args,
+ channel_credentials, target_name_to_check, args->args,
&subchannel_security_connector, &new_args_from_connector);
if (security_status != GRPC_SECURITY_OK) {
gpr_log(GPR_ERROR,
"Failed to create secure subchannel for secure name '%s'",
target_name_to_check);
gpr_free(target_name_to_check);
- return NULL;
+ return nullptr;
}
gpr_free(target_name_to_check);
grpc_arg new_security_connector_arg =
grpc_security_connector_to_arg(&subchannel_security_connector->base);
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
- new_args_from_connector != NULL ? new_args_from_connector : args->args,
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
+ new_args_from_connector != nullptr ? new_args_from_connector : args->args,
&new_security_connector_arg, 1);
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base,
+ GRPC_SECURITY_CONNECTOR_UNREF(&subchannel_security_connector->base,
"lb_channel_create");
- if (new_args_from_connector != NULL) {
- grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
+ if (new_args_from_connector != nullptr) {
+ grpc_channel_args_destroy(new_args_from_connector);
}
- grpc_subchannel_args *final_sc_args = gpr_malloc(sizeof(*final_sc_args));
+ grpc_subchannel_args* final_sc_args =
+ (grpc_subchannel_args*)gpr_malloc(sizeof(*final_sc_args));
memcpy(final_sc_args, args, sizeof(*args));
final_sc_args->args = new_args;
return final_sc_args;
}
-static grpc_subchannel *client_channel_factory_create_subchannel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const grpc_subchannel_args *args) {
- grpc_subchannel_args *subchannel_args =
- get_secure_naming_subchannel_args(exec_ctx, args);
- if (subchannel_args == NULL) {
+static grpc_subchannel* client_channel_factory_create_subchannel(
+ grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
+ grpc_subchannel_args* subchannel_args =
+ get_secure_naming_subchannel_args(args);
+ if (subchannel_args == nullptr) {
gpr_log(
GPR_ERROR,
"Failed to create subchannel arguments during subchannel creation.");
- return NULL;
+ return nullptr;
}
- grpc_connector *connector = grpc_chttp2_connector_create();
- grpc_subchannel *s =
- grpc_subchannel_create(exec_ctx, connector, subchannel_args);
- grpc_connector_unref(exec_ctx, connector);
- grpc_channel_args_destroy(exec_ctx,
- (grpc_channel_args *)subchannel_args->args);
+ grpc_connector* connector = grpc_chttp2_connector_create();
+ grpc_subchannel* s = grpc_subchannel_create(connector, subchannel_args);
+ grpc_connector_unref(connector);
+ grpc_channel_args_destroy((grpc_channel_args*)subchannel_args->args);
gpr_free(subchannel_args);
return s;
}
-static grpc_channel *client_channel_factory_create_channel(
- grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
- const char *target, grpc_client_channel_type type,
- const grpc_channel_args *args) {
- if (target == NULL) {
+static grpc_channel* client_channel_factory_create_channel(
+ grpc_client_channel_factory* cc_factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args) {
+ if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
- return NULL;
+ return nullptr;
}
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
- GRPC_ARG_SERVER_URI,
- grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target));
- const char *to_remove[] = {GRPC_ARG_SERVER_URI};
- grpc_channel_args *new_args =
+ (char*)GRPC_ARG_SERVER_URI,
+ grpc_resolver_factory_add_default_prefix_if_needed(target));
+ 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(exec_ctx, target, new_args,
- GRPC_CLIENT_CHANNEL, NULL);
- grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_channel* channel =
+ grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr);
+ grpc_channel_args_destroy(new_args);
return channel;
}
@@ -188,35 +186,34 @@ static grpc_client_channel_factory client_channel_factory = {
// Asynchronously: - resolve target
// - connect to it (trying alternatives as presented)
// - perform handshakes
-grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
- const char *target,
- const grpc_channel_args *args,
- void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
+ const char* target,
+ const grpc_channel_args* args,
+ void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
"reserved=%p)",
- 4, ((void *)creds, target, (void *)args, (void *)reserved));
- GPR_ASSERT(reserved == NULL);
- grpc_channel *channel = NULL;
- if (creds != NULL) {
+ 4, ((void*)creds, target, (void*)args, (void*)reserved));
+ GPR_ASSERT(reserved == nullptr);
+ grpc_channel* channel = nullptr;
+ if (creds != nullptr) {
// Add channel args containing the client channel factory and channel
// credentials.
grpc_arg args_to_add[] = {
grpc_client_channel_factory_create_channel_arg(&client_channel_factory),
grpc_channel_credentials_to_arg(creds)};
- grpc_channel_args *new_args = grpc_channel_args_copy_and_add(
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
// Create channel.
channel = client_channel_factory_create_channel(
- &exec_ctx, &client_channel_factory, target,
- GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
+ &client_channel_factory, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR,
+ new_args);
// Clean up.
- grpc_channel_args_destroy(&exec_ctx, new_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(new_args);
}
- return channel != NULL ? channel
- : grpc_lame_client_channel_create(
- target, GRPC_STATUS_INTERNAL,
- "Failed to create secure client channel");
+ return channel != nullptr ? channel
+ : grpc_lame_client_channel_create(
+ target, GRPC_STATUS_INTERNAL,
+ "Failed to create secure client channel");
}
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.c b/src/core/ext/transport/chttp2/server/chttp2_server.c
deleted file mode 100644
index 60244e163b..0000000000
--- a/src/core/ext/transport/chttp2/server/chttp2_server.c
+++ /dev/null
@@ -1,292 +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/transport/chttp2/server/chttp2_server.h"
-
-#include <grpc/grpc.h>
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/useful.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/handshaker.h"
-#include "src/core/lib/channel/handshaker_registry.h"
-#include "src/core/lib/iomgr/endpoint.h"
-#include "src/core/lib/iomgr/resolve_address.h"
-#include "src/core/lib/iomgr/tcp_server.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/surface/api_trace.h"
-#include "src/core/lib/surface/server.h"
-
-typedef struct {
- grpc_server *server;
- grpc_tcp_server *tcp_server;
- grpc_channel_args *args;
- gpr_mu mu;
- bool shutdown;
- grpc_closure tcp_server_shutdown_complete;
- grpc_closure *server_destroy_listener_done;
- grpc_handshake_manager *pending_handshake_mgrs;
-} server_state;
-
-typedef struct {
- server_state *svr_state;
- grpc_pollset *accepting_pollset;
- grpc_tcp_server_acceptor *acceptor;
- grpc_handshake_manager *handshake_mgr;
-} server_connection_state;
-
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = (grpc_handshaker_args *)arg;
- server_connection_state *connection_state =
- (server_connection_state *)args->user_data;
- gpr_mu_lock(&connection_state->svr_state->mu);
- if (error != GRPC_ERROR_NONE || connection_state->svr_state->shutdown) {
- const char *error_str = grpc_error_string(error);
- gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str);
-
- if (error == GRPC_ERROR_NONE && args->endpoint != NULL) {
- // We were shut down after handshaking completed successfully, so
- // destroy the endpoint here.
- // TODO(ctiller): It is currently necessary to shutdown endpoints
- // before destroying them, even if we know that there are no
- // pending read/write callbacks. This should be fixed, at which
- // point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, args->endpoint, GRPC_ERROR_NONE);
- grpc_endpoint_destroy(exec_ctx, args->endpoint);
- grpc_channel_args_destroy(exec_ctx, args->args);
- grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
- gpr_free(args->read_buffer);
- }
- } else {
- // If the handshaking succeeded but there is no endpoint, then the
- // handshaker may have handed off the connection to some external
- // code, so we can just clean up here without creating a transport.
- if (args->endpoint != NULL) {
- grpc_transport *transport =
- grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 0);
- grpc_server_setup_transport(
- exec_ctx, connection_state->svr_state->server, transport,
- connection_state->accepting_pollset, args->args);
- grpc_chttp2_transport_start_reading(exec_ctx, transport,
- args->read_buffer);
- grpc_channel_args_destroy(exec_ctx, args->args);
- }
- }
- grpc_handshake_manager_pending_list_remove(
- &connection_state->svr_state->pending_handshake_mgrs,
- connection_state->handshake_mgr);
- gpr_mu_unlock(&connection_state->svr_state->mu);
- grpc_handshake_manager_destroy(exec_ctx, connection_state->handshake_mgr);
- grpc_tcp_server_unref(exec_ctx, connection_state->svr_state->tcp_server);
- gpr_free(connection_state->acceptor);
- gpr_free(connection_state);
-}
-
-static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
- server_state *state = (server_state *)arg;
- gpr_mu_lock(&state->mu);
- if (state->shutdown) {
- gpr_mu_unlock(&state->mu);
- grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_NONE);
- grpc_endpoint_destroy(exec_ctx, tcp);
- gpr_free(acceptor);
- return;
- }
- grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
- grpc_handshake_manager_pending_list_add(&state->pending_handshake_mgrs,
- handshake_mgr);
- gpr_mu_unlock(&state->mu);
- grpc_tcp_server_ref(state->tcp_server);
- server_connection_state *connection_state =
- (server_connection_state *)gpr_malloc(sizeof(*connection_state));
- connection_state->svr_state = state;
- connection_state->accepting_pollset = accepting_pollset;
- connection_state->acceptor = acceptor;
- connection_state->handshake_mgr = handshake_mgr;
- grpc_handshakers_add(exec_ctx, HANDSHAKER_SERVER, state->args,
- connection_state->handshake_mgr);
- // TODO(roth): We should really get this timeout value from channel
- // args instead of hard-coding it.
- const gpr_timespec deadline = gpr_time_add(
- gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(120, GPR_TIMESPAN));
- grpc_handshake_manager_do_handshake(exec_ctx, connection_state->handshake_mgr,
- tcp, state->args, deadline, acceptor,
- on_handshake_done, connection_state);
-}
-
-/* Server callback: start listening on our ports */
-static void server_start_listener(grpc_exec_ctx *exec_ctx, grpc_server *server,
- void *arg, grpc_pollset **pollsets,
- size_t pollset_count) {
- server_state *state = (server_state *)arg;
- gpr_mu_lock(&state->mu);
- state->shutdown = false;
- gpr_mu_unlock(&state->mu);
- grpc_tcp_server_start(exec_ctx, state->tcp_server, pollsets, pollset_count,
- on_accept, state);
-}
-
-static void tcp_server_shutdown_complete(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- server_state *state = (server_state *)arg;
- /* ensure all threads have unlocked */
- gpr_mu_lock(&state->mu);
- grpc_closure *destroy_done = state->server_destroy_listener_done;
- GPR_ASSERT(state->shutdown);
- grpc_handshake_manager_pending_list_shutdown_all(
- exec_ctx, state->pending_handshake_mgrs, GRPC_ERROR_REF(error));
- gpr_mu_unlock(&state->mu);
- // Flush queued work before destroying handshaker factory, since that
- // may do a synchronous unref.
- grpc_exec_ctx_flush(exec_ctx);
- if (destroy_done != NULL) {
- destroy_done->cb(exec_ctx, destroy_done->cb_arg, GRPC_ERROR_REF(error));
- grpc_exec_ctx_flush(exec_ctx);
- }
- grpc_channel_args_destroy(exec_ctx, state->args);
- gpr_mu_destroy(&state->mu);
- gpr_free(state);
-}
-
-/* Server callback: destroy the tcp listener (so we don't generate further
- callbacks) */
-static void server_destroy_listener(grpc_exec_ctx *exec_ctx,
- grpc_server *server, void *arg,
- grpc_closure *destroy_done) {
- server_state *state = (server_state *)arg;
- gpr_mu_lock(&state->mu);
- state->shutdown = true;
- state->server_destroy_listener_done = destroy_done;
- grpc_tcp_server *tcp_server = state->tcp_server;
- gpr_mu_unlock(&state->mu);
- grpc_tcp_server_shutdown_listeners(exec_ctx, tcp_server);
- grpc_tcp_server_unref(exec_ctx, tcp_server);
-}
-
-grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
- grpc_server *server, const char *addr,
- grpc_channel_args *args,
- int *port_num) {
- grpc_resolved_addresses *resolved = NULL;
- grpc_tcp_server *tcp_server = NULL;
- size_t i;
- size_t count = 0;
- int port_temp;
- grpc_error *err = GRPC_ERROR_NONE;
- server_state *state = NULL;
- grpc_error **errors = NULL;
- size_t naddrs = 0;
-
- *port_num = -1;
-
- /* resolve address */
- err = grpc_blocking_resolve_address(addr, "https", &resolved);
- if (err != GRPC_ERROR_NONE) {
- goto error;
- }
- state = (server_state *)gpr_zalloc(sizeof(*state));
- GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete,
- tcp_server_shutdown_complete, state,
- grpc_schedule_on_exec_ctx);
- err = grpc_tcp_server_create(exec_ctx, &state->tcp_server_shutdown_complete,
- args, &tcp_server);
- if (err != GRPC_ERROR_NONE) {
- goto error;
- }
-
- state->server = server;
- state->tcp_server = tcp_server;
- state->args = args;
- state->shutdown = true;
- gpr_mu_init(&state->mu);
-
- naddrs = resolved->naddrs;
- errors = (grpc_error **)gpr_malloc(sizeof(*errors) * naddrs);
- for (i = 0; i < naddrs; i++) {
- errors[i] =
- grpc_tcp_server_add_port(tcp_server, &resolved->addrs[i], &port_temp);
- if (errors[i] == GRPC_ERROR_NONE) {
- if (*port_num == -1) {
- *port_num = port_temp;
- } else {
- GPR_ASSERT(*port_num == port_temp);
- }
- count++;
- }
- }
- if (count == 0) {
- char *msg;
- gpr_asprintf(&msg, "No address added out of total %" PRIuPTR " resolved",
- naddrs);
- err = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(msg, errors, naddrs);
- gpr_free(msg);
- goto error;
- } else if (count != naddrs) {
- char *msg;
- gpr_asprintf(&msg, "Only %" PRIuPTR
- " addresses added out of total %" PRIuPTR " resolved",
- count, naddrs);
- err = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(msg, errors, naddrs);
- gpr_free(msg);
-
- const char *warning_message = grpc_error_string(err);
- gpr_log(GPR_INFO, "WARNING: %s", warning_message);
-
- /* we managed to bind some addresses: continue */
- }
- grpc_resolved_addresses_destroy(resolved);
-
- /* Register with the server only upon success */
- grpc_server_add_listener(exec_ctx, server, state, server_start_listener,
- server_destroy_listener);
- goto done;
-
-/* Error path: cleanup and return */
-error:
- GPR_ASSERT(err != GRPC_ERROR_NONE);
- if (resolved) {
- grpc_resolved_addresses_destroy(resolved);
- }
- if (tcp_server) {
- grpc_tcp_server_unref(exec_ctx, tcp_server);
- } else {
- grpc_channel_args_destroy(exec_ctx, args);
- gpr_free(state);
- }
- *port_num = 0;
-
-done:
- if (errors != NULL) {
- for (i = 0; i < naddrs; i++) {
- GRPC_ERROR_UNREF(errors[i]);
- }
- gpr_free(errors);
- }
- return err;
-}
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
new file mode 100644
index 0000000000..5669fa4090
--- /dev/null
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -0,0 +1,348 @@
+/*
+ *
+ * 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/transport/chttp2/server/chttp2_server.h"
+
+#include <grpc/grpc.h>
+
+#include <inttypes.h>
+#include <limits.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/useful.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/ext/transport/chttp2/transport/internal.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/channel/handshaker.h"
+#include "src/core/lib/channel/handshaker_registry.h"
+#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/tcp_server.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/surface/api_trace.h"
+#include "src/core/lib/surface/server.h"
+
+typedef struct {
+ grpc_server* server;
+ grpc_tcp_server* tcp_server;
+ grpc_channel_args* args;
+ gpr_mu mu;
+ bool shutdown;
+ grpc_closure tcp_server_shutdown_complete;
+ grpc_closure* server_destroy_listener_done;
+ grpc_handshake_manager* pending_handshake_mgrs;
+} server_state;
+
+typedef struct {
+ gpr_refcount refs;
+ server_state* svr_state;
+ grpc_pollset* accepting_pollset;
+ grpc_tcp_server_acceptor* acceptor;
+ grpc_handshake_manager* handshake_mgr;
+ // State for enforcing handshake timeout on receiving HTTP/2 settings.
+ grpc_chttp2_transport* transport;
+ grpc_millis deadline;
+ grpc_timer timer;
+ grpc_closure on_timeout;
+ grpc_closure on_receive_settings;
+} server_connection_state;
+
+static void server_connection_state_unref(
+ server_connection_state* connection_state) {
+ if (gpr_unref(&connection_state->refs)) {
+ if (connection_state->transport != nullptr) {
+ GRPC_CHTTP2_UNREF_TRANSPORT(connection_state->transport,
+ "receive settings timeout");
+ }
+ gpr_free(connection_state);
+ }
+}
+
+static void on_timeout(void* arg, grpc_error* error) {
+ server_connection_state* connection_state = (server_connection_state*)arg;
+ // Note that we may be called with GRPC_ERROR_NONE when the timer fires
+ // or with an error indicating that the timer system is being shut down.
+ if (error != GRPC_ERROR_CANCELLED) {
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ op->disconnect_with_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Did not receive HTTP/2 settings before handshake timeout");
+ grpc_transport_perform_op(&connection_state->transport->base, op);
+ }
+ server_connection_state_unref(connection_state);
+}
+
+static void on_receive_settings(void* arg, grpc_error* error) {
+ server_connection_state* connection_state = (server_connection_state*)arg;
+ if (error == GRPC_ERROR_NONE) {
+ grpc_timer_cancel(&connection_state->timer);
+ }
+ server_connection_state_unref(connection_state);
+}
+
+static void on_handshake_done(void* arg, grpc_error* error) {
+ grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
+ server_connection_state* connection_state =
+ (server_connection_state*)args->user_data;
+ gpr_mu_lock(&connection_state->svr_state->mu);
+ if (error != GRPC_ERROR_NONE || connection_state->svr_state->shutdown) {
+ const char* error_str = grpc_error_string(error);
+ gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str);
+ if (error == GRPC_ERROR_NONE && args->endpoint != nullptr) {
+ // We were shut down after handshaking completed successfully, so
+ // destroy the endpoint here.
+ // TODO(ctiller): It is currently necessary to shutdown endpoints
+ // before destroying them, even if we know that there are no
+ // pending read/write callbacks. This should be fixed, at which
+ // point this can be removed.
+ grpc_endpoint_shutdown(args->endpoint, GRPC_ERROR_NONE);
+ grpc_endpoint_destroy(args->endpoint);
+ grpc_channel_args_destroy(args->args);
+ grpc_slice_buffer_destroy_internal(args->read_buffer);
+ gpr_free(args->read_buffer);
+ }
+ } else {
+ // If the handshaking succeeded but there is no endpoint, then the
+ // handshaker may have handed off the connection to some external
+ // code, so we can just clean up here without creating a transport.
+ if (args->endpoint != nullptr) {
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(args->args, args->endpoint, false);
+ grpc_server_setup_transport(
+ connection_state->svr_state->server, transport,
+ connection_state->accepting_pollset, args->args);
+ // Use notify_on_receive_settings callback to enforce the
+ // handshake deadline.
+ connection_state->transport = (grpc_chttp2_transport*)transport;
+ gpr_ref(&connection_state->refs);
+ GRPC_CLOSURE_INIT(&connection_state->on_receive_settings,
+ on_receive_settings, connection_state,
+ grpc_schedule_on_exec_ctx);
+ grpc_chttp2_transport_start_reading(
+ transport, args->read_buffer, &connection_state->on_receive_settings);
+ grpc_channel_args_destroy(args->args);
+ gpr_ref(&connection_state->refs);
+ GRPC_CHTTP2_REF_TRANSPORT((grpc_chttp2_transport*)transport,
+ "receive settings timeout");
+ GRPC_CLOSURE_INIT(&connection_state->on_timeout, on_timeout,
+ connection_state, grpc_schedule_on_exec_ctx);
+ grpc_timer_init(&connection_state->timer, connection_state->deadline,
+ &connection_state->on_timeout);
+ }
+ }
+ grpc_handshake_manager_pending_list_remove(
+ &connection_state->svr_state->pending_handshake_mgrs,
+ connection_state->handshake_mgr);
+ gpr_mu_unlock(&connection_state->svr_state->mu);
+ grpc_handshake_manager_destroy(connection_state->handshake_mgr);
+ gpr_free(connection_state->acceptor);
+ grpc_tcp_server_unref(connection_state->svr_state->tcp_server);
+ server_connection_state_unref(connection_state);
+}
+
+static void on_accept(void* arg, grpc_endpoint* tcp,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor) {
+ server_state* state = (server_state*)arg;
+ gpr_mu_lock(&state->mu);
+ if (state->shutdown) {
+ gpr_mu_unlock(&state->mu);
+ grpc_endpoint_shutdown(tcp, GRPC_ERROR_NONE);
+ grpc_endpoint_destroy(tcp);
+ gpr_free(acceptor);
+ return;
+ }
+ grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshake_manager_pending_list_add(&state->pending_handshake_mgrs,
+ handshake_mgr);
+ gpr_mu_unlock(&state->mu);
+ grpc_tcp_server_ref(state->tcp_server);
+ server_connection_state* connection_state =
+ (server_connection_state*)gpr_zalloc(sizeof(*connection_state));
+ gpr_ref_init(&connection_state->refs, 1);
+ connection_state->svr_state = state;
+ connection_state->accepting_pollset = accepting_pollset;
+ connection_state->acceptor = acceptor;
+ connection_state->handshake_mgr = handshake_mgr;
+ grpc_handshakers_add(HANDSHAKER_SERVER, state->args,
+ connection_state->handshake_mgr);
+ const grpc_arg* timeout_arg =
+ grpc_channel_args_find(state->args, GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS);
+ connection_state->deadline =
+ grpc_core::ExecCtx::Get()->Now() +
+ grpc_channel_arg_get_integer(timeout_arg,
+ {120 * GPR_MS_PER_SEC, 1, INT_MAX});
+ grpc_handshake_manager_do_handshake(
+ connection_state->handshake_mgr, nullptr /* interested_parties */, tcp,
+ state->args, connection_state->deadline, acceptor, on_handshake_done,
+ connection_state);
+}
+
+/* Server callback: start listening on our ports */
+static void server_start_listener(grpc_server* server, void* arg,
+ grpc_pollset** pollsets,
+ size_t pollset_count) {
+ server_state* state = (server_state*)arg;
+ gpr_mu_lock(&state->mu);
+ state->shutdown = false;
+ gpr_mu_unlock(&state->mu);
+ grpc_tcp_server_start(state->tcp_server, pollsets, pollset_count, on_accept,
+ state);
+}
+
+static void tcp_server_shutdown_complete(void* arg, grpc_error* error) {
+ server_state* state = (server_state*)arg;
+ /* ensure all threads have unlocked */
+ gpr_mu_lock(&state->mu);
+ grpc_closure* destroy_done = state->server_destroy_listener_done;
+ GPR_ASSERT(state->shutdown);
+ grpc_handshake_manager_pending_list_shutdown_all(
+ state->pending_handshake_mgrs, GRPC_ERROR_REF(error));
+ gpr_mu_unlock(&state->mu);
+ // Flush queued work before destroying handshaker factory, since that
+ // may do a synchronous unref.
+ grpc_core::ExecCtx::Get()->Flush();
+ if (destroy_done != nullptr) {
+ destroy_done->cb(destroy_done->cb_arg, GRPC_ERROR_REF(error));
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+ grpc_channel_args_destroy(state->args);
+ gpr_mu_destroy(&state->mu);
+ gpr_free(state);
+}
+
+/* Server callback: destroy the tcp listener (so we don't generate further
+ callbacks) */
+static void server_destroy_listener(grpc_server* server, void* arg,
+ grpc_closure* destroy_done) {
+ server_state* state = (server_state*)arg;
+ gpr_mu_lock(&state->mu);
+ state->shutdown = true;
+ state->server_destroy_listener_done = destroy_done;
+ grpc_tcp_server* tcp_server = state->tcp_server;
+ gpr_mu_unlock(&state->mu);
+ grpc_tcp_server_shutdown_listeners(tcp_server);
+ grpc_tcp_server_unref(tcp_server);
+}
+
+grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
+ grpc_channel_args* args,
+ int* port_num) {
+ grpc_resolved_addresses* resolved = nullptr;
+ grpc_tcp_server* tcp_server = nullptr;
+ size_t i;
+ size_t count = 0;
+ int port_temp;
+ grpc_error* err = GRPC_ERROR_NONE;
+ server_state* state = nullptr;
+ grpc_error** errors = nullptr;
+ size_t naddrs = 0;
+
+ *port_num = -1;
+
+ /* resolve address */
+ err = grpc_blocking_resolve_address(addr, "https", &resolved);
+ if (err != GRPC_ERROR_NONE) {
+ goto error;
+ }
+ state = (server_state*)gpr_zalloc(sizeof(*state));
+ GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete,
+ tcp_server_shutdown_complete, state,
+ grpc_schedule_on_exec_ctx);
+ err = grpc_tcp_server_create(&state->tcp_server_shutdown_complete, args,
+ &tcp_server);
+ if (err != GRPC_ERROR_NONE) {
+ goto error;
+ }
+
+ state->server = server;
+ state->tcp_server = tcp_server;
+ state->args = args;
+ state->shutdown = true;
+ gpr_mu_init(&state->mu);
+
+ naddrs = resolved->naddrs;
+ errors = (grpc_error**)gpr_malloc(sizeof(*errors) * naddrs);
+ for (i = 0; i < naddrs; i++) {
+ errors[i] =
+ grpc_tcp_server_add_port(tcp_server, &resolved->addrs[i], &port_temp);
+ if (errors[i] == GRPC_ERROR_NONE) {
+ if (*port_num == -1) {
+ *port_num = port_temp;
+ } else {
+ GPR_ASSERT(*port_num == port_temp);
+ }
+ count++;
+ }
+ }
+ if (count == 0) {
+ char* msg;
+ gpr_asprintf(&msg, "No address added out of total %" PRIuPTR " resolved",
+ naddrs);
+ err = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(msg, errors, naddrs);
+ gpr_free(msg);
+ goto error;
+ } else if (count != naddrs) {
+ char* msg;
+ gpr_asprintf(&msg,
+ "Only %" PRIuPTR " addresses added out of total %" PRIuPTR
+ " resolved",
+ count, naddrs);
+ err = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(msg, errors, naddrs);
+ gpr_free(msg);
+
+ const char* warning_message = grpc_error_string(err);
+ gpr_log(GPR_INFO, "WARNING: %s", warning_message);
+
+ /* we managed to bind some addresses: continue */
+ }
+ grpc_resolved_addresses_destroy(resolved);
+
+ /* Register with the server only upon success */
+ grpc_server_add_listener(server, state, server_start_listener,
+ server_destroy_listener);
+ goto done;
+
+/* Error path: cleanup and return */
+error:
+ GPR_ASSERT(err != GRPC_ERROR_NONE);
+ if (resolved) {
+ grpc_resolved_addresses_destroy(resolved);
+ }
+ if (tcp_server) {
+ grpc_tcp_server_unref(tcp_server);
+ } else {
+ grpc_channel_args_destroy(args);
+ gpr_free(state);
+ }
+ *port_num = 0;
+
+done:
+ if (errors != nullptr) {
+ for (i = 0; i < naddrs; i++) {
+ GRPC_ERROR_UNREF(errors[i]);
+ }
+ gpr_free(errors);
+ }
+ return err;
+}
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h
index ed968496f9..7de859da42 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.h
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.h
@@ -25,8 +25,7 @@
/// Adds a port to \a server. Sets \a port_num to the port number.
/// Takes ownership of \a args.
-grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx,
- grpc_server *server, const char *addr,
- grpc_channel_args *args, int *port_num);
+grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
+ grpc_channel_args* args, int* port_num);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
index d42b2d123e..52c42d056c 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
@@ -25,20 +25,20 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/server.h"
-int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
+ grpc_core::ExecCtx exec_ctx;
int port_num = 0;
GRPC_API_TRACE("grpc_server_add_insecure_http2_port(server=%p, addr=%s)", 2,
(server, addr));
- grpc_error *err = grpc_chttp2_server_add_port(
- &exec_ctx, server, addr,
+ grpc_error* err = grpc_chttp2_server_add_port(
+ server, addr,
grpc_channel_args_copy(grpc_server_get_channel_args(server)), &port_num);
if (err != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(err);
+ const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
GRPC_ERROR_UNREF(err);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return port_num;
}
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
index e647067f73..dafd4af6ce 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
@@ -34,41 +34,39 @@
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
-void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
- void *reserved, int fd) {
- GPR_ASSERT(reserved == NULL);
+void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
+ void* reserved, int fd) {
+ GPR_ASSERT(reserved == nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- char *name;
+ grpc_core::ExecCtx exec_ctx;
+ char* name;
gpr_asprintf(&name, "fd:%d", fd);
- grpc_endpoint *server_endpoint =
- grpc_tcp_create(&exec_ctx, grpc_fd_create(fd, name),
- grpc_server_get_channel_args(server), name);
+ grpc_endpoint* server_endpoint = grpc_tcp_create(
+ grpc_fd_create(fd, name), grpc_server_get_channel_args(server), name);
gpr_free(name);
- const grpc_channel_args *server_args = grpc_server_get_channel_args(server);
- grpc_transport *transport = grpc_create_chttp2_transport(
- &exec_ctx, server_args, server_endpoint, 0 /* is_client */);
+ const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
+ grpc_transport* transport = grpc_create_chttp2_transport(
+ server_args, server_endpoint, false /* is_client */);
- grpc_pollset **pollsets;
+ grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server, &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, server_endpoint, pollsets[i]);
+ grpc_endpoint_add_to_pollset(server_endpoint, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server, transport, NULL, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_server_setup_transport(server, transport, nullptr, server_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
-void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
- void *reserved, int fd) {
+void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
+ void* reserved, int fd) {
GPR_ASSERT(0);
}
diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
index 5ad63aaf1f..723af97ff0 100644
--- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
+++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
@@ -34,26 +34,27 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/server.h"
-int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
- grpc_server_credentials *creds) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_error *err = GRPC_ERROR_NONE;
- grpc_server_security_connector *sc = NULL;
+int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
+ grpc_server_credentials* creds) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_error* err = GRPC_ERROR_NONE;
+ grpc_server_security_connector* sc = nullptr;
int port_num = 0;
+ grpc_security_status status;
+ grpc_channel_args* args = nullptr;
GRPC_API_TRACE(
"grpc_server_add_secure_http2_port("
"server=%p, addr=%s, creds=%p)",
3, (server, addr, creds));
// Create security context.
- if (creds == NULL) {
+ if (creds == nullptr) {
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"No credentials specified for secure server port (creds==NULL)");
goto done;
}
- grpc_security_status status =
- grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
+ status = grpc_server_credentials_create_security_connector(creds, &sc);
if (status != GRPC_SECURITY_OK) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg,
"Unable to create secure server with credentials of type %s.",
creds->type);
@@ -66,18 +67,18 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
grpc_arg args_to_add[2];
args_to_add[0] = grpc_server_credentials_to_arg(creds);
args_to_add[1] = grpc_security_connector_to_arg(&sc->base);
- grpc_channel_args *args =
+ args =
grpc_channel_args_copy_and_add(grpc_server_get_channel_args(server),
args_to_add, GPR_ARRAY_SIZE(args_to_add));
// Add server port.
- err = grpc_chttp2_server_add_port(&exec_ctx, server, addr, args, &port_num);
+ err = grpc_chttp2_server_add_port(server, addr, args, &port_num);
done:
- if (sc != NULL) {
- GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "server");
+ if (sc != nullptr) {
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (err != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(err);
+ const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
GRPC_ERROR_UNREF(err);
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.c b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
index 5a99cbeffc..74778ac046 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.c
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
@@ -19,9 +19,9 @@
#include "src/core/ext/transport/chttp2/transport/bin_decoder.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
static uint8_t decode_table[] = {
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
@@ -49,7 +49,7 @@ static uint8_t decode_table[] = {
static const uint8_t tail_xtra[4] = {0, 0, 1, 2};
-static bool input_is_valid(uint8_t *input_ptr, size_t length) {
+static bool input_is_valid(uint8_t* input_ptr, size_t length) {
size_t i;
for (i = 0; i < length; ++i) {
@@ -75,7 +75,7 @@ static bool input_is_valid(uint8_t *input_ptr, size_t length) {
#define COMPOSE_OUTPUT_BYTE_2(input_ptr) \
(uint8_t)((decode_table[input_ptr[2]] << 6) | decode_table[input_ptr[3]])
-bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) {
+bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
size_t input_tail;
if (ctx->input_cur > ctx->input_end || ctx->output_cur > ctx->output_end) {
@@ -130,8 +130,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) {
return true;
}
-grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
- grpc_slice input) {
+grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t output_length = input_length / 4 * 3;
struct grpc_base64_decode_context ctx;
@@ -147,7 +146,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
}
if (input_length > 0) {
- uint8_t *input_end = GRPC_SLICE_END_PTR(input);
+ uint8_t* input_end = GRPC_SLICE_END_PTR(input);
if (*(--input_end) == '=') {
output_length--;
if (*(--input_end) == '=') {
@@ -164,10 +163,10 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
ctx.contains_tail = false;
if (!grpc_base64_decode_partial(&ctx)) {
- char *s = grpc_slice_to_c_string(input);
+ char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output));
@@ -175,8 +174,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
return output;
}
-grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
- grpc_slice input,
+grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
size_t output_length) {
size_t input_length = GRPC_SLICE_LENGTH(input);
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
@@ -189,7 +187,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
"grpc_chttp2_base64_decode_with_length has a length of %d, which "
"has a tail of 1 byte.\n",
(int)input_length);
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
@@ -199,7 +197,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
"than the max possible output length %d.\n",
(int)output_length,
(int)(input_length / 4 * 3 + tail_xtra[input_length % 4]));
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
@@ -210,10 +208,10 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
ctx.contains_tail = true;
if (!grpc_base64_decode_partial(&ctx)) {
- char *s = grpc_slice_to_c_string(input);
+ char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output));
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h
index 047b33d587..9cb75ccd81 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h
@@ -24,10 +24,10 @@
struct grpc_base64_decode_context {
/* input/output: */
- uint8_t *input_cur;
- uint8_t *input_end;
- uint8_t *output_cur;
- uint8_t *output_end;
+ uint8_t* input_cur;
+ uint8_t* input_end;
+ uint8_t* output_cur;
+ uint8_t* output_end;
/* Indicate if the decoder should handle the tail of input data*/
bool contains_tail;
};
@@ -36,17 +36,16 @@ struct grpc_base64_decode_context {
or output_end is reached. When input_end is reached, (input_end - input_cur)
is less than 4. When output_end is reached, (output_end - output_cur) is less
than 3. Returns false if decoding is failed. */
-bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx);
+bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx);
/* base64 decode a slice with pad chars. Returns a new slice, does not take
ownership of the input. Returns an empty slice if decoding is failed. */
-grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx, grpc_slice input);
+grpc_slice grpc_chttp2_base64_decode(grpc_slice input);
/* base64 decode a slice without pad chars, data length is needed. Returns a new
slice, does not take ownership of the input. Returns an empty slice if
decoding is failed. */
-grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
- grpc_slice input,
+grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
size_t output_length);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.cc
index 42d481b3c0..09f984d7b2 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.c
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.cc
@@ -52,8 +52,8 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
- uint8_t *in = GRPC_SLICE_START_PTR(input);
- char *out = (char *)GRPC_SLICE_START_PTR(output);
+ uint8_t* in = GRPC_SLICE_START_PTR(input);
+ char* out = (char*)GRPC_SLICE_START_PTR(output);
size_t i;
/* encode full triplets */
@@ -85,15 +85,15 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
break;
}
- GPR_ASSERT(out == (char *)GRPC_SLICE_END_PTR(output));
+ GPR_ASSERT(out == (char*)GRPC_SLICE_END_PTR(output));
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input));
return output;
}
grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
size_t nbits;
- uint8_t *in;
- uint8_t *out;
+ uint8_t* in;
+ uint8_t* out;
grpc_slice output;
uint32_t temp = 0;
uint32_t temp_length = 0;
@@ -136,17 +136,17 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
typedef struct {
uint32_t temp;
uint32_t temp_length;
- uint8_t *out;
+ uint8_t* out;
} huff_out;
-static void enc_flush_some(huff_out *out) {
+static void enc_flush_some(huff_out* out) {
while (out->temp_length > 8) {
out->temp_length -= 8;
*out->out++ = (uint8_t)(out->temp >> out->temp_length);
}
}
-static void enc_add2(huff_out *out, uint8_t a, uint8_t b) {
+static void enc_add2(huff_out* out, uint8_t a, uint8_t b) {
b64_huff_sym sa = huff_alphabet[a];
b64_huff_sym sb = huff_alphabet[b];
out->temp = (out->temp << (sa.length + sb.length)) |
@@ -155,7 +155,7 @@ static void enc_add2(huff_out *out, uint8_t a, uint8_t b) {
enc_flush_some(out);
}
-static void enc_add1(huff_out *out, uint8_t a) {
+static void enc_add1(huff_out* out, uint8_t a) {
b64_huff_sym sa = huff_alphabet[a];
out->temp = (out->temp << sa.length) | sa.bits;
out->temp_length += sa.length;
@@ -170,8 +170,8 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
grpc_slice output = GRPC_SLICE_MALLOC(max_output_length);
- uint8_t *in = GRPC_SLICE_START_PTR(input);
- uint8_t *start_out = GRPC_SLICE_START_PTR(output);
+ uint8_t* in = GRPC_SLICE_START_PTR(input);
+ uint8_t* start_out = GRPC_SLICE_START_PTR(output);
huff_out out;
size_t i;
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h
index a8f36a345a..93ad0dfdea 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h
@@ -32,7 +32,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input);
/* equivalent to:
grpc_slice x = grpc_chttp2_base64_encode(input);
grpc_slice y = grpc_chttp2_huffman_compress(x);
- grpc_slice_unref_internal(exec_ctx, x);
+ grpc_slice_unref_internal( x);
return y; */
grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input);
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.c b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
index 6d09953830..a69908116a 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
@@ -18,15 +18,16 @@
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/transport/metadata.h"
void grpc_chttp2_plugin_init(void) {
- grpc_register_tracer(&grpc_http_trace);
- grpc_register_tracer(&grpc_flowctl_trace);
- grpc_register_tracer(&grpc_trace_http2_stream_state);
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_chttp2_refcount);
-#endif
+ g_flow_control_enabled = true;
+ char* env_variable = gpr_getenv("GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL");
+ if (env_variable != nullptr) {
+ g_flow_control_enabled = false;
+ gpr_free(env_variable);
+ }
}
void grpc_chttp2_plugin_shutdown(void) {}
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index acf49632ff..530ab17bc7 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -18,6 +18,9 @@
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include <grpc/support/port_platform.h>
+
+#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
@@ -35,14 +38,14 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/http2_errors.h"
#include "src/core/lib/transport/static_metadata.h"
@@ -51,7 +54,6 @@
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/transport/transport_impl.h"
-#define DEFAULT_WINDOW 65535
#define DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024)
#define MAX_WINDOW 0x7fffffffu
#define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024)
@@ -77,7 +79,9 @@ static int g_default_server_keepalive_time_ms =
DEFAULT_SERVER_KEEPALIVE_TIME_MS;
static int g_default_server_keepalive_timeout_ms =
DEFAULT_SERVER_KEEPALIVE_TIMEOUT_MS;
-static bool g_default_keepalive_permit_without_calls =
+static bool g_default_client_keepalive_permit_without_calls =
+ DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS;
+static bool g_default_server_keepalive_permit_without_calls =
DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS;
static int g_default_min_sent_ping_interval_without_data_ms =
@@ -88,156 +92,133 @@ static int g_default_max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA;
static int g_default_max_ping_strikes = DEFAULT_MAX_PING_STRIKES;
#define MAX_CLIENT_STREAM_ID 0x7fffffffu
-grpc_tracer_flag grpc_http_trace = GRPC_TRACER_INITIALIZER(false, "http");
-grpc_tracer_flag grpc_flowctl_trace = GRPC_TRACER_INITIALIZER(false, "flowctl");
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_chttp2_refcount =
- GRPC_TRACER_INITIALIZER(false, "chttp2_refcount");
-#endif
+grpc_core::TraceFlag grpc_http_trace(false, "http");
+grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false,
+ "chttp2_refcount");
/* forward declarations of various callbacks that we'll build closures around */
-static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
-static void write_action(grpc_exec_ctx *exec_ctx, void *t, grpc_error *error);
-static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
+static void write_action_begin_locked(void* t, grpc_error* error);
+static void write_action(void* t, grpc_error* error);
+static void write_action_end_locked(void* t, grpc_error* error);
-static void read_action_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
+static void read_action_locked(void* t, grpc_error* error);
-static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
- grpc_error *error);
+static void complete_fetch_locked(void* gs, grpc_error* error);
/** Set a transport level setting, and push it to our peer */
-static void queue_setting_update(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void queue_setting_update(grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value);
-static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error);
+static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* error);
/** Start new streams that have been created if we can */
-static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+static void maybe_start_some_streams(grpc_chttp2_transport* t);
-static void connectivity_state_set(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void connectivity_state_set(grpc_chttp2_transport* t,
grpc_connectivity_state state,
- grpc_error *error, const char *reason);
+ grpc_error* error, const char* reason);
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
- void *byte_stream,
- grpc_error *error_ignored);
+static void incoming_byte_stream_destroy_locked(void* byte_stream,
+ grpc_error* error_ignored);
static void incoming_byte_stream_publish_error(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error);
-static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_incoming_byte_stream *bs);
-
-static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
-static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *t,
- grpc_error *error);
-
-static void post_benign_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-
-static void close_transport_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_error *error);
-static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error);
-
-static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error);
-static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error);
-
-static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error);
-static void send_ping_locked(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_ping_type ping_type, grpc_closure *on_initiate,
- grpc_closure *on_complete,
- grpc_chttp2_initiate_write_reason initiate_write_reason);
-static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error);
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error);
+static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs);
+
+static void benign_reclaimer_locked(void* t, grpc_error* error);
+static void destructive_reclaimer_locked(void* t, grpc_error* error);
+
+static void post_benign_reclaimer(grpc_chttp2_transport* t);
+static void post_destructive_reclaimer(grpc_chttp2_transport* t);
+
+static void close_transport_locked(grpc_chttp2_transport* t, grpc_error* error);
+static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error);
+
+static void schedule_bdp_ping_locked(grpc_chttp2_transport* t);
+static void start_bdp_ping_locked(void* tp, grpc_error* error);
+static void finish_bdp_ping_locked(void* tp, grpc_error* error);
+static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error);
+
+static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error);
+static void send_ping_locked(grpc_chttp2_transport* t,
+ grpc_closure* on_initiate,
+ grpc_closure* on_complete);
+static void retry_initiate_ping_locked(void* tp, grpc_error* error);
/** keepalive-relevant functions */
-static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-
-static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
+static void init_keepalive_ping_locked(void* arg, grpc_error* error);
+static void start_keepalive_ping_locked(void* arg, grpc_error* error);
+static void finish_keepalive_ping_locked(void* arg, grpc_error* error);
+static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error);
+
+static void reset_byte_stream(void* arg, grpc_error* error);
+
+// Flow control default enabled. Can be disabled by setting
+// GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL
+bool g_flow_control_enabled = true;
/*******************************************************************************
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
*/
-static void destruct_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void destruct_transport(grpc_chttp2_transport* t) {
size_t i;
- grpc_endpoint_destroy(exec_ctx, t->ep);
+ grpc_endpoint_destroy(t->ep);
- grpc_slice_buffer_destroy_internal(exec_ctx, &t->qbuf);
+ grpc_slice_buffer_destroy_internal(&t->qbuf);
- grpc_slice_buffer_destroy_internal(exec_ctx, &t->outbuf);
- grpc_chttp2_hpack_compressor_destroy(exec_ctx, &t->hpack_compressor);
+ grpc_slice_buffer_destroy_internal(&t->outbuf);
+ grpc_chttp2_hpack_compressor_destroy(&t->hpack_compressor);
- grpc_slice_buffer_destroy_internal(exec_ctx, &t->read_buffer);
- grpc_chttp2_hpack_parser_destroy(exec_ctx, &t->hpack_parser);
+ grpc_slice_buffer_destroy_internal(&t->read_buffer);
+ grpc_chttp2_hpack_parser_destroy(&t->hpack_parser);
grpc_chttp2_goaway_parser_destroy(&t->goaway_parser);
for (i = 0; i < STREAM_LIST_COUNT; i++) {
- GPR_ASSERT(t->lists[i].head == NULL);
- GPR_ASSERT(t->lists[i].tail == NULL);
+ GPR_ASSERT(t->lists[i].head == nullptr);
+ GPR_ASSERT(t->lists[i].tail == nullptr);
}
+ GRPC_ERROR_UNREF(t->goaway_error);
+
GPR_ASSERT(grpc_chttp2_stream_map_size(&t->stream_map) == 0);
grpc_chttp2_stream_map_destroy(&t->stream_map);
- grpc_connectivity_state_destroy(exec_ctx, &t->channel_callback.state_tracker);
+ grpc_connectivity_state_destroy(&t->channel_callback.state_tracker);
- GRPC_COMBINER_UNREF(exec_ctx, t->combiner, "chttp2_transport");
+ GRPC_COMBINER_UNREF(t->combiner, "chttp2_transport");
- cancel_pings(exec_ctx, t,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"));
+ cancel_pings(t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"));
while (t->write_cb_pool) {
- grpc_chttp2_write_cb *next = t->write_cb_pool->next;
+ grpc_chttp2_write_cb* next = t->write_cb_pool->next;
gpr_free(t->write_cb_pool);
t->write_cb_pool = next;
}
+ t->flow_control.Destroy();
+
+ GRPC_ERROR_UNREF(t->closed_with_error);
gpr_free(t->ping_acks);
gpr_free(t->peer_string);
gpr_free(t);
}
#ifndef NDEBUG
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) {
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_chttp2_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
gpr_log(GPR_DEBUG, "chttp2:unref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
t, val, val - 1, reason, file, line);
}
if (!gpr_unref(&t->refs)) return;
- destruct_transport(exec_ctx, t);
+ destruct_transport(t);
}
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) {
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_chttp2_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
gpr_log(GPR_DEBUG, "chttp2: ref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
t, val, val + 1, reason, file, line);
@@ -245,20 +226,19 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
gpr_ref(&t->refs);
}
#else
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) {
if (!gpr_unref(&t->refs)) return;
- destruct_transport(exec_ctx, t);
+ destruct_transport(t);
}
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t) { gpr_ref(&t->refs); }
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); }
#endif
-static const grpc_transport_vtable *get_vtable(void);
+static const grpc_transport_vtable* get_vtable(void);
-static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- const grpc_channel_args *channel_args,
- grpc_endpoint *ep, bool is_client) {
+static void init_transport(grpc_chttp2_transport* t,
+ const grpc_channel_args* channel_args,
+ grpc_endpoint* ep, bool is_client) {
size_t i;
int j;
@@ -274,9 +254,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->endpoint_reading = 1;
t->next_stream_id = is_client ? 1 : 2;
t->is_client = is_client;
- t->flow_control.remote_window = DEFAULT_WINDOW;
- t->flow_control.announced_window = DEFAULT_WINDOW;
- t->flow_control.t = t;
t->deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0;
t->is_first_frame = true;
grpc_connectivity_state_init(
@@ -301,6 +278,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, finish_bdp_ping_locked, t,
grpc_combiner_scheduler(t->combiner));
+ GRPC_CLOSURE_INIT(&t->next_bdp_ping_timer_expired_locked,
+ next_bdp_ping_timer_expired_locked, t,
+ grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping_locked,
t, grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
@@ -313,20 +293,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
keepalive_watchdog_fired_locked, t,
grpc_combiner_scheduler(t->combiner));
- grpc_bdp_estimator_init(&t->flow_control.bdp_estimator, t->peer_string);
- t->flow_control.last_pid_update = gpr_now(GPR_CLOCK_MONOTONIC);
- grpc_pid_controller_init(
- &t->flow_control.pid_controller,
- (grpc_pid_controller_args){.gain_p = 4,
- .gain_i = 8,
- .gain_d = 0,
- .initial_control_value = log2(DEFAULT_WINDOW),
- .min_control_value = -1,
- .max_control_value = 25,
- .integral_range = 10});
-
+ t->goaway_error = GRPC_ERROR_NONE;
grpc_chttp2_goaway_parser_init(&t->goaway_parser);
- grpc_chttp2_hpack_parser_init(exec_ctx, &t->hpack_parser);
+ grpc_chttp2_hpack_parser_init(&t->hpack_parser);
grpc_slice_buffer_init(&t->read_buffer);
@@ -348,8 +317,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
window -- this should by rights be 0 */
t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
t->sent_local_settings = 0;
- t->write_buffer_size = DEFAULT_WINDOW;
- t->flow_control.enable_bdp_probe = true;
+ t->write_buffer_size = grpc_core::chttp2::kDefaultWindow;
if (is_client) {
grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string(
@@ -358,52 +326,46 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
/* configure http2 the way we like it */
if (is_client) {
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_ENABLE_PUSH, 0);
- queue_setting_update(exec_ctx, t,
- GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0);
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_ENABLE_PUSH, 0);
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0);
}
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
- DEFAULT_WINDOW);
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
DEFAULT_MAX_HEADER_LIST_SIZE);
- queue_setting_update(exec_ctx, t,
- GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA, 1);
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA,
+ 1);
t->ping_policy.max_pings_without_data = g_default_max_pings_without_data;
- t->ping_policy.min_sent_ping_interval_without_data = gpr_time_from_millis(
- g_default_min_sent_ping_interval_without_data_ms, GPR_TIMESPAN);
+ t->ping_policy.min_sent_ping_interval_without_data =
+ g_default_min_sent_ping_interval_without_data_ms;
t->ping_policy.max_ping_strikes = g_default_max_ping_strikes;
- t->ping_policy.min_recv_ping_interval_without_data = gpr_time_from_millis(
- g_default_min_recv_ping_interval_without_data_ms, GPR_TIMESPAN);
+ t->ping_policy.min_recv_ping_interval_without_data =
+ g_default_min_recv_ping_interval_without_data_ms;
/* Keepalive setting */
if (t->is_client) {
- t->keepalive_time =
- g_default_client_keepalive_time_ms == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(g_default_client_keepalive_time_ms,
- GPR_TIMESPAN);
- t->keepalive_timeout =
- g_default_client_keepalive_timeout_ms == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(g_default_client_keepalive_timeout_ms,
- GPR_TIMESPAN);
+ t->keepalive_time = g_default_client_keepalive_time_ms == INT_MAX
+ ? GRPC_MILLIS_INF_FUTURE
+ : g_default_client_keepalive_time_ms;
+ t->keepalive_timeout = g_default_client_keepalive_timeout_ms == INT_MAX
+ ? GRPC_MILLIS_INF_FUTURE
+ : g_default_client_keepalive_timeout_ms;
+ t->keepalive_permit_without_calls =
+ g_default_client_keepalive_permit_without_calls;
} else {
- t->keepalive_time =
- g_default_server_keepalive_time_ms == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(g_default_server_keepalive_time_ms,
- GPR_TIMESPAN);
- t->keepalive_timeout =
- g_default_server_keepalive_timeout_ms == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(g_default_server_keepalive_timeout_ms,
- GPR_TIMESPAN);
- }
- t->keepalive_permit_without_calls = g_default_keepalive_permit_without_calls;
+ t->keepalive_time = g_default_server_keepalive_time_ms == INT_MAX
+ ? GRPC_MILLIS_INF_FUTURE
+ : g_default_server_keepalive_time_ms;
+ t->keepalive_timeout = g_default_server_keepalive_timeout_ms == INT_MAX
+ ? GRPC_MILLIS_INF_FUTURE
+ : g_default_server_keepalive_timeout_ms;
+ t->keepalive_permit_without_calls =
+ g_default_server_keepalive_permit_without_calls;
+ }
t->opt_target = GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY;
+ bool enable_bdp = true;
+
if (channel_args) {
for (i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key,
@@ -433,73 +395,62 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) {
t->ping_policy.max_pings_without_data = grpc_channel_arg_get_integer(
&channel_args->args[i],
- (grpc_integer_options){g_default_max_pings_without_data, 0,
- INT_MAX});
+ {g_default_max_pings_without_data, 0, INT_MAX});
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_MAX_PING_STRIKES)) {
t->ping_policy.max_ping_strikes = grpc_channel_arg_get_integer(
- &channel_args->args[i],
- (grpc_integer_options){g_default_max_ping_strikes, 0, INT_MAX});
+ &channel_args->args[i], {g_default_max_ping_strikes, 0, INT_MAX});
} else if (0 ==
strcmp(
channel_args->args[i].key,
GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS)) {
t->ping_policy.min_sent_ping_interval_without_data =
- gpr_time_from_millis(
- grpc_channel_arg_get_integer(
- &channel_args->args[i],
- (grpc_integer_options){
- g_default_min_sent_ping_interval_without_data_ms, 0,
- INT_MAX}),
- GPR_TIMESPAN);
+ grpc_channel_arg_get_integer(
+ &channel_args->args[i],
+ grpc_integer_options{
+ g_default_min_sent_ping_interval_without_data_ms, 0,
+ INT_MAX});
} else if (0 ==
strcmp(
channel_args->args[i].key,
GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS)) {
t->ping_policy.min_recv_ping_interval_without_data =
- gpr_time_from_millis(
- grpc_channel_arg_get_integer(
- &channel_args->args[i],
- (grpc_integer_options){
- g_default_min_recv_ping_interval_without_data_ms, 0,
- INT_MAX}),
- GPR_TIMESPAN);
+ grpc_channel_arg_get_integer(
+ &channel_args->args[i],
+ grpc_integer_options{
+ g_default_min_recv_ping_interval_without_data_ms, 0,
+ INT_MAX});
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) {
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
- &channel_args->args[i],
- (grpc_integer_options){0, 0, MAX_WRITE_BUFFER_SIZE});
+ &channel_args->args[i], {0, 0, MAX_WRITE_BUFFER_SIZE});
} else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) {
- t->flow_control.enable_bdp_probe = grpc_channel_arg_get_integer(
- &channel_args->args[i], (grpc_integer_options){1, 0, 1});
+ enable_bdp = grpc_channel_arg_get_bool(&channel_args->args[i], true);
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_TIME_MS)) {
const int value = grpc_channel_arg_get_integer(
&channel_args->args[i],
- (grpc_integer_options){t->is_client
- ? g_default_client_keepalive_time_ms
- : g_default_server_keepalive_time_ms,
- 1, INT_MAX});
- t->keepalive_time = value == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(value, GPR_TIMESPAN);
+ grpc_integer_options{t->is_client
+ ? g_default_client_keepalive_time_ms
+ : g_default_server_keepalive_time_ms,
+ 1, INT_MAX});
+ t->keepalive_time = value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
const int value = grpc_channel_arg_get_integer(
&channel_args->args[i],
- (grpc_integer_options){t->is_client
- ? g_default_client_keepalive_timeout_ms
- : g_default_server_keepalive_timeout_ms,
- 0, INT_MAX});
- t->keepalive_timeout = value == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis(value, GPR_TIMESPAN);
+ grpc_integer_options{t->is_client
+ ? g_default_client_keepalive_timeout_ms
+ : g_default_server_keepalive_timeout_ms,
+ 0, INT_MAX});
+ t->keepalive_timeout =
+ value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
t->keepalive_permit_without_calls =
- (uint32_t)grpc_channel_arg_get_integer(
- &channel_args->args[i], (grpc_integer_options){0, 0, 1});
+ (uint32_t)grpc_channel_arg_get_integer(&channel_args->args[i],
+ {0, 0, 1});
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_OPTIMIZATION_TARGET)) {
if (channel_args->args[i].type != GRPC_ARG_STRING) {
@@ -519,7 +470,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
} else {
static const struct {
- const char *channel_arg_name;
+ const char* channel_arg_name;
grpc_chttp2_setting_id setting_id;
grpc_integer_options integer_options;
bool availability[2] /* server, client */;
@@ -559,7 +510,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
int value = grpc_channel_arg_get_integer(
&channel_args->args[i], settings_map[j].integer_options);
if (value >= 0) {
- queue_setting_update(exec_ctx, t, settings_map[j].setting_id,
+ queue_setting_update(t, settings_map[j].setting_id,
(uint32_t)value);
}
}
@@ -570,62 +521,75 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
}
+ if (g_flow_control_enabled) {
+ t->flow_control.Init<grpc_core::chttp2::TransportFlowControl>(t,
+ enable_bdp);
+ } else {
+ t->flow_control.Init<grpc_core::chttp2::TransportFlowControlDisabled>(t);
+ enable_bdp = false;
+ }
+
/* No pings allowed before receiving a header or data frame. */
t->ping_state.pings_before_data_required = 0;
t->ping_state.is_delayed_ping_timer_set = false;
+ t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST;
- t->ping_recv_state.last_ping_recv_time = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST;
t->ping_recv_state.ping_strikes = 0;
/* Start keepalive pings */
- if (gpr_time_cmp(t->keepalive_time, gpr_inf_future(GPR_TIMESPAN)) != 0) {
+ if (t->keepalive_time != GRPC_MILLIS_INF_FUTURE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(
- exec_ctx, &t->keepalive_ping_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time),
- &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
+ &t->init_keepalive_ping_locked);
} else {
/* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no
inflight keeaplive timers */
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED;
}
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE);
- post_benign_reclaimer(exec_ctx, t);
+ if (enable_bdp) {
+ GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
+ schedule_bdp_ping_locked(t);
+
+ grpc_chttp2_act_on_flowctl_action(t->flow_control->PeriodicUpdate(), t,
+ nullptr);
+ }
+
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE);
+ post_benign_reclaimer(t);
}
-static void destroy_transport_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void destroy_transport_locked(void* tp, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
t->destroying = 1;
close_transport_locked(
- exec_ctx, t,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"),
- GRPC_ERROR_INT_OCCURRED_DURING_WRITE, t->write_state));
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "destroy");
+ t, grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"),
+ GRPC_ERROR_INT_OCCURRED_DURING_WRITE, t->write_state));
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "destroy");
}
-static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
+static void destroy_transport(grpc_transport* gt) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
}
-static void close_transport_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_error *error) {
- if (!t->closed) {
+static void close_transport_locked(grpc_chttp2_transport* t,
+ grpc_error* error) {
+ end_all_the_calls(t, GRPC_ERROR_REF(error));
+ cancel_pings(t, GRPC_ERROR_REF(error));
+ if (t->closed_with_error == GRPC_ERROR_NONE) {
if (!grpc_error_has_clear_grpc_status(error)) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAVAILABLE);
}
if (t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE) {
- if (t->close_transport_on_writes_finished == NULL) {
+ if (t->close_transport_on_writes_finished == nullptr) {
t->close_transport_on_writes_finished =
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Delayed close due to in-progress write");
@@ -634,20 +598,23 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
grpc_error_add_child(t->close_transport_on_writes_finished, error);
return;
}
- t->closed = 1;
- connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_REF(error), "close_transport");
- grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error));
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ t->closed_with_error = GRPC_ERROR_REF(error);
+ connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
+ "close_transport");
if (t->ping_state.is_delayed_ping_timer_set) {
- grpc_timer_cancel(exec_ctx, &t->ping_state.delayed_ping_timer);
+ grpc_timer_cancel(&t->ping_state.delayed_ping_timer);
+ }
+ if (t->have_next_bdp_ping_timer) {
+ grpc_timer_cancel(&t->next_bdp_ping_timer);
}
switch (t->keepalive_state) {
case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING:
- grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
+ grpc_timer_cancel(&t->keepalive_ping_timer);
break;
case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING:
- grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
- grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer);
+ grpc_timer_cancel(&t->keepalive_ping_timer);
+ grpc_timer_cancel(&t->keepalive_watchdog_timer);
break;
case GRPC_CHTTP2_KEEPALIVE_STATE_DYING:
case GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED:
@@ -656,39 +623,42 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
}
/* flush writable stream list to avoid dangling references */
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:close");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:close");
}
- end_all_the_calls(exec_ctx, t, GRPC_ERROR_REF(error));
- cancel_pings(exec_ctx, t, GRPC_ERROR_REF(error));
+ GPR_ASSERT(t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE);
+ grpc_endpoint_shutdown(t->ep, GRPC_ERROR_REF(error));
+ }
+ if (t->notify_on_receive_settings != nullptr) {
+ GRPC_CLOSURE_SCHED(t->notify_on_receive_settings, GRPC_ERROR_CANCELLED);
+ t->notify_on_receive_settings = nullptr;
}
GRPC_ERROR_UNREF(error);
}
#ifndef NDEBUG
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s, const char *reason) {
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason) {
grpc_stream_ref(s->refcount, reason);
}
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s,
- const char *reason) {
- grpc_stream_unref(exec_ctx, s->refcount, reason);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s, const char* reason) {
+ grpc_stream_unref(s->refcount, reason);
}
#else
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s) {
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s) {
grpc_stream_ref(s->refcount);
}
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s) {
- grpc_stream_unref(exec_ctx, s->refcount);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s) {
+ grpc_stream_unref(s->refcount);
}
#endif
-static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
+static int init_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
GPR_TIMER_BEGIN("init_stream", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
s->t = t;
s->refcount = refcount;
@@ -701,7 +671,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[1], arena);
grpc_chttp2_data_parser_init(&s->data_parser);
grpc_slice_buffer_init(&s->flow_controlled_buffer);
- s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ s->deadline = GRPC_MILLIS_INF_FUTURE;
GRPC_CLOSURE_INIT(&s->complete_fetch_locked, complete_fetch_locked, s,
grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&s->unprocessed_incoming_frames_buffer);
@@ -719,32 +689,37 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
s->id = (uint32_t)(uintptr_t)server_data;
*t->accepting_stream = s;
grpc_chttp2_stream_map_add(&t->stream_map, s->id, s);
- post_destructive_reclaimer(exec_ctx, t);
+ post_destructive_reclaimer(t);
}
- s->flow_control.s = s;
+ if (t->flow_control->flow_control_enabled()) {
+ s->flow_control.Init<grpc_core::chttp2::StreamFlowControl>(
+ static_cast<grpc_core::chttp2::TransportFlowControl*>(
+ t->flow_control.get()),
+ s);
+ } else {
+ s->flow_control.Init<grpc_core::chttp2::StreamFlowControlDisabled>();
+ }
GPR_TIMER_END("init_stream", 0);
return 0;
}
-static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)sp;
- grpc_chttp2_transport *t = s->t;
+static void destroy_stream_locked(void* sp, grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
+ grpc_chttp2_transport* t = s->t;
GPR_TIMER_BEGIN("destroy_stream", 0);
GPR_ASSERT((s->write_closed && s->read_closed) || s->id == 0);
if (s->id != 0) {
- GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) == NULL);
+ GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) == nullptr);
}
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &s->unprocessed_incoming_frames_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->frame_storage);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->compressed_data_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->decompressed_data_buffer);
+ grpc_slice_buffer_destroy_internal(&s->unprocessed_incoming_frames_buffer);
+ grpc_slice_buffer_destroy_internal(&s->frame_storage);
+ grpc_slice_buffer_destroy_internal(&s->compressed_data_buffer);
+ grpc_slice_buffer_destroy_internal(&s->decompressed_data_buffer);
grpc_chttp2_list_remove_stalled_by_transport(t, s);
grpc_chttp2_list_remove_stalled_by_stream(t, s);
@@ -757,73 +732,68 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
}
}
- GPR_ASSERT(s->send_initial_metadata_finished == NULL);
- GPR_ASSERT(s->fetching_send_message == NULL);
- GPR_ASSERT(s->send_trailing_metadata_finished == NULL);
- GPR_ASSERT(s->recv_initial_metadata_ready == NULL);
- GPR_ASSERT(s->recv_message_ready == NULL);
- GPR_ASSERT(s->recv_trailing_metadata_finished == NULL);
- grpc_chttp2_data_parser_destroy(exec_ctx, &s->data_parser);
- grpc_chttp2_incoming_metadata_buffer_destroy(exec_ctx,
- &s->metadata_buffer[0]);
- grpc_chttp2_incoming_metadata_buffer_destroy(exec_ctx,
- &s->metadata_buffer[1]);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->flow_controlled_buffer);
+ GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
+ GPR_ASSERT(s->fetching_send_message == nullptr);
+ GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
+ GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
+ GPR_ASSERT(s->recv_message_ready == nullptr);
+ GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
+ grpc_chttp2_data_parser_destroy(&s->data_parser);
+ grpc_chttp2_incoming_metadata_buffer_destroy(&s->metadata_buffer[0]);
+ grpc_chttp2_incoming_metadata_buffer_destroy(&s->metadata_buffer[1]);
+ grpc_slice_buffer_destroy_internal(&s->flow_controlled_buffer);
GRPC_ERROR_UNREF(s->read_closed_error);
GRPC_ERROR_UNREF(s->write_closed_error);
GRPC_ERROR_UNREF(s->byte_stream_error);
- grpc_chttp2_flowctl_destroy_stream(&t->flow_control, &s->flow_control);
+ s->flow_control.Destroy();
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "stream");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "stream");
GPR_TIMER_END("destroy_stream", 0);
- GRPC_CLOSURE_SCHED(exec_ctx, s->destroy_stream_arg, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->destroy_stream_arg, GRPC_ERROR_NONE);
}
-static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_closure *then_schedule_closure) {
+static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_closure* then_schedule_closure) {
GPR_TIMER_BEGIN("destroy_stream", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
- if (s->stream_compression_ctx != NULL) {
+ if (s->stream_compression_ctx != nullptr) {
grpc_stream_compression_context_destroy(s->stream_compression_ctx);
- s->stream_compression_ctx = NULL;
+ s->stream_compression_ctx = nullptr;
}
- if (s->stream_decompression_ctx != NULL) {
+ if (s->stream_decompression_ctx != nullptr) {
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
s->destroy_stream_arg = then_schedule_closure;
GRPC_CLOSURE_SCHED(
- exec_ctx, GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
- grpc_combiner_scheduler(t->combiner)),
+ GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
+ grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
GPR_TIMER_END("destroy_stream", 0);
}
-grpc_chttp2_stream *grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
uint32_t id) {
- return (grpc_chttp2_stream *)grpc_chttp2_stream_map_find(&t->stream_map, id);
+ return (grpc_chttp2_stream*)grpc_chttp2_stream_map_find(&t->stream_map, id);
}
-grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
uint32_t id) {
- if (t->channel_callback.accept_stream == NULL) {
- return NULL;
+ if (t->channel_callback.accept_stream == nullptr) {
+ return nullptr;
}
- grpc_chttp2_stream *accepting;
- GPR_ASSERT(t->accepting_stream == NULL);
+ grpc_chttp2_stream* accepting;
+ GPR_ASSERT(t->accepting_stream == nullptr);
t->accepting_stream = &accepting;
- t->channel_callback.accept_stream(exec_ctx,
- t->channel_callback.accept_stream_user_data,
- &t->base, (void *)(uintptr_t)id);
- t->accepting_stream = NULL;
+ t->channel_callback.accept_stream(t->channel_callback.accept_stream_user_data,
+ &t->base, (void*)(uintptr_t)id);
+ t->accepting_stream = nullptr;
return accepting;
}
@@ -831,7 +801,7 @@ grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
* OUTPUT PROCESSING
*/
-static const char *write_state_name(grpc_chttp2_write_state st) {
+static const char* write_state_name(grpc_chttp2_write_state st) {
switch (st) {
case GRPC_CHTTP2_WRITE_STATE_IDLE:
return "IDLE";
@@ -843,119 +813,108 @@ static const char *write_state_name(grpc_chttp2_write_state st) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-static void set_write_state(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_write_state st, const char *reason) {
+static void set_write_state(grpc_chttp2_transport* t,
+ grpc_chttp2_write_state st, const char* reason) {
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "W:%p %s state %s -> %s [%s]", t,
t->is_client ? "CLIENT" : "SERVER",
write_state_name(t->write_state),
write_state_name(st), reason));
t->write_state = st;
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &t->run_after_write);
- if (t->close_transport_on_writes_finished != NULL) {
- grpc_error *err = t->close_transport_on_writes_finished;
- t->close_transport_on_writes_finished = NULL;
- close_transport_locked(exec_ctx, t, err);
+ GRPC_CLOSURE_LIST_SCHED(&t->run_after_write);
+ if (t->close_transport_on_writes_finished != nullptr) {
+ grpc_error* err = t->close_transport_on_writes_finished;
+ t->close_transport_on_writes_finished = nullptr;
+ close_transport_locked(t, err);
}
}
}
static void inc_initiate_write_reason(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_initiate_write_reason reason) {
+ grpc_chttp2_initiate_write_reason reason) {
switch (reason) {
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA();
break;
case GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_CONTINUE_PINGS:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS();
break;
case GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT();
break;
case GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM();
break;
case GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API();
break;
case GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL();
break;
case GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS(exec_ctx);
- break;
- case GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS();
break;
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED();
break;
case GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM();
break;
}
}
-void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
grpc_chttp2_initiate_write_reason reason) {
GPR_TIMER_BEGIN("grpc_chttp2_initiate_write", 0);
switch (t->write_state) {
case GRPC_CHTTP2_WRITE_STATE_IDLE:
- inc_initiate_write_reason(exec_ctx, reason);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_WRITING,
+ inc_initiate_write_reason(reason);
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING,
grpc_chttp2_initiate_write_reason_string(reason));
t->is_first_write_in_batch = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "writing");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t,
grpc_combiner_finally_scheduler(t->combiner)),
GRPC_ERROR_NONE);
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING:
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE,
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE,
grpc_chttp2_initiate_write_reason_string(reason));
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE:
@@ -964,15 +923,15 @@ void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
GPR_TIMER_END("grpc_chttp2_initiate_write", 0);
}
-void grpc_chttp2_mark_stream_writable(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
- if (!t->closed && grpc_chttp2_list_add_writable_stream(t, s)) {
+void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ if (t->closed_with_error == GRPC_ERROR_NONE &&
+ grpc_chttp2_list_add_writable_stream(t, s)) {
GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:become");
}
}
-static grpc_closure_scheduler *write_scheduler(grpc_chttp2_transport *t,
+static grpc_closure_scheduler* write_scheduler(grpc_chttp2_transport* t,
bool early_results_scheduled,
bool partial_write) {
/* if it's not the first write in a batch, always offload to the executor:
@@ -996,11 +955,11 @@ static grpc_closure_scheduler *write_scheduler(grpc_chttp2_transport *t,
case GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY:
return grpc_schedule_on_exec_ctx;
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
#define WRITE_STATE_TUPLE_TO_INT(p, i) (2 * (int)(p) + (int)(i))
-static const char *begin_writing_desc(bool partial, bool inlined) {
+static const char* begin_writing_desc(bool partial, bool inlined) {
switch (WRITE_STATE_TUPLE_TO_INT(partial, inlined)) {
case WRITE_STATE_TUPLE_TO_INT(false, false):
return "begin write in background";
@@ -1014,68 +973,67 @@ static const char *begin_writing_desc(bool partial, bool inlined) {
GPR_UNREACHABLE_CODE(return "bad state tuple");
}
-static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
- grpc_error *error_ignored) {
+static void write_action_begin_locked(void* gt, grpc_error* error_ignored) {
GPR_TIMER_BEGIN("write_action_begin_locked", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
grpc_chttp2_begin_write_result r;
- if (t->closed) {
+ if (t->closed_with_error != GRPC_ERROR_NONE) {
r.writing = false;
} else {
- r = grpc_chttp2_begin_write(exec_ctx, t);
+ r = grpc_chttp2_begin_write(t);
}
if (r.writing) {
if (r.partial) {
- GRPC_STATS_INC_HTTP2_PARTIAL_WRITES(exec_ctx);
+ GRPC_STATS_INC_HTTP2_PARTIAL_WRITES();
}
if (!t->is_first_write_in_batch) {
- GRPC_STATS_INC_HTTP2_WRITES_CONTINUED(exec_ctx);
+ GRPC_STATS_INC_HTTP2_WRITES_CONTINUED();
}
- grpc_closure_scheduler *scheduler =
+ grpc_closure_scheduler* scheduler =
write_scheduler(t, r.early_results_scheduled, r.partial);
if (scheduler != grpc_schedule_on_exec_ctx) {
- GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED(exec_ctx);
+ GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED();
}
set_write_state(
- exec_ctx, t, r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE
- : GRPC_CHTTP2_WRITE_STATE_WRITING,
+ t,
+ r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE
+ : GRPC_CHTTP2_WRITE_STATE_WRITING,
begin_writing_desc(r.partial, scheduler == grpc_schedule_on_exec_ctx));
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_INIT(&t->write_action,
- write_action, t, scheduler),
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(
+ GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler),
+ GRPC_ERROR_NONE);
} else {
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE,
- "begin writing nothing");
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "writing");
+ GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN();
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing");
}
GPR_TIMER_END("write_action_begin_locked", 0);
}
-static void write_action(grpc_exec_ctx *exec_ctx, void *gt, grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
+static void write_action(void* gt, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GPR_TIMER_BEGIN("write_action", 0);
grpc_endpoint_write(
- exec_ctx, t->ep, &t->outbuf,
+ t->ep, &t->outbuf,
GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end_locked, t,
grpc_combiner_scheduler(t->combiner)));
GPR_TIMER_END("write_action", 0);
}
-static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
+static void write_action_end_locked(void* tp, grpc_error* error) {
GPR_TIMER_BEGIN("terminate_writing_with_lock", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (error != GRPC_ERROR_NONE) {
- close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
+ close_transport_locked(t, GRPC_ERROR_REF(error));
}
if (t->sent_goaway_state == GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED) {
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SENT;
if (grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
close_transport_locked(
- exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("goaway sent"));
+ t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("goaway sent"));
}
}
@@ -1084,17 +1042,14 @@ static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
GPR_UNREACHABLE_CODE(break);
case GRPC_CHTTP2_WRITE_STATE_WRITING:
GPR_TIMER_MARK("state=writing", 0);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE,
- "finish writing");
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "finish writing");
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE:
GPR_TIMER_MARK("state=writing_stale_no_poller", 0);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_WRITING,
- "continue writing");
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING, "continue writing");
t->is_first_write_in_batch = false;
GRPC_CHTTP2_REF_TRANSPORT(t, "writing");
GRPC_CLOSURE_RUN(
- exec_ctx,
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t,
grpc_combiner_finally_scheduler(t->combiner)),
@@ -1102,18 +1057,17 @@ static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
break;
}
- grpc_chttp2_end_write(exec_ctx, t, GRPC_ERROR_REF(error));
+ grpc_chttp2_end_write(t, GRPC_ERROR_REF(error));
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "writing");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing");
GPR_TIMER_END("terminate_writing_with_lock", 0);
}
// Dirties an HTTP2 setting to be sent out next time a writing path occurs.
// If the change needs to occur immediately, manually initiate a write.
-static void queue_setting_update(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void queue_setting_update(grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value) {
- const grpc_chttp2_setting_parameters *sp =
+ const grpc_chttp2_setting_parameters* sp =
&grpc_chttp2_settings_parameters[id];
uint32_t use_value = GPR_CLAMP(value, sp->min_value, sp->max_value);
if (use_value != value) {
@@ -1126,13 +1080,21 @@ static void queue_setting_update(grpc_exec_ctx *exec_ctx,
}
}
-void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
uint32_t goaway_error,
grpc_slice goaway_text) {
// GRPC_CHTTP2_IF_TRACING(
// gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg));
- t->seen_goaway = 1;
+
+ // Discard the error from a previous goaway frame (if any)
+ if (t->goaway_error != GRPC_ERROR_NONE) {
+ GRPC_ERROR_UNREF(t->goaway_error);
+ }
+ t->goaway_error = grpc_error_set_str(
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
+ GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
+ GRPC_ERROR_STR_RAW_BYTES, goaway_text);
/* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
* data equal to "too_many_pings", it should log the occurrence at a log level
@@ -1143,31 +1105,22 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
gpr_log(GPR_ERROR,
"Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug "
"data equal to \"too_many_pings\"");
- double current_keepalive_time_ms =
- gpr_timespec_to_micros(t->keepalive_time) / 1000;
+ double current_keepalive_time_ms = (double)t->keepalive_time;
t->keepalive_time =
current_keepalive_time_ms > INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_millis((int64_t)(current_keepalive_time_ms *
- KEEPALIVE_TIME_BACKOFF_MULTIPLIER),
- GPR_TIMESPAN);
+ ? GRPC_MILLIS_INF_FUTURE
+ : (grpc_millis)(current_keepalive_time_ms *
+ KEEPALIVE_TIME_BACKOFF_MULTIPLIER);
}
/* lie: use transient failure from the transport to indicate goaway has been
* received */
- connectivity_state_set(
- exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
- grpc_error_set_str(
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
- GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
- GRPC_ERROR_STR_RAW_BYTES, goaway_text),
- "got_goaway");
+ connectivity_state_set(t, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(t->goaway_error), "got_goaway");
}
-static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_chttp2_stream *s;
+static void maybe_start_some_streams(grpc_chttp2_transport* t) {
+ grpc_chttp2_stream* s;
/* start streams where we have free grpc_chttp2_stream ids and free
* concurrency */
while (t->next_stream_id <= MAX_CLIENT_STREAM_ID &&
@@ -1186,22 +1139,21 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) {
connectivity_state_set(
- exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ t, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"),
"no_more_stream_ids");
}
grpc_chttp2_stream_map_add(&t->stream_map, s->id, s);
- post_destructive_reclaimer(exec_ctx, t);
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM);
+ post_destructive_reclaimer(t);
+ grpc_chttp2_mark_stream_writable(t, s);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM);
}
/* cancel out streams that will never be started */
while (t->next_stream_id >= MAX_CLIENT_STREAM_ID &&
grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
@@ -1218,32 +1170,30 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
bits being used for flags defined above) */
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16)
-static grpc_closure *add_closure_barrier(grpc_closure *closure) {
+static grpc_closure* add_closure_barrier(grpc_closure* closure) {
closure->next_data.scratch += CLOSURE_BARRIER_FIRST_REF_BIT;
return closure;
}
-static void null_then_run_closure(grpc_exec_ctx *exec_ctx,
- grpc_closure **closure, grpc_error *error) {
- grpc_closure *c = *closure;
- *closure = NULL;
- GRPC_CLOSURE_RUN(exec_ctx, c, error);
+static void null_then_run_closure(grpc_closure** closure, grpc_error* error) {
+ grpc_closure* c = *closure;
+ *closure = nullptr;
+ GRPC_CLOSURE_RUN(c, error);
}
-void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
- grpc_closure **pclosure,
- grpc_error *error, const char *desc) {
- grpc_closure *closure = *pclosure;
- *pclosure = NULL;
- if (closure == NULL) {
+void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_closure** pclosure,
+ grpc_error* error, const char* desc) {
+ grpc_closure* closure = *pclosure;
+ *pclosure = nullptr;
+ if (closure == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT;
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- const char *errstr = grpc_error_string(error);
+ if (grpc_http_trace.enabled()) {
+ const char* errstr = grpc_error_string(error);
gpr_log(
GPR_DEBUG,
"complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s "
@@ -1267,11 +1217,11 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
if (closure->next_data.scratch < CLOSURE_BARRIER_FIRST_REF_BIT) {
if (closure->next_data.scratch & CLOSURE_BARRIER_STATS_BIT) {
grpc_transport_move_stats(&s->stats, s->collecting_stats);
- s->collecting_stats = NULL;
+ s->collecting_stats = nullptr;
}
if ((t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE) ||
!(closure->next_data.scratch & CLOSURE_BARRIER_MAY_COVER_WRITE)) {
- GRPC_CLOSURE_RUN(exec_ctx, closure, closure->error_data.error);
+ GRPC_CLOSURE_RUN(closure, closure->error_data.error);
} else {
grpc_closure_list_append(&t->run_after_write, closure,
closure->error_data.error);
@@ -1279,109 +1229,103 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
}
}
-static bool contains_non_ok_status(grpc_metadata_batch *batch) {
- if (batch->idx.named.grpc_status != NULL) {
+static bool contains_non_ok_status(grpc_metadata_batch* batch) {
+ if (batch->idx.named.grpc_status != nullptr) {
return !grpc_mdelem_eq(batch->idx.named.grpc_status->md,
GRPC_MDELEM_GRPC_STATUS_0);
}
return false;
}
-static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+static void maybe_become_writable_due_to_send_msg(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
if (s->id != 0 && (!s->write_buffering ||
s->flow_controlled_buffer.length > t->write_buffer_size)) {
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE);
+ grpc_chttp2_mark_stream_writable(t, s);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE);
}
}
-static void add_fetched_slice_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+static void add_fetched_slice_locked(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
s->fetched_send_message_length +=
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
- maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
+ maybe_become_writable_due_to_send_msg(t, s);
}
-static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+static void continue_fetching_send_locked(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
for (;;) {
- if (s->fetching_send_message == NULL) {
+ if (s->fetching_send_message == nullptr) {
/* Stream was cancelled before message fetch completed */
abort(); /* TODO(ctiller): what cleanup here? */
return; /* early out */
}
if (s->fetched_send_message_length == s->fetching_send_message->length) {
- grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
+ grpc_byte_stream_destroy(s->fetching_send_message);
int64_t notify_offset = s->next_message_end_offset;
if (notify_offset <= s->flow_controlled_bytes_written) {
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE,
+ t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE,
"fetching_send_message_finished");
} else {
- grpc_chttp2_write_cb *cb = t->write_cb_pool;
- if (cb == NULL) {
- cb = (grpc_chttp2_write_cb *)gpr_malloc(sizeof(*cb));
+ grpc_chttp2_write_cb* cb = t->write_cb_pool;
+ if (cb == nullptr) {
+ cb = (grpc_chttp2_write_cb*)gpr_malloc(sizeof(*cb));
} else {
t->write_cb_pool = cb->next;
}
cb->call_at_byte = notify_offset;
cb->closure = s->fetching_send_message_finished;
- s->fetching_send_message_finished = NULL;
- grpc_chttp2_write_cb **list =
+ s->fetching_send_message_finished = nullptr;
+ grpc_chttp2_write_cb** list =
s->fetching_send_message->flags & GRPC_WRITE_THROUGH
? &s->on_write_finished_cbs
: &s->on_flow_controlled_cbs;
cb->next = *list;
*list = cb;
}
- s->fetching_send_message = NULL;
+ s->fetching_send_message = nullptr;
return; /* early out */
- } else if (grpc_byte_stream_next(exec_ctx, s->fetching_send_message,
- UINT32_MAX, &s->complete_fetch_locked)) {
- grpc_error *error = grpc_byte_stream_pull(
- exec_ctx, s->fetching_send_message, &s->fetching_slice);
+ } else if (grpc_byte_stream_next(s->fetching_send_message, UINT32_MAX,
+ &s->complete_fetch_locked)) {
+ grpc_error* error =
+ grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice);
if (error != GRPC_ERROR_NONE) {
- grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
+ grpc_byte_stream_destroy(s->fetching_send_message);
+ grpc_chttp2_cancel_stream(t, s, error);
} else {
- add_fetched_slice_locked(exec_ctx, t, s);
+ add_fetched_slice_locked(t, s);
}
}
}
}
-static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
- grpc_chttp2_transport *t = s->t;
+static void complete_fetch_locked(void* gs, grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
+ grpc_chttp2_transport* t = s->t;
if (error == GRPC_ERROR_NONE) {
- error = grpc_byte_stream_pull(exec_ctx, s->fetching_send_message,
- &s->fetching_slice);
+ error = grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice);
if (error == GRPC_ERROR_NONE) {
- add_fetched_slice_locked(exec_ctx, t, s);
- continue_fetching_send_locked(exec_ctx, t, s);
+ add_fetched_slice_locked(t, s);
+ continue_fetching_send_locked(t, s);
}
}
if (error != GRPC_ERROR_NONE) {
- grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
+ grpc_byte_stream_destroy(s->fetching_send_message);
+ grpc_chttp2_cancel_stream(t, s, error);
}
}
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
-static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id,
+static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id,
bool is_client, bool is_initial) {
- for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL;
+ for (grpc_linked_mdelem* md = md_batch->list.head; md != nullptr;
md = md->next) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
- char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
+ char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
gpr_log(GPR_INFO, "HTTP:%d:%s:%s: %s: %s", id, is_initial ? "HDR" : "TRL",
is_client ? "CLI" : "SVR", key, value);
gpr_free(key);
@@ -1389,20 +1333,20 @@ static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id,
}
}
-static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
- grpc_error *error_ignored) {
+static void perform_stream_op_locked(void* stream_op,
+ grpc_error* error_ignored) {
GPR_TIMER_BEGIN("perform_stream_op_locked", 0);
- grpc_transport_stream_op_batch *op =
- (grpc_transport_stream_op_batch *)stream_op;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)op->handler_private.extra_arg;
- grpc_transport_stream_op_batch_payload *op_payload = op->payload;
- grpc_chttp2_transport *t = s->t;
+ grpc_transport_stream_op_batch* op =
+ (grpc_transport_stream_op_batch*)stream_op;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)op->handler_private.extra_arg;
+ grpc_transport_stream_op_batch_payload* op_payload = op->payload;
+ grpc_chttp2_transport* t = s->t;
- GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_BATCHES();
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- char *str = grpc_transport_stream_op_batch_string(op);
+ if (grpc_http_trace.enabled()) {
+ char* str = grpc_transport_stream_op_batch_string(op);
gpr_log(GPR_DEBUG, "perform_stream_op_locked: %s; on_complete = %p", str,
op->on_complete);
gpr_free(str);
@@ -1416,10 +1360,10 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
}
}
- grpc_closure *on_complete = op->on_complete;
- if (on_complete == NULL) {
+ grpc_closure* on_complete = op->on_complete;
+ if (on_complete == nullptr) {
on_complete =
- GRPC_CLOSURE_CREATE(do_nothing, NULL, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_CREATE(do_nothing, nullptr, grpc_schedule_on_exec_ctx);
}
/* use final_data as a barrier until enqueue time; the inital counter is
@@ -1428,25 +1372,24 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
on_complete->error_data.error = GRPC_ERROR_NONE;
if (op->collect_stats) {
- GPR_ASSERT(s->collecting_stats == NULL);
+ GPR_ASSERT(s->collecting_stats == nullptr);
s->collecting_stats = op_payload->collect_stats.collect_stats;
on_complete->next_data.scratch |= CLOSURE_BARRIER_STATS_BIT;
}
if (op->cancel_stream) {
- GRPC_STATS_INC_HTTP2_OP_CANCEL(exec_ctx);
- grpc_chttp2_cancel_stream(exec_ctx, t, s,
- op_payload->cancel_stream.cancel_error);
+ GRPC_STATS_INC_HTTP2_OP_CANCEL();
+ grpc_chttp2_cancel_stream(t, s, op_payload->cancel_stream.cancel_error);
}
if (op->send_initial_metadata) {
- GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx);
- GPR_ASSERT(s->send_initial_metadata_finished == NULL);
+ GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA();
+ GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
/* Identify stream compression */
if (op_payload->send_initial_metadata.send_initial_metadata->idx.named
- .content_encoding == NULL ||
+ .content_encoding == nullptr ||
grpc_stream_compression_method_parse(
GRPC_MDVALUE(
op_payload->send_initial_metadata.send_initial_metadata->idx
@@ -1464,12 +1407,11 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
t->settings[GRPC_PEER_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
if (t->is_client) {
- s->deadline =
- gpr_time_min(s->deadline, s->send_initial_metadata->deadline);
+ s->deadline = GPR_MIN(s->deadline, s->send_initial_metadata->deadline);
}
if (metadata_size > metadata_peer_limit) {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -1485,47 +1427,48 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
}
if (!s->write_closed) {
if (t->is_client) {
- if (!t->closed) {
+ if (t->closed_with_error == GRPC_ERROR_NONE) {
GPR_ASSERT(s->id == 0);
grpc_chttp2_list_add_waiting_for_concurrency(t, s);
- maybe_start_some_streams(exec_ctx, t);
+ maybe_start_some_streams(t);
} else {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Transport closed", &t->closed_with_error, 1),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
}
} else {
GPR_ASSERT(s->id != 0);
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
if (!(op->send_message &&
(op->payload->send_message.send_message->flags &
GRPC_WRITE_BUFFER_HINT))) {
grpc_chttp2_initiate_write(
- exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA);
+ t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA);
}
}
} else {
- s->send_initial_metadata = NULL;
+ s->send_initial_metadata = nullptr;
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_initial_metadata_finished,
+ t, s, &s->send_initial_metadata_finished,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Attempt to send initial metadata after stream was closed",
&s->write_closed_error, 1),
"send_initial_metadata_finished");
}
}
- if (op_payload->send_initial_metadata.peer_string != NULL) {
+ if (op_payload->send_initial_metadata.peer_string != nullptr) {
gpr_atm_rel_store(op_payload->send_initial_metadata.peer_string,
(gpr_atm)gpr_strdup(t->peer_string));
}
}
if (op->send_message) {
- GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE();
GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE(
- exec_ctx, op->payload->send_message.send_message->length);
+ op->payload->send_message.send_message->length);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->fetching_send_message_finished = add_closure_barrier(op->on_complete);
if (s->write_closed) {
@@ -1535,7 +1478,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
// recv_message failure, breaking out of its loop, and then
// starting recv_trailing_metadata.
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->fetching_send_message_finished,
+ t, s, &s->fetching_send_message_finished,
t->is_client && s->received_trailing_metadata
? GRPC_ERROR_NONE
: GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@@ -1543,8 +1486,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
&s->write_closed_error, 1),
"fetching_send_message_finished");
} else {
- GPR_ASSERT(s->fetching_send_message == NULL);
- uint8_t *frame_hdr = grpc_slice_buffer_tiny_add(
+ GPR_ASSERT(s->fetching_send_message == nullptr);
+ uint8_t* frame_hdr = grpc_slice_buffer_tiny_add(
&s->flow_controlled_buffer, GRPC_HEADER_SIZE_IN_BYTES);
uint32_t flags = op_payload->send_message.send_message->flags;
frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0;
@@ -1564,14 +1507,14 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
} else {
s->write_buffering = false;
}
- continue_fetching_send_locked(exec_ctx, t, s);
- maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
+ continue_fetching_send_locked(t, s);
+ maybe_become_writable_due_to_send_msg(t, s);
}
}
if (op->send_trailing_metadata) {
- GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx);
- GPR_ASSERT(s->send_trailing_metadata_finished == NULL);
+ GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA();
+ GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->send_trailing_metadata_finished = add_closure_barrier(on_complete);
s->send_trailing_metadata =
@@ -1584,7 +1527,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
if (metadata_size > metadata_peer_limit) {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -1599,9 +1542,9 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
s->seen_error = true;
}
if (s->write_closed) {
- s->send_trailing_metadata = NULL;
+ s->send_trailing_metadata = nullptr;
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_trailing_metadata_finished,
+ t, s, &s->send_trailing_metadata_finished,
grpc_metadata_batch_is_empty(
op->payload->send_trailing_metadata.send_trailing_metadata)
? GRPC_ERROR_NONE
@@ -1612,92 +1555,85 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
} else if (s->id != 0) {
/* TODO(ctiller): check if there's flow control for any outstanding
bytes before going writable */
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
- exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA);
+ t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA);
}
}
}
if (op->recv_initial_metadata) {
- GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx);
- GPR_ASSERT(s->recv_initial_metadata_ready == NULL);
+ GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA();
+ GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
s->recv_initial_metadata_ready =
op_payload->recv_initial_metadata.recv_initial_metadata_ready;
s->recv_initial_metadata =
op_payload->recv_initial_metadata.recv_initial_metadata;
s->trailing_metadata_available =
op_payload->recv_initial_metadata.trailing_metadata_available;
- if (op_payload->recv_initial_metadata.peer_string != NULL) {
+ if (op_payload->recv_initial_metadata.peer_string != nullptr) {
gpr_atm_rel_store(op_payload->recv_initial_metadata.peer_string,
(gpr_atm)gpr_strdup(t->peer_string));
}
- grpc_chttp2_maybe_complete_recv_initial_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_initial_metadata(t, s);
}
if (op->recv_message) {
- GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE();
size_t already_received;
- GPR_ASSERT(s->recv_message_ready == NULL);
+ GPR_ASSERT(s->recv_message_ready == nullptr);
GPR_ASSERT(!s->pending_byte_stream);
s->recv_message_ready = op_payload->recv_message.recv_message_ready;
s->recv_message = op_payload->recv_message.recv_message;
if (s->id != 0) {
if (!s->read_closed) {
already_received = s->frame_storage.length;
- grpc_chttp2_flowctl_incoming_bs_update(
- &t->flow_control, &s->flow_control, GRPC_HEADER_SIZE_IN_BYTES,
- already_received);
- grpc_chttp2_act_on_flowctl_action(
- exec_ctx,
- grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control),
- t, s);
+ s->flow_control->IncomingByteStreamUpdate(GRPC_HEADER_SIZE_IN_BYTES,
+ already_received);
+ grpc_chttp2_act_on_flowctl_action(s->flow_control->MakeAction(), t, s);
}
}
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
}
if (op->recv_trailing_metadata) {
- GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx);
- GPR_ASSERT(s->recv_trailing_metadata_finished == NULL);
+ GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA();
+ GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
s->recv_trailing_metadata_finished = add_closure_barrier(on_complete);
s->recv_trailing_metadata =
op_payload->recv_trailing_metadata.recv_trailing_metadata;
s->final_metadata_requested = true;
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
}
- grpc_chttp2_complete_closure_step(exec_ctx, t, s, &on_complete,
- GRPC_ERROR_NONE, "op->on_complete");
+ grpc_chttp2_complete_closure_step(t, s, &on_complete, GRPC_ERROR_NONE,
+ "op->on_complete");
GPR_TIMER_END("perform_stream_op_locked", 0);
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "perform_stream_op");
+ GRPC_CHTTP2_STREAM_UNREF(s, "perform_stream_op");
}
-static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_transport_stream_op_batch *op) {
+static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
+ grpc_transport_stream_op_batch* op) {
GPR_TIMER_BEGIN("perform_stream_op", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
if (!t->is_client) {
if (op->send_initial_metadata) {
- gpr_timespec deadline =
+ grpc_millis deadline =
op->payload->send_initial_metadata.send_initial_metadata->deadline;
- GPR_ASSERT(0 ==
- gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline));
+ GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE);
}
if (op->send_trailing_metadata) {
- gpr_timespec deadline =
+ grpc_millis deadline =
op->payload->send_trailing_metadata.send_trailing_metadata->deadline;
- GPR_ASSERT(0 ==
- gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline));
+ GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE);
}
}
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- char *str = grpc_transport_stream_op_batch_string(op);
+ if (grpc_http_trace.enabled()) {
+ char* str = grpc_transport_stream_op_batch_string(op);
gpr_log(GPR_DEBUG, "perform_stream_op[s=%p]: %s", s, str);
gpr_free(str);
}
@@ -1705,107 +1641,96 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
op->handler_private.extra_arg = gs;
GRPC_CHTTP2_STREAM_REF(s, "perform_stream_op");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&op->handler_private.closure, perform_stream_op_locked,
op, grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
GPR_TIMER_END("perform_stream_op", 0);
}
-static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
+static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error) {
/* callback remaining pings: they're not allowed to call into the transpot,
and maybe they hold resources that need to be freed */
- for (size_t i = 0; i < GRPC_CHTTP2_PING_TYPE_COUNT; i++) {
- grpc_chttp2_ping_queue *pq = &t->ping_queues[i];
- for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
- grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error));
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[j]);
- }
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
+ grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_LIST_SCHED(&pq->lists[j]);
}
GRPC_ERROR_UNREF(error);
}
-static void send_ping_locked(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_ping_type ping_type, grpc_closure *on_initiate,
- grpc_closure *on_ack,
- grpc_chttp2_initiate_write_reason initiate_write_reason) {
- grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type];
+static void send_ping_locked(grpc_chttp2_transport* t,
+ grpc_closure* on_initiate, grpc_closure* on_ack) {
+ if (t->closed_with_error != GRPC_ERROR_NONE) {
+ GRPC_CLOSURE_SCHED(on_initiate, GRPC_ERROR_REF(t->closed_with_error));
+ GRPC_CLOSURE_SCHED(on_ack, GRPC_ERROR_REF(t->closed_with_error));
+ return;
+ }
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INITIATE], on_initiate,
GRPC_ERROR_NONE);
- if (grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack,
- GRPC_ERROR_NONE)) {
- grpc_chttp2_initiate_write(exec_ctx, t, initiate_write_reason);
- }
+ grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack,
+ GRPC_ERROR_NONE);
}
-static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+static void retry_initiate_ping_locked(void* tp, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
t->ping_state.is_delayed_ping_timer_set = false;
if (error == GRPC_ERROR_NONE) {
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
}
}
-void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- uint64_t id) {
- grpc_chttp2_ping_queue *pq =
- &t->ping_queues[id % GRPC_CHTTP2_PING_TYPE_COUNT];
+void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id) {
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (pq->inflight_id != id) {
- char *from = grpc_endpoint_get_peer(t->ep);
+ char* from = grpc_endpoint_get_peer(t->ep);
gpr_log(GPR_DEBUG, "Unknown ping response from %s: %" PRIx64, from, id);
gpr_free(from);
return;
}
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
+ GRPC_CLOSURE_LIST_SCHED(&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_CONTINUE_PINGS);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CONTINUE_PINGS);
}
}
-static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
+static void send_goaway(grpc_chttp2_transport* t, grpc_error* error) {
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
grpc_http2_error_code http_error;
grpc_slice slice;
- grpc_error_get_status(error, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL,
- &slice, &http_error);
+ grpc_error_get_status(error, GRPC_MILLIS_INF_FUTURE, nullptr, &slice,
+ &http_error, nullptr);
grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error,
grpc_slice_ref_internal(slice), &t->qbuf);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT);
GRPC_ERROR_UNREF(error);
}
-void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- gpr_log(GPR_DEBUG, "PING strike");
+void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) {
+ t->ping_recv_state.ping_strikes++;
if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes &&
t->ping_policy.max_ping_strikes != 0) {
- send_goaway(exec_ctx, t,
+ send_goaway(t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
/*The transport will be closed after the write is done */
close_transport_locked(
- exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"));
+ t, grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
}
}
-static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
- void *stream_op,
- grpc_error *error_ignored) {
- grpc_transport_op *op = (grpc_transport_op *)stream_op;
- grpc_chttp2_transport *t =
- (grpc_chttp2_transport *)op->handler_private.extra_arg;
- grpc_error *close_transport = op->disconnect_with_error;
+static void perform_transport_op_locked(void* stream_op,
+ grpc_error* error_ignored) {
+ grpc_transport_op* op = (grpc_transport_op*)stream_op;
+ grpc_chttp2_transport* t =
+ (grpc_chttp2_transport*)op->handler_private.extra_arg;
if (op->goaway_error) {
- send_goaway(exec_ctx, t, op->goaway_error);
+ send_goaway(t, op->goaway_error);
}
if (op->set_accept_stream) {
@@ -1815,43 +1740,40 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
}
if (op->bind_pollset) {
- grpc_endpoint_add_to_pollset(exec_ctx, t->ep, op->bind_pollset);
+ grpc_endpoint_add_to_pollset(t->ep, op->bind_pollset);
}
if (op->bind_pollset_set) {
- grpc_endpoint_add_to_pollset_set(exec_ctx, t->ep, op->bind_pollset_set);
+ grpc_endpoint_add_to_pollset_set(t->ep, op->bind_pollset_set);
}
- if (op->send_ping) {
- send_ping_locked(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, NULL,
- op->send_ping,
- GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING);
+ if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
+ send_ping_locked(t, op->send_ping.on_initiate, op->send_ping.on_ack);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING);
}
- if (op->on_connectivity_state_change != NULL) {
+ if (op->on_connectivity_state_change != nullptr) {
grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &t->channel_callback.state_tracker, op->connectivity_state,
+ &t->channel_callback.state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
}
- if (close_transport != GRPC_ERROR_NONE) {
- close_transport_locked(exec_ctx, t, close_transport);
+ if (op->disconnect_with_error != GRPC_ERROR_NONE) {
+ close_transport_locked(t, op->disconnect_with_error);
}
- GRPC_CLOSURE_RUN(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(op->on_consumed, GRPC_ERROR_NONE);
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "transport_op");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "transport_op");
}
-static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_transport_op *op) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- char *msg = grpc_transport_op_string(op);
+static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ char* msg = grpc_transport_op_string(op);
gpr_free(msg);
op->handler_private.extra_arg = gt;
GRPC_CHTTP2_REF_TRANSPORT(t, "transport_op");
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_INIT(&op->handler_private.closure,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&op->handler_private.closure,
perform_transport_op_locked, op,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
@@ -1861,36 +1783,33 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
* INPUT PROCESSING - GENERAL
*/
-void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
- if (s->recv_initial_metadata_ready != NULL &&
+void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ if (s->recv_initial_metadata_ready != nullptr &&
s->published_metadata[0] != GRPC_METADATA_NOT_PUBLISHED) {
if (s->seen_error) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
if (!s->pending_byte_stream) {
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
}
}
- grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &s->metadata_buffer[0], s->recv_initial_metadata);
- null_then_run_closure(exec_ctx, &s->recv_initial_metadata_ready,
- GRPC_ERROR_NONE);
+ grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[0],
+ s->recv_initial_metadata);
+ null_then_run_closure(&s->recv_initial_metadata_ready, GRPC_ERROR_NONE);
}
}
-void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
- grpc_error *error = GRPC_ERROR_NONE;
- if (s->recv_message_ready != NULL) {
- *s->recv_message = NULL;
+void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (s->recv_message_ready != nullptr) {
+ *s->recv_message = nullptr;
if (s->final_metadata_requested && s->seen_error) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
if (!s->pending_byte_stream) {
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
}
}
if (!s->pending_byte_stream) {
@@ -1901,7 +1820,9 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
&s->frame_storage);
s->unprocessed_incoming_frames_decompressed = false;
}
- if (!s->unprocessed_incoming_frames_decompressed) {
+ if (!s->unprocessed_incoming_frames_decompressed &&
+ s->stream_decompression_method !=
+ GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) {
GPR_ASSERT(s->decompressed_data_buffer.length == 0);
bool end_of_context;
if (!s->stream_decompression_ctx) {
@@ -1912,13 +1833,12 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
if (!grpc_stream_decompress(
s->stream_decompression_ctx,
&s->unprocessed_incoming_frames_buffer,
- &s->decompressed_data_buffer, NULL,
+ &s->decompressed_data_buffer, nullptr,
GRPC_HEADER_SIZE_IN_BYTES - s->decompressed_header_bytes,
&end_of_context)) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Stream decompression error.");
} else {
@@ -1927,58 +1847,56 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
s->decompressed_header_bytes = 0;
}
error = grpc_deframe_unprocessed_incoming_frames(
- exec_ctx, &s->data_parser, s, &s->decompressed_data_buffer,
- NULL, s->recv_message);
+ &s->data_parser, s, &s->decompressed_data_buffer, nullptr,
+ s->recv_message);
if (end_of_context) {
grpc_stream_compression_context_destroy(
s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
}
} else {
error = grpc_deframe_unprocessed_incoming_frames(
- exec_ctx, &s->data_parser, s,
- &s->unprocessed_incoming_frames_buffer, NULL, s->recv_message);
+ &s->data_parser, s, &s->unprocessed_incoming_frames_buffer,
+ nullptr, s->recv_message);
}
if (error != GRPC_ERROR_NONE) {
s->seen_error = true;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
break;
- } else if (*s->recv_message != NULL) {
+ } else if (*s->recv_message != nullptr) {
break;
}
}
}
- if (error == GRPC_ERROR_NONE && *s->recv_message != NULL) {
- null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
+ if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) {
+ null_then_run_closure(&s->recv_message_ready, GRPC_ERROR_NONE);
} else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) {
- *s->recv_message = NULL;
- null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
+ *s->recv_message = nullptr;
+ null_then_run_closure(&s->recv_message_ready, GRPC_ERROR_NONE);
}
GRPC_ERROR_UNREF(error);
}
}
-void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
- if (s->recv_trailing_metadata_finished != NULL && s->read_closed &&
+void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ grpc_chttp2_maybe_complete_recv_message(t, s);
+ if (s->recv_trailing_metadata_finished != nullptr && s->read_closed &&
s->write_closed) {
- if (s->seen_error) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ if (s->seen_error || !t->is_client) {
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
if (!s->pending_byte_stream) {
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
}
}
bool pending_data = s->pending_byte_stream ||
s->unprocessed_incoming_frames_buffer.length > 0;
if (s->read_closed && s->frame_storage.length > 0 && !pending_data &&
- !s->seen_error && s->recv_trailing_metadata_finished != NULL) {
+ !s->seen_error && s->recv_trailing_metadata_finished != nullptr) {
/* Maybe some SYNC_FLUSH data is left in frame_storage. Consume them and
* maybe decompress the next 5 bytes in the stream. */
bool end_of_context;
@@ -1986,13 +1904,13 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
s->stream_decompression_ctx = grpc_stream_compression_context_create(
s->stream_decompression_method);
}
- if (!grpc_stream_decompress(s->stream_decompression_ctx,
- &s->frame_storage,
- &s->unprocessed_incoming_frames_buffer, NULL,
- GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ if (!grpc_stream_decompress(
+ s->stream_decompression_ctx, &s->frame_storage,
+ &s->unprocessed_incoming_frames_buffer, nullptr,
+ GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) {
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
s->seen_error = true;
} else {
if (s->unprocessed_incoming_frames_buffer.length > 0) {
@@ -2001,39 +1919,39 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
}
if (end_of_context) {
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
}
}
if (s->read_closed && s->frame_storage.length == 0 && !pending_data &&
- s->recv_trailing_metadata_finished != NULL) {
- grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &s->metadata_buffer[1], s->recv_trailing_metadata);
+ s->recv_trailing_metadata_finished != nullptr) {
+ grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[1],
+ s->recv_trailing_metadata);
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->recv_trailing_metadata_finished, GRPC_ERROR_NONE,
+ t, s, &s->recv_trailing_metadata_finished, GRPC_ERROR_NONE,
"recv_trailing_metadata_finished");
}
}
}
-static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- uint32_t id, grpc_error *error) {
- grpc_chttp2_stream *s =
- (grpc_chttp2_stream *)grpc_chttp2_stream_map_delete(&t->stream_map, id);
+static void remove_stream(grpc_chttp2_transport* t, uint32_t id,
+ grpc_error* error) {
+ grpc_chttp2_stream* s =
+ (grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
GPR_ASSERT(s);
if (t->incoming_stream == s) {
- t->incoming_stream = NULL;
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ t->incoming_stream = nullptr;
+ grpc_chttp2_parsing_become_skip_parser(t);
}
if (s->pending_byte_stream) {
- if (s->on_next != NULL) {
- grpc_chttp2_incoming_byte_stream *bs = s->data_parser.parsing_frame;
+ if (s->on_next != nullptr) {
+ grpc_chttp2_incoming_byte_stream* bs = s->data_parser.parsing_frame;
if (error == GRPC_ERROR_NONE) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
}
- incoming_byte_stream_publish_error(exec_ctx, bs, error);
- incoming_byte_stream_unref(exec_ctx, bs);
- s->data_parser.parsing_frame = NULL;
+ incoming_byte_stream_publish_error(bs, error);
+ incoming_byte_stream_unref(bs);
+ s->data_parser.parsing_frame = nullptr;
} else {
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_REF(error);
@@ -2041,55 +1959,52 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
}
if (grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
- post_benign_reclaimer(exec_ctx, t);
+ post_benign_reclaimer(t);
if (t->sent_goaway_state == GRPC_CHTTP2_GOAWAY_SENT) {
close_transport_locked(
- exec_ctx, t,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Last stream closed after sending GOAWAY", &error, 1));
+ t, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Last stream closed after sending GOAWAY", &error, 1));
}
}
if (grpc_chttp2_list_remove_writable_stream(t, s)) {
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:remove_stream");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:remove_stream");
}
GRPC_ERROR_UNREF(error);
- maybe_start_some_streams(exec_ctx, t);
+ maybe_start_some_streams(t);
}
-void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- grpc_error *due_to_error) {
+void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* due_to_error) {
if (!t->is_client && !s->sent_trailing_metadata &&
grpc_error_has_clear_grpc_status(due_to_error)) {
- close_from_api(exec_ctx, t, s, due_to_error);
+ close_from_api(t, s, due_to_error);
return;
}
if (!s->read_closed || !s->write_closed) {
if (s->id != 0) {
grpc_http2_error_code http_error;
- grpc_error_get_status(due_to_error, s->deadline, NULL, NULL, &http_error);
+ grpc_error_get_status(due_to_error, s->deadline, nullptr, nullptr,
+ &http_error, nullptr);
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error,
&s->stats.outgoing));
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM);
}
}
if (due_to_error != GRPC_ERROR_NONE && !s->seen_error) {
s->seen_error = true;
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, 1, 1, due_to_error);
+ grpc_chttp2_mark_stream_closed(t, s, 1, 1, due_to_error);
}
-void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error) {
+void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* error) {
grpc_status_code status;
grpc_slice slice;
- grpc_error_get_status(error, s->deadline, &status, &slice, NULL);
-
+ grpc_error_get_status(error, s->deadline, &status, &slice, nullptr, nullptr);
if (status != GRPC_STATUS_OK) {
s->seen_error = true;
}
@@ -2100,31 +2015,31 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
what we want - which is safe because we haven't told anyone
about the metadata yet */
if (s->published_metadata[1] == GRPC_METADATA_NOT_PUBLISHED ||
- s->recv_trailing_metadata_finished != NULL) {
+ s->recv_trailing_metadata_finished != nullptr) {
char status_string[GPR_LTOA_MIN_BUFSIZE];
gpr_ltoa(status, status_string);
GRPC_LOG_IF_ERROR("add_status",
grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- exec_ctx, &s->metadata_buffer[1],
+ &s->metadata_buffer[1],
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_STATUS,
+ GRPC_MDSTR_GRPC_STATUS,
grpc_slice_from_copied_string(status_string))));
if (!GRPC_SLICE_IS_EMPTY(slice)) {
GRPC_LOG_IF_ERROR(
"add_status_message",
grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- exec_ctx, &s->metadata_buffer[1],
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
+ &s->metadata_buffer[1],
+ grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_MESSAGE,
grpc_slice_ref_internal(slice))));
}
s->published_metadata[1] = GRPC_METADATA_SYNTHESIZED_FROM_FAKE;
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
}
GRPC_ERROR_UNREF(error);
}
-static void add_error(grpc_error *error, grpc_error **refs, size_t *nrefs) {
+static void add_error(grpc_error* error, grpc_error** refs, size_t* nrefs) {
if (error == GRPC_ERROR_NONE) return;
for (size_t i = 0; i < *nrefs; i++) {
if (error == refs[i]) {
@@ -2135,14 +2050,14 @@ static void add_error(grpc_error *error, grpc_error **refs, size_t *nrefs) {
++*nrefs;
}
-static grpc_error *removal_error(grpc_error *extra_error, grpc_chttp2_stream *s,
- const char *master_error_msg) {
- grpc_error *refs[3];
+static grpc_error* removal_error(grpc_error* extra_error, grpc_chttp2_stream* s,
+ const char* master_error_msg) {
+ grpc_error* refs[3];
size_t nrefs = 0;
add_error(s->read_closed_error, refs, &nrefs);
add_error(s->write_closed_error, refs, &nrefs);
add_error(extra_error, refs, &nrefs);
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (nrefs > 0) {
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(master_error_msg,
refs, nrefs);
@@ -2151,14 +2066,12 @@ static grpc_error *removal_error(grpc_error *extra_error, grpc_chttp2_stream *s,
return error;
}
-static void flush_write_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_chttp2_write_cb **list,
- grpc_error *error) {
+static void flush_write_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_chttp2_write_cb** list, grpc_error* error) {
while (*list) {
- grpc_chttp2_write_cb *cb = *list;
+ grpc_chttp2_write_cb* cb = *list;
*list = cb->next;
- grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure,
- GRPC_ERROR_REF(error),
+ grpc_chttp2_complete_closure_step(t, s, &cb->closure, GRPC_ERROR_REF(error),
"on_write_finished_cb");
cb->next = t->write_cb_pool;
t->write_cb_pool = cb;
@@ -2166,37 +2079,34 @@ static void flush_write_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
-void grpc_chttp2_fail_pending_writes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error) {
+void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error) {
error =
removal_error(error, s, "Pending writes failed due to stream closure");
- s->send_initial_metadata = NULL;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_initial_metadata_finished, GRPC_ERROR_REF(error),
- "send_initial_metadata_finished");
-
- s->send_trailing_metadata = NULL;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_trailing_metadata_finished,
- GRPC_ERROR_REF(error), "send_trailing_metadata_finished");
-
- s->fetching_send_message = NULL;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_REF(error),
- "fetching_send_message_finished");
- flush_write_list(exec_ctx, t, s, &s->on_write_finished_cbs,
- GRPC_ERROR_REF(error));
- flush_write_list(exec_ctx, t, s, &s->on_flow_controlled_cbs, error);
-}
-
-void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, int close_reads,
- int close_writes, grpc_error *error) {
+ s->send_initial_metadata = nullptr;
+ grpc_chttp2_complete_closure_step(t, s, &s->send_initial_metadata_finished,
+ GRPC_ERROR_REF(error),
+ "send_initial_metadata_finished");
+
+ s->send_trailing_metadata = nullptr;
+ grpc_chttp2_complete_closure_step(t, s, &s->send_trailing_metadata_finished,
+ GRPC_ERROR_REF(error),
+ "send_trailing_metadata_finished");
+
+ s->fetching_send_message = nullptr;
+ grpc_chttp2_complete_closure_step(t, s, &s->fetching_send_message_finished,
+ GRPC_ERROR_REF(error),
+ "fetching_send_message_finished");
+ flush_write_list(t, s, &s->on_write_finished_cbs, GRPC_ERROR_REF(error));
+ flush_write_list(t, s, &s->on_flow_controlled_cbs, error);
+}
+
+void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, int close_reads,
+ int close_writes, grpc_error* error) {
if (s->read_closed && s->write_closed) {
/* already closed */
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
GRPC_ERROR_UNREF(error);
return;
}
@@ -2210,20 +2120,20 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
if (close_writes && !s->write_closed) {
s->write_closed_error = GRPC_ERROR_REF(error);
s->write_closed = true;
- grpc_chttp2_fail_pending_writes(exec_ctx, t, s, GRPC_ERROR_REF(error));
+ grpc_chttp2_fail_pending_writes(t, s, GRPC_ERROR_REF(error));
}
if (s->read_closed && s->write_closed) {
became_closed = true;
- grpc_error *overall_error =
+ grpc_error* overall_error =
removal_error(GRPC_ERROR_REF(error), s, "Stream removed");
if (s->id != 0) {
- remove_stream(exec_ctx, t, s->id, GRPC_ERROR_REF(overall_error));
+ remove_stream(t, s->id, GRPC_ERROR_REF(overall_error));
} else {
/* Purge streams waiting on concurrency still waiting for id assignment */
grpc_chttp2_list_remove_waiting_for_concurrency(t, s);
}
if (overall_error != GRPC_ERROR_NONE) {
- grpc_chttp2_fake_status(exec_ctx, t, s, overall_error);
+ grpc_chttp2_fake_status(t, s, overall_error);
}
}
if (closed_read) {
@@ -2232,28 +2142,29 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
s->published_metadata[i] = GPRC_METADATA_PUBLISHED_AT_CLOSE;
}
}
- grpc_chttp2_maybe_complete_recv_initial_metadata(exec_ctx, t, s);
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_initial_metadata(t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
}
if (became_closed) {
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2");
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2");
}
GRPC_ERROR_UNREF(error);
}
-static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error) {
+static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* error) {
grpc_slice hdr;
grpc_slice status_hdr;
grpc_slice http_status_hdr;
grpc_slice content_type_hdr;
grpc_slice message_pfx;
- uint8_t *p;
+ uint8_t* p;
uint32_t len = 0;
grpc_status_code grpc_status;
grpc_slice slice;
- grpc_error_get_status(error, s->deadline, &grpc_status, &slice, NULL);
+ grpc_error_get_status(error, s->deadline, &grpc_status, &slice, nullptr,
+ nullptr);
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100);
@@ -2395,27 +2306,23 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR,
&s->stats.outgoing));
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, 1, 1, error);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API);
+ grpc_chttp2_mark_stream_closed(t, s, 1, 1, error);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API);
}
typedef struct {
- grpc_exec_ctx *exec_ctx;
- grpc_error *error;
- grpc_chttp2_transport *t;
+ grpc_error* error;
+ grpc_chttp2_transport* t;
} cancel_stream_cb_args;
-static void cancel_stream_cb(void *user_data, uint32_t key, void *stream) {
- cancel_stream_cb_args *args = (cancel_stream_cb_args *)user_data;
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)stream;
- grpc_chttp2_cancel_stream(args->exec_ctx, args->t, s,
- GRPC_ERROR_REF(args->error));
+static void cancel_stream_cb(void* user_data, uint32_t key, void* stream) {
+ cancel_stream_cb_args* args = (cancel_stream_cb_args*)user_data;
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)stream;
+ grpc_chttp2_cancel_stream(args->t, s, GRPC_ERROR_REF(args->error));
}
-static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
- cancel_stream_cb_args args = {exec_ctx, error, t};
+static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error) {
+ cancel_stream_cb_args args = {error, t};
grpc_chttp2_stream_map_for_each(&t->stream_map, cancel_stream_cb, &args);
GRPC_ERROR_UNREF(error);
}
@@ -2424,73 +2331,56 @@ static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
* INPUT PROCESSING - PARSING
*/
-void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_flowctl_action action,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
- switch (action.send_stream_update) {
- case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED:
- break;
- case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY:
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
- grpc_chttp2_initiate_write(
- exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL);
+template <class F>
+static void WithUrgency(grpc_chttp2_transport* t,
+ grpc_core::chttp2::FlowControlAction::Urgency urgency,
+ grpc_chttp2_initiate_write_reason reason, F action) {
+ switch (urgency) {
+ case grpc_core::chttp2::FlowControlAction::Urgency::NO_ACTION_NEEDED:
break;
- case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE:
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ case grpc_core::chttp2::FlowControlAction::Urgency::UPDATE_IMMEDIATELY:
+ grpc_chttp2_initiate_write(t, reason);
+ // fallthrough
+ case grpc_core::chttp2::FlowControlAction::Urgency::QUEUE_UPDATE:
+ action();
break;
}
- switch (action.send_transport_update) {
- case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED:
- break;
- case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY:
- grpc_chttp2_initiate_write(
- exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL);
- break;
- // this is the same as no action b/c every time the transport enters the
- // writing path it will maybe do an update
- case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE:
- break;
- }
- if (action.send_setting_update != GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED) {
- if (action.initial_window_size > 0) {
- queue_setting_update(exec_ctx, t,
- GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
- (uint32_t)action.initial_window_size);
- }
- if (action.max_frame_size > 0) {
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
- (uint32_t)action.max_frame_size);
- }
- if (action.send_setting_update == GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY) {
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS);
- }
- }
- if (action.need_ping) {
- GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
- grpc_bdp_estimator_schedule_ping(&t->flow_control.bdp_estimator);
- send_ping_locked(exec_ctx, t,
- GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE,
- &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked,
- GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING);
- }
}
-static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+void grpc_chttp2_act_on_flowctl_action(
+ const grpc_core::chttp2::FlowControlAction& action,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s) {
+ WithUrgency(t, action.send_stream_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL,
+ [t, s]() { grpc_chttp2_mark_stream_writable(t, s); });
+ WithUrgency(t, action.send_transport_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL, []() {});
+ WithUrgency(t, action.send_initial_window_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, [t, &action]() {
+ queue_setting_update(t,
+ GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
+ action.initial_window_size());
+ });
+ WithUrgency(t, action.send_max_frame_size_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, [t, &action]() {
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
+ action.max_frame_size());
+ });
+}
+
+static grpc_error* try_http_parsing(grpc_chttp2_transport* t) {
grpc_http_parser parser;
size_t i = 0;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
- grpc_error *parse_error = GRPC_ERROR_NONE;
+ grpc_error* parse_error = GRPC_ERROR_NONE;
for (; i < t->read_buffer.count && parse_error == GRPC_ERROR_NONE; i++) {
parse_error =
- grpc_http_parser_parse(&parser, t->read_buffer.slices[i], NULL);
+ grpc_http_parser_parse(&parser, t->read_buffer.slices[i], nullptr);
}
if (parse_error == GRPC_ERROR_NONE &&
(parse_error = grpc_http_parser_eof(&parser)) == GRPC_ERROR_NONE) {
@@ -2507,37 +2397,37 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx,
return error;
}
-static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
+static void read_action_locked(void* tp, grpc_error* error) {
GPR_TIMER_BEGIN("reading_action_locked", 0);
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
GRPC_ERROR_REF(error);
- grpc_error *err = error;
+ grpc_error* err = error;
if (err != GRPC_ERROR_NONE) {
err = grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint read failed", &err, 1),
GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
t->write_state);
}
- GPR_SWAP(grpc_error *, err, error);
+ GPR_SWAP(grpc_error*, err, error);
GRPC_ERROR_UNREF(err);
- if (!t->closed) {
+ if (t->closed_with_error == GRPC_ERROR_NONE) {
GPR_TIMER_BEGIN("reading_action.parse", 0);
size_t i = 0;
- grpc_error *errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
+ grpc_error* errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
GRPC_ERROR_NONE};
for (; i < t->read_buffer.count && errors[1] == GRPC_ERROR_NONE; i++) {
- grpc_bdp_estimator_add_incoming_bytes(
- &t->flow_control.bdp_estimator,
- (int64_t)GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
- errors[1] =
- grpc_chttp2_perform_read(exec_ctx, t, t->read_buffer.slices[i]);
+ grpc_core::BdpEstimator* bdp_est = t->flow_control->bdp_estimator();
+ if (bdp_est) {
+ bdp_est->AddIncomingBytes(
+ (int64_t)GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
+ }
+ errors[1] = grpc_chttp2_perform_read(t, t->read_buffer.slices[i]);
}
if (errors[1] != GRPC_ERROR_NONE) {
- errors[2] = try_http_parsing(exec_ctx, t);
+ errors[2] = try_http_parsing(t);
GRPC_ERROR_UNREF(error);
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed parsing HTTP/2", errors, GPR_ARRAY_SIZE(errors));
@@ -2548,44 +2438,48 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
GPR_TIMER_END("reading_action.parse", 0);
GPR_TIMER_BEGIN("post_parse_locked", 0);
- if (t->flow_control.initial_window_update != 0) {
- if (t->flow_control.initial_window_update > 0) {
- grpc_chttp2_stream *s;
+ if (t->initial_window_update != 0) {
+ if (t->initial_window_update > 0) {
+ grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) {
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
- exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING);
+ t, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING);
}
}
- t->flow_control.initial_window_update = 0;
+ t->initial_window_update = 0;
}
GPR_TIMER_END("post_parse_locked", 0);
}
GPR_TIMER_BEGIN("post_reading_action_locked", 0);
bool keep_reading = false;
- if (error == GRPC_ERROR_NONE && t->closed) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed");
+ if (error == GRPC_ERROR_NONE && t->closed_with_error != GRPC_ERROR_NONE) {
+ error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Transport closed", &t->closed_with_error, 1);
}
if (error != GRPC_ERROR_NONE) {
- close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
+ /* If a goaway frame was received, this might be the reason why the read
+ * failed. Add this info to the error */
+ if (t->goaway_error != GRPC_ERROR_NONE) {
+ error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error));
+ }
+
+ close_transport_locked(t, GRPC_ERROR_REF(error));
t->endpoint_reading = 0;
- } else if (!t->closed) {
+ } else if (t->closed_with_error == GRPC_ERROR_NONE) {
keep_reading = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "keep_reading");
}
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &t->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&t->read_buffer);
if (keep_reading) {
- grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
- &t->read_action_locked);
- grpc_chttp2_act_on_flowctl_action(
- exec_ctx, grpc_chttp2_flowctl_get_bdp_action(&t->flow_control), t,
- NULL);
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
+ grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked);
+ grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t,
+ nullptr);
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "keep_reading");
} else {
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action");
}
GPR_TIMER_END("post_reading_action_locked", 0);
@@ -2595,40 +2489,66 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
GPR_TIMER_END("reading_action_locked", 0);
}
-static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- gpr_log(GPR_DEBUG, "%s: Start BDP ping", t->peer_string);
+// t is reffed prior to calling the first time, and once the callback chain
+// that kicks off finishes, it's unreffed
+static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
+ t->flow_control->bdp_estimator()->SchedulePing();
+ send_ping_locked(t, &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked);
+}
+
+static void start_bdp_ping_locked(void* tp, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ if (grpc_http_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string,
+ grpc_error_string(error));
}
/* Reset the keepalive ping timer */
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
- grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
+ grpc_timer_cancel(&t->keepalive_ping_timer);
}
- grpc_bdp_estimator_start_ping(&t->flow_control.bdp_estimator);
+ t->flow_control->bdp_estimator()->StartPing();
}
-static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string);
+static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ if (grpc_http_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string,
+ grpc_error_string(error));
}
- grpc_bdp_estimator_complete_ping(&t->flow_control.bdp_estimator);
+ if (error != GRPC_ERROR_NONE) {
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
+ return;
+ }
+ grpc_millis next_ping = t->flow_control->bdp_estimator()->CompletePing();
+ grpc_chttp2_act_on_flowctl_action(t->flow_control->PeriodicUpdate(), t,
+ nullptr);
+ GPR_ASSERT(!t->have_next_bdp_ping_timer);
+ t->have_next_bdp_ping_timer = true;
+ grpc_timer_init(&t->next_bdp_ping_timer, next_ping,
+ &t->next_bdp_ping_timer_expired_locked);
+}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping");
+static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ GPR_ASSERT(t->have_next_bdp_ping_timer);
+ t->have_next_bdp_ping_timer = false;
+ if (error != GRPC_ERROR_NONE) {
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
+ return;
+ }
+ schedule_bdp_ping_locked(t);
}
-void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
+void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client) {
size_t i;
if (args) {
for (i = 0; i < args->num_args; i++) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_MS)) {
const int value = grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){g_default_client_keepalive_time_ms, 1,
- INT_MAX});
+ &args->args[i], {is_client ? g_default_client_keepalive_time_ms
+ : g_default_server_keepalive_time_ms,
+ 1, INT_MAX});
if (is_client) {
g_default_client_keepalive_time_ms = value;
} else {
@@ -2637,9 +2557,9 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
} else if (0 ==
strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
const int value = grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){g_default_client_keepalive_timeout_ms, 0,
- INT_MAX});
+ &args->args[i], {is_client ? g_default_client_keepalive_timeout_ms
+ : g_default_server_keepalive_timeout_ms,
+ 0, INT_MAX});
if (is_client) {
g_default_client_keepalive_timeout_ms = value;
} else {
@@ -2647,21 +2567,24 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
}
} else if (0 == strcmp(args->args[i].key,
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
- g_default_keepalive_permit_without_calls =
- (uint32_t)grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){g_default_keepalive_permit_without_calls,
- 0, 1});
+ const bool value = (uint32_t)grpc_channel_arg_get_integer(
+ &args->args[i],
+ {is_client ? g_default_client_keepalive_permit_without_calls
+ : g_default_server_keepalive_timeout_ms,
+ 0, 1});
+ if (is_client) {
+ g_default_client_keepalive_permit_without_calls = value;
+ } else {
+ g_default_server_keepalive_permit_without_calls = value;
+ }
} else if (0 ==
strcmp(args->args[i].key, GRPC_ARG_HTTP2_MAX_PING_STRIKES)) {
g_default_max_ping_strikes = grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){g_default_max_ping_strikes, 0, INT_MAX});
+ &args->args[i], {g_default_max_ping_strikes, 0, INT_MAX});
} else if (0 == strcmp(args->args[i].key,
GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) {
g_default_max_pings_without_data = grpc_channel_arg_get_integer(
- &args->args[i], (grpc_integer_options){
- g_default_max_pings_without_data, 0, INT_MAX});
+ &args->args[i], {g_default_max_pings_without_data, 0, INT_MAX});
} else if (0 ==
strcmp(
args->args[i].key,
@@ -2669,9 +2592,7 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
g_default_min_sent_ping_interval_without_data_ms =
grpc_channel_arg_get_integer(
&args->args[i],
- (grpc_integer_options){
- g_default_min_sent_ping_interval_without_data_ms, 0,
- INT_MAX});
+ {g_default_min_sent_ping_interval_without_data_ms, 0, INT_MAX});
} else if (0 ==
strcmp(
args->args[i].key,
@@ -2679,82 +2600,74 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
g_default_min_recv_ping_interval_without_data_ms =
grpc_channel_arg_get_integer(
&args->args[i],
- (grpc_integer_options){
- g_default_min_recv_ping_interval_without_data_ms, 0,
- INT_MAX});
+ {g_default_min_recv_ping_interval_without_data_ms, 0, INT_MAX});
}
}
}
}
-static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
- if (t->destroying || t->closed) {
+ if (t->destroying || t->closed_with_error != GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
} else if (error == GRPC_ERROR_NONE) {
if (t->keepalive_permit_without_calls ||
grpc_chttp2_stream_map_size(&t->stream_map) > 0) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive ping end");
- send_ping_locked(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE,
- &t->start_keepalive_ping_locked,
- &t->finish_keepalive_ping_locked,
- GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING);
+ send_ping_locked(t, &t->start_keepalive_ping_locked,
+ &t->finish_keepalive_ping_locked);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING);
} else {
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(
- exec_ctx, &t->keepalive_ping_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time),
- &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
+ &t->init_keepalive_ping_locked);
}
} else if (error == GRPC_ERROR_CANCELLED) {
/* The keepalive ping timer may be cancelled by bdp */
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(
- exec_ctx, &t->keepalive_ping_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time),
- &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
+ &t->init_keepalive_ping_locked);
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "init keepalive ping");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping");
}
-static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
- grpc_timer_init(
- exec_ctx, &t->keepalive_watchdog_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_timeout),
- &t->keepalive_watchdog_fired_locked, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&t->keepalive_watchdog_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
+ &t->keepalive_watchdog_fired_locked);
}
-static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
- grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer);
+ grpc_timer_cancel(&t->keepalive_watchdog_timer);
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(
- exec_ctx, &t->keepalive_ping_timer,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time),
- &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
+ &t->init_keepalive_ping_locked);
}
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive ping end");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive ping end");
}
-static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
- close_transport_locked(exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "keepalive watchdog timeout"));
+ close_transport_locked(
+ t,
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "keepalive watchdog timeout"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL));
}
} else {
/* The watchdog timer should have been cancelled by
@@ -2764,109 +2677,101 @@ static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
t->keepalive_state, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING);
}
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive watchdog");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive watchdog");
}
/*******************************************************************************
* CALLBACK LOOP
*/
-static void connectivity_state_set(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static void connectivity_state_set(grpc_chttp2_transport* t,
grpc_connectivity_state state,
- grpc_error *error, const char *reason) {
+ grpc_error* error, const char* reason) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_DEBUG, "set connectivity_state=%d", state));
- grpc_connectivity_state_set(exec_ctx, &t->channel_callback.state_tracker,
- state, error, reason);
+ grpc_connectivity_state_set(&t->channel_callback.state_tracker, state, error,
+ reason);
}
/*******************************************************************************
* POLLSET STUFF
*/
-static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset *pollset) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_endpoint_add_to_pollset(exec_ctx, t->ep, pollset);
+static void set_pollset(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset* pollset) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_endpoint_add_to_pollset(t->ep, pollset);
}
-static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset_set *pollset_set) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
- grpc_endpoint_add_to_pollset_set(exec_ctx, t->ep, pollset_set);
+static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset_set* pollset_set) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
+ grpc_endpoint_add_to_pollset_set(t->ep, pollset_set);
}
/*******************************************************************************
* BYTE STREAM
*/
-static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)arg;
+static void reset_byte_stream(void* arg, grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)arg;
s->pending_byte_stream = false;
if (error == GRPC_ERROR_NONE) {
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, s->t, s);
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, s->t, s);
+ grpc_chttp2_maybe_complete_recv_message(s->t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(s->t, s);
} else {
GPR_ASSERT(error != GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
- s->on_next = NULL;
+ GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_REF(error));
+ s->on_next = nullptr;
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_NONE;
- grpc_chttp2_cancel_stream(exec_ctx, s->t, s, GRPC_ERROR_REF(error));
+ grpc_chttp2_cancel_stream(s->t, s, GRPC_ERROR_REF(error));
s->byte_stream_error = GRPC_ERROR_REF(error);
}
}
-static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_incoming_byte_stream *bs) {
+static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs) {
if (gpr_unref(&bs->refs)) {
gpr_free(bs);
}
}
-static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
- void *argp,
- grpc_error *error_ignored) {
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)argp;
- grpc_chttp2_transport *t = bs->transport;
- grpc_chttp2_stream *s = bs->stream;
+static void incoming_byte_stream_next_locked(void* argp,
+ grpc_error* error_ignored) {
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)argp;
+ grpc_chttp2_transport* t = bs->transport;
+ grpc_chttp2_stream* s = bs->stream;
size_t cur_length = s->frame_storage.length;
if (!s->read_closed) {
- grpc_chttp2_flowctl_incoming_bs_update(&t->flow_control, &s->flow_control,
- bs->next_action.max_size_hint,
- cur_length);
- grpc_chttp2_act_on_flowctl_action(
- exec_ctx,
- grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control), t,
- s);
+ s->flow_control->IncomingByteStreamUpdate(bs->next_action.max_size_hint,
+ cur_length);
+ grpc_chttp2_act_on_flowctl_action(s->flow_control->MakeAction(), t, s);
}
GPR_ASSERT(s->unprocessed_incoming_frames_buffer.length == 0);
if (s->frame_storage.length > 0) {
grpc_slice_buffer_swap(&s->frame_storage,
&s->unprocessed_incoming_frames_buffer);
s->unprocessed_incoming_frames_decompressed = false;
- GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(bs->next_action.on_complete, GRPC_ERROR_NONE);
} else if (s->byte_stream_error != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
+ GRPC_CLOSURE_SCHED(bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
- if (s->data_parser.parsing_frame != NULL) {
- incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
- s->data_parser.parsing_frame = NULL;
+ if (s->data_parser.parsing_frame != nullptr) {
+ incoming_byte_stream_unref(s->data_parser.parsing_frame);
+ s->data_parser.parsing_frame = nullptr;
}
} else if (s->read_closed) {
if (bs->remaining_bytes != 0) {
s->byte_stream_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
- GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
+ GRPC_CLOSURE_SCHED(bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
- if (s->data_parser.parsing_frame != NULL) {
- incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
- s->data_parser.parsing_frame = NULL;
+ if (s->data_parser.parsing_frame != nullptr) {
+ incoming_byte_stream_unref(s->data_parser.parsing_frame);
+ s->data_parser.parsing_frame = nullptr;
}
} else {
/* Should never reach here. */
@@ -2875,17 +2780,16 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
} else {
s->on_next = bs->next_action.on_complete;
}
- incoming_byte_stream_unref(exec_ctx, bs);
+ incoming_byte_stream_unref(bs);
}
-static bool incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
+static bool incoming_byte_stream_next(grpc_byte_stream* byte_stream,
size_t max_size_hint,
- grpc_closure *on_complete) {
+ grpc_closure* on_complete) {
GPR_TIMER_BEGIN("incoming_byte_stream_next", 0);
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
- grpc_chttp2_stream *s = bs->stream;
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
+ grpc_chttp2_stream* s = bs->stream;
if (s->unprocessed_incoming_frames_buffer.length > 0) {
GPR_TIMER_END("incoming_byte_stream_next", 0);
return true;
@@ -2894,7 +2798,6 @@ static bool incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
bs->next_action.max_size_hint = max_size_hint;
bs->next_action.on_complete = on_complete;
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&bs->next_action.closure,
incoming_byte_stream_next_locked, bs,
grpc_combiner_scheduler(bs->transport->combiner)),
@@ -2904,14 +2807,13 @@ static bool incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
}
}
-static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_slice *slice) {
+static grpc_error* incoming_byte_stream_pull(grpc_byte_stream* byte_stream,
+ grpc_slice* slice) {
GPR_TIMER_BEGIN("incoming_byte_stream_pull", 0);
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
- grpc_chttp2_stream *s = bs->stream;
- grpc_error *error;
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
+ grpc_chttp2_stream* s = bs->stream;
+ grpc_error* error;
if (s->unprocessed_incoming_frames_buffer.length > 0) {
if (!s->unprocessed_incoming_frames_decompressed) {
@@ -2922,7 +2824,7 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
}
if (!grpc_stream_decompress(s->stream_decompression_ctx,
&s->unprocessed_incoming_frames_buffer,
- &s->decompressed_data_buffer, NULL,
+ &s->decompressed_data_buffer, nullptr,
MAX_SIZE_T, &end_of_context)) {
error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream decompression error.");
@@ -2934,83 +2836,79 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
s->unprocessed_incoming_frames_decompressed = true;
if (end_of_context) {
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
- s->stream_decompression_ctx = NULL;
+ s->stream_decompression_ctx = nullptr;
}
if (s->unprocessed_incoming_frames_buffer.length == 0) {
*slice = grpc_empty_slice();
}
}
error = grpc_deframe_unprocessed_incoming_frames(
- exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer,
- slice, NULL);
+ &s->data_parser, s, &s->unprocessed_incoming_frames_buffer, slice,
+ nullptr);
if (error != GRPC_ERROR_NONE) {
return error;
}
} else {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
- GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error));
return error;
}
GPR_TIMER_END("incoming_byte_stream_pull", 0);
return GRPC_ERROR_NONE;
}
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
- void *byte_stream,
- grpc_error *error_ignored);
+static void incoming_byte_stream_destroy_locked(void* byte_stream,
+ grpc_error* error_ignored);
-static void incoming_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream) {
+static void incoming_byte_stream_destroy(grpc_byte_stream* byte_stream) {
GPR_TIMER_BEGIN("incoming_byte_stream_destroy", 0);
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
GRPC_CLOSURE_SCHED(
- exec_ctx, GRPC_CLOSURE_INIT(
- &bs->destroy_action, incoming_byte_stream_destroy_locked,
- bs, grpc_combiner_scheduler(bs->transport->combiner)),
+ GRPC_CLOSURE_INIT(&bs->destroy_action,
+ incoming_byte_stream_destroy_locked, bs,
+ grpc_combiner_scheduler(bs->transport->combiner)),
GRPC_ERROR_NONE);
GPR_TIMER_END("incoming_byte_stream_destroy", 0);
}
static void incoming_byte_stream_publish_error(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error) {
- grpc_chttp2_stream *s = bs->stream;
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error) {
+ grpc_chttp2_stream* s = bs->stream;
GPR_ASSERT(error != GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
- s->on_next = NULL;
+ GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_REF(error));
+ s->on_next = nullptr;
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_REF(error);
- grpc_chttp2_cancel_stream(exec_ctx, bs->transport, bs->stream,
- GRPC_ERROR_REF(error));
+ grpc_chttp2_cancel_stream(bs->transport, bs->stream, GRPC_ERROR_REF(error));
}
-grpc_error *grpc_chttp2_incoming_byte_stream_push(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_slice slice, grpc_slice *slice_out) {
- grpc_chttp2_stream *s = bs->stream;
+grpc_error* grpc_chttp2_incoming_byte_stream_push(
+ grpc_chttp2_incoming_byte_stream* bs, grpc_slice slice,
+ grpc_slice* slice_out) {
+ grpc_chttp2_stream* s = bs->stream;
if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) {
- grpc_error *error =
+ grpc_error* error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream");
- GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
- grpc_slice_unref_internal(exec_ctx, slice);
+ GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error));
+ grpc_slice_unref_internal(slice);
return error;
} else {
bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice);
- if (slice_out != NULL) {
+ if (slice_out != nullptr) {
*slice_out = slice;
}
return GRPC_ERROR_NONE;
}
}
-grpc_error *grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error, bool reset_on_error) {
- grpc_chttp2_stream *s = bs->stream;
+grpc_error* grpc_chttp2_incoming_byte_stream_finished(
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error,
+ bool reset_on_error) {
+ grpc_chttp2_stream* s = bs->stream;
if (error == GRPC_ERROR_NONE) {
if (bs->remaining_bytes != 0) {
@@ -3018,45 +2916,43 @@ grpc_error *grpc_chttp2_incoming_byte_stream_finished(
}
}
if (error != GRPC_ERROR_NONE && reset_on_error) {
- GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error));
}
- incoming_byte_stream_unref(exec_ctx, bs);
+ incoming_byte_stream_unref(bs);
return error;
}
-static void incoming_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_error *error) {
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
+static void incoming_byte_stream_shutdown(grpc_byte_stream* byte_stream,
+ grpc_error* error) {
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, bs, error, true /* reset_on_error */));
+ bs, error, true /* reset_on_error */));
}
static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = {
incoming_byte_stream_next, incoming_byte_stream_pull,
incoming_byte_stream_shutdown, incoming_byte_stream_destroy};
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
- void *byte_stream,
- grpc_error *error_ignored) {
- grpc_chttp2_incoming_byte_stream *bs =
- (grpc_chttp2_incoming_byte_stream *)byte_stream;
- grpc_chttp2_stream *s = bs->stream;
- grpc_chttp2_transport *t = s->t;
+static void incoming_byte_stream_destroy_locked(void* byte_stream,
+ grpc_error* error_ignored) {
+ grpc_chttp2_incoming_byte_stream* bs =
+ (grpc_chttp2_incoming_byte_stream*)byte_stream;
+ grpc_chttp2_stream* s = bs->stream;
+ grpc_chttp2_transport* t = s->t;
GPR_ASSERT(bs->base.vtable == &grpc_chttp2_incoming_byte_stream_vtable);
- incoming_byte_stream_unref(exec_ctx, bs);
+ incoming_byte_stream_unref(bs);
s->pending_byte_stream = false;
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
}
-grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- uint32_t frame_size, uint32_t flags) {
- grpc_chttp2_incoming_byte_stream *incoming_byte_stream =
- (grpc_chttp2_incoming_byte_stream *)gpr_malloc(
+grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size,
+ uint32_t flags) {
+ grpc_chttp2_incoming_byte_stream* incoming_byte_stream =
+ (grpc_chttp2_incoming_byte_stream*)gpr_malloc(
sizeof(*incoming_byte_stream));
incoming_byte_stream->base.length = frame_size;
incoming_byte_stream->remaining_bytes = frame_size;
@@ -3074,45 +2970,39 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
* RESOURCE QUOTAS
*/
-static void post_benign_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void post_benign_reclaimer(grpc_chttp2_transport* t) {
if (!t->benign_reclaimer_registered) {
t->benign_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "benign_reclaimer");
- grpc_resource_user_post_reclaimer(exec_ctx,
- grpc_endpoint_get_resource_user(t->ep),
+ grpc_resource_user_post_reclaimer(grpc_endpoint_get_resource_user(t->ep),
false, &t->benign_reclaimer_locked);
}
}
-static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static void post_destructive_reclaimer(grpc_chttp2_transport* t) {
if (!t->destructive_reclaimer_registered) {
t->destructive_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "destructive_reclaimer");
- grpc_resource_user_post_reclaimer(exec_ctx,
- grpc_endpoint_get_resource_user(t->ep),
+ grpc_resource_user_post_reclaimer(grpc_endpoint_get_resource_user(t->ep),
true, &t->destructive_reclaimer_locked);
}
}
-static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void benign_reclaimer_locked(void* arg, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (error == GRPC_ERROR_NONE &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
/* Channel with no active streams: send a goaway to try and make it
* disconnect cleanly */
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "HTTP2: %s - send goaway to free memory",
t->peer_string);
}
- send_goaway(exec_ctx, t,
+ send_goaway(t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
- } else if (error == GRPC_ERROR_NONE &&
- GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ } else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG,
"HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR
" streams",
@@ -3121,25 +3011,24 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
t->benign_reclaimer_registered = false;
if (error != GRPC_ERROR_CANCELLED) {
grpc_resource_user_finish_reclamation(
- exec_ctx, grpc_endpoint_get_resource_user(t->ep));
+ grpc_endpoint_get_resource_user(t->ep));
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "benign_reclaimer");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "benign_reclaimer");
}
-static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
+static void destructive_reclaimer_locked(void* arg, grpc_error* error) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
t->destructive_reclaimer_registered = false;
if (error == GRPC_ERROR_NONE && n > 0) {
- grpc_chttp2_stream *s =
- (grpc_chttp2_stream *)grpc_chttp2_stream_map_rand(&t->stream_map);
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ grpc_chttp2_stream* s =
+ (grpc_chttp2_stream*)grpc_chttp2_stream_map_rand(&t->stream_map);
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string,
s->id);
}
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR,
GRPC_HTTP2_ENHANCE_YOUR_CALM));
@@ -3148,21 +3037,21 @@ static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
there are more streams left, we can immediately post a new
reclaimer in case the resource quota needs to free more
memory */
- post_destructive_reclaimer(exec_ctx, t);
+ post_destructive_reclaimer(t);
}
}
if (error != GRPC_ERROR_CANCELLED) {
grpc_resource_user_finish_reclamation(
- exec_ctx, grpc_endpoint_get_resource_user(t->ep));
+ grpc_endpoint_get_resource_user(t->ep));
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "destructive_reclaimer");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "destructive_reclaimer");
}
/*******************************************************************************
* MONITORING
*/
-const char *grpc_chttp2_initiate_write_reason_string(
+const char* grpc_chttp2_initiate_write_reason_string(
grpc_chttp2_initiate_write_reason reason) {
switch (reason) {
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
@@ -3191,8 +3080,6 @@ const char *grpc_chttp2_initiate_write_reason_string(
return "TRANSPORT_FLOW_CONTROL";
case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS:
return "SEND_SETTINGS";
- case GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING:
- return "BDP_ESTIMATOR_PING";
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING:
return "FLOW_CONTROL_UNSTALLED_BY_SETTING";
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE:
@@ -3211,9 +3098,8 @@ const char *grpc_chttp2_initiate_write_reason_string(
GPR_UNREACHABLE_CODE(return "unknown");
}
-static grpc_endpoint *chttp2_get_endpoint(grpc_exec_ctx *exec_ctx,
- grpc_transport *t) {
- return ((grpc_chttp2_transport *)t)->ep;
+static grpc_endpoint* chttp2_get_endpoint(grpc_transport* t) {
+ return ((grpc_chttp2_transport*)t)->ep;
}
static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
@@ -3227,26 +3113,26 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
destroy_transport,
chttp2_get_endpoint};
-static const grpc_transport_vtable *get_vtable(void) { return &vtable; }
+static const grpc_transport_vtable* get_vtable(void) { return &vtable; }
-grpc_transport *grpc_create_chttp2_transport(
- grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
- grpc_endpoint *ep, int is_client) {
- grpc_chttp2_transport *t =
- (grpc_chttp2_transport *)gpr_zalloc(sizeof(grpc_chttp2_transport));
- init_transport(exec_ctx, t, channel_args, ep, is_client != 0);
+grpc_transport* grpc_create_chttp2_transport(
+ const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client) {
+ grpc_chttp2_transport* t =
+ (grpc_chttp2_transport*)gpr_zalloc(sizeof(grpc_chttp2_transport));
+ init_transport(t, channel_args, ep, is_client);
return &t->base;
}
-void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_slice_buffer *read_buffer) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)transport;
+void grpc_chttp2_transport_start_reading(
+ grpc_transport* transport, grpc_slice_buffer* read_buffer,
+ grpc_closure* notify_on_receive_settings) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)transport;
GRPC_CHTTP2_REF_TRANSPORT(
t, "reading_action"); /* matches unref inside reading_action */
- if (read_buffer != NULL) {
+ if (read_buffer != nullptr) {
grpc_slice_buffer_move_into(read_buffer, &t->read_buffer);
gpr_free(read_buffer);
}
- GRPC_CLOSURE_SCHED(exec_ctx, &t->read_action_locked, GRPC_ERROR_NONE);
+ t->notify_on_receive_settings = notify_on_receive_settings;
+ GRPC_CLOSURE_SCHED(&t->read_action_locked, GRPC_ERROR_NONE);
}
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
index 55fb1a8343..34519ceec9 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
@@ -23,22 +23,21 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/transport/transport.h"
-extern grpc_tracer_flag grpc_http_trace;
-extern grpc_tracer_flag grpc_flowctl_trace;
-extern grpc_tracer_flag grpc_trace_http2_stream_state;
+extern grpc_core::TraceFlag grpc_http_trace;
+extern grpc_core::TraceFlag grpc_trace_http2_stream_state;
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount;
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_chttp2_refcount;
-#endif
+extern bool g_flow_control_enabled;
-grpc_transport *grpc_create_chttp2_transport(
- grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
- grpc_endpoint *ep, int is_client);
+grpc_transport* grpc_create_chttp2_transport(
+ const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client);
/// Takes ownership of \a read_buffer, which (if non-NULL) contains
/// leftover bytes previously read from the endpoint (e.g., by handshakers).
-void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_slice_buffer *read_buffer);
+/// If non-null, \a notify_on_receive_settings will be scheduled when
+/// HTTP/2 settings are received from the peer.
+void grpc_chttp2_transport_start_reading(
+ grpc_transport* transport, grpc_slice_buffer* read_buffer,
+ grpc_closure* notify_on_receive_settings);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H */
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c
deleted file mode 100644
index 569a6349d3..0000000000
--- a/src/core/ext/transport/chttp2/transport/flow_control.c
+++ /dev/null
@@ -1,502 +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 "src/core/ext/transport/chttp2/transport/internal.h"
-
-#include <limits.h>
-#include <math.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-
-#include "src/core/lib/support/string.h"
-
-static uint32_t grpc_chttp2_target_announced_window(
- const grpc_chttp2_transport_flowctl* tfc);
-
-#ifndef NDEBUG
-
-typedef struct {
- int64_t remote_window;
- int64_t target_window;
- int64_t announced_window;
- int64_t remote_window_delta;
- int64_t local_window_delta;
- int64_t announced_window_delta;
- uint32_t local_init_window;
- uint32_t local_max_frame;
-} shadow_flow_control;
-
-static void pretrace(shadow_flow_control* shadow_fc,
- grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc) {
- shadow_fc->remote_window = tfc->remote_window;
- shadow_fc->target_window = grpc_chttp2_target_announced_window(tfc);
- shadow_fc->announced_window = tfc->announced_window;
- if (sfc != NULL) {
- shadow_fc->remote_window_delta = sfc->remote_window_delta;
- shadow_fc->local_window_delta = sfc->local_window_delta;
- shadow_fc->announced_window_delta = sfc->announced_window_delta;
- }
-}
-
-#define TRACE_PADDING 30
-
-static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
- char* str;
- if (old_val != new_val) {
- gpr_asprintf(&str, "%" PRId64 " -> %" PRId64 "", old_val, new_val);
- } else {
- gpr_asprintf(&str, "%" PRId64 "", old_val);
- }
- char* str_lp = gpr_leftpad(str, ' ', TRACE_PADDING);
- gpr_free(str);
- return str_lp;
-}
-
-static char* fmt_uint32_diff_str(uint32_t old_val, uint32_t new_val) {
- char* str;
- if (new_val > 0 && old_val != new_val) {
- gpr_asprintf(&str, "%" PRIu32 " -> %" PRIu32 "", old_val, new_val);
- } else {
- gpr_asprintf(&str, "%" PRIu32 "", old_val);
- }
- char* str_lp = gpr_leftpad(str, ' ', TRACE_PADDING);
- gpr_free(str);
- return str_lp;
-}
-
-static void posttrace(shadow_flow_control* shadow_fc,
- grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc, char* reason) {
- uint32_t acked_local_window =
- tfc->t->settings[GRPC_SENT_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
- uint32_t remote_window =
- tfc->t->settings[GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
- char* trw_str =
- fmt_int64_diff_str(shadow_fc->remote_window, tfc->remote_window);
- char* tlw_str = fmt_int64_diff_str(shadow_fc->target_window,
- grpc_chttp2_target_announced_window(tfc));
- char* taw_str =
- fmt_int64_diff_str(shadow_fc->announced_window, tfc->announced_window);
- char* srw_str;
- char* slw_str;
- char* saw_str;
- if (sfc != NULL) {
- srw_str = fmt_int64_diff_str(shadow_fc->remote_window_delta + remote_window,
- sfc->remote_window_delta + remote_window);
- slw_str =
- fmt_int64_diff_str(shadow_fc->local_window_delta + acked_local_window,
- sfc->local_window_delta + acked_local_window);
- saw_str = fmt_int64_diff_str(
- shadow_fc->announced_window_delta + acked_local_window,
- sfc->announced_window_delta + acked_local_window);
- } else {
- srw_str = gpr_leftpad("", ' ', TRACE_PADDING);
- slw_str = gpr_leftpad("", ' ', TRACE_PADDING);
- saw_str = gpr_leftpad("", ' ', TRACE_PADDING);
- }
- gpr_log(GPR_DEBUG,
- "%p[%u][%s] | %s | trw:%s, ttw:%s, taw:%s, srw:%s, slw:%s, saw:%s",
- tfc, sfc != NULL ? sfc->s->id : 0, tfc->t->is_client ? "cli" : "svr",
- reason, trw_str, tlw_str, taw_str, srw_str, slw_str, saw_str);
- gpr_free(trw_str);
- gpr_free(tlw_str);
- gpr_free(taw_str);
- gpr_free(srw_str);
- gpr_free(slw_str);
- gpr_free(saw_str);
-}
-
-static char* urgency_to_string(grpc_chttp2_flowctl_urgency urgency) {
- switch (urgency) {
- case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED:
- return "no action";
- case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY:
- return "update immediately";
- case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE:
- return "queue update";
- default:
- GPR_UNREACHABLE_CODE(return "unknown");
- }
- GPR_UNREACHABLE_CODE(return "unknown");
-}
-
-static void trace_action(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_flowctl_action action) {
- char* iw_str = fmt_uint32_diff_str(
- tfc->t->settings[GRPC_SENT_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
- action.initial_window_size);
- char* mf_str = fmt_uint32_diff_str(
- tfc->t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
- action.max_frame_size);
- gpr_log(GPR_DEBUG, "t[%s], s[%s], settings[%s] iw:%s mf:%s",
- urgency_to_string(action.send_transport_update),
- urgency_to_string(action.send_stream_update),
- urgency_to_string(action.send_setting_update), iw_str, mf_str);
- gpr_free(iw_str);
- gpr_free(mf_str);
-}
-
-#define PRETRACE(tfc, sfc) \
- shadow_flow_control shadow_fc; \
- GRPC_FLOW_CONTROL_IF_TRACING(pretrace(&shadow_fc, tfc, sfc))
-#define POSTTRACE(tfc, sfc, reason) \
- GRPC_FLOW_CONTROL_IF_TRACING(posttrace(&shadow_fc, tfc, sfc, reason))
-#define TRACEACTION(tfc, action) \
- GRPC_FLOW_CONTROL_IF_TRACING(trace_action(tfc, action))
-#else
-#define PRETRACE(tfc, sfc)
-#define POSTTRACE(tfc, sfc, reason)
-#define TRACEACTION(tfc, action)
-#endif
-
-/* How many bytes of incoming flow control would we like to advertise */
-static uint32_t grpc_chttp2_target_announced_window(
- const grpc_chttp2_transport_flowctl* tfc) {
- return (uint32_t)GPR_MIN(
- (int64_t)((1u << 31) - 1),
- tfc->announced_stream_total_over_incoming_window +
- tfc->t->settings[GRPC_SENT_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
-}
-
-// we have sent data on the wire, we must track this in our bookkeeping for the
-// remote peer's flow control.
-void grpc_chttp2_flowctl_sent_data(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc,
- int64_t size) {
- PRETRACE(tfc, sfc);
- tfc->remote_window -= size;
- sfc->remote_window_delta -= size;
- POSTTRACE(tfc, sfc, " data sent");
-}
-
-static void announced_window_delta_preupdate(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc) {
- if (sfc->announced_window_delta > 0) {
- tfc->announced_stream_total_over_incoming_window -=
- sfc->announced_window_delta;
- } else {
- tfc->announced_stream_total_under_incoming_window +=
- -sfc->announced_window_delta;
- }
-}
-
-static void announced_window_delta_postupdate(
- grpc_chttp2_transport_flowctl* tfc, grpc_chttp2_stream_flowctl* sfc) {
- if (sfc->announced_window_delta > 0) {
- tfc->announced_stream_total_over_incoming_window +=
- sfc->announced_window_delta;
- } else {
- tfc->announced_stream_total_under_incoming_window -=
- -sfc->announced_window_delta;
- }
-}
-
-// We have received data from the wire. We must track this in our own flow
-// control bookkeeping.
-// Returns an error if the incoming frame violates our flow control.
-grpc_error* grpc_chttp2_flowctl_recv_data(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc,
- int64_t incoming_frame_size) {
- uint32_t sent_init_window =
- tfc->t->settings[GRPC_SENT_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
- uint32_t acked_init_window =
- tfc->t->settings[GRPC_ACKED_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
- PRETRACE(tfc, sfc);
- if (incoming_frame_size > tfc->announced_window) {
- char* msg;
- gpr_asprintf(&msg,
- "frame of size %" PRId64 " overflows local window of %" PRId64,
- incoming_frame_size, tfc->announced_window);
- grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
- gpr_free(msg);
- return err;
- }
-
- if (sfc != NULL) {
- int64_t acked_stream_window =
- sfc->announced_window_delta + acked_init_window;
- int64_t sent_stream_window = sfc->announced_window_delta + sent_init_window;
- if (incoming_frame_size > acked_stream_window) {
- if (incoming_frame_size <= sent_stream_window) {
- gpr_log(
- GPR_ERROR,
- "Incoming frame of size %" PRId64
- " exceeds local window size of %" PRId64
- ".\n"
- "The (un-acked, future) window size would be %" PRId64
- " which is not exceeded.\n"
- "This would usually cause a disconnection, but allowing it due to"
- "broken HTTP2 implementations in the wild.\n"
- "See (for example) https://github.com/netty/netty/issues/6520.",
- incoming_frame_size, acked_stream_window, sent_stream_window);
- } else {
- char* msg;
- gpr_asprintf(&msg, "frame of size %" PRId64
- " overflows local window of %" PRId64,
- incoming_frame_size, acked_stream_window);
- grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
- gpr_free(msg);
- return err;
- }
- }
-
- announced_window_delta_preupdate(tfc, sfc);
- sfc->announced_window_delta -= incoming_frame_size;
- announced_window_delta_postupdate(tfc, sfc);
- sfc->local_window_delta -= incoming_frame_size;
- }
-
- tfc->announced_window -= incoming_frame_size;
-
- POSTTRACE(tfc, sfc, " data recv");
- return GRPC_ERROR_NONE;
-}
-
-// Returns a non zero announce integer if we should send a transport window
-// update
-uint32_t grpc_chttp2_flowctl_maybe_send_transport_update(
- grpc_chttp2_transport_flowctl* tfc) {
- PRETRACE(tfc, NULL);
- uint32_t target_announced_window = grpc_chttp2_target_announced_window(tfc);
- uint32_t threshold_to_send_transport_window_update =
- tfc->t->outbuf.count > 0 ? 3 * target_announced_window / 4
- : target_announced_window / 2;
- if (tfc->announced_window <= threshold_to_send_transport_window_update &&
- tfc->announced_window != target_announced_window) {
- uint32_t announce = (uint32_t)GPR_CLAMP(
- target_announced_window - tfc->announced_window, 0, UINT32_MAX);
- tfc->announced_window += announce;
- POSTTRACE(tfc, NULL, "t updt sent");
- return announce;
- }
- GRPC_FLOW_CONTROL_IF_TRACING(
- gpr_log(GPR_DEBUG, "%p[0][%s] will not send transport update", tfc,
- tfc->t->is_client ? "cli" : "svr"));
- return 0;
-}
-
-// Returns a non zero announce integer if we should send a stream window update
-uint32_t grpc_chttp2_flowctl_maybe_send_stream_update(
- grpc_chttp2_transport_flowctl* tfc, grpc_chttp2_stream_flowctl* sfc) {
- PRETRACE(tfc, sfc);
- if (sfc->local_window_delta > sfc->announced_window_delta) {
- uint32_t announce = (uint32_t)GPR_CLAMP(
- sfc->local_window_delta - sfc->announced_window_delta, 0, UINT32_MAX);
- announced_window_delta_preupdate(tfc, sfc);
- sfc->announced_window_delta += announce;
- announced_window_delta_postupdate(tfc, sfc);
- POSTTRACE(tfc, sfc, "s updt sent");
- return announce;
- }
- GRPC_FLOW_CONTROL_IF_TRACING(
- gpr_log(GPR_DEBUG, "%p[%u][%s] will not send stream update", tfc,
- sfc->s->id, tfc->t->is_client ? "cli" : "svr"));
- return 0;
-}
-
-// we have received a WINDOW_UPDATE frame for a transport
-void grpc_chttp2_flowctl_recv_transport_update(
- grpc_chttp2_transport_flowctl* tfc, uint32_t size) {
- PRETRACE(tfc, NULL);
- tfc->remote_window += size;
- POSTTRACE(tfc, NULL, "t updt recv");
-}
-
-// we have received a WINDOW_UPDATE frame for a stream
-void grpc_chttp2_flowctl_recv_stream_update(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc,
- uint32_t size) {
- PRETRACE(tfc, sfc);
- sfc->remote_window_delta += size;
- POSTTRACE(tfc, sfc, "s updt recv");
-}
-
-void grpc_chttp2_flowctl_incoming_bs_update(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc,
- size_t max_size_hint,
- size_t have_already) {
- PRETRACE(tfc, sfc);
- uint32_t max_recv_bytes;
- uint32_t sent_init_window =
- tfc->t->settings[GRPC_SENT_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
-
- /* clamp max recv hint to an allowable size */
- if (max_size_hint >= UINT32_MAX - sent_init_window) {
- max_recv_bytes = UINT32_MAX - sent_init_window;
- } else {
- max_recv_bytes = (uint32_t)max_size_hint;
- }
-
- /* account for bytes already received but unknown to higher layers */
- if (max_recv_bytes >= have_already) {
- max_recv_bytes -= (uint32_t)have_already;
- } else {
- max_recv_bytes = 0;
- }
-
- /* add some small lookahead to keep pipelines flowing */
- GPR_ASSERT(max_recv_bytes <= UINT32_MAX - sent_init_window);
- if (sfc->local_window_delta < max_recv_bytes) {
- uint32_t add_max_recv_bytes =
- (uint32_t)(max_recv_bytes - sfc->local_window_delta);
- sfc->local_window_delta += add_max_recv_bytes;
- }
- POSTTRACE(tfc, sfc, "app st recv");
-}
-
-void grpc_chttp2_flowctl_destroy_stream(grpc_chttp2_transport_flowctl* tfc,
- grpc_chttp2_stream_flowctl* sfc) {
- announced_window_delta_preupdate(tfc, sfc);
-}
-
-// Returns an urgency with which to make an update
-static grpc_chttp2_flowctl_urgency delta_is_significant(
- const grpc_chttp2_transport_flowctl* tfc, int32_t value,
- grpc_chttp2_setting_id setting_id) {
- int64_t delta = (int64_t)value -
- (int64_t)tfc->t->settings[GRPC_LOCAL_SETTINGS][setting_id];
- // TODO(ncteisen): tune this
- if (delta != 0 && (delta <= -value / 5 || delta >= value / 5)) {
- return GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE;
- } else {
- return GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED;
- }
-}
-
-// Takes in a target and uses the pid controller to return a stabilized
-// guess at the new bdp.
-static double get_pid_controller_guess(grpc_chttp2_transport_flowctl* tfc,
- double target) {
- double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller);
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec dt_timespec = gpr_time_sub(now, tfc->last_pid_update);
- double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9;
- if (dt > 0.1) {
- dt = 0.1;
- }
- double log2_bdp_guess =
- grpc_pid_controller_update(&tfc->pid_controller, bdp_error, dt);
- tfc->last_pid_update = now;
- return pow(2, log2_bdp_guess);
-}
-
-// Take in a target and modifies it based on the memory pressure of the system
-static double get_target_under_memory_pressure(
- grpc_chttp2_transport_flowctl* tfc, double target) {
- // do not increase window under heavy memory pressure.
- double memory_pressure = grpc_resource_quota_get_memory_pressure(
- grpc_resource_user_quota(grpc_endpoint_get_resource_user(tfc->t->ep)));
- if (memory_pressure > 0.8) {
- target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1);
- }
- return target;
-}
-
-grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action(
- grpc_chttp2_transport_flowctl* tfc, grpc_chttp2_stream_flowctl* sfc) {
- grpc_chttp2_flowctl_action action;
- memset(&action, 0, sizeof(action));
- uint32_t target_announced_window = grpc_chttp2_target_announced_window(tfc);
- if (tfc->announced_window < target_announced_window / 2) {
- action.send_transport_update = GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY;
- }
- // TODO(ncteisen): tune this
- if (sfc != NULL && !sfc->s->read_closed) {
- uint32_t sent_init_window =
- tfc->t->settings[GRPC_SENT_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
- if ((int64_t)sfc->local_window_delta >
- (int64_t)sfc->announced_window_delta &&
- (int64_t)sfc->announced_window_delta + sent_init_window <=
- sent_init_window / 2) {
- action.send_stream_update = GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY;
- } else if (sfc->local_window_delta > sfc->announced_window_delta) {
- action.send_stream_update = GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE;
- }
- }
- TRACEACTION(tfc, action);
- return action;
-}
-
-grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_bdp_action(
- grpc_chttp2_transport_flowctl* tfc) {
- grpc_chttp2_flowctl_action action;
- memset(&action, 0, sizeof(action));
- if (tfc->enable_bdp_probe) {
- action.need_ping = grpc_bdp_estimator_need_ping(&tfc->bdp_estimator);
-
- // get bdp estimate and update initial_window accordingly.
- int64_t estimate = -1;
- int32_t bdp = -1;
- if (grpc_bdp_estimator_get_estimate(&tfc->bdp_estimator, &estimate)) {
- double target = 1 + log2((double)estimate);
-
- // target might change based on how much memory pressure we are under
- // TODO(ncteisen): experiment with setting target to be huge under low
- // memory pressure.
- target = get_target_under_memory_pressure(tfc, target);
-
- // run our target through the pid controller to stabilize change.
- // TODO(ncteisen): experiment with other controllers here.
- double bdp_guess = get_pid_controller_guess(tfc, target);
-
- // Though initial window 'could' drop to 0, we keep the floor at 128
- bdp = GPR_MAX((int32_t)bdp_guess, 128);
-
- grpc_chttp2_flowctl_urgency init_window_update_urgency =
- delta_is_significant(tfc, bdp,
- GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE);
- if (init_window_update_urgency != GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED) {
- action.send_setting_update = init_window_update_urgency;
- action.initial_window_size = (uint32_t)bdp;
- }
- }
-
- // get bandwidth estimate and update max_frame accordingly.
- double bw_dbl = -1;
- if (grpc_bdp_estimator_get_bw(&tfc->bdp_estimator, &bw_dbl)) {
- // we target the max of BDP or bandwidth in microseconds.
- int32_t frame_size = (int32_t)GPR_CLAMP(
- GPR_MAX((int32_t)GPR_CLAMP(bw_dbl, 0, INT_MAX) / 1000, bdp), 16384,
- 16777215);
- grpc_chttp2_flowctl_urgency frame_size_urgency = delta_is_significant(
- tfc, frame_size, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE);
- if (frame_size_urgency != GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED) {
- if (frame_size_urgency > action.send_setting_update) {
- action.send_setting_update = frame_size_urgency;
- }
- action.max_frame_size = (uint32_t)frame_size;
- }
- }
- }
-
- TRACEACTION(tfc, action);
- return action;
-}
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc
new file mode 100644
index 0000000000..581241d392
--- /dev/null
+++ b/src/core/ext/transport/chttp2/transport/flow_control.cc
@@ -0,0 +1,401 @@
+/*
+ *
+ * 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 "src/core/ext/transport/chttp2/transport/flow_control.h"
+
+#include <inttypes.h>
+#include <limits.h>
+#include <math.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/ext/transport/chttp2/transport/internal.h"
+#include "src/core/lib/gpr/string.h"
+
+grpc_core::TraceFlag grpc_flowctl_trace(false, "flowctl");
+
+namespace grpc_core {
+namespace chttp2 {
+
+namespace {
+
+static constexpr const int kTracePadding = 30;
+
+static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
+ char* str;
+ if (old_val != new_val) {
+ gpr_asprintf(&str, "%" PRId64 " -> %" PRId64 "", old_val, new_val);
+ } else {
+ gpr_asprintf(&str, "%" PRId64 "", old_val);
+ }
+ char* str_lp = gpr_leftpad(str, ' ', kTracePadding);
+ gpr_free(str);
+ return str_lp;
+}
+
+static char* fmt_uint32_diff_str(uint32_t old_val, uint32_t new_val) {
+ char* str;
+ if (new_val > 0 && old_val != new_val) {
+ gpr_asprintf(&str, "%" PRIu32 " -> %" PRIu32 "", old_val, new_val);
+ } else {
+ gpr_asprintf(&str, "%" PRIu32 "", old_val);
+ }
+ char* str_lp = gpr_leftpad(str, ' ', kTracePadding);
+ gpr_free(str);
+ return str_lp;
+}
+} // namespace
+
+void FlowControlTrace::Init(const char* reason, TransportFlowControl* tfc,
+ StreamFlowControl* sfc) {
+ tfc_ = tfc;
+ sfc_ = sfc;
+ reason_ = reason;
+ remote_window_ = tfc->remote_window();
+ target_window_ = tfc->target_window();
+ announced_window_ = tfc->announced_window();
+ if (sfc != nullptr) {
+ remote_window_delta_ = sfc->remote_window_delta();
+ local_window_delta_ = sfc->local_window_delta();
+ announced_window_delta_ = sfc->announced_window_delta();
+ }
+}
+
+void FlowControlTrace::Finish() {
+ uint32_t acked_local_window =
+ tfc_->transport()->settings[GRPC_SENT_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
+ uint32_t remote_window =
+ tfc_->transport()->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
+ char* trw_str = fmt_int64_diff_str(remote_window_, tfc_->remote_window());
+ char* tlw_str = fmt_int64_diff_str(target_window_, tfc_->target_window());
+ char* taw_str =
+ fmt_int64_diff_str(announced_window_, tfc_->announced_window());
+ char* srw_str;
+ char* slw_str;
+ char* saw_str;
+ if (sfc_ != nullptr) {
+ srw_str = fmt_int64_diff_str(remote_window_delta_ + remote_window,
+ sfc_->remote_window_delta() + remote_window);
+ slw_str = fmt_int64_diff_str(local_window_delta_ + acked_local_window,
+ local_window_delta_ + acked_local_window);
+ saw_str = fmt_int64_diff_str(announced_window_delta_ + acked_local_window,
+ announced_window_delta_ + acked_local_window);
+ } else {
+ srw_str = gpr_leftpad("", ' ', kTracePadding);
+ slw_str = gpr_leftpad("", ' ', kTracePadding);
+ saw_str = gpr_leftpad("", ' ', kTracePadding);
+ }
+ gpr_log(GPR_DEBUG,
+ "%p[%u][%s] | %s | trw:%s, ttw:%s, taw:%s, srw:%s, slw:%s, saw:%s",
+ tfc_, sfc_ != nullptr ? sfc_->stream()->id : 0,
+ tfc_->transport()->is_client ? "cli" : "svr", reason_, trw_str,
+ tlw_str, taw_str, srw_str, slw_str, saw_str);
+ gpr_free(trw_str);
+ gpr_free(tlw_str);
+ gpr_free(taw_str);
+ gpr_free(srw_str);
+ gpr_free(slw_str);
+ gpr_free(saw_str);
+}
+
+const char* FlowControlAction::UrgencyString(Urgency u) {
+ switch (u) {
+ case Urgency::NO_ACTION_NEEDED:
+ return "no action";
+ case Urgency::UPDATE_IMMEDIATELY:
+ return "update immediately";
+ case Urgency::QUEUE_UPDATE:
+ return "queue update";
+ default:
+ GPR_UNREACHABLE_CODE(return "unknown");
+ }
+ GPR_UNREACHABLE_CODE(return "unknown");
+}
+
+void FlowControlAction::Trace(grpc_chttp2_transport* t) const {
+ char* iw_str = fmt_uint32_diff_str(
+ t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
+ initial_window_size_);
+ char* mf_str = fmt_uint32_diff_str(
+ t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
+ max_frame_size_);
+ gpr_log(GPR_DEBUG, "t[%s], s[%s], iw:%s:%s mf:%s:%s",
+ UrgencyString(send_transport_update_),
+ UrgencyString(send_stream_update_),
+ UrgencyString(send_initial_window_update_), iw_str,
+ UrgencyString(send_max_frame_size_update_), mf_str);
+ gpr_free(iw_str);
+ gpr_free(mf_str);
+}
+
+TransportFlowControlDisabled::TransportFlowControlDisabled(
+ grpc_chttp2_transport* t) {
+ remote_window_ = kMaxWindow;
+ target_initial_window_size_ = kMaxWindow;
+ announced_window_ = kMaxWindow;
+ t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
+ kFrameSize;
+ t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
+ kFrameSize;
+ t->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
+ kFrameSize;
+ t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
+ kMaxWindow;
+ t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
+ kMaxWindow;
+ t->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
+ kMaxWindow;
+}
+
+TransportFlowControl::TransportFlowControl(const grpc_chttp2_transport* t,
+ bool enable_bdp_probe)
+ : t_(t),
+ enable_bdp_probe_(enable_bdp_probe),
+ bdp_estimator_(t->peer_string),
+ pid_controller_(grpc_core::PidController::Args()
+ .set_gain_p(4)
+ .set_gain_i(8)
+ .set_gain_d(0)
+ .set_initial_control_value(TargetLogBdp())
+ .set_min_control_value(-1)
+ .set_max_control_value(25)
+ .set_integral_range(10)),
+ last_pid_update_(grpc_core::ExecCtx::Get()->Now()) {}
+
+uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) {
+ FlowControlTrace trace("t updt sent", this, nullptr);
+ const uint32_t target_announced_window = (const uint32_t)target_window();
+ if ((writing_anyway || announced_window_ <= target_announced_window / 2) &&
+ announced_window_ != target_announced_window) {
+ const uint32_t announce = (uint32_t)GPR_CLAMP(
+ target_announced_window - announced_window_, 0, UINT32_MAX);
+ announced_window_ += announce;
+ return announce;
+ }
+ return 0;
+}
+
+grpc_error* TransportFlowControl::ValidateRecvData(
+ int64_t incoming_frame_size) {
+ if (incoming_frame_size > announced_window_) {
+ char* msg;
+ gpr_asprintf(&msg,
+ "frame of size %" PRId64 " overflows local window of %" PRId64,
+ incoming_frame_size, announced_window_);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ gpr_free(msg);
+ return err;
+ }
+ return GRPC_ERROR_NONE;
+}
+
+StreamFlowControl::StreamFlowControl(TransportFlowControl* tfc,
+ const grpc_chttp2_stream* s)
+ : tfc_(tfc), s_(s) {}
+
+grpc_error* StreamFlowControl::RecvData(int64_t incoming_frame_size) {
+ FlowControlTrace trace(" data recv", tfc_, this);
+
+ grpc_error* error = GRPC_ERROR_NONE;
+ error = tfc_->ValidateRecvData(incoming_frame_size);
+ if (error != GRPC_ERROR_NONE) return error;
+
+ uint32_t sent_init_window =
+ tfc_->transport()->settings[GRPC_SENT_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
+ uint32_t acked_init_window =
+ tfc_->transport()->settings[GRPC_ACKED_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
+
+ int64_t acked_stream_window = announced_window_delta_ + acked_init_window;
+ int64_t sent_stream_window = announced_window_delta_ + sent_init_window;
+ if (incoming_frame_size > acked_stream_window) {
+ if (incoming_frame_size <= sent_stream_window) {
+ gpr_log(GPR_ERROR,
+ "Incoming frame of size %" PRId64
+ " exceeds local window size of %" PRId64
+ ".\n"
+ "The (un-acked, future) window size would be %" PRId64
+ " which is not exceeded.\n"
+ "This would usually cause a disconnection, but allowing it due to"
+ "broken HTTP2 implementations in the wild.\n"
+ "See (for example) https://github.com/netty/netty/issues/6520.",
+ incoming_frame_size, acked_stream_window, sent_stream_window);
+ } else {
+ char* msg;
+ gpr_asprintf(
+ &msg, "frame of size %" PRId64 " overflows local window of %" PRId64,
+ incoming_frame_size, acked_stream_window);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ gpr_free(msg);
+ return err;
+ }
+ }
+
+ UpdateAnnouncedWindowDelta(tfc_, -incoming_frame_size);
+ local_window_delta_ -= incoming_frame_size;
+ tfc_->CommitRecvData(incoming_frame_size);
+ return GRPC_ERROR_NONE;
+}
+
+uint32_t StreamFlowControl::MaybeSendUpdate() {
+ FlowControlTrace trace("s updt sent", tfc_, this);
+ if (local_window_delta_ > announced_window_delta_) {
+ uint32_t announce = (uint32_t)GPR_CLAMP(
+ local_window_delta_ - announced_window_delta_, 0, UINT32_MAX);
+ UpdateAnnouncedWindowDelta(tfc_, announce);
+ return announce;
+ }
+ return 0;
+}
+
+void StreamFlowControl::IncomingByteStreamUpdate(size_t max_size_hint,
+ size_t have_already) {
+ FlowControlTrace trace("app st recv", tfc_, this);
+ uint32_t max_recv_bytes;
+ uint32_t sent_init_window =
+ tfc_->transport()->settings[GRPC_SENT_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
+
+ /* clamp max recv hint to an allowable size */
+ if (max_size_hint >= UINT32_MAX - sent_init_window) {
+ max_recv_bytes = UINT32_MAX - sent_init_window;
+ } else {
+ max_recv_bytes = (uint32_t)max_size_hint;
+ }
+
+ /* account for bytes already received but unknown to higher layers */
+ if (max_recv_bytes >= have_already) {
+ max_recv_bytes -= (uint32_t)have_already;
+ } else {
+ max_recv_bytes = 0;
+ }
+
+ /* add some small lookahead to keep pipelines flowing */
+ GPR_ASSERT(max_recv_bytes <= UINT32_MAX - sent_init_window);
+ if (local_window_delta_ < max_recv_bytes) {
+ uint32_t add_max_recv_bytes =
+ (uint32_t)(max_recv_bytes - local_window_delta_);
+ local_window_delta_ += add_max_recv_bytes;
+ }
+}
+
+// Take in a target and modifies it based on the memory pressure of the system
+static double AdjustForMemoryPressure(grpc_resource_quota* quota,
+ double target) {
+ // do not increase window under heavy memory pressure.
+ double memory_pressure = grpc_resource_quota_get_memory_pressure(quota);
+ static const double kLowMemPressure = 0.1;
+ static const double kZeroTarget = 22;
+ static const double kHighMemPressure = 0.8;
+ static const double kMaxMemPressure = 0.9;
+ if (memory_pressure < kLowMemPressure && target < kZeroTarget) {
+ target = (target - kZeroTarget) * memory_pressure / kLowMemPressure +
+ kZeroTarget;
+ } else if (memory_pressure > kHighMemPressure) {
+ target *= 1 - GPR_MIN(1, (memory_pressure - kHighMemPressure) /
+ (kMaxMemPressure - kHighMemPressure));
+ }
+ return target;
+}
+
+double TransportFlowControl::TargetLogBdp() {
+ return AdjustForMemoryPressure(
+ grpc_resource_user_quota(grpc_endpoint_get_resource_user(t_->ep)),
+ 1 + log2(bdp_estimator_.EstimateBdp()));
+}
+
+double TransportFlowControl::SmoothLogBdp(double value) {
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+ double bdp_error = value - pid_controller_.last_control_value();
+ const double dt = (double)(now - last_pid_update_) * 1e-3;
+ last_pid_update_ = now;
+ // Limit dt to 100ms
+ const double kMaxDt = 0.1;
+ return pid_controller_.Update(bdp_error, dt > kMaxDt ? kMaxDt : dt);
+}
+
+FlowControlAction::Urgency TransportFlowControl::DeltaUrgency(
+ int64_t value, grpc_chttp2_setting_id setting_id) {
+ int64_t delta =
+ (int64_t)value - (int64_t)t_->settings[GRPC_LOCAL_SETTINGS][setting_id];
+ // TODO(ncteisen): tune this
+ if (delta != 0 && (delta <= -value / 5 || delta >= value / 5)) {
+ return FlowControlAction::Urgency::QUEUE_UPDATE;
+ } else {
+ return FlowControlAction::Urgency::NO_ACTION_NEEDED;
+ }
+}
+
+FlowControlAction TransportFlowControl::PeriodicUpdate() {
+ FlowControlAction action;
+ if (enable_bdp_probe_) {
+ // get bdp estimate and update initial_window accordingly.
+ // target might change based on how much memory pressure we are under
+ // TODO(ncteisen): experiment with setting target to be huge under low
+ // memory pressure.
+ const double target = pow(2, SmoothLogBdp(TargetLogBdp()));
+
+ // Though initial window 'could' drop to 0, we keep the floor at 128
+ target_initial_window_size_ = (int32_t)GPR_CLAMP(target, 128, INT32_MAX);
+
+ action.set_send_initial_window_update(
+ DeltaUrgency(target_initial_window_size_,
+ GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE),
+ (uint32_t)target_initial_window_size_);
+
+ // get bandwidth estimate and update max_frame accordingly.
+ double bw_dbl = bdp_estimator_.EstimateBandwidth();
+ // we target the max of BDP or bandwidth in microseconds.
+ int32_t frame_size = (int32_t)GPR_CLAMP(
+ GPR_MAX((int32_t)GPR_CLAMP(bw_dbl, 0, INT_MAX) / 1000,
+ target_initial_window_size_),
+ 16384, 16777215);
+ action.set_send_max_frame_size_update(
+ DeltaUrgency((int64_t)frame_size, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE),
+ frame_size);
+ }
+ return UpdateAction(action);
+}
+
+FlowControlAction StreamFlowControl::UpdateAction(FlowControlAction action) {
+ // TODO(ncteisen): tune this
+ if (!s_->read_closed) {
+ uint32_t sent_init_window =
+ tfc_->transport()->settings[GRPC_SENT_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
+ if (local_window_delta_ > announced_window_delta_ &&
+ announced_window_delta_ + sent_init_window <= sent_init_window / 2) {
+ action.set_send_stream_update(
+ FlowControlAction::Urgency::UPDATE_IMMEDIATELY);
+ } else if (local_window_delta_ > announced_window_delta_) {
+ action.set_send_stream_update(FlowControlAction::Urgency::QUEUE_UPDATE);
+ }
+ }
+
+ return action;
+}
+
+} // namespace chttp2
+} // namespace grpc_core
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h
new file mode 100644
index 0000000000..2ee1345260
--- /dev/null
+++ b/src/core/ext/transport/chttp2/transport/flow_control.h
@@ -0,0 +1,480 @@
+/*
+ *
+ * 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_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FLOW_CONTROL_H
+#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FLOW_CONTROL_H
+
+#include <grpc/support/port_platform.h>
+#include <stdint.h>
+
+#include <grpc/support/useful.h>
+#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
+#include "src/core/lib/gprpp/abstract.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/transport/bdp_estimator.h"
+#include "src/core/lib/transport/pid_controller.h"
+
+struct grpc_chttp2_transport;
+struct grpc_chttp2_stream;
+
+extern grpc_core::TraceFlag grpc_flowctl_trace;
+
+namespace grpc {
+namespace testing {
+class TrickledCHTTP2; // to make this a friend
+} // namespace testing
+} // namespace grpc
+
+namespace grpc_core {
+namespace chttp2 {
+
+static constexpr uint32_t kDefaultWindow = 65535;
+static constexpr int64_t kMaxWindow = (int64_t)((1u << 31) - 1);
+// TODO(ncteisen): Tune this
+static constexpr uint32_t kFrameSize = 1024 * 1024;
+
+class TransportFlowControl;
+class StreamFlowControl;
+
+// Encapsulates a collections of actions the transport needs to take with
+// regard to flow control. Each action comes with urgencies that tell the
+// transport how quickly the action must take place.
+class FlowControlAction {
+ public:
+ enum class Urgency : uint8_t {
+ // Nothing to be done.
+ NO_ACTION_NEEDED = 0,
+ // Initiate a write to update the initial window immediately.
+ UPDATE_IMMEDIATELY,
+ // Push the flow control update into a send buffer, to be sent
+ // out the next time a write is initiated.
+ QUEUE_UPDATE,
+ };
+
+ Urgency send_stream_update() const { return send_stream_update_; }
+ Urgency send_transport_update() const { return send_transport_update_; }
+ Urgency send_initial_window_update() const {
+ return send_initial_window_update_;
+ }
+ Urgency send_max_frame_size_update() const {
+ return send_max_frame_size_update_;
+ }
+ uint32_t initial_window_size() const { return initial_window_size_; }
+ uint32_t max_frame_size() const { return max_frame_size_; }
+
+ FlowControlAction& set_send_stream_update(Urgency u) {
+ send_stream_update_ = u;
+ return *this;
+ }
+ FlowControlAction& set_send_transport_update(Urgency u) {
+ send_transport_update_ = u;
+ return *this;
+ }
+ FlowControlAction& set_send_initial_window_update(Urgency u,
+ uint32_t update) {
+ send_initial_window_update_ = u;
+ initial_window_size_ = update;
+ return *this;
+ }
+ FlowControlAction& set_send_max_frame_size_update(Urgency u,
+ uint32_t update) {
+ send_max_frame_size_update_ = u;
+ max_frame_size_ = update;
+ return *this;
+ }
+
+ static const char* UrgencyString(Urgency u);
+ void Trace(grpc_chttp2_transport* t) const;
+
+ private:
+ Urgency send_stream_update_ = Urgency::NO_ACTION_NEEDED;
+ Urgency send_transport_update_ = Urgency::NO_ACTION_NEEDED;
+ Urgency send_initial_window_update_ = Urgency::NO_ACTION_NEEDED;
+ Urgency send_max_frame_size_update_ = Urgency::NO_ACTION_NEEDED;
+ uint32_t initial_window_size_ = 0;
+ uint32_t max_frame_size_ = 0;
+};
+
+class FlowControlTrace {
+ public:
+ FlowControlTrace(const char* reason, TransportFlowControl* tfc,
+ StreamFlowControl* sfc) {
+ if (enabled_) Init(reason, tfc, sfc);
+ }
+
+ ~FlowControlTrace() {
+ if (enabled_) Finish();
+ }
+
+ private:
+ void Init(const char* reason, TransportFlowControl* tfc,
+ StreamFlowControl* sfc);
+ void Finish();
+
+ const bool enabled_ = grpc_flowctl_trace.enabled();
+
+ TransportFlowControl* tfc_;
+ StreamFlowControl* sfc_;
+ const char* reason_;
+ int64_t remote_window_;
+ int64_t target_window_;
+ int64_t announced_window_;
+ int64_t remote_window_delta_;
+ int64_t local_window_delta_;
+ int64_t announced_window_delta_;
+};
+
+// Fat interface with all methods a flow control implementation needs to
+// support. gRPC C Core does not support pure virtual functions, so instead
+// we abort in any methods which require implementation in the base class.
+class TransportFlowControlBase {
+ public:
+ TransportFlowControlBase() {}
+ virtual ~TransportFlowControlBase() {}
+
+ // Is flow control enabled? This is needed in other codepaths like the checks
+ // in parsing and in writing.
+ virtual bool flow_control_enabled() const { abort(); }
+
+ // Called to check if the transport needs to send a WINDOW_UPDATE frame
+ virtual uint32_t MaybeSendUpdate(bool writing_anyway) { abort(); }
+
+ // Using the protected members, returns and Action to be taken by the
+ // tranport.
+ virtual FlowControlAction MakeAction() { abort(); }
+
+ // Using the protected members, returns and Action to be taken by the
+ // tranport. Also checks for updates to our BDP estimate and acts
+ // accordingly.
+ virtual FlowControlAction PeriodicUpdate() { abort(); }
+
+ // Called to do bookkeeping when a stream owned by this transport sends
+ // data on the wire
+ virtual void StreamSentData(int64_t size) { abort(); }
+
+ // Called to do bookkeeping when a stream owned by this transport receives
+ // data from the wire. Also does error checking for frame size.
+ virtual grpc_error* RecvData(int64_t incoming_frame_size) { abort(); }
+
+ // Called to do bookkeeping when we receive a WINDOW_UPDATE frame.
+ virtual void RecvUpdate(uint32_t size) { abort(); }
+
+ // Returns the BdpEstimator held by this object. Caller is responsible for
+ // checking for nullptr. TODO(ncteisen): consider fully encapsulating all
+ // bdp estimator actions inside TransportFlowControl
+ virtual BdpEstimator* bdp_estimator() { return nullptr; }
+
+ // Getters
+ int64_t remote_window() const { return remote_window_; }
+ virtual int64_t target_window() const { return target_initial_window_size_; }
+ int64_t announced_window() const { return announced_window_; }
+
+ // Used in certain benchmarks in which we don't want FlowControl to be a
+ // factor
+ virtual void TestOnlyForceHugeWindow() {}
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ friend class ::grpc::testing::TrickledCHTTP2;
+ int64_t remote_window_ = kDefaultWindow;
+ int64_t target_initial_window_size_ = kDefaultWindow;
+ int64_t announced_window_ = kDefaultWindow;
+};
+
+// Implementation of flow control that does NOTHING. Always returns maximum
+// values, never initiates writes, and assumes that the remote peer is doing
+// the same. To be used to narrow down on flow control as the cause of negative
+// performance.
+class TransportFlowControlDisabled final : public TransportFlowControlBase {
+ public:
+ // Maxes out all values
+ TransportFlowControlDisabled(grpc_chttp2_transport* t);
+
+ bool flow_control_enabled() const override { return false; }
+
+ // Never do anything.
+ uint32_t MaybeSendUpdate(bool writing_anyway) override { return 0; }
+ FlowControlAction MakeAction() override { return FlowControlAction(); }
+ FlowControlAction PeriodicUpdate() override { return FlowControlAction(); }
+ void StreamSentData(int64_t size) override {}
+ grpc_error* RecvData(int64_t incoming_frame_size) override {
+ return GRPC_ERROR_NONE;
+ }
+ void RecvUpdate(uint32_t size) override {}
+};
+
+// Implementation of flow control that abides to HTTP/2 spec and attempts
+// to be as performant as possible.
+class TransportFlowControl final : public TransportFlowControlBase {
+ public:
+ TransportFlowControl(const grpc_chttp2_transport* t, bool enable_bdp_probe);
+ ~TransportFlowControl() {}
+
+ bool flow_control_enabled() const override { return true; }
+
+ bool bdp_probe() const { return enable_bdp_probe_; }
+
+ // returns an announce if we should send a transport update to our peer,
+ // else returns zero; writing_anyway indicates if a write would happen
+ // regardless of the send - if it is false and this function returns non-zero,
+ // this announce will cause a write to occur
+ uint32_t MaybeSendUpdate(bool writing_anyway) override;
+
+ // Reads the flow control data and returns and actionable struct that will
+ // tell chttp2 exactly what it needs to do
+ FlowControlAction MakeAction() override {
+ return UpdateAction(FlowControlAction());
+ }
+
+ // Call periodically (at a low-ish rate, 100ms - 10s makes sense)
+ // to perform more complex flow control calculations and return an action
+ // to let chttp2 change its parameters
+ FlowControlAction PeriodicUpdate() override;
+
+ void StreamSentData(int64_t size) override { remote_window_ -= size; }
+
+ grpc_error* ValidateRecvData(int64_t incoming_frame_size);
+ void CommitRecvData(int64_t incoming_frame_size) {
+ announced_window_ -= incoming_frame_size;
+ }
+
+ grpc_error* RecvData(int64_t incoming_frame_size) override {
+ FlowControlTrace trace(" data recv", this, nullptr);
+ grpc_error* error = ValidateRecvData(incoming_frame_size);
+ if (error != GRPC_ERROR_NONE) return error;
+ CommitRecvData(incoming_frame_size);
+ return GRPC_ERROR_NONE;
+ }
+
+ // we have received a WINDOW_UPDATE frame for a transport
+ void RecvUpdate(uint32_t size) override {
+ FlowControlTrace trace("t updt recv", this, nullptr);
+ remote_window_ += size;
+ }
+
+ // See comment above announced_stream_total_over_incoming_window_ for the
+ // logic behind this decision.
+ int64_t target_window() const override {
+ return (uint32_t)GPR_MIN((int64_t)((1u << 31) - 1),
+ announced_stream_total_over_incoming_window_ +
+ target_initial_window_size_);
+ }
+
+ const grpc_chttp2_transport* transport() const { return t_; }
+
+ void PreUpdateAnnouncedWindowOverIncomingWindow(int64_t delta) {
+ if (delta > 0) {
+ announced_stream_total_over_incoming_window_ -= delta;
+ } else {
+ announced_stream_total_under_incoming_window_ += -delta;
+ }
+ }
+
+ void PostUpdateAnnouncedWindowOverIncomingWindow(int64_t delta) {
+ if (delta > 0) {
+ announced_stream_total_over_incoming_window_ += delta;
+ } else {
+ announced_stream_total_under_incoming_window_ -= -delta;
+ }
+ }
+
+ BdpEstimator* bdp_estimator() override { return &bdp_estimator_; }
+
+ void TestOnlyForceHugeWindow() override {
+ announced_window_ = 1024 * 1024 * 1024;
+ remote_window_ = 1024 * 1024 * 1024;
+ }
+
+ private:
+ double TargetLogBdp();
+ double SmoothLogBdp(double value);
+ FlowControlAction::Urgency DeltaUrgency(int64_t value,
+ grpc_chttp2_setting_id setting_id);
+
+ FlowControlAction UpdateAction(FlowControlAction action) {
+ if (announced_window_ < target_window() / 2) {
+ action.set_send_transport_update(
+ FlowControlAction::Urgency::UPDATE_IMMEDIATELY);
+ }
+ return action;
+ }
+
+ const grpc_chttp2_transport* const t_;
+
+ /** calculating what we should give for local window:
+ we track the total amount of flow control over initial window size
+ across all streams: this is data that we want to receive right now (it
+ has an outstanding read)
+ and the total amount of flow control under initial window size across all
+ streams: this is data we've read early
+ we want to adjust incoming_window such that:
+ incoming_window = total_over - max(bdp - total_under, 0) */
+ int64_t announced_stream_total_over_incoming_window_ = 0;
+ int64_t announced_stream_total_under_incoming_window_ = 0;
+
+ /** should we probe bdp? */
+ const bool enable_bdp_probe_;
+
+ /* bdp estimation */
+ grpc_core::BdpEstimator bdp_estimator_;
+
+ /* pid controller */
+ grpc_core::PidController pid_controller_;
+ grpc_millis last_pid_update_ = 0;
+};
+
+// Fat interface with all methods a stream flow control implementation needs
+// to support. gRPC C Core does not support pure virtual functions, so instead
+// we abort in any methods which require implementation in the base class.
+class StreamFlowControlBase {
+ public:
+ StreamFlowControlBase() {}
+ virtual ~StreamFlowControlBase() {}
+
+ // Updates an action using the protected members.
+ virtual FlowControlAction UpdateAction(FlowControlAction action) { abort(); }
+
+ // Using the protected members, returns an Action for this stream to be
+ // taken by the tranport.
+ virtual FlowControlAction MakeAction() { abort(); }
+
+ // Bookkeeping for when data is sent on this stream.
+ virtual void SentData(int64_t outgoing_frame_size) { abort(); }
+
+ // Bookkeeping and error checking for when data is received by this stream.
+ virtual grpc_error* RecvData(int64_t incoming_frame_size) { abort(); }
+
+ // Called to check if this stream needs to send a WINDOW_UPDATE frame.
+ virtual uint32_t MaybeSendUpdate() { abort(); }
+
+ // Bookkeeping for receiving a WINDOW_UPDATE from for this stream.
+ virtual void RecvUpdate(uint32_t size) { abort(); }
+
+ // Bookkeeping for when a call pulls bytes out of the transport. At this
+ // point we consider the data 'used' and can thus let out peer know we are
+ // ready for more data.
+ virtual void IncomingByteStreamUpdate(size_t max_size_hint,
+ size_t have_already) {
+ abort();
+ }
+
+ // Used in certain benchmarks in which we don't want FlowControl to be a
+ // factor
+ virtual void TestOnlyForceHugeWindow() {}
+
+ // Getters
+ int64_t remote_window_delta() { return remote_window_delta_; }
+ int64_t local_window_delta() { return local_window_delta_; }
+ int64_t announced_window_delta() { return announced_window_delta_; }
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ friend class ::grpc::testing::TrickledCHTTP2;
+ int64_t remote_window_delta_ = 0;
+ int64_t local_window_delta_ = 0;
+ int64_t announced_window_delta_ = 0;
+};
+
+// Implementation of flow control that does NOTHING. Always returns maximum
+// values, never initiates writes, and assumes that the remote peer is doing
+// the same. To be used to narrow down on flow control as the cause of negative
+// performance.
+class StreamFlowControlDisabled : public StreamFlowControlBase {
+ public:
+ FlowControlAction UpdateAction(FlowControlAction action) override {
+ return action;
+ }
+ FlowControlAction MakeAction() override { return FlowControlAction(); }
+ void SentData(int64_t outgoing_frame_size) override {}
+ grpc_error* RecvData(int64_t incoming_frame_size) override {
+ return GRPC_ERROR_NONE;
+ }
+ uint32_t MaybeSendUpdate() override { return 0; }
+ void RecvUpdate(uint32_t size) override {}
+ void IncomingByteStreamUpdate(size_t max_size_hint,
+ size_t have_already) override {}
+};
+
+// Implementation of flow control that abides to HTTP/2 spec and attempts
+// to be as performant as possible.
+class StreamFlowControl final : public StreamFlowControlBase {
+ public:
+ StreamFlowControl(TransportFlowControl* tfc, const grpc_chttp2_stream* s);
+ ~StreamFlowControl() {
+ tfc_->PreUpdateAnnouncedWindowOverIncomingWindow(announced_window_delta_);
+ }
+
+ FlowControlAction UpdateAction(FlowControlAction action) override;
+ FlowControlAction MakeAction() override {
+ return UpdateAction(tfc_->MakeAction());
+ }
+
+ // we have sent data on the wire, we must track this in our bookkeeping for
+ // the remote peer's flow control.
+ void SentData(int64_t outgoing_frame_size) override {
+ FlowControlTrace tracer(" data sent", tfc_, this);
+ tfc_->StreamSentData(outgoing_frame_size);
+ remote_window_delta_ -= outgoing_frame_size;
+ }
+
+ // we have received data from the wire
+ grpc_error* RecvData(int64_t incoming_frame_size) override;
+
+ // returns an announce if we should send a stream update to our peer, else
+ // returns zero
+ uint32_t MaybeSendUpdate() override;
+
+ // we have received a WINDOW_UPDATE frame for a stream
+ void RecvUpdate(uint32_t size) override {
+ FlowControlTrace trace("s updt recv", tfc_, this);
+ remote_window_delta_ += size;
+ }
+
+ // the application is asking for a certain amount of bytes
+ void IncomingByteStreamUpdate(size_t max_size_hint,
+ size_t have_already) override;
+
+ int64_t remote_window_delta() const { return remote_window_delta_; }
+ int64_t local_window_delta() const { return local_window_delta_; }
+ int64_t announced_window_delta() const { return announced_window_delta_; }
+
+ const grpc_chttp2_stream* stream() const { return s_; }
+
+ void TestOnlyForceHugeWindow() override {
+ announced_window_delta_ = 1024 * 1024 * 1024;
+ local_window_delta_ = 1024 * 1024 * 1024;
+ remote_window_delta_ = 1024 * 1024 * 1024;
+ }
+
+ private:
+ TransportFlowControl* const tfc_;
+ const grpc_chttp2_stream* const s_;
+
+ void UpdateAnnouncedWindowDelta(TransportFlowControl* tfc, int64_t change) {
+ tfc->PreUpdateAnnouncedWindowOverIncomingWindow(announced_window_delta_);
+ announced_window_delta_ += change;
+ tfc->PostUpdateAnnouncedWindowOverIncomingWindow(announced_window_delta_);
+ }
+};
+
+} // namespace chttp2
+} // namespace grpc_core
+
+#endif
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.cc
index 73aaab1802..043b80a3cb 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.c
+++ b/src/core/ext/transport/chttp2/transport/frame_data.cc
@@ -25,35 +25,34 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
#include "src/core/ext/transport/chttp2/transport/internal.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/transport.h"
-grpc_error *grpc_chttp2_data_parser_init(grpc_chttp2_data_parser *parser) {
+grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser) {
parser->state = GRPC_CHTTP2_DATA_FH_0;
- parser->parsing_frame = NULL;
+ parser->parsing_frame = nullptr;
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_data_parser *parser) {
- if (parser->parsing_frame != NULL) {
+void grpc_chttp2_data_parser_destroy(grpc_chttp2_data_parser* parser) {
+ if (parser->parsing_frame != nullptr) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, parser->parsing_frame,
+ parser->parsing_frame,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Parser destroyed"), false));
}
GRPC_ERROR_UNREF(parser->error);
}
-grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
+grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
uint8_t flags,
uint32_t stream_id,
- grpc_chttp2_stream *s) {
+ grpc_chttp2_stream* s) {
if (flags & ~GRPC_CHTTP2_DATA_FLAG_END_STREAM) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "unsupported data flags: 0x%02x", flags);
- grpc_error *err =
+ grpc_error* err =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg),
GRPC_ERROR_INT_STREAM_ID, (intptr_t)stream_id);
gpr_free(msg);
@@ -69,12 +68,12 @@ grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
+void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
uint32_t write_bytes, int is_eof,
- grpc_transport_one_way_stats *stats,
- grpc_slice_buffer *outbuf) {
+ grpc_transport_one_way_stats* stats,
+ grpc_slice_buffer* outbuf) {
grpc_slice hdr;
- uint8_t *p;
+ uint8_t* p;
static const size_t header_size = 9;
hdr = GRPC_SLICE_MALLOC(header_size);
@@ -97,17 +96,17 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
stats->data_bytes += write_bytes;
}
-grpc_error *grpc_deframe_unprocessed_incoming_frames(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_stream *s,
- grpc_slice_buffer *slices, grpc_slice *slice_out,
- grpc_byte_stream **stream_out) {
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_chttp2_transport *t = s->t;
+grpc_error* grpc_deframe_unprocessed_incoming_frames(
+ grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
+ grpc_slice_buffer* slices, grpc_slice* slice_out,
+ grpc_byte_stream** stream_out) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_chttp2_transport* t = s->t;
while (slices->count > 0) {
- uint8_t *beg = NULL;
- uint8_t *end = NULL;
- uint8_t *cur = NULL;
+ uint8_t* beg = nullptr;
+ uint8_t* end = nullptr;
+ uint8_t* cur = nullptr;
grpc_slice slice = grpc_slice_buffer_take_first(slices);
@@ -115,17 +114,17 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
end = GRPC_SLICE_END_PTR(slice);
cur = beg;
uint32_t message_flags;
- char *msg;
+ char* msg;
if (cur == end) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
switch (p->state) {
case GRPC_CHTTP2_DATA_ERROR:
p->state = GRPC_CHTTP2_DATA_ERROR;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_REF(p->error);
case GRPC_CHTTP2_DATA_FH_0:
s->stats.incoming.framing_bytes++;
@@ -150,12 +149,12 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
p->error =
grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg);
p->state = GRPC_CHTTP2_DATA_ERROR;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_REF(p->error);
}
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_1;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -164,7 +163,7 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
p->frame_size = ((uint32_t)*cur) << 24;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_2;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -173,7 +172,7 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
p->frame_size |= ((uint32_t)*cur) << 16;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_3;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -182,14 +181,14 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
p->frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_4;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_4:
s->stats.incoming.framing_bytes++;
- GPR_ASSERT(stream_out != NULL);
- GPR_ASSERT(p->parsing_frame == NULL);
+ GPR_ASSERT(stream_out != nullptr);
+ GPR_ASSERT(p->parsing_frame == nullptr);
p->frame_size |= ((uint32_t)*cur);
p->state = GRPC_CHTTP2_DATA_FRAME;
++cur;
@@ -198,12 +197,12 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
message_flags |= GRPC_WRITE_INTERNAL_COMPRESS;
}
p->parsing_frame = grpc_chttp2_incoming_byte_stream_create(
- exec_ctx, t, s, p->frame_size, message_flags);
+ t, s, p->frame_size, message_flags);
*stream_out = &p->parsing_frame->base;
if (p->parsing_frame->remaining_bytes == 0) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true));
- p->parsing_frame = NULL;
+ p->parsing_frame, GRPC_ERROR_NONE, true));
+ p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
}
s->pending_byte_stream = true;
@@ -213,73 +212,73 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
slices,
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
}
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
case GRPC_CHTTP2_DATA_FRAME: {
- GPR_ASSERT(p->parsing_frame != NULL);
- GPR_ASSERT(slice_out != NULL);
+ GPR_ASSERT(p->parsing_frame != nullptr);
+ GPR_ASSERT(slice_out != nullptr);
if (cur == end) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
uint32_t remaining = (uint32_t)(end - cur);
if (remaining == p->frame_size) {
s->stats.incoming.data_bytes += remaining;
if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push(
- exec_ctx, p->parsing_frame,
+ p->parsing_frame,
grpc_slice_sub(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
slice_out))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return error;
}
if (GRPC_ERROR_NONE !=
(error = grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ p->parsing_frame, GRPC_ERROR_NONE, true))) {
+ grpc_slice_unref_internal(slice);
return error;
}
- p->parsing_frame = NULL;
+ p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
} else if (remaining < p->frame_size) {
s->stats.incoming.data_bytes += remaining;
if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push(
- exec_ctx, p->parsing_frame,
+ p->parsing_frame,
grpc_slice_sub(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
slice_out))) {
return error;
}
p->frame_size -= remaining;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
} else {
GPR_ASSERT(remaining > p->frame_size);
s->stats.incoming.data_bytes += p->frame_size;
if (GRPC_ERROR_NONE !=
(grpc_chttp2_incoming_byte_stream_push(
- exec_ctx, p->parsing_frame,
+ p->parsing_frame,
grpc_slice_sub(slice, (size_t)(cur - beg),
(size_t)(cur + p->frame_size - beg)),
slice_out))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return error;
}
if (GRPC_ERROR_NONE !=
(error = grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ p->parsing_frame, GRPC_ERROR_NONE, true))) {
+ grpc_slice_unref_internal(slice);
return error;
}
- p->parsing_frame = NULL;
+ p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
cur += p->frame_size;
grpc_slice_buffer_undo_take_first(
slices,
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
}
}
@@ -289,20 +288,20 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_data_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
if (!s->pending_byte_stream) {
grpc_slice_ref_internal(slice);
grpc_slice_buffer_add(&s->frame_storage, slice);
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
} else if (s->on_next) {
GPR_ASSERT(s->frame_storage.length == 0);
grpc_slice_ref_internal(slice);
grpc_slice_buffer_add(&s->unprocessed_incoming_frames_buffer, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_NONE);
- s->on_next = NULL;
+ GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_NONE);
+ s->on_next = nullptr;
s->unprocessed_incoming_frames_decompressed = false;
} else {
grpc_slice_ref_internal(slice);
@@ -310,8 +309,7 @@ grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
}
if (is_last && s->received_last_frame) {
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false,
- GRPC_ERROR_NONE);
+ grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
}
return GRPC_ERROR_NONE;
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h
index 3f1c787847..964cc59b1b 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.h
+++ b/src/core/ext/transport/chttp2/transport/frame_data.h
@@ -45,39 +45,38 @@ typedef struct {
grpc_chttp2_stream_state state;
uint8_t frame_type;
uint32_t frame_size;
- grpc_error *error;
+ grpc_error* error;
bool is_frame_compressed;
- grpc_chttp2_incoming_byte_stream *parsing_frame;
+ grpc_chttp2_incoming_byte_stream* parsing_frame;
} grpc_chttp2_data_parser;
/* initialize per-stream state for data frame parsing */
-grpc_error *grpc_chttp2_data_parser_init(grpc_chttp2_data_parser *parser);
+grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser);
-void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_data_parser *parser);
+void grpc_chttp2_data_parser_destroy(grpc_chttp2_data_parser* parser);
/* start processing a new data frame */
-grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
+grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
uint8_t flags,
uint32_t stream_id,
- grpc_chttp2_stream *s);
+ grpc_chttp2_stream* s);
/* handle a slice of a data frame - is_last indicates the last slice of a
frame */
-grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_data_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
-void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
+void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
uint32_t write_bytes, int is_eof,
- grpc_transport_one_way_stats *stats,
- grpc_slice_buffer *outbuf);
+ grpc_transport_one_way_stats* stats,
+ grpc_slice_buffer* outbuf);
-grpc_error *grpc_deframe_unprocessed_incoming_frames(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_stream *s,
- grpc_slice_buffer *slices, grpc_slice *slice_out,
- grpc_byte_stream **stream_out);
+grpc_error* grpc_deframe_unprocessed_incoming_frames(
+ grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
+ grpc_slice_buffer* slices, grpc_slice* slice_out,
+ grpc_byte_stream** stream_out);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.c b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
index 78ec08e177..b60b4227fe 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.c
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
@@ -25,42 +25,41 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p) {
- p->debug_data = NULL;
+void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p) {
+ p->debug_data = nullptr;
}
-void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p) {
+void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p) {
gpr_free(p->debug_data);
}
-grpc_error *grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser *p,
+grpc_error* grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser* p,
uint32_t length,
uint8_t flags) {
if (length < 8) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "goaway frame too short (%d bytes)", length);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
gpr_free(p->debug_data);
p->debug_length = length - 8;
- p->debug_data = (char *)gpr_malloc(p->debug_length);
+ p->debug_data = (char*)gpr_malloc(p->debug_length);
p->debug_pos = 0;
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_goaway_parser *p = (grpc_chttp2_goaway_parser *)parser;
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_goaway_parser* p = (grpc_chttp2_goaway_parser*)parser;
switch (p->state) {
case GRPC_CHTTP2_GOAWAY_LSI0:
@@ -135,9 +134,9 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) {
grpc_chttp2_add_incoming_goaway(
- exec_ctx, t, (uint32_t)p->error_code,
+ t, (uint32_t)p->error_code,
grpc_slice_new(p->debug_data, p->debug_length, gpr_free));
- p->debug_data = NULL;
+ p->debug_data = nullptr;
}
return GRPC_ERROR_NONE;
}
@@ -147,9 +146,9 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice debug_data,
- grpc_slice_buffer *slice_buffer) {
+ grpc_slice_buffer* slice_buffer) {
grpc_slice header = GRPC_SLICE_MALLOC(9 + 4 + 4);
- uint8_t *p = GRPC_SLICE_START_PTR(header);
+ uint8_t* p = GRPC_SLICE_START_PTR(header);
uint32_t frame_length;
GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
frame_length = 4 + 4 + (uint32_t)GRPC_SLICE_LENGTH(debug_data);
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h
index abc48f30c6..064d39ac59 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.h
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h
@@ -41,23 +41,22 @@ typedef struct {
grpc_chttp2_goaway_parse_state state;
uint32_t last_stream_id;
uint32_t error_code;
- char *debug_data;
+ char* debug_data;
uint32_t debug_length;
uint32_t debug_pos;
} grpc_chttp2_goaway_parser;
-void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p);
-void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p);
-grpc_error *grpc_chttp2_goaway_parser_begin_frame(
- grpc_chttp2_goaway_parser *parser, uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p);
+void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p);
+grpc_error* grpc_chttp2_goaway_parser_begin_frame(
+ grpc_chttp2_goaway_parser* parser, uint32_t length, uint8_t flags);
+grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice debug_data,
- grpc_slice_buffer *slice_buffer);
+ grpc_slice_buffer* slice_buffer);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.cc
index d431d6b2df..298a56721a 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.c
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc
@@ -29,7 +29,7 @@ static bool g_disable_ping_ack = false;
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8);
- uint8_t *p = GRPC_SLICE_START_PTR(slice);
+ uint8_t* p = GRPC_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
@@ -52,13 +52,13 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
return slice;
}
-grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
+grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser,
uint32_t length,
uint8_t flags) {
if (flags & 0xfe || length != 8) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid ping: length=%d, flags=%02x", length, flags);
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return error;
}
@@ -68,14 +68,14 @@ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_ping_parser *p = (grpc_chttp2_ping_parser *)parser;
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_ping_parser* p = (grpc_chttp2_ping_parser*)parser;
while (p->byte != 8 && cur != end) {
p->opaque_8bytes |= (((uint64_t)*cur) << (56 - 8 * p->byte));
@@ -86,13 +86,13 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
if (p->byte == 8) {
GPR_ASSERT(is_last);
if (p->is_ack) {
- grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes);
+ grpc_chttp2_ack_ping(t, p->opaque_8bytes);
} else {
if (!t->is_client) {
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec next_allowed_ping =
- gpr_time_add(t->ping_recv_state.last_ping_recv_time,
- t->ping_policy.min_recv_ping_interval_without_data);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+ grpc_millis next_allowed_ping =
+ t->ping_recv_state.last_ping_recv_time +
+ t->ping_policy.min_recv_ping_interval_without_data;
if (t->keepalive_permit_without_calls == 0 &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
@@ -100,12 +100,11 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
no less than two hours. When there is no outstanding streams, we
restrict the number of PINGS equivalent to TCP Keep-Alive. */
next_allowed_ping =
- gpr_time_add(t->ping_recv_state.last_ping_recv_time,
- gpr_time_from_seconds(7200, GPR_TIMESPAN));
+ t->ping_recv_state.last_ping_recv_time + 7200 * GPR_MS_PER_SEC;
}
- if (gpr_time_cmp(next_allowed_ping, now) > 0) {
- grpc_chttp2_add_ping_strike(exec_ctx, t);
+ if (next_allowed_ping > now) {
+ grpc_chttp2_add_ping_strike(t);
}
t->ping_recv_state.last_ping_recv_time = now;
@@ -113,12 +112,11 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
if (!g_disable_ping_ack) {
if (t->ping_ack_count == t->ping_ack_capacity) {
t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3);
- t->ping_acks = (uint64_t *)gpr_realloc(
+ t->ping_acks = (uint64_t*)gpr_realloc(
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks));
}
t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes;
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE);
}
}
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h
index 5969ace9bd..75bacfb1d4 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.h
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.h
@@ -31,11 +31,11 @@ typedef struct {
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes);
-grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
+grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser,
uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
/* Test-only function for disabling ping ack */
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
index 0133b6efa2..fee576678d 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
@@ -27,11 +27,11 @@
#include "src/core/lib/transport/http2_errors.h"
grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
- grpc_transport_one_way_stats *stats) {
+ grpc_transport_one_way_stats* stats) {
static const size_t frame_size = 13;
grpc_slice slice = GRPC_SLICE_MALLOC(frame_size);
stats->framing_bytes += frame_size;
- uint8_t *p = GRPC_SLICE_START_PTR(slice);
+ uint8_t* p = GRPC_SLICE_START_PTR(slice);
// Frame size.
*p++ = 0;
@@ -55,13 +55,13 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
return slice;
}
-grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags) {
+grpc_error* grpc_chttp2_rst_stream_parser_begin_frame(
+ grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags) {
if (length != 4) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid rst_stream: length=%d, flags=%02x", length,
flags);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -69,15 +69,14 @@ grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_rst_stream_parser *p = (grpc_chttp2_rst_stream_parser *)parser;
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_rst_stream_parser* p = (grpc_chttp2_rst_stream_parser*)parser;
while (p->byte != 4 && cur != end) {
p->reason_bytes[p->byte] = *cur;
@@ -92,9 +91,9 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
(((uint32_t)p->reason_bytes[1]) << 16) |
(((uint32_t)p->reason_bytes[2]) << 8) |
(((uint32_t)p->reason_bytes[3]));
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (reason != GRPC_HTTP2_NO_ERROR || s->metadata_buffer[1].size == 0) {
- char *message;
+ char* message;
gpr_asprintf(&message, "Received RST_STREAM with error code %d", reason);
error = grpc_error_set_int(
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("RST_STREAM"),
@@ -103,7 +102,7 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
gpr_free(message);
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, error);
+ grpc_chttp2_mark_stream_closed(t, s, true, true, error);
}
return GRPC_ERROR_NONE;
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
index d088221b52..e76a3ca841 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
@@ -30,14 +30,13 @@ typedef struct {
} grpc_chttp2_rst_stream_parser;
grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code,
- grpc_transport_one_way_stats *stats);
+ grpc_transport_one_way_stats* stats);
-grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_rst_stream_parser_begin_frame(
+ grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags);
+grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.c b/src/core/ext/transport/chttp2/transport/frame_settings.cc
index 2995bf7310..0d245f4ba1 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.c
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc
@@ -31,7 +31,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/http2_errors.h"
-static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
+static uint8_t* fill_header(uint8_t* out, uint32_t length, uint8_t flags) {
*out++ = (uint8_t)(length >> 16);
*out++ = (uint8_t)(length >> 8);
*out++ = (uint8_t)(length);
@@ -44,13 +44,13 @@ static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
return out;
}
-grpc_slice grpc_chttp2_settings_create(uint32_t *old_settings,
- const uint32_t *new_settings,
+grpc_slice grpc_chttp2_settings_create(uint32_t* old_settings,
+ const uint32_t* new_settings,
uint32_t force_mask, size_t count) {
size_t i;
uint32_t n = 0;
grpc_slice output;
- uint8_t *p;
+ uint8_t* p;
for (i = 0; i < count; i++) {
n += (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0);
@@ -82,9 +82,9 @@ grpc_slice grpc_chttp2_settings_ack_create(void) {
return output;
}
-grpc_error *grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
- uint32_t *settings) {
+grpc_error* grpc_chttp2_settings_parser_begin_frame(
+ grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
+ uint32_t* settings) {
parser->target_settings = settings;
memcpy(parser->incoming_settings, settings,
GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
@@ -108,14 +108,13 @@ grpc_error *grpc_chttp2_settings_parser_begin_frame(
}
}
-grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- grpc_chttp2_settings_parser *parser = (grpc_chttp2_settings_parser *)p;
- const uint8_t *cur = GRPC_SLICE_START_PTR(slice);
- const uint8_t *end = GRPC_SLICE_END_PTR(slice);
- char *msg;
+ grpc_chttp2_settings_parser* parser = (grpc_chttp2_settings_parser*)p;
+ const uint8_t* cur = GRPC_SLICE_START_PTR(slice);
+ const uint8_t* end = GRPC_SLICE_END_PTR(slice);
+ char* msg;
grpc_chttp2_setting_id id;
if (parser->is_ack) {
@@ -131,6 +130,11 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
memcpy(parser->target_settings, parser->incoming_settings,
GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create());
+ if (t->notify_on_receive_settings != nullptr) {
+ GRPC_CLOSURE_SCHED(t->notify_on_receive_settings,
+ GRPC_ERROR_NONE);
+ t->notify_on_receive_settings = nullptr;
+ }
}
return GRPC_ERROR_NONE;
}
@@ -180,8 +184,14 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
cur++;
if (grpc_wire_id_to_setting_id(parser->id, &id)) {
- const grpc_chttp2_setting_parameters *sp =
+ const grpc_chttp2_setting_parameters* sp =
&grpc_chttp2_settings_parameters[id];
+ // If flow control is disabled we skip these.
+ if (!t->flow_control->flow_control_enabled() &&
+ (id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE ||
+ id == GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE)) {
+ continue;
+ }
if (parser->value < sp->min_value || parser->value > sp->max_value) {
switch (sp->invalid_value_behavior) {
case GRPC_CHTTP2_CLAMP_INVALID_VALUE:
@@ -195,29 +205,28 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
&t->qbuf);
gpr_asprintf(&msg, "invalid value %u passed for %s",
parser->value, sp->name);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
}
if (id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
parser->incoming_settings[id] != parser->value) {
- t->flow_control.initial_window_update +=
+ t->initial_window_update +=
(int64_t)parser->value - parser->incoming_settings[id];
- if (GRPC_TRACER_ON(grpc_http_trace) ||
- GRPC_TRACER_ON(grpc_flowctl_trace)) {
+ if (grpc_http_trace.enabled() || grpc_flowctl_trace.enabled()) {
gpr_log(GPR_DEBUG, "%p[%s] adding %d for initial_window change",
t, t->is_client ? "cli" : "svr",
- (int)t->flow_control.initial_window_update);
+ (int)t->initial_window_update);
}
}
parser->incoming_settings[id] = parser->value;
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "CHTTP2:%s:%s: got setting %s = %d",
t->is_client ? "CLI" : "SVR", t->peer_string, sp->name,
parser->value);
}
- } else if (GRPC_TRACER_ON(grpc_http_trace)) {
+ } else if (grpc_http_trace.enabled()) {
gpr_log(GPR_ERROR, "CHTTP2: Ignoring unknown setting %d (value %d)",
parser->id, parser->value);
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h
index 47479d675d..ce65402815 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.h
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.h
@@ -36,7 +36,7 @@ typedef enum {
typedef struct {
grpc_chttp2_settings_parse_state state;
- uint32_t *target_settings;
+ uint32_t* target_settings;
uint8_t is_ack;
uint16_t id;
uint32_t value;
@@ -44,18 +44,17 @@ typedef struct {
} grpc_chttp2_settings_parser;
/* Create a settings frame by diffing old & new, and updating old to be new */
-grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *newval,
+grpc_slice grpc_chttp2_settings_create(uint32_t* old, const uint32_t* newval,
uint32_t force_mask, size_t count);
/* Create an ack settings frame */
grpc_slice grpc_chttp2_settings_ack_create(void);
-grpc_error *grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
- uint32_t *settings);
-grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx,
- void *parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_settings_parser_begin_frame(
+ grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
+ uint32_t* settings);
+grpc_error* grpc_chttp2_settings_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.c b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
index c9ab8d1b50..418ca144ce 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.c
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
@@ -24,11 +24,11 @@
#include <grpc/support/string_util.h>
grpc_slice grpc_chttp2_window_update_create(
- uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) {
+ uint32_t id, uint32_t window_update, grpc_transport_one_way_stats* stats) {
static const size_t frame_size = 13;
grpc_slice slice = GRPC_SLICE_MALLOC(frame_size);
stats->header_bytes += frame_size;
- uint8_t *p = GRPC_SLICE_START_PTR(slice);
+ uint8_t* p = GRPC_SLICE_START_PTR(slice);
GPR_ASSERT(window_update);
@@ -49,13 +49,13 @@ grpc_slice grpc_chttp2_window_update_create(
return slice;
}
-grpc_error *grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags) {
+grpc_error* grpc_chttp2_window_update_parser_begin_frame(
+ grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags) {
if (flags || length != 4) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid window update: length=%d, flags=%02x", length,
flags);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -64,14 +64,16 @@ grpc_error *grpc_chttp2_window_update_parser_begin_frame(
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_window_update_parser_parse(
- grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_slice slice, int is_last) {
- uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *const end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_chttp2_window_update_parser *p =
- (grpc_chttp2_window_update_parser *)parser;
+grpc_error* grpc_chttp2_window_update_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_slice slice,
+ int is_last) {
+ uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* const end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_chttp2_window_update_parser* p =
+ (grpc_chttp2_window_update_parser*)parser;
while (p->byte != 4 && cur != end) {
p->amount |= ((uint32_t)*cur) << (8 * (3 - p->byte));
@@ -79,41 +81,37 @@ grpc_error *grpc_chttp2_window_update_parser_parse(
p->byte++;
}
- if (s != NULL) {
+ if (s != nullptr) {
s->stats.incoming.framing_bytes += (uint32_t)(end - cur);
}
if (p->byte == 4) {
uint32_t received_update = p->amount;
if (received_update == 0 || (received_update & 0x80000000u)) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "invalid window update bytes: %d", p->amount);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
GPR_ASSERT(is_last);
if (t->incoming_stream_id != 0) {
- if (s != NULL) {
- grpc_chttp2_flowctl_recv_stream_update(
- &t->flow_control, &s->flow_control, received_update);
+ if (s != nullptr) {
+ s->flow_control->RecvUpdate(received_update);
if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) {
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
- exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE);
+ t, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE);
}
}
} else {
- bool was_zero = t->flow_control.remote_window <= 0;
- grpc_chttp2_flowctl_recv_transport_update(&t->flow_control,
- received_update);
- bool is_zero = t->flow_control.remote_window <= 0;
+ bool was_zero = t->flow_control->remote_window() <= 0;
+ t->flow_control->RecvUpdate(received_update);
+ bool is_zero = t->flow_control->remote_window() <= 0;
if (was_zero && !is_zero) {
grpc_chttp2_initiate_write(
- exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED);
+ t, GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED);
}
}
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h
index 698da4e351..a32f1a9d11 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.h
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h
@@ -31,12 +31,14 @@ typedef struct {
} grpc_chttp2_window_update_parser;
grpc_slice grpc_chttp2_window_update_create(
- uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats *stats);
+ uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats* stats);
-grpc_error *grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags);
-grpc_error *grpc_chttp2_window_update_parser_parse(
- grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_slice slice, int is_last);
+grpc_error* grpc_chttp2_window_update_parser_begin_frame(
+ grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags);
+grpc_error* grpc_chttp2_window_update_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_slice slice,
+ int is_last);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index a404b664e3..3a5692a694 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -51,14 +51,12 @@
/* don't consider adding anything bigger than this to the hpack table */
#define MAX_DECODER_SPACE_USAGE 512
-static grpc_slice_refcount terminal_slice_refcount = {NULL, NULL};
+static grpc_slice_refcount terminal_slice_refcount = {nullptr, nullptr};
static const grpc_slice terminal_slice = {
&terminal_slice_refcount, /* refcount */
- {{0, 0}} /* data.refcounted */
+ {{nullptr, 0}} /* data.refcounted */
};
-extern grpc_tracer_flag grpc_http_trace;
-
typedef struct {
int is_first_frame;
/* number of bytes in 'output' when we started the frame - used to calculate
@@ -70,15 +68,15 @@ typedef struct {
uint8_t seen_regular_header;
/* output stream id */
uint32_t stream_id;
- grpc_slice_buffer *output;
- grpc_transport_one_way_stats *stats;
+ grpc_slice_buffer* output;
+ grpc_transport_one_way_stats* stats;
/* maximum size of a frame */
size_t max_frame_size;
bool use_true_binary_metadata;
} framer_state;
/* fills p (which is expected to be 9 bytes long) with a data frame header */
-static void fill_header(uint8_t *p, uint8_t type, uint32_t id, size_t len,
+static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len,
uint8_t flags) {
GPR_ASSERT(len < 16777316);
*p++ = (uint8_t)(len >> 16);
@@ -93,7 +91,7 @@ static void fill_header(uint8_t *p, uint8_t type, uint32_t id, size_t len,
}
/* finish a frame - fill in the previously reserved header */
-static void finish_frame(framer_state *st, int is_header_boundary,
+static void finish_frame(framer_state* st, int is_header_boundary,
int is_last_in_stream) {
uint8_t type = 0xff;
type = st->is_first_frame ? GRPC_CHTTP2_FRAME_HEADER
@@ -109,7 +107,7 @@ static void finish_frame(framer_state *st, int is_header_boundary,
/* begin a new frame: reserve off header space, remember how many bytes we'd
output before beginning */
-static void begin_frame(framer_state *st) {
+static void begin_frame(framer_state* st) {
st->header_idx =
grpc_slice_buffer_add_indexed(st->output, GRPC_SLICE_MALLOC(9));
st->output_length_at_start_of_frame = st->output->length;
@@ -118,7 +116,7 @@ static void begin_frame(framer_state *st) {
/* make sure that the current frame is of the type desired, and has sufficient
space to add at least about_to_add bytes -- finishes the current frame if
needed */
-static void ensure_space(framer_state *st, size_t need_bytes) {
+static void ensure_space(framer_state* st, size_t need_bytes) {
if (st->output->length - st->output_length_at_start_of_frame + need_bytes <=
st->max_frame_size) {
return;
@@ -128,7 +126,7 @@ static void ensure_space(framer_state *st, size_t need_bytes) {
}
/* increment a filter count, halve all counts if one element reaches max */
-static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) {
+static void inc_filter(uint8_t idx, uint32_t* sum, uint8_t* elems) {
elems[idx]++;
if (elems[idx] < 255) {
(*sum)++;
@@ -142,7 +140,7 @@ static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) {
}
}
-static void add_header_data(framer_state *st, grpc_slice slice) {
+static void add_header_data(framer_state* st, grpc_slice slice) {
size_t len = GRPC_SLICE_LENGTH(slice);
size_t remaining;
if (len == 0) return;
@@ -160,13 +158,13 @@ static void add_header_data(framer_state *st, grpc_slice slice) {
}
}
-static uint8_t *add_tiny_header_data(framer_state *st, size_t len) {
+static uint8_t* add_tiny_header_data(framer_state* st, size_t len) {
ensure_space(st, len);
st->stats->header_bytes += len;
return grpc_slice_buffer_tiny_add(st->output, len);
}
-static void evict_entry(grpc_chttp2_hpack_compressor *c) {
+static void evict_entry(grpc_chttp2_hpack_compressor* c) {
c->tail_remote_index++;
GPR_ASSERT(c->tail_remote_index > 0);
GPR_ASSERT(c->table_size >=
@@ -178,24 +176,19 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
c->table_elems--;
}
-/* add an element to the decoder table */
-static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem) {
- GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
-
- uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
- uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
- uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
+// Reserve space in table for the new element, evict entries if needed.
+// Return the new index of the element. Return 0 to indicate not adding to
+// table.
+static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c,
+ size_t elem_size) {
uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
-
GPR_ASSERT(elem_size < 65536);
if (elem_size > c->max_table_size) {
while (c->table_size > 0) {
evict_entry(c);
}
- return;
+ return 0;
}
/* Reserve space for this element in the remote table: if this overflows
@@ -209,37 +202,24 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
c->table_size = (uint16_t)(c->table_size + elem_size);
c->table_elems++;
- /* Store this element into {entries,indices}_elem */
- if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) {
- /* already there: update with new index */
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
- } else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)],
- elem)) {
- /* already there (cuckoo): update with new index */
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
- } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) {
- /* not there, but a free element: add */
- c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
- } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_3(elem_hash)])) {
- /* not there (cuckoo), but a free element: add */
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
- } else if (c->indices_elems[HASH_FRAGMENT_2(elem_hash)] <
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)]) {
- /* not there: replace oldest */
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
- c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
- } else {
- /* not there: replace oldest */
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ return new_index;
+}
+
+/* dummy function */
+static void add_nothing(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ size_t elem_size) {}
+
+// Add a key to the dynamic table. Both key and value will be added to table at
+// the decoder.
+static void add_key_with_index(grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem elem, uint32_t new_index) {
+ if (new_index == 0) {
+ return;
}
- /* do exactly the same for the key (so we can find by that again too) */
+ uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
+ /* Store the key into {entries,indices}_keys */
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)],
GRPC_MDKEY(elem))) {
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
@@ -258,24 +238,77 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
} else if (c->indices_keys[HASH_FRAGMENT_2(key_hash)] <
c->indices_keys[HASH_FRAGMENT_3(key_hash)]) {
- grpc_slice_unref_internal(exec_ctx,
- c->entries_keys[HASH_FRAGMENT_2(key_hash)]);
+ grpc_slice_unref_internal(c->entries_keys[HASH_FRAGMENT_2(key_hash)]);
c->entries_keys[HASH_FRAGMENT_2(key_hash)] =
grpc_slice_ref_internal(GRPC_MDKEY(elem));
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
} else {
- grpc_slice_unref_internal(exec_ctx,
- c->entries_keys[HASH_FRAGMENT_3(key_hash)]);
+ grpc_slice_unref_internal(c->entries_keys[HASH_FRAGMENT_3(key_hash)]);
c->entries_keys[HASH_FRAGMENT_3(key_hash)] =
grpc_slice_ref_internal(GRPC_MDKEY(elem));
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
}
}
-static void emit_indexed(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
- framer_state *st) {
- GRPC_STATS_INC_HPACK_SEND_INDEXED(exec_ctx);
+/* add an element to the decoder table */
+static void add_elem_with_index(grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem elem, uint32_t new_index) {
+ if (new_index == 0) {
+ return;
+ }
+ GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
+
+ uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
+ uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
+ uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
+
+ /* Store this element into {entries,indices}_elem */
+ if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) {
+ /* already there: update with new index */
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
+ } else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)],
+ elem)) {
+ /* already there (cuckoo): update with new index */
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) {
+ /* not there, but a free element: add */
+ c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
+ } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_3(elem_hash)])) {
+ /* not there (cuckoo), but a free element: add */
+ c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ } else if (c->indices_elems[HASH_FRAGMENT_2(elem_hash)] <
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)]) {
+ /* not there: replace oldest */
+ GRPC_MDELEM_UNREF(c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
+ c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
+ } else {
+ /* not there: replace oldest */
+ GRPC_MDELEM_UNREF(c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
+ c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ }
+
+ add_key_with_index(c, elem, new_index);
+}
+
+static void add_elem(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ size_t elem_size) {
+ uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
+ add_elem_with_index(c, elem, new_index);
+}
+
+static void add_key(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ size_t elem_size) {
+ uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
+ add_key_with_index(c, elem, new_index);
+}
+
+static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index,
+ framer_state* st) {
+ GRPC_STATS_INC_HPACK_SEND_INDEXED();
uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
GRPC_CHTTP2_WRITE_VARINT(elem_index, 1, 0x80, add_tiny_header_data(st, len),
len);
@@ -287,18 +320,17 @@ typedef struct {
bool insert_null_before_wire_value;
} wire_value;
-static wire_value get_wire_value(grpc_exec_ctx *exec_ctx, grpc_mdelem elem,
- bool true_binary_enabled) {
+static wire_value get_wire_value(grpc_mdelem elem, bool true_binary_enabled) {
wire_value wire_val;
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
if (true_binary_enabled) {
- GRPC_STATS_INC_HPACK_SEND_BINARY(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_BINARY();
wire_val.huffman_prefix = 0x00;
wire_val.insert_null_before_wire_value = true;
wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem));
} else {
- GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64();
wire_val.huffman_prefix = 0x80;
wire_val.insert_null_before_wire_value = false;
wire_val.data =
@@ -306,7 +338,7 @@ static wire_value get_wire_value(grpc_exec_ctx *exec_ctx, grpc_mdelem elem,
}
} else {
/* TODO(ctiller): opportunistically compress non-binary headers */
- GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
wire_val.huffman_prefix = 0x00;
wire_val.insert_null_before_wire_value = false;
wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem));
@@ -318,19 +350,17 @@ static size_t wire_value_length(wire_value v) {
return GPR_SLICE_LENGTH(v.data) + v.insert_null_before_wire_value;
}
-static void add_wire_value(framer_state *st, wire_value v) {
+static void add_wire_value(framer_state* st, wire_value v) {
if (v.insert_null_before_wire_value) *add_tiny_header_data(st, 1) = 0;
add_header_data(st, v.data);
}
-static void emit_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor* c,
uint32_t key_index, grpc_mdelem elem,
- framer_state *st) {
- GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(exec_ctx);
+ framer_state* st) {
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX();
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
size_t len_val = wire_value_length(value);
uint32_t len_val_len;
GPR_ASSERT(len_val <= UINT32_MAX);
@@ -342,14 +372,12 @@ static void emit_lithdr_incidx(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_noidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
+static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor* c,
uint32_t key_index, grpc_mdelem elem,
- framer_state *st) {
- GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(exec_ctx);
+ framer_state* st) {
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX();
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
size_t len_val = wire_value_length(value);
uint32_t len_val_len;
GPR_ASSERT(len_val <= UINT32_MAX);
@@ -361,14 +389,14 @@ static void emit_lithdr_noidx(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem, framer_state *st) {
- GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx);
- GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
+static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c,
+ uint32_t unused_index, grpc_mdelem elem,
+ framer_state* st) {
+ GPR_ASSERT(unused_index == 0);
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V();
+ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
uint32_t len_val = (uint32_t)wire_value_length(value);
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
@@ -383,14 +411,14 @@ static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_noidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem, framer_state *st) {
- GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx);
- GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
+static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c,
+ uint32_t unused_index, grpc_mdelem elem,
+ framer_state* st) {
+ GPR_ASSERT(unused_index == 0);
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V();
+ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
uint32_t len_val = (uint32_t)wire_value_length(value);
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
@@ -405,22 +433,22 @@ static void emit_lithdr_noidx_v(grpc_exec_ctx *exec_ctx,
add_wire_value(st, value);
}
-static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor *c,
- framer_state *st) {
+static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor* c,
+ framer_state* st) {
uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(c->max_table_size, 3);
GRPC_CHTTP2_WRITE_VARINT(c->max_table_size, 3, 0x20,
add_tiny_header_data(st, len), len);
c->advertise_table_size_change = 0;
}
-static uint32_t dynidx(grpc_chttp2_hpack_compressor *c, uint32_t elem_index) {
+static uint32_t dynidx(grpc_chttp2_hpack_compressor* c, uint32_t elem_index) {
return 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY + c->tail_remote_index +
c->table_elems - elem_index;
}
/* encode an mdelem */
-static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem, framer_state *st) {
+static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ framer_state* st) {
GPR_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0);
if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */
st->seen_regular_header = 1;
@@ -430,9 +458,14 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
"Reserved header (colon-prefixed) happening after regular ones.");
}
- if (GRPC_TRACER_ON(grpc_http_trace) && !GRPC_MDELEM_IS_INTERNED(elem)) {
- char *k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
- char *v = grpc_slice_to_c_string(GRPC_MDVALUE(elem));
+ if (grpc_http_trace.enabled()) {
+ char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
+ char* v = nullptr;
+ if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
+ v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX);
+ } else {
+ v = grpc_slice_to_c_string(GRPC_MDVALUE(elem));
+ }
gpr_log(
GPR_DEBUG,
"Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
@@ -442,64 +475,69 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
gpr_free(k);
gpr_free(v);
}
- if (!GRPC_MDELEM_IS_INTERNED(elem)) {
- emit_lithdr_noidx_v(exec_ctx, c, elem, st);
+
+ bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem);
+ bool key_interned = elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem));
+
+ // Key is not interned, emit literals.
+ if (!key_interned) {
+ emit_lithdr_noidx_v(c, 0, elem, st);
return;
}
- uint32_t key_hash;
- uint32_t value_hash;
- uint32_t elem_hash;
- size_t decoder_space_usage;
- uint32_t indices_key;
- int should_add_elem;
+ uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
+ uint32_t elem_hash = 0;
- key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
- value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
- elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
+ if (elem_interned) {
+ uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
+ elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
- inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems);
+ inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum,
+ c->filter_elems);
- /* is this elem currently in the decoders table? */
+ /* is this elem currently in the decoders table? */
- if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
- /* HIT: complete element (first cuckoo hash) */
- emit_indexed(exec_ctx, c,
- dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st);
- return;
- }
+ if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
+ /* HIT: complete element (first cuckoo hash) */
+ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]),
+ st);
+ return;
+ }
- if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
- /* HIT: complete element (second cuckoo hash) */
- emit_indexed(exec_ctx, c,
- dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), st);
- return;
+ if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
+ /* HIT: complete element (second cuckoo hash) */
+ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]),
+ st);
+ return;
+ }
}
+ uint32_t indices_key;
+
/* should this elem be in the table? */
- decoder_space_usage = grpc_mdelem_get_size_in_hpack_table(elem);
- should_add_elem = decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
- c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
- c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
+ size_t decoder_space_usage =
+ grpc_mdelem_get_size_in_hpack_table(elem, st->use_true_binary_metadata);
+ bool should_add_elem = elem_interned &&
+ decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
+ c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
+ c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
+ void (*maybe_add)(grpc_chttp2_hpack_compressor*, grpc_mdelem, size_t) =
+ should_add_elem ? add_elem : add_nothing;
+ void (*emit)(grpc_chttp2_hpack_compressor*, uint32_t, grpc_mdelem,
+ framer_state*) =
+ should_add_elem ? emit_lithdr_incidx : emit_lithdr_noidx;
/* no hits for the elem... maybe there's a key? */
-
indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)];
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)],
GRPC_MDKEY(elem)) &&
indices_key > c->tail_remote_index) {
/* HIT: key (first cuckoo hash) */
- if (should_add_elem) {
- emit_lithdr_incidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- add_elem(exec_ctx, c, elem);
- return;
- } else {
- emit_lithdr_noidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- return;
- }
- GPR_UNREACHABLE_CODE(return );
+ emit(c, dynidx(c, indices_key), elem, st);
+ maybe_add(c, elem, decoder_space_usage);
+ return;
}
indices_key = c->indices_keys[HASH_FRAGMENT_3(key_hash)];
@@ -507,56 +545,47 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
GRPC_MDKEY(elem)) &&
indices_key > c->tail_remote_index) {
/* HIT: key (first cuckoo hash) */
- if (should_add_elem) {
- emit_lithdr_incidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- add_elem(exec_ctx, c, elem);
- return;
- } else {
- emit_lithdr_noidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- return;
- }
- GPR_UNREACHABLE_CODE(return );
+ emit(c, dynidx(c, indices_key), elem, st);
+ maybe_add(c, elem, decoder_space_usage);
+ return;
}
/* no elem, key in the table... fall back to literal emission */
-
- if (should_add_elem) {
- emit_lithdr_incidx_v(exec_ctx, c, elem, st);
- add_elem(exec_ctx, c, elem);
- return;
- } else {
- emit_lithdr_noidx_v(exec_ctx, c, elem, st);
- return;
- }
- GPR_UNREACHABLE_CODE(return );
+ bool should_add_key =
+ !elem_interned && decoder_space_usage < MAX_DECODER_SPACE_USAGE;
+ emit = (should_add_elem || should_add_key) ? emit_lithdr_incidx_v
+ : emit_lithdr_noidx_v;
+ maybe_add =
+ should_add_elem ? add_elem : (should_add_key ? add_key : add_nothing);
+ emit(c, 0, elem, st);
+ maybe_add(c, elem, decoder_space_usage);
}
#define STRLEN_LIT(x) (sizeof(x) - 1)
#define TIMEOUT_KEY "grpc-timeout"
-static void deadline_enc(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c, gpr_timespec deadline,
- framer_state *st) {
+static void deadline_enc(grpc_chttp2_hpack_compressor* c, grpc_millis deadline,
+ framer_state* st) {
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
grpc_mdelem mdelem;
- grpc_http2_encode_timeout(
- gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str);
- mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT,
+ grpc_http2_encode_timeout(deadline - grpc_core::ExecCtx::Get()->Now(),
+ timeout_str);
+ mdelem = grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TIMEOUT,
grpc_slice_from_copied_string(timeout_str));
- hpack_enc(exec_ctx, c, mdelem, st);
- GRPC_MDELEM_UNREF(exec_ctx, mdelem);
+ hpack_enc(c, mdelem, st);
+ GRPC_MDELEM_UNREF(mdelem);
}
static uint32_t elems_for_bytes(uint32_t bytes) { return (bytes + 31) / 32; }
-void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
+void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c) {
memset(c, 0, sizeof(*c));
c->max_table_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
c->cap_table_elems = elems_for_bytes(c->max_table_size);
c->max_table_elems = c->cap_table_elems;
c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
c->table_elem_size =
- (uint16_t *)gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
+ (uint16_t*)gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
memset(c->table_elem_size, 0,
sizeof(*c->table_elem_size) * c->cap_table_elems);
for (size_t i = 0; i < GPR_ARRAY_SIZE(c->entries_keys); i++) {
@@ -564,28 +593,27 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
}
}
-void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c) {
+void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c) {
int i;
for (i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
if (c->entries_keys[i].refcount != &terminal_slice_refcount) {
- grpc_slice_unref_internal(exec_ctx, c->entries_keys[i]);
+ grpc_slice_unref_internal(c->entries_keys[i]);
}
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[i]);
+ GRPC_MDELEM_UNREF(c->entries_elems[i]);
}
gpr_free(c->table_elem_size);
}
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, uint32_t max_table_size) {
+ grpc_chttp2_hpack_compressor* c, uint32_t max_table_size) {
c->max_usable_size = max_table_size;
grpc_chttp2_hpack_compressor_set_max_table_size(
c, GPR_MIN(c->max_table_size, max_table_size));
}
-static void rebuild_elems(grpc_chttp2_hpack_compressor *c, uint32_t new_cap) {
- uint16_t *table_elem_size =
- (uint16_t *)gpr_malloc(sizeof(*table_elem_size) * new_cap);
+static void rebuild_elems(grpc_chttp2_hpack_compressor* c, uint32_t new_cap) {
+ uint16_t* table_elem_size =
+ (uint16_t*)gpr_malloc(sizeof(*table_elem_size) * new_cap);
uint32_t i;
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
@@ -603,7 +631,7 @@ static void rebuild_elems(grpc_chttp2_hpack_compressor *c, uint32_t new_cap) {
}
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, uint32_t max_table_size) {
+ grpc_chttp2_hpack_compressor* c, uint32_t max_table_size) {
max_table_size = GPR_MIN(max_table_size, c->max_usable_size);
if (max_table_size == c->max_table_size) {
return;
@@ -622,18 +650,17 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
}
}
c->advertise_table_size_change = 1;
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "set max table size from encoder to %d", max_table_size);
}
}
-void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
- grpc_mdelem **extra_headers,
+void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem** extra_headers,
size_t extra_headers_size,
- grpc_metadata_batch *metadata,
- const grpc_encode_header_options *options,
- grpc_slice_buffer *outbuf) {
+ grpc_metadata_batch* metadata,
+ const grpc_encode_header_options* options,
+ grpc_slice_buffer* outbuf) {
GPR_ASSERT(options->stream_id != 0);
framer_state st;
@@ -654,15 +681,15 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
emit_advertise_table_size_change(c, &st);
}
for (size_t i = 0; i < extra_headers_size; ++i) {
- hpack_enc(exec_ctx, c, *extra_headers[i], &st);
+ hpack_enc(c, *extra_headers[i], &st);
}
grpc_metadata_batch_assert_ok(metadata);
- for (grpc_linked_mdelem *l = metadata->list.head; l; l = l->next) {
- hpack_enc(exec_ctx, c, l->md, &st);
+ for (grpc_linked_mdelem* l = metadata->list.head; l; l = l->next) {
+ hpack_enc(c, l->md, &st);
}
- gpr_timespec deadline = metadata->deadline;
- if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) != 0) {
- deadline_enc(exec_ctx, c, deadline, &st);
+ grpc_millis deadline = metadata->deadline;
+ if (deadline != GRPC_MILLIS_INF_FUTURE) {
+ deadline_enc(c, deadline, &st);
}
finish_frame(&st, 1, options->is_eof);
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
index 271192f894..a26514cab0 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
@@ -34,6 +34,8 @@
/* maximum table size we'll actually use */
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024)
+extern grpc_core::TraceFlag grpc_http_trace;
+
typedef struct {
uint32_t filter_elems_sum;
uint32_t max_table_size;
@@ -64,31 +66,29 @@ typedef struct {
uint32_t indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
uint32_t indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- uint16_t *table_elem_size;
+ uint16_t* table_elem_size;
} grpc_chttp2_hpack_compressor;
-void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c);
-void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c);
+void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c);
+void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c);
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
+ grpc_chttp2_hpack_compressor* c, uint32_t max_table_size);
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
+ grpc_chttp2_hpack_compressor* c, uint32_t max_table_size);
typedef struct {
uint32_t stream_id;
bool is_eof;
bool use_true_binary_metadata;
size_t max_frame_size;
- grpc_transport_one_way_stats *stats;
+ grpc_transport_one_way_stats* stats;
} grpc_encode_header_options;
-void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_compressor *c,
- grpc_mdelem **extra_headers,
+void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c,
+ grpc_mdelem** extra_headers,
size_t extra_headers_size,
- grpc_metadata_batch *metadata,
- const grpc_encode_header_options *options,
- grpc_slice_buffer *outbuf);
+ grpc_metadata_batch* metadata,
+ const grpc_encode_header_options* options,
+ grpc_slice_buffer* outbuf);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
index 3d1df19bc3..ebee5913cb 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
@@ -31,9 +31,10 @@
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/transport/http2_errors.h"
typedef enum {
@@ -60,97 +61,70 @@ typedef enum {
a set of indirect jumps, and so not waste stack space. */
/* forward declarations for parsing states */
-static grpc_error *parse_begin(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end, grpc_error *error);
-static grpc_error *still_parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_illegal_op(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-
-static grpc_error *parse_string_prefix(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_key_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_value_string_with_indexed_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value_string_with_literal_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-
-static grpc_error *parse_value0(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value1(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value2(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value3(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value4(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-
-static grpc_error *parse_indexed_field(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_indexed_field_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_lithdr_incidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_notidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_lithdr_notidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_lithdr_nvridx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end);
-static grpc_error *parse_max_tbl_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
-static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end);
+static grpc_error* parse_begin(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_error(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end, grpc_error* error);
+static grpc_error* still_parse_error(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_illegal_op(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+
+static grpc_error* parse_string_prefix(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_value_string_with_indexed_key(
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_value_string_with_literal_key(
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
+
+static grpc_error* parse_value0(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value1(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value2(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value3(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_value5up(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+
+static grpc_error* parse_indexed_field(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_incidx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end);
+static grpc_error* parse_max_tbl_size(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
+static grpc_error* parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end);
/* we translate the first byte of a hpack field into one of these decoding
cases, then use a lookup table to jump directly to the appropriate parser.
@@ -648,11 +622,16 @@ static const uint8_t inverse_base64[256] = {
};
/* emission helpers */
-static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
- grpc_mdelem md, int add_to_table) {
- if (GRPC_TRACER_ON(grpc_http_trace) && !GRPC_MDELEM_IS_INTERNED(md)) {
- char *k = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char *v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md,
+ int add_to_table) {
+ if (grpc_http_trace.enabled()) {
+ char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char* v = nullptr;
+ if (grpc_is_binary_header(GRPC_MDKEY(md))) {
+ v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
+ } else {
+ v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ }
gpr_log(
GPR_DEBUG,
"Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
@@ -665,26 +644,25 @@ static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
if (add_to_table) {
GPR_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED ||
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
- grpc_error *err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
+ grpc_error* err = grpc_chttp2_hptbl_add(&p->table, md);
if (err != GRPC_ERROR_NONE) return err;
}
- if (p->on_header == NULL) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ if (p->on_header == nullptr) {
+ GRPC_MDELEM_UNREF(md);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set");
}
- p->on_header(exec_ctx, p->on_header_user_data, md);
+ p->on_header(p->on_header_user_data, md);
return GRPC_ERROR_NONE;
}
-static grpc_slice take_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- grpc_chttp2_hpack_parser_string *str,
+static grpc_slice take_string(grpc_chttp2_hpack_parser* p,
+ grpc_chttp2_hpack_parser_string* str,
bool intern) {
grpc_slice s;
if (!str->copied) {
if (intern) {
s = grpc_slice_intern(str->data.referenced);
- grpc_slice_unref_internal(exec_ctx, str->data.referenced);
+ grpc_slice_unref_internal(str->data.referenced);
} else {
s = str->data.referenced;
}
@@ -702,87 +680,79 @@ static grpc_slice take_string(grpc_exec_ctx *exec_ctx,
}
/* jump to the next state */
-static grpc_error *parse_next(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_next(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
p->state = *p->next_state++;
- return p->state(exec_ctx, p, cur, end);
+ return p->state(p, cur, end);
}
/* begin parsing a header: all functionality is encoded into lookup tables
above */
-static grpc_error *parse_begin(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_begin(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_begin;
return GRPC_ERROR_NONE;
}
- return first_byte_action[first_byte_lut[*cur]](exec_ctx, p, cur, end);
+ return first_byte_action[first_byte_lut[*cur]](p, cur, end);
}
/* stream dependency and prioritization data: we just skip it */
-static grpc_error *parse_stream_weight(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_weight(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_weight;
return GRPC_ERROR_NONE;
}
- return p->after_prioritization(exec_ctx, p, cur + 1, end);
+ return p->after_prioritization(p, cur + 1, end);
}
-static grpc_error *parse_stream_dep3(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep3(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep3;
return GRPC_ERROR_NONE;
}
- return parse_stream_weight(exec_ctx, p, cur + 1, end);
+ return parse_stream_weight(p, cur + 1, end);
}
-static grpc_error *parse_stream_dep2(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep2(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep2;
return GRPC_ERROR_NONE;
}
- return parse_stream_dep3(exec_ctx, p, cur + 1, end);
+ return parse_stream_dep3(p, cur + 1, end);
}
-static grpc_error *parse_stream_dep1(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep1(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep1;
return GRPC_ERROR_NONE;
}
- return parse_stream_dep2(exec_ctx, p, cur + 1, end);
+ return parse_stream_dep2(p, cur + 1, end);
}
-static grpc_error *parse_stream_dep0(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_stream_dep0(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep0;
return GRPC_ERROR_NONE;
}
- return parse_stream_dep1(exec_ctx, p, cur + 1, end);
+ return parse_stream_dep1(p, cur + 1, end);
}
/* emit an indexed field; jumps to begin the next field on completion */
-static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_indexed_field(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (GRPC_MDISNULL(md)) {
return grpc_error_set_int(
@@ -792,84 +762,78 @@ static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
}
GRPC_MDELEM_REF(md);
- GRPC_STATS_INC_HPACK_RECV_INDEXED(exec_ctx);
- grpc_error *err = on_hdr(exec_ctx, p, md, 0);
+ GRPC_STATS_INC_HPACK_RECV_INDEXED();
+ grpc_error* err = on_hdr(p, md, 0);
if (err != GRPC_ERROR_NONE) return err;
- return parse_begin(exec_ctx, p, cur, end);
+ return parse_begin(p, cur, end);
}
/* parse an indexed field with index < 127 */
-static grpc_error *parse_indexed_field(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_indexed_field(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
p->dynamic_table_update_allowed = 0;
p->index = (*cur) & 0x7f;
- return finish_indexed_field(exec_ctx, p, cur + 1, end);
+ return finish_indexed_field(p, cur + 1, end);
}
/* parse an indexed field with index >= 127 */
-static grpc_error *parse_indexed_field_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_indexed_field};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = 0x7f;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* finish a literal header with incremental indexing */
-static grpc_error *finish_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_incidx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
- GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(exec_ctx);
- grpc_error *err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
- take_string(exec_ctx, p, &p->value, true)),
- 1);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)),
+ take_string(p, &p->value, true)),
+ 1);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* finish a literal header with incremental indexing with no index */
-static grpc_error *finish_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
- GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(exec_ctx);
- grpc_error *err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
- take_string(exec_ctx, p, &p->value, true)),
- 1);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+static grpc_error* finish_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(take_string(p, &p->key, true),
+ take_string(p, &p->value, true)),
+ 1);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a literal header with incremental indexing; index < 63 */
-static grpc_error *parse_lithdr_incidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_lithdr_incidx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_incidx};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = (*cur) & 0x3f;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* parse a literal header with incremental indexing; index >= 63 */
-static grpc_error *parse_lithdr_incidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_incidx};
@@ -877,71 +841,66 @@ static grpc_error *parse_lithdr_incidx_x(grpc_exec_ctx *exec_ctx,
p->next_state = and_then;
p->index = 0x3f;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* parse a literal header with incremental indexing; index = 0 */
-static grpc_error *parse_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_incidx_v};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* finish a literal header without incremental indexing */
-static grpc_error *finish_lithdr_notidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_notidx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(exec_ctx);
- grpc_error *err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* finish a literal header without incremental indexing with index = 0 */
-static grpc_error *finish_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(exec_ctx);
- grpc_error *err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+static grpc_error* finish_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(take_string(p, &p->key, true),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a literal header without incremental indexing; index < 15 */
-static grpc_error *parse_lithdr_notidx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_notidx};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = (*cur) & 0xf;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* parse a literal header without incremental indexing; index >= 15 */
-static grpc_error *parse_lithdr_notidx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_notidx};
@@ -949,71 +908,66 @@ static grpc_error *parse_lithdr_notidx_x(grpc_exec_ctx *exec_ctx,
p->next_state = and_then;
p->index = 0xf;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* parse a literal header without incremental indexing; index == 0 */
-static grpc_error *parse_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_notidx_v};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* finish a literal header that is never indexed */
-static grpc_error *finish_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(exec_ctx);
- grpc_error *err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* finish a literal header that is never indexed with an extra value */
-static grpc_error *finish_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(exec_ctx);
- grpc_error *err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+static grpc_error* finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(take_string(p, &p->key, true),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a literal header that is never indexed; index < 15 */
-static grpc_error *parse_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_nvridx};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = (*cur) & 0xf;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* parse a literal header that is never indexed; index >= 15 */
-static grpc_error *parse_lithdr_nvridx_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_nvridx};
@@ -1021,60 +975,56 @@ static grpc_error *parse_lithdr_nvridx_x(grpc_exec_ctx *exec_ctx,
p->next_state = and_then;
p->index = 0xf;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* parse a literal header that is never indexed; index == 0 */
-static grpc_error *parse_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_nvridx_v};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* finish parsing a max table size change */
-static grpc_error *finish_max_tbl_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+static grpc_error* finish_max_tbl_size(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
}
- grpc_error *err =
- grpc_chttp2_hptbl_set_current_table_size(exec_ctx, &p->table, p->index);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ grpc_error* err =
+ grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a max table size change, max size < 15 */
-static grpc_error *parse_max_tbl_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_max_tbl_size(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (p->dynamic_table_update_allowed == 0) {
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"More than two max table size changes in a single frame"));
}
p->dynamic_table_update_allowed--;
p->index = (*cur) & 0x1f;
- return finish_max_tbl_size(exec_ctx, p, cur + 1, end);
+ return finish_max_tbl_size(p, cur + 1, end);
}
/* parse a max table size change, max size >= 15 */
-static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur,
+ const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_max_tbl_size};
if (p->dynamic_table_update_allowed == 0) {
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"More than two max table size changes in a single frame"));
}
@@ -1082,13 +1032,12 @@ static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
p->next_state = and_then;
p->index = 0x1f;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* a parse error: jam the parse state into parse_error, and return error */
-static grpc_error *parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end, grpc_error *err) {
+static grpc_error* parse_error(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end, grpc_error* err) {
GPR_ASSERT(err != GRPC_ERROR_NONE);
if (p->last_error == GRPC_ERROR_NONE) {
p->last_error = GRPC_ERROR_REF(err);
@@ -1097,28 +1046,25 @@ static grpc_error *parse_error(grpc_exec_ctx *exec_ctx,
return err;
}
-static grpc_error *still_parse_error(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* still_parse_error(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
return GRPC_ERROR_REF(p->last_error);
}
-static grpc_error *parse_illegal_op(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_illegal_op(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
GPR_ASSERT(cur != end);
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Illegal hpack op code %d", *cur);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
/* parse the 1st byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value0(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value0(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value0;
return GRPC_ERROR_NONE;
@@ -1127,17 +1073,16 @@ static grpc_error *parse_value0(grpc_exec_ctx *exec_ctx,
*p->parsing.value += (*cur) & 0x7f;
if ((*cur) & 0x80) {
- return parse_value1(exec_ctx, p, cur + 1, end);
+ return parse_value1(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 2nd byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value1(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value1(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value1;
return GRPC_ERROR_NONE;
@@ -1146,17 +1091,16 @@ static grpc_error *parse_value1(grpc_exec_ctx *exec_ctx,
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 7;
if ((*cur) & 0x80) {
- return parse_value2(exec_ctx, p, cur + 1, end);
+ return parse_value2(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 3rd byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value2(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value2(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value2;
return GRPC_ERROR_NONE;
@@ -1165,17 +1109,16 @@ static grpc_error *parse_value2(grpc_exec_ctx *exec_ctx,
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 14;
if ((*cur) & 0x80) {
- return parse_value3(exec_ctx, p, cur + 1, end);
+ return parse_value3(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 4th byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error *parse_value3(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value3(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
if (cur == end) {
p->state = parse_value3;
return GRPC_ERROR_NONE;
@@ -1184,21 +1127,20 @@ static grpc_error *parse_value3(grpc_exec_ctx *exec_ctx,
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 21;
if ((*cur) & 0x80) {
- return parse_value4(exec_ctx, p, cur + 1, end);
+ return parse_value4(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 5th byte of a varint into p->parsing.value
depending on the byte, we may overflow, and care must be taken */
-static grpc_error *parse_value4(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
uint8_t c;
uint32_t cur_value;
uint32_t add_value;
- char *msg;
+ char* msg;
if (cur == end) {
p->state = parse_value4;
@@ -1219,9 +1161,9 @@ static grpc_error *parse_value4(grpc_exec_ctx *exec_ctx,
*p->parsing.value = cur_value + add_value;
if ((*cur) & 0x80) {
- return parse_value5up(exec_ctx, p, cur + 1, end);
+ return parse_value5up(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
error:
@@ -1229,17 +1171,16 @@ error:
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x on byte 5",
*p->parsing.value, *cur);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
/* parse any trailing bytes in a varint: it's possible to append an arbitrary
number of 0x80's and not affect the value - a zero will terminate - and
anything else will overflow */
-static grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_value5up(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
while (cur != end && *cur == 0x80) {
++cur;
}
@@ -1250,23 +1191,22 @@ static grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
}
if (*cur == 0) {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
- char *msg;
+ char* msg;
gpr_asprintf(&msg,
"integer overflow in hpack integer decoding: have 0x%08x, "
"got byte 0x%02x sometime after byte 5",
*p->parsing.value, *cur);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
/* parse a string prefix */
-static grpc_error *parse_string_prefix(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* parse_string_prefix(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_string_prefix;
return GRPC_ERROR_NONE;
@@ -1276,31 +1216,30 @@ static grpc_error *parse_string_prefix(grpc_exec_ctx *exec_ctx,
p->huff = (*cur) >> 7;
if (p->strlen == 0x7f) {
p->parsing.value = &p->strlen;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* append some bytes to a string */
-static void append_bytes(grpc_chttp2_hpack_parser_string *str,
- const uint8_t *data, size_t length) {
+static void append_bytes(grpc_chttp2_hpack_parser_string* str,
+ const uint8_t* data, size_t length) {
if (length == 0) return;
if (length + str->data.copied.length > str->data.copied.capacity) {
GPR_ASSERT(str->data.copied.length + length <= UINT32_MAX);
str->data.copied.capacity = (uint32_t)(str->data.copied.length + length);
str->data.copied.str =
- (char *)gpr_realloc(str->data.copied.str, str->data.copied.capacity);
+ (char*)gpr_realloc(str->data.copied.str, str->data.copied.capacity);
}
memcpy(str->data.copied.str + str->data.copied.length, data, length);
GPR_ASSERT(length <= UINT32_MAX - str->data.copied.length);
str->data.copied.length += (uint32_t)length;
}
-static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
- grpc_chttp2_hpack_parser_string *str = p->parsing.str;
+static grpc_error* append_string(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
+ grpc_chttp2_hpack_parser_string* str = p->parsing.str;
uint32_t bits;
uint8_t decoded[3];
switch ((binary_state)p->binary) {
@@ -1316,11 +1255,11 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
/* 'true-binary' case */
++cur;
p->binary = NOT_BINARY;
- GRPC_STATS_INC_HPACK_RECV_BINARY(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_BINARY();
append_bytes(str, cur, (size_t)(end - cur));
return GRPC_ERROR_NONE;
}
- GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64();
/* fallthrough */
b64_byte0:
case B64_BYTE0:
@@ -1332,7 +1271,7 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte0;
@@ -1348,7 +1287,7 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte1;
@@ -1364,7 +1303,7 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte2;
@@ -1380,7 +1319,7 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte3;
@@ -1393,16 +1332,15 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
goto b64_byte0;
}
GPR_UNREACHABLE_CODE(return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
}
-static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* finish_str(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
uint8_t decoded[2];
uint32_t bits;
- grpc_chttp2_hpack_parser_string *str = p->parsing.str;
+ grpc_chttp2_hpack_parser_string* str = p->parsing.str;
switch ((binary_state)p->binary) {
case NOT_BINARY:
break;
@@ -1411,18 +1349,18 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
case B64_BYTE0:
break;
case B64_BYTE1:
- return parse_error(exec_ctx, p, cur, end,
+ return parse_error(p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"illegal base64 encoding")); /* illegal encoding */
case B64_BYTE2:
bits = p->base64_buffer;
if (bits & 0xffff) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "trailing bits in base64 encoding: 0x%04x",
bits & 0xffff);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
decoded[0] = (uint8_t)(bits >> 16);
append_bytes(str, decoded, 1);
@@ -1430,12 +1368,12 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
case B64_BYTE3:
bits = p->base64_buffer;
if (bits & 0xff) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "trailing bits in base64 encoding: 0x%02x",
bits & 0xff);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
decoded[0] = (uint8_t)(bits >> 16);
decoded[1] = (uint8_t)(bits >> 8);
@@ -1446,14 +1384,13 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
}
/* decode a nibble from a huffman encoded stream */
-static grpc_error *huff_nibble(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, uint8_t nibble) {
+static grpc_error* huff_nibble(grpc_chttp2_hpack_parser* p, uint8_t nibble) {
int16_t emit = emit_sub_tbl[16 * emit_tbl[p->huff_state] + nibble];
int16_t next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
if (emit != -1) {
if (emit >= 0 && emit < 256) {
uint8_t c = (uint8_t)emit;
- grpc_error *err = append_string(exec_ctx, p, &c, (&c) + 1);
+ grpc_error* err = append_string(p, &c, (&c) + 1);
if (err != GRPC_ERROR_NONE) return err;
} else {
assert(emit == 256);
@@ -1464,45 +1401,42 @@ static grpc_error *huff_nibble(grpc_exec_ctx *exec_ctx,
}
/* decode full bytes from a huffman encoded stream */
-static grpc_error *add_huff_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* add_huff_bytes(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
for (; cur != end; ++cur) {
- grpc_error *err = huff_nibble(exec_ctx, p, *cur >> 4);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- err = huff_nibble(exec_ctx, p, *cur & 0xf);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
+ grpc_error* err = huff_nibble(p, *cur >> 4);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ err = huff_nibble(p, *cur & 0xf);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
}
return GRPC_ERROR_NONE;
}
/* decode some string bytes based on the current decoding mode
(huffman or not) */
-static grpc_error *add_str_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
+static grpc_error* add_str_bytes(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
if (p->huff) {
- return add_huff_bytes(exec_ctx, p, cur, end);
+ return add_huff_bytes(p, cur, end);
} else {
- return append_string(exec_ctx, p, cur, end);
+ return append_string(p, cur, end);
}
}
/* parse a string - tries to do large chunks at a time */
-static grpc_error *parse_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_string(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+ const uint8_t* end) {
size_t remaining = p->strlen - p->strgot;
size_t given = (size_t)(end - cur);
if (remaining <= given) {
- grpc_error *err = add_str_bytes(exec_ctx, p, cur, cur + remaining);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- err = finish_str(exec_ctx, p, cur + remaining, end);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_next(exec_ctx, p, cur + remaining, end);
+ grpc_error* err = add_str_bytes(p, cur, cur + remaining);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ err = finish_str(p, cur + remaining, end);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_next(p, cur + remaining, end);
} else {
- grpc_error *err = add_str_bytes(exec_ctx, p, cur, cur + given);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
+ grpc_error* err = add_str_bytes(p, cur, cur + given);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
GPR_ASSERT(given <= UINT32_MAX - p->strgot);
p->strgot += (uint32_t)given;
p->state = parse_string;
@@ -1511,20 +1445,19 @@ static grpc_error *parse_string(grpc_exec_ctx *exec_ctx,
}
/* begin parsing a string - performs setup, calls parse_string */
-static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end,
+static grpc_error* begin_parse_string(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end,
uint8_t binary,
- grpc_chttp2_hpack_parser_string *str) {
+ grpc_chttp2_hpack_parser_string* str) {
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
- p->current_slice_refcount != NULL) {
- GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
+ p->current_slice_refcount != nullptr) {
+ GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
str->copied = false;
str->data.referenced.refcount = p->current_slice_refcount;
- str->data.referenced.data.refcounted.bytes = (uint8_t *)cur;
+ str->data.referenced.data.refcounted.bytes = (uint8_t*)cur;
str->data.referenced.data.refcounted.length = p->strlen;
grpc_slice_ref_internal(str->data.referenced);
- return parse_next(exec_ctx, p, cur + p->strlen, end);
+ return parse_next(p, cur + p->strlen, end);
}
p->strgot = 0;
str->copied = true;
@@ -1535,9 +1468,9 @@ static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
switch (p->binary) {
case NOT_BINARY:
if (p->huff) {
- GRPC_STATS_INC_HPACK_RECV_HUFFMAN(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
} else {
- GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
}
break;
case BINARY_BEGIN:
@@ -1546,27 +1479,26 @@ static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
default:
abort();
}
- return parse_string(exec_ctx, p, cur, end);
+ return parse_string(p, cur, end);
}
/* parse the key string */
-static grpc_error *parse_key_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end) {
- return begin_parse_string(exec_ctx, p, cur, end, NOT_BINARY, &p->key);
+static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end) {
+ return begin_parse_string(p, cur, end, NOT_BINARY, &p->key);
}
/* check if a key represents a binary header or not */
-static bool is_binary_literal_header(grpc_chttp2_hpack_parser *p) {
+static bool is_binary_literal_header(grpc_chttp2_hpack_parser* p) {
return grpc_is_binary_header(
p->key.copied ? grpc_slice_from_static_buffer(p->key.data.copied.str,
p->key.data.copied.length)
: p->key.data.referenced);
}
-static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
- bool *is) {
+static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p,
+ bool* is) {
grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (GRPC_MDISNULL(elem)) {
return grpc_error_set_int(
@@ -1580,110 +1512,100 @@ static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
}
/* parse the value string */
-static grpc_error *parse_value_string(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
- const uint8_t *cur, const uint8_t *end,
+static grpc_error* parse_value_string(grpc_chttp2_hpack_parser* p,
+ const uint8_t* cur, const uint8_t* end,
bool is_binary) {
- return begin_parse_string(exec_ctx, p, cur, end,
- is_binary ? BINARY_BEGIN : NOT_BINARY, &p->value);
+ return begin_parse_string(p, cur, end, is_binary ? BINARY_BEGIN : NOT_BINARY,
+ &p->value);
}
-static grpc_error *parse_value_string_with_indexed_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
+static grpc_error* parse_value_string_with_indexed_key(
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) {
bool is_binary = false;
- grpc_error *err = is_binary_indexed_header(p, &is_binary);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_value_string(exec_ctx, p, cur, end, is_binary);
+ grpc_error* err = is_binary_indexed_header(p, &is_binary);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_value_string(p, cur, end, is_binary);
}
-static grpc_error *parse_value_string_with_literal_key(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *cur,
- const uint8_t *end) {
- return parse_value_string(exec_ctx, p, cur, end, is_binary_literal_header(p));
+static grpc_error* parse_value_string_with_literal_key(
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) {
+ return parse_value_string(p, cur, end, is_binary_literal_header(p));
}
/* PUBLIC INTERFACE */
-void grpc_chttp2_hpack_parser_init(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p) {
- p->on_header = NULL;
- p->on_header_user_data = NULL;
+void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p) {
+ p->on_header = nullptr;
+ p->on_header_user_data = nullptr;
p->state = parse_begin;
p->key.data.referenced = grpc_empty_slice();
- p->key.data.copied.str = NULL;
+ p->key.data.copied.str = nullptr;
p->key.data.copied.capacity = 0;
p->key.data.copied.length = 0;
p->value.data.referenced = grpc_empty_slice();
- p->value.data.copied.str = NULL;
+ p->value.data.copied.str = nullptr;
p->value.data.copied.capacity = 0;
p->value.data.copied.length = 0;
p->dynamic_table_update_allowed = 2;
p->last_error = GRPC_ERROR_NONE;
- grpc_chttp2_hptbl_init(exec_ctx, &p->table);
+ grpc_chttp2_hptbl_init(&p->table);
}
-void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p) {
+void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p) {
p->after_prioritization = p->state;
p->state = parse_stream_dep0;
}
-void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p) {
- grpc_chttp2_hptbl_destroy(exec_ctx, &p->table);
+void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser* p) {
+ grpc_chttp2_hptbl_destroy(&p->table);
GRPC_ERROR_UNREF(p->last_error);
- grpc_slice_unref_internal(exec_ctx, p->key.data.referenced);
- grpc_slice_unref_internal(exec_ctx, p->value.data.referenced);
+ grpc_slice_unref_internal(p->key.data.referenced);
+ grpc_slice_unref_internal(p->value.data.referenced);
gpr_free(p->key.data.copied.str);
gpr_free(p->value.data.copied.str);
}
-grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
+grpc_error* grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser* p,
grpc_slice slice) {
/* max number of bytes to parse at a time... limits call stack depth on
* compilers without TCO */
#define MAX_PARSE_LENGTH 1024
p->current_slice_refcount = slice.refcount;
- uint8_t *start = GRPC_SLICE_START_PTR(slice);
- uint8_t *end = GRPC_SLICE_END_PTR(slice);
- grpc_error *error = GRPC_ERROR_NONE;
+ uint8_t* start = GRPC_SLICE_START_PTR(slice);
+ uint8_t* end = GRPC_SLICE_END_PTR(slice);
+ grpc_error* error = GRPC_ERROR_NONE;
while (start != end && error == GRPC_ERROR_NONE) {
- uint8_t *target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
- error = p->state(exec_ctx, p, start, target);
+ uint8_t* target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
+ error = p->state(p, start, target);
start = target;
}
- p->current_slice_refcount = NULL;
+ p->current_slice_refcount = nullptr;
return error;
}
-typedef void (*maybe_complete_func_type)(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+typedef void (*maybe_complete_func_type)(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
static const maybe_complete_func_type maybe_complete_funcs[] = {
grpc_chttp2_maybe_complete_recv_initial_metadata,
grpc_chttp2_maybe_complete_recv_trailing_metadata};
-static void force_client_rst_stream(grpc_exec_ctx *exec_ctx, void *sp,
- grpc_error *error) {
- grpc_chttp2_stream *s = (grpc_chttp2_stream *)sp;
- grpc_chttp2_transport *t = s->t;
+static void force_client_rst_stream(void* sp, grpc_error* error) {
+ grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
+ grpc_chttp2_transport* t = s->t;
if (!s->write_closed) {
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR,
&s->stats.outgoing));
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, GRPC_ERROR_NONE);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
+ grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE);
}
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "final_rst");
+ GRPC_CHTTP2_STREAM_UNREF(s, "final_rst");
}
-static void parse_stream_compression_md(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
- grpc_metadata_batch *initial_metadata) {
- if (initial_metadata->idx.named.content_encoding == NULL ||
+static void parse_stream_compression_md(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_metadata_batch* initial_metadata) {
+ if (initial_metadata->idx.named.content_encoding == nullptr ||
grpc_stream_compression_method_parse(
GRPC_MDVALUE(initial_metadata->idx.named.content_encoding->md), false,
&s->stream_decompression_method) == 0) {
@@ -1692,17 +1614,16 @@ static void parse_stream_compression_md(grpc_exec_ctx *exec_ctx,
}
}
-grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
- void *hpack_parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
- grpc_chttp2_hpack_parser *parser = (grpc_chttp2_hpack_parser *)hpack_parser;
+ grpc_chttp2_hpack_parser* parser = (grpc_chttp2_hpack_parser*)hpack_parser;
GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0);
- if (s != NULL) {
+ if (s != nullptr) {
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
}
- grpc_error *error = grpc_chttp2_hpack_parser_parse(exec_ctx, parser, slice);
+ grpc_error* error = grpc_chttp2_hpack_parser_parse(parser, slice);
if (error != GRPC_ERROR_NONE) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
return error;
@@ -1715,7 +1636,7 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
}
/* need to check for null stream: this can occur if we receive an invalid
stream id on a header */
- if (s != NULL) {
+ if (s != nullptr) {
if (parser->is_boundary) {
if (s->header_frames_received == GPR_ARRAY_SIZE(s->metadata_buffer)) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
@@ -1725,12 +1646,11 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
/* Process stream compression md element if it exists */
if (s->header_frames_received ==
0) { /* Only acts on initial metadata */
- parse_stream_compression_md(exec_ctx, t, s,
- &s->metadata_buffer[0].batch);
+ parse_stream_compression_md(t, s, &s->metadata_buffer[0].batch);
}
s->published_metadata[s->header_frames_received] =
GRPC_METADATA_PUBLISHED_FROM_WIRE;
- maybe_complete_funcs[s->header_frames_received](exec_ctx, t, s);
+ maybe_complete_funcs[s->header_frames_received](t, s);
s->header_frames_received++;
}
if (parser->is_eof) {
@@ -1741,17 +1661,15 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
and can avoid the extra write */
GRPC_CHTTP2_STREAM_REF(s, "final_rst");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(force_client_rst_stream, s,
grpc_combiner_finally_scheduler(t->combiner)),
GRPC_ERROR_NONE);
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false,
- GRPC_ERROR_NONE);
+ grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
}
}
- parser->on_header = NULL;
- parser->on_header_user_data = NULL;
+ parser->on_header = nullptr;
+ parser->on_header_user_data = nullptr;
parser->is_boundary = 0xde;
parser->is_eof = 0xde;
parser->dynamic_table_update_allowed = 2;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h
index 8fbc6a602b..060bc5ce9d 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h
@@ -29,16 +29,15 @@
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
-typedef grpc_error *(*grpc_chttp2_hpack_parser_state)(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, const uint8_t *beg,
- const uint8_t *end);
+typedef grpc_error* (*grpc_chttp2_hpack_parser_state)(
+ grpc_chttp2_hpack_parser* p, const uint8_t* beg, const uint8_t* end);
typedef struct {
bool copied;
struct {
grpc_slice referenced;
struct {
- char *str;
+ char* str;
uint32_t length;
uint32_t capacity;
} copied;
@@ -47,23 +46,23 @@ typedef struct {
struct grpc_chttp2_hpack_parser {
/* user specified callback for each header output */
- void (*on_header)(grpc_exec_ctx *exec_ctx, void *user_data, grpc_mdelem md);
- void *on_header_user_data;
+ void (*on_header)(void* user_data, grpc_mdelem md);
+ void* on_header_user_data;
- grpc_error *last_error;
+ grpc_error* last_error;
/* current parse state - or a function that implements it */
grpc_chttp2_hpack_parser_state state;
/* future states dependent on the opening op code */
- const grpc_chttp2_hpack_parser_state *next_state;
+ const grpc_chttp2_hpack_parser_state* next_state;
/* what to do after skipping prioritization data */
grpc_chttp2_hpack_parser_state after_prioritization;
/* the refcount of the slice that we're currently parsing */
- grpc_slice_refcount *current_slice_refcount;
+ grpc_slice_refcount* current_slice_refcount;
/* the value we're currently parsing */
union {
- uint32_t *value;
- grpc_chttp2_hpack_parser_string *str;
+ uint32_t* value;
+ grpc_chttp2_hpack_parser_string* str;
} parsing;
/* string parameters for each chunk */
grpc_chttp2_hpack_parser_string key;
@@ -92,23 +91,19 @@ struct grpc_chttp2_hpack_parser {
grpc_chttp2_hptbl table;
};
-void grpc_chttp2_hpack_parser_init(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p);
-void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p);
+void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p);
+void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser* p);
-void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p);
+void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p);
-grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hpack_parser *p,
+grpc_error* grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser* p,
grpc_slice slice);
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
the transport */
-grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
- void *hpack_parser,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.c b/src/core/ext/transport/chttp2/transport/hpack_table.cc
index bbd135a318..9fad158d27 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc
@@ -26,16 +26,16 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/debug/trace.h"
-#include "src/core/lib/support/murmur_hash.h"
+#include "src/core/lib/gpr/murmur_hash.h"
-extern grpc_tracer_flag grpc_http_trace;
+extern grpc_core::TraceFlag grpc_http_trace;
static struct {
- const char *key;
- const char *value;
+ const char* key;
+ const char* value;
} static_table[] = {
/* 0: */
- {NULL, NULL},
+ {nullptr, nullptr},
/* 1: */
{":authority", ""},
/* 2: */
@@ -165,7 +165,7 @@ static uint32_t entries_for_bytes(uint32_t bytes) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
}
-void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
+void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl) {
size_t i;
memset(tbl, 0, sizeof(*tbl));
@@ -173,31 +173,28 @@ void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE;
tbl->max_entries = tbl->cap_entries =
entries_for_bytes(tbl->current_table_bytes);
- tbl->ents = (grpc_mdelem *)gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries);
+ tbl->ents = (grpc_mdelem*)gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries);
memset(tbl->ents, 0, sizeof(*tbl->ents) * tbl->cap_entries);
for (i = 1; i <= GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
tbl->static_ents[i - 1] = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_intern(grpc_slice_from_static_string(static_table[i].key)),
grpc_slice_intern(
grpc_slice_from_static_string(static_table[i].value)));
}
}
-void grpc_chttp2_hptbl_destroy(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl) {
+void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl) {
size_t i;
for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
- GRPC_MDELEM_UNREF(exec_ctx, tbl->static_ents[i]);
+ GRPC_MDELEM_UNREF(tbl->static_ents[i]);
}
for (i = 0; i < tbl->num_ents; i++) {
- GRPC_MDELEM_UNREF(exec_ctx,
- tbl->ents[(tbl->first_ent + i) % tbl->cap_entries]);
+ GRPC_MDELEM_UNREF(tbl->ents[(tbl->first_ent + i) % tbl->cap_entries]);
}
gpr_free(tbl->ents);
}
-grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
+grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl,
uint32_t tbl_index) {
/* Static table comes first, just return an entry from it */
if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) {
@@ -215,7 +212,7 @@ grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
}
/* Evict one element from the table */
-static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
+static void evict1(grpc_chttp2_hptbl* tbl) {
grpc_mdelem first_ent = tbl->ents[tbl->first_ent];
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(first_ent)) +
GRPC_SLICE_LENGTH(GRPC_MDVALUE(first_ent)) +
@@ -224,11 +221,11 @@ static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
tbl->mem_used -= (uint32_t)elem_bytes;
tbl->first_ent = ((tbl->first_ent + 1) % tbl->cap_entries);
tbl->num_ents--;
- GRPC_MDELEM_UNREF(exec_ctx, first_ent);
+ GRPC_MDELEM_UNREF(first_ent);
}
-static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
- grpc_mdelem *ents = (grpc_mdelem *)gpr_malloc(sizeof(*ents) * new_cap);
+static void rebuild_ents(grpc_chttp2_hptbl* tbl, uint32_t new_cap) {
+ grpc_mdelem* ents = (grpc_mdelem*)gpr_malloc(sizeof(*ents) * new_cap);
uint32_t i;
for (i = 0; i < tbl->num_ents; i++) {
@@ -240,41 +237,39 @@ static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
tbl->first_ent = 0;
}
-void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl,
uint32_t max_bytes) {
if (tbl->max_bytes == max_bytes) {
return;
}
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes);
}
while (tbl->mem_used > max_bytes) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
tbl->max_bytes = max_bytes;
}
-grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl,
uint32_t bytes) {
if (tbl->current_table_bytes == bytes) {
return GRPC_ERROR_NONE;
}
if (bytes > tbl->max_bytes) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg,
"Attempt to make hpack table %d bytes when max is %d bytes",
bytes, tbl->max_bytes);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
}
while (tbl->mem_used > bytes) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
tbl->current_table_bytes = bytes;
tbl->max_entries = entries_for_bytes(bytes);
@@ -289,21 +284,20 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl, grpc_mdelem md) {
+grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
/* determine how many bytes of buffer this entry represents */
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(md)) +
GRPC_SLICE_LENGTH(GRPC_MDVALUE(md)) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
if (tbl->current_table_bytes > tbl->max_bytes) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg,
"HPACK max table size reduced to %d but not reflected by hpack "
"stream (still at %d)",
tbl->max_bytes, tbl->current_table_bytes);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
@@ -320,14 +314,14 @@ grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
* empty table.
*/
while (tbl->num_ents) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
return GRPC_ERROR_NONE;
}
/* evict entries to ensure no overflow */
while (elem_bytes > (size_t)tbl->current_table_bytes - tbl->mem_used) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
/* copy the finalized entry in */
@@ -341,7 +335,7 @@ grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
}
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
- const grpc_chttp2_hptbl *tbl, grpc_mdelem md) {
+ const grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
grpc_chttp2_hptbl_find_result r = {0, 0};
uint32_t i;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h
index 2cf8f68506..189ad1c697 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.h
@@ -64,26 +64,23 @@ typedef struct {
/* a circular buffer of headers - this is stored in the opposite order to
what hpack specifies, in order to simplify table management a little...
meaning lookups need to SUBTRACT from the end position */
- grpc_mdelem *ents;
+ grpc_mdelem* ents;
grpc_mdelem static_ents[GRPC_CHTTP2_LAST_STATIC_ENTRY];
} grpc_chttp2_hptbl;
/* initialize a hpack table */
-void grpc_chttp2_hptbl_init(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl);
-void grpc_chttp2_hptbl_destroy(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl);
-void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl);
+void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl);
+void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl,
uint32_t max_bytes);
-grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl,
uint32_t bytes);
/* lookup a table entry based on its hpack index */
-grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
+grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl,
uint32_t index);
/* add a table entry to the index */
-grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_hptbl *tbl,
+grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl,
grpc_mdelem md) GRPC_MUST_USE_RESULT;
/* Find a key/value pair in the table... returns the index in the table of the
most similar entry, or 0 if the value was not found */
@@ -92,6 +89,6 @@ typedef struct {
int has_value;
} grpc_chttp2_hptbl_find_result;
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
- const grpc_chttp2_hptbl *tbl, grpc_mdelem md);
+ const grpc_chttp2_hptbl* tbl, grpc_mdelem md);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */
diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.c b/src/core/ext/transport/chttp2/transport/http2_settings.cc
index 46b7c0c49c..0aab864400 100644
--- a/src/core/ext/transport/chttp2/transport/http2_settings.c
+++ b/src/core/ext/transport/chttp2/transport/http2_settings.cc
@@ -25,7 +25,7 @@
const uint16_t grpc_setting_id_to_wire_id[] = {1, 2, 3, 4, 5, 6, 65027};
-bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) {
+bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id* out) {
uint32_t i = wire_id - 1;
uint32_t x = i % 256;
uint32_t y = i / 256;
diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.h b/src/core/ext/transport/chttp2/transport/http2_settings.h
index 706dfc3139..fd15b6977b 100644
--- a/src/core/ext/transport/chttp2/transport/http2_settings.h
+++ b/src/core/ext/transport/chttp2/transport/http2_settings.h
@@ -35,9 +35,10 @@ typedef enum {
} grpc_chttp2_setting_id;
#define GRPC_CHTTP2_NUM_SETTINGS 7
+
extern const uint16_t grpc_setting_id_to_wire_id[];
-bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out);
+bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id* out);
typedef enum {
GRPC_CHTTP2_CLAMP_INVALID_VALUE,
@@ -45,7 +46,7 @@ typedef enum {
} grpc_chttp2_invalid_value_behavior;
typedef struct {
- const char *name;
+ const char* name;
uint32_t default_value;
uint32_t min_value;
uint32_t max_value;
diff --git a/src/core/ext/transport/chttp2/transport/huffsyms.c b/src/core/ext/transport/chttp2/transport/huffsyms.cc
index f28d8cc30a..f28d8cc30a 100644
--- a/src/core/ext/transport/chttp2/transport/huffsyms.c
+++ b/src/core/ext/transport/chttp2/transport/huffsyms.cc
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.c b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
index ba680a89db..ef0c9ed230 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.c
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
@@ -26,49 +26,47 @@
#include <grpc/support/log.h>
void grpc_chttp2_incoming_metadata_buffer_init(
- grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, gpr_arena* arena) {
buffer->arena = arena;
grpc_metadata_batch_init(&buffer->batch);
- buffer->batch.deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
+ buffer->batch.deadline = GRPC_MILLIS_INF_FUTURE;
}
void grpc_chttp2_incoming_metadata_buffer_destroy(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer) {
- grpc_metadata_batch_destroy(exec_ctx, &buffer->batch);
+ grpc_chttp2_incoming_metadata_buffer* buffer) {
+ grpc_metadata_batch_destroy(&buffer->batch);
}
-grpc_error *grpc_chttp2_incoming_metadata_buffer_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
- grpc_mdelem elem) {
+grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) {
buffer->size += GRPC_MDELEM_LENGTH(elem);
return grpc_metadata_batch_add_tail(
- exec_ctx, &buffer->batch, (grpc_linked_mdelem *)gpr_arena_alloc(
- buffer->arena, sizeof(grpc_linked_mdelem)),
+ &buffer->batch,
+ (grpc_linked_mdelem*)gpr_arena_alloc(buffer->arena,
+ sizeof(grpc_linked_mdelem)),
elem);
}
-grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
- grpc_mdelem elem) {
- for (grpc_linked_mdelem *l = buffer->batch.list.head; l != NULL;
+grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) {
+ for (grpc_linked_mdelem* l = buffer->batch.list.head; l != nullptr;
l = l->next) {
if (grpc_slice_eq(GRPC_MDKEY(l->md), GRPC_MDKEY(elem))) {
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ GRPC_MDELEM_UNREF(l->md);
l->md = elem;
return GRPC_ERROR_NONE;
}
}
- return grpc_chttp2_incoming_metadata_buffer_add(exec_ctx, buffer, elem);
+ return grpc_chttp2_incoming_metadata_buffer_add(buffer, elem);
}
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
- grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline) {
buffer->batch.deadline = deadline;
}
void grpc_chttp2_incoming_metadata_buffer_publish(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
- grpc_metadata_batch *batch) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch) {
*batch = buffer->batch;
grpc_metadata_batch_init(&buffer->batch);
}
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
index a951d8764c..b84cd484c4 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
@@ -22,27 +22,26 @@
#include "src/core/lib/transport/transport.h"
typedef struct {
- gpr_arena *arena;
+ gpr_arena* arena;
grpc_metadata_batch batch;
size_t size; // total size of metadata
} grpc_chttp2_incoming_metadata_buffer;
/** assumes everything initially zeroed */
void grpc_chttp2_incoming_metadata_buffer_init(
- grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena);
+ grpc_chttp2_incoming_metadata_buffer* buffer, gpr_arena* arena);
void grpc_chttp2_incoming_metadata_buffer_destroy(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer);
+ grpc_chttp2_incoming_metadata_buffer* buffer);
void grpc_chttp2_incoming_metadata_buffer_publish(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
- grpc_metadata_batch *batch);
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch);
-grpc_error *grpc_chttp2_incoming_metadata_buffer_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
+grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
+ grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) GRPC_MUST_USE_RESULT;
-grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
+grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
+ grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) GRPC_MUST_USE_RESULT;
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
- grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline);
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */
diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h
index 49022155aa..6b6c0b28e2 100644
--- a/src/core/ext/transport/chttp2/transport/internal.h
+++ b/src/core/ext/transport/chttp2/transport/internal.h
@@ -22,6 +22,7 @@
#include <assert.h>
#include <stdbool.h>
+#include "src/core/ext/transport/chttp2/transport/flow_control.h"
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/ext/transport/chttp2/transport/frame_data.h"
#include "src/core/ext/transport/chttp2/transport/frame_goaway.h"
@@ -34,12 +35,11 @@
#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h"
#include "src/core/ext/transport/chttp2/transport/stream_map.h"
#include "src/core/lib/compression/stream_compression.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/transport/bdp_estimator.h"
#include "src/core/lib/transport/connectivity_state.h"
-#include "src/core/lib/transport/pid_controller.h"
#include "src/core/lib/transport/transport_impl.h"
/* streams are kept in various linked lists depending on what things need to
@@ -62,12 +62,6 @@ typedef enum {
} grpc_chttp2_write_state;
typedef enum {
- GRPC_CHTTP2_PING_ON_NEXT_WRITE = 0,
- GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE,
- GRPC_CHTTP2_PING_TYPE_COUNT /* must be last */
-} grpc_chttp2_ping_type;
-
-typedef enum {
GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY,
GRPC_CHTTP2_OPTIMIZE_FOR_THROUGHPUT,
} grpc_chttp2_optimization_target;
@@ -93,7 +87,6 @@ typedef enum {
GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL,
GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL,
GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS,
- GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING,
GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING,
GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE,
GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING,
@@ -103,7 +96,7 @@ typedef enum {
GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM,
} grpc_chttp2_initiate_write_reason;
-const char *grpc_chttp2_initiate_write_reason_string(
+const char* grpc_chttp2_initiate_write_reason_string(
grpc_chttp2_initiate_write_reason reason);
typedef struct {
@@ -114,19 +107,19 @@ typedef struct {
typedef struct {
int max_pings_without_data;
int max_ping_strikes;
- gpr_timespec min_sent_ping_interval_without_data;
- gpr_timespec min_recv_ping_interval_without_data;
+ grpc_millis min_sent_ping_interval_without_data;
+ grpc_millis min_recv_ping_interval_without_data;
} grpc_chttp2_repeated_ping_policy;
typedef struct {
- gpr_timespec last_ping_sent_time;
+ grpc_millis last_ping_sent_time;
int pings_before_data_required;
grpc_timer delayed_ping_timer;
bool is_delayed_ping_timer_set;
} grpc_chttp2_repeated_ping_state;
typedef struct {
- gpr_timespec last_ping_recv_time;
+ grpc_millis last_ping_recv_time;
int ping_strikes;
} grpc_chttp2_server_ping_recv_state;
@@ -174,13 +167,13 @@ typedef enum {
} grpc_chttp2_deframe_transport_state;
typedef struct {
- grpc_chttp2_stream *head;
- grpc_chttp2_stream *tail;
+ grpc_chttp2_stream* head;
+ grpc_chttp2_stream* tail;
} grpc_chttp2_stream_list;
typedef struct {
- grpc_chttp2_stream *next;
- grpc_chttp2_stream *prev;
+ grpc_chttp2_stream* next;
+ grpc_chttp2_stream* prev;
} grpc_chttp2_stream_link;
/* We keep several sets of connection wide parameters */
@@ -204,8 +197,8 @@ typedef enum {
typedef struct grpc_chttp2_write_cb {
int64_t call_at_byte;
- grpc_closure *closure;
- struct grpc_chttp2_write_cb *next;
+ grpc_closure* closure;
+ struct grpc_chttp2_write_cb* next;
} grpc_chttp2_write_cb;
/* forward declared in frame_data.h */
@@ -213,8 +206,8 @@ struct grpc_chttp2_incoming_byte_stream {
grpc_byte_stream base;
gpr_refcount refs;
- grpc_chttp2_transport *transport; /* immutable */
- grpc_chttp2_stream *stream; /* immutable */
+ grpc_chttp2_transport* transport; /* immutable */
+ grpc_chttp2_stream* stream; /* immutable */
/* Accessed only by transport thread when stream->pending_byte_stream == false
* Accessed only by application thread when stream->pending_byte_stream ==
@@ -227,7 +220,7 @@ struct grpc_chttp2_incoming_byte_stream {
struct {
grpc_closure closure;
size_t max_size_hint;
- grpc_closure *on_complete;
+ grpc_closure* on_complete;
} next_action;
grpc_closure destroy_action;
grpc_closure finished_action;
@@ -240,52 +233,15 @@ typedef enum {
GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED,
} grpc_chttp2_keepalive_state;
-typedef struct {
- /** initial window change. This is tracked as we parse settings frames from
- * the remote peer. If there is a positive delta, then we will make all
- * streams readable since they may have become unstalled */
- int64_t initial_window_update;
-
- /** Our bookkeeping for the remote peer's available window */
- int64_t remote_window;
-
- /** calculating what we should give for local window:
- we track the total amount of flow control over initial window size
- across all streams: this is data that we want to receive right now (it
- has an outstanding read)
- and the total amount of flow control under initial window size across all
- streams: this is data we've read early
- we want to adjust incoming_window such that:
- incoming_window = total_over - max(bdp - total_under, 0) */
- int64_t announced_stream_total_over_incoming_window;
- int64_t announced_stream_total_under_incoming_window;
-
- /** This is out window according to what we have sent to our remote peer. The
- * difference between this and target window is what we use to decide when
- * to send WINDOW_UPDATE frames. */
- int64_t announced_window;
-
- /** should we probe bdp? */
- bool enable_bdp_probe;
-
- /* bdp estimation */
- grpc_bdp_estimator bdp_estimator;
-
- /* pid controller */
- grpc_pid_controller pid_controller;
- gpr_timespec last_pid_update;
-
- // pointer back to transport for tracing
- const grpc_chttp2_transport *t;
-} grpc_chttp2_transport_flowctl;
-
struct grpc_chttp2_transport {
grpc_transport base; /* must be first */
gpr_refcount refs;
- grpc_endpoint *ep;
- char *peer_string;
+ grpc_endpoint* ep;
+ char* peer_string;
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
+
+ grpc_closure* notify_on_receive_settings;
/** write execution state of the transport */
grpc_chttp2_write_state write_state;
@@ -297,7 +253,7 @@ struct grpc_chttp2_transport {
/** is the transport destroying itself? */
uint8_t destroying;
/** has the upper layer closed the transport? */
- uint8_t closed;
+ grpc_error* closed_with_error;
/** is there a read request to the endpoint outstanding? */
uint8_t endpoint_reading;
@@ -322,13 +278,13 @@ struct grpc_chttp2_transport {
/** address to place a newly accepted stream - set and unset by
grpc_chttp2_parsing_accept_stream; used by init_stream to
publish the accepted server stream */
- grpc_chttp2_stream **accepting_stream;
+ grpc_chttp2_stream** accepting_stream;
struct {
/* accept stream callback */
- void (*accept_stream)(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_transport *transport, const void *server_data);
- void *accept_stream_user_data;
+ void (*accept_stream)(void* user_data, grpc_transport* transport,
+ const void* server_data);
+ void* accept_stream_user_data;
/** connectivity tracking */
grpc_connectivity_state_tracker state_tracker;
@@ -339,7 +295,7 @@ struct grpc_chttp2_transport {
/** hpack encoding */
grpc_chttp2_hpack_compressor hpack_compressor;
/** is this a client? */
- uint8_t is_client;
+ bool is_client;
/** data to write next write */
grpc_slice_buffer qbuf;
@@ -348,15 +304,16 @@ struct grpc_chttp2_transport {
*/
uint32_t write_buffer_size;
- /** have we seen a goaway */
- uint8_t seen_goaway;
- /** have we sent a goaway */
+ /** Set to a grpc_error object if a goaway frame is received. By default, set
+ * to GRPC_ERROR_NONE */
+ grpc_error* goaway_error;
+
grpc_chttp2_sent_goaway_state sent_goaway_state;
/** are the local settings dirty and need to be sent? */
- uint8_t dirtied_local_settings;
+ bool dirtied_local_settings;
/** have local settings been sent? */
- uint8_t sent_local_settings;
+ bool sent_local_settings;
/** bitmask of setting indexes to send out */
uint32_t force_send_settings;
/** settings values */
@@ -370,7 +327,7 @@ struct grpc_chttp2_transport {
uint32_t last_new_stream_id;
/** ping queues for various ping insertion points */
- grpc_chttp2_ping_queue ping_queues[GRPC_CHTTP2_PING_TYPE_COUNT];
+ grpc_chttp2_ping_queue ping_queue;
grpc_chttp2_repeated_ping_policy ping_policy;
grpc_chttp2_repeated_ping_state ping_state;
uint64_t ping_ctr; /* unique id for pings */
@@ -379,7 +336,7 @@ struct grpc_chttp2_transport {
/** ping acks */
size_t ping_ack_count;
size_t ping_ack_capacity;
- uint64_t *ping_acks;
+ uint64_t* ping_acks;
grpc_chttp2_server_ping_recv_state ping_recv_state;
/** parser for headers */
@@ -394,7 +351,15 @@ struct grpc_chttp2_transport {
/** parser for goaway frames */
grpc_chttp2_goaway_parser goaway_parser;
- grpc_chttp2_transport_flowctl flow_control;
+ grpc_core::PolymorphicManualConstructor<
+ grpc_core::chttp2::TransportFlowControlBase,
+ grpc_core::chttp2::TransportFlowControl,
+ grpc_core::chttp2::TransportFlowControlDisabled>
+ flow_control;
+ /** initial window change. This is tracked as we parse settings frames from
+ * the remote peer. If there is a positive delta, then we will make all
+ * streams readable since they may have become unstalled */
+ int64_t initial_window_update = 0;
/* deframing */
grpc_chttp2_deframe_transport_state deframe_state;
@@ -407,26 +372,21 @@ struct grpc_chttp2_transport {
uint32_t incoming_stream_id;
/* active parser */
- void *parser_data;
- grpc_chttp2_stream *incoming_stream;
- grpc_error *(*parser)(grpc_exec_ctx *exec_ctx, void *parser_user_data,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- grpc_slice slice, int is_last);
-
- /* goaway data */
- grpc_status_code goaway_error;
- uint32_t goaway_last_stream_index;
- grpc_slice goaway_text;
+ void* parser_data;
+ grpc_chttp2_stream* incoming_stream;
+ grpc_error* (*parser)(void* parser_user_data, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_slice slice, int is_last);
- grpc_chttp2_write_cb *write_cb_pool;
+ grpc_chttp2_write_cb* write_cb_pool;
/* bdp estimator */
+ grpc_closure next_bdp_ping_timer_expired_locked;
grpc_closure start_bdp_ping_locked;
grpc_closure finish_bdp_ping_locked;
/* if non-NULL, close the transport with this error when writes are finished
*/
- grpc_error *close_transport_on_writes_finished;
+ grpc_error* close_transport_on_writes_finished;
/* a list of closures to run after writes are finished */
grpc_closure_list run_after_write;
@@ -441,6 +401,10 @@ struct grpc_chttp2_transport {
/** destructive cleanup closure */
grpc_closure destructive_reclaimer_locked;
+ /* next bdp ping timer */
+ bool have_next_bdp_ping_timer;
+ grpc_timer next_bdp_ping_timer;
+
/* keep-alive ping support */
/** Closure to initialize a keepalive ping */
grpc_closure init_keepalive_ping_locked;
@@ -455,9 +419,9 @@ struct grpc_chttp2_transport {
/** watchdog to kill the transport when waiting for the keepalive ping */
grpc_timer keepalive_watchdog_timer;
/** time duration in between pings */
- gpr_timespec keepalive_time;
+ grpc_millis keepalive_time;
/** grace period for a ping to complete before watchdog kicks in */
- gpr_timespec keepalive_timeout;
+ grpc_millis keepalive_timeout;
/** if keepalive pings are allowed when there's no outstanding streams */
bool keepalive_permit_without_calls;
/** keep-alive state machine state */
@@ -471,31 +435,12 @@ typedef enum {
GPRC_METADATA_PUBLISHED_AT_CLOSE
} grpc_published_metadata_method;
-typedef struct {
- /** window available for us to send to peer, over or under the initial window
- * size of the transport... ie:
- * remote_window = remote_window_delta + transport.initial_window_size */
- int64_t remote_window_delta;
-
- /** window available for peer to send to us (as a delta on
- * transport.initial_window_size)
- * local_window = local_window_delta + transport.initial_window_size */
- int64_t local_window_delta;
-
- /** window available for peer to send to us over this stream that we have
- * announced to the peer */
- int64_t announced_window_delta;
-
- // read only pointer back to stream for data
- const grpc_chttp2_stream *s;
-} grpc_chttp2_stream_flowctl;
-
struct grpc_chttp2_stream {
- grpc_chttp2_transport *t;
- grpc_stream_refcount *refcount;
+ grpc_chttp2_transport* t;
+ grpc_stream_refcount* refcount;
grpc_closure destroy_stream;
- grpc_closure *destroy_stream_arg;
+ grpc_closure* destroy_stream_arg;
grpc_chttp2_stream_link links[STREAM_LIST_COUNT];
uint8_t included[STREAM_LIST_COUNT];
@@ -504,29 +449,29 @@ struct grpc_chttp2_stream {
uint32_t id;
/** things the upper layers would like to send */
- grpc_metadata_batch *send_initial_metadata;
- grpc_closure *send_initial_metadata_finished;
- grpc_metadata_batch *send_trailing_metadata;
- grpc_closure *send_trailing_metadata_finished;
+ grpc_metadata_batch* send_initial_metadata;
+ grpc_closure* send_initial_metadata_finished;
+ grpc_metadata_batch* send_trailing_metadata;
+ grpc_closure* send_trailing_metadata_finished;
- grpc_byte_stream *fetching_send_message;
+ grpc_byte_stream* fetching_send_message;
uint32_t fetched_send_message_length;
grpc_slice fetching_slice;
int64_t next_message_end_offset;
int64_t flow_controlled_bytes_written;
int64_t flow_controlled_bytes_flowed;
grpc_closure complete_fetch_locked;
- grpc_closure *fetching_send_message_finished;
+ grpc_closure* fetching_send_message_finished;
- grpc_metadata_batch *recv_initial_metadata;
- grpc_closure *recv_initial_metadata_ready;
- bool *trailing_metadata_available;
- grpc_byte_stream **recv_message;
- grpc_closure *recv_message_ready;
- grpc_metadata_batch *recv_trailing_metadata;
- grpc_closure *recv_trailing_metadata_finished;
+ grpc_metadata_batch* recv_initial_metadata;
+ grpc_closure* recv_initial_metadata_ready;
+ bool* trailing_metadata_available;
+ grpc_byte_stream** recv_message;
+ grpc_closure* recv_message_ready;
+ grpc_metadata_batch* recv_trailing_metadata;
+ grpc_closure* recv_trailing_metadata_finished;
- grpc_transport_stream_stats *collecting_stats;
+ grpc_transport_stream_stats* collecting_stats;
grpc_transport_stream_stats stats;
/** Is this stream closed for writing. */
@@ -545,9 +490,9 @@ struct grpc_chttp2_stream {
bool received_trailing_metadata;
/** the error that resulted in this stream being read-closed */
- grpc_error *read_closed_error;
+ grpc_error* read_closed_error;
/** the error that resulted in this stream being write-closed */
- grpc_error *write_closed_error;
+ grpc_error* write_closed_error;
grpc_published_metadata_method published_metadata[2];
bool final_metadata_requested;
@@ -560,16 +505,16 @@ struct grpc_chttp2_stream {
* Accessed only by application thread when stream->pending_byte_stream ==
* true */
grpc_slice_buffer unprocessed_incoming_frames_buffer;
- grpc_closure *on_next; /* protected by t combiner */
+ grpc_closure* on_next; /* protected by t combiner */
bool pending_byte_stream; /* protected by t combiner */
grpc_closure reset_byte_stream;
- grpc_error *byte_stream_error; /* protected by t combiner */
+ grpc_error* byte_stream_error; /* protected by t combiner */
bool received_last_frame; /* protected by t combiner */
- gpr_timespec deadline;
+ grpc_millis deadline;
/** saw some stream level error */
- grpc_error *forced_close_error;
+ grpc_error* forced_close_error;
/** how many header frames have we received? */
uint8_t header_frames_received;
/** parsing state for data frames */
@@ -583,13 +528,17 @@ struct grpc_chttp2_stream {
bool sent_initial_metadata;
bool sent_trailing_metadata;
- grpc_chttp2_stream_flowctl flow_control;
+ grpc_core::PolymorphicManualConstructor<
+ grpc_core::chttp2::StreamFlowControlBase,
+ grpc_core::chttp2::StreamFlowControl,
+ grpc_core::chttp2::StreamFlowControlDisabled>
+ flow_control;
grpc_slice_buffer flow_controlled_buffer;
- grpc_chttp2_write_cb *on_flow_controlled_cbs;
- grpc_chttp2_write_cb *on_write_finished_cbs;
- grpc_chttp2_write_cb *finish_after_write;
+ grpc_chttp2_write_cb* on_flow_controlled_cbs;
+ grpc_chttp2_write_cb* on_write_finished_cbs;
+ grpc_chttp2_write_cb* finish_after_write;
size_t sending_bytes;
/* Stream compression method to be used. */
@@ -597,9 +546,9 @@ struct grpc_chttp2_stream {
/* Stream decompression method to be used. */
grpc_stream_compression_method stream_decompression_method;
/** Stream compression decompress context */
- grpc_stream_compression_context *stream_decompression_ctx;
+ grpc_stream_compression_context* stream_decompression_ctx;
/** Stream compression compress context */
- grpc_stream_compression_context *stream_compression_ctx;
+ grpc_stream_compression_context* stream_compression_ctx;
/** Buffer storing data that is compressed but not sent */
grpc_slice_buffer compressed_data_buffer;
@@ -627,8 +576,7 @@ struct grpc_chttp2_stream {
The actual call chain is documented in the implementation of this function.
*/
-void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
grpc_chttp2_initiate_write_reason reason);
typedef struct {
@@ -641,151 +589,79 @@ typedef struct {
} grpc_chttp2_begin_write_result;
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t);
-void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error);
+ grpc_chttp2_transport* t);
+void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error);
/** Process one slice of incoming data; return 1 if the connection is still
viable after reading, or 0 if the connection should be torn down */
-grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice slice);
-bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
/** Get a writable stream
returns non-zero if there was a stream available */
-bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-bool grpc_chttp2_list_remove_writable_stream(
- grpc_chttp2_transport *t, grpc_chttp2_stream *s) GRPC_MUST_USE_RESULT;
-
-bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t);
-bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-
-void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-
-void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s);
-bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport* t);
+bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+
+void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+
+void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s);
+bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
/********* Flow Control ***************/
-// we have sent data on the wire
-void grpc_chttp2_flowctl_sent_data(grpc_chttp2_transport_flowctl *tfc,
- grpc_chttp2_stream_flowctl *sfc,
- int64_t size);
-
-// we have received data from the wire
-grpc_error *grpc_chttp2_flowctl_recv_data(grpc_chttp2_transport_flowctl *tfc,
- grpc_chttp2_stream_flowctl *sfc,
- int64_t incoming_frame_size);
-
-// returns an announce if we should send a transport update to our peer,
-// else returns zero
-uint32_t grpc_chttp2_flowctl_maybe_send_transport_update(
- grpc_chttp2_transport_flowctl *tfc);
-
-// returns an announce if we should send a stream update to our peer, else
-// returns zero
-uint32_t grpc_chttp2_flowctl_maybe_send_stream_update(
- grpc_chttp2_transport_flowctl *tfc, grpc_chttp2_stream_flowctl *sfc);
-
-// we have received a WINDOW_UPDATE frame for a transport
-void grpc_chttp2_flowctl_recv_transport_update(
- grpc_chttp2_transport_flowctl *tfc, uint32_t size);
-
-// we have received a WINDOW_UPDATE frame for a stream
-void grpc_chttp2_flowctl_recv_stream_update(grpc_chttp2_transport_flowctl *tfc,
- grpc_chttp2_stream_flowctl *sfc,
- uint32_t size);
-
-// the application is asking for a certain amount of bytes
-void grpc_chttp2_flowctl_incoming_bs_update(grpc_chttp2_transport_flowctl *tfc,
- grpc_chttp2_stream_flowctl *sfc,
- size_t max_size_hint,
- size_t have_already);
-
-void grpc_chttp2_flowctl_destroy_stream(grpc_chttp2_transport_flowctl *tfc,
- grpc_chttp2_stream_flowctl *sfc);
-
-typedef enum {
- // Nothing to be done.
- GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED = 0,
- // Initiate a write to update the initial window immediately.
- GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY,
- // Push the flow control update into a send buffer, to be sent
- // out the next time a write is initiated.
- GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE,
-} grpc_chttp2_flowctl_urgency;
-
-typedef struct {
- grpc_chttp2_flowctl_urgency send_stream_update;
- grpc_chttp2_flowctl_urgency send_transport_update;
- grpc_chttp2_flowctl_urgency send_setting_update;
- uint32_t initial_window_size;
- uint32_t max_frame_size;
- bool need_ping;
-} grpc_chttp2_flowctl_action;
-
-// Reads the flow control data and returns and actionable struct that will tell
-// chttp2 exactly what it needs to do
-grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action(
- grpc_chttp2_transport_flowctl *tfc, grpc_chttp2_stream_flowctl *sfc);
-
-grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_bdp_action(
- grpc_chttp2_transport_flowctl *tfc);
-
// Takes in a flow control action and performs all the needed operations.
-void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_flowctl_action action,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
+void grpc_chttp2_act_on_flowctl_action(
+ const grpc_core::chttp2::FlowControlAction& action,
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s);
/********* End of Flow Control ***************/
-grpc_chttp2_stream *grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
uint32_t id);
-grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
uint32_t id);
-void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
uint32_t goaway_error,
grpc_slice goaway_text);
-void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t);
-void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
- grpc_closure **pclosure,
- grpc_error *error, const char *desc);
+void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_closure** pclosure,
+ grpc_error* error, const char* desc);
#define GRPC_HEADER_SIZE_IN_BYTES 5
#define MAX_SIZE_T (~(size_t)0)
@@ -794,118 +670,94 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \
(sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1)
-extern grpc_tracer_flag grpc_http_trace;
-extern grpc_tracer_flag grpc_flowctl_trace;
+// extern grpc_core::TraceFlag grpc_http_trace;
+// extern grpc_core::TraceFlag grpc_flowctl_trace;
-#ifndef NDEBUG
-#define GRPC_FLOW_CONTROL_IF_TRACING(stmt) \
- if (!(GRPC_TRACER_ON(grpc_flowctl_trace))) \
- ; \
- else \
- stmt
-#else
-#define GRPC_FLOW_CONTROL_IF_TRACING(stmt)
-#endif
+#define GRPC_CHTTP2_IF_TRACING(stmt) \
+ if (!(grpc_http_trace.enabled())) \
+ ; \
+ else \
+ stmt
-#define GRPC_CHTTP2_IF_TRACING(stmt) \
- if (!(GRPC_TRACER_ON(grpc_http_trace))) \
- ; \
- else \
- stmt
-
-void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *stream, grpc_error *error);
-void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, int close_reads,
- int close_writes, grpc_error *error);
-void grpc_chttp2_start_writing(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+void grpc_chttp2_fake_status(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* stream, grpc_error* error);
+void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, int close_reads,
+ int close_writes, grpc_error* error);
+void grpc_chttp2_start_writing(grpc_chttp2_transport* t);
#ifndef NDEBUG
#define GRPC_CHTTP2_STREAM_REF(stream, reason) \
grpc_chttp2_stream_ref(stream, reason)
-#define GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_chttp2_stream_unref(exec_ctx, stream, reason)
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s, const char *reason);
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s,
- const char *reason);
+#define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \
+ grpc_chttp2_stream_unref(stream, reason)
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s, const char* reason);
#else
#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream)
-#define GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_chttp2_stream_unref(exec_ctx, stream)
-void grpc_chttp2_stream_ref(grpc_chttp2_stream *s);
-void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s);
+#define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \
+ grpc_chttp2_stream_unref(stream)
+void grpc_chttp2_stream_ref(grpc_chttp2_stream* s);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s);
#endif
#ifndef NDEBUG
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \
grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__)
-#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) \
- grpc_chttp2_unref_transport(cl, t, r, __FILE__, __LINE__)
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, const char *reason,
- const char *file, int line);
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
- const char *file, int line);
+#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) \
+ grpc_chttp2_unref_transport(t, r, __FILE__, __LINE__)
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line);
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
+ const char* file, int line);
#else
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t)
-#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) grpc_chttp2_unref_transport(cl, t)
-void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-void grpc_chttp2_ref_transport(grpc_chttp2_transport *t);
+#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t)
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t);
+void grpc_chttp2_ref_transport(grpc_chttp2_transport* t);
#endif
-grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- uint32_t frame_size, uint32_t flags);
-grpc_error *grpc_chttp2_incoming_byte_stream_push(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_slice slice, grpc_slice *slice_out);
-grpc_error *grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error, bool reset_on_error);
+grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size,
+ uint32_t flags);
+grpc_error* grpc_chttp2_incoming_byte_stream_push(
+ grpc_chttp2_incoming_byte_stream* bs, grpc_slice slice,
+ grpc_slice* slice_out);
+grpc_error* grpc_chttp2_incoming_byte_stream_finished(
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error,
+ bool reset_on_error);
void grpc_chttp2_incoming_byte_stream_notify(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
- grpc_error *error);
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error);
-void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- uint64_t id);
+void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id);
/** Add a new ping strike to ping_recv_state.ping_strikes. If
ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY
with error code ENHANCE_YOUR_CALM and additional debug data resembling
"too_many_pings" followed by immediately closing the connection. */
-void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
+void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t);
/** add a ref to the stream and add it to the writable list;
ref will be dropped in writing.c */
-void grpc_chttp2_mark_stream_writable(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- grpc_error *due_to_error);
-
-void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s);
-
-void grpc_chttp2_fail_pending_writes(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_error *error);
+void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* due_to_error);
+
+void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s);
+
+void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_error* error);
/** Set the default keepalive configurations, must only be called at
initialization */
-void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
+void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */
diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.cc
index 3db1ad4123..59dc38ef98 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.c
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -31,38 +31,27 @@
#include "src/core/lib/transport/status_conversion.h"
#include "src/core/lib/transport/timeout_encoding.h"
-static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
int is_continuation);
-static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_rst_stream_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_window_update_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_ping_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_goaway_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t);
-static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_data_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_rst_stream_parser(grpc_chttp2_transport* t);
+static grpc_error* init_settings_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_window_update_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_ping_parser(grpc_chttp2_transport* t);
+static grpc_error* init_goaway_parser(grpc_chttp2_transport* t);
+static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t,
int is_header);
-static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_slice slice,
+static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_slice slice,
int is_last);
-grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice slice) {
- uint8_t *beg = GRPC_SLICE_START_PTR(slice);
- uint8_t *end = GRPC_SLICE_END_PTR(slice);
- uint8_t *cur = beg;
- grpc_error *err;
+ uint8_t* beg = GRPC_SLICE_START_PTR(slice);
+ uint8_t* end = GRPC_SLICE_END_PTR(slice);
+ uint8_t* cur = beg;
+ grpc_error* err;
if (cur == end) return GRPC_ERROR_NONE;
@@ -93,7 +82,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
case GRPC_DTS_CLIENT_PREFIX_23:
while (cur != end && t->deframe_state != GRPC_DTS_FH_0) {
if (*cur != GRPC_CHTTP2_CLIENT_CONNECT_STRING[t->deframe_state]) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg,
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
@@ -182,25 +171,26 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(cur < end);
t->incoming_stream_id |= ((uint32_t)*cur);
t->deframe_state = GRPC_DTS_FRAME;
- err = init_frame_parser(exec_ctx, t);
+ err = init_frame_parser(t);
if (err != GRPC_ERROR_NONE) {
return err;
}
if (t->incoming_frame_size == 0) {
- err = parse_frame_slice(exec_ctx, t, grpc_empty_slice(), 1);
+ err = parse_frame_slice(t, grpc_empty_slice(), 1);
if (err != GRPC_ERROR_NONE) {
return err;
}
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_0;
return GRPC_ERROR_NONE;
}
goto dts_fh_0; /* loop */
- } else if (t->incoming_frame_size >
- t->settings[GRPC_ACKED_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]) {
- char *msg;
+ } else if (t->flow_control->flow_control_enabled() &&
+ t->incoming_frame_size >
+ t->settings[GRPC_ACKED_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]) {
+ char* msg;
gpr_asprintf(&msg, "Frame size %d is larger than max frame size %d",
t->incoming_frame_size,
t->settings[GRPC_ACKED_SETTINGS]
@@ -216,20 +206,21 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end);
if ((uint32_t)(end - cur) == t->incoming_frame_size) {
- err = parse_frame_slice(
- exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
- (size_t)(end - beg)),
- 1);
+ err =
+ parse_frame_slice(t,
+ grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
+ (size_t)(end - beg)),
+ 1);
if (err != GRPC_ERROR_NONE) {
return err;
}
t->deframe_state = GRPC_DTS_FH_0;
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
return GRPC_ERROR_NONE;
} else if ((uint32_t)(end - cur) > t->incoming_frame_size) {
size_t cur_offset = (size_t)(cur - beg);
err = parse_frame_slice(
- exec_ctx, t,
+ t,
grpc_slice_sub_no_ref(slice, cur_offset,
cur_offset + t->incoming_frame_size),
1);
@@ -237,105 +228,102 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
return err;
}
cur += t->incoming_frame_size;
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
goto dts_fh_0; /* loop */
} else {
- err = parse_frame_slice(
- exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
- (size_t)(end - beg)),
- 0);
+ err =
+ parse_frame_slice(t,
+ grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
+ (size_t)(end - beg)),
+ 0);
if (err != GRPC_ERROR_NONE) {
return err;
}
t->incoming_frame_size -= (uint32_t)(end - cur);
return GRPC_ERROR_NONE;
}
- GPR_UNREACHABLE_CODE(return 0);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
- GPR_UNREACHABLE_CODE(return 0);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
-static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static grpc_error* init_frame_parser(grpc_chttp2_transport* t) {
if (t->is_first_frame &&
t->incoming_frame_type != GRPC_CHTTP2_FRAME_SETTINGS) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg, "Expected SETTINGS frame as the first frame, got frame type %d",
t->incoming_frame_type);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
t->is_first_frame = false;
if (t->expect_continuation_stream_id != 0) {
if (t->incoming_frame_type != GRPC_CHTTP2_FRAME_CONTINUATION) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Expected CONTINUATION frame, got frame type %02x",
t->incoming_frame_type);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
if (t->expect_continuation_stream_id != t->incoming_stream_id) {
- char *msg;
+ char* msg;
gpr_asprintf(
&msg,
"Expected CONTINUATION frame for grpc_chttp2_stream %08x, got "
"grpc_chttp2_stream %08x",
t->expect_continuation_stream_id, t->incoming_stream_id);
- grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
return err;
}
- return init_header_frame_parser(exec_ctx, t, 1);
+ return init_header_frame_parser(t, 1);
}
switch (t->incoming_frame_type) {
case GRPC_CHTTP2_FRAME_DATA:
- return init_data_frame_parser(exec_ctx, t);
+ return init_data_frame_parser(t);
case GRPC_CHTTP2_FRAME_HEADER:
- return init_header_frame_parser(exec_ctx, t, 0);
+ return init_header_frame_parser(t, 0);
case GRPC_CHTTP2_FRAME_CONTINUATION:
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Unexpected CONTINUATION frame");
case GRPC_CHTTP2_FRAME_RST_STREAM:
- return init_rst_stream_parser(exec_ctx, t);
+ return init_rst_stream_parser(t);
case GRPC_CHTTP2_FRAME_SETTINGS:
- return init_settings_frame_parser(exec_ctx, t);
+ return init_settings_frame_parser(t);
case GRPC_CHTTP2_FRAME_WINDOW_UPDATE:
- return init_window_update_frame_parser(exec_ctx, t);
+ return init_window_update_frame_parser(t);
case GRPC_CHTTP2_FRAME_PING:
- return init_ping_parser(exec_ctx, t);
+ return init_ping_parser(t);
case GRPC_CHTTP2_FRAME_GOAWAY:
- return init_goaway_parser(exec_ctx, t);
+ return init_goaway_parser(t);
default:
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_ERROR, "Unknown frame type %02x", t->incoming_frame_type);
}
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
}
-static grpc_error *skip_parser(grpc_exec_ctx *exec_ctx, void *parser,
- grpc_chttp2_transport *t, grpc_chttp2_stream *s,
- grpc_slice slice, int is_last) {
+static grpc_error* skip_parser(void* parser, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_slice slice,
+ int is_last) {
return GRPC_ERROR_NONE;
}
-static void skip_header(grpc_exec_ctx *exec_ctx, void *tp, grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
-}
+static void skip_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); }
-static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t,
int is_header) {
if (is_header) {
uint8_t is_eoh = t->expect_continuation_stream_id != 0;
t->parser = grpc_chttp2_header_parser_parse;
t->parser_data = &t->hpack_parser;
t->hpack_parser.on_header = skip_header;
- t->hpack_parser.on_header_user_data = NULL;
+ t->hpack_parser.on_header_user_data = nullptr;
t->hpack_parser.is_boundary = is_eoh;
t->hpack_parser.is_eof = (uint8_t)(is_eoh ? t->header_eof : 0);
} else {
@@ -344,34 +332,33 @@ static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- init_skip_frame_parser(exec_ctx, t,
- t->parser == grpc_chttp2_header_parser_parse);
+void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t) {
+ init_skip_frame_parser(t, t->parser == grpc_chttp2_header_parser_parse);
}
-static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_chttp2_stream *s =
+static grpc_error* init_data_frame_parser(grpc_chttp2_transport* t) {
+ grpc_chttp2_stream* s =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- grpc_error *err = GRPC_ERROR_NONE;
- err = grpc_chttp2_flowctl_recv_data(&t->flow_control,
- s == NULL ? NULL : &s->flow_control,
- t->incoming_frame_size);
- grpc_chttp2_act_on_flowctl_action(
- exec_ctx, grpc_chttp2_flowctl_get_action(
- &t->flow_control, s == NULL ? NULL : &s->flow_control),
- t, s);
+ grpc_error* err = GRPC_ERROR_NONE;
+ grpc_core::chttp2::FlowControlAction action;
+ if (s == nullptr) {
+ err = t->flow_control->RecvData(t->incoming_frame_size);
+ action = t->flow_control->MakeAction();
+ } else {
+ err = s->flow_control->RecvData(t->incoming_frame_size);
+ action = s->flow_control->MakeAction();
+ }
+ grpc_chttp2_act_on_flowctl_action(action, t, s);
if (err != GRPC_ERROR_NONE) {
goto error_handler;
}
- if (s == NULL) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ if (s == nullptr) {
+ return init_skip_frame_parser(t, 0);
}
s->received_bytes += t->incoming_frame_size;
s->stats.incoming.framing_bytes += 9;
if (err == GRPC_ERROR_NONE && s->read_closed) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
if (err == GRPC_ERROR_NONE) {
err = grpc_chttp2_data_parser_begin_frame(
@@ -385,37 +372,36 @@ error_handler:
t->parser_data = &s->data_parser;
t->ping_state.pings_before_data_required =
t->ping_policy.max_pings_without_data;
- t->ping_state.last_ping_sent_time = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST;
return GRPC_ERROR_NONE;
- } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
+ } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
/* handle stream errors by closing the stream */
- if (s != NULL) {
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, err);
+ if (s != nullptr) {
+ grpc_chttp2_mark_stream_closed(t, s, true, false, err);
}
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id,
GRPC_HTTP2_PROTOCOL_ERROR,
&s->stats.outgoing));
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
} else {
return err;
}
}
-static void free_timeout(void *p) { gpr_free(p); }
+static void free_timeout(void* p) { gpr_free(p); }
-static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_mdelem md) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
- grpc_chttp2_stream *s = t->incoming_stream;
+static void on_initial_header(void* tp, grpc_mdelem md) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ grpc_chttp2_stream* s = t->incoming_stream;
GPR_TIMER_BEGIN("on_initial_header", 0);
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char *value =
+ if (grpc_http_trace.enabled()) {
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char* value =
grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "HTTP:%d:HDR:%s: %s: %s", s->id,
t->is_client ? "CLI" : "SVR", key, value);
@@ -430,27 +416,30 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
}
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
- gpr_timespec *cached_timeout =
- (gpr_timespec *)grpc_mdelem_get_user_data(md, free_timeout);
- gpr_timespec timeout;
- if (cached_timeout == NULL) {
- /* not already parsed: parse it now, and store the result away */
- cached_timeout = (gpr_timespec *)gpr_malloc(sizeof(gpr_timespec));
- if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), cached_timeout)) {
- char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ grpc_millis* cached_timeout =
+ static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
+ grpc_millis timeout;
+ if (cached_timeout != nullptr) {
+ timeout = *cached_timeout;
+ } else {
+ if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
gpr_free(val);
- *cached_timeout = gpr_inf_future(GPR_TIMESPAN);
+ timeout = GRPC_MILLIS_INF_FUTURE;
}
- timeout = *cached_timeout;
- grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
- } else {
- timeout = *cached_timeout;
+ if (GRPC_MDELEM_IS_INTERNED(md)) {
+ /* store the result */
+ cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
+ *cached_timeout = timeout;
+ grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
+ }
+ }
+ if (timeout != GRPC_MILLIS_INF_FUTURE) {
+ grpc_chttp2_incoming_metadata_buffer_set_deadline(
+ &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout);
}
- grpc_chttp2_incoming_metadata_buffer_set_deadline(
- &s->metadata_buffer[0],
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), timeout));
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md);
const size_t metadata_size_limit =
@@ -462,22 +451,22 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
" vs. %" PRIuPTR ")",
new_size, metadata_size_limit);
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"received initial metadata size exceeds limit"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED));
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
- grpc_error *error = grpc_chttp2_incoming_metadata_buffer_add(
- exec_ctx, &s->metadata_buffer[0], md);
+ grpc_error* error =
+ grpc_chttp2_incoming_metadata_buffer_add(&s->metadata_buffer[0], md);
if (error != GRPC_ERROR_NONE) {
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_cancel_stream(t, s, error);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
}
}
@@ -485,18 +474,17 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
GPR_TIMER_END("on_initial_header", 0);
}
-static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
- grpc_mdelem md) {
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
- grpc_chttp2_stream *s = t->incoming_stream;
+static void on_trailing_header(void* tp, grpc_mdelem md) {
+ grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
+ grpc_chttp2_stream* s = t->incoming_stream;
GPR_TIMER_BEGIN("on_trailing_header", 0);
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char *value =
+ if (grpc_http_trace.enabled()) {
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char* value =
grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "HTTP:%d:TRL:%s: %s: %s", s->id,
t->is_client ? "CLI" : "SVR", key, value);
@@ -520,34 +508,33 @@ static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
" vs. %" PRIuPTR ")",
new_size, metadata_size_limit);
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"received trailing metadata size exceeds limit"),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_RESOURCE_EXHAUSTED));
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
- grpc_error *error = grpc_chttp2_incoming_metadata_buffer_add(
- exec_ctx, &s->metadata_buffer[1], md);
+ grpc_error* error =
+ grpc_chttp2_incoming_metadata_buffer_add(&s->metadata_buffer[1], md);
if (error != GRPC_ERROR_NONE) {
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_cancel_stream(t, s, error);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
}
GPR_TIMER_END("on_trailing_header", 0);
}
-static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
+static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
int is_continuation) {
uint8_t is_eoh =
(t->incoming_frame_flags & GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
- grpc_chttp2_stream *s;
+ grpc_chttp2_stream* s;
/* TODO(ctiller): when to increment header_frames_received? */
@@ -564,16 +551,16 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
t->ping_state.pings_before_data_required =
t->ping_policy.max_pings_without_data;
- t->ping_state.last_ping_sent_time = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST;
/* could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream */
s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- if (s == NULL) {
+ if (s == nullptr) {
if (is_continuation) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR,
"grpc_chttp2_stream disbanded before CONTINUATION received"));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
if (t->is_client) {
if ((t->incoming_stream_id & 1) &&
@@ -583,7 +570,11 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "ignoring new grpc_chttp2_stream creation on client"));
}
- return init_skip_frame_parser(exec_ctx, t, 1);
+ grpc_error* err = init_skip_frame_parser(t, 1);
+ if (t->incoming_frame_flags & GRPC_CHTTP2_FLAG_HAS_PRIORITY) {
+ grpc_chttp2_hpack_parser_set_has_priority(&t->hpack_parser);
+ }
+ return err;
} else if (t->last_new_stream_id >= t->incoming_stream_id) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR,
@@ -591,13 +582,13 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
"last grpc_chttp2_stream "
"id=%d, new grpc_chttp2_stream id=%d",
t->last_new_stream_id, t->incoming_stream_id));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
} else if ((t->incoming_stream_id & 1) == 0) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR,
"ignoring grpc_chttp2_stream with non-client generated index %d",
t->incoming_stream_id));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
} else if (grpc_chttp2_stream_map_size(&t->stream_map) >=
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]) {
@@ -605,22 +596,22 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
}
t->last_new_stream_id = t->incoming_stream_id;
s = t->incoming_stream =
- grpc_chttp2_parsing_accept_stream(exec_ctx, t, t->incoming_stream_id);
- if (s == NULL) {
+ grpc_chttp2_parsing_accept_stream(t, t->incoming_stream_id);
+ if (s == nullptr) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted"));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
} else {
t->incoming_stream = s;
}
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
s->stats.incoming.framing_bytes += 9;
if (s->read_closed) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "skipping already closed grpc_chttp2_stream header"));
- t->incoming_stream = NULL;
- return init_skip_frame_parser(exec_ctx, t, 1);
+ t->incoming_stream = nullptr;
+ return init_skip_frame_parser(t, 1);
}
t->parser = grpc_chttp2_header_parser_parse;
t->parser_data = &t->hpack_parser;
@@ -628,7 +619,7 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
case 0:
if (t->is_client && t->header_eof) {
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing Trailers-Only"));
- if (s->trailing_metadata_available != NULL) {
+ if (s->trailing_metadata_available != nullptr) {
*s->trailing_metadata_available = true;
}
t->hpack_parser.on_header = on_trailing_header;
@@ -645,7 +636,7 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
break;
case 2:
gpr_log(GPR_ERROR, "too many header frames received");
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
t->hpack_parser.on_header_user_data = t;
t->hpack_parser.is_boundary = is_eoh;
@@ -657,17 +648,16 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_window_update_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_window_update_parser_begin_frame(
+static grpc_error* init_window_update_frame_parser(grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_window_update_parser_begin_frame(
&t->simple.window_update, t->incoming_frame_size,
t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
if (t->incoming_stream_id != 0) {
- grpc_chttp2_stream *s = t->incoming_stream =
+ grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- if (s == NULL) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ if (s == nullptr) {
+ return init_skip_frame_parser(t, 0);
}
s->stats.incoming.framing_bytes += 9;
}
@@ -676,9 +666,8 @@ static grpc_error *init_window_update_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_ping_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_ping_parser_begin_frame(
+static grpc_error* init_ping_parser(grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_ping_parser_begin_frame(
&t->simple.ping, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
t->parser = grpc_chttp2_ping_parser_parse;
@@ -686,15 +675,14 @@ static grpc_error *init_ping_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_rst_stream_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_rst_stream_parser_begin_frame(
+static grpc_error* init_rst_stream_parser(grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_rst_stream_parser_begin_frame(
&t->simple.rst_stream, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
- grpc_chttp2_stream *s = t->incoming_stream =
+ grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (!t->incoming_stream) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
s->stats.incoming.framing_bytes += 9;
t->parser = grpc_chttp2_rst_stream_parser_parse;
@@ -702,9 +690,8 @@ static grpc_error *init_rst_stream_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_goaway_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
- grpc_error *err = grpc_chttp2_goaway_parser_begin_frame(
+static grpc_error* init_goaway_parser(grpc_chttp2_transport* t) {
+ grpc_error* err = grpc_chttp2_goaway_parser_begin_frame(
&t->goaway_parser, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
t->parser = grpc_chttp2_goaway_parser_parse;
@@ -712,14 +699,13 @@ static grpc_error *init_goaway_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t) {
+static grpc_error* init_settings_frame_parser(grpc_chttp2_transport* t) {
if (t->incoming_stream_id != 0) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Settings frame received for grpc_chttp2_stream");
}
- grpc_error *err = grpc_chttp2_settings_parser_begin_frame(
+ grpc_error* err = grpc_chttp2_settings_parser_begin_frame(
&t->simple.settings, t->incoming_frame_size, t->incoming_frame_flags,
t->settings[GRPC_PEER_SETTINGS]);
if (err != GRPC_ERROR_NONE) {
@@ -729,7 +715,7 @@ static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
memcpy(t->settings[GRPC_ACKED_SETTINGS], t->settings[GRPC_SENT_SETTINGS],
GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
grpc_chttp2_hptbl_set_max_bytes(
- exec_ctx, &t->hpack_parser.table,
+ &t->hpack_parser.table,
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
t->sent_local_settings = 0;
@@ -739,19 +725,18 @@ static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t, grpc_slice slice,
+static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_slice slice,
int is_last) {
- grpc_chttp2_stream *s = t->incoming_stream;
- grpc_error *err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last);
+ grpc_chttp2_stream* s = t->incoming_stream;
+ grpc_error* err = t->parser(t->parser_data, t, s, slice, is_last);
if (err == GRPC_ERROR_NONE) {
return err;
- } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
- if (GRPC_TRACER_ON(grpc_http_trace)) {
- const char *msg = grpc_error_string(err);
+ } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
+ if (grpc_http_trace.enabled()) {
+ const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
}
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
if (s) {
s->forced_close_error = err;
grpc_slice_buffer_add(
diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.c b/src/core/ext/transport/chttp2/transport/stream_lists.cc
index 47cd22d177..3aad8c5823 100644
--- a/src/core/ext/transport/chttp2/transport/stream_lists.c
+++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc
@@ -16,11 +16,12 @@
*
*/
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include <grpc/support/log.h>
-static char *stream_list_id_string(grpc_chttp2_stream_list_id id) {
+static const char* stream_list_id_string(grpc_chttp2_stream_list_id id) {
switch (id) {
case GRPC_CHTTP2_LIST_WRITABLE:
return "writable";
@@ -38,41 +39,40 @@ static char *stream_list_id_string(grpc_chttp2_stream_list_id id) {
GPR_UNREACHABLE_CODE(return "unknown");
}
-grpc_tracer_flag grpc_trace_http2_stream_state =
- GRPC_TRACER_INITIALIZER(false, "http2_stream_state");
+grpc_core::TraceFlag grpc_trace_http2_stream_state(false, "http2_stream_state");
/* core list management */
-static bool stream_list_empty(grpc_chttp2_transport *t,
+static bool stream_list_empty(grpc_chttp2_transport* t,
grpc_chttp2_stream_list_id id) {
- return t->lists[id].head == NULL;
+ return t->lists[id].head == nullptr;
}
-static bool stream_list_pop(grpc_chttp2_transport *t,
- grpc_chttp2_stream **stream,
+static bool stream_list_pop(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** stream,
grpc_chttp2_stream_list_id id) {
- grpc_chttp2_stream *s = t->lists[id].head;
+ grpc_chttp2_stream* s = t->lists[id].head;
if (s) {
- grpc_chttp2_stream *new_head = s->links[id].next;
+ grpc_chttp2_stream* new_head = s->links[id].next;
GPR_ASSERT(s->included[id]);
if (new_head) {
t->lists[id].head = new_head;
- new_head->links[id].prev = NULL;
+ new_head->links[id].prev = nullptr;
} else {
- t->lists[id].head = NULL;
- t->lists[id].tail = NULL;
+ t->lists[id].head = nullptr;
+ t->lists[id].tail = nullptr;
}
s->included[id] = 0;
}
*stream = s;
- if (s && GRPC_TRACER_ON(grpc_trace_http2_stream_state)) {
+ if (s && grpc_trace_http2_stream_state.enabled()) {
gpr_log(GPR_DEBUG, "%p[%d][%s]: pop from %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}
- return s != 0;
+ return s != nullptr;
}
-static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
GPR_ASSERT(s->included[id]);
s->included[id] = 0;
@@ -87,14 +87,14 @@ static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
} else {
t->lists[id].tail = s->links[id].prev;
}
- if (GRPC_TRACER_ON(grpc_trace_http2_stream_state)) {
+ if (grpc_trace_http2_stream_state.enabled()) {
gpr_log(GPR_DEBUG, "%p[%d][%s]: remove from %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}
}
-static bool stream_list_maybe_remove(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+static bool stream_list_maybe_remove(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
if (s->included[id]) {
stream_list_remove(t, s, id);
@@ -104,13 +104,13 @@ static bool stream_list_maybe_remove(grpc_chttp2_transport *t,
}
}
-static void stream_list_add_tail(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s,
+static void stream_list_add_tail(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
- grpc_chttp2_stream *old_tail;
+ grpc_chttp2_stream* old_tail;
GPR_ASSERT(!s->included[id]);
old_tail = t->lists[id].tail;
- s->links[id].next = NULL;
+ s->links[id].next = nullptr;
s->links[id].prev = old_tail;
if (old_tail) {
old_tail->links[id].next = s;
@@ -119,13 +119,13 @@ static void stream_list_add_tail(grpc_chttp2_transport *t,
}
t->lists[id].tail = s;
s->included[id] = 1;
- if (GRPC_TRACER_ON(grpc_trace_http2_stream_state)) {
+ if (grpc_trace_http2_stream_state.enabled()) {
gpr_log(GPR_DEBUG, "%p[%d][%s]: add to %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}
}
-static bool stream_list_add(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
+static bool stream_list_add(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
if (s->included[id]) {
return false;
@@ -136,77 +136,79 @@ static bool stream_list_add(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
/* wrappers for specializations */
-bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
GPR_ASSERT(s->id != 0);
return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
-bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
-bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
return stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
-bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITING);
}
-bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t) {
+bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport* t) {
return !stream_list_empty(t, GRPC_CHTTP2_LIST_WRITING);
}
-bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WRITING);
}
-void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_add(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
-bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
-void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
-void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ GPR_ASSERT(t->flow_control->flow_control_enabled());
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
-bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
-void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
-void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
+ GPR_ASSERT(t->flow_control->flow_control_enabled());
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
}
-bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream **s) {
+bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream** s) {
return stream_list_pop(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
}
-bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport *t,
- grpc_chttp2_stream *s) {
+bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s) {
return stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
}
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.c b/src/core/ext/transport/chttp2/transport/stream_map.cc
index d6079a9a33..e4f08f5a6c 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.c
+++ b/src/core/ext/transport/chttp2/transport/stream_map.cc
@@ -24,22 +24,22 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
+void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map,
size_t initial_capacity) {
GPR_ASSERT(initial_capacity > 1);
- map->keys = (uint32_t *)gpr_malloc(sizeof(uint32_t) * initial_capacity);
- map->values = (void **)gpr_malloc(sizeof(void *) * initial_capacity);
+ map->keys = (uint32_t*)gpr_malloc(sizeof(uint32_t) * initial_capacity);
+ map->values = (void**)gpr_malloc(sizeof(void*) * initial_capacity);
map->count = 0;
map->free = 0;
map->capacity = initial_capacity;
}
-void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map) {
+void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map* map) {
gpr_free(map->keys);
gpr_free(map->values);
}
-static size_t compact(uint32_t *keys, void **values, size_t count) {
+static size_t compact(uint32_t* keys, void** values, size_t count) {
size_t i, out;
for (i = 0, out = 0; i < count; i++) {
@@ -53,16 +53,16 @@ static size_t compact(uint32_t *keys, void **values, size_t count) {
return out;
}
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
- void *value) {
+void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key,
+ void* value) {
size_t count = map->count;
size_t capacity = map->capacity;
- uint32_t *keys = map->keys;
- void **values = map->values;
+ uint32_t* keys = map->keys;
+ void** values = map->values;
GPR_ASSERT(count == 0 || keys[count - 1] < key);
GPR_ASSERT(value);
- GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == NULL);
+ GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr);
if (count == capacity) {
if (map->free > capacity / 4) {
@@ -73,9 +73,9 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
won't help much */
map->capacity = capacity = 3 * capacity / 2;
map->keys = keys =
- (uint32_t *)gpr_realloc(keys, capacity * sizeof(uint32_t));
+ (uint32_t*)gpr_realloc(keys, capacity * sizeof(uint32_t));
map->values = values =
- (void **)gpr_realloc(values, capacity * sizeof(void *));
+ (void**)gpr_realloc(values, capacity * sizeof(void*));
}
}
@@ -84,15 +84,15 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
map->count = count + 1;
}
-static void **find(grpc_chttp2_stream_map *map, uint32_t key) {
+static void** find(grpc_chttp2_stream_map* map, uint32_t key) {
size_t min_idx = 0;
size_t max_idx = map->count;
size_t mid_idx;
- uint32_t *keys = map->keys;
- void **values = map->values;
+ uint32_t* keys = map->keys;
+ void** values = map->values;
uint32_t mid_key;
- if (max_idx == 0) return NULL;
+ if (max_idx == 0) return nullptr;
while (min_idx < max_idx) {
/* find the midpoint, avoiding overflow */
@@ -109,50 +109,51 @@ static void **find(grpc_chttp2_stream_map *map, uint32_t key) {
}
}
- return NULL;
+ return nullptr;
}
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key) {
- void **pvalue = find(map, key);
- void *out = NULL;
- if (pvalue != NULL) {
+void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key) {
+ void** pvalue = find(map, key);
+ void* out = nullptr;
+ if (pvalue != nullptr) {
out = *pvalue;
- *pvalue = NULL;
- map->free += (out != NULL);
+ *pvalue = nullptr;
+ map->free += (out != nullptr);
/* recognize complete emptyness and ensure we can skip
* defragmentation later */
if (map->free == map->count) {
map->free = map->count = 0;
}
- GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == NULL);
+ GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr);
}
return out;
}
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key) {
- void **pvalue = find(map, key);
- return pvalue != NULL ? *pvalue : NULL;
+void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key) {
+ void** pvalue = find(map, key);
+ return pvalue != nullptr ? *pvalue : nullptr;
}
-size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map) {
+size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map) {
return map->count - map->free;
}
-void *grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map *map) {
+void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map) {
if (map->count == map->free) {
- return NULL;
+ return nullptr;
}
if (map->free != 0) {
map->count = compact(map->keys, map->values, map->count);
map->free = 0;
+ GPR_ASSERT(map->count > 0);
}
return map->values[((size_t)rand()) % map->count];
}
-void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, uint32_t key,
- void *value),
- void *user_data) {
+void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
+ void (*f)(void* user_data, uint32_t key,
+ void* value),
+ void* user_data) {
size_t i;
for (i = 0; i < map->count; i++) {
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.h b/src/core/ext/transport/chttp2/transport/stream_map.h
index 30c50ba32e..9fb8826e8e 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.h
+++ b/src/core/ext/transport/chttp2/transport/stream_map.h
@@ -30,39 +30,39 @@
Adds are restricted to strictly higher keys than previously seen (this is
guaranteed by http2). */
typedef struct {
- uint32_t *keys;
- void **values;
+ uint32_t* keys;
+ void** values;
size_t count;
size_t free;
size_t capacity;
} grpc_chttp2_stream_map;
-void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
+void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map,
size_t initial_capacity);
-void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map);
+void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map* map);
/* Add a new key: given http2 semantics, new keys must always be greater than
existing keys - this is asserted */
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
- void *value);
+void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key,
+ void* value);
/* Delete an existing key - returns the previous value of the key if it existed,
or NULL otherwise */
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key);
+void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key);
/* Return an existing key, or NULL if it does not exist */
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key);
+void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key);
/* Return a random entry */
-void *grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map *map);
+void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map);
/* How many (populated) entries are in the stream map? */
-size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map);
+size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map);
/* Callback on each stream */
-void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, uint32_t key,
- void *value),
- void *user_data);
+void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
+ void (*f)(void* user_data, uint32_t key,
+ void* value),
+ void* user_data);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */
diff --git a/src/core/ext/transport/chttp2/transport/varint.c b/src/core/ext/transport/chttp2/transport/varint.cc
index 0d94ddcbc3..0d94ddcbc3 100644
--- a/src/core/ext/transport/chttp2/transport/varint.c
+++ b/src/core/ext/transport/chttp2/transport/varint.cc
diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c
deleted file mode 100644
index c333a34eb3..0000000000
--- a/src/core/ext/transport/chttp2/transport/writing.c
+++ /dev/null
@@ -1,515 +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/transport/chttp2/transport/internal.h"
-
-#include <limits.h>
-
-#include <grpc/support/log.h>
-
-#include "src/core/lib/debug/stats.h"
-#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/transport/http2_errors.h"
-
-static void add_to_write_list(grpc_chttp2_write_cb **list,
- grpc_chttp2_write_cb *cb) {
- cb->next = *list;
- *list = cb;
-}
-
-static void finish_write_cb(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, grpc_chttp2_write_cb *cb,
- grpc_error *error) {
- grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure, error,
- "finish_write_cb");
- cb->next = t->write_cb_pool;
- t->write_cb_pool = cb;
-}
-
-static void collapse_pings_from_into(grpc_chttp2_transport *t,
- grpc_chttp2_ping_type ping_type,
- grpc_chttp2_ping_queue *pq) {
- for (size_t i = 0; i < GRPC_CHTTP2_PCL_COUNT; i++) {
- grpc_closure_list_move(&t->ping_queues[ping_type].lists[i], &pq->lists[i]);
- }
-}
-
-static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
- grpc_chttp2_transport *t,
- grpc_chttp2_ping_type ping_type) {
- grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type];
- if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
- /* no ping needed: wait */
- return;
- }
- if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) {
- /* ping already in-flight: wait */
- if (GRPC_TRACER_ON(grpc_http_trace) ||
- GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "Ping delayed [%p]: already pinging", t->peer_string);
- }
- return;
- }
- if (t->ping_state.pings_before_data_required == 0 &&
- t->ping_policy.max_pings_without_data != 0) {
- /* need to receive something of substance before sending a ping again */
- if (GRPC_TRACER_ON(grpc_http_trace) ||
- GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "Ping delayed [%p]: too many recent pings: %d/%d",
- t->peer_string, t->ping_state.pings_before_data_required,
- t->ping_policy.max_pings_without_data);
- }
- return;
- }
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec next_allowed_ping =
- gpr_time_add(t->ping_state.last_ping_sent_time,
- t->ping_policy.min_sent_ping_interval_without_data);
- if (t->keepalive_permit_without_calls == 0 &&
- grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
- next_allowed_ping = gpr_time_add(t->ping_recv_state.last_ping_recv_time,
- gpr_time_from_seconds(7200, GPR_TIMESPAN));
- }
- /* gpr_log(GPR_DEBUG, "next_allowed_ping:%d.%09d now:%d.%09d",
- (int)next_allowed_ping.tv_sec, (int)next_allowed_ping.tv_nsec,
- (int)now.tv_sec, (int)now.tv_nsec); */
- if (gpr_time_cmp(next_allowed_ping, now) > 0) {
- /* not enough elapsed time between successive pings */
- if (GRPC_TRACER_ON(grpc_http_trace) ||
- GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG,
- "Ping delayed [%p]: not enough time elapsed since last ping",
- t->peer_string);
- }
- if (!t->ping_state.is_delayed_ping_timer_set) {
- t->ping_state.is_delayed_ping_timer_set = true;
- grpc_timer_init(exec_ctx, &t->ping_state.delayed_ping_timer,
- next_allowed_ping, &t->retry_initiate_ping_locked,
- gpr_now(GPR_CLOCK_MONOTONIC));
- }
- return;
- }
- /* coalesce equivalent pings into this one */
- switch (ping_type) {
- case GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE:
- collapse_pings_from_into(t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, pq);
- break;
- case GRPC_CHTTP2_PING_ON_NEXT_WRITE:
- break;
- case GRPC_CHTTP2_PING_TYPE_COUNT:
- GPR_UNREACHABLE_CODE(break);
- }
- pq->inflight_id = t->ping_ctr * GRPC_CHTTP2_PING_TYPE_COUNT + ping_type;
- t->ping_ctr++;
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
- grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
- &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
- grpc_slice_buffer_add(&t->outbuf,
- grpc_chttp2_ping_create(false, pq->inflight_id));
- GRPC_STATS_INC_HTTP2_PINGS_SENT(exec_ctx);
- t->ping_state.last_ping_sent_time = now;
- if (GRPC_TRACER_ON(grpc_http_trace) ||
- GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "Ping sent [%p]: %d/%d", t->peer_string,
- t->ping_state.pings_before_data_required,
- t->ping_policy.max_pings_without_data);
- }
- t->ping_state.pings_before_data_required -=
- (t->ping_state.pings_before_data_required != 0);
-}
-
-static bool update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_chttp2_stream *s, int64_t send_bytes,
- grpc_chttp2_write_cb **list, int64_t *ctr,
- grpc_error *error) {
- bool sched_any = false;
- grpc_chttp2_write_cb *cb = *list;
- *list = NULL;
- *ctr += send_bytes;
- while (cb) {
- grpc_chttp2_write_cb *next = cb->next;
- if (cb->call_at_byte <= *ctr) {
- sched_any = true;
- finish_write_cb(exec_ctx, t, s, cb, GRPC_ERROR_REF(error));
- } else {
- add_to_write_list(list, cb);
- }
- cb = next;
- }
- GRPC_ERROR_UNREF(error);
- return sched_any;
-}
-
-static bool stream_ref_if_not_destroyed(gpr_refcount *r) {
- gpr_atm count;
- do {
- count = gpr_atm_acq_load(&r->count);
- if (count == 0) return false;
- } while (!gpr_atm_rel_cas(&r->count, count, count + 1));
- return true;
-}
-
-/* How many bytes would we like to put on the wire during a single syscall */
-static uint32_t target_write_size(grpc_chttp2_transport *t) {
- return 1024 * 1024;
-}
-
-// Returns true if initial_metadata contains only default headers.
-static bool is_default_initial_metadata(grpc_metadata_batch *initial_metadata) {
- return initial_metadata->list.default_count == initial_metadata->list.count;
-}
-
-grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
- grpc_chttp2_stream *s;
-
- /* stats histogram counters: we increment these throughout this function,
- and at the end publish to the central stats histograms */
- int flow_control_writes = 0;
- int initial_metadata_writes = 0;
- int trailing_metadata_writes = 0;
- int message_writes = 0;
-
- GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx);
-
- GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0);
-
- if (t->dirtied_local_settings && !t->sent_local_settings) {
- grpc_slice_buffer_add(
- &t->outbuf,
- grpc_chttp2_settings_create(
- t->settings[GRPC_SENT_SETTINGS], t->settings[GRPC_LOCAL_SETTINGS],
- t->force_send_settings, GRPC_CHTTP2_NUM_SETTINGS));
- t->force_send_settings = 0;
- t->dirtied_local_settings = 0;
- t->sent_local_settings = 1;
- GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx);
- }
-
- /* simple writes are queued to qbuf, and flushed here */
- grpc_slice_buffer_move_into(&t->qbuf, &t->outbuf);
- GPR_ASSERT(t->qbuf.count == 0);
-
- grpc_chttp2_hpack_compressor_set_max_table_size(
- &t->hpack_compressor,
- t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
-
- if (t->flow_control.remote_window > 0) {
- while (grpc_chttp2_list_pop_stalled_by_transport(t, &s)) {
- if (!t->closed && grpc_chttp2_list_add_writable_stream(t, s)) {
- stream_ref_if_not_destroyed(&s->refcount->refs);
- }
- }
- }
-
- grpc_chttp2_begin_write_result result = {false, false, false};
-
- /* for each grpc_chttp2_stream that's become writable, frame it's data
- (according to available window sizes) and add to the output buffer */
- while (true) {
- if (t->outbuf.length > target_write_size(t)) {
- result.partial = true;
- break;
- }
-
- if (!grpc_chttp2_list_pop_writable_stream(t, &s)) {
- break;
- }
-
- bool sent_initial_metadata = s->sent_initial_metadata;
- bool now_writing = false;
-
- GRPC_CHTTP2_IF_TRACING(
- gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t,
- t->is_client ? "CLIENT" : "SERVER", s->id,
- sent_initial_metadata, s->send_initial_metadata != NULL,
- (int)(s->flow_control.local_window_delta -
- s->flow_control.announced_window_delta)));
-
- grpc_mdelem *extra_headers_for_trailing_metadata[2];
- size_t num_extra_headers_for_trailing_metadata = 0;
-
- /* send initial metadata if it's available */
- if (!sent_initial_metadata && s->send_initial_metadata != NULL) {
- // We skip this on the server side if there is no custom initial
- // metadata, there are no messages to send, and we are also sending
- // trailing metadata. This results in a Trailers-Only response,
- // which is required for retries, as per:
- // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid
- if (t->is_client || s->fetching_send_message != NULL ||
- s->flow_controlled_buffer.length != 0 ||
- s->send_trailing_metadata == NULL ||
- !is_default_initial_metadata(s->send_initial_metadata)) {
- grpc_encode_header_options hopt = {
- .stream_id = s->id,
- .is_eof = false,
- .use_true_binary_metadata =
- t->settings
- [GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != 0,
- .max_frame_size = t->settings[GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
- .stats = &s->stats.outgoing};
- grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, NULL, 0,
- s->send_initial_metadata, &hopt, &t->outbuf);
- now_writing = true;
- if (!t->is_client) {
- t->ping_recv_state.last_ping_recv_time =
- gpr_inf_past(GPR_CLOCK_MONOTONIC);
- t->ping_recv_state.ping_strikes = 0;
- }
- initial_metadata_writes++;
- } else {
- GRPC_CHTTP2_IF_TRACING(
- gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)"));
- // When sending Trailers-Only, we need to move the :status and
- // content-type headers to the trailers.
- if (s->send_initial_metadata->idx.named.status != NULL) {
- extra_headers_for_trailing_metadata
- [num_extra_headers_for_trailing_metadata++] =
- &s->send_initial_metadata->idx.named.status->md;
- }
- if (s->send_initial_metadata->idx.named.content_type != NULL) {
- extra_headers_for_trailing_metadata
- [num_extra_headers_for_trailing_metadata++] =
- &s->send_initial_metadata->idx.named.content_type->md;
- }
- trailing_metadata_writes++;
- }
- s->send_initial_metadata = NULL;
- s->sent_initial_metadata = true;
- sent_initial_metadata = true;
- result.early_results_scheduled = true;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_initial_metadata_finished, GRPC_ERROR_NONE,
- "send_initial_metadata_finished");
- }
- /* send any window updates */
- uint32_t stream_announce = grpc_chttp2_flowctl_maybe_send_stream_update(
- &t->flow_control, &s->flow_control);
- if (stream_announce > 0) {
- grpc_slice_buffer_add(
- &t->outbuf, grpc_chttp2_window_update_create(s->id, stream_announce,
- &s->stats.outgoing));
- if (!t->is_client) {
- t->ping_recv_state.last_ping_recv_time =
- gpr_inf_past(GPR_CLOCK_MONOTONIC);
- t->ping_recv_state.ping_strikes = 0;
- }
- flow_control_writes++;
- }
- if (sent_initial_metadata) {
- /* send any body bytes, if allowed by flow control */
- if (s->flow_controlled_buffer.length > 0 ||
- s->compressed_data_buffer.length > 0) {
- uint32_t stream_remote_window = (uint32_t)GPR_MAX(
- 0,
- s->flow_control.remote_window_delta +
- (int64_t)t->settings[GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
- uint32_t max_outgoing = (uint32_t)GPR_MIN(
- t->settings[GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
- GPR_MIN(stream_remote_window, t->flow_control.remote_window));
- if (max_outgoing > 0) {
- bool is_last_data_frame = false;
- bool is_last_frame = false;
- size_t sending_bytes_before = s->sending_bytes;
- while ((s->flow_controlled_buffer.length > 0 ||
- s->compressed_data_buffer.length > 0) &&
- max_outgoing > 0) {
- if (s->compressed_data_buffer.length > 0) {
- uint32_t send_bytes = (uint32_t)GPR_MIN(
- max_outgoing, s->compressed_data_buffer.length);
- is_last_data_frame =
- (send_bytes == s->compressed_data_buffer.length &&
- s->flow_controlled_buffer.length == 0 &&
- s->fetching_send_message == NULL);
- is_last_frame =
- is_last_data_frame && s->send_trailing_metadata != NULL &&
- grpc_metadata_batch_is_empty(s->send_trailing_metadata);
- grpc_chttp2_encode_data(s->id, &s->compressed_data_buffer,
- send_bytes, is_last_frame,
- &s->stats.outgoing, &t->outbuf);
- grpc_chttp2_flowctl_sent_data(&t->flow_control, &s->flow_control,
- send_bytes);
- max_outgoing -= send_bytes;
- if (s->compressed_data_buffer.length == 0) {
- s->sending_bytes += s->uncompressed_data_size;
- }
- } else {
- if (s->stream_compression_ctx == NULL) {
- s->stream_compression_ctx =
- grpc_stream_compression_context_create(
- s->stream_compression_method);
- }
- s->uncompressed_data_size = s->flow_controlled_buffer.length;
- GPR_ASSERT(grpc_stream_compress(
- s->stream_compression_ctx, &s->flow_controlled_buffer,
- &s->compressed_data_buffer, NULL, MAX_SIZE_T,
- GRPC_STREAM_COMPRESSION_FLUSH_SYNC));
- }
- }
- if (!t->is_client) {
- t->ping_recv_state.last_ping_recv_time =
- gpr_inf_past(GPR_CLOCK_MONOTONIC);
- t->ping_recv_state.ping_strikes = 0;
- }
- if (is_last_frame) {
- s->send_trailing_metadata = NULL;
- s->sent_trailing_metadata = true;
- if (!t->is_client && !s->read_closed) {
- grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create(
- s->id, GRPC_HTTP2_NO_ERROR,
- &s->stats.outgoing));
- }
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, !t->is_client, 1,
- GRPC_ERROR_NONE);
- }
- result.early_results_scheduled |=
- update_list(exec_ctx, t, s,
- (int64_t)(s->sending_bytes - sending_bytes_before),
- &s->on_flow_controlled_cbs,
- &s->flow_controlled_bytes_flowed, GRPC_ERROR_NONE);
- now_writing = true;
- if (s->flow_controlled_buffer.length > 0 ||
- s->compressed_data_buffer.length > 0) {
- GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:fork");
- grpc_chttp2_list_add_writable_stream(t, s);
- }
- message_writes++;
- } else if (t->flow_control.remote_window == 0) {
- grpc_chttp2_list_add_stalled_by_transport(t, s);
- now_writing = true;
- } else if (stream_remote_window == 0) {
- grpc_chttp2_list_add_stalled_by_stream(t, s);
- now_writing = true;
- }
- }
- if (s->send_trailing_metadata != NULL &&
- s->fetching_send_message == NULL &&
- s->flow_controlled_buffer.length == 0 &&
- s->compressed_data_buffer.length == 0) {
- GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata"));
- if (grpc_metadata_batch_is_empty(s->send_trailing_metadata)) {
- grpc_chttp2_encode_data(s->id, &s->flow_controlled_buffer, 0, true,
- &s->stats.outgoing, &t->outbuf);
- } else {
- grpc_encode_header_options hopt = {
- .stream_id = s->id,
- .is_eof = true,
- .use_true_binary_metadata =
- t->settings
- [GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] !=
- 0,
- .max_frame_size =
- t->settings[GRPC_PEER_SETTINGS]
- [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
- .stats = &s->stats.outgoing};
- grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor,
- extra_headers_for_trailing_metadata,
- num_extra_headers_for_trailing_metadata,
- s->send_trailing_metadata, &hopt,
- &t->outbuf);
- trailing_metadata_writes++;
- }
- s->send_trailing_metadata = NULL;
- s->sent_trailing_metadata = true;
- if (!t->is_client && !s->read_closed) {
- grpc_slice_buffer_add(
- &t->outbuf, grpc_chttp2_rst_stream_create(
- s->id, GRPC_HTTP2_NO_ERROR, &s->stats.outgoing));
- }
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, !t->is_client, 1,
- GRPC_ERROR_NONE);
- now_writing = true;
- result.early_results_scheduled = true;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_trailing_metadata_finished,
- GRPC_ERROR_NONE, "send_trailing_metadata_finished");
- }
- }
-
- if (now_writing) {
- GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(
- exec_ctx, initial_metadata_writes);
- GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, message_writes);
- GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(
- exec_ctx, trailing_metadata_writes);
- GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx,
- flow_control_writes);
-
- if (!grpc_chttp2_list_add_writing_stream(t, s)) {
- /* already in writing list: drop ref */
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:already_writing");
- }
- } else {
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:no_write");
- }
- }
-
- uint32_t transport_announce =
- grpc_chttp2_flowctl_maybe_send_transport_update(&t->flow_control);
- if (transport_announce) {
- maybe_initiate_ping(exec_ctx, t,
- GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE);
- grpc_transport_one_way_stats throwaway_stats;
- grpc_slice_buffer_add(
- &t->outbuf, grpc_chttp2_window_update_create(0, transport_announce,
- &throwaway_stats));
- if (!t->is_client) {
- t->ping_recv_state.last_ping_recv_time =
- gpr_inf_past(GPR_CLOCK_MONOTONIC);
- t->ping_recv_state.ping_strikes = 0;
- }
- }
-
- for (size_t i = 0; i < t->ping_ack_count; i++) {
- grpc_slice_buffer_add(&t->outbuf,
- grpc_chttp2_ping_create(1, t->ping_acks[i]));
- }
- t->ping_ack_count = 0;
-
- maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE);
-
- GPR_TIMER_END("grpc_chttp2_begin_write", 0);
-
- result.writing = t->outbuf.count > 0;
- return result;
-}
-
-void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
- grpc_error *error) {
- GPR_TIMER_BEGIN("grpc_chttp2_end_write", 0);
- grpc_chttp2_stream *s;
-
- while (grpc_chttp2_list_pop_writing_stream(t, &s)) {
- if (s->sending_bytes != 0) {
- update_list(exec_ctx, t, s, (int64_t)s->sending_bytes,
- &s->on_write_finished_cbs, &s->flow_controlled_bytes_written,
- GRPC_ERROR_REF(error));
- s->sending_bytes = 0;
- }
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:end");
- }
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &t->outbuf);
- GRPC_ERROR_UNREF(error);
- GPR_TIMER_END("grpc_chttp2_end_write", 0);
-}
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
new file mode 100644
index 0000000000..9a6f5e9bcf
--- /dev/null
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -0,0 +1,637 @@
+/*
+ *
+ * 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/transport/chttp2/transport/internal.h"
+
+#include <limits.h>
+
+#include <grpc/support/log.h>
+
+#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/profiling/timers.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/transport/http2_errors.h"
+
+static void add_to_write_list(grpc_chttp2_write_cb** list,
+ grpc_chttp2_write_cb* cb) {
+ cb->next = *list;
+ *list = cb;
+}
+
+static void finish_write_cb(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_chttp2_write_cb* cb, grpc_error* error) {
+ grpc_chttp2_complete_closure_step(t, s, &cb->closure, error,
+ "finish_write_cb");
+ cb->next = t->write_cb_pool;
+ t->write_cb_pool = cb;
+}
+
+static void maybe_initiate_ping(grpc_chttp2_transport* t) {
+ grpc_chttp2_ping_queue* pq = &t->ping_queue;
+ if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
+ /* no ping needed: wait */
+ return;
+ }
+ if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) {
+ /* ping already in-flight: wait */
+ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: already pinging",
+ t->is_client ? "CLIENT" : "SERVER", t->peer_string);
+ }
+ return;
+ }
+ if (t->ping_state.pings_before_data_required == 0 &&
+ t->ping_policy.max_pings_without_data != 0) {
+ /* need to receive something of substance before sending a ping again */
+ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: too many recent pings: %d/%d",
+ t->is_client ? "CLIENT" : "SERVER", t->peer_string,
+ t->ping_state.pings_before_data_required,
+ t->ping_policy.max_pings_without_data);
+ }
+ return;
+ }
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+
+ grpc_millis next_allowed_ping_interval =
+ (t->keepalive_permit_without_calls == 0 &&
+ grpc_chttp2_stream_map_size(&t->stream_map) == 0)
+ ? 7200 * GPR_MS_PER_SEC
+ : t->ping_policy.min_sent_ping_interval_without_data;
+ grpc_millis next_allowed_ping =
+ t->ping_state.last_ping_sent_time + next_allowed_ping_interval;
+
+ if (next_allowed_ping > now) {
+ /* not enough elapsed time between successive pings */
+ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "%s: Ping delayed [%p]: not enough time elapsed since last ping. "
+ " Last ping %f: Next ping %f: Now %f",
+ t->is_client ? "CLIENT" : "SERVER", t->peer_string,
+ (double)t->ping_state.last_ping_sent_time,
+ (double)next_allowed_ping, (double)now);
+ }
+ if (!t->ping_state.is_delayed_ping_timer_set) {
+ t->ping_state.is_delayed_ping_timer_set = true;
+ grpc_timer_init(&t->ping_state.delayed_ping_timer, next_allowed_ping,
+ &t->retry_initiate_ping_locked);
+ }
+ return;
+ }
+
+ pq->inflight_id = t->ping_ctr;
+ t->ping_ctr++;
+ GRPC_CLOSURE_LIST_SCHED(&pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
+ grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
+ &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
+ grpc_slice_buffer_add(&t->outbuf,
+ grpc_chttp2_ping_create(false, pq->inflight_id));
+ GRPC_STATS_INC_HTTP2_PINGS_SENT();
+ t->ping_state.last_ping_sent_time = now;
+ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "%s: Ping sent [%p]: %d/%d",
+ t->is_client ? "CLIENT" : "SERVER", t->peer_string,
+ t->ping_state.pings_before_data_required,
+ t->ping_policy.max_pings_without_data);
+ }
+ t->ping_state.pings_before_data_required -=
+ (t->ping_state.pings_before_data_required != 0);
+}
+
+static bool update_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ int64_t send_bytes, grpc_chttp2_write_cb** list,
+ int64_t* ctr, grpc_error* error) {
+ bool sched_any = false;
+ grpc_chttp2_write_cb* cb = *list;
+ *list = nullptr;
+ *ctr += send_bytes;
+ while (cb) {
+ grpc_chttp2_write_cb* next = cb->next;
+ if (cb->call_at_byte <= *ctr) {
+ sched_any = true;
+ finish_write_cb(t, s, cb, GRPC_ERROR_REF(error));
+ } else {
+ add_to_write_list(list, cb);
+ }
+ cb = next;
+ }
+ GRPC_ERROR_UNREF(error);
+ return sched_any;
+}
+
+static void report_stall(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ const char* staller) {
+ gpr_log(
+ GPR_DEBUG,
+ "%s:%p stream %d stalled by %s [fc:pending=%" PRIdPTR
+ ":pending-compressed=%" PRIdPTR ":flowed=%" PRId64
+ ":peer_initwin=%d:t_win=%" PRId64 ":s_win=%d:s_delta=%" PRId64 "]",
+ t->peer_string, t, s->id, staller, s->flow_controlled_buffer.length,
+ s->compressed_data_buffer.length, s->flow_controlled_bytes_flowed,
+ t->settings[GRPC_ACKED_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
+ t->flow_control->remote_window(),
+ (uint32_t)GPR_MAX(
+ 0,
+ s->flow_control->remote_window_delta() +
+ (int64_t)t->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]),
+ s->flow_control->remote_window_delta());
+}
+
+static bool stream_ref_if_not_destroyed(gpr_refcount* r) {
+ gpr_atm count;
+ do {
+ count = gpr_atm_acq_load(&r->count);
+ if (count == 0) return false;
+ } while (!gpr_atm_rel_cas(&r->count, count, count + 1));
+ return true;
+}
+
+/* How many bytes would we like to put on the wire during a single syscall */
+static uint32_t target_write_size(grpc_chttp2_transport* t) {
+ return 1024 * 1024;
+}
+
+// Returns true if initial_metadata contains only default headers.
+static bool is_default_initial_metadata(grpc_metadata_batch* initial_metadata) {
+ return initial_metadata->list.default_count == initial_metadata->list.count;
+}
+
+namespace {
+class StreamWriteContext;
+
+class WriteContext {
+ public:
+ WriteContext(grpc_chttp2_transport* t) : t_(t) {
+ GRPC_STATS_INC_HTTP2_WRITES_BEGUN();
+ GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0);
+ }
+
+ // TODO(ctiller): make this the destructor
+ void FlushStats() {
+ GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(
+ initial_metadata_writes_);
+ GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(message_writes_);
+ GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(
+ trailing_metadata_writes_);
+ GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(flow_control_writes_);
+ }
+
+ void FlushSettings() {
+ if (t_->dirtied_local_settings && !t_->sent_local_settings) {
+ grpc_slice_buffer_add(
+ &t_->outbuf, grpc_chttp2_settings_create(
+ t_->settings[GRPC_SENT_SETTINGS],
+ t_->settings[GRPC_LOCAL_SETTINGS],
+ t_->force_send_settings, GRPC_CHTTP2_NUM_SETTINGS));
+ t_->force_send_settings = false;
+ t_->dirtied_local_settings = false;
+ t_->sent_local_settings = true;
+ GRPC_STATS_INC_HTTP2_SETTINGS_WRITES();
+ }
+ }
+
+ void FlushQueuedBuffers() {
+ /* simple writes are queued to qbuf, and flushed here */
+ grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf);
+ GPR_ASSERT(t_->qbuf.count == 0);
+ }
+
+ void FlushWindowUpdates() {
+ uint32_t transport_announce =
+ t_->flow_control->MaybeSendUpdate(t_->outbuf.count > 0);
+ if (transport_announce) {
+ grpc_transport_one_way_stats throwaway_stats;
+ grpc_slice_buffer_add(
+ &t_->outbuf, grpc_chttp2_window_update_create(0, transport_announce,
+ &throwaway_stats));
+ ResetPingRecvClock();
+ }
+ }
+
+ void FlushPingAcks() {
+ for (size_t i = 0; i < t_->ping_ack_count; i++) {
+ grpc_slice_buffer_add(&t_->outbuf,
+ grpc_chttp2_ping_create(true, t_->ping_acks[i]));
+ }
+ t_->ping_ack_count = 0;
+ }
+
+ void EnactHpackSettings() {
+ grpc_chttp2_hpack_compressor_set_max_table_size(
+ &t_->hpack_compressor,
+ t_->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
+ }
+
+ void UpdateStreamsNoLongerStalled() {
+ grpc_chttp2_stream* s;
+ while (grpc_chttp2_list_pop_stalled_by_transport(t_, &s)) {
+ if (t_->closed_with_error == GRPC_ERROR_NONE &&
+ grpc_chttp2_list_add_writable_stream(t_, s)) {
+ if (!stream_ref_if_not_destroyed(&s->refcount->refs)) {
+ grpc_chttp2_list_remove_writable_stream(t_, s);
+ }
+ }
+ }
+ }
+
+ grpc_chttp2_stream* NextStream() {
+ if (t_->outbuf.length > target_write_size(t_)) {
+ result_.partial = true;
+ return nullptr;
+ }
+
+ grpc_chttp2_stream* s;
+ if (!grpc_chttp2_list_pop_writable_stream(t_, &s)) {
+ return nullptr;
+ }
+
+ return s;
+ }
+
+ void ResetPingRecvClock() {
+ if (!t_->is_client) {
+ t_->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST;
+ t_->ping_recv_state.ping_strikes = 0;
+ }
+ }
+
+ void IncInitialMetadataWrites() { ++initial_metadata_writes_; }
+ void IncWindowUpdateWrites() { ++flow_control_writes_; }
+ void IncMessageWrites() { ++message_writes_; }
+ void IncTrailingMetadataWrites() { ++trailing_metadata_writes_; }
+
+ void NoteScheduledResults() { result_.early_results_scheduled = true; }
+
+ grpc_chttp2_transport* transport() const { return t_; }
+
+ grpc_chttp2_begin_write_result Result() {
+ result_.writing = t_->outbuf.count > 0;
+ return result_;
+ }
+
+ private:
+ grpc_chttp2_transport* const t_;
+
+ /* stats histogram counters: we increment these throughout this function,
+ and at the end publish to the central stats histograms */
+ int flow_control_writes_ = 0;
+ int initial_metadata_writes_ = 0;
+ int trailing_metadata_writes_ = 0;
+ int message_writes_ = 0;
+ grpc_chttp2_begin_write_result result_ = {false, false, false};
+};
+
+class DataSendContext {
+ public:
+ DataSendContext(WriteContext* write_context, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s)
+ : write_context_(write_context),
+ t_(t),
+ s_(s),
+ sending_bytes_before_(s_->sending_bytes) {}
+
+ uint32_t stream_remote_window() const {
+ return (uint32_t)GPR_MAX(
+ 0, s_->flow_control->remote_window_delta() +
+ (int64_t)t_->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
+ }
+
+ uint32_t max_outgoing() const {
+ return (uint32_t)GPR_MIN(
+ t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
+ GPR_MIN(stream_remote_window(), t_->flow_control->remote_window()));
+ }
+
+ bool AnyOutgoing() const { return max_outgoing() > 0; }
+
+ void FlushCompressedBytes() {
+ uint32_t send_bytes =
+ (uint32_t)GPR_MIN(max_outgoing(), s_->compressed_data_buffer.length);
+ bool is_last_data_frame =
+ (send_bytes == s_->compressed_data_buffer.length &&
+ s_->flow_controlled_buffer.length == 0 &&
+ s_->fetching_send_message == nullptr);
+ if (is_last_data_frame && s_->send_trailing_metadata != nullptr &&
+ s_->stream_compression_ctx != nullptr) {
+ if (!grpc_stream_compress(
+ s_->stream_compression_ctx, &s_->flow_controlled_buffer,
+ &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
+ GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) {
+ gpr_log(GPR_ERROR, "Stream compression failed.");
+ }
+ grpc_stream_compression_context_destroy(s_->stream_compression_ctx);
+ s_->stream_compression_ctx = nullptr;
+ /* After finish, bytes in s->compressed_data_buffer may be
+ * more than max_outgoing. Start another round of the current
+ * while loop so that send_bytes and is_last_data_frame are
+ * recalculated. */
+ return;
+ }
+ is_last_frame_ = is_last_data_frame &&
+ s_->send_trailing_metadata != nullptr &&
+ grpc_metadata_batch_is_empty(s_->send_trailing_metadata);
+ grpc_chttp2_encode_data(s_->id, &s_->compressed_data_buffer, send_bytes,
+ is_last_frame_, &s_->stats.outgoing, &t_->outbuf);
+ s_->flow_control->SentData(send_bytes);
+ if (s_->compressed_data_buffer.length == 0) {
+ s_->sending_bytes += s_->uncompressed_data_size;
+ }
+ }
+
+ void CompressMoreBytes() {
+ if (s_->stream_compression_ctx == nullptr) {
+ s_->stream_compression_ctx =
+ grpc_stream_compression_context_create(s_->stream_compression_method);
+ }
+ s_->uncompressed_data_size = s_->flow_controlled_buffer.length;
+ if (!grpc_stream_compress(s_->stream_compression_ctx,
+ &s_->flow_controlled_buffer,
+ &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
+ GRPC_STREAM_COMPRESSION_FLUSH_SYNC)) {
+ gpr_log(GPR_ERROR, "Stream compression failed.");
+ }
+ }
+
+ bool is_last_frame() const { return is_last_frame_; }
+
+ void CallCallbacks() {
+ if (update_list(t_, s_,
+ (int64_t)(s_->sending_bytes - sending_bytes_before_),
+ &s_->on_flow_controlled_cbs,
+ &s_->flow_controlled_bytes_flowed, GRPC_ERROR_NONE)) {
+ write_context_->NoteScheduledResults();
+ }
+ }
+
+ private:
+ WriteContext* write_context_;
+ grpc_chttp2_transport* t_;
+ grpc_chttp2_stream* s_;
+ const size_t sending_bytes_before_;
+ bool is_last_frame_ = false;
+};
+
+class StreamWriteContext {
+ public:
+ StreamWriteContext(WriteContext* write_context, grpc_chttp2_stream* s)
+ : write_context_(write_context), t_(write_context->transport()), s_(s) {
+ GRPC_CHTTP2_IF_TRACING(
+ gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_,
+ t_->is_client ? "CLIENT" : "SERVER", s->id,
+ s->sent_initial_metadata, s->send_initial_metadata != nullptr,
+ (int)(s->flow_control->local_window_delta() -
+ s->flow_control->announced_window_delta())));
+ }
+
+ void FlushInitialMetadata() {
+ /* send initial metadata if it's available */
+ if (s_->sent_initial_metadata) return;
+ if (s_->send_initial_metadata == nullptr) return;
+
+ // We skip this on the server side if there is no custom initial
+ // metadata, there are no messages to send, and we are also sending
+ // trailing metadata. This results in a Trailers-Only response,
+ // which is required for retries, as per:
+ // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid
+ if (!t_->is_client && s_->fetching_send_message == nullptr &&
+ s_->flow_controlled_buffer.length == 0 &&
+ s_->compressed_data_buffer.length == 0 &&
+ s_->send_trailing_metadata != nullptr &&
+ is_default_initial_metadata(s_->send_initial_metadata)) {
+ ConvertInitialMetadataToTrailingMetadata();
+ } else {
+ grpc_encode_header_options hopt = {
+ s_->id, // stream_id
+ false, // is_eof
+ t_->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] !=
+ 0, // use_true_binary_metadata
+ t_->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size
+ &s_->stats.outgoing // stats
+ };
+ grpc_chttp2_encode_header(&t_->hpack_compressor, nullptr, 0,
+ s_->send_initial_metadata, &hopt, &t_->outbuf);
+ write_context_->ResetPingRecvClock();
+ write_context_->IncInitialMetadataWrites();
+ }
+
+ s_->send_initial_metadata = nullptr;
+ s_->sent_initial_metadata = true;
+ write_context_->NoteScheduledResults();
+ grpc_chttp2_complete_closure_step(
+ t_, s_, &s_->send_initial_metadata_finished, GRPC_ERROR_NONE,
+ "send_initial_metadata_finished");
+ }
+
+ void FlushWindowUpdates() {
+ /* send any window updates */
+ const uint32_t stream_announce = s_->flow_control->MaybeSendUpdate();
+ if (stream_announce == 0) return;
+
+ grpc_slice_buffer_add(
+ &t_->outbuf, grpc_chttp2_window_update_create(s_->id, stream_announce,
+ &s_->stats.outgoing));
+ write_context_->ResetPingRecvClock();
+ write_context_->IncWindowUpdateWrites();
+ }
+
+ void FlushData() {
+ if (!s_->sent_initial_metadata) return;
+
+ if (s_->flow_controlled_buffer.length == 0 &&
+ s_->compressed_data_buffer.length == 0) {
+ return; // early out: nothing to do
+ }
+
+ DataSendContext data_send_context(write_context_, t_, s_);
+
+ if (!data_send_context.AnyOutgoing()) {
+ if (t_->flow_control->remote_window() <= 0) {
+ report_stall(t_, s_, "transport");
+ grpc_chttp2_list_add_stalled_by_transport(t_, s_);
+ } else if (data_send_context.stream_remote_window() <= 0) {
+ report_stall(t_, s_, "stream");
+ grpc_chttp2_list_add_stalled_by_stream(t_, s_);
+ }
+ return; // early out: nothing to do
+ }
+
+ while ((s_->flow_controlled_buffer.length > 0 ||
+ s_->compressed_data_buffer.length > 0) &&
+ data_send_context.max_outgoing() > 0) {
+ if (s_->compressed_data_buffer.length > 0) {
+ data_send_context.FlushCompressedBytes();
+ } else {
+ data_send_context.CompressMoreBytes();
+ }
+ }
+ write_context_->ResetPingRecvClock();
+ if (data_send_context.is_last_frame()) {
+ SentLastFrame();
+ }
+ data_send_context.CallCallbacks();
+ stream_became_writable_ = true;
+ if (s_->flow_controlled_buffer.length > 0 ||
+ s_->compressed_data_buffer.length > 0) {
+ GRPC_CHTTP2_STREAM_REF(s_, "chttp2_writing:fork");
+ grpc_chttp2_list_add_writable_stream(t_, s_);
+ }
+ write_context_->IncMessageWrites();
+ }
+
+ void FlushTrailingMetadata() {
+ if (!s_->sent_initial_metadata) return;
+
+ if (s_->send_trailing_metadata == nullptr) return;
+ if (s_->fetching_send_message != nullptr) return;
+ if (s_->flow_controlled_buffer.length != 0) return;
+ if (s_->compressed_data_buffer.length != 0) return;
+
+ GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata"));
+ if (grpc_metadata_batch_is_empty(s_->send_trailing_metadata)) {
+ grpc_chttp2_encode_data(s_->id, &s_->flow_controlled_buffer, 0, true,
+ &s_->stats.outgoing, &t_->outbuf);
+ } else {
+ grpc_encode_header_options hopt = {
+ s_->id, true,
+ t_->settings[GRPC_PEER_SETTINGS]
+ [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] !=
+ 0,
+
+ t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
+ &s_->stats.outgoing};
+ grpc_chttp2_encode_header(&t_->hpack_compressor,
+ extra_headers_for_trailing_metadata_,
+ num_extra_headers_for_trailing_metadata_,
+ s_->send_trailing_metadata, &hopt, &t_->outbuf);
+ }
+ write_context_->IncTrailingMetadataWrites();
+ write_context_->ResetPingRecvClock();
+ SentLastFrame();
+
+ write_context_->NoteScheduledResults();
+ grpc_chttp2_complete_closure_step(
+ t_, s_, &s_->send_trailing_metadata_finished, GRPC_ERROR_NONE,
+ "send_trailing_metadata_finished");
+ }
+
+ bool stream_became_writable() { return stream_became_writable_; }
+
+ private:
+ void ConvertInitialMetadataToTrailingMetadata() {
+ GRPC_CHTTP2_IF_TRACING(
+ gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)"));
+ // When sending Trailers-Only, we need to move the :status and
+ // content-type headers to the trailers.
+ if (s_->send_initial_metadata->idx.named.status != nullptr) {
+ extra_headers_for_trailing_metadata_
+ [num_extra_headers_for_trailing_metadata_++] =
+ &s_->send_initial_metadata->idx.named.status->md;
+ }
+ if (s_->send_initial_metadata->idx.named.content_type != nullptr) {
+ extra_headers_for_trailing_metadata_
+ [num_extra_headers_for_trailing_metadata_++] =
+ &s_->send_initial_metadata->idx.named.content_type->md;
+ }
+ }
+
+ void SentLastFrame() {
+ s_->send_trailing_metadata = nullptr;
+ s_->sent_trailing_metadata = true;
+
+ if (!t_->is_client && !s_->read_closed) {
+ grpc_slice_buffer_add(
+ &t_->outbuf, grpc_chttp2_rst_stream_create(
+ s_->id, GRPC_HTTP2_NO_ERROR, &s_->stats.outgoing));
+ }
+ grpc_chttp2_mark_stream_closed(t_, s_, !t_->is_client, true,
+ GRPC_ERROR_NONE);
+ }
+
+ WriteContext* const write_context_;
+ grpc_chttp2_transport* const t_;
+ grpc_chttp2_stream* const s_;
+ bool stream_became_writable_ = false;
+ grpc_mdelem* extra_headers_for_trailing_metadata_[2];
+ size_t num_extra_headers_for_trailing_metadata_ = 0;
+};
+} // namespace
+
+grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
+ grpc_chttp2_transport* t) {
+ WriteContext ctx(t);
+ ctx.FlushSettings();
+ ctx.FlushPingAcks();
+ ctx.FlushQueuedBuffers();
+ ctx.EnactHpackSettings();
+
+ if (t->flow_control->remote_window() > 0) {
+ ctx.UpdateStreamsNoLongerStalled();
+ }
+
+ /* for each grpc_chttp2_stream that's become writable, frame it's data
+ (according to available window sizes) and add to the output buffer */
+ while (grpc_chttp2_stream* s = ctx.NextStream()) {
+ StreamWriteContext stream_ctx(&ctx, s);
+ stream_ctx.FlushInitialMetadata();
+ stream_ctx.FlushWindowUpdates();
+ stream_ctx.FlushData();
+ stream_ctx.FlushTrailingMetadata();
+
+ if (stream_ctx.stream_became_writable()) {
+ if (!grpc_chttp2_list_add_writing_stream(t, s)) {
+ /* already in writing list: drop ref */
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:already_writing");
+ } else {
+ /* ref will be dropped at end of write */
+ }
+ } else {
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:no_write");
+ }
+ }
+
+ ctx.FlushWindowUpdates();
+
+ maybe_initiate_ping(t);
+
+ GPR_TIMER_END("grpc_chttp2_begin_write", 0);
+
+ return ctx.Result();
+}
+
+void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error) {
+ GPR_TIMER_BEGIN("grpc_chttp2_end_write", 0);
+ grpc_chttp2_stream* s;
+
+ while (grpc_chttp2_list_pop_writing_stream(t, &s)) {
+ if (s->sending_bytes != 0) {
+ update_list(t, s, (int64_t)s->sending_bytes, &s->on_write_finished_cbs,
+ &s->flow_controlled_bytes_written, GRPC_ERROR_REF(error));
+ s->sending_bytes = 0;
+ }
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:end");
+ }
+ grpc_slice_buffer_reset_and_unref_internal(&t->outbuf);
+ GRPC_ERROR_UNREF(error);
+ GPR_TIMER_END("grpc_chttp2_end_write", 0);
+}
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
index 83365192e3..40a30e4a31 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.c
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <string.h>
+#include <grpc/grpc_cronet.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -31,23 +33,22 @@
// Cronet transport object
typedef struct cronet_transport {
grpc_transport base; // must be first element in this structure
- void *engine;
- char *host;
+ void* engine;
+ char* host;
} cronet_transport;
extern grpc_transport_vtable grpc_cronet_vtable;
-GRPCAPI grpc_channel *grpc_cronet_secure_channel_create(
- void *engine, const char *target, const grpc_channel_args *args,
- void *reserved) {
+GRPCAPI grpc_channel* grpc_cronet_secure_channel_create(
+ void* engine, const char* target, const grpc_channel_args* args,
+ void* reserved) {
gpr_log(GPR_DEBUG,
"grpc_create_cronet_transport: stream_engine = %p, target=%s", engine,
target);
- grpc_transport *ct =
+ grpc_transport* ct =
grpc_create_cronet_transport(engine, target, args, reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- return grpc_channel_create(&exec_ctx, target, args,
- GRPC_CLIENT_DIRECT_CHANNEL, ct);
+ grpc_core::ExecCtx exec_ctx;
+ return grpc_channel_create(target, args, GRPC_CLIENT_DIRECT_CHANNEL, ct);
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_api_dummy.c b/src/core/ext/transport/cronet/transport/cronet_api_dummy.cc
index 4f248ad919..578cbb8ac6 100644
--- a/src/core/ext/transport/cronet/transport/cronet_api_dummy.c
+++ b/src/core/ext/transport/cronet/transport/cronet_api_dummy.cc
@@ -33,7 +33,7 @@ bidirectional_stream* bidirectional_stream_create(
stream_engine* engine, void* annotation,
bidirectional_stream_callback* callback) {
GPR_ASSERT(0);
- return NULL;
+ return nullptr;
}
int bidirectional_stream_destroy(bidirectional_stream* stream) {
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index 587a3b83b5..5b1c6ab3f9 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.c
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -27,11 +27,12 @@
#include <grpc/support/useful.h>
#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/string.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/static_metadata.h"
@@ -74,17 +75,17 @@ enum e_op_id {
/* Cronet callbacks. See cronet_c_for_grpc.h for documentation for each. */
-static void on_stream_ready(bidirectional_stream *);
+static void on_stream_ready(bidirectional_stream*);
static void on_response_headers_received(
- bidirectional_stream *, const bidirectional_stream_header_array *,
- const char *);
-static void on_write_completed(bidirectional_stream *, const char *);
-static void on_read_completed(bidirectional_stream *, char *, int);
+ bidirectional_stream*, const bidirectional_stream_header_array*,
+ const char*);
+static void on_write_completed(bidirectional_stream*, const char*);
+static void on_read_completed(bidirectional_stream*, char*, int);
static void on_response_trailers_received(
- bidirectional_stream *, const bidirectional_stream_header_array *);
-static void on_succeeded(bidirectional_stream *);
-static void on_failed(bidirectional_stream *, int);
-static void on_canceled(bidirectional_stream *);
+ bidirectional_stream*, const bidirectional_stream_header_array*);
+static void on_succeeded(bidirectional_stream*);
+static void on_failed(bidirectional_stream*, int);
+static void on_canceled(bidirectional_stream*);
static bidirectional_stream_callback cronet_callbacks = {
on_stream_ready,
on_response_headers_received,
@@ -98,8 +99,8 @@ static bidirectional_stream_callback cronet_callbacks = {
/* Cronet transport object */
struct grpc_cronet_transport {
grpc_transport base; /* must be first element in this structure */
- stream_engine *engine;
- char *host;
+ stream_engine* engine;
+ char* host;
bool use_packet_coalescing;
};
typedef struct grpc_cronet_transport grpc_cronet_transport;
@@ -108,14 +109,14 @@ typedef struct grpc_cronet_transport grpc_cronet_transport;
http://www.catb.org/esr/structure-packing/#_structure_reordering: */
struct read_state {
/* vars to store data coming from server */
- char *read_buffer;
+ char* read_buffer;
bool length_field_received;
int received_bytes;
int remaining_bytes;
int length_field;
bool compressed;
char grpc_header_bytes[GRPC_HEADER_SIZE_IN_BYTES];
- char *payload_field;
+ char* payload_field;
bool read_stream_closed;
/* vars for holding data destined for the application */
@@ -131,7 +132,7 @@ struct read_state {
};
struct write_state {
- char *write_buffer;
+ char* write_buffer;
};
/* track state of one stream op */
@@ -149,7 +150,7 @@ struct op_state {
bool pending_recv_trailing_metadata;
/* Cronet has not issued a callback of a bidirectional read */
bool pending_read_from_cronet;
- grpc_error *cancel_error;
+ grpc_error* cancel_error;
/* data structure for storing data coming from server */
struct read_state rs;
/* data structure for storing data going to the server */
@@ -160,22 +161,22 @@ struct op_and_state {
grpc_transport_stream_op_batch op;
struct op_state state;
bool done;
- struct stream_obj *s; /* Pointer back to the stream object */
- struct op_and_state *next; /* next op_and_state in the linked list */
+ struct stream_obj* s; /* Pointer back to the stream object */
+ struct op_and_state* next; /* next op_and_state in the linked list */
};
struct op_storage {
int num_pending_ops;
- struct op_and_state *head;
+ struct op_and_state* head;
};
struct stream_obj {
- gpr_arena *arena;
- struct op_and_state *oas;
- grpc_transport_stream_op_batch *curr_op;
- grpc_cronet_transport *curr_ct;
- grpc_stream *curr_gs;
- bidirectional_stream *cbs;
+ gpr_arena* arena;
+ struct op_and_state* oas;
+ grpc_transport_stream_op_batch* curr_op;
+ grpc_cronet_transport* curr_ct;
+ grpc_stream* curr_gs;
+ bidirectional_stream* cbs;
bidirectional_stream_header_array header_array;
/* Stream level state. Some state will be tracked both at stream and stream_op
@@ -189,39 +190,35 @@ struct stream_obj {
gpr_mu mu;
/* Refcount object of the stream */
- grpc_stream_refcount *refcount;
+ grpc_stream_refcount* refcount;
};
typedef struct stream_obj stream_obj;
#ifndef NDEBUG
#define GRPC_CRONET_STREAM_REF(stream, reason) \
grpc_cronet_stream_ref((stream), (reason))
-#define GRPC_CRONET_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_cronet_stream_unref((exec_ctx), (stream), (reason))
-void grpc_cronet_stream_ref(stream_obj *s, const char *reason) {
+#define GRPC_CRONET_STREAM_UNREF(stream, reason) \
+ grpc_cronet_stream_unref((stream), (reason))
+void grpc_cronet_stream_ref(stream_obj* s, const char* reason) {
grpc_stream_ref(s->refcount, reason);
}
-void grpc_cronet_stream_unref(grpc_exec_ctx *exec_ctx, stream_obj *s,
- const char *reason) {
- grpc_stream_unref(exec_ctx, s->refcount, reason);
+void grpc_cronet_stream_unref(stream_obj* s, const char* reason) {
+ grpc_stream_unref(s->refcount, reason);
}
#else
#define GRPC_CRONET_STREAM_REF(stream, reason) grpc_cronet_stream_ref((stream))
-#define GRPC_CRONET_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_cronet_stream_unref((exec_ctx), (stream))
-void grpc_cronet_stream_ref(stream_obj *s) { grpc_stream_ref(s->refcount); }
-void grpc_cronet_stream_unref(grpc_exec_ctx *exec_ctx, stream_obj *s) {
- grpc_stream_unref(exec_ctx, s->refcount);
-}
+#define GRPC_CRONET_STREAM_UNREF(stream, reason) \
+ grpc_cronet_stream_unref((stream))
+void grpc_cronet_stream_ref(stream_obj* s) { grpc_stream_ref(s->refcount); }
+void grpc_cronet_stream_unref(stream_obj* s) { grpc_stream_unref(s->refcount); }
#endif
-static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
- struct op_and_state *oas);
+static enum e_op_result execute_stream_op(struct op_and_state* oas);
/*
Utility function to translate enum into string for printing
*/
-static const char *op_result_string(enum e_op_result i) {
+static const char* op_result_string(enum e_op_result i) {
switch (i) {
case ACTION_TAKEN_WITH_CALLBACK:
return "ACTION_TAKEN_WITH_CALLBACK";
@@ -233,7 +230,7 @@ static const char *op_result_string(enum e_op_result i) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-static const char *op_id_string(enum e_op_id i) {
+static const char* op_id_string(enum e_op_id i) {
switch (i) {
case OP_SEND_INITIAL_METADATA:
return "OP_SEND_INITIAL_METADATA";
@@ -267,15 +264,15 @@ static const char *op_id_string(enum e_op_id i) {
return "UNKNOWN";
}
-static void null_and_maybe_free_read_buffer(stream_obj *s) {
+static void null_and_maybe_free_read_buffer(stream_obj* s) {
if (s->state.rs.read_buffer &&
s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) {
gpr_free(s->state.rs.read_buffer);
}
- s->state.rs.read_buffer = NULL;
+ s->state.rs.read_buffer = nullptr;
}
-static void maybe_flush_read(stream_obj *s) {
+static void maybe_flush_read(stream_obj* s) {
/* To enter flush read state (discarding all the buffered messages in
* transport layer), two conditions must be satisfied: 1) non-zero grpc status
* has been received, and 2) an op requesting the status code
@@ -288,7 +285,7 @@ static void maybe_flush_read(stream_obj *s) {
CRONET_LOG(GPR_DEBUG, "%p: Flush read", s);
s->state.flush_read = true;
null_and_maybe_free_read_buffer(s);
- s->state.rs.read_buffer = gpr_malloc(GRPC_FLUSH_READ_SIZE);
+ s->state.rs.read_buffer = (char*)gpr_malloc(GRPC_FLUSH_READ_SIZE);
if (!s->state.pending_read_from_cronet) {
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_read(%p)", s->cbs);
bidirectional_stream_read(s->cbs, s->state.rs.read_buffer,
@@ -299,8 +296,8 @@ static void maybe_flush_read(stream_obj *s) {
}
}
-static grpc_error *make_error_with_desc(int error_code, const char *desc) {
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
+static grpc_error* make_error_with_desc(int error_code, const char* desc) {
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, error_code);
return error;
}
@@ -308,12 +305,13 @@ static grpc_error *make_error_with_desc(int error_code, const char *desc) {
/*
Add a new stream op to op storage.
*/
-static void add_to_storage(struct stream_obj *s,
- grpc_transport_stream_op_batch *op) {
- struct op_storage *storage = &s->storage;
+static void add_to_storage(struct stream_obj* s,
+ grpc_transport_stream_op_batch* op) {
+ struct op_storage* storage = &s->storage;
/* add new op at the beginning of the linked list. The memory is freed
in remove_from_storage */
- struct op_and_state *new_op = gpr_malloc(sizeof(struct op_and_state));
+ struct op_and_state* new_op =
+ (struct op_and_state*)gpr_malloc(sizeof(struct op_and_state));
memcpy(&new_op->op, op, sizeof(grpc_transport_stream_op_batch));
memset(&new_op->state, 0, sizeof(new_op->state));
new_op->s = s;
@@ -337,10 +335,10 @@ static void add_to_storage(struct stream_obj *s,
/*
Traverse the linked list and delete op and free memory
*/
-static void remove_from_storage(struct stream_obj *s,
- struct op_and_state *oas) {
- struct op_and_state *curr;
- if (s->storage.head == NULL || oas == NULL) {
+static void remove_from_storage(struct stream_obj* s,
+ struct op_and_state* oas) {
+ struct op_and_state* curr;
+ if (s->storage.head == nullptr || oas == nullptr) {
return;
}
if (s->storage.head == oas) {
@@ -350,7 +348,7 @@ static void remove_from_storage(struct stream_obj *s,
CRONET_LOG(GPR_DEBUG, "Freed %p. Now %d in the queue", oas,
s->storage.num_pending_ops);
} else {
- for (curr = s->storage.head; curr != NULL; curr = curr->next) {
+ for (curr = s->storage.head; curr != nullptr; curr = curr->next) {
if (curr->next == oas) {
curr->next = oas->next;
s->storage.num_pending_ops--;
@@ -358,7 +356,7 @@ static void remove_from_storage(struct stream_obj *s,
s->storage.num_pending_ops);
gpr_free(oas);
break;
- } else if (curr->next == NULL) {
+ } else if (curr->next == nullptr) {
CRONET_LOG(GPR_ERROR, "Reached end of LL and did not find op to free");
}
}
@@ -371,17 +369,17 @@ static void remove_from_storage(struct stream_obj *s,
This can get executed from the Cronet network thread via cronet callback
or on the application supplied thread via the perform_stream_op function.
*/
-static void execute_from_storage(grpc_exec_ctx *exec_ctx, stream_obj *s) {
+static void execute_from_storage(stream_obj* s) {
gpr_mu_lock(&s->mu);
- for (struct op_and_state *curr = s->storage.head; curr != NULL;) {
+ for (struct op_and_state* curr = s->storage.head; curr != nullptr;) {
CRONET_LOG(GPR_DEBUG, "calling op at %p. done = %d", curr, curr->done);
GPR_ASSERT(curr->done == 0);
- enum e_op_result result = execute_stream_op(exec_ctx, curr);
+ enum e_op_result result = execute_stream_op(curr);
CRONET_LOG(GPR_DEBUG, "execute_stream_op[%p] returns %s", curr,
op_result_string(result));
/* if this op is done, then remove it and free memory */
if (curr->done) {
- struct op_and_state *next = curr->next;
+ struct op_and_state* next = curr->next;
remove_from_storage(s, curr);
curr = next;
}
@@ -398,91 +396,88 @@ static void execute_from_storage(grpc_exec_ctx *exec_ctx, stream_obj *s) {
/*
Cronet callback
*/
-static void on_failed(bidirectional_stream *stream, int net_error) {
- CRONET_LOG(GPR_DEBUG, "on_failed(%p, %d)", stream, net_error);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+static void on_failed(bidirectional_stream* stream, int net_error) {
+ gpr_log(GPR_ERROR, "on_failed(%p, %d)", stream, net_error);
+ grpc_core::ExecCtx exec_ctx;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
bidirectional_stream_destroy(s->cbs);
s->state.state_callback_received[OP_FAILED] = true;
- s->cbs = NULL;
+ s->cbs = nullptr;
if (s->header_array.headers) {
gpr_free(s->header_array.headers);
- s->header_array.headers = NULL;
+ s->header_array.headers = nullptr;
}
if (s->state.ws.write_buffer) {
gpr_free(s->state.ws.write_buffer);
- s->state.ws.write_buffer = NULL;
+ s->state.ws.write_buffer = nullptr;
}
null_and_maybe_free_read_buffer(s);
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- GRPC_CRONET_STREAM_UNREF(&exec_ctx, s, "cronet transport");
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
+ GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
}
/*
Cronet callback
*/
-static void on_canceled(bidirectional_stream *stream) {
+static void on_canceled(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "on_canceled(%p)", stream);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
bidirectional_stream_destroy(s->cbs);
s->state.state_callback_received[OP_CANCELED] = true;
- s->cbs = NULL;
+ s->cbs = nullptr;
if (s->header_array.headers) {
gpr_free(s->header_array.headers);
- s->header_array.headers = NULL;
+ s->header_array.headers = nullptr;
}
if (s->state.ws.write_buffer) {
gpr_free(s->state.ws.write_buffer);
- s->state.ws.write_buffer = NULL;
+ s->state.ws.write_buffer = nullptr;
}
null_and_maybe_free_read_buffer(s);
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- GRPC_CRONET_STREAM_UNREF(&exec_ctx, s, "cronet transport");
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
+ GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
}
/*
Cronet callback
*/
-static void on_succeeded(bidirectional_stream *stream) {
+static void on_succeeded(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "on_succeeded(%p)", stream);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
bidirectional_stream_destroy(s->cbs);
s->state.state_callback_received[OP_SUCCEEDED] = true;
- s->cbs = NULL;
+ s->cbs = nullptr;
null_and_maybe_free_read_buffer(s);
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- GRPC_CRONET_STREAM_UNREF(&exec_ctx, s, "cronet transport");
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
+ GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
}
/*
Cronet callback
*/
-static void on_stream_ready(bidirectional_stream *stream) {
+static void on_stream_ready(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "W: on_stream_ready(%p)", stream);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
- grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
+ grpc_core::ExecCtx exec_ctx;
+ stream_obj* s = (stream_obj*)stream->annotation;
+ grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
gpr_mu_lock(&s->mu);
s->state.state_op_done[OP_SEND_INITIAL_METADATA] = true;
s->state.state_callback_received[OP_SEND_INITIAL_METADATA] = true;
/* Free the memory allocated for headers */
if (s->header_array.headers) {
gpr_free(s->header_array.headers);
- s->header_array.headers = NULL;
+ s->header_array.headers = nullptr;
}
/* Send the initial metadata on wire if there is no SEND_MESSAGE or
* SEND_TRAILING_METADATA ops pending */
@@ -493,21 +488,20 @@ static void on_stream_ready(bidirectional_stream *stream) {
}
}
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
}
/*
Cronet callback
*/
static void on_response_headers_received(
- bidirectional_stream *stream,
- const bidirectional_stream_header_array *headers,
- const char *negotiated_protocol) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ bidirectional_stream* stream,
+ const bidirectional_stream_header_array* headers,
+ const char* negotiated_protocol) {
+ grpc_core::ExecCtx exec_ctx;
CRONET_LOG(GPR_DEBUG, "R: on_response_headers_received(%p, %p, %s)", stream,
headers, negotiated_protocol);
- stream_obj *s = (stream_obj *)stream->annotation;
+ stream_obj* s = (stream_obj*)stream->annotation;
/* Identify if this is a header or a trailer (in a trailer-only response case)
*/
@@ -524,15 +518,14 @@ static void on_response_headers_received(
grpc_chttp2_incoming_metadata_buffer_init(&s->state.rs.initial_metadata,
s->arena);
for (size_t i = 0; i < headers->count; i++) {
- GRPC_LOG_IF_ERROR(
- "on_response_headers_received",
- grpc_chttp2_incoming_metadata_buffer_add(
- &exec_ctx, &s->state.rs.initial_metadata,
- grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(
- headers->headers[i].key)),
- grpc_slice_intern(grpc_slice_from_static_string(
- headers->headers[i].value)))));
+ GRPC_LOG_IF_ERROR("on_response_headers_received",
+ grpc_chttp2_incoming_metadata_buffer_add(
+ &s->state.rs.initial_metadata,
+ grpc_mdelem_from_slices(
+ grpc_slice_intern(grpc_slice_from_static_string(
+ headers->headers[i].key)),
+ grpc_slice_intern(grpc_slice_from_static_string(
+ headers->headers[i].value)))));
}
s->state.state_callback_received[OP_RECV_INITIAL_METADATA] = true;
if (!(s->state.state_op_done[OP_CANCEL_ERROR] ||
@@ -550,35 +543,33 @@ static void on_response_headers_received(
s->state.pending_read_from_cronet = true;
}
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
}
/*
Cronet callback
*/
-static void on_write_completed(bidirectional_stream *stream, const char *data) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+static void on_write_completed(bidirectional_stream* stream, const char* data) {
+ grpc_core::ExecCtx exec_ctx;
+ stream_obj* s = (stream_obj*)stream->annotation;
CRONET_LOG(GPR_DEBUG, "W: on_write_completed(%p, %s)", stream, data);
gpr_mu_lock(&s->mu);
if (s->state.ws.write_buffer) {
gpr_free(s->state.ws.write_buffer);
- s->state.ws.write_buffer = NULL;
+ s->state.ws.write_buffer = nullptr;
}
s->state.state_callback_received[OP_SEND_MESSAGE] = true;
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
}
/*
Cronet callback
*/
-static void on_read_completed(bidirectional_stream *stream, char *data,
+static void on_read_completed(bidirectional_stream* stream, char* data,
int count) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- stream_obj *s = (stream_obj *)stream->annotation;
+ grpc_core::ExecCtx exec_ctx;
+ stream_obj* s = (stream_obj*)stream->annotation;
CRONET_LOG(GPR_DEBUG, "R: on_read_completed(%p, %p, %d)", stream, data,
count);
gpr_mu_lock(&s->mu);
@@ -603,28 +594,27 @@ static void on_read_completed(bidirectional_stream *stream, char *data,
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
+ execute_from_storage(s);
}
} else {
null_and_maybe_free_read_buffer(s);
s->state.rs.read_stream_closed = true;
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
+ execute_from_storage(s);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
/*
Cronet callback
*/
static void on_response_trailers_received(
- bidirectional_stream *stream,
- const bidirectional_stream_header_array *trailers) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ bidirectional_stream* stream,
+ const bidirectional_stream_header_array* trailers) {
+ grpc_core::ExecCtx exec_ctx;
CRONET_LOG(GPR_DEBUG, "R: on_response_trailers_received(%p,%p)", stream,
trailers);
- stream_obj *s = (stream_obj *)stream->annotation;
- grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
+ stream_obj* s = (stream_obj*)stream->annotation;
+ grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
gpr_mu_lock(&s->mu);
memset(&s->state.rs.trailing_metadata, 0,
sizeof(s->state.rs.trailing_metadata));
@@ -634,15 +624,14 @@ static void on_response_trailers_received(
for (size_t i = 0; i < trailers->count; i++) {
CRONET_LOG(GPR_DEBUG, "trailer key=%s, value=%s", trailers->headers[i].key,
trailers->headers[i].value);
- GRPC_LOG_IF_ERROR(
- "on_response_trailers_received",
- grpc_chttp2_incoming_metadata_buffer_add(
- &exec_ctx, &s->state.rs.trailing_metadata,
- grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(
- trailers->headers[i].key)),
- grpc_slice_intern(grpc_slice_from_static_string(
- trailers->headers[i].value)))));
+ GRPC_LOG_IF_ERROR("on_response_trailers_received",
+ grpc_chttp2_incoming_metadata_buffer_add(
+ &s->state.rs.trailing_metadata,
+ grpc_mdelem_from_slices(
+ grpc_slice_intern(grpc_slice_from_static_string(
+ trailers->headers[i].key)),
+ grpc_slice_intern(grpc_slice_from_static_string(
+ trailers->headers[i].value)))));
s->state.rs.trailing_metadata_valid = true;
if (0 == strcmp(trailers->headers[i].key, "grpc-status") &&
0 != strcmp(trailers->headers[i].value, "0")) {
@@ -668,29 +657,27 @@ static void on_response_trailers_received(
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
+ execute_from_storage(s);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
/*
Utility function that takes the data from s->write_slice_buffer and assembles
into a contiguous byte stream with 5 byte gRPC header prepended.
*/
-static void create_grpc_frame(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *write_slice_buffer,
- char **pp_write_buffer,
- size_t *p_write_buffer_size, uint32_t flags) {
+static void create_grpc_frame(grpc_slice_buffer* write_slice_buffer,
+ char** pp_write_buffer,
+ size_t* p_write_buffer_size, uint32_t flags) {
grpc_slice slice = grpc_slice_buffer_take_first(write_slice_buffer);
size_t length = GRPC_SLICE_LENGTH(slice);
*p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES;
/* This is freed in the on_write_completed callback */
- char *write_buffer = gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES);
+ char* write_buffer = (char*)gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES);
*pp_write_buffer = write_buffer;
- uint8_t *p = (uint8_t *)write_buffer;
+ uint8_t* p = (uint8_t*)write_buffer;
/* Append 5 byte header */
/* Compressed flag */
- *p++ = (flags & GRPC_WRITE_INTERNAL_COMPRESS) ? 1 : 0;
+ *p++ = (uint8_t)((flags & GRPC_WRITE_INTERNAL_COMPRESS) ? 1 : 0);
/* Message length */
*p++ = (uint8_t)(length >> 24);
*p++ = (uint8_t)(length >> 16);
@@ -698,27 +685,27 @@ static void create_grpc_frame(grpc_exec_ctx *exec_ctx,
*p++ = (uint8_t)(length);
/* append actual data */
memcpy(p, GRPC_SLICE_START_PTR(slice), length);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
}
/*
Convert metadata in a format that Cronet can consume
*/
static void convert_metadata_to_cronet_headers(
- grpc_linked_mdelem *head, const char *host, char **pp_url,
- bidirectional_stream_header **pp_headers, size_t *p_num_headers,
- const char **method) {
- grpc_linked_mdelem *curr = head;
+ grpc_linked_mdelem* head, const char* host, char** pp_url,
+ bidirectional_stream_header** pp_headers, size_t* p_num_headers,
+ const char** method) {
+ grpc_linked_mdelem* curr = head;
/* Walk the linked list and get number of header fields */
size_t num_headers_available = 0;
- while (curr != NULL) {
+ while (curr != nullptr) {
curr = curr->next;
num_headers_available++;
}
/* Allocate enough memory. It is freed in the on_stream_ready callback
*/
- bidirectional_stream_header *headers =
- (bidirectional_stream_header *)gpr_malloc(
+ bidirectional_stream_header* headers =
+ (bidirectional_stream_header*)gpr_malloc(
sizeof(bidirectional_stream_header) * num_headers_available);
*pp_headers = headers;
@@ -732,8 +719,8 @@ static void convert_metadata_to_cronet_headers(
while (num_headers < num_headers_available) {
grpc_mdelem mdelem = curr->md;
curr = curr->next;
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(mdelem));
- char *value = grpc_slice_to_c_string(GRPC_MDVALUE(mdelem));
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(mdelem));
+ char* value = grpc_slice_to_c_string(GRPC_MDVALUE(mdelem));
if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_SCHEME) ||
grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_AUTHORITY)) {
/* Cronet populates these fields on its own */
@@ -763,17 +750,17 @@ static void convert_metadata_to_cronet_headers(
headers[num_headers].key = key;
headers[num_headers].value = value;
num_headers++;
- if (curr == NULL) {
+ if (curr == nullptr) {
break;
}
}
*p_num_headers = (size_t)num_headers;
}
-static void parse_grpc_header(const uint8_t *data, int *length,
- bool *compressed) {
+static void parse_grpc_header(const uint8_t* data, int* length,
+ bool* compressed) {
const uint8_t c = *data;
- const uint8_t *p = data + 1;
+ const uint8_t* p = data + 1;
*compressed = ((c & 0x01) == 0x01);
*length = 0;
*length |= ((uint8_t)*p++) << 24;
@@ -782,8 +769,8 @@ static void parse_grpc_header(const uint8_t *data, int *length,
*length |= ((uint8_t)*p++);
}
-static bool header_has_authority(grpc_linked_mdelem *head) {
- while (head != NULL) {
+static bool header_has_authority(grpc_linked_mdelem* head) {
+ while (head != nullptr) {
if (grpc_slice_eq(GRPC_MDKEY(head->md), GRPC_MDSTR_AUTHORITY)) {
return true;
}
@@ -796,11 +783,11 @@ static bool header_has_authority(grpc_linked_mdelem *head) {
Op Execution: Decide if one of the actions contained in the stream op can be
executed. This is the heart of the state machine.
*/
-static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op,
- struct stream_obj *s, struct op_state *op_state,
+static bool op_can_be_run(grpc_transport_stream_op_batch* curr_op,
+ struct stream_obj* s, struct op_state* op_state,
enum e_op_id op_id) {
- struct op_state *stream_state = &s->state;
- grpc_cronet_transport *t = s->curr_ct;
+ struct op_state* stream_state = &s->state;
+ grpc_cronet_transport* t = s->curr_ct;
bool result = true;
/* When call is canceled, every op can be run, except under following
conditions
@@ -979,19 +966,18 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op,
/*
TODO (makdharma): Break down this function in smaller chunks for readability.
*/
-static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
- struct op_and_state *oas) {
- grpc_transport_stream_op_batch *stream_op = &oas->op;
- struct stream_obj *s = oas->s;
- grpc_cronet_transport *t = (grpc_cronet_transport *)s->curr_ct;
- struct op_state *stream_state = &s->state;
+static enum e_op_result execute_stream_op(struct op_and_state* oas) {
+ grpc_transport_stream_op_batch* stream_op = &oas->op;
+ struct stream_obj* s = oas->s;
+ grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
+ struct op_state* stream_state = &s->state;
enum e_op_result result = NO_ACTION_POSSIBLE;
if (stream_op->send_initial_metadata &&
op_can_be_run(stream_op, s, &oas->state, OP_SEND_INITIAL_METADATA)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_INITIAL_METADATA", oas);
/* Start new cronet stream. It is destroyed in on_succeeded, on_canceled,
* on_failed */
- GPR_ASSERT(s->cbs == NULL);
+ GPR_ASSERT(s->cbs == nullptr);
GPR_ASSERT(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]);
s->cbs =
bidirectional_stream_create(t->engine, s->curr_gs, &cronet_callbacks);
@@ -1000,9 +986,9 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
bidirectional_stream_disable_auto_flush(s->cbs, true);
bidirectional_stream_delay_request_headers_until_flush(s->cbs, true);
}
- char *url = NULL;
- const char *method = "POST";
- s->header_array.headers = NULL;
+ char* url = nullptr;
+ const char* method = "POST";
+ s->header_array.headers = nullptr;
convert_metadata_to_cronet_headers(stream_op->payload->send_initial_metadata
.send_initial_metadata->list.head,
t->host, &url, &s->header_array.headers,
@@ -1016,8 +1002,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
unsigned int header_index;
for (header_index = 0; header_index < s->header_array.count;
header_index++) {
- gpr_free((void *)s->header_array.headers[header_index].key);
- gpr_free((void *)s->header_array.headers[header_index].value);
+ gpr_free((void*)s->header_array.headers[header_index].key);
+ gpr_free((void*)s->header_array.headers[header_index].value);
}
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true;
if (t->use_packet_coalescing) {
@@ -1038,15 +1024,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
grpc_slice slice;
grpc_slice_buffer_init(&write_slice_buffer);
if (1 != grpc_byte_stream_next(
- exec_ctx, stream_op->payload->send_message.send_message,
+ stream_op->payload->send_message.send_message,
stream_op->payload->send_message.send_message->length,
- NULL)) {
+ nullptr)) {
/* Should never reach here */
GPR_ASSERT(false);
}
if (GRPC_ERROR_NONE !=
- grpc_byte_stream_pull(exec_ctx,
- stream_op->payload->send_message.send_message,
+ grpc_byte_stream_pull(stream_op->payload->send_message.send_message,
&slice)) {
/* Should never reach here */
GPR_ASSERT(false);
@@ -1059,15 +1044,15 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
}
if (write_slice_buffer.count > 0) {
size_t write_buffer_size;
- create_grpc_frame(exec_ctx, &write_slice_buffer,
- &stream_state->ws.write_buffer, &write_buffer_size,
+ create_grpc_frame(&write_slice_buffer, &stream_state->ws.write_buffer,
+ &write_buffer_size,
stream_op->payload->send_message.send_message->flags);
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, %p)", s->cbs,
stream_state->ws.write_buffer);
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
(int)write_buffer_size, false);
- grpc_slice_buffer_destroy_internal(exec_ctx, &write_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&write_slice_buffer);
if (t->use_packet_coalescing) {
if (!stream_op->send_trailing_metadata) {
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
@@ -1110,25 +1095,21 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
} else if (stream_state->state_callback_received[OP_FAILED]) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
} else if (stream_state->state_op_done[OP_RECV_TRAILING_METADATA]) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
} else {
grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &oas->s->state.rs.initial_metadata,
+ &oas->s->state.rs.initial_metadata,
stream_op->payload->recv_initial_metadata.recv_initial_metadata);
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
}
@@ -1139,16 +1120,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_MESSAGE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
CRONET_LOG(GPR_DEBUG, "Stream is cancelled.");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_state->state_callback_received[OP_FAILED]) {
CRONET_LOG(GPR_DEBUG, "Stream failed.");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1156,16 +1135,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
} else if (stream_state->rs.read_stream_closed == true) {
/* No more data will be received */
CRONET_LOG(GPR_DEBUG, "read stream closed");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_state->flush_read) {
CRONET_LOG(GPR_DEBUG, "flush read");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1175,14 +1152,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->rs.remaining_bytes == 0) {
/* Start a read operation for data */
stream_state->rs.length_field_received = true;
- parse_grpc_header((const uint8_t *)stream_state->rs.read_buffer,
+ parse_grpc_header((const uint8_t*)stream_state->rs.read_buffer,
&stream_state->rs.length_field,
&stream_state->rs.compressed);
CRONET_LOG(GPR_DEBUG, "length field = %d",
stream_state->rs.length_field);
if (stream_state->rs.length_field > 0) {
stream_state->rs.read_buffer =
- gpr_malloc((size_t)stream_state->rs.length_field);
+ (char*)gpr_malloc((size_t)stream_state->rs.length_field);
GPR_ASSERT(stream_state->rs.read_buffer);
stream_state->rs.remaining_bytes = stream_state->rs.length_field;
stream_state->rs.received_bytes = 0;
@@ -1198,18 +1175,17 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "read operation complete. Empty response.");
/* Clean up read_slice_buffer in case there is unread data. */
grpc_slice_buffer_destroy_internal(
- exec_ctx, &stream_state->rs.read_slice_buffer);
+ &stream_state->rs.read_slice_buffer);
grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer);
grpc_slice_buffer_stream_init(&stream_state->rs.sbs,
&stream_state->rs.read_slice_buffer, 0);
if (stream_state->rs.compressed) {
stream_state->rs.sbs.base.flags |= GRPC_WRITE_INTERNAL_COMPRESS;
}
- *((grpc_byte_buffer **)
- stream_op->payload->recv_message.recv_message) =
- (grpc_byte_buffer *)&stream_state->rs.sbs;
+ *((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
+ (grpc_byte_buffer*)&stream_state->rs.sbs;
GRPC_CLOSURE_SCHED(
- exec_ctx, stream_op->payload->recv_message.recv_message_ready,
+ stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1248,13 +1224,12 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "read operation complete");
grpc_slice read_data_slice =
GRPC_SLICE_MALLOC((uint32_t)stream_state->rs.length_field);
- uint8_t *dst_p = GRPC_SLICE_START_PTR(read_data_slice);
+ uint8_t* dst_p = GRPC_SLICE_START_PTR(read_data_slice);
memcpy(dst_p, stream_state->rs.read_buffer,
(size_t)stream_state->rs.length_field);
null_and_maybe_free_read_buffer(s);
/* Clean up read_slice_buffer in case there is unread data. */
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &stream_state->rs.read_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&stream_state->rs.read_slice_buffer);
grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer);
grpc_slice_buffer_add(&stream_state->rs.read_slice_buffer,
read_data_slice);
@@ -1263,10 +1238,9 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
if (stream_state->rs.compressed) {
stream_state->rs.sbs.base.flags = GRPC_WRITE_INTERNAL_COMPRESS;
}
- *((grpc_byte_buffer **)stream_op->payload->recv_message.recv_message) =
- (grpc_byte_buffer *)&stream_state->rs.sbs;
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ *((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
+ (grpc_byte_buffer*)&stream_state->rs.sbs;
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1289,7 +1263,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_TRAILING_METADATA", oas);
if (oas->s->state.rs.trailing_metadata_valid) {
grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &oas->s->state.rs.trailing_metadata,
+ &oas->s->state.rs.trailing_metadata,
stream_op->payload->recv_trailing_metadata.recv_trailing_metadata);
stream_state->rs.trailing_metadata_valid = false;
}
@@ -1314,17 +1288,17 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
op_can_be_run(stream_op, s, &oas->state, OP_ON_COMPLETE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_ON_COMPLETE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
- GRPC_CLOSURE_SCHED(exec_ctx, stream_op->on_complete,
+ GRPC_CLOSURE_SCHED(stream_op->on_complete,
GRPC_ERROR_REF(stream_state->cancel_error));
} else if (stream_state->state_callback_received[OP_FAILED]) {
GRPC_CLOSURE_SCHED(
- exec_ctx, stream_op->on_complete,
+ stream_op->on_complete,
make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."));
} else {
/* All actions in this stream_op are complete. Call the on_complete
* callback
*/
- GRPC_CLOSURE_SCHED(exec_ctx, stream_op->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(stream_op->on_complete, GRPC_ERROR_NONE);
}
oas->state.state_op_done[OP_ON_COMPLETE] = true;
oas->done = true;
@@ -1349,18 +1323,18 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
Functions used by upper layers to access transport functionality.
*/
-static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
- stream_obj *s = (stream_obj *)gs;
+static int init_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
+ stream_obj* s = (stream_obj*)gs;
s->refcount = refcount;
GRPC_CRONET_STREAM_REF(s, "cronet transport");
memset(&s->storage, 0, sizeof(s->storage));
- s->storage.head = NULL;
+ s->storage.head = nullptr;
memset(&s->state, 0, sizeof(s->state));
- s->curr_op = NULL;
- s->cbs = NULL;
+ s->curr_op = nullptr;
+ s->cbs = nullptr;
memset(&s->header_array, 0, sizeof(s->header_array));
memset(&s->state.rs, 0, sizeof(s->state.rs));
memset(&s->state.ws, 0, sizeof(s->state.ws));
@@ -1368,30 +1342,28 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
memset(s->state.state_callback_received, 0,
sizeof(s->state.state_callback_received));
s->state.fail_state = s->state.flush_read = false;
- s->state.cancel_error = NULL;
+ s->state.cancel_error = nullptr;
s->state.flush_cronet_when_ready = s->state.pending_write_for_trailer = false;
s->state.pending_send_message = false;
s->state.pending_recv_trailing_metadata = false;
s->state.pending_read_from_cronet = false;
s->curr_gs = gs;
- s->curr_ct = (grpc_cronet_transport *)gt;
+ s->curr_ct = (grpc_cronet_transport*)gt;
s->arena = arena;
gpr_mu_init(&s->mu);
return 0;
}
-static void set_pollset_do_nothing(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset *pollset) {}
+static void set_pollset_do_nothing(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset* pollset) {}
-static void set_pollset_set_do_nothing(grpc_exec_ctx *exec_ctx,
- grpc_transport *gt, grpc_stream *gs,
- grpc_pollset_set *pollset_set) {}
+static void set_pollset_set_do_nothing(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset_set* pollset_set) {}
-static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_transport_stream_op_batch *op) {
+static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
+ grpc_transport_stream_op_batch* op) {
CRONET_LOG(GPR_DEBUG, "perform_stream_op");
if (op->send_initial_metadata &&
header_has_authority(op->payload->send_initial_metadata
@@ -1400,42 +1372,36 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
this field is present in metadata */
if (op->recv_initial_metadata) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_CANCELLED);
}
if (op->recv_message) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(op->payload->recv_message.recv_message_ready,
GRPC_ERROR_CANCELLED);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_CANCELLED);
return;
}
- stream_obj *s = (stream_obj *)gs;
+ stream_obj* s = (stream_obj*)gs;
add_to_storage(s, op);
- execute_from_storage(exec_ctx, s);
+ execute_from_storage(s);
}
-static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_closure *then_schedule_closure) {
- stream_obj *s = (stream_obj *)gs;
+static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_closure* then_schedule_closure) {
+ stream_obj* s = (stream_obj*)gs;
null_and_maybe_free_read_buffer(s);
/* Clean up read_slice_buffer in case there is unread data. */
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->state.rs.read_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&s->state.rs.read_slice_buffer);
GRPC_ERROR_UNREF(s->state.cancel_error);
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
}
-static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {}
+static void destroy_transport(grpc_transport* gt) {}
-static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx,
- grpc_transport *gt) {
- return NULL;
-}
+static grpc_endpoint* get_endpoint(grpc_transport* gt) { return nullptr; }
-static void perform_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_transport_op *op) {}
+static void perform_op(grpc_transport* gt, grpc_transport_op* op) {}
static const grpc_transport_vtable grpc_cronet_vtable = {
sizeof(stream_obj),
@@ -1449,16 +1415,17 @@ static const grpc_transport_vtable grpc_cronet_vtable = {
destroy_transport,
get_endpoint};
-grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
- const grpc_channel_args *args,
- void *reserved) {
- grpc_cronet_transport *ct = gpr_malloc(sizeof(grpc_cronet_transport));
+grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
+ const grpc_channel_args* args,
+ void* reserved) {
+ grpc_cronet_transport* ct =
+ (grpc_cronet_transport*)gpr_malloc(sizeof(grpc_cronet_transport));
if (!ct) {
goto error;
}
ct->base.vtable = &grpc_cronet_vtable;
- ct->engine = engine;
- ct->host = gpr_malloc(strlen(target) + 1);
+ ct->engine = (stream_engine*)engine;
+ ct->host = (char*)gpr_malloc(strlen(target) + 1);
if (!ct->host) {
goto error;
}
@@ -1489,5 +1456,5 @@ error:
gpr_free(ct);
}
- return NULL;
+ return nullptr;
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.h b/src/core/ext/transport/cronet/transport/cronet_transport.h
index 3bd4249b79..d9ff913326 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.h
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.h
@@ -21,8 +21,8 @@
#include "src/core/lib/transport/transport.h"
-grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
- const grpc_channel_args *args,
- void *reserved);
+grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
+ const grpc_channel_args* args,
+ void* reserved);
#endif /* GRPC_CORE_EXT_TRANSPORT_CRONET_TRANSPORT_CRONET_TRANSPORT_H */
diff --git a/src/core/ext/transport/inproc/inproc_plugin.c b/src/core/ext/transport/inproc/inproc_plugin.cc
index 6a796a0b19..83a7d8d52f 100644
--- a/src/core/ext/transport/inproc/inproc_plugin.c
+++ b/src/core/ext/transport/inproc/inproc_plugin.cc
@@ -19,11 +19,8 @@
#include "src/core/ext/transport/inproc/inproc_transport.h"
#include "src/core/lib/debug/trace.h"
-grpc_tracer_flag grpc_inproc_trace = GRPC_TRACER_INITIALIZER(false, "inproc");
+grpc_core::TraceFlag grpc_inproc_trace(false, "inproc");
-void grpc_inproc_plugin_init(void) {
- grpc_register_tracer(&grpc_inproc_trace);
- grpc_inproc_transport_init();
-}
+void grpc_inproc_plugin_init(void) { grpc_inproc_transport_init(); }
void grpc_inproc_plugin_shutdown(void) { grpc_inproc_transport_shutdown(); }
diff --git a/src/core/ext/transport/inproc/inproc_transport.c b/src/core/ext/transport/inproc/inproc_transport.c
deleted file mode 100644
index 31739d07dd..0000000000
--- a/src/core/ext/transport/inproc/inproc_transport.c
+++ /dev/null
@@ -1,1299 +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 "src/core/ext/transport/inproc/inproc_transport.h"
-#include <grpc/support/alloc.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/time.h>
-#include <string.h>
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/surface/api_trace.h"
-#include "src/core/lib/surface/channel.h"
-#include "src/core/lib/surface/channel_stack_type.h"
-#include "src/core/lib/surface/server.h"
-#include "src/core/lib/transport/connectivity_state.h"
-#include "src/core/lib/transport/error_utils.h"
-#include "src/core/lib/transport/transport_impl.h"
-
-#define INPROC_LOG(...) \
- do { \
- if (GRPC_TRACER_ON(grpc_inproc_trace)) gpr_log(__VA_ARGS__); \
- } while (0)
-
-static grpc_slice g_empty_slice;
-static grpc_slice g_fake_path_key;
-static grpc_slice g_fake_path_value;
-static grpc_slice g_fake_auth_key;
-static grpc_slice g_fake_auth_value;
-
-typedef struct {
- gpr_mu mu;
- gpr_refcount refs;
-} shared_mu;
-
-typedef struct inproc_transport {
- grpc_transport base;
- shared_mu *mu;
- gpr_refcount refs;
- bool is_client;
- grpc_connectivity_state_tracker connectivity;
- void (*accept_stream_cb)(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_transport *transport, const void *server_data);
- void *accept_stream_data;
- bool is_closed;
- struct inproc_transport *other_side;
- struct inproc_stream *stream_list;
-} inproc_transport;
-
-typedef struct sb_list_entry {
- grpc_slice_buffer sb;
- struct sb_list_entry *next;
-} sb_list_entry;
-
-// Specialize grpc_byte_stream for our use case
-typedef struct {
- grpc_byte_stream base;
- sb_list_entry *le;
- grpc_error *shutdown_error;
-} inproc_slice_byte_stream;
-
-typedef struct {
- // TODO (vjpai): Add some inlined elements to avoid alloc in simple cases
- sb_list_entry *head;
- sb_list_entry *tail;
-} slice_buffer_list;
-
-static void slice_buffer_list_init(slice_buffer_list *l) {
- l->head = NULL;
- l->tail = NULL;
-}
-
-static void sb_list_entry_destroy(grpc_exec_ctx *exec_ctx, sb_list_entry *le) {
- grpc_slice_buffer_destroy_internal(exec_ctx, &le->sb);
- gpr_free(le);
-}
-
-static void slice_buffer_list_destroy(grpc_exec_ctx *exec_ctx,
- slice_buffer_list *l) {
- sb_list_entry *curr = l->head;
- while (curr != NULL) {
- sb_list_entry *le = curr;
- curr = curr->next;
- sb_list_entry_destroy(exec_ctx, le);
- }
- l->head = NULL;
- l->tail = NULL;
-}
-
-static bool slice_buffer_list_empty(slice_buffer_list *l) {
- return l->head == NULL;
-}
-
-static void slice_buffer_list_append_entry(slice_buffer_list *l,
- sb_list_entry *next) {
- next->next = NULL;
- if (l->tail) {
- l->tail->next = next;
- l->tail = next;
- } else {
- l->head = next;
- l->tail = next;
- }
-}
-
-static grpc_slice_buffer *slice_buffer_list_append(slice_buffer_list *l) {
- sb_list_entry *next = (sb_list_entry *)gpr_malloc(sizeof(*next));
- grpc_slice_buffer_init(&next->sb);
- slice_buffer_list_append_entry(l, next);
- return &next->sb;
-}
-
-static sb_list_entry *slice_buffer_list_pophead(slice_buffer_list *l) {
- sb_list_entry *ret = l->head;
- l->head = l->head->next;
- if (l->head == NULL) {
- l->tail = NULL;
- }
- return ret;
-}
-
-typedef struct inproc_stream {
- inproc_transport *t;
- grpc_metadata_batch to_read_initial_md;
- uint32_t to_read_initial_md_flags;
- bool to_read_initial_md_filled;
- slice_buffer_list to_read_message;
- grpc_metadata_batch to_read_trailing_md;
- bool to_read_trailing_md_filled;
- bool reads_needed;
- bool read_closure_scheduled;
- grpc_closure read_closure;
- // Write buffer used only during gap at init time when client-side
- // stream is set up but server side stream is not yet set up
- grpc_metadata_batch write_buffer_initial_md;
- bool write_buffer_initial_md_filled;
- uint32_t write_buffer_initial_md_flags;
- gpr_timespec write_buffer_deadline;
- slice_buffer_list write_buffer_message;
- grpc_metadata_batch write_buffer_trailing_md;
- bool write_buffer_trailing_md_filled;
- grpc_error *write_buffer_cancel_error;
-
- struct inproc_stream *other_side;
- bool other_side_closed; // won't talk anymore
- bool write_buffer_other_side_closed; // on hold
- grpc_stream_refcount *refs;
- grpc_closure *closure_at_destroy;
-
- gpr_arena *arena;
-
- grpc_transport_stream_op_batch *recv_initial_md_op;
- grpc_transport_stream_op_batch *recv_message_op;
- grpc_transport_stream_op_batch *recv_trailing_md_op;
-
- inproc_slice_byte_stream recv_message_stream;
-
- bool initial_md_sent;
- bool trailing_md_sent;
- bool initial_md_recvd;
- bool trailing_md_recvd;
-
- bool closed;
-
- grpc_error *cancel_self_error;
- grpc_error *cancel_other_error;
-
- gpr_timespec deadline;
-
- bool listed;
- struct inproc_stream *stream_list_prev;
- struct inproc_stream *stream_list_next;
-} inproc_stream;
-
-static bool inproc_slice_byte_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *bs, size_t max,
- grpc_closure *on_complete) {
- // Because inproc transport always provides the entire message atomically,
- // the byte stream always has data available when this function is called.
- // Thus, this function always returns true (unlike other transports) and
- // there is never any need to schedule a closure
- return true;
-}
-
-static grpc_error *inproc_slice_byte_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *bs,
- grpc_slice *slice) {
- inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs;
- if (stream->shutdown_error != GRPC_ERROR_NONE) {
- return GRPC_ERROR_REF(stream->shutdown_error);
- }
- *slice = grpc_slice_buffer_take_first(&stream->le->sb);
- return GRPC_ERROR_NONE;
-}
-
-static void inproc_slice_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *bs,
- grpc_error *error) {
- inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs;
- GRPC_ERROR_UNREF(stream->shutdown_error);
- stream->shutdown_error = error;
-}
-
-static void inproc_slice_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *bs) {
- inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs;
- sb_list_entry_destroy(exec_ctx, stream->le);
- GRPC_ERROR_UNREF(stream->shutdown_error);
-}
-
-static const grpc_byte_stream_vtable inproc_slice_byte_stream_vtable = {
- inproc_slice_byte_stream_next, inproc_slice_byte_stream_pull,
- inproc_slice_byte_stream_shutdown, inproc_slice_byte_stream_destroy};
-
-void inproc_slice_byte_stream_init(inproc_slice_byte_stream *s,
- sb_list_entry *le) {
- s->base.length = (uint32_t)le->sb.length;
- s->base.flags = 0;
- s->base.vtable = &inproc_slice_byte_stream_vtable;
- s->le = le;
- s->shutdown_error = GRPC_ERROR_NONE;
-}
-
-static void ref_transport(inproc_transport *t) {
- INPROC_LOG(GPR_DEBUG, "ref_transport %p", t);
- gpr_ref(&t->refs);
-}
-
-static void really_destroy_transport(grpc_exec_ctx *exec_ctx,
- inproc_transport *t) {
- INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t);
- grpc_connectivity_state_destroy(exec_ctx, &t->connectivity);
- if (gpr_unref(&t->mu->refs)) {
- gpr_free(t->mu);
- }
- gpr_free(t);
-}
-
-static void unref_transport(grpc_exec_ctx *exec_ctx, inproc_transport *t) {
- INPROC_LOG(GPR_DEBUG, "unref_transport %p", t);
- if (gpr_unref(&t->refs)) {
- really_destroy_transport(exec_ctx, t);
- }
-}
-
-#ifndef NDEBUG
-#define STREAM_REF(refs, reason) grpc_stream_ref(refs, reason)
-#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs, reason)
-#else
-#define STREAM_REF(refs, reason) grpc_stream_ref(refs)
-#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs)
-#endif
-
-static void ref_stream(inproc_stream *s, const char *reason) {
- INPROC_LOG(GPR_DEBUG, "ref_stream %p %s", s, reason);
- STREAM_REF(s->refs, reason);
-}
-
-static void unref_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- const char *reason) {
- INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason);
- STREAM_UNREF(exec_ctx, s->refs, reason);
-}
-
-static void really_destroy_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
- INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s);
-
- slice_buffer_list_destroy(exec_ctx, &s->to_read_message);
- slice_buffer_list_destroy(exec_ctx, &s->write_buffer_message);
- GRPC_ERROR_UNREF(s->write_buffer_cancel_error);
- GRPC_ERROR_UNREF(s->cancel_self_error);
- GRPC_ERROR_UNREF(s->cancel_other_error);
-
- unref_transport(exec_ctx, s->t);
-
- if (s->closure_at_destroy) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->closure_at_destroy, GRPC_ERROR_NONE);
- }
-}
-
-static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
-
-static void log_metadata(const grpc_metadata_batch *md_batch, bool is_client,
- bool is_initial) {
- for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL;
- md = md->next) {
- char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
- char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
- gpr_log(GPR_INFO, "INPROC:%s:%s: %s: %s", is_initial ? "HDR" : "TRL",
- is_client ? "CLI" : "SVR", key, value);
- gpr_free(key);
- gpr_free(value);
- }
-}
-
-static grpc_error *fill_in_metadata(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- const grpc_metadata_batch *metadata,
- uint32_t flags, grpc_metadata_batch *out_md,
- uint32_t *outflags, bool *markfilled) {
- if (GRPC_TRACER_ON(grpc_inproc_trace)) {
- log_metadata(metadata, s->t->is_client, outflags != NULL);
- }
-
- if (outflags != NULL) {
- *outflags = flags;
- }
- if (markfilled != NULL) {
- *markfilled = true;
- }
- grpc_error *error = GRPC_ERROR_NONE;
- for (grpc_linked_mdelem *elem = metadata->list.head;
- (elem != NULL) && (error == GRPC_ERROR_NONE); elem = elem->next) {
- grpc_linked_mdelem *nelem =
- (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*nelem));
- nelem->md = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(GRPC_MDKEY(elem->md)),
- grpc_slice_intern(GRPC_MDVALUE(elem->md)));
-
- error = grpc_metadata_batch_link_tail(exec_ctx, out_md, nelem);
- }
- return error;
-}
-
-static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
- INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
- inproc_transport *t = (inproc_transport *)gt;
- inproc_stream *s = (inproc_stream *)gs;
- s->arena = arena;
-
- s->refs = refcount;
- // Ref this stream right now
- ref_stream(s, "inproc_init_stream:init");
-
- grpc_metadata_batch_init(&s->to_read_initial_md);
- s->to_read_initial_md_flags = 0;
- s->to_read_initial_md_filled = false;
- grpc_metadata_batch_init(&s->to_read_trailing_md);
- s->to_read_trailing_md_filled = false;
- grpc_metadata_batch_init(&s->write_buffer_initial_md);
- s->write_buffer_initial_md_flags = 0;
- s->write_buffer_initial_md_filled = false;
- grpc_metadata_batch_init(&s->write_buffer_trailing_md);
- s->write_buffer_trailing_md_filled = false;
- slice_buffer_list_init(&s->to_read_message);
- slice_buffer_list_init(&s->write_buffer_message);
- s->reads_needed = false;
- s->read_closure_scheduled = false;
- GRPC_CLOSURE_INIT(&s->read_closure, read_state_machine, s,
- grpc_schedule_on_exec_ctx);
- s->t = t;
- s->closure_at_destroy = NULL;
- s->other_side_closed = false;
-
- s->initial_md_sent = s->trailing_md_sent = s->initial_md_recvd =
- s->trailing_md_recvd = false;
-
- s->closed = false;
-
- s->cancel_self_error = GRPC_ERROR_NONE;
- s->cancel_other_error = GRPC_ERROR_NONE;
- s->write_buffer_cancel_error = GRPC_ERROR_NONE;
- s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- s->write_buffer_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
-
- s->stream_list_prev = NULL;
- gpr_mu_lock(&t->mu->mu);
- s->listed = true;
- ref_stream(s, "inproc_init_stream:list");
- s->stream_list_next = t->stream_list;
- if (t->stream_list) {
- t->stream_list->stream_list_prev = s;
- }
- t->stream_list = s;
- gpr_mu_unlock(&t->mu->mu);
-
- if (!server_data) {
- ref_transport(t);
- inproc_transport *st = t->other_side;
- ref_transport(st);
- s->other_side = NULL; // will get filled in soon
- // Pass the client-side stream address to the server-side for a ref
- ref_stream(s, "inproc_init_stream:clt"); // ref it now on behalf of server
- // side to avoid destruction
- INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p",
- st->accept_stream_cb, st->accept_stream_data);
- (*st->accept_stream_cb)(exec_ctx, st->accept_stream_data, &st->base,
- (void *)s);
- } else {
- // This is the server-side and is being called through accept_stream_cb
- inproc_stream *cs = (inproc_stream *)server_data;
- s->other_side = cs;
- // Ref the server-side stream on behalf of the client now
- ref_stream(s, "inproc_init_stream:srv");
-
- // Now we are about to affect the other side, so lock the transport
- // to make sure that it doesn't get destroyed
- gpr_mu_lock(&s->t->mu->mu);
- cs->other_side = s;
- // Now transfer from the other side's write_buffer if any to the to_read
- // buffer
- if (cs->write_buffer_initial_md_filled) {
- fill_in_metadata(exec_ctx, s, &cs->write_buffer_initial_md,
- cs->write_buffer_initial_md_flags,
- &s->to_read_initial_md, &s->to_read_initial_md_flags,
- &s->to_read_initial_md_filled);
- s->deadline = gpr_time_min(s->deadline, cs->write_buffer_deadline);
- grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_initial_md);
- cs->write_buffer_initial_md_filled = false;
- }
- while (!slice_buffer_list_empty(&cs->write_buffer_message)) {
- slice_buffer_list_append_entry(
- &s->to_read_message,
- slice_buffer_list_pophead(&cs->write_buffer_message));
- }
- if (cs->write_buffer_trailing_md_filled) {
- fill_in_metadata(exec_ctx, s, &cs->write_buffer_trailing_md, 0,
- &s->to_read_trailing_md, NULL,
- &s->to_read_trailing_md_filled);
- grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_trailing_md);
- cs->write_buffer_trailing_md_filled = false;
- }
- if (cs->write_buffer_cancel_error != GRPC_ERROR_NONE) {
- s->cancel_other_error = cs->write_buffer_cancel_error;
- cs->write_buffer_cancel_error = GRPC_ERROR_NONE;
- }
-
- gpr_mu_unlock(&s->t->mu->mu);
- }
- return 0; // return value is not important
-}
-
-static void close_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
- if (!s->closed) {
- // Release the metadata that we would have written out
- grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_initial_md);
- grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_trailing_md);
-
- if (s->listed) {
- inproc_stream *p = s->stream_list_prev;
- inproc_stream *n = s->stream_list_next;
- if (p != NULL) {
- p->stream_list_next = n;
- } else {
- s->t->stream_list = n;
- }
- if (n != NULL) {
- n->stream_list_prev = p;
- }
- s->listed = false;
- unref_stream(exec_ctx, s, "close_stream:list");
- }
- s->closed = true;
- unref_stream(exec_ctx, s, "close_stream:closing");
- }
-}
-
-// This function means that we are done talking/listening to the other side
-static void close_other_side_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- const char *reason) {
- if (s->other_side != NULL) {
- // First release the metadata that came from the other side's arena
- grpc_metadata_batch_destroy(exec_ctx, &s->to_read_initial_md);
- grpc_metadata_batch_destroy(exec_ctx, &s->to_read_trailing_md);
-
- unref_stream(exec_ctx, s->other_side, reason);
- s->other_side_closed = true;
- s->other_side = NULL;
- } else if (!s->other_side_closed) {
- s->write_buffer_other_side_closed = true;
- }
-}
-
-static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- grpc_error *error) {
- INPROC_LOG(GPR_DEBUG, "read_state_machine %p fail_helper", s);
- // If we're failing this side, we need to make sure that
- // we also send or have already sent trailing metadata
- if (!s->trailing_md_sent) {
- // Send trailing md to the other side indicating cancellation
- s->trailing_md_sent = true;
-
- grpc_metadata_batch fake_md;
- grpc_metadata_batch_init(&fake_md);
-
- inproc_stream *other = s->other_side;
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
- : &other->to_read_trailing_md;
- bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
- : &other->to_read_trailing_md_filled;
- fill_in_metadata(exec_ctx, s, &fake_md, 0, dest, NULL, destfilled);
- grpc_metadata_batch_destroy(exec_ctx, &fake_md);
-
- if (other != NULL) {
- if (other->cancel_other_error == GRPC_ERROR_NONE) {
- other->cancel_other_error = GRPC_ERROR_REF(error);
- }
- if (other->reads_needed) {
- if (!other->read_closure_scheduled) {
- GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure,
- GRPC_ERROR_REF(error));
- other->read_closure_scheduled = true;
- }
- other->reads_needed = false;
- }
- } else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
- s->write_buffer_cancel_error = GRPC_ERROR_REF(error);
- }
- }
- if (s->recv_initial_md_op) {
- grpc_error *err;
- if (!s->t->is_client) {
- // If this is a server, provide initial metadata with a path and authority
- // since it expects that as well as no error yet
- grpc_metadata_batch fake_md;
- grpc_metadata_batch_init(&fake_md);
- grpc_linked_mdelem *path_md =
- (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*path_md));
- path_md->md =
- grpc_mdelem_from_slices(exec_ctx, g_fake_path_key, g_fake_path_value);
- GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, path_md) ==
- GRPC_ERROR_NONE);
- grpc_linked_mdelem *auth_md =
- (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*auth_md));
- auth_md->md =
- grpc_mdelem_from_slices(exec_ctx, g_fake_auth_key, g_fake_auth_value);
- GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, auth_md) ==
- GRPC_ERROR_NONE);
-
- fill_in_metadata(
- exec_ctx, s, &fake_md, 0,
- s->recv_initial_md_op->payload->recv_initial_metadata
- .recv_initial_metadata,
- s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
- NULL);
- grpc_metadata_batch_destroy(exec_ctx, &fake_md);
- err = GRPC_ERROR_NONE;
- } else {
- err = GRPC_ERROR_REF(error);
- }
- INPROC_LOG(GPR_DEBUG,
- "fail_helper %p scheduling initial-metadata-ready %p %p", s,
- error, err);
- GRPC_CLOSURE_SCHED(exec_ctx,
- s->recv_initial_md_op->payload->recv_initial_metadata
- .recv_initial_metadata_ready,
- err);
- // Last use of err so no need to REF and then UNREF it
-
- if ((s->recv_initial_md_op != s->recv_message_op) &&
- (s->recv_initial_md_op != s->recv_trailing_md_op)) {
- INPROC_LOG(GPR_DEBUG,
- "fail_helper %p scheduling initial-metadata-on-complete %p",
- error, s);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_initial_md_op->on_complete,
- GRPC_ERROR_REF(error));
- }
- s->recv_initial_md_op = NULL;
- }
- if (s->recv_message_op) {
- INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s,
- error);
- GRPC_CLOSURE_SCHED(
- exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
- GRPC_ERROR_REF(error));
- if (s->recv_message_op != s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-on-complete %p",
- s, error);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
- GRPC_ERROR_REF(error));
- }
- s->recv_message_op = NULL;
- }
- if (s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG,
- "fail_helper %p scheduling trailing-md-on-complete %p", s,
- error);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
- GRPC_ERROR_REF(error));
- s->recv_trailing_md_op = NULL;
- }
- close_other_side_locked(exec_ctx, s, "fail_helper:other_side");
- close_stream_locked(exec_ctx, s);
-
- GRPC_ERROR_UNREF(error);
-}
-
-static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- // This function gets called when we have contents in the unprocessed reads
- // Get what we want based on our ops wanted
- // Schedule our appropriate closures
- // and then return to reads_needed state if still needed
-
- // Since this is a closure directly invoked by the combiner, it should not
- // unref the error parameter explicitly; the combiner will do that implicitly
- grpc_error *new_err = GRPC_ERROR_NONE;
-
- bool needs_close = false;
-
- INPROC_LOG(GPR_DEBUG, "read_state_machine %p", arg);
- inproc_stream *s = (inproc_stream *)arg;
- gpr_mu *mu = &s->t->mu->mu; // keep aside in case s gets closed
- gpr_mu_lock(mu);
- s->read_closure_scheduled = false;
- // cancellation takes precedence
- if (s->cancel_self_error != GRPC_ERROR_NONE) {
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_self_error));
- goto done;
- } else if (s->cancel_other_error != GRPC_ERROR_NONE) {
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_other_error));
- goto done;
- } else if (error != GRPC_ERROR_NONE) {
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(error));
- goto done;
- }
-
- if (s->recv_initial_md_op) {
- if (!s->to_read_initial_md_filled) {
- // We entered the state machine on some other kind of read even though
- // we still haven't satisfied initial md . That's an error.
- new_err =
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexpected frame sequencing");
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p scheduling on_complete errors for no "
- "initial md %p",
- s, new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
- goto done;
- } else if (s->initial_md_recvd) {
- new_err =
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd initial md");
- INPROC_LOG(
- GPR_DEBUG,
- "read_state_machine %p scheduling on_complete errors for already "
- "recvd initial md %p",
- s, new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
- goto done;
- }
-
- s->initial_md_recvd = true;
- new_err = fill_in_metadata(
- exec_ctx, s, &s->to_read_initial_md, s->to_read_initial_md_flags,
- s->recv_initial_md_op->payload->recv_initial_metadata
- .recv_initial_metadata,
- s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags, NULL);
- s->recv_initial_md_op->payload->recv_initial_metadata.recv_initial_metadata
- ->deadline = s->deadline;
- grpc_metadata_batch_clear(exec_ctx, &s->to_read_initial_md);
- s->to_read_initial_md_filled = false;
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p scheduling initial-metadata-ready %p", s,
- new_err);
- GRPC_CLOSURE_SCHED(exec_ctx,
- s->recv_initial_md_op->payload->recv_initial_metadata
- .recv_initial_metadata_ready,
- GRPC_ERROR_REF(new_err));
- if ((s->recv_initial_md_op != s->recv_message_op) &&
- (s->recv_initial_md_op != s->recv_trailing_md_op)) {
- INPROC_LOG(
- GPR_DEBUG,
- "read_state_machine %p scheduling initial-metadata-on-complete %p", s,
- new_err);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_initial_md_op->on_complete,
- GRPC_ERROR_REF(new_err));
- }
- s->recv_initial_md_op = NULL;
-
- if (new_err != GRPC_ERROR_NONE) {
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p scheduling on_complete errors2 %p", s,
- new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
- goto done;
- }
- }
- if (s->to_read_initial_md_filled) {
- new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexpected recv frame");
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
- goto done;
- }
- if (!slice_buffer_list_empty(&s->to_read_message) && s->recv_message_op) {
- inproc_slice_byte_stream_init(
- &s->recv_message_stream,
- slice_buffer_list_pophead(&s->to_read_message));
- *s->recv_message_op->payload->recv_message.recv_message =
- &s->recv_message_stream.base;
- INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", s);
- GRPC_CLOSURE_SCHED(
- exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
- GRPC_ERROR_NONE);
- if (s->recv_message_op != s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p scheduling message-on-complete %p", s,
- new_err);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
- GRPC_ERROR_REF(new_err));
- }
- s->recv_message_op = NULL;
- }
- if (s->to_read_trailing_md_filled) {
- if (s->trailing_md_recvd) {
- new_err =
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd trailing md");
- INPROC_LOG(
- GPR_DEBUG,
- "read_state_machine %p scheduling on_complete errors for already "
- "recvd trailing md %p",
- s, new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
- goto done;
- }
- if (s->recv_message_op != NULL) {
- // This message needs to be wrapped up because it will never be
- // satisfied
- INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready",
- s);
- GRPC_CLOSURE_SCHED(
- exec_ctx,
- s->recv_message_op->payload->recv_message.recv_message_ready,
- GRPC_ERROR_NONE);
- if (s->recv_message_op != s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p scheduling message-on-complete %p", s,
- new_err);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
- GRPC_ERROR_REF(new_err));
- }
- s->recv_message_op = NULL;
- }
- if (s->recv_trailing_md_op != NULL) {
- // We wanted trailing metadata and we got it
- s->trailing_md_recvd = true;
- new_err =
- fill_in_metadata(exec_ctx, s, &s->to_read_trailing_md, 0,
- s->recv_trailing_md_op->payload
- ->recv_trailing_metadata.recv_trailing_metadata,
- NULL, NULL);
- grpc_metadata_batch_clear(exec_ctx, &s->to_read_trailing_md);
- s->to_read_trailing_md_filled = false;
-
- // We should schedule the recv_trailing_md_op completion if
- // 1. this stream is the client-side
- // 2. this stream is the server-side AND has already sent its trailing md
- // (If the server hasn't already sent its trailing md, it doesn't have
- // a final status, so don't mark this op complete)
- if (s->t->is_client || s->trailing_md_sent) {
- INPROC_LOG(
- GPR_DEBUG,
- "read_state_machine %p scheduling trailing-md-on-complete %p", s,
- new_err);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
- GRPC_ERROR_REF(new_err));
- s->recv_trailing_md_op = NULL;
- needs_close = true;
- } else {
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p server needs to delay handling "
- "trailing-md-on-complete %p",
- s, new_err);
- }
- } else {
- INPROC_LOG(
- GPR_DEBUG,
- "read_state_machine %p has trailing md but not yet waiting for it",
- s);
- }
- }
- if (s->trailing_md_recvd && s->recv_message_op) {
- // No further message will come on this stream, so finish off the
- // recv_message_op
- INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", s);
- GRPC_CLOSURE_SCHED(
- exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
- GRPC_ERROR_NONE);
- if (s->recv_message_op != s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG,
- "read_state_machine %p scheduling message-on-complete %p", s,
- new_err);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
- GRPC_ERROR_REF(new_err));
- }
- s->recv_message_op = NULL;
- }
- if (s->recv_message_op || s->recv_trailing_md_op) {
- // Didn't get the item we wanted so we still need to get
- // rescheduled
- INPROC_LOG(GPR_DEBUG, "read_state_machine %p still needs closure %p %p", s,
- s->recv_message_op, s->recv_trailing_md_op);
- s->reads_needed = true;
- }
-done:
- if (needs_close) {
- close_other_side_locked(exec_ctx, s, "read_state_machine");
- close_stream_locked(exec_ctx, s);
- }
- gpr_mu_unlock(mu);
- GRPC_ERROR_UNREF(new_err);
-}
-
-static grpc_closure do_nothing_closure;
-
-static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
- grpc_error *error) {
- bool ret = false; // was the cancel accepted
- INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s,
- grpc_error_string(error));
- if (s->cancel_self_error == GRPC_ERROR_NONE) {
- ret = true;
- s->cancel_self_error = GRPC_ERROR_REF(error);
- if (s->reads_needed) {
- if (!s->read_closure_scheduled) {
- GRPC_CLOSURE_SCHED(exec_ctx, &s->read_closure,
- GRPC_ERROR_REF(s->cancel_self_error));
- s->read_closure_scheduled = true;
- }
- s->reads_needed = false;
- }
- // Send trailing md to the other side indicating cancellation, even if we
- // already have
- s->trailing_md_sent = true;
-
- grpc_metadata_batch cancel_md;
- grpc_metadata_batch_init(&cancel_md);
-
- inproc_stream *other = s->other_side;
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
- : &other->to_read_trailing_md;
- bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
- : &other->to_read_trailing_md_filled;
- fill_in_metadata(exec_ctx, s, &cancel_md, 0, dest, NULL, destfilled);
- grpc_metadata_batch_destroy(exec_ctx, &cancel_md);
-
- if (other != NULL) {
- if (other->cancel_other_error == GRPC_ERROR_NONE) {
- other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
- }
- if (other->reads_needed) {
- if (!other->read_closure_scheduled) {
- GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure,
- GRPC_ERROR_REF(other->cancel_other_error));
- other->read_closure_scheduled = true;
- }
- other->reads_needed = false;
- }
- } else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
- s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error);
- }
-
- // if we are a server and already received trailing md but
- // couldn't complete that because we hadn't yet sent out trailing
- // md, now's the chance
- if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG,
- "cancel_stream %p scheduling trailing-md-on-complete %p", s,
- s->cancel_self_error);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
- GRPC_ERROR_REF(s->cancel_self_error));
- s->recv_trailing_md_op = NULL;
- }
- }
-
- close_other_side_locked(exec_ctx, s, "cancel_stream:other_side");
- close_stream_locked(exec_ctx, s);
-
- GRPC_ERROR_UNREF(error);
- return ret;
-}
-
-static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_transport_stream_op_batch *op) {
- INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
- inproc_stream *s = (inproc_stream *)gs;
- gpr_mu *mu = &s->t->mu->mu; // save aside in case s gets closed
- gpr_mu_lock(mu);
-
- if (GRPC_TRACER_ON(grpc_inproc_trace)) {
- if (op->send_initial_metadata) {
- log_metadata(op->payload->send_initial_metadata.send_initial_metadata,
- s->t->is_client, true);
- }
- if (op->send_trailing_metadata) {
- log_metadata(op->payload->send_trailing_metadata.send_trailing_metadata,
- s->t->is_client, false);
- }
- }
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_closure *on_complete = op->on_complete;
- if (on_complete == NULL) {
- on_complete = &do_nothing_closure;
- }
-
- if (op->cancel_stream) {
- // Call cancel_stream_locked without ref'ing the cancel_error because
- // this function is responsible to make sure that that field gets unref'ed
- cancel_stream_locked(exec_ctx, s, op->payload->cancel_stream.cancel_error);
- // this op can complete without an error
- } else if (s->cancel_self_error != GRPC_ERROR_NONE) {
- // already self-canceled so still give it an error
- error = GRPC_ERROR_REF(s->cancel_self_error);
- } else {
- INPROC_LOG(GPR_DEBUG, "perform_stream_op %p%s%s%s%s%s%s", s,
- op->send_initial_metadata ? " send_initial_metadata" : "",
- op->send_message ? " send_message" : "",
- op->send_trailing_metadata ? " send_trailing_metadata" : "",
- op->recv_initial_metadata ? " recv_initial_metadata" : "",
- op->recv_message ? " recv_message" : "",
- op->recv_trailing_metadata ? " recv_trailing_metadata" : "");
- }
-
- bool needs_close = false;
-
- if (error == GRPC_ERROR_NONE &&
- (op->send_initial_metadata || op->send_message ||
- op->send_trailing_metadata)) {
- inproc_stream *other = s->other_side;
- if (s->t->is_closed) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
- }
- if (error == GRPC_ERROR_NONE && op->send_initial_metadata) {
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_initial_md
- : &other->to_read_initial_md;
- uint32_t *destflags = (other == NULL) ? &s->write_buffer_initial_md_flags
- : &other->to_read_initial_md_flags;
- bool *destfilled = (other == NULL) ? &s->write_buffer_initial_md_filled
- : &other->to_read_initial_md_filled;
- if (*destfilled || s->initial_md_sent) {
- // The buffer is already in use; that's an error!
- INPROC_LOG(GPR_DEBUG, "Extra initial metadata %p", s);
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra initial metadata");
- } else {
- if (!other->closed) {
- fill_in_metadata(
- exec_ctx, s,
- op->payload->send_initial_metadata.send_initial_metadata,
- op->payload->send_initial_metadata.send_initial_metadata_flags,
- dest, destflags, destfilled);
- }
- if (s->t->is_client) {
- gpr_timespec *dl =
- (other == NULL) ? &s->write_buffer_deadline : &other->deadline;
- *dl = gpr_time_min(*dl, op->payload->send_initial_metadata
- .send_initial_metadata->deadline);
- s->initial_md_sent = true;
- }
- }
- }
- if (error == GRPC_ERROR_NONE && op->send_message) {
- size_t remaining = op->payload->send_message.send_message->length;
- grpc_slice_buffer *dest = slice_buffer_list_append(
- (other == NULL) ? &s->write_buffer_message : &other->to_read_message);
- do {
- grpc_slice message_slice;
- grpc_closure unused;
- GPR_ASSERT(grpc_byte_stream_next(exec_ctx,
- op->payload->send_message.send_message,
- SIZE_MAX, &unused));
- error = grpc_byte_stream_pull(
- exec_ctx, op->payload->send_message.send_message, &message_slice);
- if (error != GRPC_ERROR_NONE) {
- cancel_stream_locked(exec_ctx, s, GRPC_ERROR_REF(error));
- break;
- }
- GPR_ASSERT(error == GRPC_ERROR_NONE);
- remaining -= GRPC_SLICE_LENGTH(message_slice);
- grpc_slice_buffer_add(dest, message_slice);
- } while (remaining != 0);
- grpc_byte_stream_destroy(exec_ctx,
- op->payload->send_message.send_message);
- }
- if (error == GRPC_ERROR_NONE && op->send_trailing_metadata) {
- grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
- : &other->to_read_trailing_md;
- bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
- : &other->to_read_trailing_md_filled;
- if (*destfilled || s->trailing_md_sent) {
- // The buffer is already in use; that's an error!
- INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s);
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata");
- } else {
- if (!other->closed) {
- fill_in_metadata(
- exec_ctx, s,
- op->payload->send_trailing_metadata.send_trailing_metadata, 0,
- dest, NULL, destfilled);
- }
- s->trailing_md_sent = true;
- if (!s->t->is_client && s->trailing_md_recvd &&
- s->recv_trailing_md_op) {
- INPROC_LOG(GPR_DEBUG,
- "perform_stream_op %p scheduling trailing-md-on-complete",
- s);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
- GRPC_ERROR_NONE);
- s->recv_trailing_md_op = NULL;
- needs_close = true;
- }
- }
- }
- if (other != NULL && other->reads_needed) {
- if (!other->read_closure_scheduled) {
- GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure, error);
- other->read_closure_scheduled = true;
- }
- other->reads_needed = false;
- }
- }
- if (error == GRPC_ERROR_NONE &&
- (op->recv_initial_metadata || op->recv_message ||
- op->recv_trailing_metadata)) {
- // If there are any reads, mark it so that the read closure will react to
- // them
- if (op->recv_initial_metadata) {
- s->recv_initial_md_op = op;
- }
- if (op->recv_message) {
- s->recv_message_op = op;
- }
- if (op->recv_trailing_metadata) {
- s->recv_trailing_md_op = op;
- }
-
- // We want to initiate the closure if:
- // 1. There is initial metadata and something ready to take that
- // 2. There is a message and something ready to take it
- // 3. There is trailing metadata, even if nothing specifically wants
- // that because that can shut down the message as well
- if ((s->to_read_initial_md_filled && op->recv_initial_metadata) ||
- ((!slice_buffer_list_empty(&s->to_read_message) ||
- s->trailing_md_recvd) &&
- op->recv_message) ||
- (s->to_read_trailing_md_filled)) {
- if (!s->read_closure_scheduled) {
- GRPC_CLOSURE_SCHED(exec_ctx, &s->read_closure, GRPC_ERROR_NONE);
- s->read_closure_scheduled = true;
- }
- } else {
- s->reads_needed = true;
- }
- } else {
- if (error != GRPC_ERROR_NONE) {
- // Schedule op's read closures that we didn't push to read state machine
- if (op->recv_initial_metadata) {
- INPROC_LOG(
- GPR_DEBUG,
- "perform_stream_op error %p scheduling initial-metadata-ready %p",
- s, error);
- GRPC_CLOSURE_SCHED(
- exec_ctx,
- op->payload->recv_initial_metadata.recv_initial_metadata_ready,
- GRPC_ERROR_REF(error));
- }
- if (op->recv_message) {
- INPROC_LOG(
- GPR_DEBUG,
- "perform_stream_op error %p scheduling recv message-ready %p", s,
- error);
- GRPC_CLOSURE_SCHED(exec_ctx,
- op->payload->recv_message.recv_message_ready,
- GRPC_ERROR_REF(error));
- }
- }
- INPROC_LOG(GPR_DEBUG, "perform_stream_op %p scheduling on_complete %p", s,
- error);
- GRPC_CLOSURE_SCHED(exec_ctx, on_complete, GRPC_ERROR_REF(error));
- }
- if (needs_close) {
- close_other_side_locked(exec_ctx, s, "perform_stream_op:other_side");
- close_stream_locked(exec_ctx, s);
- }
- gpr_mu_unlock(mu);
- GRPC_ERROR_UNREF(error);
-}
-
-static void close_transport_locked(grpc_exec_ctx *exec_ctx,
- inproc_transport *t) {
- INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed);
- grpc_connectivity_state_set(
- exec_ctx, &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."),
- "close transport");
- if (!t->is_closed) {
- t->is_closed = true;
- /* Also end all streams on this transport */
- while (t->stream_list != NULL) {
- // cancel_stream_locked also adjusts stream list
- cancel_stream_locked(
- exec_ctx, t->stream_list,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
- }
- }
-}
-
-static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_transport_op *op) {
- inproc_transport *t = (inproc_transport *)gt;
- INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
- gpr_mu_lock(&t->mu->mu);
- if (op->on_connectivity_state_change) {
- grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &t->connectivity, op->connectivity_state,
- op->on_connectivity_state_change);
- }
- if (op->set_accept_stream) {
- t->accept_stream_cb = op->set_accept_stream_fn;
- t->accept_stream_data = op->set_accept_stream_user_data;
- }
- if (op->on_consumed) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
- }
-
- bool do_close = false;
- if (op->goaway_error != GRPC_ERROR_NONE) {
- do_close = true;
- GRPC_ERROR_UNREF(op->goaway_error);
- }
- if (op->disconnect_with_error != GRPC_ERROR_NONE) {
- do_close = true;
- GRPC_ERROR_UNREF(op->disconnect_with_error);
- }
-
- if (do_close) {
- close_transport_locked(exec_ctx, t);
- }
- gpr_mu_unlock(&t->mu->mu);
-}
-
-static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs,
- grpc_closure *then_schedule_closure) {
- INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
- inproc_stream *s = (inproc_stream *)gs;
- s->closure_at_destroy = then_schedule_closure;
- really_destroy_stream(exec_ctx, s);
-}
-
-static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
- inproc_transport *t = (inproc_transport *)gt;
- INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
- gpr_mu_lock(&t->mu->mu);
- close_transport_locked(exec_ctx, t);
- gpr_mu_unlock(&t->mu->mu);
- unref_transport(exec_ctx, t->other_side);
- unref_transport(exec_ctx, t);
-}
-
-/*******************************************************************************
- * INTEGRATION GLUE
- */
-
-static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset *pollset) {
- // Nothing to do here
-}
-
-static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
- grpc_stream *gs, grpc_pollset_set *pollset_set) {
- // Nothing to do here
-}
-
-static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
- return NULL;
-}
-
-/*******************************************************************************
- * GLOBAL INIT AND DESTROY
- */
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
-
-void grpc_inproc_transport_init(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL,
- grpc_schedule_on_exec_ctx);
- g_empty_slice = grpc_slice_from_static_buffer(NULL, 0);
-
- grpc_slice key_tmp = grpc_slice_from_static_string(":path");
- g_fake_path_key = grpc_slice_intern(key_tmp);
- grpc_slice_unref_internal(&exec_ctx, key_tmp);
-
- g_fake_path_value = grpc_slice_from_static_string("/");
-
- grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
- g_fake_auth_key = grpc_slice_intern(auth_tmp);
- grpc_slice_unref_internal(&exec_ctx, auth_tmp);
-
- g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static const grpc_transport_vtable inproc_vtable = {
- sizeof(inproc_stream), "inproc", init_stream,
- set_pollset, set_pollset_set, perform_stream_op,
- perform_transport_op, destroy_stream, destroy_transport,
- get_endpoint};
-
-/*******************************************************************************
- * Main inproc transport functions
- */
-static void inproc_transports_create(grpc_exec_ctx *exec_ctx,
- grpc_transport **server_transport,
- const grpc_channel_args *server_args,
- grpc_transport **client_transport,
- const grpc_channel_args *client_args) {
- INPROC_LOG(GPR_DEBUG, "inproc_transports_create");
- inproc_transport *st = (inproc_transport *)gpr_zalloc(sizeof(*st));
- inproc_transport *ct = (inproc_transport *)gpr_zalloc(sizeof(*ct));
- // Share one lock between both sides since both sides get affected
- st->mu = ct->mu = (shared_mu *)gpr_malloc(sizeof(*st->mu));
- gpr_mu_init(&st->mu->mu);
- gpr_ref_init(&st->mu->refs, 2);
- st->base.vtable = &inproc_vtable;
- ct->base.vtable = &inproc_vtable;
- // Start each side of transport with 2 refs since they each have a ref
- // to the other
- gpr_ref_init(&st->refs, 2);
- gpr_ref_init(&ct->refs, 2);
- st->is_client = false;
- ct->is_client = true;
- grpc_connectivity_state_init(&st->connectivity, GRPC_CHANNEL_READY,
- "inproc_server");
- grpc_connectivity_state_init(&ct->connectivity, GRPC_CHANNEL_READY,
- "inproc_client");
- st->other_side = ct;
- ct->other_side = st;
- st->stream_list = NULL;
- ct->stream_list = NULL;
- *server_transport = (grpc_transport *)st;
- *client_transport = (grpc_transport *)ct;
-}
-
-grpc_channel *grpc_inproc_channel_create(grpc_server *server,
- grpc_channel_args *args,
- void *reserved) {
- GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2,
- (server, args));
-
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- const grpc_channel_args *server_args = grpc_server_get_channel_args(server);
-
- // Add a default authority channel argument for the client
-
- grpc_arg default_authority_arg;
- default_authority_arg.type = GRPC_ARG_STRING;
- default_authority_arg.key = (char *)GRPC_ARG_DEFAULT_AUTHORITY;
- default_authority_arg.value.string = (char *)"inproc.authority";
- grpc_channel_args *client_args =
- grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
-
- grpc_transport *server_transport;
- grpc_transport *client_transport;
- inproc_transports_create(&exec_ctx, &server_transport, server_args,
- &client_transport, client_args);
-
- grpc_server_setup_transport(&exec_ctx, server, server_transport, NULL,
- server_args);
- grpc_channel *channel =
- grpc_channel_create(&exec_ctx, "inproc", client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
-
- // Free up created channel args
- grpc_channel_args_destroy(&exec_ctx, client_args);
-
- // Now finish scheduled operations
- grpc_exec_ctx_finish(&exec_ctx);
-
- return channel;
-}
-
-void grpc_inproc_transport_shutdown(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, g_empty_slice);
- grpc_slice_unref_internal(&exec_ctx, g_fake_path_key);
- grpc_slice_unref_internal(&exec_ctx, g_fake_path_value);
- grpc_slice_unref_internal(&exec_ctx, g_fake_auth_key);
- grpc_slice_unref_internal(&exec_ctx, g_fake_auth_value);
- grpc_exec_ctx_finish(&exec_ctx);
-}
diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc
new file mode 100644
index 0000000000..8dd0b7dce2
--- /dev/null
+++ b/src/core/ext/transport/inproc/inproc_transport.cc
@@ -0,0 +1,1223 @@
+/*
+ *
+ * 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 "src/core/ext/transport/inproc/inproc_transport.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/time.h>
+#include <string.h>
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/surface/api_trace.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/channel_stack_type.h"
+#include "src/core/lib/surface/server.h"
+#include "src/core/lib/transport/connectivity_state.h"
+#include "src/core/lib/transport/error_utils.h"
+#include "src/core/lib/transport/transport_impl.h"
+
+#define INPROC_LOG(...) \
+ do { \
+ if (grpc_inproc_trace.enabled()) gpr_log(__VA_ARGS__); \
+ } while (0)
+
+static grpc_slice g_empty_slice;
+static grpc_slice g_fake_path_key;
+static grpc_slice g_fake_path_value;
+static grpc_slice g_fake_auth_key;
+static grpc_slice g_fake_auth_value;
+
+typedef struct {
+ gpr_mu mu;
+ gpr_refcount refs;
+} shared_mu;
+
+typedef struct inproc_transport {
+ grpc_transport base;
+ shared_mu* mu;
+ gpr_refcount refs;
+ bool is_client;
+ grpc_connectivity_state_tracker connectivity;
+ void (*accept_stream_cb)(void* user_data, grpc_transport* transport,
+ const void* server_data);
+ void* accept_stream_data;
+ bool is_closed;
+ struct inproc_transport* other_side;
+ struct inproc_stream* stream_list;
+} inproc_transport;
+
+typedef struct inproc_stream {
+ inproc_transport* t;
+ grpc_metadata_batch to_read_initial_md;
+ uint32_t to_read_initial_md_flags;
+ bool to_read_initial_md_filled;
+ grpc_metadata_batch to_read_trailing_md;
+ bool to_read_trailing_md_filled;
+ bool ops_needed;
+ bool op_closure_scheduled;
+ grpc_closure op_closure;
+ // Write buffer used only during gap at init time when client-side
+ // stream is set up but server side stream is not yet set up
+ grpc_metadata_batch write_buffer_initial_md;
+ bool write_buffer_initial_md_filled;
+ uint32_t write_buffer_initial_md_flags;
+ grpc_millis write_buffer_deadline;
+ grpc_metadata_batch write_buffer_trailing_md;
+ bool write_buffer_trailing_md_filled;
+ grpc_error* write_buffer_cancel_error;
+
+ struct inproc_stream* other_side;
+ bool other_side_closed; // won't talk anymore
+ bool write_buffer_other_side_closed; // on hold
+ grpc_stream_refcount* refs;
+ grpc_closure* closure_at_destroy;
+
+ gpr_arena* arena;
+
+ grpc_transport_stream_op_batch* send_message_op;
+ grpc_transport_stream_op_batch* send_trailing_md_op;
+ grpc_transport_stream_op_batch* recv_initial_md_op;
+ grpc_transport_stream_op_batch* recv_message_op;
+ grpc_transport_stream_op_batch* recv_trailing_md_op;
+
+ grpc_slice_buffer recv_message;
+ grpc_slice_buffer_stream recv_stream;
+ bool recv_inited;
+
+ bool initial_md_sent;
+ bool trailing_md_sent;
+ bool initial_md_recvd;
+ bool trailing_md_recvd;
+
+ bool closed;
+
+ grpc_error* cancel_self_error;
+ grpc_error* cancel_other_error;
+
+ grpc_millis deadline;
+
+ bool listed;
+ struct inproc_stream* stream_list_prev;
+ struct inproc_stream* stream_list_next;
+} inproc_stream;
+
+static grpc_closure do_nothing_closure;
+static bool cancel_stream_locked(inproc_stream* s, grpc_error* error);
+static void op_state_machine(void* arg, grpc_error* error);
+
+static void ref_transport(inproc_transport* t) {
+ INPROC_LOG(GPR_DEBUG, "ref_transport %p", t);
+ gpr_ref(&t->refs);
+}
+
+static void really_destroy_transport(inproc_transport* t) {
+ INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t);
+ grpc_connectivity_state_destroy(&t->connectivity);
+ if (gpr_unref(&t->mu->refs)) {
+ gpr_free(t->mu);
+ }
+ gpr_free(t);
+}
+
+static void unref_transport(inproc_transport* t) {
+ INPROC_LOG(GPR_DEBUG, "unref_transport %p", t);
+ if (gpr_unref(&t->refs)) {
+ really_destroy_transport(t);
+ }
+}
+
+#ifndef NDEBUG
+#define STREAM_REF(refs, reason) grpc_stream_ref(refs, reason)
+#define STREAM_UNREF(refs, reason) grpc_stream_unref(refs, reason)
+#else
+#define STREAM_REF(refs, reason) grpc_stream_ref(refs)
+#define STREAM_UNREF(refs, reason) grpc_stream_unref(refs)
+#endif
+
+static void ref_stream(inproc_stream* s, const char* reason) {
+ INPROC_LOG(GPR_DEBUG, "ref_stream %p %s", s, reason);
+ STREAM_REF(s->refs, reason);
+}
+
+static void unref_stream(inproc_stream* s, const char* reason) {
+ INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason);
+ STREAM_UNREF(s->refs, reason);
+}
+
+static void really_destroy_stream(inproc_stream* s) {
+ INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s);
+
+ GRPC_ERROR_UNREF(s->write_buffer_cancel_error);
+ GRPC_ERROR_UNREF(s->cancel_self_error);
+ GRPC_ERROR_UNREF(s->cancel_other_error);
+
+ if (s->recv_inited) {
+ grpc_slice_buffer_destroy_internal(&s->recv_message);
+ }
+
+ unref_transport(s->t);
+
+ if (s->closure_at_destroy) {
+ GRPC_CLOSURE_SCHED(s->closure_at_destroy, GRPC_ERROR_NONE);
+ }
+}
+
+static void log_metadata(const grpc_metadata_batch* md_batch, bool is_client,
+ bool is_initial) {
+ for (grpc_linked_mdelem* md = md_batch->list.head; md != nullptr;
+ md = md->next) {
+ char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
+ char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
+ gpr_log(GPR_INFO, "INPROC:%s:%s: %s: %s", is_initial ? "HDR" : "TRL",
+ is_client ? "CLI" : "SVR", key, value);
+ gpr_free(key);
+ gpr_free(value);
+ }
+}
+
+static grpc_error* fill_in_metadata(inproc_stream* s,
+ const grpc_metadata_batch* metadata,
+ uint32_t flags, grpc_metadata_batch* out_md,
+ uint32_t* outflags, bool* markfilled) {
+ if (grpc_inproc_trace.enabled()) {
+ log_metadata(metadata, s->t->is_client, outflags != nullptr);
+ }
+
+ if (outflags != nullptr) {
+ *outflags = flags;
+ }
+ if (markfilled != nullptr) {
+ *markfilled = true;
+ }
+ grpc_error* error = GRPC_ERROR_NONE;
+ for (grpc_linked_mdelem* elem = metadata->list.head;
+ (elem != nullptr) && (error == GRPC_ERROR_NONE); elem = elem->next) {
+ grpc_linked_mdelem* nelem =
+ (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*nelem));
+ nelem->md =
+ grpc_mdelem_from_slices(grpc_slice_intern(GRPC_MDKEY(elem->md)),
+ grpc_slice_intern(GRPC_MDVALUE(elem->md)));
+
+ error = grpc_metadata_batch_link_tail(out_md, nelem);
+ }
+ return error;
+}
+
+static int init_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
+ INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
+ inproc_transport* t = (inproc_transport*)gt;
+ inproc_stream* s = (inproc_stream*)gs;
+ s->arena = arena;
+
+ s->refs = refcount;
+ // Ref this stream right now
+ ref_stream(s, "inproc_init_stream:init");
+
+ grpc_metadata_batch_init(&s->to_read_initial_md);
+ s->to_read_initial_md_flags = 0;
+ s->to_read_initial_md_filled = false;
+ grpc_metadata_batch_init(&s->to_read_trailing_md);
+ s->to_read_trailing_md_filled = false;
+ grpc_metadata_batch_init(&s->write_buffer_initial_md);
+ s->write_buffer_initial_md_flags = 0;
+ s->write_buffer_initial_md_filled = false;
+ grpc_metadata_batch_init(&s->write_buffer_trailing_md);
+ s->write_buffer_trailing_md_filled = false;
+ s->ops_needed = false;
+ s->op_closure_scheduled = false;
+ GRPC_CLOSURE_INIT(&s->op_closure, op_state_machine, s,
+ grpc_schedule_on_exec_ctx);
+ s->t = t;
+ s->closure_at_destroy = nullptr;
+ s->other_side_closed = false;
+
+ s->initial_md_sent = s->trailing_md_sent = s->initial_md_recvd =
+ s->trailing_md_recvd = false;
+
+ s->closed = false;
+
+ s->cancel_self_error = GRPC_ERROR_NONE;
+ s->cancel_other_error = GRPC_ERROR_NONE;
+ s->write_buffer_cancel_error = GRPC_ERROR_NONE;
+ s->deadline = GRPC_MILLIS_INF_FUTURE;
+ s->write_buffer_deadline = GRPC_MILLIS_INF_FUTURE;
+
+ s->stream_list_prev = nullptr;
+ gpr_mu_lock(&t->mu->mu);
+ s->listed = true;
+ ref_stream(s, "inproc_init_stream:list");
+ s->stream_list_next = t->stream_list;
+ if (t->stream_list) {
+ t->stream_list->stream_list_prev = s;
+ }
+ t->stream_list = s;
+ gpr_mu_unlock(&t->mu->mu);
+
+ if (!server_data) {
+ ref_transport(t);
+ inproc_transport* st = t->other_side;
+ ref_transport(st);
+ s->other_side = nullptr; // will get filled in soon
+ // Pass the client-side stream address to the server-side for a ref
+ ref_stream(s, "inproc_init_stream:clt"); // ref it now on behalf of server
+ // side to avoid destruction
+ INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p",
+ st->accept_stream_cb, st->accept_stream_data);
+ (*st->accept_stream_cb)(st->accept_stream_data, &st->base, (void*)s);
+ } else {
+ // This is the server-side and is being called through accept_stream_cb
+ inproc_stream* cs = (inproc_stream*)server_data;
+ s->other_side = cs;
+ // Ref the server-side stream on behalf of the client now
+ ref_stream(s, "inproc_init_stream:srv");
+
+ // Now we are about to affect the other side, so lock the transport
+ // to make sure that it doesn't get destroyed
+ gpr_mu_lock(&s->t->mu->mu);
+ cs->other_side = s;
+ // Now transfer from the other side's write_buffer if any to the to_read
+ // buffer
+ if (cs->write_buffer_initial_md_filled) {
+ fill_in_metadata(s, &cs->write_buffer_initial_md,
+ cs->write_buffer_initial_md_flags,
+ &s->to_read_initial_md, &s->to_read_initial_md_flags,
+ &s->to_read_initial_md_filled);
+ s->deadline = GPR_MIN(s->deadline, cs->write_buffer_deadline);
+ grpc_metadata_batch_clear(&cs->write_buffer_initial_md);
+ cs->write_buffer_initial_md_filled = false;
+ }
+ if (cs->write_buffer_trailing_md_filled) {
+ fill_in_metadata(s, &cs->write_buffer_trailing_md, 0,
+ &s->to_read_trailing_md, nullptr,
+ &s->to_read_trailing_md_filled);
+ grpc_metadata_batch_clear(&cs->write_buffer_trailing_md);
+ cs->write_buffer_trailing_md_filled = false;
+ }
+ if (cs->write_buffer_cancel_error != GRPC_ERROR_NONE) {
+ s->cancel_other_error = cs->write_buffer_cancel_error;
+ cs->write_buffer_cancel_error = GRPC_ERROR_NONE;
+ }
+
+ gpr_mu_unlock(&s->t->mu->mu);
+ }
+ return 0; // return value is not important
+}
+
+static void close_stream_locked(inproc_stream* s) {
+ if (!s->closed) {
+ // Release the metadata that we would have written out
+ grpc_metadata_batch_destroy(&s->write_buffer_initial_md);
+ grpc_metadata_batch_destroy(&s->write_buffer_trailing_md);
+
+ if (s->listed) {
+ inproc_stream* p = s->stream_list_prev;
+ inproc_stream* n = s->stream_list_next;
+ if (p != nullptr) {
+ p->stream_list_next = n;
+ } else {
+ s->t->stream_list = n;
+ }
+ if (n != nullptr) {
+ n->stream_list_prev = p;
+ }
+ s->listed = false;
+ unref_stream(s, "close_stream:list");
+ }
+ s->closed = true;
+ unref_stream(s, "close_stream:closing");
+ }
+}
+
+// This function means that we are done talking/listening to the other side
+static void close_other_side_locked(inproc_stream* s, const char* reason) {
+ if (s->other_side != nullptr) {
+ // First release the metadata that came from the other side's arena
+ grpc_metadata_batch_destroy(&s->to_read_initial_md);
+ grpc_metadata_batch_destroy(&s->to_read_trailing_md);
+
+ unref_stream(s->other_side, reason);
+ s->other_side_closed = true;
+ s->other_side = nullptr;
+ } else if (!s->other_side_closed) {
+ s->write_buffer_other_side_closed = true;
+ }
+}
+
+// Call the on_complete closure associated with this stream_op_batch if
+// this stream_op_batch is only one of the pending operations for this
+// stream. This is called when one of the pending operations for the stream
+// is done and about to be NULLed out
+static void complete_if_batch_end_locked(inproc_stream* s, grpc_error* error,
+ grpc_transport_stream_op_batch* op,
+ const char* msg) {
+ int is_sm = (int)(op == s->send_message_op);
+ int is_stm = (int)(op == s->send_trailing_md_op);
+ int is_rim = (int)(op == s->recv_initial_md_op);
+ int is_rm = (int)(op == s->recv_message_op);
+ int is_rtm = (int)(op == s->recv_trailing_md_op);
+
+ if ((is_sm + is_stm + is_rim + is_rm + is_rtm) == 1) {
+ INPROC_LOG(GPR_DEBUG, "%s %p %p %p", msg, s, op, error);
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_REF(error));
+ }
+}
+
+static void maybe_schedule_op_closure_locked(inproc_stream* s,
+ grpc_error* error) {
+ if (s && s->ops_needed && !s->op_closure_scheduled) {
+ GRPC_CLOSURE_SCHED(&s->op_closure, GRPC_ERROR_REF(error));
+ s->op_closure_scheduled = true;
+ s->ops_needed = false;
+ }
+}
+
+static void fail_helper_locked(inproc_stream* s, grpc_error* error) {
+ INPROC_LOG(GPR_DEBUG, "op_state_machine %p fail_helper", s);
+ // If we're failing this side, we need to make sure that
+ // we also send or have already sent trailing metadata
+ if (!s->trailing_md_sent) {
+ // Send trailing md to the other side indicating cancellation
+ s->trailing_md_sent = true;
+
+ grpc_metadata_batch fake_md;
+ grpc_metadata_batch_init(&fake_md);
+
+ inproc_stream* other = s->other_side;
+ grpc_metadata_batch* dest = (other == nullptr)
+ ? &s->write_buffer_trailing_md
+ : &other->to_read_trailing_md;
+ bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled
+ : &other->to_read_trailing_md_filled;
+ fill_in_metadata(s, &fake_md, 0, dest, nullptr, destfilled);
+ grpc_metadata_batch_destroy(&fake_md);
+
+ if (other != nullptr) {
+ if (other->cancel_other_error == GRPC_ERROR_NONE) {
+ other->cancel_other_error = GRPC_ERROR_REF(error);
+ }
+ maybe_schedule_op_closure_locked(other, error);
+ } else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
+ s->write_buffer_cancel_error = GRPC_ERROR_REF(error);
+ }
+ }
+ if (s->recv_initial_md_op) {
+ grpc_error* err;
+ if (!s->t->is_client) {
+ // If this is a server, provide initial metadata with a path and authority
+ // since it expects that as well as no error yet
+ grpc_metadata_batch fake_md;
+ grpc_metadata_batch_init(&fake_md);
+ grpc_linked_mdelem* path_md =
+ (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*path_md));
+ path_md->md = grpc_mdelem_from_slices(g_fake_path_key, g_fake_path_value);
+ GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, path_md) ==
+ GRPC_ERROR_NONE);
+ grpc_linked_mdelem* auth_md =
+ (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*auth_md));
+ auth_md->md = grpc_mdelem_from_slices(g_fake_auth_key, g_fake_auth_value);
+ GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, auth_md) ==
+ GRPC_ERROR_NONE);
+
+ fill_in_metadata(
+ s, &fake_md, 0,
+ s->recv_initial_md_op->payload->recv_initial_metadata
+ .recv_initial_metadata,
+ s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
+ nullptr);
+ grpc_metadata_batch_destroy(&fake_md);
+ err = GRPC_ERROR_NONE;
+ } else {
+ err = GRPC_ERROR_REF(error);
+ }
+ if (s->recv_initial_md_op->payload->recv_initial_metadata
+ .trailing_metadata_available != nullptr) {
+ // Set to true unconditionally, because we're failing the call, so even
+ // if we haven't actually seen the send_trailing_metadata op from the
+ // other side, we're going to return trailing metadata anyway.
+ *s->recv_initial_md_op->payload->recv_initial_metadata
+ .trailing_metadata_available = true;
+ }
+ INPROC_LOG(GPR_DEBUG,
+ "fail_helper %p scheduling initial-metadata-ready %p %p", s,
+ error, err);
+ GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata
+ .recv_initial_metadata_ready,
+ err);
+ // Last use of err so no need to REF and then UNREF it
+
+ complete_if_batch_end_locked(
+ s, error, s->recv_initial_md_op,
+ "fail_helper scheduling recv-initial-metadata-on-complete");
+ s->recv_initial_md_op = nullptr;
+ }
+ if (s->recv_message_op) {
+ INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s,
+ error);
+ GRPC_CLOSURE_SCHED(
+ s->recv_message_op->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_REF(error));
+ complete_if_batch_end_locked(
+ s, error, s->recv_message_op,
+ "fail_helper scheduling recv-message-on-complete");
+ s->recv_message_op = nullptr;
+ }
+ if (s->send_message_op) {
+ complete_if_batch_end_locked(
+ s, error, s->send_message_op,
+ "fail_helper scheduling send-message-on-complete");
+ s->send_message_op = nullptr;
+ }
+ if (s->send_trailing_md_op) {
+ complete_if_batch_end_locked(
+ s, error, s->send_trailing_md_op,
+ "fail_helper scheduling send-trailng-md-on-complete");
+ s->send_trailing_md_op = nullptr;
+ }
+ if (s->recv_trailing_md_op) {
+ INPROC_LOG(GPR_DEBUG,
+ "fail_helper %p scheduling trailing-md-on-complete %p", s,
+ error);
+ complete_if_batch_end_locked(
+ s, error, s->recv_trailing_md_op,
+ "fail_helper scheduling recv-trailing-metadata-on-complete");
+ s->recv_trailing_md_op = nullptr;
+ }
+ close_other_side_locked(s, "fail_helper:other_side");
+ close_stream_locked(s);
+
+ GRPC_ERROR_UNREF(error);
+}
+
+static void message_transfer_locked(inproc_stream* sender,
+ inproc_stream* receiver) {
+ size_t remaining =
+ sender->send_message_op->payload->send_message.send_message->length;
+ if (receiver->recv_inited) {
+ grpc_slice_buffer_destroy_internal(&receiver->recv_message);
+ }
+ grpc_slice_buffer_init(&receiver->recv_message);
+ receiver->recv_inited = true;
+ do {
+ grpc_slice message_slice;
+ grpc_closure unused;
+ GPR_ASSERT(grpc_byte_stream_next(
+ sender->send_message_op->payload->send_message.send_message, SIZE_MAX,
+ &unused));
+ grpc_error* error = grpc_byte_stream_pull(
+ sender->send_message_op->payload->send_message.send_message,
+ &message_slice);
+ if (error != GRPC_ERROR_NONE) {
+ cancel_stream_locked(sender, GRPC_ERROR_REF(error));
+ break;
+ }
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
+ remaining -= GRPC_SLICE_LENGTH(message_slice);
+ grpc_slice_buffer_add(&receiver->recv_message, message_slice);
+ } while (remaining > 0);
+
+ grpc_slice_buffer_stream_init(&receiver->recv_stream, &receiver->recv_message,
+ 0);
+ *receiver->recv_message_op->payload->recv_message.recv_message =
+ &receiver->recv_stream.base;
+ INPROC_LOG(GPR_DEBUG, "message_transfer_locked %p scheduling message-ready",
+ receiver);
+ GRPC_CLOSURE_SCHED(
+ receiver->recv_message_op->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_NONE);
+ complete_if_batch_end_locked(
+ sender, GRPC_ERROR_NONE, sender->send_message_op,
+ "message_transfer scheduling sender on_complete");
+ complete_if_batch_end_locked(
+ receiver, GRPC_ERROR_NONE, receiver->recv_message_op,
+ "message_transfer scheduling receiver on_complete");
+
+ receiver->recv_message_op = nullptr;
+ sender->send_message_op = nullptr;
+}
+
+static void op_state_machine(void* arg, grpc_error* error) {
+ // This function gets called when we have contents in the unprocessed reads
+ // Get what we want based on our ops wanted
+ // Schedule our appropriate closures
+ // and then return to ops_needed state if still needed
+
+ // Since this is a closure directly invoked by the combiner, it should not
+ // unref the error parameter explicitly; the combiner will do that implicitly
+ grpc_error* new_err = GRPC_ERROR_NONE;
+
+ bool needs_close = false;
+
+ INPROC_LOG(GPR_DEBUG, "op_state_machine %p", arg);
+ inproc_stream* s = (inproc_stream*)arg;
+ gpr_mu* mu = &s->t->mu->mu; // keep aside in case s gets closed
+ gpr_mu_lock(mu);
+ s->op_closure_scheduled = false;
+ // cancellation takes precedence
+ inproc_stream* other = s->other_side;
+
+ if (s->cancel_self_error != GRPC_ERROR_NONE) {
+ fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_self_error));
+ goto done;
+ } else if (s->cancel_other_error != GRPC_ERROR_NONE) {
+ fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_other_error));
+ goto done;
+ } else if (error != GRPC_ERROR_NONE) {
+ fail_helper_locked(s, GRPC_ERROR_REF(error));
+ goto done;
+ }
+
+ if (s->send_message_op && other) {
+ if (other->recv_message_op) {
+ message_transfer_locked(s, other);
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
+ } else if (!s->t->is_client &&
+ (s->trailing_md_sent || other->recv_trailing_md_op)) {
+ // A server send will never be matched if the client is waiting
+ // for trailing metadata already
+ complete_if_batch_end_locked(
+ s, GRPC_ERROR_NONE, s->send_message_op,
+ "op_state_machine scheduling send-message-on-complete");
+ s->send_message_op = nullptr;
+ }
+ }
+ // Pause a send trailing metadata if there is still an outstanding
+ // send message unless we know that the send message will never get
+ // matched to a receive. This happens on the client if the server has
+ // already sent status.
+ if (s->send_trailing_md_op &&
+ (!s->send_message_op ||
+ (s->t->is_client &&
+ (s->trailing_md_recvd || s->to_read_trailing_md_filled)))) {
+ grpc_metadata_batch* dest = (other == nullptr)
+ ? &s->write_buffer_trailing_md
+ : &other->to_read_trailing_md;
+ bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled
+ : &other->to_read_trailing_md_filled;
+ if (*destfilled || s->trailing_md_sent) {
+ // The buffer is already in use; that's an error!
+ INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s);
+ new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata");
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
+ goto done;
+ } else {
+ if (!other || !other->closed) {
+ fill_in_metadata(s,
+ s->send_trailing_md_op->payload->send_trailing_metadata
+ .send_trailing_metadata,
+ 0, dest, nullptr, destfilled);
+ }
+ s->trailing_md_sent = true;
+ if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
+ INPROC_LOG(GPR_DEBUG,
+ "op_state_machine %p scheduling trailing-md-on-complete", s);
+ GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete,
+ GRPC_ERROR_NONE);
+ s->recv_trailing_md_op = nullptr;
+ needs_close = true;
+ }
+ }
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
+ complete_if_batch_end_locked(
+ s, GRPC_ERROR_NONE, s->send_trailing_md_op,
+ "op_state_machine scheduling send-trailing-metadata-on-complete");
+ s->send_trailing_md_op = nullptr;
+ }
+ if (s->recv_initial_md_op) {
+ if (s->initial_md_recvd) {
+ new_err =
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd initial md");
+ INPROC_LOG(
+ GPR_DEBUG,
+ "op_state_machine %p scheduling on_complete errors for already "
+ "recvd initial md %p",
+ s, new_err);
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
+ goto done;
+ }
+
+ if (s->to_read_initial_md_filled) {
+ s->initial_md_recvd = true;
+ new_err = fill_in_metadata(
+ s, &s->to_read_initial_md, s->to_read_initial_md_flags,
+ s->recv_initial_md_op->payload->recv_initial_metadata
+ .recv_initial_metadata,
+ s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
+ nullptr);
+ s->recv_initial_md_op->payload->recv_initial_metadata
+ .recv_initial_metadata->deadline = s->deadline;
+ if (s->recv_initial_md_op->payload->recv_initial_metadata
+ .trailing_metadata_available != nullptr) {
+ *s->recv_initial_md_op->payload->recv_initial_metadata
+ .trailing_metadata_available =
+ (other != nullptr && other->send_trailing_md_op != nullptr);
+ }
+ grpc_metadata_batch_clear(&s->to_read_initial_md);
+ s->to_read_initial_md_filled = false;
+ INPROC_LOG(GPR_DEBUG,
+ "op_state_machine %p scheduling initial-metadata-ready %p", s,
+ new_err);
+ GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata
+ .recv_initial_metadata_ready,
+ GRPC_ERROR_REF(new_err));
+ complete_if_batch_end_locked(
+ s, new_err, s->recv_initial_md_op,
+ "op_state_machine scheduling recv-initial-metadata-on-complete");
+ s->recv_initial_md_op = nullptr;
+
+ if (new_err != GRPC_ERROR_NONE) {
+ INPROC_LOG(GPR_DEBUG,
+ "op_state_machine %p scheduling on_complete errors2 %p", s,
+ new_err);
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
+ goto done;
+ }
+ }
+ }
+ if (s->recv_message_op) {
+ if (other && other->send_message_op) {
+ message_transfer_locked(other, s);
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
+ }
+ }
+ if (s->recv_trailing_md_op && s->t->is_client && other &&
+ other->send_message_op) {
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
+ }
+ if (s->to_read_trailing_md_filled) {
+ if (s->trailing_md_recvd) {
+ new_err =
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd trailing md");
+ INPROC_LOG(
+ GPR_DEBUG,
+ "op_state_machine %p scheduling on_complete errors for already "
+ "recvd trailing md %p",
+ s, new_err);
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
+ goto done;
+ }
+ if (s->recv_message_op != nullptr) {
+ // This message needs to be wrapped up because it will never be
+ // satisfied
+ INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s);
+ GRPC_CLOSURE_SCHED(
+ s->recv_message_op->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_NONE);
+ complete_if_batch_end_locked(
+ s, new_err, s->recv_message_op,
+ "op_state_machine scheduling recv-message-on-complete");
+ s->recv_message_op = nullptr;
+ }
+ if ((s->trailing_md_sent || s->t->is_client) && s->send_message_op) {
+ // Nothing further will try to receive from this stream, so finish off
+ // any outstanding send_message op
+ complete_if_batch_end_locked(
+ s, new_err, s->send_message_op,
+ "op_state_machine scheduling send-message-on-complete");
+ s->send_message_op = nullptr;
+ }
+ if (s->recv_trailing_md_op != nullptr) {
+ // We wanted trailing metadata and we got it
+ s->trailing_md_recvd = true;
+ new_err =
+ fill_in_metadata(s, &s->to_read_trailing_md, 0,
+ s->recv_trailing_md_op->payload
+ ->recv_trailing_metadata.recv_trailing_metadata,
+ nullptr, nullptr);
+ grpc_metadata_batch_clear(&s->to_read_trailing_md);
+ s->to_read_trailing_md_filled = false;
+
+ // We should schedule the recv_trailing_md_op completion if
+ // 1. this stream is the client-side
+ // 2. this stream is the server-side AND has already sent its trailing md
+ // (If the server hasn't already sent its trailing md, it doesn't have
+ // a final status, so don't mark this op complete)
+ if (s->t->is_client || s->trailing_md_sent) {
+ INPROC_LOG(GPR_DEBUG,
+ "op_state_machine %p scheduling trailing-md-on-complete %p",
+ s, new_err);
+ GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete,
+ GRPC_ERROR_REF(new_err));
+ s->recv_trailing_md_op = nullptr;
+ needs_close = true;
+ } else {
+ INPROC_LOG(GPR_DEBUG,
+ "op_state_machine %p server needs to delay handling "
+ "trailing-md-on-complete %p",
+ s, new_err);
+ }
+ } else {
+ INPROC_LOG(
+ GPR_DEBUG,
+ "op_state_machine %p has trailing md but not yet waiting for it", s);
+ }
+ }
+ if (s->trailing_md_recvd && s->recv_message_op) {
+ // No further message will come on this stream, so finish off the
+ // recv_message_op
+ INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s);
+ GRPC_CLOSURE_SCHED(
+ s->recv_message_op->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_NONE);
+ complete_if_batch_end_locked(
+ s, new_err, s->recv_message_op,
+ "op_state_machine scheduling recv-message-on-complete");
+ s->recv_message_op = nullptr;
+ }
+ if (s->trailing_md_recvd && (s->trailing_md_sent || s->t->is_client) &&
+ s->send_message_op) {
+ // Nothing further will try to receive from this stream, so finish off
+ // any outstanding send_message op
+ complete_if_batch_end_locked(
+ s, new_err, s->send_message_op,
+ "op_state_machine scheduling send-message-on-complete");
+ s->send_message_op = nullptr;
+ }
+ if (s->send_message_op || s->send_trailing_md_op || s->recv_initial_md_op ||
+ s->recv_message_op || s->recv_trailing_md_op) {
+ // Didn't get the item we wanted so we still need to get
+ // rescheduled
+ INPROC_LOG(
+ GPR_DEBUG, "op_state_machine %p still needs closure %p %p %p %p %p", s,
+ s->send_message_op, s->send_trailing_md_op, s->recv_initial_md_op,
+ s->recv_message_op, s->recv_trailing_md_op);
+ s->ops_needed = true;
+ }
+done:
+ if (needs_close) {
+ close_other_side_locked(s, "op_state_machine");
+ close_stream_locked(s);
+ }
+ gpr_mu_unlock(mu);
+ GRPC_ERROR_UNREF(new_err);
+}
+
+static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) {
+ bool ret = false; // was the cancel accepted
+ INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s,
+ grpc_error_string(error));
+ if (s->cancel_self_error == GRPC_ERROR_NONE) {
+ ret = true;
+ s->cancel_self_error = GRPC_ERROR_REF(error);
+ maybe_schedule_op_closure_locked(s, s->cancel_self_error);
+ // Send trailing md to the other side indicating cancellation, even if we
+ // already have
+ s->trailing_md_sent = true;
+
+ grpc_metadata_batch cancel_md;
+ grpc_metadata_batch_init(&cancel_md);
+
+ inproc_stream* other = s->other_side;
+ grpc_metadata_batch* dest = (other == nullptr)
+ ? &s->write_buffer_trailing_md
+ : &other->to_read_trailing_md;
+ bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled
+ : &other->to_read_trailing_md_filled;
+ fill_in_metadata(s, &cancel_md, 0, dest, nullptr, destfilled);
+ grpc_metadata_batch_destroy(&cancel_md);
+
+ if (other != nullptr) {
+ if (other->cancel_other_error == GRPC_ERROR_NONE) {
+ other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
+ }
+ maybe_schedule_op_closure_locked(other, other->cancel_other_error);
+ } else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
+ s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error);
+ }
+
+ // if we are a server and already received trailing md but
+ // couldn't complete that because we hadn't yet sent out trailing
+ // md, now's the chance
+ if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
+ complete_if_batch_end_locked(
+ s, s->cancel_self_error, s->recv_trailing_md_op,
+ "cancel_stream scheduling trailing-md-on-complete");
+ s->recv_trailing_md_op = nullptr;
+ }
+ }
+
+ close_other_side_locked(s, "cancel_stream:other_side");
+ close_stream_locked(s);
+
+ GRPC_ERROR_UNREF(error);
+ return ret;
+}
+
+static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
+ grpc_transport_stream_op_batch* op) {
+ INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
+ inproc_stream* s = (inproc_stream*)gs;
+ gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed
+ gpr_mu_lock(mu);
+
+ if (grpc_inproc_trace.enabled()) {
+ if (op->send_initial_metadata) {
+ log_metadata(op->payload->send_initial_metadata.send_initial_metadata,
+ s->t->is_client, true);
+ }
+ if (op->send_trailing_metadata) {
+ log_metadata(op->payload->send_trailing_metadata.send_trailing_metadata,
+ s->t->is_client, false);
+ }
+ }
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_closure* on_complete = op->on_complete;
+ if (on_complete == nullptr) {
+ on_complete = &do_nothing_closure;
+ }
+
+ if (op->cancel_stream) {
+ // Call cancel_stream_locked without ref'ing the cancel_error because
+ // this function is responsible to make sure that that field gets unref'ed
+ cancel_stream_locked(s, op->payload->cancel_stream.cancel_error);
+ // this op can complete without an error
+ } else if (s->cancel_self_error != GRPC_ERROR_NONE) {
+ // already self-canceled so still give it an error
+ error = GRPC_ERROR_REF(s->cancel_self_error);
+ } else {
+ INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %s%s%s%s%s%s%s", s,
+ s->t->is_client ? "client" : "server",
+ op->send_initial_metadata ? " send_initial_metadata" : "",
+ op->send_message ? " send_message" : "",
+ op->send_trailing_metadata ? " send_trailing_metadata" : "",
+ op->recv_initial_metadata ? " recv_initial_metadata" : "",
+ op->recv_message ? " recv_message" : "",
+ op->recv_trailing_metadata ? " recv_trailing_metadata" : "");
+ }
+
+ bool needs_close = false;
+
+ inproc_stream* other = s->other_side;
+ if (error == GRPC_ERROR_NONE &&
+ (op->send_initial_metadata || op->send_trailing_metadata)) {
+ if (s->t->is_closed) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
+ }
+ if (error == GRPC_ERROR_NONE && op->send_initial_metadata) {
+ grpc_metadata_batch* dest = (other == nullptr)
+ ? &s->write_buffer_initial_md
+ : &other->to_read_initial_md;
+ uint32_t* destflags = (other == nullptr)
+ ? &s->write_buffer_initial_md_flags
+ : &other->to_read_initial_md_flags;
+ bool* destfilled = (other == nullptr) ? &s->write_buffer_initial_md_filled
+ : &other->to_read_initial_md_filled;
+ if (*destfilled || s->initial_md_sent) {
+ // The buffer is already in use; that's an error!
+ INPROC_LOG(GPR_DEBUG, "Extra initial metadata %p", s);
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra initial metadata");
+ } else {
+ if (!other || !other->closed) {
+ fill_in_metadata(
+ s, op->payload->send_initial_metadata.send_initial_metadata,
+ op->payload->send_initial_metadata.send_initial_metadata_flags,
+ dest, destflags, destfilled);
+ }
+ if (s->t->is_client) {
+ grpc_millis* dl =
+ (other == nullptr) ? &s->write_buffer_deadline : &other->deadline;
+ *dl = GPR_MIN(*dl, op->payload->send_initial_metadata
+ .send_initial_metadata->deadline);
+ s->initial_md_sent = true;
+ }
+ }
+ maybe_schedule_op_closure_locked(other, error);
+ }
+ }
+
+ if (error == GRPC_ERROR_NONE &&
+ (op->send_message || op->send_trailing_metadata ||
+ op->recv_initial_metadata || op->recv_message ||
+ op->recv_trailing_metadata)) {
+ // Mark ops that need to be processed by the closure
+ if (op->send_message) {
+ s->send_message_op = op;
+ }
+ if (op->send_trailing_metadata) {
+ s->send_trailing_md_op = op;
+ }
+ if (op->recv_initial_metadata) {
+ s->recv_initial_md_op = op;
+ }
+ if (op->recv_message) {
+ s->recv_message_op = op;
+ }
+ if (op->recv_trailing_metadata) {
+ s->recv_trailing_md_op = op;
+ }
+
+ // We want to initiate the closure if:
+ // 1. We want to send a message and the other side wants to receive or end
+ // 2. We want to send trailing metadata and there isn't an unmatched send
+ // 3. We want initial metadata and the other side has sent it
+ // 4. We want to receive a message and there is a message ready
+ // 5. There is trailing metadata, even if nothing specifically wants
+ // that because that can shut down the receive message as well
+ if ((op->send_message && other &&
+ ((other->recv_message_op != nullptr) ||
+ (other->recv_trailing_md_op != nullptr))) ||
+ (op->send_trailing_metadata && !op->send_message) ||
+ (op->recv_initial_metadata && s->to_read_initial_md_filled) ||
+ (op->recv_message && other && (other->send_message_op != nullptr)) ||
+ (s->to_read_trailing_md_filled || s->trailing_md_recvd)) {
+ if (!s->op_closure_scheduled) {
+ GRPC_CLOSURE_SCHED(&s->op_closure, GRPC_ERROR_NONE);
+ s->op_closure_scheduled = true;
+ }
+ } else {
+ s->ops_needed = true;
+ }
+ } else {
+ if (error != GRPC_ERROR_NONE) {
+ // Schedule op's closures that we didn't push to op state machine
+ if (op->recv_initial_metadata) {
+ if (op->payload->recv_initial_metadata.trailing_metadata_available !=
+ nullptr) {
+ // Set to true unconditionally, because we're failing the call, so
+ // even if we haven't actually seen the send_trailing_metadata op
+ // from the other side, we're going to return trailing metadata
+ // anyway.
+ *op->payload->recv_initial_metadata.trailing_metadata_available =
+ true;
+ }
+ INPROC_LOG(
+ GPR_DEBUG,
+ "perform_stream_op error %p scheduling initial-metadata-ready %p",
+ s, error);
+ GRPC_CLOSURE_SCHED(
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready,
+ GRPC_ERROR_REF(error));
+ }
+ if (op->recv_message) {
+ INPROC_LOG(
+ GPR_DEBUG,
+ "perform_stream_op error %p scheduling recv message-ready %p", s,
+ error);
+ GRPC_CLOSURE_SCHED(op->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_REF(error));
+ }
+ }
+ INPROC_LOG(GPR_DEBUG, "perform_stream_op %p scheduling on_complete %p", s,
+ error);
+ GRPC_CLOSURE_SCHED(on_complete, GRPC_ERROR_REF(error));
+ }
+ if (needs_close) {
+ close_other_side_locked(s, "perform_stream_op:other_side");
+ close_stream_locked(s);
+ }
+ gpr_mu_unlock(mu);
+ GRPC_ERROR_UNREF(error);
+}
+
+static void close_transport_locked(inproc_transport* t) {
+ INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed);
+ grpc_connectivity_state_set(
+ &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."),
+ "close transport");
+ if (!t->is_closed) {
+ t->is_closed = true;
+ /* Also end all streams on this transport */
+ while (t->stream_list != nullptr) {
+ // cancel_stream_locked also adjusts stream list
+ cancel_stream_locked(
+ t->stream_list,
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
+ }
+ }
+}
+
+static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
+ inproc_transport* t = (inproc_transport*)gt;
+ INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
+ gpr_mu_lock(&t->mu->mu);
+ if (op->on_connectivity_state_change) {
+ grpc_connectivity_state_notify_on_state_change(
+ &t->connectivity, op->connectivity_state,
+ op->on_connectivity_state_change);
+ }
+ if (op->set_accept_stream) {
+ t->accept_stream_cb = op->set_accept_stream_fn;
+ t->accept_stream_data = op->set_accept_stream_user_data;
+ }
+ if (op->on_consumed) {
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
+ }
+
+ bool do_close = false;
+ if (op->goaway_error != GRPC_ERROR_NONE) {
+ do_close = true;
+ GRPC_ERROR_UNREF(op->goaway_error);
+ }
+ if (op->disconnect_with_error != GRPC_ERROR_NONE) {
+ do_close = true;
+ GRPC_ERROR_UNREF(op->disconnect_with_error);
+ }
+
+ if (do_close) {
+ close_transport_locked(t);
+ }
+ gpr_mu_unlock(&t->mu->mu);
+}
+
+static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_closure* then_schedule_closure) {
+ INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
+ inproc_stream* s = (inproc_stream*)gs;
+ s->closure_at_destroy = then_schedule_closure;
+ really_destroy_stream(s);
+}
+
+static void destroy_transport(grpc_transport* gt) {
+ inproc_transport* t = (inproc_transport*)gt;
+ INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
+ gpr_mu_lock(&t->mu->mu);
+ close_transport_locked(t);
+ gpr_mu_unlock(&t->mu->mu);
+ unref_transport(t->other_side);
+ unref_transport(t);
+}
+
+/*******************************************************************************
+ * INTEGRATION GLUE
+ */
+
+static void set_pollset(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset* pollset) {
+ // Nothing to do here
+}
+
+static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset_set* pollset_set) {
+ // Nothing to do here
+}
+
+static grpc_endpoint* get_endpoint(grpc_transport* t) { return nullptr; }
+
+/*******************************************************************************
+ * GLOBAL INIT AND DESTROY
+ */
+static void do_nothing(void* arg, grpc_error* error) {}
+
+void grpc_inproc_transport_init(void) {
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr,
+ grpc_schedule_on_exec_ctx);
+ g_empty_slice = grpc_slice_from_static_buffer(nullptr, 0);
+
+ grpc_slice key_tmp = grpc_slice_from_static_string(":path");
+ g_fake_path_key = grpc_slice_intern(key_tmp);
+ grpc_slice_unref_internal(key_tmp);
+
+ g_fake_path_value = grpc_slice_from_static_string("/");
+
+ grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
+ g_fake_auth_key = grpc_slice_intern(auth_tmp);
+ grpc_slice_unref_internal(auth_tmp);
+
+ g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
+}
+
+static const grpc_transport_vtable inproc_vtable = {
+ sizeof(inproc_stream), "inproc", init_stream,
+ set_pollset, set_pollset_set, perform_stream_op,
+ perform_transport_op, destroy_stream, destroy_transport,
+ get_endpoint};
+
+/*******************************************************************************
+ * Main inproc transport functions
+ */
+static void inproc_transports_create(grpc_transport** server_transport,
+ const grpc_channel_args* server_args,
+ grpc_transport** client_transport,
+ const grpc_channel_args* client_args) {
+ INPROC_LOG(GPR_DEBUG, "inproc_transports_create");
+ inproc_transport* st = (inproc_transport*)gpr_zalloc(sizeof(*st));
+ inproc_transport* ct = (inproc_transport*)gpr_zalloc(sizeof(*ct));
+ // Share one lock between both sides since both sides get affected
+ st->mu = ct->mu = (shared_mu*)gpr_malloc(sizeof(*st->mu));
+ gpr_mu_init(&st->mu->mu);
+ gpr_ref_init(&st->mu->refs, 2);
+ st->base.vtable = &inproc_vtable;
+ ct->base.vtable = &inproc_vtable;
+ // Start each side of transport with 2 refs since they each have a ref
+ // to the other
+ gpr_ref_init(&st->refs, 2);
+ gpr_ref_init(&ct->refs, 2);
+ st->is_client = false;
+ ct->is_client = true;
+ grpc_connectivity_state_init(&st->connectivity, GRPC_CHANNEL_READY,
+ "inproc_server");
+ grpc_connectivity_state_init(&ct->connectivity, GRPC_CHANNEL_READY,
+ "inproc_client");
+ st->other_side = ct;
+ ct->other_side = st;
+ st->stream_list = nullptr;
+ ct->stream_list = nullptr;
+ *server_transport = (grpc_transport*)st;
+ *client_transport = (grpc_transport*)ct;
+}
+
+grpc_channel* grpc_inproc_channel_create(grpc_server* server,
+ grpc_channel_args* args,
+ void* reserved) {
+ GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2,
+ (server, args));
+
+ grpc_core::ExecCtx exec_ctx;
+
+ const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
+
+ // Add a default authority channel argument for the client
+
+ grpc_arg default_authority_arg;
+ default_authority_arg.type = GRPC_ARG_STRING;
+ default_authority_arg.key = (char*)GRPC_ARG_DEFAULT_AUTHORITY;
+ default_authority_arg.value.string = (char*)"inproc.authority";
+ grpc_channel_args* client_args =
+ grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
+
+ grpc_transport* server_transport;
+ grpc_transport* client_transport;
+ inproc_transports_create(&server_transport, server_args, &client_transport,
+ client_args);
+
+ grpc_server_setup_transport(server, server_transport, nullptr, server_args);
+ grpc_channel* channel = grpc_channel_create(
+ "inproc", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
+
+ // Free up created channel args
+ grpc_channel_args_destroy(client_args);
+
+ // Now finish scheduled operations
+
+ return channel;
+}
+
+void grpc_inproc_transport_shutdown(void) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_unref_internal(g_empty_slice);
+ grpc_slice_unref_internal(g_fake_path_key);
+ grpc_slice_unref_internal(g_fake_path_value);
+ grpc_slice_unref_internal(g_fake_auth_key);
+ grpc_slice_unref_internal(g_fake_auth_value);
+}
diff --git a/src/core/ext/transport/inproc/inproc_transport.h b/src/core/ext/transport/inproc/inproc_transport.h
index 37e6d99e99..7c0453e7ce 100644
--- a/src/core/ext/transport/inproc/inproc_transport.h
+++ b/src/core/ext/transport/inproc/inproc_transport.h
@@ -21,21 +21,13 @@
#include "src/core/lib/transport/transport_impl.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+grpc_channel* grpc_inproc_channel_create(grpc_server* server,
+ grpc_channel_args* args,
+ void* reserved);
-grpc_channel *grpc_inproc_channel_create(grpc_server *server,
- grpc_channel_args *args,
- void *reserved);
-
-extern grpc_tracer_flag grpc_inproc_trace;
+extern grpc_core::TraceFlag grpc_inproc_trace;
void grpc_inproc_transport_init(void);
void grpc_inproc_transport_shutdown(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_INPROC_INPROC_TRANSPORT_H */
diff --git a/src/core/lib/backoff/backoff.cc b/src/core/lib/backoff/backoff.cc
new file mode 100644
index 0000000000..d561fc7460
--- /dev/null
+++ b/src/core/lib/backoff/backoff.cc
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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 "src/core/lib/backoff/backoff.h"
+
+#include <algorithm>
+
+#include <grpc/support/useful.h>
+
+namespace grpc_core {
+
+namespace {
+
+/* Generate a random number between 0 and 1. We roll our own RNG because seeding
+ * rand() modifies a global variable we have no control over. */
+double generate_uniform_random_number(uint32_t* rng_state) {
+ constexpr uint32_t two_raise_31 = uint32_t(1) << 31;
+ *rng_state = (1103515245 * *rng_state + 12345) % two_raise_31;
+ return *rng_state / static_cast<double>(two_raise_31);
+}
+
+double generate_uniform_random_number_between(uint32_t* rng_state, double a,
+ double b) {
+ if (a == b) return a;
+ if (a > b) GPR_SWAP(double, a, b); // make sure a < b
+ const double range = b - a;
+ return a + generate_uniform_random_number(rng_state) * range;
+}
+
+} // namespace
+
+BackOff::BackOff(const Options& options)
+ : options_(options),
+ rng_state_(static_cast<uint32_t>(gpr_now(GPR_CLOCK_REALTIME).tv_nsec)) {
+ Reset();
+}
+
+grpc_millis BackOff::NextAttemptTime() {
+ if (initial_) {
+ initial_ = false;
+ return current_backoff_ + grpc_core::ExecCtx::Get()->Now();
+ }
+ current_backoff_ =
+ (grpc_millis)(std::min(current_backoff_ * options_.multiplier(),
+ (double)options_.max_backoff()));
+ const double jitter = generate_uniform_random_number_between(
+ &rng_state_, -options_.jitter() * current_backoff_,
+ options_.jitter() * current_backoff_);
+ const grpc_millis next_timeout = (grpc_millis)(current_backoff_ + jitter);
+ return next_timeout + grpc_core::ExecCtx::Get()->Now();
+}
+
+void BackOff::Reset() {
+ current_backoff_ = options_.initial_backoff();
+ initial_ = true;
+}
+
+void BackOff::SetRandomSeed(uint32_t seed) { rng_state_ = seed; }
+
+} // namespace grpc_core
diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h
new file mode 100644
index 0000000000..de30e5268b
--- /dev/null
+++ b/src/core/lib/backoff/backoff.h
@@ -0,0 +1,87 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_BACKOFF_BACKOFF_H
+#define GRPC_CORE_LIB_BACKOFF_BACKOFF_H
+
+#include "src/core/lib/iomgr/exec_ctx.h"
+
+namespace grpc_core {
+
+/// Implementation of the backoff mechanism described in
+/// doc/connection-backoff.md
+class BackOff {
+ public:
+ class Options;
+
+ /// Initialize backoff machinery - does not need to be destroyed
+ explicit BackOff(const Options& options);
+
+ /// Returns the time at which the next attempt should start.
+ grpc_millis NextAttemptTime();
+
+ /// Reset the backoff, so the next value returned by NextAttemptTime()
+ /// will be the time of the second attempt (rather than the Nth).
+ void Reset();
+
+ void SetRandomSeed(unsigned int seed);
+
+ class Options {
+ public:
+ Options& set_initial_backoff(grpc_millis initial_backoff) {
+ initial_backoff_ = initial_backoff;
+ return *this;
+ }
+ Options& set_multiplier(double multiplier) {
+ multiplier_ = multiplier;
+ return *this;
+ }
+ Options& set_jitter(double jitter) {
+ jitter_ = jitter;
+ return *this;
+ }
+ Options& set_max_backoff(grpc_millis max_backoff) {
+ max_backoff_ = max_backoff;
+ return *this;
+ }
+ /// how long to wait after the first failure before retrying
+ grpc_millis initial_backoff() const { return initial_backoff_; }
+ /// factor with which to multiply backoff after a failed retry
+ double multiplier() const { return multiplier_; }
+ /// amount to randomize backoffs
+ double jitter() const { return jitter_; }
+ /// maximum time between retries
+ grpc_millis max_backoff() const { return max_backoff_; }
+
+ private:
+ grpc_millis initial_backoff_;
+ double multiplier_;
+ double jitter_;
+ grpc_millis max_backoff_;
+ }; // class Options
+
+ private:
+ const Options options_;
+ uint32_t rng_state_;
+ bool initial_;
+ /// current delay before retries
+ grpc_millis current_backoff_;
+};
+
+} // namespace grpc_core
+#endif /* GRPC_CORE_LIB_BACKOFF_BACKOFF_H */
diff --git a/src/core/lib/channel/channel_args.c b/src/core/lib/channel/channel_args.cc
index 30248b3c60..101a6fffbc 100644
--- a/src/core/lib/channel/channel_args.c
+++ b/src/core/lib/channel/channel_args.cc
@@ -29,9 +29,9 @@
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-static grpc_arg copy_arg(const grpc_arg *src) {
+static grpc_arg copy_arg(const grpc_arg* src) {
grpc_arg dst;
dst.type = src->type;
dst.key = gpr_strdup(src->key);
@@ -51,21 +51,21 @@ static grpc_arg copy_arg(const grpc_arg *src) {
return dst;
}
-grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src,
- const grpc_arg *to_add,
+grpc_channel_args* grpc_channel_args_copy_and_add(const grpc_channel_args* src,
+ const grpc_arg* to_add,
size_t num_to_add) {
- return grpc_channel_args_copy_and_add_and_remove(src, NULL, 0, to_add,
+ return grpc_channel_args_copy_and_add_and_remove(src, nullptr, 0, to_add,
num_to_add);
}
-grpc_channel_args *grpc_channel_args_copy_and_remove(
- const grpc_channel_args *src, const char **to_remove,
+grpc_channel_args* grpc_channel_args_copy_and_remove(
+ const grpc_channel_args* src, const char** to_remove,
size_t num_to_remove) {
return grpc_channel_args_copy_and_add_and_remove(src, to_remove,
- num_to_remove, NULL, 0);
+ num_to_remove, nullptr, 0);
}
-static bool should_remove_arg(const grpc_arg *arg, const char **to_remove,
+static bool should_remove_arg(const grpc_arg* arg, const char** to_remove,
size_t num_to_remove) {
for (size_t i = 0; i < num_to_remove; ++i) {
if (strcmp(arg->key, to_remove[i]) == 0) return true;
@@ -73,12 +73,12 @@ static bool should_remove_arg(const grpc_arg *arg, const char **to_remove,
return false;
}
-grpc_channel_args *grpc_channel_args_copy_and_add_and_remove(
- const grpc_channel_args *src, const char **to_remove, size_t num_to_remove,
- const grpc_arg *to_add, size_t num_to_add) {
+grpc_channel_args* grpc_channel_args_copy_and_add_and_remove(
+ const grpc_channel_args* src, const char** to_remove, size_t num_to_remove,
+ const grpc_arg* to_add, size_t num_to_add) {
// Figure out how many args we'll be copying.
size_t num_args_to_copy = 0;
- if (src != NULL) {
+ if (src != nullptr) {
for (size_t i = 0; i < src->num_args; ++i) {
if (!should_remove_arg(&src->args[i], to_remove, num_to_remove)) {
++num_args_to_copy;
@@ -86,17 +86,17 @@ grpc_channel_args *grpc_channel_args_copy_and_add_and_remove(
}
}
// Create result.
- grpc_channel_args *dst =
- (grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
+ grpc_channel_args* dst =
+ (grpc_channel_args*)gpr_malloc(sizeof(grpc_channel_args));
dst->num_args = num_args_to_copy + num_to_add;
if (dst->num_args == 0) {
- dst->args = NULL;
+ dst->args = nullptr;
return dst;
}
- dst->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * dst->num_args);
+ dst->args = (grpc_arg*)gpr_malloc(sizeof(grpc_arg) * dst->num_args);
// Copy args from src that are not being removed.
size_t dst_idx = 0;
- if (src != NULL) {
+ if (src != nullptr) {
for (size_t i = 0; i < src->num_args; ++i) {
if (!should_remove_arg(&src->args[i], to_remove, num_to_remove)) {
dst->args[dst_idx++] = copy_arg(&src->args[i]);
@@ -111,30 +111,30 @@ grpc_channel_args *grpc_channel_args_copy_and_add_and_remove(
return dst;
}
-grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src) {
- return grpc_channel_args_copy_and_add(src, NULL, 0);
+grpc_channel_args* grpc_channel_args_copy(const grpc_channel_args* src) {
+ return grpc_channel_args_copy_and_add(src, nullptr, 0);
}
-grpc_channel_args *grpc_channel_args_union(const grpc_channel_args *a,
- const grpc_channel_args *b) {
+grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a,
+ const grpc_channel_args* b) {
const size_t max_out = (a->num_args + b->num_args);
- grpc_arg *uniques = (grpc_arg *)gpr_malloc(sizeof(*uniques) * max_out);
+ grpc_arg* uniques = (grpc_arg*)gpr_malloc(sizeof(*uniques) * max_out);
for (size_t i = 0; i < a->num_args; ++i) uniques[i] = a->args[i];
size_t uniques_idx = a->num_args;
for (size_t i = 0; i < b->num_args; ++i) {
- const char *b_key = b->args[i].key;
- if (grpc_channel_args_find(a, b_key) == NULL) { // not found
+ const char* b_key = b->args[i].key;
+ if (grpc_channel_args_find(a, b_key) == nullptr) { // not found
uniques[uniques_idx++] = b->args[i];
}
}
- grpc_channel_args *result =
- grpc_channel_args_copy_and_add(NULL, uniques, uniques_idx);
+ grpc_channel_args* result =
+ grpc_channel_args_copy_and_add(nullptr, uniques, uniques_idx);
gpr_free(uniques);
return result;
}
-static int cmp_arg(const grpc_arg *a, const grpc_arg *b) {
+static int cmp_arg(const grpc_arg* a, const grpc_arg* b) {
int c = GPR_ICMP(a->type, b->type);
if (c != 0) return c;
c = strcmp(a->key, b->key);
@@ -160,26 +160,26 @@ static int cmp_arg(const grpc_arg *a, const grpc_arg *b) {
/* stabilizing comparison function: since channel_args ordering matters for
* keys with the same name, we need to preserve that ordering */
-static int cmp_key_stable(const void *ap, const void *bp) {
- const grpc_arg *const *a = (const grpc_arg *const *)ap;
- const grpc_arg *const *b = (const grpc_arg *const *)bp;
+static int cmp_key_stable(const void* ap, const void* bp) {
+ const grpc_arg* const* a = (const grpc_arg* const*)ap;
+ const grpc_arg* const* b = (const grpc_arg* const*)bp;
int c = strcmp((*a)->key, (*b)->key);
if (c == 0) c = GPR_ICMP(*a, *b);
return c;
}
-grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a) {
- grpc_arg **args = (grpc_arg **)gpr_malloc(sizeof(grpc_arg *) * a->num_args);
+grpc_channel_args* grpc_channel_args_normalize(const grpc_channel_args* a) {
+ grpc_arg** args = (grpc_arg**)gpr_malloc(sizeof(grpc_arg*) * a->num_args);
for (size_t i = 0; i < a->num_args; i++) {
args[i] = &a->args[i];
}
if (a->num_args > 1)
- qsort(args, a->num_args, sizeof(grpc_arg *), cmp_key_stable);
+ qsort(args, a->num_args, sizeof(grpc_arg*), cmp_key_stable);
- grpc_channel_args *b =
- (grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
+ grpc_channel_args* b =
+ (grpc_channel_args*)gpr_malloc(sizeof(grpc_channel_args));
b->num_args = a->num_args;
- b->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * b->num_args);
+ b->args = (grpc_arg*)gpr_malloc(sizeof(grpc_arg) * b->num_args);
for (size_t i = 0; i < a->num_args; i++) {
b->args[i] = copy_arg(args[i]);
}
@@ -188,7 +188,7 @@ grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a) {
return b;
}
-void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a) {
+void grpc_channel_args_destroy(grpc_channel_args* a) {
size_t i;
if (!a) return;
for (i = 0; i < a->num_args; i++) {
@@ -199,8 +199,7 @@ void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a) {
case GRPC_ARG_INTEGER:
break;
case GRPC_ARG_POINTER:
- a->args[i].value.pointer.vtable->destroy(exec_ctx,
- a->args[i].value.pointer.p);
+ a->args[i].value.pointer.vtable->destroy(a->args[i].value.pointer.p);
break;
}
gpr_free(a->args[i].key);
@@ -210,9 +209,9 @@ void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a) {
}
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
- const grpc_channel_args *a) {
+ const grpc_channel_args* a) {
size_t i;
- if (a == NULL) return GRPC_COMPRESS_NONE;
+ if (a == nullptr) return GRPC_COMPRESS_NONE;
for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER &&
!strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
@@ -223,37 +222,12 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
return GRPC_COMPRESS_NONE;
}
-grpc_stream_compression_algorithm
-grpc_channel_args_get_stream_compression_algorithm(const grpc_channel_args *a) {
- size_t i;
- if (a == NULL) return GRPC_STREAM_COMPRESS_NONE;
- for (i = 0; i < a->num_args; ++i) {
- if (a->args[i].type == GRPC_ARG_INTEGER &&
- !strcmp(GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,
- a->args[i].key)) {
- return (grpc_stream_compression_algorithm)a->args[i].value.integer;
- break;
- }
- }
- return GRPC_STREAM_COMPRESS_NONE;
-}
-
-grpc_channel_args *grpc_channel_args_set_compression_algorithm(
- grpc_channel_args *a, grpc_compression_algorithm algorithm) {
+grpc_channel_args* grpc_channel_args_set_compression_algorithm(
+ grpc_channel_args* a, grpc_compression_algorithm algorithm) {
GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT);
grpc_arg tmp;
tmp.type = GRPC_ARG_INTEGER;
- tmp.key = (char *)GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
- tmp.value.integer = algorithm;
- return grpc_channel_args_copy_and_add(a, &tmp, 1);
-}
-
-grpc_channel_args *grpc_channel_args_set_stream_compression_algorithm(
- grpc_channel_args *a, grpc_stream_compression_algorithm algorithm) {
- GPR_ASSERT(algorithm < GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT);
- grpc_arg tmp;
- tmp.type = GRPC_ARG_INTEGER;
- tmp.key = (char *)GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
+ tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
tmp.value.integer = algorithm;
return grpc_channel_args_copy_and_add(a, &tmp, 1);
}
@@ -261,9 +235,9 @@ grpc_channel_args *grpc_channel_args_set_stream_compression_algorithm(
/** Returns 1 if the argument for compression algorithm's enabled states bitset
* was found in \a a, returning the arg's value in \a states. Otherwise, returns
* 0. */
-static int find_compression_algorithm_states_bitset(const grpc_channel_args *a,
- int **states_arg) {
- if (a != NULL) {
+static int find_compression_algorithm_states_bitset(const grpc_channel_args* a,
+ int** states_arg) {
+ if (a != nullptr) {
size_t i;
for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER &&
@@ -278,37 +252,16 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args *a,
return 0; /* GPR_FALSE */
}
-/** Returns 1 if the argument for compression algorithm's enabled states bitset
- * was found in \a a, returning the arg's value in \a states. Otherwise, returns
- * 0. */
-static int find_stream_compression_algorithm_states_bitset(
- const grpc_channel_args *a, int **states_arg) {
- if (a != NULL) {
- size_t i;
- for (i = 0; i < a->num_args; ++i) {
- if (a->args[i].type == GRPC_ARG_INTEGER &&
- !strcmp(GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
- a->args[i].key)) {
- *states_arg = &a->args[i].value.integer;
- **states_arg |= 0x1; /* forcefully enable support for no compression */
- return 1;
- }
- }
- }
- return 0; /* GPR_FALSE */
-}
-
-grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
- grpc_compression_algorithm algorithm, int state) {
- int *states_arg = NULL;
- grpc_channel_args *result = *a;
+grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
+ grpc_channel_args** a, grpc_compression_algorithm algorithm, int state) {
+ int* states_arg = nullptr;
+ grpc_channel_args* result = *a;
const int states_arg_found =
find_compression_algorithm_states_bitset(*a, &states_arg);
if (grpc_channel_args_get_compression_algorithm(*a) == algorithm &&
state == 0) {
- const char *algo_name = NULL;
+ const char* algo_name = nullptr;
GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0);
gpr_log(GPR_ERROR,
"Tried to disable default compression algorithm '%s'. The "
@@ -316,74 +269,32 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
algo_name);
} else if (states_arg_found) {
if (state != 0) {
- GPR_BITSET((unsigned *)states_arg, algorithm);
+ GPR_BITSET((unsigned*)states_arg, algorithm);
} else if (algorithm != GRPC_COMPRESS_NONE) {
- GPR_BITCLEAR((unsigned *)states_arg, algorithm);
+ GPR_BITCLEAR((unsigned*)states_arg, algorithm);
}
} else {
/* create a new arg */
grpc_arg tmp;
tmp.type = GRPC_ARG_INTEGER;
- tmp.key = (char *)GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
+ tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
/* all enabled by default */
tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
if (state != 0) {
- GPR_BITSET((unsigned *)&tmp.value.integer, algorithm);
+ GPR_BITSET((unsigned*)&tmp.value.integer, algorithm);
} else if (algorithm != GRPC_COMPRESS_NONE) {
- GPR_BITCLEAR((unsigned *)&tmp.value.integer, algorithm);
- }
- result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
- grpc_channel_args_destroy(exec_ctx, *a);
- *a = result;
- }
- return result;
-}
-
-grpc_channel_args *grpc_channel_args_stream_compression_algorithm_set_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
- grpc_stream_compression_algorithm algorithm, int state) {
- int *states_arg = NULL;
- grpc_channel_args *result = *a;
- const int states_arg_found =
- find_stream_compression_algorithm_states_bitset(*a, &states_arg);
-
- if (grpc_channel_args_get_stream_compression_algorithm(*a) == algorithm &&
- state == 0) {
- const char *algo_name = NULL;
- GPR_ASSERT(grpc_stream_compression_algorithm_name(algorithm, &algo_name) !=
- 0);
- gpr_log(GPR_ERROR,
- "Tried to disable default stream compression algorithm '%s'. The "
- "operation has been ignored.",
- algo_name);
- } else if (states_arg_found) {
- if (state != 0) {
- GPR_BITSET((unsigned *)states_arg, algorithm);
- } else if (algorithm != GRPC_STREAM_COMPRESS_NONE) {
- GPR_BITCLEAR((unsigned *)states_arg, algorithm);
- }
- } else {
- /* create a new arg */
- grpc_arg tmp;
- tmp.type = GRPC_ARG_INTEGER;
- tmp.key = (char *)GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
- /* all enabled by default */
- tmp.value.integer = (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1;
- if (state != 0) {
- GPR_BITSET((unsigned *)&tmp.value.integer, algorithm);
- } else if (algorithm != GRPC_STREAM_COMPRESS_NONE) {
- GPR_BITCLEAR((unsigned *)&tmp.value.integer, algorithm);
+ GPR_BITCLEAR((unsigned*)&tmp.value.integer, algorithm);
}
result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
- grpc_channel_args_destroy(exec_ctx, *a);
+ grpc_channel_args_destroy(*a);
*a = result;
}
return result;
}
uint32_t grpc_channel_args_compression_algorithm_get_states(
- const grpc_channel_args *a) {
- int *states_arg;
+ const grpc_channel_args* a) {
+ int* states_arg;
if (find_compression_algorithm_states_bitset(a, &states_arg)) {
return (uint32_t)*states_arg;
} else {
@@ -391,25 +302,14 @@ uint32_t grpc_channel_args_compression_algorithm_get_states(
}
}
-uint32_t grpc_channel_args_stream_compression_algorithm_get_states(
- const grpc_channel_args *a) {
- int *states_arg;
- if (find_stream_compression_algorithm_states_bitset(a, &states_arg)) {
- return (uint32_t)*states_arg;
- } else {
- return (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) -
- 1; /* All algs. enabled */
- }
-}
-
-grpc_channel_args *grpc_channel_args_set_socket_mutator(
- grpc_channel_args *a, grpc_socket_mutator *mutator) {
+grpc_channel_args* grpc_channel_args_set_socket_mutator(
+ grpc_channel_args* a, grpc_socket_mutator* mutator) {
grpc_arg tmp = grpc_socket_mutator_to_arg(mutator);
return grpc_channel_args_copy_and_add(a, &tmp, 1);
}
-int grpc_channel_args_compare(const grpc_channel_args *a,
- const grpc_channel_args *b) {
+int grpc_channel_args_compare(const grpc_channel_args* a,
+ const grpc_channel_args* b) {
int c = GPR_ICMP(a->num_args, b->num_args);
if (c != 0) return c;
for (size_t i = 0; i < a->num_args; i++) {
@@ -419,21 +319,21 @@ int grpc_channel_args_compare(const grpc_channel_args *a,
return 0;
}
-const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args,
- const char *name) {
- if (args != NULL) {
+const grpc_arg* grpc_channel_args_find(const grpc_channel_args* args,
+ const char* name) {
+ if (args != nullptr) {
for (size_t i = 0; i < args->num_args; ++i) {
if (strcmp(args->args[i].key, name) == 0) {
return &args->args[i];
}
}
}
- return NULL;
+ return nullptr;
}
-int grpc_channel_arg_get_integer(const grpc_arg *arg,
+int grpc_channel_arg_get_integer(const grpc_arg* arg,
const grpc_integer_options options) {
- if (arg == NULL) return options.default_value;
+ if (arg == nullptr) return options.default_value;
if (arg->type != GRPC_ARG_INTEGER) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key);
return options.default_value;
@@ -451,8 +351,8 @@ int grpc_channel_arg_get_integer(const grpc_arg *arg,
return arg->value.integer;
}
-bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value) {
- if (arg == NULL) return default_value;
+bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) {
+ if (arg == nullptr) return default_value;
if (arg->type != GRPC_ARG_INTEGER) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key);
return default_value;
@@ -469,12 +369,12 @@ bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value) {
}
}
-bool grpc_channel_args_want_minimal_stack(const grpc_channel_args *args) {
+bool grpc_channel_args_want_minimal_stack(const grpc_channel_args* args) {
return grpc_channel_arg_get_bool(
grpc_channel_args_find(args, GRPC_ARG_MINIMAL_STACK), false);
}
-grpc_arg grpc_channel_arg_string_create(char *name, char *value) {
+grpc_arg grpc_channel_arg_string_create(char* name, char* value) {
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
arg.key = name;
@@ -482,7 +382,7 @@ grpc_arg grpc_channel_arg_string_create(char *name, char *value) {
return arg;
}
-grpc_arg grpc_channel_arg_integer_create(char *name, int value) {
+grpc_arg grpc_channel_arg_integer_create(char* name, int value) {
grpc_arg arg;
arg.type = GRPC_ARG_INTEGER;
arg.key = name;
@@ -491,7 +391,7 @@ grpc_arg grpc_channel_arg_integer_create(char *name, int value) {
}
grpc_arg grpc_channel_arg_pointer_create(
- char *name, void *value, const grpc_arg_pointer_vtable *vtable) {
+ char* name, void* value, const grpc_arg_pointer_vtable* vtable) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
arg.key = name;
diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h
index 0599e189c3..73e9122e75 100644
--- a/src/core/lib/channel/channel_args.h
+++ b/src/core/lib/channel/channel_args.h
@@ -26,56 +26,44 @@
// Channel args are intentionally immutable, to avoid the need for locking.
/** Copy the arguments in \a src into a new instance */
-grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src);
+grpc_channel_args* grpc_channel_args_copy(const grpc_channel_args* src);
/** Copy the arguments in \a src into a new instance, stably sorting keys */
-grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *src);
+grpc_channel_args* grpc_channel_args_normalize(const grpc_channel_args* src);
/** Copy the arguments in \a src and append \a to_add. If \a to_add is NULL, it
* is equivalent to calling \a grpc_channel_args_copy. */
-grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src,
- const grpc_arg *to_add,
+grpc_channel_args* grpc_channel_args_copy_and_add(const grpc_channel_args* src,
+ const grpc_arg* to_add,
size_t num_to_add);
/** Copies the arguments in \a src except for those whose keys are in
\a to_remove. */
-grpc_channel_args *grpc_channel_args_copy_and_remove(
- const grpc_channel_args *src, const char **to_remove, size_t num_to_remove);
+grpc_channel_args* grpc_channel_args_copy_and_remove(
+ const grpc_channel_args* src, const char** to_remove, size_t num_to_remove);
/** Copies the arguments from \a src except for those whose keys are in
\a to_remove and appends the arguments in \a to_add. */
-grpc_channel_args *grpc_channel_args_copy_and_add_and_remove(
- const grpc_channel_args *src, const char **to_remove, size_t num_to_remove,
- const grpc_arg *to_add, size_t num_to_add);
+grpc_channel_args* grpc_channel_args_copy_and_add_and_remove(
+ const grpc_channel_args* src, const char** to_remove, size_t num_to_remove,
+ const grpc_arg* to_add, size_t num_to_add);
/** Perform the union of \a a and \a b, prioritizing \a a entries */
-grpc_channel_args *grpc_channel_args_union(const grpc_channel_args *a,
- const grpc_channel_args *b);
+grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a,
+ const grpc_channel_args* b);
/** Destroy arguments created by \a grpc_channel_args_copy */
-void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a);
+void grpc_channel_args_destroy(grpc_channel_args* a);
/** Returns the compression algorithm set in \a a. */
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
- const grpc_channel_args *a);
-
-/** Returns the stream compression algorithm set in \a a. */
-grpc_stream_compression_algorithm
-grpc_channel_args_get_stream_compression_algorithm(const grpc_channel_args *a);
+ const grpc_channel_args* a);
/** Returns a channel arg instance with compression enabled. If \a a is
* non-NULL, its args are copied. N.B. GRPC_COMPRESS_NONE disables compression
* for the channel. */
-grpc_channel_args *grpc_channel_args_set_compression_algorithm(
- grpc_channel_args *a, grpc_compression_algorithm algorithm);
-
-/** Returns a channel arg instance with stream compression enabled. If \a a is
- * non-NULL, its args are copied. N.B. GRPC_STREAM_COMPRESS_NONE disables
- * stream compression for the channel. If a value other than
- * GRPC_STREAM_COMPRESS_NONE is set, it takes precedence over message-wise
- * compression algorithms. */
-grpc_channel_args *grpc_channel_args_set_stream_compression_algorithm(
- grpc_channel_args *a, grpc_stream_compression_algorithm algorithm);
+grpc_channel_args* grpc_channel_args_set_compression_algorithm(
+ grpc_channel_args* a, grpc_compression_algorithm algorithm);
/** Sets the support for the given compression algorithm. By default, all
* compression algorithms are enabled. It's an error to disable an algorithm set
@@ -84,20 +72,8 @@ grpc_channel_args *grpc_channel_args_set_stream_compression_algorithm(
* Returns an instance with the updated algorithm states. The \a a pointer is
* modified to point to the returned instance (which may be different from the
* input value of \a a). */
-grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
- grpc_compression_algorithm algorithm, int enabled);
-
-/** Sets the support for the given stream compression algorithm. By default, all
- * stream compression algorithms are enabled. It's an error to disable an
- * algorithm set by grpc_channel_args_set_stream_compression_algorithm.
- *
- * Returns an instance with the updated algorithm states. The \a a pointer is
- * modified to point to the returned instance (which may be different from the
- * input value of \a a). */
-grpc_channel_args *grpc_channel_args_stream_compression_algorithm_set_state(
- grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
- grpc_stream_compression_algorithm algorithm, int enabled);
+grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
+ grpc_channel_args** a, grpc_compression_algorithm algorithm, int enabled);
/** Returns the bitset representing the support state (true for enabled, false
* for disabled) for compression algorithms.
@@ -105,31 +81,23 @@ grpc_channel_args *grpc_channel_args_stream_compression_algorithm_set_state(
* The i-th bit of the returned bitset corresponds to the i-th entry in the
* grpc_compression_algorithm enum. */
uint32_t grpc_channel_args_compression_algorithm_get_states(
- const grpc_channel_args *a);
-
-/** Returns the bitset representing the support state (true for enabled, false
- * for disabled) for stream compression algorithms.
- *
- * The i-th bit of the returned bitset corresponds to the i-th entry in the
- * grpc_stream_compression_algorithm enum. */
-uint32_t grpc_channel_args_stream_compression_algorithm_get_states(
- const grpc_channel_args *a);
+ const grpc_channel_args* a);
-int grpc_channel_args_compare(const grpc_channel_args *a,
- const grpc_channel_args *b);
+int grpc_channel_args_compare(const grpc_channel_args* a,
+ const grpc_channel_args* b);
/** Returns a channel arg instance with socket mutator added. The socket mutator
* will perform its mutate_fd method on all file descriptors used by the
* channel.
* If \a a is non-MULL, its args are copied. */
-grpc_channel_args *grpc_channel_args_set_socket_mutator(
- grpc_channel_args *a, grpc_socket_mutator *mutator);
+grpc_channel_args* grpc_channel_args_set_socket_mutator(
+ grpc_channel_args* a, grpc_socket_mutator* mutator);
/** Returns the value of argument \a name from \a args, or NULL if not found. */
-const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args,
- const char *name);
+const grpc_arg* grpc_channel_args_find(const grpc_channel_args* args,
+ const char* name);
-bool grpc_channel_args_want_minimal_stack(const grpc_channel_args *args);
+bool grpc_channel_args_want_minimal_stack(const grpc_channel_args* args);
typedef struct grpc_integer_options {
int default_value; // Return this if value is outside of expected bounds.
@@ -138,15 +106,15 @@ typedef struct grpc_integer_options {
} grpc_integer_options;
/** Returns the value of \a arg, subject to the contraints in \a options. */
-int grpc_channel_arg_get_integer(const grpc_arg *arg,
+int grpc_channel_arg_get_integer(const grpc_arg* arg,
const grpc_integer_options options);
-bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value);
+bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value);
// Helpers for creating channel args.
-grpc_arg grpc_channel_arg_string_create(char *name, char *value);
-grpc_arg grpc_channel_arg_integer_create(char *name, int value);
-grpc_arg grpc_channel_arg_pointer_create(char *name, void *value,
- const grpc_arg_pointer_vtable *vtable);
+grpc_arg grpc_channel_arg_string_create(char* name, char* value);
+grpc_arg grpc_channel_arg_integer_create(char* name, int value);
+grpc_arg grpc_channel_arg_pointer_create(char* name, void* value,
+ const grpc_arg_pointer_vtable* vtable);
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */
diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.cc
index 775c8bc667..195fe0b195 100644
--- a/src/core/lib/channel/channel_stack.c
+++ b/src/core/lib/channel/channel_stack.cc
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
-grpc_tracer_flag grpc_trace_channel = GRPC_TRACER_INITIALIZER(false, "channel");
+grpc_core::TraceFlag grpc_trace_channel(false, "channel");
/* Memory layouts.
@@ -45,7 +45,7 @@ grpc_tracer_flag grpc_trace_channel = GRPC_TRACER_INITIALIZER(false, "channel");
#define ROUND_UP_TO_ALIGNMENT_SIZE(x) \
(((x) + GPR_MAX_ALIGNMENT - 1u) & ~(GPR_MAX_ALIGNMENT - 1u))
-size_t grpc_channel_stack_size(const grpc_channel_filter **filters,
+size_t grpc_channel_stack_size(const grpc_channel_filter** filters,
size_t filter_count) {
/* always need the header, and size for the channel elements */
size_t size =
@@ -64,52 +64,51 @@ size_t grpc_channel_stack_size(const grpc_channel_filter **filters,
return size;
}
-#define CHANNEL_ELEMS_FROM_STACK(stk) \
- ((grpc_channel_element *)((char *)(stk) + ROUND_UP_TO_ALIGNMENT_SIZE( \
- sizeof(grpc_channel_stack))))
+#define CHANNEL_ELEMS_FROM_STACK(stk) \
+ ((grpc_channel_element*)((char*)(stk) + ROUND_UP_TO_ALIGNMENT_SIZE( \
+ sizeof(grpc_channel_stack))))
-#define CALL_ELEMS_FROM_STACK(stk) \
- ((grpc_call_element *)((char *)(stk) + \
- ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack))))
+#define CALL_ELEMS_FROM_STACK(stk) \
+ ((grpc_call_element*)((char*)(stk) + \
+ ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack))))
-grpc_channel_element *grpc_channel_stack_element(
- grpc_channel_stack *channel_stack, size_t index) {
+grpc_channel_element* grpc_channel_stack_element(
+ grpc_channel_stack* channel_stack, size_t index) {
return CHANNEL_ELEMS_FROM_STACK(channel_stack) + index;
}
-grpc_channel_element *grpc_channel_stack_last_element(
- grpc_channel_stack *channel_stack) {
+grpc_channel_element* grpc_channel_stack_last_element(
+ grpc_channel_stack* channel_stack) {
return grpc_channel_stack_element(channel_stack, channel_stack->count - 1);
}
-grpc_call_element *grpc_call_stack_element(grpc_call_stack *call_stack,
+grpc_call_element* grpc_call_stack_element(grpc_call_stack* call_stack,
size_t index) {
return CALL_ELEMS_FROM_STACK(call_stack) + index;
}
-grpc_error *grpc_channel_stack_init(
- grpc_exec_ctx *exec_ctx, int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg, const grpc_channel_filter **filters, size_t filter_count,
- const grpc_channel_args *channel_args, grpc_transport *optional_transport,
- const char *name, grpc_channel_stack *stack) {
+grpc_error* grpc_channel_stack_init(
+ int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg,
+ const grpc_channel_filter** filters, size_t filter_count,
+ const grpc_channel_args* channel_args, grpc_transport* optional_transport,
+ const char* name, grpc_channel_stack* stack) {
size_t call_size =
ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) +
ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * sizeof(grpc_call_element));
- grpc_channel_element *elems;
+ grpc_channel_element* elems;
grpc_channel_element_args args;
- char *user_data;
+ char* user_data;
size_t i;
stack->count = filter_count;
GRPC_STREAM_REF_INIT(&stack->refcount, initial_refs, destroy, destroy_arg,
name);
elems = CHANNEL_ELEMS_FROM_STACK(stack);
- user_data =
- ((char *)elems) +
- ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * sizeof(grpc_channel_element));
+ user_data = ((char*)elems) + ROUND_UP_TO_ALIGNMENT_SIZE(
+ filter_count * sizeof(grpc_channel_element));
/* init per-filter data */
- grpc_error *first_error = GRPC_ERROR_NONE;
+ grpc_error* first_error = GRPC_ERROR_NONE;
for (i = 0; i < filter_count; i++) {
args.channel_stack = stack;
args.channel_args = channel_args;
@@ -118,8 +117,7 @@ grpc_error *grpc_channel_stack_init(
args.is_last = i == (filter_count - 1);
elems[i].filter = filters[i];
elems[i].channel_data = user_data;
- grpc_error *error =
- elems[i].filter->init_channel_elem(exec_ctx, &elems[i], &args);
+ grpc_error* error = elems[i].filter->init_channel_elem(&elems[i], &args);
if (error != GRPC_ERROR_NONE) {
if (first_error == GRPC_ERROR_NONE) {
first_error = error;
@@ -131,52 +129,50 @@ grpc_error *grpc_channel_stack_init(
call_size += ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_call_data);
}
- GPR_ASSERT(user_data > (char *)stack);
- GPR_ASSERT((uintptr_t)(user_data - (char *)stack) ==
+ GPR_ASSERT(user_data > (char*)stack);
+ GPR_ASSERT((uintptr_t)(user_data - (char*)stack) ==
grpc_channel_stack_size(filters, filter_count));
stack->call_stack_size = call_size;
return first_error;
}
-void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack *stack) {
- grpc_channel_element *channel_elems = CHANNEL_ELEMS_FROM_STACK(stack);
+void grpc_channel_stack_destroy(grpc_channel_stack* stack) {
+ grpc_channel_element* channel_elems = CHANNEL_ELEMS_FROM_STACK(stack);
size_t count = stack->count;
size_t i;
/* destroy per-filter data */
for (i = 0; i < count; i++) {
- channel_elems[i].filter->destroy_channel_elem(exec_ctx, &channel_elems[i]);
+ channel_elems[i].filter->destroy_channel_elem(&channel_elems[i]);
}
}
-grpc_error *grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack *channel_stack,
+grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack,
int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg,
- const grpc_call_element_args *elem_args) {
- grpc_channel_element *channel_elems = CHANNEL_ELEMS_FROM_STACK(channel_stack);
+ void* destroy_arg,
+ const grpc_call_element_args* elem_args) {
+ grpc_channel_element* channel_elems = CHANNEL_ELEMS_FROM_STACK(channel_stack);
size_t count = channel_stack->count;
- grpc_call_element *call_elems;
- char *user_data;
+ grpc_call_element* call_elems;
+ char* user_data;
size_t i;
elem_args->call_stack->count = count;
GRPC_STREAM_REF_INIT(&elem_args->call_stack->refcount, initial_refs, destroy,
destroy_arg, "CALL_STACK");
call_elems = CALL_ELEMS_FROM_STACK(elem_args->call_stack);
- user_data = ((char *)call_elems) +
+ user_data = ((char*)call_elems) +
ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element));
/* init per-filter data */
- grpc_error *first_error = GRPC_ERROR_NONE;
+ grpc_error* first_error = GRPC_ERROR_NONE;
for (i = 0; i < count; i++) {
call_elems[i].filter = channel_elems[i].filter;
call_elems[i].channel_data = channel_elems[i].channel_data;
call_elems[i].call_data = user_data;
- grpc_error *error = call_elems[i].filter->init_call_elem(
- exec_ctx, &call_elems[i], elem_args);
+ grpc_error* error =
+ call_elems[i].filter->init_call_elem(&call_elems[i], elem_args);
if (error != GRPC_ERROR_NONE) {
if (first_error == GRPC_ERROR_NONE) {
first_error = error;
@@ -190,73 +186,68 @@ grpc_error *grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
return first_error;
}
-void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_call_stack *call_stack,
- grpc_polling_entity *pollent) {
+void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack,
+ grpc_polling_entity* pollent) {
size_t count = call_stack->count;
- grpc_call_element *call_elems;
- char *user_data;
+ grpc_call_element* call_elems;
+ char* user_data;
size_t i;
call_elems = CALL_ELEMS_FROM_STACK(call_stack);
- user_data = ((char *)call_elems) +
+ user_data = ((char*)call_elems) +
ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element));
/* init per-filter data */
for (i = 0; i < count; i++) {
- call_elems[i].filter->set_pollset_or_pollset_set(exec_ctx, &call_elems[i],
- pollent);
+ call_elems[i].filter->set_pollset_or_pollset_set(&call_elems[i], pollent);
user_data +=
ROUND_UP_TO_ALIGNMENT_SIZE(call_elems[i].filter->sizeof_call_data);
}
}
void grpc_call_stack_ignore_set_pollset_or_pollset_set(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_polling_entity *pollent) {}
+ grpc_call_element* elem, grpc_polling_entity* pollent) {}
-void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
- const grpc_call_final_info *final_info,
- grpc_closure *then_schedule_closure) {
- grpc_call_element *elems = CALL_ELEMS_FROM_STACK(stack);
+void grpc_call_stack_destroy(grpc_call_stack* stack,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_schedule_closure) {
+ grpc_call_element* elems = CALL_ELEMS_FROM_STACK(stack);
size_t count = stack->count;
size_t i;
/* destroy per-filter data */
for (i = 0; i < count; i++) {
elems[i].filter->destroy_call_elem(
- exec_ctx, &elems[i], final_info,
- i == count - 1 ? then_schedule_closure : NULL);
+ &elems[i], final_info,
+ i == count - 1 ? then_schedule_closure : nullptr);
}
}
-void grpc_call_next_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- grpc_call_element *next_elem = elem + 1;
+void grpc_call_next_op(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
+ grpc_call_element* next_elem = elem + 1;
GRPC_CALL_LOG_OP(GPR_INFO, next_elem, op);
- next_elem->filter->start_transport_stream_op_batch(exec_ctx, next_elem, op);
+ next_elem->filter->start_transport_stream_op_batch(next_elem, op);
}
-void grpc_channel_next_get_info(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {
- grpc_channel_element *next_elem = elem + 1;
- next_elem->filter->get_channel_info(exec_ctx, next_elem, channel_info);
+void grpc_channel_next_get_info(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {
+ grpc_channel_element* next_elem = elem + 1;
+ next_elem->filter->get_channel_info(next_elem, channel_info);
}
-void grpc_channel_next_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_transport_op *op) {
- grpc_channel_element *next_elem = elem + 1;
- next_elem->filter->start_transport_op(exec_ctx, next_elem, op);
+void grpc_channel_next_op(grpc_channel_element* elem, grpc_transport_op* op) {
+ grpc_channel_element* next_elem = elem + 1;
+ next_elem->filter->start_transport_op(next_elem, op);
}
-grpc_channel_stack *grpc_channel_stack_from_top_element(
- grpc_channel_element *elem) {
- return (grpc_channel_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
+grpc_channel_stack* grpc_channel_stack_from_top_element(
+ grpc_channel_element* elem) {
+ return (grpc_channel_stack*)((char*)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
sizeof(grpc_channel_stack)));
}
-grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) {
- return (grpc_call_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
+grpc_call_stack* grpc_call_stack_from_top_element(grpc_call_element* elem) {
+ return (grpc_call_stack*)((char*)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
sizeof(grpc_call_stack)));
}
diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h
index f0de80f0c0..b9f9748001 100644
--- a/src/core/lib/channel/channel_stack.h
+++ b/src/core/lib/channel/channel_stack.h
@@ -40,15 +40,11 @@
#include <grpc/support/time.h>
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/arena.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/polling_entity.h"
-#include "src/core/lib/support/arena.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_channel_element grpc_channel_element;
typedef struct grpc_call_element grpc_call_element;
@@ -56,23 +52,23 @@ typedef struct grpc_channel_stack grpc_channel_stack;
typedef struct grpc_call_stack grpc_call_stack;
typedef struct {
- grpc_channel_stack *channel_stack;
- const grpc_channel_args *channel_args;
+ grpc_channel_stack* channel_stack;
+ const grpc_channel_args* channel_args;
/** Transport, iff it is known */
- grpc_transport *optional_transport;
+ grpc_transport* optional_transport;
int is_first;
int is_last;
} grpc_channel_element_args;
typedef struct {
- grpc_call_stack *call_stack;
- const void *server_transport_data;
- grpc_call_context_element *context;
+ grpc_call_stack* call_stack;
+ const void* server_transport_data;
+ grpc_call_context_element* context;
grpc_slice path;
gpr_timespec start_time;
- gpr_timespec deadline;
- gpr_arena *arena;
- grpc_call_combiner *call_combiner;
+ grpc_millis deadline;
+ gpr_arena* arena;
+ grpc_call_combiner* call_combiner;
} grpc_call_element_args;
typedef struct {
@@ -84,6 +80,7 @@ typedef struct {
typedef struct {
grpc_call_stats stats;
grpc_status_code final_status;
+ const char** error_string;
} grpc_call_final_info;
/* Channel filters specify:
@@ -99,14 +96,12 @@ typedef struct {
typedef struct {
/* Called to eg. send/receive data on a call.
See grpc_call_next_op on how to call the next element in the stack */
- void (*start_transport_stream_op_batch)(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op);
+ void (*start_transport_stream_op_batch)(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op);
/* Called to handle channel level operations - e.g. new calls, or transport
closure.
See grpc_channel_next_op on how to call the next element in the stack */
- void (*start_transport_op)(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem, grpc_transport_op *op);
+ void (*start_transport_op)(grpc_channel_element* elem, grpc_transport_op* op);
/* sizeof(per call data) */
size_t sizeof_call_data;
@@ -119,21 +114,19 @@ typedef struct {
transport and is on the server. Most filters want to ignore this
argument.
Implementations may assume that elem->call_data is all zeros. */
- grpc_error *(*init_call_elem)(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args);
- void (*set_pollset_or_pollset_set)(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent);
+ grpc_error* (*init_call_elem)(grpc_call_element* elem,
+ const grpc_call_element_args* args);
+ void (*set_pollset_or_pollset_set)(grpc_call_element* elem,
+ grpc_polling_entity* pollent);
/* Destroy per call data.
The filter does not need to do any chaining.
The bottom filter of a stack will be passed a non-NULL pointer to
\a then_schedule_closure that should be passed to GRPC_CLOSURE_SCHED when
destruction is complete. \a final_info contains data about the completed
call, mainly for reporting purposes. */
- void (*destroy_call_elem)(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_schedule_closure);
+ void (*destroy_call_elem)(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_schedule_closure);
/* sizeof(per channel data) */
size_t sizeof_channel_data;
@@ -144,36 +137,34 @@ typedef struct {
useful for asserting correct configuration by upper layer code.
The filter does not need to do any chaining.
Implementations may assume that elem->call_data is all zeros. */
- grpc_error *(*init_channel_elem)(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args);
+ grpc_error* (*init_channel_elem)(grpc_channel_element* elem,
+ grpc_channel_element_args* args);
/* Destroy per channel data.
The filter does not need to do any chaining */
- void (*destroy_channel_elem)(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem);
+ void (*destroy_channel_elem)(grpc_channel_element* elem);
/* Implement grpc_channel_get_info() */
- void (*get_channel_info)(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- const grpc_channel_info *channel_info);
+ void (*get_channel_info)(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info);
/* The name of this filter */
- const char *name;
+ const char* name;
} grpc_channel_filter;
/* A channel_element tracks its filter and the filter requested memory within
a channel allocation */
struct grpc_channel_element {
- const grpc_channel_filter *filter;
- void *channel_data;
+ const grpc_channel_filter* filter;
+ void* channel_data;
};
/* A call_element tracks its filter, the filter requested memory within
a channel allocation, and the filter requested memory within a call
allocation */
struct grpc_call_element {
- const grpc_channel_filter *filter;
- void *channel_data;
- void *call_data;
+ const grpc_channel_filter* filter;
+ void* channel_data;
+ void* call_data;
};
/* A channel stack tracks a set of related filters for one channel, and
@@ -198,100 +189,90 @@ struct grpc_call_stack {
};
/* Get a channel element given a channel stack and its index */
-grpc_channel_element *grpc_channel_stack_element(grpc_channel_stack *stack,
+grpc_channel_element* grpc_channel_stack_element(grpc_channel_stack* stack,
size_t i);
/* Get the last channel element in a channel stack */
-grpc_channel_element *grpc_channel_stack_last_element(
- grpc_channel_stack *stack);
+grpc_channel_element* grpc_channel_stack_last_element(
+ grpc_channel_stack* stack);
/* Get a call stack element given a call stack and an index */
-grpc_call_element *grpc_call_stack_element(grpc_call_stack *stack, size_t i);
+grpc_call_element* grpc_call_stack_element(grpc_call_stack* stack, size_t i);
/* Determine memory required for a channel stack containing a set of filters */
-size_t grpc_channel_stack_size(const grpc_channel_filter **filters,
+size_t grpc_channel_stack_size(const grpc_channel_filter** filters,
size_t filter_count);
/* Initialize a channel stack given some filters */
-grpc_error *grpc_channel_stack_init(
- grpc_exec_ctx *exec_ctx, int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg, const grpc_channel_filter **filters, size_t filter_count,
- const grpc_channel_args *args, grpc_transport *optional_transport,
- const char *name, grpc_channel_stack *stack);
+grpc_error* grpc_channel_stack_init(
+ int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg,
+ const grpc_channel_filter** filters, size_t filter_count,
+ const grpc_channel_args* args, grpc_transport* optional_transport,
+ const char* name, grpc_channel_stack* stack);
/* Destroy a channel stack */
-void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack *stack);
+void grpc_channel_stack_destroy(grpc_channel_stack* stack);
/* Initialize a call stack given a channel stack. transport_server_data is
expected to be NULL on a client, or an opaque transport owned pointer on the
server. */
-grpc_error *grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack *channel_stack,
+grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack,
int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg,
- const grpc_call_element_args *elem_args);
+ void* destroy_arg,
+ const grpc_call_element_args* elem_args);
/* Set a pollset or a pollset_set for a call stack: must occur before the first
* op is started */
-void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_call_stack *call_stack,
- grpc_polling_entity *pollent);
+void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack,
+ grpc_polling_entity* pollent);
#ifndef NDEBUG
#define GRPC_CALL_STACK_REF(call_stack, reason) \
grpc_stream_ref(&(call_stack)->refcount, reason)
-#define GRPC_CALL_STACK_UNREF(exec_ctx, call_stack, reason) \
- grpc_stream_unref(exec_ctx, &(call_stack)->refcount, reason)
+#define GRPC_CALL_STACK_UNREF(call_stack, reason) \
+ grpc_stream_unref(&(call_stack)->refcount, reason)
#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \
grpc_stream_ref(&(channel_stack)->refcount, reason)
-#define GRPC_CHANNEL_STACK_UNREF(exec_ctx, channel_stack, reason) \
- grpc_stream_unref(exec_ctx, &(channel_stack)->refcount, reason)
+#define GRPC_CHANNEL_STACK_UNREF(channel_stack, reason) \
+ grpc_stream_unref(&(channel_stack)->refcount, reason)
#else
#define GRPC_CALL_STACK_REF(call_stack, reason) \
grpc_stream_ref(&(call_stack)->refcount)
-#define GRPC_CALL_STACK_UNREF(exec_ctx, call_stack, reason) \
- grpc_stream_unref(exec_ctx, &(call_stack)->refcount)
+#define GRPC_CALL_STACK_UNREF(call_stack, reason) \
+ grpc_stream_unref(&(call_stack)->refcount)
#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \
grpc_stream_ref(&(channel_stack)->refcount)
-#define GRPC_CHANNEL_STACK_UNREF(exec_ctx, channel_stack, reason) \
- grpc_stream_unref(exec_ctx, &(channel_stack)->refcount)
+#define GRPC_CHANNEL_STACK_UNREF(channel_stack, reason) \
+ grpc_stream_unref(&(channel_stack)->refcount)
#endif
/* Destroy a call stack */
-void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
- const grpc_call_final_info *final_info,
- grpc_closure *then_schedule_closure);
+void grpc_call_stack_destroy(grpc_call_stack* stack,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_schedule_closure);
/* Ignore set pollset{_set} - used by filters if they don't care about pollsets
* at all. Does nothing. */
void grpc_call_stack_ignore_set_pollset_or_pollset_set(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_polling_entity *pollent);
+ grpc_call_element* elem, grpc_polling_entity* pollent);
/* Call the next operation in a call stack */
-void grpc_call_next_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op);
+void grpc_call_next_op(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op);
/* Call the next operation (depending on call directionality) in a channel
stack */
-void grpc_channel_next_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_transport_op *op);
+void grpc_channel_next_op(grpc_channel_element* elem, grpc_transport_op* op);
/* Pass through a request to get_channel_info() to the next child element */
-void grpc_channel_next_get_info(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- const grpc_channel_info *channel_info);
+void grpc_channel_next_get_info(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info);
/* Given the top element of a channel stack, get the channel stack itself */
-grpc_channel_stack *grpc_channel_stack_from_top_element(
- grpc_channel_element *elem);
+grpc_channel_stack* grpc_channel_stack_from_top_element(
+ grpc_channel_element* elem);
/* Given the top element of a call stack, get the call stack itself */
-grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem);
+grpc_call_stack* grpc_call_stack_from_top_element(grpc_call_element* elem);
-void grpc_call_log_op(const char *file, int line, gpr_log_severity severity,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op);
+void grpc_call_log_op(const char* file, int line, gpr_log_severity severity,
+ grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op);
-extern grpc_tracer_flag grpc_trace_channel;
+extern grpc_core::TraceFlag grpc_trace_channel;
#define GRPC_CALL_LOG_OP(sev, elem, op) \
- if (GRPC_TRACER_ON(grpc_trace_channel)) grpc_call_log_op(sev, elem, op)
-
-#ifdef __cplusplus
-}
-#endif
+ if (grpc_trace_channel.enabled()) grpc_call_log_op(sev, elem, op)
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H */
diff --git a/src/core/lib/channel/channel_stack_builder.c b/src/core/lib/channel/channel_stack_builder.cc
index b663ebfb52..fcba826644 100644
--- a/src/core/lib/channel/channel_stack_builder.c
+++ b/src/core/lib/channel/channel_stack_builder.cc
@@ -23,15 +23,15 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
-grpc_tracer_flag grpc_trace_channel_stack_builder =
- GRPC_TRACER_INITIALIZER(false, "channel_stack_builder");
+grpc_core::TraceFlag grpc_trace_channel_stack_builder(false,
+ "channel_stack_builder");
typedef struct filter_node {
- struct filter_node *next;
- struct filter_node *prev;
- const grpc_channel_filter *filter;
+ struct filter_node* next;
+ struct filter_node* prev;
+ const grpc_channel_filter* filter;
grpc_post_filter_create_init_func init;
- void *init_arg;
+ void* init_arg;
} filter_node;
struct grpc_channel_stack_builder {
@@ -39,23 +39,23 @@ struct grpc_channel_stack_builder {
filter_node begin;
filter_node end;
// various set/get-able parameters
- grpc_channel_args *args;
- grpc_transport *transport;
- char *target;
- const char *name;
+ grpc_channel_args* args;
+ grpc_transport* transport;
+ char* target;
+ const char* name;
};
struct grpc_channel_stack_builder_iterator {
- grpc_channel_stack_builder *builder;
- filter_node *node;
+ grpc_channel_stack_builder* builder;
+ filter_node* node;
};
-grpc_channel_stack_builder *grpc_channel_stack_builder_create(void) {
- grpc_channel_stack_builder *b =
- (grpc_channel_stack_builder *)gpr_zalloc(sizeof(*b));
+grpc_channel_stack_builder* grpc_channel_stack_builder_create(void) {
+ grpc_channel_stack_builder* b =
+ (grpc_channel_stack_builder*)gpr_zalloc(sizeof(*b));
- b->begin.filter = NULL;
- b->end.filter = NULL;
+ b->begin.filter = nullptr;
+ b->end.filter = nullptr;
b->begin.next = &b->end;
b->begin.prev = &b->end;
b->end.next = &b->begin;
@@ -64,76 +64,76 @@ grpc_channel_stack_builder *grpc_channel_stack_builder_create(void) {
return b;
}
-void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder *b,
- const char *target) {
+void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder* b,
+ const char* target) {
gpr_free(b->target);
b->target = gpr_strdup(target);
}
-const char *grpc_channel_stack_builder_get_target(
- grpc_channel_stack_builder *b) {
+const char* grpc_channel_stack_builder_get_target(
+ grpc_channel_stack_builder* b) {
return b->target;
}
-static grpc_channel_stack_builder_iterator *create_iterator_at_filter_node(
- grpc_channel_stack_builder *builder, filter_node *node) {
- grpc_channel_stack_builder_iterator *it =
- (grpc_channel_stack_builder_iterator *)gpr_malloc(sizeof(*it));
+static grpc_channel_stack_builder_iterator* create_iterator_at_filter_node(
+ grpc_channel_stack_builder* builder, filter_node* node) {
+ grpc_channel_stack_builder_iterator* it =
+ (grpc_channel_stack_builder_iterator*)gpr_malloc(sizeof(*it));
it->builder = builder;
it->node = node;
return it;
}
void grpc_channel_stack_builder_iterator_destroy(
- grpc_channel_stack_builder_iterator *it) {
+ grpc_channel_stack_builder_iterator* it) {
gpr_free(it);
}
-grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_iterator*
grpc_channel_stack_builder_create_iterator_at_first(
- grpc_channel_stack_builder *builder) {
+ grpc_channel_stack_builder* builder) {
return create_iterator_at_filter_node(builder, &builder->begin);
}
-grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_iterator*
grpc_channel_stack_builder_create_iterator_at_last(
- grpc_channel_stack_builder *builder) {
+ grpc_channel_stack_builder* builder) {
return create_iterator_at_filter_node(builder, &builder->end);
}
bool grpc_channel_stack_builder_iterator_is_end(
- grpc_channel_stack_builder_iterator *iterator) {
+ grpc_channel_stack_builder_iterator* iterator) {
return iterator->node == &iterator->builder->end;
}
-const char *grpc_channel_stack_builder_iterator_filter_name(
- grpc_channel_stack_builder_iterator *iterator) {
- if (iterator->node->filter == NULL) return NULL;
+const char* grpc_channel_stack_builder_iterator_filter_name(
+ grpc_channel_stack_builder_iterator* iterator) {
+ if (iterator->node->filter == nullptr) return nullptr;
return iterator->node->filter->name;
}
bool grpc_channel_stack_builder_move_next(
- grpc_channel_stack_builder_iterator *iterator) {
+ grpc_channel_stack_builder_iterator* iterator) {
if (iterator->node == &iterator->builder->end) return false;
iterator->node = iterator->node->next;
return true;
}
bool grpc_channel_stack_builder_move_prev(
- grpc_channel_stack_builder_iterator *iterator) {
+ grpc_channel_stack_builder_iterator* iterator) {
if (iterator->node == &iterator->builder->begin) return false;
iterator->node = iterator->node->prev;
return true;
}
-grpc_channel_stack_builder_iterator *grpc_channel_stack_builder_iterator_find(
- grpc_channel_stack_builder *builder, const char *filter_name) {
- GPR_ASSERT(filter_name != NULL);
- grpc_channel_stack_builder_iterator *it =
+grpc_channel_stack_builder_iterator* grpc_channel_stack_builder_iterator_find(
+ grpc_channel_stack_builder* builder, const char* filter_name) {
+ GPR_ASSERT(filter_name != nullptr);
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_first(builder);
while (grpc_channel_stack_builder_move_next(it)) {
if (grpc_channel_stack_builder_iterator_is_end(it)) break;
- const char *filter_name_at_it =
+ const char* filter_name_at_it =
grpc_channel_stack_builder_iterator_filter_name(it);
if (strcmp(filter_name, filter_name_at_it) == 0) break;
}
@@ -141,43 +141,42 @@ grpc_channel_stack_builder_iterator *grpc_channel_stack_builder_iterator_find(
}
bool grpc_channel_stack_builder_move_prev(
- grpc_channel_stack_builder_iterator *iterator);
+ grpc_channel_stack_builder_iterator* iterator);
-void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder *builder,
- const char *name) {
- GPR_ASSERT(builder->name == NULL);
+void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder,
+ const char* name) {
+ GPR_ASSERT(builder->name == nullptr);
builder->name = name;
}
void grpc_channel_stack_builder_set_channel_arguments(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
- const grpc_channel_args *args) {
- if (builder->args != NULL) {
- grpc_channel_args_destroy(exec_ctx, builder->args);
+ grpc_channel_stack_builder* builder, const grpc_channel_args* args) {
+ if (builder->args != nullptr) {
+ grpc_channel_args_destroy(builder->args);
}
builder->args = grpc_channel_args_copy(args);
}
void grpc_channel_stack_builder_set_transport(
- grpc_channel_stack_builder *builder, grpc_transport *transport) {
- GPR_ASSERT(builder->transport == NULL);
+ grpc_channel_stack_builder* builder, grpc_transport* transport) {
+ GPR_ASSERT(builder->transport == nullptr);
builder->transport = transport;
}
-grpc_transport *grpc_channel_stack_builder_get_transport(
- grpc_channel_stack_builder *builder) {
+grpc_transport* grpc_channel_stack_builder_get_transport(
+ grpc_channel_stack_builder* builder) {
return builder->transport;
}
-const grpc_channel_args *grpc_channel_stack_builder_get_channel_arguments(
- grpc_channel_stack_builder *builder) {
+const grpc_channel_args* grpc_channel_stack_builder_get_channel_arguments(
+ grpc_channel_stack_builder* builder) {
return builder->args;
}
bool grpc_channel_stack_builder_append_filter(
- grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
- grpc_post_filter_create_init_func post_init_func, void *user_data) {
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder* builder, const grpc_channel_filter* filter,
+ grpc_post_filter_create_init_func post_init_func, void* user_data) {
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_last(builder);
bool ok = grpc_channel_stack_builder_add_filter_before(
it, filter, post_init_func, user_data);
@@ -186,8 +185,8 @@ bool grpc_channel_stack_builder_append_filter(
}
bool grpc_channel_stack_builder_remove_filter(
- grpc_channel_stack_builder *builder, const char *filter_name) {
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder* builder, const char* filter_name) {
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_iterator_find(builder, filter_name);
if (grpc_channel_stack_builder_iterator_is_end(it)) {
grpc_channel_stack_builder_iterator_destroy(it);
@@ -201,9 +200,9 @@ bool grpc_channel_stack_builder_remove_filter(
}
bool grpc_channel_stack_builder_prepend_filter(
- grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
- grpc_post_filter_create_init_func post_init_func, void *user_data) {
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder* builder, const grpc_channel_filter* filter,
+ grpc_post_filter_create_init_func post_init_func, void* user_data) {
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_first(builder);
bool ok = grpc_channel_stack_builder_add_filter_after(
it, filter, post_init_func, user_data);
@@ -211,10 +210,10 @@ bool grpc_channel_stack_builder_prepend_filter(
return ok;
}
-static void add_after(filter_node *before, const grpc_channel_filter *filter,
+static void add_after(filter_node* before, const grpc_channel_filter* filter,
grpc_post_filter_create_init_func post_init_func,
- void *user_data) {
- filter_node *new_node = (filter_node *)gpr_malloc(sizeof(*new_node));
+ void* user_data) {
+ filter_node* new_node = (filter_node*)gpr_malloc(sizeof(*new_node));
new_node->next = before->next;
new_node->prev = before;
new_node->next->prev = new_node->prev->next = new_node;
@@ -224,53 +223,51 @@ static void add_after(filter_node *before, const grpc_channel_filter *filter,
}
bool grpc_channel_stack_builder_add_filter_before(
- grpc_channel_stack_builder_iterator *iterator,
- const grpc_channel_filter *filter,
- grpc_post_filter_create_init_func post_init_func, void *user_data) {
+ grpc_channel_stack_builder_iterator* iterator,
+ const grpc_channel_filter* filter,
+ grpc_post_filter_create_init_func post_init_func, void* user_data) {
if (iterator->node == &iterator->builder->begin) return false;
add_after(iterator->node->prev, filter, post_init_func, user_data);
return true;
}
bool grpc_channel_stack_builder_add_filter_after(
- grpc_channel_stack_builder_iterator *iterator,
- const grpc_channel_filter *filter,
- grpc_post_filter_create_init_func post_init_func, void *user_data) {
+ grpc_channel_stack_builder_iterator* iterator,
+ const grpc_channel_filter* filter,
+ grpc_post_filter_create_init_func post_init_func, void* user_data) {
if (iterator->node == &iterator->builder->end) return false;
add_after(iterator->node, filter, post_init_func, user_data);
return true;
}
-void grpc_channel_stack_builder_destroy(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder) {
- filter_node *p = builder->begin.next;
+void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder* builder) {
+ filter_node* p = builder->begin.next;
while (p != &builder->end) {
- filter_node *next = p->next;
+ filter_node* next = p->next;
gpr_free(p);
p = next;
}
- if (builder->args != NULL) {
- grpc_channel_args_destroy(exec_ctx, builder->args);
+ if (builder->args != nullptr) {
+ grpc_channel_args_destroy(builder->args);
}
gpr_free(builder->target);
gpr_free(builder);
}
-grpc_error *grpc_channel_stack_builder_finish(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
- size_t prefix_bytes, int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg, void **result) {
+grpc_error* grpc_channel_stack_builder_finish(
+ grpc_channel_stack_builder* builder, size_t prefix_bytes, int initial_refs,
+ grpc_iomgr_cb_func destroy, void* destroy_arg, void** result) {
// count the number of filters
size_t num_filters = 0;
- for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
+ for (filter_node* p = builder->begin.next; p != &builder->end; p = p->next) {
num_filters++;
}
// create an array of filters
- const grpc_channel_filter **filters =
- (const grpc_channel_filter **)gpr_malloc(sizeof(*filters) * num_filters);
+ const grpc_channel_filter** filters =
+ (const grpc_channel_filter**)gpr_malloc(sizeof(*filters) * num_filters);
size_t i = 0;
- for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
+ for (filter_node* p = builder->begin.next; p != &builder->end; p = p->next) {
filters[i++] = p->filter;
}
@@ -280,24 +277,24 @@ grpc_error *grpc_channel_stack_builder_finish(
// allocate memory, with prefix_bytes followed by channel_stack_size
*result = gpr_zalloc(prefix_bytes + channel_stack_size);
// fetch a pointer to the channel stack
- grpc_channel_stack *channel_stack =
- (grpc_channel_stack *)((char *)(*result) + prefix_bytes);
+ grpc_channel_stack* channel_stack =
+ (grpc_channel_stack*)((char*)(*result) + prefix_bytes);
// and initialize it
- grpc_error *error = grpc_channel_stack_init(
- exec_ctx, initial_refs, destroy,
- destroy_arg == NULL ? *result : destroy_arg, filters, num_filters,
- builder->args, builder->transport, builder->name, channel_stack);
+ grpc_error* error = grpc_channel_stack_init(
+ initial_refs, destroy, destroy_arg == nullptr ? *result : destroy_arg,
+ filters, num_filters, builder->args, builder->transport, builder->name,
+ channel_stack);
if (error != GRPC_ERROR_NONE) {
- grpc_channel_stack_destroy(exec_ctx, channel_stack);
+ grpc_channel_stack_destroy(channel_stack);
gpr_free(*result);
- *result = NULL;
+ *result = nullptr;
} else {
// run post-initialization functions
i = 0;
- for (filter_node *p = builder->begin.next; p != &builder->end;
+ for (filter_node* p = builder->begin.next; p != &builder->end;
p = p->next) {
- if (p->init != NULL) {
+ if (p->init != nullptr) {
p->init(channel_stack, grpc_channel_stack_element(channel_stack, i),
p->init_arg);
}
@@ -305,8 +302,8 @@ grpc_error *grpc_channel_stack_builder_finish(
}
}
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
- gpr_free((grpc_channel_filter **)filters);
+ grpc_channel_stack_builder_destroy(builder);
+ gpr_free((grpc_channel_filter**)filters);
return error;
}
diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h
index fdff2a2b6d..d00ddc698c 100644
--- a/src/core/lib/channel/channel_stack_builder.h
+++ b/src/core/lib/channel/channel_stack_builder.h
@@ -24,10 +24,6 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// grpc_channel_stack_builder offers a programmatic interface to selected
/// and order channel filters
typedef struct grpc_channel_stack_builder grpc_channel_stack_builder;
@@ -35,135 +31,128 @@ typedef struct grpc_channel_stack_builder_iterator
grpc_channel_stack_builder_iterator;
/// Create a new channel stack builder
-grpc_channel_stack_builder *grpc_channel_stack_builder_create(void);
+grpc_channel_stack_builder* grpc_channel_stack_builder_create(void);
/// Assign a name to the channel stack: \a name must be statically allocated
-void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder *builder,
- const char *name);
+void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder,
+ const char* name);
/// Set the target uri
-void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder *b,
- const char *target);
+void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder* b,
+ const char* target);
-const char *grpc_channel_stack_builder_get_target(
- grpc_channel_stack_builder *b);
+const char* grpc_channel_stack_builder_get_target(
+ grpc_channel_stack_builder* b);
/// Attach \a transport to the builder (does not take ownership)
void grpc_channel_stack_builder_set_transport(
- grpc_channel_stack_builder *builder, grpc_transport *transport);
+ grpc_channel_stack_builder* builder, grpc_transport* transport);
/// Fetch attached transport
-grpc_transport *grpc_channel_stack_builder_get_transport(
- grpc_channel_stack_builder *builder);
+grpc_transport* grpc_channel_stack_builder_get_transport(
+ grpc_channel_stack_builder* builder);
/// Set channel arguments: copies args
void grpc_channel_stack_builder_set_channel_arguments(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
- const grpc_channel_args *args);
+ grpc_channel_stack_builder* builder, const grpc_channel_args* args);
/// Return a borrowed pointer to the channel arguments
-const grpc_channel_args *grpc_channel_stack_builder_get_channel_arguments(
- grpc_channel_stack_builder *builder);
+const grpc_channel_args* grpc_channel_stack_builder_get_channel_arguments(
+ grpc_channel_stack_builder* builder);
/// Begin iterating over already defined filters in the builder at the beginning
-grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_iterator*
grpc_channel_stack_builder_create_iterator_at_first(
- grpc_channel_stack_builder *builder);
+ grpc_channel_stack_builder* builder);
/// Begin iterating over already defined filters in the builder at the end
-grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_iterator*
grpc_channel_stack_builder_create_iterator_at_last(
- grpc_channel_stack_builder *builder);
+ grpc_channel_stack_builder* builder);
/// Is an iterator at the first element?
bool grpc_channel_stack_builder_iterator_is_first(
- grpc_channel_stack_builder_iterator *iterator);
+ grpc_channel_stack_builder_iterator* iterator);
/// Is an iterator at the end?
bool grpc_channel_stack_builder_iterator_is_end(
- grpc_channel_stack_builder_iterator *iterator);
+ grpc_channel_stack_builder_iterator* iterator);
/// What is the name of the filter at this iterator position?
-const char *grpc_channel_stack_builder_iterator_filter_name(
- grpc_channel_stack_builder_iterator *iterator);
+const char* grpc_channel_stack_builder_iterator_filter_name(
+ grpc_channel_stack_builder_iterator* iterator);
/// Move an iterator to the next item
bool grpc_channel_stack_builder_move_next(
- grpc_channel_stack_builder_iterator *iterator);
+ grpc_channel_stack_builder_iterator* iterator);
/// Move an iterator to the previous item
bool grpc_channel_stack_builder_move_prev(
- grpc_channel_stack_builder_iterator *iterator);
+ grpc_channel_stack_builder_iterator* iterator);
/// Return an iterator at \a filter_name, or at the end of the list if not
/// found.
-grpc_channel_stack_builder_iterator *grpc_channel_stack_builder_iterator_find(
- grpc_channel_stack_builder *builder, const char *filter_name);
+grpc_channel_stack_builder_iterator* grpc_channel_stack_builder_iterator_find(
+ grpc_channel_stack_builder* builder, const char* filter_name);
typedef void (*grpc_post_filter_create_init_func)(
- grpc_channel_stack *channel_stack, grpc_channel_element *elem, void *arg);
+ grpc_channel_stack* channel_stack, grpc_channel_element* elem, void* arg);
/// Add \a filter to the stack, after \a iterator.
/// Call \a post_init_func(..., \a user_data) once the channel stack is
/// created.
bool grpc_channel_stack_builder_add_filter_after(
- grpc_channel_stack_builder_iterator *iterator,
- const grpc_channel_filter *filter,
+ grpc_channel_stack_builder_iterator* iterator,
+ const grpc_channel_filter* filter,
grpc_post_filter_create_init_func post_init_func,
- void *user_data) GRPC_MUST_USE_RESULT;
+ void* user_data) GRPC_MUST_USE_RESULT;
/// Add \a filter to the stack, before \a iterator.
/// Call \a post_init_func(..., \a user_data) once the channel stack is
/// created.
bool grpc_channel_stack_builder_add_filter_before(
- grpc_channel_stack_builder_iterator *iterator,
- const grpc_channel_filter *filter,
+ grpc_channel_stack_builder_iterator* iterator,
+ const grpc_channel_filter* filter,
grpc_post_filter_create_init_func post_init_func,
- void *user_data) GRPC_MUST_USE_RESULT;
+ void* user_data) GRPC_MUST_USE_RESULT;
/// Add \a filter to the beginning of the filter list.
/// Call \a post_init_func(..., \a user_data) once the channel stack is
/// created.
bool grpc_channel_stack_builder_prepend_filter(
- grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
+ grpc_channel_stack_builder* builder, const grpc_channel_filter* filter,
grpc_post_filter_create_init_func post_init_func,
- void *user_data) GRPC_MUST_USE_RESULT;
+ void* user_data) GRPC_MUST_USE_RESULT;
/// Add \a filter to the end of the filter list.
/// Call \a post_init_func(..., \a user_data) once the channel stack is
/// created.
bool grpc_channel_stack_builder_append_filter(
- grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
+ grpc_channel_stack_builder* builder, const grpc_channel_filter* filter,
grpc_post_filter_create_init_func post_init_func,
- void *user_data) GRPC_MUST_USE_RESULT;
+ void* user_data) GRPC_MUST_USE_RESULT;
/// Remove any filter whose name is \a filter_name from \a builder. Returns true
/// if \a filter_name was not found.
bool grpc_channel_stack_builder_remove_filter(
- grpc_channel_stack_builder *builder, const char *filter_name);
+ grpc_channel_stack_builder* builder, const char* filter_name);
/// Terminate iteration and destroy \a iterator
void grpc_channel_stack_builder_iterator_destroy(
- grpc_channel_stack_builder_iterator *iterator);
+ grpc_channel_stack_builder_iterator* iterator);
/// Destroy the builder, return the freshly minted channel stack in \a result.
/// Allocates \a prefix_bytes bytes before the channel stack
/// Returns the base pointer of the allocated block
/// \a initial_refs, \a destroy, \a destroy_arg are as per
/// grpc_channel_stack_init
-grpc_error *grpc_channel_stack_builder_finish(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
- size_t prefix_bytes, int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg, void **result);
+grpc_error* grpc_channel_stack_builder_finish(
+ grpc_channel_stack_builder* builder, size_t prefix_bytes, int initial_refs,
+ grpc_iomgr_cb_func destroy, void* destroy_arg, void** result);
/// Destroy the builder without creating a channel stack
-void grpc_channel_stack_builder_destroy(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder);
-
-extern grpc_tracer_flag grpc_trace_channel_stack_builder;
+void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder* builder);
-#ifdef __cplusplus
-}
-#endif
+extern grpc_core::TraceFlag grpc_trace_channel_stack_builder;
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H */
diff --git a/src/core/lib/channel/connected_channel.c b/src/core/lib/channel/connected_channel.cc
index 4f37908958..fb26bdf586 100644
--- a/src/core/lib/channel/connected_channel.c
+++ b/src/core/lib/channel/connected_channel.cc
@@ -26,48 +26,45 @@
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/transport.h"
#define MAX_BUFFER_LENGTH 8192
typedef struct connected_channel_channel_data {
- grpc_transport *transport;
+ grpc_transport* transport;
} channel_data;
typedef struct {
grpc_closure closure;
- grpc_closure *original_closure;
- grpc_call_combiner *call_combiner;
- const char *reason;
+ grpc_closure* original_closure;
+ grpc_call_combiner* call_combiner;
+ const char* reason;
} callback_state;
typedef struct connected_channel_call_data {
- grpc_call_combiner *call_combiner;
+ grpc_call_combiner* call_combiner;
// Closures used for returning results on the call combiner.
callback_state on_complete[6]; // Max number of pending batches.
callback_state recv_initial_metadata_ready;
callback_state recv_message_ready;
} call_data;
-static void run_in_call_combiner(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- callback_state *state = (callback_state *)arg;
- GRPC_CALL_COMBINER_START(exec_ctx, state->call_combiner,
- state->original_closure, GRPC_ERROR_REF(error),
- state->reason);
+static void run_in_call_combiner(void* arg, grpc_error* error) {
+ callback_state* state = (callback_state*)arg;
+ GRPC_CALL_COMBINER_START(state->call_combiner, state->original_closure,
+ GRPC_ERROR_REF(error), state->reason);
}
-static void run_cancel_in_call_combiner(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- run_in_call_combiner(exec_ctx, arg, error);
+static void run_cancel_in_call_combiner(void* arg, grpc_error* error) {
+ run_in_call_combiner(arg, error);
gpr_free(arg);
}
-static void intercept_callback(call_data *calld, callback_state *state,
- bool free_when_done, const char *reason,
- grpc_closure **original_closure) {
+static void intercept_callback(call_data* calld, callback_state* state,
+ bool free_when_done, const char* reason,
+ grpc_closure** original_closure) {
state->original_closure = *original_closure;
state->call_combiner = calld->call_combiner;
state->reason = reason;
@@ -77,39 +74,38 @@ static void intercept_callback(call_data *calld, callback_state *state,
state, grpc_schedule_on_exec_ctx);
}
-static callback_state *get_state_for_batch(
- call_data *calld, grpc_transport_stream_op_batch *batch) {
+static callback_state* get_state_for_batch(
+ call_data* calld, grpc_transport_stream_op_batch* batch) {
if (batch->send_initial_metadata) return &calld->on_complete[0];
if (batch->send_message) return &calld->on_complete[1];
if (batch->send_trailing_metadata) return &calld->on_complete[2];
if (batch->recv_initial_metadata) return &calld->on_complete[3];
if (batch->recv_message) return &calld->on_complete[4];
if (batch->recv_trailing_metadata) return &calld->on_complete[5];
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
/* We perform a small hack to locate transport data alongside the connected
channel data in call allocations, to allow everything to be pulled in minimal
cache line requests */
-#define TRANSPORT_STREAM_FROM_CALL_DATA(calld) ((grpc_stream *)((calld) + 1))
+#define TRANSPORT_STREAM_FROM_CALL_DATA(calld) ((grpc_stream*)((calld) + 1))
#define CALL_DATA_FROM_TRANSPORT_STREAM(transport_stream) \
- (((call_data *)(transport_stream)) - 1)
+ (((call_data*)(transport_stream)) - 1)
/* Intercept a call operation and either push it directly up or translate it
into transport stream operations */
static void con_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
if (batch->recv_initial_metadata) {
- callback_state *state = &calld->recv_initial_metadata_ready;
+ callback_state* state = &calld->recv_initial_metadata_ready;
intercept_callback(
calld, state, false, "recv_initial_metadata_ready",
&batch->payload->recv_initial_metadata.recv_initial_metadata_ready);
}
if (batch->recv_message) {
- callback_state *state = &calld->recv_message_ready;
+ callback_state* state = &calld->recv_message_ready;
intercept_callback(calld, state, false, "recv_message_ready",
&batch->payload->recv_message.recv_message_ready);
}
@@ -119,85 +115,77 @@ static void con_start_transport_stream_op_batch(
// calld->on_complete like we can for the other ops. However,
// cancellation isn't in the fast path, so we just allocate a new
// closure for each one.
- callback_state *state = (callback_state *)gpr_malloc(sizeof(*state));
+ callback_state* state = (callback_state*)gpr_malloc(sizeof(*state));
intercept_callback(calld, state, true, "on_complete (cancel_stream)",
&batch->on_complete);
} else {
- callback_state *state = get_state_for_batch(calld, batch);
+ callback_state* state = get_state_for_batch(calld, batch);
intercept_callback(calld, state, false, "on_complete", &batch->on_complete);
}
- grpc_transport_perform_stream_op(exec_ctx, chand->transport,
- TRANSPORT_STREAM_FROM_CALL_DATA(calld),
- batch);
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
- "passed batch to transport");
+ grpc_transport_perform_stream_op(
+ chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld), batch);
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner, "passed batch to transport");
}
-static void con_start_transport_op(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_transport_op *op) {
- channel_data *chand = (channel_data *)elem->channel_data;
- grpc_transport_perform_op(exec_ctx, chand->transport, op);
+static void con_start_transport_op(grpc_channel_element* elem,
+ grpc_transport_op* op) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ grpc_transport_perform_op(chand->transport, op);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
calld->call_combiner = args->call_combiner;
int r = grpc_transport_init_stream(
- exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
+ chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
&args->call_stack->refcount, args->server_transport_data, args->arena);
return r == 0 ? GRPC_ERROR_NONE
: GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"transport stream initialization failed");
}
-static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
- grpc_transport_set_pops(exec_ctx, chand->transport,
+static void set_pollset_or_pollset_set(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ grpc_transport_set_pops(chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollent);
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_schedule_closure) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
- grpc_transport_destroy_stream(exec_ctx, chand->transport,
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_schedule_closure) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ grpc_transport_destroy_stream(chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld),
then_schedule_closure);
}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- channel_data *cd = (channel_data *)elem->channel_data;
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ channel_data* cd = (channel_data*)elem->channel_data;
GPR_ASSERT(args->is_last);
- cd->transport = NULL;
+ cd->transport = nullptr;
return GRPC_ERROR_NONE;
}
/* Destructor for channel_data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
- channel_data *cd = (channel_data *)elem->channel_data;
+static void destroy_channel_elem(grpc_channel_element* elem) {
+ channel_data* cd = (channel_data*)elem->channel_data;
if (cd->transport) {
- grpc_transport_destroy(exec_ctx, cd->transport);
+ grpc_transport_destroy(cd->transport);
}
}
/* No-op. */
-static void con_get_channel_info(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {}
+static void con_get_channel_info(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {}
const grpc_channel_filter grpc_connected_filter = {
con_start_transport_stream_op_batch,
@@ -213,12 +201,12 @@ const grpc_channel_filter grpc_connected_filter = {
"connected",
};
-static void bind_transport(grpc_channel_stack *channel_stack,
- grpc_channel_element *elem, void *t) {
- channel_data *cd = (channel_data *)elem->channel_data;
+static void bind_transport(grpc_channel_stack* channel_stack,
+ grpc_channel_element* elem, void* t) {
+ channel_data* cd = (channel_data*)elem->channel_data;
GPR_ASSERT(elem->filter == &grpc_connected_filter);
- GPR_ASSERT(cd->transport == NULL);
- cd->transport = (grpc_transport *)t;
+ GPR_ASSERT(cd->transport == nullptr);
+ cd->transport = (grpc_transport*)t;
/* HACK(ctiller): increase call stack size for the channel to make space
for channel data. We need a cleaner (but performant) way to do this,
@@ -227,20 +215,19 @@ static void bind_transport(grpc_channel_stack *channel_stack,
the last call element, and the last call element MUST be the connected
channel. */
channel_stack->call_stack_size +=
- grpc_transport_stream_size((grpc_transport *)t);
+ grpc_transport_stream_size((grpc_transport*)t);
}
-bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg_must_be_null) {
- GPR_ASSERT(arg_must_be_null == NULL);
- grpc_transport *t = grpc_channel_stack_builder_get_transport(builder);
- GPR_ASSERT(t != NULL);
+bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
+ void* arg_must_be_null) {
+ GPR_ASSERT(arg_must_be_null == nullptr);
+ grpc_transport* t = grpc_channel_stack_builder_get_transport(builder);
+ GPR_ASSERT(t != nullptr);
return grpc_channel_stack_builder_append_filter(
builder, &grpc_connected_filter, bind_transport, t);
}
-grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem) {
- call_data *calld = (call_data *)elem->call_data;
+grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem) {
+ call_data* calld = (call_data*)elem->call_data;
return TRANSPORT_STREAM_FROM_CALL_DATA(calld);
}
diff --git a/src/core/lib/channel/connected_channel.h b/src/core/lib/channel/connected_channel.h
index 10c98cce54..91de8022db 100644
--- a/src/core/lib/channel/connected_channel.h
+++ b/src/core/lib/channel/connected_channel.h
@@ -23,11 +23,10 @@
extern const grpc_channel_filter grpc_connected_filter;
-bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg_must_be_null);
+bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
+ void* arg_must_be_null);
/* Debug helper to dig the transport stream out of a call element */
-grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem);
+grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem);
#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */
diff --git a/src/core/lib/channel/context.h b/src/core/lib/channel/context.h
index 191bd63351..5daf48a9a9 100644
--- a/src/core/lib/channel/context.h
+++ b/src/core/lib/channel/context.h
@@ -42,8 +42,8 @@ typedef enum {
} grpc_context_index;
typedef struct {
- void *value;
- void (*destroy)(void *);
+ void* value;
+ void (*destroy)(void*);
} grpc_call_context_element;
#endif /* GRPC_CORE_LIB_CHANNEL_CONTEXT_H */
diff --git a/src/core/lib/channel/handshaker.c b/src/core/lib/channel/handshaker.cc
index 1753da5721..dcb149c03e 100644
--- a/src/core/lib/channel/handshaker.c
+++ b/src/core/lib/channel/handshaker.cc
@@ -34,23 +34,20 @@ void grpc_handshaker_init(const grpc_handshaker_vtable* vtable,
handshaker->vtable = vtable;
}
-void grpc_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
- handshaker->vtable->destroy(exec_ctx, handshaker);
+void grpc_handshaker_destroy(grpc_handshaker* handshaker) {
+ handshaker->vtable->destroy(handshaker);
}
-void grpc_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker, grpc_error* why) {
- handshaker->vtable->shutdown(exec_ctx, handshaker, why);
+void grpc_handshaker_shutdown(grpc_handshaker* handshaker, grpc_error* why) {
+ handshaker->vtable->shutdown(handshaker, why);
}
-void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+void grpc_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
- handshaker->vtable->do_handshake(exec_ctx, handshaker, acceptor,
- on_handshake_done, args);
+ handshaker->vtable->do_handshake(handshaker, acceptor, on_handshake_done,
+ args);
}
//
@@ -93,8 +90,8 @@ grpc_handshake_manager* grpc_handshake_manager_create() {
void grpc_handshake_manager_pending_list_add(grpc_handshake_manager** head,
grpc_handshake_manager* mgr) {
- GPR_ASSERT(mgr->prev == NULL);
- GPR_ASSERT(mgr->next == NULL);
+ GPR_ASSERT(mgr->prev == nullptr);
+ GPR_ASSERT(mgr->next == nullptr);
mgr->next = *head;
if (*head) {
(*head)->prev = mgr;
@@ -104,10 +101,10 @@ void grpc_handshake_manager_pending_list_add(grpc_handshake_manager** head,
void grpc_handshake_manager_pending_list_remove(grpc_handshake_manager** head,
grpc_handshake_manager* mgr) {
- if (mgr->next != NULL) {
+ if (mgr->next != nullptr) {
mgr->next->prev = mgr->prev;
}
- if (mgr->prev != NULL) {
+ if (mgr->prev != nullptr) {
mgr->prev->next = mgr->next;
} else {
GPR_ASSERT(*head == mgr);
@@ -116,9 +113,9 @@ void grpc_handshake_manager_pending_list_remove(grpc_handshake_manager** head,
}
void grpc_handshake_manager_pending_list_shutdown_all(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* head, grpc_error* why) {
- while (head != NULL) {
- grpc_handshake_manager_shutdown(exec_ctx, head, GRPC_ERROR_REF(why));
+ grpc_handshake_manager* head, grpc_error* why) {
+ while (head != nullptr) {
+ grpc_handshake_manager_shutdown(head, GRPC_ERROR_REF(why));
head = head->next;
}
GRPC_ERROR_UNREF(why);
@@ -145,11 +142,10 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
gpr_mu_unlock(&mgr->mu);
}
-static void grpc_handshake_manager_unref(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr) {
+static void grpc_handshake_manager_unref(grpc_handshake_manager* mgr) {
if (gpr_unref(&mgr->refs)) {
for (size_t i = 0; i < mgr->count; ++i) {
- grpc_handshaker_destroy(exec_ctx, mgr->handshakers[i]);
+ grpc_handshaker_destroy(mgr->handshakers[i]);
}
gpr_free(mgr->handshakers);
gpr_mu_destroy(&mgr->mu);
@@ -157,19 +153,17 @@ static void grpc_handshake_manager_unref(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr) {
- grpc_handshake_manager_unref(exec_ctx, mgr);
+void grpc_handshake_manager_destroy(grpc_handshake_manager* mgr) {
+ grpc_handshake_manager_unref(mgr);
}
-void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr,
+void grpc_handshake_manager_shutdown(grpc_handshake_manager* mgr,
grpc_error* why) {
gpr_mu_lock(&mgr->mu);
// Shutdown the handshaker that's currently in progress, if any.
if (!mgr->shutdown && mgr->index > 0) {
mgr->shutdown = true;
- grpc_handshaker_shutdown(exec_ctx, mgr->handshakers[mgr->index - 1],
+ grpc_handshaker_shutdown(mgr->handshakers[mgr->index - 1],
GRPC_ERROR_REF(why));
}
gpr_mu_unlock(&mgr->mu);
@@ -179,8 +173,7 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
// Helper function to call either the next handshaker or the
// on_handshake_done callback.
// Returns true if we've scheduled the on_handshake_done callback.
-static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr,
+static bool call_next_handshaker_locked(grpc_handshake_manager* mgr,
grpc_error* error) {
GPR_ASSERT(mgr->index <= mgr->count);
// If we got an error or we've been shut down or we're exiting early or
@@ -190,13 +183,12 @@ static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
mgr->index == mgr->count) {
// Cancel deadline timer, since we're invoking the on_handshake_done
// callback now.
- grpc_timer_cancel(exec_ctx, &mgr->deadline_timer);
- GRPC_CLOSURE_SCHED(exec_ctx, &mgr->on_handshake_done, error);
+ grpc_timer_cancel(&mgr->deadline_timer);
+ GRPC_CLOSURE_SCHED(&mgr->on_handshake_done, error);
mgr->shutdown = true;
} else {
- grpc_handshaker_do_handshake(exec_ctx, mgr->handshakers[mgr->index],
- mgr->acceptor, &mgr->call_next_handshaker,
- &mgr->args);
+ grpc_handshaker_do_handshake(mgr->handshakers[mgr->index], mgr->acceptor,
+ &mgr->call_next_handshaker, &mgr->args);
}
++mgr->index;
return mgr->shutdown;
@@ -204,41 +196,40 @@ static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
// A function used as the handshaker-done callback when chaining
// handshakers together.
-static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void call_next_handshaker(void* arg, grpc_error* error) {
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
gpr_mu_lock(&mgr->mu);
- bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_REF(error));
+ bool done = call_next_handshaker_locked(mgr, GRPC_ERROR_REF(error));
gpr_mu_unlock(&mgr->mu);
// If we're invoked the final callback, we won't be coming back
// to this function, so we can release our reference to the
// handshake manager.
if (done) {
- grpc_handshake_manager_unref(exec_ctx, mgr);
+ grpc_handshake_manager_unref(mgr);
}
}
// Callback invoked when deadline is exceeded.
-static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_timeout(void* arg, grpc_error* error) {
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
if (error == GRPC_ERROR_NONE) { // Timer fired, rather than being cancelled.
grpc_handshake_manager_shutdown(
- exec_ctx, mgr,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake timed out"));
+ mgr, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake timed out"));
}
- grpc_handshake_manager_unref(exec_ctx, mgr);
+ grpc_handshake_manager_unref(mgr);
}
void grpc_handshake_manager_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
+ grpc_handshake_manager* mgr, grpc_pollset_set* interested_parties,
grpc_endpoint* endpoint, const grpc_channel_args* channel_args,
- gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor,
+ grpc_millis deadline, grpc_tcp_server_acceptor* acceptor,
grpc_iomgr_cb_func on_handshake_done, void* user_data) {
gpr_mu_lock(&mgr->mu);
GPR_ASSERT(mgr->index == 0);
GPR_ASSERT(!mgr->shutdown);
// Construct handshaker args. These will be passed through all
// handshakers and eventually be freed by the on_handshake_done callback.
+ mgr->args.interested_parties = interested_parties;
mgr->args.endpoint = endpoint;
mgr->args.args = grpc_channel_args_copy(channel_args);
mgr->args.user_data = user_data;
@@ -255,14 +246,12 @@ void grpc_handshake_manager_do_handshake(
gpr_ref(&mgr->refs);
GRPC_CLOSURE_INIT(&mgr->on_timeout, on_timeout, mgr,
grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &mgr->deadline_timer,
- gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC),
- &mgr->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&mgr->deadline_timer, deadline, &mgr->on_timeout);
// Start first handshaker, which also owns a ref.
gpr_ref(&mgr->refs);
- bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_NONE);
+ bool done = call_next_handshaker_locked(mgr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mgr->mu);
if (done) {
- grpc_handshake_manager_unref(exec_ctx, mgr);
+ grpc_handshake_manager_unref(mgr);
}
}
diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h
index eb9a59bd08..68e5463123 100644
--- a/src/core/lib/channel/handshaker.h
+++ b/src/core/lib/channel/handshaker.h
@@ -54,6 +54,7 @@ typedef struct grpc_handshaker grpc_handshaker;
/// For the on_handshake_done callback, all members are input arguments,
/// which the callback takes ownership of.
typedef struct {
+ grpc_pollset_set* interested_parties;
grpc_endpoint* endpoint;
grpc_channel_args* args;
grpc_slice_buffer* read_buffer;
@@ -67,18 +68,17 @@ typedef struct {
typedef struct {
/// Destroys the handshaker.
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker);
+ void (*destroy)(grpc_handshaker* handshaker);
/// Shuts down the handshaker (e.g., to clean up when the operation is
/// aborted in the middle).
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
- grpc_error* why);
+ void (*shutdown)(grpc_handshaker* handshaker, grpc_error* why);
/// Performs handshaking, modifying \a args as needed (e.g., to
/// replace \a endpoint with a wrapped endpoint).
/// When finished, invokes \a on_handshake_done.
/// \a acceptor will be NULL for client-side handshakers.
- void (*do_handshake)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
+ void (*do_handshake)(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args);
@@ -94,12 +94,9 @@ struct grpc_handshaker {
void grpc_handshaker_init(const grpc_handshaker_vtable* vtable,
grpc_handshaker* handshaker);
-void grpc_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker);
-void grpc_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker, grpc_error* why);
-void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+void grpc_handshaker_destroy(grpc_handshaker* handshaker);
+void grpc_handshaker_shutdown(grpc_handshaker* handshaker, grpc_error* why);
+void grpc_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args);
@@ -119,23 +116,23 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
grpc_handshaker* handshaker);
/// Destroys the handshake manager.
-void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr);
+void grpc_handshake_manager_destroy(grpc_handshake_manager* mgr);
/// Shuts down the handshake manager (e.g., to clean up when the operation is
/// aborted in the middle).
/// The caller must still call grpc_handshake_manager_destroy() after
/// calling this function.
-void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr,
+void grpc_handshake_manager_shutdown(grpc_handshake_manager* mgr,
grpc_error* why);
/// Invokes handshakers in the order they were added.
+/// \a interested_parties may be non-nullptr to provide a pollset_set that
+/// may be used during handshaking. Ownership is not taken.
/// Takes ownership of \a endpoint, and then passes that ownership to
/// the \a on_handshake_done callback.
/// Does NOT take ownership of \a channel_args. Instead, makes a copy before
/// invoking the first handshaker.
-/// \a acceptor will be NULL for client-side handshakers.
+/// \a acceptor will be nullptr for client-side handshakers.
///
/// When done, invokes \a on_handshake_done with a grpc_handshaker_args
/// object as its argument. If the callback is invoked with error !=
@@ -143,9 +140,9 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
/// the necessary clean-up. Otherwise, the callback takes ownership of
/// the arguments.
void grpc_handshake_manager_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
+ grpc_handshake_manager* mgr, grpc_pollset_set* interested_parties,
grpc_endpoint* endpoint, const grpc_channel_args* channel_args,
- gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor,
+ grpc_millis deadline, grpc_tcp_server_acceptor* acceptor,
grpc_iomgr_cb_func on_handshake_done, void* user_data);
/// Add \a mgr to the server side list of all pending handshake managers, the
@@ -162,6 +159,6 @@ void grpc_handshake_manager_pending_list_remove(grpc_handshake_manager** head,
/// Shutdown all pending handshake managers on the server side.
// Not thread-safe. Caller needs to synchronize.
void grpc_handshake_manager_pending_list_shutdown_all(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* head, grpc_error* why);
+ grpc_handshake_manager* head, grpc_error* why);
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */
diff --git a/src/core/lib/channel/handshaker_factory.c b/src/core/lib/channel/handshaker_factory.cc
index 4deb280c60..2380d98300 100644
--- a/src/core/lib/channel/handshaker_factory.c
+++ b/src/core/lib/channel/handshaker_factory.cc
@@ -21,19 +21,19 @@
#include <grpc/support/log.h>
void grpc_handshaker_factory_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory,
- const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
- if (handshaker_factory != NULL) {
- GPR_ASSERT(handshaker_factory->vtable != NULL);
- handshaker_factory->vtable->add_handshakers(exec_ctx, handshaker_factory,
- args, handshake_mgr);
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
+ if (handshaker_factory != nullptr) {
+ GPR_ASSERT(handshaker_factory->vtable != nullptr);
+ handshaker_factory->vtable->add_handshakers(handshaker_factory, args,
+ handshake_mgr);
}
}
void grpc_handshaker_factory_destroy(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory) {
- if (handshaker_factory != NULL) {
- GPR_ASSERT(handshaker_factory->vtable != NULL);
- handshaker_factory->vtable->destroy(exec_ctx, handshaker_factory);
+ grpc_handshaker_factory* handshaker_factory) {
+ if (handshaker_factory != nullptr) {
+ GPR_ASSERT(handshaker_factory->vtable != nullptr);
+ handshaker_factory->vtable->destroy(handshaker_factory);
}
}
diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h
index 6238e735dc..8a7c0157e8 100644
--- a/src/core/lib/channel/handshaker_factory.h
+++ b/src/core/lib/channel/handshaker_factory.h
@@ -29,23 +29,21 @@
typedef struct grpc_handshaker_factory grpc_handshaker_factory;
typedef struct {
- void (*add_handshakers)(grpc_exec_ctx *exec_ctx,
- grpc_handshaker_factory *handshaker_factory,
- const grpc_channel_args *args,
- grpc_handshake_manager *handshake_mgr);
- void (*destroy)(grpc_exec_ctx *exec_ctx,
- grpc_handshaker_factory *handshaker_factory);
+ void (*add_handshakers)(grpc_handshaker_factory* handshaker_factory,
+ const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr);
+ void (*destroy)(grpc_handshaker_factory* handshaker_factory);
} grpc_handshaker_factory_vtable;
struct grpc_handshaker_factory {
- const grpc_handshaker_factory_vtable *vtable;
+ const grpc_handshaker_factory_vtable* vtable;
};
void grpc_handshaker_factory_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory,
- const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr);
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr);
void grpc_handshaker_factory_destroy(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory);
+ grpc_handshaker_factory* handshaker_factory);
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */
diff --git a/src/core/lib/channel/handshaker_registry.c b/src/core/lib/channel/handshaker_registry.cc
index c6bc87d704..098eabf084 100644
--- a/src/core/lib/channel/handshaker_registry.c
+++ b/src/core/lib/channel/handshaker_registry.cc
@@ -47,18 +47,17 @@ static void grpc_handshaker_factory_list_register(
}
static void grpc_handshaker_factory_list_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory_list* list,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory_list* list, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
for (size_t i = 0; i < list->num_factories; ++i) {
- grpc_handshaker_factory_add_handshakers(exec_ctx, list->list[i], args,
- handshake_mgr);
+ grpc_handshaker_factory_add_handshakers(list->list[i], args, handshake_mgr);
}
}
static void grpc_handshaker_factory_list_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory_list* list) {
+ grpc_handshaker_factory_list* list) {
for (size_t i = 0; i < list->num_factories; ++i) {
- grpc_handshaker_factory_destroy(exec_ctx, list->list[i]);
+ grpc_handshaker_factory_destroy(list->list[i]);
}
gpr_free(list->list);
}
@@ -74,10 +73,9 @@ void grpc_handshaker_factory_registry_init() {
memset(g_handshaker_factory_lists, 0, sizeof(g_handshaker_factory_lists));
}
-void grpc_handshaker_factory_registry_shutdown(grpc_exec_ctx* exec_ctx) {
+void grpc_handshaker_factory_registry_shutdown() {
for (size_t i = 0; i < NUM_HANDSHAKER_TYPES; ++i) {
- grpc_handshaker_factory_list_destroy(exec_ctx,
- &g_handshaker_factory_lists[i]);
+ grpc_handshaker_factory_list_destroy(&g_handshaker_factory_lists[i]);
}
}
@@ -88,11 +86,9 @@ void grpc_handshaker_factory_register(bool at_start,
&g_handshaker_factory_lists[handshaker_type], at_start, factory);
}
-void grpc_handshakers_add(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_type handshaker_type,
+void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args,
grpc_handshake_manager* handshake_mgr) {
grpc_handshaker_factory_list_add_handshakers(
- exec_ctx, &g_handshaker_factory_lists[handshaker_type], args,
- handshake_mgr);
+ &g_handshaker_factory_lists[handshaker_type], args, handshake_mgr);
}
diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h
index a3b2ac1dc7..0b05531b7e 100644
--- a/src/core/lib/channel/handshaker_registry.h
+++ b/src/core/lib/channel/handshaker_registry.h
@@ -31,7 +31,7 @@ typedef enum {
} grpc_handshaker_type;
void grpc_handshaker_factory_registry_init();
-void grpc_handshaker_factory_registry_shutdown(grpc_exec_ctx* exec_ctx);
+void grpc_handshaker_factory_registry_shutdown();
/// Registers a new handshaker factory. Takes ownership.
/// If \a at_start is true, the new handshaker will be at the beginning of
@@ -40,8 +40,7 @@ void grpc_handshaker_factory_register(bool at_start,
grpc_handshaker_type handshaker_type,
grpc_handshaker_factory* factory);
-void grpc_handshakers_add(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_type handshaker_type,
+void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args,
grpc_handshake_manager* handshake_mgr);
diff --git a/src/core/lib/compression/algorithm_metadata.h b/src/core/lib/compression/algorithm_metadata.h
index 08feafc1bb..7db771ea74 100644
--- a/src/core/lib/compression/algorithm_metadata.h
+++ b/src/core/lib/compression/algorithm_metadata.h
@@ -20,20 +20,27 @@
#define GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H
#include <grpc/compression.h>
+#include "src/core/lib/compression/compression_internal.h"
#include "src/core/lib/transport/metadata.h"
/** Return compression algorithm based metadata value */
grpc_slice grpc_compression_algorithm_slice(
grpc_compression_algorithm algorithm);
-/** Return stream compression algorithm based metadata value */
-grpc_slice grpc_stream_compression_algorithm_slice(
- grpc_stream_compression_algorithm algorithm);
+/** Find compression algorithm based on passed in mdstr - returns
+ * GRPC_COMPRESS_ALGORITHM_COUNT on failure */
+grpc_compression_algorithm grpc_compression_algorithm_from_slice(
+ grpc_slice str);
-/** Return compression algorithm based metadata element (grpc-encoding: xxx) */
+/** Return compression algorithm based metadata element */
grpc_mdelem grpc_compression_encoding_mdelem(
grpc_compression_algorithm algorithm);
+/** Return message compression algorithm based metadata element (grpc-encoding:
+ * xxx) */
+grpc_mdelem grpc_message_compression_encoding_mdelem(
+ grpc_message_compression_algorithm algorithm);
+
/** Return stream compression algorithm based metadata element
* (content-encoding: xxx) */
grpc_mdelem grpc_stream_compression_encoding_mdelem(
@@ -41,8 +48,8 @@ grpc_mdelem grpc_stream_compression_encoding_mdelem(
/** Find compression algorithm based on passed in mdstr - returns
* GRPC_COMPRESS_ALGORITHM_COUNT on failure */
-grpc_compression_algorithm grpc_compression_algorithm_from_slice(
- grpc_slice str);
+grpc_message_compression_algorithm
+grpc_message_compression_algorithm_from_slice(grpc_slice str);
/** Find stream compression algorithm based on passed in mdstr - returns
* GRPC_STREAM_COMPRESS_ALGORITHM_COUNT on failure */
diff --git a/src/core/lib/compression/compression.c b/src/core/lib/compression/compression.c
deleted file mode 100644
index 1cfac23129..0000000000
--- a/src/core/lib/compression/compression.c
+++ /dev/null
@@ -1,283 +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 <stdlib.h>
-#include <string.h>
-
-#include <grpc/compression.h>
-#include <grpc/support/useful.h>
-
-#include "src/core/lib/compression/algorithm_metadata.h"
-#include "src/core/lib/surface/api_trace.h"
-#include "src/core/lib/transport/static_metadata.h"
-
-int grpc_compression_algorithm_parse(grpc_slice name,
- grpc_compression_algorithm *algorithm) {
- /* we use strncmp not only because it's safer (even though in this case it
- * doesn't matter, given that we are comparing against string literals, but
- * because this way we needn't have "name" nil-terminated (useful for slice
- * data, for example) */
- if (grpc_slice_eq(name, GRPC_MDSTR_IDENTITY)) {
- *algorithm = GRPC_COMPRESS_NONE;
- 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_DEFLATE)) {
- *algorithm = GRPC_COMPRESS_DEFLATE;
- return 1;
- } else {
- return 0;
- }
-}
-
-int grpc_stream_compression_algorithm_parse(
- grpc_slice name, grpc_stream_compression_algorithm *algorithm) {
- if (grpc_slice_eq(name, GRPC_MDSTR_IDENTITY)) {
- *algorithm = GRPC_STREAM_COMPRESS_NONE;
- return 1;
- } else if (grpc_slice_eq(name, GRPC_MDSTR_GZIP)) {
- *algorithm = GRPC_STREAM_COMPRESS_GZIP;
- return 1;
- } else {
- return 0;
- }
-}
-
-int grpc_compression_algorithm_name(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_ALGORITHMS_COUNT:
- return 0;
- }
- return 0;
-}
-
-int grpc_stream_compression_algorithm_name(
- grpc_stream_compression_algorithm algorithm, const char **name) {
- GRPC_API_TRACE(
- "grpc_stream_compression_algorithm_parse(algorithm=%d, name=%p)", 2,
- ((int)algorithm, name));
- switch (algorithm) {
- case GRPC_STREAM_COMPRESS_NONE:
- *name = "identity";
- return 1;
- case GRPC_STREAM_COMPRESS_GZIP:
- *name = "gzip";
- return 1;
- case GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT:
- return 0;
- }
- return 0;
-}
-
-grpc_compression_algorithm grpc_compression_algorithm_from_slice(
- grpc_slice str) {
- if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_COMPRESS_NONE;
- if (grpc_slice_eq(str, GRPC_MDSTR_DEFLATE)) return GRPC_COMPRESS_DEFLATE;
- if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_COMPRESS_GZIP;
- return GRPC_COMPRESS_ALGORITHMS_COUNT;
-}
-
-grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice(
- grpc_slice str) {
- if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_STREAM_COMPRESS_NONE;
- if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_STREAM_COMPRESS_GZIP;
- return GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT;
-}
-
-grpc_slice grpc_compression_algorithm_slice(
- grpc_compression_algorithm algorithm) {
- switch (algorithm) {
- case GRPC_COMPRESS_NONE:
- return GRPC_MDSTR_IDENTITY;
- case GRPC_COMPRESS_DEFLATE:
- return GRPC_MDSTR_DEFLATE;
- case GRPC_COMPRESS_GZIP:
- return GRPC_MDSTR_GZIP;
- case GRPC_COMPRESS_ALGORITHMS_COUNT:
- return grpc_empty_slice();
- }
- return grpc_empty_slice();
-}
-
-grpc_slice grpc_stream_compression_algorithm_slice(
- grpc_stream_compression_algorithm algorithm) {
- switch (algorithm) {
- case GRPC_STREAM_COMPRESS_NONE:
- return GRPC_MDSTR_IDENTITY;
- case GRPC_STREAM_COMPRESS_GZIP:
- return GRPC_MDSTR_GZIP;
- case GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT:
- return grpc_empty_slice();
- }
- return grpc_empty_slice();
-}
-
-grpc_mdelem grpc_compression_encoding_mdelem(
- grpc_compression_algorithm algorithm) {
- switch (algorithm) {
- case GRPC_COMPRESS_NONE:
- return GRPC_MDELEM_GRPC_ENCODING_IDENTITY;
- case GRPC_COMPRESS_DEFLATE:
- return GRPC_MDELEM_GRPC_ENCODING_DEFLATE;
- case GRPC_COMPRESS_GZIP:
- return GRPC_MDELEM_GRPC_ENCODING_GZIP;
- default:
- break;
- }
- return GRPC_MDNULL;
-}
-
-grpc_mdelem grpc_stream_compression_encoding_mdelem(
- grpc_stream_compression_algorithm algorithm) {
- switch (algorithm) {
- case GRPC_STREAM_COMPRESS_NONE:
- return GRPC_MDELEM_CONTENT_ENCODING_IDENTITY;
- case GRPC_STREAM_COMPRESS_GZIP:
- return GRPC_MDELEM_CONTENT_ENCODING_GZIP;
- default:
- break;
- }
- return GRPC_MDNULL;
-}
-
-void grpc_compression_options_init(grpc_compression_options *opts) {
- memset(opts, 0, sizeof(*opts));
- /* all enabled by default */
- opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
- opts->enabled_stream_compression_algorithms_bitset =
- (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1;
-}
-
-void grpc_compression_options_enable_algorithm(
- grpc_compression_options *opts, grpc_compression_algorithm algorithm) {
- GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm);
-}
-
-void grpc_compression_options_disable_algorithm(
- grpc_compression_options *opts, grpc_compression_algorithm algorithm) {
- GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm);
-}
-
-int grpc_compression_options_is_algorithm_enabled(
- const grpc_compression_options *opts,
- grpc_compression_algorithm algorithm) {
- return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm);
-}
-
-int grpc_compression_options_is_stream_compression_algorithm_enabled(
- const grpc_compression_options *opts,
- grpc_stream_compression_algorithm algorithm) {
- return GPR_BITGET(opts->enabled_stream_compression_algorithms_bitset,
- algorithm);
-}
-
-/* TODO(dgq): Add the ability to specify parameters to the individual
- * compression algorithms */
-grpc_compression_algorithm grpc_compression_algorithm_for_level(
- grpc_compression_level level, uint32_t accepted_encodings) {
- GRPC_API_TRACE("grpc_compression_algorithm_for_level(level=%d)", 1,
- ((int)level));
- if (level > GRPC_COMPRESS_LEVEL_HIGH) {
- gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
- abort();
- }
-
- const size_t num_supported =
- GPR_BITCOUNT(accepted_encodings) - 1; /* discard NONE */
- if (level == GRPC_COMPRESS_LEVEL_NONE || num_supported == 0) {
- return GRPC_COMPRESS_NONE;
- }
-
- GPR_ASSERT(level > 0);
-
- /* Establish a "ranking" or compression algorithms in increasing order of
- * compression.
- * This is simplistic and we will probably want to introduce other dimensions
- * in the future (cpu/memory cost, etc). */
- const grpc_compression_algorithm algos_ranking[] = {GRPC_COMPRESS_GZIP,
- GRPC_COMPRESS_DEFLATE};
-
- /* intersect algos_ranking with the supported ones keeping the ranked order */
- grpc_compression_algorithm
- sorted_supported_algos[GRPC_COMPRESS_ALGORITHMS_COUNT];
- size_t algos_supported_idx = 0;
- for (size_t i = 0; i < GPR_ARRAY_SIZE(algos_ranking); i++) {
- const grpc_compression_algorithm alg = algos_ranking[i];
- for (size_t j = 0; j < num_supported; j++) {
- if (GPR_BITGET(accepted_encodings, alg) == 1) {
- /* if \a alg in supported */
- sorted_supported_algos[algos_supported_idx++] = alg;
- break;
- }
- }
- if (algos_supported_idx == num_supported) break;
- }
-
- switch (level) {
- case GRPC_COMPRESS_LEVEL_NONE:
- abort(); /* should have been handled already */
- case GRPC_COMPRESS_LEVEL_LOW:
- return sorted_supported_algos[0];
- case GRPC_COMPRESS_LEVEL_MED:
- return sorted_supported_algos[num_supported / 2];
- case GRPC_COMPRESS_LEVEL_HIGH:
- return sorted_supported_algos[num_supported - 1];
- default:
- abort();
- };
-}
-
-GRPCAPI grpc_stream_compression_algorithm
-grpc_stream_compression_algorithm_for_level(
- grpc_stream_compression_level level, uint32_t accepted_stream_encodings) {
- GRPC_API_TRACE("grpc_stream_compression_algorithm_for_level(level=%d)", 1,
- ((int)level));
- if (level > GRPC_STREAM_COMPRESS_LEVEL_HIGH) {
- gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
- abort();
- }
-
- switch (level) {
- case GRPC_STREAM_COMPRESS_LEVEL_NONE:
- return GRPC_STREAM_COMPRESS_NONE;
- case GRPC_STREAM_COMPRESS_LEVEL_LOW:
- case GRPC_STREAM_COMPRESS_LEVEL_MED:
- case GRPC_STREAM_COMPRESS_LEVEL_HIGH:
- if (GPR_BITGET(accepted_stream_encodings, GRPC_STREAM_COMPRESS_GZIP) ==
- 1) {
- return GRPC_STREAM_COMPRESS_GZIP;
- } else {
- return GRPC_STREAM_COMPRESS_NONE;
- }
- default:
- abort();
- }
-}
diff --git a/src/core/lib/compression/compression.cc b/src/core/lib/compression/compression.cc
new file mode 100644
index 0000000000..99e6014b23
--- /dev/null
+++ b/src/core/lib/compression/compression.cc
@@ -0,0 +1,175 @@
+/*
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include <grpc/compression.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/compression/algorithm_metadata.h"
+#include "src/core/lib/compression/compression_internal.h"
+#include "src/core/lib/surface/api_trace.h"
+#include "src/core/lib/transport/static_metadata.h"
+
+int grpc_compression_algorithm_is_message(
+ grpc_compression_algorithm algorithm) {
+ return (algorithm >= GRPC_COMPRESS_MESSAGE_DEFLATE &&
+ algorithm <= GRPC_COMPRESS_MESSAGE_GZIP)
+ ? 1
+ : 0;
+}
+
+int grpc_compression_algorithm_is_stream(grpc_compression_algorithm algorithm) {
+ return (algorithm == GRPC_COMPRESS_STREAM_GZIP) ? 1 : 0;
+}
+
+int grpc_compression_algorithm_parse(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_MESSAGE_SLASH_DEFLATE)) {
+ *algorithm = GRPC_COMPRESS_MESSAGE_DEFLATE;
+ return 1;
+ } else if (grpc_slice_eq(name, GRPC_MDSTR_MESSAGE_SLASH_GZIP)) {
+ *algorithm = GRPC_COMPRESS_MESSAGE_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(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_MESSAGE_DEFLATE:
+ *name = "message/deflate";
+ return 1;
+ case GRPC_COMPRESS_MESSAGE_GZIP:
+ *name = "message/gzip";
+ return 1;
+ case GRPC_COMPRESS_STREAM_GZIP:
+ *name = "stream/gzip";
+ return 1;
+ case GRPC_COMPRESS_ALGORITHMS_COUNT:
+ return 0;
+ }
+ return 0;
+}
+
+grpc_compression_algorithm grpc_compression_algorithm_for_level(
+ grpc_compression_level level, uint32_t accepted_encodings) {
+ grpc_compression_algorithm algo;
+ if (level == GRPC_COMPRESS_LEVEL_NONE) {
+ return GRPC_COMPRESS_NONE;
+ } else if (level <= GRPC_COMPRESS_LEVEL_HIGH) {
+ // TODO(mxyan): Design algorithm to select from all algorithms, including
+ // stream compression algorithm
+ if (!grpc_compression_algorithm_from_message_stream_compression_algorithm(
+ &algo,
+ grpc_message_compression_algorithm_for_level(
+ level,
+ grpc_compression_bitset_to_message_bitset(accepted_encodings)),
+ static_cast<grpc_stream_compression_algorithm>(0))) {
+ gpr_log(GPR_ERROR, "Parse compression level error");
+ return GRPC_COMPRESS_NONE;
+ }
+ return algo;
+ } else {
+ gpr_log(GPR_ERROR, "Unknown compression level: %d", level);
+ return GRPC_COMPRESS_NONE;
+ }
+}
+
+void grpc_compression_options_init(grpc_compression_options* opts) {
+ memset(opts, 0, sizeof(*opts));
+ /* all enabled by default */
+ opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
+}
+
+void grpc_compression_options_enable_algorithm(
+ grpc_compression_options* opts, grpc_compression_algorithm algorithm) {
+ GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm);
+}
+
+void grpc_compression_options_disable_algorithm(
+ grpc_compression_options* opts, grpc_compression_algorithm algorithm) {
+ GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm);
+}
+
+int grpc_compression_options_is_algorithm_enabled(
+ const grpc_compression_options* opts,
+ grpc_compression_algorithm algorithm) {
+ return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm);
+}
+
+grpc_slice grpc_compression_algorithm_slice(
+ grpc_compression_algorithm algorithm) {
+ switch (algorithm) {
+ case GRPC_COMPRESS_NONE:
+ return GRPC_MDSTR_IDENTITY;
+ case GRPC_COMPRESS_MESSAGE_DEFLATE:
+ return GRPC_MDSTR_MESSAGE_SLASH_DEFLATE;
+ case GRPC_COMPRESS_MESSAGE_GZIP:
+ return GRPC_MDSTR_MESSAGE_SLASH_GZIP;
+ case GRPC_COMPRESS_STREAM_GZIP:
+ return GRPC_MDSTR_STREAM_SLASH_GZIP;
+ case GRPC_COMPRESS_ALGORITHMS_COUNT:
+ return grpc_empty_slice();
+ }
+ return grpc_empty_slice();
+}
+
+grpc_compression_algorithm grpc_compression_algorithm_from_slice(
+ grpc_slice str) {
+ if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_COMPRESS_NONE;
+ if (grpc_slice_eq(str, GRPC_MDSTR_MESSAGE_SLASH_DEFLATE))
+ return GRPC_COMPRESS_MESSAGE_DEFLATE;
+ if (grpc_slice_eq(str, GRPC_MDSTR_MESSAGE_SLASH_GZIP))
+ return GRPC_COMPRESS_MESSAGE_GZIP;
+ if (grpc_slice_eq(str, GRPC_MDSTR_STREAM_SLASH_GZIP))
+ return GRPC_COMPRESS_STREAM_GZIP;
+ return GRPC_COMPRESS_ALGORITHMS_COUNT;
+}
+
+grpc_mdelem grpc_compression_encoding_mdelem(
+ grpc_compression_algorithm algorithm) {
+ switch (algorithm) {
+ case GRPC_COMPRESS_NONE:
+ return GRPC_MDELEM_GRPC_ENCODING_IDENTITY;
+ case GRPC_COMPRESS_MESSAGE_DEFLATE:
+ return GRPC_MDELEM_GRPC_ENCODING_DEFLATE;
+ case GRPC_COMPRESS_MESSAGE_GZIP:
+ return GRPC_MDELEM_GRPC_ENCODING_GZIP;
+ case GRPC_COMPRESS_STREAM_GZIP:
+ return GRPC_MDELEM_GRPC_ENCODING_GZIP;
+ default:
+ break;
+ }
+ return GRPC_MDNULL;
+}
diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc
new file mode 100644
index 0000000000..263cdf06eb
--- /dev/null
+++ b/src/core/lib/compression/compression_internal.cc
@@ -0,0 +1,273 @@
+/*
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include <grpc/compression.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/compression/algorithm_metadata.h"
+#include "src/core/lib/compression/compression_internal.h"
+#include "src/core/lib/surface/api_trace.h"
+#include "src/core/lib/transport/static_metadata.h"
+
+/* Interfaces related to MD */
+
+grpc_message_compression_algorithm
+grpc_message_compression_algorithm_from_slice(grpc_slice str) {
+ if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY))
+ return GRPC_MESSAGE_COMPRESS_NONE;
+ if (grpc_slice_eq(str, GRPC_MDSTR_DEFLATE))
+ return GRPC_MESSAGE_COMPRESS_DEFLATE;
+ if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_MESSAGE_COMPRESS_GZIP;
+ return GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT;
+}
+
+grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice(
+ grpc_slice str) {
+ if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_STREAM_COMPRESS_NONE;
+ if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_STREAM_COMPRESS_GZIP;
+ return GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT;
+}
+
+grpc_mdelem grpc_message_compression_encoding_mdelem(
+ grpc_message_compression_algorithm algorithm) {
+ switch (algorithm) {
+ case GRPC_MESSAGE_COMPRESS_NONE:
+ return GRPC_MDELEM_GRPC_ENCODING_IDENTITY;
+ case GRPC_MESSAGE_COMPRESS_DEFLATE:
+ return GRPC_MDELEM_GRPC_ENCODING_DEFLATE;
+ case GRPC_MESSAGE_COMPRESS_GZIP:
+ return GRPC_MDELEM_GRPC_ENCODING_GZIP;
+ default:
+ break;
+ }
+ return GRPC_MDNULL;
+}
+
+grpc_mdelem grpc_stream_compression_encoding_mdelem(
+ grpc_stream_compression_algorithm algorithm) {
+ switch (algorithm) {
+ case GRPC_STREAM_COMPRESS_NONE:
+ return GRPC_MDELEM_CONTENT_ENCODING_IDENTITY;
+ case GRPC_STREAM_COMPRESS_GZIP:
+ return GRPC_MDELEM_CONTENT_ENCODING_GZIP;
+ default:
+ break;
+ }
+ return GRPC_MDNULL;
+}
+
+/* Interfaces performing transformation between compression algorithms and
+ * levels. */
+grpc_message_compression_algorithm
+grpc_compression_algorithm_to_message_compression_algorithm(
+ grpc_compression_algorithm algo) {
+ switch (algo) {
+ case GRPC_COMPRESS_MESSAGE_DEFLATE:
+ return GRPC_MESSAGE_COMPRESS_DEFLATE;
+ case GRPC_COMPRESS_MESSAGE_GZIP:
+ return GRPC_MESSAGE_COMPRESS_GZIP;
+ default:
+ return GRPC_MESSAGE_COMPRESS_NONE;
+ }
+}
+
+grpc_stream_compression_algorithm
+grpc_compression_algorithm_to_stream_compression_algorithm(
+ grpc_compression_algorithm algo) {
+ switch (algo) {
+ case GRPC_COMPRESS_STREAM_GZIP:
+ return GRPC_STREAM_COMPRESS_GZIP;
+ default:
+ return GRPC_STREAM_COMPRESS_NONE;
+ }
+}
+
+uint32_t grpc_compression_bitset_to_message_bitset(uint32_t bitset) {
+ return bitset & ((1u << GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT) - 1);
+}
+
+uint32_t grpc_compression_bitset_to_stream_bitset(uint32_t bitset) {
+ uint32_t identity = (bitset & 1u);
+ uint32_t other_bits =
+ (bitset >> (GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT - 1)) &
+ ((1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 2);
+ return identity | other_bits;
+}
+
+uint32_t grpc_compression_bitset_from_message_stream_compression_bitset(
+ uint32_t message_bitset, uint32_t stream_bitset) {
+ uint32_t offset_stream_bitset =
+ (stream_bitset & 1u) |
+ ((stream_bitset & (~1u)) << (GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT - 1));
+ return message_bitset | offset_stream_bitset;
+}
+
+int grpc_compression_algorithm_from_message_stream_compression_algorithm(
+ grpc_compression_algorithm* algorithm,
+ grpc_message_compression_algorithm message_algorithm,
+ grpc_stream_compression_algorithm stream_algorithm) {
+ if (message_algorithm != GRPC_MESSAGE_COMPRESS_NONE &&
+ stream_algorithm != GRPC_STREAM_COMPRESS_NONE) {
+ *algorithm = GRPC_COMPRESS_NONE;
+ return 0;
+ }
+ if (message_algorithm == GRPC_MESSAGE_COMPRESS_NONE) {
+ switch (stream_algorithm) {
+ case GRPC_STREAM_COMPRESS_NONE:
+ *algorithm = GRPC_COMPRESS_NONE;
+ return 1;
+ case GRPC_STREAM_COMPRESS_GZIP:
+ *algorithm = GRPC_COMPRESS_STREAM_GZIP;
+ return 1;
+ default:
+ *algorithm = GRPC_COMPRESS_NONE;
+ return 0;
+ }
+ } else {
+ switch (message_algorithm) {
+ case GRPC_MESSAGE_COMPRESS_NONE:
+ *algorithm = GRPC_COMPRESS_NONE;
+ return 1;
+ case GRPC_MESSAGE_COMPRESS_DEFLATE:
+ *algorithm = GRPC_COMPRESS_MESSAGE_DEFLATE;
+ return 1;
+ case GRPC_MESSAGE_COMPRESS_GZIP:
+ *algorithm = GRPC_COMPRESS_MESSAGE_GZIP;
+ return 1;
+ default:
+ *algorithm = GRPC_COMPRESS_NONE;
+ return 0;
+ }
+ }
+ return 0;
+}
+
+/* Interfaces for message compression. */
+
+int grpc_message_compression_algorithm_name(
+ grpc_message_compression_algorithm algorithm, const char** name) {
+ GRPC_API_TRACE(
+ "grpc_message_compression_algorithm_parse(algorithm=%d, name=%p)", 2,
+ ((int)algorithm, name));
+ switch (algorithm) {
+ case GRPC_MESSAGE_COMPRESS_NONE:
+ *name = "identity";
+ return 1;
+ case GRPC_MESSAGE_COMPRESS_DEFLATE:
+ *name = "deflate";
+ return 1;
+ case GRPC_MESSAGE_COMPRESS_GZIP:
+ *name = "gzip";
+ return 1;
+ case GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT:
+ return 0;
+ }
+ return 0;
+}
+
+/* TODO(dgq): Add the ability to specify parameters to the individual
+ * compression algorithms */
+grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level(
+ grpc_compression_level level, uint32_t accepted_encodings) {
+ GRPC_API_TRACE("grpc_message_compression_algorithm_for_level(level=%d)", 1,
+ ((int)level));
+ if (level > GRPC_COMPRESS_LEVEL_HIGH) {
+ gpr_log(GPR_ERROR, "Unknown message compression level %d.", (int)level);
+ abort();
+ }
+
+ const size_t num_supported =
+ GPR_BITCOUNT(accepted_encodings) - 1; /* discard NONE */
+ if (level == GRPC_COMPRESS_LEVEL_NONE || num_supported == 0) {
+ return GRPC_MESSAGE_COMPRESS_NONE;
+ }
+
+ GPR_ASSERT(level > 0);
+
+ /* Establish a "ranking" or compression algorithms in increasing order of
+ * compression.
+ * This is simplistic and we will probably want to introduce other dimensions
+ * in the future (cpu/memory cost, etc). */
+ const grpc_message_compression_algorithm algos_ranking[] = {
+ GRPC_MESSAGE_COMPRESS_GZIP, GRPC_MESSAGE_COMPRESS_DEFLATE};
+
+ /* intersect algos_ranking with the supported ones keeping the ranked order */
+ grpc_message_compression_algorithm
+ sorted_supported_algos[GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT];
+ size_t algos_supported_idx = 0;
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(algos_ranking); i++) {
+ const grpc_message_compression_algorithm alg = algos_ranking[i];
+ for (size_t j = 0; j < num_supported; j++) {
+ if (GPR_BITGET(accepted_encodings, alg) == 1) {
+ /* if \a alg in supported */
+ sorted_supported_algos[algos_supported_idx++] = alg;
+ break;
+ }
+ }
+ if (algos_supported_idx == num_supported) break;
+ }
+
+ switch (level) {
+ case GRPC_COMPRESS_LEVEL_NONE:
+ abort(); /* should have been handled already */
+ case GRPC_COMPRESS_LEVEL_LOW:
+ return sorted_supported_algos[0];
+ case GRPC_COMPRESS_LEVEL_MED:
+ return sorted_supported_algos[num_supported / 2];
+ case GRPC_COMPRESS_LEVEL_HIGH:
+ return sorted_supported_algos[num_supported - 1];
+ default:
+ abort();
+ };
+}
+
+int grpc_message_compression_algorithm_parse(
+ grpc_slice value, grpc_message_compression_algorithm* algorithm) {
+ if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) {
+ *algorithm = GRPC_MESSAGE_COMPRESS_NONE;
+ return 1;
+ } else if (grpc_slice_eq(value, GRPC_MDSTR_DEFLATE)) {
+ *algorithm = GRPC_MESSAGE_COMPRESS_DEFLATE;
+ return 1;
+ } else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) {
+ *algorithm = GRPC_MESSAGE_COMPRESS_GZIP;
+ return 1;
+ } else {
+ return 0;
+ }
+ return 0;
+}
+
+/* Interfaces for stream compression. */
+
+int grpc_stream_compression_algorithm_parse(
+ grpc_slice value, grpc_stream_compression_algorithm* algorithm) {
+ if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) {
+ *algorithm = GRPC_STREAM_COMPRESS_NONE;
+ return 1;
+ } else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) {
+ *algorithm = GRPC_STREAM_COMPRESS_GZIP;
+ return 1;
+ } else {
+ return 0;
+ }
+ return 0;
+}
diff --git a/src/core/lib/compression/compression_internal.h b/src/core/lib/compression/compression_internal.h
new file mode 100644
index 0000000000..72f01dd1b7
--- /dev/null
+++ b/src/core/lib/compression/compression_internal.h
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H
+#define GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H
+
+#include <grpc/impl/codegen/compression_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ GRPC_MESSAGE_COMPRESS_NONE = 0,
+ GRPC_MESSAGE_COMPRESS_DEFLATE,
+ GRPC_MESSAGE_COMPRESS_GZIP,
+ /* TODO(ctiller): snappy */
+ GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT
+} grpc_message_compression_algorithm;
+
+/** Stream compresssion algorithms supported by gRPC */
+typedef enum {
+ GRPC_STREAM_COMPRESS_NONE = 0,
+ GRPC_STREAM_COMPRESS_GZIP,
+ GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT
+} grpc_stream_compression_algorithm;
+
+/* Interfaces performing transformation between compression algorithms and
+ * levels. */
+
+grpc_message_compression_algorithm
+grpc_compression_algorithm_to_message_compression_algorithm(
+ grpc_compression_algorithm algo);
+
+grpc_stream_compression_algorithm
+grpc_compression_algorithm_to_stream_compression_algorithm(
+ grpc_compression_algorithm algo);
+
+uint32_t grpc_compression_bitset_to_message_bitset(uint32_t bitset);
+
+uint32_t grpc_compression_bitset_to_stream_bitset(uint32_t bitset);
+
+uint32_t grpc_compression_bitset_from_message_stream_compression_bitset(
+ uint32_t message_bitset, uint32_t stream_bitset);
+
+int grpc_compression_algorithm_from_message_stream_compression_algorithm(
+ grpc_compression_algorithm* algorithm,
+ grpc_message_compression_algorithm message_algorithm,
+ grpc_stream_compression_algorithm stream_algorithm);
+
+/* Interfaces for message compression. */
+
+int grpc_message_compression_algorithm_name(
+ grpc_message_compression_algorithm algorithm, const char** name);
+
+grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level(
+ grpc_compression_level level, uint32_t accepted_encodings);
+
+int grpc_message_compression_algorithm_parse(
+ grpc_slice value, grpc_message_compression_algorithm* algorithm);
+
+/* Interfaces for stream compression. */
+
+int grpc_stream_compression_algorithm_parse(
+ grpc_slice value, grpc_stream_compression_algorithm* algorithm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H */
diff --git a/src/core/lib/compression/compression_ruby.cc b/src/core/lib/compression/compression_ruby.cc
new file mode 100644
index 0000000000..293062f5ed
--- /dev/null
+++ b/src/core/lib/compression/compression_ruby.cc
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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 <grpc/compression_ruby.h>
+#include <grpc/support/useful.h>
+
+#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_MESSAGE_DEFLATE;
+ return 1;
+ } else if (grpc_slice_eq(name, GRPC_MDSTR_GZIP)) {
+ *algorithm = GRPC_COMPRESS_MESSAGE_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_MESSAGE_DEFLATE:
+ *name = "deflate";
+ return 1;
+ case GRPC_COMPRESS_MESSAGE_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/core/lib/compression/message_compress.c b/src/core/lib/compression/message_compress.cc
index c051e28864..1e9b0f10ee 100644
--- a/src/core/lib/compression/message_compress.c
+++ b/src/core/lib/compression/message_compress.cc
@@ -29,8 +29,8 @@
#define OUTPUT_BLOCK_SIZE 1024
-static int zlib_body(grpc_exec_ctx* exec_ctx, z_stream* zs,
- grpc_slice_buffer* input, grpc_slice_buffer* output,
+static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
+ grpc_slice_buffer* output,
int (*flate)(z_stream* zs, int flush)) {
int r;
int flush;
@@ -74,7 +74,7 @@ static int zlib_body(grpc_exec_ctx* exec_ctx, z_stream* zs,
return 1;
error:
- grpc_slice_unref_internal(exec_ctx, outbuf);
+ grpc_slice_unref_internal(outbuf);
return 0;
}
@@ -84,8 +84,8 @@ static void* zalloc_gpr(void* opaque, unsigned int items, unsigned int size) {
static void zfree_gpr(void* opaque, void* address) { gpr_free(address); }
-static int zlib_compress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
- grpc_slice_buffer* output, int gzip) {
+static int zlib_compress(grpc_slice_buffer* input, grpc_slice_buffer* output,
+ int gzip) {
z_stream zs;
int r;
size_t i;
@@ -97,11 +97,10 @@ static int zlib_compress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
r = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 | (gzip ? 16 : 0),
8, Z_DEFAULT_STRATEGY);
GPR_ASSERT(r == Z_OK);
- r = zlib_body(exec_ctx, &zs, input, output, deflate) &&
- output->length < input->length;
+ r = zlib_body(&zs, input, output, deflate) && output->length < input->length;
if (!r) {
for (i = count_before; i < output->count; i++) {
- grpc_slice_unref_internal(exec_ctx, output->slices[i]);
+ grpc_slice_unref_internal(output->slices[i]);
}
output->count = count_before;
output->length = length_before;
@@ -110,8 +109,8 @@ static int zlib_compress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
return r;
}
-static int zlib_decompress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
- grpc_slice_buffer* output, int gzip) {
+static int zlib_decompress(grpc_slice_buffer* input, grpc_slice_buffer* output,
+ int gzip) {
z_stream zs;
int r;
size_t i;
@@ -122,10 +121,10 @@ static int zlib_decompress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
zs.zfree = zfree_gpr;
r = inflateInit2(&zs, 15 | (gzip ? 16 : 0));
GPR_ASSERT(r == Z_OK);
- r = zlib_body(exec_ctx, &zs, input, output, inflate);
+ r = zlib_body(&zs, input, output, inflate);
if (!r) {
for (i = count_before; i < output->count; i++) {
- grpc_slice_unref_internal(exec_ctx, output->slices[i]);
+ grpc_slice_unref_internal(output->slices[i]);
}
output->count = count_before;
output->length = length_before;
@@ -142,46 +141,43 @@ static int copy(grpc_slice_buffer* input, grpc_slice_buffer* output) {
return 1;
}
-static int compress_inner(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+static int compress_inner(grpc_message_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output) {
switch (algorithm) {
- case GRPC_COMPRESS_NONE:
+ case GRPC_MESSAGE_COMPRESS_NONE:
/* the fallback path always needs to be send uncompressed: we simply
rely on that here */
return 0;
- case GRPC_COMPRESS_DEFLATE:
- return zlib_compress(exec_ctx, input, output, 0);
- case GRPC_COMPRESS_GZIP:
- return zlib_compress(exec_ctx, input, output, 1);
- case GRPC_COMPRESS_ALGORITHMS_COUNT:
+ case GRPC_MESSAGE_COMPRESS_DEFLATE:
+ return zlib_compress(input, output, 0);
+ case GRPC_MESSAGE_COMPRESS_GZIP:
+ return zlib_compress(input, output, 1);
+ case GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT:
break;
}
gpr_log(GPR_ERROR, "invalid compression algorithm %d", algorithm);
return 0;
}
-int grpc_msg_compress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_compress(grpc_message_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output) {
- if (!compress_inner(exec_ctx, algorithm, input, output)) {
+ if (!compress_inner(algorithm, input, output)) {
copy(input, output);
return 0;
}
return 1;
}
-int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_decompress(grpc_message_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output) {
switch (algorithm) {
- case GRPC_COMPRESS_NONE:
+ case GRPC_MESSAGE_COMPRESS_NONE:
return copy(input, output);
- case GRPC_COMPRESS_DEFLATE:
- return zlib_decompress(exec_ctx, input, output, 0);
- case GRPC_COMPRESS_GZIP:
- return zlib_decompress(exec_ctx, input, output, 1);
- case GRPC_COMPRESS_ALGORITHMS_COUNT:
+ case GRPC_MESSAGE_COMPRESS_DEFLATE:
+ return zlib_decompress(input, output, 0);
+ case GRPC_MESSAGE_COMPRESS_GZIP:
+ return zlib_decompress(input, output, 1);
+ case GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT:
break;
}
gpr_log(GPR_ERROR, "invalid compression algorithm %d", algorithm);
diff --git a/src/core/lib/compression/message_compress.h b/src/core/lib/compression/message_compress.h
index ca8ca37f8e..ed9e5bfa39 100644
--- a/src/core/lib/compression/message_compress.h
+++ b/src/core/lib/compression/message_compress.h
@@ -19,21 +19,20 @@
#ifndef GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H
#define GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H
-#include <grpc/compression.h>
#include <grpc/slice_buffer.h>
+#include "src/core/lib/compression/compression_internal.h"
+
/* compress 'input' to 'output' using 'algorithm'.
On success, appends compressed slices to output and returns 1.
On failure, appends uncompressed slices to output and returns 0. */
-int grpc_msg_compress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_compress(grpc_message_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output);
/* decompress 'input' to 'output' using 'algorithm'.
On success, appends slices to output and returns 1.
On failure, output is unchanged, and returns 0. */
-int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_decompress(grpc_message_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output);
#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */
diff --git a/src/core/lib/compression/stream_compression.c b/src/core/lib/compression/stream_compression.cc
index 411489f029..b4b3e524d0 100644
--- a/src/core/lib/compression/stream_compression.c
+++ b/src/core/lib/compression/stream_compression.cc
@@ -24,23 +24,23 @@
extern const grpc_stream_compression_vtable
grpc_stream_compression_identity_vtable;
-bool grpc_stream_compress(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in, grpc_slice_buffer *out,
- size_t *output_size, size_t max_output_size,
+bool grpc_stream_compress(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in, grpc_slice_buffer* out,
+ size_t* output_size, size_t max_output_size,
grpc_stream_compression_flush flush) {
return ctx->vtable->compress(ctx, in, out, output_size, max_output_size,
flush);
}
-bool grpc_stream_decompress(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in, grpc_slice_buffer *out,
- size_t *output_size, size_t max_output_size,
- bool *end_of_context) {
+bool grpc_stream_decompress(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in, grpc_slice_buffer* out,
+ size_t* output_size, size_t max_output_size,
+ bool* end_of_context) {
return ctx->vtable->decompress(ctx, in, out, output_size, max_output_size,
end_of_context);
}
-grpc_stream_compression_context *grpc_stream_compression_context_create(
+grpc_stream_compression_context* grpc_stream_compression_context_create(
grpc_stream_compression_method method) {
switch (method) {
case GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS:
@@ -51,18 +51,18 @@ grpc_stream_compression_context *grpc_stream_compression_context_create(
return grpc_stream_compression_gzip_vtable.context_create(method);
default:
gpr_log(GPR_ERROR, "Unknown stream compression method: %d", method);
- return NULL;
+ return nullptr;
}
}
void grpc_stream_compression_context_destroy(
- grpc_stream_compression_context *ctx) {
+ grpc_stream_compression_context* ctx) {
ctx->vtable->context_destroy(ctx);
}
int grpc_stream_compression_method_parse(
grpc_slice value, bool is_compress,
- grpc_stream_compression_method *method) {
+ grpc_stream_compression_method* method) {
if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) {
*method = is_compress ? GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS
: GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS;
diff --git a/src/core/lib/compression/stream_compression.h b/src/core/lib/compression/stream_compression.h
index 6d073280fa..8322835c4f 100644
--- a/src/core/lib/compression/stream_compression.h
+++ b/src/core/lib/compression/stream_compression.h
@@ -30,7 +30,7 @@ typedef struct grpc_stream_compression_vtable grpc_stream_compression_vtable;
/* Stream compression/decompression context */
typedef struct grpc_stream_compression_context {
- const grpc_stream_compression_vtable *vtable;
+ const grpc_stream_compression_vtable* vtable;
} grpc_stream_compression_context;
typedef enum grpc_stream_compression_method {
@@ -49,16 +49,16 @@ typedef enum grpc_stream_compression_flush {
} grpc_stream_compression_flush;
struct grpc_stream_compression_vtable {
- bool (*compress)(grpc_stream_compression_context *ctx, grpc_slice_buffer *in,
- grpc_slice_buffer *out, size_t *output_size,
+ bool (*compress)(grpc_stream_compression_context* ctx, grpc_slice_buffer* in,
+ grpc_slice_buffer* out, size_t* output_size,
size_t max_output_size, grpc_stream_compression_flush flush);
- bool (*decompress)(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in, grpc_slice_buffer *out,
- size_t *output_size, size_t max_output_size,
- bool *end_of_context);
- grpc_stream_compression_context *(*context_create)(
+ bool (*decompress)(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in, grpc_slice_buffer* out,
+ size_t* output_size, size_t max_output_size,
+ bool* end_of_context);
+ grpc_stream_compression_context* (*context_create)(
grpc_stream_compression_method method);
- void (*context_destroy)(grpc_stream_compression_context *ctx);
+ void (*context_destroy)(grpc_stream_compression_context* ctx);
};
/**
@@ -74,9 +74,9 @@ struct grpc_stream_compression_vtable {
* previous compressed bytes. It allows corresponding decompression context to
* be dropped when reaching this boundary.
*/
-bool grpc_stream_compress(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in, grpc_slice_buffer *out,
- size_t *output_size, size_t max_output_size,
+bool grpc_stream_compress(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in, grpc_slice_buffer* out,
+ size_t* output_size, size_t max_output_size,
grpc_stream_compression_flush flush);
/**
@@ -86,29 +86,29 @@ bool grpc_stream_compress(grpc_stream_compression_context *ctx,
* it is set to false. The total number of bytes emitted is outputed in \a
* output_size.
*/
-bool grpc_stream_decompress(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in, grpc_slice_buffer *out,
- size_t *output_size, size_t max_output_size,
- bool *end_of_context);
+bool grpc_stream_decompress(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in, grpc_slice_buffer* out,
+ size_t* output_size, size_t max_output_size,
+ bool* end_of_context);
/**
* Creates a stream compression context. \a pending_bytes_buffer is the input
* buffer for compression/decompression operations. \a method specifies whether
* the context is for compression or decompression.
*/
-grpc_stream_compression_context *grpc_stream_compression_context_create(
+grpc_stream_compression_context* grpc_stream_compression_context_create(
grpc_stream_compression_method method);
/**
* Destroys a stream compression context.
*/
void grpc_stream_compression_context_destroy(
- grpc_stream_compression_context *ctx);
+ grpc_stream_compression_context* ctx);
/**
* Parse stream compression method based on algorithm name
*/
int grpc_stream_compression_method_parse(
- grpc_slice value, bool is_compress, grpc_stream_compression_method *method);
+ grpc_slice value, bool is_compress, grpc_stream_compression_method* method);
#endif
diff --git a/src/core/lib/compression/stream_compression_gzip.c b/src/core/lib/compression/stream_compression_gzip.cc
index abcbdb3a91..897f3918a7 100644
--- a/src/core/lib/compression/stream_compression_gzip.c
+++ b/src/core/lib/compression/stream_compression_gzip.cc
@@ -29,18 +29,18 @@ typedef struct grpc_stream_compression_context_gzip {
grpc_stream_compression_context base;
z_stream zs;
- int (*flate)(z_stream *zs, int flush);
+ int (*flate)(z_stream* zs, int flush);
} grpc_stream_compression_context_gzip;
-static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
- grpc_slice_buffer *in, grpc_slice_buffer *out,
- size_t *output_size, size_t max_output_size, int flush,
- bool *end_of_context) {
+static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
+ grpc_slice_buffer* in, grpc_slice_buffer* out,
+ size_t* output_size, size_t max_output_size, int flush,
+ bool* end_of_context) {
GPR_ASSERT(flush == 0 || flush == Z_SYNC_FLUSH || flush == Z_FINISH);
/* Full flush is not allowed when inflating. */
GPR_ASSERT(!(ctx->flate == inflate && (flush == Z_FINISH)));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
int r;
bool eoc = false;
size_t original_max_output_size = max_output_size;
@@ -57,8 +57,8 @@ static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
r = ctx->flate(&ctx->zs, Z_NO_FLUSH);
if (r < 0 && r != Z_BUF_ERROR) {
gpr_log(GPR_ERROR, "zlib error (%d)", r);
- grpc_slice_unref_internal(&exec_ctx, slice_out);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(slice_out);
+
return false;
} else if (r == Z_STREAM_END && ctx->flate == inflate) {
eoc = true;
@@ -69,7 +69,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
grpc_slice_sub(slice, GRPC_SLICE_LENGTH(slice) - ctx->zs.avail_in,
GRPC_SLICE_LENGTH(slice)));
}
- grpc_slice_unref_internal(&exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
}
if (flush != 0 && ctx->zs.avail_out > 0 && !eoc) {
GPR_ASSERT(in->length == 0);
@@ -88,8 +88,8 @@ static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
break;
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
- grpc_slice_unref_internal(&exec_ctx, slice_out);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(slice_out);
+
return false;
}
} else if (flush == Z_FINISH) {
@@ -104,8 +104,8 @@ static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
break;
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
- grpc_slice_unref_internal(&exec_ctx, slice_out);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(slice_out);
+
return false;
}
}
@@ -114,14 +114,15 @@ static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
if (ctx->zs.avail_out == 0) {
grpc_slice_buffer_add(out, slice_out);
} else if (ctx->zs.avail_out < slice_size) {
- slice_out.data.refcounted.length -= ctx->zs.avail_out;
+ size_t len = GRPC_SLICE_LENGTH(slice_out);
+ GRPC_SLICE_SET_LENGTH(slice_out, len - ctx->zs.avail_out);
grpc_slice_buffer_add(out, slice_out);
} else {
- grpc_slice_unref_internal(&exec_ctx, slice_out);
+ grpc_slice_unref_internal(slice_out);
}
max_output_size -= (slice_size - ctx->zs.avail_out);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (end_of_context) {
*end_of_context = eoc;
}
@@ -131,17 +132,17 @@ static bool gzip_flate(grpc_stream_compression_context_gzip *ctx,
return true;
}
-static bool grpc_stream_compress_gzip(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in,
- grpc_slice_buffer *out,
- size_t *output_size,
+static bool grpc_stream_compress_gzip(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in,
+ grpc_slice_buffer* out,
+ size_t* output_size,
size_t max_output_size,
grpc_stream_compression_flush flush) {
- if (ctx == NULL) {
+ if (ctx == nullptr) {
return false;
}
- grpc_stream_compression_context_gzip *gzip_ctx =
- (grpc_stream_compression_context_gzip *)ctx;
+ grpc_stream_compression_context_gzip* gzip_ctx =
+ (grpc_stream_compression_context_gzip*)ctx;
GPR_ASSERT(gzip_ctx->flate == deflate);
int gzip_flush;
switch (flush) {
@@ -158,36 +159,36 @@ static bool grpc_stream_compress_gzip(grpc_stream_compression_context *ctx,
gzip_flush = 0;
}
return gzip_flate(gzip_ctx, in, out, output_size, max_output_size, gzip_flush,
- NULL);
+ nullptr);
}
-static bool grpc_stream_decompress_gzip(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in,
- grpc_slice_buffer *out,
- size_t *output_size,
+static bool grpc_stream_decompress_gzip(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in,
+ grpc_slice_buffer* out,
+ size_t* output_size,
size_t max_output_size,
- bool *end_of_context) {
- if (ctx == NULL) {
+ bool* end_of_context) {
+ if (ctx == nullptr) {
return false;
}
- grpc_stream_compression_context_gzip *gzip_ctx =
- (grpc_stream_compression_context_gzip *)ctx;
+ grpc_stream_compression_context_gzip* gzip_ctx =
+ (grpc_stream_compression_context_gzip*)ctx;
GPR_ASSERT(gzip_ctx->flate == inflate);
return gzip_flate(gzip_ctx, in, out, output_size, max_output_size,
Z_SYNC_FLUSH, end_of_context);
}
-static grpc_stream_compression_context *
+static grpc_stream_compression_context*
grpc_stream_compression_context_create_gzip(
grpc_stream_compression_method method) {
GPR_ASSERT(method == GRPC_STREAM_COMPRESSION_GZIP_COMPRESS ||
method == GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
- grpc_stream_compression_context_gzip *gzip_ctx =
- (grpc_stream_compression_context_gzip *)gpr_zalloc(
+ grpc_stream_compression_context_gzip* gzip_ctx =
+ (grpc_stream_compression_context_gzip*)gpr_zalloc(
sizeof(grpc_stream_compression_context_gzip));
int r;
- if (gzip_ctx == NULL) {
- return NULL;
+ if (gzip_ctx == nullptr) {
+ return nullptr;
}
if (method == GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS) {
r = inflateInit2(&gzip_ctx->zs, 0x1F);
@@ -199,20 +200,20 @@ grpc_stream_compression_context_create_gzip(
}
if (r != Z_OK) {
gpr_free(gzip_ctx);
- return NULL;
+ return nullptr;
}
gzip_ctx->base.vtable = &grpc_stream_compression_gzip_vtable;
- return (grpc_stream_compression_context *)gzip_ctx;
+ return (grpc_stream_compression_context*)gzip_ctx;
}
static void grpc_stream_compression_context_destroy_gzip(
- grpc_stream_compression_context *ctx) {
- if (ctx == NULL) {
+ grpc_stream_compression_context* ctx) {
+ if (ctx == nullptr) {
return;
}
- grpc_stream_compression_context_gzip *gzip_ctx =
- (grpc_stream_compression_context_gzip *)ctx;
+ grpc_stream_compression_context_gzip* gzip_ctx =
+ (grpc_stream_compression_context_gzip*)ctx;
if (gzip_ctx->flate == inflate) {
inflateEnd(&gzip_ctx->zs);
} else {
@@ -222,7 +223,6 @@ static void grpc_stream_compression_context_destroy_gzip(
}
const grpc_stream_compression_vtable grpc_stream_compression_gzip_vtable = {
- .compress = grpc_stream_compress_gzip,
- .decompress = grpc_stream_decompress_gzip,
- .context_create = grpc_stream_compression_context_create_gzip,
- .context_destroy = grpc_stream_compression_context_destroy_gzip};
+ grpc_stream_compress_gzip, grpc_stream_decompress_gzip,
+ grpc_stream_compression_context_create_gzip,
+ grpc_stream_compression_context_destroy_gzip};
diff --git a/src/core/lib/compression/stream_compression_identity.c b/src/core/lib/compression/stream_compression_identity.cc
index 3dfcf53b85..af4051144c 100644
--- a/src/core/lib/compression/stream_compression_identity.c
+++ b/src/core/lib/compression/stream_compression_identity.cc
@@ -27,11 +27,11 @@
/* Singleton context used for all identity streams. */
static grpc_stream_compression_context identity_ctx = {
- .vtable = &grpc_stream_compression_identity_vtable};
+ &grpc_stream_compression_identity_vtable};
-static void grpc_stream_compression_pass_through(grpc_slice_buffer *in,
- grpc_slice_buffer *out,
- size_t *output_size,
+static void grpc_stream_compression_pass_through(grpc_slice_buffer* in,
+ grpc_slice_buffer* out,
+ size_t* output_size,
size_t max_output_size) {
if (max_output_size >= in->length) {
if (output_size) {
@@ -46,13 +46,13 @@ static void grpc_stream_compression_pass_through(grpc_slice_buffer *in,
}
}
-static bool grpc_stream_compress_identity(grpc_stream_compression_context *ctx,
- grpc_slice_buffer *in,
- grpc_slice_buffer *out,
- size_t *output_size,
+static bool grpc_stream_compress_identity(grpc_stream_compression_context* ctx,
+ grpc_slice_buffer* in,
+ grpc_slice_buffer* out,
+ size_t* output_size,
size_t max_output_size,
grpc_stream_compression_flush flush) {
- if (ctx == NULL) {
+ if (ctx == nullptr) {
return false;
}
grpc_stream_compression_pass_through(in, out, output_size, max_output_size);
@@ -60,10 +60,10 @@ static bool grpc_stream_compress_identity(grpc_stream_compression_context *ctx,
}
static bool grpc_stream_decompress_identity(
- grpc_stream_compression_context *ctx, grpc_slice_buffer *in,
- grpc_slice_buffer *out, size_t *output_size, size_t max_output_size,
- bool *end_of_context) {
- if (ctx == NULL) {
+ grpc_stream_compression_context* ctx, grpc_slice_buffer* in,
+ grpc_slice_buffer* out, size_t* output_size, size_t max_output_size,
+ bool* end_of_context) {
+ if (ctx == nullptr) {
return false;
}
grpc_stream_compression_pass_through(in, out, output_size, max_output_size);
@@ -73,22 +73,21 @@ static bool grpc_stream_decompress_identity(
return true;
}
-static grpc_stream_compression_context *
+static grpc_stream_compression_context*
grpc_stream_compression_context_create_identity(
grpc_stream_compression_method method) {
GPR_ASSERT(method == GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS ||
method == GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS);
/* No context needed in this case. Use fake context instead. */
- return (grpc_stream_compression_context *)&identity_ctx;
+ return (grpc_stream_compression_context*)&identity_ctx;
}
static void grpc_stream_compression_context_destroy_identity(
- grpc_stream_compression_context *ctx) {
+ grpc_stream_compression_context* ctx) {
return;
}
const grpc_stream_compression_vtable grpc_stream_compression_identity_vtable = {
- .compress = grpc_stream_compress_identity,
- .decompress = grpc_stream_decompress_identity,
- .context_create = grpc_stream_compression_context_create_identity,
- .context_destroy = grpc_stream_compression_context_destroy_identity};
+ grpc_stream_compress_identity, grpc_stream_decompress_identity,
+ grpc_stream_compression_context_create_identity,
+ grpc_stream_compression_context_destroy_identity};
diff --git a/src/core/lib/debug/stats.c b/src/core/lib/debug/stats.cc
index 4096384dd9..465c76114d 100644
--- a/src/core/lib/debug/stats.c
+++ b/src/core/lib/debug/stats.cc
@@ -25,20 +25,20 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-grpc_stats_data *grpc_stats_per_cpu_storage = NULL;
+grpc_stats_data* grpc_stats_per_cpu_storage = nullptr;
static size_t g_num_cores;
void grpc_stats_init(void) {
g_num_cores = GPR_MAX(1, gpr_cpu_num_cores());
grpc_stats_per_cpu_storage =
- (grpc_stats_data *)gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores);
+ (grpc_stats_data*)gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores);
}
void grpc_stats_shutdown(void) { gpr_free(grpc_stats_per_cpu_storage); }
-void grpc_stats_collect(grpc_stats_data *output) {
+void grpc_stats_collect(grpc_stats_data* output) {
memset(output, 0, sizeof(*output));
for (size_t core = 0; core < g_num_cores; core++) {
for (size_t i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
@@ -52,8 +52,8 @@ void grpc_stats_collect(grpc_stats_data *output) {
}
}
-void grpc_stats_diff(const grpc_stats_data *b, const grpc_stats_data *a,
- grpc_stats_data *c) {
+void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
+ grpc_stats_data* c) {
for (size_t i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
c->counters[i] = b->counters[i] - a->counters[i];
}
@@ -62,13 +62,13 @@ void grpc_stats_diff(const grpc_stats_data *b, const grpc_stats_data *a,
}
}
-int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx *exec_ctx, int value,
- const int *table, int table_size) {
- GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx);
- const int *const start = table;
+int grpc_stats_histo_find_bucket_slow(int value, const int* table,
+ int table_size) {
+ GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS();
+ const int* const start = table;
while (table_size > 0) {
int step = table_size / 2;
- const int *it = table + step;
+ const int* it = table + step;
if (value >= *it) {
table = it + 1;
table_size -= step + 1;
@@ -79,7 +79,7 @@ int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx *exec_ctx, int value,
return (int)(table - start) - 1;
}
-size_t grpc_stats_histo_count(const grpc_stats_data *stats,
+size_t grpc_stats_histo_count(const grpc_stats_data* stats,
grpc_stats_histograms histogram) {
size_t sum = 0;
for (int i = 0; i < grpc_stats_histo_buckets[histogram]; i++) {
@@ -88,8 +88,8 @@ size_t grpc_stats_histo_count(const grpc_stats_data *stats,
return sum;
}
-static double threshold_for_count_below(const gpr_atm *bucket_counts,
- const int *bucket_boundaries,
+static double threshold_for_count_below(const gpr_atm* bucket_counts,
+ const int* bucket_boundaries,
int num_buckets, double count_below) {
double count_so_far;
double lower_bound;
@@ -119,13 +119,13 @@ static double threshold_for_count_below(const gpr_atm *bucket_counts,
should lie */
lower_bound = bucket_boundaries[lower_idx];
upper_bound = bucket_boundaries[lower_idx + 1];
- return upper_bound -
- (upper_bound - lower_bound) * (count_so_far - count_below) /
- (double)bucket_counts[lower_idx];
+ return upper_bound - (upper_bound - lower_bound) *
+ (count_so_far - count_below) /
+ (double)bucket_counts[lower_idx];
}
}
-double grpc_stats_histo_percentile(const grpc_stats_data *stats,
+double grpc_stats_histo_percentile(const grpc_stats_data* stats,
grpc_stats_histograms histogram,
double percentile) {
size_t count = grpc_stats_histo_count(stats, histogram);
@@ -136,9 +136,9 @@ double grpc_stats_histo_percentile(const grpc_stats_data *stats,
grpc_stats_histo_buckets[histogram], (double)count * percentile / 100.0);
}
-char *grpc_stats_data_as_json(const grpc_stats_data *data) {
+char* grpc_stats_data_as_json(const grpc_stats_data* data) {
gpr_strvec v;
- char *tmp;
+ char* tmp;
bool is_first = true;
gpr_strvec_init(&v);
gpr_strvec_add(&v, gpr_strdup("{"));
@@ -168,7 +168,7 @@ char *grpc_stats_data_as_json(const grpc_stats_data *data) {
is_first = false;
}
gpr_strvec_add(&v, gpr_strdup("}"));
- tmp = gpr_strvec_flatten(&v, NULL);
+ tmp = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
return tmp;
}
diff --git a/src/core/lib/debug/stats.h b/src/core/lib/debug/stats.h
index 09d190d488..02eed5e844 100644
--- a/src/core/lib/debug/stats.h
+++ b/src/core/lib/debug/stats.h
@@ -28,34 +28,32 @@ typedef struct grpc_stats_data {
gpr_atm histograms[GRPC_STATS_HISTOGRAM_BUCKETS];
} grpc_stats_data;
-extern grpc_stats_data *grpc_stats_per_cpu_storage;
+extern grpc_stats_data* grpc_stats_per_cpu_storage;
-#define GRPC_THREAD_STATS_DATA(exec_ctx) \
- (&grpc_stats_per_cpu_storage[(exec_ctx)->starting_cpu])
+#define GRPC_THREAD_STATS_DATA() \
+ (&grpc_stats_per_cpu_storage[grpc_core::ExecCtx::Get()->starting_cpu()])
-#define GRPC_STATS_INC_COUNTER(exec_ctx, ctr) \
- (gpr_atm_no_barrier_fetch_add( \
- &GRPC_THREAD_STATS_DATA((exec_ctx))->counters[(ctr)], 1))
+#define GRPC_STATS_INC_COUNTER(ctr) \
+ (gpr_atm_no_barrier_fetch_add(&GRPC_THREAD_STATS_DATA()->counters[(ctr)], 1))
-#define GRPC_STATS_INC_HISTOGRAM(exec_ctx, histogram, index) \
- (gpr_atm_no_barrier_fetch_add( \
- &GRPC_THREAD_STATS_DATA((exec_ctx)) \
- ->histograms[histogram##_FIRST_SLOT + (index)], \
+#define GRPC_STATS_INC_HISTOGRAM(histogram, index) \
+ (gpr_atm_no_barrier_fetch_add( \
+ &GRPC_THREAD_STATS_DATA()->histograms[histogram##_FIRST_SLOT + (index)], \
1))
void grpc_stats_init(void);
void grpc_stats_shutdown(void);
-void grpc_stats_collect(grpc_stats_data *output);
+void grpc_stats_collect(grpc_stats_data* output);
// c = b-a
-void grpc_stats_diff(const grpc_stats_data *b, const grpc_stats_data *a,
- grpc_stats_data *c);
-char *grpc_stats_data_as_json(const grpc_stats_data *data);
-int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx *exec_ctx, int value,
- const int *table, int table_size);
-double grpc_stats_histo_percentile(const grpc_stats_data *data,
+void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
+ grpc_stats_data* c);
+char* grpc_stats_data_as_json(const grpc_stats_data* data);
+int grpc_stats_histo_find_bucket_slow(int value, const int* table,
+ int table_size);
+double grpc_stats_histo_percentile(const grpc_stats_data* data,
grpc_stats_histograms histogram,
double percentile);
-size_t grpc_stats_histo_count(const grpc_stats_data *data,
+size_t grpc_stats_histo_count(const grpc_stats_data* data,
grpc_stats_histograms histogram);
#endif
diff --git a/src/core/lib/debug/stats_data.c b/src/core/lib/debug/stats_data.cc
index fb6055f795..996ed3de9a 100644
--- a/src/core/lib/debug/stats_data.c
+++ b/src/core/lib/debug/stats_data.cc
@@ -22,7 +22,7 @@
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = {
+const char* grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = {
"client_calls_created",
"server_calls_created",
"cqs_created",
@@ -77,6 +77,7 @@ const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = {
"http2_initiate_write_due_to_transport_flow_control_unstalled",
"http2_initiate_write_due_to_ping_response",
"http2_initiate_write_due_to_force_rst_stream",
+ "http2_spurious_writes_begun",
"hpack_recv_indexed",
"hpack_recv_lithdr_incidx",
"hpack_recv_lithdr_incidx_v",
@@ -103,22 +104,29 @@ const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = {
"combiner_locks_scheduled_items",
"combiner_locks_scheduled_final_items",
"combiner_locks_offloaded",
+ "call_combiner_locks_initiated",
+ "call_combiner_locks_scheduled_items",
+ "call_combiner_set_notify_on_cancel",
+ "call_combiner_cancelled",
"executor_scheduled_short_items",
"executor_scheduled_long_items",
"executor_scheduled_to_self",
"executor_wakeup_initiated",
"executor_queue_drained",
"executor_push_retries",
- "executor_threads_created",
- "executor_threads_used",
"server_requested_calls",
"server_slowpath_requests_queued",
+ "cq_ev_queue_trylock_failures",
+ "cq_ev_queue_trylock_successes",
+ "cq_ev_queue_transient_pop_failures",
};
-const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
+const char* grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"Number of client side calls created by this process",
"Number of server side calls created by this process",
- "Number of completion queues created", "Number of client channels created",
- "Number of client subchannels created", "Number of server channels created",
+ "Number of completion queues created",
+ "Number of client channels created",
+ "Number of client subchannels created",
+ "Number of server channels created",
"Number of polling syscalls (epoll_wait, poll, etc) made by this process",
"Number of sleeping syscalls made by this process",
"How many polling wakeups were performed by the process (only valid for "
@@ -148,7 +156,8 @@ const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"Number of batches containing receive initial metadata",
"Number of batches containing receive message",
"Number of batches containing receive trailing metadata",
- "Number of settings frames sent", "Number of HTTP2 pings sent by process",
+ "Number of settings frames sent",
+ "Number of HTTP2 pings sent by process",
"Number of HTTP2 writes initiated",
"Number of HTTP2 writes offloaded to the executor from application threads",
"Number of HTTP2 writes that finished seeing more data needed to be "
@@ -179,6 +188,7 @@ const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"'transport_flow_control_unstalled'",
"Number of HTTP2 writes initiated due to 'ping_response'",
"Number of HTTP2 writes initiated due to 'force_rst_stream'",
+ "Number of HTTP2 writes initiated with nothing to write",
"Number of HPACK indexed fields received",
"Number of HPACK literal headers received with incremental indexing",
"Number of HPACK literal headers received with incremental indexing and "
@@ -210,6 +220,11 @@ const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"Number of items scheduled against combiner locks",
"Number of final items scheduled against combiner locks",
"Number of combiner locks offloaded to different threads",
+ "Number of call combiner lock entries by process (first items queued to a "
+ "call combiner)",
+ "Number of items scheduled against call combiner locks",
+ "Number of times a cancellation callback was set on a call combiner",
+ "Number of times a call combiner was cancelled",
"Number of finite runtime closures scheduled against the executor (gRPC "
"thread pool)",
"Number of potentially infinite runtime closures scheduled against the "
@@ -219,13 +234,17 @@ const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"Number of times an executor queue was drained",
"Number of times we raced and were forced to retry pushing a closure to "
"the executor",
- "Size of the backing thread pool for overflow gRPC Core work",
- "How many executor threads actually got used",
"How many calls were requested (not necessarily received) by the server",
"How many times was the server slow path taken (indicates too few "
"outstanding requests)",
+ "Number of lock (trylock) acquisition failures on completion queue event "
+ "queue. High value here indicates high contention on completion queues",
+ "Number of lock (trylock) acquisition successes on completion queue event "
+ "queue.",
+ "Number of times NULL was popped out of completion queue's event queue "
+ "even though the event queue was not empty",
};
-const char *grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT] = {
+const char* grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT] = {
"call_initial_size",
"poll_events_returned",
"tcp_write_size",
@@ -238,10 +257,9 @@ const char *grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT] = {
"http2_send_message_per_write",
"http2_send_trailing_metadata_per_write",
"http2_send_flowctl_per_write",
- "executor_closures_per_wakeup",
"server_cqs_checked",
};
-const char *grpc_stats_histogram_doc[GRPC_STATS_HISTOGRAM_COUNT] = {
+const char* grpc_stats_histogram_doc[GRPC_STATS_HISTOGRAM_COUNT] = {
"Initial size of the grpc_call arena created at call start",
"How many events are called for each syscall_poll",
"Number of bytes offered to each syscall_write",
@@ -254,7 +272,6 @@ const char *grpc_stats_histogram_doc[GRPC_STATS_HISTOGRAM_COUNT] = {
"Number of streams whose payload was written per TCP write",
"Number of streams terminated per TCP write",
"Number of flow control updates written per TCP write",
- "Number of closures executed each time an executor wakes up",
"How many completion queues were checked looking for a CQ that had "
"requested the incoming call",
};
@@ -325,12 +342,10 @@ const uint8_t grpc_stats_table_7[102] = {
42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 51};
const int grpc_stats_table_8[9] = {0, 1, 2, 4, 7, 13, 23, 39, 64};
const uint8_t grpc_stats_table_9[9] = {0, 0, 1, 2, 2, 3, 4, 4, 5};
-void grpc_stats_inc_call_initial_size(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_call_initial_size(int value) {
value = GPR_CLAMP(value, 0, 262144);
if (value < 6) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, value);
return;
}
union {
@@ -343,20 +358,17 @@ void grpc_stats_inc_call_initial_size(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_1[((_val.uint - 4618441417868443648ull) >> 49)] + 6;
_bkt.dbl = grpc_stats_table_0[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_0, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_0, 64));
}
-void grpc_stats_inc_poll_events_returned(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_poll_events_returned(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 29) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, value);
return;
}
union {
@@ -369,21 +381,17 @@ void grpc_stats_inc_poll_events_returned(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_3[((_val.uint - 4628855992006737920ull) >> 47)] + 29;
_bkt.dbl = grpc_stats_table_2[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_2, 128));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_2, 128));
}
-void grpc_stats_inc_tcp_write_size(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_tcp_write_size(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, value);
return;
}
union {
@@ -396,20 +404,17 @@ void grpc_stats_inc_tcp_write_size(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_tcp_write_iov_size(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_tcp_write_iov_size(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, value);
return;
}
union {
@@ -422,20 +427,17 @@ void grpc_stats_inc_tcp_write_iov_size(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_tcp_read_size(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_tcp_read_size(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, value);
return;
}
union {
@@ -448,20 +450,17 @@ void grpc_stats_inc_tcp_read_size(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_tcp_read_offer(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_tcp_read_offer(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, value);
return;
}
union {
@@ -474,21 +473,18 @@ void grpc_stats_inc_tcp_read_offer(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_tcp_read_offer_iov_size(grpc_exec_ctx *exec_ctx,
- int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_tcp_read_offer_iov_size(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
+ value);
return;
}
union {
@@ -501,22 +497,19 @@ void grpc_stats_inc_tcp_read_offer_iov_size(grpc_exec_ctx *exec_ctx,
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
+ bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_message_size(grpc_exec_ctx *exec_ctx,
- int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_http2_send_message_size(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
+ value);
return;
}
union {
@@ -529,52 +522,19 @@ void grpc_stats_inc_http2_send_message_size(grpc_exec_ctx *exec_ctx,
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE, bucket);
- return;
- }
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
-}
-void grpc_stats_inc_http2_send_initial_metadata_per_write(
- grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
- value = GPR_CLAMP(value, 0, 1024);
- if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
- value);
- return;
- }
- union {
- double dbl;
- uint64_t uint;
- } _val, _bkt;
- _val.dbl = value;
- if (_val.uint < 4637863191261478912ull) {
- int bucket =
- grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
- _bkt.dbl = grpc_stats_table_6[bucket];
- bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
+ bucket);
return;
}
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
- grpc_stats_histo_find_bucket_slow((exec_ctx), value, grpc_stats_table_6,
- 64));
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_http2_send_message_per_write(grpc_exec_ctx *exec_ctx,
- int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_http2_send_initial_metadata_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE, value);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, value);
return;
}
union {
@@ -588,22 +548,18 @@ void grpc_stats_inc_http2_send_message_per_write(grpc_exec_ctx *exec_ctx,
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE, bucket);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_trailing_metadata_per_write(
- grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_http2_send_message_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
+ value);
return;
}
union {
@@ -616,23 +572,19 @@ void grpc_stats_inc_http2_send_trailing_metadata_per_write(
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
+ bucket);
return;
}
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
- grpc_stats_histo_find_bucket_slow((exec_ctx), value, grpc_stats_table_6,
- 64));
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_flowctl_per_write(grpc_exec_ctx *exec_ctx,
- int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_http2_send_trailing_metadata_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE, value);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, value);
return;
}
union {
@@ -646,21 +598,18 @@ void grpc_stats_inc_http2_send_flowctl_per_write(grpc_exec_ctx *exec_ctx,
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE, bucket);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_executor_closures_per_wakeup(grpc_exec_ctx *exec_ctx,
- int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_http2_send_flowctl_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_EXECUTOR_CLOSURES_PER_WAKEUP, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
+ value);
return;
}
union {
@@ -673,21 +622,18 @@ void grpc_stats_inc_executor_closures_per_wakeup(grpc_exec_ctx *exec_ctx,
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_EXECUTOR_CLOSURES_PER_WAKEUP, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
+ bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_EXECUTOR_CLOSURES_PER_WAKEUP,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_server_cqs_checked(grpc_exec_ctx *exec_ctx, int value) {
- /* Automatically generated by tools/codegen/core/gen_stats_data.py */
+void grpc_stats_inc_server_cqs_checked(int value) {
value = GPR_CLAMP(value, 0, 64);
if (value < 3) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, value);
return;
}
union {
@@ -700,25 +646,24 @@ void grpc_stats_inc_server_cqs_checked(grpc_exec_ctx *exec_ctx, int value) {
grpc_stats_table_9[((_val.uint - 4613937818241073152ull) >> 51)] + 3;
_bkt.dbl = grpc_stats_table_8[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_8, 8));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_8, 8));
}
-const int grpc_stats_histo_buckets[14] = {64, 128, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 8};
-const int grpc_stats_histo_start[14] = {0, 64, 192, 256, 320, 384, 448,
- 512, 576, 640, 704, 768, 832, 896};
-const int *const grpc_stats_histo_bucket_boundaries[14] = {
+const int grpc_stats_histo_buckets[13] = {64, 128, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 8};
+const int grpc_stats_histo_start[13] = {0, 64, 192, 256, 320, 384, 448,
+ 512, 576, 640, 704, 768, 832};
+const int* const grpc_stats_histo_bucket_boundaries[13] = {
grpc_stats_table_0, grpc_stats_table_2, grpc_stats_table_4,
grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_4,
grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_6,
grpc_stats_table_6, grpc_stats_table_6, grpc_stats_table_6,
- grpc_stats_table_6, grpc_stats_table_8};
-void (*const grpc_stats_inc_histogram[14])(grpc_exec_ctx *exec_ctx, int x) = {
+ grpc_stats_table_8};
+void (*const grpc_stats_inc_histogram[13])(int x) = {
grpc_stats_inc_call_initial_size,
grpc_stats_inc_poll_events_returned,
grpc_stats_inc_tcp_write_size,
@@ -731,5 +676,4 @@ void (*const grpc_stats_inc_histogram[14])(grpc_exec_ctx *exec_ctx, int x) = {
grpc_stats_inc_http2_send_message_per_write,
grpc_stats_inc_http2_send_trailing_metadata_per_write,
grpc_stats_inc_http2_send_flowctl_per_write,
- grpc_stats_inc_executor_closures_per_wakeup,
grpc_stats_inc_server_cqs_checked};
diff --git a/src/core/lib/debug/stats_data.h b/src/core/lib/debug/stats_data.h
index 6c0ad30543..4504be33e7 100644
--- a/src/core/lib/debug/stats_data.h
+++ b/src/core/lib/debug/stats_data.h
@@ -79,6 +79,7 @@ typedef enum {
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED,
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE,
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM,
+ GRPC_STATS_COUNTER_HTTP2_SPURIOUS_WRITES_BEGUN,
GRPC_STATS_COUNTER_HPACK_RECV_INDEXED,
GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX,
GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX_V,
@@ -105,20 +106,25 @@ typedef enum {
GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_ITEMS,
GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS,
GRPC_STATS_COUNTER_COMBINER_LOCKS_OFFLOADED,
+ GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_INITIATED,
+ GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS,
+ GRPC_STATS_COUNTER_CALL_COMBINER_SET_NOTIFY_ON_CANCEL,
+ GRPC_STATS_COUNTER_CALL_COMBINER_CANCELLED,
GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_SHORT_ITEMS,
GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_LONG_ITEMS,
GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_TO_SELF,
GRPC_STATS_COUNTER_EXECUTOR_WAKEUP_INITIATED,
GRPC_STATS_COUNTER_EXECUTOR_QUEUE_DRAINED,
GRPC_STATS_COUNTER_EXECUTOR_PUSH_RETRIES,
- GRPC_STATS_COUNTER_EXECUTOR_THREADS_CREATED,
- GRPC_STATS_COUNTER_EXECUTOR_THREADS_USED,
GRPC_STATS_COUNTER_SERVER_REQUESTED_CALLS,
GRPC_STATS_COUNTER_SERVER_SLOWPATH_REQUESTS_QUEUED,
+ GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_FAILURES,
+ GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_SUCCESSES,
+ GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES,
GRPC_STATS_COUNTER_COUNT
} grpc_stats_counters;
-extern const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT];
-extern const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT];
+extern const char* grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT];
+extern const char* grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT];
typedef enum {
GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
@@ -132,12 +138,11 @@ typedef enum {
GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
- GRPC_STATS_HISTOGRAM_EXECUTOR_CLOSURES_PER_WAKEUP,
GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
GRPC_STATS_HISTOGRAM_COUNT
} grpc_stats_histograms;
-extern const char *grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT];
-extern const char *grpc_stats_histogram_doc[GRPC_STATS_HISTOGRAM_COUNT];
+extern const char* grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT];
+extern const char* grpc_stats_histogram_doc[GRPC_STATS_HISTOGRAM_COUNT];
typedef enum {
GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE_FIRST_SLOT = 0,
GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE_BUCKETS = 64,
@@ -163,322 +168,266 @@ typedef enum {
GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE_BUCKETS = 64,
GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE_FIRST_SLOT = 768,
GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE_BUCKETS = 64,
- GRPC_STATS_HISTOGRAM_EXECUTOR_CLOSURES_PER_WAKEUP_FIRST_SLOT = 832,
- GRPC_STATS_HISTOGRAM_EXECUTOR_CLOSURES_PER_WAKEUP_BUCKETS = 64,
- GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED_FIRST_SLOT = 896,
+ GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED_FIRST_SLOT = 832,
GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED_BUCKETS = 8,
- GRPC_STATS_HISTOGRAM_BUCKETS = 904
+ GRPC_STATS_HISTOGRAM_BUCKETS = 840
} grpc_stats_histogram_constants;
-#define GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED)
-#define GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CALLS_CREATED)
-#define GRPC_STATS_INC_CQS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CQS_CREATED)
-#define GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CHANNELS_CREATED)
-#define GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_CLIENT_SUBCHANNELS_CREATED)
-#define GRPC_STATS_INC_SERVER_CHANNELS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CHANNELS_CREATED)
-#define GRPC_STATS_INC_SYSCALL_POLL(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_POLL)
-#define GRPC_STATS_INC_SYSCALL_WAIT(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WAIT)
-#define GRPC_STATS_INC_POLLSET_KICK(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK)
-#define GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_POLLSET_KICKED_WITHOUT_POLLER)
-#define GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICKED_AGAIN)
-#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_FD)
-#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_CV)
-#define GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK_OWN_THREAD)
-#define GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS)
-#define GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WRITE)
-#define GRPC_STATS_INC_SYSCALL_READ(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_READ)
-#define GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_TCP_BACKUP_POLLERS_CREATED)
-#define GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_TCP_BACKUP_POLLER_POLLS)
-#define GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_BATCHES)
-#define GRPC_STATS_INC_HTTP2_OP_CANCEL(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_CANCEL)
-#define GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_SEND_INITIAL_METADATA)
-#define GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_SEND_MESSAGE)
-#define GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_SEND_TRAILING_METADATA)
-#define GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_RECV_INITIAL_METADATA)
-#define GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_RECV_MESSAGE)
-#define GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_RECV_TRAILING_METADATA)
-#define GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_SETTINGS_WRITES)
-#define GRPC_STATS_INC_HTTP2_PINGS_SENT(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_PINGS_SENT)
-#define GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_WRITES_BEGUN)
-#define GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_WRITES_OFFLOADED)
-#define GRPC_STATS_INC_HTTP2_WRITES_CONTINUED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_WRITES_CONTINUED)
-#define GRPC_STATS_INC_HTTP2_PARTIAL_WRITES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_PARTIAL_WRITES)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_CLIENT_CALLS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED)
+#define GRPC_STATS_INC_SERVER_CALLS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_CALLS_CREATED)
+#define GRPC_STATS_INC_CQS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQS_CREATED)
+#define GRPC_STATS_INC_CLIENT_CHANNELS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CLIENT_CHANNELS_CREATED)
+#define GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CLIENT_SUBCHANNELS_CREATED)
+#define GRPC_STATS_INC_SERVER_CHANNELS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_CHANNELS_CREATED)
+#define GRPC_STATS_INC_SYSCALL_POLL() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_POLL)
+#define GRPC_STATS_INC_SYSCALL_WAIT() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_WAIT)
+#define GRPC_STATS_INC_POLLSET_KICK() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK)
+#define GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICKED_WITHOUT_POLLER)
+#define GRPC_STATS_INC_POLLSET_KICKED_AGAIN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICKED_AGAIN)
+#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_FD)
+#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_CV)
+#define GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK_OWN_THREAD)
+#define GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS)
+#define GRPC_STATS_INC_SYSCALL_WRITE() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_WRITE)
+#define GRPC_STATS_INC_SYSCALL_READ() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_READ)
+#define GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_TCP_BACKUP_POLLERS_CREATED)
+#define GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_TCP_BACKUP_POLLER_POLLS)
+#define GRPC_STATS_INC_HTTP2_OP_BATCHES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_BATCHES)
+#define GRPC_STATS_INC_HTTP2_OP_CANCEL() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_CANCEL)
+#define GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_SEND_INITIAL_METADATA)
+#define GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_SEND_MESSAGE)
+#define GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_SEND_TRAILING_METADATA)
+#define GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_RECV_INITIAL_METADATA)
+#define GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_RECV_MESSAGE)
+#define GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_RECV_TRAILING_METADATA)
+#define GRPC_STATS_INC_HTTP2_SETTINGS_WRITES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_SETTINGS_WRITES)
+#define GRPC_STATS_INC_HTTP2_PINGS_SENT() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_PINGS_SENT)
+#define GRPC_STATS_INC_HTTP2_WRITES_BEGUN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_WRITES_BEGUN)
+#define GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_WRITES_OFFLOADED)
+#define GRPC_STATS_INC_HTTP2_WRITES_CONTINUED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_WRITES_CONTINUED)
+#define GRPC_STATS_INC_HTTP2_PARTIAL_WRITES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_PARTIAL_WRITES)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA( \
- exec_ctx) \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA() \
GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM)
-#define GRPC_STATS_INC_HPACK_RECV_INDEXED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_INDEXED)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX_V)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX_V)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX_V)
-#define GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_UNCOMPRESSED)
-#define GRPC_STATS_INC_HPACK_RECV_HUFFMAN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_HUFFMAN)
-#define GRPC_STATS_INC_HPACK_RECV_BINARY(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_BINARY)
-#define GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_BINARY_BASE64)
-#define GRPC_STATS_INC_HPACK_SEND_INDEXED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_INDEXED)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX_V)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX_V)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX_V)
-#define GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_UNCOMPRESSED)
-#define GRPC_STATS_INC_HPACK_SEND_HUFFMAN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_HUFFMAN)
-#define GRPC_STATS_INC_HPACK_SEND_BINARY(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_BINARY)
-#define GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_BINARY_BASE64)
-#define GRPC_STATS_INC_COMBINER_LOCKS_INITIATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_COMBINER_LOCKS_INITIATED)
-#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_ITEMS)
-#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS(exec_ctx) \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM() \
GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS)
-#define GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_COMBINER_LOCKS_OFFLOADED)
-#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_SHORT_ITEMS)
-#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_LONG_ITEMS)
-#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_TO_SELF)
-#define GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_WAKEUP_INITIATED)
-#define GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_EXECUTOR_QUEUE_DRAINED)
-#define GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_EXECUTOR_PUSH_RETRIES)
-#define GRPC_STATS_INC_EXECUTOR_THREADS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_THREADS_CREATED)
-#define GRPC_STATS_INC_EXECUTOR_THREADS_USED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_EXECUTOR_THREADS_USED)
-#define GRPC_STATS_INC_SERVER_REQUESTED_CALLS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_REQUESTED_CALLS)
-#define GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_SERVER_SLOWPATH_REQUESTS_QUEUED)
-#define GRPC_STATS_INC_CALL_INITIAL_SIZE(exec_ctx, value) \
- grpc_stats_inc_call_initial_size((exec_ctx), (int)(value))
-void grpc_stats_inc_call_initial_size(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_POLL_EVENTS_RETURNED(exec_ctx, value) \
- grpc_stats_inc_poll_events_returned((exec_ctx), (int)(value))
-void grpc_stats_inc_poll_events_returned(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_write_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_write_size(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_write_iov_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_write_iov_size(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_read_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_read_size(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_READ_OFFER(exec_ctx, value) \
- grpc_stats_inc_tcp_read_offer((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_read_offer(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_read_offer_iov_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_read_offer_iov_size(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE(exec_ctx, value) \
- grpc_stats_inc_http2_send_message_size((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_message_size(grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_initial_metadata_per_write((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_initial_metadata_per_write(
- grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_message_per_write((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_message_per_write(grpc_exec_ctx *exec_ctx,
- int x);
-#define GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_trailing_metadata_per_write((exec_ctx), \
- (int)(value))
-void grpc_stats_inc_http2_send_trailing_metadata_per_write(
- grpc_exec_ctx *exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_flowctl_per_write((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_flowctl_per_write(grpc_exec_ctx *exec_ctx,
- int x);
-#define GRPC_STATS_INC_EXECUTOR_CLOSURES_PER_WAKEUP(exec_ctx, value) \
- grpc_stats_inc_executor_closures_per_wakeup((exec_ctx), (int)(value))
-void grpc_stats_inc_executor_closures_per_wakeup(grpc_exec_ctx *exec_ctx,
- int x);
-#define GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, value) \
- grpc_stats_inc_server_cqs_checked((exec_ctx), (int)(value))
-void grpc_stats_inc_server_cqs_checked(grpc_exec_ctx *exec_ctx, int x);
-extern const int grpc_stats_histo_buckets[14];
-extern const int grpc_stats_histo_start[14];
-extern const int *const grpc_stats_histo_bucket_boundaries[14];
-extern void (*const grpc_stats_inc_histogram[14])(grpc_exec_ctx *exec_ctx,
- int x);
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM)
+#define GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_SPURIOUS_WRITES_BEGUN)
+#define GRPC_STATS_INC_HPACK_RECV_INDEXED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_INDEXED)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX_V)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX_V)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX_V)
+#define GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_UNCOMPRESSED)
+#define GRPC_STATS_INC_HPACK_RECV_HUFFMAN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_HUFFMAN)
+#define GRPC_STATS_INC_HPACK_RECV_BINARY() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_BINARY)
+#define GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_BINARY_BASE64)
+#define GRPC_STATS_INC_HPACK_SEND_INDEXED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_INDEXED)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX_V)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX_V)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX_V)
+#define GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_UNCOMPRESSED)
+#define GRPC_STATS_INC_HPACK_SEND_HUFFMAN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_HUFFMAN)
+#define GRPC_STATS_INC_HPACK_SEND_BINARY() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_BINARY)
+#define GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_BINARY_BASE64)
+#define GRPC_STATS_INC_COMBINER_LOCKS_INITIATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_COMBINER_LOCKS_INITIATED)
+#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_ITEMS)
+#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS)
+#define GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_COMBINER_LOCKS_OFFLOADED)
+#define GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_INITIATED)
+#define GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS)
+#define GRPC_STATS_INC_CALL_COMBINER_SET_NOTIFY_ON_CANCEL() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_SET_NOTIFY_ON_CANCEL)
+#define GRPC_STATS_INC_CALL_COMBINER_CANCELLED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_CANCELLED)
+#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_SHORT_ITEMS)
+#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_LONG_ITEMS)
+#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_TO_SELF)
+#define GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_WAKEUP_INITIATED)
+#define GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_QUEUE_DRAINED)
+#define GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_PUSH_RETRIES)
+#define GRPC_STATS_INC_SERVER_REQUESTED_CALLS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_REQUESTED_CALLS)
+#define GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_SLOWPATH_REQUESTS_QUEUED)
+#define GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_FAILURES)
+#define GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_SUCCESSES)
+#define GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES)
+#define GRPC_STATS_INC_CALL_INITIAL_SIZE(value) \
+ grpc_stats_inc_call_initial_size((int)(value))
+void grpc_stats_inc_call_initial_size(int x);
+#define GRPC_STATS_INC_POLL_EVENTS_RETURNED(value) \
+ grpc_stats_inc_poll_events_returned((int)(value))
+void grpc_stats_inc_poll_events_returned(int x);
+#define GRPC_STATS_INC_TCP_WRITE_SIZE(value) \
+ grpc_stats_inc_tcp_write_size((int)(value))
+void grpc_stats_inc_tcp_write_size(int x);
+#define GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(value) \
+ grpc_stats_inc_tcp_write_iov_size((int)(value))
+void grpc_stats_inc_tcp_write_iov_size(int x);
+#define GRPC_STATS_INC_TCP_READ_SIZE(value) \
+ grpc_stats_inc_tcp_read_size((int)(value))
+void grpc_stats_inc_tcp_read_size(int x);
+#define GRPC_STATS_INC_TCP_READ_OFFER(value) \
+ grpc_stats_inc_tcp_read_offer((int)(value))
+void grpc_stats_inc_tcp_read_offer(int x);
+#define GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(value) \
+ grpc_stats_inc_tcp_read_offer_iov_size((int)(value))
+void grpc_stats_inc_tcp_read_offer_iov_size(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE(value) \
+ grpc_stats_inc_http2_send_message_size((int)(value))
+void grpc_stats_inc_http2_send_message_size(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_initial_metadata_per_write((int)(value))
+void grpc_stats_inc_http2_send_initial_metadata_per_write(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_message_per_write((int)(value))
+void grpc_stats_inc_http2_send_message_per_write(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_trailing_metadata_per_write((int)(value))
+void grpc_stats_inc_http2_send_trailing_metadata_per_write(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_flowctl_per_write((int)(value))
+void grpc_stats_inc_http2_send_flowctl_per_write(int x);
+#define GRPC_STATS_INC_SERVER_CQS_CHECKED(value) \
+ grpc_stats_inc_server_cqs_checked((int)(value))
+void grpc_stats_inc_server_cqs_checked(int x);
+extern const int grpc_stats_histo_buckets[13];
+extern const int grpc_stats_histo_start[13];
+extern const int* const grpc_stats_histo_bucket_boundaries[13];
+extern void (*const grpc_stats_inc_histogram[13])(int x);
#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */
diff --git a/src/core/lib/debug/stats_data.yaml b/src/core/lib/debug/stats_data.yaml
index de575f01c7..af4553028e 100644
--- a/src/core/lib/debug/stats_data.yaml
+++ b/src/core/lib/debug/stats_data.yaml
@@ -189,6 +189,8 @@
doc: Number of HTTP2 writes initiated due to 'ping_response'
- counter: http2_initiate_write_due_to_force_rst_stream
doc: Number of HTTP2 writes initiated due to 'force_rst_stream'
+- counter: http2_spurious_writes_begun
+ doc: Number of HTTP2 writes initiated with nothing to write
- counter: hpack_recv_indexed
doc: Number of HPACK indexed fields received
- counter: hpack_recv_lithdr_incidx
@@ -243,6 +245,16 @@
doc: Number of final items scheduled against combiner locks
- counter: combiner_locks_offloaded
doc: Number of combiner locks offloaded to different threads
+# call combiner locks
+- counter: call_combiner_locks_initiated
+ doc: Number of call combiner lock entries by process
+ (first items queued to a call combiner)
+- counter: call_combiner_locks_scheduled_items
+ doc: Number of items scheduled against call combiner locks
+- counter: call_combiner_set_notify_on_cancel
+ doc: Number of times a cancellation callback was set on a call combiner
+- counter: call_combiner_cancelled
+ doc: Number of times a call combiner was cancelled
# executor
- counter: executor_scheduled_short_items
doc: Number of finite runtime closures scheduled against the executor
@@ -259,14 +271,6 @@
- counter: executor_push_retries
doc: Number of times we raced and were forced to retry pushing a closure to
the executor
-- counter: executor_threads_created
- doc: Size of the backing thread pool for overflow gRPC Core work
-- counter: executor_threads_used
- doc: How many executor threads actually got used
-- histogram: executor_closures_per_wakeup
- max: 1024
- buckets: 64
- doc: Number of closures executed each time an executor wakes up
# server
- counter: server_requested_calls
doc: How many calls were requested (not necessarily received) by the server
@@ -278,3 +282,13 @@
- counter: server_slowpath_requests_queued
doc: How many times was the server slow path taken (indicates too few
outstanding requests)
+# cq
+- counter: cq_ev_queue_trylock_failures
+ doc: Number of lock (trylock) acquisition failures on completion queue event
+ queue. High value here indicates high contention on completion queues
+- counter: cq_ev_queue_trylock_successes
+ doc: Number of lock (trylock) acquisition successes on completion queue event
+ queue.
+- counter: cq_ev_queue_transient_pop_failures
+ doc: Number of times NULL was popped out of completion queue's event queue
+ even though the event queue was not empty
diff --git a/src/core/lib/debug/stats_data_bq_schema.sql b/src/core/lib/debug/stats_data_bq_schema.sql
index 0611ccaff0..04b6d471f6 100644
--- a/src/core/lib/debug/stats_data_bq_schema.sql
+++ b/src/core/lib/debug/stats_data_bq_schema.sql
@@ -52,6 +52,7 @@ http2_initiate_write_due_to_keepalive_ping_per_iteration:FLOAT,
http2_initiate_write_due_to_transport_flow_control_unstalled_per_iteration:FLOAT,
http2_initiate_write_due_to_ping_response_per_iteration:FLOAT,
http2_initiate_write_due_to_force_rst_stream_per_iteration:FLOAT,
+http2_spurious_writes_begun_per_iteration:FLOAT,
hpack_recv_indexed_per_iteration:FLOAT,
hpack_recv_lithdr_incidx_per_iteration:FLOAT,
hpack_recv_lithdr_incidx_v_per_iteration:FLOAT,
@@ -78,13 +79,18 @@ combiner_locks_initiated_per_iteration:FLOAT,
combiner_locks_scheduled_items_per_iteration:FLOAT,
combiner_locks_scheduled_final_items_per_iteration:FLOAT,
combiner_locks_offloaded_per_iteration:FLOAT,
+call_combiner_locks_initiated_per_iteration:FLOAT,
+call_combiner_locks_scheduled_items_per_iteration:FLOAT,
+call_combiner_set_notify_on_cancel_per_iteration:FLOAT,
+call_combiner_cancelled_per_iteration:FLOAT,
executor_scheduled_short_items_per_iteration:FLOAT,
executor_scheduled_long_items_per_iteration:FLOAT,
executor_scheduled_to_self_per_iteration:FLOAT,
executor_wakeup_initiated_per_iteration:FLOAT,
executor_queue_drained_per_iteration:FLOAT,
executor_push_retries_per_iteration:FLOAT,
-executor_threads_created_per_iteration:FLOAT,
-executor_threads_used_per_iteration:FLOAT,
server_requested_calls_per_iteration:FLOAT,
-server_slowpath_requests_queued_per_iteration:FLOAT
+server_slowpath_requests_queued_per_iteration:FLOAT,
+cq_ev_queue_trylock_failures_per_iteration:FLOAT,
+cq_ev_queue_trylock_successes_per_iteration:FLOAT,
+cq_ev_queue_transient_pop_failures_per_iteration:FLOAT
diff --git a/src/core/lib/debug/trace.c b/src/core/lib/debug/trace.c
deleted file mode 100644
index 7cb2789a19..0000000000
--- a/src/core/lib/debug/trace.c
+++ /dev/null
@@ -1,146 +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/debug/trace.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
-
-int grpc_tracer_set_enabled(const char *name, int enabled);
-
-typedef struct tracer {
- grpc_tracer_flag *flag;
- struct tracer *next;
-} tracer;
-static tracer *tracers;
-
-#ifdef GRPC_THREADSAFE_TRACER
-#define TRACER_SET(flag, on) gpr_atm_no_barrier_store(&(flag).value, (on))
-#else
-#define TRACER_SET(flag, on) (flag).value = (on)
-#endif
-
-void grpc_register_tracer(grpc_tracer_flag *flag) {
- tracer *t = (tracer *)gpr_malloc(sizeof(*t));
- t->flag = flag;
- t->next = tracers;
- TRACER_SET(*flag, false);
- tracers = t;
-}
-
-static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
- size_t n = *ns;
- size_t np = n + 1;
- char *s;
- size_t len;
- GPR_ASSERT(end >= beg);
- len = (size_t)(end - beg);
- s = (char *)gpr_malloc(len + 1);
- memcpy(s, beg, len);
- s[len] = 0;
- *ss = (char **)gpr_realloc(*ss, sizeof(char **) * np);
- (*ss)[n] = s;
- *ns = np;
-}
-
-static void split(const char *s, char ***ss, size_t *ns) {
- const char *c = strchr(s, ',');
- if (c == NULL) {
- add(s, s + strlen(s), ss, ns);
- } else {
- add(s, c, ss, ns);
- split(c + 1, ss, ns);
- }
-}
-
-static void parse(const char *s) {
- char **strings = NULL;
- size_t nstrings = 0;
- size_t i;
- split(s, &strings, &nstrings);
-
- for (i = 0; i < nstrings; i++) {
- if (strings[i][0] == '-') {
- grpc_tracer_set_enabled(strings[i] + 1, 0);
- } else {
- grpc_tracer_set_enabled(strings[i], 1);
- }
- }
-
- for (i = 0; i < nstrings; i++) {
- gpr_free(strings[i]);
- }
- gpr_free(strings);
-}
-
-static void list_tracers() {
- gpr_log(GPR_DEBUG, "available tracers:");
- tracer *t;
- for (t = tracers; t; t = t->next) {
- gpr_log(GPR_DEBUG, "\t%s", t->flag->name);
- }
-}
-
-void grpc_tracer_init(const char *env_var) {
- char *e = gpr_getenv(env_var);
- if (e != NULL) {
- parse(e);
- gpr_free(e);
- }
-}
-
-void grpc_tracer_shutdown(void) {
- while (tracers) {
- tracer *t = tracers;
- tracers = t->next;
- gpr_free(t);
- }
-}
-
-int grpc_tracer_set_enabled(const char *name, int enabled) {
- tracer *t;
- if (0 == strcmp(name, "all")) {
- for (t = tracers; t; t = t->next) {
- TRACER_SET(*t->flag, enabled);
- }
- } else if (0 == strcmp(name, "list_tracers")) {
- list_tracers();
- } else if (0 == strcmp(name, "refcount")) {
- for (t = tracers; t; t = t->next) {
- if (strstr(t->flag->name, "refcount") != NULL) {
- TRACER_SET(*t->flag, enabled);
- }
- }
- } else {
- int found = 0;
- for (t = tracers; t; t = t->next) {
- if (0 == strcmp(name, t->flag->name)) {
- TRACER_SET(*t->flag, enabled);
- found = 1;
- }
- }
- if (!found) {
- gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
- return 0; /* early return */
- }
- }
- return 1;
-}
diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc
new file mode 100644
index 0000000000..d870bbc5e7
--- /dev/null
+++ b/src/core/lib/debug/trace.cc
@@ -0,0 +1,142 @@
+/*
+ *
+ * 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/debug/trace.h"
+
+#include <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include "src/core/lib/gpr/env.h"
+
+int grpc_tracer_set_enabled(const char* name, int enabled);
+
+namespace grpc_core {
+
+TraceFlag* TraceFlagList::root_tracer_ = nullptr;
+
+bool TraceFlagList::Set(const char* name, bool enabled) {
+ TraceFlag* t;
+ if (0 == strcmp(name, "all")) {
+ for (t = root_tracer_; t; t = t->next_tracer_) {
+ t->set_enabled(enabled);
+ }
+ } else if (0 == strcmp(name, "list_tracers")) {
+ LogAllTracers();
+ } else if (0 == strcmp(name, "refcount")) {
+ for (t = root_tracer_; t; t = t->next_tracer_) {
+ if (strstr(t->name_, "refcount") != nullptr) {
+ t->set_enabled(enabled);
+ }
+ }
+ } else {
+ bool found = false;
+ for (t = root_tracer_; t; t = t->next_tracer_) {
+ if (0 == strcmp(name, t->name_)) {
+ t->set_enabled(enabled);
+ found = true;
+ }
+ }
+ if (!found) {
+ gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
+ return false; /* early return */
+ }
+ }
+ return true;
+}
+
+void TraceFlagList::Add(TraceFlag* flag) {
+ flag->next_tracer_ = root_tracer_;
+ root_tracer_ = flag;
+}
+
+void TraceFlagList::LogAllTracers() {
+ gpr_log(GPR_DEBUG, "available tracers:");
+ TraceFlag* t;
+ for (t = root_tracer_; t != nullptr; t = t->next_tracer_) {
+ gpr_log(GPR_DEBUG, "\t%s", t->name_);
+ }
+}
+
+// Flags register themselves on the list during construction
+TraceFlag::TraceFlag(bool default_enabled, const char* name) : name_(name) {
+ set_enabled(default_enabled);
+ TraceFlagList::Add(this);
+}
+
+} // namespace grpc_core
+
+static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
+ size_t n = *ns;
+ size_t np = n + 1;
+ char* s;
+ size_t len;
+ GPR_ASSERT(end >= beg);
+ len = (size_t)(end - beg);
+ s = (char*)gpr_malloc(len + 1);
+ memcpy(s, beg, len);
+ s[len] = 0;
+ *ss = (char**)gpr_realloc(*ss, sizeof(char**) * np);
+ (*ss)[n] = s;
+ *ns = np;
+}
+
+static void split(const char* s, char*** ss, size_t* ns) {
+ const char* c = strchr(s, ',');
+ if (c == nullptr) {
+ add(s, s + strlen(s), ss, ns);
+ } else {
+ add(s, c, ss, ns);
+ split(c + 1, ss, ns);
+ }
+}
+
+static void parse(const char* s) {
+ char** strings = nullptr;
+ size_t nstrings = 0;
+ size_t i;
+ split(s, &strings, &nstrings);
+
+ for (i = 0; i < nstrings; i++) {
+ if (strings[i][0] == '-') {
+ grpc_core::TraceFlagList::Set(strings[i] + 1, false);
+ } else {
+ grpc_core::TraceFlagList::Set(strings[i], true);
+ }
+ }
+
+ for (i = 0; i < nstrings; i++) {
+ gpr_free(strings[i]);
+ }
+ gpr_free(strings);
+}
+
+void grpc_tracer_init(const char* env_var) {
+ char* e = gpr_getenv(env_var);
+ if (e != nullptr) {
+ parse(e);
+ gpr_free(e);
+ }
+}
+
+void grpc_tracer_shutdown(void) {}
+
+int grpc_tracer_set_enabled(const char* name, int enabled) {
+ return grpc_core::TraceFlagList::Set(name, enabled != 0);
+}
diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h
index 64f2e3fc33..69ddd80222 100644
--- a/src/core/lib/debug/trace.h
+++ b/src/core/lib/debug/trace.h
@@ -23,33 +23,81 @@
#include <grpc/support/port_platform.h>
#include <stdbool.h>
+void grpc_tracer_init(const char* env_var_name);
+void grpc_tracer_shutdown(void);
+
#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
#define GRPC_THREADSAFE_TRACER
#endif
#endif
-typedef struct {
+namespace grpc_core {
+
+class TraceFlag;
+class TraceFlagList {
+ public:
+ static bool Set(const char* name, bool enabled);
+ static void Add(TraceFlag* flag);
+
+ private:
+ static void LogAllTracers();
+ static TraceFlag* root_tracer_;
+};
+
+namespace testing {
+void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag);
+}
+
+class TraceFlag {
+ public:
+ TraceFlag(bool default_enabled, const char* name);
+ ~TraceFlag() {}
+
+ const char* name() const { return name_; }
+
+ bool enabled() {
+#ifdef GRPC_THREADSAFE_TRACER
+ return gpr_atm_no_barrier_load(&value_) != 0;
+#else
+ return value_;
+#endif
+ }
+
+ private:
+ friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag);
+ friend class TraceFlagList;
+
+ void set_enabled(bool enabled) {
#ifdef GRPC_THREADSAFE_TRACER
- gpr_atm value;
+ gpr_atm_no_barrier_store(&value_, enabled);
#else
- bool value;
+ value_ = enabled;
#endif
- const char *name;
-} grpc_tracer_flag;
+ }
+ TraceFlag* next_tracer_;
+ const char* const name_;
#ifdef GRPC_THREADSAFE_TRACER
-#define GRPC_TRACER_ON(flag) (gpr_atm_no_barrier_load(&(flag).value) != 0)
-#define GRPC_TRACER_INITIALIZER(on, name) \
- { (gpr_atm)(on), (name) }
+ gpr_atm value_;
#else
-#define GRPC_TRACER_ON(flag) ((flag).value)
-#define GRPC_TRACER_INITIALIZER(on, name) \
- { (on), (name) }
+ bool value_;
#endif
+};
-void grpc_register_tracer(grpc_tracer_flag *flag);
-void grpc_tracer_init(const char *env_var_name);
-void grpc_tracer_shutdown(void);
+#ifndef NDEBUG
+typedef TraceFlag DebugOnlyTraceFlag;
+#else
+class DebugOnlyTraceFlag {
+ public:
+ DebugOnlyTraceFlag(bool default_enabled, const char* name) {}
+ bool enabled() { return false; }
+
+ private:
+ void set_enabled(bool enabled) {}
+};
+#endif
+
+} // namespace grpc_core
#endif /* GRPC_CORE_LIB_DEBUG_TRACE_H */
diff --git a/src/core/lib/gpr/README.md b/src/core/lib/gpr/README.md
new file mode 100644
index 0000000000..21fb0c796d
--- /dev/null
+++ b/src/core/lib/gpr/README.md
@@ -0,0 +1,8 @@
+# GPR - Google Portable Runtime for C
+
+The files in this directory contain basic utility code and platform
+abstractions for C code. None of this code is gRPC-specific; anything
+here may also be useful for other open source projects written in C.
+
+Note that this is one of the few places in src/core where we allow
+the use of portability macros.
diff --git a/src/core/lib/support/alloc.c b/src/core/lib/gpr/alloc.cc
index 886d69d64c..000b7dcb25 100644
--- a/src/core/lib/support/alloc.c
+++ b/src/core/lib/gpr/alloc.cc
@@ -24,10 +24,10 @@
#include <string.h>
#include "src/core/lib/profiling/timers.h"
-static void *zalloc_with_calloc(size_t sz) { return calloc(sz, 1); }
+static void* zalloc_with_calloc(size_t sz) { return calloc(sz, 1); }
-static void *zalloc_with_gpr_malloc(size_t sz) {
- void *p = gpr_malloc(sz);
+static void* zalloc_with_gpr_malloc(size_t sz) {
+ void* p = gpr_malloc(sz);
memset(p, 0, sz);
return p;
}
@@ -40,18 +40,18 @@ gpr_allocation_functions gpr_get_allocation_functions() {
}
void gpr_set_allocation_functions(gpr_allocation_functions functions) {
- GPR_ASSERT(functions.malloc_fn != NULL);
- GPR_ASSERT(functions.realloc_fn != NULL);
- GPR_ASSERT(functions.free_fn != NULL);
- if (functions.zalloc_fn == NULL) {
+ GPR_ASSERT(functions.malloc_fn != nullptr);
+ GPR_ASSERT(functions.realloc_fn != nullptr);
+ GPR_ASSERT(functions.free_fn != nullptr);
+ if (functions.zalloc_fn == nullptr) {
functions.zalloc_fn = zalloc_with_gpr_malloc;
}
g_alloc_functions = functions;
}
-void *gpr_malloc(size_t size) {
- void *p;
- if (size == 0) return NULL;
+void* gpr_malloc(size_t size) {
+ void* p;
+ if (size == 0) return nullptr;
GPR_TIMER_BEGIN("gpr_malloc", 0);
p = g_alloc_functions.malloc_fn(size);
if (!p) {
@@ -61,9 +61,9 @@ void *gpr_malloc(size_t size) {
return p;
}
-void *gpr_zalloc(size_t size) {
- void *p;
- if (size == 0) return NULL;
+void* gpr_zalloc(size_t size) {
+ void* p;
+ if (size == 0) return nullptr;
GPR_TIMER_BEGIN("gpr_zalloc", 0);
p = g_alloc_functions.zalloc_fn(size);
if (!p) {
@@ -73,14 +73,14 @@ void *gpr_zalloc(size_t size) {
return p;
}
-void gpr_free(void *p) {
+void gpr_free(void* p) {
GPR_TIMER_BEGIN("gpr_free", 0);
g_alloc_functions.free_fn(p);
GPR_TIMER_END("gpr_free", 0);
}
-void *gpr_realloc(void *p, size_t size) {
- if ((size == 0) && (p == NULL)) return NULL;
+void* gpr_realloc(void* p, size_t size) {
+ if ((size == 0) && (p == nullptr)) return nullptr;
GPR_TIMER_BEGIN("gpr_realloc", 0);
p = g_alloc_functions.realloc_fn(p, size);
if (!p) {
@@ -90,13 +90,13 @@ void *gpr_realloc(void *p, size_t size) {
return p;
}
-void *gpr_malloc_aligned(size_t size, size_t alignment_log) {
- size_t alignment = ((size_t)1) << alignment_log;
- size_t extra = alignment - 1 + sizeof(void *);
- void *p = gpr_malloc(size + extra);
- void **ret = (void **)(((uintptr_t)p + extra) & ~(alignment - 1));
+void* gpr_malloc_aligned(size_t size, size_t alignment) {
+ GPR_ASSERT(((alignment - 1) & alignment) == 0); // Must be power of 2.
+ size_t extra = alignment - 1 + sizeof(void*);
+ void* p = gpr_malloc(size + extra);
+ void** ret = (void**)(((uintptr_t)p + extra) & ~(alignment - 1));
ret[-1] = p;
- return (void *)ret;
+ return (void*)ret;
}
-void gpr_free_aligned(void *ptr) { gpr_free(((void **)ptr)[-1]); }
+void gpr_free_aligned(void* ptr) { gpr_free(((void**)ptr)[-1]); }
diff --git a/src/core/lib/support/arena.c b/src/core/lib/gpr/arena.cc
index 9e0f73ae3d..687592a140 100644
--- a/src/core/lib/support/arena.c
+++ b/src/core/lib/gpr/arena.cc
@@ -16,12 +16,20 @@
*
*/
-#include "src/core/lib/support/arena.h"
+#include "src/core/lib/gpr/arena.h"
+
+#include <string.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
+// 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
+// arena API to C++, we should consider replacing gpr_arena_alloc() with a
+// template that takes the type of the value being allocated, which
+// would allow us to use the alignment actually needed by the caller.
#define ROUND_UP_TO_ALIGNMENT_SIZE(x) \
(((x) + GPR_MAX_ALIGNMENT - 1u) & ~(GPR_MAX_ALIGNMENT - 1u))
@@ -36,40 +44,48 @@ struct gpr_arena {
zone initial_zone;
};
-gpr_arena *gpr_arena_create(size_t initial_size) {
+static void* zalloc_aligned(size_t size) {
+ void* ptr = gpr_malloc_aligned(size, GPR_MAX_ALIGNMENT);
+ memset(ptr, 0, size);
+ return ptr;
+}
+
+gpr_arena* gpr_arena_create(size_t initial_size) {
initial_size = ROUND_UP_TO_ALIGNMENT_SIZE(initial_size);
- gpr_arena *a = (gpr_arena *)gpr_zalloc(sizeof(gpr_arena) + initial_size);
+ gpr_arena* a = (gpr_arena*)zalloc_aligned(
+ ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(gpr_arena)) + initial_size);
a->initial_zone.size_end = initial_size;
return a;
}
-size_t gpr_arena_destroy(gpr_arena *arena) {
+size_t gpr_arena_destroy(gpr_arena* arena) {
gpr_atm size = gpr_atm_no_barrier_load(&arena->size_so_far);
- zone *z = (zone *)gpr_atm_no_barrier_load(&arena->initial_zone.next_atm);
- gpr_free(arena);
+ zone* z = (zone*)gpr_atm_no_barrier_load(&arena->initial_zone.next_atm);
+ gpr_free_aligned(arena);
while (z) {
- zone *next_z = (zone *)gpr_atm_no_barrier_load(&z->next_atm);
- gpr_free(z);
+ zone* next_z = (zone*)gpr_atm_no_barrier_load(&z->next_atm);
+ gpr_free_aligned(z);
z = next_z;
}
return (size_t)size;
}
-void *gpr_arena_alloc(gpr_arena *arena, size_t size) {
+void* gpr_arena_alloc(gpr_arena* arena, size_t size) {
size = ROUND_UP_TO_ALIGNMENT_SIZE(size);
size_t start =
(size_t)gpr_atm_no_barrier_fetch_add(&arena->size_so_far, size);
- zone *z = &arena->initial_zone;
+ zone* z = &arena->initial_zone;
while (start > z->size_end) {
- zone *next_z = (zone *)gpr_atm_acq_load(&z->next_atm);
- if (next_z == NULL) {
+ zone* next_z = (zone*)gpr_atm_acq_load(&z->next_atm);
+ if (next_z == nullptr) {
size_t next_z_size = (size_t)gpr_atm_no_barrier_load(&arena->size_so_far);
- next_z = (zone *)gpr_zalloc(sizeof(zone) + next_z_size);
+ next_z = (zone*)zalloc_aligned(ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(zone)) +
+ next_z_size);
next_z->size_begin = z->size_end;
next_z->size_end = z->size_end + next_z_size;
if (!gpr_atm_rel_cas(&z->next_atm, (gpr_atm)NULL, (gpr_atm)next_z)) {
- gpr_free(next_z);
- next_z = (zone *)gpr_atm_acq_load(&z->next_atm);
+ gpr_free_aligned(next_z);
+ next_z = (zone*)gpr_atm_acq_load(&z->next_atm);
}
}
z = next_z;
@@ -79,5 +95,8 @@ void *gpr_arena_alloc(gpr_arena *arena, size_t size) {
}
GPR_ASSERT(start >= z->size_begin);
GPR_ASSERT(start + size <= z->size_end);
- return ((char *)(z + 1)) + start - z->size_begin;
+ char* ptr = (z == &arena->initial_zone)
+ ? (char*)arena + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(gpr_arena))
+ : (char*)z + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(zone));
+ return ptr + start - z->size_begin;
}
diff --git a/src/core/lib/support/arena.h b/src/core/lib/gpr/arena.h
index 47f0e4d16b..339771c0e3 100644
--- a/src/core/lib/support/arena.h
+++ b/src/core/lib/gpr/arena.h
@@ -22,18 +22,18 @@
// Tracks the total memory allocated against it, so that future arenas can
// pre-allocate the right amount of memory
-#ifndef GRPC_CORE_LIB_SUPPORT_ARENA_H
-#define GRPC_CORE_LIB_SUPPORT_ARENA_H
+#ifndef GRPC_CORE_LIB_GPR_ARENA_H
+#define GRPC_CORE_LIB_GPR_ARENA_H
#include <stddef.h>
typedef struct gpr_arena gpr_arena;
// Create an arena, with \a initial_size bytes in the first allocated buffer
-gpr_arena *gpr_arena_create(size_t initial_size);
+gpr_arena* gpr_arena_create(size_t initial_size);
// Allocate \a size bytes from the arena
-void *gpr_arena_alloc(gpr_arena *arena, size_t size);
+void* gpr_arena_alloc(gpr_arena* arena, size_t size);
// Destroy an arena, returning the total number of bytes allocated
-size_t gpr_arena_destroy(gpr_arena *arena);
+size_t gpr_arena_destroy(gpr_arena* arena);
-#endif /* GRPC_CORE_LIB_SUPPORT_ARENA_H */
+#endif /* GRPC_CORE_LIB_GPR_ARENA_H */
diff --git a/src/core/lib/support/atm.c b/src/core/lib/gpr/atm.cc
index 2f37d62f76..15bfe52d64 100644
--- a/src/core/lib/support/atm.c
+++ b/src/core/lib/gpr/atm.cc
@@ -19,7 +19,7 @@
#include <grpc/support/atm.h>
#include <grpc/support/useful.h>
-gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm *value, gpr_atm delta,
+gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm* value, gpr_atm delta,
gpr_atm min, gpr_atm max) {
gpr_atm current_value;
gpr_atm new_value;
diff --git a/src/core/lib/support/avl.c b/src/core/lib/gpr/avl.cc
index 0e28b24c98..0b67a21f2f 100644
--- a/src/core/lib/support/avl.c
+++ b/src/core/lib/gpr/avl.cc
@@ -25,23 +25,23 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-gpr_avl gpr_avl_create(const gpr_avl_vtable *vtable) {
+gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable) {
gpr_avl out;
out.vtable = vtable;
- out.root = NULL;
+ out.root = nullptr;
return out;
}
-static gpr_avl_node *ref_node(gpr_avl_node *node) {
+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 == NULL) {
+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)) {
@@ -53,18 +53,19 @@ static void unref_node(const gpr_avl_vtable *vtable, gpr_avl_node *node,
}
}
-static long node_height(gpr_avl_node *node) {
- return node == NULL ? 0 : node->height;
+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 == NULL ? 0 : 1 + GPR_MAX(calculate_height(node->left),
- calculate_height(node->right));
+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 == NULL) return NULL;
+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);
@@ -72,12 +73,12 @@ static gpr_avl_node *assert_invariants(gpr_avl_node *n) {
return n;
}
#else
-static gpr_avl_node *assert_invariants(gpr_avl_node *n) { return n; }
+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_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;
@@ -87,12 +88,12 @@ gpr_avl_node *new_node(void *key, void *value, gpr_avl_node *left,
return node;
}
-static gpr_avl_node *get(const gpr_avl_vtable *vtable, gpr_avl_node *node,
- void *key, void *user_data) {
+static gpr_avl_node* get(const gpr_avl_vtable* vtable, gpr_avl_node* node,
+ void* key, void* user_data) {
long cmp;
- if (node == NULL) {
- return NULL;
+ if (node == nullptr) {
+ return nullptr;
}
cmp = vtable->compare_keys(node->key, key, user_data);
@@ -105,24 +106,24 @@ static gpr_avl_node *get(const gpr_avl_vtable *vtable, gpr_avl_node *node,
}
}
-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 : NULL;
+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 != NULL) {
+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),
+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));
@@ -130,10 +131,10 @@ static gpr_avl_node *rotate_left(const gpr_avl_vtable *vtable, void *key,
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 =
+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));
@@ -141,11 +142,11 @@ static gpr_avl_node *rotate_right(const gpr_avl_vtable *vtable, void *key,
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) {
+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 =
+ 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),
@@ -156,11 +157,11 @@ static gpr_avl_node *rotate_left_right(const gpr_avl_vtable *vtable, void *key,
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) {
+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 =
+ 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)),
@@ -171,9 +172,9 @@ static gpr_avl_node *rotate_right_left(const gpr_avl_vtable *vtable, void *key,
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) {
+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) {
@@ -196,11 +197,11 @@ static gpr_avl_node *rebalance(const gpr_avl_vtable *vtable, void *key,
}
}
-static gpr_avl_node *add_key(const gpr_avl_vtable *vtable, gpr_avl_node *node,
- void *key, void *value, void *user_data) {
+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 == NULL) {
- return new_node(key, value, NULL, NULL);
+ if (node == nullptr) {
+ return new_node(key, value, nullptr, nullptr);
}
cmp = vtable->compare_keys(node->key, key, user_data);
if (cmp == 0) {
@@ -218,49 +219,49 @@ static gpr_avl_node *add_key(const gpr_avl_vtable *vtable, gpr_avl_node *node,
}
}
-gpr_avl gpr_avl_add(gpr_avl avl, void *key, void *value, void *user_data) {
- gpr_avl_node *old_root = avl.root;
+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 != NULL) {
+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 != NULL) {
+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) {
+static gpr_avl_node* remove_key(const gpr_avl_vtable* vtable,
+ gpr_avl_node* node, void* key,
+ void* user_data) {
long cmp;
- if (node == NULL) {
- return NULL;
+ if (node == nullptr) {
+ return nullptr;
}
cmp = vtable->compare_keys(node->key, key, user_data);
if (cmp == 0) {
- if (node->left == NULL) {
+ if (node->left == nullptr) {
return ref_node(node->right);
- } else if (node->right == NULL) {
+ } 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);
+ 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);
+ 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),
@@ -279,21 +280,21 @@ static gpr_avl_node *remove_key(const gpr_avl_vtable *vtable,
}
}
-gpr_avl gpr_avl_remove(gpr_avl avl, void *key, void *user_data) {
- gpr_avl_node *old_root = avl.root;
+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) {
+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) {
+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 == NULL; }
+int gpr_avl_is_empty(gpr_avl avl) { return avl.root == nullptr; }
diff --git a/src/core/lib/support/cmdline.c b/src/core/lib/gpr/cmdline.cc
index 9fb80d4460..4118f9a72a 100644
--- a/src/core/lib/support/cmdline.c
+++ b/src/core/lib/gpr/cmdline.cc
@@ -25,38 +25,38 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#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;
+ const char* name;
+ const char* help;
argtype type;
- void *value;
- struct arg *next;
+ void* value;
+ struct arg* next;
} arg;
struct gpr_cmdline {
- const char *description;
- arg *args;
- const char *argv0;
+ 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;
+ 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 (*state)(gpr_cmdline* cl, char* arg);
+ arg* cur_arg;
int survive_failure;
};
-static int normal_state(gpr_cmdline *cl, char *arg);
+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));
+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;
@@ -64,28 +64,28 @@ gpr_cmdline *gpr_cmdline_create(const char *description) {
return cl;
}
-void gpr_cmdline_set_survive_failure(gpr_cmdline *cl) {
+void gpr_cmdline_set_survive_failure(gpr_cmdline* cl) {
cl->survive_failure = 1;
}
-void gpr_cmdline_destroy(gpr_cmdline *cl) {
+void gpr_cmdline_destroy(gpr_cmdline* cl) {
while (cl->args) {
- arg *a = 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;
+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 = (arg*)gpr_zalloc(sizeof(arg));
a->name = name;
a->help = help;
a->type = type;
@@ -94,24 +94,24 @@ static void add_arg(gpr_cmdline *cl, const char *name, const char *help,
cl->args = a;
}
-void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name, const char *help,
- int *value) {
+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) {
+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,
- char **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_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);
@@ -124,8 +124,8 @@ void gpr_cmdline_on_extra_arg(
/* 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;
+static void add_args_to_usage(gpr_strvec* s, arg* a) {
+ char* tmp;
if (!a) return;
add_args_to_usage(s, a->next);
@@ -146,11 +146,11 @@ static void add_args_to_usage(gpr_strvec *s, arg *a) {
}
}
-char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0) {
+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, '/');
+ char* tmp;
+ const char* name = strrchr(argv0, '/');
if (name) {
name++;
@@ -169,13 +169,13 @@ char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0) {
}
gpr_strvec_add(&s, gpr_strdup("\n"));
- tmp = gpr_strvec_flatten(&s, NULL);
+ 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);
+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) {
@@ -184,7 +184,7 @@ static int print_usage_and_die(gpr_cmdline *cl) {
return 0;
}
-static int extra_state(gpr_cmdline *cl, char *str) {
+static int extra_state(gpr_cmdline* cl, char* str) {
if (!cl->extra_arg) {
return print_usage_and_die(cl);
}
@@ -192,8 +192,8 @@ static int extra_state(gpr_cmdline *cl, char *str) {
return 1;
}
-static arg *find_arg(gpr_cmdline *cl, char *name) {
- arg *a;
+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)) {
@@ -203,15 +203,15 @@ static arg *find_arg(gpr_cmdline *cl, char *name) {
if (!a) {
fprintf(stderr, "Unknown argument: %s\n", name);
- return NULL;
+ return nullptr;
}
return a;
}
-static int value_state(gpr_cmdline *cl, char *str) {
+static int value_state(gpr_cmdline* cl, char* str) {
long intval;
- char *end;
+ char* end;
GPR_ASSERT(cl->cur_arg);
@@ -223,13 +223,13 @@ static int value_state(gpr_cmdline *cl, char *str) {
cl->cur_arg->name);
return print_usage_and_die(cl);
}
- *(int *)cl->cur_arg->value = (int)intval;
+ *(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;
+ *(int*)cl->cur_arg->value = 1;
} else if (0 == strcmp(str, "0") || 0 == strcmp(str, "false")) {
- *(int *)cl->cur_arg->value = 0;
+ *(int*)cl->cur_arg->value = 0;
} else {
fprintf(stderr, "expected boolean, got '%s' for %s\n", str,
cl->cur_arg->name);
@@ -237,7 +237,7 @@ static int value_state(gpr_cmdline *cl, char *str) {
}
break;
case ARGTYPE_STRING:
- *(char **)cl->cur_arg->value = str;
+ *(char**)cl->cur_arg->value = str;
break;
}
@@ -245,10 +245,10 @@ static int value_state(gpr_cmdline *cl, char *str) {
return 1;
}
-static int normal_state(gpr_cmdline *cl, char *str) {
- char *eq = NULL;
- char *tmp = NULL;
- char *arg_name = NULL;
+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") ||
@@ -256,7 +256,7 @@ static int normal_state(gpr_cmdline *cl, char *str) {
return print_usage_and_die(cl);
}
- cl->cur_arg = NULL;
+ cl->cur_arg = nullptr;
if (str[0] == '-') {
if (str[1] == '-') {
@@ -274,30 +274,30 @@ static int normal_state(gpr_cmdline *cl, char *str) {
/* 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 == NULL) {
+ 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;
+ *(int*)cl->cur_arg->value = 0;
return 1; /* early out */
}
eq = strchr(str, '=');
- if (eq != NULL) {
+ 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));
+ 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 == NULL) {
+ if (cl->cur_arg == nullptr) {
return print_usage_and_die(cl);
}
- if (eq != NULL) {
+ 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) {
@@ -305,7 +305,7 @@ static int normal_state(gpr_cmdline *cl, char *str) {
cl->state = value_state;
} else {
/* flag parameter: just set the value */
- *(int *)cl->cur_arg->value = 1;
+ *(int*)cl->cur_arg->value = 1;
}
} else {
r = extra_state(cl, str);
@@ -315,7 +315,7 @@ static int normal_state(gpr_cmdline *cl, char *str) {
return r;
}
-int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv) {
+int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv) {
int i;
GPR_ASSERT(argc >= 1);
diff --git a/src/core/lib/support/cpu_iphone.c b/src/core/lib/gpr/cpu_iphone.cc
index dfd69b9fd8..2847e03ba5 100644
--- a/src/core/lib/support/cpu_iphone.c
+++ b/src/core/lib/gpr/cpu_iphone.cc
@@ -18,6 +18,8 @@
#include <grpc/support/port_platform.h>
+#include <grpc/support/cpu.h>
+
#ifdef GPR_CPU_IPHONE
/* Probably 2 instead of 1, but see comment on gpr_cpu_current_cpu. */
diff --git a/src/core/lib/support/cpu_linux.c b/src/core/lib/gpr/cpu_linux.cc
index 2280668442..21b1a71dc9 100644
--- a/src/core/lib/support/cpu_linux.c
+++ b/src/core/lib/gpr/cpu_linux.cc
@@ -36,6 +36,13 @@
static int ncpus = 0;
static void init_num_cpus() {
+#ifndef GPR_MUSL_LIBC_COMPAT
+ if (sched_getcpu() < 0) {
+ gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
+ ncpus = 1;
+ return;
+ }
+#endif
/* This must be signed. sysconf returns -1 when the number cannot be
determined */
ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN);
@@ -56,6 +63,9 @@ unsigned gpr_cpu_current_cpu(void) {
// sched_getcpu() is undefined on musl
return 0;
#else
+ if (gpr_cpu_num_cores() == 1) {
+ return 0;
+ }
int cpu = sched_getcpu();
if (cpu < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
diff --git a/src/core/lib/support/cpu_posix.c b/src/core/lib/gpr/cpu_posix.cc
index a1ba8202a8..bca14a0c12 100644
--- a/src/core/lib/support/cpu_posix.c
+++ b/src/core/lib/gpr/cpu_posix.cc
@@ -18,20 +18,23 @@
#include <grpc/support/port_platform.h>
-#ifdef GPR_CPU_POSIX
+#if defined(GPR_CPU_POSIX)
#include <errno.h>
+#include <pthread.h>
#include <string.h>
#include <unistd.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
-static __thread char magic_thread_local;
-
static long ncpus = 0;
+static pthread_key_t thread_id_key;
+
static void init_ncpus() {
ncpus = sysconf(_SC_NPROCESSORS_ONLN);
if (ncpus < 1 || ncpus > INT32_MAX) {
@@ -46,12 +49,32 @@ unsigned gpr_cpu_num_cores(void) {
return (unsigned)ncpus;
}
+static void delete_thread_id(void* value) {
+ if (value) {
+ gpr_free(value);
+ }
+}
+
+static void init_thread_id_key(void) {
+ pthread_key_create(&thread_id_key, delete_thread_id);
+}
+
unsigned gpr_cpu_current_cpu(void) {
/* NOTE: there's no way I know to return the actual cpu index portably...
most code that's using this is using it to shard across work queues though,
so here we use thread identity instead to achieve a similar though not
identical effect */
- return (unsigned)GPR_HASH_POINTER(&magic_thread_local, gpr_cpu_num_cores());
+ static gpr_once once = GPR_ONCE_INIT;
+ gpr_once_init(&once, init_thread_id_key);
+
+ unsigned int* thread_id =
+ static_cast<unsigned int*>(pthread_getspecific(thread_id_key));
+ if (thread_id == nullptr) {
+ thread_id = static_cast<unsigned int*>(gpr_malloc(sizeof(unsigned int)));
+ pthread_setspecific(thread_id_key, thread_id);
+ }
+
+ return (unsigned)GPR_HASH_POINTER(thread_id, gpr_cpu_num_cores());
}
#endif /* GPR_CPU_POSIX */
diff --git a/src/core/lib/support/cpu_windows.c b/src/core/lib/gpr/cpu_windows.cc
index af26ff3679..8d89453403 100644
--- a/src/core/lib/support/cpu_windows.c
+++ b/src/core/lib/gpr/cpu_windows.cc
@@ -19,6 +19,7 @@
#include <grpc/support/port_platform.h>
#ifdef GPR_WINDOWS
+#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
unsigned gpr_cpu_num_cores(void) {
diff --git a/src/core/lib/support/env.h b/src/core/lib/gpr/env.h
index e2c012a728..7f35104be3 100644
--- a/src/core/lib/support/env.h
+++ b/src/core/lib/gpr/env.h
@@ -16,34 +16,26 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_ENV_H
-#define GRPC_CORE_LIB_SUPPORT_ENV_H
+#ifndef GRPC_CORE_LIB_GPR_ENV_H
+#define GRPC_CORE_LIB_GPR_ENV_H
#include <stdio.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Env utility functions */
/* Gets the environment variable value with the specified name.
Returns a newly allocated string. It is the responsability of the caller to
gpr_free the return value if not NULL (which means that the environment
variable exists). */
-char *gpr_getenv(const char *name);
+char* gpr_getenv(const char* name);
/* Sets the the environment with the specified name to the specified value. */
-void gpr_setenv(const char *name, const char *value);
+void gpr_setenv(const char* name, const char* value);
/* This is a version of gpr_getenv that does not produce any output if it has to
use an insecure version of the function. It is ONLY to be used to solve the
problem in which we need to check an env variable to configure the verbosity
level of logging. So DO NOT USE THIS. */
-const char *gpr_getenv_silent(const char *name, char **dst);
-
-#ifdef __cplusplus
-}
-#endif
+const char* gpr_getenv_silent(const char* name, char** dst);
-#endif /* GRPC_CORE_LIB_SUPPORT_ENV_H */
+#endif /* GRPC_CORE_LIB_GPR_ENV_H */
diff --git a/src/core/lib/support/env_linux.c b/src/core/lib/gpr/env_linux.cc
index 4c45a977ca..17902c3d0b 100644
--- a/src/core/lib/support/env_linux.c
+++ b/src/core/lib/gpr/env_linux.cc
@@ -25,7 +25,7 @@
#ifdef GPR_LINUX_ENV
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include <dlfcn.h>
#include <features.h>
@@ -36,17 +36,17 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-const char *gpr_getenv_silent(const char *name, char **dst) {
- const char *insecure_func_used = NULL;
- char *result = NULL;
+const char* gpr_getenv_silent(const char* name, char** dst) {
+ const char* insecure_func_used = nullptr;
+ char* result = nullptr;
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
- typedef char *(*getenv_type)(const char *);
+ typedef char* (*getenv_type)(const char*);
static getenv_type getenv_func = NULL;
/* Check to see which getenv variant is supported (go from most
* to least secure) */
- const char *names[] = {"secure_getenv", "__secure_getenv", "getenv"};
+ const char* names[] = {"secure_getenv", "__secure_getenv", "getenv"};
for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) {
getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]);
if (getenv_func != NULL && strstr(names[i], "secure") == NULL) {
@@ -60,21 +60,21 @@ const char *gpr_getenv_silent(const char *name, char **dst) {
result = getenv(name);
insecure_func_used = "getenv";
#endif
- *dst = result == NULL ? result : gpr_strdup(result);
+ *dst = result == nullptr ? result : gpr_strdup(result);
return insecure_func_used;
}
-char *gpr_getenv(const char *name) {
- char *result = NULL;
- const char *insecure_func_used = gpr_getenv_silent(name, &result);
- if (insecure_func_used != NULL) {
+char* gpr_getenv(const char* name) {
+ char* result = nullptr;
+ const char* insecure_func_used = gpr_getenv_silent(name, &result);
+ if (insecure_func_used != nullptr) {
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
insecure_func_used);
}
return result;
}
-void gpr_setenv(const char *name, const char *value) {
+void gpr_setenv(const char* name, const char* value) {
int res = setenv(name, value, 1);
GPR_ASSERT(res == 0);
}
diff --git a/src/core/lib/support/env_posix.c b/src/core/lib/gpr/env_posix.cc
index b88822ca02..599f85aa72 100644
--- a/src/core/lib/support/env_posix.c
+++ b/src/core/lib/gpr/env_posix.cc
@@ -20,26 +20,26 @@
#ifdef GPR_POSIX_ENV
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include <stdlib.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-const char *gpr_getenv_silent(const char *name, char **dst) {
+const char* gpr_getenv_silent(const char* name, char** dst) {
*dst = gpr_getenv(name);
- return NULL;
+ return nullptr;
}
-char *gpr_getenv(const char *name) {
- char *result = getenv(name);
- return result == NULL ? result : gpr_strdup(result);
+char* gpr_getenv(const char* name) {
+ char* result = getenv(name);
+ return result == nullptr ? result : gpr_strdup(result);
}
-void gpr_setenv(const char *name, const char *value) {
+void gpr_setenv(const char* name, const char* value) {
int res = setenv(name, value, 1);
GPR_ASSERT(res == 0);
}
diff --git a/src/core/lib/support/env_windows.c b/src/core/lib/gpr/env_windows.cc
index 652eeb61c6..9ca1e02d03 100644
--- a/src/core/lib/support/env_windows.c
+++ b/src/core/lib/gpr/env_windows.cc
@@ -22,30 +22,33 @@
#include <windows.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/string_windows.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/string_windows.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-const char *gpr_getenv_silent(const char *name, char **dst) {
+const char* gpr_getenv_silent(const char* name, char** dst) {
*dst = gpr_getenv(name);
return NULL;
}
-char *gpr_getenv(const char *name) {
- char *result = NULL;
+char* gpr_getenv(const char* name) {
+ char* result = NULL;
DWORD size;
LPTSTR tresult = NULL;
LPTSTR tname = gpr_char_to_tchar(name);
DWORD ret;
ret = GetEnvironmentVariable(tname, NULL, 0);
- if (ret == 0) return NULL;
+ if (ret == 0) {
+ gpr_free(tname);
+ return NULL;
+ }
size = ret * (DWORD)sizeof(TCHAR);
- tresult = gpr_malloc(size);
+ tresult = (LPTSTR)gpr_malloc(size);
ret = GetEnvironmentVariable(tname, tresult, size);
gpr_free(tname);
if (ret == 0) {
@@ -57,7 +60,7 @@ char *gpr_getenv(const char *name) {
return result;
}
-void gpr_setenv(const char *name, const char *value) {
+void gpr_setenv(const char* name, const char* value) {
LPTSTR tname = gpr_char_to_tchar(name);
LPTSTR tvalue = gpr_char_to_tchar(value);
BOOL res = SetEnvironmentVariable(tname, tvalue);
diff --git a/src/core/lib/gpr/fork.cc b/src/core/lib/gpr/fork.cc
new file mode 100644
index 0000000000..92023f4350
--- /dev/null
+++ b/src/core/lib/gpr/fork.cc
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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 "src/core/lib/gpr/fork.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/gpr/env.h"
+
+/*
+ * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
+ * AROUND VERY SPECIFIC USE CASES.
+ */
+
+static int override_fork_support_enabled = -1;
+static int fork_support_enabled;
+
+void grpc_fork_support_init() {
+#ifdef GRPC_ENABLE_FORK_SUPPORT
+ fork_support_enabled = 1;
+#else
+ fork_support_enabled = 0;
+#endif
+ bool env_var_set = false;
+ char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT");
+ if (env != nullptr) {
+ static const char* truthy[] = {"yes", "Yes", "YES", "true",
+ "True", "TRUE", "1"};
+ static const char* falsey[] = {"no", "No", "NO", "false",
+ "False", "FALSE", "0"};
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) {
+ if (0 == strcmp(env, truthy[i])) {
+ fork_support_enabled = 1;
+ env_var_set = true;
+ break;
+ }
+ }
+ if (!env_var_set) {
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(falsey); i++) {
+ if (0 == strcmp(env, falsey[i])) {
+ fork_support_enabled = 0;
+ env_var_set = true;
+ break;
+ }
+ }
+ }
+ gpr_free(env);
+ }
+ if (override_fork_support_enabled != -1) {
+ fork_support_enabled = override_fork_support_enabled;
+ }
+}
+
+int grpc_fork_support_enabled() { return fork_support_enabled; }
+
+void grpc_enable_fork_support(int enable) {
+ override_fork_support_enabled = enable;
+}
diff --git a/src/core/lib/gpr/fork.h b/src/core/lib/gpr/fork.h
new file mode 100644
index 0000000000..94c61bb836
--- /dev/null
+++ b/src/core/lib/gpr/fork.h
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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_CORE_LIB_GPR_FORK_H
+#define GRPC_CORE_LIB_GPR_FORK_H
+
+/*
+ * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
+ * AROUND VERY SPECIFIC USE CASES.
+ */
+
+void grpc_fork_support_init(void);
+
+int grpc_fork_support_enabled(void);
+
+// Test only: Must be called before grpc_init(), and overrides
+// environment variables/compile flags
+void grpc_enable_fork_support(int enable);
+
+#endif /* GRPC_CORE_LIB_GPR_FORK_H */
diff --git a/src/core/lib/support/host_port.c b/src/core/lib/gpr/host_port.cc
index 3302e574ab..29178279d3 100644
--- a/src/core/lib/support/host_port.c
+++ b/src/core/lib/gpr/host_port.cc
@@ -23,10 +23,10 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-int gpr_join_host_port(char **out, const char *host, int port) {
- if (host[0] != '[' && strchr(host, ':') != NULL) {
+int gpr_join_host_port(char** out, const char* host, int port) {
+ if (host[0] != '[' && strchr(host, ':') != nullptr) {
/* IPv6 literals must be enclosed in brackets. */
return gpr_asprintf(out, "[%s]:%d", host, port);
} else {
@@ -35,24 +35,24 @@ int gpr_join_host_port(char **out, const char *host, int port) {
}
}
-int gpr_split_host_port(const char *name, char **host, char **port) {
- const char *host_start;
+int gpr_split_host_port(const char* name, char** host, char** port) {
+ const char* host_start;
size_t host_len;
- const char *port_start;
+ const char* port_start;
- *host = NULL;
- *port = NULL;
+ *host = nullptr;
+ *port = nullptr;
if (name[0] == '[') {
/* Parse a bracketed host, typically an IPv6 literal. */
- const char *rbracket = strchr(name, ']');
- if (rbracket == NULL) {
+ const char* rbracket = strchr(name, ']');
+ if (rbracket == nullptr) {
/* Unmatched [ */
return 0;
}
if (rbracket[1] == '\0') {
/* ]<end> */
- port_start = NULL;
+ port_start = nullptr;
} else if (rbracket[1] == ':') {
/* ]:<port?> */
port_start = rbracket + 2;
@@ -62,14 +62,14 @@ int gpr_split_host_port(const char *name, char **host, char **port) {
}
host_start = name + 1;
host_len = (size_t)(rbracket - host_start);
- if (memchr(host_start, ':', host_len) == NULL) {
+ if (memchr(host_start, ':', host_len) == nullptr) {
/* Require all bracketed hosts to contain a colon, because a hostname or
IPv4 address should never use brackets. */
return 0;
}
} else {
- const char *colon = strchr(name, ':');
- if (colon != NULL && strchr(colon + 1, ':') == NULL) {
+ const char* colon = strchr(name, ':');
+ if (colon != nullptr && strchr(colon + 1, ':') == nullptr) {
/* Exactly 1 colon. Split into host:port. */
host_start = name;
host_len = (size_t)(colon - name);
@@ -78,16 +78,16 @@ int gpr_split_host_port(const char *name, char **host, char **port) {
/* 0 or 2+ colons. Bare hostname or IPv6 litearal. */
host_start = name;
host_len = strlen(name);
- port_start = NULL;
+ port_start = nullptr;
}
}
/* Allocate return values. */
- *host = (char *)gpr_malloc(host_len + 1);
+ *host = (char*)gpr_malloc(host_len + 1);
memcpy(*host, host_start, host_len);
(*host)[host_len] = '\0';
- if (port_start != NULL) {
+ if (port_start != nullptr) {
*port = gpr_strdup(port_start);
}
diff --git a/src/core/lib/support/log.c b/src/core/lib/gpr/log.cc
index fadb4d9a2c..19c0f6c34d 100644
--- a/src/core/lib/support/log.c
+++ b/src/core/lib/gpr/log.cc
@@ -21,17 +21,17 @@
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include <stdio.h>
#include <string.h>
-extern void gpr_default_log(gpr_log_func_args *args);
+void gpr_default_log(gpr_log_func_args* args);
static gpr_atm g_log_func = (gpr_atm)gpr_default_log;
static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET;
-const char *gpr_log_severity_string(gpr_log_severity severity) {
+const char* gpr_log_severity_string(gpr_log_severity severity) {
switch (severity) {
case GPR_LOG_SEVERITY_DEBUG:
return "D";
@@ -43,8 +43,8 @@ const char *gpr_log_severity_string(gpr_log_severity severity) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-void gpr_log_message(const char *file, int line, gpr_log_severity severity,
- const char *message) {
+void gpr_log_message(const char* file, int line, gpr_log_severity severity,
+ const char* message) {
if ((gpr_atm)severity < gpr_atm_no_barrier_load(&g_min_severity_to_print)) {
return;
}
@@ -64,11 +64,11 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) {
}
void gpr_log_verbosity_init() {
- char *verbosity = NULL;
- const char *insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity);
+ char* verbosity = nullptr;
+ const char* insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity);
gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR;
- if (verbosity != NULL) {
+ if (verbosity != nullptr) {
if (gpr_stricmp(verbosity, "DEBUG") == 0) {
min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_DEBUG;
} else if (gpr_stricmp(verbosity, "INFO") == 0) {
@@ -83,7 +83,7 @@ void gpr_log_verbosity_init() {
gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
}
- if (insecure_getenv != NULL) {
+ if (insecure_getenv != nullptr) {
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
insecure_getenv);
}
diff --git a/src/core/lib/support/log_android.c b/src/core/lib/gpr/log_android.cc
index 6f1cec51f1..0d3ac0fe52 100644
--- a/src/core/lib/support/log_android.c
+++ b/src/core/lib/gpr/log_android.cc
@@ -39,9 +39,9 @@ static android_LogPriority severity_to_log_priority(gpr_log_severity severity) {
return ANDROID_LOG_DEFAULT;
}
-void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) {
- char *message = NULL;
+void gpr_log(const char* file, int line, gpr_log_severity severity,
+ const char* format, ...) {
+ char* message = NULL;
va_list args;
va_start(args, format);
vasprintf(&message, format, args);
@@ -50,10 +50,10 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
free(message);
}
-void gpr_default_log(gpr_log_func_args *args) {
- char *final_slash;
- const char *display_file;
- char *output = NULL;
+void gpr_default_log(gpr_log_func_args* args) {
+ const char* final_slash;
+ const char* display_file;
+ char* output = NULL;
final_slash = strrchr(args->file, '/');
if (final_slash == NULL)
diff --git a/src/core/lib/support/log_linux.c b/src/core/lib/gpr/log_linux.cc
index 7755018693..6b1f1c71e4 100644
--- a/src/core/lib/support/log_linux.c
+++ b/src/core/lib/gpr/log_linux.cc
@@ -41,9 +41,9 @@
static long gettid(void) { return syscall(__NR_gettid); }
-void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) {
- char *message = NULL;
+void gpr_log(const char* file, int line, gpr_log_severity severity,
+ const char* format, ...) {
+ char* message = nullptr;
va_list args;
va_start(args, format);
if (vasprintf(&message, format, args) == -1) {
@@ -56,10 +56,10 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
free(message);
}
-void gpr_default_log(gpr_log_func_args *args) {
- const char *final_slash;
- char *prefix;
- const char *display_file;
+void gpr_default_log(gpr_log_func_args* args) {
+ const char* final_slash;
+ char* prefix;
+ const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
@@ -69,7 +69,7 @@ void gpr_default_log(gpr_log_func_args *args) {
timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '/');
- if (final_slash == NULL)
+ if (final_slash == nullptr)
display_file = args->file;
else
display_file = final_slash + 1;
diff --git a/src/core/lib/support/log_posix.c b/src/core/lib/gpr/log_posix.cc
index 8b376fce41..6f93cdefcd 100644
--- a/src/core/lib/support/log_posix.c
+++ b/src/core/lib/gpr/log_posix.cc
@@ -27,28 +27,27 @@
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
-#include <stdio.h>
#include <string.h>
#include <time.h>
static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
-void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) {
+void gpr_log(const char* file, int line, gpr_log_severity severity,
+ const char* format, ...) {
char buf[64];
- char *allocated = NULL;
- char *message = NULL;
+ char* allocated = nullptr;
+ char* message = nullptr;
int ret;
va_list args;
va_start(args, format);
ret = vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if (ret < 0) {
- message = NULL;
+ message = nullptr;
} else if ((size_t)ret <= sizeof(buf) - 1) {
message = buf;
} else {
- message = allocated = gpr_malloc((size_t)ret + 1);
+ message = allocated = (char*)gpr_malloc((size_t)ret + 1);
va_start(args, format);
vsnprintf(message, (size_t)(ret + 1), format, args);
va_end(args);
@@ -57,9 +56,9 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
gpr_free(allocated);
}
-void gpr_default_log(gpr_log_func_args *args) {
- char *final_slash;
- const char *display_file;
+void gpr_default_log(gpr_log_func_args* args) {
+ const char* final_slash;
+ const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
@@ -67,7 +66,7 @@ void gpr_default_log(gpr_log_func_args *args) {
timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '/');
- if (final_slash == NULL)
+ if (final_slash == nullptr)
display_file = args->file;
else
display_file = final_slash + 1;
@@ -79,7 +78,7 @@ void gpr_default_log(gpr_log_func_args *args) {
strcpy(time_buffer, "error:strftime");
}
- char *prefix;
+ char* prefix;
gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]",
gpr_log_severity_string(args->severity), time_buffer,
(int)(now.tv_nsec), gettid(), display_file, args->line);
diff --git a/src/core/lib/support/log_windows.c b/src/core/lib/gpr/log_windows.cc
index 0fdab79ae6..caaa973f5a 100644
--- a/src/core/lib/support/log_windows.c
+++ b/src/core/lib/gpr/log_windows.cc
@@ -29,12 +29,12 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/string_windows.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/string_windows.h"
-void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) {
- char *message = NULL;
+void gpr_log(const char* file, int line, gpr_log_severity severity,
+ const char* format, ...) {
+ char* message = NULL;
va_list args;
int ret;
@@ -47,7 +47,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
} else {
/* Allocate a new buffer, with space for the NUL terminator. */
size_t strp_buflen = (size_t)ret + 1;
- message = gpr_malloc(strp_buflen);
+ message = (char*)gpr_malloc(strp_buflen);
/* Print to the buffer. */
va_start(args, format);
@@ -65,9 +65,9 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
}
/* Simple starter implementation */
-void gpr_default_log(gpr_log_func_args *args) {
- char *final_slash;
- const char *display_file;
+void gpr_default_log(gpr_log_func_args* args) {
+ const char* final_slash;
+ const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
diff --git a/src/core/lib/gpr/mpscq.cc b/src/core/lib/gpr/mpscq.cc
new file mode 100644
index 0000000000..34fc050a11
--- /dev/null
+++ b/src/core/lib/gpr/mpscq.cc
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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 "src/core/lib/gpr/mpscq.h"
+
+#include <grpc/support/log.h>
+
+void gpr_mpscq_init(gpr_mpscq* q) {
+ gpr_atm_no_barrier_store(&q->head, (gpr_atm)&q->stub);
+ q->tail = &q->stub;
+ gpr_atm_no_barrier_store(&q->stub.next, (gpr_atm)NULL);
+}
+
+void gpr_mpscq_destroy(gpr_mpscq* q) {
+ GPR_ASSERT(gpr_atm_no_barrier_load(&q->head) == (gpr_atm)&q->stub);
+ GPR_ASSERT(q->tail == &q->stub);
+}
+
+bool gpr_mpscq_push(gpr_mpscq* q, gpr_mpscq_node* n) {
+ gpr_atm_no_barrier_store(&n->next, (gpr_atm)NULL);
+ gpr_mpscq_node* prev =
+ (gpr_mpscq_node*)gpr_atm_full_xchg(&q->head, (gpr_atm)n);
+ gpr_atm_rel_store(&prev->next, (gpr_atm)n);
+ return prev == &q->stub;
+}
+
+gpr_mpscq_node* gpr_mpscq_pop(gpr_mpscq* q) {
+ bool empty;
+ return gpr_mpscq_pop_and_check_end(q, &empty);
+}
+
+gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty) {
+ gpr_mpscq_node* tail = q->tail;
+ gpr_mpscq_node* next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
+ if (tail == &q->stub) {
+ // indicates the list is actually (ephemerally) empty
+ if (next == nullptr) {
+ *empty = true;
+ return nullptr;
+ }
+ q->tail = next;
+ tail = next;
+ next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
+ }
+ if (next != nullptr) {
+ *empty = false;
+ q->tail = next;
+ return tail;
+ }
+ gpr_mpscq_node* head = (gpr_mpscq_node*)gpr_atm_acq_load(&q->head);
+ if (tail != head) {
+ *empty = false;
+ // indicates a retry is in order: we're still adding
+ return nullptr;
+ }
+ gpr_mpscq_push(q, &q->stub);
+ next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
+ if (next != nullptr) {
+ q->tail = next;
+ return tail;
+ }
+ // indicates a retry is in order: we're still adding
+ *empty = false;
+ return nullptr;
+}
+
+void gpr_locked_mpscq_init(gpr_locked_mpscq* q) {
+ gpr_mpscq_init(&q->queue);
+ gpr_mu_init(&q->mu);
+}
+
+void gpr_locked_mpscq_destroy(gpr_locked_mpscq* q) {
+ gpr_mpscq_destroy(&q->queue);
+ gpr_mu_destroy(&q->mu);
+}
+
+bool gpr_locked_mpscq_push(gpr_locked_mpscq* q, gpr_mpscq_node* n) {
+ return gpr_mpscq_push(&q->queue, n);
+}
+
+gpr_mpscq_node* gpr_locked_mpscq_try_pop(gpr_locked_mpscq* q) {
+ if (gpr_mu_trylock(&q->mu)) {
+ gpr_mpscq_node* n = gpr_mpscq_pop(&q->queue);
+ gpr_mu_unlock(&q->mu);
+ return n;
+ }
+ return nullptr;
+}
+
+gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q) {
+ gpr_mu_lock(&q->mu);
+ bool empty = false;
+ gpr_mpscq_node* n;
+ do {
+ n = gpr_mpscq_pop_and_check_end(&q->queue, &empty);
+ } while (n == nullptr && !empty);
+ gpr_mu_unlock(&q->mu);
+ return n;
+}
diff --git a/src/core/lib/gpr/mpscq.h b/src/core/lib/gpr/mpscq.h
new file mode 100644
index 0000000000..4409c5c9f5
--- /dev/null
+++ b/src/core/lib/gpr/mpscq.h
@@ -0,0 +1,84 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_GPR_MPSCQ_H
+#define GRPC_CORE_LIB_GPR_MPSCQ_H
+
+#include <grpc/support/atm.h>
+#include <grpc/support/sync.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+// Multiple-producer single-consumer lock free queue, based upon the
+// implementation from Dmitry Vyukov here:
+// http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue
+
+// List node (include this in a data structure at the top, and add application
+// fields after it - to simulate inheritance)
+typedef struct gpr_mpscq_node {
+ gpr_atm next;
+} gpr_mpscq_node;
+
+// Actual queue type
+typedef struct gpr_mpscq {
+ gpr_atm head;
+ // make sure head & tail don't share a cacheline
+ char padding[GPR_CACHELINE_SIZE];
+ gpr_mpscq_node* tail;
+ gpr_mpscq_node stub;
+} gpr_mpscq;
+
+void gpr_mpscq_init(gpr_mpscq* q);
+void gpr_mpscq_destroy(gpr_mpscq* q);
+// Push a node
+// Thread safe - can be called from multiple threads concurrently
+// Returns true if this was possibly the first node (may return true
+// sporadically, will not return false sporadically)
+bool gpr_mpscq_push(gpr_mpscq* q, gpr_mpscq_node* n);
+// Pop a node (returns NULL if no node is ready - which doesn't indicate that
+// the queue is empty!!)
+// Thread compatible - can only be called from one thread at a time
+gpr_mpscq_node* gpr_mpscq_pop(gpr_mpscq* q);
+// Pop a node; sets *empty to true if the queue is empty, or false if it is not
+gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty);
+
+// An mpscq with a lock: it's safe to pop from multiple threads, but doing
+// only one thread will succeed concurrently
+typedef struct gpr_locked_mpscq {
+ gpr_mpscq queue;
+ gpr_mu mu;
+} gpr_locked_mpscq;
+
+void gpr_locked_mpscq_init(gpr_locked_mpscq* q);
+void gpr_locked_mpscq_destroy(gpr_locked_mpscq* q);
+// Push a node
+// Thread safe - can be called from multiple threads concurrently
+// Returns true if this was possibly the first node (may return true
+// sporadically, will not return false sporadically)
+bool gpr_locked_mpscq_push(gpr_locked_mpscq* q, gpr_mpscq_node* n);
+
+// Pop a node (returns NULL if no node is ready - which doesn't indicate that
+// the queue is empty!!)
+// Thread safe - can be called from multiple threads concurrently
+gpr_mpscq_node* gpr_locked_mpscq_try_pop(gpr_locked_mpscq* q);
+
+// Pop a node. Returns NULL only if the queue was empty at some point after
+// calling this function
+gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q);
+
+#endif /* GRPC_CORE_LIB_GPR_MPSCQ_H */
diff --git a/src/core/lib/support/murmur_hash.c b/src/core/lib/gpr/murmur_hash.cc
index f06b970de7..3f5e04d211 100644
--- a/src/core/lib/support/murmur_hash.c
+++ b/src/core/lib/gpr/murmur_hash.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/murmur_hash.h"
+#include "src/core/lib/gpr/murmur_hash.h"
#include <string.h>
@@ -29,23 +29,20 @@
(h) *= 0xc2b2ae35; \
(h) ^= (h) >> 16;
-uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) {
- const uint8_t *data = (const uint8_t *)key;
- const size_t nblocks = len / 4;
- int i;
-
+uint32_t gpr_murmur_hash3(const void* key, size_t len, uint32_t seed) {
uint32_t h1 = seed;
uint32_t k1;
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;
- const uint32_t *blocks = ((const uint32_t *)key) + nblocks;
- const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
+ const uint8_t* keyptr = (const uint8_t*)key;
+ const size_t bsize = sizeof(k1);
+ const size_t nblocks = len / bsize;
/* body */
- for (i = -(int)nblocks; i; i++) {
- memcpy(&k1, blocks + i, sizeof(uint32_t));
+ for (size_t i = 0; i < nblocks; i++, keyptr += bsize) {
+ memcpy(&k1, keyptr, bsize);
k1 *= c1;
k1 = ROTL32(k1, 15);
@@ -61,13 +58,13 @@ uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) {
/* tail */
switch (len & 3) {
case 3:
- k1 ^= ((uint32_t)tail[2]) << 16;
+ k1 ^= ((uint32_t)keyptr[2]) << 16;
/* fallthrough */
case 2:
- k1 ^= ((uint32_t)tail[1]) << 8;
+ k1 ^= ((uint32_t)keyptr[1]) << 8;
/* fallthrough */
case 1:
- k1 ^= tail[0];
+ k1 ^= keyptr[0];
k1 *= c1;
k1 = ROTL32(k1, 15);
k1 *= c2;
diff --git a/src/core/lib/support/murmur_hash.h b/src/core/lib/gpr/murmur_hash.h
index 7510b4d09c..8004889a9a 100644
--- a/src/core/lib/support/murmur_hash.h
+++ b/src/core/lib/gpr/murmur_hash.h
@@ -16,14 +16,14 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_MURMUR_HASH_H
-#define GRPC_CORE_LIB_SUPPORT_MURMUR_HASH_H
+#ifndef GRPC_CORE_LIB_GPR_MURMUR_HASH_H
+#define GRPC_CORE_LIB_GPR_MURMUR_HASH_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
/* compute the hash of key (length len) */
-uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed);
+uint32_t gpr_murmur_hash3(const void* key, size_t len, uint32_t seed);
-#endif /* GRPC_CORE_LIB_SUPPORT_MURMUR_HASH_H */
+#endif /* GRPC_CORE_LIB_GPR_MURMUR_HASH_H */
diff --git a/src/core/lib/support/spinlock.h b/src/core/lib/gpr/spinlock.h
index 37adda11b0..f03be1d791 100644
--- a/src/core/lib/support/spinlock.h
+++ b/src/core/lib/gpr/spinlock.h
@@ -16,22 +16,29 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_SPINLOCK_H
-#define GRPC_CORE_LIB_SUPPORT_SPINLOCK_H
+#ifndef GRPC_CORE_LIB_GPR_SPINLOCK_H
+#define GRPC_CORE_LIB_GPR_SPINLOCK_H
#include <grpc/support/atm.h>
/* Simple spinlock. No backoff strategy, gpr_spinlock_lock is almost always
a concurrency code smell. */
-typedef struct { gpr_atm atm; } gpr_spinlock;
+typedef struct {
+ gpr_atm atm;
+} gpr_spinlock;
+#ifdef __cplusplus
+#define GPR_SPINLOCK_INITIALIZER (gpr_spinlock{0})
+#else
#define GPR_SPINLOCK_INITIALIZER ((gpr_spinlock){0})
+#endif
#define GPR_SPINLOCK_STATIC_INITIALIZER \
{ 0 }
+
#define gpr_spinlock_trylock(lock) (gpr_atm_acq_cas(&(lock)->atm, 0, 1))
#define gpr_spinlock_unlock(lock) (gpr_atm_rel_store(&(lock)->atm, 0))
#define gpr_spinlock_lock(lock) \
do { \
} while (!gpr_spinlock_trylock((lock)))
-#endif /* GRPC_CORE_LIB_SUPPORT_SPINLOCK_H */
+#endif /* GRPC_CORE_LIB_GPR_SPINLOCK_H */
diff --git a/src/core/lib/support/string.c b/src/core/lib/gpr/string.cc
index 6b172df82f..919d957d1b 100644
--- a/src/core/lib/support/string.c
+++ b/src/core/lib/gpr/string.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include <ctype.h>
#include <limits.h>
@@ -27,18 +27,19 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-char *gpr_strdup(const char *src) {
- char *dst;
+char* gpr_strdup(const char* src) {
+ char* dst;
size_t len;
if (!src) {
- return NULL;
+ return nullptr;
}
len = strlen(src) + 1;
- dst = (char *)gpr_malloc(len);
+ dst = (char*)gpr_malloc(len);
memcpy(dst, src, len);
@@ -48,28 +49,28 @@ char *gpr_strdup(const char *src) {
typedef struct {
size_t capacity;
size_t length;
- char *data;
+ char* data;
} dump_out;
static dump_out dump_out_create(void) {
- dump_out r = {0, 0, NULL};
+ dump_out r = {0, 0, nullptr};
return r;
}
-static void dump_out_append(dump_out *out, char c) {
+static void dump_out_append(dump_out* out, char c) {
if (out->length == out->capacity) {
out->capacity = GPR_MAX(8, 2 * out->capacity);
- out->data = (char *)gpr_realloc(out->data, out->capacity);
+ out->data = (char*)gpr_realloc(out->data, out->capacity);
}
out->data[out->length++] = c;
}
-static void hexdump(dump_out *out, const char *buf, size_t len) {
- static const char *hex = "0123456789abcdef";
+static void hexdump(dump_out* out, const char* buf, size_t len) {
+ static const char* hex = "0123456789abcdef";
- const uint8_t *const beg = (const uint8_t *)buf;
- const uint8_t *const end = beg + len;
- const uint8_t *cur;
+ const uint8_t* const beg = (const uint8_t*)buf;
+ const uint8_t* const end = beg + len;
+ const uint8_t* cur;
for (cur = beg; cur != end; ++cur) {
if (cur != beg) dump_out_append(out, ' ');
@@ -78,24 +79,24 @@ static void hexdump(dump_out *out, const char *buf, size_t len) {
}
}
-static void asciidump(dump_out *out, const char *buf, size_t len) {
- const uint8_t *const beg = (const uint8_t *)buf;
- const uint8_t *const end = beg + len;
- const uint8_t *cur;
+static void asciidump(dump_out* out, const char* buf, size_t len) {
+ const uint8_t* const beg = (const uint8_t*)buf;
+ const uint8_t* const end = beg + len;
+ const uint8_t* cur;
int out_was_empty = (out->length == 0);
if (!out_was_empty) {
dump_out_append(out, ' ');
dump_out_append(out, '\'');
}
for (cur = beg; cur != end; ++cur) {
- dump_out_append(out, (char)(isprint(*cur) ? *(char *)cur : '.'));
+ dump_out_append(out, (char)(isprint(*cur) ? *(char*)cur : '.'));
}
if (!out_was_empty) {
dump_out_append(out, '\'');
}
}
-char *gpr_dump(const char *buf, size_t len, uint32_t flags) {
+char* gpr_dump(const char* buf, size_t len, uint32_t flags) {
dump_out out = dump_out_create();
if (flags & GPR_DUMP_HEX) {
hexdump(&out, buf, len);
@@ -107,7 +108,7 @@ char *gpr_dump(const char *buf, size_t len, uint32_t flags) {
return out.data;
}
-int gpr_parse_bytes_to_uint32(const char *buf, size_t len, uint32_t *result) {
+int gpr_parse_bytes_to_uint32(const char* buf, size_t len, uint32_t* result) {
uint32_t out = 0;
uint32_t new_val;
size_t i;
@@ -125,7 +126,7 @@ int gpr_parse_bytes_to_uint32(const char *buf, size_t len, uint32_t *result) {
return 1;
}
-void gpr_reverse_bytes(char *str, int len) {
+void gpr_reverse_bytes(char* str, int len) {
char *p1, *p2;
for (p1 = str, p2 = str + len - 1; p2 > p1; ++p1, --p2) {
char temp = *p1;
@@ -134,7 +135,7 @@ void gpr_reverse_bytes(char *str, int len) {
}
}
-int gpr_ltoa(long value, char *string) {
+int gpr_ltoa(long value, char* string) {
long sign;
int i = 0;
@@ -155,7 +156,7 @@ int gpr_ltoa(long value, char *string) {
return i;
}
-int int64_ttoa(int64_t value, char *string) {
+int int64_ttoa(int64_t value, char* string) {
int64_t sign;
int i = 0;
@@ -176,33 +177,33 @@ int int64_ttoa(int64_t value, char *string) {
return i;
}
-int gpr_parse_nonnegative_int(const char *value) {
- char *end;
+int gpr_parse_nonnegative_int(const char* value) {
+ char* end;
long result = strtol(value, &end, 0);
if (*end != '\0' || result < 0 || result > INT_MAX) return -1;
return (int)result;
}
-char *gpr_leftpad(const char *str, char flag, size_t length) {
+char* gpr_leftpad(const char* str, char flag, size_t length) {
const size_t str_length = strlen(str);
const size_t out_length = str_length > length ? str_length : length;
- char *out = (char *)gpr_malloc(out_length + 1);
+ char* out = (char*)gpr_malloc(out_length + 1);
memset(out, flag, out_length - str_length);
memcpy(out + out_length - str_length, str, str_length);
out[out_length] = 0;
return out;
}
-char *gpr_strjoin(const char **strs, size_t nstrs, size_t *final_length) {
+char* gpr_strjoin(const char** strs, size_t nstrs, size_t* final_length) {
return gpr_strjoin_sep(strs, nstrs, "", final_length);
}
-char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep,
- size_t *final_length) {
+char* gpr_strjoin_sep(const char** strs, size_t nstrs, const char* sep,
+ size_t* final_length) {
const size_t sep_len = strlen(sep);
size_t out_length = 0;
size_t i;
- char *out;
+ char* out;
for (i = 0; i < nstrs; i++) {
out_length += strlen(strs[i]);
}
@@ -210,7 +211,7 @@ char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep,
if (nstrs > 0) {
out_length += sep_len * (nstrs - 1); /* separators */
}
- out = (char *)gpr_malloc(out_length);
+ out = (char*)gpr_malloc(out_length);
out_length = 0;
for (i = 0; i < nstrs; i++) {
const size_t slen = strlen(strs[i]);
@@ -222,15 +223,15 @@ char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep,
out_length += slen;
}
out[out_length] = 0;
- if (final_length != NULL) {
+ if (final_length != nullptr) {
*final_length = out_length;
}
return out;
}
-void gpr_strvec_init(gpr_strvec *sv) { memset(sv, 0, sizeof(*sv)); }
+void gpr_strvec_init(gpr_strvec* sv) { memset(sv, 0, sizeof(*sv)); }
-void gpr_strvec_destroy(gpr_strvec *sv) {
+void gpr_strvec_destroy(gpr_strvec* sv) {
size_t i;
for (i = 0; i < sv->count; i++) {
gpr_free(sv->strs[i]);
@@ -238,19 +239,19 @@ void gpr_strvec_destroy(gpr_strvec *sv) {
gpr_free(sv->strs);
}
-void gpr_strvec_add(gpr_strvec *sv, char *str) {
+void gpr_strvec_add(gpr_strvec* sv, char* str) {
if (sv->count == sv->capacity) {
sv->capacity = GPR_MAX(sv->capacity + 8, sv->capacity * 2);
- sv->strs = (char **)gpr_realloc(sv->strs, sizeof(char *) * sv->capacity);
+ sv->strs = (char**)gpr_realloc(sv->strs, sizeof(char*) * sv->capacity);
}
sv->strs[sv->count++] = str;
}
-char *gpr_strvec_flatten(gpr_strvec *sv, size_t *final_length) {
- return gpr_strjoin((const char **)sv->strs, sv->count, final_length);
+char* gpr_strvec_flatten(gpr_strvec* sv, size_t* final_length) {
+ return gpr_strjoin((const char**)sv->strs, sv->count, final_length);
}
-int gpr_stricmp(const char *a, const char *b) {
+int gpr_stricmp(const char* a, const char* b) {
int ca, cb;
do {
ca = tolower(*a);
@@ -261,23 +262,23 @@ int gpr_stricmp(const char *a, const char *b) {
return ca - cb;
}
-static void add_string_to_split(const char *beg, const char *end, char ***strs,
- size_t *nstrs, size_t *capstrs) {
- char *out = (char *)gpr_malloc((size_t)(end - beg) + 1);
+static void add_string_to_split(const char* beg, const char* end, char*** strs,
+ size_t* nstrs, size_t* capstrs) {
+ char* out = (char*)gpr_malloc((size_t)(end - beg) + 1);
memcpy(out, beg, (size_t)(end - beg));
out[end - beg] = 0;
if (*nstrs == *capstrs) {
*capstrs = GPR_MAX(8, 2 * *capstrs);
- *strs = (char **)gpr_realloc(*strs, sizeof(*strs) * *capstrs);
+ *strs = (char**)gpr_realloc(*strs, sizeof(*strs) * *capstrs);
}
(*strs)[*nstrs] = out;
++*nstrs;
}
-void gpr_string_split(const char *input, const char *sep, char ***strs,
- size_t *nstrs) {
- const char *next;
- *strs = NULL;
+void gpr_string_split(const char* input, const char* sep, char*** strs,
+ size_t* nstrs) {
+ const char* next;
+ *strs = nullptr;
*nstrs = 0;
size_t capstrs = 0;
while ((next = strstr(input, sep))) {
@@ -287,24 +288,24 @@ void gpr_string_split(const char *input, const char *sep, char ***strs,
add_string_to_split(input, input + strlen(input), strs, nstrs, &capstrs);
}
-void *gpr_memrchr(const void *s, int c, size_t n) {
- if (s == NULL) return NULL;
- char *b = (char *)s;
+void* gpr_memrchr(const void* s, int c, size_t n) {
+ if (s == nullptr) return nullptr;
+ char* b = (char*)s;
size_t i;
for (i = 0; i < n; i++) {
if (b[n - i - 1] == c) {
return &b[n - i - 1];
}
}
- return NULL;
+ return nullptr;
}
-bool gpr_is_true(const char *s) {
+bool gpr_is_true(const char* s) {
size_t i;
- if (s == NULL) {
+ if (s == nullptr) {
return false;
}
- static const char *truthy[] = {"yes", "true", "1"};
+ static const char* truthy[] = {"yes", "true", "1"};
for (i = 0; i < GPR_ARRAY_SIZE(truthy); i++) {
if (0 == gpr_stricmp(s, truthy[i])) {
return true;
diff --git a/src/core/lib/support/string.h b/src/core/lib/gpr/string.h
index 5a56fa3a0a..ef3a8c6086 100644
--- a/src/core/lib/support/string.h
+++ b/src/core/lib/gpr/string.h
@@ -16,18 +16,14 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_STRING_H
-#define GRPC_CORE_LIB_SUPPORT_STRING_H
+#ifndef GRPC_CORE_LIB_GPR_STRING_H
+#define GRPC_CORE_LIB_GPR_STRING_H
#include <stdbool.h>
#include <stddef.h>
#include <grpc/support/port_platform.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* String utility functions */
/* Flags for gpr_dump function. */
@@ -36,12 +32,12 @@ extern "C" {
/* Converts array buf, of length len, into a C string according to the flags.
Result should be freed with gpr_free() */
-char *gpr_dump(const char *buf, size_t len, uint32_t flags);
+char* gpr_dump(const char* buf, size_t len, uint32_t flags);
/* Parses an array of bytes into an integer (base 10). Returns 1 on success,
0 on failure. */
-int gpr_parse_bytes_to_uint32(const char *data, size_t length,
- uint32_t *result);
+int gpr_parse_bytes_to_uint32(const char* data, size_t length,
+ uint32_t* result);
/* Minimum buffer size for calling ltoa */
#define GPR_LTOA_MIN_BUFSIZE (3 * sizeof(long))
@@ -49,7 +45,7 @@ int gpr_parse_bytes_to_uint32(const char *data, size_t length,
/* Convert a long to a string in base 10; returns the length of the
output string (or 0 on failure).
output must be at least GPR_LTOA_MIN_BUFSIZE bytes long. */
-int gpr_ltoa(long value, char *output);
+int gpr_ltoa(long value, char* output);
/* Minimum buffer size for calling int64toa */
#define GPR_INT64TOA_MIN_BUFSIZE (3 * sizeof(int64_t))
@@ -59,58 +55,55 @@ output string (or 0 on failure).
output must be at least GPR_INT64TOA_MIN_BUFSIZE bytes long.
NOTE: This function ensures sufficient bit width even on Win x64,
where long is 32bit is size.*/
-int int64_ttoa(int64_t value, char *output);
+int int64_ttoa(int64_t value, char* output);
// Parses a non-negative number from a value string. Returns -1 on error.
-int gpr_parse_nonnegative_int(const char *value);
+int gpr_parse_nonnegative_int(const char* value);
/* Reverse a run of bytes */
-void gpr_reverse_bytes(char *str, int len);
+void gpr_reverse_bytes(char* str, int len);
/* Pad a string with flag characters. The given length specifies the minimum
field width. The input string is never truncated. */
-char *gpr_leftpad(const char *str, char flag, size_t length);
+char* gpr_leftpad(const char* str, char flag, size_t length);
/* Join a set of strings, returning the resulting string.
Total combined length (excluding null terminator) is returned in total_length
if it is non-null. */
-char *gpr_strjoin(const char **strs, size_t nstrs, size_t *total_length);
+char* gpr_strjoin(const char** strs, size_t nstrs, size_t* total_length);
/* Join a set of strings using a separator, returning the resulting string.
Total combined length (excluding null terminator) is returned in total_length
if it is non-null. */
-char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep,
- size_t *total_length);
+char* gpr_strjoin_sep(const char** strs, size_t nstrs, const char* sep,
+ size_t* total_length);
-void gpr_string_split(const char *input, const char *sep, char ***strs,
- size_t *nstrs);
+void gpr_string_split(const char* input, const char* sep, char*** strs,
+ size_t* nstrs);
/* A vector of strings... for building up a final string one piece at a time */
typedef struct {
- char **strs;
+ char** strs;
size_t count;
size_t capacity;
} gpr_strvec;
/* Initialize/destroy */
-void gpr_strvec_init(gpr_strvec *strs);
-void gpr_strvec_destroy(gpr_strvec *strs);
+void gpr_strvec_init(gpr_strvec* strs);
+void gpr_strvec_destroy(gpr_strvec* strs);
/* Add a string to a strvec, takes ownership of the string */
-void gpr_strvec_add(gpr_strvec *strs, char *add);
+void gpr_strvec_add(gpr_strvec* strs, char* add);
/* Return a joined string with all added substrings, optionally setting
total_length as per gpr_strjoin */
-char *gpr_strvec_flatten(gpr_strvec *strs, size_t *total_length);
+char* gpr_strvec_flatten(gpr_strvec* strs, size_t* total_length);
/** Case insensitive string comparison... return <0 if lower(a)<lower(b), ==0 if
lower(a)==lower(b), >0 if lower(a)>lower(b) */
-int gpr_stricmp(const char *a, const char *b);
+int gpr_stricmp(const char* a, const char* b);
-void *gpr_memrchr(const void *s, int c, size_t n);
+void* gpr_memrchr(const void* s, int c, size_t n);
/** Return true if lower(s) equals "true", "yes" or "1", otherwise false. */
-bool gpr_is_true(const char *s);
-#ifdef __cplusplus
-}
-#endif
+bool gpr_is_true(const char* s);
-#endif /* GRPC_CORE_LIB_SUPPORT_STRING_H */
+#endif /* GRPC_CORE_LIB_GPR_STRING_H */
diff --git a/src/core/lib/support/string_posix.c b/src/core/lib/gpr/string_posix.cc
index e768faf739..8b818e39b9 100644
--- a/src/core/lib/support/string_posix.c
+++ b/src/core/lib/gpr/string_posix.cc
@@ -25,8 +25,9 @@
#include <string.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
-int gpr_asprintf(char **strp, const char *format, ...) {
+int gpr_asprintf(char** strp, const char* format, ...) {
va_list args;
int ret;
char buf[64];
@@ -37,13 +38,13 @@ int gpr_asprintf(char **strp, const char *format, ...) {
ret = vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if (ret < 0) {
- *strp = NULL;
+ *strp = nullptr;
return -1;
}
/* Allocate a new buffer, with space for the NUL terminator. */
strp_buflen = (size_t)ret + 1;
- if ((*strp = (char *)gpr_malloc(strp_buflen)) == NULL) {
+ if ((*strp = (char*)gpr_malloc(strp_buflen)) == nullptr) {
/* This shouldn't happen, because gpr_malloc() calls abort(). */
return -1;
}
@@ -64,7 +65,7 @@ int gpr_asprintf(char **strp, const char *format, ...) {
/* This should never happen. */
gpr_free(*strp);
- *strp = NULL;
+ *strp = nullptr;
return -1;
}
diff --git a/src/core/lib/support/string_util_windows.c b/src/core/lib/gpr/string_util_windows.cc
index 2a03404448..8c8c99cd21 100644
--- a/src/core/lib/support/string_util_windows.c
+++ b/src/core/lib/gpr/string_util_windows.cc
@@ -26,15 +26,18 @@
anything else, especially strsafe.h. */
#include <wchar.h>
+#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <strsafe.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/log_windows.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/string_windows.h"
#if defined UNICODE || defined _UNICODE
LPTSTR
@@ -42,7 +45,7 @@ gpr_char_to_tchar(LPCSTR input) {
LPTSTR ret;
int needed = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
if (needed <= 0) return NULL;
- ret = gpr_malloc((unsigned)needed * sizeof(TCHAR));
+ ret = (LPTSTR)gpr_malloc((unsigned)needed * sizeof(TCHAR));
MultiByteToWideChar(CP_UTF8, 0, input, -1, ret, needed);
return ret;
}
@@ -52,19 +55,19 @@ gpr_tchar_to_char(LPCTSTR input) {
LPSTR ret;
int needed = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
if (needed <= 0) return NULL;
- ret = gpr_malloc((unsigned)needed);
+ ret = (LPSTR)gpr_malloc((unsigned)needed);
WideCharToMultiByte(CP_UTF8, 0, input, -1, ret, needed, NULL, NULL);
return ret;
}
#else
-char *gpr_tchar_to_char(LPTSTR input) { return gpr_strdup(input); }
+LPSTR gpr_tchar_to_char(LPCTSTR input) { return (LPSTR)gpr_strdup(input); }
-char *gpr_char_to_tchar(LPTSTR input) { return gpr_strdup(input); }
+LPTSTR gpr_char_to_tchar(LPCTSTR input) { return (LPTSTR)gpr_strdup(input); }
#endif
-char *gpr_format_message(int messageid) {
+char* gpr_format_message(int messageid) {
LPTSTR tmessage;
- char *message;
+ char* message;
DWORD status = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
diff --git a/src/core/lib/support/string_windows.c b/src/core/lib/gpr/string_windows.cc
index 50278d9559..25bfd412e4 100644
--- a/src/core/lib/support/string_windows.c
+++ b/src/core/lib/gpr/string_windows.cc
@@ -27,10 +27,11 @@
#include <string.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-int gpr_asprintf(char **strp, const char *format, ...) {
+int gpr_asprintf(char** strp, const char* format, ...) {
va_list args;
int ret;
size_t strp_buflen;
@@ -46,7 +47,7 @@ int gpr_asprintf(char **strp, const char *format, ...) {
/* Allocate a new buffer, with space for the NUL terminator. */
strp_buflen = (size_t)ret + 1;
- if ((*strp = gpr_malloc(strp_buflen)) == NULL) {
+ if ((*strp = (char*)gpr_malloc(strp_buflen)) == NULL) {
/* This shouldn't happen, because gpr_malloc() calls abort(). */
return -1;
}
diff --git a/src/core/lib/support/string_windows.h b/src/core/lib/gpr/string_windows.h
index 7c7f31e7aa..e370f802cf 100644
--- a/src/core/lib/support/string_windows.h
+++ b/src/core/lib/gpr/string_windows.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_STRING_WINDOWS_H
-#define GRPC_CORE_LIB_SUPPORT_STRING_WINDOWS_H
+#ifndef GRPC_CORE_LIB_GPR_STRING_WINDOWS_H
+#define GRPC_CORE_LIB_GPR_STRING_WINDOWS_H
#include <grpc/support/port_platform.h>
@@ -29,4 +29,4 @@ LPSTR gpr_tchar_to_char(LPCTSTR input);
#endif /* GPR_WINDOWS */
-#endif /* GRPC_CORE_LIB_SUPPORT_STRING_WINDOWS_H */
+#endif /* GRPC_CORE_LIB_GPR_STRING_WINDOWS_H */
diff --git a/src/core/lib/support/subprocess_posix.c b/src/core/lib/gpr/subprocess_posix.cc
index af75162ee9..dc046b6499 100644
--- a/src/core/lib/support/subprocess_posix.c
+++ b/src/core/lib/gpr/subprocess_posix.cc
@@ -41,33 +41,33 @@ struct gpr_subprocess {
bool joined;
};
-const char *gpr_subprocess_binary_extension() { return ""; }
+const char* gpr_subprocess_binary_extension() { return ""; }
-gpr_subprocess *gpr_subprocess_create(int argc, const char **argv) {
- gpr_subprocess *r;
+gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
+ gpr_subprocess* r;
int pid;
- char **exec_args;
+ char** exec_args;
pid = fork();
if (pid == -1) {
- return NULL;
+ 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] = NULL;
+ 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 NULL;
+ return nullptr;
} else {
- r = (gpr_subprocess *)gpr_zalloc(sizeof(gpr_subprocess));
+ r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess));
r->pid = pid;
return r;
}
}
-void gpr_subprocess_destroy(gpr_subprocess *p) {
+void gpr_subprocess_destroy(gpr_subprocess* p) {
if (!p->joined) {
kill(p->pid, SIGKILL);
gpr_subprocess_join(p);
@@ -75,7 +75,7 @@ void gpr_subprocess_destroy(gpr_subprocess *p) {
gpr_free(p);
}
-int gpr_subprocess_join(gpr_subprocess *p) {
+int gpr_subprocess_join(gpr_subprocess* p) {
int status;
retry:
if (waitpid(p->pid, &status, 0) == -1) {
@@ -90,7 +90,7 @@ retry:
return status;
}
-void gpr_subprocess_interrupt(gpr_subprocess *p) {
+void gpr_subprocess_interrupt(gpr_subprocess* p) {
if (!p->joined) {
kill(p->pid, SIGINT);
}
diff --git a/src/core/lib/support/subprocess_windows.c b/src/core/lib/gpr/subprocess_windows.cc
index 7412f8d344..1947d475e3 100644
--- a/src/core/lib/support/subprocess_windows.c
+++ b/src/core/lib/gpr/subprocess_windows.cc
@@ -27,8 +27,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/string_windows.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/string_windows.h"
struct gpr_subprocess {
PROCESS_INFORMATION pi;
@@ -36,16 +36,16 @@ struct gpr_subprocess {
int interrupted;
};
-const char *gpr_subprocess_binary_extension() { return ".exe"; }
+const char* gpr_subprocess_binary_extension() { return ".exe"; }
-gpr_subprocess *gpr_subprocess_create(int argc, const char **argv) {
- gpr_subprocess *r;
+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;
+ char* args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL);
+ TCHAR* args_tchar;
args_tchar = gpr_char_to_tchar(args);
gpr_free(args);
@@ -61,13 +61,13 @@ gpr_subprocess *gpr_subprocess_create(int argc, const char **argv) {
}
gpr_free(args_tchar);
- r = gpr_malloc(sizeof(gpr_subprocess));
+ 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) {
+void gpr_subprocess_destroy(gpr_subprocess* p) {
if (p) {
if (!p->joined) {
gpr_subprocess_interrupt(p);
@@ -83,7 +83,7 @@ void gpr_subprocess_destroy(gpr_subprocess *p) {
}
}
-int gpr_subprocess_join(gpr_subprocess *p) {
+int gpr_subprocess_join(gpr_subprocess* p) {
DWORD dwExitCode;
if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) {
if (dwExitCode == STILL_ACTIVE) {
@@ -110,7 +110,7 @@ getExitCode:
}
}
-void gpr_subprocess_interrupt(gpr_subprocess *p) {
+void gpr_subprocess_interrupt(gpr_subprocess* p) {
DWORD dwExitCode;
if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) {
if (dwExitCode == STILL_ACTIVE) {
diff --git a/src/core/lib/support/sync.c b/src/core/lib/gpr/sync.cc
index 994dcb0e14..347ffcd00e 100644
--- a/src/core/lib/support/sync.c
+++ b/src/core/lib/gpr/sync.cc
@@ -45,47 +45,47 @@ static void event_initialize(void) {
}
/* Hash ev into an element of sync_array[]. */
-static struct sync_array_s *hash(gpr_event *ev) {
+static struct sync_array_s* hash(gpr_event* ev) {
return &sync_array[((uintptr_t)ev) % event_sync_partitions];
}
-void gpr_event_init(gpr_event *ev) {
+void gpr_event_init(gpr_event* ev) {
gpr_once_init(&event_once, &event_initialize);
ev->state = 0;
}
-void gpr_event_set(gpr_event *ev, void *value) {
- struct sync_array_s *s = hash(ev);
+void gpr_event_set(gpr_event* ev, void* value) {
+ struct sync_array_s* s = hash(ev);
gpr_mu_lock(&s->mu);
GPR_ASSERT(gpr_atm_acq_load(&ev->state) == 0);
gpr_atm_rel_store(&ev->state, (gpr_atm)value);
gpr_cv_broadcast(&s->cv);
gpr_mu_unlock(&s->mu);
- GPR_ASSERT(value != NULL);
+ GPR_ASSERT(value != nullptr);
}
-void *gpr_event_get(gpr_event *ev) {
- return (void *)gpr_atm_acq_load(&ev->state);
+void* gpr_event_get(gpr_event* ev) {
+ return (void*)gpr_atm_acq_load(&ev->state);
}
-void *gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline) {
- void *result = (void *)gpr_atm_acq_load(&ev->state);
- if (result == NULL) {
- struct sync_array_s *s = hash(ev);
+void* gpr_event_wait(gpr_event* ev, gpr_timespec abs_deadline) {
+ void* result = (void*)gpr_atm_acq_load(&ev->state);
+ if (result == nullptr) {
+ struct sync_array_s* s = hash(ev);
gpr_mu_lock(&s->mu);
do {
- result = (void *)gpr_atm_acq_load(&ev->state);
- } while (result == NULL && !gpr_cv_wait(&s->cv, &s->mu, abs_deadline));
+ result = (void*)gpr_atm_acq_load(&ev->state);
+ } while (result == nullptr && !gpr_cv_wait(&s->cv, &s->mu, abs_deadline));
gpr_mu_unlock(&s->mu);
}
return result;
}
-void gpr_ref_init(gpr_refcount *r, int n) { gpr_atm_rel_store(&r->count, n); }
+void gpr_ref_init(gpr_refcount* r, int n) { gpr_atm_rel_store(&r->count, n); }
-void gpr_ref(gpr_refcount *r) { gpr_atm_no_barrier_fetch_add(&r->count, 1); }
+void gpr_ref(gpr_refcount* r) { gpr_atm_no_barrier_fetch_add(&r->count, 1); }
-void gpr_ref_non_zero(gpr_refcount *r) {
+void gpr_ref_non_zero(gpr_refcount* r) {
#ifndef NDEBUG
gpr_atm prior = gpr_atm_no_barrier_fetch_add(&r->count, 1);
assert(prior > 0);
@@ -94,29 +94,29 @@ void gpr_ref_non_zero(gpr_refcount *r) {
#endif
}
-void gpr_refn(gpr_refcount *r, int n) {
+void gpr_refn(gpr_refcount* r, int n) {
gpr_atm_no_barrier_fetch_add(&r->count, n);
}
-int gpr_unref(gpr_refcount *r) {
+int gpr_unref(gpr_refcount* r) {
gpr_atm prior = gpr_atm_full_fetch_add(&r->count, -1);
GPR_ASSERT(prior > 0);
return prior == 1;
}
-int gpr_ref_is_unique(gpr_refcount *r) {
+int gpr_ref_is_unique(gpr_refcount* r) {
return gpr_atm_acq_load(&r->count) == 1;
}
-void gpr_stats_init(gpr_stats_counter *c, intptr_t n) {
+void gpr_stats_init(gpr_stats_counter* c, intptr_t n) {
gpr_atm_rel_store(&c->value, n);
}
-void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc) {
+void gpr_stats_inc(gpr_stats_counter* c, intptr_t inc) {
gpr_atm_no_barrier_fetch_add(&c->value, inc);
}
-intptr_t gpr_stats_read(const gpr_stats_counter *c) {
+intptr_t gpr_stats_read(const gpr_stats_counter* c) {
/* don't need acquire-load, but we have no no-barrier load yet */
return gpr_atm_acq_load(&c->value);
}
diff --git a/src/core/lib/support/sync_posix.c b/src/core/lib/gpr/sync_posix.cc
index 62d800b18c..c3f6b10463 100644
--- a/src/core/lib/support/sync_posix.c
+++ b/src/core/lib/gpr/sync_posix.cc
@@ -33,7 +33,9 @@ gpr_atm gpr_counter_atm_cas = 0;
gpr_atm gpr_counter_atm_add = 0;
#endif
-void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); }
+void gpr_mu_init(gpr_mu* mu) {
+ GPR_ASSERT(pthread_mutex_init(mu, nullptr) == 0);
+}
void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); }
@@ -63,7 +65,14 @@ int gpr_mu_trylock(gpr_mu* mu) {
/*----------------------------------------*/
-void gpr_cv_init(gpr_cv* cv) { GPR_ASSERT(pthread_cond_init(cv, NULL) == 0); }
+void gpr_cv_init(gpr_cv* cv) {
+ pthread_condattr_t attr;
+ GPR_ASSERT(pthread_condattr_init(&attr) == 0);
+#if GPR_LINUX
+ GPR_ASSERT(pthread_condattr_setclock(&attr, CLOCK_MONOTONIC) == 0);
+#endif // GPR_LINUX
+ GPR_ASSERT(pthread_cond_init(cv, &attr) == 0);
+}
void gpr_cv_destroy(gpr_cv* cv) { GPR_ASSERT(pthread_cond_destroy(cv) == 0); }
@@ -74,7 +83,11 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
err = pthread_cond_wait(cv, mu);
} else {
struct timespec abs_deadline_ts;
+#if GPR_LINUX
+ abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_MONOTONIC);
+#else
abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
+#endif // GPR_LINUX
abs_deadline_ts.tv_sec = (time_t)abs_deadline.tv_sec;
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
diff --git a/src/core/lib/support/sync_windows.c b/src/core/lib/gpr/sync_windows.cc
index 008c5aecba..7cd41633d5 100644
--- a/src/core/lib/support/sync_windows.c
+++ b/src/core/lib/gpr/sync_windows.cc
@@ -26,25 +26,25 @@
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
-void gpr_mu_init(gpr_mu *mu) {
+void gpr_mu_init(gpr_mu* mu) {
InitializeCriticalSection(&mu->cs);
mu->locked = 0;
}
-void gpr_mu_destroy(gpr_mu *mu) { DeleteCriticalSection(&mu->cs); }
+void gpr_mu_destroy(gpr_mu* mu) { DeleteCriticalSection(&mu->cs); }
-void gpr_mu_lock(gpr_mu *mu) {
+void gpr_mu_lock(gpr_mu* mu) {
EnterCriticalSection(&mu->cs);
GPR_ASSERT(!mu->locked);
mu->locked = 1;
}
-void gpr_mu_unlock(gpr_mu *mu) {
+void gpr_mu_unlock(gpr_mu* mu) {
mu->locked = 0;
LeaveCriticalSection(&mu->cs);
}
-int gpr_mu_trylock(gpr_mu *mu) {
+int gpr_mu_trylock(gpr_mu* mu) {
int result = TryEnterCriticalSection(&mu->cs);
if (result) {
if (mu->locked) { /* This thread already holds the lock. */
@@ -58,13 +58,13 @@ int gpr_mu_trylock(gpr_mu *mu) {
/*----------------------------------------*/
-void gpr_cv_init(gpr_cv *cv) { InitializeConditionVariable(cv); }
+void gpr_cv_init(gpr_cv* cv) { InitializeConditionVariable(cv); }
-void gpr_cv_destroy(gpr_cv *cv) {
+void gpr_cv_destroy(gpr_cv* cv) {
/* Condition variables don't need destruction in Win32. */
}
-int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
+int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
int timeout = 0;
DWORD timeout_max_ms;
mu->locked = 0;
@@ -93,23 +93,23 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
return timeout;
}
-void gpr_cv_signal(gpr_cv *cv) { WakeConditionVariable(cv); }
+void gpr_cv_signal(gpr_cv* cv) { WakeConditionVariable(cv); }
-void gpr_cv_broadcast(gpr_cv *cv) { WakeAllConditionVariable(cv); }
+void gpr_cv_broadcast(gpr_cv* cv) { WakeAllConditionVariable(cv); }
/*----------------------------------------*/
-static void *dummy;
+static void* dummy;
struct run_once_func_arg {
void (*init_function)(void);
};
-static BOOL CALLBACK run_once_func(gpr_once *once, void *v, void **pv) {
- struct run_once_func_arg *arg = v;
+static BOOL CALLBACK run_once_func(gpr_once* once, void* v, void** pv) {
+ struct run_once_func_arg* arg = (struct run_once_func_arg*)v;
(*arg->init_function)();
return 1;
}
-void gpr_once_init(gpr_once *once, void (*init_function)(void)) {
+void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
struct run_once_func_arg arg;
arg.init_function = init_function;
InitOnceExecuteOnce(once, run_once_func, &arg, &dummy);
diff --git a/src/core/lib/support/thd.c b/src/core/lib/gpr/thd.cc
index ca62615d65..ca62615d65 100644
--- a/src/core/lib/support/thd.c
+++ b/src/core/lib/gpr/thd.cc
diff --git a/src/core/lib/gpr/thd_internal.h b/src/core/lib/gpr/thd_internal.h
new file mode 100644
index 0000000000..692c00c8e1
--- /dev/null
+++ b/src/core/lib/gpr/thd_internal.h
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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_THD_INTERNAL_H
+#define GRPC_CORE_LIB_GPR_THD_INTERNAL_H
+
+#include <grpc/support/time.h>
+
+/* Internal interfaces between modules within the gpr support library. */
+void gpr_thd_init();
+
+/* Wait for all outstanding threads to finish, up to deadline */
+int gpr_await_threads(gpr_timespec deadline);
+
+#endif /* GRPC_CORE_LIB_GPR_THD_INTERNAL_H */
diff --git a/src/core/lib/gpr/thd_posix.cc b/src/core/lib/gpr/thd_posix.cc
new file mode 100644
index 0000000000..cfff0df6de
--- /dev/null
+++ b/src/core/lib/gpr/thd_posix.cc
@@ -0,0 +1,152 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+/* Posix implementation for gpr threads. */
+
+#include <grpc/support/port_platform.h>
+
+#ifdef GPR_POSIX_SYNC
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "src/core/lib/gpr/fork.h"
+
+static gpr_mu g_mu;
+static gpr_cv g_cv;
+static int g_thread_count;
+static int g_awaiting_threads;
+
+struct thd_arg {
+ void (*body)(void* arg); /* body of a thread */
+ void* arg; /* argument to a thread */
+ const char* name; /* name of thread. Can be nullptr. */
+};
+
+static void inc_thd_count();
+static void dec_thd_count();
+
+/* Body of every thread started via gpr_thd_new. */
+static void* thread_body(void* v) {
+ struct thd_arg a = *(struct thd_arg*)v;
+ free(v);
+ if (a.name != nullptr) {
+#if GPR_APPLE_PTHREAD_NAME
+ /* Apple supports 64 characters, and will truncate if it's longer. */
+ pthread_setname_np(a.name);
+#elif GPR_LINUX_PTHREAD_NAME
+ /* Linux supports 16 characters max, and will error if it's longer. */
+ char buf[16];
+ size_t buf_len = GPR_ARRAY_SIZE(buf) - 1;
+ strncpy(buf, a.name, buf_len);
+ buf[buf_len] = '\0';
+ pthread_setname_np(pthread_self(), buf);
+#endif // GPR_APPLE_PTHREAD_NAME
+ }
+ (*a.body)(a.arg);
+ dec_thd_count();
+ return nullptr;
+}
+
+int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
+ void (*thd_body)(void* arg), void* arg,
+ const gpr_thd_options* options) {
+ int thread_started;
+ pthread_attr_t attr;
+ pthread_t p;
+ /* don't use gpr_malloc as we may cause an infinite recursion with
+ * the profiling code */
+ struct thd_arg* a = (struct thd_arg*)malloc(sizeof(*a));
+ GPR_ASSERT(a != nullptr);
+ a->body = thd_body;
+ a->arg = arg;
+ a->name = thd_name;
+ inc_thd_count();
+
+ GPR_ASSERT(pthread_attr_init(&attr) == 0);
+ if (gpr_thd_options_is_detached(options)) {
+ GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) ==
+ 0);
+ } else {
+ GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) ==
+ 0);
+ }
+ thread_started = (pthread_create(&p, &attr, &thread_body, a) == 0);
+ GPR_ASSERT(pthread_attr_destroy(&attr) == 0);
+ if (!thread_started) {
+ /* don't use gpr_free, as this was allocated using malloc (see above) */
+ free(a);
+ dec_thd_count();
+ }
+ *t = (gpr_thd_id)p;
+ return thread_started;
+}
+
+gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)pthread_self(); }
+
+void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, nullptr); }
+
+/*****************************************
+ * Only used when fork support is enabled
+ */
+
+static void inc_thd_count() {
+ if (grpc_fork_support_enabled()) {
+ gpr_mu_lock(&g_mu);
+ g_thread_count++;
+ gpr_mu_unlock(&g_mu);
+ }
+}
+
+static void dec_thd_count() {
+ if (grpc_fork_support_enabled()) {
+ gpr_mu_lock(&g_mu);
+ g_thread_count--;
+ if (g_awaiting_threads && g_thread_count == 0) {
+ gpr_cv_signal(&g_cv);
+ }
+ gpr_mu_unlock(&g_mu);
+ }
+}
+
+void gpr_thd_init() {
+ gpr_mu_init(&g_mu);
+ gpr_cv_init(&g_cv);
+ g_thread_count = 0;
+ g_awaiting_threads = 0;
+}
+
+int gpr_await_threads(gpr_timespec deadline) {
+ gpr_mu_lock(&g_mu);
+ g_awaiting_threads = 1;
+ int res = 0;
+ if (g_thread_count > 0) {
+ res = gpr_cv_wait(&g_cv, &g_mu, deadline);
+ }
+ g_awaiting_threads = 0;
+ gpr_mu_unlock(&g_mu);
+ return res == 0;
+}
+
+#endif /* GPR_POSIX_SYNC */
diff --git a/src/core/lib/support/thd_windows.c b/src/core/lib/gpr/thd_windows.cc
index 54533e9412..f920770f32 100644
--- a/src/core/lib/support/thd_windows.c
+++ b/src/core/lib/gpr/thd_windows.cc
@@ -36,23 +36,25 @@
#endif
struct thd_info {
- void (*body)(void *arg); /* body of a thread */
- void *arg; /* argument to a thread */
+ void (*body)(void* arg); /* body of a thread */
+ void* arg; /* argument to a thread */
HANDLE join_event; /* if joinable, the join event */
int joinable; /* true if not detached */
};
-static thread_local struct thd_info *g_thd_info;
+static thread_local struct thd_info* g_thd_info;
/* Destroys a thread info */
-static void destroy_thread(struct thd_info *t) {
+static void destroy_thread(struct thd_info* t) {
if (t->joinable) CloseHandle(t->join_event);
gpr_free(t);
}
+void gpr_thd_init(void) {}
+
/* Body of every thread started via gpr_thd_new. */
-static DWORD WINAPI thread_body(void *v) {
- g_thd_info = (struct thd_info *)v;
+static DWORD WINAPI thread_body(void* v) {
+ g_thd_info = (struct thd_info*)v;
g_thd_info->body(g_thd_info->arg);
if (g_thd_info->joinable) {
BOOL ret = SetEvent(g_thd_info->join_event);
@@ -63,10 +65,11 @@ static DWORD WINAPI thread_body(void *v) {
return 0;
}
-int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
- const gpr_thd_options *options) {
+int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
+ void (*thd_body)(void* arg), void* arg,
+ const gpr_thd_options* options) {
HANDLE handle;
- struct thd_info *info = gpr_malloc(sizeof(*info));
+ struct thd_info* info = (struct thd_info*)gpr_malloc(sizeof(*info));
info->body = thd_body;
info->arg = arg;
*t = 0;
@@ -93,7 +96,7 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)g_thd_info; }
void gpr_thd_join(gpr_thd_id t) {
- struct thd_info *info = (struct thd_info *)t;
+ struct thd_info* info = (struct thd_info*)t;
DWORD ret = WaitForSingleObject(info->join_event, INFINITE);
GPR_ASSERT(ret == WAIT_OBJECT_0);
destroy_thread(info);
diff --git a/src/core/lib/support/time.c b/src/core/lib/gpr/time.cc
index 6903674d75..6903674d75 100644
--- a/src/core/lib/support/time.c
+++ b/src/core/lib/gpr/time.cc
diff --git a/src/core/lib/support/time_posix.c b/src/core/lib/gpr/time_posix.cc
index 3ead40d807..9c7e86b080 100644
--- a/src/core/lib/support/time_posix.c
+++ b/src/core/lib/gpr/time_posix.cc
@@ -17,7 +17,7 @@
*/
#include <grpc/support/port_platform.h>
-#include "src/core/lib/support/time_precise.h"
+#include "src/core/lib/gpr/time_precise.h"
#ifdef GPR_POSIX_TIME
@@ -30,7 +30,6 @@
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
-#include "src/core/lib/support/block_annotate.h"
static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
@@ -43,7 +42,7 @@ static struct timespec timespec_from_gpr(gpr_timespec gts) {
return rv;
}
-#if _POSIX_TIMERS > 0
+#if _POSIX_TIMERS > 0 || defined(__OpenBSD__)
static gpr_timespec gpr_from_timespec(struct timespec ts,
gpr_clock_type clock_type) {
/*
@@ -82,7 +81,7 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) {
}
}
#else
-/* For some reason Apple's OSes haven't implemented clock_gettime. */
+ /* For some reason Apple's OSes haven't implemented clock_gettime. */
#include <mach/mach.h>
#include <mach/mach_time.h>
@@ -108,7 +107,7 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
now.clock_type = clock;
switch (clock) {
case GPR_CLOCK_REALTIME:
- gettimeofday(&now_tv, NULL);
+ gettimeofday(&now_tv, nullptr);
now.tv_sec = now_tv.tv_sec;
now.tv_nsec = now_tv.tv_usec * 1000;
break;
@@ -157,9 +156,7 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
delta_ts = timespec_from_gpr(delta);
- GRPC_SCHEDULING_START_BLOCKING_REGION;
- ns_result = nanosleep(&delta_ts, NULL);
- GRPC_SCHEDULING_END_BLOCKING_REGION;
+ ns_result = nanosleep(&delta_ts, nullptr);
if (ns_result == 0) {
break;
}
diff --git a/src/core/lib/support/time_precise.c b/src/core/lib/gpr/time_precise.cc
index 6ce19e53cc..3c7aaabc40 100644
--- a/src/core/lib/support/time_precise.c
+++ b/src/core/lib/gpr/time_precise.cc
@@ -20,9 +20,11 @@
#include <grpc/support/time.h>
#include <stdio.h>
+#include "src/core/lib/gpr/time_precise.h"
+
#ifdef GRPC_TIMERS_RDTSC
#if defined(__i386__)
-static void gpr_get_cycle_counter(int64_t int *clk) {
+static void gpr_get_cycle_counter(int64_t int* clk) {
int64_t int ret;
__asm__ volatile("rdtsc" : "=A"(ret));
*clk = ret;
@@ -30,7 +32,7 @@ static void gpr_get_cycle_counter(int64_t int *clk) {
// ----------------------------------------------------------------
#elif defined(__x86_64__) || defined(__amd64__)
-static void gpr_get_cycle_counter(int64_t *clk) {
+static void gpr_get_cycle_counter(int64_t* clk) {
uint64_t low, high;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
*clk = (int64_t)(high << 32) | (int64_t)low;
@@ -54,7 +56,7 @@ void gpr_precise_clock_init(void) {
gpr_log(GPR_DEBUG, "... cycles_per_second = %f\n", cycles_per_second);
}
-void gpr_precise_clock_now(gpr_timespec *clk) {
+void gpr_precise_clock_now(gpr_timespec* clk) {
int64_t counter;
double secs;
gpr_get_cycle_counter(&counter);
@@ -67,7 +69,7 @@ void gpr_precise_clock_now(gpr_timespec *clk) {
#else /* GRPC_TIMERS_RDTSC */
void gpr_precise_clock_init(void) {}
-void gpr_precise_clock_now(gpr_timespec *clk) {
+void gpr_precise_clock_now(gpr_timespec* clk) {
*clk = gpr_now(GPR_CLOCK_REALTIME);
clk->clock_type = GPR_CLOCK_PRECISE;
}
diff --git a/src/core/lib/support/time_precise.h b/src/core/lib/gpr/time_precise.h
index aa28d6d7c4..acc4ee3d1b 100644
--- a/src/core/lib/support/time_precise.h
+++ b/src/core/lib/gpr/time_precise.h
@@ -16,12 +16,12 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_TIME_PRECISE_H
-#define GRPC_CORE_LIB_SUPPORT_TIME_PRECISE_H
+#ifndef GRPC_CORE_LIB_GPR_TIME_PRECISE_H
+#define GRPC_CORE_LIB_GPR_TIME_PRECISE_H
#include <grpc/support/time.h>
void gpr_precise_clock_init(void);
-void gpr_precise_clock_now(gpr_timespec *clk);
+void gpr_precise_clock_now(gpr_timespec* clk);
-#endif /* GRPC_CORE_LIB_SUPPORT_TIME_PRECISE_H */
+#endif /* GRPC_CORE_LIB_GPR_TIME_PRECISE_H */
diff --git a/src/core/lib/support/time_windows.c b/src/core/lib/gpr/time_windows.cc
index 40df3761c0..247cc16468 100644
--- a/src/core/lib/support/time_windows.c
+++ b/src/core/lib/gpr/time_windows.cc
@@ -28,8 +28,7 @@
#include <process.h>
#include <sys/timeb.h>
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/time_precise.h"
+#include "src/core/lib/gpr/time_precise.h"
static LARGE_INTEGER g_start_time;
static double g_time_scale;
@@ -92,9 +91,7 @@ void gpr_sleep_until(gpr_timespec until) {
sleep_millis =
delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
GPR_ASSERT((sleep_millis >= 0) && (sleep_millis <= INT_MAX));
- GRPC_SCHEDULING_START_BLOCKING_REGION;
Sleep((DWORD)sleep_millis);
- GRPC_SCHEDULING_END_BLOCKING_REGION;
}
}
diff --git a/src/core/lib/support/tls_pthread.c b/src/core/lib/gpr/tls_pthread.cc
index 9ebee577fe..ebeef2a8c2 100644
--- a/src/core/lib/support/tls_pthread.c
+++ b/src/core/lib/gpr/tls_pthread.cc
@@ -22,8 +22,8 @@
#include <grpc/support/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));
+intptr_t gpr_tls_set(struct gpr_pthread_thread_local* tls, intptr_t value) {
+ GPR_ASSERT(0 == pthread_setspecific(tls->key, (void*)value));
return value;
}
diff --git a/src/core/lib/support/tmpfile.h b/src/core/lib/gpr/tmpfile.h
index caa1d0f4d2..f47ec7aa63 100644
--- a/src/core/lib/support/tmpfile.h
+++ b/src/core/lib/gpr/tmpfile.h
@@ -16,23 +16,15 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_TMPFILE_H
-#define GRPC_CORE_LIB_SUPPORT_TMPFILE_H
+#ifndef GRPC_CORE_LIB_GPR_TMPFILE_H
+#define GRPC_CORE_LIB_GPR_TMPFILE_H
#include <stdio.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Creates a temporary file from a prefix.
If tmp_filename is not NULL, *tmp_filename is assigned the name of the
created file and it is the responsibility of the caller to gpr_free it
unless an error occurs in which case it will be set to NULL. */
-FILE *gpr_tmpfile(const char *prefix, char **tmp_filename);
-
-#ifdef __cplusplus
-}
-#endif
+FILE* gpr_tmpfile(const char* prefix, char** tmp_filename);
-#endif /* GRPC_CORE_LIB_SUPPORT_TMPFILE_H */
+#endif /* GRPC_CORE_LIB_GPR_TMPFILE_H */
diff --git a/src/core/lib/support/tmpfile_msys.c b/src/core/lib/gpr/tmpfile_msys.cc
index 614c0a4a18..76cd886f3a 100644
--- a/src/core/lib/support/tmpfile_msys.c
+++ b/src/core/lib/gpr/tmpfile_msys.cc
@@ -29,11 +29,11 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string_windows.h"
-#include "src/core/lib/support/tmpfile.h"
+#include "src/core/lib/gpr/string_windows.h"
+#include "src/core/lib/gpr/tmpfile.h"
-FILE *gpr_tmpfile(const char *prefix, char **tmp_filename_out) {
- FILE *result = NULL;
+FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
+ FILE* result = NULL;
char tmp_filename[MAX_PATH];
UINT success;
diff --git a/src/core/lib/support/tmpfile_posix.c b/src/core/lib/gpr/tmpfile_posix.cc
index 7ad3af0a57..ffdad335d6 100644
--- a/src/core/lib/support/tmpfile_posix.c
+++ b/src/core/lib/gpr/tmpfile_posix.cc
@@ -20,7 +20,7 @@
#ifdef GPR_POSIX_TMPFILE
-#include "src/core/lib/support/tmpfile.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include <errno.h>
#include <stdlib.h>
@@ -31,17 +31,17 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-FILE *gpr_tmpfile(const char *prefix, char **tmp_filename) {
- FILE *result = NULL;
- char *filename_template;
+FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
+ FILE* result = nullptr;
+ char* filename_template;
int fd;
- if (tmp_filename != NULL) *tmp_filename = NULL;
+ if (tmp_filename != nullptr) *tmp_filename = nullptr;
gpr_asprintf(&filename_template, "/tmp/%s_XXXXXX", prefix);
- GPR_ASSERT(filename_template != NULL);
+ GPR_ASSERT(filename_template != nullptr);
fd = mkstemp(filename_template);
if (fd == -1) {
@@ -50,7 +50,7 @@ FILE *gpr_tmpfile(const char *prefix, char **tmp_filename) {
goto end;
}
result = fdopen(fd, "w+");
- if (result == NULL) {
+ if (result == nullptr) {
gpr_log(GPR_ERROR, "Could not open file %s from fd %d (error = %s).",
filename_template, fd, strerror(errno));
unlink(filename_template);
@@ -59,7 +59,7 @@ FILE *gpr_tmpfile(const char *prefix, char **tmp_filename) {
}
end:
- if (result != NULL && tmp_filename != NULL) {
+ if (result != nullptr && tmp_filename != nullptr) {
*tmp_filename = filename_template;
} else {
gpr_free(filename_template);
diff --git a/src/core/lib/support/tmpfile_windows.c b/src/core/lib/gpr/tmpfile_windows.cc
index 47b4510a72..d486808418 100644
--- a/src/core/lib/support/tmpfile_windows.c
+++ b/src/core/lib/gpr/tmpfile_windows.cc
@@ -29,11 +29,11 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string_windows.h"
-#include "src/core/lib/support/tmpfile.h"
+#include "src/core/lib/gpr/string_windows.h"
+#include "src/core/lib/gpr/tmpfile.h"
-FILE *gpr_tmpfile(const char *prefix, char **tmp_filename_out) {
- FILE *result = NULL;
+FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
+ FILE* result = NULL;
LPTSTR template_string = NULL;
TCHAR tmp_path[MAX_PATH];
TCHAR tmp_filename[MAX_PATH];
diff --git a/src/core/lib/support/wrap_memcpy.c b/src/core/lib/gpr/wrap_memcpy.cc
index cff056dc3b..9b8608e056 100644
--- a/src/core/lib/support/wrap_memcpy.c
+++ b/src/core/lib/gpr/wrap_memcpy.cc
@@ -26,15 +26,17 @@
* Enable by setting LDFLAGS=-Wl,-wrap,memcpy when linking.
*/
+extern "C" {
#ifdef __linux__
#if defined(__x86_64__) && !defined(GPR_MUSL_LIBC_COMPAT)
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
-void *__wrap_memcpy(void *destination, const void *source, size_t num) {
+void* __wrap_memcpy(void* destination, const void* source, size_t num) {
return memcpy(destination, source, num);
}
#else /* !__x86_64__ */
-void *__wrap_memcpy(void *destination, const void *source, size_t num) {
+void* __wrap_memcpy(void* destination, const void* source, size_t num) {
return memmove(destination, source, num);
}
#endif
#endif
+}
diff --git a/src/core/lib/gprpp/README.md b/src/core/lib/gprpp/README.md
new file mode 100644
index 0000000000..eab018bb31
--- /dev/null
+++ b/src/core/lib/gprpp/README.md
@@ -0,0 +1,16 @@
+# GPR++ - Google Portable Runtime for C++
+
+The files in this directory contain various utility code for C++ code.
+None of this code is gRPC-specific; anything here may also be useful
+for other open source projects written in C++.
+
+Note that this is one of the few places in src/core where we allow
+the use of portability macros.
+
+Note that this is the only place in src/core where we allow
+use of the C++ standard library (i.e., anything in the `std::`
+namespace). And for now, we require that any use of the
+standard library is build-time-only -- i.e., we do not allow
+run-time dependencies on libstdc++. For more details, see
+[gRFC L6](/grpc/proposal/blob/master/L6-allow-c%2B%2B-in-grpc-core.md) and
+[Moving gRPC core to C++](/grpc/grpc/blob/master/doc/core/moving-to-c%2B%2B.md).
diff --git a/src/core/lib/gprpp/abstract.h b/src/core/lib/gprpp/abstract.h
new file mode 100644
index 0000000000..cc96edc49b
--- /dev/null
+++ b/src/core/lib/gprpp/abstract.h
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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_CORE_LIB_GPRPP_ABSTRACT_H
+#define GRPC_CORE_LIB_GPRPP_ABSTRACT_H
+
+// This is needed to support abstract base classes in the c core. Since gRPC
+// doesn't have a c++ runtime, it will hit a linker error on delete unless
+// we define a virtual operator delete. See this blog for more info:
+// https://eli.thegreenplace.net/2015/c-deleting-destructors-and-virtual-operator-delete/
+#define GRPC_ABSTRACT_BASE_CLASS \
+ static void operator delete(void* p) { abort(); }
+
+// gRPC currently can't depend on libstdc++, so we can't use "= 0" for
+// pure virtual methods. Instead, we use this macro.
+#define GRPC_ABSTRACT \
+ { GPR_ASSERT(false); }
+
+#endif /* GRPC_CORE_LIB_GPRPP_ABSTRACT_H */
diff --git a/src/core/lib/support/atomic.h b/src/core/lib/gprpp/atomic.h
index 73c59ae3cd..8b08fc4e9c 100644
--- a/src/core/lib/support/atomic.h
+++ b/src/core/lib/gprpp/atomic.h
@@ -16,15 +16,15 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_ATOMIC_H
-#define GRPC_CORE_LIB_SUPPORT_ATOMIC_H
+#ifndef GRPC_CORE_LIB_GPRPP_ATOMIC_H
+#define GRPC_CORE_LIB_GPRPP_ATOMIC_H
#include <grpc/support/port_platform.h>
#ifdef GPR_HAS_CXX11_ATOMIC
-#include "src/core/lib/support/atomic_with_std.h"
+#include "src/core/lib/gprpp/atomic_with_std.h"
#else
-#include "src/core/lib/support/atomic_with_atm.h"
+#include "src/core/lib/gprpp/atomic_with_atm.h"
#endif
-#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_H */
+#endif /* GRPC_CORE_LIB_GPRPP_ATOMIC_H */
diff --git a/src/core/lib/support/atomic_with_atm.h b/src/core/lib/gprpp/atomic_with_atm.h
index fe00e9b5bc..6abf0bc38d 100644
--- a/src/core/lib/support/atomic_with_atm.h
+++ b/src/core/lib/gprpp/atomic_with_atm.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_ATM_H
-#define GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_ATM_H
+#ifndef GRPC_CORE_LIB_GPRPP_ATOMIC_WITH_ATM_H
+#define GRPC_CORE_LIB_GPRPP_ATOMIC_WITH_ATM_H
#include <grpc/support/atm.h>
@@ -52,4 +52,4 @@ class atomic<bool> {
} // namespace grpc_core
-#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_ATM_H */
+#endif /* GRPC_CORE_LIB_GPRPP_ATOMIC_WITH_ATM_H */
diff --git a/src/core/lib/support/atomic_with_std.h b/src/core/lib/gprpp/atomic_with_std.h
index c7a92f7012..83322b81c1 100644
--- a/src/core/lib/support/atomic_with_std.h
+++ b/src/core/lib/gprpp/atomic_with_std.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_STD_H
-#define GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_STD_H
+#ifndef GRPC_CORE_LIB_GPRPP_ATOMIC_WITH_STD_H
+#define GRPC_CORE_LIB_GPRPP_ATOMIC_WITH_STD_H
#include <atomic>
@@ -30,4 +30,4 @@ typedef std::memory_order memory_order;
} // namespace grpc_core
-#endif /* GRPC_CORE_LIB_SUPPORT_ATOMIC_WITH_STD_H */
+#endif /* GRPC_CORE_LIB_GPRPP_ATOMIC_WITH_STD_H */
diff --git a/src/core/lib/gprpp/debug_location.h b/src/core/lib/gprpp/debug_location.h
new file mode 100644
index 0000000000..287761beaf
--- /dev/null
+++ b/src/core/lib/gprpp/debug_location.h
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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_CORE_LIB_GPRPP_DEBUG_LOCATION_H
+#define GRPC_CORE_LIB_GPRPP_DEBUG_LOCATION_H
+
+namespace grpc_core {
+
+// Used for tracking file and line where a call is made for debug builds.
+// No-op for non-debug builds.
+// Callers can use the DEBUG_LOCATION macro in either case.
+#ifndef NDEBUG
+class DebugLocation {
+ public:
+ DebugLocation(const char* file, int line) : file_(file), line_(line) {}
+ bool Log() const { return true; }
+ const char* file() const { return file_; }
+ int line() const { return line_; }
+
+ private:
+ const char* file_;
+ const int line_;
+};
+#define DEBUG_LOCATION ::grpc_core::DebugLocation(__FILE__, __LINE__)
+#else
+class DebugLocation {
+ public:
+ bool Log() const { return false; }
+ const char* file() const { return nullptr; }
+ int line() const { return -1; }
+};
+#define DEBUG_LOCATION ::grpc_core::DebugLocation()
+#endif
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_GPRPP_DEBUG_LOCATION_H */
diff --git a/src/core/lib/gprpp/inlined_vector.h b/src/core/lib/gprpp/inlined_vector.h
new file mode 100644
index 0000000000..2ced3d74b8
--- /dev/null
+++ b/src/core/lib/gprpp/inlined_vector.h
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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_CORE_LIB_GPRPP_INLINED_VECTOR_H
+#define GRPC_CORE_LIB_GPRPP_INLINED_VECTOR_H
+
+#include <cassert>
+
+#include "src/core/lib/gprpp/memory.h"
+
+namespace grpc_core {
+
+// NOTE: We eventually want to use absl::InlinedVector here. However,
+// there are currently build problems that prevent us from using absl.
+// In the interim, we define a custom implementation as a place-holder,
+// with the intent to eventually replace this with the absl
+// implementation.
+//
+// This place-holder implementation does not implement the full set of
+// functionality from the absl version; it has just the methods that we
+// currently happen to need in gRPC. If additional functionality is
+// needed before this gets replaced with the absl version, it can be
+// added, with the following proviso:
+//
+// ANY METHOD ADDED HERE MUST COMPLY WITH THE INTERFACE IN THE absl
+// IMPLEMENTATION!
+//
+// TODO(nnoble, roth): Replace this with absl::InlinedVector once we
+// integrate absl into the gRPC build system in a usable way.
+template <typename T, size_t N>
+class InlinedVector {
+ public:
+ InlinedVector() { init_data(); }
+ ~InlinedVector() { destroy_elements(); }
+
+ // For now, we do not support copying.
+ InlinedVector(const InlinedVector&) = delete;
+ InlinedVector& operator=(const InlinedVector&) = delete;
+
+ T& operator[](size_t offset) {
+ assert(offset < size_);
+ if (offset < N) {
+ return *reinterpret_cast<T*>(inline_ + offset);
+ } else {
+ return dynamic_[offset - N];
+ }
+ }
+
+ const T& operator[](size_t offset) const {
+ assert(offset < size_);
+ if (offset < N) {
+ return *reinterpret_cast<const T*>(inline_ + offset);
+ } else {
+ return dynamic_[offset - N];
+ }
+ }
+
+ template <typename... Args>
+ void emplace_back(Args&&... args) {
+ if (size_ < N) {
+ new (&inline_[size_]) T(std::forward<Args>(args)...);
+ } else {
+ if (size_ - N == dynamic_capacity_) {
+ size_t new_capacity =
+ dynamic_capacity_ == 0 ? 2 : dynamic_capacity_ * 2;
+ T* new_dynamic = static_cast<T*>(gpr_malloc(sizeof(T) * new_capacity));
+ for (size_t i = 0; i < dynamic_capacity_; ++i) {
+ new (&new_dynamic[i]) T(std::move(dynamic_[i]));
+ dynamic_[i].~T();
+ }
+ gpr_free(dynamic_);
+ dynamic_ = new_dynamic;
+ dynamic_capacity_ = new_capacity;
+ }
+ new (&dynamic_[size_ - N]) T(std::forward<Args>(args)...);
+ }
+ ++size_;
+ }
+
+ void push_back(const T& value) { emplace_back(value); }
+
+ void push_back(T&& value) { emplace_back(std::move(value)); }
+
+ size_t size() const { return size_; }
+
+ void clear() {
+ destroy_elements();
+ init_data();
+ }
+
+ private:
+ void init_data() {
+ dynamic_ = nullptr;
+ size_ = 0;
+ dynamic_capacity_ = 0;
+ }
+
+ void destroy_elements() {
+ for (size_t i = 0; i < size_ && i < N; ++i) {
+ T& value = *reinterpret_cast<T*>(inline_ + i);
+ value.~T();
+ }
+ if (size_ > N) { // Avoid subtracting two signed values.
+ for (size_t i = 0; i < size_ - N; ++i) {
+ dynamic_[i].~T();
+ }
+ }
+ gpr_free(dynamic_);
+ }
+
+ typename std::aligned_storage<sizeof(T)>::type inline_[N];
+ T* dynamic_;
+ size_t size_;
+ size_t dynamic_capacity_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_GPRPP_INLINED_VECTOR_H */
diff --git a/src/core/lib/gprpp/manual_constructor.h b/src/core/lib/gprpp/manual_constructor.h
new file mode 100644
index 0000000000..cee38abc1b
--- /dev/null
+++ b/src/core/lib/gprpp/manual_constructor.h
@@ -0,0 +1,211 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_GPRPP_MANUAL_CONSTRUCTOR_H
+#define GRPC_CORE_LIB_GPRPP_MANUAL_CONSTRUCTOR_H
+
+// manually construct a region of memory with some type
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <new>
+#include <type_traits>
+#include <utility>
+
+#include <grpc/support/log.h>
+
+namespace grpc_core {
+
+// this contains templated helpers needed to implement the ManualConstructors
+// in this file.
+namespace manual_ctor_impl {
+
+// is_one_of returns true it a class, Member, is present in a variadic list of
+// classes, List.
+template <class Member, class... List>
+class is_one_of;
+
+template <class Member, class... List>
+class is_one_of<Member, Member, List...> {
+ public:
+ static constexpr const bool value = true;
+};
+
+template <class Member, class A, class... List>
+class is_one_of<Member, A, List...> {
+ public:
+ static constexpr const bool value = is_one_of<Member, List...>::value;
+};
+
+template <class Member>
+class is_one_of<Member> {
+ public:
+ static constexpr const bool value = false;
+};
+
+// max_size_of returns sizeof(Type) for the largest type in the variadic list
+// of classes, Types.
+template <class... Types>
+class max_size_of;
+
+template <class A>
+class max_size_of<A> {
+ public:
+ static constexpr const size_t value = sizeof(A);
+};
+
+template <class A, class... B>
+class max_size_of<A, B...> {
+ public:
+ static constexpr const size_t value = sizeof(A) > max_size_of<B...>::value
+ ? sizeof(A)
+ : max_size_of<B...>::value;
+};
+
+// max_size_of returns alignof(Type) for the largest type in the variadic list
+// of classes, Types.
+template <class... Types>
+class max_align_of;
+
+template <class A>
+class max_align_of<A> {
+ public:
+ static constexpr const size_t value = alignof(A);
+};
+
+template <class A, class... B>
+class max_align_of<A, B...> {
+ public:
+ static constexpr const size_t value = alignof(A) > max_align_of<B...>::value
+ ? alignof(A)
+ : max_align_of<B...>::value;
+};
+
+} // namespace manual_ctor_impl
+
+template <class BaseType, class... DerivedTypes>
+class PolymorphicManualConstructor {
+ public:
+ // No constructor or destructor because one of the most useful uses of
+ // this class is as part of a union, and members of a union could not have
+ // constructors or destructors till C++11. And, anyway, the whole point of
+ // this class is to bypass constructor and destructor.
+
+ BaseType* get() { return reinterpret_cast<BaseType*>(&space_); }
+ const BaseType* get() const {
+ return reinterpret_cast<const BaseType*>(&space_);
+ }
+
+ BaseType* operator->() { return get(); }
+ const BaseType* operator->() const { return get(); }
+
+ BaseType& operator*() { return *get(); }
+ const BaseType& operator*() const { return *get(); }
+
+ template <class DerivedType>
+ void Init() {
+ FinishInit(new (&space_) DerivedType);
+ }
+
+ // Init() constructs the Type instance using the given arguments
+ // (which are forwarded to Type's constructor).
+ //
+ // Note that Init() with no arguments performs default-initialization,
+ // not zero-initialization (i.e it behaves the same as "new Type;", not
+ // "new Type();"), so it will leave non-class types uninitialized.
+ template <class DerivedType, typename... Ts>
+ void Init(Ts&&... args) {
+ FinishInit(new (&space_) DerivedType(std::forward<Ts>(args)...));
+ }
+
+ // Init() that is equivalent to copy and move construction.
+ // Enables usage like this:
+ // ManualConstructor<std::vector<int>> v;
+ // v.Init({1, 2, 3});
+ template <class DerivedType>
+ void Init(const DerivedType& x) {
+ FinishInit(new (&space_) DerivedType(x));
+ }
+ template <class DerivedType>
+ void Init(DerivedType&& x) {
+ FinishInit(new (&space_) DerivedType(std::move(x)));
+ }
+
+ void Destroy() { get()->~BaseType(); }
+
+ private:
+ template <class DerivedType>
+ void FinishInit(DerivedType* p) {
+ static_assert(
+ manual_ctor_impl::is_one_of<DerivedType, DerivedTypes...>::value,
+ "DerivedType must be one of the predeclared DerivedTypes");
+ GPR_ASSERT(reinterpret_cast<BaseType*>(static_cast<DerivedType*>(p)) == p);
+ }
+
+ typename std::aligned_storage<
+ grpc_core::manual_ctor_impl::max_size_of<DerivedTypes...>::value,
+ grpc_core::manual_ctor_impl::max_align_of<DerivedTypes...>::value>::type
+ space_;
+};
+
+template <typename Type>
+class ManualConstructor {
+ public:
+ // No constructor or destructor because one of the most useful uses of
+ // this class is as part of a union, and members of a union could not have
+ // constructors or destructors till C++11. And, anyway, the whole point of
+ // this class is to bypass constructor and destructor.
+
+ Type* get() { return reinterpret_cast<Type*>(&space_); }
+ const Type* get() const { return reinterpret_cast<const Type*>(&space_); }
+
+ Type* operator->() { return get(); }
+ const Type* operator->() const { return get(); }
+
+ Type& operator*() { return *get(); }
+ const Type& operator*() const { return *get(); }
+
+ void Init() { new (&space_) Type; }
+
+ // Init() constructs the Type instance using the given arguments
+ // (which are forwarded to Type's constructor).
+ //
+ // Note that Init() with no arguments performs default-initialization,
+ // not zero-initialization (i.e it behaves the same as "new Type;", not
+ // "new Type();"), so it will leave non-class types uninitialized.
+ template <typename... Ts>
+ void Init(Ts&&... args) {
+ new (&space_) Type(std::forward<Ts>(args)...);
+ }
+
+ // Init() that is equivalent to copy and move construction.
+ // Enables usage like this:
+ // ManualConstructor<std::vector<int>> v;
+ // v.Init({1, 2, 3});
+ void Init(const Type& x) { new (&space_) Type(x); }
+ void Init(Type&& x) { new (&space_) Type(std::move(x)); }
+
+ void Destroy() { get()->~Type(); }
+
+ private:
+ typename std::aligned_storage<sizeof(Type), alignof(Type)>::type space_;
+};
+
+} // namespace grpc_core
+
+#endif
diff --git a/src/core/lib/support/memory.h b/src/core/lib/gprpp/memory.h
index dc3d32e1c2..17f42f5983 100644
--- a/src/core/lib/support/memory.h
+++ b/src/core/lib/gprpp/memory.h
@@ -16,11 +16,12 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_MEMORY_H
-#define GRPC_CORE_LIB_SUPPORT_MEMORY_H
+#ifndef GRPC_CORE_LIB_GPRPP_MEMORY_H
+#define GRPC_CORE_LIB_GPRPP_MEMORY_H
#include <grpc/support/alloc.h>
+#include <limits>
#include <memory>
#include <utility>
@@ -54,6 +55,46 @@ inline UniquePtr<T> MakeUnique(Args&&... args) {
return UniquePtr<T>(New<T>(std::forward<Args>(args)...));
}
+// an allocator that uses gpr_malloc/gpr_free
+template <class T>
+class Allocator {
+ public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef std::false_type propagate_on_container_move_assignment;
+ template <class U>
+ struct rebind {
+ typedef Allocator<U> other;
+ };
+ typedef std::true_type is_always_equal;
+
+ pointer address(reference x) const { return &x; }
+ const_pointer address(const_reference x) const { return &x; }
+ pointer allocate(std::size_t n,
+ std::allocator<void>::const_pointer hint = nullptr) {
+ return static_cast<pointer>(gpr_malloc(n * sizeof(T)));
+ }
+ void deallocate(T* p, std::size_t n) { gpr_free(p); }
+ size_t max_size() const {
+ return std::numeric_limits<size_type>::max() / sizeof(value_type);
+ }
+ void construct(pointer p, const_reference val) { new ((void*)p) T(val); }
+ template <class U, class... Args>
+ void construct(U* p, Args&&... args) {
+ ::new ((void*)p) U(std::forward<Args>(args)...);
+ }
+ void destroy(pointer p) { p->~T(); }
+ template <class U>
+ void destroy(U* p) {
+ p->~U();
+ }
+};
+
} // namespace grpc_core
-#endif /* GRPC_CORE_LIB_SUPPORT_MEMORY_H */
+#endif /* GRPC_CORE_LIB_GPRPP_MEMORY_H */
diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h
new file mode 100644
index 0000000000..50199730c9
--- /dev/null
+++ b/src/core/lib/gprpp/orphanable.h
@@ -0,0 +1,171 @@
+/*
+ *
+ * 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_CORE_LIB_GPRPP_ORPHANABLE_H
+#define GRPC_CORE_LIB_GPRPP_ORPHANABLE_H
+
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+
+#include <memory>
+
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/abstract.h"
+#include "src/core/lib/gprpp/debug_location.h"
+#include "src/core/lib/gprpp/memory.h"
+
+namespace grpc_core {
+
+// A base class for orphanable objects, which have one external owner
+// but are not necessarily destroyed immediately when the external owner
+// gives up ownership. Instead, the owner calls the object's Orphan()
+// method, and the object then takes responsibility for its own cleanup
+// and destruction.
+class Orphanable {
+ public:
+ // Gives up ownership of the object. The implementation must arrange
+ // to eventually destroy the object without further interaction from the
+ // caller.
+ virtual void Orphan() GRPC_ABSTRACT;
+
+ // Not copyable or movable.
+ Orphanable(const Orphanable&) = delete;
+ Orphanable& operator=(const Orphanable&) = delete;
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ Orphanable() {}
+ virtual ~Orphanable() {}
+};
+
+template <typename T>
+class OrphanableDelete {
+ public:
+ void operator()(T* p) { p->Orphan(); }
+};
+
+template <typename T, typename Deleter = OrphanableDelete<T>>
+using OrphanablePtr = std::unique_ptr<T, Deleter>;
+
+template <typename T, typename... Args>
+inline OrphanablePtr<T> MakeOrphanable(Args&&... args) {
+ return OrphanablePtr<T>(New<T>(std::forward<Args>(args)...));
+}
+
+// A type of Orphanable with internal ref-counting.
+class InternallyRefCounted : public Orphanable {
+ public:
+ // Not copyable nor movable.
+ InternallyRefCounted(const InternallyRefCounted&) = delete;
+ InternallyRefCounted& operator=(const InternallyRefCounted&) = delete;
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ InternallyRefCounted() { gpr_ref_init(&refs_, 1); }
+ virtual ~InternallyRefCounted() {}
+
+ void Ref() { gpr_ref(&refs_); }
+
+ void Unref() {
+ if (gpr_unref(&refs_)) {
+ Delete(this);
+ }
+ }
+
+ // Allow Delete() to access destructor.
+ template <typename T>
+ friend void Delete(T*);
+
+ private:
+ gpr_refcount refs_;
+};
+
+// An alternative version of the InternallyRefCounted base class that
+// supports tracing. This is intended to be used in cases where the
+// object will be handled both by idiomatic C++ code using smart
+// 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.
+class InternallyRefCountedWithTracing : public Orphanable {
+ public:
+ // Not copyable nor movable.
+ InternallyRefCountedWithTracing(const InternallyRefCountedWithTracing&) =
+ delete;
+ InternallyRefCountedWithTracing& operator=(
+ const InternallyRefCountedWithTracing&) = delete;
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ // Allow Delete() to access destructor.
+ template <typename T>
+ friend void Delete(T*);
+
+ InternallyRefCountedWithTracing()
+ : InternallyRefCountedWithTracing(static_cast<TraceFlag*>(nullptr)) {}
+
+ explicit InternallyRefCountedWithTracing(TraceFlag* trace_flag)
+ : trace_flag_(trace_flag) {
+ gpr_ref_init(&refs_, 1);
+ }
+
+#ifdef NDEBUG
+ explicit InternallyRefCountedWithTracing(DebugOnlyTraceFlag* trace_flag)
+ : InternallyRefCountedWithTracing() {}
+#endif
+
+ virtual ~InternallyRefCountedWithTracing() {}
+
+ void Ref() { gpr_ref(&refs_); }
+
+ void Ref(const DebugLocation& location, const char* reason) {
+ 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();
+ }
+
+ void Unref() {
+ if (gpr_unref(&refs_)) {
+ Delete(this);
+ }
+ }
+
+ void Unref(const DebugLocation& location, const char* reason) {
+ 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 unref %" PRIdPTR " -> %" PRIdPTR " %s",
+ trace_flag_->name(), this, location.file(), location.line(),
+ old_refs, old_refs - 1, reason);
+ }
+ Unref();
+ }
+
+ private:
+ TraceFlag* trace_flag_ = nullptr;
+ gpr_refcount refs_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_GPRPP_ORPHANABLE_H */
diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h
new file mode 100644
index 0000000000..c68118a71a
--- /dev/null
+++ b/src/core/lib/gprpp/ref_counted.h
@@ -0,0 +1,133 @@
+/*
+ *
+ * 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_CORE_LIB_GPRPP_REF_COUNTED_H
+#define GRPC_CORE_LIB_GPRPP_REF_COUNTED_H
+
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/abstract.h"
+#include "src/core/lib/gprpp/debug_location.h"
+#include "src/core/lib/gprpp/memory.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().
+class RefCounted {
+ public:
+ void Ref() { gpr_ref(&refs_); }
+
+ void Unref() {
+ if (gpr_unref(&refs_)) {
+ Delete(this);
+ }
+ }
+
+ // Not copyable nor movable.
+ RefCounted(const RefCounted&) = delete;
+ RefCounted& operator=(const RefCounted&) = delete;
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ // Allow Delete() to access destructor.
+ template <typename T>
+ friend void Delete(T*);
+
+ RefCounted() { gpr_ref_init(&refs_, 1); }
+
+ virtual ~RefCounted() {}
+
+ private:
+ gpr_refcount refs_;
+};
+
+// An alternative version of the RefCounted base class that
+// supports tracing. This is intended to be used in cases where the
+// object will be handled both by idiomatic C++ code using smart
+// 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.
+class RefCountedWithTracing {
+ public:
+ void Ref() { gpr_ref(&refs_); }
+
+ void Ref(const DebugLocation& location, const char* reason) {
+ 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();
+ }
+
+ void Unref() {
+ if (gpr_unref(&refs_)) {
+ Delete(this);
+ }
+ }
+
+ void Unref(const DebugLocation& location, const char* reason) {
+ 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 unref %" PRIdPTR " -> %" PRIdPTR " %s",
+ trace_flag_->name(), this, location.file(), location.line(),
+ old_refs, old_refs - 1, reason);
+ }
+ Unref();
+ }
+
+ // Not copyable nor movable.
+ RefCountedWithTracing(const RefCountedWithTracing&) = delete;
+ RefCountedWithTracing& operator=(const RefCountedWithTracing&) = delete;
+
+ GRPC_ABSTRACT_BASE_CLASS
+
+ protected:
+ // Allow Delete() to access destructor.
+ template <typename T>
+ friend void Delete(T*);
+
+ RefCountedWithTracing()
+ : RefCountedWithTracing(static_cast<TraceFlag*>(nullptr)) {}
+
+ explicit RefCountedWithTracing(TraceFlag* trace_flag)
+ : trace_flag_(trace_flag) {
+ gpr_ref_init(&refs_, 1);
+ }
+
+#ifdef NDEBUG
+ explicit RefCountedWithTracing(DebugOnlyTraceFlag* trace_flag)
+ : RefCountedWithTracing() {}
+#endif
+
+ virtual ~RefCountedWithTracing() {}
+
+ private:
+ TraceFlag* trace_flag_ = nullptr;
+ gpr_refcount refs_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_GPRPP_REF_COUNTED_H */
diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h
new file mode 100644
index 0000000000..dda0f00d79
--- /dev/null
+++ b/src/core/lib/gprpp/ref_counted_ptr.h
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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_CORE_LIB_GPRPP_REF_COUNTED_PTR_H
+#define GRPC_CORE_LIB_GPRPP_REF_COUNTED_PTR_H
+
+#include <utility>
+
+#include "src/core/lib/gprpp/memory.h"
+
+namespace grpc_core {
+
+// A smart pointer class for objects that provide Ref() and Unref() methods,
+// such as those provided by the RefCounted base class.
+template <typename T>
+class RefCountedPtr {
+ public:
+ RefCountedPtr() {}
+
+ // If value is non-null, we take ownership of a ref to it.
+ explicit RefCountedPtr(T* value) { value_ = value; }
+
+ // Move support.
+ RefCountedPtr(RefCountedPtr&& other) {
+ value_ = other.value_;
+ other.value_ = nullptr;
+ }
+ RefCountedPtr& operator=(RefCountedPtr&& other) {
+ if (value_ != nullptr) value_->Unref();
+ value_ = other.value_;
+ other.value_ = nullptr;
+ return *this;
+ }
+
+ // Copy support.
+ RefCountedPtr(const RefCountedPtr& other) {
+ if (other.value_ != nullptr) other.value_->Ref();
+ 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 (value_ != nullptr) value_->Unref();
+ value_ = other.value_;
+ return *this;
+ }
+
+ ~RefCountedPtr() {
+ if (value_ != nullptr) value_->Unref();
+ }
+
+ // If value is non-null, we take ownership of a ref to it.
+ void reset(T* value = nullptr) {
+ if (value_ != nullptr) value_->Unref();
+ value_ = value;
+ }
+
+ T* get() const { return value_; }
+
+ T& operator*() const { return *value_; }
+ T* operator->() const { return value_; }
+
+ bool operator==(const RefCountedPtr& other) const {
+ return value_ == other.value_;
+ }
+ bool operator==(const T* other) const { return value_ == other; }
+ bool operator!=(const RefCountedPtr& other) const {
+ return value_ != other.value_;
+ }
+ bool operator!=(const T* other) const { return value_ != other; }
+
+ private:
+ T* value_ = nullptr;
+};
+
+template <typename T, typename... Args>
+inline RefCountedPtr<T> MakeRefCounted(Args&&... args) {
+ return RefCountedPtr<T>(New<T>(std::forward<Args>(args)...));
+}
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_GPRPP_REF_COUNTED_PTR_H */
diff --git a/src/core/lib/http/format_request.c b/src/core/lib/http/format_request.cc
index 88fb0ab0b6..473fa71790 100644
--- a/src/core/lib/http/format_request.c
+++ b/src/core/lib/http/format_request.cc
@@ -26,10 +26,10 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-static void fill_common_header(const grpc_httpcli_request *request,
- gpr_strvec *buf, bool connection_close) {
+static void fill_common_header(const grpc_httpcli_request* request,
+ gpr_strvec* buf, bool connection_close) {
size_t i;
gpr_strvec_add(buf, gpr_strdup(request->http.path));
gpr_strvec_add(buf, gpr_strdup(" HTTP/1.0\r\n"));
@@ -51,9 +51,9 @@ static void fill_common_header(const grpc_httpcli_request *request,
}
grpc_slice grpc_httpcli_format_get_request(
- const grpc_httpcli_request *request) {
+ const grpc_httpcli_request* request) {
gpr_strvec out;
- char *flat;
+ char* flat;
size_t flat_len;
gpr_strvec_init(&out);
@@ -67,11 +67,11 @@ grpc_slice grpc_httpcli_format_get_request(
return grpc_slice_new(flat, flat_len, gpr_free);
}
-grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
- const char *body_bytes,
+grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
+ const char* body_bytes,
size_t body_size) {
gpr_strvec out;
- char *tmp;
+ char* tmp;
size_t out_len;
size_t i;
@@ -98,7 +98,7 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
gpr_strvec_destroy(&out);
if (body_bytes) {
- tmp = (char *)gpr_realloc(tmp, out_len + body_size);
+ tmp = (char*)gpr_realloc(tmp, out_len + body_size);
memcpy(tmp + out_len, body_bytes, body_size);
out_len += body_size;
}
@@ -107,14 +107,14 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
}
grpc_slice grpc_httpcli_format_connect_request(
- const grpc_httpcli_request *request) {
+ const grpc_httpcli_request* request) {
gpr_strvec out;
gpr_strvec_init(&out);
gpr_strvec_add(&out, gpr_strdup("CONNECT "));
fill_common_header(request, &out, false);
gpr_strvec_add(&out, gpr_strdup("\r\n"));
size_t flat_len;
- char *flat = gpr_strvec_flatten(&out, &flat_len);
+ char* flat = gpr_strvec_flatten(&out, &flat_len);
gpr_strvec_destroy(&out);
return grpc_slice_new(flat, flat_len, gpr_free);
}
diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h
index 12b42e42fa..c1919651f9 100644
--- a/src/core/lib/http/format_request.h
+++ b/src/core/lib/http/format_request.h
@@ -22,11 +22,11 @@
#include <grpc/slice.h>
#include "src/core/lib/http/httpcli.h"
-grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request);
-grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
- const char *body_bytes,
+grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request* request);
+grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
+ const char* body_bytes,
size_t body_size);
grpc_slice grpc_httpcli_format_connect_request(
- const grpc_httpcli_request *request);
+ const grpc_httpcli_request* request);
#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */
diff --git a/src/core/lib/http/httpcli.c b/src/core/lib/http/httpcli.c
deleted file mode 100644
index db995943a9..0000000000
--- a/src/core/lib/http/httpcli.c
+++ /dev/null
@@ -1,321 +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/http/httpcli.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/http/format_request.h"
-#include "src/core/lib/http/parser.h"
-#include "src/core/lib/iomgr/endpoint.h"
-#include "src/core/lib/iomgr/iomgr_internal.h"
-#include "src/core/lib/iomgr/resolve_address.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/iomgr/tcp_client.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
-
-typedef struct {
- grpc_slice request_text;
- grpc_http_parser parser;
- grpc_resolved_addresses *addresses;
- size_t next_address;
- grpc_endpoint *ep;
- char *host;
- char *ssl_host_override;
- gpr_timespec deadline;
- int have_read_byte;
- const grpc_httpcli_handshaker *handshaker;
- grpc_closure *on_done;
- grpc_httpcli_context *context;
- grpc_polling_entity *pollent;
- grpc_iomgr_object iomgr_obj;
- grpc_slice_buffer incoming;
- grpc_slice_buffer outgoing;
- grpc_closure on_read;
- grpc_closure done_write;
- grpc_closure connected;
- grpc_error *overall_error;
- grpc_resource_quota *resource_quota;
-} internal_request;
-
-static grpc_httpcli_get_override g_get_override = NULL;
-static grpc_httpcli_post_override g_post_override = NULL;
-
-static void plaintext_handshake(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *endpoint, const char *host,
- gpr_timespec deadline,
- void (*on_done)(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_endpoint *endpoint)) {
- on_done(exec_ctx, arg, endpoint);
-}
-
-const grpc_httpcli_handshaker grpc_httpcli_plaintext = {"http",
- plaintext_handshake};
-
-void grpc_httpcli_context_init(grpc_httpcli_context *context) {
- context->pollset_set = grpc_pollset_set_create();
-}
-
-void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx,
- grpc_httpcli_context *context) {
- grpc_pollset_set_destroy(exec_ctx, context->pollset_set);
-}
-
-static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
- grpc_error *due_to_error);
-
-static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
- grpc_error *error) {
- grpc_polling_entity_del_from_pollset_set(exec_ctx, req->pollent,
- req->context->pollset_set);
- GRPC_CLOSURE_SCHED(exec_ctx, req->on_done, error);
- grpc_http_parser_destroy(&req->parser);
- if (req->addresses != NULL) {
- grpc_resolved_addresses_destroy(req->addresses);
- }
- if (req->ep != NULL) {
- grpc_endpoint_destroy(exec_ctx, req->ep);
- }
- grpc_slice_unref_internal(exec_ctx, req->request_text);
- gpr_free(req->host);
- gpr_free(req->ssl_host_override);
- grpc_iomgr_unregister_object(&req->iomgr_obj);
- grpc_slice_buffer_destroy_internal(exec_ctx, &req->incoming);
- grpc_slice_buffer_destroy_internal(exec_ctx, &req->outgoing);
- GRPC_ERROR_UNREF(req->overall_error);
- grpc_resource_quota_unref_internal(exec_ctx, req->resource_quota);
- gpr_free(req);
-}
-
-static void append_error(internal_request *req, grpc_error *error) {
- if (req->overall_error == GRPC_ERROR_NONE) {
- req->overall_error =
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request");
- }
- grpc_resolved_address *addr = &req->addresses->addrs[req->next_address - 1];
- char *addr_text = grpc_sockaddr_to_uri(addr);
- req->overall_error = grpc_error_add_child(
- req->overall_error,
- grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_copied_string(addr_text)));
- gpr_free(addr_text);
-}
-
-static void do_read(grpc_exec_ctx *exec_ctx, internal_request *req) {
- grpc_endpoint_read(exec_ctx, req->ep, &req->incoming, &req->on_read);
-}
-
-static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *error) {
- internal_request *req = (internal_request *)user_data;
- size_t i;
-
- for (i = 0; i < req->incoming.count; i++) {
- if (GRPC_SLICE_LENGTH(req->incoming.slices[i])) {
- req->have_read_byte = 1;
- grpc_error *err =
- grpc_http_parser_parse(&req->parser, req->incoming.slices[i], NULL);
- if (err != GRPC_ERROR_NONE) {
- finish(exec_ctx, req, err);
- return;
- }
- }
- }
-
- if (error == GRPC_ERROR_NONE) {
- do_read(exec_ctx, req);
- } else if (!req->have_read_byte) {
- next_address(exec_ctx, req, GRPC_ERROR_REF(error));
- } else {
- finish(exec_ctx, req, grpc_http_parser_eof(&req->parser));
- }
-}
-
-static void on_written(grpc_exec_ctx *exec_ctx, internal_request *req) {
- do_read(exec_ctx, req);
-}
-
-static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- internal_request *req = (internal_request *)arg;
- if (error == GRPC_ERROR_NONE) {
- on_written(exec_ctx, req);
- } else {
- next_address(exec_ctx, req, GRPC_ERROR_REF(error));
- }
-}
-
-static void start_write(grpc_exec_ctx *exec_ctx, internal_request *req) {
- grpc_slice_ref_internal(req->request_text);
- grpc_slice_buffer_add(&req->outgoing, req->request_text);
- grpc_endpoint_write(exec_ctx, req->ep, &req->outgoing, &req->done_write);
-}
-
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *ep) {
- internal_request *req = (internal_request *)arg;
-
- if (!ep) {
- next_address(exec_ctx, req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Unexplained handshake failure"));
- return;
- }
-
- req->ep = ep;
- start_write(exec_ctx, req);
-}
-
-static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- internal_request *req = (internal_request *)arg;
-
- if (!req->ep) {
- next_address(exec_ctx, req, GRPC_ERROR_REF(error));
- return;
- }
- req->handshaker->handshake(
- exec_ctx, req, req->ep,
- req->ssl_host_override ? req->ssl_host_override : req->host,
- req->deadline, on_handshake_done);
-}
-
-static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
- grpc_error *error) {
- grpc_resolved_address *addr;
- if (error != GRPC_ERROR_NONE) {
- append_error(req, error);
- }
- if (req->next_address == req->addresses->naddrs) {
- finish(exec_ctx, req,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Failed HTTP requests to all targets", &req->overall_error, 1));
- return;
- }
- addr = &req->addresses->addrs[req->next_address++];
- GRPC_CLOSURE_INIT(&req->connected, on_connected, req,
- grpc_schedule_on_exec_ctx);
- grpc_arg arg = grpc_channel_arg_pointer_create(
- (char *)GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
- grpc_resource_quota_arg_vtable());
- grpc_channel_args args = {1, &arg};
- grpc_tcp_client_connect(exec_ctx, &req->connected, &req->ep,
- req->context->pollset_set, &args, addr,
- req->deadline);
-}
-
-static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- internal_request *req = (internal_request *)arg;
- if (error != GRPC_ERROR_NONE) {
- finish(exec_ctx, req, GRPC_ERROR_REF(error));
- return;
- }
- req->next_address = 0;
- next_address(exec_ctx, req, GRPC_ERROR_NONE);
-}
-
-static void internal_request_begin(grpc_exec_ctx *exec_ctx,
- grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response,
- const char *name, grpc_slice request_text) {
- internal_request *req =
- (internal_request *)gpr_malloc(sizeof(internal_request));
- memset(req, 0, sizeof(*req));
- req->request_text = request_text;
- grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);
- req->on_done = on_done;
- req->deadline = deadline;
- req->handshaker =
- request->handshaker ? request->handshaker : &grpc_httpcli_plaintext;
- req->context = context;
- req->pollent = pollent;
- req->overall_error = GRPC_ERROR_NONE;
- req->resource_quota = grpc_resource_quota_ref_internal(resource_quota);
- GRPC_CLOSURE_INIT(&req->on_read, on_read, req, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_INIT(&req->done_write, done_write, req,
- grpc_schedule_on_exec_ctx);
- grpc_slice_buffer_init(&req->incoming);
- grpc_slice_buffer_init(&req->outgoing);
- grpc_iomgr_register_object(&req->iomgr_obj, name);
- req->host = gpr_strdup(request->host);
- req->ssl_host_override = gpr_strdup(request->ssl_host_override);
-
- GPR_ASSERT(pollent);
- grpc_polling_entity_add_to_pollset_set(exec_ctx, req->pollent,
- req->context->pollset_set);
- grpc_resolve_address(
- exec_ctx, request->host, req->handshaker->default_port,
- req->context->pollset_set,
- GRPC_CLOSURE_CREATE(on_resolved, req, grpc_schedule_on_exec_ctx),
- &req->addresses);
-}
-
-void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
- char *name;
- if (g_get_override &&
- g_get_override(exec_ctx, request, deadline, on_done, response)) {
- return;
- }
- gpr_asprintf(&name, "HTTP:GET:%s:%s", request->host, request->http.path);
- internal_request_begin(exec_ctx, context, pollent, resource_quota, request,
- deadline, on_done, response, name,
- grpc_httpcli_format_get_request(request));
- gpr_free(name);
-}
-
-void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
- char *name;
- if (g_post_override &&
- g_post_override(exec_ctx, request, body_bytes, body_size, deadline,
- on_done, response)) {
- return;
- }
- gpr_asprintf(&name, "HTTP:POST:%s:%s", request->host, request->http.path);
- internal_request_begin(
- exec_ctx, context, pollent, resource_quota, request, deadline, on_done,
- response, name,
- grpc_httpcli_format_post_request(request, body_bytes, body_size));
- gpr_free(name);
-}
-
-void grpc_httpcli_set_override(grpc_httpcli_get_override get,
- grpc_httpcli_post_override post) {
- g_get_override = get;
- g_post_override = post;
-}
diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc
new file mode 100644
index 0000000000..c43c92b57d
--- /dev/null
+++ b/src/core/lib/http/httpcli.cc
@@ -0,0 +1,302 @@
+/*
+ *
+ * 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/http/httpcli.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/http/format_request.h"
+#include "src/core/lib/http/parser.h"
+#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/iomgr/iomgr_internal.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/tcp_client.h"
+#include "src/core/lib/slice/slice_internal.h"
+
+typedef struct {
+ grpc_slice request_text;
+ grpc_http_parser parser;
+ grpc_resolved_addresses* addresses;
+ size_t next_address;
+ grpc_endpoint* ep;
+ char* host;
+ char* ssl_host_override;
+ grpc_millis deadline;
+ int have_read_byte;
+ const grpc_httpcli_handshaker* handshaker;
+ grpc_closure* on_done;
+ grpc_httpcli_context* context;
+ grpc_polling_entity* pollent;
+ grpc_iomgr_object iomgr_obj;
+ grpc_slice_buffer incoming;
+ grpc_slice_buffer outgoing;
+ grpc_closure on_read;
+ grpc_closure done_write;
+ grpc_closure connected;
+ grpc_error* overall_error;
+ grpc_resource_quota* resource_quota;
+} internal_request;
+
+static grpc_httpcli_get_override g_get_override = nullptr;
+static grpc_httpcli_post_override g_post_override = nullptr;
+
+static void plaintext_handshake(void* arg, grpc_endpoint* endpoint,
+ const char* host, grpc_millis deadline,
+ void (*on_done)(void* arg,
+ grpc_endpoint* endpoint)) {
+ on_done(arg, endpoint);
+}
+
+const grpc_httpcli_handshaker grpc_httpcli_plaintext = {"http",
+ plaintext_handshake};
+
+void grpc_httpcli_context_init(grpc_httpcli_context* context) {
+ context->pollset_set = grpc_pollset_set_create();
+}
+
+void grpc_httpcli_context_destroy(grpc_httpcli_context* context) {
+ grpc_pollset_set_destroy(context->pollset_set);
+}
+
+static void next_address(internal_request* req, grpc_error* due_to_error);
+
+static void finish(internal_request* req, grpc_error* error) {
+ grpc_polling_entity_del_from_pollset_set(req->pollent,
+ req->context->pollset_set);
+ GRPC_CLOSURE_SCHED(req->on_done, error);
+ grpc_http_parser_destroy(&req->parser);
+ if (req->addresses != nullptr) {
+ grpc_resolved_addresses_destroy(req->addresses);
+ }
+ if (req->ep != nullptr) {
+ grpc_endpoint_destroy(req->ep);
+ }
+ grpc_slice_unref_internal(req->request_text);
+ gpr_free(req->host);
+ gpr_free(req->ssl_host_override);
+ grpc_iomgr_unregister_object(&req->iomgr_obj);
+ grpc_slice_buffer_destroy_internal(&req->incoming);
+ grpc_slice_buffer_destroy_internal(&req->outgoing);
+ GRPC_ERROR_UNREF(req->overall_error);
+ grpc_resource_quota_unref_internal(req->resource_quota);
+ gpr_free(req);
+}
+
+static void append_error(internal_request* req, grpc_error* error) {
+ if (req->overall_error == GRPC_ERROR_NONE) {
+ req->overall_error =
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request");
+ }
+ grpc_resolved_address* addr = &req->addresses->addrs[req->next_address - 1];
+ char* addr_text = grpc_sockaddr_to_uri(addr);
+ req->overall_error = grpc_error_add_child(
+ req->overall_error,
+ grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
+ grpc_slice_from_copied_string(addr_text)));
+ gpr_free(addr_text);
+}
+
+static void do_read(internal_request* req) {
+ grpc_endpoint_read(req->ep, &req->incoming, &req->on_read);
+}
+
+static void on_read(void* user_data, grpc_error* error) {
+ internal_request* req = (internal_request*)user_data;
+ size_t i;
+
+ for (i = 0; i < req->incoming.count; i++) {
+ if (GRPC_SLICE_LENGTH(req->incoming.slices[i])) {
+ req->have_read_byte = 1;
+ grpc_error* err = grpc_http_parser_parse(
+ &req->parser, req->incoming.slices[i], nullptr);
+ if (err != GRPC_ERROR_NONE) {
+ finish(req, err);
+ return;
+ }
+ }
+ }
+
+ if (error == GRPC_ERROR_NONE) {
+ do_read(req);
+ } else if (!req->have_read_byte) {
+ next_address(req, GRPC_ERROR_REF(error));
+ } else {
+ finish(req, grpc_http_parser_eof(&req->parser));
+ }
+}
+
+static void on_written(internal_request* req) { do_read(req); }
+
+static void done_write(void* arg, grpc_error* error) {
+ internal_request* req = (internal_request*)arg;
+ if (error == GRPC_ERROR_NONE) {
+ on_written(req);
+ } else {
+ next_address(req, GRPC_ERROR_REF(error));
+ }
+}
+
+static void start_write(internal_request* req) {
+ grpc_slice_ref_internal(req->request_text);
+ grpc_slice_buffer_add(&req->outgoing, req->request_text);
+ grpc_endpoint_write(req->ep, &req->outgoing, &req->done_write);
+}
+
+static void on_handshake_done(void* arg, grpc_endpoint* ep) {
+ internal_request* req = (internal_request*)arg;
+
+ if (!ep) {
+ next_address(req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Unexplained handshake failure"));
+ return;
+ }
+
+ req->ep = ep;
+ start_write(req);
+}
+
+static void on_connected(void* arg, grpc_error* error) {
+ internal_request* req = (internal_request*)arg;
+
+ if (!req->ep) {
+ next_address(req, GRPC_ERROR_REF(error));
+ return;
+ }
+ req->handshaker->handshake(
+ req, req->ep, req->ssl_host_override ? req->ssl_host_override : req->host,
+ req->deadline, on_handshake_done);
+}
+
+static void next_address(internal_request* req, grpc_error* error) {
+ grpc_resolved_address* addr;
+ if (error != GRPC_ERROR_NONE) {
+ append_error(req, error);
+ }
+ if (req->next_address == req->addresses->naddrs) {
+ finish(req,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Failed HTTP requests to all targets", &req->overall_error, 1));
+ return;
+ }
+ addr = &req->addresses->addrs[req->next_address++];
+ GRPC_CLOSURE_INIT(&req->connected, on_connected, req,
+ grpc_schedule_on_exec_ctx);
+ grpc_arg arg = grpc_channel_arg_pointer_create(
+ (char*)GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
+ grpc_resource_quota_arg_vtable());
+ grpc_channel_args args = {1, &arg};
+ grpc_tcp_client_connect(&req->connected, &req->ep, req->context->pollset_set,
+ &args, addr, req->deadline);
+}
+
+static void on_resolved(void* arg, grpc_error* error) {
+ internal_request* req = (internal_request*)arg;
+ if (error != GRPC_ERROR_NONE) {
+ finish(req, GRPC_ERROR_REF(error));
+ return;
+ }
+ req->next_address = 0;
+ next_address(req, GRPC_ERROR_NONE);
+}
+
+static void internal_request_begin(grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response,
+ const char* name, grpc_slice request_text) {
+ internal_request* req =
+ (internal_request*)gpr_malloc(sizeof(internal_request));
+ memset(req, 0, sizeof(*req));
+ req->request_text = request_text;
+ grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);
+ req->on_done = on_done;
+ req->deadline = deadline;
+ req->handshaker =
+ request->handshaker ? request->handshaker : &grpc_httpcli_plaintext;
+ req->context = context;
+ req->pollent = pollent;
+ req->overall_error = GRPC_ERROR_NONE;
+ req->resource_quota = grpc_resource_quota_ref_internal(resource_quota);
+ GRPC_CLOSURE_INIT(&req->on_read, on_read, req, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&req->done_write, done_write, req,
+ grpc_schedule_on_exec_ctx);
+ grpc_slice_buffer_init(&req->incoming);
+ grpc_slice_buffer_init(&req->outgoing);
+ grpc_iomgr_register_object(&req->iomgr_obj, name);
+ req->host = gpr_strdup(request->host);
+ req->ssl_host_override = gpr_strdup(request->ssl_host_override);
+
+ GPR_ASSERT(pollent);
+ grpc_polling_entity_add_to_pollset_set(req->pollent,
+ req->context->pollset_set);
+ grpc_resolve_address(
+ request->host, req->handshaker->default_port, req->context->pollset_set,
+ GRPC_CLOSURE_CREATE(on_resolved, req, grpc_schedule_on_exec_ctx),
+ &req->addresses);
+}
+
+void grpc_httpcli_get(grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
+ char* name;
+ if (g_get_override && g_get_override(request, deadline, on_done, response)) {
+ return;
+ }
+ gpr_asprintf(&name, "HTTP:GET:%s:%s", request->host, request->http.path);
+ internal_request_begin(context, pollent, resource_quota, request, deadline,
+ on_done, response, name,
+ grpc_httpcli_format_get_request(request));
+ gpr_free(name);
+}
+
+void grpc_httpcli_post(grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
+ char* name;
+ if (g_post_override && g_post_override(request, body_bytes, body_size,
+ deadline, on_done, response)) {
+ return;
+ }
+ gpr_asprintf(&name, "HTTP:POST:%s:%s", request->host, request->http.path);
+ internal_request_begin(
+ context, pollent, resource_quota, request, deadline, on_done, response,
+ name, grpc_httpcli_format_post_request(request, body_bytes, body_size));
+ gpr_free(name);
+}
+
+void grpc_httpcli_set_override(grpc_httpcli_get_override get,
+ grpc_httpcli_post_override post) {
+ g_get_override = get;
+ g_post_override = post;
+}
diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h
index 809618695e..72d20cc7a3 100644
--- a/src/core/lib/http/httpcli.h
+++ b/src/core/lib/http/httpcli.h
@@ -36,15 +36,14 @@
TODO(ctiller): allow caching and capturing multiple requests for the
same content and combining them */
typedef struct grpc_httpcli_context {
- grpc_pollset_set *pollset_set;
+ grpc_pollset_set* pollset_set;
} grpc_httpcli_context;
typedef struct {
- const char *default_port;
- void (*handshake)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint,
- const char *host, gpr_timespec deadline,
- void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *endpoint));
+ const char* default_port;
+ void (*handshake)(void* arg, grpc_endpoint* endpoint, const char* host,
+ grpc_millis deadline,
+ void (*on_done)(void* arg, grpc_endpoint* endpoint));
} grpc_httpcli_handshaker;
extern const grpc_httpcli_handshaker grpc_httpcli_plaintext;
@@ -53,23 +52,22 @@ extern const grpc_httpcli_handshaker grpc_httpcli_ssl;
/* A request */
typedef struct grpc_httpcli_request {
/* The host name to connect to */
- char *host;
+ char* host;
/* The host to verify in the SSL handshake (or NULL) */
- char *ssl_host_override;
+ char* ssl_host_override;
/* The main part of the request
The following headers are supplied automatically and MUST NOT be set here:
Host, Connection, User-Agent */
grpc_http_request http;
/* handshaker to use ssl for the request */
- const grpc_httpcli_handshaker *handshaker;
+ const grpc_httpcli_handshaker* handshaker;
} grpc_httpcli_request;
/* Expose the parser response type as a httpcli response too */
typedef struct grpc_http_response grpc_httpcli_response;
-void grpc_httpcli_context_init(grpc_httpcli_context *context);
-void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx,
- grpc_httpcli_context *context);
+void grpc_httpcli_context_init(grpc_httpcli_context* context);
+void grpc_httpcli_context_destroy(grpc_httpcli_context* context);
/* Asynchronously perform a HTTP GET.
'context' specifies the http context under which to do the get
@@ -80,12 +78,12 @@ void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx,
destroyed once the call returns
'deadline' contains a deadline for the request (or gpr_inf_future)
'on_response' is a callback to report results to */
-void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_complete,
- grpc_httpcli_response *response);
+void grpc_httpcli_get(grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_complete,
+ grpc_httpcli_response* response);
/* Asynchronously perform a HTTP POST.
'context' specifies the http context under which to do the post
@@ -101,24 +99,25 @@ void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
lifetime of the request
'on_response' is a callback to report results to
Does not support ?var1=val1&var2=val2 in the path. */
-void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size,
- gpr_timespec deadline, grpc_closure *on_complete,
- grpc_httpcli_response *response);
+void grpc_httpcli_post(grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_complete,
+ grpc_httpcli_response* response);
/* override functions return 1 if they handled the request, 0 otherwise */
-typedef int (*grpc_httpcli_get_override)(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- gpr_timespec deadline,
- grpc_closure *on_complete,
- grpc_httpcli_response *response);
-typedef int (*grpc_httpcli_post_override)(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size, gpr_timespec deadline,
- grpc_closure *on_complete, grpc_httpcli_response *response);
+typedef int (*grpc_httpcli_get_override)(const grpc_httpcli_request* request,
+ grpc_millis deadline,
+ grpc_closure* on_complete,
+ grpc_httpcli_response* response);
+typedef int (*grpc_httpcli_post_override)(const grpc_httpcli_request* request,
+ const char* body_bytes,
+ size_t body_size,
+ grpc_millis deadline,
+ grpc_closure* on_complete,
+ grpc_httpcli_response* response);
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
grpc_httpcli_post_override post);
diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c
deleted file mode 100644
index c553fa3981..0000000000
--- a/src/core/lib/http/httpcli_security_connector.c
+++ /dev/null
@@ -1,185 +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/http/httpcli.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/channel/handshaker_registry.h"
-#include "src/core/lib/security/transport/security_handshaker.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/tsi/ssl_transport_security.h"
-#include "src/core/tsi/transport_security_adapter.h"
-
-typedef struct {
- grpc_channel_security_connector base;
- tsi_ssl_client_handshaker_factory *handshaker_factory;
- char *secure_peer_name;
-} grpc_httpcli_ssl_channel_security_connector;
-
-static void httpcli_ssl_destroy(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- grpc_httpcli_ssl_channel_security_connector *c =
- (grpc_httpcli_ssl_channel_security_connector *)sc;
- if (c->handshaker_factory != NULL) {
- tsi_ssl_client_handshaker_factory_unref(c->handshaker_factory);
- c->handshaker_factory = NULL;
- }
- if (c->secure_peer_name != NULL) gpr_free(c->secure_peer_name);
- gpr_free(sc);
-}
-
-static void httpcli_ssl_add_handshakers(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_httpcli_ssl_channel_security_connector *c =
- (grpc_httpcli_ssl_channel_security_connector *)sc;
- tsi_handshaker *handshaker = NULL;
- if (c->handshaker_factory != NULL) {
- tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
- c->handshaker_factory, c->secure_peer_name, &handshaker);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
- tsi_result_to_string(result));
- }
- }
- grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(handshaker), &sc->base));
-}
-
-static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- grpc_httpcli_ssl_channel_security_connector *c =
- (grpc_httpcli_ssl_channel_security_connector *)sc;
- grpc_error *error = GRPC_ERROR_NONE;
-
- /* Check the peer name. */
- if (c->secure_peer_name != NULL &&
- !tsi_ssl_peer_matches_name(&peer, c->secure_peer_name)) {
- char *msg;
- gpr_asprintf(&msg, "Peer name %s is not in peer certificate",
- c->secure_peer_name);
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
- gpr_free(msg);
- }
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
- tsi_peer_destruct(&peer);
-}
-
-static grpc_security_connector_vtable httpcli_ssl_vtable = {
- httpcli_ssl_destroy, httpcli_ssl_check_peer};
-
-static grpc_security_status httpcli_ssl_channel_security_connector_create(
- grpc_exec_ctx *exec_ctx, const char *pem_root_certs,
- const char *secure_peer_name, grpc_channel_security_connector **sc) {
- tsi_result result = TSI_OK;
- grpc_httpcli_ssl_channel_security_connector *c;
-
- if (secure_peer_name != NULL && pem_root_certs == NULL) {
- gpr_log(GPR_ERROR,
- "Cannot assert a secure peer name without a trust root.");
- return GRPC_SECURITY_ERROR;
- }
-
- c = gpr_zalloc(sizeof(grpc_httpcli_ssl_channel_security_connector));
-
- gpr_ref_init(&c->base.base.refcount, 1);
- c->base.base.vtable = &httpcli_ssl_vtable;
- if (secure_peer_name != NULL) {
- c->secure_peer_name = gpr_strdup(secure_peer_name);
- }
- result = tsi_create_ssl_client_handshaker_factory(
- NULL, pem_root_certs, NULL, NULL, 0, &c->handshaker_factory);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
- tsi_result_to_string(result));
- httpcli_ssl_destroy(exec_ctx, &c->base.base);
- *sc = NULL;
- return GRPC_SECURITY_ERROR;
- }
- c->base.add_handshakers = httpcli_ssl_add_handshakers;
- *sc = &c->base;
- return GRPC_SECURITY_OK;
-}
-
-/* handshaker */
-
-typedef struct {
- void (*func)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint);
- void *arg;
- grpc_handshake_manager *handshake_mgr;
-} on_done_closure;
-
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = arg;
- on_done_closure *c = args->user_data;
- if (error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(error);
- gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
-
- c->func(exec_ctx, c->arg, NULL);
- } else {
- grpc_channel_args_destroy(exec_ctx, args->args);
- grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
- gpr_free(args->read_buffer);
- c->func(exec_ctx, c->arg, args->endpoint);
- }
- grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
- gpr_free(c);
-}
-
-static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *tcp, const char *host,
- gpr_timespec deadline,
- void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *endpoint)) {
- on_done_closure *c = gpr_malloc(sizeof(*c));
- const char *pem_root_certs = grpc_get_default_ssl_roots();
- if (pem_root_certs == NULL) {
- gpr_log(GPR_ERROR, "Could not get default pem root certs.");
- on_done(exec_ctx, arg, NULL);
- gpr_free(c);
- return;
- }
- c->func = on_done;
- c->arg = arg;
- grpc_channel_security_connector *sc = NULL;
- GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
- exec_ctx, pem_root_certs, host, &sc) == GRPC_SECURITY_OK);
- grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base);
- grpc_channel_args args = {1, &channel_arg};
- c->handshake_mgr = grpc_handshake_manager_create();
- grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, &args, c->handshake_mgr);
- grpc_handshake_manager_do_handshake(
- exec_ctx, c->handshake_mgr, tcp, NULL /* channel_args */, deadline,
- NULL /* acceptor */, on_handshake_done, c /* user_data */);
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "httpcli");
-}
-
-const grpc_httpcli_handshaker grpc_httpcli_ssl = {"https", ssl_handshake};
diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc
new file mode 100644
index 0000000000..8664418144
--- /dev/null
+++ b/src/core/lib/http/httpcli_security_connector.cc
@@ -0,0 +1,193 @@
+/*
+ *
+ * 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/http/httpcli.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/channel/handshaker_registry.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/security/transport/security_handshaker.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/tsi/ssl_transport_security.h"
+#include "src/core/tsi/transport_security_adapter.h"
+
+typedef struct {
+ grpc_channel_security_connector base;
+ tsi_ssl_client_handshaker_factory* handshaker_factory;
+ char* secure_peer_name;
+} grpc_httpcli_ssl_channel_security_connector;
+
+static void httpcli_ssl_destroy(grpc_security_connector* sc) {
+ grpc_httpcli_ssl_channel_security_connector* c =
+ (grpc_httpcli_ssl_channel_security_connector*)sc;
+ if (c->handshaker_factory != nullptr) {
+ tsi_ssl_client_handshaker_factory_unref(c->handshaker_factory);
+ c->handshaker_factory = nullptr;
+ }
+ if (c->secure_peer_name != nullptr) gpr_free(c->secure_peer_name);
+ gpr_free(sc);
+}
+
+static void httpcli_ssl_add_handshakers(grpc_channel_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_httpcli_ssl_channel_security_connector* c =
+ (grpc_httpcli_ssl_channel_security_connector*)sc;
+ tsi_handshaker* handshaker = nullptr;
+ if (c->handshaker_factory != nullptr) {
+ tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
+ c->handshaker_factory, c->secure_peer_name, &handshaker);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
+ tsi_result_to_string(result));
+ }
+ }
+ grpc_handshake_manager_add(
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(handshaker), &sc->base));
+}
+
+static void httpcli_ssl_check_peer(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ grpc_httpcli_ssl_channel_security_connector* c =
+ (grpc_httpcli_ssl_channel_security_connector*)sc;
+ grpc_error* error = GRPC_ERROR_NONE;
+
+ /* Check the peer name. */
+ if (c->secure_peer_name != nullptr &&
+ !tsi_ssl_peer_matches_name(&peer, c->secure_peer_name)) {
+ char* msg;
+ gpr_asprintf(&msg, "Peer name %s is not in peer certificate",
+ c->secure_peer_name);
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ gpr_free(msg);
+ }
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
+ tsi_peer_destruct(&peer);
+}
+
+static int httpcli_ssl_cmp(grpc_security_connector* sc1,
+ grpc_security_connector* sc2) {
+ grpc_httpcli_ssl_channel_security_connector* c1 =
+ (grpc_httpcli_ssl_channel_security_connector*)sc1;
+ grpc_httpcli_ssl_channel_security_connector* c2 =
+ (grpc_httpcli_ssl_channel_security_connector*)sc2;
+ return strcmp(c1->secure_peer_name, c2->secure_peer_name);
+}
+
+static grpc_security_connector_vtable httpcli_ssl_vtable = {
+ httpcli_ssl_destroy, httpcli_ssl_check_peer, httpcli_ssl_cmp};
+
+static grpc_security_status httpcli_ssl_channel_security_connector_create(
+ const char* pem_root_certs, const char* secure_peer_name,
+ grpc_channel_security_connector** sc) {
+ tsi_result result = TSI_OK;
+ grpc_httpcli_ssl_channel_security_connector* c;
+
+ if (secure_peer_name != nullptr && pem_root_certs == nullptr) {
+ gpr_log(GPR_ERROR,
+ "Cannot assert a secure peer name without a trust root.");
+ return GRPC_SECURITY_ERROR;
+ }
+
+ c = (grpc_httpcli_ssl_channel_security_connector*)gpr_zalloc(
+ sizeof(grpc_httpcli_ssl_channel_security_connector));
+
+ gpr_ref_init(&c->base.base.refcount, 1);
+ c->base.base.vtable = &httpcli_ssl_vtable;
+ if (secure_peer_name != nullptr) {
+ c->secure_peer_name = gpr_strdup(secure_peer_name);
+ }
+ result = tsi_create_ssl_client_handshaker_factory(
+ nullptr, pem_root_certs, nullptr, nullptr, 0, &c->handshaker_factory);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
+ tsi_result_to_string(result));
+ httpcli_ssl_destroy(&c->base.base);
+ *sc = nullptr;
+ return GRPC_SECURITY_ERROR;
+ }
+ // We don't actually need a channel credentials object in this case,
+ // but we set it to a non-nullptr address so that we don't trigger
+ // assertions in grpc_channel_security_connector_cmp().
+ c->base.channel_creds = (grpc_channel_credentials*)1;
+ c->base.add_handshakers = httpcli_ssl_add_handshakers;
+ *sc = &c->base;
+ return GRPC_SECURITY_OK;
+}
+
+/* handshaker */
+
+typedef struct {
+ void (*func)(void* arg, grpc_endpoint* endpoint);
+ void* arg;
+ grpc_handshake_manager* handshake_mgr;
+} on_done_closure;
+
+static void on_handshake_done(void* arg, grpc_error* error) {
+ grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
+ on_done_closure* c = (on_done_closure*)args->user_data;
+ if (error != GRPC_ERROR_NONE) {
+ const char* msg = grpc_error_string(error);
+ gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
+
+ c->func(c->arg, nullptr);
+ } else {
+ grpc_channel_args_destroy(args->args);
+ grpc_slice_buffer_destroy_internal(args->read_buffer);
+ gpr_free(args->read_buffer);
+ c->func(c->arg, args->endpoint);
+ }
+ grpc_handshake_manager_destroy(c->handshake_mgr);
+ gpr_free(c);
+}
+
+static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host,
+ grpc_millis deadline,
+ void (*on_done)(void* arg, grpc_endpoint* endpoint)) {
+ on_done_closure* c = (on_done_closure*)gpr_malloc(sizeof(*c));
+ const char* pem_root_certs = grpc_get_default_ssl_roots();
+ if (pem_root_certs == nullptr) {
+ gpr_log(GPR_ERROR, "Could not get default pem root certs.");
+ on_done(arg, nullptr);
+ gpr_free(c);
+ return;
+ }
+ c->func = on_done;
+ c->arg = arg;
+ grpc_channel_security_connector* sc = nullptr;
+ GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
+ pem_root_certs, host, &sc) == GRPC_SECURITY_OK);
+ grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base);
+ grpc_channel_args args = {1, &channel_arg};
+ c->handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshakers_add(HANDSHAKER_CLIENT, &args, c->handshake_mgr);
+ grpc_handshake_manager_do_handshake(
+ c->handshake_mgr, nullptr /* interested_parties */, tcp,
+ nullptr /* channel_args */, deadline, nullptr /* acceptor */,
+ on_handshake_done, c /* user_data */);
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "httpcli");
+}
+
+const grpc_httpcli_handshaker grpc_httpcli_ssl = {"https", ssl_handshake};
diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.cc
index 0950bd655e..fb4eb234a7 100644
--- a/src/core/lib/http/parser.c
+++ b/src/core/lib/http/parser.cc
@@ -25,19 +25,19 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false, "http1");
+grpc_core::TraceFlag grpc_http1_trace(false, "http1");
-static char *buf2str(void *buffer, size_t length) {
- char *out = (char *)gpr_malloc(length + 1);
+static char* buf2str(void* buffer, size_t length) {
+ char* out = (char*)gpr_malloc(length + 1);
memcpy(out, buffer, length);
out[length] = 0;
return out;
}
-static grpc_error *handle_response_line(grpc_http_parser *parser) {
- uint8_t *beg = parser->cur_line;
- uint8_t *cur = beg;
- uint8_t *end = beg + parser->cur_line_length;
+static grpc_error* handle_response_line(grpc_http_parser* parser) {
+ uint8_t* beg = parser->cur_line;
+ uint8_t* cur = beg;
+ uint8_t* end = beg + parser->cur_line_length;
if (cur == end || *cur++ != 'H')
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Expected 'H'");
@@ -75,10 +75,10 @@ static grpc_error *handle_response_line(grpc_http_parser *parser) {
return GRPC_ERROR_NONE;
}
-static grpc_error *handle_request_line(grpc_http_parser *parser) {
- uint8_t *beg = parser->cur_line;
- uint8_t *cur = beg;
- uint8_t *end = beg + parser->cur_line_length;
+static grpc_error* handle_request_line(grpc_http_parser* parser) {
+ uint8_t* beg = parser->cur_line;
+ uint8_t* cur = beg;
+ uint8_t* end = beg + parser->cur_line_length;
uint8_t vers_major = 0;
uint8_t vers_minor = 0;
@@ -137,7 +137,7 @@ static grpc_error *handle_request_line(grpc_http_parser *parser) {
return GRPC_ERROR_NONE;
}
-static grpc_error *handle_first_line(grpc_http_parser *parser) {
+static grpc_error* handle_first_line(grpc_http_parser* parser) {
switch (parser->type) {
case GRPC_HTTP_REQUEST:
return handle_request_line(parser);
@@ -148,14 +148,14 @@ static grpc_error *handle_first_line(grpc_http_parser *parser) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here"));
}
-static grpc_error *add_header(grpc_http_parser *parser) {
- uint8_t *beg = parser->cur_line;
- uint8_t *cur = beg;
- uint8_t *end = beg + parser->cur_line_length;
- size_t *hdr_count = NULL;
- grpc_http_header **hdrs = NULL;
- grpc_http_header hdr = {NULL, NULL};
- grpc_error *error = GRPC_ERROR_NONE;
+static grpc_error* add_header(grpc_http_parser* parser) {
+ uint8_t* beg = parser->cur_line;
+ uint8_t* cur = beg;
+ uint8_t* end = beg + parser->cur_line_length;
+ size_t* hdr_count = nullptr;
+ grpc_http_header** hdrs = nullptr;
+ grpc_http_header hdr = {nullptr, nullptr};
+ grpc_error* error = GRPC_ERROR_NONE;
GPR_ASSERT(cur != end);
@@ -197,7 +197,7 @@ static grpc_error *add_header(grpc_http_parser *parser) {
if (*hdr_count == parser->hdr_capacity) {
parser->hdr_capacity =
GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
- *hdrs = (grpc_http_header *)gpr_realloc(
+ *hdrs = (grpc_http_header*)gpr_realloc(
*hdrs, parser->hdr_capacity * sizeof(**hdrs));
}
(*hdrs)[(*hdr_count)++] = hdr;
@@ -210,9 +210,9 @@ done:
return error;
}
-static grpc_error *finish_line(grpc_http_parser *parser,
- bool *found_body_start) {
- grpc_error *err;
+static grpc_error* finish_line(grpc_http_parser* parser,
+ bool* found_body_start) {
+ grpc_error* err;
switch (parser->state) {
case GRPC_HTTP_FIRST_LINE:
err = handle_first_line(parser);
@@ -239,9 +239,9 @@ static grpc_error *finish_line(grpc_http_parser *parser,
return GRPC_ERROR_NONE;
}
-static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
- size_t *body_length = NULL;
- char **body = NULL;
+static grpc_error* addbyte_body(grpc_http_parser* parser, uint8_t byte) {
+ size_t* body_length = nullptr;
+ char** body = nullptr;
if (parser->type == GRPC_HTTP_RESPONSE) {
body_length = &parser->http.response->body_length;
@@ -256,7 +256,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
if (*body_length == parser->body_capacity) {
parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
- *body = (char *)gpr_realloc((void *)*body, parser->body_capacity);
+ *body = (char*)gpr_realloc((void*)*body, parser->body_capacity);
}
(*body)[*body_length] = (char)byte;
(*body_length)++;
@@ -264,7 +264,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
return GRPC_ERROR_NONE;
}
-static bool check_line(grpc_http_parser *parser) {
+static bool check_line(grpc_http_parser* parser) {
if (parser->cur_line_length >= 2 &&
parser->cur_line[parser->cur_line_length - 2] == '\r' &&
parser->cur_line[parser->cur_line_length - 1] == '\n') {
@@ -288,13 +288,13 @@ static bool check_line(grpc_http_parser *parser) {
return false;
}
-static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte,
- bool *found_body_start) {
+static grpc_error* addbyte(grpc_http_parser* parser, uint8_t byte,
+ bool* found_body_start) {
switch (parser->state) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
- if (GRPC_TRACER_ON(grpc_http1_trace))
+ if (grpc_http1_trace.enabled())
gpr_log(GPR_ERROR, "HTTP header max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -312,8 +312,8 @@ static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte,
GPR_UNREACHABLE_CODE(return GRPC_ERROR_NONE);
}
-void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type,
- void *request_or_response) {
+void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type,
+ void* request_or_response) {
memset(parser, 0, sizeof(*parser));
parser->state = GRPC_HTTP_FIRST_LINE;
parser->type = type;
@@ -321,9 +321,9 @@ void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type,
parser->cur_line_end_length = 2;
}
-void grpc_http_parser_destroy(grpc_http_parser *parser) {}
+void grpc_http_parser_destroy(grpc_http_parser* parser) {}
-void grpc_http_request_destroy(grpc_http_request *request) {
+void grpc_http_request_destroy(grpc_http_request* request) {
size_t i;
gpr_free(request->body);
for (i = 0; i < request->hdr_count; i++) {
@@ -335,7 +335,7 @@ void grpc_http_request_destroy(grpc_http_request *request) {
gpr_free(request->path);
}
-void grpc_http_response_destroy(grpc_http_response *response) {
+void grpc_http_response_destroy(grpc_http_response* response) {
size_t i;
gpr_free(response->body);
for (i = 0; i < response->hdr_count; i++) {
@@ -345,19 +345,19 @@ void grpc_http_response_destroy(grpc_http_response *response) {
gpr_free(response->hdrs);
}
-grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice,
- size_t *start_of_body) {
+grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, grpc_slice slice,
+ size_t* start_of_body) {
for (size_t i = 0; i < GRPC_SLICE_LENGTH(slice); i++) {
bool found_body_start = false;
- grpc_error *err =
+ grpc_error* err =
addbyte(parser, GRPC_SLICE_START_PTR(slice)[i], &found_body_start);
if (err != GRPC_ERROR_NONE) return err;
- if (found_body_start && start_of_body != NULL) *start_of_body = i + 1;
+ if (found_body_start && start_of_body != nullptr) *start_of_body = i + 1;
}
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_http_parser_eof(grpc_http_parser *parser) {
+grpc_error* grpc_http_parser_eof(grpc_http_parser* parser) {
if (parser->state != GRPC_HTTP_BODY) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Did not finish headers");
}
diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h
index c8dced3901..5fef448019 100644
--- a/src/core/lib/http/parser.h
+++ b/src/core/lib/http/parser.h
@@ -29,8 +29,8 @@
/* A single header to be passed in a request */
typedef struct grpc_http_header {
- char *key;
- char *value;
+ char* key;
+ char* value;
} grpc_http_header;
typedef enum {
@@ -53,17 +53,17 @@ typedef enum {
/* A request */
typedef struct grpc_http_request {
/* Method of the request (e.g. GET, POST) */
- char *method;
+ char* method;
/* The path of the resource to fetch */
- char *path;
+ char* path;
/* HTTP version to use */
grpc_http_version version;
/* Headers attached to the request */
size_t hdr_count;
- grpc_http_header *hdrs;
+ grpc_http_header* hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
- char *body;
+ char* body;
} grpc_http_request;
/* A response */
@@ -72,10 +72,10 @@ typedef struct grpc_http_response {
int status;
/* Headers: count and key/values */
size_t hdr_count;
- grpc_http_header *hdrs;
+ grpc_http_header* hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
- char *body;
+ char* body;
} grpc_http_response;
typedef struct {
@@ -83,9 +83,9 @@ typedef struct {
grpc_http_type type;
union {
- grpc_http_response *response;
- grpc_http_request *request;
- void *request_or_response;
+ grpc_http_response* response;
+ grpc_http_request* request;
+ void* request_or_response;
} http;
size_t body_capacity;
size_t hdr_capacity;
@@ -95,18 +95,18 @@ typedef struct {
size_t cur_line_end_length;
} grpc_http_parser;
-void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type,
- void *request_or_response);
-void grpc_http_parser_destroy(grpc_http_parser *parser);
+void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type,
+ void* request_or_response);
+void grpc_http_parser_destroy(grpc_http_parser* parser);
/* Sets \a start_of_body to the offset in \a slice of the start of the body. */
-grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice,
- size_t *start_of_body);
-grpc_error *grpc_http_parser_eof(grpc_http_parser *parser);
+grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, grpc_slice slice,
+ size_t* start_of_body);
+grpc_error* grpc_http_parser_eof(grpc_http_parser* parser);
-void grpc_http_request_destroy(grpc_http_request *request);
-void grpc_http_response_destroy(grpc_http_response *response);
+void grpc_http_request_destroy(grpc_http_request* request);
+void grpc_http_response_destroy(grpc_http_response* response);
-extern grpc_tracer_flag grpc_http1_trace;
+extern grpc_core::TraceFlag grpc_http1_trace;
#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */
diff --git a/src/core/lib/support/block_annotate.h b/src/core/lib/iomgr/block_annotate.h
index 8e3ef7df65..a57873aabb 100644
--- a/src/core/lib/support/block_annotate.h
+++ b/src/core/lib/iomgr/block_annotate.h
@@ -16,20 +16,12 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
-#define GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
+#define GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
void gpr_thd_start_blocking_region();
void gpr_thd_end_blocking_region();
-#ifdef __cplusplus
-}
-#endif
-
/* These annotations identify the beginning and end of regions where
the code may block for reasons other than synchronization functions.
These include poll, epoll, and getaddrinfo. */
@@ -39,17 +31,27 @@ void gpr_thd_end_blocking_region();
do { \
gpr_thd_start_blocking_region(); \
} while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION \
- do { \
- gpr_thd_end_blocking_region(); \
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+ do { \
+ gpr_thd_end_blocking_region(); \
+ grpc_core::ExecCtx::Get()->InvalidateNow(); \
} while (0)
+#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
+ do { \
+ gpr_thd_end_blocking_region(); \
+ } while (0)
+
#else
#define GRPC_SCHEDULING_START_BLOCKING_REGION \
do { \
} while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION \
- do { \
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+ do { \
+ grpc_core::ExecCtx::Get()->InvalidateNow(); \
+ } while (0)
+#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
+ do { \
} while (0)
#endif
-#endif /* GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H */
+#endif /* GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H */
diff --git a/src/core/lib/iomgr/call_combiner.c b/src/core/lib/iomgr/call_combiner.cc
index 48d8eaec18..a9f48fb3c2 100644
--- a/src/core/lib/iomgr/call_combiner.c
+++ b/src/core/lib/iomgr/call_combiner.cc
@@ -18,10 +18,13 @@
#include "src/core/lib/iomgr/call_combiner.h"
+#include <inttypes.h>
+
#include <grpc/support/log.h>
+#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/profiling/timers.h"
-grpc_tracer_flag grpc_call_combiner_trace =
- GRPC_TRACER_INITIALIZER(false, "call_combiner");
+grpc_core::TraceFlag grpc_call_combiner_trace(false, "call_combiner");
static grpc_error* decode_cancel_state_error(gpr_atm cancel_state) {
if (cancel_state & 1) {
@@ -53,12 +56,12 @@ void grpc_call_combiner_destroy(grpc_call_combiner* call_combiner) {
#define DEBUG_FMT_ARGS
#endif
-void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
grpc_closure* closure,
grpc_error* error DEBUG_ARGS,
const char* reason) {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ GPR_TIMER_BEGIN("call_combiner_start", 0);
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG,
"==> grpc_call_combiner_start() [%p] closure=%p [" DEBUG_FMT_STR
"%s] error=%s",
@@ -67,72 +70,78 @@ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
}
size_t prev_size =
(size_t)gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)1);
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
prev_size + 1);
}
+ GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS();
if (prev_size == 0) {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED();
+
+ GPR_TIMER_MARK("call_combiner_initiate", 0);
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " EXECUTING IMMEDIATELY");
}
// Queue was empty, so execute this closure immediately.
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
+ GRPC_CLOSURE_SCHED(closure, error);
} else {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_INFO, " QUEUING");
}
// Queue was not empty, so add closure to queue.
closure->error_data.error = error;
gpr_mpscq_push(&call_combiner->queue, (gpr_mpscq_node*)closure);
}
+ GPR_TIMER_END("call_combiner_start", 0);
}
-void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner DEBUG_ARGS,
+void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS,
const char* reason) {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ GPR_TIMER_BEGIN("call_combiner_stop", 0);
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG,
"==> grpc_call_combiner_stop() [%p] [" DEBUG_FMT_STR "%s]",
call_combiner DEBUG_FMT_ARGS, reason);
}
size_t prev_size =
(size_t)gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)-1);
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
prev_size - 1);
}
GPR_ASSERT(prev_size >= 1);
if (prev_size > 1) {
while (true) {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " checking queue");
}
bool empty;
grpc_closure* closure = (grpc_closure*)gpr_mpscq_pop_and_check_end(
&call_combiner->queue, &empty);
- if (closure == NULL) {
+ if (closure == nullptr) {
// This can happen either due to a race condition within the mpscq
// code or because of a race with grpc_call_combiner_start().
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " queue returned no result; checking again");
}
continue;
}
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " EXECUTING FROM QUEUE: closure=%p error=%s",
closure, grpc_error_string(closure->error_data.error));
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, closure->error_data.error);
+ GRPC_CLOSURE_SCHED(closure, closure->error_data.error);
break;
}
- } else if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ } else if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, " queue empty");
}
+ GPR_TIMER_END("call_combiner_stop", 0);
}
-void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
grpc_closure* closure) {
+ GRPC_STATS_INC_CALL_COMBINER_SET_NOTIFY_ON_CANCEL();
while (true) {
// Decode original state.
gpr_atm original_state = gpr_atm_acq_load(&call_combiner->cancel_state);
@@ -140,18 +149,18 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
// If error is set, invoke the cancellation closure immediately.
// Otherwise, store the new closure.
if (original_error != GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG,
"call_combiner=%p: scheduling notify_on_cancel callback=%p "
"for pre-existing cancellation",
call_combiner, closure);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_REF(original_error));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_REF(original_error));
break;
} else {
if (gpr_atm_full_cas(&call_combiner->cancel_state, original_state,
(gpr_atm)closure)) {
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG, "call_combiner=%p: setting notify_on_cancel=%p",
call_combiner, closure);
}
@@ -160,12 +169,12 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
// up any resources they may be holding for the callback.
if (original_state != 0) {
closure = (grpc_closure*)original_state;
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG,
"call_combiner=%p: scheduling old cancel callback=%p",
call_combiner, closure);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
break;
}
@@ -174,9 +183,9 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_cancel(grpc_call_combiner* call_combiner,
grpc_error* error) {
+ GRPC_STATS_INC_CALL_COMBINER_CANCELLED();
while (true) {
gpr_atm original_state = gpr_atm_acq_load(&call_combiner->cancel_state);
grpc_error* original_error = decode_cancel_state_error(original_state);
@@ -188,12 +197,12 @@ void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
encode_cancel_state_error(error))) {
if (original_state != 0) {
grpc_closure* notify_on_cancel = (grpc_closure*)original_state;
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG,
"call_combiner=%p: scheduling notify_on_cancel callback=%p",
call_combiner, notify_on_cancel);
}
- GRPC_CLOSURE_SCHED(exec_ctx, notify_on_cancel, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(notify_on_cancel, GRPC_ERROR_REF(error));
}
break;
}
diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h
index 5cfb3f0c07..4814dbf8d2 100644
--- a/src/core/lib/iomgr/call_combiner.h
+++ b/src/core/lib/iomgr/call_combiner.h
@@ -23,9 +23,9 @@
#include <grpc/support/atm.h>
+#include "src/core/lib/gpr/mpscq.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/mpscq.h"
// A simple, lock-free mechanism for serializing activity related to a
// single call. This is similar to a combiner but is more lightweight.
@@ -36,7 +36,7 @@
// when it is done with the action that was kicked off by the original
// callback.
-extern grpc_tracer_flag grpc_call_combiner_trace;
+extern grpc_core::TraceFlag grpc_call_combiner_trace;
typedef struct {
gpr_atm size; // size_t, num closures in queue or currently executing
@@ -53,37 +53,29 @@ void grpc_call_combiner_init(grpc_call_combiner* call_combiner);
void grpc_call_combiner_destroy(grpc_call_combiner* call_combiner);
#ifndef NDEBUG
-#define GRPC_CALL_COMBINER_START(exec_ctx, call_combiner, closure, error, \
- reason) \
- grpc_call_combiner_start((exec_ctx), (call_combiner), (closure), (error), \
- __FILE__, __LINE__, (reason))
-#define GRPC_CALL_COMBINER_STOP(exec_ctx, call_combiner, reason) \
- grpc_call_combiner_stop((exec_ctx), (call_combiner), __FILE__, __LINE__, \
- (reason))
+#define GRPC_CALL_COMBINER_START(call_combiner, closure, error, reason) \
+ grpc_call_combiner_start((call_combiner), (closure), (error), __FILE__, \
+ __LINE__, (reason))
+#define GRPC_CALL_COMBINER_STOP(call_combiner, reason) \
+ grpc_call_combiner_stop((call_combiner), __FILE__, __LINE__, (reason))
/// Starts processing \a closure on \a call_combiner.
-void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
grpc_closure* closure, grpc_error* error,
const char* file, int line, const char* reason);
/// Yields the call combiner to the next closure in the queue, if any.
-void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_stop(grpc_call_combiner* call_combiner,
const char* file, int line, const char* reason);
#else
-#define GRPC_CALL_COMBINER_START(exec_ctx, call_combiner, closure, error, \
- reason) \
- grpc_call_combiner_start((exec_ctx), (call_combiner), (closure), (error), \
- (reason))
-#define GRPC_CALL_COMBINER_STOP(exec_ctx, call_combiner, reason) \
- grpc_call_combiner_stop((exec_ctx), (call_combiner), (reason))
+#define GRPC_CALL_COMBINER_START(call_combiner, closure, error, reason) \
+ grpc_call_combiner_start((call_combiner), (closure), (error), (reason))
+#define GRPC_CALL_COMBINER_STOP(call_combiner, reason) \
+ grpc_call_combiner_stop((call_combiner), (reason))
/// Starts processing \a closure on \a call_combiner.
-void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
grpc_closure* closure, grpc_error* error,
const char* reason);
/// Yields the call combiner to the next closure in the queue, if any.
-void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_stop(grpc_call_combiner* call_combiner,
const char* reason);
#endif
@@ -109,13 +101,11 @@ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
/// cancellation; this effectively unregisters the previously set closure.
/// However, most filters will not need to explicitly unregister their
/// callbacks, as this is done automatically when the call is destroyed.
-void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
grpc_closure* closure);
/// Indicates that the call has been cancelled.
-void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_cancel(grpc_call_combiner* call_combiner,
grpc_error* error);
#endif /* GRPC_CORE_LIB_IOMGR_CALL_COMBINER_H */
diff --git a/src/core/lib/iomgr/closure.c b/src/core/lib/iomgr/closure.c
deleted file mode 100644
index 00edefc6ae..0000000000
--- a/src/core/lib/iomgr/closure.c
+++ /dev/null
@@ -1,219 +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/iomgr/closure.h"
-
-#include <assert.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/profiling/timers.h"
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_closure = GRPC_TRACER_INITIALIZER(false, "closure");
-#endif
-
-#ifndef NDEBUG
-grpc_closure *grpc_closure_init(const char *file, int line,
- grpc_closure *closure, grpc_iomgr_cb_func cb,
- void *cb_arg,
- grpc_closure_scheduler *scheduler) {
-#else
-grpc_closure *grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb,
- void *cb_arg,
- grpc_closure_scheduler *scheduler) {
-#endif
- closure->cb = cb;
- closure->cb_arg = cb_arg;
- closure->scheduler = scheduler;
-#ifndef NDEBUG
- closure->scheduled = false;
- closure->file_initiated = NULL;
- closure->line_initiated = 0;
- closure->run = false;
- closure->file_created = file;
- closure->line_created = line;
-#endif
- return closure;
-}
-
-void grpc_closure_list_init(grpc_closure_list *closure_list) {
- closure_list->head = closure_list->tail = NULL;
-}
-
-bool grpc_closure_list_append(grpc_closure_list *closure_list,
- grpc_closure *closure, grpc_error *error) {
- if (closure == NULL) {
- GRPC_ERROR_UNREF(error);
- return false;
- }
- closure->error_data.error = error;
- closure->next_data.next = NULL;
- bool was_empty = (closure_list->head == NULL);
- if (was_empty) {
- closure_list->head = closure;
- } else {
- closure_list->tail->next_data.next = closure;
- }
- closure_list->tail = closure;
- return was_empty;
-}
-
-void grpc_closure_list_fail_all(grpc_closure_list *list,
- grpc_error *forced_failure) {
- for (grpc_closure *c = list->head; c != NULL; c = c->next_data.next) {
- if (c->error_data.error == GRPC_ERROR_NONE) {
- c->error_data.error = GRPC_ERROR_REF(forced_failure);
- }
- }
- GRPC_ERROR_UNREF(forced_failure);
-}
-
-bool grpc_closure_list_empty(grpc_closure_list closure_list) {
- return closure_list.head == NULL;
-}
-
-void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst) {
- if (src->head == NULL) {
- return;
- }
- if (dst->head == NULL) {
- *dst = *src;
- } else {
- dst->tail->next_data.next = src->head;
- dst->tail = src->tail;
- }
- src->head = src->tail = NULL;
-}
-
-typedef struct {
- grpc_iomgr_cb_func cb;
- void *cb_arg;
- grpc_closure wrapper;
-} wrapped_closure;
-
-static void closure_wrapper(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- wrapped_closure *wc = (wrapped_closure *)arg;
- grpc_iomgr_cb_func cb = wc->cb;
- void *cb_arg = wc->cb_arg;
- gpr_free(wc);
- cb(exec_ctx, cb_arg, error);
-}
-
-#ifndef NDEBUG
-grpc_closure *grpc_closure_create(const char *file, int line,
- grpc_iomgr_cb_func cb, void *cb_arg,
- grpc_closure_scheduler *scheduler) {
-#else
-grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg,
- grpc_closure_scheduler *scheduler) {
-#endif
- wrapped_closure *wc = (wrapped_closure *)gpr_malloc(sizeof(*wc));
- wc->cb = cb;
- wc->cb_arg = cb_arg;
-#ifndef NDEBUG
- grpc_closure_init(file, line, &wc->wrapper, closure_wrapper, wc, scheduler);
-#else
- grpc_closure_init(&wc->wrapper, closure_wrapper, wc, scheduler);
-#endif
- return &wc->wrapper;
-}
-
-#ifndef NDEBUG
-void grpc_closure_run(const char *file, int line, grpc_exec_ctx *exec_ctx,
- grpc_closure *c, grpc_error *error) {
-#else
-void grpc_closure_run(grpc_exec_ctx *exec_ctx, grpc_closure *c,
- grpc_error *error) {
-#endif
- GPR_TIMER_BEGIN("grpc_closure_run", 0);
- if (c != NULL) {
-#ifndef NDEBUG
- c->file_initiated = file;
- c->line_initiated = line;
- c->run = true;
-#endif
- assert(c->cb);
- c->scheduler->vtable->run(exec_ctx, c, error);
- } else {
- GRPC_ERROR_UNREF(error);
- }
- GPR_TIMER_END("grpc_closure_run", 0);
-}
-
-#ifndef NDEBUG
-void grpc_closure_sched(const char *file, int line, grpc_exec_ctx *exec_ctx,
- grpc_closure *c, grpc_error *error) {
-#else
-void grpc_closure_sched(grpc_exec_ctx *exec_ctx, grpc_closure *c,
- grpc_error *error) {
-#endif
- GPR_TIMER_BEGIN("grpc_closure_sched", 0);
- if (c != NULL) {
-#ifndef NDEBUG
- if (c->scheduled) {
- gpr_log(GPR_ERROR,
- "Closure already scheduled. (closure: %p, created: [%s:%d], "
- "previously scheduled at: [%s: %d] run?: %s",
- c, c->file_created, c->line_created, c->file_initiated,
- c->line_initiated, c->run ? "true" : "false");
- abort();
- }
- c->scheduled = true;
- c->file_initiated = file;
- c->line_initiated = line;
- c->run = false;
-#endif
- assert(c->cb);
- c->scheduler->vtable->sched(exec_ctx, c, error);
- } else {
- GRPC_ERROR_UNREF(error);
- }
- GPR_TIMER_END("grpc_closure_sched", 0);
-}
-
-#ifndef NDEBUG
-void grpc_closure_list_sched(const char *file, int line,
- grpc_exec_ctx *exec_ctx, grpc_closure_list *list) {
-#else
-void grpc_closure_list_sched(grpc_exec_ctx *exec_ctx, grpc_closure_list *list) {
-#endif
- grpc_closure *c = list->head;
- while (c != NULL) {
- grpc_closure *next = c->next_data.next;
-#ifndef NDEBUG
- if (c->scheduled) {
- gpr_log(GPR_ERROR,
- "Closure already scheduled. (closure: %p, created: [%s:%d], "
- "previously scheduled at: [%s: %d] run?: %s",
- c, c->file_created, c->line_created, c->file_initiated,
- c->line_initiated, c->run ? "true" : "false");
- abort();
- }
- c->scheduled = true;
- c->file_initiated = file;
- c->line_initiated = line;
- c->run = false;
-#endif
- assert(c->cb);
- c->scheduler->vtable->sched(exec_ctx, c, c->error_data.error);
- c = next;
- }
- list->head = list->tail = NULL;
-}
diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h
index cd32a4ba38..249fca6cd6 100644
--- a/src/core/lib/iomgr/closure.h
+++ b/src/core/lib/iomgr/closure.h
@@ -21,25 +21,22 @@
#include <grpc/support/port_platform.h>
-#include <grpc/impl/codegen/exec_ctx_fwd.h>
+#include <assert.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
#include <stdbool.h>
+#include "src/core/lib/gpr/mpscq.h"
#include "src/core/lib/iomgr/error.h"
-#include "src/core/lib/support/mpscq.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "src/core/lib/profiling/timers.h"
struct grpc_closure;
typedef struct grpc_closure grpc_closure;
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_closure;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_closure;
typedef struct grpc_closure_list {
- grpc_closure *head;
- grpc_closure *tail;
+ grpc_closure* head;
+ grpc_closure* tail;
} grpc_closure_list;
/** gRPC Callback definition.
@@ -49,24 +46,21 @@ typedef struct grpc_closure_list {
* describing what went wrong.
* Error contract: it is not the cb's job to unref this error;
* the closure scheduler will do that after the cb returns */
-typedef void (*grpc_iomgr_cb_func)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
+typedef void (*grpc_iomgr_cb_func)(void* arg, grpc_error* error);
typedef struct grpc_closure_scheduler grpc_closure_scheduler;
typedef struct grpc_closure_scheduler_vtable {
/* NOTE: for all these functions, closure->scheduler == the scheduler that was
used to find this vtable */
- void (*run)(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
- void (*sched)(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
- const char *name;
+ void (*run)(grpc_closure* closure, grpc_error* error);
+ void (*sched)(grpc_closure* closure, grpc_error* error);
+ const char* name;
} grpc_closure_scheduler_vtable;
/** Abstract type that can schedule closures for execution */
struct grpc_closure_scheduler {
- const grpc_closure_scheduler_vtable *vtable;
+ const grpc_closure_scheduler_vtable* vtable;
};
/** A closure over a grpc_iomgr_cb_func. */
@@ -74,7 +68,7 @@ struct grpc_closure {
/** Once queued, next indicates the next queued closure; before then, scratch
* space */
union {
- grpc_closure *next;
+ grpc_closure* next;
gpr_mpscq_node atm_next;
uintptr_t scratch;
} next_data;
@@ -83,15 +77,15 @@ struct grpc_closure {
grpc_iomgr_cb_func cb;
/** Arguments to be passed to "cb". */
- void *cb_arg;
+ void* cb_arg;
- /** Scheduler to schedule against: NULL to schedule against current execution
- context */
- grpc_closure_scheduler *scheduler;
+ /** Scheduler to schedule against: nullptr to schedule against current
+ execution context */
+ grpc_closure_scheduler* scheduler;
/** Once queued, the result of the closure. Before then: scratch space */
union {
- grpc_error *error;
+ grpc_error* error;
uintptr_t scratch;
} error_data;
@@ -100,109 +94,260 @@ struct grpc_closure {
#ifndef NDEBUG
bool scheduled;
bool run; // true = run, false = scheduled
- const char *file_created;
+ const char* file_created;
int line_created;
- const char *file_initiated;
+ const char* file_initiated;
int line_initiated;
#endif
};
+#ifndef NDEBUG
+inline grpc_closure* grpc_closure_init(const char* file, int line,
+ grpc_closure* closure,
+ grpc_iomgr_cb_func cb, void* cb_arg,
+ grpc_closure_scheduler* scheduler) {
+#else
+inline grpc_closure* grpc_closure_init(grpc_closure* closure,
+ grpc_iomgr_cb_func cb, void* cb_arg,
+ grpc_closure_scheduler* scheduler) {
+#endif
+ closure->cb = cb;
+ closure->cb_arg = cb_arg;
+ closure->scheduler = scheduler;
+#ifndef NDEBUG
+ closure->scheduled = false;
+ closure->file_initiated = nullptr;
+ closure->line_initiated = 0;
+ closure->run = false;
+ closure->file_created = file;
+ closure->line_created = line;
+#endif
+ return closure;
+}
+
/** Initializes \a closure with \a cb and \a cb_arg. Returns \a closure. */
#ifndef NDEBUG
-grpc_closure *grpc_closure_init(const char *file, int line,
- grpc_closure *closure, grpc_iomgr_cb_func cb,
- void *cb_arg,
- grpc_closure_scheduler *scheduler);
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler) \
grpc_closure_init(__FILE__, __LINE__, closure, cb, cb_arg, scheduler)
#else
-grpc_closure *grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb,
- void *cb_arg,
- grpc_closure_scheduler *scheduler);
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler) \
grpc_closure_init(closure, cb, cb_arg, scheduler)
#endif
+namespace closure_impl {
+
+typedef struct {
+ grpc_iomgr_cb_func cb;
+ void* cb_arg;
+ grpc_closure wrapper;
+} wrapped_closure;
+
+inline void closure_wrapper(void* arg, grpc_error* error) {
+ wrapped_closure* wc = (wrapped_closure*)arg;
+ grpc_iomgr_cb_func cb = wc->cb;
+ void* cb_arg = wc->cb_arg;
+ gpr_free(wc);
+ cb(cb_arg, error);
+}
+
+} // namespace closure_impl
+
+#ifndef NDEBUG
+inline grpc_closure* grpc_closure_create(const char* file, int line,
+ grpc_iomgr_cb_func cb, void* cb_arg,
+ grpc_closure_scheduler* scheduler) {
+#else
+inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg,
+ grpc_closure_scheduler* scheduler) {
+#endif
+ closure_impl::wrapped_closure* wc =
+ (closure_impl::wrapped_closure*)gpr_malloc(sizeof(*wc));
+ wc->cb = cb;
+ wc->cb_arg = cb_arg;
+#ifndef NDEBUG
+ grpc_closure_init(file, line, &wc->wrapper, closure_impl::closure_wrapper, wc,
+ scheduler);
+#else
+ grpc_closure_init(&wc->wrapper, closure_impl::closure_wrapper, wc, scheduler);
+#endif
+ return &wc->wrapper;
+}
+
/* Create a heap allocated closure: try to avoid except for very rare events */
#ifndef NDEBUG
-grpc_closure *grpc_closure_create(const char *file, int line,
- grpc_iomgr_cb_func cb, void *cb_arg,
- grpc_closure_scheduler *scheduler);
#define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler) \
grpc_closure_create(__FILE__, __LINE__, cb, cb_arg, scheduler)
#else
-grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg,
- grpc_closure_scheduler *scheduler);
#define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler) \
grpc_closure_create(cb, cb_arg, scheduler)
#endif
#define GRPC_CLOSURE_LIST_INIT \
- { NULL, NULL }
+ { nullptr, nullptr }
-void grpc_closure_list_init(grpc_closure_list *list);
+inline void grpc_closure_list_init(grpc_closure_list* closure_list) {
+ closure_list->head = closure_list->tail = nullptr;
+}
/** add \a closure to the end of \a list
and set \a closure's result to \a error
Returns true if \a list becomes non-empty */
-bool grpc_closure_list_append(grpc_closure_list *list, grpc_closure *closure,
- grpc_error *error);
+inline bool grpc_closure_list_append(grpc_closure_list* closure_list,
+ grpc_closure* closure, grpc_error* error) {
+ if (closure == nullptr) {
+ GRPC_ERROR_UNREF(error);
+ return false;
+ }
+ closure->error_data.error = error;
+ closure->next_data.next = nullptr;
+ bool was_empty = (closure_list->head == nullptr);
+ if (was_empty) {
+ closure_list->head = closure;
+ } else {
+ closure_list->tail->next_data.next = closure;
+ }
+ closure_list->tail = closure;
+ return was_empty;
+}
/** force all success bits in \a list to false */
-void grpc_closure_list_fail_all(grpc_closure_list *list,
- grpc_error *forced_failure);
+inline void grpc_closure_list_fail_all(grpc_closure_list* list,
+ grpc_error* forced_failure) {
+ for (grpc_closure* c = list->head; c != nullptr; c = c->next_data.next) {
+ if (c->error_data.error == GRPC_ERROR_NONE) {
+ c->error_data.error = GRPC_ERROR_REF(forced_failure);
+ }
+ }
+ GRPC_ERROR_UNREF(forced_failure);
+}
/** append all closures from \a src to \a dst and empty \a src. */
-void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst);
+inline void grpc_closure_list_move(grpc_closure_list* src,
+ grpc_closure_list* dst) {
+ if (src->head == nullptr) {
+ return;
+ }
+ if (dst->head == nullptr) {
+ *dst = *src;
+ } else {
+ dst->tail->next_data.next = src->head;
+ dst->tail = src->tail;
+ }
+ src->head = src->tail = nullptr;
+}
/** return whether \a list is empty. */
-bool grpc_closure_list_empty(grpc_closure_list list);
+inline bool grpc_closure_list_empty(grpc_closure_list closure_list) {
+ return closure_list.head == nullptr;
+}
+
+#ifndef NDEBUG
+inline void grpc_closure_run(const char* file, int line, grpc_closure* c,
+ grpc_error* error) {
+#else
+inline void grpc_closure_run(grpc_closure* c, grpc_error* error) {
+#endif
+ GPR_TIMER_BEGIN("grpc_closure_run", 0);
+ if (c != nullptr) {
+#ifndef NDEBUG
+ c->file_initiated = file;
+ c->line_initiated = line;
+ c->run = true;
+#endif
+ assert(c->cb);
+ c->scheduler->vtable->run(c, error);
+ } else {
+ GRPC_ERROR_UNREF(error);
+ }
+ GPR_TIMER_END("grpc_closure_run", 0);
+}
/** Run a closure directly. Caller ensures that no locks are being held above.
* Note that calling this at the end of a closure callback function itself is
* by definition safe. */
#ifndef NDEBUG
-void grpc_closure_run(const char *file, int line, grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_error *error);
-#define GRPC_CLOSURE_RUN(exec_ctx, closure, error) \
- grpc_closure_run(__FILE__, __LINE__, exec_ctx, closure, error)
+#define GRPC_CLOSURE_RUN(closure, error) \
+ grpc_closure_run(__FILE__, __LINE__, closure, error)
#else
-void grpc_closure_run(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
-#define GRPC_CLOSURE_RUN(exec_ctx, closure, error) \
- grpc_closure_run(exec_ctx, closure, error)
+#define GRPC_CLOSURE_RUN(closure, error) grpc_closure_run(closure, error)
#endif
-/** Schedule a closure to be run. Does not need to be run from a safe point. */
#ifndef NDEBUG
-void grpc_closure_sched(const char *file, int line, grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_error *error);
-#define GRPC_CLOSURE_SCHED(exec_ctx, closure, error) \
- grpc_closure_sched(__FILE__, __LINE__, exec_ctx, closure, error)
+inline void grpc_closure_sched(const char* file, int line, grpc_closure* c,
+ grpc_error* error) {
#else
-void grpc_closure_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
-#define GRPC_CLOSURE_SCHED(exec_ctx, closure, error) \
- grpc_closure_sched(exec_ctx, closure, error)
+inline void grpc_closure_sched(grpc_closure* c, grpc_error* error) {
#endif
+ GPR_TIMER_BEGIN("grpc_closure_sched", 0);
+ if (c != nullptr) {
+#ifndef NDEBUG
+ if (c->scheduled) {
+ gpr_log(GPR_ERROR,
+ "Closure already scheduled. (closure: %p, created: [%s:%d], "
+ "previously scheduled at: [%s: %d] run?: %s",
+ c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated, c->run ? "true" : "false");
+ abort();
+ }
+ c->scheduled = true;
+ c->file_initiated = file;
+ c->line_initiated = line;
+ c->run = false;
+#endif
+ assert(c->cb);
+ c->scheduler->vtable->sched(c, error);
+ } else {
+ GRPC_ERROR_UNREF(error);
+ }
+ GPR_TIMER_END("grpc_closure_sched", 0);
+}
-/** Schedule all closures in a list to be run. Does not need to be run from a
- * safe point. */
+/** Schedule a closure to be run. Does not need to be run from a safe point. */
#ifndef NDEBUG
-void grpc_closure_list_sched(const char *file, int line,
- grpc_exec_ctx *exec_ctx,
- grpc_closure_list *closure_list);
-#define GRPC_CLOSURE_LIST_SCHED(exec_ctx, closure_list) \
- grpc_closure_list_sched(__FILE__, __LINE__, exec_ctx, closure_list)
+#define GRPC_CLOSURE_SCHED(closure, error) \
+ grpc_closure_sched(__FILE__, __LINE__, closure, error)
#else
-void grpc_closure_list_sched(grpc_exec_ctx *exec_ctx,
- grpc_closure_list *closure_list);
-#define GRPC_CLOSURE_LIST_SCHED(exec_ctx, closure_list) \
- grpc_closure_list_sched(exec_ctx, closure_list)
+#define GRPC_CLOSURE_SCHED(closure, error) grpc_closure_sched(closure, error)
#endif
-#ifdef __cplusplus
+#ifndef NDEBUG
+inline void grpc_closure_list_sched(const char* file, int line,
+ grpc_closure_list* list) {
+#else
+inline void grpc_closure_list_sched(grpc_closure_list* list) {
+#endif
+ grpc_closure* c = list->head;
+ while (c != nullptr) {
+ grpc_closure* next = c->next_data.next;
+#ifndef NDEBUG
+ if (c->scheduled) {
+ gpr_log(GPR_ERROR,
+ "Closure already scheduled. (closure: %p, created: [%s:%d], "
+ "previously scheduled at: [%s: %d] run?: %s",
+ c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated, c->run ? "true" : "false");
+ abort();
+ }
+ c->scheduled = true;
+ c->file_initiated = file;
+ c->line_initiated = line;
+ c->run = false;
+#endif
+ assert(c->cb);
+ c->scheduler->vtable->sched(c, c->error_data.error);
+ c = next;
+ }
+ list->head = list->tail = nullptr;
}
+
+/** Schedule all closures in a list to be run. Does not need to be run from a
+ * safe point. */
+#ifndef NDEBUG
+#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
+ grpc_closure_list_sched(__FILE__, __LINE__, closure_list)
+#else
+#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
+ grpc_closure_list_sched(closure_list)
#endif
#endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */
diff --git a/src/core/lib/iomgr/combiner.c b/src/core/lib/iomgr/combiner.cc
index f899b25f10..e4d7a6abd8 100644
--- a/src/core/lib/iomgr/combiner.c
+++ b/src/core/lib/iomgr/combiner.cc
@@ -19,6 +19,7 @@
#include "src/core/lib/iomgr/combiner.h"
#include <assert.h>
+#include <inttypes.h>
#include <string.h>
#include <grpc/support/alloc.h>
@@ -28,21 +29,20 @@
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/profiling/timers.h"
-grpc_tracer_flag grpc_combiner_trace =
- GRPC_TRACER_INITIALIZER(false, "combiner");
+grpc_core::TraceFlag grpc_combiner_trace(false, "combiner");
-#define GRPC_COMBINER_TRACE(fn) \
- do { \
- if (GRPC_TRACER_ON(grpc_combiner_trace)) { \
- fn; \
- } \
+#define GRPC_COMBINER_TRACE(fn) \
+ do { \
+ if (grpc_combiner_trace.enabled()) { \
+ fn; \
+ } \
} while (0)
#define STATE_UNORPHANED 1
#define STATE_ELEM_COUNT_LOW_BIT 2
struct grpc_combiner {
- grpc_combiner *next_combiner_on_this_exec_ctx;
+ grpc_combiner* next_combiner_on_this_exec_ctx;
grpc_closure_scheduler scheduler;
grpc_closure_scheduler finally_scheduler;
gpr_mpscq queue;
@@ -61,20 +61,18 @@ struct grpc_combiner {
gpr_refcount refs;
};
-static void combiner_exec(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
-static void combiner_finally_exec(grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_error *error);
+static void combiner_exec(grpc_closure* closure, grpc_error* error);
+static void combiner_finally_exec(grpc_closure* closure, grpc_error* error);
static const grpc_closure_scheduler_vtable scheduler = {
combiner_exec, combiner_exec, "combiner:immediately"};
static const grpc_closure_scheduler_vtable finally_scheduler = {
combiner_finally_exec, combiner_finally_exec, "combiner:finally"};
-static void offload(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error);
+static void offload(void* arg, grpc_error* error);
-grpc_combiner *grpc_combiner_create(void) {
- grpc_combiner *lock = (grpc_combiner *)gpr_zalloc(sizeof(*lock));
+grpc_combiner* grpc_combiner_create(void) {
+ grpc_combiner* lock = (grpc_combiner*)gpr_zalloc(sizeof(*lock));
gpr_ref_init(&lock->refs, 1);
lock->scheduler.vtable = &scheduler;
lock->finally_scheduler.vtable = &finally_scheduler;
@@ -87,25 +85,25 @@ grpc_combiner *grpc_combiner_create(void) {
return lock;
}
-static void really_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
+static void really_destroy(grpc_combiner* lock) {
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p really_destroy", lock));
GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0);
gpr_mpscq_destroy(&lock->queue);
gpr_free(lock);
}
-static void start_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
+static void start_destroy(grpc_combiner* lock) {
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED);
GRPC_COMBINER_TRACE(gpr_log(
GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state));
if (old_state == 1) {
- really_destroy(exec_ctx, lock);
+ really_destroy(lock);
}
}
#ifndef NDEBUG
#define GRPC_COMBINER_DEBUG_SPAM(op, delta) \
- if (GRPC_TRACER_ON(grpc_combiner_trace)) { \
+ if (grpc_combiner_trace.enabled()) { \
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, \
"C:%p %s %" PRIdPTR " --> %" PRIdPTR " %s", lock, (op), \
gpr_atm_no_barrier_load(&lock->refs.count), \
@@ -115,66 +113,67 @@ static void start_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
#define GRPC_COMBINER_DEBUG_SPAM(op, delta)
#endif
-void grpc_combiner_unref(grpc_exec_ctx *exec_ctx,
- grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS) {
+void grpc_combiner_unref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM("UNREF", -1);
if (gpr_unref(&lock->refs)) {
- start_destroy(exec_ctx, lock);
+ start_destroy(lock);
}
}
-grpc_combiner *grpc_combiner_ref(grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS) {
+grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM(" REF", 1);
gpr_ref(&lock->refs);
return lock;
}
-static void push_last_on_exec_ctx(grpc_exec_ctx *exec_ctx,
- grpc_combiner *lock) {
- lock->next_combiner_on_this_exec_ctx = NULL;
- if (exec_ctx->active_combiner == NULL) {
- exec_ctx->active_combiner = exec_ctx->last_combiner = lock;
+static void push_last_on_exec_ctx(grpc_combiner* lock) {
+ lock->next_combiner_on_this_exec_ctx = nullptr;
+ if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner == nullptr) {
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner =
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = lock;
} else {
- exec_ctx->last_combiner->next_combiner_on_this_exec_ctx = lock;
- exec_ctx->last_combiner = lock;
+ grpc_core::ExecCtx::Get()
+ ->combiner_data()
+ ->last_combiner->next_combiner_on_this_exec_ctx = lock;
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = lock;
}
}
-static void push_first_on_exec_ctx(grpc_exec_ctx *exec_ctx,
- grpc_combiner *lock) {
- lock->next_combiner_on_this_exec_ctx = exec_ctx->active_combiner;
- exec_ctx->active_combiner = lock;
- if (lock->next_combiner_on_this_exec_ctx == NULL) {
- exec_ctx->last_combiner = lock;
+static void push_first_on_exec_ctx(grpc_combiner* lock) {
+ lock->next_combiner_on_this_exec_ctx =
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner;
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner = lock;
+ if (lock->next_combiner_on_this_exec_ctx == nullptr) {
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = lock;
}
}
#define COMBINER_FROM_CLOSURE_SCHEDULER(closure, scheduler_name) \
- ((grpc_combiner *)(((char *)((closure)->scheduler)) - \
- offsetof(grpc_combiner, scheduler_name)))
+ ((grpc_combiner*)(((char*)((closure)->scheduler)) - \
+ offsetof(grpc_combiner, scheduler_name)))
-static void combiner_exec(grpc_exec_ctx *exec_ctx, grpc_closure *cl,
- grpc_error *error) {
- GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS(exec_ctx);
+static void combiner_exec(grpc_closure* cl, grpc_error* error) {
+ GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS();
GPR_TIMER_BEGIN("combiner.execute", 0);
- grpc_combiner *lock = COMBINER_FROM_CLOSURE_SCHEDULER(cl, scheduler);
+ grpc_combiner* lock = COMBINER_FROM_CLOSURE_SCHEDULER(cl, scheduler);
gpr_atm last = gpr_atm_full_fetch_add(&lock->state, STATE_ELEM_COUNT_LOW_BIT);
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG,
"C:%p grpc_combiner_execute c=%p last=%" PRIdPTR,
lock, cl, last));
if (last == 1) {
- GRPC_STATS_INC_COMBINER_LOCKS_INITIATED(exec_ctx);
+ GRPC_STATS_INC_COMBINER_LOCKS_INITIATED();
+ GPR_TIMER_MARK("combiner.initiated", 0);
gpr_atm_no_barrier_store(&lock->initiating_exec_ctx_or_null,
- (gpr_atm)exec_ctx);
+ (gpr_atm)grpc_core::ExecCtx::Get());
// first element on this list: add it to the list of combiner locks
// executing within this exec_ctx
- push_last_on_exec_ctx(exec_ctx, lock);
+ push_last_on_exec_ctx(lock);
} else {
// there may be a race with setting here: if that happens, we may delay
// offload for one or two actions, and that's fine
gpr_atm initiator =
gpr_atm_no_barrier_load(&lock->initiating_exec_ctx_or_null);
- if (initiator != 0 && initiator != (gpr_atm)exec_ctx) {
+ if (initiator != 0 && initiator != (gpr_atm)grpc_core::ExecCtx::Get()) {
gpr_atm_no_barrier_store(&lock->initiating_exec_ctx_or_null, 0);
}
}
@@ -185,30 +184,33 @@ static void combiner_exec(grpc_exec_ctx *exec_ctx, grpc_closure *cl,
GPR_TIMER_END("combiner.execute", 0);
}
-static void move_next(grpc_exec_ctx *exec_ctx) {
- exec_ctx->active_combiner =
- exec_ctx->active_combiner->next_combiner_on_this_exec_ctx;
- if (exec_ctx->active_combiner == NULL) {
- exec_ctx->last_combiner = NULL;
+static void move_next() {
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner =
+ grpc_core::ExecCtx::Get()
+ ->combiner_data()
+ ->active_combiner->next_combiner_on_this_exec_ctx;
+ if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner == nullptr) {
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = nullptr;
}
}
-static void offload(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_combiner *lock = (grpc_combiner *)arg;
- push_last_on_exec_ctx(exec_ctx, lock);
+static void offload(void* arg, grpc_error* error) {
+ grpc_combiner* lock = (grpc_combiner*)arg;
+ push_last_on_exec_ctx(lock);
}
-static void queue_offload(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
- GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED(exec_ctx);
- move_next(exec_ctx);
+static void queue_offload(grpc_combiner* lock) {
+ GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED();
+ move_next();
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p queue_offload", lock));
- GRPC_CLOSURE_SCHED(exec_ctx, &lock->offload, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&lock->offload, GRPC_ERROR_NONE);
}
-bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
+bool grpc_combiner_continue_exec_ctx() {
GPR_TIMER_BEGIN("combiner.continue_exec_ctx", 0);
- grpc_combiner *lock = exec_ctx->active_combiner;
- if (lock == NULL) {
+ grpc_combiner* lock =
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner;
+ if (lock == nullptr) {
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return false;
}
@@ -222,15 +224,15 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
"exec_ctx_ready_to_finish=%d "
"time_to_execute_final_list=%d",
lock, contended,
- grpc_exec_ctx_ready_to_finish(exec_ctx),
+ grpc_core::ExecCtx::Get()->IsReadyToFinish(),
lock->time_to_execute_final_list));
- if (contended && grpc_exec_ctx_ready_to_finish(exec_ctx) &&
+ if (contended && grpc_core::ExecCtx::Get()->IsReadyToFinish() &&
grpc_executor_is_threaded()) {
GPR_TIMER_MARK("offload_from_finished_exec_ctx", 0);
// this execution context wants to move on: schedule remaining work to be
// picked up on the executor
- queue_offload(exec_ctx, lock);
+ queue_offload(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
}
@@ -239,41 +241,41 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
// peek to see if something new has shown up, and execute that with
// priority
(gpr_atm_acq_load(&lock->state) >> 1) > 1) {
- gpr_mpscq_node *n = gpr_mpscq_pop(&lock->queue);
+ gpr_mpscq_node* n = gpr_mpscq_pop(&lock->queue);
GRPC_COMBINER_TRACE(
gpr_log(GPR_DEBUG, "C:%p maybe_finish_one n=%p", lock, n));
- if (n == NULL) {
+ if (n == nullptr) {
// queue is in an inconsistent state: use this as a cue that we should
// go off and do something else for a while (and come back later)
GPR_TIMER_MARK("delay_busy", 0);
- queue_offload(exec_ctx, lock);
+ queue_offload(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
}
GPR_TIMER_BEGIN("combiner.exec1", 0);
- grpc_closure *cl = (grpc_closure *)n;
- grpc_error *cl_err = cl->error_data.error;
+ grpc_closure* cl = (grpc_closure*)n;
+ grpc_error* cl_err = cl->error_data.error;
#ifndef NDEBUG
cl->scheduled = false;
#endif
- cl->cb(exec_ctx, cl->cb_arg, cl_err);
+ cl->cb(cl->cb_arg, cl_err);
GRPC_ERROR_UNREF(cl_err);
GPR_TIMER_END("combiner.exec1", 0);
} else {
- grpc_closure *c = lock->final_list.head;
- GPR_ASSERT(c != NULL);
+ grpc_closure* c = lock->final_list.head;
+ GPR_ASSERT(c != nullptr);
grpc_closure_list_init(&lock->final_list);
int loops = 0;
- while (c != NULL) {
+ while (c != nullptr) {
GPR_TIMER_BEGIN("combiner.exec_1final", 0);
GRPC_COMBINER_TRACE(
gpr_log(GPR_DEBUG, "C:%p execute_final[%d] c=%p", lock, loops, c));
- grpc_closure *next = c->next_data.next;
- grpc_error *error = c->error_data.error;
+ grpc_closure* next = c->next_data.next;
+ grpc_error* error = c->error_data.error;
#ifndef NDEBUG
c->scheduled = false;
#endif
- c->cb(exec_ctx, c->cb_arg, error);
+ c->cb(c->cb_arg, error);
GRPC_ERROR_UNREF(error);
c = next;
GPR_TIMER_END("combiner.exec_1final", 0);
@@ -281,7 +283,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
}
GPR_TIMER_MARK("unref", 0);
- move_next(exec_ctx);
+ move_next();
lock->time_to_execute_final_list = false;
gpr_atm old_state =
gpr_atm_full_fetch_add(&lock->state, -STATE_ELEM_COUNT_LOW_BIT);
@@ -310,7 +312,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
return true;
case OLD_STATE_WAS(true, 1):
// and one count, one orphaned --> unlocked and orphaned
- really_destroy(exec_ctx, lock);
+ really_destroy(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
case OLD_STATE_WAS(false, 0):
@@ -320,27 +322,24 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
GPR_UNREACHABLE_CODE(return true);
}
- push_first_on_exec_ctx(exec_ctx, lock);
+ push_first_on_exec_ctx(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
}
-static void enqueue_finally(grpc_exec_ctx *exec_ctx, void *closure,
- grpc_error *error);
+static void enqueue_finally(void* closure, grpc_error* error);
-static void combiner_finally_exec(grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_error *error) {
- GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS(exec_ctx);
- grpc_combiner *lock =
+static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) {
+ GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS();
+ grpc_combiner* lock =
COMBINER_FROM_CLOSURE_SCHEDULER(closure, finally_scheduler);
- GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG,
- "C:%p grpc_combiner_execute_finally c=%p; ac=%p",
- lock, closure, exec_ctx->active_combiner));
+ GRPC_COMBINER_TRACE(gpr_log(
+ GPR_DEBUG, "C:%p grpc_combiner_execute_finally c=%p; ac=%p", lock,
+ closure, grpc_core::ExecCtx::Get()->combiner_data()->active_combiner));
GPR_TIMER_BEGIN("combiner.execute_finally", 0);
- if (exec_ctx->active_combiner != lock) {
+ if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner != lock) {
GPR_TIMER_MARK("slowpath", 0);
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(enqueue_finally, closure,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(enqueue_finally, closure,
grpc_combiner_scheduler(lock)),
error);
GPR_TIMER_END("combiner.execute_finally", 0);
@@ -354,17 +353,15 @@ static void combiner_finally_exec(grpc_exec_ctx *exec_ctx,
GPR_TIMER_END("combiner.execute_finally", 0);
}
-static void enqueue_finally(grpc_exec_ctx *exec_ctx, void *closure,
- grpc_error *error) {
- combiner_finally_exec(exec_ctx, (grpc_closure *)closure,
- GRPC_ERROR_REF(error));
+static void enqueue_finally(void* closure, grpc_error* error) {
+ combiner_finally_exec((grpc_closure*)closure, GRPC_ERROR_REF(error));
}
-grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *combiner) {
+grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* combiner) {
return &combiner->scheduler;
}
-grpc_closure_scheduler *grpc_combiner_finally_scheduler(
- grpc_combiner *combiner) {
+grpc_closure_scheduler* grpc_combiner_finally_scheduler(
+ grpc_combiner* combiner) {
return &combiner->finally_scheduler;
}
diff --git a/src/core/lib/iomgr/combiner.h b/src/core/lib/iomgr/combiner.h
index 8e0434369d..c62d21a051 100644
--- a/src/core/lib/iomgr/combiner.h
+++ b/src/core/lib/iomgr/combiner.h
@@ -23,8 +23,8 @@
#include <grpc/support/atm.h>
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/mpscq.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/mpscq.h"
// Provides serialized access to some resource.
// Each action queued on a combiner is executed serially in a borrowed thread.
@@ -33,34 +33,32 @@
// Initialize the lock, with an optional workqueue to shift load to when
// necessary
-grpc_combiner *grpc_combiner_create(void);
+grpc_combiner* grpc_combiner_create(void);
#ifndef NDEBUG
#define GRPC_COMBINER_DEBUG_ARGS \
, const char *file, int line, const char *reason
#define GRPC_COMBINER_REF(combiner, reason) \
grpc_combiner_ref((combiner), __FILE__, __LINE__, (reason))
-#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
- grpc_combiner_unref((exec_ctx), (combiner), __FILE__, __LINE__, (reason))
+#define GRPC_COMBINER_UNREF(combiner, reason) \
+ grpc_combiner_unref((combiner), __FILE__, __LINE__, (reason))
#else
#define GRPC_COMBINER_DEBUG_ARGS
#define GRPC_COMBINER_REF(combiner, reason) grpc_combiner_ref((combiner))
-#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
- grpc_combiner_unref((exec_ctx), (combiner))
+#define GRPC_COMBINER_UNREF(combiner, reason) grpc_combiner_unref((combiner))
#endif
// Ref/unref the lock, for when we're sharing the lock ownership
// Prefer to use the macros above
-grpc_combiner *grpc_combiner_ref(grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS);
-void grpc_combiner_unref(grpc_exec_ctx *exec_ctx,
- grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS);
+grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
+void grpc_combiner_unref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
// Fetch a scheduler to schedule closures against
-grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *lock);
+grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* lock);
// Scheduler to execute \a action within the lock just prior to unlocking.
-grpc_closure_scheduler *grpc_combiner_finally_scheduler(grpc_combiner *lock);
+grpc_closure_scheduler* grpc_combiner_finally_scheduler(grpc_combiner* lock);
-bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx);
+bool grpc_combiner_continue_exec_ctx();
-extern grpc_tracer_flag grpc_combiner_trace;
+extern grpc_core::TraceFlag grpc_combiner_trace;
#endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */
diff --git a/src/core/lib/iomgr/endpoint.c b/src/core/lib/iomgr/endpoint.cc
index 37cce335ca..9d4b102822 100644
--- a/src/core/lib/iomgr/endpoint.c
+++ b/src/core/lib/iomgr/endpoint.cc
@@ -18,36 +18,36 @@
#include "src/core/lib/iomgr/endpoint.h"
-void grpc_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- ep->vtable->read(exec_ctx, ep, slices, cb);
+void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ ep->vtable->read(ep, slices, cb);
}
-void grpc_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- ep->vtable->write(exec_ctx, ep, slices, cb);
+void grpc_endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ ep->vtable->write(ep, slices, cb);
}
-void grpc_endpoint_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {
- ep->vtable->add_to_pollset(exec_ctx, ep, pollset);
+void grpc_endpoint_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
+ ep->vtable->add_to_pollset(ep, pollset);
}
-void grpc_endpoint_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+void grpc_endpoint_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- ep->vtable->add_to_pollset_set(exec_ctx, ep, pollset_set);
+ ep->vtable->add_to_pollset_set(ep, pollset_set);
}
-void grpc_endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
- ep->vtable->shutdown(exec_ctx, ep, why);
+void grpc_endpoint_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set) {
+ ep->vtable->delete_from_pollset_set(ep, pollset_set);
}
-void grpc_endpoint_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
- ep->vtable->destroy(exec_ctx, ep);
+void grpc_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ ep->vtable->shutdown(ep, why);
}
+void grpc_endpoint_destroy(grpc_endpoint* ep) { ep->vtable->destroy(ep); }
+
char* grpc_endpoint_get_peer(grpc_endpoint* ep) {
return ep->vtable->get_peer(ep);
}
diff --git a/src/core/lib/iomgr/endpoint.h b/src/core/lib/iomgr/endpoint.h
index 8f0523a981..cd53099334 100644
--- a/src/core/lib/iomgr/endpoint.h
+++ b/src/core/lib/iomgr/endpoint.h
@@ -33,19 +33,16 @@ typedef struct grpc_endpoint grpc_endpoint;
typedef struct grpc_endpoint_vtable grpc_endpoint_vtable;
struct grpc_endpoint_vtable {
- void (*read)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb);
- void (*write)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb);
- void (*add_to_pollset)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset);
- void (*add_to_pollset_set)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset);
- void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_error *why);
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep);
- grpc_resource_user *(*get_resource_user)(grpc_endpoint *ep);
- char *(*get_peer)(grpc_endpoint *ep);
- int (*get_fd)(grpc_endpoint *ep);
+ void (*read)(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb);
+ void (*write)(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb);
+ void (*add_to_pollset)(grpc_endpoint* ep, grpc_pollset* pollset);
+ void (*add_to_pollset_set)(grpc_endpoint* ep, grpc_pollset_set* pollset);
+ void (*delete_from_pollset_set)(grpc_endpoint* ep, grpc_pollset_set* pollset);
+ void (*shutdown)(grpc_endpoint* ep, grpc_error* why);
+ void (*destroy)(grpc_endpoint* ep);
+ grpc_resource_user* (*get_resource_user)(grpc_endpoint* ep);
+ char* (*get_peer)(grpc_endpoint* ep);
+ int (*get_fd)(grpc_endpoint* ep);
};
/* When data is available on the connection, calls the callback with slices.
@@ -53,14 +50,14 @@ struct grpc_endpoint_vtable {
indicates the endpoint is closed.
Valid slices may be placed into \a slices even when the callback is
invoked with error != GRPC_ERROR_NONE. */
-void grpc_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb);
+void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb);
-char *grpc_endpoint_get_peer(grpc_endpoint *ep);
+char* grpc_endpoint_get_peer(grpc_endpoint* ep);
/* Get the file descriptor used by \a ep. Return -1 if \a ep is not using an fd.
- */
-int grpc_endpoint_get_fd(grpc_endpoint *ep);
+ */
+int grpc_endpoint_get_fd(grpc_endpoint* ep);
/* Write slices out to the socket.
@@ -72,27 +69,28 @@ int grpc_endpoint_get_fd(grpc_endpoint *ep);
No guarantee is made to the content of slices after a write EXCEPT that
it is a valid slice buffer.
*/
-void grpc_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb);
+void grpc_endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb);
/* Causes any pending and future read/write callbacks to run immediately with
success==0 */
-void grpc_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why);
-void grpc_endpoint_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep);
+void grpc_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why);
+void grpc_endpoint_destroy(grpc_endpoint* ep);
+
+/* Add an endpoint to a pollset or pollset_set, so that when the pollset is
+ polled, events from this endpoint are considered */
+void grpc_endpoint_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset);
+void grpc_endpoint_add_to_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set);
-/* Add an endpoint to a pollset, so that when the pollset is polled, events from
- this endpoint are considered */
-void grpc_endpoint_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset);
-void grpc_endpoint_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *ep,
- grpc_pollset_set *pollset_set);
+/* Delete an endpoint from a pollset_set */
+void grpc_endpoint_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set);
-grpc_resource_user *grpc_endpoint_get_resource_user(grpc_endpoint *endpoint);
+grpc_resource_user* grpc_endpoint_get_resource_user(grpc_endpoint* endpoint);
struct grpc_endpoint {
- const grpc_endpoint_vtable *vtable;
+ const grpc_endpoint_vtable* vtable;
};
#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */
diff --git a/src/core/lib/iomgr/endpoint_pair.h b/src/core/lib/iomgr/endpoint_pair.h
index b60e62fc3e..506ffc88b4 100644
--- a/src/core/lib/iomgr/endpoint_pair.h
+++ b/src/core/lib/iomgr/endpoint_pair.h
@@ -22,11 +22,11 @@
#include "src/core/lib/iomgr/endpoint.h"
typedef struct {
- grpc_endpoint *client;
- grpc_endpoint *server;
+ grpc_endpoint* client;
+ grpc_endpoint* server;
} grpc_endpoint_pair;
-grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name,
- grpc_channel_args *args);
+grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
+ grpc_channel_args* args);
#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */
diff --git a/src/core/lib/iomgr/endpoint_pair_posix.c b/src/core/lib/iomgr/endpoint_pair_posix.cc
index 3ade2148ba..3ad6b47756 100644
--- a/src/core/lib/iomgr/endpoint_pair_posix.c
+++ b/src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -33,8 +33,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/tcp_posix.h"
-#include "src/core/lib/support/string.h"
static void create_sockets(int sv[2]) {
int flags;
@@ -47,25 +47,24 @@ static void create_sockets(int sv[2]) {
GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[1]) == GRPC_ERROR_NONE);
}
-grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name,
- grpc_channel_args *args) {
+grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
+ grpc_channel_args* args) {
int sv[2];
grpc_endpoint_pair p;
- char *final_name;
+ char* final_name;
create_sockets(sv);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_asprintf(&final_name, "%s:client", name);
- p.client = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], final_name), args,
+ p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name), args,
"socketpair-server");
gpr_free(final_name);
gpr_asprintf(&final_name, "%s:server", name);
- p.server = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[0], final_name), args,
+ p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name), args,
"socketpair-client");
gpr_free(final_name);
- grpc_exec_ctx_finish(&exec_ctx);
return p;
}
diff --git a/src/core/lib/iomgr/endpoint_pair_uv.c b/src/core/lib/iomgr/endpoint_pair_uv.cc
index ff72fe0492..128a947d1b 100644
--- a/src/core/lib/iomgr/endpoint_pair_uv.c
+++ b/src/core/lib/iomgr/endpoint_pair_uv.cc
@@ -26,8 +26,8 @@
#include "src/core/lib/iomgr/endpoint_pair.h"
-grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name,
- grpc_channel_args *args) {
+grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
+ grpc_channel_args* args) {
grpc_endpoint_pair endpoint_pair;
// TODO(mlumish): implement this properly under libuv
GPR_ASSERT(false &&
diff --git a/src/core/lib/iomgr/endpoint_pair_windows.c b/src/core/lib/iomgr/endpoint_pair_windows.cc
index 782fa2fd69..cc07ac0708 100644
--- a/src/core/lib/iomgr/endpoint_pair_windows.c
+++ b/src/core/lib/iomgr/endpoint_pair_windows.cc
@@ -44,19 +44,19 @@ static void create_sockets(SOCKET sv[2]) {
memset(&addr, 0, sizeof(addr));
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_family = AF_INET;
- GPR_ASSERT(bind(lst_sock, (struct sockaddr *)&addr, sizeof(addr)) !=
+ GPR_ASSERT(bind(lst_sock, (struct sockaddr*)&addr, sizeof(addr)) !=
SOCKET_ERROR);
GPR_ASSERT(listen(lst_sock, SOMAXCONN) != SOCKET_ERROR);
- GPR_ASSERT(getsockname(lst_sock, (struct sockaddr *)&addr, &addr_len) !=
+ GPR_ASSERT(getsockname(lst_sock, (struct sockaddr*)&addr, &addr_len) !=
SOCKET_ERROR);
cli_sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0,
WSA_FLAG_OVERLAPPED);
GPR_ASSERT(cli_sock != INVALID_SOCKET);
- GPR_ASSERT(WSAConnect(cli_sock, (struct sockaddr *)&addr, addr_len, NULL,
- NULL, NULL, NULL) == 0);
- svr_sock = accept(lst_sock, (struct sockaddr *)&addr, &addr_len);
+ GPR_ASSERT(WSAConnect(cli_sock, (struct sockaddr*)&addr, addr_len, NULL, NULL,
+ NULL, NULL) == 0);
+ svr_sock = accept(lst_sock, (struct sockaddr*)&addr, &addr_len);
GPR_ASSERT(svr_sock != INVALID_SOCKET);
closesocket(lst_sock);
@@ -68,18 +68,16 @@ static void create_sockets(SOCKET sv[2]) {
}
grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(
- const char *name, grpc_channel_args *channel_args) {
+ const char* name, grpc_channel_args* channel_args) {
SOCKET sv[2];
grpc_endpoint_pair p;
create_sockets(sv);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- p.client = grpc_tcp_create(&exec_ctx,
- grpc_winsocket_create(sv[1], "endpoint:client"),
+ grpc_core::ExecCtx exec_ctx;
+ p.client = grpc_tcp_create(grpc_winsocket_create(sv[1], "endpoint:client"),
channel_args, "endpoint:server");
- p.server = grpc_tcp_create(&exec_ctx,
- grpc_winsocket_create(sv[0], "endpoint:server"),
+ p.server = grpc_tcp_create(grpc_winsocket_create(sv[0], "endpoint:server"),
channel_args, "endpoint:client");
- grpc_exec_ctx_finish(&exec_ctx);
+
return p;
}
diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.cc
index aa05501537..67c3caf5ee 100644
--- a/src/core/lib/iomgr/error.c
+++ b/src/core/lib/iomgr/error.cc
@@ -15,9 +15,11 @@
* limitations under the License.
*
*/
+#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/error.h"
+#include <inttypes.h>
#include <string.h>
#include <grpc/status.h>
@@ -35,12 +37,11 @@
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_error_refcount =
- GRPC_TRACER_INITIALIZER(false, "error_refcount");
-#endif
+grpc_core::DebugOnlyTraceFlag grpc_trace_error_refcount(false,
+ "error_refcount");
+grpc_core::DebugOnlyTraceFlag grpc_trace_closure(false, "closure");
-static const char *error_int_name(grpc_error_ints key) {
+static const char* error_int_name(grpc_error_ints key) {
switch (key) {
case GRPC_ERROR_INT_ERRNO:
return "errno";
@@ -78,7 +79,7 @@ static const char *error_int_name(grpc_error_ints key) {
GPR_UNREACHABLE_CODE(return "unknown");
}
-static const char *error_str_name(grpc_error_strs key) {
+static const char* error_str_name(grpc_error_strs key) {
switch (key) {
case GRPC_ERROR_STR_KEY:
return "key";
@@ -110,7 +111,7 @@ static const char *error_str_name(grpc_error_strs key) {
GPR_UNREACHABLE_CODE(return "unknown");
}
-static const char *error_time_name(grpc_error_times key) {
+static const char* error_time_name(grpc_error_times key) {
switch (key) {
case GRPC_ERROR_TIME_CREATED:
return "created";
@@ -120,15 +121,15 @@ static const char *error_time_name(grpc_error_times key) {
GPR_UNREACHABLE_CODE(return "unknown");
}
-bool grpc_error_is_special(grpc_error *err) {
+bool grpc_error_is_special(grpc_error* err) {
return err == GRPC_ERROR_NONE || err == GRPC_ERROR_OOM ||
err == GRPC_ERROR_CANCELLED;
}
#ifndef NDEBUG
-grpc_error *grpc_error_ref(grpc_error *err, const char *file, int line) {
+grpc_error* grpc_error_ref(grpc_error* err, const char* file, int line) {
if (grpc_error_is_special(err)) return err;
- if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
+ if (grpc_trace_error_refcount.enabled()) {
gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d]", err,
gpr_atm_no_barrier_load(&err->atomics.refs.count),
gpr_atm_no_barrier_load(&err->atomics.refs.count) + 1, file, line);
@@ -137,17 +138,17 @@ grpc_error *grpc_error_ref(grpc_error *err, const char *file, int line) {
return err;
}
#else
-grpc_error *grpc_error_ref(grpc_error *err) {
+grpc_error* grpc_error_ref(grpc_error* err) {
if (grpc_error_is_special(err)) return err;
gpr_ref(&err->atomics.refs);
return err;
}
#endif
-static void unref_errs(grpc_error *err) {
+static void unref_errs(grpc_error* err) {
uint8_t slot = err->first_err;
while (slot != UINT8_MAX) {
- grpc_linked_error *lerr = (grpc_linked_error *)(err->arena + slot);
+ grpc_linked_error* lerr = (grpc_linked_error*)(err->arena + slot);
GRPC_ERROR_UNREF(lerr->err);
GPR_ASSERT(err->last_err == slot ? lerr->next == UINT8_MAX
: lerr->next != UINT8_MAX);
@@ -155,33 +156,29 @@ static void unref_errs(grpc_error *err) {
}
}
-static void unref_slice(grpc_slice slice) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, slice);
- grpc_exec_ctx_finish(&exec_ctx);
-}
+static void unref_slice(grpc_slice slice) { grpc_slice_unref_internal(slice); }
-static void unref_strs(grpc_error *err) {
+static void unref_strs(grpc_error* err) {
for (size_t which = 0; which < GRPC_ERROR_STR_MAX; ++which) {
uint8_t slot = err->strs[which];
if (slot != UINT8_MAX) {
- unref_slice(*(grpc_slice *)(err->arena + slot));
+ unref_slice(*(grpc_slice*)(err->arena + slot));
}
}
}
-static void error_destroy(grpc_error *err) {
+static void error_destroy(grpc_error* err) {
GPR_ASSERT(!grpc_error_is_special(err));
unref_errs(err);
unref_strs(err);
- gpr_free((void *)gpr_atm_acq_load(&err->atomics.error_string));
+ gpr_free((void*)gpr_atm_acq_load(&err->atomics.error_string));
gpr_free(err);
}
#ifndef NDEBUG
-void grpc_error_unref(grpc_error *err, const char *file, int line) {
+void grpc_error_unref(grpc_error* err, const char* file, int line) {
if (grpc_error_is_special(err)) return;
- if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
+ if (grpc_trace_error_refcount.enabled()) {
gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d]", err,
gpr_atm_no_barrier_load(&err->atomics.refs.count),
gpr_atm_no_barrier_load(&err->atomics.refs.count) - 1, file, line);
@@ -191,7 +188,7 @@ void grpc_error_unref(grpc_error *err, const char *file, int line) {
}
}
#else
-void grpc_error_unref(grpc_error *err) {
+void grpc_error_unref(grpc_error* err) {
if (grpc_error_is_special(err)) return;
if (gpr_unref(&err->atomics.refs)) {
error_destroy(err);
@@ -199,7 +196,7 @@ void grpc_error_unref(grpc_error *err) {
}
#endif
-static uint8_t get_placement(grpc_error **err, size_t size) {
+static uint8_t get_placement(grpc_error** err, size_t size) {
GPR_ASSERT(*err);
uint8_t slots = (uint8_t)(size / sizeof(intptr_t));
if ((*err)->arena_size + slots > (*err)->arena_capacity) {
@@ -209,12 +206,12 @@ static uint8_t get_placement(grpc_error **err, size_t size) {
return UINT8_MAX;
}
#ifndef NDEBUG
- grpc_error *orig = *err;
+ grpc_error* orig = *err;
#endif
- *err = (grpc_error *)gpr_realloc(
+ *err = (grpc_error*)gpr_realloc(
*err, sizeof(grpc_error) + (*err)->arena_capacity * sizeof(intptr_t));
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
+ if (grpc_trace_error_refcount.enabled()) {
if (*err != orig) {
gpr_log(GPR_DEBUG, "realloc %p -> %p", orig, *err);
}
@@ -226,7 +223,7 @@ static uint8_t get_placement(grpc_error **err, size_t size) {
return placement;
}
-static void internal_set_int(grpc_error **err, grpc_error_ints which,
+static void internal_set_int(grpc_error** err, grpc_error_ints which,
intptr_t value) {
uint8_t slot = (*err)->ints[which];
if (slot == UINT8_MAX) {
@@ -241,36 +238,36 @@ static void internal_set_int(grpc_error **err, grpc_error_ints which,
(*err)->arena[slot] = value;
}
-static void internal_set_str(grpc_error **err, grpc_error_strs which,
+static void internal_set_str(grpc_error** err, grpc_error_strs which,
grpc_slice value) {
uint8_t slot = (*err)->strs[which];
if (slot == UINT8_MAX) {
slot = get_placement(err, sizeof(value));
if (slot == UINT8_MAX) {
- const char *str = grpc_slice_to_c_string(value);
+ const char* str = grpc_slice_to_c_string(value);
gpr_log(GPR_ERROR, "Error %p is full, dropping string {\"%s\":\"%s\"}",
*err, error_str_name(which), str);
- gpr_free((void *)str);
+ gpr_free((void*)str);
return;
}
} else {
- unref_slice(*(grpc_slice *)((*err)->arena + slot));
+ unref_slice(*(grpc_slice*)((*err)->arena + slot));
}
(*err)->strs[which] = slot;
memcpy((*err)->arena + slot, &value, sizeof(value));
}
-static char *fmt_time(gpr_timespec tm);
-static void internal_set_time(grpc_error **err, grpc_error_times which,
+static char* fmt_time(gpr_timespec tm);
+static void internal_set_time(grpc_error** err, grpc_error_times which,
gpr_timespec value) {
uint8_t slot = (*err)->times[which];
if (slot == UINT8_MAX) {
slot = get_placement(err, sizeof(value));
if (slot == UINT8_MAX) {
- const char *time_str = fmt_time(value);
+ const char* time_str = fmt_time(value);
gpr_log(GPR_ERROR, "Error %p is full, dropping \"%s\":\"%s\"}", *err,
error_time_name(which), time_str);
- gpr_free((void *)time_str);
+ gpr_free((void*)time_str);
return;
}
}
@@ -278,7 +275,7 @@ static void internal_set_time(grpc_error **err, grpc_error_times which,
memcpy((*err)->arena + slot, &value, sizeof(value));
}
-static void internal_add_error(grpc_error **err, grpc_error *new_err) {
+static void internal_add_error(grpc_error** err, grpc_error* new_err) {
grpc_linked_error new_last = {new_err, UINT8_MAX};
uint8_t slot = get_placement(err, sizeof(grpc_linked_error));
if (slot == UINT8_MAX) {
@@ -293,8 +290,8 @@ static void internal_add_error(grpc_error **err, grpc_error *new_err) {
(*err)->first_err = slot;
} else {
GPR_ASSERT((*err)->last_err != UINT8_MAX);
- grpc_linked_error *old_last =
- (grpc_linked_error *)((*err)->arena + (*err)->last_err);
+ grpc_linked_error* old_last =
+ (grpc_linked_error*)((*err)->arena + (*err)->last_err);
old_last->next = slot;
(*err)->last_err = slot;
}
@@ -314,20 +311,20 @@ static void internal_add_error(grpc_error **err, grpc_error *new_err) {
// It is very common to include and extra int and string in an error
#define SURPLUS_CAPACITY (2 * SLOTS_PER_INT + SLOTS_PER_TIME)
-grpc_error *grpc_error_create(const char *file, int line, grpc_slice desc,
- grpc_error **referencing,
+grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc,
+ grpc_error** referencing,
size_t num_referencing) {
GPR_TIMER_BEGIN("grpc_error_create", 0);
uint8_t initial_arena_capacity = (uint8_t)(
DEFAULT_ERROR_CAPACITY +
(uint8_t)(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY);
- grpc_error *err = (grpc_error *)gpr_malloc(
+ grpc_error* err = (grpc_error*)gpr_malloc(
sizeof(*err) + initial_arena_capacity * sizeof(intptr_t));
- if (err == NULL) { // TODO(ctiller): make gpr_malloc return NULL
+ if (err == nullptr) { // TODO(ctiller): make gpr_malloc return NULL
return GRPC_ERROR_OOM;
}
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
+ if (grpc_trace_error_refcount.enabled()) {
gpr_log(GPR_DEBUG, "%p create [%s:%d]", err, file, line);
}
#endif
@@ -362,27 +359,27 @@ grpc_error *grpc_error_create(const char *file, int line, grpc_slice desc,
return err;
}
-static void ref_strs(grpc_error *err) {
+static void ref_strs(grpc_error* err) {
for (size_t i = 0; i < GRPC_ERROR_STR_MAX; ++i) {
uint8_t slot = err->strs[i];
if (slot != UINT8_MAX) {
- grpc_slice_ref_internal(*(grpc_slice *)(err->arena + slot));
+ grpc_slice_ref_internal(*(grpc_slice*)(err->arena + slot));
}
}
}
-static void ref_errs(grpc_error *err) {
+static void ref_errs(grpc_error* err) {
uint8_t slot = err->first_err;
while (slot != UINT8_MAX) {
- grpc_linked_error *lerr = (grpc_linked_error *)(err->arena + slot);
+ grpc_linked_error* lerr = (grpc_linked_error*)(err->arena + slot);
GRPC_ERROR_REF(lerr->err);
slot = lerr->next;
}
}
-static grpc_error *copy_error_and_unref(grpc_error *in) {
+static grpc_error* copy_error_and_unref(grpc_error* in) {
GPR_TIMER_BEGIN("copy_error_and_unref", 0);
- grpc_error *out;
+ grpc_error* out;
if (grpc_error_is_special(in)) {
out = GRPC_ERROR_CREATE_FROM_STATIC_STRING("unknown");
if (in == GRPC_ERROR_NONE) {
@@ -406,16 +403,16 @@ static grpc_error *copy_error_and_unref(grpc_error *in) {
if (in->arena_capacity - in->arena_size < (uint8_t)SLOTS_PER_STR) {
new_arena_capacity = (uint8_t)(3 * new_arena_capacity / 2);
}
- out = (grpc_error *)gpr_malloc(sizeof(*in) +
- new_arena_capacity * sizeof(intptr_t));
+ out = (grpc_error*)gpr_malloc(sizeof(*in) +
+ new_arena_capacity * sizeof(intptr_t));
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
+ if (grpc_trace_error_refcount.enabled()) {
gpr_log(GPR_DEBUG, "%p create copying %p", out, in);
}
#endif
// bulk memcpy of the rest of the struct.
size_t skip = sizeof(&out->atomics);
- memcpy((void *)((uintptr_t)out + skip), (void *)((uintptr_t)in + skip),
+ memcpy((void*)((uintptr_t)out + skip), (void*)((uintptr_t)in + skip),
sizeof(*in) + (in->arena_size * sizeof(intptr_t)) - skip);
// manually set the atomics and the new capacity
gpr_atm_no_barrier_store(&out->atomics.error_string, 0);
@@ -429,19 +426,19 @@ static grpc_error *copy_error_and_unref(grpc_error *in) {
return out;
}
-grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
+grpc_error* grpc_error_set_int(grpc_error* src, grpc_error_ints which,
intptr_t value) {
GPR_TIMER_BEGIN("grpc_error_set_int", 0);
- grpc_error *new_err = copy_error_and_unref(src);
+ grpc_error* new_err = copy_error_and_unref(src);
internal_set_int(&new_err, which, value);
GPR_TIMER_END("grpc_error_set_int", 0);
return new_err;
}
typedef struct {
- grpc_error *error;
+ grpc_error* error;
grpc_status_code code;
- const char *msg;
+ const char* msg;
} special_error_status_map;
static special_error_status_map error_status_map[] = {
{GRPC_ERROR_NONE, GRPC_STATUS_OK, ""},
@@ -449,13 +446,13 @@ static special_error_status_map error_status_map[] = {
{GRPC_ERROR_OOM, GRPC_STATUS_RESOURCE_EXHAUSTED, "Out of memory"},
};
-bool grpc_error_get_int(grpc_error *err, grpc_error_ints which, intptr_t *p) {
+bool grpc_error_get_int(grpc_error* err, grpc_error_ints which, intptr_t* p) {
GPR_TIMER_BEGIN("grpc_error_get_int", 0);
if (grpc_error_is_special(err)) {
if (which == GRPC_ERROR_INT_GRPC_STATUS) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(error_status_map); i++) {
if (error_status_map[i].error == err) {
- if (p != NULL) *p = error_status_map[i].code;
+ if (p != nullptr) *p = error_status_map[i].code;
GPR_TIMER_END("grpc_error_get_int", 0);
return true;
}
@@ -466,7 +463,7 @@ bool grpc_error_get_int(grpc_error *err, grpc_error_ints which, intptr_t *p) {
}
uint8_t slot = err->ints[which];
if (slot != UINT8_MAX) {
- if (p != NULL) *p = err->arena[slot];
+ if (p != nullptr) *p = err->arena[slot];
GPR_TIMER_END("grpc_error_get_int", 0);
return true;
}
@@ -474,17 +471,17 @@ bool grpc_error_get_int(grpc_error *err, grpc_error_ints which, intptr_t *p) {
return false;
}
-grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
+grpc_error* grpc_error_set_str(grpc_error* src, grpc_error_strs which,
grpc_slice str) {
GPR_TIMER_BEGIN("grpc_error_set_str", 0);
- grpc_error *new_err = copy_error_and_unref(src);
+ grpc_error* new_err = copy_error_and_unref(src);
internal_set_str(&new_err, which, str);
GPR_TIMER_END("grpc_error_set_str", 0);
return new_err;
}
-bool grpc_error_get_str(grpc_error *err, grpc_error_strs which,
- grpc_slice *str) {
+bool grpc_error_get_str(grpc_error* err, grpc_error_strs which,
+ grpc_slice* str) {
if (grpc_error_is_special(err)) {
if (which == GRPC_ERROR_STR_GRPC_MESSAGE) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(error_status_map); i++) {
@@ -498,53 +495,53 @@ bool grpc_error_get_str(grpc_error *err, grpc_error_strs which,
}
uint8_t slot = err->strs[which];
if (slot != UINT8_MAX) {
- *str = *(grpc_slice *)(err->arena + slot);
+ *str = *(grpc_slice*)(err->arena + slot);
return true;
} else {
return false;
}
}
-grpc_error *grpc_error_add_child(grpc_error *src, grpc_error *child) {
+grpc_error* grpc_error_add_child(grpc_error* src, grpc_error* child) {
GPR_TIMER_BEGIN("grpc_error_add_child", 0);
- grpc_error *new_err = copy_error_and_unref(src);
+ grpc_error* new_err = copy_error_and_unref(src);
internal_add_error(&new_err, child);
GPR_TIMER_END("grpc_error_add_child", 0);
return new_err;
}
-static const char *no_error_string = "\"No Error\"";
-static const char *oom_error_string = "\"Out of memory\"";
-static const char *cancelled_error_string = "\"Cancelled\"";
+static const char* no_error_string = "\"No Error\"";
+static const char* oom_error_string = "\"Out of memory\"";
+static const char* cancelled_error_string = "\"Cancelled\"";
typedef struct {
- char *key;
- char *value;
+ char* key;
+ char* value;
} kv_pair;
typedef struct {
- kv_pair *kvs;
+ kv_pair* kvs;
size_t num_kvs;
size_t cap_kvs;
} kv_pairs;
-static void append_chr(char c, char **s, size_t *sz, size_t *cap) {
+static void append_chr(char c, char** s, size_t* sz, size_t* cap) {
if (*sz == *cap) {
*cap = GPR_MAX(8, 3 * *cap / 2);
- *s = (char *)gpr_realloc(*s, *cap);
+ *s = (char*)gpr_realloc(*s, *cap);
}
(*s)[(*sz)++] = c;
}
-static void append_str(const char *str, char **s, size_t *sz, size_t *cap) {
- for (const char *c = str; *c; c++) {
+static void append_str(const char* str, char** s, size_t* sz, size_t* cap) {
+ for (const char* c = str; *c; c++) {
append_chr(*c, s, sz, cap);
}
}
-static void append_esc_str(const uint8_t *str, size_t len, char **s, size_t *sz,
- size_t *cap) {
- static const char *hex = "0123456789abcdef";
+static void append_esc_str(const uint8_t* str, size_t len, char** s, size_t* sz,
+ size_t* cap) {
+ static const char* hex = "0123456789abcdef";
append_chr('"', s, sz, cap);
for (size_t i = 0; i < len; i++, str++) {
if (*str < 32 || *str >= 127) {
@@ -580,28 +577,28 @@ static void append_esc_str(const uint8_t *str, size_t len, char **s, size_t *sz,
append_chr('"', s, sz, cap);
}
-static void append_kv(kv_pairs *kvs, char *key, char *value) {
+static void append_kv(kv_pairs* kvs, char* key, char* value) {
if (kvs->num_kvs == kvs->cap_kvs) {
kvs->cap_kvs = GPR_MAX(3 * kvs->cap_kvs / 2, 4);
kvs->kvs =
- (kv_pair *)gpr_realloc(kvs->kvs, sizeof(*kvs->kvs) * kvs->cap_kvs);
+ (kv_pair*)gpr_realloc(kvs->kvs, sizeof(*kvs->kvs) * kvs->cap_kvs);
}
kvs->kvs[kvs->num_kvs].key = key;
kvs->kvs[kvs->num_kvs].value = value;
kvs->num_kvs++;
}
-static char *key_int(grpc_error_ints which) {
+static char* key_int(grpc_error_ints which) {
return gpr_strdup(error_int_name(which));
}
-static char *fmt_int(intptr_t p) {
- char *s;
+static char* fmt_int(intptr_t p) {
+ char* s;
gpr_asprintf(&s, "%" PRIdPTR, p);
return s;
}
-static void collect_ints_kvs(grpc_error *err, kv_pairs *kvs) {
+static void collect_ints_kvs(grpc_error* err, kv_pairs* kvs) {
for (size_t which = 0; which < GRPC_ERROR_INT_MAX; ++which) {
uint8_t slot = err->ints[which];
if (slot != UINT8_MAX) {
@@ -611,37 +608,37 @@ static void collect_ints_kvs(grpc_error *err, kv_pairs *kvs) {
}
}
-static char *key_str(grpc_error_strs which) {
+static char* key_str(grpc_error_strs which) {
return gpr_strdup(error_str_name(which));
}
-static char *fmt_str(grpc_slice slice) {
- char *s = NULL;
+static char* fmt_str(grpc_slice slice) {
+ char* s = nullptr;
size_t sz = 0;
size_t cap = 0;
- append_esc_str((const uint8_t *)GRPC_SLICE_START_PTR(slice),
+ append_esc_str((const uint8_t*)GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice), &s, &sz, &cap);
append_chr(0, &s, &sz, &cap);
return s;
}
-static void collect_strs_kvs(grpc_error *err, kv_pairs *kvs) {
+static void collect_strs_kvs(grpc_error* err, kv_pairs* kvs) {
for (size_t which = 0; which < GRPC_ERROR_STR_MAX; ++which) {
uint8_t slot = err->strs[which];
if (slot != UINT8_MAX) {
append_kv(kvs, key_str((grpc_error_strs)which),
- fmt_str(*(grpc_slice *)(err->arena + slot)));
+ fmt_str(*(grpc_slice*)(err->arena + slot)));
}
}
}
-static char *key_time(grpc_error_times which) {
+static char* key_time(grpc_error_times which) {
return gpr_strdup(error_time_name(which));
}
-static char *fmt_time(gpr_timespec tm) {
- char *out;
- const char *pfx = "!!";
+static char* fmt_time(gpr_timespec tm) {
+ char* out;
+ const char* pfx = "!!";
switch (tm.clock_type) {
case GPR_CLOCK_MONOTONIC:
pfx = "@monotonic:";
@@ -660,24 +657,24 @@ static char *fmt_time(gpr_timespec tm) {
return out;
}
-static void collect_times_kvs(grpc_error *err, kv_pairs *kvs) {
+static void collect_times_kvs(grpc_error* err, kv_pairs* kvs) {
for (size_t which = 0; which < GRPC_ERROR_TIME_MAX; ++which) {
uint8_t slot = err->times[which];
if (slot != UINT8_MAX) {
append_kv(kvs, key_time((grpc_error_times)which),
- fmt_time(*(gpr_timespec *)(err->arena + slot)));
+ fmt_time(*(gpr_timespec*)(err->arena + slot)));
}
}
}
-static void add_errs(grpc_error *err, char **s, size_t *sz, size_t *cap) {
+static void add_errs(grpc_error* err, char** s, size_t* sz, size_t* cap) {
uint8_t slot = err->first_err;
bool first = true;
while (slot != UINT8_MAX) {
- grpc_linked_error *lerr = (grpc_linked_error *)(err->arena + slot);
+ grpc_linked_error* lerr = (grpc_linked_error*)(err->arena + slot);
if (!first) append_chr(',', s, sz, cap);
first = false;
- const char *e = grpc_error_string(lerr->err);
+ const char* e = grpc_error_string(lerr->err);
append_str(e, s, sz, cap);
GPR_ASSERT(err->last_err == slot ? lerr->next == UINT8_MAX
: lerr->next != UINT8_MAX);
@@ -685,8 +682,8 @@ static void add_errs(grpc_error *err, char **s, size_t *sz, size_t *cap) {
}
}
-static char *errs_string(grpc_error *err) {
- char *s = NULL;
+static char* errs_string(grpc_error* err) {
+ char* s = nullptr;
size_t sz = 0;
size_t cap = 0;
append_chr('[', &s, &sz, &cap);
@@ -696,22 +693,22 @@ static char *errs_string(grpc_error *err) {
return s;
}
-static int cmp_kvs(const void *a, const void *b) {
- const kv_pair *ka = (const kv_pair *)a;
- const kv_pair *kb = (const kv_pair *)b;
+static int cmp_kvs(const void* a, const void* b) {
+ const kv_pair* ka = (const kv_pair*)a;
+ const kv_pair* kb = (const kv_pair*)b;
return strcmp(ka->key, kb->key);
}
-static char *finish_kvs(kv_pairs *kvs) {
- char *s = NULL;
+static char* finish_kvs(kv_pairs* kvs) {
+ char* s = nullptr;
size_t sz = 0;
size_t cap = 0;
append_chr('{', &s, &sz, &cap);
for (size_t i = 0; i < kvs->num_kvs; i++) {
if (i != 0) append_chr(',', &s, &sz, &cap);
- append_esc_str((const uint8_t *)kvs->kvs[i].key, strlen(kvs->kvs[i].key),
- &s, &sz, &cap);
+ append_esc_str((const uint8_t*)kvs->kvs[i].key, strlen(kvs->kvs[i].key), &s,
+ &sz, &cap);
gpr_free(kvs->kvs[i].key);
append_chr(':', &s, &sz, &cap);
append_str(kvs->kvs[i].value, &s, &sz, &cap);
@@ -724,16 +721,16 @@ static char *finish_kvs(kv_pairs *kvs) {
return s;
}
-const char *grpc_error_string(grpc_error *err) {
+const char* grpc_error_string(grpc_error* err) {
GPR_TIMER_BEGIN("grpc_error_string", 0);
if (err == GRPC_ERROR_NONE) return no_error_string;
if (err == GRPC_ERROR_OOM) return oom_error_string;
if (err == GRPC_ERROR_CANCELLED) return cancelled_error_string;
- void *p = (void *)gpr_atm_acq_load(&err->atomics.error_string);
- if (p != NULL) {
+ void* p = (void*)gpr_atm_acq_load(&err->atomics.error_string);
+ if (p != nullptr) {
GPR_TIMER_END("grpc_error_string", 0);
- return (const char *)p;
+ return (const char*)p;
}
kv_pairs kvs;
@@ -748,25 +745,25 @@ const char *grpc_error_string(grpc_error *err) {
qsort(kvs.kvs, kvs.num_kvs, sizeof(kv_pair), cmp_kvs);
- char *out = finish_kvs(&kvs);
+ char* out = finish_kvs(&kvs);
if (!gpr_atm_rel_cas(&err->atomics.error_string, 0, (gpr_atm)out)) {
gpr_free(out);
- out = (char *)gpr_atm_no_barrier_load(&err->atomics.error_string);
+ out = (char*)gpr_atm_acq_load(&err->atomics.error_string);
}
GPR_TIMER_END("grpc_error_string", 0);
return out;
}
-grpc_error *grpc_os_error(const char *file, int line, int err,
- const char *call_name) {
+grpc_error* grpc_os_error(const char* file, int line, int err,
+ const char* call_name) {
return grpc_error_set_str(
grpc_error_set_str(
grpc_error_set_int(
grpc_error_create(file, line,
- grpc_slice_from_static_string("OS Error"), NULL,
- 0),
+ grpc_slice_from_static_string("OS Error"),
+ nullptr, 0),
GRPC_ERROR_INT_ERRNO, err),
GRPC_ERROR_STR_OS_ERROR,
grpc_slice_from_static_string(strerror(err))),
@@ -774,10 +771,10 @@ grpc_error *grpc_os_error(const char *file, int line, int err,
}
#ifdef GPR_WINDOWS
-grpc_error *grpc_wsa_error(const char *file, int line, int err,
- const char *call_name) {
- char *utf8_message = gpr_format_message(err);
- grpc_error *error = grpc_error_set_str(
+grpc_error* grpc_wsa_error(const char* file, int line, int err,
+ const char* call_name) {
+ char* utf8_message = gpr_format_message(err);
+ grpc_error* error = grpc_error_set_str(
grpc_error_set_str(
grpc_error_set_int(
grpc_error_create(file, line,
@@ -791,10 +788,10 @@ grpc_error *grpc_wsa_error(const char *file, int line, int err,
}
#endif
-bool grpc_log_if_error(const char *what, grpc_error *error, const char *file,
+bool grpc_log_if_error(const char* what, grpc_error* error, const char* file,
int line) {
if (error == GRPC_ERROR_NONE) return true;
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, msg);
GRPC_ERROR_UNREF(error);
return false;
diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h
index b362948691..8c72a439f6 100644
--- a/src/core/lib/iomgr/error.h
+++ b/src/core/lib/iomgr/error.h
@@ -19,28 +19,23 @@
#ifndef GRPC_CORE_LIB_IOMGR_ERROR_H
#define GRPC_CORE_LIB_IOMGR_ERROR_H
+#include <inttypes.h>
#include <stdbool.h>
-#include <stdint.h>
#include <grpc/slice.h>
#include <grpc/status.h>
+#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/debug/trace.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// Opaque representation of an error.
/// See https://github.com/grpc/grpc/blob/master/doc/core/grpc-error.md for a
/// full write up of this object.
typedef struct grpc_error grpc_error;
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_error_refcount;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_error_refcount;
typedef enum {
/// 'errno' from the operating system
@@ -122,15 +117,15 @@ typedef enum {
/// They are always even so that other code (particularly combiner locks,
/// polling engines) can safely use the lower bit for themselves.
-#define GRPC_ERROR_NONE ((grpc_error *)NULL)
-#define GRPC_ERROR_OOM ((grpc_error *)2)
-#define GRPC_ERROR_CANCELLED ((grpc_error *)4)
+#define GRPC_ERROR_NONE ((grpc_error*)NULL)
+#define GRPC_ERROR_OOM ((grpc_error*)2)
+#define GRPC_ERROR_CANCELLED ((grpc_error*)4)
-const char *grpc_error_string(grpc_error *error);
+const char* grpc_error_string(grpc_error* error);
/// Create an error - but use GRPC_ERROR_CREATE instead
-grpc_error *grpc_error_create(const char *file, int line, grpc_slice desc,
- grpc_error **referencing, size_t num_referencing);
+grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc,
+ grpc_error** referencing, size_t num_referencing);
/// Create an error (this is the preferred way of generating an error that is
/// not due to a system call - for system calls, use GRPC_OS_ERROR or
/// GRPC_WSA_ERROR as appropriate)
@@ -156,50 +151,55 @@ grpc_error *grpc_error_create(const char *file, int line, grpc_slice desc,
errs, count)
#ifndef NDEBUG
-grpc_error *grpc_error_ref(grpc_error *err, const char *file, int line);
-void grpc_error_unref(grpc_error *err, const char *file, int line);
+grpc_error* grpc_error_ref(grpc_error* err, const char* file, int line);
+void grpc_error_unref(grpc_error* err, const char* file, int line);
#define GRPC_ERROR_REF(err) grpc_error_ref(err, __FILE__, __LINE__)
#define GRPC_ERROR_UNREF(err) grpc_error_unref(err, __FILE__, __LINE__)
#else
-grpc_error *grpc_error_ref(grpc_error *err);
-void grpc_error_unref(grpc_error *err);
+grpc_error* grpc_error_ref(grpc_error* err);
+void grpc_error_unref(grpc_error* err);
#define GRPC_ERROR_REF(err) grpc_error_ref(err)
#define GRPC_ERROR_UNREF(err) grpc_error_unref(err)
#endif
-grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
+grpc_error* grpc_error_set_int(grpc_error* src, grpc_error_ints which,
intptr_t value) GRPC_MUST_USE_RESULT;
-bool grpc_error_get_int(grpc_error *error, grpc_error_ints which, intptr_t *p);
-grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
+bool grpc_error_get_int(grpc_error* error, grpc_error_ints which, intptr_t* p);
+/// This call takes ownership of the slice; the error is responsible for
+/// eventually unref-ing it.
+grpc_error* grpc_error_set_str(grpc_error* src, grpc_error_strs which,
grpc_slice str) GRPC_MUST_USE_RESULT;
/// Returns false if the specified string is not set.
/// Caller does NOT own the slice.
-bool grpc_error_get_str(grpc_error *error, grpc_error_strs which,
- grpc_slice *s);
+bool grpc_error_get_str(grpc_error* error, grpc_error_strs which,
+ grpc_slice* s);
/// Add a child error: an error that is believed to have contributed to this
/// error occurring. Allows root causing high level errors from lower level
-/// errors that contributed to them.
-grpc_error *grpc_error_add_child(grpc_error *src,
- grpc_error *child) GRPC_MUST_USE_RESULT;
-grpc_error *grpc_os_error(const char *file, int line, int err,
- const char *call_name) GRPC_MUST_USE_RESULT;
+/// errors that contributed to them. The src error takes ownership of the
+/// child error.
+grpc_error* grpc_error_add_child(grpc_error* src,
+ grpc_error* child) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_os_error(const char* file, int line, int err,
+ const char* call_name) GRPC_MUST_USE_RESULT;
+
+inline grpc_error* grpc_assert_never_ok(grpc_error* error) {
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ return error;
+}
+
/// create an error associated with errno!=0 (an 'operating system' error)
#define GRPC_OS_ERROR(err, call_name) \
- grpc_os_error(__FILE__, __LINE__, err, call_name)
-grpc_error *grpc_wsa_error(const char *file, int line, int err,
- const char *call_name) GRPC_MUST_USE_RESULT;
+ grpc_assert_never_ok(grpc_os_error(__FILE__, __LINE__, err, call_name))
+grpc_error* grpc_wsa_error(const char* file, int line, int err,
+ const char* call_name) GRPC_MUST_USE_RESULT;
/// windows only: create an error associated with WSAGetLastError()!=0
#define GRPC_WSA_ERROR(err, call_name) \
grpc_wsa_error(__FILE__, __LINE__, err, call_name)
-bool grpc_log_if_error(const char *what, grpc_error *error, const char *file,
+bool grpc_log_if_error(const char* what, grpc_error* error, const char* file,
int line);
#define GRPC_LOG_IF_ERROR(what, error) \
grpc_log_if_error((what), (error), __FILE__, __LINE__)
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_ERROR_H */
diff --git a/src/core/lib/iomgr/error_internal.h b/src/core/lib/iomgr/error_internal.h
index 7507484557..6cb09c2cdb 100644
--- a/src/core/lib/iomgr/error_internal.h
+++ b/src/core/lib/iomgr/error_internal.h
@@ -23,11 +23,12 @@
#include <stdbool.h> // TODO, do we need this?
#include <grpc/support/sync.h>
+#include "src/core/lib/iomgr/error.h"
typedef struct grpc_linked_error grpc_linked_error;
struct grpc_linked_error {
- grpc_error *err;
+ grpc_error* err;
uint8_t next;
};
@@ -55,6 +56,6 @@ struct grpc_error {
intptr_t arena[0];
};
-bool grpc_error_is_special(grpc_error *err);
+bool grpc_error_is_special(struct grpc_error* err);
#endif /* GRPC_CORE_LIB_IOMGR_ERROR_INTERNAL_H */
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.c b/src/core/lib/iomgr/ev_epoll1_linux.cc
index 3ac12ab56f..ad274b839c 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.c
+++ b/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -18,13 +18,17 @@
#include "src/core/lib/iomgr/port.h"
-/* This polling engine is only relevant on linux kernels supporting epoll() */
-#ifdef GRPC_LINUX_EPOLL
+#include <grpc/support/log.h>
+/* This polling engine is only relevant on linux kernels supporting epoll
+ epoll_create() or epoll_create1() */
+#ifdef GRPC_LINUX_EPOLL
#include "src/core/lib/iomgr/ev_epoll1_linux.h"
#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
#include <poll.h>
#include <pthread.h>
#include <string.h>
@@ -34,19 +38,19 @@
#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/tls.h>
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/string.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"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/lockfree_event.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/string.h"
static grpc_wakeup_fd global_wakeup_fd;
@@ -82,11 +86,28 @@ typedef struct epoll_set {
/* The global singleton epoll set */
static epoll_set g_epoll_set;
+static int epoll_create_and_cloexec() {
+#ifdef GRPC_LINUX_EPOLL_CREATE1
+ int fd = epoll_create1(EPOLL_CLOEXEC);
+ if (fd < 0) {
+ gpr_log(GPR_ERROR, "epoll_create1 unavailable");
+ }
+#else
+ int fd = epoll_create(MAX_EPOLL_EVENTS);
+ if (fd < 0) {
+ gpr_log(GPR_ERROR, "epoll_create unavailable");
+ } else if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) {
+ gpr_log(GPR_ERROR, "fcntl following epoll_create failed");
+ return -1;
+ }
+#endif
+ return fd;
+}
+
/* Must be called *only* once */
static bool epoll_set_init() {
- g_epoll_set.epfd = epoll_create1(EPOLL_CLOEXEC);
+ g_epoll_set.epfd = epoll_create_and_cloexec();
if (g_epoll_set.epfd < 0) {
- gpr_log(GPR_ERROR, "epoll unavailable");
return false;
}
@@ -111,10 +132,10 @@ static void epoll_set_shutdown() {
struct grpc_fd {
int fd;
- gpr_atm read_closure;
- gpr_atm write_closure;
+ grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure;
+ grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure;
- struct grpc_fd *freelist_next;
+ struct grpc_fd* freelist_next;
/* The pollset that last noticed that the fd is readable. The actual type
* stored in this is (grpc_pollset *) */
@@ -132,7 +153,7 @@ static void fd_global_shutdown(void);
typedef enum { UNKICKED, KICKED, DESIGNATED_POLLER } kick_state;
-static const char *kick_state_string(kick_state st) {
+static const char* kick_state_string(kick_state st) {
switch (st) {
case UNKICKED:
return "UNKICKED";
@@ -148,8 +169,8 @@ struct grpc_pollset_worker {
kick_state state;
int kick_state_mutator; // which line of code last changed kick state
bool initialized_cv;
- grpc_pollset_worker *next;
- grpc_pollset_worker *prev;
+ grpc_pollset_worker* next;
+ grpc_pollset_worker* prev;
gpr_cv cv;
grpc_closure_list schedule_on_end_work;
};
@@ -164,29 +185,29 @@ struct grpc_pollset_worker {
typedef struct pollset_neighborhood {
gpr_mu mu;
- grpc_pollset *active_root;
+ grpc_pollset* active_root;
char pad[GPR_CACHELINE_SIZE];
} pollset_neighborhood;
struct grpc_pollset {
gpr_mu mu;
- pollset_neighborhood *neighborhood;
+ pollset_neighborhood* neighborhood;
bool reassigning_neighborhood;
- grpc_pollset_worker *root_worker;
+ grpc_pollset_worker* root_worker;
bool kicked_without_poller;
/* Set to true if the pollset is observed to have no workers available to
poll */
bool seen_inactive;
bool shutting_down; /* Is the pollset shutting down ? */
- grpc_closure *shutdown_closure; /* Called after after shutdown is complete */
+ grpc_closure* shutdown_closure; /* Called after after shutdown is complete */
/* Number of workers who are *about-to* attach themselves to the pollset
* worker list */
int begin_refs;
- grpc_pollset *next;
- grpc_pollset *prev;
+ grpc_pollset* next;
+ grpc_pollset* prev;
};
/*******************************************************************************
@@ -201,8 +222,8 @@ struct grpc_pollset_set {
* Common helpers
*/
-static bool append_error(grpc_error **composite, grpc_error *error,
- const char *desc) {
+static bool append_error(grpc_error** composite, grpc_error* error,
+ const char* desc) {
if (error == GRPC_ERROR_NONE) return true;
if (*composite == GRPC_ERROR_NONE) {
*composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
@@ -233,7 +254,7 @@ static bool append_error(grpc_error **composite, grpc_error *error,
* alarm 'epoch'). This wakeup_fd gives us something to alert on when such a
* case occurs. */
-static grpc_fd *fd_freelist = NULL;
+static grpc_fd* fd_freelist = nullptr;
static gpr_mu fd_freelist_mu;
static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
@@ -241,40 +262,42 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
static void fd_global_shutdown(void) {
gpr_mu_lock(&fd_freelist_mu);
gpr_mu_unlock(&fd_freelist_mu);
- while (fd_freelist != NULL) {
- grpc_fd *fd = fd_freelist;
+ while (fd_freelist != nullptr) {
+ grpc_fd* fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
gpr_free(fd);
}
gpr_mu_destroy(&fd_freelist_mu);
}
-static grpc_fd *fd_create(int fd, const char *name) {
- grpc_fd *new_fd = NULL;
+static grpc_fd* fd_create(int fd, const char* name) {
+ grpc_fd* new_fd = nullptr;
gpr_mu_lock(&fd_freelist_mu);
- if (fd_freelist != NULL) {
+ if (fd_freelist != nullptr) {
new_fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
}
gpr_mu_unlock(&fd_freelist_mu);
- if (new_fd == NULL) {
- new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
+ if (new_fd == nullptr) {
+ new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
+ new_fd->read_closure.Init();
+ new_fd->write_closure.Init();
}
new_fd->fd = fd;
- grpc_lfev_init(&new_fd->read_closure);
- grpc_lfev_init(&new_fd->write_closure);
+ new_fd->read_closure->InitEvent();
+ new_fd->write_closure->InitEvent();
gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
- new_fd->freelist_next = NULL;
+ new_fd->freelist_next = nullptr;
- char *fd_name;
+ char* fd_name;
gpr_asprintf(&fd_name, "%s fd=%d", name, fd);
grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
+ if (grpc_trace_fd_refcount.enabled()) {
gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, new_fd, fd_name);
}
#endif
@@ -290,37 +313,34 @@ static grpc_fd *fd_create(int fd, const char *name) {
return new_fd;
}
-static int fd_wrapped_fd(grpc_fd *fd) { return fd->fd; }
+static int fd_wrapped_fd(grpc_fd* fd) { return fd->fd; }
/* if 'releasing_fd' is true, it means that we are going to detach the internal
* fd from grpc_fd structure (i.e which means we should not be calling
* shutdown() syscall on that fd) */
-static void fd_shutdown_internal(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_error *why, bool releasing_fd) {
- if (grpc_lfev_set_shutdown(exec_ctx, &fd->read_closure,
- GRPC_ERROR_REF(why))) {
+static void fd_shutdown_internal(grpc_fd* fd, grpc_error* why,
+ bool releasing_fd) {
+ if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) {
if (!releasing_fd) {
shutdown(fd->fd, SHUT_RDWR);
}
- grpc_lfev_set_shutdown(exec_ctx, &fd->write_closure, GRPC_ERROR_REF(why));
+ fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));
}
GRPC_ERROR_UNREF(why);
}
/* Might be called multiple times */
-static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
- fd_shutdown_internal(exec_ctx, fd, why, false);
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ fd_shutdown_internal(fd, why, false);
}
-static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *on_done, int *release_fd,
- bool already_closed, const char *reason) {
- grpc_error *error = GRPC_ERROR_NONE;
- bool is_release_fd = (release_fd != NULL);
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ bool is_release_fd = (release_fd != nullptr);
- if (!grpc_lfev_is_shutdown(&fd->read_closure)) {
- fd_shutdown_internal(exec_ctx, fd,
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(reason),
+ if (!fd->read_closure->IsShutdown()) {
+ fd_shutdown_internal(fd, GRPC_ERROR_CREATE_FROM_COPIED_STRING(reason),
is_release_fd);
}
@@ -332,11 +352,11 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
close(fd->fd);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_REF(error));
grpc_iomgr_unregister_object(&fd->iomgr_object);
- grpc_lfev_destroy(&fd->read_closure);
- grpc_lfev_destroy(&fd->write_closure);
+ fd->read_closure->DestroyEvent();
+ fd->write_closure->DestroyEvent();
gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist;
@@ -344,36 +364,30 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
gpr_mu_unlock(&fd_freelist_mu);
}
-static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd) {
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
- return (grpc_pollset *)notifier;
+ return (grpc_pollset*)notifier;
}
-static bool fd_is_shutdown(grpc_fd *fd) {
- return grpc_lfev_is_shutdown(&fd->read_closure);
+static bool fd_is_shutdown(grpc_fd* fd) {
+ return fd->read_closure->IsShutdown();
}
-static void fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- grpc_lfev_notify_on(exec_ctx, &fd->read_closure, closure, "read");
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ fd->read_closure->NotifyOn(closure);
}
-static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- grpc_lfev_notify_on(exec_ctx, &fd->write_closure, closure, "write");
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ fd->write_closure->NotifyOn(closure);
}
-static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_pollset *notifier) {
- grpc_lfev_set_ready(exec_ctx, &fd->read_closure, "read");
+static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
+ fd->read_closure->SetReady();
/* Use release store to match with acquire load in fd_get_read_notifier */
gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
}
-static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
- grpc_lfev_set_ready(exec_ctx, &fd->write_closure, "write");
-}
+static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
/*******************************************************************************
* Pollset Definitions
@@ -385,12 +399,12 @@ GPR_TLS_DECL(g_current_thread_worker);
/* The designated poller */
static gpr_atm g_active_poller;
-static pollset_neighborhood *g_neighborhoods;
+static pollset_neighborhood* g_neighborhoods;
static size_t g_num_neighborhoods;
/* Return true if first in list */
-static bool worker_insert(grpc_pollset *pollset, grpc_pollset_worker *worker) {
- if (pollset->root_worker == NULL) {
+static bool worker_insert(grpc_pollset* pollset, grpc_pollset_worker* worker) {
+ if (pollset->root_worker == nullptr) {
pollset->root_worker = worker;
worker->next = worker->prev = worker;
return true;
@@ -406,11 +420,11 @@ static bool worker_insert(grpc_pollset *pollset, grpc_pollset_worker *worker) {
/* Return true if last in list */
typedef enum { EMPTIED, NEW_ROOT, REMOVED } worker_remove_result;
-static worker_remove_result worker_remove(grpc_pollset *pollset,
- grpc_pollset_worker *worker) {
+static worker_remove_result worker_remove(grpc_pollset* pollset,
+ grpc_pollset_worker* worker) {
if (worker == pollset->root_worker) {
if (worker == worker->next) {
- pollset->root_worker = NULL;
+ pollset->root_worker = nullptr;
return EMPTIED;
} else {
pollset->root_worker = worker->next;
@@ -429,12 +443,12 @@ static size_t choose_neighborhood(void) {
return (size_t)gpr_cpu_current_cpu() % g_num_neighborhoods;
}
-static grpc_error *pollset_global_init(void) {
+static grpc_error* pollset_global_init(void) {
gpr_tls_init(&g_current_thread_pollset);
gpr_tls_init(&g_current_thread_worker);
gpr_atm_no_barrier_store(&g_active_poller, 0);
global_wakeup_fd.read_fd = -1;
- grpc_error *err = grpc_wakeup_fd_init(&global_wakeup_fd);
+ grpc_error* err = grpc_wakeup_fd_init(&global_wakeup_fd);
if (err != GRPC_ERROR_NONE) return err;
struct epoll_event ev;
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
@@ -444,8 +458,8 @@ static grpc_error *pollset_global_init(void) {
return GRPC_OS_ERROR(errno, "epoll_ctl");
}
g_num_neighborhoods = GPR_CLAMP(gpr_cpu_num_cores(), 1, MAX_NEIGHBORHOODS);
- g_neighborhoods = (pollset_neighborhood *)gpr_zalloc(
- sizeof(*g_neighborhoods) * g_num_neighborhoods);
+ g_neighborhoods = (pollset_neighborhood*)gpr_zalloc(sizeof(*g_neighborhoods) *
+ g_num_neighborhoods);
for (size_t i = 0; i < g_num_neighborhoods; i++) {
gpr_mu_init(&g_neighborhoods[i].mu);
}
@@ -462,24 +476,24 @@ static void pollset_global_shutdown(void) {
gpr_free(g_neighborhoods);
}
-static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
+static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
gpr_mu_init(&pollset->mu);
*mu = &pollset->mu;
pollset->neighborhood = &g_neighborhoods[choose_neighborhood()];
pollset->reassigning_neighborhood = false;
- pollset->root_worker = NULL;
+ pollset->root_worker = nullptr;
pollset->kicked_without_poller = false;
pollset->seen_inactive = true;
pollset->shutting_down = false;
- pollset->shutdown_closure = NULL;
+ pollset->shutdown_closure = nullptr;
pollset->begin_refs = 0;
- pollset->next = pollset->prev = NULL;
+ pollset->next = pollset->prev = nullptr;
}
-static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
+static void pollset_destroy(grpc_pollset* pollset) {
gpr_mu_lock(&pollset->mu);
if (!pollset->seen_inactive) {
- pollset_neighborhood *neighborhood = pollset->neighborhood;
+ pollset_neighborhood* neighborhood = pollset->neighborhood;
gpr_mu_unlock(&pollset->mu);
retry_lock_neighborhood:
gpr_mu_lock(&neighborhood->mu);
@@ -495,7 +509,7 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
pollset->next->prev = pollset->prev;
if (pollset == pollset->neighborhood->active_root) {
pollset->neighborhood->active_root =
- pollset->next == pollset ? NULL : pollset->next;
+ pollset->next == pollset ? nullptr : pollset->next;
}
}
gpr_mu_unlock(&pollset->neighborhood->mu);
@@ -504,27 +518,26 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
gpr_mu_destroy(&pollset->mu);
}
-static grpc_error *pollset_kick_all(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset) {
+static grpc_error* pollset_kick_all(grpc_pollset* pollset) {
GPR_TIMER_BEGIN("pollset_kick_all", 0);
- grpc_error *error = GRPC_ERROR_NONE;
- if (pollset->root_worker != NULL) {
- grpc_pollset_worker *worker = pollset->root_worker;
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (pollset->root_worker != nullptr) {
+ grpc_pollset_worker* worker = pollset->root_worker;
do {
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK();
switch (worker->state) {
case KICKED:
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
break;
case UNKICKED:
SET_KICK_STATE(worker, KICKED);
if (worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&worker->cv);
}
break;
case DESIGNATED_POLLER:
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
SET_KICK_STATE(worker, KICKED);
append_error(&error, grpc_wakeup_fd_wakeup(&global_wakeup_fd),
"pollset_kick_all");
@@ -540,47 +553,36 @@ static grpc_error *pollset_kick_all(grpc_exec_ctx *exec_ctx,
return error;
}
-static void pollset_maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset) {
- if (pollset->shutdown_closure != NULL && pollset->root_worker == NULL &&
+static void pollset_maybe_finish_shutdown(grpc_pollset* pollset) {
+ if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr &&
pollset->begin_refs == 0) {
GPR_TIMER_MARK("pollset_finish_shutdown", 0);
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE);
- pollset->shutdown_closure = NULL;
+ GRPC_CLOSURE_SCHED(pollset->shutdown_closure, GRPC_ERROR_NONE);
+ pollset->shutdown_closure = nullptr;
}
}
-static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_TIMER_BEGIN("pollset_shutdown", 0);
- GPR_ASSERT(pollset->shutdown_closure == NULL);
+ GPR_ASSERT(pollset->shutdown_closure == nullptr);
GPR_ASSERT(!pollset->shutting_down);
pollset->shutdown_closure = closure;
pollset->shutting_down = true;
- GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(exec_ctx, pollset));
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
+ GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(pollset));
+ pollset_maybe_finish_shutdown(pollset);
GPR_TIMER_END("pollset_shutdown", 0);
}
-static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
- gpr_timespec now) {
- gpr_timespec timeout;
- if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
- return -1;
- }
-
- if (gpr_time_cmp(deadline, now) <= 0) {
+static int poll_deadline_to_millis_timeout(grpc_millis millis) {
+ if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
+ grpc_millis delta = millis - grpc_core::ExecCtx::Get()->Now();
+ if (delta > INT_MAX) {
+ return INT_MAX;
+ } else if (delta < 0) {
return 0;
+ } else {
+ return (int)delta;
}
-
- static const gpr_timespec round_up = {
- 0, /* tv_sec */
- GPR_NS_PER_MS - 1, /* tv_nsec */
- GPR_TIMESPAN /* clock_type */
- };
- timeout = gpr_time_sub(deadline, now);
- int millis = gpr_time_to_millis(gpr_time_add(timeout, round_up));
- return millis >= 1 ? millis : 1;
}
/* Process the epoll events found by do_epoll_wait() function.
@@ -591,10 +593,9 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
NOTE ON SYNCRHONIZATION: Similar to do_epoll_wait(), this function is only
called by g_active_poller thread. So there is no need for synchronization
when accessing fields in g_epoll_set */
-static grpc_error *process_epoll_events(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset) {
- static const char *err_desc = "process_events";
- grpc_error *error = GRPC_ERROR_NONE;
+static grpc_error* process_epoll_events(grpc_pollset* pollset) {
+ static const char* err_desc = "process_events";
+ grpc_error* error = GRPC_ERROR_NONE;
GPR_TIMER_BEGIN("process_epoll_events", 0);
long num_events = gpr_atm_acq_load(&g_epoll_set.num_events);
@@ -603,24 +604,24 @@ static grpc_error *process_epoll_events(grpc_exec_ctx *exec_ctx,
(idx < MAX_EPOLL_EVENTS_HANDLED_PER_ITERATION) && cursor != num_events;
idx++) {
long c = cursor++;
- struct epoll_event *ev = &g_epoll_set.events[c];
- void *data_ptr = ev->data.ptr;
+ struct epoll_event* ev = &g_epoll_set.events[c];
+ void* data_ptr = ev->data.ptr;
if (data_ptr == &global_wakeup_fd) {
append_error(&error, grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd),
err_desc);
} else {
- grpc_fd *fd = (grpc_fd *)(data_ptr);
+ grpc_fd* fd = (grpc_fd*)(data_ptr);
bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0;
bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0;
bool write_ev = (ev->events & EPOLLOUT) != 0;
if (read_ev || cancel) {
- fd_become_readable(exec_ctx, fd, pollset);
+ fd_become_readable(fd, pollset);
}
if (write_ev || cancel) {
- fd_become_writable(exec_ctx, fd);
+ fd_become_writable(fd);
}
}
}
@@ -636,17 +637,16 @@ static grpc_error *process_epoll_events(grpc_exec_ctx *exec_ctx,
NOTE ON SYNCHRONIZATION: At any point of time, only the g_active_poller
(i.e the designated poller thread) will be calling this function. So there is
no need for any synchronization when accesing fields in g_epoll_set */
-static grpc_error *do_epoll_wait(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
- gpr_timespec now, gpr_timespec deadline) {
+static grpc_error* do_epoll_wait(grpc_pollset* ps, grpc_millis deadline) {
GPR_TIMER_BEGIN("do_epoll_wait", 0);
int r;
- int timeout = poll_deadline_to_millis_timeout(deadline, now);
+ int timeout = poll_deadline_to_millis_timeout(deadline);
if (timeout != 0) {
GRPC_SCHEDULING_START_BLOCKING_REGION;
}
do {
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
r = epoll_wait(g_epoll_set.epfd, g_epoll_set.events, MAX_EPOLL_EVENTS,
timeout);
} while (r < 0 && errno == EINTR);
@@ -656,9 +656,9 @@ static grpc_error *do_epoll_wait(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
- GRPC_STATS_INC_POLL_EVENTS_RETURNED(exec_ctx, r);
+ GRPC_STATS_INC_POLL_EVENTS_RETURNED(r);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "ps: %p poll got %d events", ps, r);
}
@@ -669,18 +669,18 @@ static grpc_error *do_epoll_wait(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
return GRPC_ERROR_NONE;
}
-static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
- grpc_pollset_worker **worker_hdl, gpr_timespec *now,
- gpr_timespec deadline) {
+static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
GPR_TIMER_BEGIN("begin_worker", 0);
- if (worker_hdl != NULL) *worker_hdl = worker;
+ if (worker_hdl != nullptr) *worker_hdl = worker;
worker->initialized_cv = false;
SET_KICK_STATE(worker, UNKICKED);
worker->schedule_on_end_work = (grpc_closure_list)GRPC_CLOSURE_LIST_INIT;
pollset->begin_refs++;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, "PS:%p BEGIN_STARTS:%p", pollset, worker);
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p BEGIN_STARTS:%p", pollset, worker);
}
if (pollset->seen_inactive) {
@@ -692,14 +692,14 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
pollset->reassigning_neighborhood = true;
pollset->neighborhood = &g_neighborhoods[choose_neighborhood()];
}
- pollset_neighborhood *neighborhood = pollset->neighborhood;
+ pollset_neighborhood* neighborhood = pollset->neighborhood;
gpr_mu_unlock(&pollset->mu);
// pollset unlocked: state may change (even worker->kick_state)
retry_lock_neighborhood:
gpr_mu_lock(&neighborhood->mu);
gpr_mu_lock(&pollset->mu);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, "PS:%p BEGIN_REORG:%p kick_state=%s is_reassigning=%d",
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p BEGIN_REORG:%p kick_state=%s is_reassigning=%d",
pollset, worker, kick_state_string(worker->state),
is_reassigning);
}
@@ -722,7 +722,7 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
not visible in the "kick any" path yet */
if (worker->state == UNKICKED) {
pollset->seen_inactive = false;
- if (neighborhood->active_root == NULL) {
+ if (neighborhood->active_root == nullptr) {
neighborhood->active_root = pollset->next = pollset->prev = pollset;
/* Make this the designated poller if there isn't one already */
if (worker->state == UNKICKED &&
@@ -750,24 +750,25 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
worker->initialized_cv = true;
gpr_cv_init(&worker->cv);
while (worker->state == UNKICKED && !pollset->shutting_down) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, "PS:%p BEGIN_WAIT:%p kick_state=%s shutdown=%d",
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p BEGIN_WAIT:%p kick_state=%s shutdown=%d",
pollset, worker, kick_state_string(worker->state),
pollset->shutting_down);
}
- if (gpr_cv_wait(&worker->cv, &pollset->mu, deadline) &&
+ if (gpr_cv_wait(&worker->cv, &pollset->mu,
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC)) &&
worker->state == UNKICKED) {
/* If gpr_cv_wait returns true (i.e a timeout), pretend that the worker
received a kick */
SET_KICK_STATE(worker, KICKED);
}
}
- *now = gpr_now(now->clock_type);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
}
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR,
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
"PS:%p BEGIN_DONE:%p kick_state=%s shutdown=%d "
"kicked_without_poller: %d",
pollset, worker, kick_state_string(worker->state),
@@ -794,35 +795,35 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
}
static bool check_neighborhood_for_available_poller(
- grpc_exec_ctx *exec_ctx, pollset_neighborhood *neighborhood) {
+ pollset_neighborhood* neighborhood) {
GPR_TIMER_BEGIN("check_neighborhood_for_available_poller", 0);
bool found_worker = false;
do {
- grpc_pollset *inspect = neighborhood->active_root;
- if (inspect == NULL) {
+ grpc_pollset* inspect = neighborhood->active_root;
+ if (inspect == nullptr) {
break;
}
gpr_mu_lock(&inspect->mu);
GPR_ASSERT(!inspect->seen_inactive);
- grpc_pollset_worker *inspect_worker = inspect->root_worker;
- if (inspect_worker != NULL) {
+ grpc_pollset_worker* inspect_worker = inspect->root_worker;
+ if (inspect_worker != nullptr) {
do {
switch (inspect_worker->state) {
case UNKICKED:
if (gpr_atm_no_barrier_cas(&g_active_poller, 0,
(gpr_atm)inspect_worker)) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. choose next poller to be %p",
inspect_worker);
}
SET_KICK_STATE(inspect_worker, DESIGNATED_POLLER);
if (inspect_worker->initialized_cv) {
GPR_TIMER_MARK("signal worker", 0);
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&inspect_worker->cv);
}
} else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. beaten to choose next poller");
}
}
@@ -840,17 +841,17 @@ static bool check_neighborhood_for_available_poller(
} while (!found_worker && inspect_worker != inspect->root_worker);
}
if (!found_worker) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. mark pollset %p inactive", inspect);
}
inspect->seen_inactive = true;
if (inspect == neighborhood->active_root) {
neighborhood->active_root =
- inspect->next == inspect ? NULL : inspect->next;
+ inspect->next == inspect ? nullptr : inspect->next;
}
inspect->next->prev = inspect->prev;
inspect->prev->next = inspect->next;
- inspect->next = inspect->prev = NULL;
+ inspect->next = inspect->prev = nullptr;
}
gpr_mu_unlock(&inspect->mu);
} while (!found_worker);
@@ -858,31 +859,30 @@ static bool check_neighborhood_for_available_poller(
return found_worker;
}
-static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *worker,
- grpc_pollset_worker **worker_hdl) {
+static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
+ grpc_pollset_worker** worker_hdl) {
GPR_TIMER_BEGIN("end_worker", 0);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p END_WORKER:%p", pollset, worker);
}
- if (worker_hdl != NULL) *worker_hdl = NULL;
+ if (worker_hdl != nullptr) *worker_hdl = nullptr;
/* Make sure we appear kicked */
SET_KICK_STATE(worker, KICKED);
grpc_closure_list_move(&worker->schedule_on_end_work,
- &exec_ctx->closure_list);
+ grpc_core::ExecCtx::Get()->closure_list());
if (gpr_atm_no_barrier_load(&g_active_poller) == (gpr_atm)worker) {
if (worker->next != worker && worker->next->state == UNKICKED) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. choose next poller to be peer %p", worker);
}
GPR_ASSERT(worker->next->initialized_cv);
gpr_atm_no_barrier_store(&g_active_poller, (gpr_atm)worker->next);
SET_KICK_STATE(worker->next, DESIGNATED_POLLER);
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&worker->next->cv);
- if (grpc_exec_ctx_has_work(exec_ctx)) {
+ if (grpc_core::ExecCtx::Get()->HasWork()) {
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
} else {
@@ -893,12 +893,11 @@ static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
bool found_worker = false;
bool scan_state[MAX_NEIGHBORHOODS];
for (size_t i = 0; !found_worker && i < g_num_neighborhoods; i++) {
- pollset_neighborhood *neighborhood =
+ pollset_neighborhood* neighborhood =
&g_neighborhoods[(poller_neighborhood_idx + i) %
g_num_neighborhoods];
if (gpr_mu_trylock(&neighborhood->mu)) {
- found_worker =
- check_neighborhood_for_available_poller(exec_ctx, neighborhood);
+ found_worker = check_neighborhood_for_available_poller(neighborhood);
gpr_mu_unlock(&neighborhood->mu);
scan_state[i] = true;
} else {
@@ -907,30 +906,29 @@ static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
}
for (size_t i = 0; !found_worker && i < g_num_neighborhoods; i++) {
if (scan_state[i]) continue;
- pollset_neighborhood *neighborhood =
+ pollset_neighborhood* neighborhood =
&g_neighborhoods[(poller_neighborhood_idx + i) %
g_num_neighborhoods];
gpr_mu_lock(&neighborhood->mu);
- found_worker =
- check_neighborhood_for_available_poller(exec_ctx, neighborhood);
+ found_worker = check_neighborhood_for_available_poller(neighborhood);
gpr_mu_unlock(&neighborhood->mu);
}
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
- } else if (grpc_exec_ctx_has_work(exec_ctx)) {
+ } else if (grpc_core::ExecCtx::Get()->HasWork()) {
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
if (worker->initialized_cv) {
gpr_cv_destroy(&worker->cv);
}
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. remove worker");
}
if (EMPTIED == worker_remove(pollset, worker)) {
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
+ pollset_maybe_finish_shutdown(pollset);
}
GPR_ASSERT(gpr_atm_no_barrier_load(&g_active_poller) != (gpr_atm)worker);
GPR_TIMER_END("end_worker", 0);
@@ -940,12 +938,12 @@ static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
The function pollset_work() may temporarily release the lock (pollset->po.mu)
during the course of its execution but it will always re-acquire the lock and
ensure that it is held by the time the function returns */
-static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
- grpc_pollset_worker **worker_hdl,
- gpr_timespec now, gpr_timespec deadline) {
+static grpc_error* pollset_work(grpc_pollset* ps,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
grpc_pollset_worker worker;
- grpc_error *error = GRPC_ERROR_NONE;
- static const char *err_desc = "pollset_work";
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* err_desc = "pollset_work";
GPR_TIMER_BEGIN("pollset_work", 0);
if (ps->kicked_without_poller) {
ps->kicked_without_poller = false;
@@ -953,7 +951,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
return GRPC_ERROR_NONE;
}
- if (begin_worker(ps, &worker, worker_hdl, &now, deadline)) {
+ if (begin_worker(ps, &worker, worker_hdl, deadline)) {
gpr_tls_set(&g_current_thread_pollset, (intptr_t)ps);
gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
GPR_ASSERT(!ps->shutting_down);
@@ -971,15 +969,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
process_epoll_events() returns very quickly: It just queues the work on
exec_ctx but does not execute it (the actual exectution or more
- accurately grpc_exec_ctx_flush() happens in end_worker() AFTER selecting
- a designated poller). So we are not waiting long periods without a
- designated poller */
+ accurately grpc_core::ExecCtx::Get()->Flush() happens in end_worker()
+ AFTER selecting a designated poller). So we are not waiting long periods
+ without a designated poller */
if (gpr_atm_acq_load(&g_epoll_set.cursor) ==
gpr_atm_acq_load(&g_epoll_set.num_events)) {
- append_error(&error, do_epoll_wait(exec_ctx, ps, now, deadline),
- err_desc);
+ append_error(&error, do_epoll_wait(ps, deadline), err_desc);
}
- append_error(&error, process_epoll_events(exec_ctx, ps), err_desc);
+ append_error(&error, process_epoll_events(ps), err_desc);
gpr_mu_lock(&ps->mu); /* lock */
@@ -987,87 +984,87 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *ps,
} else {
gpr_tls_set(&g_current_thread_pollset, (intptr_t)ps);
}
- end_worker(exec_ctx, ps, &worker, worker_hdl);
+ end_worker(ps, &worker, worker_hdl);
gpr_tls_set(&g_current_thread_pollset, 0);
GPR_TIMER_END("pollset_work", 0);
return error;
}
-static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker) {
+static grpc_error* pollset_kick(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker) {
GPR_TIMER_BEGIN("pollset_kick", 0);
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
- grpc_error *ret_err = GRPC_ERROR_NONE;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ GRPC_STATS_INC_POLLSET_KICK();
+ grpc_error* ret_err = GRPC_ERROR_NONE;
+ if (grpc_polling_trace.enabled()) {
gpr_strvec log;
gpr_strvec_init(&log);
- char *tmp;
- gpr_asprintf(
- &tmp, "PS:%p KICK:%p curps=%p curworker=%p root=%p", pollset,
- specific_worker, (void *)gpr_tls_get(&g_current_thread_pollset),
- (void *)gpr_tls_get(&g_current_thread_worker), pollset->root_worker);
+ char* tmp;
+ gpr_asprintf(&tmp, "PS:%p KICK:%p curps=%p curworker=%p root=%p", pollset,
+ specific_worker, (void*)gpr_tls_get(&g_current_thread_pollset),
+ (void*)gpr_tls_get(&g_current_thread_worker),
+ pollset->root_worker);
gpr_strvec_add(&log, tmp);
- if (pollset->root_worker != NULL) {
+ if (pollset->root_worker != nullptr) {
gpr_asprintf(&tmp, " {kick_state=%s next=%p {kick_state=%s}}",
kick_state_string(pollset->root_worker->state),
pollset->root_worker->next,
kick_state_string(pollset->root_worker->next->state));
gpr_strvec_add(&log, tmp);
}
- if (specific_worker != NULL) {
+ if (specific_worker != nullptr) {
gpr_asprintf(&tmp, " worker_kick_state=%s",
kick_state_string(specific_worker->state));
gpr_strvec_add(&log, tmp);
}
- tmp = gpr_strvec_flatten(&log, NULL);
+ tmp = gpr_strvec_flatten(&log, nullptr);
gpr_strvec_destroy(&log);
- gpr_log(GPR_ERROR, "%s", tmp);
+ gpr_log(GPR_DEBUG, "%s", tmp);
gpr_free(tmp);
}
- if (specific_worker == NULL) {
+ if (specific_worker == nullptr) {
if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) {
- grpc_pollset_worker *root_worker = pollset->root_worker;
- if (root_worker == NULL) {
- GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx);
+ grpc_pollset_worker* root_worker = pollset->root_worker;
+ if (root_worker == nullptr) {
+ GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER();
pollset->kicked_without_poller = true;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kicked_without_poller");
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kicked_without_poller");
}
goto done;
}
- grpc_pollset_worker *next_worker = root_worker->next;
+ grpc_pollset_worker* next_worker = root_worker->next;
if (root_worker->state == KICKED) {
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. already kicked %p", root_worker);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. already kicked %p", root_worker);
}
SET_KICK_STATE(root_worker, KICKED);
goto done;
} else if (next_worker->state == KICKED) {
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. already kicked %p", next_worker);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. already kicked %p", next_worker);
}
SET_KICK_STATE(next_worker, KICKED);
goto done;
} else if (root_worker ==
next_worker && // only try and wake up a poller if
// there is no next worker
- root_worker == (grpc_pollset_worker *)gpr_atm_no_barrier_load(
+ root_worker == (grpc_pollset_worker*)gpr_atm_no_barrier_load(
&g_active_poller)) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kicked %p", root_worker);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kicked %p", root_worker);
}
SET_KICK_STATE(root_worker, KICKED);
ret_err = grpc_wakeup_fd_wakeup(&global_wakeup_fd);
goto done;
} else if (next_worker->state == UNKICKED) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kicked %p", next_worker);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kicked %p", next_worker);
}
GPR_ASSERT(next_worker->initialized_cv);
SET_KICK_STATE(next_worker, KICKED);
@@ -1075,22 +1072,22 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
goto done;
} else if (next_worker->state == DESIGNATED_POLLER) {
if (root_worker->state != DESIGNATED_POLLER) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(
- GPR_ERROR,
+ GPR_DEBUG,
" .. kicked root non-poller %p (initialized_cv=%d) (poller=%p)",
root_worker, root_worker->initialized_cv, next_worker);
}
SET_KICK_STATE(root_worker, KICKED);
if (root_worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&root_worker->cv);
}
goto done;
} else {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. non-root poller %p (root=%p)", next_worker,
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. non-root poller %p (root=%p)", next_worker,
root_worker);
}
SET_KICK_STATE(next_worker, KICKED);
@@ -1098,15 +1095,15 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
goto done;
}
} else {
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
GPR_ASSERT(next_worker->state == KICKED);
SET_KICK_STATE(next_worker, KICKED);
goto done;
}
} else {
- GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kicked while waking up");
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kicked while waking up");
}
goto done;
}
@@ -1115,39 +1112,39 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
}
if (specific_worker->state == KICKED) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. specific worker already kicked");
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. specific worker already kicked");
}
goto done;
} else if (gpr_tls_get(&g_current_thread_worker) ==
(intptr_t)specific_worker) {
- GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. mark %p kicked", specific_worker);
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. mark %p kicked", specific_worker);
}
SET_KICK_STATE(specific_worker, KICKED);
goto done;
} else if (specific_worker ==
- (grpc_pollset_worker *)gpr_atm_no_barrier_load(&g_active_poller)) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kick active poller");
+ (grpc_pollset_worker*)gpr_atm_no_barrier_load(&g_active_poller)) {
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kick active poller");
}
SET_KICK_STATE(specific_worker, KICKED);
ret_err = grpc_wakeup_fd_wakeup(&global_wakeup_fd);
goto done;
} else if (specific_worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kick waiting worker");
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kick waiting worker");
}
SET_KICK_STATE(specific_worker, KICKED);
gpr_cv_signal(&specific_worker->cv);
goto done;
} else {
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, " .. kick non-waiting worker");
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. kick non-waiting worker");
}
SET_KICK_STATE(specific_worker, KICKED);
goto done;
@@ -1157,39 +1154,31 @@ done:
return ret_err;
}
-static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_fd *fd) {}
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {}
/*******************************************************************************
* Pollset-set Definitions
*/
-static grpc_pollset_set *pollset_set_create(void) {
- return (grpc_pollset_set *)((intptr_t)0xdeafbeef);
+static grpc_pollset_set* pollset_set_create(void) {
+ return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss) {}
+static void pollset_set_destroy(grpc_pollset_set* pss) {}
-static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
- grpc_fd *fd) {}
+static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {}
-static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
- grpc_fd *fd) {}
+static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) {}
-static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss, grpc_pollset *ps) {}
+static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {}
-static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss, grpc_pollset *ps) {}
+static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {}
-static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {}
+static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {}
-static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {}
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {}
/*******************************************************************************
* Event engine binding
@@ -1235,13 +1224,14 @@ static const grpc_event_engine_vtable vtable = {
/* It is possible that GLIBC has epoll but the underlying kernel doesn't.
* Create epoll_fd (epoll_set_init() takes care of that) to make sure epoll
* support is available */
-const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) {
+const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) {
if (!grpc_has_wakeup_fd()) {
- return NULL;
+ gpr_log(GPR_ERROR, "Skipping epoll1 because of no wakeup fd.");
+ return nullptr;
}
if (!epoll_set_init()) {
- return NULL;
+ return nullptr;
}
fd_global_init();
@@ -1249,7 +1239,7 @@ const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) {
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
fd_global_shutdown();
epoll_set_shutdown();
- return NULL;
+ return nullptr;
}
return &vtable;
@@ -1257,11 +1247,11 @@ const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) {
#else /* defined(GRPC_LINUX_EPOLL) */
#if defined(GRPC_POSIX_SOCKET)
-#include "src/core/lib/iomgr/ev_posix.h"
+#include "src/core/lib/iomgr/ev_epoll1_linux.h"
/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
* NULL */
-const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) {
- return NULL;
+const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) {
+ return nullptr;
}
#endif /* defined(GRPC_POSIX_SOCKET) */
#endif /* !defined(GRPC_LINUX_EPOLL) */
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.h b/src/core/lib/iomgr/ev_epoll1_linux.h
index 0696e0df40..9a1b96bd45 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.h
+++ b/src/core/lib/iomgr/ev_epoll1_linux.h
@@ -24,6 +24,6 @@
// a polling engine that utilizes a singleton epoll set and turnstile polling
-const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request);
+const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request);
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c
deleted file mode 100644
index 8eb4de44d9..0000000000
--- a/src/core/lib/iomgr/ev_epollex_linux.c
+++ /dev/null
@@ -1,1461 +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 "src/core/lib/iomgr/port.h"
-
-/* This polling engine is only relevant on linux kernels supporting epoll() */
-#ifdef GRPC_LINUX_EPOLL
-
-#include "src/core/lib/iomgr/ev_epollex_linux.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <poll.h>
-#include <pthread.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/tls.h>
-#include <grpc/support/useful.h>
-
-#include "src/core/lib/debug/stats.h"
-#include "src/core/lib/iomgr/ev_posix.h"
-#include "src/core/lib/iomgr/iomgr_internal.h"
-#include "src/core/lib/iomgr/is_epollexclusive_available.h"
-#include "src/core/lib/iomgr/lockfree_event.h"
-#include "src/core/lib/iomgr/sys_epoll_wrapper.h"
-#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/spinlock.h"
-
-/*******************************************************************************
- * Polling object
- */
-
-typedef enum {
- PO_POLLING_GROUP,
- PO_POLLSET_SET,
- PO_POLLSET,
- PO_FD, /* ordering is important: we always want to lock pollsets before fds:
- this guarantees that using an fd as a pollable is safe */
- PO_EMPTY_POLLABLE,
- PO_COUNT
-} polling_obj_type;
-
-typedef struct polling_obj polling_obj;
-typedef struct polling_group polling_group;
-
-struct polling_obj {
- gpr_mu mu;
- polling_obj_type type;
- polling_group *group;
- struct polling_obj *next;
- struct polling_obj *prev;
-};
-
-struct polling_group {
- polling_obj po;
- gpr_refcount refs;
-};
-
-static void po_init(polling_obj *po, polling_obj_type type);
-static void po_destroy(polling_obj *po);
-static void po_join(grpc_exec_ctx *exec_ctx, polling_obj *a, polling_obj *b);
-static int po_cmp(polling_obj *a, polling_obj *b);
-
-static void pg_create(grpc_exec_ctx *exec_ctx, polling_obj **initial_po,
- size_t initial_po_count);
-static polling_group *pg_ref(polling_group *pg);
-static void pg_unref(polling_group *pg);
-static void pg_merge(grpc_exec_ctx *exec_ctx, polling_group *a,
- polling_group *b);
-static void pg_join(grpc_exec_ctx *exec_ctx, polling_group *pg,
- polling_obj *po);
-
-/*******************************************************************************
- * pollable Declarations
- */
-
-typedef struct pollable {
- polling_obj po;
- int epfd;
- grpc_wakeup_fd wakeup;
- grpc_pollset_worker *root_worker;
-} pollable;
-
-static const char *polling_obj_type_string(polling_obj_type t) {
- switch (t) {
- case PO_POLLING_GROUP:
- return "polling_group";
- case PO_POLLSET_SET:
- return "pollset_set";
- case PO_POLLSET:
- return "pollset";
- case PO_FD:
- return "fd";
- case PO_EMPTY_POLLABLE:
- return "empty_pollable";
- case PO_COUNT:
- return "<invalid:count>";
- }
- return "<invalid>";
-}
-
-static char *pollable_desc(pollable *p) {
- char *out;
- gpr_asprintf(&out, "type=%s group=%p epfd=%d wakeup=%d",
- polling_obj_type_string(p->po.type), p->po.group, p->epfd,
- p->wakeup.read_fd);
- return out;
-}
-
-static pollable g_empty_pollable;
-
-static void pollable_init(pollable *p, polling_obj_type type);
-static void pollable_destroy(pollable *p);
-/* ensure that p->epfd, p->wakeup are initialized; p->po.mu must be held */
-static grpc_error *pollable_materialize(pollable *p);
-
-/*******************************************************************************
- * Fd Declarations
- */
-
-struct grpc_fd {
- pollable pollable_obj;
- int fd;
- /* refst format:
- bit 0 : 1=Active / 0=Orphaned
- bits 1-n : refcount
- Ref/Unref by two to avoid altering the orphaned bit */
- gpr_atm refst;
-
- /* The fd is either closed or we relinquished control of it. In either
- cases, this indicates that the 'fd' on this structure is no longer
- valid */
- gpr_mu orphaned_mu;
- bool orphaned;
-
- gpr_atm read_closure;
- gpr_atm write_closure;
-
- struct grpc_fd *freelist_next;
- grpc_closure *on_done_closure;
-
- /* The pollset that last noticed that the fd is readable. The actual type
- * stored in this is (grpc_pollset *) */
- gpr_atm read_notifier_pollset;
-
- grpc_iomgr_object iomgr_object;
-};
-
-static void fd_global_init(void);
-static void fd_global_shutdown(void);
-
-/*******************************************************************************
- * Pollset Declarations
- */
-
-typedef struct pollset_worker_link {
- grpc_pollset_worker *next;
- grpc_pollset_worker *prev;
-} pollset_worker_link;
-
-typedef enum {
- PWL_POLLSET,
- PWL_POLLABLE,
- POLLSET_WORKER_LINK_COUNT
-} pollset_worker_links;
-
-struct grpc_pollset_worker {
- bool kicked;
- bool initialized_cv;
- pollset_worker_link links[POLLSET_WORKER_LINK_COUNT];
- gpr_cv cv;
- grpc_pollset *pollset;
- pollable *pollable_obj;
-};
-
-#define MAX_EPOLL_EVENTS 100
-#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5
-
-struct grpc_pollset {
- pollable pollable_obj;
- pollable *current_pollable_obj;
- int kick_alls_pending;
- bool kicked_without_poller;
- grpc_closure *shutdown_closure;
- grpc_pollset_worker *root_worker;
-
- int event_cursor;
- int event_count;
- struct epoll_event events[MAX_EPOLL_EVENTS];
-};
-
-/*******************************************************************************
- * Pollset-set Declarations
- */
-struct grpc_pollset_set {
- polling_obj po;
-};
-
-/*******************************************************************************
- * Common helpers
- */
-
-static bool append_error(grpc_error **composite, grpc_error *error,
- const char *desc) {
- if (error == GRPC_ERROR_NONE) return true;
- if (*composite == GRPC_ERROR_NONE) {
- *composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
- }
- *composite = grpc_error_add_child(*composite, error);
- return false;
-}
-
-/*******************************************************************************
- * Fd Definitions
- */
-
-/* We need to keep a freelist not because of any concerns of malloc performance
- * but instead so that implementations with multiple threads in (for example)
- * epoll_wait deal with the race between pollset removal and incoming poll
- * notifications.
- *
- * The problem is that the poller ultimately holds a reference to this
- * object, so it is very difficult to know when is safe to free it, at least
- * without some expensive synchronization.
- *
- * If we keep the object freelisted, in the worst case losing this race just
- * becomes a spurious read notification on a reused fd.
- */
-
-/* The alarm system needs to be able to wakeup 'some poller' sometimes
- * (specifically when a new alarm needs to be triggered earlier than the next
- * alarm 'epoch'). This wakeup_fd gives us something to alert on when such a
- * case occurs. */
-
-static grpc_fd *fd_freelist = NULL;
-static gpr_mu fd_freelist_mu;
-
-#ifndef NDEBUG
-#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
-#define UNREF_BY(ec, fd, n, reason) \
- unref_by(ec, fd, n, reason, __FILE__, __LINE__)
-static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
- int line) {
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
- gpr_log(GPR_DEBUG,
- "FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
- fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
- gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line);
- }
-#else
-#define REF_BY(fd, n, reason) ref_by(fd, n)
-#define UNREF_BY(ec, fd, n, reason) unref_by(ec, fd, n)
-static void ref_by(grpc_fd *fd, int n) {
-#endif
- GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
-}
-
-static void fd_destroy(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_fd *fd = (grpc_fd *)arg;
- /* Add the fd to the freelist */
- grpc_iomgr_unregister_object(&fd->iomgr_object);
- pollable_destroy(&fd->pollable_obj);
- gpr_mu_destroy(&fd->orphaned_mu);
- gpr_mu_lock(&fd_freelist_mu);
- fd->freelist_next = fd_freelist;
- fd_freelist = fd;
-
- grpc_lfev_destroy(&fd->read_closure);
- grpc_lfev_destroy(&fd->write_closure);
-
- gpr_mu_unlock(&fd_freelist_mu);
-}
-
-#ifndef NDEBUG
-static void unref_by(grpc_exec_ctx *exec_ctx, grpc_fd *fd, int n,
- const char *reason, const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
- gpr_log(GPR_DEBUG,
- "FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
- fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
- gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
- }
-#else
-static void unref_by(grpc_exec_ctx *exec_ctx, grpc_fd *fd, int n) {
-#endif
- gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
- if (old == n) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(fd_destroy, fd,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
- } else {
- GPR_ASSERT(old > n);
- }
-}
-
-static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
-
-static void fd_global_shutdown(void) {
- gpr_mu_lock(&fd_freelist_mu);
- gpr_mu_unlock(&fd_freelist_mu);
- while (fd_freelist != NULL) {
- grpc_fd *fd = fd_freelist;
- fd_freelist = fd_freelist->freelist_next;
- gpr_free(fd);
- }
- gpr_mu_destroy(&fd_freelist_mu);
-}
-
-static grpc_fd *fd_create(int fd, const char *name) {
- grpc_fd *new_fd = NULL;
-
- gpr_mu_lock(&fd_freelist_mu);
- if (fd_freelist != NULL) {
- new_fd = fd_freelist;
- fd_freelist = fd_freelist->freelist_next;
- }
- gpr_mu_unlock(&fd_freelist_mu);
-
- if (new_fd == NULL) {
- new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
- }
-
- pollable_init(&new_fd->pollable_obj, PO_FD);
-
- gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
- new_fd->fd = fd;
- gpr_mu_init(&new_fd->orphaned_mu);
- new_fd->orphaned = false;
- grpc_lfev_init(&new_fd->read_closure);
- grpc_lfev_init(&new_fd->write_closure);
- gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
-
- new_fd->freelist_next = NULL;
- new_fd->on_done_closure = NULL;
-
- char *fd_name;
- gpr_asprintf(&fd_name, "%s fd=%d", name, fd);
- grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name);
-#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
- gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, new_fd, fd_name);
- }
-#endif
- gpr_free(fd_name);
- return new_fd;
-}
-
-static int fd_wrapped_fd(grpc_fd *fd) {
- int ret_fd = -1;
- gpr_mu_lock(&fd->orphaned_mu);
- if (!fd->orphaned) {
- ret_fd = fd->fd;
- }
- gpr_mu_unlock(&fd->orphaned_mu);
-
- return ret_fd;
-}
-
-static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *on_done, int *release_fd,
- bool already_closed, const char *reason) {
- bool is_fd_closed = already_closed;
- grpc_error *error = GRPC_ERROR_NONE;
-
- gpr_mu_lock(&fd->pollable_obj.po.mu);
- gpr_mu_lock(&fd->orphaned_mu);
- fd->on_done_closure = on_done;
-
- /* If release_fd is not NULL, we should be relinquishing control of the file
- descriptor fd->fd (but we still own the grpc_fd structure). */
- if (release_fd != NULL) {
- *release_fd = fd->fd;
- } else if (!is_fd_closed) {
- close(fd->fd);
- is_fd_closed = true;
- }
-
- fd->orphaned = true;
-
- if (!is_fd_closed) {
- gpr_log(GPR_DEBUG, "TODO: handle fd removal?");
- }
-
- /* Remove the active status but keep referenced. We want this grpc_fd struct
- to be alive (and not added to freelist) until the end of this function */
- REF_BY(fd, 1, reason);
-
- GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error));
-
- gpr_mu_unlock(&fd->orphaned_mu);
- gpr_mu_unlock(&fd->pollable_obj.po.mu);
- UNREF_BY(exec_ctx, fd, 2, reason); /* Drop the reference */
- GRPC_LOG_IF_ERROR("fd_orphan", GRPC_ERROR_REF(error));
- GRPC_ERROR_UNREF(error);
-}
-
-static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd) {
- gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
- return (grpc_pollset *)notifier;
-}
-
-static bool fd_is_shutdown(grpc_fd *fd) {
- return grpc_lfev_is_shutdown(&fd->read_closure);
-}
-
-/* Might be called multiple times */
-static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
- if (grpc_lfev_set_shutdown(exec_ctx, &fd->read_closure,
- GRPC_ERROR_REF(why))) {
- shutdown(fd->fd, SHUT_RDWR);
- grpc_lfev_set_shutdown(exec_ctx, &fd->write_closure, GRPC_ERROR_REF(why));
- }
- GRPC_ERROR_UNREF(why);
-}
-
-static void fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- grpc_lfev_notify_on(exec_ctx, &fd->read_closure, closure, "read");
-}
-
-static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- grpc_lfev_notify_on(exec_ctx, &fd->write_closure, closure, "write");
-}
-
-/*******************************************************************************
- * Pollable Definitions
- */
-
-static void pollable_init(pollable *p, polling_obj_type type) {
- po_init(&p->po, type);
- p->root_worker = NULL;
- p->epfd = -1;
-}
-
-static void pollable_destroy(pollable *p) {
- po_destroy(&p->po);
- if (p->epfd != -1) {
- close(p->epfd);
- grpc_wakeup_fd_destroy(&p->wakeup);
- }
-}
-
-/* ensure that p->epfd, p->wakeup are initialized; p->po.mu must be held */
-static grpc_error *pollable_materialize(pollable *p) {
- if (p->epfd == -1) {
- int new_epfd = epoll_create1(EPOLL_CLOEXEC);
- if (new_epfd < 0) {
- return GRPC_OS_ERROR(errno, "epoll_create1");
- }
- grpc_error *err = grpc_wakeup_fd_init(&p->wakeup);
- if (err != GRPC_ERROR_NONE) {
- close(new_epfd);
- return err;
- }
- struct epoll_event ev;
- ev.events = (uint32_t)(EPOLLIN | EPOLLET);
- ev.data.ptr = (void *)(1 | (intptr_t)&p->wakeup);
- if (epoll_ctl(new_epfd, EPOLL_CTL_ADD, p->wakeup.read_fd, &ev) != 0) {
- err = GRPC_OS_ERROR(errno, "epoll_ctl");
- close(new_epfd);
- grpc_wakeup_fd_destroy(&p->wakeup);
- return err;
- }
-
- p->epfd = new_epfd;
- }
- return GRPC_ERROR_NONE;
-}
-
-/* pollable must be materialized */
-static grpc_error *pollable_add_fd(pollable *p, grpc_fd *fd) {
- grpc_error *error = GRPC_ERROR_NONE;
- static const char *err_desc = "pollable_add_fd";
- const int epfd = p->epfd;
- GPR_ASSERT(epfd != -1);
-
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "add fd %p (%d) to pollable %p", fd, fd->fd, p);
- }
-
- gpr_mu_lock(&fd->orphaned_mu);
- if (fd->orphaned) {
- gpr_mu_unlock(&fd->orphaned_mu);
- return GRPC_ERROR_NONE;
- }
- struct epoll_event ev_fd;
- ev_fd.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLOUT | EPOLLEXCLUSIVE);
- ev_fd.data.ptr = fd;
- if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd->fd, &ev_fd) != 0) {
- switch (errno) {
- case EEXIST:
- break;
- default:
- append_error(&error, GRPC_OS_ERROR(errno, "epoll_ctl"), err_desc);
- }
- }
- gpr_mu_unlock(&fd->orphaned_mu);
-
- return error;
-}
-
-/*******************************************************************************
- * Pollset Definitions
- */
-
-GPR_TLS_DECL(g_current_thread_pollset);
-GPR_TLS_DECL(g_current_thread_worker);
-
-/* Global state management */
-static grpc_error *pollset_global_init(void) {
- gpr_tls_init(&g_current_thread_pollset);
- gpr_tls_init(&g_current_thread_worker);
- pollable_init(&g_empty_pollable, PO_EMPTY_POLLABLE);
- return GRPC_ERROR_NONE;
-}
-
-static void pollset_global_shutdown(void) {
- pollable_destroy(&g_empty_pollable);
- gpr_tls_destroy(&g_current_thread_pollset);
- gpr_tls_destroy(&g_current_thread_worker);
-}
-
-static void pollset_maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset) {
- if (pollset->shutdown_closure != NULL && pollset->root_worker == NULL &&
- pollset->kick_alls_pending == 0) {
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE);
- pollset->shutdown_closure = NULL;
- }
-}
-
-static void do_kick_all(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error_unused) {
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_pollset *pollset = (grpc_pollset *)arg;
- gpr_mu_lock(&pollset->pollable_obj.po.mu);
- if (pollset->root_worker != NULL) {
- grpc_pollset_worker *worker = pollset->root_worker;
- do {
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
- if (worker->pollable_obj != &pollset->pollable_obj) {
- gpr_mu_lock(&worker->pollable_obj->po.mu);
- }
- if (worker->initialized_cv && worker != pollset->root_worker) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kickall_via_cv %p (pollable %p vs %p)",
- pollset, worker, &pollset->pollable_obj,
- worker->pollable_obj);
- }
- worker->kicked = true;
- gpr_cv_signal(&worker->cv);
- } else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kickall_via_wakeup %p (pollable %p vs %p)",
- pollset, worker, &pollset->pollable_obj,
- worker->pollable_obj);
- }
- append_error(&error,
- grpc_wakeup_fd_wakeup(&worker->pollable_obj->wakeup),
- "pollset_shutdown");
- }
- if (worker->pollable_obj != &pollset->pollable_obj) {
- gpr_mu_unlock(&worker->pollable_obj->po.mu);
- }
-
- worker = worker->links[PWL_POLLSET].next;
- } while (worker != pollset->root_worker);
- }
- pollset->kick_alls_pending--;
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
- gpr_mu_unlock(&pollset->pollable_obj.po.mu);
- GRPC_LOG_IF_ERROR("kick_all", error);
-}
-
-static void pollset_kick_all(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
- pollset->kick_alls_pending++;
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(do_kick_all, pollset,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
-}
-
-static grpc_error *pollset_kick_inner(grpc_pollset *pollset, pollable *p,
- grpc_pollset_worker *specific_worker) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG,
- "PS:%p kick %p tls_pollset=%p tls_worker=%p "
- "root_worker=(pollset:%p pollable:%p)",
- p, specific_worker, (void *)gpr_tls_get(&g_current_thread_pollset),
- (void *)gpr_tls_get(&g_current_thread_worker), pollset->root_worker,
- p->root_worker);
- }
- if (specific_worker == NULL) {
- if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) {
- if (pollset->root_worker == NULL) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", p);
- }
- pollset->kicked_without_poller = true;
- return GRPC_ERROR_NONE;
- } else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_any_via_wakeup_fd", p);
- }
- grpc_error *err = pollable_materialize(p);
- if (err != GRPC_ERROR_NONE) return err;
- return grpc_wakeup_fd_wakeup(&p->wakeup);
- }
- } else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", p);
- }
- return GRPC_ERROR_NONE;
- }
- } else if (specific_worker->kicked) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p);
- }
- return GRPC_ERROR_NONE;
- } else if (gpr_tls_get(&g_current_thread_worker) ==
- (intptr_t)specific_worker) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_awake", p);
- }
- specific_worker->kicked = true;
- return GRPC_ERROR_NONE;
- } else if (specific_worker == p->root_worker) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_wakeup_fd", p);
- }
- grpc_error *err = pollable_materialize(p);
- if (err != GRPC_ERROR_NONE) return err;
- specific_worker->kicked = true;
- return grpc_wakeup_fd_wakeup(&p->wakeup);
- } else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_cv", p);
- }
- specific_worker->kicked = true;
- gpr_cv_signal(&specific_worker->cv);
- return GRPC_ERROR_NONE;
- }
-}
-
-/* p->po.mu must be held before calling this function */
-static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker) {
- pollable *p = pollset->current_pollable_obj;
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
- if (p != &pollset->pollable_obj) {
- gpr_mu_lock(&p->po.mu);
- }
- grpc_error *error = pollset_kick_inner(pollset, p, specific_worker);
- if (p != &pollset->pollable_obj) {
- gpr_mu_unlock(&p->po.mu);
- }
- return error;
-}
-
-static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
- pollable_init(&pollset->pollable_obj, PO_POLLSET);
- pollset->current_pollable_obj = &g_empty_pollable;
- pollset->kicked_without_poller = false;
- pollset->shutdown_closure = NULL;
- pollset->root_worker = NULL;
- *mu = &pollset->pollable_obj.po.mu;
-}
-
-/* Convert a timespec to milliseconds:
- - Very small or negative poll times are clamped to zero to do a non-blocking
- poll (which becomes spin polling)
- - Other small values are rounded up to one millisecond
- - Longer than a millisecond polls are rounded up to the next nearest
- millisecond to avoid spinning
- - Infinite timeouts are converted to -1 */
-static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
- gpr_timespec now) {
- gpr_timespec timeout;
- if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
- return -1;
- }
-
- if (gpr_time_cmp(deadline, now) <= 0) {
- return 0;
- }
-
- static const gpr_timespec round_up = {
- 0, /* tv_sec */
- GPR_NS_PER_MS - 1, /* tv_nsec */
- GPR_TIMESPAN /* clock_type */
- };
- timeout = gpr_time_sub(deadline, now);
- int millis = gpr_time_to_millis(gpr_time_add(timeout, round_up));
- return millis >= 1 ? millis : 1;
-}
-
-static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_pollset *notifier) {
- grpc_lfev_set_ready(exec_ctx, &fd->read_closure, "read");
-
- /* Note, it is possible that fd_become_readable might be called twice with
- different 'notifier's when an fd becomes readable and it is in two epoll
- sets (This can happen briefly during polling island merges). In such cases
- it does not really matter which notifer is set as the read_notifier_pollset
- (They would both point to the same polling island anyway) */
- /* Use release store to match with acquire load in fd_get_read_notifier */
- gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
-}
-
-static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
- grpc_lfev_set_ready(exec_ctx, &fd->write_closure, "write");
-}
-
-static grpc_error *fd_become_pollable_locked(grpc_fd *fd) {
- grpc_error *error = GRPC_ERROR_NONE;
- static const char *err_desc = "fd_become_pollable";
- if (append_error(&error, pollable_materialize(&fd->pollable_obj), err_desc)) {
- append_error(&error, pollable_add_fd(&fd->pollable_obj, fd), err_desc);
- }
- return error;
-}
-
-/* pollset->po.mu lock must be held by the caller before calling this */
-static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
- GPR_ASSERT(pollset->shutdown_closure == NULL);
- pollset->shutdown_closure = closure;
- pollset_kick_all(exec_ctx, pollset);
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
-}
-
-static bool pollset_is_pollable_fd(grpc_pollset *pollset, pollable *p) {
- return p != &g_empty_pollable && p != &pollset->pollable_obj;
-}
-
-static grpc_error *pollset_process_events(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset, bool drain) {
- static const char *err_desc = "pollset_process_events";
- grpc_error *error = GRPC_ERROR_NONE;
- for (int i = 0; (drain || i < MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL) &&
- pollset->event_cursor != pollset->event_count;
- i++) {
- int n = pollset->event_cursor++;
- struct epoll_event *ev = &pollset->events[n];
- void *data_ptr = ev->data.ptr;
- if (1 & (intptr_t)data_ptr) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr);
- }
- append_error(&error,
- grpc_wakeup_fd_consume_wakeup(
- (grpc_wakeup_fd *)((~(intptr_t)1) & (intptr_t)data_ptr)),
- err_desc);
- } else {
- grpc_fd *fd = (grpc_fd *)data_ptr;
- bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0;
- bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0;
- bool write_ev = (ev->events & EPOLLOUT) != 0;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG,
- "PS:%p got fd %p: cancel=%d read=%d "
- "write=%d",
- pollset, fd, cancel, read_ev, write_ev);
- }
- if (read_ev || cancel) {
- fd_become_readable(exec_ctx, fd, pollset);
- }
- if (write_ev || cancel) {
- fd_become_writable(exec_ctx, fd);
- }
- }
- }
-
- return error;
-}
-
-/* pollset_shutdown is guaranteed to be called before pollset_destroy. */
-static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
- pollable_destroy(&pollset->pollable_obj);
- if (pollset_is_pollable_fd(pollset, pollset->current_pollable_obj)) {
- UNREF_BY(exec_ctx, (grpc_fd *)pollset->current_pollable_obj, 2,
- "pollset_pollable");
- }
- GRPC_LOG_IF_ERROR("pollset_process_events",
- pollset_process_events(exec_ctx, pollset, true));
-}
-
-static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- pollable *p, gpr_timespec now,
- gpr_timespec deadline) {
- int timeout = poll_deadline_to_millis_timeout(deadline, now);
-
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- char *desc = pollable_desc(p);
- gpr_log(GPR_DEBUG, "PS:%p poll %p[%s] for %dms", pollset, p, desc, timeout);
- gpr_free(desc);
- }
-
- if (timeout != 0) {
- GRPC_SCHEDULING_START_BLOCKING_REGION;
- }
- int r;
- do {
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
- r = epoll_wait(p->epfd, pollset->events, MAX_EPOLL_EVENTS, timeout);
- } while (r < 0 && errno == EINTR);
- if (timeout != 0) {
- GRPC_SCHEDULING_END_BLOCKING_REGION;
- }
-
- if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
-
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p poll %p got %d events", pollset, p, r);
- }
-
- pollset->event_cursor = 0;
- pollset->event_count = r;
-
- return GRPC_ERROR_NONE;
-}
-
-/* Return true if first in list */
-static bool worker_insert(grpc_pollset_worker **root, pollset_worker_links link,
- grpc_pollset_worker *worker) {
- if (*root == NULL) {
- *root = worker;
- worker->links[link].next = worker->links[link].prev = worker;
- return true;
- } else {
- worker->links[link].next = *root;
- worker->links[link].prev = worker->links[link].next->links[link].prev;
- worker->links[link].next->links[link].prev = worker;
- worker->links[link].prev->links[link].next = worker;
- return false;
- }
-}
-
-/* Return true if last in list */
-typedef enum { EMPTIED, NEW_ROOT, REMOVED } worker_remove_result;
-
-static worker_remove_result worker_remove(grpc_pollset_worker **root,
- pollset_worker_links link,
- grpc_pollset_worker *worker) {
- if (worker == *root) {
- if (worker == worker->links[link].next) {
- *root = NULL;
- return EMPTIED;
- } else {
- *root = worker->links[link].next;
- worker->links[link].prev->links[link].next = worker->links[link].next;
- worker->links[link].next->links[link].prev = worker->links[link].prev;
- return NEW_ROOT;
- }
- } else {
- worker->links[link].prev->links[link].next = worker->links[link].next;
- worker->links[link].next->links[link].prev = worker->links[link].prev;
- return REMOVED;
- }
-}
-
-/* Return true if this thread should poll */
-static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
- grpc_pollset_worker **worker_hdl, gpr_timespec *now,
- gpr_timespec deadline) {
- bool do_poll = true;
- if (worker_hdl != NULL) *worker_hdl = worker;
- worker->initialized_cv = false;
- worker->kicked = false;
- worker->pollset = pollset;
- worker->pollable_obj = pollset->current_pollable_obj;
-
- if (pollset_is_pollable_fd(pollset, worker->pollable_obj)) {
- REF_BY((grpc_fd *)worker->pollable_obj, 2, "one_poll");
- }
-
- worker_insert(&pollset->root_worker, PWL_POLLSET, worker);
- if (!worker_insert(&worker->pollable_obj->root_worker, PWL_POLLABLE,
- worker)) {
- worker->initialized_cv = true;
- gpr_cv_init(&worker->cv);
- if (worker->pollable_obj != &pollset->pollable_obj) {
- gpr_mu_unlock(&pollset->pollable_obj.po.mu);
- }
- if (GRPC_TRACER_ON(grpc_polling_trace) &&
- worker->pollable_obj->root_worker != worker) {
- gpr_log(GPR_DEBUG, "PS:%p wait %p w=%p for %dms", pollset,
- worker->pollable_obj, worker,
- poll_deadline_to_millis_timeout(deadline, *now));
- }
- while (do_poll && worker->pollable_obj->root_worker != worker) {
- if (gpr_cv_wait(&worker->cv, &worker->pollable_obj->po.mu, deadline)) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p timeout_wait %p w=%p", pollset,
- worker->pollable_obj, worker);
- }
- do_poll = false;
- } else if (worker->kicked) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p wakeup %p w=%p", pollset,
- worker->pollable_obj, worker);
- }
- do_poll = false;
- } else if (GRPC_TRACER_ON(grpc_polling_trace) &&
- worker->pollable_obj->root_worker != worker) {
- gpr_log(GPR_DEBUG, "PS:%p spurious_wakeup %p w=%p", pollset,
- worker->pollable_obj, worker);
- }
- }
- if (worker->pollable_obj != &pollset->pollable_obj) {
- gpr_mu_unlock(&worker->pollable_obj->po.mu);
- gpr_mu_lock(&pollset->pollable_obj.po.mu);
- gpr_mu_lock(&worker->pollable_obj->po.mu);
- }
- *now = gpr_now(now->clock_type);
- }
-
- return do_poll && pollset->shutdown_closure == NULL &&
- pollset->current_pollable_obj == worker->pollable_obj;
-}
-
-static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *worker,
- grpc_pollset_worker **worker_hdl) {
- if (NEW_ROOT ==
- worker_remove(&worker->pollable_obj->root_worker, PWL_POLLABLE, worker)) {
- gpr_cv_signal(&worker->pollable_obj->root_worker->cv);
- }
- if (worker->initialized_cv) {
- gpr_cv_destroy(&worker->cv);
- }
- if (pollset_is_pollable_fd(pollset, worker->pollable_obj)) {
- UNREF_BY(exec_ctx, (grpc_fd *)worker->pollable_obj, 2, "one_poll");
- }
- if (EMPTIED == worker_remove(&pollset->root_worker, PWL_POLLSET, worker)) {
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
- }
-}
-
-/* pollset->po.mu lock must be held by the caller before calling this.
- The function pollset_work() may temporarily release the lock (pollset->po.mu)
- during the course of its execution but it will always re-acquire the lock and
- ensure that it is held by the time the function returns */
-static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker_hdl,
- gpr_timespec now, gpr_timespec deadline) {
- grpc_pollset_worker worker;
- if (0 && GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p work hdl=%p worker=%p now=%" PRId64
- ".%09d deadline=%" PRId64 ".%09d kwp=%d root_worker=%p",
- pollset, worker_hdl, &worker, now.tv_sec, now.tv_nsec,
- deadline.tv_sec, deadline.tv_nsec, pollset->kicked_without_poller,
- pollset->root_worker);
- }
- grpc_error *error = GRPC_ERROR_NONE;
- static const char *err_desc = "pollset_work";
- if (pollset->kicked_without_poller) {
- pollset->kicked_without_poller = false;
- return GRPC_ERROR_NONE;
- }
- if (pollset->current_pollable_obj != &pollset->pollable_obj) {
- gpr_mu_lock(&pollset->current_pollable_obj->po.mu);
- }
- if (begin_worker(pollset, &worker, worker_hdl, &now, deadline)) {
- gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset);
- gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
- GPR_ASSERT(!pollset->shutdown_closure);
- append_error(&error, pollable_materialize(worker.pollable_obj), err_desc);
- if (worker.pollable_obj != &pollset->pollable_obj) {
- gpr_mu_unlock(&worker.pollable_obj->po.mu);
- }
- gpr_mu_unlock(&pollset->pollable_obj.po.mu);
- if (pollset->event_cursor == pollset->event_count) {
- append_error(&error, pollset_epoll(exec_ctx, pollset, worker.pollable_obj,
- now, deadline),
- err_desc);
- }
- append_error(&error, pollset_process_events(exec_ctx, pollset, false),
- err_desc);
- gpr_mu_lock(&pollset->pollable_obj.po.mu);
- if (worker.pollable_obj != &pollset->pollable_obj) {
- gpr_mu_lock(&worker.pollable_obj->po.mu);
- }
- gpr_tls_set(&g_current_thread_pollset, 0);
- gpr_tls_set(&g_current_thread_worker, 0);
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
- }
- end_worker(exec_ctx, pollset, &worker, worker_hdl);
- if (worker.pollable_obj != &pollset->pollable_obj) {
- gpr_mu_unlock(&worker.pollable_obj->po.mu);
- }
- if (grpc_exec_ctx_has_work(exec_ctx)) {
- gpr_mu_unlock(&pollset->pollable_obj.po.mu);
- grpc_exec_ctx_flush(exec_ctx);
- gpr_mu_lock(&pollset->pollable_obj.po.mu);
- }
- return error;
-}
-
-static void unref_fd_no_longer_poller(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_fd *fd = (grpc_fd *)arg;
- UNREF_BY(exec_ctx, fd, 2, "pollset_pollable");
-}
-
-/* expects pollsets locked, flag whether fd is locked or not */
-static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset, grpc_fd *fd,
- bool fd_locked) {
- static const char *err_desc = "pollset_add_fd";
- grpc_error *error = GRPC_ERROR_NONE;
- if (pollset->current_pollable_obj == &g_empty_pollable) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG,
- "PS:%p add fd %p; transition pollable from empty to fd", pollset,
- fd);
- }
- /* empty pollable --> single fd pollable */
- pollset_kick_all(exec_ctx, pollset);
- pollset->current_pollable_obj = &fd->pollable_obj;
- if (!fd_locked) gpr_mu_lock(&fd->pollable_obj.po.mu);
- append_error(&error, fd_become_pollable_locked(fd), err_desc);
- if (!fd_locked) gpr_mu_unlock(&fd->pollable_obj.po.mu);
- REF_BY(fd, 2, "pollset_pollable");
- } else if (pollset->current_pollable_obj == &pollset->pollable_obj) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG, "PS:%p add fd %p; already multipolling", pollset, fd);
- }
- append_error(&error, pollable_add_fd(pollset->current_pollable_obj, fd),
- err_desc);
- } else if (pollset->current_pollable_obj != &fd->pollable_obj) {
- grpc_fd *had_fd = (grpc_fd *)pollset->current_pollable_obj;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_DEBUG,
- "PS:%p add fd %p; transition pollable from fd %p to multipoller",
- pollset, fd, had_fd);
- }
- /* Introduce a spurious completion.
- If we do not, then it may be that the fd-specific epoll set consumed
- a completion without being polled, leading to a missed edge going up. */
- grpc_lfev_set_ready(exec_ctx, &had_fd->read_closure, "read");
- grpc_lfev_set_ready(exec_ctx, &had_fd->write_closure, "write");
- pollset_kick_all(exec_ctx, pollset);
- pollset->current_pollable_obj = &pollset->pollable_obj;
- if (append_error(&error, pollable_materialize(&pollset->pollable_obj),
- err_desc)) {
- pollable_add_fd(&pollset->pollable_obj, had_fd);
- pollable_add_fd(&pollset->pollable_obj, fd);
- }
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(unref_fd_no_longer_poller, had_fd,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
- }
- return error;
-}
-
-static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_fd *fd) {
- gpr_mu_lock(&pollset->pollable_obj.po.mu);
- grpc_error *error = pollset_add_fd_locked(exec_ctx, pollset, fd, false);
- gpr_mu_unlock(&pollset->pollable_obj.po.mu);
- GRPC_LOG_IF_ERROR("pollset_add_fd", error);
-}
-
-/*******************************************************************************
- * Pollset-set Definitions
- */
-
-static grpc_pollset_set *pollset_set_create(void) {
- grpc_pollset_set *pss = (grpc_pollset_set *)gpr_zalloc(sizeof(*pss));
- po_init(&pss->po, PO_POLLSET_SET);
- return pss;
-}
-
-static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss) {
- po_destroy(&pss->po);
- gpr_free(pss);
-}
-
-static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
- grpc_fd *fd) {
- po_join(exec_ctx, &pss->po, &fd->pollable_obj.po);
-}
-
-static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
- grpc_fd *fd) {}
-
-static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss, grpc_pollset *ps) {
- po_join(exec_ctx, &pss->po, &ps->pollable_obj.po);
-}
-
-static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss, grpc_pollset *ps) {}
-
-static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
- po_join(exec_ctx, &bag->po, &item->po);
-}
-
-static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {}
-
-static void po_init(polling_obj *po, polling_obj_type type) {
- gpr_mu_init(&po->mu);
- po->type = type;
- po->group = NULL;
- po->next = po;
- po->prev = po;
-}
-
-static polling_group *pg_lock_latest(polling_group *pg) {
- /* assumes pg unlocked; consumes ref, returns ref */
- gpr_mu_lock(&pg->po.mu);
- while (pg->po.group != NULL) {
- polling_group *new_pg = pg_ref(pg->po.group);
- gpr_mu_unlock(&pg->po.mu);
- pg_unref(pg);
- pg = new_pg;
- gpr_mu_lock(&pg->po.mu);
- }
- return pg;
-}
-
-static void po_destroy(polling_obj *po) {
- if (po->group != NULL) {
- polling_group *pg = pg_lock_latest(po->group);
- po->prev->next = po->next;
- po->next->prev = po->prev;
- gpr_mu_unlock(&pg->po.mu);
- pg_unref(pg);
- }
- gpr_mu_destroy(&po->mu);
-}
-
-static polling_group *pg_ref(polling_group *pg) {
- gpr_ref(&pg->refs);
- return pg;
-}
-
-static void pg_unref(polling_group *pg) {
- if (gpr_unref(&pg->refs)) {
- po_destroy(&pg->po);
- gpr_free(pg);
- }
-}
-
-static int po_cmp(polling_obj *a, polling_obj *b) {
- if (a == b) return 0;
- if (a->type < b->type) return -1;
- if (a->type > b->type) return 1;
- if (a < b) return -1;
- assert(a > b);
- return 1;
-}
-
-static void po_join(grpc_exec_ctx *exec_ctx, polling_obj *a, polling_obj *b) {
- switch (po_cmp(a, b)) {
- case 0:
- return;
- case 1:
- GPR_SWAP(polling_obj *, a, b);
- /* fall through */
- case -1:
- gpr_mu_lock(&a->mu);
- gpr_mu_lock(&b->mu);
-
- if (a->group == NULL) {
- if (b->group == NULL) {
- polling_obj *initial_po[] = {a, b};
- pg_create(exec_ctx, initial_po, GPR_ARRAY_SIZE(initial_po));
- gpr_mu_unlock(&a->mu);
- gpr_mu_unlock(&b->mu);
- } else {
- polling_group *b_group = pg_ref(b->group);
- gpr_mu_unlock(&b->mu);
- gpr_mu_unlock(&a->mu);
- pg_join(exec_ctx, b_group, a);
- }
- } else if (b->group == NULL) {
- polling_group *a_group = pg_ref(a->group);
- gpr_mu_unlock(&a->mu);
- gpr_mu_unlock(&b->mu);
- pg_join(exec_ctx, a_group, b);
- } else if (a->group == b->group) {
- /* nothing to do */
- gpr_mu_unlock(&a->mu);
- gpr_mu_unlock(&b->mu);
- } else {
- polling_group *a_group = pg_ref(a->group);
- polling_group *b_group = pg_ref(b->group);
- gpr_mu_unlock(&a->mu);
- gpr_mu_unlock(&b->mu);
- pg_merge(exec_ctx, a_group, b_group);
- }
- }
-}
-
-static void pg_notify(grpc_exec_ctx *exec_ctx, polling_obj *a, polling_obj *b) {
- if (a->type == PO_FD && b->type == PO_POLLSET) {
- pollset_add_fd_locked(exec_ctx, (grpc_pollset *)b, (grpc_fd *)a, true);
- } else if (a->type == PO_POLLSET && b->type == PO_FD) {
- pollset_add_fd_locked(exec_ctx, (grpc_pollset *)a, (grpc_fd *)b, true);
- }
-}
-
-static void pg_broadcast(grpc_exec_ctx *exec_ctx, polling_group *from,
- polling_group *to) {
- for (polling_obj *a = from->po.next; a != &from->po; a = a->next) {
- for (polling_obj *b = to->po.next; b != &to->po; b = b->next) {
- if (po_cmp(a, b) < 0) {
- gpr_mu_lock(&a->mu);
- gpr_mu_lock(&b->mu);
- } else {
- GPR_ASSERT(po_cmp(a, b) != 0);
- gpr_mu_lock(&b->mu);
- gpr_mu_lock(&a->mu);
- }
- pg_notify(exec_ctx, a, b);
- gpr_mu_unlock(&a->mu);
- gpr_mu_unlock(&b->mu);
- }
- }
-}
-
-static void pg_create(grpc_exec_ctx *exec_ctx, polling_obj **initial_po,
- size_t initial_po_count) {
- /* assumes all polling objects in initial_po are locked */
- polling_group *pg = (polling_group *)gpr_malloc(sizeof(*pg));
- po_init(&pg->po, PO_POLLING_GROUP);
- gpr_ref_init(&pg->refs, (int)initial_po_count);
- for (size_t i = 0; i < initial_po_count; i++) {
- GPR_ASSERT(initial_po[i]->group == NULL);
- initial_po[i]->group = pg;
- }
- for (size_t i = 1; i < initial_po_count; i++) {
- initial_po[i]->prev = initial_po[i - 1];
- }
- for (size_t i = 0; i < initial_po_count - 1; i++) {
- initial_po[i]->next = initial_po[i + 1];
- }
- initial_po[0]->prev = &pg->po;
- initial_po[initial_po_count - 1]->next = &pg->po;
- pg->po.next = initial_po[0];
- pg->po.prev = initial_po[initial_po_count - 1];
- for (size_t i = 1; i < initial_po_count; i++) {
- for (size_t j = 0; j < i; j++) {
- pg_notify(exec_ctx, initial_po[i], initial_po[j]);
- }
- }
-}
-
-static void pg_join(grpc_exec_ctx *exec_ctx, polling_group *pg,
- polling_obj *po) {
- /* assumes neither pg nor po are locked; consumes one ref to pg */
- pg = pg_lock_latest(pg);
- /* pg locked */
- for (polling_obj *existing = pg->po.next /* skip pg - it's just a stub */;
- existing != &pg->po; existing = existing->next) {
- if (po_cmp(po, existing) < 0) {
- gpr_mu_lock(&po->mu);
- gpr_mu_lock(&existing->mu);
- } else {
- GPR_ASSERT(po_cmp(po, existing) != 0);
- gpr_mu_lock(&existing->mu);
- gpr_mu_lock(&po->mu);
- }
- /* pg, po, existing locked */
- if (po->group != NULL) {
- gpr_mu_unlock(&pg->po.mu);
- polling_group *po_group = pg_ref(po->group);
- gpr_mu_unlock(&po->mu);
- gpr_mu_unlock(&existing->mu);
- pg_merge(exec_ctx, pg, po_group);
- /* early exit: polling obj picked up a group during joining: we needed
- to do a full merge */
- return;
- }
- pg_notify(exec_ctx, po, existing);
- gpr_mu_unlock(&po->mu);
- gpr_mu_unlock(&existing->mu);
- }
- gpr_mu_lock(&po->mu);
- if (po->group != NULL) {
- gpr_mu_unlock(&pg->po.mu);
- polling_group *po_group = pg_ref(po->group);
- gpr_mu_unlock(&po->mu);
- pg_merge(exec_ctx, pg, po_group);
- /* early exit: polling obj picked up a group during joining: we needed
- to do a full merge */
- return;
- }
- po->group = pg;
- po->next = &pg->po;
- po->prev = pg->po.prev;
- po->prev->next = po->next->prev = po;
- gpr_mu_unlock(&pg->po.mu);
- gpr_mu_unlock(&po->mu);
-}
-
-static void pg_merge(grpc_exec_ctx *exec_ctx, polling_group *a,
- polling_group *b) {
- for (;;) {
- if (a == b) {
- pg_unref(a);
- pg_unref(b);
- return;
- }
- if (a > b) GPR_SWAP(polling_group *, a, b);
- gpr_mu_lock(&a->po.mu);
- gpr_mu_lock(&b->po.mu);
- if (a->po.group != NULL) {
- polling_group *m2 = pg_ref(a->po.group);
- gpr_mu_unlock(&a->po.mu);
- gpr_mu_unlock(&b->po.mu);
- pg_unref(a);
- a = m2;
- } else if (b->po.group != NULL) {
- polling_group *m2 = pg_ref(b->po.group);
- gpr_mu_unlock(&a->po.mu);
- gpr_mu_unlock(&b->po.mu);
- pg_unref(b);
- b = m2;
- } else {
- break;
- }
- }
- polling_group **unref = NULL;
- size_t unref_count = 0;
- size_t unref_cap = 0;
- b->po.group = a;
- pg_broadcast(exec_ctx, a, b);
- pg_broadcast(exec_ctx, b, a);
- while (b->po.next != &b->po) {
- polling_obj *po = b->po.next;
- gpr_mu_lock(&po->mu);
- if (unref_count == unref_cap) {
- unref_cap = GPR_MAX(8, 3 * unref_cap / 2);
- unref = (polling_group **)gpr_realloc(unref, unref_cap * sizeof(*unref));
- }
- unref[unref_count++] = po->group;
- po->group = pg_ref(a);
- // unlink from b
- po->prev->next = po->next;
- po->next->prev = po->prev;
- // link to a
- po->next = &a->po;
- po->prev = a->po.prev;
- po->next->prev = po->prev->next = po;
- gpr_mu_unlock(&po->mu);
- }
- gpr_mu_unlock(&a->po.mu);
- gpr_mu_unlock(&b->po.mu);
- for (size_t i = 0; i < unref_count; i++) {
- pg_unref(unref[i]);
- }
- gpr_free(unref);
- pg_unref(b);
-}
-
-/*******************************************************************************
- * Event engine binding
- */
-
-static void shutdown_engine(void) {
- fd_global_shutdown();
- pollset_global_shutdown();
-}
-
-static const grpc_event_engine_vtable vtable = {
- sizeof(grpc_pollset),
-
- fd_create,
- fd_wrapped_fd,
- fd_orphan,
- fd_shutdown,
- fd_notify_on_read,
- fd_notify_on_write,
- fd_is_shutdown,
- fd_get_read_notifier_pollset,
-
- pollset_init,
- pollset_shutdown,
- pollset_destroy,
- pollset_work,
- pollset_kick,
- pollset_add_fd,
-
- pollset_set_create,
- pollset_set_destroy,
- pollset_set_add_pollset,
- pollset_set_del_pollset,
- pollset_set_add_pollset_set,
- pollset_set_del_pollset_set,
- pollset_set_add_fd,
- pollset_set_del_fd,
-
- shutdown_engine,
-};
-
-const grpc_event_engine_vtable *grpc_init_epollex_linux(
- bool explicitly_requested) {
- if (!grpc_has_wakeup_fd()) {
- return NULL;
- }
-
- if (!grpc_is_epollexclusive_available()) {
- return NULL;
- }
-
- fd_global_init();
-
- if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
- pollset_global_shutdown();
- fd_global_shutdown();
- return NULL;
- }
-
- return &vtable;
-}
-
-#else /* defined(GRPC_LINUX_EPOLL) */
-#if defined(GRPC_POSIX_SOCKET)
-#include "src/core/lib/iomgr/ev_posix.h"
-/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
- * NULL */
-const grpc_event_engine_vtable *grpc_init_epollex_linux(
- bool explicitly_requested) {
- return NULL;
-}
-#endif /* defined(GRPC_POSIX_SOCKET) */
-
-#endif /* !defined(GRPC_LINUX_EPOLL) */
diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc
new file mode 100644
index 0000000000..5412358ab8
--- /dev/null
+++ b/src/core/lib/iomgr/ev_epollex_linux.cc
@@ -0,0 +1,1464 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+#include <grpc/support/log.h>
+
+/* This polling engine is only relevant on linux kernels supporting epoll() */
+#ifdef GRPC_LINUX_EPOLL_CREATE1
+
+#include "src/core/lib/iomgr/ev_epollex_linux.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <poll.h>
+#include <pthread.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/tls.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/spinlock.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"
+#include "src/core/lib/iomgr/is_epollexclusive_available.h"
+#include "src/core/lib/iomgr/lockfree_event.h"
+#include "src/core/lib/iomgr/sys_epoll_wrapper.h"
+#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/iomgr/wakeup_fd_posix.h"
+#include "src/core/lib/profiling/timers.h"
+
+// debug aid: create workers on the heap (allows asan to spot
+// use-after-destruction)
+//#define GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP 1
+
+#define MAX_EPOLL_EVENTS 100
+#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5
+
+grpc_core::DebugOnlyTraceFlag grpc_trace_pollable_refcount(false,
+ "pollable_refcount");
+
+/*******************************************************************************
+ * pollable Declarations
+ */
+
+typedef enum { PO_MULTI, PO_FD, PO_EMPTY } pollable_type;
+
+typedef struct pollable pollable;
+
+/// A pollable is something that can be polled: it has an epoll set to poll on,
+/// and a wakeup fd for kicks
+/// There are three broad types:
+/// - PO_EMPTY - the empty pollable, used before file descriptors are added to
+/// a pollset
+/// - PO_FD - a pollable containing only one FD - used to optimize single-fd
+/// pollsets (which are common with synchronous api usage)
+/// - PO_MULTI - a pollable containing many fds
+struct pollable {
+ pollable_type type; // immutable
+ gpr_refcount refs;
+
+ int epfd;
+ grpc_wakeup_fd wakeup;
+
+ // only for type fd... one ref to the owner fd
+ grpc_fd* owner_fd;
+
+ grpc_pollset_set* pollset_set;
+ pollable* next;
+ pollable* prev;
+
+ gpr_mu mu;
+ grpc_pollset_worker* root_worker;
+
+ int event_cursor;
+ int event_count;
+ struct epoll_event events[MAX_EPOLL_EVENTS];
+};
+
+static const char* pollable_type_string(pollable_type t) {
+ switch (t) {
+ case PO_MULTI:
+ return "pollset";
+ case PO_FD:
+ return "fd";
+ case PO_EMPTY:
+ return "empty";
+ }
+ return "<invalid>";
+}
+
+static char* pollable_desc(pollable* p) {
+ char* out;
+ gpr_asprintf(&out, "type=%s epfd=%d wakeup=%d", pollable_type_string(p->type),
+ p->epfd, p->wakeup.read_fd);
+ return out;
+}
+
+/// Shared empty pollable - used by pollset to poll on until the first fd is
+/// added
+static pollable* g_empty_pollable;
+
+static grpc_error* pollable_create(pollable_type type, pollable** p);
+#ifdef NDEBUG
+static pollable* pollable_ref(pollable* p);
+static void pollable_unref(pollable* p);
+#define POLLABLE_REF(p, r) pollable_ref(p)
+#define POLLABLE_UNREF(p, r) pollable_unref(p)
+#else
+static pollable* pollable_ref(pollable* p, int line, const char* reason);
+static void pollable_unref(pollable* p, int line, const char* reason);
+#define POLLABLE_REF(p, r) pollable_ref((p), __LINE__, (r))
+#define POLLABLE_UNREF(p, r) pollable_unref((p), __LINE__, (r))
+#endif
+
+/*******************************************************************************
+ * Fd Declarations
+ */
+
+struct grpc_fd {
+ int fd;
+ /* refst format:
+ bit 0 : 1=Active / 0=Orphaned
+ bits 1-n : refcount
+ Ref/Unref by two to avoid altering the orphaned bit */
+ gpr_atm refst;
+
+ gpr_mu orphan_mu;
+
+ gpr_mu pollable_mu;
+ pollable* pollable_obj;
+
+ grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure;
+ grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure;
+
+ struct grpc_fd* freelist_next;
+ grpc_closure* on_done_closure;
+
+ /* The pollset that last noticed that the fd is readable. The actual type
+ * stored in this is (grpc_pollset *) */
+ gpr_atm read_notifier_pollset;
+
+ grpc_iomgr_object iomgr_object;
+};
+
+static void fd_global_init(void);
+static void fd_global_shutdown(void);
+
+/*******************************************************************************
+ * Pollset Declarations
+ */
+
+typedef struct {
+ grpc_pollset_worker* next;
+ grpc_pollset_worker* prev;
+} pwlink;
+
+typedef enum { PWLINK_POLLABLE = 0, PWLINK_POLLSET, PWLINK_COUNT } pwlinks;
+
+struct grpc_pollset_worker {
+ bool kicked;
+ bool initialized_cv;
+#ifndef NDEBUG
+ // debug aid: which thread started this worker
+ pid_t originator;
+#endif
+ gpr_cv cv;
+ grpc_pollset* pollset;
+ pollable* pollable_obj;
+
+ pwlink links[PWLINK_COUNT];
+};
+
+struct grpc_pollset {
+ gpr_mu mu;
+ pollable* active_pollable;
+ bool kicked_without_poller;
+ grpc_closure* shutdown_closure;
+ bool already_shutdown;
+ grpc_pollset_worker* root_worker;
+ int containing_pollset_set_count;
+};
+
+/*******************************************************************************
+ * Pollset-set Declarations
+ */
+
+struct grpc_pollset_set {
+ gpr_refcount refs;
+ gpr_mu mu;
+ grpc_pollset_set* parent;
+
+ size_t pollset_count;
+ size_t pollset_capacity;
+ grpc_pollset** pollsets;
+
+ size_t fd_count;
+ size_t fd_capacity;
+ grpc_fd** fds;
+};
+
+/*******************************************************************************
+ * Common helpers
+ */
+
+static bool append_error(grpc_error** composite, grpc_error* error,
+ const char* desc) {
+ if (error == GRPC_ERROR_NONE) return true;
+ if (*composite == GRPC_ERROR_NONE) {
+ *composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
+ }
+ *composite = grpc_error_add_child(*composite, error);
+ return false;
+}
+
+/*******************************************************************************
+ * Fd Definitions
+ */
+
+/* We need to keep a freelist not because of any concerns of malloc performance
+ * but instead so that implementations with multiple threads in (for example)
+ * epoll_wait deal with the race between pollset removal and incoming poll
+ * notifications.
+ *
+ * The problem is that the poller ultimately holds a reference to this
+ * object, so it is very difficult to know when is safe to free it, at least
+ * without some expensive synchronization.
+ *
+ * If we keep the object freelisted, in the worst case losing this race just
+ * becomes a spurious read notification on a reused fd.
+ */
+
+static grpc_fd* fd_freelist = nullptr;
+static gpr_mu fd_freelist_mu;
+
+#ifndef NDEBUG
+#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
+#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
+static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file,
+ int line) {
+ if (grpc_trace_fd_refcount.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
+ fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
+ gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line);
+ }
+#else
+#define REF_BY(fd, n, reason) ref_by(fd, n)
+#define UNREF_BY(fd, n, reason) unref_by(fd, n)
+static void ref_by(grpc_fd* fd, int n) {
+#endif
+ GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
+}
+
+static void fd_destroy(void* arg, grpc_error* error) {
+ grpc_fd* fd = (grpc_fd*)arg;
+ /* Add the fd to the freelist */
+ grpc_iomgr_unregister_object(&fd->iomgr_object);
+ POLLABLE_UNREF(fd->pollable_obj, "fd_pollable");
+ gpr_mu_destroy(&fd->pollable_mu);
+ gpr_mu_destroy(&fd->orphan_mu);
+ gpr_mu_lock(&fd_freelist_mu);
+ fd->freelist_next = fd_freelist;
+ fd_freelist = fd;
+
+ fd->read_closure->DestroyEvent();
+ fd->write_closure->DestroyEvent();
+
+ gpr_mu_unlock(&fd_freelist_mu);
+}
+
+#ifndef NDEBUG
+static void unref_by(grpc_fd* fd, int n, const char* reason, const char* file,
+ int line) {
+ if (grpc_trace_fd_refcount.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
+ fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
+ gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
+ }
+#else
+static void unref_by(grpc_fd* fd, int n) {
+#endif
+ gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
+ if (old == n) {
+ GRPC_CLOSURE_SCHED(
+ GRPC_CLOSURE_CREATE(fd_destroy, fd, grpc_schedule_on_exec_ctx),
+ GRPC_ERROR_NONE);
+ } else {
+ GPR_ASSERT(old > n);
+ }
+}
+
+static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
+
+static void fd_global_shutdown(void) {
+ gpr_mu_lock(&fd_freelist_mu);
+ gpr_mu_unlock(&fd_freelist_mu);
+ while (fd_freelist != nullptr) {
+ grpc_fd* fd = fd_freelist;
+ fd_freelist = fd_freelist->freelist_next;
+ gpr_free(fd);
+ }
+ gpr_mu_destroy(&fd_freelist_mu);
+}
+
+static grpc_fd* fd_create(int fd, const char* name) {
+ grpc_fd* new_fd = nullptr;
+
+ gpr_mu_lock(&fd_freelist_mu);
+ if (fd_freelist != nullptr) {
+ new_fd = fd_freelist;
+ fd_freelist = fd_freelist->freelist_next;
+ }
+ gpr_mu_unlock(&fd_freelist_mu);
+
+ if (new_fd == nullptr) {
+ new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
+ new_fd->read_closure.Init();
+ new_fd->write_closure.Init();
+ }
+
+ gpr_mu_init(&new_fd->pollable_mu);
+ gpr_mu_init(&new_fd->orphan_mu);
+ new_fd->pollable_obj = nullptr;
+ gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
+ new_fd->fd = fd;
+ new_fd->read_closure->InitEvent();
+ new_fd->write_closure->InitEvent();
+ gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
+
+ new_fd->freelist_next = nullptr;
+ new_fd->on_done_closure = nullptr;
+
+ char* fd_name;
+ gpr_asprintf(&fd_name, "%s fd=%d", name, fd);
+ grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name);
+#ifndef NDEBUG
+ if (grpc_trace_fd_refcount.enabled()) {
+ gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, new_fd, fd_name);
+ }
+#endif
+ gpr_free(fd_name);
+ return new_fd;
+}
+
+static int fd_wrapped_fd(grpc_fd* fd) {
+ int ret_fd = fd->fd;
+ return (gpr_atm_acq_load(&fd->refst) & 1) ? ret_fd : -1;
+}
+
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason) {
+ bool is_fd_closed = already_closed;
+
+ gpr_mu_lock(&fd->orphan_mu);
+
+ fd->on_done_closure = on_done;
+
+ /* If release_fd is not NULL, we should be relinquishing control of the file
+ descriptor fd->fd (but we still own the grpc_fd structure). */
+ if (release_fd != nullptr) {
+ *release_fd = fd->fd;
+ } else if (!is_fd_closed) {
+ close(fd->fd);
+ is_fd_closed = true;
+ }
+
+ if (!is_fd_closed) {
+ gpr_log(GPR_DEBUG, "TODO: handle fd removal?");
+ }
+
+ /* Remove the active status but keep referenced. We want this grpc_fd struct
+ to be alive (and not added to freelist) until the end of this function */
+ REF_BY(fd, 1, reason);
+
+ GRPC_CLOSURE_SCHED(fd->on_done_closure, GRPC_ERROR_NONE);
+
+ gpr_mu_unlock(&fd->orphan_mu);
+
+ UNREF_BY(fd, 2, reason); /* Drop the reference */
+}
+
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
+ gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
+ return (grpc_pollset*)notifier;
+}
+
+static bool fd_is_shutdown(grpc_fd* fd) {
+ return fd->read_closure->IsShutdown();
+}
+
+/* Might be called multiple times */
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) {
+ shutdown(fd->fd, SHUT_RDWR);
+ fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));
+ }
+ GRPC_ERROR_UNREF(why);
+}
+
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ fd->read_closure->NotifyOn(closure);
+}
+
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ fd->write_closure->NotifyOn(closure);
+}
+
+/*******************************************************************************
+ * Pollable Definitions
+ */
+
+static grpc_error* pollable_create(pollable_type type, pollable** p) {
+ *p = nullptr;
+
+ int epfd = epoll_create1(EPOLL_CLOEXEC);
+ if (epfd == -1) {
+ return GRPC_OS_ERROR(errno, "epoll_create1");
+ }
+ *p = (pollable*)gpr_malloc(sizeof(**p));
+ grpc_error* err = grpc_wakeup_fd_init(&(*p)->wakeup);
+ if (err != GRPC_ERROR_NONE) {
+ close(epfd);
+ gpr_free(*p);
+ *p = nullptr;
+ return err;
+ }
+ struct epoll_event ev;
+ ev.events = (uint32_t)(EPOLLIN | EPOLLET);
+ ev.data.ptr = (void*)(1 | (intptr_t) & (*p)->wakeup);
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, (*p)->wakeup.read_fd, &ev) != 0) {
+ err = GRPC_OS_ERROR(errno, "epoll_ctl");
+ close(epfd);
+ grpc_wakeup_fd_destroy(&(*p)->wakeup);
+ gpr_free(*p);
+ *p = nullptr;
+ return err;
+ }
+
+ (*p)->type = type;
+ gpr_ref_init(&(*p)->refs, 1);
+ gpr_mu_init(&(*p)->mu);
+ (*p)->epfd = epfd;
+ (*p)->owner_fd = nullptr;
+ (*p)->pollset_set = nullptr;
+ (*p)->next = (*p)->prev = *p;
+ (*p)->root_worker = nullptr;
+ (*p)->event_cursor = 0;
+ (*p)->event_count = 0;
+ return GRPC_ERROR_NONE;
+}
+
+#ifdef NDEBUG
+static pollable* pollable_ref(pollable* p) {
+#else
+static pollable* pollable_ref(pollable* p, int line, const char* reason) {
+ if (grpc_trace_pollable_refcount.enabled()) {
+ int r = (int)gpr_atm_no_barrier_load(&p->refs.count);
+ gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG,
+ "POLLABLE:%p ref %d->%d %s", p, r, r + 1, reason);
+ }
+#endif
+ gpr_ref(&p->refs);
+ return p;
+}
+
+#ifdef NDEBUG
+static void pollable_unref(pollable* p) {
+#else
+static void pollable_unref(pollable* p, int line, const char* reason) {
+ if (p == nullptr) return;
+ if (grpc_trace_pollable_refcount.enabled()) {
+ int r = (int)gpr_atm_no_barrier_load(&p->refs.count);
+ gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG,
+ "POLLABLE:%p unref %d->%d %s", p, r, r - 1, reason);
+ }
+#endif
+ if (p != nullptr && gpr_unref(&p->refs)) {
+ close(p->epfd);
+ grpc_wakeup_fd_destroy(&p->wakeup);
+ gpr_free(p);
+ }
+}
+
+static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* err_desc = "pollable_add_fd";
+ const int epfd = p->epfd;
+
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "add fd %p (%d) to pollable %p", fd, fd->fd, p);
+ }
+
+ struct epoll_event ev_fd;
+ ev_fd.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLOUT | EPOLLEXCLUSIVE);
+ ev_fd.data.ptr = fd;
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd->fd, &ev_fd) != 0) {
+ switch (errno) {
+ case EEXIST:
+ break;
+ default:
+ append_error(&error, GRPC_OS_ERROR(errno, "epoll_ctl"), err_desc);
+ }
+ }
+
+ return error;
+}
+
+/*******************************************************************************
+ * Pollset Definitions
+ */
+
+GPR_TLS_DECL(g_current_thread_pollset);
+GPR_TLS_DECL(g_current_thread_worker);
+
+/* Global state management */
+static grpc_error* pollset_global_init(void) {
+ gpr_tls_init(&g_current_thread_pollset);
+ gpr_tls_init(&g_current_thread_worker);
+ return pollable_create(PO_EMPTY, &g_empty_pollable);
+}
+
+static void pollset_global_shutdown(void) {
+ POLLABLE_UNREF(g_empty_pollable, "g_empty_pollable");
+ gpr_tls_destroy(&g_current_thread_pollset);
+ gpr_tls_destroy(&g_current_thread_worker);
+}
+
+/* pollset->mu must be held while calling this function */
+static void pollset_maybe_finish_shutdown(grpc_pollset* pollset) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "PS:%p (pollable:%p) maybe_finish_shutdown sc=%p (target:!NULL) "
+ "rw=%p (target:NULL) cpsc=%d (target:0)",
+ pollset, pollset->active_pollable, pollset->shutdown_closure,
+ pollset->root_worker, pollset->containing_pollset_set_count);
+ }
+ if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr &&
+ pollset->containing_pollset_set_count == 0) {
+ GRPC_CLOSURE_SCHED(pollset->shutdown_closure, GRPC_ERROR_NONE);
+ pollset->shutdown_closure = nullptr;
+ pollset->already_shutdown = true;
+ }
+}
+
+/* pollset->mu must be held before calling this function,
+ * pollset->active_pollable->mu & specific_worker->pollable_obj->mu must not be
+ * held */
+static grpc_error* kick_one_worker(grpc_pollset_worker* specific_worker) {
+ pollable* p = specific_worker->pollable_obj;
+ grpc_core::mu_guard lock(&p->mu);
+ GPR_ASSERT(specific_worker != nullptr);
+ if (specific_worker->kicked) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p);
+ }
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
+ return GRPC_ERROR_NONE;
+ }
+ if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_awake", p);
+ }
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
+ specific_worker->kicked = true;
+ return GRPC_ERROR_NONE;
+ }
+ if (specific_worker == p->root_worker) {
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_wakeup_fd", p);
+ }
+ specific_worker->kicked = true;
+ grpc_error* error = grpc_wakeup_fd_wakeup(&p->wakeup);
+ return error;
+ }
+ if (specific_worker->initialized_cv) {
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_cv", p);
+ }
+ specific_worker->kicked = true;
+ gpr_cv_signal(&specific_worker->cv);
+ return GRPC_ERROR_NONE;
+ }
+ // we can get here during end_worker after removing specific_worker from the
+ // pollable list but before removing it from the pollset list
+ return GRPC_ERROR_NONE;
+}
+
+static grpc_error* pollset_kick(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker) {
+ GRPC_STATS_INC_POLLSET_KICK();
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "PS:%p kick %p tls_pollset=%p tls_worker=%p pollset.root_worker=%p",
+ pollset, specific_worker,
+ (void*)gpr_tls_get(&g_current_thread_pollset),
+ (void*)gpr_tls_get(&g_current_thread_worker), pollset->root_worker);
+ }
+ if (specific_worker == nullptr) {
+ if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) {
+ if (pollset->root_worker == nullptr) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", pollset);
+ }
+ GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER();
+ pollset->kicked_without_poller = true;
+ return GRPC_ERROR_NONE;
+ } else {
+ // We've been asked to kick a poller, but we haven't been told which one
+ // ... any will do
+ // We look at the pollset worker list because:
+ // 1. the pollable list may include workers from other pollers, so we'd
+ // need to do an O(N) search
+ // 2. we'd additionally need to take the pollable lock, which we've so
+ // far avoided
+ // Now, we would prefer to wake a poller in cv_wait, and not in
+ // epoll_wait (since the latter would imply the need to do an additional
+ // wakeup)
+ // We know that if a worker is at the root of a pollable, it's (likely)
+ // also the root of a pollset, and we know that if a worker is NOT at
+ // the root of a pollset, it's (likely) not at the root of a pollable,
+ // so we take our chances and choose the SECOND worker enqueued against
+ // the pollset as a worker that's likely to be in cv_wait
+ return kick_one_worker(
+ pollset->root_worker->links[PWLINK_POLLSET].next);
+ }
+ } else {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", pollset);
+ }
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
+ return GRPC_ERROR_NONE;
+ }
+ } else {
+ return kick_one_worker(specific_worker);
+ }
+}
+
+static grpc_error* pollset_kick_all(grpc_pollset* pollset) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ const char* err_desc = "pollset_kick_all";
+ grpc_pollset_worker* w = pollset->root_worker;
+ if (w != nullptr) {
+ do {
+ GRPC_STATS_INC_POLLSET_KICK();
+ append_error(&error, kick_one_worker(w), err_desc);
+ w = w->links[PWLINK_POLLSET].next;
+ } while (w != pollset->root_worker);
+ }
+ return error;
+}
+
+static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
+ gpr_mu_init(&pollset->mu);
+ pollset->active_pollable = POLLABLE_REF(g_empty_pollable, "pollset");
+ pollset->kicked_without_poller = false;
+ pollset->shutdown_closure = nullptr;
+ pollset->already_shutdown = false;
+ pollset->root_worker = nullptr;
+ pollset->containing_pollset_set_count = 0;
+ *mu = &pollset->mu;
+}
+
+static int poll_deadline_to_millis_timeout(grpc_millis millis) {
+ if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
+ grpc_millis delta = millis - grpc_core::ExecCtx::Get()->Now();
+ if (delta > INT_MAX)
+ return INT_MAX;
+ else if (delta < 0)
+ return 0;
+ else
+ return (int)delta;
+}
+
+static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
+ fd->read_closure->SetReady();
+
+ /* Note, it is possible that fd_become_readable might be called twice with
+ different 'notifier's when an fd becomes readable and it is in two epoll
+ sets (This can happen briefly during polling island merges). In such cases
+ it does not really matter which notifer is set as the read_notifier_pollset
+ (They would both point to the same polling island anyway) */
+ /* Use release store to match with acquire load in fd_get_read_notifier */
+ gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
+}
+
+static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
+
+static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) {
+ gpr_mu_lock(&fd->pollable_mu);
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* err_desc = "fd_get_or_become_pollable";
+ if (fd->pollable_obj == nullptr) {
+ if (append_error(&error, pollable_create(PO_FD, &fd->pollable_obj),
+ err_desc)) {
+ fd->pollable_obj->owner_fd = fd;
+ if (!append_error(&error, pollable_add_fd(fd->pollable_obj, fd),
+ err_desc)) {
+ POLLABLE_UNREF(fd->pollable_obj, "fd_pollable");
+ fd->pollable_obj = nullptr;
+ }
+ }
+ }
+ if (error == GRPC_ERROR_NONE) {
+ GPR_ASSERT(fd->pollable_obj != nullptr);
+ *p = POLLABLE_REF(fd->pollable_obj, "pollset");
+ } else {
+ GPR_ASSERT(fd->pollable_obj == nullptr);
+ *p = nullptr;
+ }
+ gpr_mu_unlock(&fd->pollable_mu);
+ return error;
+}
+
+/* pollset->po.mu lock must be held by the caller before calling this */
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
+ GPR_ASSERT(pollset->shutdown_closure == nullptr);
+ pollset->shutdown_closure = closure;
+ GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(pollset));
+ pollset_maybe_finish_shutdown(pollset);
+}
+
+static grpc_error* pollable_process_events(grpc_pollset* pollset,
+ pollable* pollable_obj, bool drain) {
+ static const char* err_desc = "pollset_process_events";
+ grpc_error* error = GRPC_ERROR_NONE;
+ for (int i = 0; (drain || i < MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL) &&
+ pollable_obj->event_cursor != pollable_obj->event_count;
+ i++) {
+ int n = pollable_obj->event_cursor++;
+ struct epoll_event* ev = &pollable_obj->events[n];
+ void* data_ptr = ev->data.ptr;
+ if (1 & (intptr_t)data_ptr) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr);
+ }
+ append_error(&error,
+ grpc_wakeup_fd_consume_wakeup(
+ (grpc_wakeup_fd*)((~(intptr_t)1) & (intptr_t)data_ptr)),
+ err_desc);
+ } else {
+ grpc_fd* fd = (grpc_fd*)data_ptr;
+ bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0;
+ bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0;
+ bool write_ev = (ev->events & EPOLLOUT) != 0;
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "PS:%p got fd %p: cancel=%d read=%d "
+ "write=%d",
+ pollset, fd, cancel, read_ev, write_ev);
+ }
+ if (read_ev || cancel) {
+ fd_become_readable(fd, pollset);
+ }
+ if (write_ev || cancel) {
+ fd_become_writable(fd);
+ }
+ }
+ }
+
+ return error;
+}
+
+/* pollset_shutdown is guaranteed to be called before pollset_destroy. */
+static void pollset_destroy(grpc_pollset* pollset) {
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ pollset->active_pollable = nullptr;
+}
+
+static grpc_error* pollable_epoll(pollable* p, grpc_millis deadline) {
+ int timeout = poll_deadline_to_millis_timeout(deadline);
+
+ if (grpc_polling_trace.enabled()) {
+ char* desc = pollable_desc(p);
+ gpr_log(GPR_DEBUG, "POLLABLE:%p[%s] poll for %dms", p, desc, timeout);
+ gpr_free(desc);
+ }
+
+ if (timeout != 0) {
+ GRPC_SCHEDULING_START_BLOCKING_REGION;
+ }
+ int r;
+ do {
+ GRPC_STATS_INC_SYSCALL_POLL();
+ r = epoll_wait(p->epfd, p->events, MAX_EPOLL_EVENTS, timeout);
+ } while (r < 0 && errno == EINTR);
+ if (timeout != 0) {
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
+ }
+
+ if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
+
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "POLLABLE:%p got %d events", p, r);
+ }
+
+ p->event_cursor = 0;
+ p->event_count = r;
+
+ return GRPC_ERROR_NONE;
+}
+
+/* Return true if first in list */
+static bool worker_insert(grpc_pollset_worker** root_worker,
+ grpc_pollset_worker* worker, pwlinks link) {
+ if (*root_worker == nullptr) {
+ *root_worker = worker;
+ worker->links[link].next = worker->links[link].prev = worker;
+ return true;
+ } else {
+ worker->links[link].next = *root_worker;
+ worker->links[link].prev = worker->links[link].next->links[link].prev;
+ worker->links[link].next->links[link].prev = worker;
+ worker->links[link].prev->links[link].next = worker;
+ return false;
+ }
+}
+
+/* returns the new root IFF the root changed */
+typedef enum { WRR_NEW_ROOT, WRR_EMPTIED, WRR_REMOVED } worker_remove_result;
+
+static worker_remove_result worker_remove(grpc_pollset_worker** root_worker,
+ grpc_pollset_worker* worker,
+ pwlinks link) {
+ if (worker == *root_worker) {
+ if (worker == worker->links[link].next) {
+ *root_worker = nullptr;
+ return WRR_EMPTIED;
+ } else {
+ *root_worker = worker->links[link].next;
+ worker->links[link].prev->links[link].next = worker->links[link].next;
+ worker->links[link].next->links[link].prev = worker->links[link].prev;
+ return WRR_NEW_ROOT;
+ }
+ } else {
+ worker->links[link].prev->links[link].next = worker->links[link].next;
+ worker->links[link].next->links[link].prev = worker->links[link].prev;
+ return WRR_REMOVED;
+ }
+}
+
+/* Return true if this thread should poll */
+static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
+ bool do_poll =
+ (pollset->shutdown_closure == nullptr && !pollset->already_shutdown);
+ if (worker_hdl != nullptr) *worker_hdl = worker;
+ worker->initialized_cv = false;
+ worker->kicked = false;
+ worker->pollset = pollset;
+ worker->pollable_obj =
+ POLLABLE_REF(pollset->active_pollable, "pollset_worker");
+ worker_insert(&pollset->root_worker, worker, PWLINK_POLLSET);
+ gpr_mu_lock(&worker->pollable_obj->mu);
+ if (!worker_insert(&worker->pollable_obj->root_worker, worker,
+ PWLINK_POLLABLE)) {
+ worker->initialized_cv = true;
+ gpr_cv_init(&worker->cv);
+ gpr_mu_unlock(&pollset->mu);
+ if (grpc_polling_trace.enabled() &&
+ worker->pollable_obj->root_worker != worker) {
+ gpr_log(GPR_DEBUG, "PS:%p wait %p w=%p for %dms", pollset,
+ worker->pollable_obj, worker,
+ poll_deadline_to_millis_timeout(deadline));
+ }
+ while (do_poll && worker->pollable_obj->root_worker != worker) {
+ if (gpr_cv_wait(&worker->cv, &worker->pollable_obj->mu,
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p timeout_wait %p w=%p", pollset,
+ worker->pollable_obj, worker);
+ }
+ do_poll = false;
+ } else if (worker->kicked) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PS:%p wakeup %p w=%p", pollset,
+ worker->pollable_obj, worker);
+ }
+ do_poll = false;
+ } else if (grpc_polling_trace.enabled() &&
+ worker->pollable_obj->root_worker != worker) {
+ gpr_log(GPR_DEBUG, "PS:%p spurious_wakeup %p w=%p", pollset,
+ worker->pollable_obj, worker);
+ }
+ }
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ } else {
+ gpr_mu_unlock(&pollset->mu);
+ }
+ gpr_mu_unlock(&worker->pollable_obj->mu);
+
+ return do_poll;
+}
+
+static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
+ grpc_pollset_worker** worker_hdl) {
+ gpr_mu_lock(&pollset->mu);
+ gpr_mu_lock(&worker->pollable_obj->mu);
+ switch (worker_remove(&worker->pollable_obj->root_worker, worker,
+ PWLINK_POLLABLE)) {
+ case WRR_NEW_ROOT: {
+ // wakeup new poller
+ grpc_pollset_worker* new_root = worker->pollable_obj->root_worker;
+ GPR_ASSERT(new_root->initialized_cv);
+ gpr_cv_signal(&new_root->cv);
+ break;
+ }
+ case WRR_EMPTIED:
+ if (pollset->active_pollable != worker->pollable_obj) {
+ // pollable no longer being polled: flush events
+ pollable_process_events(pollset, worker->pollable_obj, true);
+ }
+ break;
+ case WRR_REMOVED:
+ break;
+ }
+ gpr_mu_unlock(&worker->pollable_obj->mu);
+ POLLABLE_UNREF(worker->pollable_obj, "pollset_worker");
+ if (worker_remove(&pollset->root_worker, worker, PWLINK_POLLSET) ==
+ WRR_EMPTIED) {
+ pollset_maybe_finish_shutdown(pollset);
+ }
+ if (worker->initialized_cv) {
+ gpr_cv_destroy(&worker->cv);
+ }
+}
+
+#ifndef NDEBUG
+static long gettid(void) { return syscall(__NR_gettid); }
+#endif
+
+/* pollset->mu lock must be held by the caller before calling this.
+ The function pollset_work() may temporarily release the lock (pollset->po.mu)
+ during the course of its execution but it will always re-acquire the lock and
+ ensure that it is held by the time the function returns */
+static grpc_error* pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
+#ifdef GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP
+ grpc_pollset_worker* worker =
+ (grpc_pollset_worker*)gpr_malloc(sizeof(*worker));
+#define WORKER_PTR (worker)
+#else
+ grpc_pollset_worker worker;
+#define WORKER_PTR (&worker)
+#endif
+#ifndef NDEBUG
+ WORKER_PTR->originator = gettid();
+#endif
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "PS:%p work hdl=%p worker=%p now=%" PRIdPTR " deadline=%" PRIdPTR
+ " kwp=%d pollable=%p",
+ pollset, worker_hdl, WORKER_PTR, grpc_core::ExecCtx::Get()->Now(),
+ deadline, pollset->kicked_without_poller, pollset->active_pollable);
+ }
+ static const char* err_desc = "pollset_work";
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (pollset->kicked_without_poller) {
+ pollset->kicked_without_poller = false;
+ } else {
+ if (begin_worker(pollset, WORKER_PTR, worker_hdl, deadline)) {
+ gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset);
+ gpr_tls_set(&g_current_thread_worker, (intptr_t)WORKER_PTR);
+ if (WORKER_PTR->pollable_obj->event_cursor ==
+ WORKER_PTR->pollable_obj->event_count) {
+ append_error(&error, pollable_epoll(WORKER_PTR->pollable_obj, deadline),
+ err_desc);
+ }
+ append_error(
+ &error,
+ pollable_process_events(pollset, WORKER_PTR->pollable_obj, false),
+ err_desc);
+ grpc_core::ExecCtx::Get()->Flush();
+ gpr_tls_set(&g_current_thread_pollset, 0);
+ gpr_tls_set(&g_current_thread_worker, 0);
+ }
+ end_worker(pollset, WORKER_PTR, worker_hdl);
+ }
+#ifdef GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP
+ gpr_free(worker);
+#endif
+#undef WORKER_PTR
+ return error;
+}
+
+static grpc_error* pollset_transition_pollable_from_empty_to_fd_locked(
+ grpc_pollset* pollset, grpc_fd* fd) {
+ static const char* err_desc = "pollset_transition_pollable_from_empty_to_fd";
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "PS:%p add fd %p (%d); transition pollable from empty to fd",
+ pollset, fd, fd->fd);
+ }
+ append_error(&error, pollset_kick_all(pollset), err_desc);
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ append_error(&error, fd_get_or_become_pollable(fd, &pollset->active_pollable),
+ err_desc);
+ return error;
+}
+
+static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked(
+ grpc_pollset* pollset, grpc_fd* and_add_fd) {
+ static const char* err_desc = "pollset_transition_pollable_from_fd_to_multi";
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(
+ GPR_DEBUG,
+ "PS:%p add fd %p (%d); transition pollable from fd %p to multipoller",
+ pollset, and_add_fd, and_add_fd ? and_add_fd->fd : -1,
+ pollset->active_pollable->owner_fd);
+ }
+ append_error(&error, pollset_kick_all(pollset), err_desc);
+ grpc_fd* initial_fd = pollset->active_pollable->owner_fd;
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ pollset->active_pollable = nullptr;
+ if (append_error(&error, pollable_create(PO_MULTI, &pollset->active_pollable),
+ err_desc)) {
+ append_error(&error, pollable_add_fd(pollset->active_pollable, initial_fd),
+ err_desc);
+ if (and_add_fd != nullptr) {
+ append_error(&error,
+ pollable_add_fd(pollset->active_pollable, and_add_fd),
+ err_desc);
+ }
+ }
+ return error;
+}
+
+/* expects pollsets locked, flag whether fd is locked or not */
+static grpc_error* pollset_add_fd_locked(grpc_pollset* pollset, grpc_fd* fd) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ pollable* po_at_start =
+ POLLABLE_REF(pollset->active_pollable, "pollset_add_fd");
+ switch (pollset->active_pollable->type) {
+ case PO_EMPTY:
+ /* empty pollable --> single fd pollable */
+ error = pollset_transition_pollable_from_empty_to_fd_locked(pollset, fd);
+ break;
+ case PO_FD:
+ gpr_mu_lock(&po_at_start->owner_fd->orphan_mu);
+ if ((gpr_atm_no_barrier_load(&pollset->active_pollable->owner_fd->refst) &
+ 1) == 0) {
+ error =
+ pollset_transition_pollable_from_empty_to_fd_locked(pollset, fd);
+ } else {
+ /* fd --> multipoller */
+ error =
+ pollset_transition_pollable_from_fd_to_multi_locked(pollset, fd);
+ }
+ gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu);
+ break;
+ case PO_MULTI:
+ error = pollable_add_fd(pollset->active_pollable, fd);
+ break;
+ }
+ if (error != GRPC_ERROR_NONE) {
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ pollset->active_pollable = po_at_start;
+ } else {
+ POLLABLE_UNREF(po_at_start, "pollset_add_fd");
+ }
+ return error;
+}
+
+static grpc_error* pollset_as_multipollable_locked(grpc_pollset* pollset,
+ pollable** pollable_obj) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ pollable* po_at_start =
+ POLLABLE_REF(pollset->active_pollable, "pollset_as_multipollable");
+ switch (pollset->active_pollable->type) {
+ case PO_EMPTY:
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ error = pollable_create(PO_MULTI, &pollset->active_pollable);
+ break;
+ case PO_FD:
+ gpr_mu_lock(&po_at_start->owner_fd->orphan_mu);
+ if ((gpr_atm_no_barrier_load(&pollset->active_pollable->owner_fd->refst) &
+ 1) == 0) {
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ error = pollable_create(PO_MULTI, &pollset->active_pollable);
+ } else {
+ error = pollset_transition_pollable_from_fd_to_multi_locked(pollset,
+ nullptr);
+ }
+ gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu);
+ break;
+ case PO_MULTI:
+ break;
+ }
+ if (error != GRPC_ERROR_NONE) {
+ POLLABLE_UNREF(pollset->active_pollable, "pollset");
+ pollset->active_pollable = po_at_start;
+ *pollable_obj = nullptr;
+ } else {
+ *pollable_obj = POLLABLE_REF(pollset->active_pollable, "pollset_set");
+ POLLABLE_UNREF(po_at_start, "pollset_as_multipollable");
+ }
+ return error;
+}
+
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
+ gpr_mu_lock(&pollset->mu);
+ grpc_error* error = pollset_add_fd_locked(pollset, fd);
+ gpr_mu_unlock(&pollset->mu);
+ GRPC_LOG_IF_ERROR("pollset_add_fd", error);
+}
+
+/*******************************************************************************
+ * Pollset-set Definitions
+ */
+
+static grpc_pollset_set* pss_lock_adam(grpc_pollset_set* pss) {
+ gpr_mu_lock(&pss->mu);
+ while (pss->parent != nullptr) {
+ gpr_mu_unlock(&pss->mu);
+ pss = pss->parent;
+ gpr_mu_lock(&pss->mu);
+ }
+ return pss;
+}
+
+static grpc_pollset_set* pollset_set_create(void) {
+ grpc_pollset_set* pss = (grpc_pollset_set*)gpr_zalloc(sizeof(*pss));
+ gpr_mu_init(&pss->mu);
+ gpr_ref_init(&pss->refs, 1);
+ return pss;
+}
+
+static void pollset_set_unref(grpc_pollset_set* pss) {
+ if (pss == nullptr) return;
+ if (!gpr_unref(&pss->refs)) return;
+ pollset_set_unref(pss->parent);
+ gpr_mu_destroy(&pss->mu);
+ for (size_t i = 0; i < pss->pollset_count; i++) {
+ gpr_mu_lock(&pss->pollsets[i]->mu);
+ if (0 == --pss->pollsets[i]->containing_pollset_set_count) {
+ pollset_maybe_finish_shutdown(pss->pollsets[i]);
+ }
+ gpr_mu_unlock(&pss->pollsets[i]->mu);
+ }
+ for (size_t i = 0; i < pss->fd_count; i++) {
+ UNREF_BY(pss->fds[i], 2, "pollset_set");
+ }
+ gpr_free(pss->pollsets);
+ gpr_free(pss->fds);
+ gpr_free(pss);
+}
+
+static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PSS:%p: add fd %p (%d)", pss, fd, fd->fd);
+ }
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* err_desc = "pollset_set_add_fd";
+ pss = pss_lock_adam(pss);
+ for (size_t i = 0; i < pss->pollset_count; i++) {
+ append_error(&error, pollable_add_fd(pss->pollsets[i]->active_pollable, fd),
+ err_desc);
+ }
+ if (pss->fd_count == pss->fd_capacity) {
+ pss->fd_capacity = GPR_MAX(pss->fd_capacity * 2, 8);
+ pss->fds =
+ (grpc_fd**)gpr_realloc(pss->fds, pss->fd_capacity * sizeof(*pss->fds));
+ }
+ REF_BY(fd, 2, "pollset_set");
+ pss->fds[pss->fd_count++] = fd;
+ gpr_mu_unlock(&pss->mu);
+
+ GRPC_LOG_IF_ERROR(err_desc, error);
+}
+
+static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PSS:%p: del fd %p", pss, fd);
+ }
+ pss = pss_lock_adam(pss);
+ size_t i;
+ for (i = 0; i < pss->fd_count; i++) {
+ if (pss->fds[i] == fd) {
+ UNREF_BY(fd, 2, "pollset_set");
+ break;
+ }
+ }
+ GPR_ASSERT(i != pss->fd_count);
+ for (; i < pss->fd_count - 1; i++) {
+ pss->fds[i] = pss->fds[i + 1];
+ }
+ pss->fd_count--;
+ gpr_mu_unlock(&pss->mu);
+}
+
+static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PSS:%p: del pollset %p", pss, ps);
+ }
+ pss = pss_lock_adam(pss);
+ size_t i;
+ for (i = 0; i < pss->pollset_count; i++) {
+ if (pss->pollsets[i] == ps) {
+ break;
+ }
+ }
+ GPR_ASSERT(i != pss->pollset_count);
+ for (; i < pss->pollset_count - 1; i++) {
+ pss->pollsets[i] = pss->pollsets[i + 1];
+ }
+ pss->pollset_count--;
+ gpr_mu_unlock(&pss->mu);
+ gpr_mu_lock(&ps->mu);
+ if (0 == --ps->containing_pollset_set_count) {
+ pollset_maybe_finish_shutdown(ps);
+ }
+ gpr_mu_unlock(&ps->mu);
+}
+
+// add all fds to pollables, and output a new array of unorphaned out_fds
+// assumes pollsets are multipollable
+static grpc_error* add_fds_to_pollsets(grpc_fd** fds, size_t fd_count,
+ grpc_pollset** pollsets,
+ size_t pollset_count,
+ const char* err_desc, grpc_fd** out_fds,
+ size_t* out_fd_count) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ for (size_t i = 0; i < fd_count; i++) {
+ gpr_mu_lock(&fds[i]->orphan_mu);
+ if ((gpr_atm_no_barrier_load(&fds[i]->refst) & 1) == 0) {
+ gpr_mu_unlock(&fds[i]->orphan_mu);
+ UNREF_BY(fds[i], 2, "pollset_set");
+ } else {
+ for (size_t j = 0; j < pollset_count; j++) {
+ append_error(&error,
+ pollable_add_fd(pollsets[j]->active_pollable, fds[i]),
+ err_desc);
+ }
+ gpr_mu_unlock(&fds[i]->orphan_mu);
+ out_fds[(*out_fd_count)++] = fds[i];
+ }
+ }
+ return error;
+}
+
+static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PSS:%p: add pollset %p", pss, ps);
+ }
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* err_desc = "pollset_set_add_pollset";
+ pollable* pollable_obj = nullptr;
+ gpr_mu_lock(&ps->mu);
+ if (!GRPC_LOG_IF_ERROR(err_desc,
+ pollset_as_multipollable_locked(ps, &pollable_obj))) {
+ GPR_ASSERT(pollable_obj == nullptr);
+ gpr_mu_unlock(&ps->mu);
+ return;
+ }
+ ps->containing_pollset_set_count++;
+ gpr_mu_unlock(&ps->mu);
+ pss = pss_lock_adam(pss);
+ size_t initial_fd_count = pss->fd_count;
+ pss->fd_count = 0;
+ append_error(&error,
+ add_fds_to_pollsets(pss->fds, initial_fd_count, &ps, 1, err_desc,
+ pss->fds, &pss->fd_count),
+ err_desc);
+ if (pss->pollset_count == pss->pollset_capacity) {
+ pss->pollset_capacity = GPR_MAX(pss->pollset_capacity * 2, 8);
+ pss->pollsets = (grpc_pollset**)gpr_realloc(
+ pss->pollsets, pss->pollset_capacity * sizeof(*pss->pollsets));
+ }
+ pss->pollsets[pss->pollset_count++] = ps;
+ gpr_mu_unlock(&pss->mu);
+ POLLABLE_UNREF(pollable_obj, "pollset_set");
+
+ GRPC_LOG_IF_ERROR(err_desc, error);
+}
+
+static void pollset_set_add_pollset_set(grpc_pollset_set* a,
+ grpc_pollset_set* b) {
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PSS: merge (%p, %p)", a, b);
+ }
+ grpc_error* error = GRPC_ERROR_NONE;
+ static const char* err_desc = "pollset_set_add_fd";
+ for (;;) {
+ if (a == b) {
+ // pollset ancestors are the same: nothing to do
+ return;
+ }
+ if (a > b) {
+ GPR_SWAP(grpc_pollset_set*, a, b);
+ }
+ gpr_mu* a_mu = &a->mu;
+ gpr_mu* b_mu = &b->mu;
+ gpr_mu_lock(a_mu);
+ gpr_mu_lock(b_mu);
+ if (a->parent != nullptr) {
+ a = a->parent;
+ } else if (b->parent != nullptr) {
+ b = b->parent;
+ } else {
+ break; // exit loop, both pollsets locked
+ }
+ gpr_mu_unlock(a_mu);
+ gpr_mu_unlock(b_mu);
+ }
+ // try to do the least copying possible
+ // TODO(ctiller): there's probably a better heuristic here
+ const size_t a_size = a->fd_count + a->pollset_count;
+ const size_t b_size = b->fd_count + b->pollset_count;
+ if (b_size > a_size) {
+ GPR_SWAP(grpc_pollset_set*, a, b);
+ }
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "PSS: parent %p to %p", b, a);
+ }
+ gpr_ref(&a->refs);
+ b->parent = a;
+ if (a->fd_capacity < a->fd_count + b->fd_count) {
+ a->fd_capacity = GPR_MAX(2 * a->fd_capacity, a->fd_count + b->fd_count);
+ a->fds = (grpc_fd**)gpr_realloc(a->fds, a->fd_capacity * sizeof(*a->fds));
+ }
+ size_t initial_a_fd_count = a->fd_count;
+ a->fd_count = 0;
+ append_error(
+ &error,
+ add_fds_to_pollsets(a->fds, initial_a_fd_count, b->pollsets,
+ b->pollset_count, "merge_a2b", a->fds, &a->fd_count),
+ err_desc);
+ append_error(
+ &error,
+ add_fds_to_pollsets(b->fds, b->fd_count, a->pollsets, a->pollset_count,
+ "merge_b2a", a->fds, &a->fd_count),
+ err_desc);
+ if (a->pollset_capacity < a->pollset_count + b->pollset_count) {
+ a->pollset_capacity =
+ GPR_MAX(2 * a->pollset_capacity, a->pollset_count + b->pollset_count);
+ a->pollsets = (grpc_pollset**)gpr_realloc(
+ a->pollsets, a->pollset_capacity * sizeof(*a->pollsets));
+ }
+ if (b->pollset_count > 0) {
+ memcpy(a->pollsets + a->pollset_count, b->pollsets,
+ b->pollset_count * sizeof(*b->pollsets));
+ }
+ a->pollset_count += b->pollset_count;
+ gpr_free(b->fds);
+ gpr_free(b->pollsets);
+ b->fds = nullptr;
+ b->pollsets = nullptr;
+ b->fd_count = b->fd_capacity = b->pollset_count = b->pollset_capacity = 0;
+ gpr_mu_unlock(&a->mu);
+ gpr_mu_unlock(&b->mu);
+}
+
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {}
+
+/*******************************************************************************
+ * Event engine binding
+ */
+
+static void shutdown_engine(void) {
+ fd_global_shutdown();
+ pollset_global_shutdown();
+}
+
+static const grpc_event_engine_vtable vtable = {
+ sizeof(grpc_pollset),
+
+ fd_create,
+ fd_wrapped_fd,
+ fd_orphan,
+ fd_shutdown,
+ fd_notify_on_read,
+ fd_notify_on_write,
+ fd_is_shutdown,
+ fd_get_read_notifier_pollset,
+
+ pollset_init,
+ pollset_shutdown,
+ pollset_destroy,
+ pollset_work,
+ pollset_kick,
+ pollset_add_fd,
+
+ pollset_set_create,
+ pollset_set_unref, // destroy ==> unref 1 public ref
+ pollset_set_add_pollset,
+ pollset_set_del_pollset,
+ pollset_set_add_pollset_set,
+ pollset_set_del_pollset_set,
+ pollset_set_add_fd,
+ pollset_set_del_fd,
+
+ shutdown_engine,
+};
+
+const grpc_event_engine_vtable* grpc_init_epollex_linux(
+ bool explicitly_requested) {
+ if (!explicitly_requested) {
+ return nullptr;
+ }
+
+ if (!grpc_has_wakeup_fd()) {
+ gpr_log(GPR_ERROR, "Skipping epollex because of no wakeup fd.");
+ return nullptr;
+ }
+
+ if (!grpc_is_epollexclusive_available()) {
+ gpr_log(GPR_INFO, "Skipping epollex because it is not supported.");
+ return nullptr;
+ }
+
+ fd_global_init();
+
+ if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
+ pollset_global_shutdown();
+ fd_global_shutdown();
+ return nullptr;
+ }
+
+ return &vtable;
+}
+
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
+#if defined(GRPC_POSIX_SOCKET)
+#include "src/core/lib/iomgr/ev_epollex_linux.h"
+/* If GRPC_LINUX_EPOLL_CREATE1 is not defined, it means
+ epoll_create1 is not available. Return NULL */
+const grpc_event_engine_vtable* grpc_init_epollex_linux(
+ bool explicitly_requested) {
+ return nullptr;
+}
+#endif /* defined(GRPC_POSIX_SOCKET) */
+
+#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/src/core/lib/iomgr/ev_epollex_linux.h b/src/core/lib/iomgr/ev_epollex_linux.h
index cff9b43c02..ffa7fc7f32 100644
--- a/src/core/lib/iomgr/ev_epollex_linux.h
+++ b/src/core/lib/iomgr/ev_epollex_linux.h
@@ -22,7 +22,7 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
-const grpc_event_engine_vtable *grpc_init_epollex_linux(
+const grpc_event_engine_vtable* grpc_init_epollex_linux(
bool explicitly_requested);
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.cc
index 4d8bdf1401..1518348992 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.c
+++ b/src/core/lib/iomgr/ev_epollsig_linux.cc
@@ -18,13 +18,17 @@
#include "src/core/lib/iomgr/port.h"
+#include <grpc/grpc_posix.h>
+#include <grpc/support/log.h>
+
/* This polling engine is only relevant on linux kernels supporting epoll() */
-#ifdef GRPC_LINUX_EPOLL
+#ifdef GRPC_LINUX_EPOLL_CREATE1
#include "src/core/lib/iomgr/ev_epollsig_linux.h"
#include <assert.h>
#include <errno.h>
+#include <limits.h>
#include <poll.h>
#include <pthread.h>
#include <signal.h>
@@ -34,25 +38,25 @@
#include <unistd.h>
#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/tls.h>
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.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"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/lockfree_event.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/block_annotate.h"
-#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
+#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
-#define GRPC_POLLING_TRACE(...) \
- if (GRPC_TRACER_ON(grpc_polling_trace)) { \
- gpr_log(GPR_INFO, __VA_ARGS__); \
+#define GRPC_POLLING_TRACE(...) \
+ if (grpc_polling_trace.enabled()) { \
+ gpr_log(GPR_INFO, __VA_ARGS__); \
}
static int grpc_wakeup_signal = -1;
@@ -87,10 +91,10 @@ typedef struct poll_obj {
poll_obj_type obj_type;
#endif
gpr_mu mu;
- struct polling_island *pi;
+ struct polling_island* pi;
} poll_obj;
-const char *poll_obj_string(poll_obj_type po_type) {
+const char* poll_obj_string(poll_obj_type po_type) {
switch (po_type) {
case POLL_OBJ_FD:
return "fd";
@@ -103,11 +107,11 @@ const char *poll_obj_string(poll_obj_type po_type) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-/*******************************************************************************
- * Fd Declarations
- */
+ /*******************************************************************************
+ * Fd Declarations
+ */
-#define FD_FROM_PO(po) ((grpc_fd *)(po))
+#define FD_FROM_PO(po) ((grpc_fd*)(po))
struct grpc_fd {
poll_obj po;
@@ -124,11 +128,11 @@ struct grpc_fd {
valid */
bool orphaned;
- gpr_atm read_closure;
- gpr_atm write_closure;
+ grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure;
+ grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure;
- struct grpc_fd *freelist_next;
- grpc_closure *on_done_closure;
+ struct grpc_fd* freelist_next;
+ grpc_closure* on_done_closure;
/* The pollset that last noticed that the fd is readable. The actual type
* stored in this is (grpc_pollset *) */
@@ -139,14 +143,14 @@ struct grpc_fd {
/* Reference counting for fds */
#ifndef NDEBUG
-static void fd_ref(grpc_fd *fd, const char *reason, const char *file, int line);
-static void fd_unref(grpc_fd *fd, const char *reason, const char *file,
+static void fd_ref(grpc_fd* fd, const char* reason, const char* file, int line);
+static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
int line);
#define GRPC_FD_REF(fd, reason) fd_ref(fd, reason, __FILE__, __LINE__)
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd, reason, __FILE__, __LINE__)
#else
-static void fd_ref(grpc_fd *fd);
-static void fd_unref(grpc_fd *fd);
+static void fd_ref(grpc_fd* fd);
+static void fd_unref(grpc_fd* fd);
#define GRPC_FD_REF(fd, reason) fd_ref(fd)
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd)
#endif
@@ -161,13 +165,12 @@ static void fd_global_shutdown(void);
#ifndef NDEBUG
#define PI_ADD_REF(p, r) pi_add_ref_dbg((p), (r), __FILE__, __LINE__)
-#define PI_UNREF(exec_ctx, p, r) \
- pi_unref_dbg((exec_ctx), (p), (r), __FILE__, __LINE__)
+#define PI_UNREF(p, r) pi_unref_dbg((p), (r), __FILE__, __LINE__)
#else
#define PI_ADD_REF(p, r) pi_add_ref((p))
-#define PI_UNREF(exec_ctx, p, r) pi_unref((exec_ctx), (p))
+#define PI_UNREF(p, r) pi_unref((p))
#endif
@@ -200,7 +203,7 @@ typedef struct polling_island {
/* The file descriptors in the epoll set */
size_t fd_cnt;
size_t fd_capacity;
- grpc_fd **fds;
+ grpc_fd** fds;
} polling_island;
/*******************************************************************************
@@ -212,8 +215,8 @@ struct grpc_pollset_worker {
/* Used to prevent a worker from getting kicked multiple times */
gpr_atm is_kicked;
- struct grpc_pollset_worker *next;
- struct grpc_pollset_worker *prev;
+ struct grpc_pollset_worker* next;
+ struct grpc_pollset_worker* prev;
};
struct grpc_pollset {
@@ -224,7 +227,7 @@ struct grpc_pollset {
bool shutting_down; /* Is the pollset shutting down ? */
bool finish_shutdown_called; /* Is the 'finish_shutdown_locked()' called ? */
- grpc_closure *shutdown_done; /* Called after after shutdown is complete */
+ grpc_closure* shutdown_done; /* Called after after shutdown is complete */
};
/*******************************************************************************
@@ -238,8 +241,8 @@ struct grpc_pollset_set {
* Common helpers
*/
-static bool append_error(grpc_error **composite, grpc_error *error,
- const char *desc) {
+static bool append_error(grpc_error** composite, grpc_error* error,
+ const char* desc) {
if (error == GRPC_ERROR_NONE) return true;
if (*composite == GRPC_ERROR_NONE) {
*composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
@@ -263,10 +266,10 @@ static grpc_wakeup_fd polling_island_wakeup_fd;
/* The polling island being polled right now.
See comments in workqueue_maybe_wakeup for why this is tracked. */
-static __thread polling_island *g_current_thread_polling_island;
+static __thread polling_island* g_current_thread_polling_island;
/* Forward declaration */
-static void polling_island_delete(grpc_exec_ctx *exec_ctx, polling_island *pi);
+static void polling_island_delete(polling_island* pi);
#ifdef GRPC_TSAN
/* Currently TSAN may incorrectly flag data races between epoll_ctl and
@@ -279,38 +282,40 @@ static void polling_island_delete(grpc_exec_ctx *exec_ctx, polling_island *pi);
gpr_atm g_epoll_sync;
#endif /* defined(GRPC_TSAN) */
-static void pi_add_ref(polling_island *pi);
-static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi);
+static void pi_add_ref(polling_island* pi);
+static void pi_unref(polling_island* pi);
#ifndef NDEBUG
-static void pi_add_ref_dbg(polling_island *pi, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+static void pi_add_ref_dbg(polling_island* pi, const char* reason,
+ const char* file, int line) {
+ if (grpc_polling_trace.enabled()) {
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
- gpr_log(GPR_DEBUG, "Add ref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
- " (%s) - (%s, %d)",
+ gpr_log(GPR_DEBUG,
+ "Add ref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
+ " (%s) - (%s, %d)",
pi, old_cnt, old_cnt + 1, reason, file, line);
}
pi_add_ref(pi);
}
-static void pi_unref_dbg(grpc_exec_ctx *exec_ctx, polling_island *pi,
- const char *reason, const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+static void pi_unref_dbg(polling_island* pi, const char* reason,
+ const char* file, int line) {
+ if (grpc_polling_trace.enabled()) {
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
- gpr_log(GPR_DEBUG, "Unref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
- " (%s) - (%s, %d)",
+ gpr_log(GPR_DEBUG,
+ "Unref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
+ " (%s) - (%s, %d)",
pi, old_cnt, (old_cnt - 1), reason, file, line);
}
- pi_unref(exec_ctx, pi);
+ pi_unref(pi);
}
#endif
-static void pi_add_ref(polling_island *pi) {
+static void pi_add_ref(polling_island* pi) {
gpr_atm_no_barrier_fetch_add(&pi->ref_count, 1);
}
-static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi) {
+static void pi_unref(polling_island* pi) {
/* If ref count went to zero, delete the polling island.
Note that this deletion not be done under a lock. Once the ref count goes
to zero, we are guaranteed that no one else holds a reference to the
@@ -320,23 +325,23 @@ static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi) {
non-empty, we should remove a ref to the merged_to polling island
*/
if (1 == gpr_atm_full_fetch_add(&pi->ref_count, -1)) {
- polling_island *next = (polling_island *)gpr_atm_acq_load(&pi->merged_to);
- polling_island_delete(exec_ctx, pi);
- if (next != NULL) {
- PI_UNREF(exec_ctx, next, "pi_delete"); /* Recursive call */
+ polling_island* next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
+ polling_island_delete(pi);
+ if (next != nullptr) {
+ PI_UNREF(next, "pi_delete"); /* Recursive call */
}
}
}
/* The caller is expected to hold pi->mu lock before calling this function */
-static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
+static void polling_island_add_fds_locked(polling_island* pi, grpc_fd** fds,
size_t fd_count, bool add_fd_refs,
- grpc_error **error) {
+ grpc_error** error) {
int err;
size_t i;
struct epoll_event ev;
- char *err_msg;
- const char *err_desc = "polling_island_add_fds";
+ char* err_msg;
+ const char* err_desc = "polling_island_add_fds";
#ifdef GRPC_TSAN
/* See the definition of g_epoll_sync for more context */
@@ -364,7 +369,7 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
if (pi->fd_cnt == pi->fd_capacity) {
pi->fd_capacity = GPR_MAX(pi->fd_capacity + 8, pi->fd_cnt * 3 / 2);
pi->fds =
- (grpc_fd **)gpr_realloc(pi->fds, sizeof(grpc_fd *) * pi->fd_capacity);
+ (grpc_fd**)gpr_realloc(pi->fds, sizeof(grpc_fd*) * pi->fd_capacity);
}
pi->fds[pi->fd_cnt++] = fds[i];
@@ -375,13 +380,13 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
}
/* The caller is expected to hold pi->mu before calling this */
-static void polling_island_add_wakeup_fd_locked(polling_island *pi,
- grpc_wakeup_fd *wakeup_fd,
- grpc_error **error) {
+static void polling_island_add_wakeup_fd_locked(polling_island* pi,
+ grpc_wakeup_fd* wakeup_fd,
+ grpc_error** error) {
struct epoll_event ev;
int err;
- char *err_msg;
- const char *err_desc = "polling_island_add_wakeup_fd";
+ char* err_msg;
+ const char* err_desc = "polling_island_add_wakeup_fd";
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
ev.data.ptr = wakeup_fd;
@@ -399,16 +404,16 @@ static void polling_island_add_wakeup_fd_locked(polling_island *pi,
}
/* The caller is expected to hold pi->mu lock before calling this function */
-static void polling_island_remove_all_fds_locked(polling_island *pi,
+static void polling_island_remove_all_fds_locked(polling_island* pi,
bool remove_fd_refs,
- grpc_error **error) {
+ grpc_error** error) {
int err;
size_t i;
- char *err_msg;
- const char *err_desc = "polling_island_remove_fds";
+ char* err_msg;
+ const char* err_desc = "polling_island_remove_fds";
for (i = 0; i < pi->fd_cnt; i++) {
- err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, pi->fds[i]->fd, NULL);
+ err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, pi->fds[i]->fd, nullptr);
if (err < 0 && errno != ENOENT) {
gpr_asprintf(&err_msg,
"epoll_ctl (epoll_fd: %d) delete fds[%zu]: %d failed with "
@@ -427,18 +432,18 @@ static void polling_island_remove_all_fds_locked(polling_island *pi,
}
/* The caller is expected to hold pi->mu lock before calling this function */
-static void polling_island_remove_fd_locked(polling_island *pi, grpc_fd *fd,
+static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd,
bool is_fd_closed,
- grpc_error **error) {
+ grpc_error** error) {
int err;
size_t i;
- char *err_msg;
- const char *err_desc = "polling_island_remove_fd";
+ char* err_msg;
+ const char* err_desc = "polling_island_remove_fd";
/* If fd is already closed, then it would have been automatically been removed
from the epoll set */
if (!is_fd_closed) {
- err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, NULL);
+ err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, nullptr);
if (err < 0 && errno != ENOENT) {
gpr_asprintf(
&err_msg,
@@ -459,24 +464,23 @@ static void polling_island_remove_fd_locked(polling_island *pi, grpc_fd *fd,
}
/* Might return NULL in case of an error */
-static polling_island *polling_island_create(grpc_exec_ctx *exec_ctx,
- grpc_fd *initial_fd,
- grpc_error **error) {
- polling_island *pi = NULL;
- const char *err_desc = "polling_island_create";
+static polling_island* polling_island_create(grpc_fd* initial_fd,
+ grpc_error** error) {
+ polling_island* pi = nullptr;
+ const char* err_desc = "polling_island_create";
*error = GRPC_ERROR_NONE;
- pi = (polling_island *)gpr_malloc(sizeof(*pi));
+ pi = (polling_island*)gpr_malloc(sizeof(*pi));
gpr_mu_init(&pi->mu);
pi->fd_cnt = 0;
pi->fd_capacity = 0;
- pi->fds = NULL;
+ pi->fds = nullptr;
pi->epoll_fd = -1;
gpr_atm_rel_store(&pi->ref_count, 0);
gpr_atm_rel_store(&pi->poller_count, 0);
- gpr_atm_rel_store(&pi->merged_to, (gpr_atm)NULL);
+ gpr_atm_rel_store(&pi->merged_to, (gpr_atm) nullptr);
pi->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
@@ -485,19 +489,19 @@ static polling_island *polling_island_create(grpc_exec_ctx *exec_ctx,
goto done;
}
- if (initial_fd != NULL) {
+ if (initial_fd != nullptr) {
polling_island_add_fds_locked(pi, &initial_fd, 1, true, error);
}
done:
if (*error != GRPC_ERROR_NONE) {
- polling_island_delete(exec_ctx, pi);
- pi = NULL;
+ polling_island_delete(pi);
+ pi = nullptr;
}
return pi;
}
-static void polling_island_delete(grpc_exec_ctx *exec_ctx, polling_island *pi) {
+static void polling_island_delete(polling_island* pi) {
GPR_ASSERT(pi->fd_cnt == 0);
if (pi->epoll_fd >= 0) {
@@ -511,11 +515,11 @@ static void polling_island_delete(grpc_exec_ctx *exec_ctx, polling_island *pi) {
/* Attempts to gets the last polling island in the linked list (liked by the
* 'merged_to' field). Since this does not lock the polling island, there are no
* guarantees that the island returned is the last island */
-static polling_island *polling_island_maybe_get_latest(polling_island *pi) {
- polling_island *next = (polling_island *)gpr_atm_acq_load(&pi->merged_to);
- while (next != NULL) {
+static polling_island* polling_island_maybe_get_latest(polling_island* pi) {
+ polling_island* next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
+ while (next != nullptr) {
pi = next;
- next = (polling_island *)gpr_atm_acq_load(&pi->merged_to);
+ next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
}
return pi;
@@ -530,19 +534,19 @@ static polling_island *polling_island_maybe_get_latest(polling_island *pi) {
... critical section ..
...
gpr_mu_unlock(&pi_latest->mu); // NOTE: use pi_latest->mu. NOT pi->mu */
-static polling_island *polling_island_lock(polling_island *pi) {
- polling_island *next = NULL;
+static polling_island* polling_island_lock(polling_island* pi) {
+ polling_island* next = nullptr;
while (true) {
- next = (polling_island *)gpr_atm_acq_load(&pi->merged_to);
- if (next == NULL) {
+ next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
+ if (next == nullptr) {
/* Looks like 'pi' is the last node in the linked list but unless we check
this by holding the pi->mu lock, we cannot be sure (i.e without the
pi->mu lock, we don't prevent island merges).
To be absolutely sure, check once more by holding the pi->mu lock */
gpr_mu_lock(&pi->mu);
- next = (polling_island *)gpr_atm_acq_load(&pi->merged_to);
- if (next == NULL) {
+ next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
+ if (next == nullptr) {
/* pi is infact the last node and we have the pi->mu lock. we're done */
break;
}
@@ -579,11 +583,11 @@ static polling_island *polling_island_lock(polling_island *pi) {
// Release locks: Always call polling_island_unlock_pair() to release locks
polling_island_unlock_pair(p1, p2);
*/
-static void polling_island_lock_pair(polling_island **p, polling_island **q) {
- polling_island *pi_1 = *p;
- polling_island *pi_2 = *q;
- polling_island *next_1 = NULL;
- polling_island *next_2 = NULL;
+static void polling_island_lock_pair(polling_island** p, polling_island** q) {
+ polling_island* pi_1 = *p;
+ polling_island* pi_2 = *q;
+ polling_island* next_1 = nullptr;
+ polling_island* next_2 = nullptr;
/* The algorithm is simple:
- Go to the last polling islands in the linked lists *pi_1 and *pi_2 (and
@@ -600,16 +604,16 @@ static void polling_island_lock_pair(polling_island **p, polling_island **q) {
- If the polling islands are the last islands, we are done. If not,
release the locks and continue the process from the first step */
while (true) {
- next_1 = (polling_island *)gpr_atm_acq_load(&pi_1->merged_to);
- while (next_1 != NULL) {
+ next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to);
+ while (next_1 != nullptr) {
pi_1 = next_1;
- next_1 = (polling_island *)gpr_atm_acq_load(&pi_1->merged_to);
+ next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to);
}
- next_2 = (polling_island *)gpr_atm_acq_load(&pi_2->merged_to);
- while (next_2 != NULL) {
+ next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
+ while (next_2 != nullptr) {
pi_2 = next_2;
- next_2 = (polling_island *)gpr_atm_acq_load(&pi_2->merged_to);
+ next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
}
if (pi_1 == pi_2) {
@@ -625,9 +629,9 @@ static void polling_island_lock_pair(polling_island **p, polling_island **q) {
gpr_mu_lock(&pi_1->mu);
}
- next_1 = (polling_island *)gpr_atm_acq_load(&pi_1->merged_to);
- next_2 = (polling_island *)gpr_atm_acq_load(&pi_2->merged_to);
- if (next_1 == NULL && next_2 == NULL) {
+ next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to);
+ next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
+ if (next_1 == nullptr && next_2 == nullptr) {
break;
}
@@ -639,7 +643,7 @@ static void polling_island_lock_pair(polling_island **p, polling_island **q) {
*q = pi_2;
}
-static void polling_island_unlock_pair(polling_island *p, polling_island *q) {
+static void polling_island_unlock_pair(polling_island* p, polling_island* q) {
if (p == q) {
gpr_mu_unlock(&p->mu);
} else {
@@ -648,16 +652,16 @@ static void polling_island_unlock_pair(polling_island *p, polling_island *q) {
}
}
-static polling_island *polling_island_merge(polling_island *p,
- polling_island *q,
- grpc_error **error) {
+static polling_island* polling_island_merge(polling_island* p,
+ polling_island* q,
+ grpc_error** error) {
/* Get locks on both the polling islands */
polling_island_lock_pair(&p, &q);
if (p != q) {
/* Make sure that p points to the polling island with fewer fds than q */
if (p->fd_cnt > q->fd_cnt) {
- GPR_SWAP(polling_island *, p, q);
+ GPR_SWAP(polling_island*, p, q);
}
/* Merge p with q i.e move all the fds from p (The one with fewer fds) to q
@@ -682,8 +686,8 @@ static polling_island *polling_island_merge(polling_island *p,
return q;
}
-static grpc_error *polling_island_global_init() {
- grpc_error *error = GRPC_ERROR_NONE;
+static grpc_error* polling_island_global_init() {
+ grpc_error* error = GRPC_ERROR_NONE;
error = grpc_wakeup_fd_init(&polling_island_wakeup_fd);
if (error == GRPC_ERROR_NONE) {
@@ -719,15 +723,15 @@ static void polling_island_global_shutdown() {
* alarm 'epoch'). This wakeup_fd gives us something to alert on when such a
* case occurs. */
-static grpc_fd *fd_freelist = NULL;
+static grpc_fd* fd_freelist = nullptr;
static gpr_mu fd_freelist_mu;
#ifndef NDEBUG
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
-static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
+static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file,
int line) {
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
+ if (grpc_trace_fd_refcount.enabled()) {
gpr_log(GPR_DEBUG,
"FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
@@ -736,22 +740,22 @@ static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
#else
#define REF_BY(fd, n, reason) ref_by(fd, n)
#define UNREF_BY(fd, n, reason) unref_by(fd, n)
-static void ref_by(grpc_fd *fd, int n) {
+static void ref_by(grpc_fd* fd, int n) {
#endif
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
}
#ifndef NDEBUG
-static void unref_by(grpc_fd *fd, int n, const char *reason, const char *file,
+static void unref_by(grpc_fd* fd, int n, const char* reason, const char* file,
int line) {
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
+ if (grpc_trace_fd_refcount.enabled()) {
gpr_log(GPR_DEBUG,
"FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
}
#else
-static void unref_by(grpc_fd *fd, int n) {
+static void unref_by(grpc_fd* fd, int n) {
#endif
gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
if (old == n) {
@@ -761,8 +765,8 @@ static void unref_by(grpc_fd *fd, int n) {
fd_freelist = fd;
grpc_iomgr_unregister_object(&fd->iomgr_object);
- grpc_lfev_destroy(&fd->read_closure);
- grpc_lfev_destroy(&fd->write_closure);
+ fd->read_closure->DestroyEvent();
+ fd->write_closure->DestroyEvent();
gpr_mu_unlock(&fd_freelist_mu);
} else {
@@ -772,18 +776,18 @@ static void unref_by(grpc_fd *fd, int n) {
/* Increment refcount by two to avoid changing the orphan bit */
#ifndef NDEBUG
-static void fd_ref(grpc_fd *fd, const char *reason, const char *file,
+static void fd_ref(grpc_fd* fd, const char* reason, const char* file,
int line) {
ref_by(fd, 2, reason, file, line);
}
-static void fd_unref(grpc_fd *fd, const char *reason, const char *file,
+static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
int line) {
unref_by(fd, 2, reason, file, line);
}
#else
-static void fd_ref(grpc_fd *fd) { ref_by(fd, 2); }
-static void fd_unref(grpc_fd *fd) { unref_by(fd, 2); }
+static void fd_ref(grpc_fd* fd) { ref_by(fd, 2); }
+static void fd_unref(grpc_fd* fd) { unref_by(fd, 2); }
#endif
static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
@@ -791,8 +795,8 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
static void fd_global_shutdown(void) {
gpr_mu_lock(&fd_freelist_mu);
gpr_mu_unlock(&fd_freelist_mu);
- while (fd_freelist != NULL) {
- grpc_fd *fd = fd_freelist;
+ while (fd_freelist != nullptr) {
+ grpc_fd* fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
gpr_mu_destroy(&fd->po.mu);
gpr_free(fd);
@@ -800,26 +804,28 @@ static void fd_global_shutdown(void) {
gpr_mu_destroy(&fd_freelist_mu);
}
-static grpc_fd *fd_create(int fd, const char *name) {
- grpc_fd *new_fd = NULL;
+static grpc_fd* fd_create(int fd, const char* name) {
+ grpc_fd* new_fd = nullptr;
gpr_mu_lock(&fd_freelist_mu);
- if (fd_freelist != NULL) {
+ if (fd_freelist != nullptr) {
new_fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
}
gpr_mu_unlock(&fd_freelist_mu);
- if (new_fd == NULL) {
- new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
+ if (new_fd == nullptr) {
+ new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
gpr_mu_init(&new_fd->po.mu);
+ new_fd->read_closure.Init();
+ new_fd->write_closure.Init();
}
/* Note: It is not really needed to get the new_fd->po.mu lock here. If this
* is a newly created fd (or an fd we got from the freelist), no one else
* would be holding a lock to it anyway. */
gpr_mu_lock(&new_fd->po.mu);
- new_fd->po.pi = NULL;
+ new_fd->po.pi = nullptr;
#ifndef NDEBUG
new_fd->po.obj_type = POLL_OBJ_FD;
#endif
@@ -827,23 +833,23 @@ static grpc_fd *fd_create(int fd, const char *name) {
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
new_fd->fd = fd;
new_fd->orphaned = false;
- grpc_lfev_init(&new_fd->read_closure);
- grpc_lfev_init(&new_fd->write_closure);
+ new_fd->read_closure->InitEvent();
+ new_fd->write_closure->InitEvent();
gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
- new_fd->freelist_next = NULL;
- new_fd->on_done_closure = NULL;
+ new_fd->freelist_next = nullptr;
+ new_fd->on_done_closure = nullptr;
gpr_mu_unlock(&new_fd->po.mu);
- char *fd_name;
+ char* fd_name;
gpr_asprintf(&fd_name, "%s fd=%d", name, fd);
grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name);
gpr_free(fd_name);
return new_fd;
}
-static int fd_wrapped_fd(grpc_fd *fd) {
+static int fd_wrapped_fd(grpc_fd* fd) {
int ret_fd = -1;
gpr_mu_lock(&fd->po.mu);
if (!fd->orphaned) {
@@ -854,11 +860,10 @@ static int fd_wrapped_fd(grpc_fd *fd) {
return ret_fd;
}
-static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *on_done, int *release_fd,
- bool already_closed, const char *reason) {
- grpc_error *error = GRPC_ERROR_NONE;
- polling_island *unref_pi = NULL;
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ polling_island* unref_pi = nullptr;
gpr_mu_lock(&fd->po.mu);
fd->on_done_closure = on_done;
@@ -875,18 +880,18 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- Unlock the latest polling island
- Set fd->po.pi to NULL (but remove the ref on the polling island
before doing this.) */
- if (fd->po.pi != NULL) {
- polling_island *pi_latest = polling_island_lock(fd->po.pi);
+ if (fd->po.pi != nullptr) {
+ polling_island* pi_latest = polling_island_lock(fd->po.pi);
polling_island_remove_fd_locked(pi_latest, fd, already_closed, &error);
gpr_mu_unlock(&pi_latest->mu);
unref_pi = fd->po.pi;
- fd->po.pi = NULL;
+ fd->po.pi = nullptr;
}
/* If release_fd is not NULL, we should be relinquishing control of the file
descriptor fd->fd (but we still own the grpc_fd structure). */
- if (release_fd != NULL) {
+ if (release_fd != nullptr) {
*release_fd = fd->fd;
} else {
close(fd->fd);
@@ -894,52 +899,48 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
fd->orphaned = true;
- GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(fd->on_done_closure, GRPC_ERROR_REF(error));
gpr_mu_unlock(&fd->po.mu);
UNREF_BY(fd, 2, reason); /* Drop the reference */
- if (unref_pi != NULL) {
+ if (unref_pi != nullptr) {
/* Unref stale polling island here, outside the fd lock above.
The polling island owns a workqueue which owns an fd, and unreffing
inside the lock can cause an eventual lock loop that makes TSAN very
unhappy. */
- PI_UNREF(exec_ctx, unref_pi, "fd_orphan");
+ PI_UNREF(unref_pi, "fd_orphan");
}
if (error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "fd_orphan: %s", msg);
}
GRPC_ERROR_UNREF(error);
}
-static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd) {
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
- return (grpc_pollset *)notifier;
+ return (grpc_pollset*)notifier;
}
-static bool fd_is_shutdown(grpc_fd *fd) {
- return grpc_lfev_is_shutdown(&fd->read_closure);
+static bool fd_is_shutdown(grpc_fd* fd) {
+ return fd->read_closure->IsShutdown();
}
/* Might be called multiple times */
-static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
- if (grpc_lfev_set_shutdown(exec_ctx, &fd->read_closure,
- GRPC_ERROR_REF(why))) {
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) {
shutdown(fd->fd, SHUT_RDWR);
- grpc_lfev_set_shutdown(exec_ctx, &fd->write_closure, GRPC_ERROR_REF(why));
+ fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));
}
GRPC_ERROR_UNREF(why);
}
-static void fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- grpc_lfev_notify_on(exec_ctx, &fd->read_closure, closure, "read");
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ fd->read_closure->NotifyOn(closure);
}
-static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- grpc_lfev_notify_on(exec_ctx, &fd->write_closure, closure, "write");
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ fd->write_closure->NotifyOn(closure);
}
/*******************************************************************************
@@ -959,7 +960,7 @@ static void sig_handler(int sig_num) {
static void poller_kick_init() { signal(grpc_wakeup_signal, sig_handler); }
/* Global state management */
-static grpc_error *pollset_global_init(void) {
+static grpc_error* pollset_global_init(void) {
gpr_tls_init(&g_current_thread_pollset);
gpr_tls_init(&g_current_thread_worker);
poller_kick_init();
@@ -971,14 +972,14 @@ static void pollset_global_shutdown(void) {
gpr_tls_destroy(&g_current_thread_worker);
}
-static grpc_error *pollset_worker_kick(grpc_pollset_worker *worker) {
- grpc_error *err = GRPC_ERROR_NONE;
+static grpc_error* pollset_worker_kick(grpc_pollset_worker* worker) {
+ grpc_error* err = GRPC_ERROR_NONE;
/* Kick the worker only if it was not already kicked */
if (gpr_atm_no_barrier_cas(&worker->is_kicked, (gpr_atm)0, (gpr_atm)1)) {
GRPC_POLLING_TRACE(
"pollset_worker_kick: Kicking worker: %p (thread id: %ld)",
- (void *)worker, (long int)worker->pt_id);
+ (void*)worker, (long int)worker->pt_id);
int err_num = pthread_kill(worker->pt_id, grpc_wakeup_signal);
if (err_num != 0) {
err = GRPC_OS_ERROR(err_num, "pthread_kill");
@@ -989,46 +990,46 @@ static grpc_error *pollset_worker_kick(grpc_pollset_worker *worker) {
/* Return 1 if the pollset has active threads in pollset_work (pollset must
* be locked) */
-static int pollset_has_workers(grpc_pollset *p) {
+static int pollset_has_workers(grpc_pollset* p) {
return p->root_worker.next != &p->root_worker;
}
-static void remove_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
+static void remove_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
worker->prev->next = worker->next;
worker->next->prev = worker->prev;
}
-static grpc_pollset_worker *pop_front_worker(grpc_pollset *p) {
+static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) {
if (pollset_has_workers(p)) {
- grpc_pollset_worker *w = p->root_worker.next;
+ grpc_pollset_worker* w = p->root_worker.next;
remove_worker(p, w);
return w;
} else {
- return NULL;
+ return nullptr;
}
}
-static void push_back_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
+static void push_back_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
worker->next = &p->root_worker;
worker->prev = worker->next->prev;
worker->prev->next = worker->next->prev = worker;
}
-static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
+static void push_front_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
worker->prev = &p->root_worker;
worker->next = worker->prev->next;
worker->prev->next = worker->next->prev = worker;
}
/* p->mu must be held before calling this function */
-static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
- grpc_pollset_worker *specific_worker) {
+static grpc_error* pollset_kick(grpc_pollset* p,
+ grpc_pollset_worker* specific_worker) {
GPR_TIMER_BEGIN("pollset_kick", 0);
- grpc_error *error = GRPC_ERROR_NONE;
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
- const char *err_desc = "Kick Failure";
- grpc_pollset_worker *worker = specific_worker;
- if (worker != NULL) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ GRPC_STATS_INC_POLLSET_KICK();
+ const char* err_desc = "Kick Failure";
+ grpc_pollset_worker* worker = specific_worker;
+ if (worker != nullptr) {
if (worker == GRPC_POLLSET_KICK_BROADCAST) {
if (pollset_has_workers(p)) {
GPR_TIMER_BEGIN("pollset_kick.broadcast", 0);
@@ -1058,7 +1059,7 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
GPR_TIMER_MARK("kick_anonymous", 0);
worker = pop_front_worker(p);
- if (worker != NULL) {
+ if (worker != nullptr) {
GPR_TIMER_MARK("finally_kick", 0);
push_back_worker(p, worker);
append_error(&error, pollset_worker_kick(worker), err_desc);
@@ -1073,10 +1074,10 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
return error;
}
-static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
+static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
gpr_mu_init(&pollset->po.mu);
*mu = &pollset->po.mu;
- pollset->po.pi = NULL;
+ pollset->po.pi = nullptr;
#ifndef NDEBUG
pollset->po.obj_type = POLL_OBJ_POLLSET;
#endif
@@ -1086,38 +1087,22 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
pollset->shutting_down = false;
pollset->finish_shutdown_called = false;
- pollset->shutdown_done = NULL;
-}
-
-/* Convert a timespec to milliseconds:
- - Very small or negative poll times are clamped to zero to do a non-blocking
- poll (which becomes spin polling)
- - Other small values are rounded up to one millisecond
- - Longer than a millisecond polls are rounded up to the next nearest
- millisecond to avoid spinning
- - Infinite timeouts are converted to -1 */
-static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
- gpr_timespec now) {
- gpr_timespec timeout;
- static const int64_t max_spin_polling_us = 10;
- if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
- return -1;
- }
+ pollset->shutdown_done = nullptr;
+}
- if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros(
- max_spin_polling_us,
- GPR_TIMESPAN))) <= 0) {
+static int poll_deadline_to_millis_timeout(grpc_millis millis) {
+ if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
+ grpc_millis delta = millis - grpc_core::ExecCtx::Get()->Now();
+ if (delta > INT_MAX)
+ return INT_MAX;
+ else if (delta < 0)
return 0;
- }
- timeout = gpr_time_sub(deadline, now);
- int millis = gpr_time_to_millis(gpr_time_add(
- timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
- return millis >= 1 ? millis : 1;
+ else
+ return (int)delta;
}
-static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_pollset *notifier) {
- grpc_lfev_set_ready(exec_ctx, &fd->read_closure, "read");
+static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
+ fd->read_closure->SetReady();
/* Note, it is possible that fd_become_readable might be called twice with
different 'notifier's when an fd becomes readable and it is in two epoll
@@ -1128,39 +1113,34 @@ static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
}
-static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
- grpc_lfev_set_ready(exec_ctx, &fd->write_closure, "write");
-}
+static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
-static void pollset_release_polling_island(grpc_exec_ctx *exec_ctx,
- grpc_pollset *ps,
- const char *reason) {
- if (ps->po.pi != NULL) {
- PI_UNREF(exec_ctx, ps->po.pi, reason);
+static void pollset_release_polling_island(grpc_pollset* ps,
+ const char* reason) {
+ if (ps->po.pi != nullptr) {
+ PI_UNREF(ps->po.pi, reason);
}
- ps->po.pi = NULL;
+ ps->po.pi = nullptr;
}
-static void finish_shutdown_locked(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset) {
+static void finish_shutdown_locked(grpc_pollset* pollset) {
/* The pollset cannot have any workers if we are at this stage */
GPR_ASSERT(!pollset_has_workers(pollset));
pollset->finish_shutdown_called = true;
/* Release the ref and set pollset->po.pi to NULL */
- pollset_release_polling_island(exec_ctx, pollset, "ps_shutdown");
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_done, GRPC_ERROR_NONE);
+ pollset_release_polling_island(pollset, "ps_shutdown");
+ GRPC_CLOSURE_SCHED(pollset->shutdown_done, GRPC_ERROR_NONE);
}
/* pollset->po.mu lock must be held by the caller before calling this */
-static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_TIMER_BEGIN("pollset_shutdown", 0);
GPR_ASSERT(!pollset->shutting_down);
pollset->shutting_down = true;
pollset->shutdown_done = closure;
- pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
+ pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
/* If the pollset has any workers, we cannot call finish_shutdown_locked()
because it would release the underlying polling island. In such a case, we
@@ -1168,7 +1148,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (!pollset_has_workers(pollset)) {
GPR_ASSERT(!pollset->finish_shutdown_called);
GPR_TIMER_MARK("pollset_shutdown.finish_shutdown_locked", 0);
- finish_shutdown_locked(exec_ctx, pollset);
+ finish_shutdown_locked(pollset);
}
GPR_TIMER_END("pollset_shutdown", 0);
}
@@ -1176,23 +1156,22 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* pollset_shutdown is guaranteed to be called before pollset_destroy. So other
* than destroying the mutexes, there is nothing special that needs to be done
* here */
-static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
+static void pollset_destroy(grpc_pollset* pollset) {
GPR_ASSERT(!pollset_has_workers(pollset));
gpr_mu_destroy(&pollset->po.mu);
}
#define GRPC_EPOLL_MAX_EVENTS 100
/* Note: sig_mask contains the signal mask to use *during* epoll_wait() */
-static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset,
- grpc_pollset_worker *worker, int timeout_ms,
- sigset_t *sig_mask, grpc_error **error) {
+static void pollset_work_and_unlock(grpc_pollset* pollset,
+ grpc_pollset_worker* worker, int timeout_ms,
+ sigset_t* sig_mask, grpc_error** error) {
struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS];
int epoll_fd = -1;
int ep_rv;
- polling_island *pi = NULL;
- char *err_msg;
- const char *err_desc = "pollset_work_and_unlock";
+ polling_island* pi = nullptr;
+ char* err_msg;
+ const char* err_desc = "pollset_work_and_unlock";
GPR_TIMER_BEGIN("pollset_work_and_unlock", 0);
/* We need to get the epoll_fd to wait on. The epoll_fd is in inside the
@@ -1205,16 +1184,16 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
right-away from epoll_wait() and pick up the latest polling_island the next
this function (i.e pollset_work_and_unlock()) is called */
- if (pollset->po.pi == NULL) {
- pollset->po.pi = polling_island_create(exec_ctx, NULL, error);
- if (pollset->po.pi == NULL) {
+ if (pollset->po.pi == nullptr) {
+ pollset->po.pi = polling_island_create(nullptr, error);
+ if (pollset->po.pi == nullptr) {
GPR_TIMER_END("pollset_work_and_unlock", 0);
return; /* Fatal error. We cannot continue */
}
PI_ADD_REF(pollset->po.pi, "ps");
GRPC_POLLING_TRACE("pollset_work: pollset: %p created new pi: %p",
- (void *)pollset, (void *)pollset->po.pi);
+ (void*)pollset, (void*)pollset->po.pi);
}
pi = polling_island_maybe_get_latest(pollset->po.pi);
@@ -1226,7 +1205,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
/* Always do PI_ADD_REF before PI_UNREF because PI_UNREF may cause the
polling island to be deleted */
PI_ADD_REF(pi, "ps");
- PI_UNREF(exec_ctx, pollset->po.pi, "ps");
+ PI_UNREF(pollset->po.pi, "ps");
pollset->po.pi = pi;
}
@@ -1240,7 +1219,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
g_current_thread_polling_island = pi;
GRPC_SCHEDULING_START_BLOCKING_REGION;
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
ep_rv =
epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask);
GRPC_SCHEDULING_END_BLOCKING_REGION;
@@ -1254,7 +1233,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
/* We were interrupted. Save an interation by doing a zero timeout
epoll_wait to see if there are any other events of interest */
GRPC_POLLING_TRACE("pollset_work: pollset: %p, worker: %p received kick",
- (void *)pollset, (void *)worker);
+ (void*)pollset, (void*)worker);
ep_rv = epoll_wait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, 0);
}
}
@@ -1265,41 +1244,41 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
#endif /* defined(GRPC_TSAN) */
for (int i = 0; i < ep_rv; ++i) {
- void *data_ptr = ep_ev[i].data.ptr;
+ void* data_ptr = ep_ev[i].data.ptr;
if (data_ptr == &polling_island_wakeup_fd) {
GRPC_POLLING_TRACE(
"pollset_work: pollset: %p, worker: %p polling island (epoll_fd: "
"%d) got merged",
- (void *)pollset, (void *)worker, epoll_fd);
+ (void*)pollset, (void*)worker, epoll_fd);
/* This means that our polling island is merged with a different
island. We do not have to do anything here since the subsequent call
to the function pollset_work_and_unlock() will pick up the correct
epoll_fd */
} else {
- grpc_fd *fd = (grpc_fd *)data_ptr;
+ grpc_fd* fd = (grpc_fd*)data_ptr;
int cancel = ep_ev[i].events & (EPOLLERR | EPOLLHUP);
int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
int write_ev = ep_ev[i].events & EPOLLOUT;
if (read_ev || cancel) {
- fd_become_readable(exec_ctx, fd, pollset);
+ fd_become_readable(fd, pollset);
}
if (write_ev || cancel) {
- fd_become_writable(exec_ctx, fd);
+ fd_become_writable(fd);
}
}
}
- g_current_thread_polling_island = NULL;
+ g_current_thread_polling_island = nullptr;
gpr_atm_no_barrier_fetch_add(&pi->poller_count, -1);
- GPR_ASSERT(pi != NULL);
+ GPR_ASSERT(pi != nullptr);
/* Before leaving, release the extra ref we added to the polling island. It
is important to use "pi" here (i.e our old copy of pollset->po.pi
that we got before releasing the polling island lock). This is because
pollset->po.pi pointer might get udpated in other parts of the
code when there is an island merge while we are doing epoll_wait() above */
- PI_UNREF(exec_ctx, pi, "ps_work");
+ PI_UNREF(pi, "ps_work");
GPR_TIMER_END("pollset_work_and_unlock", 0);
}
@@ -1308,17 +1287,17 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
The function pollset_work() may temporarily release the lock (pollset->po.mu)
during the course of its execution but it will always re-acquire the lock and
ensure that it is held by the time the function returns */
-static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker_hdl,
- gpr_timespec now, gpr_timespec deadline) {
+static grpc_error* pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
GPR_TIMER_BEGIN("pollset_work", 0);
- grpc_error *error = GRPC_ERROR_NONE;
- int timeout_ms = poll_deadline_to_millis_timeout(deadline, now);
+ grpc_error* error = GRPC_ERROR_NONE;
+ int timeout_ms = poll_deadline_to_millis_timeout(deadline);
sigset_t new_mask;
grpc_pollset_worker worker;
- worker.next = worker.prev = NULL;
+ worker.next = worker.prev = nullptr;
worker.pt_id = pthread_self();
gpr_atm_no_barrier_store(&worker.is_kicked, (gpr_atm)0);
@@ -1371,9 +1350,9 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
push_front_worker(pollset, &worker); /* Add worker to pollset */
- pollset_work_and_unlock(exec_ctx, pollset, &worker, timeout_ms,
- &g_orig_sigmask, &error);
- grpc_exec_ctx_flush(exec_ctx);
+ pollset_work_and_unlock(pollset, &worker, timeout_ms, &g_orig_sigmask,
+ &error);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->po.mu);
@@ -1393,14 +1372,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (pollset->shutting_down && !pollset_has_workers(pollset) &&
!pollset->finish_shutdown_called) {
GPR_TIMER_MARK("pollset_work.finish_shutdown_locked", 0);
- finish_shutdown_locked(exec_ctx, pollset);
+ finish_shutdown_locked(pollset);
gpr_mu_unlock(&pollset->po.mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->po.mu);
}
- if (worker_hdl) *worker_hdl = NULL;
+ if (worker_hdl) *worker_hdl = nullptr;
gpr_tls_set(&g_current_thread_pollset, (intptr_t)0);
gpr_tls_set(&g_current_thread_worker, (intptr_t)0);
@@ -1411,9 +1390,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
return error;
}
-static void add_poll_object(grpc_exec_ctx *exec_ctx, poll_obj *bag,
- poll_obj_type bag_type, poll_obj *item,
- poll_obj_type item_type) {
+static void add_poll_object(poll_obj* bag, poll_obj_type bag_type,
+ poll_obj* item, poll_obj_type item_type) {
GPR_TIMER_BEGIN("add_poll_object", 0);
#ifndef NDEBUG
@@ -1421,8 +1399,8 @@ static void add_poll_object(grpc_exec_ctx *exec_ctx, poll_obj *bag,
GPR_ASSERT(bag->obj_type == bag_type);
#endif
- grpc_error *error = GRPC_ERROR_NONE;
- polling_island *pi_new = NULL;
+ grpc_error* error = GRPC_ERROR_NONE;
+ polling_island* pi_new = nullptr;
gpr_mu_lock(&bag->mu);
gpr_mu_lock(&item->mu);
@@ -1449,7 +1427,7 @@ retry:
if (item->pi == bag->pi) {
pi_new = item->pi;
- if (pi_new == NULL) {
+ if (pi_new == nullptr) {
/* GPR_ASSERT(item->pi == bag->pi == NULL) */
/* If we are adding an fd to a bag (i.e pollset or pollset_set), then
@@ -1463,18 +1441,18 @@ retry:
keeping TSAN happy outweigh any performance advantage we might have
by keeping the lock held. */
gpr_mu_unlock(&item->mu);
- pi_new = polling_island_create(exec_ctx, FD_FROM_PO(item), &error);
+ pi_new = polling_island_create(FD_FROM_PO(item), &error);
gpr_mu_lock(&item->mu);
/* Need to reverify any assumptions made between the initial lock and
getting to this branch: if they've changed, we need to throw away our
work and figure things out again. */
- if (item->pi != NULL) {
+ if (item->pi != nullptr) {
GRPC_POLLING_TRACE(
"add_poll_object: Raced creating new polling island. pi_new: %p "
"(fd: %d, %s: %p)",
- (void *)pi_new, FD_FROM_PO(item)->fd, poll_obj_string(bag_type),
- (void *)bag);
+ (void*)pi_new, FD_FROM_PO(item)->fd, poll_obj_string(bag_type),
+ (void*)bag);
/* No need to lock 'pi_new' here since this is a new polling island
and no one has a reference to it yet */
polling_island_remove_all_fds_locked(pi_new, true, &error);
@@ -1482,31 +1460,30 @@ retry:
/* Ref and unref so that the polling island gets deleted during unref
*/
PI_ADD_REF(pi_new, "dance_of_destruction");
- PI_UNREF(exec_ctx, pi_new, "dance_of_destruction");
+ PI_UNREF(pi_new, "dance_of_destruction");
goto retry;
}
} else {
- pi_new = polling_island_create(exec_ctx, NULL, &error);
+ pi_new = polling_island_create(nullptr, &error);
}
GRPC_POLLING_TRACE(
"add_poll_object: Created new polling island. pi_new: %p (%s: %p, "
"%s: %p)",
- (void *)pi_new, poll_obj_string(item_type), (void *)item,
- poll_obj_string(bag_type), (void *)bag);
+ (void*)pi_new, poll_obj_string(item_type), (void*)item,
+ poll_obj_string(bag_type), (void*)bag);
} else {
GRPC_POLLING_TRACE(
"add_poll_object: Same polling island. pi: %p (%s, %s)",
- (void *)pi_new, poll_obj_string(item_type),
- poll_obj_string(bag_type));
+ (void*)pi_new, poll_obj_string(item_type), poll_obj_string(bag_type));
}
- } else if (item->pi == NULL) {
+ } else if (item->pi == nullptr) {
/* GPR_ASSERT(bag->pi != NULL) */
/* Make pi_new point to latest pi*/
pi_new = polling_island_lock(bag->pi);
if (item_type == POLL_OBJ_FD) {
- grpc_fd *fd = FD_FROM_PO(item);
+ grpc_fd* fd = FD_FROM_PO(item);
polling_island_add_fds_locked(pi_new, &fd, 1, true, &error);
}
@@ -1514,9 +1491,9 @@ retry:
GRPC_POLLING_TRACE(
"add_poll_obj: item->pi was NULL. pi_new: %p (item(%s): %p, "
"bag(%s): %p)",
- (void *)pi_new, poll_obj_string(item_type), (void *)item,
- poll_obj_string(bag_type), (void *)bag);
- } else if (bag->pi == NULL) {
+ (void*)pi_new, poll_obj_string(item_type), (void*)item,
+ poll_obj_string(bag_type), (void*)bag);
+ } else if (bag->pi == nullptr) {
/* GPR_ASSERT(item->pi != NULL) */
/* Make pi_new to point to latest pi */
pi_new = polling_island_lock(item->pi);
@@ -1524,15 +1501,15 @@ retry:
GRPC_POLLING_TRACE(
"add_poll_obj: bag->pi was NULL. pi_new: %p (item(%s): %p, "
"bag(%s): %p)",
- (void *)pi_new, poll_obj_string(item_type), (void *)item,
- poll_obj_string(bag_type), (void *)bag);
+ (void*)pi_new, poll_obj_string(item_type), (void*)item,
+ poll_obj_string(bag_type), (void*)bag);
} else {
pi_new = polling_island_merge(item->pi, bag->pi, &error);
GRPC_POLLING_TRACE(
"add_poll_obj: polling islands merged. pi_new: %p (item(%s): %p, "
"bag(%s): %p)",
- (void *)pi_new, poll_obj_string(item_type), (void *)item,
- poll_obj_string(bag_type), (void *)bag);
+ (void*)pi_new, poll_obj_string(item_type), (void*)item,
+ poll_obj_string(bag_type), (void*)bag);
}
/* At this point, pi_new is the polling island that both item->pi and bag->pi
@@ -1540,16 +1517,16 @@ retry:
if (item->pi != pi_new) {
PI_ADD_REF(pi_new, poll_obj_string(item_type));
- if (item->pi != NULL) {
- PI_UNREF(exec_ctx, item->pi, poll_obj_string(item_type));
+ if (item->pi != nullptr) {
+ PI_UNREF(item->pi, poll_obj_string(item_type));
}
item->pi = pi_new;
}
if (bag->pi != pi_new) {
PI_ADD_REF(pi_new, poll_obj_string(bag_type));
- if (bag->pi != NULL) {
- PI_UNREF(exec_ctx, bag->pi, poll_obj_string(bag_type));
+ if (bag->pi != nullptr) {
+ PI_UNREF(bag->pi, poll_obj_string(bag_type));
}
bag->pi = pi_new;
}
@@ -1561,76 +1538,65 @@ retry:
GPR_TIMER_END("add_poll_object", 0);
}
-static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_fd *fd) {
- add_poll_object(exec_ctx, &pollset->po, POLL_OBJ_POLLSET, &fd->po,
- POLL_OBJ_FD);
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
+ add_poll_object(&pollset->po, POLL_OBJ_POLLSET, &fd->po, POLL_OBJ_FD);
}
/*******************************************************************************
* Pollset-set Definitions
*/
-static grpc_pollset_set *pollset_set_create(void) {
- grpc_pollset_set *pss = (grpc_pollset_set *)gpr_malloc(sizeof(*pss));
+static grpc_pollset_set* pollset_set_create(void) {
+ grpc_pollset_set* pss = (grpc_pollset_set*)gpr_malloc(sizeof(*pss));
gpr_mu_init(&pss->po.mu);
- pss->po.pi = NULL;
+ pss->po.pi = nullptr;
#ifndef NDEBUG
pss->po.obj_type = POLL_OBJ_POLLSET_SET;
#endif
return pss;
}
-static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss) {
+static void pollset_set_destroy(grpc_pollset_set* pss) {
gpr_mu_destroy(&pss->po.mu);
- if (pss->po.pi != NULL) {
- PI_UNREF(exec_ctx, pss->po.pi, "pss_destroy");
+ if (pss->po.pi != nullptr) {
+ PI_UNREF(pss->po.pi, "pss_destroy");
}
gpr_free(pss);
}
-static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
- grpc_fd *fd) {
- add_poll_object(exec_ctx, &pss->po, POLL_OBJ_POLLSET_SET, &fd->po,
- POLL_OBJ_FD);
+static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {
+ add_poll_object(&pss->po, POLL_OBJ_POLLSET_SET, &fd->po, POLL_OBJ_FD);
}
-static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
- grpc_fd *fd) {
+static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) {
/* Nothing to do */
}
-static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss, grpc_pollset *ps) {
- add_poll_object(exec_ctx, &pss->po, POLL_OBJ_POLLSET_SET, &ps->po,
- POLL_OBJ_POLLSET);
+static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
+ add_poll_object(&pss->po, POLL_OBJ_POLLSET_SET, &ps->po, POLL_OBJ_POLLSET);
}
-static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pss, grpc_pollset *ps) {
+static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
/* Nothing to do */
}
-static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
- add_poll_object(exec_ctx, &bag->po, POLL_OBJ_POLLSET_SET, &item->po,
+static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {
+ add_poll_object(&bag->po, POLL_OBJ_POLLSET_SET, &item->po,
POLL_OBJ_POLLSET_SET);
}
-static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {
/* Nothing to do */
}
/* Test helper functions
* */
-void *grpc_fd_get_polling_island(grpc_fd *fd) {
- polling_island *pi;
+void* grpc_fd_get_polling_island(grpc_fd* fd) {
+ polling_island* pi;
gpr_mu_lock(&fd->po.mu);
pi = fd->po.pi;
@@ -1639,8 +1605,8 @@ void *grpc_fd_get_polling_island(grpc_fd *fd) {
return pi;
}
-void *grpc_pollset_get_polling_island(grpc_pollset *ps) {
- polling_island *pi;
+void* grpc_pollset_get_polling_island(grpc_pollset* ps) {
+ polling_island* pi;
gpr_mu_lock(&ps->po.mu);
pi = ps->po.pi;
@@ -1649,9 +1615,9 @@ void *grpc_pollset_get_polling_island(grpc_pollset *ps) {
return pi;
}
-bool grpc_are_polling_islands_equal(void *p, void *q) {
- polling_island *p1 = (polling_island *)p;
- polling_island *p2 = (polling_island *)q;
+bool grpc_are_polling_islands_equal(void* p, void* q) {
+ polling_island* p1 = (polling_island*)p;
+ polling_island* p2 = (polling_island*)q;
/* Note: polling_island_lock_pair() may change p1 and p2 to point to the
latest polling islands in their respective linked lists */
@@ -1717,53 +1683,58 @@ static bool is_epoll_available() {
return true;
}
-const grpc_event_engine_vtable *grpc_init_epollsig_linux(
+const grpc_event_engine_vtable* grpc_init_epollsig_linux(
bool explicit_request) {
/* If use of signals is disabled, we cannot use epoll engine*/
if (is_grpc_wakeup_signal_initialized && grpc_wakeup_signal < 0) {
- return NULL;
+ gpr_log(GPR_ERROR, "Skipping epollsig because use of signals is disabled.");
+ return nullptr;
}
if (!grpc_has_wakeup_fd()) {
- return NULL;
+ gpr_log(GPR_ERROR, "Skipping epollsig because of no wakeup fd.");
+ return nullptr;
}
if (!is_epoll_available()) {
- return NULL;
+ gpr_log(GPR_ERROR, "Skipping epollsig because epoll is unavailable.");
+ return nullptr;
}
if (!is_grpc_wakeup_signal_initialized) {
if (explicit_request) {
grpc_use_signal(SIGRTMIN + 6);
} else {
- return NULL;
+ gpr_log(GPR_ERROR,
+ "Skipping epollsig because uninitialized wakeup signal.");
+ return nullptr;
}
}
fd_global_init();
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
- return NULL;
+ return nullptr;
}
if (!GRPC_LOG_IF_ERROR("polling_island_global_init",
polling_island_global_init())) {
- return NULL;
+ return nullptr;
}
return &vtable;
}
-#else /* defined(GRPC_LINUX_EPOLL) */
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
#if defined(GRPC_POSIX_SOCKET)
-#include "src/core/lib/iomgr/ev_posix.h"
-/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
- * NULL */
-const grpc_event_engine_vtable *grpc_init_epollsig_linux(
+#include "src/core/lib/iomgr/ev_epollsig_linux.h"
+/* If GRPC_LINUX_EPOLL_CREATE1 is not defined, it means
+ epoll_create1 is not available. Return NULL */
+const grpc_event_engine_vtable* grpc_init_epollsig_linux(
bool explicit_request) {
- return NULL;
+ return nullptr;
}
#endif /* defined(GRPC_POSIX_SOCKET) */
void grpc_use_signal(int signum) {}
-#endif /* !defined(GRPC_LINUX_EPOLL) */
+#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.h b/src/core/lib/iomgr/ev_epollsig_linux.h
index 88328682b3..48178d3713 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.h
+++ b/src/core/lib/iomgr/ev_epollsig_linux.h
@@ -22,12 +22,12 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
-const grpc_event_engine_vtable *grpc_init_epollsig_linux(bool explicit_request);
+const grpc_event_engine_vtable* grpc_init_epollsig_linux(bool explicit_request);
-#ifdef GRPC_LINUX_EPOLL
-void *grpc_fd_get_polling_island(grpc_fd *fd);
-void *grpc_pollset_get_polling_island(grpc_pollset *ps);
-bool grpc_are_polling_islands_equal(void *p, void *q);
-#endif /* defined(GRPC_LINUX_EPOLL) */
+#ifdef GRPC_LINUX_EPOLL_CREATE1
+void* grpc_fd_get_polling_island(grpc_fd* fd);
+void* grpc_pollset_get_polling_island(grpc_pollset* ps);
+bool grpc_are_polling_islands_equal(void* p, void* q);
+#endif /* defined(GRPC_LINUX_EPOLL_CREATE1) */
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.cc
index e170702dca..3b79728055 100644
--- a/src/core/lib/iomgr/ev_poll_posix.c
+++ b/src/core/lib/iomgr/ev_poll_posix.cc
@@ -24,6 +24,7 @@
#include <assert.h>
#include <errno.h>
+#include <limits.h>
#include <poll.h>
#include <string.h>
#include <sys/socket.h>
@@ -37,26 +38,24 @@
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/murmur_hash.h"
+#include "src/core/lib/iomgr/block_annotate.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
-#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/wakeup_fd_cv.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/murmur_hash.h"
-#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
+#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
/*******************************************************************************
* FD declarations
*/
-
typedef struct grpc_fd_watcher {
- struct grpc_fd_watcher *next;
- struct grpc_fd_watcher *prev;
- grpc_pollset *pollset;
- grpc_pollset_worker *worker;
- grpc_fd *fd;
+ struct grpc_fd_watcher* next;
+ struct grpc_fd_watcher* prev;
+ grpc_pollset* pollset;
+ grpc_pollset_worker* worker;
+ grpc_fd* fd;
} grpc_fd_watcher;
struct grpc_fd {
@@ -72,7 +71,8 @@ struct grpc_fd {
int shutdown;
int closed;
int released;
- grpc_error *shutdown_error;
+ gpr_atm pollhup;
+ grpc_error* shutdown_error;
/* The watcher list.
@@ -97,18 +97,18 @@ struct grpc_fd {
the inactive pollers may be kicked out of their poll loops to take
that responsibility. */
grpc_fd_watcher inactive_watcher_root;
- grpc_fd_watcher *read_watcher;
- grpc_fd_watcher *write_watcher;
+ grpc_fd_watcher* read_watcher;
+ grpc_fd_watcher* write_watcher;
- grpc_closure *read_closure;
- grpc_closure *write_closure;
+ grpc_closure* read_closure;
+ grpc_closure* write_closure;
- grpc_closure *on_done_closure;
+ grpc_closure* on_done_closure;
grpc_iomgr_object iomgr_object;
/* The pollset that last noticed and notified that the fd is readable */
- grpc_pollset *read_notifier_pollset;
+ grpc_pollset* read_notifier_pollset;
};
/* Begin polling on an fd.
@@ -122,35 +122,34 @@ struct grpc_fd {
Polling strategies that do not need to alter their behavior depending on the
fd's current interest (such as epoll) do not need to call this function.
MUST NOT be called with a pollset lock taken */
-static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- grpc_pollset_worker *worker, uint32_t read_mask,
- uint32_t write_mask, grpc_fd_watcher *rec);
+static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
+ grpc_pollset_worker* worker, uint32_t read_mask,
+ uint32_t write_mask, grpc_fd_watcher* rec);
/* Complete polling previously started with fd_begin_poll
MUST NOT be called with a pollset lock taken
if got_read or got_write are 1, also does the become_{readable,writable} as
appropriate. */
-static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *rec,
- int got_read, int got_write,
- grpc_pollset *read_notifier_pollset);
+static void fd_end_poll(grpc_fd_watcher* rec, int got_read, int got_write,
+ grpc_pollset* read_notifier_pollset);
/* Return 1 if this fd is orphaned, 0 otherwise */
-static bool fd_is_orphaned(grpc_fd *fd);
+static bool fd_is_orphaned(grpc_fd* fd);
#ifndef NDEBUG
-static void fd_ref(grpc_fd *fd, const char *reason, const char *file, int line);
-static void fd_unref(grpc_fd *fd, const char *reason, const char *file,
+static void fd_ref(grpc_fd* fd, const char* reason, const char* file, int line);
+static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
int line);
#define GRPC_FD_REF(fd, reason) fd_ref(fd, reason, __FILE__, __LINE__)
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd, reason, __FILE__, __LINE__)
#else
-static void fd_ref(grpc_fd *fd);
-static void fd_unref(grpc_fd *fd);
+static void fd_ref(grpc_fd* fd);
+static void fd_unref(grpc_fd* fd);
#define GRPC_FD_REF(fd, reason) fd_ref(fd)
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd)
#endif
-#define CLOSURE_NOT_READY ((grpc_closure *)0)
-#define CLOSURE_READY ((grpc_closure *)1)
+#define CLOSURE_NOT_READY ((grpc_closure*)0)
+#define CLOSURE_READY ((grpc_closure*)1)
/*******************************************************************************
* pollset declarations
@@ -158,15 +157,15 @@ static void fd_unref(grpc_fd *fd);
typedef struct grpc_cached_wakeup_fd {
grpc_wakeup_fd fd;
- struct grpc_cached_wakeup_fd *next;
+ struct grpc_cached_wakeup_fd* next;
} grpc_cached_wakeup_fd;
struct grpc_pollset_worker {
- grpc_cached_wakeup_fd *wakeup_fd;
+ grpc_cached_wakeup_fd* wakeup_fd;
int reevaluate_polling_on_wakeup;
int kicked_specifically;
- struct grpc_pollset_worker *next;
- struct grpc_pollset_worker *prev;
+ struct grpc_pollset_worker* next;
+ struct grpc_pollset_worker* prev;
};
struct grpc_pollset {
@@ -175,23 +174,21 @@ struct grpc_pollset {
int shutting_down;
int called_shutdown;
int kicked_without_pollers;
- grpc_closure *shutdown_done;
+ grpc_closure* shutdown_done;
grpc_closure_list idle_jobs;
int pollset_set_count;
/* all polled fds */
size_t fd_count;
size_t fd_capacity;
- grpc_fd **fds;
+ grpc_fd** fds;
/* Local cache of eventfds for workers */
- grpc_cached_wakeup_fd *local_wakeup_cache;
+ grpc_cached_wakeup_fd* local_wakeup_cache;
};
/* Add an fd to a pollset */
-static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- struct grpc_fd *fd);
+static void pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd);
-static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd);
+static void pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd);
/* Convert a timespec to milliseconds:
- very small or negative poll times are clamped to zero to do a
@@ -200,8 +197,7 @@ static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
- longer than a millisecond polls are rounded up to the next nearest
millisecond to avoid spinning
- infinite timeouts are converted to -1 */
-static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
- gpr_timespec now);
+static int poll_deadline_to_millis_timeout(grpc_millis deadline);
/* Allow kick to wakeup the currently polling worker */
#define GRPC_POLLSET_CAN_KICK_SELF 1
@@ -209,13 +205,13 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
#define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2
/* As per pollset_kick, with an extended set of flags (defined above)
-- mostly for fd_posix's use. */
-static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
- grpc_pollset_worker *specific_worker,
+static grpc_error* pollset_kick_ext(grpc_pollset* p,
+ grpc_pollset_worker* specific_worker,
uint32_t flags) GRPC_MUST_USE_RESULT;
/* Return 1 if the pollset has active threads in pollset_work (pollset must
* be locked) */
-static bool pollset_has_workers(grpc_pollset *pollset);
+static bool pollset_has_workers(grpc_pollset* pollset);
/*******************************************************************************
* pollset_set definitions
@@ -226,15 +222,15 @@ struct grpc_pollset_set {
size_t pollset_count;
size_t pollset_capacity;
- grpc_pollset **pollsets;
+ grpc_pollset** pollsets;
size_t pollset_set_count;
size_t pollset_set_capacity;
- struct grpc_pollset_set **pollset_sets;
+ struct grpc_pollset_set** pollset_sets;
size_t fd_count;
size_t fd_capacity;
- grpc_fd **fds;
+ grpc_fd** fds;
};
/*******************************************************************************
@@ -247,9 +243,9 @@ struct grpc_pollset_set {
typedef struct poll_result {
gpr_refcount refcount;
- cv_node *watchers;
+ grpc_cv_node* watchers;
int watchcount;
- struct pollfd *fds;
+ struct pollfd* fds;
nfds_t nfds;
int retval;
int err;
@@ -259,11 +255,11 @@ typedef struct poll_result {
typedef struct poll_args {
gpr_cv trigger;
int trigger_set;
- struct pollfd *fds;
+ struct pollfd* fds;
nfds_t nfds;
- poll_result *result;
- struct poll_args *next;
- struct poll_args *prev;
+ poll_result* result;
+ struct poll_args* next;
+ struct poll_args* prev;
} poll_args;
// This is a 2-tiered cache, we mantain a hash table
@@ -271,14 +267,14 @@ typedef struct poll_args {
// of that call. We also maintain a freelist of inactive
// poll threads.
typedef struct poll_hash_table {
- poll_args *free_pollers;
- poll_args **active_pollers;
+ poll_args* free_pollers;
+ poll_args** active_pollers;
unsigned int size;
unsigned int count;
} poll_hash_table;
poll_hash_table poll_cache;
-cv_fd_table g_cvfds;
+grpc_cv_fd_table g_cvfds;
/*******************************************************************************
* fd_posix.c
@@ -287,9 +283,9 @@ cv_fd_table g_cvfds;
#ifndef NDEBUG
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
-static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
+static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file,
int line) {
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
+ if (grpc_trace_fd_refcount.enabled()) {
gpr_log(GPR_DEBUG,
"FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
@@ -298,22 +294,22 @@ static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
#else
#define REF_BY(fd, n, reason) ref_by(fd, n)
#define UNREF_BY(fd, n, reason) unref_by(fd, n)
-static void ref_by(grpc_fd *fd, int n) {
+static void ref_by(grpc_fd* fd, int n) {
#endif
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
}
#ifndef NDEBUG
-static void unref_by(grpc_fd *fd, int n, const char *reason, const char *file,
+static void unref_by(grpc_fd* fd, int n, const char* reason, const char* file,
int line) {
- if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) {
+ if (grpc_trace_fd_refcount.enabled()) {
gpr_log(GPR_DEBUG,
"FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
}
#else
-static void unref_by(grpc_fd *fd, int n) {
+static void unref_by(grpc_fd* fd, int n) {
#endif
gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
if (old == n) {
@@ -326,8 +322,8 @@ static void unref_by(grpc_fd *fd, int n) {
}
}
-static grpc_fd *fd_create(int fd, const char *name) {
- grpc_fd *r = (grpc_fd *)gpr_malloc(sizeof(*r));
+static grpc_fd* fd_create(int fd, const char* name) {
+ grpc_fd* r = (grpc_fd*)gpr_malloc(sizeof(*r));
gpr_mu_init(&r->mu);
gpr_atm_rel_store(&r->refst, 1);
r->shutdown = 0;
@@ -336,27 +332,27 @@ static grpc_fd *fd_create(int fd, const char *name) {
r->fd = fd;
r->inactive_watcher_root.next = r->inactive_watcher_root.prev =
&r->inactive_watcher_root;
- r->read_watcher = r->write_watcher = NULL;
- r->on_done_closure = NULL;
+ r->read_watcher = r->write_watcher = nullptr;
+ r->on_done_closure = nullptr;
r->closed = 0;
r->released = 0;
- r->read_notifier_pollset = NULL;
+ gpr_atm_no_barrier_store(&r->pollhup, 0);
+ r->read_notifier_pollset = nullptr;
- char *name2;
+ char* name2;
gpr_asprintf(&name2, "%s fd=%d", name, fd);
grpc_iomgr_register_object(&r->iomgr_object, name2);
gpr_free(name2);
return r;
}
-static bool fd_is_orphaned(grpc_fd *fd) {
+static bool fd_is_orphaned(grpc_fd* fd) {
return (gpr_atm_acq_load(&fd->refst) & 1) == 0;
}
/* Return the read-notifier pollset */
-static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd) {
- grpc_pollset *notifier = NULL;
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
+ grpc_pollset* notifier = nullptr;
gpr_mu_lock(&fd->mu);
notifier = fd->read_notifier_pollset;
@@ -365,56 +361,53 @@ static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
return notifier;
}
-static grpc_error *pollset_kick_locked(grpc_exec_ctx *exec_ctx,
- grpc_fd_watcher *watcher) {
+static grpc_error* pollset_kick_locked(grpc_fd_watcher* watcher) {
gpr_mu_lock(&watcher->pollset->mu);
GPR_ASSERT(watcher->worker);
- grpc_error *err =
- pollset_kick_ext(exec_ctx, watcher->pollset, watcher->worker,
- GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
+ grpc_error* err = pollset_kick_ext(watcher->pollset, watcher->worker,
+ GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
gpr_mu_unlock(&watcher->pollset->mu);
return err;
}
-static void maybe_wake_one_watcher_locked(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd) {
+static void maybe_wake_one_watcher_locked(grpc_fd* fd) {
if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) {
- pollset_kick_locked(exec_ctx, fd->inactive_watcher_root.next);
+ pollset_kick_locked(fd->inactive_watcher_root.next);
} else if (fd->read_watcher) {
- pollset_kick_locked(exec_ctx, fd->read_watcher);
+ pollset_kick_locked(fd->read_watcher);
} else if (fd->write_watcher) {
- pollset_kick_locked(exec_ctx, fd->write_watcher);
+ pollset_kick_locked(fd->write_watcher);
}
}
-static void wake_all_watchers_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
- grpc_fd_watcher *watcher;
+static void wake_all_watchers_locked(grpc_fd* fd) {
+ grpc_fd_watcher* watcher;
for (watcher = fd->inactive_watcher_root.next;
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
- pollset_kick_locked(exec_ctx, watcher);
+ pollset_kick_locked(watcher);
}
if (fd->read_watcher) {
- pollset_kick_locked(exec_ctx, fd->read_watcher);
+ pollset_kick_locked(fd->read_watcher);
}
if (fd->write_watcher && fd->write_watcher != fd->read_watcher) {
- pollset_kick_locked(exec_ctx, fd->write_watcher);
+ pollset_kick_locked(fd->write_watcher);
}
}
-static int has_watchers(grpc_fd *fd) {
- return fd->read_watcher != NULL || fd->write_watcher != NULL ||
+static int has_watchers(grpc_fd* fd) {
+ return fd->read_watcher != nullptr || fd->write_watcher != nullptr ||
fd->inactive_watcher_root.next != &fd->inactive_watcher_root;
}
-static void close_fd_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
+static void close_fd_locked(grpc_fd* fd) {
fd->closed = 1;
if (!fd->released) {
close(fd->fd);
}
- GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fd->on_done_closure, GRPC_ERROR_NONE);
}
-static int fd_wrapped_fd(grpc_fd *fd) {
+static int fd_wrapped_fd(grpc_fd* fd) {
if (fd->released || fd->closed) {
return -1;
} else {
@@ -422,12 +415,11 @@ static int fd_wrapped_fd(grpc_fd *fd) {
}
}
-static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *on_done, int *release_fd,
- bool already_closed, const char *reason) {
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason) {
fd->on_done_closure = on_done;
- fd->released = release_fd != NULL;
- if (release_fd != NULL) {
+ fd->released = release_fd != nullptr;
+ if (release_fd != nullptr) {
*release_fd = fd->fd;
fd->released = true;
} else if (already_closed) {
@@ -436,9 +428,9 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
gpr_mu_lock(&fd->mu);
REF_BY(fd, 1, reason); /* remove active status, but keep referenced */
if (!has_watchers(fd)) {
- close_fd_locked(exec_ctx, fd);
+ close_fd_locked(fd);
} else {
- wake_all_watchers_locked(exec_ctx, fd);
+ wake_all_watchers_locked(fd);
}
gpr_mu_unlock(&fd->mu);
UNREF_BY(fd, 2, reason); /* drop the reference */
@@ -446,22 +438,22 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
/* increment refcount by two to avoid changing the orphan bit */
#ifndef NDEBUG
-static void fd_ref(grpc_fd *fd, const char *reason, const char *file,
+static void fd_ref(grpc_fd* fd, const char* reason, const char* file,
int line) {
ref_by(fd, 2, reason, file, line);
}
-static void fd_unref(grpc_fd *fd, const char *reason, const char *file,
+static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
int line) {
unref_by(fd, 2, reason, file, line);
}
#else
-static void fd_ref(grpc_fd *fd) { ref_by(fd, 2); }
+static void fd_ref(grpc_fd* fd) { ref_by(fd, 2); }
-static void fd_unref(grpc_fd *fd) { unref_by(fd, 2); }
+static void fd_unref(grpc_fd* fd) { unref_by(fd, 2); }
#endif
-static grpc_error *fd_shutdown_error(grpc_fd *fd) {
+static grpc_error* fd_shutdown_error(grpc_fd* fd) {
if (!fd->shutdown) {
return GRPC_ERROR_NONE;
} else {
@@ -470,10 +462,10 @@ static grpc_error *fd_shutdown_error(grpc_fd *fd) {
}
}
-static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure **st, grpc_closure *closure) {
- if (fd->shutdown) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure,
+static void notify_on_locked(grpc_fd* fd, grpc_closure** st,
+ grpc_closure* closure) {
+ if (fd->shutdown || gpr_atm_no_barrier_load(&fd->pollhup)) {
+ GRPC_CLOSURE_SCHED(closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("FD shutdown"));
} else if (*st == CLOSURE_NOT_READY) {
/* not ready ==> switch to a waiting state by setting the closure */
@@ -481,8 +473,8 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
} else if (*st == CLOSURE_READY) {
/* already ready ==> queue the closure to run immediately */
*st = CLOSURE_NOT_READY;
- GRPC_CLOSURE_SCHED(exec_ctx, closure, fd_shutdown_error(fd));
- maybe_wake_one_watcher_locked(exec_ctx, fd);
+ GRPC_CLOSURE_SCHED(closure, fd_shutdown_error(fd));
+ maybe_wake_one_watcher_locked(fd);
} else {
/* upcallptr was set to a different closure. This is an error! */
gpr_log(GPR_ERROR,
@@ -493,8 +485,7 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
}
/* returns 1 if state becomes not ready */
-static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure **st) {
+static int set_ready_locked(grpc_fd* fd, grpc_closure** st) {
if (*st == CLOSURE_READY) {
/* duplicate ready ==> ignore */
return 0;
@@ -504,18 +495,18 @@ static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
return 0;
} else {
/* waiting ==> queue closure */
- GRPC_CLOSURE_SCHED(exec_ctx, *st, fd_shutdown_error(fd));
+ GRPC_CLOSURE_SCHED(*st, fd_shutdown_error(fd));
*st = CLOSURE_NOT_READY;
return 1;
}
}
static void set_read_notifier_pollset_locked(
- grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_pollset *read_notifier_pollset) {
+ grpc_fd* fd, grpc_pollset* read_notifier_pollset) {
fd->read_notifier_pollset = read_notifier_pollset;
}
-static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
gpr_mu_lock(&fd->mu);
/* only shutdown once */
if (!fd->shutdown) {
@@ -523,40 +514,38 @@ static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
fd->shutdown_error = why;
/* signal read/write closed to OS so that future operations fail */
shutdown(fd->fd, SHUT_RDWR);
- set_ready_locked(exec_ctx, fd, &fd->read_closure);
- set_ready_locked(exec_ctx, fd, &fd->write_closure);
+ set_ready_locked(fd, &fd->read_closure);
+ set_ready_locked(fd, &fd->write_closure);
} else {
GRPC_ERROR_UNREF(why);
}
gpr_mu_unlock(&fd->mu);
}
-static bool fd_is_shutdown(grpc_fd *fd) {
+static bool fd_is_shutdown(grpc_fd* fd) {
gpr_mu_lock(&fd->mu);
bool r = fd->shutdown;
gpr_mu_unlock(&fd->mu);
return r;
}
-static void fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
gpr_mu_lock(&fd->mu);
- notify_on_locked(exec_ctx, fd, &fd->read_closure, closure);
+ notify_on_locked(fd, &fd->read_closure, closure);
gpr_mu_unlock(&fd->mu);
}
-static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
gpr_mu_lock(&fd->mu);
- notify_on_locked(exec_ctx, fd, &fd->write_closure, closure);
+ notify_on_locked(fd, &fd->write_closure, closure);
gpr_mu_unlock(&fd->mu);
}
-static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- grpc_pollset_worker *worker, uint32_t read_mask,
- uint32_t write_mask, grpc_fd_watcher *watcher) {
+static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
+ grpc_pollset_worker* worker, uint32_t read_mask,
+ uint32_t write_mask, grpc_fd_watcher* watcher) {
uint32_t mask = 0;
- grpc_closure *cur;
+ grpc_closure* cur;
int requested;
/* keep track of pollers that have requested our events, in case they change
*/
@@ -566,9 +555,9 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
/* if we are shutdown, then don't add to the watcher set */
if (fd->shutdown) {
- watcher->fd = NULL;
- watcher->pollset = NULL;
- watcher->worker = NULL;
+ watcher->fd = nullptr;
+ watcher->pollset = nullptr;
+ watcher->worker = nullptr;
gpr_mu_unlock(&fd->mu);
GRPC_FD_UNREF(fd, "poll");
return 0;
@@ -577,7 +566,7 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
/* if there is nobody polling for read, but we need to, then start doing so */
cur = fd->read_closure;
requested = cur != CLOSURE_READY;
- if (read_mask && fd->read_watcher == NULL && requested) {
+ if (read_mask && fd->read_watcher == nullptr && requested) {
fd->read_watcher = watcher;
mask |= read_mask;
}
@@ -585,12 +574,12 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
*/
cur = fd->write_closure;
requested = cur != CLOSURE_READY;
- if (write_mask && fd->write_watcher == NULL && requested) {
+ if (write_mask && fd->write_watcher == nullptr && requested) {
fd->write_watcher = watcher;
mask |= write_mask;
}
/* if not polling, remember this watcher in case we need someone to later */
- if (mask == 0 && worker != NULL) {
+ if (mask == 0 && worker != nullptr) {
watcher->next = &fd->inactive_watcher_root;
watcher->prev = watcher->next->prev;
watcher->next->prev = watcher->prev->next = watcher;
@@ -603,14 +592,13 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
return mask;
}
-static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
- int got_read, int got_write,
- grpc_pollset *read_notifier_pollset) {
+static void fd_end_poll(grpc_fd_watcher* watcher, int got_read, int got_write,
+ grpc_pollset* read_notifier_pollset) {
int was_polling = 0;
int kick = 0;
- grpc_fd *fd = watcher->fd;
+ grpc_fd* fd = watcher->fd;
- if (fd == NULL) {
+ if (fd == nullptr) {
return;
}
@@ -622,7 +610,7 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
if (!got_read) {
kick = 1;
}
- fd->read_watcher = NULL;
+ fd->read_watcher = nullptr;
}
if (watcher == fd->write_watcher) {
/* remove write watcher, kick if we still need a write */
@@ -630,31 +618,31 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
if (!got_write) {
kick = 1;
}
- fd->write_watcher = NULL;
+ fd->write_watcher = nullptr;
}
- if (!was_polling && watcher->worker != NULL) {
+ if (!was_polling && watcher->worker != nullptr) {
/* remove from inactive list */
watcher->next->prev = watcher->prev;
watcher->prev->next = watcher->next;
}
if (got_read) {
- if (set_ready_locked(exec_ctx, fd, &fd->read_closure)) {
+ if (set_ready_locked(fd, &fd->read_closure)) {
kick = 1;
}
- if (read_notifier_pollset != NULL) {
- set_read_notifier_pollset_locked(exec_ctx, fd, read_notifier_pollset);
+ if (read_notifier_pollset != nullptr) {
+ set_read_notifier_pollset_locked(fd, read_notifier_pollset);
}
}
if (got_write) {
- if (set_ready_locked(exec_ctx, fd, &fd->write_closure)) {
+ if (set_ready_locked(fd, &fd->write_closure)) {
kick = 1;
}
}
if (kick) {
- maybe_wake_one_watcher_locked(exec_ctx, fd);
+ maybe_wake_one_watcher_locked(fd);
}
if (fd_is_orphaned(fd) && !has_watchers(fd) && !fd->closed) {
- close_fd_locked(exec_ctx, fd);
+ close_fd_locked(fd);
}
gpr_mu_unlock(&fd->mu);
@@ -668,46 +656,46 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
GPR_TLS_DECL(g_current_thread_poller);
GPR_TLS_DECL(g_current_thread_worker);
-static void remove_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
+static void remove_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
worker->prev->next = worker->next;
worker->next->prev = worker->prev;
}
-static bool pollset_has_workers(grpc_pollset *p) {
+static bool pollset_has_workers(grpc_pollset* p) {
return p->root_worker.next != &p->root_worker;
}
-static bool pollset_in_pollset_sets(grpc_pollset *p) {
+static bool pollset_in_pollset_sets(grpc_pollset* p) {
return p->pollset_set_count;
}
-static bool pollset_has_observers(grpc_pollset *p) {
+static bool pollset_has_observers(grpc_pollset* p) {
return pollset_has_workers(p) || pollset_in_pollset_sets(p);
}
-static grpc_pollset_worker *pop_front_worker(grpc_pollset *p) {
+static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) {
if (pollset_has_workers(p)) {
- grpc_pollset_worker *w = p->root_worker.next;
+ grpc_pollset_worker* w = p->root_worker.next;
remove_worker(p, w);
return w;
} else {
- return NULL;
+ return nullptr;
}
}
-static void push_back_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
+static void push_back_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
worker->next = &p->root_worker;
worker->prev = worker->next->prev;
worker->prev->next = worker->next->prev = worker;
}
-static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
+static void push_front_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
worker->prev = &p->root_worker;
worker->next = worker->prev->next;
worker->prev->next = worker->next->prev = worker;
}
-static void kick_append_error(grpc_error **composite, grpc_error *error) {
+static void kick_append_error(grpc_error** composite, grpc_error* error) {
if (error == GRPC_ERROR_NONE) return;
if (*composite == GRPC_ERROR_NONE) {
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Kick Failure");
@@ -715,15 +703,15 @@ static void kick_append_error(grpc_error **composite, grpc_error *error) {
*composite = grpc_error_add_child(*composite, error);
}
-static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
- grpc_pollset_worker *specific_worker,
+static grpc_error* pollset_kick_ext(grpc_pollset* p,
+ grpc_pollset_worker* specific_worker,
uint32_t flags) {
GPR_TIMER_BEGIN("pollset_kick_ext", 0);
- grpc_error *error = GRPC_ERROR_NONE;
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ grpc_error* error = GRPC_ERROR_NONE;
+ GRPC_STATS_INC_POLLSET_KICK();
/* pollset->mu already held */
- if (specific_worker != NULL) {
+ if (specific_worker != nullptr) {
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
GPR_TIMER_BEGIN("pollset_kick_ext.broadcast", 0);
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
@@ -757,7 +745,7 @@ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
GPR_TIMER_MARK("kick_anonymous", 0);
specific_worker = pop_front_worker(p);
- if (specific_worker != NULL) {
+ if (specific_worker != nullptr) {
if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
GPR_TIMER_MARK("kick_anonymous_not_self", 0);
push_back_worker(p, specific_worker);
@@ -766,10 +754,10 @@ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
gpr_tls_get(&g_current_thread_worker) ==
(intptr_t)specific_worker) {
push_back_worker(p, specific_worker);
- specific_worker = NULL;
+ specific_worker = nullptr;
}
}
- if (specific_worker != NULL) {
+ if (specific_worker != nullptr) {
GPR_TIMER_MARK("finally_kick", 0);
push_back_worker(p, specific_worker);
kick_append_error(
@@ -786,14 +774,14 @@ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
return error;
}
-static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
- grpc_pollset_worker *specific_worker) {
- return pollset_kick_ext(exec_ctx, p, specific_worker, 0);
+static grpc_error* pollset_kick(grpc_pollset* p,
+ grpc_pollset_worker* specific_worker) {
+ return pollset_kick_ext(p, specific_worker, 0);
}
/* global state management */
-static grpc_error *pollset_global_init(void) {
+static grpc_error* pollset_global_init(void) {
gpr_tls_init(&g_current_thread_poller);
gpr_tls_init(&g_current_thread_worker);
return GRPC_ERROR_NONE;
@@ -806,27 +794,27 @@ static void pollset_global_shutdown(void) {
/* main interface */
-static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
+static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
gpr_mu_init(&pollset->mu);
*mu = &pollset->mu;
pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker;
pollset->shutting_down = 0;
pollset->called_shutdown = 0;
pollset->kicked_without_pollers = 0;
- pollset->idle_jobs.head = pollset->idle_jobs.tail = NULL;
- pollset->local_wakeup_cache = NULL;
+ pollset->idle_jobs.head = pollset->idle_jobs.tail = nullptr;
+ pollset->local_wakeup_cache = nullptr;
pollset->kicked_without_pollers = 0;
pollset->fd_count = 0;
pollset->fd_capacity = 0;
- pollset->fds = NULL;
+ pollset->fds = nullptr;
pollset->pollset_set_count = 0;
}
-static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
+static void pollset_destroy(grpc_pollset* pollset) {
GPR_ASSERT(!pollset_has_workers(pollset));
GPR_ASSERT(pollset->idle_jobs.head == pollset->idle_jobs.tail);
while (pollset->local_wakeup_cache) {
- grpc_cached_wakeup_fd *next = pollset->local_wakeup_cache->next;
+ grpc_cached_wakeup_fd* next = pollset->local_wakeup_cache->next;
grpc_wakeup_fd_destroy(&pollset->local_wakeup_cache->fd);
gpr_free(pollset->local_wakeup_cache);
pollset->local_wakeup_cache = next;
@@ -835,8 +823,7 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
gpr_mu_destroy(&pollset->mu);
}
-static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_fd *fd) {
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
gpr_mu_lock(&pollset->mu);
size_t i;
/* TODO(ctiller): this is O(num_fds^2); maybe switch to a hash set here */
@@ -846,27 +833,27 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (pollset->fd_count == pollset->fd_capacity) {
pollset->fd_capacity =
GPR_MAX(pollset->fd_capacity + 8, pollset->fd_count * 3 / 2);
- pollset->fds = (grpc_fd **)gpr_realloc(
- pollset->fds, sizeof(grpc_fd *) * pollset->fd_capacity);
+ pollset->fds = (grpc_fd**)gpr_realloc(
+ pollset->fds, sizeof(grpc_fd*) * pollset->fd_capacity);
}
pollset->fds[pollset->fd_count++] = fd;
GRPC_FD_REF(fd, "multipoller");
- pollset_kick(exec_ctx, pollset, NULL);
+ pollset_kick(pollset, nullptr);
exit:
gpr_mu_unlock(&pollset->mu);
}
-static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
+static void finish_shutdown(grpc_pollset* pollset) {
GPR_ASSERT(grpc_closure_list_empty(pollset->idle_jobs));
size_t i;
for (i = 0; i < pollset->fd_count; i++) {
GRPC_FD_UNREF(pollset->fds[i], "multipoller");
}
pollset->fd_count = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pollset->shutdown_done, GRPC_ERROR_NONE);
}
-static void work_combine_error(grpc_error **composite, grpc_error *error) {
+static void work_combine_error(grpc_error** composite, grpc_error* error) {
if (error == GRPC_ERROR_NONE) return;
if (*composite == GRPC_ERROR_NONE) {
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("pollset_work");
@@ -874,12 +861,12 @@ static void work_combine_error(grpc_error **composite, grpc_error *error) {
*composite = grpc_error_add_child(*composite, error);
}
-static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker_hdl,
- gpr_timespec now, gpr_timespec deadline) {
+static grpc_error* pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
grpc_pollset_worker worker;
if (worker_hdl) *worker_hdl = &worker;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
/* Avoid malloc for small number of elements. */
enum { inline_elements = 96 };
@@ -893,14 +880,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
int keep_polling = 0;
GPR_TIMER_BEGIN("pollset_work", 0);
/* this must happen before we (potentially) drop pollset->mu */
- worker.next = worker.prev = NULL;
+ worker.next = worker.prev = nullptr;
worker.reevaluate_polling_on_wakeup = 0;
- if (pollset->local_wakeup_cache != NULL) {
+ if (pollset->local_wakeup_cache != nullptr) {
worker.wakeup_fd = pollset->local_wakeup_cache;
pollset->local_wakeup_cache = worker.wakeup_fd->next;
} else {
worker.wakeup_fd =
- (grpc_cached_wakeup_fd *)gpr_malloc(sizeof(*worker.wakeup_fd));
+ (grpc_cached_wakeup_fd*)gpr_malloc(sizeof(*worker.wakeup_fd));
error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
if (error != GRPC_ERROR_NONE) {
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
@@ -913,7 +900,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (!pollset_has_workers(pollset) &&
!grpc_closure_list_empty(pollset->idle_jobs)) {
GPR_TIMER_MARK("pollset_work.idle_jobs", 0);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
+ GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
goto done;
}
/* If we're shutting down then we don't execute any extended work */
@@ -942,10 +929,10 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
int r;
size_t i, fd_count;
nfds_t pfd_count;
- grpc_fd_watcher *watchers;
- struct pollfd *pfds;
+ grpc_fd_watcher* watchers;
+ struct pollfd* pfds;
- timeout = poll_deadline_to_millis_timeout(deadline, now);
+ timeout = poll_deadline_to_millis_timeout(deadline);
if (pollset->fd_count + 2 <= inline_elements) {
pfds = pollfd_space;
@@ -954,9 +941,9 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* Allocate one buffer to hold both pfds and watchers arrays */
const size_t pfd_size = sizeof(*pfds) * (pollset->fd_count + 2);
const size_t watch_size = sizeof(*watchers) * (pollset->fd_count + 2);
- void *buf = gpr_malloc(pfd_size + watch_size);
- pfds = (struct pollfd *)buf;
- watchers = (grpc_fd_watcher *)(void *)((char *)buf + pfd_size);
+ void* buf = gpr_malloc(pfd_size + watch_size);
+ pfds = (struct pollfd*)buf;
+ watchers = (grpc_fd_watcher*)(void*)((char*)buf + pfd_size);
}
fd_count = 0;
@@ -965,7 +952,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pfds[0].events = POLLIN;
pfds[0].revents = 0;
for (i = 0; i < pollset->fd_count; i++) {
- if (fd_is_orphaned(pollset->fds[i])) {
+ if (fd_is_orphaned(pollset->fds[i]) ||
+ gpr_atm_no_barrier_load(&pollset->fds[i]->pollhup) == 1) {
GRPC_FD_UNREF(pollset->fds[i], "multipoller");
} else {
pollset->fds[fd_count++] = pollset->fds[i];
@@ -980,7 +968,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
gpr_mu_unlock(&pollset->mu);
for (i = 1; i < pfd_count; i++) {
- grpc_fd *fd = watchers[i].fd;
+ grpc_fd* fd = watchers[i].fd;
pfds[i].events = (short)fd_begin_poll(fd, pollset, &worker, POLLIN,
POLLOUT, &watchers[i]);
GRPC_FD_UNREF(fd, "multipoller_start");
@@ -989,11 +977,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* TODO(vpai): Consider first doing a 0 timeout poll here to avoid
even going into the blocking annotation if possible */
GRPC_SCHEDULING_START_BLOCKING_REGION;
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
r = grpc_poll_function(pfds, pfd_count, timeout);
GRPC_SCHEDULING_END_BLOCKING_REGION;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
}
@@ -1003,36 +991,42 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
}
for (i = 1; i < pfd_count; i++) {
- if (watchers[i].fd == NULL) {
- fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
+ if (watchers[i].fd == nullptr) {
+ fd_end_poll(&watchers[i], 0, 0, nullptr);
} else {
// Wake up all the file descriptors, if we have an invalid one
// we can identify it on the next pollset_work()
- fd_end_poll(exec_ctx, &watchers[i], 1, 1, pollset);
+ fd_end_poll(&watchers[i], 1, 1, pollset);
}
}
} else if (r == 0) {
for (i = 1; i < pfd_count; i++) {
- fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
+ fd_end_poll(&watchers[i], 0, 0, nullptr);
}
} else {
if (pfds[0].revents & POLLIN_CHECK) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "%p: got_wakeup", pollset);
}
work_combine_error(
&error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
}
for (i = 1; i < pfd_count; i++) {
- if (watchers[i].fd == NULL) {
- fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
+ if (watchers[i].fd == nullptr) {
+ fd_end_poll(&watchers[i], 0, 0, nullptr);
} else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset,
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0,
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents);
}
- fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK,
+ /* This is a mitigation to prevent poll() from spinning on a
+ ** POLLHUP https://github.com/grpc/grpc/pull/13665
+ */
+ if (pfds[i].revents & POLLHUP) {
+ gpr_atm_no_barrier_store(&watchers[i].fd->pollhup, 1);
+ }
+ fd_end_poll(&watchers[i], pfds[i].revents & POLLIN_CHECK,
pfds[i].revents & POLLOUT_CHECK, pollset);
}
}
@@ -1055,7 +1049,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
worker list, which means nobody could ask us to re-evaluate polling). */
done:
if (!locked) {
- queued_work |= grpc_exec_ctx_flush(exec_ctx);
+ queued_work |= grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
locked = 1;
}
@@ -1068,13 +1062,10 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
if (queued_work || worker.kicked_specifically) {
/* If there's queued work on the list, then set the deadline to be
immediate so we get back out of the polling loop quickly */
- deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ deadline = 0;
}
keep_polling = 1;
}
- if (keep_polling) {
- now = gpr_now(now.clock_type);
- }
}
gpr_tls_set(&g_current_thread_poller, 0);
if (added_worker) {
@@ -1087,82 +1078,72 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* check shutdown conditions */
if (pollset->shutting_down) {
if (pollset_has_workers(pollset)) {
- pollset_kick(exec_ctx, pollset, NULL);
+ pollset_kick(pollset, nullptr);
} else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
- finish_shutdown(exec_ctx, pollset);
- grpc_exec_ctx_flush(exec_ctx);
+ finish_shutdown(pollset);
+ grpc_core::ExecCtx::Get()->Flush();
/* Continuing to access pollset here is safe -- it is the caller's
* responsibility to not destroy when it has outstanding calls to
* pollset_work.
* TODO(dklempner): Can we refactor the shutdown logic to avoid this? */
gpr_mu_lock(&pollset->mu);
} else if (!grpc_closure_list_empty(pollset->idle_jobs)) {
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
+ GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
}
- if (worker_hdl) *worker_hdl = NULL;
+ if (worker_hdl) *worker_hdl = nullptr;
GPR_TIMER_END("pollset_work", 0);
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
return error;
}
-static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_ASSERT(!pollset->shutting_down);
pollset->shutting_down = 1;
pollset->shutdown_done = closure;
- pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
+ pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
if (!pollset_has_workers(pollset)) {
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
+ GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
}
if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
- finish_shutdown(exec_ctx, pollset);
+ finish_shutdown(pollset);
}
}
-static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
- gpr_timespec now) {
- gpr_timespec timeout;
- static const int64_t max_spin_polling_us = 10;
- if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
- return -1;
- }
- if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros(
- max_spin_polling_us,
- GPR_TIMESPAN))) <= 0) {
- return 0;
- }
- timeout = gpr_time_sub(deadline, now);
- return gpr_time_to_millis(gpr_time_add(
- timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
+static int poll_deadline_to_millis_timeout(grpc_millis deadline) {
+ if (deadline == GRPC_MILLIS_INF_FUTURE) return -1;
+ if (deadline == 0) return 0;
+ grpc_millis n = deadline - grpc_core::ExecCtx::Get()->Now();
+ if (n < 0) return 0;
+ if (n > INT_MAX) return -1;
+ return (int)n;
}
/*******************************************************************************
* pollset_set_posix.c
*/
-static grpc_pollset_set *pollset_set_create(void) {
- grpc_pollset_set *pollset_set =
- (grpc_pollset_set *)gpr_zalloc(sizeof(*pollset_set));
+static grpc_pollset_set* pollset_set_create(void) {
+ grpc_pollset_set* pollset_set =
+ (grpc_pollset_set*)gpr_zalloc(sizeof(*pollset_set));
gpr_mu_init(&pollset_set->mu);
return pollset_set;
}
-static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set) {
+static void pollset_set_destroy(grpc_pollset_set* pollset_set) {
size_t i;
gpr_mu_destroy(&pollset_set->mu);
for (i = 0; i < pollset_set->fd_count; i++) {
GRPC_FD_UNREF(pollset_set->fds[i], "pollset_set");
}
for (i = 0; i < pollset_set->pollset_count; i++) {
- grpc_pollset *pollset = pollset_set->pollsets[i];
+ grpc_pollset* pollset = pollset_set->pollsets[i];
gpr_mu_lock(&pollset->mu);
pollset->pollset_set_count--;
/* check shutdown */
@@ -1170,7 +1151,7 @@ static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
!pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
- finish_shutdown(exec_ctx, pollset);
+ finish_shutdown(pollset);
} else {
gpr_mu_unlock(&pollset->mu);
}
@@ -1181,9 +1162,8 @@ static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(pollset_set);
}
-static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset) {
+static void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset) {
size_t i, j;
gpr_mu_lock(&pollset->mu);
pollset->pollset_set_count++;
@@ -1192,7 +1172,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
pollset_set->pollset_capacity =
GPR_MAX(8, 2 * pollset_set->pollset_capacity);
- pollset_set->pollsets = (grpc_pollset **)gpr_realloc(
+ pollset_set->pollsets = (grpc_pollset**)gpr_realloc(
pollset_set->pollsets,
pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets));
}
@@ -1201,7 +1181,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
if (fd_is_orphaned(pollset_set->fds[i])) {
GRPC_FD_UNREF(pollset_set->fds[i], "pollset_set");
} else {
- pollset_add_fd(exec_ctx, pollset, pollset_set->fds[i]);
+ pollset_add_fd(pollset, pollset_set->fds[i]);
pollset_set->fds[j++] = pollset_set->fds[i];
}
}
@@ -1209,15 +1189,14 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
gpr_mu_unlock(&pollset_set->mu);
}
-static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset) {
+static void pollset_set_del_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset) {
size_t i;
gpr_mu_lock(&pollset_set->mu);
for (i = 0; i < pollset_set->pollset_count; i++) {
if (pollset_set->pollsets[i] == pollset) {
pollset_set->pollset_count--;
- GPR_SWAP(grpc_pollset *, pollset_set->pollsets[i],
+ GPR_SWAP(grpc_pollset*, pollset_set->pollsets[i],
pollset_set->pollsets[pollset_set->pollset_count]);
break;
}
@@ -1230,20 +1209,19 @@ static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
!pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
- finish_shutdown(exec_ctx, pollset);
+ finish_shutdown(pollset);
} else {
gpr_mu_unlock(&pollset->mu);
}
}
-static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
+static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {
size_t i, j;
gpr_mu_lock(&bag->mu);
if (bag->pollset_set_count == bag->pollset_set_capacity) {
bag->pollset_set_capacity = GPR_MAX(8, 2 * bag->pollset_set_capacity);
- bag->pollset_sets = (grpc_pollset_set **)gpr_realloc(
+ bag->pollset_sets = (grpc_pollset_set**)gpr_realloc(
bag->pollset_sets,
bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
}
@@ -1252,7 +1230,7 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
if (fd_is_orphaned(bag->fds[i])) {
GRPC_FD_UNREF(bag->fds[i], "pollset_set");
} else {
- pollset_set_add_fd(exec_ctx, item, bag->fds[i]);
+ pollset_set_add_fd(item, bag->fds[i]);
bag->fds[j++] = bag->fds[i];
}
}
@@ -1260,15 +1238,14 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
gpr_mu_unlock(&bag->mu);
}
-static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {
size_t i;
gpr_mu_lock(&bag->mu);
for (i = 0; i < bag->pollset_set_count; i++) {
if (bag->pollset_sets[i] == item) {
bag->pollset_set_count--;
- GPR_SWAP(grpc_pollset_set *, bag->pollset_sets[i],
+ GPR_SWAP(grpc_pollset_set*, bag->pollset_sets[i],
bag->pollset_sets[bag->pollset_set_count]);
break;
}
@@ -1276,41 +1253,39 @@ static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
gpr_mu_unlock(&bag->mu);
}
-static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd) {
+static void pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
size_t i;
gpr_mu_lock(&pollset_set->mu);
if (pollset_set->fd_count == pollset_set->fd_capacity) {
pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
- pollset_set->fds = (grpc_fd **)gpr_realloc(
+ pollset_set->fds = (grpc_fd**)gpr_realloc(
pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
}
GRPC_FD_REF(fd, "pollset_set");
pollset_set->fds[pollset_set->fd_count++] = fd;
for (i = 0; i < pollset_set->pollset_count; i++) {
- pollset_add_fd(exec_ctx, pollset_set->pollsets[i], fd);
+ pollset_add_fd(pollset_set->pollsets[i], fd);
}
for (i = 0; i < pollset_set->pollset_set_count; i++) {
- pollset_set_add_fd(exec_ctx, pollset_set->pollset_sets[i], fd);
+ pollset_set_add_fd(pollset_set->pollset_sets[i], fd);
}
gpr_mu_unlock(&pollset_set->mu);
}
-static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd) {
+static void pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
size_t i;
gpr_mu_lock(&pollset_set->mu);
for (i = 0; i < pollset_set->fd_count; i++) {
if (pollset_set->fds[i] == fd) {
pollset_set->fd_count--;
- GPR_SWAP(grpc_fd *, pollset_set->fds[i],
+ GPR_SWAP(grpc_fd*, pollset_set->fds[i],
pollset_set->fds[pollset_set->fd_count]);
GRPC_FD_UNREF(fd, "pollset_set");
break;
}
}
for (i = 0; i < pollset_set->pollset_set_count; i++) {
- pollset_set_del_fd(exec_ctx, pollset_set->pollset_sets[i], fd);
+ pollset_set_del_fd(pollset_set->pollset_sets[i], fd);
}
gpr_mu_unlock(&pollset_set->mu);
}
@@ -1319,10 +1294,10 @@ static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
* Condition Variable polling extensions
*/
-static void run_poll(void *args);
-static void cache_poller_locked(poll_args *args);
+static void run_poll(void* args);
+static void cache_poller_locked(poll_args* args);
-static void cache_insert_locked(poll_args *args) {
+static void cache_insert_locked(poll_args* args) {
uint32_t key = gpr_murmur_hash3(args->fds, args->nfds * sizeof(struct pollfd),
0xDEADBEEF);
key = key % poll_cache.size;
@@ -1330,18 +1305,18 @@ static void cache_insert_locked(poll_args *args) {
poll_cache.active_pollers[key]->prev = args;
}
args->next = poll_cache.active_pollers[key];
- args->prev = NULL;
+ args->prev = nullptr;
poll_cache.active_pollers[key] = args;
poll_cache.count++;
}
-static void init_result(poll_args *pargs) {
- pargs->result = (poll_result *)gpr_malloc(sizeof(poll_result));
+static void init_result(poll_args* pargs) {
+ pargs->result = (poll_result*)gpr_malloc(sizeof(poll_result));
gpr_ref_init(&pargs->result->refcount, 1);
- pargs->result->watchers = NULL;
+ pargs->result->watchers = nullptr;
pargs->result->watchcount = 0;
pargs->result->fds =
- (struct pollfd *)gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
+ (struct pollfd*)gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
memcpy(pargs->result->fds, pargs->fds, sizeof(struct pollfd) * pargs->nfds);
pargs->result->nfds = pargs->nfds;
pargs->result->retval = 0;
@@ -1351,11 +1326,11 @@ static void init_result(poll_args *pargs) {
// Creates a poll_args object for a given arguments to poll().
// This object may return a poll_args in the cache.
-static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
+static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) {
uint32_t key =
gpr_murmur_hash3(fds, count * sizeof(struct pollfd), 0xDEADBEEF);
key = key % poll_cache.size;
- poll_args *curr = poll_cache.active_pollers[key];
+ poll_args* curr = poll_cache.active_pollers[key];
while (curr) {
if (curr->nfds == count &&
memcmp(curr->fds, fds, count * sizeof(struct pollfd)) == 0) {
@@ -1366,26 +1341,26 @@ static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
}
if (poll_cache.free_pollers) {
- poll_args *pargs = poll_cache.free_pollers;
+ poll_args* pargs = poll_cache.free_pollers;
poll_cache.free_pollers = pargs->next;
if (poll_cache.free_pollers) {
- poll_cache.free_pollers->prev = NULL;
+ poll_cache.free_pollers->prev = nullptr;
}
pargs->fds = fds;
pargs->nfds = count;
- pargs->next = NULL;
- pargs->prev = NULL;
+ pargs->next = nullptr;
+ pargs->prev = nullptr;
init_result(pargs);
cache_poller_locked(pargs);
return pargs;
}
- poll_args *pargs = (poll_args *)gpr_malloc(sizeof(struct poll_args));
+ poll_args* pargs = (poll_args*)gpr_malloc(sizeof(struct poll_args));
gpr_cv_init(&pargs->trigger);
pargs->fds = fds;
pargs->nfds = count;
- pargs->next = NULL;
- pargs->prev = NULL;
+ pargs->next = nullptr;
+ pargs->prev = nullptr;
pargs->trigger_set = 0;
init_result(pargs);
cache_poller_locked(pargs);
@@ -1393,11 +1368,11 @@ static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
gpr_thd_options opt = gpr_thd_options_default();
gpr_ref(&g_cvfds.pollcount);
gpr_thd_options_set_detached(&opt);
- GPR_ASSERT(gpr_thd_new(&t_id, &run_poll, pargs, &opt));
+ GPR_ASSERT(gpr_thd_new(&t_id, "grpc_poller", &run_poll, pargs, &opt));
return pargs;
}
-static void cache_delete_locked(poll_args *args) {
+static void cache_delete_locked(poll_args* args) {
if (!args->prev) {
uint32_t key = gpr_murmur_hash3(
args->fds, args->nfds * sizeof(struct pollfd), 0xDEADBEEF);
@@ -1416,25 +1391,25 @@ static void cache_delete_locked(poll_args *args) {
if (poll_cache.free_pollers) {
poll_cache.free_pollers->prev = args;
}
- args->prev = NULL;
+ args->prev = nullptr;
args->next = poll_cache.free_pollers;
gpr_free(args->fds);
poll_cache.free_pollers = args;
}
-static void cache_poller_locked(poll_args *args) {
+static void cache_poller_locked(poll_args* args) {
if (poll_cache.count + 1 > poll_cache.size / 2) {
- poll_args **old_active_pollers = poll_cache.active_pollers;
+ poll_args** old_active_pollers = poll_cache.active_pollers;
poll_cache.size = poll_cache.size * 2;
poll_cache.count = 0;
poll_cache.active_pollers =
- (poll_args **)gpr_malloc(sizeof(void *) * poll_cache.size);
+ (poll_args**)gpr_malloc(sizeof(void*) * poll_cache.size);
for (unsigned int i = 0; i < poll_cache.size; i++) {
- poll_cache.active_pollers[i] = NULL;
+ poll_cache.active_pollers[i] = nullptr;
}
for (unsigned int i = 0; i < poll_cache.size / 2; i++) {
- poll_args *curr = old_active_pollers[i];
- poll_args *next = NULL;
+ poll_args* curr = old_active_pollers[i];
+ poll_args* next = nullptr;
while (curr) {
next = curr->next;
cache_insert_locked(curr);
@@ -1447,7 +1422,7 @@ static void cache_poller_locked(poll_args *args) {
cache_insert_locked(args);
}
-static void cache_destroy_locked(poll_args *args) {
+static void cache_destroy_locked(poll_args* args) {
if (args->next) {
args->next->prev = args->prev;
}
@@ -1461,7 +1436,7 @@ static void cache_destroy_locked(poll_args *args) {
gpr_free(args);
}
-static void decref_poll_result(poll_result *res) {
+static void decref_poll_result(poll_result* res) {
if (gpr_unref(&res->refcount)) {
GPR_ASSERT(!res->watchers);
gpr_free(res->fds);
@@ -1469,7 +1444,7 @@ static void decref_poll_result(poll_result *res) {
}
}
-void remove_cvn(cv_node **head, cv_node *target) {
+void remove_cvn(grpc_cv_node** head, grpc_cv_node* target) {
if (target->next) {
target->next->prev = target->prev;
}
@@ -1484,17 +1459,17 @@ void remove_cvn(cv_node **head, cv_node *target) {
gpr_timespec thread_grace;
// Poll in a background thread
-static void run_poll(void *args) {
- poll_args *pargs = (poll_args *)args;
+static void run_poll(void* args) {
+ poll_args* pargs = (poll_args*)args;
while (1) {
- poll_result *result = pargs->result;
+ poll_result* result = pargs->result;
int retval = g_cvfds.poll(result->fds, result->nfds, CV_POLL_PERIOD_MS);
gpr_mu_lock(&g_cvfds.mu);
if (retval != 0) {
result->completed = 1;
result->retval = retval;
result->err = errno;
- cv_node *watcher = result->watchers;
+ grpc_cv_node* watcher = result->watchers;
while (watcher) {
gpr_cv_signal(watcher->cv);
watcher = watcher->next;
@@ -1505,7 +1480,7 @@ static void run_poll(void *args) {
decref_poll_result(result);
// Leave this polling thread alive for a grace period to do another poll()
// op
- gpr_timespec deadline = gpr_now(GPR_CLOCK_REALTIME);
+ gpr_timespec deadline = gpr_now(GPR_CLOCK_MONOTONIC);
deadline = gpr_time_add(deadline, thread_grace);
pargs->trigger_set = 0;
gpr_cv_wait(&pargs->trigger, &g_cvfds.mu, deadline);
@@ -1525,27 +1500,27 @@ static void run_poll(void *args) {
}
// This function overrides poll() to handle condition variable wakeup fds
-static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
+static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
unsigned int i;
int res, idx;
- cv_node *pollcv;
+ grpc_cv_node* pollcv;
int skip_poll = 0;
nfds_t nsockfds = 0;
- poll_result *result = NULL;
+ poll_result* result = nullptr;
gpr_mu_lock(&g_cvfds.mu);
- pollcv = (cv_node *)gpr_malloc(sizeof(cv_node));
- pollcv->next = NULL;
+ pollcv = (grpc_cv_node*)gpr_malloc(sizeof(grpc_cv_node));
+ pollcv->next = nullptr;
gpr_cv pollcv_cv;
gpr_cv_init(&pollcv_cv);
pollcv->cv = &pollcv_cv;
- cv_node *fd_cvs = (cv_node *)gpr_malloc(nfds * sizeof(cv_node));
+ grpc_cv_node* fd_cvs = (grpc_cv_node*)gpr_malloc(nfds * sizeof(grpc_cv_node));
for (i = 0; i < nfds; i++) {
fds[i].revents = 0;
if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
idx = GRPC_FD_TO_IDX(fds[i].fd);
fd_cvs[i].cv = &pollcv_cv;
- fd_cvs[i].prev = NULL;
+ fd_cvs[i].prev = nullptr;
fd_cvs[i].next = g_cvfds.cvfds[idx].cvs;
if (g_cvfds.cvfds[idx].cvs) {
g_cvfds.cvfds[idx].cvs->prev = &(fd_cvs[i]);
@@ -1560,9 +1535,9 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
}
}
- gpr_timespec deadline = gpr_now(GPR_CLOCK_REALTIME);
+ gpr_timespec deadline = gpr_now(GPR_CLOCK_MONOTONIC);
if (timeout < 0) {
- deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
+ deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
} else {
deadline =
gpr_time_add(deadline, gpr_time_from_millis(timeout, GPR_TIMESPAN));
@@ -1570,8 +1545,8 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
res = 0;
if (!skip_poll && nsockfds > 0) {
- struct pollfd *pollfds =
- (struct pollfd *)gpr_malloc(sizeof(struct pollfd) * nsockfds);
+ struct pollfd* pollfds =
+ (struct pollfd*)gpr_malloc(sizeof(struct pollfd) * nsockfds);
idx = 0;
for (i = 0; i < nfds; i++) {
if (fds[i].fd >= 0) {
@@ -1581,10 +1556,10 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
idx++;
}
}
- poll_args *pargs = get_poller_locked(pollfds, nsockfds);
+ poll_args* pargs = get_poller_locked(pollfds, nsockfds);
result = pargs->result;
pollcv->next = result->watchers;
- pollcv->prev = NULL;
+ pollcv->prev = nullptr;
if (result->watchers) {
result->watchers->prev = pollcv;
}
@@ -1635,12 +1610,12 @@ static void global_cv_fd_table_init() {
gpr_ref_init(&g_cvfds.pollcount, 1);
g_cvfds.size = CV_DEFAULT_TABLE_SIZE;
g_cvfds.cvfds =
- (fd_node *)gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE);
- g_cvfds.free_fds = NULL;
+ (grpc_fd_node*)gpr_malloc(sizeof(grpc_fd_node) * CV_DEFAULT_TABLE_SIZE);
+ g_cvfds.free_fds = nullptr;
thread_grace = gpr_time_from_millis(POLLCV_THREAD_GRACE_MS, GPR_TIMESPAN);
for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) {
g_cvfds.cvfds[i].is_set = 0;
- g_cvfds.cvfds[i].cvs = NULL;
+ g_cvfds.cvfds[i].cvs = nullptr;
g_cvfds.cvfds[i].next_free = g_cvfds.free_fds;
g_cvfds.free_fds = &g_cvfds.cvfds[i];
}
@@ -1651,10 +1626,10 @@ static void global_cv_fd_table_init() {
// Initialize the cache
poll_cache.size = 32;
poll_cache.count = 0;
- poll_cache.free_pollers = NULL;
- poll_cache.active_pollers = (poll_args **)gpr_malloc(sizeof(void *) * 32);
+ poll_cache.free_pollers = nullptr;
+ poll_cache.active_pollers = (poll_args**)gpr_malloc(sizeof(void*) * 32);
for (unsigned int i = 0; i < poll_cache.size; i++) {
- poll_cache.active_pollers[i] = NULL;
+ poll_cache.active_pollers[i] = nullptr;
}
gpr_mu_unlock(&g_cvfds.mu);
@@ -1666,7 +1641,7 @@ static void global_cv_fd_table_shutdown() {
// Not doing so will result in reported memory leaks
if (!gpr_unref(&g_cvfds.pollcount)) {
int res = gpr_cv_wait(&g_cvfds.shutdown_cv, &g_cvfds.mu,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(3, GPR_TIMESPAN)));
GPR_ASSERT(res == 0);
}
@@ -1722,23 +1697,24 @@ static const grpc_event_engine_vtable vtable = {
shutdown_engine,
};
-const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request) {
+const grpc_event_engine_vtable* grpc_init_poll_posix(bool explicit_request) {
if (!grpc_has_wakeup_fd()) {
- return NULL;
+ gpr_log(GPR_ERROR, "Skipping poll because of no wakeup fd.");
+ return nullptr;
}
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
- return NULL;
+ return nullptr;
}
return &vtable;
}
-const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request) {
+const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request) {
global_cv_fd_table_init();
grpc_enable_cv_wakeup_fds(1);
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
global_cv_fd_table_shutdown();
grpc_enable_cv_wakeup_fds(0);
- return NULL;
+ return nullptr;
}
return &vtable;
}
diff --git a/src/core/lib/iomgr/ev_poll_posix.h b/src/core/lib/iomgr/ev_poll_posix.h
index d444e60944..f6bc624d4f 100644
--- a/src/core/lib/iomgr/ev_poll_posix.h
+++ b/src/core/lib/iomgr/ev_poll_posix.h
@@ -21,7 +21,7 @@
#include "src/core/lib/iomgr/ev_posix.h"
-const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request);
-const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request);
+const grpc_event_engine_vtable* grpc_init_poll_posix(bool explicit_request);
+const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request);
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */
diff --git a/src/core/lib/iomgr/ev_posix.c b/src/core/lib/iomgr/ev_posix.c
deleted file mode 100644
index 4d3ae2228e..0000000000
--- a/src/core/lib/iomgr/ev_posix.c
+++ /dev/null
@@ -1,266 +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/iomgr/port.h"
-
-#ifdef GRPC_POSIX_SOCKET
-
-#include "src/core/lib/iomgr/ev_posix.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-
-#include "src/core/lib/debug/trace.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"
-#include "src/core/lib/iomgr/ev_poll_posix.h"
-#include "src/core/lib/support/env.h"
-
-grpc_tracer_flag grpc_polling_trace =
- GRPC_TRACER_INITIALIZER(false, "polling"); /* Disabled by default */
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_fd_refcount =
- GRPC_TRACER_INITIALIZER(false, "fd_refcount");
-#endif
-
-/** Default poll() function - a pointer so that it can be overridden by some
- * tests */
-grpc_poll_function_type grpc_poll_function = poll;
-
-grpc_wakeup_fd grpc_global_wakeup_fd;
-
-static const grpc_event_engine_vtable *g_event_engine;
-static const char *g_poll_strategy_name = NULL;
-
-typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(
- bool explicit_request);
-
-typedef struct {
- const char *name;
- event_engine_factory_fn factory;
-} event_engine_factory;
-
-static const event_engine_factory g_factories[] = {
- {"epoll1", grpc_init_epoll1_linux},
- {"epollsig", grpc_init_epollsig_linux},
- {"poll", grpc_init_poll_posix},
- {"poll-cv", grpc_init_poll_cv_posix},
- {"epollex", grpc_init_epollex_linux},
-};
-
-static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
- size_t n = *ns;
- size_t np = n + 1;
- char *s;
- size_t len;
- GPR_ASSERT(end >= beg);
- len = (size_t)(end - beg);
- s = (char *)gpr_malloc(len + 1);
- memcpy(s, beg, len);
- s[len] = 0;
- *ss = (char **)gpr_realloc(*ss, sizeof(char **) * np);
- (*ss)[n] = s;
- *ns = np;
-}
-
-static void split(const char *s, char ***ss, size_t *ns) {
- const char *c = strchr(s, ',');
- if (c == NULL) {
- add(s, s + strlen(s), ss, ns);
- } else {
- add(s, c, ss, ns);
- split(c + 1, ss, ns);
- }
-}
-
-static bool is(const char *want, const char *have) {
- return 0 == strcmp(want, "all") || 0 == strcmp(want, have);
-}
-
-static void try_engine(const char *engine) {
- for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
- if (is(engine, g_factories[i].name)) {
- if ((g_event_engine = g_factories[i].factory(
- 0 == strcmp(engine, g_factories[i].name)))) {
- g_poll_strategy_name = g_factories[i].name;
- gpr_log(GPR_DEBUG, "Using polling engine: %s", g_factories[i].name);
- return;
- }
- }
- }
-}
-
-/* This should be used for testing purposes ONLY */
-void grpc_set_event_engine_test_only(
- const grpc_event_engine_vtable *ev_engine) {
- g_event_engine = ev_engine;
-}
-
-const grpc_event_engine_vtable *grpc_get_event_engine_test_only() {
- return g_event_engine;
-}
-
-/* Call this only after calling grpc_event_engine_init() */
-const char *grpc_get_poll_strategy_name() { return g_poll_strategy_name; }
-
-void grpc_event_engine_init(void) {
- grpc_register_tracer(&grpc_polling_trace);
-
- char *s = gpr_getenv("GRPC_POLL_STRATEGY");
- if (s == NULL) {
- s = gpr_strdup("all");
- }
-
- char **strings = NULL;
- size_t nstrings = 0;
- split(s, &strings, &nstrings);
-
- for (size_t i = 0; g_event_engine == NULL && i < nstrings; i++) {
- try_engine(strings[i]);
- }
-
- for (size_t i = 0; i < nstrings; i++) {
- gpr_free(strings[i]);
- }
- gpr_free(strings);
- gpr_free(s);
-
- if (g_event_engine == NULL) {
- gpr_log(GPR_ERROR, "No event engine could be initialized");
- abort();
- }
-}
-
-void grpc_event_engine_shutdown(void) {
- g_event_engine->shutdown_engine();
- g_event_engine = NULL;
-}
-
-grpc_fd *grpc_fd_create(int fd, const char *name) {
- return g_event_engine->fd_create(fd, name);
-}
-
-int grpc_fd_wrapped_fd(grpc_fd *fd) {
- return g_event_engine->fd_wrapped_fd(fd);
-}
-
-void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
- int *release_fd, bool already_closed, const char *reason) {
- g_event_engine->fd_orphan(exec_ctx, fd, on_done, release_fd, already_closed,
- reason);
-}
-
-void grpc_fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
- g_event_engine->fd_shutdown(exec_ctx, fd, why);
-}
-
-bool grpc_fd_is_shutdown(grpc_fd *fd) {
- return g_event_engine->fd_is_shutdown(fd);
-}
-
-void grpc_fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- g_event_engine->fd_notify_on_read(exec_ctx, fd, closure);
-}
-
-void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure) {
- g_event_engine->fd_notify_on_write(exec_ctx, fd, closure);
-}
-
-size_t grpc_pollset_size(void) { return g_event_engine->pollset_size; }
-
-void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
- g_event_engine->pollset_init(pollset, mu);
-}
-
-void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
- g_event_engine->pollset_shutdown(exec_ctx, pollset, closure);
-}
-
-void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
- g_event_engine->pollset_destroy(exec_ctx, pollset);
-}
-
-grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker, gpr_timespec now,
- gpr_timespec deadline) {
- return g_event_engine->pollset_work(exec_ctx, pollset, worker, now, deadline);
-}
-
-grpc_error *grpc_pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker) {
- return g_event_engine->pollset_kick(exec_ctx, pollset, specific_worker);
-}
-
-void grpc_pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- struct grpc_fd *fd) {
- g_event_engine->pollset_add_fd(exec_ctx, pollset, fd);
-}
-
-grpc_pollset_set *grpc_pollset_set_create(void) {
- return g_event_engine->pollset_set_create();
-}
-
-void grpc_pollset_set_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set) {
- g_event_engine->pollset_set_destroy(exec_ctx, pollset_set);
-}
-
-void grpc_pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset) {
- g_event_engine->pollset_set_add_pollset(exec_ctx, pollset_set, pollset);
-}
-
-void grpc_pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset) {
- g_event_engine->pollset_set_del_pollset(exec_ctx, pollset_set, pollset);
-}
-
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
- g_event_engine->pollset_set_add_pollset_set(exec_ctx, bag, item);
-}
-
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item) {
- g_event_engine->pollset_set_del_pollset_set(exec_ctx, bag, item);
-}
-
-void grpc_pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd) {
- g_event_engine->pollset_set_add_fd(exec_ctx, pollset_set, fd);
-}
-
-void grpc_pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd) {
- g_event_engine->pollset_set_del_fd(exec_ctx, pollset_set, fd);
-}
-
-#endif // GRPC_POSIX_SOCKET
diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc
new file mode 100644
index 0000000000..3a5714132d
--- /dev/null
+++ b/src/core/lib/iomgr/ev_posix.cc
@@ -0,0 +1,273 @@
+/*
+ *
+ * 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/iomgr/port.h"
+
+#ifdef GRPC_POSIX_SOCKET
+
+#include "src/core/lib/iomgr/ev_posix.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/env.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"
+#include "src/core/lib/iomgr/ev_poll_posix.h"
+
+grpc_core::TraceFlag grpc_polling_trace(false,
+ "polling"); /* Disabled by default */
+grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount");
+
+/** Default poll() function - a pointer so that it can be overridden by some
+ * tests */
+grpc_poll_function_type grpc_poll_function = poll;
+
+grpc_wakeup_fd grpc_global_wakeup_fd;
+
+static const grpc_event_engine_vtable* g_event_engine = nullptr;
+static const char* g_poll_strategy_name = nullptr;
+
+typedef const grpc_event_engine_vtable* (*event_engine_factory_fn)(
+ bool explicit_request);
+
+typedef struct {
+ const char* name;
+ event_engine_factory_fn factory;
+} event_engine_factory;
+
+namespace {
+
+grpc_poll_function_type real_poll_function;
+
+int dummy_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
+ if (timeout == 0) {
+ return real_poll_function(fds, nfds, 0);
+ } else {
+ gpr_log(GPR_ERROR, "Attempted a blocking poll when declared non-polling.");
+ GPR_ASSERT(false);
+ return -1;
+ }
+}
+
+const grpc_event_engine_vtable* init_non_polling(bool explicit_request) {
+ if (!explicit_request) {
+ return nullptr;
+ }
+ // return the simplest engine as a dummy but also override the poller
+ auto ret = grpc_init_poll_posix(explicit_request);
+ real_poll_function = grpc_poll_function;
+ grpc_poll_function = dummy_poll;
+
+ return ret;
+}
+} // namespace
+
+static const event_engine_factory g_factories[] = {
+ {"epollex", grpc_init_epollex_linux}, {"epoll1", grpc_init_epoll1_linux},
+ {"epollsig", grpc_init_epollsig_linux}, {"poll", grpc_init_poll_posix},
+ {"poll-cv", grpc_init_poll_cv_posix}, {"none", init_non_polling},
+};
+
+static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
+ size_t n = *ns;
+ size_t np = n + 1;
+ char* s;
+ size_t len;
+ GPR_ASSERT(end >= beg);
+ len = (size_t)(end - beg);
+ s = (char*)gpr_malloc(len + 1);
+ memcpy(s, beg, len);
+ s[len] = 0;
+ *ss = (char**)gpr_realloc(*ss, sizeof(char**) * np);
+ (*ss)[n] = s;
+ *ns = np;
+}
+
+static void split(const char* s, char*** ss, size_t* ns) {
+ const char* c = strchr(s, ',');
+ if (c == nullptr) {
+ add(s, s + strlen(s), ss, ns);
+ } else {
+ add(s, c, ss, ns);
+ split(c + 1, ss, ns);
+ }
+}
+
+static bool is(const char* want, const char* have) {
+ return 0 == strcmp(want, "all") || 0 == strcmp(want, have);
+}
+
+static void try_engine(const char* engine) {
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
+ if (is(engine, g_factories[i].name)) {
+ if ((g_event_engine = g_factories[i].factory(
+ 0 == strcmp(engine, g_factories[i].name)))) {
+ g_poll_strategy_name = g_factories[i].name;
+ gpr_log(GPR_DEBUG, "Using polling engine: %s", g_factories[i].name);
+ return;
+ }
+ }
+ }
+}
+
+/* This should be used for testing purposes ONLY */
+void grpc_set_event_engine_test_only(
+ const grpc_event_engine_vtable* ev_engine) {
+ g_event_engine = ev_engine;
+}
+
+const grpc_event_engine_vtable* grpc_get_event_engine_test_only() {
+ return g_event_engine;
+}
+
+/* Call this only after calling grpc_event_engine_init() */
+const char* grpc_get_poll_strategy_name() { return g_poll_strategy_name; }
+
+void grpc_event_engine_init(void) {
+ char* s = gpr_getenv("GRPC_POLL_STRATEGY");
+ if (s == nullptr) {
+ s = gpr_strdup("all");
+ }
+
+ char** strings = nullptr;
+ size_t nstrings = 0;
+ split(s, &strings, &nstrings);
+
+ for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) {
+ try_engine(strings[i]);
+ }
+
+ for (size_t i = 0; i < nstrings; i++) {
+ gpr_free(strings[i]);
+ }
+ gpr_free(strings);
+
+ if (g_event_engine == nullptr) {
+ gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s);
+ abort();
+ }
+ gpr_free(s);
+}
+
+void grpc_event_engine_shutdown(void) {
+ g_event_engine->shutdown_engine();
+ g_event_engine = nullptr;
+}
+
+grpc_fd* grpc_fd_create(int fd, const char* name) {
+ return g_event_engine->fd_create(fd, name);
+}
+
+int grpc_fd_wrapped_fd(grpc_fd* fd) {
+ return g_event_engine->fd_wrapped_fd(fd);
+}
+
+void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason) {
+ g_event_engine->fd_orphan(fd, on_done, release_fd, already_closed, reason);
+}
+
+void grpc_fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ g_event_engine->fd_shutdown(fd, why);
+}
+
+bool grpc_fd_is_shutdown(grpc_fd* fd) {
+ return g_event_engine->fd_is_shutdown(fd);
+}
+
+void grpc_fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ g_event_engine->fd_notify_on_read(fd, closure);
+}
+
+void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ g_event_engine->fd_notify_on_write(fd, closure);
+}
+
+size_t grpc_pollset_size(void) { return g_event_engine->pollset_size; }
+
+void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
+ g_event_engine->pollset_init(pollset, mu);
+}
+
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
+ g_event_engine->pollset_shutdown(pollset, closure);
+}
+
+void grpc_pollset_destroy(grpc_pollset* pollset) {
+ g_event_engine->pollset_destroy(pollset);
+}
+
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker,
+ grpc_millis deadline) {
+ return g_event_engine->pollset_work(pollset, worker, deadline);
+}
+
+grpc_error* grpc_pollset_kick(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker) {
+ return g_event_engine->pollset_kick(pollset, specific_worker);
+}
+
+void grpc_pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd) {
+ g_event_engine->pollset_add_fd(pollset, fd);
+}
+
+grpc_pollset_set* grpc_pollset_set_create(void) {
+ return g_event_engine->pollset_set_create();
+}
+
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {
+ g_event_engine->pollset_set_destroy(pollset_set);
+}
+
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset) {
+ g_event_engine->pollset_set_add_pollset(pollset_set, pollset);
+}
+
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset) {
+ g_event_engine->pollset_set_del_pollset(pollset_set, pollset);
+}
+
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {
+ g_event_engine->pollset_set_add_pollset_set(bag, item);
+}
+
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item) {
+ g_event_engine->pollset_set_del_pollset_set(bag, item);
+}
+
+void grpc_pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
+ g_event_engine->pollset_set_add_fd(pollset_set, fd);
+}
+
+void grpc_pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
+ g_event_engine->pollset_set_del_fd(pollset_set, fd);
+}
+
+#endif // GRPC_POSIX_SOCKET
diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h
index 1ff2ff1413..62f1162a23 100644
--- a/src/core/lib/iomgr/ev_posix.h
+++ b/src/core/lib/iomgr/ev_posix.h
@@ -27,57 +27,45 @@
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-extern grpc_tracer_flag grpc_polling_trace; /* Disabled by default */
+extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */
typedef struct grpc_fd grpc_fd;
typedef struct grpc_event_engine_vtable {
size_t pollset_size;
- grpc_fd *(*fd_create)(int fd, const char *name);
- int (*fd_wrapped_fd)(grpc_fd *fd);
- void (*fd_orphan)(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
- int *release_fd, bool already_closed, const char *reason);
- void (*fd_shutdown)(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why);
- void (*fd_notify_on_read)(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure);
- void (*fd_notify_on_write)(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure);
- bool (*fd_is_shutdown)(grpc_fd *fd);
- grpc_pollset *(*fd_get_read_notifier_pollset)(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd);
-
- void (*pollset_init)(grpc_pollset *pollset, gpr_mu **mu);
- void (*pollset_shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure);
- void (*pollset_destroy)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset);
- grpc_error *(*pollset_work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker, gpr_timespec now,
- gpr_timespec deadline);
- grpc_error *(*pollset_kick)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker);
- void (*pollset_add_fd)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- struct grpc_fd *fd);
-
- grpc_pollset_set *(*pollset_set_create)(void);
- void (*pollset_set_destroy)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set);
- void (*pollset_set_add_pollset)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset);
- void (*pollset_set_del_pollset)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset);
- void (*pollset_set_add_pollset_set)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item);
- void (*pollset_set_del_pollset_set)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item);
- void (*pollset_set_add_fd)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd);
- void (*pollset_set_del_fd)(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd);
+ grpc_fd* (*fd_create)(int fd, const char* name);
+ int (*fd_wrapped_fd)(grpc_fd* fd);
+ void (*fd_orphan)(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason);
+ void (*fd_shutdown)(grpc_fd* fd, grpc_error* why);
+ void (*fd_notify_on_read)(grpc_fd* fd, grpc_closure* closure);
+ void (*fd_notify_on_write)(grpc_fd* fd, grpc_closure* closure);
+ bool (*fd_is_shutdown)(grpc_fd* fd);
+ grpc_pollset* (*fd_get_read_notifier_pollset)(grpc_fd* fd);
+
+ void (*pollset_init)(grpc_pollset* pollset, gpr_mu** mu);
+ void (*pollset_shutdown)(grpc_pollset* pollset, grpc_closure* closure);
+ void (*pollset_destroy)(grpc_pollset* pollset);
+ grpc_error* (*pollset_work)(grpc_pollset* pollset,
+ grpc_pollset_worker** worker,
+ grpc_millis deadline);
+ grpc_error* (*pollset_kick)(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker);
+ void (*pollset_add_fd)(grpc_pollset* pollset, struct grpc_fd* fd);
+
+ grpc_pollset_set* (*pollset_set_create)(void);
+ void (*pollset_set_destroy)(grpc_pollset_set* pollset_set);
+ void (*pollset_set_add_pollset)(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset);
+ void (*pollset_set_del_pollset)(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset);
+ void (*pollset_set_add_pollset_set)(grpc_pollset_set* bag,
+ grpc_pollset_set* item);
+ void (*pollset_set_del_pollset_set)(grpc_pollset_set* bag,
+ grpc_pollset_set* item);
+ void (*pollset_set_add_fd)(grpc_pollset_set* pollset_set, grpc_fd* fd);
+ void (*pollset_set_del_fd)(grpc_pollset_set* pollset_set, grpc_fd* fd);
void (*shutdown_engine)(void);
} grpc_event_engine_vtable;
@@ -86,15 +74,15 @@ void grpc_event_engine_init(void);
void grpc_event_engine_shutdown(void);
/* Return the name of the poll strategy */
-const char *grpc_get_poll_strategy_name();
+const char* grpc_get_poll_strategy_name();
/* Create a wrapped file descriptor.
Requires fd is a non-blocking file descriptor.
This takes ownership of closing fd. */
-grpc_fd *grpc_fd_create(int fd, const char *name);
+grpc_fd* grpc_fd_create(int fd, const char* name);
/* Return the wrapped fd, or -1 if it has been released or closed. */
-int grpc_fd_wrapped_fd(grpc_fd *fd);
+int grpc_fd_wrapped_fd(grpc_fd* fd);
/* Releases fd to be asynchronously destroyed.
on_done is called when the underlying file descriptor is definitely close()d.
@@ -103,14 +91,14 @@ int grpc_fd_wrapped_fd(grpc_fd *fd);
Requires: *fd initialized; no outstanding notify_on_read or
notify_on_write.
MUST NOT be called with a pollset lock taken */
-void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
- int *release_fd, bool already_closed, const char *reason);
+void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason);
/* Has grpc_fd_shutdown been called on an fd? */
-bool grpc_fd_is_shutdown(grpc_fd *fd);
+bool grpc_fd_is_shutdown(grpc_fd* fd);
/* Cause any current and future callbacks to fail. */
-void grpc_fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why);
+void grpc_fd_shutdown(grpc_fd* fd, grpc_error* why);
/* Register read interest, causing read_cb to be called once when fd becomes
readable, on deadline specified by deadline, or on shutdown triggered by
@@ -125,37 +113,31 @@ void grpc_fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why);
underlying platform. This means that users must drain fd in read_cb before
calling notify_on_read again. Users are also expected to handle spurious
events, i.e read_cb is called while nothing can be readable from fd */
-void grpc_fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure);
+void grpc_fd_notify_on_read(grpc_fd* fd, grpc_closure* closure);
/* Exactly the same semantics as above, except based on writable events. */
-void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- grpc_closure *closure);
+void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure);
/* Return the read notifier pollset from the fd */
-grpc_pollset *grpc_fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
- grpc_fd *fd);
+grpc_pollset* grpc_fd_get_read_notifier_pollset(grpc_fd* fd);
/* pollset_posix functions */
/* Add an fd to a pollset */
-void grpc_pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- struct grpc_fd *fd);
+void grpc_pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd);
/* pollset_set_posix functions */
-void grpc_pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd);
-void grpc_pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set, grpc_fd *fd);
+void grpc_pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd);
+void grpc_pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd);
/* override to allow tests to hook poll() usage */
-typedef int (*grpc_poll_function_type)(struct pollfd *, nfds_t, int);
+typedef int (*grpc_poll_function_type)(struct pollfd*, nfds_t, int);
extern grpc_poll_function_type grpc_poll_function;
/* WARNING: The following two functions should be used for testing purposes
* ONLY */
-void grpc_set_event_engine_test_only(const grpc_event_engine_vtable *);
-const grpc_event_engine_vtable *grpc_get_event_engine_test_only();
+void grpc_set_event_engine_test_only(const grpc_event_engine_vtable*);
+const grpc_event_engine_vtable* grpc_get_event_engine_test_only();
#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */
diff --git a/src/core/lib/iomgr/ev_windows.c b/src/core/lib/iomgr/ev_windows.cc
index c24dfaeaf7..697697d0b0 100644
--- a/src/core/lib/iomgr/ev_windows.c
+++ b/src/core/lib/iomgr/ev_windows.cc
@@ -22,7 +22,7 @@
#include "src/core/lib/debug/trace.h"
-grpc_tracer_flag grpc_polling_trace =
- GRPC_TRACER_INITIALIZER(false, "polling"); /* Disabled by default */
+grpc_core::TraceFlag grpc_polling_trace(false,
+ "polling"); /* Disabled by default */
#endif // GRPC_WINSOCK_SOCKET
diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c
deleted file mode 100644
index 41c69add17..0000000000
--- a/src/core/lib/iomgr/exec_ctx.c
+++ /dev/null
@@ -1,113 +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/iomgr/exec_ctx.h"
-
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-
-#include "src/core/lib/iomgr/combiner.h"
-#include "src/core/lib/profiling/timers.h"
-
-bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx *exec_ctx) {
- if ((exec_ctx->flags & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
- if (exec_ctx->check_ready_to_finish(exec_ctx,
- exec_ctx->check_ready_to_finish_arg)) {
- exec_ctx->flags |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
- return true;
- }
- return false;
- } else {
- return true;
- }
-}
-
-bool grpc_never_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) {
- return false;
-}
-
-bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) {
- return true;
-}
-
-bool grpc_exec_ctx_has_work(grpc_exec_ctx *exec_ctx) {
- return exec_ctx->active_combiner != NULL ||
- !grpc_closure_list_empty(exec_ctx->closure_list);
-}
-
-void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx) {
- exec_ctx->flags |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
- grpc_exec_ctx_flush(exec_ctx);
-}
-
-static void exec_ctx_run(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error) {
-#ifndef NDEBUG
- closure->scheduled = false;
- if (GRPC_TRACER_ON(grpc_trace_closure)) {
- gpr_log(GPR_DEBUG, "running closure %p: created [%s:%d]: %s [%s:%d]",
- closure, closure->file_created, closure->line_created,
- closure->run ? "run" : "scheduled", closure->file_initiated,
- closure->line_initiated);
- }
-#endif
- closure->cb(exec_ctx, closure->cb_arg, error);
-#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_closure)) {
- gpr_log(GPR_DEBUG, "closure %p finished", closure);
- }
-#endif
- GRPC_ERROR_UNREF(error);
-}
-
-bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
- bool did_something = 0;
- GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
- for (;;) {
- if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
- grpc_closure *c = exec_ctx->closure_list.head;
- exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL;
- while (c != NULL) {
- grpc_closure *next = c->next_data.next;
- grpc_error *error = c->error_data.error;
- did_something = true;
- exec_ctx_run(exec_ctx, c, error);
- c = next;
- }
- } else if (!grpc_combiner_continue_exec_ctx(exec_ctx)) {
- break;
- }
- }
- GPR_ASSERT(exec_ctx->active_combiner == NULL);
- GPR_TIMER_END("grpc_exec_ctx_flush", 0);
- return did_something;
-}
-
-static void exec_ctx_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error) {
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
-}
-
-void grpc_exec_ctx_global_init(void) {}
-void grpc_exec_ctx_global_shutdown(void) {}
-
-static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
- exec_ctx_run, exec_ctx_sched, "exec_ctx"};
-static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
-grpc_closure_scheduler *grpc_schedule_on_exec_ctx = &exec_ctx_scheduler;
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc
new file mode 100644
index 0000000000..e005437e0a
--- /dev/null
+++ b/src/core/lib/iomgr/exec_ctx.cc
@@ -0,0 +1,145 @@
+/*
+ *
+ * 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/iomgr/exec_ctx.h"
+
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/profiling/timers.h"
+
+static void exec_ctx_run(grpc_closure* closure, grpc_error* error) {
+#ifndef NDEBUG
+ closure->scheduled = false;
+ if (grpc_trace_closure.enabled()) {
+ gpr_log(GPR_DEBUG, "running closure %p: created [%s:%d]: %s [%s:%d]",
+ closure, closure->file_created, closure->line_created,
+ closure->run ? "run" : "scheduled", closure->file_initiated,
+ closure->line_initiated);
+ }
+#endif
+ closure->cb(closure->cb_arg, error);
+#ifndef NDEBUG
+ if (grpc_trace_closure.enabled()) {
+ gpr_log(GPR_DEBUG, "closure %p finished", closure);
+ }
+#endif
+ GRPC_ERROR_UNREF(error);
+}
+
+static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) {
+ grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(), closure,
+ error);
+}
+
+static gpr_timespec g_start_time;
+
+static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) {
+ ts = gpr_time_sub(ts, g_start_time);
+ double x =
+ GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS;
+ if (x < 0) return 0;
+ if (x > GPR_ATM_MAX) return GPR_ATM_MAX;
+ return (gpr_atm)x;
+}
+
+static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) {
+ ts = gpr_time_sub(ts, g_start_time);
+ double x = GPR_MS_PER_SEC * (double)ts.tv_sec +
+ (double)ts.tv_nsec / GPR_NS_PER_MS +
+ (double)(GPR_NS_PER_SEC - 1) / (double)GPR_NS_PER_SEC;
+ if (x < 0) return 0;
+ if (x > GPR_ATM_MAX) return GPR_ATM_MAX;
+ return (gpr_atm)x;
+}
+
+gpr_timespec grpc_millis_to_timespec(grpc_millis millis,
+ gpr_clock_type clock_type) {
+ // special-case infinities as grpc_millis can be 32bit on some platforms
+ // while gpr_time_from_millis always takes an int64_t.
+ if (millis == GRPC_MILLIS_INF_FUTURE) {
+ return gpr_inf_future(clock_type);
+ }
+ if (millis == GRPC_MILLIS_INF_PAST) {
+ return gpr_inf_past(clock_type);
+ }
+
+ if (clock_type == GPR_TIMESPAN) {
+ return gpr_time_from_millis(millis, GPR_TIMESPAN);
+ }
+ return gpr_time_add(gpr_convert_clock_type(g_start_time, clock_type),
+ gpr_time_from_millis(millis, GPR_TIMESPAN));
+}
+
+grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec ts) {
+ return timespec_to_atm_round_down(
+ gpr_convert_clock_type(ts, g_start_time.clock_type));
+}
+
+grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) {
+ return timespec_to_atm_round_up(
+ gpr_convert_clock_type(ts, g_start_time.clock_type));
+}
+
+static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
+ exec_ctx_run, exec_ctx_sched, "exec_ctx"};
+static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
+grpc_closure_scheduler* grpc_schedule_on_exec_ctx = &exec_ctx_scheduler;
+
+namespace grpc_core {
+GPR_TLS_CLASS_DEF(ExecCtx::exec_ctx_);
+
+void ExecCtx::GlobalInit(void) {
+ g_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
+ gpr_tls_init(&exec_ctx_);
+}
+
+bool ExecCtx::Flush() {
+ bool did_something = 0;
+ GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
+ for (;;) {
+ if (!grpc_closure_list_empty(closure_list_)) {
+ grpc_closure* c = closure_list_.head;
+ closure_list_.head = closure_list_.tail = nullptr;
+ while (c != nullptr) {
+ grpc_closure* next = c->next_data.next;
+ grpc_error* error = c->error_data.error;
+ did_something = true;
+ exec_ctx_run(c, error);
+ c = next;
+ }
+ } else if (!grpc_combiner_continue_exec_ctx()) {
+ break;
+ }
+ }
+ GPR_ASSERT(combiner_data_.active_combiner == nullptr);
+ GPR_TIMER_END("grpc_exec_ctx_flush", 0);
+ return did_something;
+}
+
+grpc_millis ExecCtx::Now() {
+ if (!now_is_valid_) {
+ now_ = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC));
+ now_is_valid_ = true;
+ }
+ return now_;
+}
+
+} // namespace grpc_core
diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h
index c89792c8c4..2e71482fb7 100644
--- a/src/core/lib/iomgr/exec_ctx.h
+++ b/src/core/lib/iomgr/exec_ctx.h
@@ -19,10 +19,17 @@
#ifndef GRPC_CORE_LIB_IOMGR_EXEC_CTX_H
#define GRPC_CORE_LIB_IOMGR_EXEC_CTX_H
+#include <grpc/support/atm.h>
#include <grpc/support/cpu.h>
+#include <grpc/support/log.h>
+#include <grpc/support/tls.h>
+
#include "src/core/lib/iomgr/closure.h"
-/* #define GRPC_EXECUTION_CONTEXT_SANITIZER 1 */
+typedef gpr_atm grpc_millis;
+
+#define GRPC_MILLIS_INF_FUTURE GPR_ATM_MAX
+#define GRPC_MILLIS_INF_PAST GPR_ATM_MIN
/** A workqueue represents a list of work to be executed asynchronously.
Forward declared here to avoid a circular dependency with workqueue.h. */
@@ -36,6 +43,13 @@ typedef struct grpc_combiner grpc_combiner;
should be given to not delete said call/channel from this exec_ctx */
#define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2
+extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
+
+gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
+grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
+grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
+
+namespace grpc_core {
/** Execution context.
* A bag of data that collects information along a callstack.
* Generally created at public API entry points, and passed down as
@@ -56,54 +70,129 @@ typedef struct grpc_combiner grpc_combiner;
* - Instances are always passed as the first argument to a function that
* takes it, and always as a pointer (grpc_exec_ctx is never copied).
*/
-struct grpc_exec_ctx {
- grpc_closure_list closure_list;
- /** currently active combiner: updated only via combiner.c */
- grpc_combiner *active_combiner;
- /** last active combiner in the active combiner list */
- grpc_combiner *last_combiner;
- uintptr_t flags;
- unsigned starting_cpu;
- void *check_ready_to_finish_arg;
- bool (*check_ready_to_finish)(grpc_exec_ctx *exec_ctx, void *arg);
-};
+class ExecCtx {
+ public:
+ /** Default Constructor */
+
+ ExecCtx() : flags_(GRPC_EXEC_CTX_FLAG_IS_FINISHED) { Set(this); }
+
+ /** Parameterised Constructor */
+ ExecCtx(uintptr_t fl) : flags_(fl) { Set(this); }
+
+ /** Destructor */
+ virtual ~ExecCtx() {
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
+ Flush();
+ Set(last_exec_ctx_);
+ }
+
+ /** Disallow copy and assignment operators */
+ ExecCtx(const ExecCtx&) = delete;
+ ExecCtx& operator=(const ExecCtx&) = delete;
+
+ /** Return starting_cpu */
+ unsigned starting_cpu() const { return starting_cpu_; }
+
+ struct CombinerData {
+ /* currently active combiner: updated only via combiner.c */
+ grpc_combiner* active_combiner;
+ /* last active combiner in the active combiner list */
+ grpc_combiner* last_combiner;
+ };
+
+ /** Only to be used by grpc-combiner code */
+ CombinerData* combiner_data() { return &combiner_data_; }
+
+ /** Return pointer to grpc_closure_list */
+ grpc_closure_list* closure_list() { return &closure_list_; }
+
+ /** Return flags */
+ uintptr_t flags() { return flags_; }
+
+ /** Checks if there is work to be done */
+ bool HasWork() {
+ return combiner_data_.active_combiner != nullptr ||
+ !grpc_closure_list_empty(closure_list_);
+ }
+
+ /** Flush any work that has been enqueued onto this grpc_exec_ctx.
+ * Caller must guarantee that no interfering locks are held.
+ * Returns true if work was performed, false otherwise. */
+ bool Flush();
-/* initializer for grpc_exec_ctx:
- prefer to use GRPC_EXEC_CTX_INIT whenever possible */
-#define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \
- { \
- GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, gpr_cpu_current_cpu(), \
- finish_check_arg, finish_check \
+ /** Returns true if we'd like to leave this execution context as soon as
+possible: useful for deciding whether to do something more or not depending
+on outside context */
+ bool IsReadyToFinish() {
+ if ((flags_ & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
+ if (CheckReadyToFinish()) {
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
+ return true;
+ }
+ return false;
+ } else {
+ return true;
+ }
}
-/* initialize an execution context at the top level of an API call into grpc
- (this is safe to use elsewhere, though possibly not as efficient) */
-#define GRPC_EXEC_CTX_INIT \
- GRPC_EXEC_CTX_INITIALIZER(GRPC_EXEC_CTX_FLAG_IS_FINISHED, NULL, NULL)
-
-extern grpc_closure_scheduler *grpc_schedule_on_exec_ctx;
-
-bool grpc_exec_ctx_has_work(grpc_exec_ctx *exec_ctx);
-
-/** Flush any work that has been enqueued onto this grpc_exec_ctx.
- * Caller must guarantee that no interfering locks are held.
- * Returns true if work was performed, false otherwise. */
-bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx);
-/** Finish any pending work for a grpc_exec_ctx. Must be called before
- * the instance is destroyed, or work may be lost. */
-void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx);
-/** Returns true if we'd like to leave this execution context as soon as
- possible: useful for deciding whether to do something more or not depending
- on outside context */
-bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx *exec_ctx);
-/** A finish check that is never ready to finish */
-bool grpc_never_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored);
-/** A finish check that is always ready to finish */
-bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored);
-
-void grpc_exec_ctx_global_init(void);
-
-void grpc_exec_ctx_global_init(void);
-void grpc_exec_ctx_global_shutdown(void);
+ /** Returns the stored current time relative to start if valid,
+ * otherwise refreshes the stored time, sets it valid and returns the new
+ * value */
+ grpc_millis Now();
+
+ /** Invalidates the stored time value. A new time value will be set on calling
+ * Now() */
+ void InvalidateNow() { now_is_valid_ = false; }
+
+ /** To be used only by shutdown code in iomgr */
+ void SetNowIomgrShutdown() {
+ now_ = GRPC_MILLIS_INF_FUTURE;
+ now_is_valid_ = true;
+ }
+
+ /** To be used only for testing.
+ * Sets the now value
+ */
+ void TestOnlySetNow(grpc_millis new_val) {
+ now_ = new_val;
+ now_is_valid_ = true;
+ }
+
+ /** Global initialization for ExecCtx. Called by iomgr */
+ static void GlobalInit(void);
+
+ /** Global shutdown for ExecCtx. Called by iomgr */
+ static void GlobalShutdown(void) { gpr_tls_destroy(&exec_ctx_); }
+
+ /** Gets pointer to current exec_ctx */
+ static ExecCtx* Get() {
+ return reinterpret_cast<ExecCtx*>(gpr_tls_get(&exec_ctx_));
+ }
+
+ protected:
+ /** Check if ready to finish */
+ virtual bool CheckReadyToFinish() { return false; }
+
+ /** Disallow delete on ExecCtx */
+ static void operator delete(void* p) { abort(); }
+
+ private:
+ /** Set exec_ctx_ to exec_ctx */
+ void Set(ExecCtx* exec_ctx) {
+ gpr_tls_set(&exec_ctx_, reinterpret_cast<intptr_t>(exec_ctx));
+ }
+
+ grpc_closure_list closure_list_ = GRPC_CLOSURE_LIST_INIT;
+ CombinerData combiner_data_ = {nullptr, nullptr};
+ uintptr_t flags_;
+ unsigned starting_cpu_ = gpr_cpu_current_cpu();
+
+ bool now_is_valid_ = false;
+ grpc_millis now_ = 0;
+
+ GPR_TLS_CLASS_DECL(exec_ctx_);
+ ExecCtx* last_exec_ctx_ = Get();
+};
+} // namespace grpc_core
#endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */
diff --git a/src/core/lib/iomgr/executor.c b/src/core/lib/iomgr/executor.cc
index 2439f15a8a..835dc9d0f7 100644
--- a/src/core/lib/iomgr/executor.c
+++ b/src/core/lib/iomgr/executor.cc
@@ -29,67 +29,65 @@
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/spinlock.h"
+
+#define MAX_DEPTH 2
typedef struct {
gpr_mu mu;
gpr_cv cv;
grpc_closure_list elems;
+ size_t depth;
bool shutdown;
bool queued_long_job;
gpr_thd_id id;
- grpc_closure_list local_elems;
} thread_state;
-static thread_state *g_thread_state;
+static thread_state* g_thread_state;
static size_t g_max_threads;
static gpr_atm g_cur_threads;
static gpr_spinlock g_adding_thread_lock = GPR_SPINLOCK_STATIC_INITIALIZER;
GPR_TLS_DECL(g_this_thread_state);
-static grpc_tracer_flag executor_trace =
- GRPC_TRACER_INITIALIZER(false, "executor");
+grpc_core::TraceFlag executor_trace(false, "executor");
-static void executor_thread(void *arg);
+static void executor_thread(void* arg);
-static void run_closures(grpc_exec_ctx *exec_ctx, grpc_closure_list *list) {
- int n = 0; // number of closures executed
+static size_t run_closures(grpc_closure_list list) {
+ size_t n = 0;
- while (!grpc_closure_list_empty(*list)) {
- grpc_closure *c = list->head;
- grpc_closure_list_init(list);
- while (c != NULL) {
- grpc_closure *next = c->next_data.next;
- grpc_error *error = c->error_data.error;
- if (GRPC_TRACER_ON(executor_trace)) {
+ grpc_closure* c = list.head;
+ while (c != nullptr) {
+ grpc_closure* next = c->next_data.next;
+ grpc_error* error = c->error_data.error;
+ if (executor_trace.enabled()) {
#ifndef NDEBUG
- gpr_log(GPR_DEBUG, "EXECUTOR: run %p [created by %s:%d]", c,
- c->file_created, c->line_created);
+ gpr_log(GPR_DEBUG, "EXECUTOR: run %p [created by %s:%d]", c,
+ c->file_created, c->line_created);
#else
- gpr_log(GPR_DEBUG, "EXECUTOR: run %p", c);
+ gpr_log(GPR_DEBUG, "EXECUTOR: run %p", c);
#endif
- }
+ }
#ifndef NDEBUG
- c->scheduled = false;
+ c->scheduled = false;
#endif
- n++;
- c->cb(exec_ctx, c->cb_arg, error);
- GRPC_ERROR_UNREF(error);
- c = next;
- grpc_exec_ctx_flush(exec_ctx);
- }
+ c->cb(c->cb_arg, error);
+ GRPC_ERROR_UNREF(error);
+ c = next;
+ n++;
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_STATS_INC_EXECUTOR_CLOSURES_PER_WAKEUP(exec_ctx, n);
+ return n;
}
bool grpc_executor_is_threaded() {
return gpr_atm_no_barrier_load(&g_cur_threads) > 0;
}
-void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool threading) {
+void grpc_executor_set_threading(bool threading) {
gpr_atm cur_threads = gpr_atm_no_barrier_load(&g_cur_threads);
if (threading) {
if (cur_threads > 0) return;
@@ -97,17 +95,17 @@ void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool threading) {
gpr_atm_no_barrier_store(&g_cur_threads, 1);
gpr_tls_init(&g_this_thread_state);
g_thread_state =
- (thread_state *)gpr_zalloc(sizeof(thread_state) * g_max_threads);
+ (thread_state*)gpr_zalloc(sizeof(thread_state) * g_max_threads);
for (size_t i = 0; i < g_max_threads; i++) {
gpr_mu_init(&g_thread_state[i].mu);
gpr_cv_init(&g_thread_state[i].cv);
- g_thread_state[i].elems = (grpc_closure_list)GRPC_CLOSURE_LIST_INIT;
+ g_thread_state[i].elems = GRPC_CLOSURE_LIST_INIT;
}
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&g_thread_state[0].id, executor_thread, &g_thread_state[0],
- &opt);
+ gpr_thd_new(&g_thread_state[0].id, "grpc_executor", executor_thread,
+ &g_thread_state[0], &opt);
} else {
if (cur_threads == 0) return;
for (size_t i = 0; i < g_max_threads; i++) {
@@ -127,81 +125,72 @@ void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool threading) {
for (size_t i = 0; i < g_max_threads; i++) {
gpr_mu_destroy(&g_thread_state[i].mu);
gpr_cv_destroy(&g_thread_state[i].cv);
- run_closures(exec_ctx, &g_thread_state[i].elems);
+ run_closures(g_thread_state[i].elems);
}
gpr_free(g_thread_state);
gpr_tls_destroy(&g_this_thread_state);
}
}
-void grpc_executor_init(grpc_exec_ctx *exec_ctx) {
- grpc_register_tracer(&executor_trace);
+void grpc_executor_init() {
gpr_atm_no_barrier_store(&g_cur_threads, 0);
- grpc_executor_set_threading(exec_ctx, true);
+ grpc_executor_set_threading(true);
}
-void grpc_executor_shutdown(grpc_exec_ctx *exec_ctx) {
- grpc_executor_set_threading(exec_ctx, false);
-}
+void grpc_executor_shutdown() { grpc_executor_set_threading(false); }
-static void executor_thread(void *arg) {
- thread_state *ts = (thread_state *)arg;
+static void executor_thread(void* arg) {
+ thread_state* ts = (thread_state*)arg;
gpr_tls_set(&g_this_thread_state, (intptr_t)ts);
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
-
- GRPC_STATS_INC_EXECUTOR_THREADS_CREATED(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx(0);
- bool used = false;
+ size_t subtract_depth = 0;
for (;;) {
- if (GRPC_TRACER_ON(executor_trace)) {
- gpr_log(GPR_DEBUG, "EXECUTOR[%d]: step", (int)(ts - g_thread_state));
+ if (executor_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "EXECUTOR[%d]: step (sub_depth=%" PRIdPTR ")",
+ (int)(ts - g_thread_state), subtract_depth);
}
gpr_mu_lock(&ts->mu);
+ ts->depth -= subtract_depth;
while (grpc_closure_list_empty(ts->elems) && !ts->shutdown) {
ts->queued_long_job = false;
- gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
if (ts->shutdown) {
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
gpr_log(GPR_DEBUG, "EXECUTOR[%d]: shutdown",
(int)(ts - g_thread_state));
}
gpr_mu_unlock(&ts->mu);
break;
}
- if (!used) {
- GRPC_STATS_INC_EXECUTOR_THREADS_USED(&exec_ctx);
- used = true;
- }
- GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED(&exec_ctx);
- GPR_ASSERT(grpc_closure_list_empty(ts->local_elems));
- ts->local_elems = ts->elems;
- ts->elems = (grpc_closure_list)GRPC_CLOSURE_LIST_INIT;
+ GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED();
+ grpc_closure_list exec = ts->elems;
+ ts->elems = GRPC_CLOSURE_LIST_INIT;
gpr_mu_unlock(&ts->mu);
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
gpr_log(GPR_DEBUG, "EXECUTOR[%d]: execute", (int)(ts - g_thread_state));
}
- run_closures(&exec_ctx, &ts->local_elems);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ subtract_depth = run_closures(exec);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void executor_push(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error, bool is_short) {
+static void executor_push(grpc_closure* closure, grpc_error* error,
+ bool is_short) {
bool retry_push;
if (is_short) {
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS();
} else {
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS();
}
do {
retry_push = false;
size_t cur_thread_count = (size_t)gpr_atm_no_barrier_load(&g_cur_threads);
if (cur_thread_count == 0) {
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
#ifndef NDEBUG
gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p (created %s:%d) inline",
closure, closure->file_created, closure->line_created);
@@ -209,24 +198,22 @@ static void executor_push(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p inline", closure);
#endif
}
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
+ grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(),
+ closure, error);
return;
}
- thread_state *ts = (thread_state *)gpr_tls_get(&g_this_thread_state);
- if (ts == NULL) {
- ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)];
+ thread_state* ts = (thread_state*)gpr_tls_get(&g_this_thread_state);
+ if (ts == nullptr) {
+ ts = &g_thread_state[GPR_HASH_POINTER(grpc_core::ExecCtx::Get(),
+ cur_thread_count)];
} else {
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx);
- if (is_short) {
- grpc_closure_list_append(&ts->local_elems, closure, error);
- return;
- }
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF();
}
- thread_state *orig_ts = ts;
+ thread_state* orig_ts = ts;
bool try_new_thread;
for (;;) {
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
#ifndef NDEBUG
gpr_log(
GPR_DEBUG,
@@ -255,12 +242,13 @@ static void executor_push(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
}
continue;
}
- if (grpc_closure_list_empty(ts->elems)) {
- GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED(exec_ctx);
+ if (grpc_closure_list_empty(ts->elems) && !ts->shutdown) {
+ GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED();
gpr_cv_signal(&ts->cv);
}
grpc_closure_list_append(&ts->elems, closure, error);
- try_new_thread = ts->elems.head != closure &&
+ ts->depth++;
+ try_new_thread = ts->depth > MAX_DEPTH &&
cur_thread_count < g_max_threads && !ts->shutdown;
if (!is_short) ts->queued_long_job = true;
gpr_mu_unlock(&ts->mu);
@@ -273,25 +261,23 @@ static void executor_push(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&g_thread_state[cur_thread_count].id, executor_thread,
- &g_thread_state[cur_thread_count], &opt);
+ gpr_thd_new(&g_thread_state[cur_thread_count].id, "gpr_executor",
+ executor_thread, &g_thread_state[cur_thread_count], &opt);
}
gpr_spinlock_unlock(&g_adding_thread_lock);
}
if (retry_push) {
- GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES();
}
} while (retry_push);
}
-static void executor_push_short(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error) {
- executor_push(exec_ctx, closure, error, true);
+static void executor_push_short(grpc_closure* closure, grpc_error* error) {
+ executor_push(closure, error, true);
}
-static void executor_push_long(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error) {
- executor_push(exec_ctx, closure, error, false);
+static void executor_push_long(grpc_closure* closure, grpc_error* error) {
+ executor_push(closure, error, false);
}
static const grpc_closure_scheduler_vtable executor_vtable_short = {
@@ -303,7 +289,7 @@ static const grpc_closure_scheduler_vtable executor_vtable_long = {
executor_push_long, executor_push_long, "executor"};
static grpc_closure_scheduler executor_scheduler_long = {&executor_vtable_long};
-grpc_closure_scheduler *grpc_executor_scheduler(
+grpc_closure_scheduler* grpc_executor_scheduler(
grpc_executor_job_length length) {
return length == GRPC_EXECUTOR_SHORT ? &executor_scheduler_short
: &executor_scheduler_long;
diff --git a/src/core/lib/iomgr/executor.h b/src/core/lib/iomgr/executor.h
index 0412c02790..e16f11aa21 100644
--- a/src/core/lib/iomgr/executor.h
+++ b/src/core/lib/iomgr/executor.h
@@ -31,18 +31,18 @@ typedef enum {
* This mechanism is meant to outsource work (grpc_closure instances) to a
* thread, for those cases where blocking isn't an option but there isn't a
* non-blocking solution available. */
-void grpc_executor_init(grpc_exec_ctx *exec_ctx);
+void grpc_executor_init();
-grpc_closure_scheduler *grpc_executor_scheduler(grpc_executor_job_length);
+grpc_closure_scheduler* grpc_executor_scheduler(grpc_executor_job_length);
/** Shutdown the executor, running all pending work as part of the call */
-void grpc_executor_shutdown(grpc_exec_ctx *exec_ctx);
+void grpc_executor_shutdown();
/** Is the executor multi-threaded? */
bool grpc_executor_is_threaded();
/* enable/disable threading - must be called after grpc_executor_init and before
grpc_executor_shutdown */
-void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool enable);
+void grpc_executor_set_threading(bool enable);
#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */
diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc
new file mode 100644
index 0000000000..9bfa79219a
--- /dev/null
+++ b/src/core/lib/iomgr/fork_posix.cc
@@ -0,0 +1,89 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_POSIX_FORK
+
+#include <string.h>
+
+#include <grpc/fork.h>
+#include <grpc/support/log.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/fork.h"
+#include "src/core/lib/gpr/thd_internal.h"
+#include "src/core/lib/iomgr/ev_posix.h"
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/iomgr/timer_manager.h"
+#include "src/core/lib/iomgr/wakeup_fd_posix.h"
+#include "src/core/lib/surface/init.h"
+
+/*
+ * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
+ * AROUND VERY SPECIFIC USE CASES.
+ */
+
+void grpc_prefork() {
+ if (!grpc_fork_support_enabled()) {
+ gpr_log(GPR_ERROR,
+ "Fork support not enabled; try running with the "
+ "environment variable GRPC_ENABLE_FORK_SUPPORT=1");
+ return;
+ }
+ if (grpc_is_initialized()) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_timer_manager_set_threading(false);
+ grpc_executor_set_threading(false);
+ grpc_core::ExecCtx::Get()->Flush();
+ if (!gpr_await_threads(
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(3, GPR_TIMESPAN)))) {
+ gpr_log(GPR_ERROR, "gRPC thread still active! Cannot fork!");
+ }
+ }
+}
+
+void grpc_postfork_parent() {
+ if (grpc_is_initialized()) {
+ grpc_timer_manager_set_threading(true);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(true);
+ }
+}
+
+void grpc_postfork_child() {
+ if (grpc_is_initialized()) {
+ grpc_timer_manager_set_threading(true);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(true);
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+}
+
+void grpc_fork_handlers_auto_register() {
+ if (grpc_fork_support_enabled()) {
+#ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
+ pthread_atfork(grpc_prefork, grpc_postfork_parent, grpc_postfork_child);
+#endif // GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
+ }
+}
+
+#endif // GRPC_POSIX_FORK
diff --git a/src/core/lib/iomgr/fork_windows.cc b/src/core/lib/iomgr/fork_windows.cc
new file mode 100644
index 0000000000..f9986f33c7
--- /dev/null
+++ b/src/core/lib/iomgr/fork_windows.cc
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+#ifndef GRPC_POSIX_FORK
+
+#include <grpc/fork.h>
+#include <grpc/support/log.h>
+
+/*
+ * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
+ * AROUND VERY SPECIFIC USE CASES.
+ */
+
+void grpc_prefork() { gpr_log(GPR_ERROR, "Forking not supported on Windows"); }
+
+void grpc_postfork_parent() {}
+
+void grpc_postfork_child() {}
+
+void grpc_fork_handlers_auto_register() {}
+
+#endif // GRPC_POSIX_FORK
diff --git a/src/core/lib/iomgr/gethostname.h b/src/core/lib/iomgr/gethostname.h
index 9c6b9d8d42..9f10b4afa7 100644
--- a/src/core/lib/iomgr/gethostname.h
+++ b/src/core/lib/iomgr/gethostname.h
@@ -21,6 +21,6 @@
// Returns the hostname of the local machine.
// Caller takes ownership of result.
-char *grpc_gethostname();
+char* grpc_gethostname();
#endif /* GRPC_CORE_LIB_IOMGR_GETHOSTNAME_H */
diff --git a/src/core/lib/iomgr/gethostname_fallback.c b/src/core/lib/iomgr/gethostname_fallback.cc
index 6229461568..81e2c7aeec 100644
--- a/src/core/lib/iomgr/gethostname_fallback.c
+++ b/src/core/lib/iomgr/gethostname_fallback.cc
@@ -16,12 +16,13 @@
*
*/
+#include "src/core/lib/iomgr/gethostname.h"
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_GETHOSTNAME_FALLBACK
#include <stddef.h>
-char *grpc_gethostname() { return NULL; }
+char* grpc_gethostname() { return NULL; }
#endif // GRPC_GETHOSTNAME_FALLBACK
diff --git a/src/core/lib/iomgr/gethostname_host_name_max.c b/src/core/lib/iomgr/gethostname_host_name_max.cc
index 4d0511412e..2487160916 100644
--- a/src/core/lib/iomgr/gethostname_host_name_max.c
+++ b/src/core/lib/iomgr/gethostname_host_name_max.cc
@@ -16,6 +16,7 @@
*
*/
+#include "src/core/lib/iomgr/gethostname.h"
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_HOST_NAME_MAX
@@ -25,11 +26,11 @@
#include <grpc/support/alloc.h>
-char *grpc_gethostname() {
- char *hostname = (char *)gpr_malloc(HOST_NAME_MAX);
+char* grpc_gethostname() {
+ char* hostname = (char*)gpr_malloc(HOST_NAME_MAX);
if (gethostname(hostname, HOST_NAME_MAX) != 0) {
gpr_free(hostname);
- return NULL;
+ return nullptr;
}
return hostname;
}
diff --git a/src/core/lib/iomgr/gethostname_sysconf.c b/src/core/lib/iomgr/gethostname_sysconf.cc
index 51bac5d69d..3d74e03338 100644
--- a/src/core/lib/iomgr/gethostname_sysconf.c
+++ b/src/core/lib/iomgr/gethostname_sysconf.cc
@@ -16,6 +16,7 @@
*
*/
+#include "src/core/lib/iomgr/gethostname.h"
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SYSCONF
@@ -24,12 +25,12 @@
#include <grpc/support/alloc.h>
-char *grpc_gethostname() {
+char* grpc_gethostname() {
size_t host_name_max = (size_t)sysconf(_SC_HOST_NAME_MAX);
- char *hostname = (char *)gpr_malloc(host_name_max);
+ char* hostname = (char*)gpr_malloc(host_name_max);
if (gethostname(hostname, host_name_max) != 0) {
gpr_free(hostname);
- return NULL;
+ return nullptr;
}
return hostname;
}
diff --git a/src/core/lib/iomgr/iocp_windows.c b/src/core/lib/iomgr/iocp_windows.cc
index c082179c0b..0b6e6823b3 100644
--- a/src/core/lib/iomgr/iocp_windows.c
+++ b/src/core/lib/iomgr/iocp_windows.cc
@@ -21,11 +21,13 @@
#ifdef GRPC_WINSOCK_SOCKET
#include <winsock2.h>
+#include <limits>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/iomgr/iocp_windows.h"
@@ -40,36 +42,30 @@ static gpr_atm g_custom_events = 0;
static HANDLE g_iocp;
-static DWORD deadline_to_millis_timeout(gpr_timespec deadline,
- gpr_timespec now) {
- gpr_timespec timeout;
- static const int64_t max_spin_polling_us = 10;
- if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
+static DWORD deadline_to_millis_timeout(grpc_millis deadline) {
+ if (deadline == GRPC_MILLIS_INF_FUTURE) {
return INFINITE;
}
- if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros(
- max_spin_polling_us,
- GPR_TIMESPAN))) <= 0) {
- return 0;
- }
- timeout = gpr_time_sub(deadline, now);
- return (DWORD)gpr_time_to_millis(gpr_time_add(
- timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+ if (deadline < now) return 0;
+ grpc_millis timeout = deadline - now;
+ if (timeout > std::numeric_limits<DWORD>::max()) return INFINITE;
+ return static_cast<DWORD>(deadline - now);
}
-grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
- gpr_timespec deadline) {
+grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline) {
BOOL success;
DWORD bytes = 0;
DWORD flags = 0;
ULONG_PTR completion_key;
LPOVERLAPPED overlapped;
- grpc_winsocket *socket;
- grpc_winsocket_callback_info *info;
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
- success = GetQueuedCompletionStatus(
- g_iocp, &bytes, &completion_key, &overlapped,
- deadline_to_millis_timeout(deadline, gpr_now(deadline.clock_type)));
+ grpc_winsocket* socket;
+ grpc_winsocket_callback_info* info;
+ GRPC_STATS_INC_SYSCALL_POLL();
+ success =
+ GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped,
+ deadline_to_millis_timeout(deadline));
+ grpc_core::ExecCtx::Get()->InvalidateNow();
if (success == 0 && overlapped == NULL) {
return GRPC_IOCP_WORK_TIMEOUT;
}
@@ -84,7 +80,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
abort();
}
- socket = (grpc_winsocket *)completion_key;
+ socket = (grpc_winsocket*)completion_key;
if (overlapped == &socket->write_info.overlapped) {
info = &socket->write_info;
} else if (overlapped == &socket->read_info.overlapped) {
@@ -97,7 +93,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
info->bytes_transfered = bytes;
info->wsa_error = success ? 0 : WSAGetLastError();
GPR_ASSERT(overlapped == &info->overlapped);
- grpc_socket_become_ready(exec_ctx, socket, info);
+ grpc_socket_become_ready(socket, info);
return GRPC_IOCP_WORK_WORK;
}
@@ -117,32 +113,32 @@ void grpc_iocp_kick(void) {
}
void grpc_iocp_flush(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_iocp_work_status work_status;
do {
- work_status = grpc_iocp_work(&exec_ctx, gpr_inf_past(GPR_CLOCK_MONOTONIC));
+ work_status = grpc_iocp_work(GRPC_MILLIS_INF_PAST);
} while (work_status == GRPC_IOCP_WORK_KICK ||
- grpc_exec_ctx_flush(&exec_ctx));
+ grpc_core::ExecCtx::Get()->Flush());
}
void grpc_iocp_shutdown(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (gpr_atm_acq_load(&g_custom_events)) {
- grpc_iocp_work(&exec_ctx, gpr_inf_future(GPR_CLOCK_MONOTONIC));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_iocp_work(GRPC_MILLIS_INF_FUTURE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
GPR_ASSERT(CloseHandle(g_iocp));
}
-void grpc_iocp_add_socket(grpc_winsocket *socket) {
+void grpc_iocp_add_socket(grpc_winsocket* socket) {
HANDLE ret;
if (socket->added_to_iocp) return;
ret = CreateIoCompletionPort((HANDLE)socket->socket, g_iocp,
(uintptr_t)socket, 0);
if (!ret) {
- char *utf8_message = gpr_format_message(WSAGetLastError());
+ char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "Unable to add socket to iocp: %s", utf8_message);
gpr_free(utf8_message);
__debugbreak();
diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h
index 9c89e868c5..75b0ff4a92 100644
--- a/src/core/lib/iomgr/iocp_windows.h
+++ b/src/core/lib/iomgr/iocp_windows.h
@@ -21,6 +21,10 @@
#include <grpc/support/sync.h>
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_WINSOCK_SOCKET
+
#include "src/core/lib/iomgr/socket_windows.h"
typedef enum {
@@ -29,12 +33,13 @@ typedef enum {
GRPC_IOCP_WORK_KICK
} grpc_iocp_work_status;
-grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
- gpr_timespec deadline);
+grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline);
void grpc_iocp_init(void);
void grpc_iocp_kick(void);
void grpc_iocp_flush(void);
void grpc_iocp_shutdown(void);
-void grpc_iocp_add_socket(grpc_winsocket *);
+void grpc_iocp_add_socket(grpc_winsocket*);
+
+#endif
#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */
diff --git a/src/core/lib/iomgr/iomgr.c b/src/core/lib/iomgr/iomgr.cc
index f63f190155..4cd0a4f1de 100644
--- a/src/core/lib/iomgr/iomgr.c
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -16,8 +16,11 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include "src/core/lib/iomgr/iomgr.h"
+#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
@@ -28,37 +31,37 @@
#include <grpc/support/thd.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/network_status_tracker.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/timer_manager.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
static gpr_mu g_mu;
static gpr_cv g_rcv;
static int g_shutdown;
static grpc_iomgr_object g_root_object;
-void grpc_iomgr_init(grpc_exec_ctx *exec_ctx) {
+void grpc_iomgr_init() {
+ grpc_core::ExecCtx exec_ctx;
g_shutdown = 0;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_rcv);
- grpc_exec_ctx_global_init();
- grpc_executor_init(exec_ctx);
- grpc_timer_list_init(gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_executor_init();
+ grpc_timer_list_init();
g_root_object.next = g_root_object.prev = &g_root_object;
- g_root_object.name = (char *)"root";
+ g_root_object.name = (char*)"root";
grpc_network_status_init();
grpc_iomgr_platform_init();
}
-void grpc_iomgr_start(grpc_exec_ctx *exec_ctx) { grpc_timer_manager_init(); }
+void grpc_iomgr_start() { grpc_timer_manager_init(); }
static size_t count_objects(void) {
- grpc_iomgr_object *obj;
+ grpc_iomgr_object* obj;
size_t n = 0;
for (obj = g_root_object.next; obj != &g_root_object; obj = obj->next) {
n++;
@@ -66,85 +69,89 @@ static size_t count_objects(void) {
return n;
}
-static void dump_objects(const char *kind) {
- grpc_iomgr_object *obj;
+static void dump_objects(const char* kind) {
+ grpc_iomgr_object* obj;
for (obj = g_root_object.next; obj != &g_root_object; obj = obj->next) {
gpr_log(GPR_DEBUG, "%s OBJECT: %s %p", kind, obj->name, obj);
}
}
-void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx) {
+void grpc_iomgr_shutdown() {
gpr_timespec shutdown_deadline = gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN));
gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
- grpc_timer_manager_shutdown();
- grpc_iomgr_platform_flush();
- grpc_executor_shutdown(exec_ctx);
-
- gpr_mu_lock(&g_mu);
- g_shutdown = 1;
- while (g_root_object.next != &g_root_object) {
- if (gpr_time_cmp(
- gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
- gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
- if (g_root_object.next != &g_root_object) {
- gpr_log(GPR_DEBUG,
- "Waiting for %" PRIuPTR " iomgr objects to be destroyed",
- count_objects());
+ {
+ grpc_timer_manager_shutdown();
+ grpc_iomgr_platform_flush();
+ grpc_executor_shutdown();
+
+ gpr_mu_lock(&g_mu);
+ g_shutdown = 1;
+ while (g_root_object.next != &g_root_object) {
+ if (gpr_time_cmp(
+ gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
+ gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
+ if (g_root_object.next != &g_root_object) {
+ gpr_log(GPR_DEBUG,
+ "Waiting for %" PRIuPTR " iomgr objects to be destroyed",
+ count_objects());
+ }
+ last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
}
- last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
- }
- if (grpc_timer_check(exec_ctx, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL) ==
- GRPC_TIMERS_FIRED) {
- gpr_mu_unlock(&g_mu);
- grpc_exec_ctx_flush(exec_ctx);
- grpc_iomgr_platform_flush();
- gpr_mu_lock(&g_mu);
- continue;
- }
- if (g_root_object.next != &g_root_object) {
- if (grpc_iomgr_abort_on_leaks()) {
- gpr_log(GPR_DEBUG, "Failed to free %" PRIuPTR
- " iomgr objects before shutdown deadline: "
- "memory leaks are likely",
- count_objects());
- dump_objects("LEAKED");
- abort();
+ grpc_core::ExecCtx::Get()->SetNowIomgrShutdown();
+ if (grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED) {
+ gpr_mu_unlock(&g_mu);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_iomgr_platform_flush();
+ gpr_mu_lock(&g_mu);
+ continue;
}
- gpr_timespec short_deadline = gpr_time_add(
- gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(100, GPR_TIMESPAN));
- if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) {
- if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) {
- if (g_root_object.next != &g_root_object) {
- gpr_log(GPR_DEBUG, "Failed to free %" PRIuPTR
- " iomgr objects before shutdown deadline: "
- "memory leaks are likely",
- count_objects());
- dump_objects("LEAKED");
+ if (g_root_object.next != &g_root_object) {
+ if (grpc_iomgr_abort_on_leaks()) {
+ gpr_log(GPR_DEBUG,
+ "Failed to free %" PRIuPTR
+ " iomgr objects before shutdown deadline: "
+ "memory leaks are likely",
+ count_objects());
+ dump_objects("LEAKED");
+ abort();
+ }
+ gpr_timespec short_deadline =
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_millis(100, GPR_TIMESPAN));
+ if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) {
+ if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) >
+ 0) {
+ if (g_root_object.next != &g_root_object) {
+ gpr_log(GPR_DEBUG,
+ "Failed to free %" PRIuPTR
+ " iomgr objects before shutdown deadline: "
+ "memory leaks are likely",
+ count_objects());
+ dump_objects("LEAKED");
+ }
+ break;
}
- break;
}
}
}
+ gpr_mu_unlock(&g_mu);
+ grpc_timer_list_shutdown();
+ grpc_core::ExecCtx::Get()->Flush();
}
- gpr_mu_unlock(&g_mu);
-
- grpc_timer_list_shutdown(exec_ctx);
- grpc_exec_ctx_flush(exec_ctx);
/* ensure all threads have left g_mu */
gpr_mu_lock(&g_mu);
gpr_mu_unlock(&g_mu);
grpc_iomgr_platform_shutdown();
- grpc_exec_ctx_global_shutdown();
grpc_network_status_shutdown();
gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_rcv);
}
-void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name) {
+void grpc_iomgr_register_object(grpc_iomgr_object* obj, const char* name) {
obj->name = gpr_strdup(name);
gpr_mu_lock(&g_mu);
obj->next = &g_root_object;
@@ -153,7 +160,7 @@ void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name) {
gpr_mu_unlock(&g_mu);
}
-void grpc_iomgr_unregister_object(grpc_iomgr_object *obj) {
+void grpc_iomgr_unregister_object(grpc_iomgr_object* obj) {
gpr_mu_lock(&g_mu);
obj->next->prev = obj->prev;
obj->prev->next = obj->next;
@@ -163,7 +170,7 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object *obj) {
}
bool grpc_iomgr_abort_on_leaks(void) {
- char *env = gpr_getenv("GRPC_ABORT_ON_LEAKS");
+ char* env = gpr_getenv("GRPC_ABORT_ON_LEAKS");
bool should_we = gpr_is_true(env);
gpr_free(env);
return should_we;
diff --git a/src/core/lib/iomgr/iomgr.h b/src/core/lib/iomgr/iomgr.h
index e3cd6ebe79..c7cde7ea59 100644
--- a/src/core/lib/iomgr/iomgr.h
+++ b/src/core/lib/iomgr/iomgr.h
@@ -19,17 +19,16 @@
#ifndef GRPC_CORE_LIB_IOMGR_IOMGR_H
#define GRPC_CORE_LIB_IOMGR_IOMGR_H
-#include <grpc/impl/codegen/exec_ctx_fwd.h>
#include "src/core/lib/iomgr/port.h"
/** Initializes the iomgr. */
-void grpc_iomgr_init(grpc_exec_ctx *exec_ctx);
+void grpc_iomgr_init();
/** Starts any background threads for iomgr. */
-void grpc_iomgr_start(grpc_exec_ctx *exec_ctx);
+void grpc_iomgr_start();
/** Signals the intention to shutdown the iomgr. Expects to be able to flush
* exec_ctx. */
-void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx);
+void grpc_iomgr_shutdown();
#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */
diff --git a/src/core/lib/iomgr/iomgr_internal.h b/src/core/lib/iomgr/iomgr_internal.h
index 836d82515d..20b3cb70d0 100644
--- a/src/core/lib/iomgr/iomgr_internal.h
+++ b/src/core/lib/iomgr/iomgr_internal.h
@@ -24,13 +24,13 @@
#include "src/core/lib/iomgr/iomgr.h"
typedef struct grpc_iomgr_object {
- char *name;
- struct grpc_iomgr_object *next;
- struct grpc_iomgr_object *prev;
+ char* name;
+ struct grpc_iomgr_object* next;
+ struct grpc_iomgr_object* prev;
} grpc_iomgr_object;
-void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name);
-void grpc_iomgr_unregister_object(grpc_iomgr_object *obj);
+void grpc_iomgr_register_object(grpc_iomgr_object* obj, const char* name);
+void grpc_iomgr_unregister_object(grpc_iomgr_object* obj);
void grpc_iomgr_platform_init(void);
/** flush any globally queued work from iomgr */
diff --git a/src/core/lib/iomgr/iomgr_posix.c b/src/core/lib/iomgr/iomgr_posix.cc
index f5875a247e..f8f6fe2353 100644
--- a/src/core/lib/iomgr/iomgr_posix.c
+++ b/src/core/lib/iomgr/iomgr_posix.cc
@@ -28,7 +28,6 @@
void grpc_iomgr_platform_init(void) {
grpc_wakeup_fd_global_init();
grpc_event_engine_init();
- grpc_register_tracer(&grpc_tcp_trace);
}
void grpc_iomgr_platform_flush(void) {}
diff --git a/src/core/lib/iomgr/iomgr_uv.c b/src/core/lib/iomgr/iomgr_uv.cc
index df5d23af3b..9614c2e664 100644
--- a/src/core/lib/iomgr/iomgr_uv.c
+++ b/src/core/lib/iomgr/iomgr_uv.cc
@@ -29,12 +29,11 @@
gpr_thd_id g_init_thread;
void grpc_iomgr_platform_init(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_pollset_global_init();
- grpc_register_tracer(&grpc_tcp_trace);
- grpc_executor_set_threading(&exec_ctx, false);
+
+ grpc_executor_set_threading(false);
g_init_thread = gpr_thd_currentid();
- grpc_exec_ctx_finish(&exec_ctx);
}
void grpc_iomgr_platform_flush(void) {}
void grpc_iomgr_platform_shutdown(void) { grpc_pollset_global_shutdown(); }
diff --git a/src/core/lib/iomgr/iomgr_windows.c b/src/core/lib/iomgr/iomgr_windows.cc
index 630370166d..630370166d 100644
--- a/src/core/lib/iomgr/iomgr_windows.c
+++ b/src/core/lib/iomgr/iomgr_windows.cc
diff --git a/src/core/lib/iomgr/is_epollexclusive_available.c b/src/core/lib/iomgr/is_epollexclusive_available.cc
index d08844c0df..08f9cf2b69 100644
--- a/src/core/lib/iomgr/is_epollexclusive_available.c
+++ b/src/core/lib/iomgr/is_epollexclusive_available.cc
@@ -20,7 +20,7 @@
#include "src/core/lib/iomgr/is_epollexclusive_available.h"
-#ifdef GRPC_LINUX_EPOLL
+#ifdef GRPC_LINUX_EPOLL_CREATE1
#include <grpc/support/log.h>
@@ -62,7 +62,7 @@ bool grpc_is_epollexclusive_available(void) {
EPOLLEXCLUSIVE enabled kernels - specifically the combination of
EPOLLONESHOT and EPOLLEXCLUSIVE */
ev.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE | EPOLLONESHOT);
- ev.data.ptr = NULL;
+ ev.data.ptr = nullptr;
if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) {
if (errno != EINVAL) {
if (!logged_why_not) {
diff --git a/src/core/lib/iomgr/is_epollexclusive_available.h b/src/core/lib/iomgr/is_epollexclusive_available.h
index 1d2e133a3b..9ae9c5c191 100644
--- a/src/core/lib/iomgr/is_epollexclusive_available.h
+++ b/src/core/lib/iomgr/is_epollexclusive_available.h
@@ -21,6 +21,14 @@
#include <stdbool.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
bool grpc_is_epollexclusive_available(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */
diff --git a/src/core/lib/iomgr/load_file.c b/src/core/lib/iomgr/load_file.cc
index 0b4d41ea4b..b6586fbc73 100644
--- a/src/core/lib/iomgr/load_file.c
+++ b/src/core/lib/iomgr/load_file.cc
@@ -25,21 +25,21 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/block_annotate.h"
-grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
- grpc_slice *output) {
- unsigned char *contents = NULL;
+grpc_error* grpc_load_file(const char* filename, int add_null_terminator,
+ grpc_slice* output) {
+ unsigned char* contents = nullptr;
size_t contents_size = 0;
grpc_slice result = grpc_empty_slice();
- FILE *file;
+ FILE* file;
size_t bytes_read = 0;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
GRPC_SCHEDULING_START_BLOCKING_REGION;
file = fopen(filename, "rb");
- if (file == NULL) {
+ if (file == nullptr) {
error = GRPC_OS_ERROR(errno, "fopen");
goto end;
}
@@ -47,8 +47,8 @@ grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
/* Converting to size_t on the assumption that it will not fail */
contents_size = (size_t)ftell(file);
fseek(file, 0, SEEK_SET);
- contents = (unsigned char *)gpr_malloc(contents_size +
- (add_null_terminator ? 1 : 0));
+ contents =
+ (unsigned char*)gpr_malloc(contents_size + (add_null_terminator ? 1 : 0));
bytes_read = fread(contents, 1, contents_size, file);
if (bytes_read < contents_size) {
error = GRPC_OS_ERROR(errno, "fread");
@@ -62,9 +62,9 @@ grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
end:
*output = result;
- if (file != NULL) fclose(file);
+ if (file != nullptr) fclose(file);
if (error != GRPC_ERROR_NONE) {
- grpc_error *error_out =
+ grpc_error* error_out =
grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to load file", &error, 1),
GRPC_ERROR_STR_FILENAME,
@@ -73,6 +73,6 @@ end:
GRPC_ERROR_UNREF(error);
error = error_out;
}
- GRPC_SCHEDULING_END_BLOCKING_REGION;
+ GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
return error;
}
diff --git a/src/core/lib/iomgr/load_file.h b/src/core/lib/iomgr/load_file.h
index db1ffb3d63..a7336527ce 100644
--- a/src/core/lib/iomgr/load_file.h
+++ b/src/core/lib/iomgr/load_file.h
@@ -25,17 +25,9 @@
#include "src/core/lib/iomgr/error.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Loads the content of a file into a slice. add_null_terminator will add
a NULL terminator if non-zero. */
-grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
- grpc_slice *slice);
-
-#ifdef __cplusplus
-}
-#endif
+grpc_error* grpc_load_file(const char* filename, int add_null_terminator,
+ grpc_slice* slice);
#endif /* GRPC_CORE_LIB_IOMGR_LOAD_FILE_H */
diff --git a/src/core/lib/iomgr/lockfree_event.c b/src/core/lib/iomgr/lockfree_event.cc
index f967b22ba9..7b194e3db5 100644
--- a/src/core/lib/iomgr/lockfree_event.c
+++ b/src/core/lib/iomgr/lockfree_event.cc
@@ -22,97 +22,103 @@
#include "src/core/lib/debug/trace.h"
-extern grpc_tracer_flag grpc_polling_trace;
+extern grpc_core::TraceFlag grpc_polling_trace;
/* 'state' holds the to call when the fd is readable or writable respectively.
It can contain one of the following values:
- CLOSURE_READY : The fd has an I/O event of interest but there is no
+ kClosureReady : The fd has an I/O event of interest but there is no
closure yet to execute
- CLOSURE_NOT_READY : The fd has no I/O event of interest
+ kClosureNotReady : The fd has no I/O event of interest
closure ptr : The closure to be executed when the fd has an I/O
event of interest
- shutdown_error | FD_SHUTDOWN_BIT :
- 'shutdown_error' field ORed with FD_SHUTDOWN_BIT.
+ shutdown_error | kShutdownBit :
+ 'shutdown_error' field ORed with kShutdownBit.
This indicates that the fd is shutdown. Since all
memory allocations are word-aligned, the lower two
bits of the shutdown_error pointer are always 0. So
- it is safe to OR these with FD_SHUTDOWN_BIT
+ it is safe to OR these with kShutdownBit
Valid state transitions:
- <closure ptr> <-----3------ CLOSURE_NOT_READY ----1----> CLOSURE_READY
+ <closure ptr> <-----3------ kClosureNotReady -----1-------> kClosureReady
| | ^ | ^ | |
| | | | | | |
| +--------------4----------+ 6 +---------2---------------+ |
| | |
| v |
- +-----5-------> [shutdown_error | FD_SHUTDOWN_BIT] <----7---------+
+ +-----5-------> [shutdown_error | kShutdownBit] <-------7---------+
- For 1, 4 : See grpc_lfev_set_ready() function
- For 2, 3 : See grpc_lfev_notify_on() function
- For 5,6,7: See grpc_lfev_set_shutdown() function */
+ For 1, 4 : See SetReady() function
+ For 2, 3 : See NotifyOn() function
+ For 5,6,7: See SetShutdown() function */
-#define CLOSURE_NOT_READY ((gpr_atm)0)
-#define CLOSURE_READY ((gpr_atm)2)
+namespace grpc_core {
-#define FD_SHUTDOWN_BIT ((gpr_atm)1)
+LockfreeEvent::LockfreeEvent() { InitEvent(); }
-void grpc_lfev_init(gpr_atm *state) {
- gpr_atm_no_barrier_store(state, CLOSURE_NOT_READY);
-}
+void LockfreeEvent::InitEvent() {
+ /* Perform an atomic store to start the state machine.
-void grpc_lfev_destroy(gpr_atm *state) {
- gpr_atm curr = gpr_atm_no_barrier_load(state);
- if (curr & FD_SHUTDOWN_BIT) {
- GRPC_ERROR_UNREF((grpc_error *)(curr & ~FD_SHUTDOWN_BIT));
- } else {
- GPR_ASSERT(curr == CLOSURE_NOT_READY || curr == CLOSURE_READY);
- }
+ Note carefully that LockfreeEvent *MAY* be used whilst in a destroyed
+ state, while a file descriptor is on a freelist. In such a state it may
+ be SetReady'd, and so we need to perform an atomic operation here to
+ ensure no races */
+ gpr_atm_no_barrier_store(&state_, kClosureNotReady);
}
-bool grpc_lfev_is_shutdown(gpr_atm *state) {
- gpr_atm curr = gpr_atm_no_barrier_load(state);
- return (curr & FD_SHUTDOWN_BIT) != 0;
+void LockfreeEvent::DestroyEvent() {
+ gpr_atm curr;
+ do {
+ curr = gpr_atm_no_barrier_load(&state_);
+ if (curr & kShutdownBit) {
+ GRPC_ERROR_UNREF((grpc_error*)(curr & ~kShutdownBit));
+ } else {
+ GPR_ASSERT(curr == kClosureNotReady || curr == kClosureReady);
+ }
+ /* we CAS in a shutdown, no error value here. If this event is interacted
+ with post-deletion (see the note in the constructor) we want the bit
+ pattern to prevent error retention in a deleted object */
+ } while (!gpr_atm_no_barrier_cas(&state_, curr,
+ kShutdownBit /* shutdown, no error */));
}
-void grpc_lfev_notify_on(grpc_exec_ctx *exec_ctx, gpr_atm *state,
- grpc_closure *closure, const char *variable) {
+void LockfreeEvent::NotifyOn(grpc_closure* closure) {
while (true) {
- gpr_atm curr = gpr_atm_no_barrier_load(state);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, "lfev_notify_on[%s]: %p curr=%p closure=%p", variable,
- state, (void *)curr, closure);
+ gpr_atm curr = gpr_atm_no_barrier_load(&state_);
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_ERROR, "LockfreeEvent::NotifyOn: %p curr=%p closure=%p", this,
+ (void*)curr, closure);
}
switch (curr) {
- case CLOSURE_NOT_READY: {
- /* CLOSURE_NOT_READY -> <closure>.
+ case kClosureNotReady: {
+ /* kClosureNotReady -> <closure>.
We're guaranteed by API that there's an acquire barrier before here,
so there's no need to double-dip and this can be a release-only.
The release itself pairs with the acquire half of a set_ready full
barrier. */
- if (gpr_atm_rel_cas(state, CLOSURE_NOT_READY, (gpr_atm)closure)) {
+ if (gpr_atm_rel_cas(&state_, kClosureNotReady, (gpr_atm)closure)) {
return; /* Successful. Return */
}
break; /* retry */
}
- case CLOSURE_READY: {
- /* Change the state to CLOSURE_NOT_READY. Schedule the closure if
+ case kClosureReady: {
+ /* Change the state to kClosureNotReady. Schedule the closure if
successful. If not, the state most likely transitioned to shutdown.
We should retry.
This can be a no-barrier cas since the state is being transitioned to
- CLOSURE_NOT_READY; set_ready and set_shutdown do not schedule any
+ kClosureNotReady; set_ready and set_shutdown do not schedule any
closure when transitioning out of CLOSURE_NO_READY state (i.e there
is no other code that needs to 'happen-after' this) */
- if (gpr_atm_no_barrier_cas(state, CLOSURE_READY, CLOSURE_NOT_READY)) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ if (gpr_atm_no_barrier_cas(&state_, kClosureReady, kClosureNotReady)) {
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
return; /* Successful. Return */
}
@@ -123,9 +129,9 @@ void grpc_lfev_notify_on(grpc_exec_ctx *exec_ctx, gpr_atm *state,
/* 'curr' is either a closure or the fd is shutdown(in which case 'curr'
contains a pointer to the shutdown-error). If the fd is shutdown,
schedule the closure with the shutdown error */
- if ((curr & FD_SHUTDOWN_BIT) > 0) {
- grpc_error *shutdown_err = (grpc_error *)(curr & ~FD_SHUTDOWN_BIT);
- GRPC_CLOSURE_SCHED(exec_ctx, closure,
+ if ((curr & kShutdownBit) > 0) {
+ grpc_error* shutdown_err = (grpc_error*)(curr & ~kShutdownBit);
+ GRPC_CLOSURE_SCHED(closure,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"FD Shutdown", &shutdown_err, 1));
return;
@@ -133,7 +139,8 @@ void grpc_lfev_notify_on(grpc_exec_ctx *exec_ctx, gpr_atm *state,
/* There is already a closure!. This indicates a bug in the code */
gpr_log(GPR_ERROR,
- "notify_on called with a previous callback still pending");
+ "LockfreeEvent::NotifyOn: notify_on called with a previous "
+ "callback still pending");
abort();
}
}
@@ -142,22 +149,21 @@ void grpc_lfev_notify_on(grpc_exec_ctx *exec_ctx, gpr_atm *state,
GPR_UNREACHABLE_CODE(return );
}
-bool grpc_lfev_set_shutdown(grpc_exec_ctx *exec_ctx, gpr_atm *state,
- grpc_error *shutdown_err) {
- gpr_atm new_state = (gpr_atm)shutdown_err | FD_SHUTDOWN_BIT;
+bool LockfreeEvent::SetShutdown(grpc_error* shutdown_err) {
+ gpr_atm new_state = (gpr_atm)shutdown_err | kShutdownBit;
while (true) {
- gpr_atm curr = gpr_atm_no_barrier_load(state);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, "lfev_set_shutdown: %p curr=%p err=%s", state,
- (void *)curr, grpc_error_string(shutdown_err));
+ gpr_atm curr = gpr_atm_no_barrier_load(&state_);
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_ERROR, "LockfreeEvent::SetShutdown: %p curr=%p err=%s",
+ &state_, (void*)curr, grpc_error_string(shutdown_err));
}
switch (curr) {
- case CLOSURE_READY:
- case CLOSURE_NOT_READY:
+ case kClosureReady:
+ case kClosureNotReady:
/* Need a full barrier here so that the initial load in notify_on
doesn't need a barrier */
- if (gpr_atm_full_cas(state, curr, new_state)) {
+ if (gpr_atm_full_cas(&state_, curr, new_state)) {
return true; /* early out */
}
break; /* retry */
@@ -166,7 +172,7 @@ bool grpc_lfev_set_shutdown(grpc_exec_ctx *exec_ctx, gpr_atm *state,
/* 'curr' is either a closure or the fd is already shutdown */
/* If fd is already shutdown, we are done */
- if ((curr & FD_SHUTDOWN_BIT) > 0) {
+ if ((curr & kShutdownBit) > 0) {
GRPC_ERROR_UNREF(shutdown_err);
return false;
}
@@ -176,8 +182,8 @@ bool grpc_lfev_set_shutdown(grpc_exec_ctx *exec_ctx, gpr_atm *state,
Needs an acquire to pair with setting the closure (and get a
happens-after on that edge), and a release to pair with anything
loading the shutdown state. */
- if (gpr_atm_full_cas(state, curr, new_state)) {
- GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure *)curr,
+ if (gpr_atm_full_cas(&state_, curr, new_state)) {
+ GRPC_CLOSURE_SCHED((grpc_closure*)curr,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"FD Shutdown", &shutdown_err, 1));
return true;
@@ -193,26 +199,25 @@ bool grpc_lfev_set_shutdown(grpc_exec_ctx *exec_ctx, gpr_atm *state,
GPR_UNREACHABLE_CODE(return false);
}
-void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state,
- const char *variable) {
+void LockfreeEvent::SetReady() {
while (true) {
- gpr_atm curr = gpr_atm_no_barrier_load(state);
+ gpr_atm curr = gpr_atm_no_barrier_load(&state_);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
- gpr_log(GPR_ERROR, "lfev_set_ready[%s]: %p curr=%p", variable, state,
- (void *)curr);
+ if (grpc_polling_trace.enabled()) {
+ gpr_log(GPR_ERROR, "LockfreeEvent::SetReady: %p curr=%p", &state_,
+ (void*)curr);
}
switch (curr) {
- case CLOSURE_READY: {
+ case kClosureReady: {
/* Already ready. We are done here */
return;
}
- case CLOSURE_NOT_READY: {
+ case kClosureNotReady: {
/* No barrier required as we're transitioning to a state that does not
involve a closure */
- if (gpr_atm_no_barrier_cas(state, CLOSURE_NOT_READY, CLOSURE_READY)) {
+ if (gpr_atm_no_barrier_cas(&state_, kClosureNotReady, kClosureReady)) {
return; /* early out */
}
break; /* retry */
@@ -220,15 +225,15 @@ void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state,
default: {
/* 'curr' is either a closure or the fd is shutdown */
- if ((curr & FD_SHUTDOWN_BIT) > 0) {
+ if ((curr & kShutdownBit) > 0) {
/* The fd is shutdown. Do nothing */
return;
}
/* Full cas: acquire pairs with this cas' release in the event of a
spurious set_ready; release pairs with this or the acquire in
notify_on (or set_shutdown) */
- else if (gpr_atm_full_cas(state, curr, CLOSURE_NOT_READY)) {
- GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure *)curr, GRPC_ERROR_NONE);
+ else if (gpr_atm_full_cas(&state_, curr, kClosureNotReady)) {
+ GRPC_CLOSURE_SCHED((grpc_closure*)curr, GRPC_ERROR_NONE);
return;
}
/* else the state changed again (only possible by either a racing
@@ -239,3 +244,5 @@ void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state,
}
}
}
+
+} // namespace grpc_core
diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h
index 6a14a0f3b2..3bd3fd72f1 100644
--- a/src/core/lib/iomgr/lockfree_event.h
+++ b/src/core/lib/iomgr/lockfree_event.h
@@ -25,16 +25,35 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-void grpc_lfev_init(gpr_atm *state);
-void grpc_lfev_destroy(gpr_atm *state);
-bool grpc_lfev_is_shutdown(gpr_atm *state);
-
-void grpc_lfev_notify_on(grpc_exec_ctx *exec_ctx, gpr_atm *state,
- grpc_closure *closure, const char *variable);
-/* Returns true on first successful shutdown */
-bool grpc_lfev_set_shutdown(grpc_exec_ctx *exec_ctx, gpr_atm *state,
- grpc_error *shutdown_err);
-void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state,
- const char *variable);
+namespace grpc_core {
+
+class LockfreeEvent {
+ public:
+ LockfreeEvent();
+
+ LockfreeEvent(const LockfreeEvent&) = delete;
+ LockfreeEvent& operator=(const LockfreeEvent&) = delete;
+
+ // These methods are used to initialize and destroy the internal state. These
+ // cannot be done in constructor and destructor because SetReady may be called
+ // when the event is destroyed and put in a freelist.
+ void InitEvent();
+ void DestroyEvent();
+
+ bool IsShutdown() const {
+ return (gpr_atm_no_barrier_load(&state_) & kShutdownBit) != 0;
+ }
+
+ void NotifyOn(grpc_closure* closure);
+ bool SetShutdown(grpc_error* error);
+ void SetReady();
+
+ private:
+ enum State { kClosureNotReady = 0, kClosureReady = 2, kShutdownBit = 1 };
+
+ gpr_atm state_;
+};
+
+} // namespace grpc_core
#endif /* GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H */
diff --git a/src/core/lib/iomgr/network_status_tracker.c b/src/core/lib/iomgr/network_status_tracker.cc
index 4e5c1d5408..73f8fbf9fb 100644
--- a/src/core/lib/iomgr/network_status_tracker.c
+++ b/src/core/lib/iomgr/network_status_tracker.cc
@@ -16,6 +16,7 @@
*
*/
+#include "src/core/lib/iomgr/network_status_tracker.h"
#include "src/core/lib/iomgr/endpoint.h"
void grpc_network_status_shutdown(void) {}
@@ -26,8 +27,8 @@ void grpc_network_status_init(void) {
void grpc_destroy_network_status_monitor() {}
-void grpc_network_status_register_endpoint(grpc_endpoint *ep) { (void)ep; }
+void grpc_network_status_register_endpoint(grpc_endpoint* ep) { (void)ep; }
-void grpc_network_status_unregister_endpoint(grpc_endpoint *ep) { (void)ep; }
+void grpc_network_status_unregister_endpoint(grpc_endpoint* ep) { (void)ep; }
void grpc_network_status_shutdown_all_endpoints() {}
diff --git a/src/core/lib/iomgr/network_status_tracker.h b/src/core/lib/iomgr/network_status_tracker.h
index c0295c1f74..32244d9b77 100644
--- a/src/core/lib/iomgr/network_status_tracker.h
+++ b/src/core/lib/iomgr/network_status_tracker.h
@@ -23,8 +23,8 @@
void grpc_network_status_init(void);
void grpc_network_status_shutdown(void);
-void grpc_network_status_register_endpoint(grpc_endpoint *ep);
-void grpc_network_status_unregister_endpoint(grpc_endpoint *ep);
+void grpc_network_status_register_endpoint(grpc_endpoint* ep);
+void grpc_network_status_unregister_endpoint(grpc_endpoint* ep);
void grpc_network_status_shutdown_all_endpoints();
#endif /* GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H */
diff --git a/src/core/lib/iomgr/polling_entity.c b/src/core/lib/iomgr/polling_entity.cc
index 8591a5518e..126f6f45d6 100644
--- a/src/core/lib/iomgr/polling_entity.c
+++ b/src/core/lib/iomgr/polling_entity.cc
@@ -22,7 +22,7 @@
#include "src/core/lib/iomgr/polling_entity.h"
grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
- grpc_pollset_set *pollset_set) {
+ grpc_pollset_set* pollset_set) {
grpc_polling_entity pollent;
pollent.pollent.pollset_set = pollset_set;
pollent.tag = GRPC_POLLS_POLLSET_SET;
@@ -30,58 +30,54 @@ grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
}
grpc_polling_entity grpc_polling_entity_create_from_pollset(
- grpc_pollset *pollset) {
+ grpc_pollset* pollset) {
grpc_polling_entity pollent;
pollent.pollent.pollset = pollset;
pollent.tag = GRPC_POLLS_POLLSET;
return pollent;
}
-grpc_pollset *grpc_polling_entity_pollset(grpc_polling_entity *pollent) {
+grpc_pollset* grpc_polling_entity_pollset(grpc_polling_entity* pollent) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
return pollent->pollent.pollset;
}
- return NULL;
+ return nullptr;
}
-grpc_pollset_set *grpc_polling_entity_pollset_set(
- grpc_polling_entity *pollent) {
+grpc_pollset_set* grpc_polling_entity_pollset_set(
+ grpc_polling_entity* pollent) {
if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
return pollent->pollent.pollset_set;
}
- return NULL;
+ return nullptr;
}
-bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent) {
+bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent) {
return pollent->tag == GRPC_POLLS_NONE;
}
-void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_polling_entity *pollent,
- grpc_pollset_set *pss_dst) {
+void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent,
+ grpc_pollset_set* pss_dst) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
- GPR_ASSERT(pollent->pollent.pollset != NULL);
- grpc_pollset_set_add_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
+ GPR_ASSERT(pollent->pollent.pollset != nullptr);
+ grpc_pollset_set_add_pollset(pss_dst, pollent->pollent.pollset);
} else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
- GPR_ASSERT(pollent->pollent.pollset_set != NULL);
- grpc_pollset_set_add_pollset_set(exec_ctx, pss_dst,
- pollent->pollent.pollset_set);
+ GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
+ grpc_pollset_set_add_pollset_set(pss_dst, pollent->pollent.pollset_set);
} else {
gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
abort();
}
}
-void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_polling_entity *pollent,
- grpc_pollset_set *pss_dst) {
+void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent,
+ grpc_pollset_set* pss_dst) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
- GPR_ASSERT(pollent->pollent.pollset != NULL);
- grpc_pollset_set_del_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
+ GPR_ASSERT(pollent->pollent.pollset != nullptr);
+ grpc_pollset_set_del_pollset(pss_dst, pollent->pollent.pollset);
} else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
- GPR_ASSERT(pollent->pollent.pollset_set != NULL);
- grpc_pollset_set_del_pollset_set(exec_ctx, pss_dst,
- pollent->pollent.pollset_set);
+ GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
+ grpc_pollset_set_del_pollset_set(pss_dst, pollent->pollent.pollset_set);
} else {
gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
abort();
diff --git a/src/core/lib/iomgr/polling_entity.h b/src/core/lib/iomgr/polling_entity.h
index a161e1fea6..0102d32c11 100644
--- a/src/core/lib/iomgr/polling_entity.h
+++ b/src/core/lib/iomgr/polling_entity.h
@@ -34,34 +34,33 @@ typedef enum grpc_pollset_tag {
typedef struct grpc_polling_entity {
union {
- grpc_pollset *pollset;
- grpc_pollset_set *pollset_set;
+ grpc_pollset* pollset;
+ grpc_pollset_set* pollset_set;
} pollent;
grpc_pollset_tag tag;
} grpc_polling_entity;
grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
- grpc_pollset_set *pollset_set);
+ grpc_pollset_set* pollset_set);
grpc_polling_entity grpc_polling_entity_create_from_pollset(
- grpc_pollset *pollset);
+ grpc_pollset* pollset);
/** If \a pollent contains a pollset, return it. Otherwise, return NULL */
-grpc_pollset *grpc_polling_entity_pollset(grpc_polling_entity *pollent);
+grpc_pollset* grpc_polling_entity_pollset(grpc_polling_entity* pollent);
/** If \a pollent contains a pollset_set, return it. Otherwise, return NULL */
-grpc_pollset_set *grpc_polling_entity_pollset_set(grpc_polling_entity *pollent);
+grpc_pollset_set* grpc_polling_entity_pollset_set(grpc_polling_entity* pollent);
-bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent);
+bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent);
/** Add the pollset or pollset_set in \a pollent to the destination pollset_set
* \a * pss_dst */
-void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_polling_entity *pollent,
- grpc_pollset_set *pss_dst);
+void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent,
+ grpc_pollset_set* pss_dst);
/** Delete the pollset or pollset_set in \a pollent from the destination
* pollset_set \a * pss_dst */
-void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_polling_entity *pollent,
- grpc_pollset_set *pss_dst);
+void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent,
+ grpc_pollset_set* pss_dst);
+
#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */
diff --git a/src/core/lib/iomgr/pollset.h b/src/core/lib/iomgr/pollset.h
index a0f6b3a9d3..6bb3cd3e0c 100644
--- a/src/core/lib/iomgr/pollset.h
+++ b/src/core/lib/iomgr/pollset.h
@@ -25,9 +25,7 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_fd_refcount;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount;
/* A grpc_pollset is a set of file descriptors that a higher level item is
interested in. For example:
@@ -41,12 +39,11 @@ typedef struct grpc_pollset_worker grpc_pollset_worker;
size_t grpc_pollset_size(void);
/* Initialize a pollset: assumes *pollset contains all zeros */
-void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu);
+void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu);
/* Begin shutting down the pollset, and call closure when done.
* pollset's mutex must be held */
-void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure);
-void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset);
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure);
+void grpc_pollset_destroy(grpc_pollset* pollset);
/* Do some work on a pollset.
May involve invoking asynchronous callbacks, or actually polling file
@@ -70,14 +67,14 @@ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset);
May call grpc_closure_list_run on grpc_closure_list, without holding the
pollset
lock */
-grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker, gpr_timespec now,
- gpr_timespec deadline) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker,
+ grpc_millis deadline) GRPC_MUST_USE_RESULT;
/* Break one polling thread out of polling work for this pollset.
If specific_worker is non-NULL, then kick that worker. */
-grpc_error *grpc_pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker)
+grpc_error* grpc_pollset_kick(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker)
GRPC_MUST_USE_RESULT;
#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_H */
diff --git a/src/core/lib/iomgr/pollset_set.h b/src/core/lib/iomgr/pollset_set.h
index 29c0f03561..a94d0afe75 100644
--- a/src/core/lib/iomgr/pollset_set.h
+++ b/src/core/lib/iomgr/pollset_set.h
@@ -28,20 +28,15 @@
typedef struct grpc_pollset_set grpc_pollset_set;
-grpc_pollset_set *grpc_pollset_set_create(void);
-void grpc_pollset_set_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set);
-void grpc_pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset);
-void grpc_pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *pollset_set,
- grpc_pollset *pollset);
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item);
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_pollset_set *bag,
- grpc_pollset_set *item);
+grpc_pollset_set* grpc_pollset_set_create(void);
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set);
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset);
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
+ grpc_pollset* pollset);
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item);
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
+ grpc_pollset_set* item);
#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */
diff --git a/src/core/lib/iomgr/pollset_set_uv.c b/src/core/lib/iomgr/pollset_set_uv.cc
index 90186edbb7..ac5dade8a5 100644
--- a/src/core/lib/iomgr/pollset_set_uv.c
+++ b/src/core/lib/iomgr/pollset_set_uv.cc
@@ -26,23 +26,18 @@ grpc_pollset_set* grpc_pollset_set_create(void) {
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-void grpc_pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set) {}
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
-void grpc_pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/pollset_set_windows.c b/src/core/lib/iomgr/pollset_set_windows.cc
index 2105a47ad4..85edc9dee1 100644
--- a/src/core/lib/iomgr/pollset_set_windows.c
+++ b/src/core/lib/iomgr/pollset_set_windows.cc
@@ -27,23 +27,18 @@ grpc_pollset_set* grpc_pollset_set_create(void) {
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-void grpc_pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set) {}
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
-void grpc_pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
#endif /* GRPC_WINSOCK_SOCKET */
diff --git a/src/core/lib/iomgr/pollset_uv.c b/src/core/lib/iomgr/pollset_uv.cc
index 2651325e25..d9e5ad81be 100644
--- a/src/core/lib/iomgr/pollset_uv.c
+++ b/src/core/lib/iomgr/pollset_uv.cc
@@ -34,13 +34,10 @@
#include "src/core/lib/debug/trace.h"
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_fd_refcount =
- GRPC_TRACER_INITIALIZER(false, "fd_refcount");
-#endif
+grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount");
struct grpc_pollset {
- uv_timer_t timer;
+ uv_timer_t* timer;
int shutting_down;
};
@@ -55,17 +52,17 @@ gpr_mu grpc_polling_mu;
immediately in the next loop iteration.
Note: In the future, if there is a bug that involves missing wakeups in the
future, try adding a uv_async_t to kick the loop differently */
-uv_timer_t *dummy_uv_handle;
+uv_timer_t* dummy_uv_handle;
size_t grpc_pollset_size() { return sizeof(grpc_pollset); }
-void dummy_timer_cb(uv_timer_t *handle) {}
+void dummy_timer_cb(uv_timer_t* handle) {}
-void dummy_handle_close_cb(uv_handle_t *handle) { gpr_free(handle); }
+void dummy_handle_close_cb(uv_handle_t* handle) { gpr_free(handle); }
void grpc_pollset_global_init(void) {
gpr_mu_init(&grpc_polling_mu);
- dummy_uv_handle = gpr_malloc(sizeof(uv_timer_t));
+ dummy_uv_handle = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
uv_timer_init(uv_default_loop(), dummy_uv_handle);
grpc_pollset_work_run_loop = 1;
}
@@ -73,22 +70,25 @@ void grpc_pollset_global_init(void) {
void grpc_pollset_global_shutdown(void) {
GRPC_UV_ASSERT_SAME_THREAD();
gpr_mu_destroy(&grpc_polling_mu);
- uv_close((uv_handle_t *)dummy_uv_handle, dummy_handle_close_cb);
+ uv_close((uv_handle_t*)dummy_uv_handle, dummy_handle_close_cb);
}
-static void timer_run_cb(uv_timer_t *timer) {}
+static void timer_run_cb(uv_timer_t* timer) {}
-static void timer_close_cb(uv_handle_t *handle) { handle->data = (void *)1; }
+static void timer_close_cb(uv_handle_t* handle) {
+ handle->data = (void*)1;
+ gpr_free(handle);
+}
-void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
+void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
GRPC_UV_ASSERT_SAME_THREAD();
*mu = &grpc_polling_mu;
- uv_timer_init(uv_default_loop(), &pollset->timer);
+ pollset->timer = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
+ uv_timer_init(uv_default_loop(), pollset->timer);
pollset->shutting_down = 0;
}
-void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_ASSERT(!pollset->shutting_down);
GRPC_UV_ASSERT_SAME_THREAD();
pollset->shutting_down = 1;
@@ -99,54 +99,55 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
// kick the loop once
uv_timer_start(dummy_uv_handle, dummy_timer_cb, 0, 0);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
-void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
+void grpc_pollset_destroy(grpc_pollset* pollset) {
GRPC_UV_ASSERT_SAME_THREAD();
- uv_close((uv_handle_t *)&pollset->timer, timer_close_cb);
+ uv_close((uv_handle_t*)pollset->timer, timer_close_cb);
// timer.data is a boolean indicating that the timer has finished closing
- pollset->timer.data = (void *)0;
+ pollset->timer->data = (void*)0;
if (grpc_pollset_work_run_loop) {
- while (!pollset->timer.data) {
+ while (!pollset->timer->data) {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
}
}
-grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker_hdl,
- gpr_timespec now, gpr_timespec deadline) {
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
uint64_t timeout;
GRPC_UV_ASSERT_SAME_THREAD();
gpr_mu_unlock(&grpc_polling_mu);
if (grpc_pollset_work_run_loop) {
- if (gpr_time_cmp(deadline, now) >= 0) {
- timeout = (uint64_t)gpr_time_to_millis(gpr_time_sub(deadline, now));
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+ if (deadline >= now) {
+ timeout = deadline - now;
} else {
timeout = 0;
}
/* We special-case timeout=0 so that we don't bother with the timer when
the loop won't block anyway */
if (timeout > 0) {
- uv_timer_start(&pollset->timer, timer_run_cb, timeout, 0);
+ uv_timer_start(pollset->timer, timer_run_cb, timeout, 0);
/* Run until there is some I/O activity or the timer triggers. It doesn't
matter which happens */
uv_run(uv_default_loop(), UV_RUN_ONCE);
- uv_timer_stop(&pollset->timer);
+ uv_timer_stop(pollset->timer);
} else {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
}
- if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
- grpc_exec_ctx_flush(exec_ctx);
+ if (!grpc_closure_list_empty(*grpc_core::ExecCtx::Get()->closure_list())) {
+ grpc_core::ExecCtx::Get()->Flush();
}
gpr_mu_lock(&grpc_polling_mu);
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker) {
+grpc_error* grpc_pollset_kick(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker) {
GRPC_UV_ASSERT_SAME_THREAD();
uv_timer_start(dummy_uv_handle, dummy_timer_cb, 0, 0);
return GRPC_ERROR_NONE;
diff --git a/src/core/lib/iomgr/pollset_windows.c b/src/core/lib/iomgr/pollset_windows.cc
index eb295d3eeb..6ef949aad7 100644
--- a/src/core/lib/iomgr/pollset_windows.c
+++ b/src/core/lib/iomgr/pollset_windows.cc
@@ -28,15 +28,12 @@
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_windows.h"
-#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
+#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_fd_refcount =
- GRPC_TRACER_INITIALIZER(false, "fd_refcount");
-#endif
+grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount");
gpr_mu grpc_polling_mu;
-static grpc_pollset_worker *g_active_poller;
+static grpc_pollset_worker* g_active_poller;
static grpc_pollset_worker g_global_root_worker;
void grpc_pollset_global_init(void) {
@@ -49,22 +46,22 @@ void grpc_pollset_global_init(void) {
void grpc_pollset_global_shutdown(void) { gpr_mu_destroy(&grpc_polling_mu); }
-static void remove_worker(grpc_pollset_worker *worker,
+static void remove_worker(grpc_pollset_worker* worker,
grpc_pollset_worker_link_type type) {
worker->links[type].prev->links[type].next = worker->links[type].next;
worker->links[type].next->links[type].prev = worker->links[type].prev;
worker->links[type].next = worker->links[type].prev = worker;
}
-static int has_workers(grpc_pollset_worker *root,
+static int has_workers(grpc_pollset_worker* root,
grpc_pollset_worker_link_type type) {
return root->links[type].next != root;
}
-static grpc_pollset_worker *pop_front_worker(
- grpc_pollset_worker *root, grpc_pollset_worker_link_type type) {
+static grpc_pollset_worker* pop_front_worker(
+ grpc_pollset_worker* root, grpc_pollset_worker_link_type type) {
if (has_workers(root, type)) {
- grpc_pollset_worker *w = root->links[type].next;
+ grpc_pollset_worker* w = root->links[type].next;
remove_worker(w, type);
return w;
} else {
@@ -72,9 +69,9 @@ static grpc_pollset_worker *pop_front_worker(
}
}
-static void push_front_worker(grpc_pollset_worker *root,
+static void push_front_worker(grpc_pollset_worker* root,
grpc_pollset_worker_link_type type,
- grpc_pollset_worker *worker) {
+ grpc_pollset_worker* worker) {
worker->links[type].prev = root;
worker->links[type].next = worker->links[type].prev->links[type].next;
worker->links[type].prev->links[type].next =
@@ -88,29 +85,28 @@ size_t grpc_pollset_size(void) { return sizeof(grpc_pollset); }
set of features for the sake of the rest of grpc. But grpc_pollset_work
won't actually do any polling, and return as quickly as possible. */
-void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
+void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
*mu = &grpc_polling_mu;
pollset->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].next =
pollset->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].prev =
&pollset->root_worker;
}
-void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure) {
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
pollset->shutting_down = 1;
- grpc_pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
+ grpc_pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
if (!pollset->is_iocp_worker) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
} else {
pollset->on_shutdown = closure;
}
}
-void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {}
+void grpc_pollset_destroy(grpc_pollset* pollset) {}
-grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker_hdl,
- gpr_timespec now, gpr_timespec deadline) {
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker_hdl,
+ grpc_millis deadline) {
grpc_pollset_worker worker;
if (worker_hdl) *worker_hdl = &worker;
@@ -124,13 +120,13 @@ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
gpr_cv_init(&worker.cv);
if (!pollset->kicked_without_pollers && !pollset->shutting_down) {
if (g_active_poller == NULL) {
- grpc_pollset_worker *next_worker;
+ grpc_pollset_worker* next_worker;
/* become poller */
pollset->is_iocp_worker = 1;
g_active_poller = &worker;
gpr_mu_unlock(&grpc_polling_mu);
- grpc_iocp_work(exec_ctx, deadline);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_iocp_work(deadline);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);
pollset->is_iocp_worker = 0;
g_active_poller = NULL;
@@ -148,7 +144,7 @@ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
}
if (pollset->shutting_down && pollset->on_shutdown != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->on_shutdown, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pollset->on_shutdown, GRPC_ERROR_NONE);
pollset->on_shutdown = NULL;
}
goto done;
@@ -159,17 +155,20 @@ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
&worker);
added_worker = 1;
while (!worker.kicked) {
- if (gpr_cv_wait(&worker.cv, &grpc_polling_mu, deadline)) {
+ if (gpr_cv_wait(&worker.cv, &grpc_polling_mu,
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) {
+ grpc_core::ExecCtx::Get()->InvalidateNow();
break;
}
+ grpc_core::ExecCtx::Get()->InvalidateNow();
}
} else {
pollset->kicked_without_pollers = 0;
}
done:
- if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
+ if (!grpc_closure_list_empty(*grpc_core::ExecCtx::Get()->closure_list())) {
gpr_mu_unlock(&grpc_polling_mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);
}
if (added_worker) {
@@ -181,8 +180,8 @@ done:
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
- grpc_pollset_worker *specific_worker) {
+grpc_error* grpc_pollset_kick(grpc_pollset* p,
+ grpc_pollset_worker* specific_worker) {
if (specific_worker != NULL) {
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
for (specific_worker =
@@ -209,7 +208,7 @@ grpc_error *grpc_pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
specific_worker =
pop_front_worker(&p->root_worker, GRPC_POLLSET_WORKER_LINK_POLLSET);
if (specific_worker != NULL) {
- grpc_pollset_kick(exec_ctx, p, specific_worker);
+ grpc_pollset_kick(p, specific_worker);
} else if (p->is_iocp_worker) {
grpc_iocp_kick();
} else {
diff --git a/src/core/lib/iomgr/pollset_windows.h b/src/core/lib/iomgr/pollset_windows.h
index 71878c3d30..93fe7d669b 100644
--- a/src/core/lib/iomgr/pollset_windows.h
+++ b/src/core/lib/iomgr/pollset_windows.h
@@ -21,6 +21,9 @@
#include <grpc/support/sync.h>
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_WINSOCK_SOCKET
#include "src/core/lib/iomgr/socket_windows.h"
/* There isn't really any such thing as a pollset under Windows, due to the
@@ -35,8 +38,8 @@ typedef enum {
} grpc_pollset_worker_link_type;
typedef struct grpc_pollset_worker_link {
- struct grpc_pollset_worker *next;
- struct grpc_pollset_worker *prev;
+ struct grpc_pollset_worker* next;
+ struct grpc_pollset_worker* prev;
} grpc_pollset_worker_link;
struct grpc_pollset;
@@ -45,7 +48,7 @@ typedef struct grpc_pollset grpc_pollset;
typedef struct grpc_pollset_worker {
gpr_cv cv;
int kicked;
- struct grpc_pollset *pollset;
+ struct grpc_pollset* pollset;
grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES];
} grpc_pollset_worker;
@@ -54,10 +57,12 @@ struct grpc_pollset {
int kicked_without_pollers;
int is_iocp_worker;
grpc_pollset_worker root_worker;
- grpc_closure *on_shutdown;
+ grpc_closure* on_shutdown;
};
void grpc_pollset_global_init(void);
void grpc_pollset_global_shutdown(void);
+#endif
+
#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */
diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h
index 42033d0ba4..25090898ed 100644
--- a/src/core/lib/iomgr/port.h
+++ b/src/core/lib/iomgr/port.h
@@ -30,12 +30,14 @@
#define GRPC_HAVE_IP_PKTINFO 1
#define GRPC_HAVE_MSG_NOSIGNAL 1
#define GRPC_HAVE_UNIX_SOCKET 1
+#define GRPC_POSIX_FORK 1
#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
#define GRPC_POSIX_SOCKET 1
#define GRPC_POSIX_SOCKETADDR 1
#define GRPC_POSIX_SOCKETUTILS 1
#define GRPC_POSIX_WAKEUP_FD 1
#define GRPC_TIMER_USE_GENERIC 1
+#define GRPC_LINUX_EPOLL 1
#elif defined(GPR_WINDOWS)
#define GRPC_TIMER_USE_GENERIC 1
#define GRPC_WINSOCK_SOCKET 1
@@ -59,14 +61,18 @@
#define GRPC_HAVE_MSG_NOSIGNAL 1
#define GRPC_HAVE_UNIX_SOCKET 1
#define GRPC_LINUX_MULTIPOLL_WITH_EPOLL 1
+#define GRPC_POSIX_FORK 1
#define GRPC_POSIX_HOST_NAME_MAX 1
#define GRPC_POSIX_SOCKET 1
#define GRPC_POSIX_SOCKETADDR 1
#define GRPC_POSIX_WAKEUP_FD 1
#define GRPC_TIMER_USE_GENERIC 1
#ifdef __GLIBC_PREREQ
-#if __GLIBC_PREREQ(2, 9)
+#if __GLIBC_PREREQ(2, 4)
#define GRPC_LINUX_EPOLL 1
+#endif
+#if __GLIBC_PREREQ(2, 9)
+#define GRPC_LINUX_EPOLL_CREATE1 1
#define GRPC_LINUX_EVENTFD 1
#endif
#if __GLIBC_PREREQ(2, 10)
@@ -75,6 +81,7 @@
#endif
#ifndef __GLIBC__
#define GRPC_LINUX_EPOLL 1
+#define GRPC_LINUX_EPOLL_CREATE1 1
#define GRPC_LINUX_EVENTFD 1
#define GRPC_MSG_IOVLEN_TYPE int
#endif
@@ -90,6 +97,7 @@
#define GRPC_HAVE_SO_NOSIGPIPE 1
#define GRPC_HAVE_UNIX_SOCKET 1
#define GRPC_MSG_IOVLEN_TYPE int
+#define GRPC_POSIX_FORK 1
#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
#define GRPC_POSIX_SOCKET 1
#define GRPC_POSIX_SOCKETADDR 1
@@ -103,6 +111,17 @@
#define GRPC_HAVE_IPV6_RECVPKTINFO 1
#define GRPC_HAVE_SO_NOSIGPIPE 1
#define GRPC_HAVE_UNIX_SOCKET 1
+#define GRPC_POSIX_FORK 1
+#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
+#define GRPC_POSIX_SOCKET 1
+#define GRPC_POSIX_SOCKETADDR 1
+#define GRPC_POSIX_SOCKETUTILS 1
+#define GRPC_POSIX_WAKEUP_FD 1
+#define GRPC_TIMER_USE_GENERIC 1
+#elif defined(GPR_OPENBSD)
+#define GRPC_HAVE_IFADDRS 1
+#define GRPC_HAVE_IPV6_RECVPKTINFO 1
+#define GRPC_HAVE_UNIX_SOCKET 1
#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
#define GRPC_POSIX_SOCKET 1
#define GRPC_POSIX_SOCKETADDR 1
diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h
index fe1dd78576..12fc2ed088 100644
--- a/src/core/lib/iomgr/resolve_address.h
+++ b/src/core/lib/iomgr/resolve_address.h
@@ -32,24 +32,23 @@ typedef struct {
typedef struct {
size_t naddrs;
- grpc_resolved_address *addrs;
+ grpc_resolved_address* addrs;
} grpc_resolved_addresses;
/* Asynchronously resolve addr. Use default_port if a port isn't designated
in addr, otherwise use the port in addr. */
/* TODO(ctiller): add a timeout here */
-extern void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *addr,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addresses);
+extern void (*grpc_resolve_address)(const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addresses);
/* Destroy resolved addresses */
-void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addresses);
+void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addresses);
/* Resolve addr in a blocking fashion. Returns NULL on failure. On success,
result must be freed with grpc_resolved_addresses_destroy. */
-extern grpc_error *(*grpc_blocking_resolve_address)(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses);
+extern grpc_error* (*grpc_blocking_resolve_address)(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses);
#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */
diff --git a/src/core/lib/iomgr/resolve_address_posix.c b/src/core/lib/iomgr/resolve_address_posix.cc
index 60cfeebd47..176caee490 100644
--- a/src/core/lib/iomgr/resolve_address_posix.c
+++ b/src/core/lib/iomgr/resolve_address_posix.cc
@@ -33,22 +33,23 @@
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/block_annotate.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/string.h"
-static grpc_error *blocking_resolve_address_impl(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses) {
+static grpc_error* blocking_resolve_address_impl(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses) {
+ grpc_core::ExecCtx exec_ctx;
struct addrinfo hints;
- struct addrinfo *result = NULL, *resp;
- char *host;
- char *port;
+ struct addrinfo *result = nullptr, *resp;
+ char* host;
+ char* port;
int s;
size_t i;
- grpc_error *err;
+ grpc_error* err;
if (name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'x' &&
name[4] == ':' && name[5] != 0) {
@@ -57,14 +58,14 @@ static grpc_error *blocking_resolve_address_impl(
/* parse name, splitting it into host and port parts */
gpr_split_host_port(name, &host, &port);
- if (host == NULL) {
+ if (host == nullptr) {
err = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
goto done;
}
- if (port == NULL) {
- if (default_port == NULL) {
+ if (port == nullptr) {
+ if (default_port == nullptr) {
err = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
@@ -85,7 +86,7 @@ static grpc_error *blocking_resolve_address_impl(
if (s != 0) {
/* Retry if well-known service name is recognized */
- const char *svc[][2] = {{"http", "80"}, {"https", "443"}};
+ const char* svc[][2] = {{"http", "80"}, {"https", "443"}};
for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
if (strcmp(port, svc[i][0]) == 0) {
GRPC_SCHEDULING_START_BLOCKING_REGION;
@@ -113,15 +114,15 @@ static grpc_error *blocking_resolve_address_impl(
/* Success path: set addrs non-NULL, fill it in */
*addresses =
- (grpc_resolved_addresses *)gpr_malloc(sizeof(grpc_resolved_addresses));
+ (grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses));
(*addresses)->naddrs = 0;
- for (resp = result; resp != NULL; resp = resp->ai_next) {
+ for (resp = result; resp != nullptr; resp = resp->ai_next) {
(*addresses)->naddrs++;
}
- (*addresses)->addrs = (grpc_resolved_address *)gpr_malloc(
+ (*addresses)->addrs = (grpc_resolved_address*)gpr_malloc(
sizeof(grpc_resolved_address) * (*addresses)->naddrs);
i = 0;
- for (resp = result; resp != NULL; resp = resp->ai_next) {
+ for (resp = result; resp != nullptr; resp = resp->ai_next) {
memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
(*addresses)->addrs[i].len = resp->ai_addrlen;
i++;
@@ -137,57 +138,54 @@ done:
return err;
}
-grpc_error *(*grpc_blocking_resolve_address)(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses) = blocking_resolve_address_impl;
+grpc_error* (*grpc_blocking_resolve_address)(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses) = blocking_resolve_address_impl;
typedef struct {
- char *name;
- char *default_port;
- grpc_closure *on_done;
- grpc_resolved_addresses **addrs_out;
+ char* name;
+ char* default_port;
+ grpc_closure* on_done;
+ grpc_resolved_addresses** addrs_out;
grpc_closure request_closure;
- void *arg;
+ void* arg;
} request;
/* Callback to be passed to grpc_executor to asynch-ify
* grpc_blocking_resolve_address */
-static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
- grpc_error *error) {
- request *r = (request *)rp;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->on_done,
- grpc_blocking_resolve_address(r->name, r->default_port, r->addrs_out));
+static void do_request_thread(void* rp, grpc_error* error) {
+ request* r = (request*)rp;
+ GRPC_CLOSURE_SCHED(r->on_done, grpc_blocking_resolve_address(
+ r->name, r->default_port, r->addrs_out));
gpr_free(r->name);
gpr_free(r->default_port);
gpr_free(r);
}
-void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) {
- if (addrs != NULL) {
+void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
+ if (addrs != nullptr) {
gpr_free(addrs->addrs);
}
gpr_free(addrs);
}
-static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {
- request *r = (request *)gpr_malloc(sizeof(request));
+static void resolve_address_impl(const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) {
+ request* r = (request*)gpr_malloc(sizeof(request));
GRPC_CLOSURE_INIT(&r->request_closure, do_request_thread, r,
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT));
r->name = gpr_strdup(name);
r->default_port = gpr_strdup(default_port);
r->on_done = on_done;
r->addrs_out = addrs;
- GRPC_CLOSURE_SCHED(exec_ctx, &r->request_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&r->request_closure, GRPC_ERROR_NONE);
}
void (*grpc_resolve_address)(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
- grpc_pollset_set *interested_parties, grpc_closure *on_done,
- grpc_resolved_addresses **addrs) = resolve_address_impl;
+ const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) = resolve_address_impl;
#endif
diff --git a/src/core/lib/iomgr/resolve_address_uv.c b/src/core/lib/iomgr/resolve_address_uv.cc
index 2d438e8b48..3eab04f3de 100644
--- a/src/core/lib/iomgr/resolve_address_uv.c
+++ b/src/core/lib/iomgr/resolve_address_uv.cc
@@ -38,22 +38,23 @@
#include <string.h>
typedef struct request {
- grpc_closure *on_done;
- grpc_resolved_addresses **addresses;
- struct addrinfo *hints;
- char *host;
- char *port;
+ grpc_closure* on_done;
+ grpc_resolved_addresses** addresses;
+ struct addrinfo* hints;
+ char* host;
+ char* port;
} request;
-static int retry_named_port_failure(int status, request *r,
+static int retry_named_port_failure(int status, request* r,
uv_getaddrinfo_cb getaddrinfo_cb) {
if (status != 0) {
// This loop is copied from resolve_address_posix.c
- char *svc[][2] = {{"http", "80"}, {"https", "443"}};
+ const char* svc[][2] = {{"http", "80"}, {"https", "443"}};
for (size_t i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
if (strcmp(r->port, svc[i][0]) == 0) {
int retry_status;
- uv_getaddrinfo_t *req = gpr_malloc(sizeof(uv_getaddrinfo_t));
+ uv_getaddrinfo_t* req =
+ (uv_getaddrinfo_t*)gpr_malloc(sizeof(uv_getaddrinfo_t));
req->data = r;
r->port = gpr_strdup(svc[i][1]);
retry_status = uv_getaddrinfo(uv_default_loop(), req, getaddrinfo_cb,
@@ -72,12 +73,12 @@ static int retry_named_port_failure(int status, request *r,
return 1;
}
-static grpc_error *handle_addrinfo_result(int status, struct addrinfo *result,
- grpc_resolved_addresses **addresses) {
- struct addrinfo *resp;
+static grpc_error* handle_addrinfo_result(int status, struct addrinfo* result,
+ grpc_resolved_addresses** addresses) {
+ struct addrinfo* resp;
size_t i;
if (status != 0) {
- grpc_error *error;
+ grpc_error* error;
*addresses = NULL;
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("getaddrinfo failed");
error =
@@ -85,13 +86,14 @@ static grpc_error *handle_addrinfo_result(int status, struct addrinfo *result,
grpc_slice_from_static_string(uv_strerror(status)));
return error;
}
- (*addresses) = gpr_malloc(sizeof(grpc_resolved_addresses));
+ (*addresses) =
+ (grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses));
(*addresses)->naddrs = 0;
for (resp = result; resp != NULL; resp = resp->ai_next) {
(*addresses)->naddrs++;
}
- (*addresses)->addrs =
- gpr_malloc(sizeof(grpc_resolved_address) * (*addresses)->naddrs);
+ (*addresses)->addrs = (grpc_resolved_address*)gpr_malloc(
+ sizeof(grpc_resolved_address) * (*addresses)->naddrs);
i = 0;
for (resp = result; resp != NULL; resp = resp->ai_next) {
memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
@@ -101,7 +103,7 @@ static grpc_error *handle_addrinfo_result(int status, struct addrinfo *result,
{
for (i = 0; i < (*addresses)->naddrs; i++) {
- char *buf;
+ char* buf;
grpc_sockaddr_to_string(&buf, &(*addresses)->addrs[i], 0);
gpr_free(buf);
}
@@ -109,13 +111,13 @@ static grpc_error *handle_addrinfo_result(int status, struct addrinfo *result,
return GRPC_ERROR_NONE;
}
-static void getaddrinfo_callback(uv_getaddrinfo_t *req, int status,
- struct addrinfo *res) {
- request *r = (request *)req->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_error *error;
+static void getaddrinfo_callback(uv_getaddrinfo_t* req, int status,
+ struct addrinfo* res) {
+ request* r = (request*)req->data;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_error* error;
int retry_status;
- char *port = r->port;
+ char* port = r->port;
gpr_free(req);
retry_status = retry_named_port_failure(status, r, getaddrinfo_callback);
@@ -128,8 +130,8 @@ static void getaddrinfo_callback(uv_getaddrinfo_t *req, int status,
/* Either no retry was attempted, or the retry failed. Either way, the
original error probably has more interesting information */
error = handle_addrinfo_result(status, res, r->addresses);
- GRPC_CLOSURE_SCHED(&exec_ctx, r->on_done, error);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(r->on_done, error);
+
gpr_free(r->hints);
gpr_free(r->host);
gpr_free(r->port);
@@ -137,14 +139,14 @@ static void getaddrinfo_callback(uv_getaddrinfo_t *req, int status,
uv_freeaddrinfo(res);
}
-static grpc_error *try_split_host_port(const char *name,
- const char *default_port, char **host,
- char **port) {
+static grpc_error* try_split_host_port(const char* name,
+ const char* default_port, char** host,
+ char** port) {
/* parse name, splitting it into host and port parts */
- grpc_error *error;
+ grpc_error* error;
gpr_split_host_port(name, host, port);
if (*host == NULL) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "unparseable host:port: '%s'", name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
@@ -153,7 +155,7 @@ static grpc_error *try_split_host_port(const char *name,
if (*port == NULL) {
// TODO(murgatroid99): add tests for this case
if (default_port == NULL) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "no port in name '%s'", name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
@@ -164,16 +166,17 @@ static grpc_error *try_split_host_port(const char *name,
return GRPC_ERROR_NONE;
}
-static grpc_error *blocking_resolve_address_impl(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses) {
- char *host;
- char *port;
+static grpc_error* blocking_resolve_address_impl(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses) {
+ char* host;
+ char* port;
struct addrinfo hints;
uv_getaddrinfo_t req;
int s;
- grpc_error *err;
+ grpc_error* err;
int retry_status;
+ request r;
GRPC_UV_ASSERT_SAME_THREAD();
@@ -191,8 +194,10 @@ static grpc_error *blocking_resolve_address_impl(
hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */
s = uv_getaddrinfo(uv_default_loop(), &req, NULL, host, port, &hints);
- request r = {
- .addresses = addresses, .hints = &hints, .host = host, .port = port};
+ r.addresses = addresses;
+ r.hints = &hints;
+ r.host = host;
+ r.port = port;
retry_status = retry_named_port_failure(s, &r, NULL);
if (retry_status <= 0) {
s = retry_status;
@@ -208,47 +213,46 @@ done:
return err;
}
-grpc_error *(*grpc_blocking_resolve_address)(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses) = blocking_resolve_address_impl;
+grpc_error* (*grpc_blocking_resolve_address)(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses) = blocking_resolve_address_impl;
-void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) {
+void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
if (addrs != NULL) {
gpr_free(addrs->addrs);
}
gpr_free(addrs);
}
-static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {
- uv_getaddrinfo_t *req = NULL;
- request *r = NULL;
- struct addrinfo *hints = NULL;
- char *host = NULL;
- char *port = NULL;
- grpc_error *err;
+static void resolve_address_impl(const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) {
+ uv_getaddrinfo_t* req = NULL;
+ request* r = NULL;
+ struct addrinfo* hints = NULL;
+ char* host = NULL;
+ char* port = NULL;
+ grpc_error* err;
int s;
GRPC_UV_ASSERT_SAME_THREAD();
err = try_split_host_port(name, default_port, &host, &port);
if (err != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, err);
+ GRPC_CLOSURE_SCHED(on_done, err);
gpr_free(host);
gpr_free(port);
return;
}
- r = gpr_malloc(sizeof(request));
+ r = (request*)gpr_malloc(sizeof(request));
r->on_done = on_done;
r->addresses = addrs;
r->host = host;
r->port = port;
- req = gpr_malloc(sizeof(uv_getaddrinfo_t));
+ req = (uv_getaddrinfo_t*)gpr_malloc(sizeof(uv_getaddrinfo_t));
req->data = r;
/* Call getaddrinfo */
- hints = gpr_malloc(sizeof(struct addrinfo));
+ hints = (addrinfo*)gpr_malloc(sizeof(struct addrinfo));
memset(hints, 0, sizeof(struct addrinfo));
hints->ai_family = AF_UNSPEC; /* ipv4 or ipv6 */
hints->ai_socktype = SOCK_STREAM; /* stream socket */
@@ -263,7 +267,7 @@ static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("getaddrinfo failed");
err = grpc_error_set_str(err, GRPC_ERROR_STR_OS_ERROR,
grpc_slice_from_static_string(uv_strerror(s)));
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, err);
+ GRPC_CLOSURE_SCHED(on_done, err);
gpr_free(r);
gpr_free(req);
gpr_free(hints);
@@ -273,8 +277,8 @@ static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
}
void (*grpc_resolve_address)(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
- grpc_pollset_set *interested_parties, grpc_closure *on_done,
- grpc_resolved_addresses **addrs) = resolve_address_impl;
+ const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) = resolve_address_impl;
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.cc
index 0cb0029f4e..e44ab396b3 100644
--- a/src/core/lib/iomgr/resolve_address_windows.c
+++ b/src/core/lib/iomgr/resolve_address_windows.cc
@@ -23,6 +23,7 @@
#include "src/core/lib/iomgr/resolve_address.h"
+#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
@@ -33,35 +34,36 @@
#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/block_annotate.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/block_annotate.h"
-#include "src/core/lib/support/string.h"
typedef struct {
- char *name;
- char *default_port;
+ char* name;
+ char* default_port;
grpc_closure request_closure;
- grpc_closure *on_done;
- grpc_resolved_addresses **addresses;
+ grpc_closure* on_done;
+ grpc_resolved_addresses** addresses;
} request;
-static grpc_error *blocking_resolve_address_impl(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses) {
+static grpc_error* blocking_resolve_address_impl(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses) {
+ grpc_core::ExecCtx exec_ctx;
struct addrinfo hints;
struct addrinfo *result = NULL, *resp;
- char *host;
- char *port;
+ char* host;
+ char* port;
int s;
size_t i;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
/* parse name, splitting it into host and port parts */
gpr_split_host_port(name, &host, &port);
if (host == NULL) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "unparseable host:port: '%s'", name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
@@ -69,7 +71,7 @@ static grpc_error *blocking_resolve_address_impl(
}
if (port == NULL) {
if (default_port == NULL) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "no port in name '%s'", name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
@@ -93,13 +95,14 @@ static grpc_error *blocking_resolve_address_impl(
}
/* Success path: set addrs non-NULL, fill it in */
- (*addresses) = gpr_malloc(sizeof(grpc_resolved_addresses));
+ (*addresses) =
+ (grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses));
(*addresses)->naddrs = 0;
for (resp = result; resp != NULL; resp = resp->ai_next) {
(*addresses)->naddrs++;
}
- (*addresses)->addrs =
- gpr_malloc(sizeof(grpc_resolved_address) * (*addresses)->naddrs);
+ (*addresses)->addrs = (grpc_resolved_address*)gpr_malloc(
+ sizeof(grpc_resolved_address) * (*addresses)->naddrs);
i = 0;
for (resp = result; resp != NULL; resp = resp->ai_next) {
memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
@@ -109,7 +112,7 @@ static grpc_error *blocking_resolve_address_impl(
{
for (i = 0; i < (*addresses)->naddrs; i++) {
- char *buf;
+ char* buf;
grpc_sockaddr_to_string(&buf, &(*addresses)->addrs[i], 0);
gpr_free(buf);
}
@@ -124,52 +127,50 @@ done:
return error;
}
-grpc_error *(*grpc_blocking_resolve_address)(
- const char *name, const char *default_port,
- grpc_resolved_addresses **addresses) = blocking_resolve_address_impl;
+grpc_error* (*grpc_blocking_resolve_address)(
+ const char* name, const char* default_port,
+ grpc_resolved_addresses** addresses) = blocking_resolve_address_impl;
/* Callback to be passed to grpc_executor to asynch-ify
* grpc_blocking_resolve_address */
-static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
- grpc_error *error) {
- request *r = rp;
+static void do_request_thread(void* rp, grpc_error* error) {
+ request* r = (request*)rp;
if (error == GRPC_ERROR_NONE) {
error =
grpc_blocking_resolve_address(r->name, r->default_port, r->addresses);
} else {
GRPC_ERROR_REF(error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, error);
+ GRPC_CLOSURE_SCHED(r->on_done, error);
gpr_free(r->name);
gpr_free(r->default_port);
gpr_free(r);
}
-void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) {
+void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
if (addrs != NULL) {
gpr_free(addrs->addrs);
}
gpr_free(addrs);
}
-static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addresses) {
- request *r = gpr_malloc(sizeof(request));
+static void resolve_address_impl(const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addresses) {
+ request* r = (request*)gpr_malloc(sizeof(request));
GRPC_CLOSURE_INIT(&r->request_closure, do_request_thread, r,
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT));
r->name = gpr_strdup(name);
r->default_port = gpr_strdup(default_port);
r->on_done = on_done;
r->addresses = addresses;
- GRPC_CLOSURE_SCHED(exec_ctx, &r->request_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&r->request_closure, GRPC_ERROR_NONE);
}
void (*grpc_resolve_address)(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
- grpc_pollset_set *interested_parties, grpc_closure *on_done,
- grpc_resolved_addresses **addresses) = resolve_address_impl;
+ const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_resolved_addresses** addresses) = resolve_address_impl;
#endif
diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.cc
index 4d69986fbc..eaf2f5d1b2 100644
--- a/src/core/lib/iomgr/resource_quota.c
+++ b/src/core/lib/iomgr/resource_quota.cc
@@ -18,6 +18,7 @@
#include "src/core/lib/iomgr/resource_quota.h"
+#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
@@ -30,15 +31,14 @@
#include "src/core/lib/iomgr/combiner.h"
-grpc_tracer_flag grpc_resource_quota_trace =
- GRPC_TRACER_INITIALIZER(false, "resource_quota");
+grpc_core::TraceFlag grpc_resource_quota_trace(false, "resource_quota");
#define MEMORY_USAGE_ESTIMATION_MAX 65536
/* Internal linked list pointers for a resource user */
typedef struct {
- grpc_resource_user *next;
- grpc_resource_user *prev;
+ grpc_resource_user* next;
+ grpc_resource_user* prev;
} grpc_resource_user_link;
/* Resource users are kept in (potentially) several intrusive linked lists
@@ -59,7 +59,7 @@ typedef enum {
struct grpc_resource_user {
/* The quota this resource user consumes from */
- grpc_resource_quota *resource_quota;
+ grpc_resource_quota* resource_quota;
/* Closure to schedule an allocation under the resource quota combiner lock */
grpc_closure allocate_closure;
@@ -88,16 +88,18 @@ struct grpc_resource_user {
grpc_closure_list on_allocated;
/* True if we are currently trying to allocate from the quota, false if not */
bool allocating;
+ /* How many bytes of allocations are outstanding */
+ int64_t outstanding_allocations;
/* True if we are currently trying to add ourselves to the non-free quota
list, false otherwise */
bool added_to_free_pool;
/* Reclaimers: index 0 is the benign reclaimer, 1 is the destructive reclaimer
*/
- grpc_closure *reclaimers[2];
+ grpc_closure* reclaimers[2];
/* Reclaimers just posted: once we're in the combiner lock, we'll move them
to the array above */
- grpc_closure *new_reclaimers[2];
+ grpc_closure* new_reclaimers[2];
/* Trampoline closures to finish reclamation and re-enter the quota combiner
lock */
grpc_closure post_reclaimer_closure[2];
@@ -110,7 +112,7 @@ struct grpc_resource_user {
grpc_resource_user_link links[GRPC_RULIST_COUNT];
/* The name of this resource user, for debugging/tracing */
- char *name;
+ char* name;
};
struct grpc_resource_quota {
@@ -123,7 +125,7 @@ struct grpc_resource_quota {
/* Master combiner lock: all activity on a quota executes under this combiner
* (so no mutex is needed for this data structure) */
- grpc_combiner *combiner;
+ grpc_combiner* combiner;
/* Size of the resource quota */
int64_t size;
/* Amount of free memory in the resource quota */
@@ -143,24 +145,26 @@ struct grpc_resource_quota {
/* This is only really usable for debugging: it's always a stale pointer, but
a stale pointer that might just be fresh enough to guide us to where the
reclamation system is stuck */
- grpc_closure *debug_only_last_initiated_reclaimer;
- grpc_resource_user *debug_only_last_reclaimer_resource_user;
+ grpc_closure* debug_only_last_initiated_reclaimer;
+ grpc_resource_user* debug_only_last_reclaimer_resource_user;
/* Roots of all resource user lists */
- grpc_resource_user *roots[GRPC_RULIST_COUNT];
+ grpc_resource_user* roots[GRPC_RULIST_COUNT];
- char *name;
+ char* name;
};
+static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount);
+
/*******************************************************************************
* list management
*/
-static void rulist_add_head(grpc_resource_user *resource_user,
+static void rulist_add_head(grpc_resource_user* resource_user,
grpc_rulist list) {
- grpc_resource_quota *resource_quota = resource_user->resource_quota;
- grpc_resource_user **root = &resource_quota->roots[list];
- if (*root == NULL) {
+ grpc_resource_quota* resource_quota = resource_user->resource_quota;
+ grpc_resource_user** root = &resource_quota->roots[list];
+ if (*root == nullptr) {
*root = resource_user;
resource_user->links[list].next = resource_user->links[list].prev =
resource_user;
@@ -173,11 +177,11 @@ static void rulist_add_head(grpc_resource_user *resource_user,
}
}
-static void rulist_add_tail(grpc_resource_user *resource_user,
+static void rulist_add_tail(grpc_resource_user* resource_user,
grpc_rulist list) {
- grpc_resource_quota *resource_quota = resource_user->resource_quota;
- grpc_resource_user **root = &resource_quota->roots[list];
- if (*root == NULL) {
+ grpc_resource_quota* resource_quota = resource_user->resource_quota;
+ grpc_resource_user** root = &resource_quota->roots[list];
+ if (*root == nullptr) {
*root = resource_user;
resource_user->links[list].next = resource_user->links[list].prev =
resource_user;
@@ -189,20 +193,20 @@ static void rulist_add_tail(grpc_resource_user *resource_user,
}
}
-static bool rulist_empty(grpc_resource_quota *resource_quota,
+static bool rulist_empty(grpc_resource_quota* resource_quota,
grpc_rulist list) {
- return resource_quota->roots[list] == NULL;
+ return resource_quota->roots[list] == nullptr;
}
-static grpc_resource_user *rulist_pop_head(grpc_resource_quota *resource_quota,
+static grpc_resource_user* rulist_pop_head(grpc_resource_quota* resource_quota,
grpc_rulist list) {
- grpc_resource_user **root = &resource_quota->roots[list];
- grpc_resource_user *resource_user = *root;
- if (resource_user == NULL) {
- return NULL;
+ grpc_resource_user** root = &resource_quota->roots[list];
+ grpc_resource_user* resource_user = *root;
+ if (resource_user == nullptr) {
+ return nullptr;
}
if (resource_user->links[list].next == resource_user) {
- *root = NULL;
+ *root = nullptr;
} else {
resource_user->links[list].next->links[list].prev =
resource_user->links[list].prev;
@@ -210,70 +214,65 @@ static grpc_resource_user *rulist_pop_head(grpc_resource_quota *resource_quota,
resource_user->links[list].next;
*root = resource_user->links[list].next;
}
- resource_user->links[list].next = resource_user->links[list].prev = NULL;
+ resource_user->links[list].next = resource_user->links[list].prev = nullptr;
return resource_user;
}
-static void rulist_remove(grpc_resource_user *resource_user, grpc_rulist list) {
- if (resource_user->links[list].next == NULL) return;
- grpc_resource_quota *resource_quota = resource_user->resource_quota;
+static void rulist_remove(grpc_resource_user* resource_user, grpc_rulist list) {
+ if (resource_user->links[list].next == nullptr) return;
+ grpc_resource_quota* resource_quota = resource_user->resource_quota;
if (resource_quota->roots[list] == resource_user) {
resource_quota->roots[list] = resource_user->links[list].next;
if (resource_quota->roots[list] == resource_user) {
- resource_quota->roots[list] = NULL;
+ resource_quota->roots[list] = nullptr;
}
}
resource_user->links[list].next->links[list].prev =
resource_user->links[list].prev;
resource_user->links[list].prev->links[list].next =
resource_user->links[list].next;
- resource_user->links[list].next = resource_user->links[list].prev = NULL;
+ resource_user->links[list].next = resource_user->links[list].prev = nullptr;
}
/*******************************************************************************
* resource quota state machine
*/
-static bool rq_alloc(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota);
+static bool rq_alloc(grpc_resource_quota* resource_quota);
static bool rq_reclaim_from_per_user_free_pool(
- grpc_exec_ctx *exec_ctx, grpc_resource_quota *resource_quota);
-static bool rq_reclaim(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota, bool destructive);
+ grpc_resource_quota* resource_quota);
+static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive);
-static void rq_step(grpc_exec_ctx *exec_ctx, void *rq, grpc_error *error) {
- grpc_resource_quota *resource_quota = (grpc_resource_quota *)rq;
+static void rq_step(void* rq, grpc_error* error) {
+ grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
resource_quota->step_scheduled = false;
do {
- if (rq_alloc(exec_ctx, resource_quota)) goto done;
- } while (rq_reclaim_from_per_user_free_pool(exec_ctx, resource_quota));
+ if (rq_alloc(resource_quota)) goto done;
+ } while (rq_reclaim_from_per_user_free_pool(resource_quota));
- if (!rq_reclaim(exec_ctx, resource_quota, false)) {
- rq_reclaim(exec_ctx, resource_quota, true);
+ if (!rq_reclaim(resource_quota, false)) {
+ rq_reclaim(resource_quota, true);
}
done:
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
-static void rq_step_sched(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota) {
+static void rq_step_sched(grpc_resource_quota* resource_quota) {
if (resource_quota->step_scheduled) return;
resource_quota->step_scheduled = true;
grpc_resource_quota_ref_internal(resource_quota);
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_quota->rq_step_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&resource_quota->rq_step_closure, GRPC_ERROR_NONE);
}
/* update the atomically available resource estimate - use no barriers since
timeliness of delivery really doesn't matter much */
-static void rq_update_estimate(grpc_resource_quota *resource_quota) {
+static void rq_update_estimate(grpc_resource_quota* resource_quota) {
gpr_atm memory_usage_estimation = MEMORY_USAGE_ESTIMATION_MAX;
if (resource_quota->size != 0) {
memory_usage_estimation =
- GPR_CLAMP((gpr_atm)((1.0 -
- ((double)resource_quota->free_pool) /
- ((double)resource_quota->size)) *
+ GPR_CLAMP((gpr_atm)((1.0 - ((double)resource_quota->free_pool) /
+ ((double)resource_quota->size)) *
MEMORY_USAGE_ESTIMATION_MAX),
0, MEMORY_USAGE_ESTIMATION_MAX);
}
@@ -282,32 +281,53 @@ static void rq_update_estimate(grpc_resource_quota *resource_quota) {
}
/* returns true if all allocations are completed */
-static bool rq_alloc(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota) {
- grpc_resource_user *resource_user;
+static bool rq_alloc(grpc_resource_quota* resource_quota) {
+ grpc_resource_user* resource_user;
while ((resource_user = rulist_pop_head(resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION))) {
gpr_mu_lock(&resource_user->mu);
+ if (grpc_resource_quota_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "RQ: check allocation for user %p shutdown=%" PRIdPTR
+ " free_pool=%" PRId64,
+ resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown),
+ resource_user->free_pool);
+ }
+ if (gpr_atm_no_barrier_load(&resource_user->shutdown)) {
+ resource_user->allocating = false;
+ grpc_closure_list_fail_all(
+ &resource_user->on_allocated,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource user shutdown"));
+ int64_t aborted_allocations = resource_user->outstanding_allocations;
+ resource_user->outstanding_allocations = 0;
+ resource_user->free_pool += aborted_allocations;
+ GRPC_CLOSURE_LIST_SCHED(&resource_user->on_allocated);
+ gpr_mu_unlock(&resource_user->mu);
+ ru_unref_by(resource_user, (gpr_atm)aborted_allocations);
+ continue;
+ }
if (resource_user->free_pool < 0 &&
-resource_user->free_pool <= resource_quota->free_pool) {
int64_t amt = -resource_user->free_pool;
resource_user->free_pool = 0;
resource_quota->free_pool -= amt;
rq_update_estimate(resource_quota);
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
- gpr_log(GPR_DEBUG, "RQ %s %s: grant alloc %" PRId64
- " bytes; rq_free_pool -> %" PRId64,
+ if (grpc_resource_quota_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "RQ %s %s: grant alloc %" PRId64
+ " bytes; rq_free_pool -> %" PRId64,
resource_quota->name, resource_user->name, amt,
resource_quota->free_pool);
}
- } else if (GRPC_TRACER_ON(grpc_resource_quota_trace) &&
+ } else if (grpc_resource_quota_trace.enabled() &&
resource_user->free_pool >= 0) {
gpr_log(GPR_DEBUG, "RQ %s %s: discard already satisfied alloc request",
resource_quota->name, resource_user->name);
}
if (resource_user->free_pool >= 0) {
resource_user->allocating = false;
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated);
+ resource_user->outstanding_allocations = 0;
+ GRPC_CLOSURE_LIST_SCHED(&resource_user->on_allocated);
gpr_mu_unlock(&resource_user->mu);
} else {
rulist_add_head(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
@@ -320,8 +340,8 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx,
/* returns true if any memory could be reclaimed from buffers */
static bool rq_reclaim_from_per_user_free_pool(
- grpc_exec_ctx *exec_ctx, grpc_resource_quota *resource_quota) {
- grpc_resource_user *resource_user;
+ grpc_resource_quota* resource_quota) {
+ grpc_resource_user* resource_user;
while ((resource_user = rulist_pop_head(resource_quota,
GRPC_RULIST_NON_EMPTY_FREE_POOL))) {
gpr_mu_lock(&resource_user->mu);
@@ -330,9 +350,10 @@ static bool rq_reclaim_from_per_user_free_pool(
resource_user->free_pool = 0;
resource_quota->free_pool += amt;
rq_update_estimate(resource_quota);
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
- gpr_log(GPR_DEBUG, "RQ %s %s: reclaim_from_per_user_free_pool %" PRId64
- " bytes; rq_free_pool -> %" PRId64,
+ if (grpc_resource_quota_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "RQ %s %s: reclaim_from_per_user_free_pool %" PRId64
+ " bytes; rq_free_pool -> %" PRId64,
resource_quota->name, resource_user->name, amt,
resource_quota->free_pool);
}
@@ -346,26 +367,25 @@ static bool rq_reclaim_from_per_user_free_pool(
}
/* returns true if reclamation is proceeding */
-static bool rq_reclaim(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota, bool destructive) {
+static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) {
if (resource_quota->reclaiming) return true;
grpc_rulist list = destructive ? GRPC_RULIST_RECLAIMER_DESTRUCTIVE
: GRPC_RULIST_RECLAIMER_BENIGN;
- grpc_resource_user *resource_user = rulist_pop_head(resource_quota, list);
- if (resource_user == NULL) return false;
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list);
+ if (resource_user == nullptr) return false;
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "RQ %s %s: initiate %s reclamation",
resource_quota->name, resource_user->name,
destructive ? "destructive" : "benign");
}
resource_quota->reclaiming = true;
grpc_resource_quota_ref_internal(resource_quota);
- grpc_closure *c = resource_user->reclaimers[destructive];
+ grpc_closure* c = resource_user->reclaimers[destructive];
GPR_ASSERT(c);
resource_quota->debug_only_last_reclaimer_resource_user = resource_user;
resource_quota->debug_only_last_initiated_reclaimer = c;
- resource_user->reclaimers[destructive] = NULL;
- GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_NONE);
+ resource_user->reclaimers[destructive] = nullptr;
+ GRPC_CLOSURE_RUN(c, GRPC_ERROR_NONE);
return true;
}
@@ -376,19 +396,19 @@ static bool rq_reclaim(grpc_exec_ctx *exec_ctx,
typedef struct {
grpc_slice_refcount base;
gpr_refcount refs;
- grpc_resource_user *resource_user;
+ grpc_resource_user* resource_user;
size_t size;
} ru_slice_refcount;
-static void ru_slice_ref(void *p) {
- ru_slice_refcount *rc = (ru_slice_refcount *)p;
+static void ru_slice_ref(void* p) {
+ ru_slice_refcount* rc = (ru_slice_refcount*)p;
gpr_ref(&rc->refs);
}
-static void ru_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
- ru_slice_refcount *rc = (ru_slice_refcount *)p;
+static void ru_slice_unref(void* p) {
+ ru_slice_refcount* rc = (ru_slice_refcount*)p;
if (gpr_unref(&rc->refs)) {
- grpc_resource_user_free(exec_ctx, rc->resource_user, rc->size);
+ grpc_resource_user_free(rc->resource_user, rc->size);
gpr_free(rc);
}
}
@@ -397,10 +417,10 @@ static const grpc_slice_refcount_vtable ru_slice_vtable = {
ru_slice_ref, ru_slice_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
-static grpc_slice ru_slice_create(grpc_resource_user *resource_user,
+static grpc_slice ru_slice_create(grpc_resource_user* resource_user,
size_t size) {
- ru_slice_refcount *rc =
- (ru_slice_refcount *)gpr_malloc(sizeof(ru_slice_refcount) + size);
+ ru_slice_refcount* rc =
+ (ru_slice_refcount*)gpr_malloc(sizeof(ru_slice_refcount) + size);
rc->base.vtable = &ru_slice_vtable;
rc->base.sub_refcount = &rc->base;
gpr_ref_init(&rc->refs, 1);
@@ -408,7 +428,7 @@ static grpc_slice ru_slice_create(grpc_resource_user *resource_user,
rc->size = size;
grpc_slice slice;
slice.refcount = &rc->base;
- slice.data.refcounted.bytes = (uint8_t *)(rc + 1);
+ slice.data.refcounted.bytes = (uint8_t*)(rc + 1);
slice.data.refcounted.length = size;
return slice;
}
@@ -418,61 +438,57 @@ static grpc_slice ru_slice_create(grpc_resource_user *resource_user,
* the combiner
*/
-static void ru_allocate(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) {
- grpc_resource_user *resource_user = (grpc_resource_user *)ru;
+static void ru_allocate(void* ru, grpc_error* error) {
+ grpc_resource_user* resource_user = (grpc_resource_user*)ru;
if (rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
}
-static void ru_add_to_free_pool(grpc_exec_ctx *exec_ctx, void *ru,
- grpc_error *error) {
- grpc_resource_user *resource_user = (grpc_resource_user *)ru;
+static void ru_add_to_free_pool(void* ru, grpc_error* error) {
+ grpc_resource_user* resource_user = (grpc_resource_user*)ru;
if (!rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_NON_EMPTY_FREE_POOL)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_NON_EMPTY_FREE_POOL);
}
-static bool ru_post_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user,
+static bool ru_post_reclaimer(grpc_resource_user* resource_user,
bool destructive) {
- grpc_closure *closure = resource_user->new_reclaimers[destructive];
- GPR_ASSERT(closure != NULL);
- resource_user->new_reclaimers[destructive] = NULL;
- GPR_ASSERT(resource_user->reclaimers[destructive] == NULL);
+ grpc_closure* closure = resource_user->new_reclaimers[destructive];
+ GPR_ASSERT(closure != nullptr);
+ resource_user->new_reclaimers[destructive] = nullptr;
+ GPR_ASSERT(resource_user->reclaimers[destructive] == nullptr);
if (gpr_atm_acq_load(&resource_user->shutdown) > 0) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CANCELLED);
return false;
}
resource_user->reclaimers[destructive] = closure;
return true;
}
-static void ru_post_benign_reclaimer(grpc_exec_ctx *exec_ctx, void *ru,
- grpc_error *error) {
- grpc_resource_user *resource_user = (grpc_resource_user *)ru;
- if (!ru_post_reclaimer(exec_ctx, resource_user, false)) return;
+static void ru_post_benign_reclaimer(void* ru, grpc_error* error) {
+ grpc_resource_user* resource_user = (grpc_resource_user*)ru;
+ if (!ru_post_reclaimer(resource_user, false)) return;
if (!rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_NON_EMPTY_FREE_POOL) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_RECLAIMER_BENIGN)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
}
-static void ru_post_destructive_reclaimer(grpc_exec_ctx *exec_ctx, void *ru,
- grpc_error *error) {
- grpc_resource_user *resource_user = (grpc_resource_user *)ru;
- if (!ru_post_reclaimer(exec_ctx, resource_user, true)) return;
+static void ru_post_destructive_reclaimer(void* ru, grpc_error* error) {
+ grpc_resource_user* resource_user = (grpc_resource_user*)ru;
+ if (!ru_post_reclaimer(resource_user, true)) return;
if (!rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION) &&
rulist_empty(resource_user->resource_quota,
@@ -481,47 +497,50 @@ static void ru_post_destructive_reclaimer(grpc_exec_ctx *exec_ctx, void *ru,
GRPC_RULIST_RECLAIMER_BENIGN) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_RECLAIMER_DESTRUCTIVE)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
}
-static void ru_shutdown(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) {
- grpc_resource_user *resource_user = (grpc_resource_user *)ru;
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[0],
- GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1],
- GRPC_ERROR_CANCELLED);
- resource_user->reclaimers[0] = NULL;
- resource_user->reclaimers[1] = NULL;
+static void ru_shutdown(void* ru, grpc_error* error) {
+ if (grpc_resource_quota_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "RU shutdown %p", ru);
+ }
+ grpc_resource_user* resource_user = (grpc_resource_user*)ru;
+ gpr_mu_lock(&resource_user->mu);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[0], GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[1], GRPC_ERROR_CANCELLED);
+ resource_user->reclaimers[0] = nullptr;
+ resource_user->reclaimers[1] = nullptr;
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
+ if (resource_user->allocating) {
+ rq_step_sched(resource_user->resource_quota);
+ }
+ gpr_mu_unlock(&resource_user->mu);
}
-static void ru_destroy(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) {
- grpc_resource_user *resource_user = (grpc_resource_user *)ru;
+static void ru_destroy(void* ru, grpc_error* error) {
+ grpc_resource_user* resource_user = (grpc_resource_user*)ru;
GPR_ASSERT(gpr_atm_no_barrier_load(&resource_user->refs) == 0);
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
rulist_remove(resource_user, (grpc_rulist)i);
}
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[0],
- GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1],
- GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[0], GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[1], GRPC_ERROR_CANCELLED);
if (resource_user->free_pool != 0) {
resource_user->resource_quota->free_pool += resource_user->free_pool;
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
- grpc_resource_quota_unref_internal(exec_ctx, resource_user->resource_quota);
+ grpc_resource_quota_unref_internal(resource_user->resource_quota);
gpr_mu_destroy(&resource_user->mu);
gpr_free(resource_user->name);
gpr_free(resource_user);
}
-static void ru_allocated_slices(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_resource_user_slice_allocator *slice_allocator =
- (grpc_resource_user_slice_allocator *)arg;
+static void ru_allocated_slices(void* arg, grpc_error* error) {
+ grpc_resource_user_slice_allocator* slice_allocator =
+ (grpc_resource_user_slice_allocator*)arg;
if (error == GRPC_ERROR_NONE) {
for (size_t i = 0; i < slice_allocator->count; i++) {
grpc_slice_buffer_add_indexed(
@@ -529,7 +548,7 @@ static void ru_allocated_slices(grpc_exec_ctx *exec_ctx, void *arg,
slice_allocator->length));
}
}
- GRPC_CLOSURE_RUN(exec_ctx, &slice_allocator->on_done, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(&slice_allocator->on_done, GRPC_ERROR_REF(error));
}
/*******************************************************************************
@@ -539,27 +558,26 @@ static void ru_allocated_slices(grpc_exec_ctx *exec_ctx, void *arg,
typedef struct {
int64_t size;
- grpc_resource_quota *resource_quota;
+ grpc_resource_quota* resource_quota;
grpc_closure closure;
} rq_resize_args;
-static void rq_resize(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) {
- rq_resize_args *a = (rq_resize_args *)args;
+static void rq_resize(void* args, grpc_error* error) {
+ rq_resize_args* a = (rq_resize_args*)args;
int64_t delta = a->size - a->resource_quota->size;
a->resource_quota->size += delta;
a->resource_quota->free_pool += delta;
rq_update_estimate(a->resource_quota);
- rq_step_sched(exec_ctx, a->resource_quota);
- grpc_resource_quota_unref_internal(exec_ctx, a->resource_quota);
+ rq_step_sched(a->resource_quota);
+ grpc_resource_quota_unref_internal(a->resource_quota);
gpr_free(a);
}
-static void rq_reclamation_done(grpc_exec_ctx *exec_ctx, void *rq,
- grpc_error *error) {
- grpc_resource_quota *resource_quota = (grpc_resource_quota *)rq;
+static void rq_reclamation_done(void* rq, grpc_error* error) {
+ grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
resource_quota->reclaiming = false;
- rq_step_sched(exec_ctx, resource_quota);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ rq_step_sched(resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
/*******************************************************************************
@@ -567,9 +585,9 @@ static void rq_reclamation_done(grpc_exec_ctx *exec_ctx, void *rq,
*/
/* Public API */
-grpc_resource_quota *grpc_resource_quota_create(const char *name) {
- grpc_resource_quota *resource_quota =
- (grpc_resource_quota *)gpr_malloc(sizeof(*resource_quota));
+grpc_resource_quota* grpc_resource_quota_create(const char* name) {
+ grpc_resource_quota* resource_quota =
+ (grpc_resource_quota*)gpr_malloc(sizeof(*resource_quota));
gpr_ref_init(&resource_quota->refs, 1);
resource_quota->combiner = grpc_combiner_create();
resource_quota->free_pool = INT64_MAX;
@@ -578,7 +596,7 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) {
resource_quota->step_scheduled = false;
resource_quota->reclaiming = false;
gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, 0);
- if (name != NULL) {
+ if (name != nullptr) {
resource_quota->name = gpr_strdup(name);
} else {
gpr_asprintf(&resource_quota->name, "anonymous_pool_%" PRIxPTR,
@@ -590,60 +608,57 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) {
rq_reclamation_done, resource_quota,
grpc_combiner_scheduler(resource_quota->combiner));
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
- resource_quota->roots[i] = NULL;
+ resource_quota->roots[i] = nullptr;
}
return resource_quota;
}
-void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota) {
+void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota) {
if (gpr_unref(&resource_quota->refs)) {
- GRPC_COMBINER_UNREF(exec_ctx, resource_quota->combiner, "resource_quota");
+ GRPC_COMBINER_UNREF(resource_quota->combiner, "resource_quota");
gpr_free(resource_quota->name);
gpr_free(resource_quota);
}
}
/* Public API */
-void grpc_resource_quota_unref(grpc_resource_quota *resource_quota) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_finish(&exec_ctx);
+void grpc_resource_quota_unref(grpc_resource_quota* resource_quota) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_quota_unref_internal(resource_quota);
}
-grpc_resource_quota *grpc_resource_quota_ref_internal(
- grpc_resource_quota *resource_quota) {
+grpc_resource_quota* grpc_resource_quota_ref_internal(
+ grpc_resource_quota* resource_quota) {
gpr_ref(&resource_quota->refs);
return resource_quota;
}
/* Public API */
-void grpc_resource_quota_ref(grpc_resource_quota *resource_quota) {
+void grpc_resource_quota_ref(grpc_resource_quota* resource_quota) {
grpc_resource_quota_ref_internal(resource_quota);
}
double grpc_resource_quota_get_memory_pressure(
- grpc_resource_quota *resource_quota) {
+ grpc_resource_quota* resource_quota) {
return ((double)(gpr_atm_no_barrier_load(
&resource_quota->memory_usage_estimation))) /
((double)MEMORY_USAGE_ESTIMATION_MAX);
}
/* Public API */
-void grpc_resource_quota_resize(grpc_resource_quota *resource_quota,
+void grpc_resource_quota_resize(grpc_resource_quota* resource_quota,
size_t size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- rq_resize_args *a = (rq_resize_args *)gpr_malloc(sizeof(*a));
+ grpc_core::ExecCtx exec_ctx;
+ rq_resize_args* a = (rq_resize_args*)gpr_malloc(sizeof(*a));
a->resource_quota = grpc_resource_quota_ref_internal(resource_quota);
a->size = (int64_t)size;
gpr_atm_no_barrier_store(&resource_quota->last_size,
(gpr_atm)GPR_MIN((size_t)GPR_ATM_MAX, size));
GRPC_CLOSURE_INIT(&a->closure, rq_resize, a, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(&exec_ctx, &a->closure, GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&a->closure, GRPC_ERROR_NONE);
}
-size_t grpc_resource_quota_peek_size(grpc_resource_quota *resource_quota) {
+size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota) {
return (size_t)gpr_atm_no_barrier_load(&resource_quota->last_size);
}
@@ -651,33 +666,33 @@ size_t grpc_resource_quota_peek_size(grpc_resource_quota *resource_quota) {
* grpc_resource_user channel args api
*/
-grpc_resource_quota *grpc_resource_quota_from_channel_args(
- const grpc_channel_args *channel_args) {
+grpc_resource_quota* grpc_resource_quota_from_channel_args(
+ const grpc_channel_args* channel_args) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
if (channel_args->args[i].type == GRPC_ARG_POINTER) {
return grpc_resource_quota_ref_internal(
- (grpc_resource_quota *)channel_args->args[i].value.pointer.p);
+ (grpc_resource_quota*)channel_args->args[i].value.pointer.p);
} else {
gpr_log(GPR_DEBUG, GRPC_ARG_RESOURCE_QUOTA " should be a pointer");
}
}
}
- return grpc_resource_quota_create(NULL);
+ return grpc_resource_quota_create(nullptr);
}
-static void *rq_copy(void *rq) {
- grpc_resource_quota_ref((grpc_resource_quota *)rq);
+static void* rq_copy(void* rq) {
+ grpc_resource_quota_ref((grpc_resource_quota*)rq);
return rq;
}
-static void rq_destroy(grpc_exec_ctx *exec_ctx, void *rq) {
- grpc_resource_quota_unref_internal(exec_ctx, (grpc_resource_quota *)rq);
+static void rq_destroy(void* rq) {
+ grpc_resource_quota_unref_internal((grpc_resource_quota*)rq);
}
-static int rq_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
+static int rq_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
-const grpc_arg_pointer_vtable *grpc_resource_quota_arg_vtable(void) {
+const grpc_arg_pointer_vtable* grpc_resource_quota_arg_vtable(void) {
static const grpc_arg_pointer_vtable vtable = {rq_copy, rq_destroy, rq_cmp};
return &vtable;
}
@@ -686,10 +701,10 @@ const grpc_arg_pointer_vtable *grpc_resource_quota_arg_vtable(void) {
* grpc_resource_user api
*/
-grpc_resource_user *grpc_resource_user_create(
- grpc_resource_quota *resource_quota, const char *name) {
- grpc_resource_user *resource_user =
- (grpc_resource_user *)gpr_malloc(sizeof(*resource_user));
+grpc_resource_user* grpc_resource_user_create(
+ grpc_resource_quota* resource_quota, const char* name) {
+ grpc_resource_user* resource_user =
+ (grpc_resource_user*)gpr_malloc(sizeof(*resource_user));
resource_user->resource_quota =
grpc_resource_quota_ref_internal(resource_quota);
GRPC_CLOSURE_INIT(&resource_user->allocate_closure, &ru_allocate,
@@ -713,14 +728,15 @@ grpc_resource_user *grpc_resource_user_create(
grpc_closure_list_init(&resource_user->on_allocated);
resource_user->allocating = false;
resource_user->added_to_free_pool = false;
- resource_user->reclaimers[0] = NULL;
- resource_user->reclaimers[1] = NULL;
- resource_user->new_reclaimers[0] = NULL;
- resource_user->new_reclaimers[1] = NULL;
+ resource_user->reclaimers[0] = nullptr;
+ resource_user->reclaimers[1] = nullptr;
+ resource_user->new_reclaimers[0] = nullptr;
+ resource_user->new_reclaimers[1] = nullptr;
+ resource_user->outstanding_allocations = 0;
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
- resource_user->links[i].next = resource_user->links[i].prev = NULL;
+ resource_user->links[i].next = resource_user->links[i].prev = nullptr;
}
- if (name != NULL) {
+ if (name != nullptr) {
resource_user->name = gpr_strdup(name);
} else {
gpr_asprintf(&resource_user->name, "anonymous_resource_user_%" PRIxPTR,
@@ -729,41 +745,36 @@ grpc_resource_user *grpc_resource_user_create(
return resource_user;
}
-grpc_resource_quota *grpc_resource_user_quota(
- grpc_resource_user *resource_user) {
+grpc_resource_quota* grpc_resource_user_quota(
+ grpc_resource_user* resource_user) {
return resource_user->resource_quota;
}
-static void ru_ref_by(grpc_resource_user *resource_user, gpr_atm amount) {
+static void ru_ref_by(grpc_resource_user* resource_user, gpr_atm amount) {
GPR_ASSERT(amount > 0);
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&resource_user->refs, amount) != 0);
}
-static void ru_unref_by(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user, gpr_atm amount) {
+static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount) {
GPR_ASSERT(amount > 0);
gpr_atm old = gpr_atm_full_fetch_add(&resource_user->refs, -amount);
GPR_ASSERT(old >= amount);
if (old == amount) {
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->destroy_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&resource_user->destroy_closure, GRPC_ERROR_NONE);
}
}
-void grpc_resource_user_ref(grpc_resource_user *resource_user) {
+void grpc_resource_user_ref(grpc_resource_user* resource_user) {
ru_ref_by(resource_user, 1);
}
-void grpc_resource_user_unref(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user) {
- ru_unref_by(exec_ctx, resource_user, 1);
+void grpc_resource_user_unref(grpc_resource_user* resource_user) {
+ ru_unref_by(resource_user, 1);
}
-void grpc_resource_user_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user) {
+void grpc_resource_user_shutdown(grpc_resource_user* resource_user) {
if (gpr_atm_full_fetch_add(&resource_user->shutdown, 1) == 0) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(
ru_shutdown, resource_user,
grpc_combiner_scheduler(resource_user->resource_quota->combiner)),
@@ -771,13 +782,13 @@ void grpc_resource_user_shutdown(grpc_exec_ctx *exec_ctx,
}
}
-void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user, size_t size,
- grpc_closure *optional_on_done) {
+void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
+ grpc_closure* optional_on_done) {
gpr_mu_lock(&resource_user->mu);
ru_ref_by(resource_user, (gpr_atm)size);
resource_user->free_pool -= (int64_t)size;
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ resource_user->outstanding_allocations += (int64_t)size;
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64,
resource_user->resource_quota->name, resource_user->name, size,
resource_user->free_pool);
@@ -787,21 +798,20 @@ void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_NONE);
if (!resource_user->allocating) {
resource_user->allocating = true;
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->allocate_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&resource_user->allocate_closure, GRPC_ERROR_NONE);
}
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, optional_on_done, GRPC_ERROR_NONE);
+ resource_user->outstanding_allocations -= (int64_t)size;
+ GRPC_CLOSURE_SCHED(optional_on_done, GRPC_ERROR_NONE);
}
gpr_mu_unlock(&resource_user->mu);
}
-void grpc_resource_user_free(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user, size_t size) {
+void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
gpr_mu_lock(&resource_user->mu);
bool was_zero_or_negative = resource_user->free_pool <= 0;
resource_user->free_pool += (int64_t)size;
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64,
resource_user->resource_quota->name, resource_user->name, size,
resource_user->free_pool);
@@ -810,38 +820,35 @@ void grpc_resource_user_free(grpc_exec_ctx *exec_ctx,
if (is_bigger_than_zero && was_zero_or_negative &&
!resource_user->added_to_free_pool) {
resource_user->added_to_free_pool = true;
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->add_to_free_pool_closure,
+ GRPC_CLOSURE_SCHED(&resource_user->add_to_free_pool_closure,
GRPC_ERROR_NONE);
}
gpr_mu_unlock(&resource_user->mu);
- ru_unref_by(exec_ctx, resource_user, (gpr_atm)size);
+ ru_unref_by(resource_user, (gpr_atm)size);
}
-void grpc_resource_user_post_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user,
+void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
bool destructive,
- grpc_closure *closure) {
- GPR_ASSERT(resource_user->new_reclaimers[destructive] == NULL);
+ grpc_closure* closure) {
+ GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr);
resource_user->new_reclaimers[destructive] = closure;
- GRPC_CLOSURE_SCHED(exec_ctx,
- &resource_user->post_reclaimer_closure[destructive],
+ GRPC_CLOSURE_SCHED(&resource_user->post_reclaimer_closure[destructive],
GRPC_ERROR_NONE);
}
-void grpc_resource_user_finish_reclamation(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user) {
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete",
resource_user->resource_quota->name, resource_user->name);
}
GRPC_CLOSURE_SCHED(
- exec_ctx, &resource_user->resource_quota->rq_reclamation_done_closure,
+ &resource_user->resource_quota->rq_reclamation_done_closure,
GRPC_ERROR_NONE);
}
void grpc_resource_user_slice_allocator_init(
- grpc_resource_user_slice_allocator *slice_allocator,
- grpc_resource_user *resource_user, grpc_iomgr_cb_func cb, void *p) {
+ grpc_resource_user_slice_allocator* slice_allocator,
+ grpc_resource_user* resource_user, grpc_iomgr_cb_func cb, void* p) {
GRPC_CLOSURE_INIT(&slice_allocator->on_allocated, ru_allocated_slices,
slice_allocator, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&slice_allocator->on_done, cb, p,
@@ -850,19 +857,11 @@ void grpc_resource_user_slice_allocator_init(
}
void grpc_resource_user_alloc_slices(
- grpc_exec_ctx *exec_ctx,
- grpc_resource_user_slice_allocator *slice_allocator, size_t length,
- size_t count, grpc_slice_buffer *dest) {
+ grpc_resource_user_slice_allocator* slice_allocator, size_t length,
+ size_t count, grpc_slice_buffer* dest) {
slice_allocator->length = length;
slice_allocator->count = count;
slice_allocator->dest = dest;
- grpc_resource_user_alloc(exec_ctx, slice_allocator->resource_user,
- count * length, &slice_allocator->on_allocated);
-}
-
-grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user,
- size_t size) {
- grpc_resource_user_alloc(exec_ctx, resource_user, size, NULL);
- return ru_slice_create(resource_user, size);
+ grpc_resource_user_alloc(slice_allocator->resource_user, count * length,
+ &slice_allocator->on_allocated);
}
diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h
index d66f9ae774..39e3aabf18 100644
--- a/src/core/lib/iomgr/resource_quota.h
+++ b/src/core/lib/iomgr/resource_quota.h
@@ -61,60 +61,53 @@
maintain lists of users (which users arrange to leave before they are
destroyed) */
-extern grpc_tracer_flag grpc_resource_quota_trace;
+extern grpc_core::TraceFlag grpc_resource_quota_trace;
-grpc_resource_quota *grpc_resource_quota_ref_internal(
- grpc_resource_quota *resource_quota);
-void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx,
- grpc_resource_quota *resource_quota);
-grpc_resource_quota *grpc_resource_quota_from_channel_args(
- const grpc_channel_args *channel_args);
+grpc_resource_quota* grpc_resource_quota_ref_internal(
+ grpc_resource_quota* resource_quota);
+void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota);
+grpc_resource_quota* grpc_resource_quota_from_channel_args(
+ const grpc_channel_args* channel_args);
/* Return a number indicating current memory pressure:
0.0 ==> no memory usage
1.0 ==> maximum memory usage */
double grpc_resource_quota_get_memory_pressure(
- grpc_resource_quota *resource_quota);
+ grpc_resource_quota* resource_quota);
-size_t grpc_resource_quota_peek_size(grpc_resource_quota *resource_quota);
+size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota);
typedef struct grpc_resource_user grpc_resource_user;
-grpc_resource_user *grpc_resource_user_create(
- grpc_resource_quota *resource_quota, const char *name);
+grpc_resource_user* grpc_resource_user_create(
+ grpc_resource_quota* resource_quota, const char* name);
/* Returns a borrowed reference to the underlying resource quota for this
resource user. */
-grpc_resource_quota *grpc_resource_user_quota(
- grpc_resource_user *resource_user);
+grpc_resource_quota* grpc_resource_user_quota(
+ grpc_resource_user* resource_user);
-void grpc_resource_user_ref(grpc_resource_user *resource_user);
-void grpc_resource_user_unref(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user);
-void grpc_resource_user_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user);
+void grpc_resource_user_ref(grpc_resource_user* resource_user);
+void grpc_resource_user_unref(grpc_resource_user* resource_user);
+void grpc_resource_user_shutdown(grpc_resource_user* resource_user);
/* Allocate from the resource user (and its quota).
If optional_on_done is NULL, then allocate immediately. This may push the
quota over-limit, at which point reclamation will kick in.
If optional_on_done is non-NULL, it will be scheduled when the allocation has
been granted by the quota. */
-void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user, size_t size,
- grpc_closure *optional_on_done);
+void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
+ grpc_closure* optional_on_done);
/* Release memory back to the quota */
-void grpc_resource_user_free(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user, size_t size);
+void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size);
/* Post a memory reclaimer to the resource user. Only one benign and one
destructive reclaimer can be posted at once. When executed, the reclaimer
MUST call grpc_resource_user_finish_reclamation before it completes, to
return control to the resource quota. */
-void grpc_resource_user_post_reclaimer(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user,
- bool destructive, grpc_closure *closure);
+void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
+ bool destructive, grpc_closure* closure);
/* Finish a reclamation step */
-void grpc_resource_user_finish_reclamation(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user);
+void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user);
/* Helper to allocate slices from a resource user */
typedef struct grpc_resource_user_slice_allocator {
@@ -127,27 +120,25 @@ typedef struct grpc_resource_user_slice_allocator {
/* Number of slices to allocate on the current request */
size_t count;
/* Destination for slices to allocate on the current request */
- grpc_slice_buffer *dest;
+ grpc_slice_buffer* dest;
/* Parent resource user */
- grpc_resource_user *resource_user;
+ grpc_resource_user* resource_user;
} grpc_resource_user_slice_allocator;
/* Initialize a slice allocator.
When an allocation is completed, calls \a cb with arg \p. */
void grpc_resource_user_slice_allocator_init(
- grpc_resource_user_slice_allocator *slice_allocator,
- grpc_resource_user *resource_user, grpc_iomgr_cb_func cb, void *p);
+ grpc_resource_user_slice_allocator* slice_allocator,
+ grpc_resource_user* resource_user, grpc_iomgr_cb_func cb, void* p);
/* Allocate \a count slices of length \a length into \a dest. Only one request
can be outstanding at a time. */
void grpc_resource_user_alloc_slices(
- grpc_exec_ctx *exec_ctx,
- grpc_resource_user_slice_allocator *slice_allocator, size_t length,
- size_t count, grpc_slice_buffer *dest);
+ grpc_resource_user_slice_allocator* slice_allocator, size_t length,
+ size_t count, grpc_slice_buffer* dest);
/* Allocate one slice of length \a size synchronously. */
-grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user,
+grpc_slice grpc_resource_user_slice_malloc(grpc_resource_user* resource_user,
size_t size);
#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */
diff --git a/src/core/lib/iomgr/sockaddr_utils.c b/src/core/lib/iomgr/sockaddr_utils.cc
index 3f4145d104..71e3e38624 100644
--- a/src/core/lib/iomgr/sockaddr_utils.c
+++ b/src/core/lib/iomgr/sockaddr_utils.cc
@@ -19,6 +19,7 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include <errno.h>
+#include <inttypes.h>
#include <string.h>
#include <grpc/support/alloc.h>
@@ -27,27 +28,27 @@
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
-#include "src/core/lib/support/string.h"
static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xff};
-int grpc_sockaddr_is_v4mapped(const grpc_resolved_address *resolved_addr,
- grpc_resolved_address *resolved_addr4_out) {
+int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* resolved_addr,
+ grpc_resolved_address* resolved_addr4_out) {
GPR_ASSERT(resolved_addr != resolved_addr4_out);
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
- struct sockaddr_in *addr4_out =
- resolved_addr4_out == NULL
- ? NULL
- : (struct sockaddr_in *)resolved_addr4_out->addr;
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
+ struct sockaddr_in* addr4_out =
+ resolved_addr4_out == nullptr
+ ? nullptr
+ : (struct sockaddr_in*)resolved_addr4_out->addr;
if (addr->sa_family == AF_INET6) {
- const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
+ const struct sockaddr_in6* addr6 = (const struct sockaddr_in6*)addr;
if (memcmp(addr6->sin6_addr.s6_addr, kV4MappedPrefix,
sizeof(kV4MappedPrefix)) == 0) {
- if (resolved_addr4_out != NULL) {
+ if (resolved_addr4_out != nullptr) {
/* Normalize ::ffff:0.0.0.0/96 to IPv4. */
memset(resolved_addr4_out, 0, sizeof(*resolved_addr4_out));
addr4_out->sin_family = AF_INET;
@@ -62,14 +63,14 @@ int grpc_sockaddr_is_v4mapped(const grpc_resolved_address *resolved_addr,
return 0;
}
-int grpc_sockaddr_to_v4mapped(const grpc_resolved_address *resolved_addr,
- grpc_resolved_address *resolved_addr6_out) {
+int grpc_sockaddr_to_v4mapped(const grpc_resolved_address* resolved_addr,
+ grpc_resolved_address* resolved_addr6_out) {
GPR_ASSERT(resolved_addr != resolved_addr6_out);
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
- struct sockaddr_in6 *addr6_out =
- (struct sockaddr_in6 *)resolved_addr6_out->addr;
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
+ struct sockaddr_in6* addr6_out =
+ (struct sockaddr_in6*)resolved_addr6_out->addr;
if (addr->sa_family == AF_INET) {
- const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr;
+ const struct sockaddr_in* addr4 = (const struct sockaddr_in*)addr;
memset(resolved_addr6_out, 0, sizeof(*resolved_addr6_out));
addr6_out->sin6_family = AF_INET6;
memcpy(&addr6_out->sin6_addr.s6_addr[0], kV4MappedPrefix, 12);
@@ -81,17 +82,17 @@ int grpc_sockaddr_to_v4mapped(const grpc_resolved_address *resolved_addr,
return 0;
}
-int grpc_sockaddr_is_wildcard(const grpc_resolved_address *resolved_addr,
- int *port_out) {
- const struct sockaddr *addr;
+int grpc_sockaddr_is_wildcard(const grpc_resolved_address* resolved_addr,
+ int* port_out) {
+ const struct sockaddr* addr;
grpc_resolved_address addr4_normalized;
if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr4_normalized)) {
resolved_addr = &addr4_normalized;
}
- addr = (const struct sockaddr *)resolved_addr->addr;
+ addr = (const struct sockaddr*)resolved_addr->addr;
if (addr->sa_family == AF_INET) {
/* Check for 0.0.0.0 */
- const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr;
+ const struct sockaddr_in* addr4 = (const struct sockaddr_in*)addr;
if (addr4->sin_addr.s_addr != 0) {
return 0;
}
@@ -99,7 +100,7 @@ int grpc_sockaddr_is_wildcard(const grpc_resolved_address *resolved_addr,
return 1;
} else if (addr->sa_family == AF_INET6) {
/* Check for :: */
- const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
+ const struct sockaddr_in6* addr6 = (const struct sockaddr_in6*)addr;
int i;
for (i = 0; i < 16; i++) {
if (addr6->sin6_addr.s6_addr[i] != 0) {
@@ -113,15 +114,15 @@ int grpc_sockaddr_is_wildcard(const grpc_resolved_address *resolved_addr,
}
}
-void grpc_sockaddr_make_wildcards(int port, grpc_resolved_address *wild4_out,
- grpc_resolved_address *wild6_out) {
+void grpc_sockaddr_make_wildcards(int port, grpc_resolved_address* wild4_out,
+ grpc_resolved_address* wild6_out) {
grpc_sockaddr_make_wildcard4(port, wild4_out);
grpc_sockaddr_make_wildcard6(port, wild6_out);
}
void grpc_sockaddr_make_wildcard4(int port,
- grpc_resolved_address *resolved_wild_out) {
- struct sockaddr_in *wild_out = (struct sockaddr_in *)resolved_wild_out->addr;
+ grpc_resolved_address* resolved_wild_out) {
+ struct sockaddr_in* wild_out = (struct sockaddr_in*)resolved_wild_out->addr;
GPR_ASSERT(port >= 0 && port < 65536);
memset(resolved_wild_out, 0, sizeof(*resolved_wild_out));
wild_out->sin_family = AF_INET;
@@ -130,9 +131,8 @@ void grpc_sockaddr_make_wildcard4(int port,
}
void grpc_sockaddr_make_wildcard6(int port,
- grpc_resolved_address *resolved_wild_out) {
- struct sockaddr_in6 *wild_out =
- (struct sockaddr_in6 *)resolved_wild_out->addr;
+ grpc_resolved_address* resolved_wild_out) {
+ struct sockaddr_in6* wild_out = (struct sockaddr_in6*)resolved_wild_out->addr;
GPR_ASSERT(port >= 0 && port < 65536);
memset(resolved_wild_out, 0, sizeof(*resolved_wild_out));
wild_out->sin6_family = AF_INET6;
@@ -140,37 +140,37 @@ void grpc_sockaddr_make_wildcard6(int port,
resolved_wild_out->len = sizeof(struct sockaddr_in6);
}
-int grpc_sockaddr_to_string(char **out,
- const grpc_resolved_address *resolved_addr,
+int grpc_sockaddr_to_string(char** out,
+ const grpc_resolved_address* resolved_addr,
int normalize) {
- const struct sockaddr *addr;
+ const struct sockaddr* addr;
const int save_errno = errno;
grpc_resolved_address addr_normalized;
char ntop_buf[INET6_ADDRSTRLEN];
- const void *ip = NULL;
- int port;
+ const void* ip = nullptr;
+ int port = 0;
uint32_t sin6_scope_id = 0;
int ret;
- *out = NULL;
+ *out = nullptr;
if (normalize && grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
resolved_addr = &addr_normalized;
}
- addr = (const struct sockaddr *)resolved_addr->addr;
+ addr = (const struct sockaddr*)resolved_addr->addr;
if (addr->sa_family == AF_INET) {
- const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr;
+ const struct sockaddr_in* addr4 = (const struct sockaddr_in*)addr;
ip = &addr4->sin_addr;
port = ntohs(addr4->sin_port);
} else if (addr->sa_family == AF_INET6) {
- const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
+ const struct sockaddr_in6* addr6 = (const struct sockaddr_in6*)addr;
ip = &addr6->sin6_addr;
port = ntohs(addr6->sin6_port);
sin6_scope_id = addr6->sin6_scope_id;
}
- if (ip != NULL &&
- grpc_inet_ntop(addr->sa_family, ip, ntop_buf, sizeof(ntop_buf)) != NULL) {
+ if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf,
+ sizeof(ntop_buf)) != nullptr) {
if (sin6_scope_id != 0) {
- char *host_with_scope;
+ char* host_with_scope;
/* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */
gpr_asprintf(&host_with_scope, "%s%%25%" PRIu32, ntop_buf, sin6_scope_id);
ret = gpr_join_host_port(out, host_with_scope, port);
@@ -186,29 +186,29 @@ int grpc_sockaddr_to_string(char **out,
return ret;
}
-char *grpc_sockaddr_to_uri(const grpc_resolved_address *resolved_addr) {
+char* grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) {
grpc_resolved_address addr_normalized;
if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) {
resolved_addr = &addr_normalized;
}
- const char *scheme = grpc_sockaddr_get_uri_scheme(resolved_addr);
- if (scheme == NULL || strcmp("unix", scheme) == 0) {
+ const char* scheme = grpc_sockaddr_get_uri_scheme(resolved_addr);
+ if (scheme == nullptr || strcmp("unix", scheme) == 0) {
return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr);
}
- char *path = NULL;
- char *uri_str = NULL;
+ char* path = nullptr;
+ char* uri_str = nullptr;
if (grpc_sockaddr_to_string(&path, resolved_addr,
false /* suppress errors */) &&
- scheme != NULL) {
+ scheme != nullptr) {
gpr_asprintf(&uri_str, "%s:%s", scheme, path);
}
gpr_free(path);
- return uri_str != NULL ? uri_str : NULL;
+ return uri_str != nullptr ? uri_str : nullptr;
}
-const char *grpc_sockaddr_get_uri_scheme(
- const grpc_resolved_address *resolved_addr) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+const char* grpc_sockaddr_get_uri_scheme(
+ const grpc_resolved_address* resolved_addr) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
switch (addr->sa_family) {
case AF_INET:
return "ipv4";
@@ -217,21 +217,21 @@ const char *grpc_sockaddr_get_uri_scheme(
case AF_UNIX:
return "unix";
}
- return NULL;
+ return nullptr;
}
-int grpc_sockaddr_get_family(const grpc_resolved_address *resolved_addr) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+int grpc_sockaddr_get_family(const grpc_resolved_address* resolved_addr) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
return addr->sa_family;
}
-int grpc_sockaddr_get_port(const grpc_resolved_address *resolved_addr) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+int grpc_sockaddr_get_port(const grpc_resolved_address* resolved_addr) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
switch (addr->sa_family) {
case AF_INET:
- return ntohs(((struct sockaddr_in *)addr)->sin_port);
+ return ntohs(((struct sockaddr_in*)addr)->sin_port);
case AF_INET6:
- return ntohs(((struct sockaddr_in6 *)addr)->sin6_port);
+ return ntohs(((struct sockaddr_in6*)addr)->sin6_port);
default:
if (grpc_is_unix_socket(resolved_addr)) {
return 1;
@@ -242,17 +242,17 @@ int grpc_sockaddr_get_port(const grpc_resolved_address *resolved_addr) {
}
}
-int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr,
+int grpc_sockaddr_set_port(const grpc_resolved_address* resolved_addr,
int port) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
switch (addr->sa_family) {
case AF_INET:
GPR_ASSERT(port >= 0 && port < 65536);
- ((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)port);
+ ((struct sockaddr_in*)addr)->sin_port = htons((uint16_t)port);
return 1;
case AF_INET6:
GPR_ASSERT(port >= 0 && port < 65536);
- ((struct sockaddr_in6 *)addr)->sin6_port = htons((uint16_t)port);
+ ((struct sockaddr_in6*)addr)->sin6_port = htons((uint16_t)port);
return 1;
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_set_port",
diff --git a/src/core/lib/iomgr/sockaddr_utils.h b/src/core/lib/iomgr/sockaddr_utils.h
index a589a19705..e3bd51a4ad 100644
--- a/src/core/lib/iomgr/sockaddr_utils.h
+++ b/src/core/lib/iomgr/sockaddr_utils.h
@@ -26,33 +26,33 @@
If addr4_out is non-NULL, the inner IPv4 address will be copied here when
returning true. */
-int grpc_sockaddr_is_v4mapped(const grpc_resolved_address *addr,
- grpc_resolved_address *addr4_out);
+int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* addr,
+ grpc_resolved_address* addr4_out);
/* If addr is an AF_INET address, writes the corresponding ::ffff:0.0.0.0/96
address to addr6_out and returns true. Otherwise returns false. */
-int grpc_sockaddr_to_v4mapped(const grpc_resolved_address *addr,
- grpc_resolved_address *addr6_out);
+int grpc_sockaddr_to_v4mapped(const grpc_resolved_address* addr,
+ grpc_resolved_address* addr6_out);
/* If addr is ::, 0.0.0.0, or ::ffff:0.0.0.0, writes the port number to
*port_out (if not NULL) and returns true, otherwise returns false. */
-int grpc_sockaddr_is_wildcard(const grpc_resolved_address *addr, int *port_out);
+int grpc_sockaddr_is_wildcard(const grpc_resolved_address* addr, int* port_out);
/* Writes 0.0.0.0:port and [::]:port to separate sockaddrs. */
-void grpc_sockaddr_make_wildcards(int port, grpc_resolved_address *wild4_out,
- grpc_resolved_address *wild6_out);
+void grpc_sockaddr_make_wildcards(int port, grpc_resolved_address* wild4_out,
+ grpc_resolved_address* wild6_out);
/* Writes 0.0.0.0:port. */
-void grpc_sockaddr_make_wildcard4(int port, grpc_resolved_address *wild_out);
+void grpc_sockaddr_make_wildcard4(int port, grpc_resolved_address* wild_out);
/* Writes [::]:port. */
-void grpc_sockaddr_make_wildcard6(int port, grpc_resolved_address *wild_out);
+void grpc_sockaddr_make_wildcard6(int port, grpc_resolved_address* wild_out);
/* Return the IP port number of a sockaddr */
-int grpc_sockaddr_get_port(const grpc_resolved_address *addr);
+int grpc_sockaddr_get_port(const grpc_resolved_address* addr);
/* Set IP port number of a sockaddr */
-int grpc_sockaddr_set_port(const grpc_resolved_address *addr, int port);
+int grpc_sockaddr_set_port(const grpc_resolved_address* addr, int port);
/* Converts a sockaddr into a newly-allocated human-readable string.
@@ -66,15 +66,15 @@ int grpc_sockaddr_set_port(const grpc_resolved_address *addr, int port);
In the unlikely event of an error, returns -1 and sets *out to NULL.
The existing value of errno is always preserved. */
-int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr,
+int grpc_sockaddr_to_string(char** out, const grpc_resolved_address* addr,
int normalize);
/* Returns the URI string corresponding to \a addr */
-char *grpc_sockaddr_to_uri(const grpc_resolved_address *addr);
+char* grpc_sockaddr_to_uri(const grpc_resolved_address* addr);
/* Returns the URI scheme corresponding to \a addr */
-const char *grpc_sockaddr_get_uri_scheme(const grpc_resolved_address *addr);
+const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* addr);
-int grpc_sockaddr_get_family(const grpc_resolved_address *resolved_addr);
+int grpc_sockaddr_get_family(const grpc_resolved_address* resolved_addr);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */
diff --git a/src/core/lib/iomgr/sockaddr_windows.h b/src/core/lib/iomgr/sockaddr_windows.h
index cf0f6b914d..20e37c9fc4 100644
--- a/src/core/lib/iomgr/sockaddr_windows.h
+++ b/src/core/lib/iomgr/sockaddr_windows.h
@@ -19,10 +19,16 @@
#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H
#define GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_WINSOCK_SOCKET
+
#include <winsock2.h>
#include <ws2tcpip.h>
// must be included after the above
#include <mswsock.h>
+#endif
+
#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H */
diff --git a/src/core/lib/iomgr/socket_factory_posix.c b/src/core/lib/iomgr/socket_factory_posix.cc
index 8e907703ae..bc7d0b12f3 100644
--- a/src/core/lib/iomgr/socket_factory_posix.c
+++ b/src/core/lib/iomgr/socket_factory_posix.cc
@@ -27,28 +27,28 @@
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
-void grpc_socket_factory_init(grpc_socket_factory *factory,
- const grpc_socket_factory_vtable *vtable) {
+void grpc_socket_factory_init(grpc_socket_factory* factory,
+ const grpc_socket_factory_vtable* vtable) {
factory->vtable = vtable;
gpr_ref_init(&factory->refcount, 1);
}
-int grpc_socket_factory_socket(grpc_socket_factory *factory, int domain,
+int grpc_socket_factory_socket(grpc_socket_factory* factory, int domain,
int type, int protocol) {
return factory->vtable->socket(factory, domain, type, protocol);
}
-int grpc_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
- const grpc_resolved_address *addr) {
+int grpc_socket_factory_bind(grpc_socket_factory* factory, int sockfd,
+ const grpc_resolved_address* addr) {
return factory->vtable->bind(factory, sockfd, addr);
}
-int grpc_socket_factory_compare(grpc_socket_factory *a,
- grpc_socket_factory *b) {
+int grpc_socket_factory_compare(grpc_socket_factory* a,
+ grpc_socket_factory* b) {
int c = GPR_ICMP(a, b);
if (c != 0) {
- grpc_socket_factory *sma = a;
- grpc_socket_factory *smb = b;
+ grpc_socket_factory* sma = a;
+ grpc_socket_factory* smb = b;
c = GPR_ICMP(sma->vtable, smb->vtable);
if (c == 0) {
c = sma->vtable->compare(sma, smb);
@@ -57,35 +57,35 @@ int grpc_socket_factory_compare(grpc_socket_factory *a,
return c;
}
-grpc_socket_factory *grpc_socket_factory_ref(grpc_socket_factory *factory) {
+grpc_socket_factory* grpc_socket_factory_ref(grpc_socket_factory* factory) {
gpr_ref(&factory->refcount);
return factory;
}
-void grpc_socket_factory_unref(grpc_socket_factory *factory) {
+void grpc_socket_factory_unref(grpc_socket_factory* factory) {
if (gpr_unref(&factory->refcount)) {
factory->vtable->destroy(factory);
}
}
-static void *socket_factory_arg_copy(void *p) {
- return grpc_socket_factory_ref((grpc_socket_factory *)p);
+static void* socket_factory_arg_copy(void* p) {
+ return grpc_socket_factory_ref((grpc_socket_factory*)p);
}
-static void socket_factory_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
- grpc_socket_factory_unref((grpc_socket_factory *)p);
+static void socket_factory_arg_destroy(void* p) {
+ grpc_socket_factory_unref((grpc_socket_factory*)p);
}
-static int socket_factory_cmp(void *a, void *b) {
- return grpc_socket_factory_compare((grpc_socket_factory *)a,
- (grpc_socket_factory *)b);
+static int socket_factory_cmp(void* a, void* b) {
+ return grpc_socket_factory_compare((grpc_socket_factory*)a,
+ (grpc_socket_factory*)b);
}
static const grpc_arg_pointer_vtable socket_factory_arg_vtable = {
socket_factory_arg_copy, socket_factory_arg_destroy, socket_factory_cmp};
-grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory *factory) {
- return grpc_channel_arg_pointer_create((char *)GRPC_ARG_SOCKET_FACTORY,
+grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory* factory) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_ARG_SOCKET_FACTORY,
factory, &socket_factory_arg_vtable);
}
diff --git a/src/core/lib/iomgr/socket_factory_posix.h b/src/core/lib/iomgr/socket_factory_posix.h
index a46938b06e..af57cc5b60 100644
--- a/src/core/lib/iomgr/socket_factory_posix.h
+++ b/src/core/lib/iomgr/socket_factory_posix.h
@@ -23,53 +23,45 @@
#include <grpc/support/sync.h>
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** The virtual table of grpc_socket_factory */
typedef struct {
/** Replacement for socket(2) */
- int (*socket)(grpc_socket_factory *factory, int domain, int type,
+ int (*socket)(grpc_socket_factory* factory, int domain, int type,
int protocol);
/** Replacement for bind(2) */
- int (*bind)(grpc_socket_factory *factory, int sockfd,
- const grpc_resolved_address *addr);
+ int (*bind)(grpc_socket_factory* factory, int sockfd,
+ const grpc_resolved_address* addr);
/** Compare socket factory \a a and \a b */
- int (*compare)(grpc_socket_factory *a, grpc_socket_factory *b);
+ int (*compare)(grpc_socket_factory* a, grpc_socket_factory* b);
/** Destroys the socket factory instance */
- void (*destroy)(grpc_socket_factory *factory);
+ void (*destroy)(grpc_socket_factory* factory);
} grpc_socket_factory_vtable;
/** The Socket Factory interface allows changes on socket options */
struct grpc_socket_factory {
- const grpc_socket_factory_vtable *vtable;
+ const grpc_socket_factory_vtable* vtable;
gpr_refcount refcount;
};
/** called by concrete implementations to initialize the base struct */
-void grpc_socket_factory_init(grpc_socket_factory *factory,
- const grpc_socket_factory_vtable *vtable);
+void grpc_socket_factory_init(grpc_socket_factory* factory,
+ const grpc_socket_factory_vtable* vtable);
/** Wrap \a factory as a grpc_arg */
-grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory *factory);
+grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory* factory);
/** Perform the equivalent of a socket(2) operation using \a factory */
-int grpc_socket_factory_socket(grpc_socket_factory *factory, int domain,
+int grpc_socket_factory_socket(grpc_socket_factory* factory, int domain,
int type, int protocol);
/** Perform the equivalent of a bind(2) operation using \a factory */
-int grpc_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
- const grpc_resolved_address *addr);
+int grpc_socket_factory_bind(grpc_socket_factory* factory, int sockfd,
+ const grpc_resolved_address* addr);
/** Compare if \a a and \a b are the same factory or have same settings */
-int grpc_socket_factory_compare(grpc_socket_factory *a, grpc_socket_factory *b);
-
-grpc_socket_factory *grpc_socket_factory_ref(grpc_socket_factory *factory);
-void grpc_socket_factory_unref(grpc_socket_factory *factory);
+int grpc_socket_factory_compare(grpc_socket_factory* a, grpc_socket_factory* b);
-#ifdef __cplusplus
-}
-#endif
+grpc_socket_factory* grpc_socket_factory_ref(grpc_socket_factory* factory);
+void grpc_socket_factory_unref(grpc_socket_factory* factory);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_FACTORY_POSIX_H */
diff --git a/src/core/lib/iomgr/socket_mutator.c b/src/core/lib/iomgr/socket_mutator.cc
index b0435d5a07..9d30e46b6b 100644
--- a/src/core/lib/iomgr/socket_mutator.c
+++ b/src/core/lib/iomgr/socket_mutator.cc
@@ -24,27 +24,27 @@
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
-void grpc_socket_mutator_init(grpc_socket_mutator *mutator,
- const grpc_socket_mutator_vtable *vtable) {
+void grpc_socket_mutator_init(grpc_socket_mutator* mutator,
+ const grpc_socket_mutator_vtable* vtable) {
mutator->vtable = vtable;
gpr_ref_init(&mutator->refcount, 1);
}
-grpc_socket_mutator *grpc_socket_mutator_ref(grpc_socket_mutator *mutator) {
+grpc_socket_mutator* grpc_socket_mutator_ref(grpc_socket_mutator* mutator) {
gpr_ref(&mutator->refcount);
return mutator;
}
-bool grpc_socket_mutator_mutate_fd(grpc_socket_mutator *mutator, int fd) {
+bool grpc_socket_mutator_mutate_fd(grpc_socket_mutator* mutator, int fd) {
return mutator->vtable->mutate_fd(fd, mutator);
}
-int grpc_socket_mutator_compare(grpc_socket_mutator *a,
- grpc_socket_mutator *b) {
+int grpc_socket_mutator_compare(grpc_socket_mutator* a,
+ grpc_socket_mutator* b) {
int c = GPR_ICMP(a, b);
if (c != 0) {
- grpc_socket_mutator *sma = a;
- grpc_socket_mutator *smb = b;
+ grpc_socket_mutator* sma = a;
+ grpc_socket_mutator* smb = b;
c = GPR_ICMP(sma->vtable, smb->vtable);
if (c == 0) {
c = sma->vtable->compare(sma, smb);
@@ -53,29 +53,29 @@ int grpc_socket_mutator_compare(grpc_socket_mutator *a,
return c;
}
-void grpc_socket_mutator_unref(grpc_socket_mutator *mutator) {
+void grpc_socket_mutator_unref(grpc_socket_mutator* mutator) {
if (gpr_unref(&mutator->refcount)) {
mutator->vtable->destory(mutator);
}
}
-static void *socket_mutator_arg_copy(void *p) {
- return grpc_socket_mutator_ref((grpc_socket_mutator *)p);
+static void* socket_mutator_arg_copy(void* p) {
+ return grpc_socket_mutator_ref((grpc_socket_mutator*)p);
}
-static void socket_mutator_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
- grpc_socket_mutator_unref((grpc_socket_mutator *)p);
+static void socket_mutator_arg_destroy(void* p) {
+ grpc_socket_mutator_unref((grpc_socket_mutator*)p);
}
-static int socket_mutator_cmp(void *a, void *b) {
- return grpc_socket_mutator_compare((grpc_socket_mutator *)a,
- (grpc_socket_mutator *)b);
+static int socket_mutator_cmp(void* a, void* b) {
+ return grpc_socket_mutator_compare((grpc_socket_mutator*)a,
+ (grpc_socket_mutator*)b);
}
static const grpc_arg_pointer_vtable socket_mutator_arg_vtable = {
socket_mutator_arg_copy, socket_mutator_arg_destroy, socket_mutator_cmp};
-grpc_arg grpc_socket_mutator_to_arg(grpc_socket_mutator *mutator) {
- return grpc_channel_arg_pointer_create((char *)GRPC_ARG_SOCKET_MUTATOR,
+grpc_arg grpc_socket_mutator_to_arg(grpc_socket_mutator* mutator) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_ARG_SOCKET_MUTATOR,
mutator, &socket_mutator_arg_vtable);
}
diff --git a/src/core/lib/iomgr/socket_mutator.h b/src/core/lib/iomgr/socket_mutator.h
index ba956e16f0..f8fd21d15a 100644
--- a/src/core/lib/iomgr/socket_mutator.h
+++ b/src/core/lib/iomgr/socket_mutator.h
@@ -24,44 +24,36 @@
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** The virtual table of grpc_socket_mutator */
typedef struct {
- /** Mutates the socket opitons of \a fd */
- bool (*mutate_fd)(int fd, grpc_socket_mutator *mutator);
+ /** Mutates the socket options of \a fd */
+ bool (*mutate_fd)(int fd, grpc_socket_mutator* mutator);
/** Compare socket mutator \a a and \a b */
- int (*compare)(grpc_socket_mutator *a, grpc_socket_mutator *b);
+ int (*compare)(grpc_socket_mutator* a, grpc_socket_mutator* b);
/** Destroys the socket mutator instance */
- void (*destory)(grpc_socket_mutator *mutator);
+ void (*destory)(grpc_socket_mutator* mutator);
} grpc_socket_mutator_vtable;
/** The Socket Mutator interface allows changes on socket options */
struct grpc_socket_mutator {
- const grpc_socket_mutator_vtable *vtable;
+ const grpc_socket_mutator_vtable* vtable;
gpr_refcount refcount;
};
/** called by concrete implementations to initialize the base struct */
-void grpc_socket_mutator_init(grpc_socket_mutator *mutator,
- const grpc_socket_mutator_vtable *vtable);
+void grpc_socket_mutator_init(grpc_socket_mutator* mutator,
+ const grpc_socket_mutator_vtable* vtable);
/** Wrap \a mutator as a grpc_arg */
-grpc_arg grpc_socket_mutator_to_arg(grpc_socket_mutator *mutator);
+grpc_arg grpc_socket_mutator_to_arg(grpc_socket_mutator* mutator);
/** Perform the file descriptor mutation operation of \a mutator on \a fd */
-bool grpc_socket_mutator_mutate_fd(grpc_socket_mutator *mutator, int fd);
+bool grpc_socket_mutator_mutate_fd(grpc_socket_mutator* mutator, int fd);
/** Compare if \a a and \a b are the same mutator or have same settings */
-int grpc_socket_mutator_compare(grpc_socket_mutator *a, grpc_socket_mutator *b);
-
-grpc_socket_mutator *grpc_socket_mutator_ref(grpc_socket_mutator *mutator);
-void grpc_socket_mutator_unref(grpc_socket_mutator *mutator);
+int grpc_socket_mutator_compare(grpc_socket_mutator* a, grpc_socket_mutator* b);
-#ifdef __cplusplus
-}
-#endif
+grpc_socket_mutator* grpc_socket_mutator_ref(grpc_socket_mutator* mutator);
+void grpc_socket_mutator_unref(grpc_socket_mutator* mutator);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H */
diff --git a/src/core/lib/iomgr/socket_utils.h b/src/core/lib/iomgr/socket_utils.h
index 03fe46e5e9..9fd141b6de 100644
--- a/src/core/lib/iomgr/socket_utils.h
+++ b/src/core/lib/iomgr/socket_utils.h
@@ -22,6 +22,6 @@
#include <stddef.h>
/* A wrapper for inet_ntop on POSIX systems and InetNtop on Windows systems */
-const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size);
+const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.cc
index b8e2a0cdfd..5068a8081d 100644
--- a/src/core/lib/iomgr/socket_utils_common_posix.c
+++ b/src/core/lib/iomgr/socket_utils_common_posix.cc
@@ -40,11 +40,11 @@
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/string.h"
/* set a socket to non blocking mode */
-grpc_error *grpc_set_socket_nonblocking(int fd, int non_blocking) {
+grpc_error* grpc_set_socket_nonblocking(int fd, int non_blocking) {
int oldflags = fcntl(fd, F_GETFL, 0);
if (oldflags < 0) {
return GRPC_OS_ERROR(errno, "fcntl");
@@ -63,7 +63,7 @@ grpc_error *grpc_set_socket_nonblocking(int fd, int non_blocking) {
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_set_socket_no_sigpipe_if_possible(int fd) {
+grpc_error* grpc_set_socket_no_sigpipe_if_possible(int fd) {
#ifdef GRPC_HAVE_SO_NOSIGPIPE
int val = 1;
int newval;
@@ -81,7 +81,7 @@ grpc_error *grpc_set_socket_no_sigpipe_if_possible(int fd) {
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_set_socket_ip_pktinfo_if_possible(int fd) {
+grpc_error* grpc_set_socket_ip_pktinfo_if_possible(int fd) {
#ifdef GRPC_HAVE_IP_PKTINFO
int get_local_ip = 1;
if (0 != setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip,
@@ -92,7 +92,7 @@ grpc_error *grpc_set_socket_ip_pktinfo_if_possible(int fd) {
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) {
+grpc_error* grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) {
#ifdef GRPC_HAVE_IPV6_RECVPKTINFO
int get_local_ip = 1;
if (0 != setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip,
@@ -103,14 +103,14 @@ grpc_error *grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) {
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_set_socket_sndbuf(int fd, int buffer_size_bytes) {
+grpc_error* grpc_set_socket_sndbuf(int fd, int buffer_size_bytes) {
return 0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buffer_size_bytes,
sizeof(buffer_size_bytes))
? GRPC_ERROR_NONE
: GRPC_OS_ERROR(errno, "setsockopt(SO_SNDBUF)");
}
-grpc_error *grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) {
+grpc_error* grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) {
return 0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buffer_size_bytes,
sizeof(buffer_size_bytes))
? GRPC_ERROR_NONE
@@ -118,7 +118,7 @@ grpc_error *grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) {
}
/* set a socket to close on exec */
-grpc_error *grpc_set_socket_cloexec(int fd, int close_on_exec) {
+grpc_error* grpc_set_socket_cloexec(int fd, int close_on_exec) {
int oldflags = fcntl(fd, F_GETFD, 0);
if (oldflags < 0) {
return GRPC_OS_ERROR(errno, "fcntl");
@@ -138,7 +138,7 @@ grpc_error *grpc_set_socket_cloexec(int fd, int close_on_exec) {
}
/* set a socket to reuse old addresses */
-grpc_error *grpc_set_socket_reuse_addr(int fd, int reuse) {
+grpc_error* grpc_set_socket_reuse_addr(int fd, int reuse) {
int val = (reuse != 0);
int newval;
socklen_t intlen = sizeof(newval);
@@ -156,7 +156,7 @@ grpc_error *grpc_set_socket_reuse_addr(int fd, int reuse) {
}
/* set a socket to reuse old addresses */
-grpc_error *grpc_set_socket_reuse_port(int fd, int reuse) {
+grpc_error* grpc_set_socket_reuse_port(int fd, int reuse) {
#ifndef SO_REUSEPORT
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"SO_REUSEPORT unavailable on compiling system");
@@ -179,7 +179,7 @@ grpc_error *grpc_set_socket_reuse_port(int fd, int reuse) {
}
/* disable nagle */
-grpc_error *grpc_set_socket_low_latency(int fd, int low_latency) {
+grpc_error* grpc_set_socket_low_latency(int fd, int low_latency) {
int val = (low_latency != 0);
int newval;
socklen_t intlen = sizeof(newval);
@@ -196,7 +196,7 @@ grpc_error *grpc_set_socket_low_latency(int fd, int low_latency) {
}
/* set a socket using a grpc_socket_mutator */
-grpc_error *grpc_set_socket_with_mutator(int fd, grpc_socket_mutator *mutator) {
+grpc_error* grpc_set_socket_with_mutator(int fd, grpc_socket_mutator* mutator) {
GPR_ASSERT(mutator);
if (!grpc_socket_mutator_mutate_fd(mutator, fd)) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("grpc_socket_mutator failed.");
@@ -217,7 +217,7 @@ static void probe_ipv6_once(void) {
memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_addr.s6_addr[15] = 1; /* [::1]:0 */
- if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
+ if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == 0) {
g_ipv6_loopback_available = 1;
} else {
gpr_log(GPR_INFO,
@@ -249,35 +249,35 @@ static int set_socket_dualstack(int fd) {
}
}
-static grpc_error *error_for_fd(int fd, const grpc_resolved_address *addr) {
+static grpc_error* error_for_fd(int fd, const grpc_resolved_address* addr) {
if (fd >= 0) return GRPC_ERROR_NONE;
- char *addr_str;
+ char* addr_str;
grpc_sockaddr_to_string(&addr_str, addr, 0);
- grpc_error *err = grpc_error_set_str(GRPC_OS_ERROR(errno, "socket"),
+ grpc_error* err = grpc_error_set_str(GRPC_OS_ERROR(errno, "socket"),
GRPC_ERROR_STR_TARGET_ADDRESS,
grpc_slice_from_copied_string(addr_str));
gpr_free(addr_str);
return err;
}
-grpc_error *grpc_create_dualstack_socket(
- const grpc_resolved_address *resolved_addr, int type, int protocol,
- grpc_dualstack_mode *dsmode, int *newfd) {
- return grpc_create_dualstack_socket_using_factory(NULL, resolved_addr, type,
- protocol, dsmode, newfd);
+grpc_error* grpc_create_dualstack_socket(
+ const grpc_resolved_address* resolved_addr, int type, int protocol,
+ grpc_dualstack_mode* dsmode, int* newfd) {
+ return grpc_create_dualstack_socket_using_factory(
+ nullptr, resolved_addr, type, protocol, dsmode, newfd);
}
-static int create_socket(grpc_socket_factory *factory, int domain, int type,
+static int create_socket(grpc_socket_factory* factory, int domain, int type,
int protocol) {
- return (factory != NULL)
+ return (factory != nullptr)
? grpc_socket_factory_socket(factory, domain, type, protocol)
: socket(domain, type, protocol);
}
-grpc_error *grpc_create_dualstack_socket_using_factory(
- grpc_socket_factory *factory, const grpc_resolved_address *resolved_addr,
- int type, int protocol, grpc_dualstack_mode *dsmode, int *newfd) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+grpc_error* grpc_create_dualstack_socket_using_factory(
+ grpc_socket_factory* factory, const grpc_resolved_address* resolved_addr,
+ int type, int protocol, grpc_dualstack_mode* dsmode, int* newfd) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
int family = addr->sa_family;
if (family == AF_INET6) {
if (grpc_ipv6_loopback_available()) {
@@ -292,7 +292,7 @@ grpc_error *grpc_create_dualstack_socket_using_factory(
return GRPC_ERROR_NONE;
}
/* If this isn't an IPv4 address, then return whatever we've got. */
- if (!grpc_sockaddr_is_v4mapped(resolved_addr, NULL)) {
+ if (!grpc_sockaddr_is_v4mapped(resolved_addr, nullptr)) {
*dsmode = GRPC_DSMODE_IPV6;
return error_for_fd(*newfd, resolved_addr);
}
@@ -307,7 +307,7 @@ grpc_error *grpc_create_dualstack_socket_using_factory(
return error_for_fd(*newfd, resolved_addr);
}
-const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size) {
+const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size) {
GPR_ASSERT(size <= (socklen_t)-1);
return inet_ntop(af, src, dst, (socklen_t)size);
}
diff --git a/src/core/lib/iomgr/socket_utils_linux.c b/src/core/lib/iomgr/socket_utils_linux.cc
index e7b094d216..12199c5c89 100644
--- a/src/core/lib/iomgr/socket_utils_linux.c
+++ b/src/core/lib/iomgr/socket_utils_linux.cc
@@ -28,15 +28,15 @@
#include <sys/socket.h>
#include <sys/types.h>
-int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, int nonblock,
+int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec) {
int flags = 0;
GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t));
GPR_ASSERT(resolved_addr->len <= (socklen_t)-1);
flags |= nonblock ? SOCK_NONBLOCK : 0;
flags |= cloexec ? SOCK_CLOEXEC : 0;
- return accept4(sockfd, (struct sockaddr *)resolved_addr->addr,
- (socklen_t *)&resolved_addr->len, flags);
+ return accept4(sockfd, (struct sockaddr*)resolved_addr->addr,
+ (socklen_t*)&resolved_addr->len, flags);
}
#endif
diff --git a/src/core/lib/iomgr/socket_utils_posix.c b/src/core/lib/iomgr/socket_utils_posix.cc
index dfd1ffd1e3..c49cbb203b 100644
--- a/src/core/lib/iomgr/socket_utils_posix.c
+++ b/src/core/lib/iomgr/socket_utils_posix.cc
@@ -29,13 +29,13 @@
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/sockaddr.h"
-int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, int nonblock,
+int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec) {
int fd, flags;
GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t));
GPR_ASSERT(resolved_addr->len <= (socklen_t)-1);
- fd = accept(sockfd, (struct sockaddr *)resolved_addr->addr,
- (socklen_t *)&resolved_addr->len);
+ fd = accept(sockfd, (struct sockaddr*)resolved_addr->addr,
+ (socklen_t*)&resolved_addr->len);
if (fd >= 0) {
if (nonblock) {
flags = fcntl(fd, F_GETFL, 0);
diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h
index eef80b439e..77df4205ff 100644
--- a/src/core/lib/iomgr/socket_utils_posix.h
+++ b/src/core/lib/iomgr/socket_utils_posix.h
@@ -30,23 +30,23 @@
#include "src/core/lib/iomgr/socket_mutator.h"
/* a wrapper for accept or accept4 */
-int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, int nonblock,
+int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec);
/* set a socket to non blocking mode */
-grpc_error *grpc_set_socket_nonblocking(int fd, int non_blocking);
+grpc_error* grpc_set_socket_nonblocking(int fd, int non_blocking);
/* set a socket to close on exec */
-grpc_error *grpc_set_socket_cloexec(int fd, int close_on_exec);
+grpc_error* grpc_set_socket_cloexec(int fd, int close_on_exec);
/* set a socket to reuse old addresses */
-grpc_error *grpc_set_socket_reuse_addr(int fd, int reuse);
+grpc_error* grpc_set_socket_reuse_addr(int fd, int reuse);
/* disable nagle */
-grpc_error *grpc_set_socket_low_latency(int fd, int low_latency);
+grpc_error* grpc_set_socket_low_latency(int fd, int low_latency);
/* set SO_REUSEPORT */
-grpc_error *grpc_set_socket_reuse_port(int fd, int reuse);
+grpc_error* grpc_set_socket_reuse_port(int fd, int reuse);
/* Returns true if this system can create AF_INET6 sockets bound to ::1.
The value is probed once, and cached for the life of the process.
@@ -60,24 +60,24 @@ int grpc_ipv6_loopback_available(void);
/* Tries to set SO_NOSIGPIPE if available on this platform.
If SO_NO_SIGPIPE is not available, returns 1. */
-grpc_error *grpc_set_socket_no_sigpipe_if_possible(int fd);
+grpc_error* grpc_set_socket_no_sigpipe_if_possible(int fd);
/* Tries to set IP_PKTINFO if available on this platform.
If IP_PKTINFO is not available, returns 1. */
-grpc_error *grpc_set_socket_ip_pktinfo_if_possible(int fd);
+grpc_error* grpc_set_socket_ip_pktinfo_if_possible(int fd);
/* Tries to set IPV6_RECVPKTINFO if available on this platform.
If IPV6_RECVPKTINFO is not available, returns 1. */
-grpc_error *grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd);
+grpc_error* grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd);
/* Tries to set the socket's send buffer to given size. */
-grpc_error *grpc_set_socket_sndbuf(int fd, int buffer_size_bytes);
+grpc_error* grpc_set_socket_sndbuf(int fd, int buffer_size_bytes);
/* Tries to set the socket's receive buffer to given size. */
-grpc_error *grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes);
+grpc_error* grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes);
/* Tries to set the socket using a grpc_socket_mutator */
-grpc_error *grpc_set_socket_with_mutator(int fd, grpc_socket_mutator *mutator);
+grpc_error* grpc_set_socket_with_mutator(int fd, grpc_socket_mutator* mutator);
/* An enum to keep track of IPv4/IPv6 socket modes.
@@ -118,15 +118,15 @@ extern int grpc_forbid_dualstack_sockets_for_testing;
IPv4, so that bind() or connect() see the correct family.
Also, it's important to distinguish between DUALSTACK and IPV6 when
listening on the [::] wildcard address. */
-grpc_error *grpc_create_dualstack_socket(const grpc_resolved_address *addr,
+grpc_error* grpc_create_dualstack_socket(const grpc_resolved_address* addr,
int type, int protocol,
- grpc_dualstack_mode *dsmode,
- int *newfd);
+ grpc_dualstack_mode* dsmode,
+ int* newfd);
/* Same as grpc_create_dualstack_socket(), but use the given socket factory (if
non-null) to create the socket, rather than calling socket() directly. */
-grpc_error *grpc_create_dualstack_socket_using_factory(
- grpc_socket_factory *factory, const grpc_resolved_address *addr, int type,
- int protocol, grpc_dualstack_mode *dsmode, int *newfd);
+grpc_error* grpc_create_dualstack_socket_using_factory(
+ grpc_socket_factory* factory, const grpc_resolved_address* addr, int type,
+ int protocol, grpc_dualstack_mode* dsmode, int* newfd);
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */
diff --git a/src/core/lib/iomgr/socket_utils_uv.c b/src/core/lib/iomgr/socket_utils_uv.cc
index 0f7de4dfad..75316d8c24 100644
--- a/src/core/lib/iomgr/socket_utils_uv.c
+++ b/src/core/lib/iomgr/socket_utils_uv.cc
@@ -26,7 +26,7 @@
#include <grpc/support/log.h>
-const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size) {
+const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size) {
uv_inet_ntop(af, src, dst, size);
return dst;
}
diff --git a/src/core/lib/iomgr/socket_utils_windows.c b/src/core/lib/iomgr/socket_utils_windows.cc
index 2732c159aa..0482a1783d 100644
--- a/src/core/lib/iomgr/socket_utils_windows.c
+++ b/src/core/lib/iomgr/socket_utils_windows.cc
@@ -25,13 +25,9 @@
#include <grpc/support/log.h>
-const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size) {
-#ifdef GPR_WIN_INET_NTOP
- return inet_ntop(af, src, dst, size);
-#else
+const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size) {
/* Windows InetNtopA wants a mutable ip pointer */
- return InetNtopA(af, (void *)src, dst, size);
-#endif /* GPR_WIN_INET_NTOP */
+ return InetNtopA(af, (void*)src, dst, size);
}
#endif /* GRPC_WINDOWS_SOCKETUTILS */
diff --git a/src/core/lib/iomgr/socket_windows.c b/src/core/lib/iomgr/socket_windows.cc
index a0d731b942..9bb6a75dd8 100644
--- a/src/core/lib/iomgr/socket_windows.c
+++ b/src/core/lib/iomgr/socket_windows.cc
@@ -36,9 +36,9 @@
#include "src/core/lib/iomgr/pollset_windows.h"
#include "src/core/lib/iomgr/socket_windows.h"
-grpc_winsocket *grpc_winsocket_create(SOCKET socket, const char *name) {
- char *final_name;
- grpc_winsocket *r = gpr_malloc(sizeof(grpc_winsocket));
+grpc_winsocket* grpc_winsocket_create(SOCKET socket, const char* name) {
+ char* final_name;
+ grpc_winsocket* r = (grpc_winsocket*)gpr_malloc(sizeof(grpc_winsocket));
memset(r, 0, sizeof(grpc_winsocket));
r->socket = socket;
gpr_mu_init(&r->state_mu);
@@ -53,7 +53,7 @@ grpc_winsocket *grpc_winsocket_create(SOCKET socket, const char *name) {
operations to abort them. We need to do that this way because of the
various callsites of that function, which happens to be in various
mutex hold states, and that'd be unsafe to call them directly. */
-void grpc_winsocket_shutdown(grpc_winsocket *winsocket) {
+void grpc_winsocket_shutdown(grpc_winsocket* winsocket) {
/* Grab the function pointer for DisconnectEx for that specific socket.
It may change depending on the interface. */
int status;
@@ -76,7 +76,7 @@ void grpc_winsocket_shutdown(grpc_winsocket *winsocket) {
if (status == 0) {
DisconnectEx(winsocket->socket, NULL, 0, 0);
} else {
- char *utf8_message = gpr_format_message(WSAGetLastError());
+ char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_INFO, "Unable to retrieve DisconnectEx pointer : %s",
utf8_message);
gpr_free(utf8_message);
@@ -84,19 +84,19 @@ void grpc_winsocket_shutdown(grpc_winsocket *winsocket) {
closesocket(winsocket->socket);
}
-static void destroy(grpc_winsocket *winsocket) {
+static void destroy(grpc_winsocket* winsocket) {
grpc_iomgr_unregister_object(&winsocket->iomgr_object);
gpr_mu_destroy(&winsocket->state_mu);
gpr_free(winsocket);
}
-static bool check_destroyable(grpc_winsocket *winsocket) {
+static bool check_destroyable(grpc_winsocket* winsocket) {
return winsocket->destroy_called == true &&
winsocket->write_info.closure == NULL &&
winsocket->read_info.closure == NULL;
}
-void grpc_winsocket_destroy(grpc_winsocket *winsocket) {
+void grpc_winsocket_destroy(grpc_winsocket* winsocket) {
gpr_mu_lock(&winsocket->state_mu);
GPR_ASSERT(!winsocket->destroy_called);
winsocket->destroy_called = true;
@@ -109,37 +109,34 @@ void grpc_winsocket_destroy(grpc_winsocket *winsocket) {
-) The IOCP already completed in the background, and we need to call
the callback now.
-) The IOCP hasn't completed yet, and we're queuing it for later. */
-static void socket_notify_on_iocp(grpc_exec_ctx *exec_ctx,
- grpc_winsocket *socket, grpc_closure *closure,
- grpc_winsocket_callback_info *info) {
+static void socket_notify_on_iocp(grpc_winsocket* socket, grpc_closure* closure,
+ grpc_winsocket_callback_info* info) {
GPR_ASSERT(info->closure == NULL);
gpr_mu_lock(&socket->state_mu);
if (info->has_pending_iocp) {
info->has_pending_iocp = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
} else {
info->closure = closure;
}
gpr_mu_unlock(&socket->state_mu);
}
-void grpc_socket_notify_on_write(grpc_exec_ctx *exec_ctx,
- grpc_winsocket *socket,
- grpc_closure *closure) {
- socket_notify_on_iocp(exec_ctx, socket, closure, &socket->write_info);
+void grpc_socket_notify_on_write(grpc_winsocket* socket,
+ grpc_closure* closure) {
+ socket_notify_on_iocp(socket, closure, &socket->write_info);
}
-void grpc_socket_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket,
- grpc_closure *closure) {
- socket_notify_on_iocp(exec_ctx, socket, closure, &socket->read_info);
+void grpc_socket_notify_on_read(grpc_winsocket* socket, grpc_closure* closure) {
+ socket_notify_on_iocp(socket, closure, &socket->read_info);
}
-void grpc_socket_become_ready(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket,
- grpc_winsocket_callback_info *info) {
+void grpc_socket_become_ready(grpc_winsocket* socket,
+ grpc_winsocket_callback_info* info) {
GPR_ASSERT(!info->has_pending_iocp);
gpr_mu_lock(&socket->state_mu);
if (info->closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, info->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(info->closure, GRPC_ERROR_NONE);
info->closure = NULL;
} else {
info->has_pending_iocp = 1;
diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h
index 67dc4ca53e..cb28f2b8df 100644
--- a/src/core/lib/iomgr/socket_windows.h
+++ b/src/core/lib/iomgr/socket_windows.h
@@ -20,6 +20,9 @@
#define GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H
#include <grpc/support/port_platform.h>
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_WINSOCK_SOCKET
#include <winsock2.h>
#include <grpc/support/atm.h>
@@ -40,7 +43,7 @@ typedef struct grpc_winsocket_callback_info {
OVERLAPPED overlapped;
/* The callback information for the pending operation. May be empty if the
caller hasn't registered a callback yet. */
- grpc_closure *closure;
+ grpc_closure* closure;
/* A boolean to describe if the IO Completion Port got a notification for
that operation. This will happen if the operation completed before the
called had time to register a callback. We could avoid that behavior
@@ -86,25 +89,24 @@ typedef struct grpc_winsocket {
/* Create a wrapped windows handle. This takes ownership of it, meaning that
it will be responsible for closing it. */
-grpc_winsocket *grpc_winsocket_create(SOCKET socket, const char *name);
+grpc_winsocket* grpc_winsocket_create(SOCKET socket, const char* name);
/* Initiate an asynchronous shutdown of the socket. Will call off any pending
operation to cancel them. */
-void grpc_winsocket_shutdown(grpc_winsocket *socket);
+void grpc_winsocket_shutdown(grpc_winsocket* socket);
/* Destroy a socket. Should only be called if there's no pending operation. */
-void grpc_winsocket_destroy(grpc_winsocket *socket);
+void grpc_winsocket_destroy(grpc_winsocket* socket);
+
+void grpc_socket_notify_on_write(grpc_winsocket* winsocket,
+ grpc_closure* closure);
-void grpc_socket_notify_on_write(grpc_exec_ctx *exec_ctx,
- grpc_winsocket *winsocket,
- grpc_closure *closure);
+void grpc_socket_notify_on_read(grpc_winsocket* winsocket,
+ grpc_closure* closure);
-void grpc_socket_notify_on_read(grpc_exec_ctx *exec_ctx,
- grpc_winsocket *winsocket,
- grpc_closure *closure);
+void grpc_socket_become_ready(grpc_winsocket* winsocket,
+ grpc_winsocket_callback_info* ci);
-void grpc_socket_become_ready(grpc_exec_ctx *exec_ctx,
- grpc_winsocket *winsocket,
- grpc_winsocket_callback_info *ci);
+#endif
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */
diff --git a/src/core/lib/iomgr/tcp_client.h b/src/core/lib/iomgr/tcp_client.h
index 6c9e51ae84..5f55d30955 100644
--- a/src/core/lib/iomgr/tcp_client.h
+++ b/src/core/lib/iomgr/tcp_client.h
@@ -30,11 +30,10 @@
NULL on failure).
interested_parties points to a set of pollsets that would be interested
in this connection being established (in order to continue their work) */
-void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect,
- grpc_endpoint **endpoint,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline);
+void grpc_tcp_client_connect(grpc_closure* on_connect, grpc_endpoint** endpoint,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline);
#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */
diff --git a/src/core/lib/iomgr/tcp_client_posix.c b/src/core/lib/iomgr/tcp_client_posix.cc
index 39dbb506e2..3dff624065 100644
--- a/src/core/lib/iomgr/tcp_client_posix.c
+++ b/src/core/lib/iomgr/tcp_client_posix.cc
@@ -33,6 +33,7 @@
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_posix.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
@@ -41,28 +42,26 @@
#include "src/core/lib/iomgr/tcp_posix.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
-#include "src/core/lib/support/string.h"
-extern grpc_tracer_flag grpc_tcp_trace;
+extern grpc_core::TraceFlag grpc_tcp_trace;
typedef struct {
gpr_mu mu;
- grpc_fd *fd;
- gpr_timespec deadline;
+ grpc_fd* fd;
grpc_timer alarm;
grpc_closure on_alarm;
int refs;
grpc_closure write_closure;
- grpc_pollset_set *interested_parties;
- char *addr_str;
- grpc_endpoint **ep;
- grpc_closure *closure;
- grpc_channel_args *channel_args;
+ grpc_pollset_set* interested_parties;
+ char* addr_str;
+ grpc_endpoint** ep;
+ grpc_closure* closure;
+ grpc_channel_args* channel_args;
} async_connect;
-static grpc_error *prepare_socket(const grpc_resolved_address *addr, int fd,
- const grpc_channel_args *channel_args) {
- grpc_error *err = GRPC_ERROR_NONE;
+static grpc_error* prepare_socket(const grpc_resolved_address* addr, int fd,
+ const grpc_channel_args* channel_args) {
+ grpc_error* err = GRPC_ERROR_NONE;
GPR_ASSERT(fd >= 0);
@@ -80,8 +79,8 @@ static grpc_error *prepare_socket(const grpc_resolved_address *addr, int fd,
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_SOCKET_MUTATOR)) {
GPR_ASSERT(channel_args->args[i].type == GRPC_ARG_POINTER);
- grpc_socket_mutator *mutator =
- (grpc_socket_mutator *)channel_args->args[i].value.pointer.p;
+ grpc_socket_mutator* mutator =
+ (grpc_socket_mutator*)channel_args->args[i].value.pointer.p;
err = grpc_set_socket_with_mutator(fd, mutator);
if (err != GRPC_ERROR_NONE) goto error;
}
@@ -97,49 +96,48 @@ done:
return err;
}
-static void tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
+static void tc_on_alarm(void* acp, grpc_error* error) {
int done;
- async_connect *ac = (async_connect *)acp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
+ async_connect* ac = (async_connect*)acp;
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s", ac->addr_str,
str);
}
gpr_mu_lock(&ac->mu);
- if (ac->fd != NULL) {
- grpc_fd_shutdown(exec_ctx, ac->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "connect() timed out"));
+ if (ac->fd != nullptr) {
+ grpc_fd_shutdown(
+ ac->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("connect() timed out"));
}
done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu);
if (done) {
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_str);
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_free(ac);
}
}
-grpc_endpoint *grpc_tcp_client_create_from_fd(
- grpc_exec_ctx *exec_ctx, grpc_fd *fd, const grpc_channel_args *channel_args,
- const char *addr_str) {
- return grpc_tcp_create(exec_ctx, fd, channel_args, addr_str);
+grpc_endpoint* grpc_tcp_client_create_from_fd(
+ grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str) {
+ return grpc_tcp_create(fd, channel_args, addr_str);
}
-static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
- async_connect *ac = (async_connect *)acp;
+static void on_writable(void* acp, grpc_error* error) {
+ async_connect* ac = (async_connect*)acp;
int so_error = 0;
socklen_t so_error_size;
int err;
int done;
- grpc_endpoint **ep = ac->ep;
- grpc_closure *closure = ac->closure;
- grpc_fd *fd;
+ grpc_endpoint** ep = ac->ep;
+ grpc_closure* closure = ac->closure;
+ grpc_fd* fd;
GRPC_ERROR_REF(error);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_writable: error=%s",
ac->addr_str, str);
}
@@ -147,10 +145,10 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
gpr_mu_lock(&ac->mu);
GPR_ASSERT(ac->fd);
fd = ac->fd;
- ac->fd = NULL;
+ ac->fd = nullptr;
gpr_mu_unlock(&ac->mu);
- grpc_timer_cancel(exec_ctx, &ac->alarm);
+ grpc_timer_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu);
if (error != GRPC_ERROR_NONE) {
@@ -172,10 +170,9 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
switch (so_error) {
case 0:
- grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd);
- *ep = grpc_tcp_client_create_from_fd(exec_ctx, fd, ac->channel_args,
- ac->addr_str);
- fd = NULL;
+ grpc_pollset_set_del_fd(ac->interested_parties, fd);
+ *ep = grpc_tcp_client_create_from_fd(fd, ac->channel_args, ac->addr_str);
+ fd = nullptr;
break;
case ENOBUFS:
/* We will get one of these errors if we have run out of
@@ -194,7 +191,7 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
don't do that! */
gpr_log(GPR_ERROR, "kernel out of buffers");
gpr_mu_unlock(&ac->mu);
- grpc_fd_notify_on_write(exec_ctx, fd, &ac->write_closure);
+ grpc_fd_notify_on_write(fd, &ac->write_closure);
return;
case ECONNREFUSED:
/* This error shouldn't happen for anything other than connect(). */
@@ -208,149 +205,167 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
}
finish:
- if (fd != NULL) {
- grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd);
- grpc_fd_orphan(exec_ctx, fd, NULL, NULL, false /* already_closed */,
+ if (fd != nullptr) {
+ grpc_pollset_set_del_fd(ac->interested_parties, fd);
+ grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */,
"tcp_client_orphan");
- fd = NULL;
+ fd = nullptr;
}
done = (--ac->refs == 0);
+ // Create a copy of the data from "ac" to be accessed after the unlock, as
+ // "ac" and its contents may be deallocated by the time they are read.
+ const grpc_slice addr_str_slice = grpc_slice_from_copied_string(ac->addr_str);
gpr_mu_unlock(&ac->mu);
if (error != GRPC_ERROR_NONE) {
- char *error_descr;
+ char* error_descr;
grpc_slice str;
bool ret = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str);
GPR_ASSERT(ret);
- char *desc = grpc_slice_to_c_string(str);
+ char* desc = grpc_slice_to_c_string(str);
gpr_asprintf(&error_descr, "Failed to connect to remote host: %s", desc);
error = grpc_error_set_str(error, GRPC_ERROR_STR_DESCRIPTION,
grpc_slice_from_copied_string(error_descr));
gpr_free(error_descr);
gpr_free(desc);
error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
- grpc_slice_from_copied_string(ac->addr_str));
+ addr_str_slice /* takes ownership */);
+ } else {
+ grpc_slice_unref(addr_str_slice);
}
if (done) {
+ // This is safe even outside the lock, because "done", the sentinel, is
+ // populated *inside* the lock.
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_str);
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_free(ac);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
+ GRPC_CLOSURE_SCHED(closure, error);
}
-static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) {
- int fd;
+grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_resolved_address* mapped_addr,
+ grpc_fd** fdobj) {
grpc_dualstack_mode dsmode;
- int err;
- async_connect *ac;
- grpc_resolved_address addr6_v4mapped;
- grpc_resolved_address addr4_copy;
- grpc_fd *fdobj;
- char *name;
- char *addr_str;
- grpc_error *error;
-
- *ep = NULL;
-
- /* Use dualstack sockets where available. */
- if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
- addr = &addr6_v4mapped;
+ int fd;
+ grpc_error* error;
+ char* name;
+ char* addr_str;
+ *fdobj = nullptr;
+ /* Use dualstack sockets where available. Set mapped to v6 or v4 mapped to
+ v6. */
+ if (!grpc_sockaddr_to_v4mapped(addr, mapped_addr)) {
+ /* addr is v4 mapped to v6 or v6. */
+ memcpy(mapped_addr, addr, sizeof(*mapped_addr));
}
-
- error = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode, &fd);
+ error =
+ grpc_create_dualstack_socket(mapped_addr, SOCK_STREAM, 0, &dsmode, &fd);
if (error != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
- return;
+ return error;
}
if (dsmode == GRPC_DSMODE_IPV4) {
- /* If we got an AF_INET socket, map the address back to IPv4. */
- GPR_ASSERT(grpc_sockaddr_is_v4mapped(addr, &addr4_copy));
- addr = &addr4_copy;
+ /* Original addr is either v4 or v4 mapped to v6. Set mapped_addr to v4. */
+ if (!grpc_sockaddr_is_v4mapped(addr, mapped_addr)) {
+ memcpy(mapped_addr, addr, sizeof(*mapped_addr));
+ }
}
- if ((error = prepare_socket(addr, fd, channel_args)) != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
- return;
+ if ((error = prepare_socket(mapped_addr, fd, channel_args)) !=
+ GRPC_ERROR_NONE) {
+ return error;
}
+ addr_str = grpc_sockaddr_to_uri(mapped_addr);
+ gpr_asprintf(&name, "tcp-client:%s", addr_str);
+ *fdobj = grpc_fd_create(fd, name);
+ gpr_free(name);
+ gpr_free(addr_str);
+ return GRPC_ERROR_NONE;
+}
+void grpc_tcp_client_create_from_prepared_fd(
+ grpc_pollset_set* interested_parties, grpc_closure* closure, grpc_fd* fdobj,
+ const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
+ grpc_millis deadline, grpc_endpoint** ep) {
+ const int fd = grpc_fd_wrapped_fd(fdobj);
+ int err;
+ async_connect* ac;
do {
GPR_ASSERT(addr->len < ~(socklen_t)0);
- err =
- connect(fd, (const struct sockaddr *)addr->addr, (socklen_t)addr->len);
+ err = connect(fd, (const struct sockaddr*)addr->addr, (socklen_t)addr->len);
} while (err < 0 && errno == EINTR);
-
- addr_str = grpc_sockaddr_to_uri(addr);
- gpr_asprintf(&name, "tcp-client:%s", addr_str);
-
- fdobj = grpc_fd_create(fd, name);
-
if (err >= 0) {
- *ep =
- grpc_tcp_client_create_from_fd(exec_ctx, fdobj, channel_args, addr_str);
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
- goto done;
+ char* addr_str = grpc_sockaddr_to_uri(addr);
+ *ep = grpc_tcp_client_create_from_fd(fdobj, channel_args, addr_str);
+ gpr_free(addr_str);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
+ return;
}
-
if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
- grpc_fd_orphan(exec_ctx, fdobj, NULL, NULL, false /* already_closed */,
+ grpc_fd_orphan(fdobj, nullptr, nullptr, false /* already_closed */,
"tcp_client_connect_error");
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_OS_ERROR(errno, "connect"));
- goto done;
+ GRPC_CLOSURE_SCHED(closure, GRPC_OS_ERROR(errno, "connect"));
+ return;
}
- grpc_pollset_set_add_fd(exec_ctx, interested_parties, fdobj);
+ grpc_pollset_set_add_fd(interested_parties, fdobj);
- ac = (async_connect *)gpr_malloc(sizeof(async_connect));
+ ac = (async_connect*)gpr_malloc(sizeof(async_connect));
ac->closure = closure;
ac->ep = ep;
ac->fd = fdobj;
ac->interested_parties = interested_parties;
- ac->addr_str = addr_str;
- addr_str = NULL;
+ ac->addr_str = grpc_sockaddr_to_uri(addr);
gpr_mu_init(&ac->mu);
ac->refs = 2;
GRPC_CLOSURE_INIT(&ac->write_closure, on_writable, ac,
grpc_schedule_on_exec_ctx);
ac->channel_args = grpc_channel_args_copy(channel_args);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting fd %p",
ac->addr_str, fdobj);
}
gpr_mu_lock(&ac->mu);
GRPC_CLOSURE_INIT(&ac->on_alarm, tc_on_alarm, ac, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &ac->alarm,
- gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC),
- &ac->on_alarm, gpr_now(GPR_CLOCK_MONOTONIC));
- grpc_fd_notify_on_write(exec_ctx, ac->fd, &ac->write_closure);
+ grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
+ grpc_fd_notify_on_write(ac->fd, &ac->write_closure);
gpr_mu_unlock(&ac->mu);
+}
-done:
- gpr_free(name);
- gpr_free(addr_str);
+static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
+ grpc_resolved_address mapped_addr;
+ grpc_fd* fdobj = nullptr;
+ grpc_error* error;
+ *ep = nullptr;
+ if ((error = grpc_tcp_client_prepare_fd(channel_args, addr, &mapped_addr,
+ &fdobj)) != GRPC_ERROR_NONE) {
+ GRPC_CLOSURE_SCHED(closure, error);
+ return;
+ }
+ grpc_tcp_client_create_from_prepared_fd(interested_parties, closure, fdobj,
+ channel_args, &mapped_addr, deadline,
+ ep);
}
// overridden by api_fuzzer.c
void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) = tcp_client_connect_impl;
-
-void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_endpoint **ep,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) = tcp_client_connect_impl;
+
+void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif
diff --git a/src/core/lib/iomgr/tcp_client_posix.h b/src/core/lib/iomgr/tcp_client_posix.h
index b5a3814799..57e50a67d2 100644
--- a/src/core/lib/iomgr/tcp_client_posix.h
+++ b/src/core/lib/iomgr/tcp_client_posix.h
@@ -23,8 +23,44 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/tcp_client.h"
-grpc_endpoint *grpc_tcp_client_create_from_fd(
- grpc_exec_ctx *exec_ctx, grpc_fd *fd, const grpc_channel_args *channel_args,
- const char *addr_str);
+/* Create an endpoint from a connected grpc_fd.
+
+ fd: a connected FD. Ownership is taken.
+ channel_args: may contain custom settings for the endpoint
+ addr_str: destination address in printable format
+ Returns: a new endpoint
+*/
+grpc_endpoint* grpc_tcp_client_create_from_fd(
+ grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str);
+
+/* Return a configured, unbound, unconnected TCP client grpc_fd.
+
+ channel_args: may contain custom settings for the fd
+ addr: the destination address
+ mapped_addr: out parameter. addr mapped to an address appropriate to the
+ type of socket FD created. For example, if addr is IPv4 and dual stack
+ sockets are available, mapped_addr will be an IPv4-mapped IPv6 address
+ fdobj: out parameter. The new FD
+ Returns: error, if any. Out parameters are not set on error
+*/
+grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_resolved_address* mapped_addr,
+ grpc_fd** fdobj);
+
+/* Connect a configured TCP client grpc_fd.
+
+ interested_parties: a set of pollsets that would be interested in this
+ connection being established (in order to continue their work
+ closure: called when complete. On success, *ep will be set.
+ fdobj: an FD returned from grpc_tcp_client_prepare_fd(). Ownership is taken
+ channel_args: may contain custom settings for the endpoint
+ deadline: connection deadline
+ ep: out parameter. Set before closure is called if successful
+*/
+void grpc_tcp_client_create_from_prepared_fd(
+ grpc_pollset_set* interested_parties, grpc_closure* closure, grpc_fd* fdobj,
+ const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
+ grpc_millis deadline, grpc_endpoint** ep);
#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */
diff --git a/src/core/lib/iomgr/tcp_client_uv.c b/src/core/lib/iomgr/tcp_client_uv.cc
index 786c456b73..4e9c7cc11d 100644
--- a/src/core/lib/iomgr/tcp_client_uv.c
+++ b/src/core/lib/iomgr/tcp_client_uv.cc
@@ -32,35 +32,33 @@
#include "src/core/lib/iomgr/tcp_uv.h"
#include "src/core/lib/iomgr/timer.h"
-extern grpc_tracer_flag grpc_tcp_trace;
+extern grpc_core::TraceFlag grpc_tcp_trace;
typedef struct grpc_uv_tcp_connect {
uv_connect_t connect_req;
grpc_timer alarm;
grpc_closure on_alarm;
- uv_tcp_t *tcp_handle;
- grpc_closure *closure;
- grpc_endpoint **endpoint;
+ uv_tcp_t* tcp_handle;
+ grpc_closure* closure;
+ grpc_endpoint** endpoint;
int refs;
- char *addr_name;
- grpc_resource_quota *resource_quota;
+ char* addr_name;
+ grpc_resource_quota* resource_quota;
} grpc_uv_tcp_connect;
-static void uv_tcp_connect_cleanup(grpc_exec_ctx *exec_ctx,
- grpc_uv_tcp_connect *connect) {
- grpc_resource_quota_unref_internal(exec_ctx, connect->resource_quota);
+static void uv_tcp_connect_cleanup(grpc_uv_tcp_connect* connect) {
+ grpc_resource_quota_unref_internal(connect->resource_quota);
gpr_free(connect->addr_name);
gpr_free(connect);
}
-static void tcp_close_callback(uv_handle_t *handle) { gpr_free(handle); }
+static void tcp_close_callback(uv_handle_t* handle) { gpr_free(handle); }
-static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp,
- grpc_error *error) {
+static void uv_tc_on_alarm(void* acp, grpc_error* error) {
int done;
- grpc_uv_tcp_connect *connect = acp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
+ grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)acp;
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s",
connect->addr_name, str);
}
@@ -68,21 +66,21 @@ static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp,
/* error == NONE implies that the timer ran out, and wasn't cancelled. If
it was cancelled, then the handler that cancelled it also should close
the handle, if applicable */
- uv_close((uv_handle_t *)connect->tcp_handle, tcp_close_callback);
+ uv_close((uv_handle_t*)connect->tcp_handle, tcp_close_callback);
}
done = (--connect->refs == 0);
if (done) {
- uv_tcp_connect_cleanup(exec_ctx, connect);
+ uv_tcp_connect_cleanup(connect);
}
}
-static void uv_tc_on_connect(uv_connect_t *req, int status) {
- grpc_uv_tcp_connect *connect = req->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_error *error = GRPC_ERROR_NONE;
+static void uv_tc_on_connect(uv_connect_t* req, int status) {
+ grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)req->data;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_error* error = GRPC_ERROR_NONE;
int done;
- grpc_closure *closure = connect->closure;
- grpc_timer_cancel(&exec_ctx, &connect->alarm);
+ grpc_closure* closure = connect->closure;
+ grpc_timer_cancel(&connect->alarm);
if (status == 0) {
*connect->endpoint = grpc_tcp_create(
connect->tcp_handle, connect->resource_quota, connect->addr_name);
@@ -102,26 +100,24 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) {
error = grpc_error_set_str(
error, GRPC_ERROR_STR_OS_ERROR,
grpc_slice_from_static_string(uv_strerror(status)));
- uv_close((uv_handle_t *)connect->tcp_handle, tcp_close_callback);
+ uv_close((uv_handle_t*)connect->tcp_handle, tcp_close_callback);
}
}
done = (--connect->refs == 0);
if (done) {
- grpc_exec_ctx_flush(&exec_ctx);
- uv_tcp_connect_cleanup(&exec_ctx, connect);
+ grpc_core::ExecCtx::Get()->Flush();
+ uv_tcp_connect_cleanup(connect);
}
- GRPC_CLOSURE_SCHED(&exec_ctx, closure, error);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(closure, error);
}
-static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *resolved_addr,
- gpr_timespec deadline) {
- grpc_uv_tcp_connect *connect;
- grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
+static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* resolved_addr,
+ grpc_millis deadline) {
+ grpc_uv_tcp_connect* connect;
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL);
(void)channel_args;
(void)interested_parties;
@@ -130,54 +126,50 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
if (channel_args != NULL) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
resource_quota = grpc_resource_quota_ref_internal(
- channel_args->args[i].value.pointer.p);
+ (grpc_resource_quota*)channel_args->args[i].value.pointer.p);
}
}
}
- connect = gpr_zalloc(sizeof(grpc_uv_tcp_connect));
+ connect = (grpc_uv_tcp_connect*)gpr_zalloc(sizeof(grpc_uv_tcp_connect));
connect->closure = closure;
connect->endpoint = ep;
- connect->tcp_handle = gpr_malloc(sizeof(uv_tcp_t));
+ connect->tcp_handle = (uv_tcp_t*)gpr_malloc(sizeof(uv_tcp_t));
connect->addr_name = grpc_sockaddr_to_uri(resolved_addr);
connect->resource_quota = resource_quota;
uv_tcp_init(uv_default_loop(), connect->tcp_handle);
connect->connect_req.data = connect;
- connect->refs = 1;
+ connect->refs = 2; // One for the connect operation, one for the timer.
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting",
connect->addr_name);
}
// TODO(murgatroid99): figure out what the return value here means
uv_tcp_connect(&connect->connect_req, connect->tcp_handle,
- (const struct sockaddr *)resolved_addr->addr,
- uv_tc_on_connect);
+ (const struct sockaddr*)resolved_addr->addr, uv_tc_on_connect);
GRPC_CLOSURE_INIT(&connect->on_alarm, uv_tc_on_alarm, connect,
grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &connect->alarm,
- gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC),
- &connect->on_alarm, gpr_now(GPR_CLOCK_MONOTONIC));
+ grpc_timer_init(&connect->alarm, deadline, &connect->on_alarm);
}
// overridden by api_fuzzer.c
void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) = tcp_client_connect_impl;
-
-void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_endpoint **ep,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) = tcp_client_connect_impl;
+
+void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.cc
index fc62105cc9..97aa9237dc 100644
--- a/src/core/lib/iomgr/tcp_client_windows.c
+++ b/src/core/lib/iomgr/tcp_client_windows.cc
@@ -18,6 +18,8 @@
#include "src/core/lib/iomgr/port.h"
+#include <inttypes.h>
+
#ifdef GRPC_WINSOCK_SOCKET
#include "src/core/lib/iomgr/sockaddr_windows.h"
@@ -38,26 +40,24 @@
#include "src/core/lib/iomgr/timer.h"
typedef struct {
- grpc_closure *on_done;
+ grpc_closure* on_done;
gpr_mu mu;
- grpc_winsocket *socket;
- gpr_timespec deadline;
+ grpc_winsocket* socket;
grpc_timer alarm;
grpc_closure on_alarm;
- char *addr_name;
+ char* addr_name;
int refs;
grpc_closure on_connect;
- grpc_endpoint **endpoint;
- grpc_channel_args *channel_args;
+ grpc_endpoint** endpoint;
+ grpc_channel_args* channel_args;
} async_connect;
-static void async_connect_unlock_and_cleanup(grpc_exec_ctx *exec_ctx,
- async_connect *ac,
- grpc_winsocket *socket) {
+static void async_connect_unlock_and_cleanup(async_connect* ac,
+ grpc_winsocket* socket) {
int done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu);
if (done) {
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_name);
gpr_free(ac);
@@ -65,31 +65,31 @@ static void async_connect_unlock_and_cleanup(grpc_exec_ctx *exec_ctx,
if (socket != NULL) grpc_winsocket_destroy(socket);
}
-static void on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
- async_connect *ac = acp;
+static void on_alarm(void* acp, grpc_error* error) {
+ async_connect* ac = (async_connect*)acp;
gpr_mu_lock(&ac->mu);
- grpc_winsocket *socket = ac->socket;
+ grpc_winsocket* socket = ac->socket;
ac->socket = NULL;
if (socket != NULL) {
grpc_winsocket_shutdown(socket);
}
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
+ async_connect_unlock_and_cleanup(ac, socket);
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
- async_connect *ac = acp;
- grpc_endpoint **ep = ac->endpoint;
+static void on_connect(void* acp, grpc_error* error) {
+ async_connect* ac = (async_connect*)acp;
+ grpc_endpoint** ep = ac->endpoint;
GPR_ASSERT(*ep == NULL);
- grpc_closure *on_done = ac->on_done;
+ grpc_closure* on_done = ac->on_done;
GRPC_ERROR_REF(error);
gpr_mu_lock(&ac->mu);
- grpc_winsocket *socket = ac->socket;
+ grpc_winsocket* socket = ac->socket;
ac->socket = NULL;
gpr_mu_unlock(&ac->mu);
- grpc_timer_cancel(exec_ctx, &ac->alarm);
+ grpc_timer_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu);
@@ -103,9 +103,9 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
GPR_ASSERT(transfered_bytes == 0);
if (!wsa_success) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
+ closesocket(socket->socket);
} else {
- *ep =
- grpc_tcp_create(exec_ctx, socket, ac->channel_args, ac->addr_name);
+ *ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name);
socket = NULL;
}
} else {
@@ -113,30 +113,32 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
}
}
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
+ async_connect_unlock_and_cleanup(ac, socket);
/* If the connection was aborted, the callback was already called when
the deadline was met. */
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
/* Tries to issue one async connection, then schedules both an IOCP
notification request for the connection, and one timeout alert. */
-static void tcp_client_connect_impl(
- grpc_exec_ctx *exec_ctx, grpc_closure *on_done, grpc_endpoint **endpoint,
- grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr, gpr_timespec deadline) {
+static void tcp_client_connect_impl(grpc_closure* on_done,
+ grpc_endpoint** endpoint,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
SOCKET sock = INVALID_SOCKET;
BOOL success;
int status;
grpc_resolved_address addr6_v4mapped;
grpc_resolved_address local_address;
- async_connect *ac;
- grpc_winsocket *socket = NULL;
+ async_connect* ac;
+ grpc_winsocket* socket = NULL;
LPFN_CONNECTEX ConnectEx;
GUID guid = WSAID_CONNECTEX;
DWORD ioctl_num_bytes;
- grpc_winsocket_callback_info *info;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_winsocket_callback_info* info;
+ grpc_error* error = GRPC_ERROR_NONE;
*endpoint = NULL;
@@ -171,8 +173,8 @@ static void tcp_client_connect_impl(
grpc_sockaddr_make_wildcard6(0, &local_address);
- status = bind(sock, (struct sockaddr *)&local_address.addr,
- (int)local_address.len);
+ status =
+ bind(sock, (struct sockaddr*)&local_address.addr, (int)local_address.len);
if (status != 0) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "bind");
goto failure;
@@ -180,8 +182,8 @@ static void tcp_client_connect_impl(
socket = grpc_winsocket_create(sock, "client");
info = &socket->write_info;
- success = ConnectEx(sock, (struct sockaddr *)&addr->addr, (int)addr->len,
- NULL, 0, NULL, &info->overlapped);
+ success = ConnectEx(sock, (struct sockaddr*)&addr->addr, (int)addr->len, NULL,
+ 0, NULL, &info->overlapped);
/* It wouldn't be unusual to get a success immediately. But we'll still get
an IOCP notification, so let's ignore it. */
@@ -193,7 +195,7 @@ static void tcp_client_connect_impl(
}
}
- ac = gpr_malloc(sizeof(async_connect));
+ ac = (async_connect*)gpr_malloc(sizeof(async_connect));
ac->on_done = on_done;
ac->socket = socket;
gpr_mu_init(&ac->mu);
@@ -204,15 +206,14 @@ static void tcp_client_connect_impl(
GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm,
- gpr_now(GPR_CLOCK_MONOTONIC));
- grpc_socket_notify_on_write(exec_ctx, socket, &ac->on_connect);
+ grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
+ grpc_socket_notify_on_write(socket, &ac->on_connect);
return;
failure:
GPR_ASSERT(error != GRPC_ERROR_NONE);
- char *target_uri = grpc_sockaddr_to_uri(addr);
- grpc_error *final_error = grpc_error_set_str(
+ char* target_uri = grpc_sockaddr_to_uri(addr);
+ grpc_error* final_error = grpc_error_set_str(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Failed to connect",
&error, 1),
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(target_uri));
@@ -222,24 +223,23 @@ failure:
} else if (sock != INVALID_SOCKET) {
closesocket(sock);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, final_error);
+ GRPC_CLOSURE_SCHED(on_done, final_error);
}
// overridden by api_fuzzer.c
void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) = tcp_client_connect_impl;
-
-void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_endpoint **ep,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) = tcp_client_connect_impl;
+
+void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif /* GRPC_WINSOCK_SOCKET */
diff --git a/src/core/lib/iomgr/tcp_posix.c b/src/core/lib/iomgr/tcp_posix.cc
index 7e271294fd..0ec5926227 100644
--- a/src/core/lib/iomgr/tcp_posix.c
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -42,12 +42,12 @@
#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/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#ifdef GRPC_HAVE_MSG_NOSIGNAL
#define SENDMSG_FLAGS MSG_NOSIGNAL
@@ -61,11 +61,12 @@ typedef GRPC_MSG_IOVLEN_TYPE msg_iovlen_type;
typedef size_t msg_iovlen_type;
#endif
-grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false, "tcp");
+grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
-typedef struct {
+namespace {
+struct grpc_tcp {
grpc_endpoint base;
- grpc_fd *em_fd;
+ grpc_fd* em_fd;
int fd;
bool finished_edge;
double target_length;
@@ -79,69 +80,61 @@ typedef struct {
/* garbage after the last read */
grpc_slice_buffer last_read_buffer;
- grpc_slice_buffer *incoming_buffer;
- grpc_slice_buffer *outgoing_buffer;
- /** slice within outgoing_buffer to write next */
- size_t outgoing_slice_idx;
- /** byte within outgoing_buffer->slices[outgoing_slice_idx] to write next */
+ grpc_slice_buffer* incoming_buffer;
+ grpc_slice_buffer* outgoing_buffer;
+ /** byte within outgoing_buffer->slices[0] to write next */
size_t outgoing_byte_idx;
- grpc_closure *read_cb;
- grpc_closure *write_cb;
- grpc_closure *release_fd_cb;
- int *release_fd;
+ grpc_closure* read_cb;
+ grpc_closure* write_cb;
+ grpc_closure* release_fd_cb;
+ int* release_fd;
grpc_closure read_done_closure;
grpc_closure write_done_closure;
- char *peer_string;
+ char* peer_string;
- grpc_resource_user *resource_user;
+ grpc_resource_user* resource_user;
grpc_resource_user_slice_allocator slice_allocator;
-} grpc_tcp;
+};
-typedef struct backup_poller {
- gpr_mu *pollset_mu;
+struct backup_poller {
+ gpr_mu* pollset_mu;
grpc_closure run_poller;
-} backup_poller;
+};
+} // namespace
-#define BACKUP_POLLER_POLLSET(b) ((grpc_pollset *)((b) + 1))
+#define BACKUP_POLLER_POLLSET(b) ((grpc_pollset*)((b) + 1))
static gpr_atm g_uncovered_notifications_pending;
static gpr_atm g_backup_poller; /* backup_poller* */
-static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
- grpc_error *error);
-static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
- grpc_error *error);
-static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx *exec_ctx,
- void *arg /* grpc_tcp */,
- grpc_error *error);
-
-static void done_poller(grpc_exec_ctx *exec_ctx, void *bp,
- grpc_error *error_ignored) {
- backup_poller *p = (backup_poller *)bp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
+static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
+static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */,
+ grpc_error* error);
+
+static void done_poller(void* bp, grpc_error* error_ignored) {
+ backup_poller* p = (backup_poller*)bp;
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p);
}
- grpc_pollset_destroy(exec_ctx, BACKUP_POLLER_POLLSET(p));
+ grpc_pollset_destroy(BACKUP_POLLER_POLLSET(p));
gpr_free(p);
}
-static void run_poller(grpc_exec_ctx *exec_ctx, void *bp,
- grpc_error *error_ignored) {
- backup_poller *p = (backup_poller *)bp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void run_poller(void* bp, grpc_error* error_ignored) {
+ backup_poller* p = (backup_poller*)bp;
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
}
gpr_mu_lock(p->pollset_mu);
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec deadline =
- gpr_time_add(now, gpr_time_from_seconds(10, GPR_TIMESPAN));
- GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx);
- GRPC_LOG_IF_ERROR("backup_poller:pollset_work",
- grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL,
- now, deadline));
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 13 * GPR_MS_PER_SEC;
+ GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
+ GRPC_LOG_IF_ERROR(
+ "backup_poller:pollset_work",
+ grpc_pollset_work(BACKUP_POLLER_POLLSET(p), nullptr, deadline));
gpr_mu_unlock(p->pollset_mu);
/* last "uncovered" notification is the ref that keeps us polling, if we get
* there try a cas to release it */
@@ -149,104 +142,103 @@ static void run_poller(grpc_exec_ctx *exec_ctx, void *bp,
gpr_atm_full_cas(&g_uncovered_notifications_pending, 1, 0)) {
gpr_mu_lock(p->pollset_mu);
bool cas_ok = gpr_atm_full_cas(&g_backup_poller, (gpr_atm)p, 0);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p done cas_ok=%d", p, cas_ok);
}
gpr_mu_unlock(p->pollset_mu);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p shutdown", p);
}
- grpc_pollset_shutdown(exec_ctx, BACKUP_POLLER_POLLSET(p),
+ grpc_pollset_shutdown(BACKUP_POLLER_POLLSET(p),
GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p,
grpc_schedule_on_exec_ctx));
} else {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p reschedule", p);
}
- GRPC_CLOSURE_SCHED(exec_ctx, &p->run_poller, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&p->run_poller, GRPC_ERROR_NONE);
}
}
-static void drop_uncovered(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- backup_poller *p = (backup_poller *)gpr_atm_acq_load(&g_backup_poller);
+static void drop_uncovered(grpc_tcp* tcp) {
+ backup_poller* p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller);
gpr_atm old_count =
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p uncover cnt %d->%d", p, (int)old_count,
(int)old_count - 1);
}
GPR_ASSERT(old_count != 1);
}
-static void cover_self(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- backup_poller *p;
+static void cover_self(grpc_tcp* tcp) {
+ backup_poller* p;
gpr_atm old_count =
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER: cover cnt %d->%d", (int)old_count,
2 + (int)old_count);
}
if (old_count == 0) {
- GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx);
- p = (backup_poller *)gpr_malloc(sizeof(*p) + grpc_pollset_size());
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED();
+ p = (backup_poller*)gpr_zalloc(sizeof(*p) + grpc_pollset_size());
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);
}
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
grpc_executor_scheduler(GRPC_EXECUTOR_LONG)),
GRPC_ERROR_NONE);
} else {
- while ((p = (backup_poller *)gpr_atm_acq_load(&g_backup_poller)) == NULL) {
+ while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) ==
+ nullptr) {
// spin waiting for backup poller
}
}
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p add %p", p, tcp);
}
- grpc_pollset_add_fd(exec_ctx, BACKUP_POLLER_POLLSET(p), tcp->em_fd);
+ grpc_pollset_add_fd(BACKUP_POLLER_POLLSET(p), tcp->em_fd);
if (old_count != 0) {
- drop_uncovered(exec_ctx, tcp);
+ drop_uncovered(tcp);
}
}
-static void notify_on_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void notify_on_read(grpc_tcp* tcp) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p notify_on_read", tcp);
}
GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, tcp->em_fd, &tcp->read_done_closure);
+ grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_done_closure);
}
-static void notify_on_write(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void notify_on_write(grpc_tcp* tcp) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp);
}
- cover_self(exec_ctx, tcp);
+ cover_self(tcp);
GRPC_CLOSURE_INIT(&tcp->write_done_closure,
tcp_drop_uncovered_then_handle_write, tcp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, tcp->em_fd, &tcp->write_done_closure);
+ grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_done_closure);
}
-static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error));
}
- drop_uncovered(exec_ctx, (grpc_tcp *)arg);
- tcp_handle_write(exec_ctx, arg, error);
+ drop_uncovered((grpc_tcp*)arg);
+ tcp_handle_write(arg, error);
}
-static void add_to_estimate(grpc_tcp *tcp, size_t bytes) {
+static void add_to_estimate(grpc_tcp* tcp, size_t bytes) {
tcp->bytes_read_this_round += (double)bytes;
}
-static void finish_estimate(grpc_tcp *tcp) {
+static void finish_estimate(grpc_tcp* tcp) {
/* If we read >80% of the target buffer in one read loop, increase the size
of the target buffer to either the amount read, or twice its previous
value */
@@ -260,8 +252,8 @@ static void finish_estimate(grpc_tcp *tcp) {
tcp->bytes_read_this_round = 0;
}
-static size_t get_target_read_size(grpc_tcp *tcp) {
- grpc_resource_quota *rq = grpc_resource_user_quota(tcp->resource_user);
+static size_t get_target_read_size(grpc_tcp* tcp) {
+ grpc_resource_quota* rq = grpc_resource_user_quota(tcp->resource_user);
double pressure = grpc_resource_quota_get_memory_pressure(rq);
double target =
tcp->target_length * (pressure > 0.8 ? (1.0 - pressure) / 0.2 : 1.0);
@@ -278,54 +270,54 @@ static size_t get_target_read_size(grpc_tcp *tcp) {
return sz;
}
-static grpc_error *tcp_annotate_error(grpc_error *src_error, grpc_tcp *tcp) {
+static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
return grpc_error_set_str(
- grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
+ grpc_error_set_int(
+ grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
+ /* All tcp errors are marked with UNAVAILABLE so that application may
+ * choose to retry. */
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
GRPC_ERROR_STR_TARGET_ADDRESS,
grpc_slice_from_copied_string(tcp->peer_string));
}
-static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
- grpc_error *error);
-static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
- grpc_error *error);
+static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
+static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
-static void tcp_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_fd_shutdown(exec_ctx, tcp->em_fd, why);
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
+static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_fd_shutdown(tcp->em_fd, why);
+ grpc_resource_user_shutdown(tcp->resource_user);
}
-static void tcp_free(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- grpc_fd_orphan(exec_ctx, tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
+static void tcp_free(grpc_tcp* tcp) {
+ grpc_fd_orphan(tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
false /* already_closed */, "tcp_unref_orphan");
- grpc_slice_buffer_destroy_internal(exec_ctx, &tcp->last_read_buffer);
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
+ grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
+ grpc_resource_user_unref(tcp->resource_user);
gpr_free(tcp->peer_string);
gpr_free(tcp);
}
#ifndef NDEBUG
-#define TCP_UNREF(cl, tcp, reason) \
- tcp_unref((cl), (tcp), (reason), __FILE__, __LINE__)
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
-static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
- const char *reason, const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
+ if (grpc_tcp_trace.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
val - 1);
}
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
-static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file,
+static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
int line) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
@@ -334,49 +326,48 @@ static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file,
gpr_ref(&tcp->refcount);
}
#else
-#define TCP_UNREF(cl, tcp, reason) tcp_unref((cl), (tcp))
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
#define TCP_REF(tcp, reason) tcp_ref((tcp))
-static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
+static void tcp_unref(grpc_tcp* tcp) {
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
-static void tcp_ref(grpc_tcp *tcp) { gpr_ref(&tcp->refcount); }
+static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
#endif
-static void tcp_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
+static void tcp_destroy(grpc_endpoint* ep) {
grpc_network_status_unregister_endpoint(ep);
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &tcp->last_read_buffer);
- TCP_UNREF(exec_ctx, tcp, "destroy");
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ TCP_UNREF(tcp, "destroy");
}
-static void call_read_cb(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
- grpc_error *error) {
- grpc_closure *cb = tcp->read_cb;
+static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
+ grpc_closure* cb = tcp->read_cb;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
size_t i;
- const char *str = grpc_error_string(error);
+ const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "read: error=%s", str);
for (i = 0; i < tcp->incoming_buffer->count; i++) {
- char *dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
+ char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump);
gpr_free(dump);
}
}
- tcp->read_cb = NULL;
- tcp->incoming_buffer = NULL;
- GRPC_CLOSURE_RUN(exec_ctx, cb, error);
+ tcp->read_cb = nullptr;
+ tcp->incoming_buffer = nullptr;
+ GRPC_CLOSURE_RUN(cb, error);
}
#define MAX_READ_IOVEC 4
-static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
+static void tcp_do_read(grpc_tcp* tcp) {
struct msghdr msg;
struct iovec iov[MAX_READ_IOVEC];
ssize_t read_bytes;
@@ -391,20 +382,20 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]);
}
- msg.msg_name = NULL;
+ msg.msg_name = nullptr;
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = (msg_iovlen_type)tcp->incoming_buffer->count;
- msg.msg_control = NULL;
+ msg.msg_control = nullptr;
msg.msg_controllen = 0;
msg.msg_flags = 0;
- GRPC_STATS_INC_TCP_READ_OFFER(exec_ctx, tcp->incoming_buffer->length);
- GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(exec_ctx, tcp->incoming_buffer->count);
+ GRPC_STATS_INC_TCP_READ_OFFER(tcp->incoming_buffer->length);
+ GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(tcp->incoming_buffer->count);
GPR_TIMER_BEGIN("recvmsg", 0);
do {
- GRPC_STATS_INC_SYSCALL_READ(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_READ();
read_bytes = recvmsg(tcp->fd, &msg, 0);
} while (read_bytes < 0 && errno == EINTR);
GPR_TIMER_END("recvmsg", read_bytes >= 0);
@@ -415,24 +406,22 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
if (errno == EAGAIN) {
finish_estimate(tcp);
/* We've consumed the edge, request a new one */
- notify_on_read(exec_ctx, tcp);
+ notify_on_read(tcp);
} else {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- tcp->incoming_buffer);
- call_read_cb(exec_ctx, tcp,
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
+ call_read_cb(tcp,
tcp_annotate_error(GRPC_OS_ERROR(errno, "recvmsg"), tcp));
- TCP_UNREF(exec_ctx, tcp, "read");
+ TCP_UNREF(tcp, "read");
}
} else if (read_bytes == 0) {
/* 0 read size ==> end of stream */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
call_read_cb(
- exec_ctx, tcp,
- tcp_annotate_error(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
- TCP_UNREF(exec_ctx, tcp, "read");
+ tcp, tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
+ TCP_UNREF(tcp, "read");
} else {
- GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, read_bytes);
+ GRPC_STATS_INC_TCP_READ_SIZE(read_bytes);
add_to_estimate(tcp, (size_t)read_bytes);
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
if ((size_t)read_bytes < tcp->incoming_buffer->length) {
@@ -442,88 +431,83 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
&tcp->last_read_buffer);
}
GPR_ASSERT((size_t)read_bytes == tcp->incoming_buffer->length);
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_NONE);
- TCP_UNREF(exec_ctx, tcp, "read");
+ call_read_cb(tcp, GRPC_ERROR_NONE);
+ TCP_UNREF(tcp, "read");
}
GPR_TIMER_END("tcp_continue_read", 0);
}
-static void tcp_read_allocation_done(grpc_exec_ctx *exec_ctx, void *tcpp,
- grpc_error *error) {
- grpc_tcp *tcp = (grpc_tcp *)tcpp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
+ grpc_tcp* tcp = (grpc_tcp*)tcpp;
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
grpc_error_string(error));
}
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &tcp->last_read_buffer);
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
- TCP_UNREF(exec_ctx, tcp, "read");
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
+ TCP_UNREF(tcp, "read");
} else {
- tcp_do_read(exec_ctx, tcp);
+ tcp_do_read(tcp);
}
}
-static void tcp_continue_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
+static void tcp_continue_read(grpc_tcp* tcp) {
size_t target_read_size = get_target_read_size(tcp);
if (tcp->incoming_buffer->length < target_read_size &&
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p alloc_slices", tcp);
}
- grpc_resource_user_alloc_slices(exec_ctx, &tcp->slice_allocator,
- target_read_size, 1, tcp->incoming_buffer);
+ grpc_resource_user_alloc_slices(&tcp->slice_allocator, target_read_size, 1,
+ tcp->incoming_buffer);
} else {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p do_read", tcp);
}
- tcp_do_read(exec_ctx, tcp);
+ tcp_do_read(tcp);
}
}
-static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
- grpc_error *error) {
- grpc_tcp *tcp = (grpc_tcp *)arg;
+static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) {
+ grpc_tcp* tcp = (grpc_tcp*)arg;
GPR_ASSERT(!tcp->finished_edge);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p got_read: %s", tcp, grpc_error_string(error));
}
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &tcp->last_read_buffer);
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
- TCP_UNREF(exec_ctx, tcp, "read");
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
+ TCP_UNREF(tcp, "read");
} else {
- tcp_continue_read(exec_ctx, tcp);
+ tcp_continue_read(tcp);
}
}
-static void tcp_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *incoming_buffer, grpc_closure *cb) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- GPR_ASSERT(tcp->read_cb == NULL);
+static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
+ grpc_closure* cb) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ GPR_ASSERT(tcp->read_cb == nullptr);
tcp->read_cb = cb;
tcp->incoming_buffer = incoming_buffer;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
TCP_REF(tcp, "read");
if (tcp->finished_edge) {
tcp->finished_edge = false;
- notify_on_read(exec_ctx, tcp);
+ notify_on_read(tcp);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->read_done_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&tcp->read_done_closure, GRPC_ERROR_NONE);
}
}
/* returns true if done, false if pending; if returning true, *error is set */
#define MAX_WRITE_IOVEC 1000
-static bool tcp_flush(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
- grpc_error **error) {
+static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
struct msghdr msg;
struct iovec iov[MAX_WRITE_IOVEC];
msg_iovlen_type iov_size;
@@ -533,58 +517,66 @@ static bool tcp_flush(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
size_t unwind_slice_idx;
size_t unwind_byte_idx;
+ // We always start at zero, because we eagerly unref and trim the slice
+ // buffer as we write
+ size_t outgoing_slice_idx = 0;
+
for (;;) {
sending_length = 0;
- unwind_slice_idx = tcp->outgoing_slice_idx;
+ unwind_slice_idx = outgoing_slice_idx;
unwind_byte_idx = tcp->outgoing_byte_idx;
- for (iov_size = 0; tcp->outgoing_slice_idx != tcp->outgoing_buffer->count &&
+ for (iov_size = 0; outgoing_slice_idx != tcp->outgoing_buffer->count &&
iov_size != MAX_WRITE_IOVEC;
iov_size++) {
iov[iov_size].iov_base =
GRPC_SLICE_START_PTR(
- tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]) +
+ tcp->outgoing_buffer->slices[outgoing_slice_idx]) +
tcp->outgoing_byte_idx;
iov[iov_size].iov_len =
- GRPC_SLICE_LENGTH(
- tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]) -
+ GRPC_SLICE_LENGTH(tcp->outgoing_buffer->slices[outgoing_slice_idx]) -
tcp->outgoing_byte_idx;
sending_length += iov[iov_size].iov_len;
- tcp->outgoing_slice_idx++;
+ outgoing_slice_idx++;
tcp->outgoing_byte_idx = 0;
}
GPR_ASSERT(iov_size > 0);
- msg.msg_name = NULL;
+ msg.msg_name = nullptr;
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = iov_size;
- msg.msg_control = NULL;
+ msg.msg_control = nullptr;
msg.msg_controllen = 0;
msg.msg_flags = 0;
- GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, sending_length);
- GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, iov_size);
+ GRPC_STATS_INC_TCP_WRITE_SIZE(sending_length);
+ GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(iov_size);
GPR_TIMER_BEGIN("sendmsg", 1);
do {
/* TODO(klempner): Cork if this is a partial write */
- GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_WRITE();
sent_length = sendmsg(tcp->fd, &msg, SENDMSG_FLAGS);
} while (sent_length < 0 && errno == EINTR);
GPR_TIMER_END("sendmsg", 0);
if (sent_length < 0) {
if (errno == EAGAIN) {
- tcp->outgoing_slice_idx = unwind_slice_idx;
tcp->outgoing_byte_idx = unwind_byte_idx;
+ // unref all and forget about all slices that have been written to this
+ // point
+ for (size_t idx = 0; idx < unwind_slice_idx; ++idx) {
+ grpc_slice_unref_internal(
+ grpc_slice_buffer_take_first(tcp->outgoing_buffer));
+ }
return false;
} else if (errno == EPIPE) {
- *error = grpc_error_set_int(GRPC_OS_ERROR(errno, "sendmsg"),
- GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_UNAVAILABLE);
+ *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
return true;
} else {
*error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
return true;
}
}
@@ -594,9 +586,9 @@ static bool tcp_flush(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
while (trailing > 0) {
size_t slice_length;
- tcp->outgoing_slice_idx--;
- slice_length = GRPC_SLICE_LENGTH(
- tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]);
+ outgoing_slice_idx--;
+ slice_length =
+ GRPC_SLICE_LENGTH(tcp->outgoing_buffer->slices[outgoing_slice_idx]);
if (slice_length > trailing) {
tcp->outgoing_byte_idx = slice_length - trailing;
break;
@@ -605,54 +597,54 @@ static bool tcp_flush(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
}
}
- if (tcp->outgoing_slice_idx == tcp->outgoing_buffer->count) {
+ if (outgoing_slice_idx == tcp->outgoing_buffer->count) {
*error = GRPC_ERROR_NONE;
+ grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
return true;
}
- };
+ }
}
-static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
- grpc_error *error) {
- grpc_tcp *tcp = (grpc_tcp *)arg;
- grpc_closure *cb;
+static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
+ grpc_tcp* tcp = (grpc_tcp*)arg;
+ grpc_closure* cb;
if (error != GRPC_ERROR_NONE) {
cb = tcp->write_cb;
- tcp->write_cb = NULL;
- cb->cb(exec_ctx, cb->cb_arg, error);
- TCP_UNREF(exec_ctx, tcp, "write");
+ tcp->write_cb = nullptr;
+ cb->cb(cb->cb_arg, error);
+ TCP_UNREF(tcp, "write");
return;
}
- if (!tcp_flush(exec_ctx, tcp, &error)) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (!tcp_flush(tcp, &error)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "write: delayed");
}
- notify_on_write(exec_ctx, tcp);
+ notify_on_write(tcp);
} else {
cb = tcp->write_cb;
- tcp->write_cb = NULL;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
+ tcp->write_cb = nullptr;
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "write: %s", str);
}
- GRPC_CLOSURE_RUN(exec_ctx, cb, error);
- TCP_UNREF(exec_ctx, tcp, "write");
+ GRPC_CLOSURE_RUN(cb, error);
+ TCP_UNREF(tcp, "write");
}
}
-static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *buf, grpc_closure *cb) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_error *error = GRPC_ERROR_NONE;
+static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
+ grpc_closure* cb) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_error* error = GRPC_ERROR_NONE;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
size_t i;
for (i = 0; i < buf->count; i++) {
- char *data =
+ char* data =
grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data);
gpr_free(data);
@@ -660,82 +652,91 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
}
GPR_TIMER_BEGIN("tcp_write", 0);
- GPR_ASSERT(tcp->write_cb == NULL);
+ GPR_ASSERT(tcp->write_cb == nullptr);
if (buf->length == 0) {
GPR_TIMER_END("tcp_write", 0);
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- grpc_fd_is_shutdown(tcp->em_fd)
- ? tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"),
- tcp)
- : GRPC_ERROR_NONE);
+ cb, grpc_fd_is_shutdown(tcp->em_fd)
+ ? tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp)
+ : GRPC_ERROR_NONE);
return;
}
tcp->outgoing_buffer = buf;
- tcp->outgoing_slice_idx = 0;
tcp->outgoing_byte_idx = 0;
- if (!tcp_flush(exec_ctx, tcp, &error)) {
+ if (!tcp_flush(tcp, &error)) {
TCP_REF(tcp, "write");
tcp->write_cb = cb;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "write: delayed");
}
- notify_on_write(exec_ctx, tcp);
+ notify_on_write(tcp);
} else {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "write: %s", str);
}
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
}
GPR_TIMER_END("tcp_write", 0);
}
-static void tcp_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_pollset_add_fd(exec_ctx, pollset, tcp->em_fd);
+static void tcp_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_pollset_add_fd(pollset, tcp->em_fd);
+}
+
+static void tcp_add_to_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_pollset_set_add_fd(pollset_set, tcp->em_fd);
}
-static void tcp_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset_set) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_pollset_set_add_fd(exec_ctx, pollset_set, tcp->em_fd);
+static void tcp_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_pollset_set_del_fd(pollset_set, tcp->em_fd);
}
-static char *tcp_get_peer(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+static char* tcp_get_peer(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
return gpr_strdup(tcp->peer_string);
}
-static int tcp_get_fd(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+static int tcp_get_fd(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
return tcp->fd;
}
-static grpc_resource_user *tcp_get_resource_user(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+static grpc_resource_user* tcp_get_resource_user(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
return tcp->resource_user;
}
-static const grpc_endpoint_vtable vtable = {
- tcp_read, tcp_write, tcp_add_to_pollset, tcp_add_to_pollset_set,
- tcp_shutdown, tcp_destroy, tcp_get_resource_user, tcp_get_peer,
- tcp_get_fd};
+static const grpc_endpoint_vtable vtable = {tcp_read,
+ tcp_write,
+ tcp_add_to_pollset,
+ tcp_add_to_pollset_set,
+ tcp_delete_from_pollset_set,
+ tcp_shutdown,
+ tcp_destroy,
+ tcp_get_resource_user,
+ tcp_get_peer,
+ tcp_get_fd};
#define MAX_CHUNK_SIZE 32 * 1024 * 1024
-grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
- const grpc_channel_args *channel_args,
- const char *peer_string) {
+grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
+ const grpc_channel_args* channel_args,
+ const char* peer_string) {
int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
int tcp_max_read_chunk_size = 4 * 1024 * 1024;
int tcp_min_read_chunk_size = 256;
- grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
- if (channel_args != NULL) {
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create(nullptr);
+ if (channel_args != nullptr) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) {
@@ -757,9 +758,9 @@ grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
grpc_channel_arg_get_integer(&channel_args->args[i], options);
} else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
resource_quota = grpc_resource_quota_ref_internal(
- (grpc_resource_quota *)channel_args->args[i].value.pointer.p);
+ (grpc_resource_quota*)channel_args->args[i].value.pointer.p);
}
}
}
@@ -770,15 +771,15 @@ grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
tcp_read_chunk_size = GPR_CLAMP(tcp_read_chunk_size, tcp_min_read_chunk_size,
tcp_max_read_chunk_size);
- grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
+ grpc_tcp* tcp = (grpc_tcp*)gpr_malloc(sizeof(grpc_tcp));
tcp->base.vtable = &vtable;
tcp->peer_string = gpr_strdup(peer_string);
tcp->fd = grpc_fd_wrapped_fd(em_fd);
- tcp->read_cb = NULL;
- tcp->write_cb = NULL;
- tcp->release_fd_cb = NULL;
- tcp->release_fd = NULL;
- tcp->incoming_buffer = NULL;
+ tcp->read_cb = nullptr;
+ tcp->write_cb = nullptr;
+ tcp->release_fd_cb = nullptr;
+ tcp->release_fd = nullptr;
+ tcp->incoming_buffer = nullptr;
tcp->target_length = (double)tcp_read_chunk_size;
tcp->min_read_chunk_size = tcp_min_read_chunk_size;
tcp->max_read_chunk_size = tcp_max_read_chunk_size;
@@ -794,26 +795,26 @@ grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
&tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
/* Tell network status tracker about new endpoint */
grpc_network_status_register_endpoint(&tcp->base);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
return &tcp->base;
}
-int grpc_tcp_fd(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+int grpc_tcp_fd(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
GPR_ASSERT(ep->vtable == &vtable);
return grpc_fd_wrapped_fd(tcp->em_fd);
}
-void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- int *fd, grpc_closure *done) {
+void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
+ grpc_closure* done) {
grpc_network_status_unregister_endpoint(ep);
- grpc_tcp *tcp = (grpc_tcp *)ep;
+ grpc_tcp* tcp = (grpc_tcp*)ep;
GPR_ASSERT(ep->vtable == &vtable);
tcp->release_fd = fd;
tcp->release_fd_cb = done;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &tcp->last_read_buffer);
- TCP_UNREF(exec_ctx, tcp, "destroy");
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ TCP_UNREF(tcp, "destroy");
}
#endif
diff --git a/src/core/lib/iomgr/tcp_posix.h b/src/core/lib/iomgr/tcp_posix.h
index 6831a4a57f..4529c02beb 100644
--- a/src/core/lib/iomgr/tcp_posix.h
+++ b/src/core/lib/iomgr/tcp_posix.h
@@ -33,24 +33,23 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/ev_posix.h"
-extern grpc_tracer_flag grpc_tcp_trace;
+extern grpc_core::TraceFlag grpc_tcp_trace;
/* Create a tcp endpoint given a file desciptor and a read slice size.
Takes ownership of fd. */
-grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
- const grpc_channel_args *args,
- const char *peer_string);
+grpc_endpoint* grpc_tcp_create(grpc_fd* fd, const grpc_channel_args* args,
+ const char* peer_string);
/* Return the tcp endpoint's fd, or -1 if this is not available. Does not
release the fd.
Requires: ep must be a tcp endpoint.
*/
-int grpc_tcp_fd(grpc_endpoint *ep);
+int grpc_tcp_fd(grpc_endpoint* ep);
/* Destroy the tcp endpoint without closing its fd. *fd will be set and done
* will be called when the endpoint is destroyed.
* Requires: ep must be a tcp endpoint and fd must not be NULL. */
-void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- int *fd, grpc_closure *done);
+void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
+ grpc_closure* done);
#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */
diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h
index 8a126b6dee..038c765c6c 100644
--- a/src/core/lib/iomgr/tcp_server.h
+++ b/src/core/lib/iomgr/tcp_server.h
@@ -31,7 +31,7 @@ typedef struct grpc_tcp_server grpc_tcp_server;
typedef struct grpc_tcp_server_acceptor {
/* grpc_tcp_server_cb functions share a ref on from_server that is valid
until the function returns. */
- grpc_tcp_server *from_server;
+ grpc_tcp_server* from_server;
/* Indices that may be passed to grpc_tcp_server_port_fd(). */
unsigned port_index;
unsigned fd_index;
@@ -39,23 +39,21 @@ typedef struct grpc_tcp_server_acceptor {
/* Called for newly connected TCP connections.
Takes ownership of acceptor. */
-typedef void (*grpc_tcp_server_cb)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *ep,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor);
+typedef void (*grpc_tcp_server_cb)(void* arg, grpc_endpoint* ep,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor);
/* Create a server, initially not bound to any ports. The caller owns one ref.
If shutdown_complete is not NULL, it will be used by
grpc_tcp_server_unref() when the ref count reaches zero. */
-grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
- grpc_closure *shutdown_complete,
- const grpc_channel_args *args,
- grpc_tcp_server **server);
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
+ const grpc_channel_args* args,
+ grpc_tcp_server** server);
/* Start listening to bound ports */
-void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *server,
- grpc_pollset **pollsets, size_t pollset_count,
- grpc_tcp_server_cb on_accept_cb, void *cb_arg);
+void grpc_tcp_server_start(grpc_tcp_server* server, grpc_pollset** pollsets,
+ size_t pollset_count,
+ grpc_tcp_server_cb on_accept_cb, void* cb_arg);
/* Add a port to the server, returning the newly allocated port on success, or
-1 on failure.
@@ -66,36 +64,35 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *server,
but not dualstack sockets. */
/* TODO(ctiller): deprecate this, and make grpc_tcp_server_add_ports to handle
all of the multiple socket port matching logic in one place */
-grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
- const grpc_resolved_address *addr,
- int *out_port);
+grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
+ int* out_port);
/* Number of fds at the given port_index, or 0 if port_index is out of
bounds. */
-unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s, unsigned port_index);
+unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server* s, unsigned port_index);
/* Returns the file descriptor of the Mth (fd_index) listening socket of the Nth
(port_index) call to add_port() on this server, or -1 if the indices are out
of bounds. The file descriptor remains owned by the server, and will be
cleaned up when the ref count reaches zero. */
-int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index,
+int grpc_tcp_server_port_fd(grpc_tcp_server* s, unsigned port_index,
unsigned fd_index);
/* Ref s and return s. */
-grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s);
+grpc_tcp_server* grpc_tcp_server_ref(grpc_tcp_server* s);
/* shutdown_starting is called when ref count has reached zero and the server is
about to be destroyed. The server will be deleted after it returns. Calling
grpc_tcp_server_ref() from it has no effect. */
-void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s,
- grpc_closure *shutdown_starting);
+void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
+ grpc_closure* shutdown_starting);
/* If the refcount drops to zero, enqueue calls on exec_ctx to
shutdown_listeners and delete s. */
-void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s);
+void grpc_tcp_server_unref(grpc_tcp_server* s);
/* Shutdown the fds of listeners. */
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx,
- grpc_tcp_server *s);
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s);
#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */
diff --git a/src/core/lib/iomgr/tcp_server_posix.c b/src/core/lib/iomgr/tcp_server_posix.cc
index 06612d639c..2fa00a81d2 100644
--- a/src/core/lib/iomgr/tcp_server_posix.c
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -45,6 +45,7 @@
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
@@ -52,7 +53,6 @@
#include "src/core/lib/iomgr/tcp_posix.h"
#include "src/core/lib/iomgr/tcp_server_utils_posix.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
-#include "src/core/lib/support/string.h"
static gpr_once check_init = GPR_ONCE_INIT;
static bool has_so_reuseport = false;
@@ -68,16 +68,15 @@ static void init(void) {
#endif
}
-grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
- grpc_closure *shutdown_complete,
- const grpc_channel_args *args,
- grpc_tcp_server **server) {
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
+ const grpc_channel_args* args,
+ grpc_tcp_server** server) {
gpr_once_init(&check_init, init);
- grpc_tcp_server *s = (grpc_tcp_server *)gpr_zalloc(sizeof(grpc_tcp_server));
+ grpc_tcp_server* s = (grpc_tcp_server*)gpr_zalloc(sizeof(grpc_tcp_server));
s->so_reuseport = has_so_reuseport;
s->expand_wildcard_addrs = false;
- for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) {
+ for (size_t i = 0; i < (args == nullptr ? 0 : args->num_args); i++) {
if (0 == strcmp(GRPC_ARG_ALLOW_REUSEPORT, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_INTEGER) {
s->so_reuseport =
@@ -102,13 +101,13 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
s->active_ports = 0;
s->destroyed_ports = 0;
s->shutdown = false;
- s->shutdown_starting.head = NULL;
- s->shutdown_starting.tail = NULL;
+ s->shutdown_starting.head = nullptr;
+ s->shutdown_starting.tail = nullptr;
s->shutdown_complete = shutdown_complete;
- s->on_accept_cb = NULL;
- s->on_accept_cb_arg = NULL;
- s->head = NULL;
- s->tail = NULL;
+ s->on_accept_cb = nullptr;
+ s->on_accept_cb_arg = nullptr;
+ s->head = nullptr;
+ s->tail = nullptr;
s->nports = 0;
s->channel_args = grpc_channel_args_copy(args);
gpr_atm_no_barrier_store(&s->next_pollset_to_assign, 0);
@@ -116,34 +115,33 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+static void finish_shutdown(grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
GPR_ASSERT(s->shutdown);
gpr_mu_unlock(&s->mu);
- if (s->shutdown_complete != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ if (s->shutdown_complete != nullptr) {
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
gpr_mu_destroy(&s->mu);
while (s->head) {
- grpc_tcp_listener *sp = s->head;
+ grpc_tcp_listener* sp = s->head;
s->head = sp->next;
gpr_free(sp);
}
- grpc_channel_args_destroy(exec_ctx, s->channel_args);
+ grpc_channel_args_destroy(s->channel_args);
gpr_free(s);
}
-static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server,
- grpc_error *error) {
- grpc_tcp_server *s = (grpc_tcp_server *)server;
+static void destroyed_port(void* server, grpc_error* error) {
+ grpc_tcp_server* s = (grpc_tcp_server*)server;
gpr_mu_lock(&s->mu);
s->destroyed_ports++;
if (s->destroyed_ports == s->nports) {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
} else {
GPR_ASSERT(s->destroyed_ports < s->nports);
gpr_mu_unlock(&s->mu);
@@ -153,29 +151,29 @@ static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server,
/* called when all listening endpoints have been shutdown, so no further
events will be received on them - at this point it's safe to destroy
things */
-static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+static void deactivated_all_ports(grpc_tcp_server* s) {
/* delete ALL the things */
gpr_mu_lock(&s->mu);
GPR_ASSERT(s->shutdown);
if (s->head) {
- grpc_tcp_listener *sp;
+ grpc_tcp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
grpc_unlink_if_unix_domain_socket(&sp->addr);
GRPC_CLOSURE_INIT(&sp->destroyed_closure, destroyed_port, s,
grpc_schedule_on_exec_ctx);
- grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
+ grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr,
false /* already_closed */, "tcp_listener_shutdown");
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
}
}
-static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+static void tcp_server_destroy(grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
GPR_ASSERT(!s->shutdown);
@@ -183,22 +181,22 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
/* shutdown all fd's */
if (s->active_ports) {
- grpc_tcp_listener *sp;
+ grpc_tcp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
- grpc_fd_shutdown(exec_ctx, sp->emfd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Server destroyed"));
+ grpc_fd_shutdown(
+ sp->emfd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server destroyed"));
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- deactivated_all_ports(exec_ctx, s);
+ deactivated_all_ports(s);
}
}
/* event manager callback when reads are ready */
-static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
- grpc_tcp_listener *sp = (grpc_tcp_listener *)arg;
- grpc_pollset *read_notifier_pollset;
+static void on_read(void* arg, grpc_error* err) {
+ grpc_tcp_listener* sp = (grpc_tcp_listener*)arg;
+ grpc_pollset* read_notifier_pollset;
if (err != GRPC_ERROR_NONE) {
goto error;
}
@@ -211,8 +209,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
/* loop until accept4 returns EAGAIN, and then re-arm notification */
for (;;) {
grpc_resolved_address addr;
- char *addr_str;
- char *name;
+ char* addr_str;
+ char* name;
addr.len = sizeof(struct sockaddr_storage);
/* Note: If we ever decide to return this address to the user, remember to
strip off the ::ffff:0.0.0.0/96 prefix first. */
@@ -222,7 +220,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
case EINTR:
continue;
case EAGAIN:
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
return;
default:
gpr_mu_lock(&sp->server->mu);
@@ -242,24 +240,24 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
addr_str = grpc_sockaddr_to_uri(&addr);
gpr_asprintf(&name, "tcp-server-connection:%s", addr_str);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "SERVER_CONNECT: incoming connection: %s", addr_str);
}
- grpc_fd *fdobj = grpc_fd_create(fd, name);
+ grpc_fd* fdobj = grpc_fd_create(fd, name);
- grpc_pollset_add_fd(exec_ctx, read_notifier_pollset, fdobj);
+ grpc_pollset_add_fd(read_notifier_pollset, fdobj);
// Create acceptor.
- grpc_tcp_server_acceptor *acceptor =
- (grpc_tcp_server_acceptor *)gpr_malloc(sizeof(*acceptor));
+ grpc_tcp_server_acceptor* acceptor =
+ (grpc_tcp_server_acceptor*)gpr_malloc(sizeof(*acceptor));
acceptor->from_server = sp->server;
acceptor->port_index = sp->port_index;
acceptor->fd_index = sp->fd_index;
sp->server->on_accept_cb(
- exec_ctx, sp->server->on_accept_cb_arg,
- grpc_tcp_create(exec_ctx, fdobj, sp->server->channel_args, addr_str),
+ sp->server->on_accept_cb_arg,
+ grpc_tcp_create(fdobj, sp->server->channel_args, addr_str),
read_notifier_pollset, acceptor);
gpr_free(name);
@@ -272,25 +270,25 @@ error:
gpr_mu_lock(&sp->server->mu);
if (0 == --sp->server->active_ports && sp->server->shutdown) {
gpr_mu_unlock(&sp->server->mu);
- deactivated_all_ports(exec_ctx, sp->server);
+ deactivated_all_ports(sp->server);
} else {
gpr_mu_unlock(&sp->server->mu);
}
}
/* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */
-static grpc_error *add_wildcard_addrs_to_server(grpc_tcp_server *s,
+static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s,
unsigned port_index,
int requested_port,
- int *out_port) {
+ int* out_port) {
grpc_resolved_address wild4;
grpc_resolved_address wild6;
unsigned fd_index = 0;
grpc_dualstack_mode dsmode;
- grpc_tcp_listener *sp = NULL;
- grpc_tcp_listener *sp2 = NULL;
- grpc_error *v6_err = GRPC_ERROR_NONE;
- grpc_error *v4_err = GRPC_ERROR_NONE;
+ grpc_tcp_listener* sp = nullptr;
+ grpc_tcp_listener* sp2 = nullptr;
+ grpc_error* v6_err = GRPC_ERROR_NONE;
+ grpc_error* v4_err = GRPC_ERROR_NONE;
*out_port = -1;
if (grpc_tcp_server_have_ifaddrs() && s->expand_wildcard_addrs) {
@@ -313,7 +311,7 @@ static grpc_error *add_wildcard_addrs_to_server(grpc_tcp_server *s,
if ((v4_err = grpc_tcp_server_add_addr(s, &wild4, port_index, fd_index,
&dsmode, &sp2)) == GRPC_ERROR_NONE) {
*out_port = sp2->port;
- if (sp != NULL) {
+ if (sp != nullptr) {
sp2->is_sibling = 1;
sp->sibling = sp2;
}
@@ -335,7 +333,7 @@ static grpc_error *add_wildcard_addrs_to_server(grpc_tcp_server *s,
}
return GRPC_ERROR_NONE;
} else {
- grpc_error *root_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ grpc_error* root_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to add any wildcard listeners");
GPR_ASSERT(v6_err != GRPC_ERROR_NONE && v4_err != GRPC_ERROR_NONE);
root_err = grpc_error_add_child(root_err, v6_err);
@@ -344,13 +342,13 @@ static grpc_error *add_wildcard_addrs_to_server(grpc_tcp_server *s,
}
}
-static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
- grpc_tcp_listener *sp = NULL;
- char *addr_str;
- char *name;
- grpc_error *err;
+static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) {
+ grpc_tcp_listener* sp = nullptr;
+ char* addr_str;
+ char* name;
+ grpc_error* err;
- for (grpc_tcp_listener *l = listener->next; l && l->is_sibling; l = l->next) {
+ for (grpc_tcp_listener* l = listener->next; l && l->is_sibling; l = l->next) {
l->fd_index += count;
}
@@ -366,7 +364,7 @@ static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
listener->server->nports++;
grpc_sockaddr_to_string(&addr_str, &listener->addr, 1);
gpr_asprintf(&name, "tcp-server-listener:%s/clone-%d", addr_str, i);
- sp = (grpc_tcp_listener *)gpr_malloc(sizeof(grpc_tcp_listener));
+ sp = (grpc_tcp_listener*)gpr_malloc(sizeof(grpc_tcp_listener));
sp->next = listener->next;
listener->next = sp;
/* sp (the new listener) is a sibling of 'listener' (the original
@@ -382,7 +380,7 @@ static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
sp->port_index = listener->port_index;
sp->fd_index = listener->fd_index + count - i;
GPR_ASSERT(sp->emfd);
- while (listener->server->tail->next != NULL) {
+ while (listener->server->tail->next != nullptr) {
listener->server->tail = listener->server->tail->next;
}
gpr_free(addr_str);
@@ -392,18 +390,18 @@ static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
- const grpc_resolved_address *addr,
- int *out_port) {
- grpc_tcp_listener *sp;
+grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
+ int* out_port) {
+ grpc_tcp_listener* sp;
grpc_resolved_address sockname_temp;
grpc_resolved_address addr6_v4mapped;
int requested_port = grpc_sockaddr_get_port(addr);
unsigned port_index = 0;
grpc_dualstack_mode dsmode;
- grpc_error *err;
+ grpc_error* err;
*out_port = -1;
- if (s->tail != NULL) {
+ if (s->tail != nullptr) {
port_index = s->tail->port_index + 1;
}
grpc_unlink_if_unix_domain_socket(addr);
@@ -413,8 +411,8 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
if (requested_port == 0) {
for (sp = s->head; sp; sp = sp->next) {
sockname_temp.len = sizeof(struct sockaddr_storage);
- if (0 == getsockname(sp->fd, (struct sockaddr *)&sockname_temp.addr,
- (socklen_t *)&sockname_temp.len)) {
+ if (0 == getsockname(sp->fd, (struct sockaddr*)&sockname_temp.addr,
+ (socklen_t*)&sockname_temp.len)) {
int used_port = grpc_sockaddr_get_port(&sockname_temp);
if (used_port > 0) {
memcpy(&sockname_temp, addr, sizeof(grpc_resolved_address));
@@ -442,10 +440,10 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
/* Return listener at port_index or NULL. Should only be called with s->mu
locked. */
-static grpc_tcp_listener *get_port_index(grpc_tcp_server *s,
+static grpc_tcp_listener* get_port_index(grpc_tcp_server* s,
unsigned port_index) {
unsigned num_ports = 0;
- grpc_tcp_listener *sp;
+ grpc_tcp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
if (!sp->is_sibling) {
if (++num_ports > port_index) {
@@ -453,14 +451,14 @@ static grpc_tcp_listener *get_port_index(grpc_tcp_server *s,
}
}
}
- return NULL;
+ return nullptr;
}
-unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s,
+unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server* s,
unsigned port_index) {
unsigned num_fds = 0;
gpr_mu_lock(&s->mu);
- grpc_tcp_listener *sp = get_port_index(s, port_index);
+ grpc_tcp_listener* sp = get_port_index(s, port_index);
for (; sp; sp = sp->sibling) {
++num_fds;
}
@@ -468,10 +466,10 @@ unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s,
return num_fds;
}
-int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index,
+int grpc_tcp_server_port_fd(grpc_tcp_server* s, unsigned port_index,
unsigned fd_index) {
gpr_mu_lock(&s->mu);
- grpc_tcp_listener *sp = get_port_index(s, port_index);
+ grpc_tcp_listener* sp = get_port_index(s, port_index);
for (; sp; sp = sp->sibling, --fd_index) {
if (fd_index == 0) {
gpr_mu_unlock(&s->mu);
@@ -482,12 +480,12 @@ int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index,
return -1;
}
-void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s,
- grpc_pollset **pollsets, size_t pollset_count,
+void grpc_tcp_server_start(grpc_tcp_server* s, grpc_pollset** pollsets,
+ size_t pollset_count,
grpc_tcp_server_cb on_accept_cb,
- void *on_accept_cb_arg) {
+ void* on_accept_cb_arg) {
size_t i;
- grpc_tcp_listener *sp;
+ grpc_tcp_listener* sp;
GPR_ASSERT(on_accept_cb);
gpr_mu_lock(&s->mu);
GPR_ASSERT(!s->on_accept_cb);
@@ -497,26 +495,26 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s,
s->pollsets = pollsets;
s->pollset_count = pollset_count;
sp = s->head;
- while (sp != NULL) {
+ while (sp != nullptr) {
if (s->so_reuseport && !grpc_is_unix_socket(&sp->addr) &&
pollset_count > 1) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"clone_port", clone_port(sp, (unsigned)(pollset_count - 1))));
for (i = 0; i < pollset_count; i++) {
- grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
+ grpc_pollset_add_fd(pollsets[i], sp->emfd);
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
s->active_ports++;
sp = sp->next;
}
} else {
for (i = 0; i < pollset_count; i++) {
- grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
+ grpc_pollset_add_fd(pollsets[i], sp->emfd);
}
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
s->active_ports++;
sp = sp->next;
}
@@ -524,38 +522,37 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s,
gpr_mu_unlock(&s->mu);
}
-grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s) {
+grpc_tcp_server* grpc_tcp_server_ref(grpc_tcp_server* s) {
gpr_ref_non_zero(&s->refs);
return s;
}
-void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s,
- grpc_closure *shutdown_starting) {
+void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
+ grpc_closure* shutdown_starting) {
gpr_mu_lock(&s->mu);
grpc_closure_list_append(&s->shutdown_starting, shutdown_starting,
GRPC_ERROR_NONE);
gpr_mu_unlock(&s->mu);
}
-void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+void grpc_tcp_server_unref(grpc_tcp_server* s) {
if (gpr_unref(&s->refs)) {
- grpc_tcp_server_shutdown_listeners(exec_ctx, s);
+ grpc_tcp_server_shutdown_listeners(s);
gpr_mu_lock(&s->mu);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &s->shutdown_starting);
+ GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
gpr_mu_unlock(&s->mu);
- tcp_server_destroy(exec_ctx, s);
+ tcp_server_destroy(s);
}
}
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx,
- grpc_tcp_server *s) {
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
s->shutdown_listeners = true;
/* shutdown all fd's */
if (s->active_ports) {
- grpc_tcp_listener *sp;
+ grpc_tcp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
- grpc_fd_shutdown(exec_ctx, sp->emfd,
+ grpc_fd_shutdown(sp->emfd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"));
}
}
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix.h b/src/core/lib/iomgr/tcp_server_utils_posix.h
index 85dea515d9..6046f257f9 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix.h
+++ b/src/core/lib/iomgr/tcp_server_utils_posix.h
@@ -27,22 +27,22 @@
/* one listening port */
typedef struct grpc_tcp_listener {
int fd;
- grpc_fd *emfd;
- grpc_tcp_server *server;
+ grpc_fd* emfd;
+ grpc_tcp_server* server;
grpc_resolved_address addr;
int port;
unsigned port_index;
unsigned fd_index;
grpc_closure read_closure;
grpc_closure destroyed_closure;
- struct grpc_tcp_listener *next;
+ struct grpc_tcp_listener* next;
/* sibling is a linked list of all listeners for a given port. add_port and
clone_port place all new listeners in the same sibling list. A member of
the 'sibling' list is also a member of the 'next' list. The head of each
sibling list has is_sibling==0, and subsequent members of sibling lists
have is_sibling==1. is_sibling allows separate sibling lists to be
identified while iterating through 'next'. */
- struct grpc_tcp_listener *sibling;
+ struct grpc_tcp_listener* sibling;
int is_sibling;
} grpc_tcp_listener;
@@ -51,7 +51,7 @@ struct grpc_tcp_server {
gpr_refcount refs;
/* Called whenever accept() succeeds on a server port. */
grpc_tcp_server_cb on_accept_cb;
- void *on_accept_cb_arg;
+ void* on_accept_cb_arg;
gpr_mu mu;
@@ -70,18 +70,18 @@ struct grpc_tcp_server {
bool expand_wildcard_addrs;
/* linked list of server ports */
- grpc_tcp_listener *head;
- grpc_tcp_listener *tail;
+ grpc_tcp_listener* head;
+ grpc_tcp_listener* tail;
unsigned nports;
/* List of closures passed to shutdown_starting_add(). */
grpc_closure_list shutdown_starting;
/* shutdown callback */
- grpc_closure *shutdown_complete;
+ grpc_closure* shutdown_complete;
/* all pollsets interested in new connections */
- grpc_pollset **pollsets;
+ grpc_pollset** pollsets;
/* number of pollsets in the pollsets array */
size_t pollset_count;
@@ -89,31 +89,31 @@ struct grpc_tcp_server {
gpr_atm next_pollset_to_assign;
/* channel args for this server */
- grpc_channel_args *channel_args;
+ grpc_channel_args* channel_args;
};
/* If successful, add a listener to \a s for \a addr, set \a dsmode for the
socket, and return the \a listener. */
-grpc_error *grpc_tcp_server_add_addr(grpc_tcp_server *s,
- const grpc_resolved_address *addr,
+grpc_error* grpc_tcp_server_add_addr(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
unsigned port_index, unsigned fd_index,
- grpc_dualstack_mode *dsmode,
- grpc_tcp_listener **listener);
+ grpc_dualstack_mode* dsmode,
+ grpc_tcp_listener** listener);
/* Get all addresses assigned to network interfaces on the machine and create a
listener for each. requested_port is the port to use for every listener, or 0
to select one random port that will be used for every listener. Set *out_port
to the port selected. Return GRPC_ERROR_NONE only if all listeners were
added. */
-grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
+grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
unsigned port_index,
int requested_port,
- int *out_port);
+ int* out_port);
/* Prepare a recently-created socket for listening. */
-grpc_error *grpc_tcp_server_prepare_socket(int fd,
- const grpc_resolved_address *addr,
- bool so_reuseport, int *port);
+grpc_error* grpc_tcp_server_prepare_socket(int fd,
+ const grpc_resolved_address* addr,
+ bool so_reuseport, int* port);
/* Ruturn true if the platform supports ifaddrs */
bool grpc_tcp_server_have_ifaddrs(void);
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_common.c b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
index a828bee074..5139760634 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_common.c
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
@@ -46,16 +46,16 @@ static int s_max_accept_queue_size;
static void init_max_accept_queue_size(void) {
int n = SOMAXCONN;
char buf[64];
- FILE *fp = fopen("/proc/sys/net/core/somaxconn", "r");
- if (fp == NULL) {
+ FILE* fp = fopen("/proc/sys/net/core/somaxconn", "r");
+ if (fp == nullptr) {
/* 2.4 kernel. */
s_max_accept_queue_size = SOMAXCONN;
return;
}
if (fgets(buf, sizeof buf, fp)) {
- char *end;
+ char* end;
long i = strtol(buf, &end, 10);
- if (i > 0 && i <= INT_MAX && end && *end == 0) {
+ if (i > 0 && i <= INT_MAX && end && *end == '\n') {
n = (int)i;
}
}
@@ -75,16 +75,16 @@ static int get_max_accept_queue_size(void) {
return s_max_accept_queue_size;
}
-static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd,
- const grpc_resolved_address *addr,
+static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd,
+ const grpc_resolved_address* addr,
unsigned port_index, unsigned fd_index,
- grpc_tcp_listener **listener) {
- grpc_tcp_listener *sp = NULL;
+ grpc_tcp_listener** listener) {
+ grpc_tcp_listener* sp = nullptr;
int port = -1;
- char *addr_str;
- char *name;
+ char* addr_str;
+ char* name;
- grpc_error *err =
+ grpc_error* err =
grpc_tcp_server_prepare_socket(fd, addr, s->so_reuseport, &port);
if (err == GRPC_ERROR_NONE) {
GPR_ASSERT(port > 0);
@@ -93,9 +93,9 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd,
gpr_mu_lock(&s->mu);
s->nports++;
GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server");
- sp = (grpc_tcp_listener *)gpr_malloc(sizeof(grpc_tcp_listener));
- sp->next = NULL;
- if (s->head == NULL) {
+ sp = (grpc_tcp_listener*)gpr_malloc(sizeof(grpc_tcp_listener));
+ sp->next = nullptr;
+ if (s->head == nullptr) {
s->head = sp;
} else {
s->tail->next = sp;
@@ -109,7 +109,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd,
sp->port_index = port_index;
sp->fd_index = fd_index;
sp->is_sibling = 0;
- sp->sibling = NULL;
+ sp->sibling = nullptr;
GPR_ASSERT(sp->emfd);
gpr_mu_unlock(&s->mu);
gpr_free(addr_str);
@@ -122,14 +122,14 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd,
/* If successful, add a listener to s for addr, set *dsmode for the socket, and
return the *listener. */
-grpc_error *grpc_tcp_server_add_addr(grpc_tcp_server *s,
- const grpc_resolved_address *addr,
+grpc_error* grpc_tcp_server_add_addr(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
unsigned port_index, unsigned fd_index,
- grpc_dualstack_mode *dsmode,
- grpc_tcp_listener **listener) {
+ grpc_dualstack_mode* dsmode,
+ grpc_tcp_listener** listener) {
grpc_resolved_address addr4_copy;
int fd;
- grpc_error *err =
+ grpc_error* err =
grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, dsmode, &fd);
if (err != GRPC_ERROR_NONE) {
return err;
@@ -142,11 +142,11 @@ grpc_error *grpc_tcp_server_add_addr(grpc_tcp_server *s,
}
/* Prepare a recently-created socket for listening. */
-grpc_error *grpc_tcp_server_prepare_socket(int fd,
- const grpc_resolved_address *addr,
- bool so_reuseport, int *port) {
+grpc_error* grpc_tcp_server_prepare_socket(int fd,
+ const grpc_resolved_address* addr,
+ bool so_reuseport, int* port) {
grpc_resolved_address sockname_temp;
- grpc_error *err = GRPC_ERROR_NONE;
+ grpc_error* err = GRPC_ERROR_NONE;
GPR_ASSERT(fd >= 0);
@@ -169,7 +169,7 @@ grpc_error *grpc_tcp_server_prepare_socket(int fd,
if (err != GRPC_ERROR_NONE) goto error;
GPR_ASSERT(addr->len < ~(socklen_t)0);
- if (bind(fd, (struct sockaddr *)addr->addr, (socklen_t)addr->len) < 0) {
+ if (bind(fd, (struct sockaddr*)addr->addr, (socklen_t)addr->len) < 0) {
err = GRPC_OS_ERROR(errno, "bind");
goto error;
}
@@ -181,8 +181,8 @@ grpc_error *grpc_tcp_server_prepare_socket(int fd,
sockname_temp.len = sizeof(struct sockaddr_storage);
- if (getsockname(fd, (struct sockaddr *)sockname_temp.addr,
- (socklen_t *)&sockname_temp.len) < 0) {
+ if (getsockname(fd, (struct sockaddr*)sockname_temp.addr,
+ (socklen_t*)&sockname_temp.len) < 0) {
err = GRPC_OS_ERROR(errno, "getsockname");
goto error;
}
@@ -195,7 +195,7 @@ error:
if (fd >= 0) {
close(fd);
}
- grpc_error *ret =
+ grpc_error* ret =
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Unable to configure socket", &err, 1),
GRPC_ERROR_INT_FD, fd);
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
index a243b69f35..227bf94aa7 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
@@ -36,11 +36,11 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
/* Return the listener in s with address addr or NULL. */
-static grpc_tcp_listener *find_listener_with_addr(grpc_tcp_server *s,
- grpc_resolved_address *addr) {
- grpc_tcp_listener *l;
+static grpc_tcp_listener* find_listener_with_addr(grpc_tcp_server* s,
+ grpc_resolved_address* addr) {
+ grpc_tcp_listener* l;
gpr_mu_lock(&s->mu);
- for (l = s->head; l != NULL; l = l->next) {
+ for (l = s->head; l != nullptr; l = l->next) {
if (l->addr.len != addr->len) {
continue;
}
@@ -53,12 +53,12 @@ static grpc_tcp_listener *find_listener_with_addr(grpc_tcp_server *s,
}
/* Bind to "::" to get a port number not used by any address. */
-static grpc_error *get_unused_port(int *port) {
+static grpc_error* get_unused_port(int* port) {
grpc_resolved_address wild;
grpc_sockaddr_make_wildcard6(0, &wild);
grpc_dualstack_mode dsmode;
int fd;
- grpc_error *err =
+ grpc_error* err =
grpc_create_dualstack_socket(&wild, SOCK_STREAM, 0, &dsmode, &fd);
if (err != GRPC_ERROR_NONE) {
return err;
@@ -66,12 +66,12 @@ static grpc_error *get_unused_port(int *port) {
if (dsmode == GRPC_DSMODE_IPV4) {
grpc_sockaddr_make_wildcard4(0, &wild);
}
- if (bind(fd, (const struct sockaddr *)wild.addr, (socklen_t)wild.len) != 0) {
+ if (bind(fd, (const struct sockaddr*)wild.addr, (socklen_t)wild.len) != 0) {
err = GRPC_OS_ERROR(errno, "bind");
close(fd);
return err;
}
- if (getsockname(fd, (struct sockaddr *)wild.addr, (socklen_t *)&wild.len) !=
+ if (getsockname(fd, (struct sockaddr*)wild.addr, (socklen_t*)&wild.len) !=
0) {
err = GRPC_OS_ERROR(errno, "getsockname");
close(fd);
@@ -83,15 +83,15 @@ static grpc_error *get_unused_port(int *port) {
: GRPC_ERROR_NONE;
}
-grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
+grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
unsigned port_index,
int requested_port,
- int *out_port) {
- struct ifaddrs *ifa = NULL;
- struct ifaddrs *ifa_it;
+ int* out_port) {
+ struct ifaddrs* ifa = nullptr;
+ struct ifaddrs* ifa_it;
unsigned fd_index = 0;
- grpc_tcp_listener *sp = NULL;
- grpc_error *err = GRPC_ERROR_NONE;
+ grpc_tcp_listener* sp = nullptr;
+ grpc_error* err = GRPC_ERROR_NONE;
if (requested_port == 0) {
/* Note: There could be a race where some local addrs can listen on the
selected port and some can't. The sane way to handle this would be to
@@ -104,16 +104,16 @@ grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
}
gpr_log(GPR_DEBUG, "Picked unused port %d", requested_port);
}
- if (getifaddrs(&ifa) != 0 || ifa == NULL) {
+ if (getifaddrs(&ifa) != 0 || ifa == nullptr) {
return GRPC_OS_ERROR(errno, "getifaddrs");
}
- for (ifa_it = ifa; ifa_it != NULL; ifa_it = ifa_it->ifa_next) {
+ for (ifa_it = ifa; ifa_it != nullptr; ifa_it = ifa_it->ifa_next) {
grpc_resolved_address addr;
- char *addr_str = NULL;
+ char* addr_str = nullptr;
grpc_dualstack_mode dsmode;
- grpc_tcp_listener *new_sp = NULL;
- const char *ifa_name = (ifa_it->ifa_name ? ifa_it->ifa_name : "<unknown>");
- if (ifa_it->ifa_addr == NULL) {
+ grpc_tcp_listener* new_sp = nullptr;
+ const char* ifa_name = (ifa_it->ifa_name ? ifa_it->ifa_name : "<unknown>");
+ if (ifa_it->ifa_addr == nullptr) {
continue;
} else if (ifa_it->ifa_addr->sa_family == AF_INET) {
addr.len = sizeof(struct sockaddr_in);
@@ -136,7 +136,7 @@ grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
ifa_name, ifa_it->ifa_flags, addr_str);
/* We could have multiple interfaces with the same address (e.g., bonding),
so look for duplicates. */
- if (find_listener_with_addr(s, &addr) != NULL) {
+ if (find_listener_with_addr(s, &addr) != nullptr) {
gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s", addr_str,
ifa_name);
gpr_free(addr_str);
@@ -144,8 +144,8 @@ grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
}
if ((err = grpc_tcp_server_add_addr(s, &addr, port_index, fd_index, &dsmode,
&new_sp)) != GRPC_ERROR_NONE) {
- char *err_str = NULL;
- grpc_error *root_err;
+ char* err_str = nullptr;
+ grpc_error* root_err;
if (gpr_asprintf(&err_str, "Failed to add listener: %s", addr_str) < 0) {
err_str = gpr_strdup("Failed to add listener");
}
@@ -157,7 +157,7 @@ grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
} else {
GPR_ASSERT(requested_port == new_sp->port);
++fd_index;
- if (sp != NULL) {
+ if (sp != nullptr) {
new_sp->is_sibling = 1;
sp->sibling = new_sp;
}
@@ -168,7 +168,7 @@ grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
freeifaddrs(ifa);
if (err != GRPC_ERROR_NONE) {
return err;
- } else if (sp == NULL) {
+ } else if (sp == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No local addresses");
} else {
*out_port = sp->port;
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c b/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
index 34eab20d6a..2d72b95def 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc
@@ -22,10 +22,10 @@
#include "src/core/lib/iomgr/tcp_server_utils_posix.h"
-grpc_error *grpc_tcp_server_add_all_local_addrs(grpc_tcp_server *s,
+grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
unsigned port_index,
int requested_port,
- int *out_port) {
+ int* out_port) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("no ifaddrs available");
}
diff --git a/src/core/lib/iomgr/tcp_server_uv.c b/src/core/lib/iomgr/tcp_server_uv.cc
index 3b9332321f..1ac49190fb 100644
--- a/src/core/lib/iomgr/tcp_server_uv.c
+++ b/src/core/lib/iomgr/tcp_server_uv.cc
@@ -37,12 +37,12 @@
/* one listening port */
typedef struct grpc_tcp_listener grpc_tcp_listener;
struct grpc_tcp_listener {
- uv_tcp_t *handle;
- grpc_tcp_server *server;
+ uv_tcp_t* handle;
+ grpc_tcp_server* server;
unsigned port_index;
int port;
/* linked list */
- struct grpc_tcp_listener *next;
+ struct grpc_tcp_listener* next;
bool closed;
@@ -54,39 +54,38 @@ struct grpc_tcp_server {
/* Called whenever accept() succeeds on a server port. */
grpc_tcp_server_cb on_accept_cb;
- void *on_accept_cb_arg;
+ void* on_accept_cb_arg;
int open_ports;
/* linked list of server ports */
- grpc_tcp_listener *head;
- grpc_tcp_listener *tail;
+ grpc_tcp_listener* head;
+ grpc_tcp_listener* tail;
/* List of closures passed to shutdown_starting_add(). */
grpc_closure_list shutdown_starting;
/* shutdown callback */
- grpc_closure *shutdown_complete;
+ grpc_closure* shutdown_complete;
bool shutdown;
- grpc_resource_quota *resource_quota;
+ grpc_resource_quota* resource_quota;
};
-grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
- grpc_closure *shutdown_complete,
- const grpc_channel_args *args,
- grpc_tcp_server **server) {
- grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
+ const grpc_channel_args* args,
+ grpc_tcp_server** server) {
+ grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server));
s->resource_quota = grpc_resource_quota_create(NULL);
for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) {
if (0 == strcmp(GRPC_ARG_RESOURCE_QUOTA, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_POINTER) {
- grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
- s->resource_quota =
- grpc_resource_quota_ref_internal(args->args[i].value.pointer.p);
+ grpc_resource_quota_unref_internal(s->resource_quota);
+ s->resource_quota = grpc_resource_quota_ref_internal(
+ (grpc_resource_quota*)args->args[i].value.pointer.p);
} else {
- grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
+ grpc_resource_quota_unref_internal(s->resource_quota);
gpr_free(s);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
GRPC_ARG_RESOURCE_QUOTA " must be a pointer to a buffer pool");
@@ -107,55 +106,54 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s) {
+grpc_tcp_server* grpc_tcp_server_ref(grpc_tcp_server* s) {
GRPC_UV_ASSERT_SAME_THREAD();
gpr_ref(&s->refs);
return s;
}
-void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s,
- grpc_closure *shutdown_starting) {
+void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
+ grpc_closure* shutdown_starting) {
grpc_closure_list_append(&s->shutdown_starting, shutdown_starting,
GRPC_ERROR_NONE);
}
-static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+static void finish_shutdown(grpc_tcp_server* s) {
GPR_ASSERT(s->shutdown);
if (s->shutdown_complete != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
while (s->head) {
- grpc_tcp_listener *sp = s->head;
+ grpc_tcp_listener* sp = s->head;
s->head = sp->next;
sp->next = NULL;
gpr_free(sp->handle);
gpr_free(sp);
}
- grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
+ grpc_resource_quota_unref_internal(s->resource_quota);
gpr_free(s);
}
-static void handle_close_callback(uv_handle_t *handle) {
- grpc_tcp_listener *sp = (grpc_tcp_listener *)handle->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+static void handle_close_callback(uv_handle_t* handle) {
+ grpc_tcp_listener* sp = (grpc_tcp_listener*)handle->data;
+ grpc_core::ExecCtx exec_ctx;
sp->server->open_ports--;
if (sp->server->open_ports == 0 && sp->server->shutdown) {
- finish_shutdown(&exec_ctx, sp->server);
+ finish_shutdown(sp->server);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void close_listener(grpc_tcp_listener *sp) {
+static void close_listener(grpc_tcp_listener* sp) {
if (!sp->closed) {
sp->closed = true;
- uv_close((uv_handle_t *)sp->handle, handle_close_callback);
+ uv_close((uv_handle_t*)sp->handle, handle_close_callback);
}
}
-static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+static void tcp_server_destroy(grpc_tcp_server* s) {
int immediately_done = 0;
- grpc_tcp_listener *sp;
+ grpc_tcp_listener* sp;
GPR_ASSERT(!s->shutdown);
s->shutdown = true;
@@ -168,51 +166,46 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
}
if (immediately_done) {
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
}
}
-void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+void grpc_tcp_server_unref(grpc_tcp_server* s) {
GRPC_UV_ASSERT_SAME_THREAD();
if (gpr_unref(&s->refs)) {
/* Complete shutdown_starting work before destroying. */
- grpc_exec_ctx local_exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_LIST_SCHED(&local_exec_ctx, &s->shutdown_starting);
- if (exec_ctx == NULL) {
- grpc_exec_ctx_flush(&local_exec_ctx);
- tcp_server_destroy(&local_exec_ctx, s);
- grpc_exec_ctx_finish(&local_exec_ctx);
- } else {
- grpc_exec_ctx_finish(&local_exec_ctx);
- tcp_server_destroy(exec_ctx, s);
- }
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
+ grpc_core::ExecCtx::Get()->Flush();
+ tcp_server_destroy(s);
}
}
-static void finish_accept(grpc_exec_ctx *exec_ctx, grpc_tcp_listener *sp) {
- grpc_tcp_server_acceptor *acceptor = gpr_malloc(sizeof(*acceptor));
- uv_tcp_t *client;
- grpc_endpoint *ep = NULL;
+static void finish_accept(grpc_tcp_listener* sp) {
+ grpc_tcp_server_acceptor* acceptor =
+ (grpc_tcp_server_acceptor*)gpr_malloc(sizeof(*acceptor));
+ uv_tcp_t* client = NULL;
+ grpc_endpoint* ep = NULL;
grpc_resolved_address peer_name;
- char *peer_name_string;
+ char* peer_name_string;
int err;
- uv_tcp_t *server = sp->handle;
+ uv_tcp_t* server = sp->handle;
- client = gpr_malloc(sizeof(uv_tcp_t));
+ client = (uv_tcp_t*)gpr_malloc(sizeof(uv_tcp_t));
uv_tcp_init(uv_default_loop(), client);
// UV documentation says this is guaranteed to succeed
- uv_accept((uv_stream_t *)server, (uv_stream_t *)client);
+ uv_accept((uv_stream_t*)server, (uv_stream_t*)client);
peer_name_string = NULL;
memset(&peer_name, 0, sizeof(grpc_resolved_address));
peer_name.len = sizeof(struct sockaddr_storage);
- err = uv_tcp_getpeername(client, (struct sockaddr *)&peer_name.addr,
- (int *)&peer_name.len);
+ err = uv_tcp_getpeername(client, (struct sockaddr*)&peer_name.addr,
+ (int*)&peer_name.len);
if (err == 0) {
peer_name_string = grpc_sockaddr_to_uri(&peer_name);
} else {
gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", uv_strerror(err));
}
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
if (peer_name_string) {
gpr_log(GPR_DEBUG, "SERVER_CONNECT: %p accepted connection: %s",
sp->server, peer_name_string);
@@ -224,14 +217,13 @@ static void finish_accept(grpc_exec_ctx *exec_ctx, grpc_tcp_listener *sp) {
acceptor->from_server = sp->server;
acceptor->port_index = sp->port_index;
acceptor->fd_index = 0;
- sp->server->on_accept_cb(exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
- acceptor);
+ sp->server->on_accept_cb(sp->server->on_accept_cb_arg, ep, NULL, acceptor);
gpr_free(peer_name_string);
}
-static void on_connect(uv_stream_t *server, int status) {
- grpc_tcp_listener *sp = (grpc_tcp_listener *)server->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+static void on_connect(uv_stream_t* server, int status) {
+ grpc_tcp_listener* sp = (grpc_tcp_listener*)server->data;
+ grpc_core::ExecCtx exec_ctx;
if (status < 0) {
switch (status) {
@@ -246,31 +238,51 @@ static void on_connect(uv_stream_t *server, int status) {
GPR_ASSERT(!sp->has_pending_connection);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "SERVER_CONNECT: %p incoming connection", sp->server);
}
// Create acceptor.
if (sp->server->on_accept_cb) {
- finish_accept(&exec_ctx, sp);
+ finish_accept(sp);
} else {
sp->has_pending_connection = true;
}
- grpc_exec_ctx_finish(&exec_ctx);
}
-static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
- const grpc_resolved_address *addr,
- unsigned port_index,
- grpc_tcp_listener **listener) {
- grpc_tcp_listener *sp = NULL;
+static grpc_error* add_addr_to_server(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
+ unsigned port_index,
+ grpc_tcp_listener** listener) {
+ grpc_tcp_listener* sp = NULL;
int port = -1;
int status;
- grpc_error *error;
+ grpc_error* error;
grpc_resolved_address sockname_temp;
+ uv_tcp_t* handle = (uv_tcp_t*)gpr_malloc(sizeof(uv_tcp_t));
+ int family = grpc_sockaddr_get_family(addr);
+
+ status = uv_tcp_init_ex(uv_default_loop(), handle, (unsigned int)family);
+#if defined(GPR_LINUX) && defined(SO_REUSEPORT)
+ if (family == AF_INET || family == AF_INET6) {
+ int fd;
+ uv_fileno((uv_handle_t*)handle, &fd);
+ int enable = 1;
+ setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable));
+ }
+#endif /* GPR_LINUX && SO_REUSEPORT */
+
+ if (status != 0) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Failed to initialize UV tcp handle");
+ error =
+ grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
+ grpc_slice_from_static_string(uv_strerror(status)));
+ return error;
+ }
// The last argument to uv_tcp_bind is flags
- status = uv_tcp_bind(handle, (struct sockaddr *)addr->addr, 0);
+ status = uv_tcp_bind(handle, (struct sockaddr*)addr->addr, 0);
if (status != 0) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to bind to port");
error =
@@ -279,7 +291,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
return error;
}
- status = uv_listen((uv_stream_t *)handle, SOMAXCONN, on_connect);
+ status = uv_listen((uv_stream_t*)handle, SOMAXCONN, on_connect);
if (status != 0) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to listen to port");
error =
@@ -289,8 +301,8 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
}
sockname_temp.len = (int)sizeof(struct sockaddr_storage);
- status = uv_tcp_getsockname(handle, (struct sockaddr *)&sockname_temp.addr,
- (int *)&sockname_temp.len);
+ status = uv_tcp_getsockname(handle, (struct sockaddr*)&sockname_temp.addr,
+ (int*)&sockname_temp.len);
if (status != 0) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("getsockname failed");
error =
@@ -303,7 +315,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
GPR_ASSERT(port >= 0);
GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server");
- sp = gpr_zalloc(sizeof(grpc_tcp_listener));
+ sp = (grpc_tcp_listener*)gpr_zalloc(sizeof(grpc_tcp_listener));
sp->next = NULL;
if (s->head == NULL) {
s->head = sp;
@@ -324,20 +336,48 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
- const grpc_resolved_address *addr,
- int *port) {
+static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s,
+ unsigned port_index,
+ int requested_port,
+ grpc_tcp_listener** listener) {
+ grpc_resolved_address wild4;
+ grpc_resolved_address wild6;
+ grpc_tcp_listener* sp = nullptr;
+ grpc_tcp_listener* sp2 = nullptr;
+ grpc_error* v6_err = GRPC_ERROR_NONE;
+ grpc_error* v4_err = GRPC_ERROR_NONE;
+
+ grpc_sockaddr_make_wildcards(requested_port, &wild4, &wild6);
+ /* Try listening on IPv6 first. */
+ if ((v6_err = add_addr_to_server(s, &wild6, port_index, &sp)) ==
+ GRPC_ERROR_NONE) {
+ *listener = sp;
+ return GRPC_ERROR_NONE;
+ }
+
+ if ((v4_err = add_addr_to_server(s, &wild4, port_index, &sp2)) ==
+ GRPC_ERROR_NONE) {
+ *listener = sp2;
+ return GRPC_ERROR_NONE;
+ }
+
+ grpc_error* root_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Failed to add any wildcard listeners");
+ root_err = grpc_error_add_child(root_err, v6_err);
+ root_err = grpc_error_add_child(root_err, v4_err);
+ return root_err;
+}
+
+grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
+ int* port) {
// This function is mostly copied from tcp_server_windows.c
- grpc_tcp_listener *sp = NULL;
- uv_tcp_t *handle;
+ grpc_tcp_listener* sp = NULL;
grpc_resolved_address addr6_v4mapped;
- grpc_resolved_address wildcard;
- grpc_resolved_address *allocated_addr = NULL;
+ grpc_resolved_address* allocated_addr = NULL;
grpc_resolved_address sockname_temp;
unsigned port_index = 0;
- int status;
- grpc_error *error = GRPC_ERROR_NONE;
- int family;
+ grpc_error* error = GRPC_ERROR_NONE;
GRPC_UV_ASSERT_SAME_THREAD();
@@ -351,11 +391,12 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
for (sp = s->head; sp; sp = sp->next) {
sockname_temp.len = sizeof(struct sockaddr_storage);
if (0 == uv_tcp_getsockname(sp->handle,
- (struct sockaddr *)&sockname_temp.addr,
- (int *)&sockname_temp.len)) {
+ (struct sockaddr*)&sockname_temp.addr,
+ (int*)&sockname_temp.len)) {
*port = grpc_sockaddr_get_port(&sockname_temp);
if (*port > 0) {
- allocated_addr = gpr_malloc(sizeof(grpc_resolved_address));
+ allocated_addr =
+ (grpc_resolved_address*)gpr_malloc(sizeof(grpc_resolved_address));
memcpy(allocated_addr, addr, sizeof(grpc_resolved_address));
grpc_sockaddr_set_port(allocated_addr, *port);
addr = allocated_addr;
@@ -365,46 +406,23 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
}
}
- if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
- addr = &addr6_v4mapped;
- }
-
/* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */
if (grpc_sockaddr_is_wildcard(addr, port)) {
- grpc_sockaddr_make_wildcard6(*port, &wildcard);
-
- addr = &wildcard;
- }
-
- handle = gpr_malloc(sizeof(uv_tcp_t));
-
- family = grpc_sockaddr_get_family(addr);
- status = uv_tcp_init_ex(uv_default_loop(), handle, (unsigned int)family);
-#if defined(GPR_LINUX) && defined(SO_REUSEPORT)
- if (family == AF_INET || family == AF_INET6) {
- int fd;
- uv_fileno((uv_handle_t *)handle, &fd);
- int enable = 1;
- setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable));
- }
-#endif /* GPR_LINUX && SO_REUSEPORT */
-
- if (status == 0) {
- error = add_socket_to_server(s, handle, addr, port_index, &sp);
+ error = add_wildcard_addrs_to_server(s, port_index, *port, &sp);
} else {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Failed to initialize UV tcp handle");
- error =
- grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
- grpc_slice_from_static_string(uv_strerror(status)));
+ if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
+ addr = &addr6_v4mapped;
+ }
+
+ error = add_addr_to_server(s, addr, port_index, &sp);
}
gpr_free(allocated_addr);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- char *port_string;
+ if (grpc_tcp_trace.enabled()) {
+ char* port_string;
grpc_sockaddr_to_string(&port_string, addr, 0);
- const char *str = grpc_error_string(error);
+ const char* str = grpc_error_string(error);
if (port_string) {
gpr_log(GPR_DEBUG, "SERVER %p add_port %s error=%s", s, port_string, str);
gpr_free(port_string);
@@ -414,7 +432,7 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
}
if (error != GRPC_ERROR_NONE) {
- grpc_error *error_out = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ grpc_error* error_out = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to add port to server", &error, 1);
GRPC_ERROR_UNREF(error);
error = error_out;
@@ -426,14 +444,14 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
return error;
}
-void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *server,
- grpc_pollset **pollsets, size_t pollset_count,
- grpc_tcp_server_cb on_accept_cb, void *cb_arg) {
- grpc_tcp_listener *sp;
+void grpc_tcp_server_start(grpc_tcp_server* server, grpc_pollset** pollsets,
+ size_t pollset_count,
+ grpc_tcp_server_cb on_accept_cb, void* cb_arg) {
+ grpc_tcp_listener* sp;
(void)pollsets;
(void)pollset_count;
GRPC_UV_ASSERT_SAME_THREAD();
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "SERVER_START %p", server);
}
GPR_ASSERT(on_accept_cb);
@@ -442,13 +460,12 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *server,
server->on_accept_cb_arg = cb_arg;
for (sp = server->head; sp; sp = sp->next) {
if (sp->has_pending_connection) {
- finish_accept(exec_ctx, sp);
+ finish_accept(sp);
sp->has_pending_connection = false;
}
}
}
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx,
- grpc_tcp_server *s) {}
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s) {}
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/tcp_server_windows.c b/src/core/lib/iomgr/tcp_server_windows.cc
index 0162afc1ad..8a30dfde43 100644
--- a/src/core/lib/iomgr/tcp_server_windows.c
+++ b/src/core/lib/iomgr/tcp_server_windows.cc
@@ -22,6 +22,7 @@
#include "src/core/lib/iomgr/sockaddr.h"
+#include <inttypes.h>
#include <io.h>
#include <grpc/support/alloc.h>
@@ -51,11 +52,11 @@ struct grpc_tcp_listener {
/* This will hold the socket for the next accept. */
SOCKET new_socket;
/* The listener winsocket. */
- grpc_winsocket *socket;
+ grpc_winsocket* socket;
/* The actual TCP port number. */
int port;
unsigned port_index;
- grpc_tcp_server *server;
+ grpc_tcp_server* server;
/* The cached AcceptEx for that port. */
LPFN_ACCEPTEX AcceptEx;
int shutting_down;
@@ -63,7 +64,7 @@ struct grpc_tcp_listener {
/* closure for socket notification of accept being ready */
grpc_closure on_accept;
/* linked list */
- struct grpc_tcp_listener *next;
+ struct grpc_tcp_listener* next;
};
/* the overall server */
@@ -71,7 +72,7 @@ struct grpc_tcp_server {
gpr_refcount refs;
/* Called whenever accept() succeeds on a server port. */
grpc_tcp_server_cb on_accept_cb;
- void *on_accept_cb_arg;
+ void* on_accept_cb_arg;
gpr_mu mu;
@@ -79,25 +80,24 @@ struct grpc_tcp_server {
int active_ports;
/* linked list of server ports */
- grpc_tcp_listener *head;
- grpc_tcp_listener *tail;
+ grpc_tcp_listener* head;
+ grpc_tcp_listener* tail;
/* List of closures passed to shutdown_starting_add(). */
grpc_closure_list shutdown_starting;
/* shutdown callback */
- grpc_closure *shutdown_complete;
+ grpc_closure* shutdown_complete;
- grpc_channel_args *channel_args;
+ grpc_channel_args* channel_args;
};
/* Public function. Allocates the proper data structures to hold a
grpc_tcp_server. */
-grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
- grpc_closure *shutdown_complete,
- const grpc_channel_args *args,
- grpc_tcp_server **server) {
- grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
+ const grpc_channel_args* args,
+ grpc_tcp_server** server) {
+ grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server));
s->channel_args = grpc_channel_args_copy(args);
gpr_ref_init(&s->refs, 1);
gpr_mu_init(&s->mu);
@@ -113,56 +113,54 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_server(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_tcp_server *s = arg;
+static void destroy_server(void* arg, grpc_error* error) {
+ grpc_tcp_server* s = (grpc_tcp_server*)arg;
/* Now that the accepts have been aborted, we can destroy the sockets.
The IOCP won't get notified on these, so we can flag them as already
closed by the system. */
while (s->head) {
- grpc_tcp_listener *sp = s->head;
+ grpc_tcp_listener* sp = s->head;
s->head = sp->next;
sp->next = NULL;
grpc_winsocket_destroy(sp->socket);
gpr_free(sp);
}
- grpc_channel_args_destroy(exec_ctx, s->channel_args);
+ grpc_channel_args_destroy(s->channel_args);
gpr_free(s);
}
-static void finish_shutdown_locked(grpc_exec_ctx *exec_ctx,
- grpc_tcp_server *s) {
+static void finish_shutdown_locked(grpc_tcp_server* s) {
if (s->shutdown_complete != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(destroy_server, s,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(
+ GRPC_CLOSURE_CREATE(destroy_server, s, grpc_schedule_on_exec_ctx),
+ GRPC_ERROR_NONE);
}
-grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s) {
+grpc_tcp_server* grpc_tcp_server_ref(grpc_tcp_server* s) {
gpr_ref_non_zero(&s->refs);
return s;
}
-void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s,
- grpc_closure *shutdown_starting) {
+void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
+ grpc_closure* shutdown_starting) {
gpr_mu_lock(&s->mu);
grpc_closure_list_append(&s->shutdown_starting, shutdown_starting,
GRPC_ERROR_NONE);
gpr_mu_unlock(&s->mu);
}
-static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
- grpc_tcp_listener *sp;
+static void tcp_server_destroy(grpc_tcp_server* s) {
+ grpc_tcp_listener* sp;
gpr_mu_lock(&s->mu);
/* First, shutdown all fd's. This will queue abortion calls for all
of the pending accepts due to the normal operation mechanism. */
if (s->active_ports == 0) {
- finish_shutdown_locked(exec_ctx, s);
+ finish_shutdown_locked(s);
} else {
for (sp = s->head; sp; sp = sp->next) {
sp->shutting_down = 1;
@@ -172,29 +170,30 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
gpr_mu_unlock(&s->mu);
}
-void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
+void grpc_tcp_server_unref(grpc_tcp_server* s) {
if (gpr_unref(&s->refs)) {
- grpc_tcp_server_shutdown_listeners(exec_ctx, s);
+ grpc_tcp_server_shutdown_listeners(s);
gpr_mu_lock(&s->mu);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &s->shutdown_starting);
+ GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
gpr_mu_unlock(&s->mu);
- tcp_server_destroy(exec_ctx, s);
+ tcp_server_destroy(s);
}
}
/* Prepare (bind) a recently-created socket for listening. */
-static grpc_error *prepare_socket(SOCKET sock,
- const grpc_resolved_address *addr,
- int *port) {
+static grpc_error* prepare_socket(SOCKET sock,
+ const grpc_resolved_address* addr,
+ int* port) {
grpc_resolved_address sockname_temp;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
+ int sockname_temp_len;
error = grpc_tcp_prepare_socket(sock);
if (error != GRPC_ERROR_NONE) {
goto failure;
}
- if (bind(sock, (const struct sockaddr *)addr->addr, (int)addr->len) ==
+ if (bind(sock, (const struct sockaddr*)addr->addr, (int)addr->len) ==
SOCKET_ERROR) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "bind");
goto failure;
@@ -205,8 +204,8 @@ static grpc_error *prepare_socket(SOCKET sock,
goto failure;
}
- int sockname_temp_len = sizeof(struct sockaddr_storage);
- if (getsockname(sock, (struct sockaddr *)sockname_temp.addr,
+ sockname_temp_len = sizeof(struct sockaddr_storage);
+ if (getsockname(sock, (struct sockaddr*)sockname_temp.addr,
&sockname_temp_len) == SOCKET_ERROR) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "getsockname");
goto failure;
@@ -218,7 +217,7 @@ static grpc_error *prepare_socket(SOCKET sock,
failure:
GPR_ASSERT(error != GRPC_ERROR_NONE);
- char *tgtaddr = grpc_sockaddr_to_uri(addr);
+ char* tgtaddr = grpc_sockaddr_to_uri(addr);
grpc_error_set_int(
grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to prepare server socket", &error, 1),
@@ -231,24 +230,22 @@ failure:
return error;
}
-static void decrement_active_ports_and_notify_locked(grpc_exec_ctx *exec_ctx,
- grpc_tcp_listener *sp) {
+static void decrement_active_ports_and_notify_locked(grpc_tcp_listener* sp) {
sp->shutting_down = 0;
GPR_ASSERT(sp->server->active_ports > 0);
if (0 == --sp->server->active_ports) {
- finish_shutdown_locked(exec_ctx, sp->server);
+ finish_shutdown_locked(sp->server);
}
}
/* In order to do an async accept, we need to create a socket first which
will be the one assigned to the new incoming connection. */
-static grpc_error *start_accept_locked(grpc_exec_ctx *exec_ctx,
- grpc_tcp_listener *port) {
+static grpc_error* start_accept_locked(grpc_tcp_listener* port) {
SOCKET sock = INVALID_SOCKET;
BOOL success;
DWORD addrlen = sizeof(struct sockaddr_in6) + 16;
DWORD bytes_received = 0;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (port->shutting_down) {
return GRPC_ERROR_NONE;
@@ -282,7 +279,7 @@ static grpc_error *start_accept_locked(grpc_exec_ctx *exec_ctx,
/* We're ready to do the accept. Calling grpc_socket_notify_on_read may
immediately process an accept that happened in the meantime. */
port->new_socket = sock;
- grpc_socket_notify_on_read(exec_ctx, port->socket, &port->on_accept);
+ grpc_socket_notify_on_read(port->socket, &port->on_accept);
port->outstanding_calls++;
return error;
@@ -293,14 +290,14 @@ failure:
}
/* Event manager callback when reads are ready. */
-static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_tcp_listener *sp = arg;
+static void on_accept(void* arg, grpc_error* error) {
+ grpc_tcp_listener* sp = (grpc_tcp_listener*)arg;
SOCKET sock = sp->new_socket;
- grpc_winsocket_callback_info *info = &sp->socket->read_info;
- grpc_endpoint *ep = NULL;
+ grpc_winsocket_callback_info* info = &sp->socket->read_info;
+ grpc_endpoint* ep = NULL;
grpc_resolved_address peer_name;
- char *peer_name_string;
- char *fd_name;
+ char* peer_name_string;
+ char* fd_name;
DWORD transfered_bytes;
DWORD flags;
BOOL wsa_success;
@@ -314,7 +311,7 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
this is necessary in the read/write case, it's useless for the accept
case. We only need to adjust the pending callback count */
if (error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_INFO, "Skipping on_accept due to error: %s", msg);
gpr_mu_unlock(&sp->server->mu);
@@ -328,7 +325,7 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
&transfered_bytes, FALSE, &flags);
if (!wsa_success) {
if (!sp->shutting_down) {
- char *utf8_message = gpr_format_message(WSAGetLastError());
+ char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "on_accept error: %s", utf8_message);
gpr_free(utf8_message);
}
@@ -337,25 +334,24 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
if (!sp->shutting_down) {
peer_name_string = NULL;
err = setsockopt(sock, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
- (char *)&sp->socket->socket, sizeof(sp->socket->socket));
+ (char*)&sp->socket->socket, sizeof(sp->socket->socket));
if (err) {
- char *utf8_message = gpr_format_message(WSAGetLastError());
+ char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "setsockopt error: %s", utf8_message);
gpr_free(utf8_message);
}
int peer_name_len = (int)peer_name.len;
- err =
- getpeername(sock, (struct sockaddr *)peer_name.addr, &peer_name_len);
+ err = getpeername(sock, (struct sockaddr*)peer_name.addr, &peer_name_len);
peer_name.len = (size_t)peer_name_len;
if (!err) {
peer_name_string = grpc_sockaddr_to_uri(&peer_name);
} else {
- char *utf8_message = gpr_format_message(WSAGetLastError());
+ char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "getpeername error: %s", utf8_message);
gpr_free(utf8_message);
}
gpr_asprintf(&fd_name, "tcp_server:%s", peer_name_string);
- ep = grpc_tcp_create(exec_ctx, grpc_winsocket_create(sock, fd_name),
+ ep = grpc_tcp_create(grpc_winsocket_create(sock, fd_name),
sp->server->channel_args, peer_name_string);
gpr_free(fd_name);
gpr_free(peer_name_string);
@@ -368,36 +364,35 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
managed to accept a connection, and created an endpoint. */
if (ep) {
// Create acceptor.
- grpc_tcp_server_acceptor *acceptor = gpr_malloc(sizeof(*acceptor));
+ grpc_tcp_server_acceptor* acceptor =
+ (grpc_tcp_server_acceptor*)gpr_malloc(sizeof(*acceptor));
acceptor->from_server = sp->server;
acceptor->port_index = sp->port_index;
acceptor->fd_index = 0;
- sp->server->on_accept_cb(exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
- acceptor);
+ sp->server->on_accept_cb(sp->server->on_accept_cb_arg, ep, NULL, acceptor);
}
/* As we were notified from the IOCP of one and exactly one accept,
the former socked we created has now either been destroy or assigned
to the new connection. We need to create a new one for the next
connection. */
- GPR_ASSERT(
- GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(sp)));
if (0 == --sp->outstanding_calls) {
- decrement_active_ports_and_notify_locked(exec_ctx, sp);
+ decrement_active_ports_and_notify_locked(sp);
}
gpr_mu_unlock(&sp->server->mu);
}
-static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock,
- const grpc_resolved_address *addr,
+static grpc_error* add_socket_to_server(grpc_tcp_server* s, SOCKET sock,
+ const grpc_resolved_address* addr,
unsigned port_index,
- grpc_tcp_listener **listener) {
- grpc_tcp_listener *sp = NULL;
+ grpc_tcp_listener** listener) {
+ grpc_tcp_listener* sp = NULL;
int port = -1;
int status;
GUID guid = WSAID_ACCEPTEX;
DWORD ioctl_num_bytes;
LPFN_ACCEPTEX AcceptEx;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
/* We need to grab the AcceptEx pointer for that port, as it may be
interface-dependent. We'll cache it to avoid doing that again. */
@@ -406,7 +401,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock,
&AcceptEx, sizeof(AcceptEx), &ioctl_num_bytes, NULL, NULL);
if (status != 0) {
- char *utf8_message = gpr_format_message(WSAGetLastError());
+ char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "on_connect error: %s", utf8_message);
gpr_free(utf8_message);
closesocket(sock);
@@ -421,7 +416,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock,
GPR_ASSERT(port >= 0);
gpr_mu_lock(&s->mu);
GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server");
- sp = gpr_malloc(sizeof(grpc_tcp_listener));
+ sp = (grpc_tcp_listener*)gpr_malloc(sizeof(grpc_tcp_listener));
sp->next = NULL;
if (s->head == NULL) {
s->head = sp;
@@ -445,17 +440,17 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
- const grpc_resolved_address *addr,
- int *port) {
- grpc_tcp_listener *sp = NULL;
+grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
+ const grpc_resolved_address* addr,
+ int* port) {
+ grpc_tcp_listener* sp = NULL;
SOCKET sock;
grpc_resolved_address addr6_v4mapped;
grpc_resolved_address wildcard;
- grpc_resolved_address *allocated_addr = NULL;
+ grpc_resolved_address* allocated_addr = NULL;
grpc_resolved_address sockname_temp;
unsigned port_index = 0;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (s->tail != NULL) {
port_index = s->tail->port_index + 1;
@@ -467,12 +462,13 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
for (sp = s->head; sp; sp = sp->next) {
int sockname_temp_len = sizeof(struct sockaddr_storage);
if (0 == getsockname(sp->socket->socket,
- (struct sockaddr *)sockname_temp.addr,
+ (struct sockaddr*)sockname_temp.addr,
&sockname_temp_len)) {
sockname_temp.len = (size_t)sockname_temp_len;
*port = grpc_sockaddr_get_port(&sockname_temp);
if (*port > 0) {
- allocated_addr = gpr_malloc(sizeof(grpc_resolved_address));
+ allocated_addr =
+ (grpc_resolved_address*)gpr_malloc(sizeof(grpc_resolved_address));
memcpy(allocated_addr, addr, sizeof(grpc_resolved_address));
grpc_sockaddr_set_port(allocated_addr, *port);
addr = allocated_addr;
@@ -506,7 +502,7 @@ done:
gpr_free(allocated_addr);
if (error != GRPC_ERROR_NONE) {
- grpc_error *error_out = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ grpc_error* error_out = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to add port to server", &error, 1);
GRPC_ERROR_UNREF(error);
error = error_out;
@@ -518,11 +514,11 @@ done:
return error;
}
-void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s,
- grpc_pollset **pollset, size_t pollset_count,
+void grpc_tcp_server_start(grpc_tcp_server* s, grpc_pollset** pollset,
+ size_t pollset_count,
grpc_tcp_server_cb on_accept_cb,
- void *on_accept_cb_arg) {
- grpc_tcp_listener *sp;
+ void* on_accept_cb_arg) {
+ grpc_tcp_listener* sp;
GPR_ASSERT(on_accept_cb);
gpr_mu_lock(&s->mu);
GPR_ASSERT(!s->on_accept_cb);
@@ -530,14 +526,12 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s,
s->on_accept_cb = on_accept_cb;
s->on_accept_cb_arg = on_accept_cb_arg;
for (sp = s->head; sp; sp = sp->next) {
- GPR_ASSERT(
- GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(sp)));
s->active_ports++;
}
gpr_mu_unlock(&s->mu);
}
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx,
- grpc_tcp_server *s) {}
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s) {}
#endif /* GRPC_WINSOCK_SOCKET */
diff --git a/src/core/lib/iomgr/tcp_uv.c b/src/core/lib/iomgr/tcp_uv.c
deleted file mode 100644
index a05c19b4ac..0000000000
--- a/src/core/lib/iomgr/tcp_uv.c
+++ /dev/null
@@ -1,381 +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 "src/core/lib/iomgr/port.h"
-
-#ifdef GRPC_UV
-
-#include <limits.h>
-#include <string.h>
-
-#include <grpc/slice_buffer.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/iomgr/error.h"
-#include "src/core/lib/iomgr/iomgr_uv.h"
-#include "src/core/lib/iomgr/network_status_tracker.h"
-#include "src/core/lib/iomgr/resource_quota.h"
-#include "src/core/lib/iomgr/tcp_uv.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
-
-grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false, "tcp");
-
-typedef struct {
- grpc_endpoint base;
- gpr_refcount refcount;
-
- uv_write_t write_req;
- uv_shutdown_t shutdown_req;
-
- uv_tcp_t *handle;
-
- grpc_closure *read_cb;
- grpc_closure *write_cb;
-
- grpc_slice read_slice;
- grpc_slice_buffer *read_slices;
- grpc_slice_buffer *write_slices;
- uv_buf_t *write_buffers;
-
- grpc_resource_user *resource_user;
-
- bool shutting_down;
-
- char *peer_string;
- grpc_pollset *pollset;
-} grpc_tcp;
-
-static void tcp_free(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- grpc_slice_unref_internal(exec_ctx, tcp->read_slice);
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
- gpr_free(tcp->handle);
- gpr_free(tcp->peer_string);
- gpr_free(tcp);
-}
-
-#ifndef NDEBUG
-#define TCP_UNREF(exec_ctx, tcp, reason) \
- tcp_unref((exec_ctx), (tcp), (reason), __FILE__, __LINE__)
-#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
-static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
- const char *reason, const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
- val - 1);
- }
- if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
- }
-}
-
-static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file,
- int line) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
- val + 1);
- }
- gpr_ref(&tcp->refcount);
-}
-#else
-#define TCP_UNREF(exec_ctx, tcp, reason) tcp_unref((exec_ctx), (tcp))
-#define TCP_REF(tcp, reason) tcp_ref((tcp))
-static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
- if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
- }
-}
-
-static void tcp_ref(grpc_tcp *tcp) { gpr_ref(&tcp->refcount); }
-#endif
-
-static void uv_close_callback(uv_handle_t *handle) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp *tcp = handle->data;
- TCP_UNREF(&exec_ctx, tcp, "destroy");
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static grpc_slice alloc_read_slice(grpc_exec_ctx *exec_ctx,
- grpc_resource_user *resource_user) {
- return grpc_resource_user_slice_malloc(exec_ctx, resource_user,
- GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
-}
-
-static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size,
- uv_buf_t *buf) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp *tcp = handle->data;
- (void)suggested_size;
- buf->base = (char *)GRPC_SLICE_START_PTR(tcp->read_slice);
- buf->len = GRPC_SLICE_LENGTH(tcp->read_slice);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void read_callback(uv_stream_t *stream, ssize_t nread,
- const uv_buf_t *buf) {
- grpc_slice sub;
- grpc_error *error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp *tcp = stream->data;
- grpc_closure *cb = tcp->read_cb;
- if (nread == 0) {
- // Nothing happened. Wait for the next callback
- return;
- }
- TCP_UNREF(&exec_ctx, tcp, "read");
- tcp->read_cb = NULL;
- // TODO(murgatroid99): figure out what the return value here means
- uv_read_stop(stream);
- if (nread == UV_EOF) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF");
- } else if (nread > 0) {
- // Successful read
- sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, (size_t)nread);
- grpc_slice_buffer_add(tcp->read_slices, sub);
- tcp->read_slice = alloc_read_slice(&exec_ctx, tcp->resource_user);
- error = GRPC_ERROR_NONE;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- size_t i;
- const char *str = grpc_error_string(error);
- gpr_log(GPR_DEBUG, "read: error=%s", str);
-
- for (i = 0; i < tcp->read_slices->count; i++) {
- char *dump = grpc_dump_slice(tcp->read_slices->slices[i],
- GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string,
- dump);
- gpr_free(dump);
- }
- }
- } else {
- // nread < 0: Error
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed");
- }
- GRPC_CLOSURE_SCHED(&exec_ctx, cb, error);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void uv_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *read_slices, grpc_closure *cb) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- int status;
- grpc_error *error = GRPC_ERROR_NONE;
- GRPC_UV_ASSERT_SAME_THREAD();
- GPR_ASSERT(tcp->read_cb == NULL);
- tcp->read_cb = cb;
- tcp->read_slices = read_slices;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, read_slices);
- TCP_REF(tcp, "read");
- // TODO(murgatroid99): figure out what the return value here means
- status =
- uv_read_start((uv_stream_t *)tcp->handle, alloc_uv_buf, read_callback);
- if (status != 0) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed at start");
- error =
- grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
- grpc_slice_from_static_string(uv_strerror(status)));
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
- }
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
- gpr_log(GPR_DEBUG, "Initiating read on %p: error=%s", tcp, str);
- }
-}
-
-static void write_callback(uv_write_t *req, int status) {
- grpc_tcp *tcp = req->data;
- grpc_error *error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_closure *cb = tcp->write_cb;
- tcp->write_cb = NULL;
- TCP_UNREF(&exec_ctx, tcp, "write");
- if (status == 0) {
- error = GRPC_ERROR_NONE;
- } else {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Write failed");
- }
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(error);
- gpr_log(GPR_DEBUG, "write complete on %p: error=%s", tcp, str);
- }
- gpr_free(tcp->write_buffers);
- grpc_resource_user_free(&exec_ctx, tcp->resource_user,
- sizeof(uv_buf_t) * tcp->write_slices->count);
- GRPC_CLOSURE_SCHED(&exec_ctx, cb, error);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *write_slices,
- grpc_closure *cb) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- uv_buf_t *buffers;
- unsigned int buffer_count;
- unsigned int i;
- grpc_slice *slice;
- uv_write_t *write_req;
- GRPC_UV_ASSERT_SAME_THREAD();
-
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- size_t j;
-
- for (j = 0; j < write_slices->count; j++) {
- char *data = grpc_dump_slice(write_slices->slices[j],
- GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data);
- gpr_free(data);
- }
- }
-
- if (tcp->shutting_down) {
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "TCP socket is shutting down"));
- return;
- }
-
- GPR_ASSERT(tcp->write_cb == NULL);
- tcp->write_slices = write_slices;
- GPR_ASSERT(tcp->write_slices->count <= UINT_MAX);
- if (tcp->write_slices->count == 0) {
- // No slices means we don't have to do anything,
- // and libuv doesn't like empty writes
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
- return;
- }
-
- tcp->write_cb = cb;
- buffer_count = (unsigned int)tcp->write_slices->count;
- buffers = gpr_malloc(sizeof(uv_buf_t) * buffer_count);
- grpc_resource_user_alloc(exec_ctx, tcp->resource_user,
- sizeof(uv_buf_t) * buffer_count, NULL);
- for (i = 0; i < buffer_count; i++) {
- slice = &tcp->write_slices->slices[i];
- buffers[i].base = (char *)GRPC_SLICE_START_PTR(*slice);
- buffers[i].len = GRPC_SLICE_LENGTH(*slice);
- }
- tcp->write_buffers = buffers;
- write_req = &tcp->write_req;
- write_req->data = tcp;
- TCP_REF(tcp, "write");
- // TODO(murgatroid99): figure out what the return value here means
- uv_write(write_req, (uv_stream_t *)tcp->handle, buffers, buffer_count,
- write_callback);
-}
-
-static void uv_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset) {
- // No-op. We're ignoring pollsets currently
- (void)exec_ctx;
- (void)ep;
- (void)pollset;
- grpc_tcp *tcp = (grpc_tcp *)ep;
- tcp->pollset = pollset;
-}
-
-static void uv_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset) {
- // No-op. We're ignoring pollsets currently
- (void)exec_ctx;
- (void)ep;
- (void)pollset;
-}
-
-static void shutdown_callback(uv_shutdown_t *req, int status) {}
-
-static void uv_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- if (!tcp->shutting_down) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- const char *str = grpc_error_string(why);
- gpr_log(GPR_DEBUG, "TCP %p shutdown why=%s", tcp->handle, str);
- }
- tcp->shutting_down = true;
- uv_shutdown_t *req = &tcp->shutdown_req;
- uv_shutdown(req, (uv_stream_t *)tcp->handle, shutdown_callback);
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
- }
- GRPC_ERROR_UNREF(why);
-}
-
-static void uv_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
- grpc_network_status_unregister_endpoint(ep);
- grpc_tcp *tcp = (grpc_tcp *)ep;
- uv_close((uv_handle_t *)tcp->handle, uv_close_callback);
-}
-
-static char *uv_get_peer(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- return gpr_strdup(tcp->peer_string);
-}
-
-static grpc_resource_user *uv_get_resource_user(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- return tcp->resource_user;
-}
-
-static int uv_get_fd(grpc_endpoint *ep) { return -1; }
-
-static grpc_endpoint_vtable vtable = {
- uv_endpoint_read, uv_endpoint_write, uv_add_to_pollset,
- uv_add_to_pollset_set, uv_endpoint_shutdown, uv_destroy,
- uv_get_resource_user, uv_get_peer, uv_get_fd};
-
-grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle,
- grpc_resource_quota *resource_quota,
- char *peer_string) {
- grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
- gpr_log(GPR_DEBUG, "Creating TCP endpoint %p", tcp);
- }
-
- /* Disable Nagle's Algorithm */
- uv_tcp_nodelay(handle, 1);
-
- memset(tcp, 0, sizeof(grpc_tcp));
- tcp->base.vtable = &vtable;
- tcp->handle = handle;
- handle->data = tcp;
- gpr_ref_init(&tcp->refcount, 1);
- tcp->peer_string = gpr_strdup(peer_string);
- tcp->shutting_down = false;
- tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
- tcp->read_slice = alloc_read_slice(&exec_ctx, tcp->resource_user);
- /* Tell network status tracking code about the new endpoint */
- grpc_network_status_register_endpoint(&tcp->base);
-
-#ifndef GRPC_UV_TCP_HOLD_LOOP
- uv_unref((uv_handle_t *)handle);
-#endif
-
- grpc_exec_ctx_finish(&exec_ctx);
- return &tcp->base;
-}
-
-#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc
new file mode 100644
index 0000000000..b384623a5e
--- /dev/null
+++ b/src/core/lib/iomgr/tcp_uv.cc
@@ -0,0 +1,423 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_UV
+
+#include <limits.h>
+#include <string.h>
+
+#include <grpc/slice_buffer.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/iomgr/iomgr_uv.h"
+#include "src/core/lib/iomgr/network_status_tracker.h"
+#include "src/core/lib/iomgr/resource_quota.h"
+#include "src/core/lib/iomgr/tcp_uv.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+
+grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
+
+typedef struct {
+ grpc_endpoint base;
+ gpr_refcount refcount;
+
+ uv_write_t write_req;
+ uv_shutdown_t shutdown_req;
+
+ uv_tcp_t* handle;
+
+ grpc_closure* read_cb;
+ grpc_closure* write_cb;
+
+ grpc_slice_buffer* read_slices;
+ grpc_slice_buffer* write_slices;
+ uv_buf_t* write_buffers;
+
+ grpc_resource_user* resource_user;
+ grpc_resource_user_slice_allocator slice_allocator;
+
+ bool shutting_down;
+
+ char* peer_string;
+ grpc_pollset* pollset;
+} grpc_tcp;
+
+static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
+ return grpc_error_set_str(
+ grpc_error_set_int(
+ src_error,
+ /* All tcp errors are marked with UNAVAILABLE so that application may
+ * choose to retry. */
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
+ GRPC_ERROR_STR_TARGET_ADDRESS,
+ grpc_slice_from_copied_string(tcp->peer_string));
+}
+
+static void tcp_free(grpc_tcp* tcp) {
+ grpc_resource_user_unref(tcp->resource_user);
+ gpr_free(tcp->handle);
+ gpr_free(tcp->peer_string);
+ gpr_free(tcp);
+}
+
+#ifndef NDEBUG
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
+#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
+static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
+ if (grpc_tcp_trace.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
+ val - 1);
+ }
+ if (gpr_unref(&tcp->refcount)) {
+ tcp_free(tcp);
+ }
+}
+
+static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
+ if (grpc_tcp_trace.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
+ val + 1);
+ }
+ gpr_ref(&tcp->refcount);
+}
+#else
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
+#define TCP_REF(tcp, reason) tcp_ref((tcp))
+static void tcp_unref(grpc_tcp* tcp) {
+ if (gpr_unref(&tcp->refcount)) {
+ tcp_free(tcp);
+ }
+}
+
+static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
+#endif
+
+static void uv_close_callback(uv_handle_t* handle) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp* tcp = (grpc_tcp*)handle->data;
+ TCP_UNREF(tcp, "destroy");
+}
+
+static void alloc_uv_buf(uv_handle_t* handle, size_t suggested_size,
+ uv_buf_t* buf) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp* tcp = (grpc_tcp*)handle->data;
+ (void)suggested_size;
+ /* Before calling uv_read_start, we allocate a buffer with exactly one slice
+ * to tcp->read_slices and wait for the callback indicating that the
+ * allocation was successful. So slices[0] should always exist here */
+ buf->base = (char*)GRPC_SLICE_START_PTR(tcp->read_slices->slices[0]);
+ buf->len = GRPC_SLICE_LENGTH(tcp->read_slices->slices[0]);
+}
+
+static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
+ grpc_closure* cb = tcp->read_cb;
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
+ size_t i;
+ const char* str = grpc_error_string(error);
+ gpr_log(GPR_DEBUG, "read: error=%s", str);
+
+ for (i = 0; i < tcp->read_slices->count; i++) {
+ char* dump = grpc_dump_slice(tcp->read_slices->slices[i],
+ GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump);
+ gpr_free(dump);
+ }
+ }
+ tcp->read_slices = NULL;
+ tcp->read_cb = NULL;
+ GRPC_CLOSURE_RUN(cb, error);
+}
+
+static void read_callback(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf) {
+ grpc_error* error;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp* tcp = (grpc_tcp*)stream->data;
+ grpc_slice_buffer garbage;
+ if (nread == 0) {
+ // Nothing happened. Wait for the next callback
+ return;
+ }
+ TCP_UNREF(tcp, "read");
+ // TODO(murgatroid99): figure out what the return value here means
+ uv_read_stop(stream);
+ if (nread == UV_EOF) {
+ error =
+ tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
+ } else if (nread > 0) {
+ // Successful read
+ error = GRPC_ERROR_NONE;
+ if ((size_t)nread < tcp->read_slices->length) {
+ /* TODO(murgatroid99): Instead of discarding the unused part of the read
+ * buffer, reuse it as the next read buffer. */
+ grpc_slice_buffer_init(&garbage);
+ grpc_slice_buffer_trim_end(
+ tcp->read_slices, tcp->read_slices->length - (size_t)nread, &garbage);
+ grpc_slice_buffer_reset_and_unref_internal(&garbage);
+ }
+ } else {
+ // nread < 0: Error
+ error = tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed"), tcp);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
+ }
+ call_read_cb(tcp, error);
+}
+
+static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
+ int status;
+ grpc_tcp* tcp = (grpc_tcp*)tcpp;
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
+ grpc_error_string(error));
+ }
+ if (error == GRPC_ERROR_NONE) {
+ status =
+ uv_read_start((uv_stream_t*)tcp->handle, alloc_uv_buf, read_callback);
+ if (status != 0) {
+ error = tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed at start"),
+ tcp);
+ error = grpc_error_set_str(
+ error, GRPC_ERROR_STR_OS_ERROR,
+ grpc_slice_from_static_string(uv_strerror(status)));
+ }
+ }
+ if (error != GRPC_ERROR_NONE) {
+ grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
+ TCP_UNREF(tcp, "read");
+ }
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
+ gpr_log(GPR_DEBUG, "Initiating read on %p: error=%s", tcp, str);
+ }
+}
+
+static void uv_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
+ grpc_closure* cb) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ GRPC_UV_ASSERT_SAME_THREAD();
+ GPR_ASSERT(tcp->read_cb == NULL);
+ tcp->read_cb = cb;
+ tcp->read_slices = read_slices;
+ grpc_slice_buffer_reset_and_unref_internal(read_slices);
+ TCP_REF(tcp, "read");
+ grpc_resource_user_alloc_slices(&tcp->slice_allocator,
+ GRPC_TCP_DEFAULT_READ_SLICE_SIZE, 1,
+ tcp->read_slices);
+}
+
+static void write_callback(uv_write_t* req, int status) {
+ grpc_tcp* tcp = (grpc_tcp*)req->data;
+ grpc_error* error;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_closure* cb = tcp->write_cb;
+ tcp->write_cb = NULL;
+ TCP_UNREF(tcp, "write");
+ if (status == 0) {
+ error = GRPC_ERROR_NONE;
+ } else {
+ error = tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Write failed"), tcp);
+ }
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(error);
+ gpr_log(GPR_DEBUG, "write complete on %p: error=%s", tcp, str);
+ }
+ gpr_free(tcp->write_buffers);
+ GRPC_CLOSURE_SCHED(cb, error);
+}
+
+static void uv_endpoint_write(grpc_endpoint* ep,
+ grpc_slice_buffer* write_slices,
+ grpc_closure* cb) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ uv_buf_t* buffers;
+ unsigned int buffer_count;
+ unsigned int i;
+ grpc_slice* slice;
+ uv_write_t* write_req;
+ GRPC_UV_ASSERT_SAME_THREAD();
+
+ if (grpc_tcp_trace.enabled()) {
+ size_t j;
+
+ for (j = 0; j < write_slices->count; j++) {
+ char* data = grpc_dump_slice(write_slices->slices[j],
+ GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data);
+ gpr_free(data);
+ }
+ }
+
+ if (tcp->shutting_down) {
+ GRPC_CLOSURE_SCHED(cb,
+ tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "TCP socket is shutting down"),
+ tcp));
+ return;
+ }
+
+ GPR_ASSERT(tcp->write_cb == NULL);
+ tcp->write_slices = write_slices;
+ GPR_ASSERT(tcp->write_slices->count <= UINT_MAX);
+ if (tcp->write_slices->count == 0) {
+ // No slices means we don't have to do anything,
+ // and libuv doesn't like empty writes
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
+ return;
+ }
+
+ tcp->write_cb = cb;
+ buffer_count = (unsigned int)tcp->write_slices->count;
+ buffers = (uv_buf_t*)gpr_malloc(sizeof(uv_buf_t) * buffer_count);
+ for (i = 0; i < buffer_count; i++) {
+ slice = &tcp->write_slices->slices[i];
+ buffers[i].base = (char*)GRPC_SLICE_START_PTR(*slice);
+ buffers[i].len = GRPC_SLICE_LENGTH(*slice);
+ }
+ tcp->write_buffers = buffers;
+ write_req = &tcp->write_req;
+ write_req->data = tcp;
+ TCP_REF(tcp, "write");
+ // TODO(murgatroid99): figure out what the return value here means
+ uv_write(write_req, (uv_stream_t*)tcp->handle, buffers, buffer_count,
+ write_callback);
+}
+
+static void uv_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
+ // No-op. We're ignoring pollsets currently
+ (void)ep;
+ (void)pollset;
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ tcp->pollset = pollset;
+}
+
+static void uv_add_to_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {
+ // No-op. We're ignoring pollsets currently
+ (void)ep;
+ (void)pollset;
+}
+
+static void uv_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {
+ // No-op. We're ignoring pollsets currently
+ (void)ep;
+ (void)pollset;
+}
+
+static void shutdown_callback(uv_shutdown_t* req, int status) {}
+
+static void uv_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ if (!tcp->shutting_down) {
+ if (grpc_tcp_trace.enabled()) {
+ const char* str = grpc_error_string(why);
+ gpr_log(GPR_DEBUG, "TCP %p shutdown why=%s", tcp->handle, str);
+ }
+ tcp->shutting_down = true;
+ uv_shutdown_t* req = &tcp->shutdown_req;
+ uv_shutdown(req, (uv_stream_t*)tcp->handle, shutdown_callback);
+ grpc_resource_user_shutdown(tcp->resource_user);
+ }
+ GRPC_ERROR_UNREF(why);
+}
+
+static void uv_destroy(grpc_endpoint* ep) {
+ grpc_network_status_unregister_endpoint(ep);
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ uv_close((uv_handle_t*)tcp->handle, uv_close_callback);
+}
+
+static char* uv_get_peer(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ return gpr_strdup(tcp->peer_string);
+}
+
+static grpc_resource_user* uv_get_resource_user(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ return tcp->resource_user;
+}
+
+static int uv_get_fd(grpc_endpoint* ep) { return -1; }
+
+static grpc_endpoint_vtable vtable = {uv_endpoint_read,
+ uv_endpoint_write,
+ uv_add_to_pollset,
+ uv_add_to_pollset_set,
+ uv_delete_from_pollset_set,
+ uv_endpoint_shutdown,
+ uv_destroy,
+ uv_get_resource_user,
+ uv_get_peer,
+ uv_get_fd};
+
+grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
+ grpc_resource_quota* resource_quota,
+ char* peer_string) {
+ grpc_tcp* tcp = (grpc_tcp*)gpr_malloc(sizeof(grpc_tcp));
+ grpc_core::ExecCtx exec_ctx;
+
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "Creating TCP endpoint %p", tcp);
+ }
+
+ /* Disable Nagle's Algorithm */
+ uv_tcp_nodelay(handle, 1);
+
+ memset(tcp, 0, sizeof(grpc_tcp));
+ tcp->base.vtable = &vtable;
+ tcp->handle = handle;
+ handle->data = tcp;
+ gpr_ref_init(&tcp->refcount, 1);
+ tcp->peer_string = gpr_strdup(peer_string);
+ tcp->shutting_down = false;
+ tcp->read_slices = NULL;
+ tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
+ grpc_resource_user_slice_allocator_init(
+ &tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
+ /* Tell network status tracking code about the new endpoint */
+ grpc_network_status_register_endpoint(&tcp->base);
+
+#ifndef GRPC_UV_TCP_HOLD_LOOP
+ uv_unref((uv_handle_t*)handle);
+#endif
+
+ return &tcp->base;
+}
+
+#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/tcp_uv.h b/src/core/lib/iomgr/tcp_uv.h
index 0e67481d35..fd6d19049a 100644
--- a/src/core/lib/iomgr/tcp_uv.h
+++ b/src/core/lib/iomgr/tcp_uv.h
@@ -32,14 +32,20 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_UV
+
#include <uv.h>
-extern grpc_tracer_flag grpc_tcp_trace;
+extern grpc_core::TraceFlag grpc_tcp_trace;
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
-grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle,
- grpc_resource_quota *resource_quota,
- char *peer_string);
+grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
+ grpc_resource_quota* resource_quota,
+ char* peer_string);
+
+#endif /* GRPC_UV */
#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */
diff --git a/src/core/lib/iomgr/tcp_windows.c b/src/core/lib/iomgr/tcp_windows.cc
index 2cbb97403b..6d091b77bb 100644
--- a/src/core/lib/iomgr/tcp_windows.c
+++ b/src/core/lib/iomgr/tcp_windows.cc
@@ -37,6 +37,7 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/socket_windows.h"
#include "src/core/lib/iomgr/tcp_client.h"
+#include "src/core/lib/iomgr/tcp_windows.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/slice/slice_internal.h"
@@ -48,9 +49,9 @@
#define GRPC_FIONBIO FIONBIO
#endif
-grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false, "tcp");
+grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
-static grpc_error *set_non_block(SOCKET sock) {
+static grpc_error* set_non_block(SOCKET sock) {
int status;
uint32_t param = 1;
DWORD ret;
@@ -61,18 +62,18 @@ static grpc_error *set_non_block(SOCKET sock) {
: GRPC_WSA_ERROR(WSAGetLastError(), "WSAIoctl(GRPC_FIONBIO)");
}
-static grpc_error *set_dualstack(SOCKET sock) {
+static grpc_error* set_dualstack(SOCKET sock) {
int status;
unsigned long param = 0;
- status = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&param,
+ status = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&param,
sizeof(param));
return status == 0
? GRPC_ERROR_NONE
: GRPC_WSA_ERROR(WSAGetLastError(), "setsockopt(IPV6_V6ONLY)");
}
-grpc_error *grpc_tcp_prepare_socket(SOCKET sock) {
- grpc_error *err;
+grpc_error* grpc_tcp_prepare_socket(SOCKET sock) {
+ grpc_error* err;
err = set_non_block(sock);
if (err != GRPC_ERROR_NONE) return err;
err = set_dualstack(sock);
@@ -84,59 +85,58 @@ typedef struct grpc_tcp {
/* This is our C++ class derivation emulation. */
grpc_endpoint base;
/* The one socket this endpoint is using. */
- grpc_winsocket *socket;
+ grpc_winsocket* socket;
/* Refcounting how many operations are in progress. */
gpr_refcount refcount;
grpc_closure on_read;
grpc_closure on_write;
- grpc_closure *read_cb;
- grpc_closure *write_cb;
+ grpc_closure* read_cb;
+ grpc_closure* write_cb;
grpc_slice read_slice;
- grpc_slice_buffer *write_slices;
- grpc_slice_buffer *read_slices;
+ grpc_slice_buffer* write_slices;
+ grpc_slice_buffer* read_slices;
- grpc_resource_user *resource_user;
+ grpc_resource_user* resource_user;
/* The IO Completion Port runs from another thread. We need some mechanism
to protect ourselves when requesting a shutdown. */
gpr_mu mu;
int shutting_down;
- grpc_error *shutdown_error;
+ grpc_error* shutdown_error;
- char *peer_string;
+ char* peer_string;
} grpc_tcp;
-static void tcp_free(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
+static void tcp_free(grpc_tcp* tcp) {
grpc_winsocket_destroy(tcp->socket);
gpr_mu_destroy(&tcp->mu);
gpr_free(tcp->peer_string);
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
+ grpc_resource_user_unref(tcp->resource_user);
if (tcp->shutting_down) GRPC_ERROR_UNREF(tcp->shutdown_error);
gpr_free(tcp);
}
#ifndef NDEBUG
-#define TCP_UNREF(exec_ctx, tcp, reason) \
- tcp_unref((exec_ctx), (tcp), (reason), __FILE__, __LINE__)
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
-static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
- const char *reason, const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
+ if (grpc_tcp_trace.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
val - 1);
}
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
-static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file,
+static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
int line) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
@@ -145,39 +145,39 @@ static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file,
gpr_ref(&tcp->refcount);
}
#else
-#define TCP_UNREF(exec_ctx, tcp, reason) tcp_unref((exec_ctx), (tcp))
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
#define TCP_REF(tcp, reason) tcp_ref((tcp))
-static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
+static void tcp_unref(grpc_tcp* tcp) {
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
-static void tcp_ref(grpc_tcp *tcp) { gpr_ref(&tcp->refcount); }
+static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
#endif
/* Asynchronous callback from the IOCP, or the background thread. */
-static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) {
- grpc_tcp *tcp = tcpp;
- grpc_closure *cb = tcp->read_cb;
- grpc_winsocket *socket = tcp->socket;
+static void on_read(void* tcpp, grpc_error* error) {
+ grpc_tcp* tcp = (grpc_tcp*)tcpp;
+ grpc_closure* cb = tcp->read_cb;
+ grpc_winsocket* socket = tcp->socket;
grpc_slice sub;
- grpc_winsocket_callback_info *info = &socket->read_info;
+ grpc_winsocket_callback_info* info = &socket->read_info;
GRPC_ERROR_REF(error);
if (error == GRPC_ERROR_NONE) {
if (info->wsa_error != 0 && !tcp->shutting_down) {
- char *utf8_message = gpr_format_message(info->wsa_error);
+ char* utf8_message = gpr_format_message(info->wsa_error);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(utf8_message);
gpr_free(utf8_message);
- grpc_slice_unref_internal(exec_ctx, tcp->read_slice);
+ grpc_slice_unref_internal(tcp->read_slice);
} else {
if (info->bytes_transfered != 0 && !tcp->shutting_down) {
sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, info->bytes_transfered);
grpc_slice_buffer_add(tcp->read_slices, sub);
} else {
- grpc_slice_unref_internal(exec_ctx, tcp->read_slice);
+ grpc_slice_unref_internal(tcp->read_slice);
error = tcp->shutting_down
? GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"TCP stream shutting down", &tcp->shutdown_error, 1)
@@ -187,15 +187,15 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) {
}
tcp->read_cb = NULL;
- TCP_UNREF(exec_ctx, tcp, "read");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ TCP_UNREF(tcp, "read");
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *read_slices, grpc_closure *cb) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_winsocket *handle = tcp->socket;
- grpc_winsocket_callback_info *info = &handle->read_info;
+static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
+ grpc_closure* cb) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_winsocket* handle = tcp->socket;
+ grpc_winsocket_callback_info* info = &handle->read_info;
int status;
DWORD bytes_read = 0;
DWORD flags = 0;
@@ -203,21 +203,20 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
if (tcp->shutting_down) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "TCP socket is shutting down", &tcp->shutdown_error, 1));
+ cb, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "TCP socket is shutting down", &tcp->shutdown_error, 1));
return;
}
tcp->read_cb = cb;
tcp->read_slices = read_slices;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, read_slices);
+ grpc_slice_buffer_reset_and_unref_internal(read_slices);
tcp->read_slice = GRPC_SLICE_MALLOC(8192);
buffer.len = (ULONG)GRPC_SLICE_LENGTH(
tcp->read_slice); // we know slice size fits in 32bit.
- buffer.buf = (char *)GRPC_SLICE_START_PTR(tcp->read_slice);
+ buffer.buf = (char*)GRPC_SLICE_START_PTR(tcp->read_slice);
TCP_REF(tcp, "read");
@@ -229,7 +228,7 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
/* Did we get data immediately ? Yay. */
if (info->wsa_error != WSAEWOULDBLOCK) {
info->bytes_transfered = bytes_read;
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->on_read, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&tcp->on_read, GRPC_ERROR_NONE);
return;
}
@@ -242,21 +241,21 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
int wsa_error = WSAGetLastError();
if (wsa_error != WSA_IO_PENDING) {
info->wsa_error = wsa_error;
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->on_read,
+ GRPC_CLOSURE_SCHED(&tcp->on_read,
GRPC_WSA_ERROR(info->wsa_error, "WSARecv"));
return;
}
}
- grpc_socket_notify_on_read(exec_ctx, tcp->socket, &tcp->on_read);
+ grpc_socket_notify_on_read(tcp->socket, &tcp->on_read);
}
/* Asynchronous callback from the IOCP, or the background thread. */
-static void on_write(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) {
- grpc_tcp *tcp = (grpc_tcp *)tcpp;
- grpc_winsocket *handle = tcp->socket;
- grpc_winsocket_callback_info *info = &handle->write_info;
- grpc_closure *cb;
+static void on_write(void* tcpp, grpc_error* error) {
+ grpc_tcp* tcp = (grpc_tcp*)tcpp;
+ grpc_winsocket* handle = tcp->socket;
+ grpc_winsocket_callback_info* info = &handle->write_info;
+ grpc_closure* cb;
GRPC_ERROR_REF(error);
@@ -273,29 +272,28 @@ static void on_write(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) {
}
}
- TCP_UNREF(exec_ctx, tcp, "write");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ TCP_UNREF(tcp, "write");
+ GRPC_CLOSURE_SCHED(cb, error);
}
/* Initiates a write. */
-static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
- grpc_winsocket *socket = tcp->socket;
- grpc_winsocket_callback_info *info = &socket->write_info;
+static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_winsocket* socket = tcp->socket;
+ grpc_winsocket_callback_info* info = &socket->write_info;
unsigned i;
DWORD bytes_sent;
int status;
WSABUF local_buffers[16];
- WSABUF *allocated = NULL;
- WSABUF *buffers = local_buffers;
+ WSABUF* allocated = NULL;
+ WSABUF* buffers = local_buffers;
size_t len;
if (tcp->shutting_down) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "TCP socket is shutting down", &tcp->shutdown_error, 1));
+ cb, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "TCP socket is shutting down", &tcp->shutdown_error, 1));
return;
}
@@ -303,7 +301,7 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
tcp->write_slices = slices;
GPR_ASSERT(tcp->write_slices->count <= UINT_MAX);
if (tcp->write_slices->count > GPR_ARRAY_SIZE(local_buffers)) {
- buffers = (WSABUF *)gpr_malloc(sizeof(WSABUF) * tcp->write_slices->count);
+ buffers = (WSABUF*)gpr_malloc(sizeof(WSABUF) * tcp->write_slices->count);
allocated = buffers;
}
@@ -311,7 +309,7 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
len = GRPC_SLICE_LENGTH(tcp->write_slices->slices[i]);
GPR_ASSERT(len <= ULONG_MAX);
buffers[i].len = (ULONG)len;
- buffers[i].buf = (char *)GRPC_SLICE_START_PTR(tcp->write_slices->slices[i]);
+ buffers[i].buf = (char*)GRPC_SLICE_START_PTR(tcp->write_slices->slices[i]);
}
/* First, let's try a synchronous, non-blocking write. */
@@ -323,10 +321,10 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
connection that has its send queue filled up. But if we don't, then we can
avoid doing an async write operation at all. */
if (info->wsa_error != WSAEWOULDBLOCK) {
- grpc_error *error = status == 0
+ grpc_error* error = status == 0
? GRPC_ERROR_NONE
: GRPC_WSA_ERROR(info->wsa_error, "WSASend");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
if (allocated) gpr_free(allocated);
return;
}
@@ -343,42 +341,42 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
if (status != 0) {
int wsa_error = WSAGetLastError();
if (wsa_error != WSA_IO_PENDING) {
- TCP_UNREF(exec_ctx, tcp, "write");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_WSA_ERROR(wsa_error, "WSASend"));
+ TCP_UNREF(tcp, "write");
+ GRPC_CLOSURE_SCHED(cb, GRPC_WSA_ERROR(wsa_error, "WSASend"));
return;
}
}
/* As all is now setup, we can now ask for the IOCP notification. It may
trigger the callback immediately however, but no matter. */
- grpc_socket_notify_on_write(exec_ctx, socket, &tcp->on_write);
+ grpc_socket_notify_on_write(socket, &tcp->on_write);
}
-static void win_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *ps) {
- grpc_tcp *tcp;
+static void win_add_to_pollset(grpc_endpoint* ep, grpc_pollset* ps) {
+ grpc_tcp* tcp;
(void)ps;
- tcp = (grpc_tcp *)ep;
+ tcp = (grpc_tcp*)ep;
grpc_iocp_add_socket(tcp->socket);
}
-static void win_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pss) {
- grpc_tcp *tcp;
+static void win_add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pss) {
+ grpc_tcp* tcp;
(void)pss;
- tcp = (grpc_tcp *)ep;
+ tcp = (grpc_tcp*)ep;
grpc_iocp_add_socket(tcp->socket);
}
+static void win_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pss) {}
+
/* Initiates a shutdown of the TCP endpoint. This will queue abort callbacks
for the potential read and write operations. It is up to the caller to
guarantee this isn't called in parallel to a read or write request, so
we're not going to protect against these. However the IO Completion Port
callback will happen from another thread, so we need to protect against
concurrent access of the data structure in that regard. */
-static void win_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+static void win_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
gpr_mu_lock(&tcp->mu);
/* At that point, what may happen is that we're already inside the IOCP
callback. See the comments in on_read and on_write. */
@@ -390,46 +388,52 @@ static void win_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
}
grpc_winsocket_shutdown(tcp->socket);
gpr_mu_unlock(&tcp->mu);
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
+ grpc_resource_user_shutdown(tcp->resource_user);
}
-static void win_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
+static void win_destroy(grpc_endpoint* ep) {
grpc_network_status_unregister_endpoint(ep);
- grpc_tcp *tcp = (grpc_tcp *)ep;
- TCP_UNREF(exec_ctx, tcp, "destroy");
+ grpc_tcp* tcp = (grpc_tcp*)ep;
+ TCP_UNREF(tcp, "destroy");
}
-static char *win_get_peer(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+static char* win_get_peer(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
return gpr_strdup(tcp->peer_string);
}
-static grpc_resource_user *win_get_resource_user(grpc_endpoint *ep) {
- grpc_tcp *tcp = (grpc_tcp *)ep;
+static grpc_resource_user* win_get_resource_user(grpc_endpoint* ep) {
+ grpc_tcp* tcp = (grpc_tcp*)ep;
return tcp->resource_user;
}
-static int win_get_fd(grpc_endpoint *ep) { return -1; }
-
-static grpc_endpoint_vtable vtable = {
- win_read, win_write, win_add_to_pollset, win_add_to_pollset_set,
- win_shutdown, win_destroy, win_get_resource_user, win_get_peer,
- win_get_fd};
-
-grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket,
- grpc_channel_args *channel_args,
- char *peer_string) {
- grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
+static int win_get_fd(grpc_endpoint* ep) { return -1; }
+
+static grpc_endpoint_vtable vtable = {win_read,
+ win_write,
+ win_add_to_pollset,
+ win_add_to_pollset_set,
+ win_delete_from_pollset_set,
+ win_shutdown,
+ win_destroy,
+ win_get_resource_user,
+ win_get_peer,
+ win_get_fd};
+
+grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
+ grpc_channel_args* channel_args,
+ const char* peer_string) {
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL);
if (channel_args != NULL) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
resource_quota = grpc_resource_quota_ref_internal(
- channel_args->args[i].value.pointer.p);
+ (grpc_resource_quota*)channel_args->args[i].value.pointer.p);
}
}
}
- grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
+ grpc_tcp* tcp = (grpc_tcp*)gpr_malloc(sizeof(grpc_tcp));
memset(tcp, 0, sizeof(grpc_tcp));
tcp->base.vtable = &vtable;
tcp->socket = socket;
@@ -441,6 +445,7 @@ grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket,
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
/* Tell network status tracking code about the new endpoint */
grpc_network_status_register_endpoint(&tcp->base);
+ grpc_resource_quota_unref_internal(resource_quota);
return &tcp->base;
}
diff --git a/src/core/lib/iomgr/tcp_windows.h b/src/core/lib/iomgr/tcp_windows.h
index 864184ce84..8578a358ea 100644
--- a/src/core/lib/iomgr/tcp_windows.h
+++ b/src/core/lib/iomgr/tcp_windows.h
@@ -29,16 +29,21 @@
otherwise specified.
*/
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_WINSOCK_SOCKET
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/socket_windows.h"
/* Create a tcp endpoint given a winsock handle.
* Takes ownership of the handle.
*/
-grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket,
- grpc_channel_args *channel_args,
- char *peer_string);
+grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
+ grpc_channel_args* channel_args,
+ const char* peer_string);
+
+grpc_error* grpc_tcp_prepare_socket(SOCKET sock);
-grpc_error *grpc_tcp_prepare_socket(SOCKET sock);
+#endif
#endif /* GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H */
diff --git a/src/core/lib/iomgr/time_averaged_stats.c b/src/core/lib/iomgr/time_averaged_stats.cc
index 3bddec04dd..3bddec04dd 100644
--- a/src/core/lib/iomgr/time_averaged_stats.c
+++ b/src/core/lib/iomgr/time_averaged_stats.cc
diff --git a/src/core/lib/iomgr/timer.h b/src/core/lib/iomgr/timer.h
index ac392f87fe..82049859c5 100644
--- a/src/core/lib/iomgr/timer.h
+++ b/src/core/lib/iomgr/timer.h
@@ -40,13 +40,12 @@ typedef struct grpc_timer grpc_timer;
application code should check the error to determine how it was invoked. The
application callback is also responsible for maintaining information about
when to free up any user-level state. */
-void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
- gpr_timespec deadline, grpc_closure *closure,
- gpr_timespec now);
+void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
+ grpc_closure* closure);
/* Initialize *timer without setting it. This can later be passed through
the regular init or cancel */
-void grpc_timer_init_unset(grpc_timer *timer);
+void grpc_timer_init_unset(grpc_timer* timer);
/* Note that there is no timer destroy function. This is because the
timer is a one-time occurrence with a guarantee that the callback will
@@ -74,7 +73,7 @@ void grpc_timer_init_unset(grpc_timer *timer);
matches this aim.
Requires: cancel() must happen after init() on a given timer */
-void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer);
+void grpc_timer_cancel(grpc_timer* timer);
/* iomgr internal api for dealing with timers */
@@ -91,10 +90,9 @@ typedef enum {
*next is never guaranteed to be updated on any given execution; however,
with high probability at least one thread in the system will see an update
at any time slice. */
-grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx,
- gpr_timespec now, gpr_timespec *next);
-void grpc_timer_list_init(gpr_timespec now);
-void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx);
+grpc_timer_check_result grpc_timer_check(grpc_millis* next);
+void grpc_timer_list_init();
+void grpc_timer_list_shutdown();
/* Consume a kick issued by grpc_kick_poller */
void grpc_timer_consume_kick(void);
diff --git a/src/core/lib/iomgr/timer_generic.c b/src/core/lib/iomgr/timer_generic.cc
index e9a7236c8c..177bdec8df 100644
--- a/src/core/lib/iomgr/timer_generic.c
+++ b/src/core/lib/iomgr/timer_generic.cc
@@ -18,32 +18,32 @@
#include "src/core/lib/iomgr/port.h"
+#include <inttypes.h>
+
#ifdef GRPC_TIMER_USE_GENERIC
#include "src/core/lib/iomgr/timer.h"
#include <grpc/support/alloc.h>
+#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/tls.h>
#include <grpc/support/useful.h>
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/iomgr/time_averaged_stats.h"
#include "src/core/lib/iomgr/timer_heap.h"
-#include "src/core/lib/support/spinlock.h"
#define INVALID_HEAP_INDEX 0xffffffffu
-#define LOG2_NUM_SHARDS 5
-#define NUM_SHARDS (1 << LOG2_NUM_SHARDS)
#define ADD_DEADLINE_SCALE 0.33
#define MIN_QUEUE_WINDOW_DURATION 0.01
#define MAX_QUEUE_WINDOW_DURATION 1
-grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false, "timer");
-grpc_tracer_flag grpc_timer_check_trace =
- GRPC_TRACER_INITIALIZER(false, "timer_check");
+grpc_core::TraceFlag grpc_timer_trace(false, "timer");
+grpc_core::TraceFlag grpc_timer_check_trace(false, "timer_check");
/* A "timer shard". Contains a 'heap' and a 'list' of timers. All timers with
* deadlines earlier than 'queue_deadline" cap are maintained in the heap and
@@ -70,14 +70,135 @@ typedef struct {
grpc_timer list;
} timer_shard;
+static size_t g_num_shards;
+
/* Array of timer shards. Whenever a timer (grpc_timer *) is added, its address
* is hashed to select the timer shard to add the timer to */
-static timer_shard g_shards[NUM_SHARDS];
+static timer_shard* g_shards;
/* Maintains a sorted list of timer shards (sorted by their min_deadline, i.e
* the deadline of the next timer in each shard).
* Access to this is protected by g_shared_mutables.mu */
-static timer_shard *g_shard_queue[NUM_SHARDS];
+static timer_shard** g_shard_queue;
+
+#ifndef NDEBUG
+
+/* == Hash table for duplicate timer detection == */
+
+#define NUM_HASH_BUCKETS 1009 /* Prime number close to 1000 */
+
+static gpr_mu g_hash_mu[NUM_HASH_BUCKETS]; /* One mutex per bucket */
+static grpc_timer* g_timer_ht[NUM_HASH_BUCKETS] = {nullptr};
+
+static void init_timer_ht() {
+ for (int i = 0; i < NUM_HASH_BUCKETS; i++) {
+ gpr_mu_init(&g_hash_mu[i]);
+ }
+}
+
+static bool is_in_ht(grpc_timer* t) {
+ size_t i = GPR_HASH_POINTER(t, NUM_HASH_BUCKETS);
+
+ gpr_mu_lock(&g_hash_mu[i]);
+ grpc_timer* p = g_timer_ht[i];
+ while (p != nullptr && p != t) {
+ p = p->hash_table_next;
+ }
+ gpr_mu_unlock(&g_hash_mu[i]);
+
+ return (p == t);
+}
+
+static void add_to_ht(grpc_timer* t) {
+ GPR_ASSERT(!t->hash_table_next);
+ size_t i = GPR_HASH_POINTER(t, NUM_HASH_BUCKETS);
+
+ gpr_mu_lock(&g_hash_mu[i]);
+ grpc_timer* p = g_timer_ht[i];
+ while (p != nullptr && p != t) {
+ p = p->hash_table_next;
+ }
+
+ if (p == t) {
+ grpc_closure* c = t->closure;
+ gpr_log(GPR_ERROR,
+ "** Duplicate timer (%p) being added. Closure: (%p), created at: "
+ "(%s:%d), scheduled at: (%s:%d) **",
+ t, c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated);
+ abort();
+ }
+
+ /* Timer not present in the bucket. Insert at head of the list */
+ t->hash_table_next = g_timer_ht[i];
+ g_timer_ht[i] = t;
+ gpr_mu_unlock(&g_hash_mu[i]);
+}
+
+static void remove_from_ht(grpc_timer* t) {
+ size_t i = GPR_HASH_POINTER(t, NUM_HASH_BUCKETS);
+ bool removed = false;
+
+ gpr_mu_lock(&g_hash_mu[i]);
+ if (g_timer_ht[i] == t) {
+ g_timer_ht[i] = g_timer_ht[i]->hash_table_next;
+ removed = true;
+ } else if (g_timer_ht[i] != nullptr) {
+ grpc_timer* p = g_timer_ht[i];
+ while (p->hash_table_next != nullptr && p->hash_table_next != t) {
+ p = p->hash_table_next;
+ }
+
+ if (p->hash_table_next == t) {
+ p->hash_table_next = t->hash_table_next;
+ removed = true;
+ }
+ }
+ gpr_mu_unlock(&g_hash_mu[i]);
+
+ if (!removed) {
+ grpc_closure* c = t->closure;
+ gpr_log(GPR_ERROR,
+ "** Removing timer (%p) that is not added to hash table. Closure "
+ "(%p), created at: (%s:%d), scheduled at: (%s:%d) **",
+ t, c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated);
+ abort();
+ }
+
+ t->hash_table_next = nullptr;
+}
+
+/* If a timer is added to a timer shard (either heap or a list), it cannot
+ * be pending. A timer is added to hash table only-if it is added to the
+ * timer shard.
+ * Therefore, if timer->pending is false, it cannot be in hash table */
+static void validate_non_pending_timer(grpc_timer* t) {
+ if (!t->pending && is_in_ht(t)) {
+ grpc_closure* c = t->closure;
+ gpr_log(GPR_ERROR,
+ "** gpr_timer_cancel() called on a non-pending timer (%p) which "
+ "is in the hash table. Closure: (%p), created at: (%s:%d), "
+ "scheduled at: (%s:%d) **",
+ t, c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated);
+ abort();
+ }
+}
+
+#define INIT_TIMER_HASH_TABLE() init_timer_ht()
+#define ADD_TO_HASH_TABLE(t) add_to_ht((t))
+#define REMOVE_FROM_HASH_TABLE(t) remove_from_ht((t))
+#define VALIDATE_NON_PENDING_TIMER(t) validate_non_pending_timer((t))
+
+#else
+
+#define INIT_TIMER_HASH_TABLE()
+#define ADD_TO_HASH_TABLE(t)
+#define REMOVE_FROM_HASH_TABLE(t)
+#define VALIDATE_NON_PENDING_TIMER(t)
+
+#endif
/* Thread local variable that stores the deadline of the next timer the thread
* has last-seen. This is an optimization to prevent the thread from checking
@@ -97,9 +218,6 @@ struct shared_mutables {
static struct shared_mutables g_shared_mutables;
-static gpr_clock_type g_clock_type;
-static gpr_timespec g_start_time;
-
static gpr_atm saturating_add(gpr_atm a, gpr_atm b) {
if (a > GPR_ATM_MAX - b) {
return GPR_ATM_MAX;
@@ -107,64 +225,33 @@ static gpr_atm saturating_add(gpr_atm a, gpr_atm b) {
return a + b;
}
-static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx *exec_ctx,
- gpr_atm now,
- gpr_atm *next,
- grpc_error *error);
-
-static gpr_timespec dbl_to_ts(double d) {
- gpr_timespec ts;
- ts.tv_sec = (int64_t)d;
- ts.tv_nsec = (int32_t)(1e9 * (d - (double)ts.tv_sec));
- ts.clock_type = GPR_TIMESPAN;
- return ts;
-}
-
-static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) {
- ts = gpr_time_sub(ts, g_start_time);
- double x = GPR_MS_PER_SEC * (double)ts.tv_sec +
- (double)ts.tv_nsec / GPR_NS_PER_MS +
- (double)(GPR_NS_PER_SEC - 1) / (double)GPR_NS_PER_SEC;
- if (x < 0) return 0;
- if (x > GPR_ATM_MAX) return GPR_ATM_MAX;
- return (gpr_atm)x;
-}
-
-static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) {
- ts = gpr_time_sub(ts, g_start_time);
- double x =
- GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS;
- if (x < 0) return 0;
- if (x > GPR_ATM_MAX) return GPR_ATM_MAX;
- return (gpr_atm)x;
-}
-
-static gpr_timespec atm_to_timespec(gpr_atm x) {
- return gpr_time_add(g_start_time, dbl_to_ts((double)x / 1000.0));
-}
+static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
+ gpr_atm* next,
+ grpc_error* error);
-static gpr_atm compute_min_deadline(timer_shard *shard) {
+static gpr_atm compute_min_deadline(timer_shard* shard) {
return grpc_timer_heap_is_empty(&shard->heap)
? saturating_add(shard->queue_deadline_cap, 1)
: grpc_timer_heap_top(&shard->heap)->deadline;
}
-void grpc_timer_list_init(gpr_timespec now) {
+void grpc_timer_list_init() {
uint32_t i;
+ g_num_shards = GPR_MIN(1, 2 * gpr_cpu_num_cores());
+ g_shards = (timer_shard*)gpr_zalloc(g_num_shards * sizeof(*g_shards));
+ g_shard_queue =
+ (timer_shard**)gpr_zalloc(g_num_shards * sizeof(*g_shard_queue));
+
g_shared_mutables.initialized = true;
g_shared_mutables.checker_mu = GPR_SPINLOCK_INITIALIZER;
gpr_mu_init(&g_shared_mutables.mu);
- g_clock_type = now.clock_type;
- g_start_time = now;
- g_shared_mutables.min_timer = timespec_to_atm_round_down(now);
+ g_shared_mutables.min_timer = grpc_core::ExecCtx::Get()->Now();
gpr_tls_init(&g_last_seen_min_timer);
gpr_tls_set(&g_last_seen_min_timer, 0);
- grpc_register_tracer(&grpc_timer_trace);
- grpc_register_tracer(&grpc_timer_check_trace);
- for (i = 0; i < NUM_SHARDS; i++) {
- timer_shard *shard = &g_shards[i];
+ for (i = 0; i < g_num_shards; i++) {
+ timer_shard* shard = &g_shards[i];
gpr_mu_init(&shard->mu);
grpc_time_averaged_stats_init(&shard->stats, 1.0 / ADD_DEADLINE_SCALE, 0.1,
0.5);
@@ -175,41 +262,41 @@ void grpc_timer_list_init(gpr_timespec now) {
shard->min_deadline = compute_min_deadline(shard);
g_shard_queue[i] = shard;
}
+
+ INIT_TIMER_HASH_TABLE();
}
-void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {
- int i;
+void grpc_timer_list_shutdown() {
+ size_t i;
run_some_expired_timers(
- exec_ctx, GPR_ATM_MAX, NULL,
+ GPR_ATM_MAX, nullptr,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Timer list shutdown"));
- for (i = 0; i < NUM_SHARDS; i++) {
- timer_shard *shard = &g_shards[i];
+ for (i = 0; i < g_num_shards; i++) {
+ timer_shard* shard = &g_shards[i];
gpr_mu_destroy(&shard->mu);
grpc_timer_heap_destroy(&shard->heap);
}
gpr_mu_destroy(&g_shared_mutables.mu);
gpr_tls_destroy(&g_last_seen_min_timer);
+ gpr_free(g_shards);
+ gpr_free(g_shard_queue);
g_shared_mutables.initialized = false;
}
-static double ts_to_dbl(gpr_timespec ts) {
- return (double)ts.tv_sec + 1e-9 * ts.tv_nsec;
-}
-
/* returns true if the first element in the list */
-static void list_join(grpc_timer *head, grpc_timer *timer) {
+static void list_join(grpc_timer* head, grpc_timer* timer) {
timer->next = head;
timer->prev = head->prev;
timer->next->prev = timer->prev->next = timer;
}
-static void list_remove(grpc_timer *timer) {
+static void list_remove(grpc_timer* timer) {
timer->next->prev = timer->prev;
timer->prev->next = timer->next;
}
static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) {
- timer_shard *temp;
+ timer_shard* temp;
temp = g_shard_queue[first_shard_queue_index];
g_shard_queue[first_shard_queue_index] =
g_shard_queue[first_shard_queue_index + 1];
@@ -220,41 +307,41 @@ static void swap_adjacent_shards_in_queue(uint32_t first_shard_queue_index) {
first_shard_queue_index + 1;
}
-static void note_deadline_change(timer_shard *shard) {
+static void note_deadline_change(timer_shard* shard) {
while (shard->shard_queue_index > 0 &&
shard->min_deadline <
g_shard_queue[shard->shard_queue_index - 1]->min_deadline) {
swap_adjacent_shards_in_queue(shard->shard_queue_index - 1);
}
- while (shard->shard_queue_index < NUM_SHARDS - 1 &&
+ while (shard->shard_queue_index < g_num_shards - 1 &&
shard->min_deadline >
g_shard_queue[shard->shard_queue_index + 1]->min_deadline) {
swap_adjacent_shards_in_queue(shard->shard_queue_index);
}
}
-void grpc_timer_init_unset(grpc_timer *timer) { timer->pending = false; }
+void grpc_timer_init_unset(grpc_timer* timer) { timer->pending = false; }
-void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
- gpr_timespec deadline, grpc_closure *closure,
- gpr_timespec now) {
+void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
+ grpc_closure* closure) {
int is_first_timer = 0;
- timer_shard *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)];
- GPR_ASSERT(deadline.clock_type == g_clock_type);
- GPR_ASSERT(now.clock_type == g_clock_type);
+ timer_shard* shard = &g_shards[GPR_HASH_POINTER(timer, g_num_shards)];
timer->closure = closure;
- gpr_atm deadline_atm = timer->deadline = timespec_to_atm_round_up(deadline);
+ timer->deadline = deadline;
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
- gpr_log(GPR_DEBUG, "TIMER %p: SET %" PRId64 ".%09d [%" PRIdPTR
- "] now %" PRId64 ".%09d [%" PRIdPTR "] call %p[%p]",
- timer, deadline.tv_sec, deadline.tv_nsec, deadline_atm, now.tv_sec,
- now.tv_nsec, timespec_to_atm_round_down(now), closure, closure->cb);
+#ifndef NDEBUG
+ timer->hash_table_next = nullptr;
+#endif
+
+ if (grpc_timer_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", timer,
+ deadline, grpc_core::ExecCtx::Get()->Now(), closure, closure->cb);
}
if (!g_shared_mutables.initialized) {
timer->pending = false;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure,
+ GRPC_CLOSURE_SCHED(timer->closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Attempt to create timer before initialization"));
return;
@@ -262,25 +349,30 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
gpr_mu_lock(&shard->mu);
timer->pending = true;
- if (gpr_time_cmp(deadline, now) <= 0) {
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+ if (deadline <= now) {
timer->pending = false;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
gpr_mu_unlock(&shard->mu);
/* early out */
return;
}
grpc_time_averaged_stats_add_sample(&shard->stats,
- ts_to_dbl(gpr_time_sub(deadline, now)));
- if (deadline_atm < shard->queue_deadline_cap) {
+ (double)(deadline - now) / 1000.0);
+
+ ADD_TO_HASH_TABLE(timer);
+
+ if (deadline < shard->queue_deadline_cap) {
is_first_timer = grpc_timer_heap_add(&shard->heap, timer);
} else {
timer->heap_index = INVALID_HEAP_INDEX;
list_join(&shard->list, timer);
}
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
- gpr_log(GPR_DEBUG, " .. add to shard %d with queue_deadline_cap=%" PRIdPTR
- " => is_first_timer=%s",
+ if (grpc_timer_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ " .. add to shard %d with queue_deadline_cap=%" PRIdPTR
+ " => is_first_timer=%s",
(int)(shard - g_shards), shard->queue_deadline_cap,
is_first_timer ? "true" : "false");
}
@@ -299,16 +391,16 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
grpc_timer_check. */
if (is_first_timer) {
gpr_mu_lock(&g_shared_mutables.mu);
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
+ if (grpc_timer_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. old shard min_deadline=%" PRIdPTR,
shard->min_deadline);
}
- if (deadline_atm < shard->min_deadline) {
+ if (deadline < shard->min_deadline) {
gpr_atm old_min_deadline = g_shard_queue[0]->min_deadline;
- shard->min_deadline = deadline_atm;
+ shard->min_deadline = deadline;
note_deadline_change(shard);
- if (shard->shard_queue_index == 0 && deadline_atm < old_min_deadline) {
- gpr_atm_no_barrier_store(&g_shared_mutables.min_timer, deadline_atm);
+ if (shard->shard_queue_index == 0 && deadline < old_min_deadline) {
+ gpr_atm_no_barrier_store(&g_shared_mutables.min_timer, deadline);
grpc_kick_poller();
}
}
@@ -321,26 +413,31 @@ void grpc_timer_consume_kick(void) {
gpr_tls_set(&g_last_seen_min_timer, 0);
}
-void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
+void grpc_timer_cancel(grpc_timer* timer) {
if (!g_shared_mutables.initialized) {
/* must have already been cancelled, also the shard mutex is invalid */
return;
}
- timer_shard *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)];
+ timer_shard* shard = &g_shards[GPR_HASH_POINTER(timer, g_num_shards)];
gpr_mu_lock(&shard->mu);
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
+ if (grpc_timer_trace.enabled()) {
gpr_log(GPR_DEBUG, "TIMER %p: CANCEL pending=%s", timer,
timer->pending ? "true" : "false");
}
+
if (timer->pending) {
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_CANCELLED);
+ REMOVE_FROM_HASH_TABLE(timer);
+
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_CANCELLED);
timer->pending = false;
if (timer->heap_index == INVALID_HEAP_INDEX) {
list_remove(timer);
} else {
grpc_timer_heap_remove(&shard->heap, timer);
}
+ } else {
+ VALIDATE_NON_PENDING_TIMER(timer);
}
gpr_mu_unlock(&shard->mu);
}
@@ -350,7 +447,7 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
'queue_deadline_cap') into into shard->heap.
Returns 'true' if shard->heap has atleast ONE element
REQUIRES: shard->mu locked */
-static int refill_heap(timer_shard *shard, gpr_atm now) {
+static int refill_heap(timer_shard* shard, gpr_atm now) {
/* Compute the new queue window width and bound by the limits: */
double computed_deadline_delta =
grpc_time_averaged_stats_update_average(&shard->stats) *
@@ -365,7 +462,7 @@ static int refill_heap(timer_shard *shard, gpr_atm now) {
saturating_add(GPR_MAX(now, shard->queue_deadline_cap),
(gpr_atm)(deadline_delta * 1000.0));
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. shard[%d]->queue_deadline_cap --> %" PRIdPTR,
(int)(shard - g_shards), shard->queue_deadline_cap);
}
@@ -373,7 +470,7 @@ static int refill_heap(timer_shard *shard, gpr_atm now) {
next = timer->next;
if (timer->deadline < shard->queue_deadline_cap) {
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. add timer with deadline %" PRIdPTR " to heap",
timer->deadline);
}
@@ -387,28 +484,29 @@ static int refill_heap(timer_shard *shard, gpr_atm now) {
/* This pops the next non-cancelled timer with deadline <= now from the
queue, or returns NULL if there isn't one.
REQUIRES: shard->mu locked */
-static grpc_timer *pop_one(timer_shard *shard, gpr_atm now) {
- grpc_timer *timer;
+static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) {
+ grpc_timer* timer;
for (;;) {
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. shard[%d]: heap_empty=%s",
(int)(shard - g_shards),
grpc_timer_heap_is_empty(&shard->heap) ? "true" : "false");
}
if (grpc_timer_heap_is_empty(&shard->heap)) {
- if (now < shard->queue_deadline_cap) return NULL;
- if (!refill_heap(shard, now)) return NULL;
+ if (now < shard->queue_deadline_cap) return nullptr;
+ if (!refill_heap(shard, now)) return nullptr;
}
timer = grpc_timer_heap_top(&shard->heap);
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG,
" .. check top timer deadline=%" PRIdPTR " now=%" PRIdPTR,
timer->deadline, now);
}
- if (timer->deadline > now) return NULL;
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
- gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late", timer,
- now - timer->deadline);
+ if (timer->deadline > now) return nullptr;
+ if (grpc_timer_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late via %s scheduler",
+ timer, now - timer->deadline,
+ timer->closure->scheduler->vtable->name);
}
timer->pending = false;
grpc_timer_heap_pop(&shard->heap);
@@ -417,31 +515,34 @@ static grpc_timer *pop_one(timer_shard *shard, gpr_atm now) {
}
/* REQUIRES: shard->mu unlocked */
-static size_t pop_timers(grpc_exec_ctx *exec_ctx, timer_shard *shard,
- gpr_atm now, gpr_atm *new_min_deadline,
- grpc_error *error) {
+static size_t pop_timers(timer_shard* shard, gpr_atm now,
+ gpr_atm* new_min_deadline, grpc_error* error) {
size_t n = 0;
- grpc_timer *timer;
+ grpc_timer* timer;
gpr_mu_lock(&shard->mu);
while ((timer = pop_one(shard, now))) {
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_REF(error));
+ REMOVE_FROM_HASH_TABLE(timer);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_REF(error));
n++;
}
*new_min_deadline = compute_min_deadline(shard);
gpr_mu_unlock(&shard->mu);
+ if (grpc_timer_check_trace.enabled()) {
+ gpr_log(GPR_DEBUG, " .. shard[%d] popped %" PRIdPTR,
+ (int)(shard - g_shards), n);
+ }
return n;
}
-static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx *exec_ctx,
- gpr_atm now,
- gpr_atm *next,
- grpc_error *error) {
+static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
+ gpr_atm* next,
+ grpc_error* error) {
grpc_timer_check_result result = GRPC_TIMERS_NOT_CHECKED;
gpr_atm min_timer = gpr_atm_no_barrier_load(&g_shared_mutables.min_timer);
gpr_tls_set(&g_last_seen_min_timer, min_timer);
if (now < min_timer) {
- if (next != NULL) *next = GPR_MIN(*next, min_timer);
+ if (next != nullptr) *next = GPR_MIN(*next, min_timer);
return GRPC_TIMERS_CHECKED_AND_EMPTY;
}
@@ -449,7 +550,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx *exec_ctx,
gpr_mu_lock(&g_shared_mutables.mu);
result = GRPC_TIMERS_CHECKED_AND_EMPTY;
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. shard[%d]->min_deadline = %" PRIdPTR,
(int)(g_shard_queue[0] - g_shards),
g_shard_queue[0]->min_deadline);
@@ -462,12 +563,11 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx *exec_ctx,
/* For efficiency, we pop as many available timers as we can from the
shard. This may violate perfect timer deadline ordering, but that
shouldn't be a big deal because we don't make ordering guarantees. */
- if (pop_timers(exec_ctx, g_shard_queue[0], now, &new_min_deadline,
- error) > 0) {
+ if (pop_timers(g_shard_queue[0], now, &new_min_deadline, error) > 0) {
result = GRPC_TIMERS_FIRED;
}
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG,
" .. result --> %d"
", shard[%d]->min_deadline %" PRIdPTR " --> %" PRIdPTR
@@ -500,67 +600,55 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx *exec_ctx,
return result;
}
-grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx,
- gpr_timespec now, gpr_timespec *next) {
+grpc_timer_check_result grpc_timer_check(grpc_millis* next) {
// prelude
- GPR_ASSERT(now.clock_type == g_clock_type);
- gpr_atm now_atm = timespec_to_atm_round_down(now);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
/* fetch from a thread-local first: this avoids contention on a globally
mutable cacheline in the common case */
- gpr_atm min_timer = gpr_tls_get(&g_last_seen_min_timer);
- if (now_atm < min_timer) {
- if (next != NULL) {
- *next =
- atm_to_timespec(GPR_MIN(timespec_to_atm_round_up(*next), min_timer));
+ grpc_millis min_timer = gpr_tls_get(&g_last_seen_min_timer);
+ if (now < min_timer) {
+ if (next != nullptr) {
+ *next = GPR_MIN(*next, min_timer);
}
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG,
- "TIMER CHECK SKIP: now_atm=%" PRIdPTR " min_timer=%" PRIdPTR,
- now_atm, min_timer);
+ "TIMER CHECK SKIP: now=%" PRIdPTR " min_timer=%" PRIdPTR, now,
+ min_timer);
}
return GRPC_TIMERS_CHECKED_AND_EMPTY;
}
- grpc_error *shutdown_error =
- gpr_time_cmp(now, gpr_inf_future(now.clock_type)) != 0
+ grpc_error* shutdown_error =
+ now != GRPC_MILLIS_INF_FUTURE
? GRPC_ERROR_NONE
: GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutting down timer system");
// tracing
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
- char *next_str;
- if (next == NULL) {
+ if (grpc_timer_check_trace.enabled()) {
+ char* next_str;
+ if (next == nullptr) {
next_str = gpr_strdup("NULL");
} else {
- gpr_asprintf(&next_str, "%" PRId64 ".%09d [%" PRIdPTR "]", next->tv_sec,
- next->tv_nsec, timespec_to_atm_round_down(*next));
+ gpr_asprintf(&next_str, "%" PRIdPTR, *next);
}
- gpr_log(GPR_DEBUG, "TIMER CHECK BEGIN: now=%" PRId64 ".%09d [%" PRIdPTR
- "] next=%s tls_min=%" PRIdPTR " glob_min=%" PRIdPTR,
- now.tv_sec, now.tv_nsec, now_atm, next_str,
- gpr_tls_get(&g_last_seen_min_timer),
+ gpr_log(GPR_DEBUG,
+ "TIMER CHECK BEGIN: now=%" PRIdPTR " next=%s tls_min=%" PRIdPTR
+ " glob_min=%" PRIdPTR,
+ now, next_str, gpr_tls_get(&g_last_seen_min_timer),
gpr_atm_no_barrier_load(&g_shared_mutables.min_timer));
gpr_free(next_str);
}
// actual code
- grpc_timer_check_result r;
- gpr_atm next_atm;
- if (next == NULL) {
- r = run_some_expired_timers(exec_ctx, now_atm, NULL, shutdown_error);
- } else {
- next_atm = timespec_to_atm_round_down(*next);
- r = run_some_expired_timers(exec_ctx, now_atm, &next_atm, shutdown_error);
- *next = atm_to_timespec(next_atm);
- }
+ grpc_timer_check_result r =
+ run_some_expired_timers(now, next, shutdown_error);
// tracing
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
- char *next_str;
- if (next == NULL) {
+ if (grpc_timer_check_trace.enabled()) {
+ char* next_str;
+ if (next == nullptr) {
next_str = gpr_strdup("NULL");
} else {
- gpr_asprintf(&next_str, "%" PRId64 ".%09d [%" PRIdPTR "]", next->tv_sec,
- next->tv_nsec, next_atm);
+ gpr_asprintf(&next_str, "%" PRIdPTR, *next);
}
gpr_log(GPR_DEBUG, "TIMER CHECK END: r=%d; next=%s", r, next_str);
gpr_free(next_str);
diff --git a/src/core/lib/iomgr/timer_generic.h b/src/core/lib/iomgr/timer_generic.h
index 72a4ac1f10..190381e904 100644
--- a/src/core/lib/iomgr/timer_generic.h
+++ b/src/core/lib/iomgr/timer_generic.h
@@ -26,9 +26,12 @@ struct grpc_timer {
gpr_atm deadline;
uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */
bool pending;
- struct grpc_timer *next;
- struct grpc_timer *prev;
- grpc_closure *closure;
+ struct grpc_timer* next;
+ struct grpc_timer* prev;
+ grpc_closure* closure;
+#ifndef NDEBUG
+ struct grpc_timer* hash_table_next;
+#endif
};
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H */
diff --git a/src/core/lib/iomgr/timer_heap.c b/src/core/lib/iomgr/timer_heap.cc
index 2648d5da5d..b350452c63 100644
--- a/src/core/lib/iomgr/timer_heap.c
+++ b/src/core/lib/iomgr/timer_heap.cc
@@ -32,7 +32,7 @@
position. This functor is called each time immediately after modifying a
value in the underlying container, with the offset of the modified element as
its argument. */
-static void adjust_upwards(grpc_timer **first, uint32_t i, grpc_timer *t) {
+static void adjust_upwards(grpc_timer** first, uint32_t i, grpc_timer* t) {
while (i > 0) {
uint32_t parent = (uint32_t)(((int)i - 1) / 2);
if (first[parent]->deadline <= t->deadline) break;
@@ -47,17 +47,16 @@ static void adjust_upwards(grpc_timer **first, uint32_t i, grpc_timer *t) {
/* Adjusts a heap so as to move a hole at position i farther away from the root,
until a suitable position is found for element t. Then, copies t into that
position. */
-static void adjust_downwards(grpc_timer **first, uint32_t i, uint32_t length,
- grpc_timer *t) {
+static void adjust_downwards(grpc_timer** first, uint32_t i, uint32_t length,
+ grpc_timer* t) {
for (;;) {
uint32_t left_child = 1u + 2u * i;
if (left_child >= length) break;
uint32_t right_child = left_child + 1;
- uint32_t next_i =
- right_child < length &&
- first[left_child]->deadline > first[right_child]->deadline
- ? right_child
- : left_child;
+ uint32_t next_i = right_child < length && first[left_child]->deadline >
+ first[right_child]->deadline
+ ? right_child
+ : left_child;
if (t->deadline <= first[next_i]->deadline) break;
first[i] = first[next_i];
first[i]->heap_index = i;
@@ -70,16 +69,16 @@ static void adjust_downwards(grpc_timer **first, uint32_t i, uint32_t length,
#define SHRINK_MIN_ELEMS 8
#define SHRINK_FULLNESS_FACTOR 2
-static void maybe_shrink(grpc_timer_heap *heap) {
+static void maybe_shrink(grpc_timer_heap* heap) {
if (heap->timer_count >= 8 &&
heap->timer_count <= heap->timer_capacity / SHRINK_FULLNESS_FACTOR / 2) {
heap->timer_capacity = heap->timer_count * SHRINK_FULLNESS_FACTOR;
- heap->timers = (grpc_timer **)gpr_realloc(
- heap->timers, heap->timer_capacity * sizeof(grpc_timer *));
+ heap->timers = (grpc_timer**)gpr_realloc(
+ heap->timers, heap->timer_capacity * sizeof(grpc_timer*));
}
}
-static void note_changed_priority(grpc_timer_heap *heap, grpc_timer *timer) {
+static void note_changed_priority(grpc_timer_heap* heap, grpc_timer* timer) {
uint32_t i = timer->heap_index;
uint32_t parent = (uint32_t)(((int)i - 1) / 2);
if (heap->timers[parent]->deadline > timer->deadline) {
@@ -89,18 +88,18 @@ static void note_changed_priority(grpc_timer_heap *heap, grpc_timer *timer) {
}
}
-void grpc_timer_heap_init(grpc_timer_heap *heap) {
+void grpc_timer_heap_init(grpc_timer_heap* heap) {
memset(heap, 0, sizeof(*heap));
}
-void grpc_timer_heap_destroy(grpc_timer_heap *heap) { gpr_free(heap->timers); }
+void grpc_timer_heap_destroy(grpc_timer_heap* heap) { gpr_free(heap->timers); }
-int grpc_timer_heap_add(grpc_timer_heap *heap, grpc_timer *timer) {
+int grpc_timer_heap_add(grpc_timer_heap* heap, grpc_timer* timer) {
if (heap->timer_count == heap->timer_capacity) {
heap->timer_capacity =
GPR_MAX(heap->timer_capacity + 1, heap->timer_capacity * 3 / 2);
- heap->timers = (grpc_timer **)gpr_realloc(
- heap->timers, heap->timer_capacity * sizeof(grpc_timer *));
+ heap->timers = (grpc_timer**)gpr_realloc(
+ heap->timers, heap->timer_capacity * sizeof(grpc_timer*));
}
timer->heap_index = heap->timer_count;
adjust_upwards(heap->timers, heap->timer_count, timer);
@@ -108,7 +107,7 @@ int grpc_timer_heap_add(grpc_timer_heap *heap, grpc_timer *timer) {
return timer->heap_index == 0;
}
-void grpc_timer_heap_remove(grpc_timer_heap *heap, grpc_timer *timer) {
+void grpc_timer_heap_remove(grpc_timer_heap* heap, grpc_timer* timer) {
uint32_t i = timer->heap_index;
if (i == heap->timer_count - 1) {
heap->timer_count--;
@@ -122,15 +121,15 @@ void grpc_timer_heap_remove(grpc_timer_heap *heap, grpc_timer *timer) {
note_changed_priority(heap, heap->timers[i]);
}
-int grpc_timer_heap_is_empty(grpc_timer_heap *heap) {
+int grpc_timer_heap_is_empty(grpc_timer_heap* heap) {
return heap->timer_count == 0;
}
-grpc_timer *grpc_timer_heap_top(grpc_timer_heap *heap) {
+grpc_timer* grpc_timer_heap_top(grpc_timer_heap* heap) {
return heap->timers[0];
}
-void grpc_timer_heap_pop(grpc_timer_heap *heap) {
+void grpc_timer_heap_pop(grpc_timer_heap* heap) {
grpc_timer_heap_remove(heap, grpc_timer_heap_top(heap));
}
diff --git a/src/core/lib/iomgr/timer_heap.h b/src/core/lib/iomgr/timer_heap.h
index 0d64199ab9..436eef55a6 100644
--- a/src/core/lib/iomgr/timer_heap.h
+++ b/src/core/lib/iomgr/timer_heap.h
@@ -22,21 +22,21 @@
#include "src/core/lib/iomgr/timer.h"
typedef struct {
- grpc_timer **timers;
+ grpc_timer** timers;
uint32_t timer_count;
uint32_t timer_capacity;
} grpc_timer_heap;
/* return 1 if the new timer is the first timer in the heap */
-int grpc_timer_heap_add(grpc_timer_heap *heap, grpc_timer *timer);
+int grpc_timer_heap_add(grpc_timer_heap* heap, grpc_timer* timer);
-void grpc_timer_heap_init(grpc_timer_heap *heap);
-void grpc_timer_heap_destroy(grpc_timer_heap *heap);
+void grpc_timer_heap_init(grpc_timer_heap* heap);
+void grpc_timer_heap_destroy(grpc_timer_heap* heap);
-void grpc_timer_heap_remove(grpc_timer_heap *heap, grpc_timer *timer);
-grpc_timer *grpc_timer_heap_top(grpc_timer_heap *heap);
-void grpc_timer_heap_pop(grpc_timer_heap *heap);
+void grpc_timer_heap_remove(grpc_timer_heap* heap, grpc_timer* timer);
+grpc_timer* grpc_timer_heap_top(grpc_timer_heap* heap);
+void grpc_timer_heap_pop(grpc_timer_heap* heap);
-int grpc_timer_heap_is_empty(grpc_timer_heap *heap);
+int grpc_timer_heap_is_empty(grpc_timer_heap* heap);
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */
diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.cc
index 04ca44563d..7fb068f10f 100644
--- a/src/core/lib/iomgr/timer_manager.c
+++ b/src/core/lib/iomgr/timer_manager.cc
@@ -20,17 +20,20 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/port_platform.h>
#include <grpc/support/thd.h>
+#include <inttypes.h>
+
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/timer.h"
typedef struct completed_thread {
gpr_thd_id t;
- struct completed_thread *next;
+ struct completed_thread* next;
} completed_thread;
-extern grpc_tracer_flag grpc_timer_check_trace;
+extern grpc_core::TraceFlag grpc_timer_check_trace;
// global mutex
static gpr_mu g_mu;
@@ -45,27 +48,27 @@ static int g_thread_count;
// number of threads sitting around waiting
static int g_waiter_count;
// linked list of threads that have completed (and need joining)
-static completed_thread *g_completed_threads;
+static completed_thread* g_completed_threads;
// was the manager kicked by the timer system
static bool g_kicked;
// is there a thread waiting until the next timer should fire?
static bool g_has_timed_waiter;
// the deadline of the current timed waiter thread (only relevant if
// g_has_timed_waiter is true)
-static gpr_timespec g_timed_waiter_deadline;
+static grpc_millis g_timed_waiter_deadline;
// generation counter to track which thread is waiting for the next timer
static uint64_t g_timed_waiter_generation;
-static void timer_thread(void *completed_thread_ptr);
+static void timer_thread(void* completed_thread_ptr);
static void gc_completed_threads(void) {
- if (g_completed_threads != NULL) {
- completed_thread *to_gc = g_completed_threads;
- g_completed_threads = NULL;
+ if (g_completed_threads != nullptr) {
+ completed_thread* to_gc = g_completed_threads;
+ g_completed_threads = nullptr;
gpr_mu_unlock(&g_mu);
- while (to_gc != NULL) {
+ while (to_gc != nullptr) {
gpr_thd_join(to_gc->t);
- completed_thread *next = to_gc->next;
+ completed_thread* next = to_gc->next;
gpr_free(to_gc);
to_gc = next;
}
@@ -78,31 +81,29 @@ static void start_timer_thread_and_unlock(void) {
++g_waiter_count;
++g_thread_count;
gpr_mu_unlock(&g_mu);
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "Spawn timer thread");
}
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- completed_thread *ct = (completed_thread *)gpr_malloc(sizeof(*ct));
+ completed_thread* ct = (completed_thread*)gpr_malloc(sizeof(*ct));
// The call to gpr_thd_new() has to be under the same lock used by
// gc_completed_threads(), particularly due to ct->t, which is written here
// (internally by gpr_thd_new) and read there. Otherwise it's possible for ct
// to leak through g_completed_threads and be freed in gc_completed_threads()
// before "&ct->t" is written to, causing a use-after-free.
gpr_mu_lock(&g_mu);
- gpr_thd_new(&ct->t, timer_thread, ct, &opt);
+ gpr_thd_new(&ct->t, "grpc_global_timer", timer_thread, ct, &opt);
gpr_mu_unlock(&g_mu);
}
void grpc_timer_manager_tick() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_timespec next = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- grpc_timer_check(&exec_ctx, now, &next);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_millis next = GRPC_MILLIS_INF_FUTURE;
+ grpc_timer_check(&next);
}
-static void run_some_timers(grpc_exec_ctx *exec_ctx) {
+static void run_some_timers() {
// if there's something to execute...
gpr_mu_lock(&g_mu);
// remove a waiter from the pool, and start another thread if necessary
@@ -113,7 +114,7 @@ static void run_some_timers(grpc_exec_ctx *exec_ctx) {
// if there's no thread waiting with a timeout, kick an existing
// waiter so that the next deadline is not missed
if (!g_has_timed_waiter) {
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "kick untimed waiter");
}
gpr_cv_signal(&g_cv_wait);
@@ -121,7 +122,10 @@ static void run_some_timers(grpc_exec_ctx *exec_ctx) {
gpr_mu_unlock(&g_mu);
}
// without our lock, flush the exec_ctx
- grpc_exec_ctx_flush(exec_ctx);
+ if (grpc_timer_check_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "flush exec_ctx");
+ }
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&g_mu);
// garbage collect any threads hanging out that are dead
gc_completed_threads();
@@ -133,8 +137,7 @@ static void run_some_timers(grpc_exec_ctx *exec_ctx) {
// wait until 'next' (or forever if there is already a timed waiter in the pool)
// returns true if the thread should continue executing (false if it should
// shutdown)
-static bool wait_until(gpr_timespec next) {
- const gpr_timespec inf_future = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+static bool wait_until(grpc_millis next) {
gpr_mu_lock(&g_mu);
// if we're not threaded anymore, leave
if (!g_threaded) {
@@ -168,32 +171,30 @@ static bool wait_until(gpr_timespec next) {
unless their 'next' is earlier than the current timed-waiter's deadline
(in which case the thread with earlier 'next' takes over as the new timed
waiter) */
- if (gpr_time_cmp(next, inf_future) != 0) {
- if (!g_has_timed_waiter ||
- (gpr_time_cmp(next, g_timed_waiter_deadline) < 0)) {
+ if (next != GRPC_MILLIS_INF_FUTURE) {
+ if (!g_has_timed_waiter || (next < g_timed_waiter_deadline)) {
my_timed_waiter_generation = ++g_timed_waiter_generation;
g_has_timed_waiter = true;
g_timed_waiter_deadline = next;
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
- gpr_timespec wait_time =
- gpr_time_sub(next, gpr_now(GPR_CLOCK_MONOTONIC));
- gpr_log(GPR_DEBUG, "sleep for a %" PRId64 ".%09d seconds",
- wait_time.tv_sec, wait_time.tv_nsec);
+ if (grpc_timer_check_trace.enabled()) {
+ grpc_millis wait_time = next - grpc_core::ExecCtx::Get()->Now();
+ gpr_log(GPR_DEBUG, "sleep for a %" PRIdPTR " milliseconds",
+ wait_time);
}
} else { // g_timed_waiter == true && next >= g_timed_waiter_deadline
- next = inf_future;
+ next = GRPC_MILLIS_INF_FUTURE;
}
}
- if (GRPC_TRACER_ON(grpc_timer_check_trace) &&
- gpr_time_cmp(next, inf_future) == 0) {
+ if (grpc_timer_check_trace.enabled() && next == GRPC_MILLIS_INF_FUTURE) {
gpr_log(GPR_DEBUG, "sleep until kicked");
}
- gpr_cv_wait(&g_cv_wait, &g_mu, next);
+ gpr_cv_wait(&g_cv_wait, &g_mu,
+ grpc_millis_to_timespec(next, GPR_CLOCK_MONOTONIC));
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d",
my_timed_waiter_generation == g_timed_waiter_generation,
g_kicked);
@@ -203,7 +204,7 @@ static bool wait_until(gpr_timespec next) {
// there's work to do after checking timers (code above)
if (my_timed_waiter_generation == g_timed_waiter_generation) {
g_has_timed_waiter = false;
- g_timed_waiter_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ g_timed_waiter_deadline = GRPC_MILLIS_INF_FUTURE;
}
}
@@ -218,15 +219,15 @@ static bool wait_until(gpr_timespec next) {
return true;
}
-static void timer_main_loop(grpc_exec_ctx *exec_ctx) {
- const gpr_timespec inf_future = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+static void timer_main_loop() {
for (;;) {
- gpr_timespec next = inf_future;
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
+ grpc_millis next = GRPC_MILLIS_INF_FUTURE;
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+
// check timer state, updates next to the next time to run a check
- switch (grpc_timer_check(exec_ctx, now, &next)) {
+ switch (grpc_timer_check(&next)) {
case GRPC_TIMERS_FIRED:
- run_some_timers(exec_ctx);
+ run_some_timers();
break;
case GRPC_TIMERS_NOT_CHECKED:
/* This case only happens under contention, meaning more than one timer
@@ -238,10 +239,10 @@ static void timer_main_loop(grpc_exec_ctx *exec_ctx) {
Consequently, we can just sleep forever here and be happy at some
saved wakeup cycles. */
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "timers not checked: expect another thread to");
}
- next = inf_future;
+ next = GRPC_MILLIS_INF_FUTURE;
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
if (!wait_until(next)) {
@@ -252,7 +253,7 @@ static void timer_main_loop(grpc_exec_ctx *exec_ctx) {
}
}
-static void timer_thread_cleanup(completed_thread *ct) {
+static void timer_thread_cleanup(completed_thread* ct) {
gpr_mu_lock(&g_mu);
// terminate the thread: drop the waiter count, thread count, and let whomever
// stopped the threading stuff know that we're done
@@ -264,19 +265,18 @@ static void timer_thread_cleanup(completed_thread *ct) {
ct->next = g_completed_threads;
g_completed_threads = ct;
gpr_mu_unlock(&g_mu);
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "End timer thread");
}
}
-static void timer_thread(void *completed_thread_ptr) {
+static void timer_thread(void* completed_thread_ptr) {
// this threads exec_ctx: we try to run things through to completion here
// since it's easy to spin up new threads
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
- timer_main_loop(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
- timer_thread_cleanup((completed_thread *)completed_thread_ptr);
+ grpc_core::ExecCtx exec_ctx(0);
+ timer_main_loop();
+
+ timer_thread_cleanup((completed_thread*)completed_thread_ptr);
}
static void start_threads(void) {
@@ -297,28 +297,28 @@ void grpc_timer_manager_init(void) {
g_threaded = false;
g_thread_count = 0;
g_waiter_count = 0;
- g_completed_threads = NULL;
+ g_completed_threads = nullptr;
g_has_timed_waiter = false;
- g_timed_waiter_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ g_timed_waiter_deadline = GRPC_MILLIS_INF_FUTURE;
start_threads();
}
static void stop_threads(void) {
gpr_mu_lock(&g_mu);
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "stop timer threads: threaded=%d", g_threaded);
}
if (g_threaded) {
g_threaded = false;
gpr_cv_broadcast(&g_cv_wait);
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count);
}
while (g_thread_count > 0) {
- gpr_cv_wait(&g_cv_shutdown, &g_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ gpr_cv_wait(&g_cv_shutdown, &g_mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count);
}
gc_completed_threads();
@@ -347,7 +347,7 @@ void grpc_kick_poller(void) {
gpr_mu_lock(&g_mu);
g_kicked = true;
g_has_timed_waiter = false;
- g_timed_waiter_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ g_timed_waiter_deadline = GRPC_MILLIS_INF_FUTURE;
++g_timed_waiter_generation;
gpr_cv_signal(&g_cv_wait);
gpr_mu_unlock(&g_mu);
diff --git a/src/core/lib/iomgr/timer_uv.c b/src/core/lib/iomgr/timer_uv.cc
index adced41f53..5d238da089 100644
--- a/src/core/lib/iomgr/timer_uv.c
+++ b/src/core/lib/iomgr/timer_uv.cc
@@ -29,44 +29,41 @@
#include <uv.h>
-grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false, "timer");
-grpc_tracer_flag grpc_timer_check_trace =
- GRPC_TRACER_INITIALIZER(false, "timer_check");
+grpc_core::TraceFlag grpc_timer_trace(false, "timer");
+grpc_core::TraceFlag grpc_timer_check_trace(false, "timer_check");
-static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); }
+static void timer_close_callback(uv_handle_t* handle) { gpr_free(handle); }
-static void stop_uv_timer(uv_timer_t *handle) {
+static void stop_uv_timer(uv_timer_t* handle) {
uv_timer_stop(handle);
- uv_unref((uv_handle_t *)handle);
- uv_close((uv_handle_t *)handle, timer_close_callback);
+ uv_unref((uv_handle_t*)handle);
+ uv_close((uv_handle_t*)handle, timer_close_callback);
}
-void run_expired_timer(uv_timer_t *handle) {
- grpc_timer *timer = (grpc_timer *)handle->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+void run_expired_timer(uv_timer_t* handle) {
+ grpc_timer* timer = (grpc_timer*)handle->data;
+ grpc_core::ExecCtx exec_ctx;
GRPC_UV_ASSERT_SAME_THREAD();
GPR_ASSERT(timer->pending);
timer->pending = 0;
- GRPC_CLOSURE_SCHED(&exec_ctx, timer->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
stop_uv_timer(handle);
- grpc_exec_ctx_finish(&exec_ctx);
}
-void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
- gpr_timespec deadline, grpc_closure *closure,
- gpr_timespec now) {
+void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
+ grpc_closure* closure) {
uint64_t timeout;
- uv_timer_t *uv_timer;
+ uv_timer_t* uv_timer;
GRPC_UV_ASSERT_SAME_THREAD();
timer->closure = closure;
- if (gpr_time_cmp(deadline, now) <= 0) {
+ if (deadline <= grpc_core::ExecCtx::Get()->Now()) {
timer->pending = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
return;
}
timer->pending = 1;
- timeout = (uint64_t)gpr_time_to_millis(gpr_time_sub(deadline, now));
- uv_timer = gpr_malloc(sizeof(uv_timer_t));
+ timeout = (uint64_t)(deadline - grpc_core::ExecCtx::Get()->Now());
+ uv_timer = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
uv_timer_init(uv_default_loop(), uv_timer);
uv_timer->data = timer;
timer->uv_timer = uv_timer;
@@ -74,27 +71,26 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
/* We assume that gRPC timers are only used alongside other active gRPC
objects, and that there will therefore always be something else keeping
the uv loop alive whenever there is a timer */
- uv_unref((uv_handle_t *)uv_timer);
+ uv_unref((uv_handle_t*)uv_timer);
}
-void grpc_timer_init_unset(grpc_timer *timer) { timer->pending = 0; }
+void grpc_timer_init_unset(grpc_timer* timer) { timer->pending = 0; }
-void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
+void grpc_timer_cancel(grpc_timer* timer) {
GRPC_UV_ASSERT_SAME_THREAD();
if (timer->pending) {
timer->pending = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_CANCELLED);
- stop_uv_timer((uv_timer_t *)timer->uv_timer);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_CANCELLED);
+ stop_uv_timer((uv_timer_t*)timer->uv_timer);
}
}
-grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx,
- gpr_timespec now, gpr_timespec *next) {
+grpc_timer_check_result grpc_timer_check(grpc_millis* next) {
return GRPC_TIMERS_NOT_CHECKED;
}
-void grpc_timer_list_init(gpr_timespec now) {}
-void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {}
+void grpc_timer_list_init() {}
+void grpc_timer_list_shutdown() {}
void grpc_timer_consume_kick(void) {}
diff --git a/src/core/lib/iomgr/timer_uv.h b/src/core/lib/iomgr/timer_uv.h
index 8a4c17c844..214aaa600a 100644
--- a/src/core/lib/iomgr/timer_uv.h
+++ b/src/core/lib/iomgr/timer_uv.h
@@ -22,10 +22,10 @@
#include "src/core/lib/iomgr/exec_ctx.h"
struct grpc_timer {
- grpc_closure *closure;
+ grpc_closure* closure;
/* This is actually a uv_timer_t*, but we want to keep platform-specific
types out of headers */
- void *uv_timer;
+ void* uv_timer;
int pending;
};
diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.cc
index 00b2e68bb5..27d32c59ae 100644
--- a/src/core/lib/iomgr/udp_server.c
+++ b/src/core/lib/iomgr/udp_server.cc
@@ -21,6 +21,10 @@
#define _GNU_SOURCE
#endif
+#ifndef SO_RXQ_OVFL
+#define SO_RXQ_OVFL 40
+#endif
+
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SOCKET
@@ -45,22 +49,23 @@
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/ev_posix.h"
+#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
-#include "src/core/lib/support/string.h"
/* one listening port */
typedef struct grpc_udp_listener grpc_udp_listener;
struct grpc_udp_listener {
int fd;
- grpc_fd *emfd;
- grpc_udp_server *server;
+ grpc_fd* emfd;
+ grpc_udp_server* server;
grpc_resolved_address addr;
grpc_closure read_closure;
grpc_closure write_closure;
@@ -71,15 +76,24 @@ struct grpc_udp_listener {
grpc_udp_server_read_cb read_cb;
grpc_udp_server_write_cb write_cb;
grpc_udp_server_orphan_cb orphan_cb;
+ grpc_udp_server_start_cb start_cb;
+ // To be scheduled on another thread to actually read/write.
+ grpc_closure do_read_closure;
+ grpc_closure do_write_closure;
+ grpc_closure notify_on_write_closure;
// True if orphan_cb is trigered.
bool orphan_notified;
+ // True if grpc_fd_notify_on_write() is called after on_write() call.
+ bool notify_on_write_armed;
+ // True if fd has been shutdown.
+ bool already_shutdown;
- struct grpc_udp_listener *next;
+ struct grpc_udp_listener* next;
};
struct shutdown_fd_args {
- grpc_fd *fd;
- gpr_mu *server_mu;
+ grpc_udp_listener* sp;
+ gpr_mu* server_mu;
};
/* the overall server */
@@ -87,7 +101,7 @@ struct grpc_udp_server {
gpr_mu mu;
/* factory to use for creating and binding sockets, or NULL */
- grpc_socket_factory *socket_factory;
+ grpc_socket_factory* socket_factory;
/* active port count: how many ports are actually still listening */
size_t active_ports;
@@ -98,34 +112,34 @@ struct grpc_udp_server {
int shutdown;
/* linked list of server ports */
- grpc_udp_listener *head;
- grpc_udp_listener *tail;
+ grpc_udp_listener* head;
+ grpc_udp_listener* tail;
unsigned nports;
/* shutdown callback */
- grpc_closure *shutdown_complete;
+ grpc_closure* shutdown_complete;
/* all pollsets interested in new connections */
- grpc_pollset **pollsets;
+ grpc_pollset** pollsets;
/* number of pollsets in the pollsets array */
size_t pollset_count;
/* opaque object to pass to callbacks */
- void *user_data;
+ void* user_data;
};
-static grpc_socket_factory *get_socket_factory(const grpc_channel_args *args) {
+static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) {
if (args) {
- const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY);
+ const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY);
if (arg) {
GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
- return (grpc_socket_factory *)arg->value.pointer.p;
+ return (grpc_socket_factory*)arg->value.pointer.p;
}
}
- return NULL;
+ return nullptr;
}
-grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args) {
- grpc_udp_server *s = (grpc_udp_server *)gpr_malloc(sizeof(grpc_udp_server));
+grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
+ grpc_udp_server* s = (grpc_udp_server*)gpr_malloc(sizeof(grpc_udp_server));
gpr_mu_init(&s->mu);
s->socket_factory = get_socket_factory(args);
if (s->socket_factory) {
@@ -134,35 +148,44 @@ grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args) {
s->active_ports = 0;
s->destroyed_ports = 0;
s->shutdown = 0;
- s->head = NULL;
- s->tail = NULL;
+ s->head = nullptr;
+ s->tail = nullptr;
s->nports = 0;
return s;
}
-static void shutdown_fd(grpc_exec_ctx *exec_ctx, void *args,
- grpc_error *error) {
- struct shutdown_fd_args *shutdown_args = (struct shutdown_fd_args *)args;
+static void shutdown_fd(void* args, grpc_error* error) {
+ struct shutdown_fd_args* shutdown_args = (struct shutdown_fd_args*)args;
+ grpc_udp_listener* sp = shutdown_args->sp;
+ gpr_log(GPR_DEBUG, "shutdown fd %d", sp->fd);
gpr_mu_lock(shutdown_args->server_mu);
- grpc_fd_shutdown(exec_ctx, shutdown_args->fd, GRPC_ERROR_REF(error));
+ grpc_fd_shutdown(sp->emfd, GRPC_ERROR_REF(error));
+ sp->already_shutdown = true;
+ if (!sp->notify_on_write_armed) {
+ // Re-arm write notification to notify listener with error. This is
+ // necessary to decrement active_ports.
+ sp->notify_on_write_armed = true;
+ grpc_fd_notify_on_write(sp->emfd, &sp->write_closure);
+ }
gpr_mu_unlock(shutdown_args->server_mu);
gpr_free(shutdown_args);
}
-static void dummy_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+static void dummy_cb(void* arg, grpc_error* error) {
// No-op.
}
-static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
- if (s->shutdown_complete != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+static void finish_shutdown(grpc_udp_server* s) {
+ if (s->shutdown_complete != nullptr) {
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
gpr_mu_destroy(&s->mu);
+ gpr_log(GPR_DEBUG, "Destroy all listeners.");
while (s->head) {
- grpc_udp_listener *sp = s->head;
+ grpc_udp_listener* sp = s->head;
s->head = sp->next;
gpr_free(sp);
}
@@ -174,14 +197,13 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
gpr_free(s);
}
-static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server,
- grpc_error *error) {
- grpc_udp_server *s = (grpc_udp_server *)server;
+static void destroyed_port(void* server, grpc_error* error) {
+ grpc_udp_server* s = (grpc_udp_server*)server;
gpr_mu_lock(&s->mu);
s->destroyed_ports++;
if (s->destroyed_ports == s->nports) {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
} else {
gpr_mu_unlock(&s->mu);
}
@@ -190,14 +212,14 @@ static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server,
/* called when all listening endpoints have been shutdown, so no further
events will be received on them - at this point it's safe to destroy
things */
-static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
+static void deactivated_all_ports(grpc_udp_server* s) {
/* delete ALL the things */
gpr_mu_lock(&s->mu);
GPR_ASSERT(s->shutdown);
if (s->head) {
- grpc_udp_listener *sp;
+ grpc_udp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
grpc_unlink_if_unix_domain_socket(&sp->addr);
@@ -207,25 +229,24 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
/* Call the orphan_cb to signal that the FD is about to be closed and
* should no longer be used. Because at this point, all listening ports
* have been shutdown already, no need to shutdown again.*/
- GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, dummy_cb, sp->emfd,
+ GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, dummy_cb, sp,
grpc_schedule_on_exec_ctx);
GPR_ASSERT(sp->orphan_cb);
- sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
- sp->server->user_data);
+ gpr_log(GPR_DEBUG, "Orphan fd %d", sp->fd);
+ sp->orphan_cb(sp->emfd, &sp->orphan_fd_closure, sp->server->user_data);
}
- grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
+ grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr,
false /* already_closed */, "udp_listener_shutdown");
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
}
}
-void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
- grpc_closure *on_done) {
- grpc_udp_listener *sp;
+void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) {
+ grpc_udp_listener* sp;
gpr_mu_lock(&s->mu);
GPR_ASSERT(!s->shutdown);
@@ -233,42 +254,40 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
s->shutdown_complete = on_done;
+ gpr_log(GPR_DEBUG, "start to destroy udp_server");
/* shutdown all fd's */
if (s->active_ports) {
for (sp = s->head; sp; sp = sp->next) {
GPR_ASSERT(sp->orphan_cb);
- struct shutdown_fd_args *args =
- (struct shutdown_fd_args *)gpr_malloc(sizeof(*args));
- args->fd = sp->emfd;
+ struct shutdown_fd_args* args =
+ (struct shutdown_fd_args*)gpr_malloc(sizeof(*args));
+ args->sp = sp;
args->server_mu = &s->mu;
GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, shutdown_fd, args,
grpc_schedule_on_exec_ctx);
- sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
- sp->server->user_data);
+ sp->orphan_cb(sp->emfd, &sp->orphan_fd_closure, sp->server->user_data);
sp->orphan_notified = true;
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- deactivated_all_ports(exec_ctx, s);
+ deactivated_all_ports(s);
}
}
-static int bind_socket(grpc_socket_factory *socket_factory, int sockfd,
- const grpc_resolved_address *addr) {
- return (socket_factory != NULL)
+static int bind_socket(grpc_socket_factory* socket_factory, int sockfd,
+ const grpc_resolved_address* addr) {
+ return (socket_factory != nullptr)
? grpc_socket_factory_bind(socket_factory, sockfd, addr)
- : bind(sockfd, (struct sockaddr *)addr->addr,
- (socklen_t)addr->len);
+ : bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len);
}
/* Prepare a recently-created socket for listening. */
-static int prepare_socket(grpc_socket_factory *socket_factory, int fd,
- const grpc_resolved_address *addr) {
+static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
+ const grpc_resolved_address* addr, int rcv_buf_size,
+ int snd_buf_size) {
grpc_resolved_address sockname_temp;
- struct sockaddr *addr_ptr = (struct sockaddr *)addr->addr;
- /* Set send/receive socket buffers to 1 MB */
- int buffer_size_bytes = 1024 * 1024;
+ struct sockaddr* addr_ptr = (struct sockaddr*)addr->addr;
if (fd < 0) {
goto error;
@@ -295,7 +314,7 @@ static int prepare_socket(grpc_socket_factory *socket_factory, int fd,
GPR_ASSERT(addr->len < ~(socklen_t)0);
if (bind_socket(socket_factory, fd, addr) < 0) {
- char *addr_str;
+ char* addr_str;
grpc_sockaddr_to_string(&addr_str, addr, 0);
gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str, strerror(errno));
gpr_free(addr_str);
@@ -304,23 +323,30 @@ static int prepare_socket(grpc_socket_factory *socket_factory, int fd,
sockname_temp.len = sizeof(struct sockaddr_storage);
- if (getsockname(fd, (struct sockaddr *)sockname_temp.addr,
- (socklen_t *)&sockname_temp.len) < 0) {
+ if (getsockname(fd, (struct sockaddr*)sockname_temp.addr,
+ (socklen_t*)&sockname_temp.len) < 0) {
goto error;
}
- if (grpc_set_socket_sndbuf(fd, buffer_size_bytes) != GRPC_ERROR_NONE) {
+ if (grpc_set_socket_sndbuf(fd, snd_buf_size) != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Failed to set send buffer size to %d bytes",
- buffer_size_bytes);
+ snd_buf_size);
goto error;
}
- if (grpc_set_socket_rcvbuf(fd, buffer_size_bytes) != GRPC_ERROR_NONE) {
+ if (grpc_set_socket_rcvbuf(fd, rcv_buf_size) != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Failed to set receive buffer size to %d bytes",
- buffer_size_bytes);
+ rcv_buf_size);
goto error;
}
+ {
+ int get_overflow = 1;
+ if (0 != setsockopt(fd, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
+ sizeof(get_overflow))) {
+ gpr_log(GPR_INFO, "Failed to set socket overflow support");
+ }
+ }
return grpc_sockaddr_get_port(&sockname_temp);
error:
@@ -330,73 +356,132 @@ error:
return -1;
}
+static void do_read(void* arg, grpc_error* error) {
+ grpc_udp_listener* sp = reinterpret_cast<grpc_udp_listener*>(arg);
+ GPR_ASSERT(sp->read_cb && error == GRPC_ERROR_NONE);
+ /* TODO: the reason we hold server->mu here is merely to prevent fd
+ * shutdown while we are reading. However, it blocks do_write(). Switch to
+ * read lock if available. */
+ gpr_mu_lock(&sp->server->mu);
+ /* Tell the registered callback that data is available to read. */
+ if (!sp->already_shutdown && sp->read_cb(sp->emfd)) {
+ /* There maybe more packets to read. Schedule read_more_cb_ closure to run
+ * after finishing this event loop. */
+ GRPC_CLOSURE_SCHED(&sp->do_read_closure, GRPC_ERROR_NONE);
+ } else {
+ /* Finish reading all the packets, re-arm the notification event so we can
+ * get another chance to read. Or fd already shutdown, re-arm to get a
+ * notification with shutdown error. */
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
+ }
+ gpr_mu_unlock(&sp->server->mu);
+}
+
/* event manager callback when reads are ready */
-static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_udp_listener *sp = (grpc_udp_listener *)arg;
+static void on_read(void* arg, grpc_error* error) {
+ grpc_udp_listener* sp = (grpc_udp_listener*)arg;
gpr_mu_lock(&sp->server->mu);
if (error != GRPC_ERROR_NONE) {
if (0 == --sp->server->active_ports && sp->server->shutdown) {
gpr_mu_unlock(&sp->server->mu);
- deactivated_all_ports(exec_ctx, sp->server);
+ deactivated_all_ports(sp->server);
} else {
gpr_mu_unlock(&sp->server->mu);
}
return;
}
-
- /* Tell the registered callback that data is available to read. */
+ /* Read once. If there is more data to read, off load the work to another
+ * thread to finish. */
GPR_ASSERT(sp->read_cb);
- sp->read_cb(exec_ctx, sp->emfd, sp->server->user_data);
+ if (sp->read_cb(sp->emfd)) {
+ /* There maybe more packets to read. Schedule read_more_cb_ closure to run
+ * after finishing this event loop. */
+ GRPC_CLOSURE_INIT(&sp->do_read_closure, do_read, arg,
+ grpc_executor_scheduler(GRPC_EXECUTOR_LONG));
+ GRPC_CLOSURE_SCHED(&sp->do_read_closure, GRPC_ERROR_NONE);
+ } else {
+ /* Finish reading all the packets, re-arm the notification event so we can
+ * get another chance to read. Or fd already shutdown, re-arm to get a
+ * notification with shutdown error. */
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
+ }
+ gpr_mu_unlock(&sp->server->mu);
+}
- /* Re-arm the notification event so we get another chance to read. */
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+// Wrapper of grpc_fd_notify_on_write() with a grpc_closure callback interface.
+void fd_notify_on_write_wrapper(void* arg, grpc_error* error) {
+ grpc_udp_listener* sp = reinterpret_cast<grpc_udp_listener*>(arg);
+ gpr_mu_lock(&sp->server->mu);
+ if (!sp->notify_on_write_armed) {
+ grpc_fd_notify_on_write(sp->emfd, &sp->write_closure);
+ sp->notify_on_write_armed = true;
+ }
gpr_mu_unlock(&sp->server->mu);
}
-static void on_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_udp_listener *sp = (grpc_udp_listener *)arg;
+static void do_write(void* arg, grpc_error* error) {
+ grpc_udp_listener* sp = reinterpret_cast<grpc_udp_listener*>(arg);
+ gpr_mu_lock(&sp->server->mu);
+ if (sp->already_shutdown) {
+ // If fd has been shutdown, don't write any more and re-arm notification.
+ grpc_fd_notify_on_write(sp->emfd, &sp->write_closure);
+ } else {
+ sp->notify_on_write_armed = false;
+ /* Tell the registered callback that the socket is writeable. */
+ GPR_ASSERT(sp->write_cb && error == GRPC_ERROR_NONE);
+ GRPC_CLOSURE_INIT(&sp->notify_on_write_closure, fd_notify_on_write_wrapper,
+ arg, grpc_schedule_on_exec_ctx);
+ sp->write_cb(sp->emfd, sp->server->user_data, &sp->notify_on_write_closure);
+ }
+ gpr_mu_unlock(&sp->server->mu);
+}
+
+static void on_write(void* arg, grpc_error* error) {
+ grpc_udp_listener* sp = (grpc_udp_listener*)arg;
- gpr_mu_lock(&(sp->server->mu));
+ gpr_mu_lock(&sp->server->mu);
if (error != GRPC_ERROR_NONE) {
if (0 == --sp->server->active_ports && sp->server->shutdown) {
gpr_mu_unlock(&sp->server->mu);
- deactivated_all_ports(exec_ctx, sp->server);
+ deactivated_all_ports(sp->server);
} else {
gpr_mu_unlock(&sp->server->mu);
}
return;
}
- /* Tell the registered callback that the socket is writeable. */
- GPR_ASSERT(sp->write_cb);
- sp->write_cb(exec_ctx, sp->emfd, sp->server->user_data);
+ /* Schedule actual write in another thread. */
+ GRPC_CLOSURE_INIT(&sp->do_write_closure, do_write, arg,
+ grpc_executor_scheduler(GRPC_EXECUTOR_LONG));
- /* Re-arm the notification event so we get another chance to write. */
- grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure);
+ GRPC_CLOSURE_SCHED(&sp->do_write_closure, GRPC_ERROR_NONE);
gpr_mu_unlock(&sp->server->mu);
}
-static int add_socket_to_server(grpc_udp_server *s, int fd,
- const grpc_resolved_address *addr,
+static int add_socket_to_server(grpc_udp_server* s, int fd,
+ const grpc_resolved_address* addr,
+ int rcv_buf_size, int snd_buf_size,
+ grpc_udp_server_start_cb start_cb,
grpc_udp_server_read_cb read_cb,
grpc_udp_server_write_cb write_cb,
grpc_udp_server_orphan_cb orphan_cb) {
- grpc_udp_listener *sp;
+ grpc_udp_listener* sp;
int port;
- char *addr_str;
- char *name;
+ char* addr_str;
+ char* name;
- port = prepare_socket(s->socket_factory, fd, addr);
+ port =
+ prepare_socket(s->socket_factory, fd, addr, rcv_buf_size, snd_buf_size);
if (port >= 0) {
grpc_sockaddr_to_string(&addr_str, addr, 1);
gpr_asprintf(&name, "udp-server-listener:%s", addr_str);
gpr_free(addr_str);
gpr_mu_lock(&s->mu);
s->nports++;
- sp = (grpc_udp_listener *)gpr_malloc(sizeof(grpc_udp_listener));
- sp->next = NULL;
- if (s->head == NULL) {
+ sp = (grpc_udp_listener*)gpr_malloc(sizeof(grpc_udp_listener));
+ sp->next = nullptr;
+ if (s->head == nullptr) {
s->head = sp;
} else {
s->tail->next = sp;
@@ -409,7 +494,9 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
sp->read_cb = read_cb;
sp->write_cb = write_cb;
sp->orphan_cb = orphan_cb;
+ sp->start_cb = start_cb;
sp->orphan_notified = false;
+ sp->already_shutdown = false;
GPR_ASSERT(sp->emfd);
gpr_mu_unlock(&s->mu);
gpr_free(name);
@@ -418,12 +505,14 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
return port;
}
-int grpc_udp_server_add_port(grpc_udp_server *s,
- const grpc_resolved_address *addr,
+int grpc_udp_server_add_port(grpc_udp_server* s,
+ const grpc_resolved_address* addr,
+ int rcv_buf_size, int snd_buf_size,
+ grpc_udp_server_start_cb start_cb,
grpc_udp_server_read_cb read_cb,
grpc_udp_server_write_cb write_cb,
grpc_udp_server_orphan_cb orphan_cb) {
- grpc_udp_listener *sp;
+ grpc_udp_listener* sp;
int allocated_port1 = -1;
int allocated_port2 = -1;
int fd;
@@ -432,7 +521,7 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
grpc_resolved_address wild4;
grpc_resolved_address wild6;
grpc_resolved_address addr4_copy;
- grpc_resolved_address *allocated_addr = NULL;
+ grpc_resolved_address* allocated_addr = nullptr;
grpc_resolved_address sockname_temp;
int port;
@@ -441,12 +530,12 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
if (grpc_sockaddr_get_port(addr) == 0) {
for (sp = s->head; sp; sp = sp->next) {
sockname_temp.len = sizeof(struct sockaddr_storage);
- if (0 == getsockname(sp->fd, (struct sockaddr *)sockname_temp.addr,
- (socklen_t *)&sockname_temp.len)) {
+ if (0 == getsockname(sp->fd, (struct sockaddr*)sockname_temp.addr,
+ (socklen_t*)&sockname_temp.len)) {
port = grpc_sockaddr_get_port(&sockname_temp);
if (port > 0) {
- allocated_addr = (grpc_resolved_address *)gpr_malloc(
- sizeof(grpc_resolved_address));
+ allocated_addr =
+ (grpc_resolved_address*)gpr_malloc(sizeof(grpc_resolved_address));
memcpy(allocated_addr, addr, sizeof(grpc_resolved_address));
grpc_sockaddr_set_port(allocated_addr, port);
addr = allocated_addr;
@@ -470,7 +559,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
allocated_port1 =
- add_socket_to_server(s, fd, addr, read_cb, write_cb, orphan_cb);
+ add_socket_to_server(s, fd, addr, rcv_buf_size, snd_buf_size, start_cb,
+ read_cb, write_cb, orphan_cb);
if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
goto done;
}
@@ -493,15 +583,16 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
addr = &addr4_copy;
}
allocated_port2 =
- add_socket_to_server(s, fd, addr, read_cb, write_cb, orphan_cb);
+ add_socket_to_server(s, fd, addr, rcv_buf_size, snd_buf_size, start_cb,
+ read_cb, write_cb, orphan_cb);
done:
gpr_free(allocated_addr);
return allocated_port1 >= 0 ? allocated_port1 : allocated_port2;
}
-int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index) {
- grpc_udp_listener *sp;
+int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index) {
+ grpc_udp_listener* sp;
if (port_index >= s->nports) {
return -1;
}
@@ -509,31 +600,34 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index) {
for (sp = s->head; sp && port_index != 0; sp = sp->next) {
--port_index;
}
+ GPR_ASSERT(sp); // if this fails, our check earlier was bogus
return sp->fd;
}
-void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
- grpc_pollset **pollsets, size_t pollset_count,
- void *user_data) {
+void grpc_udp_server_start(grpc_udp_server* s, grpc_pollset** pollsets,
+ size_t pollset_count, void* user_data) {
+ gpr_log(GPR_DEBUG, "grpc_udp_server_start");
size_t i;
gpr_mu_lock(&s->mu);
- grpc_udp_listener *sp;
+ grpc_udp_listener* sp;
GPR_ASSERT(s->active_ports == 0);
s->pollsets = pollsets;
s->user_data = user_data;
sp = s->head;
- while (sp != NULL) {
+ while (sp != nullptr) {
+ sp->start_cb(sp->emfd, sp->server->user_data);
for (i = 0; i < pollset_count; i++) {
- grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
+ grpc_pollset_add_fd(pollsets[i], sp->emfd);
}
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
GRPC_CLOSURE_INIT(&sp->write_closure, on_write, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure);
+ sp->notify_on_write_armed = true;
+ grpc_fd_notify_on_write(sp->emfd, &sp->write_closure);
/* Registered for both read and write callbacks: increment active_ports
* twice to account for this, and delay free-ing of memory until both
diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h
index 881468ea2c..c1aa49f15d 100644
--- a/src/core/lib/iomgr/udp_server.h
+++ b/src/core/lib/iomgr/udp_server.h
@@ -30,29 +30,31 @@ struct grpc_server;
/* Forward decl of grpc_udp_server */
typedef struct grpc_udp_server grpc_udp_server;
-/* Called when data is available to read from the socket. */
-typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
- void *user_data);
+/* Called when grpc server starts to listening on the grpc_fd. */
+typedef void (*grpc_udp_server_start_cb)(grpc_fd* emfd, void* user_data);
-/* Called when the socket is writeable. */
-typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
- void *user_data);
+/* Called when data is available to read from the socket.
+ * Return true if there is more data to read from fd. */
+typedef bool (*grpc_udp_server_read_cb)(grpc_fd* emfd);
+
+/* Called when the socket is writeable. The given closure should be scheduled
+ * when the socket becomes blocked next time. */
+typedef void (*grpc_udp_server_write_cb)(grpc_fd* emfd, void* user_data,
+ grpc_closure* notify_on_write_closure);
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */
-typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx *exec_ctx,
- grpc_fd *emfd,
- grpc_closure *shutdown_fd_callback,
- void *user_data);
+typedef void (*grpc_udp_server_orphan_cb)(grpc_fd* emfd,
+ grpc_closure* shutdown_fd_callback,
+ void* user_data);
/* Create a server, initially not bound to any ports */
-grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args);
+grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args);
/* Start listening to bound ports. user_data is passed to callbacks. */
-void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server,
- grpc_pollset **pollsets, size_t pollset_count,
- void *user_data);
+void grpc_udp_server_start(grpc_udp_server* udp_server, grpc_pollset** pollsets,
+ size_t pollset_count, void* user_data);
-int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index);
+int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index);
/* Add a port to the server, returning port number on success, or negative
on failure.
@@ -64,13 +66,14 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index);
/* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle
all of the multiple socket port matching logic in one place */
-int grpc_udp_server_add_port(grpc_udp_server *s,
- const grpc_resolved_address *addr,
+int grpc_udp_server_add_port(grpc_udp_server* s,
+ const grpc_resolved_address* addr,
+ int rcv_buf_size, int snd_buf_size,
+ grpc_udp_server_start_cb start_cb,
grpc_udp_server_read_cb read_cb,
grpc_udp_server_write_cb write_cb,
grpc_udp_server_orphan_cb orphan_cb);
-void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server,
- grpc_closure *on_done);
+void grpc_udp_server_destroy(grpc_udp_server* server, grpc_closure* on_done);
#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */
diff --git a/src/core/lib/iomgr/unix_sockets_posix.c b/src/core/lib/iomgr/unix_sockets_posix.cc
index 35f898f13a..af862c00dc 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.c
+++ b/src/core/lib/iomgr/unix_sockets_posix.cc
@@ -36,12 +36,13 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
}
-grpc_error *grpc_resolve_unix_domain_address(const char *name,
- grpc_resolved_addresses **addrs) {
- struct sockaddr_un *un;
- if (strlen(name) > GPR_ARRAY_SIZE(((struct sockaddr_un *)0)->sun_path) - 1) {
- char *err_msg;
- grpc_error *err;
+grpc_error* grpc_resolve_unix_domain_address(const char* name,
+ grpc_resolved_addresses** addrs) {
+ struct sockaddr_un* un;
+ if (strlen(name) >
+ GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) - 1) {
+ char* err_msg;
+ grpc_error* err;
gpr_asprintf(&err_msg,
"Path name should not have more than %" PRIuPTR " characters.",
GPR_ARRAY_SIZE(un->sun_path) - 1);
@@ -50,29 +51,29 @@ grpc_error *grpc_resolve_unix_domain_address(const char *name,
return err;
}
*addrs =
- (grpc_resolved_addresses *)gpr_malloc(sizeof(grpc_resolved_addresses));
+ (grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses));
(*addrs)->naddrs = 1;
(*addrs)->addrs =
- (grpc_resolved_address *)gpr_malloc(sizeof(grpc_resolved_address));
- un = (struct sockaddr_un *)(*addrs)->addrs->addr;
+ (grpc_resolved_address*)gpr_malloc(sizeof(grpc_resolved_address));
+ un = (struct sockaddr_un*)(*addrs)->addrs->addr;
un->sun_family = AF_UNIX;
- strcpy(un->sun_path, name);
+ strncpy(un->sun_path, name, sizeof(un->sun_path));
(*addrs)->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return GRPC_ERROR_NONE;
}
-int grpc_is_unix_socket(const grpc_resolved_address *resolved_addr) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+int grpc_is_unix_socket(const grpc_resolved_address* resolved_addr) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
return addr->sa_family == AF_UNIX;
}
void grpc_unlink_if_unix_domain_socket(
- const grpc_resolved_address *resolved_addr) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+ const grpc_resolved_address* resolved_addr) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
if (addr->sa_family != AF_UNIX) {
return;
}
- struct sockaddr_un *un = (struct sockaddr_un *)resolved_addr->addr;
+ struct sockaddr_un* un = (struct sockaddr_un*)resolved_addr->addr;
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
@@ -80,15 +81,15 @@ void grpc_unlink_if_unix_domain_socket(
}
}
-char *grpc_sockaddr_to_uri_unix_if_possible(
- const grpc_resolved_address *resolved_addr) {
- const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
+char* grpc_sockaddr_to_uri_unix_if_possible(
+ const grpc_resolved_address* resolved_addr) {
+ const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr;
if (addr->sa_family != AF_UNIX) {
- return NULL;
+ return nullptr;
}
- char *result;
- gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
+ char* result;
+ gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un*)addr)->sun_path);
return result;
}
diff --git a/src/core/lib/iomgr/unix_sockets_posix.h b/src/core/lib/iomgr/unix_sockets_posix.h
index 25b64b3eec..1c079e6e76 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.h
+++ b/src/core/lib/iomgr/unix_sockets_posix.h
@@ -27,15 +27,15 @@
void grpc_create_socketpair_if_unix(int sv[2]);
-grpc_error *grpc_resolve_unix_domain_address(
- const char *name, grpc_resolved_addresses **addresses);
+grpc_error* grpc_resolve_unix_domain_address(
+ const char* name, grpc_resolved_addresses** addresses);
-int grpc_is_unix_socket(const grpc_resolved_address *resolved_addr);
+int grpc_is_unix_socket(const grpc_resolved_address* resolved_addr);
void grpc_unlink_if_unix_domain_socket(
- const grpc_resolved_address *resolved_addr);
+ const grpc_resolved_address* resolved_addr);
-char *grpc_sockaddr_to_uri_unix_if_possible(
- const grpc_resolved_address *resolved_addr);
+char* grpc_sockaddr_to_uri_unix_if_possible(
+ const grpc_resolved_address* resolved_addr);
#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */
diff --git a/src/core/lib/iomgr/unix_sockets_posix_noop.c b/src/core/lib/iomgr/unix_sockets_posix_noop.cc
index e46b1c003d..fbd9602e1b 100644
--- a/src/core/lib/iomgr/unix_sockets_posix_noop.c
+++ b/src/core/lib/iomgr/unix_sockets_posix_noop.cc
@@ -29,18 +29,18 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
GPR_ASSERT(0);
}
-grpc_error *grpc_resolve_unix_domain_address(
- const char *name, grpc_resolved_addresses **addresses) {
+grpc_error* grpc_resolve_unix_domain_address(
+ const char* name, grpc_resolved_addresses** addresses) {
*addresses = NULL;
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Unix domain sockets are not supported on Windows");
}
-int grpc_is_unix_socket(const grpc_resolved_address *addr) { return false; }
+int grpc_is_unix_socket(const grpc_resolved_address* addr) { return false; }
-void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address *addr) {}
+void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address* addr) {}
-char *grpc_sockaddr_to_uri_unix_if_possible(const grpc_resolved_address *addr) {
+char* grpc_sockaddr_to_uri_unix_if_possible(const grpc_resolved_address* addr) {
return NULL;
}
diff --git a/src/core/lib/iomgr/wakeup_fd_cv.c b/src/core/lib/iomgr/wakeup_fd_cv.cc
index 268e0175dd..c785114212 100644
--- a/src/core/lib/iomgr/wakeup_fd_cv.c
+++ b/src/core/lib/iomgr/wakeup_fd_cv.cc
@@ -34,7 +34,7 @@
#define MAX_TABLE_RESIZE 256
-extern cv_fd_table g_cvfds;
+extern grpc_cv_fd_table g_cvfds;
static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) {
unsigned int i, newsize;
@@ -42,11 +42,11 @@ static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) {
gpr_mu_lock(&g_cvfds.mu);
if (!g_cvfds.free_fds) {
newsize = GPR_MIN(g_cvfds.size * 2, g_cvfds.size + MAX_TABLE_RESIZE);
- g_cvfds.cvfds =
- (fd_node*)gpr_realloc(g_cvfds.cvfds, sizeof(fd_node) * newsize);
+ g_cvfds.cvfds = (grpc_fd_node*)gpr_realloc(g_cvfds.cvfds,
+ sizeof(grpc_fd_node) * newsize);
for (i = g_cvfds.size; i < newsize; i++) {
g_cvfds.cvfds[i].is_set = 0;
- g_cvfds.cvfds[i].cvs = NULL;
+ g_cvfds.cvfds[i].cvs = nullptr;
g_cvfds.cvfds[i].next_free = g_cvfds.free_fds;
g_cvfds.free_fds = &g_cvfds.cvfds[i];
}
@@ -55,7 +55,7 @@ static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) {
idx = (int)(g_cvfds.free_fds - g_cvfds.cvfds);
g_cvfds.free_fds = g_cvfds.free_fds->next_free;
- g_cvfds.cvfds[idx].cvs = NULL;
+ g_cvfds.cvfds[idx].cvs = nullptr;
g_cvfds.cvfds[idx].is_set = 0;
fd_info->read_fd = GRPC_IDX_TO_FD(idx);
fd_info->write_fd = -1;
@@ -64,7 +64,7 @@ static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) {
}
static grpc_error* cv_fd_wakeup(grpc_wakeup_fd* fd_info) {
- cv_node* cvn;
+ grpc_cv_node* cvn;
gpr_mu_lock(&g_cvfds.mu);
g_cvfds.cvfds[GRPC_FD_TO_IDX(fd_info->read_fd)].is_set = 1;
cvn = g_cvfds.cvfds[GRPC_FD_TO_IDX(fd_info->read_fd)].cvs;
diff --git a/src/core/lib/iomgr/wakeup_fd_cv.h b/src/core/lib/iomgr/wakeup_fd_cv.h
index dc170ad5b4..399620af76 100644
--- a/src/core/lib/iomgr/wakeup_fd_cv.h
+++ b/src/core/lib/iomgr/wakeup_fd_cv.h
@@ -40,26 +40,28 @@
#define GRPC_FD_TO_IDX(fd) (-(fd)-1)
#define GRPC_IDX_TO_FD(idx) (-(idx)-1)
-typedef struct cv_node {
+typedef struct grpc_cv_node {
gpr_cv* cv;
- struct cv_node* next;
- struct cv_node* prev;
-} cv_node;
+ struct grpc_cv_node* next;
+ struct grpc_cv_node* prev;
+} grpc_cv_node;
-typedef struct fd_node {
+typedef struct grpc_fd_node {
int is_set;
- cv_node* cvs;
- struct fd_node* next_free;
-} fd_node;
+ grpc_cv_node* cvs;
+ struct grpc_fd_node* next_free;
+} grpc_fd_node;
-typedef struct cv_fd_table {
+typedef struct grpc_cv_fd_table {
gpr_mu mu;
gpr_refcount pollcount;
gpr_cv shutdown_cv;
- fd_node* cvfds;
- fd_node* free_fds;
+ grpc_fd_node* cvfds;
+ grpc_fd_node* free_fds;
unsigned int size;
grpc_poll_function_type poll;
-} cv_fd_table;
+} grpc_cv_fd_table;
+
+extern const grpc_wakeup_fd_vtable grpc_cv_wakeup_fd_vtable;
#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_CV_H */
diff --git a/src/core/lib/iomgr/wakeup_fd_eventfd.c b/src/core/lib/iomgr/wakeup_fd_eventfd.cc
index 81cb7ee280..81cb7ee280 100644
--- a/src/core/lib/iomgr/wakeup_fd_eventfd.c
+++ b/src/core/lib/iomgr/wakeup_fd_eventfd.cc
diff --git a/src/core/lib/iomgr/wakeup_fd_nospecial.c b/src/core/lib/iomgr/wakeup_fd_nospecial.cc
index 4c20b8c1b7..c2b525a254 100644
--- a/src/core/lib/iomgr/wakeup_fd_nospecial.c
+++ b/src/core/lib/iomgr/wakeup_fd_nospecial.cc
@@ -31,6 +31,6 @@
static int check_availability_invalid(void) { return 0; }
const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable = {
- NULL, NULL, NULL, NULL, check_availability_invalid};
+ nullptr, nullptr, nullptr, nullptr, check_availability_invalid};
#endif /* GRPC_POSIX_NO_SPECIAL_WAKEUP_FD */
diff --git a/src/core/lib/iomgr/wakeup_fd_pipe.c b/src/core/lib/iomgr/wakeup_fd_pipe.cc
index 4189488f8a..05d69dc9cc 100644
--- a/src/core/lib/iomgr/wakeup_fd_pipe.c
+++ b/src/core/lib/iomgr/wakeup_fd_pipe.cc
@@ -20,6 +20,7 @@
#ifdef GRPC_POSIX_WAKEUP_FD
+#include "src/core/lib/iomgr/wakeup_fd_pipe.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
#include <errno.h>
diff --git a/src/core/lib/iomgr/wakeup_fd_pipe.h b/src/core/lib/iomgr/wakeup_fd_pipe.h
index f860406bda..326a0c4e01 100644
--- a/src/core/lib/iomgr/wakeup_fd_pipe.h
+++ b/src/core/lib/iomgr/wakeup_fd_pipe.h
@@ -21,6 +21,6 @@
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-extern grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable;
+extern const grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable;
#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H */
diff --git a/src/core/lib/iomgr/wakeup_fd_posix.c b/src/core/lib/iomgr/wakeup_fd_posix.cc
index 25daa7d3fb..e8de208a25 100644
--- a/src/core/lib/iomgr/wakeup_fd_posix.c
+++ b/src/core/lib/iomgr/wakeup_fd_posix.cc
@@ -25,8 +25,7 @@
#include "src/core/lib/iomgr/wakeup_fd_pipe.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-extern grpc_wakeup_fd_vtable grpc_cv_wakeup_fd_vtable;
-static const grpc_wakeup_fd_vtable *wakeup_fd_vtable = NULL;
+static const grpc_wakeup_fd_vtable* wakeup_fd_vtable = nullptr;
int grpc_allow_specialized_wakeup_fd = 1;
int grpc_allow_pipe_wakeup_fd = 1;
@@ -46,7 +45,7 @@ void grpc_wakeup_fd_global_init(void) {
}
}
-void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = NULL; }
+void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = nullptr; }
int grpc_has_wakeup_fd(void) { return has_real_wakeup_fd; }
@@ -54,28 +53,28 @@ int grpc_cv_wakeup_fds_enabled(void) { return cv_wakeup_fds_enabled; }
void grpc_enable_cv_wakeup_fds(int enable) { cv_wakeup_fds_enabled = enable; }
-grpc_error *grpc_wakeup_fd_init(grpc_wakeup_fd *fd_info) {
+grpc_error* grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info) {
if (cv_wakeup_fds_enabled) {
return grpc_cv_wakeup_fd_vtable.init(fd_info);
}
return wakeup_fd_vtable->init(fd_info);
}
-grpc_error *grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd *fd_info) {
+grpc_error* grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info) {
if (cv_wakeup_fds_enabled) {
return grpc_cv_wakeup_fd_vtable.consume(fd_info);
}
return wakeup_fd_vtable->consume(fd_info);
}
-grpc_error *grpc_wakeup_fd_wakeup(grpc_wakeup_fd *fd_info) {
+grpc_error* grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info) {
if (cv_wakeup_fds_enabled) {
return grpc_cv_wakeup_fd_vtable.wakeup(fd_info);
}
return wakeup_fd_vtable->wakeup(fd_info);
}
-void grpc_wakeup_fd_destroy(grpc_wakeup_fd *fd_info) {
+void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info) {
if (cv_wakeup_fds_enabled) {
grpc_cv_wakeup_fd_vtable.destroy(fd_info);
} else {
diff --git a/src/core/lib/json/json.c b/src/core/lib/json/json.cc
index 4ad51f662a..4ad51f662a 100644
--- a/src/core/lib/json/json.c
+++ b/src/core/lib/json/json.cc
diff --git a/src/core/lib/json/json_reader.c b/src/core/lib/json/json_reader.cc
index 094a35176c..30039419b1 100644
--- a/src/core/lib/json/json_reader.c
+++ b/src/core/lib/json/json_reader.cc
@@ -24,60 +24,60 @@
#include "src/core/lib/json/json_reader.h"
-static void json_reader_string_clear(grpc_json_reader *reader) {
+static void json_reader_string_clear(grpc_json_reader* reader) {
reader->vtable->string_clear(reader->userdata);
}
-static void json_reader_string_add_char(grpc_json_reader *reader, uint32_t c) {
+static void json_reader_string_add_char(grpc_json_reader* reader, uint32_t c) {
reader->vtable->string_add_char(reader->userdata, c);
}
-static void json_reader_string_add_utf32(grpc_json_reader *reader,
+static void json_reader_string_add_utf32(grpc_json_reader* reader,
uint32_t utf32) {
reader->vtable->string_add_utf32(reader->userdata, utf32);
}
-static uint32_t grpc_json_reader_read_char(grpc_json_reader *reader) {
+static uint32_t grpc_json_reader_read_char(grpc_json_reader* reader) {
return reader->vtable->read_char(reader->userdata);
}
-static void json_reader_container_begins(grpc_json_reader *reader,
+static void json_reader_container_begins(grpc_json_reader* reader,
grpc_json_type type) {
reader->vtable->container_begins(reader->userdata, type);
}
static grpc_json_type grpc_json_reader_container_ends(
- grpc_json_reader *reader) {
+ grpc_json_reader* reader) {
return reader->vtable->container_ends(reader->userdata);
}
-static void json_reader_set_key(grpc_json_reader *reader) {
+static void json_reader_set_key(grpc_json_reader* reader) {
reader->vtable->set_key(reader->userdata);
}
-static void json_reader_set_string(grpc_json_reader *reader) {
+static void json_reader_set_string(grpc_json_reader* reader) {
reader->vtable->set_string(reader->userdata);
}
-static int json_reader_set_number(grpc_json_reader *reader) {
+static int json_reader_set_number(grpc_json_reader* reader) {
return reader->vtable->set_number(reader->userdata);
}
-static void json_reader_set_true(grpc_json_reader *reader) {
+static void json_reader_set_true(grpc_json_reader* reader) {
reader->vtable->set_true(reader->userdata);
}
-static void json_reader_set_false(grpc_json_reader *reader) {
+static void json_reader_set_false(grpc_json_reader* reader) {
reader->vtable->set_false(reader->userdata);
}
-static void json_reader_set_null(grpc_json_reader *reader) {
+static void json_reader_set_null(grpc_json_reader* reader) {
reader->vtable->set_null(reader->userdata);
}
/* Call this function to initialize the reader structure. */
-void grpc_json_reader_init(grpc_json_reader *reader,
- grpc_json_reader_vtable *vtable, void *userdata) {
+void grpc_json_reader_init(grpc_json_reader* reader,
+ grpc_json_reader_vtable* vtable, void* userdata) {
memset(reader, 0, sizeof(*reader));
reader->vtable = vtable;
reader->userdata = userdata;
@@ -85,13 +85,13 @@ void grpc_json_reader_init(grpc_json_reader *reader,
reader->state = GRPC_JSON_STATE_VALUE_BEGIN;
}
-int grpc_json_reader_is_complete(grpc_json_reader *reader) {
+int grpc_json_reader_is_complete(grpc_json_reader* reader) {
return ((reader->depth == 0) &&
((reader->state == GRPC_JSON_STATE_END) ||
(reader->state == GRPC_JSON_STATE_VALUE_END)));
}
-grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
+grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
uint32_t c, success;
/* This state-machine is a strict implementation of ECMA-404 */
@@ -177,8 +177,8 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
if (!success) return GRPC_JSON_PARSE_ERROR;
json_reader_string_clear(reader);
reader->state = GRPC_JSON_STATE_VALUE_END;
- /* The missing break here is intentional. */
- /* fallthrough */
+ /* The missing break here is intentional. */
+ /* fallthrough */
case GRPC_JSON_STATE_VALUE_END:
case GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
diff --git a/src/core/lib/json/json_reader.h b/src/core/lib/json/json_reader.h
index 577fbbbaf6..03185cb2b6 100644
--- a/src/core/lib/json/json_reader.h
+++ b/src/core/lib/json/json_reader.h
@@ -67,27 +67,27 @@ struct grpc_json_reader;
typedef struct grpc_json_reader_vtable {
/* Clears your internal string scratchpad. */
- void (*string_clear)(void *userdata);
+ void (*string_clear)(void* userdata);
/* Adds a char to the string scratchpad. */
- void (*string_add_char)(void *userdata, uint32_t c);
+ void (*string_add_char)(void* userdata, uint32_t c);
/* Adds a utf32 char to the string scratchpad. */
- void (*string_add_utf32)(void *userdata, uint32_t c);
+ void (*string_add_utf32)(void* userdata, uint32_t c);
/* Reads a character from your input. May be utf-8, 16 or 32. */
- uint32_t (*read_char)(void *userdata);
+ uint32_t (*read_char)(void* userdata);
/* Starts a container of type GRPC_JSON_ARRAY or GRPC_JSON_OBJECT. */
- void (*container_begins)(void *userdata, grpc_json_type type);
+ void (*container_begins)(void* userdata, grpc_json_type type);
/* Ends the current container. Must return the type of its parent. */
- grpc_json_type (*container_ends)(void *userdata);
+ grpc_json_type (*container_ends)(void* userdata);
/* Your internal string scratchpad is an object's key. */
- void (*set_key)(void *userdata);
+ void (*set_key)(void* userdata);
/* Your internal string scratchpad is a string value. */
- void (*set_string)(void *userdata);
+ void (*set_string)(void* userdata);
/* Your internal string scratchpad is a numerical value. Return 1 if valid. */
- int (*set_number)(void *userdata);
+ int (*set_number)(void* userdata);
/* Sets the values true, false or null. */
- void (*set_true)(void *userdata);
- void (*set_false)(void *userdata);
- void (*set_null)(void *userdata);
+ void (*set_true)(void* userdata);
+ void (*set_false)(void* userdata);
+ void (*set_null)(void* userdata);
} grpc_json_reader_vtable;
typedef struct grpc_json_reader {
@@ -95,8 +95,8 @@ typedef struct grpc_json_reader {
* The definition is public so you can put it on your stack.
*/
- void *userdata;
- grpc_json_reader_vtable *vtable;
+ void* userdata;
+ grpc_json_reader_vtable* vtable;
int depth;
int in_object;
int in_array;
@@ -129,17 +129,17 @@ typedef enum {
* . GRPC_JSON_INTERNAL_ERROR if the parser somehow ended into an invalid
* internal state.
*/
-grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader);
+grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader);
/* Call this function to initialize the reader structure. */
-void grpc_json_reader_init(grpc_json_reader *reader,
- grpc_json_reader_vtable *vtable, void *userdata);
+void grpc_json_reader_init(grpc_json_reader* reader,
+ grpc_json_reader_vtable* vtable, void* userdata);
/* You may call this from the read_char callback if you don't know where is the
* end of your input stream, and you'd like the json reader to hint you that it
* has completed reading its input, so you can return an EOF to it. Note that
* there might still be trailing whitespaces after that point.
*/
-int grpc_json_reader_is_complete(grpc_json_reader *reader);
+int grpc_json_reader_is_complete(grpc_json_reader* reader);
#endif /* GRPC_CORE_LIB_JSON_JSON_READER_H */
diff --git a/src/core/lib/json/json_string.c b/src/core/lib/json/json_string.cc
index 3178d2d2b4..a339eec81b 100644
--- a/src/core/lib/json/json_string.c
+++ b/src/core/lib/json/json_string.cc
@@ -38,13 +38,13 @@
* input size, and never expands it.
*/
typedef struct {
- grpc_json *top;
- grpc_json *current_container;
- grpc_json *current_value;
- uint8_t *input;
- uint8_t *key;
- uint8_t *string;
- uint8_t *string_ptr;
+ grpc_json* top;
+ grpc_json* current_container;
+ grpc_json* current_value;
+ uint8_t* input;
+ uint8_t* key;
+ uint8_t* string;
+ uint8_t* string_ptr;
size_t remaining_input;
} json_reader_userdata;
@@ -52,7 +52,7 @@ typedef struct {
* The point is that we allocate that string in chunks of 256 bytes.
*/
typedef struct {
- char *output;
+ char* output;
size_t free_space;
size_t string_len;
size_t allocated;
@@ -62,35 +62,35 @@ typedef struct {
* and will enlarge it if necessary. We're only allocating chunks of 256
* bytes at a time (or multiples thereof).
*/
-static void json_writer_output_check(void *userdata, size_t needed) {
- json_writer_userdata *state = (json_writer_userdata *)userdata;
+static void json_writer_output_check(void* userdata, size_t needed) {
+ json_writer_userdata* state = (json_writer_userdata*)userdata;
if (state->free_space >= needed) return;
needed -= state->free_space;
/* Round up by 256 bytes. */
needed = (needed + 0xff) & ~0xffU;
- state->output = (char *)gpr_realloc(state->output, state->allocated + needed);
+ state->output = (char*)gpr_realloc(state->output, state->allocated + needed);
state->free_space += needed;
state->allocated += needed;
}
/* These are needed by the writer's implementation. */
-static void json_writer_output_char(void *userdata, char c) {
- json_writer_userdata *state = (json_writer_userdata *)userdata;
+static void json_writer_output_char(void* userdata, char c) {
+ json_writer_userdata* state = (json_writer_userdata*)userdata;
json_writer_output_check(userdata, 1);
state->output[state->string_len++] = c;
state->free_space--;
}
-static void json_writer_output_string_with_len(void *userdata, const char *str,
+static void json_writer_output_string_with_len(void* userdata, const char* str,
size_t len) {
- json_writer_userdata *state = (json_writer_userdata *)userdata;
+ json_writer_userdata* state = (json_writer_userdata*)userdata;
json_writer_output_check(userdata, len);
memcpy(state->output + state->string_len, str, len);
state->string_len += len;
state->free_space -= len;
}
-static void json_writer_output_string(void *userdata, const char *str) {
+static void json_writer_output_string(void* userdata, const char* str) {
size_t len = strlen(str);
json_writer_output_string_with_len(userdata, str, len);
}
@@ -98,8 +98,8 @@ static void json_writer_output_string(void *userdata, const char *str) {
/* The reader asks us to clear our scratchpad. In our case, we'll simply mark
* the end of the current string, and advance our output pointer.
*/
-static void json_reader_string_clear(void *userdata) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
+static void json_reader_string_clear(void* userdata) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
if (state->string) {
GPR_ASSERT(state->string_ptr < state->input);
*state->string_ptr++ = 0;
@@ -107,8 +107,8 @@ static void json_reader_string_clear(void *userdata) {
state->string = state->string_ptr;
}
-static void json_reader_string_add_char(void *userdata, uint32_t c) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
+static void json_reader_string_add_char(void* userdata, uint32_t c) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
GPR_ASSERT(state->string_ptr < state->input);
GPR_ASSERT(c <= 0xff);
*state->string_ptr++ = (uint8_t)c;
@@ -117,7 +117,7 @@ static void json_reader_string_add_char(void *userdata, uint32_t c) {
/* We are converting a UTF-32 character into UTF-8 here,
* as described by RFC3629.
*/
-static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
+static void json_reader_string_add_utf32(void* userdata, uint32_t c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) {
@@ -147,9 +147,9 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
/* We consider that the input may be a zero-terminated string. So we
* can end up hitting eof before the end of the alleged string length.
*/
-static uint32_t json_reader_read_char(void *userdata) {
+static uint32_t json_reader_read_char(void* userdata) {
uint32_t r;
- json_reader_userdata *state = (json_reader_userdata *)userdata;
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
if (state->remaining_input == 0) return GRPC_JSON_READ_CHAR_EOF;
@@ -167,9 +167,9 @@ static uint32_t json_reader_read_char(void *userdata) {
/* Helper function to create a new grpc_json object and link it into
* our tree-in-progress inside our opaque structure.
*/
-static grpc_json *json_create_and_link(void *userdata, grpc_json_type type) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
- grpc_json *json = grpc_json_create(type);
+static grpc_json* json_create_and_link(void* userdata, grpc_json_type type) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
+ grpc_json* json = grpc_json_create(type);
json->parent = state->current_container;
json->prev = state->current_value;
@@ -183,7 +183,7 @@ static grpc_json *json_create_and_link(void *userdata, grpc_json_type type) {
json->parent->child = json;
}
if (json->parent->type == GRPC_JSON_OBJECT) {
- json->key = (char *)state->key;
+ json->key = (char*)state->key;
}
}
if (!state->top) {
@@ -193,15 +193,15 @@ static grpc_json *json_create_and_link(void *userdata, grpc_json_type type) {
return json;
}
-static void json_reader_container_begins(void *userdata, grpc_json_type type) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
- grpc_json *container;
+static void json_reader_container_begins(void* userdata, grpc_json_type type) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
+ grpc_json* container;
GPR_ASSERT(type == GRPC_JSON_ARRAY || type == GRPC_JSON_OBJECT);
container = json_create_and_link(userdata, type);
state->current_container = container;
- state->current_value = NULL;
+ state->current_value = nullptr;
}
/* It's important to remember that the reader is mostly stateless, so it
@@ -213,9 +213,9 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) {
* Also note that if we're at the top of the tree, and the last container
* ends, we have to return GRPC_JSON_TOP_LEVEL.
*/
-static grpc_json_type json_reader_container_ends(void *userdata) {
+static grpc_json_type json_reader_container_ends(void* userdata) {
grpc_json_type container_type = GRPC_JSON_TOP_LEVEL;
- json_reader_userdata *state = (json_reader_userdata *)userdata;
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
GPR_ASSERT(state->current_container);
@@ -235,36 +235,36 @@ static grpc_json_type json_reader_container_ends(void *userdata) {
* Note that in the set_number case, we're not going to try interpreting it.
* We'll keep it as a string, and leave it to the caller to evaluate it.
*/
-static void json_reader_set_key(void *userdata) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
+static void json_reader_set_key(void* userdata) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
state->key = state->string;
}
-static void json_reader_set_string(void *userdata) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
- grpc_json *json = json_create_and_link(userdata, GRPC_JSON_STRING);
- json->value = (char *)state->string;
+static void json_reader_set_string(void* userdata) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
+ grpc_json* json = json_create_and_link(userdata, GRPC_JSON_STRING);
+ json->value = (char*)state->string;
}
-static int json_reader_set_number(void *userdata) {
- json_reader_userdata *state = (json_reader_userdata *)userdata;
- grpc_json *json = json_create_and_link(userdata, GRPC_JSON_NUMBER);
- json->value = (char *)state->string;
+static int json_reader_set_number(void* userdata) {
+ json_reader_userdata* state = (json_reader_userdata*)userdata;
+ grpc_json* json = json_create_and_link(userdata, GRPC_JSON_NUMBER);
+ json->value = (char*)state->string;
return 1;
}
/* The object types true, false and null are self-sufficient, and don't need
* any more information beside their type.
*/
-static void json_reader_set_true(void *userdata) {
+static void json_reader_set_true(void* userdata) {
json_create_and_link(userdata, GRPC_JSON_TRUE);
}
-static void json_reader_set_false(void *userdata) {
+static void json_reader_set_false(void* userdata) {
json_create_and_link(userdata, GRPC_JSON_FALSE);
}
-static void json_reader_set_null(void *userdata) {
+static void json_reader_set_null(void* userdata) {
json_create_and_link(userdata, GRPC_JSON_NULL);
}
@@ -277,17 +277,17 @@ static grpc_json_reader_vtable reader_vtable = {
json_reader_set_false, json_reader_set_null};
/* And finally, let's define our public API. */
-grpc_json *grpc_json_parse_string_with_len(char *input, size_t size) {
+grpc_json* grpc_json_parse_string_with_len(char* input, size_t size) {
grpc_json_reader reader;
json_reader_userdata state;
- grpc_json *json = NULL;
+ grpc_json* json = nullptr;
grpc_json_reader_status status;
- if (!input) return NULL;
+ if (!input) return nullptr;
- state.top = state.current_container = state.current_value = NULL;
- state.string = state.key = NULL;
- state.string_ptr = state.input = (uint8_t *)input;
+ state.top = state.current_container = state.current_value = nullptr;
+ state.string = state.key = nullptr;
+ state.string_ptr = state.input = (uint8_t*)input;
state.remaining_input = size;
grpc_json_reader_init(&reader, &reader_vtable, &state);
@@ -296,7 +296,7 @@ grpc_json *grpc_json_parse_string_with_len(char *input, size_t size) {
if ((status != GRPC_JSON_DONE) && json) {
grpc_json_destroy(json);
- json = NULL;
+ json = nullptr;
}
return json;
@@ -304,11 +304,11 @@ grpc_json *grpc_json_parse_string_with_len(char *input, size_t size) {
#define UNBOUND_JSON_STRING_LENGTH 0x7fffffff
-grpc_json *grpc_json_parse_string(char *input) {
+grpc_json* grpc_json_parse_string(char* input) {
return grpc_json_parse_string_with_len(input, UNBOUND_JSON_STRING_LENGTH);
}
-static void json_dump_recursive(grpc_json_writer *writer, grpc_json *json,
+static void json_dump_recursive(grpc_json_writer* writer, grpc_json* json,
int in_object) {
while (json) {
if (in_object) grpc_json_writer_object_key(writer, json->key);
@@ -348,11 +348,11 @@ static grpc_json_writer_vtable writer_vtable = {
json_writer_output_char, json_writer_output_string,
json_writer_output_string_with_len};
-char *grpc_json_dump_to_string(grpc_json *json, int indent) {
+char* grpc_json_dump_to_string(grpc_json* json, int indent) {
grpc_json_writer writer;
json_writer_userdata state;
- state.output = NULL;
+ state.output = nullptr;
state.free_space = state.string_len = state.allocated = 0;
grpc_json_writer_init(&writer, indent, &writer_vtable, &state);
diff --git a/src/core/lib/json/json_writer.c b/src/core/lib/json/json_writer.cc
index eab1bff7a6..0b9c7c30ea 100644
--- a/src/core/lib/json/json_writer.c
+++ b/src/core/lib/json/json_writer.cc
@@ -22,22 +22,22 @@
#include "src/core/lib/json/json_writer.h"
-static void json_writer_output_char(grpc_json_writer *writer, char c) {
+static void json_writer_output_char(grpc_json_writer* writer, char c) {
writer->vtable->output_char(writer->userdata, c);
}
-static void json_writer_output_string(grpc_json_writer *writer,
- const char *str) {
+static void json_writer_output_string(grpc_json_writer* writer,
+ const char* str) {
writer->vtable->output_string(writer->userdata, str);
}
-static void json_writer_output_string_with_len(grpc_json_writer *writer,
- const char *str, size_t len) {
+static void json_writer_output_string_with_len(grpc_json_writer* writer,
+ const char* str, size_t len) {
writer->vtable->output_string_with_len(writer->userdata, str, len);
}
-void grpc_json_writer_init(grpc_json_writer *writer, int indent,
- grpc_json_writer_vtable *vtable, void *userdata) {
+void grpc_json_writer_init(grpc_json_writer* writer, int indent,
+ grpc_json_writer_vtable* vtable, void* userdata) {
memset(writer, 0, sizeof(*writer));
writer->container_empty = 1;
writer->indent = indent;
@@ -45,7 +45,7 @@ void grpc_json_writer_init(grpc_json_writer *writer, int indent,
writer->userdata = userdata;
}
-static void json_writer_output_indent(grpc_json_writer *writer) {
+static void json_writer_output_indent(grpc_json_writer* writer) {
static const char spacesstr[] =
" "
" "
@@ -73,7 +73,7 @@ static void json_writer_output_indent(grpc_json_writer *writer) {
writer, spacesstr + sizeof(spacesstr) - 1 - spaces, spaces);
}
-static void json_writer_value_end(grpc_json_writer *writer) {
+static void json_writer_value_end(grpc_json_writer* writer) {
if (writer->container_empty) {
writer->container_empty = 0;
if ((writer->indent == 0) || (writer->depth == 0)) return;
@@ -85,7 +85,7 @@ static void json_writer_value_end(grpc_json_writer *writer) {
}
}
-static void json_writer_escape_utf16(grpc_json_writer *writer, uint16_t utf16) {
+static void json_writer_escape_utf16(grpc_json_writer* writer, uint16_t utf16) {
static const char hex[] = "0123456789abcdef";
json_writer_output_string_with_len(writer, "\\u", 2);
@@ -95,8 +95,8 @@ static void json_writer_escape_utf16(grpc_json_writer *writer, uint16_t utf16) {
json_writer_output_char(writer, hex[(utf16)&0x0f]);
}
-static void json_writer_escape_string(grpc_json_writer *writer,
- const char *string) {
+static void json_writer_escape_string(grpc_json_writer* writer,
+ const char* string) {
json_writer_output_char(writer, '"');
for (;;) {
@@ -190,7 +190,7 @@ static void json_writer_escape_string(grpc_json_writer *writer,
json_writer_output_char(writer, '"');
}
-void grpc_json_writer_container_begins(grpc_json_writer *writer,
+void grpc_json_writer_container_begins(grpc_json_writer* writer,
grpc_json_type type) {
if (!writer->got_key) json_writer_value_end(writer);
json_writer_output_indent(writer);
@@ -200,7 +200,7 @@ void grpc_json_writer_container_begins(grpc_json_writer *writer,
writer->depth++;
}
-void grpc_json_writer_container_ends(grpc_json_writer *writer,
+void grpc_json_writer_container_ends(grpc_json_writer* writer,
grpc_json_type type) {
if (writer->indent && !writer->container_empty)
json_writer_output_char(writer, '\n');
@@ -211,7 +211,7 @@ void grpc_json_writer_container_ends(grpc_json_writer *writer,
writer->got_key = 0;
}
-void grpc_json_writer_object_key(grpc_json_writer *writer, const char *string) {
+void grpc_json_writer_object_key(grpc_json_writer* writer, const char* string) {
json_writer_value_end(writer);
json_writer_output_indent(writer);
json_writer_escape_string(writer, string);
@@ -219,23 +219,23 @@ void grpc_json_writer_object_key(grpc_json_writer *writer, const char *string) {
writer->got_key = 1;
}
-void grpc_json_writer_value_raw(grpc_json_writer *writer, const char *string) {
+void grpc_json_writer_value_raw(grpc_json_writer* writer, const char* string) {
if (!writer->got_key) json_writer_value_end(writer);
json_writer_output_indent(writer);
json_writer_output_string(writer, string);
writer->got_key = 0;
}
-void grpc_json_writer_value_raw_with_len(grpc_json_writer *writer,
- const char *string, size_t len) {
+void grpc_json_writer_value_raw_with_len(grpc_json_writer* writer,
+ const char* string, size_t len) {
if (!writer->got_key) json_writer_value_end(writer);
json_writer_output_indent(writer);
json_writer_output_string_with_len(writer, string, len);
writer->got_key = 0;
}
-void grpc_json_writer_value_string(grpc_json_writer *writer,
- const char *string) {
+void grpc_json_writer_value_string(grpc_json_writer* writer,
+ const char* string) {
if (!writer->got_key) json_writer_value_end(writer);
json_writer_output_indent(writer);
json_writer_escape_string(writer, string);
diff --git a/src/core/lib/json/json_writer.h b/src/core/lib/json/json_writer.h
index 8779039d42..a4f2d4daeb 100644
--- a/src/core/lib/json/json_writer.h
+++ b/src/core/lib/json/json_writer.h
@@ -37,17 +37,17 @@
typedef struct grpc_json_writer_vtable {
/* Adds a character to the output stream. */
- void (*output_char)(void *userdata, char);
+ void (*output_char)(void* userdata, char);
/* Adds a zero-terminated string to the output stream. */
- void (*output_string)(void *userdata, const char *str);
+ void (*output_string)(void* userdata, const char* str);
/* Adds a fixed-length string to the output stream. */
- void (*output_string_with_len)(void *userdata, const char *str, size_t len);
+ void (*output_string_with_len)(void* userdata, const char* str, size_t len);
} grpc_json_writer_vtable;
typedef struct grpc_json_writer {
- void *userdata;
- grpc_json_writer_vtable *vtable;
+ void* userdata;
+ grpc_json_writer_vtable* vtable;
int indent;
int depth;
int container_empty;
@@ -59,24 +59,24 @@ typedef struct grpc_json_writer {
* use indent=0, then the output will not have any newlines either, thus
* emitting a condensed json output.
*/
-void grpc_json_writer_init(grpc_json_writer *writer, int indent,
- grpc_json_writer_vtable *vtable, void *userdata);
+void grpc_json_writer_init(grpc_json_writer* writer, int indent,
+ grpc_json_writer_vtable* vtable, void* userdata);
/* Signals the beginning of a container. */
-void grpc_json_writer_container_begins(grpc_json_writer *writer,
+void grpc_json_writer_container_begins(grpc_json_writer* writer,
grpc_json_type type);
/* Signals the end of a container. */
-void grpc_json_writer_container_ends(grpc_json_writer *writer,
+void grpc_json_writer_container_ends(grpc_json_writer* writer,
grpc_json_type type);
/* Writes down an object key for the next value. */
-void grpc_json_writer_object_key(grpc_json_writer *writer, const char *string);
+void grpc_json_writer_object_key(grpc_json_writer* writer, const char* string);
/* Sets a raw value. Useful for numbers. */
-void grpc_json_writer_value_raw(grpc_json_writer *writer, const char *string);
+void grpc_json_writer_value_raw(grpc_json_writer* writer, const char* string);
/* Sets a raw value with its length. Useful for values like true or false. */
-void grpc_json_writer_value_raw_with_len(grpc_json_writer *writer,
- const char *string, size_t len);
+void grpc_json_writer_value_raw_with_len(grpc_json_writer* writer,
+ const char* string, size_t len);
/* Sets a string value. It'll be escaped, and utf-8 validated. */
-void grpc_json_writer_value_string(grpc_json_writer *writer,
- const char *string);
+void grpc_json_writer_value_string(grpc_json_writer* writer,
+ const char* string);
#endif /* GRPC_CORE_LIB_JSON_JSON_WRITER_H */
diff --git a/src/core/lib/profiling/basic_timers.c b/src/core/lib/profiling/basic_timers.cc
index c7645b74f2..d1c9fd7dec 100644
--- a/src/core/lib/profiling/basic_timers.c
+++ b/src/core/lib/profiling/basic_timers.cc
@@ -18,10 +18,10 @@
#include <grpc/support/port_platform.h>
-#ifdef GRPC_BASIC_PROFILER
-
#include "src/core/lib/profiling/timers.h"
+#ifdef GRPC_BASIC_PROFILER
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -30,14 +30,14 @@
#include <stdio.h>
#include <string.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;
typedef struct gpr_timer_entry {
gpr_timespec tm;
- const char *tagstr;
- const char *file;
+ const char* tagstr;
+ const char* file;
short line;
char type;
uint8_t important;
@@ -48,21 +48,21 @@ typedef struct gpr_timer_entry {
typedef struct gpr_timer_log {
size_t num_entries;
- struct gpr_timer_log *next;
- struct gpr_timer_log *prev;
+ struct gpr_timer_log* next;
+ struct gpr_timer_log* prev;
gpr_timer_entry log[MAX_COUNT];
} gpr_timer_log;
typedef struct gpr_timer_log_list {
- gpr_timer_log *head;
+ gpr_timer_log* head;
/* valid iff head!=NULL */
- gpr_timer_log *tail;
+ gpr_timer_log* tail;
} gpr_timer_log_list;
-static __thread gpr_timer_log *g_thread_log;
+static __thread gpr_timer_log* g_thread_log;
static gpr_once g_once_init = GPR_ONCE_INIT;
-static FILE *output_file;
-static const char *output_filename_or_null = NULL;
+static FILE* output_file;
+static const char* output_filename_or_null = NULL;
static pthread_mutex_t g_mu;
static pthread_cond_t g_cv;
static gpr_timer_log_list g_in_progress_logs;
@@ -73,7 +73,7 @@ static __thread int g_thread_id;
static int g_next_thread_id;
static int g_writing_enabled = 1;
-static const char *output_filename() {
+static const char* output_filename() {
if (output_filename_or_null == NULL) {
output_filename_or_null = gpr_getenv("LATENCY_TRACE");
if (output_filename_or_null == NULL ||
@@ -84,7 +84,7 @@ static const char *output_filename() {
return output_filename_or_null;
}
-static int timer_log_push_back(gpr_timer_log_list *list, gpr_timer_log *log) {
+static int timer_log_push_back(gpr_timer_log_list* list, gpr_timer_log* log) {
if (list->head == NULL) {
list->head = list->tail = log;
log->next = log->prev = NULL;
@@ -98,8 +98,8 @@ static int timer_log_push_back(gpr_timer_log_list *list, gpr_timer_log *log) {
}
}
-static gpr_timer_log *timer_log_pop_front(gpr_timer_log_list *list) {
- gpr_timer_log *out = list->head;
+static gpr_timer_log* timer_log_pop_front(gpr_timer_log_list* list) {
+ gpr_timer_log* out = list->head;
if (out != NULL) {
list->head = out->next;
if (list->head != NULL) {
@@ -111,7 +111,7 @@ static gpr_timer_log *timer_log_pop_front(gpr_timer_log_list *list) {
return out;
}
-static void timer_log_remove(gpr_timer_log_list *list, gpr_timer_log *log) {
+static void timer_log_remove(gpr_timer_log_list* list, gpr_timer_log* log) {
if (log->prev == NULL) {
list->head = log->next;
if (list->head != NULL) {
@@ -130,13 +130,13 @@ static void timer_log_remove(gpr_timer_log_list *list, gpr_timer_log *log) {
}
}
-static void write_log(gpr_timer_log *log) {
+static void write_log(gpr_timer_log* log) {
size_t i;
if (output_file == NULL) {
output_file = fopen(output_filename(), "w");
}
for (i = 0; i < log->num_entries; i++) {
- gpr_timer_entry *entry = &(log->log[i]);
+ gpr_timer_entry* entry = &(log->log[i]);
if (gpr_time_cmp(entry->tm, gpr_time_0(entry->tm.clock_type)) < 0) {
entry->tm = gpr_time_0(entry->tm.clock_type);
}
@@ -149,8 +149,8 @@ static void write_log(gpr_timer_log *log) {
}
}
-static void writing_thread(void *unused) {
- gpr_timer_log *log;
+static void writing_thread(void* unused) {
+ gpr_timer_log* log;
pthread_mutex_lock(&g_mu);
for (;;) {
while ((log = timer_log_pop_front(&g_done_logs)) == NULL && !g_shutdown) {
@@ -169,8 +169,8 @@ static void writing_thread(void *unused) {
}
}
-static void flush_logs(gpr_timer_log_list *list) {
- gpr_timer_log *log;
+static void flush_logs(gpr_timer_log_list* list) {
+ gpr_timer_log* log;
while ((log = timer_log_pop_front(list)) != NULL) {
write_log(log);
free(log);
@@ -196,22 +196,23 @@ static void finish_writing(void) {
}
}
-void gpr_timers_set_log_filename(const char *filename) {
+void gpr_timers_set_log_filename(const char* filename) {
output_filename_or_null = filename;
}
static void init_output() {
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
- GPR_ASSERT(gpr_thd_new(&g_writing_thread, writing_thread, NULL, &options));
+ GPR_ASSERT(gpr_thd_new(&g_writing_thread, "timer_output_thread",
+ writing_thread, NULL, &options));
atexit(finish_writing);
}
static void rotate_log() {
/* Using malloc here, as this code could end up being called by gpr_malloc */
- gpr_timer_log *new = malloc(sizeof(*new));
+ gpr_timer_log* log = static_cast<gpr_timer_log*>(malloc(sizeof(*log)));
gpr_once_init(&g_once_init, init_output);
- new->num_entries = 0;
+ log->num_entries = 0;
pthread_mutex_lock(&g_mu);
if (g_thread_log != NULL) {
timer_log_remove(&g_in_progress_logs, g_thread_log);
@@ -221,14 +222,14 @@ static void rotate_log() {
} else {
g_thread_id = g_next_thread_id++;
}
- timer_log_push_back(&g_in_progress_logs, new);
+ timer_log_push_back(&g_in_progress_logs, log);
pthread_mutex_unlock(&g_mu);
- g_thread_log = new;
+ g_thread_log = log;
}
-static void gpr_timers_log_add(const char *tagstr, marker_type type,
- int important, const char *file, int line) {
- gpr_timer_entry *entry;
+static void gpr_timers_log_add(const char* tagstr, marker_type type,
+ int important, const char* file, int line) {
+ gpr_timer_entry* entry;
if (!g_writing_enabled) {
return;
@@ -250,17 +251,17 @@ static void gpr_timers_log_add(const char *tagstr, marker_type type,
}
/* Latency profiler API implementation. */
-void gpr_timer_add_mark(const char *tagstr, int important, const char *file,
+void gpr_timer_add_mark(const char* tagstr, int important, const char* file,
int line) {
gpr_timers_log_add(tagstr, MARK, important, file, line);
}
-void gpr_timer_begin(const char *tagstr, int important, const char *file,
+void gpr_timer_begin(const char* tagstr, int important, const char* file,
int line) {
gpr_timers_log_add(tagstr, BEGIN, important, file, line);
}
-void gpr_timer_end(const char *tagstr, int important, const char *file,
+void gpr_timer_end(const char* tagstr, int important, const char* file,
int line) {
gpr_timers_log_add(tagstr, END, important, file, line);
}
@@ -277,7 +278,7 @@ void gpr_timers_global_init(void) {}
void gpr_timers_global_destroy(void) {}
-void gpr_timers_set_log_filename(const char *filename) {}
+void gpr_timers_set_log_filename(const char* filename) {}
void gpr_timer_set_enabled(int enabled) {}
#endif /* GRPC_BASIC_PROFILER */
diff --git a/src/core/lib/profiling/stap_timers.c b/src/core/lib/profiling/stap_timers.cc
index c86d74f058..5ee1c4317c 100644
--- a/src/core/lib/profiling/stap_timers.c
+++ b/src/core/lib/profiling/stap_timers.cc
@@ -27,22 +27,22 @@
#include "src/core/lib/profiling/stap_probes.h"
/* Latency profiler API implementation. */
-void gpr_timer_add_mark(int tag, const char *tagstr, void *id, const char *file,
+void gpr_timer_add_mark(int tag, const char* tagstr, void* id, const char* file,
int line) {
_STAP_ADD_MARK(tag);
}
-void gpr_timer_add_important_mark(int tag, const char *tagstr, void *id,
- const char *file, int line) {
+void gpr_timer_add_important_mark(int tag, const char* tagstr, void* id,
+ const char* file, int line) {
_STAP_ADD_IMPORTANT_MARK(tag);
}
-void gpr_timer_begin(int tag, const char *tagstr, void *id, const char *file,
+void gpr_timer_begin(int tag, const char* tagstr, void* id, const char* file,
int line) {
_STAP_TIMING_NS_BEGIN(tag);
}
-void gpr_timer_end(int tag, const char *tagstr, void *id, const char *file,
+void gpr_timer_end(int tag, const char* tagstr, void* id, const char* file,
int line) {
_STAP_TIMING_NS_END(tag);
}
diff --git a/src/core/lib/profiling/timers.h b/src/core/lib/profiling/timers.h
index 7f02b4bf84..9f11f771e6 100644
--- a/src/core/lib/profiling/timers.h
+++ b/src/core/lib/profiling/timers.h
@@ -19,21 +19,17 @@
#ifndef GRPC_CORE_LIB_PROFILING_TIMERS_H
#define GRPC_CORE_LIB_PROFILING_TIMERS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void gpr_timers_global_init(void);
void gpr_timers_global_destroy(void);
-void gpr_timer_add_mark(const char *tagstr, int important, const char *file,
+void gpr_timer_add_mark(const char* tagstr, int important, const char* file,
int line);
-void gpr_timer_begin(const char *tagstr, int important, const char *file,
+void gpr_timer_begin(const char* tagstr, int important, const char* file,
int line);
-void gpr_timer_end(const char *tagstr, int important, const char *file,
+void gpr_timer_end(const char* tagstr, int important, const char* file,
int line);
-void gpr_timers_set_log_filename(const char *filename);
+void gpr_timers_set_log_filename(const char* filename);
void gpr_timer_set_enabled(int enabled);
@@ -84,22 +80,19 @@ void gpr_timer_set_enabled(int enabled);
#endif /* at least one profiler requested. */
-#ifdef __cplusplus
-}
-
#if (defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER) + \
defined(GRPC_CUSTOM_PROFILER))
namespace grpc {
class ProfileScope {
public:
- ProfileScope(const char *desc, bool important, const char *file, int line)
+ ProfileScope(const char* desc, bool important, const char* file, int line)
: desc_(desc) {
gpr_timer_begin(desc_, important ? 1 : 0, file, line);
}
~ProfileScope() { gpr_timer_end(desc_, 0, "n/a", 0); }
private:
- const char *const desc_;
+ const char* const desc_;
};
} // namespace grpc
@@ -111,6 +104,5 @@ class ProfileScope {
do { \
} while (false)
#endif
-#endif
#endif /* GRPC_CORE_LIB_PROFILING_TIMERS_H */
diff --git a/src/core/lib/security/context/security_context.c b/src/core/lib/security/context/security_context.cc
index 8fff2c92c5..63ec42cf86 100644
--- a/src/core/lib/security/context/security_context.c
+++ b/src/core/lib/security/context/security_context.cc
@@ -19,8 +19,8 @@
#include <string.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
@@ -29,84 +29,83 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_auth_context_refcount =
- GRPC_TRACER_INITIALIZER(false, "auth_context_refcount");
-#endif
+grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount(
+ false, "auth_context_refcount");
/* --- grpc_call --- */
-grpc_call_error grpc_call_set_credentials(grpc_call *call,
- grpc_call_credentials *creds) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_client_security_context *ctx = NULL;
+grpc_call_error grpc_call_set_credentials(grpc_call* call,
+ grpc_call_credentials* creds) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_client_security_context* ctx = nullptr;
GRPC_API_TRACE("grpc_call_set_credentials(call=%p, creds=%p)", 2,
(call, creds));
if (!grpc_call_is_client(call)) {
gpr_log(GPR_ERROR, "Method is client-side only.");
return GRPC_CALL_ERROR_NOT_ON_SERVER;
}
- ctx = (grpc_client_security_context *)grpc_call_context_get(
+ ctx = (grpc_client_security_context*)grpc_call_context_get(
call, GRPC_CONTEXT_SECURITY);
- if (ctx == NULL) {
+ if (ctx == nullptr) {
ctx = grpc_client_security_context_create();
ctx->creds = grpc_call_credentials_ref(creds);
grpc_call_context_set(call, GRPC_CONTEXT_SECURITY, ctx,
grpc_client_security_context_destroy);
} else {
- grpc_call_credentials_unref(&exec_ctx, ctx->creds);
+ grpc_call_credentials_unref(ctx->creds);
ctx->creds = grpc_call_credentials_ref(creds);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return GRPC_CALL_OK;
}
-grpc_auth_context *grpc_call_auth_context(grpc_call *call) {
- void *sec_ctx = grpc_call_context_get(call, GRPC_CONTEXT_SECURITY);
+grpc_auth_context* grpc_call_auth_context(grpc_call* call) {
+ void* sec_ctx = grpc_call_context_get(call, GRPC_CONTEXT_SECURITY);
GRPC_API_TRACE("grpc_call_auth_context(call=%p)", 1, (call));
- if (sec_ctx == NULL) return NULL;
+ if (sec_ctx == nullptr) return nullptr;
return grpc_call_is_client(call)
? GRPC_AUTH_CONTEXT_REF(
- ((grpc_client_security_context *)sec_ctx)->auth_context,
+ ((grpc_client_security_context*)sec_ctx)->auth_context,
"grpc_call_auth_context client")
: GRPC_AUTH_CONTEXT_REF(
- ((grpc_server_security_context *)sec_ctx)->auth_context,
+ ((grpc_server_security_context*)sec_ctx)->auth_context,
"grpc_call_auth_context server");
}
-void grpc_auth_context_release(grpc_auth_context *context) {
+void grpc_auth_context_release(grpc_auth_context* context) {
GRPC_API_TRACE("grpc_auth_context_release(context=%p)", 1, (context));
GRPC_AUTH_CONTEXT_UNREF(context, "grpc_auth_context_unref");
}
/* --- grpc_client_security_context --- */
-grpc_client_security_context *grpc_client_security_context_create(void) {
- return gpr_zalloc(sizeof(grpc_client_security_context));
+grpc_client_security_context* grpc_client_security_context_create(void) {
+ return (grpc_client_security_context*)gpr_zalloc(
+ sizeof(grpc_client_security_context));
}
-void grpc_client_security_context_destroy(void *ctx) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_client_security_context *c = (grpc_client_security_context *)ctx;
- grpc_call_credentials_unref(&exec_ctx, c->creds);
+void grpc_client_security_context_destroy(void* ctx) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_client_security_context* c = (grpc_client_security_context*)ctx;
+ grpc_call_credentials_unref(c->creds);
GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "client_security_context");
- if (c->extension.instance != NULL && c->extension.destroy != NULL) {
+ if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
c->extension.destroy(c->extension.instance);
}
gpr_free(ctx);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* --- grpc_server_security_context --- */
-grpc_server_security_context *grpc_server_security_context_create(void) {
- return gpr_zalloc(sizeof(grpc_server_security_context));
+grpc_server_security_context* grpc_server_security_context_create(void) {
+ return (grpc_server_security_context*)gpr_zalloc(
+ sizeof(grpc_server_security_context));
}
-void grpc_server_security_context_destroy(void *ctx) {
- grpc_server_security_context *c = (grpc_server_security_context *)ctx;
+void grpc_server_security_context_destroy(void* ctx) {
+ grpc_server_security_context* c = (grpc_server_security_context*)ctx;
GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "server_security_context");
- if (c->extension.instance != NULL && c->extension.destroy != NULL) {
+ if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
c->extension.destroy(c->extension.instance);
}
gpr_free(ctx);
@@ -114,12 +113,13 @@ void grpc_server_security_context_destroy(void *ctx) {
/* --- grpc_auth_context --- */
-static grpc_auth_property_iterator empty_iterator = {NULL, 0, NULL};
+static grpc_auth_property_iterator empty_iterator = {nullptr, 0, nullptr};
-grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained) {
- grpc_auth_context *ctx = gpr_zalloc(sizeof(grpc_auth_context));
+grpc_auth_context* grpc_auth_context_create(grpc_auth_context* chained) {
+ grpc_auth_context* ctx =
+ (grpc_auth_context*)gpr_zalloc(sizeof(grpc_auth_context));
gpr_ref_init(&ctx->refcount, 1);
- if (chained != NULL) {
+ if (chained != nullptr) {
ctx->chained = GRPC_AUTH_CONTEXT_REF(chained, "chained");
ctx->peer_identity_property_name =
ctx->chained->peer_identity_property_name;
@@ -128,42 +128,42 @@ grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained) {
}
#ifndef NDEBUG
-grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *ctx,
- const char *file, int line,
- const char *reason) {
- if (ctx == NULL) return NULL;
- if (GRPC_TRACER_ON(grpc_trace_auth_context_refcount)) {
+grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx,
+ const char* file, int line,
+ const char* reason) {
+ if (ctx == nullptr) return nullptr;
+ if (grpc_trace_auth_context_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&ctx->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"AUTH_CONTEXT:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", ctx, val,
val + 1, reason);
}
#else
-grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *ctx) {
- if (ctx == NULL) return NULL;
+grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx) {
+ if (ctx == nullptr) return nullptr;
#endif
gpr_ref(&ctx->refcount);
return ctx;
}
#ifndef NDEBUG
-void grpc_auth_context_unref(grpc_auth_context *ctx, const char *file, int line,
- const char *reason) {
- if (ctx == NULL) return;
- if (GRPC_TRACER_ON(grpc_trace_auth_context_refcount)) {
+void grpc_auth_context_unref(grpc_auth_context* ctx, const char* file, int line,
+ const char* reason) {
+ if (ctx == nullptr) return;
+ if (grpc_trace_auth_context_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&ctx->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"AUTH_CONTEXT:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", ctx, val,
val - 1, reason);
}
#else
-void grpc_auth_context_unref(grpc_auth_context *ctx) {
- if (ctx == NULL) return;
+void grpc_auth_context_unref(grpc_auth_context* ctx) {
+ if (ctx == nullptr) return;
#endif
if (gpr_unref(&ctx->refcount)) {
size_t i;
GRPC_AUTH_CONTEXT_UNREF(ctx->chained, "chained");
- if (ctx->properties.array != NULL) {
+ if (ctx->properties.array != nullptr) {
for (i = 0; i < ctx->properties.count; i++) {
grpc_auth_property_reset(&ctx->properties.array[i]);
}
@@ -173,59 +173,59 @@ void grpc_auth_context_unref(grpc_auth_context *ctx) {
}
}
-const char *grpc_auth_context_peer_identity_property_name(
- const grpc_auth_context *ctx) {
+const char* grpc_auth_context_peer_identity_property_name(
+ const grpc_auth_context* ctx) {
GRPC_API_TRACE("grpc_auth_context_peer_identity_property_name(ctx=%p)", 1,
(ctx));
return ctx->peer_identity_property_name;
}
-int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context *ctx,
- const char *name) {
+int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context* ctx,
+ const char* name) {
grpc_auth_property_iterator it =
grpc_auth_context_find_properties_by_name(ctx, name);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
GRPC_API_TRACE(
"grpc_auth_context_set_peer_identity_property_name(ctx=%p, name=%s)", 2,
(ctx, name));
- if (prop == NULL) {
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "Property name %s not found in auth context.",
- name != NULL ? name : "NULL");
+ name != nullptr ? name : "NULL");
return 0;
}
ctx->peer_identity_property_name = prop->name;
return 1;
}
-int grpc_auth_context_peer_is_authenticated(const grpc_auth_context *ctx) {
+int grpc_auth_context_peer_is_authenticated(const grpc_auth_context* ctx) {
GRPC_API_TRACE("grpc_auth_context_peer_is_authenticated(ctx=%p)", 1, (ctx));
- return ctx->peer_identity_property_name == NULL ? 0 : 1;
+ return ctx->peer_identity_property_name == nullptr ? 0 : 1;
}
grpc_auth_property_iterator grpc_auth_context_property_iterator(
- const grpc_auth_context *ctx) {
+ const grpc_auth_context* ctx) {
grpc_auth_property_iterator it = empty_iterator;
GRPC_API_TRACE("grpc_auth_context_property_iterator(ctx=%p)", 1, (ctx));
- if (ctx == NULL) return it;
+ if (ctx == nullptr) return it;
it.ctx = ctx;
return it;
}
-const grpc_auth_property *grpc_auth_property_iterator_next(
- grpc_auth_property_iterator *it) {
+const grpc_auth_property* grpc_auth_property_iterator_next(
+ grpc_auth_property_iterator* it) {
GRPC_API_TRACE("grpc_auth_property_iterator_next(it=%p)", 1, (it));
- if (it == NULL || it->ctx == NULL) return NULL;
+ if (it == nullptr || it->ctx == nullptr) return nullptr;
while (it->index == it->ctx->properties.count) {
- if (it->ctx->chained == NULL) return NULL;
+ if (it->ctx->chained == nullptr) return nullptr;
it->ctx = it->ctx->chained;
it->index = 0;
}
- if (it->name == NULL) {
+ if (it->name == nullptr) {
return &it->ctx->properties.array[it->index++];
} else {
while (it->index < it->ctx->properties.count) {
- const grpc_auth_property *prop = &it->ctx->properties.array[it->index++];
- GPR_ASSERT(prop->name != NULL);
+ const grpc_auth_property* prop = &it->ctx->properties.array[it->index++];
+ GPR_ASSERT(prop->name != nullptr);
if (strcmp(it->name, prop->name) == 0) {
return prop;
}
@@ -236,55 +236,56 @@ const grpc_auth_property *grpc_auth_property_iterator_next(
}
grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
- const grpc_auth_context *ctx, const char *name) {
+ const grpc_auth_context* ctx, const char* name) {
grpc_auth_property_iterator it = empty_iterator;
GRPC_API_TRACE("grpc_auth_context_find_properties_by_name(ctx=%p, name=%s)",
2, (ctx, name));
- if (ctx == NULL || name == NULL) return empty_iterator;
+ if (ctx == nullptr || name == nullptr) return empty_iterator;
it.ctx = ctx;
it.name = name;
return it;
}
grpc_auth_property_iterator grpc_auth_context_peer_identity(
- const grpc_auth_context *ctx) {
+ const grpc_auth_context* ctx) {
GRPC_API_TRACE("grpc_auth_context_peer_identity(ctx=%p)", 1, (ctx));
- if (ctx == NULL) return empty_iterator;
+ if (ctx == nullptr) return empty_iterator;
return grpc_auth_context_find_properties_by_name(
ctx, ctx->peer_identity_property_name);
}
-static void ensure_auth_context_capacity(grpc_auth_context *ctx) {
+static void ensure_auth_context_capacity(grpc_auth_context* ctx) {
if (ctx->properties.count == ctx->properties.capacity) {
ctx->properties.capacity =
GPR_MAX(ctx->properties.capacity + 8, ctx->properties.capacity * 2);
- ctx->properties.array =
- gpr_realloc(ctx->properties.array,
- ctx->properties.capacity * sizeof(grpc_auth_property));
+ ctx->properties.array = (grpc_auth_property*)gpr_realloc(
+ ctx->properties.array,
+ ctx->properties.capacity * sizeof(grpc_auth_property));
}
}
-void grpc_auth_context_add_property(grpc_auth_context *ctx, const char *name,
- const char *value, size_t value_length) {
- grpc_auth_property *prop;
+void grpc_auth_context_add_property(grpc_auth_context* ctx, const char* name,
+ const char* value, size_t value_length) {
+ grpc_auth_property* prop;
GRPC_API_TRACE(
"grpc_auth_context_add_property(ctx=%p, name=%s, value=%*.*s, "
"value_length=%lu)",
- 6, (ctx, name, (int)value_length, (int)value_length, value,
- (unsigned long)value_length));
+ 6,
+ (ctx, name, (int)value_length, (int)value_length, value,
+ (unsigned long)value_length));
ensure_auth_context_capacity(ctx);
prop = &ctx->properties.array[ctx->properties.count++];
prop->name = gpr_strdup(name);
- prop->value = gpr_malloc(value_length + 1);
+ prop->value = (char*)gpr_malloc(value_length + 1);
memcpy(prop->value, value, value_length);
prop->value[value_length] = '\0';
prop->value_length = value_length;
}
-void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
- const char *name,
- const char *value) {
- grpc_auth_property *prop;
+void grpc_auth_context_add_cstring_property(grpc_auth_context* ctx,
+ const char* name,
+ const char* value) {
+ grpc_auth_property* prop;
GRPC_API_TRACE(
"grpc_auth_context_add_cstring_property(ctx=%p, name=%s, value=%s)", 3,
(ctx, name, value));
@@ -295,48 +296,49 @@ void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
prop->value_length = strlen(value);
}
-void grpc_auth_property_reset(grpc_auth_property *property) {
+void grpc_auth_property_reset(grpc_auth_property* property) {
gpr_free(property->name);
gpr_free(property->value);
memset(property, 0, sizeof(grpc_auth_property));
}
-static void auth_context_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
- GRPC_AUTH_CONTEXT_UNREF(p, "auth_context_pointer_arg");
+static void auth_context_pointer_arg_destroy(void* p) {
+ GRPC_AUTH_CONTEXT_UNREF((grpc_auth_context*)p, "auth_context_pointer_arg");
}
-static void *auth_context_pointer_arg_copy(void *p) {
- return GRPC_AUTH_CONTEXT_REF(p, "auth_context_pointer_arg");
+static void* auth_context_pointer_arg_copy(void* p) {
+ return GRPC_AUTH_CONTEXT_REF((grpc_auth_context*)p,
+ "auth_context_pointer_arg");
}
-static int auth_context_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
+static int auth_context_pointer_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
static const grpc_arg_pointer_vtable auth_context_pointer_vtable = {
auth_context_pointer_arg_copy, auth_context_pointer_arg_destroy,
auth_context_pointer_cmp};
-grpc_arg grpc_auth_context_to_arg(grpc_auth_context *p) {
- return grpc_channel_arg_pointer_create(GRPC_AUTH_CONTEXT_ARG, p,
+grpc_arg grpc_auth_context_to_arg(grpc_auth_context* p) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_AUTH_CONTEXT_ARG, p,
&auth_context_pointer_vtable);
}
-grpc_auth_context *grpc_auth_context_from_arg(const grpc_arg *arg) {
- if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return NULL;
+grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg) {
+ if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return nullptr;
if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
GRPC_AUTH_CONTEXT_ARG);
- return NULL;
+ return nullptr;
}
- return arg->value.pointer.p;
+ return (grpc_auth_context*)arg->value.pointer.p;
}
-grpc_auth_context *grpc_find_auth_context_in_args(
- const grpc_channel_args *args) {
+grpc_auth_context* grpc_find_auth_context_in_args(
+ const grpc_channel_args* args) {
size_t i;
- if (args == NULL) return NULL;
+ if (args == nullptr) return nullptr;
for (i = 0; i < args->num_args; i++) {
- grpc_auth_context *p = grpc_auth_context_from_arg(&args->args[i]);
- if (p != NULL) return p;
+ grpc_auth_context* p = grpc_auth_context_from_arg(&args->args[i]);
+ if (p != nullptr) return p;
}
- return NULL;
+ return nullptr;
}
diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h
index 0df39257a7..34f8c2487e 100644
--- a/src/core/lib/security/context/security_context.h
+++ b/src/core/lib/security/context/security_context.h
@@ -22,13 +22,7 @@
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/security/credentials/credentials.h"
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_auth_context_refcount;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount;
/* --- grpc_auth_context ---
@@ -37,21 +31,21 @@ extern "C" {
/* Property names are always NULL terminated. */
typedef struct {
- grpc_auth_property *array;
+ grpc_auth_property* array;
size_t count;
size_t capacity;
} grpc_auth_property_array;
struct grpc_auth_context {
- struct grpc_auth_context *chained;
+ struct grpc_auth_context* chained;
grpc_auth_property_array properties;
gpr_refcount refcount;
- const char *peer_identity_property_name;
- grpc_pollset *pollset;
+ const char* peer_identity_property_name;
+ grpc_pollset* pollset;
};
/* Creation. */
-grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained);
+grpc_auth_context* grpc_auth_context_create(grpc_auth_context* chained);
/* Refcounting. */
#ifndef NDEBUG
@@ -59,19 +53,19 @@ grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained);
grpc_auth_context_ref((p), __FILE__, __LINE__, (r))
#define GRPC_AUTH_CONTEXT_UNREF(p, r) \
grpc_auth_context_unref((p), __FILE__, __LINE__, (r))
-grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *policy,
- const char *file, int line,
- const char *reason);
-void grpc_auth_context_unref(grpc_auth_context *policy, const char *file,
- int line, const char *reason);
+grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* policy,
+ const char* file, int line,
+ const char* reason);
+void grpc_auth_context_unref(grpc_auth_context* policy, const char* file,
+ int line, const char* reason);
#else
#define GRPC_AUTH_CONTEXT_REF(p, r) grpc_auth_context_ref((p))
#define GRPC_AUTH_CONTEXT_UNREF(p, r) grpc_auth_context_unref((p))
-grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *policy);
-void grpc_auth_context_unref(grpc_auth_context *policy);
+grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* policy);
+void grpc_auth_context_unref(grpc_auth_context* policy);
#endif
-void grpc_auth_property_reset(grpc_auth_property *property);
+void grpc_auth_property_reset(grpc_auth_property* property);
/* --- grpc_security_context_extension ---
@@ -79,8 +73,8 @@ void grpc_auth_property_reset(grpc_auth_property *property);
later by a higher level method on a grpc_call object. */
typedef struct {
- void *instance;
- void (*destroy)(void *);
+ void* instance;
+ void (*destroy)(void*);
} grpc_security_context_extension;
/* --- grpc_client_security_context ---
@@ -88,36 +82,32 @@ typedef struct {
Internal client-side security context. */
typedef struct {
- grpc_call_credentials *creds;
- grpc_auth_context *auth_context;
+ grpc_call_credentials* creds;
+ grpc_auth_context* auth_context;
grpc_security_context_extension extension;
} grpc_client_security_context;
-grpc_client_security_context *grpc_client_security_context_create(void);
-void grpc_client_security_context_destroy(void *ctx);
+grpc_client_security_context* grpc_client_security_context_create(void);
+void grpc_client_security_context_destroy(void* ctx);
/* --- grpc_server_security_context ---
Internal server-side security context. */
typedef struct {
- grpc_auth_context *auth_context;
+ grpc_auth_context* auth_context;
grpc_security_context_extension extension;
} grpc_server_security_context;
-grpc_server_security_context *grpc_server_security_context_create(void);
-void grpc_server_security_context_destroy(void *ctx);
+grpc_server_security_context* grpc_server_security_context_create(void);
+void grpc_server_security_context_destroy(void* ctx);
/* --- Channel args for auth context --- */
#define GRPC_AUTH_CONTEXT_ARG "grpc.auth_context"
-grpc_arg grpc_auth_context_to_arg(grpc_auth_context *c);
-grpc_auth_context *grpc_auth_context_from_arg(const grpc_arg *arg);
-grpc_auth_context *grpc_find_auth_context_in_args(
- const grpc_channel_args *args);
-
-#ifdef __cplusplus
-}
-#endif
+grpc_arg grpc_auth_context_to_arg(grpc_auth_context* c);
+grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg);
+grpc_auth_context* grpc_find_auth_context_in_args(
+ const grpc_channel_args* args);
#endif /* GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H */
diff --git a/src/core/lib/security/credentials/composite/composite_credentials.c b/src/core/lib/security/credentials/composite/composite_credentials.cc
index 09fd60a12c..e4c1604795 100644
--- a/src/core/lib/security/credentials/composite/composite_credentials.c
+++ b/src/core/lib/security/credentials/composite/composite_credentials.cc
@@ -30,56 +30,55 @@
/* -- Composite call credentials. -- */
typedef struct {
- grpc_composite_call_credentials *composite_creds;
+ grpc_composite_call_credentials* composite_creds;
size_t creds_index;
- grpc_polling_entity *pollent;
+ grpc_polling_entity* pollent;
grpc_auth_metadata_context auth_md_context;
- grpc_credentials_mdelem_array *md_array;
- grpc_closure *on_request_metadata;
+ grpc_credentials_mdelem_array* md_array;
+ grpc_closure* on_request_metadata;
grpc_closure internal_on_request_metadata;
} grpc_composite_call_credentials_metadata_context;
-static void composite_call_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds;
+static void composite_call_destruct(grpc_call_credentials* creds) {
+ grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
for (size_t i = 0; i < c->inner.num_creds; i++) {
- grpc_call_credentials_unref(exec_ctx, c->inner.creds_array[i]);
+ grpc_call_credentials_unref(c->inner.creds_array[i]);
}
gpr_free(c->inner.creds_array);
}
-static void composite_call_metadata_cb(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_composite_call_credentials_metadata_context *ctx =
- (grpc_composite_call_credentials_metadata_context *)arg;
+static void composite_call_metadata_cb(void* arg, grpc_error* error) {
+ grpc_composite_call_credentials_metadata_context* ctx =
+ (grpc_composite_call_credentials_metadata_context*)arg;
if (error == GRPC_ERROR_NONE) {
/* See if we need to get some more metadata. */
if (ctx->creds_index < ctx->composite_creds->inner.num_creds) {
- grpc_call_credentials *inner_creds =
+ grpc_call_credentials* inner_creds =
ctx->composite_creds->inner.creds_array[ctx->creds_index++];
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, inner_creds, ctx->pollent, ctx->auth_md_context,
- ctx->md_array, &ctx->internal_on_request_metadata, &error)) {
+ inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
+ &ctx->internal_on_request_metadata, &error)) {
// Synchronous response, so call ourselves recursively.
- composite_call_metadata_cb(exec_ctx, arg, error);
+ composite_call_metadata_cb(arg, error);
GRPC_ERROR_UNREF(error);
}
return;
}
// We're done!
}
- GRPC_CLOSURE_SCHED(exec_ctx, ctx->on_request_metadata, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(ctx->on_request_metadata, GRPC_ERROR_REF(error));
gpr_free(ctx);
}
static bool composite_call_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_polling_entity *pollent, grpc_auth_metadata_context auth_md_context,
- grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds;
- grpc_composite_call_credentials_metadata_context *ctx;
- ctx = gpr_zalloc(sizeof(grpc_composite_call_credentials_metadata_context));
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context auth_md_context,
+ grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
+ grpc_error** error) {
+ grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
+ grpc_composite_call_credentials_metadata_context* ctx;
+ ctx = (grpc_composite_call_credentials_metadata_context*)gpr_zalloc(
+ sizeof(grpc_composite_call_credentials_metadata_context));
ctx->composite_creds = c;
ctx->pollent = pollent;
ctx->auth_md_context = auth_md_context;
@@ -87,36 +86,30 @@ static bool composite_call_get_request_metadata(
ctx->on_request_metadata = on_request_metadata;
GRPC_CLOSURE_INIT(&ctx->internal_on_request_metadata,
composite_call_metadata_cb, ctx, grpc_schedule_on_exec_ctx);
+ bool synchronous = true;
while (ctx->creds_index < ctx->composite_creds->inner.num_creds) {
- grpc_call_credentials *inner_creds =
+ grpc_call_credentials* inner_creds =
ctx->composite_creds->inner.creds_array[ctx->creds_index++];
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, inner_creds, ctx->pollent, ctx->auth_md_context,
- ctx->md_array, &ctx->internal_on_request_metadata, error)) {
+ inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
+ &ctx->internal_on_request_metadata, error)) {
if (*error != GRPC_ERROR_NONE) break;
} else {
+ synchronous = false; // Async return.
break;
}
}
- // If we got through all creds synchronously or we got a synchronous
- // error on one of them, return synchronously.
- if (ctx->creds_index == ctx->composite_creds->inner.num_creds ||
- *error != GRPC_ERROR_NONE) {
- gpr_free(ctx);
- return true;
- }
- // At least one inner cred is returning asynchronously, so we'll
- // return asynchronously as well.
- return false;
+ if (synchronous) gpr_free(ctx);
+ return synchronous;
}
static void composite_call_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
- grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds;
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
+ grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
for (size_t i = 0; i < c->inner.num_creds; ++i) {
grpc_call_credentials_cancel_get_request_metadata(
- exec_ctx, c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
+ c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
@@ -126,9 +119,9 @@ static grpc_call_credentials_vtable composite_call_credentials_vtable = {
composite_call_cancel_get_request_metadata};
static grpc_call_credentials_array get_creds_array(
- grpc_call_credentials **creds_addr) {
+ grpc_call_credentials** creds_addr) {
grpc_call_credentials_array result;
- grpc_call_credentials *creds = *creds_addr;
+ grpc_call_credentials* creds = *creds_addr;
result.creds_array = creds_addr;
result.num_creds = 1;
if (strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0) {
@@ -137,113 +130,113 @@ static grpc_call_credentials_array get_creds_array(
return result;
}
-grpc_call_credentials *grpc_composite_call_credentials_create(
- grpc_call_credentials *creds1, grpc_call_credentials *creds2,
- void *reserved) {
+grpc_call_credentials* grpc_composite_call_credentials_create(
+ grpc_call_credentials* creds1, grpc_call_credentials* creds2,
+ void* reserved) {
size_t i;
size_t creds_array_byte_size;
grpc_call_credentials_array creds1_array;
grpc_call_credentials_array creds2_array;
- grpc_composite_call_credentials *c;
+ grpc_composite_call_credentials* c;
GRPC_API_TRACE(
"grpc_composite_call_credentials_create(creds1=%p, creds2=%p, "
"reserved=%p)",
3, (creds1, creds2, reserved));
- GPR_ASSERT(reserved == NULL);
- GPR_ASSERT(creds1 != NULL);
- GPR_ASSERT(creds2 != NULL);
- c = gpr_zalloc(sizeof(grpc_composite_call_credentials));
+ GPR_ASSERT(reserved == nullptr);
+ GPR_ASSERT(creds1 != nullptr);
+ GPR_ASSERT(creds2 != nullptr);
+ c = (grpc_composite_call_credentials*)gpr_zalloc(
+ sizeof(grpc_composite_call_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE;
c->base.vtable = &composite_call_credentials_vtable;
gpr_ref_init(&c->base.refcount, 1);
creds1_array = get_creds_array(&creds1);
creds2_array = get_creds_array(&creds2);
c->inner.num_creds = creds1_array.num_creds + creds2_array.num_creds;
- creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials *);
- c->inner.creds_array = gpr_zalloc(creds_array_byte_size);
+ creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials*);
+ c->inner.creds_array =
+ (grpc_call_credentials**)gpr_zalloc(creds_array_byte_size);
for (i = 0; i < creds1_array.num_creds; i++) {
- grpc_call_credentials *cur_creds = creds1_array.creds_array[i];
+ grpc_call_credentials* cur_creds = creds1_array.creds_array[i];
c->inner.creds_array[i] = grpc_call_credentials_ref(cur_creds);
}
for (i = 0; i < creds2_array.num_creds; i++) {
- grpc_call_credentials *cur_creds = creds2_array.creds_array[i];
+ grpc_call_credentials* cur_creds = creds2_array.creds_array[i];
c->inner.creds_array[i + creds1_array.num_creds] =
grpc_call_credentials_ref(cur_creds);
}
return &c->base;
}
-const grpc_call_credentials_array *
-grpc_composite_call_credentials_get_credentials(grpc_call_credentials *creds) {
- const grpc_composite_call_credentials *c =
- (const grpc_composite_call_credentials *)creds;
+const grpc_call_credentials_array*
+grpc_composite_call_credentials_get_credentials(grpc_call_credentials* creds) {
+ const grpc_composite_call_credentials* c =
+ (const grpc_composite_call_credentials*)creds;
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
return &c->inner;
}
-grpc_call_credentials *grpc_credentials_contains_type(
- grpc_call_credentials *creds, const char *type,
- grpc_call_credentials **composite_creds) {
+grpc_call_credentials* grpc_credentials_contains_type(
+ grpc_call_credentials* creds, const char* type,
+ grpc_call_credentials** composite_creds) {
size_t i;
if (strcmp(creds->type, type) == 0) {
- if (composite_creds != NULL) *composite_creds = NULL;
+ if (composite_creds != nullptr) *composite_creds = nullptr;
return creds;
} else if (strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0) {
- const grpc_call_credentials_array *inner_creds_array =
+ const grpc_call_credentials_array* inner_creds_array =
grpc_composite_call_credentials_get_credentials(creds);
for (i = 0; i < inner_creds_array->num_creds; i++) {
if (strcmp(type, inner_creds_array->creds_array[i]->type) == 0) {
- if (composite_creds != NULL) *composite_creds = creds;
+ if (composite_creds != nullptr) *composite_creds = creds;
return inner_creds_array->creds_array[i];
}
}
}
- return NULL;
+ return nullptr;
}
/* -- Composite channel credentials. -- */
-static void composite_channel_destruct(grpc_exec_ctx *exec_ctx,
- grpc_channel_credentials *creds) {
- grpc_composite_channel_credentials *c =
- (grpc_composite_channel_credentials *)creds;
- grpc_channel_credentials_unref(exec_ctx, c->inner_creds);
- grpc_call_credentials_unref(exec_ctx, c->call_creds);
+static void composite_channel_destruct(grpc_channel_credentials* creds) {
+ grpc_composite_channel_credentials* c =
+ (grpc_composite_channel_credentials*)creds;
+ grpc_channel_credentials_unref(c->inner_creds);
+ grpc_call_credentials_unref(c->call_creds);
}
static grpc_security_status composite_channel_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *creds,
- grpc_call_credentials *call_creds, const char *target,
- const grpc_channel_args *args, grpc_channel_security_connector **sc,
- grpc_channel_args **new_args) {
- grpc_composite_channel_credentials *c =
- (grpc_composite_channel_credentials *)creds;
+ grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
+ grpc_composite_channel_credentials* c =
+ (grpc_composite_channel_credentials*)creds;
grpc_security_status status = GRPC_SECURITY_ERROR;
- GPR_ASSERT(c->inner_creds != NULL && c->call_creds != NULL &&
- c->inner_creds->vtable != NULL &&
- c->inner_creds->vtable->create_security_connector != NULL);
+ GPR_ASSERT(c->inner_creds != nullptr && c->call_creds != nullptr &&
+ c->inner_creds->vtable != nullptr &&
+ c->inner_creds->vtable->create_security_connector != nullptr);
/* If we are passed a call_creds, create a call composite to pass it
downstream. */
- if (call_creds != NULL) {
- grpc_call_credentials *composite_call_creds =
- grpc_composite_call_credentials_create(c->call_creds, call_creds, NULL);
+ if (call_creds != nullptr) {
+ grpc_call_credentials* composite_call_creds =
+ grpc_composite_call_credentials_create(c->call_creds, call_creds,
+ nullptr);
status = c->inner_creds->vtable->create_security_connector(
- exec_ctx, c->inner_creds, composite_call_creds, target, args, sc,
- new_args);
- grpc_call_credentials_unref(exec_ctx, composite_call_creds);
+ c->inner_creds, composite_call_creds, target, args, sc, new_args);
+ grpc_call_credentials_unref(composite_call_creds);
} else {
status = c->inner_creds->vtable->create_security_connector(
- exec_ctx, c->inner_creds, c->call_creds, target, args, sc, new_args);
+ c->inner_creds, c->call_creds, target, args, sc, new_args);
}
return status;
}
-static grpc_channel_credentials *
+static grpc_channel_credentials*
composite_channel_duplicate_without_call_credentials(
- grpc_channel_credentials *creds) {
- grpc_composite_channel_credentials *c =
- (grpc_composite_channel_credentials *)creds;
+ grpc_channel_credentials* creds) {
+ grpc_composite_channel_credentials* c =
+ (grpc_composite_channel_credentials*)creds;
return grpc_channel_credentials_ref(c->inner_creds);
}
@@ -251,11 +244,13 @@ static grpc_channel_credentials_vtable composite_channel_credentials_vtable = {
composite_channel_destruct, composite_channel_create_security_connector,
composite_channel_duplicate_without_call_credentials};
-grpc_channel_credentials *grpc_composite_channel_credentials_create(
- grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds,
- void *reserved) {
- grpc_composite_channel_credentials *c = gpr_zalloc(sizeof(*c));
- GPR_ASSERT(channel_creds != NULL && call_creds != NULL && reserved == NULL);
+grpc_channel_credentials* grpc_composite_channel_credentials_create(
+ grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds,
+ void* reserved) {
+ grpc_composite_channel_credentials* c =
+ (grpc_composite_channel_credentials*)gpr_zalloc(sizeof(*c));
+ GPR_ASSERT(channel_creds != nullptr && call_creds != nullptr &&
+ reserved == nullptr);
GRPC_API_TRACE(
"grpc_composite_channel_credentials_create(channel_creds=%p, "
"call_creds=%p, reserved=%p)",
diff --git a/src/core/lib/security/credentials/composite/composite_credentials.h b/src/core/lib/security/credentials/composite/composite_credentials.h
index 3076afcb7e..11990d38ff 100644
--- a/src/core/lib/security/credentials/composite/composite_credentials.h
+++ b/src/core/lib/security/credentials/composite/composite_credentials.h
@@ -22,28 +22,28 @@
#include "src/core/lib/security/credentials/credentials.h"
typedef struct {
- grpc_call_credentials **creds_array;
+ grpc_call_credentials** creds_array;
size_t num_creds;
} grpc_call_credentials_array;
-const grpc_call_credentials_array *
+const grpc_call_credentials_array*
grpc_composite_call_credentials_get_credentials(
- grpc_call_credentials *composite_creds);
+ grpc_call_credentials* composite_creds);
/* Returns creds if creds is of the specified type or the inner creds of the
specified type (if found), if the creds is of type COMPOSITE.
If composite_creds is not NULL, *composite_creds will point to creds if of
type COMPOSITE in case of success. */
-grpc_call_credentials *grpc_credentials_contains_type(
- grpc_call_credentials *creds, const char *type,
- grpc_call_credentials **composite_creds);
+grpc_call_credentials* grpc_credentials_contains_type(
+ grpc_call_credentials* creds, const char* type,
+ grpc_call_credentials** composite_creds);
/* -- Composite channel credentials. -- */
typedef struct {
grpc_channel_credentials base;
- grpc_channel_credentials *inner_creds;
- grpc_call_credentials *call_creds;
+ grpc_channel_credentials* inner_creds;
+ grpc_call_credentials* call_creds;
} grpc_composite_channel_credentials;
/* -- Composite call credentials. -- */
@@ -54,4 +54,4 @@ typedef struct {
} grpc_composite_call_credentials;
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H \
- */
+ */
diff --git a/src/core/lib/security/credentials/credentials.c b/src/core/lib/security/credentials/credentials.c
deleted file mode 100644
index 8a67c9865b..0000000000
--- a/src/core/lib/security/credentials/credentials.c
+++ /dev/null
@@ -1,287 +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/security/credentials/credentials.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/http/httpcli.h"
-#include "src/core/lib/http/parser.h"
-#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/json/json.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/surface/api_trace.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/time.h>
-
-/* -- Common. -- */
-
-grpc_credentials_metadata_request *grpc_credentials_metadata_request_create(
- grpc_call_credentials *creds) {
- grpc_credentials_metadata_request *r =
- gpr_zalloc(sizeof(grpc_credentials_metadata_request));
- r->creds = grpc_call_credentials_ref(creds);
- return r;
-}
-
-void grpc_credentials_metadata_request_destroy(
- grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *r) {
- grpc_call_credentials_unref(exec_ctx, r->creds);
- grpc_http_response_destroy(&r->response);
- gpr_free(r);
-}
-
-grpc_channel_credentials *grpc_channel_credentials_ref(
- grpc_channel_credentials *creds) {
- if (creds == NULL) return NULL;
- gpr_ref(&creds->refcount);
- return creds;
-}
-
-void grpc_channel_credentials_unref(grpc_exec_ctx *exec_ctx,
- grpc_channel_credentials *creds) {
- if (creds == NULL) return;
- if (gpr_unref(&creds->refcount)) {
- if (creds->vtable->destruct != NULL) {
- creds->vtable->destruct(exec_ctx, creds);
- }
- gpr_free(creds);
- }
-}
-
-void grpc_channel_credentials_release(grpc_channel_credentials *creds) {
- GRPC_API_TRACE("grpc_channel_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-grpc_call_credentials *grpc_call_credentials_ref(grpc_call_credentials *creds) {
- if (creds == NULL) return NULL;
- gpr_ref(&creds->refcount);
- return creds;
-}
-
-void grpc_call_credentials_unref(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- if (creds == NULL) return;
- if (gpr_unref(&creds->refcount)) {
- if (creds->vtable->destruct != NULL) {
- creds->vtable->destruct(exec_ctx, creds);
- }
- gpr_free(creds);
- }
-}
-
-void grpc_call_credentials_release(grpc_call_credentials *creds) {
- GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-bool grpc_call_credentials_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_polling_entity *pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
- grpc_error **error) {
- if (creds == NULL || creds->vtable->get_request_metadata == NULL) {
- return true;
- }
- return creds->vtable->get_request_metadata(
- exec_ctx, creds, pollent, context, md_array, on_request_metadata, error);
-}
-
-void grpc_call_credentials_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
- if (creds == NULL || creds->vtable->cancel_get_request_metadata == NULL) {
- return;
- }
- creds->vtable->cancel_get_request_metadata(exec_ctx, creds, md_array, error);
-}
-
-grpc_security_status grpc_channel_credentials_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *channel_creds,
- const char *target, const grpc_channel_args *args,
- grpc_channel_security_connector **sc, grpc_channel_args **new_args) {
- *new_args = NULL;
- if (channel_creds == NULL) {
- return GRPC_SECURITY_ERROR;
- }
- GPR_ASSERT(channel_creds->vtable->create_security_connector != NULL);
- return channel_creds->vtable->create_security_connector(
- exec_ctx, channel_creds, NULL, target, args, sc, new_args);
-}
-
-grpc_channel_credentials *
-grpc_channel_credentials_duplicate_without_call_credentials(
- grpc_channel_credentials *channel_creds) {
- if (channel_creds != NULL && channel_creds->vtable != NULL &&
- channel_creds->vtable->duplicate_without_call_credentials != NULL) {
- return channel_creds->vtable->duplicate_without_call_credentials(
- channel_creds);
- } else {
- return grpc_channel_credentials_ref(channel_creds);
- }
-}
-
-static void credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
- grpc_channel_credentials_unref(exec_ctx, p);
-}
-
-static void *credentials_pointer_arg_copy(void *p) {
- return grpc_channel_credentials_ref(p);
-}
-
-static int credentials_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
-
-static const grpc_arg_pointer_vtable credentials_pointer_vtable = {
- credentials_pointer_arg_copy, credentials_pointer_arg_destroy,
- credentials_pointer_cmp};
-
-grpc_arg grpc_channel_credentials_to_arg(
- grpc_channel_credentials *credentials) {
- return grpc_channel_arg_pointer_create(
- GRPC_ARG_CHANNEL_CREDENTIALS, credentials, &credentials_pointer_vtable);
-}
-
-grpc_channel_credentials *grpc_channel_credentials_from_arg(
- const grpc_arg *arg) {
- if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return NULL;
- if (arg->type != GRPC_ARG_POINTER) {
- gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
- GRPC_ARG_CHANNEL_CREDENTIALS);
- return NULL;
- }
- return arg->value.pointer.p;
-}
-
-grpc_channel_credentials *grpc_channel_credentials_find_in_args(
- const grpc_channel_args *args) {
- size_t i;
- if (args == NULL) return NULL;
- for (i = 0; i < args->num_args; i++) {
- grpc_channel_credentials *credentials =
- grpc_channel_credentials_from_arg(&args->args[i]);
- if (credentials != NULL) return credentials;
- }
- return NULL;
-}
-
-grpc_server_credentials *grpc_server_credentials_ref(
- grpc_server_credentials *creds) {
- if (creds == NULL) return NULL;
- gpr_ref(&creds->refcount);
- return creds;
-}
-
-void grpc_server_credentials_unref(grpc_exec_ctx *exec_ctx,
- grpc_server_credentials *creds) {
- if (creds == NULL) return;
- if (gpr_unref(&creds->refcount)) {
- if (creds->vtable->destruct != NULL) {
- creds->vtable->destruct(exec_ctx, creds);
- }
- if (creds->processor.destroy != NULL && creds->processor.state != NULL) {
- creds->processor.destroy(creds->processor.state);
- }
- gpr_free(creds);
- }
-}
-
-void grpc_server_credentials_release(grpc_server_credentials *creds) {
- GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_server_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-grpc_security_status grpc_server_credentials_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_server_credentials *creds,
- grpc_server_security_connector **sc) {
- if (creds == NULL || creds->vtable->create_security_connector == NULL) {
- gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
- return GRPC_SECURITY_ERROR;
- }
- return creds->vtable->create_security_connector(exec_ctx, creds, sc);
-}
-
-void grpc_server_credentials_set_auth_metadata_processor(
- grpc_server_credentials *creds, grpc_auth_metadata_processor processor) {
- GRPC_API_TRACE(
- "grpc_server_credentials_set_auth_metadata_processor("
- "creds=%p, "
- "processor=grpc_auth_metadata_processor { process: %p, state: %p })",
- 3, (creds, (void *)(intptr_t)processor.process, processor.state));
- if (creds == NULL) return;
- if (creds->processor.destroy != NULL && creds->processor.state != NULL) {
- creds->processor.destroy(creds->processor.state);
- }
- creds->processor = processor;
-}
-
-static void server_credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx,
- void *p) {
- grpc_server_credentials_unref(exec_ctx, p);
-}
-
-static void *server_credentials_pointer_arg_copy(void *p) {
- return grpc_server_credentials_ref(p);
-}
-
-static int server_credentials_pointer_cmp(void *a, void *b) {
- return GPR_ICMP(a, b);
-}
-
-static const grpc_arg_pointer_vtable cred_ptr_vtable = {
- server_credentials_pointer_arg_copy, server_credentials_pointer_arg_destroy,
- server_credentials_pointer_cmp};
-
-grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials *p) {
- return grpc_channel_arg_pointer_create(GRPC_SERVER_CREDENTIALS_ARG, p,
- &cred_ptr_vtable);
-}
-
-grpc_server_credentials *grpc_server_credentials_from_arg(const grpc_arg *arg) {
- if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return NULL;
- if (arg->type != GRPC_ARG_POINTER) {
- gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
- GRPC_SERVER_CREDENTIALS_ARG);
- return NULL;
- }
- return arg->value.pointer.p;
-}
-
-grpc_server_credentials *grpc_find_server_credentials_in_args(
- const grpc_channel_args *args) {
- size_t i;
- if (args == NULL) return NULL;
- for (i = 0; i < args->num_args; i++) {
- grpc_server_credentials *p =
- grpc_server_credentials_from_arg(&args->args[i]);
- if (p != NULL) return p;
- }
- return NULL;
-}
diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc
new file mode 100644
index 0000000000..009a5ce4ec
--- /dev/null
+++ b/src/core/lib/security/credentials/credentials.cc
@@ -0,0 +1,283 @@
+/*
+ *
+ * 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/security/credentials/credentials.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/http/httpcli.h"
+#include "src/core/lib/http/parser.h"
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/json/json.h"
+#include "src/core/lib/surface/api_trace.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/time.h>
+
+/* -- Common. -- */
+
+grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
+ grpc_call_credentials* creds) {
+ grpc_credentials_metadata_request* r =
+ (grpc_credentials_metadata_request*)gpr_zalloc(
+ sizeof(grpc_credentials_metadata_request));
+ r->creds = grpc_call_credentials_ref(creds);
+ return r;
+}
+
+void grpc_credentials_metadata_request_destroy(
+ grpc_credentials_metadata_request* r) {
+ grpc_call_credentials_unref(r->creds);
+ grpc_http_response_destroy(&r->response);
+ gpr_free(r);
+}
+
+grpc_channel_credentials* grpc_channel_credentials_ref(
+ grpc_channel_credentials* creds) {
+ if (creds == nullptr) return nullptr;
+ gpr_ref(&creds->refcount);
+ return creds;
+}
+
+void grpc_channel_credentials_unref(grpc_channel_credentials* creds) {
+ if (creds == nullptr) return;
+ if (gpr_unref(&creds->refcount)) {
+ if (creds->vtable->destruct != nullptr) {
+ creds->vtable->destruct(creds);
+ }
+ gpr_free(creds);
+ }
+}
+
+void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
+ GRPC_API_TRACE("grpc_channel_credentials_release(creds=%p)", 1, (creds));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_credentials_unref(creds);
+}
+
+grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
+ if (creds == nullptr) return nullptr;
+ gpr_ref(&creds->refcount);
+ return creds;
+}
+
+void grpc_call_credentials_unref(grpc_call_credentials* creds) {
+ if (creds == nullptr) return;
+ if (gpr_unref(&creds->refcount)) {
+ if (creds->vtable->destruct != nullptr) {
+ creds->vtable->destruct(creds);
+ }
+ gpr_free(creds);
+ }
+}
+
+void grpc_call_credentials_release(grpc_call_credentials* creds) {
+ GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_call_credentials_unref(creds);
+}
+
+bool grpc_call_credentials_get_request_metadata(
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
+ if (creds == nullptr || creds->vtable->get_request_metadata == nullptr) {
+ return true;
+ }
+ return creds->vtable->get_request_metadata(creds, pollent, context, md_array,
+ on_request_metadata, error);
+}
+
+void grpc_call_credentials_cancel_get_request_metadata(
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
+ if (creds == nullptr ||
+ creds->vtable->cancel_get_request_metadata == nullptr) {
+ return;
+ }
+ creds->vtable->cancel_get_request_metadata(creds, md_array, error);
+}
+
+grpc_security_status grpc_channel_credentials_create_security_connector(
+ grpc_channel_credentials* channel_creds, const char* target,
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
+ grpc_channel_args** new_args) {
+ *new_args = nullptr;
+ if (channel_creds == nullptr) {
+ return GRPC_SECURITY_ERROR;
+ }
+ GPR_ASSERT(channel_creds->vtable->create_security_connector != nullptr);
+ return channel_creds->vtable->create_security_connector(
+ channel_creds, nullptr, target, args, sc, new_args);
+}
+
+grpc_channel_credentials*
+grpc_channel_credentials_duplicate_without_call_credentials(
+ grpc_channel_credentials* channel_creds) {
+ if (channel_creds != nullptr && channel_creds->vtable != nullptr &&
+ channel_creds->vtable->duplicate_without_call_credentials != nullptr) {
+ return channel_creds->vtable->duplicate_without_call_credentials(
+ channel_creds);
+ } else {
+ return grpc_channel_credentials_ref(channel_creds);
+ }
+}
+
+static void credentials_pointer_arg_destroy(void* p) {
+ grpc_channel_credentials_unref((grpc_channel_credentials*)p);
+}
+
+static void* credentials_pointer_arg_copy(void* p) {
+ return grpc_channel_credentials_ref((grpc_channel_credentials*)p);
+}
+
+static int credentials_pointer_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
+
+static const grpc_arg_pointer_vtable credentials_pointer_vtable = {
+ credentials_pointer_arg_copy, credentials_pointer_arg_destroy,
+ credentials_pointer_cmp};
+
+grpc_arg grpc_channel_credentials_to_arg(
+ grpc_channel_credentials* credentials) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_ARG_CHANNEL_CREDENTIALS,
+ credentials,
+ &credentials_pointer_vtable);
+}
+
+grpc_channel_credentials* grpc_channel_credentials_from_arg(
+ const grpc_arg* arg) {
+ if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return nullptr;
+ if (arg->type != GRPC_ARG_POINTER) {
+ gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
+ GRPC_ARG_CHANNEL_CREDENTIALS);
+ return nullptr;
+ }
+ return (grpc_channel_credentials*)arg->value.pointer.p;
+}
+
+grpc_channel_credentials* grpc_channel_credentials_find_in_args(
+ const grpc_channel_args* args) {
+ size_t i;
+ if (args == nullptr) return nullptr;
+ for (i = 0; i < args->num_args; i++) {
+ grpc_channel_credentials* credentials =
+ grpc_channel_credentials_from_arg(&args->args[i]);
+ if (credentials != nullptr) return credentials;
+ }
+ return nullptr;
+}
+
+grpc_server_credentials* grpc_server_credentials_ref(
+ grpc_server_credentials* creds) {
+ if (creds == nullptr) return nullptr;
+ gpr_ref(&creds->refcount);
+ return creds;
+}
+
+void grpc_server_credentials_unref(grpc_server_credentials* creds) {
+ if (creds == nullptr) return;
+ if (gpr_unref(&creds->refcount)) {
+ if (creds->vtable->destruct != nullptr) {
+ creds->vtable->destruct(creds);
+ }
+ if (creds->processor.destroy != nullptr &&
+ creds->processor.state != nullptr) {
+ creds->processor.destroy(creds->processor.state);
+ }
+ gpr_free(creds);
+ }
+}
+
+void grpc_server_credentials_release(grpc_server_credentials* creds) {
+ GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_server_credentials_unref(creds);
+}
+
+grpc_security_status grpc_server_credentials_create_security_connector(
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
+ if (creds == nullptr || creds->vtable->create_security_connector == nullptr) {
+ gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
+ return GRPC_SECURITY_ERROR;
+ }
+ return creds->vtable->create_security_connector(creds, sc);
+}
+
+void grpc_server_credentials_set_auth_metadata_processor(
+ grpc_server_credentials* creds, grpc_auth_metadata_processor processor) {
+ GRPC_API_TRACE(
+ "grpc_server_credentials_set_auth_metadata_processor("
+ "creds=%p, "
+ "processor=grpc_auth_metadata_processor { process: %p, state: %p })",
+ 3, (creds, (void*)(intptr_t)processor.process, processor.state));
+ if (creds == nullptr) return;
+ if (creds->processor.destroy != nullptr &&
+ creds->processor.state != nullptr) {
+ creds->processor.destroy(creds->processor.state);
+ }
+ creds->processor = processor;
+}
+
+static void server_credentials_pointer_arg_destroy(void* p) {
+ grpc_server_credentials_unref((grpc_server_credentials*)p);
+}
+
+static void* server_credentials_pointer_arg_copy(void* p) {
+ return grpc_server_credentials_ref((grpc_server_credentials*)p);
+}
+
+static int server_credentials_pointer_cmp(void* a, void* b) {
+ return GPR_ICMP(a, b);
+}
+
+static const grpc_arg_pointer_vtable cred_ptr_vtable = {
+ server_credentials_pointer_arg_copy, server_credentials_pointer_arg_destroy,
+ server_credentials_pointer_cmp};
+
+grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* p) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_SERVER_CREDENTIALS_ARG, p,
+ &cred_ptr_vtable);
+}
+
+grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg) {
+ if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return nullptr;
+ if (arg->type != GRPC_ARG_POINTER) {
+ gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
+ GRPC_SERVER_CREDENTIALS_ARG);
+ return nullptr;
+ }
+ return (grpc_server_credentials*)arg->value.pointer.p;
+}
+
+grpc_server_credentials* grpc_find_server_credentials_in_args(
+ const grpc_channel_args* args) {
+ size_t i;
+ if (args == nullptr) return nullptr;
+ for (i = 0; i < args->num_args; i++) {
+ grpc_server_credentials* p =
+ grpc_server_credentials_from_arg(&args->args[i]);
+ if (p != nullptr) return p;
+ }
+ return nullptr;
+}
diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h
index 04a54b0ca8..4825b65720 100644
--- a/src/core/lib/security/credentials/credentials.h
+++ b/src/core/lib/security/credentials/credentials.h
@@ -73,13 +73,13 @@ typedef enum {
/* --- Google utils --- */
/* It is the caller's responsibility to gpr_free the result if not NULL. */
-char *grpc_get_well_known_google_credentials_file_path(void);
+char* grpc_get_well_known_google_credentials_file_path(void);
/* Implementation function for the different platforms. */
-char *grpc_get_well_known_google_credentials_file_path_impl(void);
+char* grpc_get_well_known_google_credentials_file_path_impl(void);
/* Override for testing only. Not thread-safe */
-typedef char *(*grpc_well_known_credentials_path_getter)(void);
+typedef char* (*grpc_well_known_credentials_path_getter)(void);
void grpc_override_well_known_credentials_path_getter(
grpc_well_known_credentials_path_getter getter);
@@ -88,168 +88,157 @@ void grpc_override_well_known_credentials_path_getter(
#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
typedef struct {
- void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c);
+ void (*destruct)(grpc_channel_credentials* c);
grpc_security_status (*create_security_connector)(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
- grpc_call_credentials *call_creds, const char *target,
- const grpc_channel_args *args, grpc_channel_security_connector **sc,
- grpc_channel_args **new_args);
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args);
- grpc_channel_credentials *(*duplicate_without_call_credentials)(
- grpc_channel_credentials *c);
+ grpc_channel_credentials* (*duplicate_without_call_credentials)(
+ grpc_channel_credentials* c);
} grpc_channel_credentials_vtable;
struct grpc_channel_credentials {
- const grpc_channel_credentials_vtable *vtable;
- const char *type;
+ const grpc_channel_credentials_vtable* vtable;
+ const char* type;
gpr_refcount refcount;
};
-grpc_channel_credentials *grpc_channel_credentials_ref(
- grpc_channel_credentials *creds);
-void grpc_channel_credentials_unref(grpc_exec_ctx *exec_ctx,
- grpc_channel_credentials *creds);
+grpc_channel_credentials* grpc_channel_credentials_ref(
+ grpc_channel_credentials* creds);
+void grpc_channel_credentials_unref(grpc_channel_credentials* creds);
/* Creates a security connector for the channel. May also create new channel
args for the channel to be used in place of the passed in const args if
returned non NULL. In that case the caller is responsible for destroying
new_args after channel creation. */
grpc_security_status grpc_channel_credentials_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *creds,
- const char *target, const grpc_channel_args *args,
- grpc_channel_security_connector **sc, grpc_channel_args **new_args);
+ grpc_channel_credentials* creds, const char* target,
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
+ grpc_channel_args** new_args);
/* Creates a version of the channel credentials without any attached call
credentials. This can be used in order to open a channel to a non-trusted
gRPC load balancer. */
-grpc_channel_credentials *
+grpc_channel_credentials*
grpc_channel_credentials_duplicate_without_call_credentials(
- grpc_channel_credentials *creds);
+ grpc_channel_credentials* creds);
/* Util to encapsulate the channel credentials in a channel arg. */
-grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials *credentials);
+grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials* credentials);
/* Util to get the channel credentials from a channel arg. */
-grpc_channel_credentials *grpc_channel_credentials_from_arg(
- const grpc_arg *arg);
+grpc_channel_credentials* grpc_channel_credentials_from_arg(
+ const grpc_arg* arg);
/* Util to find the channel credentials from channel args. */
-grpc_channel_credentials *grpc_channel_credentials_find_in_args(
- const grpc_channel_args *args);
+grpc_channel_credentials* grpc_channel_credentials_find_in_args(
+ const grpc_channel_args* args);
/* --- grpc_credentials_mdelem_array. --- */
typedef struct {
- grpc_mdelem *md;
+ grpc_mdelem* md;
size_t size;
} grpc_credentials_mdelem_array;
/// Takes a new ref to \a md.
-void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array *list,
+void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array* list,
grpc_mdelem md);
/// Appends all elements from \a src to \a dst, taking a new ref to each one.
-void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array *dst,
- grpc_credentials_mdelem_array *src);
+void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst,
+ grpc_credentials_mdelem_array* src);
-void grpc_credentials_mdelem_array_destroy(grpc_exec_ctx *exec_ctx,
- grpc_credentials_mdelem_array *list);
+void grpc_credentials_mdelem_array_destroy(grpc_credentials_mdelem_array* list);
/* --- grpc_call_credentials. --- */
typedef struct {
- void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_call_credentials *c);
- bool (*get_request_metadata)(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *c,
- grpc_polling_entity *pollent,
+ void (*destruct)(grpc_call_credentials* c);
+ bool (*get_request_metadata)(grpc_call_credentials* c,
+ grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array,
- grpc_closure *on_request_metadata,
- grpc_error **error);
- void (*cancel_get_request_metadata)(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array,
- grpc_error *error);
+ grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata,
+ grpc_error** error);
+ void (*cancel_get_request_metadata)(grpc_call_credentials* c,
+ grpc_credentials_mdelem_array* md_array,
+ grpc_error* error);
} grpc_call_credentials_vtable;
struct grpc_call_credentials {
- const grpc_call_credentials_vtable *vtable;
- const char *type;
+ const grpc_call_credentials_vtable* vtable;
+ const char* type;
gpr_refcount refcount;
};
-grpc_call_credentials *grpc_call_credentials_ref(grpc_call_credentials *creds);
-void grpc_call_credentials_unref(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds);
+grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds);
+void grpc_call_credentials_unref(grpc_call_credentials* creds);
/// Returns true if completed synchronously, in which case \a error will
/// be set to indicate the result. Otherwise, \a on_request_metadata will
/// be invoked asynchronously when complete. \a md_array will be populated
/// with the resulting metadata once complete.
bool grpc_call_credentials_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_polling_entity *pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
- grpc_error **error);
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error);
/// Cancels a pending asynchronous operation started by
/// grpc_call_credentials_get_request_metadata() with the corresponding
/// value of \a md_array.
void grpc_call_credentials_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array, grpc_error *error);
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error);
/* Metadata-only credentials with the specified key and value where
asynchronicity can be simulated for testing. */
-grpc_call_credentials *grpc_md_only_test_credentials_create(
- grpc_exec_ctx *exec_ctx, const char *md_key, const char *md_value,
- bool is_async);
+grpc_call_credentials* grpc_md_only_test_credentials_create(
+ const char* md_key, const char* md_value, bool is_async);
/* --- grpc_server_credentials. --- */
typedef struct {
- void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_server_credentials *c);
+ void (*destruct)(grpc_server_credentials* c);
grpc_security_status (*create_security_connector)(
- grpc_exec_ctx *exec_ctx, grpc_server_credentials *c,
- grpc_server_security_connector **sc);
+ grpc_server_credentials* c, grpc_server_security_connector** sc);
} grpc_server_credentials_vtable;
struct grpc_server_credentials {
- const grpc_server_credentials_vtable *vtable;
- const char *type;
+ const grpc_server_credentials_vtable* vtable;
+ const char* type;
gpr_refcount refcount;
grpc_auth_metadata_processor processor;
};
grpc_security_status grpc_server_credentials_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_server_credentials *creds,
- grpc_server_security_connector **sc);
+ grpc_server_credentials* creds, grpc_server_security_connector** sc);
-grpc_server_credentials *grpc_server_credentials_ref(
- grpc_server_credentials *creds);
+grpc_server_credentials* grpc_server_credentials_ref(
+ grpc_server_credentials* creds);
-void grpc_server_credentials_unref(grpc_exec_ctx *exec_ctx,
- grpc_server_credentials *creds);
+void grpc_server_credentials_unref(grpc_server_credentials* creds);
#define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials"
-grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials *c);
-grpc_server_credentials *grpc_server_credentials_from_arg(const grpc_arg *arg);
-grpc_server_credentials *grpc_find_server_credentials_in_args(
- const grpc_channel_args *args);
+grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* c);
+grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg);
+grpc_server_credentials* grpc_find_server_credentials_in_args(
+ const grpc_channel_args* args);
/* -- Credentials Metadata Request. -- */
typedef struct {
- grpc_call_credentials *creds;
+ grpc_call_credentials* creds;
grpc_http_response response;
} grpc_credentials_metadata_request;
-grpc_credentials_metadata_request *grpc_credentials_metadata_request_create(
- grpc_call_credentials *creds);
+grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
+ grpc_call_credentials* creds);
void grpc_credentials_metadata_request_destroy(
- grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *r);
+ grpc_credentials_metadata_request* r);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/credentials_metadata.c b/src/core/lib/security/credentials/credentials_metadata.cc
index ccd39e610f..9ceaf21139 100644
--- a/src/core/lib/security/credentials/credentials_metadata.c
+++ b/src/core/lib/security/credentials/credentials_metadata.cc
@@ -24,7 +24,7 @@
#include "src/core/lib/slice/slice_internal.h"
-static void mdelem_list_ensure_capacity(grpc_credentials_mdelem_array *list,
+static void mdelem_list_ensure_capacity(grpc_credentials_mdelem_array* list,
size_t additional_space_needed) {
size_t target_size = list->size + additional_space_needed;
// Find the next power of two greater than the target size (i.e.,
@@ -33,17 +33,18 @@ static void mdelem_list_ensure_capacity(grpc_credentials_mdelem_array *list,
while (new_size < target_size) {
new_size *= 2;
}
- list->md = gpr_realloc(list->md, sizeof(grpc_mdelem) * new_size);
+ list->md =
+ (grpc_mdelem*)gpr_realloc(list->md, sizeof(grpc_mdelem) * new_size);
}
-void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array *list,
+void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array* list,
grpc_mdelem md) {
mdelem_list_ensure_capacity(list, 1);
list->md[list->size++] = GRPC_MDELEM_REF(md);
}
-void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array *dst,
- grpc_credentials_mdelem_array *src) {
+void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst,
+ grpc_credentials_mdelem_array* src) {
mdelem_list_ensure_capacity(dst, src->size);
for (size_t i = 0; i < src->size; ++i) {
dst->md[dst->size++] = GRPC_MDELEM_REF(src->md[i]);
@@ -51,9 +52,9 @@ void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array *dst,
}
void grpc_credentials_mdelem_array_destroy(
- grpc_exec_ctx *exec_ctx, grpc_credentials_mdelem_array *list) {
+ grpc_credentials_mdelem_array* list) {
for (size_t i = 0; i < list->size; ++i) {
- GRPC_MDELEM_UNREF(exec_ctx, list->md[i]);
+ GRPC_MDELEM_UNREF(list->md[i]);
}
gpr_free(list->md);
}
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.c b/src/core/lib/security/credentials/fake/fake_credentials.cc
index ac9017850f..9065325cdd 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.c
+++ b/src/core/lib/security/credentials/fake/fake_credentials.cc
@@ -25,8 +25,8 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/support/string.h"
/* -- Fake transport security credentials. -- */
@@ -34,42 +34,43 @@
"grpc.fake_security.expected_targets"
static grpc_security_status fake_transport_security_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
- grpc_call_credentials *call_creds, const char *target,
- const grpc_channel_args *args, grpc_channel_security_connector **sc,
- grpc_channel_args **new_args) {
- *sc = grpc_fake_channel_security_connector_create(call_creds, target, args);
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
+ *sc =
+ grpc_fake_channel_security_connector_create(c, call_creds, target, args);
return GRPC_SECURITY_OK;
}
static grpc_security_status
fake_transport_security_server_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_server_credentials *c,
- grpc_server_security_connector **sc) {
- *sc = grpc_fake_server_security_connector_create();
+ grpc_server_credentials* c, grpc_server_security_connector** sc) {
+ *sc = grpc_fake_server_security_connector_create(c);
return GRPC_SECURITY_OK;
}
static grpc_channel_credentials_vtable
fake_transport_security_credentials_vtable = {
- NULL, fake_transport_security_create_security_connector, NULL};
+ nullptr, fake_transport_security_create_security_connector, nullptr};
static grpc_server_credentials_vtable
fake_transport_security_server_credentials_vtable = {
- NULL, fake_transport_security_server_create_security_connector};
+ nullptr, fake_transport_security_server_create_security_connector};
-grpc_channel_credentials *grpc_fake_transport_security_credentials_create(
+grpc_channel_credentials* grpc_fake_transport_security_credentials_create(
void) {
- grpc_channel_credentials *c = gpr_zalloc(sizeof(grpc_channel_credentials));
+ grpc_channel_credentials* c =
+ (grpc_channel_credentials*)gpr_zalloc(sizeof(grpc_channel_credentials));
c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY;
c->vtable = &fake_transport_security_credentials_vtable;
gpr_ref_init(&c->refcount, 1);
return c;
}
-grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
+grpc_server_credentials* grpc_fake_transport_security_server_credentials_create(
void) {
- grpc_server_credentials *c = gpr_malloc(sizeof(grpc_server_credentials));
+ grpc_server_credentials* c =
+ (grpc_server_credentials*)gpr_malloc(sizeof(grpc_server_credentials));
memset(c, 0, sizeof(grpc_server_credentials));
c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY;
gpr_ref_init(&c->refcount, 1);
@@ -77,47 +78,45 @@ grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
return c;
}
-grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets) {
- return grpc_channel_arg_string_create(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS,
- expected_targets);
+grpc_arg grpc_fake_transport_expected_targets_arg(char* expected_targets) {
+ return grpc_channel_arg_string_create(
+ (char*)GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets);
}
-const char *grpc_fake_transport_get_expected_targets(
- const grpc_channel_args *args) {
- const grpc_arg *expected_target_arg =
+const char* grpc_fake_transport_get_expected_targets(
+ const grpc_channel_args* args) {
+ const grpc_arg* expected_target_arg =
grpc_channel_args_find(args, GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS);
- if (expected_target_arg != NULL &&
+ if (expected_target_arg != nullptr &&
expected_target_arg->type == GRPC_ARG_STRING) {
return expected_target_arg->value.string;
}
- return NULL;
+ return nullptr;
}
/* -- Metadata-only test credentials. -- */
-static void md_only_test_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_md_only_test_credentials *c = (grpc_md_only_test_credentials *)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->md);
+static void md_only_test_destruct(grpc_call_credentials* creds) {
+ grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)creds;
+ GRPC_MDELEM_UNREF(c->md);
}
static bool md_only_test_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_polling_entity *pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_md_only_test_credentials *c = (grpc_md_only_test_credentials *)creds;
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
+ grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)creds;
grpc_credentials_mdelem_array_add(md_array, c->md);
if (c->is_async) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_request_metadata, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_request_metadata, GRPC_ERROR_NONE);
return false;
}
return true;
}
static void md_only_test_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -125,17 +124,15 @@ static grpc_call_credentials_vtable md_only_test_vtable = {
md_only_test_destruct, md_only_test_get_request_metadata,
md_only_test_cancel_get_request_metadata};
-grpc_call_credentials *grpc_md_only_test_credentials_create(
- grpc_exec_ctx *exec_ctx, const char *md_key, const char *md_value,
- bool is_async) {
- grpc_md_only_test_credentials *c =
- gpr_zalloc(sizeof(grpc_md_only_test_credentials));
+grpc_call_credentials* grpc_md_only_test_credentials_create(
+ const char* md_key, const char* md_value, bool is_async) {
+ grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)gpr_zalloc(
+ sizeof(grpc_md_only_test_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &md_only_test_vtable;
gpr_ref_init(&c->base.refcount, 1);
- c->md =
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(md_key),
- grpc_slice_from_copied_string(md_value));
+ c->md = grpc_mdelem_from_slices(grpc_slice_from_copied_string(md_key),
+ grpc_slice_from_copied_string(md_value));
c->is_async = is_async;
return &c->base;
}
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h
index aa0f3b6e20..0e9ff155d8 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.h
+++ b/src/core/lib/security/credentials/fake/fake_credentials.h
@@ -24,10 +24,10 @@
/* -- Fake transport security credentials. -- */
/* Creates a fake transport security credentials object for testing. */
-grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void);
+grpc_channel_credentials* grpc_fake_transport_security_credentials_create(void);
/* Creates a fake server transport security credentials object for testing. */
-grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
+grpc_server_credentials* grpc_fake_transport_security_server_credentials_create(
void);
/* Used to verify the target names given to the fake transport security
@@ -42,11 +42,11 @@ grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
* That is to say, LB channels have a heading list of LB targets separated from
* the list of backend targets by a semicolon. For non-LB channels, only the
* latter is present. */
-grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets);
+grpc_arg grpc_fake_transport_expected_targets_arg(char* expected_targets);
/* Return the value associated with the expected targets channel arg or NULL */
-const char *grpc_fake_transport_get_expected_targets(
- const grpc_channel_args *args);
+const char* grpc_fake_transport_get_expected_targets(
+ const grpc_channel_args* args);
/* -- Metadata-only Test credentials. -- */
diff --git a/src/core/lib/security/credentials/google_default/credentials_generic.c b/src/core/lib/security/credentials/google_default/credentials_generic.cc
index 4f79718f3d..15ae9d6428 100644
--- a/src/core/lib/security/credentials/google_default/credentials_generic.c
+++ b/src/core/lib/security/credentials/google_default/credentials_generic.cc
@@ -22,16 +22,16 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
-char *grpc_get_well_known_google_credentials_file_path_impl(void) {
- char *result = NULL;
- char *base = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR);
- if (base == NULL) {
- gpr_log(GPR_ERROR, "Could not get " GRPC_GOOGLE_CREDENTIALS_ENV_VAR
+char* grpc_get_well_known_google_credentials_file_path_impl(void) {
+ char* result = nullptr;
+ char* base = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR);
+ if (base == nullptr) {
+ gpr_log(GPR_ERROR, "Could not get " GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR
" environment variable.");
- return NULL;
+ return nullptr;
}
gpr_asprintf(&result, "%s/%s", base, GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX);
gpr_free(base);
diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.c b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index 691d66df69..dc19202033 100644
--- a/src/core/lib/security/credentials/google_default/google_default_credentials.c
+++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
@@ -24,16 +24,17 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/http/httpcli.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/iomgr/polling_entity.h"
+#include "src/core/lib/security/credentials/google_default/google_default_credentials.h"
#include "src/core/lib/security/credentials/jwt/jwt_credentials.h"
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
/* -- Constants. -- */
@@ -42,10 +43,10 @@
/* -- Default credentials. -- */
-static grpc_channel_credentials *default_credentials = NULL;
+static grpc_channel_credentials* default_credentials = nullptr;
static int compute_engine_detection_done = 0;
static gpr_mu g_state_mu;
-static gpr_mu *g_polling_mu;
+static gpr_mu* g_polling_mu;
static gpr_once g_once = GPR_ONCE_INIT;
static void init_default_credentials(void) { gpr_mu_init(&g_state_mu); }
@@ -57,17 +58,16 @@ typedef struct {
grpc_http_response response;
} compute_engine_detector;
-static void on_compute_engine_detection_http_response(grpc_exec_ctx *exec_ctx,
- void *user_data,
- grpc_error *error) {
- compute_engine_detector *detector = (compute_engine_detector *)user_data;
+static void on_compute_engine_detection_http_response(void* user_data,
+ grpc_error* error) {
+ compute_engine_detector* detector = (compute_engine_detector*)user_data;
if (error == GRPC_ERROR_NONE && detector->response.status == 200 &&
detector->response.hdr_count > 0) {
/* Internet providers can return a generic response to all requests, so
it is necessary to check that metadata header is present also. */
size_t i;
for (i = 0; i < detector->response.hdr_count; i++) {
- grpc_http_header *header = &detector->response.hdrs[i];
+ grpc_http_header* header = &detector->response.hdrs[i];
if (strcmp(header->key, "Metadata-Flavor") == 0 &&
strcmp(header->value, "Google") == 0) {
detector->success = 1;
@@ -79,16 +79,16 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx *exec_ctx,
detector->is_done = 1;
GRPC_LOG_IF_ERROR(
"Pollset kick",
- grpc_pollset_kick(exec_ctx,
- grpc_polling_entity_pollset(&detector->pollent), NULL));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&detector->pollent),
+ nullptr));
gpr_mu_unlock(g_polling_mu);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, grpc_error *e) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* e) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
+static int is_stack_running_on_compute_engine() {
compute_engine_detector detector;
grpc_httpcli_request request;
grpc_httpcli_context context;
@@ -96,9 +96,9 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
/* The http call is local. If it takes more than one sec, it is for sure not
on compute engine. */
- gpr_timespec max_detection_delay = gpr_time_from_seconds(1, GPR_TIMESPAN);
+ grpc_millis max_detection_delay = GPR_MS_PER_SEC;
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &g_polling_mu);
detector.pollent = grpc_polling_entity_create_from_pollset(pollset);
detector.is_done = 0;
@@ -106,49 +106,46 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
memset(&detector.response, 0, sizeof(detector.response));
memset(&request, 0, sizeof(grpc_httpcli_request));
- request.host = GRPC_COMPUTE_ENGINE_DETECTION_HOST;
- request.http.path = "/";
+ request.host = (char*)GRPC_COMPUTE_ENGINE_DETECTION_HOST;
+ request.http.path = (char*)"/";
grpc_httpcli_context_init(&context);
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("google_default_credentials");
grpc_httpcli_get(
- exec_ctx, &context, &detector.pollent, resource_quota, &request,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), max_detection_delay),
+ &context, &detector.pollent, resource_quota, &request,
+ grpc_core::ExecCtx::Get()->Now() + max_detection_delay,
GRPC_CLOSURE_CREATE(on_compute_engine_detection_http_response, &detector,
grpc_schedule_on_exec_ctx),
&detector.response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* Block until we get the response. This is not ideal but this should only be
called once for the lifetime of the process by the default credentials. */
gpr_mu_lock(g_polling_mu);
while (!detector.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(exec_ctx,
- grpc_polling_entity_pollset(&detector.pollent),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC)))) {
+ grpc_pollset_work(grpc_polling_entity_pollset(&detector.pollent),
+ &worker, GRPC_MILLIS_INF_FUTURE))) {
detector.is_done = 1;
detector.success = 0;
}
}
gpr_mu_unlock(g_polling_mu);
- grpc_httpcli_context_destroy(exec_ctx, &context);
+ grpc_httpcli_context_destroy(&context);
GRPC_CLOSURE_INIT(&destroy_closure, destroy_pollset,
grpc_polling_entity_pollset(&detector.pollent),
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx,
- grpc_polling_entity_pollset(&detector.pollent),
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&detector.pollent),
&destroy_closure);
- g_polling_mu = NULL;
- grpc_exec_ctx_flush(exec_ctx);
+ g_polling_mu = nullptr;
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(grpc_polling_entity_pollset(&detector.pollent));
grpc_http_response_destroy(&detector.response);
@@ -157,15 +154,15 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
}
/* Takes ownership of creds_path if not NULL. */
-static grpc_error *create_default_creds_from_path(
- grpc_exec_ctx *exec_ctx, char *creds_path, grpc_call_credentials **creds) {
- grpc_json *json = NULL;
+static grpc_error* create_default_creds_from_path(
+ char* creds_path, grpc_call_credentials** creds) {
+ grpc_json* json = nullptr;
grpc_auth_json_key key;
grpc_auth_refresh_token token;
- grpc_call_credentials *result = NULL;
+ grpc_call_credentials* result = nullptr;
grpc_slice creds_data = grpc_empty_slice();
- grpc_error *error = GRPC_ERROR_NONE;
- if (creds_path == NULL) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (creds_path == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("creds_path unset");
goto end;
}
@@ -174,8 +171,8 @@ static grpc_error *create_default_creds_from_path(
goto end;
}
json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data));
- if (json == NULL) {
+ (char*)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data));
+ if (json == nullptr) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"),
GRPC_ERROR_STR_RAW_BYTES, grpc_slice_ref_internal(creds_data));
@@ -187,8 +184,8 @@ static grpc_error *create_default_creds_from_path(
if (grpc_auth_json_key_is_valid(&key)) {
result =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- exec_ctx, key, grpc_max_auth_token_lifetime());
- if (result == NULL) {
+ key, grpc_max_auth_token_lifetime());
+ if (result == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"grpc_service_account_jwt_access_credentials_create_from_auth_json_"
"key failed");
@@ -201,7 +198,7 @@ static grpc_error *create_default_creds_from_path(
if (grpc_auth_refresh_token_is_valid(&token)) {
result =
grpc_refresh_token_credentials_create_from_auth_refresh_token(token);
- if (result == NULL) {
+ if (result == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"grpc_refresh_token_credentials_create_from_auth_refresh_token "
"failed");
@@ -210,21 +207,21 @@ static grpc_error *create_default_creds_from_path(
}
end:
- GPR_ASSERT((result == NULL) + (error == GRPC_ERROR_NONE) == 1);
- if (creds_path != NULL) gpr_free(creds_path);
- grpc_slice_unref_internal(exec_ctx, creds_data);
- if (json != NULL) grpc_json_destroy(json);
+ GPR_ASSERT((result == nullptr) + (error == GRPC_ERROR_NONE) == 1);
+ if (creds_path != nullptr) gpr_free(creds_path);
+ grpc_slice_unref_internal(creds_data);
+ if (json != nullptr) grpc_json_destroy(json);
*creds = result;
return error;
}
-grpc_channel_credentials *grpc_google_default_credentials_create(void) {
- grpc_channel_credentials *result = NULL;
- grpc_call_credentials *call_creds = NULL;
- grpc_error *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+grpc_channel_credentials* grpc_google_default_credentials_create(void) {
+ grpc_channel_credentials* result = nullptr;
+ grpc_call_credentials* call_creds = nullptr;
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create Google credentials");
- grpc_error *err;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_error* err;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_google_default_credentials_create(void)", 0, ());
@@ -232,33 +229,31 @@ grpc_channel_credentials *grpc_google_default_credentials_create(void) {
gpr_mu_lock(&g_state_mu);
- if (default_credentials != NULL) {
+ if (default_credentials != nullptr) {
result = grpc_channel_credentials_ref(default_credentials);
goto end;
}
/* First, try the environment variable. */
err = create_default_creds_from_path(
- &exec_ctx, gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR), &call_creds);
+ gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR), &call_creds);
if (err == GRPC_ERROR_NONE) goto end;
error = grpc_error_add_child(error, err);
/* Then the well-known file. */
err = create_default_creds_from_path(
- &exec_ctx, grpc_get_well_known_google_credentials_file_path(),
- &call_creds);
+ grpc_get_well_known_google_credentials_file_path(), &call_creds);
if (err == GRPC_ERROR_NONE) goto end;
error = grpc_error_add_child(error, err);
/* At last try to see if we're on compute engine (do the detection only once
since it requires a network test). */
if (!compute_engine_detection_done) {
- int need_compute_engine_creds =
- is_stack_running_on_compute_engine(&exec_ctx);
+ int need_compute_engine_creds = is_stack_running_on_compute_engine();
compute_engine_detection_done = 1;
if (need_compute_engine_creds) {
- call_creds = grpc_google_compute_engine_credentials_create(NULL);
- if (call_creds == NULL) {
+ call_creds = grpc_google_compute_engine_credentials_create(nullptr);
+ if (call_creds == nullptr) {
error = grpc_error_add_child(
error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to get credentials from network"));
@@ -267,53 +262,52 @@ grpc_channel_credentials *grpc_google_default_credentials_create(void) {
}
end:
- if (result == NULL) {
- if (call_creds != NULL) {
+ if (result == nullptr) {
+ if (call_creds != nullptr) {
/* Blend with default ssl credentials and add a global reference so that
it
can be cached and re-served. */
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(NULL, NULL, NULL);
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
default_credentials = grpc_channel_credentials_ref(
grpc_composite_channel_credentials_create(ssl_creds, call_creds,
- NULL));
- GPR_ASSERT(default_credentials != NULL);
- grpc_channel_credentials_unref(&exec_ctx, ssl_creds);
- grpc_call_credentials_unref(&exec_ctx, call_creds);
+ nullptr));
+ GPR_ASSERT(default_credentials != nullptr);
+ grpc_channel_credentials_unref(ssl_creds);
+ grpc_call_credentials_unref(call_creds);
result = default_credentials;
} else {
gpr_log(GPR_ERROR, "Could not create google default credentials.");
}
}
gpr_mu_unlock(&g_state_mu);
- if (result == NULL) {
+ if (result == nullptr) {
GRPC_LOG_IF_ERROR("grpc_google_default_credentials_create", error);
} else {
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return result;
}
void grpc_flush_cached_google_default_credentials(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_state_mu);
- if (default_credentials != NULL) {
- grpc_channel_credentials_unref(&exec_ctx, default_credentials);
- default_credentials = NULL;
+ if (default_credentials != nullptr) {
+ grpc_channel_credentials_unref(default_credentials);
+ default_credentials = nullptr;
}
compute_engine_detection_done = 0;
gpr_mu_unlock(&g_state_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* -- Well known credentials path. -- */
-static grpc_well_known_credentials_path_getter creds_path_getter = NULL;
+static grpc_well_known_credentials_path_getter creds_path_getter = nullptr;
-char *grpc_get_well_known_google_credentials_file_path(void) {
- if (creds_path_getter != NULL) return creds_path_getter();
+char* grpc_get_well_known_google_credentials_file_path(void) {
+ if (creds_path_getter != nullptr) return creds_path_getter();
return grpc_get_well_known_google_credentials_file_path_impl();
}
diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.h b/src/core/lib/security/credentials/google_default/google_default_credentials.h
index c3755e01a6..b163e48631 100644
--- a/src/core/lib/security/credentials/google_default/google_default_credentials.h
+++ b/src/core/lib/security/credentials/google_default/google_default_credentials.h
@@ -42,4 +42,4 @@
void grpc_flush_cached_google_default_credentials(void);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \
- */
+ */
diff --git a/src/core/lib/security/credentials/iam/iam_credentials.c b/src/core/lib/security/credentials/iam/iam_credentials.cc
index 3de8319d98..75acb2a58e 100644
--- a/src/core/lib/security/credentials/iam/iam_credentials.c
+++ b/src/core/lib/security/credentials/iam/iam_credentials.cc
@@ -27,59 +27,56 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-static void iam_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_google_iam_credentials *c = (grpc_google_iam_credentials *)creds;
- grpc_credentials_mdelem_array_destroy(exec_ctx, &c->md_array);
+static void iam_destruct(grpc_call_credentials* creds) {
+ grpc_google_iam_credentials* c = (grpc_google_iam_credentials*)creds;
+ grpc_credentials_mdelem_array_destroy(&c->md_array);
}
-static bool iam_get_request_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds,
- grpc_polling_entity *pollent,
+static bool iam_get_request_metadata(grpc_call_credentials* creds,
+ grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array,
- grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_google_iam_credentials *c = (grpc_google_iam_credentials *)creds;
+ grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata,
+ grpc_error** error) {
+ grpc_google_iam_credentials* c = (grpc_google_iam_credentials*)creds;
grpc_credentials_mdelem_array_append(md_array, &c->md_array);
return true;
}
static void iam_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
static grpc_call_credentials_vtable iam_vtable = {
iam_destruct, iam_get_request_metadata, iam_cancel_get_request_metadata};
-grpc_call_credentials *grpc_google_iam_credentials_create(
- const char *token, const char *authority_selector, void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+grpc_call_credentials* grpc_google_iam_credentials_create(
+ const char* token, const char* authority_selector, void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_iam_credentials_create(token=%s, authority_selector=%s, "
"reserved=%p)",
3, (token, authority_selector, reserved));
- GPR_ASSERT(reserved == NULL);
- GPR_ASSERT(token != NULL);
- GPR_ASSERT(authority_selector != NULL);
- grpc_google_iam_credentials *c = gpr_zalloc(sizeof(*c));
+ GPR_ASSERT(reserved == nullptr);
+ GPR_ASSERT(token != nullptr);
+ GPR_ASSERT(authority_selector != nullptr);
+ grpc_google_iam_credentials* c =
+ (grpc_google_iam_credentials*)gpr_zalloc(sizeof(*c));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_IAM;
c->base.vtable = &iam_vtable;
gpr_ref_init(&c->base.refcount, 1);
grpc_mdelem md = grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_from_static_string(GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY),
grpc_slice_from_copied_string(token));
grpc_credentials_mdelem_array_add(&c->md_array, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
md = grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_from_static_string(GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY),
grpc_slice_from_copied_string(authority_selector));
grpc_credentials_mdelem_array_add(&c->md_array, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
return &c->base;
}
diff --git a/src/core/lib/security/credentials/jwt/json_token.c b/src/core/lib/security/credentials/jwt/json_token.cc
index fff71255a5..078f04ed11 100644
--- a/src/core/lib/security/credentials/jwt/json_token.c
+++ b/src/core/lib/security/credentials/jwt/json_token.cc
@@ -20,18 +20,21 @@
#include <string.h>
+#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/util/json_util.h"
#include "src/core/lib/slice/b64.h"
-#include "src/core/lib/support/string.h"
+extern "C" {
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
+}
/* --- Constants. --- */
@@ -49,30 +52,31 @@ gpr_timespec grpc_max_auth_token_lifetime() {
/* --- Override for testing. --- */
-static grpc_jwt_encode_and_sign_override g_jwt_encode_and_sign_override = NULL;
+static grpc_jwt_encode_and_sign_override g_jwt_encode_and_sign_override =
+ nullptr;
/* --- grpc_auth_json_key. --- */
-int grpc_auth_json_key_is_valid(const grpc_auth_json_key *json_key) {
- return (json_key != NULL) &&
+int grpc_auth_json_key_is_valid(const grpc_auth_json_key* json_key) {
+ return (json_key != nullptr) &&
strcmp(json_key->type, GRPC_AUTH_JSON_TYPE_INVALID);
}
-grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json *json) {
+grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json* json) {
grpc_auth_json_key result;
- BIO *bio = NULL;
- const char *prop_value;
+ BIO* bio = nullptr;
+ const char* prop_value;
int success = 0;
memset(&result, 0, sizeof(grpc_auth_json_key));
result.type = GRPC_AUTH_JSON_TYPE_INVALID;
- if (json == NULL) {
+ if (json == nullptr) {
gpr_log(GPR_ERROR, "Invalid json.");
goto end;
}
prop_value = grpc_json_get_string_property(json, "type");
- if (prop_value == NULL ||
+ if (prop_value == nullptr ||
strcmp(prop_value, GRPC_AUTH_JSON_TYPE_SERVICE_ACCOUNT)) {
goto end;
}
@@ -87,7 +91,7 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json *json) {
}
prop_value = grpc_json_get_string_property(json, "private_key");
- if (prop_value == NULL) {
+ if (prop_value == nullptr) {
goto end;
}
bio = BIO_new(BIO_s_mem());
@@ -96,56 +100,57 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json *json) {
gpr_log(GPR_ERROR, "Could not write into openssl BIO.");
goto end;
}
- result.private_key = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, "");
- if (result.private_key == NULL) {
+ result.private_key =
+ PEM_read_bio_RSAPrivateKey(bio, nullptr, nullptr, (void*)"");
+ if (result.private_key == nullptr) {
gpr_log(GPR_ERROR, "Could not deserialize private key.");
goto end;
}
success = 1;
end:
- if (bio != NULL) BIO_free(bio);
+ if (bio != nullptr) BIO_free(bio);
if (!success) grpc_auth_json_key_destruct(&result);
return result;
}
grpc_auth_json_key grpc_auth_json_key_create_from_string(
- const char *json_string) {
- char *scratchpad = gpr_strdup(json_string);
- grpc_json *json = grpc_json_parse_string(scratchpad);
+ const char* json_string) {
+ char* scratchpad = gpr_strdup(json_string);
+ grpc_json* json = grpc_json_parse_string(scratchpad);
grpc_auth_json_key result = grpc_auth_json_key_create_from_json(json);
- if (json != NULL) grpc_json_destroy(json);
+ if (json != nullptr) grpc_json_destroy(json);
gpr_free(scratchpad);
return result;
}
-void grpc_auth_json_key_destruct(grpc_auth_json_key *json_key) {
- if (json_key == NULL) return;
+void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key) {
+ if (json_key == nullptr) return;
json_key->type = GRPC_AUTH_JSON_TYPE_INVALID;
- if (json_key->client_id != NULL) {
+ if (json_key->client_id != nullptr) {
gpr_free(json_key->client_id);
- json_key->client_id = NULL;
+ json_key->client_id = nullptr;
}
- if (json_key->private_key_id != NULL) {
+ if (json_key->private_key_id != nullptr) {
gpr_free(json_key->private_key_id);
- json_key->private_key_id = NULL;
+ json_key->private_key_id = nullptr;
}
- if (json_key->client_email != NULL) {
+ if (json_key->client_email != nullptr) {
gpr_free(json_key->client_email);
- json_key->client_email = NULL;
+ json_key->client_email = nullptr;
}
- if (json_key->private_key != NULL) {
+ if (json_key->private_key != nullptr) {
RSA_free(json_key->private_key);
- json_key->private_key = NULL;
+ json_key->private_key = nullptr;
}
}
/* --- jwt encoding and signature. --- */
-static grpc_json *create_child(grpc_json *brother, grpc_json *parent,
- const char *key, const char *value,
+static grpc_json* create_child(grpc_json* brother, grpc_json* parent,
+ const char* key, const char* value,
grpc_json_type type) {
- grpc_json *child = grpc_json_create(type);
+ grpc_json* child = grpc_json_create(type);
if (brother) brother->next = child;
if (!parent->child) parent->child = child;
child->parent = parent;
@@ -154,13 +159,13 @@ static grpc_json *create_child(grpc_json *brother, grpc_json *parent,
return child;
}
-static char *encoded_jwt_header(const char *key_id, const char *algorithm) {
- grpc_json *json = grpc_json_create(GRPC_JSON_OBJECT);
- grpc_json *child = NULL;
- char *json_str = NULL;
- char *result = NULL;
+static char* encoded_jwt_header(const char* key_id, const char* algorithm) {
+ grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT);
+ grpc_json* child = nullptr;
+ char* json_str = nullptr;
+ char* result = nullptr;
- child = create_child(NULL, json, "alg", algorithm, GRPC_JSON_STRING);
+ child = create_child(nullptr, json, "alg", algorithm, GRPC_JSON_STRING);
child = create_child(child, json, "typ", GRPC_JWT_TYPE, GRPC_JSON_STRING);
create_child(child, json, "kid", key_id, GRPC_JSON_STRING);
@@ -171,13 +176,13 @@ static char *encoded_jwt_header(const char *key_id, const char *algorithm) {
return result;
}
-static char *encoded_jwt_claim(const grpc_auth_json_key *json_key,
- const char *audience,
- gpr_timespec token_lifetime, const char *scope) {
- grpc_json *json = grpc_json_create(GRPC_JSON_OBJECT);
- grpc_json *child = NULL;
- char *json_str = NULL;
- char *result = NULL;
+static char* encoded_jwt_claim(const grpc_auth_json_key* json_key,
+ const char* audience,
+ gpr_timespec token_lifetime, const char* scope) {
+ grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT);
+ grpc_json* child = nullptr;
+ char* json_str = nullptr;
+ char* result = nullptr;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec expiration = gpr_time_add(now, token_lifetime);
char now_str[GPR_LTOA_MIN_BUFSIZE];
@@ -189,9 +194,9 @@ static char *encoded_jwt_claim(const grpc_auth_json_key *json_key,
int64_ttoa(now.tv_sec, now_str);
int64_ttoa(expiration.tv_sec, expiration_str);
- child =
- create_child(NULL, json, "iss", json_key->client_email, GRPC_JSON_STRING);
- if (scope != NULL) {
+ child = create_child(nullptr, json, "iss", json_key->client_email,
+ GRPC_JSON_STRING);
+ if (scope != nullptr) {
child = create_child(child, json, "scope", scope, GRPC_JSON_STRING);
} else {
/* Unscoped JWTs need a sub field. */
@@ -210,12 +215,12 @@ static char *encoded_jwt_claim(const grpc_auth_json_key *json_key,
return result;
}
-static char *dot_concat_and_free_strings(char *str1, char *str2) {
+static char* dot_concat_and_free_strings(char* str1, char* str2) {
size_t str1_len = strlen(str1);
size_t str2_len = strlen(str2);
size_t result_len = str1_len + 1 /* dot */ + str2_len;
- char *result = gpr_malloc(result_len + 1 /* NULL terminated */);
- char *current = result;
+ char* result = (char*)gpr_malloc(result_len + 1 /* NULL terminated */);
+ char* current = result;
memcpy(current, str1, str1_len);
current += str1_len;
*(current++) = '.';
@@ -229,32 +234,32 @@ static char *dot_concat_and_free_strings(char *str1, char *str2) {
return result;
}
-const EVP_MD *openssl_digest_from_algorithm(const char *algorithm) {
+const EVP_MD* openssl_digest_from_algorithm(const char* algorithm) {
if (strcmp(algorithm, GRPC_JWT_RSA_SHA256_ALGORITHM) == 0) {
return EVP_sha256();
} else {
gpr_log(GPR_ERROR, "Unknown algorithm %s.", algorithm);
- return NULL;
+ return nullptr;
}
}
-char *compute_and_encode_signature(const grpc_auth_json_key *json_key,
- const char *signature_algorithm,
- const char *to_sign) {
- const EVP_MD *md = openssl_digest_from_algorithm(signature_algorithm);
- EVP_MD_CTX *md_ctx = NULL;
- EVP_PKEY *key = EVP_PKEY_new();
+char* compute_and_encode_signature(const grpc_auth_json_key* json_key,
+ const char* signature_algorithm,
+ const char* to_sign) {
+ const EVP_MD* md = openssl_digest_from_algorithm(signature_algorithm);
+ EVP_MD_CTX* md_ctx = nullptr;
+ EVP_PKEY* key = EVP_PKEY_new();
size_t sig_len = 0;
- unsigned char *sig = NULL;
- char *result = NULL;
- if (md == NULL) return NULL;
+ unsigned char* sig = nullptr;
+ char* result = nullptr;
+ if (md == nullptr) return nullptr;
md_ctx = EVP_MD_CTX_create();
- if (md_ctx == NULL) {
+ if (md_ctx == nullptr) {
gpr_log(GPR_ERROR, "Could not create MD_CTX");
goto end;
}
EVP_PKEY_set1_RSA(key, json_key->private_key);
- if (EVP_DigestSignInit(md_ctx, NULL, md, NULL, key) != 1) {
+ if (EVP_DigestSignInit(md_ctx, nullptr, md, nullptr, key) != 1) {
gpr_log(GPR_ERROR, "DigestInit failed.");
goto end;
}
@@ -262,11 +267,11 @@ char *compute_and_encode_signature(const grpc_auth_json_key *json_key,
gpr_log(GPR_ERROR, "DigestUpdate failed.");
goto end;
}
- if (EVP_DigestSignFinal(md_ctx, NULL, &sig_len) != 1) {
+ if (EVP_DigestSignFinal(md_ctx, nullptr, &sig_len) != 1) {
gpr_log(GPR_ERROR, "DigestFinal (get signature length) failed.");
goto end;
}
- sig = gpr_malloc(sig_len);
+ sig = (unsigned char*)gpr_malloc(sig_len);
if (EVP_DigestSignFinal(md_ctx, sig, &sig_len) != 1) {
gpr_log(GPR_ERROR, "DigestFinal (signature compute) failed.");
goto end;
@@ -274,27 +279,27 @@ char *compute_and_encode_signature(const grpc_auth_json_key *json_key,
result = grpc_base64_encode(sig, sig_len, 1, 0);
end:
- if (key != NULL) EVP_PKEY_free(key);
- if (md_ctx != NULL) EVP_MD_CTX_destroy(md_ctx);
- if (sig != NULL) gpr_free(sig);
+ if (key != nullptr) EVP_PKEY_free(key);
+ if (md_ctx != nullptr) EVP_MD_CTX_destroy(md_ctx);
+ if (sig != nullptr) gpr_free(sig);
return result;
}
-char *grpc_jwt_encode_and_sign(const grpc_auth_json_key *json_key,
- const char *audience,
- gpr_timespec token_lifetime, const char *scope) {
- if (g_jwt_encode_and_sign_override != NULL) {
+char* grpc_jwt_encode_and_sign(const grpc_auth_json_key* json_key,
+ const char* audience,
+ gpr_timespec token_lifetime, const char* scope) {
+ if (g_jwt_encode_and_sign_override != nullptr) {
return g_jwt_encode_and_sign_override(json_key, audience, token_lifetime,
scope);
} else {
- const char *sig_algo = GRPC_JWT_RSA_SHA256_ALGORITHM;
- char *to_sign = dot_concat_and_free_strings(
+ const char* sig_algo = GRPC_JWT_RSA_SHA256_ALGORITHM;
+ char* to_sign = dot_concat_and_free_strings(
encoded_jwt_header(json_key->private_key_id, sig_algo),
encoded_jwt_claim(json_key, audience, token_lifetime, scope));
- char *sig = compute_and_encode_signature(json_key, sig_algo, to_sign);
- if (sig == NULL) {
+ char* sig = compute_and_encode_signature(json_key, sig_algo, to_sign);
+ if (sig == nullptr) {
gpr_free(to_sign);
- return NULL;
+ return nullptr;
}
return dot_concat_and_free_strings(to_sign, sig);
}
diff --git a/src/core/lib/security/credentials/jwt/json_token.h b/src/core/lib/security/credentials/jwt/json_token.h
index e50790ef2e..9b774882b7 100644
--- a/src/core/lib/security/credentials/jwt/json_token.h
+++ b/src/core/lib/security/credentials/jwt/json_token.h
@@ -31,40 +31,40 @@
/* --- auth_json_key parsing. --- */
typedef struct {
- const char *type;
- char *private_key_id;
- char *client_id;
- char *client_email;
- RSA *private_key;
+ const char* type;
+ char* private_key_id;
+ char* client_id;
+ char* client_email;
+ RSA* private_key;
} grpc_auth_json_key;
/* Returns 1 if the object is valid, 0 otherwise. */
-int grpc_auth_json_key_is_valid(const grpc_auth_json_key *json_key);
+int grpc_auth_json_key_is_valid(const grpc_auth_json_key* json_key);
/* Creates a json_key object from string. Returns an invalid object if a parsing
error has been encountered. */
grpc_auth_json_key grpc_auth_json_key_create_from_string(
- const char *json_string);
+ const char* json_string);
/* Creates a json_key object from parsed json. Returns an invalid object if a
parsing error has been encountered. */
-grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json *json);
+grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json* json);
/* Destructs the object. */
-void grpc_auth_json_key_destruct(grpc_auth_json_key *json_key);
+void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key);
/* --- json token encoding and signing. --- */
/* Caller is responsible for calling gpr_free on the returned value. May return
NULL on invalid input. The scope parameter may be NULL. */
-char *grpc_jwt_encode_and_sign(const grpc_auth_json_key *json_key,
- const char *audience,
- gpr_timespec token_lifetime, const char *scope);
+char* grpc_jwt_encode_and_sign(const grpc_auth_json_key* json_key,
+ const char* audience,
+ gpr_timespec token_lifetime, const char* scope);
/* Override encode_and_sign function for testing. */
-typedef char *(*grpc_jwt_encode_and_sign_override)(
- const grpc_auth_json_key *json_key, const char *audience,
- gpr_timespec token_lifetime, const char *scope);
+typedef char* (*grpc_jwt_encode_and_sign_override)(
+ const grpc_auth_json_key* json_key, const char* audience,
+ gpr_timespec token_lifetime, const char* scope);
/* Set a custom encode_and_sign override for testing. */
void grpc_jwt_encode_and_sign_set_override(
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.c b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
index 02c82e99ba..2404e860e4 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.c
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
@@ -16,8 +16,11 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include "src/core/lib/security/credentials/jwt/jwt_credentials.h"
+#include <inttypes.h>
#include <string.h>
#include "src/core/lib/surface/api_trace.h"
@@ -27,35 +30,32 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-static void jwt_reset_cache(grpc_exec_ctx *exec_ctx,
- grpc_service_account_jwt_access_credentials *c) {
- GRPC_MDELEM_UNREF(exec_ctx, c->cached.jwt_md);
+static void jwt_reset_cache(grpc_service_account_jwt_access_credentials* c) {
+ GRPC_MDELEM_UNREF(c->cached.jwt_md);
c->cached.jwt_md = GRPC_MDNULL;
- if (c->cached.service_url != NULL) {
+ if (c->cached.service_url != nullptr) {
gpr_free(c->cached.service_url);
- c->cached.service_url = NULL;
+ c->cached.service_url = nullptr;
}
c->cached.jwt_expiration = gpr_inf_past(GPR_CLOCK_REALTIME);
}
-static void jwt_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_service_account_jwt_access_credentials *c =
- (grpc_service_account_jwt_access_credentials *)creds;
+static void jwt_destruct(grpc_call_credentials* creds) {
+ grpc_service_account_jwt_access_credentials* c =
+ (grpc_service_account_jwt_access_credentials*)creds;
grpc_auth_json_key_destruct(&c->key);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
gpr_mu_destroy(&c->cache_mu);
}
-static bool jwt_get_request_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds,
- grpc_polling_entity *pollent,
+static bool jwt_get_request_metadata(grpc_call_credentials* creds,
+ grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array,
- grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_service_account_jwt_access_credentials *c =
- (grpc_service_account_jwt_access_credentials *)creds;
+ grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata,
+ grpc_error** error) {
+ grpc_service_account_jwt_access_credentials* c =
+ (grpc_service_account_jwt_access_credentials*)creds;
gpr_timespec refresh_threshold = gpr_time_from_seconds(
GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS, GPR_TIMESPAN);
@@ -63,7 +63,7 @@ static bool jwt_get_request_metadata(grpc_exec_ctx *exec_ctx,
grpc_mdelem jwt_md = GRPC_MDNULL;
{
gpr_mu_lock(&c->cache_mu);
- if (c->cached.service_url != NULL &&
+ if (c->cached.service_url != nullptr &&
strcmp(c->cached.service_url, context.service_url) == 0 &&
!GRPC_MDISNULL(c->cached.jwt_md) &&
(gpr_time_cmp(gpr_time_sub(c->cached.jwt_expiration,
@@ -75,21 +75,20 @@ static bool jwt_get_request_metadata(grpc_exec_ctx *exec_ctx,
}
if (GRPC_MDISNULL(jwt_md)) {
- char *jwt = NULL;
+ char* jwt = nullptr;
/* Generate a new jwt. */
gpr_mu_lock(&c->cache_mu);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
jwt = grpc_jwt_encode_and_sign(&c->key, context.service_url,
- c->jwt_lifetime, NULL);
- if (jwt != NULL) {
- char *md_value;
+ c->jwt_lifetime, nullptr);
+ if (jwt != nullptr) {
+ char* md_value;
gpr_asprintf(&md_value, "Bearer %s", jwt);
gpr_free(jwt);
c->cached.jwt_expiration =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c->jwt_lifetime);
c->cached.service_url = gpr_strdup(context.service_url);
c->cached.jwt_md = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(md_value));
gpr_free(md_value);
@@ -100,7 +99,7 @@ static bool jwt_get_request_metadata(grpc_exec_ctx *exec_ctx,
if (!GRPC_MDISNULL(jwt_md)) {
grpc_credentials_mdelem_array_add(md_array, jwt_md);
- GRPC_MDELEM_UNREF(exec_ctx, jwt_md);
+ GRPC_MDELEM_UNREF(jwt_md);
} else {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT.");
}
@@ -108,24 +107,24 @@ static bool jwt_get_request_metadata(grpc_exec_ctx *exec_ctx,
}
static void jwt_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
static grpc_call_credentials_vtable jwt_vtable = {
jwt_destruct, jwt_get_request_metadata, jwt_cancel_get_request_metadata};
-grpc_call_credentials *
+grpc_call_credentials*
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- grpc_exec_ctx *exec_ctx, grpc_auth_json_key key,
- gpr_timespec token_lifetime) {
- grpc_service_account_jwt_access_credentials *c;
+ grpc_auth_json_key key, gpr_timespec token_lifetime) {
+ grpc_service_account_jwt_access_credentials* c;
if (!grpc_auth_json_key_is_valid(&key)) {
gpr_log(GPR_ERROR, "Invalid input for jwt credentials creation");
- return NULL;
+ return nullptr;
}
- c = gpr_zalloc(sizeof(grpc_service_account_jwt_access_credentials));
+ c = (grpc_service_account_jwt_access_credentials*)gpr_zalloc(
+ sizeof(grpc_service_account_jwt_access_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_JWT;
gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &jwt_vtable;
@@ -139,37 +138,37 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
}
c->jwt_lifetime = token_lifetime;
gpr_mu_init(&c->cache_mu);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
return &c->base;
}
-static char *redact_private_key(const char *json_key) {
- char *json_copy = gpr_strdup(json_key);
- grpc_json *json = grpc_json_parse_string(json_copy);
+static char* redact_private_key(const char* json_key) {
+ char* json_copy = gpr_strdup(json_key);
+ grpc_json* json = grpc_json_parse_string(json_copy);
if (!json) {
gpr_free(json_copy);
return gpr_strdup("<Json failed to parse.>");
}
- const char *redacted = "<redacted>";
- grpc_json *current = json->child;
+ const char* redacted = "<redacted>";
+ grpc_json* current = json->child;
while (current) {
if (current->type == GRPC_JSON_STRING &&
strcmp(current->key, "private_key") == 0) {
- current->value = (char *)redacted;
+ current->value = (char*)redacted;
break;
}
current = current->next;
}
- char *clean_json = grpc_json_dump_to_string(json, 2);
+ char* clean_json = grpc_json_dump_to_string(json, 2);
gpr_free(json_copy);
grpc_json_destroy(json);
return clean_json;
}
-grpc_call_credentials *grpc_service_account_jwt_access_credentials_create(
- const char *json_key, gpr_timespec token_lifetime, void *reserved) {
- if (GRPC_TRACER_ON(grpc_api_trace)) {
- char *clean_json = redact_private_key(json_key);
+grpc_call_credentials* grpc_service_account_jwt_access_credentials_create(
+ const char* json_key, gpr_timespec token_lifetime, void* reserved) {
+ if (grpc_api_trace.enabled()) {
+ char* clean_json = redact_private_key(json_key);
gpr_log(GPR_INFO,
"grpc_service_account_jwt_access_credentials_create("
"json_key=%s, "
@@ -181,12 +180,11 @@ grpc_call_credentials *grpc_service_account_jwt_access_credentials_create(
(int)token_lifetime.clock_type, reserved);
gpr_free(clean_json);
}
- GPR_ASSERT(reserved == NULL);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_call_credentials *creds =
+ GPR_ASSERT(reserved == nullptr);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- &exec_ctx, grpc_auth_json_key_create_from_string(json_key),
- token_lifetime);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_auth_json_key_create_from_string(json_key), token_lifetime);
+
return creds;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h
index 07f4022669..f58a8b67ba 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.h
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h
@@ -30,7 +30,7 @@ typedef struct {
gpr_mu cache_mu;
struct {
grpc_mdelem jwt_md;
- char *service_url;
+ char* service_url;
gpr_timespec jwt_expiration;
} cached;
@@ -40,9 +40,8 @@ typedef struct {
// Private constructor for jwt credentials from an already parsed json key.
// Takes ownership of the key.
-grpc_call_credentials *
+grpc_call_credentials*
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- grpc_exec_ctx *exec_ctx, grpc_auth_json_key key,
- gpr_timespec token_lifetime);
+ grpc_auth_json_key key, gpr_timespec token_lifetime);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
index a27284bc50..860506df39 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.c
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
@@ -26,18 +26,21 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
+
+extern "C" {
#include <openssl/pem.h>
+}
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/http/httpcli.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "src/core/tsi/ssl_types.h"
/* --- Utils. --- */
-const char *grpc_jwt_verifier_status_to_string(
+const char* grpc_jwt_verifier_status_to_string(
grpc_jwt_verifier_status status) {
switch (status) {
case GRPC_JWT_VERIFIER_OK:
@@ -59,7 +62,7 @@ const char *grpc_jwt_verifier_status_to_string(
}
}
-static const EVP_MD *evp_md_from_alg(const char *alg) {
+static const EVP_MD* evp_md_from_alg(const char* alg) {
if (strcmp(alg, "RS256") == 0) {
return EVP_sha256();
} else if (strcmp(alg, "RS384") == 0) {
@@ -67,91 +70,89 @@ static const EVP_MD *evp_md_from_alg(const char *alg) {
} else if (strcmp(alg, "RS512") == 0) {
return EVP_sha512();
} else {
- return NULL;
+ return nullptr;
}
}
-static grpc_json *parse_json_part_from_jwt(grpc_exec_ctx *exec_ctx,
- const char *str, size_t len,
- grpc_slice *buffer) {
- grpc_json *json;
+static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
+ grpc_slice* buffer) {
+ grpc_json* json;
- *buffer = grpc_base64_decode_with_len(exec_ctx, str, len, 1);
+ *buffer = grpc_base64_decode_with_len(str, len, 1);
if (GRPC_SLICE_IS_EMPTY(*buffer)) {
gpr_log(GPR_ERROR, "Invalid base64.");
- return NULL;
+ return nullptr;
}
- json = grpc_json_parse_string_with_len((char *)GRPC_SLICE_START_PTR(*buffer),
+ json = grpc_json_parse_string_with_len((char*)GRPC_SLICE_START_PTR(*buffer),
GRPC_SLICE_LENGTH(*buffer));
- if (json == NULL) {
- grpc_slice_unref_internal(exec_ctx, *buffer);
+ if (json == nullptr) {
+ grpc_slice_unref_internal(*buffer);
gpr_log(GPR_ERROR, "JSON parsing error.");
}
return json;
}
-static const char *validate_string_field(const grpc_json *json,
- const char *key) {
+static const char* validate_string_field(const grpc_json* json,
+ const char* key) {
if (json->type != GRPC_JSON_STRING) {
gpr_log(GPR_ERROR, "Invalid %s field [%s]", key, json->value);
- return NULL;
+ return nullptr;
}
return json->value;
}
-static gpr_timespec validate_time_field(const grpc_json *json,
- const char *key) {
+static gpr_timespec validate_time_field(const grpc_json* json,
+ const char* key) {
gpr_timespec result = gpr_time_0(GPR_CLOCK_REALTIME);
if (json->type != GRPC_JSON_NUMBER) {
gpr_log(GPR_ERROR, "Invalid %s field [%s]", key, json->value);
return result;
}
- result.tv_sec = strtol(json->value, NULL, 10);
+ result.tv_sec = strtol(json->value, nullptr, 10);
return result;
}
/* --- JOSE header. see http://tools.ietf.org/html/rfc7515#section-4 --- */
typedef struct {
- const char *alg;
- const char *kid;
- const char *typ;
+ const char* alg;
+ const char* kid;
+ const char* typ;
/* TODO(jboeuf): Add others as needed (jku, jwk, x5u, x5c and so on...). */
grpc_slice buffer;
} jose_header;
-static void jose_header_destroy(grpc_exec_ctx *exec_ctx, jose_header *h) {
- grpc_slice_unref_internal(exec_ctx, h->buffer);
+static void jose_header_destroy(jose_header* h) {
+ grpc_slice_unref_internal(h->buffer);
gpr_free(h);
}
/* Takes ownership of json and buffer. */
-static jose_header *jose_header_from_json(grpc_exec_ctx *exec_ctx,
- grpc_json *json, grpc_slice buffer) {
- grpc_json *cur;
- jose_header *h = gpr_zalloc(sizeof(jose_header));
+static jose_header* jose_header_from_json(grpc_json* json, grpc_slice buffer) {
+ grpc_json* cur;
+ jose_header* h = (jose_header*)gpr_zalloc(sizeof(jose_header));
h->buffer = buffer;
- for (cur = json->child; cur != NULL; cur = cur->next) {
+ for (cur = json->child; cur != nullptr; cur = cur->next) {
if (strcmp(cur->key, "alg") == 0) {
/* We only support RSA-1.5 signatures for now.
Beware of this if we add HMAC support:
https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/
*/
if (cur->type != GRPC_JSON_STRING || strncmp(cur->value, "RS", 2) ||
- evp_md_from_alg(cur->value) == NULL) {
+ evp_md_from_alg(cur->value) == nullptr) {
gpr_log(GPR_ERROR, "Invalid alg field [%s]", cur->value);
goto error;
}
h->alg = cur->value;
} else if (strcmp(cur->key, "typ") == 0) {
h->typ = validate_string_field(cur, "typ");
- if (h->typ == NULL) goto error;
+ if (h->typ == nullptr) goto error;
} else if (strcmp(cur->key, "kid") == 0) {
h->kid = validate_string_field(cur, "kid");
- if (h->kid == NULL) goto error;
+ if (h->kid == nullptr) goto error;
}
}
- if (h->alg == NULL) {
+ if (h->alg == nullptr) {
gpr_log(GPR_ERROR, "Missing alg field.");
goto error;
}
@@ -161,77 +162,77 @@ static jose_header *jose_header_from_json(grpc_exec_ctx *exec_ctx,
error:
grpc_json_destroy(json);
- jose_header_destroy(exec_ctx, h);
- return NULL;
+ jose_header_destroy(h);
+ return nullptr;
}
/* --- JWT claims. see http://tools.ietf.org/html/rfc7519#section-4.1 */
struct grpc_jwt_claims {
/* Well known properties already parsed. */
- const char *sub;
- const char *iss;
- const char *aud;
- const char *jti;
+ const char* sub;
+ const char* iss;
+ const char* aud;
+ const char* jti;
gpr_timespec iat;
gpr_timespec exp;
gpr_timespec nbf;
- grpc_json *json;
+ grpc_json* json;
grpc_slice buffer;
};
-void grpc_jwt_claims_destroy(grpc_exec_ctx *exec_ctx, grpc_jwt_claims *claims) {
+void grpc_jwt_claims_destroy(grpc_jwt_claims* claims) {
grpc_json_destroy(claims->json);
- grpc_slice_unref_internal(exec_ctx, claims->buffer);
+ grpc_slice_unref_internal(claims->buffer);
gpr_free(claims);
}
-const grpc_json *grpc_jwt_claims_json(const grpc_jwt_claims *claims) {
- if (claims == NULL) return NULL;
+const grpc_json* grpc_jwt_claims_json(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return nullptr;
return claims->json;
}
-const char *grpc_jwt_claims_subject(const grpc_jwt_claims *claims) {
- if (claims == NULL) return NULL;
+const char* grpc_jwt_claims_subject(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return nullptr;
return claims->sub;
}
-const char *grpc_jwt_claims_issuer(const grpc_jwt_claims *claims) {
- if (claims == NULL) return NULL;
+const char* grpc_jwt_claims_issuer(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return nullptr;
return claims->iss;
}
-const char *grpc_jwt_claims_id(const grpc_jwt_claims *claims) {
- if (claims == NULL) return NULL;
+const char* grpc_jwt_claims_id(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return nullptr;
return claims->jti;
}
-const char *grpc_jwt_claims_audience(const grpc_jwt_claims *claims) {
- if (claims == NULL) return NULL;
+const char* grpc_jwt_claims_audience(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return nullptr;
return claims->aud;
}
-gpr_timespec grpc_jwt_claims_issued_at(const grpc_jwt_claims *claims) {
- if (claims == NULL) return gpr_inf_past(GPR_CLOCK_REALTIME);
+gpr_timespec grpc_jwt_claims_issued_at(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return gpr_inf_past(GPR_CLOCK_REALTIME);
return claims->iat;
}
-gpr_timespec grpc_jwt_claims_expires_at(const grpc_jwt_claims *claims) {
- if (claims == NULL) return gpr_inf_future(GPR_CLOCK_REALTIME);
+gpr_timespec grpc_jwt_claims_expires_at(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return gpr_inf_future(GPR_CLOCK_REALTIME);
return claims->exp;
}
-gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims *claims) {
- if (claims == NULL) return gpr_inf_past(GPR_CLOCK_REALTIME);
+gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims) {
+ if (claims == nullptr) return gpr_inf_past(GPR_CLOCK_REALTIME);
return claims->nbf;
}
/* Takes ownership of json and buffer even in case of failure. */
-grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_exec_ctx *exec_ctx,
- grpc_json *json, grpc_slice buffer) {
- grpc_json *cur;
- grpc_jwt_claims *claims = gpr_malloc(sizeof(grpc_jwt_claims));
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json, grpc_slice buffer) {
+ grpc_json* cur;
+ grpc_jwt_claims* claims =
+ (grpc_jwt_claims*)gpr_malloc(sizeof(grpc_jwt_claims));
memset(claims, 0, sizeof(grpc_jwt_claims));
claims->json = json;
claims->buffer = buffer;
@@ -240,19 +241,19 @@ grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_exec_ctx *exec_ctx,
claims->exp = gpr_inf_future(GPR_CLOCK_REALTIME);
/* Per the spec, all fields are optional. */
- for (cur = json->child; cur != NULL; cur = cur->next) {
+ for (cur = json->child; cur != nullptr; cur = cur->next) {
if (strcmp(cur->key, "sub") == 0) {
claims->sub = validate_string_field(cur, "sub");
- if (claims->sub == NULL) goto error;
+ if (claims->sub == nullptr) goto error;
} else if (strcmp(cur->key, "iss") == 0) {
claims->iss = validate_string_field(cur, "iss");
- if (claims->iss == NULL) goto error;
+ if (claims->iss == nullptr) goto error;
} else if (strcmp(cur->key, "aud") == 0) {
claims->aud = validate_string_field(cur, "aud");
- if (claims->aud == NULL) goto error;
+ if (claims->aud == nullptr) goto error;
} else if (strcmp(cur->key, "jti") == 0) {
claims->jti = validate_string_field(cur, "jti");
- if (claims->jti == NULL) goto error;
+ if (claims->jti == nullptr) goto error;
} else if (strcmp(cur->key, "iat") == 0) {
claims->iat = validate_time_field(cur, "iat");
if (gpr_time_cmp(claims->iat, gpr_time_0(GPR_CLOCK_REALTIME)) == 0)
@@ -270,16 +271,16 @@ grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_exec_ctx *exec_ctx,
return claims;
error:
- grpc_jwt_claims_destroy(exec_ctx, claims);
- return NULL;
+ grpc_jwt_claims_destroy(claims);
+ return nullptr;
}
-grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims *claims,
- const char *audience) {
+grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
+ const char* audience) {
gpr_timespec skewed_now;
int audience_ok;
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
skewed_now =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_clock_skew);
@@ -297,23 +298,23 @@ grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims *claims,
/* This should be probably up to the upper layer to decide but let's harcode
the 99% use case here for email issuers, where the JWT must be self
issued. */
- if (grpc_jwt_issuer_email_domain(claims->iss) != NULL &&
- claims->sub != NULL && strcmp(claims->iss, claims->sub) != 0) {
+ if (grpc_jwt_issuer_email_domain(claims->iss) != nullptr &&
+ claims->sub != nullptr && strcmp(claims->iss, claims->sub) != 0) {
gpr_log(GPR_ERROR,
"Email issuer (%s) cannot assert another subject (%s) than itself.",
claims->iss, claims->sub);
return GRPC_JWT_VERIFIER_BAD_SUBJECT;
}
- if (audience == NULL) {
- audience_ok = claims->aud == NULL;
+ if (audience == nullptr) {
+ audience_ok = claims->aud == nullptr;
} else {
- audience_ok = claims->aud != NULL && strcmp(audience, claims->aud) == 0;
+ audience_ok = claims->aud != nullptr && strcmp(audience, claims->aud) == 0;
}
if (!audience_ok) {
gpr_log(GPR_ERROR, "Audience mismatch: expected %s and found %s.",
- audience == NULL ? "NULL" : audience,
- claims->aud == NULL ? "NULL" : claims->aud);
+ audience == nullptr ? "NULL" : audience,
+ claims->aud == nullptr ? "NULL" : claims->aud);
return GRPC_JWT_VERIFIER_BAD_AUDIENCE;
}
return GRPC_JWT_VERIFIER_OK;
@@ -328,26 +329,26 @@ typedef enum {
} http_response_index;
typedef struct {
- grpc_jwt_verifier *verifier;
+ grpc_jwt_verifier* verifier;
grpc_polling_entity pollent;
- jose_header *header;
- grpc_jwt_claims *claims;
- char *audience;
+ jose_header* header;
+ grpc_jwt_claims* claims;
+ char* audience;
grpc_slice signature;
grpc_slice signed_data;
- void *user_data;
+ void* user_data;
grpc_jwt_verification_done_cb user_cb;
grpc_http_response responses[HTTP_RESPONSE_COUNT];
} verifier_cb_ctx;
/* Takes ownership of the header, claims and signature. */
-static verifier_cb_ctx *verifier_cb_ctx_create(
- grpc_jwt_verifier *verifier, grpc_pollset *pollset, jose_header *header,
- grpc_jwt_claims *claims, const char *audience, grpc_slice signature,
- const char *signed_jwt, size_t signed_jwt_len, void *user_data,
+static verifier_cb_ctx* verifier_cb_ctx_create(
+ grpc_jwt_verifier* verifier, grpc_pollset* pollset, jose_header* header,
+ grpc_jwt_claims* claims, const char* audience, grpc_slice signature,
+ const char* signed_jwt, size_t signed_jwt_len, void* user_data,
grpc_jwt_verification_done_cb cb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- verifier_cb_ctx *ctx = gpr_zalloc(sizeof(verifier_cb_ctx));
+ grpc_core::ExecCtx exec_ctx;
+ verifier_cb_ctx* ctx = (verifier_cb_ctx*)gpr_zalloc(sizeof(verifier_cb_ctx));
ctx->verifier = verifier;
ctx->pollent = grpc_polling_entity_create_from_pollset(pollset);
ctx->header = header;
@@ -357,16 +358,16 @@ static verifier_cb_ctx *verifier_cb_ctx_create(
ctx->signed_data = grpc_slice_from_copied_buffer(signed_jwt, signed_jwt_len);
ctx->user_data = user_data;
ctx->user_cb = cb;
- grpc_exec_ctx_finish(&exec_ctx);
+
return ctx;
}
-void verifier_cb_ctx_destroy(grpc_exec_ctx *exec_ctx, verifier_cb_ctx *ctx) {
- if (ctx->audience != NULL) gpr_free(ctx->audience);
- if (ctx->claims != NULL) grpc_jwt_claims_destroy(exec_ctx, ctx->claims);
- grpc_slice_unref_internal(exec_ctx, ctx->signature);
- grpc_slice_unref_internal(exec_ctx, ctx->signed_data);
- jose_header_destroy(exec_ctx, ctx->header);
+void verifier_cb_ctx_destroy(verifier_cb_ctx* ctx) {
+ if (ctx->audience != nullptr) gpr_free(ctx->audience);
+ if (ctx->claims != nullptr) grpc_jwt_claims_destroy(ctx->claims);
+ grpc_slice_unref_internal(ctx->signature);
+ grpc_slice_unref_internal(ctx->signed_data);
+ jose_header_destroy(ctx->header);
for (size_t i = 0; i < HTTP_RESPONSE_COUNT; i++) {
grpc_http_response_destroy(&ctx->responses[i]);
}
@@ -380,63 +381,63 @@ void verifier_cb_ctx_destroy(grpc_exec_ctx *exec_ctx, verifier_cb_ctx *ctx) {
gpr_timespec grpc_jwt_verifier_clock_skew = {60, 0, GPR_TIMESPAN};
/* Max delay defaults to one minute. */
-gpr_timespec grpc_jwt_verifier_max_delay = {60, 0, GPR_TIMESPAN};
+grpc_millis grpc_jwt_verifier_max_delay = 60 * GPR_MS_PER_SEC;
typedef struct {
- char *email_domain;
- char *key_url_prefix;
+ char* email_domain;
+ char* key_url_prefix;
} email_key_mapping;
struct grpc_jwt_verifier {
- email_key_mapping *mappings;
+ email_key_mapping* mappings;
size_t num_mappings; /* Should be very few, linear search ok. */
size_t allocated_mappings;
grpc_httpcli_context http_ctx;
};
-static grpc_json *json_from_http(const grpc_httpcli_response *response) {
- grpc_json *json = NULL;
+static grpc_json* json_from_http(const grpc_httpcli_response* response) {
+ grpc_json* json = nullptr;
- if (response == NULL) {
+ if (response == nullptr) {
gpr_log(GPR_ERROR, "HTTP response is NULL.");
- return NULL;
+ return nullptr;
}
if (response->status != 200) {
gpr_log(GPR_ERROR, "Call to http server failed with error %d.",
response->status);
- return NULL;
+ return nullptr;
}
json = grpc_json_parse_string_with_len(response->body, response->body_length);
- if (json == NULL) {
+ if (json == nullptr) {
gpr_log(GPR_ERROR, "Invalid JSON found in response.");
}
return json;
}
-static const grpc_json *find_property_by_name(const grpc_json *json,
- const char *name) {
- const grpc_json *cur;
- for (cur = json->child; cur != NULL; cur = cur->next) {
+static const grpc_json* find_property_by_name(const grpc_json* json,
+ const char* name) {
+ const grpc_json* cur;
+ for (cur = json->child; cur != nullptr; cur = cur->next) {
if (strcmp(cur->key, name) == 0) return cur;
}
- return NULL;
+ return nullptr;
}
-static EVP_PKEY *extract_pkey_from_x509(const char *x509_str) {
- X509 *x509 = NULL;
- EVP_PKEY *result = NULL;
- BIO *bio = BIO_new(BIO_s_mem());
+static EVP_PKEY* extract_pkey_from_x509(const char* x509_str) {
+ X509* x509 = nullptr;
+ EVP_PKEY* result = nullptr;
+ BIO* bio = BIO_new(BIO_s_mem());
size_t len = strlen(x509_str);
GPR_ASSERT(len < INT_MAX);
BIO_write(bio, x509_str, (int)len);
- x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
- if (x509 == NULL) {
+ x509 = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr);
+ if (x509 == nullptr) {
gpr_log(GPR_ERROR, "Unable to parse x509 cert.");
goto end;
}
result = X509_get_pubkey(x509);
- if (result == NULL) {
+ if (result == nullptr) {
gpr_log(GPR_ERROR, "Cannot find public key in X509 cert.");
}
@@ -446,43 +447,43 @@ end:
return result;
}
-static BIGNUM *bignum_from_base64(grpc_exec_ctx *exec_ctx, const char *b64) {
- BIGNUM *result = NULL;
+static BIGNUM* bignum_from_base64(const char* b64) {
+ BIGNUM* result = nullptr;
grpc_slice bin;
- if (b64 == NULL) return NULL;
- bin = grpc_base64_decode(exec_ctx, b64, 1);
+ if (b64 == nullptr) return nullptr;
+ bin = grpc_base64_decode(b64, 1);
if (GRPC_SLICE_IS_EMPTY(bin)) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
- return NULL;
+ return nullptr;
}
result = BN_bin2bn(GRPC_SLICE_START_PTR(bin),
- TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), NULL);
- grpc_slice_unref_internal(exec_ctx, bin);
+ TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), nullptr);
+ grpc_slice_unref_internal(bin);
return result;
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
// Provide compatibility across OpenSSL 1.02 and 1.1.
-static int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) {
+static int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
/* If the fields n and e in r are NULL, the corresponding input
* parameters MUST be non-NULL for n and e. d may be
* left NULL (in case only the public key is used).
*/
- if ((r->n == NULL && n == NULL) || (r->e == NULL && e == NULL)) {
+ if ((r->n == nullptr && n == nullptr) || (r->e == nullptr && e == nullptr)) {
return 0;
}
- if (n != NULL) {
+ if (n != nullptr) {
BN_free(r->n);
r->n = n;
}
- if (e != NULL) {
+ if (e != nullptr) {
BN_free(r->e);
r->e = e;
}
- if (d != NULL) {
+ if (d != nullptr) {
BN_free(r->d);
r->d = d;
}
@@ -491,46 +492,43 @@ static int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) {
}
#endif // OPENSSL_VERSION_NUMBER < 0x10100000L
-static EVP_PKEY *pkey_from_jwk(grpc_exec_ctx *exec_ctx, const grpc_json *json,
- const char *kty) {
- const grpc_json *key_prop;
- RSA *rsa = NULL;
- EVP_PKEY *result = NULL;
- BIGNUM *tmp_n = NULL;
- BIGNUM *tmp_e = NULL;
+static EVP_PKEY* pkey_from_jwk(const grpc_json* json, const char* kty) {
+ const grpc_json* key_prop;
+ RSA* rsa = nullptr;
+ EVP_PKEY* result = nullptr;
+ BIGNUM* tmp_n = nullptr;
+ BIGNUM* tmp_e = nullptr;
- GPR_ASSERT(kty != NULL && json != NULL);
+ GPR_ASSERT(kty != nullptr && json != nullptr);
if (strcmp(kty, "RSA") != 0) {
gpr_log(GPR_ERROR, "Unsupported key type %s.", kty);
goto end;
}
rsa = RSA_new();
- if (rsa == NULL) {
+ if (rsa == nullptr) {
gpr_log(GPR_ERROR, "Could not create rsa key.");
goto end;
}
- for (key_prop = json->child; key_prop != NULL; key_prop = key_prop->next) {
+ for (key_prop = json->child; key_prop != nullptr; key_prop = key_prop->next) {
if (strcmp(key_prop->key, "n") == 0) {
- tmp_n =
- bignum_from_base64(exec_ctx, validate_string_field(key_prop, "n"));
- if (tmp_n == NULL) goto end;
+ tmp_n = bignum_from_base64(validate_string_field(key_prop, "n"));
+ if (tmp_n == nullptr) goto end;
} else if (strcmp(key_prop->key, "e") == 0) {
- tmp_e =
- bignum_from_base64(exec_ctx, validate_string_field(key_prop, "e"));
- if (tmp_e == NULL) goto end;
+ tmp_e = bignum_from_base64(validate_string_field(key_prop, "e"));
+ if (tmp_e == nullptr) goto end;
}
}
- if (tmp_e == NULL || tmp_n == NULL) {
+ if (tmp_e == nullptr || tmp_n == nullptr) {
gpr_log(GPR_ERROR, "Missing RSA public key field.");
goto end;
}
- if (!RSA_set0_key(rsa, tmp_n, tmp_e, NULL)) {
+ if (!RSA_set0_key(rsa, tmp_n, tmp_e, nullptr)) {
gpr_log(GPR_ERROR, "Cannot set RSA key from inputs.");
goto end;
}
/* RSA_set0_key takes ownership on success. */
- tmp_n = NULL;
- tmp_e = NULL;
+ tmp_n = nullptr;
+ tmp_e = nullptr;
result = EVP_PKEY_new();
EVP_PKEY_set1_RSA(result, rsa); /* uprefs rsa. */
@@ -541,38 +539,38 @@ end:
return result;
}
-static EVP_PKEY *find_verification_key(grpc_exec_ctx *exec_ctx,
- const grpc_json *json,
- const char *header_alg,
- const char *header_kid) {
- const grpc_json *jkey;
- const grpc_json *jwk_keys;
+static EVP_PKEY* find_verification_key(const grpc_json* json,
+ const char* header_alg,
+ const char* header_kid) {
+ const grpc_json* jkey;
+ const grpc_json* jwk_keys;
/* Try to parse the json as a JWK set:
https://tools.ietf.org/html/rfc7517#section-5. */
jwk_keys = find_property_by_name(json, "keys");
- if (jwk_keys == NULL) {
+ if (jwk_keys == nullptr) {
/* Use the google proprietary format which is:
{ <kid1>: <x5091>, <kid2>: <x5092>, ... } */
- const grpc_json *cur = find_property_by_name(json, header_kid);
- if (cur == NULL) return NULL;
+ const grpc_json* cur = find_property_by_name(json, header_kid);
+ if (cur == nullptr) return nullptr;
return extract_pkey_from_x509(cur->value);
}
if (jwk_keys->type != GRPC_JSON_ARRAY) {
gpr_log(GPR_ERROR,
"Unexpected value type of keys property in jwks key set.");
- return NULL;
+ return nullptr;
}
/* Key format is specified in:
https://tools.ietf.org/html/rfc7518#section-6. */
- for (jkey = jwk_keys->child; jkey != NULL; jkey = jkey->next) {
- grpc_json *key_prop;
- const char *alg = NULL;
- const char *kid = NULL;
- const char *kty = NULL;
+ for (jkey = jwk_keys->child; jkey != nullptr; jkey = jkey->next) {
+ grpc_json* key_prop;
+ const char* alg = nullptr;
+ const char* kid = nullptr;
+ const char* kty = nullptr;
if (jkey->type != GRPC_JSON_OBJECT) continue;
- for (key_prop = jkey->child; key_prop != NULL; key_prop = key_prop->next) {
+ for (key_prop = jkey->child; key_prop != nullptr;
+ key_prop = key_prop->next) {
if (strcmp(key_prop->key, "alg") == 0 &&
key_prop->type == GRPC_JSON_STRING) {
alg = key_prop->value;
@@ -584,29 +582,29 @@ static EVP_PKEY *find_verification_key(grpc_exec_ctx *exec_ctx,
kty = key_prop->value;
}
}
- if (alg != NULL && kid != NULL && kty != NULL &&
+ if (alg != nullptr && kid != nullptr && kty != nullptr &&
strcmp(kid, header_kid) == 0 && strcmp(alg, header_alg) == 0) {
- return pkey_from_jwk(exec_ctx, jkey, kty);
+ return pkey_from_jwk(jkey, kty);
}
}
gpr_log(GPR_ERROR,
"Could not find matching key in key set for kid=%s and alg=%s",
header_kid, header_alg);
- return NULL;
+ return nullptr;
}
-static int verify_jwt_signature(EVP_PKEY *key, const char *alg,
+static int verify_jwt_signature(EVP_PKEY* key, const char* alg,
grpc_slice signature, grpc_slice signed_data) {
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
- const EVP_MD *md = evp_md_from_alg(alg);
+ EVP_MD_CTX* md_ctx = EVP_MD_CTX_create();
+ const EVP_MD* md = evp_md_from_alg(alg);
int result = 0;
- GPR_ASSERT(md != NULL); /* Checked before. */
- if (md_ctx == NULL) {
+ GPR_ASSERT(md != nullptr); /* Checked before. */
+ if (md_ctx == nullptr) {
gpr_log(GPR_ERROR, "Could not create EVP_MD_CTX.");
goto end;
}
- if (EVP_DigestVerifyInit(md_ctx, NULL, md, NULL, key) != 1) {
+ if (EVP_DigestVerifyInit(md_ctx, nullptr, md, nullptr, key) != 1) {
gpr_log(GPR_ERROR, "EVP_DigestVerifyInit failed.");
goto end;
}
@@ -627,21 +625,20 @@ end:
return result;
}
-static void on_keys_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *error) {
- verifier_cb_ctx *ctx = (verifier_cb_ctx *)user_data;
- grpc_json *json = json_from_http(&ctx->responses[HTTP_RESPONSE_KEYS]);
- EVP_PKEY *verification_key = NULL;
+static void on_keys_retrieved(void* user_data, grpc_error* error) {
+ verifier_cb_ctx* ctx = (verifier_cb_ctx*)user_data;
+ grpc_json* json = json_from_http(&ctx->responses[HTTP_RESPONSE_KEYS]);
+ EVP_PKEY* verification_key = nullptr;
grpc_jwt_verifier_status status = GRPC_JWT_VERIFIER_GENERIC_ERROR;
- grpc_jwt_claims *claims = NULL;
+ grpc_jwt_claims* claims = nullptr;
- if (json == NULL) {
+ if (json == nullptr) {
status = GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR;
goto end;
}
verification_key =
- find_verification_key(exec_ctx, json, ctx->header->alg, ctx->header->kid);
- if (verification_key == NULL) {
+ find_verification_key(json, ctx->header->alg, ctx->header->kid);
+ if (verification_key == nullptr) {
gpr_log(GPR_ERROR, "Could not find verification key with kid %s.",
ctx->header->kid);
status = GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR;
@@ -658,34 +655,34 @@ static void on_keys_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
if (status == GRPC_JWT_VERIFIER_OK) {
/* Pass ownership. */
claims = ctx->claims;
- ctx->claims = NULL;
+ ctx->claims = nullptr;
}
end:
- if (json != NULL) grpc_json_destroy(json);
+ if (json != nullptr) grpc_json_destroy(json);
EVP_PKEY_free(verification_key);
- ctx->user_cb(exec_ctx, ctx->user_data, status, claims);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, status, claims);
+ verifier_cb_ctx_destroy(ctx);
}
-static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *error) {
- const grpc_json *cur;
- verifier_cb_ctx *ctx = (verifier_cb_ctx *)user_data;
- const grpc_http_response *response = &ctx->responses[HTTP_RESPONSE_OPENID];
- grpc_json *json = json_from_http(response);
+static void on_openid_config_retrieved(void* user_data, grpc_error* error) {
+ const grpc_json* cur;
+ verifier_cb_ctx* ctx = (verifier_cb_ctx*)user_data;
+ const grpc_http_response* response = &ctx->responses[HTTP_RESPONSE_OPENID];
+ grpc_json* json = json_from_http(response);
grpc_httpcli_request req;
- const char *jwks_uri;
+ const char* jwks_uri;
+ grpc_resource_quota* resource_quota = nullptr;
/* TODO(jboeuf): Cache the jwks_uri in order to avoid this hop next time. */
- if (json == NULL) goto error;
+ if (json == nullptr) goto error;
cur = find_property_by_name(json, "jwks_uri");
- if (cur == NULL) {
+ if (cur == nullptr) {
gpr_log(GPR_ERROR, "Could not find jwks_uri in openid config.");
goto error;
}
jwks_uri = validate_string_field(cur, "jwks_uri");
- if (jwks_uri == NULL) goto error;
+ if (jwks_uri == nullptr) goto error;
if (strstr(jwks_uri, "https://") != jwks_uri) {
gpr_log(GPR_ERROR, "Invalid non https jwks_uri: %s.", jwks_uri);
goto error;
@@ -693,9 +690,9 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
jwks_uri += 8;
req.handshaker = &grpc_httpcli_ssl;
req.host = gpr_strdup(jwks_uri);
- req.http.path = strchr(jwks_uri, '/');
- if (req.http.path == NULL) {
- req.http.path = "";
+ req.http.path = (char*)strchr(jwks_uri, '/');
+ if (req.http.path == nullptr) {
+ req.http.path = (char*)"";
} else {
*(req.host + (req.http.path - jwks_uri)) = '\0';
}
@@ -703,42 +700,40 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("jwt_verifier");
+ resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get(
- exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay),
+ &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay,
GRPC_CLOSURE_CREATE(on_keys_retrieved, ctx, grpc_schedule_on_exec_ctx),
&ctx->responses[HTTP_RESPONSE_KEYS]);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_json_destroy(json);
gpr_free(req.host);
return;
error:
- if (json != NULL) grpc_json_destroy(json);
- ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- NULL);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ if (json != nullptr) grpc_json_destroy(json);
+ ctx->user_cb(ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, nullptr);
+ verifier_cb_ctx_destroy(ctx);
}
-static email_key_mapping *verifier_get_mapping(grpc_jwt_verifier *v,
- const char *email_domain) {
+static email_key_mapping* verifier_get_mapping(grpc_jwt_verifier* v,
+ const char* email_domain) {
size_t i;
- if (v->mappings == NULL) return NULL;
+ if (v->mappings == nullptr) return nullptr;
for (i = 0; i < v->num_mappings; i++) {
if (strcmp(email_domain, v->mappings[i].email_domain) == 0) {
return &v->mappings[i];
}
}
- return NULL;
+ return nullptr;
}
-static void verifier_put_mapping(grpc_jwt_verifier *v, const char *email_domain,
- const char *key_url_prefix) {
- email_key_mapping *mapping = verifier_get_mapping(v, email_domain);
+static void verifier_put_mapping(grpc_jwt_verifier* v, const char* email_domain,
+ const char* key_url_prefix) {
+ email_key_mapping* mapping = verifier_get_mapping(v, email_domain);
GPR_ASSERT(v->num_mappings < v->allocated_mappings);
- if (mapping != NULL) {
+ if (mapping != nullptr) {
gpr_free(mapping->key_url_prefix);
mapping->key_url_prefix = gpr_strdup(key_url_prefix);
return;
@@ -751,39 +746,41 @@ static void verifier_put_mapping(grpc_jwt_verifier *v, const char *email_domain,
/* Very non-sophisticated way to detect an email address. Should be good
enough for now... */
-const char *grpc_jwt_issuer_email_domain(const char *issuer) {
- const char *at_sign = strchr(issuer, '@');
- if (at_sign == NULL) return NULL;
- const char *email_domain = at_sign + 1;
- if (*email_domain == '\0') return NULL;
- const char *dot = strrchr(email_domain, '.');
- if (dot == NULL || dot == email_domain) return email_domain;
+const char* grpc_jwt_issuer_email_domain(const char* issuer) {
+ const char* at_sign = strchr(issuer, '@');
+ if (at_sign == nullptr) return nullptr;
+ const char* email_domain = at_sign + 1;
+ if (*email_domain == '\0') return nullptr;
+ const char* dot = strrchr(email_domain, '.');
+ if (dot == nullptr || dot == email_domain) return email_domain;
GPR_ASSERT(dot > email_domain);
/* There may be a subdomain, we just want the domain. */
- dot = gpr_memrchr(email_domain, '.', (size_t)(dot - email_domain));
- if (dot == NULL) return email_domain;
+ dot = (const char*)gpr_memrchr((void*)email_domain, '.',
+ (size_t)(dot - email_domain));
+ if (dot == nullptr) return email_domain;
return dot + 1;
}
/* Takes ownership of ctx. */
-static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
- verifier_cb_ctx *ctx) {
- const char *email_domain;
- grpc_closure *http_cb;
- char *path_prefix = NULL;
- const char *iss;
+static void retrieve_key_and_verify(verifier_cb_ctx* ctx) {
+ const char* email_domain;
+ grpc_closure* http_cb;
+ char* path_prefix = nullptr;
+ const char* iss;
grpc_httpcli_request req;
+ grpc_resource_quota* resource_quota = nullptr;
memset(&req, 0, sizeof(grpc_httpcli_request));
req.handshaker = &grpc_httpcli_ssl;
http_response_index rsp_idx;
- GPR_ASSERT(ctx != NULL && ctx->header != NULL && ctx->claims != NULL);
+ GPR_ASSERT(ctx != nullptr && ctx->header != nullptr &&
+ ctx->claims != nullptr);
iss = ctx->claims->iss;
- if (ctx->header->kid == NULL) {
+ if (ctx->header->kid == nullptr) {
gpr_log(GPR_ERROR, "Missing kid in jose header.");
goto error;
}
- if (iss == NULL) {
+ if (iss == nullptr) {
gpr_log(GPR_ERROR, "Missing iss in claims.");
goto error;
}
@@ -794,17 +791,17 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
so we will rely instead on email/url mappings if we detect such an issuer.
Part 4, on the other hand is implemented by both google and salesforce. */
email_domain = grpc_jwt_issuer_email_domain(iss);
- if (email_domain != NULL) {
- email_key_mapping *mapping;
- GPR_ASSERT(ctx->verifier != NULL);
+ if (email_domain != nullptr) {
+ email_key_mapping* mapping;
+ GPR_ASSERT(ctx->verifier != nullptr);
mapping = verifier_get_mapping(ctx->verifier, email_domain);
- if (mapping == NULL) {
+ if (mapping == nullptr) {
gpr_log(GPR_ERROR, "Missing mapping for issuer email.");
goto error;
}
req.host = gpr_strdup(mapping->key_url_prefix);
path_prefix = strchr(req.host, '/');
- if (path_prefix == NULL) {
+ if (path_prefix == nullptr) {
gpr_asprintf(&req.http.path, "/%s", iss);
} else {
*(path_prefix++) = '\0';
@@ -816,7 +813,7 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
} else {
req.host = gpr_strdup(strstr(iss, "https://") == iss ? iss + 8 : iss);
path_prefix = strchr(req.host, '/');
- if (path_prefix == NULL) {
+ if (path_prefix == nullptr) {
req.http.path = gpr_strdup(GRPC_OPENID_CONFIG_URL_SUFFIX);
} else {
*(path_prefix++) = 0;
@@ -831,86 +828,83 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("jwt_verifier");
+ resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get(
- exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay),
- http_cb, &ctx->responses[rsp_idx]);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay, http_cb,
+ &ctx->responses[rsp_idx]);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_free(req.host);
gpr_free(req.http.path);
return;
error:
- ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- NULL);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, nullptr);
+ verifier_cb_ctx_destroy(ctx);
}
-void grpc_jwt_verifier_verify(grpc_exec_ctx *exec_ctx,
- grpc_jwt_verifier *verifier,
- grpc_pollset *pollset, const char *jwt,
- const char *audience,
+void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
+ grpc_pollset* pollset, const char* jwt,
+ const char* audience,
grpc_jwt_verification_done_cb cb,
- void *user_data) {
- const char *dot = NULL;
- grpc_json *json;
- jose_header *header = NULL;
- grpc_jwt_claims *claims = NULL;
+ void* user_data) {
+ const char* dot = nullptr;
+ grpc_json* json;
+ jose_header* header = nullptr;
+ grpc_jwt_claims* claims = nullptr;
grpc_slice header_buffer;
grpc_slice claims_buffer;
grpc_slice signature;
size_t signed_jwt_len;
- const char *cur = jwt;
+ const char* cur = jwt;
- GPR_ASSERT(verifier != NULL && jwt != NULL && audience != NULL && cb != NULL);
+ GPR_ASSERT(verifier != nullptr && jwt != nullptr && audience != nullptr &&
+ cb != nullptr);
dot = strchr(cur, '.');
- if (dot == NULL) goto error;
- json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
- &header_buffer);
- if (json == NULL) goto error;
- header = jose_header_from_json(exec_ctx, json, header_buffer);
- if (header == NULL) goto error;
+ if (dot == nullptr) goto error;
+ json = parse_json_part_from_jwt(cur, (size_t)(dot - cur), &header_buffer);
+ if (json == nullptr) goto error;
+ header = jose_header_from_json(json, header_buffer);
+ if (header == nullptr) goto error;
cur = dot + 1;
dot = strchr(cur, '.');
- if (dot == NULL) goto error;
- json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
- &claims_buffer);
- if (json == NULL) goto error;
- claims = grpc_jwt_claims_from_json(exec_ctx, json, claims_buffer);
- if (claims == NULL) goto error;
+ if (dot == nullptr) goto error;
+ json = parse_json_part_from_jwt(cur, (size_t)(dot - cur), &claims_buffer);
+ if (json == nullptr) goto error;
+ claims = grpc_jwt_claims_from_json(json, claims_buffer);
+ if (claims == nullptr) goto error;
signed_jwt_len = (size_t)(dot - jwt);
cur = dot + 1;
- signature = grpc_base64_decode(exec_ctx, cur, 1);
+ signature = grpc_base64_decode(cur, 1);
if (GRPC_SLICE_IS_EMPTY(signature)) goto error;
retrieve_key_and_verify(
- exec_ctx,
verifier_cb_ctx_create(verifier, pollset, header, claims, audience,
signature, jwt, signed_jwt_len, user_data, cb));
return;
error:
- if (header != NULL) jose_header_destroy(exec_ctx, header);
- if (claims != NULL) grpc_jwt_claims_destroy(exec_ctx, claims);
- cb(exec_ctx, user_data, GRPC_JWT_VERIFIER_BAD_FORMAT, NULL);
+ if (header != nullptr) jose_header_destroy(header);
+ if (claims != nullptr) grpc_jwt_claims_destroy(claims);
+ cb(user_data, GRPC_JWT_VERIFIER_BAD_FORMAT, nullptr);
}
-grpc_jwt_verifier *grpc_jwt_verifier_create(
- const grpc_jwt_verifier_email_domain_key_url_mapping *mappings,
+grpc_jwt_verifier* grpc_jwt_verifier_create(
+ const grpc_jwt_verifier_email_domain_key_url_mapping* mappings,
size_t num_mappings) {
- grpc_jwt_verifier *v = gpr_zalloc(sizeof(grpc_jwt_verifier));
+ grpc_jwt_verifier* v =
+ (grpc_jwt_verifier*)gpr_zalloc(sizeof(grpc_jwt_verifier));
grpc_httpcli_context_init(&v->http_ctx);
/* We know at least of one mapping. */
v->allocated_mappings = 1 + num_mappings;
- v->mappings = gpr_malloc(v->allocated_mappings * sizeof(email_key_mapping));
+ v->mappings = (email_key_mapping*)gpr_malloc(v->allocated_mappings *
+ sizeof(email_key_mapping));
verifier_put_mapping(v, GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN,
GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX);
/* User-Provided mappings. */
- if (mappings != NULL) {
+ if (mappings != nullptr) {
size_t i;
for (i = 0; i < num_mappings; i++) {
verifier_put_mapping(v, mappings[i].email_domain,
@@ -920,11 +914,11 @@ grpc_jwt_verifier *grpc_jwt_verifier_create(
return v;
}
-void grpc_jwt_verifier_destroy(grpc_exec_ctx *exec_ctx, grpc_jwt_verifier *v) {
+void grpc_jwt_verifier_destroy(grpc_jwt_verifier* v) {
size_t i;
- if (v == NULL) return;
- grpc_httpcli_context_destroy(exec_ctx, &v->http_ctx);
- if (v->mappings != NULL) {
+ if (v == nullptr) return;
+ grpc_httpcli_context_destroy(&v->http_ctx);
+ if (v->mappings != nullptr) {
for (i = 0; i < v->num_mappings; i++) {
gpr_free(v->mappings[i].email_domain);
gpr_free(v->mappings[i].key_url_prefix);
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.h b/src/core/lib/security/credentials/jwt/jwt_verifier.h
index 8fac452d4e..b3805e75cd 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.h
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h
@@ -45,25 +45,25 @@ typedef enum {
GRPC_JWT_VERIFIER_GENERIC_ERROR
} grpc_jwt_verifier_status;
-const char *grpc_jwt_verifier_status_to_string(grpc_jwt_verifier_status status);
+const char* grpc_jwt_verifier_status_to_string(grpc_jwt_verifier_status status);
/* --- grpc_jwt_claims. --- */
typedef struct grpc_jwt_claims grpc_jwt_claims;
-void grpc_jwt_claims_destroy(grpc_exec_ctx *exec_ctx, grpc_jwt_claims *claims);
+void grpc_jwt_claims_destroy(grpc_jwt_claims* claims);
/* Returns the whole JSON tree of the claims. */
-const grpc_json *grpc_jwt_claims_json(const grpc_jwt_claims *claims);
+const grpc_json* grpc_jwt_claims_json(const grpc_jwt_claims* claims);
/* Access to registered claims in https://tools.ietf.org/html/rfc7519#page-9 */
-const char *grpc_jwt_claims_subject(const grpc_jwt_claims *claims);
-const char *grpc_jwt_claims_issuer(const grpc_jwt_claims *claims);
-const char *grpc_jwt_claims_id(const grpc_jwt_claims *claims);
-const char *grpc_jwt_claims_audience(const grpc_jwt_claims *claims);
-gpr_timespec grpc_jwt_claims_issued_at(const grpc_jwt_claims *claims);
-gpr_timespec grpc_jwt_claims_expires_at(const grpc_jwt_claims *claims);
-gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims *claims);
+const char* grpc_jwt_claims_subject(const grpc_jwt_claims* claims);
+const char* grpc_jwt_claims_issuer(const grpc_jwt_claims* claims);
+const char* grpc_jwt_claims_id(const grpc_jwt_claims* claims);
+const char* grpc_jwt_claims_audience(const grpc_jwt_claims* claims);
+gpr_timespec grpc_jwt_claims_issued_at(const grpc_jwt_claims* claims);
+gpr_timespec grpc_jwt_claims_expires_at(const grpc_jwt_claims* claims);
+gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims);
/* --- grpc_jwt_verifier. --- */
@@ -71,17 +71,17 @@ typedef struct grpc_jwt_verifier grpc_jwt_verifier;
typedef struct {
/* The email domain is the part after the @ sign. */
- const char *email_domain;
+ const char* email_domain;
/* The key url prefix will be used to get the public key from the issuer:
https://<key_url_prefix>/<issuer_email>
Therefore the key_url_prefix must NOT contain https://. */
- const char *key_url_prefix;
+ const char* key_url_prefix;
} grpc_jwt_verifier_email_domain_key_url_mapping;
/* Globals to control the verifier. Not thread-safe. */
extern gpr_timespec grpc_jwt_verifier_clock_skew;
-extern gpr_timespec grpc_jwt_verifier_max_delay;
+extern grpc_millis grpc_jwt_verifier_max_delay;
/* The verifier can be created with some custom mappings to help with key
discovery in the case where the issuer is an email address.
@@ -89,37 +89,33 @@ extern gpr_timespec grpc_jwt_verifier_max_delay;
A verifier object has one built-in mapping (unless overridden):
GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN ->
GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX.*/
-grpc_jwt_verifier *grpc_jwt_verifier_create(
- const grpc_jwt_verifier_email_domain_key_url_mapping *mappings,
+grpc_jwt_verifier* grpc_jwt_verifier_create(
+ const grpc_jwt_verifier_email_domain_key_url_mapping* mappings,
size_t num_mappings);
/*The verifier must not be destroyed if there are still outstanding callbacks.*/
-void grpc_jwt_verifier_destroy(grpc_exec_ctx *exec_ctx,
- grpc_jwt_verifier *verifier);
+void grpc_jwt_verifier_destroy(grpc_jwt_verifier* verifier);
/* User provided callback that will be called when the verification of the JWT
is done (maybe in another thread).
It is the responsibility of the callee to call grpc_jwt_claims_destroy on
the claims. */
-typedef void (*grpc_jwt_verification_done_cb)(grpc_exec_ctx *exec_ctx,
- void *user_data,
+typedef void (*grpc_jwt_verification_done_cb)(void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims);
+ grpc_jwt_claims* claims);
/* Verifies for the JWT for the given expected audience. */
-void grpc_jwt_verifier_verify(grpc_exec_ctx *exec_ctx,
- grpc_jwt_verifier *verifier,
- grpc_pollset *pollset, const char *jwt,
- const char *audience,
+void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
+ grpc_pollset* pollset, const char* jwt,
+ const char* audience,
grpc_jwt_verification_done_cb cb,
- void *user_data);
+ void* user_data);
/* --- TESTING ONLY exposed functions. --- */
-grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_exec_ctx *exec_ctx,
- grpc_json *json, grpc_slice buffer);
-grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims *claims,
- const char *audience);
-const char *grpc_jwt_issuer_email_domain(const char *issuer);
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json, grpc_slice buffer);
+grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
+ const char* audience);
+const char* grpc_jwt_issuer_email_domain(const char* issuer);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H */
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.c b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index 10b270c49c..e243ea52c6 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.c
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -32,26 +32,26 @@
//
int grpc_auth_refresh_token_is_valid(
- const grpc_auth_refresh_token *refresh_token) {
- return (refresh_token != NULL) &&
+ const grpc_auth_refresh_token* refresh_token) {
+ return (refresh_token != nullptr) &&
strcmp(refresh_token->type, GRPC_AUTH_JSON_TYPE_INVALID);
}
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
- const grpc_json *json) {
+ const grpc_json* json) {
grpc_auth_refresh_token result;
- const char *prop_value;
+ const char* prop_value;
int success = 0;
memset(&result, 0, sizeof(grpc_auth_refresh_token));
result.type = GRPC_AUTH_JSON_TYPE_INVALID;
- if (json == NULL) {
+ if (json == nullptr) {
gpr_log(GPR_ERROR, "Invalid json.");
goto end;
}
prop_value = grpc_json_get_string_property(json, "type");
- if (prop_value == NULL ||
+ if (prop_value == nullptr ||
strcmp(prop_value, GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER)) {
goto end;
}
@@ -72,30 +72,30 @@ end:
}
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
- const char *json_string) {
- char *scratchpad = gpr_strdup(json_string);
- grpc_json *json = grpc_json_parse_string(scratchpad);
+ const char* json_string) {
+ char* scratchpad = gpr_strdup(json_string);
+ grpc_json* json = grpc_json_parse_string(scratchpad);
grpc_auth_refresh_token result =
grpc_auth_refresh_token_create_from_json(json);
- if (json != NULL) grpc_json_destroy(json);
+ if (json != nullptr) grpc_json_destroy(json);
gpr_free(scratchpad);
return result;
}
-void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token *refresh_token) {
- if (refresh_token == NULL) return;
+void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token) {
+ if (refresh_token == nullptr) return;
refresh_token->type = GRPC_AUTH_JSON_TYPE_INVALID;
- if (refresh_token->client_id != NULL) {
+ if (refresh_token->client_id != nullptr) {
gpr_free(refresh_token->client_id);
- refresh_token->client_id = NULL;
+ refresh_token->client_id = nullptr;
}
- if (refresh_token->client_secret != NULL) {
+ if (refresh_token->client_secret != nullptr) {
gpr_free(refresh_token->client_secret);
- refresh_token->client_secret = NULL;
+ refresh_token->client_secret = nullptr;
}
- if (refresh_token->refresh_token != NULL) {
+ if (refresh_token->refresh_token != nullptr) {
gpr_free(refresh_token->refresh_token);
- refresh_token->refresh_token = NULL;
+ refresh_token->refresh_token = nullptr;
}
}
@@ -103,34 +103,32 @@ void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token *refresh_token) {
// Oauth2 Token Fetcher credentials.
//
-static void oauth2_token_fetcher_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_oauth2_token_fetcher_credentials *c =
- (grpc_oauth2_token_fetcher_credentials *)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
+static void oauth2_token_fetcher_destruct(grpc_call_credentials* creds) {
+ grpc_oauth2_token_fetcher_credentials* c =
+ (grpc_oauth2_token_fetcher_credentials*)creds;
+ GRPC_MDELEM_UNREF(c->access_token_md);
gpr_mu_destroy(&c->mu);
- grpc_pollset_set_destroy(exec_ctx,
- grpc_polling_entity_pollset_set(&c->pollent));
- grpc_httpcli_context_destroy(exec_ctx, &c->httpcli_context);
+ grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&c->pollent));
+ grpc_httpcli_context_destroy(&c->httpcli_context);
}
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- grpc_exec_ctx *exec_ctx, const grpc_http_response *response,
- grpc_mdelem *token_md, gpr_timespec *token_lifetime) {
- char *null_terminated_body = NULL;
- char *new_access_token = NULL;
+ const grpc_http_response* response, grpc_mdelem* token_md,
+ grpc_millis* token_lifetime) {
+ char* null_terminated_body = nullptr;
+ char* new_access_token = nullptr;
grpc_credentials_status status = GRPC_CREDENTIALS_OK;
- grpc_json *json = NULL;
+ grpc_json* json = nullptr;
- if (response == NULL) {
+ if (response == nullptr) {
gpr_log(GPR_ERROR, "Received NULL response.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
if (response->body_length > 0) {
- null_terminated_body = gpr_malloc(response->body_length + 1);
+ null_terminated_body = (char*)gpr_malloc(response->body_length + 1);
null_terminated_body[response->body_length] = '\0';
memcpy(null_terminated_body, response->body, response->body_length);
}
@@ -138,16 +136,16 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
if (response->status != 200) {
gpr_log(GPR_ERROR, "Call to http server ended with error %d [%s].",
response->status,
- null_terminated_body != NULL ? null_terminated_body : "");
+ null_terminated_body != nullptr ? null_terminated_body : "");
status = GRPC_CREDENTIALS_ERROR;
goto end;
} else {
- grpc_json *access_token = NULL;
- grpc_json *token_type = NULL;
- grpc_json *expires_in = NULL;
- grpc_json *ptr;
+ grpc_json* access_token = nullptr;
+ grpc_json* token_type = nullptr;
+ grpc_json* expires_in = nullptr;
+ grpc_json* ptr;
json = grpc_json_parse_string(null_terminated_body);
- if (json == NULL) {
+ if (json == nullptr) {
gpr_log(GPR_ERROR, "Could not parse JSON from %s", null_terminated_body);
status = GRPC_CREDENTIALS_ERROR;
goto end;
@@ -166,29 +164,26 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
expires_in = ptr;
}
}
- if (access_token == NULL || access_token->type != GRPC_JSON_STRING) {
+ if (access_token == nullptr || access_token->type != GRPC_JSON_STRING) {
gpr_log(GPR_ERROR, "Missing or invalid access_token in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- if (token_type == NULL || token_type->type != GRPC_JSON_STRING) {
+ if (token_type == nullptr || token_type->type != GRPC_JSON_STRING) {
gpr_log(GPR_ERROR, "Missing or invalid token_type in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- if (expires_in == NULL || expires_in->type != GRPC_JSON_NUMBER) {
+ if (expires_in == nullptr || expires_in->type != GRPC_JSON_NUMBER) {
gpr_log(GPR_ERROR, "Missing or invalid expires_in in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
gpr_asprintf(&new_access_token, "%s %s", token_type->value,
access_token->value);
- token_lifetime->tv_sec = strtol(expires_in->value, NULL, 10);
- token_lifetime->tv_nsec = 0;
- token_lifetime->clock_type = GPR_TIMESPAN;
- if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(exec_ctx, *token_md);
+ *token_lifetime = strtol(expires_in->value, nullptr, 10) * GPR_MS_PER_SEC;
+ if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(*token_md);
*token_md = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(new_access_token));
status = GRPC_CREDENTIALS_OK;
@@ -196,42 +191,40 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
end:
if (status != GRPC_CREDENTIALS_OK && !GRPC_MDISNULL(*token_md)) {
- GRPC_MDELEM_UNREF(exec_ctx, *token_md);
+ GRPC_MDELEM_UNREF(*token_md);
*token_md = GRPC_MDNULL;
}
- if (null_terminated_body != NULL) gpr_free(null_terminated_body);
- if (new_access_token != NULL) gpr_free(new_access_token);
- if (json != NULL) grpc_json_destroy(json);
+ if (null_terminated_body != nullptr) gpr_free(null_terminated_body);
+ if (new_access_token != nullptr) gpr_free(new_access_token);
+ if (json != nullptr) grpc_json_destroy(json);
return status;
}
-static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx *exec_ctx,
- void *user_data,
- grpc_error *error) {
+static void on_oauth2_token_fetcher_http_response(void* user_data,
+ grpc_error* error) {
GRPC_LOG_IF_ERROR("oauth_fetch", GRPC_ERROR_REF(error));
- grpc_credentials_metadata_request *r =
- (grpc_credentials_metadata_request *)user_data;
- grpc_oauth2_token_fetcher_credentials *c =
- (grpc_oauth2_token_fetcher_credentials *)r->creds;
+ grpc_credentials_metadata_request* r =
+ (grpc_credentials_metadata_request*)user_data;
+ grpc_oauth2_token_fetcher_credentials* c =
+ (grpc_oauth2_token_fetcher_credentials*)r->creds;
grpc_mdelem access_token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_credentials_status status =
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- exec_ctx, &r->response, &access_token_md, &token_lifetime);
+ &r->response, &access_token_md, &token_lifetime);
// Update cache and grab list of pending requests.
gpr_mu_lock(&c->mu);
c->token_fetch_pending = false;
c->access_token_md = GRPC_MDELEM_REF(access_token_md);
- c->token_expiration =
- status == GRPC_CREDENTIALS_OK
- ? gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), token_lifetime)
- : gpr_inf_past(GPR_CLOCK_REALTIME);
- grpc_oauth2_pending_get_request_metadata *pending_request =
+ c->token_expiration = status == GRPC_CREDENTIALS_OK
+ ? grpc_core::ExecCtx::Get()->Now() + token_lifetime
+ : 0;
+ grpc_oauth2_pending_get_request_metadata* pending_request =
c->pending_requests;
- c->pending_requests = NULL;
+ c->pending_requests = nullptr;
gpr_mu_unlock(&c->mu);
// Invoke callbacks for all pending requests.
- while (pending_request != NULL) {
+ while (pending_request != nullptr) {
if (status == GRPC_CREDENTIALS_OK) {
grpc_credentials_mdelem_array_add(pending_request->md_array,
access_token_md);
@@ -239,53 +232,50 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx *exec_ctx,
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token.", &error, 1);
}
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata, error);
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, error);
grpc_polling_entity_del_from_pollset_set(
- exec_ctx, pending_request->pollent,
- grpc_polling_entity_pollset_set(&c->pollent));
- grpc_oauth2_pending_get_request_metadata *prev = pending_request;
+ pending_request->pollent, grpc_polling_entity_pollset_set(&c->pollent));
+ grpc_oauth2_pending_get_request_metadata* prev = pending_request;
pending_request = pending_request->next;
gpr_free(prev);
}
- GRPC_MDELEM_UNREF(exec_ctx, access_token_md);
- grpc_call_credentials_unref(exec_ctx, r->creds);
- grpc_credentials_metadata_request_destroy(exec_ctx, r);
+ GRPC_MDELEM_UNREF(access_token_md);
+ grpc_call_credentials_unref(r->creds);
+ grpc_credentials_metadata_request_destroy(r);
}
static bool oauth2_token_fetcher_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_polling_entity *pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_oauth2_token_fetcher_credentials *c =
- (grpc_oauth2_token_fetcher_credentials *)creds;
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
+ grpc_oauth2_token_fetcher_credentials* c =
+ (grpc_oauth2_token_fetcher_credentials*)creds;
// Check if we can use the cached token.
- gpr_timespec refresh_threshold = gpr_time_from_seconds(
- GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS, GPR_TIMESPAN);
+ grpc_millis refresh_threshold =
+ GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS * GPR_MS_PER_SEC;
grpc_mdelem cached_access_token_md = GRPC_MDNULL;
gpr_mu_lock(&c->mu);
if (!GRPC_MDISNULL(c->access_token_md) &&
- (gpr_time_cmp(
- gpr_time_sub(c->token_expiration, gpr_now(GPR_CLOCK_REALTIME)),
- refresh_threshold) > 0)) {
+ (c->token_expiration - grpc_core::ExecCtx::Get()->Now() >
+ refresh_threshold)) {
cached_access_token_md = GRPC_MDELEM_REF(c->access_token_md);
}
if (!GRPC_MDISNULL(cached_access_token_md)) {
gpr_mu_unlock(&c->mu);
grpc_credentials_mdelem_array_add(md_array, cached_access_token_md);
- GRPC_MDELEM_UNREF(exec_ctx, cached_access_token_md);
+ GRPC_MDELEM_UNREF(cached_access_token_md);
return true;
}
// Couldn't get the token from the cache.
// Add request to c->pending_requests and start a new fetch if needed.
- grpc_oauth2_pending_get_request_metadata *pending_request =
- (grpc_oauth2_pending_get_request_metadata *)gpr_malloc(
+ grpc_oauth2_pending_get_request_metadata* pending_request =
+ (grpc_oauth2_pending_get_request_metadata*)gpr_malloc(
sizeof(*pending_request));
pending_request->md_array = md_array;
pending_request->on_request_metadata = on_request_metadata;
pending_request->pollent = pollent;
grpc_polling_entity_add_to_pollset_set(
- exec_ctx, pollent, grpc_polling_entity_pollset_set(&c->pollent));
+ pollent, grpc_polling_entity_pollset_set(&c->pollent));
pending_request->next = c->pending_requests;
c->pending_requests = pending_request;
bool start_fetch = false;
@@ -296,33 +286,33 @@ static bool oauth2_token_fetcher_get_request_metadata(
gpr_mu_unlock(&c->mu);
if (start_fetch) {
grpc_call_credentials_ref(creds);
- c->fetch_func(
- exec_ctx, grpc_credentials_metadata_request_create(creds),
- &c->httpcli_context, &c->pollent, on_oauth2_token_fetcher_http_response,
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), refresh_threshold));
+ c->fetch_func(grpc_credentials_metadata_request_create(creds),
+ &c->httpcli_context, &c->pollent,
+ on_oauth2_token_fetcher_http_response,
+ grpc_core::ExecCtx::Get()->Now() + refresh_threshold);
}
return false;
}
static void oauth2_token_fetcher_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
- grpc_oauth2_token_fetcher_credentials *c =
- (grpc_oauth2_token_fetcher_credentials *)creds;
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
+ grpc_oauth2_token_fetcher_credentials* c =
+ (grpc_oauth2_token_fetcher_credentials*)creds;
gpr_mu_lock(&c->mu);
- grpc_oauth2_pending_get_request_metadata *prev = NULL;
- grpc_oauth2_pending_get_request_metadata *pending_request =
+ grpc_oauth2_pending_get_request_metadata* prev = nullptr;
+ grpc_oauth2_pending_get_request_metadata* pending_request =
c->pending_requests;
- while (pending_request != NULL) {
+ while (pending_request != nullptr) {
if (pending_request->md_array == md_array) {
// Remove matching pending request from the list.
- if (prev != NULL) {
+ if (prev != nullptr) {
prev->next = pending_request->next;
} else {
c->pending_requests = pending_request->next;
}
// Invoke the callback immediately with an error.
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata,
GRPC_ERROR_REF(error));
gpr_free(pending_request);
break;
@@ -334,13 +324,13 @@ static void oauth2_token_fetcher_cancel_get_request_metadata(
GRPC_ERROR_UNREF(error);
}
-static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials *c,
+static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials* c,
grpc_fetch_oauth2_func fetch_func) {
memset(c, 0, sizeof(grpc_oauth2_token_fetcher_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
gpr_ref_init(&c->base.refcount, 1);
gpr_mu_init(&c->mu);
- c->token_expiration = gpr_inf_past(GPR_CLOCK_REALTIME);
+ c->token_expiration = 0;
c->fetch_func = fetch_func;
c->pollent =
grpc_polling_entity_create_from_pollset_set(grpc_pollset_set_create());
@@ -356,35 +346,36 @@ static grpc_call_credentials_vtable compute_engine_vtable = {
oauth2_token_fetcher_cancel_get_request_metadata};
static void compute_engine_fetch_oauth2(
- grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req,
- grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent,
- grpc_iomgr_cb_func response_cb, gpr_timespec deadline) {
- grpc_http_header header = {"Metadata-Flavor", "Google"};
+ grpc_credentials_metadata_request* metadata_req,
+ grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
+ grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
+ grpc_http_header header = {(char*)"Metadata-Flavor", (char*)"Google"};
grpc_httpcli_request request;
memset(&request, 0, sizeof(grpc_httpcli_request));
- request.host = GRPC_COMPUTE_ENGINE_METADATA_HOST;
- request.http.path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
+ request.host = (char*)GRPC_COMPUTE_ENGINE_METADATA_HOST;
+ request.http.path = (char*)GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
request.http.hdr_count = 1;
request.http.hdrs = &header;
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials");
grpc_httpcli_get(
- exec_ctx, httpcli_context, pollent, resource_quota, &request, deadline,
+ httpcli_context, pollent, resource_quota, &request, deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
-grpc_call_credentials *grpc_google_compute_engine_credentials_create(
- void *reserved) {
- grpc_oauth2_token_fetcher_credentials *c =
- gpr_malloc(sizeof(grpc_oauth2_token_fetcher_credentials));
+grpc_call_credentials* grpc_google_compute_engine_credentials_create(
+ void* reserved) {
+ grpc_oauth2_token_fetcher_credentials* c =
+ (grpc_oauth2_token_fetcher_credentials*)gpr_malloc(
+ sizeof(grpc_oauth2_token_fetcher_credentials));
GRPC_API_TRACE("grpc_compute_engine_credentials_create(reserved=%p)", 1,
(reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
init_oauth2_token_fetcher(c, compute_engine_fetch_oauth2);
c->base.vtable = &compute_engine_vtable;
return &c->base;
@@ -394,12 +385,11 @@ grpc_call_credentials *grpc_google_compute_engine_credentials_create(
// Google Refresh Token credentials.
//
-static void refresh_token_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_google_refresh_token_credentials *c =
- (grpc_google_refresh_token_credentials *)creds;
+static void refresh_token_destruct(grpc_call_credentials* creds) {
+ grpc_google_refresh_token_credentials* c =
+ (grpc_google_refresh_token_credentials*)creds;
grpc_auth_refresh_token_destruct(&c->refresh_token);
- oauth2_token_fetcher_destruct(exec_ctx, &c->base.base);
+ oauth2_token_fetcher_destruct(&c->base.base);
}
static grpc_call_credentials_vtable refresh_token_vtable = {
@@ -407,58 +397,59 @@ static grpc_call_credentials_vtable refresh_token_vtable = {
oauth2_token_fetcher_cancel_get_request_metadata};
static void refresh_token_fetch_oauth2(
- grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req,
- grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent,
- grpc_iomgr_cb_func response_cb, gpr_timespec deadline) {
- grpc_google_refresh_token_credentials *c =
- (grpc_google_refresh_token_credentials *)metadata_req->creds;
- grpc_http_header header = {"Content-Type",
- "application/x-www-form-urlencoded"};
+ grpc_credentials_metadata_request* metadata_req,
+ grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
+ grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
+ grpc_google_refresh_token_credentials* c =
+ (grpc_google_refresh_token_credentials*)metadata_req->creds;
+ grpc_http_header header = {(char*)"Content-Type",
+ (char*)"application/x-www-form-urlencoded"};
grpc_httpcli_request request;
- char *body = NULL;
+ char* body = nullptr;
gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
c->refresh_token.client_id, c->refresh_token.client_secret,
c->refresh_token.refresh_token);
memset(&request, 0, sizeof(grpc_httpcli_request));
- request.host = GRPC_GOOGLE_OAUTH2_SERVICE_HOST;
- request.http.path = GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
+ request.host = (char*)GRPC_GOOGLE_OAUTH2_SERVICE_HOST;
+ request.http.path = (char*)GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
request.http.hdr_count = 1;
request.http.hdrs = &header;
request.handshaker = &grpc_httpcli_ssl;
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials_refresh");
grpc_httpcli_post(
- exec_ctx, httpcli_context, pollent, resource_quota, &request, body,
- strlen(body), deadline,
+ httpcli_context, pollent, resource_quota, &request, body, strlen(body),
+ deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_free(body);
}
-grpc_call_credentials *
+grpc_call_credentials*
grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_auth_refresh_token refresh_token) {
- grpc_google_refresh_token_credentials *c;
+ grpc_google_refresh_token_credentials* c;
if (!grpc_auth_refresh_token_is_valid(&refresh_token)) {
gpr_log(GPR_ERROR, "Invalid input for refresh token credentials creation");
- return NULL;
+ return nullptr;
}
- c = gpr_zalloc(sizeof(grpc_google_refresh_token_credentials));
+ c = (grpc_google_refresh_token_credentials*)gpr_zalloc(
+ sizeof(grpc_google_refresh_token_credentials));
init_oauth2_token_fetcher(&c->base, refresh_token_fetch_oauth2);
c->base.base.vtable = &refresh_token_vtable;
c->refresh_token = refresh_token;
return &c->base.base;
}
-static char *create_loggable_refresh_token(grpc_auth_refresh_token *token) {
+static char* create_loggable_refresh_token(grpc_auth_refresh_token* token) {
if (strcmp(token->type, GRPC_AUTH_JSON_TYPE_INVALID) == 0) {
return gpr_strdup("<Invalid json token>");
}
- char *loggable_token = NULL;
+ char* loggable_token = nullptr;
gpr_asprintf(&loggable_token,
"{\n type: %s\n client_id: %s\n client_secret: "
"<redacted>\n refresh_token: <redacted>\n}",
@@ -466,19 +457,19 @@ static char *create_loggable_refresh_token(grpc_auth_refresh_token *token) {
return loggable_token;
}
-grpc_call_credentials *grpc_google_refresh_token_credentials_create(
- const char *json_refresh_token, void *reserved) {
+grpc_call_credentials* grpc_google_refresh_token_credentials_create(
+ const char* json_refresh_token, void* reserved) {
grpc_auth_refresh_token token =
grpc_auth_refresh_token_create_from_string(json_refresh_token);
- if (GRPC_TRACER_ON(grpc_api_trace)) {
- char *loggable_token = create_loggable_refresh_token(&token);
+ if (grpc_api_trace.enabled()) {
+ char* loggable_token = create_loggable_refresh_token(&token);
gpr_log(GPR_INFO,
"grpc_refresh_token_credentials_create(json_refresh_token=%s, "
"reserved=%p)",
loggable_token, reserved);
gpr_free(loggable_token);
}
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
return grpc_refresh_token_credentials_create_from_auth_refresh_token(token);
}
@@ -486,25 +477,23 @@ grpc_call_credentials *grpc_google_refresh_token_credentials_create(
// Oauth2 Access Token credentials.
//
-static void access_token_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_access_token_credentials *c = (grpc_access_token_credentials *)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
+static void access_token_destruct(grpc_call_credentials* creds) {
+ grpc_access_token_credentials* c = (grpc_access_token_credentials*)creds;
+ GRPC_MDELEM_UNREF(c->access_token_md);
}
static bool access_token_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_polling_entity *pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_access_token_credentials *c = (grpc_access_token_credentials *)creds;
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
+ grpc_access_token_credentials* c = (grpc_access_token_credentials*)creds;
grpc_credentials_mdelem_array_add(md_array, c->access_token_md);
return true;
}
static void access_token_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -512,25 +501,25 @@ static grpc_call_credentials_vtable access_token_vtable = {
access_token_destruct, access_token_get_request_metadata,
access_token_cancel_get_request_metadata};
-grpc_call_credentials *grpc_access_token_credentials_create(
- const char *access_token, void *reserved) {
- grpc_access_token_credentials *c =
- gpr_zalloc(sizeof(grpc_access_token_credentials));
+grpc_call_credentials* grpc_access_token_credentials_create(
+ const char* access_token, void* reserved) {
+ grpc_access_token_credentials* c = (grpc_access_token_credentials*)gpr_zalloc(
+ sizeof(grpc_access_token_credentials));
GRPC_API_TRACE(
"grpc_access_token_credentials_create(access_token=<redacted>, "
"reserved=%p)",
1, (reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &access_token_vtable;
gpr_ref_init(&c->base.refcount, 1);
- char *token_md_value;
+ char* token_md_value;
gpr_asprintf(&token_md_value, "Bearer %s", access_token);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
c->access_token_md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
+ grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(token_md_value));
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(token_md_value);
return &c->base;
}
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
index d9ad6691b8..e5b8df8eb9 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
@@ -24,55 +24,54 @@
// auth_refresh_token parsing.
typedef struct {
- const char *type;
- char *client_id;
- char *client_secret;
- char *refresh_token;
+ const char* type;
+ char* client_id;
+ char* client_secret;
+ char* refresh_token;
} grpc_auth_refresh_token;
/// Returns 1 if the object is valid, 0 otherwise.
int grpc_auth_refresh_token_is_valid(
- const grpc_auth_refresh_token *refresh_token);
+ const grpc_auth_refresh_token* refresh_token);
/// Creates a refresh token object from string. Returns an invalid object if a
/// parsing error has been encountered.
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
- const char *json_string);
+ const char* json_string);
/// Creates a refresh token object from parsed json. Returns an invalid object
/// if a parsing error has been encountered.
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
- const grpc_json *json);
+ const grpc_json* json);
/// Destructs the object.
-void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token *refresh_token);
+void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token);
// -- Oauth2 Token Fetcher credentials --
//
// This object is a base for credentials that need to acquire an oauth2 token
// from an http service.
-typedef void (*grpc_fetch_oauth2_func)(grpc_exec_ctx *exec_ctx,
- grpc_credentials_metadata_request *req,
- grpc_httpcli_context *http_context,
- grpc_polling_entity *pollent,
+typedef void (*grpc_fetch_oauth2_func)(grpc_credentials_metadata_request* req,
+ grpc_httpcli_context* http_context,
+ grpc_polling_entity* pollent,
grpc_iomgr_cb_func cb,
- gpr_timespec deadline);
+ grpc_millis deadline);
typedef struct grpc_oauth2_pending_get_request_metadata {
- grpc_credentials_mdelem_array *md_array;
- grpc_closure *on_request_metadata;
- grpc_polling_entity *pollent;
- struct grpc_oauth2_pending_get_request_metadata *next;
+ grpc_credentials_mdelem_array* md_array;
+ grpc_closure* on_request_metadata;
+ grpc_polling_entity* pollent;
+ struct grpc_oauth2_pending_get_request_metadata* next;
} grpc_oauth2_pending_get_request_metadata;
typedef struct {
grpc_call_credentials base;
gpr_mu mu;
grpc_mdelem access_token_md;
- gpr_timespec token_expiration;
+ grpc_millis token_expiration;
bool token_fetch_pending;
- grpc_oauth2_pending_get_request_metadata *pending_requests;
+ grpc_oauth2_pending_get_request_metadata* pending_requests;
grpc_httpcli_context httpcli_context;
grpc_fetch_oauth2_func fetch_func;
grpc_polling_entity pollent;
@@ -92,14 +91,14 @@ typedef struct {
// Private constructor for refresh token credentials from an already parsed
// refresh token. Takes ownership of the refresh token.
-grpc_call_credentials *
+grpc_call_credentials*
grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_auth_refresh_token token);
// Exposed for testing only.
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- grpc_exec_ctx *exec_ctx, const struct grpc_http_response *response,
- grpc_mdelem *token_md, gpr_timespec *token_lifetime);
+ const struct grpc_http_response* response, grpc_mdelem* token_md,
+ grpc_millis* token_lifetime);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.c b/src/core/lib/security/credentials/plugin/plugin_credentials.c
deleted file mode 100644
index 73e0c23e0f..0000000000
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.c
+++ /dev/null
@@ -1,189 +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 "src/core/lib/security/credentials/plugin/plugin_credentials.h"
-
-#include <string.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/sync.h>
-
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/surface/api_trace.h"
-#include "src/core/lib/surface/validate_metadata.h"
-
-static void plugin_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
- grpc_plugin_credentials *c = (grpc_plugin_credentials *)creds;
- gpr_mu_destroy(&c->mu);
- if (c->plugin.state != NULL && c->plugin.destroy != NULL) {
- c->plugin.destroy(c->plugin.state);
- }
-}
-
-static void pending_request_remove_locked(
- grpc_plugin_credentials *c,
- grpc_plugin_credentials_pending_request *pending_request) {
- if (pending_request->prev == NULL) {
- c->pending_requests = pending_request->next;
- } else {
- pending_request->prev->next = pending_request->next;
- }
- if (pending_request->next != NULL) {
- pending_request->next->prev = pending_request->prev;
- }
-}
-
-static void plugin_md_request_metadata_ready(void *request,
- const grpc_metadata *md,
- size_t num_md,
- grpc_status_code status,
- const char *error_details) {
- /* called from application code */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(
- GRPC_EXEC_CTX_FLAG_IS_FINISHED | GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP,
- NULL, NULL);
- grpc_plugin_credentials_pending_request *r =
- (grpc_plugin_credentials_pending_request *)request;
- // Check if the request has been cancelled.
- // If not, remove it from the pending list, so that it cannot be
- // cancelled out from under us.
- gpr_mu_lock(&r->creds->mu);
- if (!r->cancelled) pending_request_remove_locked(r->creds, r);
- gpr_mu_unlock(&r->creds->mu);
- grpc_call_credentials_unref(&exec_ctx, &r->creds->base);
- // If it has not been cancelled, process it.
- if (!r->cancelled) {
- if (status != GRPC_STATUS_OK) {
- char *msg;
- gpr_asprintf(&msg, "Getting metadata from plugin failed with error: %s",
- error_details);
- GRPC_CLOSURE_SCHED(&exec_ctx, r->on_request_metadata,
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
- gpr_free(msg);
- } else {
- bool seen_illegal_header = false;
- for (size_t i = 0; i < num_md; ++i) {
- if (!GRPC_LOG_IF_ERROR("validate_metadata_from_plugin",
- grpc_validate_header_key_is_legal(md[i].key))) {
- seen_illegal_header = true;
- break;
- } else if (!grpc_is_binary_header(md[i].key) &&
- !GRPC_LOG_IF_ERROR(
- "validate_metadata_from_plugin",
- grpc_validate_header_nonbin_value_is_legal(
- md[i].value))) {
- gpr_log(GPR_ERROR, "Plugin added invalid metadata value.");
- seen_illegal_header = true;
- break;
- }
- }
- if (seen_illegal_header) {
- GRPC_CLOSURE_SCHED(
- &exec_ctx, r->on_request_metadata,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata"));
- } else {
- for (size_t i = 0; i < num_md; ++i) {
- grpc_mdelem mdelem = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_ref_internal(md[i].key),
- grpc_slice_ref_internal(md[i].value));
- grpc_credentials_mdelem_array_add(r->md_array, mdelem);
- GRPC_MDELEM_UNREF(&exec_ctx, mdelem);
- }
- GRPC_CLOSURE_SCHED(&exec_ctx, r->on_request_metadata, GRPC_ERROR_NONE);
- }
- }
- }
- gpr_free(r);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static bool plugin_get_request_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds,
- grpc_polling_entity *pollent,
- grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array *md_array,
- grpc_closure *on_request_metadata,
- grpc_error **error) {
- grpc_plugin_credentials *c = (grpc_plugin_credentials *)creds;
- if (c->plugin.get_metadata != NULL) {
- // Create pending_request object.
- grpc_plugin_credentials_pending_request *pending_request =
- (grpc_plugin_credentials_pending_request *)gpr_zalloc(
- sizeof(*pending_request));
- pending_request->creds = c;
- pending_request->md_array = md_array;
- pending_request->on_request_metadata = on_request_metadata;
- // Add it to the pending list.
- gpr_mu_lock(&c->mu);
- if (c->pending_requests != NULL) {
- c->pending_requests->prev = pending_request;
- }
- pending_request->next = c->pending_requests;
- c->pending_requests = pending_request;
- gpr_mu_unlock(&c->mu);
- // Invoke the plugin. The callback holds a ref to us.
- grpc_call_credentials_ref(creds);
- c->plugin.get_metadata(c->plugin.state, context,
- plugin_md_request_metadata_ready, pending_request);
- return false;
- }
- return true;
-}
-
-static void plugin_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
- grpc_plugin_credentials *c = (grpc_plugin_credentials *)creds;
- gpr_mu_lock(&c->mu);
- for (grpc_plugin_credentials_pending_request *pending_request =
- c->pending_requests;
- pending_request != NULL; pending_request = pending_request->next) {
- if (pending_request->md_array == md_array) {
- pending_request->cancelled = true;
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
- GRPC_ERROR_REF(error));
- pending_request_remove_locked(c, pending_request);
- break;
- }
- }
- gpr_mu_unlock(&c->mu);
- GRPC_ERROR_UNREF(error);
-}
-
-static grpc_call_credentials_vtable plugin_vtable = {
- plugin_destruct, plugin_get_request_metadata,
- plugin_cancel_get_request_metadata};
-
-grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
- grpc_metadata_credentials_plugin plugin, void *reserved) {
- grpc_plugin_credentials *c = gpr_zalloc(sizeof(*c));
- GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1,
- (reserved));
- GPR_ASSERT(reserved == NULL);
- c->base.type = plugin.type;
- c->base.vtable = &plugin_vtable;
- gpr_ref_init(&c->base.refcount, 1);
- c->plugin = plugin;
- gpr_mu_init(&c->mu);
- return &c->base;
-}
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
new file mode 100644
index 0000000000..203ba58c67
--- /dev/null
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
@@ -0,0 +1,265 @@
+/*
+ *
+ * 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 "src/core/lib/security/credentials/plugin/plugin_credentials.h"
+
+#include <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+#include "src/core/lib/surface/api_trace.h"
+#include "src/core/lib/surface/validate_metadata.h"
+
+grpc_core::TraceFlag grpc_plugin_credentials_trace(false, "plugin_credentials");
+
+static void plugin_destruct(grpc_call_credentials* creds) {
+ grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
+ gpr_mu_destroy(&c->mu);
+ if (c->plugin.state != nullptr && c->plugin.destroy != nullptr) {
+ c->plugin.destroy(c->plugin.state);
+ }
+}
+
+static void pending_request_remove_locked(
+ grpc_plugin_credentials* c,
+ grpc_plugin_credentials_pending_request* pending_request) {
+ if (pending_request->prev == nullptr) {
+ c->pending_requests = pending_request->next;
+ } else {
+ pending_request->prev->next = pending_request->next;
+ }
+ if (pending_request->next != nullptr) {
+ pending_request->next->prev = pending_request->prev;
+ }
+}
+
+// Checks if the request has been cancelled.
+// If not, removes it from the pending list, so that it cannot be
+// cancelled out from under us.
+// When this returns, r->cancelled indicates whether the request was
+// cancelled before completion.
+static void pending_request_complete(
+ grpc_plugin_credentials_pending_request* r) {
+ gpr_mu_lock(&r->creds->mu);
+ if (!r->cancelled) pending_request_remove_locked(r->creds, r);
+ gpr_mu_unlock(&r->creds->mu);
+ // Ref to credentials not needed anymore.
+ grpc_call_credentials_unref(&r->creds->base);
+}
+
+static grpc_error* process_plugin_result(
+ grpc_plugin_credentials_pending_request* r, const grpc_metadata* md,
+ size_t num_md, grpc_status_code status, const char* error_details) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (status != GRPC_STATUS_OK) {
+ char* msg;
+ gpr_asprintf(&msg, "Getting metadata from plugin failed with error: %s",
+ error_details);
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ gpr_free(msg);
+ } else {
+ bool seen_illegal_header = false;
+ for (size_t i = 0; i < num_md; ++i) {
+ if (!GRPC_LOG_IF_ERROR("validate_metadata_from_plugin",
+ grpc_validate_header_key_is_legal(md[i].key))) {
+ seen_illegal_header = true;
+ break;
+ } else if (!grpc_is_binary_header(md[i].key) &&
+ !GRPC_LOG_IF_ERROR(
+ "validate_metadata_from_plugin",
+ grpc_validate_header_nonbin_value_is_legal(md[i].value))) {
+ gpr_log(GPR_ERROR, "Plugin added invalid metadata value.");
+ seen_illegal_header = true;
+ break;
+ }
+ }
+ if (seen_illegal_header) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata");
+ } else {
+ for (size_t i = 0; i < num_md; ++i) {
+ grpc_mdelem mdelem =
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(md[i].key),
+ grpc_slice_ref_internal(md[i].value));
+ grpc_credentials_mdelem_array_add(r->md_array, mdelem);
+ GRPC_MDELEM_UNREF(mdelem);
+ }
+ }
+ }
+ return error;
+}
+
+static void plugin_md_request_metadata_ready(void* request,
+ const grpc_metadata* md,
+ size_t num_md,
+ grpc_status_code status,
+ const char* error_details) {
+ /* called from application code */
+ grpc_core::ExecCtx exec_ctx(GRPC_EXEC_CTX_FLAG_IS_FINISHED |
+ GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP);
+ grpc_plugin_credentials_pending_request* r =
+ (grpc_plugin_credentials_pending_request*)request;
+ if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "plugin_credentials[%p]: request %p: plugin returned "
+ "asynchronously",
+ r->creds, r);
+ }
+ // Remove request from pending list if not previously cancelled.
+ pending_request_complete(r);
+ // If it has not been cancelled, process it.
+ if (!r->cancelled) {
+ grpc_error* error =
+ process_plugin_result(r, md, num_md, status, error_details);
+ GRPC_CLOSURE_SCHED(r->on_request_metadata, error);
+ } else if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "plugin_credentials[%p]: request %p: plugin was previously "
+ "cancelled",
+ r->creds, r);
+ }
+ gpr_free(r);
+}
+
+static bool plugin_get_request_metadata(grpc_call_credentials* creds,
+ grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context,
+ grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata,
+ grpc_error** error) {
+ grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
+ bool retval = true; // Synchronous return.
+ if (c->plugin.get_metadata != nullptr) {
+ // Create pending_request object.
+ grpc_plugin_credentials_pending_request* pending_request =
+ (grpc_plugin_credentials_pending_request*)gpr_zalloc(
+ sizeof(*pending_request));
+ pending_request->creds = c;
+ pending_request->md_array = md_array;
+ pending_request->on_request_metadata = on_request_metadata;
+ // Add it to the pending list.
+ gpr_mu_lock(&c->mu);
+ if (c->pending_requests != nullptr) {
+ c->pending_requests->prev = pending_request;
+ }
+ pending_request->next = c->pending_requests;
+ c->pending_requests = pending_request;
+ gpr_mu_unlock(&c->mu);
+ // Invoke the plugin. The callback holds a ref to us.
+ if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: invoking plugin",
+ c, pending_request);
+ }
+ grpc_call_credentials_ref(creds);
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX];
+ size_t num_creds_md = 0;
+ grpc_status_code status = GRPC_STATUS_OK;
+ const char* error_details = nullptr;
+ if (!c->plugin.get_metadata(c->plugin.state, context,
+ plugin_md_request_metadata_ready,
+ pending_request, creds_md, &num_creds_md,
+ &status, &error_details)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "plugin_credentials[%p]: request %p: plugin will return "
+ "asynchronously",
+ c, pending_request);
+ }
+ return false; // Asynchronous return.
+ }
+ // Returned synchronously.
+ // Remove request from pending list if not previously cancelled.
+ pending_request_complete(pending_request);
+ // If the request was cancelled, the error will have been returned
+ // asynchronously by plugin_cancel_get_request_metadata(), so return
+ // false. Otherwise, process the result.
+ if (pending_request->cancelled) {
+ if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "plugin_credentials[%p]: request %p was cancelled, error "
+ "will be returned asynchronously",
+ c, pending_request);
+ }
+ retval = false;
+ } else {
+ if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO,
+ "plugin_credentials[%p]: request %p: plugin returned "
+ "synchronously",
+ c, pending_request);
+ }
+ *error = process_plugin_result(pending_request, creds_md, num_creds_md,
+ status, error_details);
+ }
+ // Clean up.
+ for (size_t i = 0; i < num_creds_md; ++i) {
+ grpc_slice_unref_internal(creds_md[i].key);
+ grpc_slice_unref_internal(creds_md[i].value);
+ }
+ gpr_free((void*)error_details);
+ gpr_free(pending_request);
+ }
+ return retval;
+}
+
+static void plugin_cancel_get_request_metadata(
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
+ grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
+ gpr_mu_lock(&c->mu);
+ for (grpc_plugin_credentials_pending_request* pending_request =
+ c->pending_requests;
+ pending_request != nullptr; pending_request = pending_request->next) {
+ if (pending_request->md_array == md_array) {
+ if (grpc_plugin_credentials_trace.enabled()) {
+ gpr_log(GPR_INFO, "plugin_credentials[%p]: cancelling request %p", c,
+ pending_request);
+ }
+ pending_request->cancelled = true;
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata,
+ GRPC_ERROR_REF(error));
+ pending_request_remove_locked(c, pending_request);
+ break;
+ }
+ }
+ gpr_mu_unlock(&c->mu);
+ GRPC_ERROR_UNREF(error);
+}
+
+static grpc_call_credentials_vtable plugin_vtable = {
+ plugin_destruct, plugin_get_request_metadata,
+ plugin_cancel_get_request_metadata};
+
+grpc_call_credentials* grpc_metadata_credentials_create_from_plugin(
+ grpc_metadata_credentials_plugin plugin, void* reserved) {
+ grpc_plugin_credentials* c = (grpc_plugin_credentials*)gpr_zalloc(sizeof(*c));
+ GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1,
+ (reserved));
+ GPR_ASSERT(reserved == nullptr);
+ c->base.type = plugin.type;
+ c->base.vtable = &plugin_vtable;
+ gpr_ref_init(&c->base.refcount, 1);
+ c->plugin = plugin;
+ gpr_mu_init(&c->mu);
+ return &c->base;
+}
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h
index 57266d589a..e1467b0824 100644
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.h
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h
@@ -21,22 +21,24 @@
#include "src/core/lib/security/credentials/credentials.h"
+extern grpc_core::TraceFlag grpc_plugin_credentials_trace;
+
struct grpc_plugin_credentials;
typedef struct grpc_plugin_credentials_pending_request {
bool cancelled;
- struct grpc_plugin_credentials *creds;
- grpc_credentials_mdelem_array *md_array;
- grpc_closure *on_request_metadata;
- struct grpc_plugin_credentials_pending_request *prev;
- struct grpc_plugin_credentials_pending_request *next;
+ struct grpc_plugin_credentials* creds;
+ grpc_credentials_mdelem_array* md_array;
+ grpc_closure* on_request_metadata;
+ struct grpc_plugin_credentials_pending_request* prev;
+ struct grpc_plugin_credentials_pending_request* next;
} grpc_plugin_credentials_pending_request;
typedef struct grpc_plugin_credentials {
grpc_call_credentials base;
grpc_metadata_credentials_plugin plugin;
gpr_mu mu;
- grpc_plugin_credentials_pending_request *pending_requests;
+ grpc_plugin_credentials_pending_request* pending_requests;
} grpc_plugin_credentials;
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.c b/src/core/lib/security/credentials/ssl/ssl_credentials.c
deleted file mode 100644
index 006db1ec76..0000000000
--- a/src/core/lib/security/credentials/ssl/ssl_credentials.c
+++ /dev/null
@@ -1,194 +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 "src/core/lib/security/credentials/ssl/ssl_credentials.h"
-
-#include <string.h>
-
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/surface/api_trace.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-//
-// SSL Channel Credentials.
-//
-
-static void ssl_config_pem_key_cert_pair_destroy(
- tsi_ssl_pem_key_cert_pair *kp) {
- if (kp == NULL) return;
- gpr_free((void *)kp->private_key);
- gpr_free((void *)kp->cert_chain);
-}
-
-static void ssl_destruct(grpc_exec_ctx *exec_ctx,
- grpc_channel_credentials *creds) {
- grpc_ssl_credentials *c = (grpc_ssl_credentials *)creds;
- gpr_free(c->config.pem_root_certs);
- ssl_config_pem_key_cert_pair_destroy(&c->config.pem_key_cert_pair);
-}
-
-static grpc_security_status ssl_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *creds,
- grpc_call_credentials *call_creds, const char *target,
- const grpc_channel_args *args, grpc_channel_security_connector **sc,
- grpc_channel_args **new_args) {
- grpc_ssl_credentials *c = (grpc_ssl_credentials *)creds;
- grpc_security_status status = GRPC_SECURITY_OK;
- const char *overridden_target_name = NULL;
- for (size_t i = 0; args && i < args->num_args; i++) {
- grpc_arg *arg = &args->args[i];
- if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 &&
- arg->type == GRPC_ARG_STRING) {
- overridden_target_name = arg->value.string;
- break;
- }
- }
- status = grpc_ssl_channel_security_connector_create(
- exec_ctx, call_creds, &c->config, target, overridden_target_name, sc);
- if (status != GRPC_SECURITY_OK) {
- return status;
- }
- grpc_arg new_arg =
- grpc_channel_arg_string_create(GRPC_ARG_HTTP2_SCHEME, "https");
- *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
- return status;
-}
-
-static grpc_channel_credentials_vtable ssl_vtable = {
- ssl_destruct, ssl_create_security_connector, NULL};
-
-static void ssl_build_config(const char *pem_root_certs,
- grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
- grpc_ssl_config *config) {
- if (pem_root_certs != NULL) {
- config->pem_root_certs = gpr_strdup(pem_root_certs);
- }
- if (pem_key_cert_pair != NULL) {
- GPR_ASSERT(pem_key_cert_pair->private_key != NULL);
- GPR_ASSERT(pem_key_cert_pair->cert_chain != NULL);
- config->pem_key_cert_pair.cert_chain =
- gpr_strdup(pem_key_cert_pair->cert_chain);
- config->pem_key_cert_pair.private_key =
- gpr_strdup(pem_key_cert_pair->private_key);
- }
-}
-
-grpc_channel_credentials *grpc_ssl_credentials_create(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
- void *reserved) {
- grpc_ssl_credentials *c = gpr_zalloc(sizeof(grpc_ssl_credentials));
- GRPC_API_TRACE(
- "grpc_ssl_credentials_create(pem_root_certs=%s, "
- "pem_key_cert_pair=%p, "
- "reserved=%p)",
- 3, (pem_root_certs, pem_key_cert_pair, reserved));
- GPR_ASSERT(reserved == NULL);
- c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
- c->base.vtable = &ssl_vtable;
- gpr_ref_init(&c->base.refcount, 1);
- ssl_build_config(pem_root_certs, pem_key_cert_pair, &c->config);
- return &c->base;
-}
-
-//
-// SSL Server Credentials.
-//
-
-static void ssl_server_destruct(grpc_exec_ctx *exec_ctx,
- grpc_server_credentials *creds) {
- grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds;
- size_t i;
- for (i = 0; i < c->config.num_key_cert_pairs; i++) {
- ssl_config_pem_key_cert_pair_destroy(&c->config.pem_key_cert_pairs[i]);
- }
- gpr_free(c->config.pem_key_cert_pairs);
- gpr_free(c->config.pem_root_certs);
-}
-
-static grpc_security_status ssl_server_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_server_credentials *creds,
- grpc_server_security_connector **sc) {
- grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds;
- return grpc_ssl_server_security_connector_create(exec_ctx, &c->config, sc);
-}
-
-static grpc_server_credentials_vtable ssl_server_vtable = {
- ssl_server_destruct, ssl_server_create_security_connector};
-
-static void ssl_build_server_config(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs,
- grpc_ssl_client_certificate_request_type client_certificate_request,
- grpc_ssl_server_config *config) {
- size_t i;
- config->client_certificate_request = client_certificate_request;
- if (pem_root_certs != NULL) {
- config->pem_root_certs = gpr_strdup(pem_root_certs);
- }
- if (num_key_cert_pairs > 0) {
- GPR_ASSERT(pem_key_cert_pairs != NULL);
- config->pem_key_cert_pairs =
- gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair));
- }
- config->num_key_cert_pairs = num_key_cert_pairs;
- for (i = 0; i < num_key_cert_pairs; i++) {
- GPR_ASSERT(pem_key_cert_pairs[i].private_key != NULL);
- GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != NULL);
- config->pem_key_cert_pairs[i].cert_chain =
- gpr_strdup(pem_key_cert_pairs[i].cert_chain);
- config->pem_key_cert_pairs[i].private_key =
- gpr_strdup(pem_key_cert_pairs[i].private_key);
- }
-}
-
-grpc_server_credentials *grpc_ssl_server_credentials_create(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, int force_client_auth, void *reserved) {
- return grpc_ssl_server_credentials_create_ex(
- pem_root_certs, pem_key_cert_pairs, num_key_cert_pairs,
- force_client_auth
- ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
- : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
- reserved);
-}
-
-grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs,
- grpc_ssl_client_certificate_request_type client_certificate_request,
- void *reserved) {
- grpc_ssl_server_credentials *c =
- gpr_zalloc(sizeof(grpc_ssl_server_credentials));
- GRPC_API_TRACE(
- "grpc_ssl_server_credentials_create_ex("
- "pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, "
- "client_certificate_request=%d, reserved=%p)",
- 5, (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs,
- client_certificate_request, reserved));
- GPR_ASSERT(reserved == NULL);
- c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
- gpr_ref_init(&c->base.refcount, 1);
- c->base.vtable = &ssl_server_vtable;
- ssl_build_server_config(pem_root_certs, pem_key_cert_pairs,
- num_key_cert_pairs, client_certificate_request,
- &c->config);
- return &c->base;
-}
diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
new file mode 100644
index 0000000000..d8546441c9
--- /dev/null
+++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
@@ -0,0 +1,339 @@
+/*
+ *
+ * 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 "src/core/lib/security/credentials/ssl/ssl_credentials.h"
+
+#include <string.h>
+
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/surface/api_trace.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+//
+// SSL Channel Credentials.
+//
+
+void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
+ size_t num_key_cert_pairs) {
+ if (kp == nullptr) return;
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
+ gpr_free((void*)kp[i].private_key);
+ gpr_free((void*)kp[i].cert_chain);
+ }
+ gpr_free(kp);
+}
+
+static void ssl_destruct(grpc_channel_credentials* creds) {
+ grpc_ssl_credentials* c = (grpc_ssl_credentials*)creds;
+ gpr_free(c->config.pem_root_certs);
+ grpc_tsi_ssl_pem_key_cert_pairs_destroy(c->config.pem_key_cert_pair, 1);
+}
+
+static grpc_security_status ssl_create_security_connector(
+ grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
+ grpc_ssl_credentials* c = (grpc_ssl_credentials*)creds;
+ grpc_security_status status = GRPC_SECURITY_OK;
+ const char* overridden_target_name = nullptr;
+ for (size_t i = 0; args && i < args->num_args; i++) {
+ grpc_arg* arg = &args->args[i];
+ if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 &&
+ arg->type == GRPC_ARG_STRING) {
+ overridden_target_name = arg->value.string;
+ break;
+ }
+ }
+ status = grpc_ssl_channel_security_connector_create(
+ creds, call_creds, &c->config, target, overridden_target_name, sc);
+ if (status != GRPC_SECURITY_OK) {
+ return status;
+ }
+ grpc_arg new_arg = grpc_channel_arg_string_create(
+ (char*)GRPC_ARG_HTTP2_SCHEME, (char*)"https");
+ *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
+ return status;
+}
+
+static grpc_channel_credentials_vtable ssl_vtable = {
+ ssl_destruct, ssl_create_security_connector, nullptr};
+
+static void ssl_build_config(const char* pem_root_certs,
+ grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
+ grpc_ssl_config* config) {
+ if (pem_root_certs != nullptr) {
+ config->pem_root_certs = gpr_strdup(pem_root_certs);
+ }
+ if (pem_key_cert_pair != nullptr) {
+ GPR_ASSERT(pem_key_cert_pair->private_key != nullptr);
+ GPR_ASSERT(pem_key_cert_pair->cert_chain != nullptr);
+ config->pem_key_cert_pair = (tsi_ssl_pem_key_cert_pair*)gpr_zalloc(
+ sizeof(tsi_ssl_pem_key_cert_pair));
+ config->pem_key_cert_pair->cert_chain =
+ gpr_strdup(pem_key_cert_pair->cert_chain);
+ config->pem_key_cert_pair->private_key =
+ gpr_strdup(pem_key_cert_pair->private_key);
+ }
+}
+
+grpc_channel_credentials* grpc_ssl_credentials_create(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
+ void* reserved) {
+ grpc_ssl_credentials* c =
+ (grpc_ssl_credentials*)gpr_zalloc(sizeof(grpc_ssl_credentials));
+ GRPC_API_TRACE(
+ "grpc_ssl_credentials_create(pem_root_certs=%s, "
+ "pem_key_cert_pair=%p, "
+ "reserved=%p)",
+ 3, (pem_root_certs, pem_key_cert_pair, reserved));
+ GPR_ASSERT(reserved == nullptr);
+ c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
+ c->base.vtable = &ssl_vtable;
+ gpr_ref_init(&c->base.refcount, 1);
+ ssl_build_config(pem_root_certs, pem_key_cert_pair, &c->config);
+ return &c->base;
+}
+
+//
+// SSL Server Credentials.
+//
+
+struct grpc_ssl_server_credentials_options {
+ grpc_ssl_client_certificate_request_type client_certificate_request;
+ grpc_ssl_server_certificate_config* certificate_config;
+ grpc_ssl_server_certificate_config_fetcher* certificate_config_fetcher;
+};
+
+static void ssl_server_destruct(grpc_server_credentials* creds) {
+ grpc_ssl_server_credentials* c = (grpc_ssl_server_credentials*)creds;
+ grpc_tsi_ssl_pem_key_cert_pairs_destroy(c->config.pem_key_cert_pairs,
+ c->config.num_key_cert_pairs);
+ gpr_free(c->config.pem_root_certs);
+}
+
+static grpc_security_status ssl_server_create_security_connector(
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
+ return grpc_ssl_server_security_connector_create(creds, sc);
+}
+
+static grpc_server_credentials_vtable ssl_server_vtable = {
+ ssl_server_destruct, ssl_server_create_security_connector};
+
+tsi_ssl_pem_key_cert_pair* grpc_convert_grpc_to_tsi_cert_pairs(
+ const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs) {
+ tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr;
+ if (num_key_cert_pairs > 0) {
+ GPR_ASSERT(pem_key_cert_pairs != nullptr);
+ tsi_pairs = (tsi_ssl_pem_key_cert_pair*)gpr_zalloc(
+ num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair));
+ }
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
+ GPR_ASSERT(pem_key_cert_pairs[i].private_key != nullptr);
+ GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != nullptr);
+ tsi_pairs[i].cert_chain = gpr_strdup(pem_key_cert_pairs[i].cert_chain);
+ tsi_pairs[i].private_key = gpr_strdup(pem_key_cert_pairs[i].private_key);
+ }
+ return tsi_pairs;
+}
+
+static void ssl_build_server_config(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs,
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_config* config) {
+ config->client_certificate_request = client_certificate_request;
+ if (pem_root_certs != nullptr) {
+ config->pem_root_certs = gpr_strdup(pem_root_certs);
+ }
+ config->pem_key_cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
+ pem_key_cert_pairs, num_key_cert_pairs);
+ config->num_key_cert_pairs = num_key_cert_pairs;
+}
+
+grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create(
+ const char* pem_root_certs,
+ const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs) {
+ grpc_ssl_server_certificate_config* config =
+ (grpc_ssl_server_certificate_config*)gpr_zalloc(
+ sizeof(grpc_ssl_server_certificate_config));
+ if (pem_root_certs != nullptr) {
+ config->pem_root_certs = gpr_strdup(pem_root_certs);
+ }
+ if (num_key_cert_pairs > 0) {
+ GPR_ASSERT(pem_key_cert_pairs != nullptr);
+ config->pem_key_cert_pairs = (grpc_ssl_pem_key_cert_pair*)gpr_zalloc(
+ num_key_cert_pairs * sizeof(grpc_ssl_pem_key_cert_pair));
+ }
+ config->num_key_cert_pairs = num_key_cert_pairs;
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
+ GPR_ASSERT(pem_key_cert_pairs[i].private_key != nullptr);
+ GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != nullptr);
+ config->pem_key_cert_pairs[i].cert_chain =
+ gpr_strdup(pem_key_cert_pairs[i].cert_chain);
+ config->pem_key_cert_pairs[i].private_key =
+ gpr_strdup(pem_key_cert_pairs[i].private_key);
+ }
+ return config;
+}
+
+void grpc_ssl_server_certificate_config_destroy(
+ grpc_ssl_server_certificate_config* config) {
+ if (config == nullptr) return;
+ for (size_t i = 0; i < config->num_key_cert_pairs; i++) {
+ gpr_free((void*)config->pem_key_cert_pairs[i].private_key);
+ gpr_free((void*)config->pem_key_cert_pairs[i].cert_chain);
+ }
+ gpr_free(config->pem_key_cert_pairs);
+ gpr_free(config->pem_root_certs);
+ gpr_free(config);
+}
+
+grpc_ssl_server_credentials_options*
+grpc_ssl_server_credentials_create_options_using_config(
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_certificate_config* config) {
+ grpc_ssl_server_credentials_options* options = nullptr;
+ if (config == nullptr) {
+ gpr_log(GPR_ERROR, "Certificate config must not be NULL.");
+ goto done;
+ }
+ options = (grpc_ssl_server_credentials_options*)gpr_zalloc(
+ sizeof(grpc_ssl_server_credentials_options));
+ options->client_certificate_request = client_certificate_request;
+ options->certificate_config = config;
+done:
+ return options;
+}
+
+grpc_ssl_server_credentials_options*
+grpc_ssl_server_credentials_create_options_using_config_fetcher(
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_certificate_config_callback cb, void* user_data) {
+ if (cb == nullptr) {
+ gpr_log(GPR_ERROR, "Invalid certificate config callback parameter.");
+ return nullptr;
+ }
+
+ grpc_ssl_server_certificate_config_fetcher* fetcher =
+ (grpc_ssl_server_certificate_config_fetcher*)gpr_zalloc(
+ sizeof(grpc_ssl_server_certificate_config_fetcher));
+ fetcher->cb = cb;
+ fetcher->user_data = user_data;
+
+ grpc_ssl_server_credentials_options* options =
+ (grpc_ssl_server_credentials_options*)gpr_zalloc(
+ sizeof(grpc_ssl_server_credentials_options));
+ options->client_certificate_request = client_certificate_request;
+ options->certificate_config_fetcher = fetcher;
+
+ return options;
+}
+
+grpc_server_credentials* grpc_ssl_server_credentials_create(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs, int force_client_auth, void* reserved) {
+ return grpc_ssl_server_credentials_create_ex(
+ pem_root_certs, pem_key_cert_pairs, num_key_cert_pairs,
+ force_client_auth
+ ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ reserved);
+}
+
+grpc_server_credentials* grpc_ssl_server_credentials_create_ex(
+ const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs,
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ void* reserved) {
+ GRPC_API_TRACE(
+ "grpc_ssl_server_credentials_create_ex("
+ "pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, "
+ "client_certificate_request=%d, reserved=%p)",
+ 5,
+ (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs,
+ client_certificate_request, reserved));
+ GPR_ASSERT(reserved == nullptr);
+
+ grpc_ssl_server_certificate_config* cert_config =
+ grpc_ssl_server_certificate_config_create(
+ pem_root_certs, pem_key_cert_pairs, num_key_cert_pairs);
+ grpc_ssl_server_credentials_options* options =
+ grpc_ssl_server_credentials_create_options_using_config(
+ client_certificate_request, cert_config);
+
+ return grpc_ssl_server_credentials_create_with_options(options);
+}
+
+grpc_server_credentials* grpc_ssl_server_credentials_create_with_options(
+ grpc_ssl_server_credentials_options* options) {
+ grpc_server_credentials* retval = nullptr;
+ grpc_ssl_server_credentials* c = nullptr;
+
+ if (options == nullptr) {
+ gpr_log(GPR_ERROR,
+ "Invalid options trying to create SSL server credentials.");
+ goto done;
+ }
+
+ if (options->certificate_config == nullptr &&
+ options->certificate_config_fetcher == nullptr) {
+ gpr_log(GPR_ERROR,
+ "SSL server credentials options must specify either "
+ "certificate config or fetcher.");
+ goto done;
+ } else if (options->certificate_config_fetcher != nullptr &&
+ options->certificate_config_fetcher->cb == nullptr) {
+ gpr_log(GPR_ERROR, "Certificate config fetcher callback must not be NULL.");
+ goto done;
+ }
+
+ c = (grpc_ssl_server_credentials*)gpr_zalloc(
+ sizeof(grpc_ssl_server_credentials));
+ c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
+ gpr_ref_init(&c->base.refcount, 1);
+ c->base.vtable = &ssl_server_vtable;
+
+ if (options->certificate_config_fetcher != nullptr) {
+ c->config.client_certificate_request = options->client_certificate_request;
+ c->certificate_config_fetcher = *options->certificate_config_fetcher;
+ } else {
+ ssl_build_server_config(options->certificate_config->pem_root_certs,
+ options->certificate_config->pem_key_cert_pairs,
+ options->certificate_config->num_key_cert_pairs,
+ options->client_certificate_request, &c->config);
+ }
+
+ retval = &c->base;
+
+done:
+ grpc_ssl_server_credentials_options_destroy(options);
+ return retval;
+}
+
+void grpc_ssl_server_credentials_options_destroy(
+ grpc_ssl_server_credentials_options* o) {
+ if (o == nullptr) return;
+ gpr_free(o->certificate_config_fetcher);
+ grpc_ssl_server_certificate_config_destroy(o->certificate_config);
+ gpr_free(o);
+}
diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.h b/src/core/lib/security/credentials/ssl/ssl_credentials.h
index b43c656cd7..0003905857 100644
--- a/src/core/lib/security/credentials/ssl/ssl_credentials.h
+++ b/src/core/lib/security/credentials/ssl/ssl_credentials.h
@@ -25,9 +25,28 @@ typedef struct {
grpc_ssl_config config;
} grpc_ssl_credentials;
+struct grpc_ssl_server_certificate_config {
+ grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs;
+ size_t num_key_cert_pairs;
+ char* pem_root_certs;
+};
+
+typedef struct {
+ grpc_ssl_server_certificate_config_callback cb;
+ void* user_data;
+} grpc_ssl_server_certificate_config_fetcher;
+
typedef struct {
grpc_server_credentials base;
grpc_ssl_server_config config;
+ grpc_ssl_server_certificate_config_fetcher certificate_config_fetcher;
} grpc_ssl_server_credentials;
+tsi_ssl_pem_key_cert_pair* grpc_convert_grpc_to_tsi_cert_pairs(
+ const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs);
+
+void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
+ size_t num_key_cert_pairs);
+
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H */
diff --git a/src/core/lib/security/transport/auth_filters.h b/src/core/lib/security/transport/auth_filters.h
index bd5902a128..e999a027ae 100644
--- a/src/core/lib/security/transport/auth_filters.h
+++ b/src/core/lib/security/transport/auth_filters.h
@@ -19,9 +19,17 @@
#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H
#define GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H
+#include <grpc/grpc_security.h>
#include "src/core/lib/channel/channel_stack.h"
extern const grpc_channel_filter grpc_client_auth_filter;
extern const grpc_channel_filter grpc_server_auth_filter;
+void grpc_auth_metadata_context_build(
+ const char* url_scheme, grpc_slice call_host, grpc_slice call_method,
+ grpc_auth_context* auth_context,
+ grpc_auth_metadata_context* auth_md_context);
+
+void grpc_auth_metadata_context_reset(grpc_auth_metadata_context* context);
+
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H */
diff --git a/src/core/lib/security/transport/client_auth_filter.c b/src/core/lib/security/transport/client_auth_filter.cc
index dd7dd44e79..045cb3e239 100644
--- a/src/core/lib/security/transport/client_auth_filter.c
+++ b/src/core/lib/security/transport/client_auth_filter.cc
@@ -25,23 +25,24 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/transport/security_connector.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/transport/static_metadata.h"
#define MAX_CREDENTIALS_METADATA_COUNT 4
+namespace {
/* We can have a per-call credentials. */
-typedef struct {
- grpc_call_stack *owning_call;
- grpc_call_combiner *call_combiner;
- grpc_call_credentials *creds;
+struct call_data {
+ grpc_call_stack* owning_call;
+ grpc_call_combiner* call_combiner;
+ grpc_call_credentials* creds;
bool have_host;
bool have_method;
grpc_slice host;
@@ -50,38 +51,39 @@ typedef struct {
network requests, they should be done under a pollset added to this
pollset_set so that work can progress when this call wants work to progress
*/
- grpc_polling_entity *pollent;
+ grpc_polling_entity* pollent;
grpc_credentials_mdelem_array md_array;
grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT];
grpc_auth_metadata_context auth_md_context;
grpc_closure async_result_closure;
grpc_closure check_call_host_cancel_closure;
grpc_closure get_request_metadata_cancel_closure;
-} call_data;
+};
/* We can have a per-channel credentials. */
-typedef struct {
- grpc_channel_security_connector *security_connector;
- grpc_auth_context *auth_context;
-} channel_data;
-
-static void reset_auth_metadata_context(
- grpc_auth_metadata_context *auth_md_context) {
- if (auth_md_context->service_url != NULL) {
- gpr_free((char *)auth_md_context->service_url);
- auth_md_context->service_url = NULL;
+struct channel_data {
+ grpc_channel_security_connector* security_connector;
+ grpc_auth_context* auth_context;
+};
+} // namespace
+
+void grpc_auth_metadata_context_reset(
+ grpc_auth_metadata_context* auth_md_context) {
+ if (auth_md_context->service_url != nullptr) {
+ gpr_free((char*)auth_md_context->service_url);
+ auth_md_context->service_url = nullptr;
}
- if (auth_md_context->method_name != NULL) {
- gpr_free((char *)auth_md_context->method_name);
- auth_md_context->method_name = NULL;
+ if (auth_md_context->method_name != nullptr) {
+ gpr_free((char*)auth_md_context->method_name);
+ auth_md_context->method_name = nullptr;
}
GRPC_AUTH_CONTEXT_UNREF(
- (grpc_auth_context *)auth_md_context->channel_auth_context,
+ (grpc_auth_context*)auth_md_context->channel_auth_context,
"grpc_auth_metadata_context");
- auth_md_context->channel_auth_context = NULL;
+ auth_md_context->channel_auth_context = nullptr;
}
-static void add_error(grpc_error **combined, grpc_error *error) {
+static void add_error(grpc_error** combined, grpc_error* error) {
if (error == GRPC_ERROR_NONE) return;
if (*combined == GRPC_ERROR_NONE) {
*combined = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -90,101 +92,105 @@ static void add_error(grpc_error **combined, grpc_error *error) {
*combined = grpc_error_add_child(*combined, error);
}
-static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *input_error) {
- grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg;
- grpc_call_element *elem = batch->handler_private.extra_arg;
- call_data *calld = elem->call_data;
- reset_auth_metadata_context(&calld->auth_md_context);
- grpc_error *error = GRPC_ERROR_REF(input_error);
+static void on_credentials_metadata(void* arg, grpc_error* input_error) {
+ grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
+ grpc_call_element* elem =
+ (grpc_call_element*)batch->handler_private.extra_arg;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_auth_metadata_context_reset(&calld->auth_md_context);
+ grpc_error* error = GRPC_ERROR_REF(input_error);
if (error == GRPC_ERROR_NONE) {
GPR_ASSERT(calld->md_array.size <= MAX_CREDENTIALS_METADATA_COUNT);
GPR_ASSERT(batch->send_initial_metadata);
- grpc_metadata_batch *mdb =
+ grpc_metadata_batch* mdb =
batch->payload->send_initial_metadata.send_initial_metadata;
for (size_t i = 0; i < calld->md_array.size; ++i) {
add_error(&error, grpc_metadata_batch_add_tail(
- exec_ctx, mdb, &calld->md_links[i],
+ mdb, &calld->md_links[i],
GRPC_MDELEM_REF(calld->md_array.md[i])));
}
}
if (error == GRPC_ERROR_NONE) {
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
} else {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_UNAUTHENTICATED);
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error,
+ GRPC_STATUS_UNAVAILABLE);
+ grpc_transport_stream_op_batch_finish_with_failure(batch, error,
calld->call_combiner);
}
}
-void build_auth_metadata_context(grpc_security_connector *sc,
- grpc_auth_context *auth_context,
- call_data *calld) {
- char *service = grpc_slice_to_c_string(calld->method);
- char *last_slash = strrchr(service, '/');
- char *method_name = NULL;
- char *service_url = NULL;
- reset_auth_metadata_context(&calld->auth_md_context);
- if (last_slash == NULL) {
+void grpc_auth_metadata_context_build(
+ const char* url_scheme, grpc_slice call_host, grpc_slice call_method,
+ grpc_auth_context* auth_context,
+ grpc_auth_metadata_context* auth_md_context) {
+ char* service = grpc_slice_to_c_string(call_method);
+ char* last_slash = strrchr(service, '/');
+ char* method_name = nullptr;
+ char* service_url = nullptr;
+ grpc_auth_metadata_context_reset(auth_md_context);
+ if (last_slash == nullptr) {
gpr_log(GPR_ERROR, "No '/' found in fully qualified method name");
service[0] = '\0';
+ method_name = gpr_strdup("");
} else if (last_slash == service) {
- /* No service part in fully qualified method name: will just be "/". */
- service[1] = '\0';
+ method_name = gpr_strdup("");
} else {
*last_slash = '\0';
method_name = gpr_strdup(last_slash + 1);
}
- if (method_name == NULL) method_name = gpr_strdup("");
- char *host = grpc_slice_to_c_string(calld->host);
+ char* host_and_port = grpc_slice_to_c_string(call_host);
+ if (url_scheme != nullptr && strcmp(url_scheme, GRPC_SSL_URL_SCHEME) == 0) {
+ /* Remove the port if it is 443. */
+ char* port_delimiter = strrchr(host_and_port, ':');
+ if (port_delimiter != nullptr && strcmp(port_delimiter + 1, "443") == 0) {
+ *port_delimiter = '\0';
+ }
+ }
gpr_asprintf(&service_url, "%s://%s%s",
- sc->url_scheme == NULL ? "" : sc->url_scheme, host, service);
- calld->auth_md_context.service_url = service_url;
- calld->auth_md_context.method_name = method_name;
- calld->auth_md_context.channel_auth_context =
+ url_scheme == nullptr ? "" : url_scheme, host_and_port, service);
+ auth_md_context->service_url = service_url;
+ auth_md_context->method_name = method_name;
+ auth_md_context->channel_auth_context =
GRPC_AUTH_CONTEXT_REF(auth_context, "grpc_auth_metadata_context");
gpr_free(service);
- gpr_free(host);
+ gpr_free(host_and_port);
}
-static void cancel_get_request_metadata(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
+static void cancel_get_request_metadata(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
grpc_call_credentials_cancel_get_request_metadata(
- exec_ctx, calld->creds, &calld->md_array, GRPC_ERROR_REF(error));
+ calld->creds, &calld->md_array, GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call,
- "cancel_get_request_metadata");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_get_request_metadata");
}
-static void send_security_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = elem->call_data;
- channel_data *chand = elem->channel_data;
- grpc_client_security_context *ctx =
- (grpc_client_security_context *)batch->payload
+static void send_security_metadata(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ grpc_client_security_context* ctx =
+ (grpc_client_security_context*)batch->payload
->context[GRPC_CONTEXT_SECURITY]
.value;
- grpc_call_credentials *channel_call_creds =
+ grpc_call_credentials* channel_call_creds =
chand->security_connector->request_metadata_creds;
- int call_creds_has_md = (ctx != NULL) && (ctx->creds != NULL);
+ int call_creds_has_md = (ctx != nullptr) && (ctx->creds != nullptr);
- if (channel_call_creds == NULL && !call_creds_has_md) {
+ if (channel_call_creds == nullptr && !call_creds_has_md) {
/* Skip sending metadata altogether. */
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
return;
}
- if (channel_call_creds != NULL && call_creds_has_md) {
+ if (channel_call_creds != nullptr && call_creds_has_md) {
calld->creds = grpc_composite_call_credentials_create(channel_call_creds,
- ctx->creds, NULL);
- if (calld->creds == NULL) {
+ ctx->creds, nullptr);
+ if (calld->creds == nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch,
+ batch,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Incompatible credentials set on channel and call."),
@@ -197,46 +203,47 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx,
call_creds_has_md ? ctx->creds : channel_call_creds);
}
- build_auth_metadata_context(&chand->security_connector->base,
- chand->auth_context, calld);
+ grpc_auth_metadata_context_build(
+ chand->security_connector->base.url_scheme, calld->host, calld->method,
+ chand->auth_context, &calld->auth_md_context);
- GPR_ASSERT(calld->pollent != NULL);
+ GPR_ASSERT(calld->pollent != nullptr);
GRPC_CLOSURE_INIT(&calld->async_result_closure, on_credentials_metadata,
batch, grpc_schedule_on_exec_ctx);
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, calld->creds, calld->pollent, calld->auth_md_context,
+ calld->creds, calld->pollent, calld->auth_md_context,
&calld->md_array, &calld->async_result_closure, &error)) {
// Synchronous return; invoke on_credentials_metadata() directly.
- on_credentials_metadata(exec_ctx, batch, error);
+ on_credentials_metadata(batch, error);
GRPC_ERROR_UNREF(error);
} else {
// Async return; register cancellation closure with call combiner.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_get_request_metadata");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->get_request_metadata_cancel_closure,
cancel_get_request_metadata, elem,
grpc_schedule_on_exec_ctx));
}
}
-static void on_host_checked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg;
- grpc_call_element *elem = batch->handler_private.extra_arg;
- call_data *calld = elem->call_data;
+static void on_host_checked(void* arg, grpc_error* error) {
+ grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
+ grpc_call_element* elem =
+ (grpc_call_element*)batch->handler_private.extra_arg;
+ call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- send_security_metadata(exec_ctx, elem, batch);
+ send_security_metadata(elem, batch);
} else {
- char *error_msg;
- char *host = grpc_slice_to_c_string(calld->host);
+ char* error_msg;
+ char* host = grpc_slice_to_c_string(calld->host);
gpr_asprintf(&error_msg, "Invalid host %s set in :authority metadata.",
host);
gpr_free(host);
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch,
+ batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAUTHENTICATED),
@@ -245,59 +252,59 @@ static void on_host_checked(grpc_exec_ctx *exec_ctx, void *arg,
}
}
-static void cancel_check_call_host(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+static void cancel_check_call_host(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
if (error != GRPC_ERROR_NONE) {
grpc_channel_security_connector_cancel_check_call_host(
- exec_ctx, chand->security_connector, &calld->async_result_closure,
+ chand->security_connector, &calld->async_result_closure,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_check_call_host");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_check_call_host");
}
static void auth_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
GPR_TIMER_BEGIN("auth_start_transport_stream_op_batch", 0);
/* grab pointers to our data from the call element */
- call_data *calld = elem->call_data;
- channel_data *chand = elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
if (!batch->cancel_stream) {
- GPR_ASSERT(batch->payload->context != NULL);
- if (batch->payload->context[GRPC_CONTEXT_SECURITY].value == NULL) {
+ GPR_ASSERT(batch->payload->context != nullptr);
+ if (batch->payload->context[GRPC_CONTEXT_SECURITY].value == nullptr) {
batch->payload->context[GRPC_CONTEXT_SECURITY].value =
grpc_client_security_context_create();
batch->payload->context[GRPC_CONTEXT_SECURITY].destroy =
grpc_client_security_context_destroy;
}
- grpc_client_security_context *sec_ctx =
- batch->payload->context[GRPC_CONTEXT_SECURITY].value;
+ grpc_client_security_context* sec_ctx =
+ (grpc_client_security_context*)batch->payload
+ ->context[GRPC_CONTEXT_SECURITY]
+ .value;
GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter");
sec_ctx->auth_context =
GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter");
}
if (batch->send_initial_metadata) {
- for (grpc_linked_mdelem *l = batch->payload->send_initial_metadata
+ for (grpc_linked_mdelem* l = batch->payload->send_initial_metadata
.send_initial_metadata->list.head;
- l != NULL; l = l->next) {
+ l != nullptr; l = l->next) {
grpc_mdelem md = l->md;
/* Pointer comparison is OK for md_elems created from the same context.
*/
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_AUTHORITY)) {
if (calld->have_host) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
calld->host = grpc_slice_ref_internal(GRPC_MDVALUE(md));
calld->have_host = true;
} else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_PATH)) {
if (calld->have_method) {
- grpc_slice_unref_internal(exec_ctx, calld->method);
+ grpc_slice_unref_internal(calld->method);
}
calld->method = grpc_slice_ref_internal(GRPC_MDVALUE(md));
calld->have_method = true;
@@ -307,19 +314,19 @@ static void auth_start_transport_stream_op_batch(
batch->handler_private.extra_arg = elem;
GRPC_CLOSURE_INIT(&calld->async_result_closure, on_host_checked, batch,
grpc_schedule_on_exec_ctx);
- char *call_host = grpc_slice_to_c_string(calld->host);
- grpc_error *error = GRPC_ERROR_NONE;
+ char* call_host = grpc_slice_to_c_string(calld->host);
+ grpc_error* error = GRPC_ERROR_NONE;
if (grpc_channel_security_connector_check_call_host(
- exec_ctx, chand->security_connector, call_host,
- chand->auth_context, &calld->async_result_closure, &error)) {
+ chand->security_connector, call_host, chand->auth_context,
+ &calld->async_result_closure, &error)) {
// Synchronous return; invoke on_host_checked() directly.
- on_host_checked(exec_ctx, batch, error);
+ on_host_checked(batch, error);
GRPC_ERROR_UNREF(error);
} else {
// Async return; register cancellation closure with call combiner.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_check_call_host");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->check_call_host_cancel_closure,
cancel_check_call_host, elem,
grpc_schedule_on_exec_ctx));
@@ -331,62 +338,59 @@ static void auth_start_transport_stream_op_batch(
}
/* pass control down the stack */
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
GPR_TIMER_END("auth_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = elem->call_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
calld->owning_call = args->call_stack;
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
-static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {
- call_data *calld = elem->call_data;
+static void set_pollset_or_pollset_set(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {
+ call_data* calld = (call_data*)elem->call_data;
calld->pollent = pollent;
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- call_data *calld = elem->call_data;
- grpc_credentials_mdelem_array_destroy(exec_ctx, &calld->md_array);
- grpc_call_credentials_unref(exec_ctx, calld->creds);
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_credentials_mdelem_array_destroy(&calld->md_array);
+ grpc_call_credentials_unref(calld->creds);
if (calld->have_host) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
if (calld->have_method) {
- grpc_slice_unref_internal(exec_ctx, calld->method);
+ grpc_slice_unref_internal(calld->method);
}
- reset_auth_metadata_context(&calld->auth_md_context);
+ grpc_auth_metadata_context_reset(&calld->auth_md_context);
}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- grpc_security_connector *sc =
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ grpc_security_connector* sc =
grpc_security_connector_find_in_args(args->channel_args);
- if (sc == NULL) {
+ if (sc == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Security connector missing from client auth filter args");
}
- grpc_auth_context *auth_context =
+ grpc_auth_context* auth_context =
grpc_find_auth_context_in_args(args->channel_args);
- if (auth_context == NULL) {
+ if (auth_context == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Auth context missing from client auth filter args");
}
/* grab pointers to our data from the channel element */
- channel_data *chand = elem->channel_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
/* The first and the last filters tend to be implemented differently to
handle the case that there's no 'next' filter to call on the up or down
@@ -395,7 +399,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
/* initialize members */
chand->security_connector =
- (grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF(
+ (grpc_channel_security_connector*)GRPC_SECURITY_CONNECTOR_REF(
sc, "client_auth_filter");
chand->auth_context =
GRPC_AUTH_CONTEXT_REF(auth_context, "client_auth_filter");
@@ -403,13 +407,12 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
/* grab pointers to our data from the channel element */
- channel_data *chand = elem->channel_data;
- grpc_channel_security_connector *sc = chand->security_connector;
- if (sc != NULL) {
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "client_auth_filter");
+ channel_data* chand = (channel_data*)elem->channel_data;
+ grpc_channel_security_connector* sc = chand->security_connector;
+ if (sc != nullptr) {
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "client_auth_filter");
}
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "client_auth_filter");
}
diff --git a/src/core/lib/security/transport/lb_targets_info.c b/src/core/lib/security/transport/lb_targets_info.cc
index 5583a4e0ff..183b1ebf35 100644
--- a/src/core/lib/security/transport/lb_targets_info.c
+++ b/src/core/lib/security/transport/lb_targets_info.cc
@@ -25,30 +25,33 @@
* secure naming purposes. */
#define GRPC_ARG_LB_SECURE_NAMING_MAP "grpc.lb_secure_naming_map"
-static void *targets_info_copy(void *p) { return grpc_slice_hash_table_ref(p); }
-static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) {
- grpc_slice_hash_table_unref(exec_ctx, p);
+static void* targets_info_copy(void* p) {
+ return grpc_slice_hash_table_ref((grpc_slice_hash_table*)p);
}
-static int targets_info_cmp(void *a, void *b) {
- return grpc_slice_hash_table_cmp(a, b);
+static void targets_info_destroy(void* p) {
+ grpc_slice_hash_table_unref((grpc_slice_hash_table*)p);
+}
+static int targets_info_cmp(void* a, void* b) {
+ return grpc_slice_hash_table_cmp((const grpc_slice_hash_table*)a,
+ (const grpc_slice_hash_table*)b);
}
static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = {
targets_info_copy, targets_info_destroy, targets_info_cmp};
grpc_arg grpc_lb_targets_info_create_channel_arg(
- grpc_slice_hash_table *targets_info) {
- return grpc_channel_arg_pointer_create(GRPC_ARG_LB_SECURE_NAMING_MAP,
+ grpc_slice_hash_table* targets_info) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_ARG_LB_SECURE_NAMING_MAP,
targets_info,
&server_to_balancer_names_vtable);
}
-grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
- const grpc_channel_args *args) {
- const grpc_arg *targets_info_arg =
+grpc_slice_hash_table* grpc_lb_targets_info_find_in_args(
+ const grpc_channel_args* args) {
+ const grpc_arg* targets_info_arg =
grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP);
- if (targets_info_arg != NULL) {
+ if (targets_info_arg != nullptr) {
GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER);
- return targets_info_arg->value.pointer.p;
+ return (grpc_slice_hash_table*)targets_info_arg->value.pointer.p;
}
- return NULL;
+ return nullptr;
}
diff --git a/src/core/lib/security/transport/lb_targets_info.h b/src/core/lib/security/transport/lb_targets_info.h
index c3d685df5f..7543d3c012 100644
--- a/src/core/lib/security/transport/lb_targets_info.h
+++ b/src/core/lib/security/transport/lb_targets_info.h
@@ -23,10 +23,10 @@
/** Return a channel argument containing \a targets_info. */
grpc_arg grpc_lb_targets_info_create_channel_arg(
- grpc_slice_hash_table *targets_info);
+ grpc_slice_hash_table* targets_info);
/** Return the instance of targets info in \a args or NULL */
-grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
- const grpc_channel_args *args);
+grpc_slice_hash_table* grpc_lb_targets_info_find_in_args(
+ const grpc_channel_args* args);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */
diff --git a/src/core/lib/security/transport/secure_endpoint.c b/src/core/lib/security/transport/secure_endpoint.cc
index ae5633b82c..bd8a6cd76a 100644
--- a/src/core/lib/security/transport/secure_endpoint.c
+++ b/src/core/lib/security/transport/secure_endpoint.cc
@@ -28,27 +28,27 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/security/transport/secure_endpoint.h"
#include "src/core/lib/security/transport/tsi_error.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/tsi/transport_security_grpc.h"
#define STAGING_BUFFER_SIZE 8192
typedef struct {
grpc_endpoint base;
- grpc_endpoint *wrapped_ep;
- struct tsi_frame_protector *protector;
- struct tsi_zero_copy_grpc_protector *zero_copy_protector;
+ grpc_endpoint* wrapped_ep;
+ struct tsi_frame_protector* protector;
+ struct tsi_zero_copy_grpc_protector* zero_copy_protector;
gpr_mu protector_mu;
/* saved upper level callbacks and user_data. */
- grpc_closure *read_cb;
- grpc_closure *write_cb;
+ grpc_closure* read_cb;
+ grpc_closure* write_cb;
grpc_closure on_read;
- grpc_slice_buffer *read_buffer;
+ grpc_slice_buffer* read_buffer;
grpc_slice_buffer source_buffer;
/* saved handshaker leftover data to unprotect. */
grpc_slice_buffer leftover_bytes;
@@ -61,45 +61,43 @@ typedef struct {
gpr_refcount ref;
} secure_endpoint;
-grpc_tracer_flag grpc_trace_secure_endpoint =
- GRPC_TRACER_INITIALIZER(false, "secure_endpoint");
+grpc_core::TraceFlag grpc_trace_secure_endpoint(false, "secure_endpoint");
-static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) {
- secure_endpoint *ep = secure_ep;
- grpc_endpoint_destroy(exec_ctx, ep->wrapped_ep);
+static void destroy(secure_endpoint* secure_ep) {
+ secure_endpoint* ep = secure_ep;
+ grpc_endpoint_destroy(ep->wrapped_ep);
tsi_frame_protector_destroy(ep->protector);
- tsi_zero_copy_grpc_protector_destroy(exec_ctx, ep->zero_copy_protector);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->leftover_bytes);
- grpc_slice_unref_internal(exec_ctx, ep->read_staging_buffer);
- grpc_slice_unref_internal(exec_ctx, ep->write_staging_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->output_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->source_buffer);
+ tsi_zero_copy_grpc_protector_destroy(ep->zero_copy_protector);
+ grpc_slice_buffer_destroy_internal(&ep->leftover_bytes);
+ grpc_slice_unref_internal(ep->read_staging_buffer);
+ grpc_slice_unref_internal(ep->write_staging_buffer);
+ grpc_slice_buffer_destroy_internal(&ep->output_buffer);
+ grpc_slice_buffer_destroy_internal(&ep->source_buffer);
gpr_mu_destroy(&ep->protector_mu);
gpr_free(ep);
}
#ifndef NDEBUG
-#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \
- secure_endpoint_unref((exec_ctx), (ep), (reason), __FILE__, __LINE__)
+#define SECURE_ENDPOINT_UNREF(ep, reason) \
+ secure_endpoint_unref((ep), (reason), __FILE__, __LINE__)
#define SECURE_ENDPOINT_REF(ep, reason) \
secure_endpoint_ref((ep), (reason), __FILE__, __LINE__)
-static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
- const char *reason, const char *file,
- int line) {
- if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
+static void secure_endpoint_unref(secure_endpoint* ep, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_secure_endpoint.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"SECENDP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, reason, val,
val - 1);
}
if (gpr_unref(&ep->ref)) {
- destroy(exec_ctx, ep);
+ destroy(ep);
}
}
-static void secure_endpoint_ref(secure_endpoint *ep, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
+static void secure_endpoint_ref(secure_endpoint* ep, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_secure_endpoint.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"SECENDP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, reason, val,
@@ -108,69 +106,65 @@ static void secure_endpoint_ref(secure_endpoint *ep, const char *reason,
gpr_ref(&ep->ref);
}
#else
-#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \
- secure_endpoint_unref((exec_ctx), (ep))
+#define SECURE_ENDPOINT_UNREF(ep, reason) secure_endpoint_unref((ep))
#define SECURE_ENDPOINT_REF(ep, reason) secure_endpoint_ref((ep))
-static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx,
- secure_endpoint *ep) {
+static void secure_endpoint_unref(secure_endpoint* ep) {
if (gpr_unref(&ep->ref)) {
- destroy(exec_ctx, ep);
+ destroy(ep);
}
}
-static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); }
+static void secure_endpoint_ref(secure_endpoint* ep) { gpr_ref(&ep->ref); }
#endif
-static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur,
- uint8_t **end) {
+static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur,
+ uint8_t** end) {
grpc_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer);
ep->read_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
*cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
*end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
}
-static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
- grpc_error *error) {
- if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
+static void call_read_cb(secure_endpoint* ep, grpc_error* error) {
+ if (grpc_trace_secure_endpoint.enabled()) {
size_t i;
for (i = 0; i < ep->read_buffer->count; i++) {
- char *data = grpc_dump_slice(ep->read_buffer->slices[i],
+ char* data = grpc_dump_slice(ep->read_buffer->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "READ %p: %s", ep, data);
gpr_free(data);
}
}
- ep->read_buffer = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, ep->read_cb, error);
- SECURE_ENDPOINT_UNREF(exec_ctx, ep, "read");
+ ep->read_buffer = nullptr;
+ GRPC_CLOSURE_SCHED(ep->read_cb, error);
+ SECURE_ENDPOINT_UNREF(ep, "read");
}
-static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *error) {
+static void on_read(void* user_data, grpc_error* error) {
unsigned i;
uint8_t keep_looping = 0;
tsi_result result = TSI_OK;
- secure_endpoint *ep = (secure_endpoint *)user_data;
- uint8_t *cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
- uint8_t *end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
+ secure_endpoint* ep = (secure_endpoint*)user_data;
+ uint8_t* cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
+ uint8_t* end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
- call_read_cb(exec_ctx, ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Secure read failed", &error, 1));
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
+ call_read_cb(ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Secure read failed", &error, 1));
return;
}
- if (ep->zero_copy_protector != NULL) {
+ if (ep->zero_copy_protector != nullptr) {
// Use zero-copy grpc protector to unprotect.
result = tsi_zero_copy_grpc_protector_unprotect(
- exec_ctx, ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer);
+ ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer);
} else {
// Use frame protector to unprotect.
/* TODO(yangg) check error, maybe bail out early */
for (i = 0; i < ep->source_buffer.count; i++) {
grpc_slice encrypted = ep->source_buffer.slices[i];
- uint8_t *message_bytes = GRPC_SLICE_START_PTR(encrypted);
+ uint8_t* message_bytes = GRPC_SLICE_START_PTR(encrypted);
size_t message_size = GRPC_SLICE_LENGTH(encrypted);
while (message_size > 0 || keep_looping) {
@@ -217,77 +211,75 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
/* TODO(yangg) experiment with moving this block after read_cb to see if it
helps latency */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->source_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->source_buffer);
if (result != TSI_OK) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
call_read_cb(
- exec_ctx, ep,
- grpc_set_tsi_error_result(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
+ ep, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
return;
}
- call_read_cb(exec_ctx, ep, GRPC_ERROR_NONE);
+ call_read_cb(ep, GRPC_ERROR_NONE);
}
-static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
+static void endpoint_read(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
ep->read_cb = cb;
ep->read_buffer = slices;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
SECURE_ENDPOINT_REF(ep, "read");
if (ep->leftover_bytes.count) {
grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer);
GPR_ASSERT(ep->leftover_bytes.count == 0);
- on_read(exec_ctx, ep, GRPC_ERROR_NONE);
+ on_read(ep, GRPC_ERROR_NONE);
return;
}
- grpc_endpoint_read(exec_ctx, ep->wrapped_ep, &ep->source_buffer,
- &ep->on_read);
+ grpc_endpoint_read(ep->wrapped_ep, &ep->source_buffer, &ep->on_read);
}
-static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur,
- uint8_t **end) {
+static void flush_write_staging_buffer(secure_endpoint* ep, uint8_t** cur,
+ uint8_t** end) {
grpc_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer);
ep->write_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
*cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
*end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
}
-static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
+static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
GPR_TIMER_BEGIN("secure_endpoint.endpoint_write", 0);
unsigned i;
tsi_result result = TSI_OK;
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
- uint8_t *cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
- uint8_t *end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
+ uint8_t* cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
+ uint8_t* end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer);
- if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
+ if (grpc_trace_secure_endpoint.enabled()) {
for (i = 0; i < slices->count; i++) {
- char *data =
+ char* data =
grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "WRITE %p: %s", ep, data);
gpr_free(data);
}
}
- if (ep->zero_copy_protector != NULL) {
+ if (ep->zero_copy_protector != nullptr) {
// Use zero-copy grpc protector to protect.
- result = tsi_zero_copy_grpc_protector_protect(
- exec_ctx, ep->zero_copy_protector, slices, &ep->output_buffer);
+ result = tsi_zero_copy_grpc_protector_protect(ep->zero_copy_protector,
+ slices, &ep->output_buffer);
} else {
// Use frame protector to protect.
for (i = 0; i < slices->count; i++) {
grpc_slice plain = slices->slices[i];
- uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain);
+ uint8_t* message_bytes = GRPC_SLICE_START_PTR(plain);
size_t message_size = GRPC_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = (size_t)(end - cur);
@@ -340,58 +332,59 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
if (result != TSI_OK) {
/* TODO(yangg) do different things according to the error type? */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer);
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- grpc_set_tsi_error_result(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
+ cb, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
return;
}
- grpc_endpoint_write(exec_ctx, ep->wrapped_ep, &ep->output_buffer, cb);
+ grpc_endpoint_write(ep->wrapped_ep, &ep->output_buffer, cb);
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
}
-static void endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
- grpc_error *why) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
- grpc_endpoint_shutdown(exec_ctx, ep->wrapped_ep, why);
+static void endpoint_shutdown(grpc_endpoint* secure_ep, grpc_error* why) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
+ grpc_endpoint_shutdown(ep->wrapped_ep, why);
}
-static void endpoint_destroy(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *secure_ep) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
- SECURE_ENDPOINT_UNREF(exec_ctx, ep, "destroy");
+static void endpoint_destroy(grpc_endpoint* secure_ep) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
+ SECURE_ENDPOINT_UNREF(ep, "destroy");
}
-static void endpoint_add_to_pollset(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *secure_ep,
- grpc_pollset *pollset) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
- grpc_endpoint_add_to_pollset(exec_ctx, ep->wrapped_ep, pollset);
+static void endpoint_add_to_pollset(grpc_endpoint* secure_ep,
+ grpc_pollset* pollset) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
+ grpc_endpoint_add_to_pollset(ep->wrapped_ep, pollset);
}
-static void endpoint_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *secure_ep,
- grpc_pollset_set *pollset_set) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
- grpc_endpoint_add_to_pollset_set(exec_ctx, ep->wrapped_ep, pollset_set);
+static void endpoint_add_to_pollset_set(grpc_endpoint* secure_ep,
+ grpc_pollset_set* pollset_set) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
+ grpc_endpoint_add_to_pollset_set(ep->wrapped_ep, pollset_set);
}
-static char *endpoint_get_peer(grpc_endpoint *secure_ep) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
+static void endpoint_delete_from_pollset_set(grpc_endpoint* secure_ep,
+ grpc_pollset_set* pollset_set) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
+ grpc_endpoint_delete_from_pollset_set(ep->wrapped_ep, pollset_set);
+}
+
+static char* endpoint_get_peer(grpc_endpoint* secure_ep) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
return grpc_endpoint_get_peer(ep->wrapped_ep);
}
-static int endpoint_get_fd(grpc_endpoint *secure_ep) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
+static int endpoint_get_fd(grpc_endpoint* secure_ep) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
return grpc_endpoint_get_fd(ep->wrapped_ep);
}
-static grpc_resource_user *endpoint_get_resource_user(
- grpc_endpoint *secure_ep) {
- secure_endpoint *ep = (secure_endpoint *)secure_ep;
+static grpc_resource_user* endpoint_get_resource_user(
+ grpc_endpoint* secure_ep) {
+ secure_endpoint* ep = (secure_endpoint*)secure_ep;
return grpc_endpoint_get_resource_user(ep->wrapped_ep);
}
@@ -399,19 +392,20 @@ static const grpc_endpoint_vtable vtable = {endpoint_read,
endpoint_write,
endpoint_add_to_pollset,
endpoint_add_to_pollset_set,
+ endpoint_delete_from_pollset_set,
endpoint_shutdown,
endpoint_destroy,
endpoint_get_resource_user,
endpoint_get_peer,
endpoint_get_fd};
-grpc_endpoint *grpc_secure_endpoint_create(
- struct tsi_frame_protector *protector,
- struct tsi_zero_copy_grpc_protector *zero_copy_protector,
- grpc_endpoint *transport, grpc_slice *leftover_slices,
+grpc_endpoint* grpc_secure_endpoint_create(
+ struct tsi_frame_protector* protector,
+ struct tsi_zero_copy_grpc_protector* zero_copy_protector,
+ grpc_endpoint* transport, grpc_slice* leftover_slices,
size_t leftover_nslices) {
size_t i;
- secure_endpoint *ep = (secure_endpoint *)gpr_malloc(sizeof(secure_endpoint));
+ secure_endpoint* ep = (secure_endpoint*)gpr_malloc(sizeof(secure_endpoint));
ep->base.vtable = &vtable;
ep->wrapped_ep = transport;
ep->protector = protector;
@@ -425,7 +419,7 @@ grpc_endpoint *grpc_secure_endpoint_create(
ep->read_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
grpc_slice_buffer_init(&ep->output_buffer);
grpc_slice_buffer_init(&ep->source_buffer);
- ep->read_buffer = NULL;
+ ep->read_buffer = nullptr;
GRPC_CLOSURE_INIT(&ep->on_read, on_read, ep, grpc_schedule_on_exec_ctx);
gpr_mu_init(&ep->protector_mu);
gpr_ref_init(&ep->ref, 1);
diff --git a/src/core/lib/security/transport/secure_endpoint.h b/src/core/lib/security/transport/secure_endpoint.h
index 3323a6ff42..b2556a0182 100644
--- a/src/core/lib/security/transport/secure_endpoint.h
+++ b/src/core/lib/security/transport/secure_endpoint.h
@@ -25,15 +25,15 @@
struct tsi_frame_protector;
struct tsi_zero_copy_grpc_protector;
-extern grpc_tracer_flag grpc_trace_secure_endpoint;
+extern grpc_core::TraceFlag grpc_trace_secure_endpoint;
/* Takes ownership of protector, zero_copy_protector, and to_wrap, and refs
* leftover_slices. If zero_copy_protector is not NULL, protector will never be
* used. */
-grpc_endpoint *grpc_secure_endpoint_create(
- struct tsi_frame_protector *protector,
- struct tsi_zero_copy_grpc_protector *zero_copy_protector,
- grpc_endpoint *to_wrap, grpc_slice *leftover_slices,
+grpc_endpoint* grpc_secure_endpoint_create(
+ struct tsi_frame_protector* protector,
+ struct tsi_zero_copy_grpc_protector* zero_copy_protector,
+ grpc_endpoint* to_wrap, grpc_slice* leftover_slices,
size_t leftover_nslices);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */
diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c
deleted file mode 100644
index 2a9e939d40..0000000000
--- a/src/core/lib/security/transport/security_connector.c
+++ /dev/null
@@ -1,914 +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/security/transport/security_connector.h"
-
-#include <stdbool.h>
-#include <string.h>
-
-#include <grpc/slice_buffer.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/host_port.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/ext/transport/chttp2/alpn/alpn.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/channel/handshaker.h"
-#include "src/core/lib/iomgr/load_file.h"
-#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/security/credentials/fake/fake_credentials.h"
-#include "src/core/lib/security/transport/lb_targets_info.h"
-#include "src/core/lib/security/transport/secure_endpoint.h"
-#include "src/core/lib/security/transport/security_handshaker.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/tsi/fake_transport_security.h"
-#include "src/core/tsi/ssl_transport_security.h"
-#include "src/core/tsi/transport_security_adapter.h"
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_security_connector_refcount =
- GRPC_TRACER_INITIALIZER(false, "security_connector_refcount");
-#endif
-
-/* -- Constants. -- */
-
-#ifndef INSTALL_PREFIX
-static const char *installed_roots_path = "/usr/share/grpc/roots.pem";
-#else
-static const char *installed_roots_path =
- INSTALL_PREFIX "/share/grpc/roots.pem";
-#endif
-
-/* -- Overridden default roots. -- */
-
-static grpc_ssl_roots_override_callback ssl_roots_override_cb = NULL;
-
-void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
- ssl_roots_override_cb = cb;
-}
-
-/* -- Cipher suites. -- */
-
-/* Defines the cipher suites that we accept by default. All these cipher suites
- are compliant with HTTP2. */
-#define GRPC_SSL_CIPHER_SUITES \
- "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384"
-
-static gpr_once cipher_suites_once = GPR_ONCE_INIT;
-static const char *cipher_suites = NULL;
-
-static void init_cipher_suites(void) {
- char *overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES");
- cipher_suites = overridden != NULL ? overridden : GRPC_SSL_CIPHER_SUITES;
-}
-
-static const char *ssl_cipher_suites(void) {
- gpr_once_init(&cipher_suites_once, init_cipher_suites);
- return cipher_suites;
-}
-
-/* -- Common methods. -- */
-
-/* Returns the first property with that name. */
-const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer,
- const char *name) {
- size_t i;
- if (peer == NULL) return NULL;
- for (i = 0; i < peer->property_count; i++) {
- const tsi_peer_property *property = &peer->properties[i];
- if (name == NULL && property->name == NULL) {
- return property;
- }
- if (name != NULL && property->name != NULL &&
- strcmp(property->name, name) == 0) {
- return property;
- }
- }
- return NULL;
-}
-
-void grpc_channel_security_connector_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector,
- grpc_handshake_manager *handshake_mgr) {
- if (connector != NULL) {
- connector->add_handshakers(exec_ctx, connector, handshake_mgr);
- }
-}
-
-void grpc_server_security_connector_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_server_security_connector *connector,
- grpc_handshake_manager *handshake_mgr) {
- if (connector != NULL) {
- connector->add_handshakers(exec_ctx, connector, handshake_mgr);
- }
-}
-
-void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc,
- tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- if (sc == NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "cannot check peer -- no security connector"));
- tsi_peer_destruct(&peer);
- } else {
- sc->vtable->check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
- }
-}
-
-bool grpc_channel_security_connector_check_call_host(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- const char *host, grpc_auth_context *auth_context,
- grpc_closure *on_call_host_checked, grpc_error **error) {
- if (sc == NULL || sc->check_call_host == NULL) {
- *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "cannot check call host -- no security connector");
- return true;
- }
- return sc->check_call_host(exec_ctx, sc, host, auth_context,
- on_call_host_checked, error);
-}
-
-void grpc_channel_security_connector_cancel_check_call_host(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- grpc_closure *on_call_host_checked, grpc_error *error) {
- if (sc == NULL || sc->cancel_check_call_host == NULL) {
- GRPC_ERROR_UNREF(error);
- return;
- }
- sc->cancel_check_call_host(exec_ctx, sc, on_call_host_checked, error);
-}
-
-#ifndef NDEBUG
-grpc_security_connector *grpc_security_connector_ref(
- grpc_security_connector *sc, const char *file, int line,
- const char *reason) {
- if (sc == NULL) return NULL;
- if (GRPC_TRACER_ON(grpc_trace_security_connector_refcount)) {
- gpr_atm val = gpr_atm_no_barrier_load(&sc->refcount.count);
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "SECURITY_CONNECTOR:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", sc,
- val, val + 1, reason);
- }
-#else
-grpc_security_connector *grpc_security_connector_ref(
- grpc_security_connector *sc) {
- if (sc == NULL) return NULL;
-#endif
- gpr_ref(&sc->refcount);
- return sc;
-}
-
-#ifndef NDEBUG
-void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc,
- const char *file, int line,
- const char *reason) {
- if (sc == NULL) return;
- if (GRPC_TRACER_ON(grpc_trace_security_connector_refcount)) {
- gpr_atm val = gpr_atm_no_barrier_load(&sc->refcount.count);
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "SECURITY_CONNECTOR:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", sc,
- val, val - 1, reason);
- }
-#else
-void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- if (sc == NULL) return;
-#endif
- if (gpr_unref(&sc->refcount)) sc->vtable->destroy(exec_ctx, sc);
-}
-
-static void connector_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, "connector_pointer_arg_destroy");
-}
-
-static void *connector_pointer_arg_copy(void *p) {
- return GRPC_SECURITY_CONNECTOR_REF(p, "connector_pointer_arg_copy");
-}
-
-static int connector_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
-
-static const grpc_arg_pointer_vtable connector_pointer_vtable = {
- connector_pointer_arg_copy, connector_pointer_arg_destroy,
- connector_pointer_cmp};
-
-grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) {
- return grpc_channel_arg_pointer_create(GRPC_ARG_SECURITY_CONNECTOR, sc,
- &connector_pointer_vtable);
-}
-
-grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) {
- if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return NULL;
- if (arg->type != GRPC_ARG_POINTER) {
- gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
- GRPC_ARG_SECURITY_CONNECTOR);
- return NULL;
- }
- return arg->value.pointer.p;
-}
-
-grpc_security_connector *grpc_security_connector_find_in_args(
- const grpc_channel_args *args) {
- size_t i;
- if (args == NULL) return NULL;
- for (i = 0; i < args->num_args; i++) {
- grpc_security_connector *sc =
- grpc_security_connector_from_arg(&args->args[i]);
- if (sc != NULL) return sc;
- }
- return NULL;
-}
-
-/* -- Fake implementation. -- */
-
-typedef struct {
- grpc_channel_security_connector base;
- char *target;
- char *expected_targets;
- bool is_lb_channel;
-} grpc_fake_channel_security_connector;
-
-static void fake_channel_destroy(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- grpc_fake_channel_security_connector *c =
- (grpc_fake_channel_security_connector *)sc;
- grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
- gpr_free(c->target);
- gpr_free(c->expected_targets);
- gpr_free(c);
-}
-
-static void fake_server_destroy(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- gpr_free(sc);
-}
-
-static bool fake_check_target(const char *target_type, const char *target,
- const char *set_str) {
- GPR_ASSERT(target_type != NULL);
- GPR_ASSERT(target != NULL);
- char **set = NULL;
- size_t set_size = 0;
- gpr_string_split(set_str, ",", &set, &set_size);
- bool found = false;
- for (size_t i = 0; i < set_size; ++i) {
- if (set[i] != NULL && strcmp(target, set[i]) == 0) found = true;
- }
- for (size_t i = 0; i < set_size; ++i) {
- gpr_free(set[i]);
- }
- gpr_free(set);
- return found;
-}
-
-static void fake_secure_name_check(const char *target,
- const char *expected_targets,
- bool is_lb_channel) {
- if (expected_targets == NULL) return;
- char **lbs_and_backends = NULL;
- size_t lbs_and_backends_size = 0;
- bool success = false;
- gpr_string_split(expected_targets, ";", &lbs_and_backends,
- &lbs_and_backends_size);
- if (lbs_and_backends_size > 2 || lbs_and_backends_size == 0) {
- gpr_log(GPR_ERROR, "Invalid expected targets arg value: '%s'",
- expected_targets);
- goto done;
- }
- if (is_lb_channel) {
- if (lbs_and_backends_size != 2) {
- gpr_log(GPR_ERROR,
- "Invalid expected targets arg value: '%s'. Expectations for LB "
- "channels must be of the form 'be1,be2,be3,...;lb1,lb2,...",
- expected_targets);
- goto done;
- }
- if (!fake_check_target("LB", target, lbs_and_backends[1])) {
- gpr_log(GPR_ERROR, "LB target '%s' not found in expected set '%s'",
- target, lbs_and_backends[1]);
- goto done;
- }
- success = true;
- } else {
- if (!fake_check_target("Backend", target, lbs_and_backends[0])) {
- gpr_log(GPR_ERROR, "Backend target '%s' not found in expected set '%s'",
- target, lbs_and_backends[0]);
- goto done;
- }
- success = true;
- }
-done:
- for (size_t i = 0; i < lbs_and_backends_size; ++i) {
- gpr_free(lbs_and_backends[i]);
- }
- gpr_free(lbs_and_backends);
- if (!success) abort();
-}
-
-static void fake_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- const char *prop_name;
- grpc_error *error = GRPC_ERROR_NONE;
- *auth_context = NULL;
- if (peer.property_count != 1) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Fake peers should only have 1 property.");
- goto end;
- }
- prop_name = peer.properties[0].name;
- if (prop_name == NULL ||
- strcmp(prop_name, TSI_CERTIFICATE_TYPE_PEER_PROPERTY)) {
- char *msg;
- gpr_asprintf(&msg, "Unexpected property in fake peer: %s.",
- prop_name == NULL ? "<EMPTY>" : prop_name);
- error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
- gpr_free(msg);
- goto end;
- }
- if (strncmp(peer.properties[0].value.data, TSI_FAKE_CERTIFICATE_TYPE,
- peer.properties[0].value.length)) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Invalid value for cert type property.");
- goto end;
- }
- *auth_context = grpc_auth_context_create(NULL);
- grpc_auth_context_add_cstring_property(
- *auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
- GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
-end:
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
- tsi_peer_destruct(&peer);
-}
-
-static void fake_channel_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
- grpc_fake_channel_security_connector *c =
- (grpc_fake_channel_security_connector *)sc;
- fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel);
-}
-
-static void fake_server_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
-}
-
-static bool fake_channel_check_call_host(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- const char *host,
- grpc_auth_context *auth_context,
- grpc_closure *on_call_host_checked,
- grpc_error **error) {
- return true;
-}
-
-static void fake_channel_cancel_check_call_host(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- grpc_closure *on_call_host_checked, grpc_error *error) {
- GRPC_ERROR_UNREF(error);
-}
-
-static void fake_channel_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_fake_handshaker(true /* is_client */),
- &sc->base));
-}
-
-static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx,
- grpc_server_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_fake_handshaker(false /* is_client */),
- &sc->base));
-}
-
-static grpc_security_connector_vtable fake_channel_vtable = {
- fake_channel_destroy, fake_channel_check_peer};
-
-static grpc_security_connector_vtable fake_server_vtable = {
- fake_server_destroy, fake_server_check_peer};
-
-grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
- grpc_call_credentials *request_metadata_creds, const char *target,
- const grpc_channel_args *args) {
- grpc_fake_channel_security_connector *c = gpr_zalloc(sizeof(*c));
- gpr_ref_init(&c->base.base.refcount, 1);
- c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
- c->base.base.vtable = &fake_channel_vtable;
- c->base.request_metadata_creds =
- grpc_call_credentials_ref(request_metadata_creds);
- c->base.check_call_host = fake_channel_check_call_host;
- c->base.cancel_check_call_host = fake_channel_cancel_check_call_host;
- c->base.add_handshakers = fake_channel_add_handshakers;
- c->target = gpr_strdup(target);
- const char *expected_targets = grpc_fake_transport_get_expected_targets(args);
- c->expected_targets = gpr_strdup(expected_targets);
- c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != NULL);
- return &c->base;
-}
-
-grpc_server_security_connector *grpc_fake_server_security_connector_create(
- void) {
- grpc_server_security_connector *c =
- gpr_zalloc(sizeof(grpc_server_security_connector));
- gpr_ref_init(&c->base.refcount, 1);
- c->base.vtable = &fake_server_vtable;
- c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
- c->add_handshakers = fake_server_add_handshakers;
- return c;
-}
-
-/* --- Ssl implementation. --- */
-
-typedef struct {
- grpc_channel_security_connector base;
- tsi_ssl_client_handshaker_factory *client_handshaker_factory;
- char *target_name;
- char *overridden_target_name;
-} grpc_ssl_channel_security_connector;
-
-typedef struct {
- grpc_server_security_connector base;
- tsi_ssl_server_handshaker_factory *server_handshaker_factory;
-} grpc_ssl_server_security_connector;
-
-static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- grpc_ssl_channel_security_connector *c =
- (grpc_ssl_channel_security_connector *)sc;
- grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
- tsi_ssl_client_handshaker_factory_unref(c->client_handshaker_factory);
- c->client_handshaker_factory = NULL;
- if (c->target_name != NULL) gpr_free(c->target_name);
- if (c->overridden_target_name != NULL) gpr_free(c->overridden_target_name);
- gpr_free(sc);
-}
-
-static void ssl_server_destroy(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- grpc_ssl_server_security_connector *c =
- (grpc_ssl_server_security_connector *)sc;
- tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory);
- c->server_handshaker_factory = NULL;
- gpr_free(sc);
-}
-
-static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_ssl_channel_security_connector *c =
- (grpc_ssl_channel_security_connector *)sc;
- // Instantiate TSI handshaker.
- tsi_handshaker *tsi_hs = NULL;
- tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
- c->client_handshaker_factory,
- c->overridden_target_name != NULL ? c->overridden_target_name
- : c->target_name,
- &tsi_hs);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
- tsi_result_to_string(result));
- return;
- }
-
- // Create handshakers.
- grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
-}
-
-static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
- grpc_server_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_ssl_server_security_connector *c =
- (grpc_ssl_server_security_connector *)sc;
- // Instantiate TSI handshaker.
- tsi_handshaker *tsi_hs = NULL;
- tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
- c->server_handshaker_factory, &tsi_hs);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
- tsi_result_to_string(result));
- return;
- }
-
- // Create handshakers.
- grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
-}
-
-static int ssl_host_matches_name(const tsi_peer *peer, const char *peer_name) {
- char *allocated_name = NULL;
- int r;
-
- if (strchr(peer_name, ':') != NULL) {
- char *ignored_port;
- gpr_split_host_port(peer_name, &allocated_name, &ignored_port);
- gpr_free(ignored_port);
- peer_name = allocated_name;
- if (!peer_name) return 0;
- }
- r = tsi_ssl_peer_matches_name(peer, peer_name);
- gpr_free(allocated_name);
- return r;
-}
-
-grpc_auth_context *tsi_ssl_peer_to_auth_context(const tsi_peer *peer) {
- size_t i;
- grpc_auth_context *ctx = NULL;
- const char *peer_identity_property_name = NULL;
-
- /* The caller has checked the certificate type property. */
- GPR_ASSERT(peer->property_count >= 1);
- ctx = grpc_auth_context_create(NULL);
- grpc_auth_context_add_cstring_property(
- ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
- GRPC_SSL_TRANSPORT_SECURITY_TYPE);
- for (i = 0; i < peer->property_count; i++) {
- const tsi_peer_property *prop = &peer->properties[i];
- if (prop->name == NULL) continue;
- if (strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) {
- /* If there is no subject alt name, have the CN as the identity. */
- if (peer_identity_property_name == NULL) {
- peer_identity_property_name = GRPC_X509_CN_PROPERTY_NAME;
- }
- grpc_auth_context_add_property(ctx, GRPC_X509_CN_PROPERTY_NAME,
- prop->value.data, prop->value.length);
- } else if (strcmp(prop->name,
- TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
- peer_identity_property_name = GRPC_X509_SAN_PROPERTY_NAME;
- grpc_auth_context_add_property(ctx, GRPC_X509_SAN_PROPERTY_NAME,
- prop->value.data, prop->value.length);
- } else if (strcmp(prop->name, TSI_X509_PEM_CERT_PROPERTY) == 0) {
- grpc_auth_context_add_property(ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME,
- prop->value.data, prop->value.length);
- }
- }
- if (peer_identity_property_name != NULL) {
- GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
- ctx, peer_identity_property_name) == 1);
- }
- return ctx;
-}
-
-static grpc_error *ssl_check_peer(grpc_security_connector *sc,
- const char *peer_name, const tsi_peer *peer,
- grpc_auth_context **auth_context) {
- /* Check the ALPN. */
- const tsi_peer_property *p =
- tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
- if (p == NULL) {
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Cannot check peer: missing selected ALPN property.");
- }
- if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Cannot check peer: invalid ALPN value.");
- }
-
- /* Check the peer name if specified. */
- if (peer_name != NULL && !ssl_host_matches_name(peer, peer_name)) {
- char *msg;
- gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
- grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
- gpr_free(msg);
- return error;
- }
- *auth_context = tsi_ssl_peer_to_auth_context(peer);
- return GRPC_ERROR_NONE;
-}
-
-static void ssl_channel_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- grpc_ssl_channel_security_connector *c =
- (grpc_ssl_channel_security_connector *)sc;
- grpc_error *error = ssl_check_peer(sc, c->overridden_target_name != NULL
- ? c->overridden_target_name
- : c->target_name,
- &peer, auth_context);
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
- tsi_peer_destruct(&peer);
-}
-
-static void ssl_server_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- grpc_error *error = ssl_check_peer(sc, NULL, &peer, auth_context);
- tsi_peer_destruct(&peer);
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
-}
-
-static void add_shallow_auth_property_to_peer(tsi_peer *peer,
- const grpc_auth_property *prop,
- const char *tsi_prop_name) {
- tsi_peer_property *tsi_prop = &peer->properties[peer->property_count++];
- tsi_prop->name = (char *)tsi_prop_name;
- tsi_prop->value.data = prop->value;
- tsi_prop->value.length = prop->value_length;
-}
-
-tsi_peer tsi_shallow_peer_from_ssl_auth_context(
- const grpc_auth_context *auth_context) {
- size_t max_num_props = 0;
- grpc_auth_property_iterator it;
- const grpc_auth_property *prop;
- tsi_peer peer;
- memset(&peer, 0, sizeof(peer));
-
- it = grpc_auth_context_property_iterator(auth_context);
- while (grpc_auth_property_iterator_next(&it) != NULL) max_num_props++;
-
- if (max_num_props > 0) {
- peer.properties = gpr_malloc(max_num_props * sizeof(tsi_peer_property));
- it = grpc_auth_context_property_iterator(auth_context);
- while ((prop = grpc_auth_property_iterator_next(&it)) != NULL) {
- if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) {
- add_shallow_auth_property_to_peer(
- &peer, prop, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY);
- } else if (strcmp(prop->name, GRPC_X509_CN_PROPERTY_NAME) == 0) {
- add_shallow_auth_property_to_peer(
- &peer, prop, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY);
- } else if (strcmp(prop->name, GRPC_X509_PEM_CERT_PROPERTY_NAME) == 0) {
- add_shallow_auth_property_to_peer(&peer, prop,
- TSI_X509_PEM_CERT_PROPERTY);
- }
- }
- }
- return peer;
-}
-
-void tsi_shallow_peer_destruct(tsi_peer *peer) {
- if (peer->properties != NULL) gpr_free(peer->properties);
-}
-
-static bool ssl_channel_check_call_host(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- const char *host,
- grpc_auth_context *auth_context,
- grpc_closure *on_call_host_checked,
- grpc_error **error) {
- grpc_ssl_channel_security_connector *c =
- (grpc_ssl_channel_security_connector *)sc;
- grpc_security_status status = GRPC_SECURITY_ERROR;
- tsi_peer peer = tsi_shallow_peer_from_ssl_auth_context(auth_context);
- if (ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK;
- /* If the target name was overridden, then the original target_name was
- 'checked' transitively during the previous peer check at the end of the
- handshake. */
- if (c->overridden_target_name != NULL && strcmp(host, c->target_name) == 0) {
- status = GRPC_SECURITY_OK;
- }
- if (status != GRPC_SECURITY_OK) {
- *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "call host does not match SSL server name");
- }
- tsi_shallow_peer_destruct(&peer);
- return true;
-}
-
-static void ssl_channel_cancel_check_call_host(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- grpc_closure *on_call_host_checked, grpc_error *error) {
- GRPC_ERROR_UNREF(error);
-}
-
-static grpc_security_connector_vtable ssl_channel_vtable = {
- ssl_channel_destroy, ssl_channel_check_peer};
-
-static grpc_security_connector_vtable ssl_server_vtable = {
- ssl_server_destroy, ssl_server_check_peer};
-
-/* returns a NULL terminated slice. */
-static grpc_slice compute_default_pem_root_certs_once(void) {
- grpc_slice result = grpc_empty_slice();
-
- /* First try to load the roots from the environment. */
- char *default_root_certs_path =
- gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR);
- if (default_root_certs_path != NULL) {
- GRPC_LOG_IF_ERROR("load_file",
- grpc_load_file(default_root_certs_path, 1, &result));
- gpr_free(default_root_certs_path);
- }
-
- /* Try overridden roots if needed. */
- grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL;
- if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) {
- char *pem_root_certs = NULL;
- ovrd_res = ssl_roots_override_cb(&pem_root_certs);
- if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) {
- GPR_ASSERT(pem_root_certs != NULL);
- result = grpc_slice_from_copied_buffer(
- pem_root_certs,
- strlen(pem_root_certs) + 1); // NULL terminator.
- }
- gpr_free(pem_root_certs);
- }
-
- /* Fall back to installed certs if needed. */
- if (GRPC_SLICE_IS_EMPTY(result) &&
- ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) {
- GRPC_LOG_IF_ERROR("load_file",
- grpc_load_file(installed_roots_path, 1, &result));
- }
- return result;
-}
-
-static grpc_slice default_pem_root_certs;
-
-static void init_default_pem_root_certs(void) {
- default_pem_root_certs = compute_default_pem_root_certs_once();
-}
-
-grpc_slice grpc_get_default_ssl_roots_for_testing(void) {
- return compute_default_pem_root_certs_once();
-}
-
-static tsi_client_certificate_request_type
-get_tsi_client_certificate_request_type(
- grpc_ssl_client_certificate_request_type grpc_request_type) {
- switch (grpc_request_type) {
- case GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE:
- return TSI_DONT_REQUEST_CLIENT_CERTIFICATE;
-
- case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
- return TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY;
-
- case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY:
- return TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY;
-
- case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
- return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY;
-
- case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY:
- return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY;
-
- default:
- // Is this a sane default
- return TSI_DONT_REQUEST_CLIENT_CERTIFICATE;
- }
-}
-
-const char *grpc_get_default_ssl_roots(void) {
- /* TODO(jboeuf@google.com): Maybe revisit the approach which consists in
- loading all the roots once for the lifetime of the process. */
- static gpr_once once = GPR_ONCE_INIT;
- gpr_once_init(&once, init_default_pem_root_certs);
- return GRPC_SLICE_IS_EMPTY(default_pem_root_certs)
- ? NULL
- : (const char *)GRPC_SLICE_START_PTR(default_pem_root_certs);
-}
-
-grpc_security_status grpc_ssl_channel_security_connector_create(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *request_metadata_creds,
- const grpc_ssl_config *config, const char *target_name,
- const char *overridden_target_name, grpc_channel_security_connector **sc) {
- size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
- const char **alpn_protocol_strings =
- gpr_malloc(sizeof(const char *) * num_alpn_protocols);
- tsi_result result = TSI_OK;
- grpc_ssl_channel_security_connector *c;
- size_t i;
- const char *pem_root_certs;
- char *port;
-
- for (i = 0; i < num_alpn_protocols; i++) {
- alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i);
- }
-
- if (config == NULL || target_name == NULL) {
- gpr_log(GPR_ERROR, "An ssl channel needs a config and a target name.");
- goto error;
- }
- if (config->pem_root_certs == NULL) {
- pem_root_certs = grpc_get_default_ssl_roots();
- if (pem_root_certs == NULL) {
- gpr_log(GPR_ERROR, "Could not get default pem root certs.");
- goto error;
- }
- } else {
- pem_root_certs = config->pem_root_certs;
- }
-
- c = gpr_zalloc(sizeof(grpc_ssl_channel_security_connector));
-
- gpr_ref_init(&c->base.base.refcount, 1);
- c->base.base.vtable = &ssl_channel_vtable;
- c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
- c->base.request_metadata_creds =
- grpc_call_credentials_ref(request_metadata_creds);
- c->base.check_call_host = ssl_channel_check_call_host;
- c->base.cancel_check_call_host = ssl_channel_cancel_check_call_host;
- c->base.add_handshakers = ssl_channel_add_handshakers;
- gpr_split_host_port(target_name, &c->target_name, &port);
- gpr_free(port);
- if (overridden_target_name != NULL) {
- c->overridden_target_name = gpr_strdup(overridden_target_name);
- }
-
- bool has_key_cert_pair = config->pem_key_cert_pair.private_key != NULL &&
- config->pem_key_cert_pair.cert_chain != NULL;
- result = tsi_create_ssl_client_handshaker_factory(
- has_key_cert_pair ? &config->pem_key_cert_pair : NULL, pem_root_certs,
- ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
- &c->client_handshaker_factory);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
- tsi_result_to_string(result));
- ssl_channel_destroy(exec_ctx, &c->base.base);
- *sc = NULL;
- goto error;
- }
- *sc = &c->base;
- gpr_free((void *)alpn_protocol_strings);
- return GRPC_SECURITY_OK;
-
-error:
- gpr_free((void *)alpn_protocol_strings);
- return GRPC_SECURITY_ERROR;
-}
-
-grpc_security_status grpc_ssl_server_security_connector_create(
- grpc_exec_ctx *exec_ctx, const grpc_ssl_server_config *config,
- grpc_server_security_connector **sc) {
- size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
- const char **alpn_protocol_strings =
- gpr_malloc(sizeof(const char *) * num_alpn_protocols);
- tsi_result result = TSI_OK;
- grpc_ssl_server_security_connector *c;
- size_t i;
-
- for (i = 0; i < num_alpn_protocols; i++) {
- alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i);
- }
-
- if (config == NULL || config->num_key_cert_pairs == 0) {
- gpr_log(GPR_ERROR, "An SSL server needs a key and a cert.");
- goto error;
- }
- c = gpr_zalloc(sizeof(grpc_ssl_server_security_connector));
-
- gpr_ref_init(&c->base.base.refcount, 1);
- c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
- c->base.base.vtable = &ssl_server_vtable;
- result = tsi_create_ssl_server_handshaker_factory_ex(
- config->pem_key_cert_pairs, config->num_key_cert_pairs,
- config->pem_root_certs, get_tsi_client_certificate_request_type(
- config->client_certificate_request),
- ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
- &c->server_handshaker_factory);
- if (result != TSI_OK) {
- gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
- tsi_result_to_string(result));
- ssl_server_destroy(exec_ctx, &c->base.base);
- *sc = NULL;
- goto error;
- }
- c->base.add_handshakers = ssl_server_add_handshakers;
- *sc = &c->base;
- gpr_free((void *)alpn_protocol_strings);
- return GRPC_SECURITY_OK;
-
-error:
- gpr_free((void *)alpn_protocol_strings);
- return GRPC_SECURITY_ERROR;
-}
diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc
new file mode 100644
index 0000000000..1d962f94b2
--- /dev/null
+++ b/src/core/lib/security/transport/security_connector.cc
@@ -0,0 +1,1097 @@
+/*
+ *
+ * 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/security/transport/security_connector.h"
+
+#include <stdbool.h>
+#include <string.h>
+
+#include <grpc/slice_buffer.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/ext/transport/chttp2/alpn/alpn.h"
+#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/string.h"
+#include "src/core/lib/iomgr/load_file.h"
+#include "src/core/lib/security/context/security_context.h"
+#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/credentials/fake/fake_credentials.h"
+#include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
+#include "src/core/lib/security/transport/lb_targets_info.h"
+#include "src/core/lib/security/transport/secure_endpoint.h"
+#include "src/core/lib/security/transport/security_handshaker.h"
+#include "src/core/tsi/fake_transport_security.h"
+#include "src/core/tsi/ssl_transport_security.h"
+#include "src/core/tsi/transport_security_adapter.h"
+
+grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount(
+ false, "security_connector_refcount");
+
+/* -- Constants. -- */
+
+#ifndef INSTALL_PREFIX
+static const char* installed_roots_path = "/usr/share/grpc/roots.pem";
+#else
+static const char* installed_roots_path =
+ INSTALL_PREFIX "/share/grpc/roots.pem";
+#endif
+
+/* -- Overridden default roots. -- */
+
+static grpc_ssl_roots_override_callback ssl_roots_override_cb = nullptr;
+
+void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
+ ssl_roots_override_cb = cb;
+}
+
+/* -- Cipher suites. -- */
+
+/* Defines the cipher suites that we accept by default. All these cipher suites
+ are compliant with HTTP2. */
+#define GRPC_SSL_CIPHER_SUITES \
+ "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384"
+
+static gpr_once cipher_suites_once = GPR_ONCE_INIT;
+static const char* cipher_suites = nullptr;
+
+static void init_cipher_suites(void) {
+ char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES");
+ cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES;
+}
+
+static const char* ssl_cipher_suites(void) {
+ gpr_once_init(&cipher_suites_once, init_cipher_suites);
+ return cipher_suites;
+}
+
+/* -- Common methods. -- */
+
+/* Returns the first property with that name. */
+const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
+ const char* name) {
+ size_t i;
+ if (peer == nullptr) return nullptr;
+ for (i = 0; i < peer->property_count; i++) {
+ const tsi_peer_property* property = &peer->properties[i];
+ if (name == nullptr && property->name == nullptr) {
+ return property;
+ }
+ if (name != nullptr && property->name != nullptr &&
+ strcmp(property->name, name) == 0) {
+ return property;
+ }
+ }
+ return nullptr;
+}
+
+void grpc_channel_security_connector_add_handshakers(
+ grpc_channel_security_connector* connector,
+ grpc_handshake_manager* handshake_mgr) {
+ if (connector != nullptr) {
+ connector->add_handshakers(connector, handshake_mgr);
+ }
+}
+
+void grpc_server_security_connector_add_handshakers(
+ grpc_server_security_connector* connector,
+ grpc_handshake_manager* handshake_mgr) {
+ if (connector != nullptr) {
+ connector->add_handshakers(connector, handshake_mgr);
+ }
+}
+
+void grpc_security_connector_check_peer(grpc_security_connector* sc,
+ tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ if (sc == nullptr) {
+ GRPC_CLOSURE_SCHED(on_peer_checked,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "cannot check peer -- no security connector"));
+ tsi_peer_destruct(&peer);
+ } else {
+ sc->vtable->check_peer(sc, peer, auth_context, on_peer_checked);
+ }
+}
+
+int grpc_security_connector_cmp(grpc_security_connector* sc,
+ grpc_security_connector* other) {
+ if (sc == nullptr || other == nullptr) return GPR_ICMP(sc, other);
+ int c = GPR_ICMP(sc->vtable, other->vtable);
+ if (c != 0) return c;
+ return sc->vtable->cmp(sc, other);
+}
+
+int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
+ grpc_channel_security_connector* sc2) {
+ GPR_ASSERT(sc1->channel_creds != nullptr);
+ GPR_ASSERT(sc2->channel_creds != nullptr);
+ int c = GPR_ICMP(sc1->channel_creds, sc2->channel_creds);
+ if (c != 0) return c;
+ c = GPR_ICMP(sc1->request_metadata_creds, sc2->request_metadata_creds);
+ if (c != 0) return c;
+ c = GPR_ICMP((void*)sc1->check_call_host, (void*)sc2->check_call_host);
+ if (c != 0) return c;
+ c = GPR_ICMP((void*)sc1->cancel_check_call_host,
+ (void*)sc2->cancel_check_call_host);
+ if (c != 0) return c;
+ return GPR_ICMP((void*)sc1->add_handshakers, (void*)sc2->add_handshakers);
+}
+
+int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
+ grpc_server_security_connector* sc2) {
+ GPR_ASSERT(sc1->server_creds != nullptr);
+ GPR_ASSERT(sc2->server_creds != nullptr);
+ int c = GPR_ICMP(sc1->server_creds, sc2->server_creds);
+ if (c != 0) return c;
+ return GPR_ICMP((void*)sc1->add_handshakers, (void*)sc2->add_handshakers);
+}
+
+bool grpc_channel_security_connector_check_call_host(
+ grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context, grpc_closure* on_call_host_checked,
+ grpc_error** error) {
+ if (sc == nullptr || sc->check_call_host == nullptr) {
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "cannot check call host -- no security connector");
+ return true;
+ }
+ return sc->check_call_host(sc, host, auth_context, on_call_host_checked,
+ error);
+}
+
+void grpc_channel_security_connector_cancel_check_call_host(
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
+ if (sc == nullptr || sc->cancel_check_call_host == nullptr) {
+ GRPC_ERROR_UNREF(error);
+ return;
+ }
+ sc->cancel_check_call_host(sc, on_call_host_checked, error);
+}
+
+#ifndef NDEBUG
+grpc_security_connector* grpc_security_connector_ref(
+ grpc_security_connector* sc, const char* file, int line,
+ const char* reason) {
+ if (sc == nullptr) return nullptr;
+ if (grpc_trace_security_connector_refcount.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&sc->refcount.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "SECURITY_CONNECTOR:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", sc,
+ val, val + 1, reason);
+ }
+#else
+grpc_security_connector* grpc_security_connector_ref(
+ grpc_security_connector* sc) {
+ if (sc == nullptr) return nullptr;
+#endif
+ gpr_ref(&sc->refcount);
+ return sc;
+}
+
+#ifndef NDEBUG
+void grpc_security_connector_unref(grpc_security_connector* sc,
+ const char* file, int line,
+ const char* reason) {
+ if (sc == nullptr) return;
+ if (grpc_trace_security_connector_refcount.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&sc->refcount.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "SECURITY_CONNECTOR:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", sc,
+ val, val - 1, reason);
+ }
+#else
+void grpc_security_connector_unref(grpc_security_connector* sc) {
+ if (sc == nullptr) return;
+#endif
+ if (gpr_unref(&sc->refcount)) sc->vtable->destroy(sc);
+}
+
+static void connector_arg_destroy(void* p) {
+ GRPC_SECURITY_CONNECTOR_UNREF((grpc_security_connector*)p,
+ "connector_arg_destroy");
+}
+
+static void* connector_arg_copy(void* p) {
+ return GRPC_SECURITY_CONNECTOR_REF((grpc_security_connector*)p,
+ "connector_arg_copy");
+}
+
+static int connector_cmp(void* a, void* b) {
+ return grpc_security_connector_cmp((grpc_security_connector*)a,
+ (grpc_security_connector*)b);
+}
+
+static const grpc_arg_pointer_vtable connector_arg_vtable = {
+ connector_arg_copy, connector_arg_destroy, connector_cmp};
+
+grpc_arg grpc_security_connector_to_arg(grpc_security_connector* sc) {
+ return grpc_channel_arg_pointer_create((char*)GRPC_ARG_SECURITY_CONNECTOR, sc,
+ &connector_arg_vtable);
+}
+
+grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg) {
+ if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return nullptr;
+ if (arg->type != GRPC_ARG_POINTER) {
+ gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
+ GRPC_ARG_SECURITY_CONNECTOR);
+ return nullptr;
+ }
+ return (grpc_security_connector*)arg->value.pointer.p;
+}
+
+grpc_security_connector* grpc_security_connector_find_in_args(
+ const grpc_channel_args* args) {
+ size_t i;
+ if (args == nullptr) return nullptr;
+ for (i = 0; i < args->num_args; i++) {
+ grpc_security_connector* sc =
+ grpc_security_connector_from_arg(&args->args[i]);
+ if (sc != nullptr) return sc;
+ }
+ return nullptr;
+}
+
+static tsi_client_certificate_request_type
+get_tsi_client_certificate_request_type(
+ grpc_ssl_client_certificate_request_type grpc_request_type) {
+ switch (grpc_request_type) {
+ case GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE:
+ return TSI_DONT_REQUEST_CLIENT_CERTIFICATE;
+
+ case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
+ return TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY;
+
+ case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY:
+ return TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY;
+
+ case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
+ return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY;
+
+ case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY:
+ return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY;
+
+ default:
+ return TSI_DONT_REQUEST_CLIENT_CERTIFICATE;
+ }
+}
+
+/* -- Fake implementation. -- */
+
+typedef struct {
+ grpc_channel_security_connector base;
+ char* target;
+ char* expected_targets;
+ bool is_lb_channel;
+} grpc_fake_channel_security_connector;
+
+static void fake_channel_destroy(grpc_security_connector* sc) {
+ grpc_fake_channel_security_connector* c =
+ (grpc_fake_channel_security_connector*)sc;
+ grpc_call_credentials_unref(c->base.request_metadata_creds);
+ gpr_free(c->target);
+ gpr_free(c->expected_targets);
+ gpr_free(c);
+}
+
+static void fake_server_destroy(grpc_security_connector* sc) { gpr_free(sc); }
+
+static bool fake_check_target(const char* target_type, const char* target,
+ const char* set_str) {
+ GPR_ASSERT(target_type != nullptr);
+ GPR_ASSERT(target != nullptr);
+ char** set = nullptr;
+ size_t set_size = 0;
+ gpr_string_split(set_str, ",", &set, &set_size);
+ bool found = false;
+ for (size_t i = 0; i < set_size; ++i) {
+ if (set[i] != nullptr && strcmp(target, set[i]) == 0) found = true;
+ }
+ for (size_t i = 0; i < set_size; ++i) {
+ gpr_free(set[i]);
+ }
+ gpr_free(set);
+ return found;
+}
+
+static void fake_secure_name_check(const char* target,
+ const char* expected_targets,
+ bool is_lb_channel) {
+ if (expected_targets == nullptr) return;
+ char** lbs_and_backends = nullptr;
+ size_t lbs_and_backends_size = 0;
+ bool success = false;
+ gpr_string_split(expected_targets, ";", &lbs_and_backends,
+ &lbs_and_backends_size);
+ if (lbs_and_backends_size > 2 || lbs_and_backends_size == 0) {
+ gpr_log(GPR_ERROR, "Invalid expected targets arg value: '%s'",
+ expected_targets);
+ goto done;
+ }
+ if (is_lb_channel) {
+ if (lbs_and_backends_size != 2) {
+ gpr_log(GPR_ERROR,
+ "Invalid expected targets arg value: '%s'. Expectations for LB "
+ "channels must be of the form 'be1,be2,be3,...;lb1,lb2,...",
+ expected_targets);
+ goto done;
+ }
+ if (!fake_check_target("LB", target, lbs_and_backends[1])) {
+ gpr_log(GPR_ERROR, "LB target '%s' not found in expected set '%s'",
+ target, lbs_and_backends[1]);
+ goto done;
+ }
+ success = true;
+ } else {
+ if (!fake_check_target("Backend", target, lbs_and_backends[0])) {
+ gpr_log(GPR_ERROR, "Backend target '%s' not found in expected set '%s'",
+ target, lbs_and_backends[0]);
+ goto done;
+ }
+ success = true;
+ }
+done:
+ for (size_t i = 0; i < lbs_and_backends_size; ++i) {
+ gpr_free(lbs_and_backends[i]);
+ }
+ gpr_free(lbs_and_backends);
+ if (!success) abort();
+}
+
+static void fake_check_peer(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ const char* prop_name;
+ grpc_error* error = GRPC_ERROR_NONE;
+ *auth_context = nullptr;
+ if (peer.property_count != 1) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Fake peers should only have 1 property.");
+ goto end;
+ }
+ prop_name = peer.properties[0].name;
+ if (prop_name == nullptr ||
+ strcmp(prop_name, TSI_CERTIFICATE_TYPE_PEER_PROPERTY)) {
+ char* msg;
+ gpr_asprintf(&msg, "Unexpected property in fake peer: %s.",
+ prop_name == nullptr ? "<EMPTY>" : prop_name);
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ gpr_free(msg);
+ goto end;
+ }
+ if (strncmp(peer.properties[0].value.data, TSI_FAKE_CERTIFICATE_TYPE,
+ peer.properties[0].value.length)) {
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Invalid value for cert type property.");
+ goto end;
+ }
+ *auth_context = grpc_auth_context_create(nullptr);
+ grpc_auth_context_add_cstring_property(
+ *auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
+ GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
+end:
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
+ tsi_peer_destruct(&peer);
+}
+
+static void fake_channel_check_peer(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ fake_check_peer(sc, peer, auth_context, on_peer_checked);
+ grpc_fake_channel_security_connector* c =
+ (grpc_fake_channel_security_connector*)sc;
+ fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel);
+}
+
+static void fake_server_check_peer(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ fake_check_peer(sc, peer, auth_context, on_peer_checked);
+}
+
+static int fake_channel_cmp(grpc_security_connector* sc1,
+ grpc_security_connector* sc2) {
+ grpc_fake_channel_security_connector* c1 =
+ (grpc_fake_channel_security_connector*)sc1;
+ grpc_fake_channel_security_connector* c2 =
+ (grpc_fake_channel_security_connector*)sc2;
+ int c = grpc_channel_security_connector_cmp(&c1->base, &c2->base);
+ if (c != 0) return c;
+ c = strcmp(c1->target, c2->target);
+ if (c != 0) return c;
+ if (c1->expected_targets == nullptr || c2->expected_targets == nullptr) {
+ c = GPR_ICMP(c1->expected_targets, c2->expected_targets);
+ } else {
+ c = strcmp(c1->expected_targets, c2->expected_targets);
+ }
+ if (c != 0) return c;
+ return GPR_ICMP(c1->is_lb_channel, c2->is_lb_channel);
+}
+
+static int fake_server_cmp(grpc_security_connector* sc1,
+ grpc_security_connector* sc2) {
+ return grpc_server_security_connector_cmp(
+ (grpc_server_security_connector*)sc1,
+ (grpc_server_security_connector*)sc2);
+}
+
+static bool fake_channel_check_call_host(grpc_channel_security_connector* sc,
+ const char* host,
+ grpc_auth_context* auth_context,
+ grpc_closure* on_call_host_checked,
+ grpc_error** error) {
+ return true;
+}
+
+static void fake_channel_cancel_check_call_host(
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
+ GRPC_ERROR_UNREF(error);
+}
+
+static void fake_channel_add_handshakers(
+ grpc_channel_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(
+ tsi_create_fake_handshaker(true /* is_client */), &sc->base));
+}
+
+static void fake_server_add_handshakers(grpc_server_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(
+ tsi_create_fake_handshaker(false /* is_client */), &sc->base));
+}
+
+static grpc_security_connector_vtable fake_channel_vtable = {
+ fake_channel_destroy, fake_channel_check_peer, fake_channel_cmp};
+
+static grpc_security_connector_vtable fake_server_vtable = {
+ fake_server_destroy, fake_server_check_peer, fake_server_cmp};
+
+grpc_channel_security_connector* grpc_fake_channel_security_connector_create(
+ grpc_channel_credentials* channel_creds,
+ grpc_call_credentials* request_metadata_creds, const char* target,
+ const grpc_channel_args* args) {
+ grpc_fake_channel_security_connector* c =
+ (grpc_fake_channel_security_connector*)gpr_zalloc(sizeof(*c));
+ gpr_ref_init(&c->base.base.refcount, 1);
+ c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
+ c->base.base.vtable = &fake_channel_vtable;
+ c->base.channel_creds = channel_creds;
+ c->base.request_metadata_creds =
+ grpc_call_credentials_ref(request_metadata_creds);
+ c->base.check_call_host = fake_channel_check_call_host;
+ c->base.cancel_check_call_host = fake_channel_cancel_check_call_host;
+ c->base.add_handshakers = fake_channel_add_handshakers;
+ c->target = gpr_strdup(target);
+ const char* expected_targets = grpc_fake_transport_get_expected_targets(args);
+ c->expected_targets = gpr_strdup(expected_targets);
+ c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != nullptr);
+ return &c->base;
+}
+
+grpc_server_security_connector* grpc_fake_server_security_connector_create(
+ grpc_server_credentials* server_creds) {
+ grpc_server_security_connector* c =
+ (grpc_server_security_connector*)gpr_zalloc(
+ sizeof(grpc_server_security_connector));
+ gpr_ref_init(&c->base.refcount, 1);
+ c->base.vtable = &fake_server_vtable;
+ c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
+ c->server_creds = server_creds;
+ c->add_handshakers = fake_server_add_handshakers;
+ return c;
+}
+
+/* --- Ssl implementation. --- */
+
+typedef struct {
+ grpc_channel_security_connector base;
+ tsi_ssl_client_handshaker_factory* client_handshaker_factory;
+ char* target_name;
+ char* overridden_target_name;
+} grpc_ssl_channel_security_connector;
+
+typedef struct {
+ grpc_server_security_connector base;
+ tsi_ssl_server_handshaker_factory* server_handshaker_factory;
+} grpc_ssl_server_security_connector;
+
+static bool server_connector_has_cert_config_fetcher(
+ grpc_ssl_server_security_connector* c) {
+ GPR_ASSERT(c != nullptr);
+ grpc_ssl_server_credentials* server_creds =
+ (grpc_ssl_server_credentials*)c->base.server_creds;
+ GPR_ASSERT(server_creds != nullptr);
+ return server_creds->certificate_config_fetcher.cb != nullptr;
+}
+
+static void ssl_channel_destroy(grpc_security_connector* sc) {
+ grpc_ssl_channel_security_connector* c =
+ (grpc_ssl_channel_security_connector*)sc;
+ grpc_channel_credentials_unref(c->base.channel_creds);
+ grpc_call_credentials_unref(c->base.request_metadata_creds);
+ tsi_ssl_client_handshaker_factory_unref(c->client_handshaker_factory);
+ c->client_handshaker_factory = nullptr;
+ if (c->target_name != nullptr) gpr_free(c->target_name);
+ if (c->overridden_target_name != nullptr) gpr_free(c->overridden_target_name);
+ gpr_free(sc);
+}
+
+static void ssl_server_destroy(grpc_security_connector* sc) {
+ grpc_ssl_server_security_connector* c =
+ (grpc_ssl_server_security_connector*)sc;
+ grpc_server_credentials_unref(c->base.server_creds);
+ tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory);
+ c->server_handshaker_factory = nullptr;
+ gpr_free(sc);
+}
+
+static void ssl_channel_add_handshakers(grpc_channel_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_ssl_channel_security_connector* c =
+ (grpc_ssl_channel_security_connector*)sc;
+ // Instantiate TSI handshaker.
+ tsi_handshaker* tsi_hs = nullptr;
+ tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
+ c->client_handshaker_factory,
+ c->overridden_target_name != nullptr ? c->overridden_target_name
+ : c->target_name,
+ &tsi_hs);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
+ tsi_result_to_string(result));
+ return;
+ }
+ // Create handshakers.
+ grpc_handshake_manager_add(
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(tsi_hs), &sc->base));
+}
+
+static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
+ GPR_ASSERT(num_alpn_protocols != nullptr);
+ *num_alpn_protocols = grpc_chttp2_num_alpn_versions();
+ const char** alpn_protocol_strings =
+ (const char**)gpr_malloc(sizeof(const char*) * (*num_alpn_protocols));
+ for (size_t i = 0; i < *num_alpn_protocols; i++) {
+ alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i);
+ }
+ return alpn_protocol_strings;
+}
+
+/* Attempts to replace the server_handshaker_factory with a new factory using
+ * the provided grpc_ssl_server_certificate_config. Should new factory creation
+ * fail, the existing factory will not be replaced. Returns true on success (new
+ * factory created). */
+static bool try_replace_server_handshaker_factory(
+ grpc_ssl_server_security_connector* sc,
+ const grpc_ssl_server_certificate_config* config) {
+ if (config == nullptr) {
+ gpr_log(GPR_ERROR,
+ "Server certificate config callback returned invalid (NULL) "
+ "config.");
+ return false;
+ }
+ gpr_log(GPR_DEBUG, "Using new server certificate config (%p).", config);
+
+ size_t num_alpn_protocols = 0;
+ const char** alpn_protocol_strings =
+ fill_alpn_protocol_strings(&num_alpn_protocols);
+ tsi_ssl_pem_key_cert_pair* cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
+ config->pem_key_cert_pairs, config->num_key_cert_pairs);
+ tsi_ssl_server_handshaker_factory* new_handshaker_factory = nullptr;
+ grpc_ssl_server_credentials* server_creds =
+ (grpc_ssl_server_credentials*)sc->base.server_creds;
+ tsi_result result = tsi_create_ssl_server_handshaker_factory_ex(
+ cert_pairs, config->num_key_cert_pairs, config->pem_root_certs,
+ get_tsi_client_certificate_request_type(
+ server_creds->config.client_certificate_request),
+ ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
+ &new_handshaker_factory);
+ gpr_free(cert_pairs);
+ gpr_free((void*)alpn_protocol_strings);
+
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
+ tsi_result_to_string(result));
+ return false;
+ }
+ tsi_ssl_server_handshaker_factory_unref(sc->server_handshaker_factory);
+ sc->server_handshaker_factory = new_handshaker_factory;
+ return true;
+}
+
+/* Attempts to fetch the server certificate config if a callback is available.
+ * Current certificate config will continue to be used if the callback returns
+ * an error. Returns true if new credentials were sucessfully loaded. */
+static bool try_fetch_ssl_server_credentials(
+ grpc_ssl_server_security_connector* sc) {
+ grpc_ssl_server_certificate_config* certificate_config = nullptr;
+ bool status;
+
+ GPR_ASSERT(sc != nullptr);
+ if (!server_connector_has_cert_config_fetcher(sc)) return false;
+
+ grpc_ssl_server_credentials* server_creds =
+ (grpc_ssl_server_credentials*)sc->base.server_creds;
+ grpc_ssl_certificate_config_reload_status cb_result =
+ server_creds->certificate_config_fetcher.cb(
+ server_creds->certificate_config_fetcher.user_data,
+ &certificate_config);
+ if (cb_result == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED) {
+ gpr_log(GPR_DEBUG, "No change in SSL server credentials.");
+ status = false;
+ } else if (cb_result == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) {
+ status = try_replace_server_handshaker_factory(sc, certificate_config);
+ } else {
+ // Log error, continue using previously-loaded credentials.
+ gpr_log(GPR_ERROR,
+ "Failed fetching new server credentials, continuing to "
+ "use previously-loaded credentials.");
+ status = false;
+ }
+
+ if (certificate_config != nullptr) {
+ grpc_ssl_server_certificate_config_destroy(certificate_config);
+ }
+ return status;
+}
+
+static void ssl_server_add_handshakers(grpc_server_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_ssl_server_security_connector* c =
+ (grpc_ssl_server_security_connector*)sc;
+ // Instantiate TSI handshaker.
+ try_fetch_ssl_server_credentials(c);
+ tsi_handshaker* tsi_hs = nullptr;
+ tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
+ c->server_handshaker_factory, &tsi_hs);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
+ tsi_result_to_string(result));
+ return;
+ }
+ // Create handshakers.
+ grpc_handshake_manager_add(
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(tsi_hs), &sc->base));
+}
+
+static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
+ char* allocated_name = nullptr;
+ int r;
+
+ if (strchr(peer_name, ':') != nullptr) {
+ char* ignored_port;
+ gpr_split_host_port(peer_name, &allocated_name, &ignored_port);
+ gpr_free(ignored_port);
+ peer_name = allocated_name;
+ if (!peer_name) return 0;
+ }
+ r = tsi_ssl_peer_matches_name(peer, peer_name);
+ gpr_free(allocated_name);
+ return r;
+}
+
+grpc_auth_context* tsi_ssl_peer_to_auth_context(const tsi_peer* peer) {
+ size_t i;
+ grpc_auth_context* ctx = nullptr;
+ const char* peer_identity_property_name = nullptr;
+
+ /* The caller has checked the certificate type property. */
+ GPR_ASSERT(peer->property_count >= 1);
+ ctx = grpc_auth_context_create(nullptr);
+ grpc_auth_context_add_cstring_property(
+ ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
+ GRPC_SSL_TRANSPORT_SECURITY_TYPE);
+ for (i = 0; i < peer->property_count; i++) {
+ const tsi_peer_property* prop = &peer->properties[i];
+ if (prop->name == nullptr) continue;
+ if (strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) {
+ /* If there is no subject alt name, have the CN as the identity. */
+ if (peer_identity_property_name == nullptr) {
+ peer_identity_property_name = GRPC_X509_CN_PROPERTY_NAME;
+ }
+ grpc_auth_context_add_property(ctx, GRPC_X509_CN_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
+ } else if (strcmp(prop->name,
+ TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
+ peer_identity_property_name = GRPC_X509_SAN_PROPERTY_NAME;
+ grpc_auth_context_add_property(ctx, GRPC_X509_SAN_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
+ } else if (strcmp(prop->name, TSI_X509_PEM_CERT_PROPERTY) == 0) {
+ grpc_auth_context_add_property(ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
+ }
+ }
+ if (peer_identity_property_name != nullptr) {
+ GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
+ ctx, peer_identity_property_name) == 1);
+ }
+ return ctx;
+}
+
+static grpc_error* ssl_check_peer(grpc_security_connector* sc,
+ const char* peer_name, const tsi_peer* peer,
+ grpc_auth_context** auth_context) {
+ /* Check the ALPN. */
+ const tsi_peer_property* p =
+ tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
+ if (p == nullptr) {
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Cannot check peer: missing selected ALPN property.");
+ }
+ if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Cannot check peer: invalid ALPN value.");
+ }
+
+ /* Check the peer name if specified. */
+ if (peer_name != nullptr && !ssl_host_matches_name(peer, peer_name)) {
+ char* msg;
+ gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
+ gpr_free(msg);
+ return error;
+ }
+ *auth_context = tsi_ssl_peer_to_auth_context(peer);
+ return GRPC_ERROR_NONE;
+}
+
+static void ssl_channel_check_peer(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ grpc_ssl_channel_security_connector* c =
+ (grpc_ssl_channel_security_connector*)sc;
+ grpc_error* error = ssl_check_peer(sc,
+ c->overridden_target_name != nullptr
+ ? c->overridden_target_name
+ : c->target_name,
+ &peer, auth_context);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
+ tsi_peer_destruct(&peer);
+}
+
+static void ssl_server_check_peer(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ grpc_error* error = ssl_check_peer(sc, nullptr, &peer, auth_context);
+ tsi_peer_destruct(&peer);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
+}
+
+static int ssl_channel_cmp(grpc_security_connector* sc1,
+ grpc_security_connector* sc2) {
+ grpc_ssl_channel_security_connector* c1 =
+ (grpc_ssl_channel_security_connector*)sc1;
+ grpc_ssl_channel_security_connector* c2 =
+ (grpc_ssl_channel_security_connector*)sc2;
+ int c = grpc_channel_security_connector_cmp(&c1->base, &c2->base);
+ if (c != 0) return c;
+ c = strcmp(c1->target_name, c2->target_name);
+ if (c != 0) return c;
+ return (c1->overridden_target_name == nullptr ||
+ c2->overridden_target_name == nullptr)
+ ? GPR_ICMP(c1->overridden_target_name, c2->overridden_target_name)
+ : strcmp(c1->overridden_target_name, c2->overridden_target_name);
+}
+
+static int ssl_server_cmp(grpc_security_connector* sc1,
+ grpc_security_connector* sc2) {
+ return grpc_server_security_connector_cmp(
+ (grpc_server_security_connector*)sc1,
+ (grpc_server_security_connector*)sc2);
+}
+
+static void add_shallow_auth_property_to_peer(tsi_peer* peer,
+ const grpc_auth_property* prop,
+ const char* tsi_prop_name) {
+ tsi_peer_property* tsi_prop = &peer->properties[peer->property_count++];
+ tsi_prop->name = (char*)tsi_prop_name;
+ tsi_prop->value.data = prop->value;
+ tsi_prop->value.length = prop->value_length;
+}
+
+tsi_peer tsi_shallow_peer_from_ssl_auth_context(
+ const grpc_auth_context* auth_context) {
+ size_t max_num_props = 0;
+ grpc_auth_property_iterator it;
+ const grpc_auth_property* prop;
+ tsi_peer peer;
+ memset(&peer, 0, sizeof(peer));
+
+ it = grpc_auth_context_property_iterator(auth_context);
+ while (grpc_auth_property_iterator_next(&it) != nullptr) max_num_props++;
+
+ if (max_num_props > 0) {
+ peer.properties = (tsi_peer_property*)gpr_malloc(max_num_props *
+ sizeof(tsi_peer_property));
+ it = grpc_auth_context_property_iterator(auth_context);
+ while ((prop = grpc_auth_property_iterator_next(&it)) != nullptr) {
+ if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) {
+ add_shallow_auth_property_to_peer(
+ &peer, prop, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY);
+ } else if (strcmp(prop->name, GRPC_X509_CN_PROPERTY_NAME) == 0) {
+ add_shallow_auth_property_to_peer(
+ &peer, prop, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY);
+ } else if (strcmp(prop->name, GRPC_X509_PEM_CERT_PROPERTY_NAME) == 0) {
+ add_shallow_auth_property_to_peer(&peer, prop,
+ TSI_X509_PEM_CERT_PROPERTY);
+ }
+ }
+ }
+ return peer;
+}
+
+void tsi_shallow_peer_destruct(tsi_peer* peer) {
+ if (peer->properties != nullptr) gpr_free(peer->properties);
+}
+
+static bool ssl_channel_check_call_host(grpc_channel_security_connector* sc,
+ const char* host,
+ grpc_auth_context* auth_context,
+ grpc_closure* on_call_host_checked,
+ grpc_error** error) {
+ grpc_ssl_channel_security_connector* c =
+ (grpc_ssl_channel_security_connector*)sc;
+ grpc_security_status status = GRPC_SECURITY_ERROR;
+ tsi_peer peer = tsi_shallow_peer_from_ssl_auth_context(auth_context);
+ if (ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK;
+ /* If the target name was overridden, then the original target_name was
+ 'checked' transitively during the previous peer check at the end of the
+ handshake. */
+ if (c->overridden_target_name != nullptr &&
+ strcmp(host, c->target_name) == 0) {
+ status = GRPC_SECURITY_OK;
+ }
+ if (status != GRPC_SECURITY_OK) {
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "call host does not match SSL server name");
+ }
+ tsi_shallow_peer_destruct(&peer);
+ return true;
+}
+
+static void ssl_channel_cancel_check_call_host(
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
+ GRPC_ERROR_UNREF(error);
+}
+
+static grpc_security_connector_vtable ssl_channel_vtable = {
+ ssl_channel_destroy, ssl_channel_check_peer, ssl_channel_cmp};
+
+static grpc_security_connector_vtable ssl_server_vtable = {
+ ssl_server_destroy, ssl_server_check_peer, ssl_server_cmp};
+
+/* returns a NULL terminated slice. */
+static grpc_slice compute_default_pem_root_certs_once(void) {
+ grpc_slice result = grpc_empty_slice();
+
+ /* First try to load the roots from the environment. */
+ char* default_root_certs_path =
+ gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR);
+ if (default_root_certs_path != nullptr) {
+ GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(default_root_certs_path, 1, &result));
+ gpr_free(default_root_certs_path);
+ }
+
+ /* Try overridden roots if needed. */
+ grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL;
+ if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != nullptr) {
+ char* pem_root_certs = nullptr;
+ ovrd_res = ssl_roots_override_cb(&pem_root_certs);
+ if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) {
+ GPR_ASSERT(pem_root_certs != nullptr);
+ result = grpc_slice_from_copied_buffer(
+ pem_root_certs,
+ strlen(pem_root_certs) + 1); // NULL terminator.
+ }
+ gpr_free(pem_root_certs);
+ }
+
+ /* Fall back to installed certs if needed. */
+ if (GRPC_SLICE_IS_EMPTY(result) &&
+ ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) {
+ GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(installed_roots_path, 1, &result));
+ }
+ return result;
+}
+
+static grpc_slice default_pem_root_certs;
+
+static void init_default_pem_root_certs(void) {
+ default_pem_root_certs = compute_default_pem_root_certs_once();
+}
+
+grpc_slice grpc_get_default_ssl_roots_for_testing(void) {
+ return compute_default_pem_root_certs_once();
+}
+
+const char* grpc_get_default_ssl_roots(void) {
+ /* TODO(jboeuf@google.com): Maybe revisit the approach which consists in
+ loading all the roots once for the lifetime of the process. */
+ static gpr_once once = GPR_ONCE_INIT;
+ gpr_once_init(&once, init_default_pem_root_certs);
+ return GRPC_SLICE_IS_EMPTY(default_pem_root_certs)
+ ? nullptr
+ : (const char*)GRPC_SLICE_START_PTR(default_pem_root_certs);
+}
+
+grpc_security_status grpc_ssl_channel_security_connector_create(
+ grpc_channel_credentials* channel_creds,
+ grpc_call_credentials* request_metadata_creds,
+ const grpc_ssl_config* config, const char* target_name,
+ const char* overridden_target_name, grpc_channel_security_connector** sc) {
+ size_t num_alpn_protocols = 0;
+ const char** alpn_protocol_strings =
+ fill_alpn_protocol_strings(&num_alpn_protocols);
+ tsi_result result = TSI_OK;
+ grpc_ssl_channel_security_connector* c;
+ const char* pem_root_certs;
+ char* port;
+ bool has_key_cert_pair;
+
+ if (config == nullptr || target_name == nullptr) {
+ gpr_log(GPR_ERROR, "An ssl channel needs a config and a target name.");
+ goto error;
+ }
+ if (config->pem_root_certs == nullptr) {
+ pem_root_certs = grpc_get_default_ssl_roots();
+ if (pem_root_certs == nullptr) {
+ gpr_log(GPR_ERROR, "Could not get default pem root certs.");
+ goto error;
+ }
+ } else {
+ pem_root_certs = config->pem_root_certs;
+ }
+
+ c = (grpc_ssl_channel_security_connector*)gpr_zalloc(
+ sizeof(grpc_ssl_channel_security_connector));
+
+ gpr_ref_init(&c->base.base.refcount, 1);
+ c->base.base.vtable = &ssl_channel_vtable;
+ c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
+ c->base.channel_creds = grpc_channel_credentials_ref(channel_creds);
+ c->base.request_metadata_creds =
+ grpc_call_credentials_ref(request_metadata_creds);
+ c->base.check_call_host = ssl_channel_check_call_host;
+ c->base.cancel_check_call_host = ssl_channel_cancel_check_call_host;
+ c->base.add_handshakers = ssl_channel_add_handshakers;
+ gpr_split_host_port(target_name, &c->target_name, &port);
+ gpr_free(port);
+ if (overridden_target_name != nullptr) {
+ c->overridden_target_name = gpr_strdup(overridden_target_name);
+ }
+
+ has_key_cert_pair = config->pem_key_cert_pair != nullptr &&
+ config->pem_key_cert_pair->private_key != nullptr &&
+ config->pem_key_cert_pair->cert_chain != nullptr;
+ result = tsi_create_ssl_client_handshaker_factory(
+ has_key_cert_pair ? config->pem_key_cert_pair : nullptr, pem_root_certs,
+ ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
+ &c->client_handshaker_factory);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
+ tsi_result_to_string(result));
+ ssl_channel_destroy(&c->base.base);
+ *sc = nullptr;
+ goto error;
+ }
+ *sc = &c->base;
+ gpr_free((void*)alpn_protocol_strings);
+ return GRPC_SECURITY_OK;
+
+error:
+ gpr_free((void*)alpn_protocol_strings);
+ return GRPC_SECURITY_ERROR;
+}
+
+static grpc_ssl_server_security_connector*
+grpc_ssl_server_security_connector_initialize(
+ grpc_server_credentials* server_creds) {
+ grpc_ssl_server_security_connector* c =
+ (grpc_ssl_server_security_connector*)gpr_zalloc(
+ sizeof(grpc_ssl_server_security_connector));
+ gpr_ref_init(&c->base.base.refcount, 1);
+ c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
+ c->base.base.vtable = &ssl_server_vtable;
+ c->base.add_handshakers = ssl_server_add_handshakers;
+ c->base.server_creds = grpc_server_credentials_ref(server_creds);
+ return c;
+}
+
+grpc_security_status grpc_ssl_server_security_connector_create(
+ grpc_server_credentials* gsc, grpc_server_security_connector** sc) {
+ tsi_result result = TSI_OK;
+ grpc_ssl_server_credentials* server_credentials =
+ (grpc_ssl_server_credentials*)gsc;
+ grpc_security_status retval = GRPC_SECURITY_OK;
+
+ GPR_ASSERT(server_credentials != nullptr);
+ GPR_ASSERT(sc != nullptr);
+
+ grpc_ssl_server_security_connector* c =
+ grpc_ssl_server_security_connector_initialize(gsc);
+ if (server_connector_has_cert_config_fetcher(c)) {
+ // Load initial credentials from certificate_config_fetcher:
+ if (!try_fetch_ssl_server_credentials(c)) {
+ gpr_log(GPR_ERROR, "Failed loading SSL server credentials from fetcher.");
+ retval = GRPC_SECURITY_ERROR;
+ }
+ } else {
+ size_t num_alpn_protocols = 0;
+ const char** alpn_protocol_strings =
+ fill_alpn_protocol_strings(&num_alpn_protocols);
+ result = tsi_create_ssl_server_handshaker_factory_ex(
+ server_credentials->config.pem_key_cert_pairs,
+ server_credentials->config.num_key_cert_pairs,
+ server_credentials->config.pem_root_certs,
+ get_tsi_client_certificate_request_type(
+ server_credentials->config.client_certificate_request),
+ ssl_cipher_suites(), alpn_protocol_strings,
+ (uint16_t)num_alpn_protocols, &c->server_handshaker_factory);
+ gpr_free((void*)alpn_protocol_strings);
+ if (result != TSI_OK) {
+ gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
+ tsi_result_to_string(result));
+ retval = GRPC_SECURITY_ERROR;
+ }
+ }
+
+ if (retval == GRPC_SECURITY_OK) {
+ *sc = &c->base;
+ } else {
+ if (c != nullptr) ssl_server_destroy(&c->base.base);
+ if (sc != nullptr) *sc = nullptr;
+ }
+ return retval;
+}
diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h
index 4f9b63ad20..495821d247 100644
--- a/src/core/lib/security/transport/security_connector.h
+++ b/src/core/lib/security/transport/security_connector.h
@@ -29,9 +29,7 @@
#include "src/core/tsi/ssl_transport_security.h"
#include "src/core/tsi/transport_security_interface.h"
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_security_connector_refcount;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount;
/* --- status enum. --- */
@@ -52,145 +50,147 @@ typedef struct grpc_security_connector grpc_security_connector;
#define GRPC_ARG_SECURITY_CONNECTOR "grpc.security_connector"
typedef struct {
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc);
- void (*check_peer)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc,
- tsi_peer peer, grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked);
+ void (*destroy)(grpc_security_connector* sc);
+ void (*check_peer)(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked);
+ int (*cmp)(grpc_security_connector* sc, grpc_security_connector* other);
} grpc_security_connector_vtable;
-typedef struct grpc_security_connector_handshake_list {
- void *handshake;
- struct grpc_security_connector_handshake_list *next;
-} grpc_security_connector_handshake_list;
-
struct grpc_security_connector {
- const grpc_security_connector_vtable *vtable;
+ const grpc_security_connector_vtable* vtable;
gpr_refcount refcount;
- const char *url_scheme;
+ const char* url_scheme;
};
/* Refcounting. */
#ifndef NDEBUG
#define GRPC_SECURITY_CONNECTOR_REF(p, r) \
grpc_security_connector_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \
- grpc_security_connector_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
-grpc_security_connector *grpc_security_connector_ref(
- grpc_security_connector *policy, const char *file, int line,
- const char *reason);
-void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *policy,
- const char *file, int line,
- const char *reason);
+#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) \
+ grpc_security_connector_unref((p), __FILE__, __LINE__, (r))
+grpc_security_connector* grpc_security_connector_ref(
+ grpc_security_connector* policy, const char* file, int line,
+ const char* reason);
+void grpc_security_connector_unref(grpc_security_connector* policy,
+ const char* file, int line,
+ const char* reason);
#else
#define GRPC_SECURITY_CONNECTOR_REF(p, r) grpc_security_connector_ref((p))
-#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \
- grpc_security_connector_unref((exec_ctx), (p))
-grpc_security_connector *grpc_security_connector_ref(
- grpc_security_connector *policy);
-void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *policy);
+#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) grpc_security_connector_unref((p))
+grpc_security_connector* grpc_security_connector_ref(
+ grpc_security_connector* policy);
+void grpc_security_connector_unref(grpc_security_connector* policy);
#endif
/* Check the peer. Callee takes ownership of the peer object.
When done, sets *auth_context and invokes on_peer_checked. */
-void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc,
+void grpc_security_connector_check_peer(grpc_security_connector* sc,
tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked);
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked);
+
+/* Compares two security connectors. */
+int grpc_security_connector_cmp(grpc_security_connector* sc,
+ grpc_security_connector* other);
/* Util to encapsulate the connector in a channel arg. */
-grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc);
+grpc_arg grpc_security_connector_to_arg(grpc_security_connector* sc);
/* Util to get the connector from a channel arg. */
-grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg);
+grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg);
/* Util to find the connector from channel args. */
-grpc_security_connector *grpc_security_connector_find_in_args(
- const grpc_channel_args *args);
+grpc_security_connector* grpc_security_connector_find_in_args(
+ const grpc_channel_args* args);
/* --- channel_security_connector object. ---
- A channel security connector object represents away to configure the
+ A channel security connector object represents a way to configure the
underlying transport security mechanism on the client side. */
typedef struct grpc_channel_security_connector grpc_channel_security_connector;
struct grpc_channel_security_connector {
grpc_security_connector base;
- grpc_call_credentials *request_metadata_creds;
- bool (*check_call_host)(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc, const char *host,
- grpc_auth_context *auth_context,
- grpc_closure *on_call_host_checked,
- grpc_error **error);
- void (*cancel_check_call_host)(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- grpc_closure *on_call_host_checked,
- grpc_error *error);
- void (*add_handshakers)(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- grpc_handshake_manager *handshake_mgr);
+ grpc_channel_credentials* channel_creds;
+ grpc_call_credentials* request_metadata_creds;
+ bool (*check_call_host)(grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context,
+ grpc_closure* on_call_host_checked,
+ grpc_error** error);
+ void (*cancel_check_call_host)(grpc_channel_security_connector* sc,
+ grpc_closure* on_call_host_checked,
+ grpc_error* error);
+ void (*add_handshakers)(grpc_channel_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr);
};
+/// A helper function for use in grpc_security_connector_cmp() implementations.
+int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
+ grpc_channel_security_connector* sc2);
+
/// Checks that the host that will be set for a call is acceptable.
/// Returns true if completed synchronously, in which case \a error will
/// be set to indicate the result. Otherwise, \a on_call_host_checked
/// will be invoked when complete.
bool grpc_channel_security_connector_check_call_host(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- const char *host, grpc_auth_context *auth_context,
- grpc_closure *on_call_host_checked, grpc_error **error);
+ grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context, grpc_closure* on_call_host_checked,
+ grpc_error** error);
/// Cancels a pending asychronous call to
/// grpc_channel_security_connector_check_call_host() with
/// \a on_call_host_checked as its callback.
void grpc_channel_security_connector_cancel_check_call_host(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
- grpc_closure *on_call_host_checked, grpc_error *error);
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error);
/* Registers handshakers with \a handshake_mgr. */
void grpc_channel_security_connector_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector,
- grpc_handshake_manager *handshake_mgr);
+ grpc_channel_security_connector* connector,
+ grpc_handshake_manager* handshake_mgr);
/* --- server_security_connector object. ---
- A server security connector object represents away to configure the
+ A server security connector object represents a way to configure the
underlying transport security mechanism on the server side. */
typedef struct grpc_server_security_connector grpc_server_security_connector;
struct grpc_server_security_connector {
grpc_security_connector base;
- void (*add_handshakers)(grpc_exec_ctx *exec_ctx,
- grpc_server_security_connector *sc,
- grpc_handshake_manager *handshake_mgr);
+ grpc_server_credentials* server_creds;
+ void (*add_handshakers)(grpc_server_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr);
};
+/// A helper function for use in grpc_security_connector_cmp() implementations.
+int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
+ grpc_server_security_connector* sc2);
+
void grpc_server_security_connector_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
- grpc_handshake_manager *handshake_mgr);
+ grpc_server_security_connector* sc, grpc_handshake_manager* handshake_mgr);
/* --- Creation security connectors. --- */
/* For TESTING ONLY!
Creates a fake connector that emulates real channel security. */
-grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
- grpc_call_credentials *request_metadata_creds, const char *target,
- const grpc_channel_args *args);
+grpc_channel_security_connector* grpc_fake_channel_security_connector_create(
+ grpc_channel_credentials* channel_creds,
+ grpc_call_credentials* request_metadata_creds, const char* target,
+ const grpc_channel_args* args);
/* For TESTING ONLY!
Creates a fake connector that emulates real server security. */
-grpc_server_security_connector *grpc_fake_server_security_connector_create(
- void);
+grpc_server_security_connector* grpc_fake_server_security_connector_create(
+ grpc_server_credentials* server_creds);
/* Config for ssl clients. */
typedef struct {
- tsi_ssl_pem_key_cert_pair pem_key_cert_pair;
- char *pem_root_certs;
+ tsi_ssl_pem_key_cert_pair* pem_key_cert_pair;
+ char* pem_root_certs;
} grpc_ssl_config;
/* Creates an SSL channel_security_connector.
@@ -207,21 +207,22 @@ typedef struct {
specific error code otherwise.
*/
grpc_security_status grpc_ssl_channel_security_connector_create(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *request_metadata_creds,
- const grpc_ssl_config *config, const char *target_name,
- const char *overridden_target_name, grpc_channel_security_connector **sc);
+ grpc_channel_credentials* channel_creds,
+ grpc_call_credentials* request_metadata_creds,
+ const grpc_ssl_config* config, const char* target_name,
+ const char* overridden_target_name, grpc_channel_security_connector** sc);
/* Gets the default ssl roots. Returns NULL if not found. */
-const char *grpc_get_default_ssl_roots(void);
+const char* grpc_get_default_ssl_roots(void);
/* Exposed for TESTING ONLY!. */
grpc_slice grpc_get_default_ssl_roots_for_testing(void);
/* Config for ssl servers. */
typedef struct {
- tsi_ssl_pem_key_cert_pair *pem_key_cert_pairs;
+ tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs;
size_t num_key_cert_pairs;
- char *pem_root_certs;
+ char* pem_root_certs;
grpc_ssl_client_certificate_request_type client_certificate_request;
} grpc_ssl_server_config;
@@ -232,17 +233,17 @@ typedef struct {
specific error code otherwise.
*/
grpc_security_status grpc_ssl_server_security_connector_create(
- grpc_exec_ctx *exec_ctx, const grpc_ssl_server_config *config,
- grpc_server_security_connector **sc);
+ grpc_server_credentials* server_credentials,
+ grpc_server_security_connector** sc);
/* Util. */
-const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer,
- const char *name);
+const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
+ const char* name);
/* Exposed for testing only. */
-grpc_auth_context *tsi_ssl_peer_to_auth_context(const tsi_peer *peer);
+grpc_auth_context* tsi_ssl_peer_to_auth_context(const tsi_peer* peer);
tsi_peer tsi_shallow_peer_from_ssl_auth_context(
- const grpc_auth_context *auth_context);
-void tsi_shallow_peer_destruct(tsi_peer *peer);
+ const grpc_auth_context* auth_context);
+void tsi_shallow_peer_destruct(tsi_peer* peer);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_CONNECTOR_H */
diff --git a/src/core/lib/security/transport/security_handshaker.c b/src/core/lib/security/transport/security_handshaker.cc
index 3d19605617..7623fbfd5b 100644
--- a/src/core/lib/security/transport/security_handshaker.c
+++ b/src/core/lib/security/transport/security_handshaker.cc
@@ -40,75 +40,90 @@ typedef struct {
grpc_handshaker base;
// State set at creation time.
- tsi_handshaker *handshaker;
- grpc_security_connector *connector;
+ tsi_handshaker* handshaker;
+ grpc_security_connector* connector;
gpr_mu mu;
gpr_refcount refs;
bool shutdown;
// Endpoint and read buffer to destroy after a shutdown.
- grpc_endpoint *endpoint_to_destroy;
- grpc_slice_buffer *read_buffer_to_destroy;
+ grpc_endpoint* endpoint_to_destroy;
+ grpc_slice_buffer* read_buffer_to_destroy;
// State saved while performing the handshake.
- grpc_handshaker_args *args;
- grpc_closure *on_handshake_done;
+ grpc_handshaker_args* args;
+ grpc_closure* on_handshake_done;
- unsigned char *handshake_buffer;
+ unsigned char* handshake_buffer;
size_t handshake_buffer_size;
grpc_slice_buffer outgoing;
grpc_closure on_handshake_data_sent_to_peer;
grpc_closure on_handshake_data_received_from_peer;
grpc_closure on_peer_checked;
- grpc_auth_context *auth_context;
- tsi_handshaker_result *handshaker_result;
+ grpc_auth_context* auth_context;
+ tsi_handshaker_result* handshaker_result;
} security_handshaker;
-static void security_handshaker_unref(grpc_exec_ctx *exec_ctx,
- security_handshaker *h) {
+static size_t move_read_buffer_into_handshake_buffer(security_handshaker* h) {
+ size_t bytes_in_read_buffer = h->args->read_buffer->length;
+ if (h->handshake_buffer_size < bytes_in_read_buffer) {
+ h->handshake_buffer =
+ (uint8_t*)gpr_realloc(h->handshake_buffer, bytes_in_read_buffer);
+ h->handshake_buffer_size = bytes_in_read_buffer;
+ }
+ size_t offset = 0;
+ while (h->args->read_buffer->count > 0) {
+ grpc_slice next_slice = grpc_slice_buffer_take_first(h->args->read_buffer);
+ memcpy(h->handshake_buffer + offset, GRPC_SLICE_START_PTR(next_slice),
+ GRPC_SLICE_LENGTH(next_slice));
+ offset += GRPC_SLICE_LENGTH(next_slice);
+ grpc_slice_unref_internal(next_slice);
+ }
+ return bytes_in_read_buffer;
+}
+
+static void security_handshaker_unref(security_handshaker* h) {
if (gpr_unref(&h->refs)) {
gpr_mu_destroy(&h->mu);
tsi_handshaker_destroy(h->handshaker);
tsi_handshaker_result_destroy(h->handshaker_result);
- if (h->endpoint_to_destroy != NULL) {
- grpc_endpoint_destroy(exec_ctx, h->endpoint_to_destroy);
+ if (h->endpoint_to_destroy != nullptr) {
+ grpc_endpoint_destroy(h->endpoint_to_destroy);
}
- if (h->read_buffer_to_destroy != NULL) {
- grpc_slice_buffer_destroy_internal(exec_ctx, h->read_buffer_to_destroy);
+ if (h->read_buffer_to_destroy != nullptr) {
+ grpc_slice_buffer_destroy_internal(h->read_buffer_to_destroy);
gpr_free(h->read_buffer_to_destroy);
}
gpr_free(h->handshake_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &h->outgoing);
+ grpc_slice_buffer_destroy_internal(&h->outgoing);
GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake");
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, h->connector, "handshake");
+ GRPC_SECURITY_CONNECTOR_UNREF(h->connector, "handshake");
gpr_free(h);
}
}
// Set args fields to NULL, saving the endpoint and read buffer for
// later destruction.
-static void cleanup_args_for_failure_locked(grpc_exec_ctx *exec_ctx,
- security_handshaker *h) {
+static void cleanup_args_for_failure_locked(security_handshaker* h) {
h->endpoint_to_destroy = h->args->endpoint;
- h->args->endpoint = NULL;
+ h->args->endpoint = nullptr;
h->read_buffer_to_destroy = h->args->read_buffer;
- h->args->read_buffer = NULL;
- grpc_channel_args_destroy(exec_ctx, h->args->args);
- h->args->args = NULL;
+ h->args->read_buffer = nullptr;
+ grpc_channel_args_destroy(h->args->args);
+ h->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
// callback with the error.
-static void security_handshake_failed_locked(grpc_exec_ctx *exec_ctx,
- security_handshaker *h,
- grpc_error *error) {
+static void security_handshake_failed_locked(security_handshaker* h,
+ grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
// If we were shut down after the handshake succeeded but before an
// endpoint callback was invoked, we need to generate our own error.
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshaker shutdown");
}
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "Security handshake failed: %s", msg);
if (!h->shutdown) {
@@ -116,93 +131,88 @@ static void security_handshake_failed_locked(grpc_exec_ctx *exec_ctx,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(error));
// Not shutting down, so the write failed. Clean up before
// invoking the callback.
- cleanup_args_for_failure_locked(exec_ctx, h);
+ cleanup_args_for_failure_locked(h);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
h->shutdown = true;
}
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(h->on_handshake_done, error);
}
-static void on_peer_checked_inner(grpc_exec_ctx *exec_ctx,
- security_handshaker *h, grpc_error *error) {
+static void on_peer_checked_inner(security_handshaker* h, grpc_error* error) {
if (error != GRPC_ERROR_NONE || h->shutdown) {
- security_handshake_failed_locked(exec_ctx, h, GRPC_ERROR_REF(error));
+ security_handshake_failed_locked(h, GRPC_ERROR_REF(error));
return;
}
// Create zero-copy frame protector, if implemented.
- tsi_zero_copy_grpc_protector *zero_copy_protector = NULL;
+ tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr;
tsi_result result = tsi_handshaker_result_create_zero_copy_grpc_protector(
- exec_ctx, h->handshaker_result, NULL, &zero_copy_protector);
+ h->handshaker_result, nullptr, &zero_copy_protector);
if (result != TSI_OK && result != TSI_UNIMPLEMENTED) {
error = grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Zero-copy frame protector creation failed"),
result);
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
return;
}
// Create frame protector if zero-copy frame protector is NULL.
- tsi_frame_protector *protector = NULL;
- if (zero_copy_protector == NULL) {
+ tsi_frame_protector* protector = nullptr;
+ if (zero_copy_protector == nullptr) {
result = tsi_handshaker_result_create_frame_protector(h->handshaker_result,
- NULL, &protector);
+ nullptr, &protector);
if (result != TSI_OK) {
error = grpc_set_tsi_error_result(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Frame protector creation failed"),
result);
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
return;
}
}
// Get unused bytes.
- const unsigned char *unused_bytes = NULL;
+ const unsigned char* unused_bytes = nullptr;
size_t unused_bytes_size = 0;
result = tsi_handshaker_result_get_unused_bytes(
h->handshaker_result, &unused_bytes, &unused_bytes_size);
// Create secure endpoint.
if (unused_bytes_size > 0) {
grpc_slice slice =
- grpc_slice_from_copied_buffer((char *)unused_bytes, unused_bytes_size);
+ grpc_slice_from_copied_buffer((char*)unused_bytes, unused_bytes_size);
h->args->endpoint = grpc_secure_endpoint_create(
protector, zero_copy_protector, h->args->endpoint, &slice, 1);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
} else {
h->args->endpoint = grpc_secure_endpoint_create(
- protector, zero_copy_protector, h->args->endpoint, NULL, 0);
+ protector, zero_copy_protector, h->args->endpoint, nullptr, 0);
}
tsi_handshaker_result_destroy(h->handshaker_result);
- h->handshaker_result = NULL;
- // Clear out the read buffer before it gets passed to the transport.
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, h->args->read_buffer);
+ h->handshaker_result = nullptr;
// Add auth context to channel args.
grpc_arg auth_context_arg = grpc_auth_context_to_arg(h->auth_context);
- grpc_channel_args *tmp_args = h->args->args;
+ grpc_channel_args* tmp_args = h->args->args;
h->args->args =
grpc_channel_args_copy_and_add(tmp_args, &auth_context_arg, 1);
- grpc_channel_args_destroy(exec_ctx, tmp_args);
+ grpc_channel_args_destroy(tmp_args);
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(h->on_handshake_done, GRPC_ERROR_NONE);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
h->shutdown = true;
}
-static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- security_handshaker *h = (security_handshaker *)arg;
+static void on_peer_checked(void* arg, grpc_error* error) {
+ security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
- on_peer_checked_inner(exec_ctx, h, error);
+ on_peer_checked_inner(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
}
-static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx,
- security_handshaker *h) {
+static grpc_error* check_peer_locked(security_handshaker* h) {
tsi_peer peer;
tsi_result result =
tsi_handshaker_result_extract_peer(h->handshaker_result, &peer);
@@ -210,20 +220,20 @@ static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx,
return grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result);
}
- grpc_security_connector_check_peer(exec_ctx, h->connector, peer,
- &h->auth_context, &h->on_peer_checked);
+ grpc_security_connector_check_peer(h->connector, peer, &h->auth_context,
+ &h->on_peer_checked);
return GRPC_ERROR_NONE;
}
-static grpc_error *on_handshake_next_done_locked(
- grpc_exec_ctx *exec_ctx, security_handshaker *h, tsi_result result,
- const unsigned char *bytes_to_send, size_t bytes_to_send_size,
- tsi_handshaker_result *handshaker_result) {
- grpc_error *error = GRPC_ERROR_NONE;
+static grpc_error* on_handshake_next_done_locked(
+ security_handshaker* h, tsi_result result,
+ const unsigned char* bytes_to_send, size_t bytes_to_send_size,
+ tsi_handshaker_result* handshaker_result) {
+ grpc_error* error = GRPC_ERROR_NONE;
// Read more if we need to.
if (result == TSI_INCOMPLETE_DATA) {
GPR_ASSERT(bytes_to_send_size == 0);
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
return error;
}
@@ -232,57 +242,55 @@ static grpc_error *on_handshake_next_done_locked(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
}
// Update handshaker result.
- if (handshaker_result != NULL) {
- GPR_ASSERT(h->handshaker_result == NULL);
+ if (handshaker_result != nullptr) {
+ GPR_ASSERT(h->handshaker_result == nullptr);
h->handshaker_result = handshaker_result;
}
if (bytes_to_send_size > 0) {
// Send data to peer, if needed.
grpc_slice to_send = grpc_slice_from_copied_buffer(
- (const char *)bytes_to_send, bytes_to_send_size);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &h->outgoing);
+ (const char*)bytes_to_send, bytes_to_send_size);
+ grpc_slice_buffer_reset_and_unref_internal(&h->outgoing);
grpc_slice_buffer_add(&h->outgoing, to_send);
- grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing,
+ grpc_endpoint_write(h->args->endpoint, &h->outgoing,
&h->on_handshake_data_sent_to_peer);
- } else if (handshaker_result == NULL) {
+ } else if (handshaker_result == nullptr) {
// There is nothing to send, but need to read from peer.
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
// Handshake has finished, check peer and so on.
- error = check_peer_locked(exec_ctx, h);
+ error = check_peer_locked(h);
}
return error;
}
static void on_handshake_next_done_grpc_wrapper(
- tsi_result result, void *user_data, const unsigned char *bytes_to_send,
- size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result) {
- security_handshaker *h = (security_handshaker *)user_data;
+ tsi_result result, void* user_data, const unsigned char* bytes_to_send,
+ size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
+ security_handshaker* h = (security_handshaker*)user_data;
// This callback will be invoked by TSI in a non-grpc thread, so it's
// safe to create our own exec_ctx here.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_mu_lock(&h->mu);
- grpc_error *error =
- on_handshake_next_done_locked(&exec_ctx, h, result, bytes_to_send,
- bytes_to_send_size, handshaker_result);
+ grpc_error* error = on_handshake_next_done_locked(
+ h, result, bytes_to_send, bytes_to_send_size, handshaker_result);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(&exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(&exec_ctx, h);
+ security_handshaker_unref(h);
} else {
gpr_mu_unlock(&h->mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
-static grpc_error *do_handshaker_next_locked(
- grpc_exec_ctx *exec_ctx, security_handshaker *h,
- const unsigned char *bytes_received, size_t bytes_received_size) {
+static grpc_error* do_handshaker_next_locked(
+ security_handshaker* h, const unsigned char* bytes_received,
+ size_t bytes_received_size) {
// Invoke TSI handshaker.
- const unsigned char *bytes_to_send = NULL;
+ const unsigned char* bytes_to_send = nullptr;
size_t bytes_to_send_size = 0;
- tsi_handshaker_result *handshaker_result = NULL;
+ tsi_handshaker_result* handshaker_result = nullptr;
tsi_result result = tsi_handshaker_next(
h->handshaker, bytes_received, bytes_received_size, &bytes_to_send,
&bytes_to_send_size, &handshaker_result,
@@ -294,75 +302,57 @@ static grpc_error *do_handshaker_next_locked(
}
// Handshaker returned synchronously. Invoke callback directly in
// this thread with our existing exec_ctx.
- return on_handshake_next_done_locked(exec_ctx, h, result, bytes_to_send,
+ return on_handshake_next_done_locked(h, result, bytes_to_send,
bytes_to_send_size, handshaker_result);
}
-static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
- void *arg, grpc_error *error) {
- security_handshaker *h = (security_handshaker *)arg;
+static void on_handshake_data_received_from_peer(void* arg, grpc_error* error) {
+ security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
security_handshake_failed_locked(
- exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Handshake read failed", &error, 1));
+ h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Handshake read failed", &error, 1));
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
// Copy all slices received.
- size_t i;
- size_t bytes_received_size = 0;
- for (i = 0; i < h->args->read_buffer->count; i++) {
- bytes_received_size += GRPC_SLICE_LENGTH(h->args->read_buffer->slices[i]);
- }
- if (bytes_received_size > h->handshake_buffer_size) {
- h->handshake_buffer =
- (uint8_t *)gpr_realloc(h->handshake_buffer, bytes_received_size);
- h->handshake_buffer_size = bytes_received_size;
- }
- size_t offset = 0;
- for (i = 0; i < h->args->read_buffer->count; i++) {
- size_t slice_size = GPR_SLICE_LENGTH(h->args->read_buffer->slices[i]);
- memcpy(h->handshake_buffer + offset,
- GRPC_SLICE_START_PTR(h->args->read_buffer->slices[i]), slice_size);
- offset += slice_size;
- }
+ size_t bytes_received_size = move_read_buffer_into_handshake_buffer(h);
// Call TSI handshaker.
- error = do_handshaker_next_locked(exec_ctx, h, h->handshake_buffer,
- bytes_received_size);
+ error =
+ do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
} else {
gpr_mu_unlock(&h->mu);
}
}
-static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- security_handshaker *h = (security_handshaker *)arg;
+static void on_handshake_data_sent_to_peer(void* arg, grpc_error* error) {
+ security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
security_handshake_failed_locked(
- exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Handshake write failed", &error, 1));
+ h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Handshake write failed", &error, 1));
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
// We may be done.
- if (h->handshaker_result == NULL) {
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ if (h->handshaker_result == nullptr) {
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
- error = check_peer_locked(exec_ctx, h);
+ error = check_peer_locked(h);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
}
@@ -373,41 +363,40 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg,
// public handshaker API
//
-static void security_handshaker_destroy(grpc_exec_ctx *exec_ctx,
- grpc_handshaker *handshaker) {
- security_handshaker *h = (security_handshaker *)handshaker;
- security_handshaker_unref(exec_ctx, h);
+static void security_handshaker_destroy(grpc_handshaker* handshaker) {
+ security_handshaker* h = (security_handshaker*)handshaker;
+ security_handshaker_unref(h);
}
-static void security_handshaker_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_handshaker *handshaker,
- grpc_error *why) {
- security_handshaker *h = (security_handshaker *)handshaker;
+static void security_handshaker_shutdown(grpc_handshaker* handshaker,
+ grpc_error* why) {
+ security_handshaker* h = (security_handshaker*)handshaker;
gpr_mu_lock(&h->mu);
if (!h->shutdown) {
h->shutdown = true;
- grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(why));
- cleanup_args_for_failure_locked(exec_ctx, h);
+ grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(why));
+ cleanup_args_for_failure_locked(h);
}
gpr_mu_unlock(&h->mu);
GRPC_ERROR_UNREF(why);
}
-static void security_handshaker_do_handshake(grpc_exec_ctx *exec_ctx,
- grpc_handshaker *handshaker,
- grpc_tcp_server_acceptor *acceptor,
- grpc_closure *on_handshake_done,
- grpc_handshaker_args *args) {
- security_handshaker *h = (security_handshaker *)handshaker;
+static void security_handshaker_do_handshake(grpc_handshaker* handshaker,
+ grpc_tcp_server_acceptor* acceptor,
+ grpc_closure* on_handshake_done,
+ grpc_handshaker_args* args) {
+ security_handshaker* h = (security_handshaker*)handshaker;
gpr_mu_lock(&h->mu);
h->args = args;
h->on_handshake_done = on_handshake_done;
gpr_ref(&h->refs);
- grpc_error *error = do_handshaker_next_locked(exec_ctx, h, NULL, 0);
+ size_t bytes_received_size = move_read_buffer_into_handshake_buffer(h);
+ grpc_error* error =
+ do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
gpr_mu_unlock(&h->mu);
@@ -417,18 +406,17 @@ static const grpc_handshaker_vtable security_handshaker_vtable = {
security_handshaker_destroy, security_handshaker_shutdown,
security_handshaker_do_handshake};
-static grpc_handshaker *security_handshaker_create(
- grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker,
- grpc_security_connector *connector) {
- security_handshaker *h =
- (security_handshaker *)gpr_zalloc(sizeof(security_handshaker));
+static grpc_handshaker* security_handshaker_create(
+ tsi_handshaker* handshaker, grpc_security_connector* connector) {
+ security_handshaker* h =
+ (security_handshaker*)gpr_zalloc(sizeof(security_handshaker));
grpc_handshaker_init(&security_handshaker_vtable, &h->base);
h->handshaker = handshaker;
h->connector = GRPC_SECURITY_CONNECTOR_REF(connector, "handshake");
gpr_mu_init(&h->mu);
gpr_ref_init(&h->refs, 1);
h->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE;
- h->handshake_buffer = (uint8_t *)gpr_malloc(h->handshake_buffer_size);
+ h->handshake_buffer = (uint8_t*)gpr_malloc(h->handshake_buffer_size);
GRPC_CLOSURE_INIT(&h->on_handshake_data_sent_to_peer,
on_handshake_data_sent_to_peer, h,
grpc_schedule_on_exec_ctx);
@@ -445,23 +433,20 @@ static grpc_handshaker *security_handshaker_create(
// fail_handshaker
//
-static void fail_handshaker_destroy(grpc_exec_ctx *exec_ctx,
- grpc_handshaker *handshaker) {
+static void fail_handshaker_destroy(grpc_handshaker* handshaker) {
gpr_free(handshaker);
}
-static void fail_handshaker_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_handshaker *handshaker,
- grpc_error *why) {
+static void fail_handshaker_shutdown(grpc_handshaker* handshaker,
+ grpc_error* why) {
GRPC_ERROR_UNREF(why);
}
-static void fail_handshaker_do_handshake(grpc_exec_ctx *exec_ctx,
- grpc_handshaker *handshaker,
- grpc_tcp_server_acceptor *acceptor,
- grpc_closure *on_handshake_done,
- grpc_handshaker_args *args) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_handshake_done,
+static void fail_handshaker_do_handshake(grpc_handshaker* handshaker,
+ grpc_tcp_server_acceptor* acceptor,
+ grpc_closure* on_handshake_done,
+ grpc_handshaker_args* args) {
+ GRPC_CLOSURE_SCHED(on_handshake_done,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create security handshaker"));
}
@@ -470,8 +455,8 @@ static const grpc_handshaker_vtable fail_handshaker_vtable = {
fail_handshaker_destroy, fail_handshaker_shutdown,
fail_handshaker_do_handshake};
-static grpc_handshaker *fail_handshaker_create() {
- grpc_handshaker *h = (grpc_handshaker *)gpr_malloc(sizeof(*h));
+static grpc_handshaker* fail_handshaker_create() {
+ grpc_handshaker* h = (grpc_handshaker*)gpr_malloc(sizeof(*h));
grpc_handshaker_init(&fail_handshaker_vtable, h);
return h;
}
@@ -481,27 +466,27 @@ static grpc_handshaker *fail_handshaker_create() {
//
static void client_handshaker_factory_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory,
- const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
- grpc_channel_security_connector *security_connector =
- (grpc_channel_security_connector *)grpc_security_connector_find_in_args(
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_channel_security_connector* security_connector =
+ (grpc_channel_security_connector*)grpc_security_connector_find_in_args(
args);
- grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector,
+ grpc_channel_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void server_handshaker_factory_add_handshakers(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *hf,
- const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) {
- grpc_server_security_connector *security_connector =
- (grpc_server_security_connector *)grpc_security_connector_find_in_args(
+ grpc_handshaker_factory* hf, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_server_security_connector* security_connector =
+ (grpc_server_security_connector*)grpc_security_connector_find_in_args(
args);
- grpc_server_security_connector_add_handshakers(exec_ctx, security_connector,
+ grpc_server_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void handshaker_factory_destroy(
- grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory) {}
+ grpc_handshaker_factory* handshaker_factory) {}
static const grpc_handshaker_factory_vtable client_handshaker_factory_vtable = {
client_handshaker_factory_add_handshakers, handshaker_factory_destroy};
@@ -519,15 +504,14 @@ static grpc_handshaker_factory server_handshaker_factory = {
// exported functions
//
-grpc_handshaker *grpc_security_handshaker_create(
- grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker,
- grpc_security_connector *connector) {
+grpc_handshaker* grpc_security_handshaker_create(
+ tsi_handshaker* handshaker, grpc_security_connector* connector) {
// If no TSI handshaker was created, return a handshaker that always fails.
// Otherwise, return a real security handshaker.
- if (handshaker == NULL) {
+ if (handshaker == nullptr) {
return fail_handshaker_create();
} else {
- return security_handshaker_create(exec_ctx, handshaker, connector);
+ return security_handshaker_create(handshaker, connector);
}
}
diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h
index 95bf127fc6..6cd6446b5a 100644
--- a/src/core/lib/security/transport/security_handshaker.h
+++ b/src/core/lib/security/transport/security_handshaker.h
@@ -24,9 +24,8 @@
#include "src/core/lib/security/transport/security_connector.h"
/// Creates a security handshaker using \a handshaker.
-grpc_handshaker *grpc_security_handshaker_create(
- grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker,
- grpc_security_connector *connector);
+grpc_handshaker* grpc_security_handshaker_create(
+ tsi_handshaker* handshaker, grpc_security_connector* connector);
/// Registers security handshaker factories.
void grpc_security_register_handshaker_factories();
diff --git a/src/core/lib/security/transport/server_auth_filter.c b/src/core/lib/security/transport/server_auth_filter.cc
index 7f523c0883..f82971dc56 100644
--- a/src/core/lib/security/transport/server_auth_filter.c
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -26,45 +26,47 @@
#include "src/core/lib/security/transport/auth_filters.h"
#include "src/core/lib/slice/slice_internal.h"
-typedef enum {
+namespace {
+enum async_state {
STATE_INIT = 0,
STATE_DONE,
STATE_CANCELLED,
-} async_state;
+};
-typedef struct call_data {
- grpc_call_combiner *call_combiner;
- grpc_call_stack *owning_call;
- grpc_transport_stream_op_batch *recv_initial_metadata_batch;
- grpc_closure *original_recv_initial_metadata_ready;
+struct call_data {
+ grpc_call_combiner* call_combiner;
+ grpc_call_stack* owning_call;
+ grpc_transport_stream_op_batch* recv_initial_metadata_batch;
+ grpc_closure* original_recv_initial_metadata_ready;
grpc_closure recv_initial_metadata_ready;
grpc_metadata_array md;
- const grpc_metadata *consumed_md;
+ const grpc_metadata* consumed_md;
size_t num_consumed_md;
- grpc_auth_context *auth_context;
+ grpc_auth_context* auth_context;
grpc_closure cancel_closure;
gpr_atm state; // async_state
-} call_data;
+};
-typedef struct channel_data {
- grpc_auth_context *auth_context;
- grpc_server_credentials *creds;
-} channel_data;
+struct channel_data {
+ grpc_auth_context* auth_context;
+ grpc_server_credentials* creds;
+};
+} // namespace
static grpc_metadata_array metadata_batch_to_md_array(
- const grpc_metadata_batch *batch) {
- grpc_linked_mdelem *l;
+ const grpc_metadata_batch* batch) {
+ grpc_linked_mdelem* l;
grpc_metadata_array result;
grpc_metadata_array_init(&result);
- for (l = batch->list.head; l != NULL; l = l->next) {
- grpc_metadata *usr_md = NULL;
+ for (l = batch->list.head; l != nullptr; l = l->next) {
+ grpc_metadata* usr_md = nullptr;
grpc_mdelem md = l->md;
grpc_slice key = GRPC_MDKEY(md);
grpc_slice value = GRPC_MDVALUE(md);
if (result.count == result.capacity) {
result.capacity = GPR_MAX(result.capacity + 8, result.capacity * 2);
- result.metadata =
- gpr_realloc(result.metadata, result.capacity * sizeof(grpc_metadata));
+ result.metadata = (grpc_metadata*)gpr_realloc(
+ result.metadata, result.capacity * sizeof(grpc_metadata));
}
usr_md = &result.metadata[result.count++];
usr_md->key = grpc_slice_ref_internal(key);
@@ -73,14 +75,13 @@ static grpc_metadata_array metadata_batch_to_md_array(
return result;
}
-static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx,
- void *user_data,
+static grpc_filtered_mdelem remove_consumed_md(void* user_data,
grpc_mdelem md) {
- grpc_call_element *elem = user_data;
- call_data *calld = elem->call_data;
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
size_t i;
for (i = 0; i < calld->num_consumed_md; i++) {
- const grpc_metadata *consumed_md = &calld->consumed_md[i];
+ const grpc_metadata* consumed_md = &calld->consumed_md[i];
if (grpc_slice_eq(GRPC_MDKEY(md), consumed_md->key) &&
grpc_slice_eq(GRPC_MDVALUE(md), consumed_md->value))
return GRPC_FILTERED_REMOVE();
@@ -88,17 +89,16 @@ static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx,
return GRPC_FILTERED_MDELEM(md);
}
-static void on_md_processing_done_inner(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_metadata *consumed_md,
+static void on_md_processing_done_inner(grpc_call_element* elem,
+ const grpc_metadata* consumed_md,
size_t num_consumed_md,
- const grpc_metadata *response_md,
+ const grpc_metadata* response_md,
size_t num_response_md,
- grpc_error *error) {
- call_data *calld = elem->call_data;
- grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch;
+ grpc_error* error) {
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_transport_stream_op_batch* batch = calld->recv_initial_metadata_batch;
/* TODO(jboeuf): Implement support for response_md. */
- if (response_md != NULL && num_response_md > 0) {
+ if (response_md != nullptr && num_response_md > 0) {
gpr_log(GPR_INFO,
"response_md in auth metadata processing not supported for now. "
"Ignoring...");
@@ -107,73 +107,70 @@ static void on_md_processing_done_inner(grpc_exec_ctx *exec_ctx,
calld->consumed_md = consumed_md;
calld->num_consumed_md = num_consumed_md;
error = grpc_metadata_batch_filter(
- exec_ctx, batch->payload->recv_initial_metadata.recv_initial_metadata,
+ batch->payload->recv_initial_metadata.recv_initial_metadata,
remove_consumed_md, elem, "Response metadata filtering error");
}
- GRPC_CLOSURE_SCHED(exec_ctx, calld->original_recv_initial_metadata_ready,
- error);
+ GRPC_CLOSURE_SCHED(calld->original_recv_initial_metadata_ready, error);
}
// Called from application code.
static void on_md_processing_done(
- void *user_data, const grpc_metadata *consumed_md, size_t num_consumed_md,
- const grpc_metadata *response_md, size_t num_response_md,
- grpc_status_code status, const char *error_details) {
- grpc_call_element *elem = user_data;
- call_data *calld = elem->call_data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ void* user_data, const grpc_metadata* consumed_md, size_t num_consumed_md,
+ const grpc_metadata* response_md, size_t num_response_md,
+ grpc_status_code status, const char* error_details) {
+ grpc_call_element* elem = (grpc_call_element*)user_data;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_core::ExecCtx exec_ctx;
// If the call was not cancelled while we were in flight, process the result.
if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
(gpr_atm)STATE_DONE)) {
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (status != GRPC_STATUS_OK) {
- if (error_details == NULL) {
+ if (error_details == nullptr) {
error_details = "Authentication metadata processing failed.";
}
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
GRPC_ERROR_INT_GRPC_STATUS, status);
}
- on_md_processing_done_inner(&exec_ctx, elem, consumed_md, num_consumed_md,
- response_md, num_response_md, error);
+ on_md_processing_done_inner(elem, consumed_md, num_consumed_md, response_md,
+ num_response_md, error);
}
// Clean up.
for (size_t i = 0; i < calld->md.count; i++) {
- grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].key);
- grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].value);
+ grpc_slice_unref_internal(calld->md.metadata[i].key);
+ grpc_slice_unref_internal(calld->md.metadata[i].value);
}
grpc_metadata_array_destroy(&calld->md);
- GRPC_CALL_STACK_UNREF(&exec_ctx, calld->owning_call, "server_auth_metadata");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "server_auth_metadata");
}
-static void cancel_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = elem->call_data;
+static void cancel_call(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
// If the result was not already processed, invoke the callback now.
if (error != GRPC_ERROR_NONE &&
gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
(gpr_atm)STATE_CANCELLED)) {
- on_md_processing_done_inner(exec_ctx, elem, NULL, 0, NULL, 0,
+ on_md_processing_done_inner(elem, nullptr, 0, nullptr, 0,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_call");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_call");
}
-static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- channel_data *chand = elem->channel_data;
- call_data *calld = elem->call_data;
- grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch;
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_transport_stream_op_batch* batch = calld->recv_initial_metadata_batch;
if (error == GRPC_ERROR_NONE) {
- if (chand->creds != NULL && chand->creds->processor.process != NULL) {
+ if (chand->creds != nullptr && chand->creds->processor.process != nullptr) {
// We're calling out to the application, so we need to make sure
// to drop the call combiner early if we get cancelled.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_call");
GRPC_CLOSURE_INIT(&calld->cancel_closure, cancel_call, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_combiner_set_notify_on_cancel(exec_ctx, calld->call_combiner,
+ grpc_call_combiner_set_notify_on_cancel(calld->call_combiner,
&calld->cancel_closure);
GRPC_CALL_STACK_REF(calld->owning_call, "server_auth_metadata");
calld->md = metadata_batch_to_md_array(
@@ -184,14 +181,13 @@ static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
return;
}
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
static void auth_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *batch) {
- call_data *calld = elem->call_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
+ call_data* calld = (call_data*)elem->call_data;
if (batch->recv_initial_metadata) {
// Inject our callback.
calld->recv_initial_metadata_batch = batch;
@@ -200,15 +196,14 @@ static void auth_start_transport_stream_op_batch(
batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
&calld->recv_initial_metadata_ready;
}
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
/* Constructor for call_data */
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = elem->call_data;
- channel_data *chand = elem->channel_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
calld->call_combiner = args->call_combiner;
calld->owning_call = args->call_stack;
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
@@ -216,11 +211,11 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_schedule_on_exec_ctx);
// Create server security context. Set its auth context from channel
// data and save it in the call context.
- grpc_server_security_context *server_ctx =
+ grpc_server_security_context* server_ctx =
grpc_server_security_context_create();
server_ctx->auth_context = grpc_auth_context_create(chand->auth_context);
calld->auth_context = server_ctx->auth_context;
- if (args->context[GRPC_CONTEXT_SECURITY].value != NULL) {
+ if (args->context[GRPC_CONTEXT_SECURITY].value != nullptr) {
args->context[GRPC_CONTEXT_SECURITY].destroy(
args->context[GRPC_CONTEXT_SECURITY].value);
}
@@ -231,33 +226,31 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {}
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {}
/* Constructor for channel_data */
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
- channel_data *chand = elem->channel_data;
- grpc_auth_context *auth_context =
+ channel_data* chand = (channel_data*)elem->channel_data;
+ grpc_auth_context* auth_context =
grpc_find_auth_context_in_args(args->channel_args);
- GPR_ASSERT(auth_context != NULL);
+ GPR_ASSERT(auth_context != nullptr);
chand->auth_context =
GRPC_AUTH_CONTEXT_REF(auth_context, "server_auth_filter");
- grpc_server_credentials *creds =
+ grpc_server_credentials* creds =
grpc_find_server_credentials_in_args(args->channel_args);
chand->creds = grpc_server_credentials_ref(creds);
return GRPC_ERROR_NONE;
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
- channel_data *chand = elem->channel_data;
+static void destroy_channel_elem(grpc_channel_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "server_auth_filter");
- grpc_server_credentials_unref(exec_ctx, chand->creds);
+ grpc_server_credentials_unref(chand->creds);
}
const grpc_channel_filter grpc_server_auth_filter = {
diff --git a/src/core/lib/security/transport/tsi_error.c b/src/core/lib/security/transport/tsi_error.cc
index 72f9600e84..f71696d35d 100644
--- a/src/core/lib/security/transport/tsi_error.c
+++ b/src/core/lib/security/transport/tsi_error.cc
@@ -18,7 +18,7 @@
#include "src/core/lib/security/transport/tsi_error.h"
-grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result) {
+grpc_error* grpc_set_tsi_error_result(grpc_error* error, tsi_result result) {
return grpc_error_set_int(
grpc_error_set_str(
error, GRPC_ERROR_STR_TSI_ERROR,
diff --git a/src/core/lib/security/transport/tsi_error.h b/src/core/lib/security/transport/tsi_error.h
index 87a63a8a7c..8fa6c480ac 100644
--- a/src/core/lib/security/transport/tsi_error.h
+++ b/src/core/lib/security/transport/tsi_error.h
@@ -22,6 +22,6 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/tsi/transport_security_interface.h"
-grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result);
+grpc_error* grpc_set_tsi_error_result(grpc_error* error, tsi_result result);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */
diff --git a/src/core/lib/security/util/json_util.c b/src/core/lib/security/util/json_util.cc
index d847addef9..fef1a1f51d 100644
--- a/src/core/lib/security/util/json_util.c
+++ b/src/core/lib/security/util/json_util.cc
@@ -23,24 +23,24 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-const char *grpc_json_get_string_property(const grpc_json *json,
- const char *prop_name) {
- grpc_json *child;
- for (child = json->child; child != NULL; child = child->next) {
+const char* grpc_json_get_string_property(const grpc_json* json,
+ const char* prop_name) {
+ grpc_json* child;
+ for (child = json->child; child != nullptr; child = child->next) {
if (strcmp(child->key, prop_name) == 0) break;
}
- if (child == NULL || child->type != GRPC_JSON_STRING) {
+ if (child == nullptr || child->type != GRPC_JSON_STRING) {
gpr_log(GPR_ERROR, "Invalid or missing %s property.", prop_name);
- return NULL;
+ return nullptr;
}
return child->value;
}
-bool grpc_copy_json_string_property(const grpc_json *json,
- const char *prop_name,
- char **copied_value) {
- const char *prop_value = grpc_json_get_string_property(json, prop_name);
- if (prop_value == NULL) return false;
+bool grpc_copy_json_string_property(const grpc_json* json,
+ const char* prop_name,
+ char** copied_value) {
+ const char* prop_value = grpc_json_get_string_property(json, prop_name);
+ if (prop_value == nullptr) return false;
*copied_value = gpr_strdup(prop_value);
return true;
}
diff --git a/src/core/lib/security/util/json_util.h b/src/core/lib/security/util/json_util.h
index 5ea831e27e..b7e46d4062 100644
--- a/src/core/lib/security/util/json_util.h
+++ b/src/core/lib/security/util/json_util.h
@@ -29,12 +29,12 @@
#define GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER "authorized_user"
// Gets a child property from a json node.
-const char *grpc_json_get_string_property(const grpc_json *json,
- const char *prop_name);
+const char* grpc_json_get_string_property(const grpc_json* json,
+ const char* prop_name);
// Copies the value of the json child property specified by prop_name.
// Returns false if the property was not found.
-bool grpc_copy_json_string_property(const grpc_json *json,
- const char *prop_name, char **copied_value);
+bool grpc_copy_json_string_property(const grpc_json* json,
+ const char* prop_name, char** copied_value);
#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */
diff --git a/src/core/lib/slice/b64.c b/src/core/lib/slice/b64.cc
index 50264719a4..f36b13ef1b 100644
--- a/src/core/lib/slice/b64.c
+++ b/src/core/lib/slice/b64.cc
@@ -54,11 +54,11 @@ static const char base64_url_safe_chars[] =
/* --- base64 functions. --- */
-char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
+char* grpc_base64_encode(const void* vdata, size_t data_size, int url_safe,
int multiline) {
size_t result_projected_size =
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
- char *result = (char *)gpr_malloc(result_projected_size);
+ char* result = (char*)gpr_malloc(result_projected_size);
grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline);
return result;
}
@@ -73,15 +73,15 @@ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
return result_projected_size;
}
-void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
+void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
int url_safe, int multiline) {
- const unsigned char *data = (const unsigned char *)vdata;
- const char *base64_chars =
+ const unsigned char* data = (const unsigned char*)vdata;
+ const char* base64_chars =
url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
const size_t result_projected_size =
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
- char *current = result;
+ char* current = result;
size_t num_blocks = 0;
size_t i = 0;
@@ -122,27 +122,26 @@ void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
result[current - result] = '\0';
}
-grpc_slice grpc_base64_decode(grpc_exec_ctx *exec_ctx, const char *b64,
- int url_safe) {
- return grpc_base64_decode_with_len(exec_ctx, b64, strlen(b64), url_safe);
+grpc_slice grpc_base64_decode(const char* b64, int url_safe) {
+ return grpc_base64_decode_with_len(b64, strlen(b64), url_safe);
}
-static void decode_one_char(const unsigned char *codes, unsigned char *result,
- size_t *result_offset) {
+static void decode_one_char(const unsigned char* codes, unsigned char* result,
+ size_t* result_offset) {
uint32_t packed = ((uint32_t)codes[0] << 2) | ((uint32_t)codes[1] >> 4);
result[(*result_offset)++] = (unsigned char)packed;
}
-static void decode_two_chars(const unsigned char *codes, unsigned char *result,
- size_t *result_offset) {
+static void decode_two_chars(const unsigned char* codes, unsigned char* result,
+ size_t* result_offset) {
uint32_t packed = ((uint32_t)codes[0] << 10) | ((uint32_t)codes[1] << 4) |
((uint32_t)codes[2] >> 2);
result[(*result_offset)++] = (unsigned char)(packed >> 8);
result[(*result_offset)++] = (unsigned char)(packed);
}
-static int decode_group(const unsigned char *codes, size_t num_codes,
- unsigned char *result, size_t *result_offset) {
+static int decode_group(const unsigned char* codes, size_t num_codes,
+ unsigned char* result, size_t* result_offset) {
GPR_ASSERT(num_codes <= 4);
/* Short end groups that may not have padding. */
@@ -185,10 +184,10 @@ static int decode_group(const unsigned char *codes, size_t num_codes,
return 1;
}
-grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64,
- size_t b64_len, int url_safe) {
+grpc_slice grpc_base64_decode_with_len(const char* b64, size_t b64_len,
+ int url_safe) {
grpc_slice result = GRPC_SLICE_MALLOC(b64_len);
- unsigned char *current = GRPC_SLICE_START_PTR(result);
+ unsigned char* current = GRPC_SLICE_START_PTR(result);
size_t result_size = 0;
unsigned char codes[4];
size_t num_codes = 0;
@@ -231,6 +230,6 @@ grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64,
return result;
fail:
- grpc_slice_unref_internal(exec_ctx, result);
+ grpc_slice_unref_internal(result);
return grpc_empty_slice();
}
diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h
index 3fd15febe5..17e7306303 100644
--- a/src/core/lib/slice/b64.h
+++ b/src/core/lib/slice/b64.h
@@ -24,7 +24,7 @@
/* Encodes data using base64. It is the caller's responsability to free
the returned char * using gpr_free. Returns NULL on NULL input.
TODO(makdharma) : change the flags to bool from int */
-char *grpc_base64_encode(const void *data, size_t data_size, int url_safe,
+char* grpc_base64_encode(const void* data, size_t data_size, int url_safe,
int multiline);
/* estimate the upper bound on size of base64 encoded data. The actual size
@@ -35,16 +35,15 @@ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
/* Encodes data using base64 and write it to memory pointed to by result. It is
* the caller's responsiblity to allocate enough memory in |result| to fit the
* encoded data. */
-void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
+void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
int url_safe, int multiline);
/* Decodes data according to the base64 specification. Returns an empty
slice in case of failure. */
-grpc_slice grpc_base64_decode(grpc_exec_ctx *exec_ctx, const char *b64,
- int url_safe);
+grpc_slice grpc_base64_decode(const char* b64, int url_safe);
/* Same as above except that the length is provided by the caller. */
-grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64,
- size_t b64_len, int url_safe);
+grpc_slice grpc_base64_decode_with_len(const char* b64, size_t b64_len,
+ int url_safe);
#endif /* GRPC_CORE_LIB_SLICE_B64_H */
diff --git a/src/core/lib/slice/percent_encoding.c b/src/core/lib/slice/percent_encoding.cc
index effc8d7ad6..894e43b191 100644
--- a/src/core/lib/slice/percent_encoding.c
+++ b/src/core/lib/slice/percent_encoding.cc
@@ -32,19 +32,19 @@ const uint8_t grpc_compatible_percent_encoding_unreserved_bytes[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static bool is_unreserved_character(uint8_t c,
- const uint8_t *unreserved_bytes) {
+ const uint8_t* unreserved_bytes) {
return ((unreserved_bytes[c / 8] >> (c % 8)) & 1) != 0;
}
grpc_slice grpc_percent_encode_slice(grpc_slice slice,
- const uint8_t *unreserved_bytes) {
+ const uint8_t* unreserved_bytes) {
static const uint8_t hex[] = "0123456789ABCDEF";
// first pass: count the number of bytes needed to output this string
size_t output_length = 0;
- const uint8_t *slice_start = GRPC_SLICE_START_PTR(slice);
- const uint8_t *slice_end = GRPC_SLICE_END_PTR(slice);
- const uint8_t *p;
+ const uint8_t* slice_start = GRPC_SLICE_START_PTR(slice);
+ const uint8_t* slice_end = GRPC_SLICE_END_PTR(slice);
+ const uint8_t* p;
bool any_reserved_bytes = false;
for (p = slice_start; p < slice_end; p++) {
bool unres = is_unreserved_character(*p, unreserved_bytes);
@@ -57,7 +57,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
}
// second pass: actually encode
grpc_slice out = GRPC_SLICE_MALLOC(output_length);
- uint8_t *q = GRPC_SLICE_START_PTR(out);
+ uint8_t* q = GRPC_SLICE_START_PTR(out);
for (p = slice_start; p < slice_end; p++) {
if (is_unreserved_character(*p, unreserved_bytes)) {
*q++ = *p;
@@ -71,7 +71,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
return out;
}
-static bool valid_hex(const uint8_t *p, const uint8_t *end) {
+static bool valid_hex(const uint8_t* p, const uint8_t* end) {
if (p >= end) return false;
return (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') ||
(*p >= 'A' && *p <= 'F');
@@ -85,10 +85,10 @@ static uint8_t dehex(uint8_t c) {
}
bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
- const uint8_t *unreserved_bytes,
- grpc_slice *slice_out) {
- const uint8_t *p = GRPC_SLICE_START_PTR(slice_in);
- const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in);
+ const uint8_t* unreserved_bytes,
+ grpc_slice* slice_out) {
+ const uint8_t* p = GRPC_SLICE_START_PTR(slice_in);
+ const uint8_t* in_end = GRPC_SLICE_END_PTR(slice_in);
size_t out_length = 0;
bool any_percent_encoded_stuff = false;
while (p != in_end) {
@@ -111,7 +111,7 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
}
p = GRPC_SLICE_START_PTR(slice_in);
*slice_out = GRPC_SLICE_MALLOC(out_length);
- uint8_t *q = GRPC_SLICE_START_PTR(*slice_out);
+ uint8_t* q = GRPC_SLICE_START_PTR(*slice_out);
while (p != in_end) {
if (*p == '%') {
*q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2]));
@@ -125,8 +125,8 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
}
grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
- const uint8_t *p = GRPC_SLICE_START_PTR(slice_in);
- const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in);
+ const uint8_t* p = GRPC_SLICE_START_PTR(slice_in);
+ const uint8_t* in_end = GRPC_SLICE_END_PTR(slice_in);
size_t out_length = 0;
bool any_percent_encoded_stuff = false;
while (p != in_end) {
@@ -149,7 +149,7 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
}
p = GRPC_SLICE_START_PTR(slice_in);
grpc_slice out = GRPC_SLICE_MALLOC(out_length);
- uint8_t *q = GRPC_SLICE_START_PTR(out);
+ uint8_t* q = GRPC_SLICE_START_PTR(out);
while (p != in_end) {
if (*p == '%') {
if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) {
diff --git a/src/core/lib/slice/percent_encoding.h b/src/core/lib/slice/percent_encoding.h
index faae26a683..a1009ff01f 100644
--- a/src/core/lib/slice/percent_encoding.h
+++ b/src/core/lib/slice/percent_encoding.h
@@ -45,7 +45,7 @@ extern const uint8_t grpc_compatible_percent_encoding_unreserved_bytes[256 / 8];
unreserved_bytes is a bitfield indicating which bytes are considered
unreserved and thus do not need percent encoding */
grpc_slice grpc_percent_encode_slice(grpc_slice slice,
- const uint8_t *unreserved_bytes);
+ const uint8_t* unreserved_bytes);
/* Percent-decode a slice, strictly.
If the input is legal (contains no unreserved bytes, and legal % encodings),
returns true and sets *slice_out to the decoded slice.
@@ -53,8 +53,8 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
unreserved_bytes is a bitfield indicating which bytes are considered
unreserved and thus do not need percent encoding */
bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
- const uint8_t *unreserved_bytes,
- grpc_slice *slice_out);
+ const uint8_t* unreserved_bytes,
+ grpc_slice* slice_out);
/* Percent-decode a slice, permissively.
If a % triplet can not be decoded, pass it through verbatim.
This cannot fail. */
diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.cc
index 0764eda052..1eb15290eb 100644
--- a/src/core/lib/slice/slice.c
+++ b/src/core/lib/slice/slice.cc
@@ -26,8 +26,8 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-char *grpc_slice_to_c_string(grpc_slice slice) {
- char *out = (char *)gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
+char* grpc_slice_to_c_string(grpc_slice slice) {
+ char* out = (char*)gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
memcpy(out, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice));
out[GRPC_SLICE_LENGTH(slice)] = 0;
return out;
@@ -35,7 +35,7 @@ char *grpc_slice_to_c_string(grpc_slice slice) {
grpc_slice grpc_empty_slice(void) {
grpc_slice out;
- out.refcount = NULL;
+ out.refcount = nullptr;
out.data.inlined.length = 0;
return out;
}
@@ -54,9 +54,9 @@ grpc_slice grpc_slice_ref_internal(grpc_slice slice) {
return slice;
}
-void grpc_slice_unref_internal(grpc_exec_ctx *exec_ctx, grpc_slice slice) {
+void grpc_slice_unref_internal(grpc_slice slice) {
if (slice.refcount) {
- slice.refcount->vtable->unref(exec_ctx, slice.refcount);
+ slice.refcount->vtable->unref(slice.refcount);
}
}
@@ -67,15 +67,14 @@ grpc_slice grpc_slice_ref(grpc_slice slice) {
/* Public API */
void grpc_slice_unref(grpc_slice slice) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, slice);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_unref_internal(slice);
}
/* grpc_slice_from_static_string support structure - a refcount that does
nothing */
-static void noop_ref(void *unused) {}
-static void noop_unref(grpc_exec_ctx *exec_ctx, void *unused) {}
+static void noop_ref(void* unused) {}
+static void noop_unref(void* unused) {}
static const grpc_slice_refcount_vtable noop_refcount_vtable = {
noop_ref, noop_unref, grpc_slice_default_eq_impl,
@@ -83,15 +82,15 @@ static const grpc_slice_refcount_vtable noop_refcount_vtable = {
static grpc_slice_refcount noop_refcount = {&noop_refcount_vtable,
&noop_refcount};
-grpc_slice grpc_slice_from_static_buffer(const void *s, size_t len) {
+grpc_slice grpc_slice_from_static_buffer(const void* s, size_t len) {
grpc_slice slice;
slice.refcount = &noop_refcount;
- slice.data.refcounted.bytes = (uint8_t *)s;
+ slice.data.refcounted.bytes = (uint8_t*)s;
slice.data.refcounted.length = len;
return slice;
}
-grpc_slice grpc_slice_from_static_string(const char *s) {
+grpc_slice grpc_slice_from_static_string(const char* s) {
return grpc_slice_from_static_buffer(s, strlen(s));
}
@@ -100,17 +99,17 @@ grpc_slice grpc_slice_from_static_string(const char *s) {
typedef struct new_slice_refcount {
grpc_slice_refcount rc;
gpr_refcount refs;
- void (*user_destroy)(void *);
- void *user_data;
+ void (*user_destroy)(void*);
+ void* user_data;
} new_slice_refcount;
-static void new_slice_ref(void *p) {
- new_slice_refcount *r = (new_slice_refcount *)p;
+static void new_slice_ref(void* p) {
+ new_slice_refcount* r = (new_slice_refcount*)p;
gpr_ref(&r->refs);
}
-static void new_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
- new_slice_refcount *r = (new_slice_refcount *)p;
+static void new_slice_unref(void* p) {
+ new_slice_refcount* r = (new_slice_refcount*)p;
if (gpr_unref(&r->refs)) {
r->user_destroy(r->user_data);
gpr_free(r);
@@ -121,12 +120,12 @@ static const grpc_slice_refcount_vtable new_slice_vtable = {
new_slice_ref, new_slice_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
-grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
- void (*destroy)(void *),
- void *user_data) {
+grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
+ void (*destroy)(void*),
+ void* user_data) {
grpc_slice slice;
- new_slice_refcount *rc =
- (new_slice_refcount *)gpr_malloc(sizeof(new_slice_refcount));
+ new_slice_refcount* rc =
+ (new_slice_refcount*)gpr_malloc(sizeof(new_slice_refcount));
gpr_ref_init(&rc->refs, 1);
rc->rc.vtable = &new_slice_vtable;
rc->rc.sub_refcount = &rc->rc;
@@ -134,12 +133,12 @@ grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
rc->user_data = user_data;
slice.refcount = &rc->rc;
- slice.data.refcounted.bytes = (uint8_t *)p;
+ slice.data.refcounted.bytes = (uint8_t*)p;
slice.data.refcounted.length = len;
return slice;
}
-grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) {
+grpc_slice grpc_slice_new(void* p, size_t len, void (*destroy)(void*)) {
/* Pass "p" to *destroy when the slice is no longer needed. */
return grpc_slice_new_with_user_data(p, len, destroy, p);
}
@@ -149,18 +148,18 @@ grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) {
typedef struct new_with_len_slice_refcount {
grpc_slice_refcount rc;
gpr_refcount refs;
- void *user_data;
+ void* user_data;
size_t user_length;
- void (*user_destroy)(void *, size_t);
+ void (*user_destroy)(void*, size_t);
} new_with_len_slice_refcount;
-static void new_with_len_ref(void *p) {
- new_with_len_slice_refcount *r = (new_with_len_slice_refcount *)p;
+static void new_with_len_ref(void* p) {
+ new_with_len_slice_refcount* r = (new_with_len_slice_refcount*)p;
gpr_ref(&r->refs);
}
-static void new_with_len_unref(grpc_exec_ctx *exec_ctx, void *p) {
- new_with_len_slice_refcount *r = (new_with_len_slice_refcount *)p;
+static void new_with_len_unref(void* p) {
+ new_with_len_slice_refcount* r = (new_with_len_slice_refcount*)p;
if (gpr_unref(&r->refs)) {
r->user_destroy(r->user_data, r->user_length);
gpr_free(r);
@@ -171,10 +170,10 @@ static const grpc_slice_refcount_vtable new_with_len_vtable = {
new_with_len_ref, new_with_len_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
-grpc_slice grpc_slice_new_with_len(void *p, size_t len,
- void (*destroy)(void *, size_t)) {
+grpc_slice grpc_slice_new_with_len(void* p, size_t len,
+ void (*destroy)(void*, size_t)) {
grpc_slice slice;
- new_with_len_slice_refcount *rc = (new_with_len_slice_refcount *)gpr_malloc(
+ new_with_len_slice_refcount* rc = (new_with_len_slice_refcount*)gpr_malloc(
sizeof(new_with_len_slice_refcount));
gpr_ref_init(&rc->refs, 1);
rc->rc.vtable = &new_with_len_vtable;
@@ -184,19 +183,19 @@ grpc_slice grpc_slice_new_with_len(void *p, size_t len,
rc->user_length = len;
slice.refcount = &rc->rc;
- slice.data.refcounted.bytes = (uint8_t *)p;
+ slice.data.refcounted.bytes = (uint8_t*)p;
slice.data.refcounted.length = len;
return slice;
}
-grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t length) {
+grpc_slice grpc_slice_from_copied_buffer(const char* source, size_t length) {
if (length == 0) return grpc_empty_slice();
grpc_slice slice = GRPC_SLICE_MALLOC(length);
memcpy(GRPC_SLICE_START_PTR(slice), source, length);
return slice;
}
-grpc_slice grpc_slice_from_copied_string(const char *source) {
+grpc_slice grpc_slice_from_copied_string(const char* source) {
return grpc_slice_from_copied_buffer(source, strlen(source));
}
@@ -205,13 +204,13 @@ typedef struct {
gpr_refcount refs;
} malloc_refcount;
-static void malloc_ref(void *p) {
- malloc_refcount *r = (malloc_refcount *)p;
+static void malloc_ref(void* p) {
+ malloc_refcount* r = (malloc_refcount*)p;
gpr_ref(&r->refs);
}
-static void malloc_unref(grpc_exec_ctx *exec_ctx, void *p) {
- malloc_refcount *r = (malloc_refcount *)p;
+static void malloc_unref(void* p) {
+ malloc_refcount* r = (malloc_refcount*)p;
if (gpr_unref(&r->refs)) {
gpr_free(r);
}
@@ -233,8 +232,8 @@ grpc_slice grpc_slice_malloc_large(size_t length) {
refcount is a malloc_refcount
bytes is an array of bytes of the requested length
Both parts are placed in the same allocation returned from gpr_malloc */
- malloc_refcount *rc =
- (malloc_refcount *)gpr_malloc(sizeof(malloc_refcount) + length);
+ malloc_refcount* rc =
+ (malloc_refcount*)gpr_malloc(sizeof(malloc_refcount) + length);
/* Initial refcount on rc is 1 - and it's up to the caller to release
this reference. */
@@ -247,7 +246,7 @@ grpc_slice grpc_slice_malloc_large(size_t length) {
/* The slices refcount points back to the allocated block. */
slice.refcount = &rc->base;
/* The data bytes are placed immediately after the refcount struct */
- slice.data.refcounted.bytes = (uint8_t *)(rc + 1);
+ slice.data.refcounted.bytes = (uint8_t*)(rc + 1);
/* And the length of the block is set to the requested length */
slice.data.refcounted.length = length;
return slice;
@@ -260,7 +259,7 @@ grpc_slice grpc_slice_malloc(size_t length) {
return grpc_slice_malloc_large(length);
} else {
/* small slice: just inline the data */
- slice.refcount = NULL;
+ slice.refcount = nullptr;
slice.data.inlined.length = (uint8_t)length;
}
return slice;
@@ -283,7 +282,7 @@ grpc_slice grpc_slice_sub_no_ref(grpc_slice source, size_t begin, size_t end) {
} else {
/* Enforce preconditions */
GPR_ASSERT(source.data.inlined.length >= end);
- subset.refcount = NULL;
+ subset.refcount = nullptr;
subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin,
end - begin);
@@ -295,7 +294,7 @@ grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) {
grpc_slice subset;
if (end - begin <= sizeof(subset.data.inlined.bytes)) {
- subset.refcount = NULL;
+ subset.refcount = nullptr;
subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, GRPC_SLICE_START_PTR(source) + begin,
end - begin);
@@ -307,14 +306,14 @@ grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) {
return subset;
}
-grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *source, size_t split,
+grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* source, size_t split,
grpc_slice_ref_whom ref_whom) {
grpc_slice tail;
- if (source->refcount == NULL) {
+ if (source->refcount == nullptr) {
/* inlined data, copy it out */
GPR_ASSERT(source->data.inlined.length >= split);
- tail.refcount = NULL;
+ tail.refcount = nullptr;
tail.data.inlined.length = (uint8_t)(source->data.inlined.length - split);
memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split,
tail.data.inlined.length);
@@ -325,7 +324,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *source, size_t split,
if (tail_length < sizeof(tail.data.inlined.bytes) &&
ref_whom != GRPC_SLICE_REF_TAIL) {
/* Copy out the bytes - it'll be cheaper than refcounting */
- tail.refcount = NULL;
+ tail.refcount = nullptr;
tail.data.inlined.length = (uint8_t)tail_length;
memcpy(tail.data.inlined.bytes, source->data.refcounted.bytes + split,
tail_length);
@@ -358,17 +357,17 @@ grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *source, size_t split,
return tail;
}
-grpc_slice grpc_slice_split_tail(grpc_slice *source, size_t split) {
+grpc_slice grpc_slice_split_tail(grpc_slice* source, size_t split) {
return grpc_slice_split_tail_maybe_ref(source, split, GRPC_SLICE_REF_BOTH);
}
-grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) {
+grpc_slice grpc_slice_split_head(grpc_slice* source, size_t split) {
grpc_slice head;
- if (source->refcount == NULL) {
+ if (source->refcount == nullptr) {
GPR_ASSERT(source->data.inlined.length >= split);
- head.refcount = NULL;
+ head.refcount = nullptr;
head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split);
source->data.inlined.length =
@@ -378,7 +377,7 @@ grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) {
} else if (split < sizeof(head.data.inlined.bytes)) {
GPR_ASSERT(source->data.refcounted.length >= split);
- head.refcount = NULL;
+ head.refcount = nullptr;
head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split);
source->refcount = source->refcount->sub_refcount;
@@ -423,7 +422,7 @@ int grpc_slice_cmp(grpc_slice a, grpc_slice b) {
GRPC_SLICE_LENGTH(a));
}
-int grpc_slice_str_cmp(grpc_slice a, const char *b) {
+int grpc_slice_str_cmp(grpc_slice a, const char* b) {
size_t b_length = strlen(b);
int d = (int)(GRPC_SLICE_LENGTH(a) - b_length);
if (d != 0) return d;
@@ -431,20 +430,20 @@ int grpc_slice_str_cmp(grpc_slice a, const char *b) {
}
int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b) {
- if (a.refcount == NULL || b.refcount == NULL) {
+ if (a.refcount == nullptr || b.refcount == nullptr) {
return grpc_slice_eq(a, b);
}
return a.data.refcounted.length == b.data.refcounted.length &&
a.data.refcounted.bytes == b.data.refcounted.bytes;
}
-int grpc_slice_buf_start_eq(grpc_slice a, const void *b, size_t len) {
+int grpc_slice_buf_start_eq(grpc_slice a, const void* b, size_t len) {
if (GRPC_SLICE_LENGTH(a) < len) return 0;
return 0 == memcmp(GRPC_SLICE_START_PTR(a), b, len);
}
int grpc_slice_rchr(grpc_slice s, char c) {
- const char *b = (const char *)GRPC_SLICE_START_PTR(s);
+ const char* b = (const char*)GRPC_SLICE_START_PTR(s);
int i;
for (i = (int)GRPC_SLICE_LENGTH(s) - 1; i != -1 && b[i] != c; i--)
;
@@ -452,16 +451,16 @@ int grpc_slice_rchr(grpc_slice s, char c) {
}
int grpc_slice_chr(grpc_slice s, char c) {
- const char *b = (const char *)GRPC_SLICE_START_PTR(s);
- const char *p = (const char *)memchr(b, c, GRPC_SLICE_LENGTH(s));
- return p == NULL ? -1 : (int)(p - b);
+ const char* b = (const char*)GRPC_SLICE_START_PTR(s);
+ const char* p = (const char*)memchr(b, c, GRPC_SLICE_LENGTH(s));
+ return p == nullptr ? -1 : (int)(p - b);
}
int grpc_slice_slice(grpc_slice haystack, grpc_slice needle) {
size_t haystack_len = GRPC_SLICE_LENGTH(haystack);
- const uint8_t *haystack_bytes = GRPC_SLICE_START_PTR(haystack);
+ const uint8_t* haystack_bytes = GRPC_SLICE_START_PTR(haystack);
size_t needle_len = GRPC_SLICE_LENGTH(needle);
- const uint8_t *needle_bytes = GRPC_SLICE_START_PTR(needle);
+ const uint8_t* needle_bytes = GRPC_SLICE_START_PTR(needle);
if (haystack_len == 0 || needle_len == 0) return -1;
if (haystack_len < needle_len) return -1;
@@ -469,8 +468,8 @@ int grpc_slice_slice(grpc_slice haystack, grpc_slice needle) {
return grpc_slice_eq(haystack, needle) ? 0 : -1;
if (needle_len == 1) return grpc_slice_chr(haystack, (char)*needle_bytes);
- const uint8_t *last = haystack_bytes + haystack_len - needle_len;
- for (const uint8_t *cur = haystack_bytes; cur != last; ++cur) {
+ const uint8_t* last = haystack_bytes + haystack_len - needle_len;
+ for (const uint8_t* cur = haystack_bytes; cur != last; ++cur) {
if (0 == memcmp(cur, needle_bytes, needle_len)) {
return (int)(cur - haystack_bytes);
}
diff --git a/src/core/lib/slice/slice_buffer.c b/src/core/lib/slice/slice_buffer.cc
index 63ffc0b00d..33ec2af683 100644
--- a/src/core/lib/slice/slice_buffer.c
+++ b/src/core/lib/slice/slice_buffer.cc
@@ -30,7 +30,7 @@
/* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */
#define GROW(x) (3 * (x) / 2)
-static void maybe_embiggen(grpc_slice_buffer *sb) {
+static void maybe_embiggen(grpc_slice_buffer* sb) {
/* How far away from sb->base_slices is sb->slices pointer */
size_t slice_offset = (size_t)(sb->slices - sb->base_slices);
size_t slice_count = sb->count + slice_offset;
@@ -46,10 +46,10 @@ static void maybe_embiggen(grpc_slice_buffer *sb) {
GPR_ASSERT(sb->capacity > slice_count);
if (sb->base_slices == sb->inlined) {
sb->base_slices =
- (grpc_slice *)gpr_malloc(sb->capacity * sizeof(grpc_slice));
+ (grpc_slice*)gpr_malloc(sb->capacity * sizeof(grpc_slice));
memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice));
} else {
- sb->base_slices = (grpc_slice *)gpr_realloc(
+ sb->base_slices = (grpc_slice*)gpr_realloc(
sb->base_slices, sb->capacity * sizeof(grpc_slice));
}
@@ -58,30 +58,28 @@ static void maybe_embiggen(grpc_slice_buffer *sb) {
}
}
-void grpc_slice_buffer_init(grpc_slice_buffer *sb) {
+void grpc_slice_buffer_init(grpc_slice_buffer* sb) {
sb->count = 0;
sb->length = 0;
sb->capacity = GRPC_SLICE_BUFFER_INLINE_ELEMENTS;
sb->base_slices = sb->slices = sb->inlined;
}
-void grpc_slice_buffer_destroy_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, sb);
+void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb) {
+ grpc_slice_buffer_reset_and_unref_internal(sb);
if (sb->base_slices != sb->inlined) {
gpr_free(sb->base_slices);
}
}
-void grpc_slice_buffer_destroy(grpc_slice_buffer *sb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, sb);
- grpc_exec_ctx_finish(&exec_ctx);
+void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_buffer_destroy_internal(sb);
}
-uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t n) {
- grpc_slice *back;
- uint8_t *out;
+uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) {
+ grpc_slice* back;
+ uint8_t* out;
sb->length += n;
@@ -98,12 +96,12 @@ add_new:
maybe_embiggen(sb);
back = &sb->slices[sb->count];
sb->count++;
- back->refcount = NULL;
+ back->refcount = nullptr;
back->data.inlined.length = (uint8_t)n;
return back->data.inlined.bytes;
}
-size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) {
+size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer* sb, grpc_slice s) {
size_t out = sb->count;
maybe_embiggen(sb);
sb->slices[out] = s;
@@ -112,7 +110,7 @@ size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) {
return out;
}
-void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
+void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice s) {
size_t n = sb->count;
/* if both the last slice in the slice buffer and the slice being added
are inlined (that is, that they carry their data inside the slice data
@@ -120,7 +118,7 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
into the back slice, preventing many small slices being passed into
writes */
if (!s.refcount && n) {
- grpc_slice *back = &sb->slices[n - 1];
+ grpc_slice* back = &sb->slices[n - 1];
if (!back->refcount &&
back->data.inlined.length < GRPC_SLICE_INLINED_SIZE) {
if (s.data.inlined.length + back->data.inlined.length <=
@@ -137,7 +135,7 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
maybe_embiggen(sb);
back = &sb->slices[n];
sb->count = n + 1;
- back->refcount = NULL;
+ back->refcount = nullptr;
back->data.inlined.length = (uint8_t)(s.data.inlined.length - cp1);
memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1,
s.data.inlined.length - cp1);
@@ -149,38 +147,36 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
grpc_slice_buffer_add_indexed(sb, s);
}
-void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *s, size_t n) {
+void grpc_slice_buffer_addn(grpc_slice_buffer* sb, grpc_slice* s, size_t n) {
size_t i;
for (i = 0; i < n; i++) {
grpc_slice_buffer_add(sb, s[i]);
}
}
-void grpc_slice_buffer_pop(grpc_slice_buffer *sb) {
+void grpc_slice_buffer_pop(grpc_slice_buffer* sb) {
if (sb->count != 0) {
size_t count = --sb->count;
sb->length -= GRPC_SLICE_LENGTH(sb->slices[count]);
}
}
-void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb) {
+void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb) {
size_t i;
for (i = 0; i < sb->count; i++) {
- grpc_slice_unref_internal(exec_ctx, sb->slices[i]);
+ grpc_slice_unref_internal(sb->slices[i]);
}
sb->count = 0;
sb->length = 0;
}
-void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, sb);
- grpc_exec_ctx_finish(&exec_ctx);
+void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_buffer_reset_and_unref_internal(sb);
}
-void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) {
+void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) {
size_t a_offset = (size_t)(a->slices - a->base_slices);
size_t b_offset = (size_t)(b->slices - b->base_slices);
@@ -207,7 +203,7 @@ void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) {
memcpy(a->base_slices, b->inlined, b_count * sizeof(grpc_slice));
} else {
/* no inlining: easy swap */
- GPR_SWAP(grpc_slice *, a->base_slices, b->base_slices);
+ GPR_SWAP(grpc_slice*, a->base_slices, b->base_slices);
}
/* Update the slices pointers (cannot do a GPR_SWAP on slices fields here).
@@ -222,8 +218,8 @@ void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) {
GPR_SWAP(size_t, a->length, b->length);
}
-void grpc_slice_buffer_move_into(grpc_slice_buffer *src,
- grpc_slice_buffer *dst) {
+void grpc_slice_buffer_move_into(grpc_slice_buffer* src,
+ grpc_slice_buffer* dst) {
/* anything to move? */
if (src->count == 0) {
return;
@@ -239,8 +235,8 @@ void grpc_slice_buffer_move_into(grpc_slice_buffer *src,
src->length = 0;
}
-static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst,
+static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst,
bool incref) {
GPR_ASSERT(src->length >= n);
if (src->length == n) {
@@ -279,20 +275,19 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer *src, size_t n,
GPR_ASSERT(src->count > 0);
}
-void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst) {
+void grpc_slice_buffer_move_first(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst) {
slice_buffer_move_first_maybe_ref(src, n, dst, true);
}
-void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst) {
+void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst) {
slice_buffer_move_first_maybe_ref(src, n, dst, false);
}
-void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *src, size_t n,
- void *dst) {
- char *dstp = (char *)dst;
+void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n,
+ void* dst) {
+ char* dstp = (char*)dst;
GPR_ASSERT(src->length >= n);
while (n > 0) {
@@ -305,19 +300,19 @@ void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
n = 0;
} else if (slice_len == n) {
memcpy(dstp, GRPC_SLICE_START_PTR(slice), n);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
n = 0;
} else {
memcpy(dstp, GRPC_SLICE_START_PTR(slice), slice_len);
dstp += slice_len;
n -= slice_len;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
}
}
}
-void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n,
- grpc_slice_buffer *garbage) {
+void grpc_slice_buffer_trim_end(grpc_slice_buffer* sb, size_t n,
+ grpc_slice_buffer* garbage) {
GPR_ASSERT(n <= sb->length);
sb->length -= n;
for (;;) {
@@ -340,7 +335,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n,
}
}
-grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) {
+grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) {
grpc_slice slice;
GPR_ASSERT(sb->count > 0);
slice = sb->slices[0];
@@ -351,7 +346,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) {
return slice;
}
-void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *sb,
+void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* sb,
grpc_slice slice) {
sb->slices--;
sb->slices[0] = slice;
diff --git a/src/core/lib/slice/slice_hash_table.c b/src/core/lib/slice/slice_hash_table.cc
index 6c2c9c201c..89340eff84 100644
--- a/src/core/lib/slice/slice_hash_table.c
+++ b/src/core/lib/slice/slice_hash_table.cc
@@ -27,7 +27,7 @@
struct grpc_slice_hash_table {
gpr_refcount refs;
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value);
+ void (*destroy_value)(void* value);
int (*value_cmp)(void* a, void* b);
size_t size;
size_t max_num_probes;
@@ -35,12 +35,12 @@ struct grpc_slice_hash_table {
};
static bool is_empty(grpc_slice_hash_table_entry* entry) {
- return entry->value == NULL;
+ return entry->value == nullptr;
}
static void grpc_slice_hash_table_add(grpc_slice_hash_table* table,
grpc_slice key, void* value) {
- GPR_ASSERT(value != NULL);
+ GPR_ASSERT(value != nullptr);
const size_t hash = grpc_slice_hash(key);
for (size_t offset = 0; offset < table->size; ++offset) {
const size_t idx = (hash + offset) % table->size;
@@ -58,8 +58,7 @@ static void grpc_slice_hash_table_add(grpc_slice_hash_table* table,
grpc_slice_hash_table* grpc_slice_hash_table_create(
size_t num_entries, grpc_slice_hash_table_entry* entries,
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value),
- int (*value_cmp)(void* a, void* b)) {
+ void (*destroy_value)(void* value), int (*value_cmp)(void* a, void* b)) {
grpc_slice_hash_table* table =
(grpc_slice_hash_table*)gpr_zalloc(sizeof(*table));
gpr_ref_init(&table->refs, 1);
@@ -77,18 +76,17 @@ grpc_slice_hash_table* grpc_slice_hash_table_create(
}
grpc_slice_hash_table* grpc_slice_hash_table_ref(grpc_slice_hash_table* table) {
- if (table != NULL) gpr_ref(&table->refs);
+ if (table != nullptr) gpr_ref(&table->refs);
return table;
}
-void grpc_slice_hash_table_unref(grpc_exec_ctx* exec_ctx,
- grpc_slice_hash_table* table) {
- if (table != NULL && gpr_unref(&table->refs)) {
+void grpc_slice_hash_table_unref(grpc_slice_hash_table* table) {
+ if (table != nullptr && gpr_unref(&table->refs)) {
for (size_t i = 0; i < table->size; ++i) {
grpc_slice_hash_table_entry* entry = &table->entries[i];
if (!is_empty(entry)) {
- grpc_slice_unref_internal(exec_ctx, entry->key);
- table->destroy_value(exec_ctx, entry->value);
+ grpc_slice_unref_internal(entry->key);
+ table->destroy_value(entry->value);
}
}
gpr_free(table->entries);
@@ -108,16 +106,16 @@ void* grpc_slice_hash_table_get(const grpc_slice_hash_table* table,
return table->entries[idx].value;
}
}
- return NULL; // Not found.
+ return nullptr; // Not found.
}
static int pointer_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
int grpc_slice_hash_table_cmp(const grpc_slice_hash_table* a,
const grpc_slice_hash_table* b) {
int (*const value_cmp_fn_a)(void* a, void* b) =
- a->value_cmp != NULL ? a->value_cmp : pointer_cmp;
+ a->value_cmp != nullptr ? a->value_cmp : pointer_cmp;
int (*const value_cmp_fn_b)(void* a, void* b) =
- b->value_cmp != NULL ? b->value_cmp : pointer_cmp;
+ b->value_cmp != nullptr ? b->value_cmp : pointer_cmp;
// Compare value_fns
const int value_fns_cmp =
GPR_ICMP((void*)value_cmp_fn_a, (void*)value_cmp_fn_b);
diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h
index 339078fef5..db69da662a 100644
--- a/src/core/lib/slice/slice_hash_table.h
+++ b/src/core/lib/slice/slice_hash_table.h
@@ -35,7 +35,7 @@ typedef struct grpc_slice_hash_table grpc_slice_hash_table;
typedef struct grpc_slice_hash_table_entry {
grpc_slice key;
- void *value; /* Must not be NULL. */
+ void* value; /* Must not be NULL. */
} grpc_slice_hash_table_entry;
/** Creates a new hash table of containing \a entries, which is an array
@@ -44,18 +44,16 @@ typedef struct grpc_slice_hash_table_entry {
value_cmp will be used to compare values in the context of \a
grpc_slice_hash_table_cmp. If NULL, raw pointer (\a GPR_ICMP) comparison
will be used. */
-grpc_slice_hash_table *grpc_slice_hash_table_create(
- size_t num_entries, grpc_slice_hash_table_entry *entries,
- void (*destroy_value)(grpc_exec_ctx *exec_ctx, void *value),
- int (*value_cmp)(void *a, void *b));
+grpc_slice_hash_table* grpc_slice_hash_table_create(
+ size_t num_entries, grpc_slice_hash_table_entry* entries,
+ void (*destroy_value)(void* value), int (*value_cmp)(void* a, void* b));
-grpc_slice_hash_table *grpc_slice_hash_table_ref(grpc_slice_hash_table *table);
-void grpc_slice_hash_table_unref(grpc_exec_ctx *exec_ctx,
- grpc_slice_hash_table *table);
+grpc_slice_hash_table* grpc_slice_hash_table_ref(grpc_slice_hash_table* table);
+void grpc_slice_hash_table_unref(grpc_slice_hash_table* table);
/** Returns the value from \a table associated with \a key.
Returns NULL if \a key is not found. */
-void *grpc_slice_hash_table_get(const grpc_slice_hash_table *table,
+void* grpc_slice_hash_table_get(const grpc_slice_hash_table* table,
const grpc_slice key);
/** Compares \a a vs. \a b.
@@ -64,7 +62,7 @@ void *grpc_slice_hash_table_get(const grpc_slice_hash_table *table,
* - else, it contains fewer (resp. more) entries,
* - else, if strcmp(a_key, b_key) < 1 (resp. > 1),
* - else, if value_cmp(a_value, b_value) < 1 (resp. > 1). */
-int grpc_slice_hash_table_cmp(const grpc_slice_hash_table *a,
- const grpc_slice_hash_table *b);
+int grpc_slice_hash_table_cmp(const grpc_slice_hash_table* a,
+ const grpc_slice_hash_table* b);
#endif /* GRPC_CORE_LIB_SLICE_SLICE_HASH_TABLE_H */
diff --git a/src/core/lib/slice/slice_intern.c b/src/core/lib/slice/slice_intern.cc
index ec71b3ca1d..fe1770b92c 100644
--- a/src/core/lib/slice/slice_intern.c
+++ b/src/core/lib/slice/slice_intern.cc
@@ -18,15 +18,16 @@
#include "src/core/lib/slice/slice_internal.h"
+#include <inttypes.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/murmur_hash.h"
#include "src/core/lib/iomgr/iomgr_internal.h" /* for iomgr_abort_on_leaks() */
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/murmur_hash.h"
#include "src/core/lib/transport/static_metadata.h"
#define LOG2_SHARD_COUNT 5
@@ -42,12 +43,12 @@ typedef struct interned_slice_refcount {
size_t length;
gpr_atm refcnt;
uint32_t hash;
- struct interned_slice_refcount *bucket_next;
+ struct interned_slice_refcount* bucket_next;
} interned_slice_refcount;
typedef struct slice_shard {
gpr_mu mu;
- interned_slice_refcount **strs;
+ interned_slice_refcount** strs;
size_t count;
size_t capacity;
} slice_shard;
@@ -68,17 +69,17 @@ static static_metadata_hash_ent
static uint32_t max_static_metadata_hash_probe;
static uint32_t static_metadata_hash_values[GRPC_STATIC_MDSTR_COUNT];
-static void interned_slice_ref(void *p) {
- interned_slice_refcount *s = (interned_slice_refcount *)p;
+static void interned_slice_ref(void* p) {
+ interned_slice_refcount* s = (interned_slice_refcount*)p;
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&s->refcnt, 1) > 0);
}
-static void interned_slice_destroy(interned_slice_refcount *s) {
- slice_shard *shard = &g_shards[SHARD_IDX(s->hash)];
+static void interned_slice_destroy(interned_slice_refcount* s) {
+ slice_shard* shard = &g_shards[SHARD_IDX(s->hash)];
gpr_mu_lock(&shard->mu);
GPR_ASSERT(0 == gpr_atm_no_barrier_load(&s->refcnt));
- interned_slice_refcount **prev_next;
- interned_slice_refcount *cur;
+ interned_slice_refcount** prev_next;
+ interned_slice_refcount* cur;
for (prev_next = &shard->strs[TABLE_IDX(s->hash, shard->capacity)],
cur = *prev_next;
cur != s; prev_next = &cur->bucket_next, cur = cur->bucket_next)
@@ -89,24 +90,23 @@ static void interned_slice_destroy(interned_slice_refcount *s) {
gpr_mu_unlock(&shard->mu);
}
-static void interned_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
- interned_slice_refcount *s = (interned_slice_refcount *)p;
+static void interned_slice_unref(void* p) {
+ interned_slice_refcount* s = (interned_slice_refcount*)p;
if (1 == gpr_atm_full_fetch_add(&s->refcnt, -1)) {
interned_slice_destroy(s);
}
}
-static void interned_slice_sub_ref(void *p) {
- interned_slice_ref(((char *)p) - offsetof(interned_slice_refcount, sub));
+static void interned_slice_sub_ref(void* p) {
+ interned_slice_ref(((char*)p) - offsetof(interned_slice_refcount, sub));
}
-static void interned_slice_sub_unref(grpc_exec_ctx *exec_ctx, void *p) {
- interned_slice_unref(exec_ctx,
- ((char *)p) - offsetof(interned_slice_refcount, sub));
+static void interned_slice_sub_unref(void* p) {
+ interned_slice_unref(((char*)p) - offsetof(interned_slice_refcount, sub));
}
static uint32_t interned_slice_hash(grpc_slice slice) {
- interned_slice_refcount *s = (interned_slice_refcount *)slice.refcount;
+ interned_slice_refcount* s = (interned_slice_refcount*)slice.refcount;
return s->hash;
}
@@ -121,16 +121,16 @@ static const grpc_slice_refcount_vtable interned_slice_sub_vtable = {
interned_slice_sub_ref, interned_slice_sub_unref,
grpc_slice_default_eq_impl, grpc_slice_default_hash_impl};
-static void grow_shard(slice_shard *shard) {
+static void grow_shard(slice_shard* shard) {
size_t capacity = shard->capacity * 2;
size_t i;
- interned_slice_refcount **strtab;
+ interned_slice_refcount** strtab;
interned_slice_refcount *s, *next;
GPR_TIMER_BEGIN("grow_strtab", 0);
- strtab = (interned_slice_refcount **)gpr_zalloc(
- sizeof(interned_slice_refcount *) * capacity);
+ strtab = (interned_slice_refcount**)gpr_zalloc(
+ sizeof(interned_slice_refcount*) * capacity);
for (i = 0; i < shard->capacity; i++) {
for (s = shard->strs[i]; s; s = next) {
@@ -148,10 +148,10 @@ static void grow_shard(slice_shard *shard) {
GPR_TIMER_END("grow_strtab", 0);
}
-static grpc_slice materialize(interned_slice_refcount *s) {
+static grpc_slice materialize(interned_slice_refcount* s) {
grpc_slice slice;
slice.refcount = &s->base;
- slice.data.refcounted.bytes = (uint8_t *)(s + 1);
+ slice.data.refcounted.bytes = (uint8_t*)(s + 1);
slice.data.refcounted.length = s->length;
return slice;
}
@@ -170,12 +170,12 @@ int grpc_static_slice_eq(grpc_slice a, grpc_slice b) {
}
uint32_t grpc_slice_hash(grpc_slice s) {
- return s.refcount == NULL ? grpc_slice_default_hash_impl(s)
- : s.refcount->vtable->hash(s);
+ return s.refcount == nullptr ? grpc_slice_default_hash_impl(s)
+ : s.refcount->vtable->hash(s);
}
grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
- bool *returned_slice_is_different) {
+ bool* returned_slice_is_different) {
if (GRPC_IS_STATIC_METADATA_STRING(slice)) {
return slice;
}
@@ -217,8 +217,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
}
}
- interned_slice_refcount *s;
- slice_shard *shard = &g_shards[SHARD_IDX(hash)];
+ interned_slice_refcount* s;
+ slice_shard* shard = &g_shards[SHARD_IDX(hash)];
gpr_mu_lock(&shard->mu);
@@ -243,8 +243,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
/* not found: create a new string */
/* string data goes after the internal_string header */
- s = (interned_slice_refcount *)gpr_malloc(sizeof(*s) +
- GRPC_SLICE_LENGTH(slice));
+ s = (interned_slice_refcount*)gpr_malloc(sizeof(*s) +
+ GRPC_SLICE_LENGTH(slice));
gpr_atm_rel_store(&s->refcnt, 1);
s->length = GRPC_SLICE_LENGTH(slice);
s->hash = hash;
@@ -278,12 +278,12 @@ void grpc_slice_intern_init(void) {
g_hash_seed = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
}
for (size_t i = 0; i < SHARD_COUNT; i++) {
- slice_shard *shard = &g_shards[i];
+ slice_shard* shard = &g_shards[i];
gpr_mu_init(&shard->mu);
shard->count = 0;
shard->capacity = INITIAL_SHARD_CAPACITY;
- shard->strs = (interned_slice_refcount **)gpr_zalloc(sizeof(*shard->strs) *
- shard->capacity);
+ shard->strs = (interned_slice_refcount**)gpr_zalloc(sizeof(*shard->strs) *
+ shard->capacity);
}
for (size_t i = 0; i < GPR_ARRAY_SIZE(static_metadata_hash); i++) {
static_metadata_hash[i].hash = 0;
@@ -310,16 +310,16 @@ void grpc_slice_intern_init(void) {
void grpc_slice_intern_shutdown(void) {
for (size_t i = 0; i < SHARD_COUNT; i++) {
- slice_shard *shard = &g_shards[i];
+ slice_shard* shard = &g_shards[i];
gpr_mu_destroy(&shard->mu);
/* TODO(ctiller): GPR_ASSERT(shard->count == 0); */
if (shard->count != 0) {
gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata strings were leaked",
shard->count);
for (size_t j = 0; j < shard->capacity; j++) {
- for (interned_slice_refcount *s = shard->strs[j]; s;
+ for (interned_slice_refcount* s = shard->strs[j]; s;
s = s->bucket_next) {
- char *text =
+ char* text =
grpc_dump_slice(materialize(s), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "LEAKED: %s", text);
gpr_free(text);
diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h
index 6df0b4b50b..4e9ab80261 100644
--- a/src/core/lib/slice/slice_internal.h
+++ b/src/core/lib/slice/slice_internal.h
@@ -25,11 +25,11 @@
#include "src/core/lib/iomgr/exec_ctx.h"
grpc_slice grpc_slice_ref_internal(grpc_slice slice);
-void grpc_slice_unref_internal(grpc_exec_ctx *exec_ctx, grpc_slice slice);
-void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb);
-void grpc_slice_buffer_destroy_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb);
+void grpc_slice_unref_internal(grpc_slice slice);
+void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb);
+void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb,
+ size_t idx);
+void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb);
/* Check if a slice is interned */
bool grpc_slice_is_interned(grpc_slice slice);
@@ -42,7 +42,7 @@ void grpc_test_only_set_slice_hash_seed(uint32_t key);
// used for surface boundaries where we might receive an un-interned static
// string
grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
- bool *returned_slice_is_different);
+ bool* returned_slice_is_different);
uint32_t grpc_static_slice_hash(grpc_slice s);
int grpc_static_slice_eq(grpc_slice a, grpc_slice b);
diff --git a/src/core/lib/slice/slice_string_helpers.c b/src/core/lib/slice/slice_string_helpers.cc
index d461c474d2..4441a26d8e 100644
--- a/src/core/lib/slice/slice_string_helpers.c
+++ b/src/core/lib/slice/slice_string_helpers.cc
@@ -22,11 +22,11 @@
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
-char *grpc_dump_slice(grpc_slice s, uint32_t flags) {
- return gpr_dump((const char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
+char* grpc_dump_slice(grpc_slice s, uint32_t flags) {
+ return gpr_dump((const char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
flags);
}
@@ -35,11 +35,11 @@ char *grpc_dump_slice(grpc_slice s, uint32_t flags) {
* str.
*
* Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */
-static int slice_find_separator_offset(const grpc_slice str, const char *sep,
- const size_t read_offset, size_t *begin,
- size_t *end) {
+static int slice_find_separator_offset(const grpc_slice str, const char* sep,
+ const size_t read_offset, size_t* begin,
+ size_t* end) {
size_t i;
- const uint8_t *str_ptr = GRPC_SLICE_START_PTR(str) + read_offset;
+ const uint8_t* str_ptr = GRPC_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GRPC_SLICE_LENGTH(str) - read_offset;
const size_t sep_len = strlen(sep);
if (str_len < sep_len) {
@@ -56,25 +56,60 @@ static int slice_find_separator_offset(const grpc_slice str, const char *sep,
return 0;
}
-void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) {
+static void skip_leading_trailing_spaces(const uint8_t* str_buffer,
+ size_t* begin, size_t* end) {
+ while (*begin < *end && str_buffer[*begin] == ' ') {
+ (*begin)++;
+ }
+ while (*begin < *end && str_buffer[*end - 1] == ' ') {
+ (*end)--;
+ }
+}
+
+static void grpc_slice_split_inner(grpc_slice str, const char* sep,
+ grpc_slice_buffer* dst, bool no_space) {
const size_t sep_len = strlen(sep);
size_t begin, end;
+ const uint8_t* str_buffer = GRPC_SLICE_START_PTR(str);
+ size_t sep_pos;
GPR_ASSERT(sep_len > 0);
if (slice_find_separator_offset(str, sep, 0, &begin, &end) != 0) {
do {
+ sep_pos = end;
+ if (no_space) {
+ skip_leading_trailing_spaces(str_buffer, &begin, &end);
+ }
grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
- } while (slice_find_separator_offset(str, sep, end + sep_len, &begin,
+ } while (slice_find_separator_offset(str, sep, sep_pos + sep_len, &begin,
&end) != 0);
- grpc_slice_buffer_add_indexed(
- dst, grpc_slice_sub(str, end + sep_len, GRPC_SLICE_LENGTH(str)));
+ begin = sep_pos + sep_len;
+ end = GRPC_SLICE_LENGTH(str);
+ if (no_space) {
+ skip_leading_trailing_spaces(str_buffer, &begin, &end);
+ }
+ grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
} else { /* no sep found, add whole input */
- grpc_slice_buffer_add_indexed(dst, grpc_slice_ref_internal(str));
+ begin = 0;
+ end = GRPC_SLICE_LENGTH(str);
+ if (no_space) {
+ skip_leading_trailing_spaces(str_buffer, &begin, &end);
+ }
+ grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
}
}
-bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t *result) {
- return gpr_parse_bytes_to_uint32((const char *)GRPC_SLICE_START_PTR(str),
+void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst) {
+ grpc_slice_split_inner(str, sep, dst, false);
+}
+
+void grpc_slice_split_without_space(grpc_slice str, const char* sep,
+ grpc_slice_buffer* dst) {
+ grpc_slice_split_inner(str, sep, dst, true);
+}
+
+bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result) {
+ return gpr_parse_bytes_to_uint32((const char*)GRPC_SLICE_START_PTR(str),
GRPC_SLICE_LENGTH(str), result) != 0;
}
diff --git a/src/core/lib/slice/slice_string_helpers.h b/src/core/lib/slice/slice_string_helpers.h
index bcfb33bfb3..429f9ff4b5 100644
--- a/src/core/lib/slice/slice_string_helpers.h
+++ b/src/core/lib/slice/slice_string_helpers.h
@@ -26,23 +26,21 @@
#include <grpc/slice_buffer.h>
#include <grpc/support/port_platform.h>
-#include "src/core/lib/support/string.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "src/core/lib/gpr/string.h"
/* Calls gpr_dump on a slice. */
-char *grpc_dump_slice(grpc_slice slice, uint32_t flags);
+char* grpc_dump_slice(grpc_slice slice, uint32_t flags);
/** Split \a str by the separator \a sep. Results are stored in \a dst, which
* should be a properly initialized instance. */
-void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst);
+void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst);
-bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t *result);
+/** Split \a str by the separator \a sep and remove the leading and trailing
+ * spaces of each resulting token. Results are stored in \a dst, which should be
+ * a properly initialized instance. */
+void grpc_slice_split_without_space(grpc_slice str, const char* sep,
+ grpc_slice_buffer* dst);
-#ifdef __cplusplus
-}
-#endif
+bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result);
#endif /* GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H */
diff --git a/src/core/lib/support/backoff.c b/src/core/lib/support/backoff.c
deleted file mode 100644
index 6dc0df473b..0000000000
--- a/src/core/lib/support/backoff.c
+++ /dev/null
@@ -1,72 +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 "src/core/lib/support/backoff.h"
-
-#include <grpc/support/useful.h>
-
-void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout,
- double multiplier, double jitter,
- int64_t min_timeout_millis, int64_t max_timeout_millis) {
- backoff->initial_connect_timeout = initial_connect_timeout;
- backoff->multiplier = multiplier;
- backoff->jitter = jitter;
- backoff->min_timeout_millis = min_timeout_millis;
- backoff->max_timeout_millis = max_timeout_millis;
- backoff->rng_state = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
-}
-
-gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now) {
- backoff->current_timeout_millis = backoff->initial_connect_timeout;
- const int64_t first_timeout =
- GPR_MAX(backoff->current_timeout_millis, backoff->min_timeout_millis);
- return gpr_time_add(now, gpr_time_from_millis(first_timeout, GPR_TIMESPAN));
-}
-
-/* Generate a random number between 0 and 1. */
-static double generate_uniform_random_number(uint32_t *rng_state) {
- *rng_state = (1103515245 * *rng_state + 12345) % ((uint32_t)1 << 31);
- return *rng_state / (double)((uint32_t)1 << 31);
-}
-
-gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) {
- const double new_timeout_millis =
- backoff->multiplier * (double)backoff->current_timeout_millis;
- backoff->current_timeout_millis =
- GPR_MIN((int64_t)new_timeout_millis, backoff->max_timeout_millis);
-
- const double jitter_range_width = backoff->jitter * new_timeout_millis;
- const double jitter =
- (2 * generate_uniform_random_number(&backoff->rng_state) - 1) *
- jitter_range_width;
-
- backoff->current_timeout_millis =
- (int64_t)((double)(backoff->current_timeout_millis) + jitter);
-
- const gpr_timespec current_deadline = gpr_time_add(
- now, gpr_time_from_millis(backoff->current_timeout_millis, GPR_TIMESPAN));
-
- const gpr_timespec min_deadline = gpr_time_add(
- now, gpr_time_from_millis(backoff->min_timeout_millis, GPR_TIMESPAN));
-
- return gpr_time_max(current_deadline, min_deadline);
-}
-
-void gpr_backoff_reset(gpr_backoff *backoff) {
- backoff->current_timeout_millis = backoff->initial_connect_timeout;
-}
diff --git a/src/core/lib/support/backoff.h b/src/core/lib/support/backoff.h
deleted file mode 100644
index 6e0cc3a4b6..0000000000
--- a/src/core/lib/support/backoff.h
+++ /dev/null
@@ -1,56 +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.
- *
- */
-
-#ifndef GRPC_CORE_LIB_SUPPORT_BACKOFF_H
-#define GRPC_CORE_LIB_SUPPORT_BACKOFF_H
-
-#include <grpc/support/time.h>
-
-typedef struct {
- /// const: how long to wait after the first failure before retrying
- int64_t initial_connect_timeout;
- /// const: factor with which to multiply backoff after a failed retry
- double multiplier;
- /// const: amount to randomize backoffs
- double jitter;
- /// const: minimum time between retries in milliseconds
- int64_t min_timeout_millis;
- /// const: maximum time between retries in milliseconds
- int64_t max_timeout_millis;
-
- /// random number generator
- uint32_t rng_state;
-
- /// current retry timeout in milliseconds
- int64_t current_timeout_millis;
-} gpr_backoff;
-
-/// Initialize backoff machinery - does not need to be destroyed
-void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout,
- double multiplier, double jitter,
- int64_t min_timeout_millis, int64_t max_timeout_millis);
-
-/// Begin retry loop: returns a timespec for the NEXT retry
-gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now);
-/// Step a retry loop: returns a timespec for the NEXT retry
-gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now);
-/// Reset the backoff, so the next gpr_backoff_step will be a gpr_backoff_begin
-/// instead
-void gpr_backoff_reset(gpr_backoff *backoff);
-
-#endif /* GRPC_CORE_LIB_SUPPORT_BACKOFF_H */
diff --git a/src/core/lib/support/mpscq.c b/src/core/lib/support/mpscq.c
deleted file mode 100644
index e9f893988d..0000000000
--- a/src/core/lib/support/mpscq.c
+++ /dev/null
@@ -1,79 +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 "src/core/lib/support/mpscq.h"
-
-#include <grpc/support/log.h>
-
-void gpr_mpscq_init(gpr_mpscq *q) {
- gpr_atm_no_barrier_store(&q->head, (gpr_atm)&q->stub);
- q->tail = &q->stub;
- gpr_atm_no_barrier_store(&q->stub.next, (gpr_atm)NULL);
-}
-
-void gpr_mpscq_destroy(gpr_mpscq *q) {
- GPR_ASSERT(gpr_atm_no_barrier_load(&q->head) == (gpr_atm)&q->stub);
- GPR_ASSERT(q->tail == &q->stub);
-}
-
-void gpr_mpscq_push(gpr_mpscq *q, gpr_mpscq_node *n) {
- gpr_atm_no_barrier_store(&n->next, (gpr_atm)NULL);
- gpr_mpscq_node *prev =
- (gpr_mpscq_node *)gpr_atm_full_xchg(&q->head, (gpr_atm)n);
- gpr_atm_rel_store(&prev->next, (gpr_atm)n);
-}
-
-gpr_mpscq_node *gpr_mpscq_pop(gpr_mpscq *q) {
- bool empty;
- return gpr_mpscq_pop_and_check_end(q, &empty);
-}
-
-gpr_mpscq_node *gpr_mpscq_pop_and_check_end(gpr_mpscq *q, bool *empty) {
- gpr_mpscq_node *tail = q->tail;
- gpr_mpscq_node *next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next);
- if (tail == &q->stub) {
- // indicates the list is actually (ephemerally) empty
- if (next == NULL) {
- *empty = true;
- return NULL;
- }
- q->tail = next;
- tail = next;
- next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next);
- }
- if (next != NULL) {
- *empty = false;
- q->tail = next;
- return tail;
- }
- gpr_mpscq_node *head = (gpr_mpscq_node *)gpr_atm_acq_load(&q->head);
- if (tail != head) {
- *empty = false;
- // indicates a retry is in order: we're still adding
- return NULL;
- }
- gpr_mpscq_push(q, &q->stub);
- next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next);
- if (next != NULL) {
- q->tail = next;
- return tail;
- }
- // indicates a retry is in order: we're still adding
- *empty = false;
- return NULL;
-}
diff --git a/src/core/lib/support/mpscq.h b/src/core/lib/support/mpscq.h
deleted file mode 100644
index daa51768f7..0000000000
--- a/src/core/lib/support/mpscq.h
+++ /dev/null
@@ -1,53 +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.
- *
- */
-
-#ifndef GRPC_CORE_LIB_SUPPORT_MPSCQ_H
-#define GRPC_CORE_LIB_SUPPORT_MPSCQ_H
-
-#include <grpc/support/atm.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-// Multiple-producer single-consumer lock free queue, based upon the
-// implementation from Dmitry Vyukov here:
-// http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue
-
-// List node (include this in a data structure at the top, and add application
-// fields after it - to simulate inheritance)
-typedef struct gpr_mpscq_node { gpr_atm next; } gpr_mpscq_node;
-
-// Actual queue type
-typedef struct gpr_mpscq {
- gpr_atm head;
- // make sure head & tail don't share a cacheline
- char padding[GPR_CACHELINE_SIZE];
- gpr_mpscq_node *tail;
- gpr_mpscq_node stub;
-} gpr_mpscq;
-
-void gpr_mpscq_init(gpr_mpscq *q);
-void gpr_mpscq_destroy(gpr_mpscq *q);
-// Push a node
-void gpr_mpscq_push(gpr_mpscq *q, gpr_mpscq_node *n);
-// Pop a node (returns NULL if no node is ready - which doesn't indicate that
-// the queue is empty!!)
-gpr_mpscq_node *gpr_mpscq_pop(gpr_mpscq *q);
-// Pop a node; sets *empty to true if the queue is empty, or false if it is not
-gpr_mpscq_node *gpr_mpscq_pop_and_check_end(gpr_mpscq *q, bool *empty);
-
-#endif /* GRPC_CORE_LIB_SUPPORT_MPSCQ_H */
diff --git a/src/core/lib/support/stack_lockfree.c b/src/core/lib/support/stack_lockfree.c
deleted file mode 100644
index 0fb64ed001..0000000000
--- a/src/core/lib/support/stack_lockfree.c
+++ /dev/null
@@ -1,137 +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/support/stack_lockfree.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/atm.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-
-/* The lockfree node structure is a single architecture-level
- word that allows for an atomic CAS to set it up. */
-struct lockfree_node_contents {
- /* next thing to look at. Actual index for head, next index otherwise */
- uint16_t index;
-#ifdef GPR_ARCH_64
- uint16_t pad;
- uint32_t aba_ctr;
-#else
-#ifdef GPR_ARCH_32
- uint16_t aba_ctr;
-#else
-#error Unsupported bit width architecture
-#endif
-#endif
-};
-
-/* Use a union to make sure that these are in the same bits as an atm word */
-typedef union lockfree_node {
- gpr_atm atm;
- struct lockfree_node_contents contents;
-} lockfree_node;
-
-/* make sure that entries aligned to 8-bytes */
-#define ENTRY_ALIGNMENT_BITS 3
-/* reserve this entry as invalid */
-#define INVALID_ENTRY_INDEX ((1 << 16) - 1)
-
-struct gpr_stack_lockfree {
- lockfree_node *entries;
- lockfree_node head; /* An atomic entry describing curr head */
-};
-
-gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) {
- gpr_stack_lockfree *stack;
- stack = (gpr_stack_lockfree *)gpr_malloc(sizeof(*stack));
- /* Since we only allocate 16 bits to represent an entry number,
- * make sure that we are within the desired range */
- /* Reserve the highest entry number as a dummy */
- GPR_ASSERT(entries < INVALID_ENTRY_INDEX);
- stack->entries = (lockfree_node *)gpr_malloc_aligned(
- entries * sizeof(stack->entries[0]), ENTRY_ALIGNMENT_BITS);
- /* Clear out all entries */
- memset(stack->entries, 0, entries * sizeof(stack->entries[0]));
- memset(&stack->head, 0, sizeof(stack->head));
-
- GPR_ASSERT(sizeof(stack->entries->atm) == sizeof(stack->entries->contents));
-
- /* Point the head at reserved dummy entry */
- stack->head.contents.index = INVALID_ENTRY_INDEX;
-/* Fill in the pad and aba_ctr to avoid confusing memcheck tools */
-#ifdef GPR_ARCH_64
- stack->head.contents.pad = 0;
-#endif
- stack->head.contents.aba_ctr = 0;
- return stack;
-}
-
-void gpr_stack_lockfree_destroy(gpr_stack_lockfree *stack) {
- gpr_free_aligned(stack->entries);
- gpr_free(stack);
-}
-
-int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
- lockfree_node head;
- lockfree_node newhead;
- lockfree_node curent;
- lockfree_node newent;
-
- /* First fill in the entry's index and aba ctr for new head */
- newhead.contents.index = (uint16_t)entry;
-#ifdef GPR_ARCH_64
- /* Fill in the pad to avoid confusing memcheck tools */
- newhead.contents.pad = 0;
-#endif
-
- /* Also post-increment the aba_ctr */
- curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
- newhead.contents.aba_ctr = ++curent.contents.aba_ctr;
- gpr_atm_no_barrier_store(&stack->entries[entry].atm, curent.atm);
-
- do {
- /* Atomically get the existing head value for use */
- head.atm = gpr_atm_no_barrier_load(&(stack->head.atm));
- /* Point to it */
- newent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
- newent.contents.index = head.contents.index;
- gpr_atm_no_barrier_store(&stack->entries[entry].atm, newent.atm);
- } while (!gpr_atm_rel_cas(&(stack->head.atm), head.atm, newhead.atm));
- /* Use rel_cas above to make sure that entry index is set properly */
- return head.contents.index == INVALID_ENTRY_INDEX;
-}
-
-int gpr_stack_lockfree_pop(gpr_stack_lockfree *stack) {
- lockfree_node head;
- lockfree_node newhead;
-
- do {
- head.atm = gpr_atm_acq_load(&(stack->head.atm));
- if (head.contents.index == INVALID_ENTRY_INDEX) {
- return -1;
- }
- newhead.atm =
- gpr_atm_no_barrier_load(&(stack->entries[head.contents.index].atm));
-
- } while (!gpr_atm_no_barrier_cas(&(stack->head.atm), head.atm, newhead.atm));
-
- return head.contents.index;
-}
diff --git a/src/core/lib/support/stack_lockfree.h b/src/core/lib/support/stack_lockfree.h
deleted file mode 100644
index 6324211b72..0000000000
--- a/src/core/lib/support/stack_lockfree.h
+++ /dev/null
@@ -1,38 +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_SUPPORT_STACK_LOCKFREE_H
-#define GRPC_CORE_LIB_SUPPORT_STACK_LOCKFREE_H
-
-#include <stddef.h>
-
-typedef struct gpr_stack_lockfree gpr_stack_lockfree;
-
-/* This stack must specify the maximum number of entries to track.
- The current implementation only allows up to 65534 entries */
-gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries);
-void gpr_stack_lockfree_destroy(gpr_stack_lockfree *stack);
-
-/* Pass in a valid entry number for the next stack entry */
-/* Returns 1 if this is the first element on the stack, 0 otherwise */
-int gpr_stack_lockfree_push(gpr_stack_lockfree *, int entry);
-
-/* Returns -1 on empty or the actual entry number */
-int gpr_stack_lockfree_pop(gpr_stack_lockfree *stack);
-
-#endif /* GRPC_CORE_LIB_SUPPORT_STACK_LOCKFREE_H */
diff --git a/src/core/lib/support/thd_posix.c b/src/core/lib/support/thd_posix.c
deleted file mode 100644
index 98afd10df7..0000000000
--- a/src/core/lib/support/thd_posix.c
+++ /dev/null
@@ -1,80 +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.
- *
- */
-
-/* Posix implementation for gpr threads. */
-
-#include <grpc/support/port_platform.h>
-
-#ifdef GPR_POSIX_SYNC
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/thd.h>
-#include <grpc/support/useful.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct thd_arg {
- void (*body)(void *arg); /* body of a thread */
- void *arg; /* argument to a thread */
-};
-
-/* Body of every thread started via gpr_thd_new. */
-static void *thread_body(void *v) {
- struct thd_arg a = *(struct thd_arg *)v;
- free(v);
- (*a.body)(a.arg);
- return NULL;
-}
-
-int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
- const gpr_thd_options *options) {
- int thread_started;
- pthread_attr_t attr;
- pthread_t p;
- /* don't use gpr_malloc as we may cause an infinite recursion with
- * the profiling code */
- struct thd_arg *a = (struct thd_arg *)malloc(sizeof(*a));
- GPR_ASSERT(a != NULL);
- a->body = thd_body;
- a->arg = arg;
-
- GPR_ASSERT(pthread_attr_init(&attr) == 0);
- if (gpr_thd_options_is_detached(options)) {
- GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) ==
- 0);
- } else {
- GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) ==
- 0);
- }
- thread_started = (pthread_create(&p, &attr, &thread_body, a) == 0);
- GPR_ASSERT(pthread_attr_destroy(&attr) == 0);
- if (!thread_started) {
- /* don't use gpr_free, as this was allocated using malloc (see above) */
- free(a);
- }
- *t = (gpr_thd_id)p;
- return thread_started;
-}
-
-gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)pthread_self(); }
-
-void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, NULL); }
-
-#endif /* GPR_POSIX_SYNC */
diff --git a/src/core/lib/surface/alarm.c b/src/core/lib/surface/alarm.cc
index 7712f560b9..f6ea016c33 100644
--- a/src/core/lib/surface/alarm.c
+++ b/src/core/lib/surface/alarm.cc
@@ -15,6 +15,10 @@
* limitations under the License.
*
*/
+#include <grpc/support/port_platform.h>
+
+#include <inttypes.h>
+
#include "src/core/lib/surface/alarm_internal.h"
#include <grpc/grpc.h>
@@ -23,10 +27,8 @@
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/surface/completion_queue.h"
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_alarm_refcount =
- GRPC_TRACER_INITIALIZER(false, "alarm_refcount");
-#endif
+grpc_core::DebugOnlyTraceFlag grpc_trace_alarm_refcount(false,
+ "alarm_refcount");
struct grpc_alarm {
gpr_refcount refs;
@@ -34,28 +36,28 @@ struct grpc_alarm {
grpc_closure on_alarm;
grpc_cq_completion completion;
/** completion queue where events about this alarm will be posted */
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
/** user supplied tag */
- void *tag;
+ void* tag;
};
-static void alarm_ref(grpc_alarm *alarm) { gpr_ref(&alarm->refs); }
+static void alarm_ref(grpc_alarm* alarm) { gpr_ref(&alarm->refs); }
-static void alarm_unref(grpc_alarm *alarm) {
+static void alarm_unref(grpc_alarm* alarm) {
if (gpr_unref(&alarm->refs)) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (alarm->cq != NULL) {
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, alarm->cq, "alarm");
+ grpc_core::ExecCtx exec_ctx;
+ if (alarm->cq != nullptr) {
+ GRPC_CQ_INTERNAL_UNREF(alarm->cq, "alarm");
}
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(alarm);
}
}
#ifndef NDEBUG
-static void alarm_ref_dbg(grpc_alarm *alarm, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_alarm_refcount)) {
+static void alarm_ref_dbg(grpc_alarm* alarm, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_alarm_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&alarm->refs.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"Alarm:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", alarm, val,
@@ -65,9 +67,9 @@ static void alarm_ref_dbg(grpc_alarm *alarm, const char *reason,
alarm_ref(alarm);
}
-static void alarm_unref_dbg(grpc_alarm *alarm, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_alarm_refcount)) {
+static void alarm_unref_dbg(grpc_alarm* alarm, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_alarm_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&alarm->refs.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"Alarm:%p Unref %" PRIdPTR " -> %" PRIdPTR " %s", alarm, val,
@@ -78,62 +80,58 @@ static void alarm_unref_dbg(grpc_alarm *alarm, const char *reason,
}
#endif
-static void alarm_end_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *c) {
- grpc_alarm *alarm = (grpc_alarm *)arg;
+static void alarm_end_completion(void* arg, grpc_cq_completion* c) {
+ grpc_alarm* alarm = (grpc_alarm*)arg;
GRPC_ALARM_UNREF(alarm, "dequeue-end-op");
}
-static void alarm_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_alarm *alarm = (grpc_alarm *)arg;
+static void alarm_cb(void* arg, grpc_error* error) {
+ grpc_alarm* alarm = (grpc_alarm*)arg;
/* We are queuing an op on completion queue. This means, the alarm's structure
cannot be destroyed until the op is dequeued. Adding an extra ref
here and unref'ing when the op is dequeued will achieve this */
GRPC_ALARM_REF(alarm, "queue-end-op");
- grpc_cq_end_op(exec_ctx, alarm->cq, alarm->tag, error, alarm_end_completion,
- (void *)alarm, &alarm->completion);
+ grpc_cq_end_op(alarm->cq, alarm->tag, error, alarm_end_completion,
+ (void*)alarm, &alarm->completion);
}
-grpc_alarm *grpc_alarm_create(void *reserved) {
- grpc_alarm *alarm = (grpc_alarm *)gpr_malloc(sizeof(grpc_alarm));
+grpc_alarm* grpc_alarm_create(void* reserved) {
+ grpc_alarm* alarm = (grpc_alarm*)gpr_malloc(sizeof(grpc_alarm));
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_alarm_refcount)) {
+ if (grpc_trace_alarm_refcount.enabled()) {
gpr_log(GPR_DEBUG, "Alarm:%p created (ref: 1)", alarm);
}
#endif
gpr_ref_init(&alarm->refs, 1);
grpc_timer_init_unset(&alarm->alarm);
- alarm->cq = NULL;
+ alarm->cq = nullptr;
GRPC_CLOSURE_INIT(&alarm->on_alarm, alarm_cb, alarm,
grpc_schedule_on_exec_ctx);
return alarm;
}
-void grpc_alarm_set(grpc_alarm *alarm, grpc_completion_queue *cq,
- gpr_timespec deadline, void *tag, void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+void grpc_alarm_set(grpc_alarm* alarm, grpc_completion_queue* cq,
+ gpr_timespec deadline, void* tag, void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
GRPC_CQ_INTERNAL_REF(cq, "alarm");
alarm->cq = cq;
alarm->tag = tag;
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
- grpc_timer_init(&exec_ctx, &alarm->alarm,
- gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC),
- &alarm->on_alarm, gpr_now(GPR_CLOCK_MONOTONIC));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_init(&alarm->alarm, grpc_timespec_to_millis_round_up(deadline),
+ &alarm->on_alarm);
}
-void grpc_alarm_cancel(grpc_alarm *alarm, void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_timer_cancel(&exec_ctx, &alarm->alarm);
- grpc_exec_ctx_finish(&exec_ctx);
+void grpc_alarm_cancel(grpc_alarm* alarm, void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_timer_cancel(&alarm->alarm);
}
-void grpc_alarm_destroy(grpc_alarm *alarm, void *reserved) {
+void grpc_alarm_destroy(grpc_alarm* alarm, void* reserved) {
grpc_alarm_cancel(alarm, reserved);
GRPC_ALARM_UNREF(alarm, "alarm_destroy");
}
diff --git a/src/core/lib/surface/alarm_internal.h b/src/core/lib/surface/alarm_internal.h
index 7f2126c5c9..99e981234d 100644
--- a/src/core/lib/surface/alarm_internal.h
+++ b/src/core/lib/surface/alarm_internal.h
@@ -22,9 +22,9 @@
#include <grpc/support/log.h>
#include "src/core/lib/debug/trace.h"
-#ifndef NDEBUG
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_alarm_refcount;
-extern grpc_tracer_flag grpc_trace_alarm_refcount;
+#ifndef NDEBUG
#define GRPC_ALARM_REF(a, reason) alarm_ref_dbg(a, reason, __FILE__, __LINE__)
#define GRPC_ALARM_UNREF(a, reason) \
diff --git a/src/core/lib/surface/api_trace.c b/src/core/lib/surface/api_trace.cc
index 56973303da..7ab836a9ba 100644
--- a/src/core/lib/surface/api_trace.c
+++ b/src/core/lib/surface/api_trace.cc
@@ -19,4 +19,4 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/debug/trace.h"
-grpc_tracer_flag grpc_api_trace = GRPC_TRACER_INITIALIZER(false, "api");
+grpc_core::TraceFlag grpc_api_trace(false, "api");
diff --git a/src/core/lib/surface/api_trace.h b/src/core/lib/surface/api_trace.h
index 849cbaaef6..a4e11ce154 100644
--- a/src/core/lib/surface/api_trace.h
+++ b/src/core/lib/surface/api_trace.h
@@ -22,7 +22,7 @@
#include <grpc/support/log.h>
#include "src/core/lib/debug/trace.h"
-extern grpc_tracer_flag grpc_api_trace;
+extern grpc_core::TraceFlag grpc_api_trace;
/* Provide unwrapping macros because we're in C89 and variadic macros weren't
introduced until C99... */
@@ -43,7 +43,7 @@ extern grpc_tracer_flag grpc_api_trace;
/* Due to the limitations of C89's preprocessor, the arity of the var-arg list
'nargs' must be specified. */
#define GRPC_API_TRACE(fmt, nargs, args) \
- if (GRPC_TRACER_ON(grpc_api_trace)) { \
+ if (grpc_api_trace.enabled()) { \
gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \
}
diff --git a/src/core/lib/surface/byte_buffer.c b/src/core/lib/surface/byte_buffer.cc
index 7ed550ef87..e4c2a4a4c2 100644
--- a/src/core/lib/surface/byte_buffer.c
+++ b/src/core/lib/surface/byte_buffer.cc
@@ -22,18 +22,18 @@
#include "src/core/lib/slice/slice_internal.h"
-grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices,
+grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slices,
size_t nslices) {
return grpc_raw_compressed_byte_buffer_create(slices, nslices,
GRPC_COMPRESS_NONE);
}
-grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
- grpc_slice *slices, size_t nslices,
+grpc_byte_buffer* grpc_raw_compressed_byte_buffer_create(
+ grpc_slice* slices, size_t nslices,
grpc_compression_algorithm compression) {
size_t i;
- grpc_byte_buffer *bb =
- (grpc_byte_buffer *)gpr_malloc(sizeof(grpc_byte_buffer));
+ grpc_byte_buffer* bb =
+ (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer));
bb->type = GRPC_BB_RAW;
bb->data.raw.compression = compression;
grpc_slice_buffer_init(&bb->data.raw.slice_buffer);
@@ -44,10 +44,10 @@ grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
return bb;
}
-grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(
- grpc_byte_buffer_reader *reader) {
- grpc_byte_buffer *bb =
- (grpc_byte_buffer *)gpr_malloc(sizeof(grpc_byte_buffer));
+grpc_byte_buffer* grpc_raw_byte_buffer_from_reader(
+ grpc_byte_buffer_reader* reader) {
+ grpc_byte_buffer* bb =
+ (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer));
grpc_slice slice;
bb->type = GRPC_BB_RAW;
bb->data.raw.compression = GRPC_COMPRESS_NONE;
@@ -59,29 +59,28 @@ grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(
return bb;
}
-grpc_byte_buffer *grpc_byte_buffer_copy(grpc_byte_buffer *bb) {
+grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) {
switch (bb->type) {
case GRPC_BB_RAW:
return grpc_raw_compressed_byte_buffer_create(
bb->data.raw.slice_buffer.slices, bb->data.raw.slice_buffer.count,
bb->data.raw.compression);
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
-void grpc_byte_buffer_destroy(grpc_byte_buffer *bb) {
+void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) {
if (!bb) return;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
switch (bb->type) {
case GRPC_BB_RAW:
- grpc_slice_buffer_destroy_internal(&exec_ctx, &bb->data.raw.slice_buffer);
+ grpc_slice_buffer_destroy_internal(&bb->data.raw.slice_buffer);
break;
}
gpr_free(bb);
- grpc_exec_ctx_finish(&exec_ctx);
}
-size_t grpc_byte_buffer_length(grpc_byte_buffer *bb) {
+size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) {
switch (bb->type) {
case GRPC_BB_RAW:
return bb->data.raw.slice_buffer.length;
diff --git a/src/core/lib/surface/byte_buffer_reader.c b/src/core/lib/surface/byte_buffer_reader.cc
index 87bd3239c0..f7ea5161c7 100644
--- a/src/core/lib/surface/byte_buffer_reader.c
+++ b/src/core/lib/surface/byte_buffer_reader.cc
@@ -29,7 +29,7 @@
#include "src/core/lib/compression/message_compress.h"
#include "src/core/lib/slice/slice_internal.h"
-static int is_compressed(grpc_byte_buffer *buffer) {
+static int is_compressed(grpc_byte_buffer* buffer) {
switch (buffer->type) {
case GRPC_BB_RAW:
if (buffer->data.raw.compression == GRPC_COMPRESS_NONE) {
@@ -40,19 +40,21 @@ static int is_compressed(grpc_byte_buffer *buffer) {
return 1 /* GPR_TRUE */;
}
-int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
- grpc_byte_buffer *buffer) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
+ grpc_byte_buffer* buffer) {
+ grpc_core::ExecCtx exec_ctx;
grpc_slice_buffer decompressed_slices_buffer;
reader->buffer_in = buffer;
switch (reader->buffer_in->type) {
case GRPC_BB_RAW:
grpc_slice_buffer_init(&decompressed_slices_buffer);
if (is_compressed(reader->buffer_in)) {
- if (grpc_msg_decompress(&exec_ctx,
- reader->buffer_in->data.raw.compression,
- &reader->buffer_in->data.raw.slice_buffer,
- &decompressed_slices_buffer) == 0) {
+ if (grpc_msg_decompress(
+
+ grpc_compression_algorithm_to_message_compression_algorithm(
+ reader->buffer_in->data.raw.compression),
+ &reader->buffer_in->data.raw.slice_buffer,
+ &decompressed_slices_buffer) == 0) {
gpr_log(GPR_ERROR,
"Unexpected error decompressing data for algorithm with enum "
"value '%d'.",
@@ -64,19 +66,18 @@ int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
grpc_raw_byte_buffer_create(decompressed_slices_buffer.slices,
decompressed_slices_buffer.count);
}
- grpc_slice_buffer_destroy_internal(&exec_ctx,
- &decompressed_slices_buffer);
+ grpc_slice_buffer_destroy_internal(&decompressed_slices_buffer);
} else { /* not compressed, use the input buffer as output */
reader->buffer_out = reader->buffer_in;
}
reader->current.index = 0;
break;
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return 1;
}
-void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) {
+void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader) {
switch (reader->buffer_in->type) {
case GRPC_BB_RAW:
/* keeping the same if-else structure as in the init function */
@@ -87,11 +88,11 @@ void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) {
}
}
-int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
- grpc_slice *slice) {
+int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
+ grpc_slice* slice) {
switch (reader->buffer_in->type) {
case GRPC_BB_RAW: {
- grpc_slice_buffer *slice_buffer;
+ grpc_slice_buffer* slice_buffer;
slice_buffer = &reader->buffer_out->data.raw.slice_buffer;
if (reader->current.index < slice_buffer->count) {
*slice = grpc_slice_ref_internal(
@@ -105,21 +106,21 @@ int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
return 0;
}
-grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader) {
+grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader) {
grpc_slice in_slice;
size_t bytes_read = 0;
const size_t input_size = grpc_byte_buffer_length(reader->buffer_out);
grpc_slice out_slice = GRPC_SLICE_MALLOC(input_size);
- uint8_t *const outbuf = GRPC_SLICE_START_PTR(out_slice); /* just an alias */
+ uint8_t* const outbuf = GRPC_SLICE_START_PTR(out_slice); /* just an alias */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (grpc_byte_buffer_reader_next(reader, &in_slice) != 0) {
const size_t slice_length = GRPC_SLICE_LENGTH(in_slice);
memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length);
bytes_read += slice_length;
- grpc_slice_unref_internal(&exec_ctx, in_slice);
+ grpc_slice_unref_internal(in_slice);
GPR_ASSERT(bytes_read <= input_size);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return out_slice;
}
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.cc
index 03f47553a1..ce63fa4d67 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.cc
@@ -33,14 +33,15 @@
#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/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/arena.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
+#include "src/core/lib/surface/call_test_only.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/validate_metadata.h"
@@ -85,7 +86,7 @@ typedef enum {
typedef struct {
bool is_set;
- grpc_error *error;
+ grpc_error* error;
} received_status;
static gpr_atm pack_received_status(received_status r) {
@@ -93,16 +94,17 @@ static gpr_atm pack_received_status(received_status r) {
}
static received_status unpack_received_status(gpr_atm atm) {
- return (atm & 1) == 0
- ? (received_status){.is_set = false, .error = GRPC_ERROR_NONE}
- : (received_status){.is_set = true,
- .error = (grpc_error *)(atm & ~(gpr_atm)1)};
+ if ((atm & 1) == 0) {
+ return {false, GRPC_ERROR_NONE};
+ } else {
+ return {true, (grpc_error*)(atm & ~(gpr_atm)1)};
+ }
}
#define MAX_ERRORS_PER_BATCH 4
typedef struct batch_control {
- grpc_call *call;
+ grpc_call* call;
/* Share memory for cq_completion and notify_tag as they are never needed
simultaneously. Each byte used in this data structure count as six bytes
per call, so any savings we can make are worthwhile,
@@ -118,7 +120,7 @@ typedef struct batch_control {
\a is_closure is true, \a tag indicates a closure to be invoked;
otherwise, \a tag indicates the tag to be used in the notification to
be sent to the completion queue. */
- void *tag;
+ void* tag;
bool is_closure;
} notify_tag;
} completion_data;
@@ -126,7 +128,7 @@ typedef struct batch_control {
grpc_closure finish_batch;
gpr_refcount steps_to_complete;
- grpc_error *errors[MAX_ERRORS_PER_BATCH];
+ grpc_error* errors[MAX_ERRORS_PER_BATCH];
gpr_atm num_errors;
grpc_transport_stream_op_batch op;
@@ -134,16 +136,16 @@ typedef struct batch_control {
typedef struct {
gpr_mu child_list_mu;
- grpc_call *first_child;
+ grpc_call* first_child;
} parent_call;
typedef struct {
- grpc_call *parent;
+ grpc_call* parent;
/** siblings: children of the same parent form a list, and this list is
protected under
parent->mu */
- grpc_call *sibling_next;
- grpc_call *sibling_prev;
+ grpc_call* sibling_next;
+ grpc_call* sibling_prev;
} child_call;
#define RECV_NONE ((gpr_atm)0)
@@ -151,14 +153,14 @@ typedef struct {
struct grpc_call {
gpr_refcount ext_ref;
- gpr_arena *arena;
+ gpr_arena* arena;
grpc_call_combiner call_combiner;
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
grpc_polling_entity pollent;
- grpc_channel *channel;
+ grpc_channel* channel;
gpr_timespec start_time;
/* parent_call* */ gpr_atm parent_call_atm;
- child_call *child;
+ child_call* child;
/* client or server call */
bool is_client;
@@ -176,7 +178,7 @@ struct grpc_call {
gpr_atm any_ops_sent_atm;
gpr_atm received_final_op_atm;
- batch_control *active_batches[MAX_CONCURRENT_BATCHES];
+ batch_control* active_batches[MAX_CONCURRENT_BATCHES];
grpc_transport_stream_op_batch_payload stream_op_payload;
/* first idx: is_receiving, second idx: is_trailing */
@@ -184,7 +186,7 @@ struct grpc_call {
/* Buffered read metadata waiting to be returned to the application.
Element 0 is initial metadata, element 1 is trailing metadata. */
- grpc_metadata_array *buffered_metadata[2];
+ grpc_metadata_array* buffered_metadata[2];
grpc_metadata compression_md;
@@ -199,7 +201,7 @@ struct grpc_call {
grpc_call_final_info final_info;
/* Compression algorithm for *incoming* data */
- grpc_compression_algorithm incoming_compression_algorithm;
+ grpc_message_compression_algorithm incoming_message_compression_algorithm;
/* Stream compression algorithm for *incoming* data */
grpc_stream_compression_algorithm incoming_stream_compression_algorithm;
/* Supported encodings (compression algorithms), a bitset */
@@ -214,12 +216,12 @@ struct grpc_call {
server, it's trailing metadata */
grpc_linked_mdelem send_extra_metadata[MAX_SEND_EXTRA_METADATA_COUNT];
int send_extra_metadata_count;
- gpr_timespec send_deadline;
+ grpc_millis send_deadline;
grpc_slice_buffer_stream sending_stream;
- grpc_byte_stream *receiving_stream;
- grpc_byte_buffer **receiving_buffer;
+ grpc_byte_stream* receiving_stream;
+ grpc_byte_buffer** receiving_buffer;
grpc_slice receiving_slice;
grpc_closure receiving_slice_ready;
grpc_closure receiving_stream_ready;
@@ -230,11 +232,12 @@ struct grpc_call {
union {
struct {
- grpc_status_code *status;
- grpc_slice *status_details;
+ grpc_status_code* status;
+ grpc_slice* status_details;
+ const char** error_string;
} client;
struct {
- int *cancelled;
+ int* cancelled;
} server;
} final_op;
@@ -257,83 +260,77 @@ struct grpc_call {
gpr_atm recv_state;
};
-grpc_tracer_flag grpc_call_error_trace =
- GRPC_TRACER_INITIALIZER(false, "call_error");
-grpc_tracer_flag grpc_compression_trace =
- GRPC_TRACER_INITIALIZER(false, "compression");
+grpc_core::TraceFlag grpc_call_error_trace(false, "call_error");
+grpc_core::TraceFlag grpc_compression_trace(false, "compression");
-#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1))
-#define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1)
+#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack*)((call) + 1))
+#define CALL_FROM_CALL_STACK(call_stack) (((grpc_call*)(call_stack)) - 1)
#define CALL_ELEM_FROM_CALL(call, idx) \
grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx)
#define CALL_FROM_TOP_ELEM(top_elem) \
CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))
-static void execute_batch(grpc_exec_ctx *exec_ctx, grpc_call *call,
- grpc_transport_stream_op_batch *op,
- grpc_closure *start_batch_closure);
-static void cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c,
- status_source source, grpc_status_code status,
- const char *description);
-static void cancel_with_error(grpc_exec_ctx *exec_ctx, grpc_call *c,
- status_source source, grpc_error *error);
-static void destroy_call(grpc_exec_ctx *exec_ctx, void *call_stack,
- grpc_error *error);
-static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
- grpc_error *error);
-static void get_final_status(grpc_call *call,
- void (*set_value)(grpc_status_code code,
- void *user_data),
- void *set_value_user_data, grpc_slice *details);
-static void set_status_value_directly(grpc_status_code status, void *dest);
-static void set_status_from_error(grpc_exec_ctx *exec_ctx, grpc_call *call,
- status_source source, grpc_error *error);
-static void process_data_after_md(grpc_exec_ctx *exec_ctx, batch_control *bctl);
-static void post_batch_completion(grpc_exec_ctx *exec_ctx, batch_control *bctl);
-static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl,
- grpc_error *error, bool has_cancelled);
-
-static void add_init_error(grpc_error **composite, grpc_error *new_err) {
+static void execute_batch(grpc_call* call, grpc_transport_stream_op_batch* op,
+ grpc_closure* start_batch_closure);
+static void cancel_with_status(grpc_call* c, status_source source,
+ grpc_status_code status,
+ const char* description);
+static void cancel_with_error(grpc_call* c, status_source source,
+ grpc_error* error);
+static void destroy_call(void* call_stack, grpc_error* error);
+static void receiving_slice_ready(void* bctlp, grpc_error* error);
+static void get_final_status(
+ grpc_call* call, void (*set_value)(grpc_status_code code, void* user_data),
+ void* set_value_user_data, grpc_slice* details, const char** error_string);
+static void set_status_value_directly(grpc_status_code status, void* dest);
+static void set_status_from_error(grpc_call* call, status_source source,
+ grpc_error* error);
+static void process_data_after_md(batch_control* bctl);
+static void post_batch_completion(batch_control* bctl);
+static void add_batch_error(batch_control* bctl, grpc_error* error,
+ bool has_cancelled);
+
+static void add_init_error(grpc_error** composite, grpc_error* new_err) {
if (new_err == GRPC_ERROR_NONE) return;
if (*composite == GRPC_ERROR_NONE)
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed");
*composite = grpc_error_add_child(*composite, new_err);
}
-void *grpc_call_arena_alloc(grpc_call *call, size_t size) {
+void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
return gpr_arena_alloc(call->arena, size);
}
-static parent_call *get_or_create_parent_call(grpc_call *call) {
- parent_call *p = (parent_call *)gpr_atm_acq_load(&call->parent_call_atm);
- if (p == NULL) {
- p = (parent_call *)gpr_arena_alloc(call->arena, sizeof(*p));
+static parent_call* get_or_create_parent_call(grpc_call* call) {
+ parent_call* p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
+ if (p == nullptr) {
+ p = (parent_call*)gpr_arena_alloc(call->arena, sizeof(*p));
gpr_mu_init(&p->child_list_mu);
- if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm)NULL, (gpr_atm)p)) {
+ if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm) nullptr,
+ (gpr_atm)p)) {
gpr_mu_destroy(&p->child_list_mu);
- p = (parent_call *)gpr_atm_acq_load(&call->parent_call_atm);
+ p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
}
}
return p;
}
-static parent_call *get_parent_call(grpc_call *call) {
- return (parent_call *)gpr_atm_acq_load(&call->parent_call_atm);
+static parent_call* get_parent_call(grpc_call* call) {
+ return (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
}
-grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
- const grpc_call_create_args *args,
- grpc_call **out_call) {
+grpc_error* grpc_call_create(const grpc_call_create_args* args,
+ grpc_call** out_call) {
size_t i, j;
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_channel_stack *channel_stack =
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_channel_stack* channel_stack =
grpc_channel_get_channel_stack(args->channel);
- grpc_call *call;
+ grpc_call* call;
GPR_TIMER_BEGIN("grpc_call_create", 0);
size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
- GRPC_STATS_INC_CALL_INITIAL_SIZE(exec_ctx, initial_size);
- gpr_arena *arena = gpr_arena_create(initial_size);
- call = (grpc_call *)gpr_arena_alloc(
+ GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
+ gpr_arena* arena = gpr_arena_create(initial_size);
+ call = (grpc_call*)gpr_arena_alloc(
arena, sizeof(grpc_call) + channel_stack->call_stack_size);
gpr_ref_init(&call->ext_ref, 1);
call->arena = arena;
@@ -343,12 +340,12 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
call->cq = args->cq;
call->start_time = gpr_now(GPR_CLOCK_MONOTONIC);
/* Always support no compression */
- GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_COMPRESS_NONE);
- call->is_client = args->server_transport_data == NULL;
+ GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_MESSAGE_COMPRESS_NONE);
+ call->is_client = args->server_transport_data == nullptr;
if (call->is_client) {
- GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx);
+ GRPC_STATS_INC_CLIENT_CALLS_CREATED();
} else {
- GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx);
+ GRPC_STATS_INC_SERVER_CALLS_CREATED();
}
call->stream_op_payload.context = call->context;
grpc_slice path = grpc_empty_slice();
@@ -370,32 +367,28 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
- call->metadata_batch[i][j].deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ call->metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE;
}
}
- gpr_timespec send_deadline =
- gpr_convert_clock_type(args->send_deadline, GPR_CLOCK_MONOTONIC);
+ grpc_millis send_deadline = args->send_deadline;
bool immediately_cancel = false;
- if (args->parent != NULL) {
- child_call *cc = call->child =
- (child_call *)gpr_arena_alloc(arena, sizeof(child_call));
+ if (args->parent != nullptr) {
+ child_call* cc = call->child =
+ (child_call*)gpr_arena_alloc(arena, sizeof(child_call));
call->child->parent = args->parent;
GRPC_CALL_INTERNAL_REF(args->parent, "child");
GPR_ASSERT(call->is_client);
GPR_ASSERT(!args->parent->is_client);
- parent_call *pc = get_or_create_parent_call(args->parent);
+ parent_call* pc = get_or_create_parent_call(args->parent);
gpr_mu_lock(&pc->child_list_mu);
if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) {
- send_deadline = gpr_time_min(
- gpr_convert_clock_type(send_deadline,
- args->parent->send_deadline.clock_type),
- args->parent->send_deadline);
+ send_deadline = GPR_MIN(send_deadline, args->parent->send_deadline);
}
/* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with
* GRPC_PROPAGATE_STATS_CONTEXT */
@@ -409,7 +402,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
}
grpc_call_context_set(call, GRPC_CONTEXT_TRACING,
args->parent->context[GRPC_CONTEXT_TRACING].value,
- NULL);
+ nullptr);
} else if (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
add_init_error(&error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Census context propagation requested "
@@ -422,7 +415,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
}
}
- if (pc->first_child == NULL) {
+ if (pc->first_child == nullptr) {
pc->first_child = call;
cc->sibling_next = cc->sibling_prev = call;
} else {
@@ -439,107 +432,102 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
/* initial refcount dropped by grpc_call_unref */
- grpc_call_element_args call_args = {
- .call_stack = CALL_STACK_FROM_CALL(call),
- .server_transport_data = args->server_transport_data,
- .context = call->context,
- .path = path,
- .start_time = call->start_time,
- .deadline = send_deadline,
- .arena = call->arena,
- .call_combiner = &call->call_combiner};
- add_init_error(&error, grpc_call_stack_init(exec_ctx, channel_stack, 1,
- destroy_call, call, &call_args));
+ grpc_call_element_args call_args = {CALL_STACK_FROM_CALL(call),
+ args->server_transport_data,
+ call->context,
+ path,
+ call->start_time,
+ send_deadline,
+ call->arena,
+ &call->call_combiner};
+ add_init_error(&error, grpc_call_stack_init(channel_stack, 1, destroy_call,
+ call, &call_args));
if (error != GRPC_ERROR_NONE) {
- cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_ERROR_REF(error));
+ cancel_with_error(call, STATUS_FROM_SURFACE, GRPC_ERROR_REF(error));
}
if (immediately_cancel) {
- cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
- GRPC_ERROR_CANCELLED);
+ cancel_with_error(call, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
}
- if (args->cq != NULL) {
- GPR_ASSERT(
- args->pollset_set_alternative == NULL &&
- "Only one of 'cq' and 'pollset_set_alternative' should be non-NULL.");
+ if (args->cq != nullptr) {
+ GPR_ASSERT(args->pollset_set_alternative == nullptr &&
+ "Only one of 'cq' and 'pollset_set_alternative' should be "
+ "non-nullptr.");
GRPC_CQ_INTERNAL_REF(args->cq, "bind");
call->pollent =
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq));
}
- if (args->pollset_set_alternative != NULL) {
+ if (args->pollset_set_alternative != nullptr) {
call->pollent = grpc_polling_entity_create_from_pollset_set(
args->pollset_set_alternative);
}
if (!grpc_polling_entity_is_empty(&call->pollent)) {
- grpc_call_stack_set_pollset_or_pollset_set(
- exec_ctx, CALL_STACK_FROM_CALL(call), &call->pollent);
+ grpc_call_stack_set_pollset_or_pollset_set(CALL_STACK_FROM_CALL(call),
+ &call->pollent);
}
- grpc_slice_unref_internal(exec_ctx, path);
+ grpc_slice_unref_internal(path);
GPR_TIMER_END("grpc_call_create", 0);
return error;
}
-void grpc_call_set_completion_queue(grpc_exec_ctx *exec_ctx, grpc_call *call,
- grpc_completion_queue *cq) {
+void grpc_call_set_completion_queue(grpc_call* call,
+ grpc_completion_queue* cq) {
GPR_ASSERT(cq);
- if (grpc_polling_entity_pollset_set(&call->pollent) != NULL) {
+ if (grpc_polling_entity_pollset_set(&call->pollent) != nullptr) {
gpr_log(GPR_ERROR, "A pollset_set is already registered for this call.");
abort();
}
call->cq = cq;
GRPC_CQ_INTERNAL_REF(cq, "bind");
call->pollent = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq));
- grpc_call_stack_set_pollset_or_pollset_set(
- exec_ctx, CALL_STACK_FROM_CALL(call), &call->pollent);
+ grpc_call_stack_set_pollset_or_pollset_set(CALL_STACK_FROM_CALL(call),
+ &call->pollent);
}
#ifndef NDEBUG
#define REF_REASON reason
-#define REF_ARG , const char *reason
+#define REF_ARG , const char* reason
#else
#define REF_REASON ""
#define REF_ARG
#endif
-void grpc_call_internal_ref(grpc_call *c REF_ARG) {
+void grpc_call_internal_ref(grpc_call* c REF_ARG) {
GRPC_CALL_STACK_REF(CALL_STACK_FROM_CALL(c), REF_REASON);
}
-void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *c REF_ARG) {
- GRPC_CALL_STACK_UNREF(exec_ctx, CALL_STACK_FROM_CALL(c), REF_REASON);
+void grpc_call_internal_unref(grpc_call* c REF_ARG) {
+ GRPC_CALL_STACK_UNREF(CALL_STACK_FROM_CALL(c), REF_REASON);
}
-static void release_call(grpc_exec_ctx *exec_ctx, void *call,
- grpc_error *error) {
- grpc_call *c = (grpc_call *)call;
- grpc_channel *channel = c->channel;
+static void release_call(void* call, grpc_error* error) {
+ grpc_call* c = (grpc_call*)call;
+ grpc_channel* channel = c->channel;
grpc_call_combiner_destroy(&c->call_combiner);
- gpr_free((char *)c->peer_string);
+ gpr_free((char*)c->peer_string);
grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(c->arena));
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, "call");
+ GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
}
-static void set_status_value_directly(grpc_status_code status, void *dest);
-static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
- grpc_error *error) {
+static void set_status_value_directly(grpc_status_code status, void* dest);
+static void destroy_call(void* call, grpc_error* error) {
size_t i;
int ii;
- grpc_call *c = (grpc_call *)call;
+ grpc_call* c = (grpc_call*)call;
GPR_TIMER_BEGIN("destroy_call", 0);
for (i = 0; i < 2; i++) {
grpc_metadata_batch_destroy(
- exec_ctx, &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
+ &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
}
- if (c->receiving_stream != NULL) {
- grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
+ if (c->receiving_stream != nullptr) {
+ grpc_byte_stream_destroy(c->receiving_stream);
}
- parent_call *pc = get_parent_call(c);
- if (pc != NULL) {
+ parent_call* pc = get_parent_call(c);
+ if (pc != nullptr) {
gpr_mu_destroy(&pc->child_list_mu);
}
for (ii = 0; ii < c->send_extra_metadata_count; ii++) {
- GRPC_MDELEM_UNREF(exec_ctx, c->send_extra_metadata[ii].md);
+ GRPC_MDELEM_UNREF(c->send_extra_metadata[ii].md);
}
for (i = 0; i < GRPC_CONTEXT_COUNT; i++) {
if (c->context[i].destroy) {
@@ -547,11 +535,11 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
}
}
if (c->cq) {
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind");
+ GRPC_CQ_INTERNAL_UNREF(c->cq, "bind");
}
get_final_status(c, set_status_value_directly, &c->final_info.final_status,
- NULL);
+ nullptr, c->final_info.error_string);
c->final_info.stats.latency =
gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time);
@@ -560,36 +548,36 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
unpack_received_status(gpr_atm_acq_load(&c->status[i])).error);
}
- grpc_call_stack_destroy(exec_ctx, CALL_STACK_FROM_CALL(c), &c->final_info,
+ grpc_call_stack_destroy(CALL_STACK_FROM_CALL(c), &c->final_info,
GRPC_CLOSURE_INIT(&c->release_call, release_call, c,
grpc_schedule_on_exec_ctx));
GPR_TIMER_END("destroy_call", 0);
}
-void grpc_call_ref(grpc_call *c) { gpr_ref(&c->ext_ref); }
+void grpc_call_ref(grpc_call* c) { gpr_ref(&c->ext_ref); }
-void grpc_call_unref(grpc_call *c) {
+void grpc_call_unref(grpc_call* c) {
if (!gpr_unref(&c->ext_ref)) return;
- child_call *cc = c->child;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ child_call* cc = c->child;
+ grpc_core::ExecCtx exec_ctx;
GPR_TIMER_BEGIN("grpc_call_unref", 0);
GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c));
if (cc) {
- parent_call *pc = get_parent_call(cc->parent);
+ parent_call* pc = get_parent_call(cc->parent);
gpr_mu_lock(&pc->child_list_mu);
if (c == pc->first_child) {
pc->first_child = cc->sibling_next;
if (c == pc->first_child) {
- pc->first_child = NULL;
+ pc->first_child = nullptr;
}
}
cc->sibling_prev->child->sibling_next = cc->sibling_next;
cc->sibling_next->child->sibling_prev = cc->sibling_prev;
gpr_mu_unlock(&pc->child_list_mu);
- GRPC_CALL_INTERNAL_UNREF(&exec_ctx, cc->parent, "child");
+ GRPC_CALL_INTERNAL_UNREF(cc->parent, "child");
}
GPR_ASSERT(!c->destroy_called);
@@ -597,64 +585,61 @@ void grpc_call_unref(grpc_call *c) {
bool cancel = gpr_atm_acq_load(&c->any_ops_sent_atm) != 0 &&
gpr_atm_acq_load(&c->received_final_op_atm) == 0;
if (cancel) {
- cancel_with_error(&exec_ctx, c, STATUS_FROM_API_OVERRIDE,
- GRPC_ERROR_CANCELLED);
+ cancel_with_error(c, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
} else {
// Unset the call combiner cancellation closure. This has the
// effect of scheduling the previously set cancellation closure, if
// any, so that it can release any internal references it may be
// holding to the call stack.
- grpc_call_combiner_set_notify_on_cancel(&exec_ctx, &c->call_combiner, NULL);
+ grpc_call_combiner_set_notify_on_cancel(&c->call_combiner, nullptr);
}
- GRPC_CALL_INTERNAL_UNREF(&exec_ctx, c, "destroy");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CALL_INTERNAL_UNREF(c, "destroy");
+
GPR_TIMER_END("grpc_call_unref", 0);
}
-grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved) {
+grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- cancel_with_error(&exec_ctx, call, STATUS_FROM_API_OVERRIDE,
- GRPC_ERROR_CANCELLED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ cancel_with_error(call, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
+
return GRPC_CALL_OK;
}
// This is called via the call combiner to start sending a batch down
// the filter stack.
-static void execute_batch_in_call_combiner(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *ignored) {
- grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg;
- grpc_call *call = (grpc_call *)batch->handler_private.extra_arg;
+static void execute_batch_in_call_combiner(void* arg, grpc_error* ignored) {
+ grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
+ grpc_call* call = (grpc_call*)batch->handler_private.extra_arg;
GPR_TIMER_BEGIN("execute_batch", 0);
- grpc_call_element *elem = CALL_ELEM_FROM_CALL(call, 0);
+ grpc_call_element* elem = CALL_ELEM_FROM_CALL(call, 0);
GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
- elem->filter->start_transport_stream_op_batch(exec_ctx, elem, batch);
+ elem->filter->start_transport_stream_op_batch(elem, batch);
GPR_TIMER_END("execute_batch", 0);
}
// start_batch_closure points to a caller-allocated closure to be used
// for entering the call combiner.
-static void execute_batch(grpc_exec_ctx *exec_ctx, grpc_call *call,
- grpc_transport_stream_op_batch *batch,
- grpc_closure *start_batch_closure) {
+static void execute_batch(grpc_call* call,
+ grpc_transport_stream_op_batch* batch,
+ grpc_closure* start_batch_closure) {
batch->handler_private.extra_arg = call;
GRPC_CLOSURE_INIT(start_batch_closure, execute_batch_in_call_combiner, batch,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, &call->call_combiner, start_batch_closure,
+ GRPC_CALL_COMBINER_START(&call->call_combiner, start_batch_closure,
GRPC_ERROR_NONE, "executing batch");
}
-char *grpc_call_get_peer(grpc_call *call) {
- char *peer_string = (char *)gpr_atm_acq_load(&call->peer_string);
- if (peer_string != NULL) return gpr_strdup(peer_string);
+char* grpc_call_get_peer(grpc_call* call) {
+ char* peer_string = (char*)gpr_atm_acq_load(&call->peer_string);
+ if (peer_string != nullptr) return gpr_strdup(peer_string);
peer_string = grpc_channel_get_target(call->channel);
- if (peer_string != NULL) return peer_string;
+ if (peer_string != nullptr) return peer_string;
return gpr_strdup("unknown");
}
-grpc_call *grpc_call_from_top_element(grpc_call_element *elem) {
+grpc_call* grpc_call_from_top_element(grpc_call_element* elem) {
return CALL_FROM_TOP_ELEM(elem);
}
@@ -662,61 +647,59 @@ grpc_call *grpc_call_from_top_element(grpc_call_element *elem) {
* CANCELLATION
*/
-grpc_call_error grpc_call_cancel_with_status(grpc_call *c,
+grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
grpc_status_code status,
- const char *description,
- void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ const char* description,
+ void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_call_cancel_with_status("
"c=%p, status=%d, description=%s, reserved=%p)",
4, (c, (int)status, description, reserved));
- GPR_ASSERT(reserved == NULL);
- cancel_with_status(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, status,
- description);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(reserved == nullptr);
+ cancel_with_status(c, STATUS_FROM_API_OVERRIDE, status, description);
+
return GRPC_CALL_OK;
}
typedef struct {
- grpc_call *call;
+ grpc_call* call;
grpc_closure start_batch;
grpc_closure finish_batch;
} cancel_state;
// The on_complete callback used when sending a cancel_stream batch down
// the filter stack. Yields the call combiner when the batch is done.
-static void done_termination(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- cancel_state *state = (cancel_state *)arg;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &state->call->call_combiner,
+static void done_termination(void* arg, grpc_error* error) {
+ cancel_state* state = (cancel_state*)arg;
+ GRPC_CALL_COMBINER_STOP(&state->call->call_combiner,
"on_complete for cancel_stream op");
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, state->call, "termination");
+ GRPC_CALL_INTERNAL_UNREF(state->call, "termination");
gpr_free(state);
}
-static void cancel_with_error(grpc_exec_ctx *exec_ctx, grpc_call *c,
- status_source source, grpc_error *error) {
+static void cancel_with_error(grpc_call* c, status_source source,
+ grpc_error* error) {
GRPC_CALL_INTERNAL_REF(c, "termination");
// Inform the call combiner of the cancellation, so that it can cancel
// any in-flight asynchronous actions that may be holding the call
// combiner. This ensures that the cancel_stream batch can be sent
// down the filter stack in a timely manner.
- grpc_call_combiner_cancel(exec_ctx, &c->call_combiner, GRPC_ERROR_REF(error));
- set_status_from_error(exec_ctx, c, source, GRPC_ERROR_REF(error));
- cancel_state *state = (cancel_state *)gpr_malloc(sizeof(*state));
+ grpc_call_combiner_cancel(&c->call_combiner, GRPC_ERROR_REF(error));
+ set_status_from_error(c, source, GRPC_ERROR_REF(error));
+ cancel_state* state = (cancel_state*)gpr_malloc(sizeof(*state));
state->call = c;
GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
grpc_schedule_on_exec_ctx);
- grpc_transport_stream_op_batch *op =
+ grpc_transport_stream_op_batch* op =
grpc_make_transport_stream_op(&state->finish_batch);
op->cancel_stream = true;
op->payload->cancel_stream.cancel_error = error;
- execute_batch(exec_ctx, c, op, &state->start_batch);
+ execute_batch(c, op, &state->start_batch);
}
-static grpc_error *error_from_status(grpc_status_code status,
- const char *description) {
+static grpc_error* error_from_status(grpc_status_code status,
+ const char* description) {
// copying 'description' is needed to ensure the grpc_call_cancel_with_status
// guarantee that can be short-lived.
return grpc_error_set_int(
@@ -726,11 +709,10 @@ static grpc_error *error_from_status(grpc_status_code status,
GRPC_ERROR_INT_GRPC_STATUS, status);
}
-static void cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c,
- status_source source, grpc_status_code status,
- const char *description) {
- cancel_with_error(exec_ctx, c, source,
- error_from_status(status, description));
+static void cancel_with_status(grpc_call* c, status_source source,
+ grpc_status_code status,
+ const char* description) {
+ cancel_with_error(c, source, error_from_status(status, description));
}
/*******************************************************************************
@@ -738,33 +720,33 @@ static void cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c,
*/
static bool get_final_status_from(
- grpc_call *call, grpc_error *error, bool allow_ok_status,
- void (*set_value)(grpc_status_code code, void *user_data),
- void *set_value_user_data, grpc_slice *details) {
+ grpc_call* call, grpc_error* error, bool allow_ok_status,
+ void (*set_value)(grpc_status_code code, void* user_data),
+ void* set_value_user_data, grpc_slice* details, const char** error_string) {
grpc_status_code code;
grpc_slice slice = grpc_empty_slice();
- grpc_error_get_status(error, call->send_deadline, &code, &slice, NULL);
+ grpc_error_get_status(error, call->send_deadline, &code, &slice, nullptr,
+ error_string);
if (code == GRPC_STATUS_OK && !allow_ok_status) {
return false;
}
set_value(code, set_value_user_data);
- if (details != NULL) {
+ if (details != nullptr) {
*details = grpc_slice_ref_internal(slice);
}
return true;
}
-static void get_final_status(grpc_call *call,
- void (*set_value)(grpc_status_code code,
- void *user_data),
- void *set_value_user_data, grpc_slice *details) {
+static void get_final_status(
+ grpc_call* call, void (*set_value)(grpc_status_code code, void* user_data),
+ void* set_value_user_data, grpc_slice* details, const char** error_string) {
int i;
received_status status[STATUS_SOURCE_COUNT];
for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
status[i] = unpack_received_status(gpr_atm_acq_load(&call->status[i]));
}
- if (GRPC_TRACER_ON(grpc_call_error_trace)) {
+ if (grpc_call_error_trace.enabled()) {
gpr_log(GPR_DEBUG, "get_final_status %s", call->is_client ? "CLI" : "SVR");
for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
if (status[i].is_set) {
@@ -781,7 +763,8 @@ static void get_final_status(grpc_call *call,
if (status[i].is_set &&
grpc_error_has_clear_grpc_status(status[i].error)) {
if (get_final_status_from(call, status[i].error, allow_ok_status != 0,
- set_value, set_value_user_data, details)) {
+ set_value, set_value_user_data, details,
+ error_string)) {
return;
}
}
@@ -790,7 +773,8 @@ static void get_final_status(grpc_call *call,
for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
if (status[i].is_set) {
if (get_final_status_from(call, status[i].error, allow_ok_status != 0,
- set_value, set_value_user_data, details)) {
+ set_value, set_value_user_data, details,
+ error_string)) {
return;
}
}
@@ -804,13 +788,11 @@ static void get_final_status(grpc_call *call,
}
}
-static void set_status_from_error(grpc_exec_ctx *exec_ctx, grpc_call *call,
- status_source source, grpc_error *error) {
+static void set_status_from_error(grpc_call* call, status_source source,
+ grpc_error* error) {
if (!gpr_atm_rel_cas(&call->status[source],
- pack_received_status((received_status){
- .is_set = false, .error = GRPC_ERROR_NONE}),
- pack_received_status((received_status){
- .is_set = true, .error = error}))) {
+ pack_received_status({false, GRPC_ERROR_NONE}),
+ pack_received_status({true, error}))) {
GRPC_ERROR_UNREF(error);
}
}
@@ -819,123 +801,82 @@ static void set_status_from_error(grpc_exec_ctx *exec_ctx, grpc_call *call,
* COMPRESSION
*/
-static void set_incoming_compression_algorithm(
- grpc_call *call, grpc_compression_algorithm algo) {
- GPR_ASSERT(algo < GRPC_COMPRESS_ALGORITHMS_COUNT);
- call->incoming_compression_algorithm = algo;
+static void set_incoming_message_compression_algorithm(
+ grpc_call* call, grpc_message_compression_algorithm algo) {
+ GPR_ASSERT(algo < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT);
+ call->incoming_message_compression_algorithm = algo;
}
static void set_incoming_stream_compression_algorithm(
- grpc_call *call, grpc_stream_compression_algorithm algo) {
+ grpc_call* call, grpc_stream_compression_algorithm algo) {
GPR_ASSERT(algo < GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT);
call->incoming_stream_compression_algorithm = algo;
}
grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
- grpc_call *call) {
- grpc_compression_algorithm algorithm;
- algorithm = call->incoming_compression_algorithm;
+ grpc_call* call) {
+ grpc_compression_algorithm algorithm = GRPC_COMPRESS_NONE;
+ grpc_compression_algorithm_from_message_stream_compression_algorithm(
+ &algorithm, call->incoming_message_compression_algorithm,
+ call->incoming_stream_compression_algorithm);
return algorithm;
}
static grpc_compression_algorithm compression_algorithm_for_level_locked(
- grpc_call *call, grpc_compression_level level) {
+ grpc_call* call, grpc_compression_level level) {
return grpc_compression_algorithm_for_level(level,
call->encodings_accepted_by_peer);
}
-static grpc_stream_compression_algorithm
-stream_compression_algorithm_for_level_locked(
- grpc_call *call, grpc_stream_compression_level level) {
- return grpc_stream_compression_algorithm_for_level(
- level, call->stream_encodings_accepted_by_peer);
-}
-
-uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) {
+uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) {
uint32_t flags;
flags = call->test_only_last_message_flags;
return flags;
}
-static void destroy_encodings_accepted_by_peer(void *p) { return; }
+static void destroy_encodings_accepted_by_peer(void* p) { return; }
-static void set_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx,
- grpc_call *call, grpc_mdelem mdel) {
+static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel,
+ uint32_t* encodings_accepted_by_peer,
+ bool stream_encoding) {
size_t i;
- grpc_compression_algorithm algorithm;
+ uint32_t algorithm;
grpc_slice_buffer accept_encoding_parts;
grpc_slice accept_encoding_slice;
- void *accepted_user_data;
+ void* accepted_user_data;
accepted_user_data =
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
- if (accepted_user_data != NULL) {
- call->encodings_accepted_by_peer =
+ if (accepted_user_data != nullptr) {
+ *encodings_accepted_by_peer =
(uint32_t)(((uintptr_t)accepted_user_data) - 1);
return;
}
+ *encodings_accepted_by_peer = 0;
+
accept_encoding_slice = GRPC_MDVALUE(mdel);
grpc_slice_buffer_init(&accept_encoding_parts);
- grpc_slice_split(accept_encoding_slice, ",", &accept_encoding_parts);
+ grpc_slice_split_without_space(accept_encoding_slice, ",",
+ &accept_encoding_parts);
- /* No need to zero call->encodings_accepted_by_peer: grpc_call_create already
- * zeroes the whole grpc_call */
- /* Always support no compression */
- GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_COMPRESS_NONE);
+ GPR_BITSET(encodings_accepted_by_peer, GRPC_COMPRESS_NONE);
for (i = 0; i < accept_encoding_parts.count; i++) {
+ int r;
grpc_slice accept_encoding_entry_slice = accept_encoding_parts.slices[i];
- if (grpc_compression_algorithm_parse(accept_encoding_entry_slice,
- &algorithm)) {
- GPR_BITSET(&call->encodings_accepted_by_peer, algorithm);
+ if (!stream_encoding) {
+ r = grpc_message_compression_algorithm_parse(
+ accept_encoding_entry_slice,
+ (grpc_message_compression_algorithm*)&algorithm);
} else {
- char *accept_encoding_entry_str =
- grpc_slice_to_c_string(accept_encoding_entry_slice);
- gpr_log(GPR_ERROR,
- "Invalid entry in accept encoding metadata: '%s'. Ignoring.",
- accept_encoding_entry_str);
- gpr_free(accept_encoding_entry_str);
+ r = grpc_stream_compression_algorithm_parse(
+ accept_encoding_entry_slice,
+ (grpc_stream_compression_algorithm*)&algorithm);
}
- }
-
- grpc_slice_buffer_destroy_internal(exec_ctx, &accept_encoding_parts);
-
- grpc_mdelem_set_user_data(
- mdel, destroy_encodings_accepted_by_peer,
- (void *)(((uintptr_t)call->encodings_accepted_by_peer) + 1));
-}
-
-static void set_stream_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx,
- grpc_call *call,
- grpc_mdelem mdel) {
- size_t i;
- grpc_stream_compression_algorithm algorithm;
- grpc_slice_buffer accept_encoding_parts;
- grpc_slice accept_encoding_slice;
- void *accepted_user_data;
-
- accepted_user_data =
- grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
- if (accepted_user_data != NULL) {
- call->stream_encodings_accepted_by_peer =
- (uint32_t)(((uintptr_t)accepted_user_data) - 1);
- return;
- }
-
- accept_encoding_slice = GRPC_MDVALUE(mdel);
- grpc_slice_buffer_init(&accept_encoding_parts);
- grpc_slice_split(accept_encoding_slice, ",", &accept_encoding_parts);
-
- /* Always support no compression */
- GPR_BITSET(&call->stream_encodings_accepted_by_peer,
- GRPC_STREAM_COMPRESS_NONE);
- for (i = 0; i < accept_encoding_parts.count; i++) {
- grpc_slice accept_encoding_entry_slice = accept_encoding_parts.slices[i];
- if (grpc_stream_compression_algorithm_parse(accept_encoding_entry_slice,
- &algorithm)) {
- GPR_BITSET(&call->stream_encodings_accepted_by_peer, algorithm);
+ if (r) {
+ GPR_BITSET(encodings_accepted_by_peer, algorithm);
} else {
- char *accept_encoding_entry_str =
+ char* accept_encoding_entry_str =
grpc_slice_to_c_string(accept_encoding_entry_slice);
gpr_log(GPR_ERROR,
"Invalid entry in accept encoding metadata: '%s'. Ignoring.",
@@ -944,56 +885,51 @@ static void set_stream_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx,
}
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &accept_encoding_parts);
+ grpc_slice_buffer_destroy_internal(&accept_encoding_parts);
grpc_mdelem_set_user_data(
mdel, destroy_encodings_accepted_by_peer,
- (void *)(((uintptr_t)call->stream_encodings_accepted_by_peer) + 1));
+ (void*)(((uintptr_t)(*encodings_accepted_by_peer)) + 1));
}
-uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call) {
+uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
uint32_t encodings_accepted_by_peer;
encodings_accepted_by_peer = call->encodings_accepted_by_peer;
return encodings_accepted_by_peer;
}
-uint32_t grpc_call_test_only_get_stream_encodings_accepted_by_peer(
- grpc_call *call) {
- uint32_t stream_encodings_accepted_by_peer;
- stream_encodings_accepted_by_peer = call->stream_encodings_accepted_by_peer;
- return stream_encodings_accepted_by_peer;
-}
-
grpc_stream_compression_algorithm
-grpc_call_test_only_get_incoming_stream_encodings(grpc_call *call) {
+grpc_call_test_only_get_incoming_stream_encodings(grpc_call* call) {
return call->incoming_stream_compression_algorithm;
}
-static grpc_linked_mdelem *linked_from_md(const grpc_metadata *md) {
- return (grpc_linked_mdelem *)&md->internal_data;
+static grpc_linked_mdelem* linked_from_md(const grpc_metadata* md) {
+ return (grpc_linked_mdelem*)&md->internal_data;
}
-static grpc_metadata *get_md_elem(grpc_metadata *metadata,
- grpc_metadata *additional_metadata, int i,
+static grpc_metadata* get_md_elem(grpc_metadata* metadata,
+ grpc_metadata* additional_metadata, int i,
int count) {
- grpc_metadata *res =
+ grpc_metadata* res =
i < count ? &metadata[i] : &additional_metadata[i - count];
GPR_ASSERT(res);
return res;
}
-static int prepare_application_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call *call, int count,
- grpc_metadata *metadata, int is_trailing, int prepend_extra_metadata,
- grpc_metadata *additional_metadata, int additional_metadata_count) {
+static int prepare_application_metadata(grpc_call* call, int count,
+ grpc_metadata* metadata,
+ int is_trailing,
+ int prepend_extra_metadata,
+ grpc_metadata* additional_metadata,
+ int additional_metadata_count) {
int total_count = count + additional_metadata_count;
int i;
- grpc_metadata_batch *batch =
+ grpc_metadata_batch* batch =
&call->metadata_batch[0 /* is_receiving */][is_trailing];
for (i = 0; i < total_count; i++) {
- const grpc_metadata *md =
+ const grpc_metadata* md =
get_md_elem(metadata, additional_metadata, i, count);
- grpc_linked_mdelem *l = linked_from_md(md);
+ grpc_linked_mdelem* l = linked_from_md(md);
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
if (!GRPC_LOG_IF_ERROR("validate_metadata",
grpc_validate_header_key_is_legal(md->key))) {
@@ -1004,14 +940,14 @@ static int prepare_application_metadata(
grpc_validate_header_nonbin_value_is_legal(md->value))) {
break;
}
- l->md = grpc_mdelem_from_grpc_metadata(exec_ctx, (grpc_metadata *)md);
+ l->md = grpc_mdelem_from_grpc_metadata((grpc_metadata*)md);
}
if (i != total_count) {
for (int j = 0; j < i; j++) {
- const grpc_metadata *md =
+ const grpc_metadata* md =
get_md_elem(metadata, additional_metadata, j, count);
- grpc_linked_mdelem *l = linked_from_md(md);
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ grpc_linked_mdelem* l = linked_from_md(md);
+ GRPC_MDELEM_UNREF(l->md);
}
return 0;
}
@@ -1022,16 +958,16 @@ static int prepare_application_metadata(
for (i = 0; i < call->send_extra_metadata_count; i++) {
GRPC_LOG_IF_ERROR("prepare_application_metadata",
grpc_metadata_batch_link_tail(
- exec_ctx, batch, &call->send_extra_metadata[i]));
+ batch, &call->send_extra_metadata[i]));
}
}
}
for (i = 0; i < total_count; i++) {
- grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count);
- grpc_linked_mdelem *l = linked_from_md(md);
- grpc_error *error = grpc_metadata_batch_link_tail(exec_ctx, batch, l);
+ grpc_metadata* md = get_md_elem(metadata, additional_metadata, i, count);
+ grpc_linked_mdelem* l = linked_from_md(md);
+ grpc_error* error = grpc_metadata_batch_link_tail(batch, l);
if (error != GRPC_ERROR_NONE) {
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ GRPC_MDELEM_UNREF(l->md);
}
GRPC_LOG_IF_ERROR("prepare_application_metadata", error);
}
@@ -1044,38 +980,39 @@ static int prepare_application_metadata(
as metadata cannot store a 0 value (which is used as OK for grpc_status_codes
*/
#define STATUS_OFFSET 1
-static void destroy_status(void *ignored) {}
+static void destroy_status(void* ignored) {}
static uint32_t decode_status(grpc_mdelem md) {
uint32_t status;
- void *user_data;
+ void* user_data;
if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) return 0;
if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_1)) return 1;
if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_2)) return 2;
user_data = grpc_mdelem_get_user_data(md, destroy_status);
- if (user_data != NULL) {
+ if (user_data != nullptr) {
status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET;
} else {
if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(md), &status)) {
status = GRPC_STATUS_UNKNOWN; /* could not parse status code */
}
grpc_mdelem_set_user_data(md, destroy_status,
- (void *)(intptr_t)(status + STATUS_OFFSET));
+ (void*)(intptr_t)(status + STATUS_OFFSET));
}
return status;
}
-static grpc_compression_algorithm decode_compression(grpc_mdelem md) {
- grpc_compression_algorithm algorithm =
- grpc_compression_algorithm_from_slice(GRPC_MDVALUE(md));
- if (algorithm == GRPC_COMPRESS_ALGORITHMS_COUNT) {
- char *md_c_str = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+static grpc_message_compression_algorithm decode_message_compression(
+ grpc_mdelem md) {
+ grpc_message_compression_algorithm algorithm =
+ grpc_message_compression_algorithm_from_slice(GRPC_MDVALUE(md));
+ if (algorithm == GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT) {
+ char* md_c_str = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR,
- "Invalid incoming compression algorithm: '%s'. Interpreting "
- "incoming data as uncompressed.",
+ "Invalid incoming message compression algorithm: '%s'. "
+ "Interpreting incoming data as uncompressed.",
md_c_str);
gpr_free(md_c_str);
- return GRPC_COMPRESS_NONE;
+ return GRPC_MESSAGE_COMPRESS_NONE;
}
return algorithm;
}
@@ -1085,7 +1022,7 @@ static grpc_stream_compression_algorithm decode_stream_compression(
grpc_stream_compression_algorithm algorithm =
grpc_stream_compression_algorithm_from_slice(GRPC_MDVALUE(md));
if (algorithm == GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) {
- char *md_c_str = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ char* md_c_str = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR,
"Invalid incoming stream compression algorithm: '%s'. Interpreting "
"incoming data as uncompressed.",
@@ -1096,20 +1033,20 @@ static grpc_stream_compression_algorithm decode_stream_compression(
return algorithm;
}
-static void publish_app_metadata(grpc_call *call, grpc_metadata_batch *b,
+static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
int is_trailing) {
if (b->list.count == 0) return;
GPR_TIMER_BEGIN("publish_app_metadata", 0);
- grpc_metadata_array *dest;
- grpc_metadata *mdusr;
+ grpc_metadata_array* dest;
+ grpc_metadata* mdusr;
dest = call->buffered_metadata[is_trailing];
if (dest->count + b->list.count > dest->capacity) {
dest->capacity =
GPR_MAX(dest->capacity + b->list.count, dest->capacity * 3 / 2);
- dest->metadata = (grpc_metadata *)gpr_realloc(
+ dest->metadata = (grpc_metadata*)gpr_realloc(
dest->metadata, sizeof(grpc_metadata) * dest->capacity);
}
- for (grpc_linked_mdelem *l = b->list.head; l != NULL; l = l->next) {
+ for (grpc_linked_mdelem* l = b->list.head; l != nullptr; l = l->next) {
mdusr = &dest->metadata[dest->count++];
/* we pass back borrowed slices that are valid whilst the call is valid */
mdusr->key = GRPC_MDKEY(l->md);
@@ -1118,72 +1055,71 @@ static void publish_app_metadata(grpc_call *call, grpc_metadata_batch *b,
GPR_TIMER_END("publish_app_metadata", 0);
}
-static void recv_initial_filter(grpc_exec_ctx *exec_ctx, grpc_call *call,
- grpc_metadata_batch *b) {
- if (b->idx.named.content_encoding != NULL) {
- if (b->idx.named.grpc_encoding != NULL) {
- gpr_log(GPR_ERROR,
- "Received both content-encoding and grpc-encoding header. "
- "Ignoring grpc-encoding.");
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_encoding);
- }
+static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) {
+ if (b->idx.named.content_encoding != nullptr) {
GPR_TIMER_BEGIN("incoming_stream_compression_algorithm", 0);
set_incoming_stream_compression_algorithm(
call, decode_stream_compression(b->idx.named.content_encoding->md));
GPR_TIMER_END("incoming_stream_compression_algorithm", 0);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_encoding);
- } else if (b->idx.named.grpc_encoding != NULL) {
- GPR_TIMER_BEGIN("incoming_compression_algorithm", 0);
- set_incoming_compression_algorithm(
- call, decode_compression(b->idx.named.grpc_encoding->md));
- GPR_TIMER_END("incoming_compression_algorithm", 0);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_encoding);
- }
- if (b->idx.named.grpc_accept_encoding != NULL) {
+ grpc_metadata_batch_remove(b, b->idx.named.content_encoding);
+ }
+ if (b->idx.named.grpc_encoding != nullptr) {
+ GPR_TIMER_BEGIN("incoming_message_compression_algorithm", 0);
+ set_incoming_message_compression_algorithm(
+ call, decode_message_compression(b->idx.named.grpc_encoding->md));
+ GPR_TIMER_END("incoming_message_compression_algorithm", 0);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_encoding);
+ }
+ uint32_t message_encodings_accepted_by_peer = 1u;
+ uint32_t stream_encodings_accepted_by_peer = 1u;
+ if (b->idx.named.grpc_accept_encoding != nullptr) {
GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0);
- set_encodings_accepted_by_peer(exec_ctx, call,
- b->idx.named.grpc_accept_encoding->md);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_accept_encoding);
+ set_encodings_accepted_by_peer(call, b->idx.named.grpc_accept_encoding->md,
+ &message_encodings_accepted_by_peer, false);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_accept_encoding);
GPR_TIMER_END("encodings_accepted_by_peer", 0);
}
- if (b->idx.named.accept_encoding != NULL) {
+ if (b->idx.named.accept_encoding != nullptr) {
GPR_TIMER_BEGIN("stream_encodings_accepted_by_peer", 0);
- set_stream_encodings_accepted_by_peer(exec_ctx, call,
- b->idx.named.accept_encoding->md);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.accept_encoding);
+ set_encodings_accepted_by_peer(call, b->idx.named.accept_encoding->md,
+ &stream_encodings_accepted_by_peer, true);
+ grpc_metadata_batch_remove(b, b->idx.named.accept_encoding);
GPR_TIMER_END("stream_encodings_accepted_by_peer", 0);
}
+ call->encodings_accepted_by_peer =
+ grpc_compression_bitset_from_message_stream_compression_bitset(
+ message_encodings_accepted_by_peer,
+ stream_encodings_accepted_by_peer);
publish_app_metadata(call, b, false);
}
-static void recv_trailing_filter(grpc_exec_ctx *exec_ctx, void *args,
- grpc_metadata_batch *b) {
- grpc_call *call = (grpc_call *)args;
- if (b->idx.named.grpc_status != NULL) {
+static void recv_trailing_filter(void* args, grpc_metadata_batch* b) {
+ grpc_call* call = (grpc_call*)args;
+ if (b->idx.named.grpc_status != nullptr) {
uint32_t status_code = decode_status(b->idx.named.grpc_status->md);
- grpc_error *error =
+ grpc_error* error =
status_code == GRPC_STATUS_OK
? GRPC_ERROR_NONE
: grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error received from peer"),
GRPC_ERROR_INT_GRPC_STATUS,
(intptr_t)status_code);
- if (b->idx.named.grpc_message != NULL) {
+ if (b->idx.named.grpc_message != nullptr) {
error = grpc_error_set_str(
error, GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_message->md)));
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_message);
} else if (error != GRPC_ERROR_NONE) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_empty_slice());
}
- set_status_from_error(exec_ctx, call, STATUS_FROM_WIRE, error);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_status);
+ set_status_from_error(call, STATUS_FROM_WIRE, error);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_status);
}
publish_app_metadata(call, b, true);
}
-grpc_call_stack *grpc_call_get_call_stack(grpc_call *call) {
+grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
return CALL_STACK_FROM_CALL(call);
}
@@ -1191,12 +1127,12 @@ grpc_call_stack *grpc_call_get_call_stack(grpc_call *call) {
* BATCH API IMPLEMENTATION
*/
-static void set_status_value_directly(grpc_status_code status, void *dest) {
- *(grpc_status_code *)dest = status;
+static void set_status_value_directly(grpc_status_code status, void* dest) {
+ *(grpc_status_code*)dest = status;
}
-static void set_cancelled_value(grpc_status_code status, void *dest) {
- *(int *)dest = (status != GRPC_STATUS_OK);
+static void set_cancelled_value(grpc_status_code status, void* dest) {
+ *(int*)dest = (status != GRPC_STATUS_OK);
}
static bool are_write_flags_valid(uint32_t flags) {
@@ -1236,18 +1172,18 @@ static int batch_slot_for_op(grpc_op_type type) {
GPR_UNREACHABLE_CODE(return 123456789);
}
-static batch_control *allocate_batch_control(grpc_call *call,
- const grpc_op *ops,
+static batch_control* allocate_batch_control(grpc_call* call,
+ const grpc_op* ops,
size_t num_ops) {
int slot = batch_slot_for_op(ops[0].op);
- batch_control **pslot = &call->active_batches[slot];
- if (*pslot == NULL) {
+ batch_control** pslot = &call->active_batches[slot];
+ if (*pslot == nullptr) {
*pslot =
- (batch_control *)gpr_arena_alloc(call->arena, sizeof(batch_control));
+ (batch_control*)gpr_arena_alloc(call->arena, sizeof(batch_control));
}
- batch_control *bctl = *pslot;
- if (bctl->call != NULL) {
- return NULL;
+ batch_control* bctl = *pslot;
+ if (bctl->call != nullptr) {
+ return nullptr;
}
memset(bctl, 0, sizeof(*bctl));
bctl->call = call;
@@ -1255,44 +1191,43 @@ static batch_control *allocate_batch_control(grpc_call *call,
return bctl;
}
-static void finish_batch_completion(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_cq_completion *storage) {
- batch_control *bctl = (batch_control *)user_data;
- grpc_call *call = bctl->call;
- bctl->call = NULL;
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
+static void finish_batch_completion(void* user_data,
+ grpc_cq_completion* storage) {
+ batch_control* bctl = (batch_control*)user_data;
+ grpc_call* call = bctl->call;
+ bctl->call = nullptr;
+ GRPC_CALL_INTERNAL_UNREF(call, "completion");
}
-static grpc_error *consolidate_batch_errors(batch_control *bctl) {
+static grpc_error* consolidate_batch_errors(batch_control* bctl) {
size_t n = (size_t)gpr_atm_acq_load(&bctl->num_errors);
if (n == 0) {
return GRPC_ERROR_NONE;
} else if (n == 1) {
/* Skip creating a composite error in the case that only one error was
logged */
- grpc_error *e = bctl->errors[0];
- bctl->errors[0] = NULL;
+ grpc_error* e = bctl->errors[0];
+ bctl->errors[0] = nullptr;
return e;
} else {
- grpc_error *error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ grpc_error* error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Call batch failed", bctl->errors, n);
for (size_t i = 0; i < n; i++) {
GRPC_ERROR_UNREF(bctl->errors[i]);
- bctl->errors[i] = NULL;
+ bctl->errors[i] = nullptr;
}
return error;
}
}
-static void post_batch_completion(grpc_exec_ctx *exec_ctx,
- batch_control *bctl) {
- grpc_call *next_child_call;
- grpc_call *call = bctl->call;
- grpc_error *error = consolidate_batch_errors(bctl);
+static void post_batch_completion(batch_control* bctl) {
+ grpc_call* next_child_call;
+ grpc_call* call = bctl->call;
+ grpc_error* error = consolidate_batch_errors(bctl);
if (bctl->op.send_initial_metadata) {
grpc_metadata_batch_destroy(
- exec_ctx,
+
&call->metadata_batch[0 /* is_receiving */][0 /* is_trailing */]);
}
if (bctl->op.send_message) {
@@ -1300,29 +1235,29 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
}
if (bctl->op.send_trailing_metadata) {
grpc_metadata_batch_destroy(
- exec_ctx,
+
&call->metadata_batch[0 /* is_receiving */][1 /* is_trailing */]);
}
if (bctl->op.recv_trailing_metadata) {
- grpc_metadata_batch *md =
+ grpc_metadata_batch* md =
&call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */];
- recv_trailing_filter(exec_ctx, call, md);
+ recv_trailing_filter(call, md);
/* propagate cancellation to any interested children */
gpr_atm_rel_store(&call->received_final_op_atm, 1);
- parent_call *pc = get_parent_call(call);
- if (pc != NULL) {
- grpc_call *child;
+ parent_call* pc = get_parent_call(call);
+ if (pc != nullptr) {
+ grpc_call* child;
gpr_mu_lock(&pc->child_list_mu);
child = pc->first_child;
- if (child != NULL) {
+ if (child != nullptr) {
do {
next_child_call = child->child->sibling_next;
if (child->cancellation_is_inherited) {
GRPC_CALL_INTERNAL_REF(child, "propagate_cancel");
- cancel_with_error(exec_ctx, child, STATUS_FROM_API_OVERRIDE,
+ cancel_with_error(child, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED);
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, child, "propagate_cancel");
+ GRPC_CALL_INTERNAL_UNREF(child, "propagate_cancel");
}
child = next_child_call;
} while (child != pc->first_child);
@@ -1333,64 +1268,69 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
if (call->is_client) {
get_final_status(call, set_status_value_directly,
call->final_op.client.status,
- call->final_op.client.status_details);
+ call->final_op.client.status_details,
+ call->final_op.client.error_string);
} else {
get_final_status(call, set_cancelled_value,
- call->final_op.server.cancelled, NULL);
+ call->final_op.server.cancelled, nullptr, nullptr);
}
GRPC_ERROR_UNREF(error);
error = GRPC_ERROR_NONE;
}
+ if (error != GRPC_ERROR_NONE && bctl->op.recv_message &&
+ *call->receiving_buffer != nullptr) {
+ grpc_byte_buffer_destroy(*call->receiving_buffer);
+ *call->receiving_buffer = nullptr;
+ }
if (bctl->completion_data.notify_tag.is_closure) {
/* unrefs bctl->error */
- bctl->call = NULL;
- GRPC_CLOSURE_RUN(
- exec_ctx, (grpc_closure *)bctl->completion_data.notify_tag.tag, error);
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
+ bctl->call = nullptr;
+ GRPC_CLOSURE_RUN((grpc_closure*)bctl->completion_data.notify_tag.tag,
+ error);
+ GRPC_CALL_INTERNAL_UNREF(call, "completion");
} else {
/* unrefs bctl->error */
- grpc_cq_end_op(
- exec_ctx, bctl->call->cq, bctl->completion_data.notify_tag.tag, error,
- finish_batch_completion, bctl, &bctl->completion_data.cq_completion);
+ grpc_cq_end_op(bctl->call->cq, bctl->completion_data.notify_tag.tag, error,
+ finish_batch_completion, bctl,
+ &bctl->completion_data.cq_completion);
}
}
-static void finish_batch_step(grpc_exec_ctx *exec_ctx, batch_control *bctl) {
+static void finish_batch_step(batch_control* bctl) {
if (gpr_unref(&bctl->steps_to_complete)) {
- post_batch_completion(exec_ctx, bctl);
+ post_batch_completion(bctl);
}
}
-static void continue_receiving_slices(grpc_exec_ctx *exec_ctx,
- batch_control *bctl) {
- grpc_error *error;
- grpc_call *call = bctl->call;
+static void continue_receiving_slices(batch_control* bctl) {
+ grpc_error* error;
+ grpc_call* call = bctl->call;
for (;;) {
size_t remaining = call->receiving_stream->length -
(*call->receiving_buffer)->data.raw.slice_buffer.length;
if (remaining == 0) {
call->receiving_message = 0;
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
- finish_batch_step(exec_ctx, bctl);
+ grpc_byte_stream_destroy(call->receiving_stream);
+ call->receiving_stream = nullptr;
+ finish_batch_step(bctl);
return;
}
- if (grpc_byte_stream_next(exec_ctx, call->receiving_stream, remaining,
+ if (grpc_byte_stream_next(call->receiving_stream, remaining,
&call->receiving_slice_ready)) {
- error = grpc_byte_stream_pull(exec_ctx, call->receiving_stream,
- &call->receiving_slice);
+ error =
+ grpc_byte_stream_pull(call->receiving_stream, &call->receiving_slice);
if (error == GRPC_ERROR_NONE) {
grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
call->receiving_slice);
} else {
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
+ grpc_byte_stream_destroy(call->receiving_stream);
+ call->receiving_stream = nullptr;
grpc_byte_buffer_destroy(*call->receiving_buffer);
- *call->receiving_buffer = NULL;
+ *call->receiving_buffer = nullptr;
call->receiving_message = 0;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
return;
}
} else {
@@ -1399,20 +1339,19 @@ static void continue_receiving_slices(grpc_exec_ctx *exec_ctx,
}
}
-static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
- grpc_error *error) {
- batch_control *bctl = (batch_control *)bctlp;
- grpc_call *call = bctl->call;
- grpc_byte_stream *bs = call->receiving_stream;
+static void receiving_slice_ready(void* bctlp, grpc_error* error) {
+ batch_control* bctl = (batch_control*)bctlp;
+ grpc_call* call = bctl->call;
+ grpc_byte_stream* bs = call->receiving_stream;
bool release_error = false;
if (error == GRPC_ERROR_NONE) {
grpc_slice slice;
- error = grpc_byte_stream_pull(exec_ctx, bs, &slice);
+ error = grpc_byte_stream_pull(bs, &slice);
if (error == GRPC_ERROR_NONE) {
grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
slice);
- continue_receiving_slices(exec_ctx, bctl);
+ continue_receiving_slices(bctl);
} else {
/* Error returned by grpc_byte_stream_pull needs to be released manually
*/
@@ -1421,206 +1360,179 @@ static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
}
if (error != GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_trace_operation_failures)) {
+ if (grpc_trace_operation_failures.enabled()) {
GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
}
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
+ grpc_byte_stream_destroy(call->receiving_stream);
+ call->receiving_stream = nullptr;
grpc_byte_buffer_destroy(*call->receiving_buffer);
- *call->receiving_buffer = NULL;
+ *call->receiving_buffer = nullptr;
call->receiving_message = 0;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
if (release_error) {
GRPC_ERROR_UNREF(error);
}
}
}
-static void process_data_after_md(grpc_exec_ctx *exec_ctx,
- batch_control *bctl) {
- grpc_call *call = bctl->call;
- if (call->receiving_stream == NULL) {
- *call->receiving_buffer = NULL;
+static void process_data_after_md(batch_control* bctl) {
+ grpc_call* call = bctl->call;
+ if (call->receiving_stream == nullptr) {
+ *call->receiving_buffer = nullptr;
call->receiving_message = 0;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
} else {
call->test_only_last_message_flags = call->receiving_stream->flags;
if ((call->receiving_stream->flags & GRPC_WRITE_INTERNAL_COMPRESS) &&
- (call->incoming_compression_algorithm > GRPC_COMPRESS_NONE)) {
- *call->receiving_buffer = grpc_raw_compressed_byte_buffer_create(
- NULL, 0, call->incoming_compression_algorithm);
+ (call->incoming_message_compression_algorithm >
+ GRPC_MESSAGE_COMPRESS_NONE)) {
+ grpc_compression_algorithm algo;
+ GPR_ASSERT(
+ grpc_compression_algorithm_from_message_stream_compression_algorithm(
+ &algo, call->incoming_message_compression_algorithm,
+ (grpc_stream_compression_algorithm)0));
+ *call->receiving_buffer =
+ grpc_raw_compressed_byte_buffer_create(nullptr, 0, algo);
} else {
- *call->receiving_buffer = grpc_raw_byte_buffer_create(NULL, 0);
+ *call->receiving_buffer = grpc_raw_byte_buffer_create(nullptr, 0);
}
GRPC_CLOSURE_INIT(&call->receiving_slice_ready, receiving_slice_ready, bctl,
grpc_schedule_on_exec_ctx);
- continue_receiving_slices(exec_ctx, bctl);
+ continue_receiving_slices(bctl);
}
}
-static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
- grpc_error *error) {
- batch_control *bctl = (batch_control *)bctlp;
- grpc_call *call = bctl->call;
+static void receiving_stream_ready(void* bctlp, grpc_error* error) {
+ batch_control* bctl = (batch_control*)bctlp;
+ grpc_call* call = bctl->call;
if (error != GRPC_ERROR_NONE) {
- if (call->receiving_stream != NULL) {
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
+ if (call->receiving_stream != nullptr) {
+ grpc_byte_stream_destroy(call->receiving_stream);
+ call->receiving_stream = nullptr;
}
- add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), true);
- cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_ERROR_REF(error));
+ add_batch_error(bctl, GRPC_ERROR_REF(error), true);
+ cancel_with_error(call, STATUS_FROM_SURFACE, GRPC_ERROR_REF(error));
}
/* If recv_state is RECV_NONE, we will save the batch_control
* object with rel_cas, and will not use it after the cas. Its corresponding
* acq_load is in receiving_initial_metadata_ready() */
- if (error != GRPC_ERROR_NONE || call->receiving_stream == NULL ||
+ if (error != GRPC_ERROR_NONE || call->receiving_stream == nullptr ||
!gpr_atm_rel_cas(&call->recv_state, RECV_NONE, (gpr_atm)bctlp)) {
- process_data_after_md(exec_ctx, bctl);
+ process_data_after_md(bctl);
}
}
// The recv_message_ready callback used when sending a batch containing
// a recv_message op down the filter stack. Yields the call combiner
// before processing the received message.
-static void receiving_stream_ready_in_call_combiner(grpc_exec_ctx *exec_ctx,
- void *bctlp,
- grpc_error *error) {
- batch_control *bctl = (batch_control *)bctlp;
- grpc_call *call = bctl->call;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &call->call_combiner, "recv_message_ready");
- receiving_stream_ready(exec_ctx, bctlp, error);
-}
-
-static void validate_filtered_metadata(grpc_exec_ctx *exec_ctx,
- batch_control *bctl) {
- grpc_call *call = bctl->call;
- /* validate compression algorithms */
+static void receiving_stream_ready_in_call_combiner(void* bctlp,
+ grpc_error* error) {
+ batch_control* bctl = (batch_control*)bctlp;
+ grpc_call* call = bctl->call;
+ GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_message_ready");
+ receiving_stream_ready(bctlp, error);
+}
+
+static void validate_filtered_metadata(batch_control* bctl) {
+ grpc_compression_algorithm compression_algorithm;
+ grpc_call* call = bctl->call;
if (call->incoming_stream_compression_algorithm !=
- GRPC_STREAM_COMPRESS_NONE) {
- const grpc_stream_compression_algorithm algo =
- call->incoming_stream_compression_algorithm;
- char *error_msg = NULL;
- const grpc_compression_options compression_options =
- grpc_channel_compression_options(call->channel);
- if (algo >= GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) {
- gpr_asprintf(&error_msg,
- "Invalid stream compression algorithm value '%d'.", algo);
- gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
- } else if (grpc_compression_options_is_stream_compression_algorithm_enabled(
- &compression_options, algo) == 0) {
- /* check if algorithm is supported by current channel config */
- const char *algo_name = NULL;
- grpc_stream_compression_algorithm_name(algo, &algo_name);
- gpr_asprintf(&error_msg, "Stream compression algorithm '%s' is disabled.",
- algo_name);
- gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
- }
+ GRPC_STREAM_COMPRESS_NONE &&
+ call->incoming_message_compression_algorithm !=
+ GRPC_MESSAGE_COMPRESS_NONE) {
+ char* error_msg = nullptr;
+ gpr_asprintf(&error_msg,
+ "Incoming stream has both stream compression (%d) and message "
+ "compression (%d).",
+ call->incoming_stream_compression_algorithm,
+ call->incoming_message_compression_algorithm);
+ gpr_log(GPR_ERROR, "%s", error_msg);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_INTERNAL,
+ error_msg);
gpr_free(error_msg);
-
- GPR_ASSERT(call->stream_encodings_accepted_by_peer != 0);
- if (!GPR_BITGET(call->stream_encodings_accepted_by_peer,
- call->incoming_stream_compression_algorithm)) {
- if (GRPC_TRACER_ON(grpc_compression_trace)) {
- const char *algo_name = NULL;
- grpc_stream_compression_algorithm_name(
- call->incoming_stream_compression_algorithm, &algo_name);
- gpr_log(
- GPR_ERROR,
- "Stream compression algorithm (content-encoding = '%s') not "
- "present in the bitset of accepted encodings (accept-encodings: "
- "'0x%x')",
- algo_name, call->stream_encodings_accepted_by_peer);
- }
- }
- } else if (call->incoming_compression_algorithm != GRPC_COMPRESS_NONE) {
- const grpc_compression_algorithm algo =
- call->incoming_compression_algorithm;
- char *error_msg = NULL;
+ } else if (
+ grpc_compression_algorithm_from_message_stream_compression_algorithm(
+ &compression_algorithm, call->incoming_message_compression_algorithm,
+ call->incoming_stream_compression_algorithm) == 0) {
+ char* error_msg = nullptr;
+ gpr_asprintf(&error_msg,
+ "Error in incoming message compression (%d) or stream "
+ "compression (%d).",
+ call->incoming_stream_compression_algorithm,
+ call->incoming_message_compression_algorithm);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_INTERNAL,
+ error_msg);
+ gpr_free(error_msg);
+ } else {
+ char* error_msg = nullptr;
const grpc_compression_options compression_options =
grpc_channel_compression_options(call->channel);
- /* check if algorithm is known */
- if (algo >= GRPC_COMPRESS_ALGORITHMS_COUNT) {
+ if (compression_algorithm >= GRPC_COMPRESS_ALGORITHMS_COUNT) {
gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.",
- algo);
+ compression_algorithm);
gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_UNIMPLEMENTED,
+ error_msg);
} else if (grpc_compression_options_is_algorithm_enabled(
- &compression_options, algo) == 0) {
+ &compression_options, compression_algorithm) == 0) {
/* check if algorithm is supported by current channel config */
- const char *algo_name = NULL;
- grpc_compression_algorithm_name(algo, &algo_name);
+ const char* algo_name = nullptr;
+ grpc_compression_algorithm_name(compression_algorithm, &algo_name);
gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.",
algo_name);
gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
- } else {
- call->incoming_compression_algorithm = algo;
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_UNIMPLEMENTED,
+ error_msg);
}
gpr_free(error_msg);
GPR_ASSERT(call->encodings_accepted_by_peer != 0);
- if (!GPR_BITGET(call->encodings_accepted_by_peer,
- call->incoming_compression_algorithm)) {
- if (GRPC_TRACER_ON(grpc_compression_trace)) {
- const char *algo_name = NULL;
- grpc_compression_algorithm_name(call->incoming_compression_algorithm,
- &algo_name);
+ if (!GPR_BITGET(call->encodings_accepted_by_peer, compression_algorithm)) {
+ if (grpc_compression_trace.enabled()) {
+ const char* algo_name = nullptr;
+ grpc_compression_algorithm_name(compression_algorithm, &algo_name);
gpr_log(GPR_ERROR,
- "Compression algorithm (grpc-encoding = '%s') not present in "
- "the bitset of accepted encodings (grpc-accept-encodings: "
- "'0x%x')",
+ "Compression algorithm ('%s') not present in the bitset of "
+ "accepted encodings ('0x%x')",
algo_name, call->encodings_accepted_by_peer);
}
}
}
}
-static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl,
- grpc_error *error, bool has_cancelled) {
+static void add_batch_error(batch_control* bctl, grpc_error* error,
+ bool has_cancelled) {
if (error == GRPC_ERROR_NONE) return;
int idx = (int)gpr_atm_full_fetch_add(&bctl->num_errors, 1);
if (idx == 0 && !has_cancelled) {
- cancel_with_error(exec_ctx, bctl->call, STATUS_FROM_CORE,
- GRPC_ERROR_REF(error));
+ cancel_with_error(bctl->call, STATUS_FROM_CORE, GRPC_ERROR_REF(error));
}
bctl->errors[idx] = error;
}
-static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
- void *bctlp, grpc_error *error) {
- batch_control *bctl = (batch_control *)bctlp;
- grpc_call *call = bctl->call;
+static void receiving_initial_metadata_ready(void* bctlp, grpc_error* error) {
+ batch_control* bctl = (batch_control*)bctlp;
+ grpc_call* call = bctl->call;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &call->call_combiner,
- "recv_initial_metadata_ready");
+ GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_initial_metadata_ready");
- add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), false);
+ add_batch_error(bctl, GRPC_ERROR_REF(error), false);
if (error == GRPC_ERROR_NONE) {
- grpc_metadata_batch *md =
+ grpc_metadata_batch* md =
&call->metadata_batch[1 /* is_receiving */][0 /* is_trailing */];
- recv_initial_filter(exec_ctx, call, md);
+ recv_initial_filter(call, md);
/* TODO(ctiller): this could be moved into recv_initial_filter now */
GPR_TIMER_BEGIN("validate_filtered_metadata", 0);
- validate_filtered_metadata(exec_ctx, bctl);
+ validate_filtered_metadata(bctl);
GPR_TIMER_END("validate_filtered_metadata", 0);
- if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) !=
- 0 &&
- !call->is_client) {
- call->send_deadline =
- gpr_convert_clock_type(md->deadline, GPR_CLOCK_MONOTONIC);
+ if (md->deadline != GRPC_MILLIS_INF_FUTURE && !call->is_client) {
+ call->send_deadline = md->deadline;
}
}
- grpc_closure *saved_rsr_closure = NULL;
+ grpc_closure* saved_rsr_closure = nullptr;
while (true) {
gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state);
/* Should only receive initial metadata once */
@@ -1637,45 +1549,42 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
}
} else {
/* Already received messages */
- saved_rsr_closure = GRPC_CLOSURE_CREATE(receiving_stream_ready,
- (batch_control *)rsr_bctlp,
- grpc_schedule_on_exec_ctx);
+ saved_rsr_closure =
+ GRPC_CLOSURE_CREATE(receiving_stream_ready, (batch_control*)rsr_bctlp,
+ grpc_schedule_on_exec_ctx);
/* No need to modify recv_state */
break;
}
}
- if (saved_rsr_closure != NULL) {
- GRPC_CLOSURE_RUN(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error));
+ if (saved_rsr_closure != nullptr) {
+ GRPC_CLOSURE_RUN(saved_rsr_closure, GRPC_ERROR_REF(error));
}
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
}
-static void finish_batch(grpc_exec_ctx *exec_ctx, void *bctlp,
- grpc_error *error) {
- batch_control *bctl = (batch_control *)bctlp;
- grpc_call *call = bctl->call;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &call->call_combiner, "on_complete");
- add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), false);
- finish_batch_step(exec_ctx, bctl);
+static void finish_batch(void* bctlp, grpc_error* error) {
+ batch_control* bctl = (batch_control*)bctlp;
+ grpc_call* call = bctl->call;
+ GRPC_CALL_COMBINER_STOP(&call->call_combiner, "on_complete");
+ add_batch_error(bctl, GRPC_ERROR_REF(error), false);
+ finish_batch_step(bctl);
}
-static void free_no_op_completion(grpc_exec_ctx *exec_ctx, void *p,
- grpc_cq_completion *completion) {
+static void free_no_op_completion(void* p, grpc_cq_completion* completion) {
gpr_free(completion);
}
-static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
- grpc_call *call, const grpc_op *ops,
- size_t nops, void *notify_tag,
+static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
+ size_t nops, void* notify_tag,
int is_notify_tag_closure) {
size_t i;
- const grpc_op *op;
- batch_control *bctl;
+ const grpc_op* op;
+ batch_control* bctl;
int num_completion_callbacks_needed = 1;
grpc_call_error error = GRPC_CALL_OK;
- grpc_transport_stream_op_batch *stream_op;
- grpc_transport_stream_op_batch_payload *stream_op_payload;
+ grpc_transport_stream_op_batch* stream_op;
+ grpc_transport_stream_op_batch_payload* stream_op_payload;
GPR_TIMER_BEGIN("grpc_call_start_batch", 0);
GRPC_CALL_LOG_BATCH(GPR_INFO, call, ops, nops, notify_tag);
@@ -1684,18 +1593,17 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
if (!is_notify_tag_closure) {
GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
grpc_cq_end_op(
- exec_ctx, call->cq, notify_tag, GRPC_ERROR_NONE,
- free_no_op_completion, NULL,
- (grpc_cq_completion *)gpr_malloc(sizeof(grpc_cq_completion)));
+ call->cq, notify_tag, GRPC_ERROR_NONE, free_no_op_completion, nullptr,
+ (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure *)notify_tag, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED((grpc_closure*)notify_tag, GRPC_ERROR_NONE);
}
error = GRPC_CALL_OK;
goto done;
}
bctl = allocate_batch_control(call, ops, nops);
- if (bctl == NULL) {
+ if (bctl == nullptr) {
return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
}
bctl->completion_data.notify_tag.tag = notify_tag;
@@ -1708,7 +1616,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
/* rewrite batch ops into a transport op */
for (i = 0; i < nops; i++) {
op = &ops[i];
- if (op->reserved != NULL) {
+ if (op->reserved != nullptr) {
error = GRPC_CALL_ERROR;
goto done_with_error;
}
@@ -1728,56 +1636,28 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
size_t additional_metadata_count = 0;
grpc_compression_level effective_compression_level =
GRPC_COMPRESS_LEVEL_NONE;
- grpc_stream_compression_level effective_stream_compression_level =
- GRPC_STREAM_COMPRESS_LEVEL_NONE;
bool level_set = false;
- bool stream_compression = false;
- if (op->data.send_initial_metadata.maybe_stream_compression_level
- .is_set) {
- effective_stream_compression_level =
- op->data.send_initial_metadata.maybe_stream_compression_level
- .level;
- level_set = true;
- stream_compression = true;
- } else if (op->data.send_initial_metadata.maybe_compression_level
- .is_set) {
+ if (op->data.send_initial_metadata.maybe_compression_level.is_set) {
effective_compression_level =
op->data.send_initial_metadata.maybe_compression_level.level;
level_set = true;
} else {
const grpc_compression_options copts =
grpc_channel_compression_options(call->channel);
- if (copts.default_stream_compression_level.is_set) {
- level_set = true;
- effective_stream_compression_level =
- copts.default_stream_compression_level.level;
- stream_compression = true;
- } else if (copts.default_level.is_set) {
+ if (copts.default_level.is_set) {
level_set = true;
effective_compression_level = copts.default_level.level;
}
}
if (level_set && !call->is_client) {
- if (stream_compression) {
- const grpc_stream_compression_algorithm calgo =
- stream_compression_algorithm_for_level_locked(
- call, effective_stream_compression_level);
- call->compression_md.key =
- GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST;
- call->compression_md.value =
- grpc_stream_compression_algorithm_slice(calgo);
- } else {
- const grpc_compression_algorithm calgo =
- compression_algorithm_for_level_locked(
- call, effective_compression_level);
- /* the following will be picked up by the compress filter and used
- * as the call's compression algorithm. */
- call->compression_md.key =
- GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
- call->compression_md.value =
- grpc_compression_algorithm_slice(calgo);
- additional_metadata_count++;
- }
+ const grpc_compression_algorithm calgo =
+ compression_algorithm_for_level_locked(
+ call, effective_compression_level);
+ /* the following will be picked up by the compress filter and used
+ * as the call's compression algorithm. */
+ call->compression_md.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
+ call->compression_md.value = grpc_compression_algorithm_slice(calgo);
+ additional_metadata_count++;
}
if (op->data.send_initial_metadata.count + additional_metadata_count >
@@ -1788,7 +1668,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
stream_op->send_initial_metadata = true;
call->sent_initial_metadata = true;
if (!prepare_application_metadata(
- exec_ctx, call, (int)op->data.send_initial_metadata.count,
+ call, (int)op->data.send_initial_metadata.count,
op->data.send_initial_metadata.metadata, 0, call->is_client,
&call->compression_md, (int)additional_metadata_count)) {
error = GRPC_CALL_ERROR_INVALID_METADATA;
@@ -1813,7 +1693,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
error = GRPC_CALL_ERROR_INVALID_FLAGS;
goto done_with_error;
}
- if (op->data.send_message.send_message == NULL) {
+ if (op->data.send_message.send_message == nullptr) {
error = GRPC_CALL_ERROR_INVALID_MESSAGE;
goto done_with_error;
}
@@ -1882,36 +1762,36 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(call->send_extra_metadata_count == 0);
call->send_extra_metadata_count = 1;
call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem(
- exec_ctx, call->channel, op->data.send_status_from_server.status);
+ call->channel, op->data.send_status_from_server.status);
{
- grpc_error *override_error = GRPC_ERROR_NONE;
+ grpc_error* override_error = GRPC_ERROR_NONE;
if (op->data.send_status_from_server.status != GRPC_STATUS_OK) {
- override_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Error from server send status");
+ override_error =
+ error_from_status(op->data.send_status_from_server.status,
+ "Returned non-ok status");
}
- if (op->data.send_status_from_server.status_details != NULL) {
+ if (op->data.send_status_from_server.status_details != nullptr) {
call->send_extra_metadata[1].md = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
+ GRPC_MDSTR_GRPC_MESSAGE,
grpc_slice_ref_internal(
*op->data.send_status_from_server.status_details));
call->send_extra_metadata_count++;
- char *msg = grpc_slice_to_c_string(
+ char* msg = grpc_slice_to_c_string(
GRPC_MDVALUE(call->send_extra_metadata[1].md));
override_error =
grpc_error_set_str(override_error, GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_slice_from_copied_string(msg));
gpr_free(msg);
}
- set_status_from_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
- override_error);
+ set_status_from_error(call, STATUS_FROM_API_OVERRIDE, override_error);
}
if (!prepare_application_metadata(
- exec_ctx, call,
+ call,
(int)op->data.send_status_from_server.trailing_metadata_count,
- op->data.send_status_from_server.trailing_metadata, 1, 1, NULL,
- 0)) {
+ op->data.send_status_from_server.trailing_metadata, 1, 1,
+ nullptr, 0)) {
for (int n = 0; n < call->send_extra_metadata_count; n++) {
- GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md);
+ GRPC_MDELEM_UNREF(call->send_extra_metadata[n].md);
}
call->send_extra_metadata_count = 0;
error = GRPC_CALL_ERROR_INVALID_METADATA;
@@ -1991,6 +1871,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
call->final_op.client.status = op->data.recv_status_on_client.status;
call->final_op.client.status_details =
op->data.recv_status_on_client.status_details;
+ call->final_op.client.error_string =
+ op->data.recv_status_on_client.error_string;
stream_op->recv_trailing_metadata = true;
stream_op->collect_stats = true;
stream_op_payload->recv_trailing_metadata.recv_trailing_metadata =
@@ -2038,7 +1920,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
stream_op->on_complete = &bctl->finish_batch;
gpr_atm_rel_store(&call->any_ops_sent_atm, 1);
- execute_batch(exec_ctx, call, stream_op, &bctl->start_batch);
+ execute_batch(call, stream_op, &bctl->start_batch);
done:
GPR_TIMER_END("grpc_call_start_batch", 0);
@@ -2048,15 +1930,15 @@ done_with_error:
/* reverse any mutations that occured */
if (stream_op->send_initial_metadata) {
call->sent_initial_metadata = false;
- grpc_metadata_batch_clear(exec_ctx, &call->metadata_batch[0][0]);
+ grpc_metadata_batch_clear(&call->metadata_batch[0][0]);
}
if (stream_op->send_message) {
call->sending_message = false;
- grpc_byte_stream_destroy(exec_ctx, &call->sending_stream.base);
+ grpc_byte_stream_destroy(&call->sending_stream.base);
}
if (stream_op->send_trailing_metadata) {
call->sent_final_op = false;
- grpc_metadata_batch_clear(exec_ctx, &call->metadata_batch[0][1]);
+ grpc_metadata_batch_clear(&call->metadata_batch[0][1]);
}
if (stream_op->recv_initial_metadata) {
call->received_initial_metadata = false;
@@ -2070,9 +1952,9 @@ done_with_error:
goto done;
}
-grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
- size_t nops, void *tag, void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
+ size_t nops, void* tag, void* reserved) {
+ grpc_core::ExecCtx exec_ctx;
grpc_call_error err;
GRPC_API_TRACE(
@@ -2080,26 +1962,24 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
"reserved=%p)",
5, (call, ops, (unsigned long)nops, tag, reserved));
- if (reserved != NULL) {
+ if (reserved != nullptr) {
err = GRPC_CALL_ERROR;
} else {
- err = call_start_batch(&exec_ctx, call, ops, nops, tag, 0);
+ err = call_start_batch(call, ops, nops, tag, 0);
}
- grpc_exec_ctx_finish(&exec_ctx);
return err;
}
-grpc_call_error grpc_call_start_batch_and_execute(grpc_exec_ctx *exec_ctx,
- grpc_call *call,
- const grpc_op *ops,
+grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,
+ const grpc_op* ops,
size_t nops,
- grpc_closure *closure) {
- return call_start_batch(exec_ctx, call, ops, nops, closure, 1);
+ grpc_closure* closure) {
+ return call_start_batch(call, ops, nops, closure, 1);
}
-void grpc_call_context_set(grpc_call *call, grpc_context_index elem,
- void *value, void (*destroy)(void *value)) {
+void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
+ void* value, void (*destroy)(void* value)) {
if (call->context[elem].destroy) {
call->context[elem].destroy(call->context[elem].value);
}
@@ -2107,20 +1987,20 @@ void grpc_call_context_set(grpc_call *call, grpc_context_index elem,
call->context[elem].destroy = destroy;
}
-void *grpc_call_context_get(grpc_call *call, grpc_context_index elem) {
+void* grpc_call_context_get(grpc_call* call, grpc_context_index elem) {
return call->context[elem].value;
}
-uint8_t grpc_call_is_client(grpc_call *call) { return call->is_client; }
+uint8_t grpc_call_is_client(grpc_call* call) { return call->is_client; }
grpc_compression_algorithm grpc_call_compression_for_level(
- grpc_call *call, grpc_compression_level level) {
+ grpc_call* call, grpc_compression_level level) {
grpc_compression_algorithm algo =
compression_algorithm_for_level_locked(call, level);
return algo;
}
-const char *grpc_call_error_to_string(grpc_call_error error) {
+const char* grpc_call_error_to_string(grpc_call_error error) {
switch (error) {
case GRPC_CALL_ERROR:
return "GRPC_CALL_ERROR";
diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h
index c680139cf6..189329ccc4 100644
--- a/src/core/lib/surface/call.h
+++ b/src/core/lib/surface/call.h
@@ -19,10 +19,6 @@
#ifndef GRPC_CORE_LIB_SURFACE_CALL_H
#define GRPC_CORE_LIB_SURFACE_CALL_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/context.h"
#include "src/core/lib/surface/api_trace.h"
@@ -30,93 +26,82 @@ extern "C" {
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
-typedef void (*grpc_ioreq_completion_func)(grpc_exec_ctx *exec_ctx,
- grpc_call *call, int success,
- void *user_data);
+typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success,
+ void* user_data);
typedef struct grpc_call_create_args {
- grpc_channel *channel;
+ grpc_channel* channel;
- grpc_call *parent;
+ grpc_call* parent;
uint32_t propagation_mask;
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
/* if not NULL, it'll be used in lieu of cq */
- grpc_pollset_set *pollset_set_alternative;
+ grpc_pollset_set* pollset_set_alternative;
- const void *server_transport_data;
+ const void* server_transport_data;
- grpc_mdelem *add_initial_metadata;
+ grpc_mdelem* add_initial_metadata;
size_t add_initial_metadata_count;
- gpr_timespec send_deadline;
+ grpc_millis send_deadline;
} grpc_call_create_args;
/* Create a new call based on \a args.
Regardless of success or failure, always returns a valid new call into *call
*/
-grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
- const grpc_call_create_args *args,
- grpc_call **call);
+grpc_error* grpc_call_create(const grpc_call_create_args* args,
+ grpc_call** call);
-void grpc_call_set_completion_queue(grpc_exec_ctx *exec_ctx, grpc_call *call,
- grpc_completion_queue *cq);
+void grpc_call_set_completion_queue(grpc_call* call, grpc_completion_queue* cq);
#ifndef NDEBUG
-void grpc_call_internal_ref(grpc_call *call, const char *reason);
-void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *call,
- const char *reason);
+void grpc_call_internal_ref(grpc_call* call, const char* reason);
+void grpc_call_internal_unref(grpc_call* call, const char* reason);
#define GRPC_CALL_INTERNAL_REF(call, reason) \
grpc_call_internal_ref(call, reason)
-#define GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, reason) \
- grpc_call_internal_unref(exec_ctx, call, reason)
+#define GRPC_CALL_INTERNAL_UNREF(call, reason) \
+ grpc_call_internal_unref(call, reason)
#else
-void grpc_call_internal_ref(grpc_call *call);
-void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *call);
+void grpc_call_internal_ref(grpc_call* call);
+void grpc_call_internal_unref(grpc_call* call);
#define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call)
-#define GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, reason) \
- grpc_call_internal_unref(exec_ctx, call)
+#define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
#endif
-grpc_call_stack *grpc_call_get_call_stack(grpc_call *call);
+grpc_call_stack* grpc_call_get_call_stack(grpc_call* call);
-grpc_call_error grpc_call_start_batch_and_execute(grpc_exec_ctx *exec_ctx,
- grpc_call *call,
- const grpc_op *ops,
+grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,
+ const grpc_op* ops,
size_t nops,
- grpc_closure *closure);
+ grpc_closure* closure);
/* Given the top call_element, get the call object. */
-grpc_call *grpc_call_from_top_element(grpc_call_element *surface_element);
+grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element);
-void grpc_call_log_batch(const char *file, int line, gpr_log_severity severity,
- grpc_call *call, const grpc_op *ops, size_t nops,
- void *tag);
+void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity,
+ grpc_call* call, const grpc_op* ops, size_t nops,
+ void* tag);
/* Set a context pointer.
No thread safety guarantees are made wrt this value. */
/* TODO(#9731): add exec_ctx to destroy */
-void grpc_call_context_set(grpc_call *call, grpc_context_index elem,
- void *value, void (*destroy)(void *value));
+void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
+ void* value, void (*destroy)(void* value));
/* Get a context pointer. */
-void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
+void* grpc_call_context_get(grpc_call* call, grpc_context_index elem);
#define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
- if (GRPC_TRACER_ON(grpc_api_trace)) \
- grpc_call_log_batch(sev, call, ops, nops, tag)
+ if (grpc_api_trace.enabled()) grpc_call_log_batch(sev, call, ops, nops, tag)
-uint8_t grpc_call_is_client(grpc_call *call);
+uint8_t grpc_call_is_client(grpc_call* call);
/* Return an appropriate compression algorithm for the requested compression \a
* level in the context of \a call. */
grpc_compression_algorithm grpc_call_compression_for_level(
- grpc_call *call, grpc_compression_level level);
+ grpc_call* call, grpc_compression_level level);
-extern grpc_tracer_flag grpc_call_error_trace;
-extern grpc_tracer_flag grpc_compression_trace;
-
-#ifdef __cplusplus
-}
-#endif
+extern grpc_core::TraceFlag grpc_call_error_trace;
+extern grpc_core::TraceFlag grpc_compression_trace;
#endif /* GRPC_CORE_LIB_SURFACE_CALL_H */
diff --git a/src/core/lib/surface/call_details.c b/src/core/lib/surface/call_details.cc
index ea9208c7e3..cd0b14586a 100644
--- a/src/core/lib/surface/call_details.c
+++ b/src/core/lib/surface/call_details.cc
@@ -34,8 +34,7 @@ void grpc_call_details_init(grpc_call_details* cd) {
void grpc_call_details_destroy(grpc_call_details* cd) {
GRPC_API_TRACE("grpc_call_details_destroy(cd=%p)", 1, (cd));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, cd->method);
- grpc_slice_unref_internal(&exec_ctx, cd->host);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_unref_internal(cd->method);
+ grpc_slice_unref_internal(cd->host);
}
diff --git a/src/core/lib/surface/call_log_batch.c b/src/core/lib/surface/call_log_batch.cc
index 4a1c265817..d56ea2a932 100644
--- a/src/core/lib/surface/call_log_batch.c
+++ b/src/core/lib/surface/call_log_batch.cc
@@ -18,14 +18,16 @@
#include "src/core/lib/surface/call.h"
+#include <inttypes.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
-static void add_metadata(gpr_strvec *b, const grpc_metadata *md, size_t count) {
+static void add_metadata(gpr_strvec* b, const grpc_metadata* md, size_t count) {
size_t i;
- if (md == NULL) {
+ if (md == nullptr) {
gpr_strvec_add(b, gpr_strdup("(nil)"));
return;
}
@@ -39,9 +41,9 @@ static void add_metadata(gpr_strvec *b, const grpc_metadata *md, size_t count) {
}
}
-char *grpc_op_string(const grpc_op *op) {
- char *tmp;
- char *out;
+char* grpc_op_string(const grpc_op* op) {
+ char* tmp;
+ char* out;
gpr_strvec b;
gpr_strvec_init(&b);
@@ -64,7 +66,7 @@ char *grpc_op_string(const grpc_op *op) {
gpr_asprintf(&tmp, "SEND_STATUS_FROM_SERVER status=%d details=",
op->data.send_status_from_server.status);
gpr_strvec_add(&b, tmp);
- if (op->data.send_status_from_server.status_details != NULL) {
+ if (op->data.send_status_from_server.status_details != nullptr) {
gpr_strvec_add(&b, grpc_dump_slice(
*op->data.send_status_from_server.status_details,
GPR_DUMP_ASCII));
@@ -97,16 +99,16 @@ char *grpc_op_string(const grpc_op *op) {
op->data.recv_close_on_server.cancelled);
gpr_strvec_add(&b, tmp);
}
- out = gpr_strvec_flatten(&b, NULL);
+ out = gpr_strvec_flatten(&b, nullptr);
gpr_strvec_destroy(&b);
return out;
}
-void grpc_call_log_batch(const char *file, int line, gpr_log_severity severity,
- grpc_call *call, const grpc_op *ops, size_t nops,
- void *tag) {
- char *tmp;
+void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity,
+ grpc_call* call, const grpc_op* ops, size_t nops,
+ void* tag) {
+ char* tmp;
size_t i;
for (i = 0; i < nops; i++) {
tmp = grpc_op_string(&ops[i]);
diff --git a/src/core/lib/surface/call_test_only.h b/src/core/lib/surface/call_test_only.h
index a5a01b3679..9eb32f03fb 100644
--- a/src/core/lib/surface/call_test_only.h
+++ b/src/core/lib/surface/call_test_only.h
@@ -21,41 +21,21 @@
#include <grpc/grpc.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** Return the compression algorithm from \a call.
+/** Return the message compression algorithm from \a call.
*
* \warning This function should \b only be used in test code. */
grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
- grpc_call *call);
+ grpc_call* call);
/** Return the message flags from \a call.
*
* \warning This function should \b only be used in test code. */
-uint32_t grpc_call_test_only_get_message_flags(grpc_call *call);
+uint32_t grpc_call_test_only_get_message_flags(grpc_call* call);
/** Returns a bitset for the encodings (compression algorithms) supported by \a
* call's peer.
*
* To be indexed by grpc_compression_algorithm enum values. */
-uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call);
-
-/** Returns a bitset for the stream encodings (stream compression algorithms)
- * supported by \a call's peer.
- *
- * To be indexed by grpc_stream_compression_algorithm enum values. */
-uint32_t grpc_call_test_only_get_stream_encodings_accepted_by_peer(
- grpc_call *call);
-
-/** Returns the incoming stream compression algorithm (content-encoding header)
- * received by a call. */
-grpc_stream_compression_algorithm
-grpc_call_test_only_get_incoming_stream_encodings(grpc_call *call);
-
-#ifdef __cplusplus
-}
-#endif
+uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call);
#endif /* GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H */
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.cc
index 48962e5e45..679666bc5f 100644
--- a/src/core/lib/surface/channel.c
+++ b/src/core/lib/surface/channel.cc
@@ -18,6 +18,7 @@
#include "src/core/lib/surface/channel.h"
+#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
@@ -28,9 +29,9 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel_init.h"
@@ -46,7 +47,7 @@
typedef struct registered_call {
grpc_mdelem path;
grpc_mdelem authority;
- struct registered_call *next;
+ struct registered_call* next;
} registered_call;
struct grpc_channel {
@@ -57,35 +58,34 @@ struct grpc_channel {
gpr_atm call_size_estimate;
gpr_mu registered_call_mu;
- registered_call *registered_calls;
+ registered_call* registered_calls;
- char *target;
+ char* target;
};
-#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c) + 1))
+#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1))
#define CHANNEL_FROM_CHANNEL_STACK(channel_stack) \
- (((grpc_channel *)(channel_stack)) - 1)
+ (((grpc_channel*)(channel_stack)) - 1)
#define CHANNEL_FROM_TOP_ELEM(top_elem) \
CHANNEL_FROM_CHANNEL_STACK(grpc_channel_stack_from_top_element(top_elem))
-static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
+static void destroy_channel(void* arg, grpc_error* error);
-grpc_channel *grpc_channel_create_with_builder(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
+grpc_channel* grpc_channel_create_with_builder(
+ grpc_channel_stack_builder* builder,
grpc_channel_stack_type channel_stack_type) {
- char *target = gpr_strdup(grpc_channel_stack_builder_get_target(builder));
- grpc_channel_args *args = grpc_channel_args_copy(
+ char* target = gpr_strdup(grpc_channel_stack_builder_get_target(builder));
+ grpc_channel_args* args = grpc_channel_args_copy(
grpc_channel_stack_builder_get_channel_arguments(builder));
- grpc_channel *channel;
+ grpc_channel* channel;
if (channel_stack_type == GRPC_SERVER_CHANNEL) {
- GRPC_STATS_INC_SERVER_CHANNELS_CREATED(exec_ctx);
+ GRPC_STATS_INC_SERVER_CHANNELS_CREATED();
} else {
- GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(exec_ctx);
+ GRPC_STATS_INC_CLIENT_CHANNELS_CREATED();
}
- grpc_error *error = grpc_channel_stack_builder_finish(
- exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, NULL,
- (void **)&channel);
+ grpc_error* error = grpc_channel_stack_builder_finish(
+ builder, sizeof(grpc_channel), 1, destroy_channel, nullptr,
+ (void**)&channel);
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "channel stack builder failed: %s",
grpc_error_string(error));
@@ -98,7 +98,7 @@ grpc_channel *grpc_channel_create_with_builder(
channel->target = target;
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
gpr_mu_init(&channel->registered_call_mu);
- channel->registered_calls = NULL;
+ channel->registered_calls = nullptr;
gpr_atm_no_barrier_store(
&channel->call_size_estimate,
@@ -113,10 +113,10 @@ grpc_channel *grpc_channel_create_with_builder(
} else {
if (!GRPC_MDISNULL(channel->default_authority)) {
/* setting this takes precedence over anything else */
- GRPC_MDELEM_UNREF(exec_ctx, channel->default_authority);
+ GRPC_MDELEM_UNREF(channel->default_authority);
}
channel->default_authority = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(
grpc_slice_from_static_string(args->args[i].value.string)));
}
@@ -133,7 +133,7 @@ grpc_channel *grpc_channel_create_with_builder(
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
} else {
channel->default_authority = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(
grpc_slice_from_static_string(args->args[i].value.string)));
}
@@ -142,80 +142,47 @@ grpc_channel *grpc_channel_create_with_builder(
GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) {
channel->compression_options.default_level.is_set = true;
channel->compression_options.default_level.level =
- (grpc_compression_level)grpc_channel_arg_get_integer(
+ static_cast<grpc_compression_level>(grpc_channel_arg_get_integer(
&args->args[i],
- (grpc_integer_options){GRPC_COMPRESS_LEVEL_NONE,
- GRPC_COMPRESS_LEVEL_NONE,
- GRPC_COMPRESS_LEVEL_COUNT - 1});
- } else if (0 == strcmp(args->args[i].key,
- GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) {
- channel->compression_options.default_stream_compression_level.is_set =
- true;
- channel->compression_options.default_stream_compression_level.level =
- (grpc_stream_compression_level)grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){GRPC_STREAM_COMPRESS_LEVEL_NONE,
- GRPC_STREAM_COMPRESS_LEVEL_NONE,
- GRPC_STREAM_COMPRESS_LEVEL_COUNT - 1});
+ {GRPC_COMPRESS_LEVEL_NONE, GRPC_COMPRESS_LEVEL_NONE,
+ GRPC_COMPRESS_LEVEL_COUNT - 1}));
} else if (0 == strcmp(args->args[i].key,
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM)) {
channel->compression_options.default_algorithm.is_set = true;
channel->compression_options.default_algorithm.algorithm =
- (grpc_compression_algorithm)grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
- GRPC_COMPRESS_ALGORITHMS_COUNT - 1});
- } else if (0 == strcmp(args->args[i].key,
- GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM)) {
- channel->compression_options.default_stream_compression_algorithm.is_set =
- true;
- channel->compression_options.default_stream_compression_algorithm
- .algorithm =
- (grpc_stream_compression_algorithm)grpc_channel_arg_get_integer(
- &args->args[i],
- (grpc_integer_options){
- GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE,
- GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT - 1});
+ static_cast<grpc_compression_algorithm>(grpc_channel_arg_get_integer(
+ &args->args[i], {GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
+ GRPC_COMPRESS_ALGORITHMS_COUNT - 1}));
} else if (0 ==
strcmp(args->args[i].key,
GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET)) {
channel->compression_options.enabled_algorithms_bitset =
(uint32_t)args->args[i].value.integer |
0x1; /* always support no compression */
- } else if (0 ==
- strcmp(
- args->args[i].key,
- GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET)) {
- channel->compression_options
- .enabled_stream_compression_algorithms_bitset =
- (uint32_t)args->args[i].value.integer |
- 0x1; /* always support no compression */
}
}
done:
- grpc_channel_args_destroy(exec_ctx, args);
+ grpc_channel_args_destroy(args);
return channel;
}
-grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_args *input_args,
+grpc_channel* grpc_channel_create(const char* target,
+ const grpc_channel_args* input_args,
grpc_channel_stack_type channel_stack_type,
- grpc_transport *optional_transport) {
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
- grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
- input_args);
+ grpc_transport* optional_transport) {
+ grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder_set_channel_arguments(builder, input_args);
grpc_channel_stack_builder_set_target(builder, target);
grpc_channel_stack_builder_set_transport(builder, optional_transport);
- if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
- return NULL;
+ if (!grpc_channel_init_create_stack(builder, channel_stack_type)) {
+ grpc_channel_stack_builder_destroy(builder);
+ return nullptr;
}
- return grpc_channel_create_with_builder(exec_ctx, builder,
- channel_stack_type);
+ return grpc_channel_create_with_builder(builder, channel_stack_type);
}
-size_t grpc_channel_get_call_size_estimate(grpc_channel *channel) {
+size_t grpc_channel_get_call_size_estimate(grpc_channel* channel) {
#define ROUND_UP_SIZE 256
/* We round up our current estimate to the NEXT value of ROUND_UP_SIZE.
This ensures:
@@ -228,7 +195,7 @@ size_t grpc_channel_get_call_size_estimate(grpc_channel *channel) {
~(size_t)(ROUND_UP_SIZE - 1);
}
-void grpc_channel_update_call_size_estimate(grpc_channel *channel,
+void grpc_channel_update_call_size_estimate(grpc_channel* channel,
size_t size) {
size_t cur = (size_t)gpr_atm_no_barrier_load(&channel->call_size_estimate);
if (cur < size) {
@@ -247,30 +214,29 @@ void grpc_channel_update_call_size_estimate(grpc_channel *channel,
}
}
-char *grpc_channel_get_target(grpc_channel *channel) {
+char* grpc_channel_get_target(grpc_channel* channel) {
GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel));
return gpr_strdup(channel->target);
}
-void grpc_channel_get_info(grpc_channel *channel,
- const grpc_channel_info *channel_info) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_element *elem =
+void grpc_channel_get_info(grpc_channel* channel,
+ const grpc_channel_info* channel_info) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_element* elem =
grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
- elem->filter->get_channel_info(&exec_ctx, elem, channel_info);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->get_channel_info(elem, channel_info);
}
-static grpc_call *grpc_channel_create_call_internal(
- grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call,
- uint32_t propagation_mask, grpc_completion_queue *cq,
- grpc_pollset_set *pollset_set_alternative, grpc_mdelem path_mdelem,
- grpc_mdelem authority_mdelem, gpr_timespec deadline) {
+static grpc_call* grpc_channel_create_call_internal(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative,
+ grpc_mdelem path_mdelem, grpc_mdelem authority_mdelem,
+ grpc_millis deadline) {
grpc_mdelem send_metadata[2];
size_t num_metadata = 0;
GPR_ASSERT(channel->is_client);
- GPR_ASSERT(!(cq != NULL && pollset_set_alternative != NULL));
+ GPR_ASSERT(!(cq != nullptr && pollset_set_alternative != nullptr));
send_metadata[num_metadata++] = path_mdelem;
if (!GRPC_MDISNULL(authority_mdelem)) {
@@ -286,81 +252,79 @@ static grpc_call *grpc_channel_create_call_internal(
args.propagation_mask = propagation_mask;
args.cq = cq;
args.pollset_set_alternative = pollset_set_alternative;
- args.server_transport_data = NULL;
+ args.server_transport_data = nullptr;
args.add_initial_metadata = send_metadata;
args.add_initial_metadata_count = num_metadata;
args.send_deadline = deadline;
- grpc_call *call;
- GRPC_LOG_IF_ERROR("call_create", grpc_call_create(exec_ctx, &args, &call));
+ grpc_call* call;
+ GRPC_LOG_IF_ERROR("call_create", grpc_call_create(&args, &call));
return call;
}
-grpc_call *grpc_channel_create_call(grpc_channel *channel,
- grpc_call *parent_call,
+grpc_call* grpc_channel_create_call(grpc_channel* channel,
+ grpc_call* parent_call,
uint32_t propagation_mask,
- grpc_completion_queue *cq,
- grpc_slice method, const grpc_slice *host,
- gpr_timespec deadline, void *reserved) {
+ grpc_completion_queue* cq,
+ grpc_slice method, const grpc_slice* host,
+ gpr_timespec deadline, void* reserved) {
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_call *call = grpc_channel_create_call_internal(
- &exec_ctx, channel, parent_call, propagation_mask, cq, NULL,
- grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_PATH,
- grpc_slice_ref_internal(method)),
- host != NULL ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY,
- grpc_slice_ref_internal(*host))
- : GRPC_MDNULL,
- deadline);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_call* call = grpc_channel_create_call_internal(
+ channel, parent_call, propagation_mask, cq, nullptr,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH, grpc_slice_ref_internal(method)),
+ host != nullptr ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
+ grpc_slice_ref_internal(*host))
+ : GRPC_MDNULL,
+ grpc_timespec_to_millis_round_up(deadline));
+
return call;
}
-grpc_call *grpc_channel_create_pollset_set_call(
- grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call,
- uint32_t propagation_mask, grpc_pollset_set *pollset_set, grpc_slice method,
- const grpc_slice *host, gpr_timespec deadline, void *reserved) {
+grpc_call* grpc_channel_create_pollset_set_call(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host,
+ grpc_millis deadline, void* reserved) {
GPR_ASSERT(!reserved);
return grpc_channel_create_call_internal(
- exec_ctx, channel, parent_call, propagation_mask, NULL, pollset_set,
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH,
- grpc_slice_ref_internal(method)),
- host != NULL ? grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
- grpc_slice_ref_internal(*host))
- : GRPC_MDNULL,
+ channel, parent_call, propagation_mask, nullptr, pollset_set,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH, grpc_slice_ref_internal(method)),
+ host != nullptr ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
+ grpc_slice_ref_internal(*host))
+ : GRPC_MDNULL,
deadline);
}
-void *grpc_channel_register_call(grpc_channel *channel, const char *method,
- const char *host, void *reserved) {
- registered_call *rc = (registered_call *)gpr_malloc(sizeof(registered_call));
+void* grpc_channel_register_call(grpc_channel* channel, const char* method,
+ const char* host, void* reserved) {
+ registered_call* rc = (registered_call*)gpr_malloc(sizeof(registered_call));
GRPC_API_TRACE(
"grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)",
4, (channel, method, host, reserved));
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
rc->path = grpc_mdelem_from_slices(
- &exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string(method)));
rc->authority =
host ? grpc_mdelem_from_slices(
- &exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(host)))
: GRPC_MDNULL;
gpr_mu_lock(&channel->registered_call_mu);
rc->next = channel->registered_calls;
channel->registered_calls = rc;
gpr_mu_unlock(&channel->registered_call_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
return rc;
}
-grpc_call *grpc_channel_create_registered_call(
- grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
- grpc_completion_queue *completion_queue, void *registered_call_handle,
- gpr_timespec deadline, void *reserved) {
- registered_call *rc = (registered_call *)registered_call_handle;
+grpc_call* grpc_channel_create_registered_call(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_completion_queue* completion_queue, void* registered_call_handle,
+ gpr_timespec deadline, void* reserved) {
+ registered_call* rc = (registered_call*)registered_call_handle;
GRPC_API_TRACE(
"grpc_channel_create_registered_call("
"channel=%p, parent_call=%p, propagation_mask=%x, completion_queue=%p, "
@@ -368,77 +332,74 @@ grpc_call *grpc_channel_create_registered_call(
"deadline=gpr_timespec { tv_sec: %" PRId64
", tv_nsec: %d, clock_type: %d }, "
"reserved=%p)",
- 9, (channel, parent_call, (unsigned)propagation_mask, completion_queue,
- registered_call_handle, deadline.tv_sec, deadline.tv_nsec,
- (int)deadline.clock_type, reserved));
+ 9,
+ (channel, parent_call, (unsigned)propagation_mask, completion_queue,
+ registered_call_handle, deadline.tv_sec, deadline.tv_nsec,
+ (int)deadline.clock_type, reserved));
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_call *call = grpc_channel_create_call_internal(
- &exec_ctx, channel, parent_call, propagation_mask, completion_queue, NULL,
- GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), deadline);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_call* call = grpc_channel_create_call_internal(
+ channel, parent_call, propagation_mask, completion_queue, nullptr,
+ GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority),
+ grpc_timespec_to_millis_round_up(deadline));
+
return call;
}
#ifndef NDEBUG
#define REF_REASON reason
-#define REF_ARG , const char *reason
+#define REF_ARG , const char* reason
#else
#define REF_REASON ""
#define REF_ARG
#endif
-void grpc_channel_internal_ref(grpc_channel *c REF_ARG) {
+void grpc_channel_internal_ref(grpc_channel* c REF_ARG) {
GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON);
}
-void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx,
- grpc_channel *c REF_ARG) {
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON);
+void grpc_channel_internal_unref(grpc_channel* c REF_ARG) {
+ GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON);
}
-static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_channel *channel = (grpc_channel *)arg;
- grpc_channel_stack_destroy(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(channel));
+static void destroy_channel(void* arg, grpc_error* error) {
+ grpc_channel* channel = (grpc_channel*)arg;
+ grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CHANNEL(channel));
while (channel->registered_calls) {
- registered_call *rc = channel->registered_calls;
+ registered_call* rc = channel->registered_calls;
channel->registered_calls = rc->next;
- GRPC_MDELEM_UNREF(exec_ctx, rc->path);
- GRPC_MDELEM_UNREF(exec_ctx, rc->authority);
+ GRPC_MDELEM_UNREF(rc->path);
+ GRPC_MDELEM_UNREF(rc->authority);
gpr_free(rc);
}
- GRPC_MDELEM_UNREF(exec_ctx, channel->default_authority);
+ GRPC_MDELEM_UNREF(channel->default_authority);
gpr_mu_destroy(&channel->registered_call_mu);
gpr_free(channel->target);
gpr_free(channel);
}
-void grpc_channel_destroy(grpc_channel *channel) {
- grpc_transport_op *op = grpc_make_transport_op(NULL);
- grpc_channel_element *elem;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+void grpc_channel_destroy(grpc_channel* channel) {
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ grpc_channel_element* elem;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (channel));
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Destroyed");
elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
-
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, channel, "channel");
+ elem->filter->start_transport_op(elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel");
}
-grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel) {
+grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel) {
return CHANNEL_STACK_FROM_CHANNEL(channel);
}
grpc_compression_options grpc_channel_compression_options(
- const grpc_channel *channel) {
+ const grpc_channel* channel) {
return channel->compression_options;
}
-grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel *channel, int i) {
+grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, int i) {
char tmp[GPR_LTOA_MIN_BUFSIZE];
switch (i) {
case 0:
@@ -449,6 +410,6 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx,
return GRPC_MDELEM_GRPC_STATUS_2;
}
gpr_ltoa(i, tmp);
- return grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_STATUS,
+ return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS,
grpc_slice_from_copied_string(tmp));
}
diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h
index 528bb868e2..26d8fceb2f 100644
--- a/src/core/lib/surface/channel.h
+++ b/src/core/lib/surface/channel.h
@@ -23,13 +23,13 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/surface/channel_stack_type.h"
-grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_args *args,
+grpc_channel* grpc_channel_create(const char* target,
+ const grpc_channel_args* args,
grpc_channel_stack_type channel_stack_type,
- grpc_transport *optional_transport);
+ grpc_transport* optional_transport);
-grpc_channel *grpc_channel_create_with_builder(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
+grpc_channel* grpc_channel_create_with_builder(
+ grpc_channel_stack_builder* builder,
grpc_channel_stack_type channel_stack_type);
/** Create a call given a grpc_channel, in order to call \a method.
@@ -40,45 +40,42 @@ grpc_channel *grpc_channel_create_with_builder(
non-NULL, it must be a server-side call. It will be used to propagate
properties from the server call to this new client call, depending on the
value of \a propagation_mask (see propagation_bits.h for possible values) */
-grpc_call *grpc_channel_create_pollset_set_call(
- grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call,
- uint32_t propagation_mask, grpc_pollset_set *pollset_set, grpc_slice method,
- const grpc_slice *host, gpr_timespec deadline, void *reserved);
+grpc_call* grpc_channel_create_pollset_set_call(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host,
+ grpc_millis deadline, void* reserved);
/** Get a (borrowed) pointer to this channels underlying channel stack */
-grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel);
+grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel);
/** Get a grpc_mdelem of grpc-status: X where X is the numeric value of
status_code.
The returned elem is owned by the caller. */
-grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel *channel,
+grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel,
int status_code);
-size_t grpc_channel_get_call_size_estimate(grpc_channel *channel);
-void grpc_channel_update_call_size_estimate(grpc_channel *channel, size_t size);
+size_t grpc_channel_get_call_size_estimate(grpc_channel* channel);
+void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size);
#ifndef NDEBUG
-void grpc_channel_internal_ref(grpc_channel *channel, const char *reason);
-void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
- const char *reason);
+void grpc_channel_internal_ref(grpc_channel* channel, const char* reason);
+void grpc_channel_internal_unref(grpc_channel* channel, const char* reason);
#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
grpc_channel_internal_ref(channel, reason)
-#define GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, reason) \
- grpc_channel_internal_unref(exec_ctx, channel, reason)
+#define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
+ grpc_channel_internal_unref(channel, reason)
#else
-void grpc_channel_internal_ref(grpc_channel *channel);
-void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx,
- grpc_channel *channel);
+void grpc_channel_internal_ref(grpc_channel* channel);
+void grpc_channel_internal_unref(grpc_channel* channel);
#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
grpc_channel_internal_ref(channel)
-#define GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, reason) \
- grpc_channel_internal_unref(exec_ctx, channel)
+#define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
+ grpc_channel_internal_unref(channel)
#endif
/** Return the channel's compression options. */
grpc_compression_options grpc_channel_compression_options(
- const grpc_channel *channel);
+ const grpc_channel* channel);
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */
diff --git a/src/core/lib/surface/channel_init.c b/src/core/lib/surface/channel_init.cc
index 33f444b89e..95cbbbd037 100644
--- a/src/core/lib/surface/channel_init.c
+++ b/src/core/lib/surface/channel_init.cc
@@ -23,13 +23,13 @@
typedef struct stage_slot {
grpc_channel_init_stage fn;
- void *arg;
+ void* arg;
int priority;
size_t insertion_order;
} stage_slot;
typedef struct stage_slots {
- stage_slot *slots;
+ stage_slot* slots;
size_t num_slots;
size_t cap_slots;
} stage_slots;
@@ -39,7 +39,7 @@ static bool g_finalized;
void grpc_channel_init_init(void) {
for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
- g_slots[i].slots = NULL;
+ g_slots[i].slots = nullptr;
g_slots[i].num_slots = 0;
g_slots[i].cap_slots = 0;
}
@@ -49,24 +49,24 @@ void grpc_channel_init_init(void) {
void grpc_channel_init_register_stage(grpc_channel_stack_type type,
int priority,
grpc_channel_init_stage stage,
- void *stage_arg) {
+ void* stage_arg) {
GPR_ASSERT(!g_finalized);
if (g_slots[type].cap_slots == g_slots[type].num_slots) {
g_slots[type].cap_slots = GPR_MAX(8, 3 * g_slots[type].cap_slots / 2);
- g_slots[type].slots = (stage_slot *)gpr_realloc(
+ g_slots[type].slots = (stage_slot*)gpr_realloc(
g_slots[type].slots,
g_slots[type].cap_slots * sizeof(*g_slots[type].slots));
}
- stage_slot *s = &g_slots[type].slots[g_slots[type].num_slots++];
+ stage_slot* s = &g_slots[type].slots[g_slots[type].num_slots++];
s->insertion_order = g_slots[type].num_slots;
s->priority = priority;
s->fn = stage;
s->arg = stage_arg;
}
-static int compare_slots(const void *a, const void *b) {
- const stage_slot *sa = (const stage_slot *)a;
- const stage_slot *sb = (const stage_slot *)b;
+static int compare_slots(const void* a, const void* b) {
+ const stage_slot* sa = (const stage_slot*)a;
+ const stage_slot* sb = (const stage_slot*)b;
int c = GPR_ICMP(sa->priority, sb->priority);
if (c != 0) return c;
@@ -85,12 +85,11 @@ void grpc_channel_init_finalize(void) {
void grpc_channel_init_shutdown(void) {
for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
gpr_free(g_slots[i].slots);
- g_slots[i].slots = (stage_slot *)(void *)(uintptr_t)0xdeadbeef;
+ g_slots[i].slots = (stage_slot*)(void*)(uintptr_t)0xdeadbeef;
}
}
-bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
+bool grpc_channel_init_create_stack(grpc_channel_stack_builder* builder,
grpc_channel_stack_type type) {
GPR_ASSERT(g_finalized);
@@ -98,8 +97,8 @@ bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx,
grpc_channel_stack_type_string(type));
for (size_t i = 0; i < g_slots[type].num_slots; i++) {
- const stage_slot *slot = &g_slots[type].slots[i];
- if (!slot->fn(exec_ctx, builder, slot->arg)) {
+ const stage_slot* slot = &g_slots[type].slots[i];
+ if (!slot->fn(builder, slot->arg)) {
return false;
}
}
diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h
index 5f109332ad..d702f0f325 100644
--- a/src/core/lib/surface/channel_init.h
+++ b/src/core/lib/surface/channel_init.h
@@ -25,10 +25,6 @@
#define GRPC_CHANNEL_INIT_BUILTIN_PRIORITY 10000
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// This module provides a way for plugins (and the grpc core library itself)
/// to register mutators for channel stacks.
/// It also provides a universal entry path to run those mutators to build
@@ -36,9 +32,8 @@ extern "C" {
/// One stage of mutation: call functions against \a builder to influence the
/// finally constructed channel stack
-typedef bool (*grpc_channel_init_stage)(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg);
+typedef bool (*grpc_channel_init_stage)(grpc_channel_stack_builder* builder,
+ void* arg);
/// Global initialization of the system
void grpc_channel_init_init(void);
@@ -51,7 +46,7 @@ void grpc_channel_init_init(void);
void grpc_channel_init_register_stage(grpc_channel_stack_type type,
int priority,
grpc_channel_init_stage stage_fn,
- void *stage_arg);
+ void* stage_arg);
/// Finalize registration. No more calls to grpc_channel_init_register_stage are
/// allowed.
@@ -70,12 +65,7 @@ void grpc_channel_init_shutdown(void);
/// \a optional_transport is either NULL or a constructed transport object
/// Returns a pointer to the base of the memory allocated (the actual channel
/// stack object will be prefix_bytes past that pointer)
-bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
+bool grpc_channel_init_create_stack(grpc_channel_stack_builder* builder,
grpc_channel_stack_type type);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H */
diff --git a/src/core/lib/surface/channel_ping.c b/src/core/lib/surface/channel_ping.cc
index f45b568958..a030d8d0f0 100644
--- a/src/core/lib/surface/channel_ping.c
+++ b/src/core/lib/surface/channel_ping.cc
@@ -28,38 +28,36 @@
typedef struct {
grpc_closure closure;
- void *tag;
- grpc_completion_queue *cq;
+ void* tag;
+ grpc_completion_queue* cq;
grpc_cq_completion completion_storage;
} ping_result;
-static void ping_destroy(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *storage) {
+static void ping_destroy(void* arg, grpc_cq_completion* storage) {
gpr_free(arg);
}
-static void ping_done(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- ping_result *pr = (ping_result *)arg;
- grpc_cq_end_op(exec_ctx, pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy,
- pr, &pr->completion_storage);
+static void ping_done(void* arg, grpc_error* error) {
+ ping_result* pr = (ping_result*)arg;
+ grpc_cq_end_op(pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy, pr,
+ &pr->completion_storage);
}
-void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
- void *tag, void *reserved) {
+void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
+ void* tag, void* reserved) {
GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4,
(channel, cq, tag, reserved));
- grpc_transport_op *op = grpc_make_transport_op(NULL);
- ping_result *pr = (ping_result *)gpr_malloc(sizeof(*pr));
- grpc_channel_element *top_elem =
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ ping_result* pr = (ping_result*)gpr_malloc(sizeof(*pr));
+ grpc_channel_element* top_elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(reserved == NULL);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(reserved == nullptr);
pr->tag = tag;
pr->cq = cq;
GRPC_CLOSURE_INIT(&pr->closure, ping_done, pr, grpc_schedule_on_exec_ctx);
- op->send_ping = &pr->closure;
+ op->send_ping.on_ack = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
- top_elem->filter->start_transport_op(&exec_ctx, top_elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ top_elem->filter->start_transport_op(top_elem, op);
}
diff --git a/src/core/lib/surface/channel_stack_type.c b/src/core/lib/surface/channel_stack_type.cc
index 5f5c877727..366c452942 100644
--- a/src/core/lib/surface/channel_stack_type.c
+++ b/src/core/lib/surface/channel_stack_type.cc
@@ -38,7 +38,7 @@ bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type) {
GPR_UNREACHABLE_CODE(return true;);
}
-const char *grpc_channel_stack_type_string(grpc_channel_stack_type type) {
+const char* grpc_channel_stack_type_string(grpc_channel_stack_type type) {
switch (type) {
case GRPC_CLIENT_CHANNEL:
return "CLIENT_CHANNEL";
diff --git a/src/core/lib/surface/channel_stack_type.h b/src/core/lib/surface/channel_stack_type.h
index 3f0e14ffc0..52f85a6406 100644
--- a/src/core/lib/surface/channel_stack_type.h
+++ b/src/core/lib/surface/channel_stack_type.h
@@ -40,6 +40,6 @@ typedef enum {
bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type);
-const char *grpc_channel_stack_type_string(grpc_channel_stack_type type);
+const char* grpc_channel_stack_type_string(grpc_channel_stack_type type);
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */
diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c
deleted file mode 100644
index fed66e3a20..0000000000
--- a/src/core/lib/surface/completion_queue.c
+++ /dev/null
@@ -1,1249 +0,0 @@
-/*
- *
- * Copyright 2015-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 "src/core/lib/surface/completion_queue.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/atm.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/time.h>
-
-#include "src/core/lib/debug/stats.h"
-#include "src/core/lib/iomgr/pollset.h"
-#include "src/core/lib/iomgr/timer.h"
-#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/spinlock.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/surface/api_trace.h"
-#include "src/core/lib/surface/call.h"
-#include "src/core/lib/surface/event_string.h"
-
-grpc_tracer_flag grpc_trace_operation_failures =
- GRPC_TRACER_INITIALIZER(false, "op_failure");
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_pending_tags =
- GRPC_TRACER_INITIALIZER(false, "pending_tags");
-grpc_tracer_flag grpc_trace_cq_refcount =
- GRPC_TRACER_INITIALIZER(false, "cq_refcount");
-#endif
-
-typedef struct {
- grpc_pollset_worker **worker;
- void *tag;
-} plucker;
-
-typedef struct {
- bool can_get_pollset;
- bool can_listen;
- size_t (*size)(void);
- void (*init)(grpc_pollset *pollset, gpr_mu **mu);
- grpc_error *(*kick)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker);
- grpc_error *(*work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker **worker, gpr_timespec now,
- gpr_timespec deadline);
- void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_closure *closure);
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset);
-} cq_poller_vtable;
-
-typedef struct non_polling_worker {
- gpr_cv cv;
- bool kicked;
- struct non_polling_worker *next;
- struct non_polling_worker *prev;
-} non_polling_worker;
-
-typedef struct {
- gpr_mu mu;
- non_polling_worker *root;
- grpc_closure *shutdown;
-} non_polling_poller;
-
-static size_t non_polling_poller_size(void) {
- return sizeof(non_polling_poller);
-}
-
-static void non_polling_poller_init(grpc_pollset *pollset, gpr_mu **mu) {
- non_polling_poller *npp = (non_polling_poller *)pollset;
- gpr_mu_init(&npp->mu);
- *mu = &npp->mu;
-}
-
-static void non_polling_poller_destroy(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset) {
- non_polling_poller *npp = (non_polling_poller *)pollset;
- gpr_mu_destroy(&npp->mu);
-}
-
-static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset,
- grpc_pollset_worker **worker,
- gpr_timespec now,
- gpr_timespec deadline) {
- non_polling_poller *npp = (non_polling_poller *)pollset;
- if (npp->shutdown) return GRPC_ERROR_NONE;
- non_polling_worker w;
- gpr_cv_init(&w.cv);
- if (worker != NULL) *worker = (grpc_pollset_worker *)&w;
- if (npp->root == NULL) {
- npp->root = w.next = w.prev = &w;
- } else {
- w.next = npp->root;
- w.prev = w.next->prev;
- w.next->prev = w.prev->next = &w;
- }
- w.kicked = false;
- while (!npp->shutdown && !w.kicked && !gpr_cv_wait(&w.cv, &npp->mu, deadline))
- ;
- if (&w == npp->root) {
- npp->root = w.next;
- if (&w == npp->root) {
- if (npp->shutdown) {
- GRPC_CLOSURE_SCHED(exec_ctx, npp->shutdown, GRPC_ERROR_NONE);
- }
- npp->root = NULL;
- }
- }
- w.next->prev = w.prev;
- w.prev->next = w.next;
- gpr_cv_destroy(&w.cv);
- if (worker != NULL) *worker = NULL;
- return GRPC_ERROR_NONE;
-}
-
-static grpc_error *non_polling_poller_kick(
- grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
- grpc_pollset_worker *specific_worker) {
- non_polling_poller *p = (non_polling_poller *)pollset;
- if (specific_worker == NULL) specific_worker = (grpc_pollset_worker *)p->root;
- if (specific_worker != NULL) {
- non_polling_worker *w = (non_polling_worker *)specific_worker;
- if (!w->kicked) {
- w->kicked = true;
- gpr_cv_signal(&w->cv);
- }
- }
- return GRPC_ERROR_NONE;
-}
-
-static void non_polling_poller_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_pollset *pollset,
- grpc_closure *closure) {
- non_polling_poller *p = (non_polling_poller *)pollset;
- GPR_ASSERT(closure != NULL);
- p->shutdown = closure;
- if (p->root == NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
- } else {
- non_polling_worker *w = p->root;
- do {
- gpr_cv_signal(&w->cv);
- w = w->next;
- } while (w != p->root);
- }
-}
-
-static const cq_poller_vtable g_poller_vtable_by_poller_type[] = {
- /* GRPC_CQ_DEFAULT_POLLING */
- {.can_get_pollset = true,
- .can_listen = true,
- .size = grpc_pollset_size,
- .init = grpc_pollset_init,
- .kick = grpc_pollset_kick,
- .work = grpc_pollset_work,
- .shutdown = grpc_pollset_shutdown,
- .destroy = grpc_pollset_destroy},
- /* GRPC_CQ_NON_LISTENING */
- {.can_get_pollset = true,
- .can_listen = false,
- .size = grpc_pollset_size,
- .init = grpc_pollset_init,
- .kick = grpc_pollset_kick,
- .work = grpc_pollset_work,
- .shutdown = grpc_pollset_shutdown,
- .destroy = grpc_pollset_destroy},
- /* GRPC_CQ_NON_POLLING */
- {.can_get_pollset = false,
- .can_listen = false,
- .size = non_polling_poller_size,
- .init = non_polling_poller_init,
- .kick = non_polling_poller_kick,
- .work = non_polling_poller_work,
- .shutdown = non_polling_poller_shutdown,
- .destroy = non_polling_poller_destroy},
-};
-
-typedef struct cq_vtable {
- grpc_cq_completion_type cq_completion_type;
- size_t data_size;
- void (*init)(void *data);
- void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq);
- void (*destroy)(void *data);
- bool (*begin_op)(grpc_completion_queue *cq, void *tag);
- void (*end_op)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq, void *tag,
- grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage);
- grpc_event (*next)(grpc_completion_queue *cq, gpr_timespec deadline,
- void *reserved);
- grpc_event (*pluck)(grpc_completion_queue *cq, void *tag,
- gpr_timespec deadline, void *reserved);
-} cq_vtable;
-
-/* Queue that holds the cq_completion_events. Internally uses gpr_mpscq queue
- * (a lockfree multiproducer single consumer queue). It uses a queue_lock
- * to support multiple consumers.
- * Only used in completion queues whose completion_type is GRPC_CQ_NEXT */
-typedef struct grpc_cq_event_queue {
- /* Spinlock to serialize consumers i.e pop() operations */
- gpr_spinlock queue_lock;
-
- gpr_mpscq queue;
-
- /* A lazy counter of number of items in the queue. This is NOT atomically
- incremented/decremented along with push/pop operations and hence is only
- eventually consistent */
- gpr_atm num_queue_items;
-} grpc_cq_event_queue;
-
-typedef struct cq_next_data {
- /** Completed events for completion-queues of type GRPC_CQ_NEXT */
- grpc_cq_event_queue queue;
-
- /** Counter of how many things have ever been queued on this completion queue
- useful for avoiding locks to check the queue */
- gpr_atm things_queued_ever;
-
- /* Number of outstanding events (+1 if not shut down) */
- gpr_atm pending_events;
-
- /** 0 initially. 1 once we initiated shutdown */
- bool shutdown_called;
-} cq_next_data;
-
-typedef struct cq_pluck_data {
- /** Completed events for completion-queues of type GRPC_CQ_PLUCK */
- grpc_cq_completion completed_head;
- grpc_cq_completion *completed_tail;
-
- /** Number of pending events (+1 if we're not shutdown) */
- gpr_atm pending_events;
-
- /** Counter of how many things have ever been queued on this completion queue
- useful for avoiding locks to check the queue */
- gpr_atm things_queued_ever;
-
- /** 0 initially. 1 once we completed shutting */
- /* TODO: (sreek) This is not needed since (shutdown == 1) if and only if
- * (pending_events == 0). So consider removing this in future and use
- * pending_events */
- gpr_atm shutdown;
-
- /** 0 initially. 1 once we initiated shutdown */
- bool shutdown_called;
-
- int num_pluckers;
- plucker pluckers[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
-} cq_pluck_data;
-
-/* Completion queue structure */
-struct grpc_completion_queue {
- /** Once owning_refs drops to zero, we will destroy the cq */
- gpr_refcount owning_refs;
-
- gpr_mu *mu;
-
- const cq_vtable *vtable;
- const cq_poller_vtable *poller_vtable;
-
-#ifndef NDEBUG
- void **outstanding_tags;
- size_t outstanding_tag_count;
- size_t outstanding_tag_capacity;
-#endif
-
- grpc_closure pollset_shutdown_done;
- int num_polls;
-};
-
-/* Forward declarations */
-static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq);
-static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq);
-static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq);
-static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq);
-
-static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag);
-static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag);
-
-static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq, void *tag,
- grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx,
- void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage);
-
-static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq, void *tag,
- grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx,
- void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage);
-
-static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
- void *reserved);
-
-static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
- gpr_timespec deadline, void *reserved);
-
-static void cq_init_next(void *data);
-static void cq_init_pluck(void *data);
-static void cq_destroy_next(void *data);
-static void cq_destroy_pluck(void *data);
-
-/* Completion queue vtables based on the completion-type */
-static const cq_vtable g_cq_vtable[] = {
- /* GRPC_CQ_NEXT */
- {GRPC_CQ_NEXT, sizeof(cq_next_data), cq_init_next, cq_shutdown_next,
- cq_destroy_next, cq_begin_op_for_next, cq_end_op_for_next, cq_next, NULL},
- /* GRPC_CQ_PLUCK */
- {GRPC_CQ_PLUCK, sizeof(cq_pluck_data), cq_init_pluck, cq_shutdown_pluck,
- cq_destroy_pluck, cq_begin_op_for_pluck, cq_end_op_for_pluck, NULL,
- cq_pluck},
-};
-
-#define DATA_FROM_CQ(cq) ((void *)(cq + 1))
-#define POLLSET_FROM_CQ(cq) \
- ((grpc_pollset *)(cq->vtable->data_size + (char *)DATA_FROM_CQ(cq)))
-
-grpc_tracer_flag grpc_cq_pluck_trace =
- GRPC_TRACER_INITIALIZER(true, "queue_pluck");
-grpc_tracer_flag grpc_cq_event_timeout_trace =
- GRPC_TRACER_INITIALIZER(true, "queue_timeout");
-
-#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
- if (GRPC_TRACER_ON(grpc_api_trace) && \
- (GRPC_TRACER_ON(grpc_cq_pluck_trace) || \
- (event)->type != GRPC_QUEUE_TIMEOUT)) { \
- char *_ev = grpc_event_string(event); \
- gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \
- gpr_free(_ev); \
- }
-
-static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cq,
- grpc_error *error);
-
-static void cq_event_queue_init(grpc_cq_event_queue *q) {
- gpr_mpscq_init(&q->queue);
- q->queue_lock = GPR_SPINLOCK_INITIALIZER;
- gpr_atm_no_barrier_store(&q->num_queue_items, 0);
-}
-
-static void cq_event_queue_destroy(grpc_cq_event_queue *q) {
- gpr_mpscq_destroy(&q->queue);
-}
-
-static bool cq_event_queue_push(grpc_cq_event_queue *q, grpc_cq_completion *c) {
- gpr_mpscq_push(&q->queue, (gpr_mpscq_node *)c);
- return gpr_atm_no_barrier_fetch_add(&q->num_queue_items, 1) == 0;
-}
-
-static grpc_cq_completion *cq_event_queue_pop(grpc_cq_event_queue *q) {
- grpc_cq_completion *c = NULL;
- if (gpr_spinlock_trylock(&q->queue_lock)) {
- c = (grpc_cq_completion *)gpr_mpscq_pop(&q->queue);
- gpr_spinlock_unlock(&q->queue_lock);
- }
-
- if (c) {
- gpr_atm_no_barrier_fetch_add(&q->num_queue_items, -1);
- }
-
- return c;
-}
-
-/* Note: The counter is not incremented/decremented atomically with push/pop.
- * The count is only eventually consistent */
-static long cq_event_queue_num_items(grpc_cq_event_queue *q) {
- return (long)gpr_atm_no_barrier_load(&q->num_queue_items);
-}
-
-grpc_completion_queue *grpc_completion_queue_create_internal(
- grpc_cq_completion_type completion_type,
- grpc_cq_polling_type polling_type) {
- grpc_completion_queue *cq;
-
- GPR_TIMER_BEGIN("grpc_completion_queue_create_internal", 0);
-
- GRPC_API_TRACE(
- "grpc_completion_queue_create_internal(completion_type=%d, "
- "polling_type=%d)",
- 2, (completion_type, polling_type));
-
- const cq_vtable *vtable = &g_cq_vtable[completion_type];
- const cq_poller_vtable *poller_vtable =
- &g_poller_vtable_by_poller_type[polling_type];
-
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_CQS_CREATED(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
-
- cq = (grpc_completion_queue *)gpr_zalloc(sizeof(grpc_completion_queue) +
- vtable->data_size +
- poller_vtable->size());
-
- cq->vtable = vtable;
- cq->poller_vtable = poller_vtable;
-
- /* One for destroy(), one for pollset_shutdown */
- gpr_ref_init(&cq->owning_refs, 2);
-
- poller_vtable->init(POLLSET_FROM_CQ(cq), &cq->mu);
- vtable->init(DATA_FROM_CQ(cq));
-
- GRPC_CLOSURE_INIT(&cq->pollset_shutdown_done, on_pollset_shutdown_done, cq,
- grpc_schedule_on_exec_ctx);
-
- GPR_TIMER_END("grpc_completion_queue_create_internal", 0);
-
- return cq;
-}
-
-static void cq_init_next(void *ptr) {
- cq_next_data *cqd = (cq_next_data *)ptr;
- /* Initial count is dropped by grpc_completion_queue_shutdown */
- gpr_atm_no_barrier_store(&cqd->pending_events, 1);
- cqd->shutdown_called = false;
- gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
- cq_event_queue_init(&cqd->queue);
-}
-
-static void cq_destroy_next(void *ptr) {
- cq_next_data *cqd = (cq_next_data *)ptr;
- GPR_ASSERT(cq_event_queue_num_items(&cqd->queue) == 0);
- cq_event_queue_destroy(&cqd->queue);
-}
-
-static void cq_init_pluck(void *ptr) {
- cq_pluck_data *cqd = (cq_pluck_data *)ptr;
- /* Initial count is dropped by grpc_completion_queue_shutdown */
- gpr_atm_no_barrier_store(&cqd->pending_events, 1);
- cqd->completed_tail = &cqd->completed_head;
- cqd->completed_head.next = (uintptr_t)cqd->completed_tail;
- gpr_atm_no_barrier_store(&cqd->shutdown, 0);
- cqd->shutdown_called = false;
- cqd->num_pluckers = 0;
- gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
-}
-
-static void cq_destroy_pluck(void *ptr) {
- cq_pluck_data *cqd = (cq_pluck_data *)ptr;
- GPR_ASSERT(cqd->completed_head.next == (uintptr_t)&cqd->completed_head);
-}
-
-grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cq) {
- return cq->vtable->cq_completion_type;
-}
-
-int grpc_get_cq_poll_num(grpc_completion_queue *cq) {
- int cur_num_polls;
- gpr_mu_lock(cq->mu);
- cur_num_polls = cq->num_polls;
- gpr_mu_unlock(cq->mu);
- return cur_num_polls;
-}
-
-#ifndef NDEBUG
-void grpc_cq_internal_ref(grpc_completion_queue *cq, const char *reason,
- const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
- gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1,
- reason);
- }
-#else
-void grpc_cq_internal_ref(grpc_completion_queue *cq) {
-#endif
- gpr_ref(&cq->owning_refs);
-}
-
-static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_completion_queue *cq = (grpc_completion_queue *)arg;
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "pollset_destroy");
-}
-
-#ifndef NDEBUG
-void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq,
- const char *reason, const char *file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
- gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1,
- reason);
- }
-#else
-void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq) {
-#endif
- if (gpr_unref(&cq->owning_refs)) {
- cq->vtable->destroy(DATA_FROM_CQ(cq));
- cq->poller_vtable->destroy(exec_ctx, POLLSET_FROM_CQ(cq));
-#ifndef NDEBUG
- gpr_free(cq->outstanding_tags);
-#endif
- gpr_free(cq);
- }
-}
-
-#ifndef NDEBUG
-static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {
- int found = 0;
- if (lock_cq) {
- gpr_mu_lock(cq->mu);
- }
-
- for (int i = 0; i < (int)cq->outstanding_tag_count; i++) {
- if (cq->outstanding_tags[i] == tag) {
- cq->outstanding_tag_count--;
- GPR_SWAP(void *, cq->outstanding_tags[i],
- cq->outstanding_tags[cq->outstanding_tag_count]);
- found = 1;
- break;
- }
- }
-
- if (lock_cq) {
- gpr_mu_unlock(cq->mu);
- }
-
- GPR_ASSERT(found);
-}
-#else
-static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {}
-#endif
-
-/* Atomically increments a counter only if the counter is not zero. Returns
- * true if the increment was successful; false if the counter is zero */
-static bool atm_inc_if_nonzero(gpr_atm *counter) {
- while (true) {
- gpr_atm count = gpr_atm_acq_load(counter);
- /* If zero, we are done. If not, we must to a CAS (instead of an atomic
- * increment) to maintain the contract: do not increment the counter if it
- * is zero. */
- if (count == 0) {
- return false;
- } else if (gpr_atm_full_cas(counter, count, count + 1)) {
- break;
- }
- }
-
- return true;
-}
-
-static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag) {
- cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
- return atm_inc_if_nonzero(&cqd->pending_events);
-}
-
-static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag) {
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
- return atm_inc_if_nonzero(&cqd->pending_events);
-}
-
-bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag) {
-#ifndef NDEBUG
- gpr_mu_lock(cq->mu);
- if (cq->outstanding_tag_count == cq->outstanding_tag_capacity) {
- cq->outstanding_tag_capacity = GPR_MAX(4, 2 * cq->outstanding_tag_capacity);
- cq->outstanding_tags = (void **)gpr_realloc(
- cq->outstanding_tags,
- sizeof(*cq->outstanding_tags) * cq->outstanding_tag_capacity);
- }
- cq->outstanding_tags[cq->outstanding_tag_count++] = tag;
- gpr_mu_unlock(cq->mu);
-#endif
- return cq->vtable->begin_op(cq, tag);
-}
-
-/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
- * completion
- * type of GRPC_CQ_NEXT) */
-static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq, void *tag,
- grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx,
- void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage) {
- GPR_TIMER_BEGIN("cq_end_op_for_next", 0);
-
- if (GRPC_TRACER_ON(grpc_api_trace) ||
- (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
- error != GRPC_ERROR_NONE)) {
- const char *errmsg = grpc_error_string(error);
- GRPC_API_TRACE(
- "cq_end_op_for_next(exec_ctx=%p, cq=%p, tag=%p, error=%s, "
- "done=%p, done_arg=%p, storage=%p)",
- 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
- if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
- error != GRPC_ERROR_NONE) {
- gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
- }
- }
-
- cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
- int is_success = (error == GRPC_ERROR_NONE);
-
- storage->tag = tag;
- storage->done = done;
- storage->done_arg = done_arg;
- storage->next = (uintptr_t)(is_success);
-
- cq_check_tag(cq, tag, true); /* Used in debug builds only */
-
- /* Add the completion to the queue */
- bool is_first = cq_event_queue_push(&cqd->queue, storage);
- gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
-
- /* Since we do not hold the cq lock here, it is important to do an 'acquire'
- load here (instead of a 'no_barrier' load) to match with the release store
- (done via gpr_atm_full_fetch_add(pending_events, -1)) in cq_shutdown_next
- */
- bool will_definitely_shutdown = gpr_atm_acq_load(&cqd->pending_events) == 1;
-
- if (!will_definitely_shutdown) {
- /* Only kick if this is the first item queued */
- if (is_first) {
- gpr_mu_lock(cq->mu);
- grpc_error *kick_error =
- cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), NULL);
- gpr_mu_unlock(cq->mu);
-
- if (kick_error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(kick_error);
- gpr_log(GPR_ERROR, "Kick failed: %s", msg);
- GRPC_ERROR_UNREF(kick_error);
- }
- }
- if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
- gpr_mu_lock(cq->mu);
- cq_finish_shutdown_next(exec_ctx, cq);
- gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
- }
- } else {
- GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
- gpr_atm_rel_store(&cqd->pending_events, 0);
- gpr_mu_lock(cq->mu);
- cq_finish_shutdown_next(exec_ctx, cq);
- gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
- }
-
- GPR_TIMER_END("cq_end_op_for_next", 0);
-
- GRPC_ERROR_UNREF(error);
-}
-
-/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
- * completion
- * type of GRPC_CQ_PLUCK) */
-static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq, void *tag,
- grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx,
- void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage) {
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
- int is_success = (error == GRPC_ERROR_NONE);
-
- GPR_TIMER_BEGIN("cq_end_op_for_pluck", 0);
-
- if (GRPC_TRACER_ON(grpc_api_trace) ||
- (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
- error != GRPC_ERROR_NONE)) {
- const char *errmsg = grpc_error_string(error);
- GRPC_API_TRACE(
- "cq_end_op_for_pluck(exec_ctx=%p, cq=%p, tag=%p, error=%s, "
- "done=%p, done_arg=%p, storage=%p)",
- 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
- if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
- error != GRPC_ERROR_NONE) {
- gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
- }
- }
-
- storage->tag = tag;
- storage->done = done;
- storage->done_arg = done_arg;
- storage->next = ((uintptr_t)&cqd->completed_head) | ((uintptr_t)(is_success));
-
- gpr_mu_lock(cq->mu);
- cq_check_tag(cq, tag, false); /* Used in debug builds only */
-
- /* Add to the list of completions */
- gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
- cqd->completed_tail->next =
- ((uintptr_t)storage) | (1u & (uintptr_t)cqd->completed_tail->next);
- cqd->completed_tail = storage;
-
- if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- cq_finish_shutdown_pluck(exec_ctx, cq);
- gpr_mu_unlock(cq->mu);
- } else {
- grpc_pollset_worker *pluck_worker = NULL;
- for (int i = 0; i < cqd->num_pluckers; i++) {
- if (cqd->pluckers[i].tag == tag) {
- pluck_worker = *cqd->pluckers[i].worker;
- break;
- }
- }
-
- grpc_error *kick_error =
- cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), pluck_worker);
-
- gpr_mu_unlock(cq->mu);
-
- if (kick_error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(kick_error);
- gpr_log(GPR_ERROR, "Kick failed: %s", msg);
-
- GRPC_ERROR_UNREF(kick_error);
- }
- }
-
- GPR_TIMER_END("cq_end_op_for_pluck", 0);
-
- GRPC_ERROR_UNREF(error);
-}
-
-void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq,
- void *tag, grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage) {
- cq->vtable->end_op(exec_ctx, cq, tag, error, done, done_arg, storage);
-}
-
-typedef struct {
- gpr_atm last_seen_things_queued_ever;
- grpc_completion_queue *cq;
- gpr_timespec deadline;
- grpc_cq_completion *stolen_completion;
- void *tag; /* for pluck */
- bool first_loop;
-} cq_is_finished_arg;
-
-static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
- cq_is_finished_arg *a = (cq_is_finished_arg *)arg;
- grpc_completion_queue *cq = a->cq;
- cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
- GPR_ASSERT(a->stolen_completion == NULL);
-
- gpr_atm current_last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
-
- if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
- a->last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
-
- /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
- * might return NULL in some cases even if the queue is not empty; but
- * that
- * is ok and doesn't affect correctness. Might effect the tail latencies a
- * bit) */
- a->stolen_completion = cq_event_queue_pop(&cqd->queue);
- if (a->stolen_completion != NULL) {
- return true;
- }
- }
- return !a->first_loop &&
- gpr_time_cmp(a->deadline, gpr_now(a->deadline.clock_type)) < 0;
-}
-
-#ifndef NDEBUG
-static void dump_pending_tags(grpc_completion_queue *cq) {
- if (!GRPC_TRACER_ON(grpc_trace_pending_tags)) return;
-
- gpr_strvec v;
- gpr_strvec_init(&v);
- gpr_strvec_add(&v, gpr_strdup("PENDING TAGS:"));
- gpr_mu_lock(cq->mu);
- for (size_t i = 0; i < cq->outstanding_tag_count; i++) {
- char *s;
- gpr_asprintf(&s, " %p", cq->outstanding_tags[i]);
- gpr_strvec_add(&v, s);
- }
- gpr_mu_unlock(cq->mu);
- char *out = gpr_strvec_flatten(&v, NULL);
- gpr_strvec_destroy(&v);
- gpr_log(GPR_DEBUG, "%s", out);
- gpr_free(out);
-}
-#else
-static void dump_pending_tags(grpc_completion_queue *cq) {}
-#endif
-
-static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
- void *reserved) {
- grpc_event ret;
- gpr_timespec now;
- cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
-
- GPR_TIMER_BEGIN("grpc_completion_queue_next", 0);
-
- GRPC_API_TRACE(
- "grpc_completion_queue_next("
- "cq=%p, "
- "deadline=gpr_timespec { tv_sec: %" PRId64
- ", tv_nsec: %d, clock_type: %d }, "
- "reserved=%p)",
- 5, (cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
- reserved));
- GPR_ASSERT(!reserved);
-
- dump_pending_tags(cq);
-
- deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
-
- GRPC_CQ_INTERNAL_REF(cq, "next");
-
- cq_is_finished_arg is_finished_arg = {
- .last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever),
- .cq = cq,
- .deadline = deadline,
- .stolen_completion = NULL,
- .tag = NULL,
- .first_loop = true};
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, cq_is_next_finished, &is_finished_arg);
-
- for (;;) {
- gpr_timespec iteration_deadline = deadline;
-
- if (is_finished_arg.stolen_completion != NULL) {
- grpc_cq_completion *c = is_finished_arg.stolen_completion;
- is_finished_arg.stolen_completion = NULL;
- ret.type = GRPC_OP_COMPLETE;
- ret.success = c->next & 1u;
- ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
- break;
- }
-
- grpc_cq_completion *c = cq_event_queue_pop(&cqd->queue);
-
- if (c != NULL) {
- ret.type = GRPC_OP_COMPLETE;
- ret.success = c->next & 1u;
- ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
- break;
- } else {
- /* If c == NULL it means either the queue is empty OR in an transient
- inconsistent state. If it is the latter, we shold do a 0-timeout poll
- so that the thread comes back quickly from poll to make a second
- attempt at popping. Not doing this can potentially deadlock this
- thread forever (if the deadline is infinity) */
- if (cq_event_queue_num_items(&cqd->queue) > 0) {
- iteration_deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
- }
- }
-
- if (gpr_atm_acq_load(&cqd->pending_events) == 0) {
- /* Before returning, check if the queue has any items left over (since
- gpr_mpscq_pop() can sometimes return NULL even if the queue is not
- empty. If so, keep retrying but do not return GRPC_QUEUE_SHUTDOWN */
- if (cq_event_queue_num_items(&cqd->queue) > 0) {
- /* Go to the beginning of the loop. No point doing a poll because
- (cq->shutdown == true) is only possible when there is no pending
- work (i.e cq->pending_events == 0) and any outstanding completion
- events should have already been queued on this cq */
- continue;
- }
-
- memset(&ret, 0, sizeof(ret));
- ret.type = GRPC_QUEUE_SHUTDOWN;
- break;
- }
-
- now = gpr_now(GPR_CLOCK_MONOTONIC);
- if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) {
- memset(&ret, 0, sizeof(ret));
- ret.type = GRPC_QUEUE_TIMEOUT;
- dump_pending_tags(cq);
- break;
- }
-
- /* The main polling work happens in grpc_pollset_work */
- gpr_mu_lock(cq->mu);
- cq->num_polls++;
- grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
- NULL, now, iteration_deadline);
- gpr_mu_unlock(cq->mu);
-
- if (err != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(err);
- gpr_log(GPR_ERROR, "Completion queue next failed: %s", msg);
-
- GRPC_ERROR_UNREF(err);
- memset(&ret, 0, sizeof(ret));
- ret.type = GRPC_QUEUE_TIMEOUT;
- dump_pending_tags(cq);
- break;
- }
- is_finished_arg.first_loop = false;
- }
-
- if (cq_event_queue_num_items(&cqd->queue) > 0 &&
- gpr_atm_acq_load(&cqd->pending_events) > 0) {
- gpr_mu_lock(cq->mu);
- cq->poller_vtable->kick(&exec_ctx, POLLSET_FROM_CQ(cq), NULL);
- gpr_mu_unlock(cq->mu);
- }
-
- GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "next");
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
-
- GPR_TIMER_END("grpc_completion_queue_next", 0);
-
- return ret;
-}
-
-/* Finishes the completion queue shutdown. This means that there are no more
- completion events / tags expected from the completion queue
- - Must be called under completion queue lock
- - Must be called only once in completion queue's lifetime
- - grpc_completion_queue_shutdown() MUST have been called before calling
- this function */
-static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq) {
- cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
-
- GPR_ASSERT(cqd->shutdown_called);
- GPR_ASSERT(gpr_atm_no_barrier_load(&cqd->pending_events) == 0);
-
- cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
- &cq->pollset_shutdown_done);
-}
-
-static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq) {
- cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
-
- /* Need an extra ref for cq here because:
- * We call cq_finish_shutdown_next() below, that would call pollset shutdown.
- * Pollset shutdown decrements the cq ref count which can potentially destroy
- * the cq (if that happens to be the last ref).
- * Creating an extra ref here prevents the cq from getting destroyed while
- * this function is still active */
- GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
- gpr_mu_lock(cq->mu);
- if (cqd->shutdown_called) {
- gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
- return;
- }
- cqd->shutdown_called = true;
- /* Doing a full_fetch_add (i.e acq/release) here to match with
- * cq_begin_op_for_next and and cq_end_op_for_next functions which read/write
- * on this counter without necessarily holding a lock on cq */
- if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- cq_finish_shutdown_next(exec_ctx, cq);
- }
- gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
-}
-
-grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
- gpr_timespec deadline, void *reserved) {
- return cq->vtable->next(cq, deadline, reserved);
-}
-
-static int add_plucker(grpc_completion_queue *cq, void *tag,
- grpc_pollset_worker **worker) {
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
- if (cqd->num_pluckers == GRPC_MAX_COMPLETION_QUEUE_PLUCKERS) {
- return 0;
- }
- cqd->pluckers[cqd->num_pluckers].tag = tag;
- cqd->pluckers[cqd->num_pluckers].worker = worker;
- cqd->num_pluckers++;
- return 1;
-}
-
-static void del_plucker(grpc_completion_queue *cq, void *tag,
- grpc_pollset_worker **worker) {
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
- for (int i = 0; i < cqd->num_pluckers; i++) {
- if (cqd->pluckers[i].tag == tag && cqd->pluckers[i].worker == worker) {
- cqd->num_pluckers--;
- GPR_SWAP(plucker, cqd->pluckers[i], cqd->pluckers[cqd->num_pluckers]);
- return;
- }
- }
- GPR_UNREACHABLE_CODE(return );
-}
-
-static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) {
- cq_is_finished_arg *a = (cq_is_finished_arg *)arg;
- grpc_completion_queue *cq = a->cq;
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
-
- GPR_ASSERT(a->stolen_completion == NULL);
- gpr_atm current_last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
- gpr_mu_lock(cq->mu);
- a->last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- grpc_cq_completion *c;
- grpc_cq_completion *prev = &cqd->completed_head;
- while ((c = (grpc_cq_completion *)(prev->next & ~(uintptr_t)1)) !=
- &cqd->completed_head) {
- if (c->tag == a->tag) {
- prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
- if (c == cqd->completed_tail) {
- cqd->completed_tail = prev;
- }
- gpr_mu_unlock(cq->mu);
- a->stolen_completion = c;
- return true;
- }
- prev = c;
- }
- gpr_mu_unlock(cq->mu);
- }
- return !a->first_loop &&
- gpr_time_cmp(a->deadline, gpr_now(a->deadline.clock_type)) < 0;
-}
-
-static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
- gpr_timespec deadline, void *reserved) {
- grpc_event ret;
- grpc_cq_completion *c;
- grpc_cq_completion *prev;
- grpc_pollset_worker *worker = NULL;
- gpr_timespec now;
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
-
- GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0);
-
- if (GRPC_TRACER_ON(grpc_cq_pluck_trace)) {
- GRPC_API_TRACE(
- "grpc_completion_queue_pluck("
- "cq=%p, tag=%p, "
- "deadline=gpr_timespec { tv_sec: %" PRId64
- ", tv_nsec: %d, clock_type: %d }, "
- "reserved=%p)",
- 6, (cq, tag, deadline.tv_sec, deadline.tv_nsec,
- (int)deadline.clock_type, reserved));
- }
- GPR_ASSERT(!reserved);
-
- dump_pending_tags(cq);
-
- deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
-
- GRPC_CQ_INTERNAL_REF(cq, "pluck");
- gpr_mu_lock(cq->mu);
- cq_is_finished_arg is_finished_arg = {
- .last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever),
- .cq = cq,
- .deadline = deadline,
- .stolen_completion = NULL,
- .tag = tag,
- .first_loop = true};
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg);
- for (;;) {
- if (is_finished_arg.stolen_completion != NULL) {
- gpr_mu_unlock(cq->mu);
- c = is_finished_arg.stolen_completion;
- is_finished_arg.stolen_completion = NULL;
- ret.type = GRPC_OP_COMPLETE;
- ret.success = c->next & 1u;
- ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
- break;
- }
- prev = &cqd->completed_head;
- while ((c = (grpc_cq_completion *)(prev->next & ~(uintptr_t)1)) !=
- &cqd->completed_head) {
- if (c->tag == tag) {
- prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
- if (c == cqd->completed_tail) {
- cqd->completed_tail = prev;
- }
- gpr_mu_unlock(cq->mu);
- ret.type = GRPC_OP_COMPLETE;
- ret.success = c->next & 1u;
- ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
- goto done;
- }
- prev = c;
- }
- if (gpr_atm_no_barrier_load(&cqd->shutdown)) {
- gpr_mu_unlock(cq->mu);
- memset(&ret, 0, sizeof(ret));
- ret.type = GRPC_QUEUE_SHUTDOWN;
- break;
- }
- if (!add_plucker(cq, tag, &worker)) {
- gpr_log(GPR_DEBUG,
- "Too many outstanding grpc_completion_queue_pluck calls: maximum "
- "is %d",
- GRPC_MAX_COMPLETION_QUEUE_PLUCKERS);
- gpr_mu_unlock(cq->mu);
- memset(&ret, 0, sizeof(ret));
- /* TODO(ctiller): should we use a different result here */
- ret.type = GRPC_QUEUE_TIMEOUT;
- dump_pending_tags(cq);
- break;
- }
- now = gpr_now(GPR_CLOCK_MONOTONIC);
- if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) {
- del_plucker(cq, tag, &worker);
- gpr_mu_unlock(cq->mu);
- memset(&ret, 0, sizeof(ret));
- ret.type = GRPC_QUEUE_TIMEOUT;
- dump_pending_tags(cq);
- break;
- }
-
- cq->num_polls++;
- grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
- &worker, now, deadline);
- if (err != GRPC_ERROR_NONE) {
- del_plucker(cq, tag, &worker);
- gpr_mu_unlock(cq->mu);
- const char *msg = grpc_error_string(err);
- gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", msg);
-
- GRPC_ERROR_UNREF(err);
- memset(&ret, 0, sizeof(ret));
- ret.type = GRPC_QUEUE_TIMEOUT;
- dump_pending_tags(cq);
- break;
- }
- is_finished_arg.first_loop = false;
- del_plucker(cq, tag, &worker);
- }
-done:
- GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "pluck");
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
-
- GPR_TIMER_END("grpc_completion_queue_pluck", 0);
-
- return ret;
-}
-
-grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
- gpr_timespec deadline, void *reserved) {
- return cq->vtable->pluck(cq, tag, deadline, reserved);
-}
-
-static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq) {
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
-
- GPR_ASSERT(cqd->shutdown_called);
- GPR_ASSERT(!gpr_atm_no_barrier_load(&cqd->shutdown));
- gpr_atm_no_barrier_store(&cqd->shutdown, 1);
-
- cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
- &cq->pollset_shutdown_done);
-}
-
-/* NOTE: This function is almost exactly identical to cq_shutdown_next() but
- * merging them is a bit tricky and probably not worth it */
-static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
- grpc_completion_queue *cq) {
- cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
-
- /* Need an extra ref for cq here because:
- * We call cq_finish_shutdown_pluck() below, that would call pollset shutdown.
- * Pollset shutdown decrements the cq ref count which can potentially destroy
- * the cq (if that happens to be the last ref).
- * Creating an extra ref here prevents the cq from getting destroyed while
- * this function is still active */
- GRPC_CQ_INTERNAL_REF(cq, "shutting_down (pluck cq)");
- gpr_mu_lock(cq->mu);
- if (cqd->shutdown_called) {
- gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
- return;
- }
- cqd->shutdown_called = true;
- if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- cq_finish_shutdown_pluck(exec_ctx, cq);
- }
- gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
-}
-
-/* Shutdown simply drops a ref that we reserved at creation time; if we drop
- to zero here, then enter shutdown mode and wake up any waiters */
-void grpc_completion_queue_shutdown(grpc_completion_queue *cq) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
- GRPC_API_TRACE("grpc_completion_queue_shutdown(cq=%p)", 1, (cq));
- cq->vtable->shutdown(&exec_ctx, cq);
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
-}
-
-void grpc_completion_queue_destroy(grpc_completion_queue *cq) {
- GRPC_API_TRACE("grpc_completion_queue_destroy(cq=%p)", 1, (cq));
- GPR_TIMER_BEGIN("grpc_completion_queue_destroy", 0);
- grpc_completion_queue_shutdown(cq);
-
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "destroy");
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_TIMER_END("grpc_completion_queue_destroy", 0);
-}
-
-grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cq) {
- return cq->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cq) : NULL;
-}
-
-bool grpc_cq_can_listen(grpc_completion_queue *cq) {
- return cq->poller_vtable->can_listen;
-}
diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc
new file mode 100644
index 0000000000..e731e2139f
--- /dev/null
+++ b/src/core/lib/surface/completion_queue.cc
@@ -0,0 +1,1268 @@
+/*
+ *
+ * Copyright 2015-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 <grpc/support/port_platform.h>
+
+#include "src/core/lib/surface/completion_queue.h"
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/atm.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/time.h>
+#include <grpc/support/tls.h>
+
+#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/iomgr/pollset.h"
+#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/profiling/timers.h"
+#include "src/core/lib/surface/api_trace.h"
+#include "src/core/lib/surface/call.h"
+#include "src/core/lib/surface/event_string.h"
+
+grpc_core::TraceFlag grpc_trace_operation_failures(false, "op_failure");
+grpc_core::DebugOnlyTraceFlag grpc_trace_pending_tags(false, "pending_tags");
+grpc_core::DebugOnlyTraceFlag grpc_trace_cq_refcount(false, "cq_refcount");
+
+// Specifies a cq thread local cache.
+// The first event that occurs on a thread
+// with a cq cache will go into that cache, and
+// will only be returned on the thread that initialized the cache.
+// NOTE: Only one event will ever be cached.
+GPR_TLS_DECL(g_cached_event);
+GPR_TLS_DECL(g_cached_cq);
+
+typedef struct {
+ grpc_pollset_worker** worker;
+ void* tag;
+} plucker;
+
+typedef struct {
+ bool can_get_pollset;
+ bool can_listen;
+ size_t (*size)(void);
+ void (*init)(grpc_pollset* pollset, gpr_mu** mu);
+ grpc_error* (*kick)(grpc_pollset* pollset,
+ grpc_pollset_worker* specific_worker);
+ grpc_error* (*work)(grpc_pollset* pollset, grpc_pollset_worker** worker,
+ grpc_millis deadline);
+ void (*shutdown)(grpc_pollset* pollset, grpc_closure* closure);
+ void (*destroy)(grpc_pollset* pollset);
+} cq_poller_vtable;
+
+typedef struct non_polling_worker {
+ gpr_cv cv;
+ bool kicked;
+ struct non_polling_worker* next;
+ struct non_polling_worker* prev;
+} non_polling_worker;
+
+typedef struct {
+ gpr_mu mu;
+ non_polling_worker* root;
+ grpc_closure* shutdown;
+} non_polling_poller;
+
+static size_t non_polling_poller_size(void) {
+ return sizeof(non_polling_poller);
+}
+
+static void non_polling_poller_init(grpc_pollset* pollset, gpr_mu** mu) {
+ non_polling_poller* npp = (non_polling_poller*)pollset;
+ gpr_mu_init(&npp->mu);
+ *mu = &npp->mu;
+}
+
+static void non_polling_poller_destroy(grpc_pollset* pollset) {
+ non_polling_poller* npp = (non_polling_poller*)pollset;
+ gpr_mu_destroy(&npp->mu);
+}
+
+static grpc_error* non_polling_poller_work(grpc_pollset* pollset,
+ grpc_pollset_worker** worker,
+ grpc_millis deadline) {
+ non_polling_poller* npp = (non_polling_poller*)pollset;
+ if (npp->shutdown) return GRPC_ERROR_NONE;
+ non_polling_worker w;
+ gpr_cv_init(&w.cv);
+ if (worker != nullptr) *worker = (grpc_pollset_worker*)&w;
+ if (npp->root == nullptr) {
+ npp->root = w.next = w.prev = &w;
+ } else {
+ w.next = npp->root;
+ w.prev = w.next->prev;
+ w.next->prev = w.prev->next = &w;
+ }
+ w.kicked = false;
+ gpr_timespec deadline_ts =
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC);
+ while (!npp->shutdown && !w.kicked &&
+ !gpr_cv_wait(&w.cv, &npp->mu, deadline_ts))
+ ;
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ if (&w == npp->root) {
+ npp->root = w.next;
+ if (&w == npp->root) {
+ if (npp->shutdown) {
+ GRPC_CLOSURE_SCHED(npp->shutdown, GRPC_ERROR_NONE);
+ }
+ npp->root = nullptr;
+ }
+ }
+ w.next->prev = w.prev;
+ w.prev->next = w.next;
+ gpr_cv_destroy(&w.cv);
+ if (worker != nullptr) *worker = nullptr;
+ return GRPC_ERROR_NONE;
+}
+
+static grpc_error* non_polling_poller_kick(
+ grpc_pollset* pollset, grpc_pollset_worker* specific_worker) {
+ non_polling_poller* p = (non_polling_poller*)pollset;
+ if (specific_worker == nullptr)
+ specific_worker = (grpc_pollset_worker*)p->root;
+ if (specific_worker != nullptr) {
+ non_polling_worker* w = (non_polling_worker*)specific_worker;
+ if (!w->kicked) {
+ w->kicked = true;
+ gpr_cv_signal(&w->cv);
+ }
+ }
+ return GRPC_ERROR_NONE;
+}
+
+static void non_polling_poller_shutdown(grpc_pollset* pollset,
+ grpc_closure* closure) {
+ non_polling_poller* p = (non_polling_poller*)pollset;
+ GPR_ASSERT(closure != nullptr);
+ p->shutdown = closure;
+ if (p->root == nullptr) {
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
+ } else {
+ non_polling_worker* w = p->root;
+ do {
+ gpr_cv_signal(&w->cv);
+ w = w->next;
+ } while (w != p->root);
+ }
+}
+
+static const cq_poller_vtable g_poller_vtable_by_poller_type[] = {
+ /* GRPC_CQ_DEFAULT_POLLING */
+ {true, true, grpc_pollset_size, grpc_pollset_init, grpc_pollset_kick,
+ grpc_pollset_work, grpc_pollset_shutdown, grpc_pollset_destroy},
+ /* GRPC_CQ_NON_LISTENING */
+ {true, false, grpc_pollset_size, grpc_pollset_init, grpc_pollset_kick,
+ grpc_pollset_work, grpc_pollset_shutdown, grpc_pollset_destroy},
+ /* GRPC_CQ_NON_POLLING */
+ {false, false, non_polling_poller_size, non_polling_poller_init,
+ non_polling_poller_kick, non_polling_poller_work,
+ non_polling_poller_shutdown, non_polling_poller_destroy},
+};
+
+typedef struct cq_vtable {
+ grpc_cq_completion_type cq_completion_type;
+ size_t data_size;
+ void (*init)(void* data);
+ void (*shutdown)(grpc_completion_queue* cq);
+ void (*destroy)(void* data);
+ bool (*begin_op)(grpc_completion_queue* cq, void* tag);
+ void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error,
+ void (*done)(void* done_arg, grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage);
+ grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline,
+ void* reserved);
+ grpc_event (*pluck)(grpc_completion_queue* cq, void* tag,
+ gpr_timespec deadline, void* reserved);
+} cq_vtable;
+
+/* Queue that holds the cq_completion_events. Internally uses gpr_mpscq queue
+ * (a lockfree multiproducer single consumer queue). It uses a queue_lock
+ * to support multiple consumers.
+ * Only used in completion queues whose completion_type is GRPC_CQ_NEXT */
+typedef struct grpc_cq_event_queue {
+ /* Spinlock to serialize consumers i.e pop() operations */
+ gpr_spinlock queue_lock;
+
+ gpr_mpscq queue;
+
+ /* A lazy counter of number of items in the queue. This is NOT atomically
+ incremented/decremented along with push/pop operations and hence is only
+ eventually consistent */
+ gpr_atm num_queue_items;
+} grpc_cq_event_queue;
+
+typedef struct cq_next_data {
+ /** Completed events for completion-queues of type GRPC_CQ_NEXT */
+ grpc_cq_event_queue queue;
+
+ /** Counter of how many things have ever been queued on this completion queue
+ useful for avoiding locks to check the queue */
+ gpr_atm things_queued_ever;
+
+ /* Number of outstanding events (+1 if not shut down) */
+ gpr_atm pending_events;
+
+ /** 0 initially. 1 once we initiated shutdown */
+ bool shutdown_called;
+} cq_next_data;
+
+typedef struct cq_pluck_data {
+ /** Completed events for completion-queues of type GRPC_CQ_PLUCK */
+ grpc_cq_completion completed_head;
+ grpc_cq_completion* completed_tail;
+
+ /** Number of pending events (+1 if we're not shutdown) */
+ gpr_atm pending_events;
+
+ /** Counter of how many things have ever been queued on this completion queue
+ useful for avoiding locks to check the queue */
+ gpr_atm things_queued_ever;
+
+ /** 0 initially. 1 once we completed shutting */
+ /* TODO: (sreek) This is not needed since (shutdown == 1) if and only if
+ * (pending_events == 0). So consider removing this in future and use
+ * pending_events */
+ gpr_atm shutdown;
+
+ /** 0 initially. 1 once we initiated shutdown */
+ bool shutdown_called;
+
+ int num_pluckers;
+ plucker pluckers[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
+} cq_pluck_data;
+
+/* Completion queue structure */
+struct grpc_completion_queue {
+ /** Once owning_refs drops to zero, we will destroy the cq */
+ gpr_refcount owning_refs;
+
+ gpr_mu* mu;
+
+ const cq_vtable* vtable;
+ const cq_poller_vtable* poller_vtable;
+
+#ifndef NDEBUG
+ void** outstanding_tags;
+ size_t outstanding_tag_count;
+ size_t outstanding_tag_capacity;
+#endif
+
+ grpc_closure pollset_shutdown_done;
+ int num_polls;
+};
+
+/* Forward declarations */
+static void cq_finish_shutdown_next(grpc_completion_queue* cq);
+static void cq_finish_shutdown_pluck(grpc_completion_queue* cq);
+static void cq_shutdown_next(grpc_completion_queue* cq);
+static void cq_shutdown_pluck(grpc_completion_queue* cq);
+
+static bool cq_begin_op_for_next(grpc_completion_queue* cq, void* tag);
+static bool cq_begin_op_for_pluck(grpc_completion_queue* cq, void* tag);
+
+static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag,
+ grpc_error* error,
+ void (*done)(void* done_arg,
+ grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage);
+
+static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag,
+ grpc_error* error,
+ void (*done)(void* done_arg,
+ grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage);
+
+static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
+ void* reserved);
+
+static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
+ gpr_timespec deadline, void* reserved);
+
+static void cq_init_next(void* data);
+static void cq_init_pluck(void* data);
+static void cq_destroy_next(void* data);
+static void cq_destroy_pluck(void* data);
+
+/* Completion queue vtables based on the completion-type */
+static const cq_vtable g_cq_vtable[] = {
+ /* GRPC_CQ_NEXT */
+ {GRPC_CQ_NEXT, sizeof(cq_next_data), cq_init_next, cq_shutdown_next,
+ cq_destroy_next, cq_begin_op_for_next, cq_end_op_for_next, cq_next,
+ nullptr},
+ /* GRPC_CQ_PLUCK */
+ {GRPC_CQ_PLUCK, sizeof(cq_pluck_data), cq_init_pluck, cq_shutdown_pluck,
+ cq_destroy_pluck, cq_begin_op_for_pluck, cq_end_op_for_pluck, nullptr,
+ cq_pluck},
+};
+
+#define DATA_FROM_CQ(cq) ((void*)(cq + 1))
+#define POLLSET_FROM_CQ(cq) \
+ ((grpc_pollset*)(cq->vtable->data_size + (char*)DATA_FROM_CQ(cq)))
+
+grpc_core::TraceFlag grpc_cq_pluck_trace(true, "queue_pluck");
+grpc_core::TraceFlag grpc_cq_event_timeout_trace(true, "queue_timeout");
+
+#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
+ if (grpc_api_trace.enabled() && (grpc_cq_pluck_trace.enabled() || \
+ (event)->type != GRPC_QUEUE_TIMEOUT)) { \
+ char* _ev = grpc_event_string(event); \
+ gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \
+ gpr_free(_ev); \
+ }
+
+static void on_pollset_shutdown_done(void* cq, grpc_error* error);
+
+void grpc_cq_global_init() {
+ gpr_tls_init(&g_cached_event);
+ gpr_tls_init(&g_cached_cq);
+}
+
+void grpc_completion_queue_thread_local_cache_init(grpc_completion_queue* cq) {
+ if ((grpc_completion_queue*)gpr_tls_get(&g_cached_cq) == nullptr) {
+ gpr_tls_set(&g_cached_event, (intptr_t)0);
+ gpr_tls_set(&g_cached_cq, (intptr_t)cq);
+ }
+}
+
+int grpc_completion_queue_thread_local_cache_flush(grpc_completion_queue* cq,
+ void** tag, int* ok) {
+ grpc_cq_completion* storage =
+ (grpc_cq_completion*)gpr_tls_get(&g_cached_event);
+ int ret = 0;
+ if (storage != nullptr &&
+ (grpc_completion_queue*)gpr_tls_get(&g_cached_cq) == cq) {
+ *tag = storage->tag;
+ grpc_core::ExecCtx exec_ctx;
+ *ok = (storage->next & (uintptr_t)(1)) == 1;
+ storage->done(storage->done_arg, storage);
+ ret = 1;
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
+ gpr_mu_lock(cq->mu);
+ cq_finish_shutdown_next(cq);
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
+ }
+ }
+ gpr_tls_set(&g_cached_event, (intptr_t)0);
+ gpr_tls_set(&g_cached_cq, (intptr_t)0);
+
+ return ret;
+}
+
+static void cq_event_queue_init(grpc_cq_event_queue* q) {
+ gpr_mpscq_init(&q->queue);
+ q->queue_lock = GPR_SPINLOCK_INITIALIZER;
+ gpr_atm_no_barrier_store(&q->num_queue_items, 0);
+}
+
+static void cq_event_queue_destroy(grpc_cq_event_queue* q) {
+ gpr_mpscq_destroy(&q->queue);
+}
+
+static bool cq_event_queue_push(grpc_cq_event_queue* q, grpc_cq_completion* c) {
+ gpr_mpscq_push(&q->queue, (gpr_mpscq_node*)c);
+ return gpr_atm_no_barrier_fetch_add(&q->num_queue_items, 1) == 0;
+}
+
+static grpc_cq_completion* cq_event_queue_pop(grpc_cq_event_queue* q) {
+ grpc_cq_completion* c = nullptr;
+ grpc_core::ExecCtx exec_ctx;
+
+ if (gpr_spinlock_trylock(&q->queue_lock)) {
+ GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES();
+
+ bool is_empty = false;
+ c = (grpc_cq_completion*)gpr_mpscq_pop_and_check_end(&q->queue, &is_empty);
+ gpr_spinlock_unlock(&q->queue_lock);
+
+ if (c == nullptr && !is_empty) {
+ GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES();
+ }
+ } else {
+ GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES();
+ }
+
+ if (c) {
+ gpr_atm_no_barrier_fetch_add(&q->num_queue_items, -1);
+ }
+
+ return c;
+}
+
+/* Note: The counter is not incremented/decremented atomically with push/pop.
+ * The count is only eventually consistent */
+static long cq_event_queue_num_items(grpc_cq_event_queue* q) {
+ return (long)gpr_atm_no_barrier_load(&q->num_queue_items);
+}
+
+grpc_completion_queue* grpc_completion_queue_create_internal(
+ grpc_cq_completion_type completion_type,
+ grpc_cq_polling_type polling_type) {
+ grpc_completion_queue* cq;
+
+ GPR_TIMER_BEGIN("grpc_completion_queue_create_internal", 0);
+
+ GRPC_API_TRACE(
+ "grpc_completion_queue_create_internal(completion_type=%d, "
+ "polling_type=%d)",
+ 2, (completion_type, polling_type));
+
+ const cq_vtable* vtable = &g_cq_vtable[completion_type];
+ const cq_poller_vtable* poller_vtable =
+ &g_poller_vtable_by_poller_type[polling_type];
+
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_STATS_INC_CQS_CREATED();
+
+ cq = (grpc_completion_queue*)gpr_zalloc(sizeof(grpc_completion_queue) +
+ vtable->data_size +
+ poller_vtable->size());
+
+ cq->vtable = vtable;
+ cq->poller_vtable = poller_vtable;
+
+ /* One for destroy(), one for pollset_shutdown */
+ gpr_ref_init(&cq->owning_refs, 2);
+
+ poller_vtable->init(POLLSET_FROM_CQ(cq), &cq->mu);
+ vtable->init(DATA_FROM_CQ(cq));
+
+ GRPC_CLOSURE_INIT(&cq->pollset_shutdown_done, on_pollset_shutdown_done, cq,
+ grpc_schedule_on_exec_ctx);
+
+ GPR_TIMER_END("grpc_completion_queue_create_internal", 0);
+
+ return cq;
+}
+
+static void cq_init_next(void* ptr) {
+ cq_next_data* cqd = (cq_next_data*)ptr;
+ /* Initial count is dropped by grpc_completion_queue_shutdown */
+ gpr_atm_no_barrier_store(&cqd->pending_events, 1);
+ cqd->shutdown_called = false;
+ gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
+ cq_event_queue_init(&cqd->queue);
+}
+
+static void cq_destroy_next(void* ptr) {
+ cq_next_data* cqd = (cq_next_data*)ptr;
+ GPR_ASSERT(cq_event_queue_num_items(&cqd->queue) == 0);
+ cq_event_queue_destroy(&cqd->queue);
+}
+
+static void cq_init_pluck(void* ptr) {
+ cq_pluck_data* cqd = (cq_pluck_data*)ptr;
+ /* Initial count is dropped by grpc_completion_queue_shutdown */
+ gpr_atm_no_barrier_store(&cqd->pending_events, 1);
+ cqd->completed_tail = &cqd->completed_head;
+ cqd->completed_head.next = (uintptr_t)cqd->completed_tail;
+ gpr_atm_no_barrier_store(&cqd->shutdown, 0);
+ cqd->shutdown_called = false;
+ cqd->num_pluckers = 0;
+ gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
+}
+
+static void cq_destroy_pluck(void* ptr) {
+ cq_pluck_data* cqd = (cq_pluck_data*)ptr;
+ GPR_ASSERT(cqd->completed_head.next == (uintptr_t)&cqd->completed_head);
+}
+
+grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue* cq) {
+ return cq->vtable->cq_completion_type;
+}
+
+int grpc_get_cq_poll_num(grpc_completion_queue* cq) {
+ int cur_num_polls;
+ gpr_mu_lock(cq->mu);
+ cur_num_polls = cq->num_polls;
+ gpr_mu_unlock(cq->mu);
+ return cur_num_polls;
+}
+
+#ifndef NDEBUG
+void grpc_cq_internal_ref(grpc_completion_queue* cq, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_cq_refcount.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1,
+ reason);
+ }
+#else
+void grpc_cq_internal_ref(grpc_completion_queue* cq) {
+#endif
+ gpr_ref(&cq->owning_refs);
+}
+
+static void on_pollset_shutdown_done(void* arg, grpc_error* error) {
+ grpc_completion_queue* cq = (grpc_completion_queue*)arg;
+ GRPC_CQ_INTERNAL_UNREF(cq, "pollset_destroy");
+}
+
+#ifndef NDEBUG
+void grpc_cq_internal_unref(grpc_completion_queue* cq, const char* reason,
+ const char* file, int line) {
+ if (grpc_trace_cq_refcount.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
+ "CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1,
+ reason);
+ }
+#else
+void grpc_cq_internal_unref(grpc_completion_queue* cq) {
+#endif
+ if (gpr_unref(&cq->owning_refs)) {
+ cq->vtable->destroy(DATA_FROM_CQ(cq));
+ cq->poller_vtable->destroy(POLLSET_FROM_CQ(cq));
+#ifndef NDEBUG
+ gpr_free(cq->outstanding_tags);
+#endif
+ gpr_free(cq);
+ }
+}
+
+#ifndef NDEBUG
+static void cq_check_tag(grpc_completion_queue* cq, void* tag, bool lock_cq) {
+ int found = 0;
+ if (lock_cq) {
+ gpr_mu_lock(cq->mu);
+ }
+
+ for (int i = 0; i < (int)cq->outstanding_tag_count; i++) {
+ if (cq->outstanding_tags[i] == tag) {
+ cq->outstanding_tag_count--;
+ GPR_SWAP(void*, cq->outstanding_tags[i],
+ cq->outstanding_tags[cq->outstanding_tag_count]);
+ found = 1;
+ break;
+ }
+ }
+
+ if (lock_cq) {
+ gpr_mu_unlock(cq->mu);
+ }
+
+ GPR_ASSERT(found);
+}
+#else
+static void cq_check_tag(grpc_completion_queue* cq, void* tag, bool lock_cq) {}
+#endif
+
+/* Atomically increments a counter only if the counter is not zero. Returns
+ * true if the increment was successful; false if the counter is zero */
+static bool atm_inc_if_nonzero(gpr_atm* counter) {
+ while (true) {
+ gpr_atm count = gpr_atm_acq_load(counter);
+ /* If zero, we are done. If not, we must to a CAS (instead of an atomic
+ * increment) to maintain the contract: do not increment the counter if it
+ * is zero. */
+ if (count == 0) {
+ return false;
+ } else if (gpr_atm_full_cas(counter, count, count + 1)) {
+ break;
+ }
+ }
+
+ return true;
+}
+
+static bool cq_begin_op_for_next(grpc_completion_queue* cq, void* tag) {
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+ return atm_inc_if_nonzero(&cqd->pending_events);
+}
+
+static bool cq_begin_op_for_pluck(grpc_completion_queue* cq, void* tag) {
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+ return atm_inc_if_nonzero(&cqd->pending_events);
+}
+
+bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) {
+#ifndef NDEBUG
+ gpr_mu_lock(cq->mu);
+ if (cq->outstanding_tag_count == cq->outstanding_tag_capacity) {
+ cq->outstanding_tag_capacity = GPR_MAX(4, 2 * cq->outstanding_tag_capacity);
+ cq->outstanding_tags = (void**)gpr_realloc(
+ cq->outstanding_tags,
+ sizeof(*cq->outstanding_tags) * cq->outstanding_tag_capacity);
+ }
+ cq->outstanding_tags[cq->outstanding_tag_count++] = tag;
+ gpr_mu_unlock(cq->mu);
+#endif
+ return cq->vtable->begin_op(cq, tag);
+}
+
+/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
+ * completion
+ * type of GRPC_CQ_NEXT) */
+static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag,
+ grpc_error* error,
+ void (*done)(void* done_arg,
+ grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage) {
+ GPR_TIMER_BEGIN("cq_end_op_for_next", 0);
+
+ if (grpc_api_trace.enabled() ||
+ (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) {
+ const char* errmsg = grpc_error_string(error);
+ GRPC_API_TRACE(
+ "cq_end_op_for_next(cq=%p, tag=%p, error=%s, "
+ "done=%p, done_arg=%p, storage=%p)",
+ 6, (cq, tag, errmsg, done, done_arg, storage));
+ if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
+ gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
+ }
+ }
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+ int is_success = (error == GRPC_ERROR_NONE);
+
+ storage->tag = tag;
+ storage->done = done;
+ storage->done_arg = done_arg;
+ storage->next = (uintptr_t)(is_success);
+
+ cq_check_tag(cq, tag, true); /* Used in debug builds only */
+
+ if ((grpc_completion_queue*)gpr_tls_get(&g_cached_cq) == cq &&
+ (grpc_cq_completion*)gpr_tls_get(&g_cached_event) == nullptr) {
+ gpr_tls_set(&g_cached_event, (intptr_t)storage);
+ } else {
+ /* Add the completion to the queue */
+ bool is_first = cq_event_queue_push(&cqd->queue, storage);
+ gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
+
+ /* Since we do not hold the cq lock here, it is important to do an 'acquire'
+ load here (instead of a 'no_barrier' load) to match with the release
+ store
+ (done via gpr_atm_full_fetch_add(pending_events, -1)) in cq_shutdown_next
+ */
+ bool will_definitely_shutdown = gpr_atm_acq_load(&cqd->pending_events) == 1;
+
+ if (!will_definitely_shutdown) {
+ /* Only kick if this is the first item queued */
+ if (is_first) {
+ gpr_mu_lock(cq->mu);
+ grpc_error* kick_error =
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), nullptr);
+ gpr_mu_unlock(cq->mu);
+
+ if (kick_error != GRPC_ERROR_NONE) {
+ const char* msg = grpc_error_string(kick_error);
+ gpr_log(GPR_ERROR, "Kick failed: %s", msg);
+ GRPC_ERROR_UNREF(kick_error);
+ }
+ }
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
+ gpr_mu_lock(cq->mu);
+ cq_finish_shutdown_next(cq);
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
+ }
+ } else {
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
+ gpr_atm_rel_store(&cqd->pending_events, 0);
+ gpr_mu_lock(cq->mu);
+ cq_finish_shutdown_next(cq);
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
+ }
+ }
+
+ GPR_TIMER_END("cq_end_op_for_next", 0);
+
+ GRPC_ERROR_UNREF(error);
+}
+
+/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
+ * completion
+ * type of GRPC_CQ_PLUCK) */
+static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag,
+ grpc_error* error,
+ void (*done)(void* done_arg,
+ grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage) {
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+ int is_success = (error == GRPC_ERROR_NONE);
+
+ GPR_TIMER_BEGIN("cq_end_op_for_pluck", 0);
+
+ if (grpc_api_trace.enabled() ||
+ (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) {
+ const char* errmsg = grpc_error_string(error);
+ GRPC_API_TRACE(
+ "cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, "
+ "done=%p, done_arg=%p, storage=%p)",
+ 6, (cq, tag, errmsg, done, done_arg, storage));
+ if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
+ gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
+ }
+ }
+
+ storage->tag = tag;
+ storage->done = done;
+ storage->done_arg = done_arg;
+ storage->next = ((uintptr_t)&cqd->completed_head) | ((uintptr_t)(is_success));
+
+ gpr_mu_lock(cq->mu);
+ cq_check_tag(cq, tag, false); /* Used in debug builds only */
+
+ /* Add to the list of completions */
+ gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
+ cqd->completed_tail->next =
+ ((uintptr_t)storage) | (1u & (uintptr_t)cqd->completed_tail->next);
+ cqd->completed_tail = storage;
+
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
+ cq_finish_shutdown_pluck(cq);
+ gpr_mu_unlock(cq->mu);
+ } else {
+ grpc_pollset_worker* pluck_worker = nullptr;
+ for (int i = 0; i < cqd->num_pluckers; i++) {
+ if (cqd->pluckers[i].tag == tag) {
+ pluck_worker = *cqd->pluckers[i].worker;
+ break;
+ }
+ }
+
+ grpc_error* kick_error =
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), pluck_worker);
+
+ gpr_mu_unlock(cq->mu);
+
+ if (kick_error != GRPC_ERROR_NONE) {
+ const char* msg = grpc_error_string(kick_error);
+ gpr_log(GPR_ERROR, "Kick failed: %s", msg);
+
+ GRPC_ERROR_UNREF(kick_error);
+ }
+ }
+
+ GPR_TIMER_END("cq_end_op_for_pluck", 0);
+
+ GRPC_ERROR_UNREF(error);
+}
+
+void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error,
+ void (*done)(void* done_arg, grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage) {
+ cq->vtable->end_op(cq, tag, error, done, done_arg, storage);
+}
+
+typedef struct {
+ gpr_atm last_seen_things_queued_ever;
+ grpc_completion_queue* cq;
+ grpc_millis deadline;
+ grpc_cq_completion* stolen_completion;
+ void* tag; /* for pluck */
+ bool first_loop;
+} cq_is_finished_arg;
+
+class ExecCtxNext : public grpc_core::ExecCtx {
+ public:
+ ExecCtxNext(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {}
+
+ bool CheckReadyToFinish() override {
+ cq_is_finished_arg* a = (cq_is_finished_arg*)check_ready_to_finish_arg_;
+ grpc_completion_queue* cq = a->cq;
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+ GPR_ASSERT(a->stolen_completion == nullptr);
+
+ gpr_atm current_last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+
+ if (current_last_seen_things_queued_ever !=
+ a->last_seen_things_queued_ever) {
+ a->last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+
+ /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
+ * might return NULL in some cases even if the queue is not empty; but
+ * that
+ * is ok and doesn't affect correctness. Might effect the tail latencies a
+ * bit) */
+ a->stolen_completion = cq_event_queue_pop(&cqd->queue);
+ if (a->stolen_completion != nullptr) {
+ return true;
+ }
+ }
+ return !a->first_loop && a->deadline < grpc_core::ExecCtx::Get()->Now();
+ }
+
+ private:
+ void* check_ready_to_finish_arg_;
+};
+
+#ifndef NDEBUG
+static void dump_pending_tags(grpc_completion_queue* cq) {
+ if (!grpc_trace_pending_tags.enabled()) return;
+
+ gpr_strvec v;
+ gpr_strvec_init(&v);
+ gpr_strvec_add(&v, gpr_strdup("PENDING TAGS:"));
+ gpr_mu_lock(cq->mu);
+ for (size_t i = 0; i < cq->outstanding_tag_count; i++) {
+ char* s;
+ gpr_asprintf(&s, " %p", cq->outstanding_tags[i]);
+ gpr_strvec_add(&v, s);
+ }
+ gpr_mu_unlock(cq->mu);
+ char* out = gpr_strvec_flatten(&v, nullptr);
+ gpr_strvec_destroy(&v);
+ gpr_log(GPR_DEBUG, "%s", out);
+ gpr_free(out);
+}
+#else
+static void dump_pending_tags(grpc_completion_queue* cq) {}
+#endif
+
+static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
+ void* reserved) {
+ grpc_event ret;
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+
+ GPR_TIMER_BEGIN("grpc_completion_queue_next", 0);
+
+ GRPC_API_TRACE(
+ "grpc_completion_queue_next("
+ "cq=%p, "
+ "deadline=gpr_timespec { tv_sec: %" PRId64
+ ", tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 5,
+ (cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
+ reserved));
+ GPR_ASSERT(!reserved);
+
+ dump_pending_tags(cq);
+
+ GRPC_CQ_INTERNAL_REF(cq, "next");
+
+ grpc_millis deadline_millis = grpc_timespec_to_millis_round_up(deadline);
+ cq_is_finished_arg is_finished_arg = {
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever),
+ cq,
+ deadline_millis,
+ nullptr,
+ nullptr,
+ true};
+ ExecCtxNext exec_ctx(&is_finished_arg);
+ for (;;) {
+ grpc_millis iteration_deadline = deadline_millis;
+
+ if (is_finished_arg.stolen_completion != nullptr) {
+ grpc_cq_completion* c = is_finished_arg.stolen_completion;
+ is_finished_arg.stolen_completion = nullptr;
+ ret.type = GRPC_OP_COMPLETE;
+ ret.success = c->next & 1u;
+ ret.tag = c->tag;
+ c->done(c->done_arg, c);
+ break;
+ }
+
+ grpc_cq_completion* c = cq_event_queue_pop(&cqd->queue);
+
+ if (c != nullptr) {
+ ret.type = GRPC_OP_COMPLETE;
+ ret.success = c->next & 1u;
+ ret.tag = c->tag;
+ c->done(c->done_arg, c);
+ break;
+ } else {
+ /* If c == NULL it means either the queue is empty OR in an transient
+ inconsistent state. If it is the latter, we shold do a 0-timeout poll
+ so that the thread comes back quickly from poll to make a second
+ attempt at popping. Not doing this can potentially deadlock this
+ thread forever (if the deadline is infinity) */
+ if (cq_event_queue_num_items(&cqd->queue) > 0) {
+ iteration_deadline = 0;
+ }
+ }
+
+ if (gpr_atm_acq_load(&cqd->pending_events) == 0) {
+ /* Before returning, check if the queue has any items left over (since
+ gpr_mpscq_pop() can sometimes return NULL even if the queue is not
+ empty. If so, keep retrying but do not return GRPC_QUEUE_SHUTDOWN */
+ if (cq_event_queue_num_items(&cqd->queue) > 0) {
+ /* Go to the beginning of the loop. No point doing a poll because
+ (cq->shutdown == true) is only possible when there is no pending
+ work (i.e cq->pending_events == 0) and any outstanding completion
+ events should have already been queued on this cq */
+ continue;
+ }
+
+ memset(&ret, 0, sizeof(ret));
+ ret.type = GRPC_QUEUE_SHUTDOWN;
+ break;
+ }
+
+ if (!is_finished_arg.first_loop &&
+ grpc_core::ExecCtx::Get()->Now() >= deadline_millis) {
+ memset(&ret, 0, sizeof(ret));
+ ret.type = GRPC_QUEUE_TIMEOUT;
+ dump_pending_tags(cq);
+ break;
+ }
+
+ /* The main polling work happens in grpc_pollset_work */
+ gpr_mu_lock(cq->mu);
+ cq->num_polls++;
+ grpc_error* err = cq->poller_vtable->work(POLLSET_FROM_CQ(cq), nullptr,
+ iteration_deadline);
+ gpr_mu_unlock(cq->mu);
+
+ if (err != GRPC_ERROR_NONE) {
+ const char* msg = grpc_error_string(err);
+ gpr_log(GPR_ERROR, "Completion queue next failed: %s", msg);
+
+ GRPC_ERROR_UNREF(err);
+ memset(&ret, 0, sizeof(ret));
+ ret.type = GRPC_QUEUE_TIMEOUT;
+ dump_pending_tags(cq);
+ break;
+ }
+ is_finished_arg.first_loop = false;
+ }
+
+ if (cq_event_queue_num_items(&cqd->queue) > 0 &&
+ gpr_atm_acq_load(&cqd->pending_events) > 0) {
+ gpr_mu_lock(cq->mu);
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), nullptr);
+ gpr_mu_unlock(cq->mu);
+ }
+
+ GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
+ GRPC_CQ_INTERNAL_UNREF(cq, "next");
+
+ GPR_ASSERT(is_finished_arg.stolen_completion == nullptr);
+
+ GPR_TIMER_END("grpc_completion_queue_next", 0);
+
+ return ret;
+}
+
+/* Finishes the completion queue shutdown. This means that there are no more
+ completion events / tags expected from the completion queue
+ - Must be called under completion queue lock
+ - Must be called only once in completion queue's lifetime
+ - grpc_completion_queue_shutdown() MUST have been called before calling
+ this function */
+static void cq_finish_shutdown_next(grpc_completion_queue* cq) {
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+
+ GPR_ASSERT(cqd->shutdown_called);
+ GPR_ASSERT(gpr_atm_no_barrier_load(&cqd->pending_events) == 0);
+
+ cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
+}
+
+static void cq_shutdown_next(grpc_completion_queue* cq) {
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+
+ /* Need an extra ref for cq here because:
+ * We call cq_finish_shutdown_next() below, that would call pollset shutdown.
+ * Pollset shutdown decrements the cq ref count which can potentially destroy
+ * the cq (if that happens to be the last ref).
+ * Creating an extra ref here prevents the cq from getting destroyed while
+ * this function is still active */
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
+ gpr_mu_lock(cq->mu);
+ if (cqd->shutdown_called) {
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
+ return;
+ }
+ cqd->shutdown_called = true;
+ /* Doing a full_fetch_add (i.e acq/release) here to match with
+ * cq_begin_op_for_next and and cq_end_op_for_next functions which read/write
+ * on this counter without necessarily holding a lock on cq */
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
+ cq_finish_shutdown_next(cq);
+ }
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
+}
+
+grpc_event grpc_completion_queue_next(grpc_completion_queue* cq,
+ gpr_timespec deadline, void* reserved) {
+ return cq->vtable->next(cq, deadline, reserved);
+}
+
+static int add_plucker(grpc_completion_queue* cq, void* tag,
+ grpc_pollset_worker** worker) {
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+ if (cqd->num_pluckers == GRPC_MAX_COMPLETION_QUEUE_PLUCKERS) {
+ return 0;
+ }
+ cqd->pluckers[cqd->num_pluckers].tag = tag;
+ cqd->pluckers[cqd->num_pluckers].worker = worker;
+ cqd->num_pluckers++;
+ return 1;
+}
+
+static void del_plucker(grpc_completion_queue* cq, void* tag,
+ grpc_pollset_worker** worker) {
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+ for (int i = 0; i < cqd->num_pluckers; i++) {
+ if (cqd->pluckers[i].tag == tag && cqd->pluckers[i].worker == worker) {
+ cqd->num_pluckers--;
+ GPR_SWAP(plucker, cqd->pluckers[i], cqd->pluckers[cqd->num_pluckers]);
+ return;
+ }
+ }
+ GPR_UNREACHABLE_CODE(return );
+}
+
+class ExecCtxPluck : public grpc_core::ExecCtx {
+ public:
+ ExecCtxPluck(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {}
+
+ bool CheckReadyToFinish() override {
+ cq_is_finished_arg* a = (cq_is_finished_arg*)check_ready_to_finish_arg_;
+ grpc_completion_queue* cq = a->cq;
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+
+ GPR_ASSERT(a->stolen_completion == nullptr);
+ gpr_atm current_last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+ if (current_last_seen_things_queued_ever !=
+ a->last_seen_things_queued_ever) {
+ gpr_mu_lock(cq->mu);
+ a->last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+ grpc_cq_completion* c;
+ grpc_cq_completion* prev = &cqd->completed_head;
+ while ((c = (grpc_cq_completion*)(prev->next & ~(uintptr_t)1)) !=
+ &cqd->completed_head) {
+ if (c->tag == a->tag) {
+ prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
+ if (c == cqd->completed_tail) {
+ cqd->completed_tail = prev;
+ }
+ gpr_mu_unlock(cq->mu);
+ a->stolen_completion = c;
+ return true;
+ }
+ prev = c;
+ }
+ gpr_mu_unlock(cq->mu);
+ }
+ return !a->first_loop && a->deadline < grpc_core::ExecCtx::Get()->Now();
+ }
+
+ private:
+ void* check_ready_to_finish_arg_;
+};
+
+static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
+ gpr_timespec deadline, void* reserved) {
+ grpc_event ret;
+ grpc_cq_completion* c;
+ grpc_cq_completion* prev;
+ grpc_pollset_worker* worker = nullptr;
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+
+ GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0);
+
+ if (grpc_cq_pluck_trace.enabled()) {
+ GRPC_API_TRACE(
+ "grpc_completion_queue_pluck("
+ "cq=%p, tag=%p, "
+ "deadline=gpr_timespec { tv_sec: %" PRId64
+ ", tv_nsec: %d, clock_type: %d }, "
+ "reserved=%p)",
+ 6,
+ (cq, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
+ reserved));
+ }
+ GPR_ASSERT(!reserved);
+
+ dump_pending_tags(cq);
+
+ GRPC_CQ_INTERNAL_REF(cq, "pluck");
+ gpr_mu_lock(cq->mu);
+ grpc_millis deadline_millis = grpc_timespec_to_millis_round_up(deadline);
+ cq_is_finished_arg is_finished_arg = {
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever),
+ cq,
+ deadline_millis,
+ nullptr,
+ tag,
+ true};
+ ExecCtxPluck exec_ctx(&is_finished_arg);
+ for (;;) {
+ if (is_finished_arg.stolen_completion != nullptr) {
+ gpr_mu_unlock(cq->mu);
+ c = is_finished_arg.stolen_completion;
+ is_finished_arg.stolen_completion = nullptr;
+ ret.type = GRPC_OP_COMPLETE;
+ ret.success = c->next & 1u;
+ ret.tag = c->tag;
+ c->done(c->done_arg, c);
+ break;
+ }
+ prev = &cqd->completed_head;
+ while ((c = (grpc_cq_completion*)(prev->next & ~(uintptr_t)1)) !=
+ &cqd->completed_head) {
+ if (c->tag == tag) {
+ prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
+ if (c == cqd->completed_tail) {
+ cqd->completed_tail = prev;
+ }
+ gpr_mu_unlock(cq->mu);
+ ret.type = GRPC_OP_COMPLETE;
+ ret.success = c->next & 1u;
+ ret.tag = c->tag;
+ c->done(c->done_arg, c);
+ goto done;
+ }
+ prev = c;
+ }
+ if (gpr_atm_no_barrier_load(&cqd->shutdown)) {
+ gpr_mu_unlock(cq->mu);
+ memset(&ret, 0, sizeof(ret));
+ ret.type = GRPC_QUEUE_SHUTDOWN;
+ break;
+ }
+ if (!add_plucker(cq, tag, &worker)) {
+ gpr_log(GPR_DEBUG,
+ "Too many outstanding grpc_completion_queue_pluck calls: maximum "
+ "is %d",
+ GRPC_MAX_COMPLETION_QUEUE_PLUCKERS);
+ gpr_mu_unlock(cq->mu);
+ memset(&ret, 0, sizeof(ret));
+ /* TODO(ctiller): should we use a different result here */
+ ret.type = GRPC_QUEUE_TIMEOUT;
+ dump_pending_tags(cq);
+ break;
+ }
+ if (!is_finished_arg.first_loop &&
+ grpc_core::ExecCtx::Get()->Now() >= deadline_millis) {
+ del_plucker(cq, tag, &worker);
+ gpr_mu_unlock(cq->mu);
+ memset(&ret, 0, sizeof(ret));
+ ret.type = GRPC_QUEUE_TIMEOUT;
+ dump_pending_tags(cq);
+ break;
+ }
+ cq->num_polls++;
+ grpc_error* err =
+ cq->poller_vtable->work(POLLSET_FROM_CQ(cq), &worker, deadline_millis);
+ if (err != GRPC_ERROR_NONE) {
+ del_plucker(cq, tag, &worker);
+ gpr_mu_unlock(cq->mu);
+ const char* msg = grpc_error_string(err);
+ gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", msg);
+
+ GRPC_ERROR_UNREF(err);
+ memset(&ret, 0, sizeof(ret));
+ ret.type = GRPC_QUEUE_TIMEOUT;
+ dump_pending_tags(cq);
+ break;
+ }
+ is_finished_arg.first_loop = false;
+ del_plucker(cq, tag, &worker);
+ }
+done:
+ GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
+ GRPC_CQ_INTERNAL_UNREF(cq, "pluck");
+
+ GPR_ASSERT(is_finished_arg.stolen_completion == nullptr);
+
+ GPR_TIMER_END("grpc_completion_queue_pluck", 0);
+
+ return ret;
+}
+
+grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
+ gpr_timespec deadline, void* reserved) {
+ return cq->vtable->pluck(cq, tag, deadline, reserved);
+}
+
+static void cq_finish_shutdown_pluck(grpc_completion_queue* cq) {
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+
+ GPR_ASSERT(cqd->shutdown_called);
+ GPR_ASSERT(!gpr_atm_no_barrier_load(&cqd->shutdown));
+ gpr_atm_no_barrier_store(&cqd->shutdown, 1);
+
+ cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
+}
+
+/* NOTE: This function is almost exactly identical to cq_shutdown_next() but
+ * merging them is a bit tricky and probably not worth it */
+static void cq_shutdown_pluck(grpc_completion_queue* cq) {
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+
+ /* Need an extra ref for cq here because:
+ * We call cq_finish_shutdown_pluck() below, that would call pollset shutdown.
+ * Pollset shutdown decrements the cq ref count which can potentially destroy
+ * the cq (if that happens to be the last ref).
+ * Creating an extra ref here prevents the cq from getting destroyed while
+ * this function is still active */
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down (pluck cq)");
+ gpr_mu_lock(cq->mu);
+ if (cqd->shutdown_called) {
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (pluck cq)");
+ return;
+ }
+ cqd->shutdown_called = true;
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
+ cq_finish_shutdown_pluck(cq);
+ }
+ gpr_mu_unlock(cq->mu);
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (pluck cq)");
+}
+
+/* Shutdown simply drops a ref that we reserved at creation time; if we drop
+ to zero here, then enter shutdown mode and wake up any waiters */
+void grpc_completion_queue_shutdown(grpc_completion_queue* cq) {
+ grpc_core::ExecCtx exec_ctx;
+ GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
+ GRPC_API_TRACE("grpc_completion_queue_shutdown(cq=%p)", 1, (cq));
+ cq->vtable->shutdown(cq);
+
+ GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
+}
+
+void grpc_completion_queue_destroy(grpc_completion_queue* cq) {
+ GRPC_API_TRACE("grpc_completion_queue_destroy(cq=%p)", 1, (cq));
+ GPR_TIMER_BEGIN("grpc_completion_queue_destroy", 0);
+ grpc_completion_queue_shutdown(cq);
+
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CQ_INTERNAL_UNREF(cq, "destroy");
+
+ GPR_TIMER_END("grpc_completion_queue_destroy", 0);
+}
+
+grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cq) {
+ return cq->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cq) : nullptr;
+}
+
+bool grpc_cq_can_listen(grpc_completion_queue* cq) {
+ return cq->poller_vtable->can_listen;
+}
diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h
index 69d144bd95..aea47afaf5 100644
--- a/src/core/lib/surface/completion_queue.h
+++ b/src/core/lib/surface/completion_queue.h
@@ -27,76 +27,65 @@
/* These trace flags default to 1. The corresponding lines are only traced
if grpc_api_trace is also truthy */
-extern grpc_tracer_flag grpc_cq_pluck_trace;
-extern grpc_tracer_flag grpc_cq_event_timeout_trace;
-extern grpc_tracer_flag grpc_trace_operation_failures;
-
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_pending_tags;
-extern grpc_tracer_flag grpc_trace_cq_refcount;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+extern grpc_core::TraceFlag grpc_cq_pluck_trace;
+extern grpc_core::TraceFlag grpc_cq_event_timeout_trace;
+extern grpc_core::TraceFlag grpc_trace_operation_failures;
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_pending_tags;
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_cq_refcount;
typedef struct grpc_cq_completion {
gpr_mpscq_node node;
/** user supplied tag */
- void *tag;
+ void* tag;
/** done callback - called when this queue element is no longer
needed by the completion queue */
- void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
- struct grpc_cq_completion *c);
- void *done_arg;
+ void (*done)(void* done_arg, struct grpc_cq_completion* c);
+ void* done_arg;
/** next pointer; low bit is used to indicate success or not */
uintptr_t next;
} grpc_cq_completion;
#ifndef NDEBUG
-void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason,
- const char *file, int line);
-void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
- const char *reason, const char *file, int line);
+void grpc_cq_internal_ref(grpc_completion_queue* cc, const char* reason,
+ const char* file, int line);
+void grpc_cq_internal_unref(grpc_completion_queue* cc, const char* reason,
+ const char* file, int line);
#define GRPC_CQ_INTERNAL_REF(cc, reason) \
grpc_cq_internal_ref(cc, reason, __FILE__, __LINE__)
-#define GRPC_CQ_INTERNAL_UNREF(ec, cc, reason) \
- grpc_cq_internal_unref(ec, cc, reason, __FILE__, __LINE__)
+#define GRPC_CQ_INTERNAL_UNREF(cc, reason) \
+ grpc_cq_internal_unref(cc, reason, __FILE__, __LINE__)
#else
-void grpc_cq_internal_ref(grpc_completion_queue *cc);
-void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc);
+void grpc_cq_internal_ref(grpc_completion_queue* cc);
+void grpc_cq_internal_unref(grpc_completion_queue* cc);
#define GRPC_CQ_INTERNAL_REF(cc, reason) grpc_cq_internal_ref(cc)
-#define GRPC_CQ_INTERNAL_UNREF(ec, cc, reason) grpc_cq_internal_unref(ec, cc)
+#define GRPC_CQ_INTERNAL_UNREF(cc, reason) grpc_cq_internal_unref(cc)
#endif
+/* Initializes global variables used by completion queues */
+void grpc_cq_global_init();
+
/* Flag that an operation is beginning: the completion channel will not finish
shutdown until a corrensponding grpc_cq_end_* call is made.
\a tag is currently used only in debug builds. Return true on success, and
false if completion_queue has been shutdown. */
-bool grpc_cq_begin_op(grpc_completion_queue *cc, void *tag);
+bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag);
/* Queue a GRPC_OP_COMPLETED operation; tag must correspond to the tag passed to
grpc_cq_begin_op */
-void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
- void *tag, grpc_error *error,
- void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
- grpc_cq_completion *storage),
- void *done_arg, grpc_cq_completion *storage);
+void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error,
+ void (*done)(void* done_arg, grpc_cq_completion* storage),
+ void* done_arg, grpc_cq_completion* storage);
-grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cc);
+grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc);
-bool grpc_cq_can_listen(grpc_completion_queue *cc);
+bool grpc_cq_can_listen(grpc_completion_queue* cc);
-grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc);
+grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue* cc);
-int grpc_get_cq_poll_num(grpc_completion_queue *cc);
+int grpc_get_cq_poll_num(grpc_completion_queue* cc);
-grpc_completion_queue *grpc_completion_queue_create_internal(
+grpc_completion_queue* grpc_completion_queue_create_internal(
grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H */
diff --git a/src/core/lib/surface/completion_queue_factory.c b/src/core/lib/surface/completion_queue_factory.cc
index aeecff5306..d0bb065c8f 100644
--- a/src/core/lib/surface/completion_queue_factory.c
+++ b/src/core/lib/surface/completion_queue_factory.cc
@@ -35,7 +35,7 @@ static grpc_completion_queue* default_create(
static grpc_completion_queue_factory_vtable default_vtable = {default_create};
static const grpc_completion_queue_factory g_default_cq_factory = {
- "Default Factory", NULL, &default_vtable};
+ "Default Factory", nullptr, &default_vtable};
/*
* == Completion queue factory APIs
diff --git a/src/core/lib/surface/event_string.c b/src/core/lib/surface/event_string.cc
index f236272e2a..7f40bb2405 100644
--- a/src/core/lib/surface/event_string.c
+++ b/src/core/lib/surface/event_string.cc
@@ -22,27 +22,27 @@
#include <grpc/byte_buffer.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
-static void addhdr(gpr_strvec *buf, grpc_event *ev) {
- char *tmp;
+static void addhdr(gpr_strvec* buf, grpc_event* ev) {
+ char* tmp;
gpr_asprintf(&tmp, "tag:%p", ev->tag);
gpr_strvec_add(buf, tmp);
}
-static const char *errstr(int success) { return success ? "OK" : "ERROR"; }
+static const char* errstr(int success) { return success ? "OK" : "ERROR"; }
-static void adderr(gpr_strvec *buf, int success) {
- char *tmp;
+static void adderr(gpr_strvec* buf, int success) {
+ char* tmp;
gpr_asprintf(&tmp, " %s", errstr(success));
gpr_strvec_add(buf, tmp);
}
-char *grpc_event_string(grpc_event *ev) {
- char *out;
+char* grpc_event_string(grpc_event* ev) {
+ char* out;
gpr_strvec buf;
- if (ev == NULL) return gpr_strdup("null");
+ if (ev == nullptr) return gpr_strdup("null");
gpr_strvec_init(&buf);
@@ -60,7 +60,7 @@ char *grpc_event_string(grpc_event *ev) {
break;
}
- out = gpr_strvec_flatten(&buf, NULL);
+ out = gpr_strvec_flatten(&buf, nullptr);
gpr_strvec_destroy(&buf);
return out;
}
diff --git a/src/core/lib/surface/event_string.h b/src/core/lib/surface/event_string.h
index f00efca7f3..cbf96da6c5 100644
--- a/src/core/lib/surface/event_string.h
+++ b/src/core/lib/surface/event_string.h
@@ -22,6 +22,6 @@
#include <grpc/grpc.h>
/* Returns a string describing an event. Must be later freed with gpr_free() */
-char *grpc_event_string(grpc_event *ev);
+char* grpc_event_string(grpc_event* ev);
#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */
diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.cc
index b089da2c54..70329b09f4 100644
--- a/src/core/lib/surface/init.c
+++ b/src/core/lib/surface/init.cc
@@ -21,6 +21,7 @@
#include <limits.h>
#include <memory.h>
+#include <grpc/fork.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -30,6 +31,8 @@
#include "src/core/lib/channel/handshaker_registry.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gpr/fork.h"
+#include "src/core/lib/gpr/thd_internal.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/combiner.h"
@@ -62,38 +65,39 @@ static int g_initializations;
static void do_basic_init(void) {
gpr_log_verbosity_init();
+ grpc_fork_support_init();
gpr_mu_init(&g_init_mu);
grpc_register_built_in_plugins();
+ grpc_cq_global_init();
g_initializations = 0;
+ grpc_fork_handlers_auto_register();
}
-static bool append_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder, void *arg) {
+static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_append_filter(
- builder, (const grpc_channel_filter *)arg, NULL, NULL);
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
-static bool prepend_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder, void *arg) {
+static bool prepend_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_prepend_filter(
- builder, (const grpc_channel_filter *)arg, NULL, NULL);
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
static void register_builtin_channel_init() {
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- grpc_add_connected_filter, NULL);
+ grpc_add_connected_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- grpc_add_connected_filter, NULL);
+ grpc_add_connected_filter, nullptr);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- grpc_add_connected_filter, NULL);
+ grpc_add_connected_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
- append_filter, (void *)&grpc_lame_filter);
+ append_filter, (void*)&grpc_lame_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
- (void *)&grpc_server_top_filter);
+ (void*)&grpc_server_top_filter);
}
typedef struct grpc_plugin {
@@ -106,7 +110,7 @@ static int g_number_of_plugins = 0;
void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) {
GRPC_API_TRACE("grpc_register_plugin(init=%p, destroy=%p)", 2,
- ((void *)(intptr_t)init, (void *)(intptr_t)destroy));
+ ((void*)(intptr_t)init, (void*)(intptr_t)destroy));
GPR_ASSERT(g_number_of_plugins != MAX_PLUGINS);
g_all_of_the_plugins[g_number_of_plugins].init = init;
g_all_of_the_plugins[g_number_of_plugins].destroy = destroy;
@@ -117,45 +121,22 @@ void grpc_init(void) {
int i;
gpr_once_init(&g_basic_init, do_basic_init);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_lock(&g_init_mu);
if (++g_initializations == 1) {
gpr_time_init();
+ gpr_thd_init();
grpc_stats_init();
grpc_slice_intern_init();
grpc_mdctx_global_init();
grpc_channel_init_init();
- grpc_register_tracer(&grpc_api_trace);
- grpc_register_tracer(&grpc_trace_channel);
- grpc_register_tracer(&grpc_connectivity_state_trace);
- grpc_register_tracer(&grpc_trace_channel_stack_builder);
- grpc_register_tracer(&grpc_http1_trace);
- grpc_register_tracer(&grpc_cq_pluck_trace); // default on
- grpc_register_tracer(&grpc_call_combiner_trace);
- grpc_register_tracer(&grpc_combiner_trace);
- grpc_register_tracer(&grpc_server_channel_trace);
- grpc_register_tracer(&grpc_bdp_estimator_trace);
- grpc_register_tracer(&grpc_cq_event_timeout_trace); // default on
- grpc_register_tracer(&grpc_trace_operation_failures);
- grpc_register_tracer(&grpc_resource_quota_trace);
- grpc_register_tracer(&grpc_call_error_trace);
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_pending_tags);
- grpc_register_tracer(&grpc_trace_alarm_refcount);
- grpc_register_tracer(&grpc_trace_cq_refcount);
- grpc_register_tracer(&grpc_trace_closure);
- grpc_register_tracer(&grpc_trace_error_refcount);
- grpc_register_tracer(&grpc_trace_stream_refcount);
- grpc_register_tracer(&grpc_trace_fd_refcount);
- grpc_register_tracer(&grpc_trace_metadata);
-#endif
grpc_security_pre_init();
- grpc_iomgr_init(&exec_ctx);
+ grpc_core::ExecCtx::GlobalInit();
+ grpc_iomgr_init();
gpr_timers_global_init();
grpc_handshaker_factory_registry_init();
grpc_security_init();
for (i = 0; i < g_number_of_plugins; i++) {
- if (g_all_of_the_plugins[i].init != NULL) {
+ if (g_all_of_the_plugins[i].init != nullptr) {
g_all_of_the_plugins[i].init();
}
}
@@ -166,37 +147,41 @@ void grpc_init(void) {
grpc_tracer_init("GRPC_TRACE");
/* no more changes to channel init pipelines */
grpc_channel_init_finalize();
- grpc_iomgr_start(&exec_ctx);
+ grpc_iomgr_start();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
GRPC_API_TRACE("grpc_init(void)", 0, ());
}
void grpc_shutdown(void) {
int i;
GRPC_API_TRACE("grpc_shutdown(void)", 0, ());
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
gpr_mu_lock(&g_init_mu);
if (--g_initializations == 0) {
- grpc_executor_shutdown(&exec_ctx);
- grpc_timer_manager_set_threading(false); // shutdown timer_manager thread
- for (i = g_number_of_plugins; i >= 0; i--) {
- if (g_all_of_the_plugins[i].destroy != NULL) {
- g_all_of_the_plugins[i].destroy();
+ {
+ grpc_core::ExecCtx exec_ctx(0);
+ {
+ grpc_executor_shutdown();
+ grpc_timer_manager_set_threading(
+ false); // shutdown timer_manager thread
+ for (i = g_number_of_plugins; i >= 0; i--) {
+ if (g_all_of_the_plugins[i].destroy != nullptr) {
+ g_all_of_the_plugins[i].destroy();
+ }
+ }
}
+ grpc_iomgr_shutdown();
+ gpr_timers_global_destroy();
+ grpc_tracer_shutdown();
+ grpc_mdctx_global_shutdown();
+ grpc_handshaker_factory_registry_shutdown();
+ grpc_slice_intern_shutdown();
+ grpc_stats_shutdown();
}
- grpc_iomgr_shutdown(&exec_ctx);
- gpr_timers_global_destroy();
- grpc_tracer_shutdown();
- grpc_mdctx_global_shutdown(&exec_ctx);
- grpc_handshaker_factory_registry_shutdown(&exec_ctx);
- grpc_slice_intern_shutdown();
- grpc_stats_shutdown();
+ grpc_core::ExecCtx::GlobalShutdown();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
int grpc_is_initialized(void) {
diff --git a/src/core/lib/surface/init_secure.c b/src/core/lib/surface/init_secure.cc
index 2366c24910..75ed9faef0 100644
--- a/src/core/lib/surface/init_secure.c
+++ b/src/core/lib/surface/init_secure.cc
@@ -24,7 +24,9 @@
#include <string.h>
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/credentials/plugin/plugin_credentials.h"
#include "src/core/lib/security/transport/auth_filters.h"
#include "src/core/lib/security/transport/secure_endpoint.h"
#include "src/core/lib/security/transport/security_connector.h"
@@ -32,28 +34,17 @@
#include "src/core/lib/surface/channel_init.h"
#include "src/core/tsi/transport_security_interface.h"
-#ifndef NDEBUG
-#include "src/core/lib/security/context/security_context.h"
-#endif
-
-void grpc_security_pre_init(void) {
- grpc_register_tracer(&grpc_trace_secure_endpoint);
- grpc_register_tracer(&tsi_tracing_enabled);
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_auth_context_refcount);
- grpc_register_tracer(&grpc_trace_security_connector_refcount);
-#endif
-}
+void grpc_security_pre_init(void) {}
static bool maybe_prepend_client_auth_filter(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
- const grpc_channel_args *args =
+ grpc_channel_stack_builder* builder, void* arg) {
+ const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
if (args) {
for (size_t i = 0; i < args->num_args; i++) {
if (0 == strcmp(GRPC_ARG_SECURITY_CONNECTOR, args->args[i].key)) {
return grpc_channel_stack_builder_prepend_filter(
- builder, &grpc_client_auth_filter, NULL, NULL);
+ builder, &grpc_client_auth_filter, nullptr, nullptr);
}
}
}
@@ -61,14 +52,14 @@ static bool maybe_prepend_client_auth_filter(
}
static bool maybe_prepend_server_auth_filter(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
- const grpc_channel_args *args =
+ grpc_channel_stack_builder* builder, void* arg) {
+ const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
if (args) {
for (size_t i = 0; i < args->num_args; i++) {
if (0 == strcmp(GRPC_SERVER_CREDENTIALS_ARG, args->args[i].key)) {
return grpc_channel_stack_builder_prepend_filter(
- builder, &grpc_server_auth_filter, NULL, NULL);
+ builder, &grpc_server_auth_filter, nullptr, nullptr);
}
}
}
@@ -77,11 +68,11 @@ static bool maybe_prepend_server_auth_filter(
void grpc_register_security_filters(void) {
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
- maybe_prepend_client_auth_filter, NULL);
+ maybe_prepend_client_auth_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
- maybe_prepend_client_auth_filter, NULL);
+ maybe_prepend_client_auth_filter, nullptr);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
- maybe_prepend_server_auth_filter, NULL);
+ maybe_prepend_server_auth_filter, nullptr);
}
void grpc_security_init() { grpc_security_register_handshaker_factories(); }
diff --git a/src/core/lib/surface/init_unsecure.c b/src/core/lib/surface/init_unsecure.cc
index b852cab985..b852cab985 100644
--- a/src/core/lib/surface/init_unsecure.c
+++ b/src/core/lib/surface/init_unsecure.cc
diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc
index 6286f9159d..a1f1cf1107 100644
--- a/src/core/lib/surface/lame_client.cc
+++ b/src/core/lib/surface/lame_client.cc
@@ -23,24 +23,22 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include "src/core/lib/support/atomic.h"
+#include "src/core/lib/gprpp/atomic.h"
-extern "C" {
#include "src/core/lib/channel/channel_stack.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/lame_client.h"
#include "src/core/lib/transport/static_metadata.h"
-}
namespace grpc_core {
namespace {
struct CallData {
- grpc_call_combiner *call_combiner;
+ grpc_call_combiner* call_combiner;
grpc_linked_mdelem status;
grpc_linked_mdelem details;
grpc_core::atomic<bool> filled_metadata;
@@ -48,105 +46,102 @@ struct CallData {
struct ChannelData {
grpc_status_code error_code;
- const char *error_message;
+ const char* error_message;
};
-static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_metadata_batch *mdb) {
- CallData *calld = reinterpret_cast<CallData *>(elem->call_data);
+static void fill_metadata(grpc_call_element* elem, grpc_metadata_batch* mdb) {
+ CallData* calld = reinterpret_cast<CallData*>(elem->call_data);
bool expected = false;
if (!calld->filled_metadata.compare_exchange_strong(
expected, true, grpc_core::memory_order_relaxed,
grpc_core::memory_order_relaxed)) {
return;
}
- ChannelData *chand = reinterpret_cast<ChannelData *>(elem->channel_data);
+ ChannelData* chand = reinterpret_cast<ChannelData*>(elem->channel_data);
char tmp[GPR_LTOA_MIN_BUFSIZE];
gpr_ltoa(chand->error_code, tmp);
calld->status.md = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_STATUS, grpc_slice_from_copied_string(tmp));
+ GRPC_MDSTR_GRPC_STATUS, grpc_slice_from_copied_string(tmp));
calld->details.md = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
+ GRPC_MDSTR_GRPC_MESSAGE,
grpc_slice_from_copied_string(chand->error_message));
- calld->status.prev = calld->details.next = NULL;
+ calld->status.prev = calld->details.next = nullptr;
calld->status.next = &calld->details;
calld->details.prev = &calld->status;
mdb->list.head = &calld->status;
mdb->list.tail = &calld->details;
mdb->list.count = 2;
- mdb->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
+ mdb->deadline = GRPC_MILLIS_INF_FUTURE;
}
static void lame_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- CallData *calld = reinterpret_cast<CallData *>(elem->call_data);
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
+ CallData* calld = reinterpret_cast<CallData*>(elem->call_data);
if (op->recv_initial_metadata) {
- fill_metadata(exec_ctx, elem,
+ fill_metadata(elem,
op->payload->recv_initial_metadata.recv_initial_metadata);
} else if (op->recv_trailing_metadata) {
- fill_metadata(exec_ctx, elem,
+ fill_metadata(elem,
op->payload->recv_trailing_metadata.recv_trailing_metadata);
}
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, op, GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"),
+ op, GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"),
calld->call_combiner);
}
-static void lame_get_channel_info(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {}
+static void lame_get_channel_info(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {}
-static void lame_start_transport_op(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_transport_op *op) {
+static void lame_start_transport_op(grpc_channel_element* elem,
+ grpc_transport_op* op) {
if (op->on_connectivity_state_change) {
GPR_ASSERT(*op->connectivity_state != GRPC_CHANNEL_SHUTDOWN);
*op->connectivity_state = GRPC_CHANNEL_SHUTDOWN;
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_connectivity_state_change,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_connectivity_state_change, GRPC_ERROR_NONE);
}
- if (op->send_ping != NULL) {
+ if (op->send_ping.on_initiate != nullptr) {
GRPC_CLOSURE_SCHED(
- exec_ctx, op->send_ping,
+ op->send_ping.on_initiate,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
+ }
+ if (op->send_ping.on_ack != nullptr) {
+ GRPC_CLOSURE_SCHED(
+ op->send_ping.on_ack,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
- if (op->on_consumed != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ if (op->on_consumed != nullptr) {
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
}
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- CallData *calld = reinterpret_cast<CallData *>(elem->call_data);
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ CallData* calld = reinterpret_cast<CallData*>(elem->call_data);
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_schedule_closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_schedule_closure) {
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
}
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
GPR_ASSERT(args->is_first);
GPR_ASSERT(args->is_last);
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
} // namespace
} // namespace grpc_core
-extern "C" const grpc_channel_filter grpc_lame_filter = {
+const grpc_channel_filter grpc_lame_filter = {
grpc_core::lame_start_transport_stream_op_batch,
grpc_core::lame_start_transport_op,
sizeof(grpc_core::CallData),
@@ -160,24 +155,24 @@ extern "C" const grpc_channel_filter grpc_lame_filter = {
"lame-client",
};
-#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c) + 1))
+#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1))
-grpc_channel *grpc_lame_client_channel_create(const char *target,
+grpc_channel* grpc_lame_client_channel_create(const char* target,
grpc_status_code error_code,
- const char *error_message) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_element *elem;
- grpc_channel *channel = grpc_channel_create(&exec_ctx, target, NULL,
- GRPC_CLIENT_LAME_CHANNEL, NULL);
+ const char* error_message) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_element* elem;
+ grpc_channel* channel =
+ grpc_channel_create(target, nullptr, GRPC_CLIENT_LAME_CHANNEL, nullptr);
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
GRPC_API_TRACE(
"grpc_lame_client_channel_create(target=%s, error_code=%d, "
"error_message=%s)",
3, (target, (int)error_code, error_message));
GPR_ASSERT(elem->filter == &grpc_lame_filter);
- auto chand = reinterpret_cast<grpc_core::ChannelData *>(elem->channel_data);
+ auto chand = reinterpret_cast<grpc_core::ChannelData*>(elem->channel_data);
chand->error_code = error_code;
chand->error_message = error_message;
- grpc_exec_ctx_finish(&exec_ctx);
+
return channel;
}
diff --git a/src/core/lib/surface/metadata_array.c b/src/core/lib/surface/metadata_array.cc
index 0afb8b4b87..0afb8b4b87 100644
--- a/src/core/lib/surface/metadata_array.c
+++ b/src/core/lib/surface/metadata_array.cc
diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.cc
index 1d0fd472d0..c8c1db337f 100644
--- a/src/core/lib/surface/server.c
+++ b/src/core/lib/surface/server.cc
@@ -30,11 +30,12 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/mpscq.h"
+#include "src/core/lib/gpr/spinlock.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/stack_lockfree.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
@@ -43,63 +44,61 @@
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
-typedef struct listener {
- void *arg;
- void (*start)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- grpc_pollset **pollsets, size_t pollset_count);
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- grpc_closure *closure);
- struct listener *next;
- grpc_closure destroy_done;
-} listener;
+grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel");
-typedef struct call_data call_data;
-typedef struct channel_data channel_data;
-typedef struct registered_method registered_method;
+namespace {
+struct listener {
+ void* arg;
+ void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets,
+ size_t pollset_count);
+ void (*destroy)(grpc_server* server, void* arg, grpc_closure* closure);
+ struct listener* next;
+ grpc_closure destroy_done;
+};
-typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type;
+enum requested_call_type { BATCH_CALL, REGISTERED_CALL };
-grpc_tracer_flag grpc_server_channel_trace =
- GRPC_TRACER_INITIALIZER(false, "server_channel");
+struct registered_method;
-typedef struct requested_call {
+struct requested_call {
+ gpr_mpscq_node request_link; /* must be first */
requested_call_type type;
size_t cq_idx;
- void *tag;
- grpc_server *server;
- grpc_completion_queue *cq_bound_to_call;
- grpc_call **call;
+ void* tag;
+ grpc_server* server;
+ grpc_completion_queue* cq_bound_to_call;
+ grpc_call** call;
grpc_cq_completion completion;
- grpc_metadata_array *initial_metadata;
+ grpc_metadata_array* initial_metadata;
union {
struct {
- grpc_call_details *details;
+ grpc_call_details* details;
} batch;
struct {
- registered_method *method;
- gpr_timespec *deadline;
- grpc_byte_buffer **optional_payload;
+ registered_method* method;
+ gpr_timespec* deadline;
+ grpc_byte_buffer** optional_payload;
} registered;
} data;
-} requested_call;
+};
-typedef struct channel_registered_method {
- registered_method *server_registered_method;
+struct channel_registered_method {
+ registered_method* server_registered_method;
uint32_t flags;
bool has_host;
grpc_slice method;
grpc_slice host;
-} channel_registered_method;
+};
struct channel_data {
- grpc_server *server;
+ grpc_server* server;
grpc_connectivity_state connectivity_state;
- grpc_channel *channel;
+ grpc_channel* channel;
size_t cq_idx;
/* linked list of all channels on a server */
- channel_data *next;
- channel_data *prev;
- channel_registered_method *registered_methods;
+ channel_data* next;
+ channel_data* prev;
+ channel_registered_method* registered_methods;
uint32_t registered_method_slots;
uint32_t registered_method_max_probes;
grpc_closure finish_destroy_channel_closure;
@@ -107,8 +106,8 @@ struct channel_data {
};
typedef struct shutdown_tag {
- void *tag;
- grpc_completion_queue *cq;
+ void* tag;
+ grpc_completion_queue* cq;
grpc_cq_completion completion;
} shutdown_tag;
@@ -126,65 +125,63 @@ typedef enum {
typedef struct request_matcher request_matcher;
struct call_data {
- grpc_call *call;
+ grpc_call* call;
- /** protects state */
- gpr_mu mu_state;
- /** the current state of a call - see call_state */
- call_state state;
+ gpr_atm state;
bool path_set;
bool host_set;
grpc_slice path;
grpc_slice host;
- gpr_timespec deadline;
+ grpc_millis deadline;
- grpc_completion_queue *cq_new;
+ grpc_completion_queue* cq_new;
- grpc_metadata_batch *recv_initial_metadata;
+ grpc_metadata_batch* recv_initial_metadata;
uint32_t recv_initial_metadata_flags;
grpc_metadata_array initial_metadata;
- request_matcher *matcher;
- grpc_byte_buffer *payload;
+ request_matcher* matcher;
+ grpc_byte_buffer* payload;
grpc_closure got_initial_metadata;
grpc_closure server_on_recv_initial_metadata;
grpc_closure kill_zombie_closure;
- grpc_closure *on_done_recv_initial_metadata;
+ grpc_closure* on_done_recv_initial_metadata;
grpc_closure publish;
- call_data *pending_next;
+ call_data* pending_next;
};
struct request_matcher {
- grpc_server *server;
- call_data *pending_head;
- call_data *pending_tail;
- gpr_stack_lockfree **requests_per_cq;
+ grpc_server* server;
+ call_data* pending_head;
+ call_data* pending_tail;
+ gpr_locked_mpscq* requests_per_cq;
};
struct registered_method {
- char *method;
- char *host;
+ char* method;
+ char* host;
grpc_server_register_method_payload_handling payload_handling;
uint32_t flags;
/* one request matcher per method */
request_matcher matcher;
- registered_method *next;
+ registered_method* next;
};
typedef struct {
- grpc_channel **channels;
+ grpc_channel** channels;
size_t num_channels;
} channel_broadcaster;
+} // namespace
struct grpc_server {
- grpc_channel_args *channel_args;
+ grpc_channel_args* channel_args;
- grpc_completion_queue **cqs;
- grpc_pollset **pollsets;
+ grpc_completion_queue** cqs;
+ grpc_pollset** pollsets;
size_t cq_count;
size_t pollset_count;
bool started;
@@ -204,23 +201,18 @@ struct grpc_server {
bool starting;
gpr_cv starting_cv;
- registered_method *registered_methods;
+ registered_method* registered_methods;
/** one request matcher for unregistered methods */
request_matcher unregistered_request_matcher;
- /** free list of available requested_calls_per_cq indices */
- gpr_stack_lockfree **request_freelist_per_cq;
- /** requested call backing data */
- requested_call **requested_calls_per_cq;
- int max_requested_calls_per_cq;
gpr_atm shutdown_flag;
uint8_t shutdown_published;
size_t num_shutdown_tags;
- shutdown_tag *shutdown_tags;
+ shutdown_tag* shutdown_tags;
channel_data root_channel_data;
- listener *listeners;
+ listener* listeners;
int listeners_destroyed;
gpr_refcount internal_refcount;
@@ -229,30 +221,29 @@ struct grpc_server {
};
#define SERVER_FROM_CALL_ELEM(elem) \
- (((channel_data *)(elem)->channel_data)->server)
+ (((channel_data*)(elem)->channel_data)->server)
-static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *calld,
- grpc_error *error);
-static void fail_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
- size_t cq_idx, requested_call *rc, grpc_error *error);
+static void publish_new_rpc(void* calld, grpc_error* error);
+static void fail_call(grpc_server* server, size_t cq_idx, requested_call* rc,
+ grpc_error* error);
/* Before calling maybe_finish_shutdown, we must hold mu_global and not
hold mu_call */
-static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_server *server);
+static void maybe_finish_shutdown(grpc_server* server);
/*
* channel broadcaster
*/
/* assumes server locked */
-static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) {
- channel_data *c;
+static void channel_broadcaster_init(grpc_server* s, channel_broadcaster* cb) {
+ channel_data* c;
size_t count = 0;
for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
count++;
}
cb->num_channels = count;
cb->channels =
- (grpc_channel **)gpr_malloc(sizeof(*cb->channels) * cb->num_channels);
+ (grpc_channel**)gpr_malloc(sizeof(*cb->channels) * cb->num_channels);
count = 0;
for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
cb->channels[count++] = c->channel;
@@ -265,21 +256,20 @@ struct shutdown_cleanup_args {
grpc_slice slice;
};
-static void shutdown_cleanup(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- struct shutdown_cleanup_args *a = (struct shutdown_cleanup_args *)arg;
- grpc_slice_unref_internal(exec_ctx, a->slice);
+static void shutdown_cleanup(void* arg, grpc_error* error) {
+ struct shutdown_cleanup_args* a = (struct shutdown_cleanup_args*)arg;
+ grpc_slice_unref_internal(a->slice);
gpr_free(a);
}
-static void send_shutdown(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
- bool send_goaway, grpc_error *send_disconnect) {
- struct shutdown_cleanup_args *sc =
- (struct shutdown_cleanup_args *)gpr_malloc(sizeof(*sc));
+static void send_shutdown(grpc_channel* channel, bool send_goaway,
+ grpc_error* send_disconnect) {
+ struct shutdown_cleanup_args* sc =
+ (struct shutdown_cleanup_args*)gpr_malloc(sizeof(*sc));
GRPC_CLOSURE_INIT(&sc->closure, shutdown_cleanup, sc,
grpc_schedule_on_exec_ctx);
- grpc_transport_op *op = grpc_make_transport_op(&sc->closure);
- grpc_channel_element *elem;
+ grpc_transport_op* op = grpc_make_transport_op(&sc->closure);
+ grpc_channel_element* elem;
op->goaway_error =
send_goaway ? grpc_error_set_int(
@@ -291,19 +281,18 @@ static void send_shutdown(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
op->disconnect_with_error = send_disconnect;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
}
-static void channel_broadcaster_shutdown(grpc_exec_ctx *exec_ctx,
- channel_broadcaster *cb,
+static void channel_broadcaster_shutdown(channel_broadcaster* cb,
bool send_goaway,
- grpc_error *force_disconnect) {
+ grpc_error* force_disconnect) {
size_t i;
for (i = 0; i < cb->num_channels; i++) {
- send_shutdown(exec_ctx, cb->channels[i], send_goaway,
+ send_shutdown(cb->channels[i], send_goaway,
GRPC_ERROR_REF(force_disconnect));
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, cb->channels[i], "broadcast");
+ GRPC_CHANNEL_INTERNAL_UNREF(cb->channels[i], "broadcast");
}
gpr_free(cb->channels);
GRPC_ERROR_UNREF(force_disconnect);
@@ -313,57 +302,49 @@ static void channel_broadcaster_shutdown(grpc_exec_ctx *exec_ctx,
* request_matcher
*/
-static void request_matcher_init(request_matcher *rm, size_t entries,
- grpc_server *server) {
+static void request_matcher_init(request_matcher* rm, grpc_server* server) {
memset(rm, 0, sizeof(*rm));
rm->server = server;
- rm->requests_per_cq = (gpr_stack_lockfree **)gpr_malloc(
+ rm->requests_per_cq = (gpr_locked_mpscq*)gpr_malloc(
sizeof(*rm->requests_per_cq) * server->cq_count);
for (size_t i = 0; i < server->cq_count; i++) {
- rm->requests_per_cq[i] = gpr_stack_lockfree_create(entries);
+ gpr_locked_mpscq_init(&rm->requests_per_cq[i]);
}
}
-static void request_matcher_destroy(request_matcher *rm) {
+static void request_matcher_destroy(request_matcher* rm) {
for (size_t i = 0; i < rm->server->cq_count; i++) {
- GPR_ASSERT(gpr_stack_lockfree_pop(rm->requests_per_cq[i]) == -1);
- gpr_stack_lockfree_destroy(rm->requests_per_cq[i]);
+ GPR_ASSERT(gpr_locked_mpscq_pop(&rm->requests_per_cq[i]) == nullptr);
+ gpr_locked_mpscq_destroy(&rm->requests_per_cq[i]);
}
gpr_free(rm->requests_per_cq);
}
-static void kill_zombie(grpc_exec_ctx *exec_ctx, void *elem,
- grpc_error *error) {
- grpc_call_unref(grpc_call_from_top_element((grpc_call_element *)elem));
+static void kill_zombie(void* elem, grpc_error* error) {
+ grpc_call_unref(grpc_call_from_top_element((grpc_call_element*)elem));
}
-static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx *exec_ctx,
- request_matcher *rm) {
+static void request_matcher_zombify_all_pending_calls(request_matcher* rm) {
while (rm->pending_head) {
- call_data *calld = rm->pending_head;
+ call_data* calld = rm->pending_head;
rm->pending_head = calld->pending_next;
- gpr_mu_lock(&calld->mu_state);
- calld->state = ZOMBIED;
- gpr_mu_unlock(&calld->mu_state);
+ gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
GRPC_CLOSURE_INIT(
&calld->kill_zombie_closure, kill_zombie,
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
}
}
-static void request_matcher_kill_requests(grpc_exec_ctx *exec_ctx,
- grpc_server *server,
- request_matcher *rm,
- grpc_error *error) {
- int request_id;
+static void request_matcher_kill_requests(grpc_server* server,
+ request_matcher* rm,
+ grpc_error* error) {
+ requested_call* rc;
for (size_t i = 0; i < server->cq_count; i++) {
- while ((request_id = gpr_stack_lockfree_pop(rm->requests_per_cq[i])) !=
- -1) {
- fail_call(exec_ctx, server, i,
- &server->requested_calls_per_cq[i][request_id],
- GRPC_ERROR_REF(error));
+ while ((rc = (requested_call*)gpr_locked_mpscq_pop(
+ &rm->requests_per_cq[i])) != nullptr) {
+ fail_call(server, i, rc, GRPC_ERROR_REF(error));
}
}
GRPC_ERROR_UNREF(error);
@@ -373,18 +354,18 @@ static void request_matcher_kill_requests(grpc_exec_ctx *exec_ctx,
* server proper
*/
-static void server_ref(grpc_server *server) {
+static void server_ref(grpc_server* server) {
gpr_ref(&server->internal_refcount);
}
-static void server_delete(grpc_exec_ctx *exec_ctx, grpc_server *server) {
- registered_method *rm;
+static void server_delete(grpc_server* server) {
+ registered_method* rm;
size_t i;
- grpc_channel_args_destroy(exec_ctx, server->channel_args);
+ grpc_channel_args_destroy(server->channel_args);
gpr_mu_destroy(&server->mu_global);
gpr_mu_destroy(&server->mu_call);
gpr_cv_destroy(&server->starting_cv);
- while ((rm = server->registered_methods) != NULL) {
+ while ((rm = server->registered_methods) != nullptr) {
server->registered_methods = rm->next;
if (server->started) {
request_matcher_destroy(&rm->matcher);
@@ -397,92 +378,68 @@ static void server_delete(grpc_exec_ctx *exec_ctx, grpc_server *server) {
request_matcher_destroy(&server->unregistered_request_matcher);
}
for (i = 0; i < server->cq_count; i++) {
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, server->cqs[i], "server");
- if (server->started) {
- gpr_stack_lockfree_destroy(server->request_freelist_per_cq[i]);
- gpr_free(server->requested_calls_per_cq[i]);
- }
+ GRPC_CQ_INTERNAL_UNREF(server->cqs[i], "server");
}
- gpr_free(server->request_freelist_per_cq);
- gpr_free(server->requested_calls_per_cq);
gpr_free(server->cqs);
gpr_free(server->pollsets);
gpr_free(server->shutdown_tags);
gpr_free(server);
}
-static void server_unref(grpc_exec_ctx *exec_ctx, grpc_server *server) {
+static void server_unref(grpc_server* server) {
if (gpr_unref(&server->internal_refcount)) {
- server_delete(exec_ctx, server);
+ server_delete(server);
}
}
-static int is_channel_orphaned(channel_data *chand) {
+static int is_channel_orphaned(channel_data* chand) {
return chand->next == chand;
}
-static void orphan_channel(channel_data *chand) {
+static void orphan_channel(channel_data* chand) {
chand->next->prev = chand->prev;
chand->prev->next = chand->next;
chand->next = chand->prev = chand;
}
-static void finish_destroy_channel(grpc_exec_ctx *exec_ctx, void *cd,
- grpc_error *error) {
- channel_data *chand = (channel_data *)cd;
- grpc_server *server = chand->server;
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, chand->channel, "server");
- server_unref(exec_ctx, server);
+static void finish_destroy_channel(void* cd, grpc_error* error) {
+ channel_data* chand = (channel_data*)cd;
+ grpc_server* server = chand->server;
+ GRPC_CHANNEL_INTERNAL_UNREF(chand->channel, "server");
+ server_unref(server);
}
-static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand,
- grpc_error *error) {
+static void destroy_channel(channel_data* chand, grpc_error* error) {
if (is_channel_orphaned(chand)) return;
- GPR_ASSERT(chand->server != NULL);
+ GPR_ASSERT(chand->server != nullptr);
orphan_channel(chand);
server_ref(chand->server);
- maybe_finish_shutdown(exec_ctx, chand->server);
+ maybe_finish_shutdown(chand->server);
GRPC_CLOSURE_INIT(&chand->finish_destroy_channel_closure,
finish_destroy_channel, chand, grpc_schedule_on_exec_ctx);
- if (GRPC_TRACER_ON(grpc_server_channel_trace) && error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(error);
+ if (grpc_server_channel_trace.enabled() && error != GRPC_ERROR_NONE) {
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_INFO, "Disconnected client: %s", msg);
}
GRPC_ERROR_UNREF(error);
- grpc_transport_op *op =
+ grpc_transport_op* op =
grpc_make_transport_op(&chand->finish_destroy_channel_closure);
op->set_accept_stream = true;
- grpc_channel_next_op(exec_ctx,
- grpc_channel_stack_element(
+ grpc_channel_next_op(grpc_channel_stack_element(
grpc_channel_get_channel_stack(chand->channel), 0),
op);
}
-static void done_request_event(grpc_exec_ctx *exec_ctx, void *req,
- grpc_cq_completion *c) {
- requested_call *rc = (requested_call *)req;
- grpc_server *server = rc->server;
-
- if (rc >= server->requested_calls_per_cq[rc->cq_idx] &&
- rc < server->requested_calls_per_cq[rc->cq_idx] +
- server->max_requested_calls_per_cq) {
- GPR_ASSERT(rc - server->requested_calls_per_cq[rc->cq_idx] <= INT_MAX);
- gpr_stack_lockfree_push(
- server->request_freelist_per_cq[rc->cq_idx],
- (int)(rc - server->requested_calls_per_cq[rc->cq_idx]));
- } else {
- gpr_free(req);
- }
-
- server_unref(exec_ctx, server);
+static void done_request_event(void* req, grpc_cq_completion* c) {
+ gpr_free(req);
}
-static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
- call_data *calld, size_t cq_idx, requested_call *rc) {
- grpc_call_set_completion_queue(exec_ctx, calld->call, rc->cq_bound_to_call);
- grpc_call *call = calld->call;
+static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx,
+ requested_call* rc) {
+ grpc_call_set_completion_queue(calld->call, rc->cq_bound_to_call);
+ grpc_call* call = calld->call;
*rc->call = call;
calld->cq_new = server->cqs[cq_idx];
GPR_SWAP(grpc_metadata_array, *rc->initial_metadata, calld->initial_metadata);
@@ -492,94 +449,101 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
GPR_ASSERT(calld->path_set);
rc->data.batch.details->host = grpc_slice_ref_internal(calld->host);
rc->data.batch.details->method = grpc_slice_ref_internal(calld->path);
- rc->data.batch.details->deadline = calld->deadline;
+ rc->data.batch.details->deadline =
+ grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_MONOTONIC);
rc->data.batch.details->flags = calld->recv_initial_metadata_flags;
break;
case REGISTERED_CALL:
- *rc->data.registered.deadline = calld->deadline;
+ *rc->data.registered.deadline =
+ grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_MONOTONIC);
if (rc->data.registered.optional_payload) {
*rc->data.registered.optional_payload = calld->payload;
- calld->payload = NULL;
+ calld->payload = nullptr;
}
break;
default:
GPR_UNREACHABLE_CODE(return );
}
- grpc_call_element *elem =
- grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
- channel_data *chand = (channel_data *)elem->channel_data;
- server_ref(chand->server);
- grpc_cq_end_op(exec_ctx, calld->cq_new, rc->tag, GRPC_ERROR_NONE,
- done_request_event, rc, &rc->completion);
+ grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event,
+ rc, &rc->completion);
}
-static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *call_elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)call_elem->call_data;
- channel_data *chand = (channel_data *)call_elem->channel_data;
- request_matcher *rm = calld->matcher;
- grpc_server *server = rm->server;
+static void publish_new_rpc(void* arg, grpc_error* error) {
+ grpc_call_element* call_elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)call_elem->call_data;
+ channel_data* chand = (channel_data*)call_elem->channel_data;
+ request_matcher* rm = calld->matcher;
+ grpc_server* server = rm->server;
if (error != GRPC_ERROR_NONE || gpr_atm_acq_load(&server->shutdown_flag)) {
- gpr_mu_lock(&calld->mu_state);
- calld->state = ZOMBIED;
- gpr_mu_unlock(&calld->mu_state);
+ gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
GRPC_CLOSURE_INIT(
&calld->kill_zombie_closure, kill_zombie,
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_REF(error));
return;
}
for (size_t i = 0; i < server->cq_count; i++) {
size_t cq_idx = (chand->cq_idx + i) % server->cq_count;
- int request_id = gpr_stack_lockfree_pop(rm->requests_per_cq[cq_idx]);
- if (request_id == -1) {
+ requested_call* rc =
+ (requested_call*)gpr_locked_mpscq_try_pop(&rm->requests_per_cq[cq_idx]);
+ if (rc == nullptr) {
continue;
} else {
- GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i);
- gpr_mu_lock(&calld->mu_state);
- calld->state = ACTIVATED;
- gpr_mu_unlock(&calld->mu_state);
- publish_call(exec_ctx, server, calld, cq_idx,
- &server->requested_calls_per_cq[cq_idx][request_id]);
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(i);
+ gpr_atm_no_barrier_store(&calld->state, ACTIVATED);
+ publish_call(server, calld, cq_idx, rc);
return; /* early out */
}
}
/* no cq to take the request found: queue it on the slow list */
- GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(exec_ctx);
+ GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED();
gpr_mu_lock(&server->mu_call);
- gpr_mu_lock(&calld->mu_state);
- calld->state = PENDING;
- gpr_mu_unlock(&calld->mu_state);
- if (rm->pending_head == NULL) {
+
+ // We need to ensure that all the queues are empty. We do this under
+ // the server mu_call lock to ensure that if something is added to
+ // an empty request queue, it will block until the call is actually
+ // added to the pending list.
+ for (size_t i = 0; i < server->cq_count; i++) {
+ size_t cq_idx = (chand->cq_idx + i) % server->cq_count;
+ requested_call* rc =
+ (requested_call*)gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]);
+ if (rc == nullptr) {
+ continue;
+ } else {
+ gpr_mu_unlock(&server->mu_call);
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(i + server->cq_count);
+ gpr_atm_no_barrier_store(&calld->state, ACTIVATED);
+ publish_call(server, calld, cq_idx, rc);
+ return; /* early out */
+ }
+ }
+
+ gpr_atm_no_barrier_store(&calld->state, PENDING);
+ if (rm->pending_head == nullptr) {
rm->pending_tail = rm->pending_head = calld;
} else {
rm->pending_tail->pending_next = calld;
rm->pending_tail = calld;
}
- calld->pending_next = NULL;
+ calld->pending_next = nullptr;
gpr_mu_unlock(&server->mu_call);
}
static void finish_start_new_rpc(
- grpc_exec_ctx *exec_ctx, grpc_server *server, grpc_call_element *elem,
- request_matcher *rm,
+ grpc_server* server, grpc_call_element* elem, request_matcher* rm,
grpc_server_register_method_payload_handling payload_handling) {
- call_data *calld = (call_data *)elem->call_data;
+ call_data* calld = (call_data*)elem->call_data;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
- gpr_mu_lock(&calld->mu_state);
- calld->state = ZOMBIED;
- gpr_mu_unlock(&calld->mu_state);
+ gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
GRPC_CLOSURE_INIT(&calld->kill_zombie_closure, kill_zombie, elem,
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
return;
}
@@ -587,7 +551,7 @@ static void finish_start_new_rpc(
switch (payload_handling) {
case GRPC_SRM_PAYLOAD_NONE:
- publish_new_rpc(exec_ctx, elem, GRPC_ERROR_NONE);
+ publish_new_rpc(elem, GRPC_ERROR_NONE);
break;
case GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER: {
grpc_op op;
@@ -596,20 +560,19 @@ static void finish_start_new_rpc(
op.data.recv_message.recv_message = &calld->payload;
GRPC_CLOSURE_INIT(&calld->publish, publish_new_rpc, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_start_batch_and_execute(exec_ctx, calld->call, &op, 1,
- &calld->publish);
+ grpc_call_start_batch_and_execute(calld->call, &op, 1, &calld->publish);
break;
}
}
}
-static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
- grpc_server *server = chand->server;
+static void start_new_rpc(grpc_call_element* elem) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_server* server = chand->server;
uint32_t i;
uint32_t hash;
- channel_registered_method *rm;
+ channel_registered_method* rm;
if (chand->registered_methods && calld->path_set && calld->host_set) {
/* TODO(ctiller): unify these two searches */
@@ -628,8 +591,7 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)) {
continue;
}
- finish_start_new_rpc(exec_ctx, server, elem,
- &rm->server_registered_method->matcher,
+ finish_start_new_rpc(server, elem, &rm->server_registered_method->matcher,
rm->server_registered_method->payload_handling);
return;
}
@@ -646,19 +608,17 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)) {
continue;
}
- finish_start_new_rpc(exec_ctx, server, elem,
- &rm->server_registered_method->matcher,
+ finish_start_new_rpc(server, elem, &rm->server_registered_method->matcher,
rm->server_registered_method->payload_handling);
return;
}
}
- finish_start_new_rpc(exec_ctx, server, elem,
- &server->unregistered_request_matcher,
+ finish_start_new_rpc(server, elem, &server->unregistered_request_matcher,
GRPC_SRM_PAYLOAD_NONE);
}
-static int num_listeners(grpc_server *server) {
- listener *l;
+static int num_listeners(grpc_server* server) {
+ listener* l;
int n = 0;
for (l = server->listeners; l; l = l->next) {
n++;
@@ -666,13 +626,12 @@ static int num_listeners(grpc_server *server) {
return n;
}
-static void done_shutdown_event(grpc_exec_ctx *exec_ctx, void *server,
- grpc_cq_completion *completion) {
- server_unref(exec_ctx, (grpc_server *)server);
+static void done_shutdown_event(void* server, grpc_cq_completion* completion) {
+ server_unref((grpc_server*)server);
}
-static int num_channels(grpc_server *server) {
- channel_data *chand;
+static int num_channels(grpc_server* server) {
+ channel_data* chand;
int n = 0;
for (chand = server->root_channel_data.next;
chand != &server->root_channel_data; chand = chand->next) {
@@ -681,34 +640,30 @@ static int num_channels(grpc_server *server) {
return n;
}
-static void kill_pending_work_locked(grpc_exec_ctx *exec_ctx,
- grpc_server *server, grpc_error *error) {
+static void kill_pending_work_locked(grpc_server* server, grpc_error* error) {
if (server->started) {
- request_matcher_kill_requests(exec_ctx, server,
- &server->unregistered_request_matcher,
+ request_matcher_kill_requests(server, &server->unregistered_request_matcher,
GRPC_ERROR_REF(error));
request_matcher_zombify_all_pending_calls(
- exec_ctx, &server->unregistered_request_matcher);
- for (registered_method *rm = server->registered_methods; rm;
+ &server->unregistered_request_matcher);
+ for (registered_method* rm = server->registered_methods; rm;
rm = rm->next) {
- request_matcher_kill_requests(exec_ctx, server, &rm->matcher,
+ request_matcher_kill_requests(server, &rm->matcher,
GRPC_ERROR_REF(error));
- request_matcher_zombify_all_pending_calls(exec_ctx, &rm->matcher);
+ request_matcher_zombify_all_pending_calls(&rm->matcher);
}
}
GRPC_ERROR_UNREF(error);
}
-static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_server *server) {
+static void maybe_finish_shutdown(grpc_server* server) {
size_t i;
if (!gpr_atm_acq_load(&server->shutdown_flag) || server->shutdown_published) {
return;
}
kill_pending_work_locked(
- exec_ctx, server,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
if (server->root_channel_data.next != &server->root_channel_data ||
server->listeners_destroyed < num_listeners(server)) {
@@ -728,58 +683,56 @@ static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
server->shutdown_published = 1;
for (i = 0; i < server->num_shutdown_tags; i++) {
server_ref(server);
- grpc_cq_end_op(exec_ctx, server->shutdown_tags[i].cq,
- server->shutdown_tags[i].tag, GRPC_ERROR_NONE,
- done_shutdown_event, server,
+ grpc_cq_end_op(server->shutdown_tags[i].cq, server->shutdown_tags[i].tag,
+ GRPC_ERROR_NONE, done_shutdown_event, server,
&server->shutdown_tags[i].completion);
}
}
-static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)ptr;
- call_data *calld = (call_data *)elem->call_data;
- gpr_timespec op_deadline;
+static void server_on_recv_initial_metadata(void* ptr, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)ptr;
+ call_data* calld = (call_data*)elem->call_data;
+ grpc_millis op_deadline;
if (error == GRPC_ERROR_NONE) {
- GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != NULL);
- GPR_ASSERT(calld->recv_initial_metadata->idx.named.authority != NULL);
+ GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != nullptr);
+ GPR_ASSERT(calld->recv_initial_metadata->idx.named.authority != nullptr);
calld->path = grpc_slice_ref_internal(
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md));
calld->host = grpc_slice_ref_internal(
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.authority->md));
calld->path_set = true;
calld->host_set = true;
- grpc_metadata_batch_remove(exec_ctx, calld->recv_initial_metadata,
+ grpc_metadata_batch_remove(calld->recv_initial_metadata,
calld->recv_initial_metadata->idx.named.path);
grpc_metadata_batch_remove(
- exec_ctx, calld->recv_initial_metadata,
+ calld->recv_initial_metadata,
calld->recv_initial_metadata->idx.named.authority);
} else {
GRPC_ERROR_REF(error);
}
op_deadline = calld->recv_initial_metadata->deadline;
- if (0 != gpr_time_cmp(op_deadline, gpr_inf_future(op_deadline.clock_type))) {
+ if (op_deadline != GRPC_MILLIS_INF_FUTURE) {
calld->deadline = op_deadline;
}
if (calld->host_set && calld->path_set) {
/* do nothing */
} else {
- grpc_error *src_error = error;
+ grpc_error* src_error = error;
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Missing :authority or :path", &error, 1);
GRPC_ERROR_UNREF(src_error);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->on_done_recv_initial_metadata, error);
+ GRPC_CLOSURE_RUN(calld->on_done_recv_initial_metadata, error);
}
-static void server_mutate_op(grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- call_data *calld = (call_data *)elem->call_data;
+static void server_mutate_op(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
+ call_data* calld = (call_data*)elem->call_data;
if (op->recv_initial_metadata) {
- GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags == NULL);
+ GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags == nullptr);
calld->recv_initial_metadata =
op->payload->recv_initial_metadata.recv_initial_metadata;
calld->on_done_recv_initial_metadata =
@@ -792,58 +745,47 @@ static void server_mutate_op(grpc_call_element *elem,
}
static void server_start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
server_mutate_op(elem, op);
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
-static void got_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)ptr;
- call_data *calld = (call_data *)elem->call_data;
+static void got_initial_metadata(void* ptr, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)ptr;
+ call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- start_new_rpc(exec_ctx, elem);
+ start_new_rpc(elem);
} else {
- gpr_mu_lock(&calld->mu_state);
- if (calld->state == NOT_STARTED) {
- calld->state = ZOMBIED;
- gpr_mu_unlock(&calld->mu_state);
+ if (gpr_atm_full_cas(&calld->state, NOT_STARTED, ZOMBIED)) {
GRPC_CLOSURE_INIT(&calld->kill_zombie_closure, kill_zombie, elem,
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
- GRPC_ERROR_NONE);
- } else if (calld->state == PENDING) {
- calld->state = ZOMBIED;
- gpr_mu_unlock(&calld->mu_state);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
+ } else if (gpr_atm_full_cas(&calld->state, PENDING, ZOMBIED)) {
/* zombied call will be destroyed when it's removed from the pending
queue... later */
- } else {
- gpr_mu_unlock(&calld->mu_state);
}
}
}
-static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd,
- grpc_transport *transport,
- const void *transport_server_data) {
- channel_data *chand = (channel_data *)cd;
+static void accept_stream(void* cd, grpc_transport* transport,
+ const void* transport_server_data) {
+ channel_data* chand = (channel_data*)cd;
/* create a call */
grpc_call_create_args args;
memset(&args, 0, sizeof(args));
args.channel = chand->channel;
args.server_transport_data = transport_server_data;
- args.send_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- grpc_call *call;
- grpc_error *error = grpc_call_create(exec_ctx, &args, &call);
- grpc_call_element *elem =
+ args.send_deadline = GRPC_MILLIS_INF_FUTURE;
+ grpc_call* call;
+ grpc_error* error = grpc_call_create(&args, &call);
+ grpc_call_element* elem =
grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
if (error != GRPC_ERROR_NONE) {
- got_initial_metadata(exec_ctx, elem, error);
+ got_initial_metadata(elem, error);
GRPC_ERROR_UNREF(error);
return;
}
- call_data *calld = (call_data *)elem->call_data;
+ call_data* calld = (call_data*)elem->call_data;
grpc_op op;
memset(&op, 0, sizeof(op));
op.op = GRPC_OP_RECV_INITIAL_METADATA;
@@ -851,39 +793,34 @@ static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd,
&calld->initial_metadata;
GRPC_CLOSURE_INIT(&calld->got_initial_metadata, got_initial_metadata, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_start_batch_and_execute(exec_ctx, call, &op, 1,
- &calld->got_initial_metadata);
+ grpc_call_start_batch_and_execute(call, &op, 1, &calld->got_initial_metadata);
}
-static void channel_connectivity_changed(grpc_exec_ctx *exec_ctx, void *cd,
- grpc_error *error) {
- channel_data *chand = (channel_data *)cd;
- grpc_server *server = chand->server;
+static void channel_connectivity_changed(void* cd, grpc_error* error) {
+ channel_data* chand = (channel_data*)cd;
+ grpc_server* server = chand->server;
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
- grpc_transport_op *op = grpc_make_transport_op(NULL);
- op->on_connectivity_state_change = &chand->channel_connectivity_changed,
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
+ op->on_connectivity_state_change = &chand->channel_connectivity_changed;
op->connectivity_state = &chand->connectivity_state;
- grpc_channel_next_op(exec_ctx,
- grpc_channel_stack_element(
+ grpc_channel_next_op(grpc_channel_stack_element(
grpc_channel_get_channel_stack(chand->channel), 0),
op);
} else {
gpr_mu_lock(&server->mu_global);
- destroy_channel(exec_ctx, chand, GRPC_ERROR_REF(error));
+ destroy_channel(chand, GRPC_ERROR_REF(error));
gpr_mu_unlock(&server->mu_global);
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, chand->channel, "connectivity");
+ GRPC_CHANNEL_INTERNAL_UNREF(chand->channel, "connectivity");
}
}
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = (call_data *)elem->call_data;
- channel_data *chand = (channel_data *)elem->channel_data;
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = (call_data*)elem->call_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
memset(calld, 0, sizeof(call_data));
- calld->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
+ calld->deadline = GRPC_MILLIS_INF_FUTURE;
calld->call = grpc_call_from_top_element(elem);
- gpr_mu_init(&calld->mu_state);
GRPC_CLOSURE_INIT(&calld->server_on_recv_initial_metadata,
server_on_recv_initial_metadata, elem,
@@ -893,38 +830,35 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- channel_data *chand = (channel_data *)elem->channel_data;
- call_data *calld = (call_data *)elem->call_data;
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ channel_data* chand = (channel_data*)elem->channel_data;
+ call_data* calld = (call_data*)elem->call_data;
GPR_ASSERT(calld->state != PENDING);
if (calld->host_set) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
if (calld->path_set) {
- grpc_slice_unref_internal(exec_ctx, calld->path);
+ grpc_slice_unref_internal(calld->path);
}
grpc_metadata_array_destroy(&calld->initial_metadata);
grpc_byte_buffer_destroy(calld->payload);
- gpr_mu_destroy(&calld->mu_state);
-
- server_unref(exec_ctx, chand->server);
+ server_unref(chand->server);
}
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- channel_data *chand = (channel_data *)elem->channel_data;
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(args->is_first);
GPR_ASSERT(!args->is_last);
- chand->server = NULL;
- chand->channel = NULL;
+ chand->server = nullptr;
+ chand->channel = nullptr;
chand->next = chand->prev = chand;
- chand->registered_methods = NULL;
+ chand->registered_methods = nullptr;
chand->connectivity_state = GRPC_CHANNEL_IDLE;
GRPC_CLOSURE_INIT(&chand->channel_connectivity_changed,
channel_connectivity_changed, chand,
@@ -932,15 +866,14 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
size_t i;
- channel_data *chand = (channel_data *)elem->channel_data;
+ channel_data* chand = (channel_data*)elem->channel_data;
if (chand->registered_methods) {
for (i = 0; i < chand->registered_method_slots; i++) {
- grpc_slice_unref_internal(exec_ctx, chand->registered_methods[i].method);
+ grpc_slice_unref_internal(chand->registered_methods[i].method);
if (chand->registered_methods[i].has_host) {
- grpc_slice_unref_internal(exec_ctx, chand->registered_methods[i].host);
+ grpc_slice_unref_internal(chand->registered_methods[i].host);
}
}
gpr_free(chand->registered_methods);
@@ -950,9 +883,9 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
chand->next->prev = chand->prev;
chand->prev->next = chand->next;
chand->next = chand->prev = chand;
- maybe_finish_shutdown(exec_ctx, chand->server);
+ maybe_finish_shutdown(chand->server);
gpr_mu_unlock(&chand->server->mu_global);
- server_unref(exec_ctx, chand->server);
+ server_unref(chand->server);
}
}
@@ -970,9 +903,9 @@ const grpc_channel_filter grpc_server_top_filter = {
"server",
};
-static void register_completion_queue(grpc_server *server,
- grpc_completion_queue *cq,
- void *reserved) {
+static void register_completion_queue(grpc_server* server,
+ grpc_completion_queue* cq,
+ void* reserved) {
size_t i, n;
GPR_ASSERT(!reserved);
for (i = 0; i < server->cq_count; i++) {
@@ -981,14 +914,14 @@ static void register_completion_queue(grpc_server *server,
GRPC_CQ_INTERNAL_REF(cq, "server");
n = server->cq_count++;
- server->cqs = (grpc_completion_queue **)gpr_realloc(
- server->cqs, server->cq_count * sizeof(grpc_completion_queue *));
+ server->cqs = (grpc_completion_queue**)gpr_realloc(
+ server->cqs, server->cq_count * sizeof(grpc_completion_queue*));
server->cqs[n] = cq;
}
-void grpc_server_register_completion_queue(grpc_server *server,
- grpc_completion_queue *cq,
- void *reserved) {
+void grpc_server_register_completion_queue(grpc_server* server,
+ grpc_completion_queue* cq,
+ void* reserved) {
GRPC_API_TRACE(
"grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3,
(server, cq, reserved));
@@ -1004,10 +937,10 @@ void grpc_server_register_completion_queue(grpc_server *server,
register_completion_queue(server, cq, reserved);
}
-grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
+grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) {
GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
- grpc_server *server = (grpc_server *)gpr_zalloc(sizeof(grpc_server));
+ grpc_server* server = (grpc_server*)gpr_zalloc(sizeof(grpc_server));
gpr_mu_init(&server->mu_global);
gpr_mu_init(&server->mu_call);
@@ -1018,25 +951,23 @@ grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
server->root_channel_data.next = server->root_channel_data.prev =
&server->root_channel_data;
- /* TODO(ctiller): expose a channel_arg for this */
- server->max_requested_calls_per_cq = 32768;
server->channel_args = grpc_channel_args_copy(args);
return server;
}
-static int streq(const char *a, const char *b) {
- if (a == NULL && b == NULL) return 1;
- if (a == NULL) return 0;
- if (b == NULL) return 0;
+static int streq(const char* a, const char* b) {
+ if (a == nullptr && b == nullptr) return 1;
+ if (a == nullptr) return 0;
+ if (b == nullptr) return 0;
return 0 == strcmp(a, b);
}
-void *grpc_server_register_method(
- grpc_server *server, const char *method, const char *host,
+void* grpc_server_register_method(
+ grpc_server* server, const char* method, const char* host,
grpc_server_register_method_payload_handling payload_handling,
uint32_t flags) {
- registered_method *m;
+ registered_method* m;
GRPC_API_TRACE(
"grpc_server_register_method(server=%p, method=%s, host=%s, "
"flags=0x%08x)",
@@ -1044,21 +975,21 @@ void *grpc_server_register_method(
if (!method) {
gpr_log(GPR_ERROR,
"grpc_server_register_method method string cannot be NULL");
- return NULL;
+ return nullptr;
}
for (m = server->registered_methods; m; m = m->next) {
if (streq(m->method, method) && streq(m->host, host)) {
gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method,
host ? host : "*");
- return NULL;
+ return nullptr;
}
}
if ((flags & ~GRPC_INITIAL_METADATA_USED_MASK) != 0) {
gpr_log(GPR_ERROR, "grpc_server_register_method invalid flags 0x%08x",
flags);
- return NULL;
+ return nullptr;
}
- m = (registered_method *)gpr_zalloc(sizeof(registered_method));
+ m = (registered_method*)gpr_zalloc(sizeof(registered_method));
m->method = gpr_strdup(method);
m->host = gpr_strdup(host);
m->next = server->registered_methods;
@@ -1068,11 +999,10 @@ void *grpc_server_register_method(
return m;
}
-static void start_listeners(grpc_exec_ctx *exec_ctx, void *s,
- grpc_error *error) {
- grpc_server *server = (grpc_server *)s;
- for (listener *l = server->listeners; l; l = l->next) {
- l->start(exec_ctx, server, l->arg, server->pollsets, server->pollset_count);
+static void start_listeners(void* s, grpc_error* error) {
+ grpc_server* server = (grpc_server*)s;
+ for (listener* l = server->listeners; l; l = l->next) {
+ l->start(server, l->arg, server->pollsets, server->pollset_count);
}
gpr_mu_lock(&server->mu_global);
@@ -1080,80 +1010,61 @@ static void start_listeners(grpc_exec_ctx *exec_ctx, void *s,
gpr_cv_signal(&server->starting_cv);
gpr_mu_unlock(&server->mu_global);
- server_unref(exec_ctx, server);
+ server_unref(server);
}
-void grpc_server_start(grpc_server *server) {
+void grpc_server_start(grpc_server* server) {
size_t i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_start(server=%p)", 1, (server));
server->started = true;
server->pollset_count = 0;
server->pollsets =
- (grpc_pollset **)gpr_malloc(sizeof(grpc_pollset *) * server->cq_count);
- server->request_freelist_per_cq = (gpr_stack_lockfree **)gpr_malloc(
- sizeof(*server->request_freelist_per_cq) * server->cq_count);
- server->requested_calls_per_cq = (requested_call **)gpr_malloc(
- sizeof(*server->requested_calls_per_cq) * server->cq_count);
+ (grpc_pollset**)gpr_malloc(sizeof(grpc_pollset*) * server->cq_count);
for (i = 0; i < server->cq_count; i++) {
if (grpc_cq_can_listen(server->cqs[i])) {
server->pollsets[server->pollset_count++] =
grpc_cq_pollset(server->cqs[i]);
}
- server->request_freelist_per_cq[i] =
- gpr_stack_lockfree_create((size_t)server->max_requested_calls_per_cq);
- for (int j = 0; j < server->max_requested_calls_per_cq; j++) {
- gpr_stack_lockfree_push(server->request_freelist_per_cq[i], j);
- }
- server->requested_calls_per_cq[i] = (requested_call *)gpr_malloc(
- (size_t)server->max_requested_calls_per_cq *
- sizeof(*server->requested_calls_per_cq[i]));
}
- request_matcher_init(&server->unregistered_request_matcher,
- (size_t)server->max_requested_calls_per_cq, server);
- for (registered_method *rm = server->registered_methods; rm; rm = rm->next) {
- request_matcher_init(&rm->matcher,
- (size_t)server->max_requested_calls_per_cq, server);
+ request_matcher_init(&server->unregistered_request_matcher, server);
+ for (registered_method* rm = server->registered_methods; rm; rm = rm->next) {
+ request_matcher_init(&rm->matcher, server);
}
server_ref(server);
server->starting = true;
GRPC_CLOSURE_SCHED(
- &exec_ctx,
GRPC_CLOSURE_CREATE(start_listeners, server,
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT)),
GRPC_ERROR_NONE);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
-void grpc_server_get_pollsets(grpc_server *server, grpc_pollset ***pollsets,
- size_t *pollset_count) {
+void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
+ size_t* pollset_count) {
*pollset_count = server->pollset_count;
*pollsets = server->pollsets;
}
-void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
- grpc_transport *transport,
- grpc_pollset *accepting_pollset,
- const grpc_channel_args *args) {
+void grpc_server_setup_transport(grpc_server* s, grpc_transport* transport,
+ grpc_pollset* accepting_pollset,
+ const grpc_channel_args* args) {
size_t num_registered_methods;
size_t alloc;
- registered_method *rm;
- channel_registered_method *crm;
- grpc_channel *channel;
- channel_data *chand;
+ registered_method* rm;
+ channel_registered_method* crm;
+ grpc_channel* channel;
+ channel_data* chand;
uint32_t hash;
size_t slots;
uint32_t probes;
uint32_t max_probes = 0;
- grpc_transport_op *op = NULL;
+ grpc_transport_op* op = nullptr;
- channel =
- grpc_channel_create(exec_ctx, NULL, args, GRPC_SERVER_CHANNEL, transport);
- chand = (channel_data *)grpc_channel_stack_element(
+ channel = grpc_channel_create(nullptr, args, GRPC_SERVER_CHANNEL, transport);
+ chand = (channel_data*)grpc_channel_stack_element(
grpc_channel_get_channel_stack(channel), 0)
->channel_data;
chand->server = s;
@@ -1179,12 +1090,12 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
if (num_registered_methods > 0) {
slots = 2 * num_registered_methods;
alloc = sizeof(channel_registered_method) * slots;
- chand->registered_methods = (channel_registered_method *)gpr_zalloc(alloc);
+ chand->registered_methods = (channel_registered_method*)gpr_zalloc(alloc);
for (rm = s->registered_methods; rm; rm = rm->next) {
grpc_slice host;
bool has_host;
grpc_slice method;
- if (rm->host != NULL) {
+ if (rm->host != nullptr) {
host = grpc_slice_intern(grpc_slice_from_static_string(rm->host));
has_host = true;
} else {
@@ -1194,7 +1105,7 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash(host) : 0,
grpc_slice_hash(method));
for (probes = 0; chand->registered_methods[(hash + probes) % slots]
- .server_registered_method != NULL;
+ .server_registered_method != nullptr;
probes++)
;
if (probes > max_probes) max_probes = probes;
@@ -1219,7 +1130,7 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
gpr_mu_unlock(&s->mu_global);
GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity");
- op = grpc_make_transport_op(NULL);
+ op = grpc_make_transport_op(nullptr);
op->set_accept_stream = true;
op->set_accept_stream_fn = accept_stream;
op->set_accept_stream_user_data = chand;
@@ -1229,30 +1140,28 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown");
}
- grpc_transport_perform_op(exec_ctx, transport, op);
+ grpc_transport_perform_op(transport, op);
}
-void done_published_shutdown(grpc_exec_ctx *exec_ctx, void *done_arg,
- grpc_cq_completion *storage) {
+void done_published_shutdown(void* done_arg, grpc_cq_completion* storage) {
(void)done_arg;
gpr_free(storage);
}
-static void listener_destroy_done(grpc_exec_ctx *exec_ctx, void *s,
- grpc_error *error) {
- grpc_server *server = (grpc_server *)s;
+static void listener_destroy_done(void* s, grpc_error* error) {
+ grpc_server* server = (grpc_server*)s;
gpr_mu_lock(&server->mu_global);
server->listeners_destroyed++;
- maybe_finish_shutdown(exec_ctx, server);
+ maybe_finish_shutdown(server);
gpr_mu_unlock(&server->mu_global);
}
-void grpc_server_shutdown_and_notify(grpc_server *server,
- grpc_completion_queue *cq, void *tag) {
- listener *l;
- shutdown_tag *sdt;
+void grpc_server_shutdown_and_notify(grpc_server* server,
+ grpc_completion_queue* cq, void* tag) {
+ listener* l;
+ shutdown_tag* sdt;
channel_broadcaster broadcaster;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_shutdown_and_notify(server=%p, cq=%p, tag=%p)", 3,
(server, cq, tag));
@@ -1261,19 +1170,18 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
gpr_mu_lock(&server->mu_global);
while (server->starting) {
gpr_cv_wait(&server->starting_cv, &server->mu_global,
- gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
/* stay locked, and gather up some stuff to do */
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
if (server->shutdown_published) {
- grpc_cq_end_op(
- &exec_ctx, cq, tag, GRPC_ERROR_NONE, done_published_shutdown, NULL,
- (grpc_cq_completion *)gpr_malloc(sizeof(grpc_cq_completion)));
+ grpc_cq_end_op(cq, tag, GRPC_ERROR_NONE, done_published_shutdown, nullptr,
+ (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
gpr_mu_unlock(&server->mu_global);
- goto done;
+ return;
}
- server->shutdown_tags = (shutdown_tag *)gpr_realloc(
+ server->shutdown_tags = (shutdown_tag*)gpr_realloc(
server->shutdown_tags,
sizeof(shutdown_tag) * (server->num_shutdown_tags + 1));
sdt = &server->shutdown_tags[server->num_shutdown_tags++];
@@ -1281,7 +1189,7 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
sdt->cq = cq;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
gpr_mu_unlock(&server->mu_global);
- goto done;
+ return;
}
server->last_shutdown_message_time = gpr_now(GPR_CLOCK_REALTIME);
@@ -1293,30 +1201,26 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
/* collect all unregistered then registered calls */
gpr_mu_lock(&server->mu_call);
kill_pending_work_locked(
- &exec_ctx, server,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
gpr_mu_unlock(&server->mu_call);
- maybe_finish_shutdown(&exec_ctx, server);
+ maybe_finish_shutdown(server);
gpr_mu_unlock(&server->mu_global);
/* Shutdown listeners */
for (l = server->listeners; l; l = l->next) {
GRPC_CLOSURE_INIT(&l->destroy_done, listener_destroy_done, server,
grpc_schedule_on_exec_ctx);
- l->destroy(&exec_ctx, server, l->arg, &l->destroy_done);
+ l->destroy(server, l->arg, &l->destroy_done);
}
- channel_broadcaster_shutdown(&exec_ctx, &broadcaster, true /* send_goaway */,
+ channel_broadcaster_shutdown(&broadcaster, true /* send_goaway */,
GRPC_ERROR_NONE);
-
-done:
- grpc_exec_ctx_finish(&exec_ctx);
}
-void grpc_server_cancel_all_calls(grpc_server *server) {
+void grpc_server_cancel_all_calls(grpc_server* server) {
channel_broadcaster broadcaster;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_cancel_all_calls(server=%p)", 1, (server));
@@ -1325,14 +1229,13 @@ void grpc_server_cancel_all_calls(grpc_server *server) {
gpr_mu_unlock(&server->mu_global);
channel_broadcaster_shutdown(
- &exec_ctx, &broadcaster, false /* send_goaway */,
+ &broadcaster, false /* send_goaway */,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls"));
- grpc_exec_ctx_finish(&exec_ctx);
}
-void grpc_server_destroy(grpc_server *server) {
- listener *l;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+void grpc_server_destroy(grpc_server* server) {
+ listener* l;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_destroy(server=%p)", 1, (server));
@@ -1348,17 +1251,16 @@ void grpc_server_destroy(grpc_server *server) {
gpr_mu_unlock(&server->mu_global);
- server_unref(&exec_ctx, server);
- grpc_exec_ctx_finish(&exec_ctx);
+ server_unref(server);
}
-void grpc_server_add_listener(
- grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- void (*start)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- grpc_pollset **pollsets, size_t pollset_count),
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- grpc_closure *on_done)) {
- listener *l = (listener *)gpr_malloc(sizeof(listener));
+void grpc_server_add_listener(grpc_server* server, void* arg,
+ void (*start)(grpc_server* server, void* arg,
+ grpc_pollset** pollsets,
+ size_t pollset_count),
+ void (*destroy)(grpc_server* server, void* arg,
+ grpc_closure* on_done)) {
+ listener* l = (listener*)gpr_malloc(sizeof(listener));
l->arg = arg;
l->start = start;
l->destroy = destroy;
@@ -1366,26 +1268,15 @@ void grpc_server_add_listener(
server->listeners = l;
}
-static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
- grpc_server *server, size_t cq_idx,
- requested_call *rc) {
- call_data *calld = NULL;
- request_matcher *rm = NULL;
- int request_id;
+static grpc_call_error queue_call_request(grpc_server* server, size_t cq_idx,
+ requested_call* rc) {
+ call_data* calld = nullptr;
+ request_matcher* rm = nullptr;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
- fail_call(exec_ctx, server, cq_idx, rc,
+ fail_call(server, cq_idx, rc,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
return GRPC_CALL_OK;
}
- request_id = gpr_stack_lockfree_pop(server->request_freelist_per_cq[cq_idx]);
- if (request_id == -1) {
- /* out of request ids: just fail this one */
- fail_call(exec_ctx, server, cq_idx, rc,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Out of request ids"),
- GRPC_ERROR_INT_LIMIT, server->max_requested_calls_per_cq));
- return GRPC_CALL_OK;
- }
switch (rc->type) {
case BATCH_CALL:
rm = &server->unregistered_request_matcher;
@@ -1394,32 +1285,24 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
rm = &rc->data.registered.method->matcher;
break;
}
- server->requested_calls_per_cq[cq_idx][request_id] = *rc;
- gpr_free(rc);
- if (gpr_stack_lockfree_push(rm->requests_per_cq[cq_idx], request_id)) {
+ if (gpr_locked_mpscq_push(&rm->requests_per_cq[cq_idx], &rc->request_link)) {
/* this was the first queued request: we need to lock and start
matching calls */
gpr_mu_lock(&server->mu_call);
- while ((calld = rm->pending_head) != NULL) {
- request_id = gpr_stack_lockfree_pop(rm->requests_per_cq[cq_idx]);
- if (request_id == -1) break;
+ while ((calld = rm->pending_head) != nullptr) {
+ rc = (requested_call*)gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]);
+ if (rc == nullptr) break;
rm->pending_head = calld->pending_next;
gpr_mu_unlock(&server->mu_call);
- gpr_mu_lock(&calld->mu_state);
- if (calld->state == ZOMBIED) {
- gpr_mu_unlock(&calld->mu_state);
+ if (!gpr_atm_full_cas(&calld->state, PENDING, ACTIVATED)) {
+ // Zombied Call
GRPC_CLOSURE_INIT(
&calld->kill_zombie_closure, kill_zombie,
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
} else {
- GPR_ASSERT(calld->state == PENDING);
- calld->state = ACTIVATED;
- gpr_mu_unlock(&calld->mu_state);
- publish_call(exec_ctx, server, calld, cq_idx,
- &server->requested_calls_per_cq[cq_idx][request_id]);
+ publish_call(server, calld, cq_idx, rc);
}
gpr_mu_lock(&server->mu_call);
}
@@ -1429,20 +1312,21 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
}
grpc_call_error grpc_server_request_call(
- grpc_server *server, grpc_call **call, grpc_call_details *details,
- grpc_metadata_array *initial_metadata,
- grpc_completion_queue *cq_bound_to_call,
- grpc_completion_queue *cq_for_notification, void *tag) {
+ grpc_server* server, grpc_call** call, grpc_call_details* details,
+ grpc_metadata_array* initial_metadata,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification, void* tag) {
grpc_call_error error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- requested_call *rc = (requested_call *)gpr_malloc(sizeof(*rc));
- GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ requested_call* rc = (requested_call*)gpr_malloc(sizeof(*rc));
+ GRPC_STATS_INC_SERVER_REQUESTED_CALLS();
GRPC_API_TRACE(
"grpc_server_request_call("
"server=%p, call=%p, details=%p, initial_metadata=%p, "
"cq_bound_to_call=%p, cq_for_notification=%p, tag=%p)",
- 7, (server, call, details, initial_metadata, cq_bound_to_call,
- cq_for_notification, tag));
+ 7,
+ (server, call, details, initial_metadata, cq_bound_to_call,
+ cq_for_notification, tag));
size_t cq_idx;
for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) {
if (server->cqs[cq_idx] == cq_for_notification) {
@@ -1459,7 +1343,7 @@ grpc_call_error grpc_server_request_call(
error = GRPC_CALL_ERROR_COMPLETION_QUEUE_SHUTDOWN;
goto done;
}
- details->reserved = NULL;
+ details->reserved = nullptr;
rc->cq_idx = cq_idx;
rc->type = BATCH_CALL;
rc->server = server;
@@ -1468,29 +1352,30 @@ grpc_call_error grpc_server_request_call(
rc->call = call;
rc->data.batch.details = details;
rc->initial_metadata = initial_metadata;
- error = queue_call_request(&exec_ctx, server, cq_idx, rc);
+ error = queue_call_request(server, cq_idx, rc);
done:
- grpc_exec_ctx_finish(&exec_ctx);
+
return error;
}
grpc_call_error grpc_server_request_registered_call(
- grpc_server *server, void *rmp, grpc_call **call, gpr_timespec *deadline,
- grpc_metadata_array *initial_metadata, grpc_byte_buffer **optional_payload,
- grpc_completion_queue *cq_bound_to_call,
- grpc_completion_queue *cq_for_notification, void *tag) {
+ grpc_server* server, void* rmp, grpc_call** call, gpr_timespec* deadline,
+ grpc_metadata_array* initial_metadata, grpc_byte_buffer** optional_payload,
+ grpc_completion_queue* cq_bound_to_call,
+ grpc_completion_queue* cq_for_notification, void* tag) {
grpc_call_error error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- requested_call *rc = (requested_call *)gpr_malloc(sizeof(*rc));
- registered_method *rm = (registered_method *)rmp;
- GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ requested_call* rc = (requested_call*)gpr_malloc(sizeof(*rc));
+ registered_method* rm = (registered_method*)rmp;
+ GRPC_STATS_INC_SERVER_REQUESTED_CALLS();
GRPC_API_TRACE(
"grpc_server_request_registered_call("
"server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, "
"optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, "
"tag=%p)",
- 9, (server, rmp, call, deadline, initial_metadata, optional_payload,
- cq_bound_to_call, cq_for_notification, tag));
+ 9,
+ (server, rmp, call, deadline, initial_metadata, optional_payload,
+ cq_bound_to_call, cq_for_notification, tag));
size_t cq_idx;
for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) {
@@ -1503,7 +1388,7 @@ grpc_call_error grpc_server_request_registered_call(
error = GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE;
goto done;
}
- if ((optional_payload == NULL) !=
+ if ((optional_payload == nullptr) !=
(rm->payload_handling == GRPC_SRM_PAYLOAD_NONE)) {
gpr_free(rc);
error = GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH;
@@ -1524,28 +1409,27 @@ grpc_call_error grpc_server_request_registered_call(
rc->data.registered.deadline = deadline;
rc->initial_metadata = initial_metadata;
rc->data.registered.optional_payload = optional_payload;
- error = queue_call_request(&exec_ctx, server, cq_idx, rc);
+ error = queue_call_request(server, cq_idx, rc);
done:
- grpc_exec_ctx_finish(&exec_ctx);
+
return error;
}
-static void fail_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
- size_t cq_idx, requested_call *rc, grpc_error *error) {
- *rc->call = NULL;
+static void fail_call(grpc_server* server, size_t cq_idx, requested_call* rc,
+ grpc_error* error) {
+ *rc->call = nullptr;
rc->initial_metadata->count = 0;
GPR_ASSERT(error != GRPC_ERROR_NONE);
- server_ref(server);
- grpc_cq_end_op(exec_ctx, server->cqs[cq_idx], rc->tag, error,
- done_request_event, rc, &rc->completion);
+ grpc_cq_end_op(server->cqs[cq_idx], rc->tag, error, done_request_event, rc,
+ &rc->completion);
}
-const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server) {
+const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server) {
return server->channel_args;
}
-int grpc_server_has_open_connections(grpc_server *server) {
+int grpc_server_has_open_connections(grpc_server* server) {
int r;
gpr_mu_lock(&server->mu_global);
r = server->root_channel_data.next != &server->root_channel_data;
diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h
index dd5639d97a..63b6dff16b 100644
--- a/src/core/lib/surface/server.h
+++ b/src/core/lib/surface/server.h
@@ -27,31 +27,30 @@
extern const grpc_channel_filter grpc_server_top_filter;
/** Lightweight tracing of server channel state */
-extern grpc_tracer_flag grpc_server_channel_trace;
+extern grpc_core::TraceFlag grpc_server_channel_trace;
/* Add a listener to the server: when the server starts, it will call start,
and when it shuts down, it will call destroy */
-void grpc_server_add_listener(
- grpc_exec_ctx *exec_ctx, grpc_server *server, void *listener,
- void (*start)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- grpc_pollset **pollsets, size_t npollsets),
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
- grpc_closure *on_done));
+void grpc_server_add_listener(grpc_server* server, void* listener,
+ void (*start)(grpc_server* server, void* arg,
+ grpc_pollset** pollsets,
+ size_t npollsets),
+ void (*destroy)(grpc_server* server, void* arg,
+ grpc_closure* on_done));
/* Setup a transport - creates a channel stack, binds the transport to the
server */
-void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *server,
- grpc_transport *transport,
- grpc_pollset *accepting_pollset,
- const grpc_channel_args *args);
+void grpc_server_setup_transport(grpc_server* server, grpc_transport* transport,
+ grpc_pollset* accepting_pollset,
+ const grpc_channel_args* args);
-const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server);
+const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server);
-int grpc_server_has_open_connections(grpc_server *server);
+int grpc_server_has_open_connections(grpc_server* server);
/* Do not call this before grpc_server_start. Returns the pollsets and the
* number of pollsets via 'pollsets' and 'pollset_count'. */
-void grpc_server_get_pollsets(grpc_server *server, grpc_pollset ***pollsets,
- size_t *pollset_count);
+void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
+ size_t* pollset_count);
#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */
diff --git a/src/core/lib/surface/validate_metadata.c b/src/core/lib/surface/validate_metadata.cc
index 61209ae48d..fc94ea7dbe 100644
--- a/src/core/lib/surface/validate_metadata.c
+++ b/src/core/lib/surface/validate_metadata.cc
@@ -26,18 +26,19 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
+#include "src/core/lib/surface/validate_metadata.h"
-static grpc_error *conforms_to(grpc_slice slice, const uint8_t *legal_bits,
- const char *err_desc) {
- const uint8_t *p = GRPC_SLICE_START_PTR(slice);
- const uint8_t *e = GRPC_SLICE_END_PTR(slice);
+static grpc_error* conforms_to(grpc_slice slice, const uint8_t* legal_bits,
+ const char* err_desc) {
+ const uint8_t* p = GRPC_SLICE_START_PTR(slice);
+ const uint8_t* e = GRPC_SLICE_END_PTR(slice);
for (; p != e; p++) {
int idx = *p;
int byte = idx / 8;
int bit = idx % 8;
if ((legal_bits[byte] & (1 << bit)) == 0) {
- char *dump = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- grpc_error *error = grpc_error_set_str(
+ char* dump = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ grpc_error* error = grpc_error_set_str(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_desc),
GRPC_ERROR_INT_OFFSET,
p - GRPC_SLICE_START_PTR(slice)),
@@ -49,13 +50,13 @@ static grpc_error *conforms_to(grpc_slice slice, const uint8_t *legal_bits,
return GRPC_ERROR_NONE;
}
-static int error2int(grpc_error *error) {
+static int error2int(grpc_error* error) {
int r = (error == GRPC_ERROR_NONE);
GRPC_ERROR_UNREF(error);
return r;
}
-grpc_error *grpc_validate_header_key_is_legal(grpc_slice slice) {
+grpc_error* grpc_validate_header_key_is_legal(grpc_slice slice) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00,
0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -75,7 +76,7 @@ int grpc_header_key_is_legal(grpc_slice slice) {
return error2int(grpc_validate_header_key_is_legal(slice));
}
-grpc_error *grpc_validate_header_nonbin_value_is_legal(grpc_slice slice) {
+grpc_error* grpc_validate_header_nonbin_value_is_legal(grpc_slice slice) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h
index de869d89b4..ff074b00b2 100644
--- a/src/core/lib/surface/validate_metadata.h
+++ b/src/core/lib/surface/validate_metadata.h
@@ -22,7 +22,7 @@
#include <grpc/slice.h>
#include "src/core/lib/iomgr/error.h"
-grpc_error *grpc_validate_header_key_is_legal(grpc_slice slice);
-grpc_error *grpc_validate_header_nonbin_value_is_legal(grpc_slice slice);
+grpc_error* grpc_validate_header_key_is_legal(grpc_slice slice);
+grpc_error* grpc_validate_header_nonbin_value_is_legal(grpc_slice slice);
#endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */
diff --git a/src/core/lib/surface/version.c b/src/core/lib/surface/version.cc
index fd6ea4daa9..19498a6df7 100644
--- a/src/core/lib/surface/version.c
+++ b/src/core/lib/surface/version.cc
@@ -21,6 +21,6 @@
#include <grpc/grpc.h>
-const char *grpc_version_string(void) { return "5.0.0-dev"; }
+const char* grpc_version_string(void) { return "5.0.0-dev"; }
-const char *grpc_g_stands_for(void) { return "gambit"; }
+const char* grpc_g_stands_for(void) { return "glamorous"; }
diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c
deleted file mode 100644
index 8b57693413..0000000000
--- a/src/core/lib/transport/bdp_estimator.c
+++ /dev/null
@@ -1,110 +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 "src/core/lib/transport/bdp_estimator.h"
-
-#include <stdlib.h>
-
-#include <grpc/support/log.h>
-#include <grpc/support/useful.h>
-
-grpc_tracer_flag grpc_bdp_estimator_trace =
- GRPC_TRACER_INITIALIZER(false, "bdp_estimator");
-
-void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) {
- estimator->estimate = 65536;
- estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED;
- estimator->name = name;
- estimator->bw_est = 0;
-}
-
-bool grpc_bdp_estimator_get_estimate(const grpc_bdp_estimator *estimator,
- int64_t *estimate) {
- *estimate = estimator->estimate;
- return true;
-}
-
-bool grpc_bdp_estimator_get_bw(const grpc_bdp_estimator *estimator,
- double *bw) {
- *bw = estimator->bw_est;
- return true;
-}
-
-void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator,
- int64_t num_bytes) {
- estimator->accumulator += num_bytes;
-}
-
-bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator) {
- switch (estimator->ping_state) {
- case GRPC_BDP_PING_UNSCHEDULED:
- return true;
- case GRPC_BDP_PING_SCHEDULED:
- return false;
- case GRPC_BDP_PING_STARTED:
- return false;
- }
- GPR_UNREACHABLE_CODE(return false);
-}
-
-void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator) {
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64,
- estimator->name, estimator->accumulator, estimator->estimate);
- }
- GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_UNSCHEDULED);
- estimator->ping_state = GRPC_BDP_PING_SCHEDULED;
- estimator->accumulator = 0;
-}
-
-void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) {
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64,
- estimator->name, estimator->accumulator, estimator->estimate);
- }
- GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_SCHEDULED);
- estimator->ping_state = GRPC_BDP_PING_STARTED;
- estimator->accumulator = 0;
- estimator->ping_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
-}
-
-void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) {
- gpr_timespec dt_ts =
- gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), estimator->ping_start_time);
- double dt = (double)dt_ts.tv_sec + 1e-9 * (double)dt_ts.tv_nsec;
- double bw = dt > 0 ? ((double)estimator->accumulator / dt) : 0;
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64
- " dt=%lf bw=%lfMbs bw_est=%lfMbs",
- estimator->name, estimator->accumulator, estimator->estimate, dt,
- bw / 125000.0, estimator->bw_est / 125000.0);
- }
- GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_STARTED);
- if (estimator->accumulator > 2 * estimator->estimate / 3 &&
- bw > estimator->bw_est) {
- estimator->estimate =
- GPR_MAX(estimator->accumulator, estimator->estimate * 2);
- estimator->bw_est = bw;
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
- gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64,
- estimator->name, estimator->estimate);
- }
- }
- estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED;
- estimator->accumulator = 0;
-}
diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc
new file mode 100644
index 0000000000..5fcc62ec43
--- /dev/null
+++ b/src/core/lib/transport/bdp_estimator.cc
@@ -0,0 +1,84 @@
+/*
+ *
+ * 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 "src/core/lib/transport/bdp_estimator.h"
+
+#include <inttypes.h>
+#include <stdlib.h>
+
+#include <grpc/support/useful.h>
+
+grpc_core::TraceFlag grpc_bdp_estimator_trace(false, "bdp_estimator");
+
+namespace grpc_core {
+
+BdpEstimator::BdpEstimator(const char* name)
+ : ping_state_(PingState::UNSCHEDULED),
+ accumulator_(0),
+ estimate_(65536),
+ ping_start_time_(gpr_time_0(GPR_CLOCK_MONOTONIC)),
+ inter_ping_delay_(100.0), // start at 100ms
+ stable_estimate_count_(0),
+ bw_est_(0),
+ name_(name) {}
+
+grpc_millis BdpEstimator::CompletePing() {
+ gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
+ gpr_timespec dt_ts = gpr_time_sub(now, ping_start_time_);
+ double dt = (double)dt_ts.tv_sec + 1e-9 * (double)dt_ts.tv_nsec;
+ double bw = dt > 0 ? ((double)accumulator_ / dt) : 0;
+ int start_inter_ping_delay = inter_ping_delay_;
+ if (grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG,
+ "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64
+ " dt=%lf bw=%lfMbs bw_est=%lfMbs",
+ name_, accumulator_, estimate_, dt, bw / 125000.0,
+ bw_est_ / 125000.0);
+ }
+ GPR_ASSERT(ping_state_ == PingState::STARTED);
+ if (accumulator_ > 2 * estimate_ / 3 && bw > bw_est_) {
+ estimate_ = GPR_MAX(accumulator_, estimate_ * 2);
+ bw_est_ = bw;
+ if (grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64, name_,
+ estimate_);
+ }
+ inter_ping_delay_ /= 2; // if the ping estimate changes,
+ // exponentially get faster at probing
+ } else if (inter_ping_delay_ < 10000) {
+ stable_estimate_count_++;
+ if (stable_estimate_count_ >= 2) {
+ inter_ping_delay_ +=
+ 100 +
+ (int)(rand() * 100.0 / RAND_MAX); // if the ping estimate is steady,
+ // slowly ramp down the probe time
+ }
+ }
+ if (start_inter_ping_delay != inter_ping_delay_) {
+ stable_estimate_count_ = 0;
+ if (grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "bdp[%s]:update_inter_time to %dms", name_,
+ inter_ping_delay_);
+ }
+ }
+ ping_state_ = PingState::UNSCHEDULED;
+ accumulator_ = 0;
+ return grpc_core::ExecCtx::Get()->Now() + inter_ping_delay_;
+}
+
+} // namespace grpc_core
diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h
index 1ef0dc99dd..e703af121c 100644
--- a/src/core/lib/transport/bdp_estimator.h
+++ b/src/core/lib/transport/bdp_estimator.h
@@ -19,51 +19,76 @@
#ifndef GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H
#define GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H
-#include <grpc/support/time.h>
+#include <grpc/support/port_platform.h>
+
+#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
+
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+
+extern grpc_core::TraceFlag grpc_bdp_estimator_trace;
+
+namespace grpc_core {
+
+class BdpEstimator {
+ public:
+ explicit BdpEstimator(const char* name);
+ ~BdpEstimator() {}
+
+ int64_t EstimateBdp() const { return estimate_; }
+ double EstimateBandwidth() const { return bw_est_; }
+
+ void AddIncomingBytes(int64_t num_bytes) { accumulator_ += num_bytes; }
+
+ // Schedule a ping: call in response to receiving a true from
+ // grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a
+ // transport (but not necessarily started)
+ void SchedulePing() {
+ if (grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_,
+ accumulator_, estimate_);
+ }
+ GPR_ASSERT(ping_state_ == PingState::UNSCHEDULED);
+ ping_state_ = PingState::SCHEDULED;
+ accumulator_ = 0;
+ }
+
+ // Start a ping: call after calling grpc_bdp_estimator_schedule_ping and
+ // once
+ // the ping is on the wire
+ void StartPing() {
+ if (grpc_bdp_estimator_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_,
+ accumulator_, estimate_);
+ }
+ GPR_ASSERT(ping_state_ == PingState::SCHEDULED);
+ ping_state_ = PingState::STARTED;
+ accumulator_ = 0;
+ ping_start_time_ = gpr_now(GPR_CLOCK_MONOTONIC);
+ }
+
+ // Completes a previously started ping, returns when to schedule the next one
+ grpc_millis CompletePing();
+
+ private:
+ enum class PingState { UNSCHEDULED, SCHEDULED, STARTED };
+
+ PingState ping_state_;
+ int64_t accumulator_;
+ int64_t estimate_;
+ // when was the current ping started?
+ gpr_timespec ping_start_time_;
+ int inter_ping_delay_;
+ int stable_estimate_count_;
+ double bw_est_;
+ const char* name_;
+};
-#define GRPC_BDP_SAMPLES 16
-#define GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE 3
-
-extern grpc_tracer_flag grpc_bdp_estimator_trace;
-
-typedef enum {
- GRPC_BDP_PING_UNSCHEDULED,
- GRPC_BDP_PING_SCHEDULED,
- GRPC_BDP_PING_STARTED
-} grpc_bdp_estimator_ping_state;
-
-typedef struct grpc_bdp_estimator {
- grpc_bdp_estimator_ping_state ping_state;
- int64_t accumulator;
- int64_t estimate;
- gpr_timespec ping_start_time;
- double bw_est;
- const char *name;
-} grpc_bdp_estimator;
-
-void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name);
-
-// Returns true if a reasonable estimate could be obtained
-bool grpc_bdp_estimator_get_estimate(const grpc_bdp_estimator *estimator,
- int64_t *estimate);
-// Tracks new bytes read.
-bool grpc_bdp_estimator_get_bw(const grpc_bdp_estimator *estimator, double *bw);
-// Returns true if the user should schedule a ping
-void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator,
- int64_t num_bytes);
-// Returns true if the user should schedule a ping
-bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator);
-// Schedule a ping: call in response to receiving a true from
-// grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a
-// transport (but not necessarily started)
-void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator);
-// Start a ping: call after calling grpc_bdp_estimator_schedule_ping and once
-// the ping is on the wire
-void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator);
-// Completes a previously started ping
-void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator);
+} // namespace grpc_core
#endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */
diff --git a/src/core/lib/transport/byte_stream.c b/src/core/lib/transport/byte_stream.c
deleted file mode 100644
index 08f61629a9..0000000000
--- a/src/core/lib/transport/byte_stream.c
+++ /dev/null
@@ -1,187 +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/transport/byte_stream.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <grpc/support/log.h>
-
-#include "src/core/lib/slice/slice_internal.h"
-
-bool grpc_byte_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream, size_t max_size_hint,
- grpc_closure *on_complete) {
- return byte_stream->vtable->next(exec_ctx, byte_stream, max_size_hint,
- on_complete);
-}
-
-grpc_error *grpc_byte_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_slice *slice) {
- return byte_stream->vtable->pull(exec_ctx, byte_stream, slice);
-}
-
-void grpc_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_error *error) {
- byte_stream->vtable->shutdown(exec_ctx, byte_stream, error);
-}
-
-void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream) {
- byte_stream->vtable->destroy(exec_ctx, byte_stream);
-}
-
-// grpc_slice_buffer_stream
-
-static bool slice_buffer_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- size_t max_size_hint,
- grpc_closure *on_complete) {
- grpc_slice_buffer_stream *stream = (grpc_slice_buffer_stream *)byte_stream;
- GPR_ASSERT(stream->cursor < stream->backing_buffer->count);
- return true;
-}
-
-static grpc_error *slice_buffer_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_slice *slice) {
- grpc_slice_buffer_stream *stream = (grpc_slice_buffer_stream *)byte_stream;
- if (stream->shutdown_error != GRPC_ERROR_NONE) {
- return GRPC_ERROR_REF(stream->shutdown_error);
- }
- GPR_ASSERT(stream->cursor < stream->backing_buffer->count);
- *slice =
- grpc_slice_ref_internal(stream->backing_buffer->slices[stream->cursor]);
- stream->cursor++;
- return GRPC_ERROR_NONE;
-}
-
-static void slice_buffer_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_error *error) {
- grpc_slice_buffer_stream *stream = (grpc_slice_buffer_stream *)byte_stream;
- GRPC_ERROR_UNREF(stream->shutdown_error);
- stream->shutdown_error = error;
-}
-
-static void slice_buffer_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream) {
- grpc_slice_buffer_stream *stream = (grpc_slice_buffer_stream *)byte_stream;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, stream->backing_buffer);
- GRPC_ERROR_UNREF(stream->shutdown_error);
-}
-
-static const grpc_byte_stream_vtable slice_buffer_stream_vtable = {
- slice_buffer_stream_next, slice_buffer_stream_pull,
- slice_buffer_stream_shutdown, slice_buffer_stream_destroy};
-
-void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream,
- grpc_slice_buffer *slice_buffer,
- uint32_t flags) {
- GPR_ASSERT(slice_buffer->length <= UINT32_MAX);
- stream->base.length = (uint32_t)slice_buffer->length;
- stream->base.flags = flags;
- stream->base.vtable = &slice_buffer_stream_vtable;
- stream->backing_buffer = slice_buffer;
- stream->cursor = 0;
- stream->shutdown_error = GRPC_ERROR_NONE;
-}
-
-// grpc_caching_byte_stream
-
-void grpc_byte_stream_cache_init(grpc_byte_stream_cache *cache,
- grpc_byte_stream *underlying_stream) {
- cache->underlying_stream = underlying_stream;
- grpc_slice_buffer_init(&cache->cache_buffer);
-}
-
-void grpc_byte_stream_cache_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream_cache *cache) {
- grpc_byte_stream_destroy(exec_ctx, cache->underlying_stream);
- grpc_slice_buffer_destroy_internal(exec_ctx, &cache->cache_buffer);
-}
-
-static bool caching_byte_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- size_t max_size_hint,
- grpc_closure *on_complete) {
- grpc_caching_byte_stream *stream = (grpc_caching_byte_stream *)byte_stream;
- if (stream->shutdown_error != GRPC_ERROR_NONE) return true;
- if (stream->cursor < stream->cache->cache_buffer.count) return true;
- return grpc_byte_stream_next(exec_ctx, stream->cache->underlying_stream,
- max_size_hint, on_complete);
-}
-
-static grpc_error *caching_byte_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_slice *slice) {
- grpc_caching_byte_stream *stream = (grpc_caching_byte_stream *)byte_stream;
- if (stream->shutdown_error != GRPC_ERROR_NONE) {
- return GRPC_ERROR_REF(stream->shutdown_error);
- }
- if (stream->cursor < stream->cache->cache_buffer.count) {
- *slice = grpc_slice_ref_internal(
- stream->cache->cache_buffer.slices[stream->cursor]);
- ++stream->cursor;
- return GRPC_ERROR_NONE;
- }
- grpc_error *error =
- grpc_byte_stream_pull(exec_ctx, stream->cache->underlying_stream, slice);
- if (error == GRPC_ERROR_NONE) {
- ++stream->cursor;
- grpc_slice_buffer_add(&stream->cache->cache_buffer,
- grpc_slice_ref_internal(*slice));
- }
- return error;
-}
-
-static void caching_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_error *error) {
- grpc_caching_byte_stream *stream = (grpc_caching_byte_stream *)byte_stream;
- GRPC_ERROR_UNREF(stream->shutdown_error);
- stream->shutdown_error = GRPC_ERROR_REF(error);
- grpc_byte_stream_shutdown(exec_ctx, stream->cache->underlying_stream, error);
-}
-
-static void caching_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream) {
- grpc_caching_byte_stream *stream = (grpc_caching_byte_stream *)byte_stream;
- GRPC_ERROR_UNREF(stream->shutdown_error);
-}
-
-static const grpc_byte_stream_vtable caching_byte_stream_vtable = {
- caching_byte_stream_next, caching_byte_stream_pull,
- caching_byte_stream_shutdown, caching_byte_stream_destroy};
-
-void grpc_caching_byte_stream_init(grpc_caching_byte_stream *stream,
- grpc_byte_stream_cache *cache) {
- memset(stream, 0, sizeof(*stream));
- stream->base.length = cache->underlying_stream->length;
- stream->base.flags = cache->underlying_stream->flags;
- stream->base.vtable = &caching_byte_stream_vtable;
- stream->cache = cache;
- stream->shutdown_error = GRPC_ERROR_NONE;
-}
-
-void grpc_caching_byte_stream_reset(grpc_caching_byte_stream *stream) {
- stream->cursor = 0;
-}
diff --git a/src/core/lib/transport/byte_stream.cc b/src/core/lib/transport/byte_stream.cc
new file mode 100644
index 0000000000..8dcb1e0bdb
--- /dev/null
+++ b/src/core/lib/transport/byte_stream.cc
@@ -0,0 +1,173 @@
+/*
+ *
+ * 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/transport/byte_stream.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <grpc/support/log.h>
+
+#include "src/core/lib/slice/slice_internal.h"
+
+bool grpc_byte_stream_next(grpc_byte_stream* byte_stream, size_t max_size_hint,
+ grpc_closure* on_complete) {
+ return byte_stream->vtable->next(byte_stream, max_size_hint, on_complete);
+}
+
+grpc_error* grpc_byte_stream_pull(grpc_byte_stream* byte_stream,
+ grpc_slice* slice) {
+ return byte_stream->vtable->pull(byte_stream, slice);
+}
+
+void grpc_byte_stream_shutdown(grpc_byte_stream* byte_stream,
+ grpc_error* error) {
+ byte_stream->vtable->shutdown(byte_stream, error);
+}
+
+void grpc_byte_stream_destroy(grpc_byte_stream* byte_stream) {
+ byte_stream->vtable->destroy(byte_stream);
+}
+
+// grpc_slice_buffer_stream
+
+static bool slice_buffer_stream_next(grpc_byte_stream* byte_stream,
+ size_t max_size_hint,
+ grpc_closure* on_complete) {
+ grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
+ GPR_ASSERT(stream->cursor < stream->backing_buffer->count);
+ return true;
+}
+
+static grpc_error* slice_buffer_stream_pull(grpc_byte_stream* byte_stream,
+ grpc_slice* slice) {
+ grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
+ if (stream->shutdown_error != GRPC_ERROR_NONE) {
+ return GRPC_ERROR_REF(stream->shutdown_error);
+ }
+ GPR_ASSERT(stream->cursor < stream->backing_buffer->count);
+ *slice =
+ grpc_slice_ref_internal(stream->backing_buffer->slices[stream->cursor]);
+ stream->cursor++;
+ return GRPC_ERROR_NONE;
+}
+
+static void slice_buffer_stream_shutdown(grpc_byte_stream* byte_stream,
+ grpc_error* error) {
+ grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
+ GRPC_ERROR_UNREF(stream->shutdown_error);
+ stream->shutdown_error = error;
+}
+
+static void slice_buffer_stream_destroy(grpc_byte_stream* byte_stream) {
+ grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
+ grpc_slice_buffer_reset_and_unref_internal(stream->backing_buffer);
+ GRPC_ERROR_UNREF(stream->shutdown_error);
+}
+
+static const grpc_byte_stream_vtable slice_buffer_stream_vtable = {
+ slice_buffer_stream_next, slice_buffer_stream_pull,
+ slice_buffer_stream_shutdown, slice_buffer_stream_destroy};
+
+void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream* stream,
+ grpc_slice_buffer* slice_buffer,
+ uint32_t flags) {
+ GPR_ASSERT(slice_buffer->length <= UINT32_MAX);
+ stream->base.length = (uint32_t)slice_buffer->length;
+ stream->base.flags = flags;
+ stream->base.vtable = &slice_buffer_stream_vtable;
+ stream->backing_buffer = slice_buffer;
+ stream->cursor = 0;
+ stream->shutdown_error = GRPC_ERROR_NONE;
+}
+
+// grpc_caching_byte_stream
+
+void grpc_byte_stream_cache_init(grpc_byte_stream_cache* cache,
+ grpc_byte_stream* underlying_stream) {
+ cache->underlying_stream = underlying_stream;
+ grpc_slice_buffer_init(&cache->cache_buffer);
+}
+
+void grpc_byte_stream_cache_destroy(grpc_byte_stream_cache* cache) {
+ grpc_byte_stream_destroy(cache->underlying_stream);
+ grpc_slice_buffer_destroy_internal(&cache->cache_buffer);
+}
+
+static bool caching_byte_stream_next(grpc_byte_stream* byte_stream,
+ size_t max_size_hint,
+ grpc_closure* on_complete) {
+ grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
+ if (stream->shutdown_error != GRPC_ERROR_NONE) return true;
+ if (stream->cursor < stream->cache->cache_buffer.count) return true;
+ return grpc_byte_stream_next(stream->cache->underlying_stream, max_size_hint,
+ on_complete);
+}
+
+static grpc_error* caching_byte_stream_pull(grpc_byte_stream* byte_stream,
+ grpc_slice* slice) {
+ grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
+ if (stream->shutdown_error != GRPC_ERROR_NONE) {
+ return GRPC_ERROR_REF(stream->shutdown_error);
+ }
+ if (stream->cursor < stream->cache->cache_buffer.count) {
+ *slice = grpc_slice_ref_internal(
+ stream->cache->cache_buffer.slices[stream->cursor]);
+ ++stream->cursor;
+ return GRPC_ERROR_NONE;
+ }
+ grpc_error* error =
+ grpc_byte_stream_pull(stream->cache->underlying_stream, slice);
+ if (error == GRPC_ERROR_NONE) {
+ ++stream->cursor;
+ grpc_slice_buffer_add(&stream->cache->cache_buffer,
+ grpc_slice_ref_internal(*slice));
+ }
+ return error;
+}
+
+static void caching_byte_stream_shutdown(grpc_byte_stream* byte_stream,
+ grpc_error* error) {
+ grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
+ GRPC_ERROR_UNREF(stream->shutdown_error);
+ stream->shutdown_error = GRPC_ERROR_REF(error);
+ grpc_byte_stream_shutdown(stream->cache->underlying_stream, error);
+}
+
+static void caching_byte_stream_destroy(grpc_byte_stream* byte_stream) {
+ grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
+ GRPC_ERROR_UNREF(stream->shutdown_error);
+}
+
+static const grpc_byte_stream_vtable caching_byte_stream_vtable = {
+ caching_byte_stream_next, caching_byte_stream_pull,
+ caching_byte_stream_shutdown, caching_byte_stream_destroy};
+
+void grpc_caching_byte_stream_init(grpc_caching_byte_stream* stream,
+ grpc_byte_stream_cache* cache) {
+ memset(stream, 0, sizeof(*stream));
+ stream->base.length = cache->underlying_stream->length;
+ stream->base.flags = cache->underlying_stream->flags;
+ stream->base.vtable = &caching_byte_stream_vtable;
+ stream->cache = cache;
+ stream->shutdown_error = GRPC_ERROR_NONE;
+}
+
+void grpc_caching_byte_stream_reset(grpc_caching_byte_stream* stream) {
+ stream->cursor = 0;
+}
diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h
index be2a35213e..52c7a07f56 100644
--- a/src/core/lib/transport/byte_stream.h
+++ b/src/core/lib/transport/byte_stream.h
@@ -31,19 +31,17 @@
typedef struct grpc_byte_stream grpc_byte_stream;
typedef struct {
- bool (*next)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream,
- size_t max_size_hint, grpc_closure *on_complete);
- grpc_error *(*pull)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream,
- grpc_slice *slice);
- void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream,
- grpc_error *error);
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream);
+ bool (*next)(grpc_byte_stream* byte_stream, size_t max_size_hint,
+ grpc_closure* on_complete);
+ grpc_error* (*pull)(grpc_byte_stream* byte_stream, grpc_slice* slice);
+ void (*shutdown)(grpc_byte_stream* byte_stream, grpc_error* error);
+ void (*destroy)(grpc_byte_stream* byte_stream);
} grpc_byte_stream_vtable;
struct grpc_byte_stream {
uint32_t length;
uint32_t flags;
- const grpc_byte_stream_vtable *vtable;
+ const grpc_byte_stream_vtable* vtable;
};
// Returns true if the bytes are available immediately (in which case
@@ -52,18 +50,16 @@ struct grpc_byte_stream {
//
// max_size_hint can be set as a hint as to the maximum number
// of bytes that would be acceptable to read.
-bool grpc_byte_stream_next(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream, size_t max_size_hint,
- grpc_closure *on_complete);
+bool grpc_byte_stream_next(grpc_byte_stream* byte_stream, size_t max_size_hint,
+ grpc_closure* on_complete);
// Returns the next slice in the byte stream when it is ready (indicated by
// either grpc_byte_stream_next returning true or on_complete passed to
// grpc_byte_stream_next is called).
//
// Once a slice is returned into *slice, it is owned by the caller.
-grpc_error *grpc_byte_stream_pull(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_slice *slice);
+grpc_error* grpc_byte_stream_pull(grpc_byte_stream* byte_stream,
+ grpc_slice* slice);
// Shuts down the byte stream.
//
@@ -72,12 +68,10 @@ grpc_error *grpc_byte_stream_pull(grpc_exec_ctx *exec_ctx,
//
// The next call to grpc_byte_stream_pull() (if any) will return the error
// passed to grpc_byte_stream_shutdown().
-void grpc_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream,
- grpc_error *error);
+void grpc_byte_stream_shutdown(grpc_byte_stream* byte_stream,
+ grpc_error* error);
-void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream *byte_stream);
+void grpc_byte_stream_destroy(grpc_byte_stream* byte_stream);
// grpc_slice_buffer_stream
//
@@ -87,13 +81,13 @@ void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
typedef struct grpc_slice_buffer_stream {
grpc_byte_stream base;
- grpc_slice_buffer *backing_buffer;
+ grpc_slice_buffer* backing_buffer;
size_t cursor;
- grpc_error *shutdown_error;
+ grpc_error* shutdown_error;
} grpc_slice_buffer_stream;
-void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream,
- grpc_slice_buffer *slice_buffer,
+void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream* stream,
+ grpc_slice_buffer* slice_buffer,
uint32_t flags);
// grpc_caching_byte_stream
@@ -110,29 +104,28 @@ void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream,
// grpc_byte_stream_cache at the same time.
typedef struct {
- grpc_byte_stream *underlying_stream;
+ grpc_byte_stream* underlying_stream;
grpc_slice_buffer cache_buffer;
} grpc_byte_stream_cache;
// Takes ownership of underlying_stream.
-void grpc_byte_stream_cache_init(grpc_byte_stream_cache *cache,
- grpc_byte_stream *underlying_stream);
+void grpc_byte_stream_cache_init(grpc_byte_stream_cache* cache,
+ grpc_byte_stream* underlying_stream);
// Must not be called while still in use by a grpc_caching_byte_stream.
-void grpc_byte_stream_cache_destroy(grpc_exec_ctx *exec_ctx,
- grpc_byte_stream_cache *cache);
+void grpc_byte_stream_cache_destroy(grpc_byte_stream_cache* cache);
typedef struct {
grpc_byte_stream base;
- grpc_byte_stream_cache *cache;
+ grpc_byte_stream_cache* cache;
size_t cursor;
- grpc_error *shutdown_error;
+ grpc_error* shutdown_error;
} grpc_caching_byte_stream;
-void grpc_caching_byte_stream_init(grpc_caching_byte_stream *stream,
- grpc_byte_stream_cache *cache);
+void grpc_caching_byte_stream_init(grpc_caching_byte_stream* stream,
+ grpc_byte_stream_cache* cache);
// Resets the byte stream to the start of the underlying stream.
-void grpc_caching_byte_stream_reset(grpc_caching_byte_stream *stream);
+void grpc_caching_byte_stream_reset(grpc_caching_byte_stream* stream);
#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */
diff --git a/src/core/lib/transport/connectivity_state.c b/src/core/lib/transport/connectivity_state.cc
index f328a6cdbb..c42cc9c8d0 100644
--- a/src/core/lib/transport/connectivity_state.c
+++ b/src/core/lib/transport/connectivity_state.cc
@@ -24,13 +24,10 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-grpc_tracer_flag grpc_connectivity_state_trace =
- GRPC_TRACER_INITIALIZER(false, "connectivity_state");
+grpc_core::TraceFlag grpc_connectivity_state_trace(false, "connectivity_state");
-const char *grpc_connectivity_state_name(grpc_connectivity_state state) {
+const char* grpc_connectivity_state_name(grpc_connectivity_state state) {
switch (state) {
- case GRPC_CHANNEL_INIT:
- return "INIT";
case GRPC_CHANNEL_IDLE:
return "IDLE";
case GRPC_CHANNEL_CONNECTING:
@@ -45,19 +42,18 @@ const char *grpc_connectivity_state_name(grpc_connectivity_state state) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker,
+void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state init_state,
- const char *name) {
+ const char* name) {
gpr_atm_no_barrier_store(&tracker->current_state_atm, init_state);
tracker->current_error = GRPC_ERROR_NONE;
- tracker->watchers = NULL;
+ tracker->watchers = nullptr;
tracker->name = gpr_strdup(name);
}
-void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
- grpc_connectivity_state_tracker *tracker) {
- grpc_error *error;
- grpc_connectivity_state_watcher *w;
+void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker* tracker) {
+ grpc_error* error;
+ grpc_connectivity_state_watcher* w;
while ((w = tracker->watchers)) {
tracker->watchers = w->next;
@@ -68,7 +64,7 @@ void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutdown connectivity owner");
}
- GRPC_CLOSURE_SCHED(exec_ctx, w->notify, error);
+ GRPC_CLOSURE_SCHED(w->notify, error);
gpr_free(w);
}
GRPC_ERROR_UNREF(tracker->current_error);
@@ -76,11 +72,11 @@ void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
}
grpc_connectivity_state grpc_connectivity_state_check(
- grpc_connectivity_state_tracker *tracker) {
+ grpc_connectivity_state_tracker* tracker) {
grpc_connectivity_state cur =
(grpc_connectivity_state)gpr_atm_no_barrier_load(
&tracker->current_state_atm);
- if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
+ if (grpc_connectivity_state_trace.enabled()) {
gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name,
grpc_connectivity_state_name(cur));
}
@@ -88,33 +84,33 @@ grpc_connectivity_state grpc_connectivity_state_check(
}
grpc_connectivity_state grpc_connectivity_state_get(
- grpc_connectivity_state_tracker *tracker, grpc_error **error) {
+ grpc_connectivity_state_tracker* tracker, grpc_error** error) {
grpc_connectivity_state cur =
(grpc_connectivity_state)gpr_atm_no_barrier_load(
&tracker->current_state_atm);
- if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
+ if (grpc_connectivity_state_trace.enabled()) {
gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name,
grpc_connectivity_state_name(cur));
}
- if (error != NULL) {
+ if (error != nullptr) {
*error = GRPC_ERROR_REF(tracker->current_error);
}
return cur;
}
bool grpc_connectivity_state_has_watchers(
- grpc_connectivity_state_tracker *connectivity_state) {
- return connectivity_state->watchers != NULL;
+ grpc_connectivity_state_tracker* connectivity_state) {
+ return connectivity_state->watchers != nullptr;
}
bool grpc_connectivity_state_notify_on_state_change(
- grpc_exec_ctx *exec_ctx, grpc_connectivity_state_tracker *tracker,
- grpc_connectivity_state *current, grpc_closure *notify) {
+ grpc_connectivity_state_tracker* tracker, grpc_connectivity_state* current,
+ grpc_closure* notify) {
grpc_connectivity_state cur =
(grpc_connectivity_state)gpr_atm_no_barrier_load(
&tracker->current_state_atm);
- if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
- if (current == NULL) {
+ if (grpc_connectivity_state_trace.enabled()) {
+ if (current == nullptr) {
gpr_log(GPR_DEBUG, "CONWATCH: %p %s: unsubscribe notify=%p", tracker,
tracker->name, notify);
} else {
@@ -123,18 +119,18 @@ bool grpc_connectivity_state_notify_on_state_change(
grpc_connectivity_state_name(cur), notify);
}
}
- if (current == NULL) {
- grpc_connectivity_state_watcher *w = tracker->watchers;
- if (w != NULL && w->notify == notify) {
- GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
+ if (current == nullptr) {
+ grpc_connectivity_state_watcher* w = tracker->watchers;
+ if (w != nullptr && w->notify == notify) {
+ GRPC_CLOSURE_SCHED(notify, GRPC_ERROR_CANCELLED);
tracker->watchers = w->next;
gpr_free(w);
return false;
}
- while (w != NULL) {
- grpc_connectivity_state_watcher *rm_candidate = w->next;
- if (rm_candidate != NULL && rm_candidate->notify == notify) {
- GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
+ while (w != nullptr) {
+ grpc_connectivity_state_watcher* rm_candidate = w->next;
+ if (rm_candidate != nullptr && rm_candidate->notify == notify) {
+ GRPC_CLOSURE_SCHED(notify, GRPC_ERROR_CANCELLED);
w->next = w->next->next;
gpr_free(rm_candidate);
return false;
@@ -145,11 +141,10 @@ bool grpc_connectivity_state_notify_on_state_change(
} else {
if (cur != *current) {
*current = cur;
- GRPC_CLOSURE_SCHED(exec_ctx, notify,
- GRPC_ERROR_REF(tracker->current_error));
+ GRPC_CLOSURE_SCHED(notify, GRPC_ERROR_REF(tracker->current_error));
} else {
- grpc_connectivity_state_watcher *w =
- (grpc_connectivity_state_watcher *)gpr_malloc(sizeof(*w));
+ grpc_connectivity_state_watcher* w =
+ (grpc_connectivity_state_watcher*)gpr_malloc(sizeof(*w));
w->current = current;
w->notify = notify;
w->next = tracker->watchers;
@@ -159,22 +154,20 @@ bool grpc_connectivity_state_notify_on_state_change(
}
}
-void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx,
- grpc_connectivity_state_tracker *tracker,
+void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state state,
- grpc_error *error, const char *reason) {
+ grpc_error* error, const char* reason) {
grpc_connectivity_state cur =
(grpc_connectivity_state)gpr_atm_no_barrier_load(
&tracker->current_state_atm);
- grpc_connectivity_state_watcher *w;
- if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
- const char *error_string = grpc_error_string(error);
+ grpc_connectivity_state_watcher* w;
+ if (grpc_connectivity_state_trace.enabled()) {
+ const char* error_string = grpc_error_string(error);
gpr_log(GPR_DEBUG, "SET: %p %s: %s --> %s [%s] error=%p %s", tracker,
tracker->name, grpc_connectivity_state_name(cur),
grpc_connectivity_state_name(state), reason, error, error_string);
}
switch (state) {
- case GRPC_CHANNEL_INIT:
case GRPC_CHANNEL_CONNECTING:
case GRPC_CHANNEL_IDLE:
case GRPC_CHANNEL_READY:
@@ -192,15 +185,14 @@ void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx,
}
GPR_ASSERT(cur != GRPC_CHANNEL_SHUTDOWN);
gpr_atm_no_barrier_store(&tracker->current_state_atm, state);
- while ((w = tracker->watchers) != NULL) {
+ while ((w = tracker->watchers) != nullptr) {
*w->current = state;
tracker->watchers = w->next;
- if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) {
+ if (grpc_connectivity_state_trace.enabled()) {
gpr_log(GPR_DEBUG, "NOTIFY: %p %s: %p", tracker, tracker->name,
w->notify);
}
- GRPC_CLOSURE_SCHED(exec_ctx, w->notify,
- GRPC_ERROR_REF(tracker->current_error));
+ GRPC_CLOSURE_SCHED(w->notify, GRPC_ERROR_REF(tracker->current_error));
gpr_free(w);
}
}
diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h
index 2fece6cc21..c3a50f3211 100644
--- a/src/core/lib/transport/connectivity_state.h
+++ b/src/core/lib/transport/connectivity_state.h
@@ -25,63 +25,61 @@
typedef struct grpc_connectivity_state_watcher {
/** we keep watchers in a linked list */
- struct grpc_connectivity_state_watcher *next;
+ struct grpc_connectivity_state_watcher* next;
/** closure to notify on change */
- grpc_closure *notify;
+ grpc_closure* notify;
/** the current state as believed by the watcher */
- grpc_connectivity_state *current;
+ grpc_connectivity_state* current;
} grpc_connectivity_state_watcher;
typedef struct {
/** current grpc_connectivity_state */
gpr_atm current_state_atm;
/** error associated with state */
- grpc_error *current_error;
+ grpc_error* current_error;
/** all our watchers */
- grpc_connectivity_state_watcher *watchers;
+ grpc_connectivity_state_watcher* watchers;
/** a name to help debugging */
- char *name;
+ char* name;
} grpc_connectivity_state_tracker;
-extern grpc_tracer_flag grpc_connectivity_state_trace;
+extern grpc_core::TraceFlag grpc_connectivity_state_trace;
/** enum --> string conversion */
-const char *grpc_connectivity_state_name(grpc_connectivity_state state);
+const char* grpc_connectivity_state_name(grpc_connectivity_state state);
-void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker,
+void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state init_state,
- const char *name);
-void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
- grpc_connectivity_state_tracker *tracker);
+ const char* name);
+void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker* tracker);
/** Set connectivity state; not thread safe; access must be serialized with an
* external lock */
-void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx,
- grpc_connectivity_state_tracker *tracker,
+void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state state,
- grpc_error *associated_error,
- const char *reason);
+ grpc_error* associated_error,
+ const char* reason);
/** Return true if this connectivity state has watchers.
Access must be serialized with an external lock. */
bool grpc_connectivity_state_has_watchers(
- grpc_connectivity_state_tracker *tracker);
+ grpc_connectivity_state_tracker* tracker);
/** Return the last seen connectivity state. No need to synchronize access. */
grpc_connectivity_state grpc_connectivity_state_check(
- grpc_connectivity_state_tracker *tracker);
+ grpc_connectivity_state_tracker* tracker);
/** Return the last seen connectivity state, and the associated error.
Access must be serialized with an external lock. */
grpc_connectivity_state grpc_connectivity_state_get(
- grpc_connectivity_state_tracker *tracker, grpc_error **error);
+ grpc_connectivity_state_tracker* tracker, grpc_error** error);
/** Return 1 if the channel should start connecting, 0 otherwise.
If current==NULL cancel notify if it is already queued (success==0 in that
case).
Access must be serialized with an external lock. */
bool grpc_connectivity_state_notify_on_state_change(
- grpc_exec_ctx *exec_ctx, grpc_connectivity_state_tracker *tracker,
- grpc_connectivity_state *current, grpc_closure *notify);
+ grpc_connectivity_state_tracker* tracker, grpc_connectivity_state* current,
+ grpc_closure* notify);
#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */
diff --git a/src/core/lib/transport/error_utils.c b/src/core/lib/transport/error_utils.cc
index 5e3920b627..891576f4ba 100644
--- a/src/core/lib/transport/error_utils.c
+++ b/src/core/lib/transport/error_utils.cc
@@ -18,35 +18,37 @@
#include "src/core/lib/transport/error_utils.h"
+#include <grpc/support/string_util.h>
#include "src/core/lib/iomgr/error_internal.h"
#include "src/core/lib/transport/status_conversion.h"
-static grpc_error *recursively_find_error_with_field(grpc_error *error,
+static grpc_error* recursively_find_error_with_field(grpc_error* error,
grpc_error_ints which) {
// If the error itself has a status code, return it.
- if (grpc_error_get_int(error, which, NULL)) {
+ if (grpc_error_get_int(error, which, nullptr)) {
return error;
}
- if (grpc_error_is_special(error)) return NULL;
+ if (grpc_error_is_special(error)) return nullptr;
// Otherwise, search through its children.
uint8_t slot = error->first_err;
while (slot != UINT8_MAX) {
- grpc_linked_error *lerr = (grpc_linked_error *)(error->arena + slot);
- grpc_error *result = recursively_find_error_with_field(lerr->err, which);
+ grpc_linked_error* lerr = (grpc_linked_error*)(error->arena + slot);
+ grpc_error* result = recursively_find_error_with_field(lerr->err, which);
if (result) return result;
slot = lerr->next;
}
- return NULL;
+ return nullptr;
}
-void grpc_error_get_status(grpc_error *error, gpr_timespec deadline,
- grpc_status_code *code, grpc_slice *slice,
- grpc_http2_error_code *http_error) {
+void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
+ grpc_status_code* code, grpc_slice* slice,
+ grpc_http2_error_code* http_error,
+ const char** error_string) {
// Start with the parent error and recurse through the tree of children
// until we find the first one that has a status code.
- grpc_error *found_error =
+ grpc_error* found_error =
recursively_find_error_with_field(error, GRPC_ERROR_INT_GRPC_STATUS);
- if (found_error == NULL) {
+ if (found_error == nullptr) {
/// If no grpc-status exists, retry through the tree to find a http2 error
/// code
found_error =
@@ -55,7 +57,7 @@ void grpc_error_get_status(grpc_error *error, gpr_timespec deadline,
// If we found an error with a status code above, use that; otherwise,
// fall back to using the parent error.
- if (found_error == NULL) found_error = error;
+ if (found_error == nullptr) found_error = error;
grpc_status_code status = GRPC_STATUS_UNKNOWN;
intptr_t integer;
@@ -66,9 +68,13 @@ void grpc_error_get_status(grpc_error *error, gpr_timespec deadline,
status = grpc_http2_error_to_grpc_status((grpc_http2_error_code)integer,
deadline);
}
- if (code != NULL) *code = status;
+ if (code != nullptr) *code = status;
- if (http_error != NULL) {
+ if (error_string != nullptr && status != GRPC_STATUS_OK) {
+ *error_string = gpr_strdup(grpc_error_string(error));
+ }
+
+ if (http_error != nullptr) {
if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR, &integer)) {
*http_error = (grpc_http2_error_code)integer;
} else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_GRPC_STATUS,
@@ -82,24 +88,22 @@ void grpc_error_get_status(grpc_error *error, gpr_timespec deadline,
// If the error has a status message, use it. Otherwise, fall back to
// the error description.
- if (slice != NULL) {
+ if (slice != nullptr) {
if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_GRPC_MESSAGE, slice)) {
if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_DESCRIPTION, slice)) {
*slice = grpc_slice_from_static_string("unknown error");
}
}
}
-
- if (found_error == NULL) found_error = error;
}
-bool grpc_error_has_clear_grpc_status(grpc_error *error) {
- if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, NULL)) {
+bool grpc_error_has_clear_grpc_status(grpc_error* error) {
+ if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, nullptr)) {
return true;
}
uint8_t slot = error->first_err;
while (slot != UINT8_MAX) {
- grpc_linked_error *lerr = (grpc_linked_error *)(error->arena + slot);
+ grpc_linked_error* lerr = (grpc_linked_error*)(error->arena + slot);
if (grpc_error_has_clear_grpc_status(lerr->err)) {
return true;
}
diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h
index e530884215..4100f65d6d 100644
--- a/src/core/lib/transport/error_utils.h
+++ b/src/core/lib/transport/error_utils.h
@@ -20,22 +20,25 @@
#define GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H
#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/http2_errors.h"
/// A utility function to get the status code and message to be returned
/// to the application. If not set in the top-level message, looks
/// through child errors until it finds the first one with these attributes.
-/// All attributes are pulled from the same child error. If any of the
-/// attributes (code, msg, http_status) are unneeded, they can be passed as
+/// All attributes are pulled from the same child error. error_string will
+/// be populated with the entire error string. If any of the attributes (code,
+/// msg, http_status, error_string) are unneeded, they can be passed as
/// NULL.
-void grpc_error_get_status(grpc_error *error, gpr_timespec deadline,
- grpc_status_code *code, grpc_slice *slice,
- grpc_http2_error_code *http_status);
+void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
+ grpc_status_code* code, grpc_slice* slice,
+ grpc_http2_error_code* http_status,
+ const char** error_string);
/// A utility function to check whether there is a clear status code that
/// doesn't need to be guessed in \a error. This means that \a error or some
/// child has GRPC_ERROR_INT_GRPC_STATUS set, or that it is GRPC_ERROR_NONE or
/// GRPC_ERROR_CANCELLED
-bool grpc_error_has_clear_grpc_status(grpc_error *error);
+bool grpc_error_has_clear_grpc_status(grpc_error* error);
#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */
diff --git a/src/core/lib/transport/metadata.c b/src/core/lib/transport/metadata.cc
index 188b485625..652222bd0b 100644
--- a/src/core/lib/transport/metadata.c
+++ b/src/core/lib/transport/metadata.cc
@@ -19,6 +19,7 @@
#include "src/core/lib/transport/metadata.h"
#include <assert.h>
+#include <inttypes.h>
#include <stddef.h>
#include <string.h>
@@ -30,12 +31,12 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/murmur_hash.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/murmur_hash.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h"
/* There are two kinds of mdelem and mdstr instances.
@@ -47,9 +48,9 @@
* used to determine which kind of element a pointer refers to.
*/
+grpc_core::DebugOnlyTraceFlag grpc_trace_metadata(false, "metadata");
+
#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_metadata =
- GRPC_TRACER_INITIALIZER(false, "metadata");
#define DEBUG_ARGS , const char *file, int line
#define FWD_DEBUG_ARGS , file, line
#define REF_MD_LOCKED(shard, s) ref_md_locked((shard), (s), __FILE__, __LINE__)
@@ -66,7 +67,7 @@ grpc_tracer_flag grpc_trace_metadata =
#define TABLE_IDX(hash, capacity) (((hash) >> (LOG2_SHARD_COUNT)) % (capacity))
#define SHARD_IDX(hash) ((hash) & ((1 << (LOG2_SHARD_COUNT)) - 1))
-typedef void (*destroy_user_data_func)(void *user_data);
+typedef void (*destroy_user_data_func)(void* user_data);
/* Shadow structure for grpc_mdelem_data for interned elements */
typedef struct interned_metadata {
@@ -81,7 +82,7 @@ typedef struct interned_metadata {
gpr_atm destroy_user_data;
gpr_atm user_data;
- struct interned_metadata *bucket_next;
+ struct interned_metadata* bucket_next;
} interned_metadata;
/* Shadow structure for grpc_mdelem_data for allocated elements */
@@ -96,7 +97,7 @@ typedef struct allocated_metadata {
typedef struct mdtab_shard {
gpr_mu mu;
- interned_metadata **elems;
+ interned_metadata** elems;
size_t count;
size_t capacity;
/** Estimate of the number of unreferenced mdelems in the hash table.
@@ -107,26 +108,26 @@ typedef struct mdtab_shard {
static mdtab_shard g_shards[SHARD_COUNT];
-static void gc_mdtab(grpc_exec_ctx *exec_ctx, mdtab_shard *shard);
+static void gc_mdtab(mdtab_shard* shard);
void grpc_mdctx_global_init(void) {
/* initialize shards */
for (size_t i = 0; i < SHARD_COUNT; i++) {
- mdtab_shard *shard = &g_shards[i];
+ mdtab_shard* shard = &g_shards[i];
gpr_mu_init(&shard->mu);
shard->count = 0;
gpr_atm_no_barrier_store(&shard->free_estimate, 0);
shard->capacity = INITIAL_SHARD_CAPACITY;
- shard->elems = (interned_metadata **)gpr_zalloc(sizeof(*shard->elems) *
- shard->capacity);
+ shard->elems = (interned_metadata**)gpr_zalloc(sizeof(*shard->elems) *
+ shard->capacity);
}
}
-void grpc_mdctx_global_shutdown(grpc_exec_ctx *exec_ctx) {
+void grpc_mdctx_global_shutdown() {
for (size_t i = 0; i < SHARD_COUNT; i++) {
- mdtab_shard *shard = &g_shards[i];
+ mdtab_shard* shard = &g_shards[i];
gpr_mu_destroy(&shard->mu);
- gc_mdtab(exec_ctx, shard);
+ gc_mdtab(shard);
/* TODO(ctiller): GPR_ASSERT(shard->count == 0); */
if (shard->count != 0) {
gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata elements were leaked",
@@ -145,14 +146,14 @@ static int is_mdelem_static(grpc_mdelem e) {
&grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
}
-static void ref_md_locked(mdtab_shard *shard,
- interned_metadata *md DEBUG_ARGS) {
+static void ref_md_locked(mdtab_shard* shard,
+ interned_metadata* md DEBUG_ARGS) {
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(md->key);
- char *value_str = grpc_slice_to_c_string(md->value);
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(md->key);
+ char* value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
- "ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", (void *)md,
+ "ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", (void*)md,
gpr_atm_no_barrier_load(&md->refcnt),
gpr_atm_no_barrier_load(&md->refcnt) + 1, key_str, value_str);
gpr_free(key_str);
@@ -164,9 +165,9 @@ static void ref_md_locked(mdtab_shard *shard,
}
}
-static void gc_mdtab(grpc_exec_ctx *exec_ctx, mdtab_shard *shard) {
+static void gc_mdtab(mdtab_shard* shard) {
size_t i;
- interned_metadata **prev_next;
+ interned_metadata** prev_next;
interned_metadata *md, *next;
gpr_atm num_freed = 0;
@@ -174,11 +175,11 @@ static void gc_mdtab(grpc_exec_ctx *exec_ctx, mdtab_shard *shard) {
for (i = 0; i < shard->capacity; i++) {
prev_next = &shard->elems[i];
for (md = shard->elems[i]; md; md = next) {
- void *user_data = (void *)gpr_atm_no_barrier_load(&md->user_data);
+ void* user_data = (void*)gpr_atm_no_barrier_load(&md->user_data);
next = md->bucket_next;
if (gpr_atm_acq_load(&md->refcnt) == 0) {
- grpc_slice_unref_internal(exec_ctx, md->key);
- grpc_slice_unref_internal(exec_ctx, md->value);
+ grpc_slice_unref_internal(md->key);
+ grpc_slice_unref_internal(md->value);
if (md->user_data) {
((destroy_user_data_func)gpr_atm_no_barrier_load(
&md->destroy_user_data))(user_data);
@@ -196,17 +197,17 @@ static void gc_mdtab(grpc_exec_ctx *exec_ctx, mdtab_shard *shard) {
GPR_TIMER_END("gc_mdtab", 0);
}
-static void grow_mdtab(mdtab_shard *shard) {
+static void grow_mdtab(mdtab_shard* shard) {
size_t capacity = shard->capacity * 2;
size_t i;
- interned_metadata **mdtab;
+ interned_metadata** mdtab;
interned_metadata *md, *next;
uint32_t hash;
GPR_TIMER_BEGIN("grow_mdtab", 0);
mdtab =
- (interned_metadata **)gpr_zalloc(sizeof(interned_metadata *) * capacity);
+ (interned_metadata**)gpr_zalloc(sizeof(interned_metadata*) * capacity);
for (i = 0; i < shard->capacity; i++) {
for (md = shard->elems[i]; md; md = next) {
@@ -227,35 +228,35 @@ static void grow_mdtab(mdtab_shard *shard) {
GPR_TIMER_END("grow_mdtab", 0);
}
-static void rehash_mdtab(grpc_exec_ctx *exec_ctx, mdtab_shard *shard) {
+static void rehash_mdtab(mdtab_shard* shard) {
if (gpr_atm_no_barrier_load(&shard->free_estimate) >
(gpr_atm)(shard->capacity / 4)) {
- gc_mdtab(exec_ctx, shard);
+ gc_mdtab(shard);
} else {
grow_mdtab(shard);
}
}
grpc_mdelem grpc_mdelem_create(
- grpc_exec_ctx *exec_ctx, grpc_slice key, grpc_slice value,
- grpc_mdelem_data *compatible_external_backing_store) {
+ grpc_slice key, grpc_slice value,
+ grpc_mdelem_data* compatible_external_backing_store) {
if (!grpc_slice_is_interned(key) || !grpc_slice_is_interned(value)) {
- if (compatible_external_backing_store != NULL) {
+ if (compatible_external_backing_store != nullptr) {
return GRPC_MAKE_MDELEM(compatible_external_backing_store,
GRPC_MDELEM_STORAGE_EXTERNAL);
}
- allocated_metadata *allocated =
- (allocated_metadata *)gpr_malloc(sizeof(*allocated));
+ allocated_metadata* allocated =
+ (allocated_metadata*)gpr_malloc(sizeof(*allocated));
allocated->key = grpc_slice_ref_internal(key);
allocated->value = grpc_slice_ref_internal(value);
gpr_atm_rel_store(&allocated->refcnt, 1);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(allocated->key);
- char *value_str = grpc_slice_to_c_string(allocated->value);
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(allocated->key);
+ char* value_str = grpc_slice_to_c_string(allocated->value);
gpr_log(GPR_DEBUG, "ELM ALLOC:%p:%" PRIdPTR ": '%s' = '%s'",
- (void *)allocated, gpr_atm_no_barrier_load(&allocated->refcnt),
+ (void*)allocated, gpr_atm_no_barrier_load(&allocated->refcnt),
key_str, value_str);
gpr_free(key_str);
gpr_free(value_str);
@@ -275,8 +276,8 @@ grpc_mdelem grpc_mdelem_create(
uint32_t hash =
GRPC_MDSTR_KV_HASH(grpc_slice_hash(key), grpc_slice_hash(value));
- interned_metadata *md;
- mdtab_shard *shard = &g_shards[SHARD_IDX(hash)];
+ interned_metadata* md;
+ mdtab_shard* shard = &g_shards[SHARD_IDX(hash)];
size_t idx;
GPR_TIMER_BEGIN("grpc_mdelem_from_metadata_strings", 0);
@@ -295,7 +296,7 @@ grpc_mdelem grpc_mdelem_create(
}
/* not found: create a new pair */
- md = (interned_metadata *)gpr_malloc(sizeof(interned_metadata));
+ md = (interned_metadata*)gpr_malloc(sizeof(interned_metadata));
gpr_atm_rel_store(&md->refcnt, 1);
md->key = grpc_slice_ref_internal(key);
md->value = grpc_slice_ref_internal(value);
@@ -305,10 +306,10 @@ grpc_mdelem grpc_mdelem_create(
shard->elems[idx] = md;
gpr_mu_init(&md->mu_user_data);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(md->key);
- char *value_str = grpc_slice_to_c_string(md->value);
- gpr_log(GPR_DEBUG, "ELM NEW:%p:%" PRIdPTR ": '%s' = '%s'", (void *)md,
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(md->key);
+ char* value_str = grpc_slice_to_c_string(md->value);
+ gpr_log(GPR_DEBUG, "ELM NEW:%p:%" PRIdPTR ": '%s' = '%s'", (void*)md,
gpr_atm_no_barrier_load(&md->refcnt), key_str, value_str);
gpr_free(key_str);
gpr_free(value_str);
@@ -317,7 +318,7 @@ grpc_mdelem grpc_mdelem_create(
shard->count++;
if (shard->count > shard->capacity * 2) {
- rehash_mdtab(exec_ctx, shard);
+ rehash_mdtab(shard);
}
gpr_mu_unlock(&shard->mu);
@@ -327,23 +328,21 @@ grpc_mdelem grpc_mdelem_create(
return GRPC_MAKE_MDELEM(md, GRPC_MDELEM_STORAGE_INTERNED);
}
-grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key,
- grpc_slice value) {
- grpc_mdelem out = grpc_mdelem_create(exec_ctx, key, value, NULL);
- grpc_slice_unref_internal(exec_ctx, key);
- grpc_slice_unref_internal(exec_ctx, value);
+grpc_mdelem grpc_mdelem_from_slices(grpc_slice key, grpc_slice value) {
+ grpc_mdelem out = grpc_mdelem_create(key, value, nullptr);
+ grpc_slice_unref_internal(key);
+ grpc_slice_unref_internal(value);
return out;
}
-grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx *exec_ctx,
- grpc_metadata *metadata) {
+grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata) {
bool changed = false;
grpc_slice key_slice =
grpc_slice_maybe_static_intern(metadata->key, &changed);
grpc_slice value_slice =
grpc_slice_maybe_static_intern(metadata->value, &changed);
- return grpc_mdelem_create(exec_ctx, key_slice, value_slice,
- changed ? NULL : (grpc_mdelem_data *)metadata);
+ return grpc_mdelem_create(key_slice, value_slice,
+ changed ? nullptr : (grpc_mdelem_data*)metadata);
}
static size_t get_base64_encoded_size(size_t raw_length) {
@@ -351,11 +350,14 @@ static size_t get_base64_encoded_size(size_t raw_length) {
return raw_length / 3 * 4 + tail_xtra[raw_length % 3];
}
-size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem) {
+size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem,
+ bool use_true_binary_metadata) {
size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
size_t value_len = GRPC_SLICE_LENGTH(GRPC_MDVALUE(elem));
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
- return overhead_and_key + get_base64_encoded_size(value_len);
+ return overhead_and_key + (use_true_binary_metadata
+ ? value_len + 1
+ : get_base64_encoded_size(value_len));
} else {
return overhead_and_key + value_len;
}
@@ -367,14 +369,14 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_STATIC:
break;
case GRPC_MDELEM_STORAGE_INTERNED: {
- interned_metadata *md = (interned_metadata *)GRPC_MDELEM_DATA(gmd);
+ interned_metadata* md = (interned_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(md->key);
- char *value_str = grpc_slice_to_c_string(md->value);
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(md->key);
+ char* value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'",
- (void *)md, gpr_atm_no_barrier_load(&md->refcnt),
+ (void*)md, gpr_atm_no_barrier_load(&md->refcnt),
gpr_atm_no_barrier_load(&md->refcnt) + 1, key_str, value_str);
gpr_free(key_str);
gpr_free(value_str);
@@ -389,14 +391,14 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
break;
}
case GRPC_MDELEM_STORAGE_ALLOCATED: {
- allocated_metadata *md = (allocated_metadata *)GRPC_MDELEM_DATA(gmd);
+ allocated_metadata* md = (allocated_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(md->key);
- char *value_str = grpc_slice_to_c_string(md->value);
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(md->key);
+ char* value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'",
- (void *)md, gpr_atm_no_barrier_load(&md->refcnt),
+ (void*)md, gpr_atm_no_barrier_load(&md->refcnt),
gpr_atm_no_barrier_load(&md->refcnt) + 1, key_str, value_str);
gpr_free(key_str);
gpr_free(value_str);
@@ -413,20 +415,20 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
return gmd;
}
-void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
+void grpc_mdelem_unref(grpc_mdelem gmd DEBUG_ARGS) {
switch (GRPC_MDELEM_STORAGE(gmd)) {
case GRPC_MDELEM_STORAGE_EXTERNAL:
case GRPC_MDELEM_STORAGE_STATIC:
break;
case GRPC_MDELEM_STORAGE_INTERNED: {
- interned_metadata *md = (interned_metadata *)GRPC_MDELEM_DATA(gmd);
+ interned_metadata* md = (interned_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(md->key);
- char *value_str = grpc_slice_to_c_string(md->value);
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(md->key);
+ char* value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM UNREF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'",
- (void *)md, gpr_atm_no_barrier_load(&md->refcnt),
+ (void*)md, gpr_atm_no_barrier_load(&md->refcnt),
gpr_atm_no_barrier_load(&md->refcnt) - 1, key_str, value_str);
gpr_free(key_str);
gpr_free(value_str);
@@ -439,20 +441,20 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
if (1 == prev_refcount) {
/* once the refcount hits zero, some other thread can come along and
free md at any time: it's unsafe from this point on to access it */
- mdtab_shard *shard = &g_shards[SHARD_IDX(hash)];
+ mdtab_shard* shard = &g_shards[SHARD_IDX(hash)];
gpr_atm_no_barrier_fetch_add(&shard->free_estimate, 1);
}
break;
}
case GRPC_MDELEM_STORAGE_ALLOCATED: {
- allocated_metadata *md = (allocated_metadata *)GRPC_MDELEM_DATA(gmd);
+ allocated_metadata* md = (allocated_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
- char *key_str = grpc_slice_to_c_string(md->key);
- char *value_str = grpc_slice_to_c_string(md->value);
+ if (grpc_trace_metadata.enabled()) {
+ char* key_str = grpc_slice_to_c_string(md->key);
+ char* value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM UNREF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'",
- (void *)md, gpr_atm_no_barrier_load(&md->refcnt),
+ (void*)md, gpr_atm_no_barrier_load(&md->refcnt),
gpr_atm_no_barrier_load(&md->refcnt) - 1, key_str, value_str);
gpr_free(key_str);
gpr_free(value_str);
@@ -461,8 +463,8 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
const gpr_atm prev_refcount = gpr_atm_full_fetch_add(&md->refcnt, -1);
GPR_ASSERT(prev_refcount >= 1);
if (1 == prev_refcount) {
- grpc_slice_unref_internal(exec_ctx, md->key);
- grpc_slice_unref_internal(exec_ctx, md->value);
+ grpc_slice_unref_internal(md->key);
+ grpc_slice_unref_internal(md->value);
gpr_free(md);
}
break;
@@ -470,51 +472,51 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
}
}
-void *grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void *)) {
+void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) {
switch (GRPC_MDELEM_STORAGE(md)) {
case GRPC_MDELEM_STORAGE_EXTERNAL:
case GRPC_MDELEM_STORAGE_ALLOCATED:
- return NULL;
+ return nullptr;
case GRPC_MDELEM_STORAGE_STATIC:
- return (void *)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) -
- grpc_static_mdelem_table];
+ return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) -
+ grpc_static_mdelem_table];
case GRPC_MDELEM_STORAGE_INTERNED: {
- interned_metadata *im = (interned_metadata *)GRPC_MDELEM_DATA(md);
- void *result;
+ interned_metadata* im = (interned_metadata*)GRPC_MDELEM_DATA(md);
+ void* result;
if (gpr_atm_acq_load(&im->destroy_user_data) == (gpr_atm)destroy_func) {
- return (void *)gpr_atm_no_barrier_load(&im->user_data);
+ return (void*)gpr_atm_no_barrier_load(&im->user_data);
} else {
- return NULL;
+ return nullptr;
}
return result;
}
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
-void *grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void *),
- void *user_data) {
+void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
+ void* user_data) {
switch (GRPC_MDELEM_STORAGE(md)) {
case GRPC_MDELEM_STORAGE_EXTERNAL:
case GRPC_MDELEM_STORAGE_ALLOCATED:
destroy_func(user_data);
- return NULL;
+ return nullptr;
case GRPC_MDELEM_STORAGE_STATIC:
destroy_func(user_data);
- return (void *)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) -
- grpc_static_mdelem_table];
+ return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) -
+ grpc_static_mdelem_table];
case GRPC_MDELEM_STORAGE_INTERNED: {
- interned_metadata *im = (interned_metadata *)GRPC_MDELEM_DATA(md);
+ interned_metadata* im = (interned_metadata*)GRPC_MDELEM_DATA(md);
GPR_ASSERT(!is_mdelem_static(md));
- GPR_ASSERT((user_data == NULL) == (destroy_func == NULL));
+ GPR_ASSERT((user_data == nullptr) == (destroy_func == nullptr));
gpr_mu_lock(&im->mu_user_data);
if (gpr_atm_no_barrier_load(&im->destroy_user_data)) {
/* user data can only be set once */
gpr_mu_unlock(&im->mu_user_data);
- if (destroy_func != NULL) {
+ if (destroy_func != nullptr) {
destroy_func(user_data);
}
- return (void *)gpr_atm_no_barrier_load(&im->user_data);
+ return (void*)gpr_atm_no_barrier_load(&im->user_data);
}
gpr_atm_no_barrier_store(&im->user_data, (gpr_atm)user_data);
gpr_atm_rel_store(&im->destroy_user_data, (gpr_atm)destroy_func);
@@ -522,7 +524,7 @@ void *grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void *),
return user_data;
}
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b) {
diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h
index 974469e436..78e6beff9b 100644
--- a/src/core/lib/transport/metadata.h
+++ b/src/core/lib/transport/metadata.h
@@ -25,13 +25,7 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_metadata;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata;
/* This file provides a mechanism for tracking metadata through the grpc stack.
It's not intended for consumption outside of the library.
@@ -98,56 +92,56 @@ struct grpc_mdelem {
uintptr_t payload;
};
-#define GRPC_MDELEM_DATA(md) \
- ((grpc_mdelem_data *)((md).payload & ~(uintptr_t)3))
+#define GRPC_MDELEM_DATA(md) ((grpc_mdelem_data*)((md).payload & ~(uintptr_t)3))
#define GRPC_MDELEM_STORAGE(md) \
((grpc_mdelem_data_storage)((md).payload & (uintptr_t)3))
+#ifdef __cplusplus
+#define GRPC_MAKE_MDELEM(data, storage) \
+ (grpc_mdelem{((uintptr_t)(data)) | ((uintptr_t)storage)})
+#else
#define GRPC_MAKE_MDELEM(data, storage) \
((grpc_mdelem){((uintptr_t)(data)) | ((uintptr_t)storage)})
+#endif
#define GRPC_MDELEM_IS_INTERNED(md) \
((grpc_mdelem_data_storage)((md).payload & \
(uintptr_t)GRPC_MDELEM_STORAGE_INTERNED_BIT))
/* Unrefs the slices. */
-grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key,
- grpc_slice value);
+grpc_mdelem grpc_mdelem_from_slices(grpc_slice key, grpc_slice value);
/* Cheaply convert a grpc_metadata to a grpc_mdelem; may use the grpc_metadata
object as backing storage (so lifetimes should align) */
-grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx *exec_ctx,
- grpc_metadata *metadata);
+grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata);
/* Does not unref the slices; if a new non-interned mdelem is needed, allocates
one if compatible_external_backing_store is NULL, or uses
compatible_external_backing_store if it is non-NULL (in which case it's the
users responsibility to ensure that it outlives usage) */
grpc_mdelem grpc_mdelem_create(
- grpc_exec_ctx *exec_ctx, grpc_slice key, grpc_slice value,
- grpc_mdelem_data *compatible_external_backing_store);
+ grpc_slice key, grpc_slice value,
+ grpc_mdelem_data* compatible_external_backing_store);
bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b);
-size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem);
+size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem,
+ bool use_true_binary_metadata);
/* Mutator and accessor for grpc_mdelem user data. The destructor function
is used as a type tag and is checked during user_data fetch. */
-void *grpc_mdelem_get_user_data(grpc_mdelem md,
- void (*if_destroy_func)(void *));
-void *grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void *),
- void *user_data);
+void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*if_destroy_func)(void*));
+void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
+ void* user_data);
#ifndef NDEBUG
#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s), __FILE__, __LINE__)
-#define GRPC_MDELEM_UNREF(exec_ctx, s) \
- grpc_mdelem_unref((exec_ctx), (s), __FILE__, __LINE__)
-grpc_mdelem grpc_mdelem_ref(grpc_mdelem md, const char *file, int line);
-void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem md,
- const char *file, int line);
+#define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s), __FILE__, __LINE__)
+grpc_mdelem grpc_mdelem_ref(grpc_mdelem md, const char* file, int line);
+void grpc_mdelem_unref(grpc_mdelem md, const char* file, int line);
#else
#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s))
-#define GRPC_MDELEM_UNREF(exec_ctx, s) grpc_mdelem_unref((exec_ctx), (s))
+#define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s))
grpc_mdelem grpc_mdelem_ref(grpc_mdelem md);
-void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem md);
+void grpc_mdelem_unref(grpc_mdelem md);
#endif
#define GRPC_MDKEY(md) (GRPC_MDELEM_DATA(md)->key)
@@ -164,10 +158,6 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem md);
#define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash))
void grpc_mdctx_global_init(void);
-void grpc_mdctx_global_shutdown(grpc_exec_ctx *exec_ctx);
-
-#ifdef __cplusplus
-}
-#endif
+void grpc_mdctx_global_shutdown();
#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */
diff --git a/src/core/lib/transport/metadata_batch.c b/src/core/lib/transport/metadata_batch.c
deleted file mode 100644
index 54388bdcda..0000000000
--- a/src/core/lib/transport/metadata_batch.c
+++ /dev/null
@@ -1,315 +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/transport/metadata_batch.h"
-
-#include <stdbool.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-
-static void assert_valid_list(grpc_mdelem_list *list) {
-#ifndef NDEBUG
- grpc_linked_mdelem *l;
-
- GPR_ASSERT((list->head == NULL) == (list->tail == NULL));
- if (!list->head) return;
- GPR_ASSERT(list->head->prev == NULL);
- GPR_ASSERT(list->tail->next == NULL);
- GPR_ASSERT((list->head == list->tail) == (list->head->next == NULL));
-
- size_t verified_count = 0;
- for (l = list->head; l; l = l->next) {
- GPR_ASSERT(!GRPC_MDISNULL(l->md));
- GPR_ASSERT((l->prev == NULL) == (l == list->head));
- GPR_ASSERT((l->next == NULL) == (l == list->tail));
- if (l->next) GPR_ASSERT(l->next->prev == l);
- if (l->prev) GPR_ASSERT(l->prev->next == l);
- verified_count++;
- }
- GPR_ASSERT(list->count == verified_count);
-#endif /* NDEBUG */
-}
-
-static void assert_valid_callouts(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch) {
-#ifndef NDEBUG
- for (grpc_linked_mdelem *l = batch->list.head; l != NULL; l = l->next) {
- grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md));
- grpc_metadata_batch_callouts_index callout_idx =
- GRPC_BATCH_INDEX_OF(key_interned);
- if (callout_idx != GRPC_BATCH_CALLOUTS_COUNT) {
- GPR_ASSERT(batch->idx.array[callout_idx] == l);
- }
- grpc_slice_unref_internal(exec_ctx, key_interned);
- }
-#endif
-}
-
-#ifndef NDEBUG
-void grpc_metadata_batch_assert_ok(grpc_metadata_batch *batch) {
- assert_valid_list(&batch->list);
-}
-#endif /* NDEBUG */
-
-void grpc_metadata_batch_init(grpc_metadata_batch *batch) {
- memset(batch, 0, sizeof(*batch));
- batch->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
-}
-
-void grpc_metadata_batch_destroy(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch) {
- grpc_linked_mdelem *l;
- for (l = batch->list.head; l; l = l->next) {
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
- }
-}
-
-grpc_error *grpc_attach_md_to_error(grpc_error *src, grpc_mdelem md) {
- grpc_error *out = grpc_error_set_str(
- grpc_error_set_str(src, GRPC_ERROR_STR_KEY,
- grpc_slice_ref_internal(GRPC_MDKEY(md))),
- GRPC_ERROR_STR_VALUE, grpc_slice_ref_internal(GRPC_MDVALUE(md)));
- return out;
-}
-
-static grpc_error *maybe_link_callout(grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage)
- GRPC_MUST_USE_RESULT;
-
-static grpc_error *maybe_link_callout(grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) {
- grpc_metadata_batch_callouts_index idx =
- GRPC_BATCH_INDEX_OF(GRPC_MDKEY(storage->md));
- if (idx == GRPC_BATCH_CALLOUTS_COUNT) {
- return GRPC_ERROR_NONE;
- }
- if (batch->idx.array[idx] == NULL) {
- if (grpc_static_callout_is_default[idx]) ++batch->list.default_count;
- batch->idx.array[idx] = storage;
- return GRPC_ERROR_NONE;
- }
- return grpc_attach_md_to_error(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unallowed duplicate metadata"),
- storage->md);
-}
-
-static void maybe_unlink_callout(grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) {
- grpc_metadata_batch_callouts_index idx =
- GRPC_BATCH_INDEX_OF(GRPC_MDKEY(storage->md));
- if (idx == GRPC_BATCH_CALLOUTS_COUNT) {
- return;
- }
- if (grpc_static_callout_is_default[idx]) --batch->list.default_count;
- GPR_ASSERT(batch->idx.array[idx] != NULL);
- batch->idx.array[idx] = NULL;
-}
-
-grpc_error *grpc_metadata_batch_add_head(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage,
- grpc_mdelem elem_to_add) {
- GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
- storage->md = elem_to_add;
- return grpc_metadata_batch_link_head(exec_ctx, batch, storage);
-}
-
-static void link_head(grpc_mdelem_list *list, grpc_linked_mdelem *storage) {
- assert_valid_list(list);
- GPR_ASSERT(!GRPC_MDISNULL(storage->md));
- storage->prev = NULL;
- storage->next = list->head;
- if (list->head != NULL) {
- list->head->prev = storage;
- } else {
- list->tail = storage;
- }
- list->head = storage;
- list->count++;
- assert_valid_list(list);
-}
-
-grpc_error *grpc_metadata_batch_link_head(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) {
- assert_valid_callouts(exec_ctx, batch);
- grpc_error *err = maybe_link_callout(batch, storage);
- if (err != GRPC_ERROR_NONE) {
- assert_valid_callouts(exec_ctx, batch);
- return err;
- }
- link_head(&batch->list, storage);
- assert_valid_callouts(exec_ctx, batch);
- return GRPC_ERROR_NONE;
-}
-
-grpc_error *grpc_metadata_batch_add_tail(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage,
- grpc_mdelem elem_to_add) {
- GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
- storage->md = elem_to_add;
- return grpc_metadata_batch_link_tail(exec_ctx, batch, storage);
-}
-
-static void link_tail(grpc_mdelem_list *list, grpc_linked_mdelem *storage) {
- assert_valid_list(list);
- GPR_ASSERT(!GRPC_MDISNULL(storage->md));
- storage->prev = list->tail;
- storage->next = NULL;
- storage->reserved = NULL;
- if (list->tail != NULL) {
- list->tail->next = storage;
- } else {
- list->head = storage;
- }
- list->tail = storage;
- list->count++;
- assert_valid_list(list);
-}
-
-grpc_error *grpc_metadata_batch_link_tail(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) {
- assert_valid_callouts(exec_ctx, batch);
- grpc_error *err = maybe_link_callout(batch, storage);
- if (err != GRPC_ERROR_NONE) {
- assert_valid_callouts(exec_ctx, batch);
- return err;
- }
- link_tail(&batch->list, storage);
- assert_valid_callouts(exec_ctx, batch);
- return GRPC_ERROR_NONE;
-}
-
-static void unlink_storage(grpc_mdelem_list *list,
- grpc_linked_mdelem *storage) {
- assert_valid_list(list);
- if (storage->prev != NULL) {
- storage->prev->next = storage->next;
- } else {
- list->head = storage->next;
- }
- if (storage->next != NULL) {
- storage->next->prev = storage->prev;
- } else {
- list->tail = storage->prev;
- }
- list->count--;
- assert_valid_list(list);
-}
-
-void grpc_metadata_batch_remove(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) {
- assert_valid_callouts(exec_ctx, batch);
- maybe_unlink_callout(batch, storage);
- unlink_storage(&batch->list, storage);
- GRPC_MDELEM_UNREF(exec_ctx, storage->md);
- assert_valid_callouts(exec_ctx, batch);
-}
-
-void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx,
- grpc_linked_mdelem *storage,
- grpc_slice value) {
- grpc_mdelem old_mdelem = storage->md;
- grpc_mdelem new_mdelem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(old_mdelem)), value);
- storage->md = new_mdelem;
- GRPC_MDELEM_UNREF(exec_ctx, old_mdelem);
-}
-
-grpc_error *grpc_metadata_batch_substitute(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage,
- grpc_mdelem new_mdelem) {
- assert_valid_callouts(exec_ctx, batch);
- grpc_error *error = GRPC_ERROR_NONE;
- grpc_mdelem old_mdelem = storage->md;
- if (!grpc_slice_eq(GRPC_MDKEY(new_mdelem), GRPC_MDKEY(old_mdelem))) {
- maybe_unlink_callout(batch, storage);
- storage->md = new_mdelem;
- error = maybe_link_callout(batch, storage);
- if (error != GRPC_ERROR_NONE) {
- unlink_storage(&batch->list, storage);
- GRPC_MDELEM_UNREF(exec_ctx, storage->md);
- }
- } else {
- storage->md = new_mdelem;
- }
- GRPC_MDELEM_UNREF(exec_ctx, old_mdelem);
- assert_valid_callouts(exec_ctx, batch);
- return error;
-}
-
-void grpc_metadata_batch_clear(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch) {
- grpc_metadata_batch_destroy(exec_ctx, batch);
- grpc_metadata_batch_init(batch);
-}
-
-bool grpc_metadata_batch_is_empty(grpc_metadata_batch *batch) {
- return batch->list.head == NULL &&
- gpr_time_cmp(gpr_inf_future(batch->deadline.clock_type),
- batch->deadline) == 0;
-}
-
-size_t grpc_metadata_batch_size(grpc_metadata_batch *batch) {
- size_t size = 0;
- for (grpc_linked_mdelem *elem = batch->list.head; elem != NULL;
- elem = elem->next) {
- size += GRPC_MDELEM_LENGTH(elem->md);
- }
- return size;
-}
-
-static void add_error(grpc_error **composite, grpc_error *error,
- const char *composite_error_string) {
- if (error == GRPC_ERROR_NONE) return;
- if (*composite == GRPC_ERROR_NONE) {
- *composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(composite_error_string);
- }
- *composite = grpc_error_add_child(*composite, error);
-}
-
-grpc_error *grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_metadata_batch_filter_func func,
- void *user_data,
- const char *composite_error_string) {
- grpc_linked_mdelem *l = batch->list.head;
- grpc_error *error = GRPC_ERROR_NONE;
- while (l) {
- grpc_linked_mdelem *next = l->next;
- grpc_filtered_mdelem new_mdelem = func(exec_ctx, user_data, l->md);
- add_error(&error, new_mdelem.error, composite_error_string);
- if (GRPC_MDISNULL(new_mdelem.md)) {
- grpc_metadata_batch_remove(exec_ctx, batch, l);
- } else if (new_mdelem.md.payload != l->md.payload) {
- grpc_metadata_batch_substitute(exec_ctx, batch, l, new_mdelem.md);
- }
- l = next;
- }
- return error;
-}
diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc
new file mode 100644
index 0000000000..9c95339ba0
--- /dev/null
+++ b/src/core/lib/transport/metadata_batch.cc
@@ -0,0 +1,303 @@
+/*
+ *
+ * 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/transport/metadata_batch.h"
+
+#include <stdbool.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/profiling/timers.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+
+static void assert_valid_list(grpc_mdelem_list* list) {
+#ifndef NDEBUG
+ grpc_linked_mdelem* l;
+
+ GPR_ASSERT((list->head == nullptr) == (list->tail == nullptr));
+ if (!list->head) return;
+ GPR_ASSERT(list->head->prev == nullptr);
+ GPR_ASSERT(list->tail->next == nullptr);
+ GPR_ASSERT((list->head == list->tail) == (list->head->next == nullptr));
+
+ size_t verified_count = 0;
+ for (l = list->head; l; l = l->next) {
+ GPR_ASSERT(!GRPC_MDISNULL(l->md));
+ GPR_ASSERT((l->prev == nullptr) == (l == list->head));
+ GPR_ASSERT((l->next == nullptr) == (l == list->tail));
+ if (l->next) GPR_ASSERT(l->next->prev == l);
+ if (l->prev) GPR_ASSERT(l->prev->next == l);
+ verified_count++;
+ }
+ GPR_ASSERT(list->count == verified_count);
+#endif /* NDEBUG */
+}
+
+static void assert_valid_callouts(grpc_metadata_batch* batch) {
+#ifndef NDEBUG
+ for (grpc_linked_mdelem* l = batch->list.head; l != nullptr; l = l->next) {
+ grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md));
+ grpc_metadata_batch_callouts_index callout_idx =
+ GRPC_BATCH_INDEX_OF(key_interned);
+ if (callout_idx != GRPC_BATCH_CALLOUTS_COUNT) {
+ GPR_ASSERT(batch->idx.array[callout_idx] == l);
+ }
+ grpc_slice_unref_internal(key_interned);
+ }
+#endif
+}
+
+#ifndef NDEBUG
+void grpc_metadata_batch_assert_ok(grpc_metadata_batch* batch) {
+ assert_valid_list(&batch->list);
+}
+#endif /* NDEBUG */
+
+void grpc_metadata_batch_init(grpc_metadata_batch* batch) {
+ memset(batch, 0, sizeof(*batch));
+ batch->deadline = GRPC_MILLIS_INF_FUTURE;
+}
+
+void grpc_metadata_batch_destroy(grpc_metadata_batch* batch) {
+ grpc_linked_mdelem* l;
+ for (l = batch->list.head; l; l = l->next) {
+ GRPC_MDELEM_UNREF(l->md);
+ }
+}
+
+grpc_error* grpc_attach_md_to_error(grpc_error* src, grpc_mdelem md) {
+ grpc_error* out = grpc_error_set_str(
+ grpc_error_set_str(src, GRPC_ERROR_STR_KEY,
+ grpc_slice_ref_internal(GRPC_MDKEY(md))),
+ GRPC_ERROR_STR_VALUE, grpc_slice_ref_internal(GRPC_MDVALUE(md)));
+ return out;
+}
+
+static grpc_error* maybe_link_callout(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage)
+ GRPC_MUST_USE_RESULT;
+
+static grpc_error* maybe_link_callout(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage) {
+ grpc_metadata_batch_callouts_index idx =
+ GRPC_BATCH_INDEX_OF(GRPC_MDKEY(storage->md));
+ if (idx == GRPC_BATCH_CALLOUTS_COUNT) {
+ return GRPC_ERROR_NONE;
+ }
+ if (batch->idx.array[idx] == nullptr) {
+ if (grpc_static_callout_is_default[idx]) ++batch->list.default_count;
+ batch->idx.array[idx] = storage;
+ return GRPC_ERROR_NONE;
+ }
+ return grpc_attach_md_to_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unallowed duplicate metadata"),
+ storage->md);
+}
+
+static void maybe_unlink_callout(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage) {
+ grpc_metadata_batch_callouts_index idx =
+ GRPC_BATCH_INDEX_OF(GRPC_MDKEY(storage->md));
+ if (idx == GRPC_BATCH_CALLOUTS_COUNT) {
+ return;
+ }
+ if (grpc_static_callout_is_default[idx]) --batch->list.default_count;
+ GPR_ASSERT(batch->idx.array[idx] != nullptr);
+ batch->idx.array[idx] = nullptr;
+}
+
+grpc_error* grpc_metadata_batch_add_head(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage,
+ grpc_mdelem elem_to_add) {
+ GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
+ storage->md = elem_to_add;
+ return grpc_metadata_batch_link_head(batch, storage);
+}
+
+static void link_head(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
+ assert_valid_list(list);
+ GPR_ASSERT(!GRPC_MDISNULL(storage->md));
+ storage->prev = nullptr;
+ storage->next = list->head;
+ if (list->head != nullptr) {
+ list->head->prev = storage;
+ } else {
+ list->tail = storage;
+ }
+ list->head = storage;
+ list->count++;
+ assert_valid_list(list);
+}
+
+grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage) {
+ assert_valid_callouts(batch);
+ grpc_error* err = maybe_link_callout(batch, storage);
+ if (err != GRPC_ERROR_NONE) {
+ assert_valid_callouts(batch);
+ return err;
+ }
+ link_head(&batch->list, storage);
+ assert_valid_callouts(batch);
+ return GRPC_ERROR_NONE;
+}
+
+grpc_error* grpc_metadata_batch_add_tail(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage,
+ grpc_mdelem elem_to_add) {
+ GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
+ storage->md = elem_to_add;
+ return grpc_metadata_batch_link_tail(batch, storage);
+}
+
+static void link_tail(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
+ assert_valid_list(list);
+ GPR_ASSERT(!GRPC_MDISNULL(storage->md));
+ storage->prev = list->tail;
+ storage->next = nullptr;
+ storage->reserved = nullptr;
+ if (list->tail != nullptr) {
+ list->tail->next = storage;
+ } else {
+ list->head = storage;
+ }
+ list->tail = storage;
+ list->count++;
+ assert_valid_list(list);
+}
+
+grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage) {
+ assert_valid_callouts(batch);
+ grpc_error* err = maybe_link_callout(batch, storage);
+ if (err != GRPC_ERROR_NONE) {
+ assert_valid_callouts(batch);
+ return err;
+ }
+ link_tail(&batch->list, storage);
+ assert_valid_callouts(batch);
+ return GRPC_ERROR_NONE;
+}
+
+static void unlink_storage(grpc_mdelem_list* list,
+ grpc_linked_mdelem* storage) {
+ assert_valid_list(list);
+ if (storage->prev != nullptr) {
+ storage->prev->next = storage->next;
+ } else {
+ list->head = storage->next;
+ }
+ if (storage->next != nullptr) {
+ storage->next->prev = storage->prev;
+ } else {
+ list->tail = storage->prev;
+ }
+ list->count--;
+ assert_valid_list(list);
+}
+
+void grpc_metadata_batch_remove(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage) {
+ assert_valid_callouts(batch);
+ maybe_unlink_callout(batch, storage);
+ unlink_storage(&batch->list, storage);
+ GRPC_MDELEM_UNREF(storage->md);
+ assert_valid_callouts(batch);
+}
+
+void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage,
+ grpc_slice value) {
+ grpc_mdelem old_mdelem = storage->md;
+ grpc_mdelem new_mdelem = grpc_mdelem_from_slices(
+ grpc_slice_ref_internal(GRPC_MDKEY(old_mdelem)), value);
+ storage->md = new_mdelem;
+ GRPC_MDELEM_UNREF(old_mdelem);
+}
+
+grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage,
+ grpc_mdelem new_mdelem) {
+ assert_valid_callouts(batch);
+ grpc_error* error = GRPC_ERROR_NONE;
+ grpc_mdelem old_mdelem = storage->md;
+ if (!grpc_slice_eq(GRPC_MDKEY(new_mdelem), GRPC_MDKEY(old_mdelem))) {
+ maybe_unlink_callout(batch, storage);
+ storage->md = new_mdelem;
+ error = maybe_link_callout(batch, storage);
+ if (error != GRPC_ERROR_NONE) {
+ unlink_storage(&batch->list, storage);
+ GRPC_MDELEM_UNREF(storage->md);
+ }
+ } else {
+ storage->md = new_mdelem;
+ }
+ GRPC_MDELEM_UNREF(old_mdelem);
+ assert_valid_callouts(batch);
+ return error;
+}
+
+void grpc_metadata_batch_clear(grpc_metadata_batch* batch) {
+ grpc_metadata_batch_destroy(batch);
+ grpc_metadata_batch_init(batch);
+}
+
+bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch) {
+ return batch->list.head == nullptr &&
+ batch->deadline == GRPC_MILLIS_INF_FUTURE;
+}
+
+size_t grpc_metadata_batch_size(grpc_metadata_batch* batch) {
+ size_t size = 0;
+ for (grpc_linked_mdelem* elem = batch->list.head; elem != nullptr;
+ elem = elem->next) {
+ size += GRPC_MDELEM_LENGTH(elem->md);
+ }
+ return size;
+}
+
+static void add_error(grpc_error** composite, grpc_error* error,
+ const char* composite_error_string) {
+ if (error == GRPC_ERROR_NONE) return;
+ if (*composite == GRPC_ERROR_NONE) {
+ *composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(composite_error_string);
+ }
+ *composite = grpc_error_add_child(*composite, error);
+}
+
+grpc_error* grpc_metadata_batch_filter(grpc_metadata_batch* batch,
+ grpc_metadata_batch_filter_func func,
+ void* user_data,
+ const char* composite_error_string) {
+ grpc_linked_mdelem* l = batch->list.head;
+ grpc_error* error = GRPC_ERROR_NONE;
+ while (l) {
+ grpc_linked_mdelem* next = l->next;
+ grpc_filtered_mdelem new_mdelem = func(user_data, l->md);
+ add_error(&error, new_mdelem.error, composite_error_string);
+ if (GRPC_MDISNULL(new_mdelem.md)) {
+ grpc_metadata_batch_remove(batch, l);
+ } else if (new_mdelem.md.payload != l->md.payload) {
+ grpc_metadata_batch_substitute(batch, l, new_mdelem.md);
+ }
+ l = next;
+ }
+ return error;
+}
diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h
index 57d298c75c..8353a426f8 100644
--- a/src/core/lib/transport/metadata_batch.h
+++ b/src/core/lib/transport/metadata_batch.h
@@ -28,22 +28,18 @@
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_linked_mdelem {
grpc_mdelem md;
- struct grpc_linked_mdelem *next;
- struct grpc_linked_mdelem *prev;
- void *reserved;
+ struct grpc_linked_mdelem* next;
+ struct grpc_linked_mdelem* prev;
+ void* reserved;
} grpc_linked_mdelem;
typedef struct grpc_mdelem_list {
size_t count;
size_t default_count; // Number of default keys.
- grpc_linked_mdelem *head;
- grpc_linked_mdelem *tail;
+ grpc_linked_mdelem* head;
+ grpc_linked_mdelem* tail;
} grpc_mdelem_list;
typedef struct grpc_metadata_batch {
@@ -51,34 +47,29 @@ typedef struct grpc_metadata_batch {
grpc_mdelem_list list;
grpc_metadata_batch_callouts idx;
/** Used to calculate grpc-timeout at the point of sending,
- or gpr_inf_future if this batch does not need to send a
+ or GRPC_MILLIS_INF_FUTURE if this batch does not need to send a
grpc-timeout */
- gpr_timespec deadline;
+ grpc_millis deadline;
} grpc_metadata_batch;
-void grpc_metadata_batch_init(grpc_metadata_batch *batch);
-void grpc_metadata_batch_destroy(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch);
-void grpc_metadata_batch_clear(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch);
-bool grpc_metadata_batch_is_empty(grpc_metadata_batch *batch);
+void grpc_metadata_batch_init(grpc_metadata_batch* batch);
+void grpc_metadata_batch_destroy(grpc_metadata_batch* batch);
+void grpc_metadata_batch_clear(grpc_metadata_batch* batch);
+bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch);
/* Returns the transport size of the batch. */
-size_t grpc_metadata_batch_size(grpc_metadata_batch *batch);
+size_t grpc_metadata_batch_size(grpc_metadata_batch* batch);
/** Remove \a storage from the batch, unreffing the mdelem contained */
-void grpc_metadata_batch_remove(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage);
+void grpc_metadata_batch_remove(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage);
/** Substitute a new mdelem for an old value */
-grpc_error *grpc_metadata_batch_substitute(grpc_exec_ctx *exec_ctx,
- grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage,
+grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage,
grpc_mdelem new_value);
-void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx,
- grpc_linked_mdelem *storage,
+void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage,
grpc_slice value);
/** Add \a storage to the beginning of \a batch. storage->md is
@@ -86,17 +77,17 @@ void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx,
\a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around
for the lifetime of the call. */
-grpc_error *grpc_metadata_batch_link_head(
- grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage)
+ GRPC_MUST_USE_RESULT;
/** Add \a storage to the end of \a batch. storage->md is
assumed to be valid.
\a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around
for the lifetime of the call. */
-grpc_error *grpc_metadata_batch_link_tail(
- grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage)
+ GRPC_MUST_USE_RESULT;
/** Add \a elem_to_add as the first element in \a batch, using
\a storage as backing storage for the linked list element.
@@ -104,49 +95,45 @@ grpc_error *grpc_metadata_batch_link_tail(
lifetime of batch. This usually means it should be around
for the lifetime of the call.
Takes ownership of \a elem_to_add */
-grpc_error *grpc_metadata_batch_add_head(
- grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_metadata_batch_add_head(
+ grpc_metadata_batch* batch, grpc_linked_mdelem* storage,
+ grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
/** Add \a elem_to_add as the last element in \a batch, using
\a storage as backing storage for the linked list element.
\a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around
for the lifetime of the call.
Takes ownership of \a elem_to_add */
-grpc_error *grpc_metadata_batch_add_tail(
- grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
- grpc_linked_mdelem *storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_metadata_batch_add_tail(
+ grpc_metadata_batch* batch, grpc_linked_mdelem* storage,
+ grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
-grpc_error *grpc_attach_md_to_error(grpc_error *src, grpc_mdelem md);
+grpc_error* grpc_attach_md_to_error(grpc_error* src, grpc_mdelem md);
typedef struct {
- grpc_error *error;
+ grpc_error* error;
grpc_mdelem md;
} grpc_filtered_mdelem;
#define GRPC_FILTERED_ERROR(error) \
- ((grpc_filtered_mdelem){(error), GRPC_MDNULL})
-#define GRPC_FILTERED_MDELEM(md) ((grpc_filtered_mdelem){GRPC_ERROR_NONE, (md)})
+ { (error), GRPC_MDNULL }
+#define GRPC_FILTERED_MDELEM(md) \
+ { GRPC_ERROR_NONE, (md) }
#define GRPC_FILTERED_REMOVE() \
- ((grpc_filtered_mdelem){GRPC_ERROR_NONE, GRPC_MDNULL})
+ { GRPC_ERROR_NONE, GRPC_MDNULL }
typedef grpc_filtered_mdelem (*grpc_metadata_batch_filter_func)(
- grpc_exec_ctx *exec_ctx, void *user_data, grpc_mdelem elem);
-grpc_error *grpc_metadata_batch_filter(
- grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
- grpc_metadata_batch_filter_func func, void *user_data,
- const char *composite_error_string) GRPC_MUST_USE_RESULT;
+ void* user_data, grpc_mdelem elem);
+grpc_error* grpc_metadata_batch_filter(
+ grpc_metadata_batch* batch, grpc_metadata_batch_filter_func func,
+ void* user_data, const char* composite_error_string) GRPC_MUST_USE_RESULT;
#ifndef NDEBUG
-void grpc_metadata_batch_assert_ok(grpc_metadata_batch *comd);
+void grpc_metadata_batch_assert_ok(grpc_metadata_batch* comd);
#else
#define grpc_metadata_batch_assert_ok(comd) \
do { \
} while (0)
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H */
diff --git a/src/core/lib/transport/pid_controller.c b/src/core/lib/transport/pid_controller.c
deleted file mode 100644
index 4b304f17b2..0000000000
--- a/src/core/lib/transport/pid_controller.c
+++ /dev/null
@@ -1,63 +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 "src/core/lib/transport/pid_controller.h"
-#include <grpc/support/useful.h>
-
-void grpc_pid_controller_init(grpc_pid_controller *pid_controller,
- grpc_pid_controller_args args) {
- pid_controller->args = args;
- pid_controller->last_control_value = args.initial_control_value;
- grpc_pid_controller_reset(pid_controller);
-}
-
-void grpc_pid_controller_reset(grpc_pid_controller *pid_controller) {
- pid_controller->last_error = 0.0;
- pid_controller->last_dc_dt = 0.0;
- pid_controller->error_integral = 0.0;
-}
-
-double grpc_pid_controller_update(grpc_pid_controller *pid_controller,
- double error, double dt) {
- if (dt == 0) return pid_controller->last_control_value;
- /* integrate error using the trapezoid rule */
- pid_controller->error_integral +=
- dt * (pid_controller->last_error + error) * 0.5;
- pid_controller->error_integral = GPR_CLAMP(
- pid_controller->error_integral, -pid_controller->args.integral_range,
- pid_controller->args.integral_range);
- double diff_error = (error - pid_controller->last_error) / dt;
- /* calculate derivative of control value vs time */
- double dc_dt = pid_controller->args.gain_p * error +
- pid_controller->args.gain_i * pid_controller->error_integral +
- pid_controller->args.gain_d * diff_error;
- /* and perform trapezoidal integration */
- double new_control_value = pid_controller->last_control_value +
- dt * (pid_controller->last_dc_dt + dc_dt) * 0.5;
- new_control_value =
- GPR_CLAMP(new_control_value, pid_controller->args.min_control_value,
- pid_controller->args.max_control_value);
- pid_controller->last_error = error;
- pid_controller->last_dc_dt = dc_dt;
- pid_controller->last_control_value = new_control_value;
- return new_control_value;
-}
-
-double grpc_pid_controller_last(grpc_pid_controller *pid_controller) {
- return pid_controller->last_control_value;
-}
diff --git a/src/core/lib/transport/pid_controller.cc b/src/core/lib/transport/pid_controller.cc
new file mode 100644
index 0000000000..e31cc85f76
--- /dev/null
+++ b/src/core/lib/transport/pid_controller.cc
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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 "src/core/lib/transport/pid_controller.h"
+#include <grpc/support/useful.h>
+
+namespace grpc_core {
+
+PidController::PidController(const Args& args)
+ : last_control_value_(args.initial_control_value()), args_(args) {}
+
+double PidController::Update(double error, double dt) {
+ if (dt <= 0) return last_control_value_;
+ /* integrate error using the trapezoid rule */
+ error_integral_ += dt * (last_error_ + error) * 0.5;
+ error_integral_ = GPR_CLAMP(error_integral_, -args_.integral_range(),
+ args_.integral_range());
+ double diff_error = (error - last_error_) / dt;
+ /* calculate derivative of control value vs time */
+ double dc_dt = args_.gain_p() * error + args_.gain_i() * error_integral_ +
+ args_.gain_d() * diff_error;
+ /* and perform trapezoidal integration */
+ double new_control_value =
+ last_control_value_ + dt * (last_dc_dt_ + dc_dt) * 0.5;
+ new_control_value = GPR_CLAMP(new_control_value, args_.min_control_value(),
+ args_.max_control_value());
+ last_error_ = error;
+ last_dc_dt_ = dc_dt;
+ last_control_value_ = new_control_value;
+ return new_control_value;
+}
+
+} // namespace grpc_core
diff --git a/src/core/lib/transport/pid_controller.h b/src/core/lib/transport/pid_controller.h
index 9352b2643f..87e59a1a90 100644
--- a/src/core/lib/transport/pid_controller.h
+++ b/src/core/lib/transport/pid_controller.h
@@ -19,6 +19,8 @@
#ifndef GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H
#define GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H
+#include <limits>
+
/* \file Simple PID controller.
Implements a proportional-integral-derivative controller.
Used when we want to iteratively control a variable to converge some other
@@ -26,37 +28,87 @@
Gains can be set to adjust sensitivity to current error (p), the integral
of error (i), and the derivative of error (d). */
-typedef struct {
- double gain_p;
- double gain_i;
- double gain_d;
- double initial_control_value;
- double min_control_value;
- double max_control_value;
- double integral_range;
-} grpc_pid_controller_args;
-
-typedef struct {
- double last_error;
- double error_integral;
- double last_control_value;
- double last_dc_dt;
- grpc_pid_controller_args args;
-} grpc_pid_controller;
-
-/** Initialize the controller */
-void grpc_pid_controller_init(grpc_pid_controller *pid_controller,
- grpc_pid_controller_args args);
-
-/** Reset the controller: useful when things have changed significantly */
-void grpc_pid_controller_reset(grpc_pid_controller *pid_controller);
-
-/** Update the controller: given a current error estimate, and the time since
- the last update, returns a new control value */
-double grpc_pid_controller_update(grpc_pid_controller *pid_controller,
- double error, double dt);
-
-/** Returns the last control value calculated */
-double grpc_pid_controller_last(grpc_pid_controller *pid_controller);
+namespace grpc_core {
+
+class PidController {
+ public:
+ class Args {
+ public:
+ double gain_p() const { return gain_p_; }
+ double gain_i() const { return gain_i_; }
+ double gain_d() const { return gain_d_; }
+ double initial_control_value() const { return initial_control_value_; }
+ double min_control_value() const { return min_control_value_; }
+ double max_control_value() const { return max_control_value_; }
+ double integral_range() const { return integral_range_; }
+
+ Args& set_gain_p(double gain_p) {
+ gain_p_ = gain_p;
+ return *this;
+ }
+ Args& set_gain_i(double gain_i) {
+ gain_i_ = gain_i;
+ return *this;
+ }
+ Args& set_gain_d(double gain_d) {
+ gain_d_ = gain_d;
+ return *this;
+ }
+ Args& set_initial_control_value(double initial_control_value) {
+ initial_control_value_ = initial_control_value;
+ return *this;
+ }
+ Args& set_min_control_value(double min_control_value) {
+ min_control_value_ = min_control_value;
+ return *this;
+ }
+ Args& set_max_control_value(double max_control_value) {
+ max_control_value_ = max_control_value;
+ return *this;
+ }
+ Args& set_integral_range(double integral_range) {
+ integral_range_ = integral_range;
+ return *this;
+ }
+
+ private:
+ double gain_p_ = 0.0;
+ double gain_i_ = 0.0;
+ double gain_d_ = 0.0;
+ double initial_control_value_ = 0.0;
+ double min_control_value_ = std::numeric_limits<double>::min();
+ double max_control_value_ = std::numeric_limits<double>::max();
+ double integral_range_ = std::numeric_limits<double>::max();
+ };
+
+ explicit PidController(const Args& args);
+
+ /// Reset the controller internal state: useful when the environment has
+ /// changed significantly
+ void Reset() {
+ last_error_ = 0.0;
+ last_dc_dt_ = 0.0;
+ error_integral_ = 0.0;
+ }
+
+ /// Update the controller: given a current error estimate, and the time since
+ /// the last update, returns a new control value
+ double Update(double error, double dt);
+
+ /// Returns the last control value calculated
+ double last_control_value() const { return last_control_value_; }
+
+ /// Returns the current error integral (mostly for testing)
+ double error_integral() const { return error_integral_; }
+
+ private:
+ double last_error_ = 0.0;
+ double error_integral_ = 0.0;
+ double last_control_value_;
+ double last_dc_dt_ = 0.0;
+ const Args args_;
+};
+
+} // namespace grpc_core
#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */
diff --git a/src/core/lib/transport/service_config.c b/src/core/lib/transport/service_config.cc
index 070a13a2b4..5c9930a273 100644
--- a/src/core/lib/transport/service_config.c
+++ b/src/core/lib/transport/service_config.cc
@@ -23,11 +23,11 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/json/json.h"
#include "src/core/lib/slice/slice_hash_table.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
// The main purpose of the code here is to parse the service config in
// JSON form, which will look like this:
@@ -64,11 +64,11 @@ grpc_service_config* grpc_service_config_create(const char* json_string) {
service_config->json_string = gpr_strdup(json_string);
service_config->json_tree =
grpc_json_parse_string(service_config->json_string);
- if (service_config->json_tree == NULL) {
+ if (service_config->json_tree == nullptr) {
gpr_log(GPR_INFO, "failed to parse JSON for service config");
gpr_free(service_config->json_string);
gpr_free(service_config);
- return NULL;
+ return nullptr;
}
return service_config;
}
@@ -83,9 +83,9 @@ void grpc_service_config_parse_global_params(
const grpc_service_config* service_config,
void (*process_json)(const grpc_json* json, void* arg), void* arg) {
const grpc_json* json = service_config->json_tree;
- if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) return;
+ if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) return;
if (strcmp(field->key, "methodConfig") == 0) continue;
process_json(field, arg);
}
@@ -94,13 +94,13 @@ void grpc_service_config_parse_global_params(
const char* grpc_service_config_get_lb_policy_name(
const grpc_service_config* service_config) {
const grpc_json* json = service_config->json_tree;
- if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL;
- const char* lb_policy_name = NULL;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) return NULL;
+ if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr;
+ const char* lb_policy_name = nullptr;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) return nullptr;
if (strcmp(field->key, "loadBalancingPolicy") == 0) {
- if (lb_policy_name != NULL) return NULL; // Duplicate.
- if (field->type != GRPC_JSON_STRING) return NULL;
+ if (lb_policy_name != nullptr) return nullptr; // Duplicate.
+ if (field->type != GRPC_JSON_STRING) return nullptr;
lb_policy_name = field->value;
}
}
@@ -110,8 +110,14 @@ const char* grpc_service_config_get_lb_policy_name(
// Returns the number of names specified in the method config \a json.
static size_t count_names_in_method_config_json(grpc_json* json) {
size_t num_names = 0;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key != NULL && strcmp(field->key, "name") == 0) ++num_names;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key != nullptr && strcmp(field->key, "name") == 0) {
+ if (field->type != GRPC_JSON_ARRAY) return -1;
+ for (grpc_json* name = field->child; name != nullptr; name = name->next) {
+ if (name->type != GRPC_JSON_OBJECT) return -1;
+ ++num_names;
+ }
+ }
}
return num_names;
}
@@ -119,26 +125,26 @@ static size_t count_names_in_method_config_json(grpc_json* json) {
// Returns a path string for the JSON name object specified by \a json.
// Returns NULL on error. Caller takes ownership of result.
static char* parse_json_method_name(grpc_json* json) {
- if (json->type != GRPC_JSON_OBJECT) return NULL;
- const char* service_name = NULL;
- const char* method_name = NULL;
- for (grpc_json* child = json->child; child != NULL; child = child->next) {
- if (child->key == NULL) return NULL;
- if (child->type != GRPC_JSON_STRING) return NULL;
+ if (json->type != GRPC_JSON_OBJECT) return nullptr;
+ const char* service_name = nullptr;
+ const char* method_name = nullptr;
+ for (grpc_json* child = json->child; child != nullptr; child = child->next) {
+ if (child->key == nullptr) return nullptr;
+ if (child->type != GRPC_JSON_STRING) return nullptr;
if (strcmp(child->key, "service") == 0) {
- if (service_name != NULL) return NULL; // Duplicate.
- if (child->value == NULL) return NULL;
+ if (service_name != nullptr) return nullptr; // Duplicate.
+ if (child->value == nullptr) return nullptr;
service_name = child->value;
} else if (strcmp(child->key, "method") == 0) {
- if (method_name != NULL) return NULL; // Duplicate.
- if (child->value == NULL) return NULL;
+ if (method_name != nullptr) return nullptr; // Duplicate.
+ if (child->value == nullptr) return nullptr;
method_name = child->value;
}
}
- if (service_name == NULL) return NULL; // Required field.
+ if (service_name == nullptr) return nullptr; // Required field.
char* path;
gpr_asprintf(&path, "/%s/%s", service_name,
- method_name == NULL ? "*" : method_name);
+ method_name == nullptr ? "*" : method_name);
return path;
}
@@ -146,22 +152,23 @@ static char* parse_json_method_name(grpc_json* json) {
// each name found, incrementing \a idx for each entry added.
// Returns false on error.
static bool parse_json_method_config(
- grpc_exec_ctx* exec_ctx, grpc_json* json,
- void* (*create_value)(const grpc_json* method_config_json),
+ grpc_json* json, void* (*create_value)(const grpc_json* method_config_json),
+ void* (*ref_value)(void* value), void (*unref_value)(void* value),
grpc_slice_hash_table_entry* entries, size_t* idx) {
// Construct value.
void* method_config = create_value(json);
- if (method_config == NULL) return false;
+ if (method_config == nullptr) return false;
// Construct list of paths.
bool success = false;
gpr_strvec paths;
gpr_strvec_init(&paths);
- for (grpc_json* child = json->child; child != NULL; child = child->next) {
- if (child->key == NULL) continue;
+ for (grpc_json* child = json->child; child != nullptr; child = child->next) {
+ if (child->key == nullptr) continue;
if (strcmp(child->key, "name") == 0) {
if (child->type != GRPC_JSON_ARRAY) goto done;
- for (grpc_json* name = child->child; name != NULL; name = name->next) {
+ for (grpc_json* name = child->child; name != nullptr; name = name->next) {
char* path = parse_json_method_name(name);
+ if (path == nullptr) goto done;
gpr_strvec_add(&paths, path);
}
}
@@ -170,65 +177,72 @@ static bool parse_json_method_config(
// Add entry for each path.
for (size_t i = 0; i < paths.count; ++i) {
entries[*idx].key = grpc_slice_from_copied_string(paths.strs[i]);
- entries[*idx].value = method_config;
+ entries[*idx].value = ref_value(method_config);
++*idx;
}
success = true;
done:
+ unref_value(method_config);
gpr_strvec_destroy(&paths);
return success;
}
grpc_slice_hash_table* grpc_service_config_create_method_config_table(
- grpc_exec_ctx* exec_ctx, const grpc_service_config* service_config,
+ const grpc_service_config* service_config,
void* (*create_value)(const grpc_json* method_config_json),
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value)) {
+ void* (*ref_value)(void* value), void (*unref_value)(void* value)) {
const grpc_json* json = service_config->json_tree;
// Traverse parsed JSON tree.
- if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL;
+ if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr;
size_t num_entries = 0;
- grpc_slice_hash_table_entry* entries = NULL;
- for (grpc_json* field = json->child; field != NULL; field = field->next) {
- if (field->key == NULL) return NULL;
+ grpc_slice_hash_table_entry* entries = nullptr;
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
+ if (field->key == nullptr) return nullptr;
if (strcmp(field->key, "methodConfig") == 0) {
- if (entries != NULL) return NULL; // Duplicate.
- if (field->type != GRPC_JSON_ARRAY) return NULL;
+ if (entries != nullptr) return nullptr; // Duplicate.
+ if (field->type != GRPC_JSON_ARRAY) return nullptr;
// Find number of entries.
- for (grpc_json* method = field->child; method != NULL;
+ for (grpc_json* method = field->child; method != nullptr;
method = method->next) {
- num_entries += count_names_in_method_config_json(method);
+ size_t count = count_names_in_method_config_json(method);
+ if (count <= 0) return nullptr;
+ num_entries += count;
}
// Populate method config table entries.
entries = (grpc_slice_hash_table_entry*)gpr_malloc(
num_entries * sizeof(grpc_slice_hash_table_entry));
size_t idx = 0;
- for (grpc_json* method = field->child; method != NULL;
+ for (grpc_json* method = field->child; method != nullptr;
method = method->next) {
- if (!parse_json_method_config(exec_ctx, method, create_value, entries,
- &idx)) {
- return NULL;
+ if (!parse_json_method_config(method, create_value, ref_value,
+ unref_value, entries, &idx)) {
+ for (size_t i = 0; i < idx; ++i) {
+ grpc_slice_unref_internal(entries[i].key);
+ unref_value(entries[i].value);
+ }
+ gpr_free(entries);
+ return nullptr;
}
}
GPR_ASSERT(idx == num_entries);
}
}
// Instantiate method config table.
- grpc_slice_hash_table* method_config_table = NULL;
- if (entries != NULL) {
- method_config_table =
- grpc_slice_hash_table_create(num_entries, entries, destroy_value, NULL);
+ grpc_slice_hash_table* method_config_table = nullptr;
+ if (entries != nullptr) {
+ method_config_table = grpc_slice_hash_table_create(num_entries, entries,
+ unref_value, nullptr);
gpr_free(entries);
}
return method_config_table;
}
-void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
- const grpc_slice_hash_table* table,
+void* grpc_method_config_table_get(const grpc_slice_hash_table* table,
grpc_slice path) {
void* value = grpc_slice_hash_table_get(table, path);
// If we didn't find a match for the path, try looking for a wildcard
// entry (i.e., change "/service/method" to "/service/*").
- if (value == NULL) {
+ if (value == nullptr) {
char* path_str = grpc_slice_to_c_string(path);
const char* sep = strrchr(path_str, '/') + 1;
const size_t len = (size_t)(sep - path_str);
@@ -239,7 +253,7 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
grpc_slice wildcard_path = grpc_slice_from_copied_string(buf);
gpr_free(buf);
value = grpc_slice_hash_table_get(table, wildcard_path);
- grpc_slice_unref_internal(exec_ctx, wildcard_path);
+ grpc_slice_unref_internal(wildcard_path);
gpr_free(path_str);
}
return value;
diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h
index 84110abc36..98554b9f0f 100644
--- a/src/core/lib/transport/service_config.h
+++ b/src/core/lib/transport/service_config.h
@@ -42,12 +42,12 @@ const char* grpc_service_config_get_lb_policy_name(
/// Creates a method config table based on the data in \a json.
/// The table's keys are request paths. The table's value type is
/// returned by \a create_value(), based on data parsed from the JSON tree.
-/// \a destroy_value is used to clean up values.
+/// \a ref_value() and \a unref_value() are used to ref and unref values.
/// Returns NULL on error.
grpc_slice_hash_table* grpc_service_config_create_method_config_table(
- grpc_exec_ctx* exec_ctx, const grpc_service_config* service_config,
+ const grpc_service_config* service_config,
void* (*create_value)(const grpc_json* method_config_json),
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value));
+ void* (*ref_value)(void* value), void (*unref_value)(void* value));
/// A helper function for looking up values in the table returned by
/// \a grpc_service_config_create_method_config_table().
@@ -55,8 +55,7 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
/// the form "/service/method".
/// Returns NULL if the method has no config.
/// Caller does NOT own a reference to the result.
-void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
- const grpc_slice_hash_table* table,
+void* grpc_method_config_table_get(const grpc_slice_hash_table* table,
grpc_slice path);
#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */
diff --git a/src/core/lib/transport/static_metadata.c b/src/core/lib/transport/static_metadata.cc
index 472cf888ea..82ba7ac51a 100644
--- a/src/core/lib/transport/static_metadata.c
+++ b/src/core/lib/transport/static_metadata.cc
@@ -57,54 +57,56 @@ static uint8_t g_bytes[] = {
112, 111, 110, 115, 101, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98,
121, 116, 101, 115, 47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49,
46, 76, 111, 97, 100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66,
- 97, 108, 97, 110, 99, 101, 76, 111, 97, 100, 48, 49, 50, 105, 100,
- 101, 110, 116, 105, 116, 121, 103, 122, 105, 112, 100, 101, 102, 108, 97,
- 116, 101, 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105,
- 99, 97, 116, 105, 111, 110, 47, 103, 114, 112, 99, 80, 79, 83, 84,
- 50, 48, 48, 52, 48, 52, 104, 116, 116, 112, 104, 116, 116, 112, 115,
- 103, 114, 112, 99, 71, 69, 84, 80, 85, 84, 47, 47, 105, 110, 100,
- 101, 120, 46, 104, 116, 109, 108, 50, 48, 52, 50, 48, 54, 51, 48,
- 52, 52, 48, 48, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99,
- 104, 97, 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102,
- 108, 97, 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103,
- 117, 97, 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103,
- 101, 115, 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45,
- 99, 111, 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111,
- 114, 105, 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117,
- 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104,
- 101, 45, 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110,
- 116, 45, 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111,
- 110, 116, 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99,
- 111, 110, 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111,
- 110, 116, 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99,
- 111, 110, 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111,
- 107, 105, 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101,
- 99, 116, 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102,
- 45, 109, 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105,
- 101, 100, 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101,
- 45, 109, 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105,
- 102, 45, 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105,
- 110, 99, 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101,
- 100, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 108, 105, 110,
- 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45, 102, 111,
- 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97, 117, 116,
- 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120, 121, 45,
- 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 114, 97,
- 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102, 114, 101,
- 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114, 115, 101,
- 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105, 101, 115,
- 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111, 114, 116,
- 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110, 115, 102,
- 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97, 114, 121,
- 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110, 116, 105,
- 99, 97, 116, 101, 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, 101,
- 102, 108, 97, 116, 101, 105, 100, 101, 110, 116, 105, 116, 121, 44, 103,
- 122, 105, 112, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112,
- 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116,
- 101, 44, 103, 122, 105, 112};
+ 97, 108, 97, 110, 99, 101, 76, 111, 97, 100, 109, 101, 115, 115, 97,
+ 103, 101, 47, 100, 101, 102, 108, 97, 116, 101, 109, 101, 115, 115, 97,
+ 103, 101, 47, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103,
+ 122, 105, 112, 48, 49, 50, 105, 100, 101, 110, 116, 105, 116, 121, 103,
+ 122, 105, 112, 100, 101, 102, 108, 97, 116, 101, 116, 114, 97, 105, 108,
+ 101, 114, 115, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47,
+ 103, 114, 112, 99, 80, 79, 83, 84, 50, 48, 48, 52, 48, 52, 104,
+ 116, 116, 112, 104, 116, 116, 112, 115, 103, 114, 112, 99, 71, 69, 84,
+ 80, 85, 84, 47, 47, 105, 110, 100, 101, 120, 46, 104, 116, 109, 108,
+ 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 53, 48, 48,
+ 97, 99, 99, 101, 112, 116, 45, 99, 104, 97, 114, 115, 101, 116, 103,
+ 122, 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, 101, 97, 99, 99,
+ 101, 112, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 97, 99, 99,
+ 101, 112, 116, 45, 114, 97, 110, 103, 101, 115, 97, 99, 99, 101, 112,
+ 116, 97, 99, 99, 101, 115, 115, 45, 99, 111, 110, 116, 114, 111, 108,
+ 45, 97, 108, 108, 111, 119, 45, 111, 114, 105, 103, 105, 110, 97, 103,
+ 101, 97, 108, 108, 111, 119, 97, 117, 116, 104, 111, 114, 105, 122, 97,
+ 116, 105, 111, 110, 99, 97, 99, 104, 101, 45, 99, 111, 110, 116, 114,
+ 111, 108, 99, 111, 110, 116, 101, 110, 116, 45, 100, 105, 115, 112, 111,
+ 115, 105, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, 45, 108,
+ 97, 110, 103, 117, 97, 103, 101, 99, 111, 110, 116, 101, 110, 116, 45,
+ 108, 101, 110, 103, 116, 104, 99, 111, 110, 116, 101, 110, 116, 45, 108,
+ 111, 99, 97, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, 45,
+ 114, 97, 110, 103, 101, 99, 111, 111, 107, 105, 101, 100, 97, 116, 101,
+ 101, 116, 97, 103, 101, 120, 112, 101, 99, 116, 101, 120, 112, 105, 114,
+ 101, 115, 102, 114, 111, 109, 105, 102, 45, 109, 97, 116, 99, 104, 105,
+ 102, 45, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99,
+ 101, 105, 102, 45, 110, 111, 110, 101, 45, 109, 97, 116, 99, 104, 105,
+ 102, 45, 114, 97, 110, 103, 101, 105, 102, 45, 117, 110, 109, 111, 100,
+ 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, 108, 97, 115, 116,
+ 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 98, 45, 99, 111, 115,
+ 116, 45, 98, 105, 110, 108, 105, 110, 107, 108, 111, 99, 97, 116, 105,
+ 111, 110, 109, 97, 120, 45, 102, 111, 114, 119, 97, 114, 100, 115, 112,
+ 114, 111, 120, 121, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97,
+ 116, 101, 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, 111, 114, 105,
+ 122, 97, 116, 105, 111, 110, 114, 97, 110, 103, 101, 114, 101, 102, 101,
+ 114, 101, 114, 114, 101, 102, 114, 101, 115, 104, 114, 101, 116, 114, 121,
+ 45, 97, 102, 116, 101, 114, 115, 101, 114, 118, 101, 114, 115, 101, 116,
+ 45, 99, 111, 111, 107, 105, 101, 115, 116, 114, 105, 99, 116, 45, 116,
+ 114, 97, 110, 115, 112, 111, 114, 116, 45, 115, 101, 99, 117, 114, 105,
+ 116, 121, 116, 114, 97, 110, 115, 102, 101, 114, 45, 101, 110, 99, 111,
+ 100, 105, 110, 103, 118, 97, 114, 121, 118, 105, 97, 119, 119, 119, 45,
+ 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 105, 100, 101,
+ 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100,
+ 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108,
+ 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116,
+ 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112};
-static void static_ref(void *unused) {}
-static void static_unref(grpc_exec_ctx *exec_ctx, void *unused) {}
+static void static_ref(void* unused) {}
+static void static_unref(void* unused) {}
static const grpc_slice_refcount_vtable static_sub_vtable = {
static_ref, static_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
@@ -213,6 +215,9 @@ grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = {
{&grpc_static_metadata_vtable, &static_sub_refcnt},
{&grpc_static_metadata_vtable, &static_sub_refcnt},
{&grpc_static_metadata_vtable, &static_sub_refcnt},
+ {&grpc_static_metadata_vtable, &static_sub_refcnt},
+ {&grpc_static_metadata_vtable, &static_sub_refcnt},
+ {&grpc_static_metadata_vtable, &static_sub_refcnt},
};
const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = {
@@ -245,77 +250,80 @@ const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = {
{&grpc_static_metadata_refcounts[26], {{g_bytes + 333, 30}}},
{&grpc_static_metadata_refcounts[27], {{g_bytes + 363, 31}}},
{&grpc_static_metadata_refcounts[28], {{g_bytes + 394, 36}}},
- {&grpc_static_metadata_refcounts[29], {{g_bytes + 430, 1}}},
- {&grpc_static_metadata_refcounts[30], {{g_bytes + 431, 1}}},
- {&grpc_static_metadata_refcounts[31], {{g_bytes + 432, 1}}},
- {&grpc_static_metadata_refcounts[32], {{g_bytes + 433, 8}}},
- {&grpc_static_metadata_refcounts[33], {{g_bytes + 441, 4}}},
- {&grpc_static_metadata_refcounts[34], {{g_bytes + 445, 7}}},
- {&grpc_static_metadata_refcounts[35], {{g_bytes + 452, 8}}},
- {&grpc_static_metadata_refcounts[36], {{g_bytes + 460, 16}}},
- {&grpc_static_metadata_refcounts[37], {{g_bytes + 476, 4}}},
- {&grpc_static_metadata_refcounts[38], {{g_bytes + 480, 3}}},
- {&grpc_static_metadata_refcounts[39], {{g_bytes + 483, 3}}},
- {&grpc_static_metadata_refcounts[40], {{g_bytes + 486, 4}}},
- {&grpc_static_metadata_refcounts[41], {{g_bytes + 490, 5}}},
- {&grpc_static_metadata_refcounts[42], {{g_bytes + 495, 4}}},
- {&grpc_static_metadata_refcounts[43], {{g_bytes + 499, 3}}},
- {&grpc_static_metadata_refcounts[44], {{g_bytes + 502, 3}}},
- {&grpc_static_metadata_refcounts[45], {{g_bytes + 505, 1}}},
- {&grpc_static_metadata_refcounts[46], {{g_bytes + 506, 11}}},
- {&grpc_static_metadata_refcounts[47], {{g_bytes + 517, 3}}},
- {&grpc_static_metadata_refcounts[48], {{g_bytes + 520, 3}}},
- {&grpc_static_metadata_refcounts[49], {{g_bytes + 523, 3}}},
- {&grpc_static_metadata_refcounts[50], {{g_bytes + 526, 3}}},
- {&grpc_static_metadata_refcounts[51], {{g_bytes + 529, 3}}},
- {&grpc_static_metadata_refcounts[52], {{g_bytes + 532, 14}}},
- {&grpc_static_metadata_refcounts[53], {{g_bytes + 546, 13}}},
- {&grpc_static_metadata_refcounts[54], {{g_bytes + 559, 15}}},
- {&grpc_static_metadata_refcounts[55], {{g_bytes + 574, 13}}},
- {&grpc_static_metadata_refcounts[56], {{g_bytes + 587, 6}}},
- {&grpc_static_metadata_refcounts[57], {{g_bytes + 593, 27}}},
- {&grpc_static_metadata_refcounts[58], {{g_bytes + 620, 3}}},
- {&grpc_static_metadata_refcounts[59], {{g_bytes + 623, 5}}},
- {&grpc_static_metadata_refcounts[60], {{g_bytes + 628, 13}}},
- {&grpc_static_metadata_refcounts[61], {{g_bytes + 641, 13}}},
- {&grpc_static_metadata_refcounts[62], {{g_bytes + 654, 19}}},
- {&grpc_static_metadata_refcounts[63], {{g_bytes + 673, 16}}},
- {&grpc_static_metadata_refcounts[64], {{g_bytes + 689, 14}}},
- {&grpc_static_metadata_refcounts[65], {{g_bytes + 703, 16}}},
- {&grpc_static_metadata_refcounts[66], {{g_bytes + 719, 13}}},
- {&grpc_static_metadata_refcounts[67], {{g_bytes + 732, 6}}},
- {&grpc_static_metadata_refcounts[68], {{g_bytes + 738, 4}}},
- {&grpc_static_metadata_refcounts[69], {{g_bytes + 742, 4}}},
- {&grpc_static_metadata_refcounts[70], {{g_bytes + 746, 6}}},
- {&grpc_static_metadata_refcounts[71], {{g_bytes + 752, 7}}},
- {&grpc_static_metadata_refcounts[72], {{g_bytes + 759, 4}}},
- {&grpc_static_metadata_refcounts[73], {{g_bytes + 763, 8}}},
- {&grpc_static_metadata_refcounts[74], {{g_bytes + 771, 17}}},
- {&grpc_static_metadata_refcounts[75], {{g_bytes + 788, 13}}},
+ {&grpc_static_metadata_refcounts[29], {{g_bytes + 430, 15}}},
+ {&grpc_static_metadata_refcounts[30], {{g_bytes + 445, 12}}},
+ {&grpc_static_metadata_refcounts[31], {{g_bytes + 457, 11}}},
+ {&grpc_static_metadata_refcounts[32], {{g_bytes + 468, 1}}},
+ {&grpc_static_metadata_refcounts[33], {{g_bytes + 469, 1}}},
+ {&grpc_static_metadata_refcounts[34], {{g_bytes + 470, 1}}},
+ {&grpc_static_metadata_refcounts[35], {{g_bytes + 471, 8}}},
+ {&grpc_static_metadata_refcounts[36], {{g_bytes + 479, 4}}},
+ {&grpc_static_metadata_refcounts[37], {{g_bytes + 483, 7}}},
+ {&grpc_static_metadata_refcounts[38], {{g_bytes + 490, 8}}},
+ {&grpc_static_metadata_refcounts[39], {{g_bytes + 498, 16}}},
+ {&grpc_static_metadata_refcounts[40], {{g_bytes + 514, 4}}},
+ {&grpc_static_metadata_refcounts[41], {{g_bytes + 518, 3}}},
+ {&grpc_static_metadata_refcounts[42], {{g_bytes + 521, 3}}},
+ {&grpc_static_metadata_refcounts[43], {{g_bytes + 524, 4}}},
+ {&grpc_static_metadata_refcounts[44], {{g_bytes + 528, 5}}},
+ {&grpc_static_metadata_refcounts[45], {{g_bytes + 533, 4}}},
+ {&grpc_static_metadata_refcounts[46], {{g_bytes + 537, 3}}},
+ {&grpc_static_metadata_refcounts[47], {{g_bytes + 540, 3}}},
+ {&grpc_static_metadata_refcounts[48], {{g_bytes + 543, 1}}},
+ {&grpc_static_metadata_refcounts[49], {{g_bytes + 544, 11}}},
+ {&grpc_static_metadata_refcounts[50], {{g_bytes + 555, 3}}},
+ {&grpc_static_metadata_refcounts[51], {{g_bytes + 558, 3}}},
+ {&grpc_static_metadata_refcounts[52], {{g_bytes + 561, 3}}},
+ {&grpc_static_metadata_refcounts[53], {{g_bytes + 564, 3}}},
+ {&grpc_static_metadata_refcounts[54], {{g_bytes + 567, 3}}},
+ {&grpc_static_metadata_refcounts[55], {{g_bytes + 570, 14}}},
+ {&grpc_static_metadata_refcounts[56], {{g_bytes + 584, 13}}},
+ {&grpc_static_metadata_refcounts[57], {{g_bytes + 597, 15}}},
+ {&grpc_static_metadata_refcounts[58], {{g_bytes + 612, 13}}},
+ {&grpc_static_metadata_refcounts[59], {{g_bytes + 625, 6}}},
+ {&grpc_static_metadata_refcounts[60], {{g_bytes + 631, 27}}},
+ {&grpc_static_metadata_refcounts[61], {{g_bytes + 658, 3}}},
+ {&grpc_static_metadata_refcounts[62], {{g_bytes + 661, 5}}},
+ {&grpc_static_metadata_refcounts[63], {{g_bytes + 666, 13}}},
+ {&grpc_static_metadata_refcounts[64], {{g_bytes + 679, 13}}},
+ {&grpc_static_metadata_refcounts[65], {{g_bytes + 692, 19}}},
+ {&grpc_static_metadata_refcounts[66], {{g_bytes + 711, 16}}},
+ {&grpc_static_metadata_refcounts[67], {{g_bytes + 727, 14}}},
+ {&grpc_static_metadata_refcounts[68], {{g_bytes + 741, 16}}},
+ {&grpc_static_metadata_refcounts[69], {{g_bytes + 757, 13}}},
+ {&grpc_static_metadata_refcounts[70], {{g_bytes + 770, 6}}},
+ {&grpc_static_metadata_refcounts[71], {{g_bytes + 776, 4}}},
+ {&grpc_static_metadata_refcounts[72], {{g_bytes + 780, 4}}},
+ {&grpc_static_metadata_refcounts[73], {{g_bytes + 784, 6}}},
+ {&grpc_static_metadata_refcounts[74], {{g_bytes + 790, 7}}},
+ {&grpc_static_metadata_refcounts[75], {{g_bytes + 797, 4}}},
{&grpc_static_metadata_refcounts[76], {{g_bytes + 801, 8}}},
- {&grpc_static_metadata_refcounts[77], {{g_bytes + 809, 19}}},
- {&grpc_static_metadata_refcounts[78], {{g_bytes + 828, 13}}},
- {&grpc_static_metadata_refcounts[79], {{g_bytes + 841, 11}}},
- {&grpc_static_metadata_refcounts[80], {{g_bytes + 852, 4}}},
- {&grpc_static_metadata_refcounts[81], {{g_bytes + 856, 8}}},
- {&grpc_static_metadata_refcounts[82], {{g_bytes + 864, 12}}},
- {&grpc_static_metadata_refcounts[83], {{g_bytes + 876, 18}}},
- {&grpc_static_metadata_refcounts[84], {{g_bytes + 894, 19}}},
- {&grpc_static_metadata_refcounts[85], {{g_bytes + 913, 5}}},
- {&grpc_static_metadata_refcounts[86], {{g_bytes + 918, 7}}},
- {&grpc_static_metadata_refcounts[87], {{g_bytes + 925, 7}}},
- {&grpc_static_metadata_refcounts[88], {{g_bytes + 932, 11}}},
- {&grpc_static_metadata_refcounts[89], {{g_bytes + 943, 6}}},
- {&grpc_static_metadata_refcounts[90], {{g_bytes + 949, 10}}},
- {&grpc_static_metadata_refcounts[91], {{g_bytes + 959, 25}}},
- {&grpc_static_metadata_refcounts[92], {{g_bytes + 984, 17}}},
- {&grpc_static_metadata_refcounts[93], {{g_bytes + 1001, 4}}},
- {&grpc_static_metadata_refcounts[94], {{g_bytes + 1005, 3}}},
- {&grpc_static_metadata_refcounts[95], {{g_bytes + 1008, 16}}},
- {&grpc_static_metadata_refcounts[96], {{g_bytes + 1024, 16}}},
- {&grpc_static_metadata_refcounts[97], {{g_bytes + 1040, 13}}},
- {&grpc_static_metadata_refcounts[98], {{g_bytes + 1053, 12}}},
- {&grpc_static_metadata_refcounts[99], {{g_bytes + 1065, 21}}},
+ {&grpc_static_metadata_refcounts[77], {{g_bytes + 809, 17}}},
+ {&grpc_static_metadata_refcounts[78], {{g_bytes + 826, 13}}},
+ {&grpc_static_metadata_refcounts[79], {{g_bytes + 839, 8}}},
+ {&grpc_static_metadata_refcounts[80], {{g_bytes + 847, 19}}},
+ {&grpc_static_metadata_refcounts[81], {{g_bytes + 866, 13}}},
+ {&grpc_static_metadata_refcounts[82], {{g_bytes + 879, 11}}},
+ {&grpc_static_metadata_refcounts[83], {{g_bytes + 890, 4}}},
+ {&grpc_static_metadata_refcounts[84], {{g_bytes + 894, 8}}},
+ {&grpc_static_metadata_refcounts[85], {{g_bytes + 902, 12}}},
+ {&grpc_static_metadata_refcounts[86], {{g_bytes + 914, 18}}},
+ {&grpc_static_metadata_refcounts[87], {{g_bytes + 932, 19}}},
+ {&grpc_static_metadata_refcounts[88], {{g_bytes + 951, 5}}},
+ {&grpc_static_metadata_refcounts[89], {{g_bytes + 956, 7}}},
+ {&grpc_static_metadata_refcounts[90], {{g_bytes + 963, 7}}},
+ {&grpc_static_metadata_refcounts[91], {{g_bytes + 970, 11}}},
+ {&grpc_static_metadata_refcounts[92], {{g_bytes + 981, 6}}},
+ {&grpc_static_metadata_refcounts[93], {{g_bytes + 987, 10}}},
+ {&grpc_static_metadata_refcounts[94], {{g_bytes + 997, 25}}},
+ {&grpc_static_metadata_refcounts[95], {{g_bytes + 1022, 17}}},
+ {&grpc_static_metadata_refcounts[96], {{g_bytes + 1039, 4}}},
+ {&grpc_static_metadata_refcounts[97], {{g_bytes + 1043, 3}}},
+ {&grpc_static_metadata_refcounts[98], {{g_bytes + 1046, 16}}},
+ {&grpc_static_metadata_refcounts[99], {{g_bytes + 1062, 16}}},
+ {&grpc_static_metadata_refcounts[100], {{g_bytes + 1078, 13}}},
+ {&grpc_static_metadata_refcounts[101], {{g_bytes + 1091, 12}}},
+ {&grpc_static_metadata_refcounts[102], {{g_bytes + 1103, 21}}},
};
uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
@@ -325,16 +333,16 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4};
static const int8_t elems_r[] = {
- 11, 9, -3, 0, 10, 27, -74, 28, 0, 14, -7, 0, 0, 0, 18, 8, -2,
- 0, 0, 13, 12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, -50, 0, -33, -55, -56, -57, -58, -57, 0, 40, 39, 38, 37, 36, 35, 34,
- 33, 32, 31, 30, 29, 28, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 22,
- 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 0};
+ 11, 9, -3, 0, 10, 25, -77, 26, 0, 11, -7, 0, 0, 0, 21, 14, 1,
+ 0, 0, 33, 12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, -56, 0, -36, -61, -60, -39, -63, -64, 0, 36, 35, 34, 33,
+ 34, 33, 32, 31, 31, 30, 29, 28, 27, 26, 26, 25, 25, 24, 23, 22, 21,
+ 20, 19, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 0};
static uint32_t elems_phash(uint32_t i) {
- i -= 45;
- uint32_t x = i % 98;
- uint32_t y = i / 98;
+ i -= 48;
+ uint32_t x = i % 101;
+ uint32_t y = i / 101;
uint32_t h = x;
if (y < GPR_ARRAY_SIZE(elems_r)) {
uint32_t delta = (uint32_t)elems_r[y];
@@ -344,31 +352,31 @@ static uint32_t elems_phash(uint32_t i) {
}
static const uint16_t elem_keys[] = {
- 1032, 1033, 1034, 247, 248, 249, 250, 251, 1623, 143, 144, 45,
- 46, 440, 441, 442, 1523, 1632, 1633, 932, 933, 934, 729, 730,
- 1423, 1532, 1533, 535, 731, 1923, 2023, 2123, 5223, 5523, 5623, 5723,
- 5823, 1436, 1653, 5923, 6023, 6123, 6223, 6323, 6423, 6523, 6623, 6723,
- 6823, 6923, 7023, 7123, 7223, 5423, 7323, 7423, 7523, 7623, 7723, 7823,
- 7923, 8023, 8123, 8223, 1096, 1097, 1098, 1099, 8323, 8423, 8523, 8623,
- 8723, 8823, 8923, 9023, 9123, 9223, 9323, 323, 9423, 9523, 1697, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 137, 238, 239, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
+ 1065, 1066, 1067, 256, 257, 258, 259, 260, 1671, 149, 150, 48,
+ 49, 455, 456, 457, 962, 963, 964, 1568, 1683, 1684, 753, 754,
+ 1465, 553, 755, 2083, 2186, 5688, 5997, 1580, 1581, 6100, 6306, 6409,
+ 6512, 6615, 6718, 6821, 1481, 1704, 6924, 7027, 7130, 7233, 1980, 7336,
+ 7439, 7542, 7645, 7748, 7851, 5894, 7954, 8057, 6203, 8160, 8263, 8366,
+ 8469, 8572, 8675, 8778, 1129, 1130, 1131, 1132, 8881, 8984, 9087, 9190,
+ 9293, 9396, 9499, 9602, 9705, 9808, 9911, 332, 10014, 10117, 0, 0,
+ 0, 1748, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 247,
+ 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0};
static const uint8_t elem_idxs[] = {
76, 79, 77, 19, 20, 21, 22, 23, 25, 15, 16, 17, 18, 11,
- 12, 13, 38, 83, 84, 3, 4, 5, 0, 1, 43, 36, 37, 6,
- 2, 72, 50, 57, 24, 28, 29, 30, 31, 7, 26, 32, 33, 34,
- 35, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 27, 51, 52,
- 53, 54, 55, 56, 58, 59, 60, 61, 78, 80, 81, 82, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 73, 14, 74, 75, 85, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 8, 9, 10};
+ 12, 13, 3, 4, 5, 38, 83, 84, 0, 1, 43, 6, 2, 50,
+ 57, 24, 28, 36, 37, 29, 31, 32, 33, 34, 35, 39, 7, 26,
+ 40, 41, 42, 44, 72, 45, 46, 47, 48, 49, 51, 27, 52, 53,
+ 30, 54, 55, 56, 58, 59, 60, 61, 78, 80, 81, 82, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 73, 14, 74, 75, 255, 255,
+ 255, 85, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 8, 9, 10};
grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {
if (a == -1 || b == -1) return GRPC_MDNULL;
- uint32_t k = (uint32_t)(a * 100 + b);
+ uint32_t k = (uint32_t)(a * 103 + b);
uint32_t h = elems_phash(k);
return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k &&
elem_idxs[h] != 255
@@ -379,177 +387,177 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {
grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {
{{&grpc_static_metadata_refcounts[7], {{g_bytes + 50, 11}}},
- {&grpc_static_metadata_refcounts[29], {{g_bytes + 430, 1}}}},
+ {&grpc_static_metadata_refcounts[32], {{g_bytes + 468, 1}}}},
{{&grpc_static_metadata_refcounts[7], {{g_bytes + 50, 11}}},
- {&grpc_static_metadata_refcounts[30], {{g_bytes + 431, 1}}}},
+ {&grpc_static_metadata_refcounts[33], {{g_bytes + 469, 1}}}},
{{&grpc_static_metadata_refcounts[7], {{g_bytes + 50, 11}}},
- {&grpc_static_metadata_refcounts[31], {{g_bytes + 432, 1}}}},
+ {&grpc_static_metadata_refcounts[34], {{g_bytes + 470, 1}}}},
{{&grpc_static_metadata_refcounts[9], {{g_bytes + 77, 13}}},
- {&grpc_static_metadata_refcounts[32], {{g_bytes + 433, 8}}}},
+ {&grpc_static_metadata_refcounts[35], {{g_bytes + 471, 8}}}},
{{&grpc_static_metadata_refcounts[9], {{g_bytes + 77, 13}}},
- {&grpc_static_metadata_refcounts[33], {{g_bytes + 441, 4}}}},
+ {&grpc_static_metadata_refcounts[36], {{g_bytes + 479, 4}}}},
{{&grpc_static_metadata_refcounts[9], {{g_bytes + 77, 13}}},
- {&grpc_static_metadata_refcounts[34], {{g_bytes + 445, 7}}}},
+ {&grpc_static_metadata_refcounts[37], {{g_bytes + 483, 7}}}},
{{&grpc_static_metadata_refcounts[5], {{g_bytes + 36, 2}}},
- {&grpc_static_metadata_refcounts[35], {{g_bytes + 452, 8}}}},
+ {&grpc_static_metadata_refcounts[38], {{g_bytes + 490, 8}}}},
{{&grpc_static_metadata_refcounts[14], {{g_bytes + 158, 12}}},
- {&grpc_static_metadata_refcounts[36], {{g_bytes + 460, 16}}}},
+ {&grpc_static_metadata_refcounts[39], {{g_bytes + 498, 16}}}},
{{&grpc_static_metadata_refcounts[1], {{g_bytes + 5, 7}}},
- {&grpc_static_metadata_refcounts[37], {{g_bytes + 476, 4}}}},
+ {&grpc_static_metadata_refcounts[40], {{g_bytes + 514, 4}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[38], {{g_bytes + 480, 3}}}},
+ {&grpc_static_metadata_refcounts[41], {{g_bytes + 518, 3}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[39], {{g_bytes + 483, 3}}}},
+ {&grpc_static_metadata_refcounts[42], {{g_bytes + 521, 3}}}},
{{&grpc_static_metadata_refcounts[4], {{g_bytes + 29, 7}}},
- {&grpc_static_metadata_refcounts[40], {{g_bytes + 486, 4}}}},
+ {&grpc_static_metadata_refcounts[43], {{g_bytes + 524, 4}}}},
{{&grpc_static_metadata_refcounts[4], {{g_bytes + 29, 7}}},
- {&grpc_static_metadata_refcounts[41], {{g_bytes + 490, 5}}}},
+ {&grpc_static_metadata_refcounts[44], {{g_bytes + 528, 5}}}},
{{&grpc_static_metadata_refcounts[4], {{g_bytes + 29, 7}}},
- {&grpc_static_metadata_refcounts[42], {{g_bytes + 495, 4}}}},
+ {&grpc_static_metadata_refcounts[45], {{g_bytes + 533, 4}}}},
{{&grpc_static_metadata_refcounts[3], {{g_bytes + 19, 10}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[1], {{g_bytes + 5, 7}}},
- {&grpc_static_metadata_refcounts[43], {{g_bytes + 499, 3}}}},
+ {&grpc_static_metadata_refcounts[46], {{g_bytes + 537, 3}}}},
{{&grpc_static_metadata_refcounts[1], {{g_bytes + 5, 7}}},
- {&grpc_static_metadata_refcounts[44], {{g_bytes + 502, 3}}}},
+ {&grpc_static_metadata_refcounts[47], {{g_bytes + 540, 3}}}},
{{&grpc_static_metadata_refcounts[0], {{g_bytes + 0, 5}}},
- {&grpc_static_metadata_refcounts[45], {{g_bytes + 505, 1}}}},
+ {&grpc_static_metadata_refcounts[48], {{g_bytes + 543, 1}}}},
{{&grpc_static_metadata_refcounts[0], {{g_bytes + 0, 5}}},
- {&grpc_static_metadata_refcounts[46], {{g_bytes + 506, 11}}}},
+ {&grpc_static_metadata_refcounts[49], {{g_bytes + 544, 11}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[47], {{g_bytes + 517, 3}}}},
+ {&grpc_static_metadata_refcounts[50], {{g_bytes + 555, 3}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[48], {{g_bytes + 520, 3}}}},
+ {&grpc_static_metadata_refcounts[51], {{g_bytes + 558, 3}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[49], {{g_bytes + 523, 3}}}},
+ {&grpc_static_metadata_refcounts[52], {{g_bytes + 561, 3}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[50], {{g_bytes + 526, 3}}}},
+ {&grpc_static_metadata_refcounts[53], {{g_bytes + 564, 3}}}},
{{&grpc_static_metadata_refcounts[2], {{g_bytes + 12, 7}}},
- {&grpc_static_metadata_refcounts[51], {{g_bytes + 529, 3}}}},
- {{&grpc_static_metadata_refcounts[52], {{g_bytes + 532, 14}}},
+ {&grpc_static_metadata_refcounts[54], {{g_bytes + 567, 3}}}},
+ {{&grpc_static_metadata_refcounts[55], {{g_bytes + 570, 14}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[16], {{g_bytes + 186, 15}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[16], {{g_bytes + 186, 15}}},
- {&grpc_static_metadata_refcounts[53], {{g_bytes + 546, 13}}}},
- {{&grpc_static_metadata_refcounts[54], {{g_bytes + 559, 15}}},
+ {&grpc_static_metadata_refcounts[56], {{g_bytes + 584, 13}}}},
+ {{&grpc_static_metadata_refcounts[57], {{g_bytes + 597, 15}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[55], {{g_bytes + 574, 13}}},
+ {{&grpc_static_metadata_refcounts[58], {{g_bytes + 612, 13}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[56], {{g_bytes + 587, 6}}},
+ {{&grpc_static_metadata_refcounts[59], {{g_bytes + 625, 6}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[57], {{g_bytes + 593, 27}}},
+ {{&grpc_static_metadata_refcounts[60], {{g_bytes + 631, 27}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[58], {{g_bytes + 620, 3}}},
+ {{&grpc_static_metadata_refcounts[61], {{g_bytes + 658, 3}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[59], {{g_bytes + 623, 5}}},
+ {{&grpc_static_metadata_refcounts[62], {{g_bytes + 661, 5}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[60], {{g_bytes + 628, 13}}},
+ {{&grpc_static_metadata_refcounts[63], {{g_bytes + 666, 13}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[61], {{g_bytes + 641, 13}}},
+ {{&grpc_static_metadata_refcounts[64], {{g_bytes + 679, 13}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[62], {{g_bytes + 654, 19}}},
+ {{&grpc_static_metadata_refcounts[65], {{g_bytes + 692, 19}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[15], {{g_bytes + 170, 16}}},
- {&grpc_static_metadata_refcounts[32], {{g_bytes + 433, 8}}}},
+ {&grpc_static_metadata_refcounts[35], {{g_bytes + 471, 8}}}},
{{&grpc_static_metadata_refcounts[15], {{g_bytes + 170, 16}}},
- {&grpc_static_metadata_refcounts[33], {{g_bytes + 441, 4}}}},
+ {&grpc_static_metadata_refcounts[36], {{g_bytes + 479, 4}}}},
{{&grpc_static_metadata_refcounts[15], {{g_bytes + 170, 16}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[63], {{g_bytes + 673, 16}}},
+ {{&grpc_static_metadata_refcounts[66], {{g_bytes + 711, 16}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[64], {{g_bytes + 689, 14}}},
+ {{&grpc_static_metadata_refcounts[67], {{g_bytes + 727, 14}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[65], {{g_bytes + 703, 16}}},
+ {{&grpc_static_metadata_refcounts[68], {{g_bytes + 741, 16}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[66], {{g_bytes + 719, 13}}},
+ {{&grpc_static_metadata_refcounts[69], {{g_bytes + 757, 13}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[14], {{g_bytes + 158, 12}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[67], {{g_bytes + 732, 6}}},
+ {{&grpc_static_metadata_refcounts[70], {{g_bytes + 770, 6}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[68], {{g_bytes + 738, 4}}},
+ {{&grpc_static_metadata_refcounts[71], {{g_bytes + 776, 4}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[69], {{g_bytes + 742, 4}}},
+ {{&grpc_static_metadata_refcounts[72], {{g_bytes + 780, 4}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[70], {{g_bytes + 746, 6}}},
+ {{&grpc_static_metadata_refcounts[73], {{g_bytes + 784, 6}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[71], {{g_bytes + 752, 7}}},
+ {{&grpc_static_metadata_refcounts[74], {{g_bytes + 790, 7}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[72], {{g_bytes + 759, 4}}},
+ {{&grpc_static_metadata_refcounts[75], {{g_bytes + 797, 4}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[20], {{g_bytes + 278, 4}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[73], {{g_bytes + 763, 8}}},
+ {{&grpc_static_metadata_refcounts[76], {{g_bytes + 801, 8}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[74], {{g_bytes + 771, 17}}},
+ {{&grpc_static_metadata_refcounts[77], {{g_bytes + 809, 17}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[75], {{g_bytes + 788, 13}}},
+ {{&grpc_static_metadata_refcounts[78], {{g_bytes + 826, 13}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[76], {{g_bytes + 801, 8}}},
+ {{&grpc_static_metadata_refcounts[79], {{g_bytes + 839, 8}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[77], {{g_bytes + 809, 19}}},
+ {{&grpc_static_metadata_refcounts[80], {{g_bytes + 847, 19}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[78], {{g_bytes + 828, 13}}},
+ {{&grpc_static_metadata_refcounts[81], {{g_bytes + 866, 13}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[21], {{g_bytes + 282, 8}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[79], {{g_bytes + 841, 11}}},
+ {{&grpc_static_metadata_refcounts[82], {{g_bytes + 879, 11}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[80], {{g_bytes + 852, 4}}},
+ {{&grpc_static_metadata_refcounts[83], {{g_bytes + 890, 4}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[81], {{g_bytes + 856, 8}}},
+ {{&grpc_static_metadata_refcounts[84], {{g_bytes + 894, 8}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[82], {{g_bytes + 864, 12}}},
+ {{&grpc_static_metadata_refcounts[85], {{g_bytes + 902, 12}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[83], {{g_bytes + 876, 18}}},
+ {{&grpc_static_metadata_refcounts[86], {{g_bytes + 914, 18}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[84], {{g_bytes + 894, 19}}},
+ {{&grpc_static_metadata_refcounts[87], {{g_bytes + 932, 19}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[85], {{g_bytes + 913, 5}}},
+ {{&grpc_static_metadata_refcounts[88], {{g_bytes + 951, 5}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[86], {{g_bytes + 918, 7}}},
+ {{&grpc_static_metadata_refcounts[89], {{g_bytes + 956, 7}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[87], {{g_bytes + 925, 7}}},
+ {{&grpc_static_metadata_refcounts[90], {{g_bytes + 963, 7}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[88], {{g_bytes + 932, 11}}},
+ {{&grpc_static_metadata_refcounts[91], {{g_bytes + 970, 11}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[89], {{g_bytes + 943, 6}}},
+ {{&grpc_static_metadata_refcounts[92], {{g_bytes + 981, 6}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[90], {{g_bytes + 949, 10}}},
+ {{&grpc_static_metadata_refcounts[93], {{g_bytes + 987, 10}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[91], {{g_bytes + 959, 25}}},
+ {{&grpc_static_metadata_refcounts[94], {{g_bytes + 997, 25}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[92], {{g_bytes + 984, 17}}},
+ {{&grpc_static_metadata_refcounts[95], {{g_bytes + 1022, 17}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[19], {{g_bytes + 268, 10}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[93], {{g_bytes + 1001, 4}}},
+ {{&grpc_static_metadata_refcounts[96], {{g_bytes + 1039, 4}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[94], {{g_bytes + 1005, 3}}},
+ {{&grpc_static_metadata_refcounts[97], {{g_bytes + 1043, 3}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
- {{&grpc_static_metadata_refcounts[95], {{g_bytes + 1008, 16}}},
+ {{&grpc_static_metadata_refcounts[98], {{g_bytes + 1046, 16}}},
{&grpc_static_metadata_refcounts[23], {{g_bytes + 302, 0}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[32], {{g_bytes + 433, 8}}}},
+ {&grpc_static_metadata_refcounts[35], {{g_bytes + 471, 8}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[34], {{g_bytes + 445, 7}}}},
+ {&grpc_static_metadata_refcounts[37], {{g_bytes + 483, 7}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[96], {{g_bytes + 1024, 16}}}},
+ {&grpc_static_metadata_refcounts[99], {{g_bytes + 1062, 16}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[33], {{g_bytes + 441, 4}}}},
+ {&grpc_static_metadata_refcounts[36], {{g_bytes + 479, 4}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[97], {{g_bytes + 1040, 13}}}},
+ {&grpc_static_metadata_refcounts[100], {{g_bytes + 1078, 13}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[98], {{g_bytes + 1053, 12}}}},
+ {&grpc_static_metadata_refcounts[101], {{g_bytes + 1091, 12}}}},
{{&grpc_static_metadata_refcounts[10], {{g_bytes + 90, 20}}},
- {&grpc_static_metadata_refcounts[99], {{g_bytes + 1065, 21}}}},
+ {&grpc_static_metadata_refcounts[102], {{g_bytes + 1103, 21}}}},
{{&grpc_static_metadata_refcounts[16], {{g_bytes + 186, 15}}},
- {&grpc_static_metadata_refcounts[32], {{g_bytes + 433, 8}}}},
+ {&grpc_static_metadata_refcounts[35], {{g_bytes + 471, 8}}}},
{{&grpc_static_metadata_refcounts[16], {{g_bytes + 186, 15}}},
- {&grpc_static_metadata_refcounts[33], {{g_bytes + 441, 4}}}},
+ {&grpc_static_metadata_refcounts[36], {{g_bytes + 479, 4}}}},
{{&grpc_static_metadata_refcounts[16], {{g_bytes + 186, 15}}},
- {&grpc_static_metadata_refcounts[97], {{g_bytes + 1040, 13}}}},
+ {&grpc_static_metadata_refcounts[100], {{g_bytes + 1078, 13}}}},
};
bool grpc_static_callout_is_default[GRPC_BATCH_CALLOUTS_COUNT] = {
true, // :path
diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h
index f03a9d23b1..21dc7a3d3f 100644
--- a/src/core/lib/transport/static_metadata.h
+++ b/src/core/lib/transport/static_metadata.h
@@ -29,7 +29,7 @@
#include "src/core/lib/transport/metadata.h"
-#define GRPC_STATIC_MDSTR_COUNT 100
+#define GRPC_STATIC_MDSTR_COUNT 103
extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];
/* ":path" */
#define GRPC_MDSTR_PATH (grpc_static_slice_table[0])
@@ -93,149 +93,155 @@ extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];
/* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */
#define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \
(grpc_static_slice_table[28])
+/* "message/deflate" */
+#define GRPC_MDSTR_MESSAGE_SLASH_DEFLATE (grpc_static_slice_table[29])
+/* "message/gzip" */
+#define GRPC_MDSTR_MESSAGE_SLASH_GZIP (grpc_static_slice_table[30])
+/* "stream/gzip" */
+#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[31])
/* "0" */
-#define GRPC_MDSTR_0 (grpc_static_slice_table[29])
+#define GRPC_MDSTR_0 (grpc_static_slice_table[32])
/* "1" */
-#define GRPC_MDSTR_1 (grpc_static_slice_table[30])
+#define GRPC_MDSTR_1 (grpc_static_slice_table[33])
/* "2" */
-#define GRPC_MDSTR_2 (grpc_static_slice_table[31])
+#define GRPC_MDSTR_2 (grpc_static_slice_table[34])
/* "identity" */
-#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[32])
+#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[35])
/* "gzip" */
-#define GRPC_MDSTR_GZIP (grpc_static_slice_table[33])
+#define GRPC_MDSTR_GZIP (grpc_static_slice_table[36])
/* "deflate" */
-#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[34])
+#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[37])
/* "trailers" */
-#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[35])
+#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[38])
/* "application/grpc" */
-#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[36])
+#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[39])
/* "POST" */
-#define GRPC_MDSTR_POST (grpc_static_slice_table[37])
+#define GRPC_MDSTR_POST (grpc_static_slice_table[40])
/* "200" */
-#define GRPC_MDSTR_200 (grpc_static_slice_table[38])
+#define GRPC_MDSTR_200 (grpc_static_slice_table[41])
/* "404" */
-#define GRPC_MDSTR_404 (grpc_static_slice_table[39])
+#define GRPC_MDSTR_404 (grpc_static_slice_table[42])
/* "http" */
-#define GRPC_MDSTR_HTTP (grpc_static_slice_table[40])
+#define GRPC_MDSTR_HTTP (grpc_static_slice_table[43])
/* "https" */
-#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[41])
+#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[44])
/* "grpc" */
-#define GRPC_MDSTR_GRPC (grpc_static_slice_table[42])
+#define GRPC_MDSTR_GRPC (grpc_static_slice_table[45])
/* "GET" */
-#define GRPC_MDSTR_GET (grpc_static_slice_table[43])
+#define GRPC_MDSTR_GET (grpc_static_slice_table[46])
/* "PUT" */
-#define GRPC_MDSTR_PUT (grpc_static_slice_table[44])
+#define GRPC_MDSTR_PUT (grpc_static_slice_table[47])
/* "/" */
-#define GRPC_MDSTR_SLASH (grpc_static_slice_table[45])
+#define GRPC_MDSTR_SLASH (grpc_static_slice_table[48])
/* "/index.html" */
-#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[46])
+#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[49])
/* "204" */
-#define GRPC_MDSTR_204 (grpc_static_slice_table[47])
+#define GRPC_MDSTR_204 (grpc_static_slice_table[50])
/* "206" */
-#define GRPC_MDSTR_206 (grpc_static_slice_table[48])
+#define GRPC_MDSTR_206 (grpc_static_slice_table[51])
/* "304" */
-#define GRPC_MDSTR_304 (grpc_static_slice_table[49])
+#define GRPC_MDSTR_304 (grpc_static_slice_table[52])
/* "400" */
-#define GRPC_MDSTR_400 (grpc_static_slice_table[50])
+#define GRPC_MDSTR_400 (grpc_static_slice_table[53])
/* "500" */
-#define GRPC_MDSTR_500 (grpc_static_slice_table[51])
+#define GRPC_MDSTR_500 (grpc_static_slice_table[54])
/* "accept-charset" */
-#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[52])
+#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[55])
/* "gzip, deflate" */
-#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[53])
+#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[56])
/* "accept-language" */
-#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[54])
+#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[57])
/* "accept-ranges" */
-#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[55])
+#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[58])
/* "accept" */
-#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[56])
+#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[59])
/* "access-control-allow-origin" */
-#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[57])
+#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[60])
/* "age" */
-#define GRPC_MDSTR_AGE (grpc_static_slice_table[58])
+#define GRPC_MDSTR_AGE (grpc_static_slice_table[61])
/* "allow" */
-#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[59])
+#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[62])
/* "authorization" */
-#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[60])
+#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[63])
/* "cache-control" */
-#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[61])
+#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[64])
/* "content-disposition" */
-#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[62])
+#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[65])
/* "content-language" */
-#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[63])
+#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[66])
/* "content-length" */
-#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[64])
+#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[67])
/* "content-location" */
-#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[65])
+#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[68])
/* "content-range" */
-#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[66])
+#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[69])
/* "cookie" */
-#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[67])
+#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[70])
/* "date" */
-#define GRPC_MDSTR_DATE (grpc_static_slice_table[68])
+#define GRPC_MDSTR_DATE (grpc_static_slice_table[71])
/* "etag" */
-#define GRPC_MDSTR_ETAG (grpc_static_slice_table[69])
+#define GRPC_MDSTR_ETAG (grpc_static_slice_table[72])
/* "expect" */
-#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[70])
+#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[73])
/* "expires" */
-#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[71])
+#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[74])
/* "from" */
-#define GRPC_MDSTR_FROM (grpc_static_slice_table[72])
+#define GRPC_MDSTR_FROM (grpc_static_slice_table[75])
/* "if-match" */
-#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[73])
+#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[76])
/* "if-modified-since" */
-#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[74])
+#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[77])
/* "if-none-match" */
-#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[75])
+#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[78])
/* "if-range" */
-#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[76])
+#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[79])
/* "if-unmodified-since" */
-#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[77])
+#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[80])
/* "last-modified" */
-#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[78])
+#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[81])
/* "lb-cost-bin" */
-#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[79])
+#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[82])
/* "link" */
-#define GRPC_MDSTR_LINK (grpc_static_slice_table[80])
+#define GRPC_MDSTR_LINK (grpc_static_slice_table[83])
/* "location" */
-#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[81])
+#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[84])
/* "max-forwards" */
-#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[82])
+#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[85])
/* "proxy-authenticate" */
-#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[83])
+#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[86])
/* "proxy-authorization" */
-#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[84])
+#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[87])
/* "range" */
-#define GRPC_MDSTR_RANGE (grpc_static_slice_table[85])
+#define GRPC_MDSTR_RANGE (grpc_static_slice_table[88])
/* "referer" */
-#define GRPC_MDSTR_REFERER (grpc_static_slice_table[86])
+#define GRPC_MDSTR_REFERER (grpc_static_slice_table[89])
/* "refresh" */
-#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[87])
+#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[90])
/* "retry-after" */
-#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[88])
+#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[91])
/* "server" */
-#define GRPC_MDSTR_SERVER (grpc_static_slice_table[89])
+#define GRPC_MDSTR_SERVER (grpc_static_slice_table[92])
/* "set-cookie" */
-#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[90])
+#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[93])
/* "strict-transport-security" */
-#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[91])
+#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[94])
/* "transfer-encoding" */
-#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[92])
+#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[95])
/* "vary" */
-#define GRPC_MDSTR_VARY (grpc_static_slice_table[93])
+#define GRPC_MDSTR_VARY (grpc_static_slice_table[96])
/* "via" */
-#define GRPC_MDSTR_VIA (grpc_static_slice_table[94])
+#define GRPC_MDSTR_VIA (grpc_static_slice_table[97])
/* "www-authenticate" */
-#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[95])
+#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[98])
/* "identity,deflate" */
-#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[96])
+#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[99])
/* "identity,gzip" */
-#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[97])
+#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[100])
/* "deflate,gzip" */
-#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[98])
+#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[101])
/* "identity,deflate,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
- (grpc_static_slice_table[99])
+ (grpc_static_slice_table[102])
extern const grpc_slice_refcount_vtable grpc_static_metadata_vtable;
extern grpc_slice_refcount
@@ -537,30 +543,30 @@ typedef enum {
} grpc_metadata_batch_callouts_index;
typedef union {
- struct grpc_linked_mdelem *array[GRPC_BATCH_CALLOUTS_COUNT];
+ struct grpc_linked_mdelem* array[GRPC_BATCH_CALLOUTS_COUNT];
struct {
- struct grpc_linked_mdelem *path;
- struct grpc_linked_mdelem *method;
- struct grpc_linked_mdelem *status;
- struct grpc_linked_mdelem *authority;
- struct grpc_linked_mdelem *scheme;
- struct grpc_linked_mdelem *te;
- struct grpc_linked_mdelem *grpc_message;
- struct grpc_linked_mdelem *grpc_status;
- struct grpc_linked_mdelem *grpc_payload_bin;
- struct grpc_linked_mdelem *grpc_encoding;
- struct grpc_linked_mdelem *grpc_accept_encoding;
- struct grpc_linked_mdelem *grpc_server_stats_bin;
- struct grpc_linked_mdelem *grpc_tags_bin;
- struct grpc_linked_mdelem *grpc_trace_bin;
- struct grpc_linked_mdelem *content_type;
- struct grpc_linked_mdelem *content_encoding;
- struct grpc_linked_mdelem *accept_encoding;
- struct grpc_linked_mdelem *grpc_internal_encoding_request;
- struct grpc_linked_mdelem *grpc_internal_stream_encoding_request;
- struct grpc_linked_mdelem *user_agent;
- struct grpc_linked_mdelem *host;
- struct grpc_linked_mdelem *lb_token;
+ struct grpc_linked_mdelem* path;
+ struct grpc_linked_mdelem* method;
+ struct grpc_linked_mdelem* status;
+ struct grpc_linked_mdelem* authority;
+ struct grpc_linked_mdelem* scheme;
+ struct grpc_linked_mdelem* te;
+ struct grpc_linked_mdelem* grpc_message;
+ struct grpc_linked_mdelem* grpc_status;
+ struct grpc_linked_mdelem* grpc_payload_bin;
+ struct grpc_linked_mdelem* grpc_encoding;
+ struct grpc_linked_mdelem* grpc_accept_encoding;
+ struct grpc_linked_mdelem* grpc_server_stats_bin;
+ struct grpc_linked_mdelem* grpc_tags_bin;
+ struct grpc_linked_mdelem* grpc_trace_bin;
+ struct grpc_linked_mdelem* content_type;
+ struct grpc_linked_mdelem* content_encoding;
+ struct grpc_linked_mdelem* accept_encoding;
+ struct grpc_linked_mdelem* grpc_internal_encoding_request;
+ struct grpc_linked_mdelem* grpc_internal_stream_encoding_request;
+ struct grpc_linked_mdelem* user_agent;
+ struct grpc_linked_mdelem* host;
+ struct grpc_linked_mdelem* lb_token;
} named;
} grpc_metadata_batch_callouts;
@@ -584,4 +590,5 @@ extern const uint8_t grpc_static_accept_stream_encoding_metadata[4];
(GRPC_MAKE_MDELEM(&grpc_static_mdelem_table \
[grpc_static_accept_stream_encoding_metadata[(algs)]], \
GRPC_MDELEM_STORAGE_STATIC))
+
#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */
diff --git a/src/core/lib/transport/status_conversion.c b/src/core/lib/transport/status_conversion.cc
index a40d333284..46cba4292b 100644
--- a/src/core/lib/transport/status_conversion.c
+++ b/src/core/lib/transport/status_conversion.cc
@@ -38,7 +38,7 @@ grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status) {
}
grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
- gpr_timespec deadline) {
+ grpc_millis deadline) {
switch (error) {
case GRPC_HTTP2_NO_ERROR:
/* should never be received */
@@ -46,7 +46,7 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
case GRPC_HTTP2_CANCEL:
/* http2 cancel translates to STATUS_CANCELLED iff deadline hasn't been
* exceeded */
- return gpr_time_cmp(gpr_now(deadline.clock_type), deadline) >= 0
+ return grpc_core::ExecCtx::Get()->Now() > deadline
? GRPC_STATUS_DEADLINE_EXCEEDED
: GRPC_STATUS_CANCELLED;
case GRPC_HTTP2_ENHANCE_YOUR_CALM:
diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h
index e93f3dfd9b..107eb92a53 100644
--- a/src/core/lib/transport/status_conversion.h
+++ b/src/core/lib/transport/status_conversion.h
@@ -20,12 +20,13 @@
#define GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H
#include <grpc/grpc.h>
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/http2_errors.h"
/* Conversion of grpc status codes to http2 error codes (for RST_STREAM) */
grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status);
grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
- gpr_timespec deadline);
+ grpc_millis deadline);
/* Conversion of HTTP status codes (:status) to grpc status codes */
grpc_status_code grpc_http2_status_to_grpc_status(int status);
diff --git a/src/core/lib/transport/timeout_encoding.c b/src/core/lib/transport/timeout_encoding.cc
index 02f179d6a3..47f964af45 100644
--- a/src/core/lib/transport/timeout_encoding.c
+++ b/src/core/lib/transport/timeout_encoding.cc
@@ -22,7 +22,7 @@
#include <string.h>
#include <grpc/support/port_platform.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
static int64_t round_up(int64_t x, int64_t divisor) {
return (x / divisor + (x % divisor != 0)) * divisor;
@@ -41,15 +41,15 @@ static int64_t round_up_to_three_sig_figs(int64_t x) {
}
/* encode our minimum viable timeout value */
-static void enc_tiny(char *buffer) { memcpy(buffer, "1n", 3); }
+static void enc_tiny(char* buffer) { memcpy(buffer, "1n", 3); }
-static void enc_ext(char *buffer, int64_t value, char ext) {
+static void enc_ext(char* buffer, int64_t value, char ext) {
int n = int64_ttoa(value, buffer);
buffer[n] = ext;
buffer[n + 1] = 0;
}
-static void enc_seconds(char *buffer, int64_t sec) {
+static void enc_seconds(char* buffer, int64_t sec) {
if (sec % 3600 == 0) {
enc_ext(buffer, sec / 3600, 'H');
} else if (sec % 60 == 0) {
@@ -59,72 +59,39 @@ static void enc_seconds(char *buffer, int64_t sec) {
}
}
-static void enc_nanos(char *buffer, int64_t x) {
+static void enc_millis(char* buffer, int64_t x) {
x = round_up_to_three_sig_figs(x);
- if (x < 100000) {
- if (x % 1000 == 0) {
- enc_ext(buffer, x / 1000, 'u');
- } else {
- enc_ext(buffer, x, 'n');
- }
- } else if (x < 100000000) {
- if (x % 1000000 == 0) {
- enc_ext(buffer, x / 1000000, 'm');
- } else {
- enc_ext(buffer, x / 1000, 'u');
- }
- } else if (x < 1000000000) {
- enc_ext(buffer, x / 1000000, 'm');
+ if (x < GPR_MS_PER_SEC) {
+ enc_ext(buffer, x, 'm');
} else {
- /* note that this is only ever called with times of less than one second,
- so if we reach here the time must have been rounded up to a whole second
- (and no more) */
- memcpy(buffer, "1S", 3);
- }
-}
-
-static void enc_micros(char *buffer, int64_t x) {
- x = round_up_to_three_sig_figs(x);
- if (x < 100000) {
- if (x % 1000 == 0) {
- enc_ext(buffer, x / 1000, 'm');
+ if (x % GPR_MS_PER_SEC == 0) {
+ enc_seconds(buffer, x / GPR_MS_PER_SEC);
} else {
- enc_ext(buffer, x, 'u');
+ enc_ext(buffer, x, 'm');
}
- } else if (x < 100000000) {
- if (x % 1000000 == 0) {
- enc_ext(buffer, x / 1000000, 'S');
- } else {
- enc_ext(buffer, x / 1000, 'm');
- }
- } else {
- enc_ext(buffer, x / 1000000, 'S');
}
}
-void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer) {
- if (timeout.tv_sec < 0) {
+void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer) {
+ if (timeout <= 0) {
enc_tiny(buffer);
- } else if (timeout.tv_sec == 0) {
- enc_nanos(buffer, timeout.tv_nsec);
- } else if (timeout.tv_sec < 1000 && timeout.tv_nsec != 0) {
- enc_micros(buffer,
- (int64_t)(timeout.tv_sec * 1000000) +
- (timeout.tv_nsec / 1000 + (timeout.tv_nsec % 1000 != 0)));
+ } else if (timeout < 1000 * GPR_MS_PER_SEC) {
+ enc_millis(buffer, timeout);
} else {
- enc_seconds(buffer, timeout.tv_sec + (timeout.tv_nsec != 0));
+ enc_seconds(buffer,
+ timeout / GPR_MS_PER_SEC + (timeout % GPR_MS_PER_SEC != 0));
}
}
-static int is_all_whitespace(const char *p, const char *end) {
+static int is_all_whitespace(const char* p, const char* end) {
while (p != end && *p == ' ') p++;
return p == end;
}
-int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) {
- int32_t x = 0;
- const uint8_t *p = GRPC_SLICE_START_PTR(text);
- const uint8_t *end = GRPC_SLICE_END_PTR(text);
+int grpc_http2_decode_timeout(grpc_slice text, grpc_millis* timeout) {
+ grpc_millis x = 0;
+ const uint8_t* p = GRPC_SLICE_START_PTR(text);
+ const uint8_t* end = GRPC_SLICE_END_PTR(text);
int have_digit = 0;
/* skip whitespace */
for (; p != end && *p == ' '; p++)
@@ -136,7 +103,7 @@ int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) {
/* spec allows max. 8 digits, but we allow values up to 1,000,000,000 */
if (x >= (100 * 1000 * 1000)) {
if (x != (100 * 1000 * 1000) || digit != 0) {
- *timeout = gpr_inf_future(GPR_TIMESPAN);
+ *timeout = GRPC_MILLIS_INF_FUTURE;
return 1;
}
}
@@ -150,26 +117,26 @@ int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) {
/* decode unit specifier */
switch (*p) {
case 'n':
- *timeout = gpr_time_from_nanos(x, GPR_TIMESPAN);
+ *timeout = x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0);
break;
case 'u':
- *timeout = gpr_time_from_micros(x, GPR_TIMESPAN);
+ *timeout = x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0);
break;
case 'm':
- *timeout = gpr_time_from_millis(x, GPR_TIMESPAN);
+ *timeout = x;
break;
case 'S':
- *timeout = gpr_time_from_seconds(x, GPR_TIMESPAN);
+ *timeout = x * GPR_MS_PER_SEC;
break;
case 'M':
- *timeout = gpr_time_from_minutes(x, GPR_TIMESPAN);
+ *timeout = x * 60 * GPR_MS_PER_SEC;
break;
case 'H':
- *timeout = gpr_time_from_hours(x, GPR_TIMESPAN);
+ *timeout = x * 60 * 60 * GPR_MS_PER_SEC;
break;
default:
return 0;
}
p++;
- return is_all_whitespace((const char *)p, (const char *)end);
+ return is_all_whitespace((const char*)p, (const char*)end);
}
diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h
index 7ff35c4083..4e9268262e 100644
--- a/src/core/lib/transport/timeout_encoding.h
+++ b/src/core/lib/transport/timeout_encoding.h
@@ -22,13 +22,14 @@
#include <grpc/slice.h>
#include <grpc/support/time.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
#define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE (GPR_LTOA_MIN_BUFSIZE + 1)
/* Encode/decode timeouts to the GRPC over HTTP/2 format;
encoding may round up arbitrarily */
-void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer);
-int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout);
+void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer);
+int grpc_http2_decode_timeout(grpc_slice text, grpc_millis* timeout);
#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */
diff --git a/src/core/lib/transport/transport.c b/src/core/lib/transport/transport.c
deleted file mode 100644
index 682a820b48..0000000000
--- a/src/core/lib/transport/transport.c
+++ /dev/null
@@ -1,289 +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/transport/transport.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/atm.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-
-#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/transport/transport_impl.h"
-
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_stream_refcount =
- GRPC_TRACER_INITIALIZER(false, "stream_refcount");
-#endif
-
-#ifndef NDEBUG
-void grpc_stream_ref(grpc_stream_refcount *refcount, const char *reason) {
- if (GRPC_TRACER_ON(grpc_trace_stream_refcount)) {
- gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
- gpr_log(GPR_DEBUG, "%s %p:%p REF %" PRIdPTR "->%" PRIdPTR " %s",
- refcount->object_type, refcount, refcount->destroy.cb_arg, val,
- val + 1, reason);
- }
-#else
-void grpc_stream_ref(grpc_stream_refcount *refcount) {
-#endif
- gpr_ref_non_zero(&refcount->refs);
-}
-
-#ifndef NDEBUG
-void grpc_stream_unref(grpc_exec_ctx *exec_ctx, grpc_stream_refcount *refcount,
- const char *reason) {
- if (GRPC_TRACER_ON(grpc_trace_stream_refcount)) {
- gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
- gpr_log(GPR_DEBUG, "%s %p:%p UNREF %" PRIdPTR "->%" PRIdPTR " %s",
- refcount->object_type, refcount, refcount->destroy.cb_arg, val,
- val - 1, reason);
- }
-#else
-void grpc_stream_unref(grpc_exec_ctx *exec_ctx,
- grpc_stream_refcount *refcount) {
-#endif
- if (gpr_unref(&refcount->refs)) {
- if (exec_ctx->flags & GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
- /* Ick.
- The thread we're running on MAY be owned (indirectly) by a call-stack.
- If that's the case, destroying the call-stack MAY try to destroy the
- thread, which is a tangled mess that we just don't want to ever have to
- cope with.
- Throw this over to the executor (on a core-owned thread) and process it
- there. */
- refcount->destroy.scheduler =
- grpc_executor_scheduler(GRPC_EXECUTOR_SHORT);
- }
- GRPC_CLOSURE_SCHED(exec_ctx, &refcount->destroy, GRPC_ERROR_NONE);
- }
-}
-
-#define STREAM_REF_FROM_SLICE_REF(p) \
- ((grpc_stream_refcount *)(((uint8_t *)p) - \
- offsetof(grpc_stream_refcount, slice_refcount)))
-
-static void slice_stream_ref(void *p) {
-#ifndef NDEBUG
- grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p), "slice");
-#else
- grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p));
-#endif
-}
-
-static void slice_stream_unref(grpc_exec_ctx *exec_ctx, void *p) {
-#ifndef NDEBUG
- grpc_stream_unref(exec_ctx, STREAM_REF_FROM_SLICE_REF(p), "slice");
-#else
- grpc_stream_unref(exec_ctx, STREAM_REF_FROM_SLICE_REF(p));
-#endif
-}
-
-grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount *refcount,
- void *buffer, size_t length) {
- slice_stream_ref(&refcount->slice_refcount);
- grpc_slice res;
- res.refcount = &refcount->slice_refcount,
- res.data.refcounted.bytes = (uint8_t *)buffer;
- res.data.refcounted.length = length;
- return res;
-}
-
-static const grpc_slice_refcount_vtable stream_ref_slice_vtable = {
- .ref = slice_stream_ref,
- .unref = slice_stream_unref,
- .eq = grpc_slice_default_eq_impl,
- .hash = grpc_slice_default_hash_impl};
-
-#ifndef NDEBUG
-void grpc_stream_ref_init(grpc_stream_refcount *refcount, int initial_refs,
- grpc_iomgr_cb_func cb, void *cb_arg,
- const char *object_type) {
- refcount->object_type = object_type;
-#else
-void grpc_stream_ref_init(grpc_stream_refcount *refcount, int initial_refs,
- grpc_iomgr_cb_func cb, void *cb_arg) {
-#endif
- gpr_ref_init(&refcount->refs, initial_refs);
- GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx);
- refcount->slice_refcount.vtable = &stream_ref_slice_vtable;
- refcount->slice_refcount.sub_refcount = &refcount->slice_refcount;
-}
-
-static void move64(uint64_t *from, uint64_t *to) {
- *to += *from;
- *from = 0;
-}
-
-void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats *from,
- grpc_transport_one_way_stats *to) {
- move64(&from->framing_bytes, &to->framing_bytes);
- move64(&from->data_bytes, &to->data_bytes);
- move64(&from->header_bytes, &to->header_bytes);
-}
-
-void grpc_transport_move_stats(grpc_transport_stream_stats *from,
- grpc_transport_stream_stats *to) {
- grpc_transport_move_one_way_stats(&from->incoming, &to->incoming);
- grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing);
-}
-
-size_t grpc_transport_stream_size(grpc_transport *transport) {
- return transport->vtable->sizeof_stream;
-}
-
-void grpc_transport_destroy(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport) {
- transport->vtable->destroy(exec_ctx, transport);
-}
-
-int grpc_transport_init_stream(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport, grpc_stream *stream,
- grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
- return transport->vtable->init_stream(exec_ctx, transport, stream, refcount,
- server_data, arena);
-}
-
-void grpc_transport_perform_stream_op(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_stream *stream,
- grpc_transport_stream_op_batch *op) {
- transport->vtable->perform_stream_op(exec_ctx, transport, stream, op);
-}
-
-void grpc_transport_perform_op(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_transport_op *op) {
- transport->vtable->perform_op(exec_ctx, transport, op);
-}
-
-void grpc_transport_set_pops(grpc_exec_ctx *exec_ctx, grpc_transport *transport,
- grpc_stream *stream,
- grpc_polling_entity *pollent) {
- grpc_pollset *pollset;
- grpc_pollset_set *pollset_set;
- if ((pollset = grpc_polling_entity_pollset(pollent)) != NULL) {
- transport->vtable->set_pollset(exec_ctx, transport, stream, pollset);
- } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) != NULL) {
- transport->vtable->set_pollset_set(exec_ctx, transport, stream,
- pollset_set);
- } else {
- abort();
- }
-}
-
-void grpc_transport_destroy_stream(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_stream *stream,
- grpc_closure *then_schedule_closure) {
- transport->vtable->destroy_stream(exec_ctx, transport, stream,
- then_schedule_closure);
-}
-
-grpc_endpoint *grpc_transport_get_endpoint(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport) {
- return transport->vtable->get_endpoint(exec_ctx, transport);
-}
-
-// This comment should be sung to the tune of
-// "Supercalifragilisticexpialidocious":
-//
-// grpc_transport_stream_op_batch_finish_with_failure
-// is a function that must always unref cancel_error
-// though it lives in lib, it handles transport stream ops sure
-// it's grpc_transport_stream_op_batch_finish_with_failure
-void grpc_transport_stream_op_batch_finish_with_failure(
- grpc_exec_ctx *exec_ctx, grpc_transport_stream_op_batch *batch,
- grpc_error *error, grpc_call_combiner *call_combiner) {
- if (batch->send_message) {
- grpc_byte_stream_destroy(exec_ctx,
- batch->payload->send_message.send_message);
- }
- if (batch->recv_message) {
- GRPC_CALL_COMBINER_START(exec_ctx, call_combiner,
- batch->payload->recv_message.recv_message_ready,
- GRPC_ERROR_REF(error),
- "failing recv_message_ready");
- }
- if (batch->recv_initial_metadata) {
- GRPC_CALL_COMBINER_START(
- exec_ctx, call_combiner,
- batch->payload->recv_initial_metadata.recv_initial_metadata_ready,
- GRPC_ERROR_REF(error), "failing recv_initial_metadata_ready");
- }
- GRPC_CLOSURE_SCHED(exec_ctx, batch->on_complete, error);
- if (batch->cancel_stream) {
- GRPC_ERROR_UNREF(batch->payload->cancel_stream.cancel_error);
- }
-}
-
-typedef struct {
- grpc_closure outer_on_complete;
- grpc_closure *inner_on_complete;
- grpc_transport_op op;
-} made_transport_op;
-
-static void destroy_made_transport_op(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- made_transport_op *op = (made_transport_op *)arg;
- GRPC_CLOSURE_SCHED(exec_ctx, op->inner_on_complete, GRPC_ERROR_REF(error));
- gpr_free(op);
-}
-
-grpc_transport_op *grpc_make_transport_op(grpc_closure *on_complete) {
- made_transport_op *op = (made_transport_op *)gpr_malloc(sizeof(*op));
- GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op,
- grpc_schedule_on_exec_ctx);
- op->inner_on_complete = on_complete;
- memset(&op->op, 0, sizeof(op->op));
- op->op.on_consumed = &op->outer_on_complete;
- return &op->op;
-}
-
-typedef struct {
- grpc_closure outer_on_complete;
- grpc_closure *inner_on_complete;
- grpc_transport_stream_op_batch op;
- grpc_transport_stream_op_batch_payload payload;
-} made_transport_stream_op;
-
-static void destroy_made_transport_stream_op(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- made_transport_stream_op *op = (made_transport_stream_op *)arg;
- grpc_closure *c = op->inner_on_complete;
- gpr_free(op);
- GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_REF(error));
-}
-
-grpc_transport_stream_op_batch *grpc_make_transport_stream_op(
- grpc_closure *on_complete) {
- made_transport_stream_op *op =
- (made_transport_stream_op *)gpr_zalloc(sizeof(*op));
- op->op.payload = &op->payload;
- GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_stream_op,
- op, grpc_schedule_on_exec_ctx);
- op->inner_on_complete = on_complete;
- op->op.on_complete = &op->outer_on_complete;
- return &op->op;
-}
diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc
new file mode 100644
index 0000000000..ea0380e591
--- /dev/null
+++ b/src/core/lib/transport/transport.cc
@@ -0,0 +1,275 @@
+/*
+ *
+ * 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/transport/transport.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/atm.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+#include "src/core/lib/transport/transport_impl.h"
+
+grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount(false,
+ "stream_refcount");
+
+#ifndef NDEBUG
+void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason) {
+ if (grpc_trace_stream_refcount.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
+ gpr_log(GPR_DEBUG, "%s %p:%p REF %" PRIdPTR "->%" PRIdPTR " %s",
+ refcount->object_type, refcount, refcount->destroy.cb_arg, val,
+ val + 1, reason);
+ }
+#else
+void grpc_stream_ref(grpc_stream_refcount* refcount) {
+#endif
+ gpr_ref_non_zero(&refcount->refs);
+}
+
+#ifndef NDEBUG
+void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason) {
+ if (grpc_trace_stream_refcount.enabled()) {
+ gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
+ gpr_log(GPR_DEBUG, "%s %p:%p UNREF %" PRIdPTR "->%" PRIdPTR " %s",
+ refcount->object_type, refcount, refcount->destroy.cb_arg, val,
+ val - 1, reason);
+ }
+#else
+void grpc_stream_unref(grpc_stream_refcount* refcount) {
+#endif
+ if (gpr_unref(&refcount->refs)) {
+ if (grpc_core::ExecCtx::Get()->flags() &
+ GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
+ /* Ick.
+ The thread we're running on MAY be owned (indirectly) by a call-stack.
+ If that's the case, destroying the call-stack MAY try to destroy the
+ thread, which is a tangled mess that we just don't want to ever have to
+ cope with.
+ Throw this over to the executor (on a core-owned thread) and process it
+ there. */
+ refcount->destroy.scheduler =
+ grpc_executor_scheduler(GRPC_EXECUTOR_SHORT);
+ }
+ GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
+ }
+}
+
+#define STREAM_REF_FROM_SLICE_REF(p) \
+ ((grpc_stream_refcount*)(((uint8_t*)p) - \
+ offsetof(grpc_stream_refcount, slice_refcount)))
+
+static void slice_stream_ref(void* p) {
+#ifndef NDEBUG
+ grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p), "slice");
+#else
+ grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p));
+#endif
+}
+
+static void slice_stream_unref(void* p) {
+#ifndef NDEBUG
+ grpc_stream_unref(STREAM_REF_FROM_SLICE_REF(p), "slice");
+#else
+ grpc_stream_unref(STREAM_REF_FROM_SLICE_REF(p));
+#endif
+}
+
+grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
+ void* buffer, size_t length) {
+ slice_stream_ref(&refcount->slice_refcount);
+ grpc_slice res;
+ res.refcount = &refcount->slice_refcount;
+ res.data.refcounted.bytes = (uint8_t*)buffer;
+ res.data.refcounted.length = length;
+ return res;
+}
+
+static const grpc_slice_refcount_vtable stream_ref_slice_vtable = {
+ slice_stream_ref, /* ref */
+ slice_stream_unref, /* unref */
+ grpc_slice_default_eq_impl, /* eq */
+ grpc_slice_default_hash_impl /* hash */
+};
+
+#ifndef NDEBUG
+void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
+ grpc_iomgr_cb_func cb, void* cb_arg,
+ const char* object_type) {
+ refcount->object_type = object_type;
+#else
+void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
+ grpc_iomgr_cb_func cb, void* cb_arg) {
+#endif
+ gpr_ref_init(&refcount->refs, initial_refs);
+ GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx);
+ refcount->slice_refcount.vtable = &stream_ref_slice_vtable;
+ refcount->slice_refcount.sub_refcount = &refcount->slice_refcount;
+}
+
+static void move64(uint64_t* from, uint64_t* to) {
+ *to += *from;
+ *from = 0;
+}
+
+void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from,
+ grpc_transport_one_way_stats* to) {
+ move64(&from->framing_bytes, &to->framing_bytes);
+ move64(&from->data_bytes, &to->data_bytes);
+ move64(&from->header_bytes, &to->header_bytes);
+}
+
+void grpc_transport_move_stats(grpc_transport_stream_stats* from,
+ grpc_transport_stream_stats* to) {
+ grpc_transport_move_one_way_stats(&from->incoming, &to->incoming);
+ grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing);
+}
+
+size_t grpc_transport_stream_size(grpc_transport* transport) {
+ return transport->vtable->sizeof_stream;
+}
+
+void grpc_transport_destroy(grpc_transport* transport) {
+ transport->vtable->destroy(transport);
+}
+
+int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
+ grpc_stream_refcount* refcount,
+ const void* server_data, gpr_arena* arena) {
+ return transport->vtable->init_stream(transport, stream, refcount,
+ server_data, arena);
+}
+
+void grpc_transport_perform_stream_op(grpc_transport* transport,
+ grpc_stream* stream,
+ grpc_transport_stream_op_batch* op) {
+ transport->vtable->perform_stream_op(transport, stream, op);
+}
+
+void grpc_transport_perform_op(grpc_transport* transport,
+ grpc_transport_op* op) {
+ transport->vtable->perform_op(transport, op);
+}
+
+void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
+ grpc_polling_entity* pollent) {
+ grpc_pollset* pollset;
+ grpc_pollset_set* pollset_set;
+ if ((pollset = grpc_polling_entity_pollset(pollent)) != nullptr) {
+ transport->vtable->set_pollset(transport, stream, pollset);
+ } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) !=
+ nullptr) {
+ transport->vtable->set_pollset_set(transport, stream, pollset_set);
+ } else {
+ abort();
+ }
+}
+
+void grpc_transport_destroy_stream(grpc_transport* transport,
+ grpc_stream* stream,
+ grpc_closure* then_schedule_closure) {
+ transport->vtable->destroy_stream(transport, stream, then_schedule_closure);
+}
+
+grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport) {
+ return transport->vtable->get_endpoint(transport);
+}
+
+// This comment should be sung to the tune of
+// "Supercalifragilisticexpialidocious":
+//
+// grpc_transport_stream_op_batch_finish_with_failure
+// is a function that must always unref cancel_error
+// though it lives in lib, it handles transport stream ops sure
+// it's grpc_transport_stream_op_batch_finish_with_failure
+void grpc_transport_stream_op_batch_finish_with_failure(
+ grpc_transport_stream_op_batch* batch, grpc_error* error,
+ grpc_call_combiner* call_combiner) {
+ if (batch->send_message) {
+ grpc_byte_stream_destroy(batch->payload->send_message.send_message);
+ }
+ if (batch->recv_message) {
+ GRPC_CALL_COMBINER_START(
+ call_combiner, batch->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_REF(error), "failing recv_message_ready");
+ }
+ if (batch->recv_initial_metadata) {
+ GRPC_CALL_COMBINER_START(
+ call_combiner,
+ batch->payload->recv_initial_metadata.recv_initial_metadata_ready,
+ GRPC_ERROR_REF(error), "failing recv_initial_metadata_ready");
+ }
+ GRPC_CLOSURE_SCHED(batch->on_complete, error);
+ if (batch->cancel_stream) {
+ GRPC_ERROR_UNREF(batch->payload->cancel_stream.cancel_error);
+ }
+}
+
+typedef struct {
+ grpc_closure outer_on_complete;
+ grpc_closure* inner_on_complete;
+ grpc_transport_op op;
+} made_transport_op;
+
+static void destroy_made_transport_op(void* arg, grpc_error* error) {
+ made_transport_op* op = (made_transport_op*)arg;
+ GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error));
+ gpr_free(op);
+}
+
+grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) {
+ made_transport_op* op = (made_transport_op*)gpr_malloc(sizeof(*op));
+ GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op,
+ grpc_schedule_on_exec_ctx);
+ op->inner_on_complete = on_complete;
+ memset(&op->op, 0, sizeof(op->op));
+ op->op.on_consumed = &op->outer_on_complete;
+ return &op->op;
+}
+
+typedef struct {
+ grpc_closure outer_on_complete;
+ grpc_closure* inner_on_complete;
+ grpc_transport_stream_op_batch op;
+ grpc_transport_stream_op_batch_payload payload;
+} made_transport_stream_op;
+
+static void destroy_made_transport_stream_op(void* arg, grpc_error* error) {
+ made_transport_stream_op* op = (made_transport_stream_op*)arg;
+ grpc_closure* c = op->inner_on_complete;
+ gpr_free(op);
+ GRPC_CLOSURE_RUN(c, GRPC_ERROR_REF(error));
+}
+
+grpc_transport_stream_op_batch* grpc_make_transport_stream_op(
+ grpc_closure* on_complete) {
+ made_transport_stream_op* op =
+ (made_transport_stream_op*)gpr_zalloc(sizeof(*op));
+ op->op.payload = &op->payload;
+ GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_stream_op,
+ op, grpc_schedule_on_exec_ctx);
+ op->inner_on_complete = on_complete;
+ op->op.on_complete = &op->outer_on_complete;
+ return &op->op;
+}
diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h
index fbf5dcb8b5..b392c696cd 100644
--- a/src/core/lib/transport/transport.h
+++ b/src/core/lib/transport/transport.h
@@ -22,20 +22,23 @@
#include <stddef.h>
#include "src/core/lib/channel/context.h"
+#include "src/core/lib/gpr/arena.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_set.h"
-#include "src/core/lib/support/arena.h"
#include "src/core/lib/transport/byte_stream.h"
#include "src/core/lib/transport/metadata_batch.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* Minimum and maximum protocol accepted versions. */
+#define GRPC_PROTOCOL_VERSION_MAX_MAJOR 2
+#define GRPC_PROTOCOL_VERSION_MAX_MINOR 1
+#define GRPC_PROTOCOL_VERSION_MIN_MAJOR 2
+#define GRPC_PROTOCOL_VERSION_MIN_MINOR 1
/* forward declarations */
+
typedef struct grpc_transport grpc_transport;
/* grpc_stream doesn't actually exist. It's used as a typesafe
@@ -43,41 +46,38 @@ typedef struct grpc_transport grpc_transport;
for a stream. */
typedef struct grpc_stream grpc_stream;
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_stream_refcount;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount;
typedef struct grpc_stream_refcount {
gpr_refcount refs;
grpc_closure destroy;
#ifndef NDEBUG
- const char *object_type;
+ const char* object_type;
#endif
grpc_slice_refcount slice_refcount;
} grpc_stream_refcount;
#ifndef NDEBUG
-void grpc_stream_ref_init(grpc_stream_refcount *refcount, int initial_refs,
- grpc_iomgr_cb_func cb, void *cb_arg,
- const char *object_type);
-void grpc_stream_ref(grpc_stream_refcount *refcount, const char *reason);
-void grpc_stream_unref(grpc_exec_ctx *exec_ctx, grpc_stream_refcount *refcount,
- const char *reason);
+void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
+ grpc_iomgr_cb_func cb, void* cb_arg,
+ const char* object_type);
+void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason);
+void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason);
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
grpc_stream_ref_init(rc, ir, cb, cb_arg, objtype)
#else
-void grpc_stream_ref_init(grpc_stream_refcount *refcount, int initial_refs,
- grpc_iomgr_cb_func cb, void *cb_arg);
-void grpc_stream_ref(grpc_stream_refcount *refcount);
-void grpc_stream_unref(grpc_exec_ctx *exec_ctx, grpc_stream_refcount *refcount);
+void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
+ grpc_iomgr_cb_func cb, void* cb_arg);
+void grpc_stream_ref(grpc_stream_refcount* refcount);
+void grpc_stream_unref(grpc_stream_refcount* refcount);
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
grpc_stream_ref_init(rc, ir, cb, cb_arg)
#endif
/* Wrap a buffer that is owned by some stream object into a slice that shares
the same refcount */
-grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount *refcount,
- void *buffer, size_t length);
+grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
+ void* buffer, size_t length);
typedef struct {
uint64_t framing_bytes;
@@ -90,14 +90,14 @@ typedef struct grpc_transport_stream_stats {
grpc_transport_one_way_stats outgoing;
} grpc_transport_stream_stats;
-void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats *from,
- grpc_transport_one_way_stats *to);
+void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from,
+ grpc_transport_one_way_stats* to);
-void grpc_transport_move_stats(grpc_transport_stream_stats *from,
- grpc_transport_stream_stats *to);
+void grpc_transport_move_stats(grpc_transport_stream_stats* from,
+ grpc_transport_stream_stats* to);
typedef struct {
- void *extra_arg;
+ void* extra_arg;
grpc_closure closure;
} grpc_handler_private_op_data;
@@ -110,10 +110,10 @@ typedef struct grpc_transport_stream_op_batch {
/** Should be enqueued when all requested operations (excluding recv_message
and recv_initial_metadata which have their own closures) in a given batch
have been completed. */
- grpc_closure *on_complete;
+ grpc_closure* on_complete;
/** Values for the stream op (fields set are determined by flags above) */
- grpc_transport_stream_op_batch_payload *payload;
+ grpc_transport_stream_op_batch_payload* payload;
/** Send initial metadata to the peer, from the provided metadata batch. */
bool send_initial_metadata : 1;
@@ -149,17 +149,17 @@ typedef struct grpc_transport_stream_op_batch {
struct grpc_transport_stream_op_batch_payload {
struct {
- grpc_metadata_batch *send_initial_metadata;
+ grpc_metadata_batch* send_initial_metadata;
/** Iff send_initial_metadata != NULL, flags associated with
send_initial_metadata: a bitfield of GRPC_INITIAL_METADATA_xxx */
uint32_t send_initial_metadata_flags;
// If non-NULL, will be set by the transport to the peer string
// (a char*, which the caller takes ownership of).
- gpr_atm *peer_string;
+ gpr_atm* peer_string;
} send_initial_metadata;
struct {
- grpc_metadata_batch *send_trailing_metadata;
+ grpc_metadata_batch* send_trailing_metadata;
} send_trailing_metadata;
struct {
@@ -168,21 +168,21 @@ struct grpc_transport_stream_op_batch_payload {
// grpc_byte_stream_destroy() on this.
// The batch's on_complete will not be called until after the byte
// stream is destroyed.
- grpc_byte_stream *send_message;
+ grpc_byte_stream* send_message;
} send_message;
struct {
- grpc_metadata_batch *recv_initial_metadata;
- uint32_t *recv_flags;
+ grpc_metadata_batch* recv_initial_metadata;
+ uint32_t* recv_flags;
/** Should be enqueued when initial metadata is ready to be processed. */
- grpc_closure *recv_initial_metadata_ready;
+ grpc_closure* recv_initial_metadata_ready;
// If not NULL, will be set to true if trailing metadata is
// immediately available. This may be a signal that we received a
// Trailers-Only response.
- bool *trailing_metadata_available;
+ bool* trailing_metadata_available;
// If non-NULL, will be set by the transport to the peer string
// (a char*, which the caller takes ownership of).
- gpr_atm *peer_string;
+ gpr_atm* peer_string;
} recv_initial_metadata;
struct {
@@ -190,17 +190,17 @@ struct grpc_transport_stream_op_batch_payload {
// containing a received message.
// The caller is responsible for calling grpc_byte_stream_destroy()
// on this byte stream.
- grpc_byte_stream **recv_message;
+ grpc_byte_stream** recv_message;
/** Should be enqueued when one message is ready to be processed. */
- grpc_closure *recv_message_ready;
+ grpc_closure* recv_message_ready;
} recv_message;
struct {
- grpc_metadata_batch *recv_trailing_metadata;
+ grpc_metadata_batch* recv_trailing_metadata;
} recv_trailing_metadata;
struct {
- grpc_transport_stream_stats *collect_stats;
+ grpc_transport_stream_stats* collect_stats;
} collect_stats;
/** Forcefully close this stream.
@@ -216,43 +216,48 @@ struct grpc_transport_stream_op_batch_payload {
struct {
// Error contract: the transport that gets this op must cause cancel_error
// to be unref'ed after processing it
- grpc_error *cancel_error;
+ grpc_error* cancel_error;
} cancel_stream;
/* Indexes correspond to grpc_context_index enum values */
- grpc_call_context_element *context;
+ grpc_call_context_element* context;
};
/** Transport op: a set of operations to perform on a transport as a whole */
typedef struct grpc_transport_op {
/** Called when processing of this op is done. */
- grpc_closure *on_consumed;
+ grpc_closure* on_consumed;
/** connectivity monitoring - set connectivity_state to NULL to unsubscribe */
- grpc_closure *on_connectivity_state_change;
- grpc_connectivity_state *connectivity_state;
+ grpc_closure* on_connectivity_state_change;
+ grpc_connectivity_state* connectivity_state;
/** should the transport be disconnected
* Error contract: the transport that gets this op must cause
* disconnect_with_error to be unref'ed after processing it */
- grpc_error *disconnect_with_error;
+ grpc_error* disconnect_with_error;
/** what should the goaway contain?
* Error contract: the transport that gets this op must cause
* goaway_error to be unref'ed after processing it */
- grpc_error *goaway_error;
+ grpc_error* goaway_error;
/** set the callback for accepting new streams;
this is a permanent callback, unlike the other one-shot closures.
If true, the callback is set to set_accept_stream_fn, with its
user_data argument set to set_accept_stream_user_data */
bool set_accept_stream;
- void (*set_accept_stream_fn)(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_transport *transport,
- const void *server_data);
- void *set_accept_stream_user_data;
+ void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport,
+ const void* server_data);
+ void* set_accept_stream_user_data;
/** add this transport to a pollset */
- grpc_pollset *bind_pollset;
+ grpc_pollset* bind_pollset;
/** add this transport to a pollset_set */
- grpc_pollset_set *bind_pollset_set;
- /** send a ping, call this back if not NULL */
- grpc_closure *send_ping;
+ grpc_pollset_set* bind_pollset_set;
+ /** send a ping, if either on_initiate or on_ack is not NULL */
+ struct {
+ /** Ping may be delayed by the transport, on_initiate callback will be
+ called when the ping is actually being sent. */
+ grpc_closure* on_initiate;
+ /** Called when the ping ack is received */
+ grpc_closure* on_ack;
+ } send_ping;
/***************************************************************************
* remaining fields are initialized and used at the discretion of the
@@ -263,7 +268,7 @@ typedef struct grpc_transport_op {
/* Returns the amount of memory required to store a grpc_stream for this
transport */
-size_t grpc_transport_stream_size(grpc_transport *transport);
+size_t grpc_transport_stream_size(grpc_transport* transport);
/* Initialize transport data for a stream.
@@ -275,13 +280,12 @@ size_t grpc_transport_stream_size(grpc_transport *transport);
stream - a pointer to uninitialized memory to initialize
server_data - either NULL for a client initiated stream, or a pointer
supplied from the accept_stream callback function */
-int grpc_transport_init_stream(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport, grpc_stream *stream,
- grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena);
+int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
+ grpc_stream_refcount* refcount,
+ const void* server_data, gpr_arena* arena);
-void grpc_transport_set_pops(grpc_exec_ctx *exec_ctx, grpc_transport *transport,
- grpc_stream *stream, grpc_polling_entity *pollent);
+void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
+ grpc_polling_entity* pollent);
/* Destroy transport data for a stream.
@@ -293,17 +297,16 @@ void grpc_transport_set_pops(grpc_exec_ctx *exec_ctx, grpc_transport *transport,
transport - the transport on which to create this stream
stream - the grpc_stream to destroy (memory is still owned by the
caller, but any child memory must be cleaned up) */
-void grpc_transport_destroy_stream(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_stream *stream,
- grpc_closure *then_schedule_closure);
+void grpc_transport_destroy_stream(grpc_transport* transport,
+ grpc_stream* stream,
+ grpc_closure* then_schedule_closure);
void grpc_transport_stream_op_batch_finish_with_failure(
- grpc_exec_ctx *exec_ctx, grpc_transport_stream_op_batch *op,
- grpc_error *error, grpc_call_combiner *call_combiner);
+ grpc_transport_stream_op_batch* op, grpc_error* error,
+ grpc_call_combiner* call_combiner);
-char *grpc_transport_stream_op_batch_string(grpc_transport_stream_op_batch *op);
-char *grpc_transport_op_string(grpc_transport_op *op);
+char* grpc_transport_stream_op_batch_string(grpc_transport_stream_op_batch* op);
+char* grpc_transport_op_string(grpc_transport_op* op);
/* Send a batch of operations on a transport
@@ -315,45 +318,35 @@ char *grpc_transport_op_string(grpc_transport_op *op);
non-NULL and previously initialized by the same transport.
op - a grpc_transport_stream_op_batch specifying the op to perform
*/
-void grpc_transport_perform_stream_op(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_stream *stream,
- grpc_transport_stream_op_batch *op);
+void grpc_transport_perform_stream_op(grpc_transport* transport,
+ grpc_stream* stream,
+ grpc_transport_stream_op_batch* op);
-void grpc_transport_perform_op(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport,
- grpc_transport_op *op);
+void grpc_transport_perform_op(grpc_transport* transport,
+ grpc_transport_op* op);
/* Send a ping on a transport
Calls cb with user data when a response is received. */
-void grpc_transport_ping(grpc_transport *transport, grpc_closure *cb);
+void grpc_transport_ping(grpc_transport* transport, grpc_closure* cb);
/* Advise peer of pending connection termination. */
-void grpc_transport_goaway(grpc_transport *transport, grpc_status_code status,
+void grpc_transport_goaway(grpc_transport* transport, grpc_status_code status,
grpc_slice debug_data);
-/* Close a transport. Aborts all open streams. */
-void grpc_transport_close(grpc_transport *transport);
-
/* Destroy the transport */
-void grpc_transport_destroy(grpc_exec_ctx *exec_ctx, grpc_transport *transport);
+void grpc_transport_destroy(grpc_transport* transport);
/* Get the endpoint used by \a transport */
-grpc_endpoint *grpc_transport_get_endpoint(grpc_exec_ctx *exec_ctx,
- grpc_transport *transport);
+grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport);
/* Allocate a grpc_transport_op, and preconfigure the on_consumed closure to
\a on_consumed and then delete the returned transport op */
-grpc_transport_op *grpc_make_transport_op(grpc_closure *on_consumed);
+grpc_transport_op* grpc_make_transport_op(grpc_closure* on_consumed);
/* Allocate a grpc_transport_stream_op_batch, and preconfigure the on_consumed
closure
to \a on_consumed and then delete the returned transport op */
-grpc_transport_stream_op_batch *grpc_make_transport_stream_op(
- grpc_closure *on_consumed);
-
-#ifdef __cplusplus
-}
-#endif
+grpc_transport_stream_op_batch* grpc_make_transport_stream_op(
+ grpc_closure* on_consumed);
#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H */
diff --git a/src/core/lib/transport/transport_impl.h b/src/core/lib/transport/transport_impl.h
index bbae69c223..50b8a5f9b7 100644
--- a/src/core/lib/transport/transport_impl.h
+++ b/src/core/lib/transport/transport_impl.h
@@ -27,46 +27,43 @@ typedef struct grpc_transport_vtable {
size_t sizeof_stream; /* = sizeof(transport stream) */
/* name of this transport implementation */
- const char *name;
+ const char* name;
/* implementation of grpc_transport_init_stream */
- int (*init_stream)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena);
+ int (*init_stream)(grpc_transport* self, grpc_stream* stream,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena);
/* implementation of grpc_transport_set_pollset */
- void (*set_pollset)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_pollset *pollset);
+ void (*set_pollset)(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset* pollset);
/* implementation of grpc_transport_set_pollset */
- void (*set_pollset_set)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_pollset_set *pollset_set);
+ void (*set_pollset_set)(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset_set* pollset_set);
/* implementation of grpc_transport_perform_stream_op */
- void (*perform_stream_op)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream,
- grpc_transport_stream_op_batch *op);
+ void (*perform_stream_op)(grpc_transport* self, grpc_stream* stream,
+ grpc_transport_stream_op_batch* op);
/* implementation of grpc_transport_perform_op */
- void (*perform_op)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_transport_op *op);
+ void (*perform_op)(grpc_transport* self, grpc_transport_op* op);
/* implementation of grpc_transport_destroy_stream */
- void (*destroy_stream)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream,
- grpc_closure *then_schedule_closure);
+ void (*destroy_stream)(grpc_transport* self, grpc_stream* stream,
+ grpc_closure* then_schedule_closure);
/* implementation of grpc_transport_destroy */
- void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_transport *self);
+ void (*destroy)(grpc_transport* self);
/* implementation of grpc_transport_get_endpoint */
- grpc_endpoint *(*get_endpoint)(grpc_exec_ctx *exec_ctx, grpc_transport *self);
+ grpc_endpoint* (*get_endpoint)(grpc_transport* self);
} grpc_transport_vtable;
/* an instance of a grpc transport */
struct grpc_transport {
/* pointer to a vtable defining operations on this transport */
- const grpc_transport_vtable *vtable;
+ const grpc_transport_vtable* vtable;
};
#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */
diff --git a/src/core/lib/transport/transport_op_string.c b/src/core/lib/transport/transport_op_string.cc
index 858664715c..58a21e9b60 100644
--- a/src/core/lib/transport/transport_op_string.c
+++ b/src/core/lib/transport/transport_op_string.cc
@@ -16,8 +16,11 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include "src/core/lib/channel/channel_stack.h"
+#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@@ -25,14 +28,14 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/connectivity_state.h"
/* These routines are here to facilitate debugging - they produce string
representations of various transport data structures */
-static void put_metadata(gpr_strvec *b, grpc_mdelem md) {
+static void put_metadata(gpr_strvec* b, grpc_mdelem md) {
gpr_strvec_add(b, gpr_strdup("key="));
gpr_strvec_add(
b, grpc_dump_slice(GRPC_MDKEY(md), GPR_DUMP_HEX | GPR_DUMP_ASCII));
@@ -42,24 +45,23 @@ static void put_metadata(gpr_strvec *b, grpc_mdelem md) {
b, grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII));
}
-static void put_metadata_list(gpr_strvec *b, grpc_metadata_batch md) {
- grpc_linked_mdelem *m;
- for (m = md.list.head; m != NULL; m = m->next) {
+static void put_metadata_list(gpr_strvec* b, grpc_metadata_batch md) {
+ grpc_linked_mdelem* m;
+ for (m = md.list.head; m != nullptr; m = m->next) {
if (m != md.list.head) gpr_strvec_add(b, gpr_strdup(", "));
put_metadata(b, m->md);
}
- if (gpr_time_cmp(md.deadline, gpr_inf_future(md.deadline.clock_type)) != 0) {
- char *tmp;
- gpr_asprintf(&tmp, " deadline=%" PRId64 ".%09d", md.deadline.tv_sec,
- md.deadline.tv_nsec);
+ if (md.deadline != GRPC_MILLIS_INF_FUTURE) {
+ char* tmp;
+ gpr_asprintf(&tmp, " deadline=%" PRIdPTR, md.deadline);
gpr_strvec_add(b, tmp);
}
}
-char *grpc_transport_stream_op_batch_string(
- grpc_transport_stream_op_batch *op) {
- char *tmp;
- char *out;
+char* grpc_transport_stream_op_batch_string(
+ grpc_transport_stream_op_batch* op) {
+ char* tmp;
+ char* out;
gpr_strvec b;
gpr_strvec_init(&b);
@@ -105,7 +107,7 @@ char *grpc_transport_stream_op_batch_string(
if (op->cancel_stream) {
gpr_strvec_add(&b, gpr_strdup(" "));
- const char *msg =
+ const char* msg =
grpc_error_string(op->payload->cancel_stream.cancel_error);
gpr_asprintf(&tmp, "CANCEL:%s", msg);
@@ -119,24 +121,24 @@ char *grpc_transport_stream_op_batch_string(
gpr_strvec_add(&b, tmp);
}
- out = gpr_strvec_flatten(&b, NULL);
+ out = gpr_strvec_flatten(&b, nullptr);
gpr_strvec_destroy(&b);
return out;
}
-char *grpc_transport_op_string(grpc_transport_op *op) {
- char *tmp;
- char *out;
+char* grpc_transport_op_string(grpc_transport_op* op) {
+ char* tmp;
+ char* out;
bool first = true;
gpr_strvec b;
gpr_strvec_init(&b);
- if (op->on_connectivity_state_change != NULL) {
+ if (op->on_connectivity_state_change != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
- if (op->connectivity_state != NULL) {
+ if (op->connectivity_state != nullptr) {
gpr_asprintf(&tmp, "ON_CONNECTIVITY_STATE_CHANGE:p=%p:from=%s",
op->on_connectivity_state_change,
grpc_connectivity_state_name(*op->connectivity_state));
@@ -151,7 +153,7 @@ char *grpc_transport_op_string(grpc_transport_op *op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
- const char *err = grpc_error_string(op->disconnect_with_error);
+ const char* err = grpc_error_string(op->disconnect_with_error);
gpr_asprintf(&tmp, "DISCONNECT:%s", err);
gpr_strvec_add(&b, tmp);
}
@@ -159,7 +161,7 @@ char *grpc_transport_op_string(grpc_transport_op *op) {
if (op->goaway_error) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
- const char *msg = grpc_error_string(op->goaway_error);
+ const char* msg = grpc_error_string(op->goaway_error);
gpr_asprintf(&tmp, "SEND_GOAWAY:%s", msg);
gpr_strvec_add(&b, tmp);
@@ -173,34 +175,34 @@ char *grpc_transport_op_string(grpc_transport_op *op) {
gpr_strvec_add(&b, tmp);
}
- if (op->bind_pollset != NULL) {
+ if (op->bind_pollset != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET"));
}
- if (op->bind_pollset_set != NULL) {
+ if (op->bind_pollset_set != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
first = false;
gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET_SET"));
}
- if (op->send_ping != NULL) {
+ if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
- first = false;
+ // first = false;
gpr_strvec_add(&b, gpr_strdup("SEND_PING"));
}
- out = gpr_strvec_flatten(&b, NULL);
+ out = gpr_strvec_flatten(&b, nullptr);
gpr_strvec_destroy(&b);
return out;
}
-void grpc_call_log_op(const char *file, int line, gpr_log_severity severity,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- char *str = grpc_transport_stream_op_batch_string(op);
+void grpc_call_log_op(const char* file, int line, gpr_log_severity severity,
+ grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
+ char* str = grpc_transport_stream_op_batch_string(op);
gpr_log(file, line, severity, "OP[%s:%p]: %s", elem->filter->name, elem, str);
gpr_free(str);
}
diff --git a/src/core/plugin_registry/grpc_cronet_plugin_registry.c b/src/core/plugin_registry/grpc_cronet_plugin_registry.cc
index 1c09f54ad9..fe5eb28f05 100644
--- a/src/core/plugin_registry/grpc_cronet_plugin_registry.c
+++ b/src/core/plugin_registry/grpc_cronet_plugin_registry.cc
@@ -18,18 +18,18 @@
#include <grpc/grpc.h>
-extern void grpc_http_filters_init(void);
-extern void grpc_http_filters_shutdown(void);
-extern void grpc_chttp2_plugin_init(void);
-extern void grpc_chttp2_plugin_shutdown(void);
-extern void grpc_deadline_filter_init(void);
-extern void grpc_deadline_filter_shutdown(void);
-extern void grpc_client_channel_init(void);
-extern void grpc_client_channel_shutdown(void);
-extern void grpc_tsi_gts_init(void);
-extern void grpc_tsi_gts_shutdown(void);
-extern void grpc_server_load_reporting_plugin_init(void);
-extern void grpc_server_load_reporting_plugin_shutdown(void);
+void grpc_http_filters_init(void);
+void grpc_http_filters_shutdown(void);
+void grpc_chttp2_plugin_init(void);
+void grpc_chttp2_plugin_shutdown(void);
+void grpc_deadline_filter_init(void);
+void grpc_deadline_filter_shutdown(void);
+void grpc_client_channel_init(void);
+void grpc_client_channel_shutdown(void);
+void grpc_tsi_alts_init(void);
+void grpc_tsi_alts_shutdown(void);
+void grpc_server_load_reporting_plugin_init(void);
+void grpc_server_load_reporting_plugin_shutdown(void);
void grpc_register_built_in_plugins(void) {
grpc_register_plugin(grpc_http_filters_init,
@@ -40,8 +40,8 @@ void grpc_register_built_in_plugins(void) {
grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown);
- grpc_register_plugin(grpc_tsi_gts_init,
- grpc_tsi_gts_shutdown);
+ grpc_register_plugin(grpc_tsi_alts_init,
+ grpc_tsi_alts_shutdown);
grpc_register_plugin(grpc_server_load_reporting_plugin_init,
grpc_server_load_reporting_plugin_shutdown);
}
diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.cc
index 7b90d796d5..fdf9acc09c 100644
--- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c
+++ b/src/core/plugin_registry/grpc_plugin_registry.cc
@@ -18,70 +18,70 @@
#include <grpc/grpc.h>
-extern void grpc_http_filters_init(void);
-extern void grpc_http_filters_shutdown(void);
-extern void grpc_chttp2_plugin_init(void);
-extern void grpc_chttp2_plugin_shutdown(void);
-extern void grpc_deadline_filter_init(void);
-extern void grpc_deadline_filter_shutdown(void);
-extern void grpc_client_channel_init(void);
-extern void grpc_client_channel_shutdown(void);
-extern void grpc_inproc_plugin_init(void);
-extern void grpc_inproc_plugin_shutdown(void);
-extern void grpc_resolver_dns_ares_init(void);
-extern void grpc_resolver_dns_ares_shutdown(void);
-extern void grpc_resolver_dns_native_init(void);
-extern void grpc_resolver_dns_native_shutdown(void);
-extern void grpc_resolver_sockaddr_init(void);
-extern void grpc_resolver_sockaddr_shutdown(void);
-extern void grpc_resolver_fake_init(void);
-extern void grpc_resolver_fake_shutdown(void);
-extern void grpc_server_load_reporting_plugin_init(void);
-extern void grpc_server_load_reporting_plugin_shutdown(void);
-extern void grpc_lb_policy_grpclb_init(void);
-extern void grpc_lb_policy_grpclb_shutdown(void);
-extern void grpc_lb_policy_pick_first_init(void);
-extern void grpc_lb_policy_pick_first_shutdown(void);
-extern void grpc_lb_policy_round_robin_init(void);
-extern void grpc_lb_policy_round_robin_shutdown(void);
-extern void census_grpc_plugin_init(void);
-extern void census_grpc_plugin_shutdown(void);
-extern void grpc_max_age_filter_init(void);
-extern void grpc_max_age_filter_shutdown(void);
-extern void grpc_message_size_filter_init(void);
-extern void grpc_message_size_filter_shutdown(void);
-extern void grpc_workaround_cronet_compression_filter_init(void);
-extern void grpc_workaround_cronet_compression_filter_shutdown(void);
+void grpc_http_filters_init(void);
+void grpc_http_filters_shutdown(void);
+void grpc_chttp2_plugin_init(void);
+void grpc_chttp2_plugin_shutdown(void);
+void grpc_tsi_alts_init(void);
+void grpc_tsi_alts_shutdown(void);
+void grpc_deadline_filter_init(void);
+void grpc_deadline_filter_shutdown(void);
+void grpc_client_channel_init(void);
+void grpc_client_channel_shutdown(void);
+void grpc_inproc_plugin_init(void);
+void grpc_inproc_plugin_shutdown(void);
+void grpc_resolver_fake_init(void);
+void grpc_resolver_fake_shutdown(void);
+void grpc_lb_policy_grpclb_init(void);
+void grpc_lb_policy_grpclb_shutdown(void);
+void grpc_lb_policy_pick_first_init(void);
+void grpc_lb_policy_pick_first_shutdown(void);
+void grpc_lb_policy_round_robin_init(void);
+void grpc_lb_policy_round_robin_shutdown(void);
+void grpc_resolver_dns_ares_init(void);
+void grpc_resolver_dns_ares_shutdown(void);
+void grpc_resolver_dns_native_init(void);
+void grpc_resolver_dns_native_shutdown(void);
+void grpc_resolver_sockaddr_init(void);
+void grpc_resolver_sockaddr_shutdown(void);
+void grpc_server_load_reporting_plugin_init(void);
+void grpc_server_load_reporting_plugin_shutdown(void);
+void grpc_max_age_filter_init(void);
+void grpc_max_age_filter_shutdown(void);
+void grpc_message_size_filter_init(void);
+void grpc_message_size_filter_shutdown(void);
+void grpc_workaround_cronet_compression_filter_init(void);
+void grpc_workaround_cronet_compression_filter_shutdown(void);
void grpc_register_built_in_plugins(void) {
grpc_register_plugin(grpc_http_filters_init,
grpc_http_filters_shutdown);
grpc_register_plugin(grpc_chttp2_plugin_init,
grpc_chttp2_plugin_shutdown);
+ grpc_register_plugin(grpc_tsi_alts_init,
+ grpc_tsi_alts_shutdown);
grpc_register_plugin(grpc_deadline_filter_init,
grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown);
grpc_register_plugin(grpc_inproc_plugin_init,
grpc_inproc_plugin_shutdown);
- grpc_register_plugin(grpc_resolver_dns_ares_init,
- grpc_resolver_dns_ares_shutdown);
- grpc_register_plugin(grpc_resolver_dns_native_init,
- grpc_resolver_dns_native_shutdown);
- grpc_register_plugin(grpc_resolver_sockaddr_init,
- grpc_resolver_sockaddr_shutdown);
grpc_register_plugin(grpc_resolver_fake_init,
grpc_resolver_fake_shutdown);
- grpc_register_plugin(grpc_server_load_reporting_plugin_init,
- grpc_server_load_reporting_plugin_shutdown);
grpc_register_plugin(grpc_lb_policy_grpclb_init,
grpc_lb_policy_grpclb_shutdown);
grpc_register_plugin(grpc_lb_policy_pick_first_init,
grpc_lb_policy_pick_first_shutdown);
grpc_register_plugin(grpc_lb_policy_round_robin_init,
grpc_lb_policy_round_robin_shutdown);
- grpc_register_plugin(census_grpc_plugin_init,
- census_grpc_plugin_shutdown);
+ grpc_register_plugin(grpc_resolver_dns_ares_init,
+ grpc_resolver_dns_ares_shutdown);
+ grpc_register_plugin(grpc_resolver_dns_native_init,
+ grpc_resolver_dns_native_shutdown);
+ grpc_register_plugin(grpc_resolver_sockaddr_init,
+ grpc_resolver_sockaddr_shutdown);
+ grpc_register_plugin(grpc_server_load_reporting_plugin_init,
+ grpc_server_load_reporting_plugin_shutdown);
grpc_register_plugin(grpc_max_age_filter_init,
grpc_max_age_filter_shutdown);
grpc_register_plugin(grpc_message_size_filter_init,
diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc
index 9cacf3d306..d73f946241 100644
--- a/src/core/plugin_registry/grpc_plugin_registry.c
+++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc
@@ -18,74 +18,66 @@
#include <grpc/grpc.h>
-extern void grpc_http_filters_init(void);
-extern void grpc_http_filters_shutdown(void);
-extern void grpc_chttp2_plugin_init(void);
-extern void grpc_chttp2_plugin_shutdown(void);
-extern void grpc_tsi_gts_init(void);
-extern void grpc_tsi_gts_shutdown(void);
-extern void grpc_deadline_filter_init(void);
-extern void grpc_deadline_filter_shutdown(void);
-extern void grpc_client_channel_init(void);
-extern void grpc_client_channel_shutdown(void);
-extern void grpc_inproc_plugin_init(void);
-extern void grpc_inproc_plugin_shutdown(void);
-extern void grpc_resolver_fake_init(void);
-extern void grpc_resolver_fake_shutdown(void);
-extern void grpc_lb_policy_grpclb_init(void);
-extern void grpc_lb_policy_grpclb_shutdown(void);
-extern void grpc_lb_policy_pick_first_init(void);
-extern void grpc_lb_policy_pick_first_shutdown(void);
-extern void grpc_lb_policy_round_robin_init(void);
-extern void grpc_lb_policy_round_robin_shutdown(void);
-extern void grpc_resolver_dns_ares_init(void);
-extern void grpc_resolver_dns_ares_shutdown(void);
-extern void grpc_resolver_dns_native_init(void);
-extern void grpc_resolver_dns_native_shutdown(void);
-extern void grpc_resolver_sockaddr_init(void);
-extern void grpc_resolver_sockaddr_shutdown(void);
-extern void grpc_server_load_reporting_plugin_init(void);
-extern void grpc_server_load_reporting_plugin_shutdown(void);
-extern void census_grpc_plugin_init(void);
-extern void census_grpc_plugin_shutdown(void);
-extern void grpc_max_age_filter_init(void);
-extern void grpc_max_age_filter_shutdown(void);
-extern void grpc_message_size_filter_init(void);
-extern void grpc_message_size_filter_shutdown(void);
-extern void grpc_workaround_cronet_compression_filter_init(void);
-extern void grpc_workaround_cronet_compression_filter_shutdown(void);
+void grpc_http_filters_init(void);
+void grpc_http_filters_shutdown(void);
+void grpc_chttp2_plugin_init(void);
+void grpc_chttp2_plugin_shutdown(void);
+void grpc_deadline_filter_init(void);
+void grpc_deadline_filter_shutdown(void);
+void grpc_client_channel_init(void);
+void grpc_client_channel_shutdown(void);
+void grpc_inproc_plugin_init(void);
+void grpc_inproc_plugin_shutdown(void);
+void grpc_resolver_dns_ares_init(void);
+void grpc_resolver_dns_ares_shutdown(void);
+void grpc_resolver_dns_native_init(void);
+void grpc_resolver_dns_native_shutdown(void);
+void grpc_resolver_sockaddr_init(void);
+void grpc_resolver_sockaddr_shutdown(void);
+void grpc_resolver_fake_init(void);
+void grpc_resolver_fake_shutdown(void);
+void grpc_server_load_reporting_plugin_init(void);
+void grpc_server_load_reporting_plugin_shutdown(void);
+void grpc_lb_policy_grpclb_init(void);
+void grpc_lb_policy_grpclb_shutdown(void);
+void grpc_lb_policy_pick_first_init(void);
+void grpc_lb_policy_pick_first_shutdown(void);
+void grpc_lb_policy_round_robin_init(void);
+void grpc_lb_policy_round_robin_shutdown(void);
+void grpc_max_age_filter_init(void);
+void grpc_max_age_filter_shutdown(void);
+void grpc_message_size_filter_init(void);
+void grpc_message_size_filter_shutdown(void);
+void grpc_workaround_cronet_compression_filter_init(void);
+void grpc_workaround_cronet_compression_filter_shutdown(void);
void grpc_register_built_in_plugins(void) {
grpc_register_plugin(grpc_http_filters_init,
grpc_http_filters_shutdown);
grpc_register_plugin(grpc_chttp2_plugin_init,
grpc_chttp2_plugin_shutdown);
- grpc_register_plugin(grpc_tsi_gts_init,
- grpc_tsi_gts_shutdown);
grpc_register_plugin(grpc_deadline_filter_init,
grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown);
grpc_register_plugin(grpc_inproc_plugin_init,
grpc_inproc_plugin_shutdown);
- grpc_register_plugin(grpc_resolver_fake_init,
- grpc_resolver_fake_shutdown);
- grpc_register_plugin(grpc_lb_policy_grpclb_init,
- grpc_lb_policy_grpclb_shutdown);
- grpc_register_plugin(grpc_lb_policy_pick_first_init,
- grpc_lb_policy_pick_first_shutdown);
- grpc_register_plugin(grpc_lb_policy_round_robin_init,
- grpc_lb_policy_round_robin_shutdown);
grpc_register_plugin(grpc_resolver_dns_ares_init,
grpc_resolver_dns_ares_shutdown);
grpc_register_plugin(grpc_resolver_dns_native_init,
grpc_resolver_dns_native_shutdown);
grpc_register_plugin(grpc_resolver_sockaddr_init,
grpc_resolver_sockaddr_shutdown);
+ grpc_register_plugin(grpc_resolver_fake_init,
+ grpc_resolver_fake_shutdown);
grpc_register_plugin(grpc_server_load_reporting_plugin_init,
grpc_server_load_reporting_plugin_shutdown);
- grpc_register_plugin(census_grpc_plugin_init,
- census_grpc_plugin_shutdown);
+ grpc_register_plugin(grpc_lb_policy_grpclb_init,
+ grpc_lb_policy_grpclb_shutdown);
+ grpc_register_plugin(grpc_lb_policy_pick_first_init,
+ grpc_lb_policy_pick_first_shutdown);
+ grpc_register_plugin(grpc_lb_policy_round_robin_init,
+ grpc_lb_policy_round_robin_shutdown);
grpc_register_plugin(grpc_max_age_filter_init,
grpc_max_age_filter_shutdown);
grpc_register_plugin(grpc_message_size_filter_init,
diff --git a/src/core/tsi/gts_transport_security.c b/src/core/tsi/alts_transport_security.cc
index e2ac685e44..ddd75cbd02 100644
--- a/src/core/tsi/gts_transport_security.c
+++ b/src/core/tsi/alts_transport_security.cc
@@ -16,25 +16,27 @@
*
*/
-#include "src/core/tsi/gts_transport_security.h"
+#include "src/core/tsi/alts_transport_security.h"
#include <string.h>
-static gts_shared_resource g_gts_resource;
+static alts_shared_resource g_alts_resource;
-gts_shared_resource *gts_get_shared_resource(void) { return &g_gts_resource; }
+alts_shared_resource* alts_get_shared_resource(void) {
+ return &g_alts_resource;
+}
-void grpc_tsi_gts_init() {
- memset(&g_gts_resource, 0, sizeof(gts_shared_resource));
- gpr_mu_init(&g_gts_resource.mu);
+void grpc_tsi_alts_init() {
+ memset(&g_alts_resource, 0, sizeof(alts_shared_resource));
+ gpr_mu_init(&g_alts_resource.mu);
}
-void grpc_tsi_gts_shutdown() {
- gpr_mu_destroy(&g_gts_resource.mu);
- if (g_gts_resource.cq == NULL) {
+void grpc_tsi_alts_shutdown() {
+ gpr_mu_destroy(&g_alts_resource.mu);
+ if (g_alts_resource.cq == nullptr) {
return;
}
- grpc_completion_queue_destroy(g_gts_resource.cq);
- grpc_channel_destroy(g_gts_resource.channel);
- gpr_thd_join(g_gts_resource.thread_id);
+ grpc_completion_queue_destroy(g_alts_resource.cq);
+ grpc_channel_destroy(g_alts_resource.channel);
+ gpr_thd_join(g_alts_resource.thread_id);
}
diff --git a/src/core/tsi/gts_transport_security.h b/src/core/tsi/alts_transport_security.h
index 538e1030bc..c90e31478e 100644
--- a/src/core/tsi/gts_transport_security.h
+++ b/src/core/tsi/alts_transport_security.h
@@ -16,22 +16,22 @@
*
*/
-#ifndef GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H
-#define GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H
+#ifndef GRPC_CORE_TSI_ALTS_TRANSPORT_SECURITY_H
+#define GRPC_CORE_TSI_ALTS_TRANSPORT_SECURITY_H
#include <grpc/grpc.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
-typedef struct gts_shared_resource {
+typedef struct alts_shared_resource {
gpr_thd_id thread_id;
- grpc_channel *channel;
- grpc_completion_queue *cq;
+ grpc_channel* channel;
+ grpc_completion_queue* cq;
gpr_mu mu;
-} gts_shared_resource;
+} alts_shared_resource;
-/* This method returns the address of gts_shared_resource object shared by all
+/* This method returns the address of alts_shared_resource object shared by all
* TSI handshakes. */
-gts_shared_resource *gts_get_shared_resource(void);
+alts_shared_resource* alts_get_shared_resource(void);
-#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */
+#endif /* GRPC_CORE_TSI_ALTS_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/fake_transport_security.c b/src/core/tsi/fake_transport_security.cc
index 64043fea08..b907636f9d 100644
--- a/src/core/tsi/fake_transport_security.c
+++ b/src/core/tsi/fake_transport_security.cc
@@ -41,7 +41,7 @@
where the size field value is the size of the size field plus the size of
the data encoded in little endian on 4 bytes. */
typedef struct {
- unsigned char *data;
+ unsigned char* data;
size_t size;
size_t allocated_size;
size_t offset;
@@ -63,7 +63,7 @@ typedef struct {
int needs_incoming_message;
tsi_fake_frame incoming_frame;
tsi_fake_frame outgoing_frame;
- unsigned char *outgoing_bytes_buffer;
+ unsigned char* outgoing_bytes_buffer;
size_t outgoing_bytes_buffer_size;
tsi_result result;
} tsi_fake_handshaker;
@@ -85,10 +85,10 @@ typedef struct {
/* --- Utils. ---*/
-static const char *tsi_fake_handshake_message_strings[] = {
+static const char* tsi_fake_handshake_message_strings[] = {
"CLIENT_INIT", "SERVER_INIT", "CLIENT_FINISHED", "SERVER_FINISHED"};
-static const char *tsi_fake_handshake_message_to_string(int msg) {
+static const char* tsi_fake_handshake_message_to_string(int msg) {
if (msg < 0 || msg >= TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
gpr_log(GPR_ERROR, "Invalid message %d", msg);
return "UNKNOWN";
@@ -97,12 +97,11 @@ static const char *tsi_fake_handshake_message_to_string(int msg) {
}
static tsi_result tsi_fake_handshake_message_from_string(
- const char *msg_string, tsi_fake_handshake_message *msg) {
- tsi_fake_handshake_message i;
- for (i = 0; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX; i++) {
+ const char* msg_string, tsi_fake_handshake_message* msg) {
+ for (int i = 0; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX; i++) {
if (strncmp(msg_string, tsi_fake_handshake_message_strings[i],
strlen(tsi_fake_handshake_message_strings[i])) == 0) {
- *msg = i;
+ *msg = (tsi_fake_handshake_message)i;
return TSI_OK;
}
}
@@ -110,22 +109,22 @@ static tsi_result tsi_fake_handshake_message_from_string(
return TSI_DATA_CORRUPTED;
}
-static uint32_t load32_little_endian(const unsigned char *buf) {
+static uint32_t load32_little_endian(const unsigned char* buf) {
return ((uint32_t)(buf[0]) | (uint32_t)(buf[1] << 8) |
(uint32_t)(buf[2] << 16) | (uint32_t)(buf[3] << 24));
}
-static void store32_little_endian(uint32_t value, unsigned char *buf) {
+static void store32_little_endian(uint32_t value, unsigned char* buf) {
buf[3] = (unsigned char)((value >> 24) & 0xFF);
buf[2] = (unsigned char)((value >> 16) & 0xFF);
buf[1] = (unsigned char)((value >> 8) & 0xFF);
buf[0] = (unsigned char)((value)&0xFF);
}
-static uint32_t read_frame_size(const grpc_slice_buffer *sb) {
- GPR_ASSERT(sb != NULL && sb->length >= TSI_FAKE_FRAME_HEADER_SIZE);
+static uint32_t read_frame_size(const grpc_slice_buffer* sb) {
+ GPR_ASSERT(sb != nullptr && sb->length >= TSI_FAKE_FRAME_HEADER_SIZE);
uint8_t frame_size_buffer[TSI_FAKE_FRAME_HEADER_SIZE];
- uint8_t *buf = frame_size_buffer;
+ uint8_t* buf = frame_size_buffer;
/* Copies the first 4 bytes to a temporary buffer. */
size_t remaining = TSI_FAKE_FRAME_HEADER_SIZE;
for (size_t i = 0; i < sb->count; i++) {
@@ -144,7 +143,7 @@ static uint32_t read_frame_size(const grpc_slice_buffer *sb) {
return load32_little_endian(frame_size_buffer);
}
-static void tsi_fake_frame_reset(tsi_fake_frame *frame, int needs_draining) {
+static void tsi_fake_frame_reset(tsi_fake_frame* frame, int needs_draining) {
frame->offset = 0;
frame->needs_draining = needs_draining;
if (!needs_draining) frame->size = 0;
@@ -152,12 +151,13 @@ static void tsi_fake_frame_reset(tsi_fake_frame *frame, int needs_draining) {
/* Checks if the frame's allocated size is at least frame->size, and reallocs
* more memory if necessary. */
-static void tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
- if (frame->data == NULL) {
+static void tsi_fake_frame_ensure_size(tsi_fake_frame* frame) {
+ if (frame->data == nullptr) {
frame->allocated_size = frame->size;
- frame->data = gpr_malloc(frame->allocated_size);
+ frame->data = (unsigned char*)gpr_malloc(frame->allocated_size);
} else if (frame->size > frame->allocated_size) {
- unsigned char *new_data = gpr_realloc(frame->data, frame->size);
+ unsigned char* new_data =
+ (unsigned char*)gpr_realloc(frame->data, frame->size);
frame->data = new_data;
frame->allocated_size = frame->size;
}
@@ -166,17 +166,17 @@ static void tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
/* Decodes the serialized fake frame contained in incoming_bytes, and fills
* frame with the contents of the decoded frame.
* This method should not be called if frame->needs_framing is not 0. */
-static tsi_result tsi_fake_frame_decode(const unsigned char *incoming_bytes,
- size_t *incoming_bytes_size,
- tsi_fake_frame *frame) {
+static tsi_result tsi_fake_frame_decode(const unsigned char* incoming_bytes,
+ size_t* incoming_bytes_size,
+ tsi_fake_frame* frame) {
size_t available_size = *incoming_bytes_size;
size_t to_read_size = 0;
- const unsigned char *bytes_cursor = incoming_bytes;
+ const unsigned char* bytes_cursor = incoming_bytes;
if (frame->needs_draining) return TSI_INTERNAL_ERROR;
- if (frame->data == NULL) {
+ if (frame->data == nullptr) {
frame->allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE;
- frame->data = gpr_malloc(frame->allocated_size);
+ frame->data = (unsigned char*)gpr_malloc(frame->allocated_size);
}
if (frame->offset < TSI_FAKE_FRAME_HEADER_SIZE) {
@@ -215,9 +215,9 @@ static tsi_result tsi_fake_frame_decode(const unsigned char *incoming_bytes,
/* Encodes a fake frame into its wire format and places the result in
* outgoing_bytes. outgoing_bytes_size indicates the size of the encoded frame.
* This method should not be called if frame->needs_framing is 0. */
-static tsi_result tsi_fake_frame_encode(unsigned char *outgoing_bytes,
- size_t *outgoing_bytes_size,
- tsi_fake_frame *frame) {
+static tsi_result tsi_fake_frame_encode(unsigned char* outgoing_bytes,
+ size_t* outgoing_bytes_size,
+ tsi_fake_frame* frame) {
size_t to_write_size = frame->size - frame->offset;
if (!frame->needs_draining) return TSI_INTERNAL_ERROR;
if (*outgoing_bytes_size < to_write_size) {
@@ -233,8 +233,8 @@ static tsi_result tsi_fake_frame_encode(unsigned char *outgoing_bytes,
/* Sets the payload of a fake frame to contain the given data blob, where
* data_size indicates the size of data. */
-static tsi_result tsi_fake_frame_set_data(unsigned char *data, size_t data_size,
- tsi_fake_frame *frame) {
+static tsi_result tsi_fake_frame_set_data(unsigned char* data, size_t data_size,
+ tsi_fake_frame* frame) {
frame->offset = 0;
frame->size = data_size + TSI_FAKE_FRAME_HEADER_SIZE;
tsi_fake_frame_ensure_size(frame);
@@ -245,24 +245,24 @@ static tsi_result tsi_fake_frame_set_data(unsigned char *data, size_t data_size,
}
/* Destroys the contents of a fake frame. */
-static void tsi_fake_frame_destruct(tsi_fake_frame *frame) {
- if (frame->data != NULL) gpr_free(frame->data);
+static void tsi_fake_frame_destruct(tsi_fake_frame* frame) {
+ if (frame->data != nullptr) gpr_free(frame->data);
}
/* --- tsi_frame_protector methods implementation. ---*/
-static tsi_result fake_protector_protect(tsi_frame_protector *self,
- const unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size) {
+static tsi_result fake_protector_protect(tsi_frame_protector* self,
+ const unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size) {
tsi_result result = TSI_OK;
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
unsigned char frame_header[TSI_FAKE_FRAME_HEADER_SIZE];
- tsi_fake_frame *frame = &impl->protect_frame;
+ tsi_fake_frame* frame = &impl->protect_frame;
size_t saved_output_size = *protected_output_frames_size;
size_t drained_size = 0;
- size_t *num_bytes_written = protected_output_frames_size;
+ size_t* num_bytes_written = protected_output_frames_size;
*num_bytes_written = 0;
/* Try to drain first. */
@@ -313,11 +313,11 @@ static tsi_result fake_protector_protect(tsi_frame_protector *self,
}
static tsi_result fake_protector_protect_flush(
- tsi_frame_protector *self, unsigned char *protected_output_frames,
- size_t *protected_output_frames_size, size_t *still_pending_size) {
+ tsi_frame_protector* self, unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size, size_t* still_pending_size) {
tsi_result result = TSI_OK;
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
- tsi_fake_frame *frame = &impl->protect_frame;
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
+ tsi_fake_frame* frame = &impl->protect_frame;
if (!frame->needs_draining) {
/* Create a short frame. */
frame->size = frame->offset;
@@ -334,15 +334,15 @@ static tsi_result fake_protector_protect_flush(
}
static tsi_result fake_protector_unprotect(
- tsi_frame_protector *self, const unsigned char *protected_frames_bytes,
- size_t *protected_frames_bytes_size, unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size) {
+ tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
+ size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size) {
tsi_result result = TSI_OK;
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
- tsi_fake_frame *frame = &impl->unprotect_frame;
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
+ tsi_fake_frame* frame = &impl->unprotect_frame;
size_t saved_output_size = *unprotected_bytes_size;
size_t drained_size = 0;
- size_t *num_bytes_written = unprotected_bytes_size;
+ size_t* num_bytes_written = unprotected_bytes_size;
*num_bytes_written = 0;
/* Try to drain first. */
@@ -382,29 +382,31 @@ static tsi_result fake_protector_unprotect(
return result;
}
-static void fake_protector_destroy(tsi_frame_protector *self) {
- tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
+static void fake_protector_destroy(tsi_frame_protector* self) {
+ tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
tsi_fake_frame_destruct(&impl->protect_frame);
tsi_fake_frame_destruct(&impl->unprotect_frame);
gpr_free(self);
}
static const tsi_frame_protector_vtable frame_protector_vtable = {
- fake_protector_protect, fake_protector_protect_flush,
- fake_protector_unprotect, fake_protector_destroy,
+ fake_protector_protect,
+ fake_protector_protect_flush,
+ fake_protector_unprotect,
+ fake_protector_destroy,
};
/* --- tsi_zero_copy_grpc_protector methods implementation. ---*/
static tsi_result fake_zero_copy_grpc_protector_protect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *unprotected_slices,
- grpc_slice_buffer *protected_slices) {
- if (self == NULL || unprotected_slices == NULL || protected_slices == NULL) {
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
+ grpc_slice_buffer* protected_slices) {
+ if (self == nullptr || unprotected_slices == nullptr ||
+ protected_slices == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)self;
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)self;
/* Protects each frame. */
while (unprotected_slices->length > 0) {
size_t frame_length =
@@ -421,14 +423,14 @@ static tsi_result fake_zero_copy_grpc_protector_protect(
}
static tsi_result fake_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *protected_slices,
- grpc_slice_buffer *unprotected_slices) {
- if (self == NULL || unprotected_slices == NULL || protected_slices == NULL) {
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
+ grpc_slice_buffer* unprotected_slices) {
+ if (self == nullptr || unprotected_slices == nullptr ||
+ protected_slices == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)self;
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)self;
grpc_slice_buffer_move_into(protected_slices, &impl->protected_sb);
/* Unprotect each frame, if we get a full frame. */
while (impl->protected_sb.length >= TSI_FAKE_FRAME_HEADER_SIZE) {
@@ -450,18 +452,18 @@ static tsi_result fake_zero_copy_grpc_protector_unprotect(
impl->parsed_frame_size - TSI_FAKE_FRAME_HEADER_SIZE,
unprotected_slices);
impl->parsed_frame_size = 0;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &impl->header_sb);
+ grpc_slice_buffer_reset_and_unref_internal(&impl->header_sb);
}
return TSI_OK;
}
static void fake_zero_copy_grpc_protector_destroy(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self) {
- if (self == NULL) return;
- tsi_fake_zero_copy_grpc_protector *impl =
- (tsi_fake_zero_copy_grpc_protector *)self;
- grpc_slice_buffer_destroy_internal(exec_ctx, &impl->header_sb);
- grpc_slice_buffer_destroy_internal(exec_ctx, &impl->protected_sb);
+ tsi_zero_copy_grpc_protector* self) {
+ if (self == nullptr) return;
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)self;
+ grpc_slice_buffer_destroy_internal(&impl->header_sb);
+ grpc_slice_buffer_destroy_internal(&impl->protected_sb);
gpr_free(impl);
}
@@ -476,12 +478,12 @@ static const tsi_zero_copy_grpc_protector_vtable
typedef struct {
tsi_handshaker_result base;
- unsigned char *unused_bytes;
+ unsigned char* unused_bytes;
size_t unused_bytes_size;
} fake_handshaker_result;
static tsi_result fake_handshaker_result_extract_peer(
- const tsi_handshaker_result *self, tsi_peer *peer) {
+ const tsi_handshaker_result* self, tsi_peer* peer) {
/* Construct a tsi_peer with 1 property: certificate type. */
tsi_result result = tsi_construct_peer(1, peer);
if (result != TSI_OK) return result;
@@ -493,32 +495,31 @@ static tsi_result fake_handshaker_result_extract_peer(
}
static tsi_result fake_handshaker_result_create_zero_copy_grpc_protector(
- void *exec_ctx, const tsi_handshaker_result *self,
- size_t *max_output_protected_frame_size,
- tsi_zero_copy_grpc_protector **protector) {
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_zero_copy_grpc_protector** protector) {
*protector =
tsi_create_fake_zero_copy_grpc_protector(max_output_protected_frame_size);
return TSI_OK;
}
static tsi_result fake_handshaker_result_create_frame_protector(
- const tsi_handshaker_result *self, size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector) {
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector) {
*protector = tsi_create_fake_frame_protector(max_output_protected_frame_size);
return TSI_OK;
}
static tsi_result fake_handshaker_result_get_unused_bytes(
- const tsi_handshaker_result *self, const unsigned char **bytes,
- size_t *bytes_size) {
- fake_handshaker_result *result = (fake_handshaker_result *)self;
+ const tsi_handshaker_result* self, const unsigned char** bytes,
+ size_t* bytes_size) {
+ fake_handshaker_result* result = (fake_handshaker_result*)self;
*bytes_size = result->unused_bytes_size;
*bytes = result->unused_bytes;
return TSI_OK;
}
-static void fake_handshaker_result_destroy(tsi_handshaker_result *self) {
- fake_handshaker_result *result = (fake_handshaker_result *)self;
+static void fake_handshaker_result_destroy(tsi_handshaker_result* self) {
+ fake_handshaker_result* result = (fake_handshaker_result*)self;
gpr_free(result->unused_bytes);
gpr_free(self);
}
@@ -532,16 +533,17 @@ static const tsi_handshaker_result_vtable handshaker_result_vtable = {
};
static tsi_result fake_handshaker_result_create(
- const unsigned char *unused_bytes, size_t unused_bytes_size,
- tsi_handshaker_result **handshaker_result) {
- if ((unused_bytes_size > 0 && unused_bytes == NULL) ||
- handshaker_result == NULL) {
+ const unsigned char* unused_bytes, size_t unused_bytes_size,
+ tsi_handshaker_result** handshaker_result) {
+ if ((unused_bytes_size > 0 && unused_bytes == nullptr) ||
+ handshaker_result == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- fake_handshaker_result *result = gpr_zalloc(sizeof(*result));
+ fake_handshaker_result* result =
+ (fake_handshaker_result*)gpr_zalloc(sizeof(*result));
result->base.vtable = &handshaker_result_vtable;
if (unused_bytes_size > 0) {
- result->unused_bytes = gpr_malloc(unused_bytes_size);
+ result->unused_bytes = (unsigned char*)gpr_malloc(unused_bytes_size);
memcpy(result->unused_bytes, unused_bytes, unused_bytes_size);
}
result->unused_bytes_size = unused_bytes_size;
@@ -552,8 +554,8 @@ static tsi_result fake_handshaker_result_create(
/* --- tsi_handshaker methods implementation. ---*/
static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
- tsi_handshaker *self, unsigned char *bytes, size_t *bytes_size) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+ tsi_handshaker* self, unsigned char* bytes, size_t* bytes_size) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
tsi_result result = TSI_OK;
if (impl->needs_incoming_message || impl->result == TSI_OK) {
*bytes_size = 0;
@@ -561,16 +563,16 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
}
if (!impl->outgoing_frame.needs_draining) {
tsi_fake_handshake_message next_message_to_send =
- impl->next_message_to_send + 2;
- const char *msg_string =
+ (tsi_fake_handshake_message)(impl->next_message_to_send + 2);
+ const char* msg_string =
tsi_fake_handshake_message_to_string(impl->next_message_to_send);
- result = tsi_fake_frame_set_data((unsigned char *)msg_string,
+ result = tsi_fake_frame_set_data((unsigned char*)msg_string,
strlen(msg_string), &impl->outgoing_frame);
if (result != TSI_OK) return result;
if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX;
}
- if (GRPC_TRACER_ON(tsi_tracing_enabled)) {
+ if (tsi_tracing_enabled.enabled()) {
gpr_log(GPR_INFO, "%s prepared %s.",
impl->is_client ? "Client" : "Server",
tsi_fake_handshake_message_to_string(impl->next_message_to_send));
@@ -582,7 +584,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
if (!impl->is_client &&
impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
/* We're done. */
- if (GRPC_TRACER_ON(tsi_tracing_enabled)) {
+ if (tsi_tracing_enabled.enabled()) {
gpr_log(GPR_INFO, "Server is done.");
}
impl->result = TSI_OK;
@@ -593,10 +595,11 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
}
static tsi_result fake_handshaker_process_bytes_from_peer(
- tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size) {
+ tsi_handshaker* self, const unsigned char* bytes, size_t* bytes_size) {
tsi_result result = TSI_OK;
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
- tsi_fake_handshake_message expected_msg = impl->next_message_to_send - 1;
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
+ tsi_fake_handshake_message expected_msg =
+ (tsi_fake_handshake_message)(impl->next_message_to_send - 1);
tsi_fake_handshake_message received_msg;
if (!impl->needs_incoming_message || impl->result == TSI_OK) {
@@ -608,7 +611,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
/* We now have a complete frame. */
result = tsi_fake_handshake_message_from_string(
- (const char *)impl->incoming_frame.data + TSI_FAKE_FRAME_HEADER_SIZE,
+ (const char*)impl->incoming_frame.data + TSI_FAKE_FRAME_HEADER_SIZE,
&received_msg);
if (result != TSI_OK) {
impl->result = result;
@@ -619,7 +622,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
tsi_fake_handshake_message_to_string(received_msg),
tsi_fake_handshake_message_to_string(expected_msg));
}
- if (GRPC_TRACER_ON(tsi_tracing_enabled)) {
+ if (tsi_tracing_enabled.enabled()) {
gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server",
tsi_fake_handshake_message_to_string(received_msg));
}
@@ -627,7 +630,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
impl->needs_incoming_message = 0;
if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
/* We're done. */
- if (GRPC_TRACER_ON(tsi_tracing_enabled)) {
+ if (tsi_tracing_enabled.enabled()) {
gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server");
}
impl->result = TSI_OK;
@@ -635,13 +638,13 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
return TSI_OK;
}
-static tsi_result fake_handshaker_get_result(tsi_handshaker *self) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+static tsi_result fake_handshaker_get_result(tsi_handshaker* self) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
return impl->result;
}
-static void fake_handshaker_destroy(tsi_handshaker *self) {
- tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
+static void fake_handshaker_destroy(tsi_handshaker* self) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)self;
tsi_fake_frame_destruct(&impl->incoming_frame);
tsi_fake_frame_destruct(&impl->outgoing_frame);
gpr_free(impl->outgoing_bytes_buffer);
@@ -649,17 +652,17 @@ static void fake_handshaker_destroy(tsi_handshaker *self) {
}
static tsi_result fake_handshaker_next(
- tsi_handshaker *self, const unsigned char *received_bytes,
- size_t received_bytes_size, const unsigned char **bytes_to_send,
- size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
- tsi_handshaker_on_next_done_cb cb, void *user_data) {
+ tsi_handshaker* self, const unsigned char* received_bytes,
+ size_t received_bytes_size, const unsigned char** bytes_to_send,
+ size_t* bytes_to_send_size, tsi_handshaker_result** handshaker_result,
+ tsi_handshaker_on_next_done_cb cb, void* user_data) {
/* Sanity check the arguments. */
- if ((received_bytes_size > 0 && received_bytes == NULL) ||
- bytes_to_send == NULL || bytes_to_send_size == NULL ||
- handshaker_result == NULL) {
+ if ((received_bytes_size > 0 && received_bytes == nullptr) ||
+ bytes_to_send == nullptr || bytes_to_send_size == nullptr ||
+ handshaker_result == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- tsi_fake_handshaker *handshaker = (tsi_fake_handshaker *)self;
+ tsi_fake_handshaker* handshaker = (tsi_fake_handshaker*)self;
tsi_result result = TSI_OK;
/* Decode and process a handshake frame from the peer. */
@@ -681,8 +684,8 @@ static tsi_result fake_handshaker_next(
if (result == TSI_INCOMPLETE_DATA) {
handshaker->outgoing_bytes_buffer_size *= 2;
handshaker->outgoing_bytes_buffer =
- gpr_realloc(handshaker->outgoing_bytes_buffer,
- handshaker->outgoing_bytes_buffer_size);
+ (unsigned char*)gpr_realloc(handshaker->outgoing_bytes_buffer,
+ handshaker->outgoing_bytes_buffer_size);
}
} while (result == TSI_INCOMPLETE_DATA);
if (result != TSI_OK) return result;
@@ -691,10 +694,10 @@ static tsi_result fake_handshaker_next(
/* Check if the handshake was completed. */
if (fake_handshaker_get_result(self) == TSI_HANDSHAKE_IN_PROGRESS) {
- *handshaker_result = NULL;
+ *handshaker_result = nullptr;
} else {
/* Calculate the unused bytes. */
- const unsigned char *unused_bytes = NULL;
+ const unsigned char* unused_bytes = nullptr;
size_t unused_bytes_size = received_bytes_size - consumed_bytes_size;
if (unused_bytes_size > 0) {
unused_bytes = received_bytes + consumed_bytes_size;
@@ -713,23 +716,24 @@ static tsi_result fake_handshaker_next(
}
static const tsi_handshaker_vtable handshaker_vtable = {
- NULL, /* get_bytes_to_send_to_peer -- deprecated */
- NULL, /* process_bytes_from_peer -- deprecated */
- NULL, /* get_result -- deprecated */
- NULL, /* extract_peer -- deprecated */
- NULL, /* create_frame_protector -- deprecated */
+ nullptr, /* get_bytes_to_send_to_peer -- deprecated */
+ nullptr, /* process_bytes_from_peer -- deprecated */
+ nullptr, /* get_result -- deprecated */
+ nullptr, /* extract_peer -- deprecated */
+ nullptr, /* create_frame_protector -- deprecated */
fake_handshaker_destroy,
fake_handshaker_next,
};
-tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
- tsi_fake_handshaker *impl = gpr_zalloc(sizeof(*impl));
+tsi_handshaker* tsi_create_fake_handshaker(int is_client) {
+ tsi_fake_handshaker* impl = (tsi_fake_handshaker*)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &handshaker_vtable;
impl->is_client = is_client;
impl->result = TSI_HANDSHAKE_IN_PROGRESS;
impl->outgoing_bytes_buffer_size =
TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE;
- impl->outgoing_bytes_buffer = gpr_malloc(impl->outgoing_bytes_buffer_size);
+ impl->outgoing_bytes_buffer =
+ (unsigned char*)gpr_malloc(impl->outgoing_bytes_buffer_size);
if (is_client) {
impl->needs_incoming_message = 0;
impl->next_message_to_send = TSI_FAKE_CLIENT_INIT;
@@ -740,22 +744,24 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
return &impl->base;
}
-tsi_frame_protector *tsi_create_fake_frame_protector(
- size_t *max_protected_frame_size) {
- tsi_fake_frame_protector *impl = gpr_zalloc(sizeof(*impl));
- impl->max_frame_size = (max_protected_frame_size == NULL)
+tsi_frame_protector* tsi_create_fake_frame_protector(
+ size_t* max_protected_frame_size) {
+ tsi_fake_frame_protector* impl =
+ (tsi_fake_frame_protector*)gpr_zalloc(sizeof(*impl));
+ impl->max_frame_size = (max_protected_frame_size == nullptr)
? TSI_FAKE_DEFAULT_FRAME_SIZE
: *max_protected_frame_size;
impl->base.vtable = &frame_protector_vtable;
return &impl->base;
}
-tsi_zero_copy_grpc_protector *tsi_create_fake_zero_copy_grpc_protector(
- size_t *max_protected_frame_size) {
- tsi_fake_zero_copy_grpc_protector *impl = gpr_zalloc(sizeof(*impl));
+tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
+ size_t* max_protected_frame_size) {
+ tsi_fake_zero_copy_grpc_protector* impl =
+ (tsi_fake_zero_copy_grpc_protector*)gpr_zalloc(sizeof(*impl));
grpc_slice_buffer_init(&impl->header_sb);
grpc_slice_buffer_init(&impl->protected_sb);
- impl->max_frame_size = (max_protected_frame_size == NULL)
+ impl->max_frame_size = (max_protected_frame_size == nullptr)
? TSI_FAKE_DEFAULT_FRAME_SIZE
: *max_protected_frame_size;
impl->parsed_frame_size = 0;
diff --git a/src/core/tsi/fake_transport_security.h b/src/core/tsi/fake_transport_security.h
index 6159708a84..3848e7c6bf 100644
--- a/src/core/tsi/fake_transport_security.h
+++ b/src/core/tsi/fake_transport_security.h
@@ -21,10 +21,6 @@
#include "src/core/tsi/transport_security_interface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for FAKE certs. */
#define TSI_FAKE_CERTIFICATE_TYPE "FAKE"
@@ -33,19 +29,15 @@ extern "C" {
No cryptography is performed in these objects. They just simulate handshake
messages going back and forth for the handshaker and do some framing on
cleartext data for the protector. */
-tsi_handshaker *tsi_create_fake_handshaker(int is_client);
+tsi_handshaker* tsi_create_fake_handshaker(int is_client);
/* Creates a protector directly without going through the handshake phase. */
-tsi_frame_protector *tsi_create_fake_frame_protector(
- size_t *max_protected_frame_size);
+tsi_frame_protector* tsi_create_fake_frame_protector(
+ size_t* max_protected_frame_size);
/* Creates a zero-copy protector directly without going through the handshake
* phase. */
-tsi_zero_copy_grpc_protector *tsi_create_fake_zero_copy_grpc_protector(
- size_t *max_protected_frame_size);
-
-#ifdef __cplusplus
-}
-#endif
+tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
+ size_t* max_protected_frame_size);
#endif /* GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.cc
index 7ebf9dd96f..b396a621bd 100644
--- a/src/core/tsi/ssl_transport_security.c
+++ b/src/core/tsi/ssl_transport_security.cc
@@ -39,12 +39,14 @@
#include <grpc/support/thd.h>
#include <grpc/support/useful.h>
+extern "C" {
#include <openssl/bio.h>
#include <openssl/crypto.h> /* For OPENSSL_free */
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
+}
#include "src/core/tsi/ssl_types.h"
#include "src/core/tsi/transport_security.h"
@@ -68,14 +70,14 @@
/* --- Structure definitions. ---*/
struct tsi_ssl_handshaker_factory {
- const tsi_ssl_handshaker_factory_vtable *vtable;
+ const tsi_ssl_handshaker_factory_vtable* vtable;
gpr_refcount refcount;
};
struct tsi_ssl_client_handshaker_factory {
tsi_ssl_handshaker_factory base;
- SSL_CTX *ssl_context;
- unsigned char *alpn_protocol_list;
+ SSL_CTX* ssl_context;
+ unsigned char* alpn_protocol_list;
size_t alpn_protocol_list_length;
};
@@ -84,28 +86,26 @@ struct tsi_ssl_server_handshaker_factory {
The tsi_peer array contains the subject names of the server certificates
associated with the contexts at the same index. */
tsi_ssl_handshaker_factory base;
- SSL_CTX **ssl_contexts;
- tsi_peer *ssl_context_x509_subject_names;
+ SSL_CTX** ssl_contexts;
+ tsi_peer* ssl_context_x509_subject_names;
size_t ssl_context_count;
- unsigned char *alpn_protocol_list;
+ unsigned char* alpn_protocol_list;
size_t alpn_protocol_list_length;
};
typedef struct {
tsi_handshaker base;
- SSL *ssl;
- BIO *into_ssl;
- BIO *from_ssl;
+ SSL* ssl;
+ BIO* network_io;
tsi_result result;
- tsi_ssl_handshaker_factory *factory_ref;
+ tsi_ssl_handshaker_factory* factory_ref;
} tsi_ssl_handshaker;
typedef struct {
tsi_frame_protector base;
- SSL *ssl;
- BIO *into_ssl;
- BIO *from_ssl;
- unsigned char *buffer;
+ SSL* ssl;
+ BIO* network_io;
+ unsigned char* buffer;
size_t buffer_size;
size_t buffer_offset;
} tsi_ssl_frame_protector;
@@ -113,9 +113,12 @@ typedef struct {
/* --- Library Initialization. ---*/
static gpr_once init_openssl_once = GPR_ONCE_INIT;
-static gpr_mu *openssl_mutexes = NULL;
+static gpr_mu* openssl_mutexes = nullptr;
+static void openssl_locking_cb(int mode, int type, const char* file,
+ int line) GRPC_UNUSED;
+static unsigned long openssl_thread_id_cb(void) GRPC_UNUSED;
-static void openssl_locking_cb(int mode, int type, const char *file, int line) {
+static void openssl_locking_cb(int mode, int type, const char* file, int line) {
if (mode & CRYPTO_LOCK) {
gpr_mu_lock(&openssl_mutexes[type]);
} else {
@@ -135,7 +138,7 @@ static void init_openssl(void) {
OpenSSL_add_all_algorithms();
num_locks = CRYPTO_num_locks();
GPR_ASSERT(num_locks > 0);
- openssl_mutexes = gpr_malloc((size_t)num_locks * sizeof(gpr_mu));
+ openssl_mutexes = (gpr_mu*)gpr_malloc((size_t)num_locks * sizeof(gpr_mu));
for (i = 0; i < CRYPTO_num_locks(); i++) {
gpr_mu_init(&openssl_mutexes[i]);
}
@@ -145,7 +148,7 @@ static void init_openssl(void) {
/* --- Ssl utils. ---*/
-static const char *ssl_error_string(int error) {
+static const char* ssl_error_string(int error) {
switch (error) {
case SSL_ERROR_NONE:
return "SSL_ERROR_NONE";
@@ -171,16 +174,16 @@ static const char *ssl_error_string(int error) {
}
/* TODO(jboeuf): Remove when we are past the debugging phase with this code. */
-static void ssl_log_where_info(const SSL *ssl, int where, int flag,
- const char *msg) {
- if ((where & flag) && GRPC_TRACER_ON(tsi_tracing_enabled)) {
+static void ssl_log_where_info(const SSL* ssl, int where, int flag,
+ const char* msg) {
+ if ((where & flag) && tsi_tracing_enabled.enabled()) {
gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg,
SSL_state_string_long(ssl), SSL_state_string(ssl));
}
}
/* Used for debugging. TODO(jboeuf): Remove when code is mature enough. */
-static void ssl_info_callback(const SSL *ssl, int where, int ret) {
+static void ssl_info_callback(const SSL* ssl, int where, int ret) {
if (ret == 0) {
gpr_log(GPR_ERROR, "ssl_info_callback: error occured.\n");
return;
@@ -193,7 +196,7 @@ static void ssl_info_callback(const SSL *ssl, int where, int ret) {
/* Returns 1 if name looks like an IP address, 0 otherwise.
This is a very rough heuristic, and only handles IPv6 in hexadecimal form. */
-static int looks_like_ip_address(const char *name) {
+static int looks_like_ip_address(const char* name) {
size_t i;
size_t dot_count = 0;
size_t num_size = 0;
@@ -218,14 +221,14 @@ static int looks_like_ip_address(const char *name) {
}
/* Gets the subject CN from an X509 cert. */
-static tsi_result ssl_get_x509_common_name(X509 *cert, unsigned char **utf8,
- size_t *utf8_size) {
+static tsi_result ssl_get_x509_common_name(X509* cert, unsigned char** utf8,
+ size_t* utf8_size) {
int common_name_index = -1;
- X509_NAME_ENTRY *common_name_entry = NULL;
- ASN1_STRING *common_name_asn1 = NULL;
- X509_NAME *subject_name = X509_get_subject_name(cert);
+ X509_NAME_ENTRY* common_name_entry = nullptr;
+ ASN1_STRING* common_name_asn1 = nullptr;
+ X509_NAME* subject_name = X509_get_subject_name(cert);
int utf8_returned_size = 0;
- if (subject_name == NULL) {
+ if (subject_name == nullptr) {
gpr_log(GPR_ERROR, "Could not get subject name from certificate.");
return TSI_NOT_FOUND;
}
@@ -237,12 +240,12 @@ static tsi_result ssl_get_x509_common_name(X509 *cert, unsigned char **utf8,
return TSI_NOT_FOUND;
}
common_name_entry = X509_NAME_get_entry(subject_name, common_name_index);
- if (common_name_entry == NULL) {
+ if (common_name_entry == nullptr) {
gpr_log(GPR_ERROR, "Could not get common name entry from certificate.");
return TSI_INTERNAL_ERROR;
}
common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
- if (common_name_asn1 == NULL) {
+ if (common_name_asn1 == nullptr) {
gpr_log(GPR_ERROR,
"Could not get common name entry asn1 from certificate.");
return TSI_INTERNAL_ERROR;
@@ -258,14 +261,14 @@ static tsi_result ssl_get_x509_common_name(X509 *cert, unsigned char **utf8,
/* Gets the subject CN of an X509 cert as a tsi_peer_property. */
static tsi_result peer_property_from_x509_common_name(
- X509 *cert, tsi_peer_property *property) {
- unsigned char *common_name;
+ X509* cert, tsi_peer_property* property) {
+ unsigned char* common_name;
size_t common_name_size;
tsi_result result =
ssl_get_x509_common_name(cert, &common_name, &common_name_size);
if (result != TSI_OK) {
if (result == TSI_NOT_FOUND) {
- common_name = NULL;
+ common_name = nullptr;
common_name_size = 0;
} else {
return result;
@@ -273,35 +276,34 @@ static tsi_result peer_property_from_x509_common_name(
}
result = tsi_construct_string_peer_property(
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY,
- common_name == NULL ? "" : (const char *)common_name, common_name_size,
+ common_name == nullptr ? "" : (const char*)common_name, common_name_size,
property);
OPENSSL_free(common_name);
return result;
}
/* Gets the X509 cert in PEM format as a tsi_peer_property. */
-static tsi_result add_pem_certificate(X509 *cert, tsi_peer_property *property) {
- BIO *bio = BIO_new(BIO_s_mem());
+static tsi_result add_pem_certificate(X509* cert, tsi_peer_property* property) {
+ BIO* bio = BIO_new(BIO_s_mem());
if (!PEM_write_bio_X509(bio, cert)) {
BIO_free(bio);
return TSI_INTERNAL_ERROR;
}
- char *contents;
+ char* contents;
long len = BIO_get_mem_data(bio, &contents);
if (len <= 0) {
BIO_free(bio);
return TSI_INTERNAL_ERROR;
}
tsi_result result = tsi_construct_string_peer_property(
- TSI_X509_PEM_CERT_PROPERTY, (const char *)contents, (size_t)len,
- property);
+ TSI_X509_PEM_CERT_PROPERTY, (const char*)contents, (size_t)len, property);
BIO_free(bio);
return result;
}
/* Gets the subject SANs from an X509 cert as a tsi_peer_property. */
static tsi_result add_subject_alt_names_properties_to_peer(
- tsi_peer *peer, GENERAL_NAMES *subject_alt_names,
+ tsi_peer* peer, GENERAL_NAMES* subject_alt_names,
size_t subject_alt_name_count) {
size_t i;
tsi_result result = TSI_OK;
@@ -310,11 +312,11 @@ static tsi_result add_subject_alt_names_properties_to_peer(
peer->property_count -= subject_alt_name_count;
for (i = 0; i < subject_alt_name_count; i++) {
- GENERAL_NAME *subject_alt_name =
+ GENERAL_NAME* subject_alt_name =
sk_GENERAL_NAME_value(subject_alt_names, TSI_SIZE_AS_SIZE(i));
/* Filter out the non-dns entries names. */
if (subject_alt_name->type == GEN_DNS) {
- unsigned char *name = NULL;
+ unsigned char* name = nullptr;
int name_size;
name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.dNSName);
if (name_size < 0) {
@@ -323,7 +325,7 @@ static tsi_result add_subject_alt_names_properties_to_peer(
break;
}
result = tsi_construct_string_peer_property(
- TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, (const char *)name,
+ TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, (const char*)name,
(size_t)name_size, &peer->properties[peer->property_count++]);
OPENSSL_free(name);
} else if (subject_alt_name->type == GEN_IPADD) {
@@ -339,9 +341,9 @@ static tsi_result add_subject_alt_names_properties_to_peer(
result = TSI_INTERNAL_ERROR;
break;
}
- const char *name = inet_ntop(af, subject_alt_name->d.iPAddress->data,
+ const char* name = inet_ntop(af, subject_alt_name->d.iPAddress->data,
ntop_buf, INET6_ADDRSTRLEN);
- if (name == NULL) {
+ if (name == nullptr) {
gpr_log(GPR_ERROR, "Could not get IP string from asn1 octet.");
result = TSI_INTERNAL_ERROR;
break;
@@ -357,12 +359,12 @@ static tsi_result add_subject_alt_names_properties_to_peer(
}
/* Gets information about the peer's X509 cert as a tsi_peer object. */
-static tsi_result peer_from_x509(X509 *cert, int include_certificate_type,
- tsi_peer *peer) {
+static tsi_result peer_from_x509(X509* cert, int include_certificate_type,
+ tsi_peer* peer) {
/* TODO(jboeuf): Maybe add more properties. */
- GENERAL_NAMES *subject_alt_names =
- X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0);
- int subject_alt_name_count = (subject_alt_names != NULL)
+ GENERAL_NAMES* subject_alt_names = (GENERAL_NAMES*)X509_get_ext_d2i(
+ cert, NID_subject_alt_name, nullptr, nullptr);
+ int subject_alt_name_count = (subject_alt_names != nullptr)
? (int)sk_GENERAL_NAME_num(subject_alt_names)
: 0;
size_t property_count;
@@ -395,7 +397,7 @@ static tsi_result peer_from_x509(X509 *cert, int include_certificate_type,
}
} while (0);
- if (subject_alt_names != NULL) {
+ if (subject_alt_names != nullptr) {
sk_GENERAL_NAME_pop_free(subject_alt_names, GENERAL_NAME_free);
}
if (result != TSI_OK) tsi_peer_destruct(peer);
@@ -413,8 +415,8 @@ static void log_ssl_error_stack(void) {
}
/* Performs an SSL_read and handle errors. */
-static tsi_result do_ssl_read(SSL *ssl, unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size) {
+static tsi_result do_ssl_read(SSL* ssl, unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size) {
int read_from_ssl;
GPR_ASSERT(*unprotected_bytes_size <= INT_MAX);
read_from_ssl =
@@ -446,7 +448,7 @@ static tsi_result do_ssl_read(SSL *ssl, unsigned char *unprotected_bytes,
}
/* Performs an SSL_write and handle errors. */
-static tsi_result do_ssl_write(SSL *ssl, unsigned char *unprotected_bytes,
+static tsi_result do_ssl_write(SSL* ssl, unsigned char* unprotected_bytes,
size_t unprotected_bytes_size) {
int ssl_write_result;
GPR_ASSERT(unprotected_bytes_size <= INT_MAX);
@@ -468,19 +470,19 @@ static tsi_result do_ssl_write(SSL *ssl, unsigned char *unprotected_bytes,
}
/* Loads an in-memory PEM certificate chain into the SSL context. */
-static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
- const char *pem_cert_chain,
+static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
+ const char* pem_cert_chain,
size_t pem_cert_chain_size) {
tsi_result result = TSI_OK;
- X509 *certificate = NULL;
- BIO *pem;
+ X509* certificate = nullptr;
+ BIO* pem;
GPR_ASSERT(pem_cert_chain_size <= INT_MAX);
- pem = BIO_new_mem_buf((void *)pem_cert_chain, (int)pem_cert_chain_size);
- if (pem == NULL) return TSI_OUT_OF_RESOURCES;
+ pem = BIO_new_mem_buf((void*)pem_cert_chain, (int)pem_cert_chain_size);
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
do {
- certificate = PEM_read_bio_X509_AUX(pem, NULL, NULL, "");
- if (certificate == NULL) {
+ certificate = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)"");
+ if (certificate == nullptr) {
result = TSI_INVALID_ARGUMENT;
break;
}
@@ -489,8 +491,9 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
break;
}
while (1) {
- X509 *certificate_authority = PEM_read_bio_X509(pem, NULL, NULL, "");
- if (certificate_authority == NULL) {
+ X509* certificate_authority =
+ PEM_read_bio_X509(pem, nullptr, nullptr, (void*)"");
+ if (certificate_authority == nullptr) {
ERR_clear_error();
break; /* Done reading. */
}
@@ -505,23 +508,23 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
}
} while (0);
- if (certificate != NULL) X509_free(certificate);
+ if (certificate != nullptr) X509_free(certificate);
BIO_free(pem);
return result;
}
/* Loads an in-memory PEM private key into the SSL context. */
-static tsi_result ssl_ctx_use_private_key(SSL_CTX *context, const char *pem_key,
+static tsi_result ssl_ctx_use_private_key(SSL_CTX* context, const char* pem_key,
size_t pem_key_size) {
tsi_result result = TSI_OK;
- EVP_PKEY *private_key = NULL;
- BIO *pem;
+ EVP_PKEY* private_key = nullptr;
+ BIO* pem;
GPR_ASSERT(pem_key_size <= INT_MAX);
- pem = BIO_new_mem_buf((void *)pem_key, (int)pem_key_size);
- if (pem == NULL) return TSI_OUT_OF_RESOURCES;
+ pem = BIO_new_mem_buf((void*)pem_key, (int)pem_key_size);
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
do {
- private_key = PEM_read_bio_PrivateKey(pem, NULL, NULL, "");
- if (private_key == NULL) {
+ private_key = PEM_read_bio_PrivateKey(pem, nullptr, nullptr, (void*)"");
+ if (private_key == nullptr) {
result = TSI_INVALID_ARGUMENT;
break;
}
@@ -530,54 +533,54 @@ static tsi_result ssl_ctx_use_private_key(SSL_CTX *context, const char *pem_key,
break;
}
} while (0);
- if (private_key != NULL) EVP_PKEY_free(private_key);
+ if (private_key != nullptr) EVP_PKEY_free(private_key);
BIO_free(pem);
return result;
}
/* Loads in-memory PEM verification certs into the SSL context and optionally
returns the verification cert names (root_names can be NULL). */
-static tsi_result ssl_ctx_load_verification_certs(SSL_CTX *context,
- const char *pem_roots,
+static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context,
+ const char* pem_roots,
size_t pem_roots_size,
STACK_OF(X509_NAME) *
*root_names) {
tsi_result result = TSI_OK;
size_t num_roots = 0;
- X509 *root = NULL;
- X509_NAME *root_name = NULL;
- BIO *pem;
- X509_STORE *root_store;
+ X509* root = nullptr;
+ X509_NAME* root_name = nullptr;
+ BIO* pem;
+ X509_STORE* root_store;
GPR_ASSERT(pem_roots_size <= INT_MAX);
- pem = BIO_new_mem_buf((void *)pem_roots, (int)pem_roots_size);
+ pem = BIO_new_mem_buf((void*)pem_roots, (int)pem_roots_size);
root_store = SSL_CTX_get_cert_store(context);
- if (root_store == NULL) return TSI_INVALID_ARGUMENT;
- if (pem == NULL) return TSI_OUT_OF_RESOURCES;
- if (root_names != NULL) {
+ if (root_store == nullptr) return TSI_INVALID_ARGUMENT;
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
+ if (root_names != nullptr) {
*root_names = sk_X509_NAME_new_null();
- if (*root_names == NULL) return TSI_OUT_OF_RESOURCES;
+ if (*root_names == nullptr) return TSI_OUT_OF_RESOURCES;
}
while (1) {
- root = PEM_read_bio_X509_AUX(pem, NULL, NULL, "");
- if (root == NULL) {
+ root = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)"");
+ if (root == nullptr) {
ERR_clear_error();
break; /* We're at the end of stream. */
}
- if (root_names != NULL) {
+ if (root_names != nullptr) {
root_name = X509_get_subject_name(root);
- if (root_name == NULL) {
+ if (root_name == nullptr) {
gpr_log(GPR_ERROR, "Could not get name from root certificate.");
result = TSI_INVALID_ARGUMENT;
break;
}
root_name = X509_NAME_dup(root_name);
- if (root_name == NULL) {
+ if (root_name == nullptr) {
result = TSI_OUT_OF_RESOURCES;
break;
}
sk_X509_NAME_push(*root_names, root_name);
- root_name = NULL;
+ root_name = nullptr;
}
if (!X509_STORE_add_cert(root_store, root)) {
gpr_log(GPR_ERROR, "Could not add root certificate to ssl context.");
@@ -594,11 +597,11 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX *context,
}
if (result != TSI_OK) {
- if (root != NULL) X509_free(root);
- if (root_names != NULL) {
+ if (root != nullptr) X509_free(root);
+ if (root_names != nullptr) {
sk_X509_NAME_pop_free(*root_names, X509_NAME_free);
- *root_names = NULL;
- if (root_name != NULL) X509_NAME_free(root_name);
+ *root_names = nullptr;
+ if (root_name != nullptr) X509_NAME_free(root_name);
}
}
BIO_free(pem);
@@ -608,11 +611,11 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX *context,
/* Populates the SSL context with a private key and a cert chain, and sets the
cipher list and the ephemeral ECDH key. */
static tsi_result populate_ssl_context(
- SSL_CTX *context, const tsi_ssl_pem_key_cert_pair *key_cert_pair,
- const char *cipher_list) {
+ SSL_CTX* context, const tsi_ssl_pem_key_cert_pair* key_cert_pair,
+ const char* cipher_list) {
tsi_result result = TSI_OK;
- if (key_cert_pair != NULL) {
- if (key_cert_pair->cert_chain != NULL) {
+ if (key_cert_pair != nullptr) {
+ if (key_cert_pair->cert_chain != nullptr) {
result = ssl_ctx_use_certificate_chain(context, key_cert_pair->cert_chain,
strlen(key_cert_pair->cert_chain));
if (result != TSI_OK) {
@@ -620,7 +623,7 @@ static tsi_result populate_ssl_context(
return result;
}
}
- if (key_cert_pair->private_key != NULL) {
+ if (key_cert_pair->private_key != nullptr) {
result = ssl_ctx_use_private_key(context, key_cert_pair->private_key,
strlen(key_cert_pair->private_key));
if (result != TSI_OK || !SSL_CTX_check_private_key(context)) {
@@ -629,12 +632,13 @@ static tsi_result populate_ssl_context(
}
}
}
- if ((cipher_list != NULL) && !SSL_CTX_set_cipher_list(context, cipher_list)) {
+ if ((cipher_list != nullptr) &&
+ !SSL_CTX_set_cipher_list(context, cipher_list)) {
gpr_log(GPR_ERROR, "Invalid cipher list: %s.", cipher_list);
return TSI_INVALID_ARGUMENT;
}
{
- EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
+ EC_KEY* ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
if (!SSL_CTX_set_tmp_ecdh(context, ecdh)) {
gpr_log(GPR_ERROR, "Could not set ephemeral ECDH key.");
EC_KEY_free(ecdh);
@@ -647,45 +651,46 @@ static tsi_result populate_ssl_context(
}
/* Extracts the CN and the SANs from an X509 cert as a peer object. */
-static tsi_result extract_x509_subject_names_from_pem_cert(const char *pem_cert,
- tsi_peer *peer) {
+static tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert,
+ tsi_peer* peer) {
tsi_result result = TSI_OK;
- X509 *cert = NULL;
- BIO *pem;
- pem = BIO_new_mem_buf((void *)pem_cert, (int)strlen(pem_cert));
- if (pem == NULL) return TSI_OUT_OF_RESOURCES;
+ X509* cert = nullptr;
+ BIO* pem;
+ pem = BIO_new_mem_buf((void*)pem_cert, (int)strlen(pem_cert));
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
- cert = PEM_read_bio_X509(pem, NULL, NULL, "");
- if (cert == NULL) {
+ cert = PEM_read_bio_X509(pem, nullptr, nullptr, (void*)"");
+ if (cert == nullptr) {
gpr_log(GPR_ERROR, "Invalid certificate");
result = TSI_INVALID_ARGUMENT;
} else {
result = peer_from_x509(cert, 0, peer);
}
- if (cert != NULL) X509_free(cert);
+ if (cert != nullptr) X509_free(cert);
BIO_free(pem);
return result;
}
/* Builds the alpn protocol name list according to rfc 7301. */
static tsi_result build_alpn_protocol_name_list(
- const char **alpn_protocols, uint16_t num_alpn_protocols,
- unsigned char **protocol_name_list, size_t *protocol_name_list_length) {
+ const char** alpn_protocols, uint16_t num_alpn_protocols,
+ unsigned char** protocol_name_list, size_t* protocol_name_list_length) {
uint16_t i;
- unsigned char *current;
- *protocol_name_list = NULL;
+ unsigned char* current;
+ *protocol_name_list = nullptr;
*protocol_name_list_length = 0;
if (num_alpn_protocols == 0) return TSI_INVALID_ARGUMENT;
for (i = 0; i < num_alpn_protocols; i++) {
- size_t length = alpn_protocols[i] == NULL ? 0 : strlen(alpn_protocols[i]);
+ size_t length =
+ alpn_protocols[i] == nullptr ? 0 : strlen(alpn_protocols[i]);
if (length == 0 || length > 255) {
gpr_log(GPR_ERROR, "Invalid protocol name length: %d.", (int)length);
return TSI_INVALID_ARGUMENT;
}
*protocol_name_list_length += length + 1;
}
- *protocol_name_list = gpr_malloc(*protocol_name_list_length);
- if (*protocol_name_list == NULL) return TSI_OUT_OF_RESOURCES;
+ *protocol_name_list = (unsigned char*)gpr_malloc(*protocol_name_list_length);
+ if (*protocol_name_list == nullptr) return TSI_OUT_OF_RESOURCES;
current = *protocol_name_list;
for (i = 0; i < num_alpn_protocols; i++) {
size_t length = strlen(alpn_protocols[i]);
@@ -706,28 +711,28 @@ static tsi_result build_alpn_protocol_name_list(
// the server's certificate, but we need to pull it anyway, in case a higher
// layer wants to look at it. In this case the verification may fail, but
// we don't really care.
-static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX *ctx) {
+static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) {
return 1;
}
/* --- tsi_frame_protector methods implementation. ---*/
-static tsi_result ssl_protector_protect(tsi_frame_protector *self,
- const unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size) {
- tsi_ssl_frame_protector *impl = (tsi_ssl_frame_protector *)self;
+static tsi_result ssl_protector_protect(tsi_frame_protector* self,
+ const unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size) {
+ tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
int read_from_ssl;
size_t available;
tsi_result result = TSI_OK;
/* First see if we have some pending data in the SSL BIO. */
- int pending_in_ssl = (int)BIO_pending(impl->from_ssl);
+ int pending_in_ssl = (int)BIO_pending(impl->network_io);
if (pending_in_ssl > 0) {
*unprotected_bytes_size = 0;
GPR_ASSERT(*protected_output_frames_size <= INT_MAX);
- read_from_ssl = BIO_read(impl->from_ssl, protected_output_frames,
+ read_from_ssl = BIO_read(impl->network_io, protected_output_frames,
(int)*protected_output_frames_size);
if (read_from_ssl < 0) {
gpr_log(GPR_ERROR,
@@ -755,7 +760,7 @@ static tsi_result ssl_protector_protect(tsi_frame_protector *self,
if (result != TSI_OK) return result;
GPR_ASSERT(*protected_output_frames_size <= INT_MAX);
- read_from_ssl = BIO_read(impl->from_ssl, protected_output_frames,
+ read_from_ssl = BIO_read(impl->network_io, protected_output_frames,
(int)*protected_output_frames_size);
if (read_from_ssl < 0) {
gpr_log(GPR_ERROR, "Could not read from BIO after SSL_write.");
@@ -768,10 +773,10 @@ static tsi_result ssl_protector_protect(tsi_frame_protector *self,
}
static tsi_result ssl_protector_protect_flush(
- tsi_frame_protector *self, unsigned char *protected_output_frames,
- size_t *protected_output_frames_size, size_t *still_pending_size) {
+ tsi_frame_protector* self, unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size, size_t* still_pending_size) {
tsi_result result = TSI_OK;
- tsi_ssl_frame_protector *impl = (tsi_ssl_frame_protector *)self;
+ tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
int read_from_ssl = 0;
int pending;
@@ -781,34 +786,34 @@ static tsi_result ssl_protector_protect_flush(
impl->buffer_offset = 0;
}
- pending = (int)BIO_pending(impl->from_ssl);
+ pending = (int)BIO_pending(impl->network_io);
GPR_ASSERT(pending >= 0);
*still_pending_size = (size_t)pending;
if (*still_pending_size == 0) return TSI_OK;
GPR_ASSERT(*protected_output_frames_size <= INT_MAX);
- read_from_ssl = BIO_read(impl->from_ssl, protected_output_frames,
+ read_from_ssl = BIO_read(impl->network_io, protected_output_frames,
(int)*protected_output_frames_size);
if (read_from_ssl <= 0) {
gpr_log(GPR_ERROR, "Could not read from BIO after SSL_write.");
return TSI_INTERNAL_ERROR;
}
*protected_output_frames_size = (size_t)read_from_ssl;
- pending = (int)BIO_pending(impl->from_ssl);
+ pending = (int)BIO_pending(impl->network_io);
GPR_ASSERT(pending >= 0);
*still_pending_size = (size_t)pending;
return TSI_OK;
}
static tsi_result ssl_protector_unprotect(
- tsi_frame_protector *self, const unsigned char *protected_frames_bytes,
- size_t *protected_frames_bytes_size, unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size) {
+ tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
+ size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size) {
tsi_result result = TSI_OK;
int written_into_ssl = 0;
size_t output_bytes_size = *unprotected_bytes_size;
size_t output_bytes_offset = 0;
- tsi_ssl_frame_protector *impl = (tsi_ssl_frame_protector *)self;
+ tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
/* First, try to read remaining data from ssl. */
result = do_ssl_read(impl->ssl, unprotected_bytes, unprotected_bytes_size);
@@ -824,7 +829,7 @@ static tsi_result ssl_protector_unprotect(
/* Then, try to write some data to ssl. */
GPR_ASSERT(*protected_frames_bytes_size <= INT_MAX);
- written_into_ssl = BIO_write(impl->into_ssl, protected_frames_bytes,
+ written_into_ssl = BIO_write(impl->network_io, protected_frames_bytes,
(int)*protected_frames_bytes_size);
if (written_into_ssl < 0) {
gpr_log(GPR_ERROR, "Sending protected frame to ssl failed with %d",
@@ -842,25 +847,28 @@ static tsi_result ssl_protector_unprotect(
return result;
}
-static void ssl_protector_destroy(tsi_frame_protector *self) {
- tsi_ssl_frame_protector *impl = (tsi_ssl_frame_protector *)self;
- if (impl->buffer != NULL) gpr_free(impl->buffer);
- if (impl->ssl != NULL) SSL_free(impl->ssl);
+static void ssl_protector_destroy(tsi_frame_protector* self) {
+ tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
+ if (impl->buffer != nullptr) gpr_free(impl->buffer);
+ if (impl->ssl != nullptr) SSL_free(impl->ssl);
+ if (impl->network_io != nullptr) BIO_free(impl->network_io);
gpr_free(self);
}
static const tsi_frame_protector_vtable frame_protector_vtable = {
- ssl_protector_protect, ssl_protector_protect_flush, ssl_protector_unprotect,
+ ssl_protector_protect,
+ ssl_protector_protect_flush,
+ ssl_protector_unprotect,
ssl_protector_destroy,
};
/* --- tsi_server_handshaker_factory methods implementation. --- */
static void tsi_ssl_handshaker_factory_destroy(
- tsi_ssl_handshaker_factory *self) {
- if (self == NULL) return;
+ tsi_ssl_handshaker_factory* self) {
+ if (self == nullptr) return;
- if (self->vtable != NULL && self->vtable->destroy != NULL) {
+ if (self->vtable != nullptr && self->vtable->destroy != nullptr) {
self->vtable->destroy(self);
}
/* Note, we don't free(self) here because this object is always directly
@@ -868,28 +876,28 @@ static void tsi_ssl_handshaker_factory_destroy(
* any memory, it should be free'd here. */
}
-static tsi_ssl_handshaker_factory *tsi_ssl_handshaker_factory_ref(
- tsi_ssl_handshaker_factory *self) {
- if (self == NULL) return NULL;
+static tsi_ssl_handshaker_factory* tsi_ssl_handshaker_factory_ref(
+ tsi_ssl_handshaker_factory* self) {
+ if (self == nullptr) return nullptr;
gpr_refn(&self->refcount, 1);
return self;
}
-static void tsi_ssl_handshaker_factory_unref(tsi_ssl_handshaker_factory *self) {
- if (self == NULL) return;
+static void tsi_ssl_handshaker_factory_unref(tsi_ssl_handshaker_factory* self) {
+ if (self == nullptr) return;
if (gpr_unref(&self->refcount)) {
tsi_ssl_handshaker_factory_destroy(self);
}
}
-static tsi_ssl_handshaker_factory_vtable handshaker_factory_vtable = {NULL};
+static tsi_ssl_handshaker_factory_vtable handshaker_factory_vtable = {nullptr};
/* Initializes a tsi_ssl_handshaker_factory object. Caller is responsible for
* allocating memory for the factory. */
static void tsi_ssl_handshaker_factory_init(
- tsi_ssl_handshaker_factory *factory) {
- GPR_ASSERT(factory != NULL);
+ tsi_ssl_handshaker_factory* factory) {
+ GPR_ASSERT(factory != nullptr);
factory->vtable = &handshaker_factory_vtable;
gpr_ref_init(&factory->refcount, 1);
@@ -897,20 +905,20 @@ static void tsi_ssl_handshaker_factory_init(
/* --- tsi_handshaker methods implementation. ---*/
-static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
- unsigned char *bytes,
- size_t *bytes_size) {
- tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
+static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
+ unsigned char* bytes,
+ size_t* bytes_size) {
+ tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
int bytes_read_from_ssl = 0;
- if (bytes == NULL || bytes_size == NULL || *bytes_size == 0 ||
+ if (bytes == nullptr || bytes_size == nullptr || *bytes_size == 0 ||
*bytes_size > INT_MAX) {
return TSI_INVALID_ARGUMENT;
}
GPR_ASSERT(*bytes_size <= INT_MAX);
- bytes_read_from_ssl = BIO_read(impl->from_ssl, bytes, (int)*bytes_size);
+ bytes_read_from_ssl = BIO_read(impl->network_io, bytes, (int)*bytes_size);
if (bytes_read_from_ssl < 0) {
*bytes_size = 0;
- if (!BIO_should_retry(impl->from_ssl)) {
+ if (!BIO_should_retry(impl->network_io)) {
impl->result = TSI_INTERNAL_ERROR;
return impl->result;
} else {
@@ -918,11 +926,11 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
}
}
*bytes_size = (size_t)bytes_read_from_ssl;
- return BIO_pending(impl->from_ssl) == 0 ? TSI_OK : TSI_INCOMPLETE_DATA;
+ return BIO_pending(impl->network_io) == 0 ? TSI_OK : TSI_INCOMPLETE_DATA;
}
-static tsi_result ssl_handshaker_get_result(tsi_handshaker *self) {
- tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
+static tsi_result ssl_handshaker_get_result(tsi_handshaker* self) {
+ tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
if ((impl->result == TSI_HANDSHAKE_IN_PROGRESS) &&
SSL_is_init_finished(impl->ssl)) {
impl->result = TSI_OK;
@@ -931,15 +939,15 @@ static tsi_result ssl_handshaker_get_result(tsi_handshaker *self) {
}
static tsi_result ssl_handshaker_process_bytes_from_peer(
- tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size) {
- tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
+ tsi_handshaker* self, const unsigned char* bytes, size_t* bytes_size) {
+ tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
int bytes_written_into_ssl_size = 0;
- if (bytes == NULL || bytes_size == 0 || *bytes_size > INT_MAX) {
+ if (bytes == nullptr || bytes_size == nullptr || *bytes_size > INT_MAX) {
return TSI_INVALID_ARGUMENT;
}
GPR_ASSERT(*bytes_size <= INT_MAX);
bytes_written_into_ssl_size =
- BIO_write(impl->into_ssl, bytes, (int)*bytes_size);
+ BIO_write(impl->network_io, bytes, (int)*bytes_size);
if (bytes_written_into_ssl_size < 0) {
gpr_log(GPR_ERROR, "Could not write to memory BIO.");
impl->result = TSI_INTERNAL_ERROR;
@@ -956,7 +964,7 @@ static tsi_result ssl_handshaker_process_bytes_from_peer(
ssl_result = SSL_get_error(impl->ssl, ssl_result);
switch (ssl_result) {
case SSL_ERROR_WANT_READ:
- if (BIO_pending(impl->from_ssl) == 0) {
+ if (BIO_pending(impl->network_io) == 0) {
/* We need more data. */
return TSI_INCOMPLETE_DATA;
} else {
@@ -976,14 +984,14 @@ static tsi_result ssl_handshaker_process_bytes_from_peer(
}
}
-static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
- tsi_peer *peer) {
+static tsi_result ssl_handshaker_extract_peer(tsi_handshaker* self,
+ tsi_peer* peer) {
tsi_result result = TSI_OK;
- const unsigned char *alpn_selected = NULL;
+ const unsigned char* alpn_selected = nullptr;
unsigned int alpn_selected_len;
- tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
- X509 *peer_cert = SSL_get_peer_certificate(impl->ssl);
- if (peer_cert != NULL) {
+ tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
+ X509* peer_cert = SSL_get_peer_certificate(impl->ssl);
+ if (peer_cert != nullptr) {
result = peer_from_x509(peer_cert, 1, peer);
X509_free(peer_cert);
if (result != TSI_OK) return result;
@@ -991,26 +999,26 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
#if TSI_OPENSSL_ALPN_SUPPORT
SSL_get0_alpn_selected(impl->ssl, &alpn_selected, &alpn_selected_len);
#endif /* TSI_OPENSSL_ALPN_SUPPORT */
- if (alpn_selected == NULL) {
+ if (alpn_selected == nullptr) {
/* Try npn. */
SSL_get0_next_proto_negotiated(impl->ssl, &alpn_selected,
&alpn_selected_len);
}
- if (alpn_selected != NULL) {
+ if (alpn_selected != nullptr) {
size_t i;
- tsi_peer_property *new_properties =
- gpr_zalloc(sizeof(*new_properties) * (peer->property_count + 1));
+ tsi_peer_property* new_properties = (tsi_peer_property*)gpr_zalloc(
+ sizeof(*new_properties) * (peer->property_count + 1));
for (i = 0; i < peer->property_count; i++) {
new_properties[i] = peer->properties[i];
}
result = tsi_construct_string_peer_property(
- TSI_SSL_ALPN_SELECTED_PROTOCOL, (const char *)alpn_selected,
+ TSI_SSL_ALPN_SELECTED_PROTOCOL, (const char*)alpn_selected,
alpn_selected_len, &new_properties[peer->property_count]);
if (result != TSI_OK) {
gpr_free(new_properties);
return result;
}
- if (peer->properties != NULL) gpr_free(peer->properties);
+ if (peer->properties != nullptr) gpr_free(peer->properties);
peer->property_count++;
peer->properties = new_properties;
}
@@ -1018,14 +1026,15 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
}
static tsi_result ssl_handshaker_create_frame_protector(
- tsi_handshaker *self, size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector) {
+ tsi_handshaker* self, size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector) {
size_t actual_max_output_protected_frame_size =
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND;
- tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
- tsi_ssl_frame_protector *protector_impl = gpr_zalloc(sizeof(*protector_impl));
+ tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
+ tsi_ssl_frame_protector* protector_impl =
+ (tsi_ssl_frame_protector*)gpr_zalloc(sizeof(*protector_impl));
- if (max_output_protected_frame_size != NULL) {
+ if (max_output_protected_frame_size != nullptr) {
if (*max_output_protected_frame_size >
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND) {
*max_output_protected_frame_size =
@@ -1039,29 +1048,32 @@ static tsi_result ssl_handshaker_create_frame_protector(
}
protector_impl->buffer_size =
actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD;
- protector_impl->buffer = gpr_malloc(protector_impl->buffer_size);
- if (protector_impl->buffer == NULL) {
+ protector_impl->buffer =
+ (unsigned char*)gpr_malloc(protector_impl->buffer_size);
+ if (protector_impl->buffer == nullptr) {
gpr_log(GPR_ERROR,
"Could not allocated buffer for tsi_ssl_frame_protector.");
gpr_free(protector_impl);
return TSI_INTERNAL_ERROR;
}
- /* Transfer ownership of ssl to the frame protector. It is OK as the caller
- * cannot call anything else but destroy on the handshaker after this call. */
+ /* Transfer ownership of ssl and network_io to the frame protector. It is OK
+ * as the caller cannot call anything else but destroy on the handshaker
+ * after this call. */
protector_impl->ssl = impl->ssl;
- impl->ssl = NULL;
- protector_impl->into_ssl = impl->into_ssl;
- protector_impl->from_ssl = impl->from_ssl;
+ impl->ssl = nullptr;
+ protector_impl->network_io = impl->network_io;
+ impl->network_io = nullptr;
protector_impl->base.vtable = &frame_protector_vtable;
*protector = &protector_impl->base;
return TSI_OK;
}
-static void ssl_handshaker_destroy(tsi_handshaker *self) {
- tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
- SSL_free(impl->ssl); /* The BIO objects are owned by ssl */
+static void ssl_handshaker_destroy(tsi_handshaker* self) {
+ tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
+ SSL_free(impl->ssl);
+ BIO_free(impl->network_io);
tsi_ssl_handshaker_factory_unref(impl->factory_ref);
gpr_free(impl);
}
@@ -1073,47 +1085,44 @@ static const tsi_handshaker_vtable handshaker_vtable = {
ssl_handshaker_extract_peer,
ssl_handshaker_create_frame_protector,
ssl_handshaker_destroy,
- NULL,
+ nullptr,
};
/* --- tsi_ssl_handshaker_factory common methods. --- */
-static tsi_result create_tsi_ssl_handshaker(SSL_CTX *ctx, int is_client,
- const char *server_name_indication,
- tsi_ssl_handshaker_factory *factory,
- tsi_handshaker **handshaker) {
- SSL *ssl = SSL_new(ctx);
- BIO *into_ssl = NULL;
- BIO *from_ssl = NULL;
- tsi_ssl_handshaker *impl = NULL;
- *handshaker = NULL;
- if (ctx == NULL) {
+static tsi_result create_tsi_ssl_handshaker(SSL_CTX* ctx, int is_client,
+ const char* server_name_indication,
+ tsi_ssl_handshaker_factory* factory,
+ tsi_handshaker** handshaker) {
+ SSL* ssl = SSL_new(ctx);
+ BIO* network_io = nullptr;
+ BIO* ssl_io = nullptr;
+ tsi_ssl_handshaker* impl = nullptr;
+ *handshaker = nullptr;
+ if (ctx == nullptr) {
gpr_log(GPR_ERROR, "SSL Context is null. Should never happen.");
return TSI_INTERNAL_ERROR;
}
- if (ssl == NULL) {
+ if (ssl == nullptr) {
return TSI_OUT_OF_RESOURCES;
}
SSL_set_info_callback(ssl, ssl_info_callback);
- into_ssl = BIO_new(BIO_s_mem());
- from_ssl = BIO_new(BIO_s_mem());
- if (into_ssl == NULL || from_ssl == NULL) {
- gpr_log(GPR_ERROR, "BIO_new failed.");
+ if (!BIO_new_bio_pair(&network_io, 0, &ssl_io, 0)) {
+ gpr_log(GPR_ERROR, "BIO_new_bio_pair failed.");
SSL_free(ssl);
- if (into_ssl != NULL) BIO_free(into_ssl);
- if (from_ssl != NULL) BIO_free(into_ssl);
return TSI_OUT_OF_RESOURCES;
}
- SSL_set_bio(ssl, into_ssl, from_ssl);
+ SSL_set_bio(ssl, ssl_io, ssl_io);
if (is_client) {
int ssl_result;
SSL_set_connect_state(ssl);
- if (server_name_indication != NULL) {
+ if (server_name_indication != nullptr) {
if (!SSL_set_tlsext_host_name(ssl, server_name_indication)) {
gpr_log(GPR_ERROR, "Invalid server name indication %s.",
server_name_indication);
SSL_free(ssl);
+ BIO_free(network_io);
return TSI_INTERNAL_ERROR;
}
}
@@ -1124,16 +1133,16 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX *ctx, int is_client,
"Unexpected error received from first SSL_do_handshake call: %s",
ssl_error_string(ssl_result));
SSL_free(ssl);
+ BIO_free(network_io);
return TSI_INTERNAL_ERROR;
}
} else {
SSL_set_accept_state(ssl);
}
- impl = gpr_zalloc(sizeof(*impl));
+ impl = (tsi_ssl_handshaker*)gpr_zalloc(sizeof(*impl));
impl->ssl = ssl;
- impl->into_ssl = into_ssl;
- impl->from_ssl = from_ssl;
+ impl->network_io = network_io;
impl->result = TSI_HANDSHAKE_IN_PROGRESS;
impl->base.vtable = &handshaker_vtable;
impl->factory_ref = tsi_ssl_handshaker_factory_ref(factory);
@@ -1142,16 +1151,16 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX *ctx, int is_client,
return TSI_OK;
}
-static int select_protocol_list(const unsigned char **out,
- unsigned char *outlen,
- const unsigned char *client_list,
+static int select_protocol_list(const unsigned char** out,
+ unsigned char* outlen,
+ const unsigned char* client_list,
size_t client_list_len,
- const unsigned char *server_list,
+ const unsigned char* server_list,
size_t server_list_len) {
- const unsigned char *client_current = client_list;
+ const unsigned char* client_current = client_list;
while ((unsigned int)(client_current - client_list) < client_list_len) {
unsigned char client_current_len = *(client_current++);
- const unsigned char *server_current = server_list;
+ const unsigned char* server_current = server_list;
while ((server_current >= server_list) &&
(uintptr_t)(server_current - server_list) < server_list_len) {
unsigned char server_current_len = *(server_current++);
@@ -1171,36 +1180,36 @@ static int select_protocol_list(const unsigned char **out,
/* --- tsi_ssl_client_handshaker_factory methods implementation. --- */
tsi_result tsi_ssl_client_handshaker_factory_create_handshaker(
- tsi_ssl_client_handshaker_factory *self, const char *server_name_indication,
- tsi_handshaker **handshaker) {
+ tsi_ssl_client_handshaker_factory* self, const char* server_name_indication,
+ tsi_handshaker** handshaker) {
return create_tsi_ssl_handshaker(self->ssl_context, 1, server_name_indication,
&self->base, handshaker);
}
void tsi_ssl_client_handshaker_factory_unref(
- tsi_ssl_client_handshaker_factory *self) {
- if (self == NULL) return;
+ tsi_ssl_client_handshaker_factory* self) {
+ if (self == nullptr) return;
tsi_ssl_handshaker_factory_unref(&self->base);
}
static void tsi_ssl_client_handshaker_factory_destroy(
- tsi_ssl_handshaker_factory *factory) {
- if (factory == NULL) return;
- tsi_ssl_client_handshaker_factory *self =
- (tsi_ssl_client_handshaker_factory *)factory;
- if (self->ssl_context != NULL) SSL_CTX_free(self->ssl_context);
- if (self->alpn_protocol_list != NULL) gpr_free(self->alpn_protocol_list);
+ tsi_ssl_handshaker_factory* factory) {
+ if (factory == nullptr) return;
+ tsi_ssl_client_handshaker_factory* self =
+ (tsi_ssl_client_handshaker_factory*)factory;
+ if (self->ssl_context != nullptr) SSL_CTX_free(self->ssl_context);
+ if (self->alpn_protocol_list != nullptr) gpr_free(self->alpn_protocol_list);
gpr_free(self);
}
-static int client_handshaker_factory_npn_callback(SSL *ssl, unsigned char **out,
- unsigned char *outlen,
- const unsigned char *in,
+static int client_handshaker_factory_npn_callback(SSL* ssl, unsigned char** out,
+ unsigned char* outlen,
+ const unsigned char* in,
unsigned int inlen,
- void *arg) {
- tsi_ssl_client_handshaker_factory *factory =
- (tsi_ssl_client_handshaker_factory *)arg;
- return select_protocol_list((const unsigned char **)out, outlen,
+ void* arg) {
+ tsi_ssl_client_handshaker_factory* factory =
+ (tsi_ssl_client_handshaker_factory*)arg;
+ return select_protocol_list((const unsigned char**)out, outlen,
factory->alpn_protocol_list,
factory->alpn_protocol_list_length, in, inlen);
}
@@ -1208,44 +1217,44 @@ static int client_handshaker_factory_npn_callback(SSL *ssl, unsigned char **out,
/* --- tsi_ssl_server_handshaker_factory methods implementation. --- */
tsi_result tsi_ssl_server_handshaker_factory_create_handshaker(
- tsi_ssl_server_handshaker_factory *self, tsi_handshaker **handshaker) {
+ tsi_ssl_server_handshaker_factory* self, tsi_handshaker** handshaker) {
if (self->ssl_context_count == 0) return TSI_INVALID_ARGUMENT;
/* Create the handshaker with the first context. We will switch if needed
because of SNI in ssl_server_handshaker_factory_servername_callback. */
- return create_tsi_ssl_handshaker(self->ssl_contexts[0], 0, NULL, &self->base,
- handshaker);
+ return create_tsi_ssl_handshaker(self->ssl_contexts[0], 0, nullptr,
+ &self->base, handshaker);
}
void tsi_ssl_server_handshaker_factory_unref(
- tsi_ssl_server_handshaker_factory *self) {
- if (self == NULL) return;
+ tsi_ssl_server_handshaker_factory* self) {
+ if (self == nullptr) return;
tsi_ssl_handshaker_factory_unref(&self->base);
}
static void tsi_ssl_server_handshaker_factory_destroy(
- tsi_ssl_handshaker_factory *factory) {
- if (factory == NULL) return;
- tsi_ssl_server_handshaker_factory *self =
- (tsi_ssl_server_handshaker_factory *)factory;
+ tsi_ssl_handshaker_factory* factory) {
+ if (factory == nullptr) return;
+ tsi_ssl_server_handshaker_factory* self =
+ (tsi_ssl_server_handshaker_factory*)factory;
size_t i;
for (i = 0; i < self->ssl_context_count; i++) {
- if (self->ssl_contexts[i] != NULL) {
+ if (self->ssl_contexts[i] != nullptr) {
SSL_CTX_free(self->ssl_contexts[i]);
tsi_peer_destruct(&self->ssl_context_x509_subject_names[i]);
}
}
- if (self->ssl_contexts != NULL) gpr_free(self->ssl_contexts);
- if (self->ssl_context_x509_subject_names != NULL) {
+ if (self->ssl_contexts != nullptr) gpr_free(self->ssl_contexts);
+ if (self->ssl_context_x509_subject_names != nullptr) {
gpr_free(self->ssl_context_x509_subject_names);
}
- if (self->alpn_protocol_list != NULL) gpr_free(self->alpn_protocol_list);
+ if (self->alpn_protocol_list != nullptr) gpr_free(self->alpn_protocol_list);
gpr_free(self);
}
-static int does_entry_match_name(const char *entry, size_t entry_length,
- const char *name) {
- const char *dot;
- const char *name_subdomain = NULL;
+static int does_entry_match_name(const char* entry, size_t entry_length,
+ const char* name) {
+ const char* dot;
+ const char* name_subdomain = nullptr;
size_t name_length = strlen(name);
size_t name_subdomain_length;
if (entry_length == 0) return 0;
@@ -1271,7 +1280,7 @@ static int does_entry_match_name(const char *entry, size_t entry_length,
return 0;
}
name_subdomain = strchr(name, '.');
- if (name_subdomain == NULL) return 0;
+ if (name_subdomain == nullptr) return 0;
name_subdomain_length = strlen(name_subdomain);
if (name_subdomain_length < 2) return 0;
name_subdomain++; /* Starts after the dot. */
@@ -1279,7 +1288,7 @@ static int does_entry_match_name(const char *entry, size_t entry_length,
entry += 2; /* Remove *. */
entry_length -= 2;
dot = strchr(name_subdomain, '.');
- if ((dot == NULL) || (dot == &name_subdomain[name_subdomain_length - 1])) {
+ if ((dot == nullptr) || (dot == &name_subdomain[name_subdomain_length - 1])) {
gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", name_subdomain);
return 0;
}
@@ -1290,13 +1299,13 @@ static int does_entry_match_name(const char *entry, size_t entry_length,
strncmp(entry, name_subdomain, entry_length) == 0);
}
-static int ssl_server_handshaker_factory_servername_callback(SSL *ssl, int *ap,
- void *arg) {
- tsi_ssl_server_handshaker_factory *impl =
- (tsi_ssl_server_handshaker_factory *)arg;
+static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap,
+ void* arg) {
+ tsi_ssl_server_handshaker_factory* impl =
+ (tsi_ssl_server_handshaker_factory*)arg;
size_t i = 0;
- const char *servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
- if (servername == NULL || strlen(servername) == 0) {
+ const char* servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
+ if (servername == nullptr || strlen(servername) == 0) {
return SSL_TLSEXT_ERR_NOACK;
}
@@ -1313,10 +1322,10 @@ static int ssl_server_handshaker_factory_servername_callback(SSL *ssl, int *ap,
#if TSI_OPENSSL_ALPN_SUPPORT
static int server_handshaker_factory_alpn_callback(
- SSL *ssl, const unsigned char **out, unsigned char *outlen,
- const unsigned char *in, unsigned int inlen, void *arg) {
- tsi_ssl_server_handshaker_factory *factory =
- (tsi_ssl_server_handshaker_factory *)arg;
+ SSL* ssl, const unsigned char** out, unsigned char* outlen,
+ const unsigned char* in, unsigned int inlen, void* arg) {
+ tsi_ssl_server_handshaker_factory* factory =
+ (tsi_ssl_server_handshaker_factory*)arg;
return select_protocol_list(out, outlen, in, inlen,
factory->alpn_protocol_list,
factory->alpn_protocol_list_length);
@@ -1324,9 +1333,9 @@ static int server_handshaker_factory_alpn_callback(
#endif /* TSI_OPENSSL_ALPN_SUPPORT */
static int server_handshaker_factory_npn_advertised_callback(
- SSL *ssl, const unsigned char **out, unsigned int *outlen, void *arg) {
- tsi_ssl_server_handshaker_factory *factory =
- (tsi_ssl_server_handshaker_factory *)arg;
+ SSL* ssl, const unsigned char** out, unsigned int* outlen, void* arg) {
+ tsi_ssl_server_handshaker_factory* factory =
+ (tsi_ssl_server_handshaker_factory*)arg;
*out = factory->alpn_protocol_list;
GPR_ASSERT(factory->alpn_protocol_list_length <= UINT_MAX);
*outlen = (unsigned int)factory->alpn_protocol_list_length;
@@ -1339,27 +1348,27 @@ static tsi_ssl_handshaker_factory_vtable client_handshaker_factory_vtable = {
tsi_ssl_client_handshaker_factory_destroy};
tsi_result tsi_create_ssl_client_handshaker_factory(
- const tsi_ssl_pem_key_cert_pair *pem_key_cert_pair,
- const char *pem_root_certs, const char *cipher_suites,
- const char **alpn_protocols, uint16_t num_alpn_protocols,
- tsi_ssl_client_handshaker_factory **factory) {
- SSL_CTX *ssl_context = NULL;
- tsi_ssl_client_handshaker_factory *impl = NULL;
+ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pair,
+ const char* pem_root_certs, const char* cipher_suites,
+ const char** alpn_protocols, uint16_t num_alpn_protocols,
+ tsi_ssl_client_handshaker_factory** factory) {
+ SSL_CTX* ssl_context = nullptr;
+ tsi_ssl_client_handshaker_factory* impl = nullptr;
tsi_result result = TSI_OK;
gpr_once_init(&init_openssl_once, init_openssl);
- if (factory == NULL) return TSI_INVALID_ARGUMENT;
- *factory = NULL;
- if (pem_root_certs == NULL) return TSI_INVALID_ARGUMENT;
+ if (factory == nullptr) return TSI_INVALID_ARGUMENT;
+ *factory = nullptr;
+ if (pem_root_certs == nullptr) return TSI_INVALID_ARGUMENT;
ssl_context = SSL_CTX_new(TLSv1_2_method());
- if (ssl_context == NULL) {
+ if (ssl_context == nullptr) {
gpr_log(GPR_ERROR, "Could not create ssl context.");
return TSI_INVALID_ARGUMENT;
}
- impl = gpr_zalloc(sizeof(*impl));
+ impl = (tsi_ssl_client_handshaker_factory*)gpr_zalloc(sizeof(*impl));
tsi_ssl_handshaker_factory_init(&impl->base);
impl->base.vtable = &client_handshaker_factory_vtable;
@@ -1370,7 +1379,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
populate_ssl_context(ssl_context, pem_key_cert_pair, cipher_suites);
if (result != TSI_OK) break;
result = ssl_ctx_load_verification_certs(ssl_context, pem_root_certs,
- strlen(pem_root_certs), NULL);
+ strlen(pem_root_certs), nullptr);
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Cannot load server root certificates.");
break;
@@ -1403,7 +1412,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
tsi_ssl_handshaker_factory_unref(&impl->base);
return result;
}
- SSL_CTX_set_verify(ssl_context, SSL_VERIFY_PEER, NULL);
+ SSL_CTX_set_verify(ssl_context, SSL_VERIFY_PEER, nullptr);
/* TODO(jboeuf): Add revocation verification. */
*factory = impl;
@@ -1414,11 +1423,11 @@ static tsi_ssl_handshaker_factory_vtable server_handshaker_factory_vtable = {
tsi_ssl_server_handshaker_factory_destroy};
tsi_result tsi_create_ssl_server_handshaker_factory(
- const tsi_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, const char *pem_client_root_certs,
- int force_client_auth, const char *cipher_suites,
- const char **alpn_protocols, uint16_t num_alpn_protocols,
- tsi_ssl_server_handshaker_factory **factory) {
+ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs, const char* pem_client_root_certs,
+ int force_client_auth, const char* cipher_suites,
+ const char** alpn_protocols, uint16_t num_alpn_protocols,
+ tsi_ssl_server_handshaker_factory** factory) {
return tsi_create_ssl_server_handshaker_factory_ex(
pem_key_cert_pairs, num_key_cert_pairs, pem_client_root_certs,
force_client_auth ? TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
@@ -1427,32 +1436,33 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
}
tsi_result tsi_create_ssl_server_handshaker_factory_ex(
- const tsi_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, const char *pem_client_root_certs,
+ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs, const char* pem_client_root_certs,
tsi_client_certificate_request_type client_certificate_request,
- const char *cipher_suites, const char **alpn_protocols,
- uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory **factory) {
- tsi_ssl_server_handshaker_factory *impl = NULL;
+ const char* cipher_suites, const char** alpn_protocols,
+ uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory** factory) {
+ tsi_ssl_server_handshaker_factory* impl = nullptr;
tsi_result result = TSI_OK;
size_t i = 0;
gpr_once_init(&init_openssl_once, init_openssl);
- if (factory == NULL) return TSI_INVALID_ARGUMENT;
- *factory = NULL;
- if (num_key_cert_pairs == 0 || pem_key_cert_pairs == NULL) {
+ if (factory == nullptr) return TSI_INVALID_ARGUMENT;
+ *factory = nullptr;
+ if (num_key_cert_pairs == 0 || pem_key_cert_pairs == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- impl = gpr_zalloc(sizeof(*impl));
+ impl = (tsi_ssl_server_handshaker_factory*)gpr_zalloc(sizeof(*impl));
tsi_ssl_handshaker_factory_init(&impl->base);
impl->base.vtable = &server_handshaker_factory_vtable;
- impl->ssl_contexts = gpr_zalloc(num_key_cert_pairs * sizeof(SSL_CTX *));
+ impl->ssl_contexts =
+ (SSL_CTX**)gpr_zalloc(num_key_cert_pairs * sizeof(SSL_CTX*));
impl->ssl_context_x509_subject_names =
- gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer));
- if (impl->ssl_contexts == NULL ||
- impl->ssl_context_x509_subject_names == NULL) {
+ (tsi_peer*)gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer));
+ if (impl->ssl_contexts == nullptr ||
+ impl->ssl_context_x509_subject_names == nullptr) {
tsi_ssl_handshaker_factory_unref(&impl->base);
return TSI_OUT_OF_RESOURCES;
}
@@ -1471,7 +1481,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
for (i = 0; i < num_key_cert_pairs; i++) {
do {
impl->ssl_contexts[i] = SSL_CTX_new(TLSv1_2_method());
- if (impl->ssl_contexts[i] == NULL) {
+ if (impl->ssl_contexts[i] == nullptr) {
gpr_log(GPR_ERROR, "Could not create ssl context.");
result = TSI_OUT_OF_RESOURCES;
break;
@@ -1480,8 +1490,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
&pem_key_cert_pairs[i], cipher_suites);
if (result != TSI_OK) break;
- if (pem_client_root_certs != NULL) {
- STACK_OF(X509_NAME) *root_names = NULL;
+ if (pem_client_root_certs != nullptr) {
+ STACK_OF(X509_NAME)* root_names = nullptr;
result = ssl_ctx_load_verification_certs(
impl->ssl_contexts[i], pem_client_root_certs,
strlen(pem_client_root_certs), &root_names);
@@ -1492,14 +1502,14 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
SSL_CTX_set_client_CA_list(impl->ssl_contexts[i], root_names);
switch (client_certificate_request) {
case TSI_DONT_REQUEST_CLIENT_CERTIFICATE:
- SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_NONE, NULL);
+ SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_NONE, nullptr);
break;
case TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER,
NullVerifyCallback);
break;
case TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY:
- SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER, NULL);
+ SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER, nullptr);
break;
case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
SSL_CTX_set_verify(
@@ -1510,7 +1520,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY:
SSL_CTX_set_verify(
impl->ssl_contexts[i],
- SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
+ SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr);
break;
}
/* TODO(jboeuf): Add revocation verification. */
@@ -1546,16 +1556,16 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
/* --- tsi_ssl utils. --- */
-int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name) {
+int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) {
size_t i = 0;
size_t san_count = 0;
- const tsi_peer_property *cn_property = NULL;
+ const tsi_peer_property* cn_property = nullptr;
int like_ip = looks_like_ip_address(name);
/* Check the SAN first. */
for (i = 0; i < peer->property_count; i++) {
- const tsi_peer_property *property = &peer->properties[i];
- if (property->name == NULL) continue;
+ const tsi_peer_property* property = &peer->properties[i];
+ if (property->name == nullptr) continue;
if (strcmp(property->name,
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
san_count++;
@@ -1577,7 +1587,7 @@ int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name) {
}
/* If there's no SAN, try the CN, but only if its not like an IP Address */
- if (san_count == 0 && cn_property != NULL && !like_ip) {
+ if (san_count == 0 && cn_property != nullptr && !like_ip) {
if (does_entry_match_name(cn_property->value.data,
cn_property->value.length, name)) {
return 1;
@@ -1588,13 +1598,13 @@ int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name) {
}
/* --- Testing support. --- */
-const tsi_ssl_handshaker_factory_vtable *tsi_ssl_handshaker_factory_swap_vtable(
- tsi_ssl_handshaker_factory *factory,
- tsi_ssl_handshaker_factory_vtable *new_vtable) {
- GPR_ASSERT(factory != NULL);
- GPR_ASSERT(factory->vtable != NULL);
+const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable(
+ tsi_ssl_handshaker_factory* factory,
+ tsi_ssl_handshaker_factory_vtable* new_vtable) {
+ GPR_ASSERT(factory != nullptr);
+ GPR_ASSERT(factory->vtable != nullptr);
- const tsi_ssl_handshaker_factory_vtable *orig_vtable = factory->vtable;
+ const tsi_ssl_handshaker_factory_vtable* orig_vtable = factory->vtable;
factory->vtable = new_vtable;
return orig_vtable;
}
diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h
index 3abfdf5ed8..bf211e110a 100644
--- a/src/core/tsi/ssl_transport_security.h
+++ b/src/core/tsi/ssl_transport_security.h
@@ -21,10 +21,6 @@
#include "src/core/tsi/transport_security_interface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for X509 certs. */
#define TSI_X509_CERTIFICATE_TYPE "X509"
@@ -49,11 +45,11 @@ typedef struct tsi_ssl_client_handshaker_factory
typedef struct {
/* private_key is the NULL-terminated string containing the PEM encoding of
the client's private key. */
- const char *private_key;
+ const char* private_key;
/* cert_chain is the NULL-terminated string containing the PEM encoding of
the client's certificate chain. */
- const char *cert_chain;
+ const char* cert_chain;
} tsi_ssl_pem_key_cert_pair;
/* Creates a client handshaker factory.
@@ -78,10 +74,10 @@ typedef struct {
- This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case
where a parameter is invalid. */
tsi_result tsi_create_ssl_client_handshaker_factory(
- const tsi_ssl_pem_key_cert_pair *pem_key_cert_pair,
- const char *pem_root_certs, const char *cipher_suites,
- const char **alpn_protocols, uint16_t num_alpn_protocols,
- tsi_ssl_client_handshaker_factory **factory);
+ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pair,
+ const char* pem_root_certs, const char* cipher_suites,
+ const char** alpn_protocols, uint16_t num_alpn_protocols,
+ tsi_ssl_client_handshaker_factory** factory);
/* Creates a client handshaker.
- self is the factory from which the handshaker will be created.
@@ -93,13 +89,13 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
- This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case
where a parameter is invalid. */
tsi_result tsi_ssl_client_handshaker_factory_create_handshaker(
- tsi_ssl_client_handshaker_factory *self, const char *server_name_indication,
- tsi_handshaker **handshaker);
+ tsi_ssl_client_handshaker_factory* self, const char* server_name_indication,
+ tsi_handshaker** handshaker);
/* Decrements reference count of the handshaker factory. Handshaker factory will
* be destroyed once no references exist. */
void tsi_ssl_client_handshaker_factory_unref(
- tsi_ssl_client_handshaker_factory *factory);
+ tsi_ssl_client_handshaker_factory* factory);
/* --- tsi_ssl_server_handshaker_factory object ---
@@ -130,11 +126,11 @@ typedef struct tsi_ssl_server_handshaker_factory
- This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case
where a parameter is invalid. */
tsi_result tsi_create_ssl_server_handshaker_factory(
- const tsi_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, const char *pem_client_root_certs,
- int force_client_auth, const char *cipher_suites,
- const char **alpn_protocols, uint16_t num_alpn_protocols,
- tsi_ssl_server_handshaker_factory **factory);
+ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs, const char* pem_client_root_certs,
+ int force_client_auth, const char* cipher_suites,
+ const char** alpn_protocols, uint16_t num_alpn_protocols,
+ tsi_ssl_server_handshaker_factory** factory);
/* Same as tsi_create_ssl_server_handshaker_factory method except uses
tsi_client_certificate_request_type to support more ways to handle client
@@ -143,11 +139,11 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
authenticate with an SSL cert. Note that this option is ignored if
pem_client_root_certs is NULL or pem_client_roots_certs_size is 0 */
tsi_result tsi_create_ssl_server_handshaker_factory_ex(
- const tsi_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, const char *pem_client_root_certs,
+ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs,
+ size_t num_key_cert_pairs, const char* pem_client_root_certs,
tsi_client_certificate_request_type client_certificate_request,
- const char *cipher_suites, const char **alpn_protocols,
- uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory **factory);
+ const char* cipher_suites, const char** alpn_protocols,
+ uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory** factory);
/* Creates a server handshaker.
- self is the factory from which the handshaker will be created.
@@ -156,19 +152,19 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
- This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case
where a parameter is invalid. */
tsi_result tsi_ssl_server_handshaker_factory_create_handshaker(
- tsi_ssl_server_handshaker_factory *self, tsi_handshaker **handshaker);
+ tsi_ssl_server_handshaker_factory* self, tsi_handshaker** handshaker);
/* Decrements reference count of the handshaker factory. Handshaker factory will
* be destroyed once no references exist. */
void tsi_ssl_server_handshaker_factory_unref(
- tsi_ssl_server_handshaker_factory *self);
+ tsi_ssl_server_handshaker_factory* self);
/* Util that checks that an ssl peer matches a specific name.
Still TODO(jboeuf):
- handle mixed case.
- handle %encoded chars.
- handle public suffix wildchar more strictly (e.g. *.co.uk) */
-int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name);
+int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name);
/* --- Testing support. ---
@@ -180,7 +176,7 @@ typedef struct tsi_ssl_handshaker_factory tsi_ssl_handshaker_factory;
/* Function pointer to handshaker_factory destructor. */
typedef void (*tsi_ssl_handshaker_factory_destructor)(
- tsi_ssl_handshaker_factory *factory);
+ tsi_ssl_handshaker_factory* factory);
/* Virtual table for tsi_ssl_handshaker_factory. */
typedef struct {
@@ -189,12 +185,8 @@ typedef struct {
/* Set destructor of handshaker_factory to new_destructor, returns previous
destructor. */
-const tsi_ssl_handshaker_factory_vtable *tsi_ssl_handshaker_factory_swap_vtable(
- tsi_ssl_handshaker_factory *factory,
- tsi_ssl_handshaker_factory_vtable *new_vtable);
-
-#ifdef __cplusplus
-}
-#endif
+const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable(
+ tsi_ssl_handshaker_factory* factory,
+ tsi_ssl_handshaker_factory_vtable* new_vtable);
#endif /* GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/transport_security.c b/src/core/tsi/transport_security.cc
index 76213072a3..5abd2f0f68 100644
--- a/src/core/tsi/transport_security.c
+++ b/src/core/tsi/transport_security.cc
@@ -26,11 +26,11 @@
/* --- Tracing. --- */
-grpc_tracer_flag tsi_tracing_enabled = GRPC_TRACER_INITIALIZER(false, "tsi");
+grpc_core::TraceFlag tsi_tracing_enabled(false, "tsi");
/* --- tsi_result common implementation. --- */
-const char *tsi_result_to_string(tsi_result result) {
+const char* tsi_result_to_string(tsi_result result) {
switch (result) {
case TSI_OK:
return "TSI_OK";
@@ -69,52 +69,56 @@ const char *tsi_result_to_string(tsi_result result) {
Calls specific implementation after state/input validation. */
-tsi_result tsi_frame_protector_protect(tsi_frame_protector *self,
- const unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size) {
- if (self == NULL || self->vtable == NULL || unprotected_bytes == NULL ||
- unprotected_bytes_size == NULL || protected_output_frames == NULL ||
- protected_output_frames_size == NULL) {
+tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
+ const unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size) {
+ if (self == nullptr || self->vtable == nullptr ||
+ unprotected_bytes == nullptr || unprotected_bytes_size == nullptr ||
+ protected_output_frames == nullptr ||
+ protected_output_frames_size == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- if (self->vtable->protect == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->protect == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->protect(self, unprotected_bytes, unprotected_bytes_size,
protected_output_frames,
protected_output_frames_size);
}
tsi_result tsi_frame_protector_protect_flush(
- tsi_frame_protector *self, unsigned char *protected_output_frames,
- size_t *protected_output_frames_size, size_t *still_pending_size) {
- if (self == NULL || self->vtable == NULL || protected_output_frames == NULL ||
- protected_output_frames_size == NULL || still_pending_size == NULL) {
+ tsi_frame_protector* self, unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size, size_t* still_pending_size) {
+ if (self == nullptr || self->vtable == nullptr ||
+ protected_output_frames == nullptr ||
+ protected_output_frames_size == nullptr ||
+ still_pending_size == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- if (self->vtable->protect_flush == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->protect_flush == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->protect_flush(self, protected_output_frames,
protected_output_frames_size,
still_pending_size);
}
tsi_result tsi_frame_protector_unprotect(
- tsi_frame_protector *self, const unsigned char *protected_frames_bytes,
- size_t *protected_frames_bytes_size, unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size) {
- if (self == NULL || self->vtable == NULL || protected_frames_bytes == NULL ||
- protected_frames_bytes_size == NULL || unprotected_bytes == NULL ||
- unprotected_bytes_size == NULL) {
+ tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
+ size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size) {
+ if (self == nullptr || self->vtable == nullptr ||
+ protected_frames_bytes == nullptr ||
+ protected_frames_bytes_size == nullptr || unprotected_bytes == nullptr ||
+ unprotected_bytes_size == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- if (self->vtable->unprotect == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->unprotect == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->unprotect(self, protected_frames_bytes,
protected_frames_bytes_size, unprotected_bytes,
unprotected_bytes_size);
}
-void tsi_frame_protector_destroy(tsi_frame_protector *self) {
- if (self == NULL) return;
+void tsi_frame_protector_destroy(tsi_frame_protector* self) {
+ if (self == nullptr) return;
self->vtable->destroy(self);
}
@@ -122,39 +126,41 @@ void tsi_frame_protector_destroy(tsi_frame_protector *self) {
Calls specific implementation after state/input validation. */
-tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
- unsigned char *bytes,
- size_t *bytes_size) {
- if (self == NULL || self->vtable == NULL || bytes == NULL ||
- bytes_size == NULL) {
+tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
+ unsigned char* bytes,
+ size_t* bytes_size) {
+ if (self == nullptr || self->vtable == nullptr || bytes == nullptr ||
+ bytes_size == nullptr) {
return TSI_INVALID_ARGUMENT;
}
if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
- if (self->vtable->get_bytes_to_send_to_peer == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->get_bytes_to_send_to_peer == nullptr)
+ return TSI_UNIMPLEMENTED;
return self->vtable->get_bytes_to_send_to_peer(self, bytes, bytes_size);
}
-tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker *self,
- const unsigned char *bytes,
- size_t *bytes_size) {
- if (self == NULL || self->vtable == NULL || bytes == NULL ||
- bytes_size == NULL) {
+tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker* self,
+ const unsigned char* bytes,
+ size_t* bytes_size) {
+ if (self == nullptr || self->vtable == nullptr || bytes == nullptr ||
+ bytes_size == nullptr) {
return TSI_INVALID_ARGUMENT;
}
if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
- if (self->vtable->process_bytes_from_peer == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->process_bytes_from_peer == nullptr)
+ return TSI_UNIMPLEMENTED;
return self->vtable->process_bytes_from_peer(self, bytes, bytes_size);
}
-tsi_result tsi_handshaker_get_result(tsi_handshaker *self) {
- if (self == NULL || self->vtable == NULL) return TSI_INVALID_ARGUMENT;
+tsi_result tsi_handshaker_get_result(tsi_handshaker* self) {
+ if (self == nullptr || self->vtable == nullptr) return TSI_INVALID_ARGUMENT;
if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
- if (self->vtable->get_result == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->get_result == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->get_result(self);
}
-tsi_result tsi_handshaker_extract_peer(tsi_handshaker *self, tsi_peer *peer) {
- if (self == NULL || self->vtable == NULL || peer == NULL) {
+tsi_result tsi_handshaker_extract_peer(tsi_handshaker* self, tsi_peer* peer) {
+ if (self == nullptr || self->vtable == nullptr || peer == nullptr) {
return TSI_INVALID_ARGUMENT;
}
memset(peer, 0, sizeof(tsi_peer));
@@ -162,20 +168,20 @@ tsi_result tsi_handshaker_extract_peer(tsi_handshaker *self, tsi_peer *peer) {
if (tsi_handshaker_get_result(self) != TSI_OK) {
return TSI_FAILED_PRECONDITION;
}
- if (self->vtable->extract_peer == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->extract_peer == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->extract_peer(self, peer);
}
tsi_result tsi_handshaker_create_frame_protector(
- tsi_handshaker *self, size_t *max_protected_frame_size,
- tsi_frame_protector **protector) {
+ tsi_handshaker* self, size_t* max_protected_frame_size,
+ tsi_frame_protector** protector) {
tsi_result result;
- if (self == NULL || self->vtable == NULL || protector == NULL) {
+ if (self == nullptr || self->vtable == nullptr || protector == nullptr) {
return TSI_INVALID_ARGUMENT;
}
if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
if (tsi_handshaker_get_result(self) != TSI_OK) return TSI_FAILED_PRECONDITION;
- if (self->vtable->create_frame_protector == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->create_frame_protector == nullptr) return TSI_UNIMPLEMENTED;
result = self->vtable->create_frame_protector(self, max_protected_frame_size,
protector);
if (result == TSI_OK) {
@@ -185,59 +191,59 @@ tsi_result tsi_handshaker_create_frame_protector(
}
tsi_result tsi_handshaker_next(
- tsi_handshaker *self, const unsigned char *received_bytes,
- size_t received_bytes_size, const unsigned char **bytes_to_send,
- size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
- tsi_handshaker_on_next_done_cb cb, void *user_data) {
- if (self == NULL || self->vtable == NULL) return TSI_INVALID_ARGUMENT;
+ tsi_handshaker* self, const unsigned char* received_bytes,
+ size_t received_bytes_size, const unsigned char** bytes_to_send,
+ size_t* bytes_to_send_size, tsi_handshaker_result** handshaker_result,
+ tsi_handshaker_on_next_done_cb cb, void* user_data) {
+ if (self == nullptr || self->vtable == nullptr) return TSI_INVALID_ARGUMENT;
if (self->handshaker_result_created) return TSI_FAILED_PRECONDITION;
- if (self->vtable->next == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->next == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->next(self, received_bytes, received_bytes_size,
bytes_to_send, bytes_to_send_size,
handshaker_result, cb, user_data);
}
-void tsi_handshaker_destroy(tsi_handshaker *self) {
- if (self == NULL) return;
+void tsi_handshaker_destroy(tsi_handshaker* self) {
+ if (self == nullptr) return;
self->vtable->destroy(self);
}
/* --- tsi_handshaker_result implementation. --- */
-tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result *self,
- tsi_peer *peer) {
- if (self == NULL || self->vtable == NULL || peer == NULL) {
+tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result* self,
+ tsi_peer* peer) {
+ if (self == nullptr || self->vtable == nullptr || peer == nullptr) {
return TSI_INVALID_ARGUMENT;
}
memset(peer, 0, sizeof(tsi_peer));
- if (self->vtable->extract_peer == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->extract_peer == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->extract_peer(self, peer);
}
tsi_result tsi_handshaker_result_create_frame_protector(
- const tsi_handshaker_result *self, size_t *max_protected_frame_size,
- tsi_frame_protector **protector) {
- if (self == NULL || self->vtable == NULL || protector == NULL) {
+ const tsi_handshaker_result* self, size_t* max_protected_frame_size,
+ tsi_frame_protector** protector) {
+ if (self == nullptr || self->vtable == nullptr || protector == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- if (self->vtable->create_frame_protector == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->create_frame_protector == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->create_frame_protector(self, max_protected_frame_size,
protector);
}
tsi_result tsi_handshaker_result_get_unused_bytes(
- const tsi_handshaker_result *self, const unsigned char **bytes,
- size_t *bytes_size) {
- if (self == NULL || self->vtable == NULL || bytes == NULL ||
- bytes_size == NULL) {
+ const tsi_handshaker_result* self, const unsigned char** bytes,
+ size_t* bytes_size) {
+ if (self == nullptr || self->vtable == nullptr || bytes == nullptr ||
+ bytes_size == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- if (self->vtable->get_unused_bytes == NULL) return TSI_UNIMPLEMENTED;
+ if (self->vtable->get_unused_bytes == nullptr) return TSI_UNIMPLEMENTED;
return self->vtable->get_unused_bytes(self, bytes, bytes_size);
}
-void tsi_handshaker_result_destroy(tsi_handshaker_result *self) {
- if (self == NULL) return;
+void tsi_handshaker_result_destroy(tsi_handshaker_result* self) {
+ if (self == nullptr) return;
self->vtable->destroy(self);
}
@@ -249,7 +255,7 @@ tsi_peer_property tsi_init_peer_property(void) {
return property;
}
-static void tsi_peer_destroy_list_property(tsi_peer_property *children,
+static void tsi_peer_destroy_list_property(tsi_peer_property* children,
size_t child_count) {
size_t i;
for (i = 0; i < child_count; i++) {
@@ -258,46 +264,46 @@ static void tsi_peer_destroy_list_property(tsi_peer_property *children,
gpr_free(children);
}
-void tsi_peer_property_destruct(tsi_peer_property *property) {
- if (property->name != NULL) {
+void tsi_peer_property_destruct(tsi_peer_property* property) {
+ if (property->name != nullptr) {
gpr_free(property->name);
}
- if (property->value.data != NULL) {
+ if (property->value.data != nullptr) {
gpr_free(property->value.data);
}
*property = tsi_init_peer_property(); /* Reset everything to 0. */
}
-void tsi_peer_destruct(tsi_peer *self) {
- if (self == NULL) return;
- if (self->properties != NULL) {
+void tsi_peer_destruct(tsi_peer* self) {
+ if (self == nullptr) return;
+ if (self->properties != nullptr) {
tsi_peer_destroy_list_property(self->properties, self->property_count);
- self->properties = NULL;
+ self->properties = nullptr;
}
self->property_count = 0;
}
tsi_result tsi_construct_allocated_string_peer_property(
- const char *name, size_t value_length, tsi_peer_property *property) {
+ const char* name, size_t value_length, tsi_peer_property* property) {
*property = tsi_init_peer_property();
- if (name != NULL) property->name = gpr_strdup(name);
+ if (name != nullptr) property->name = gpr_strdup(name);
if (value_length > 0) {
- property->value.data = gpr_zalloc(value_length);
+ property->value.data = (char*)gpr_zalloc(value_length);
property->value.length = value_length;
}
return TSI_OK;
}
tsi_result tsi_construct_string_peer_property_from_cstring(
- const char *name, const char *value, tsi_peer_property *property) {
+ const char* name, const char* value, tsi_peer_property* property) {
return tsi_construct_string_peer_property(name, value, strlen(value),
property);
}
-tsi_result tsi_construct_string_peer_property(const char *name,
- const char *value,
+tsi_result tsi_construct_string_peer_property(const char* name,
+ const char* value,
size_t value_length,
- tsi_peer_property *property) {
+ tsi_peer_property* property) {
tsi_result result = tsi_construct_allocated_string_peer_property(
name, value_length, property);
if (result != TSI_OK) return result;
@@ -307,10 +313,11 @@ tsi_result tsi_construct_string_peer_property(const char *name,
return TSI_OK;
}
-tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer) {
+tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer) {
memset(peer, 0, sizeof(tsi_peer));
if (property_count > 0) {
- peer->properties = gpr_zalloc(property_count * sizeof(tsi_peer_property));
+ peer->properties = (tsi_peer_property*)gpr_zalloc(
+ property_count * sizeof(tsi_peer_property));
peer->property_count = property_count;
}
return TSI_OK;
diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h
index 3bba38149c..ed662d48af 100644
--- a/src/core/tsi/transport_security.h
+++ b/src/core/tsi/transport_security.h
@@ -24,61 +24,57 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/tsi/transport_security_interface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern grpc_tracer_flag tsi_tracing_enabled;
+extern grpc_core::TraceFlag tsi_tracing_enabled;
/* Base for tsi_frame_protector implementations.
See transport_security_interface.h for documentation. */
typedef struct {
- tsi_result (*protect)(tsi_frame_protector *self,
- const unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size);
- tsi_result (*protect_flush)(tsi_frame_protector *self,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size,
- size_t *still_pending_size);
- tsi_result (*unprotect)(tsi_frame_protector *self,
- const unsigned char *protected_frames_bytes,
- size_t *protected_frames_bytes_size,
- unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size);
- void (*destroy)(tsi_frame_protector *self);
+ tsi_result (*protect)(tsi_frame_protector* self,
+ const unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size);
+ tsi_result (*protect_flush)(tsi_frame_protector* self,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size,
+ size_t* still_pending_size);
+ tsi_result (*unprotect)(tsi_frame_protector* self,
+ const unsigned char* protected_frames_bytes,
+ size_t* protected_frames_bytes_size,
+ unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size);
+ void (*destroy)(tsi_frame_protector* self);
} tsi_frame_protector_vtable;
struct tsi_frame_protector {
- const tsi_frame_protector_vtable *vtable;
+ const tsi_frame_protector_vtable* vtable;
};
/* Base for tsi_handshaker implementations.
See transport_security_interface.h for documentation. */
typedef struct {
- tsi_result (*get_bytes_to_send_to_peer)(tsi_handshaker *self,
- unsigned char *bytes,
- size_t *bytes_size);
- tsi_result (*process_bytes_from_peer)(tsi_handshaker *self,
- const unsigned char *bytes,
- size_t *bytes_size);
- tsi_result (*get_result)(tsi_handshaker *self);
- tsi_result (*extract_peer)(tsi_handshaker *self, tsi_peer *peer);
- tsi_result (*create_frame_protector)(tsi_handshaker *self,
- size_t *max_protected_frame_size,
- tsi_frame_protector **protector);
- void (*destroy)(tsi_handshaker *self);
- tsi_result (*next)(tsi_handshaker *self, const unsigned char *received_bytes,
+ tsi_result (*get_bytes_to_send_to_peer)(tsi_handshaker* self,
+ unsigned char* bytes,
+ size_t* bytes_size);
+ tsi_result (*process_bytes_from_peer)(tsi_handshaker* self,
+ const unsigned char* bytes,
+ size_t* bytes_size);
+ tsi_result (*get_result)(tsi_handshaker* self);
+ tsi_result (*extract_peer)(tsi_handshaker* self, tsi_peer* peer);
+ tsi_result (*create_frame_protector)(tsi_handshaker* self,
+ size_t* max_protected_frame_size,
+ tsi_frame_protector** protector);
+ void (*destroy)(tsi_handshaker* self);
+ tsi_result (*next)(tsi_handshaker* self, const unsigned char* received_bytes,
size_t received_bytes_size,
- const unsigned char **bytes_to_send,
- size_t *bytes_to_send_size,
- tsi_handshaker_result **handshaker_result,
- tsi_handshaker_on_next_done_cb cb, void *user_data);
+ const unsigned char** bytes_to_send,
+ size_t* bytes_to_send_size,
+ tsi_handshaker_result** handshaker_result,
+ tsi_handshaker_on_next_done_cb cb, void* user_data);
} tsi_handshaker_vtable;
struct tsi_handshaker {
- const tsi_handshaker_vtable *vtable;
+ const tsi_handshaker_vtable* vtable;
bool frame_protector_created;
bool handshaker_result_created;
};
@@ -92,42 +88,38 @@ struct tsi_handshaker {
needs to compile in other applications, where grpc_exec_ctx is not defined.
*/
typedef struct {
- tsi_result (*extract_peer)(const tsi_handshaker_result *self, tsi_peer *peer);
+ tsi_result (*extract_peer)(const tsi_handshaker_result* self, tsi_peer* peer);
tsi_result (*create_zero_copy_grpc_protector)(
- void *exec_ctx, const tsi_handshaker_result *self,
- size_t *max_output_protected_frame_size,
- tsi_zero_copy_grpc_protector **protector);
- tsi_result (*create_frame_protector)(const tsi_handshaker_result *self,
- size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector);
- tsi_result (*get_unused_bytes)(const tsi_handshaker_result *self,
- const unsigned char **bytes,
- size_t *bytes_size);
- void (*destroy)(tsi_handshaker_result *self);
+ const tsi_handshaker_result* self,
+ size_t* max_output_protected_frame_size,
+ tsi_zero_copy_grpc_protector** protector);
+ tsi_result (*create_frame_protector)(const tsi_handshaker_result* self,
+ size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector);
+ tsi_result (*get_unused_bytes)(const tsi_handshaker_result* self,
+ const unsigned char** bytes,
+ size_t* bytes_size);
+ void (*destroy)(tsi_handshaker_result* self);
} tsi_handshaker_result_vtable;
struct tsi_handshaker_result {
- const tsi_handshaker_result_vtable *vtable;
+ const tsi_handshaker_result_vtable* vtable;
};
/* Peer and property construction/destruction functions. */
-tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer);
+tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer);
tsi_peer_property tsi_init_peer_property(void);
-void tsi_peer_property_destruct(tsi_peer_property *property);
-tsi_result tsi_construct_string_peer_property(const char *name,
- const char *value,
+void tsi_peer_property_destruct(tsi_peer_property* property);
+tsi_result tsi_construct_string_peer_property(const char* name,
+ const char* value,
size_t value_length,
- tsi_peer_property *property);
+ tsi_peer_property* property);
tsi_result tsi_construct_allocated_string_peer_property(
- const char *name, size_t value_length, tsi_peer_property *property);
+ const char* name, size_t value_length, tsi_peer_property* property);
tsi_result tsi_construct_string_peer_property_from_cstring(
- const char *name, const char *value, tsi_peer_property *property);
+ const char* name, const char* value, tsi_peer_property* property);
/* Utils. */
-char *tsi_strdup(const char *src); /* Sadly, no strdup in C89. */
-
-#ifdef __cplusplus
-}
-#endif
+char* tsi_strdup(const char* src); /* Sadly, no strdup in C89. */
#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/transport_security_adapter.c b/src/core/tsi/transport_security_adapter.cc
index 1c2a57b3bd..56dec55494 100644
--- a/src/core/tsi/transport_security_adapter.c
+++ b/src/core/tsi/transport_security_adapter.cc
@@ -30,36 +30,36 @@
typedef struct {
tsi_handshaker_result base;
- tsi_handshaker *wrapped;
- unsigned char *unused_bytes;
+ tsi_handshaker* wrapped;
+ unsigned char* unused_bytes;
size_t unused_bytes_size;
} tsi_adapter_handshaker_result;
-static tsi_result adapter_result_extract_peer(const tsi_handshaker_result *self,
- tsi_peer *peer) {
- tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result *)self;
+static tsi_result adapter_result_extract_peer(const tsi_handshaker_result* self,
+ tsi_peer* peer) {
+ tsi_adapter_handshaker_result* impl = (tsi_adapter_handshaker_result*)self;
return tsi_handshaker_extract_peer(impl->wrapped, peer);
}
static tsi_result adapter_result_create_frame_protector(
- const tsi_handshaker_result *self, size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector) {
- tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result *)self;
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector) {
+ tsi_adapter_handshaker_result* impl = (tsi_adapter_handshaker_result*)self;
return tsi_handshaker_create_frame_protector(
impl->wrapped, max_output_protected_frame_size, protector);
}
static tsi_result adapter_result_get_unused_bytes(
- const tsi_handshaker_result *self, const unsigned char **bytes,
- size_t *byte_size) {
- tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result *)self;
+ const tsi_handshaker_result* self, const unsigned char** bytes,
+ size_t* byte_size) {
+ tsi_adapter_handshaker_result* impl = (tsi_adapter_handshaker_result*)self;
*bytes = impl->unused_bytes;
*byte_size = impl->unused_bytes_size;
return TSI_OK;
}
-static void adapter_result_destroy(tsi_handshaker_result *self) {
- tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result *)self;
+static void adapter_result_destroy(tsi_handshaker_result* self) {
+ tsi_adapter_handshaker_result* impl = (tsi_adapter_handshaker_result*)self;
tsi_handshaker_destroy(impl->wrapped);
gpr_free(impl->unused_bytes);
gpr_free(self);
@@ -67,7 +67,7 @@ static void adapter_result_destroy(tsi_handshaker_result *self) {
static const tsi_handshaker_result_vtable result_vtable = {
adapter_result_extract_peer,
- NULL, /* create_zero_copy_grpc_protector */
+ nullptr, /* create_zero_copy_grpc_protector */
adapter_result_create_frame_protector,
adapter_result_get_unused_bytes,
adapter_result_destroy,
@@ -75,20 +75,22 @@ static const tsi_handshaker_result_vtable result_vtable = {
/* Ownership of wrapped tsi_handshaker is transferred to the result object. */
static tsi_result tsi_adapter_create_handshaker_result(
- tsi_handshaker *wrapped, const unsigned char *unused_bytes,
- size_t unused_bytes_size, tsi_handshaker_result **handshaker_result) {
- if (wrapped == NULL || (unused_bytes_size > 0 && unused_bytes == NULL)) {
+ tsi_handshaker* wrapped, const unsigned char* unused_bytes,
+ size_t unused_bytes_size, tsi_handshaker_result** handshaker_result) {
+ if (wrapped == nullptr ||
+ (unused_bytes_size > 0 && unused_bytes == nullptr)) {
return TSI_INVALID_ARGUMENT;
}
- tsi_adapter_handshaker_result *impl = gpr_zalloc(sizeof(*impl));
+ tsi_adapter_handshaker_result* impl =
+ (tsi_adapter_handshaker_result*)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &result_vtable;
impl->wrapped = wrapped;
impl->unused_bytes_size = unused_bytes_size;
if (unused_bytes_size > 0) {
- impl->unused_bytes = gpr_malloc(unused_bytes_size);
+ impl->unused_bytes = (unsigned char*)gpr_malloc(unused_bytes_size);
memcpy(impl->unused_bytes, unused_bytes, unused_bytes_size);
} else {
- impl->unused_bytes = NULL;
+ impl->unused_bytes = nullptr;
}
*handshaker_result = &impl->base;
return TSI_OK;
@@ -98,63 +100,63 @@ static tsi_result tsi_adapter_create_handshaker_result(
typedef struct {
tsi_handshaker base;
- tsi_handshaker *wrapped;
- unsigned char *adapter_buffer;
+ tsi_handshaker* wrapped;
+ unsigned char* adapter_buffer;
size_t adapter_buffer_size;
} tsi_adapter_handshaker;
-static tsi_result adapter_get_bytes_to_send_to_peer(tsi_handshaker *self,
- unsigned char *bytes,
- size_t *bytes_size) {
+static tsi_result adapter_get_bytes_to_send_to_peer(tsi_handshaker* self,
+ unsigned char* bytes,
+ size_t* bytes_size) {
return tsi_handshaker_get_bytes_to_send_to_peer(
tsi_adapter_handshaker_get_wrapped(self), bytes, bytes_size);
}
-static tsi_result adapter_process_bytes_from_peer(tsi_handshaker *self,
- const unsigned char *bytes,
- size_t *bytes_size) {
+static tsi_result adapter_process_bytes_from_peer(tsi_handshaker* self,
+ const unsigned char* bytes,
+ size_t* bytes_size) {
return tsi_handshaker_process_bytes_from_peer(
tsi_adapter_handshaker_get_wrapped(self), bytes, bytes_size);
}
-static tsi_result adapter_get_result(tsi_handshaker *self) {
+static tsi_result adapter_get_result(tsi_handshaker* self) {
return tsi_handshaker_get_result(tsi_adapter_handshaker_get_wrapped(self));
}
-static tsi_result adapter_extract_peer(tsi_handshaker *self, tsi_peer *peer) {
+static tsi_result adapter_extract_peer(tsi_handshaker* self, tsi_peer* peer) {
return tsi_handshaker_extract_peer(tsi_adapter_handshaker_get_wrapped(self),
peer);
}
static tsi_result adapter_create_frame_protector(
- tsi_handshaker *self, size_t *max_protected_frame_size,
- tsi_frame_protector **protector) {
+ tsi_handshaker* self, size_t* max_protected_frame_size,
+ tsi_frame_protector** protector) {
return tsi_handshaker_create_frame_protector(
tsi_adapter_handshaker_get_wrapped(self), max_protected_frame_size,
protector);
}
-static void adapter_destroy(tsi_handshaker *self) {
- tsi_adapter_handshaker *impl = (tsi_adapter_handshaker *)self;
+static void adapter_destroy(tsi_handshaker* self) {
+ tsi_adapter_handshaker* impl = (tsi_adapter_handshaker*)self;
tsi_handshaker_destroy(impl->wrapped);
gpr_free(impl->adapter_buffer);
gpr_free(self);
}
static tsi_result adapter_next(
- tsi_handshaker *self, const unsigned char *received_bytes,
- size_t received_bytes_size, const unsigned char **bytes_to_send,
- size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
- tsi_handshaker_on_next_done_cb cb, void *user_data) {
+ tsi_handshaker* self, const unsigned char* received_bytes,
+ size_t received_bytes_size, const unsigned char** bytes_to_send,
+ size_t* bytes_to_send_size, tsi_handshaker_result** handshaker_result,
+ tsi_handshaker_on_next_done_cb cb, void* user_data) {
/* Input sanity check. */
- if ((received_bytes_size > 0 && received_bytes == NULL) ||
- bytes_to_send == NULL || bytes_to_send_size == NULL ||
- handshaker_result == NULL) {
+ if ((received_bytes_size > 0 && received_bytes == nullptr) ||
+ bytes_to_send == nullptr || bytes_to_send_size == nullptr ||
+ handshaker_result == nullptr) {
return TSI_INVALID_ARGUMENT;
}
/* If there are received bytes, process them first. */
- tsi_adapter_handshaker *impl = (tsi_adapter_handshaker *)self;
+ tsi_adapter_handshaker* impl = (tsi_adapter_handshaker*)self;
tsi_result status = TSI_OK;
size_t bytes_consumed = received_bytes_size;
if (received_bytes_size > 0) {
@@ -172,8 +174,8 @@ static tsi_result adapter_next(
offset += to_send_size;
if (status == TSI_INCOMPLETE_DATA) {
impl->adapter_buffer_size *= 2;
- impl->adapter_buffer =
- gpr_realloc(impl->adapter_buffer, impl->adapter_buffer_size);
+ impl->adapter_buffer = (unsigned char*)gpr_realloc(
+ impl->adapter_buffer, impl->adapter_buffer_size);
}
} while (status == TSI_INCOMPLETE_DATA);
if (status != TSI_OK) return status;
@@ -182,16 +184,16 @@ static tsi_result adapter_next(
/* If handshake completes, create tsi_handshaker_result. */
if (tsi_handshaker_is_in_progress(impl->wrapped)) {
- *handshaker_result = NULL;
+ *handshaker_result = nullptr;
} else {
size_t unused_bytes_size = received_bytes_size - bytes_consumed;
- const unsigned char *unused_bytes =
- unused_bytes_size == 0 ? NULL : received_bytes + bytes_consumed;
+ const unsigned char* unused_bytes =
+ unused_bytes_size == 0 ? nullptr : received_bytes + bytes_consumed;
status = tsi_adapter_create_handshaker_result(
impl->wrapped, unused_bytes, unused_bytes_size, handshaker_result);
if (status == TSI_OK) {
impl->base.handshaker_result_created = true;
- impl->wrapped = NULL;
+ impl->wrapped = nullptr;
}
}
return status;
@@ -207,18 +209,19 @@ static const tsi_handshaker_vtable handshaker_vtable = {
adapter_next,
};
-tsi_handshaker *tsi_create_adapter_handshaker(tsi_handshaker *wrapped) {
- GPR_ASSERT(wrapped != NULL);
- tsi_adapter_handshaker *impl = gpr_zalloc(sizeof(*impl));
+tsi_handshaker* tsi_create_adapter_handshaker(tsi_handshaker* wrapped) {
+ GPR_ASSERT(wrapped != nullptr);
+ tsi_adapter_handshaker* impl =
+ (tsi_adapter_handshaker*)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &handshaker_vtable;
impl->wrapped = wrapped;
impl->adapter_buffer_size = TSI_ADAPTER_INITIAL_BUFFER_SIZE;
- impl->adapter_buffer = gpr_malloc(impl->adapter_buffer_size);
+ impl->adapter_buffer = (unsigned char*)gpr_malloc(impl->adapter_buffer_size);
return &impl->base;
}
-tsi_handshaker *tsi_adapter_handshaker_get_wrapped(tsi_handshaker *adapter) {
- if (adapter == NULL) return NULL;
- tsi_adapter_handshaker *impl = (tsi_adapter_handshaker *)adapter;
+tsi_handshaker* tsi_adapter_handshaker_get_wrapped(tsi_handshaker* adapter) {
+ if (adapter == nullptr) return nullptr;
+ tsi_adapter_handshaker* impl = (tsi_adapter_handshaker*)adapter;
return impl->wrapped;
}
diff --git a/src/core/tsi/transport_security_adapter.h b/src/core/tsi/transport_security_adapter.h
index 02f33d4c1c..9818fceb86 100644
--- a/src/core/tsi/transport_security_adapter.h
+++ b/src/core/tsi/transport_security_adapter.h
@@ -21,10 +21,6 @@
#include "src/core/tsi/transport_security_interface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Create a tsi handshaker that takes an implementation of old interface and
converts into an implementation of new interface. In the old interface,
there are get_bytes_to_send_to_peer, process_bytes_from_peer, get_result,
@@ -33,15 +29,11 @@ extern "C" {
this tsi adapter handshaker is temporary. It will be removed once TSI has
been fully migrated to the new interface.
Ownership of input tsi_handshaker is transferred to this new adapter. */
-tsi_handshaker *tsi_create_adapter_handshaker(tsi_handshaker *wrapped);
+tsi_handshaker* tsi_create_adapter_handshaker(tsi_handshaker* wrapped);
/* Given a tsi adapter handshaker, return the original wrapped handshaker. The
adapter still owns the wrapped handshaker which should not be destroyed by
the caller. */
-tsi_handshaker *tsi_adapter_handshaker_get_wrapped(tsi_handshaker *adapter);
-
-#ifdef __cplusplus
-}
-#endif
+tsi_handshaker* tsi_adapter_handshaker_get_wrapped(tsi_handshaker* adapter);
#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_ADAPTER_H */
diff --git a/src/core/tsi/transport_security_grpc.c b/src/core/tsi/transport_security_grpc.c
deleted file mode 100644
index affd995230..0000000000
--- a/src/core/tsi/transport_security_grpc.c
+++ /dev/null
@@ -1,71 +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 "src/core/tsi/transport_security_grpc.h"
-
-/* This method creates a tsi_zero_copy_grpc_protector object. */
-tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
- grpc_exec_ctx *exec_ctx, const tsi_handshaker_result *self,
- size_t *max_output_protected_frame_size,
- tsi_zero_copy_grpc_protector **protector) {
- if (exec_ctx == NULL || self == NULL || self->vtable == NULL ||
- protector == NULL) {
- return TSI_INVALID_ARGUMENT;
- }
- if (self->vtable->create_zero_copy_grpc_protector == NULL) {
- return TSI_UNIMPLEMENTED;
- }
- return self->vtable->create_zero_copy_grpc_protector(
- exec_ctx, self, max_output_protected_frame_size, protector);
-}
-
-/* --- tsi_zero_copy_grpc_protector common implementation. ---
-
- Calls specific implementation after state/input validation. */
-
-tsi_result tsi_zero_copy_grpc_protector_protect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *unprotected_slices,
- grpc_slice_buffer *protected_slices) {
- if (exec_ctx == NULL || self == NULL || self->vtable == NULL ||
- unprotected_slices == NULL || protected_slices == NULL) {
- return TSI_INVALID_ARGUMENT;
- }
- if (self->vtable->protect == NULL) return TSI_UNIMPLEMENTED;
- return self->vtable->protect(exec_ctx, self, unprotected_slices,
- protected_slices);
-}
-
-tsi_result tsi_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *protected_slices,
- grpc_slice_buffer *unprotected_slices) {
- if (exec_ctx == NULL || self == NULL || self->vtable == NULL ||
- protected_slices == NULL || unprotected_slices == NULL) {
- return TSI_INVALID_ARGUMENT;
- }
- if (self->vtable->unprotect == NULL) return TSI_UNIMPLEMENTED;
- return self->vtable->unprotect(exec_ctx, self, protected_slices,
- unprotected_slices);
-}
-
-void tsi_zero_copy_grpc_protector_destroy(grpc_exec_ctx *exec_ctx,
- tsi_zero_copy_grpc_protector *self) {
- if (self == NULL) return;
- self->vtable->destroy(exec_ctx, self);
-}
diff --git a/src/core/tsi/transport_security_grpc.cc b/src/core/tsi/transport_security_grpc.cc
new file mode 100644
index 0000000000..76f7ae782f
--- /dev/null
+++ b/src/core/tsi/transport_security_grpc.cc
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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 "src/core/tsi/transport_security_grpc.h"
+
+/* This method creates a tsi_zero_copy_grpc_protector object. */
+tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_zero_copy_grpc_protector** protector) {
+ if (self == nullptr || self->vtable == nullptr || protector == nullptr) {
+ return TSI_INVALID_ARGUMENT;
+ }
+ if (self->vtable->create_zero_copy_grpc_protector == nullptr) {
+ return TSI_UNIMPLEMENTED;
+ }
+ return self->vtable->create_zero_copy_grpc_protector(
+ self, max_output_protected_frame_size, protector);
+}
+
+/* --- tsi_zero_copy_grpc_protector common implementation. ---
+
+ Calls specific implementation after state/input validation. */
+
+tsi_result tsi_zero_copy_grpc_protector_protect(
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
+ grpc_slice_buffer* protected_slices) {
+ if (self == nullptr || self->vtable == nullptr ||
+ unprotected_slices == nullptr || protected_slices == nullptr) {
+ return TSI_INVALID_ARGUMENT;
+ }
+ if (self->vtable->protect == nullptr) return TSI_UNIMPLEMENTED;
+ return self->vtable->protect(self, unprotected_slices, protected_slices);
+}
+
+tsi_result tsi_zero_copy_grpc_protector_unprotect(
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
+ grpc_slice_buffer* unprotected_slices) {
+ if (self == nullptr || self->vtable == nullptr ||
+ protected_slices == nullptr || unprotected_slices == nullptr) {
+ return TSI_INVALID_ARGUMENT;
+ }
+ if (self->vtable->unprotect == nullptr) return TSI_UNIMPLEMENTED;
+ return self->vtable->unprotect(self, protected_slices, unprotected_slices);
+}
+
+void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector* self) {
+ if (self == nullptr) return;
+ self->vtable->destroy(self);
+}
diff --git a/src/core/tsi/transport_security_grpc.h b/src/core/tsi/transport_security_grpc.h
index ca6755c12f..0156ff1c68 100644
--- a/src/core/tsi/transport_security_grpc.h
+++ b/src/core/tsi/transport_security_grpc.h
@@ -22,17 +22,12 @@
#include <grpc/slice_buffer.h>
#include "src/core/tsi/transport_security.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* This method creates a tsi_zero_copy_grpc_protector object. It return TSI_OK
assuming there is no fatal error.
The caller is responsible for destroying the protector. */
tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
- grpc_exec_ctx *exec_ctx, const tsi_handshaker_result *self,
- size_t *max_output_protected_frame_size,
- tsi_zero_copy_grpc_protector **protector);
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_zero_copy_grpc_protector** protector);
/* -- tsi_zero_copy_grpc_protector object -- */
@@ -43,8 +38,8 @@ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
- This method returns TSI_OK in case of success or a specific error code in
case of failure. */
tsi_result tsi_zero_copy_grpc_protector_protect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *unprotected_slices, grpc_slice_buffer *protected_slices);
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
+ grpc_slice_buffer* protected_slices);
/* Outputs unprotected bytes.
- protected_slices is the bytes of protected frames.
@@ -53,32 +48,25 @@ tsi_result tsi_zero_copy_grpc_protector_protect(
there is not enough data to output in which case unprotected_slices has 0
bytes. */
tsi_result tsi_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *protected_slices, grpc_slice_buffer *unprotected_slices);
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
+ grpc_slice_buffer* unprotected_slices);
/* Destroys the tsi_zero_copy_grpc_protector object. */
-void tsi_zero_copy_grpc_protector_destroy(grpc_exec_ctx *exec_ctx,
- tsi_zero_copy_grpc_protector *self);
+void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector* self);
/* Base for tsi_zero_copy_grpc_protector implementations. */
typedef struct {
- tsi_result (*protect)(grpc_exec_ctx *exec_ctx,
- tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *unprotected_slices,
- grpc_slice_buffer *protected_slices);
- tsi_result (*unprotect)(grpc_exec_ctx *exec_ctx,
- tsi_zero_copy_grpc_protector *self,
- grpc_slice_buffer *protected_slices,
- grpc_slice_buffer *unprotected_slices);
- void (*destroy)(grpc_exec_ctx *exec_ctx, tsi_zero_copy_grpc_protector *self);
+ tsi_result (*protect)(tsi_zero_copy_grpc_protector* self,
+ grpc_slice_buffer* unprotected_slices,
+ grpc_slice_buffer* protected_slices);
+ tsi_result (*unprotect)(tsi_zero_copy_grpc_protector* self,
+ grpc_slice_buffer* protected_slices,
+ grpc_slice_buffer* unprotected_slices);
+ void (*destroy)(tsi_zero_copy_grpc_protector* self);
} tsi_zero_copy_grpc_protector_vtable;
struct tsi_zero_copy_grpc_protector {
- const tsi_zero_copy_grpc_protector_vtable *vtable;
+ const tsi_zero_copy_grpc_protector_vtable* vtable;
};
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_GRPC_H */
diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h
index 80c426bbdb..e925598463 100644
--- a/src/core/tsi/transport_security_interface.h
+++ b/src/core/tsi/transport_security_interface.h
@@ -24,10 +24,6 @@
#include "src/core/lib/debug/trace.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* --- tsi result --- */
typedef enum {
@@ -56,11 +52,11 @@ typedef enum {
TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY,
} tsi_client_certificate_request_type;
-const char *tsi_result_to_string(tsi_result result);
+const char* tsi_result_to_string(tsi_result result);
/* --- tsi tracing --- */
-extern grpc_tracer_flag tsi_tracing_enabled;
+extern grpc_core::TraceFlag tsi_tracing_enabled;
/* -- tsi_zero_copy_grpc_protector object --
@@ -131,11 +127,11 @@ typedef struct tsi_frame_protector tsi_frame_protector;
if (result != TSI_OK) HandleError(result);
------------------------------------------------------------------------ */
-tsi_result tsi_frame_protector_protect(tsi_frame_protector *self,
- const unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size,
- unsigned char *protected_output_frames,
- size_t *protected_output_frames_size);
+tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
+ const unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size,
+ unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size);
/* Indicates that we need to flush the bytes buffered in the protector and get
the resulting frame.
@@ -146,8 +142,8 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector *self,
- still_pending_bytes is an output parameter indicating the number of bytes
that still need to be flushed from the protector.*/
tsi_result tsi_frame_protector_protect_flush(
- tsi_frame_protector *self, unsigned char *protected_output_frames,
- size_t *protected_output_frames_size, size_t *still_pending_size);
+ tsi_frame_protector* self, unsigned char* protected_output_frames,
+ size_t* protected_output_frames_size, size_t* still_pending_size);
/* Outputs unprotected bytes.
- protected_frames_bytes is an input only parameter and points to the
@@ -172,12 +168,12 @@ tsi_result tsi_frame_protector_protect_flush(
needs to be read before new protected data can be processed in which case
protected_frames_size will be set to 0. */
tsi_result tsi_frame_protector_unprotect(
- tsi_frame_protector *self, const unsigned char *protected_frames_bytes,
- size_t *protected_frames_bytes_size, unsigned char *unprotected_bytes,
- size_t *unprotected_bytes_size);
+ tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
+ size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
+ size_t* unprotected_bytes_size);
/* Destroys the tsi_frame_protector object. */
-void tsi_frame_protector_destroy(tsi_frame_protector *self);
+void tsi_frame_protector_destroy(tsi_frame_protector* self);
/* --- tsi_peer objects ---
@@ -189,20 +185,20 @@ void tsi_frame_protector_destroy(tsi_frame_protector *self);
/* Property values may contain NULL characters just like C++ strings.
The length field gives the length of the string. */
typedef struct tsi_peer_property {
- char *name;
+ char* name;
struct {
- char *data;
+ char* data;
size_t length;
} value;
} tsi_peer_property;
typedef struct {
- tsi_peer_property *properties;
+ tsi_peer_property* properties;
size_t property_count;
} tsi_peer;
/* Destructs the tsi_peer object. */
-void tsi_peer_destruct(tsi_peer *self);
+void tsi_peer_destruct(tsi_peer* self);
/* --- tsi_handshaker_result object ---
@@ -215,27 +211,27 @@ typedef struct tsi_handshaker_result tsi_handshaker_result;
/* This method extracts tsi peer. It returns TSI_OK assuming there is no fatal
error.
The caller is responsible for destructing the peer. */
-tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result *self,
- tsi_peer *peer);
+tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result* self,
+ tsi_peer* peer);
/* This method creates a tsi_frame_protector object. It returns TSI_OK assuming
there is no fatal error.
The caller is responsible for destroying the protector. */
tsi_result tsi_handshaker_result_create_frame_protector(
- const tsi_handshaker_result *self, size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector);
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector);
/* This method returns the unused bytes from the handshake. It returns TSI_OK
assuming there is no fatal error.
Ownership of the bytes is retained by the handshaker result. As a
consequence, the caller must not free the bytes. */
tsi_result tsi_handshaker_result_get_unused_bytes(
- const tsi_handshaker_result *self, const unsigned char **bytes,
- size_t *byte_size);
+ const tsi_handshaker_result* self, const unsigned char** bytes,
+ size_t* byte_size);
/* This method releases the tsi_handshaker_handshaker object. After this method
is called, no other method can be called on the object. */
-void tsi_handshaker_result_destroy(tsi_handshaker_result *self);
+void tsi_handshaker_result_destroy(tsi_handshaker_result* self);
/* --- tsi_handshaker objects ----
@@ -346,9 +342,9 @@ typedef struct tsi_handshaker tsi_handshaker;
needs to be called again to get all the bytes to send to the peer (there
was more data to write than the specified bytes_size). In case of a fatal
error in the handshake, another specific error code is returned. */
-tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
- unsigned char *bytes,
- size_t *bytes_size);
+tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
+ unsigned char* bytes,
+ size_t* bytes_size);
/* TO BE DEPRECATED SOON. Use tsi_handshaker_next instead.
Processes bytes received from the peer.
@@ -360,9 +356,9 @@ tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
needs to be called again to complete the data needed for processing. In
case of a fatal error in the handshake, another specific error code is
returned. */
-tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker *self,
- const unsigned char *bytes,
- size_t *bytes_size);
+tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker* self,
+ const unsigned char* bytes,
+ size_t* bytes_size);
/* TO BE DEPRECATED SOON.
Gets the result of the handshaker.
@@ -370,7 +366,7 @@ tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker *self,
errors. Returns TSI_HANDSHAKE_IN_PROGRESS if the handshaker is not done yet
but no error has been encountered so far. Otherwise the handshaker failed
with the returned error. */
-tsi_result tsi_handshaker_get_result(tsi_handshaker *self);
+tsi_result tsi_handshaker_get_result(tsi_handshaker* self);
/* TO BE DEPRECATED SOON.
Returns 1 if the handshake is in progress, 0 otherwise. */
@@ -382,7 +378,7 @@ tsi_result tsi_handshaker_get_result(tsi_handshaker *self);
tsi_handshaker_is_in_progress returns 1, it returns TSI_OK otherwise
assuming the handshaker is not in a fatal error state.
The caller is responsible for destructing the peer. */
-tsi_result tsi_handshaker_extract_peer(tsi_handshaker *self, tsi_peer *peer);
+tsi_result tsi_handshaker_extract_peer(tsi_handshaker* self, tsi_peer* peer);
/* TO BE DEPRECATED SOON. Use tsi_handshaker_result_create_frame_protector
instead.
@@ -403,8 +399,8 @@ tsi_result tsi_handshaker_extract_peer(tsi_handshaker *self, tsi_peer *peer);
the handshaker is not in a fatal error state.
The caller is responsible for destroying the protector. */
tsi_result tsi_handshaker_create_frame_protector(
- tsi_handshaker *self, size_t *max_output_protected_frame_size,
- tsi_frame_protector **protector);
+ tsi_handshaker* self, size_t* max_output_protected_frame_size,
+ tsi_frame_protector** protector);
/* Callback function definition for tsi_handshaker_next.
- status indicates the status of the next operation.
@@ -414,8 +410,8 @@ tsi_result tsi_handshaker_create_frame_protector(
- handshaker_result is the result of handshake when the handshake completes,
is NULL otherwise. */
typedef void (*tsi_handshaker_on_next_done_cb)(
- tsi_result status, void *user_data, const unsigned char *bytes_to_send,
- size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result);
+ tsi_result status, void* user_data, const unsigned char* bytes_to_send,
+ size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result);
/* Conduct a next step of the handshake.
- received_bytes is the buffer containing the data received from the peer.
@@ -437,14 +433,14 @@ typedef void (*tsi_handshaker_on_next_done_cb)(
the caller should not free bytes_to_send, as the buffer is owned by the
tsi_handshaker object. */
tsi_result tsi_handshaker_next(
- tsi_handshaker *self, const unsigned char *received_bytes,
- size_t received_bytes_size, const unsigned char **bytes_to_send,
- size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
- tsi_handshaker_on_next_done_cb cb, void *user_data);
+ tsi_handshaker* self, const unsigned char* received_bytes,
+ size_t received_bytes_size, const unsigned char** bytes_to_send,
+ size_t* bytes_to_send_size, tsi_handshaker_result** handshaker_result,
+ tsi_handshaker_on_next_done_cb cb, void* user_data);
/* This method releases the tsi_handshaker object. After this method is called,
no other method can be called on the object. */
-void tsi_handshaker_destroy(tsi_handshaker *self);
+void tsi_handshaker_destroy(tsi_handshaker* self);
/* This method initializes the necessary shared objects used for tsi
implementation. */
@@ -453,8 +449,4 @@ void tsi_init();
/* This method destroys the shared objects created by tsi_init. */
void tsi_destroy();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H */
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc
index 19a25c838f..362dff642c 100644
--- a/src/cpp/client/channel_cc.cc
+++ b/src/cpp/client/channel_cc.cc
@@ -42,204 +42,30 @@
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
namespace grpc {
-namespace {
-int kConnectivityCheckIntervalMsec = 500;
-void WatchStateChange(void* arg);
-
-class TagSaver final : public CompletionQueueTag {
- public:
- explicit TagSaver(void* tag) : tag_(tag) {}
- ~TagSaver() override {}
- bool FinalizeResult(void** tag, bool* status) override {
- *tag = tag_;
- delete this;
- return true;
- }
-
- private:
- void* tag_;
-};
-
-// Constantly watches channel connectivity status to reconnect a transiently
-// disconnected channel. This is a temporary work-around before we have retry
-// support.
-class ChannelConnectivityWatcher : private GrpcLibraryCodegen {
- public:
- static void StartWatching(grpc_channel* channel) {
- if (!IsDisabled()) {
- std::unique_lock<std::mutex> lock(g_watcher_mu_);
- if (g_watcher_ == nullptr) {
- g_watcher_ = new ChannelConnectivityWatcher();
- }
- g_watcher_->StartWatchingLocked(channel);
- }
- }
-
- static void StopWatching() {
- if (!IsDisabled()) {
- std::unique_lock<std::mutex> lock(g_watcher_mu_);
- if (g_watcher_->StopWatchingLocked()) {
- delete g_watcher_;
- g_watcher_ = nullptr;
- }
- }
- }
-
- private:
- ChannelConnectivityWatcher() : channel_count_(0), shutdown_(false) {
- gpr_ref_init(&ref_, 0);
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
- gpr_thd_new(&thd_id_, &WatchStateChange, this, &options);
- }
-
- static bool IsDisabled() {
- char* env = gpr_getenv("GRPC_DISABLE_CHANNEL_CONNECTIVITY_WATCHER");
- bool disabled = gpr_is_true(env);
- gpr_free(env);
- return disabled;
- }
-
- void WatchStateChangeImpl() {
- bool ok = false;
- void* tag = NULL;
- CompletionQueue::NextStatus status = CompletionQueue::GOT_EVENT;
- while (true) {
- {
- std::unique_lock<std::mutex> lock(shutdown_mu_);
- if (shutdown_) {
- // Drain cq_ if the watcher is shutting down
- status = cq_.AsyncNext(&tag, &ok, gpr_inf_future(GPR_CLOCK_REALTIME));
- } else {
- status = cq_.AsyncNext(&tag, &ok, gpr_inf_past(GPR_CLOCK_REALTIME));
- // Make sure we've seen 2 TIMEOUTs before going to sleep
- if (status == CompletionQueue::TIMEOUT) {
- status = cq_.AsyncNext(&tag, &ok, gpr_inf_past(GPR_CLOCK_REALTIME));
- if (status == CompletionQueue::TIMEOUT) {
- shutdown_cv_.wait_for(lock, std::chrono::milliseconds(
- kConnectivityCheckIntervalMsec));
- continue;
- }
- }
- }
- }
- ChannelState* channel_state = static_cast<ChannelState*>(tag);
- channel_state->state =
- grpc_channel_check_connectivity_state(channel_state->channel, false);
- if (channel_state->state == GRPC_CHANNEL_SHUTDOWN) {
- void* shutdown_tag = NULL;
- channel_state->shutdown_cq.Next(&shutdown_tag, &ok);
- delete channel_state;
- if (gpr_unref(&ref_)) {
- break;
- }
- } else {
- TagSaver* tag_saver = new TagSaver(channel_state);
- grpc_channel_watch_connectivity_state(
- channel_state->channel, channel_state->state,
- gpr_inf_future(GPR_CLOCK_REALTIME), cq_.cq(), tag_saver);
- }
- }
- }
-
- void StartWatchingLocked(grpc_channel* channel) {
- if (thd_id_ != 0) {
- gpr_ref(&ref_);
- ++channel_count_;
- ChannelState* channel_state = new ChannelState(channel);
- // The first grpc_channel_watch_connectivity_state() is not used to
- // monitor the channel state change, but to hold a reference of the
- // c channel. So that WatchStateChangeImpl() can observe state ==
- // GRPC_CHANNEL_SHUTDOWN before the channel gets destroyed.
- grpc_channel_watch_connectivity_state(
- channel_state->channel, channel_state->state,
- gpr_inf_future(GPR_CLOCK_REALTIME), channel_state->shutdown_cq.cq(),
- new TagSaver(nullptr));
- grpc_channel_watch_connectivity_state(
- channel_state->channel, channel_state->state,
- gpr_inf_future(GPR_CLOCK_REALTIME), cq_.cq(),
- new TagSaver(channel_state));
- }
- }
-
- bool StopWatchingLocked() {
- if (--channel_count_ == 0) {
- {
- std::unique_lock<std::mutex> lock(shutdown_mu_);
- shutdown_ = true;
- shutdown_cv_.notify_one();
- }
- gpr_thd_join(thd_id_);
- return true;
- }
- return false;
- }
-
- friend void WatchStateChange(void* arg);
- struct ChannelState {
- explicit ChannelState(grpc_channel* channel)
- : channel(channel), state(GRPC_CHANNEL_IDLE){};
- grpc_channel* channel;
- grpc_connectivity_state state;
- CompletionQueue shutdown_cq;
- };
- gpr_thd_id thd_id_;
- CompletionQueue cq_;
- gpr_refcount ref_;
- int channel_count_;
-
- std::mutex shutdown_mu_;
- std::condition_variable shutdown_cv_; // protected by shutdown_mu_
- bool shutdown_; // protected by shutdown_mu_
-
- static std::mutex g_watcher_mu_;
- static ChannelConnectivityWatcher* g_watcher_; // protected by g_watcher_mu_
-};
-
-std::mutex ChannelConnectivityWatcher::g_watcher_mu_;
-ChannelConnectivityWatcher* ChannelConnectivityWatcher::g_watcher_ = nullptr;
-
-void WatchStateChange(void* arg) {
- ChannelConnectivityWatcher* watcher =
- static_cast<ChannelConnectivityWatcher*>(arg);
- watcher->WatchStateChangeImpl();
-}
-} // namespace
-
static internal::GrpcLibraryInitializer g_gli_initializer;
Channel::Channel(const grpc::string& host, grpc_channel* channel)
: host_(host), c_channel_(channel) {
g_gli_initializer.summon();
- if (grpc_channel_support_connectivity_watcher(channel)) {
- ChannelConnectivityWatcher::StartWatching(channel);
- }
}
-Channel::~Channel() {
- const bool stop_watching =
- grpc_channel_support_connectivity_watcher(c_channel_);
- grpc_channel_destroy(c_channel_);
- if (stop_watching) {
- ChannelConnectivityWatcher::StopWatching();
- }
-}
+Channel::~Channel() { grpc_channel_destroy(c_channel_); }
namespace {
grpc::string GetChannelInfoField(grpc_channel* channel,
grpc_channel_info* channel_info,
char*** channel_info_field) {
- char* value = NULL;
+ char* value = nullptr;
memset(channel_info, 0, sizeof(*channel_info));
*channel_info_field = &value;
grpc_channel_get_info(channel, channel_info);
- if (value == NULL) return "";
+ if (value == nullptr) return "";
grpc::string result = value;
gpr_free(value);
return result;
@@ -259,17 +85,18 @@ grpc::string Channel::GetServiceConfigJSON() const {
&channel_info.service_config_json);
}
-Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
- CompletionQueue* cq) {
+internal::Call Channel::CreateCall(const internal::RpcMethod& method,
+ ClientContext* context,
+ CompletionQueue* cq) {
const bool kRegistered = method.channel_tag() && context->authority().empty();
- grpc_call* c_call = NULL;
+ grpc_call* c_call = nullptr;
if (kRegistered) {
c_call = grpc_channel_create_registered_call(
c_channel_, context->propagate_from_call_,
context->propagation_options_.c_bitmask(), cq->cq(),
method.channel_tag(), context->raw_deadline(), nullptr);
} else {
- const char* host_str = NULL;
+ const char* host_str = nullptr;
if (!context->authority().empty()) {
host_str = context->authority_.c_str();
} else if (!host_.empty()) {
@@ -292,10 +119,11 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
}
grpc_census_call_set_context(c_call, context->census_context());
context->set_call(c_call, shared_from_this());
- return Call(c_call, this, cq);
+ return internal::Call(c_call, this, cq);
}
-void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) {
+void Channel::PerformOpsOnCall(internal::CallOpSetInterface* ops,
+ internal::Call* call) {
static const size_t MAX_OPS = 8;
size_t nops = 0;
grpc_op cops[MAX_OPS];
@@ -306,13 +134,31 @@ void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) {
void* Channel::RegisterMethod(const char* method) {
return grpc_channel_register_call(
- c_channel_, method, host_.empty() ? NULL : host_.c_str(), nullptr);
+ c_channel_, method, host_.empty() ? nullptr : host_.c_str(), nullptr);
}
grpc_connectivity_state Channel::GetState(bool try_to_connect) {
return grpc_channel_check_connectivity_state(c_channel_, try_to_connect);
}
+namespace {
+
+class TagSaver final : public internal::CompletionQueueTag {
+ public:
+ explicit TagSaver(void* tag) : tag_(tag) {}
+ ~TagSaver() override {}
+ bool FinalizeResult(void** tag, bool* status) override {
+ *tag = tag_;
+ delete this;
+ return true;
+ }
+
+ private:
+ void* tag_;
+};
+
+} // namespace
+
void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline,
CompletionQueue* cq, void* tag) {
@@ -325,10 +171,10 @@ bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline) {
CompletionQueue cq;
bool ok = false;
- void* tag = NULL;
- NotifyOnStateChangeImpl(last_observed, deadline, &cq, NULL);
+ void* tag = nullptr;
+ NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr);
cq.Next(&tag, &ok);
- GPR_ASSERT(tag == NULL);
+ GPR_ASSERT(tag == nullptr);
return ok;
}
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index 40e95f3c05..dafa8081e9 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -127,7 +127,7 @@ grpc::string ClientContext::peer() const {
void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) {
GPR_ASSERT(g_client_callbacks == &g_default_client_callbacks);
- GPR_ASSERT(client_callbacks != NULL);
+ GPR_ASSERT(client_callbacks != nullptr);
GPR_ASSERT(client_callbacks != &g_default_client_callbacks);
g_client_callbacks = client_callbacks;
}
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index e2893c8f3c..93233153d0 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -38,13 +38,12 @@ std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
- internal::GrpcLibrary
- init_lib; // We need to call init in case of a bad creds.
- return creds
- ? creds->CreateChannel(target, args)
- : CreateChannelInternal("", grpc_lame_client_channel_create(
- NULL, GRPC_STATUS_INVALID_ARGUMENT,
- "Invalid credentials."));
+ GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds.
+ return creds ? creds->CreateChannel(target, args)
+ : CreateChannelInternal(
+ "", grpc_lame_client_channel_create(
+ nullptr, GRPC_STATUS_INVALID_ARGUMENT,
+ "Invalid credentials."));
}
} // namespace grpc
diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc
index 693b8bea56..4b4b8dd427 100644
--- a/src/cpp/client/generic_stub.cc
+++ b/src/cpp/client/generic_stub.cc
@@ -27,8 +27,10 @@ std::unique_ptr<GenericClientAsyncReaderWriter> CallInternal(
ChannelInterface* channel, ClientContext* context,
const grpc::string& method, CompletionQueue* cq, bool start, void* tag) {
return std::unique_ptr<GenericClientAsyncReaderWriter>(
- GenericClientAsyncReaderWriter::Create(
- channel, cq, RpcMethod(method.c_str(), RpcMethod::BIDI_STREAMING),
+ internal::ClientAsyncReaderWriterFactory<ByteBuffer, ByteBuffer>::Create(
+ channel, cq,
+ internal::RpcMethod(method.c_str(),
+ internal::RpcMethod::BIDI_STREAMING),
context, start, tag));
}
@@ -52,8 +54,9 @@ std::unique_ptr<GenericClientAsyncResponseReader> GenericStub::PrepareUnaryCall(
ClientContext* context, const grpc::string& method,
const ByteBuffer& request, CompletionQueue* cq) {
return std::unique_ptr<GenericClientAsyncResponseReader>(
- GenericClientAsyncResponseReader::Create(
- channel_.get(), cq, RpcMethod(method.c_str(), RpcMethod::NORMAL_RPC),
+ internal::ClientAsyncResponseReaderFactory<ByteBuffer>::Create(
+ channel_.get(), cq,
+ internal::RpcMethod(method.c_str(), internal::RpcMethod::NORMAL_RPC),
context, request, false));
}
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index 057a058a3f..4fb128d98b 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -21,6 +21,7 @@
#include <grpc++/impl/grpc_library.h>
#include <grpc++/support/channel_arguments.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/cpp/client/create_channel_internal.h"
#include "src/cpp/common/secure_auth_context.h"
@@ -55,14 +56,16 @@ bool SecureCallCredentials::ApplyToCall(grpc_call* call) {
namespace {
std::shared_ptr<ChannelCredentials> WrapChannelCredentials(
grpc_channel_credentials* creds) {
- return creds == nullptr ? nullptr : std::shared_ptr<ChannelCredentials>(
- new SecureChannelCredentials(creds));
+ return creds == nullptr ? nullptr
+ : std::shared_ptr<ChannelCredentials>(
+ new SecureChannelCredentials(creds));
}
std::shared_ptr<CallCredentials> WrapCallCredentials(
grpc_call_credentials* creds) {
- return creds == nullptr ? nullptr : std::shared_ptr<CallCredentials>(
- new SecureCallCredentials(creds));
+ return creds == nullptr ? nullptr
+ : std::shared_ptr<CallCredentials>(
+ new SecureCallCredentials(creds));
}
} // namespace
@@ -150,6 +153,18 @@ std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
return nullptr;
}
+std::shared_ptr<CallCredentials> CompositeCallCredentials(
+ const std::shared_ptr<CallCredentials>& creds1,
+ const std::shared_ptr<CallCredentials>& creds2) {
+ SecureCallCredentials* s_creds1 = creds1->AsSecureCredentials();
+ SecureCallCredentials* s_creds2 = creds2->AsSecureCredentials();
+ if (s_creds1 != nullptr && s_creds2 != nullptr) {
+ return WrapCallCredentials(grpc_composite_call_credentials_create(
+ s_creds1->GetRawCreds(), s_creds2->GetRawCreds(), nullptr));
+ }
+ return nullptr;
+}
+
void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) {
if (wrapper == nullptr) return;
MetadataCredentialsPluginWrapper* w =
@@ -157,28 +172,50 @@ void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) {
delete w;
}
-void MetadataCredentialsPluginWrapper::GetMetadata(
+int MetadataCredentialsPluginWrapper::GetMetadata(
void* wrapper, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void* user_data) {
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
GPR_ASSERT(wrapper);
MetadataCredentialsPluginWrapper* w =
reinterpret_cast<MetadataCredentialsPluginWrapper*>(wrapper);
if (!w->plugin_) {
- cb(user_data, NULL, 0, GRPC_STATUS_OK, NULL);
- return;
+ *num_creds_md = 0;
+ *status = GRPC_STATUS_OK;
+ *error_details = nullptr;
+ return true;
}
if (w->plugin_->IsBlocking()) {
+ // Asynchronous return.
w->thread_pool_->Add(
std::bind(&MetadataCredentialsPluginWrapper::InvokePlugin, w, context,
- cb, user_data));
+ cb, user_data, nullptr, nullptr, nullptr, nullptr));
+ return 0;
} else {
- w->InvokePlugin(context, cb, user_data);
+ // Synchronous return.
+ w->InvokePlugin(context, cb, user_data, creds_md, num_creds_md, status,
+ error_details);
+ return 1;
+ }
+}
+
+namespace {
+
+void UnrefMetadata(const std::vector<grpc_metadata>& md) {
+ for (auto it = md.begin(); it != md.end(); ++it) {
+ grpc_slice_unref(it->key);
+ grpc_slice_unref(it->value);
}
}
+} // namespace
+
void MetadataCredentialsPluginWrapper::InvokePlugin(
grpc_auth_metadata_context context, grpc_credentials_plugin_metadata_cb cb,
- void* user_data) {
+ void* user_data, grpc_metadata creds_md[4], size_t* num_creds_md,
+ grpc_status_code* status_code, const char** error_details) {
std::multimap<grpc::string, grpc::string> metadata;
// const_cast is safe since the SecureAuthContext does not take owndership and
@@ -196,12 +233,31 @@ void MetadataCredentialsPluginWrapper::InvokePlugin(
md_entry.flags = 0;
md.push_back(md_entry);
}
- cb(user_data, md.empty() ? nullptr : &md[0], md.size(),
- static_cast<grpc_status_code>(status.error_code()),
- status.error_message().c_str());
- for (auto it = md.begin(); it != md.end(); ++it) {
- grpc_slice_unref(it->key);
- grpc_slice_unref(it->value);
+ if (creds_md != nullptr) {
+ // Synchronous return.
+ if (md.size() > GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX) {
+ *num_creds_md = 0;
+ *status_code = GRPC_STATUS_INTERNAL;
+ *error_details = gpr_strdup(
+ "blocking plugin credentials returned too many metadata keys");
+ UnrefMetadata(md);
+ } else {
+ for (const auto& elem : md) {
+ creds_md[*num_creds_md].key = elem.key;
+ creds_md[*num_creds_md].value = elem.value;
+ creds_md[*num_creds_md].flags = elem.flags;
+ ++(*num_creds_md);
+ }
+ *status_code = static_cast<grpc_status_code>(status.error_code());
+ *error_details =
+ status.ok() ? nullptr : gpr_strdup(status.error_message().c_str());
+ }
+ } else {
+ // Asynchronous return.
+ cb(user_data, md.empty() ? nullptr : &md[0], md.size(),
+ static_cast<grpc_status_code>(status.error_code()),
+ status.error_message().c_str());
+ UnrefMetadata(md);
}
}
diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h
index 66547c736b..ed9afb37b0 100644
--- a/src/cpp/client/secure_credentials.h
+++ b/src/cpp/client/secure_credentials.h
@@ -58,16 +58,23 @@ class SecureCallCredentials final : public CallCredentials {
class MetadataCredentialsPluginWrapper final : private GrpcLibraryCodegen {
public:
static void Destroy(void* wrapper);
- static void GetMetadata(void* wrapper, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void* user_data);
+ static int GetMetadata(
+ void* wrapper, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details);
explicit MetadataCredentialsPluginWrapper(
std::unique_ptr<MetadataCredentialsPlugin> plugin);
private:
- void InvokePlugin(grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void* user_data);
+ void InvokePlugin(
+ grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status_code,
+ const char** error_details);
std::unique_ptr<ThreadPoolInterface> thread_pool_;
std::unique_ptr<MetadataCredentialsPlugin> plugin_;
};
diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc
index f130aecd4b..b696774243 100644
--- a/src/cpp/common/channel_arguments.cc
+++ b/src/cpp/common/channel_arguments.cc
@@ -23,11 +23,10 @@
#include <grpc++/resource_quota.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/log.h>
-extern "C" {
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/socket_mutator.h"
-}
+
namespace grpc {
ChannelArguments::ChannelArguments() {
@@ -67,13 +66,12 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
}
ChannelArguments::~ChannelArguments() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
for (auto it = args_.begin(); it != args_.end(); ++it) {
if (it->type == GRPC_ARG_POINTER) {
- it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p);
+ it->value.pointer.vtable->destroy(it->value.pointer.p);
}
}
- grpc_exec_ctx_finish(&exec_ctx);
}
void ChannelArguments::Swap(ChannelArguments& other) {
@@ -86,23 +84,27 @@ void ChannelArguments::SetCompressionAlgorithm(
SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, algorithm);
}
+void ChannelArguments::SetGrpclbFallbackTimeout(int fallback_timeout) {
+ SetInt(GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS, fallback_timeout);
+}
+
void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
if (!mutator) {
return;
}
grpc_arg mutator_arg = grpc_socket_mutator_to_arg(mutator);
bool replaced = false;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
for (auto it = args_.begin(); it != args_.end(); ++it) {
if (it->type == mutator_arg.type &&
grpc::string(it->key) == grpc::string(mutator_arg.key)) {
GPR_ASSERT(!replaced);
- it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p);
+ it->value.pointer.vtable->destroy(it->value.pointer.p);
it->value.pointer = mutator_arg.value.pointer;
replaced = true;
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (!replaced) {
args_.push_back(mutator_arg);
}
diff --git a/src/cpp/common/channel_filter.cc b/src/cpp/common/channel_filter.cc
index ea44cff832..cbe2a209f5 100644
--- a/src/cpp/common/channel_filter.cc
+++ b/src/cpp/common/channel_filter.cc
@@ -18,9 +18,7 @@
#include <string.h>
-extern "C" {
#include "src/core/lib/channel/channel_stack.h"
-}
#include "src/cpp/common/channel_filter.h"
#include <grpc++/impl/codegen/slice.h>
@@ -29,43 +27,39 @@ namespace grpc {
// MetadataBatch
-grpc_linked_mdelem *MetadataBatch::AddMetadata(grpc_exec_ctx *exec_ctx,
- const string &key,
- const string &value) {
- grpc_linked_mdelem *storage = new grpc_linked_mdelem;
+grpc_linked_mdelem* MetadataBatch::AddMetadata(const string& key,
+ const string& value) {
+ grpc_linked_mdelem* storage = new grpc_linked_mdelem;
memset(storage, 0, sizeof(grpc_linked_mdelem));
- storage->md = grpc_mdelem_from_slices(exec_ctx, SliceFromCopiedString(key),
+ storage->md = grpc_mdelem_from_slices(SliceFromCopiedString(key),
SliceFromCopiedString(value));
GRPC_LOG_IF_ERROR("MetadataBatch::AddMetadata",
- grpc_metadata_batch_link_head(exec_ctx, batch_, storage));
+ grpc_metadata_batch_link_head(batch_, storage));
return storage;
}
// ChannelData
-void ChannelData::StartTransportOp(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- TransportOp *op) {
- grpc_channel_next_op(exec_ctx, elem, op->op());
+void ChannelData::StartTransportOp(grpc_channel_element* elem,
+ TransportOp* op) {
+ grpc_channel_next_op(elem, op->op());
}
-void ChannelData::GetInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {
- grpc_channel_next_get_info(exec_ctx, elem, channel_info);
+void ChannelData::GetInfo(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {
+ grpc_channel_next_get_info(elem, channel_info);
}
// CallData
-void CallData::StartTransportStreamOpBatch(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- TransportStreamOpBatch *op) {
- grpc_call_next_op(exec_ctx, elem, op->op());
+void CallData::StartTransportStreamOpBatch(grpc_call_element* elem,
+ TransportStreamOpBatch* op) {
+ grpc_call_next_op(elem, op->op());
}
-void CallData::SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {
- grpc_call_stack_ignore_set_pollset_or_pollset_set(exec_ctx, elem, pollent);
+void CallData::SetPollsetOrPollsetSet(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {
+ grpc_call_stack_ignore_set_pollset_or_pollset_set(elem, pollent);
}
// internal code used by RegisterChannelFilter()
@@ -73,15 +67,14 @@ void CallData::SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx,
namespace internal {
// Note: Implicitly initialized to nullptr due to static lifetime.
-std::vector<FilterRecord> *channel_filters;
+std::vector<FilterRecord>* channel_filters;
namespace {
-bool MaybeAddFilter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder, void *arg) {
- const FilterRecord &filter = *(FilterRecord *)arg;
+bool MaybeAddFilter(grpc_channel_stack_builder* builder, void* arg) {
+ const FilterRecord& filter = *(FilterRecord*)arg;
if (filter.include_filter) {
- const grpc_channel_args *args =
+ const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
if (!filter.include_filter(*args)) return true;
}
@@ -93,9 +86,9 @@ bool MaybeAddFilter(grpc_exec_ctx *exec_ctx,
void ChannelFilterPluginInit() {
for (size_t i = 0; i < channel_filters->size(); ++i) {
- FilterRecord &filter = (*channel_filters)[i];
+ FilterRecord& filter = (*channel_filters)[i];
grpc_channel_init_register_stage(filter.stack_type, filter.priority,
- MaybeAddFilter, (void *)&filter);
+ MaybeAddFilter, (void*)&filter);
}
}
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index c1aeb3f724..a1f42c0b32 100644
--- a/src/cpp/common/channel_filter.h
+++ b/src/cpp/common/channel_filter.h
@@ -26,11 +26,9 @@
#include <functional>
#include <vector>
-extern "C" {
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/metadata_batch.h"
-}
/// An interface to define filters.
///
@@ -49,23 +47,22 @@ class MetadataBatch {
/// Borrows a pointer to \a batch, but does NOT take ownership.
/// The caller must ensure that \a batch continues to exist for as
/// long as the MetadataBatch object does.
- explicit MetadataBatch(grpc_metadata_batch *batch) : batch_(batch) {}
+ explicit MetadataBatch(grpc_metadata_batch* batch) : batch_(batch) {}
- grpc_metadata_batch *batch() const { return batch_; }
+ grpc_metadata_batch* batch() const { return batch_; }
/// Adds metadata and returns the newly allocated storage.
/// The caller takes ownership of the result, which must exist for the
/// lifetime of the gRPC call.
- grpc_linked_mdelem *AddMetadata(grpc_exec_ctx *exec_ctx, const string &key,
- const string &value);
+ grpc_linked_mdelem* AddMetadata(const string& key, const string& value);
class const_iterator : public std::iterator<std::bidirectional_iterator_tag,
const grpc_mdelem> {
public:
- const grpc_mdelem &operator*() const { return elem_->md; }
+ const grpc_mdelem& operator*() const { return elem_->md; }
const grpc_mdelem operator->() const { return elem_->md; }
- const_iterator &operator++() {
+ const_iterator& operator++() {
elem_ = elem_->next;
return *this;
}
@@ -74,7 +71,7 @@ class MetadataBatch {
operator++();
return tmp;
}
- const_iterator &operator--() {
+ const_iterator& operator--() {
elem_ = elem_->prev;
return *this;
}
@@ -84,25 +81,25 @@ class MetadataBatch {
return tmp;
}
- bool operator==(const const_iterator &other) const {
+ bool operator==(const const_iterator& other) const {
return elem_ == other.elem_;
}
- bool operator!=(const const_iterator &other) const {
+ bool operator!=(const const_iterator& other) const {
return elem_ != other.elem_;
}
private:
friend class MetadataBatch;
- explicit const_iterator(grpc_linked_mdelem *elem) : elem_(elem) {}
+ explicit const_iterator(grpc_linked_mdelem* elem) : elem_(elem) {}
- grpc_linked_mdelem *elem_;
+ grpc_linked_mdelem* elem_;
};
const_iterator begin() const { return const_iterator(batch_->list.head); }
const_iterator end() const { return const_iterator(nullptr); }
private:
- grpc_metadata_batch *batch_; // Not owned.
+ grpc_metadata_batch* batch_; // Not owned.
};
/// A C++ wrapper for the \c grpc_transport_op struct.
@@ -111,12 +108,12 @@ class TransportOp {
/// Borrows a pointer to \a op, but does NOT take ownership.
/// The caller must ensure that \a op continues to exist for as
/// long as the TransportOp object does.
- explicit TransportOp(grpc_transport_op *op) : op_(op) {}
+ explicit TransportOp(grpc_transport_op* op) : op_(op) {}
- grpc_transport_op *op() const { return op_; }
+ grpc_transport_op* op() const { return op_; }
// TODO(roth): Add a C++ wrapper for grpc_error?
- grpc_error *disconnect_with_error() const {
+ grpc_error* disconnect_with_error() const {
return op_->disconnect_with_error;
}
bool send_goaway() const { return op_->goaway_error != GRPC_ERROR_NONE; }
@@ -124,7 +121,7 @@ class TransportOp {
// TODO(roth): Add methods for additional fields as needed.
private:
- grpc_transport_op *op_; // Not owned.
+ grpc_transport_op* op_; // Not owned.
};
/// A C++ wrapper for the \c grpc_transport_stream_op_batch struct.
@@ -133,7 +130,7 @@ class TransportStreamOpBatch {
/// Borrows a pointer to \a op, but does NOT take ownership.
/// The caller must ensure that \a op continues to exist for as
/// long as the TransportStreamOpBatch object does.
- explicit TransportStreamOpBatch(grpc_transport_stream_op_batch *op)
+ explicit TransportStreamOpBatch(grpc_transport_stream_op_batch* op)
: op_(op),
send_initial_metadata_(
op->send_initial_metadata
@@ -152,64 +149,63 @@ class TransportStreamOpBatch {
? op->payload->recv_trailing_metadata.recv_trailing_metadata
: nullptr) {}
- grpc_transport_stream_op_batch *op() const { return op_; }
+ grpc_transport_stream_op_batch* op() const { return op_; }
- grpc_closure *on_complete() const { return op_->on_complete; }
- void set_on_complete(grpc_closure *closure) { op_->on_complete = closure; }
+ grpc_closure* on_complete() const { return op_->on_complete; }
+ void set_on_complete(grpc_closure* closure) { op_->on_complete = closure; }
- MetadataBatch *send_initial_metadata() {
+ MetadataBatch* send_initial_metadata() {
return op_->send_initial_metadata ? &send_initial_metadata_ : nullptr;
}
- MetadataBatch *send_trailing_metadata() {
+ MetadataBatch* send_trailing_metadata() {
return op_->send_trailing_metadata ? &send_trailing_metadata_ : nullptr;
}
- MetadataBatch *recv_initial_metadata() {
+ MetadataBatch* recv_initial_metadata() {
return op_->recv_initial_metadata ? &recv_initial_metadata_ : nullptr;
}
- MetadataBatch *recv_trailing_metadata() {
+ MetadataBatch* recv_trailing_metadata() {
return op_->recv_trailing_metadata ? &recv_trailing_metadata_ : nullptr;
}
- uint32_t *send_initial_metadata_flags() const {
- return op_->send_initial_metadata
- ? &op_->payload->send_initial_metadata
- .send_initial_metadata_flags
- : nullptr;
+ uint32_t* send_initial_metadata_flags() const {
+ return op_->send_initial_metadata ? &op_->payload->send_initial_metadata
+ .send_initial_metadata_flags
+ : nullptr;
}
- grpc_closure *recv_initial_metadata_ready() const {
+ grpc_closure* recv_initial_metadata_ready() const {
return op_->recv_initial_metadata
? op_->payload->recv_initial_metadata.recv_initial_metadata_ready
: nullptr;
}
- void set_recv_initial_metadata_ready(grpc_closure *closure) {
+ void set_recv_initial_metadata_ready(grpc_closure* closure) {
op_->payload->recv_initial_metadata.recv_initial_metadata_ready = closure;
}
- grpc_byte_stream *send_message() const {
+ grpc_byte_stream* send_message() const {
return op_->send_message ? op_->payload->send_message.send_message
: nullptr;
}
- void set_send_message(grpc_byte_stream *send_message) {
+ void set_send_message(grpc_byte_stream* send_message) {
op_->send_message = true;
op_->payload->send_message.send_message = send_message;
}
- grpc_byte_stream **recv_message() const {
+ grpc_byte_stream** recv_message() const {
return op_->recv_message ? op_->payload->recv_message.recv_message
: nullptr;
}
- void set_recv_message(grpc_byte_stream **recv_message) {
+ void set_recv_message(grpc_byte_stream** recv_message) {
op_->recv_message = true;
op_->payload->recv_message.recv_message = recv_message;
}
- census_context *get_census_context() const {
- return (census_context *)op_->payload->context[GRPC_CONTEXT_TRACING].value;
+ census_context* get_census_context() const {
+ return (census_context*)op_->payload->context[GRPC_CONTEXT_TRACING].value;
}
private:
- grpc_transport_stream_op_batch *op_; // Not owned.
+ grpc_transport_stream_op_batch* op_; // Not owned.
MetadataBatch send_initial_metadata_;
MetadataBatch send_trailing_metadata_;
MetadataBatch recv_initial_metadata_;
@@ -225,19 +221,18 @@ class ChannelData {
// TODO(roth): Come up with a more C++-like API for the channel element.
/// Initializes the channel data.
- virtual grpc_error *Init(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+ virtual grpc_error* Init(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {}
+ virtual void Destroy(grpc_channel_element* elem) {}
- virtual void StartTransportOp(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem, TransportOp *op);
+ virtual void StartTransportOp(grpc_channel_element* elem, TransportOp* op);
- virtual void GetInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- const grpc_channel_info *channel_info);
+ virtual void GetInfo(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info);
};
/// Represents call data.
@@ -249,25 +244,23 @@ class CallData {
// TODO(roth): Come up with a more C++-like API for the call element.
/// Initializes the call data.
- virtual grpc_error *Init(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_element_args *args) {
+ virtual grpc_error* Init(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_call_closure) {}
+ virtual void Destroy(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_call_closure) {}
/// Starts a new stream operation.
- virtual void StartTransportStreamOpBatch(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- TransportStreamOpBatch *op);
+ virtual void StartTransportStreamOpBatch(grpc_call_element* elem,
+ TransportStreamOpBatch* op);
/// Sets a pollset or pollset set.
- virtual void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent);
+ virtual void SetPollsetOrPollsetSet(grpc_call_element* elem,
+ grpc_polling_entity* pollent);
};
namespace internal {
@@ -280,81 +273,73 @@ class ChannelFilter final {
public:
static const size_t channel_data_size = sizeof(ChannelDataType);
- static grpc_error *InitChannelElement(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+ static grpc_error* InitChannelElement(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
// Construct the object in the already-allocated memory.
- ChannelDataType *channel_data = new (elem->channel_data) ChannelDataType();
- return channel_data->Init(exec_ctx, elem, args);
+ ChannelDataType* channel_data = new (elem->channel_data) ChannelDataType();
+ return channel_data->Init(elem, args);
}
- static void DestroyChannelElement(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {
- ChannelDataType *channel_data =
- reinterpret_cast<ChannelDataType *>(elem->channel_data);
- channel_data->Destroy(exec_ctx, elem);
+ static void DestroyChannelElement(grpc_channel_element* elem) {
+ ChannelDataType* channel_data =
+ reinterpret_cast<ChannelDataType*>(elem->channel_data);
+ channel_data->Destroy(elem);
channel_data->~ChannelDataType();
}
- static void StartTransportOp(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_transport_op *op) {
- ChannelDataType *channel_data =
- reinterpret_cast<ChannelDataType *>(elem->channel_data);
+ static void StartTransportOp(grpc_channel_element* elem,
+ grpc_transport_op* op) {
+ ChannelDataType* channel_data =
+ reinterpret_cast<ChannelDataType*>(elem->channel_data);
TransportOp op_wrapper(op);
- channel_data->StartTransportOp(exec_ctx, elem, &op_wrapper);
+ channel_data->StartTransportOp(elem, &op_wrapper);
}
- static void GetChannelInfo(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {
- ChannelDataType *channel_data =
- reinterpret_cast<ChannelDataType *>(elem->channel_data);
- channel_data->GetInfo(exec_ctx, elem, channel_info);
+ static void GetChannelInfo(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {
+ ChannelDataType* channel_data =
+ reinterpret_cast<ChannelDataType*>(elem->channel_data);
+ channel_data->GetInfo(elem, channel_info);
}
static const size_t call_data_size = sizeof(CallDataType);
- static grpc_error *InitCallElement(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+ static grpc_error* InitCallElement(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
// Construct the object in the already-allocated memory.
- CallDataType *call_data = new (elem->call_data) CallDataType();
- return call_data->Init(exec_ctx, elem, args);
+ CallDataType* call_data = new (elem->call_data) CallDataType();
+ return call_data->Init(elem, args);
}
- static void DestroyCallElement(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_call_closure) {
- CallDataType *call_data = reinterpret_cast<CallDataType *>(elem->call_data);
- call_data->Destroy(exec_ctx, elem, final_info, then_call_closure);
+ static void DestroyCallElement(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_call_closure) {
+ CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
+ call_data->Destroy(elem, final_info, then_call_closure);
call_data->~CallDataType();
}
- static void StartTransportStreamOpBatch(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- CallDataType *call_data = reinterpret_cast<CallDataType *>(elem->call_data);
+ static void StartTransportStreamOpBatch(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
+ CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
TransportStreamOpBatch op_wrapper(op);
- call_data->StartTransportStreamOpBatch(exec_ctx, elem, &op_wrapper);
+ call_data->StartTransportStreamOpBatch(elem, &op_wrapper);
}
- static void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {
- CallDataType *call_data = reinterpret_cast<CallDataType *>(elem->call_data);
- call_data->SetPollsetOrPollsetSet(exec_ctx, elem, pollent);
+ static void SetPollsetOrPollsetSet(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {
+ CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
+ call_data->SetPollsetOrPollsetSet(elem, pollent);
}
};
struct FilterRecord {
grpc_channel_stack_type stack_type;
int priority;
- std::function<bool(const grpc_channel_args &)> include_filter;
+ std::function<bool(const grpc_channel_args&)> include_filter;
grpc_channel_filter filter;
};
-extern std::vector<FilterRecord> *channel_filters;
+extern std::vector<FilterRecord>* channel_filters;
void ChannelFilterPluginInit();
void ChannelFilterPluginShutdown();
@@ -368,8 +353,8 @@ void ChannelFilterPluginShutdown();
/// value is nullptr, the filter will be added unconditionally.
template <typename ChannelDataType, typename CallDataType>
void RegisterChannelFilter(
- const char *name, grpc_channel_stack_type stack_type, int priority,
- std::function<bool(const grpc_channel_args &)> include_filter) {
+ const char* name, grpc_channel_stack_type stack_type, int priority,
+ std::function<bool(const grpc_channel_args&)> include_filter) {
// If we haven't been called before, initialize channel_filters and
// call grpc_register_plugin().
if (internal::channel_filters == nullptr) {
diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc
index f34b0f3d58..eb6dc8cc5f 100644
--- a/src/cpp/common/completion_queue_cc.cc
+++ b/src/cpp/common/completion_queue_cc.cc
@@ -60,7 +60,7 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
case GRPC_QUEUE_SHUTDOWN:
return SHUTDOWN;
case GRPC_OP_COMPLETE:
- auto cq_tag = static_cast<CompletionQueueTag*>(ev.tag);
+ auto cq_tag = static_cast<internal::CompletionQueueTag*>(ev.tag);
*ok = ev.success != 0;
*tag = cq_tag;
if (cq_tag->FinalizeResult(tag, ok)) {
@@ -71,4 +71,29 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
}
}
+CompletionQueue::CompletionQueueTLSCache::CompletionQueueTLSCache(
+ CompletionQueue* cq)
+ : cq_(cq), flushed_(false) {
+ grpc_completion_queue_thread_local_cache_init(cq_->cq_);
+}
+
+CompletionQueue::CompletionQueueTLSCache::~CompletionQueueTLSCache() {
+ GPR_ASSERT(flushed_);
+}
+
+bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) {
+ int res = 0;
+ void* res_tag;
+ flushed_ = true;
+ if (grpc_completion_queue_thread_local_cache_flush(cq_->cq_, &res_tag,
+ &res)) {
+ auto cq_tag = static_cast<internal::CompletionQueueTag*>(res_tag);
+ *ok = res == 1;
+ if (cq_tag->FinalizeResult(tag, ok)) {
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace grpc
diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc
index 6ea5f1d3c7..936d6996b2 100644
--- a/src/cpp/common/core_codegen.cc
+++ b/src/cpp/common/core_codegen.cc
@@ -33,9 +33,7 @@
#include "src/core/lib/profiling/timers.h"
-extern "C" {
struct grpc_byte_buffer;
-}
namespace grpc {
@@ -76,6 +74,9 @@ void* CoreCodegen::gpr_malloc(size_t size) { return ::gpr_malloc(size); }
void CoreCodegen::gpr_free(void* p) { return ::gpr_free(p); }
+void CoreCodegen::grpc_init() { ::grpc_init(); }
+void CoreCodegen::grpc_shutdown() { ::grpc_shutdown(); }
+
void CoreCodegen::gpr_mu_init(gpr_mu* mu) { ::gpr_mu_init(mu); };
void CoreCodegen::gpr_mu_destroy(gpr_mu* mu) { ::gpr_mu_destroy(mu); }
void CoreCodegen::gpr_mu_lock(gpr_mu* mu) { ::gpr_mu_lock(mu); }
@@ -156,6 +157,10 @@ grpc_slice CoreCodegen::grpc_slice_split_head(grpc_slice* s, size_t split) {
return ::grpc_slice_split_head(s, split);
}
+grpc_slice CoreCodegen::grpc_slice_sub(grpc_slice s, size_t begin, size_t end) {
+ return ::grpc_slice_sub(s, begin, end);
+}
+
grpc_slice CoreCodegen::grpc_slice_from_static_buffer(const void* buffer,
size_t length) {
return ::grpc_slice_from_static_buffer(buffer, length);
diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc
index 2e9a51316d..8bc926048f 100644
--- a/src/cpp/common/version_cc.cc
+++ b/src/cpp/common/version_cc.cc
@@ -22,5 +22,5 @@
#include <grpc++/grpc++.h>
namespace grpc {
-grpc::string Version() { return "1.7.0-dev"; }
-}
+grpc::string Version() { return "1.10.0-dev"; }
+} // namespace grpc
diff --git a/src/cpp/ext/proto_server_reflection.cc b/src/cpp/ext/proto_server_reflection.cc
index ac08ce5c76..e6122115fe 100644
--- a/src/cpp/ext/proto_server_reflection.cc
+++ b/src/cpp/ext/proto_server_reflection.cc
@@ -25,14 +25,14 @@
using grpc::Status;
using grpc::StatusCode;
-using grpc::reflection::v1alpha::ServerReflectionRequest;
+using grpc::reflection::v1alpha::ErrorResponse;
+using grpc::reflection::v1alpha::ExtensionNumberResponse;
using grpc::reflection::v1alpha::ExtensionRequest;
-using grpc::reflection::v1alpha::ServerReflectionResponse;
+using grpc::reflection::v1alpha::FileDescriptorResponse;
using grpc::reflection::v1alpha::ListServiceResponse;
+using grpc::reflection::v1alpha::ServerReflectionRequest;
+using grpc::reflection::v1alpha::ServerReflectionResponse;
using grpc::reflection::v1alpha::ServiceResponse;
-using grpc::reflection::v1alpha::ExtensionNumberResponse;
-using grpc::reflection::v1alpha::ErrorResponse;
-using grpc::reflection::v1alpha::FileDescriptorResponse;
namespace grpc {
diff --git a/src/cpp/server/channel_argument_option.cc b/src/cpp/server/channel_argument_option.cc
index 0d3a0dc25b..dcad2531d5 100644
--- a/src/cpp/server/channel_argument_option.cc
+++ b/src/cpp/server/channel_argument_option.cc
@@ -21,17 +21,17 @@
namespace grpc {
std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
- const grpc::string &name, const grpc::string &value) {
+ const grpc::string& name, const grpc::string& value) {
class StringOption final : public ServerBuilderOption {
public:
- StringOption(const grpc::string &name, const grpc::string &value)
+ StringOption(const grpc::string& name, const grpc::string& value)
: name_(name), value_(value) {}
- virtual void UpdateArguments(ChannelArguments *args) override {
+ virtual void UpdateArguments(ChannelArguments* args) override {
args->SetString(name_, value_);
}
virtual void UpdatePlugins(
- std::vector<std::unique_ptr<ServerBuilderPlugin>> *plugins) override {}
+ std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) override {}
private:
const grpc::string name_;
@@ -41,17 +41,17 @@ std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
}
std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
- const grpc::string &name, int value) {
+ const grpc::string& name, int value) {
class IntOption final : public ServerBuilderOption {
public:
- IntOption(const grpc::string &name, int value)
+ IntOption(const grpc::string& name, int value)
: name_(name), value_(value) {}
- virtual void UpdateArguments(ChannelArguments *args) override {
+ virtual void UpdateArguments(ChannelArguments* args) override {
args->SetInt(name_, value_);
}
virtual void UpdatePlugins(
- std::vector<std::unique_ptr<ServerBuilderPlugin>> *plugins) override {}
+ std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) override {}
private:
const grpc::string name_;
diff --git a/src/cpp/server/health/default_health_check_service.cc b/src/cpp/server/health/default_health_check_service.cc
index d2cba6d662..10dbd3c39a 100644
--- a/src/cpp/server/health/default_health_check_service.cc
+++ b/src/cpp/server/health/default_health_check_service.cc
@@ -37,11 +37,12 @@ const char kHealthCheckMethodName[] = "/grpc.health.v1.Health/Check";
DefaultHealthCheckService::HealthCheckServiceImpl::HealthCheckServiceImpl(
DefaultHealthCheckService* service)
: service_(service), method_(nullptr) {
- MethodHandler* handler =
- new RpcMethodHandler<HealthCheckServiceImpl, ByteBuffer, ByteBuffer>(
+ internal::MethodHandler* handler =
+ new internal::RpcMethodHandler<HealthCheckServiceImpl, ByteBuffer,
+ ByteBuffer>(
std::mem_fn(&HealthCheckServiceImpl::Check), this);
- method_ = new RpcServiceMethod(kHealthCheckMethodName, RpcMethod::NORMAL_RPC,
- handler);
+ method_ = new internal::RpcServiceMethod(
+ kHealthCheckMethodName, internal::RpcMethod::NORMAL_RPC, handler);
AddMethod(method_);
}
diff --git a/src/cpp/server/health/default_health_check_service.h b/src/cpp/server/health/default_health_check_service.h
index 09d5cebe98..99d6680c50 100644
--- a/src/cpp/server/health/default_health_check_service.h
+++ b/src/cpp/server/health/default_health_check_service.h
@@ -41,7 +41,7 @@ class DefaultHealthCheckService final : public HealthCheckServiceInterface {
private:
const DefaultHealthCheckService* const service_;
- RpcServiceMethod* method_;
+ internal::RpcServiceMethod* method_;
};
DefaultHealthCheckService();
diff --git a/src/cpp/server/health/health_check_service.cc b/src/cpp/server/health/health_check_service.cc
index 14c83e73c9..a34b533bb2 100644
--- a/src/cpp/server/health/health_check_service.cc
+++ b/src/cpp/server/health/health_check_service.cc
@@ -21,7 +21,7 @@
namespace grpc {
namespace {
bool g_grpc_default_health_check_service_enabled = false;
-} // namesapce
+} // namespace
bool DefaultHealthCheckServiceEnabled() {
return g_grpc_default_health_check_service_enabled;
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 6bd3ecda32..4f8f4e06fc 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -76,7 +76,7 @@ class Server::UnimplementedAsyncRequest final
public:
UnimplementedAsyncRequest(Server* server, ServerCompletionQueue* cq)
: GenericAsyncRequest(server, &server_context_, &generic_stream_, cq, cq,
- NULL, false),
+ nullptr, false),
server_(server),
cq_(cq) {}
@@ -90,7 +90,8 @@ class Server::UnimplementedAsyncRequest final
ServerCompletionQueue* const cq_;
};
-typedef SneakyCallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus>
+typedef internal::SneakyCallOpSet<internal::CallOpSendInitialMetadata,
+ internal::CallOpServerSendStatus>
UnimplementedAsyncResponseOp;
class Server::UnimplementedAsyncResponse final
: public UnimplementedAsyncResponseOp {
@@ -108,12 +109,12 @@ class Server::UnimplementedAsyncResponse final
UnimplementedAsyncRequest* const request_;
};
-class ShutdownTag : public CompletionQueueTag {
+class ShutdownTag : public internal::CompletionQueueTag {
public:
bool FinalizeResult(void** tag, bool* status) { return false; }
};
-class DummyTag : public CompletionQueueTag {
+class DummyTag : public internal::CompletionQueueTag {
public:
bool FinalizeResult(void** tag, bool* status) {
*status = true;
@@ -121,15 +122,15 @@ class DummyTag : public CompletionQueueTag {
}
};
-class Server::SyncRequest final : public CompletionQueueTag {
+class Server::SyncRequest final : public internal::CompletionQueueTag {
public:
- SyncRequest(RpcServiceMethod* method, void* tag)
+ SyncRequest(internal::RpcServiceMethod* method, void* tag)
: method_(method),
tag_(tag),
in_flight_(false),
- has_request_payload_(method->method_type() == RpcMethod::NORMAL_RPC ||
- method->method_type() ==
- RpcMethod::SERVER_STREAMING),
+ has_request_payload_(
+ method->method_type() == internal::RpcMethod::NORMAL_RPC ||
+ method->method_type() == internal::RpcMethod::SERVER_STREAMING),
call_details_(nullptr),
cq_(nullptr) {
grpc_metadata_array_init(&request_metadata_);
@@ -212,14 +213,14 @@ class Server::SyncRequest final : public CompletionQueueTag {
void Run(std::shared_ptr<GlobalCallbacks> global_callbacks) {
ctx_.BeginCompletionOp(&call_);
global_callbacks->PreSynchronousRequest(&ctx_);
- method_->handler()->RunHandler(
- MethodHandler::HandlerParameter(&call_, &ctx_, request_payload_));
+ method_->handler()->RunHandler(internal::MethodHandler::HandlerParameter(
+ &call_, &ctx_, request_payload_));
global_callbacks->PostSynchronousRequest(&ctx_);
request_payload_ = nullptr;
cq_.Shutdown();
- CompletionQueueTag* op_tag = ctx_.GetCompletionOpTag();
+ internal::CompletionQueueTag* op_tag = ctx_.GetCompletionOpTag();
cq_.TryPluck(op_tag, gpr_inf_future(GPR_CLOCK_REALTIME));
/* Ensure the cq_ is shutdown */
@@ -229,15 +230,15 @@ class Server::SyncRequest final : public CompletionQueueTag {
private:
CompletionQueue cq_;
- Call call_;
+ internal::Call call_;
ServerContext ctx_;
const bool has_request_payload_;
grpc_byte_buffer* request_payload_;
- RpcServiceMethod* const method_;
+ internal::RpcServiceMethod* const method_;
};
private:
- RpcServiceMethod* const method_;
+ internal::RpcServiceMethod* const method_;
void* const tag_;
bool in_flight_;
const bool has_request_payload_;
@@ -266,8 +267,11 @@ class Server::SyncRequestThreadManager : public ThreadManager {
WorkStatus PollForWork(void** tag, bool* ok) override {
*tag = nullptr;
+ // TODO(ctiller): workaround for GPR_TIMESPAN based deadlines not working
+ // right now
gpr_timespec deadline =
- gpr_time_from_millis(cq_timeout_msec_, GPR_TIMESPAN);
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_millis(cq_timeout_msec_, GPR_TIMESPAN));
switch (server_cq_->AsyncNext(tag, ok, deadline)) {
case CompletionQueue::TIMEOUT:
@@ -308,14 +312,15 @@ class Server::SyncRequestThreadManager : public ThreadManager {
// object
}
- void AddSyncMethod(RpcServiceMethod* method, void* tag) {
+ void AddSyncMethod(internal::RpcServiceMethod* method, void* tag) {
sync_requests_.emplace_back(new SyncRequest(method, tag));
}
void AddUnknownSyncMethod() {
if (!sync_requests_.empty()) {
- unknown_method_.reset(new RpcServiceMethod(
- "unknown", RpcMethod::BIDI_STREAMING, new UnknownMethodHandler));
+ unknown_method_.reset(new internal::RpcServiceMethod(
+ "unknown", internal::RpcMethod::BIDI_STREAMING,
+ new internal::UnknownMethodHandler));
sync_requests_.emplace_back(
new SyncRequest(unknown_method_.get(), nullptr));
}
@@ -352,8 +357,8 @@ class Server::SyncRequestThreadManager : public ThreadManager {
CompletionQueue* server_cq_;
int cq_timeout_msec_;
std::vector<std::unique_ptr<SyncRequest>> sync_requests_;
- std::unique_ptr<RpcServiceMethod> unknown_method_;
- std::unique_ptr<RpcServiceMethod> health_check_;
+ std::unique_ptr<internal::RpcServiceMethod> unknown_method_;
+ std::unique_ptr<internal::RpcServiceMethod> health_check_;
std::shared_ptr<Server::GlobalCallbacks> global_callbacks_;
};
@@ -436,13 +441,13 @@ std::shared_ptr<Channel> Server::InProcessChannel(
}
static grpc_server_register_method_payload_handling PayloadHandlingForMethod(
- RpcServiceMethod* method) {
+ internal::RpcServiceMethod* method) {
switch (method->method_type()) {
- case RpcMethod::NORMAL_RPC:
- case RpcMethod::SERVER_STREAMING:
+ case internal::RpcMethod::NORMAL_RPC:
+ case internal::RpcMethod::SERVER_STREAMING:
return GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER;
- case RpcMethod::CLIENT_STREAMING:
- case RpcMethod::BIDI_STREAMING:
+ case internal::RpcMethod::CLIENT_STREAMING:
+ case internal::RpcMethod::BIDI_STREAMING:
return GRPC_SRM_PAYLOAD_NONE;
}
GPR_UNREACHABLE_CODE(return GRPC_SRM_PAYLOAD_NONE;);
@@ -463,7 +468,7 @@ bool Server::RegisterService(const grpc::string* host, Service* service) {
continue;
}
- RpcServiceMethod* method = it->get();
+ internal::RpcServiceMethod* method = it->get();
void* tag = grpc_server_register_method(
server_, method->name(), host ? host->c_str() : nullptr,
PayloadHandlingForMethod(method), 0);
@@ -603,7 +608,8 @@ void Server::Wait() {
}
}
-void Server::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) {
+void Server::PerformOpsOnCall(internal::CallOpSetInterface* ops,
+ internal::Call* call) {
static const size_t MAX_OPS = 8;
size_t nops = 0;
grpc_op cops[MAX_OPS];
@@ -619,8 +625,8 @@ void Server::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) {
ServerInterface::BaseAsyncRequest::BaseAsyncRequest(
ServerInterface* server, ServerContext* context,
- ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag,
- bool delete_on_finalize)
+ internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
+ void* tag, bool delete_on_finalize)
: server_(server),
context_(context),
stream_(stream),
@@ -642,7 +648,8 @@ bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag,
}
context_->set_call(call_);
context_->cq_ = call_cq_;
- Call call(call_, server_, call_cq_, server_->max_receive_message_size());
+ internal::Call call(call_, server_, call_cq_,
+ server_->max_receive_message_size());
if (*status && call_) {
context_->BeginCompletionOp(&call);
}
@@ -657,7 +664,8 @@ bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag,
ServerInterface::RegisteredAsyncRequest::RegisteredAsyncRequest(
ServerInterface* server, ServerContext* context,
- ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, void* tag)
+ internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
+ void* tag)
: BaseAsyncRequest(server, context, stream, call_cq, tag, true) {}
void ServerInterface::RegisteredAsyncRequest::IssueRequest(
@@ -672,7 +680,7 @@ void ServerInterface::RegisteredAsyncRequest::IssueRequest(
ServerInterface::GenericAsyncRequest::GenericAsyncRequest(
ServerInterface* server, GenericServerContext* context,
- ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
+ internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag, bool delete_on_finalize)
: BaseAsyncRequest(server, context, stream, call_cq, tag,
delete_on_finalize) {
@@ -715,7 +723,7 @@ Server::UnimplementedAsyncResponse::UnimplementedAsyncResponse(
UnimplementedAsyncRequest* request)
: request_(request) {
Status status(StatusCode::UNIMPLEMENTED, "");
- UnknownMethodHandler::FillOps(request_->context(), this);
+ internal::UnknownMethodHandler::FillOps(request_->context(), this);
request_->stream()->call_.PerformOps(this);
}
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index d7876a000b..f0cbbdb86d 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -37,7 +37,7 @@ namespace grpc {
// CompletionOp
-class ServerContext::CompletionOp final : public CallOpSetInterface {
+class ServerContext::CompletionOp final : public internal::CallOpSetInterface {
public:
// initial refs: one in the server context, one in the cq
CompletionOp()
@@ -90,7 +90,7 @@ void ServerContext::CompletionOp::FillOps(grpc_call* call, grpc_op* ops,
ops->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
ops->data.recv_close_on_server.cancelled = &cancelled_;
ops->flags = 0;
- ops->reserved = NULL;
+ ops->reserved = nullptr;
*nops = 1;
}
@@ -146,7 +146,7 @@ ServerContext::~ServerContext() {
}
}
-void ServerContext::BeginCompletionOp(Call* call) {
+void ServerContext::BeginCompletionOp(internal::Call* call) {
GPR_ASSERT(!completion_op_);
completion_op_ = new CompletionOp();
if (has_notify_when_done_tag_) {
@@ -155,8 +155,8 @@ void ServerContext::BeginCompletionOp(Call* call) {
call->PerformOps(completion_op_);
}
-CompletionQueueTag* ServerContext::GetCompletionOpTag() {
- return static_cast<CompletionQueueTag*>(completion_op_);
+internal::CompletionQueueTag* ServerContext::GetCompletionOpTag() {
+ return static_cast<internal::CompletionQueueTag*>(completion_op_);
}
void ServerContext::AddInitialMetadata(const grpc::string& key,
@@ -171,7 +171,7 @@ void ServerContext::AddTrailingMetadata(const grpc::string& key,
void ServerContext::TryCancel() const {
grpc_call_error err = grpc_call_cancel_with_status(
- call_, GRPC_STATUS_CANCELLED, "Cancelled on the server side", NULL);
+ call_, GRPC_STATUS_CANCELLED, "Cancelled on the server side", nullptr);
if (err != GRPC_CALL_OK) {
gpr_log(GPR_ERROR, "TryCancel failed with: %d", err);
}
@@ -190,13 +190,13 @@ bool ServerContext::IsCancelled() const {
void ServerContext::set_compression_algorithm(
grpc_compression_algorithm algorithm) {
- const char* algorithm_name = NULL;
+ const char* algorithm_name = nullptr;
if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) {
gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.",
algorithm);
abort();
}
- GPR_ASSERT(algorithm_name != NULL);
+ GPR_ASSERT(algorithm_name != nullptr);
AddInitialMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name);
}
diff --git a/src/cpp/server/server_posix.cc b/src/cpp/server/server_posix.cc
index a3c58f777b..d3ef5cb650 100644
--- a/src/cpp/server/server_posix.cc
+++ b/src/cpp/server/server_posix.cc
@@ -25,7 +25,7 @@ namespace grpc {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
void AddInsecureChannelFromFd(Server* server, int fd) {
- grpc_server_add_insecure_channel_from_fd(server->c_server(), NULL, fd);
+ grpc_server_add_insecure_channel_from_fd(server->c_server(), nullptr, fd);
}
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
diff --git a/src/cpp/util/core_stats.h b/src/cpp/util/core_stats.h
index 00e38bf266..6366d7d06e 100644
--- a/src/cpp/util/core_stats.h
+++ b/src/cpp/util/core_stats.h
@@ -21,9 +21,7 @@
#include "src/proto/grpc/core/stats.pb.h"
-extern "C" {
#include "src/core/lib/debug/stats.h"
-}
namespace grpc {
diff --git a/src/cpp/util/error_details.cc b/src/cpp/util/error_details.cc
index 44bc4d1648..f06b475683 100644
--- a/src/cpp/util/error_details.cc
+++ b/src/cpp/util/error_details.cc
@@ -37,7 +37,8 @@ Status SetErrorDetails(const ::google::rpc::Status& from, Status* to) {
return Status(StatusCode::FAILED_PRECONDITION, "");
}
StatusCode code = StatusCode::UNKNOWN;
- if (from.code() >= StatusCode::OK && from.code() <= StatusCode::DATA_LOSS) {
+ if (from.code() >= StatusCode::OK &&
+ from.code() <= StatusCode::UNAUTHENTICATED) {
code = static_cast<StatusCode>(from.code());
}
*to = Status(code, from.message(), from.SerializeAsString());
diff --git a/src/cpp/util/time_cc.cc b/src/cpp/util/time_cc.cc
index 1c658b0c15..3b6e075929 100644
--- a/src/cpp/util/time_cc.cc
+++ b/src/cpp/util/time_cc.cc
@@ -21,10 +21,10 @@
#include <grpc/support/time.h>
using std::chrono::duration_cast;
+using std::chrono::high_resolution_clock;
using std::chrono::nanoseconds;
using std::chrono::seconds;
using std::chrono::system_clock;
-using std::chrono::high_resolution_clock;
namespace grpc {
diff --git a/src/csharp/Grpc.Auth/Grpc.Auth.csproj b/src/csharp/Grpc.Auth/Grpc.Auth.csproj
index bbcbd95be5..5bbff38948 100755
--- a/src/csharp/Grpc.Auth/Grpc.Auth.csproj
+++ b/src/csharp/Grpc.Auth/Grpc.Auth.csproj
@@ -15,12 +15,12 @@
<PackageTags>gRPC RPC Protocol HTTP/2 Auth OAuth2</PackageTags>
<PackageProjectUrl>https://github.com/grpc/grpc</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</PackageLicenseUrl>
- <IncludeSymbols>true</IncludeSymbols>
- <IncludeSource>true</IncludeSource>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
+ <Import Project="..\Grpc.Core\SourceLink.csproj.include" />
+
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs" />
</ItemGroup>
diff --git a/src/csharp/Grpc.Core.Testing/Grpc.Core.Testing.csproj b/src/csharp/Grpc.Core.Testing/Grpc.Core.Testing.csproj
index 4d6767fa98..40840d4da3 100755
--- a/src/csharp/Grpc.Core.Testing/Grpc.Core.Testing.csproj
+++ b/src/csharp/Grpc.Core.Testing/Grpc.Core.Testing.csproj
@@ -15,12 +15,12 @@
<PackageTags>gRPC test testing</PackageTags>
<PackageProjectUrl>https://github.com/grpc/grpc</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</PackageLicenseUrl>
- <IncludeSymbols>true</IncludeSymbols>
- <IncludeSource>true</IncludeSource>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
+ <Import Project="..\Grpc.Core\SourceLink.csproj.include" />
+
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs" />
</ItemGroup>
diff --git a/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs b/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs
new file mode 100644
index 0000000000..e040f52380
--- /dev/null
+++ b/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs
@@ -0,0 +1,182 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Grpc.Core.Internal;
+using Grpc.Core.Profiling;
+using Grpc.Core.Utils;
+using NUnit.Framework;
+
+namespace Grpc.Core.Tests
+{
+ public class CallCancellationTest
+ {
+ const string Host = "127.0.0.1";
+
+ MockServiceHelper helper;
+ Server server;
+ Channel channel;
+
+ [SetUp]
+ public void Init()
+ {
+ helper = new MockServiceHelper(Host);
+ server = helper.GetServer();
+ server.Start();
+ channel = helper.GetChannel();
+ }
+
+ [TearDown]
+ public void Cleanup()
+ {
+ channel.ShutdownAsync().Wait();
+ server.ShutdownAsync().Wait();
+ }
+
+ [Test]
+ public async Task ClientStreamingCall_CancelAfterBegin()
+ {
+ var barrier = new TaskCompletionSource<object>();
+
+ helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
+ {
+ barrier.SetResult(null);
+ await requestStream.ToListAsync();
+ return "";
+ });
+
+ var cts = new CancellationTokenSource();
+ var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
+
+ await barrier.Task; // make sure the handler has started.
+ cts.Cancel();
+
+ try
+ {
+ // cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
+ await call.ResponseAsync;
+ Assert.Fail();
+ }
+ catch (RpcException ex)
+ {
+ Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
+ }
+ }
+
+ [Test]
+ public async Task ClientStreamingCall_ServerSideReadAfterCancelNotificationReturnsNull()
+ {
+ var handlerStartedBarrier = new TaskCompletionSource<object>();
+ var cancelNotificationReceivedBarrier = new TaskCompletionSource<object>();
+ var successTcs = new TaskCompletionSource<string>();
+
+ helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
+ {
+ handlerStartedBarrier.SetResult(null);
+
+ // wait for cancellation to be delivered.
+ context.CancellationToken.Register(() => cancelNotificationReceivedBarrier.SetResult(null));
+ await cancelNotificationReceivedBarrier.Task;
+
+ var moveNextResult = await requestStream.MoveNext();
+ successTcs.SetResult(!moveNextResult ? "SUCCESS" : "FAIL");
+ return "";
+ });
+
+ var cts = new CancellationTokenSource();
+ var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
+
+ await handlerStartedBarrier.Task;
+ cts.Cancel();
+
+ try
+ {
+ await call.ResponseAsync;
+ Assert.Fail();
+ }
+ catch (RpcException ex)
+ {
+ Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
+ }
+ Assert.AreEqual("SUCCESS", await successTcs.Task);
+ }
+
+ [Test]
+ public async Task ClientStreamingCall_CancelServerSideRead()
+ {
+ helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
+ {
+ var cts = new CancellationTokenSource();
+ var moveNextTask = requestStream.MoveNext(cts.Token);
+ cts.Cancel();
+ await moveNextTask;
+ return "";
+ });
+
+ var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall());
+ try
+ {
+ // cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
+ await call.ResponseAsync;
+ Assert.Fail();
+ }
+ catch (RpcException ex)
+ {
+ Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
+ }
+ }
+
+ [Test]
+ public async Task ServerStreamingCall_CancelClientSideRead()
+ {
+ helper.ServerStreamingHandler = new ServerStreamingServerMethod<string, string>(async (request, responseStream, context) =>
+ {
+ await responseStream.WriteAsync("abc");
+ while (!context.CancellationToken.IsCancellationRequested)
+ {
+ await Task.Delay(10);
+ }
+ });
+
+ var call = Calls.AsyncServerStreamingCall(helper.CreateServerStreamingCall(), "");
+ await call.ResponseStream.MoveNext();
+ Assert.AreEqual("abc", call.ResponseStream.Current);
+
+ var cts = new CancellationTokenSource();
+ var moveNextTask = call.ResponseStream.MoveNext(cts.Token);
+ cts.Cancel();
+
+ try
+ {
+ // cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
+ await moveNextTask;
+ Assert.Fail();
+ }
+ catch (RpcException ex)
+ {
+ Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
+ }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Core.Tests/ChannelConnectivityTest.cs b/src/csharp/Grpc.Core.Tests/ChannelConnectivityTest.cs
new file mode 100644
index 0000000000..a43040f01a
--- /dev/null
+++ b/src/csharp/Grpc.Core.Tests/ChannelConnectivityTest.cs
@@ -0,0 +1,86 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Grpc.Core.Internal;
+using Grpc.Core.Profiling;
+using Grpc.Core.Utils;
+using NUnit.Framework;
+
+namespace Grpc.Core.Tests
+{
+ public class ChannelConnectivityTest
+ {
+ const string Host = "127.0.0.1";
+
+ MockServiceHelper helper;
+ Server server;
+ Channel channel;
+
+ [SetUp]
+ public void Init()
+ {
+ helper = new MockServiceHelper(Host);
+ server = helper.GetServer();
+ server.Start();
+ channel = helper.GetChannel();
+ }
+
+ [TearDown]
+ public void Cleanup()
+ {
+ channel.ShutdownAsync().Wait();
+ server.ShutdownAsync().Wait();
+ }
+
+ [Test]
+ public async Task Channel_WaitForStateChangedAsync()
+ {
+ helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
+ {
+ return Task.FromResult(request);
+ });
+
+ Assert.ThrowsAsync(typeof(TaskCanceledException),
+ async () => await channel.WaitForStateChangedAsync(channel.State, DateTime.UtcNow.AddMilliseconds(10)));
+
+ var stateChangedTask = channel.WaitForStateChangedAsync(channel.State);
+
+ await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc");
+
+ await stateChangedTask;
+ Assert.AreEqual(ChannelState.Ready, channel.State);
+ }
+
+ [Test]
+ public async Task Channel_ConnectAsync()
+ {
+ await channel.ConnectAsync();
+ Assert.AreEqual(ChannelState.Ready, channel.State);
+
+ await channel.ConnectAsync(DateTime.UtcNow.AddMilliseconds(1000));
+ Assert.AreEqual(ChannelState.Ready, channel.State);
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
index 72d9035a6f..331c3321e1 100644
--- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
@@ -273,74 +273,6 @@ namespace Grpc.Core.Tests
}
[Test]
- public async Task ClientStreamingCall_CancelAfterBegin()
- {
- var barrier = new TaskCompletionSource<object>();
-
- helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
- {
- barrier.SetResult(null);
- await requestStream.ToListAsync();
- return "";
- });
-
- var cts = new CancellationTokenSource();
- var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
-
- await barrier.Task; // make sure the handler has started.
- cts.Cancel();
-
- try
- {
- // cannot use Assert.ThrowsAsync because it uses Task.Wait and would deadlock.
- await call.ResponseAsync;
- Assert.Fail();
- }
- catch (RpcException ex)
- {
- Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
- }
- }
-
- [Test]
- public async Task ClientStreamingCall_ServerSideReadAfterCancelNotificationReturnsNull()
- {
- var handlerStartedBarrier = new TaskCompletionSource<object>();
- var cancelNotificationReceivedBarrier = new TaskCompletionSource<object>();
- var successTcs = new TaskCompletionSource<string>();
-
- helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
- {
- handlerStartedBarrier.SetResult(null);
-
- // wait for cancellation to be delivered.
- context.CancellationToken.Register(() => cancelNotificationReceivedBarrier.SetResult(null));
- await cancelNotificationReceivedBarrier.Task;
-
- var moveNextResult = await requestStream.MoveNext();
- successTcs.SetResult(!moveNextResult ? "SUCCESS" : "FAIL");
- return "";
- });
-
- var cts = new CancellationTokenSource();
- var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
-
- await handlerStartedBarrier.Task;
- cts.Cancel();
-
- try
- {
- await call.ResponseAsync;
- Assert.Fail();
- }
- catch (RpcException ex)
- {
- Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
- }
- Assert.AreEqual("SUCCESS", await successTcs.Task);
- }
-
- [Test]
public async Task AsyncUnaryCall_EchoMetadata()
{
helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
@@ -441,34 +373,5 @@ namespace Grpc.Core.Tests
});
Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "abc"));
}
-
- [Test]
- public async Task Channel_WaitForStateChangedAsync()
- {
- helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) =>
- {
- return Task.FromResult(request);
- });
-
- Assert.ThrowsAsync(typeof(TaskCanceledException),
- async () => await channel.WaitForStateChangedAsync(channel.State, DateTime.UtcNow.AddMilliseconds(10)));
-
- var stateChangedTask = channel.WaitForStateChangedAsync(channel.State);
-
- await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc");
-
- await stateChangedTask;
- Assert.AreEqual(ChannelState.Ready, channel.State);
- }
-
- [Test]
- public async Task Channel_ConnectAsync()
- {
- await channel.ConnectAsync();
- Assert.AreEqual(ChannelState.Ready, channel.State);
-
- await channel.ConnectAsync(DateTime.UtcNow.AddMilliseconds(1000));
- Assert.AreEqual(ChannelState.Ready, channel.State);
- }
}
}
diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs
index 9488ce29e9..e7d8939978 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs
@@ -64,7 +64,7 @@ namespace Grpc.Core.Internal.Tests
public void CancelNotificationAfterStartDisposes()
{
var finishedTask = asyncCallServer.ServerSideCallAsync();
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
AssertFinished(asyncCallServer, fakeCall, finishedTask);
}
@@ -76,8 +76,8 @@ namespace Grpc.Core.Internal.Tests
var moveNextTask = requestStream.MoveNext();
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
- fakeCall.ReceivedMessageHandler(true, null);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
Assert.IsFalse(moveNextTask.Result);
AssertFinished(asyncCallServer, fakeCall, finishedTask);
@@ -89,7 +89,7 @@ namespace Grpc.Core.Internal.Tests
var finishedTask = asyncCallServer.ServerSideCallAsync();
var requestStream = new ServerRequestStream<string, string>(asyncCallServer);
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
// Check that starting a read after cancel notification has been processed is legal.
var moveNextTask = requestStream.MoveNext();
@@ -107,10 +107,10 @@ namespace Grpc.Core.Internal.Tests
// if a read completion's success==false, the request stream will silently finish
// and we rely on C core cancelling the call.
var moveNextTask = requestStream.MoveNext();
- fakeCall.ReceivedMessageHandler(false, null);
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(false, null);
Assert.IsFalse(moveNextTask.Result);
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
AssertFinished(asyncCallServer, fakeCall, finishedTask);
}
@@ -120,7 +120,7 @@ namespace Grpc.Core.Internal.Tests
var finishedTask = asyncCallServer.ServerSideCallAsync();
var responseStream = new ServerResponseStream<string, string>(asyncCallServer);
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
// TODO(jtattermusch): should we throw a different exception type instead?
Assert.Throws(typeof(InvalidOperationException), () => responseStream.WriteAsync("request1"));
@@ -134,10 +134,10 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ServerResponseStream<string, string>(asyncCallServer);
var writeTask = responseStream.WriteAsync("request1");
- fakeCall.SendCompletionHandler(false);
+ fakeCall.SendCompletionCallback.OnSendCompletion(false);
Assert.ThrowsAsync(typeof(IOException), async () => await writeTask);
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
AssertFinished(asyncCallServer, fakeCall, finishedTask);
}
@@ -150,13 +150,13 @@ namespace Grpc.Core.Internal.Tests
var writeTask = responseStream.WriteAsync("request1");
var writeStatusTask = asyncCallServer.SendStatusFromServerAsync(Status.DefaultSuccess, new Metadata(), null);
- fakeCall.SendCompletionHandler(true);
- fakeCall.SendStatusFromServerHandler(true);
+ fakeCall.SendCompletionCallback.OnSendCompletion(true);
+ fakeCall.SendStatusFromServerCallback.OnSendStatusFromServerCompletion(true);
Assert.DoesNotThrowAsync(async () => await writeTask);
Assert.DoesNotThrowAsync(async () => await writeStatusTask);
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
AssertFinished(asyncCallServer, fakeCall, finishedTask);
}
@@ -170,8 +170,8 @@ namespace Grpc.Core.Internal.Tests
asyncCallServer.SendStatusFromServerAsync(Status.DefaultSuccess, new Metadata(), null);
Assert.ThrowsAsync(typeof(InvalidOperationException), async () => await responseStream.WriteAsync("request1"));
- fakeCall.SendStatusFromServerHandler(true);
- fakeCall.ReceivedCloseOnServerHandler(true, cancelled: true);
+ fakeCall.SendStatusFromServerCallback.OnSendStatusFromServerCompletion(true);
+ fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true);
AssertFinished(asyncCallServer, fakeCall, finishedTask);
}
diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
index b2b49f3a48..9aab54d2d0 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
@@ -73,7 +73,7 @@ namespace Grpc.Core.Internal.Tests
public void AsyncUnary_Success()
{
var resultTask = asyncCall.UnaryCallAsync("request1");
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -85,7 +85,7 @@ namespace Grpc.Core.Internal.Tests
public void AsyncUnary_NonSuccessStatusCode()
{
var resultTask = asyncCall.UnaryCallAsync("request1");
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
CreateClientSideStatus(StatusCode.InvalidArgument),
null,
new Metadata());
@@ -97,7 +97,7 @@ namespace Grpc.Core.Internal.Tests
public void AsyncUnary_NullResponsePayload()
{
var resultTask = asyncCall.UnaryCallAsync("request1");
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
null,
new Metadata());
@@ -118,7 +118,7 @@ namespace Grpc.Core.Internal.Tests
public void ClientStreaming_NoRequest_Success()
{
var resultTask = asyncCall.ClientStreamingCallAsync();
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -130,7 +130,7 @@ namespace Grpc.Core.Internal.Tests
public void ClientStreaming_NoRequest_NonSuccessStatusCode()
{
var resultTask = asyncCall.ClientStreamingCallAsync();
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
CreateClientSideStatus(StatusCode.InvalidArgument),
null,
new Metadata());
@@ -145,18 +145,18 @@ namespace Grpc.Core.Internal.Tests
var requestStream = new ClientRequestStream<string, string>(asyncCall);
var writeTask = requestStream.WriteAsync("request1");
- fakeCall.SendCompletionHandler(true);
+ fakeCall.SendCompletionCallback.OnSendCompletion(true);
writeTask.Wait();
var writeTask2 = requestStream.WriteAsync("request2");
- fakeCall.SendCompletionHandler(true);
+ fakeCall.SendCompletionCallback.OnSendCompletion(true);
writeTask2.Wait();
var completeTask = requestStream.CompleteAsync();
- fakeCall.SendCompletionHandler(true);
+ fakeCall.SendCompletionCallback.OnSendCompletion(true);
completeTask.Wait();
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -171,12 +171,12 @@ namespace Grpc.Core.Internal.Tests
var requestStream = new ClientRequestStream<string, string>(asyncCall);
var writeTask = requestStream.WriteAsync("request1");
- fakeCall.SendCompletionHandler(false);
+ fakeCall.SendCompletionCallback.OnSendCompletion(false);
// The write will wait for call to finish to receive the status code.
Assert.IsFalse(writeTask.IsCompleted);
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
CreateClientSideStatus(StatusCode.Internal),
null,
new Metadata());
@@ -195,12 +195,12 @@ namespace Grpc.Core.Internal.Tests
var writeTask = requestStream.WriteAsync("request1");
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
CreateClientSideStatus(StatusCode.Internal),
null,
new Metadata());
- fakeCall.SendCompletionHandler(false);
+ fakeCall.SendCompletionCallback.OnSendCompletion(false);
var ex = Assert.ThrowsAsync<RpcException>(async () => await writeTask);
Assert.AreEqual(StatusCode.Internal, ex.Status.StatusCode);
@@ -215,13 +215,13 @@ namespace Grpc.Core.Internal.Tests
var requestStream = new ClientRequestStream<string, string>(asyncCall);
var writeTask = requestStream.WriteAsync("request1");
- fakeCall.SendCompletionHandler(false);
+ fakeCall.SendCompletionCallback.OnSendCompletion(false);
// Until the delayed write completion has been triggered,
// we still act as if there was an active write.
Assert.Throws(typeof(InvalidOperationException), () => requestStream.WriteAsync("request2"));
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
CreateClientSideStatus(StatusCode.Internal),
null,
new Metadata());
@@ -242,7 +242,7 @@ namespace Grpc.Core.Internal.Tests
var resultTask = asyncCall.ClientStreamingCallAsync();
var requestStream = new ClientRequestStream<string, string>(asyncCall);
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -260,7 +260,7 @@ namespace Grpc.Core.Internal.Tests
var resultTask = asyncCall.ClientStreamingCallAsync();
var requestStream = new ClientRequestStream<string, string>(asyncCall);
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(new Status(StatusCode.OutOfRange, ""), new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -282,9 +282,9 @@ namespace Grpc.Core.Internal.Tests
Assert.Throws(typeof(InvalidOperationException), () => requestStream.WriteAsync("request1"));
- fakeCall.SendCompletionHandler(true);
+ fakeCall.SendCompletionCallback.OnSendCompletion(true);
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -298,7 +298,7 @@ namespace Grpc.Core.Internal.Tests
var resultTask = asyncCall.ClientStreamingCallAsync();
var requestStream = new ClientRequestStream<string, string>(asyncCall);
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
new ClientSideStatus(Status.DefaultSuccess, new Metadata()),
CreateResponsePayload(),
new Metadata());
@@ -319,7 +319,7 @@ namespace Grpc.Core.Internal.Tests
var writeTask = requestStream.WriteAsync("request1");
Assert.ThrowsAsync(typeof(TaskCanceledException), async () => await writeTask);
- fakeCall.UnaryResponseClientHandler(true,
+ fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true,
CreateClientSideStatus(StatusCode.Cancelled),
null,
new Metadata());
@@ -342,11 +342,11 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedResponseHeadersHandler(true, new Metadata());
+ fakeCall.ReceivedResponseHeadersCallback.OnReceivedResponseHeaders(true, new Metadata());
Assert.AreEqual(0, asyncCall.ResponseHeadersAsync.Result.Count);
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask);
}
@@ -359,8 +359,8 @@ namespace Grpc.Core.Internal.Tests
var readTask = responseStream.MoveNext();
// try alternative order of completions
- fakeCall.ReceivedStatusOnClientHandler(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
- fakeCall.ReceivedMessageHandler(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask);
}
@@ -372,8 +372,8 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(false, null); // after a failed read, we rely on C core to deliver appropriate status code.
- fakeCall.ReceivedStatusOnClientHandler(true, CreateClientSideStatus(StatusCode.Internal));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(false, null); // after a failed read, we rely on C core to deliver appropriate status code.
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Internal));
AssertStreamingResponseError(asyncCall, fakeCall, readTask, StatusCode.Internal);
}
@@ -385,18 +385,18 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var readTask1 = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, CreateResponsePayload());
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateResponsePayload());
Assert.IsTrue(readTask1.Result);
Assert.AreEqual("response1", responseStream.Current);
var readTask2 = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, CreateResponsePayload());
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateResponsePayload());
Assert.IsTrue(readTask2.Result);
Assert.AreEqual("response1", responseStream.Current);
var readTask3 = responseStream.MoveNext();
- fakeCall.ReceivedStatusOnClientHandler(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
- fakeCall.ReceivedMessageHandler(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask3);
}
@@ -409,12 +409,12 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var writeTask1 = requestStream.CompleteAsync();
- fakeCall.SendCompletionHandler(true);
+ fakeCall.SendCompletionCallback.OnSendCompletion(true);
Assert.DoesNotThrowAsync(async () => await writeTask1);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask);
}
@@ -427,8 +427,8 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask);
@@ -445,8 +445,8 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata()));
AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask);
@@ -461,14 +461,14 @@ namespace Grpc.Core.Internal.Tests
var responseStream = new ClientResponseStream<string, string>(asyncCall);
var writeTask = requestStream.WriteAsync("request1");
- fakeCall.SendCompletionHandler(false);
+ fakeCall.SendCompletionCallback.OnSendCompletion(false);
// The write will wait for call to finish to receive the status code.
Assert.IsFalse(writeTask.IsCompleted);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, CreateClientSideStatus(StatusCode.PermissionDenied));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.PermissionDenied));
var ex = Assert.ThrowsAsync<RpcException>(async () => await writeTask);
Assert.AreEqual(StatusCode.PermissionDenied, ex.Status.StatusCode);
@@ -486,9 +486,9 @@ namespace Grpc.Core.Internal.Tests
var writeTask = requestStream.WriteAsync("request1");
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, CreateClientSideStatus(StatusCode.PermissionDenied));
- fakeCall.SendCompletionHandler(false);
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.PermissionDenied));
+ fakeCall.SendCompletionCallback.OnSendCompletion(false);
var ex = Assert.ThrowsAsync<RpcException>(async () => await writeTask);
Assert.AreEqual(StatusCode.PermissionDenied, ex.Status.StatusCode);
@@ -510,8 +510,8 @@ namespace Grpc.Core.Internal.Tests
Assert.ThrowsAsync(typeof(TaskCanceledException), async () => await writeTask);
var readTask = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, CreateClientSideStatus(StatusCode.Cancelled));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Cancelled));
AssertStreamingResponseError(asyncCall, fakeCall, readTask, StatusCode.Cancelled);
}
@@ -526,13 +526,13 @@ namespace Grpc.Core.Internal.Tests
Assert.IsTrue(fakeCall.IsCancelled);
var readTask1 = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, CreateResponsePayload());
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateResponsePayload());
Assert.IsTrue(readTask1.Result);
Assert.AreEqual("response1", responseStream.Current);
var readTask2 = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, CreateClientSideStatus(StatusCode.Cancelled));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Cancelled));
AssertStreamingResponseError(asyncCall, fakeCall, readTask2, StatusCode.Cancelled);
}
@@ -547,13 +547,13 @@ namespace Grpc.Core.Internal.Tests
asyncCall.Cancel();
Assert.IsTrue(fakeCall.IsCancelled);
- fakeCall.ReceivedMessageHandler(true, CreateResponsePayload());
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateResponsePayload());
Assert.IsTrue(readTask1.Result);
Assert.AreEqual("response1", responseStream.Current);
var readTask2 = responseStream.MoveNext();
- fakeCall.ReceivedMessageHandler(true, null);
- fakeCall.ReceivedStatusOnClientHandler(true, CreateClientSideStatus(StatusCode.Cancelled));
+ fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null);
+ fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Cancelled));
AssertStreamingResponseError(asyncCall, fakeCall, readTask2, StatusCode.Cancelled);
}
diff --git a/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs
index 1d9475a8b8..7e4e2975c1 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs
@@ -40,7 +40,7 @@ namespace Grpc.Core.Internal.Tests
public void CreateAsyncAndShutdown()
{
var env = GrpcEnvironment.AddRef();
- var cq = CompletionQueueSafeHandle.CreateAsync(new CompletionRegistry(env));
+ var cq = CompletionQueueSafeHandle.CreateAsync(new CompletionRegistry(env, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()));
cq.Shutdown();
var ev = cq.Next();
cq.Dispose();
diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultObjectPoolTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultObjectPoolTest.cs
new file mode 100644
index 0000000000..9c6f8a2117
--- /dev/null
+++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultObjectPoolTest.cs
@@ -0,0 +1,95 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using Grpc.Core;
+using Grpc.Core.Internal;
+using Grpc.Core.Utils;
+using NUnit.Framework;
+
+namespace Grpc.Core.Internal.Tests
+{
+ public class DefaultObjectPoolTest
+ {
+ [Test]
+ [TestCase(10, 2)]
+ [TestCase(10, 1)]
+ [TestCase(0, 2)]
+ [TestCase(2, 0)]
+ public void ObjectIsReused(int sharedCapacity, int threadLocalCapacity)
+ {
+ var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), sharedCapacity, threadLocalCapacity);
+ var origLeased = pool.Lease();
+ pool.Return(origLeased);
+ Assert.AreSame(origLeased, pool.Lease());
+ Assert.AreNotSame(origLeased, pool.Lease());
+ }
+
+ [Test]
+ public void ZeroCapacities()
+ {
+ var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 0, 0);
+ var origLeased = pool.Lease();
+ pool.Return(origLeased);
+ Assert.AreNotSame(origLeased, pool.Lease());
+ }
+
+ [Test]
+ public void DisposeCleansSharedPool()
+ {
+ var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 10, 0);
+ var origLeased = pool.Lease();
+ pool.Return(origLeased);
+ pool.Dispose();
+ Assert.AreNotSame(origLeased, pool.Lease());
+ }
+
+ [Test]
+ public void LeaseSetsReturnAction()
+ {
+ var pool = new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 10, 0);
+ var origLeased = pool.Lease();
+ origLeased.ReturnAction(origLeased);
+ pool.Dispose();
+ Assert.AreNotSame(origLeased, pool.Lease());
+ }
+
+ [Test]
+ public void Constructor()
+ {
+ Assert.Throws<ArgumentNullException>(() => new DefaultObjectPool<TestPooledObject>(null, 10, 2));
+ Assert.Throws<ArgumentException>(() => new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), -1, 10));
+ Assert.Throws<ArgumentException>(() => new DefaultObjectPool<TestPooledObject>(() => new TestPooledObject(), 10, -1));
+ }
+
+ class TestPooledObject : IPooledObject<TestPooledObject>
+ {
+ public Action<TestPooledObject> ReturnAction;
+
+ public void SetReturnToPoolAction(Action<TestPooledObject> returnAction)
+ {
+ this.ReturnAction = returnAction;
+ }
+
+ public void Dispose()
+ {
+
+ }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs
index c3a27167f9..581ac3384b 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs
@@ -31,43 +31,43 @@ namespace Grpc.Core.Internal.Tests
/// </summary>
internal class FakeNativeCall : INativeCall
{
- public UnaryResponseClientHandler UnaryResponseClientHandler
+ public IUnaryResponseClientCallback UnaryResponseClientCallback
{
get;
set;
}
- public ReceivedStatusOnClientHandler ReceivedStatusOnClientHandler
+ public IReceivedStatusOnClientCallback ReceivedStatusOnClientCallback
{
get;
set;
}
- public ReceivedMessageHandler ReceivedMessageHandler
+ public IReceivedMessageCallback ReceivedMessageCallback
{
get;
set;
}
- public ReceivedResponseHeadersHandler ReceivedResponseHeadersHandler
+ public IReceivedResponseHeadersCallback ReceivedResponseHeadersCallback
{
get;
set;
}
- public SendCompletionHandler SendCompletionHandler
+ public ISendCompletionCallback SendCompletionCallback
{
get;
set;
}
- public SendCompletionHandler SendStatusFromServerHandler
+ public ISendStatusFromServerCompletionCallback SendStatusFromServerCallback
{
get;
set;
}
- public ReceivedCloseOnServerHandler ReceivedCloseOnServerHandler
+ public IReceivedCloseOnServerCallback ReceivedCloseOnServerCallback
{
get;
set;
@@ -100,9 +100,9 @@ namespace Grpc.Core.Internal.Tests
return "PEER";
}
- public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
- UnaryResponseClientHandler = callback;
+ UnaryResponseClientCallback = callback;
}
public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
@@ -110,55 +110,55 @@ namespace Grpc.Core.Internal.Tests
throw new NotImplementedException();
}
- public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
- UnaryResponseClientHandler = callback;
+ UnaryResponseClientCallback = callback;
}
- public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
- ReceivedStatusOnClientHandler = callback;
+ ReceivedStatusOnClientCallback = callback;
}
- public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
- ReceivedStatusOnClientHandler = callback;
+ ReceivedStatusOnClientCallback = callback;
}
- public void StartReceiveMessage(ReceivedMessageHandler callback)
+ public void StartReceiveMessage(IReceivedMessageCallback callback)
{
- ReceivedMessageHandler = callback;
+ ReceivedMessageCallback = callback;
}
- public void StartReceiveInitialMetadata(ReceivedResponseHeadersHandler callback)
+ public void StartReceiveInitialMetadata(IReceivedResponseHeadersCallback callback)
{
- ReceivedResponseHeadersHandler = callback;
+ ReceivedResponseHeadersCallback = callback;
}
- public void StartSendInitialMetadata(SendCompletionHandler callback, MetadataArraySafeHandle metadataArray)
+ public void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray)
{
- SendCompletionHandler = callback;
+ SendCompletionCallback = callback;
}
- public void StartSendMessage(SendCompletionHandler callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
+ public void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
{
- SendCompletionHandler = callback;
+ SendCompletionCallback = callback;
}
- public void StartSendCloseFromClient(SendCompletionHandler callback)
+ public void StartSendCloseFromClient(ISendCompletionCallback callback)
{
- SendCompletionHandler = callback;
+ SendCompletionCallback = callback;
}
- public void StartSendStatusFromServer(SendCompletionHandler callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata,
+ public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata,
byte[] optionalPayload, WriteFlags writeFlags)
{
- SendStatusFromServerHandler = callback;
+ SendStatusFromServerCallback = callback;
}
- public void StartServerSide(ReceivedCloseOnServerHandler callback)
+ public void StartServerSide(IReceivedCloseOnServerCallback callback)
{
- ReceivedCloseOnServerHandler = callback;
+ ReceivedCloseOnServerCallback = callback;
}
public void Dispose()
diff --git a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
index 7529c44c4e..43f816bb1c 100644
--- a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
+++ b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
@@ -63,7 +63,7 @@ namespace Grpc.Core.Tests
[Ignore("Prevent running on Jenkins")]
public void NativeCallbackBenchmark()
{
- OpCompletionDelegate handler = Handler;
+ NativeCallbackTestDelegate handler = Handler;
counter = 0;
BenchmarkUtil.RunBenchmark(
@@ -91,7 +91,7 @@ namespace Grpc.Core.Tests
10000, 10000,
() =>
{
- Native.grpcsharp_test_callback(new OpCompletionDelegate(Handler));
+ Native.grpcsharp_test_callback(new NativeCallbackTestDelegate(Handler));
});
Assert.AreNotEqual(0, counter);
}
diff --git a/src/csharp/Grpc.Core/AsyncClientStreamingCall.cs b/src/csharp/Grpc.Core/AsyncClientStreamingCall.cs
index 087b685963..f59989655e 100644
--- a/src/csharp/Grpc.Core/AsyncClientStreamingCall.cs
+++ b/src/csharp/Grpc.Core/AsyncClientStreamingCall.cs
@@ -36,7 +36,21 @@ namespace Grpc.Core
readonly Func<Metadata> getTrailersFunc;
readonly Action disposeAction;
- internal AsyncClientStreamingCall(IClientStreamWriter<TRequest> requestStream, Task<TResponse> responseAsync, Task<Metadata> responseHeadersAsync, Func<Status> getStatusFunc, Func<Metadata> getTrailersFunc, Action disposeAction)
+ /// <summary>
+ /// Creates a new AsyncClientStreamingCall object with the specified properties.
+ /// </summary>
+ /// <param name="requestStream">Stream of request values.</param>
+ /// <param name="responseAsync">The response of the asynchronous call.</param>
+ /// <param name="responseHeadersAsync">Response headers of the asynchronous call.</param>
+ /// <param name="getStatusFunc">Delegate returning the status of the call.</param>
+ /// <param name="getTrailersFunc">Delegate returning the trailing metadata of the call.</param>
+ /// <param name="disposeAction">Delegate to invoke when Dispose is called on the call object.</param>
+ public AsyncClientStreamingCall(IClientStreamWriter<TRequest> requestStream,
+ Task<TResponse> responseAsync,
+ Task<Metadata> responseHeadersAsync,
+ Func<Status> getStatusFunc,
+ Func<Metadata> getTrailersFunc,
+ Action disposeAction)
{
this.requestStream = requestStream;
this.responseAsync = responseAsync;
diff --git a/src/csharp/Grpc.Core/AsyncDuplexStreamingCall.cs b/src/csharp/Grpc.Core/AsyncDuplexStreamingCall.cs
index ce49fb1596..1cb1a91859 100644
--- a/src/csharp/Grpc.Core/AsyncDuplexStreamingCall.cs
+++ b/src/csharp/Grpc.Core/AsyncDuplexStreamingCall.cs
@@ -35,7 +35,21 @@ namespace Grpc.Core
readonly Func<Metadata> getTrailersFunc;
readonly Action disposeAction;
- internal AsyncDuplexStreamingCall(IClientStreamWriter<TRequest> requestStream, IAsyncStreamReader<TResponse> responseStream, Task<Metadata> responseHeadersAsync, Func<Status> getStatusFunc, Func<Metadata> getTrailersFunc, Action disposeAction)
+ /// <summary>
+ /// Creates a new AsyncDuplexStreamingCall object with the specified properties.
+ /// </summary>
+ /// <param name="requestStream">Stream of request values.</param>
+ /// <param name="responseStream">Stream of response values.</param>
+ /// <param name="responseHeadersAsync">Response headers of the asynchronous call.</param>
+ /// <param name="getStatusFunc">Delegate returning the status of the call.</param>
+ /// <param name="getTrailersFunc">Delegate returning the trailing metadata of the call.</param>
+ /// <param name="disposeAction">Delegate to invoke when Dispose is called on the call object.</param>
+ public AsyncDuplexStreamingCall(IClientStreamWriter<TRequest> requestStream,
+ IAsyncStreamReader<TResponse> responseStream,
+ Task<Metadata> responseHeadersAsync,
+ Func<Status> getStatusFunc,
+ Func<Metadata> getTrailersFunc,
+ Action disposeAction)
{
this.requestStream = requestStream;
this.responseStream = responseStream;
diff --git a/src/csharp/Grpc.Core/AsyncServerStreamingCall.cs b/src/csharp/Grpc.Core/AsyncServerStreamingCall.cs
index fbc97b8148..4303b0b1b0 100644
--- a/src/csharp/Grpc.Core/AsyncServerStreamingCall.cs
+++ b/src/csharp/Grpc.Core/AsyncServerStreamingCall.cs
@@ -33,7 +33,19 @@ namespace Grpc.Core
readonly Func<Metadata> getTrailersFunc;
readonly Action disposeAction;
- internal AsyncServerStreamingCall(IAsyncStreamReader<TResponse> responseStream, Task<Metadata> responseHeadersAsync, Func<Status> getStatusFunc, Func<Metadata> getTrailersFunc, Action disposeAction)
+ /// <summary>
+ /// Creates a new AsyncDuplexStreamingCall object with the specified properties.
+ /// </summary>
+ /// <param name="responseStream">Stream of response values.</param>
+ /// <param name="responseHeadersAsync">Response headers of the asynchronous call.</param>
+ /// <param name="getStatusFunc">Delegate returning the status of the call.</param>
+ /// <param name="getTrailersFunc">Delegate returning the trailing metadata of the call.</param>
+ /// <param name="disposeAction">Delegate to invoke when Dispose is called on the call object.</param>
+ public AsyncServerStreamingCall(IAsyncStreamReader<TResponse> responseStream,
+ Task<Metadata> responseHeadersAsync,
+ Func<Status> getStatusFunc,
+ Func<Metadata> getTrailersFunc,
+ Action disposeAction)
{
this.responseStream = responseStream;
this.responseHeadersAsync = responseHeadersAsync;
diff --git a/src/csharp/Grpc.Core/AsyncUnaryCall.cs b/src/csharp/Grpc.Core/AsyncUnaryCall.cs
index 6348f3c5fd..17747f86ca 100644
--- a/src/csharp/Grpc.Core/AsyncUnaryCall.cs
+++ b/src/csharp/Grpc.Core/AsyncUnaryCall.cs
@@ -34,7 +34,20 @@ namespace Grpc.Core
readonly Func<Metadata> getTrailersFunc;
readonly Action disposeAction;
- internal AsyncUnaryCall(Task<TResponse> responseAsync, Task<Metadata> responseHeadersAsync, Func<Status> getStatusFunc, Func<Metadata> getTrailersFunc, Action disposeAction)
+
+ /// <summary>
+ /// Creates a new AsyncUnaryCall object with the specified properties.
+ /// </summary>
+ /// <param name="responseAsync">The response of the asynchronous call.</param>
+ /// <param name="responseHeadersAsync">Response headers of the asynchronous call.</param>
+ /// <param name="getStatusFunc">Delegate returning the status of the call.</param>
+ /// <param name="getTrailersFunc">Delegate returning the trailing metadata of the call.</param>
+ /// <param name="disposeAction">Delegate to invoke when Dispose is called on the call object.</param>
+ public AsyncUnaryCall(Task<TResponse> responseAsync,
+ Task<Metadata> responseHeadersAsync,
+ Func<Status> getStatusFunc,
+ Func<Metadata> getTrailersFunc,
+ Action disposeAction)
{
this.responseAsync = responseAsync;
this.responseHeadersAsync = responseHeadersAsync;
diff --git a/src/csharp/Grpc.Core/Channel.cs b/src/csharp/Grpc.Core/Channel.cs
index 1803920662..e7b30cd1e9 100644
--- a/src/csharp/Grpc.Core/Channel.cs
+++ b/src/csharp/Grpc.Core/Channel.cs
@@ -127,29 +127,42 @@ namespace Grpc.Core
}
}
+ // cached handler for watch connectivity state
+ static readonly BatchCompletionDelegate WatchConnectivityStateHandler = (success, ctx, state) =>
+ {
+ var tcs = (TaskCompletionSource<bool>) state;
+ tcs.SetResult(success);
+ };
+
/// <summary>
/// Returned tasks completes once channel state has become different from
/// given lastObservedState.
/// If deadline is reached or and error occurs, returned task is cancelled.
/// </summary>
- public Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime? deadline = null)
+ public async Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime? deadline = null)
+ {
+ var result = await WaitForStateChangedInternalAsync(lastObservedState, deadline).ConfigureAwait(false);
+ if (!result)
+ {
+ throw new TaskCanceledException("Reached deadline.");
+ }
+ }
+
+ /// <summary>
+ /// Returned tasks completes once channel state has become different from
+ /// given lastObservedState (<c>true</c> is returned) or if the wait has timed out (<c>false</c> is returned).
+ /// </summary>
+ internal Task<bool> WaitForStateChangedInternalAsync(ChannelState lastObservedState, DateTime? deadline = null)
{
GrpcPreconditions.CheckArgument(lastObservedState != ChannelState.Shutdown,
"Shutdown is a terminal state. No further state changes can occur.");
- var tcs = new TaskCompletionSource<object>();
+ var tcs = new TaskCompletionSource<bool>();
var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture;
- var handler = new BatchCompletionDelegate((success, ctx) =>
+ lock (myLock)
{
- if (success)
- {
- tcs.SetResult(null);
- }
- else
- {
- tcs.SetCanceled();
- }
- });
- handle.WatchConnectivityState(lastObservedState, deadlineTimespec, completionQueue, handler);
+ // pass "tcs" as "state" for WatchConnectivityStateHandler.
+ handle.WatchConnectivityState(lastObservedState, deadlineTimespec, completionQueue, WatchConnectivityStateHandler, tcs);
+ }
return tcs.Task;
}
@@ -232,7 +245,10 @@ namespace Grpc.Core
Logger.Warning("Channel shutdown was called but there are still {0} active calls for that channel.", activeCallCount);
}
- handle.Dispose();
+ lock (myLock)
+ {
+ handle.Dispose();
+ }
await Task.WhenAll(GrpcEnvironment.ReleaseAsync(), connectivityWatcherTask).ConfigureAwait(false);
}
@@ -281,7 +297,10 @@ namespace Grpc.Core
{
try
{
- return handle.CheckConnectivityState(tryToConnect);
+ lock (myLock)
+ {
+ return handle.CheckConnectivityState(tryToConnect);
+ }
}
catch (ObjectDisposedException)
{
@@ -307,14 +326,8 @@ namespace Grpc.Core
}
}
- try
- {
- await WaitForStateChangedAsync(lastState, DateTime.UtcNow.AddSeconds(1)).ConfigureAwait(false);
- }
- catch (TaskCanceledException)
- {
- // ignore timeout
- }
+ // ignore the result
+ await WaitForStateChangedInternalAsync(lastState, DateTime.UtcNow.AddSeconds(1)).ConfigureAwait(false);
lastState = State;
}
}
diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj
index d9950b2f20..6d44be7ddd 100755
--- a/src/csharp/Grpc.Core/Grpc.Core.csproj
+++ b/src/csharp/Grpc.Core/Grpc.Core.csproj
@@ -14,12 +14,12 @@
<PackageTags>gRPC RPC Protocol HTTP/2</PackageTags>
<PackageProjectUrl>https://github.com/grpc/grpc</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</PackageLicenseUrl>
- <IncludeSymbols>true</IncludeSymbols>
- <IncludeSource>true</IncludeSource>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
+ <Import Project="SourceLink.csproj.include" />
+
<ItemGroup>
<EmbeddedResource Include="..\..\..\etc\roots.pem" />
<Content Include="..\nativelibs\csharp_ext_macos_x64\libgrpc_csharp_ext.dylib">
diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs
index 80031cb7ef..6bb2f6c3e5 100644
--- a/src/csharp/Grpc.Core/GrpcEnvironment.cs
+++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs
@@ -33,6 +33,10 @@ namespace Grpc.Core
public class GrpcEnvironment
{
const int MinDefaultThreadPoolSize = 4;
+ const int DefaultBatchContextPoolSharedCapacity = 10000;
+ const int DefaultBatchContextPoolThreadLocalCapacity = 64;
+ const int DefaultRequestCallContextPoolSharedCapacity = 10000;
+ const int DefaultRequestCallContextPoolThreadLocalCapacity = 64;
static object staticLock = new object();
static GrpcEnvironment instance;
@@ -40,11 +44,17 @@ namespace Grpc.Core
static int? customThreadPoolSize;
static int? customCompletionQueueCount;
static bool inlineHandlers;
+ static int batchContextPoolSharedCapacity = DefaultBatchContextPoolSharedCapacity;
+ static int batchContextPoolThreadLocalCapacity = DefaultBatchContextPoolThreadLocalCapacity;
+ static int requestCallContextPoolSharedCapacity = DefaultRequestCallContextPoolSharedCapacity;
+ static int requestCallContextPoolThreadLocalCapacity = DefaultRequestCallContextPoolThreadLocalCapacity;
static readonly HashSet<Channel> registeredChannels = new HashSet<Channel>();
static readonly HashSet<Server> registeredServers = new HashSet<Server>();
static ILogger logger = new LogLevelFilterLogger(new ConsoleLogger(), LogLevel.Off, true);
+ readonly IObjectPool<BatchContextSafeHandle> batchContextPool;
+ readonly IObjectPool<RequestCallContextSafeHandle> requestCallContextPool;
readonly GrpcThreadPool threadPool;
readonly DebugStats debugStats = new DebugStats();
readonly AtomicCounter cqPickerCounter = new AtomicCounter();
@@ -186,7 +196,7 @@ namespace Grpc.Core
/// <summary>
/// Sets the number of threads in the gRPC thread pool that polls for internal RPC events.
- /// Can be only invoke before the <c>GrpcEnviroment</c> is started and cannot be changed afterwards.
+ /// Can be only invoked before the <c>GrpcEnviroment</c> is started and cannot be changed afterwards.
/// Setting thread pool size is an advanced setting and you should only use it if you know what you are doing.
/// Most users should rely on the default value provided by gRPC library.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.
@@ -203,7 +213,7 @@ namespace Grpc.Core
/// <summary>
/// Sets the number of completion queues in the gRPC thread pool that polls for internal RPC events.
- /// Can be only invoke before the <c>GrpcEnviroment</c> is started and cannot be changed afterwards.
+ /// Can be only invoked before the <c>GrpcEnviroment</c> is started and cannot be changed afterwards.
/// Setting the number of completions queues is an advanced setting and you should only use it if you know what you are doing.
/// Most users should rely on the default value provided by gRPC library.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.
@@ -238,6 +248,46 @@ namespace Grpc.Core
}
/// <summary>
+ /// Sets the parameters for a pool that caches batch context instances. Reusing batch context instances
+ /// instead of creating a new one for every C core operation helps reducing the GC pressure.
+ /// Can be only invoked before the <c>GrpcEnviroment</c> is started and cannot be changed afterwards.
+ /// This is an advanced setting and you should only use it if you know what you are doing.
+ /// Most users should rely on the default value provided by gRPC library.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// </summary>
+ public static void SetBatchContextPoolParams(int sharedCapacity, int threadLocalCapacity)
+ {
+ lock (staticLock)
+ {
+ GrpcPreconditions.CheckState(instance == null, "Can only be set before GrpcEnvironment is initialized");
+ GrpcPreconditions.CheckArgument(sharedCapacity >= 0, "Shared capacity needs to be a non-negative number");
+ GrpcPreconditions.CheckArgument(threadLocalCapacity >= 0, "Thread local capacity needs to be a non-negative number");
+ batchContextPoolSharedCapacity = sharedCapacity;
+ batchContextPoolThreadLocalCapacity = threadLocalCapacity;
+ }
+ }
+
+ /// <summary>
+ /// Sets the parameters for a pool that caches request call context instances. Reusing request call context instances
+ /// instead of creating a new one for every requested call in C core helps reducing the GC pressure.
+ /// Can be only invoked before the <c>GrpcEnviroment</c> is started and cannot be changed afterwards.
+ /// This is an advanced setting and you should only use it if you know what you are doing.
+ /// Most users should rely on the default value provided by gRPC library.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// </summary>
+ public static void SetRequestCallContextPoolParams(int sharedCapacity, int threadLocalCapacity)
+ {
+ lock (staticLock)
+ {
+ GrpcPreconditions.CheckState(instance == null, "Can only be set before GrpcEnvironment is initialized");
+ GrpcPreconditions.CheckArgument(sharedCapacity >= 0, "Shared capacity needs to be a non-negative number");
+ GrpcPreconditions.CheckArgument(threadLocalCapacity >= 0, "Thread local capacity needs to be a non-negative number");
+ requestCallContextPoolSharedCapacity = sharedCapacity;
+ requestCallContextPoolThreadLocalCapacity = threadLocalCapacity;
+ }
+ }
+
+ /// <summary>
/// Occurs when <c>GrpcEnvironment</c> is about the start the shutdown logic.
/// If <c>GrpcEnvironment</c> is later initialized and shutdown, the event will be fired again (unless unregistered first).
/// </summary>
@@ -249,6 +299,8 @@ namespace Grpc.Core
private GrpcEnvironment()
{
GrpcNativeInit();
+ batchContextPool = new DefaultObjectPool<BatchContextSafeHandle>(() => BatchContextSafeHandle.Create(), batchContextPoolSharedCapacity, batchContextPoolThreadLocalCapacity);
+ requestCallContextPool = new DefaultObjectPool<RequestCallContextSafeHandle>(() => RequestCallContextSafeHandle.Create(), requestCallContextPoolSharedCapacity, requestCallContextPoolThreadLocalCapacity);
threadPool = new GrpcThreadPool(this, GetThreadPoolSizeOrDefault(), GetCompletionQueueCountOrDefault(), inlineHandlers);
threadPool.Start();
}
@@ -264,6 +316,10 @@ namespace Grpc.Core
}
}
+ internal IObjectPool<BatchContextSafeHandle> BatchContextPool => batchContextPool;
+
+ internal IObjectPool<RequestCallContextSafeHandle> RequestCallContextPool => requestCallContextPool;
+
internal bool IsAlive
{
get
@@ -325,6 +381,8 @@ namespace Grpc.Core
await Task.Run(() => ShuttingDown?.Invoke(this, null)).ConfigureAwait(false);
await threadPool.StopAsync().ConfigureAwait(false);
+ requestCallContextPool.Dispose();
+ batchContextPool.Dispose();
GrpcNativeShutdown();
isShutdown = true;
diff --git a/src/csharp/Grpc.Core/IAsyncStreamReader.cs b/src/csharp/Grpc.Core/IAsyncStreamReader.cs
index 42bfbb87e0..3751d549e3 100644
--- a/src/csharp/Grpc.Core/IAsyncStreamReader.cs
+++ b/src/csharp/Grpc.Core/IAsyncStreamReader.cs
@@ -41,6 +41,13 @@ namespace Grpc.Core
/// (<c>MoveNext</c> will return <c>false</c>) and the <c>CancellationToken</c>
/// associated with the call will be cancelled to signal the failure.
/// </para>
+ /// <para>
+ /// <c>MoveNext()</c> operations can be cancelled via a cancellation token. Cancelling
+ /// an individual read operation has the same effect as cancelling the entire call
+ /// (which will also result in the read operation returning prematurely), but the per-read cancellation
+ /// tokens passed to MoveNext() only result in cancelling the call if the read operation haven't finished
+ /// yet.
+ /// </para>
/// </summary>
/// <typeparam name="T">The message type.</typeparam>
public interface IAsyncStreamReader<T> : IAsyncEnumerator<T>
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
index 17109de587..9946d1a6cf 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
@@ -27,13 +27,16 @@ namespace Grpc.Core.Internal
/// <summary>
/// Manages client side native call lifecycle.
/// </summary>
- internal class AsyncCall<TRequest, TResponse> : AsyncCallBase<TRequest, TResponse>
+ internal class AsyncCall<TRequest, TResponse> : AsyncCallBase<TRequest, TResponse>, IUnaryResponseClientCallback, IReceivedStatusOnClientCallback, IReceivedResponseHeadersCallback
{
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<AsyncCall<TRequest, TResponse>>();
readonly CallInvocationDetails<TRequest, TResponse> details;
readonly INativeCall injectedNativeCall; // for testing
+ // Dispose of to de-register cancellation token registration
+ IDisposable cancellationTokenRegistration;
+
// Completion of a pending unary response if not null.
TaskCompletionSource<TResponse> unaryResponseTcs;
@@ -89,23 +92,28 @@ namespace Grpc.Core.Internal
}
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
- using (var ctx = BatchContextSafeHandle.Create())
{
- call.StartUnary(ctx, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
-
- var ev = cq.Pluck(ctx.Handle);
-
- bool success = (ev.success != 0);
+ var ctx = details.Channel.Environment.BatchContextPool.Lease();
try
{
- using (profiler.NewScope("AsyncCall.UnaryCall.HandleBatch"))
+ call.StartUnary(ctx, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
+ var ev = cq.Pluck(ctx.Handle);
+ bool success = (ev.success != 0);
+ try
+ {
+ using (profiler.NewScope("AsyncCall.UnaryCall.HandleBatch"))
+ {
+ HandleUnaryResponse(success, ctx.GetReceivedStatusOnClient(), ctx.GetReceivedMessage(), ctx.GetReceivedInitialMetadata());
+ }
+ }
+ catch (Exception e)
{
- HandleUnaryResponse(success, ctx.GetReceivedStatusOnClient(), ctx.GetReceivedMessage(), ctx.GetReceivedInitialMetadata());
+ Logger.Error(e, "Exception occured while invoking completion delegate.");
}
}
- catch (Exception e)
+ finally
{
- Logger.Error(e, "Exception occured while invoking completion delegate.");
+ ctx.Recycle();
}
}
@@ -135,7 +143,7 @@ namespace Grpc.Core.Internal
unaryResponseTcs = new TaskCompletionSource<TResponse>();
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
- call.StartUnary(HandleUnaryResponse, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
+ call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
}
return unaryResponseTcs.Task;
}
@@ -159,7 +167,7 @@ namespace Grpc.Core.Internal
unaryResponseTcs = new TaskCompletionSource<TResponse>();
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
- call.StartClientStreaming(HandleUnaryResponse, metadataArray, details.Options.Flags);
+ call.StartClientStreaming(UnaryResponseClientCallback, metadataArray, details.Options.Flags);
}
return unaryResponseTcs.Task;
@@ -185,9 +193,9 @@ namespace Grpc.Core.Internal
streamingResponseCallFinishedTcs = new TaskCompletionSource<object>();
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
- call.StartServerStreaming(HandleFinished, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
+ call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
}
- call.StartReceiveInitialMetadata(HandleReceivedResponseHeaders);
+ call.StartReceiveInitialMetadata(ReceivedResponseHeadersCallback);
}
}
@@ -207,9 +215,9 @@ namespace Grpc.Core.Internal
streamingResponseCallFinishedTcs = new TaskCompletionSource<object>();
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
- call.StartDuplexStreaming(HandleFinished, metadataArray, details.Options.Flags);
+ call.StartDuplexStreaming(ReceivedStatusOnClientCallback, metadataArray, details.Options.Flags);
}
- call.StartReceiveInitialMetadata(HandleReceivedResponseHeaders);
+ call.StartReceiveInitialMetadata(ReceivedResponseHeadersCallback);
}
}
@@ -253,7 +261,7 @@ namespace Grpc.Core.Internal
halfcloseRequested = true;
return TaskUtils.CompletedTask;
}
- call.StartSendCloseFromClient(HandleSendFinished);
+ call.StartSendCloseFromClient(SendCompletionCallback);
halfcloseRequested = true;
streamingWriteTcs = new TaskCompletionSource<object>();
@@ -320,6 +328,7 @@ namespace Grpc.Core.Internal
protected override void OnAfterReleaseResources()
{
details.Channel.RemoveCallReference(this);
+ cancellationTokenRegistration?.Dispose();
}
protected override bool IsClient
@@ -405,7 +414,7 @@ namespace Grpc.Core.Internal
var token = details.Options.CancellationToken;
if (token.CanBeCanceled)
{
- token.Register(() => this.Cancel());
+ cancellationTokenRegistration = token.Register(() => this.Cancel());
}
}
@@ -512,5 +521,26 @@ namespace Grpc.Core.Internal
streamingResponseCallFinishedTcs.SetResult(null);
}
+
+ IUnaryResponseClientCallback UnaryResponseClientCallback => this;
+
+ void IUnaryResponseClientCallback.OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders)
+ {
+ HandleUnaryResponse(success, receivedStatus, receivedMessage, responseHeaders);
+ }
+
+ IReceivedStatusOnClientCallback ReceivedStatusOnClientCallback => this;
+
+ void IReceivedStatusOnClientCallback.OnReceivedStatusOnClient(bool success, ClientSideStatus receivedStatus)
+ {
+ HandleFinished(success, receivedStatus);
+ }
+
+ IReceivedResponseHeadersCallback ReceivedResponseHeadersCallback => this;
+
+ void IReceivedResponseHeadersCallback.OnReceivedResponseHeaders(bool success, Metadata responseHeaders)
+ {
+ HandleReceivedResponseHeaders(success, responseHeaders);
+ }
}
}
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
index f379c85e00..3273c26b88 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
@@ -35,7 +35,7 @@ namespace Grpc.Core.Internal
/// Base for handling both client side and server side calls.
/// Manages native call lifecycle and provides convenience methods.
/// </summary>
- internal abstract class AsyncCallBase<TWrite, TRead>
+ internal abstract class AsyncCallBase<TWrite, TRead> : IReceivedMessageCallback, ISendCompletionCallback
{
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<AsyncCallBase<TWrite, TRead>>();
protected static readonly Status DeserializeResponseFailureStatus = new Status(StatusCode.Internal, "Failed to deserialize response message.");
@@ -126,7 +126,7 @@ namespace Grpc.Core.Internal
return earlyResult;
}
- call.StartSendMessage(HandleSendFinished, payload, writeFlags, !initialMetadataSent);
+ call.StartSendMessage(SendCompletionCallback, payload, writeFlags, !initialMetadataSent);
initialMetadataSent = true;
streamingWritesCounter++;
@@ -154,7 +154,7 @@ namespace Grpc.Core.Internal
GrpcPreconditions.CheckState(streamingReadTcs == null, "Only one read can be pending at a time");
GrpcPreconditions.CheckState(!disposed);
- call.StartReceiveMessage(HandleReadFinished);
+ call.StartReceiveMessage(ReceivedMessageCallback);
streamingReadTcs = new TaskCompletionSource<TRead>();
return streamingReadTcs.Task;
}
@@ -342,5 +342,19 @@ namespace Grpc.Core.Internal
}
origTcs.SetResult(msg);
}
+
+ protected ISendCompletionCallback SendCompletionCallback => this;
+
+ void ISendCompletionCallback.OnSendCompletion(bool success)
+ {
+ HandleSendFinished(success);
+ }
+
+ IReceivedMessageCallback ReceivedMessageCallback => this;
+
+ void IReceivedMessageCallback.OnReceivedMessage(bool success, byte[] receivedMessage)
+ {
+ HandleReadFinished(success, receivedMessage);
+ }
}
}
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs
index 271a6ffadf..11acb27533 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs
@@ -31,7 +31,7 @@ namespace Grpc.Core.Internal
/// <summary>
/// Manages server side native call lifecycle.
/// </summary>
- internal class AsyncCallServer<TRequest, TResponse> : AsyncCallBase<TResponse, TRequest>
+ internal class AsyncCallServer<TRequest, TResponse> : AsyncCallBase<TResponse, TRequest>, IReceivedCloseOnServerCallback, ISendStatusFromServerCompletionCallback
{
readonly TaskCompletionSource<object> finishedServersideTcs = new TaskCompletionSource<object>();
readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
@@ -70,7 +70,7 @@ namespace Grpc.Core.Internal
started = true;
- call.StartServerSide(HandleFinishedServerside);
+ call.StartServerSide(ReceiveCloseOnServerCallback);
return finishedServersideTcs.Task;
}
}
@@ -114,7 +114,7 @@ namespace Grpc.Core.Internal
using (var metadataArray = MetadataArraySafeHandle.Create(headers))
{
- call.StartSendInitialMetadata(HandleSendFinished, metadataArray);
+ call.StartSendInitialMetadata(SendCompletionCallback, metadataArray);
}
this.initialMetadataSent = true;
@@ -127,10 +127,10 @@ namespace Grpc.Core.Internal
/// Sends call result status, indicating we are done with writes.
/// Sending a status different from StatusCode.OK will also implicitly cancel the call.
/// </summary>
- public Task SendStatusFromServerAsync(Status status, Metadata trailers, Tuple<TResponse, WriteFlags> optionalWrite)
+ public Task SendStatusFromServerAsync(Status status, Metadata trailers, ResponseWithFlags? optionalWrite)
{
- byte[] payload = optionalWrite != null ? UnsafeSerialize(optionalWrite.Item1) : null;
- var writeFlags = optionalWrite != null ? optionalWrite.Item2 : default(WriteFlags);
+ byte[] payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null;
+ var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags);
lock (myLock)
{
@@ -140,13 +140,13 @@ namespace Grpc.Core.Internal
using (var metadataArray = MetadataArraySafeHandle.Create(trailers))
{
- call.StartSendStatusFromServer(HandleSendStatusFromServerFinished, status, metadataArray, !initialMetadataSent,
+ call.StartSendStatusFromServer(SendStatusFromServerCompletionCallback, status, metadataArray, !initialMetadataSent,
payload, writeFlags);
}
halfcloseRequested = true;
initialMetadataSent = true;
sendStatusFromServerTcs = new TaskCompletionSource<object>();
- if (optionalWrite != null)
+ if (optionalWrite.HasValue)
{
streamingWritesCounter++;
}
@@ -227,5 +227,31 @@ namespace Grpc.Core.Internal
finishedServersideTcs.SetResult(null);
}
+
+ IReceivedCloseOnServerCallback ReceiveCloseOnServerCallback => this;
+
+ void IReceivedCloseOnServerCallback.OnReceivedCloseOnServer(bool success, bool cancelled)
+ {
+ HandleFinishedServerside(success, cancelled);
+ }
+
+ ISendStatusFromServerCompletionCallback SendStatusFromServerCompletionCallback => this;
+
+ void ISendStatusFromServerCompletionCallback.OnSendStatusFromServerCompletion(bool success)
+ {
+ HandleSendStatusFromServerFinished(success);
+ }
+
+ public struct ResponseWithFlags
+ {
+ public ResponseWithFlags(TResponse response, WriteFlags writeFlags)
+ {
+ this.Response = response;
+ this.WriteFlags = writeFlags;
+ }
+
+ public TResponse Response { get; }
+ public WriteFlags WriteFlags { get; }
+ }
}
}
diff --git a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs
index cd5e3d8911..53a859d18f 100644
--- a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs
@@ -20,15 +20,26 @@ using System;
using System.Runtime.InteropServices;
using System.Text;
using Grpc.Core;
+using Grpc.Core.Logging;
+using Grpc.Core.Utils;
namespace Grpc.Core.Internal
{
+ internal interface IOpCompletionCallback
+ {
+ void OnComplete(bool success);
+ }
+
/// <summary>
/// grpcsharp_batch_context
/// </summary>
- internal class BatchContextSafeHandle : SafeHandleZeroIsInvalid
+ internal class BatchContextSafeHandle : SafeHandleZeroIsInvalid, IOpCompletionCallback, IPooledObject<BatchContextSafeHandle>
{
static readonly NativeMethods Native = NativeMethods.Get();
+ static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<BatchContextSafeHandle>();
+
+ Action<BatchContextSafeHandle> returnToPoolAction;
+ CompletionCallbackData completionCallbackData;
private BatchContextSafeHandle()
{
@@ -36,7 +47,8 @@ namespace Grpc.Core.Internal
public static BatchContextSafeHandle Create()
{
- return Native.grpcsharp_batch_context_create();
+ var ctx = Native.grpcsharp_batch_context_create();
+ return ctx;
}
public IntPtr Handle
@@ -47,19 +59,32 @@ namespace Grpc.Core.Internal
}
}
+ public void SetReturnToPoolAction(Action<BatchContextSafeHandle> returnAction)
+ {
+ GrpcPreconditions.CheckState(returnToPoolAction == null);
+ returnToPoolAction = returnAction;
+ }
+
+ public void SetCompletionCallback(BatchCompletionDelegate callback, object state)
+ {
+ GrpcPreconditions.CheckState(completionCallbackData.Callback == null);
+ GrpcPreconditions.CheckNotNull(callback, nameof(callback));
+ completionCallbackData = new CompletionCallbackData(callback, state);
+ }
+
// Gets data of recv_initial_metadata completion.
public Metadata GetReceivedInitialMetadata()
{
IntPtr metadataArrayPtr = Native.grpcsharp_batch_context_recv_initial_metadata(this);
return MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr);
}
-
+
// Gets data of recv_status_on_client completion.
public ClientSideStatus GetReceivedStatusOnClient()
{
UIntPtr detailsLength;
IntPtr detailsPtr = Native.grpcsharp_batch_context_recv_status_on_client_details(this, out detailsLength);
- string details = MarshalUtils.PtrToStringUTF8(detailsPtr, (int) detailsLength.ToUInt32());
+ string details = MarshalUtils.PtrToStringUTF8(detailsPtr, (int)detailsLength.ToUInt32());
var status = new Status(Native.grpcsharp_batch_context_recv_status_on_client_status(this), details);
IntPtr metadataArrayPtr = Native.grpcsharp_batch_context_recv_status_on_client_trailing_metadata(this);
@@ -86,11 +111,58 @@ namespace Grpc.Core.Internal
{
return Native.grpcsharp_batch_context_recv_close_on_server_cancelled(this) != 0;
}
-
+
+ public void Recycle()
+ {
+ if (returnToPoolAction != null)
+ {
+ Native.grpcsharp_batch_context_reset(this);
+
+ var origReturnAction = returnToPoolAction;
+ // Not clearing all the references to the pool could prevent garbage collection of the pool object
+ // and thus cause memory leaks.
+ returnToPoolAction = null;
+ origReturnAction(this);
+ }
+ else
+ {
+ Dispose();
+ }
+ }
+
protected override bool ReleaseHandle()
{
Native.grpcsharp_batch_context_destroy(handle);
return true;
}
+
+ void IOpCompletionCallback.OnComplete(bool success)
+ {
+ try
+ {
+ completionCallbackData.Callback(success, this, completionCallbackData.State);
+ }
+ catch (Exception e)
+ {
+ Logger.Error(e, "Exception occured while invoking batch completion delegate.");
+ }
+ finally
+ {
+ completionCallbackData = default(CompletionCallbackData);
+ Recycle();
+ }
+ }
+
+ struct CompletionCallbackData
+ {
+ public CompletionCallbackData(BatchCompletionDelegate callback, object state)
+ {
+ this.Callback = callback;
+ this.State = state;
+ }
+
+ public BatchCompletionDelegate Callback { get; }
+ public object State { get; }
+ }
}
}
diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs
index 3a7f97707b..a3ef3e61ee 100644
--- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs
@@ -32,6 +32,23 @@ namespace Grpc.Core.Internal
public static readonly CallSafeHandle NullInstance = new CallSafeHandle();
static readonly NativeMethods Native = NativeMethods.Get();
+ // Completion handlers are pre-allocated to avoid unneccessary delegate allocations.
+ // The "state" field is used to store the actual callback to invoke.
+ static readonly BatchCompletionDelegate CompletionHandler_IUnaryResponseClientCallback =
+ (success, context, state) => ((IUnaryResponseClientCallback)state).OnUnaryResponseClient(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata());
+ static readonly BatchCompletionDelegate CompletionHandler_IReceivedStatusOnClientCallback =
+ (success, context, state) => ((IReceivedStatusOnClientCallback)state).OnReceivedStatusOnClient(success, context.GetReceivedStatusOnClient());
+ static readonly BatchCompletionDelegate CompletionHandler_IReceivedMessageCallback =
+ (success, context, state) => ((IReceivedMessageCallback)state).OnReceivedMessage(success, context.GetReceivedMessage());
+ static readonly BatchCompletionDelegate CompletionHandler_IReceivedResponseHeadersCallback =
+ (success, context, state) => ((IReceivedResponseHeadersCallback)state).OnReceivedResponseHeaders(success, context.GetReceivedInitialMetadata());
+ static readonly BatchCompletionDelegate CompletionHandler_ISendCompletionCallback =
+ (success, context, state) => ((ISendCompletionCallback)state).OnSendCompletion(success);
+ static readonly BatchCompletionDelegate CompletionHandler_ISendStatusFromServerCompletionCallback =
+ (success, context, state) => ((ISendStatusFromServerCompletionCallback)state).OnSendStatusFromServerCompletion(success);
+ static readonly BatchCompletionDelegate CompletionHandler_IReceivedCloseOnServerCallback =
+ (success, context, state) => ((IReceivedCloseOnServerCallback)state).OnReceivedCloseOnServer(success, context.GetReceivedCloseOnServerCancelled());
+
const uint GRPC_WRITE_BUFFER_HINT = 1;
CompletionQueueSafeHandle completionQueue;
@@ -49,12 +66,11 @@ namespace Grpc.Core.Internal
Native.grpcsharp_call_set_credentials(this, credentials).CheckOk();
}
- public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IUnaryResponseClientCallback, callback);
Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags)
.CheckOk();
}
@@ -66,106 +82,96 @@ namespace Grpc.Core.Internal
.CheckOk();
}
- public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IUnaryResponseClientCallback, callback);
Native.grpcsharp_call_start_client_streaming(this, ctx, metadataArray, callFlags).CheckOk();
}
}
- public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedStatusOnClientCallback, callback);
Native.grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags).CheckOk();
}
}
- public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
+ public void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedStatusOnClientCallback, callback);
Native.grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray, callFlags).CheckOk();
}
}
- public void StartSendMessage(SendCompletionHandler callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
+ public void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendCompletionCallback, callback);
Native.grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata ? 1 : 0).CheckOk();
}
}
- public void StartSendCloseFromClient(SendCompletionHandler callback)
+ public void StartSendCloseFromClient(ISendCompletionCallback callback)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendCompletionCallback, callback);
Native.grpcsharp_call_send_close_from_client(this, ctx).CheckOk();
}
}
- public void StartSendStatusFromServer(SendCompletionHandler callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata,
+ public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata,
byte[] optionalPayload, WriteFlags writeFlags)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback);
var optionalPayloadLength = optionalPayload != null ? new UIntPtr((ulong)optionalPayload.Length) : UIntPtr.Zero;
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
var statusDetailBytes = MarshalUtils.GetBytesUTF8(status.Detail);
Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, statusDetailBytes, new UIntPtr((ulong)statusDetailBytes.Length), metadataArray, sendEmptyInitialMetadata ? 1 : 0,
optionalPayload, optionalPayloadLength, writeFlags).CheckOk();
}
}
- public void StartReceiveMessage(ReceivedMessageHandler callback)
+ public void StartReceiveMessage(IReceivedMessageCallback callback)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedMessage()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedMessageCallback, callback);
Native.grpcsharp_call_recv_message(this, ctx).CheckOk();
}
}
- public void StartReceiveInitialMetadata(ReceivedResponseHeadersHandler callback)
+ public void StartReceiveInitialMetadata(IReceivedResponseHeadersCallback callback)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedInitialMetadata()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedResponseHeadersCallback, callback);
Native.grpcsharp_call_recv_initial_metadata(this, ctx).CheckOk();
}
}
- public void StartServerSide(ReceivedCloseOnServerHandler callback)
+ public void StartServerSide(IReceivedCloseOnServerCallback callback)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedCloseOnServerCancelled()));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedCloseOnServerCallback, callback);
Native.grpcsharp_call_start_serverside(this, ctx).CheckOk();
}
}
- public void StartSendInitialMetadata(SendCompletionHandler callback, MetadataArraySafeHandle metadataArray)
+ public void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success));
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendCompletionCallback, callback);
Native.grpcsharp_call_send_initial_metadata(this, ctx, metadataArray).CheckOk();
}
}
diff --git a/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs
index f826a17bad..cd5f8ed92e 100644
--- a/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs
@@ -64,10 +64,9 @@ namespace Grpc.Core.Internal
return Native.grpcsharp_channel_check_connectivity_state(this, tryToConnect ? 1 : 0);
}
- public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchCompletionDelegate callback)
+ public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchCompletionDelegate callback, object callbackState)
{
- var ctx = BatchContextSafeHandle.Create();
- cq.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
+ var ctx = cq.CompletionRegistry.RegisterBatchCompletion(callback, callbackState);
Native.grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx);
}
diff --git a/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs b/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs
index 851b6ca213..ab649ee766 100644
--- a/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs
+++ b/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs
@@ -49,19 +49,19 @@ namespace Grpc.Core.Internal
public async Task<bool> MoveNext(CancellationToken token)
{
- if (token != CancellationToken.None)
+ var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null;
+ using (cancellationTokenRegistration)
{
- throw new InvalidOperationException("Cancellation of individual reads is not supported.");
- }
- var result = await call.ReadMessageAsync().ConfigureAwait(false);
- this.current = result;
+ var result = await call.ReadMessageAsync().ConfigureAwait(false);
+ this.current = result;
- if (result == null)
- {
- await call.StreamingResponseCallFinishedTask.ConfigureAwait(false);
- return false;
+ if (result == null)
+ {
+ await call.StreamingResponseCallFinishedTask.ConfigureAwait(false);
+ return false;
+ }
+ return true;
}
- return true;
}
public void Dispose()
diff --git a/src/csharp/Grpc.Core/Internal/CompletionRegistry.cs b/src/csharp/Grpc.Core/Internal/CompletionRegistry.cs
index 3ce08e9a75..79d0c91420 100644
--- a/src/csharp/Grpc.Core/Internal/CompletionRegistry.cs
+++ b/src/csharp/Grpc.Core/Internal/CompletionRegistry.cs
@@ -19,15 +19,15 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.InteropServices;
+using System.Threading;
using Grpc.Core.Logging;
using Grpc.Core.Utils;
namespace Grpc.Core.Internal
{
- internal delegate void OpCompletionDelegate(bool success);
-
- internal delegate void BatchCompletionDelegate(bool success, BatchContextSafeHandle ctx);
+ internal delegate void BatchCompletionDelegate(bool success, BatchContextSafeHandle ctx, object state);
internal delegate void RequestCallCompletionDelegate(bool success, RequestCallContextSafeHandle ctx);
@@ -36,85 +36,78 @@ namespace Grpc.Core.Internal
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<CompletionRegistry>();
readonly GrpcEnvironment environment;
- readonly ConcurrentDictionary<IntPtr, OpCompletionDelegate> dict = new ConcurrentDictionary<IntPtr, OpCompletionDelegate>(new IntPtrComparer());
+ readonly Func<BatchContextSafeHandle> batchContextFactory;
+ readonly Func<RequestCallContextSafeHandle> requestCallContextFactory;
+ readonly Dictionary<IntPtr, IOpCompletionCallback> dict = new Dictionary<IntPtr, IOpCompletionCallback>(new IntPtrComparer());
+ SpinLock spinLock = new SpinLock(Debugger.IsAttached);
IntPtr lastRegisteredKey; // only for testing
- public CompletionRegistry(GrpcEnvironment environment)
+ public CompletionRegistry(GrpcEnvironment environment, Func<BatchContextSafeHandle> batchContextFactory, Func<RequestCallContextSafeHandle> requestCallContextFactory)
{
- this.environment = environment;
+ this.environment = GrpcPreconditions.CheckNotNull(environment);
+ this.batchContextFactory = GrpcPreconditions.CheckNotNull(batchContextFactory);
+ this.requestCallContextFactory = GrpcPreconditions.CheckNotNull(requestCallContextFactory);
}
- public void Register(IntPtr key, OpCompletionDelegate callback)
+ public void Register(IntPtr key, IOpCompletionCallback callback)
{
environment.DebugStats.PendingBatchCompletions.Increment();
- GrpcPreconditions.CheckState(dict.TryAdd(key, callback));
- this.lastRegisteredKey = key;
- }
- public void RegisterBatchCompletion(BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
- {
- OpCompletionDelegate opCallback = ((success) => HandleBatchCompletion(success, ctx, callback));
- Register(ctx.Handle, opCallback);
- }
+ bool lockTaken = false;
+ try
+ {
+ spinLock.Enter(ref lockTaken);
- public void RegisterRequestCallCompletion(RequestCallContextSafeHandle ctx, RequestCallCompletionDelegate callback)
- {
- OpCompletionDelegate opCallback = ((success) => HandleRequestCallCompletion(success, ctx, callback));
- Register(ctx.Handle, opCallback);
+ dict.Add(key, callback);
+ this.lastRegisteredKey = key;
+ }
+ finally
+ {
+ if (lockTaken) spinLock.Exit();
+ }
}
- public OpCompletionDelegate Extract(IntPtr key)
+ public BatchContextSafeHandle RegisterBatchCompletion(BatchCompletionDelegate callback, object state)
{
- OpCompletionDelegate value;
- GrpcPreconditions.CheckState(dict.TryRemove(key, out value));
- environment.DebugStats.PendingBatchCompletions.Decrement();
- return value;
+ var ctx = batchContextFactory();
+ ctx.SetCompletionCallback(callback, state);
+ Register(ctx.Handle, ctx);
+ return ctx;
}
- /// <summary>
- /// For testing purposes only.
- /// </summary>
- public IntPtr LastRegisteredKey
+ public RequestCallContextSafeHandle RegisterRequestCallCompletion(RequestCallCompletionDelegate callback)
{
- get { return this.lastRegisteredKey; }
+ var ctx = requestCallContextFactory();
+ ctx.CompletionCallback = callback;
+ Register(ctx.Handle, ctx);
+ return ctx;
}
- private static void HandleBatchCompletion(bool success, BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
+ public IOpCompletionCallback Extract(IntPtr key)
{
+ IOpCompletionCallback value = null;
+ bool lockTaken = false;
try
{
- callback(success, ctx);
- }
- catch (Exception e)
- {
- Logger.Error(e, "Exception occured while invoking batch completion delegate.");
+ spinLock.Enter(ref lockTaken);
+
+ value = dict[key];
+ dict.Remove(key);
}
finally
{
- if (ctx != null)
- {
- ctx.Dispose();
- }
+ if (lockTaken) spinLock.Exit();
}
+ environment.DebugStats.PendingBatchCompletions.Decrement();
+ return value;
}
- private static void HandleRequestCallCompletion(bool success, RequestCallContextSafeHandle ctx, RequestCallCompletionDelegate callback)
+ /// <summary>
+ /// For testing purposes only. NOT threadsafe.
+ /// </summary>
+ public IntPtr LastRegisteredKey
{
- try
- {
- callback(success, ctx);
- }
- catch (Exception e)
- {
- Logger.Error(e, "Exception occured while invoking request call completion delegate.");
- }
- finally
- {
- if (ctx != null)
- {
- ctx.Dispose();
- }
- }
+ get { return this.lastRegisteredKey; }
}
/// <summary>
diff --git a/src/csharp/Grpc.Core/Internal/DefaultObjectPool.cs b/src/csharp/Grpc.Core/Internal/DefaultObjectPool.cs
new file mode 100644
index 0000000000..0e1dc4d158
--- /dev/null
+++ b/src/csharp/Grpc.Core/Internal/DefaultObjectPool.cs
@@ -0,0 +1,205 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using System.Threading;
+using System.Collections.Generic;
+using Grpc.Core.Utils;
+
+namespace Grpc.Core.Internal
+{
+ /// <summary>
+ /// Pool of objects that combines a shared pool and a thread local pool.
+ /// </summary>
+ internal class DefaultObjectPool<T> : IObjectPool<T>
+ where T : class, IPooledObject<T>
+ {
+ readonly object myLock = new object();
+ readonly Action<T> returnAction;
+ readonly Func<T> itemFactory;
+
+ // Queue shared between threads, access needs to be synchronized.
+ readonly Queue<T> sharedQueue;
+ readonly int sharedCapacity;
+
+ readonly ThreadLocal<ThreadLocalData> threadLocalData;
+ readonly int threadLocalCapacity;
+ readonly int rentLimit;
+
+ bool disposed;
+
+ /// <summary>
+ /// Initializes a new instance of <c>DefaultObjectPool</c> with given shared capacity and thread local capacity.
+ /// Thread local capacity should be significantly smaller than the shared capacity as we don't guarantee immediately
+ /// disposing the objects in the thread local pool after this pool is disposed (they will eventually be garbage collected
+ /// after the thread that owns them has finished).
+ /// On average, the shared pool will only be accessed approx. once for every <c>threadLocalCapacity / 2</c> rent or lease
+ /// operations.
+ /// </summary>
+ public DefaultObjectPool(Func<T> itemFactory, int sharedCapacity, int threadLocalCapacity)
+ {
+ GrpcPreconditions.CheckArgument(sharedCapacity >= 0);
+ GrpcPreconditions.CheckArgument(threadLocalCapacity >= 0);
+ this.returnAction = Return;
+ this.itemFactory = GrpcPreconditions.CheckNotNull(itemFactory, nameof(itemFactory));
+ this.sharedQueue = new Queue<T>(sharedCapacity);
+ this.sharedCapacity = sharedCapacity;
+ this.threadLocalData = new ThreadLocal<ThreadLocalData>(() => new ThreadLocalData(threadLocalCapacity), false);
+ this.threadLocalCapacity = threadLocalCapacity;
+ this.rentLimit = threadLocalCapacity != 1 ? threadLocalCapacity / 2 : 1;
+ }
+
+ /// <summary>
+ /// Leases an item from the pool or creates a new instance if the pool is empty.
+ /// Attempts to retrieve the item from the thread local pool first.
+ /// If the thread local pool is empty, the item is taken from the shared pool
+ /// along with more items that are moved to the thread local pool to avoid
+ /// prevent acquiring the lock for shared pool too often.
+ /// The methods should not be called after the pool is disposed, but it won't
+ /// results in an error to do so (after depleting the items potentially left
+ /// in the thread local pool, it will continue returning new objects created by the factory).
+ /// </summary>
+ public T Lease()
+ {
+ var item = LeaseInternal();
+ item.SetReturnToPoolAction(returnAction);
+ return item;
+ }
+
+ private T LeaseInternal()
+ {
+ var localData = threadLocalData.Value;
+ if (localData.Queue.Count > 0)
+ {
+ return localData.Queue.Dequeue();
+ }
+ if (localData.CreateBudget > 0)
+ {
+ localData.CreateBudget --;
+ return itemFactory();
+ }
+
+ int itemsMoved = 0;
+ T leasedItem = null;
+ lock(myLock)
+ {
+ if (sharedQueue.Count > 0)
+ {
+ leasedItem = sharedQueue.Dequeue();
+ }
+ while (sharedQueue.Count > 0 && itemsMoved < rentLimit)
+ {
+ localData.Queue.Enqueue(sharedQueue.Dequeue());
+ itemsMoved ++;
+ }
+ }
+
+ // If the shared pool didn't contain all rentLimit items,
+ // next time we try to lease we will just create those
+ // instead of trying to grab them from the shared queue.
+ // This is to guarantee we won't be accessing the shared queue too often.
+ localData.CreateBudget = rentLimit - itemsMoved;
+
+ return leasedItem ?? itemFactory();
+ }
+
+ /// <summary>
+ /// Returns an item to the pool.
+ /// Attempts to add the item to the thread local pool first.
+ /// If the thread local pool is full, item is added to a shared pool,
+ /// along with half of the items for the thread local pool, which
+ /// should prevent acquiring the lock for shared pool too often.
+ /// If called after the pool is disposed, we make best effort not to
+ /// add anything to the thread local pool and we guarantee not to add
+ /// anything to the shared pool (items will be disposed instead).
+ /// </summary>
+ public void Return(T item)
+ {
+ GrpcPreconditions.CheckNotNull(item);
+
+ var localData = threadLocalData.Value;
+ if (localData.Queue.Count < threadLocalCapacity && !disposed)
+ {
+ localData.Queue.Enqueue(item);
+ return;
+ }
+ if (localData.DisposeBudget > 0)
+ {
+ localData.DisposeBudget --;
+ item.Dispose();
+ return;
+ }
+
+ int itemsReturned = 0;
+ int returnLimit = rentLimit + 1;
+ lock (myLock)
+ {
+ if (sharedQueue.Count < sharedCapacity && !disposed)
+ {
+ sharedQueue.Enqueue(item);
+ itemsReturned ++;
+ }
+ while (sharedQueue.Count < sharedCapacity && itemsReturned < returnLimit && !disposed)
+ {
+ sharedQueue.Enqueue(localData.Queue.Dequeue());
+ itemsReturned ++;
+ }
+ }
+
+ // If the shared pool could not accomodate all returnLimit items,
+ // next time we try to return we will just dispose the item
+ // instead of trying to return them to the shared queue.
+ // This is to guarantee we won't be accessing the shared queue too often.
+ localData.DisposeBudget = returnLimit - itemsReturned;
+
+ if (itemsReturned == 0)
+ {
+ localData.DisposeBudget --;
+ item.Dispose();
+ }
+ }
+
+ public void Dispose()
+ {
+ lock (myLock)
+ {
+ if (!disposed)
+ {
+ disposed = true;
+
+ while (sharedQueue.Count > 0)
+ {
+ sharedQueue.Dequeue().Dispose();
+ }
+ }
+ }
+ }
+
+ class ThreadLocalData
+ {
+ public ThreadLocalData(int capacity)
+ {
+ this.Queue = new Queue<T>(capacity);
+ }
+
+ public Queue<T> Queue { get; }
+ public int CreateBudget { get; set; }
+ public int DisposeBudget { get; set; }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs
index 3c94b602c0..8ddda9be5c 100644
--- a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs
+++ b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs
@@ -68,8 +68,8 @@ namespace Grpc.Core.Internal
GrpcPreconditions.CheckArgument(poolSize >= completionQueueCount,
"Thread pool size cannot be smaller than the number of completion queues used.");
- this.runCompletionQueueEventCallbackSuccess = new WaitCallback((callback) => RunCompletionQueueEventCallback((OpCompletionDelegate) callback, true));
- this.runCompletionQueueEventCallbackFailure = new WaitCallback((callback) => RunCompletionQueueEventCallback((OpCompletionDelegate) callback, false));
+ this.runCompletionQueueEventCallbackSuccess = new WaitCallback((callback) => RunCompletionQueueEventCallback((IOpCompletionCallback) callback, true));
+ this.runCompletionQueueEventCallbackFailure = new WaitCallback((callback) => RunCompletionQueueEventCallback((IOpCompletionCallback) callback, false));
}
public void Start()
@@ -176,10 +176,10 @@ namespace Grpc.Core.Internal
try
{
var callback = cq.CompletionRegistry.Extract(tag);
- // Use cached delegates to avoid unnecessary allocations
+ queuedContinuationCounter.Increment();
if (!inlineHandlers)
{
- queuedContinuationCounter.Increment();
+ // Use cached delegates to avoid unnecessary allocations
ThreadPool.QueueUserWorkItem(success ? runCompletionQueueEventCallbackSuccess : runCompletionQueueEventCallbackFailure, callback);
}
else
@@ -219,17 +219,17 @@ namespace Grpc.Core.Internal
var list = new List<CompletionQueueSafeHandle>();
for (int i = 0; i < completionQueueCount; i++)
{
- var completionRegistry = new CompletionRegistry(environment);
+ var completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => environment.RequestCallContextPool.Lease());
list.Add(CompletionQueueSafeHandle.CreateAsync(completionRegistry));
}
return list.AsReadOnly();
}
- private void RunCompletionQueueEventCallback(OpCompletionDelegate callback, bool success)
+ private void RunCompletionQueueEventCallback(IOpCompletionCallback callback, bool success)
{
try
{
- callback(success);
+ callback.OnComplete(success);
}
catch (Exception e)
{
diff --git a/src/csharp/Grpc.Core/Internal/INativeCall.cs b/src/csharp/Grpc.Core/Internal/INativeCall.cs
index f9c06583c8..5c35b2ba46 100644
--- a/src/csharp/Grpc.Core/Internal/INativeCall.cs
+++ b/src/csharp/Grpc.Core/Internal/INativeCall.cs
@@ -20,18 +20,41 @@ using Grpc.Core;
namespace Grpc.Core.Internal
{
- internal delegate void UnaryResponseClientHandler(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders);
+ internal interface IUnaryResponseClientCallback
+ {
+ void OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders);
+ }
// Received status for streaming response calls.
- internal delegate void ReceivedStatusOnClientHandler(bool success, ClientSideStatus receivedStatus);
+ internal interface IReceivedStatusOnClientCallback
+ {
+ void OnReceivedStatusOnClient(bool success, ClientSideStatus receivedStatus);
+ }
- internal delegate void ReceivedMessageHandler(bool success, byte[] receivedMessage);
+ internal interface IReceivedMessageCallback
+ {
+ void OnReceivedMessage(bool success, byte[] receivedMessage);
+ }
- internal delegate void ReceivedResponseHeadersHandler(bool success, Metadata responseHeaders);
+ internal interface IReceivedResponseHeadersCallback
+ {
+ void OnReceivedResponseHeaders(bool success, Metadata responseHeaders);
+ }
- internal delegate void SendCompletionHandler(bool success);
+ internal interface ISendCompletionCallback
+ {
+ void OnSendCompletion(bool success);
+ }
- internal delegate void ReceivedCloseOnServerHandler(bool success, bool cancelled);
+ internal interface ISendStatusFromServerCompletionCallback
+ {
+ void OnSendStatusFromServerCompletion(bool success);
+ }
+
+ internal interface IReceivedCloseOnServerCallback
+ {
+ void OnReceivedCloseOnServer(bool success, bool cancelled);
+ }
/// <summary>
/// Abstraction of a native call object.
@@ -44,28 +67,28 @@ namespace Grpc.Core.Internal
string GetPeer();
- void StartUnary(UnaryResponseClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
+ void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
- void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
+ void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
- void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
+ void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
- void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
+ void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags);
- void StartReceiveMessage(ReceivedMessageHandler callback);
+ void StartReceiveMessage(IReceivedMessageCallback callback);
- void StartReceiveInitialMetadata(ReceivedResponseHeadersHandler callback);
+ void StartReceiveInitialMetadata(IReceivedResponseHeadersCallback callback);
- void StartSendInitialMetadata(SendCompletionHandler callback, MetadataArraySafeHandle metadataArray);
+ void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray);
- void StartSendMessage(SendCompletionHandler callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata);
+ void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata);
- void StartSendCloseFromClient(SendCompletionHandler callback);
+ void StartSendCloseFromClient(ISendCompletionCallback callback);
- void StartSendStatusFromServer(SendCompletionHandler callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags);
+ void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags);
- void StartServerSide(ReceivedCloseOnServerHandler callback);
+ void StartServerSide(IReceivedCloseOnServerCallback callback);
}
}
diff --git a/src/node/test/test_service.proto b/src/csharp/Grpc.Core/Internal/IObjectPool.cs
index b16dfecca7..f7d6e30a2a 100644
--- a/src/node/test/test_service.proto
+++ b/src/csharp/Grpc.Core/Internal/IObjectPool.cs
@@ -1,4 +1,6 @@
-// Copyright 2015 gRPC authors.
+#region Copyright notice and license
+
+// 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.
@@ -12,26 +14,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-syntax = "proto3";
-
-message Request {
- bool error = 1;
-}
-
-message Response {
- int32 count = 1;
-}
-
-service TestService {
- rpc Unary (Request) returns (Response) {
- }
-
- rpc ClientStream (stream Request) returns (Response) {
- }
+#endregion
- rpc ServerStream (Request) returns (stream Response) {
- }
+using System;
+using System.Threading;
+using System.Collections.Generic;
+using Grpc.Core.Utils;
- rpc BidiStream (stream Request) returns (stream Response) {
- }
+namespace Grpc.Core.Internal
+{
+ /// <summary>
+ /// Pool of objects.
+ /// </summary>
+ internal interface IObjectPool<T> : IDisposable
+ where T : class
+ {
+ T Lease();
+ void Return(T item);
+ }
}
diff --git a/src/node/test/test_messages.proto b/src/csharp/Grpc.Core/Internal/IPooledObject.cs
index da1ef5658d..e20bd51dce 100644
--- a/src/node/test/test_messages.proto
+++ b/src/csharp/Grpc.Core/Internal/IPooledObject.cs
@@ -1,4 +1,6 @@
-// Copyright 2015 gRPC authors.
+#region Copyright notice and license
+
+// 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.
@@ -12,34 +14,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-syntax = "proto3";
-
-message LongValues {
- int64 int_64 = 1;
- uint64 uint_64 = 2;
- sint64 sint_64 = 3;
- fixed64 fixed_64 = 4;
- sfixed64 sfixed_64 = 5;
-}
-
-message SequenceValues {
- bytes bytes_field = 1;
- repeated int32 repeated_field = 2;
-}
-
-message OneOfValues {
- oneof oneof_choice {
- int32 int_choice = 1;
- string string_choice = 2;
- }
-}
+#endregion
-enum TestEnum {
- ZERO = 0;
- ONE = 1;
- TWO = 2;
-}
+using System;
-message EnumValues {
- TestEnum enum_value = 1;
+namespace Grpc.Core.Internal
+{
+ /// <summary>
+ /// An object that can be pooled in <c>IObjectPool</c>.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ internal interface IPooledObject<T> : IDisposable
+ {
+ /// <summary>
+ /// Set the action that will be invoked to return a leased object to the pool.
+ /// </summary>
+ void SetReturnToPoolAction(Action<T> returnAction);
+ }
}
diff --git a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
index b56bdbb23f..4d695e8850 100644
--- a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
@@ -27,7 +27,8 @@ namespace Grpc.Core.Internal
internal class NativeMetadataCredentialsPlugin
{
- const string GetMetadataExceptionMsg = "Exception occured in metadata credentials plugin.";
+ const string GetMetadataExceptionStatusMsg = "Exception occurred in metadata credentials plugin.";
+ const string GetMetadataExceptionLogMsg = GetMetadataExceptionStatusMsg + " This is likely not a problem with gRPC itself. Please verify that the code supplying the metadata (usually an authentication token) works correctly.";
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<NativeMetadataCredentialsPlugin>();
static readonly NativeMethods Native = NativeMethods.Get();
@@ -61,17 +62,14 @@ namespace Grpc.Core.Internal
try
{
- var context = new AuthInterceptorContext(Marshal.PtrToStringAnsi(serviceUrlPtr),
- Marshal.PtrToStringAnsi(methodNamePtr));
- // Don't await, we are in a native callback and need to return.
- #pragma warning disable 4014
- GetMetadataAsync(context, callbackPtr, userDataPtr);
- #pragma warning restore 4014
+ var context = new AuthInterceptorContext(Marshal.PtrToStringAnsi(serviceUrlPtr), Marshal.PtrToStringAnsi(methodNamePtr));
+ // Make a guarantee that credentials_notify_from_plugin is invoked async to be compliant with c-core API.
+ ThreadPool.QueueUserWorkItem(async (stateInfo) => await GetMetadataAsync(context, callbackPtr, userDataPtr));
}
catch (Exception e)
{
- Native.grpcsharp_metadata_credentials_notify_from_plugin(callbackPtr, userDataPtr, MetadataArraySafeHandle.Create(Metadata.Empty), StatusCode.Unknown, GetMetadataExceptionMsg);
- Logger.Error(e, GetMetadataExceptionMsg);
+ Native.grpcsharp_metadata_credentials_notify_from_plugin(callbackPtr, userDataPtr, MetadataArraySafeHandle.Create(Metadata.Empty), StatusCode.Unknown, GetMetadataExceptionStatusMsg);
+ Logger.Error(e, GetMetadataExceptionLogMsg);
}
}
@@ -89,8 +87,8 @@ namespace Grpc.Core.Internal
}
catch (Exception e)
{
- Native.grpcsharp_metadata_credentials_notify_from_plugin(callbackPtr, userDataPtr, MetadataArraySafeHandle.Create(Metadata.Empty), StatusCode.Unknown, GetMetadataExceptionMsg);
- Logger.Error(e, GetMetadataExceptionMsg);
+ Native.grpcsharp_metadata_credentials_notify_from_plugin(callbackPtr, userDataPtr, MetadataArraySafeHandle.Create(Metadata.Empty), StatusCode.Unknown, GetMetadataExceptionStatusMsg);
+ Logger.Error(e, GetMetadataExceptionLogMsg);
}
}
}
diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.cs
index 22faa19d9b..8b15c2690f 100644
--- a/src/csharp/Grpc.Core/Internal/NativeMethods.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeMethods.cs
@@ -29,6 +29,8 @@ using Grpc.Core.Utils;
namespace Grpc.Core.Internal
{
+ internal delegate void NativeCallbackTestDelegate(bool success);
+
/// <summary>
/// Provides access to all native methods provided by <c>NativeExtension</c>.
/// An extra level of indirection is added to P/Invoke calls to allow intelligent loading
@@ -50,6 +52,7 @@ namespace Grpc.Core.Internal
public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate grpcsharp_batch_context_recv_status_on_client_details;
public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate grpcsharp_batch_context_recv_status_on_client_trailing_metadata;
public readonly Delegates.grpcsharp_batch_context_recv_close_on_server_cancelled_delegate grpcsharp_batch_context_recv_close_on_server_cancelled;
+ public readonly Delegates.grpcsharp_batch_context_reset_delegate grpcsharp_batch_context_reset;
public readonly Delegates.grpcsharp_batch_context_destroy_delegate grpcsharp_batch_context_destroy;
public readonly Delegates.grpcsharp_request_call_context_create_delegate grpcsharp_request_call_context_create;
@@ -58,6 +61,7 @@ namespace Grpc.Core.Internal
public readonly Delegates.grpcsharp_request_call_context_host_delegate grpcsharp_request_call_context_host;
public readonly Delegates.grpcsharp_request_call_context_deadline_delegate grpcsharp_request_call_context_deadline;
public readonly Delegates.grpcsharp_request_call_context_request_metadata_delegate grpcsharp_request_call_context_request_metadata;
+ public readonly Delegates.grpcsharp_request_call_context_reset_delegate grpcsharp_request_call_context_reset;
public readonly Delegates.grpcsharp_request_call_context_destroy_delegate grpcsharp_request_call_context_destroy;
public readonly Delegates.grpcsharp_composite_call_credentials_create_delegate grpcsharp_composite_call_credentials_create;
@@ -167,6 +171,7 @@ namespace Grpc.Core.Internal
this.grpcsharp_batch_context_recv_status_on_client_details = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate>(library);
this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate>(library);
this.grpcsharp_batch_context_recv_close_on_server_cancelled = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_close_on_server_cancelled_delegate>(library);
+ this.grpcsharp_batch_context_reset = GetMethodDelegate<Delegates.grpcsharp_batch_context_reset_delegate>(library);
this.grpcsharp_batch_context_destroy = GetMethodDelegate<Delegates.grpcsharp_batch_context_destroy_delegate>(library);
this.grpcsharp_request_call_context_create = GetMethodDelegate<Delegates.grpcsharp_request_call_context_create_delegate>(library);
@@ -175,6 +180,7 @@ namespace Grpc.Core.Internal
this.grpcsharp_request_call_context_host = GetMethodDelegate<Delegates.grpcsharp_request_call_context_host_delegate>(library);
this.grpcsharp_request_call_context_deadline = GetMethodDelegate<Delegates.grpcsharp_request_call_context_deadline_delegate>(library);
this.grpcsharp_request_call_context_request_metadata = GetMethodDelegate<Delegates.grpcsharp_request_call_context_request_metadata_delegate>(library);
+ this.grpcsharp_request_call_context_reset = GetMethodDelegate<Delegates.grpcsharp_request_call_context_reset_delegate>(library);
this.grpcsharp_request_call_context_destroy = GetMethodDelegate<Delegates.grpcsharp_request_call_context_destroy_delegate>(library);
this.grpcsharp_composite_call_credentials_create = GetMethodDelegate<Delegates.grpcsharp_composite_call_credentials_create_delegate>(library);
@@ -309,6 +315,7 @@ namespace Grpc.Core.Internal
public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_details_delegate(BatchContextSafeHandle ctx, out UIntPtr detailsLength);
public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate(BatchContextSafeHandle ctx);
public delegate int grpcsharp_batch_context_recv_close_on_server_cancelled_delegate(BatchContextSafeHandle ctx);
+ public delegate void grpcsharp_batch_context_reset_delegate(BatchContextSafeHandle ctx);
public delegate void grpcsharp_batch_context_destroy_delegate(IntPtr ctx);
public delegate RequestCallContextSafeHandle grpcsharp_request_call_context_create_delegate();
@@ -317,6 +324,7 @@ namespace Grpc.Core.Internal
public delegate IntPtr grpcsharp_request_call_context_host_delegate(RequestCallContextSafeHandle ctx, out UIntPtr hostLength);
public delegate Timespec grpcsharp_request_call_context_deadline_delegate(RequestCallContextSafeHandle ctx);
public delegate IntPtr grpcsharp_request_call_context_request_metadata_delegate(RequestCallContextSafeHandle ctx);
+ public delegate void grpcsharp_request_call_context_reset_delegate(RequestCallContextSafeHandle ctx);
public delegate void grpcsharp_request_call_context_destroy_delegate(IntPtr ctx);
public delegate CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create_delegate(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2);
@@ -420,7 +428,7 @@ namespace Grpc.Core.Internal
public delegate Timespec gprsharp_convert_clock_type_delegate(Timespec t, ClockType targetClock);
public delegate int gprsharp_sizeof_timespec_delegate();
- public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback);
+ public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback);
public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr);
public delegate void grpcsharp_test_override_method_delegate(string methodName, string variant);
}
diff --git a/src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs b/src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs
index b7af0c102d..ebc2d6d8d6 100644
--- a/src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs
@@ -19,15 +19,19 @@
using System;
using System.Runtime.InteropServices;
using Grpc.Core;
+using Grpc.Core.Logging;
+using Grpc.Core.Utils;
namespace Grpc.Core.Internal
{
/// <summary>
/// grpcsharp_request_call_context
/// </summary>
- internal class RequestCallContextSafeHandle : SafeHandleZeroIsInvalid
+ internal class RequestCallContextSafeHandle : SafeHandleZeroIsInvalid, IOpCompletionCallback, IPooledObject<RequestCallContextSafeHandle>
{
static readonly NativeMethods Native = NativeMethods.Get();
+ static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<RequestCallContextSafeHandle>();
+ Action<RequestCallContextSafeHandle> returnToPoolAction;
private RequestCallContextSafeHandle()
{
@@ -35,7 +39,8 @@ namespace Grpc.Core.Internal
public static RequestCallContextSafeHandle Create()
{
- return Native.grpcsharp_request_call_context_create();
+ var ctx = Native.grpcsharp_request_call_context_create();
+ return ctx;
}
public IntPtr Handle
@@ -46,6 +51,14 @@ namespace Grpc.Core.Internal
}
}
+ public void SetReturnToPoolAction(Action<RequestCallContextSafeHandle> returnAction)
+ {
+ GrpcPreconditions.CheckState(returnToPoolAction == null);
+ returnToPoolAction = returnAction;
+ }
+
+ public RequestCallCompletionDelegate CompletionCallback { get; set; }
+
// Gets data of server_rpc_new completion.
public ServerRpcNew GetServerRpcNew(Server server)
{
@@ -67,10 +80,45 @@ namespace Grpc.Core.Internal
return new ServerRpcNew(server, call, method, host, deadline, metadata);
}
+ public void Recycle()
+ {
+ if (returnToPoolAction != null)
+ {
+ Native.grpcsharp_request_call_context_reset(this);
+
+ var origReturnAction = returnToPoolAction;
+ // Not clearing all the references to the pool could prevent garbage collection of the pool object
+ // and thus cause memory leaks.
+ returnToPoolAction = null;
+ origReturnAction(this);
+ }
+ else
+ {
+ Dispose();
+ }
+ }
+
protected override bool ReleaseHandle()
{
Native.grpcsharp_request_call_context_destroy(handle);
return true;
}
+
+ void IOpCompletionCallback.OnComplete(bool success)
+ {
+ try
+ {
+ CompletionCallback(success, this);
+ }
+ catch (Exception e)
+ {
+ Logger.Error(e, "Exception occured while invoking request call completion delegate.");
+ }
+ finally
+ {
+ CompletionCallback = null;
+ Recycle();
+ }
+ }
}
}
diff --git a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
index 6019f8e793..98995a0862 100644
--- a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
@@ -60,7 +60,7 @@ namespace Grpc.Core.Internal
var responseStream = new ServerResponseStream<TRequest, TResponse>(asyncCall);
Status status;
- Tuple<TResponse,WriteFlags> responseTuple = null;
+ AsyncCallServer<TRequest,TResponse>.ResponseWithFlags? responseWithFlags = null;
var context = HandlerUtils.NewContext(newRpc, responseStream, asyncCall.CancellationToken);
try
{
@@ -68,7 +68,7 @@ namespace Grpc.Core.Internal
var request = requestStream.Current;
var response = await handler(request, context).ConfigureAwait(false);
status = context.Status;
- responseTuple = Tuple.Create(response, HandlerUtils.GetWriteFlags(context.WriteOptions));
+ responseWithFlags = new AsyncCallServer<TRequest, TResponse>.ResponseWithFlags(response, HandlerUtils.GetWriteFlags(context.WriteOptions));
}
catch (Exception e)
{
@@ -80,7 +80,7 @@ namespace Grpc.Core.Internal
}
try
{
- await asyncCall.SendStatusFromServerAsync(status, context.ResponseTrailers, responseTuple).ConfigureAwait(false);
+ await asyncCall.SendStatusFromServerAsync(status, context.ResponseTrailers, responseWithFlags).ConfigureAwait(false);
}
catch (Exception)
{
@@ -177,13 +177,13 @@ namespace Grpc.Core.Internal
var responseStream = new ServerResponseStream<TRequest, TResponse>(asyncCall);
Status status;
- Tuple<TResponse,WriteFlags> responseTuple = null;
+ AsyncCallServer<TRequest, TResponse>.ResponseWithFlags? responseWithFlags = null;
var context = HandlerUtils.NewContext(newRpc, responseStream, asyncCall.CancellationToken);
try
{
var response = await handler(requestStream, context).ConfigureAwait(false);
status = context.Status;
- responseTuple = Tuple.Create(response, HandlerUtils.GetWriteFlags(context.WriteOptions));
+ responseWithFlags = new AsyncCallServer<TRequest, TResponse>.ResponseWithFlags(response, HandlerUtils.GetWriteFlags(context.WriteOptions));
}
catch (Exception e)
{
@@ -196,7 +196,7 @@ namespace Grpc.Core.Internal
try
{
- await asyncCall.SendStatusFromServerAsync(status, context.ResponseTrailers, responseTuple).ConfigureAwait(false);
+ await asyncCall.SendStatusFromServerAsync(status, context.ResponseTrailers, responseWithFlags).ConfigureAwait(false);
}
catch (Exception)
{
diff --git a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
index c65b960afb..058dddb7eb 100644
--- a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs
@@ -49,13 +49,14 @@ namespace Grpc.Core.Internal
public async Task<bool> MoveNext(CancellationToken token)
{
- if (token != CancellationToken.None)
+
+ var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null;
+ using (cancellationTokenRegistration)
{
- throw new InvalidOperationException("Cancellation of individual reads is not supported.");
+ var result = await call.ReadMessageAsync().ConfigureAwait(false);
+ this.current = result;
+ return result != null;
}
- var result = await call.ReadMessageAsync().ConfigureAwait(false);
- this.current = result;
- return result != null;
}
public void Dispose()
diff --git a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs
index 63000e9a22..56dda9cff5 100644
--- a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs
@@ -59,13 +59,14 @@ namespace Grpc.Core.Internal
{
Native.grpcsharp_server_start(this);
}
-
+
public void ShutdownAndNotify(BatchCompletionDelegate callback, CompletionQueueSafeHandle completionQueue)
{
using (completionQueue.NewScope())
{
- var ctx = BatchContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
+ // TODO(jtattermusch): delegate allocation by caller can be avoided by utilizing the "state" object,
+ // but server shutdown isn't worth optimizing right now.
+ var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(callback, null);
Native.grpcsharp_server_shutdown_and_notify_callback(this, completionQueue, ctx);
}
}
@@ -74,8 +75,7 @@ namespace Grpc.Core.Internal
{
using (completionQueue.NewScope())
{
- var ctx = RequestCallContextSafeHandle.Create();
- completionQueue.CompletionRegistry.RegisterRequestCallCompletion(ctx, callback);
+ var ctx = completionQueue.CompletionRegistry.RegisterRequestCallCompletion(callback);
Native.grpcsharp_server_request_call(this, completionQueue, ctx).CheckOk();
}
}
diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs
index 77ad876bdf..60dacbf126 100644
--- a/src/csharp/Grpc.Core/Server.cs
+++ b/src/csharp/Grpc.Core/Server.cs
@@ -300,6 +300,7 @@ namespace Grpc.Core
{
if (!shutdownRequested)
{
+ // TODO(jtattermusch): avoid unnecessary delegate allocation
handle.RequestCall((success, ctx) => HandleNewServerRpc(success, ctx, cq), cq);
}
}
@@ -387,7 +388,7 @@ namespace Grpc.Core
/// <summary>
/// Handles native callback.
/// </summary>
- private void HandleServerShutdown(bool success, BatchContextSafeHandle ctx)
+ private void HandleServerShutdown(bool success, BatchContextSafeHandle ctx, object state)
{
shutdownTcs.SetResult(null);
}
diff --git a/src/csharp/Grpc.Core/SourceLink.csproj.include b/src/csharp/Grpc.Core/SourceLink.csproj.include
new file mode 100755
index 0000000000..02ae79fb89
--- /dev/null
+++ b/src/csharp/Grpc.Core/SourceLink.csproj.include
@@ -0,0 +1,19 @@
+<!-- Ensure that debugging of the resulting NuGet packages work (we're using SourceLink). -->
+<Project>
+
+ <ItemGroup Label="dotnet pack instructions">
+ <Content Include="$(OutputPath)netstandard1.5\$(PackageId).pdb">
+ <Pack>true</Pack>
+ <PackagePath>lib/netstandard1.5</PackagePath>
+ </Content>
+ <Content Include="$(OutputPath)net45\$(PackageId).pdb">
+ <Pack>true</Pack>
+ <PackagePath>lib/net45</PackagePath>
+ </Content>
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.7.3" PrivateAssets="all" />
+ </ItemGroup>
+
+</Project>
diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include
index 124ecab14c..539d3a9f80 100755
--- a/src/csharp/Grpc.Core/Version.csproj.include
+++ b/src/csharp/Grpc.Core/Version.csproj.include
@@ -1,7 +1,7 @@
<!-- This file is generated -->
<Project>
<PropertyGroup>
- <GrpcCsharpVersion>1.7.0-dev</GrpcCsharpVersion>
+ <GrpcCsharpVersion>1.10.0-dev</GrpcCsharpVersion>
<GoogleProtobufVersion>3.3.0</GoogleProtobufVersion>
</PropertyGroup>
</Project>
diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs
index 588cc84516..f1aef46c6c 100644
--- a/src/csharp/Grpc.Core/VersionInfo.cs
+++ b/src/csharp/Grpc.Core/VersionInfo.cs
@@ -33,11 +33,11 @@ namespace Grpc.Core
/// <summary>
/// Current <c>AssemblyFileVersion</c> of gRPC C# assemblies
/// </summary>
- public const string CurrentAssemblyFileVersion = "1.7.0.0";
+ public const string CurrentAssemblyFileVersion = "1.10.0.0";
/// <summary>
/// Current version of gRPC C#
/// </summary>
- public const string CurrentVersion = "1.7.0-dev";
+ public const string CurrentVersion = "1.10.0-dev";
}
}
diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs
index 4ed414400d..e29b1087e4 100644
--- a/src/csharp/Grpc.Examples/MathGrpc.cs
+++ b/src/csharp/Grpc.Examples/MathGrpc.cs
@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: math/math.proto
+// <auto-generated>
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: math/math.proto
+// </auto-generated>
// Original file comments:
// Copyright 2015 gRPC authors.
//
diff --git a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj
index 681719d124..da61253455 100755
--- a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj
+++ b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj
@@ -14,12 +14,12 @@
<PackageTags>gRPC health check</PackageTags>
<PackageProjectUrl>https://github.com/grpc/grpc</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</PackageLicenseUrl>
- <IncludeSymbols>true</IncludeSymbols>
- <IncludeSource>true</IncludeSource>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
+ <Import Project="..\Grpc.Core\SourceLink.csproj.include" />
+
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs" />
</ItemGroup>
diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
index 3e8eb34689..24a7259979 100644
--- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
+++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: grpc/health/v1/health.proto
+// <auto-generated>
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: grpc/health/v1/health.proto
+// </auto-generated>
// Original file comments:
// Copyright 2015 gRPC authors.
//
diff --git a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
index 60696b62d9..9d41d34414 100644
--- a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
@@ -72,7 +72,7 @@ namespace Grpc.IntegrationTesting
Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value");
}
- var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams);
+ var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams, config.ChannelArgs);
return new ClientRunnerImpl(channels,
config.ClientType,
@@ -84,19 +84,20 @@ namespace Grpc.IntegrationTesting
() => GetNextProfiler());
}
- private static List<Channel> CreateChannels(int clientChannels, IEnumerable<string> serverTargets, SecurityParams securityParams)
+ private static List<Channel> CreateChannels(int clientChannels, IEnumerable<string> serverTargets, SecurityParams securityParams, IEnumerable<ChannelArg> channelArguments)
{
GrpcPreconditions.CheckArgument(clientChannels > 0, "clientChannels needs to be at least 1.");
GrpcPreconditions.CheckArgument(serverTargets.Count() > 0, "at least one serverTarget needs to be specified.");
var credentials = securityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure;
- List<ChannelOption> channelOptions = null;
+ var channelOptions = new List<ChannelOption>();
if (securityParams != null && securityParams.ServerHostOverride != "")
{
- channelOptions = new List<ChannelOption>
- {
- new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride)
- };
+ channelOptions.Add(new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride));
+ }
+ foreach (var channelArgument in channelArguments)
+ {
+ channelOptions.Add(channelArgument.ToChannelOption());
}
var result = new List<Channel>();
@@ -130,7 +131,7 @@ namespace Grpc.IntegrationTesting
readonly List<Task> runnerTasks;
readonly CancellationTokenSource stoppedCts = new CancellationTokenSource();
- readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch();
+ readonly TimeStats timeStats = new TimeStats();
readonly AtomicCounter statsResetCount = new AtomicCounter();
public ClientRunnerImpl(List<Channel> channels, ClientType clientType, RpcType rpcType, int outstandingRpcsPerChannel, LoadParams loadParams, PayloadConfig payloadConfig, HistogramParams histogramParams, Func<BasicProfiler> profilerFactory)
@@ -164,7 +165,7 @@ namespace Grpc.IntegrationTesting
hist.GetSnapshot(histogramData, reset);
}
- var secondsElapsed = wallClockStopwatch.GetElapsedSnapshot(reset).TotalSeconds;
+ var timeSnapshot = timeStats.GetSnapshot(reset);
if (reset)
{
@@ -172,15 +173,14 @@ namespace Grpc.IntegrationTesting
}
GrpcEnvironment.Logger.Info("[ClientRunnerImpl.GetStats] GC collection counts: gen0 {0}, gen1 {1}, gen2 {2}, (histogram reset count:{3}, seconds since reset: {4})",
- GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2), statsResetCount.Count, secondsElapsed);
+ GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2), statsResetCount.Count, timeSnapshot.WallClockTime.TotalSeconds);
- // TODO: populate user time and system time
return new ClientStats
{
Latencies = histogramData,
- TimeElapsed = secondsElapsed,
- TimeUser = 0,
- TimeSystem = 0
+ TimeElapsed = timeSnapshot.WallClockTime.TotalSeconds,
+ TimeUser = timeSnapshot.UserProcessorTime.TotalSeconds,
+ TimeSystem = timeSnapshot.PrivilegedProcessorTime.TotalSeconds
};
}
diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs
index b15da8b8e5..8e5da7b9f2 100644
--- a/src/csharp/Grpc.IntegrationTesting/Control.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Control.cs
@@ -522,10 +522,16 @@ namespace Grpc.Testing {
}
switch (other.LoadCase) {
case LoadOneofCase.ClosedLoop:
- ClosedLoop = other.ClosedLoop;
+ if (ClosedLoop == null) {
+ ClosedLoop = new global::Grpc.Testing.ClosedLoopParams();
+ }
+ ClosedLoop.MergeFrom(other.ClosedLoop);
break;
case LoadOneofCase.Poisson:
- Poisson = other.Poisson;
+ if (Poisson == null) {
+ Poisson = new global::Grpc.Testing.PoissonParams();
+ }
+ Poisson.MergeFrom(other.Poisson);
break;
}
@@ -1901,10 +1907,16 @@ namespace Grpc.Testing {
}
switch (other.ArgtypeCase) {
case ArgtypeOneofCase.Setup:
- Setup = other.Setup;
+ if (Setup == null) {
+ Setup = new global::Grpc.Testing.ClientConfig();
+ }
+ Setup.MergeFrom(other.Setup);
break;
case ArgtypeOneofCase.Mark:
- Mark = other.Mark;
+ if (Mark == null) {
+ Mark = new global::Grpc.Testing.Mark();
+ }
+ Mark.MergeFrom(other.Mark);
break;
}
@@ -2508,10 +2520,16 @@ namespace Grpc.Testing {
}
switch (other.ArgtypeCase) {
case ArgtypeOneofCase.Setup:
- Setup = other.Setup;
+ if (Setup == null) {
+ Setup = new global::Grpc.Testing.ServerConfig();
+ }
+ Setup.MergeFrom(other.Setup);
break;
case ArgtypeOneofCase.Mark:
- Mark = other.Mark;
+ if (Mark == null) {
+ Mark = new global::Grpc.Testing.Mark();
+ }
+ Mark.MergeFrom(other.Mark);
break;
}
diff --git a/src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs b/src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs
new file mode 100644
index 0000000000..67f5faed20
--- /dev/null
+++ b/src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs
@@ -0,0 +1,43 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using Grpc.Core;
+using Grpc.Testing;
+
+namespace Grpc.IntegrationTesting
+{
+ /// <summary>
+ /// Helpers for Control.cs
+ /// </summary>
+ public static class ControlExtensions
+ {
+ public static ChannelOption ToChannelOption(this ChannelArg channelArgument)
+ {
+ switch (channelArgument.ValueCase)
+ {
+ case ChannelArg.ValueOneofCase.StrValue:
+ return new ChannelOption(channelArgument.Name, channelArgument.StrValue);
+ case ChannelArg.ValueOneofCase.IntValue:
+ return new ChannelOption(channelArgument.Name, channelArgument.IntValue);
+ default:
+ throw new ArgumentException("Unsupported channel argument value.");
+ }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.IntegrationTesting/CoreStats/Stats.cs b/src/csharp/Grpc.IntegrationTesting/CoreStats/Stats.cs
new file mode 100644
index 0000000000..380294e335
--- /dev/null
+++ b/src/csharp/Grpc.IntegrationTesting/CoreStats/Stats.cs
@@ -0,0 +1,623 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: grpc/core/stats.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace Grpc.Core {
+
+ /// <summary>Holder for reflection information generated from grpc/core/stats.proto</summary>
+ public static partial class StatsReflection {
+
+ #region Descriptor
+ /// <summary>File descriptor for grpc/core/stats.proto</summary>
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static StatsReflection() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "ChVncnBjL2NvcmUvc3RhdHMucHJvdG8SCWdycGMuY29yZSImCgZCdWNrZXQS",
+ "DQoFc3RhcnQYASABKAESDQoFY291bnQYAiABKAQiLwoJSGlzdG9ncmFtEiIK",
+ "B2J1Y2tldHMYASADKAsyES5ncnBjLmNvcmUuQnVja2V0IlsKBk1ldHJpYxIM",
+ "CgRuYW1lGAEgASgJEg8KBWNvdW50GAogASgESAASKQoJaGlzdG9ncmFtGAsg",
+ "ASgLMhQuZ3JwYy5jb3JlLkhpc3RvZ3JhbUgAQgcKBXZhbHVlIisKBVN0YXRz",
+ "EiIKB21ldHJpY3MYASADKAsyES5ncnBjLmNvcmUuTWV0cmljYgZwcm90bzM="));
+ descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Core.Bucket), global::Grpc.Core.Bucket.Parser, new[]{ "Start", "Count" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Core.Histogram), global::Grpc.Core.Histogram.Parser, new[]{ "Buckets" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Core.Metric), global::Grpc.Core.Metric.Parser, new[]{ "Name", "Count", "Histogram" }, new[]{ "Value" }, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Core.Stats), global::Grpc.Core.Stats.Parser, new[]{ "Metrics" }, null, null, null)
+ }));
+ }
+ #endregion
+
+ }
+ #region Messages
+ public sealed partial class Bucket : pb::IMessage<Bucket> {
+ private static readonly pb::MessageParser<Bucket> _parser = new pb::MessageParser<Bucket>(() => new Bucket());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<Bucket> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Core.StatsReflection.Descriptor.MessageTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Bucket() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Bucket(Bucket other) : this() {
+ start_ = other.start_;
+ count_ = other.count_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Bucket Clone() {
+ return new Bucket(this);
+ }
+
+ /// <summary>Field number for the "start" field.</summary>
+ public const int StartFieldNumber = 1;
+ private double start_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public double Start {
+ get { return start_; }
+ set {
+ start_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "count" field.</summary>
+ public const int CountFieldNumber = 2;
+ private ulong count_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ulong Count {
+ get { return count_; }
+ set {
+ count_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as Bucket);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(Bucket other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Start != other.Start) return false;
+ if (Count != other.Count) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Start != 0D) hash ^= Start.GetHashCode();
+ if (Count != 0UL) hash ^= Count.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Start != 0D) {
+ output.WriteRawTag(9);
+ output.WriteDouble(Start);
+ }
+ if (Count != 0UL) {
+ output.WriteRawTag(16);
+ output.WriteUInt64(Count);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Start != 0D) {
+ size += 1 + 8;
+ }
+ if (Count != 0UL) {
+ size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Count);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(Bucket other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Start != 0D) {
+ Start = other.Start;
+ }
+ if (other.Count != 0UL) {
+ Count = other.Count;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 9: {
+ Start = input.ReadDouble();
+ break;
+ }
+ case 16: {
+ Count = input.ReadUInt64();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class Histogram : pb::IMessage<Histogram> {
+ private static readonly pb::MessageParser<Histogram> _parser = new pb::MessageParser<Histogram>(() => new Histogram());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<Histogram> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Core.StatsReflection.Descriptor.MessageTypes[1]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Histogram() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Histogram(Histogram other) : this() {
+ buckets_ = other.buckets_.Clone();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Histogram Clone() {
+ return new Histogram(this);
+ }
+
+ /// <summary>Field number for the "buckets" field.</summary>
+ public const int BucketsFieldNumber = 1;
+ private static readonly pb::FieldCodec<global::Grpc.Core.Bucket> _repeated_buckets_codec
+ = pb::FieldCodec.ForMessage(10, global::Grpc.Core.Bucket.Parser);
+ private readonly pbc::RepeatedField<global::Grpc.Core.Bucket> buckets_ = new pbc::RepeatedField<global::Grpc.Core.Bucket>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Grpc.Core.Bucket> Buckets {
+ get { return buckets_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as Histogram);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(Histogram other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if(!buckets_.Equals(other.buckets_)) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ hash ^= buckets_.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ buckets_.WriteTo(output, _repeated_buckets_codec);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ size += buckets_.CalculateSize(_repeated_buckets_codec);
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(Histogram other) {
+ if (other == null) {
+ return;
+ }
+ buckets_.Add(other.buckets_);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ buckets_.AddEntriesFrom(input, _repeated_buckets_codec);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class Metric : pb::IMessage<Metric> {
+ private static readonly pb::MessageParser<Metric> _parser = new pb::MessageParser<Metric>(() => new Metric());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<Metric> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Core.StatsReflection.Descriptor.MessageTypes[2]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Metric() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Metric(Metric other) : this() {
+ name_ = other.name_;
+ switch (other.ValueCase) {
+ case ValueOneofCase.Count:
+ Count = other.Count;
+ break;
+ case ValueOneofCase.Histogram:
+ Histogram = other.Histogram.Clone();
+ break;
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Metric Clone() {
+ return new Metric(this);
+ }
+
+ /// <summary>Field number for the "name" field.</summary>
+ public const int NameFieldNumber = 1;
+ private string name_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string Name {
+ get { return name_; }
+ set {
+ name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "count" field.</summary>
+ public const int CountFieldNumber = 10;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ulong Count {
+ get { return valueCase_ == ValueOneofCase.Count ? (ulong) value_ : 0UL; }
+ set {
+ value_ = value;
+ valueCase_ = ValueOneofCase.Count;
+ }
+ }
+
+ /// <summary>Field number for the "histogram" field.</summary>
+ public const int HistogramFieldNumber = 11;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Grpc.Core.Histogram Histogram {
+ get { return valueCase_ == ValueOneofCase.Histogram ? (global::Grpc.Core.Histogram) value_ : null; }
+ set {
+ value_ = value;
+ valueCase_ = value == null ? ValueOneofCase.None : ValueOneofCase.Histogram;
+ }
+ }
+
+ private object value_;
+ /// <summary>Enum of possible cases for the "value" oneof.</summary>
+ public enum ValueOneofCase {
+ None = 0,
+ Count = 10,
+ Histogram = 11,
+ }
+ private ValueOneofCase valueCase_ = ValueOneofCase.None;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ValueOneofCase ValueCase {
+ get { return valueCase_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void ClearValue() {
+ valueCase_ = ValueOneofCase.None;
+ value_ = null;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as Metric);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(Metric other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Name != other.Name) return false;
+ if (Count != other.Count) return false;
+ if (!object.Equals(Histogram, other.Histogram)) return false;
+ if (ValueCase != other.ValueCase) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Name.Length != 0) hash ^= Name.GetHashCode();
+ if (valueCase_ == ValueOneofCase.Count) hash ^= Count.GetHashCode();
+ if (valueCase_ == ValueOneofCase.Histogram) hash ^= Histogram.GetHashCode();
+ hash ^= (int) valueCase_;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Name.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Name);
+ }
+ if (valueCase_ == ValueOneofCase.Count) {
+ output.WriteRawTag(80);
+ output.WriteUInt64(Count);
+ }
+ if (valueCase_ == ValueOneofCase.Histogram) {
+ output.WriteRawTag(90);
+ output.WriteMessage(Histogram);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Name.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
+ }
+ if (valueCase_ == ValueOneofCase.Count) {
+ size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Count);
+ }
+ if (valueCase_ == ValueOneofCase.Histogram) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Histogram);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(Metric other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Name.Length != 0) {
+ Name = other.Name;
+ }
+ switch (other.ValueCase) {
+ case ValueOneofCase.Count:
+ Count = other.Count;
+ break;
+ case ValueOneofCase.Histogram:
+ if (Histogram == null) {
+ Histogram = new global::Grpc.Core.Histogram();
+ }
+ Histogram.MergeFrom(other.Histogram);
+ break;
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Name = input.ReadString();
+ break;
+ }
+ case 80: {
+ Count = input.ReadUInt64();
+ break;
+ }
+ case 90: {
+ global::Grpc.Core.Histogram subBuilder = new global::Grpc.Core.Histogram();
+ if (valueCase_ == ValueOneofCase.Histogram) {
+ subBuilder.MergeFrom(Histogram);
+ }
+ input.ReadMessage(subBuilder);
+ Histogram = subBuilder;
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class Stats : pb::IMessage<Stats> {
+ private static readonly pb::MessageParser<Stats> _parser = new pb::MessageParser<Stats>(() => new Stats());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<Stats> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Core.StatsReflection.Descriptor.MessageTypes[3]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Stats() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Stats(Stats other) : this() {
+ metrics_ = other.metrics_.Clone();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Stats Clone() {
+ return new Stats(this);
+ }
+
+ /// <summary>Field number for the "metrics" field.</summary>
+ public const int MetricsFieldNumber = 1;
+ private static readonly pb::FieldCodec<global::Grpc.Core.Metric> _repeated_metrics_codec
+ = pb::FieldCodec.ForMessage(10, global::Grpc.Core.Metric.Parser);
+ private readonly pbc::RepeatedField<global::Grpc.Core.Metric> metrics_ = new pbc::RepeatedField<global::Grpc.Core.Metric>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Grpc.Core.Metric> Metrics {
+ get { return metrics_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as Stats);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(Stats other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if(!metrics_.Equals(other.metrics_)) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ hash ^= metrics_.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ metrics_.WriteTo(output, _repeated_metrics_codec);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ size += metrics_.CalculateSize(_repeated_metrics_codec);
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(Stats other) {
+ if (other == null) {
+ return;
+ }
+ metrics_.Add(other.metrics_);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ metrics_.AddEntriesFrom(input, _repeated_metrics_codec);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs
index b2fe73acdf..9581aded58 100644
--- a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs
+++ b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs
@@ -26,7 +26,7 @@ namespace Grpc.Testing {
"DGdycGMudGVzdGluZyIyCglEZWJ1Z0luZm8SFQoNc3RhY2tfZW50cmllcxgB",
"IAMoCRIOCgZkZXRhaWwYAiABKAkiUAoLRXJyb3JTdGF0dXMSDAoEY29kZRgB",
"IAEoBRIVCg1lcnJvcl9tZXNzYWdlGAIgASgJEhwKFGJpbmFyeV9lcnJvcl9k",
- "ZXRhaWxzGAMgASgJIskDCg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp",
+ "ZXRhaWxzGAMgASgJIuIDCg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp",
"bmUYASABKAgSHgoWY2xpZW50X2NhbmNlbF9hZnRlcl91cxgCIAEoBRIeChZz",
"ZXJ2ZXJfY2FuY2VsX2FmdGVyX3VzGAMgASgFEhUKDWVjaG9fbWV0YWRhdGEY",
"BCABKAgSGgoSY2hlY2tfYXV0aF9jb250ZXh0GAUgASgIEh8KF3Jlc3BvbnNl",
@@ -36,18 +36,19 @@ namespace Grpc.Testing {
"X3R5cGUYCiABKAkSKwoKZGVidWdfaW5mbxgLIAEoCzIXLmdycGMudGVzdGlu",
"Zy5EZWJ1Z0luZm8SEgoKc2VydmVyX2RpZRgMIAEoCBIcChRiaW5hcnlfZXJy",
"b3JfZGV0YWlscxgNIAEoCRIxCg5leHBlY3RlZF9lcnJvchgOIAEoCzIZLmdy",
- "cGMudGVzdGluZy5FcnJvclN0YXR1cyJKCgtFY2hvUmVxdWVzdBIPCgdtZXNz",
- "YWdlGAEgASgJEioKBXBhcmFtGAIgASgLMhsuZ3JwYy50ZXN0aW5nLlJlcXVl",
- "c3RQYXJhbXMiRgoOUmVzcG9uc2VQYXJhbXMSGAoQcmVxdWVzdF9kZWFkbGlu",
- "ZRgBIAEoAxIMCgRob3N0GAIgASgJEgwKBHBlZXIYAyABKAkiTAoMRWNob1Jl",
- "c3BvbnNlEg8KB21lc3NhZ2UYASABKAkSKwoFcGFyYW0YAiABKAsyHC5ncnBj",
- "LnRlc3RpbmcuUmVzcG9uc2VQYXJhbXNiBnByb3RvMw=="));
+ "cGMudGVzdGluZy5FcnJvclN0YXR1cxIXCg9zZXJ2ZXJfc2xlZXBfdXMYDyAB",
+ "KAUiSgoLRWNob1JlcXVlc3QSDwoHbWVzc2FnZRgBIAEoCRIqCgVwYXJhbRgC",
+ "IAEoCzIbLmdycGMudGVzdGluZy5SZXF1ZXN0UGFyYW1zIkYKDlJlc3BvbnNl",
+ "UGFyYW1zEhgKEHJlcXVlc3RfZGVhZGxpbmUYASABKAMSDAoEaG9zdBgCIAEo",
+ "CRIMCgRwZWVyGAMgASgJIkwKDEVjaG9SZXNwb25zZRIPCgdtZXNzYWdlGAEg",
+ "ASgJEisKBXBhcmFtGAIgASgLMhwuZ3JwYy50ZXN0aW5nLlJlc3BvbnNlUGFy",
+ "YW1zYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.DebugInfo), global::Grpc.Testing.DebugInfo.Parser, new[]{ "StackEntries", "Detail" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ErrorStatus), global::Grpc.Testing.ErrorStatus.Parser, new[]{ "Code", "ErrorMessage", "BinaryErrorDetails" }, null, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError", "ServerSleepUs" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoRequest), global::Grpc.Testing.EchoRequest.Parser, new[]{ "Message", "Param" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ResponseParams), global::Grpc.Testing.ResponseParams.Parser, new[]{ "RequestDeadline", "Host", "Peer" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoResponse), global::Grpc.Testing.EchoResponse.Parser, new[]{ "Message", "Param" }, null, null, null)
@@ -411,6 +412,7 @@ namespace Grpc.Testing {
serverDie_ = other.serverDie_;
binaryErrorDetails_ = other.binaryErrorDetails_;
ExpectedError = other.expectedError_ != null ? other.ExpectedError.Clone() : null;
+ serverSleepUs_ = other.serverSleepUs_;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -578,6 +580,20 @@ namespace Grpc.Testing {
}
}
+ /// <summary>Field number for the "server_sleep_us" field.</summary>
+ public const int ServerSleepUsFieldNumber = 15;
+ private int serverSleepUs_;
+ /// <summary>
+ /// Amount to sleep when invoking server
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int ServerSleepUs {
+ get { return serverSleepUs_; }
+ set {
+ serverSleepUs_ = value;
+ }
+ }
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as RequestParams);
@@ -605,6 +621,7 @@ namespace Grpc.Testing {
if (ServerDie != other.ServerDie) return false;
if (BinaryErrorDetails != other.BinaryErrorDetails) return false;
if (!object.Equals(ExpectedError, other.ExpectedError)) return false;
+ if (ServerSleepUs != other.ServerSleepUs) return false;
return true;
}
@@ -625,6 +642,7 @@ namespace Grpc.Testing {
if (ServerDie != false) hash ^= ServerDie.GetHashCode();
if (BinaryErrorDetails.Length != 0) hash ^= BinaryErrorDetails.GetHashCode();
if (expectedError_ != null) hash ^= ExpectedError.GetHashCode();
+ if (ServerSleepUs != 0) hash ^= ServerSleepUs.GetHashCode();
return hash;
}
@@ -691,6 +709,10 @@ namespace Grpc.Testing {
output.WriteRawTag(114);
output.WriteMessage(ExpectedError);
}
+ if (ServerSleepUs != 0) {
+ output.WriteRawTag(120);
+ output.WriteInt32(ServerSleepUs);
+ }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -738,6 +760,9 @@ namespace Grpc.Testing {
if (expectedError_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(ExpectedError);
}
+ if (ServerSleepUs != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(ServerSleepUs);
+ }
return size;
}
@@ -794,6 +819,9 @@ namespace Grpc.Testing {
}
ExpectedError.MergeFrom(other.ExpectedError);
}
+ if (other.ServerSleepUs != 0) {
+ ServerSleepUs = other.ServerSleepUs;
+ }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -866,6 +894,10 @@ namespace Grpc.Testing {
input.ReadMessage(expectedError_);
break;
}
+ case 120: {
+ ServerSleepUs = input.ReadInt32();
+ break;
+ }
}
}
}
diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
index e83a8a7274..10c31c455e 100644
--- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
+++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
@@ -685,7 +685,7 @@ namespace Grpc.IntegrationTesting
private static Metadata CreateClientCompressionMetadata(bool compressed)
{
- var algorithmName = compressed ? "gzip" : "identity";
+ var algorithmName = compressed ? "message/gzip" : "identity";
return new Metadata
{
{ new Metadata.Entry(Metadata.CompressionRequestAlgorithmMetadataKey, algorithmName) }
diff --git a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
index e81157cf97..c83ccd2612 100644
--- a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
@@ -90,6 +90,54 @@ namespace Grpc.IntegrationTesting
}
[Test]
+ public async Task MetadataCredentials_Composed()
+ {
+ var first = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => {
+ // Attempt to exercise the case where async callback is inlineable/synchronously-runnable.
+ metadata.Add("first_authorization", "FIRST_SECRET_TOKEN");
+ return TaskUtils.CompletedTask;
+ }));
+ var second = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => {
+ metadata.Add("second_authorization", "SECOND_SECRET_TOKEN");
+ return TaskUtils.CompletedTask;
+ }));
+ var third = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => {
+ metadata.Add("third_authorization", "THIRD_SECRET_TOKEN");
+ return TaskUtils.CompletedTask;
+ }));
+ var channelCredentials = ChannelCredentials.Create(TestCredentials.CreateSslCredentials(),
+ CallCredentials.Compose(first, second, third));
+ channel = new Channel(Host, server.Ports.Single().BoundPort, channelCredentials, options);
+ var client = new TestService.TestServiceClient(channel);
+ var call = client.StreamingOutputCall(new StreamingOutputCallRequest { });
+ Assert.IsTrue(await call.ResponseStream.MoveNext());
+ Assert.IsFalse(await call.ResponseStream.MoveNext());
+ }
+
+ [Test]
+ public async Task MetadataCredentials_ComposedPerCall()
+ {
+ channel = new Channel(Host, server.Ports.Single().BoundPort, TestCredentials.CreateSslCredentials(), options);
+ var client = new TestService.TestServiceClient(channel);
+ var first = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => {
+ metadata.Add("first_authorization", "FIRST_SECRET_TOKEN");
+ return TaskUtils.CompletedTask;
+ }));
+ var second = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => {
+ metadata.Add("second_authorization", "SECOND_SECRET_TOKEN");
+ return TaskUtils.CompletedTask;
+ }));
+ var third = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => {
+ metadata.Add("third_authorization", "THIRD_SECRET_TOKEN");
+ return TaskUtils.CompletedTask;
+ }));
+ var call = client.StreamingOutputCall(new StreamingOutputCallRequest{ },
+ new CallOptions(credentials: CallCredentials.Compose(first, second, third)));
+ Assert.IsTrue(await call.ResponseStream.MoveNext());
+ Assert.IsFalse(await call.ResponseStream.MoveNext());
+ }
+
+ [Test]
public void MetadataCredentials_InterceptorLeavesMetadataEmpty()
{
var channelCredentials = ChannelCredentials.Create(TestCredentials.CreateSslCredentials(),
@@ -114,7 +162,7 @@ namespace Grpc.IntegrationTesting
client = new TestService.TestServiceClient(channel);
var ex = Assert.Throws<RpcException>(() => client.UnaryCall(new SimpleRequest { }));
- Assert.AreEqual(StatusCode.Unauthenticated, ex.Status.StatusCode);
+ Assert.AreEqual(StatusCode.Unavailable, ex.Status.StatusCode);
}
private class FakeTestService : TestService.TestServiceBase
@@ -125,6 +173,17 @@ namespace Grpc.IntegrationTesting
Assert.AreEqual("SECRET_TOKEN", authToken);
return Task.FromResult(new SimpleResponse());
}
+
+ public override async Task StreamingOutputCall(StreamingOutputCallRequest request, IServerStreamWriter<StreamingOutputCallResponse> responseStream, ServerCallContext context)
+ {
+ var first = context.RequestHeaders.First((entry) => entry.Key == "first_authorization").Value;
+ Assert.AreEqual("FIRST_SECRET_TOKEN", first);
+ var second = context.RequestHeaders.First((entry) => entry.Key == "second_authorization").Value;
+ Assert.AreEqual("SECOND_SECRET_TOKEN", second);
+ var third = context.RequestHeaders.First((entry) => entry.Key == "third_authorization").Value;
+ Assert.AreEqual("THIRD_SECRET_TOKEN", third);
+ await responseStream.WriteAsync(new StreamingOutputCallResponse());
+ }
}
}
}
diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
index 9a664f3539..f71d6d197d 100644
--- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: src/proto/grpc/testing/metrics.proto
+// <auto-generated>
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: src/proto/grpc/testing/metrics.proto
+// </auto-generated>
// Original file comments:
// Copyright 2015-2016 gRPC authors.
//
diff --git a/src/csharp/Grpc.IntegrationTesting/Payloads.cs b/src/csharp/Grpc.IntegrationTesting/Payloads.cs
index f918b9576b..fca8cda6f6 100644
--- a/src/csharp/Grpc.IntegrationTesting/Payloads.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Payloads.cs
@@ -596,13 +596,22 @@ namespace Grpc.Testing {
}
switch (other.PayloadCase) {
case PayloadOneofCase.BytebufParams:
- BytebufParams = other.BytebufParams;
+ if (BytebufParams == null) {
+ BytebufParams = new global::Grpc.Testing.ByteBufferParams();
+ }
+ BytebufParams.MergeFrom(other.BytebufParams);
break;
case PayloadOneofCase.SimpleParams:
- SimpleParams = other.SimpleParams;
+ if (SimpleParams == null) {
+ SimpleParams = new global::Grpc.Testing.SimpleProtoParams();
+ }
+ SimpleParams.MergeFrom(other.SimpleParams);
break;
case PayloadOneofCase.ComplexParams:
- ComplexParams = other.ComplexParams;
+ if (ComplexParams == null) {
+ ComplexParams = new global::Grpc.Testing.ComplexProtoParams();
+ }
+ ComplexParams.MergeFrom(other.ComplexParams);
break;
}
diff --git a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs
index 45bff3aaf8..ea29bd74e5 100644
--- a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs
@@ -78,7 +78,8 @@ namespace Grpc.IntegrationTesting
throw new ArgumentException("Unsupported ServerType");
}
- var server = new Server
+ var channelOptions = new List<ChannelOption>(config.ChannelArgs.Select((arg) => arg.ToChannelOption()));
+ var server = new Server(channelOptions)
{
Services = { service },
Ports = { new ServerPort("[::]", config.Port, credentials) }
@@ -116,7 +117,7 @@ namespace Grpc.IntegrationTesting
public class ServerRunnerImpl : IServerRunner
{
readonly Server server;
- readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch();
+ readonly TimeStats timeStats = new TimeStats();
public ServerRunnerImpl(Server server)
{
@@ -137,17 +138,16 @@ namespace Grpc.IntegrationTesting
/// <returns>The stats.</returns>
public ServerStats GetStats(bool reset)
{
- var secondsElapsed = wallClockStopwatch.GetElapsedSnapshot(reset).TotalSeconds;
+ var timeSnapshot = timeStats.GetSnapshot(reset);
GrpcEnvironment.Logger.Info("[ServerRunner.GetStats] GC collection counts: gen0 {0}, gen1 {1}, gen2 {2}, (seconds since last reset {3})",
- GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2), secondsElapsed);
+ GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2), timeSnapshot.WallClockTime.TotalSeconds);
- // TODO: populate user time and system time
return new ServerStats
{
- TimeElapsed = secondsElapsed,
- TimeUser = 0,
- TimeSystem = 0
+ TimeElapsed = timeSnapshot.WallClockTime.TotalSeconds,
+ TimeUser = timeSnapshot.UserProcessorTime.TotalSeconds,
+ TimeSystem = timeSnapshot.PrivilegedProcessorTime.TotalSeconds
};
}
diff --git a/src/csharp/Grpc.IntegrationTesting/Services.cs b/src/csharp/Grpc.IntegrationTesting/Services.cs
index 7a0845dffb..4b761706ed 100644
--- a/src/csharp/Grpc.IntegrationTesting/Services.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Services.cs
@@ -24,28 +24,27 @@ namespace Grpc.Testing {
string.Concat(
"CiVzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3NlcnZpY2VzLnByb3RvEgxncnBj",
"LnRlc3RpbmcaJXNyYy9wcm90by9ncnBjL3Rlc3RpbmcvbWVzc2FnZXMucHJv",
- "dG8aJHNyYy9wcm90by9ncnBjL3Rlc3RpbmcvY29udHJvbC5wcm90bxoic3Jj",
- "L3Byb3RvL2dycGMvdGVzdGluZy9zdGF0cy5wcm90bzKmAwoQQmVuY2htYXJr",
- "U2VydmljZRJGCglVbmFyeUNhbGwSGy5ncnBjLnRlc3RpbmcuU2ltcGxlUmVx",
- "dWVzdBocLmdycGMudGVzdGluZy5TaW1wbGVSZXNwb25zZRJOCg1TdHJlYW1p",
- "bmdDYWxsEhsuZ3JwYy50ZXN0aW5nLlNpbXBsZVJlcXVlc3QaHC5ncnBjLnRl",
- "c3RpbmcuU2ltcGxlUmVzcG9uc2UoATABElIKE1N0cmVhbWluZ0Zyb21DbGll",
- "bnQSGy5ncnBjLnRlc3RpbmcuU2ltcGxlUmVxdWVzdBocLmdycGMudGVzdGlu",
- "Zy5TaW1wbGVSZXNwb25zZSgBElIKE1N0cmVhbWluZ0Zyb21TZXJ2ZXISGy5n",
- "cnBjLnRlc3RpbmcuU2ltcGxlUmVxdWVzdBocLmdycGMudGVzdGluZy5TaW1w",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bmcuU2ltcGxlUmVxdWVzdBocLmdy",
+ "cGMudGVzdGluZy5TaW1wbGVSZXNwb25zZSgBElIKE1N0cmVhbWluZ0Zyb21T",
+ "ZXJ2ZXISGy5ncnBjLnRlc3RpbmcuU2ltcGxlUmVxdWVzdBocLmdycGMudGVz",
+ "dGluZy5TaW1wbGVSZXNwb25zZTABElIKEVN0cmVhbWluZ0JvdGhXYXlzEhsu",
+ "Z3JwYy50ZXN0aW5nLlNpbXBsZVJlcXVlc3QaHC5ncnBjLnRlc3RpbmcuU2lt",
+ "cGxlUmVzcG9uc2UoATABMpcCCg1Xb3JrZXJTZXJ2aWNlEkUKCVJ1blNlcnZl",
+ "chIYLmdycGMudGVzdGluZy5TZXJ2ZXJBcmdzGhouZ3JwYy50ZXN0aW5nLlNl",
+ "cnZlclN0YXR1cygBMAESRQoJUnVuQ2xpZW50EhguZ3JwYy50ZXN0aW5nLkNs",
+ "aWVudEFyZ3MaGi5ncnBjLnRlc3RpbmcuQ2xpZW50U3RhdHVzKAEwARJCCglD",
+ "b3JlQ291bnQSGS5ncnBjLnRlc3RpbmcuQ29yZVJlcXVlc3QaGi5ncnBjLnRl",
+ "c3RpbmcuQ29yZVJlc3BvbnNlEjQKClF1aXRXb3JrZXISEi5ncnBjLnRlc3Rp",
+ "bmcuVm9pZBoSLmdycGMudGVzdGluZy5Wb2lkMl4KGFJlcG9ydFFwc1NjZW5h",
+ "cmlvU2VydmljZRJCCg5SZXBvcnRTY2VuYXJpbxIcLmdycGMudGVzdGluZy5T",
+ "Y2VuYXJpb1Jlc3VsdBoSLmdycGMudGVzdGluZy5Wb2lkYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
- new pbr::FileDescriptor[] { global::Grpc.Testing.MessagesReflection.Descriptor, global::Grpc.Testing.ControlReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, },
+ new pbr::FileDescriptor[] { global::Grpc.Testing.MessagesReflection.Descriptor, global::Grpc.Testing.ControlReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null));
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs
index bfae4ee6ac..d2e4f2e4a5 100644
--- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs
@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: src/proto/grpc/testing/services.proto
+// <auto-generated>
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: src/proto/grpc/testing/services.proto
+// </auto-generated>
// Original file comments:
// Copyright 2015 gRPC authors.
//
diff --git a/src/csharp/Grpc.IntegrationTesting/Stats.cs b/src/csharp/Grpc.IntegrationTesting/Stats.cs
index 23b56df6bd..e082ae7719 100644
--- a/src/csharp/Grpc.IntegrationTesting/Stats.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Stats.cs
@@ -23,28 +23,30 @@ namespace Grpc.Testing {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CiJzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3N0YXRzLnByb3RvEgxncnBjLnRl",
- "c3RpbmcikQEKC1NlcnZlclN0YXRzEhQKDHRpbWVfZWxhcHNlZBgBIAEoARIR",
- "Cgl0aW1lX3VzZXIYAiABKAESEwoLdGltZV9zeXN0ZW0YAyABKAESFgoOdG90",
- "YWxfY3B1X3RpbWUYBCABKAQSFQoNaWRsZV9jcHVfdGltZRgFIAEoBBIVCg1j",
- "cV9wb2xsX2NvdW50GAYgASgEIjsKD0hpc3RvZ3JhbVBhcmFtcxISCgpyZXNv",
- "bHV0aW9uGAEgASgBEhQKDG1heF9wb3NzaWJsZRgCIAEoASJ3Cg1IaXN0b2dy",
- "YW1EYXRhEg4KBmJ1Y2tldBgBIAMoDRIQCghtaW5fc2VlbhgCIAEoARIQCght",
- "YXhfc2Vlbh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Wx0Q291bnQSEwoLc3RhdHVzX2NvZGUYASABKAUS",
+ "DQoFY291bnQYAiABKAMi8wEKC0NsaWVudFN0YXRzEi4KCWxhdGVuY2llcxgB",
+ "IAEoCzIbLmdycGMudGVzdGluZy5IaXN0b2dyYW1EYXRhEhQKDHRpbWVfZWxh",
+ "cHNlZBgCIAEoARIRCgl0aW1lX3VzZXIYAyABKAESEwoLdGltZV9zeXN0ZW0Y",
+ "BCABKAESOQoPcmVxdWVzdF9yZXN1bHRzGAUgAygLMiAuZ3JwYy50ZXN0aW5n",
+ "LlJlcXVlc3RSZXN1bHRDb3VudBIVCg1jcV9wb2xsX2NvdW50GAYgASgEEiQK",
+ "CmNvcmVfc3RhdHMYByABKAsyEC5ncnBjLmNvcmUuU3RhdHNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
- new pbr::FileDescriptor[] { },
+ new pbr::FileDescriptor[] { global::Grpc.Core.StatsReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
- new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStats), global::Grpc.Testing.ServerStats.Parser, new[]{ "TimeElapsed", "TimeUser", "TimeSystem", "TotalCpuTime", "IdleCpuTime", "CqPollCount" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStats), global::Grpc.Testing.ServerStats.Parser, new[]{ "TimeElapsed", "TimeUser", "TimeSystem", "TotalCpuTime", "IdleCpuTime", "CqPollCount", "CoreStats" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.HistogramParams), global::Grpc.Testing.HistogramParams.Parser, new[]{ "Resolution", "MaxPossible" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.HistogramData), global::Grpc.Testing.HistogramData.Parser, new[]{ "Bucket", "MinSeen", "MaxSeen", "Sum", "SumOfSquares", "Count" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestResultCount), global::Grpc.Testing.RequestResultCount.Parser, new[]{ "StatusCode", "Count" }, null, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStats), global::Grpc.Testing.ClientStats.Parser, new[]{ "Latencies", "TimeElapsed", "TimeUser", "TimeSystem", "RequestResults", "CqPollCount" }, null, null, null)
+ new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStats), global::Grpc.Testing.ClientStats.Parser, new[]{ "Latencies", "TimeElapsed", "TimeUser", "TimeSystem", "RequestResults", "CqPollCount", "CoreStats" }, null, null, null)
}));
}
#endregion
@@ -81,6 +83,7 @@ namespace Grpc.Testing {
totalCpuTime_ = other.totalCpuTime_;
idleCpuTime_ = other.idleCpuTime_;
cqPollCount_ = other.cqPollCount_;
+ CoreStats = other.coreStats_ != null ? other.CoreStats.Clone() : null;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -173,6 +176,20 @@ namespace Grpc.Testing {
}
}
+ /// <summary>Field number for the "core_stats" field.</summary>
+ public const int CoreStatsFieldNumber = 7;
+ private global::Grpc.Core.Stats coreStats_;
+ /// <summary>
+ /// Core library stats
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Grpc.Core.Stats CoreStats {
+ get { return coreStats_; }
+ set {
+ coreStats_ = value;
+ }
+ }
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as ServerStats);
@@ -192,6 +209,7 @@ namespace Grpc.Testing {
if (TotalCpuTime != other.TotalCpuTime) return false;
if (IdleCpuTime != other.IdleCpuTime) return false;
if (CqPollCount != other.CqPollCount) return false;
+ if (!object.Equals(CoreStats, other.CoreStats)) return false;
return true;
}
@@ -204,6 +222,7 @@ namespace Grpc.Testing {
if (TotalCpuTime != 0UL) hash ^= TotalCpuTime.GetHashCode();
if (IdleCpuTime != 0UL) hash ^= IdleCpuTime.GetHashCode();
if (CqPollCount != 0UL) hash ^= CqPollCount.GetHashCode();
+ if (coreStats_ != null) hash ^= CoreStats.GetHashCode();
return hash;
}
@@ -238,6 +257,10 @@ namespace Grpc.Testing {
output.WriteRawTag(48);
output.WriteUInt64(CqPollCount);
}
+ if (coreStats_ != null) {
+ output.WriteRawTag(58);
+ output.WriteMessage(CoreStats);
+ }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -261,6 +284,9 @@ namespace Grpc.Testing {
if (CqPollCount != 0UL) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(CqPollCount);
}
+ if (coreStats_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(CoreStats);
+ }
return size;
}
@@ -287,6 +313,12 @@ namespace Grpc.Testing {
if (other.CqPollCount != 0UL) {
CqPollCount = other.CqPollCount;
}
+ if (other.coreStats_ != null) {
+ if (coreStats_ == null) {
+ coreStats_ = new global::Grpc.Core.Stats();
+ }
+ CoreStats.MergeFrom(other.CoreStats);
+ }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -321,6 +353,13 @@ namespace Grpc.Testing {
CqPollCount = input.ReadUInt64();
break;
}
+ case 58: {
+ if (coreStats_ == null) {
+ coreStats_ = new global::Grpc.Core.Stats();
+ }
+ input.ReadMessage(coreStats_);
+ break;
+ }
}
}
}
@@ -909,6 +948,7 @@ namespace Grpc.Testing {
timeSystem_ = other.timeSystem_;
requestResults_ = other.requestResults_.Clone();
cqPollCount_ = other.cqPollCount_;
+ CoreStats = other.coreStats_ != null ? other.CoreStats.Clone() : null;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -993,6 +1033,20 @@ namespace Grpc.Testing {
}
}
+ /// <summary>Field number for the "core_stats" field.</summary>
+ public const int CoreStatsFieldNumber = 7;
+ private global::Grpc.Core.Stats coreStats_;
+ /// <summary>
+ /// Core library stats
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Grpc.Core.Stats CoreStats {
+ get { return coreStats_; }
+ set {
+ coreStats_ = value;
+ }
+ }
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as ClientStats);
@@ -1012,6 +1066,7 @@ namespace Grpc.Testing {
if (TimeSystem != other.TimeSystem) return false;
if(!requestResults_.Equals(other.requestResults_)) return false;
if (CqPollCount != other.CqPollCount) return false;
+ if (!object.Equals(CoreStats, other.CoreStats)) return false;
return true;
}
@@ -1024,6 +1079,7 @@ namespace Grpc.Testing {
if (TimeSystem != 0D) hash ^= TimeSystem.GetHashCode();
hash ^= requestResults_.GetHashCode();
if (CqPollCount != 0UL) hash ^= CqPollCount.GetHashCode();
+ if (coreStats_ != null) hash ^= CoreStats.GetHashCode();
return hash;
}
@@ -1055,6 +1111,10 @@ namespace Grpc.Testing {
output.WriteRawTag(48);
output.WriteUInt64(CqPollCount);
}
+ if (coreStats_ != null) {
+ output.WriteRawTag(58);
+ output.WriteMessage(CoreStats);
+ }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1076,6 +1136,9 @@ namespace Grpc.Testing {
if (CqPollCount != 0UL) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(CqPollCount);
}
+ if (coreStats_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(CoreStats);
+ }
return size;
}
@@ -1103,6 +1166,12 @@ namespace Grpc.Testing {
if (other.CqPollCount != 0UL) {
CqPollCount = other.CqPollCount;
}
+ if (other.coreStats_ != null) {
+ if (coreStats_ == null) {
+ coreStats_ = new global::Grpc.Core.Stats();
+ }
+ CoreStats.MergeFrom(other.CoreStats);
+ }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1140,6 +1209,13 @@ namespace Grpc.Testing {
CqPollCount = input.ReadUInt64();
break;
}
+ case 58: {
+ if (coreStats_ == null) {
+ coreStats_ = new global::Grpc.Core.Stats();
+ }
+ input.ReadMessage(coreStats_);
+ break;
+ }
}
}
}
diff --git a/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs b/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
index 11956e4ac8..0c62380768 100644
--- a/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
+++ b/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
@@ -243,7 +243,7 @@ namespace Grpc.IntegrationTesting
const string GaugeName = "csharp_overall_qps";
readonly Histogram histogram;
- readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch();
+ readonly TimeStats timeStats = new TimeStats();
public MetricsServiceImpl(Histogram histogram)
{
@@ -280,9 +280,9 @@ namespace Grpc.IntegrationTesting
long GetQpsAndReset()
{
var snapshot = histogram.GetSnapshot(true);
- var elapsedSnapshot = wallClockStopwatch.GetElapsedSnapshot(true);
+ var timeSnapshot = timeStats.GetSnapshot(true);
- return (long) (snapshot.Count / elapsedSnapshot.TotalSeconds);
+ return (long) (snapshot.Count / timeSnapshot.WallClockTime.TotalSeconds);
}
}
}
diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
index b419dd1702..c0d147c150 100644
--- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: src/proto/grpc/testing/test.proto
+// <auto-generated>
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: src/proto/grpc/testing/test.proto
+// </auto-generated>
// Original file comments:
// Copyright 2015-2016 gRPC authors.
//
diff --git a/src/csharp/Grpc.IntegrationTesting/TimeStats.cs b/src/csharp/Grpc.IntegrationTesting/TimeStats.cs
new file mode 100644
index 0000000000..6aba04c194
--- /dev/null
+++ b/src/csharp/Grpc.IntegrationTesting/TimeStats.cs
@@ -0,0 +1,90 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Threading.Tasks;
+using Google.Protobuf;
+using Grpc.Core;
+using Grpc.Core.Utils;
+using NUnit.Framework;
+using Grpc.Testing;
+
+namespace Grpc.IntegrationTesting
+{
+ /// <summary>
+ /// Snapshottable time statistics.
+ /// </summary>
+ public class TimeStats
+ {
+ readonly object myLock = new object();
+ DateTime lastWallClock;
+ TimeSpan lastUserTime;
+ TimeSpan lastPrivilegedTime;
+
+ public TimeStats()
+ {
+ lastWallClock = DateTime.UtcNow;
+ lastUserTime = Process.GetCurrentProcess().UserProcessorTime;
+ lastPrivilegedTime = Process.GetCurrentProcess().PrivilegedProcessorTime;
+ }
+
+ public Snapshot GetSnapshot(bool reset)
+ {
+ lock (myLock)
+ {
+ var wallClock = DateTime.UtcNow;
+ var userTime = Process.GetCurrentProcess().UserProcessorTime;
+ var privilegedTime = Process.GetCurrentProcess().PrivilegedProcessorTime;
+ var snapshot = new Snapshot(wallClock - lastWallClock, userTime - lastUserTime, privilegedTime - lastPrivilegedTime);
+
+ if (reset)
+ {
+ lastWallClock = wallClock;
+ lastUserTime = userTime;
+ lastPrivilegedTime = privilegedTime;
+ }
+ return snapshot;
+ }
+ }
+
+ public class Snapshot
+ {
+ public TimeSpan WallClockTime { get; }
+ public TimeSpan UserProcessorTime { get; }
+ public TimeSpan PrivilegedProcessorTime { get; }
+
+ public Snapshot(TimeSpan wallClockTime, TimeSpan userProcessorTime, TimeSpan privilegedProcessorTime)
+ {
+ this.WallClockTime = wallClockTime;
+ this.UserProcessorTime = userProcessorTime;
+ this.PrivilegedProcessorTime = privilegedProcessorTime;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("[TimeStats.Snapshot: wallClock {0}, userProcessor {1}, privilegedProcessor {2}]", WallClockTime, UserProcessorTime, PrivilegedProcessorTime);
+ }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs b/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs
deleted file mode 100644
index 38b58f296c..0000000000
--- a/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-#region Copyright notice and license
-
-// 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.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-using Google.Protobuf;
-using Grpc.Core;
-using Grpc.Core.Utils;
-using NUnit.Framework;
-using Grpc.Testing;
-
-namespace Grpc.IntegrationTesting
-{
- /// <summary>
- /// Snapshottable wall clock stopwatch.
- /// </summary>
- public class WallClockStopwatch
- {
- long startTicks;
-
- public WallClockStopwatch()
- {
- this.startTicks = DateTime.UtcNow.Ticks;
- }
-
- public TimeSpan GetElapsedSnapshot(bool reset)
- {
- var utcNow = DateTime.UtcNow;
-
- long oldStartTicks;
- if (reset)
- {
- oldStartTicks = Interlocked.Exchange(ref this.startTicks, utcNow.Ticks);
- }
- else
- {
- oldStartTicks = this.startTicks;
- }
- return utcNow - new DateTime(oldStartTicks, DateTimeKind.Utc);
- }
- }
-}
diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs
new file mode 100644
index 0000000000..bb57a6968f
--- /dev/null
+++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs
@@ -0,0 +1,78 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+using Grpc.Core;
+using Grpc.Core.Internal;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+namespace Grpc.Microbenchmarks
+{
+ public class CompletionRegistryBenchmark
+ {
+ GrpcEnvironment environment;
+
+ public void Init()
+ {
+ environment = GrpcEnvironment.AddRef();
+ }
+
+ public void Cleanup()
+ {
+ GrpcEnvironment.ReleaseAsync().Wait();
+ }
+
+ public void Run(int threadCount, int iterations, bool useSharedRegistry)
+ {
+ Console.WriteLine(string.Format("CompletionRegistryBenchmark: threads={0}, iterations={1}, useSharedRegistry={2}", threadCount, iterations, useSharedRegistry));
+ CompletionRegistry sharedRegistry = useSharedRegistry ? new CompletionRegistry(environment, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()) : null;
+ var threadedBenchmark = new ThreadedBenchmark(threadCount, () => ThreadBody(iterations, sharedRegistry));
+ threadedBenchmark.Run();
+ // TODO: parametrize by number of pending completions
+ }
+
+ private void ThreadBody(int iterations, CompletionRegistry optionalSharedRegistry)
+ {
+ var completionRegistry = optionalSharedRegistry ?? new CompletionRegistry(environment, () => throw new NotImplementedException(), () => throw new NotImplementedException());
+ var ctx = BatchContextSafeHandle.Create();
+
+ var stopwatch = Stopwatch.StartNew();
+ for (int i = 0; i < iterations; i++)
+ {
+ completionRegistry.Register(ctx.Handle, ctx);
+ var callback = completionRegistry.Extract(ctx.Handle);
+ // NOTE: we are not calling the callback to avoid disposing ctx.
+ }
+ stopwatch.Stop();
+ Console.WriteLine("Elapsed millis: " + stopwatch.ElapsedMilliseconds);
+
+ ctx.Recycle();
+ }
+
+ private class NopCompletionCallback : IOpCompletionCallback
+ {
+ public void OnComplete(bool success)
+ {
+
+ }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Microbenchmarks/GCStats.cs b/src/csharp/Grpc.Microbenchmarks/GCStats.cs
new file mode 100644
index 0000000000..ca7051ec4e
--- /dev/null
+++ b/src/csharp/Grpc.Microbenchmarks/GCStats.cs
@@ -0,0 +1,69 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using Grpc.Core;
+using Grpc.Core.Internal;
+
+namespace Grpc.Microbenchmarks
+{
+ internal class GCStats
+ {
+ readonly object myLock = new object();
+ GCStatsSnapshot lastSnapshot;
+
+ public GCStats()
+ {
+ lastSnapshot = new GCStatsSnapshot(GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2));
+ }
+
+ public GCStatsSnapshot GetSnapshot(bool reset = false)
+ {
+ lock (myLock)
+ {
+ var newSnapshot = new GCStatsSnapshot(GC.CollectionCount(0) - lastSnapshot.Gen0,
+ GC.CollectionCount(1) - lastSnapshot.Gen1,
+ GC.CollectionCount(2) - lastSnapshot.Gen2);
+ if (reset)
+ {
+ lastSnapshot = newSnapshot;
+ }
+ return newSnapshot;
+ }
+ }
+ }
+
+ public class GCStatsSnapshot
+ {
+ public GCStatsSnapshot(int gen0, int gen1, int gen2)
+ {
+ this.Gen0 = gen0;
+ this.Gen1 = gen1;
+ this.Gen2 = gen2;
+ }
+
+ public int Gen0 { get; }
+ public int Gen1 { get; }
+ public int Gen2 { get; }
+
+ public override string ToString()
+ {
+ return string.Format("[GCCollectionCount: gen0 {0}, gen1 {1}, gen2 {2}]", Gen0, Gen1, Gen2);
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj
index 108357e4eb..8a629f9748 100644
--- a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj
+++ b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj
@@ -15,6 +15,10 @@
<ProjectReference Include="../Grpc.Core/Grpc.Core.csproj" />
</ItemGroup>
+ <ItemGroup>
+ <PackageReference Include="CommandLineParser" Version="2.1.1-beta" />
+ </ItemGroup>
+
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
diff --git a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs
new file mode 100644
index 0000000000..787b5508fb
--- /dev/null
+++ b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs
@@ -0,0 +1,64 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+using Grpc.Core;
+using Grpc.Core.Internal;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+namespace Grpc.Microbenchmarks
+{
+ public class PInvokeByteArrayBenchmark
+ {
+ static readonly NativeMethods Native = NativeMethods.Get();
+
+ public void Init()
+ {
+ }
+
+ public void Cleanup()
+ {
+ }
+
+ public void Run(int threadCount, int iterations, int payloadSize)
+ {
+ Console.WriteLine(string.Format("PInvokeByteArrayBenchmark: threads={0}, iterations={1}, payloadSize={2}", threadCount, iterations, payloadSize));
+ var threadedBenchmark = new ThreadedBenchmark(threadCount, () => ThreadBody(iterations, payloadSize));
+ threadedBenchmark.Run();
+ }
+
+ private void ThreadBody(int iterations, int payloadSize)
+ {
+ var payload = new byte[payloadSize];
+
+ var stopwatch = Stopwatch.StartNew();
+ for (int i = 0; i < iterations; i++)
+ {
+ var gcHandle = GCHandle.Alloc(payload, GCHandleType.Pinned);
+ var payloadPtr = gcHandle.AddrOfPinnedObject();
+ Native.grpcsharp_test_nop(payloadPtr);
+ gcHandle.Free();
+ }
+ stopwatch.Stop();
+ Console.WriteLine("Elapsed millis: " + stopwatch.ElapsedMilliseconds);
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Microbenchmarks/Program.cs b/src/csharp/Grpc.Microbenchmarks/Program.cs
index d07d4187c4..a64c2979ab 100644
--- a/src/csharp/Grpc.Microbenchmarks/Program.cs
+++ b/src/csharp/Grpc.Microbenchmarks/Program.cs
@@ -20,14 +20,84 @@ using System;
using Grpc.Core;
using Grpc.Core.Internal;
using Grpc.Core.Logging;
+using CommandLine;
+using CommandLine.Text;
namespace Grpc.Microbenchmarks
{
class Program
{
+ public enum MicrobenchmarkType
+ {
+ CompletionRegistry,
+ PInvokeByteArray,
+ SendMessage
+ }
+
+ private class BenchmarkOptions
+ {
+ [Option("benchmark", Required = true, HelpText = "Benchmark to run")]
+ public MicrobenchmarkType Benchmark { get; set; }
+ }
+
public static void Main(string[] args)
{
GrpcEnvironment.SetLogger(new ConsoleLogger());
+ var parserResult = Parser.Default.ParseArguments<BenchmarkOptions>(args)
+ .WithNotParsed(errors => {
+ Console.WriteLine("Supported benchmarks:");
+ foreach (var enumValue in Enum.GetValues(typeof(MicrobenchmarkType)))
+ {
+ Console.WriteLine(" " + enumValue);
+ }
+ Environment.Exit(1);
+ })
+ .WithParsed(options =>
+ {
+ switch (options.Benchmark)
+ {
+ case MicrobenchmarkType.CompletionRegistry:
+ RunCompletionRegistryBenchmark();
+ break;
+ case MicrobenchmarkType.PInvokeByteArray:
+ RunPInvokeByteArrayBenchmark();
+ break;
+ case MicrobenchmarkType.SendMessage:
+ RunSendMessageBenchmark();
+ break;
+ default:
+ throw new ArgumentException("Unsupported benchmark.");
+ }
+ });
+ }
+
+ static void RunCompletionRegistryBenchmark()
+ {
+ var benchmark = new CompletionRegistryBenchmark();
+ benchmark.Init();
+ foreach (int threadCount in new int[] {1, 1, 2, 4, 8, 12})
+ {
+ foreach (bool useSharedRegistry in new bool[] {false, true})
+ {
+ benchmark.Run(threadCount, 4 * 1000 * 1000, useSharedRegistry);
+ }
+ }
+ benchmark.Cleanup();
+ }
+
+ static void RunPInvokeByteArrayBenchmark()
+ {
+ var benchmark = new PInvokeByteArrayBenchmark();
+ benchmark.Init();
+ foreach (int threadCount in new int[] {1, 1, 2, 4, 8, 12})
+ {
+ benchmark.Run(threadCount, 4 * 1000 * 1000, 0);
+ }
+ benchmark.Cleanup();
+ }
+
+ static void RunSendMessageBenchmark()
+ {
var benchmark = new SendMessageBenchmark();
benchmark.Init();
foreach (int threadCount in new int[] {1, 1, 2, 4, 8, 12})
diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs
index de67874580..390c062298 100644
--- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs
+++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs
@@ -52,23 +52,20 @@ namespace Grpc.Microbenchmarks
private void ThreadBody(int iterations, int payloadSize)
{
- // TODO(jtattermusch): parametrize by number of pending completions.
- // TODO(jtattermusch): parametrize by cached/non-cached BatchContextSafeHandle
-
- var completionRegistry = new CompletionRegistry(environment);
+ var completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => throw new NotImplementedException());
var cq = CompletionQueueSafeHandle.CreateAsync(completionRegistry);
var call = CreateFakeCall(cq);
- var sendCompletionHandler = new SendCompletionHandler((success) => { });
+ var sendCompletionCallback = new NopSendCompletionCallback();
var payload = new byte[payloadSize];
var writeFlags = default(WriteFlags);
var stopwatch = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
{
- call.StartSendMessage(sendCompletionHandler, payload, writeFlags, false);
+ call.StartSendMessage(sendCompletionCallback, payload, writeFlags, false);
var callback = completionRegistry.Extract(completionRegistry.LastRegisteredKey);
- callback(true);
+ callback.OnComplete(true);
}
stopwatch.Stop();
Console.WriteLine("Elapsed millis: " + stopwatch.ElapsedMilliseconds);
@@ -87,5 +84,13 @@ namespace Grpc.Microbenchmarks
}
return call;
}
+
+ private class NopSendCompletionCallback : ISendCompletionCallback
+ {
+ public void OnSendCompletion(bool success)
+ {
+ // NOP
+ }
+ }
}
}
diff --git a/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs
index feac8d1690..95b9aaaf3f 100644
--- a/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs
+++ b/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs
@@ -46,6 +46,7 @@ namespace Grpc.Microbenchmarks
public void Run()
{
Console.WriteLine("Running threads.");
+ var gcStats = new GCStats();
var threads = new List<Thread>();
for (int i = 0; i < runners.Count; i++)
{
@@ -58,7 +59,7 @@ namespace Grpc.Microbenchmarks
{
thread.Join();
}
- Console.WriteLine("All threads finished.");
+ Console.WriteLine("All threads finished (GC Stats Delta: " + gcStats.GetSnapshot() + ")");
}
}
}
diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj
index 704eea5c17..862ecda5fd 100755
--- a/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj
+++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj
@@ -14,12 +14,12 @@
<PackageTags>gRPC reflection</PackageTags>
<PackageProjectUrl>https://github.com/grpc/grpc</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</PackageLicenseUrl>
- <IncludeSymbols>true</IncludeSymbols>
- <IncludeSource>true</IncludeSource>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
+ <Import Project="..\Grpc.Core\SourceLink.csproj.include" />
+
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs" />
</ItemGroup>
diff --git a/src/csharp/Grpc.Reflection/Reflection.cs b/src/csharp/Grpc.Reflection/Reflection.cs
index 86e9aace8c..60090e5364 100644
--- a/src/csharp/Grpc.Reflection/Reflection.cs
+++ b/src/csharp/Grpc.Reflection/Reflection.cs
@@ -345,7 +345,10 @@ namespace Grpc.Reflection.V1Alpha {
FileContainingSymbol = other.FileContainingSymbol;
break;
case MessageRequestOneofCase.FileContainingExtension:
- FileContainingExtension = other.FileContainingExtension;
+ if (FileContainingExtension == null) {
+ FileContainingExtension = new global::Grpc.Reflection.V1Alpha.ExtensionRequest();
+ }
+ FileContainingExtension.MergeFrom(other.FileContainingExtension);
break;
case MessageRequestOneofCase.AllExtensionNumbersOfType:
AllExtensionNumbersOfType = other.AllExtensionNumbersOfType;
@@ -816,16 +819,28 @@ namespace Grpc.Reflection.V1Alpha {
}
switch (other.MessageResponseCase) {
case MessageResponseOneofCase.FileDescriptorResponse:
- FileDescriptorResponse = other.FileDescriptorResponse;
+ if (FileDescriptorResponse == null) {
+ FileDescriptorResponse = new global::Grpc.Reflection.V1Alpha.FileDescriptorResponse();
+ }
+ FileDescriptorResponse.MergeFrom(other.FileDescriptorResponse);
break;
case MessageResponseOneofCase.AllExtensionNumbersResponse:
- AllExtensionNumbersResponse = other.AllExtensionNumbersResponse;
+ if (AllExtensionNumbersResponse == null) {
+ AllExtensionNumbersResponse = new global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse();
+ }
+ AllExtensionNumbersResponse.MergeFrom(other.AllExtensionNumbersResponse);
break;
case MessageResponseOneofCase.ListServicesResponse:
- ListServicesResponse = other.ListServicesResponse;
+ if (ListServicesResponse == null) {
+ ListServicesResponse = new global::Grpc.Reflection.V1Alpha.ListServiceResponse();
+ }
+ ListServicesResponse.MergeFrom(other.ListServicesResponse);
break;
case MessageResponseOneofCase.ErrorResponse:
- ErrorResponse = other.ErrorResponse;
+ if (ErrorResponse == null) {
+ ErrorResponse = new global::Grpc.Reflection.V1Alpha.ErrorResponse();
+ }
+ ErrorResponse.MergeFrom(other.ErrorResponse);
break;
}
diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs
index 58439577e3..0195186eba 100644
--- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs
+++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs
@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: grpc/reflection/v1alpha/reflection.proto
+// <auto-generated>
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: grpc/reflection/v1alpha/reflection.proto
+// </auto-generated>
// Original file comments:
// Copyright 2016 gRPC authors.
//
diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat
index c419d87049..4087d8b67a 100755
--- a/src/csharp/build_packages_dotnetcli.bat
+++ b/src/csharp/build_packages_dotnetcli.bat
@@ -13,7 +13,7 @@
@rem limitations under the License.
@rem Current package versions
-set VERSION=1.7.0-dev
+set VERSION=1.10.0-dev
@rem Adjust the location of nuget.exe
set NUGET=C:\nuget\nuget.exe
diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh
index 124dfbb257..8ccc537a60 100755
--- a/src/csharp/build_packages_dotnetcli.sh
+++ b/src/csharp/build_packages_dotnetcli.sh
@@ -39,7 +39,7 @@ dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts
dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts
dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts
-nuget pack Grpc.nuspec -Version "1.7.0-dev" -OutputDirectory ../../artifacts
-nuget pack Grpc.Tools.nuspec -Version "1.7.0-dev" -OutputDirectory ../../artifacts
+nuget pack Grpc.nuspec -Version "1.10.0-dev" -OutputDirectory ../../artifacts
+nuget pack Grpc.Tools.nuspec -Version "1.10.0-dev" -OutputDirectory ../../artifacts
(cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg)
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index aebce364c5..eb69b5829c 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include <grpc/byte_buffer_reader.h>
#include <grpc/grpc.h>
@@ -43,9 +43,9 @@
#define GPR_CALLTYPE
#endif
-grpc_byte_buffer *string_to_byte_buffer(const char *buffer, size_t len) {
+grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) {
grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len);
- grpc_byte_buffer *bb = grpc_raw_byte_buffer_create(&slice, 1);
+ grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
return bb;
}
@@ -55,12 +55,12 @@ grpc_byte_buffer *string_to_byte_buffer(const char *buffer, size_t len) {
*/
typedef struct grpcsharp_batch_context {
grpc_metadata_array send_initial_metadata;
- grpc_byte_buffer *send_message;
+ grpc_byte_buffer* send_message;
struct {
grpc_metadata_array trailing_metadata;
} send_status_from_server;
grpc_metadata_array recv_initial_metadata;
- grpc_byte_buffer *recv_message;
+ grpc_byte_buffer* recv_message;
struct {
grpc_metadata_array trailing_metadata;
grpc_status_code status;
@@ -69,22 +69,22 @@ typedef struct grpcsharp_batch_context {
int recv_close_on_server_cancelled;
} grpcsharp_batch_context;
-GPR_EXPORT grpcsharp_batch_context *GPR_CALLTYPE
+GPR_EXPORT grpcsharp_batch_context* GPR_CALLTYPE
grpcsharp_batch_context_create() {
- grpcsharp_batch_context *ctx = gpr_malloc(sizeof(grpcsharp_batch_context));
+ grpcsharp_batch_context* ctx = gpr_malloc(sizeof(grpcsharp_batch_context));
memset(ctx, 0, sizeof(grpcsharp_batch_context));
return ctx;
}
typedef struct {
- grpc_call *call;
+ grpc_call* call;
grpc_call_details call_details;
grpc_metadata_array request_metadata;
} grpcsharp_request_call_context;
-GPR_EXPORT grpcsharp_request_call_context *GPR_CALLTYPE
+GPR_EXPORT grpcsharp_request_call_context* GPR_CALLTYPE
grpcsharp_request_call_context_create() {
- grpcsharp_request_call_context *ctx =
+ grpcsharp_request_call_context* ctx =
gpr_malloc(sizeof(grpcsharp_request_call_context));
memset(ctx, 0, sizeof(grpcsharp_request_call_context));
return ctx;
@@ -95,7 +95,7 @@ grpcsharp_request_call_context_create() {
* The array pointer itself is not freed.
*/
void grpcsharp_metadata_array_destroy_metadata_only(
- grpc_metadata_array *array) {
+ grpc_metadata_array* array) {
gpr_free(array->metadata);
}
@@ -104,7 +104,7 @@ void grpcsharp_metadata_array_destroy_metadata_only(
* The array pointer itself is not freed.
*/
void grpcsharp_metadata_array_destroy_metadata_including_entries(
- grpc_metadata_array *array) {
+ grpc_metadata_array* array) {
size_t i;
if (array->metadata) {
for (i = 0; i < array->count; i++) {
@@ -119,7 +119,7 @@ void grpcsharp_metadata_array_destroy_metadata_including_entries(
* Fully destroys the metadata array.
*/
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_metadata_array_destroy_full(grpc_metadata_array *array) {
+grpcsharp_metadata_array_destroy_full(grpc_metadata_array* array) {
if (!array) {
return;
}
@@ -131,16 +131,16 @@ grpcsharp_metadata_array_destroy_full(grpc_metadata_array *array) {
* Creates an empty metadata array with given capacity.
* Array can later be destroyed by grpc_metadata_array_destroy_full.
*/
-GPR_EXPORT grpc_metadata_array *GPR_CALLTYPE
+GPR_EXPORT grpc_metadata_array* GPR_CALLTYPE
grpcsharp_metadata_array_create(size_t capacity) {
- grpc_metadata_array *array =
- (grpc_metadata_array *)gpr_malloc(sizeof(grpc_metadata_array));
+ grpc_metadata_array* array =
+ (grpc_metadata_array*)gpr_malloc(sizeof(grpc_metadata_array));
grpc_metadata_array_init(array);
array->capacity = capacity;
array->count = 0;
if (capacity > 0) {
array->metadata =
- (grpc_metadata *)gpr_malloc(sizeof(grpc_metadata) * capacity);
+ (grpc_metadata*)gpr_malloc(sizeof(grpc_metadata) * capacity);
memset(array->metadata, 0, sizeof(grpc_metadata) * capacity);
} else {
array->metadata = NULL;
@@ -149,8 +149,8 @@ grpcsharp_metadata_array_create(size_t capacity) {
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_metadata_array_add(grpc_metadata_array *array, const char *key,
- const char *value, size_t value_length) {
+grpcsharp_metadata_array_add(grpc_metadata_array* array, const char* key,
+ const char* value, size_t value_length) {
size_t i = array->count;
GPR_ASSERT(array->count < array->capacity);
array->metadata[i].key = grpc_slice_from_copied_string(key);
@@ -159,27 +159,27 @@ grpcsharp_metadata_array_add(grpc_metadata_array *array, const char *key,
}
GPR_EXPORT intptr_t GPR_CALLTYPE
-grpcsharp_metadata_array_count(grpc_metadata_array *array) {
+grpcsharp_metadata_array_count(grpc_metadata_array* array) {
return (intptr_t)array->count;
}
-GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_metadata_array_get_key(
- grpc_metadata_array *array, size_t index, size_t *key_length) {
+GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_metadata_array_get_key(
+ grpc_metadata_array* array, size_t index, size_t* key_length) {
GPR_ASSERT(index < array->count);
*key_length = GRPC_SLICE_LENGTH(array->metadata[index].key);
- return (char *)GRPC_SLICE_START_PTR(array->metadata[index].key);
+ return (char*)GRPC_SLICE_START_PTR(array->metadata[index].key);
}
-GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_metadata_array_get_value(
- grpc_metadata_array *array, size_t index, size_t *value_length) {
+GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_metadata_array_get_value(
+ grpc_metadata_array* array, size_t index, size_t* value_length) {
GPR_ASSERT(index < array->count);
*value_length = GRPC_SLICE_LENGTH(array->metadata[index].value);
- return (char *)GRPC_SLICE_START_PTR(array->metadata[index].value);
+ return (char*)GRPC_SLICE_START_PTR(array->metadata[index].value);
}
/* Move contents of metadata array */
-void grpcsharp_metadata_array_move(grpc_metadata_array *dest,
- grpc_metadata_array *src) {
+void grpcsharp_metadata_array_move(grpc_metadata_array* dest,
+ grpc_metadata_array* src) {
if (!src) {
dest->capacity = 0;
dest->count = 0;
@@ -197,10 +197,7 @@ void grpcsharp_metadata_array_move(grpc_metadata_array *dest,
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_batch_context_destroy(grpcsharp_batch_context *ctx) {
- if (!ctx) {
- return;
- }
+grpcsharp_batch_context_reset(grpcsharp_batch_context* ctx) {
grpcsharp_metadata_array_destroy_metadata_including_entries(
&(ctx->send_initial_metadata));
@@ -216,33 +213,46 @@ grpcsharp_batch_context_destroy(grpcsharp_batch_context *ctx) {
grpcsharp_metadata_array_destroy_metadata_only(
&(ctx->recv_status_on_client.trailing_metadata));
grpc_slice_unref(ctx->recv_status_on_client.status_details);
-
- gpr_free(ctx);
+ memset(ctx, 0, sizeof(grpcsharp_batch_context));
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_request_call_context_destroy(grpcsharp_request_call_context *ctx) {
+grpcsharp_batch_context_destroy(grpcsharp_batch_context* ctx) {
if (!ctx) {
return;
}
+ grpcsharp_batch_context_reset(ctx);
+ gpr_free(ctx);
+}
+
+GPR_EXPORT void GPR_CALLTYPE
+grpcsharp_request_call_context_reset(grpcsharp_request_call_context* ctx) {
/* NOTE: ctx->server_rpc_new.call is not destroyed because callback handler is
supposed
to take its ownership. */
grpc_call_details_destroy(&(ctx->call_details));
grpcsharp_metadata_array_destroy_metadata_only(&(ctx->request_metadata));
+ memset(ctx, 0, sizeof(grpcsharp_request_call_context));
+}
+GPR_EXPORT void GPR_CALLTYPE
+grpcsharp_request_call_context_destroy(grpcsharp_request_call_context* ctx) {
+ if (!ctx) {
+ return;
+ }
+ grpcsharp_request_call_context_reset(ctx);
gpr_free(ctx);
}
-GPR_EXPORT const grpc_metadata_array *GPR_CALLTYPE
+GPR_EXPORT const grpc_metadata_array* GPR_CALLTYPE
grpcsharp_batch_context_recv_initial_metadata(
- const grpcsharp_batch_context *ctx) {
+ const grpcsharp_batch_context* ctx) {
return &(ctx->recv_initial_metadata);
}
GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_batch_context_recv_message_length(
- const grpcsharp_batch_context *ctx) {
+ const grpcsharp_batch_context* ctx) {
grpc_byte_buffer_reader reader;
if (!ctx->recv_message) {
return -1;
@@ -260,7 +270,7 @@ GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_batch_context_recv_message_length(
* buffer is too small.
*/
GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer(
- const grpcsharp_batch_context *ctx, char *buffer, size_t buffer_len) {
+ const grpcsharp_batch_context* ctx, char* buffer, size_t buffer_len) {
grpc_byte_buffer_reader reader;
grpc_slice slice;
size_t offset = 0;
@@ -281,56 +291,55 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer(
GPR_EXPORT grpc_status_code GPR_CALLTYPE
grpcsharp_batch_context_recv_status_on_client_status(
- const grpcsharp_batch_context *ctx) {
+ const grpcsharp_batch_context* ctx) {
return ctx->recv_status_on_client.status;
}
-GPR_EXPORT const char *GPR_CALLTYPE
+GPR_EXPORT const char* GPR_CALLTYPE
grpcsharp_batch_context_recv_status_on_client_details(
- const grpcsharp_batch_context *ctx, size_t *details_length) {
+ const grpcsharp_batch_context* ctx, size_t* details_length) {
*details_length =
GRPC_SLICE_LENGTH(ctx->recv_status_on_client.status_details);
- return (char *)GRPC_SLICE_START_PTR(
- ctx->recv_status_on_client.status_details);
+ return (char*)GRPC_SLICE_START_PTR(ctx->recv_status_on_client.status_details);
}
-GPR_EXPORT const grpc_metadata_array *GPR_CALLTYPE
+GPR_EXPORT const grpc_metadata_array* GPR_CALLTYPE
grpcsharp_batch_context_recv_status_on_client_trailing_metadata(
- const grpcsharp_batch_context *ctx) {
+ const grpcsharp_batch_context* ctx) {
return &(ctx->recv_status_on_client.trailing_metadata);
}
-GPR_EXPORT grpc_call *GPR_CALLTYPE
-grpcsharp_request_call_context_call(const grpcsharp_request_call_context *ctx) {
+GPR_EXPORT grpc_call* GPR_CALLTYPE
+grpcsharp_request_call_context_call(const grpcsharp_request_call_context* ctx) {
return ctx->call;
}
-GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_request_call_context_method(
- const grpcsharp_request_call_context *ctx, size_t *method_length) {
+GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_request_call_context_method(
+ const grpcsharp_request_call_context* ctx, size_t* method_length) {
*method_length = GRPC_SLICE_LENGTH(ctx->call_details.method);
- return (char *)GRPC_SLICE_START_PTR(ctx->call_details.method);
+ return (char*)GRPC_SLICE_START_PTR(ctx->call_details.method);
}
-GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_request_call_context_host(
- const grpcsharp_request_call_context *ctx, size_t *host_length) {
+GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_request_call_context_host(
+ const grpcsharp_request_call_context* ctx, size_t* host_length) {
*host_length = GRPC_SLICE_LENGTH(ctx->call_details.host);
- return (char *)GRPC_SLICE_START_PTR(ctx->call_details.host);
+ return (char*)GRPC_SLICE_START_PTR(ctx->call_details.host);
}
GPR_EXPORT gpr_timespec GPR_CALLTYPE grpcsharp_request_call_context_deadline(
- const grpcsharp_request_call_context *ctx) {
+ const grpcsharp_request_call_context* ctx) {
return ctx->call_details.deadline;
}
-GPR_EXPORT const grpc_metadata_array *GPR_CALLTYPE
+GPR_EXPORT const grpc_metadata_array* GPR_CALLTYPE
grpcsharp_request_call_context_request_metadata(
- const grpcsharp_request_call_context *ctx) {
+ const grpcsharp_request_call_context* ctx) {
return &(ctx->request_metadata);
}
GPR_EXPORT int32_t GPR_CALLTYPE
grpcsharp_batch_context_recv_close_on_server_cancelled(
- const grpcsharp_batch_context *ctx) {
+ const grpcsharp_batch_context* ctx) {
return (int32_t)ctx->recv_close_on_server_cancelled;
}
@@ -342,63 +351,63 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_shutdown(void) { grpc_shutdown(); }
/* Completion queue */
-GPR_EXPORT grpc_completion_queue *GPR_CALLTYPE
+GPR_EXPORT grpc_completion_queue* GPR_CALLTYPE
grpcsharp_completion_queue_create_async(void) {
return grpc_completion_queue_create_for_next(NULL);
}
-GPR_EXPORT grpc_completion_queue *GPR_CALLTYPE
+GPR_EXPORT grpc_completion_queue* GPR_CALLTYPE
grpcsharp_completion_queue_create_sync(void) {
return grpc_completion_queue_create_for_pluck(NULL);
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_completion_queue_shutdown(grpc_completion_queue *cq) {
+grpcsharp_completion_queue_shutdown(grpc_completion_queue* cq) {
grpc_completion_queue_shutdown(cq);
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_completion_queue_destroy(grpc_completion_queue *cq) {
+grpcsharp_completion_queue_destroy(grpc_completion_queue* cq) {
grpc_completion_queue_destroy(cq);
}
GPR_EXPORT grpc_event GPR_CALLTYPE
-grpcsharp_completion_queue_next(grpc_completion_queue *cq) {
+grpcsharp_completion_queue_next(grpc_completion_queue* cq) {
return grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
NULL);
}
GPR_EXPORT grpc_event GPR_CALLTYPE
-grpcsharp_completion_queue_pluck(grpc_completion_queue *cq, void *tag) {
+grpcsharp_completion_queue_pluck(grpc_completion_queue* cq, void* tag) {
return grpc_completion_queue_pluck(cq, tag,
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
}
/* Channel */
-GPR_EXPORT grpc_channel *GPR_CALLTYPE
+GPR_EXPORT grpc_channel* GPR_CALLTYPE
-grpcsharp_insecure_channel_create(const char *target,
- const grpc_channel_args *args) {
+grpcsharp_insecure_channel_create(const char* target,
+ const grpc_channel_args* args) {
return grpc_insecure_channel_create(target, args, NULL);
}
-GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_destroy(grpc_channel *channel) {
+GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_destroy(grpc_channel* channel) {
grpc_channel_destroy(channel);
}
-GPR_EXPORT grpc_call *GPR_CALLTYPE grpcsharp_channel_create_call(
- grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
- grpc_completion_queue *cq, const char *method, const char *host,
+GPR_EXPORT grpc_call* GPR_CALLTYPE grpcsharp_channel_create_call(
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_completion_queue* cq, const char* method, const char* host,
gpr_timespec deadline) {
grpc_slice method_slice = grpc_slice_from_copied_string(method);
- grpc_slice *host_slice_ptr = NULL;
+ grpc_slice* host_slice_ptr = NULL;
grpc_slice host_slice;
if (host != NULL) {
host_slice = grpc_slice_from_copied_string(host);
host_slice_ptr = &host_slice;
}
- grpc_call *ret =
+ grpc_call* ret =
grpc_channel_create_call(channel, parent_call, propagation_mask, cq,
method_slice, host_slice_ptr, deadline, NULL);
grpc_slice_unref(method_slice);
@@ -409,40 +418,40 @@ GPR_EXPORT grpc_call *GPR_CALLTYPE grpcsharp_channel_create_call(
}
GPR_EXPORT grpc_connectivity_state GPR_CALLTYPE
-grpcsharp_channel_check_connectivity_state(grpc_channel *channel,
+grpcsharp_channel_check_connectivity_state(grpc_channel* channel,
int32_t try_to_connect) {
return grpc_channel_check_connectivity_state(channel, try_to_connect);
}
GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_watch_connectivity_state(
- grpc_channel *channel, grpc_connectivity_state last_observed_state,
- gpr_timespec deadline, grpc_completion_queue *cq,
- grpcsharp_batch_context *ctx) {
+ grpc_channel* channel, grpc_connectivity_state last_observed_state,
+ gpr_timespec deadline, grpc_completion_queue* cq,
+ grpcsharp_batch_context* ctx) {
grpc_channel_watch_connectivity_state(channel, last_observed_state, deadline,
cq, ctx);
}
-GPR_EXPORT char *GPR_CALLTYPE
-grpcsharp_channel_get_target(grpc_channel *channel) {
+GPR_EXPORT char* GPR_CALLTYPE
+grpcsharp_channel_get_target(grpc_channel* channel) {
return grpc_channel_get_target(channel);
}
/* Channel args */
-GPR_EXPORT grpc_channel_args *GPR_CALLTYPE
+GPR_EXPORT grpc_channel_args* GPR_CALLTYPE
grpcsharp_channel_args_create(size_t num_args) {
- grpc_channel_args *args =
- (grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
+ grpc_channel_args* args =
+ (grpc_channel_args*)gpr_malloc(sizeof(grpc_channel_args));
memset(args, 0, sizeof(grpc_channel_args));
args->num_args = num_args;
- args->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * num_args);
+ args->args = (grpc_arg*)gpr_malloc(sizeof(grpc_arg) * num_args);
memset(args->args, 0, sizeof(grpc_arg) * num_args);
return args;
}
GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_args_set_string(
- grpc_channel_args *args, size_t index, const char *key, const char *value) {
+ grpc_channel_args* args, size_t index, const char* key, const char* value) {
GPR_ASSERT(args);
GPR_ASSERT(index < args->num_args);
args->args[index].type = GRPC_ARG_STRING;
@@ -451,7 +460,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_args_set_string(
}
GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_args_set_integer(
- grpc_channel_args *args, size_t index, const char *key, int value) {
+ grpc_channel_args* args, size_t index, const char* key, int value) {
GPR_ASSERT(args);
GPR_ASSERT(index < args->num_args);
args->args[index].type = GRPC_ARG_INTEGER;
@@ -460,7 +469,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_channel_args_set_integer(
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_channel_args_destroy(grpc_channel_args *args) {
+grpcsharp_channel_args_destroy(grpc_channel_args* args) {
size_t i;
if (args) {
for (i = 0; i < args->num_args; i++) {
@@ -501,61 +510,61 @@ GPR_EXPORT int32_t GPR_CALLTYPE gprsharp_sizeof_timespec(void) {
/* Call */
-GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_cancel(grpc_call *call) {
+GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_cancel(grpc_call* call) {
return grpc_call_cancel(call, NULL);
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_cancel_with_status(
- grpc_call *call, grpc_status_code status, const char *description) {
+ grpc_call* call, grpc_status_code status, const char* description) {
return grpc_call_cancel_with_status(call, status, description, NULL);
}
-GPR_EXPORT char *GPR_CALLTYPE grpcsharp_call_get_peer(grpc_call *call) {
+GPR_EXPORT char* GPR_CALLTYPE grpcsharp_call_get_peer(grpc_call* call) {
return grpc_call_get_peer(call);
}
-GPR_EXPORT void GPR_CALLTYPE gprsharp_free(void *p) { gpr_free(p); }
+GPR_EXPORT void GPR_CALLTYPE gprsharp_free(void* p) { gpr_free(p); }
-GPR_EXPORT void GPR_CALLTYPE grpcsharp_call_destroy(grpc_call *call) {
+GPR_EXPORT void GPR_CALLTYPE grpcsharp_call_destroy(grpc_call* call) {
grpc_call_unref(call);
}
-typedef grpc_call_error (*grpcsharp_call_start_batch_func)(grpc_call *call,
- const grpc_op *ops,
+typedef grpc_call_error (*grpcsharp_call_start_batch_func)(grpc_call* call,
+ const grpc_op* ops,
size_t nops,
- void *tag,
- void *reserved);
+ void* tag,
+ void* reserved);
/* Only for testing */
-static grpc_call_error grpcsharp_call_start_batch_nop(grpc_call *call,
- const grpc_op *ops,
- size_t nops, void *tag,
- void *reserved) {
+static grpc_call_error grpcsharp_call_start_batch_nop(grpc_call* call,
+ const grpc_op* ops,
+ size_t nops, void* tag,
+ void* reserved) {
return GRPC_CALL_OK;
}
-static grpc_call_error grpcsharp_call_start_batch_default(grpc_call *call,
- const grpc_op *ops,
+static grpc_call_error grpcsharp_call_start_batch_default(grpc_call* call,
+ const grpc_op* ops,
size_t nops,
- void *tag,
- void *reserved) {
+ void* tag,
+ void* reserved) {
return grpc_call_start_batch(call, ops, nops, tag, reserved);
}
static grpcsharp_call_start_batch_func g_call_start_batch_func =
grpcsharp_call_start_batch_default;
-static grpc_call_error grpcsharp_call_start_batch(grpc_call *call,
- const grpc_op *ops,
- size_t nops, void *tag,
- void *reserved) {
+static grpc_call_error grpcsharp_call_start_batch(grpc_call* call,
+ const grpc_op* ops,
+ size_t nops, void* tag,
+ void* reserved) {
return g_call_start_batch_func(call, ops, nops, tag, reserved);
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary(
- grpc_call *call, grpcsharp_batch_context *ctx, const char *send_buffer,
+ grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer,
size_t send_buffer_len, uint32_t write_flags,
- grpc_metadata_array *initial_metadata, uint32_t initial_metadata_flags) {
+ grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) {
/* TODO: don't use magic number */
grpc_op ops[6];
memset(ops, 0, sizeof(ops));
@@ -604,8 +613,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming(
- grpc_call *call, grpcsharp_batch_context *ctx,
- grpc_metadata_array *initial_metadata, uint32_t initial_metadata_flags) {
+ grpc_call* call, grpcsharp_batch_context* ctx,
+ grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) {
/* TODO: don't use magic number */
grpc_op ops[4];
memset(ops, 0, sizeof(ops));
@@ -644,9 +653,9 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming(
- grpc_call *call, grpcsharp_batch_context *ctx, const char *send_buffer,
+ grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer,
size_t send_buffer_len, uint32_t write_flags,
- grpc_metadata_array *initial_metadata, uint32_t initial_metadata_flags) {
+ grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) {
/* TODO: don't use magic number */
grpc_op ops[4];
memset(ops, 0, sizeof(ops));
@@ -684,8 +693,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_duplex_streaming(
- grpc_call *call, grpcsharp_batch_context *ctx,
- grpc_metadata_array *initial_metadata, uint32_t initial_metadata_flags) {
+ grpc_call* call, grpcsharp_batch_context* ctx,
+ grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) {
/* TODO: don't use magic number */
grpc_op ops[2];
memset(ops, 0, sizeof(ops));
@@ -713,7 +722,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_duplex_streaming(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata(
- grpc_call *call, grpcsharp_batch_context *ctx) {
+ grpc_call* call, grpcsharp_batch_context* ctx) {
/* TODO: don't use magic number */
grpc_op ops[1];
ops[0].op = GRPC_OP_RECV_INITIAL_METADATA;
@@ -727,7 +736,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_message(
- grpc_call *call, grpcsharp_batch_context *ctx, const char *send_buffer,
+ grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer,
size_t send_buffer_len, uint32_t write_flags,
int32_t send_empty_initial_metadata) {
/* TODO: don't use magic number */
@@ -747,7 +756,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_message(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_close_from_client(
- grpc_call *call, grpcsharp_batch_context *ctx) {
+ grpc_call* call, grpcsharp_batch_context* ctx) {
/* TODO: don't use magic number */
grpc_op ops[1];
ops[0].op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
@@ -759,10 +768,10 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_close_from_client(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
- grpc_call *call, grpcsharp_batch_context *ctx, grpc_status_code status_code,
- const char *status_details, size_t status_details_len,
- grpc_metadata_array *trailing_metadata, int32_t send_empty_initial_metadata,
- const char *optional_send_buffer, size_t optional_send_buffer_len,
+ grpc_call* call, grpcsharp_batch_context* ctx, grpc_status_code status_code,
+ const char* status_details, size_t status_details_len,
+ grpc_metadata_array* trailing_metadata, int32_t send_empty_initial_metadata,
+ const char* optional_send_buffer, size_t optional_send_buffer_len,
uint32_t write_flags) {
/* TODO: don't use magic number */
grpc_op ops[3];
@@ -802,7 +811,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE
-grpcsharp_call_recv_message(grpc_call *call, grpcsharp_batch_context *ctx) {
+grpcsharp_call_recv_message(grpc_call* call, grpcsharp_batch_context* ctx) {
/* TODO: don't use magic number */
grpc_op ops[1];
ops[0].op = GRPC_OP_RECV_MESSAGE;
@@ -814,7 +823,7 @@ grpcsharp_call_recv_message(grpc_call *call, grpcsharp_batch_context *ctx) {
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE
-grpcsharp_call_start_serverside(grpc_call *call, grpcsharp_batch_context *ctx) {
+grpcsharp_call_start_serverside(grpc_call* call, grpcsharp_batch_context* ctx) {
/* TODO: don't use magic number */
grpc_op ops[1];
ops[0].op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -828,8 +837,8 @@ grpcsharp_call_start_serverside(grpc_call *call, grpcsharp_batch_context *ctx) {
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_initial_metadata(
- grpc_call *call, grpcsharp_batch_context *ctx,
- grpc_metadata_array *initial_metadata) {
+ grpc_call* call, grpcsharp_batch_context* ctx,
+ grpc_metadata_array* initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[1];
memset(ops, 0, sizeof(ops));
@@ -847,59 +856,59 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_initial_metadata(
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE
-grpcsharp_call_set_credentials(grpc_call *call, grpc_call_credentials *creds) {
+grpcsharp_call_set_credentials(grpc_call* call, grpc_call_credentials* creds) {
return grpc_call_set_credentials(call, creds);
}
/* Server */
-GPR_EXPORT grpc_server *GPR_CALLTYPE
-grpcsharp_server_create(const grpc_channel_args *args) {
+GPR_EXPORT grpc_server* GPR_CALLTYPE
+grpcsharp_server_create(const grpc_channel_args* args) {
return grpc_server_create(args, NULL);
}
GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_register_completion_queue(
- grpc_server *server, grpc_completion_queue *cq) {
+ grpc_server* server, grpc_completion_queue* cq) {
grpc_server_register_completion_queue(server, cq, NULL);
}
GPR_EXPORT int32_t GPR_CALLTYPE grpcsharp_server_add_insecure_http2_port(
- grpc_server *server, const char *addr) {
+ grpc_server* server, const char* addr) {
return grpc_server_add_insecure_http2_port(server, addr);
}
-GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_start(grpc_server *server) {
+GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_start(grpc_server* server) {
grpc_server_start(server);
}
GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_shutdown_and_notify_callback(
- grpc_server *server, grpc_completion_queue *cq,
- grpcsharp_batch_context *ctx) {
+ grpc_server* server, grpc_completion_queue* cq,
+ grpcsharp_batch_context* ctx) {
grpc_server_shutdown_and_notify(server, cq, ctx);
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_server_cancel_all_calls(grpc_server *server) {
+grpcsharp_server_cancel_all_calls(grpc_server* server) {
grpc_server_cancel_all_calls(server);
}
-GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_destroy(grpc_server *server) {
+GPR_EXPORT void GPR_CALLTYPE grpcsharp_server_destroy(grpc_server* server) {
grpc_server_destroy(server);
}
GPR_EXPORT grpc_call_error GPR_CALLTYPE
-grpcsharp_server_request_call(grpc_server *server, grpc_completion_queue *cq,
- grpcsharp_request_call_context *ctx) {
+grpcsharp_server_request_call(grpc_server* server, grpc_completion_queue* cq,
+ grpcsharp_request_call_context* ctx) {
return grpc_server_request_call(server, &(ctx->call), &(ctx->call_details),
&(ctx->request_metadata), cq, cq, ctx);
}
/* Security */
-static char *default_pem_root_certs = NULL;
+static char* default_pem_root_certs = NULL;
static grpc_ssl_roots_override_result override_ssl_roots_handler(
- char **pem_root_certs) {
+ char** pem_root_certs) {
if (!default_pem_root_certs) {
*pem_root_certs = NULL;
return GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY;
@@ -909,7 +918,7 @@ static grpc_ssl_roots_override_result override_ssl_roots_handler(
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_override_default_ssl_roots(const char *pem_root_certs) {
+grpcsharp_override_default_ssl_roots(const char* pem_root_certs) {
/*
* This currently wastes ~300kB of memory by keeping a copy of roots
* in a static variable, but for desktop/server use, the overhead
@@ -920,10 +929,10 @@ grpcsharp_override_default_ssl_roots(const char *pem_root_certs) {
grpc_set_ssl_roots_override_callback(override_ssl_roots_handler);
}
-GPR_EXPORT grpc_channel_credentials *GPR_CALLTYPE
-grpcsharp_ssl_credentials_create(const char *pem_root_certs,
- const char *key_cert_pair_cert_chain,
- const char *key_cert_pair_private_key) {
+GPR_EXPORT grpc_channel_credentials* GPR_CALLTYPE
+grpcsharp_ssl_credentials_create(const char* pem_root_certs,
+ const char* key_cert_pair_cert_chain,
+ const char* key_cert_pair_private_key) {
grpc_ssl_pem_key_cert_pair key_cert_pair;
if (key_cert_pair_cert_chain || key_cert_pair_private_key) {
key_cert_pair.cert_chain = key_cert_pair_cert_chain;
@@ -937,29 +946,29 @@ grpcsharp_ssl_credentials_create(const char *pem_root_certs,
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_channel_credentials_release(grpc_channel_credentials *creds) {
+grpcsharp_channel_credentials_release(grpc_channel_credentials* creds) {
grpc_channel_credentials_release(creds);
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_call_credentials_release(grpc_call_credentials *creds) {
+grpcsharp_call_credentials_release(grpc_call_credentials* creds) {
grpc_call_credentials_release(creds);
}
-GPR_EXPORT grpc_channel *GPR_CALLTYPE grpcsharp_secure_channel_create(
- grpc_channel_credentials *creds, const char *target,
- const grpc_channel_args *args) {
+GPR_EXPORT grpc_channel* GPR_CALLTYPE grpcsharp_secure_channel_create(
+ grpc_channel_credentials* creds, const char* target,
+ const grpc_channel_args* args) {
return grpc_secure_channel_create(creds, target, args, NULL);
}
-GPR_EXPORT grpc_server_credentials *GPR_CALLTYPE
+GPR_EXPORT grpc_server_credentials* GPR_CALLTYPE
grpcsharp_ssl_server_credentials_create(
- const char *pem_root_certs, const char **key_cert_pair_cert_chain_array,
- const char **key_cert_pair_private_key_array, size_t num_key_cert_pairs,
+ const char* pem_root_certs, const char** key_cert_pair_cert_chain_array,
+ const char** key_cert_pair_private_key_array, size_t num_key_cert_pairs,
int force_client_auth) {
size_t i;
- grpc_server_credentials *creds;
- grpc_ssl_pem_key_cert_pair *key_cert_pairs =
+ grpc_server_credentials* creds;
+ grpc_ssl_pem_key_cert_pair* key_cert_pairs =
gpr_malloc(sizeof(grpc_ssl_pem_key_cert_pair) * num_key_cert_pairs);
memset(key_cert_pairs, 0,
sizeof(grpc_ssl_pem_key_cert_pair) * num_key_cert_pairs);
@@ -982,35 +991,35 @@ grpcsharp_ssl_server_credentials_create(
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_server_credentials_release(grpc_server_credentials *creds) {
+grpcsharp_server_credentials_release(grpc_server_credentials* creds) {
grpc_server_credentials_release(creds);
}
GPR_EXPORT int32_t GPR_CALLTYPE grpcsharp_server_add_secure_http2_port(
- grpc_server *server, const char *addr, grpc_server_credentials *creds) {
+ grpc_server* server, const char* addr, grpc_server_credentials* creds) {
return grpc_server_add_secure_http2_port(server, addr, creds);
}
-GPR_EXPORT grpc_channel_credentials *GPR_CALLTYPE
+GPR_EXPORT grpc_channel_credentials* GPR_CALLTYPE
grpcsharp_composite_channel_credentials_create(
- grpc_channel_credentials *channel_creds,
- grpc_call_credentials *call_creds) {
+ grpc_channel_credentials* channel_creds,
+ grpc_call_credentials* call_creds) {
return grpc_composite_channel_credentials_create(channel_creds, call_creds,
NULL);
}
-GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE
-grpcsharp_composite_call_credentials_create(grpc_call_credentials *creds1,
- grpc_call_credentials *creds2) {
+GPR_EXPORT grpc_call_credentials* GPR_CALLTYPE
+grpcsharp_composite_call_credentials_create(grpc_call_credentials* creds1,
+ grpc_call_credentials* creds2) {
return grpc_composite_call_credentials_create(creds1, creds2, NULL);
}
/* Metadata credentials plugin */
GPR_EXPORT void GPR_CALLTYPE grpcsharp_metadata_credentials_notify_from_plugin(
- grpc_credentials_plugin_metadata_cb cb, void *user_data,
- grpc_metadata_array *metadata, grpc_status_code status,
- const char *error_details) {
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata_array* metadata, grpc_status_code status,
+ const char* error_details) {
if (metadata) {
cb(user_data, metadata->metadata, metadata->count, status, error_details);
} else {
@@ -1018,75 +1027,79 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_metadata_credentials_notify_from_plugin(
}
}
-typedef void(GPR_CALLTYPE *grpcsharp_metadata_interceptor_func)(
- void *state, const char *service_url, const char *method_name,
- grpc_credentials_plugin_metadata_cb cb, void *user_data,
+typedef void(GPR_CALLTYPE* grpcsharp_metadata_interceptor_func)(
+ void* state, const char* service_url, const char* method_name,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
int32_t is_destroy);
-static void grpcsharp_get_metadata_handler(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data) {
+static int grpcsharp_get_metadata_handler(
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
grpcsharp_metadata_interceptor_func interceptor =
(grpcsharp_metadata_interceptor_func)(intptr_t)state;
interceptor(state, context.service_url, context.method_name, cb, user_data,
0);
+ return 0; /* Asynchronous return. */
}
-static void grpcsharp_metadata_credentials_destroy_handler(void *state) {
+static void grpcsharp_metadata_credentials_destroy_handler(void* state) {
grpcsharp_metadata_interceptor_func interceptor =
(grpcsharp_metadata_interceptor_func)(intptr_t)state;
interceptor(state, NULL, NULL, NULL, NULL, 1);
}
-GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE
+GPR_EXPORT grpc_call_credentials* GPR_CALLTYPE
grpcsharp_metadata_credentials_create_from_plugin(
grpcsharp_metadata_interceptor_func metadata_interceptor) {
grpc_metadata_credentials_plugin plugin;
plugin.get_metadata = grpcsharp_get_metadata_handler;
plugin.destroy = grpcsharp_metadata_credentials_destroy_handler;
- plugin.state = (void *)(intptr_t)metadata_interceptor;
+ plugin.state = (void*)(intptr_t)metadata_interceptor;
plugin.type = "";
return grpc_metadata_credentials_create_from_plugin(plugin, NULL);
}
/* Auth context */
-GPR_EXPORT grpc_auth_context *GPR_CALLTYPE
-grpcsharp_call_auth_context(grpc_call *call) {
+GPR_EXPORT grpc_auth_context* GPR_CALLTYPE
+grpcsharp_call_auth_context(grpc_call* call) {
return grpc_call_auth_context(call);
}
-GPR_EXPORT const char *GPR_CALLTYPE
+GPR_EXPORT const char* GPR_CALLTYPE
grpcsharp_auth_context_peer_identity_property_name(
- const grpc_auth_context *ctx) {
+ const grpc_auth_context* ctx) {
return grpc_auth_context_peer_identity_property_name(ctx);
}
GPR_EXPORT grpc_auth_property_iterator GPR_CALLTYPE
-grpcsharp_auth_context_property_iterator(const grpc_auth_context *ctx) {
+grpcsharp_auth_context_property_iterator(const grpc_auth_context* ctx) {
return grpc_auth_context_property_iterator(ctx);
}
-GPR_EXPORT const grpc_auth_property *GPR_CALLTYPE
-grpcsharp_auth_property_iterator_next(grpc_auth_property_iterator *it) {
+GPR_EXPORT const grpc_auth_property* GPR_CALLTYPE
+grpcsharp_auth_property_iterator_next(grpc_auth_property_iterator* it) {
return grpc_auth_property_iterator_next(it);
}
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_auth_context_release(grpc_auth_context *ctx) {
+grpcsharp_auth_context_release(grpc_auth_context* ctx) {
grpc_auth_context_release(ctx);
}
/* Logging */
-typedef void(GPR_CALLTYPE *grpcsharp_log_func)(const char *file, int32_t line,
+typedef void(GPR_CALLTYPE* grpcsharp_log_func)(const char* file, int32_t line,
uint64_t thd_id,
- const char *severity_string,
- const char *msg);
+ const char* severity_string,
+ const char* msg);
static grpcsharp_log_func log_func = NULL;
/* Redirects gpr_log to log_func callback */
-static void grpcsharp_log_handler(gpr_log_func_args *args) {
+static void grpcsharp_log_handler(gpr_log_func_args* args) {
log_func(args->file, args->line, gpr_thd_currentid(),
gpr_log_severity_string(args->severity), args->message);
}
@@ -1097,10 +1110,10 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) {
gpr_set_log_function(grpcsharp_log_handler);
}
-typedef void(GPR_CALLTYPE *test_callback_funcptr)(int32_t success);
+typedef void(GPR_CALLTYPE* test_callback_funcptr)(int32_t success);
/* Version info */
-GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_version_string() {
+GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_version_string() {
return grpc_version_string();
}
@@ -1111,7 +1124,7 @@ grpcsharp_test_callback(test_callback_funcptr callback) {
}
/* For testing */
-GPR_EXPORT void *GPR_CALLTYPE grpcsharp_test_nop(void *ptr) { return ptr; }
+GPR_EXPORT void* GPR_CALLTYPE grpcsharp_test_nop(void* ptr) { return ptr; }
/* For testing */
GPR_EXPORT int32_t GPR_CALLTYPE grpcsharp_sizeof_grpc_event(void) {
@@ -1120,7 +1133,7 @@ GPR_EXPORT int32_t GPR_CALLTYPE grpcsharp_sizeof_grpc_event(void) {
/* Override a method for testing */
GPR_EXPORT void GPR_CALLTYPE
-grpcsharp_test_override_method(const char *method_name, const char *variant) {
+grpcsharp_test_override_method(const char* method_name, const char* variant) {
if (strcmp("grpcsharp_call_start_batch", method_name) == 0) {
if (strcmp("nop", variant) == 0) {
g_call_start_batch_func = grpcsharp_call_start_batch_nop;
diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh
index 1a1adbbae5..299dc3f816 100755
--- a/src/csharp/generate_proto_csharp.sh
+++ b/src/csharp/generate_proto_csharp.sh
@@ -33,6 +33,11 @@ $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_D
$PROTOC --plugin=$PLUGIN --csharp_out=$REFLECTION_DIR --grpc_out=$REFLECTION_DIR \
-I src/proto src/proto/grpc/reflection/v1alpha/reflection.proto
+# Put grp/core/stats.proto in a subdirectory to avoid collision with grpc/testing/stats.proto
+mkdir -p $TESTING_DIR/CoreStats
+$PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR/CoreStats --grpc_out=$TESTING_DIR/CoreStats \
+ -I src/proto src/proto/grpc/core/stats.proto
+
# TODO(jtattermusch): following .proto files are a bit broken and import paths
# don't match the package names. Setting -I to the correct value src/proto
# breaks the code generation.
diff --git a/src/csharp/tests.json b/src/csharp/tests.json
index 7841051052..469328af1a 100644
--- a/src/csharp/tests.json
+++ b/src/csharp/tests.json
@@ -5,13 +5,16 @@
"Grpc.Core.Internal.Tests.ChannelArgsSafeHandleTest",
"Grpc.Core.Internal.Tests.CompletionQueueEventTest",
"Grpc.Core.Internal.Tests.CompletionQueueSafeHandleTest",
+ "Grpc.Core.Internal.Tests.DefaultObjectPoolTest",
"Grpc.Core.Internal.Tests.MetadataArraySafeHandleTest",
"Grpc.Core.Internal.Tests.TimespecTest",
"Grpc.Core.Tests.AppDomainUnloadTest",
"Grpc.Core.Tests.AuthContextTest",
"Grpc.Core.Tests.AuthPropertyTest",
+ "Grpc.Core.Tests.CallCancellationTest",
"Grpc.Core.Tests.CallCredentialsTest",
"Grpc.Core.Tests.CallOptionsTest",
+ "Grpc.Core.Tests.ChannelConnectivityTest",
"Grpc.Core.Tests.ChannelCredentialsTest",
"Grpc.Core.Tests.ChannelOptionsTest",
"Grpc.Core.Tests.ChannelTest",
diff --git a/src/node/.jshintignore b/src/node/.jshintignore
deleted file mode 100644
index 0a73e1e2b6..0000000000
--- a/src/node/.jshintignore
+++ /dev/null
@@ -1 +0,0 @@
-**/*_pb.js \ No newline at end of file
diff --git a/src/node/README.md b/src/node/README.md
deleted file mode 100644
index 3b98b97879..0000000000
--- a/src/node/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-[![npm](https://img.shields.io/npm/v/grpc.svg)](https://www.npmjs.com/package/grpc)
-# Node.js gRPC Library
-
-## PREREQUISITES
-- `node`: This requires `node` to be installed, version `4.0` or above. If you instead have the `nodejs` executable on Debian, you should install the [`nodejs-legacy`](https://packages.debian.org/sid/nodejs-legacy) package.
-
-- **Note:** If you installed `node` via a package manager and the version is still less than `4.0`, try directly installing it from [nodejs.org](https://nodejs.org).
-
-## INSTALLATION
-
-Install the gRPC NPM package
-
-```sh
-npm install grpc
-```
-
-## BUILD FROM SOURCE
- 1. Clone [the grpc Git Repository](https://github.com/grpc/grpc).
- 2. Run `npm install --build-from-source` from the repository root.
-
- - **Note:** On Windows, this might fail due to [nodejs issue #4932](https://github.com/nodejs/node/issues/4932) in which case, you will see something like the following in `npm install`'s output (towards the very beginning):
-
- ```
- ..
- Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
- WINDOWS_BUILD_WARNING
- "..\IMPORTANT: Due to https:\github.com\nodejs\node\issues\4932, to build this library on Windows, you must first remove C:\Users\jenkins\.node-gyp\4.4.0\include\node\openssl"
- ...
- ..
- ```
-
- To fix this, you will have to delete the folder `C:\Users\<username>\.node-gyp\<node_version>\include\node\openssl` and retry `npm install`
-
-
-## TESTING
-To run the test suite, simply run `npm test` in the install location.
diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc
deleted file mode 100644
index 1040f70d71..0000000000
--- a/src/node/ext/byte_buffer.cc
+++ /dev/null
@@ -1,79 +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 <string.h>
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/byte_buffer_reader.h"
-#include "grpc/grpc.h"
-#include "grpc/slice.h"
-
-#include "byte_buffer.h"
-#include "slice.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::MaybeLocal;
-
-using v8::Function;
-using v8::Local;
-using v8::Object;
-using v8::Number;
-using v8::Value;
-
-grpc_byte_buffer *BufferToByteBuffer(Local<Value> buffer) {
- Nan::HandleScope scope;
- grpc_slice slice = CreateSliceFromBuffer(buffer);
- grpc_byte_buffer *byte_buffer(grpc_raw_byte_buffer_create(&slice, 1));
- grpc_slice_unref(slice);
- return byte_buffer;
-}
-
-namespace {
-void delete_buffer(char *data, void *hint) {
- grpc_slice *slice = static_cast<grpc_slice *>(hint);
- grpc_slice_unref(*slice);
- delete slice;
-}
-}
-
-Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
- Nan::EscapableHandleScope scope;
- if (buffer == NULL) {
- return scope.Escape(Nan::Null());
- }
- grpc_byte_buffer_reader reader;
- if (!grpc_byte_buffer_reader_init(&reader, buffer)) {
- Nan::ThrowError("Error initializing byte buffer reader.");
- return scope.Escape(Nan::Undefined());
- }
- grpc_slice *slice = new grpc_slice;
- *slice = grpc_byte_buffer_reader_readall(&reader);
- grpc_byte_buffer_reader_destroy(&reader);
- char *result = reinterpret_cast<char *>(GRPC_SLICE_START_PTR(*slice));
- size_t length = GRPC_SLICE_LENGTH(*slice);
- Local<Value> buf =
- Nan::NewBuffer(result, length, delete_buffer, slice).ToLocalChecked();
- return scope.Escape(buf);
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/byte_buffer.h b/src/node/ext/byte_buffer.h
deleted file mode 100644
index 6223147607..0000000000
--- a/src/node/ext/byte_buffer.h
+++ /dev/null
@@ -1,41 +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 NET_GRPC_NODE_BYTE_BUFFER_H_
-#define NET_GRPC_NODE_BYTE_BUFFER_H_
-
-#include <string.h>
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/grpc.h"
-
-namespace grpc {
-namespace node {
-
-/* Convert a Node.js Buffer to grpc_byte_buffer. Requires that
- ::node::Buffer::HasInstance(buffer) */
-grpc_byte_buffer *BufferToByteBuffer(v8::Local<v8::Value> buffer);
-
-/* Convert a grpc_byte_buffer to a Node.js Buffer */
-v8::Local<v8::Value> ByteBufferToBuffer(grpc_byte_buffer *buffer);
-
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_BYTE_BUFFER_H_
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
deleted file mode 100644
index 26095a78f9..0000000000
--- a/src/node/ext/call.cc
+++ /dev/null
@@ -1,815 +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 <map>
-#include <memory>
-#include <vector>
-
-#include <node.h>
-
-#include "byte_buffer.h"
-#include "call.h"
-#include "call_credentials.h"
-#include "channel.h"
-#include "completion_queue.h"
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "grpc/support/alloc.h"
-#include "grpc/support/log.h"
-#include "grpc/support/time.h"
-#include "slice.h"
-#include "timeval.h"
-
-using std::unique_ptr;
-using std::shared_ptr;
-using std::vector;
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::EscapableHandleScope;
-using Nan::HandleScope;
-using Nan::Maybe;
-using Nan::MaybeLocal;
-using Nan::ObjectWrap;
-using Nan::Persistent;
-using Nan::Utf8String;
-
-using v8::Array;
-using v8::Boolean;
-using v8::Exception;
-using v8::External;
-using v8::Function;
-using v8::FunctionTemplate;
-using v8::Integer;
-using v8::Local;
-using v8::Number;
-using v8::Object;
-using v8::ObjectTemplate;
-using v8::Uint32;
-using v8::String;
-using v8::Value;
-
-Callback *Call::constructor;
-Persistent<FunctionTemplate> Call::fun_tpl;
-
-/**
- * Helper function for throwing errors with a grpc_call_error value.
- * Modified from the answer by Gus Goose to
- * http://stackoverflow.com/questions/31794200.
- */
-Local<Value> nanErrorWithCode(const char *msg, grpc_call_error code) {
- EscapableHandleScope scope;
- Local<Object> err = Nan::Error(msg).As<Object>();
- Nan::Set(err, Nan::New("code").ToLocalChecked(), Nan::New<Uint32>(code));
- return scope.Escape(err);
-}
-
-bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array) {
- HandleScope scope;
- Local<Array> keys = Nan::GetOwnPropertyNames(metadata).ToLocalChecked();
- for (unsigned int i = 0; i < keys->Length(); i++) {
- Local<String> current_key =
- Nan::To<String>(Nan::Get(keys, i).ToLocalChecked()).ToLocalChecked();
- Local<Value> value_array = Nan::Get(metadata, current_key).ToLocalChecked();
- if (!value_array->IsArray()) {
- return false;
- }
- array->capacity += Local<Array>::Cast(value_array)->Length();
- }
- array->metadata = reinterpret_cast<grpc_metadata *>(
- gpr_zalloc(array->capacity * sizeof(grpc_metadata)));
- for (unsigned int i = 0; i < keys->Length(); i++) {
- Local<String> current_key(Nan::To<String>(keys->Get(i)).ToLocalChecked());
- Local<Array> values =
- Local<Array>::Cast(Nan::Get(metadata, current_key).ToLocalChecked());
- grpc_slice key_slice = CreateSliceFromString(current_key);
- grpc_slice key_intern_slice = grpc_slice_intern(key_slice);
- grpc_slice_unref(key_slice);
- for (unsigned int j = 0; j < values->Length(); j++) {
- Local<Value> value = Nan::Get(values, j).ToLocalChecked();
- grpc_metadata *current = &array->metadata[array->count];
- current->key = key_intern_slice;
- // Only allow binary headers for "-bin" keys
- if (grpc_is_binary_header(key_intern_slice)) {
- if (::node::Buffer::HasInstance(value)) {
- current->value = CreateSliceFromBuffer(value);
- } else {
- return false;
- }
- } else {
- if (value->IsString()) {
- Local<String> string_value = Nan::To<String>(value).ToLocalChecked();
- current->value = CreateSliceFromString(string_value);
- } else {
- return false;
- }
- }
- array->count += 1;
- }
- }
- return true;
-}
-
-void DestroyMetadataArray(grpc_metadata_array *array) {
- for (size_t i = 0; i < array->count; i++) {
- // Don't unref keys because they are interned
- grpc_slice_unref(array->metadata[i].value);
- }
- grpc_metadata_array_destroy(array);
-}
-
-Local<Value> ParseMetadata(const grpc_metadata_array *metadata_array) {
- EscapableHandleScope scope;
- grpc_metadata *metadata_elements = metadata_array->metadata;
- size_t length = metadata_array->count;
- Local<Object> metadata_object = Nan::New<Object>();
- for (unsigned int i = 0; i < length; i++) {
- grpc_metadata *elem = &metadata_elements[i];
- // TODO(murgatroid99): Use zero-copy string construction instead
- Local<String> key_string = CopyStringFromSlice(elem->key);
- Local<Array> array;
- MaybeLocal<Value> maybe_array = Nan::Get(metadata_object, key_string);
- if (maybe_array.IsEmpty() || !maybe_array.ToLocalChecked()->IsArray()) {
- array = Nan::New<Array>(0);
- Nan::Set(metadata_object, key_string, array);
- } else {
- array = Local<Array>::Cast(maybe_array.ToLocalChecked());
- }
- if (grpc_is_binary_header(elem->key)) {
- Nan::Set(array, array->Length(), CreateBufferFromSlice(elem->value));
- } else {
- // TODO(murgatroid99): Use zero-copy string construction instead
- Nan::Set(array, array->Length(), CopyStringFromSlice(elem->value));
- }
- }
- return scope.Escape(metadata_object);
-}
-
-Local<Value> Op::GetOpType() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::New(GetTypeString()).ToLocalChecked());
-}
-
-Op::~Op() {}
-
-class SendMetadataOp : public Op {
- public:
- SendMetadataOp() { grpc_metadata_array_init(&send_metadata); }
- ~SendMetadataOp() { DestroyMetadataArray(&send_metadata); }
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::True());
- }
- bool ParseOp(Local<Value> value, grpc_op *out) {
- if (!value->IsObject()) {
- return false;
- }
- MaybeLocal<Object> maybe_metadata = Nan::To<Object>(value);
- if (maybe_metadata.IsEmpty()) {
- return false;
- }
- if (!CreateMetadataArray(maybe_metadata.ToLocalChecked(), &send_metadata)) {
- return false;
- }
- out->data.send_initial_metadata.count = send_metadata.count;
- out->data.send_initial_metadata.metadata = send_metadata.metadata;
- return true;
- }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "send_metadata"; }
-
- private:
- grpc_metadata_array send_metadata;
-};
-
-class SendMessageOp : public Op {
- public:
- SendMessageOp() { send_message = NULL; }
- ~SendMessageOp() {
- if (send_message != NULL) {
- grpc_byte_buffer_destroy(send_message);
- }
- }
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::True());
- }
- bool ParseOp(Local<Value> value, grpc_op *out) {
- if (!::node::Buffer::HasInstance(value)) {
- return false;
- }
- Local<Object> object_value = Nan::To<Object>(value).ToLocalChecked();
- MaybeLocal<Value> maybe_flag_value =
- Nan::Get(object_value, Nan::New("grpcWriteFlags").ToLocalChecked());
- if (!maybe_flag_value.IsEmpty()) {
- Local<Value> flag_value = maybe_flag_value.ToLocalChecked();
- if (flag_value->IsUint32()) {
- Maybe<uint32_t> maybe_flag = Nan::To<uint32_t>(flag_value);
- out->flags = maybe_flag.FromMaybe(0) & GRPC_WRITE_USED_MASK;
- }
- }
- send_message = BufferToByteBuffer(value);
- out->data.send_message.send_message = send_message;
- return true;
- }
-
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "send_message"; }
-
- private:
- grpc_byte_buffer *send_message;
-};
-
-class SendClientCloseOp : public Op {
- public:
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::True());
- }
-
- bool ParseOp(Local<Value> value, grpc_op *out) { return true; }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "client_close"; }
-};
-
-class SendServerStatusOp : public Op {
- public:
- SendServerStatusOp() {
- details = grpc_empty_slice();
- grpc_metadata_array_init(&status_metadata);
- }
- ~SendServerStatusOp() {
- grpc_slice_unref(details);
- DestroyMetadataArray(&status_metadata);
- }
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::True());
- }
- bool ParseOp(Local<Value> value, grpc_op *out) {
- if (!value->IsObject()) {
- return false;
- }
- Local<Object> server_status = Nan::To<Object>(value).ToLocalChecked();
- MaybeLocal<Value> maybe_metadata =
- Nan::Get(server_status, Nan::New("metadata").ToLocalChecked());
- if (maybe_metadata.IsEmpty()) {
- return false;
- }
- if (!maybe_metadata.ToLocalChecked()->IsObject()) {
- return false;
- }
- Local<Object> metadata =
- Nan::To<Object>(maybe_metadata.ToLocalChecked()).ToLocalChecked();
- MaybeLocal<Value> maybe_code =
- Nan::Get(server_status, Nan::New("code").ToLocalChecked());
- if (maybe_code.IsEmpty()) {
- return false;
- }
- if (!maybe_code.ToLocalChecked()->IsUint32()) {
- return false;
- }
- uint32_t code = Nan::To<uint32_t>(maybe_code.ToLocalChecked()).FromJust();
- MaybeLocal<Value> maybe_details =
- Nan::Get(server_status, Nan::New("details").ToLocalChecked());
- if (maybe_details.IsEmpty()) {
- return false;
- }
- if (!maybe_details.ToLocalChecked()->IsString()) {
- return false;
- }
- Local<String> details =
- Nan::To<String>(maybe_details.ToLocalChecked()).ToLocalChecked();
- if (!CreateMetadataArray(metadata, &status_metadata)) {
- return false;
- }
- out->data.send_status_from_server.trailing_metadata_count =
- status_metadata.count;
- out->data.send_status_from_server.trailing_metadata =
- status_metadata.metadata;
- out->data.send_status_from_server.status =
- static_cast<grpc_status_code>(code);
- this->details = CreateSliceFromString(details);
- out->data.send_status_from_server.status_details = &this->details;
- return true;
- }
- bool IsFinalOp() { return true; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "send_status"; }
-
- private:
- grpc_slice details;
- grpc_metadata_array status_metadata;
-};
-
-class GetMetadataOp : public Op {
- public:
- GetMetadataOp() { grpc_metadata_array_init(&recv_metadata); }
-
- ~GetMetadataOp() { grpc_metadata_array_destroy(&recv_metadata); }
-
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(ParseMetadata(&recv_metadata));
- }
-
- bool ParseOp(Local<Value> value, grpc_op *out) {
- out->data.recv_initial_metadata.recv_initial_metadata = &recv_metadata;
- return true;
- }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "metadata"; }
-
- private:
- grpc_metadata_array recv_metadata;
-};
-
-class ReadMessageOp : public Op {
- public:
- ReadMessageOp() { recv_message = NULL; }
- ~ReadMessageOp() {
- if (recv_message != NULL) {
- grpc_byte_buffer_destroy(recv_message);
- }
- }
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(ByteBufferToBuffer(recv_message));
- }
-
- bool ParseOp(Local<Value> value, grpc_op *out) {
- out->data.recv_message.recv_message = &recv_message;
- return true;
- }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "read"; }
-
- private:
- grpc_byte_buffer *recv_message;
-};
-
-class ClientStatusOp : public Op {
- public:
- ClientStatusOp() {
- grpc_metadata_array_init(&metadata_array);
- status_details = grpc_empty_slice();
- }
-
- ~ClientStatusOp() {
- grpc_metadata_array_destroy(&metadata_array);
- grpc_slice_unref(status_details);
- }
-
- bool ParseOp(Local<Value> value, grpc_op *out) {
- out->data.recv_status_on_client.trailing_metadata = &metadata_array;
- out->data.recv_status_on_client.status = &status;
- out->data.recv_status_on_client.status_details = &status_details;
- return true;
- }
-
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- Local<Object> status_obj = Nan::New<Object>();
- Nan::Set(status_obj, Nan::New("code").ToLocalChecked(),
- Nan::New<Number>(status));
- Nan::Set(status_obj, Nan::New("details").ToLocalChecked(),
- CopyStringFromSlice(status_details));
- Nan::Set(status_obj, Nan::New("metadata").ToLocalChecked(),
- ParseMetadata(&metadata_array));
- return scope.Escape(status_obj);
- }
- bool IsFinalOp() { return true; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "status"; }
-
- private:
- grpc_metadata_array metadata_array;
- grpc_status_code status;
- grpc_slice status_details;
-};
-
-class ServerCloseResponseOp : public Op {
- public:
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::New<Boolean>(cancelled));
- }
-
- bool ParseOp(Local<Value> value, grpc_op *out) {
- out->data.recv_close_on_server.cancelled = &cancelled;
- return true;
- }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- protected:
- std::string GetTypeString() const { return "cancelled"; }
-
- private:
- int cancelled;
-};
-
-tag::tag(Callback *callback, OpVec *ops, Call *call, Local<Value> call_value)
- : callback(callback), ops(ops), call(call) {
- HandleScope scope;
- call_persist.Reset(call_value);
-}
-
-tag::~tag() {
- delete callback;
- delete ops;
-}
-
-void CompleteTag(void *tag, const char *error_message) {
- HandleScope scope;
- struct tag *tag_struct = reinterpret_cast<struct tag *>(tag);
- Callback *callback = tag_struct->callback;
- if (error_message == NULL) {
- Local<Object> tag_obj = Nan::New<Object>();
- for (vector<unique_ptr<Op> >::iterator it = tag_struct->ops->begin();
- it != tag_struct->ops->end(); ++it) {
- Op *op_ptr = it->get();
- Nan::Set(tag_obj, op_ptr->GetOpType(), op_ptr->GetNodeValue());
- }
- Local<Value> argv[] = {Nan::Null(), tag_obj};
- callback->Call(2, argv);
- } else {
- Local<Value> argv[] = {Nan::Error(error_message)};
- callback->Call(1, argv);
- }
- bool success = (error_message == NULL);
- bool is_final_op = false;
- for (vector<unique_ptr<Op> >::iterator it = tag_struct->ops->begin();
- it != tag_struct->ops->end(); ++it) {
- Op *op_ptr = it->get();
- op_ptr->OnComplete(success);
- if (op_ptr->IsFinalOp()) {
- is_final_op = true;
- }
- }
- if (tag_struct->call == NULL) {
- return;
- }
- tag_struct->call->CompleteBatch(is_final_op);
-}
-
-void DestroyTag(void *tag) {
- struct tag *tag_struct = reinterpret_cast<struct tag *>(tag);
- delete tag_struct;
-}
-
-void Call::DestroyCall() {
- if (this->wrapped_call != NULL) {
- grpc_call_unref(this->wrapped_call);
- this->wrapped_call = NULL;
- }
-}
-
-Call::Call(grpc_call *call)
- : wrapped_call(call), pending_batches(0), has_final_op_completed(false) {
- peer = grpc_call_get_peer(call);
-}
-
-Call::~Call() {
- DestroyCall();
- gpr_free(peer);
-}
-
-void Call::Init(Local<Object> exports) {
- HandleScope scope;
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
- tpl->SetClassName(Nan::New("Call").ToLocalChecked());
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- Nan::SetPrototypeMethod(tpl, "startBatch", StartBatch);
- Nan::SetPrototypeMethod(tpl, "cancel", Cancel);
- Nan::SetPrototypeMethod(tpl, "cancelWithStatus", CancelWithStatus);
- Nan::SetPrototypeMethod(tpl, "getPeer", GetPeer);
- Nan::SetPrototypeMethod(tpl, "setCredentials", SetCredentials);
- fun_tpl.Reset(tpl);
- Local<Function> ctr = Nan::GetFunction(tpl).ToLocalChecked();
- Nan::Set(exports, Nan::New("Call").ToLocalChecked(), ctr);
- constructor = new Callback(ctr);
-}
-
-bool Call::HasInstance(Local<Value> val) {
- HandleScope scope;
- return Nan::New(fun_tpl)->HasInstance(val);
-}
-
-Local<Value> Call::WrapStruct(grpc_call *call) {
- EscapableHandleScope scope;
- if (call == NULL) {
- return scope.Escape(Nan::Null());
- }
- const int argc = 1;
- Local<Value> argv[argc] = {
- Nan::New<External>(reinterpret_cast<void *>(call))};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- return scope.Escape(Nan::Null());
- } else {
- return scope.Escape(maybe_instance.ToLocalChecked());
- }
-}
-
-void Call::CompleteBatch(bool is_final_op) {
- if (is_final_op) {
- this->has_final_op_completed = true;
- }
- this->pending_batches--;
- if (this->has_final_op_completed && this->pending_batches == 0) {
- this->DestroyCall();
- }
-}
-
-NAN_METHOD(Call::New) {
- /* Arguments:
- * 0: Channel to make the call on
- * 1: Method
- * 2: Deadline
- * 3: host
- * 4: parent Call
- * 5: propagation flags
- */
- if (info.IsConstructCall()) {
- Call *call;
- if (info[0]->IsExternal()) {
- Local<External> ext = info[0].As<External>();
- // This option is used for wrapping an existing call
- grpc_call *call_value = reinterpret_cast<grpc_call *>(ext->Value());
- call = new Call(call_value);
- } else {
- if (!Channel::HasInstance(info[0])) {
- return Nan::ThrowTypeError("Call's first argument must be a Channel");
- }
- if (!info[1]->IsString()) {
- return Nan::ThrowTypeError("Call's second argument must be a string");
- }
- if (!(info[2]->IsNumber() || info[2]->IsDate())) {
- return Nan::ThrowTypeError(
- "Call's third argument must be a date or a number");
- }
- // These arguments are at the end because they are optional
- grpc_call *parent_call = NULL;
- if (Call::HasInstance(info[4])) {
- Call *parent_obj =
- ObjectWrap::Unwrap<Call>(Nan::To<Object>(info[4]).ToLocalChecked());
- parent_call = parent_obj->wrapped_call;
- } else if (!(info[4]->IsUndefined() || info[4]->IsNull())) {
- return Nan::ThrowTypeError(
- "Call's fifth argument must be another call, if provided");
- }
- uint32_t propagate_flags = GRPC_PROPAGATE_DEFAULTS;
- if (info[5]->IsUint32()) {
- propagate_flags = Nan::To<uint32_t>(info[5]).FromJust();
- } else if (!(info[5]->IsUndefined() || info[5]->IsNull())) {
- return Nan::ThrowTypeError(
- "Call's sixth argument must be propagate flags, if provided");
- }
- Local<Object> channel_object = Nan::To<Object>(info[0]).ToLocalChecked();
- Channel *channel = ObjectWrap::Unwrap<Channel>(channel_object);
- if (channel->GetWrappedChannel() == NULL) {
- return Nan::ThrowError("Call cannot be created from a closed channel");
- }
- double deadline = Nan::To<double>(info[2]).FromJust();
- grpc_channel *wrapped_channel = channel->GetWrappedChannel();
- grpc_call *wrapped_call;
- grpc_slice method =
- CreateSliceFromString(Nan::To<String>(info[1]).ToLocalChecked());
- if (info[3]->IsString()) {
- grpc_slice *host = new grpc_slice;
- *host =
- CreateSliceFromString(Nan::To<String>(info[3]).ToLocalChecked());
- wrapped_call = grpc_channel_create_call(
- wrapped_channel, parent_call, propagate_flags, GetCompletionQueue(),
- method, host, MillisecondsToTimespec(deadline), NULL);
- delete host;
- } else if (info[3]->IsUndefined() || info[3]->IsNull()) {
- wrapped_call = grpc_channel_create_call(
- wrapped_channel, parent_call, propagate_flags, GetCompletionQueue(),
- method, NULL, MillisecondsToTimespec(deadline), NULL);
- } else {
- return Nan::ThrowTypeError("Call's fourth argument must be a string");
- }
- grpc_slice_unref(method);
- call = new Call(wrapped_call);
- Nan::Set(info.This(), Nan::New("channel_").ToLocalChecked(),
- channel_object);
- }
- call->Wrap(info.This());
- info.GetReturnValue().Set(info.This());
- } else {
- const int argc = 4;
- Local<Value> argv[argc] = {info[0], info[1], info[2], info[3]};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- // There's probably a pending exception
- return;
- } else {
- info.GetReturnValue().Set(maybe_instance.ToLocalChecked());
- }
- }
-}
-
-NAN_METHOD(Call::StartBatch) {
- if (!Call::HasInstance(info.This())) {
- return Nan::ThrowTypeError("startBatch can only be called on Call objects");
- }
- if (!info[0]->IsObject()) {
- return Nan::ThrowError("startBatch's first argument must be an object");
- }
- if (!info[1]->IsFunction()) {
- return Nan::ThrowError("startBatch's second argument must be a callback");
- }
- Local<Function> callback_func = info[1].As<Function>();
- Call *call = ObjectWrap::Unwrap<Call>(info.This());
- if (call->wrapped_call == NULL) {
- /* This implies that the call has completed and has been destroyed. To
- * emulate
- * previous behavior, we should call the callback immediately with an error,
- * as though the batch had failed in core */
- Local<Value> argv[] = {
- Nan::Error("The async function failed because the call has completed")};
- Nan::Call(callback_func, Nan::New<Object>(), 1, argv);
- return;
- }
- Local<Object> obj = Nan::To<Object>(info[0]).ToLocalChecked();
- Local<Array> keys = Nan::GetOwnPropertyNames(obj).ToLocalChecked();
- size_t nops = keys->Length();
- vector<grpc_op> ops(nops);
- unique_ptr<OpVec> op_vector(new OpVec());
- for (unsigned int i = 0; i < nops; i++) {
- unique_ptr<Op> op;
- MaybeLocal<Value> maybe_key = Nan::Get(keys, i);
- if (maybe_key.IsEmpty() || (!maybe_key.ToLocalChecked()->IsUint32())) {
- return Nan::ThrowError(
- "startBatch's first argument's keys must be integers");
- }
- uint32_t type = Nan::To<uint32_t>(maybe_key.ToLocalChecked()).FromJust();
- ops[i].op = static_cast<grpc_op_type>(type);
- ops[i].flags = 0;
- ops[i].reserved = NULL;
- switch (type) {
- case GRPC_OP_SEND_INITIAL_METADATA:
- op.reset(new SendMetadataOp());
- break;
- case GRPC_OP_SEND_MESSAGE:
- op.reset(new SendMessageOp());
- break;
- case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
- op.reset(new SendClientCloseOp());
- break;
- case GRPC_OP_SEND_STATUS_FROM_SERVER:
- op.reset(new SendServerStatusOp());
- break;
- case GRPC_OP_RECV_INITIAL_METADATA:
- op.reset(new GetMetadataOp());
- break;
- case GRPC_OP_RECV_MESSAGE:
- op.reset(new ReadMessageOp());
- break;
- case GRPC_OP_RECV_STATUS_ON_CLIENT:
- op.reset(new ClientStatusOp());
- break;
- case GRPC_OP_RECV_CLOSE_ON_SERVER:
- op.reset(new ServerCloseResponseOp());
- break;
- default:
- return Nan::ThrowError("Argument object had an unrecognized key");
- }
- if (!op->ParseOp(obj->Get(type), &ops[i])) {
- return Nan::ThrowTypeError("Incorrectly typed arguments to startBatch");
- }
- op_vector->push_back(std::move(op));
- }
- Callback *callback = new Callback(callback_func);
- grpc_call_error error = grpc_call_start_batch(
- call->wrapped_call, &ops[0], nops,
- new struct tag(callback, op_vector.release(), call, info.This()), NULL);
- if (error != GRPC_CALL_OK) {
- return Nan::ThrowError(nanErrorWithCode("startBatch failed", error));
- }
- call->pending_batches++;
- CompletionQueueNext();
-}
-
-NAN_METHOD(Call::Cancel) {
- if (!Call::HasInstance(info.This())) {
- return Nan::ThrowTypeError("cancel can only be called on Call objects");
- }
- Call *call = ObjectWrap::Unwrap<Call>(info.This());
- if (call->wrapped_call == NULL) {
- /* Cancel is supposed to be idempotent. If the call has already finished,
- * cancel should just complete silently */
- return;
- }
- grpc_call_error error = grpc_call_cancel(call->wrapped_call, NULL);
- if (error != GRPC_CALL_OK) {
- return Nan::ThrowError(nanErrorWithCode("cancel failed", error));
- }
-}
-
-NAN_METHOD(Call::CancelWithStatus) {
- Nan::HandleScope scope;
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("cancel can only be called on Call objects");
- }
- if (!info[0]->IsUint32()) {
- return Nan::ThrowTypeError(
- "cancelWithStatus's first argument must be a status code");
- }
- if (!info[1]->IsString()) {
- return Nan::ThrowTypeError(
- "cancelWithStatus's second argument must be a string");
- }
- Call *call = ObjectWrap::Unwrap<Call>(info.This());
- if (call->wrapped_call == NULL) {
- /* Cancel is supposed to be idempotent. If the call has already finished,
- * cancel should just complete silently */
- return;
- }
- grpc_status_code code =
- static_cast<grpc_status_code>(Nan::To<uint32_t>(info[0]).FromJust());
- if (code == GRPC_STATUS_OK) {
- return Nan::ThrowRangeError(
- "cancelWithStatus cannot be called with OK status");
- }
- Utf8String details(info[1]);
- grpc_call_cancel_with_status(call->wrapped_call, code, *details, NULL);
-}
-
-NAN_METHOD(Call::GetPeer) {
- Nan::HandleScope scope;
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("getPeer can only be called on Call objects");
- }
- Call *call = ObjectWrap::Unwrap<Call>(info.This());
- Local<Value> peer_value = Nan::New(call->peer).ToLocalChecked();
- info.GetReturnValue().Set(peer_value);
-}
-
-NAN_METHOD(Call::SetCredentials) {
- Nan::HandleScope scope;
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError(
- "setCredentials can only be called on Call objects");
- }
- if (!CallCredentials::HasInstance(info[0])) {
- return Nan::ThrowTypeError(
- "setCredentials' first argument must be a CallCredentials");
- }
- Call *call = ObjectWrap::Unwrap<Call>(info.This());
- if (call->wrapped_call == NULL) {
- return Nan::ThrowError(
- "Cannot set credentials on a call that has already started");
- }
- CallCredentials *creds_object = ObjectWrap::Unwrap<CallCredentials>(
- Nan::To<Object>(info[0]).ToLocalChecked());
- grpc_call_credentials *creds = creds_object->GetWrappedCredentials();
- grpc_call_error error = GRPC_CALL_ERROR;
- if (creds) {
- error = grpc_call_set_credentials(call->wrapped_call, creds);
- }
- info.GetReturnValue().Set(Nan::New<Uint32>(error));
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/call.h b/src/node/ext/call.h
deleted file mode 100644
index 50248c0bc6..0000000000
--- a/src/node/ext/call.h
+++ /dev/null
@@ -1,119 +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 NET_GRPC_NODE_CALL_H_
-#define NET_GRPC_NODE_CALL_H_
-
-#include <memory>
-#include <vector>
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/grpc.h"
-#include "grpc/support/log.h"
-
-#include "channel.h"
-
-namespace grpc {
-namespace node {
-
-using std::unique_ptr;
-using std::shared_ptr;
-
-v8::Local<v8::Value> nanErrorWithCode(const char *msg, grpc_call_error code);
-
-v8::Local<v8::Value> ParseMetadata(const grpc_metadata_array *metadata_array);
-
-bool CreateMetadataArray(v8::Local<v8::Object> metadata,
- grpc_metadata_array *array);
-
-void DestroyMetadataArray(grpc_metadata_array *array);
-
-/* Wrapper class for grpc_call structs. */
-class Call : public Nan::ObjectWrap {
- public:
- static void Init(v8::Local<v8::Object> exports);
- static bool HasInstance(v8::Local<v8::Value> val);
- /* Wrap a grpc_call struct in a javascript object */
- static v8::Local<v8::Value> WrapStruct(grpc_call *call);
-
- void CompleteBatch(bool is_final_op);
-
- private:
- explicit Call(grpc_call *call);
- ~Call();
-
- // Prevent copying
- Call(const Call &);
- Call &operator=(const Call &);
-
- void DestroyCall();
-
- static NAN_METHOD(New);
- static NAN_METHOD(StartBatch);
- static NAN_METHOD(Cancel);
- static NAN_METHOD(CancelWithStatus);
- static NAN_METHOD(GetPeer);
- static NAN_METHOD(SetCredentials);
- static Nan::Callback *constructor;
- // Used for typechecking instances of this javascript class
- static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
-
- grpc_call *wrapped_call;
- // The number of ops that were started but not completed on this call
- int pending_batches;
- /* Indicates whether the "final" op on a call has completed. For a client
- call, this is GRPC_OP_RECV_STATUS_ON_CLIENT and for a server call, this
- is GRPC_OP_SEND_STATUS_FROM_SERVER */
- bool has_final_op_completed;
- char *peer;
-};
-
-class Op {
- public:
- virtual v8::Local<v8::Value> GetNodeValue() const = 0;
- virtual bool ParseOp(v8::Local<v8::Value> value, grpc_op *out) = 0;
- virtual ~Op();
- v8::Local<v8::Value> GetOpType() const;
- virtual bool IsFinalOp() = 0;
- virtual void OnComplete(bool success) = 0;
-
- protected:
- virtual std::string GetTypeString() const = 0;
-};
-
-typedef std::vector<unique_ptr<Op>> OpVec;
-struct tag {
- tag(Nan::Callback *callback, OpVec *ops, Call *call,
- v8::Local<v8::Value> call_value);
- ~tag();
- Nan::Callback *callback;
- OpVec *ops;
- Call *call;
- Nan::Persistent<v8::Value, Nan::CopyablePersistentTraits<v8::Value>>
- call_persist;
-};
-
-void DestroyTag(void *tag);
-
-void CompleteTag(void *tag, const char *error_message);
-
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_CALL_H_
diff --git a/src/node/ext/call_credentials.cc b/src/node/ext/call_credentials.cc
deleted file mode 100644
index 4cf3e565ef..0000000000
--- a/src/node/ext/call_credentials.cc
+++ /dev/null
@@ -1,272 +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 <nan.h>
-#include <node.h>
-#include <uv.h>
-
-#include <queue>
-
-#include "call.h"
-#include "call_credentials.h"
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "grpc/support/log.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::EscapableHandleScope;
-using Nan::HandleScope;
-using Nan::Maybe;
-using Nan::MaybeLocal;
-using Nan::ObjectWrap;
-using Nan::Persistent;
-using Nan::Utf8String;
-
-using v8::Exception;
-using v8::External;
-using v8::Function;
-using v8::FunctionTemplate;
-using v8::Integer;
-using v8::Local;
-using v8::Object;
-using v8::ObjectTemplate;
-using v8::Value;
-
-Nan::Callback *CallCredentials::constructor;
-Persistent<FunctionTemplate> CallCredentials::fun_tpl;
-
-static Callback *plugin_callback;
-
-CallCredentials::CallCredentials(grpc_call_credentials *credentials)
- : wrapped_credentials(credentials) {}
-
-CallCredentials::~CallCredentials() {
- grpc_call_credentials_release(wrapped_credentials);
-}
-
-void CallCredentials::Init(Local<Object> exports) {
- HandleScope scope;
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
- tpl->SetClassName(Nan::New("CallCredentials").ToLocalChecked());
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- Nan::SetPrototypeMethod(tpl, "compose", Compose);
- fun_tpl.Reset(tpl);
- Local<Function> ctr = Nan::GetFunction(tpl).ToLocalChecked();
- Nan::Set(ctr, Nan::New("createFromPlugin").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(CreateFromPlugin))
- .ToLocalChecked());
- Nan::Set(exports, Nan::New("CallCredentials").ToLocalChecked(), ctr);
- constructor = new Nan::Callback(ctr);
-
- Local<FunctionTemplate> callback_tpl =
- Nan::New<FunctionTemplate>(PluginCallback);
- plugin_callback =
- new Callback(Nan::GetFunction(callback_tpl).ToLocalChecked());
-}
-
-bool CallCredentials::HasInstance(Local<Value> val) {
- HandleScope scope;
- return Nan::New(fun_tpl)->HasInstance(val);
-}
-
-Local<Value> CallCredentials::WrapStruct(grpc_call_credentials *credentials) {
- EscapableHandleScope scope;
- const int argc = 1;
- if (credentials == NULL) {
- return scope.Escape(Nan::Null());
- }
- Local<Value> argv[argc] = {
- Nan::New<External>(reinterpret_cast<void *>(credentials))};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- return scope.Escape(Nan::Null());
- } else {
- return scope.Escape(maybe_instance.ToLocalChecked());
- }
-}
-
-grpc_call_credentials *CallCredentials::GetWrappedCredentials() {
- return wrapped_credentials;
-}
-
-NAN_METHOD(CallCredentials::New) {
- if (info.IsConstructCall()) {
- if (!info[0]->IsExternal()) {
- return Nan::ThrowTypeError(
- "CallCredentials can only be created with the provided functions");
- }
- Local<External> ext = info[0].As<External>();
- grpc_call_credentials *creds_value =
- reinterpret_cast<grpc_call_credentials *>(ext->Value());
- CallCredentials *credentials = new CallCredentials(creds_value);
- credentials->Wrap(info.This());
- info.GetReturnValue().Set(info.This());
- return;
- } else {
- // This should never be called directly
- return Nan::ThrowTypeError(
- "CallCredentials can only be created with the provided functions");
- }
-}
-
-NAN_METHOD(CallCredentials::Compose) {
- if (!CallCredentials::HasInstance(info.This())) {
- return Nan::ThrowTypeError(
- "compose can only be called on CallCredentials objects");
- }
- if (!CallCredentials::HasInstance(info[0])) {
- return Nan::ThrowTypeError(
- "compose's first argument must be a CallCredentials object");
- }
- CallCredentials *self = ObjectWrap::Unwrap<CallCredentials>(info.This());
- CallCredentials *other = ObjectWrap::Unwrap<CallCredentials>(
- Nan::To<Object>(info[0]).ToLocalChecked());
- grpc_call_credentials *creds = grpc_composite_call_credentials_create(
- self->wrapped_credentials, other->wrapped_credentials, NULL);
- info.GetReturnValue().Set(WrapStruct(creds));
-}
-
-NAN_METHOD(CallCredentials::CreateFromPlugin) {
- if (!info[0]->IsFunction()) {
- return Nan::ThrowTypeError(
- "createFromPlugin's argument must be a function");
- }
- grpc_metadata_credentials_plugin plugin;
- plugin_state *state = new plugin_state;
- state->callback = new Nan::Callback(info[0].As<Function>());
- state->pending_callbacks = new std::queue<plugin_callback_data *>();
- uv_mutex_init(&state->plugin_mutex);
- uv_async_init(uv_default_loop(), &state->plugin_async, SendPluginCallback);
- uv_unref((uv_handle_t *)&state->plugin_async);
-
- state->plugin_async.data = state;
-
- plugin.get_metadata = plugin_get_metadata;
- plugin.destroy = plugin_destroy_state;
- plugin.state = reinterpret_cast<void *>(state);
- plugin.type = "";
- grpc_call_credentials *creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
- info.GetReturnValue().Set(WrapStruct(creds));
-}
-
-NAN_METHOD(PluginCallback) {
- // Arguments: status code, error details, metadata
- if (!info[0]->IsUint32()) {
- return Nan::ThrowTypeError(
- "The callback's first argument must be a status code");
- }
- if (!info[1]->IsString()) {
- return Nan::ThrowTypeError(
- "The callback's second argument must be a string");
- }
- if (!info[2]->IsObject()) {
- return Nan::ThrowTypeError(
- "The callback's third argument must be an object");
- }
- if (!info[3]->IsObject()) {
- return Nan::ThrowTypeError(
- "The callback's fourth argument must be an object");
- }
- grpc_status_code code =
- static_cast<grpc_status_code>(Nan::To<uint32_t>(info[0]).FromJust());
- Utf8String details_utf8_str(info[1]);
- char *details = *details_utf8_str;
- grpc_metadata_array array;
- grpc_metadata_array_init(&array);
- Local<Object> callback_data = Nan::To<Object>(info[3]).ToLocalChecked();
- if (!CreateMetadataArray(Nan::To<Object>(info[2]).ToLocalChecked(), &array)) {
- return Nan::ThrowError("Failed to parse metadata");
- }
- grpc_credentials_plugin_metadata_cb cb =
- reinterpret_cast<grpc_credentials_plugin_metadata_cb>(
- Nan::Get(callback_data, Nan::New("cb").ToLocalChecked())
- .ToLocalChecked()
- .As<External>()
- ->Value());
- void *user_data =
- Nan::Get(callback_data, Nan::New("user_data").ToLocalChecked())
- .ToLocalChecked()
- .As<External>()
- ->Value();
- cb(user_data, array.metadata, array.count, code, details);
- DestroyMetadataArray(&array);
-}
-
-NAUV_WORK_CB(SendPluginCallback) {
- Nan::HandleScope scope;
- plugin_state *state = reinterpret_cast<plugin_state *>(async->data);
- std::queue<plugin_callback_data *> callbacks;
- uv_mutex_lock(&state->plugin_mutex);
- state->pending_callbacks->swap(callbacks);
- uv_mutex_unlock(&state->plugin_mutex);
- while (!callbacks.empty()) {
- plugin_callback_data *data = callbacks.front();
- callbacks.pop();
- Local<Object> callback_data = Nan::New<Object>();
- Nan::Set(callback_data, Nan::New("cb").ToLocalChecked(),
- Nan::New<v8::External>(reinterpret_cast<void *>(data->cb)));
- Nan::Set(callback_data, Nan::New("user_data").ToLocalChecked(),
- Nan::New<v8::External>(data->user_data));
- const int argc = 3;
- v8::Local<v8::Value> argv[argc] = {
- Nan::New(data->service_url).ToLocalChecked(), callback_data,
- // Get Local<Function> from Nan::Callback*
- **plugin_callback};
- Nan::Callback *callback = state->callback;
- callback->Call(argc, argv);
- delete data;
- }
-}
-
-void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data) {
- plugin_state *p_state = reinterpret_cast<plugin_state *>(state);
- plugin_callback_data *data = new plugin_callback_data;
- data->service_url = context.service_url;
- data->cb = cb;
- data->user_data = user_data;
-
- uv_mutex_lock(&p_state->plugin_mutex);
- p_state->pending_callbacks->push(data);
- uv_mutex_unlock(&p_state->plugin_mutex);
-
- uv_async_send(&p_state->plugin_async);
-}
-
-void plugin_uv_close_cb(uv_handle_t *handle) {
- uv_async_t *async = reinterpret_cast<uv_async_t *>(handle);
- plugin_state *state = reinterpret_cast<plugin_state *>(async->data);
- uv_mutex_destroy(&state->plugin_mutex);
- delete state->pending_callbacks;
- delete state->callback;
- delete state;
-}
-
-void plugin_destroy_state(void *ptr) {
- plugin_state *state = reinterpret_cast<plugin_state *>(ptr);
- uv_close((uv_handle_t *)&state->plugin_async, plugin_uv_close_cb);
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/call_credentials.h b/src/node/ext/call_credentials.h
deleted file mode 100644
index adcff84573..0000000000
--- a/src/node/ext/call_credentials.h
+++ /dev/null
@@ -1,91 +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_NODE_CALL_CREDENTIALS_H_
-#define GRPC_NODE_CALL_CREDENTIALS_H_
-
-#include <queue>
-
-#include <nan.h>
-#include <node.h>
-#include <uv.h>
-#include "grpc/grpc_security.h"
-
-namespace grpc {
-namespace node {
-
-class CallCredentials : public Nan::ObjectWrap {
- public:
- static void Init(v8::Local<v8::Object> exports);
- static bool HasInstance(v8::Local<v8::Value> val);
- /* Wrap a grpc_call_credentials struct in a javascript object */
- static v8::Local<v8::Value> WrapStruct(grpc_call_credentials *credentials);
-
- /* Returns the grpc_call_credentials struct that this object wraps */
- grpc_call_credentials *GetWrappedCredentials();
-
- private:
- explicit CallCredentials(grpc_call_credentials *credentials);
- ~CallCredentials();
-
- // Prevent copying
- CallCredentials(const CallCredentials &);
- CallCredentials &operator=(const CallCredentials &);
-
- static NAN_METHOD(New);
- static NAN_METHOD(CreateSsl);
- static NAN_METHOD(CreateFromPlugin);
-
- static NAN_METHOD(Compose);
- static Nan::Callback *constructor;
- // Used for typechecking instances of this javascript class
- static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
-
- grpc_call_credentials *wrapped_credentials;
-};
-
-/* Auth metadata plugin functionality */
-
-typedef struct plugin_callback_data {
- const char *service_url;
- grpc_credentials_plugin_metadata_cb cb;
- void *user_data;
-} plugin_callback_data;
-
-typedef struct plugin_state {
- Nan::Callback *callback;
- std::queue<plugin_callback_data *> *pending_callbacks;
- uv_mutex_t plugin_mutex;
- // async.data == this
- uv_async_t plugin_async;
-} plugin_state;
-
-void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data);
-
-void plugin_destroy_state(void *state);
-
-NAN_METHOD(PluginCallback);
-
-NAUV_WORK_CB(SendPluginCallback);
-
-} // namespace node
-} // namepsace grpc
-
-#endif // GRPC_NODE_CALL_CREDENTIALS_H_
diff --git a/src/node/ext/channel.cc b/src/node/ext/channel.cc
deleted file mode 100644
index fc085fa011..0000000000
--- a/src/node/ext/channel.cc
+++ /dev/null
@@ -1,272 +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 <vector>
-
-#include "grpc/support/log.h"
-
-#include <nan.h>
-#include <node.h>
-#include "call.h"
-#include "channel.h"
-#include "channel_credentials.h"
-#include "completion_queue.h"
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "timeval.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::EscapableHandleScope;
-using Nan::HandleScope;
-using Nan::Maybe;
-using Nan::MaybeLocal;
-using Nan::ObjectWrap;
-using Nan::Persistent;
-using Nan::Utf8String;
-
-using v8::Array;
-using v8::Exception;
-using v8::Function;
-using v8::FunctionTemplate;
-using v8::Integer;
-using v8::Local;
-using v8::Number;
-using v8::Object;
-using v8::String;
-using v8::Value;
-
-Callback *Channel::constructor;
-Persistent<FunctionTemplate> Channel::fun_tpl;
-
-bool ParseChannelArgs(Local<Value> args_val,
- grpc_channel_args **channel_args_ptr) {
- if (args_val->IsUndefined() || args_val->IsNull()) {
- *channel_args_ptr = NULL;
- return true;
- }
- if (!args_val->IsObject()) {
- *channel_args_ptr = NULL;
- return false;
- }
- grpc_channel_args *channel_args =
- reinterpret_cast<grpc_channel_args *>(malloc(sizeof(grpc_channel_args)));
- *channel_args_ptr = channel_args;
- Local<Object> args_hash = Nan::To<Object>(args_val).ToLocalChecked();
- Local<Array> keys = Nan::GetOwnPropertyNames(args_hash).ToLocalChecked();
- channel_args->num_args = keys->Length();
- channel_args->args = reinterpret_cast<grpc_arg *>(
- calloc(channel_args->num_args, sizeof(grpc_arg)));
- for (unsigned int i = 0; i < channel_args->num_args; i++) {
- Local<Value> key = Nan::Get(keys, i).ToLocalChecked();
- Utf8String key_str(key);
- if (*key_str == NULL) {
- // Key string onversion failed
- return false;
- }
- Local<Value> value = Nan::Get(args_hash, key).ToLocalChecked();
- if (value->IsInt32()) {
- channel_args->args[i].type = GRPC_ARG_INTEGER;
- channel_args->args[i].value.integer = Nan::To<int32_t>(value).FromJust();
- } else if (value->IsString()) {
- Utf8String val_str(value);
- channel_args->args[i].type = GRPC_ARG_STRING;
- channel_args->args[i].value.string =
- reinterpret_cast<char *>(calloc(val_str.length() + 1, sizeof(char)));
- memcpy(channel_args->args[i].value.string, *val_str,
- val_str.length() + 1);
- } else {
- // The value does not match either of the accepted types
- return false;
- }
- channel_args->args[i].key =
- reinterpret_cast<char *>(calloc(key_str.length() + 1, sizeof(char)));
- memcpy(channel_args->args[i].key, *key_str, key_str.length() + 1);
- }
- return true;
-}
-
-void DeallocateChannelArgs(grpc_channel_args *channel_args) {
- if (channel_args == NULL) {
- return;
- }
- for (size_t i = 0; i < channel_args->num_args; i++) {
- if (channel_args->args[i].key == NULL) {
- /* NULL key implies that this argument and all subsequent arguments failed
- * to parse */
- break;
- }
- free(channel_args->args[i].key);
- if (channel_args->args[i].type == GRPC_ARG_STRING) {
- free(channel_args->args[i].value.string);
- }
- }
- free(channel_args->args);
- free(channel_args);
-}
-
-Channel::Channel(grpc_channel *channel) : wrapped_channel(channel) {}
-
-Channel::~Channel() {
- gpr_log(GPR_DEBUG, "Destroying channel");
- if (wrapped_channel != NULL) {
- grpc_channel_destroy(wrapped_channel);
- }
-}
-
-void Channel::Init(Local<Object> exports) {
- Nan::HandleScope scope;
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
- tpl->SetClassName(Nan::New("Channel").ToLocalChecked());
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- Nan::SetPrototypeMethod(tpl, "close", Close);
- Nan::SetPrototypeMethod(tpl, "getTarget", GetTarget);
- Nan::SetPrototypeMethod(tpl, "getConnectivityState", GetConnectivityState);
- Nan::SetPrototypeMethod(tpl, "watchConnectivityState",
- WatchConnectivityState);
- fun_tpl.Reset(tpl);
- Local<Function> ctr = Nan::GetFunction(tpl).ToLocalChecked();
- Nan::Set(exports, Nan::New("Channel").ToLocalChecked(), ctr);
- constructor = new Callback(ctr);
-}
-
-bool Channel::HasInstance(Local<Value> val) {
- HandleScope scope;
- return Nan::New(fun_tpl)->HasInstance(val);
-}
-
-grpc_channel *Channel::GetWrappedChannel() { return this->wrapped_channel; }
-
-NAN_METHOD(Channel::New) {
- if (info.IsConstructCall()) {
- if (!info[0]->IsString()) {
- return Nan::ThrowTypeError(
- "Channel expects a string, a credential and an object");
- }
- grpc_channel *wrapped_channel;
- // Owned by the Channel object
- Utf8String host(info[0]);
- grpc_channel_credentials *creds;
- if (!ChannelCredentials::HasInstance(info[1])) {
- return Nan::ThrowTypeError(
- "Channel's second argument must be a ChannelCredentials");
- }
- ChannelCredentials *creds_object = ObjectWrap::Unwrap<ChannelCredentials>(
- Nan::To<Object>(info[1]).ToLocalChecked());
- creds = creds_object->GetWrappedCredentials();
- grpc_channel_args *channel_args_ptr = NULL;
- if (!ParseChannelArgs(info[2], &channel_args_ptr)) {
- DeallocateChannelArgs(channel_args_ptr);
- return Nan::ThrowTypeError(
- "Channel options must be an object with "
- "string keys and integer or string values");
- }
- if (creds == NULL) {
- wrapped_channel =
- grpc_insecure_channel_create(*host, channel_args_ptr, NULL);
- } else {
- wrapped_channel =
- grpc_secure_channel_create(creds, *host, channel_args_ptr, NULL);
- }
- DeallocateChannelArgs(channel_args_ptr);
- Channel *channel = new Channel(wrapped_channel);
- channel->Wrap(info.This());
- info.GetReturnValue().Set(info.This());
- return;
- } else {
- const int argc = 3;
- Local<Value> argv[argc] = {info[0], info[1], info[2]};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- // There's probably a pending exception
- return;
- } else {
- info.GetReturnValue().Set(maybe_instance.ToLocalChecked());
- }
- }
-}
-
-NAN_METHOD(Channel::Close) {
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("close can only be called on Channel objects");
- }
- Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
- if (channel->wrapped_channel != NULL) {
- grpc_channel_destroy(channel->wrapped_channel);
- channel->wrapped_channel = NULL;
- }
-}
-
-NAN_METHOD(Channel::GetTarget) {
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError(
- "getTarget can only be called on Channel objects");
- }
- Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
- info.GetReturnValue().Set(
- Nan::New(grpc_channel_get_target(channel->wrapped_channel))
- .ToLocalChecked());
-}
-
-NAN_METHOD(Channel::GetConnectivityState) {
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError(
- "getConnectivityState can only be called on Channel objects");
- }
- Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
- int try_to_connect = (int)info[0]->Equals(Nan::True());
- info.GetReturnValue().Set(grpc_channel_check_connectivity_state(
- channel->wrapped_channel, try_to_connect));
-}
-
-NAN_METHOD(Channel::WatchConnectivityState) {
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError(
- "watchConnectivityState can only be called on Channel objects");
- }
- if (!info[0]->IsUint32()) {
- return Nan::ThrowTypeError(
- "watchConnectivityState's first argument must be a channel state");
- }
- if (!(info[1]->IsNumber() || info[1]->IsDate())) {
- return Nan::ThrowTypeError(
- "watchConnectivityState's second argument must be a date or a number");
- }
- if (!info[2]->IsFunction()) {
- return Nan::ThrowTypeError(
- "watchConnectivityState's third argument must be a callback");
- }
- grpc_connectivity_state last_state = static_cast<grpc_connectivity_state>(
- Nan::To<uint32_t>(info[0]).FromJust());
- double deadline = Nan::To<double>(info[1]).FromJust();
- Local<Function> callback_func = info[2].As<Function>();
- Nan::Callback *callback = new Callback(callback_func);
- Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
- unique_ptr<OpVec> ops(new OpVec());
- grpc_channel_watch_connectivity_state(
- channel->wrapped_channel, last_state, MillisecondsToTimespec(deadline),
- GetCompletionQueue(),
- new struct tag(callback, ops.release(), NULL, Nan::Null()));
- CompletionQueueNext();
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/channel.h b/src/node/ext/channel.h
deleted file mode 100644
index a93dbe9d25..0000000000
--- a/src/node/ext/channel.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 NET_GRPC_NODE_CHANNEL_H_
-#define NET_GRPC_NODE_CHANNEL_H_
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/grpc.h"
-
-namespace grpc {
-namespace node {
-
-bool ParseChannelArgs(v8::Local<v8::Value> args_val,
- grpc_channel_args **channel_args_ptr);
-
-void DeallocateChannelArgs(grpc_channel_args *channel_args);
-
-/* Wrapper class for grpc_channel structs */
-class Channel : public Nan::ObjectWrap {
- public:
- static void Init(v8::Local<v8::Object> exports);
- static bool HasInstance(v8::Local<v8::Value> val);
- /* This is used to typecheck javascript objects before converting them to
- this type */
- static v8::Persistent<v8::Value> prototype;
-
- /* Returns the grpc_channel struct that this object wraps */
- grpc_channel *GetWrappedChannel();
-
- private:
- explicit Channel(grpc_channel *channel);
- ~Channel();
-
- // Prevent copying
- Channel(const Channel &);
- Channel &operator=(const Channel &);
-
- static NAN_METHOD(New);
- static NAN_METHOD(Close);
- static NAN_METHOD(GetTarget);
- static NAN_METHOD(GetConnectivityState);
- static NAN_METHOD(WatchConnectivityState);
- static Nan::Callback *constructor;
- static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
-
- grpc_channel *wrapped_channel;
-};
-
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_CHANNEL_H_
diff --git a/src/node/ext/channel_credentials.cc b/src/node/ext/channel_credentials.cc
deleted file mode 100644
index 9e87fb61bb..0000000000
--- a/src/node/ext/channel_credentials.cc
+++ /dev/null
@@ -1,188 +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 <node.h>
-
-#include "call.h"
-#include "call_credentials.h"
-#include "channel_credentials.h"
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "grpc/support/log.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::EscapableHandleScope;
-using Nan::HandleScope;
-using Nan::Maybe;
-using Nan::MaybeLocal;
-using Nan::ObjectWrap;
-using Nan::Persistent;
-using Nan::Utf8String;
-
-using v8::Exception;
-using v8::External;
-using v8::Function;
-using v8::FunctionTemplate;
-using v8::Integer;
-using v8::Local;
-using v8::Object;
-using v8::ObjectTemplate;
-using v8::Value;
-
-Nan::Callback *ChannelCredentials::constructor;
-Persistent<FunctionTemplate> ChannelCredentials::fun_tpl;
-
-ChannelCredentials::ChannelCredentials(grpc_channel_credentials *credentials)
- : wrapped_credentials(credentials) {}
-
-ChannelCredentials::~ChannelCredentials() {
- grpc_channel_credentials_release(wrapped_credentials);
-}
-
-void ChannelCredentials::Init(Local<Object> exports) {
- HandleScope scope;
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
- tpl->SetClassName(Nan::New("ChannelCredentials").ToLocalChecked());
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- Nan::SetPrototypeMethod(tpl, "compose", Compose);
- fun_tpl.Reset(tpl);
- Local<Function> ctr = Nan::GetFunction(tpl).ToLocalChecked();
- Nan::Set(
- ctr, Nan::New("createSsl").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(CreateSsl)).ToLocalChecked());
- Nan::Set(ctr, Nan::New("createInsecure").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(CreateInsecure))
- .ToLocalChecked());
- Nan::Set(exports, Nan::New("ChannelCredentials").ToLocalChecked(), ctr);
- constructor = new Nan::Callback(ctr);
-}
-
-bool ChannelCredentials::HasInstance(Local<Value> val) {
- HandleScope scope;
- return Nan::New(fun_tpl)->HasInstance(val);
-}
-
-Local<Value> ChannelCredentials::WrapStruct(
- grpc_channel_credentials *credentials) {
- EscapableHandleScope scope;
- const int argc = 1;
- Local<Value> argv[argc] = {
- Nan::New<External>(reinterpret_cast<void *>(credentials))};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- return scope.Escape(Nan::Null());
- } else {
- return scope.Escape(maybe_instance.ToLocalChecked());
- }
-}
-
-grpc_channel_credentials *ChannelCredentials::GetWrappedCredentials() {
- return wrapped_credentials;
-}
-
-NAN_METHOD(ChannelCredentials::New) {
- if (info.IsConstructCall()) {
- if (!info[0]->IsExternal()) {
- return Nan::ThrowTypeError(
- "ChannelCredentials can only be created with the provided functions");
- }
- Local<External> ext = info[0].As<External>();
- grpc_channel_credentials *creds_value =
- reinterpret_cast<grpc_channel_credentials *>(ext->Value());
- ChannelCredentials *credentials = new ChannelCredentials(creds_value);
- credentials->Wrap(info.This());
- info.GetReturnValue().Set(info.This());
- return;
- } else {
- // This should never be called directly
- return Nan::ThrowTypeError(
- "ChannelCredentials can only be created with the provided functions");
- }
-}
-
-NAN_METHOD(ChannelCredentials::CreateSsl) {
- char *root_certs = NULL;
- grpc_ssl_pem_key_cert_pair key_cert_pair = {NULL, NULL};
- if (::node::Buffer::HasInstance(info[0])) {
- root_certs = ::node::Buffer::Data(info[0]);
- } else if (!(info[0]->IsNull() || info[0]->IsUndefined())) {
- return Nan::ThrowTypeError("createSsl's first argument must be a Buffer");
- }
- if (::node::Buffer::HasInstance(info[1])) {
- key_cert_pair.private_key = ::node::Buffer::Data(info[1]);
- } else if (!(info[1]->IsNull() || info[1]->IsUndefined())) {
- return Nan::ThrowTypeError(
- "createSSl's second argument must be a Buffer if provided");
- }
- if (::node::Buffer::HasInstance(info[2])) {
- key_cert_pair.cert_chain = ::node::Buffer::Data(info[2]);
- } else if (!(info[2]->IsNull() || info[2]->IsUndefined())) {
- return Nan::ThrowTypeError(
- "createSSl's third argument must be a Buffer if provided");
- }
- if ((key_cert_pair.private_key == NULL) !=
- (key_cert_pair.cert_chain == NULL)) {
- return Nan::ThrowError(
- "createSsl's second and third arguments must be"
- " provided or omitted together");
- }
- grpc_channel_credentials *creds = grpc_ssl_credentials_create(
- root_certs, key_cert_pair.private_key == NULL ? NULL : &key_cert_pair,
- NULL);
- if (creds == NULL) {
- info.GetReturnValue().SetNull();
- } else {
- info.GetReturnValue().Set(WrapStruct(creds));
- }
-}
-
-NAN_METHOD(ChannelCredentials::Compose) {
- if (!ChannelCredentials::HasInstance(info.This())) {
- return Nan::ThrowTypeError(
- "compose can only be called on ChannelCredentials objects");
- }
- if (!CallCredentials::HasInstance(info[0])) {
- return Nan::ThrowTypeError(
- "compose's first argument must be a CallCredentials object");
- }
- ChannelCredentials *self =
- ObjectWrap::Unwrap<ChannelCredentials>(info.This());
- if (self->wrapped_credentials == NULL) {
- return Nan::ThrowTypeError("Cannot compose insecure credential");
- }
- CallCredentials *other = ObjectWrap::Unwrap<CallCredentials>(
- Nan::To<Object>(info[0]).ToLocalChecked());
- grpc_channel_credentials *creds = grpc_composite_channel_credentials_create(
- self->wrapped_credentials, other->GetWrappedCredentials(), NULL);
- if (creds == NULL) {
- info.GetReturnValue().SetNull();
- } else {
- info.GetReturnValue().Set(WrapStruct(creds));
- }
-}
-
-NAN_METHOD(ChannelCredentials::CreateInsecure) {
- info.GetReturnValue().Set(WrapStruct(NULL));
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/channel_credentials.h b/src/node/ext/channel_credentials.h
deleted file mode 100644
index 18c14837cc..0000000000
--- a/src/node/ext/channel_credentials.h
+++ /dev/null
@@ -1,64 +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 NET_GRPC_NODE_CHANNEL_CREDENTIALS_H_
-#define NET_GRPC_NODE_CHANNEL_CREDENTIALS_H_
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-
-namespace grpc {
-namespace node {
-
-/* Wrapper class for grpc_channel_credentials structs */
-class ChannelCredentials : public Nan::ObjectWrap {
- public:
- static void Init(v8::Local<v8::Object> exports);
- static bool HasInstance(v8::Local<v8::Value> val);
- /* Wrap a grpc_channel_credentials struct in a javascript object */
- static v8::Local<v8::Value> WrapStruct(grpc_channel_credentials *credentials);
-
- /* Returns the grpc_channel_credentials struct that this object wraps */
- grpc_channel_credentials *GetWrappedCredentials();
-
- private:
- explicit ChannelCredentials(grpc_channel_credentials *credentials);
- ~ChannelCredentials();
-
- // Prevent copying
- ChannelCredentials(const ChannelCredentials &);
- ChannelCredentials &operator=(const ChannelCredentials &);
-
- static NAN_METHOD(New);
- static NAN_METHOD(CreateSsl);
- static NAN_METHOD(CreateInsecure);
-
- static NAN_METHOD(Compose);
- static Nan::Callback *constructor;
- // Used for typechecking instances of this javascript class
- static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
-
- grpc_channel_credentials *wrapped_credentials;
-};
-
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_CHANNEL_CREDENTIALS_H_
diff --git a/src/node/ext/completion_queue.cc b/src/node/ext/completion_queue.cc
deleted file mode 100644
index a08febbb2c..0000000000
--- a/src/node/ext/completion_queue.cc
+++ /dev/null
@@ -1,80 +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 <grpc/grpc.h>
-#include <node.h>
-#include <uv.h>
-#include <v8.h>
-
-#include "call.h"
-#include "completion_queue.h"
-
-namespace grpc {
-namespace node {
-
-using v8::Local;
-using v8::Object;
-using v8::Value;
-
-grpc_completion_queue *queue;
-uv_prepare_t prepare;
-int pending_batches;
-
-void drain_completion_queue(uv_prepare_t *handle) {
- Nan::HandleScope scope;
- grpc_event event;
- (void)handle;
- do {
- event = grpc_completion_queue_next(queue, gpr_inf_past(GPR_CLOCK_MONOTONIC),
- NULL);
-
- if (event.type == GRPC_OP_COMPLETE) {
- const char *error_message;
- if (event.success) {
- error_message = NULL;
- } else {
- error_message = "The async function encountered an error";
- }
- CompleteTag(event.tag, error_message);
- grpc::node::DestroyTag(event.tag);
- pending_batches--;
- if (pending_batches == 0) {
- uv_prepare_stop(&prepare);
- }
- }
- } while (event.type != GRPC_QUEUE_TIMEOUT);
-}
-
-grpc_completion_queue *GetCompletionQueue() { return queue; }
-
-void CompletionQueueNext() {
- if (pending_batches == 0) {
- GPR_ASSERT(!uv_is_active((uv_handle_t *)&prepare));
- uv_prepare_start(&prepare, drain_completion_queue);
- }
- pending_batches++;
-}
-
-void CompletionQueueInit(Local<Object> exports) {
- queue = grpc_completion_queue_create_for_next(NULL);
- uv_prepare_init(uv_default_loop(), &prepare);
- pending_batches = 0;
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/completion_queue.h b/src/node/ext/completion_queue.h
deleted file mode 100644
index f91d5ea8b6..0000000000
--- a/src/node/ext/completion_queue.h
+++ /dev/null
@@ -1,32 +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 <grpc/grpc.h>
-#include <v8.h>
-
-namespace grpc {
-namespace node {
-
-grpc_completion_queue *GetCompletionQueue();
-
-void CompletionQueueNext();
-
-void CompletionQueueInit(v8::Local<v8::Object> exports);
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/node_grpc.cc b/src/node/ext/node_grpc.cc
deleted file mode 100644
index 11ed0838bc..0000000000
--- a/src/node/ext/node_grpc.cc
+++ /dev/null
@@ -1,311 +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 <queue>
-
-#include <nan.h>
-#include <node.h>
-#include <v8.h>
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "grpc/support/alloc.h"
-#include "grpc/support/log.h"
-#include "grpc/support/time.h"
-
-// TODO(murgatroid99): Remove this when the endpoint API becomes public
-extern "C" {
-#include "src/core/lib/iomgr/pollset_uv.h"
-}
-
-#include "call.h"
-#include "call_credentials.h"
-#include "channel.h"
-#include "channel_credentials.h"
-#include "completion_queue.h"
-#include "server.h"
-#include "server_credentials.h"
-#include "slice.h"
-#include "timeval.h"
-
-using grpc::node::CreateSliceFromString;
-
-using v8::FunctionTemplate;
-using v8::Local;
-using v8::Value;
-using v8::Number;
-using v8::Object;
-using v8::Uint32;
-using v8::String;
-
-typedef struct log_args {
- gpr_log_func_args core_args;
- gpr_timespec timestamp;
-} log_args;
-
-typedef struct logger_state {
- Nan::Callback *callback;
- std::queue<log_args *> *pending_args;
- uv_mutex_t mutex;
- uv_async_t async;
- // Indicates that a logger has been set
- bool logger_set;
-} logger_state;
-
-logger_state grpc_logger_state;
-
-static char *pem_root_certs = NULL;
-
-void InitOpTypeConstants(Local<Object> exports) {
- Nan::HandleScope scope;
- Local<Object> op_type = Nan::New<Object>();
- Nan::Set(exports, Nan::New("opType").ToLocalChecked(), op_type);
- Local<Value> SEND_INITIAL_METADATA(
- Nan::New<Uint32, uint32_t>(GRPC_OP_SEND_INITIAL_METADATA));
- Nan::Set(op_type, Nan::New("SEND_INITIAL_METADATA").ToLocalChecked(),
- SEND_INITIAL_METADATA);
- Local<Value> SEND_MESSAGE(Nan::New<Uint32, uint32_t>(GRPC_OP_SEND_MESSAGE));
- Nan::Set(op_type, Nan::New("SEND_MESSAGE").ToLocalChecked(), SEND_MESSAGE);
- Local<Value> SEND_CLOSE_FROM_CLIENT(
- Nan::New<Uint32, uint32_t>(GRPC_OP_SEND_CLOSE_FROM_CLIENT));
- Nan::Set(op_type, Nan::New("SEND_CLOSE_FROM_CLIENT").ToLocalChecked(),
- SEND_CLOSE_FROM_CLIENT);
- Local<Value> SEND_STATUS_FROM_SERVER(
- Nan::New<Uint32, uint32_t>(GRPC_OP_SEND_STATUS_FROM_SERVER));
- Nan::Set(op_type, Nan::New("SEND_STATUS_FROM_SERVER").ToLocalChecked(),
- SEND_STATUS_FROM_SERVER);
- Local<Value> RECV_INITIAL_METADATA(
- Nan::New<Uint32, uint32_t>(GRPC_OP_RECV_INITIAL_METADATA));
- Nan::Set(op_type, Nan::New("RECV_INITIAL_METADATA").ToLocalChecked(),
- RECV_INITIAL_METADATA);
- Local<Value> RECV_MESSAGE(Nan::New<Uint32, uint32_t>(GRPC_OP_RECV_MESSAGE));
- Nan::Set(op_type, Nan::New("RECV_MESSAGE").ToLocalChecked(), RECV_MESSAGE);
- Local<Value> RECV_STATUS_ON_CLIENT(
- Nan::New<Uint32, uint32_t>(GRPC_OP_RECV_STATUS_ON_CLIENT));
- Nan::Set(op_type, Nan::New("RECV_STATUS_ON_CLIENT").ToLocalChecked(),
- RECV_STATUS_ON_CLIENT);
- Local<Value> RECV_CLOSE_ON_SERVER(
- Nan::New<Uint32, uint32_t>(GRPC_OP_RECV_CLOSE_ON_SERVER));
- Nan::Set(op_type, Nan::New("RECV_CLOSE_ON_SERVER").ToLocalChecked(),
- RECV_CLOSE_ON_SERVER);
-}
-
-void InitConnectivityStateConstants(Local<Object> exports) {
- Nan::HandleScope scope;
- Local<Object> channel_state = Nan::New<Object>();
- Nan::Set(exports, Nan::New("connectivityState").ToLocalChecked(),
- channel_state);
- Local<Value> IDLE(Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_IDLE));
- Nan::Set(channel_state, Nan::New("IDLE").ToLocalChecked(), IDLE);
- Local<Value> CONNECTING(Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_CONNECTING));
- Nan::Set(channel_state, Nan::New("CONNECTING").ToLocalChecked(), CONNECTING);
- Local<Value> READY(Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_READY));
- Nan::Set(channel_state, Nan::New("READY").ToLocalChecked(), READY);
- Local<Value> TRANSIENT_FAILURE(
- Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_TRANSIENT_FAILURE));
- Nan::Set(channel_state, Nan::New("TRANSIENT_FAILURE").ToLocalChecked(),
- TRANSIENT_FAILURE);
- Local<Value> FATAL_FAILURE(Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_SHUTDOWN));
- Nan::Set(channel_state, Nan::New("FATAL_FAILURE").ToLocalChecked(),
- FATAL_FAILURE);
-}
-
-NAN_METHOD(MetadataKeyIsLegal) {
- if (!info[0]->IsString()) {
- return Nan::ThrowTypeError("headerKeyIsLegal's argument must be a string");
- }
- Local<String> key = Nan::To<String>(info[0]).ToLocalChecked();
- grpc_slice slice = CreateSliceFromString(key);
- info.GetReturnValue().Set(static_cast<bool>(grpc_header_key_is_legal(slice)));
- grpc_slice_unref(slice);
-}
-
-NAN_METHOD(MetadataNonbinValueIsLegal) {
- if (!info[0]->IsString()) {
- return Nan::ThrowTypeError(
- "metadataNonbinValueIsLegal's argument must be a string");
- }
- Local<String> value = Nan::To<String>(info[0]).ToLocalChecked();
- grpc_slice slice = CreateSliceFromString(value);
- info.GetReturnValue().Set(
- static_cast<bool>(grpc_header_nonbin_value_is_legal(slice)));
- grpc_slice_unref(slice);
-}
-
-NAN_METHOD(MetadataKeyIsBinary) {
- if (!info[0]->IsString()) {
- return Nan::ThrowTypeError(
- "metadataKeyIsLegal's argument must be a string");
- }
- Local<String> key = Nan::To<String>(info[0]).ToLocalChecked();
- grpc_slice slice = CreateSliceFromString(key);
- info.GetReturnValue().Set(static_cast<bool>(grpc_is_binary_header(slice)));
- grpc_slice_unref(slice);
-}
-
-static grpc_ssl_roots_override_result get_ssl_roots_override(
- char **pem_root_certs_ptr) {
- *pem_root_certs_ptr = pem_root_certs;
- if (pem_root_certs == NULL) {
- return GRPC_SSL_ROOTS_OVERRIDE_FAIL;
- } else {
- return GRPC_SSL_ROOTS_OVERRIDE_OK;
- }
-}
-
-/* This should only be called once, and only before creating any
- *ServerCredentials */
-NAN_METHOD(SetDefaultRootsPem) {
- if (!info[0]->IsString()) {
- return Nan::ThrowTypeError(
- "setDefaultRootsPem's argument must be a string");
- }
- Nan::Utf8String utf8_roots(info[0]);
- size_t length = static_cast<size_t>(utf8_roots.length());
- if (length > 0) {
- const char *data = *utf8_roots;
- pem_root_certs = (char *)gpr_malloc((length + 1) * sizeof(char));
- memcpy(pem_root_certs, data, length + 1);
- }
-}
-
-NAUV_WORK_CB(LogMessagesCallback) {
- Nan::HandleScope scope;
- std::queue<log_args *> args;
- uv_mutex_lock(&grpc_logger_state.mutex);
- grpc_logger_state.pending_args->swap(args);
- uv_mutex_unlock(&grpc_logger_state.mutex);
- /* Call the callback with each log message */
- while (!args.empty()) {
- log_args *arg = args.front();
- args.pop();
- Local<Value> file = Nan::New(arg->core_args.file).ToLocalChecked();
- Local<Value> line = Nan::New<Uint32, uint32_t>(arg->core_args.line);
- Local<Value> severity =
- Nan::New(gpr_log_severity_string(arg->core_args.severity))
- .ToLocalChecked();
- Local<Value> message = Nan::New(arg->core_args.message).ToLocalChecked();
- Local<Value> timestamp =
- Nan::New<v8::Date>(grpc::node::TimespecToMilliseconds(arg->timestamp))
- .ToLocalChecked();
- const int argc = 5;
- Local<Value> argv[argc] = {file, line, severity, message, timestamp};
- grpc_logger_state.callback->Call(argc, argv);
- delete[] arg->core_args.message;
- delete arg;
- }
-}
-
-void node_log_func(gpr_log_func_args *args) {
- // TODO(mlumish): Use the core's log formatter when it becomes available
- log_args *args_copy = new log_args;
- size_t message_len = strlen(args->message) + 1;
- char *message = new char[message_len];
- memcpy(message, args->message, message_len);
- memcpy(&args_copy->core_args, args, sizeof(gpr_log_func_args));
- args_copy->core_args.message = message;
- args_copy->timestamp = gpr_now(GPR_CLOCK_REALTIME);
-
- uv_mutex_lock(&grpc_logger_state.mutex);
- grpc_logger_state.pending_args->push(args_copy);
- uv_mutex_unlock(&grpc_logger_state.mutex);
-
- uv_async_send(&grpc_logger_state.async);
-}
-
-void init_logger() {
- memset(&grpc_logger_state, 0, sizeof(logger_state));
- grpc_logger_state.pending_args = new std::queue<log_args *>();
- uv_mutex_init(&grpc_logger_state.mutex);
- uv_async_init(uv_default_loop(), &grpc_logger_state.async,
- LogMessagesCallback);
- uv_unref((uv_handle_t *)&grpc_logger_state.async);
- grpc_logger_state.logger_set = false;
-
- gpr_log_verbosity_init();
-}
-
-/* This registers a JavaScript logger for messages from the gRPC core. Because
- that handler has to be run in the context of the JavaScript event loop, it
- will be run asynchronously. To minimize the problems that could cause for
- debugging, we leave core to do its default synchronous logging until a
- JavaScript logger is set */
-NAN_METHOD(SetDefaultLoggerCallback) {
- if (!info[0]->IsFunction()) {
- return Nan::ThrowTypeError(
- "setDefaultLoggerCallback's argument must be a function");
- }
- if (!grpc_logger_state.logger_set) {
- gpr_set_log_function(node_log_func);
- grpc_logger_state.logger_set = true;
- }
- grpc_logger_state.callback = new Nan::Callback(info[0].As<v8::Function>());
-}
-
-NAN_METHOD(SetLogVerbosity) {
- if (!info[0]->IsUint32()) {
- return Nan::ThrowTypeError("setLogVerbosity's argument must be a number");
- }
- gpr_log_severity severity =
- static_cast<gpr_log_severity>(Nan::To<uint32_t>(info[0]).FromJust());
- gpr_set_log_verbosity(severity);
-}
-
-void init(Local<Object> exports) {
- Nan::HandleScope scope;
- grpc_init();
- grpc_set_ssl_roots_override_callback(get_ssl_roots_override);
- init_logger();
-
- InitOpTypeConstants(exports);
- InitConnectivityStateConstants(exports);
-
- grpc_pollset_work_run_loop = 0;
-
- grpc::node::Call::Init(exports);
- grpc::node::CallCredentials::Init(exports);
- grpc::node::Channel::Init(exports);
- grpc::node::ChannelCredentials::Init(exports);
- grpc::node::Server::Init(exports);
- grpc::node::ServerCredentials::Init(exports);
-
- grpc::node::CompletionQueueInit(exports);
-
- // Attach a few utility functions directly to the module
- Nan::Set(exports, Nan::New("metadataKeyIsLegal").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(MetadataKeyIsLegal))
- .ToLocalChecked());
- Nan::Set(
- exports, Nan::New("metadataNonbinValueIsLegal").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(MetadataNonbinValueIsLegal))
- .ToLocalChecked());
- Nan::Set(exports, Nan::New("metadataKeyIsBinary").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(MetadataKeyIsBinary))
- .ToLocalChecked());
- Nan::Set(exports, Nan::New("setDefaultRootsPem").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(SetDefaultRootsPem))
- .ToLocalChecked());
- Nan::Set(
- exports, Nan::New("setDefaultLoggerCallback").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(SetDefaultLoggerCallback))
- .ToLocalChecked());
- Nan::Set(exports, Nan::New("setLogVerbosity").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(SetLogVerbosity))
- .ToLocalChecked());
-}
-
-NODE_MODULE(grpc_node, init)
diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc
deleted file mode 100644
index c6ab5e1895..0000000000
--- a/src/node/ext/server.cc
+++ /dev/null
@@ -1,342 +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 <memory>
-
-#include "server.h"
-
-#include <nan.h>
-#include <node.h>
-
-#include <vector>
-#include "call.h"
-#include "completion_queue.h"
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "grpc/support/log.h"
-#include "server_credentials.h"
-#include "slice.h"
-#include "timeval.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::EscapableHandleScope;
-using Nan::HandleScope;
-using Nan::Maybe;
-using Nan::MaybeLocal;
-using Nan::ObjectWrap;
-using Nan::Persistent;
-using Nan::Utf8String;
-
-using std::unique_ptr;
-using v8::Array;
-using v8::Boolean;
-using v8::Date;
-using v8::Exception;
-using v8::External;
-using v8::Function;
-using v8::FunctionTemplate;
-using v8::Local;
-using v8::Number;
-using v8::Object;
-using v8::String;
-using v8::Value;
-
-Nan::Callback *Server::constructor;
-Persistent<FunctionTemplate> Server::fun_tpl;
-
-static Callback *shutdown_callback = NULL;
-
-class ServerShutdownOp : public Op {
- public:
- ServerShutdownOp(grpc_server *server) : server(server) {}
-
- ~ServerShutdownOp() {}
-
- Local<Value> GetNodeValue() const { return Nan::Null(); }
-
- bool ParseOp(Local<Value> value, grpc_op *out) { return true; }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {
- /* Because cancel_all_calls was called, we assume that shutdown_and_notify
- completes successfully */
- grpc_server_destroy(server);
- }
-
- grpc_server *server;
-
- protected:
- std::string GetTypeString() const { return "shutdown"; }
-};
-
-class NewCallOp : public Op {
- public:
- NewCallOp() {
- call = NULL;
- grpc_call_details_init(&details);
- grpc_metadata_array_init(&request_metadata);
- }
-
- ~NewCallOp() {
- grpc_call_details_destroy(&details);
- grpc_metadata_array_destroy(&request_metadata);
- }
-
- Local<Value> GetNodeValue() const {
- Nan::EscapableHandleScope scope;
- if (call == NULL) {
- return scope.Escape(Nan::Null());
- }
- Local<Object> obj = Nan::New<Object>();
- Nan::Set(obj, Nan::New("call").ToLocalChecked(), Call::WrapStruct(call));
- // TODO(murgatroid99): Use zero-copy string construction instead
- Nan::Set(obj, Nan::New("method").ToLocalChecked(),
- CopyStringFromSlice(details.method));
- Nan::Set(obj, Nan::New("host").ToLocalChecked(),
- CopyStringFromSlice(details.host));
- Nan::Set(obj, Nan::New("deadline").ToLocalChecked(),
- Nan::New<Date>(TimespecToMilliseconds(details.deadline))
- .ToLocalChecked());
- Nan::Set(obj, Nan::New("metadata").ToLocalChecked(),
- ParseMetadata(&request_metadata));
- return scope.Escape(obj);
- }
-
- bool ParseOp(Local<Value> value, grpc_op *out) { return true; }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {}
-
- grpc_call *call;
- grpc_call_details details;
- grpc_metadata_array request_metadata;
-
- protected:
- std::string GetTypeString() const { return "new_call"; }
-};
-
-class TryShutdownOp : public Op {
- public:
- TryShutdownOp(Server *server, Local<Value> server_value) : server(server) {
- server_persist.Reset(server_value);
- }
- Local<Value> GetNodeValue() const {
- EscapableHandleScope scope;
- return scope.Escape(Nan::New(server_persist));
- }
- bool ParseOp(Local<Value> value, grpc_op *out) { return true; }
- bool IsFinalOp() { return false; }
- void OnComplete(bool success) {
- if (success) {
- server->DestroyWrappedServer();
- }
- }
-
- protected:
- std::string GetTypeString() const { return "try_shutdown"; }
-
- private:
- Server *server;
- Nan::Persistent<v8::Value, Nan::CopyablePersistentTraits<v8::Value>>
- server_persist;
-};
-
-Server::Server(grpc_server *server) : wrapped_server(server) {}
-
-Server::~Server() { this->ShutdownServer(); }
-
-void Server::Init(Local<Object> exports) {
- HandleScope scope;
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
- tpl->SetClassName(Nan::New("Server").ToLocalChecked());
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- Nan::SetPrototypeMethod(tpl, "requestCall", RequestCall);
- Nan::SetPrototypeMethod(tpl, "addHttp2Port", AddHttp2Port);
- Nan::SetPrototypeMethod(tpl, "start", Start);
- Nan::SetPrototypeMethod(tpl, "tryShutdown", TryShutdown);
- Nan::SetPrototypeMethod(tpl, "forceShutdown", ForceShutdown);
- fun_tpl.Reset(tpl);
- Local<Function> ctr = Nan::GetFunction(tpl).ToLocalChecked();
- Nan::Set(exports, Nan::New("Server").ToLocalChecked(), ctr);
- constructor = new Callback(ctr);
-}
-
-bool Server::HasInstance(Local<Value> val) {
- HandleScope scope;
- return Nan::New(fun_tpl)->HasInstance(val);
-}
-
-void Server::DestroyWrappedServer() {
- if (this->wrapped_server != NULL) {
- grpc_server_destroy(this->wrapped_server);
- this->wrapped_server = NULL;
- }
-}
-
-NAN_METHOD(ServerShutdownCallback) {
- if (!info[0]->IsNull()) {
- return Nan::ThrowError("forceShutdown failed somehow");
- }
-}
-
-void Server::ShutdownServer() {
- Nan::HandleScope scope;
- if (this->wrapped_server != NULL) {
- if (shutdown_callback == NULL) {
- Local<FunctionTemplate> callback_tpl =
- Nan::New<FunctionTemplate>(ServerShutdownCallback);
- shutdown_callback =
- new Callback(Nan::GetFunction(callback_tpl).ToLocalChecked());
- }
-
- ServerShutdownOp *op = new ServerShutdownOp(this->wrapped_server);
- unique_ptr<OpVec> ops(new OpVec());
- ops->push_back(unique_ptr<Op>(op));
-
- grpc_server_shutdown_and_notify(
- this->wrapped_server, GetCompletionQueue(),
- new struct tag(new Callback(**shutdown_callback), ops.release(), NULL,
- Nan::Null()));
- grpc_server_cancel_all_calls(this->wrapped_server);
- CompletionQueueNext();
- this->wrapped_server = NULL;
- }
-}
-
-NAN_METHOD(Server::New) {
- /* If this is not a constructor call, make a constructor call and return
- the result */
- if (!info.IsConstructCall()) {
- const int argc = 1;
- Local<Value> argv[argc] = {info[0]};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- // There's probably a pending exception
- return;
- } else {
- info.GetReturnValue().Set(maybe_instance.ToLocalChecked());
- return;
- }
- }
- grpc_server *wrapped_server;
- grpc_completion_queue *queue = GetCompletionQueue();
- grpc_channel_args *channel_args;
- if (!ParseChannelArgs(info[0], &channel_args)) {
- DeallocateChannelArgs(channel_args);
- return Nan::ThrowTypeError(
- "Server options must be an object with "
- "string keys and integer or string values");
- }
- wrapped_server = grpc_server_create(channel_args, NULL);
- DeallocateChannelArgs(channel_args);
- grpc_server_register_completion_queue(wrapped_server, queue, NULL);
- Server *server = new Server(wrapped_server);
- server->Wrap(info.This());
- info.GetReturnValue().Set(info.This());
-}
-
-NAN_METHOD(Server::RequestCall) {
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("requestCall can only be called on a Server");
- }
- Server *server = ObjectWrap::Unwrap<Server>(info.This());
- NewCallOp *op = new NewCallOp();
- unique_ptr<OpVec> ops(new OpVec());
- ops->push_back(unique_ptr<Op>(op));
- grpc_call_error error = grpc_server_request_call(
- server->wrapped_server, &op->call, &op->details, &op->request_metadata,
- GetCompletionQueue(), GetCompletionQueue(),
- new struct tag(new Callback(info[0].As<Function>()), ops.release(), NULL,
- Nan::Null()));
- if (error != GRPC_CALL_OK) {
- return Nan::ThrowError(nanErrorWithCode("requestCall failed", error));
- }
- CompletionQueueNext();
-}
-
-NAN_METHOD(Server::AddHttp2Port) {
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("addHttp2Port can only be called on a Server");
- }
- if (!info[0]->IsString()) {
- return Nan::ThrowTypeError(
- "addHttp2Port's first argument must be a String");
- }
- if (!ServerCredentials::HasInstance(info[1])) {
- return Nan::ThrowTypeError(
- "addHttp2Port's second argument must be ServerCredentials");
- }
- Server *server = ObjectWrap::Unwrap<Server>(info.This());
- ServerCredentials *creds_object = ObjectWrap::Unwrap<ServerCredentials>(
- Nan::To<Object>(info[1]).ToLocalChecked());
- grpc_server_credentials *creds = creds_object->GetWrappedServerCredentials();
- int port;
- if (creds == NULL) {
- port = grpc_server_add_insecure_http2_port(server->wrapped_server,
- *Utf8String(info[0]));
- } else {
- port = grpc_server_add_secure_http2_port(server->wrapped_server,
- *Utf8String(info[0]), creds);
- }
- info.GetReturnValue().Set(Nan::New<Number>(port));
-}
-
-NAN_METHOD(Server::Start) {
- Nan::HandleScope scope;
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("start can only be called on a Server");
- }
- Server *server = ObjectWrap::Unwrap<Server>(info.This());
- grpc_server_start(server->wrapped_server);
-}
-
-NAN_METHOD(Server::TryShutdown) {
- Nan::HandleScope scope;
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("tryShutdown can only be called on a Server");
- }
- Server *server = ObjectWrap::Unwrap<Server>(info.This());
- if (server->wrapped_server == NULL) {
- // Server is already shut down. Call callback immediately.
- Nan::Callback callback(info[0].As<Function>());
- callback.Call(0, {});
- return;
- }
- TryShutdownOp *op = new TryShutdownOp(server, info.This());
- unique_ptr<OpVec> ops(new OpVec());
- ops->push_back(unique_ptr<Op>(op));
- grpc_server_shutdown_and_notify(
- server->wrapped_server, GetCompletionQueue(),
- new struct tag(new Nan::Callback(info[0].As<Function>()), ops.release(),
- NULL, Nan::Null()));
- CompletionQueueNext();
-}
-
-NAN_METHOD(Server::ForceShutdown) {
- Nan::HandleScope scope;
- if (!HasInstance(info.This())) {
- return Nan::ThrowTypeError("forceShutdown can only be called on a Server");
- }
- Server *server = ObjectWrap::Unwrap<Server>(info.This());
- server->ShutdownServer();
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/server.h b/src/node/ext/server.h
deleted file mode 100644
index 66b3ac5267..0000000000
--- a/src/node/ext/server.h
+++ /dev/null
@@ -1,69 +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 NET_GRPC_NODE_SERVER_H_
-#define NET_GRPC_NODE_SERVER_H_
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/grpc.h"
-
-namespace grpc {
-namespace node {
-
-/* Wraps grpc_server as a JavaScript object. Provides a constructor
- and wrapper methods for grpc_server_create, grpc_server_request_call,
- grpc_server_add_http2_port, and grpc_server_start. */
-class Server : public Nan::ObjectWrap {
- public:
- /* Initializes the Server class and exposes the constructor and
- wrapper methods to JavaScript */
- static void Init(v8::Local<v8::Object> exports);
- /* Tests whether the given value was constructed by this class's
- JavaScript constructor */
- static bool HasInstance(v8::Local<v8::Value> val);
-
- void DestroyWrappedServer();
-
- private:
- explicit Server(grpc_server *server);
- ~Server();
-
- // Prevent copying
- Server(const Server &);
- Server &operator=(const Server &);
-
- void ShutdownServer();
-
- static NAN_METHOD(New);
- static NAN_METHOD(RequestCall);
- static NAN_METHOD(AddHttp2Port);
- static NAN_METHOD(Start);
- static NAN_METHOD(TryShutdown);
- static NAN_METHOD(ForceShutdown);
- static Nan::Callback *constructor;
- static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
-
- grpc_server *wrapped_server;
- grpc_completion_queue *shutdown_queue;
-};
-
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_SERVER_H_
diff --git a/src/node/ext/server_credentials.cc b/src/node/ext/server_credentials.cc
deleted file mode 100644
index b7fa478844..0000000000
--- a/src/node/ext/server_credentials.cc
+++ /dev/null
@@ -1,190 +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 <node.h>
-
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-#include "grpc/support/log.h"
-#include "server_credentials.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Callback;
-using Nan::EscapableHandleScope;
-using Nan::HandleScope;
-using Nan::Maybe;
-using Nan::MaybeLocal;
-using Nan::ObjectWrap;
-using Nan::Persistent;
-using Nan::Utf8String;
-
-using v8::Array;
-using v8::Exception;
-using v8::External;
-using v8::Function;
-using v8::FunctionTemplate;
-using v8::Integer;
-using v8::Local;
-using v8::Object;
-using v8::ObjectTemplate;
-using v8::String;
-using v8::Value;
-
-Nan::Callback *ServerCredentials::constructor;
-Persistent<FunctionTemplate> ServerCredentials::fun_tpl;
-
-ServerCredentials::ServerCredentials(grpc_server_credentials *credentials)
- : wrapped_credentials(credentials) {}
-
-ServerCredentials::~ServerCredentials() {
- grpc_server_credentials_release(wrapped_credentials);
-}
-
-void ServerCredentials::Init(Local<Object> exports) {
- Nan::HandleScope scope;
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
- tpl->SetClassName(Nan::New("ServerCredentials").ToLocalChecked());
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
- Local<Function> ctr = tpl->GetFunction();
- Nan::Set(
- ctr, Nan::New("createSsl").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(CreateSsl)).ToLocalChecked());
- Nan::Set(ctr, Nan::New("createInsecure").ToLocalChecked(),
- Nan::GetFunction(Nan::New<FunctionTemplate>(CreateInsecure))
- .ToLocalChecked());
- fun_tpl.Reset(tpl);
- constructor = new Nan::Callback(ctr);
- Nan::Set(exports, Nan::New("ServerCredentials").ToLocalChecked(), ctr);
-}
-
-bool ServerCredentials::HasInstance(Local<Value> val) {
- Nan::HandleScope scope;
- return Nan::New(fun_tpl)->HasInstance(val);
-}
-
-Local<Value> ServerCredentials::WrapStruct(
- grpc_server_credentials *credentials) {
- Nan::EscapableHandleScope scope;
- const int argc = 1;
- Local<Value> argv[argc] = {
- Nan::New<External>(reinterpret_cast<void *>(credentials))};
- MaybeLocal<Object> maybe_instance =
- Nan::NewInstance(constructor->GetFunction(), argc, argv);
- if (maybe_instance.IsEmpty()) {
- return scope.Escape(Nan::Null());
- } else {
- return scope.Escape(maybe_instance.ToLocalChecked());
- }
-}
-
-grpc_server_credentials *ServerCredentials::GetWrappedServerCredentials() {
- return wrapped_credentials;
-}
-
-NAN_METHOD(ServerCredentials::New) {
- if (info.IsConstructCall()) {
- if (!info[0]->IsExternal()) {
- return Nan::ThrowTypeError(
- "ServerCredentials can only be created with the provided functions");
- }
- Local<External> ext = info[0].As<External>();
- grpc_server_credentials *creds_value =
- reinterpret_cast<grpc_server_credentials *>(ext->Value());
- ServerCredentials *credentials = new ServerCredentials(creds_value);
- credentials->Wrap(info.This());
- info.GetReturnValue().Set(info.This());
- } else {
- // This should never be called directly
- return Nan::ThrowTypeError(
- "ServerCredentials can only be created with the provided functions");
- }
-}
-
-NAN_METHOD(ServerCredentials::CreateSsl) {
- Nan::HandleScope scope;
- char *root_certs = NULL;
- if (::node::Buffer::HasInstance(info[0])) {
- root_certs = ::node::Buffer::Data(info[0]);
- } else if (!(info[0]->IsNull() || info[0]->IsUndefined())) {
- return Nan::ThrowTypeError(
- "createSSl's first argument must be a Buffer if provided");
- }
- if (!info[1]->IsArray()) {
- return Nan::ThrowTypeError(
- "createSsl's second argument must be a list of objects");
- }
-
- // Default to not requesting the client certificate
- grpc_ssl_client_certificate_request_type client_certificate_request =
- GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
- if (info[2]->IsBoolean()) {
- client_certificate_request =
- Nan::To<bool>(info[2]).FromJust()
- ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
- : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
- } else if (!(info[2]->IsUndefined() || info[2]->IsNull())) {
- return Nan::ThrowTypeError(
- "createSsl's third argument must be a boolean if provided");
- }
- Local<Array> pair_list = Local<Array>::Cast(info[1]);
- uint32_t key_cert_pair_count = pair_list->Length();
- grpc_ssl_pem_key_cert_pair *key_cert_pairs =
- new grpc_ssl_pem_key_cert_pair[key_cert_pair_count];
-
- Local<String> key_key = Nan::New("private_key").ToLocalChecked();
- Local<String> cert_key = Nan::New("cert_chain").ToLocalChecked();
-
- for (uint32_t i = 0; i < key_cert_pair_count; i++) {
- Local<Value> pair_val = Nan::Get(pair_list, i).ToLocalChecked();
- if (!pair_val->IsObject()) {
- delete[] key_cert_pairs;
- return Nan::ThrowTypeError("Key/cert pairs must be objects");
- }
- Local<Object> pair_obj = Nan::To<Object>(pair_val).ToLocalChecked();
- Local<Value> maybe_key = Nan::Get(pair_obj, key_key).ToLocalChecked();
- Local<Value> maybe_cert = Nan::Get(pair_obj, cert_key).ToLocalChecked();
- if (!::node::Buffer::HasInstance(maybe_key)) {
- delete[] key_cert_pairs;
- return Nan::ThrowTypeError("private_key must be a Buffer");
- }
- if (!::node::Buffer::HasInstance(maybe_cert)) {
- delete[] key_cert_pairs;
- return Nan::ThrowTypeError("cert_chain must be a Buffer");
- }
- key_cert_pairs[i].private_key = ::node::Buffer::Data(maybe_key);
- key_cert_pairs[i].cert_chain = ::node::Buffer::Data(maybe_cert);
- }
- grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex(
- root_certs, key_cert_pairs, key_cert_pair_count,
- client_certificate_request, NULL);
- delete[] key_cert_pairs;
- if (creds == NULL) {
- info.GetReturnValue().SetNull();
- } else {
- info.GetReturnValue().Set(WrapStruct(creds));
- }
-}
-
-NAN_METHOD(ServerCredentials::CreateInsecure) {
- info.GetReturnValue().Set(WrapStruct(NULL));
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/server_credentials.h b/src/node/ext/server_credentials.h
deleted file mode 100644
index 59f91481a2..0000000000
--- a/src/node/ext/server_credentials.h
+++ /dev/null
@@ -1,62 +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 NET_GRPC_NODE_SERVER_CREDENTIALS_H_
-#define NET_GRPC_NODE_SERVER_CREDENTIALS_H_
-
-#include <nan.h>
-#include <node.h>
-#include "grpc/grpc.h"
-#include "grpc/grpc_security.h"
-
-namespace grpc {
-namespace node {
-
-/* Wrapper class for grpc_server_credentials structs */
-class ServerCredentials : public Nan::ObjectWrap {
- public:
- static void Init(v8::Local<v8::Object> exports);
- static bool HasInstance(v8::Local<v8::Value> val);
- /* Wrap a grpc_server_credentials struct in a javascript object */
- static v8::Local<v8::Value> WrapStruct(grpc_server_credentials *credentials);
-
- /* Returns the grpc_server_credentials struct that this object wraps */
- grpc_server_credentials *GetWrappedServerCredentials();
-
- private:
- explicit ServerCredentials(grpc_server_credentials *credentials);
- ~ServerCredentials();
-
- // Prevent copying
- ServerCredentials(const ServerCredentials &);
- ServerCredentials &operator=(const ServerCredentials &);
-
- static NAN_METHOD(New);
- static NAN_METHOD(CreateSsl);
- static NAN_METHOD(CreateInsecure);
- static Nan::Callback *constructor;
- // Used for typechecking instances of this javascript class
- static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
-
- grpc_server_credentials *wrapped_credentials;
-};
-
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_SERVER_CREDENTIALS_H_
diff --git a/src/node/ext/slice.cc b/src/node/ext/slice.cc
deleted file mode 100644
index 8806a61a9e..0000000000
--- a/src/node/ext/slice.cc
+++ /dev/null
@@ -1,90 +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 <grpc/slice.h>
-#include <grpc/support/alloc.h>
-#include <nan.h>
-#include <node.h>
-
-#include "slice.h"
-
-namespace grpc {
-namespace node {
-
-using Nan::Persistent;
-
-using v8::Local;
-using v8::String;
-using v8::Value;
-
-namespace {
-void SliceFreeCallback(char *data, void *hint) {
- grpc_slice *slice = reinterpret_cast<grpc_slice *>(hint);
- grpc_slice_unref(*slice);
- delete slice;
-}
-
-void string_destroy_func(void *user_data) {
- delete reinterpret_cast<Nan::Utf8String *>(user_data);
-}
-
-void buffer_destroy_func(void *user_data) {
- delete reinterpret_cast<PersistentValue *>(user_data);
-}
-} // namespace
-
-grpc_slice CreateSliceFromString(const Local<String> source) {
- Nan::HandleScope scope;
- Nan::Utf8String *utf8_value = new Nan::Utf8String(source);
- return grpc_slice_new_with_user_data(**utf8_value, source->Length(),
- string_destroy_func, utf8_value);
-}
-
-grpc_slice CreateSliceFromBuffer(const Local<Value> source) {
- // Prerequisite: ::node::Buffer::HasInstance(source)
- Nan::HandleScope scope;
- return grpc_slice_new_with_user_data(
- ::node::Buffer::Data(source), ::node::Buffer::Length(source),
- buffer_destroy_func, new PersistentValue(source));
-}
-Local<String> CopyStringFromSlice(const grpc_slice slice) {
- Nan::EscapableHandleScope scope;
- if (GRPC_SLICE_LENGTH(slice) == 0) {
- return scope.Escape(Nan::EmptyString());
- }
- return scope.Escape(
- Nan::New<String>(const_cast<char *>(reinterpret_cast<const char *>(
- GRPC_SLICE_START_PTR(slice))),
- GRPC_SLICE_LENGTH(slice))
- .ToLocalChecked());
-}
-
-Local<Value> CreateBufferFromSlice(const grpc_slice slice) {
- Nan::EscapableHandleScope scope;
- grpc_slice *slice_ptr = new grpc_slice;
- *slice_ptr = grpc_slice_ref(slice);
- return scope.Escape(
- Nan::NewBuffer(
- const_cast<char *>(
- reinterpret_cast<const char *>(GRPC_SLICE_START_PTR(*slice_ptr))),
- GRPC_SLICE_LENGTH(*slice_ptr), SliceFreeCallback, slice_ptr)
- .ToLocalChecked());
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/slice.h b/src/node/ext/slice.h
deleted file mode 100644
index 0a652c5755..0000000000
--- a/src/node/ext/slice.h
+++ /dev/null
@@ -1,38 +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 <grpc/slice.h>
-#include <nan.h>
-#include <node.h>
-
-namespace grpc {
-namespace node {
-
-typedef Nan::Persistent<v8::Value, Nan::CopyablePersistentTraits<v8::Value>>
- PersistentValue;
-
-grpc_slice CreateSliceFromString(const v8::Local<v8::String> source);
-
-grpc_slice CreateSliceFromBuffer(const v8::Local<v8::Value> source);
-
-v8::Local<v8::String> CopyStringFromSlice(const grpc_slice slice);
-
-v8::Local<v8::Value> CreateBufferFromSlice(const grpc_slice slice);
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/ext/timeval.cc b/src/node/ext/timeval.cc
deleted file mode 100644
index 6142584759..0000000000
--- a/src/node/ext/timeval.cc
+++ /dev/null
@@ -1,53 +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 <cstdint>
-#include <limits>
-
-#include "grpc/grpc.h"
-#include "grpc/support/time.h"
-#include "timeval.h"
-
-namespace grpc {
-namespace node {
-
-gpr_timespec MillisecondsToTimespec(double millis) {
- if (millis == std::numeric_limits<double>::infinity()) {
- return gpr_inf_future(GPR_CLOCK_REALTIME);
- } else if (millis == -std::numeric_limits<double>::infinity()) {
- return gpr_inf_past(GPR_CLOCK_REALTIME);
- } else {
- return gpr_time_from_micros(static_cast<int64_t>(millis * 1000),
- GPR_CLOCK_REALTIME);
- }
-}
-
-double TimespecToMilliseconds(gpr_timespec timespec) {
- timespec = gpr_convert_clock_type(timespec, GPR_CLOCK_REALTIME);
- if (gpr_time_cmp(timespec, gpr_inf_future(GPR_CLOCK_REALTIME)) == 0) {
- return std::numeric_limits<double>::infinity();
- } else if (gpr_time_cmp(timespec, gpr_inf_past(GPR_CLOCK_REALTIME)) == 0) {
- return -std::numeric_limits<double>::infinity();
- } else {
- return (static_cast<double>(timespec.tv_sec) * 1000 +
- static_cast<double>(timespec.tv_nsec) / 1000000);
- }
-}
-
-} // namespace node
-} // namespace grpc
diff --git a/src/node/health_check/LICENSE b/src/node/health_check/LICENSE
deleted file mode 100644
index 7750ce4fdd..0000000000
--- a/src/node/health_check/LICENSE
+++ /dev/null
@@ -1,186 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for any such Derivative Works as a whole, provided Your use,
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- Copyright 2015-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.
diff --git a/src/node/health_check/health.js b/src/node/health_check/health.js
deleted file mode 100644
index 7ad2c1e217..0000000000
--- a/src/node/health_check/health.js
+++ /dev/null
@@ -1,52 +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.
- *
- */
-
-'use strict';
-
-var grpc = require('grpc');
-
-var _ = require('lodash');
-
-var health_messages = require('./v1/health_pb');
-var health_service = require('./v1/health_grpc_pb');
-
-function HealthImplementation(statusMap) {
- this.statusMap = _.clone(statusMap);
-}
-
-HealthImplementation.prototype.setStatus = function(service, status) {
- this.statusMap[service] = status;
-};
-
-HealthImplementation.prototype.check = function(call, callback){
- var service = call.request.getService();
- var status = _.get(this.statusMap, service, null);
- if (status === null) {
- callback({code:grpc.status.NOT_FOUND});
- } else {
- var response = new health_messages.HealthCheckResponse();
- response.setStatus(status);
- callback(null, response);
- }
-};
-
-module.exports = {
- Client: health_service.HealthClient,
- service: health_service.HealthService,
- Implementation: HealthImplementation
-};
diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json
deleted file mode 100644
index 3c7d3707ee..0000000000
--- a/src/node/health_check/package.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "name": "grpc-health-check",
- "version": "1.7.0-dev",
- "author": "Google Inc.",
- "description": "Health check service for use with gRPC",
- "repository": {
- "type": "git",
- "url": "https://github.com/grpc/grpc.git"
- },
- "bugs": "https://github.com/grpc/grpc/issues",
- "contributors": [
- {
- "name": "Michael Lumish",
- "email": "mlumish@google.com"
- }
- ],
- "dependencies": {
- "grpc": "^1.7.0-dev",
- "lodash": "^3.9.3",
- "google-protobuf": "^3.0.0"
- },
- "files": [
- "LICENSE",
- "health.js",
- "v1"
- ],
- "main": "src/node/index.js",
- "license": "Apache-2.0"
-}
diff --git a/src/node/health_check/v1/health_grpc_pb.js b/src/node/health_check/v1/health_grpc_pb.js
deleted file mode 100644
index 2a1ac6ff75..0000000000
--- a/src/node/health_check/v1/health_grpc_pb.js
+++ /dev/null
@@ -1,59 +0,0 @@
-// GENERATED CODE -- DO NOT EDIT!
-
-// Original file comments:
-// 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.
-//
-'use strict';
-var grpc = require('grpc');
-var v1_health_pb = require('../v1/health_pb.js');
-
-function serialize_HealthCheckRequest(arg) {
- if (!(arg instanceof v1_health_pb.HealthCheckRequest)) {
- throw new Error('Expected argument of type HealthCheckRequest');
- }
- return new Buffer(arg.serializeBinary());
-}
-
-function deserialize_HealthCheckRequest(buffer_arg) {
- return v1_health_pb.HealthCheckRequest.deserializeBinary(new Uint8Array(buffer_arg));
-}
-
-function serialize_HealthCheckResponse(arg) {
- if (!(arg instanceof v1_health_pb.HealthCheckResponse)) {
- throw new Error('Expected argument of type HealthCheckResponse');
- }
- return new Buffer(arg.serializeBinary());
-}
-
-function deserialize_HealthCheckResponse(buffer_arg) {
- return v1_health_pb.HealthCheckResponse.deserializeBinary(new Uint8Array(buffer_arg));
-}
-
-
-var HealthService = exports.HealthService = {
- check: {
- path: '/grpc.health.v1.Health/Check',
- requestStream: false,
- responseStream: false,
- requestType: v1_health_pb.HealthCheckRequest,
- responseType: v1_health_pb.HealthCheckResponse,
- requestSerialize: serialize_HealthCheckRequest,
- requestDeserialize: deserialize_HealthCheckRequest,
- responseSerialize: serialize_HealthCheckResponse,
- responseDeserialize: deserialize_HealthCheckResponse,
- },
-};
-
-exports.HealthClient = grpc.makeGenericClientConstructor(HealthService);
diff --git a/src/node/health_check/v1/health_pb.js b/src/node/health_check/v1/health_pb.js
deleted file mode 100644
index b36d47cdbb..0000000000
--- a/src/node/health_check/v1/health_pb.js
+++ /dev/null
@@ -1,342 +0,0 @@
-/**
- * @fileoverview
- * @enhanceable
- * @public
- */
-// GENERATED CODE -- DO NOT EDIT!
-
-var jspb = require('google-protobuf');
-var goog = jspb;
-var global = Function('return this')();
-
-goog.exportSymbol('proto.grpc.health.v1.HealthCheckRequest', null, global);
-goog.exportSymbol('proto.grpc.health.v1.HealthCheckResponse', null, global);
-goog.exportSymbol('proto.grpc.health.v1.HealthCheckResponse.ServingStatus', null, global);
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.grpc.health.v1.HealthCheckRequest = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.grpc.health.v1.HealthCheckRequest, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.grpc.health.v1.HealthCheckRequest.displayName = 'proto.grpc.health.v1.HealthCheckRequest';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.grpc.health.v1.HealthCheckRequest.prototype.toObject = function(opt_includeInstance) {
- return proto.grpc.health.v1.HealthCheckRequest.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.grpc.health.v1.HealthCheckRequest} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.grpc.health.v1.HealthCheckRequest.toObject = function(includeInstance, msg) {
- var f, obj = {
- service: msg.getService()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.grpc.health.v1.HealthCheckRequest}
- */
-proto.grpc.health.v1.HealthCheckRequest.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.grpc.health.v1.HealthCheckRequest;
- return proto.grpc.health.v1.HealthCheckRequest.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.grpc.health.v1.HealthCheckRequest} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.grpc.health.v1.HealthCheckRequest}
- */
-proto.grpc.health.v1.HealthCheckRequest.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {string} */ (reader.readString());
- msg.setService(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.grpc.health.v1.HealthCheckRequest} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.grpc.health.v1.HealthCheckRequest.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.grpc.health.v1.HealthCheckRequest.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.grpc.health.v1.HealthCheckRequest.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getService();
- if (f.length > 0) {
- writer.writeString(
- 1,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.grpc.health.v1.HealthCheckRequest} The clone.
- */
-proto.grpc.health.v1.HealthCheckRequest.prototype.cloneMessage = function() {
- return /** @type {!proto.grpc.health.v1.HealthCheckRequest} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional string service = 1;
- * @return {string}
- */
-proto.grpc.health.v1.HealthCheckRequest.prototype.getService = function() {
- return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, ""));
-};
-
-
-/** @param {string} value */
-proto.grpc.health.v1.HealthCheckRequest.prototype.setService = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.grpc.health.v1.HealthCheckResponse = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.grpc.health.v1.HealthCheckResponse, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.grpc.health.v1.HealthCheckResponse.displayName = 'proto.grpc.health.v1.HealthCheckResponse';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.grpc.health.v1.HealthCheckResponse.prototype.toObject = function(opt_includeInstance) {
- return proto.grpc.health.v1.HealthCheckResponse.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.grpc.health.v1.HealthCheckResponse} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.grpc.health.v1.HealthCheckResponse.toObject = function(includeInstance, msg) {
- var f, obj = {
- status: msg.getStatus()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.grpc.health.v1.HealthCheckResponse}
- */
-proto.grpc.health.v1.HealthCheckResponse.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.grpc.health.v1.HealthCheckResponse;
- return proto.grpc.health.v1.HealthCheckResponse.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.grpc.health.v1.HealthCheckResponse} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.grpc.health.v1.HealthCheckResponse}
- */
-proto.grpc.health.v1.HealthCheckResponse.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {!proto.grpc.health.v1.HealthCheckResponse.ServingStatus} */ (reader.readEnum());
- msg.setStatus(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.grpc.health.v1.HealthCheckResponse} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.grpc.health.v1.HealthCheckResponse.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.grpc.health.v1.HealthCheckResponse.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.grpc.health.v1.HealthCheckResponse.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getStatus();
- if (f !== 0.0) {
- writer.writeEnum(
- 1,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.grpc.health.v1.HealthCheckResponse} The clone.
- */
-proto.grpc.health.v1.HealthCheckResponse.prototype.cloneMessage = function() {
- return /** @type {!proto.grpc.health.v1.HealthCheckResponse} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional ServingStatus status = 1;
- * @return {!proto.grpc.health.v1.HealthCheckResponse.ServingStatus}
- */
-proto.grpc.health.v1.HealthCheckResponse.prototype.getStatus = function() {
- return /** @type {!proto.grpc.health.v1.HealthCheckResponse.ServingStatus} */ (jspb.Message.getFieldProto3(this, 1, 0));
-};
-
-
-/** @param {!proto.grpc.health.v1.HealthCheckResponse.ServingStatus} value */
-proto.grpc.health.v1.HealthCheckResponse.prototype.setStatus = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-/**
- * @enum {number}
- */
-proto.grpc.health.v1.HealthCheckResponse.ServingStatus = {
- UNKNOWN: 0,
- SERVING: 1,
- NOT_SERVING: 2
-};
-
-goog.object.extend(exports, proto.grpc.health.v1);
diff --git a/src/node/index.js b/src/node/index.js
deleted file mode 100644
index 452b11f6db..0000000000
--- a/src/node/index.js
+++ /dev/null
@@ -1,255 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-'use strict';
-
-var path = require('path');
-var fs = require('fs');
-
-var SSL_ROOTS_PATH = path.resolve(__dirname, '..', '..', 'etc', 'roots.pem');
-
-var _ = require('lodash');
-
-var ProtoBuf = require('protobufjs');
-
-var client = require('./src/client.js');
-
-var server = require('./src/server.js');
-
-var common = require('./src/common.js');
-
-var Metadata = require('./src/metadata.js');
-
-var grpc = require('./src/grpc_extension');
-
-var protobuf_js_5_common = require('./src/protobuf_js_5_common');
-var protobuf_js_6_common = require('./src/protobuf_js_6_common');
-
-var constants = require('./src/constants.js');
-
-grpc.setDefaultRootsPem(fs.readFileSync(SSL_ROOTS_PATH, 'ascii'));
-
-/**
- * @namespace grpc
- */
-
-/**
- * Load a ProtoBuf.js object as a gRPC object.
- * @memberof grpc
- * @alias grpc.loadObject
- * @param {Object} value The ProtoBuf.js reflection object to load
- * @param {Object=} options Options to apply to the loaded file
- * @param {bool=} [options.binaryAsBase64=false] deserialize bytes values as
- * base64 strings instead of Buffers
- * @param {bool=} [options.longsAsStrings=true] deserialize long values as
- * strings instead of objects
- * @param {bool=} [options.enumsAsStrings=true] deserialize enum values as
- * strings instead of numbers. Only works with Protobuf.js 6 values.
- * @param {bool=} [options.deprecatedArgumentOrder=false] use the beta method
- * argument order for client methods, with optional arguments after the
- * callback. This option is only a temporary stopgap measure to smooth an
- * API breakage. It is deprecated, and new code should not use it.
- * @param {(number|string)=} [options.protobufjsVersion='detect'] 5 and 6
- * respectively indicate that an object from the corresponding version of
- * Protobuf.js is provided in the value argument. If the option is 'detect',
- * gRPC wll guess what the version is based on the structure of the value.
- * @return {Object<string, *>} The resulting gRPC object.
- */
-exports.loadObject = function loadObject(value, options) {
- options = _.defaults(options, common.defaultGrpcOptions);
- options = _.defaults(options, {'protobufjsVersion': 'detect'});
- var protobufjsVersion;
- if (options.protobufjsVersion === 'detect') {
- if (protobuf_js_6_common.isProbablyProtobufJs6(value)) {
- protobufjsVersion = 6;
- } else if (protobuf_js_5_common.isProbablyProtobufJs5(value)) {
- protobufjsVersion = 5;
- } else {
- var error_message = 'Could not detect ProtoBuf.js version. Please ' +
- 'specify the version number with the "protobufjs_version" option';
- throw new Error(error_message);
- }
- } else {
- protobufjsVersion = options.protobufjsVersion;
- }
- switch (protobufjsVersion) {
- case 6: return protobuf_js_6_common.loadObject(value, options);
- case 5:
- return protobuf_js_5_common.loadObject(value, options);
- default:
- throw new Error('Unrecognized protobufjsVersion', protobufjsVersion);
- }
-};
-
-var loadObject = exports.loadObject;
-
-/**
- * Load a gRPC object from a .proto file.
- * @memberof grpc
- * @alias grpc.load
- * @param {string|{root: string, file: string}} filename The file to load
- * @param {string=} format The file format to expect. Must be either 'proto' or
- * 'json'. Defaults to 'proto'
- * @param {Object=} options Options to apply to the loaded file
- * @param {bool=} [options.convertFieldsToCamelCase=false] Load this file with
- * field names in camel case instead of their original case
- * @param {bool=} [options.binaryAsBase64=false] deserialize bytes values as
- * base64 strings instead of Buffers
- * @param {bool=} [options.longsAsStrings=true] deserialize long values as
- * strings instead of objects
- * @param {bool=} [options.deprecatedArgumentOrder=false] use the beta method
- * argument order for client methods, with optional arguments after the
- * callback. This option is only a temporary stopgap measure to smooth an
- * API breakage. It is deprecated, and new code should not use it.
- * @return {Object<string, *>} The resulting gRPC object
- */
-exports.load = function load(filename, format, options) {
- options = _.defaults(options, common.defaultGrpcOptions);
- options.protobufjsVersion = 5;
- if (!format) {
- format = 'proto';
- }
- var convertFieldsToCamelCaseOriginal = ProtoBuf.convertFieldsToCamelCase;
- if(options && options.hasOwnProperty('convertFieldsToCamelCase')) {
- ProtoBuf.convertFieldsToCamelCase = options.convertFieldsToCamelCase;
- }
- var builder;
- try {
- switch(format) {
- case 'proto':
- builder = ProtoBuf.loadProtoFile(filename);
- break;
- case 'json':
- builder = ProtoBuf.loadJsonFile(filename);
- break;
- default:
- throw new Error('Unrecognized format "' + format + '"');
- }
- } finally {
- ProtoBuf.convertFieldsToCamelCase = convertFieldsToCamelCaseOriginal;
- }
- return loadObject(builder.ns, options);
-};
-
-var log_template = _.template(
- '{severity} {timestamp}\t{file}:{line}]\t{message}',
- {interpolate: /{([\s\S]+?)}/g});
-
-/**
- * Sets the logger function for the gRPC module. For debugging purposes, the C
- * core will log synchronously directly to stdout unless this function is
- * called. Note: the output format here is intended to be informational, and
- * is not guaranteed to stay the same in the future.
- * Logs will be directed to logger.error.
- * @memberof grpc
- * @alias grpc.setLogger
- * @param {Console} logger A Console-like object.
- */
-exports.setLogger = function setLogger(logger) {
- common.logger = logger;
- grpc.setDefaultLoggerCallback(function(file, line, severity,
- message, timestamp) {
- logger.error(log_template({
- file: path.basename(file),
- line: line,
- severity: severity,
- message: message,
- timestamp: timestamp.toISOString()
- }));
- });
-};
-
-/**
- * Sets the logger verbosity for gRPC module logging. The options are members
- * of the grpc.logVerbosity map.
- * @memberof grpc
- * @alias grpc.setLogVerbosity
- * @param {Number} verbosity The minimum severity to log
- */
-exports.setLogVerbosity = function setLogVerbosity(verbosity) {
- common.logVerbosity = verbosity;
- grpc.setLogVerbosity(verbosity);
-};
-
-exports.Server = server.Server;
-
-exports.Metadata = Metadata;
-
-exports.status = constants.status;
-
-exports.propagate = constants.propagate;
-
-exports.callError = constants.callError;
-
-exports.writeFlags = constants.writeFlags;
-
-exports.logVerbosity = constants.logVerbosity;
-
-exports.credentials = require('./src/credentials.js');
-
-/**
- * ServerCredentials factories
- * @constructor ServerCredentials
- * @memberof grpc
- */
-exports.ServerCredentials = grpc.ServerCredentials;
-
-/**
- * Create insecure server credentials
- * @name grpc.ServerCredentials.createInsecure
- * @kind function
- * @return grpc.ServerCredentials
- */
-
-/**
- * A private key and certificate pair
- * @typedef {Object} grpc.ServerCredentials~keyCertPair
- * @property {Buffer} privateKey The server's private key
- * @property {Buffer} certChain The server's certificate chain
- */
-
-/**
- * Create SSL server credentials
- * @name grpc.ServerCredentials.createInsecure
- * @kind function
- * @param {?Buffer} rootCerts Root CA certificates for validating client
- * certificates
- * @param {Array<grpc.ServerCredentials~keyCertPair>} keyCertPairs A list of
- * private key and certificate chain pairs to be used for authenticating
- * the server
- * @param {boolean} [checkClientCertificate=false] Indicates that the server
- * should request and verify the client's certificates
- * @return grpc.ServerCredentials
- */
-
-exports.makeGenericClientConstructor = client.makeClientConstructor;
-
-exports.getClientChannel = client.getClientChannel;
-
-exports.waitForClientReady = client.waitForClientReady;
-
-/**
- * @memberof grpc
- * @alias grpc.closeClient
- * @param {grpc.Client} client_obj The client to close
- */
-exports.closeClient = function closeClient(client_obj) {
- client.Client.prototype.close.apply(client_obj);
-};
-
-exports.Client = client.Client;
diff --git a/src/node/interop/async_delay_queue.js b/src/node/interop/async_delay_queue.js
deleted file mode 100644
index 43ac573874..0000000000
--- a/src/node/interop/async_delay_queue.js
+++ /dev/null
@@ -1,64 +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.
- *
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-/**
- * This class represents a queue of callbacks that must happen sequentially,
- * each with a specific delay after the previous event.
- */
-function AsyncDelayQueue() {
- this.queue = [];
-
- this.callback_pending = false;
-}
-
-/**
- * Run the next callback after its corresponding delay, if there are any
- * remaining.
- */
-AsyncDelayQueue.prototype.runNext = function() {
- var next = this.queue.shift();
- var continueCallback = _.bind(this.runNext, this);
- if (next) {
- this.callback_pending = true;
- setTimeout(function() {
- next.callback(continueCallback);
- }, next.delay);
- } else {
- this.callback_pending = false;
- }
-};
-
-/**
- * Add a callback to be called with a specific delay after now or after the
- * current last item in the queue or current pending callback, whichever is
- * latest.
- * @param {function(function())} callback The callback
- * @param {Number} The delay to apply, in milliseconds
- */
-AsyncDelayQueue.prototype.add = function(callback, delay) {
- this.queue.push({callback: callback, delay: delay});
- if (!this.callback_pending) {
- this.runNext();
- }
-};
-
-module.exports = AsyncDelayQueue;
diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js
deleted file mode 100644
index f321d58aa6..0000000000
--- a/src/node/interop/interop_client.js
+++ /dev/null
@@ -1,621 +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.
- *
- */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-var grpc = require('..');
-var testProto = grpc.load({
- root: __dirname + '/../../..',
- file: 'src/proto/grpc/testing/test.proto'}).grpc.testing;
-var GoogleAuth = require('google-auth-library');
-
-var assert = require('assert');
-
-var SERVICE_ACCOUNT_EMAIL;
-try {
- SERVICE_ACCOUNT_EMAIL = require(
- process.env.GOOGLE_APPLICATION_CREDENTIALS).client_email;
-} catch (e) {
- // This will cause the tests to fail if they need that string
- SERVICE_ACCOUNT_EMAIL = null;
-}
-
-var ECHO_INITIAL_KEY = 'x-grpc-test-echo-initial';
-var ECHO_TRAILING_KEY = 'x-grpc-test-echo-trailing-bin';
-
-/**
- * Create a buffer filled with size zeroes
- * @param {number} size The length of the buffer
- * @return {Buffer} The new buffer
- */
-function zeroBuffer(size) {
- var zeros = new Buffer(size);
- zeros.fill(0);
- return zeros;
-}
-
-/**
- * This is used for testing functions with multiple asynchronous calls that
- * can happen in different orders. This should be passed the number of async
- * function invocations that can occur last, and each of those should call this
- * function's return value
- * @param {function()} done The function that should be called when a test is
- * complete.
- * @param {number} count The number of calls to the resulting function if the
- * test passes.
- * @return {function()} The function that should be called at the end of each
- * sequence of asynchronous functions.
- */
-function multiDone(done, count) {
- return function() {
- count -= 1;
- if (count <= 0) {
- done();
- }
- };
-}
-
-/**
- * Run the empty_unary test
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function emptyUnary(client, done) {
- client.emptyCall({}, function(err, resp) {
- assert.ifError(err);
- if (done) {
- done();
- }
- });
-}
-
-/**
- * Run the large_unary test
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function largeUnary(client, done) {
- var arg = {
- response_type: 'COMPRESSABLE',
- response_size: 314159,
- payload: {
- body: zeroBuffer(271828)
- }
- };
- client.unaryCall(arg, function(err, resp) {
- assert.ifError(err);
- assert.strictEqual(resp.payload.type, 'COMPRESSABLE');
- assert.strictEqual(resp.payload.body.length, 314159);
- if (done) {
- done();
- }
- });
-}
-
-/**
- * Run the client_streaming test
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function clientStreaming(client, done) {
- var call = client.streamingInputCall(function(err, resp) {
- assert.ifError(err);
- assert.strictEqual(resp.aggregated_payload_size, 74922);
- if (done) {
- done();
- }
- });
- var payload_sizes = [27182, 8, 1828, 45904];
- for (var i = 0; i < payload_sizes.length; i++) {
- call.write({payload: {body: zeroBuffer(payload_sizes[i])}});
- }
- call.end();
-}
-
-/**
- * Run the server_streaming test
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function serverStreaming(client, done) {
- var arg = {
- response_type: 'COMPRESSABLE',
- response_parameters: [
- {size: 31415},
- {size: 9},
- {size: 2653},
- {size: 58979}
- ]
- };
- var call = client.streamingOutputCall(arg);
- var resp_index = 0;
- call.on('data', function(value) {
- assert(resp_index < 4);
- assert.strictEqual(value.payload.type, 'COMPRESSABLE');
- assert.strictEqual(value.payload.body.length,
- arg.response_parameters[resp_index].size);
- resp_index += 1;
- });
- call.on('end', function() {
- assert.strictEqual(resp_index, 4);
- if (done) {
- done();
- }
- });
- call.on('status', function(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- });
-}
-
-/**
- * Run the ping_pong test
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function pingPong(client, done) {
- var payload_sizes = [27182, 8, 1828, 45904];
- var response_sizes = [31415, 9, 2653, 58979];
- var call = client.fullDuplexCall();
- call.on('status', function(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- if (done) {
- done();
- }
- });
- var index = 0;
- call.write({
- response_type: 'COMPRESSABLE',
- response_parameters: [
- {size: response_sizes[index]}
- ],
- payload: {body: zeroBuffer(payload_sizes[index])}
- });
- call.on('data', function(response) {
- assert.strictEqual(response.payload.type, 'COMPRESSABLE');
- assert.equal(response.payload.body.length, response_sizes[index]);
- index += 1;
- if (index === 4) {
- call.end();
- } else {
- call.write({
- response_type: 'COMPRESSABLE',
- response_parameters: [
- {size: response_sizes[index]}
- ],
- payload: {body: zeroBuffer(payload_sizes[index])}
- });
- }
- });
-}
-
-/**
- * Run the empty_stream test.
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function emptyStream(client, done) {
- var call = client.fullDuplexCall();
- call.on('status', function(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- if (done) {
- done();
- }
- });
- call.on('data', function(value) {
- assert.fail(value, null, 'No data should have been received', '!==');
- });
- call.end();
-}
-
-/**
- * Run the cancel_after_begin test.
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function cancelAfterBegin(client, done) {
- var call = client.streamingInputCall(function(err, resp) {
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
-}
-
-/**
- * Run the cancel_after_first_response test.
- * @param {Client} client The client to test against
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function cancelAfterFirstResponse(client, done) {
- var call = client.fullDuplexCall();
- call.write({
- response_type: 'COMPRESSABLE',
- response_parameters: [
- {size: 31415}
- ],
- payload: {body: zeroBuffer(27182)}
- });
- call.on('data', function(data) {
- call.cancel();
- });
- call.on('error', function(error) {
- assert.strictEqual(error.code, grpc.status.CANCELLED);
- done();
- });
-}
-
-function timeoutOnSleepingServer(client, done) {
- var deadline = new Date();
- deadline.setMilliseconds(deadline.getMilliseconds() + 1);
- var call = client.fullDuplexCall({deadline: deadline});
- call.write({
- payload: {body: zeroBuffer(27182)}
- });
- call.on('data', function() {});
- call.on('error', function(error) {
-
- assert(error.code === grpc.status.DEADLINE_EXCEEDED ||
- error.code === grpc.status.INTERNAL);
- done();
- });
-}
-
-function customMetadata(client, done) {
- done = multiDone(done, 5);
- var metadata = new grpc.Metadata();
- metadata.set(ECHO_INITIAL_KEY, 'test_initial_metadata_value');
- metadata.set(ECHO_TRAILING_KEY, new Buffer('ababab', 'hex'));
- var arg = {
- response_type: 'COMPRESSABLE',
- response_size: 314159,
- payload: {
- body: zeroBuffer(271828)
- }
- };
- var streaming_arg = {
- response_parameters: [
- {size: 314159}
- ],
- payload: {
- body: zeroBuffer(271828)
- }
- };
- var unary = client.unaryCall(arg, metadata, function(err, resp) {
- assert.ifError(err);
- done();
- });
- unary.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get(ECHO_INITIAL_KEY),
- ['test_initial_metadata_value']);
- done();
- });
- unary.on('status', function(status) {
- var echo_trailer = status.metadata.get(ECHO_TRAILING_KEY);
- assert(echo_trailer.length > 0);
- assert.strictEqual(echo_trailer[0].toString('hex'), 'ababab');
- done();
- });
- var stream = client.fullDuplexCall(metadata);
- stream.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get(ECHO_INITIAL_KEY),
- ['test_initial_metadata_value']);
- done();
- });
- stream.on('data', function() {});
- stream.on('status', function(status) {
- var echo_trailer = status.metadata.get(ECHO_TRAILING_KEY);
- assert(echo_trailer.length > 0);
- assert.strictEqual(echo_trailer[0].toString('hex'), 'ababab');
- done();
- });
- stream.write(streaming_arg);
- stream.end();
-}
-
-function statusCodeAndMessage(client, done) {
- done = multiDone(done, 2);
- var arg = {
- response_status: {
- code: 2,
- message: 'test status message'
- }
- };
- client.unaryCall(arg, function(err, resp) {
- assert(err);
- assert.strictEqual(err.code, 2);
- assert.strictEqual(err.message, 'test status message');
- done();
- });
- var duplex = client.fullDuplexCall();
- duplex.on('data', function() {});
- duplex.on('status', function(status) {
- assert(status);
- assert.strictEqual(status.code, 2);
- assert.strictEqual(status.details, 'test status message');
- done();
- });
- duplex.on('error', function(){});
- duplex.write(arg);
- duplex.end();
-}
-
-// NOTE: the client param to this function is from UnimplementedService
-function unimplementedService(client, done) {
- client.unimplementedCall({}, function(err, resp) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.UNIMPLEMENTED);
- done();
- });
-}
-
-// NOTE: the client param to this function is from TestService
-function unimplementedMethod(client, done) {
- client.unimplementedCall({}, function(err, resp) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.UNIMPLEMENTED);
- done();
- });
-}
-
-/**
- * Run one of the authentication tests.
- * @param {string} expected_user The expected username in the response
- * @param {Client} client The client to test against
- * @param {?string} scope The scope to apply to the credentials
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- */
-function authTest(expected_user, scope, client, done) {
- var arg = {
- response_type: 'COMPRESSABLE',
- response_size: 314159,
- payload: {
- body: zeroBuffer(271828)
- },
- fill_username: true,
- fill_oauth_scope: true
- };
- client.unaryCall(arg, function(err, resp) {
- assert.ifError(err);
- assert.strictEqual(resp.payload.type, 'COMPRESSABLE');
- assert.strictEqual(resp.payload.body.length, 314159);
- assert.strictEqual(resp.username, expected_user);
- if (scope) {
- assert(scope.indexOf(resp.oauth_scope) > -1);
- }
- if (done) {
- done();
- }
- });
-}
-
-function computeEngineCreds(client, done, extra) {
- authTest(extra.service_account, null, client, done);
-}
-
-function serviceAccountCreds(client, done, extra) {
- authTest(SERVICE_ACCOUNT_EMAIL, extra.oauth_scope, client, done);
-}
-
-function jwtTokenCreds(client, done, extra) {
- authTest(SERVICE_ACCOUNT_EMAIL, null, client, done);
-}
-
-function oauth2Test(client, done, extra) {
- var arg = {
- fill_username: true,
- fill_oauth_scope: true
- };
- client.unaryCall(arg, function(err, resp) {
- assert.ifError(err);
- assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
- assert(extra.oauth_scope.indexOf(resp.oauth_scope) > -1);
- if (done) {
- done();
- }
- });
-}
-
-function perRpcAuthTest(client, done, extra) {
- (new GoogleAuth()).getApplicationDefault(function(err, credential) {
- assert.ifError(err);
- var arg = {
- fill_username: true,
- fill_oauth_scope: true
- };
- var scope = extra.oauth_scope;
- if (credential.createScopedRequired() && scope) {
- credential = credential.createScoped(scope);
- }
- var creds = grpc.credentials.createFromGoogleCredential(credential);
- client.unaryCall(arg, {credentials: creds}, function(err, resp) {
- assert.ifError(err);
- assert.strictEqual(resp.username, SERVICE_ACCOUNT_EMAIL);
- assert(extra.oauth_scope.indexOf(resp.oauth_scope) > -1);
- if (done) {
- done();
- }
- });
- });
-}
-
-function getApplicationCreds(scope, callback) {
- (new GoogleAuth()).getApplicationDefault(function(err, credential) {
- if (err) {
- callback(err);
- return;
- }
- if (credential.createScopedRequired() && scope) {
- credential = credential.createScoped(scope);
- }
- callback(null, grpc.credentials.createFromGoogleCredential(credential));
- });
-}
-
-function getOauth2Creds(scope, callback) {
- (new GoogleAuth()).getApplicationDefault(function(err, credential) {
- if (err) {
- callback(err);
- return;
- }
- credential = credential.createScoped(scope);
- credential.getAccessToken(function(err, token) {
- if (err) {
- callback(err);
- return;
- }
- var updateMd = function(service_url, callback) {
- var metadata = new grpc.Metadata();
- metadata.add('authorization', 'Bearer ' + token);
- callback(null, metadata);
- };
- callback(null, grpc.credentials.createFromMetadataGenerator(updateMd));
- });
- });
-}
-
-/**
- * Map from test case names to test functions
- */
-var test_cases = {
- empty_unary: {run: emptyUnary,
- Client: testProto.TestService},
- large_unary: {run: largeUnary,
- Client: testProto.TestService},
- client_streaming: {run: clientStreaming,
- Client: testProto.TestService},
- server_streaming: {run: serverStreaming,
- Client: testProto.TestService},
- ping_pong: {run: pingPong,
- Client: testProto.TestService},
- empty_stream: {run: emptyStream,
- Client: testProto.TestService},
- cancel_after_begin: {run: cancelAfterBegin,
- Client: testProto.TestService},
- cancel_after_first_response: {run: cancelAfterFirstResponse,
- Client: testProto.TestService},
- timeout_on_sleeping_server: {run: timeoutOnSleepingServer,
- Client: testProto.TestService},
- custom_metadata: {run: customMetadata,
- Client: testProto.TestService},
- status_code_and_message: {run: statusCodeAndMessage,
- Client: testProto.TestService},
- unimplemented_service: {run: unimplementedService,
- Client: testProto.UnimplementedService},
- unimplemented_method: {run: unimplementedMethod,
- Client: testProto.TestService},
- compute_engine_creds: {run: computeEngineCreds,
- Client: testProto.TestService,
- getCreds: getApplicationCreds},
- service_account_creds: {run: serviceAccountCreds,
- Client: testProto.TestService,
- getCreds: getApplicationCreds},
- jwt_token_creds: {run: jwtTokenCreds,
- Client: testProto.TestService,
- getCreds: getApplicationCreds},
- oauth2_auth_token: {run: oauth2Test,
- Client: testProto.TestService,
- getCreds: getOauth2Creds},
- per_rpc_creds: {run: perRpcAuthTest,
- Client: testProto.TestService}
-};
-
-exports.test_cases = test_cases;
-
-/**
- * Execute a single test case.
- * @param {string} address The address of the server to connect to, in the
- * format 'hostname:port'
- * @param {string} host_overrirde The hostname of the server to use as an SSL
- * override
- * @param {string} test_case The name of the test case to run
- * @param {bool} tls Indicates that a secure channel should be used
- * @param {function} done Callback to call when the test is completed. Included
- * primarily for use with mocha
- * @param {object=} extra Extra options for some tests
- */
-function runTest(address, host_override, test_case, tls, test_ca, done, extra) {
- // TODO(mlumish): enable TLS functionality
- var options = {};
- var creds;
- if (tls) {
- var ca_path;
- if (test_ca) {
- ca_path = path.join(__dirname, '../test/data/ca.pem');
- var ca_data = fs.readFileSync(ca_path);
- creds = grpc.credentials.createSsl(ca_data);
- } else {
- creds = grpc.credentials.createSsl();
- }
- if (host_override) {
- options['grpc.ssl_target_name_override'] = host_override;
- options['grpc.default_authority'] = host_override;
- }
- } else {
- creds = grpc.credentials.createInsecure();
- }
- var test = test_cases[test_case];
-
- var execute = function(err, creds) {
- assert.ifError(err);
- var client = new test.Client(address, creds, options);
- test.run(client, done, extra);
- };
-
- if (test.getCreds) {
- test.getCreds(extra.oauth_scope, function(err, new_creds) {
- assert.ifError(err);
- execute(err, grpc.credentials.combineChannelCredentials(
- creds, new_creds));
- });
- } else {
- execute(null, creds);
- }
-}
-
-if (require.main === module) {
- var parseArgs = require('minimist');
- var argv = parseArgs(process.argv, {
- string: ['server_host', 'server_host_override', 'server_port', 'test_case',
- 'use_tls', 'use_test_ca', 'default_service_account', 'oauth_scope',
- 'service_account_key_file']
- });
- var extra_args = {
- service_account: argv.default_service_account,
- oauth_scope: argv.oauth_scope
- };
- runTest(argv.server_host + ':' + argv.server_port, argv.server_host_override,
- argv.test_case, argv.use_tls === 'true', argv.use_test_ca === 'true',
- function () {
- console.log('OK:', argv.test_case);
- }, extra_args);
-}
-
-/**
- * See docs for runTest
- */
-exports.runTest = runTest;
diff --git a/src/node/interop/interop_server.js b/src/node/interop/interop_server.js
deleted file mode 100644
index c2028af4a1..0000000000
--- a/src/node/interop/interop_server.js
+++ /dev/null
@@ -1,241 +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.
- *
- */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-var _ = require('lodash');
-var AsyncDelayQueue = require('./async_delay_queue');
-var grpc = require('..');
-var testProto = grpc.load({
- root: __dirname + '/../../..',
- file: 'src/proto/grpc/testing/test.proto'}).grpc.testing;
-
-var ECHO_INITIAL_KEY = 'x-grpc-test-echo-initial';
-var ECHO_TRAILING_KEY = 'x-grpc-test-echo-trailing-bin';
-
-/**
- * Create a buffer filled with size zeroes
- * @param {number} size The length of the buffer
- * @return {Buffer} The new buffer
- */
-function zeroBuffer(size) {
- var zeros = new Buffer(size);
- zeros.fill(0);
- return zeros;
-}
-
-/**
- * Echos a header metadata item as specified in the interop spec.
- * @param {Call} call The call to echo metadata on
- */
-function echoHeader(call) {
- var echo_initial = call.metadata.get(ECHO_INITIAL_KEY);
- if (echo_initial.length > 0) {
- var response_metadata = new grpc.Metadata();
- response_metadata.set(ECHO_INITIAL_KEY, echo_initial[0]);
- call.sendMetadata(response_metadata);
- }
-}
-
-/**
- * Gets the trailer metadata that should be echoed when the call is done,
- * as specified in the interop spec.
- * @param {Call} call The call to get metadata from
- * @return {grpc.Metadata} The metadata to send as a trailer
- */
-function getEchoTrailer(call) {
- var echo_trailer = call.metadata.get(ECHO_TRAILING_KEY);
- var response_trailer = new grpc.Metadata();
- if (echo_trailer.length > 0) {
- response_trailer.set(ECHO_TRAILING_KEY, echo_trailer[0]);
- }
- return response_trailer;
-}
-
-function getPayload(payload_type, size) {
- var body = zeroBuffer(size);
- return {type: payload_type, body: body};
-}
-
-/**
- * Respond to an empty parameter with an empty response.
- * NOTE: this currently does not work due to issue #137
- * @param {Call} call Call to handle
- * @param {function(Error, Object)} callback Callback to call with result
- * or error
- */
-function handleEmpty(call, callback) {
- echoHeader(call);
- callback(null, {}, getEchoTrailer(call));
-}
-
-/**
- * Handle a unary request by sending the requested payload
- * @param {Call} call Call to handle
- * @param {function(Error, Object)} callback Callback to call with result or
- * error
- */
-function handleUnary(call, callback) {
- echoHeader(call);
- var req = call.request;
- if (req.response_status) {
- var status = req.response_status;
- status.metadata = getEchoTrailer(call);
- callback(status);
- return;
- }
- var payload = getPayload(req.response_type, req.response_size);
- callback(null, {payload: payload},
- getEchoTrailer(call));
-}
-
-/**
- * Respond to a streaming call with the total size of all payloads
- * @param {Call} call Call to handle
- * @param {function(Error, Object)} callback Callback to call with result or
- * error
- */
-function handleStreamingInput(call, callback) {
- echoHeader(call);
- var aggregate_size = 0;
- call.on('data', function(value) {
- aggregate_size += value.payload.body.length;
- });
- call.on('end', function() {
- callback(null, {aggregated_payload_size: aggregate_size},
- getEchoTrailer(call));
- });
-}
-
-/**
- * Respond to a payload request with a stream of the requested payloads
- * @param {Call} call Call to handle
- */
-function handleStreamingOutput(call) {
- echoHeader(call);
- var delay_queue = new AsyncDelayQueue();
- var req = call.request;
- if (req.response_status) {
- var status = req.response_status;
- status.metadata = getEchoTrailer(call);
- call.emit('error', status);
- return;
- }
- _.each(req.response_parameters, function(resp_param) {
- delay_queue.add(function(next) {
- call.write({payload: getPayload(req.response_type, resp_param.size)});
- next();
- }, resp_param.interval_us);
- });
- delay_queue.add(function(next) {
- call.end(getEchoTrailer(call));
- next();
- });
-}
-
-/**
- * Respond to a stream of payload requests with a stream of payload responses as
- * they arrive.
- * @param {Call} call Call to handle
- */
-function handleFullDuplex(call) {
- echoHeader(call);
- var delay_queue = new AsyncDelayQueue();
- call.on('data', function(value) {
- if (value.response_status) {
- var status = value.response_status;
- status.metadata = getEchoTrailer(call);
- call.emit('error', status);
- return;
- }
- _.each(value.response_parameters, function(resp_param) {
- delay_queue.add(function(next) {
- call.write({payload: getPayload(value.response_type, resp_param.size)});
- next();
- }, resp_param.interval_us);
- });
- });
- call.on('end', function() {
- delay_queue.add(function(next) {
- call.end(getEchoTrailer(call));
- next();
- });
- });
-}
-
-/**
- * Respond to a stream of payload requests with a stream of payload responses
- * after all requests have arrived
- * @param {Call} call Call to handle
- */
-function handleHalfDuplex(call) {
- call.emit('error', Error('HalfDuplexCall not yet implemented'));
-}
-
-/**
- * Get a server object bound to the given port
- * @param {string} port Port to which to bind
- * @param {boolean} tls Indicates that the bound port should use TLS
- * @return {{server: Server, port: number}} Server object bound to the support,
- * and port number that the server is bound to
- */
-function getServer(port, tls) {
- // TODO(mlumish): enable TLS functionality
- var options = {};
- var server_creds;
- if (tls) {
- var key_path = path.join(__dirname, '../test/data/server1.key');
- var pem_path = path.join(__dirname, '../test/data/server1.pem');
-
- var key_data = fs.readFileSync(key_path);
- var pem_data = fs.readFileSync(pem_path);
- server_creds = grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: pem_data}]);
- } else {
- server_creds = grpc.ServerCredentials.createInsecure();
- }
- var server = new grpc.Server(options);
- server.addService(testProto.TestService.service, {
- emptyCall: handleEmpty,
- unaryCall: handleUnary,
- streamingOutputCall: handleStreamingOutput,
- streamingInputCall: handleStreamingInput,
- fullDuplexCall: handleFullDuplex,
- halfDuplexCall: handleHalfDuplex
- });
- var port_num = server.bind('0.0.0.0:' + port, server_creds);
- return {server: server, port: port_num};
-}
-
-if (require.main === module) {
- var parseArgs = require('minimist');
- var argv = parseArgs(process.argv, {
- string: ['port', 'use_tls']
- });
- var server_obj = getServer(argv.port, argv.use_tls === 'true');
- console.log('Server attaching to port ' + argv.port);
- server_obj.server.start();
-}
-
-/**
- * See docs for getServer
- */
-exports.getServer = getServer;
diff --git a/src/node/jsdoc_conf.json b/src/node/jsdoc_conf.json
deleted file mode 100644
index 2d967753c1..0000000000
--- a/src/node/jsdoc_conf.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "tags": {
- "allowUnknownTags": true
- },
- "source": {
- "include": [ "src/node/index.js", "src/node/src" ],
- "includePattern": "src/node/.+\\.js(doc)?$",
- "excludePattern": "(^|\\/|\\\\)_"
- },
- "opts": {
- "package": "package.json",
- "readme": "src/node/README.md"
- },
- "plugins": ["plugins/markdown"],
- "templates": {
- "cleverLinks": false,
- "monospaceLinks": false,
- "default": {
- "outputSourceFiles": true
- }
- }
-}
diff --git a/src/node/performance/benchmark_client.js b/src/node/performance/benchmark_client.js
deleted file mode 100644
index 68afb8a633..0000000000
--- a/src/node/performance/benchmark_client.js
+++ /dev/null
@@ -1,365 +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.
- *
- */
-
-/**
- * Benchmark client module
- * @module
- */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-var util = require('util');
-var EventEmitter = require('events');
-
-var async = require('async');
-var _ = require('lodash');
-var PoissonProcess = require('poisson-process');
-var Histogram = require('./histogram');
-
-var genericService = require('./generic_service');
-
-var grpc = require('../../../');
-var serviceProto = grpc.load({
- root: __dirname + '/../../..',
- file: 'src/proto/grpc/testing/services.proto'}).grpc.testing;
-
-/**
- * Create a buffer filled with size zeroes
- * @param {number} size The length of the buffer
- * @return {Buffer} The new buffer
- */
-function zeroBuffer(size) {
- var zeros = new Buffer(size);
- zeros.fill(0);
- return zeros;
-}
-
-/**
- * Convert a time difference, as returned by process.hrtime, to a number of
- * nanoseconds.
- * @param {Array.<number>} time_diff The time diff, represented as
- * [seconds, nanoseconds]
- * @return {number} The total number of nanoseconds
- */
-function timeDiffToNanos(time_diff) {
- return time_diff[0] * 1e9 + time_diff[1];
-}
-
-/**
- * The BenchmarkClient class. Opens channels to servers and makes RPCs based on
- * parameters from the driver, and records statistics about those RPCs.
- * @param {Array.<string>} server_targets List of servers to connect to
- * @param {number} channels The total number of channels to open
- * @param {Object} histogram_params Options for setting up the histogram
- * @param {Object=} security_params Options for TLS setup. If absent, don't use
- * TLS
- */
-function BenchmarkClient(server_targets, channels, histogram_params,
- security_params) {
- var options = {
- "grpc.max_receive_message_length": -1,
- "grpc.max_send_message_length": -1
- };
- var creds;
- if (security_params) {
- var ca_path;
- if (security_params.use_test_ca) {
- ca_path = path.join(__dirname, '../test/data/ca.pem');
- var ca_data = fs.readFileSync(ca_path);
- creds = grpc.credentials.createSsl(ca_data);
- } else {
- creds = grpc.credentials.createSsl();
- }
- if (security_params.server_host_override) {
- var host_override = security_params.server_host_override;
- options['grpc.ssl_target_name_override'] = host_override;
- options['grpc.default_authority'] = host_override;
- }
- } else {
- creds = grpc.credentials.createInsecure();
- }
-
- this.clients = [];
- var GenericClient = grpc.makeGenericClientConstructor(genericService);
- this.genericClients = [];
-
- for (var i = 0; i < channels; i++) {
- this.clients[i] = new serviceProto.BenchmarkService(
- server_targets[i % server_targets.length], creds, options);
- this.genericClients[i] = new GenericClient(
- server_targets[i % server_targets.length], creds, options);
- }
-
- this.histogram = new Histogram(histogram_params.resolution,
- histogram_params.max_possible);
-
- this.running = false;
-
- this.pending_calls = 0;
-};
-
-util.inherits(BenchmarkClient, EventEmitter);
-
-/**
- * Start every client in the list of clients by waiting for each to be ready,
- * then starting outstanding_rpcs_per_channel calls on each of them
- * @param {Array<grpc.Client>} client_list The list of clients
- * @param {Number} outstanding_rpcs_per_channel The number of calls to start
- * on each client
- * @param {function(grpc.Client)} makeCall Function to make a single call on
- * a single client
- * @param {EventEmitter} emitter The event emitter to send errors on, if
- * necessary
- */
-function startAllClients(client_list, outstanding_rpcs_per_channel, makeCall,
- emitter) {
- var ready_wait_funcs = _.map(client_list, function(client) {
- return _.partial(grpc.waitForClientReady, client, Infinity);
- });
- async.parallel(ready_wait_funcs, function(err) {
- if (err) {
- emitter.emit('error', err);
- return;
- }
-
- _.each(client_list, function(client) {
- _.times(outstanding_rpcs_per_channel, function() {
- makeCall(client);
- });
- });
- });
-}
-
-/**
- * Start a closed-loop test. For each channel, start
- * outstanding_rpcs_per_channel RPCs. Then, whenever an RPC finishes, start
- * another one.
- * @param {number} outstanding_rpcs_per_channel Number of RPCs to start per
- * channel
- * @param {string} rpc_type Which method to call. Should be 'UNARY' or
- * 'STREAMING'
- * @param {number} req_size The size of the payload to send with each request
- * @param {number} resp_size The size of payload to request be sent in responses
- * @param {boolean} generic Indicates that the generic (non-proto) clients
- * should be used
- */
-BenchmarkClient.prototype.startClosedLoop = function(
- outstanding_rpcs_per_channel, rpc_type, req_size, resp_size, generic) {
- var self = this;
-
- self.running = true;
-
- self.last_wall_time = process.hrtime();
-
- self.last_usage = process.cpuUsage();
-
- var makeCall;
-
- var argument;
- var client_list;
- if (generic) {
- argument = zeroBuffer(req_size);
- client_list = self.genericClients;
- } else {
- argument = {
- response_size: resp_size,
- payload: {
- body: zeroBuffer(req_size)
- }
- };
- client_list = self.clients;
- }
-
- if (rpc_type == 'UNARY') {
- makeCall = function(client) {
- if (self.running) {
- self.pending_calls++;
- var start_time = process.hrtime();
- client.unaryCall(argument, function(error, response) {
- if (error) {
- self.emit('error', new Error('Client error: ' + error.message));
- self.running = false;
- return;
- }
- var time_diff = process.hrtime(start_time);
- self.histogram.add(timeDiffToNanos(time_diff));
- makeCall(client);
- self.pending_calls--;
- if ((!self.running) && self.pending_calls == 0) {
- self.emit('finished');
- }
- });
- }
- };
- } else {
- makeCall = function(client) {
- if (self.running) {
- self.pending_calls++;
- var call = client.streamingCall();
- var start_time = process.hrtime();
- call.write(argument);
- call.on('data', function() {
- var time_diff = process.hrtime(start_time);
- self.histogram.add(timeDiffToNanos(time_diff));
- self.pending_calls--;
- if (self.running) {
- self.pending_calls++;
- start_time = process.hrtime();
- call.write(argument);
- } else {
- call.end();
- if (self.pending_calls == 0) {
- self.emit('finished');
- }
- }
- });
- call.on('error', function(error) {
- self.emit('error', new Error('Client error: ' + error.message));
- self.running = false;
- });
- }
- };
- }
-
- startAllClients(client_list, outstanding_rpcs_per_channel, makeCall, self);
-};
-
-/**
- * Start a poisson test. For each channel, this initiates a number of Poisson
- * processes equal to outstanding_rpcs_per_channel, where each Poisson process
- * has the load parameter offered_load.
- * @param {number} outstanding_rpcs_per_channel Number of RPCs to start per
- * channel
- * @param {string} rpc_type Which method to call. Should be 'UNARY' or
- * 'STREAMING'
- * @param {number} req_size The size of the payload to send with each request
- * @param {number} resp_size The size of payload to request be sent in responses
- * @param {number} offered_load The load parameter for the Poisson process
- * @param {boolean} generic Indicates that the generic (non-proto) clients
- * should be used
- */
-BenchmarkClient.prototype.startPoisson = function(
- outstanding_rpcs_per_channel, rpc_type, req_size, resp_size, offered_load,
- generic) {
- var self = this;
-
- self.running = true;
-
- self.last_wall_time = process.hrtime();
-
- self.last_usage = process.cpuUsage();
-
- var makeCall;
-
- var argument;
- var client_list;
- if (generic) {
- argument = zeroBuffer(req_size);
- client_list = self.genericClients;
- } else {
- argument = {
- response_size: resp_size,
- payload: {
- body: zeroBuffer(req_size)
- }
- };
- client_list = self.clients;
- }
-
- if (rpc_type == 'UNARY') {
- makeCall = function(client, poisson) {
- if (self.running) {
- self.pending_calls++;
- var start_time = process.hrtime();
- client.unaryCall(argument, function(error, response) {
- if (error) {
- self.emit('error', new Error('Client error: ' + error.message));
- self.running = false;
- return;
- }
- var time_diff = process.hrtime(start_time);
- self.histogram.add(timeDiffToNanos(time_diff));
- self.pending_calls--;
- if ((!self.running) && self.pending_calls == 0) {
- self.emit('finished');
- }
- });
- } else {
- poisson.stop();
- }
- };
- } else {
- self.emit('error', new Error('Streaming Poisson benchmarks not supported'));
- return;
- }
-
- var averageIntervalMs = (1 / offered_load) * 1000;
-
- startAllClients(client_list, outstanding_rpcs_per_channel, function(client){
- var p = PoissonProcess.create(averageIntervalMs, function() {
- makeCall(client, p);
- });
- p.start();
- }, self);
-};
-
-/**
- * Return curent statistics for the client. If reset is set, restart
- * statistic collection.
- * @param {boolean} reset Indicates that statistics should be reset
- * @return {object} Client statistics
- */
-BenchmarkClient.prototype.mark = function(reset) {
- var wall_time_diff = process.hrtime(this.last_wall_time);
- var usage_diff = process.cpuUsage(this.last_usage);
- var histogram = this.histogram;
- if (reset) {
- this.last_wall_time = process.hrtime();
- this.last_usage = process.cpuUsage();
- this.histogram = new Histogram(histogram.resolution,
- histogram.max_possible);
- }
-
- return {
- latencies: {
- bucket: histogram.getContents(),
- min_seen: histogram.minimum(),
- max_seen: histogram.maximum(),
- sum: histogram.getSum(),
- sum_of_squares: histogram.sumOfSquares(),
- count: histogram.getCount()
- },
- time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- time_user: usage_diff.user / 1000000,
- time_system: usage_diff.system / 1000000
- };
-};
-
-/**
- * Stop the clients.
- * @param {function} callback Called when the clients have finished shutting
- * down
- */
-BenchmarkClient.prototype.stop = function(callback) {
- this.running = false;
- this.on('finished', callback);
-};
-
-module.exports = BenchmarkClient;
diff --git a/src/node/performance/benchmark_client_express.js b/src/node/performance/benchmark_client_express.js
deleted file mode 100644
index 815843fede..0000000000
--- a/src/node/performance/benchmark_client_express.js
+++ /dev/null
@@ -1,287 +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.
- *
- */
-
-/**
- * Benchmark client module
- * @module
- */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-var util = require('util');
-var EventEmitter = require('events');
-var http = require('http');
-var https = require('https');
-
-var async = require('async');
-var _ = require('lodash');
-var PoissonProcess = require('poisson-process');
-var Histogram = require('./histogram');
-
-/**
- * Convert a time difference, as returned by process.hrtime, to a number of
- * nanoseconds.
- * @param {Array.<number>} time_diff The time diff, represented as
- * [seconds, nanoseconds]
- * @return {number} The total number of nanoseconds
- */
-function timeDiffToNanos(time_diff) {
- return time_diff[0] * 1e9 + time_diff[1];
-}
-
-function BenchmarkClient(server_targets, channels, histogram_params,
- security_params) {
- var options = {
- method: 'PUT',
- headers: {
- 'Content-Type': 'application/json'
- }
- };
- var protocol;
- if (security_params) {
- var ca_path;
- protocol = https;
- this.request = _.bind(https.request, https);
- if (security_params.use_test_ca) {
- ca_path = path.join(__dirname, '../test/data/ca.pem');
- var ca_data = fs.readFileSync(ca_path);
- options.ca = ca_data;
- }
- if (security_params.server_host_override) {
- var host_override = security_params.server_host_override;
- options.servername = host_override;
- }
- } else {
- protocol = http;
- }
-
- this.request = _.bind(protocol.request, protocol);
-
- this.client_options = [];
-
- for (var i = 0; i < channels; i++) {
- var host_port;
- host_port = server_targets[i % server_targets.length].split(':');
- var new_options = _.assign({hostname: host_port[0], port: +host_port[1]}, options);
- this.client_options[i] = new_options;
- }
-
- this.histogram = new Histogram(histogram_params.resolution,
- histogram_params.max_possible);
-
- this.running = false;
-
- this.pending_calls = 0;
-}
-
-util.inherits(BenchmarkClient, EventEmitter);
-
-function startAllClients(client_options_list, outstanding_rpcs_per_channel,
- makeCall, emitter) {
- _.each(client_options_list, function(client_options) {
- _.times(outstanding_rpcs_per_channel, function() {
- makeCall(client_options);
- });
- });
-}
-
-BenchmarkClient.prototype.startClosedLoop = function(
- outstanding_rpcs_per_channel, rpc_type, req_size, resp_size, generic) {
- var self = this;
-
- var options = {};
-
- self.running = true;
-
- if (rpc_type == 'UNARY') {
- options.path = '/serviceProto.BenchmarkService.service/unaryCall';
- } else {
- self.emit('error', new Error('Unsupported rpc_type: ' + rpc_type));
- }
-
- if (generic) {
- self.emit('error', new Error('Generic client not supported'));
- }
-
- self.last_wall_time = process.hrtime();
- self.last_usage = process.cpuUsage();
-
- var argument = {
- response_size: resp_size,
- payload: {
- body: '0'.repeat(req_size)
- }
- };
-
- function makeCall(client_options) {
- if (self.running) {
- self.pending_calls++;
- var start_time = process.hrtime();
- function finishCall(success) {
- if (success) {
- var time_diff = process.hrtime(start_time);
- self.histogram.add(timeDiffToNanos(time_diff));
- }
- makeCall(client_options);
- self.pending_calls--;
- if ((!self.running) && self.pending_calls == 0) {
- self.emit('finished');
- }
- }
- var req = self.request(client_options, function(res) {
- var res_data = '';
- res.on('data', function(data) {
- res_data += data;
- });
- res.on('end', function() {
- JSON.parse(res_data);
- finishCall(true);
- });
- });
- req.write(JSON.stringify(argument));
- req.end();
- req.on('error', function(error) {
- if (error.code === 'ECONNRESET' || error.code === 'ETIMEDOUT') {
- finishCall(false);
- return;
- }
- self.emit('error', new Error('Client error: ' + error.message));
- self.running = false;
- });
- }
- }
-
- startAllClients(_.map(self.client_options, _.partial(_.assign, options)),
- outstanding_rpcs_per_channel, makeCall, self);
-};
-
-BenchmarkClient.prototype.startPoisson = function(
- outstanding_rpcs_per_channel, rpc_type, req_size, resp_size, offered_load,
- generic) {
- var self = this;
-
- var options = {};
-
- self.running = true;
-
- if (rpc_type == 'UNARY') {
- options.path = '/serviceProto.BenchmarkService.service/unaryCall';
- } else {
- self.emit('error', new Error('Unsupported rpc_type: ' + rpc_type));
- }
-
- if (generic) {
- self.emit('error', new Error('Generic client not supported'));
- }
-
- self.last_wall_time = process.hrtime();
- self.last_usage = process.cpuUsage();
-
- var argument = {
- response_size: resp_size,
- payload: {
- body: '0'.repeat(req_size)
- }
- };
-
- function makeCall(client_options, poisson) {
- if (self.running) {
- self.pending_calls++;
- var start_time = process.hrtime();
- var req = self.request(client_options, function(res) {
- var res_data = '';
- res.on('data', function(data) {
- res_data += data;
- });
- res.on('end', function() {
- JSON.parse(res_data);
- var time_diff = process.hrtime(start_time);
- self.histogram.add(timeDiffToNanos(time_diff));
- self.pending_calls--;
- if ((!self.running) && self.pending_calls == 0) {
- self.emit('finished');
- }
- });
- });
- req.write(JSON.stringify(argument));
- req.end();
- req.on('error', function(error) {
- self.emit('error', new Error('Client error: ' + error.message));
- self.running = false;
- });
- } else {
- poisson.stop();
- }
- }
-
- var averageIntervalMs = (1 / offered_load) * 1000;
-
- startAllClients(_.map(self.client_options, _.partial(_.assign, options)),
- outstanding_rpcs_per_channel, function(opts){
- var p = PoissonProcess.create(averageIntervalMs, function() {
- makeCall(opts, p);
- });
- p.start();
- }, self);
-};
-
-/**
- * Return curent statistics for the client. If reset is set, restart
- * statistic collection.
- * @param {boolean} reset Indicates that statistics should be reset
- * @return {object} Client statistics
- */
-BenchmarkClient.prototype.mark = function(reset) {
- var wall_time_diff = process.hrtime(this.last_wall_time);
- var usage_diff = process.cpuUsage(this.last_usage);
- var histogram = this.histogram;
- if (reset) {
- this.last_wall_time = process.hrtime();
- this.last_usage = process.cpuUsage();
- this.histogram = new Histogram(histogram.resolution,
- histogram.max_possible);
- }
-
- return {
- latencies: {
- bucket: histogram.getContents(),
- min_seen: histogram.minimum(),
- max_seen: histogram.maximum(),
- sum: histogram.getSum(),
- sum_of_squares: histogram.sumOfSquares(),
- count: histogram.getCount()
- },
- time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- time_user: usage_diff.user / 1000000,
- time_system: usage_diff.system / 1000000
- };
-};
-
-/**
- * Stop the clients.
- * @param {function} callback Called when the clients have finished shutting
- * down
- */
-BenchmarkClient.prototype.stop = function(callback) {
- this.running = false;
- this.on('finished', callback);
-};
-
-module.exports = BenchmarkClient;
diff --git a/src/node/performance/benchmark_server.js b/src/node/performance/benchmark_server.js
deleted file mode 100644
index 8d3a2b9049..0000000000
--- a/src/node/performance/benchmark_server.js
+++ /dev/null
@@ -1,189 +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.
- *
- */
-
-/**
- * Benchmark server module
- * @module
- */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-var EventEmitter = require('events');
-var util = require('util');
-
-var genericService = require('./generic_service');
-
-var grpc = require('../../../');
-var serviceProto = grpc.load({
- root: __dirname + '/../../..',
- file: 'src/proto/grpc/testing/services.proto'}).grpc.testing;
-
-/**
- * Create a buffer filled with size zeroes
- * @param {number} size The length of the buffer
- * @return {Buffer} The new buffer
- */
-function zeroBuffer(size) {
- var zeros = new Buffer(size);
- zeros.fill(0);
- return zeros;
-}
-
-/**
- * Handler for the unary benchmark method. Simply responds with a payload
- * containing the requested number of zero bytes.
- * @param {Call} call The call object to be handled
- * @param {function} callback The callback to call with the response
- */
-function unaryCall(call, callback) {
- var req = call.request;
- var payload = {body: zeroBuffer(req.response_size)};
- callback(null, {payload: payload});
-}
-
-/**
- * Handler for the streaming benchmark method. Simply responds to each request
- * with a payload containing the requested number of zero bytes.
- * @param {Call} call The call object to be handled
- */
-function streamingCall(call) {
- call.on('data', function(value) {
- var payload = {body: zeroBuffer(value.response_size)};
- call.write({payload: payload});
- });
- call.on('end', function() {
- call.end();
- });
-}
-
-function makeUnaryGenericCall(response_size) {
- var response = zeroBuffer(response_size);
- return function unaryGenericCall(call, callback) {
- callback(null, response);
- };
-}
-
-function makeStreamingGenericCall(response_size) {
- var response = zeroBuffer(response_size);
- return function streamingGenericCall(call) {
- call.on('data', function(value) {
- call.write(response);
- });
- call.on('end', function() {
- call.end();
- });
- };
-}
-
-/**
- * BenchmarkServer class. Constructed based on parameters from the driver and
- * stores statistics.
- * @param {string} host The host to serve on
- * @param {number} port The port to listen to
- * @param {boolean} tls Indicates whether TLS should be used
- * @param {boolean} generic Indicates whether to use the generic service
- * @param {number=} response_size The response size for the generic service
- */
-function BenchmarkServer(host, port, tls, generic, response_size) {
- var server_creds;
- var host_override;
- if (tls) {
- var key_path = path.join(__dirname, '../test/data/server1.key');
- var pem_path = path.join(__dirname, '../test/data/server1.pem');
-
- var key_data = fs.readFileSync(key_path);
- var pem_data = fs.readFileSync(pem_path);
- server_creds = grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: pem_data}]);
- } else {
- server_creds = grpc.ServerCredentials.createInsecure();
- }
-
- var options = {
- "grpc.max_receive_message_length": -1,
- "grpc.max_send_message_length": -1
- };
-
- var server = new grpc.Server(options);
- this.port = server.bind(host + ':' + port, server_creds);
- if (generic) {
- server.addService(genericService, {
- unaryCall: makeUnaryGenericCall(response_size),
- streamingCall: makeStreamingGenericCall(response_size)
- });
- } else {
- server.addService(serviceProto.BenchmarkService.service, {
- unaryCall: unaryCall,
- streamingCall: streamingCall
- });
- }
- this.server = server;
-}
-
-util.inherits(BenchmarkServer, EventEmitter);
-
-/**
- * Start the benchmark server.
- */
-BenchmarkServer.prototype.start = function() {
- this.server.start();
- this.last_wall_time = process.hrtime();
- this.last_usage = process.cpuUsage();
- this.emit('started');
-};
-
-/**
- * Return the port number that the server is bound to.
- * @return {Number} The port number
- */
-BenchmarkServer.prototype.getPort = function() {
- return this.port;
-};
-
-/**
- * Return current statistics for the server. If reset is set, restart
- * statistic collection.
- * @param {boolean} reset Indicates that statistics should be reset
- * @return {object} Server statistics
- */
-BenchmarkServer.prototype.mark = function(reset) {
- var wall_time_diff = process.hrtime(this.last_wall_time);
- var usage_diff = process.cpuUsage(this.last_usage);
- if (reset) {
- this.last_wall_time = process.hrtime();
- this.last_usage = process.cpuUsage();
- }
- return {
- time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- time_user: usage_diff.user / 1000000,
- time_system: usage_diff.system / 1000000
- };
-};
-
-/**
- * Stop the server.
- * @param {function} callback Called when the server has finished shutting down
- */
-BenchmarkServer.prototype.stop = function(callback) {
- this.server.tryShutdown(callback);
-};
-
-module.exports = BenchmarkServer;
diff --git a/src/node/performance/benchmark_server_express.js b/src/node/performance/benchmark_server_express.js
deleted file mode 100644
index 73e54091a4..0000000000
--- a/src/node/performance/benchmark_server_express.js
+++ /dev/null
@@ -1,96 +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.
- *
- */
-
-/**
- * Benchmark server module
- * @module
- */
-
-'use strict';
-
-var fs = require('fs');
-var path = require('path');
-var http = require('http');
-var https = require('https');
-var EventEmitter = require('events');
-var util = require('util');
-
-var express = require('express');
-var bodyParser = require('body-parser');
-
-function unaryCall(req, res) {
- var reqObj = req.body;
- var payload = {body: '0'.repeat(reqObj.response_size)};
- res.json(payload);
-}
-
-function BenchmarkServer(host, port, tls, generic, response_size) {
- var app = express();
- app.use(bodyParser.json());
- app.put('/serviceProto.BenchmarkService.service/unaryCall', unaryCall);
- this.input_host = host;
- this.input_port = port;
- if (tls) {
- var credentials = {};
- var key_path = path.join(__dirname, '../test/data/server1.key');
- var pem_path = path.join(__dirname, '../test/data/server1.pem');
-
- var key_data = fs.readFileSync(key_path);
- var pem_data = fs.readFileSync(pem_path);
- credentials['key'] = key_data;
- credentials['cert'] = pem_data;
- this.server = https.createServer(credentials, app);
- } else {
- this.server = http.createServer(app);
- }
-}
-
-util.inherits(BenchmarkServer, EventEmitter);
-
-BenchmarkServer.prototype.start = function() {
- var self = this;
- this.server.listen(this.input_port, this.input_hostname, function() {
- self.last_wall_time = process.hrtime();
- self.last_usage = process.cpuUsage();
- self.emit('started');
- });
-};
-
-BenchmarkServer.prototype.getPort = function() {
- return this.server.address().port;
-};
-
-BenchmarkServer.prototype.mark = function(reset) {
- var wall_time_diff = process.hrtime(this.last_wall_time);
- var usage_diff = process.cpuUsage(this.last_usage);
- if (reset) {
- this.last_wall_time = process.hrtime();
- this.last_usage = process.cpuUsage();
- }
- return {
- time_elapsed: wall_time_diff[0] + wall_time_diff[1] / 1e9,
- time_user: usage_diff.user / 1000000,
- time_system: usage_diff.system / 1000000
- };
-};
-
-BenchmarkServer.prototype.stop = function(callback) {
- this.server.close(callback);
-};
-
-module.exports = BenchmarkServer;
diff --git a/src/node/performance/generic_service.js b/src/node/performance/generic_service.js
deleted file mode 100644
index 8e76c50d58..0000000000
--- a/src/node/performance/generic_service.js
+++ /dev/null
@@ -1,40 +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.
- *
- */
-
-var _ = require('lodash');
-
-module.exports = {
- 'unaryCall' : {
- path: '/grpc.testing.BenchmarkService/UnaryCall',
- requestStream: false,
- responseStream: false,
- requestSerialize: _.identity,
- requestDeserialize: _.identity,
- responseSerialize: _.identity,
- responseDeserialize: _.identity
- },
- 'streamingCall' : {
- path: '/grpc.testing.BenchmarkService/StreamingCall',
- requestStream: true,
- responseStream: true,
- requestSerialize: _.identity,
- requestDeserialize: _.identity,
- responseSerialize: _.identity,
- responseDeserialize: _.identity
- }
-};
diff --git a/src/node/performance/histogram.js b/src/node/performance/histogram.js
deleted file mode 100644
index a03f2c13a2..0000000000
--- a/src/node/performance/histogram.js
+++ /dev/null
@@ -1,165 +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.
- *
- */
-
-/**
- * Histogram module. Exports the Histogram class
- * @module
- */
-
-'use strict';
-
-/**
- * Histogram class. Collects data and exposes a histogram and other statistics.
- * This data structure is taken directly from src/core/support/histogram.c, but
- * pared down to the statistics needed for client stats in
- * test/proto/benchmarks/stats.proto.
- * @constructor
- * @param {number} resolution The histogram's bucket resolution. Must be positive
- * @param {number} max_possible The maximum allowed value. Must be greater than 1
- */
-function Histogram(resolution, max_possible) {
- this.resolution = resolution;
- this.max_possible = max_possible;
-
- this.sum = 0;
- this.sum_of_squares = 0;
- this.multiplier = 1 + resolution;
- this.count = 0;
- this.min_seen = max_possible;
- this.max_seen = 0;
- this.buckets = [];
- for (var i = 0; i < this.bucketFor(max_possible) + 1; i++) {
- this.buckets[i] = 0;
- }
-}
-
-/**
- * Get the bucket index for a given value.
- * @param {number} value The value to check
- * @return {number} The bucket index
- */
-Histogram.prototype.bucketFor = function(value) {
- return Math.floor(Math.log(value) / Math.log(this.multiplier));
-};
-
-/**
- * Get the minimum value for a given bucket index
- * @param {number} The bucket index to check
- * @return {number} The minimum value for that bucket
- */
-Histogram.prototype.bucketStart = function(index) {
- return Math.pow(this.multiplier, index);
-};
-
-/**
- * Add a value to the histogram. This updates all statistics with the new
- * value. Those statistics should not be modified except with this function
- * @param {number} value The value to add
- */
-Histogram.prototype.add = function(value) {
- // Ensure value is a number
- value = +value;
- this.sum += value;
- this.sum_of_squares += value * value;
- this.count++;
- if (value < this.min_seen) {
- this.min_seen = value;
- }
- if (value > this.max_seen) {
- this.max_seen = value;
- }
- this.buckets[this.bucketFor(value)]++;
-};
-
-/**
- * Get the mean of all added values
- * @return {number} The mean
- */
-Histogram.prototype.mean = function() {
- return this.sum / this.count;
-};
-
-/**
- * Get the variance of all added values. Used to calulate the standard deviation
- * @return {number} The variance
- */
-Histogram.prototype.variance = function() {
- if (this.count == 0) {
- return 0;
- }
- return (this.sum_of_squares * this.count - this.sum * this.sum) /
- (this.count * this.count);
-};
-
-/**
- * Get the standard deviation of all added values
- * @return {number} The standard deviation
- */
-Histogram.prototype.stddev = function() {
- return Math.sqrt(this.variance);
-};
-
-/**
- * Get the maximum among all added values
- * @return {number} The maximum
- */
-Histogram.prototype.maximum = function() {
- return this.max_seen;
-};
-
-/**
- * Get the minimum among all added values
- * @return {number} The minimum
- */
-Histogram.prototype.minimum = function() {
- return this.min_seen;
-};
-
-/**
- * Get the number of all added values
- * @return {number} The count
- */
-Histogram.prototype.getCount = function() {
- return this.count;
-};
-
-/**
- * Get the sum of all added values
- * @return {number} The sum
- */
-Histogram.prototype.getSum = function() {
- return this.sum;
-};
-
-/**
- * Get the sum of squares of all added values
- * @return {number} The sum of squares
- */
-Histogram.prototype.sumOfSquares = function() {
- return this.sum_of_squares;
-};
-
-/**
- * Get the raw histogram as a list of bucket sizes
- * @return {Array.<number>} The buckets
- */
-Histogram.prototype.getContents = function() {
- return this.buckets;
-};
-
-module.exports = Histogram;
diff --git a/src/node/performance/worker.js b/src/node/performance/worker.js
deleted file mode 100644
index d0fb3bcb28..0000000000
--- a/src/node/performance/worker.js
+++ /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.
- *
- */
-
-'use strict';
-
-var console = require('console');
-var WorkerServiceImpl = require('./worker_service_impl');
-
-var grpc = require('../../../');
-var serviceProto = grpc.load({
- root: __dirname + '/../../..',
- file: 'src/proto/grpc/testing/services.proto'}).grpc.testing;
-
-function runServer(port, benchmark_impl) {
- var server_creds = grpc.ServerCredentials.createInsecure();
- var server = new grpc.Server();
- server.addService(serviceProto.WorkerService.service,
- new WorkerServiceImpl(benchmark_impl, server));
- var address = '0.0.0.0:' + port;
- server.bind(address, server_creds);
- server.start();
- console.log('running QPS worker on %s', address);
- return server;
-}
-
-if (require.main === module) {
- Error.stackTraceLimit = Infinity;
- var parseArgs = require('minimist');
- var argv = parseArgs(process.argv, {
- string: ['driver_port', 'benchmark_impl']
- });
- runServer(argv.driver_port, argv.benchmark_impl);
-}
-
-exports.runServer = runServer;
diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js
deleted file mode 100644
index a73d77efc3..0000000000
--- a/src/node/performance/worker_service_impl.js
+++ /dev/null
@@ -1,183 +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.
- *
- */
-
-'use strict';
-
-var os = require('os');
-var console = require('console');
-var BenchmarkClient = require('./benchmark_client');
-var BenchmarkServer = require('./benchmark_server');
-
-module.exports = function WorkerServiceImpl(benchmark_impl, server) {
- var BenchmarkClient;
- var BenchmarkServer;
- switch (benchmark_impl) {
- case 'grpc':
- BenchmarkClient = require('./benchmark_client');
- BenchmarkServer = require('./benchmark_server');
- break;
- case 'express':
- BenchmarkClient = require('./benchmark_client_express');
- BenchmarkServer = require('./benchmark_server_express');
- break;
- default:
- throw new Error('Unrecognized benchmark impl: ' + benchmark_impl);
- }
-
- this.quitWorker = function quitWorker(call, callback) {
- callback(null, {});
- server.tryShutdown(function() {});
- };
-
- this.runClient = function runClient(call) {
- var client;
- call.on('data', function(request) {
- var stats;
- switch (request.argtype) {
- case 'setup':
- var setup = request.setup;
- console.log('ClientConfig %j', setup);
- client = new BenchmarkClient(setup.server_targets,
- setup.client_channels,
- setup.histogram_params,
- setup.security_params);
- client.on('error', function(error) {
- call.emit('error', error);
- });
- var req_size, resp_size, generic;
- switch (setup.payload_config.payload) {
- case 'bytebuf_params':
- req_size = setup.payload_config.bytebuf_params.req_size;
- resp_size = setup.payload_config.bytebuf_params.resp_size;
- generic = true;
- break;
- case 'simple_params':
- req_size = setup.payload_config.simple_params.req_size;
- resp_size = setup.payload_config.simple_params.resp_size;
- generic = false;
- break;
- default:
- call.emit('error', new Error('Unsupported PayloadConfig type' +
- setup.payload_config.payload));
- return;
- }
- switch (setup.load_params.load) {
- case 'closed_loop':
- client.startClosedLoop(setup.outstanding_rpcs_per_channel,
- setup.rpc_type, req_size, resp_size, generic);
- break;
- case 'poisson':
- client.startPoisson(setup.outstanding_rpcs_per_channel,
- setup.rpc_type, req_size, resp_size,
- setup.load_params.poisson.offered_load, generic);
- break;
- default:
- call.emit('error', new Error('Unsupported LoadParams type' +
- setup.load_params.load));
- return;
- }
- stats = client.mark();
- call.write({
- stats: stats
- });
- break;
- case 'mark':
- if (client) {
- stats = client.mark(request.mark.reset);
- call.write({
- stats: stats
- });
- } else {
- call.emit('error', new Error('Got Mark before ClientConfig'));
- }
- break;
- default:
- throw new Error('Nonexistent client argtype option: ' + request.argtype);
- }
- });
- call.on('end', function() {
- client.stop(function() {
- call.end();
- });
- });
- };
-
- this.runServer = function runServer(call) {
- var server;
- call.on('data', function(request) {
- var stats;
- switch (request.argtype) {
- case 'setup':
- console.log('ServerConfig %j', request.setup);
- var setup = request.setup;
- var resp_size, generic;
- if (setup.payload_config) {
- switch (setup.payload_config.payload) {
- case 'bytebuf_params':
- resp_size = setup.payload_config.bytebuf_params.resp_size;
- generic = true;
- break;
- case 'simple_params':
- resp_size = setup.payload_config.simple_params.resp_size;
- generic = false;
- break;
- default:
- call.emit('error', new Error('Unsupported PayloadConfig type' +
- setup.payload_config.payload));
- return;
- }
- }
- server = new BenchmarkServer('[::]', request.setup.port,
- request.setup.security_params,
- generic, resp_size);
- server.on('started', function() {
- stats = server.mark();
- call.write({
- stats: stats,
- port: server.getPort()
- });
- });
- server.start();
- break;
- case 'mark':
- if (server) {
- stats = server.mark(request.mark.reset);
- call.write({
- stats: stats,
- port: server.getPort(),
- cores: 1
- });
- } else {
- call.emit('error', new Error('Got Mark before ServerConfig'));
- }
- break;
- default:
- throw new Error('Nonexistent server argtype option');
- }
- });
- call.on('end', function() {
- server.stop(function() {
- call.end();
- });
- });
- };
-
- this.coreCount = function coreCount(call, callback) {
- callback(null, {cores: os.cpus().length});
- };
-};
diff --git a/src/node/src/client.js b/src/node/src/client.js
deleted file mode 100644
index edc51b7802..0000000000
--- a/src/node/src/client.js
+++ /dev/null
@@ -1,951 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-/**
- * Client module
- *
- * This module contains the factory method for creating Client classes, and the
- * method calling code for all types of methods.
- *
- * @example <caption>Create a client and call a method on it</caption>
- *
- * var proto_obj = grpc.load(proto_file_path);
- * var Client = proto_obj.package.subpackage.ServiceName;
- * var client = new Client(server_address, client_credentials);
- * var call = client.unaryMethod(arguments, callback);
- */
-
-'use strict';
-
-var _ = require('lodash');
-var arguejs = require('arguejs');
-
-var grpc = require('./grpc_extension');
-
-var common = require('./common');
-
-var Metadata = require('./metadata');
-
-var constants = require('./constants');
-
-var EventEmitter = require('events').EventEmitter;
-
-var stream = require('stream');
-
-var Readable = stream.Readable;
-var Writable = stream.Writable;
-var Duplex = stream.Duplex;
-var util = require('util');
-var version = require('../../../package.json').version;
-
-/**
- * Initial response metadata sent by the server when it starts processing the
- * call
- * @event grpc~ClientUnaryCall#metadata
- * @type {grpc.Metadata}
- */
-
-/**
- * Status of the call when it has completed.
- * @event grpc~ClientUnaryCall#status
- * @type grpc~StatusObject
- */
-
-util.inherits(ClientUnaryCall, EventEmitter);
-
-/**
- * An EventEmitter. Used for unary calls.
- * @constructor grpc~ClientUnaryCall
- * @extends external:EventEmitter
- * @param {grpc.internal~Call} call The call object associated with the request
- */
-function ClientUnaryCall(call) {
- EventEmitter.call(this);
- this.call = call;
-}
-
-util.inherits(ClientWritableStream, Writable);
-
-/**
- * A stream that the client can write to. Used for calls that are streaming from
- * the client side.
- * @constructor grpc~ClientWritableStream
- * @extends external:Writable
- * @borrows grpc~ClientUnaryCall#cancel as grpc~ClientWritableStream#cancel
- * @borrows grpc~ClientUnaryCall#getPeer as grpc~ClientWritableStream#getPeer
- * @borrows grpc~ClientUnaryCall#event:metadata as
- * grpc~ClientWritableStream#metadata
- * @borrows grpc~ClientUnaryCall#event:status as
- * grpc~ClientWritableStream#status
- * @param {grpc.internal~Call} call The call object to send data with
- * @param {grpc~serialize=} [serialize=identity] Serialization
- * function for writes.
- */
-function ClientWritableStream(call, serialize) {
- Writable.call(this, {objectMode: true});
- this.call = call;
- this.serialize = common.wrapIgnoreNull(serialize);
- this.on('finish', function() {
- var batch = {};
- batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- call.startBatch(batch, function() {});
- });
-}
-
-/**
- * Write a message to the request stream. If serializing the argument fails,
- * the call will be cancelled and the stream will end with an error.
- * @name grpc~ClientWritableStream#write
- * @kind function
- * @override
- * @param {*} message The message to write. Must be a valid argument to the
- * serialize function of the corresponding method
- * @param {grpc.writeFlags} flags Flags to modify how the message is written
- * @param {Function} callback Callback for when this chunk of data is flushed
- * @return {boolean} As defined for [Writable]{@link external:Writable}
- */
-
-/**
- * Attempt to write the given chunk. Calls the callback when done. This is an
- * implementation of a method needed for implementing stream.Writable.
- * @private
- * @param {*} chunk The chunk to write
- * @param {grpc.writeFlags} encoding Used to pass write flags
- * @param {function(Error=)} callback Called when the write is complete
- */
-function _write(chunk, encoding, callback) {
- /* jshint validthis: true */
- var batch = {};
- var message;
- var self = this;
- if (this.writeFailed) {
- /* Once a write fails, just call the callback immediately to let the caller
- flush any pending writes. */
- setImmediate(callback);
- return;
- }
- try {
- message = this.serialize(chunk);
- } catch (e) {
- /* Sending this error to the server and emitting it immediately on the
- client may put the call in a slightly weird state on the client side,
- but passing an object that causes a serialization failure is a misuse
- of the API anyway, so that's OK. The primary purpose here is to give the
- programmer a useful error and to stop the stream properly */
- this.call.cancelWithStatus(constants.status.INTERNAL,
- 'Serialization failure');
- callback(e);
- return;
- }
- if (_.isFinite(encoding)) {
- /* Attach the encoding if it is a finite number. This is the closest we
- * can get to checking that it is valid flags */
- message.grpcWriteFlags = encoding;
- }
- batch[grpc.opType.SEND_MESSAGE] = message;
- this.call.startBatch(batch, function(err, event) {
- if (err) {
- /* Assume that the call is complete and that writing failed because a
- status was received. In that case, set a flag to discard all future
- writes */
- self.writeFailed = true;
- }
- callback();
- });
-}
-
-ClientWritableStream.prototype._write = _write;
-
-util.inherits(ClientReadableStream, Readable);
-
-/**
- * A stream that the client can read from. Used for calls that are streaming
- * from the server side.
- * @constructor grpc~ClientReadableStream
- * @extends external:Readable
- * @borrows grpc~ClientUnaryCall#cancel as grpc~ClientReadableStream#cancel
- * @borrows grpc~ClientUnaryCall#getPeer as grpc~ClientReadableStream#getPeer
- * @borrows grpc~ClientUnaryCall#event:metadata as
- * grpc~ClientReadableStream#metadata
- * @borrows grpc~ClientUnaryCall#event:status as
- * grpc~ClientReadableStream#status
- * @param {grpc.internal~Call} call The call object to read data with
- * @param {grpc~deserialize=} [deserialize=identity]
- * Deserialization function for reads
- */
-function ClientReadableStream(call, deserialize) {
- Readable.call(this, {objectMode: true});
- this.call = call;
- this.finished = false;
- this.reading = false;
- this.deserialize = common.wrapIgnoreNull(deserialize);
- /* Status generated from reading messages from the server. Overrides the
- * status from the server if not OK */
- this.read_status = null;
- /* Status received from the server. */
- this.received_status = null;
-}
-
-/**
- * Called when all messages from the server have been processed. The status
- * parameter indicates that the call should end with that status. status
- * defaults to OK if not provided.
- * @param {Object!} status The status that the call should end with
- * @private
- */
-function _readsDone(status) {
- /* jshint validthis: true */
- if (!status) {
- status = {code: constants.status.OK, details: 'OK'};
- }
- if (status.code !== constants.status.OK) {
- this.call.cancelWithStatus(status.code, status.details);
- }
- this.finished = true;
- this.read_status = status;
- this._emitStatusIfDone();
-}
-
-ClientReadableStream.prototype._readsDone = _readsDone;
-
-/**
- * Called to indicate that we have received a status from the server.
- * @private
- */
-function _receiveStatus(status) {
- /* jshint validthis: true */
- this.received_status = status;
- this._emitStatusIfDone();
-}
-
-ClientReadableStream.prototype._receiveStatus = _receiveStatus;
-
-/**
- * If we have both processed all incoming messages and received the status from
- * the server, emit the status. Otherwise, do nothing.
- * @private
- */
-function _emitStatusIfDone() {
- /* jshint validthis: true */
- var status;
- if (this.read_status && this.received_status) {
- if (this.read_status.code !== constants.status.OK) {
- status = this.read_status;
- } else {
- status = this.received_status;
- }
- if (status.code === constants.status.OK) {
- this.push(null);
- } else {
- var error = new Error(status.details);
- error.code = status.code;
- error.metadata = status.metadata;
- this.emit('error', error);
- }
- this.emit('status', status);
- }
-}
-
-ClientReadableStream.prototype._emitStatusIfDone = _emitStatusIfDone;
-
-/**
- * Read the next object from the stream.
- * @private
- * @param {*} size Ignored because we use objectMode=true
- */
-function _read(size) {
- /* jshint validthis: true */
- var self = this;
- /**
- * Callback to be called when a READ event is received. Pushes the data onto
- * the read queue and starts reading again if applicable
- * @param {grpc.Event} event READ event object
- */
- function readCallback(err, event) {
- if (err) {
- // Something has gone wrong. Stop reading and wait for status
- self.finished = true;
- self._readsDone();
- return;
- }
- var data = event.read;
- var deserialized;
- try {
- deserialized = self.deserialize(data);
- } catch (e) {
- self._readsDone({code: constants.status.INTERNAL,
- details: 'Failed to parse server response'});
- return;
- }
- if (data === null) {
- self._readsDone();
- return;
- }
- if (self.push(deserialized) && data !== null) {
- var read_batch = {};
- read_batch[grpc.opType.RECV_MESSAGE] = true;
- self.call.startBatch(read_batch, readCallback);
- } else {
- self.reading = false;
- }
- }
- if (self.finished) {
- self.push(null);
- } else {
- if (!self.reading) {
- self.reading = true;
- var read_batch = {};
- read_batch[grpc.opType.RECV_MESSAGE] = true;
- self.call.startBatch(read_batch, readCallback);
- }
- }
-}
-
-ClientReadableStream.prototype._read = _read;
-
-util.inherits(ClientDuplexStream, Duplex);
-
-/**
- * A stream that the client can read from or write to. Used for calls with
- * duplex streaming.
- * @constructor grpc~ClientDuplexStream
- * @extends external:Duplex
- * @borrows grpc~ClientUnaryCall#cancel as grpc~ClientDuplexStream#cancel
- * @borrows grpc~ClientUnaryCall#getPeer as grpc~ClientDuplexStream#getPeer
- * @borrows grpc~ClientWritableStream#write as grpc~ClientDuplexStream#write
- * @borrows grpc~ClientUnaryCall#event:metadata as
- * grpc~ClientDuplexStream#metadata
- * @borrows grpc~ClientUnaryCall#event:status as
- * grpc~ClientDuplexStream#status
- * @param {grpc.internal~Call} call Call object to proxy
- * @param {grpc~serialize=} [serialize=identity] Serialization
- * function for requests
- * @param {grpc~deserialize=} [deserialize=identity]
- * Deserialization function for responses
- */
-function ClientDuplexStream(call, serialize, deserialize) {
- Duplex.call(this, {objectMode: true});
- this.serialize = common.wrapIgnoreNull(serialize);
- this.deserialize = common.wrapIgnoreNull(deserialize);
- this.call = call;
- /* Status generated from reading messages from the server. Overrides the
- * status from the server if not OK */
- this.read_status = null;
- /* Status received from the server. */
- this.received_status = null;
- this.on('finish', function() {
- var batch = {};
- batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- call.startBatch(batch, function() {});
- });
-}
-
-ClientDuplexStream.prototype._readsDone = _readsDone;
-ClientDuplexStream.prototype._receiveStatus = _receiveStatus;
-ClientDuplexStream.prototype._emitStatusIfDone = _emitStatusIfDone;
-ClientDuplexStream.prototype._read = _read;
-ClientDuplexStream.prototype._write = _write;
-
-/**
- * Cancel the ongoing call. Results in the call ending with a CANCELLED status,
- * unless it has already ended with some other status.
- * @alias grpc~ClientUnaryCall#cancel
- */
-function cancel() {
- /* jshint validthis: true */
- this.call.cancel();
-}
-
-ClientUnaryCall.prototype.cancel = cancel;
-ClientReadableStream.prototype.cancel = cancel;
-ClientWritableStream.prototype.cancel = cancel;
-ClientDuplexStream.prototype.cancel = cancel;
-
-/**
- * Get the endpoint this call/stream is connected to.
- * @return {string} The URI of the endpoint
- * @alias grpc~ClientUnaryCall#getPeer
- */
-function getPeer() {
- /* jshint validthis: true */
- return this.call.getPeer();
-}
-
-ClientUnaryCall.prototype.getPeer = getPeer;
-ClientReadableStream.prototype.getPeer = getPeer;
-ClientWritableStream.prototype.getPeer = getPeer;
-ClientDuplexStream.prototype.getPeer = getPeer;
-
-/**
- * Any client call type
- * @typedef {(ClientUnaryCall|ClientReadableStream|
- * ClientWritableStream|ClientDuplexStream)}
- * grpc.Client~Call
- */
-
-/**
- * Options that can be set on a call.
- * @typedef {Object} grpc.Client~CallOptions
- * @property {grpc~Deadline} deadline The deadline for the entire call to
- * complete.
- * @property {string} host Server hostname to set on the call. Only meaningful
- * if different from the server address used to construct the client.
- * @property {grpc.Client~Call} parent Parent call. Used in servers when
- * making a call as part of the process of handling a call. Used to
- * propagate some information automatically, as specified by
- * propagate_flags.
- * @property {number} propagate_flags Indicates which properties of a parent
- * call should propagate to this call. Bitwise combination of flags in
- * {@link grpc.propagate}.
- * @property {grpc.credentials~CallCredentials} credentials The credentials that
- * should be used to make this particular call.
- */
-
-/**
- * Get a call object built with the provided options.
- * @access private
- * @param {grpc.Client~CallOptions=} options Options object.
- */
-function getCall(channel, method, options) {
- var deadline;
- var host;
- var parent;
- var propagate_flags;
- var credentials;
- if (options) {
- deadline = options.deadline;
- host = options.host;
- parent = _.get(options, 'parent.call');
- propagate_flags = options.propagate_flags;
- credentials = options.credentials;
- }
- if (deadline === undefined) {
- deadline = Infinity;
- }
- var call = new grpc.Call(channel, method, deadline, host,
- parent, propagate_flags);
- if (credentials) {
- call.setCredentials(credentials);
- }
- return call;
-}
-
-/**
- * A generic gRPC client. Primarily useful as a base class for generated clients
- * @memberof grpc
- * @constructor
- * @param {string} address Server address to connect to
- * @param {grpc~ChannelCredentials} credentials Credentials to use to connect to
- * the server
- * @param {Object} options Options to apply to channel creation
- */
-function Client(address, credentials, options) {
- if (!options) {
- options = {};
- }
- /* Append the grpc-node user agent string after the application user agent
- * string, and put the combination at the beginning of the user agent string
- */
- if (options['grpc.primary_user_agent']) {
- options['grpc.primary_user_agent'] += ' ';
- } else {
- options['grpc.primary_user_agent'] = '';
- }
- options['grpc.primary_user_agent'] += 'grpc-node/' + version;
- /* Private fields use $ as a prefix instead of _ because it is an invalid
- * prefix of a method name */
- this.$channel = new grpc.Channel(address, credentials, options);
-}
-
-exports.Client = Client;
-
-/**
- * @callback grpc.Client~requestCallback
- * @param {?grpc~ServiceError} error The error, if the call
- * failed
- * @param {*} value The response value, if the call succeeded
- */
-
-/**
- * Make a unary request to the given method, using the given serialize
- * and deserialize functions, with the given argument.
- * @param {string} method The name of the method to request
- * @param {grpc~serialize} serialize The serialization function for
- * inputs
- * @param {grpc~deserialize} deserialize The deserialization
- * function for outputs
- * @param {*} argument The argument to the call. Should be serializable with
- * serialize
- * @param {grpc.Metadata=} metadata Metadata to add to the call
- * @param {grpc.Client~CallOptions=} options Options map
- * @param {grpc.Client~requestCallback} callback The callback to
- * for when the response is received
- * @return {grpc~ClientUnaryCall} An event emitter for stream related events
- */
-Client.prototype.makeUnaryRequest = function(method, serialize, deserialize,
- argument, metadata, options,
- callback) {
- /* While the arguments are listed in the function signature, those variables
- * are not used directly. Instead, ArgueJS processes the arguments
- * object. This allows for simple handling of optional arguments in the
- * middle of the argument list, and also provides type checking. */
- var args = arguejs({method: String, serialize: Function,
- deserialize: Function,
- argument: null, metadata: [Metadata, new Metadata()],
- options: [Object], callback: Function}, arguments);
- var call = getCall(this.$channel, method, args.options);
- var emitter = new ClientUnaryCall(call);
- metadata = args.metadata.clone();
- var client_batch = {};
- var message = serialize(args.argument);
- if (args.options) {
- message.grpcWriteFlags = args.options.flags;
- }
-
- client_batch[grpc.opType.SEND_INITIAL_METADATA] =
- metadata._getCoreRepresentation();
- client_batch[grpc.opType.SEND_MESSAGE] = message;
- client_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- client_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- client_batch[grpc.opType.RECV_MESSAGE] = true;
- client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(client_batch, function(err, response) {
- response.status.metadata = Metadata._fromCoreRepresentation(
- response.status.metadata);
- var status = response.status;
- var error;
- var deserialized;
- emitter.emit('metadata', Metadata._fromCoreRepresentation(
- response.metadata));
- if (status.code === constants.status.OK) {
- if (err) {
- // Got a batch error, but OK status. Something went wrong
- args.callback(err);
- return;
- } else {
- try {
- deserialized = deserialize(response.read);
- } catch (e) {
- /* Change status to indicate bad server response. This will result
- * in passing an error to the callback */
- status = {
- code: constants.status.INTERNAL,
- details: 'Failed to parse server response'
- };
- }
- }
- }
- if (status.code !== constants.status.OK) {
- error = new Error(status.details);
- error.code = status.code;
- error.metadata = status.metadata;
- args.callback(error);
- } else {
- args.callback(null, deserialized);
- }
- emitter.emit('status', status);
- });
- return emitter;
-};
-
-/**
- * Make a client stream request to the given method, using the given serialize
- * and deserialize functions, with the given argument.
- * @param {string} method The name of the method to request
- * @param {grpc~serialize} serialize The serialization function for
- * inputs
- * @param {grpc~deserialize} deserialize The deserialization
- * function for outputs
- * @param {grpc.Metadata=} metadata Array of metadata key/value pairs to add to
- * the call
- * @param {grpc.Client~CallOptions=} options Options map
- * @param {grpc.Client~requestCallback} callback The callback to for when the
- * response is received
- * @return {grpc~ClientWritableStream} An event emitter for stream related
- * events
- */
-Client.prototype.makeClientStreamRequest = function(method, serialize,
- deserialize, metadata,
- options, callback) {
- /* While the arguments are listed in the function signature, those variables
- * are not used directly. Instead, ArgueJS processes the arguments
- * object. This allows for simple handling of optional arguments in the
- * middle of the argument list, and also provides type checking. */
- var args = arguejs({method:String, serialize: Function,
- deserialize: Function,
- metadata: [Metadata, new Metadata()],
- options: [Object], callback: Function}, arguments);
- var call = getCall(this.$channel, method, args.options);
- metadata = args.metadata.clone();
- var stream = new ClientWritableStream(call, serialize);
- var metadata_batch = {};
- metadata_batch[grpc.opType.SEND_INITIAL_METADATA] =
- metadata._getCoreRepresentation();
- metadata_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- call.startBatch(metadata_batch, function(err, response) {
- if (err) {
- // The call has stopped for some reason. A non-OK status will arrive
- // in the other batch.
- return;
- }
- stream.emit('metadata', Metadata._fromCoreRepresentation(
- response.metadata));
- });
- var client_batch = {};
- client_batch[grpc.opType.RECV_MESSAGE] = true;
- client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(client_batch, function(err, response) {
- response.status.metadata = Metadata._fromCoreRepresentation(
- response.status.metadata);
- var status = response.status;
- var error;
- var deserialized;
- if (status.code === constants.status.OK) {
- if (err) {
- // Got a batch error, but OK status. Something went wrong
- args.callback(err);
- return;
- } else {
- try {
- deserialized = deserialize(response.read);
- } catch (e) {
- /* Change status to indicate bad server response. This will result
- * in passing an error to the callback */
- status = {
- code: constants.status.INTERNAL,
- details: 'Failed to parse server response'
- };
- }
- }
- }
- if (status.code !== constants.status.OK) {
- error = new Error(response.status.details);
- error.code = status.code;
- error.metadata = status.metadata;
- args.callback(error);
- } else {
- args.callback(null, deserialized);
- }
- stream.emit('status', status);
- });
- return stream;
-};
-
-/**
- * Make a server stream request to the given method, with the given serialize
- * and deserialize function, using the given argument
- * @param {string} method The name of the method to request
- * @param {grpc~serialize} serialize The serialization function for inputs
- * @param {grpc~deserialize} deserialize The deserialization
- * function for outputs
- * @param {*} argument The argument to the call. Should be serializable with
- * serialize
- * @param {grpc.Metadata=} metadata Array of metadata key/value pairs to add to
- * the call
- * @param {grpc.Client~CallOptions=} options Options map
- * @return {grpc~ClientReadableStream} An event emitter for stream related
- * events
- */
-Client.prototype.makeServerStreamRequest = function(method, serialize,
- deserialize, argument,
- metadata, options) {
- /* While the arguments are listed in the function signature, those variables
- * are not used directly. Instead, ArgueJS processes the arguments
- * object. */
- var args = arguejs({method:String, serialize: Function,
- deserialize: Function,
- argument: null, metadata: [Metadata, new Metadata()],
- options: [Object]}, arguments);
- var call = getCall(this.$channel, method, args.options);
- metadata = args.metadata.clone();
- var stream = new ClientReadableStream(call, deserialize);
- var start_batch = {};
- var message = serialize(args.argument);
- if (args.options) {
- message.grpcWriteFlags = args.options.flags;
- }
- start_batch[grpc.opType.SEND_INITIAL_METADATA] =
- metadata._getCoreRepresentation();
- start_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- start_batch[grpc.opType.SEND_MESSAGE] = message;
- start_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- call.startBatch(start_batch, function(err, response) {
- if (err) {
- // The call has stopped for some reason. A non-OK status will arrive
- // in the other batch.
- return;
- }
- stream.emit('metadata', Metadata._fromCoreRepresentation(
- response.metadata));
- });
- var status_batch = {};
- status_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(status_batch, function(err, response) {
- if (err) {
- stream.emit('error', err);
- return;
- }
- response.status.metadata = Metadata._fromCoreRepresentation(
- response.status.metadata);
- stream._receiveStatus(response.status);
- });
- return stream;
-};
-
-
-/**
- * Make a bidirectional stream request with this method on the given channel.
- * @param {string} method The name of the method to request
- * @param {grpc~serialize} serialize The serialization function for inputs
- * @param {grpc~deserialize} deserialize The deserialization
- * function for outputs
- * @param {grpc.Metadata=} metadata Array of metadata key/value
- * pairs to add to the call
- * @param {grpc.Client~CallOptions=} options Options map
- * @return {grpc~ClientDuplexStream} An event emitter for stream related events
- */
-Client.prototype.makeBidiStreamRequest = function(method, serialize,
- deserialize, metadata,
- options) {
- /* While the arguments are listed in the function signature, those variables
- * are not used directly. Instead, ArgueJS processes the arguments
- * object. */
- var args = arguejs({method:String, serialize: Function,
- deserialize: Function,
- metadata: [Metadata, new Metadata()],
- options: [Object]}, arguments);
- var call = getCall(this.$channel, method, args.options);
- metadata = args.metadata.clone();
- var stream = new ClientDuplexStream(call, serialize, deserialize);
- var start_batch = {};
- start_batch[grpc.opType.SEND_INITIAL_METADATA] =
- metadata._getCoreRepresentation();
- start_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- call.startBatch(start_batch, function(err, response) {
- if (err) {
- // The call has stopped for some reason. A non-OK status will arrive
- // in the other batch.
- return;
- }
- stream.emit('metadata', Metadata._fromCoreRepresentation(
- response.metadata));
- });
- var status_batch = {};
- status_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(status_batch, function(err, response) {
- if (err) {
- stream.emit('error', err);
- return;
- }
- response.status.metadata = Metadata._fromCoreRepresentation(
- response.status.metadata);
- stream._receiveStatus(response.status);
- });
- return stream;
-};
-
-/**
- * Close this client.
- */
-Client.prototype.close = function() {
- this.$channel.close();
-};
-
-/**
- * Return the underlying channel object for the specified client
- * @return {Channel} The channel
- */
-Client.prototype.getChannel = function() {
- return this.$channel;
-};
-
-/**
- * Wait for the client to be ready. The callback will be called when the
- * client has successfully connected to the server, and it will be called
- * with an error if the attempt to connect to the server has unrecoverablly
- * failed or if the deadline expires. This function will make the channel
- * start connecting if it has not already done so.
- * @param {grpc~Deadline} deadline When to stop waiting for a connection.
- * @param {function(Error)} callback The callback to call when done attempting
- * to connect.
- */
-Client.prototype.waitForReady = function(deadline, callback) {
- var self = this;
- var checkState = function(err) {
- if (err) {
- callback(new Error('Failed to connect before the deadline'));
- return;
- }
- var new_state = self.$channel.getConnectivityState(true);
- if (new_state === grpc.connectivityState.READY) {
- callback();
- } else if (new_state === grpc.connectivityState.FATAL_FAILURE) {
- callback(new Error('Failed to connect to server'));
- } else {
- self.$channel.watchConnectivityState(new_state, deadline, checkState);
- }
- };
- checkState();
-};
-
-/**
- * Map with short names for each of the requester maker functions. Used in
- * makeClientConstructor
- * @private
- */
-var requester_funcs = {
- unary: Client.prototype.makeUnaryRequest,
- server_stream: Client.prototype.makeServerStreamRequest,
- client_stream: Client.prototype.makeClientStreamRequest,
- bidi: Client.prototype.makeBidiStreamRequest
-};
-
-function getDefaultValues(metadata, options) {
- var res = {};
- res.metadata = metadata || new Metadata();
- res.options = options || {};
- return res;
-}
-
-/**
- * Map with wrappers for each type of requester function to make it use the old
- * argument order with optional arguments after the callback.
- * @access private
- */
-var deprecated_request_wrap = {
- unary: function(makeUnaryRequest) {
- return function makeWrappedUnaryRequest(argument, callback,
- metadata, options) {
- /* jshint validthis: true */
- var opt_args = getDefaultValues(metadata, metadata);
- return makeUnaryRequest.call(this, argument, opt_args.metadata,
- opt_args.options, callback);
- };
- },
- client_stream: function(makeServerStreamRequest) {
- return function makeWrappedClientStreamRequest(callback, metadata,
- options) {
- /* jshint validthis: true */
- var opt_args = getDefaultValues(metadata, options);
- return makeServerStreamRequest.call(this, opt_args.metadata,
- opt_args.options, callback);
- };
- },
- server_stream: _.identity,
- bidi: _.identity
-};
-
-/**
- * Creates a constructor for a client with the given methods, as specified in
- * the methods argument. The resulting class will have an instance method for
- * each method in the service, which is a partial application of one of the
- * [Client]{@link grpc.Client} request methods, depending on `requestSerialize`
- * and `responseSerialize`, with the `method`, `serialize`, and `deserialize`
- * arguments predefined.
- * @memberof grpc
- * @alias grpc~makeGenericClientConstructor
- * @param {grpc~ServiceDefinition} methods An object mapping method names to
- * method attributes
- * @param {string} serviceName The fully qualified name of the service
- * @param {Object} class_options An options object.
- * @param {boolean=} [class_options.deprecatedArgumentOrder=false] Indicates
- * that the old argument order should be used for methods, with optional
- * arguments at the end instead of the callback at the end. This option
- * is only a temporary stopgap measure to smooth an API breakage.
- * It is deprecated, and new code should not use it.
- * @return {function} New client constructor, which is a subclass of
- * {@link grpc.Client}, and has the same arguments as that constructor.
- */
-exports.makeClientConstructor = function(methods, serviceName,
- class_options) {
- if (!class_options) {
- class_options = {};
- }
-
- function ServiceClient(address, credentials, options) {
- Client.call(this, address, credentials, options);
- }
-
- util.inherits(ServiceClient, Client);
-
- _.each(methods, function(attrs, name) {
- var method_type;
- if (_.startsWith(name, '$')) {
- throw new Error('Method names cannot start with $');
- }
- if (attrs.requestStream) {
- if (attrs.responseStream) {
- method_type = 'bidi';
- } else {
- method_type = 'client_stream';
- }
- } else {
- if (attrs.responseStream) {
- method_type = 'server_stream';
- } else {
- method_type = 'unary';
- }
- }
- var serialize = attrs.requestSerialize;
- var deserialize = attrs.responseDeserialize;
- var method_func = _.partial(requester_funcs[method_type], attrs.path,
- serialize, deserialize);
- if (class_options.deprecatedArgumentOrder) {
- ServiceClient.prototype[name] = deprecated_request_wrap(method_func);
- } else {
- ServiceClient.prototype[name] = method_func;
- }
- // Associate all provided attributes with the method
- _.assign(ServiceClient.prototype[name], attrs);
- });
-
- ServiceClient.service = methods;
-
- return ServiceClient;
-};
-
-/**
- * Return the underlying channel object for the specified client
- * @memberof grpc
- * @alias grpc~getClientChannel
- * @param {Client} client
- * @return {Channel} The channel
- * @see grpc.Client#getChannel
- */
-exports.getClientChannel = function(client) {
- return Client.prototype.getChannel.call(client);
-};
-
-/**
- * Wait for the client to be ready. The callback will be called when the
- * client has successfully connected to the server, and it will be called
- * with an error if the attempt to connect to the server has unrecoverablly
- * failed or if the deadline expires. This function will make the channel
- * start connecting if it has not already done so.
- * @memberof grpc
- * @alias grpc~waitForClientReady
- * @param {Client} client The client to wait on
- * @param {grpc~Deadline} deadline When to stop waiting for a connection. Pass
- * Infinity to wait forever.
- * @param {function(Error)} callback The callback to call when done attempting
- * to connect.
- * @see grpc.Client#waitForReady
- */
-exports.waitForClientReady = function(client, deadline, callback) {
- Client.prototype.waitForReady.call(client, deadline, callback);
-};
diff --git a/src/node/src/common.js b/src/node/src/common.js
deleted file mode 100644
index 5a444f5e96..0000000000
--- a/src/node/src/common.js
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-/**
- * Wrap a function to pass null-like values through without calling it. If no
- * function is given, just uses the identity.
- * @private
- * @param {?function} func The function to wrap
- * @return {function} The wrapped function
- */
-exports.wrapIgnoreNull = function wrapIgnoreNull(func) {
- if (!func) {
- return _.identity;
- }
- return function(arg) {
- if (arg === null || arg === undefined) {
- return null;
- }
- return func(arg);
- };
-};
-
-/**
- * The logger object for the gRPC module. Defaults to console.
- * @private
- */
-exports.logger = console;
-
-/**
- * The current logging verbosity. 0 corresponds to logging everything
- * @private
- */
-exports.logVerbosity = 0;
-
-/**
- * Log a message if the severity is at least as high as the current verbosity
- * @private
- * @param {Number} severity A value of the grpc.logVerbosity map
- * @param {String} message The message to log
- */
-exports.log = function log(severity, message) {
- if (severity >= exports.logVerbosity) {
- exports.logger.error(message);
- }
-};
-
-/**
- * Default options for loading proto files into gRPC
- * @alias grpc~defaultLoadOptions
- */
-exports.defaultGrpcOptions = {
- convertFieldsToCamelCase: false,
- binaryAsBase64: false,
- longsAsStrings: true,
- enumsAsStrings: true,
- deprecatedArgumentOrder: false
-};
-
-// JSDoc definitions that are used in multiple other modules
-
-/**
- * Represents the status of a completed request. If `code` is
- * {@link grpc.status}.OK, then the request has completed successfully.
- * Otherwise, the request has failed, `details` will contain a description of
- * the error. Either way, `metadata` contains the trailing response metadata
- * sent by the server when it finishes processing the call.
- * @typedef {object} grpc~StatusObject
- * @property {number} code The error code, a key of {@link grpc.status}
- * @property {string} details Human-readable description of the status
- * @property {grpc.Metadata} metadata Trailing metadata sent with the status,
- * if applicable
- */
-
-/**
- * Describes how a request has failed. The member `message` will be the same as
- * `details` in {@link grpc~StatusObject}, and `code` and `metadata` are the
- * same as in that object.
- * @typedef {Error} grpc~ServiceError
- * @property {number} code The error code, a key of {@link grpc.status} that is
- * not `grpc.status.OK`
- * @property {grpc.Metadata} metadata Trailing metadata sent with the status,
- * if applicable
- */
-
-/**
- * The EventEmitter class in the event standard module
- * @external EventEmitter
- * @see https://nodejs.org/api/events.html#events_class_eventemitter
- */
-
-/**
- * The Readable class in the stream standard module
- * @external Readable
- * @see https://nodejs.org/api/stream.html#stream_readable_streams
- */
-
-/**
- * The Writable class in the stream standard module
- * @external Writable
- * @see https://nodejs.org/api/stream.html#stream_writable_streams
- */
-
-/**
- * The Duplex class in the stream standard module
- * @external Duplex
- * @see https://nodejs.org/api/stream.html#stream_class_stream_duplex
- */
-
-/**
- * A serialization function
- * @callback grpc~serialize
- * @param {*} value The value to serialize
- * @return {Buffer} The value serialized as a byte sequence
- */
-
-/**
- * A deserialization function
- * @callback grpc~deserialize
- * @param {Buffer} data The byte sequence to deserialize
- * @return {*} The data deserialized as a value
- */
-
-/**
- * The deadline of an operation. If it is a date, the deadline is reached at
- * the date and time specified. If it is a finite number, it is treated as
- * a number of milliseconds since the Unix Epoch. If it is Infinity, the
- * deadline will never be reached. If it is -Infinity, the deadline has already
- * passed.
- * @typedef {(number|date)} grpc~Deadline
- */
-
-/**
- * An object that completely defines a service method signature.
- * @typedef {Object} grpc~MethodDefinition
- * @property {string} path The method's URL path
- * @property {boolean} requestStream Indicates whether the method accepts
- * a stream of requests
- * @property {boolean} responseStream Indicates whether the method returns
- * a stream of responses
- * @property {grpc~serialize} requestSerialize Serialization
- * function for request values
- * @property {grpc~serialize} responseSerialize Serialization
- * function for response values
- * @property {grpc~deserialize} requestDeserialize Deserialization
- * function for request data
- * @property {grpc~deserialize} responseDeserialize Deserialization
- * function for repsonse data
- */
-
-/**
- * An object that completely defines a service.
- * @typedef {Object.<string, grpc~MethodDefinition>} grpc~ServiceDefinition
- */
diff --git a/src/node/src/constants.js b/src/node/src/constants.js
deleted file mode 100644
index c90e44d0d3..0000000000
--- a/src/node/src/constants.js
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-/* The comments about status codes are copied verbatim (with some formatting
- * modifications) from include/grpc/impl/codegen/status.h, for the purpose of
- * including them in generated documentation.
- */
-/**
- * Enum of status codes that gRPC can return
- * @memberof grpc
- * @alias grpc.status
- * @readonly
- * @enum {number}
- */
-exports.status = {
- /** Not an error; returned on success */
- OK: 0,
- /** The operation was cancelled (typically by the caller). */
- CANCELLED: 1,
- /**
- * Unknown error. An example of where this error may be returned is
- * if a status value received from another address space belongs to
- * an error-space that is not known in this address space. Also
- * errors raised by APIs that do not return enough error information
- * may be converted to this error.
- */
- UNKNOWN: 2,
- /**
- * Client specified an invalid argument. Note that this differs
- * from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
- * that are problematic regardless of the state of the system
- * (e.g., a malformed file name).
- */
- INVALID_ARGUMENT: 3,
- /**
- * Deadline expired before operation could complete. For operations
- * that change the state of the system, this error may be returned
- * even if the operation has completed successfully. For example, a
- * successful response from a server could have been delayed long
- * enough for the deadline to expire.
- */
- DEADLINE_EXCEEDED: 4,
- /** Some requested entity (e.g., file or directory) was not found. */
- NOT_FOUND: 5,
- /**
- * Some entity that we attempted to create (e.g., file or directory)
- * already exists.
- */
- ALREADY_EXISTS: 6,
- /**
- * The caller does not have permission to execute the specified
- * operation. PERMISSION_DENIED must not be used for rejections
- * caused by exhausting some resource (use RESOURCE_EXHAUSTED
- * instead for those errors). PERMISSION_DENIED must not be
- * used if the caller can not be identified (use UNAUTHENTICATED
- * instead for those errors).
- */
- PERMISSION_DENIED: 7,
- /**
- * Some resource has been exhausted, perhaps a per-user quota, or
- * perhaps the entire file system is out of space.
- */
- RESOURCE_EXHAUSTED: 8,
- /**
- * Operation was rejected because the system is not in a state
- * required for the operation's execution. For example, directory
- * to be deleted may be non-empty, an rmdir operation is applied to
- * a non-directory, etc.
- *
- * A litmus test that may help a service implementor in deciding
- * between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
- *
- * - Use UNAVAILABLE if the client can retry just the failing call.
- * - Use ABORTED if the client should retry at a higher-level
- * (e.g., restarting a read-modify-write sequence).
- * - Use FAILED_PRECONDITION if the client should not retry until
- * the system state has been explicitly fixed. E.g., if an "rmdir"
- * fails because the directory is non-empty, FAILED_PRECONDITION
- * should be returned since the client should not retry unless
- * they have first fixed up the directory by deleting files from it.
- * - Use FAILED_PRECONDITION if the client performs conditional
- * REST Get/Update/Delete on a resource and the resource on the
- * server does not match the condition. E.g., conflicting
- * read-modify-write on the same resource.
- */
- FAILED_PRECONDITION: 9,
- /**
- * The operation was aborted, typically due to a concurrency issue
- * like sequencer check failures, transaction aborts, etc.
- *
- * See litmus test above for deciding between FAILED_PRECONDITION,
- * ABORTED, and UNAVAILABLE.
- */
- ABORTED: 10,
- /**
- * Operation was attempted past the valid range. E.g., seeking or
- * reading past end of file.
- *
- * Unlike INVALID_ARGUMENT, this error indicates a problem that may
- * be fixed if the system state changes. For example, a 32-bit file
- * system will generate INVALID_ARGUMENT if asked to read at an
- * offset that is not in the range [0,2^32-1], but it will generate
- * OUT_OF_RANGE if asked to read from an offset past the current
- * file size.
- *
- * There is a fair bit of overlap between FAILED_PRECONDITION and
- * OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
- * error) when it applies so that callers who are iterating through
- * a space can easily look for an OUT_OF_RANGE error to detect when
- * they are done.
- */
- OUT_OF_RANGE: 11,
- /** Operation is not implemented or not supported/enabled in this service. */
- UNIMPLEMENTED: 12,
- /**
- * Internal errors. Means some invariants expected by underlying
- * system has been broken. If you see one of these errors,
- * something is very broken.
- */
- INTERNAL: 13,
- /**
- * The service is currently unavailable. This is a most likely a
- * transient condition and may be corrected by retrying with
- * a backoff.
- *
- * See litmus test above for deciding between FAILED_PRECONDITION,
- * ABORTED, and UNAVAILABLE. */
- UNAVAILABLE: 14,
- /** Unrecoverable data loss or corruption. */
- DATA_LOSS: 15,
- /**
- * The request does not have valid authentication credentials for the
- * operation.
- */
- UNAUTHENTICATED: 16
-};
-
-/* The comments about propagation bit flags are copied rom
- * include/grpc/impl/codegen/propagation_bits.h for the purpose of including
- * them in generated documentation.
- */
-/**
- * Propagation flags: these can be bitwise or-ed to form the propagation option
- * for calls.
- *
- * Users are encouraged to write propagation masks as deltas from the default.
- * i.e. write `grpc.propagate.DEFAULTS & ~grpc.propagate.DEADLINE` to disable
- * deadline propagation.
- * @memberof grpc
- * @alias grpc.propagate
- * @enum {number}
- */
-exports.propagate = {
- DEADLINE: 1,
- CENSUS_STATS_CONTEXT: 2,
- CENSUS_TRACING_CONTEXT: 4,
- CANCELLATION: 8,
- DEFAULTS: 65535
-};
-
-/* Many of the following comments are copied from
- * include/grpc/impl/codegen/grpc_types.h
- */
-/**
- * Call error constants. Call errors almost always indicate bugs in the gRPC
- * library, and these error codes are mainly useful for finding those bugs.
- * @memberof grpc
- * @readonly
- * @enum {number}
- */
-const callError = {
- OK: 0,
- ERROR: 1,
- NOT_ON_SERVER: 2,
- NOT_ON_CLIENT: 3,
- ALREADY_INVOKED: 5,
- NOT_INVOKED: 6,
- ALREADY_FINISHED: 7,
- TOO_MANY_OPERATIONS: 8,
- INVALID_FLAGS: 9,
- INVALID_METADATA: 10,
- INVALID_MESSAGE: 11,
- NOT_SERVER_COMPLETION_QUEUE: 12,
- BATCH_TOO_BIG: 13,
- PAYLOAD_TYPE_MISMATCH: 14
-};
-
-exports.callError = callError;
-
-/**
- * Write flags: these can be bitwise or-ed to form write options that modify
- * how data is written.
- * @memberof grpc
- * @alias grpc.writeFlags
- * @readonly
- * @enum {number}
- */
-exports.writeFlags = {
- /**
- * Hint that the write may be buffered and need not go out on the wire
- * immediately. GRPC is free to buffer the message until the next non-buffered
- * write, or until writes_done, but it need not buffer completely or at all.
- */
- BUFFER_HINT: 1,
- /**
- * Force compression to be disabled for a particular write
- */
- NO_COMPRESS: 2
-};
-
-/**
- * @memberof grpc
- * @alias grpc.logVerbosity
- * @readonly
- * @enum {number}
- */
-exports.logVerbosity = {
- DEBUG: 0,
- INFO: 1,
- ERROR: 2
-};
diff --git a/src/node/src/credentials.js b/src/node/src/credentials.js
deleted file mode 100644
index d68d888e6a..0000000000
--- a/src/node/src/credentials.js
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-/**
- * Credentials module
- *
- * This module contains factory methods for two different credential types:
- * CallCredentials and ChannelCredentials. ChannelCredentials are things like
- * SSL credentials that can be used to secure a connection, and are used to
- * construct a Client object. CallCredentials genrally modify metadata, so they
- * can be attached to an individual method call.
- *
- * CallCredentials can be composed with other CallCredentials to create
- * CallCredentials. ChannelCredentials can be composed with CallCredentials
- * to create ChannelCredentials. No combined credential can have more than
- * one ChannelCredentials.
- *
- * For example, to create a client secured with SSL that uses Google
- * default application credentials to authenticate:
- *
- * @example
- * var channel_creds = credentials.createSsl(root_certs);
- * (new GoogleAuth()).getApplicationDefault(function(err, credential) {
- * var call_creds = credentials.createFromGoogleCredential(credential);
- * var combined_creds = credentials.combineChannelCredentials(
- * channel_creds, call_creds);
- * var client = new Client(address, combined_creds);
- * });
- *
- * @namespace grpc.credentials
- */
-
-'use strict';
-
-var grpc = require('./grpc_extension');
-
-/**
- * This cannot be constructed directly. Instead, instances of this class should
- * be created using the factory functions in {@link grpc.credentials}
- * @constructor grpc.credentials~CallCredentials
- */
-var CallCredentials = grpc.CallCredentials;
-
-/**
- * This cannot be constructed directly. Instead, instances of this class should
- * be created using the factory functions in {@link grpc.credentials}
- * @constructor grpc.credentials~ChannelCredentials
- */
-var ChannelCredentials = grpc.ChannelCredentials;
-
-var Metadata = require('./metadata.js');
-
-var common = require('./common.js');
-
-var constants = require('./constants');
-
-var _ = require('lodash');
-
-/**
- * @external GoogleCredential
- * @see https://github.com/google/google-auth-library-nodejs
- */
-
-/**
- * Create an SSL Credentials object. If using a client-side certificate, both
- * the second and third arguments must be passed.
- * @memberof grpc.credentials
- * @alias grpc.credentials.createSsl
- * @kind function
- * @param {Buffer=} root_certs The root certificate data
- * @param {Buffer=} private_key The client certificate private key, if
- * applicable
- * @param {Buffer=} cert_chain The client certificate cert chain, if applicable
- * @return {grpc.credentials.ChannelCredentials} The SSL Credentials object
- */
-exports.createSsl = ChannelCredentials.createSsl;
-
-/**
- * @callback grpc.credentials~metadataCallback
- * @param {Error} error The error, if getting metadata failed
- * @param {grpc.Metadata} metadata The metadata
- */
-
-/**
- * @callback grpc.credentials~generateMetadata
- * @param {Object} params Parameters that can modify metadata generation
- * @param {string} params.service_url The URL of the service that the call is
- * going to
- * @param {grpc.credentials~metadataCallback} callback
- */
-
-/**
- * Create a gRPC credentials object from a metadata generation function. This
- * function gets the service URL and a callback as parameters. The error
- * passed to the callback can optionally have a 'code' value attached to it,
- * which corresponds to a status code that this library uses.
- * @memberof grpc.credentials
- * @alias grpc.credentials.createFromMetadataGenerator
- * @param {grpc.credentials~generateMetadata} metadata_generator The function
- * that generates metadata
- * @return {grpc.credentials.CallCredentials} The credentials object
- */
-exports.createFromMetadataGenerator = function(metadata_generator) {
- return CallCredentials.createFromPlugin(function(service_url, cb_data,
- callback) {
- metadata_generator({service_url: service_url}, function(error, metadata) {
- var code = constants.status.OK;
- var message = '';
- if (error) {
- message = error.message;
- if (error.hasOwnProperty('code') && _.isFinite(error.code)) {
- code = error.code;
- } else {
- code = constants.status.UNAUTHENTICATED;
- }
- if (!metadata) {
- metadata = new Metadata();
- }
- }
- callback(code, message, metadata._getCoreRepresentation(), cb_data);
- });
- });
-};
-
-/**
- * Create a gRPC credential from a Google credential object.
- * @memberof grpc.credentials
- * @alias grpc.credentials.createFromGoogleCredential
- * @param {external:GoogleCredential} google_credential The Google credential
- * object to use
- * @return {grpc.credentials.CallCredentials} The resulting credentials object
- */
-exports.createFromGoogleCredential = function(google_credential) {
- return exports.createFromMetadataGenerator(function(auth_context, callback) {
- var service_url = auth_context.service_url;
- google_credential.getRequestMetadata(service_url, function(err, header) {
- if (err) {
- common.log(constants.logVerbosity.INFO, 'Auth error:' + err);
- callback(err);
- return;
- }
- var metadata = new Metadata();
- metadata.add('authorization', header.Authorization);
- callback(null, metadata);
- });
- });
-};
-
-/**
- * Combine a ChannelCredentials with any number of CallCredentials into a single
- * ChannelCredentials object.
- * @memberof grpc.credentials
- * @alias grpc.credentials.combineChannelCredentials
- * @param {ChannelCredentials} channel_credential The ChannelCredentials to
- * start with
- * @param {...CallCredentials} credentials The CallCredentials to compose
- * @return ChannelCredentials A credentials object that combines all of the
- * input credentials
- */
-exports.combineChannelCredentials = function(channel_credential) {
- var current = channel_credential;
- for (var i = 1; i < arguments.length; i++) {
- current = current.compose(arguments[i]);
- }
- return current;
-};
-
-/**
- * Combine any number of CallCredentials into a single CallCredentials object
- * @memberof grpc.credentials
- * @alias grpc.credentials.combineCallCredentials
- * @param {...CallCredentials} credentials the CallCredentials to compose
- * @return CallCredentials A credentials object that combines all of the input
- * credentials
- */
-exports.combineCallCredentials = function() {
- var current = arguments[0];
- for (var i = 1; i < arguments.length; i++) {
- current = current.compose(arguments[i]);
- }
- return current;
-};
-
-/**
- * Create an insecure credentials object. This is used to create a channel that
- * does not use SSL. This cannot be composed with anything.
- * @memberof grpc.credentials
- * @alias grpc.credentials.createInsecure
- * @kind function
- * @return {ChannelCredentials} The insecure credentials object
- */
-exports.createInsecure = ChannelCredentials.createInsecure;
diff --git a/src/node/src/grpc_extension.js b/src/node/src/grpc_extension.js
deleted file mode 100644
index af43eacad2..0000000000
--- a/src/node/src/grpc_extension.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-/**
- * @module
- * @private
- */
-
-'use strict';
-
-var binary = require('node-pre-gyp/lib/pre-binding');
-var path = require('path');
-var binding_path =
- binary.find(path.resolve(path.join(__dirname, '../../../package.json')));
-var binding = require(binding_path);
-
-module.exports = binding;
diff --git a/src/node/src/metadata.js b/src/node/src/metadata.js
deleted file mode 100644
index 46f9e0fead..0000000000
--- a/src/node/src/metadata.js
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-var grpc = require('./grpc_extension');
-
-/**
- * Class for storing metadata. Keys are normalized to lowercase ASCII.
- * @memberof grpc
- * @constructor
- * @example
- * var metadata = new metadata_module.Metadata();
- * metadata.set('key1', 'value1');
- * metadata.add('key1', 'value2');
- * metadata.get('key1') // returns ['value1', 'value2']
- */
-function Metadata() {
- this._internal_repr = {};
-}
-
-function normalizeKey(key) {
- key = key.toLowerCase();
- if (grpc.metadataKeyIsLegal(key)) {
- return key;
- } else {
- throw new Error('Metadata key"' + key + '" contains illegal characters');
- }
-}
-
-function validate(key, value) {
- if (grpc.metadataKeyIsBinary(key)) {
- if (!(value instanceof Buffer)) {
- throw new Error('keys that end with \'-bin\' must have Buffer values');
- }
- } else {
- if (!_.isString(value)) {
- throw new Error(
- 'keys that don\'t end with \'-bin\' must have String values');
- }
- if (!grpc.metadataNonbinValueIsLegal(value)) {
- throw new Error('Metadata string value "' + value +
- '" contains illegal characters');
- }
- }
-}
-
-/**
- * Sets the given value for the given key, replacing any other values associated
- * with that key. Normalizes the key.
- * @param {String} key The key to set
- * @param {String|Buffer} value The value to set. Must be a buffer if and only
- * if the normalized key ends with '-bin'
- */
-Metadata.prototype.set = function(key, value) {
- key = normalizeKey(key);
- validate(key, value);
- this._internal_repr[key] = [value];
-};
-
-/**
- * Adds the given value for the given key. Normalizes the key.
- * @param {String} key The key to add to.
- * @param {String|Buffer} value The value to add. Must be a buffer if and only
- * if the normalized key ends with '-bin'
- */
-Metadata.prototype.add = function(key, value) {
- key = normalizeKey(key);
- validate(key, value);
- if (!this._internal_repr[key]) {
- this._internal_repr[key] = [];
- }
- this._internal_repr[key].push(value);
-};
-
-/**
- * Remove the given key and any associated values. Normalizes the key.
- * @param {String} key The key to remove
- */
-Metadata.prototype.remove = function(key) {
- key = normalizeKey(key);
- if (Object.prototype.hasOwnProperty.call(this._internal_repr, key)) {
- delete this._internal_repr[key];
- }
-};
-
-/**
- * Gets a list of all values associated with the key. Normalizes the key.
- * @param {String} key The key to get
- * @return {Array.<String|Buffer>} The values associated with that key
- */
-Metadata.prototype.get = function(key) {
- key = normalizeKey(key);
- if (Object.prototype.hasOwnProperty.call(this._internal_repr, key)) {
- return this._internal_repr[key];
- } else {
- return [];
- }
-};
-
-/**
- * Get a map of each key to a single associated value. This reflects the most
- * common way that people will want to see metadata.
- * @return {Object.<String,String|Buffer>} A key/value mapping of the metadata
- */
-Metadata.prototype.getMap = function() {
- var result = {};
- _.forOwn(this._internal_repr, function(values, key) {
- if(values.length > 0) {
- result[key] = values[0];
- }
- });
- return result;
-};
-
-/**
- * Clone the metadata object.
- * @return {Metadata} The new cloned object
- */
-Metadata.prototype.clone = function() {
- var copy = new Metadata();
- _.forOwn(this._internal_repr, function(value, key) {
- copy._internal_repr[key] = _.clone(value);
- });
- return copy;
-};
-
-/**
- * Gets the metadata in the format used by interal code. Intended for internal
- * use only. API stability is not guaranteed.
- * @private
- * @return {Object.<String, Array.<String|Buffer>>} The metadata
- */
-Metadata.prototype._getCoreRepresentation = function() {
- return this._internal_repr;
-};
-
-/**
- * Creates a Metadata object from a metadata map in the internal format.
- * Intended for internal use only. API stability is not guaranteed.
- * @private
- * @param {Object.<String, Array.<String|Buffer>>} The metadata
- * @return {Metadata} The new Metadata object
- */
-Metadata._fromCoreRepresentation = function(metadata) {
- var newMetadata = new Metadata();
- if (metadata) {
- _.forOwn(metadata, function(value, key) {
- newMetadata._internal_repr[key] = _.clone(value);
- });
- }
- return newMetadata;
-};
-
-module.exports = Metadata;
diff --git a/src/node/src/protobuf_js_5_common.js b/src/node/src/protobuf_js_5_common.js
deleted file mode 100644
index 541965fd0a..0000000000
--- a/src/node/src/protobuf_js_5_common.js
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-/**
- * @module
- * @private
- */
-
-'use strict';
-
-var _ = require('lodash');
-var client = require('./client');
-
-/**
- * Get a function that deserializes a specific type of protobuf.
- * @param {function()} cls The constructor of the message type to deserialize
- * @param {bool=} binaryAsBase64 Deserialize bytes fields as base64 strings
- * instead of Buffers. Defaults to false
- * @param {bool=} longsAsStrings Deserialize long values as strings instead of
- * objects. Defaults to true
- * @return {function(Buffer):cls} The deserialization function
- */
-exports.deserializeCls = function deserializeCls(cls, options) {
- /**
- * Deserialize a buffer to a message object
- * @param {Buffer} arg_buf The buffer to deserialize
- * @return {cls} The resulting object
- */
- return function deserialize(arg_buf) {
- // Convert to a native object with binary fields as Buffers (first argument)
- // and longs as strings (second argument)
- return cls.decode(arg_buf).toRaw(options.binaryAsBase64,
- options.longsAsStrings);
- };
-};
-
-var deserializeCls = exports.deserializeCls;
-
-/**
- * Get a function that serializes objects to a buffer by protobuf class.
- * @param {function()} Cls The constructor of the message type to serialize
- * @return {function(Cls):Buffer} The serialization function
- */
-exports.serializeCls = function serializeCls(Cls) {
- /**
- * Serialize an object to a Buffer
- * @param {Object} arg The object to serialize
- * @return {Buffer} The serialized object
- */
- return function serialize(arg) {
- return new Buffer(new Cls(arg).encode().toBuffer());
- };
-};
-
-var serializeCls = exports.serializeCls;
-
-/**
- * Get the fully qualified (dotted) name of a ProtoBuf.Reflect value.
- * @param {ProtoBuf.Reflect.Namespace} value The value to get the name of
- * @return {string} The fully qualified name of the value
- */
-exports.fullyQualifiedName = function fullyQualifiedName(value) {
- if (value === null || value === undefined) {
- return '';
- }
- var name = value.name;
- var parent_name = fullyQualifiedName(value.parent);
- if (parent_name !== '') {
- name = parent_name + '.' + name;
- }
- return name;
-};
-
-var fullyQualifiedName = exports.fullyQualifiedName;
-
-/**
- * Return a map from method names to method attributes for the service.
- * @param {ProtoBuf.Reflect.Service} service The service to get attributes for
- * @param {Object=} options Options to apply to these attributes
- * @return {Object} The attributes map
- */
-exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service,
- options) {
- var prefix = '/' + fullyQualifiedName(service) + '/';
- var binaryAsBase64, longsAsStrings;
- if (options) {
- binaryAsBase64 = options.binaryAsBase64;
- longsAsStrings = options.longsAsStrings;
- }
- /* This slightly awkward construction is used to make sure we only use
- lodash@3.10.1-compatible functions. A previous version used
- _.fromPairs, which would be cleaner, but was introduced in lodash
- version 4 */
- return _.zipObject(_.map(service.children, function(method) {
- return _.camelCase(method.name);
- }), _.map(service.children, function(method) {
- return {
- originalName: method.name,
- path: prefix + method.name,
- requestStream: method.requestStream,
- responseStream: method.responseStream,
- requestType: method.resolvedRequestType,
- responseType: method.resolvedResponseType,
- requestSerialize: serializeCls(method.resolvedRequestType.build()),
- requestDeserialize: deserializeCls(method.resolvedRequestType.build(),
- options),
- responseSerialize: serializeCls(method.resolvedResponseType.build()),
- responseDeserialize: deserializeCls(method.resolvedResponseType.build(),
- options)
- };
- }));
-};
-
-var getProtobufServiceAttrs = exports.getProtobufServiceAttrs;
-
-/**
- * Load a gRPC object from an existing ProtoBuf.Reflect object.
- * @param {ProtoBuf.Reflect.Namespace} value The ProtoBuf object to load.
- * @param {Object=} options Options to apply to the loaded object
- * @return {Object<string, *>} The resulting gRPC object
- */
-exports.loadObject = function loadObject(value, options) {
- var result = {};
- if (!value) {
- return value;
- }
- if (value.hasOwnProperty('ns')) {
- return loadObject(value.ns, options);
- }
- if (value.className === 'Namespace') {
- _.each(value.children, function(child) {
- result[child.name] = loadObject(child, options);
- });
- return result;
- } else if (value.className === 'Service') {
- return client.makeClientConstructor(getProtobufServiceAttrs(value, options),
- options);
- } else if (value.className === 'Message' || value.className === 'Enum') {
- return value.build();
- } else {
- return value;
- }
-};
-
-/**
- * The primary purpose of this method is to distinguish between reflection
- * objects from different versions of ProtoBuf.js. This is just a heuristic,
- * checking for properties that are (currently) specific to this version of
- * ProtoBuf.js
- * @param {Object} obj The object to check
- * @return {boolean} Whether the object appears to be a Protobuf.js 5
- * ReflectionObject
- */
-exports.isProbablyProtobufJs5 = function isProbablyProtobufJs5(obj) {
- return _.isArray(obj.children) && (typeof obj.build === 'function');
-};
diff --git a/src/node/src/protobuf_js_6_common.js b/src/node/src/protobuf_js_6_common.js
deleted file mode 100644
index 0f07251677..0000000000
--- a/src/node/src/protobuf_js_6_common.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-/**
- * @module
- * @private
- */
-
-'use strict';
-
-var _ = require('lodash');
-var client = require('./client');
-
-/**
- * Get a function that deserializes a specific type of protobuf.
- * @param {function()} cls The constructor of the message type to deserialize
- * @param {bool=} binaryAsBase64 Deserialize bytes fields as base64 strings
- * instead of Buffers. Defaults to false
- * @param {bool=} longsAsStrings Deserialize long values as strings instead of
- * objects. Defaults to true
- * @return {function(Buffer):cls} The deserialization function
- */
-exports.deserializeCls = function deserializeCls(cls, options) {
- var conversion_options = {
- defaults: true,
- bytes: options.binaryAsBase64 ? String : Buffer,
- longs: options.longsAsStrings ? String : null,
- enums: options.enumsAsStrings ? String : null,
- oneofs: true
- };
- /**
- * Deserialize a buffer to a message object
- * @param {Buffer} arg_buf The buffer to deserialize
- * @return {cls} The resulting object
- */
- return function deserialize(arg_buf) {
- return cls.toObject(cls.decode(arg_buf), conversion_options);
- };
-};
-
-var deserializeCls = exports.deserializeCls;
-
-/**
- * Get a function that serializes objects to a buffer by protobuf class.
- * @param {function()} Cls The constructor of the message type to serialize
- * @return {function(Cls):Buffer} The serialization function
- */
-exports.serializeCls = function serializeCls(cls) {
- /**
- * Serialize an object to a Buffer
- * @param {Object} arg The object to serialize
- * @return {Buffer} The serialized object
- */
- return function serialize(arg) {
- var message = cls.fromObject(arg);
- return cls.encode(message).finish();
- };
-};
-
-var serializeCls = exports.serializeCls;
-
-/**
- * Get the fully qualified (dotted) name of a ProtoBuf.Reflect value.
- * @param {ProtoBuf.ReflectionObject} value The value to get the name of
- * @return {string} The fully qualified name of the value
- */
-exports.fullyQualifiedName = function fullyQualifiedName(value) {
- if (value === null || value === undefined) {
- return '';
- }
- var name = value.name;
- var parent_fqn = fullyQualifiedName(value.parent);
- if (parent_fqn !== '') {
- name = parent_fqn + '.' + name;
- }
- return name;
-};
-
-var fullyQualifiedName = exports.fullyQualifiedName;
-
-/**
- * Return a map from method names to method attributes for the service.
- * @param {ProtoBuf.Service} service The service to get attributes for
- * @param {Object=} options Options to apply to these attributes
- * @return {Object} The attributes map
- */
-exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service,
- options) {
- var prefix = '/' + fullyQualifiedName(service) + '/';
- service.resolveAll();
- return _.zipObject(_.map(service.methods, function(method) {
- return _.camelCase(method.name);
- }), _.map(service.methods, function(method) {
- return {
- originalName: method.name,
- path: prefix + method.name,
- requestStream: !!method.requestStream,
- responseStream: !!method.responseStream,
- requestType: method.resolvedRequestType,
- responseType: method.resolvedResponseType,
- requestSerialize: serializeCls(method.resolvedRequestType),
- requestDeserialize: deserializeCls(method.resolvedRequestType, options),
- responseSerialize: serializeCls(method.resolvedResponseType),
- responseDeserialize: deserializeCls(method.resolvedResponseType, options)
- };
- }));
-};
-
-var getProtobufServiceAttrs = exports.getProtobufServiceAttrs;
-
-exports.loadObject = function loadObject(value, options) {
- var result = {};
- if (!value) {
- return value;
- }
- if (value.hasOwnProperty('methods')) {
- // It's a service object
- var service_attrs = getProtobufServiceAttrs(value, options);
- return client.makeClientConstructor(service_attrs);
- }
-
- if (value.hasOwnProperty('nested')) {
- // It's a namespace or root object
- _.each(value.nested, function(nested, name) {
- result[name] = loadObject(nested, options);
- });
- return result;
- }
-
- // Otherwise, it's not something we need to change
- return value;
-};
-
-/**
- * The primary purpose of this method is to distinguish between reflection
- * objects from different versions of ProtoBuf.js. This is just a heuristic,
- * checking for properties that are (currently) specific to this version of
- * ProtoBuf.js
- * @param {Object} obj The object to check
- * @return {boolean} Whether the object appears to be a Protobuf.js 6
- * ReflectionObject
- */
-exports.isProbablyProtobufJs6 = function isProbablyProtobufJs6(obj) {
- return (typeof obj.root === 'object') && (typeof obj.resolve === 'function');
-};
diff --git a/src/node/src/server.js b/src/node/src/server.js
deleted file mode 100644
index 8b7c0b6862..0000000000
--- a/src/node/src/server.js
+++ /dev/null
@@ -1,965 +0,0 @@
-/**
- * @license
- * 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.
- *
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-var grpc = require('./grpc_extension');
-
-var common = require('./common');
-
-var Metadata = require('./metadata');
-
-var constants = require('./constants');
-
-var stream = require('stream');
-
-var Readable = stream.Readable;
-var Writable = stream.Writable;
-var Duplex = stream.Duplex;
-var util = require('util');
-
-var EventEmitter = require('events').EventEmitter;
-
-/**
- * Handle an error on a call by sending it as a status
- * @private
- * @param {grpc.internal~Call} call The call to send the error on
- * @param {(Object|Error)} error The error object
- */
-function handleError(call, error) {
- var statusMetadata = new Metadata();
- var status = {
- code: constants.status.UNKNOWN,
- details: 'Unknown Error'
- };
- if (error.hasOwnProperty('message')) {
- status.details = error.message;
- }
- if (error.hasOwnProperty('code')) {
- status.code = error.code;
- if (error.hasOwnProperty('details')) {
- status.details = error.details;
- }
- }
- if (error.hasOwnProperty('metadata')) {
- statusMetadata = error.metadata;
- }
- status.metadata = statusMetadata._getCoreRepresentation();
- var error_batch = {};
- if (!call.metadataSent) {
- error_batch[grpc.opType.SEND_INITIAL_METADATA] =
- (new Metadata())._getCoreRepresentation();
- }
- error_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
- call.startBatch(error_batch, function(){});
-}
-
-/**
- * Send a response to a unary or client streaming call.
- * @private
- * @param {grpc.Call} call The call to respond on
- * @param {*} value The value to respond with
- * @param {grpc~serialize} serialize Serialization function for the
- * response
- * @param {grpc.Metadata=} metadata Optional trailing metadata to send with
- * status
- * @param {number=} [flags=0] Flags for modifying how the message is sent.
- */
-function sendUnaryResponse(call, value, serialize, metadata, flags) {
- var end_batch = {};
- var statusMetadata = new Metadata();
- var status = {
- code: constants.status.OK,
- details: 'OK'
- };
- if (metadata) {
- statusMetadata = metadata;
- }
- var message;
- try {
- message = serialize(value);
- } catch (e) {
- e.code = constants.status.INTERNAL;
- handleError(call, e);
- return;
- }
- status.metadata = statusMetadata._getCoreRepresentation();
- if (!call.metadataSent) {
- end_batch[grpc.opType.SEND_INITIAL_METADATA] =
- (new Metadata())._getCoreRepresentation();
- call.metadataSent = true;
- }
- message.grpcWriteFlags = flags;
- end_batch[grpc.opType.SEND_MESSAGE] = message;
- end_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
- call.startBatch(end_batch, function (){});
-}
-
-/**
- * Initialize a writable stream. This is used for both the writable and duplex
- * stream constructors.
- * @private
- * @param {Writable} stream The stream to set up
- * @param {function(*):Buffer=} Serialization function for responses
- */
-function setUpWritable(stream, serialize) {
- stream.finished = false;
- stream.status = {
- code : constants.status.OK,
- details : 'OK',
- metadata : new Metadata()
- };
- stream.serialize = common.wrapIgnoreNull(serialize);
- function sendStatus() {
- var batch = {};
- if (!stream.call.metadataSent) {
- stream.call.metadataSent = true;
- batch[grpc.opType.SEND_INITIAL_METADATA] =
- (new Metadata())._getCoreRepresentation();
- }
-
- if (stream.status.metadata) {
- stream.status.metadata = stream.status.metadata._getCoreRepresentation();
- }
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = stream.status;
- stream.call.startBatch(batch, function(){});
- }
- stream.on('finish', sendStatus);
- /**
- * Set the pending status to a given error status. If the error does not have
- * code or details properties, the code will be set to grpc.status.UNKNOWN
- * and the details will be set to 'Unknown Error'.
- * @param {Error} err The error object
- */
- function setStatus(err) {
- var code = constants.status.UNKNOWN;
- var details = 'Unknown Error';
- var metadata = new Metadata();
- if (err.hasOwnProperty('message')) {
- details = err.message;
- }
- if (err.hasOwnProperty('code')) {
- code = err.code;
- if (err.hasOwnProperty('details')) {
- details = err.details;
- }
- }
- if (err.hasOwnProperty('metadata')) {
- metadata = err.metadata;
- }
- stream.status = {code: code, details: details, metadata: metadata};
- }
- /**
- * Terminate the call. This includes indicating that reads are done, draining
- * all pending writes, and sending the given error as a status
- * @param {Error} err The error object
- * @this GrpcServerStream
- */
- function terminateCall(err) {
- // Drain readable data
- setStatus(err);
- stream.end();
- }
- stream.on('error', terminateCall);
- /**
- * Override of Writable#end method that allows for sending metadata with a
- * success status.
- * @param {Metadata=} metadata Metadata to send with the status
- */
- stream.end = function(metadata) {
- if (metadata) {
- stream.status.metadata = metadata;
- }
- Writable.prototype.end.call(this);
- };
-}
-
-/**
- * Initialize a readable stream. This is used for both the readable and duplex
- * stream constructors.
- * @private
- * @param {Readable} stream The stream to initialize
- * @param {grpc~deserialize} deserialize Deserialization function for
- * incoming data.
- */
-function setUpReadable(stream, deserialize) {
- stream.deserialize = common.wrapIgnoreNull(deserialize);
- stream.finished = false;
- stream.reading = false;
-
- stream.terminate = function() {
- stream.finished = true;
- stream.on('data', function() {});
- };
-
- stream.on('cancelled', function() {
- stream.terminate();
- });
-}
-
-/**
- * Emitted when the call has been cancelled. After this has been emitted, the
- * call's `cancelled` property will be set to `true`.
- * @event grpc~ServerUnaryCall~cancelled
- */
-
-util.inherits(ServerUnaryCall, EventEmitter);
-
-/**
- * An EventEmitter. Used for unary calls.
- * @constructor grpc~ServerUnaryCall
- * @extends external:EventEmitter
- * @param {grpc.internal~Call} call The call object associated with the request
- * @param {grpc.Metadata} metadata The request metadata from the client
- */
-function ServerUnaryCall(call, metadata) {
- EventEmitter.call(this);
- this.call = call;
- /**
- * Indicates if the call has been cancelled
- * @member {boolean} grpc~ServerUnaryCall#cancelled
- */
- this.cancelled = false;
- /**
- * The request metadata from the client
- * @member {grpc.Metadata} grpc~ServerUnaryCall#metadata
- */
- this.metadata = metadata;
- /**
- * The request message from the client
- * @member {*} grpc~ServerUnaryCall#request
- */
- this.request = undefined;
-}
-
-/**
- * Emitted when the call has been cancelled. After this has been emitted, the
- * call's `cancelled` property will be set to `true`.
- * @event grpc~ServerWritableStream~cancelled
- */
-
-util.inherits(ServerWritableStream, Writable);
-
-/**
- * A stream that the server can write to. Used for calls that are streaming from
- * the server side.
- * @constructor grpc~ServerWritableStream
- * @extends external:Writable
- * @borrows grpc~ServerUnaryCall#sendMetadata as
- * grpc~ServerWritableStream#sendMetadata
- * @borrows grpc~ServerUnaryCall#getPeer as grpc~ServerWritableStream#getPeer
- * @param {grpc.internal~Call} call The call object to send data with
- * @param {grpc.Metadata} metadata The request metadata from the client
- * @param {grpc~serialize} serialize Serialization function for writes
- */
-function ServerWritableStream(call, metadata, serialize) {
- Writable.call(this, {objectMode: true});
- this.call = call;
-
- this.finished = false;
- setUpWritable(this, serialize);
- /**
- * Indicates if the call has been cancelled
- * @member {boolean} grpc~ServerWritableStream#cancelled
- */
- this.cancelled = false;
- /**
- * The request metadata from the client
- * @member {grpc.Metadata} grpc~ServerWritableStream#metadata
- */
- this.metadata = metadata;
- /**
- * The request message from the client
- * @member {*} grpc~ServerWritableStream#request
- */
- this.request = undefined;
-}
-
-/**
- * Start writing a chunk of data. This is an implementation of a method required
- * for implementing stream.Writable.
- * @private
- * @param {Buffer} chunk The chunk of data to write
- * @param {string} encoding Used to pass write flags
- * @param {function(Error=)} callback Callback to indicate that the write is
- * complete
- */
-function _write(chunk, encoding, callback) {
- /* jshint validthis: true */
- var batch = {};
- var self = this;
- var message;
- try {
- message = this.serialize(chunk);
- } catch (e) {
- e.code = constants.status.INTERNAL;
- callback(e);
- return;
- }
- if (!this.call.metadataSent) {
- batch[grpc.opType.SEND_INITIAL_METADATA] =
- (new Metadata())._getCoreRepresentation();
- this.call.metadataSent = true;
- }
- if (_.isFinite(encoding)) {
- /* Attach the encoding if it is a finite number. This is the closest we
- * can get to checking that it is valid flags */
- message.grpcWriteFlags = encoding;
- }
- batch[grpc.opType.SEND_MESSAGE] = message;
- this.call.startBatch(batch, function(err, value) {
- if (err) {
- self.emit('error', err);
- return;
- }
- callback();
- });
-}
-
-ServerWritableStream.prototype._write = _write;
-
-/**
- * Emitted when the call has been cancelled. After this has been emitted, the
- * call's `cancelled` property will be set to `true`.
- * @event grpc~ServerReadableStream~cancelled
- */
-
-util.inherits(ServerReadableStream, Readable);
-
-/**
- * A stream that the server can read from. Used for calls that are streaming
- * from the client side.
- * @constructor grpc~ServerReadableStream
- * @extends external:Readable
- * @borrows grpc~ServerUnaryCall#sendMetadata as
- * grpc~ServerReadableStream#sendMetadata
- * @borrows grpc~ServerUnaryCall#getPeer as grpc~ServerReadableStream#getPeer
- * @param {grpc.internal~Call} call The call object to read data with
- * @param {grpc.Metadata} metadata The request metadata from the client
- * @param {grpc~deserialize} deserialize Deserialization function for reads
- */
-function ServerReadableStream(call, metadata, deserialize) {
- Readable.call(this, {objectMode: true});
- this.call = call;
- setUpReadable(this, deserialize);
- /**
- * Indicates if the call has been cancelled
- * @member {boolean} grpc~ServerReadableStream#cancelled
- */
- this.cancelled = false;
- /**
- * The request metadata from the client
- * @member {grpc.Metadata} grpc~ServerReadableStream#metadata
- */
- this.metadata = metadata;
-}
-
-/**
- * Start reading from the gRPC data source. This is an implementation of a
- * method required for implementing stream.Readable
- * @access private
- * @param {number} size Ignored
- */
-function _read(size) {
- /* jshint validthis: true */
- var self = this;
- /**
- * Callback to be called when a READ event is received. Pushes the data onto
- * the read queue and starts reading again if applicable
- * @param {grpc.Event} event READ event object
- */
- function readCallback(err, event) {
- if (err) {
- self.terminate();
- return;
- }
- if (self.finished) {
- self.push(null);
- return;
- }
- var data = event.read;
- var deserialized;
- try {
- deserialized = self.deserialize(data);
- } catch (e) {
- e.code = constants.status.INTERNAL;
- self.emit('error', e);
- return;
- }
- if (self.push(deserialized) && data !== null) {
- var read_batch = {};
- read_batch[grpc.opType.RECV_MESSAGE] = true;
- self.call.startBatch(read_batch, readCallback);
- } else {
- self.reading = false;
- }
- }
- if (self.finished) {
- self.push(null);
- } else {
- if (!self.reading) {
- self.reading = true;
- var batch = {};
- batch[grpc.opType.RECV_MESSAGE] = true;
- self.call.startBatch(batch, readCallback);
- }
- }
-}
-
-ServerReadableStream.prototype._read = _read;
-
-/**
- * Emitted when the call has been cancelled. After this has been emitted, the
- * call's `cancelled` property will be set to `true`.
- * @event grpc~ServerDuplexStream~cancelled
- */
-
-util.inherits(ServerDuplexStream, Duplex);
-
-/**
- * A stream that the server can read from or write to. Used for calls with
- * duplex streaming.
- * @constructor grpc~ServerDuplexStream
- * @extends external:Duplex
- * @borrows grpc~ServerUnaryCall#sendMetadata as
- * grpc~ServerDuplexStream#sendMetadata
- * @borrows grpc~ServerUnaryCall#getPeer as grpc~ServerDuplexStream#getPeer
- * @param {grpc.internal~Call} call Call object to proxy
- * @param {grpc.Metadata} metadata The request metadata from the client
- * @param {grpc~serialize} serialize Serialization function for requests
- * @param {grpc~deserialize} deserialize Deserialization function for
- * responses
- */
-function ServerDuplexStream(call, metadata, serialize, deserialize) {
- Duplex.call(this, {objectMode: true});
- this.call = call;
- setUpWritable(this, serialize);
- setUpReadable(this, deserialize);
- /**
- * Indicates if the call has been cancelled
- * @member {boolean} grpc~ServerReadableStream#cancelled
- */
- this.cancelled = false;
- /**
- * The request metadata from the client
- * @member {grpc.Metadata} grpc~ServerReadableStream#metadata
- */
- this.metadata = metadata;
-}
-
-ServerDuplexStream.prototype._read = _read;
-ServerDuplexStream.prototype._write = _write;
-
-/**
- * Send the initial metadata for a writable stream.
- * @alias grpc~ServerUnaryCall#sendMetadata
- * @param {Metadata} responseMetadata Metadata to send
- */
-function sendMetadata(responseMetadata) {
- /* jshint validthis: true */
- var self = this;
- if (!this.call.metadataSent) {
- this.call.metadataSent = true;
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] =
- responseMetadata._getCoreRepresentation();
- this.call.startBatch(batch, function(err) {
- if (err) {
- self.emit('error', err);
- return;
- }
- });
- }
-}
-
-ServerUnaryCall.prototype.sendMetadata = sendMetadata;
-ServerWritableStream.prototype.sendMetadata = sendMetadata;
-ServerReadableStream.prototype.sendMetadata = sendMetadata;
-ServerDuplexStream.prototype.sendMetadata = sendMetadata;
-
-/**
- * Get the endpoint this call/stream is connected to.
- * @alias grpc~ServerUnaryCall#getPeer
- * @return {string} The URI of the endpoint
- */
-function getPeer() {
- /* jshint validthis: true */
- return this.call.getPeer();
-}
-
-ServerUnaryCall.prototype.getPeer = getPeer;
-ServerReadableStream.prototype.getPeer = getPeer;
-ServerWritableStream.prototype.getPeer = getPeer;
-ServerDuplexStream.prototype.getPeer = getPeer;
-
-/**
- * Wait for the client to close, then emit a cancelled event if the client
- * cancelled.
- * @private
- */
-function waitForCancel() {
- /* jshint validthis: true */
- var self = this;
- var cancel_batch = {};
- cancel_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
- self.call.startBatch(cancel_batch, function(err, result) {
- if (err) {
- self.emit('error', err);
- }
- if (result.cancelled) {
- self.cancelled = true;
- self.emit('cancelled');
- }
- });
-}
-
-ServerUnaryCall.prototype.waitForCancel = waitForCancel;
-ServerReadableStream.prototype.waitForCancel = waitForCancel;
-ServerWritableStream.prototype.waitForCancel = waitForCancel;
-ServerDuplexStream.prototype.waitForCancel = waitForCancel;
-
-/**
- * Callback function passed to server handlers that handle methods with unary
- * responses.
- * @callback grpc.Server~sendUnaryData
- * @param {grpc~ServiceError} error An error, if the call failed
- * @param {*} value The response value. Must be a valid argument to the
- * `responseSerialize` method of the method that is being handled
- * @param {grpc.Metadata=} trailer Trailing metadata to send, if applicable
- * @param {grpc.writeFlags=} flags Flags to modify writing the response
- */
-
-/**
- * User-provided method to handle unary requests on a server
- * @callback grpc.Server~handleUnaryCall
- * @param {grpc~ServerUnaryCall} call The call object
- * @param {grpc.Server~sendUnaryData} callback The callback to call to respond
- * to the request
- */
-
-/**
- * Fully handle a unary call
- * @private
- * @param {grpc.internal~Call} call The call to handle
- * @param {Object} handler Request handler object for the method that was called
- * @param {grpc~Server.handleUnaryCall} handler.func The handler function
- * @param {grpc~deserialize} handler.deserialize The deserialization function
- * for request data
- * @param {grpc~serialize} handler.serialize The serialization function for
- * response data
- * @param {grpc.Metadata} metadata Metadata from the client
- */
-function handleUnary(call, handler, metadata) {
- var emitter = new ServerUnaryCall(call, metadata);
- emitter.on('error', function(error) {
- handleError(call, error);
- });
- emitter.waitForCancel();
- var batch = {};
- batch[grpc.opType.RECV_MESSAGE] = true;
- call.startBatch(batch, function(err, result) {
- if (err) {
- handleError(call, err);
- return;
- }
- try {
- emitter.request = handler.deserialize(result.read);
- } catch (e) {
- e.code = constants.status.INTERNAL;
- handleError(call, e);
- return;
- }
- if (emitter.cancelled) {
- return;
- }
- handler.func(emitter, function sendUnaryData(err, value, trailer, flags) {
- if (err) {
- if (trailer) {
- err.metadata = trailer;
- }
- handleError(call, err);
- } else {
- sendUnaryResponse(call, value, handler.serialize, trailer, flags);
- }
- });
- });
-}
-
-/**
- * User provided method to handle server streaming methods on the server.
- * @callback grpc.Server~handleServerStreamingCall
- * @param {grpc~ServerWritableStream} call The call object
- */
-
-/**
- * Fully handle a server streaming call
- * @private
- * @param {grpc.internal~Call} call The call to handle
- * @param {Object} handler Request handler object for the method that was called
- * @param {grpc~Server.handleServerStreamingCall} handler.func The handler
- * function
- * @param {grpc~deserialize} handler.deserialize The deserialization function
- * for request data
- * @param {grpc~serialize} handler.serialize The serialization function for
- * response data
- * @param {grpc.Metadata} metadata Metadata from the client
- */
-function handleServerStreaming(call, handler, metadata) {
- var stream = new ServerWritableStream(call, metadata, handler.serialize);
- stream.waitForCancel();
- var batch = {};
- batch[grpc.opType.RECV_MESSAGE] = true;
- call.startBatch(batch, function(err, result) {
- if (err) {
- stream.emit('error', err);
- return;
- }
- try {
- stream.request = handler.deserialize(result.read);
- } catch (e) {
- e.code = constants.status.INTERNAL;
- stream.emit('error', e);
- return;
- }
- handler.func(stream);
- });
-}
-
-/**
- * User provided method to handle client streaming methods on the server.
- * @callback grpc.Server~handleClientStreamingCall
- * @param {grpc~ServerReadableStream} call The call object
- * @param {grpc.Server~sendUnaryData} callback The callback to call to respond
- * to the request
- */
-
-/**
- * Fully handle a client streaming call
- * @access private
- * @param {grpc.internal~Call} call The call to handle
- * @param {Object} handler Request handler object for the method that was called
- * @param {grpc~Server.handleClientStreamingCall} handler.func The handler
- * function
- * @param {grpc~deserialize} handler.deserialize The deserialization function
- * for request data
- * @param {grpc~serialize} handler.serialize The serialization function for
- * response data
- * @param {grpc.Metadata} metadata Metadata from the client
- */
-function handleClientStreaming(call, handler, metadata) {
- var stream = new ServerReadableStream(call, metadata, handler.deserialize);
- stream.on('error', function(error) {
- handleError(call, error);
- });
- stream.waitForCancel();
- handler.func(stream, function(err, value, trailer, flags) {
- stream.terminate();
- if (err) {
- if (trailer) {
- err.metadata = trailer;
- }
- handleError(call, err);
- } else {
- sendUnaryResponse(call, value, handler.serialize, trailer, flags);
- }
- });
-}
-
-/**
- * User provided method to handle bidirectional streaming calls on the server.
- * @callback grpc.Server~handleBidiStreamingCall
- * @param {grpc~ServerDuplexStream} call The call object
- */
-
-/**
- * Fully handle a bidirectional streaming call
- * @private
- * @param {grpc.internal~Call} call The call to handle
- * @param {Object} handler Request handler object for the method that was called
- * @param {grpc~Server.handleBidiStreamingCall} handler.func The handler
- * function
- * @param {grpc~deserialize} handler.deserialize The deserialization function
- * for request data
- * @param {grpc~serialize} handler.serialize The serialization function for
- * response data
- * @param {Metadata} metadata Metadata from the client
- */
-function handleBidiStreaming(call, handler, metadata) {
- var stream = new ServerDuplexStream(call, metadata, handler.serialize,
- handler.deserialize);
- stream.waitForCancel();
- handler.func(stream);
-}
-
-var streamHandlers = {
- unary: handleUnary,
- server_stream: handleServerStreaming,
- client_stream: handleClientStreaming,
- bidi: handleBidiStreaming
-};
-
-/**
- * Constructs a server object that stores request handlers and delegates
- * incoming requests to those handlers
- * @memberof grpc
- * @constructor
- * @param {Object=} options Options that should be passed to the internal server
- * implementation
- * @example
- * var server = new grpc.Server();
- * server.addProtoService(protobuf_service_descriptor, service_implementation);
- * server.bind('address:port', server_credential);
- * server.start();
- */
-function Server(options) {
- this.handlers = {};
- var server = new grpc.Server(options);
- this._server = server;
- this.started = false;
-}
-
-/**
- * Start the server and begin handling requests
- */
-Server.prototype.start = function() {
- if (this.started) {
- throw new Error('Server is already running');
- }
- var self = this;
- this.started = true;
- this._server.start();
- /**
- * Handles the SERVER_RPC_NEW event. If there is a handler associated with
- * the requested method, use that handler to respond to the request. Then
- * wait for the next request
- * @param {grpc.internal~Event} event The event to handle with tag
- * SERVER_RPC_NEW
- */
- function handleNewCall(err, event) {
- if (err) {
- return;
- }
- var details = event.new_call;
- var call = details.call;
- var method = details.method;
- var metadata = Metadata._fromCoreRepresentation(details.metadata);
- if (method === null) {
- return;
- }
- self._server.requestCall(handleNewCall);
- var handler;
- if (self.handlers.hasOwnProperty(method)) {
- handler = self.handlers[method];
- } else {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] =
- (new Metadata())._getCoreRepresentation();
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- code: constants.status.UNIMPLEMENTED,
- details: '',
- metadata: {}
- };
- batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
- call.startBatch(batch, function() {});
- return;
- }
- streamHandlers[handler.type](call, handler, metadata);
- }
- this._server.requestCall(handleNewCall);
-};
-
-/**
- * Unified type for application handlers for all types of calls
- * @typedef {(grpc.Server~handleUnaryCall
- * |grpc.Server~handleClientStreamingCall
- * |grpc.Server~handleServerStreamingCall
- * |grpc.Server~handleBidiStreamingCall)} grpc.Server~handleCall
- */
-
-/**
- * Registers a handler to handle the named method. Fails if there already is
- * a handler for the given method. Returns true on success
- * @param {string} name The name of the method that the provided function should
- * handle/respond to.
- * @param {grpc.Server~handleCall} handler Function that takes a stream of
- * request values and returns a stream of response values
- * @param {grpc~serialize} serialize Serialization function for responses
- * @param {grpc~deserialize} deserialize Deserialization function for requests
- * @param {string} type The streaming type of method that this handles
- * @return {boolean} True if the handler was set. False if a handler was already
- * set for that name.
- */
-Server.prototype.register = function(name, handler, serialize, deserialize,
- type) {
- if (this.handlers.hasOwnProperty(name)) {
- return false;
- }
- this.handlers[name] = {
- func: handler,
- serialize: serialize,
- deserialize: deserialize,
- type: type
- };
- return true;
-};
-
-/**
- * Gracefully shuts down the server. The server will stop receiving new calls,
- * and any pending calls will complete. The callback will be called when all
- * pending calls have completed and the server is fully shut down. This method
- * is idempotent with itself and forceShutdown.
- * @param {function()} callback The shutdown complete callback
- */
-Server.prototype.tryShutdown = function(callback) {
- this._server.tryShutdown(callback);
-};
-
-/**
- * Forcibly shuts down the server. The server will stop receiving new calls
- * and cancel all pending calls. When it returns, the server has shut down.
- * This method is idempotent with itself and tryShutdown, and it will trigger
- * any outstanding tryShutdown callbacks.
- */
-Server.prototype.forceShutdown = function() {
- this._server.forceShutdown();
-};
-
-var unimplementedStatusResponse = {
- code: constants.status.UNIMPLEMENTED,
- details: 'The server does not implement this method'
-};
-
-var defaultHandler = {
- unary: function(call, callback) {
- callback(unimplementedStatusResponse);
- },
- client_stream: function(call, callback) {
- callback(unimplementedStatusResponse);
- },
- server_stream: function(call) {
- call.emit('error', unimplementedStatusResponse);
- },
- bidi: function(call) {
- call.emit('error', unimplementedStatusResponse);
- }
-};
-
-/**
- * Add a service to the server, with a corresponding implementation.
- * @param {grpc~ServiceDefinition} service The service descriptor
- * @param {Object<String, grpc.Server~handleCall>} implementation Map of method
- * names to method implementation for the provided service.
- */
-Server.prototype.addService = function(service, implementation) {
- if (!_.isObject(service) || !_.isObject(implementation)) {
- throw new Error('addService requires two objects as arguments');
- }
- if (_.keys(service).length === 0) {
- throw new Error('Cannot add an empty service to a server');
- }
- if (this.started) {
- throw new Error('Can\'t add a service to a started server.');
- }
- var self = this;
- _.forOwn(service, function(attrs, name) {
- var method_type;
- if (attrs.requestStream) {
- if (attrs.responseStream) {
- method_type = 'bidi';
- } else {
- method_type = 'client_stream';
- }
- } else {
- if (attrs.responseStream) {
- method_type = 'server_stream';
- } else {
- method_type = 'unary';
- }
- }
- var impl;
- if (implementation[name] === undefined) {
- /* Handle the case where the method is passed with the name exactly as
- written in the proto file, instead of using JavaScript function
- naming style */
- if (implementation[attrs.originalName] === undefined) {
- common.log(constants.logVerbosity.ERROR, 'Method handler ' + name +
- ' for ' + attrs.path + ' expected but not provided');
- impl = defaultHandler[method_type];
- } else {
- impl = _.bind(implementation[attrs.originalName], implementation);
- }
- } else {
- impl = _.bind(implementation[name], implementation);
- }
- var serialize = attrs.responseSerialize;
- var deserialize = attrs.requestDeserialize;
- var register_success = self.register(attrs.path, impl, serialize,
- deserialize, method_type);
- if (!register_success) {
- throw new Error('Method handler for ' + attrs.path +
- ' already provided.');
- }
- });
-};
-
-/**
- * Add a proto service to the server, with a corresponding implementation
- * @deprecated Use {@link grpc.Server#addService} instead
- * @param {Protobuf.Reflect.Service} service The proto service descriptor
- * @param {Object<String, grpc.Server~handleCall>} implementation Map of method
- * names to method implementation for the provided service.
- */
-Server.prototype.addProtoService = util.deprecate(function(service,
- implementation) {
- var options;
- var protobuf_js_5_common = require('./protobuf_js_5_common');
- var protobuf_js_6_common = require('./protobuf_js_6_common');
- if (protobuf_js_5_common.isProbablyProtobufJs5(service)) {
- options = _.defaults(service.grpc_options, common.defaultGrpcOptions);
- this.addService(
- protobuf_js_5_common.getProtobufServiceAttrs(service, options),
- implementation);
- } else if (protobuf_js_6_common.isProbablyProtobufJs6(service)) {
- options = _.defaults(service.grpc_options, common.defaultGrpcOptions);
- this.addService(
- protobuf_js_6_common.getProtobufServiceAttrs(service, options),
- implementation);
- } else {
- // We assume that this is a service attributes object
- this.addService(service, implementation);
- }
-}, 'Server#addProtoService: Use Server#addService instead');
-
-/**
- * Binds the server to the given port, with SSL disabled if creds is an
- * insecure credentials object
- * @param {string} port The port that the server should bind on, in the format
- * "address:port"
- * @param {grpc.ServerCredentials} creds Server credential object to be used for
- * SSL. Pass an insecure credentials object for an insecure port.
- */
-Server.prototype.bind = function(port, creds) {
- if (this.started) {
- throw new Error('Can\'t bind an already running server to an address');
- }
- return this._server.addHttp2Port(port, creds);
-};
-
-exports.Server = Server;
diff --git a/src/node/stress/metrics_client.js b/src/node/stress/metrics_client.js
deleted file mode 100644
index 6850601079..0000000000
--- a/src/node/stress/metrics_client.js
+++ /dev/null
@@ -1,46 +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.
- *
- */
-
-'use strict';
-
-var grpc = require('../../..');
-
-var proto = grpc.load(__dirname + '/../../proto/grpc/testing/metrics.proto');
-var metrics = proto.grpc.testing;
-
-function main() {
- var parseArgs = require('minimist');
- var argv = parseArgs(process.argv, {
- string: 'metrics_server_address',
- boolean: 'total_only'
- });
- var client = new metrics.MetricsService(argv.metrics_server_address,
- grpc.credentials.createInsecure());
- if (argv.total_only) {
- client.getGauge({name: 'qps'}, function(err, data) {
- console.log(data.name + ':', data.long_value);
- });
- } else {
- var call = client.getAllGauges({});
- call.on('data', function(data) {
- console.log(data.name + ':', data.long_value);
- });
- }
-}
-
-main();
diff --git a/src/node/stress/metrics_server.js b/src/node/stress/metrics_server.js
deleted file mode 100644
index 52ef27be5e..0000000000
--- a/src/node/stress/metrics_server.js
+++ /dev/null
@@ -1,72 +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.
- *
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-var grpc = require('../../..');
-
-var proto = grpc.load(__dirname + '/../../proto/grpc/testing/metrics.proto');
-var metrics = proto.grpc.testing;
-
-function getGauge(call, callback) {
- /* jshint validthis: true */
- // Should be bound to a MetricsServer object
- var name = call.request.name;
- if (this.gauges.hasOwnProperty(name)) {
- callback(null, _.assign({name: name}, this.gauges[name]()));
- } else {
- callback({code: grpc.status.NOT_FOUND,
- details: 'No such gauge: ' + name});
- }
-}
-
-function getAllGauges(call) {
- /* jshint validthis: true */
- // Should be bound to a MetricsServer object
- _.each(this.gauges, function(getter, name) {
- call.write(_.assign({name: name}, getter()));
- });
- call.end();
-}
-
-function MetricsServer(port) {
- var server = new grpc.Server();
- server.addService(metrics.MetricsService.service, {
- getGauge: _.bind(getGauge, this),
- getAllGauges: _.bind(getAllGauges, this)
- });
- server.bind('localhost:' + port, grpc.ServerCredentials.createInsecure());
- this.server = server;
- this.gauges = {};
-}
-
-MetricsServer.prototype.start = function() {
- this.server.start();
-}
-
-MetricsServer.prototype.registerGauge = function(name, getter) {
- this.gauges[name] = getter;
-};
-
-MetricsServer.prototype.shutdown = function() {
- this.server.forceShutdown();
-};
-
-module.exports = MetricsServer;
diff --git a/src/node/stress/stress_client.js b/src/node/stress/stress_client.js
deleted file mode 100644
index fc35d45f4d..0000000000
--- a/src/node/stress/stress_client.js
+++ /dev/null
@@ -1,111 +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.
- *
- */
-
-'use strict';
-
-var _ = require('lodash');
-
-var grpc = require('../../..');
-
-var interop_client = require('../interop/interop_client');
-var MetricsServer = require('./metrics_server');
-
-var running;
-
-var metrics_server;
-
-var start_time;
-var query_count;
-
-function makeCall(client, test_cases) {
- if (!running) {
- return;
- }
- var test_case = test_cases[_.random(test_cases.length - 1)];
- interop_client.test_cases[test_case].run(client, function() {
- query_count += 1;
- makeCall(client, test_cases);
- });
-}
-
-function makeCalls(client, test_cases, parallel_calls_per_channel) {
- _.times(parallel_calls_per_channel, function() {
- makeCall(client, test_cases);
- });
-}
-
-function getQps() {
- var diff = process.hrtime(start_time);
- var seconds = diff[0] + diff[1] / 1e9;
- return {long_value: query_count / seconds};
-}
-
-function start(server_addresses, test_cases, channels_per_server,
- parallel_calls_per_channel, metrics_port) {
- running = true;
- /* Assuming that we are not calling unimplemented_method. The client class
- * used by empty_unary is (currently) the client class used by every interop
- * test except unimplemented_method */
- var Client = interop_client.test_cases.empty_unary.Client;
- /* Make channels_per_server clients connecting to each server address */
- var channels = _.flatten(_.times(
- channels_per_server, _.partial(_.map, server_addresses, function(address) {
- return new Client(address, grpc.credentials.createInsecure());
- })));
- metrics_server = new MetricsServer(metrics_port);
- metrics_server.registerGauge('qps', getQps);
- start_time = process.hrtime();
- query_count = 0;
- _.each(channels, _.partial(makeCalls, _, test_cases,
- parallel_calls_per_channel));
- metrics_server.start();
-}
-
-function stop() {
- running = false;
- metrics_server.shutdown();
- console.log('QPS: ' + getQps().long_value);
-}
-
-function main() {
- var parseArgs = require('minimist');
- var argv = parseArgs(process.argv, {
- string: ['server_addresses', 'test_cases', 'metrics_port'],
- default: {'server_addresses': 'localhost:8080',
- 'test_duration_secs': -1,
- 'num_channels_per_server': 1,
- 'num_stubs_per_channel': 1,
- 'metrics_port': '8081'}
- });
- var server_addresses = argv.server_addresses.split(',');
- /* Generate an array of test cases, where the number of instances of each name
- * corresponds to the number given in the argument.
- * e.g. 'empty_unary:1,large_unary:2' =>
- * ['empty_unary', 'large_unary', 'large_unary'] */
- var test_cases = _.flatten(_.map(argv.test_cases.split(','), function(value) {
- var split = value.split(':');
- return _.times(split[1], _.constant(split[0]));
- }));
- start(server_addresses, test_cases, argv.num_channels_per_server,
- argv.num_stubs_per_channel, argv.metrics_port);
- if (argv.test_duration_secs > -1) {
- setTimeout(stop, argv.test_duration_secs * 1000);
- }
-}
-
-main();
diff --git a/src/node/test/async_test.js b/src/node/test/async_test.js
deleted file mode 100644
index b62b414973..0000000000
--- a/src/node/test/async_test.js
+++ /dev/null
@@ -1,83 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-
-var grpc = require('..');
-var math = grpc.load(__dirname + '/../../proto/math/math.proto').math;
-
-
-/**
- * Client to use to make requests to a running server.
- */
-var math_client;
-
-/**
- * Server to test against
- */
-var getServer = require('./math/math_server.js');
-
-var server = getServer();
-
-describe('Async functionality', function() {
- before(function(done) {
- var port_num = server.bind('0.0.0.0:0',
- grpc.ServerCredentials.createInsecure());
- server.start();
- math_client = new math.Math('localhost:' + port_num,
- grpc.credentials.createInsecure());
- done();
- });
- after(function() {
- grpc.closeClient(math_client);
- server.forceShutdown();
- });
- it('should not hang', function(done) {
- var chunkCount=0;
- var call = math_client.sum(function handleSumResult(err, value) {
- assert.ifError(err);
- assert.equal(value.num, chunkCount);
- });
-
- var path = require('path');
- var fs = require('fs');
- var fileToRead = path.join(__dirname, 'numbers.txt');
- var readStream = fs.createReadStream(fileToRead);
-
- readStream.once('readable', function () {
- readStream.on('data', function (chunk) {
- call.write({'num': 1});
- chunkCount += 1;
- });
-
- readStream.on('end', function () {
- call.end();
- });
-
- readStream.on('error', function (error) {
- });
- });
-
- call.on('status', function checkStatus(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- done();
- });
- });
-});
diff --git a/src/node/test/call_test.js b/src/node/test/call_test.js
deleted file mode 100644
index b5246c4f31..0000000000
--- a/src/node/test/call_test.js
+++ /dev/null
@@ -1,339 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var grpc = require('../src/grpc_extension');
-var constants = require('../src/constants');
-
-/**
- * Helper function to return an absolute deadline given a relative timeout in
- * seconds.
- * @param {number} timeout_secs The number of seconds to wait before timing out
- * @return {Date} A date timeout_secs in the future
- */
-function getDeadline(timeout_secs) {
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + timeout_secs);
- return deadline;
-}
-
-var insecureCreds = grpc.ChannelCredentials.createInsecure();
-
-describe('call', function() {
- var channel;
- var server;
- before(function() {
- server = new grpc.Server();
- var port = server.addHttp2Port('localhost:0',
- grpc.ServerCredentials.createInsecure());
- server.start();
- channel = new grpc.Channel('localhost:' + port, insecureCreds);
- });
- after(function() {
- server.forceShutdown();
- });
- describe('constructor', function() {
- it('should reject anything less than 3 arguments', function() {
- assert.throws(function() {
- new grpc.Call();
- }, TypeError);
- assert.throws(function() {
- new grpc.Call(channel);
- }, TypeError);
- assert.throws(function() {
- new grpc.Call(channel, 'method');
- }, TypeError);
- });
- it('should succeed with a Channel, a string, and a date or number',
- function() {
- assert.doesNotThrow(function() {
- new grpc.Call(channel, 'method', new Date());
- });
- assert.doesNotThrow(function() {
- new grpc.Call(channel, 'method', 0);
- });
- });
- it('should accept an optional fourth string parameter', function() {
- assert.doesNotThrow(function() {
- new grpc.Call(channel, 'method', new Date(), 'host_override');
- });
- });
- it('should fail with a closed channel', function() {
- var local_channel = new grpc.Channel('hostname', insecureCreds);
- local_channel.close();
- assert.throws(function() {
- new grpc.Call(channel, 'method');
- });
- });
- it('should fail with other types', function() {
- assert.throws(function() {
- new grpc.Call({}, 'method', 0);
- }, TypeError);
- assert.throws(function() {
- new grpc.Call(channel, null, 0);
- }, TypeError);
- assert.throws(function() {
- new grpc.Call(channel, 'method', 'now');
- }, TypeError);
- });
- it('should succeed without the new keyword', function() {
- assert.doesNotThrow(function() {
- var call = grpc.Call(channel, 'method', new Date());
- assert(call instanceof grpc.Call);
- });
- });
- });
- describe('deadline', function() {
- it('should time out immediately with negative deadline', function(done) {
- var call = new grpc.Call(channel, 'method', -Infinity);
- var batch = {};
- batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(batch, function(err, response) {
- assert.strictEqual(response.status.code,
- constants.status.DEADLINE_EXCEEDED);
- done();
- });
- });
- });
- describe('startBatch', function() {
- it('should fail without an object and a function', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- call.startBatch();
- });
- assert.throws(function() {
- call.startBatch({});
- });
- assert.throws(function() {
- call.startBatch(null, function(){});
- });
- });
- it('should succeed with an empty object', function(done) {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.doesNotThrow(function() {
- call.startBatch({}, function(err) {
- assert.ifError(err);
- done();
- });
- });
- });
- });
- describe('startBatch with metadata', function() {
- it('should succeed with a map of strings to string arrays', function(done) {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.doesNotThrow(function() {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] = {'key1': ['value1'],
- 'key2': ['value2']};
- call.startBatch(batch, function(err, resp) {
- assert.ifError(err);
- assert.deepEqual(resp, {'send_metadata': true});
- done();
- });
- });
- });
- it('should succeed with a map of strings to buffer arrays', function(done) {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.doesNotThrow(function() {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] = {
- 'key1-bin': [new Buffer('value1')],
- 'key2-bin': [new Buffer('value2')]
- };
- call.startBatch(batch, function(err, resp) {
- assert.ifError(err);
- assert.deepEqual(resp, {'send_metadata': true});
- done();
- });
- });
- });
- it('should fail with other parameter types', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] = undefined;
- call.startBatch(batch, function(){});
- });
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] = null;
- call.startBatch(batch, function(){});
- }, TypeError);
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] = 'value';
- call.startBatch(batch, function(){});
- }, TypeError);
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_INITIAL_METADATA] = 5;
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- });
- describe('startBatch with message', function() {
- it('should fail with null argument', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_MESSAGE] = null;
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail with numeric argument', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_MESSAGE] = 5;
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail with string argument', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_MESSAGE] = 'value';
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- });
- describe('startBatch with status', function() {
- it('should fail without a code', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- details: 'details string',
- metadata: {}
- };
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail without details', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- code: 0,
- metadata: {}
- };
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail without metadata', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- code: 0,
- details: 'details string'
- };
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail with incorrectly typed code argument', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- code: 'code string',
- details: 'details string',
- metadata: {}
- };
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail with incorrectly typed details argument', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- code: 0,
- details: 5,
- metadata: {}
- };
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- it('should fail with incorrectly typed metadata argument', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.throws(function() {
- var batch = {};
- batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- code: 0,
- details: 'details string',
- metadata: 'abc'
- };
- call.startBatch(batch, function(){});
- }, TypeError);
- });
- });
- describe('cancel', function() {
- it('should succeed', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.doesNotThrow(function() {
- call.cancel();
- });
- });
- });
- describe('cancelWithStatus', function() {
- it('should reject anything other than an integer and a string', function() {
- assert.doesNotThrow(function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- call.cancelWithStatus(1, 'details');
- });
- assert.throws(function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- call.cancelWithStatus();
- });
- assert.throws(function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- call.cancelWithStatus('');
- });
- assert.throws(function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- call.cancelWithStatus(5, {});
- });
- });
- it('should reject the OK status code', function() {
- assert.throws(function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- call.cancelWithStatus(0, 'details');
- });
- });
- it('should result in the call ending with a status', function(done) {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- var batch = {};
- batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(batch, function(err, response) {
- assert.strictEqual(response.status.code, 5);
- assert.strictEqual(response.status.details, 'details');
- done();
- });
- call.cancelWithStatus(5, 'details');
- });
- });
- describe('getPeer', function() {
- it('should return a string', function() {
- var call = new grpc.Call(channel, 'method', getDeadline(1));
- assert.strictEqual(typeof call.getPeer(), 'string');
- });
- });
-});
diff --git a/src/node/test/channel_test.js b/src/node/test/channel_test.js
deleted file mode 100644
index 373c5ac3c8..0000000000
--- a/src/node/test/channel_test.js
+++ /dev/null
@@ -1,181 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var grpc = require('../src/grpc_extension');
-
-/**
- * This is used for testing functions with multiple asynchronous calls that
- * can happen in different orders. This should be passed the number of async
- * function invocations that can occur last, and each of those should call this
- * function's return value
- * @param {function()} done The function that should be called when a test is
- * complete.
- * @param {number} count The number of calls to the resulting function if the
- * test passes.
- * @return {function()} The function that should be called at the end of each
- * sequence of asynchronous functions.
- */
-function multiDone(done, count) {
- return function() {
- count -= 1;
- if (count <= 0) {
- done();
- }
- };
-}
-var insecureCreds = grpc.ChannelCredentials.createInsecure();
-
-describe('channel', function() {
- describe('constructor', function() {
- it('should require a string for the first argument', function() {
- assert.doesNotThrow(function() {
- new grpc.Channel('hostname', insecureCreds);
- });
- assert.throws(function() {
- new grpc.Channel();
- }, TypeError);
- assert.throws(function() {
- new grpc.Channel(5);
- });
- });
- it('should require a credential for the second argument', function() {
- assert.doesNotThrow(function() {
- new grpc.Channel('hostname', insecureCreds);
- });
- assert.throws(function() {
- new grpc.Channel('hostname', 5);
- });
- assert.throws(function() {
- new grpc.Channel('hostname');
- });
- });
- it('should accept an object for the third argument', function() {
- assert.doesNotThrow(function() {
- new grpc.Channel('hostname', insecureCreds, {});
- });
- assert.throws(function() {
- new grpc.Channel('hostname', insecureCreds, 'abc');
- });
- });
- it('should only accept objects with string or int values', function() {
- assert.doesNotThrow(function() {
- new grpc.Channel('hostname', insecureCreds,{'key' : 'value'});
- });
- assert.doesNotThrow(function() {
- new grpc.Channel('hostname', insecureCreds, {'key' : 5});
- });
- assert.throws(function() {
- new grpc.Channel('hostname', insecureCreds, {'key' : null});
- });
- assert.throws(function() {
- new grpc.Channel('hostname', insecureCreds, {'key' : new Date()});
- });
- });
- it('should succeed without the new keyword', function() {
- assert.doesNotThrow(function() {
- var channel = grpc.Channel('hostname', insecureCreds);
- assert(channel instanceof grpc.Channel);
- });
- });
- });
- describe('close', function() {
- var channel;
- beforeEach(function() {
- channel = new grpc.Channel('hostname', insecureCreds, {});
- });
- it('should succeed silently', function() {
- assert.doesNotThrow(function() {
- channel.close();
- });
- });
- it('should be idempotent', function() {
- assert.doesNotThrow(function() {
- channel.close();
- channel.close();
- });
- });
- });
- describe('getTarget', function() {
- var channel;
- beforeEach(function() {
- channel = new grpc.Channel('hostname', insecureCreds, {});
- });
- it('should return a string', function() {
- assert.strictEqual(typeof channel.getTarget(), 'string');
- });
- });
- describe('getConnectivityState', function() {
- var channel;
- beforeEach(function() {
- channel = new grpc.Channel('hostname', insecureCreds, {});
- });
- it('should return IDLE for a new channel', function() {
- assert.strictEqual(channel.getConnectivityState(),
- grpc.connectivityState.IDLE);
- });
- });
- describe('watchConnectivityState', function() {
- var channel;
- beforeEach(function() {
- channel = new grpc.Channel('localhost', insecureCreds, {});
- });
- afterEach(function() {
- channel.close();
- });
- it('should time out if called alone', function(done) {
- var old_state = channel.getConnectivityState();
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + 1);
- channel.watchConnectivityState(old_state, deadline, function(err, value) {
- assert(err);
- done();
- });
- });
- it('should complete if a connection attempt is forced', function(done) {
- var old_state = channel.getConnectivityState();
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + 1);
- channel.watchConnectivityState(old_state, deadline, function(err, value) {
- assert.ifError(err);
- assert.notEqual(value.new_state, old_state);
- done();
- });
- channel.getConnectivityState(true);
- });
- it('should complete twice if called twice', function(done) {
- done = multiDone(done, 2);
- var old_state = channel.getConnectivityState();
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + 1);
- channel.watchConnectivityState(old_state, deadline, function(err, value) {
- assert.ifError(err);
- assert.notEqual(value.new_state, old_state);
- done();
- });
- channel.watchConnectivityState(old_state, deadline, function(err, value) {
- assert.ifError(err);
- assert.notEqual(value.new_state, old_state);
- done();
- });
- channel.getConnectivityState(true);
- });
- });
-});
diff --git a/src/node/test/common_test.js b/src/node/test/common_test.js
deleted file mode 100644
index d50c1a2761..0000000000
--- a/src/node/test/common_test.js
+++ /dev/null
@@ -1,190 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var _ = require('lodash');
-
-var common = require('../src/common');
-var protobuf_js_5_common = require('../src/protobuf_js_5_common');
-
-var serializeCls = protobuf_js_5_common.serializeCls;
-var deserializeCls = protobuf_js_5_common.deserializeCls;
-
-var ProtoBuf = require('protobufjs');
-
-var messages_proto = ProtoBuf.loadProtoFile(
- __dirname + '/test_messages.proto').build();
-
-var default_options = common.defaultGrpcOptions;
-
-describe('Proto message long int serialize and deserialize', function() {
- var longSerialize = serializeCls(messages_proto.LongValues);
- var longDeserialize = deserializeCls(messages_proto.LongValues,
- default_options);
- var pos_value = '314159265358979';
- var neg_value = '-27182818284590';
- it('should preserve positive int64 values', function() {
- var serialized = longSerialize({int_64: pos_value});
- assert.strictEqual(longDeserialize(serialized).int_64.toString(),
- pos_value);
- });
- it('should preserve negative int64 values', function() {
- var serialized = longSerialize({int_64: neg_value});
- assert.strictEqual(longDeserialize(serialized).int_64.toString(),
- neg_value);
- });
- it('should preserve uint64 values', function() {
- var serialized = longSerialize({uint_64: pos_value});
- assert.strictEqual(longDeserialize(serialized).uint_64.toString(),
- pos_value);
- });
- it('should preserve positive sint64 values', function() {
- var serialized = longSerialize({sint_64: pos_value});
- assert.strictEqual(longDeserialize(serialized).sint_64.toString(),
- pos_value);
- });
- it('should preserve negative sint64 values', function() {
- var serialized = longSerialize({sint_64: neg_value});
- assert.strictEqual(longDeserialize(serialized).sint_64.toString(),
- neg_value);
- });
- it('should preserve fixed64 values', function() {
- var serialized = longSerialize({fixed_64: pos_value});
- assert.strictEqual(longDeserialize(serialized).fixed_64.toString(),
- pos_value);
- });
- it('should preserve positive sfixed64 values', function() {
- var serialized = longSerialize({sfixed_64: pos_value});
- assert.strictEqual(longDeserialize(serialized).sfixed_64.toString(),
- pos_value);
- });
- it('should preserve negative sfixed64 values', function() {
- var serialized = longSerialize({sfixed_64: neg_value});
- assert.strictEqual(longDeserialize(serialized).sfixed_64.toString(),
- neg_value);
- });
- it('should deserialize as a number with the right option set', function() {
- var num_options = _.defaults({longsAsStrings: false}, default_options);
- var longNumDeserialize = deserializeCls(messages_proto.LongValues,
- num_options);
- var serialized = longSerialize({int_64: pos_value});
- assert.strictEqual(typeof longDeserialize(serialized).int_64, 'string');
- /* With the longsAsStrings option disabled, long values are represented as
- * objects with 3 keys: low, high, and unsigned */
- assert.strictEqual(typeof longNumDeserialize(serialized).int_64, 'object');
- });
-});
-describe('Proto message bytes serialize and deserialize', function() {
- var sequenceSerialize = serializeCls(messages_proto.SequenceValues);
- var sequenceDeserialize = deserializeCls(
- messages_proto.SequenceValues, default_options);
- var b64_options = _.defaults({binaryAsBase64: true}, default_options);
- var sequenceBase64Deserialize = deserializeCls(
- messages_proto.SequenceValues, b64_options);
- var buffer_val = new Buffer([0x69, 0xb7]);
- var base64_val = 'abc=';
- it('should preserve a buffer', function() {
- var serialized = sequenceSerialize({bytes_field: buffer_val});
- var deserialized = sequenceDeserialize(serialized);
- assert.strictEqual(deserialized.bytes_field.compare(buffer_val), 0);
- });
- it('should accept base64 encoded strings', function() {
- var serialized = sequenceSerialize({bytes_field: base64_val});
- var deserialized = sequenceDeserialize(serialized);
- assert.strictEqual(deserialized.bytes_field.compare(buffer_val), 0);
- });
- it('should output base64 encoded strings with an option set', function() {
- var serialized = sequenceSerialize({bytes_field: base64_val});
- var deserialized = sequenceBase64Deserialize(serialized);
- assert.strictEqual(deserialized.bytes_field, base64_val);
- });
- it('should serialize a repeated field as packed by default', function() {
- var expected_serialize = new Buffer([0x12, 0x01, 0x0a]);
- var serialized = sequenceSerialize({repeated_field: [10]});
- assert.strictEqual(expected_serialize.compare(serialized), 0);
- });
- // This tests a bug that was fixed in Protobuf.js 6
- it.skip('should deserialize packed or unpacked repeated', function() {
- var expectedDeserialize = {
- bytes_field: new Buffer(''),
- repeated_field: [10]
- };
- var packedSerialized = new Buffer([0x12, 0x01, 0x0a]);
- var unpackedSerialized = new Buffer([0x10, 0x0a]);
- var packedDeserialized;
- var unpackedDeserialized;
- assert.doesNotThrow(function() {
- packedDeserialized = sequenceDeserialize(packedSerialized);
- });
- assert.doesNotThrow(function() {
- unpackedDeserialized = sequenceDeserialize(unpackedSerialized);
- });
- assert.deepEqual(packedDeserialized, expectedDeserialize);
- assert.deepEqual(unpackedDeserialized, expectedDeserialize);
- });
-});
-// This tests a bug that was fixed in Protobuf.js 6
-describe.skip('Proto message oneof serialize and deserialize', function() {
- var oneofSerialize = serializeCls(messages_proto.OneOfValues);
- var oneofDeserialize = deserializeCls(
- messages_proto.OneOfValues, default_options);
- it('Should have idempotent round trips', function() {
- var test_message = {oneof_choice: 'int_choice', int_choice: 5};
- var serialized1 = oneofSerialize(test_message);
- var deserialized1 = oneofDeserialize(serialized1);
- assert.equal(deserialized1.int_choice, 5);
- var serialized2 = oneofSerialize(deserialized1);
- var deserialized2 = oneofDeserialize(serialized2);
- assert.deepEqual(deserialized1, deserialized2);
- });
- it('Should emit a property indicating which field was chosen', function() {
- var test_message1 = {oneof_choice: 'int_choice', int_choice: 5};
- var serialized1 = oneofSerialize(test_message1);
- var deserialized1 = oneofDeserialize(serialized1);
- assert.equal(deserialized1.oneof_choice, 'int_choice');
- var test_message2 = {oneof_choice: 'string_choice', string_choice: 'abc'};
- var serialized2 = oneofSerialize(test_message2);
- var deserialized2 = oneofDeserialize(serialized2);
- assert.equal(deserialized2.oneof_choice, 'string_choice');
- });
-});
-describe('Proto message enum serialize and deserialize', function() {
- var enumSerialize = serializeCls(messages_proto.EnumValues);
- var enumDeserialize = deserializeCls(
- messages_proto.EnumValues, default_options);
- var enumIntOptions = _.defaults({enumsAsStrings: false}, default_options);
- var enumIntDeserialize = deserializeCls(
- messages_proto.EnumValues, enumIntOptions);
- it('Should accept both names and numbers', function() {
- var nameSerialized = enumSerialize({enum_value: 'ONE'});
- var numberSerialized = enumSerialize({enum_value: 1});
- assert.strictEqual(messages_proto.TestEnum.ONE, 1);
- assert.deepEqual(enumDeserialize(nameSerialized),
- enumDeserialize(numberSerialized));
- });
- // This tests a bug that was fixed in Protobuf.js 6
- it.skip('Should correctly handle the enumsAsStrings option', function() {
- var serialized = enumSerialize({enum_value: 'TWO'});
- var nameDeserialized = enumDeserialize(serialized);
- var numberDeserialized = enumIntDeserialize(serialized);
- assert.deepEqual(nameDeserialized, {enum_value: 'TWO'});
- assert.deepEqual(numberDeserialized, {enum_value: 2});
- });
-});
diff --git a/src/node/test/credentials_test.js b/src/node/test/credentials_test.js
deleted file mode 100644
index 0ff838e7d0..0000000000
--- a/src/node/test/credentials_test.js
+++ /dev/null
@@ -1,452 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
-
-var grpc = require('..');
-
-/**
- * This is used for testing functions with multiple asynchronous calls that
- * can happen in different orders. This should be passed the number of async
- * function invocations that can occur last, and each of those should call this
- * function's return value
- * @param {function()} done The function that should be called when a test is
- * complete.
- * @param {number} count The number of calls to the resulting function if the
- * test passes.
- * @return {function()} The function that should be called at the end of each
- * sequence of asynchronous functions.
- */
-function multiDone(done, count) {
- return function() {
- count -= 1;
- if (count <= 0) {
- done();
- }
- };
-}
-
-var fakeSuccessfulGoogleCredentials = {
- getRequestMetadata: function(service_url, callback) {
- setTimeout(function() {
- callback(null, {Authorization: 'success'});
- }, 0);
- }
-};
-
-var fakeFailingGoogleCredentials = {
- getRequestMetadata: function(service_url, callback) {
- setTimeout(function() {
- // Google credentials currently adds string error codes to auth errors
- var error = new Error('Authentication failure');
- error.code = 'ENOENT';
- callback(error);
- }, 0);
- }
-};
-
-var key_data, pem_data, ca_data;
-
-before(function() {
- var key_path = path.join(__dirname, './data/server1.key');
- var pem_path = path.join(__dirname, './data/server1.pem');
- var ca_path = path.join(__dirname, '../test/data/ca.pem');
- key_data = fs.readFileSync(key_path);
- pem_data = fs.readFileSync(pem_path);
- ca_data = fs.readFileSync(ca_path);
-});
-
-describe('channel credentials', function() {
- describe('#createSsl', function() {
- it('works with no arguments', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.credentials.createSsl();
- });
- assert.notEqual(creds, null);
- });
- it('works with just one Buffer argument', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.credentials.createSsl(ca_data);
- });
- assert.notEqual(creds, null);
- });
- it('works with 3 Buffer arguments', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.credentials.createSsl(ca_data, key_data, pem_data);
- });
- assert.notEqual(creds, null);
- });
- it('works if the first argument is null', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.credentials.createSsl(null, key_data, pem_data);
- });
- assert.notEqual(creds, null);
- });
- it('fails if the first argument is a non-Buffer value', function() {
- assert.throws(function() {
- grpc.credentials.createSsl('test');
- }, TypeError);
- });
- it('fails if the second argument is a non-Buffer value', function() {
- assert.throws(function() {
- grpc.credentials.createSsl(null, 'test', pem_data);
- }, TypeError);
- });
- it('fails if the third argument is a non-Buffer value', function() {
- assert.throws(function() {
- grpc.credentials.createSsl(null, key_data, 'test');
- }, TypeError);
- });
- it('fails if only 1 of the last 2 arguments is provided', function() {
- assert.throws(function() {
- grpc.credentials.createSsl(null, key_data);
- });
- assert.throws(function() {
- grpc.credentials.createSsl(null, null, pem_data);
- });
- });
- });
-});
-
-describe('server credentials', function() {
- describe('#createSsl', function() {
- it('accepts a buffer and array as the first 2 arguments', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.ServerCredentials.createSsl(ca_data, []);
- });
- assert.notEqual(creds, null);
- });
- it('accepts a boolean as the third argument', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.ServerCredentials.createSsl(ca_data, [], true);
- });
- assert.notEqual(creds, null);
- });
- it('accepts an object with two buffers in the second argument', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: pem_data}]);
- });
- assert.notEqual(creds, null);
- });
- it('accepts multiple objects in the second argument', function() {
- var creds;
- assert.doesNotThrow(function() {
- creds = grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: pem_data},
- {private_key: key_data,
- cert_chain: pem_data}]);
- });
- assert.notEqual(creds, null);
- });
- it('fails if the second argument is not an Array', function() {
- assert.throws(function() {
- grpc.ServerCredentials.createSsl(ca_data, 'test');
- }, TypeError);
- });
- it('fails if the first argument is a non-Buffer value', function() {
- assert.throws(function() {
- grpc.ServerCredentials.createSsl('test', []);
- }, TypeError);
- });
- it('fails if the third argument is a non-boolean value', function() {
- assert.throws(function() {
- grpc.ServerCredentials.createSsl(ca_data, [], 'test');
- }, TypeError);
- });
- it('fails if the array elements are not objects', function() {
- assert.throws(function() {
- grpc.ServerCredentials.createSsl(ca_data, 'test');
- }, TypeError);
- });
- it('fails if the object does not have a Buffer private_key', function() {
- assert.throws(function() {
- grpc.ServerCredentials.createSsl(null,
- [{private_key: 'test',
- cert_chain: pem_data}]);
- }, TypeError);
- });
- it('fails if the object does not have a Buffer cert_chain', function() {
- assert.throws(function() {
- grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: 'test'}]);
- }, TypeError);
- });
- });
-});
-
-describe('client credentials', function() {
- var Client;
- var server;
- var port;
- var client_ssl_creds;
- var client_options = {};
- before(function() {
- var proto = grpc.load(__dirname + '/test_service.proto');
- server = new grpc.Server();
- server.addService(proto.TestService.service, {
- unary: function(call, cb) {
- call.sendMetadata(call.metadata);
- cb(null, {});
- },
- clientStream: function(stream, cb){
- stream.on('data', function(data) {});
- stream.on('end', function() {
- stream.sendMetadata(stream.metadata);
- cb(null, {});
- });
- },
- serverStream: function(stream) {
- stream.sendMetadata(stream.metadata);
- stream.end();
- },
- bidiStream: function(stream) {
- stream.on('data', function(data) {});
- stream.on('end', function() {
- stream.sendMetadata(stream.metadata);
- stream.end();
- });
- }
- });
- var creds = grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: pem_data}]);
- port = server.bind('localhost:0', creds);
- server.start();
-
- Client = proto.TestService;
- client_ssl_creds = grpc.credentials.createSsl(ca_data);
- var host_override = 'foo.test.google.fr';
- client_options['grpc.ssl_target_name_override'] = host_override;
- client_options['grpc.default_authority'] = host_override;
- });
- after(function() {
- server.forceShutdown();
- });
- it('Should accept SSL creds for a client', function(done) {
- var client = new Client('localhost:' + port, client_ssl_creds,
- client_options);
- client.unary({}, function(err, data) {
- assert.ifError(err);
- done();
- });
- });
- it('Should update metadata with SSL creds', function(done) {
- var metadataUpdater = function(service_url, callback) {
- var metadata = new grpc.Metadata();
- metadata.set('plugin_key', 'plugin_value');
- callback(null, metadata);
- };
- var creds = grpc.credentials.createFromMetadataGenerator(metadataUpdater);
- var combined_creds = grpc.credentials.combineChannelCredentials(
- client_ssl_creds, creds);
- var client = new Client('localhost:' + port, combined_creds,
- client_options);
- var call = client.unary({}, function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- });
- it('Should update metadata for two simultaneous calls', function(done) {
- done = multiDone(done, 2);
- var metadataUpdater = function(service_url, callback) {
- var metadata = new grpc.Metadata();
- metadata.set('plugin_key', 'plugin_value');
- callback(null, metadata);
- };
- var creds = grpc.credentials.createFromMetadataGenerator(metadataUpdater);
- var combined_creds = grpc.credentials.combineChannelCredentials(
- client_ssl_creds, creds);
- var client = new Client('localhost:' + port, combined_creds,
- client_options);
- var call = client.unary({}, function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- var call2 = client.unary({}, function(err, data) {
- assert.ifError(err);
- });
- call2.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- });
- it('should propagate errors that the updater emits', function(done) {
- var metadataUpdater = function(service_url, callback) {
- var error = new Error('Authentication error');
- error.code = grpc.status.UNAUTHENTICATED;
- callback(error);
- };
- var creds = grpc.credentials.createFromMetadataGenerator(metadataUpdater);
- var combined_creds = grpc.credentials.combineChannelCredentials(
- client_ssl_creds, creds);
- var client = new Client('localhost:' + port, combined_creds,
- client_options);
- client.unary({}, function(err, data) {
- assert(err);
- assert.strictEqual(err.message,
- 'Getting metadata from plugin failed with error: ' +
- 'Authentication error');
- assert.strictEqual(err.code, grpc.status.UNAUTHENTICATED);
- done();
- });
- });
- it('should successfully wrap a Google credential', function(done) {
- var creds = grpc.credentials.createFromGoogleCredential(
- fakeSuccessfulGoogleCredentials);
- var combined_creds = grpc.credentials.combineChannelCredentials(
- client_ssl_creds, creds);
- var client = new Client('localhost:' + port, combined_creds,
- client_options);
- var call = client.unary({}, function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('authorization'), ['success']);
- done();
- });
- });
- it('Should not add metadata with just SSL credentials', function(done) {
- // Tests idempotency of credentials composition
- var metadataUpdater = function(service_url, callback) {
- var metadata = new grpc.Metadata();
- metadata.set('plugin_key', 'plugin_value');
- callback(null, metadata);
- };
- var creds = grpc.credentials.createFromMetadataGenerator(metadataUpdater);
- grpc.credentials.combineChannelCredentials(client_ssl_creds, creds);
- var client = new Client('localhost:' + port, client_ssl_creds,
- client_options);
- var call = client.unary({}, function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), []);
- done();
- });
- });
- it('should get an error from a Google credential', function(done) {
- var creds = grpc.credentials.createFromGoogleCredential(
- fakeFailingGoogleCredentials);
- var combined_creds = grpc.credentials.combineChannelCredentials(
- client_ssl_creds, creds);
- var client = new Client('localhost:' + port, combined_creds,
- client_options);
- client.unary({}, function(err, data) {
- assert(err);
- assert.strictEqual(err.message,
- 'Getting metadata from plugin failed with error: ' +
- 'Authentication failure');
- done();
- });
- });
- describe('Per-rpc creds', function() {
- var client;
- var updater_creds;
- before(function() {
- client = new Client('localhost:' + port, client_ssl_creds,
- client_options);
- var metadataUpdater = function(service_url, callback) {
- var metadata = new grpc.Metadata();
- metadata.set('plugin_key', 'plugin_value');
- callback(null, metadata);
- };
- updater_creds = grpc.credentials.createFromMetadataGenerator(
- metadataUpdater);
- });
- it('Should update metadata on a unary call', function(done) {
- var call = client.unary({}, {credentials: updater_creds},
- function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- });
- it('should update metadata on a client streaming call', function(done) {
- var call = client.clientStream({credentials: updater_creds},
- function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- call.end();
- });
- it('should update metadata on a server streaming call', function(done) {
- var call = client.serverStream({}, {credentials: updater_creds});
- call.on('data', function() {});
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- });
- it('should update metadata on a bidi streaming call', function(done) {
- var call = client.bidiStream({credentials: updater_creds});
- call.on('data', function() {});
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- done();
- });
- call.end();
- });
- it('should be able to use multiple plugin credentials', function(done) {
- var altMetadataUpdater = function(service_url, callback) {
- var metadata = new grpc.Metadata();
- metadata.set('other_plugin_key', 'other_plugin_value');
- callback(null, metadata);
- };
- var alt_updater_creds = grpc.credentials.createFromMetadataGenerator(
- altMetadataUpdater);
- var combined_updater = grpc.credentials.combineCallCredentials(
- updater_creds, alt_updater_creds);
- var call = client.unary({}, {credentials: combined_updater},
- function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('plugin_key'), ['plugin_value']);
- assert.deepEqual(metadata.get('other_plugin_key'),
- ['other_plugin_value']);
- done();
- });
- });
- });
-});
diff --git a/src/node/test/data/README b/src/node/test/data/README
deleted file mode 100644
index 888d95b900..0000000000
--- a/src/node/test/data/README
+++ /dev/null
@@ -1 +0,0 @@
-CONFIRMEDTESTKEY
diff --git a/src/node/test/data/ca.pem b/src/node/test/data/ca.pem
deleted file mode 100644
index 6c8511a73c..0000000000
--- a/src/node/test/data/ca.pem
+++ /dev/null
@@ -1,15 +0,0 @@
------BEGIN CERTIFICATE-----
-MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
-Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
-YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
-BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
-+L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
-g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
-Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
-HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
-sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
-oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
-Dfcog5wrJytaQ6UA0wE=
------END CERTIFICATE-----
diff --git a/src/node/test/data/server1.key b/src/node/test/data/server1.key
deleted file mode 100644
index 143a5b8765..0000000000
--- a/src/node/test/data/server1.key
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOHDFScoLCVJpYDD
-M4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1BgzkWF+slf
-3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd9N8YwbBY
-AckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAECgYAn7qGnM2vbjJNBm0VZCkOkTIWm
-V10okw7EPJrdL2mkre9NasghNXbE1y5zDshx5Nt3KsazKOxTT8d0Jwh/3KbaN+YY
-tTCbKGW0pXDRBhwUHRcuRzScjli8Rih5UOCiZkhefUTcRb6xIhZJuQy71tjaSy0p
-dHZRmYyBYO2YEQ8xoQJBAPrJPhMBkzmEYFtyIEqAxQ/o/A6E+E4w8i+KM7nQCK7q
-K4JXzyXVAjLfyBZWHGM2uro/fjqPggGD6QH1qXCkI4MCQQDmdKeb2TrKRh5BY1LR
-81aJGKcJ2XbcDu6wMZK4oqWbTX2KiYn9GB0woM6nSr/Y6iy1u145YzYxEV/iMwff
-DJULAkB8B2MnyzOg0pNFJqBJuH29bKCcHa8gHJzqXhNO5lAlEbMK95p/P2Wi+4Hd
-aiEIAF1BF326QJcvYKmwSmrORp85AkAlSNxRJ50OWrfMZnBgzVjDx3xG6KsFQVk2
-ol6VhqL6dFgKUORFUWBvnKSyhjJxurlPEahV6oo6+A+mPhFY8eUvAkAZQyTdupP3
-XEFQKctGz+9+gKkemDp7LBBMEMBXrGTLPhpEfcjv/7KPdnFHYmhYeBTBnuVmTVWe
-F98XJ7tIFfJq
------END PRIVATE KEY-----
diff --git a/src/node/test/data/server1.pem b/src/node/test/data/server1.pem
deleted file mode 100644
index f3d43fcc5b..0000000000
--- a/src/node/test/data/server1.pem
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN CERTIFICATE-----
-MIICnDCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
-MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
-dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTA0MDIyMDI0WhcNMjUxMTAx
-MDIyMDI0WjBlMQswCQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNV
-BAcTB0NoaWNhZ28xFTATBgNVBAoTDEV4YW1wbGUsIENvLjEaMBgGA1UEAxQRKi50
-ZXN0Lmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOHDFSco
-LCVJpYDDM4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1Bg
-zkWF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd
-9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw
-CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy
-em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G
-CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6
-hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh
-y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8
------END CERTIFICATE-----
diff --git a/src/node/test/echo_service.proto b/src/node/test/echo_service.proto
deleted file mode 100644
index 0b27c8b16b..0000000000
--- a/src/node/test/echo_service.proto
+++ /dev/null
@@ -1,24 +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.
-
-syntax = "proto3";
-
-message EchoMessage {
- string value = 1;
- int32 value2 = 2;
-}
-
-service EchoService {
- rpc Echo (EchoMessage) returns (EchoMessage);
-}
diff --git a/src/node/test/end_to_end_test.js b/src/node/test/end_to_end_test.js
deleted file mode 100644
index c11dfa93c2..0000000000
--- a/src/node/test/end_to_end_test.js
+++ /dev/null
@@ -1,292 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var grpc = require('../src/grpc_extension');
-var constants = require('../src/constants');
-
-/**
- * This is used for testing functions with multiple asynchronous calls that
- * can happen in different orders. This should be passed the number of async
- * function invocations that can occur last, and each of those should call this
- * function's return value
- * @param {function()} done The function that should be called when a test is
- * complete.
- * @param {number} count The number of calls to the resulting function if the
- * test passes.
- * @return {function()} The function that should be called at the end of each
- * sequence of asynchronous functions.
- */
-function multiDone(done, count) {
- return function() {
- count -= 1;
- if (count <= 0) {
- done();
- }
- };
-}
-
-var insecureCreds = grpc.ChannelCredentials.createInsecure();
-
-describe('end-to-end', function() {
- var server;
- var channel;
- before(function() {
- server = new grpc.Server();
- var port_num = server.addHttp2Port('0.0.0.0:0',
- grpc.ServerCredentials.createInsecure());
- server.start();
- channel = new grpc.Channel('localhost:' + port_num, insecureCreds);
- });
- after(function() {
- server.forceShutdown();
- });
- it('should start and end a request without error', function(complete) {
- var done = multiDone(complete, 2);
- var status_text = 'xyz';
- var call = new grpc.Call(channel,
- 'dummy_method',
- Infinity);
- var client_batch = {};
- client_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
- client_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- client_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(client_batch, function(err, response) {
- assert.ifError(err);
- assert.deepEqual(response, {
- send_metadata: true,
- client_close: true,
- metadata: {},
- status: {
- code: constants.status.OK,
- details: status_text,
- metadata: {}
- }
- });
- done();
- });
-
- server.requestCall(function(err, call_details) {
- var new_call = call_details.new_call;
- assert.notEqual(new_call, null);
- var server_call = new_call.call;
- assert.notEqual(server_call, null);
- var server_batch = {};
- server_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
- server_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- metadata: {},
- code: constants.status.OK,
- details: status_text
- };
- server_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
- server_call.startBatch(server_batch, function(err, response) {
- assert.ifError(err);
- assert.deepEqual(response, {
- send_metadata: true,
- send_status: true,
- cancelled: false
- });
- done();
- });
- });
- });
- it('should successfully send and receive metadata', function(complete) {
- var done = multiDone(complete, 2);
- var status_text = 'xyz';
- var call = new grpc.Call(channel,
- 'dummy_method',
- Infinity);
- var client_batch = {};
- client_batch[grpc.opType.SEND_INITIAL_METADATA] = {
- client_key: ['client_value']
- };
- client_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- client_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(client_batch, function(err, response) {
- assert.ifError(err);
- assert.deepEqual(response,{
- send_metadata: true,
- client_close: true,
- metadata: {server_key: ['server_value']},
- status: {code: constants.status.OK,
- details: status_text,
- metadata: {}}
- });
- done();
- });
-
- server.requestCall(function(err, call_details) {
- var new_call = call_details.new_call;
- assert.notEqual(new_call, null);
- assert.strictEqual(new_call.metadata.client_key[0],
- 'client_value');
- var server_call = new_call.call;
- assert.notEqual(server_call, null);
- var server_batch = {};
- server_batch[grpc.opType.SEND_INITIAL_METADATA] = {
- server_key: ['server_value']
- };
- server_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- metadata: {},
- code: constants.status.OK,
- details: status_text
- };
- server_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
- server_call.startBatch(server_batch, function(err, response) {
- assert.ifError(err);
- assert.deepEqual(response, {
- send_metadata: true,
- send_status: true,
- cancelled: false
- });
- done();
- });
- });
- });
- it('should send and receive data without error', function(complete) {
- var req_text = 'client_request';
- var reply_text = 'server_response';
- var done = multiDone(complete, 2);
- var status_text = 'success';
- var call = new grpc.Call(channel,
- 'dummy_method',
- Infinity);
- var client_batch = {};
- client_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
- client_batch[grpc.opType.SEND_MESSAGE] = new Buffer(req_text);
- client_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- client_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- client_batch[grpc.opType.RECV_MESSAGE] = true;
- client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(client_batch, function(err, response) {
- assert.ifError(err);
- assert(response.send_metadata);
- assert(response.client_close);
- assert.deepEqual(response.metadata, {});
- assert(response.send_message);
- assert.strictEqual(response.read.toString(), reply_text);
- assert.deepEqual(response.status, {code: constants.status.OK,
- details: status_text,
- metadata: {}});
- done();
- });
-
- server.requestCall(function(err, call_details) {
- var new_call = call_details.new_call;
- assert.notEqual(new_call, null);
- var server_call = new_call.call;
- assert.notEqual(server_call, null);
- var server_batch = {};
- server_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
- server_batch[grpc.opType.RECV_MESSAGE] = true;
- server_call.startBatch(server_batch, function(err, response) {
- assert.ifError(err);
- assert(response.send_metadata);
- assert.strictEqual(response.read.toString(), req_text);
- var response_batch = {};
- response_batch[grpc.opType.SEND_MESSAGE] = new Buffer(reply_text);
- response_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- metadata: {},
- code: constants.status.OK,
- details: status_text
- };
- response_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
- server_call.startBatch(response_batch, function(err, response) {
- assert(response.send_status);
- assert(!response.cancelled);
- done();
- });
- });
- });
- });
- it('should send multiple messages', function(complete) {
- var done = multiDone(complete, 2);
- var requests = ['req1', 'req2'];
- var status_text = 'xyz';
- var call = new grpc.Call(channel,
- 'dummy_method',
- Infinity);
- var client_batch = {};
- client_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
- client_batch[grpc.opType.SEND_MESSAGE] = new Buffer(requests[0]);
- client_batch[grpc.opType.RECV_INITIAL_METADATA] = true;
- call.startBatch(client_batch, function(err, response) {
- assert.ifError(err);
- assert.deepEqual(response, {
- send_metadata: true,
- send_message: true,
- metadata: {}
- });
- var req2_batch = {};
- req2_batch[grpc.opType.SEND_MESSAGE] = new Buffer(requests[1]);
- req2_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
- req2_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
- call.startBatch(req2_batch, function(err, resp) {
- assert.ifError(err);
- assert.deepEqual(resp, {
- send_message: true,
- client_close: true,
- status: {
- code: constants.status.OK,
- details: status_text,
- metadata: {}
- }
- });
- done();
- });
- });
-
- server.requestCall(function(err, call_details) {
- var new_call = call_details.new_call;
- assert.notEqual(new_call, null);
- var server_call = new_call.call;
- assert.notEqual(server_call, null);
- var server_batch = {};
- server_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
- server_batch[grpc.opType.RECV_MESSAGE] = true;
- server_call.startBatch(server_batch, function(err, response) {
- assert.ifError(err);
- assert(response.send_metadata);
- assert.strictEqual(response.read.toString(), requests[0]);
- var snd_batch = {};
- snd_batch[grpc.opType.RECV_MESSAGE] = true;
- server_call.startBatch(snd_batch, function(err, response) {
- assert.ifError(err);
- assert.strictEqual(response.read.toString(), requests[1]);
- var end_batch = {};
- end_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
- end_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
- metadata: {},
- code: constants.status.OK,
- details: status_text
- };
- server_call.startBatch(end_batch, function(err, response) {
- assert.ifError(err);
- assert(response.send_status);
- assert(!response.cancelled);
- done();
- });
- });
- });
- });
- });
-});
diff --git a/src/node/test/health_test.js b/src/node/test/health_test.js
deleted file mode 100644
index dc008644d8..0000000000
--- a/src/node/test/health_test.js
+++ /dev/null
@@ -1,103 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-
-var health = require('../health_check/health');
-
-var health_messages = require('../health_check/v1/health_pb');
-
-var ServingStatus = health_messages.HealthCheckResponse.ServingStatus;
-
-var grpc = require('../');
-
-describe('Health Checking', function() {
- var statusMap = {
- '': ServingStatus.SERVING,
- 'grpc.test.TestServiceNotServing': ServingStatus.NOT_SERVING,
- 'grpc.test.TestServiceServing': ServingStatus.SERVING
- };
- var healthServer;
- var healthImpl;
- var healthClient;
- before(function() {
- healthServer = new grpc.Server();
- healthImpl = new health.Implementation(statusMap);
- healthServer.addService(health.service, healthImpl);
- var port_num = healthServer.bind('0.0.0.0:0',
- grpc.ServerCredentials.createInsecure());
- healthServer.start();
- healthClient = new health.Client('localhost:' + port_num,
- grpc.credentials.createInsecure());
- });
- after(function() {
- healthServer.forceShutdown();
- });
- it('should say an enabled service is SERVING', function(done) {
- var request = new health_messages.HealthCheckRequest();
- request.setService('');
- healthClient.check(request, function(err, response) {
- assert.ifError(err);
- assert.strictEqual(response.getStatus(), ServingStatus.SERVING);
- done();
- });
- });
- it('should say that a disabled service is NOT_SERVING', function(done) {
- var request = new health_messages.HealthCheckRequest();
- request.setService('grpc.test.TestServiceNotServing');
- healthClient.check(request, function(err, response) {
- assert.ifError(err);
- assert.strictEqual(response.getStatus(), ServingStatus.NOT_SERVING);
- done();
- });
- });
- it('should say that an enabled service is SERVING', function(done) {
- var request = new health_messages.HealthCheckRequest();
- request.setService('grpc.test.TestServiceServing');
- healthClient.check(request, function(err, response) {
- assert.ifError(err);
- assert.strictEqual(response.getStatus(), ServingStatus.SERVING);
- done();
- });
- });
- it('should get NOT_FOUND if the service is not registered', function(done) {
- var request = new health_messages.HealthCheckRequest();
- request.setService('not_registered');
- healthClient.check(request, function(err, response) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.NOT_FOUND);
- done();
- });
- });
- it('should get a different response if the status changes', function(done) {
- var request = new health_messages.HealthCheckRequest();
- request.setService('transient');
- healthClient.check(request, function(err, response) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.NOT_FOUND);
- healthImpl.setStatus('transient', ServingStatus.SERVING);
- healthClient.check(request, function(err, response) {
- assert.ifError(err);
- assert.strictEqual(response.getStatus(), ServingStatus.SERVING);
- done();
- });
- });
- });
-});
diff --git a/src/node/test/interop_sanity_test.js b/src/node/test/interop_sanity_test.js
deleted file mode 100644
index b3f65a0340..0000000000
--- a/src/node/test/interop_sanity_test.js
+++ /dev/null
@@ -1,94 +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.
- *
- */
-
-'use strict';
-
-var interop_server = require('../interop/interop_server.js');
-var interop_client = require('../interop/interop_client.js');
-
-var server;
-
-var port;
-
-var name_override = 'foo.test.google.fr';
-
-describe('Interop tests', function() {
- before(function(done) {
- var server_obj = interop_server.getServer(0, true);
- server = server_obj.server;
- server.start();
- port = 'localhost:' + server_obj.port;
- done();
- });
- after(function() {
- server.forceShutdown();
- });
- // This depends on not using a binary stream
- it('should pass empty_unary', function(done) {
- interop_client.runTest(port, name_override, 'empty_unary', true, true,
- done);
- });
- // This fails due to an unknown bug
- it('should pass large_unary', function(done) {
- interop_client.runTest(port, name_override, 'large_unary', true, true,
- done);
- });
- it('should pass client_streaming', function(done) {
- interop_client.runTest(port, name_override, 'client_streaming', true, true,
- done);
- });
- it('should pass server_streaming', function(done) {
- interop_client.runTest(port, name_override, 'server_streaming', true, true,
- done);
- });
- it('should pass ping_pong', function(done) {
- interop_client.runTest(port, name_override, 'ping_pong', true, true, done);
- });
- it('should pass empty_stream', function(done) {
- interop_client.runTest(port, name_override, 'empty_stream', true, true,
- done);
- });
- it('should pass cancel_after_begin', function(done) {
- interop_client.runTest(port, name_override, 'cancel_after_begin', true,
- true, done);
- });
- it('should pass cancel_after_first_response', function(done) {
- interop_client.runTest(port, name_override, 'cancel_after_first_response',
- true, true, done);
- });
- it('should pass timeout_on_sleeping_server', function(done) {
- interop_client.runTest(port, name_override, 'timeout_on_sleeping_server',
- true, true, done);
- });
- it('should pass custom_metadata', function(done) {
- interop_client.runTest(port, name_override, 'custom_metadata',
- true, true, done);
- });
- it('should pass status_code_and_message', function(done) {
- interop_client.runTest(port, name_override, 'status_code_and_message',
- true, true, done);
- });
- it('should pass unimplemented_service', function(done) {
- interop_client.runTest(port, name_override, 'unimplemented_service',
- true, true, done);
- });
- it('should pass unimplemented_method', function(done) {
- interop_client.runTest(port, name_override, 'unimplemented_method',
- true, true, done);
- });
-});
diff --git a/src/node/test/math/math_grpc_pb.js b/src/node/test/math/math_grpc_pb.js
deleted file mode 100644
index afd08a34aa..0000000000
--- a/src/node/test/math/math_grpc_pb.js
+++ /dev/null
@@ -1,125 +0,0 @@
-// GENERATED CODE -- DO NOT EDIT!
-
-// Original file comments:
-// 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.
-//
-'use strict';
-var grpc = require('grpc');
-var math_math_pb = require('../math/math_pb.js');
-
-function serialize_DivArgs(arg) {
- if (!(arg instanceof math_math_pb.DivArgs)) {
- throw new Error('Expected argument of type DivArgs');
- }
- return new Buffer(arg.serializeBinary());
-}
-
-function deserialize_DivArgs(buffer_arg) {
- return math_math_pb.DivArgs.deserializeBinary(new Uint8Array(buffer_arg));
-}
-
-function serialize_DivReply(arg) {
- if (!(arg instanceof math_math_pb.DivReply)) {
- throw new Error('Expected argument of type DivReply');
- }
- return new Buffer(arg.serializeBinary());
-}
-
-function deserialize_DivReply(buffer_arg) {
- return math_math_pb.DivReply.deserializeBinary(new Uint8Array(buffer_arg));
-}
-
-function serialize_FibArgs(arg) {
- if (!(arg instanceof math_math_pb.FibArgs)) {
- throw new Error('Expected argument of type FibArgs');
- }
- return new Buffer(arg.serializeBinary());
-}
-
-function deserialize_FibArgs(buffer_arg) {
- return math_math_pb.FibArgs.deserializeBinary(new Uint8Array(buffer_arg));
-}
-
-function serialize_Num(arg) {
- if (!(arg instanceof math_math_pb.Num)) {
- throw new Error('Expected argument of type Num');
- }
- return new Buffer(arg.serializeBinary());
-}
-
-function deserialize_Num(buffer_arg) {
- return math_math_pb.Num.deserializeBinary(new Uint8Array(buffer_arg));
-}
-
-
-var MathService = exports.MathService = {
- // Div divides args.dividend by args.divisor and returns the quotient and
- // remainder.
- div: {
- path: '/math.Math/Div',
- requestStream: false,
- responseStream: false,
- requestType: math_math_pb.DivArgs,
- responseType: math_math_pb.DivReply,
- requestSerialize: serialize_DivArgs,
- requestDeserialize: deserialize_DivArgs,
- responseSerialize: serialize_DivReply,
- responseDeserialize: deserialize_DivReply,
- },
- // DivMany accepts an arbitrary number of division args from the client stream
- // and sends back the results in the reply stream. The stream continues until
- // the client closes its end; the server does the same after sending all the
- // replies. The stream ends immediately if either end aborts.
- divMany: {
- path: '/math.Math/DivMany',
- requestStream: true,
- responseStream: true,
- requestType: math_math_pb.DivArgs,
- responseType: math_math_pb.DivReply,
- requestSerialize: serialize_DivArgs,
- requestDeserialize: deserialize_DivArgs,
- responseSerialize: serialize_DivReply,
- responseDeserialize: deserialize_DivReply,
- },
- // Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib
- // generates up to limit numbers; otherwise it continues until the call is
- // canceled. Unlike Fib above, Fib has no final FibReply.
- fib: {
- path: '/math.Math/Fib',
- requestStream: false,
- responseStream: true,
- requestType: math_math_pb.FibArgs,
- responseType: math_math_pb.Num,
- requestSerialize: serialize_FibArgs,
- requestDeserialize: deserialize_FibArgs,
- responseSerialize: serialize_Num,
- responseDeserialize: deserialize_Num,
- },
- // Sum sums a stream of numbers, returning the final result once the stream
- // is closed.
- sum: {
- path: '/math.Math/Sum',
- requestStream: true,
- responseStream: false,
- requestType: math_math_pb.Num,
- responseType: math_math_pb.Num,
- requestSerialize: serialize_Num,
- requestDeserialize: deserialize_Num,
- responseSerialize: serialize_Num,
- responseDeserialize: deserialize_Num,
- },
-};
-
-exports.MathClient = grpc.makeGenericClientConstructor(MathService);
diff --git a/src/node/test/math/math_pb.js b/src/node/test/math/math_pb.js
deleted file mode 100644
index ccc05c6e06..0000000000
--- a/src/node/test/math/math_pb.js
+++ /dev/null
@@ -1,866 +0,0 @@
-/**
- * @fileoverview
- * @enhanceable
- * @public
- */
-// GENERATED CODE -- DO NOT EDIT!
-
-var jspb = require('google-protobuf');
-var goog = jspb;
-var global = Function('return this')();
-
-goog.exportSymbol('proto.math.DivArgs', null, global);
-goog.exportSymbol('proto.math.DivReply', null, global);
-goog.exportSymbol('proto.math.FibArgs', null, global);
-goog.exportSymbol('proto.math.FibReply', null, global);
-goog.exportSymbol('proto.math.Num', null, global);
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.math.DivArgs = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.math.DivArgs, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.math.DivArgs.displayName = 'proto.math.DivArgs';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.math.DivArgs.prototype.toObject = function(opt_includeInstance) {
- return proto.math.DivArgs.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.math.DivArgs} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.math.DivArgs.toObject = function(includeInstance, msg) {
- var f, obj = {
- dividend: msg.getDividend(),
- divisor: msg.getDivisor()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.math.DivArgs}
- */
-proto.math.DivArgs.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.math.DivArgs;
- return proto.math.DivArgs.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.math.DivArgs} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.math.DivArgs}
- */
-proto.math.DivArgs.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setDividend(value);
- break;
- case 2:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setDivisor(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.math.DivArgs} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.DivArgs.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.math.DivArgs.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.DivArgs.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getDividend();
- if (f !== 0) {
- writer.writeInt64(
- 1,
- f
- );
- }
- f = this.getDivisor();
- if (f !== 0) {
- writer.writeInt64(
- 2,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.math.DivArgs} The clone.
- */
-proto.math.DivArgs.prototype.cloneMessage = function() {
- return /** @type {!proto.math.DivArgs} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional int64 dividend = 1;
- * @return {number}
- */
-proto.math.DivArgs.prototype.getDividend = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
-};
-
-
-/** @param {number} value */
-proto.math.DivArgs.prototype.setDividend = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-/**
- * optional int64 divisor = 2;
- * @return {number}
- */
-proto.math.DivArgs.prototype.getDivisor = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 2, 0));
-};
-
-
-/** @param {number} value */
-proto.math.DivArgs.prototype.setDivisor = function(value) {
- jspb.Message.setField(this, 2, value);
-};
-
-
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.math.DivReply = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.math.DivReply, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.math.DivReply.displayName = 'proto.math.DivReply';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.math.DivReply.prototype.toObject = function(opt_includeInstance) {
- return proto.math.DivReply.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.math.DivReply} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.math.DivReply.toObject = function(includeInstance, msg) {
- var f, obj = {
- quotient: msg.getQuotient(),
- remainder: msg.getRemainder()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.math.DivReply}
- */
-proto.math.DivReply.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.math.DivReply;
- return proto.math.DivReply.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.math.DivReply} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.math.DivReply}
- */
-proto.math.DivReply.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setQuotient(value);
- break;
- case 2:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setRemainder(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.math.DivReply} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.DivReply.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.math.DivReply.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.DivReply.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getQuotient();
- if (f !== 0) {
- writer.writeInt64(
- 1,
- f
- );
- }
- f = this.getRemainder();
- if (f !== 0) {
- writer.writeInt64(
- 2,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.math.DivReply} The clone.
- */
-proto.math.DivReply.prototype.cloneMessage = function() {
- return /** @type {!proto.math.DivReply} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional int64 quotient = 1;
- * @return {number}
- */
-proto.math.DivReply.prototype.getQuotient = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
-};
-
-
-/** @param {number} value */
-proto.math.DivReply.prototype.setQuotient = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-/**
- * optional int64 remainder = 2;
- * @return {number}
- */
-proto.math.DivReply.prototype.getRemainder = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 2, 0));
-};
-
-
-/** @param {number} value */
-proto.math.DivReply.prototype.setRemainder = function(value) {
- jspb.Message.setField(this, 2, value);
-};
-
-
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.math.FibArgs = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.math.FibArgs, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.math.FibArgs.displayName = 'proto.math.FibArgs';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.math.FibArgs.prototype.toObject = function(opt_includeInstance) {
- return proto.math.FibArgs.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.math.FibArgs} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.math.FibArgs.toObject = function(includeInstance, msg) {
- var f, obj = {
- limit: msg.getLimit()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.math.FibArgs}
- */
-proto.math.FibArgs.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.math.FibArgs;
- return proto.math.FibArgs.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.math.FibArgs} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.math.FibArgs}
- */
-proto.math.FibArgs.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setLimit(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.math.FibArgs} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.FibArgs.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.math.FibArgs.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.FibArgs.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getLimit();
- if (f !== 0) {
- writer.writeInt64(
- 1,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.math.FibArgs} The clone.
- */
-proto.math.FibArgs.prototype.cloneMessage = function() {
- return /** @type {!proto.math.FibArgs} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional int64 limit = 1;
- * @return {number}
- */
-proto.math.FibArgs.prototype.getLimit = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
-};
-
-
-/** @param {number} value */
-proto.math.FibArgs.prototype.setLimit = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.math.Num = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.math.Num, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.math.Num.displayName = 'proto.math.Num';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.math.Num.prototype.toObject = function(opt_includeInstance) {
- return proto.math.Num.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.math.Num} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.math.Num.toObject = function(includeInstance, msg) {
- var f, obj = {
- num: msg.getNum()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.math.Num}
- */
-proto.math.Num.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.math.Num;
- return proto.math.Num.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.math.Num} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.math.Num}
- */
-proto.math.Num.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setNum(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.math.Num} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.Num.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.math.Num.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.Num.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getNum();
- if (f !== 0) {
- writer.writeInt64(
- 1,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.math.Num} The clone.
- */
-proto.math.Num.prototype.cloneMessage = function() {
- return /** @type {!proto.math.Num} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional int64 num = 1;
- * @return {number}
- */
-proto.math.Num.prototype.getNum = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
-};
-
-
-/** @param {number} value */
-proto.math.Num.prototype.setNum = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-
-/**
- * Generated by JsPbCodeGenerator.
- * @param {Array=} opt_data Optional initial data array, typically from a
- * server response, or constructed directly in Javascript. The array is used
- * in place and becomes part of the constructed object. It is not cloned.
- * If no data is provided, the constructed object will be empty, but still
- * valid.
- * @extends {jspb.Message}
- * @constructor
- */
-proto.math.FibReply = function(opt_data) {
- jspb.Message.initialize(this, opt_data, 0, -1, null, null);
-};
-goog.inherits(proto.math.FibReply, jspb.Message);
-if (goog.DEBUG && !COMPILED) {
- proto.math.FibReply.displayName = 'proto.math.FibReply';
-}
-
-
-if (jspb.Message.GENERATE_TO_OBJECT) {
-/**
- * Creates an object representation of this proto suitable for use in Soy templates.
- * Field names that are reserved in JavaScript and will be renamed to pb_name.
- * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
- * For the list of reserved names please see:
- * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
- * @param {boolean=} opt_includeInstance Whether to include the JSPB instance
- * for transitional soy proto support: http://goto/soy-param-migration
- * @return {!Object}
- */
-proto.math.FibReply.prototype.toObject = function(opt_includeInstance) {
- return proto.math.FibReply.toObject(opt_includeInstance, this);
-};
-
-
-/**
- * Static version of the {@see toObject} method.
- * @param {boolean|undefined} includeInstance Whether to include the JSPB
- * instance for transitional soy proto support:
- * http://goto/soy-param-migration
- * @param {!proto.math.FibReply} msg The msg instance to transform.
- * @return {!Object}
- */
-proto.math.FibReply.toObject = function(includeInstance, msg) {
- var f, obj = {
- count: msg.getCount()
- };
-
- if (includeInstance) {
- obj.$jspbMessageInstance = msg;
- }
- return obj;
-};
-}
-
-
-/**
- * Deserializes binary data (in protobuf wire format).
- * @param {jspb.ByteSource} bytes The bytes to deserialize.
- * @return {!proto.math.FibReply}
- */
-proto.math.FibReply.deserializeBinary = function(bytes) {
- var reader = new jspb.BinaryReader(bytes);
- var msg = new proto.math.FibReply;
- return proto.math.FibReply.deserializeBinaryFromReader(msg, reader);
-};
-
-
-/**
- * Deserializes binary data (in protobuf wire format) from the
- * given reader into the given message object.
- * @param {!proto.math.FibReply} msg The message object to deserialize into.
- * @param {!jspb.BinaryReader} reader The BinaryReader to use.
- * @return {!proto.math.FibReply}
- */
-proto.math.FibReply.deserializeBinaryFromReader = function(msg, reader) {
- while (reader.nextField()) {
- if (reader.isEndGroup()) {
- break;
- }
- var field = reader.getFieldNumber();
- switch (field) {
- case 1:
- var value = /** @type {number} */ (reader.readInt64());
- msg.setCount(value);
- break;
- default:
- reader.skipField();
- break;
- }
- }
- return msg;
-};
-
-
-/**
- * Class method variant: serializes the given message to binary data
- * (in protobuf wire format), writing to the given BinaryWriter.
- * @param {!proto.math.FibReply} message
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.FibReply.serializeBinaryToWriter = function(message, writer) {
- message.serializeBinaryToWriter(writer);
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format).
- * @return {!Uint8Array}
- */
-proto.math.FibReply.prototype.serializeBinary = function() {
- var writer = new jspb.BinaryWriter();
- this.serializeBinaryToWriter(writer);
- return writer.getResultBuffer();
-};
-
-
-/**
- * Serializes the message to binary data (in protobuf wire format),
- * writing to the given BinaryWriter.
- * @param {!jspb.BinaryWriter} writer
- */
-proto.math.FibReply.prototype.serializeBinaryToWriter = function (writer) {
- var f = undefined;
- f = this.getCount();
- if (f !== 0) {
- writer.writeInt64(
- 1,
- f
- );
- }
-};
-
-
-/**
- * Creates a deep clone of this proto. No data is shared with the original.
- * @return {!proto.math.FibReply} The clone.
- */
-proto.math.FibReply.prototype.cloneMessage = function() {
- return /** @type {!proto.math.FibReply} */ (jspb.Message.cloneMessage(this));
-};
-
-
-/**
- * optional int64 count = 1;
- * @return {number}
- */
-proto.math.FibReply.prototype.getCount = function() {
- return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0));
-};
-
-
-/** @param {number} value */
-proto.math.FibReply.prototype.setCount = function(value) {
- jspb.Message.setField(this, 1, value);
-};
-
-
-goog.object.extend(exports, proto.math);
diff --git a/src/node/test/math/math_server.js b/src/node/test/math/math_server.js
deleted file mode 100644
index 4291ae18b4..0000000000
--- a/src/node/test/math/math_server.js
+++ /dev/null
@@ -1,124 +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.
- *
- */
-
-'use strict';
-
-var grpc = require('../..');
-var grpcMath = require('./math_grpc_pb');
-var math = require('./math_pb');
-
-/**
- * Server function for division. Provides the /Math/DivMany and /Math/Div
- * functions (Div is just DivMany with only one stream element). For each
- * DivArgs parameter, responds with a DivReply with the results of the division
- * @param {Object} call The object containing request and cancellation info
- * @param {function(Error, *)} cb Response callback
- */
-function mathDiv(call, cb) {
- var req = call.request;
- var divisor = req.getDivisor();
- var dividend = req.getDividend();
- // Unary + is explicit coersion to integer
- if (req.getDivisor() === 0) {
- cb(new Error('cannot divide by zero'));
- } else {
- var response = new math.DivReply();
- response.setQuotient(Math.floor(dividend / divisor));
- response.setRemainder(dividend % divisor);
- cb(null, response);
- }
-}
-
-/**
- * Server function for Fibonacci numbers. Provides the /Math/Fib function. Reads
- * a single parameter that indicates the number of responses, and then responds
- * with a stream of that many Fibonacci numbers.
- * @param {stream} stream The stream for sending responses.
- */
-function mathFib(stream) {
- // Here, call is a standard writable Node object Stream
- var previous = 0, current = 1;
- for (var i = 0; i < stream.request.getLimit(); i++) {
- var response = new math.Num();
- response.setNum(current);
- stream.write(response);
- var temp = current;
- current += previous;
- previous = temp;
- }
- stream.end();
-}
-
-/**
- * Server function for summation. Provides the /Math/Sum function. Reads a
- * stream of number parameters, then responds with their sum.
- * @param {stream} call The stream of arguments.
- * @param {function(Error, *)} cb Response callback
- */
-function mathSum(call, cb) {
- // Here, call is a standard readable Node object Stream
- var sum = 0;
- call.on('data', function(data) {
- sum += data.getNum();
- });
- call.on('end', function() {
- var response = new math.Num();
- response.setNum(sum);
- cb(null, response);
- });
-}
-
-function mathDivMany(stream) {
- stream.on('data', function(div_args) {
- var divisor = div_args.getDivisor();
- var dividend = div_args.getDividend();
- if (divisor === 0) {
- stream.emit('error', new Error('cannot divide by zero'));
- } else {
- var response = new math.DivReply();
- response.setQuotient(Math.floor(dividend / divisor));
- response.setRemainder(dividend % divisor);
- stream.write(response);
- }
- });
- stream.on('end', function() {
- stream.end();
- });
-}
-
-function getMathServer() {
- var server = new grpc.Server();
- server.addService(grpcMath.MathService, {
- div: mathDiv,
- fib: mathFib,
- sum: mathSum,
- divMany: mathDivMany
- });
- return server;
-}
-
-if (require.main === module) {
- var server = getMathServer();
- server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
- server.start();
-}
-
-/**
- * See docs for server
- */
-module.exports = getMathServer;
diff --git a/src/node/test/math_client_test.js b/src/node/test/math_client_test.js
deleted file mode 100644
index 11deda34f1..0000000000
--- a/src/node/test/math_client_test.js
+++ /dev/null
@@ -1,140 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-
-var grpc = require('..');
-var math = require('./math/math_pb');
-var MathClient = require('./math/math_grpc_pb').MathClient;
-
-/**
- * Client to use to make requests to a running server.
- */
-var math_client;
-
-/**
- * Server to test against
- */
-var getServer = require('./math/math_server.js');
-
-var server = getServer();
-
-describe('Math client', function() {
- before(function(done) {
- var port_num = server.bind('0.0.0.0:0',
- grpc.ServerCredentials.createInsecure());
- server.start();
- math_client = new MathClient('localhost:' + port_num,
- grpc.credentials.createInsecure());
- done();
- });
- after(function() {
- server.forceShutdown();
- });
- it('should handle a single request', function(done) {
- var arg = new math.DivArgs();
- arg.setDividend(7);
- arg.setDivisor(4);
- math_client.div(arg, function handleDivResult(err, value) {
- assert.ifError(err);
- assert.equal(value.getQuotient(), 1);
- assert.equal(value.getRemainder(), 3);
- done();
- });
- });
- it('should handle an error from a unary request', function(done) {
- var arg = new math.DivArgs();
- arg.setDividend(7);
- arg.setDivisor(0);
- math_client.div(arg, function handleDivResult(err, value) {
- assert(err);
- done();
- });
- });
- it('should handle a server streaming request', function(done) {
- var arg = new math.FibArgs();
- arg.setLimit(7);
- var call = math_client.fib(arg);
- var expected_results = [1, 1, 2, 3, 5, 8, 13];
- var next_expected = 0;
- call.on('data', function checkResponse(value) {
- assert.equal(value.getNum(), expected_results[next_expected]);
- next_expected += 1;
- });
- call.on('status', function checkStatus(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- done();
- });
- });
- it('should handle a client streaming request', function(done) {
- var call = math_client.sum(function handleSumResult(err, value) {
- assert.ifError(err);
- assert.equal(value.getNum(), 21);
- });
- for (var i = 0; i < 7; i++) {
- var arg = new math.Num();
- arg.setNum(i);
- call.write(arg);
- }
- call.end();
- call.on('status', function checkStatus(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- done();
- });
- });
- it('should handle a bidirectional streaming request', function(done) {
- function checkResponse(index, value) {
- assert.equal(value.getQuotient(), index);
- assert.equal(value.getRemainder(), 1);
- }
- var call = math_client.divMany();
- var response_index = 0;
- call.on('data', function(value) {
- checkResponse(response_index, value);
- response_index += 1;
- });
- for (var i = 0; i < 7; i++) {
- var arg = new math.DivArgs();
- arg.setDividend(2 * i + 1);
- arg.setDivisor(2);
- call.write(arg);
- }
- call.end();
- call.on('status', function checkStatus(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- done();
- });
- });
- it('should handle an error from a bidi request', function(done) {
- var call = math_client.divMany();
- call.on('data', function(value) {
- assert.fail(value, undefined, 'Unexpected data response on failing call',
- '!=');
- });
- var arg = new math.DivArgs();
- arg.setDividend(7);
- arg.setDivisor(0);
- call.write(arg);
- call.end();
- call.on('error', function checkStatus(status) {
- done();
- });
- });
-});
diff --git a/src/node/test/metadata_test.js b/src/node/test/metadata_test.js
deleted file mode 100644
index 4ba54e0aa0..0000000000
--- a/src/node/test/metadata_test.js
+++ /dev/null
@@ -1,178 +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.
- *
- */
-
-'use strict';
-
-var Metadata = require('../src/metadata.js');
-
-var assert = require('assert');
-
-describe('Metadata', function() {
- var metadata;
- beforeEach(function() {
- metadata = new Metadata();
- });
- describe('#set', function() {
- it('Only accepts string values for non "-bin" keys', function() {
- assert.throws(function() {
- metadata.set('key', new Buffer('value'));
- });
- assert.doesNotThrow(function() {
- metadata.set('key', 'value');
- });
- });
- it('Only accepts Buffer values for "-bin" keys', function() {
- assert.throws(function() {
- metadata.set('key-bin', 'value');
- });
- assert.doesNotThrow(function() {
- metadata.set('key-bin', new Buffer('value'));
- });
- });
- it('Rejects invalid keys', function() {
- assert.throws(function() {
- metadata.set('key$', 'value');
- });
- assert.throws(function() {
- metadata.set('', 'value');
- });
- });
- it('Rejects values with non-ASCII characters', function() {
- assert.throws(function() {
- metadata.set('key', 'résumé');
- });
- });
- it('Saves values that can be retrieved', function() {
- metadata.set('key', 'value');
- assert.deepEqual(metadata.get('key'), ['value']);
- });
- it('Overwrites previous values', function() {
- metadata.set('key', 'value1');
- metadata.set('key', 'value2');
- assert.deepEqual(metadata.get('key'), ['value2']);
- });
- it('Normalizes keys', function() {
- metadata.set('Key', 'value1');
- assert.deepEqual(metadata.get('key'), ['value1']);
- metadata.set('KEY', 'value2');
- assert.deepEqual(metadata.get('key'), ['value2']);
- });
- });
- describe('#add', function() {
- it('Only accepts string values for non "-bin" keys', function() {
- assert.throws(function() {
- metadata.add('key', new Buffer('value'));
- });
- assert.doesNotThrow(function() {
- metadata.add('key', 'value');
- });
- });
- it('Only accepts Buffer values for "-bin" keys', function() {
- assert.throws(function() {
- metadata.add('key-bin', 'value');
- });
- assert.doesNotThrow(function() {
- metadata.add('key-bin', new Buffer('value'));
- });
- });
- it('Rejects invalid keys', function() {
- assert.throws(function() {
- metadata.add('key$', 'value');
- });
- assert.throws(function() {
- metadata.add('', 'value');
- });
- });
- it('Saves values that can be retrieved', function() {
- metadata.add('key', 'value');
- assert.deepEqual(metadata.get('key'), ['value']);
- });
- it('Combines with previous values', function() {
- metadata.add('key', 'value1');
- metadata.add('key', 'value2');
- assert.deepEqual(metadata.get('key'), ['value1', 'value2']);
- });
- it('Normalizes keys', function() {
- metadata.add('Key', 'value1');
- assert.deepEqual(metadata.get('key'), ['value1']);
- metadata.add('KEY', 'value2');
- assert.deepEqual(metadata.get('key'), ['value1', 'value2']);
- });
- });
- describe('#remove', function() {
- it('clears values from a key', function() {
- metadata.add('key', 'value');
- metadata.remove('key');
- assert.deepEqual(metadata.get('key'), []);
- });
- it('Normalizes keys', function() {
- metadata.add('key', 'value');
- metadata.remove('KEY');
- assert.deepEqual(metadata.get('key'), []);
- });
- });
- describe('#get', function() {
- beforeEach(function() {
- metadata.add('key', 'value1');
- metadata.add('key', 'value2');
- metadata.add('key-bin', new Buffer('value'));
- });
- it('gets all values associated with a key', function() {
- assert.deepEqual(metadata.get('key'), ['value1', 'value2']);
- });
- it('Normalizes keys', function() {
- assert.deepEqual(metadata.get('KEY'), ['value1', 'value2']);
- });
- it('returns an empty list for non-existent keys', function() {
- assert.deepEqual(metadata.get('non-existent-key'), []);
- });
- it('returns Buffers for "-bin" keys', function() {
- assert(metadata.get('key-bin')[0] instanceof Buffer);
- });
- });
- describe('#getMap', function() {
- it('gets a map of keys to values', function() {
- metadata.add('key1', 'value1');
- metadata.add('Key2', 'value2');
- metadata.add('KEY3', 'value3');
- assert.deepEqual(metadata.getMap(),
- {key1: 'value1',
- key2: 'value2',
- key3: 'value3'});
- });
- });
- describe('#clone', function() {
- it('retains values from the original', function() {
- metadata.add('key', 'value');
- var copy = metadata.clone();
- assert.deepEqual(copy.get('key'), ['value']);
- });
- it('Does not see newly added values', function() {
- metadata.add('key', 'value1');
- var copy = metadata.clone();
- metadata.add('key', 'value2');
- assert.deepEqual(copy.get('key'), ['value1']);
- });
- it('Does not add new values to the original', function() {
- metadata.add('key', 'value1');
- var copy = metadata.clone();
- copy.add('key', 'value2');
- assert.deepEqual(metadata.get('key'), ['value1']);
- });
- });
-});
diff --git a/src/node/test/numbers.txt b/src/node/test/numbers.txt
deleted file mode 100644
index 4972919b4e..0000000000
--- a/src/node/test/numbers.txt
+++ /dev/null
@@ -1,496 +0,0 @@
-1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2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5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
diff --git a/src/node/test/server_test.js b/src/node/test/server_test.js
deleted file mode 100644
index 454acbda1d..0000000000
--- a/src/node/test/server_test.js
+++ /dev/null
@@ -1,138 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
-var grpc = require('../src/grpc_extension');
-
-describe('server', function() {
- describe('constructor', function() {
- it('should work with no arguments', function() {
- assert.doesNotThrow(function() {
- new grpc.Server();
- });
- });
- it('should work with an empty object argument', function() {
- assert.doesNotThrow(function() {
- new grpc.Server({});
- });
- });
- it('should work without the new keyword', function() {
- var server;
- assert.doesNotThrow(function() {
- server = grpc.Server();
- });
- assert(server instanceof grpc.Server);
- });
- it('should only accept objects with string or int values', function() {
- assert.doesNotThrow(function() {
- new grpc.Server({'key' : 'value'});
- });
- assert.doesNotThrow(function() {
- new grpc.Server({'key' : 5});
- });
- assert.throws(function() {
- new grpc.Server({'key' : null});
- });
- assert.throws(function() {
- new grpc.Server({'key' : new Date()});
- });
- });
- });
- describe('addHttp2Port', function() {
- var server;
- before(function() {
- server = new grpc.Server();
- });
- it('should bind to an unused port', function() {
- var port;
- assert.doesNotThrow(function() {
- port = server.addHttp2Port('0.0.0.0:0',
- grpc.ServerCredentials.createInsecure());
- });
- assert(port > 0);
- });
- it('should bind to an unused port with ssl credentials', function() {
- var port;
- var key_path = path.join(__dirname, '../test/data/server1.key');
- var pem_path = path.join(__dirname, '../test/data/server1.pem');
- var key_data = fs.readFileSync(key_path);
- var pem_data = fs.readFileSync(pem_path);
- var creds = grpc.ServerCredentials.createSsl(null,
- [{private_key: key_data,
- cert_chain: pem_data}]);
- assert.doesNotThrow(function() {
- port = server.addHttp2Port('0.0.0.0:0', creds);
- });
- assert(port > 0);
- });
- });
- describe('addSecureHttp2Port', function() {
- var server;
- before(function() {
- server = new grpc.Server();
- });
- });
- describe('start', function() {
- var server;
- before(function() {
- server = new grpc.Server();
- server.addHttp2Port('0.0.0.0:0', grpc.ServerCredentials.createInsecure());
- });
- after(function() {
- server.forceShutdown();
- });
- it('should start without error', function() {
- assert.doesNotThrow(function() {
- server.start();
- });
- });
- });
- describe('shutdown', function() {
- var server;
- beforeEach(function() {
- server = new grpc.Server();
- server.addHttp2Port('0.0.0.0:0', grpc.ServerCredentials.createInsecure());
- server.start();
- });
- afterEach(function() {
- server.forceShutdown();
- });
- it('tryShutdown should shutdown successfully', function(done) {
- server.tryShutdown(done);
- });
- it('forceShutdown should shutdown successfully', function() {
- server.forceShutdown();
- });
- it('tryShutdown should be idempotent', function(done) {
- server.tryShutdown(done);
- server.tryShutdown(function() {});
- });
- it('forceShutdown should be idempotent', function() {
- server.forceShutdown();
- server.forceShutdown();
- });
- it('forceShutdown should trigger tryShutdown', function(done) {
- server.tryShutdown(done);
- server.forceShutdown();
- });
- });
-});
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
deleted file mode 100644
index 0b0b393e32..0000000000
--- a/src/node/test/surface_test.js
+++ /dev/null
@@ -1,1424 +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.
- *
- */
-
-'use strict';
-
-var assert = require('assert');
-var _ = require('lodash');
-
-var surface_client = require('../src/client.js');
-var common = require('../src/common');
-
-var ProtoBuf = require('protobufjs');
-
-var grpc = require('..');
-
-var math_proto = ProtoBuf.loadProtoFile(__dirname +
- '/../../proto/math/math.proto');
-
-var mathService = math_proto.lookup('math.Math');
-var mathServiceAttrs = grpc.loadObject(
- mathService, common.defaultGrpcOptions).service;
-
-/**
- * This is used for testing functions with multiple asynchronous calls that
- * can happen in different orders. This should be passed the number of async
- * function invocations that can occur last, and each of those should call this
- * function's return value
- * @param {function()} done The function that should be called when a test is
- * complete.
- * @param {number} count The number of calls to the resulting function if the
- * test passes.
- * @return {function()} The function that should be called at the end of each
- * sequence of asynchronous functions.
- */
-function multiDone(done, count) {
- return function() {
- count -= 1;
- if (count <= 0) {
- done();
- }
- };
-}
-
-var server_insecure_creds = grpc.ServerCredentials.createInsecure();
-
-describe('File loader', function() {
- it('Should load a proto file by default', function() {
- assert.doesNotThrow(function() {
- grpc.load(__dirname + '/test_service.proto');
- });
- });
- it('Should load a proto file with the proto format', function() {
- assert.doesNotThrow(function() {
- grpc.load(__dirname + '/test_service.proto', 'proto');
- });
- });
- it('Should load a json file with the json format', function() {
- assert.doesNotThrow(function() {
- grpc.load(__dirname + '/test_service.json', 'json');
- });
- });
-});
-describe('surface Server', function() {
- var server;
- beforeEach(function() {
- server = new grpc.Server();
- });
- afterEach(function() {
- server.forceShutdown();
- });
- it('should error if started twice', function() {
- server.start();
- assert.throws(function() {
- server.start();
- });
- });
- it('should error if a port is bound after the server starts', function() {
- server.start();
- assert.throws(function() {
- server.bind('localhost:0', grpc.ServerCredentials.createInsecure());
- });
- });
- it('should successfully shutdown if tryShutdown is called', function(done) {
- server.start();
- server.tryShutdown(done);
- });
-});
-describe('Server.prototype.addProtoService', function() {
- var server;
- var dummyImpls = {
- 'div': function() {},
- 'divMany': function() {},
- 'fib': function() {},
- 'sum': function() {}
- };
- beforeEach(function() {
- server = new grpc.Server();
- });
- afterEach(function() {
- server.forceShutdown();
- });
- it('Should succeed with a single proto service', function() {
- assert.doesNotThrow(function() {
- server.addProtoService(mathService, dummyImpls);
- });
- });
- it('Should succeed with a single service attributes object', function() {
- assert.doesNotThrow(function() {
- server.addProtoService(mathServiceAttrs, dummyImpls);
- });
- });
-});
-describe('Server.prototype.addService', function() {
- var server;
- var dummyImpls = {
- 'div': function() {},
- 'divMany': function() {},
- 'fib': function() {},
- 'sum': function() {}
- };
- beforeEach(function() {
- server = new grpc.Server();
- });
- afterEach(function() {
- server.forceShutdown();
- });
- it('Should succeed with a single service', function() {
- assert.doesNotThrow(function() {
- server.addService(mathServiceAttrs, dummyImpls);
- });
- });
- it('Should fail with conflicting method names', function() {
- server.addService(mathServiceAttrs, dummyImpls);
- assert.throws(function() {
- server.addService(mathServiceAttrs, dummyImpls);
- });
- });
- it('Should allow method names as originally written', function() {
- var altDummyImpls = {
- 'Div': function() {},
- 'DivMany': function() {},
- 'Fib': function() {},
- 'Sum': function() {}
- };
- assert.doesNotThrow(function() {
- server.addProtoService(mathService, altDummyImpls);
- });
- });
- it('Should have a conflict between name variations', function() {
- /* This is really testing that both name variations are actually used,
- by checking that the method actually gets registered, for the
- corresponding function, in both cases */
- var altDummyImpls = {
- 'Div': function() {},
- 'DivMany': function() {},
- 'Fib': function() {},
- 'Sum': function() {}
- };
- server.addProtoService(mathService, altDummyImpls);
- assert.throws(function() {
- server.addProtoService(mathService, dummyImpls);
- });
- });
- it('Should fail if the server has been started', function() {
- server.start();
- assert.throws(function() {
- server.addService(mathServiceAttrs, dummyImpls);
- });
- });
- describe('Default handlers', function() {
- var client;
- beforeEach(function() {
- server.addService(mathServiceAttrs, {});
- var port = server.bind('localhost:0', server_insecure_creds);
- var Client = grpc.loadObject(mathService);
- client = new Client('localhost:' + port,
- grpc.credentials.createInsecure());
- server.start();
- });
- it('should respond to a unary call with UNIMPLEMENTED', function(done) {
- client.div({divisor: 4, dividend: 3}, function(error, response) {
- assert(error);
- assert.strictEqual(error.code, grpc.status.UNIMPLEMENTED);
- done();
- });
- });
- it('should respond to a client stream with UNIMPLEMENTED', function(done) {
- var call = client.sum(function(error, respones) {
- assert(error);
- assert.strictEqual(error.code, grpc.status.UNIMPLEMENTED);
- done();
- });
- call.end();
- });
- it('should respond to a server stream with UNIMPLEMENTED', function(done) {
- var call = client.fib({limit: 5});
- call.on('data', function(value) {
- assert.fail('No messages expected');
- });
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.UNIMPLEMENTED);
- done();
- });
- call.on('error', function(status) { /* Do nothing */ });
- });
- it('should respond to a bidi call with UNIMPLEMENTED', function(done) {
- var call = client.divMany();
- call.on('data', function(value) {
- assert.fail('No messages expected');
- });
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.UNIMPLEMENTED);
- done();
- });
- call.on('error', function(status) { /* Do nothing */ });
- call.end();
- });
- });
-});
-describe('Client constructor building', function() {
- var illegal_service_attrs = {
- $method : {
- path: '/illegal/$method',
- requestStream: false,
- responseStream: false,
- requestSerialize: _.identity,
- requestDeserialize: _.identity,
- responseSerialize: _.identity,
- responseDeserialize: _.identity
- }
- };
- it('Should reject method names starting with $', function() {
- assert.throws(function() {
- grpc.makeGenericClientConstructor(illegal_service_attrs);
- }, /\$/);
- });
-});
-describe('waitForClientReady', function() {
- var server;
- var port;
- var Client;
- var client;
- before(function() {
- server = new grpc.Server();
- port = server.bind('localhost:0', grpc.ServerCredentials.createInsecure());
- server.start();
- Client = grpc.loadObject(mathService);
- });
- beforeEach(function() {
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- });
- after(function() {
- server.forceShutdown();
- });
- it('should complete when called alone', function(done) {
- grpc.waitForClientReady(client, Infinity, function(error) {
- assert.ifError(error);
- done();
- });
- });
- it('should complete when a call is initiated', function(done) {
- grpc.waitForClientReady(client, Infinity, function(error) {
- assert.ifError(error);
- done();
- });
- var call = client.div({}, function(err, response) {});
- call.cancel();
- });
- it('should complete if called more than once', function(done) {
- done = multiDone(done, 2);
- grpc.waitForClientReady(client, Infinity, function(error) {
- assert.ifError(error);
- done();
- });
- grpc.waitForClientReady(client, Infinity, function(error) {
- assert.ifError(error);
- done();
- });
- });
- it('should complete if called when already ready', function(done) {
- grpc.waitForClientReady(client, Infinity, function(error) {
- assert.ifError(error);
- grpc.waitForClientReady(client, Infinity, function(error) {
- assert.ifError(error);
- done();
- });
- });
- });
- it('should time out if the server does not exist', function(done) {
- var bad_client = new Client('nonexistent_hostname',
- grpc.credentials.createInsecure());
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + 1);
- grpc.waitForClientReady(bad_client, deadline, function(error) {
- assert(error);
- done();
- });
- });
-});
-describe('Echo service', function() {
- var server;
- var client;
- before(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/echo_service.proto');
- var echo_service = test_proto.lookup('EchoService');
- var Client = grpc.loadObject(echo_service);
- server = new grpc.Server();
- server.addService(Client.service, {
- echo: function(call, callback) {
- callback(null, call.request);
- }
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- after(function() {
- server.forceShutdown();
- });
- it('should echo the recieved message directly', function(done) {
- client.echo({value: 'test value', value2: 3}, function(error, response) {
- assert.ifError(error);
- assert.deepEqual(response, {value: 'test value', value2: 3});
- done();
- });
- });
- it('Should convert an undefined argument to default values', function(done) {
- client.echo(undefined, function(error, response) {
- assert.ifError(error);
- assert.deepEqual(response, {value: '', value2: 0});
- done();
- });
- });
-});
-describe('Generic client and server', function() {
- function toString(val) {
- return val.toString();
- }
- function toBuffer(str) {
- return new Buffer(str);
- }
- var string_service_attrs = {
- 'capitalize' : {
- path: '/string/capitalize',
- requestStream: false,
- responseStream: false,
- requestSerialize: toBuffer,
- requestDeserialize: toString,
- responseSerialize: toBuffer,
- responseDeserialize: toString
- }
- };
- describe('String client and server', function() {
- var client;
- var server;
- before(function() {
- server = new grpc.Server();
- server.addService(string_service_attrs, {
- capitalize: function(call, callback) {
- callback(null, _.capitalize(call.request));
- }
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- server.start();
- var Client = grpc.makeGenericClientConstructor(string_service_attrs);
- client = new Client('localhost:' + port,
- grpc.credentials.createInsecure());
- });
- after(function() {
- server.forceShutdown();
- });
- it('Should respond with a capitalized string', function(done) {
- client.capitalize('abc', function(err, response) {
- assert.ifError(err);
- assert.strictEqual(response, 'Abc');
- done();
- });
- });
- });
-});
-describe('Server-side getPeer', function() {
- function toString(val) {
- return val.toString();
- }
- function toBuffer(str) {
- return new Buffer(str);
- }
- var string_service_attrs = {
- 'getPeer' : {
- path: '/string/getPeer',
- requestStream: false,
- responseStream: false,
- requestSerialize: toBuffer,
- requestDeserialize: toString,
- responseSerialize: toBuffer,
- responseDeserialize: toString
- }
- };
- var client;
- var server;
- before(function() {
- server = new grpc.Server();
- server.addService(string_service_attrs, {
- getPeer: function(call, callback) {
- try {
- callback(null, call.getPeer());
- } catch (e) {
- call.emit('error', e);
- }
- }
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- server.start();
- var Client = grpc.makeGenericClientConstructor(string_service_attrs);
- client = new Client('localhost:' + port,
- grpc.credentials.createInsecure());
- });
- after(function() {
- server.forceShutdown();
- });
- it('should respond with a string representing the client', function(done) {
- client.getPeer('', function(err, response) {
- assert.ifError(err);
- // We don't expect a specific value, just that it worked without error
- done();
- });
- });
-});
-describe('Echo metadata', function() {
- var client;
- var server;
- var metadata;
- before(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto');
- var test_service = test_proto.lookup('TestService');
- var Client = grpc.loadObject(test_service);
- server = new grpc.Server();
- server.addService(Client.service, {
- unary: function(call, cb) {
- call.sendMetadata(call.metadata);
- cb(null, {});
- },
- clientStream: function(stream, cb){
- stream.on('data', function(data) {});
- stream.on('end', function() {
- stream.sendMetadata(stream.metadata);
- cb(null, {});
- });
- },
- serverStream: function(stream) {
- stream.sendMetadata(stream.metadata);
- stream.end();
- },
- bidiStream: function(stream) {
- stream.on('data', function(data) {});
- stream.on('end', function() {
- stream.sendMetadata(stream.metadata);
- stream.end();
- });
- }
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- metadata = new grpc.Metadata();
- metadata.set('key', 'value');
- });
- after(function() {
- server.forceShutdown();
- });
- it('with unary call', function(done) {
- var call = client.unary({}, metadata, function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('key'), ['value']);
- done();
- });
- });
- it('with client stream call', function(done) {
- var call = client.clientStream(metadata, function(err, data) {
- assert.ifError(err);
- });
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('key'), ['value']);
- done();
- });
- call.end();
- });
- it('with server stream call', function(done) {
- var call = client.serverStream({}, metadata);
- call.on('data', function() {});
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('key'), ['value']);
- done();
- });
- });
- it('with bidi stream call', function(done) {
- var call = client.bidiStream(metadata);
- call.on('data', function() {});
- call.on('metadata', function(metadata) {
- assert.deepEqual(metadata.get('key'), ['value']);
- done();
- });
- call.end();
- });
- it('shows the correct user-agent string', function(done) {
- var version = require('../../../package.json').version;
- var call = client.unary({}, metadata,
- function(err, data) { assert.ifError(err); });
- call.on('metadata', function(metadata) {
- assert(_.startsWith(metadata.get('user-agent')[0],
- 'grpc-node/' + version));
- done();
- });
- });
- it('properly handles duplicate values', function(done) {
- var dup_metadata = metadata.clone();
- dup_metadata.add('key', 'value2');
- var call = client.unary({}, dup_metadata,
- function(err, data) {assert.ifError(err); });
- call.on('metadata', function(resp_metadata) {
- // Two arrays are equal iff their symmetric difference is empty
- assert.deepEqual(_.xor(dup_metadata.get('key'), resp_metadata.get('key')),
- []);
- done();
- });
- });
-});
-describe('Client malformed response handling', function() {
- var server;
- var client;
- var badArg = new Buffer([0xFF]);
- before(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto');
- var test_service = test_proto.lookup('TestService');
- var malformed_test_service = {
- unary: {
- path: '/TestService/Unary',
- requestStream: false,
- responseStream: false,
- requestDeserialize: _.identity,
- responseSerialize: _.identity
- },
- clientStream: {
- path: '/TestService/ClientStream',
- requestStream: true,
- responseStream: false,
- requestDeserialize: _.identity,
- responseSerialize: _.identity
- },
- serverStream: {
- path: '/TestService/ServerStream',
- requestStream: false,
- responseStream: true,
- requestDeserialize: _.identity,
- responseSerialize: _.identity
- },
- bidiStream: {
- path: '/TestService/BidiStream',
- requestStream: true,
- responseStream: true,
- requestDeserialize: _.identity,
- responseSerialize: _.identity
- }
- };
- server = new grpc.Server();
- server.addService(malformed_test_service, {
- unary: function(call, cb) {
- cb(null, badArg);
- },
- clientStream: function(stream, cb) {
- stream.on('data', function() {/* Ignore requests */});
- stream.on('end', function() {
- cb(null, badArg);
- });
- },
- serverStream: function(stream) {
- stream.write(badArg);
- stream.end();
- },
- bidiStream: function(stream) {
- stream.on('data', function() {
- // Ignore requests
- stream.write(badArg);
- });
- stream.on('end', function() {
- stream.end();
- });
- }
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- var Client = grpc.loadObject(test_service);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- after(function() {
- server.forceShutdown();
- });
- it('should get an INTERNAL status with a unary call', function(done) {
- client.unary({}, function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- });
- it('should get an INTERNAL status with a client stream call', function(done) {
- var call = client.clientStream(function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- call.write({});
- call.end();
- });
- it('should get an INTERNAL status with a server stream call', function(done) {
- var call = client.serverStream({});
- call.on('data', function(){});
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- });
- it('should get an INTERNAL status with a bidi stream call', function(done) {
- var call = client.bidiStream();
- call.on('data', function(){});
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- call.write({});
- call.end();
- });
-});
-describe('Server serialization failure handling', function() {
- function serializeFail(obj) {
- throw new Error('Serialization failed');
- }
- var client;
- var server;
- before(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto');
- var test_service = test_proto.lookup('TestService');
- var malformed_test_service = {
- unary: {
- path: '/TestService/Unary',
- requestStream: false,
- responseStream: false,
- requestDeserialize: _.identity,
- responseSerialize: serializeFail
- },
- clientStream: {
- path: '/TestService/ClientStream',
- requestStream: true,
- responseStream: false,
- requestDeserialize: _.identity,
- responseSerialize: serializeFail
- },
- serverStream: {
- path: '/TestService/ServerStream',
- requestStream: false,
- responseStream: true,
- requestDeserialize: _.identity,
- responseSerialize: serializeFail
- },
- bidiStream: {
- path: '/TestService/BidiStream',
- requestStream: true,
- responseStream: true,
- requestDeserialize: _.identity,
- responseSerialize: serializeFail
- }
- };
- server = new grpc.Server();
- server.addService(malformed_test_service, {
- unary: function(call, cb) {
- cb(null, {});
- },
- clientStream: function(stream, cb) {
- stream.on('data', function() {/* Ignore requests */});
- stream.on('end', function() {
- cb(null, {});
- });
- },
- serverStream: function(stream) {
- stream.write({});
- stream.end();
- },
- bidiStream: function(stream) {
- stream.on('data', function() {
- // Ignore requests
- stream.write({});
- });
- stream.on('end', function() {
- stream.end();
- });
- }
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- var Client = grpc.loadObject(test_service);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- after(function() {
- server.forceShutdown();
- });
- it('should get an INTERNAL status with a unary call', function(done) {
- client.unary({}, function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- });
- it('should get an INTERNAL status with a client stream call', function(done) {
- var call = client.clientStream(function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- call.write({});
- call.end();
- });
- it('should get an INTERNAL status with a server stream call', function(done) {
- var call = client.serverStream({});
- call.on('data', function(){});
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- });
- it('should get an INTERNAL status with a bidi stream call', function(done) {
- var call = client.bidiStream();
- call.on('data', function(){});
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- call.write({});
- call.end();
- });
-});
-describe('Other conditions', function() {
- var Client;
- var client;
- var server;
- var port;
- before(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto');
- var test_service = test_proto.lookup('TestService');
- Client = grpc.loadObject(test_service);
- server = new grpc.Server();
- var trailer_metadata = new grpc.Metadata();
- trailer_metadata.add('trailer-present', 'yes');
- server.addService(Client.service, {
- unary: function(call, cb) {
- var req = call.request;
- if (req.error) {
- cb({code: grpc.status.UNKNOWN,
- details: 'Requested error'}, null, trailer_metadata);
- } else {
- cb(null, {count: 1}, trailer_metadata);
- }
- },
- clientStream: function(stream, cb){
- var count = 0;
- var errored;
- stream.on('data', function(data) {
- if (data.error) {
- errored = true;
- cb(new Error('Requested error'), null, trailer_metadata);
- } else {
- count += 1;
- }
- });
- stream.on('end', function() {
- if (!errored) {
- cb(null, {count: count}, trailer_metadata);
- }
- });
- },
- serverStream: function(stream) {
- var req = stream.request;
- if (req.error) {
- var err = {code: grpc.status.UNKNOWN,
- details: 'Requested error'};
- err.metadata = trailer_metadata;
- stream.emit('error', err);
- } else {
- for (var i = 0; i < 5; i++) {
- stream.write({count: i});
- }
- stream.end(trailer_metadata);
- }
- },
- bidiStream: function(stream) {
- var count = 0;
- stream.on('data', function(data) {
- if (data.error) {
- var err = new Error('Requested error');
- err.metadata = trailer_metadata.clone();
- err.metadata.add('count', '' + count);
- stream.emit('error', err);
- } else {
- stream.write({count: count});
- count += 1;
- }
- });
- stream.on('end', function() {
- stream.end(trailer_metadata);
- });
- }
- });
- port = server.bind('localhost:0', server_insecure_creds);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- after(function() {
- server.forceShutdown();
- });
- it('channel.getTarget should be available', function() {
- assert.strictEqual(typeof grpc.getClientChannel(client).getTarget(),
- 'string');
- });
- it('client should be able to pause and resume a stream', function(done) {
- var call = client.bidiStream();
- call.on('data', function(data) {
- assert(data.count < 3);
- call.pause();
- setTimeout(function() {
- call.resume();
- }, 10);
- });
- call.on('end', function() {
- done();
- });
- call.write({});
- call.write({});
- call.write({});
- call.end();
- });
- describe('Server recieving bad input', function() {
- var misbehavingClient;
- var badArg = new Buffer([0xFF]);
- before(function() {
- var test_service_attrs = {
- unary: {
- path: '/TestService/Unary',
- requestStream: false,
- responseStream: false,
- requestSerialize: _.identity,
- responseDeserialize: _.identity
- },
- clientStream: {
- path: '/TestService/ClientStream',
- requestStream: true,
- responseStream: false,
- requestSerialize: _.identity,
- responseDeserialize: _.identity
- },
- serverStream: {
- path: '/TestService/ServerStream',
- requestStream: false,
- responseStream: true,
- requestSerialize: _.identity,
- responseDeserialize: _.identity
- },
- bidiStream: {
- path: '/TestService/BidiStream',
- requestStream: true,
- responseStream: true,
- requestSerialize: _.identity,
- responseDeserialize: _.identity
- }
- };
- var Client = surface_client.makeClientConstructor(test_service_attrs,
- 'TestService');
- misbehavingClient = new Client('localhost:' + port,
- grpc.credentials.createInsecure());
- });
- it('should respond correctly to a unary call', function(done) {
- misbehavingClient.unary(badArg, function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- });
- it('should respond correctly to a client stream', function(done) {
- var call = misbehavingClient.clientStream(function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- call.write(badArg);
- // TODO(mlumish): Remove call.end()
- call.end();
- });
- it('should respond correctly to a server stream', function(done) {
- var call = misbehavingClient.serverStream(badArg);
- call.on('data', function(data) {
- assert.fail(data, null, 'Unexpected data', '===');
- });
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- });
- it('should respond correctly to a bidi stream', function(done) {
- var call = misbehavingClient.bidiStream();
- call.on('data', function(data) {
- assert.fail(data, null, 'Unexpected data', '===');
- });
- call.on('error', function(err) {
- assert.strictEqual(err.code, grpc.status.INTERNAL);
- done();
- });
- call.write(badArg);
- // TODO(mlumish): Remove call.end()
- call.end();
- });
- });
- describe('Trailing metadata', function() {
- it('should be present when a unary call succeeds', function(done) {
- var call = client.unary({error: false}, function(err, data) {
- assert.ifError(err);
- });
- call.on('status', function(status) {
- assert.deepEqual(status.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a unary call fails', function(done) {
- var call = client.unary({error: true}, function(err, data) {
- assert(err);
- });
- call.on('status', function(status) {
- assert.deepEqual(status.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a client stream call succeeds', function(done) {
- var call = client.clientStream(function(err, data) {
- assert.ifError(err);
- });
- call.write({error: false});
- call.write({error: false});
- call.end();
- call.on('status', function(status) {
- assert.deepEqual(status.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a client stream call fails', function(done) {
- var call = client.clientStream(function(err, data) {
- assert(err);
- });
- call.write({error: false});
- call.write({error: true});
- call.end();
- call.on('status', function(status) {
- assert.deepEqual(status.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a server stream call succeeds', function(done) {
- var call = client.serverStream({error: false});
- call.on('data', function(){});
- call.on('status', function(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- assert.deepEqual(status.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a server stream call fails', function(done) {
- var call = client.serverStream({error: true});
- call.on('data', function(){});
- call.on('error', function(error) {
- assert.deepEqual(error.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a bidi stream succeeds', function(done) {
- var call = client.bidiStream();
- call.write({error: false});
- call.write({error: false});
- call.end();
- call.on('data', function(){});
- call.on('status', function(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- assert.deepEqual(status.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- it('should be present when a bidi stream fails', function(done) {
- var call = client.bidiStream();
- call.write({error: false});
- call.write({error: true});
- call.end();
- call.on('data', function(){});
- call.on('error', function(error) {
- assert.deepEqual(error.metadata.get('trailer-present'), ['yes']);
- done();
- });
- });
- });
- describe('Error object should contain the status', function() {
- it('for a unary call', function(done) {
- client.unary({error: true}, function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.UNKNOWN);
- assert.strictEqual(err.message, 'Requested error');
- done();
- });
- });
- it('for a client stream call', function(done) {
- var call = client.clientStream(function(err, data) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.UNKNOWN);
- assert.strictEqual(err.message, 'Requested error');
- done();
- });
- call.write({error: false});
- call.write({error: true});
- call.end();
- });
- it('for a server stream call', function(done) {
- var call = client.serverStream({error: true});
- call.on('data', function(){});
- call.on('error', function(error) {
- assert.strictEqual(error.code, grpc.status.UNKNOWN);
- assert.strictEqual(error.message, 'Requested error');
- done();
- });
- });
- it('for a bidi stream call', function(done) {
- var call = client.bidiStream();
- call.write({error: false});
- call.write({error: true});
- call.end();
- call.on('data', function(){});
- call.on('error', function(error) {
- assert.strictEqual(error.code, grpc.status.UNKNOWN);
- assert.strictEqual(error.message, 'Requested error');
- done();
- });
- });
- });
- describe('call.getPeer should return the peer', function() {
- it('for a unary call', function(done) {
- var call = client.unary({error: false}, function(err, data) {
- assert.ifError(err);
- done();
- });
- assert.strictEqual(typeof call.getPeer(), 'string');
- });
- it('for a client stream call', function(done) {
- var call = client.clientStream(function(err, data) {
- assert.ifError(err);
- done();
- });
- assert.strictEqual(typeof call.getPeer(), 'string');
- call.write({error: false});
- call.end();
- });
- it('for a server stream call', function(done) {
- var call = client.serverStream({error: false});
- assert.strictEqual(typeof call.getPeer(), 'string');
- call.on('data', function(){});
- call.on('status', function(status) {
- assert.strictEqual(status.code, grpc.status.OK);
- done();
- });
- });
- it('for a bidi stream call', function(done) {
- var call = client.bidiStream();
- assert.strictEqual(typeof call.getPeer(), 'string');
- call.write({error: false});
- call.end();
- call.on('data', function(){});
- call.on('status', function(status) {
- done();
- });
- });
- it('after the call has fully completed', function(done) {
- var peer;
- var call = client.unary({error: false}, function(err, data) {
- assert.ifError(err);
- setImmediate(function() {
- assert.strictEqual(peer, call.getPeer());
- done();
- });
- });
- peer = call.getPeer();
- assert.strictEqual(typeof peer, 'string');
- });
- });
-});
-describe('Call propagation', function() {
- var proxy;
- var proxy_impl;
-
- var Client;
- var client;
- var server;
- before(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto');
- var test_service = test_proto.lookup('TestService');
- server = new grpc.Server();
- Client = grpc.loadObject(test_service);
- server.addService(Client.service, {
- unary: function(call) {},
- clientStream: function(stream) {},
- serverStream: function(stream) {},
- bidiStream: function(stream) {}
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- after(function() {
- server.forceShutdown();
- });
- beforeEach(function() {
- proxy = new grpc.Server();
- proxy_impl = {
- unary: function(call) {},
- clientStream: function(stream) {},
- serverStream: function(stream) {},
- bidiStream: function(stream) {}
- };
- });
- afterEach(function() {
- proxy.forceShutdown();
- });
- describe('Cancellation', function() {
- it('With a unary call', function(done) {
- done = multiDone(done, 2);
- var call;
- proxy_impl.unary = function(parent, callback) {
- client.unary(parent.request, {parent: parent}, function(err, value) {
- try {
- assert(err);
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- } finally {
- callback(err, value);
- done();
- }
- });
- call.cancel();
- };
- proxy.addService(Client.service, proxy_impl);
- var proxy_port = proxy.bind('localhost:0', server_insecure_creds);
- proxy.start();
- var proxy_client = new Client('localhost:' + proxy_port,
- grpc.credentials.createInsecure());
- call = proxy_client.unary({}, function(err, value) { done(); });
- });
- it('With a client stream call', function(done) {
- done = multiDone(done, 2);
- var call;
- proxy_impl.clientStream = function(parent, callback) {
- client.clientStream({parent: parent}, function(err, value) {
- try {
- assert(err);
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- } finally {
- callback(err, value);
- done();
- }
- });
- call.cancel();
- };
- proxy.addService(Client.service, proxy_impl);
- var proxy_port = proxy.bind('localhost:0', server_insecure_creds);
- proxy.start();
- var proxy_client = new Client('localhost:' + proxy_port,
- grpc.credentials.createInsecure());
- call = proxy_client.clientStream(function(err, value) { done(); });
- });
- it('With a server stream call', function(done) {
- done = multiDone(done, 2);
- var call;
- proxy_impl.serverStream = function(parent) {
- var child = client.serverStream(parent.request, {parent: parent});
- child.on('data', function() {});
- child.on('error', function(err) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
- };
- proxy.addService(Client.service, proxy_impl);
- var proxy_port = proxy.bind('localhost:0', server_insecure_creds);
- proxy.start();
- var proxy_client = new Client('localhost:' + proxy_port,
- grpc.credentials.createInsecure());
- call = proxy_client.serverStream({});
- call.on('data', function() {});
- call.on('error', function(err) {
- done();
- });
- });
- it('With a bidi stream call', function(done) {
- done = multiDone(done, 2);
- var call;
- proxy_impl.bidiStream = function(parent) {
- var child = client.bidiStream({parent: parent});
- child.on('data', function() {});
- child.on('error', function(err) {
- assert(err);
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
- };
- proxy.addService(Client.service, proxy_impl);
- var proxy_port = proxy.bind('localhost:0', server_insecure_creds);
- proxy.start();
- var proxy_client = new Client('localhost:' + proxy_port,
- grpc.credentials.createInsecure());
- call = proxy_client.bidiStream();
- call.on('data', function() {});
- call.on('error', function(err) {
- done();
- });
- });
- });
- describe('Deadline', function() {
- /* jshint bitwise:false */
- var deadline_flags = (grpc.propagate.DEFAULTS &
- ~grpc.propagate.CANCELLATION);
- it('With a client stream call', function(done) {
- done = multiDone(done, 2);
- proxy_impl.clientStream = function(parent, callback) {
- var options = {parent: parent, propagate_flags: deadline_flags};
- client.clientStream(options, function(err, value) {
- try {
- assert(err);
- assert(err.code === grpc.status.DEADLINE_EXCEEDED ||
- err.code === grpc.status.INTERNAL);
- } finally {
- callback(err, value);
- done();
- }
- });
- };
- proxy.addService(Client.service, proxy_impl);
- var proxy_port = proxy.bind('localhost:0', server_insecure_creds);
- proxy.start();
- var proxy_client = new Client('localhost:' + proxy_port,
- grpc.credentials.createInsecure());
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + 1);
- proxy_client.clientStream({deadline: deadline}, function(err, value) {
- done();
- });
- });
- it('With a bidi stream call', function(done) {
- done = multiDone(done, 2);
- proxy_impl.bidiStream = function(parent) {
- var child = client.bidiStream(
- {parent: parent, propagate_flags: deadline_flags});
- child.on('data', function() {});
- child.on('error', function(err) {
- assert(err);
- assert(err.code === grpc.status.DEADLINE_EXCEEDED ||
- err.code === grpc.status.INTERNAL);
- done();
- });
- };
- proxy.addService(Client.service, proxy_impl);
- var proxy_port = proxy.bind('localhost:0', server_insecure_creds);
- proxy.start();
- var proxy_client = new Client('localhost:' + proxy_port,
- grpc.credentials.createInsecure());
- var deadline = new Date();
- deadline.setSeconds(deadline.getSeconds() + 1);
- var call = proxy_client.bidiStream({deadline: deadline});
- call.on('data', function() {});
- call.on('error', function(err) {
- done();
- });
- });
- });
-});
-describe('Cancelling surface client', function() {
- var client;
- var server;
- before(function() {
- server = new grpc.Server();
- server.addService(mathServiceAttrs, {
- 'div': function(stream) {},
- 'divMany': function(stream) {},
- 'fib': function(stream) {},
- 'sum': function(stream) {}
- });
- var port = server.bind('localhost:0', server_insecure_creds);
- var Client = surface_client.makeClientConstructor(mathServiceAttrs);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- after(function() {
- server.forceShutdown();
- });
- it('Should correctly cancel a unary call', function(done) {
- var call = client.div({'divisor': 0, 'dividend': 0}, function(err, resp) {
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
- });
- it('Should correctly cancel a client stream call', function(done) {
- var call = client.sum(function(err, resp) {
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
- });
- it('Should correctly cancel a server stream call', function(done) {
- var call = client.fib({'limit': 5});
- call.on('data', function() {});
- call.on('error', function(error) {
- assert.strictEqual(error.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
- });
- it('Should correctly cancel a bidi stream call', function(done) {
- var call = client.divMany();
- call.on('data', function() {});
- call.on('error', function(error) {
- assert.strictEqual(error.code, grpc.status.CANCELLED);
- done();
- });
- call.cancel();
- });
- it('Should be idempotent', function(done) {
- var call = client.div({'divisor': 0, 'dividend': 0}, function(err, resp) {
- assert.strictEqual(err.code, grpc.status.CANCELLED);
- // Call asynchronously to try cancelling after call is fully completed
- setImmediate(function() {
- assert.doesNotThrow(function() {
- call.cancel();
- });
- done();
- });
- });
- call.cancel();
- });
-});
-describe('Client reconnect', function() {
- var server;
- var Client;
- var client;
- var port;
- beforeEach(function() {
- var test_proto = ProtoBuf.loadProtoFile(__dirname + '/echo_service.proto');
- var echo_service = test_proto.lookup('EchoService');
- Client = grpc.loadObject(echo_service);
- server = new grpc.Server();
- server.addService(Client.service, {
- echo: function(call, callback) {
- callback(null, call.request);
- }
- });
- port = server.bind('localhost:0', server_insecure_creds);
- client = new Client('localhost:' + port, grpc.credentials.createInsecure());
- server.start();
- });
- afterEach(function() {
- server.forceShutdown();
- });
- it('should reconnect after server restart', function(done) {
- client.echo({value: 'test value', value2: 3}, function(error, response) {
- assert.ifError(error);
- assert.deepEqual(response, {value: 'test value', value2: 3});
- server.tryShutdown(function() {
- server = new grpc.Server();
- server.addService(Client.service, {
- echo: function(call, callback) {
- callback(null, call.request);
- }
- });
- server.bind('localhost:' + port, server_insecure_creds);
- server.start();
-
- /* We create a new client, that will not throw an error if the server
- * is not immediately available. Instead, it will wait for the server
- * to be available, then the call will complete. Once this happens, the
- * original client should be able to make a new call and connect to the
- * restarted server without having the call fail due to connection
- * errors. */
- var client2 = new Client('localhost:' + port,
- grpc.credentials.createInsecure());
- client2.echo({value: 'test', value2: 3}, function(error, response) {
- assert.ifError(error);
- client.echo(undefined, function(error, response) {
- if (error) {
- console.log(error);
- }
- assert.ifError(error);
- assert.deepEqual(response, {value: '', value2: 0});
- done();
- });
- });
- });
- });
- });
-});
diff --git a/src/node/test/test_service.json b/src/node/test/test_service.json
deleted file mode 100644
index 6f952c6ad2..0000000000
--- a/src/node/test/test_service.json
+++ /dev/null
@@ -1,55 +0,0 @@
-{
- "package": null,
- "messages": [
- {
- "name": "Request",
- "fields": [
- {
- "rule": "optional",
- "type": "bool",
- "name": "error",
- "id": 1
- }
- ]
- },
- {
- "name": "Response",
- "fields": [
- {
- "rule": "optional",
- "type": "int32",
- "name": "count",
- "id": 1
- }
- ]
- }
- ],
- "services": [
- {
- "name": "TestService",
- "options": {},
- "rpc": {
- "Unary": {
- "request": "Request",
- "response": "Response",
- "options": {}
- },
- "ClientStream": {
- "request": "Request",
- "response": "Response",
- "options": {}
- },
- "ServerStream": {
- "request": "Request",
- "response": "Response",
- "options": {}
- },
- "BidiStream": {
- "request": "Request",
- "response": "Response",
- "options": {}
- }
- }
- }
- ]
-} \ No newline at end of file
diff --git a/src/node/tools/bin/protoc.js b/src/node/tools/bin/protoc.js
deleted file mode 100755
index 490817b3ce..0000000000
--- a/src/node/tools/bin/protoc.js
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env node
-/*
- *
- * 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.
- *
- */
-
-/**
- * This file is required because package.json cannot reference a file that
- * is not distributed with the package, and we use node-pre-gyp to distribute
- * the protoc binary
- */
-
-'use strict';
-
-var path = require('path');
-var execFile = require('child_process').execFile;
-
-var exe_ext = process.platform === 'win32' ? '.exe' : '';
-
-var protoc = path.resolve(__dirname, 'protoc' + exe_ext);
-
-var plugin = path.resolve(__dirname, 'grpc_node_plugin' + exe_ext);
-
-var args = ['--plugin=protoc-gen-grpc=' + plugin].concat(process.argv.slice(2));
-
-var child_process = execFile(protoc, args, function(error, stdout, stderr) {
- if (error) {
- throw error;
- }
-});
-
-child_process.stdout.pipe(process.stdout);
-child_process.stderr.pipe(process.stderr);
diff --git a/src/node/tools/bin/protoc_plugin.js b/src/node/tools/bin/protoc_plugin.js
deleted file mode 100755
index fbdafff7d2..0000000000
--- a/src/node/tools/bin/protoc_plugin.js
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env node
-/*
- *
- * 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.
- *
- */
-
-/**
- * This file is required because package.json cannot reference a file that
- * is not distributed with the package, and we use node-pre-gyp to distribute
- * the plugin binary
- */
-
-'use strict';
-
-var path = require('path');
-var execFile = require('child_process').execFile;
-
-var exe_ext = process.platform === 'win32' ? '.exe' : '';
-
-var plugin = path.resolve(__dirname, 'grpc_node_plugin' + exe_ext);
-
-var child_process = execFile(plugin, process.argv.slice(2), {encoding: 'buffer'}, function(error, stdout, stderr) {
- if (error) {
- throw error;
- }
-});
-
-process.stdin.pipe(child_process.stdin);
-child_process.stdout.pipe(process.stdout);
-child_process.stderr.pipe(process.stderr);
diff --git a/src/node/tools/index.js b/src/node/tools/index.js
deleted file mode 100644
index b81d625dfe..0000000000
--- a/src/node/tools/index.js
+++ /dev/null
@@ -1,26 +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.
- *
- */
-
-'use strict';
-
-/**
- * package.json requires this file to be present. In the future, this can
- * export useful information about the included tools.
- */
-
-module.exports = {};
diff --git a/src/node/tools/package.json b/src/node/tools/package.json
deleted file mode 100644
index d9b1fb86c9..0000000000
--- a/src/node/tools/package.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "name": "grpc-tools",
- "version": "1.7.0-dev",
- "author": "Google Inc.",
- "description": "Tools for developing with gRPC on Node.js",
- "homepage": "https://grpc.io/",
- "repository": {
- "type": "git",
- "url": "https://github.com/grpc/grpc.git"
- },
- "bugs": "https://github.com/grpc/grpc/issues",
- "contributors": [
- {
- "name": "Michael Lumish",
- "email": "mlumish@google.com"
- }
- ],
- "bin": {
- "grpc_tools_node_protoc": "./bin/protoc.js",
- "grpc_tools_node_protoc_plugin": "./bin/protoc_plugin.js"
- },
- "scripts": {
- "install": "./node_modules/.bin/node-pre-gyp install"
- },
- "bundledDependencies": ["node-pre-gyp"],
- "binary": {
- "module_name": "grpc_tools",
- "host": "https://storage.googleapis.com/",
- "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
- "package_name": "{platform}-{arch}.tar.gz",
- "module_path": "bin"
- },
- "files": [
- "index.js",
- "bin/protoc.js",
- "bin/protoc_plugin.js",
- "bin/google/protobuf",
- "LICENSE"
- ],
- "main": "index.js"
-}
diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
index 7d073c9a84..037ad4d9b0 100644
--- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
+++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
@@ -42,7 +42,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them.
s.name = '!ProtoCompiler-gRPCPlugin'
- v = '1.7.0-dev'
+ v = '1.10.0-dev'
s.version = v
s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.'
s.description = <<-DESC
@@ -101,7 +101,7 @@ Pod::Spec.new do |s|
s.preserve_paths = plugin
# Restrict the protoc version to the one supported by this plugin.
- s.dependency '!ProtoCompiler', '3.4.0'
+ s.dependency '!ProtoCompiler', '3.5.0'
# For the Protobuf dependency not to complain:
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec
index 25c437911f..12598e616a 100644
--- a/src/objective-c/!ProtoCompiler.podspec
+++ b/src/objective-c/!ProtoCompiler.podspec
@@ -36,7 +36,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them.
s.name = '!ProtoCompiler'
- v = '3.4.0'
+ v = '3.5.0'
s.version = v
s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files'
s.description = <<-DESC
diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec
index 37798ec3c6..6e406b0dc9 100644
--- a/src/objective-c/BoringSSL.podspec
+++ b/src/objective-c/BoringSSL.podspec
@@ -31,7 +31,7 @@
Pod::Spec.new do |s|
s.name = 'BoringSSL'
- version = '9.0'
+ version = '9.1'
s.version = version
s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google’s needs.'
# Adapted from the homepage:
@@ -67,9 +67,10 @@ Pod::Spec.new do |s|
# "The name and email addresses of the library maintainers, not the Podspec maintainer."
s.authors = 'Adam Langley', 'David Benjamin', 'Matt Braithwaite'
+ major_version = version[0] + '.0'
s.source = {
:git => 'https://boringssl.googlesource.com/boringssl',
- :tag => "version_for_cocoapods_#{version}",
+ :tag => "version_for_cocoapods_#{major_version}",
}
name = 'openssl'
@@ -135,12 +136,12 @@ Pod::Spec.new do |s|
# Replace "const BIGNUM *I" in rsa.h with a lowercase i, as the former fails when including
# OpenSSL in a Swift bridging header (complex.h defines "I", and it's as if the compiler
# included it in every bridged header).
- sed -E -i '.back' 's/\\*I,/*i,/g' include/openssl/rsa.h
+ sed -E -i'.back' 's/\\*I,/*i,/g' include/openssl/rsa.h
# Replace `#include "../crypto/internal.h"` in e_tls.c with `#include "../internal.h"`. The
# former assumes crypto/ is in the headers search path, which is hard to enforce when using
# dynamic frameworks. The latters always works, being relative to the current file.
- sed -E -i '.back' 's/crypto\\///g' crypto/cipher/e_tls.c
+ sed -E -i'.back' 's/crypto\\///g' crypto/cipher/e_tls.c
# Add a module map and an umbrella header
cat > include/openssl/umbrella.h <<EOF
@@ -186,6 +187,7 @@ Pod::Spec.new do |s|
cat > include/openssl/BoringSSL.modulemap <<EOF
framework module openssl {
umbrella header "umbrella.h"
+ textual header "arm_arch.h"
export *
module * { export * }
}
@@ -195,11 +197,11 @@ Pod::Spec.new do |s|
# https://github.com/libgit2/libgit2/commit/1ddada422caf8e72ba97dca2568d2bf879fed5f2 and libvpx
# in https://chromium.googlesource.com/webm/libvpx/+/1bec0c5a7e885ec792f6bb658eb3f34ad8f37b15
# work around it by removing the include. We need four of its macros, so we expand them here.
- sed -E -i '.back' '/<inttypes.h>/d' include/openssl/bn.h
- sed -E -i '.back' 's/PRIu32/"u"/g' include/openssl/bn.h
- sed -E -i '.back' 's/PRIx32/"x"/g' include/openssl/bn.h
- sed -E -i '.back' 's/PRIu64/"llu"/g' include/openssl/bn.h
- sed -E -i '.back' 's/PRIx64/"llx"/g' include/openssl/bn.h
+ sed -E -i'.back' '/<inttypes.h>/d' include/openssl/bn.h
+ sed -E -i'.back' 's/PRIu32/"u"/g' include/openssl/bn.h
+ sed -E -i'.back' 's/PRIx32/"x"/g' include/openssl/bn.h
+ sed -E -i'.back' 's/PRIu64/"llu"/g' include/openssl/bn.h
+ sed -E -i'.back' 's/PRIx64/"llx"/g' include/openssl/bn.h
# This is a bit ridiculous, but requiring people to install Go in order to build is slightly
# more ridiculous IMO. To save you from scrolling, this is the last part of the podspec.
diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
index 9f2361bd22..18d4597098 100644
--- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
+++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
@@ -19,6 +19,12 @@
#include <AvailabilityMacros.h>
+typedef NS_ENUM(NSInteger, GRPCCompressAlgorithm) {
+ GRPCCompressNone,
+ GRPCCompressDeflate,
+ GRPCCompressGzip,
+};
+
/**
* Methods to configure GRPC channel options.
*/
@@ -36,4 +42,8 @@
+ (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE("The API for this feature is experimental, "
"and might be removed or modified at any "
"time.");
+
++ (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm
+ forhost:(nonnull NSString *)host;
+
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
index 398d98fbc7..d44e39f551 100644
--- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
+++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
@@ -20,6 +20,8 @@
#import "private/GRPCHost.h"
+#import <grpc/impl/codegen/compression_types.h>
+
@implementation GRPCCall (ChannelArg)
+ (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix forHost:(nonnull NSString *)host {
@@ -36,4 +38,23 @@
[GRPCHost flushChannelCache];
}
++ (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm
+ forhost:(nonnull NSString *)host {
+ GRPCHost *hostConfig = [GRPCHost hostWithAddress:host];
+ switch (algorithm) {
+ case GRPCCompressNone:
+ hostConfig.compressAlgorithm = GRPC_COMPRESS_NONE;
+ break;
+ case GRPCCompressDeflate:
+ hostConfig.compressAlgorithm = GRPC_COMPRESS_MESSAGE_DEFLATE;
+ break;
+ case GRPCCompressGzip:
+ hostConfig.compressAlgorithm = GRPC_COMPRESS_MESSAGE_GZIP;
+ break;
+ default:
+ NSLog(@"Invalid compression algorithm");
+ abort();
+ }
+}
+
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index d6c3a3c165..ac4596da25 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -112,10 +112,13 @@ static NSString * const kBearerPrefix = @"Bearer ";
@synthesize state = _state;
-// TODO(jcanizales): If grpc_init is idempotent, this should be changed from load to initialize.
-+ (void)load {
- grpc_init();
- callFlags = [NSMutableDictionary dictionary];
++ (void)initialize {
+ // Guarantees the code in {} block is invoked only once. See ref at:
+ // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc
+ if (self == [GRPCCall self]) {
+ grpc_init();
+ callFlags = [NSMutableDictionary dictionary];
+ }
}
+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path {
@@ -296,7 +299,7 @@ static NSString * const kBearerPrefix = @"Bearer ";
// network queue if the write didn't succeed.
// If the call is a unary call, parameter \a errorHandler will be ignored and
// the error handler of GRPCOpSendClose will be executed in case of error.
-- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)())errorHandler {
+- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler {
__weak GRPCCall *weakSelf = self;
void(^resumingHandler)(void) = ^{
@@ -342,7 +345,7 @@ static NSString * const kBearerPrefix = @"Bearer ";
// Only called from the call queue. The error handler will be called from the
// network queue if the requests stream couldn't be closed successfully.
-- (void)finishRequestWithErrorHandler:(void (^)())errorHandler {
+- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler {
if (!_unaryCall) {
[_wrappedCall startBatchWithOperations:@[[[GRPCOpSendClose alloc] init]]
errorHandler:errorHandler];
@@ -438,7 +441,7 @@ static NSString * const kBearerPrefix = @"Bearer ";
}
_connectivityMonitor = [GRPCConnectivityMonitor monitorWithHost:host];
__weak typeof(self) weakSelf = self;
- void (^handler)() = ^{
+ void (^handler)(void) = ^{
typeof(self) strongSelf = weakSelf;
[strongSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeUnavailable
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index b78b14f2af..26efe90abd 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -189,6 +189,7 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
timeout = 0;
}
grpc_slice host_slice;
+ memset(&host_slice, 0, sizeof(host_slice));
if (serverName) {
host_slice = grpc_slice_from_copied_string(serverName.UTF8String);
}
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
index 8d3c45ee50..cb55e46d70 100644
--- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
+++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h
@@ -57,6 +57,6 @@
* Only one handler is active at a time, so if this method is called again before the previous
* handler has been called, it might never be called at all (or yes, if it has already been queued).
*/
-- (void)handleLossWithHandler:(nullable void (^)())lossHandler
- wifiStatusChangeHandler:(nullable void (^)())wifiStatusChangeHandler;
+- (void)handleLossWithHandler:(nullable void (^)(void))lossHandler
+ wifiStatusChangeHandler:(nullable void (^)(void))wifiStatusChangeHandler;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
index b322638500..c8e10dd75f 100644
--- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
+++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
@@ -136,8 +136,8 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
return returnValue;
}
-- (void)handleLossWithHandler:(nullable void (^)())lossHandler
- wifiStatusChangeHandler:(nullable void (^)())wifiStatusChangeHandler {
+- (void)handleLossWithHandler:(nullable void (^)(void))lossHandler
+ wifiStatusChangeHandler:(nullable void (^)(void))wifiStatusChangeHandler {
__weak typeof(self) weakSelf = self;
[self startListeningWithHandler:^(GRPCReachabilityFlags *flags) {
typeof(self) strongSelf = weakSelf;
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h
index 58171211b0..0215db8531 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.h
+++ b/src/objective-c/GRPCClient/private/GRPCHost.h
@@ -18,6 +18,8 @@
#import <Foundation/Foundation.h>
+#import <grpc/impl/codegen/compression_types.h>
+
NS_ASSUME_NONNULL_BEGIN
@class GRPCCompletionQueue;
@@ -32,6 +34,7 @@ struct grpc_channel_credentials;
@property(nonatomic, readonly) NSString *address;
@property(nonatomic, copy, nullable) NSString *userAgentPrefix;
@property(nonatomic, nullable) struct grpc_channel_credentials *channelCreds;
+@property(nonatomic) grpc_compression_algorithm compressAlgorithm;
/** The following properties should only be modified for testing: */
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index f73e9cbc50..665943f181 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -87,13 +87,14 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
_address = address;
_secure = YES;
kHostCache[address] = self;
+ _compressAlgorithm = GRPC_COMPRESS_NONE;
}
// Keep a single monitor to flush the cache if the connectivity status changes
// Thread safety guarded by @synchronized(kHostCache)
if (!connectivityMonitor) {
connectivityMonitor =
[GRPCConnectivityMonitor monitorWithHost:hostURL.host];
- void (^handler)() = ^{
+ void (^handler)(void) = ^{
[GRPCHost flushChannelCache];
};
[connectivityMonitor handleLossWithHandler:handler
@@ -226,6 +227,12 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
}
// Use 10000ms initial backoff time for correct behavior on bad/slow networks
args[@GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS] = @10000;
+
+ if (_compressAlgorithm != GRPC_COMPRESS_NONE) {
+ args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] =
+ [NSNumber numberWithInt:_compressAlgorithm];
+ }
+
return args;
}
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index 1cd9da8f3e..f569895e7c 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -30,24 +30,24 @@
@interface GRPCOpSendMetadata : GRPCOperation
- (instancetype)initWithMetadata:(NSDictionary *)metadata
- handler:(void(^)())handler;
+ handler:(void(^)(void))handler;
- (instancetype)initWithMetadata:(NSDictionary *)metadata
flags:(uint32_t)flags
- handler:(void(^)())handler NS_DESIGNATED_INITIALIZER;
+ handler:(void(^)(void))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpSendMessage : GRPCOperation
- (instancetype)initWithMessage:(NSData *)message
- handler:(void(^)())handler NS_DESIGNATED_INITIALIZER;
+ handler:(void(^)(void))handler NS_DESIGNATED_INITIALIZER;
@end
@interface GRPCOpSendClose : GRPCOperation
-- (instancetype)initWithHandler:(void(^)())handler NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithHandler:(void(^)(void))handler NS_DESIGNATED_INITIALIZER;
@end
@@ -79,7 +79,7 @@
path:(NSString *)path
timeout:(NSTimeInterval)timeout NS_DESIGNATED_INITIALIZER;
-- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)())errorHandler;
+- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)(void))errorHandler;
- (void)startBatchWithOperations:(NSArray *)ops;
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index b0b1223b64..9a0fa5954a 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -36,12 +36,12 @@
// Most operation subclasses don't set any flags in the grpc_op, and rely on the flag member being
// initialized to zero.
grpc_op _op;
- void(^_handler)();
+ void(^_handler)(void);
}
- (void)finish {
if (_handler) {
- void(^handler)() = _handler;
+ void(^handler)(void) = _handler;
_handler = nil;
handler();
}
@@ -55,21 +55,19 @@
}
- (instancetype)initWithMetadata:(NSDictionary *)metadata
- handler:(void (^)())handler {
+ handler:(void (^)(void))handler {
return [self initWithMetadata:metadata flags:0 handler:handler];
}
- (instancetype)initWithMetadata:(NSDictionary *)metadata
flags:(uint32_t)flags
- handler:(void (^)())handler {
+ handler:(void (^)(void))handler {
if (self = [super init]) {
_op.op = GRPC_OP_SEND_INITIAL_METADATA;
_op.data.send_initial_metadata.count = metadata.count;
_op.data.send_initial_metadata.metadata = metadata.grpc_metadataArray;
_op.data.send_initial_metadata.maybe_compression_level.is_set = false;
_op.data.send_initial_metadata.maybe_compression_level.level = 0;
- _op.data.send_initial_metadata.maybe_stream_compression_level.is_set = false;
- _op.data.send_initial_metadata.maybe_stream_compression_level.level = 0;
_op.flags = flags;
_handler = handler;
}
@@ -92,7 +90,7 @@
return [self initWithMessage:nil handler:nil];
}
-- (instancetype)initWithMessage:(NSData *)message handler:(void (^)())handler {
+- (instancetype)initWithMessage:(NSData *)message handler:(void (^)(void))handler {
if (!message) {
[NSException raise:NSInvalidArgumentException format:@"message cannot be nil"];
}
@@ -116,7 +114,7 @@
return [self initWithHandler:nil];
}
-- (instancetype)initWithHandler:(void (^)())handler {
+- (instancetype)initWithHandler:(void (^)(void))handler {
if (self = [super init]) {
_op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
_handler = handler;
@@ -271,7 +269,7 @@
[self startBatchWithOperations:operations errorHandler:nil];
}
-- (void)startBatchWithOperations:(NSArray *)operations errorHandler:(void (^)())errorHandler {
+- (void)startBatchWithOperations:(NSArray *)operations errorHandler:(void (^)(void))errorHandler {
// Keep logs of op batches when we are running tests. Disabled when in production for improved
// performance.
#ifdef GRPC_TEST_OBJC
diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h
index 843954e84a..5c134e3642 100644
--- a/src/objective-c/GRPCClient/private/version.h
+++ b/src/objective-c/GRPCClient/private/version.h
@@ -23,4 +23,4 @@
// `tools/buildgen/generate_projects.sh`.
-#define GRPC_OBJC_VERSION_STRING @"1.7.0-dev"
+#define GRPC_OBJC_VERSION_STRING @"1.10.0-dev"
diff --git a/src/objective-c/README.md b/src/objective-c/README.md
index e76ee173ea..40aba0317b 100644
--- a/src/objective-c/README.md
+++ b/src/objective-c/README.md
@@ -1,5 +1,12 @@
[![Cocoapods](https://img.shields.io/cocoapods/v/gRPC.svg)](https://cocoapods.org/pods/gRPC)
# gRPC for Objective-C
+gRPC Objective C library provides Objective C API for users to make gRPC calls on iOS or OS X
+platforms. Currently, the minimum supported iOS version is 7.0 and OS X version is 10.9 (Mavericks).
+
+While gRPC doesn't require the use of an IDL to describe the API of services, using one simplifies
+usage and adds some interoperability guarantees. Here we use [Protocol Buffers][], and provide a
+plugin for the Protobuf Compiler (_protoc_) to generate client libraries to communicate with gRPC
+services.
- [Write your API declaration in proto format](#write-protos)
- [Integrate a proto library in your project](#cocoapods)
@@ -10,11 +17,6 @@
- [Install protoc and the gRPC plugin without using Homebrew](#no-homebrew)
- [Integrate the generated gRPC library without using Cocoapods](#no-cocoapods)
-While gRPC doesn't require the use of an IDL to describe the API of services, using one simplifies
-usage and adds some interoperability guarantees. Here we use [Protocol Buffers][], and provide a
-plugin for the Protobuf Compiler (_protoc_) to generate client libraries to communicate with gRPC
-services.
-
<a name="write-protos"></a>
## Write your API declaration in proto format
diff --git a/src/objective-c/RxLibrary/GRXConcurrentWriteable.h b/src/objective-c/RxLibrary/GRXConcurrentWriteable.h
index cec45fae71..f16a3d052a 100644
--- a/src/objective-c/RxLibrary/GRXConcurrentWriteable.h
+++ b/src/objective-c/RxLibrary/GRXConcurrentWriteable.h
@@ -46,7 +46,7 @@
* Enqueues writeValue: to be sent to the writeable in the main thread.
* The passed handler is invoked from the main thread after writeValue: returns.
*/
-- (void)enqueueValue:(id)value completionHandler:(void (^)())handler;
+- (void)enqueueValue:(id)value completionHandler:(void (^)(void))handler;
/**
* Enqueues writesFinishedWithError:nil to be sent to the writeable in the main thread. After that
diff --git a/src/objective-c/RxLibrary/GRXConcurrentWriteable.m b/src/objective-c/RxLibrary/GRXConcurrentWriteable.m
index bbfe491783..37bc975f87 100644
--- a/src/objective-c/RxLibrary/GRXConcurrentWriteable.m
+++ b/src/objective-c/RxLibrary/GRXConcurrentWriteable.m
@@ -50,7 +50,7 @@
dispatchQueue:dispatch_get_main_queue()];
}
-- (void)enqueueValue:(id)value completionHandler:(void (^)())handler {
+- (void)enqueueValue:(id)value completionHandler:(void (^)(void))handler {
dispatch_async(_writeableQueue, ^{
// We're racing a possible cancellation performed by another thread. To turn all already-
// enqueued messages into noops, cancellation nillifies the writeable property. If we get it
diff --git a/src/objective-c/RxLibrary/GRXImmediateWriter.h b/src/objective-c/RxLibrary/GRXImmediateWriter.h
index bdcf5d5937..f88e46b169 100644
--- a/src/objective-c/RxLibrary/GRXImmediateWriter.h
+++ b/src/objective-c/RxLibrary/GRXImmediateWriter.h
@@ -46,7 +46,7 @@
* Returns a writer that pushes to its writeable the successive values returned by the passed
* block. When the block first returns nil, it is released.
*/
-+ (GRXWriter *)writerWithValueSupplier:(id (^)())block;
++ (GRXWriter *)writerWithValueSupplier:(id (^)(void))block;
/**
* Returns a writer that iterates over the values of the passed container and pushes them to
diff --git a/src/objective-c/RxLibrary/GRXImmediateWriter.m b/src/objective-c/RxLibrary/GRXImmediateWriter.m
index d8c6975801..c5d6d1310a 100644
--- a/src/objective-c/RxLibrary/GRXImmediateWriter.m
+++ b/src/objective-c/RxLibrary/GRXImmediateWriter.m
@@ -52,7 +52,7 @@
return [self writerWithEnumerator:enumerator error:nil];
}
-+ (GRXWriter *)writerWithValueSupplier:(id (^)())block {
++ (GRXWriter *)writerWithValueSupplier:(id (^)(void))block {
return [self writerWithEnumerator:[NSEnumerator grx_enumeratorWithValueSupplier:block]];
}
diff --git a/src/objective-c/RxLibrary/GRXWriter+Immediate.h b/src/objective-c/RxLibrary/GRXWriter+Immediate.h
index 292a35f61f..d7935deaa2 100644
--- a/src/objective-c/RxLibrary/GRXWriter+Immediate.h
+++ b/src/objective-c/RxLibrary/GRXWriter+Immediate.h
@@ -30,7 +30,7 @@
* Returns a writer that pushes to its writeable the successive values returned by the passed
* block. When the block first returns nil, it is released.
*/
-+ (instancetype)writerWithValueSupplier:(id (^)())block;
++ (instancetype)writerWithValueSupplier:(id (^)(void))block;
/**
* Returns a writer that iterates over the values of the passed container and pushes them to
diff --git a/src/objective-c/RxLibrary/GRXWriter+Immediate.m b/src/objective-c/RxLibrary/GRXWriter+Immediate.m
index 43aa9c5437..a36a56764d 100644
--- a/src/objective-c/RxLibrary/GRXWriter+Immediate.m
+++ b/src/objective-c/RxLibrary/GRXWriter+Immediate.m
@@ -27,7 +27,7 @@
return [GRXImmediateWriter writerWithEnumerator:enumerator];
}
-+ (instancetype)writerWithValueSupplier:(id (^)())block {
++ (instancetype)writerWithValueSupplier:(id (^)(void))block {
return [GRXImmediateWriter writerWithValueSupplier:block];
}
diff --git a/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.h b/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.h
index 8c72f7858d..38dbaaf9a4 100644
--- a/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.h
+++ b/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.h
@@ -38,5 +38,5 @@
* Returns a NSEnumerator instance that delegates the invocations of nextObject to the passed block.
* When the block first returns nil, it is released.
*/
-+ (NSEnumerator *)grx_enumeratorWithValueSupplier:(id (^)())block;
++ (NSEnumerator *)grx_enumeratorWithValueSupplier:(id (^)(void))block;
@end
diff --git a/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.m b/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.m
index 309e25ede5..7d8191d0f7 100644
--- a/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.m
+++ b/src/objective-c/RxLibrary/NSEnumerator+GRXUtil.m
@@ -33,7 +33,7 @@
return [[GRXNSScalarEnumerator alloc] initWithValue:value];
}
-+ (NSEnumerator *)grx_enumeratorWithValueSupplier:(id (^)())block {
++ (NSEnumerator *)grx_enumeratorWithValueSupplier:(id (^)(void))block {
return [[GRXNSBlockEnumerator alloc] initWithValueSupplier:block];
}
@end
diff --git a/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.h b/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.h
index c45338acdd..c3317b2d04 100644
--- a/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.h
+++ b/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.h
@@ -27,5 +27,5 @@
* The first time the passed block returns nil, the enumeration will end and the block will be
* released.
*/
-- (instancetype)initWithValueSupplier:(id (^)())block;
+- (instancetype)initWithValueSupplier:(id (^)(void))block;
@end
diff --git a/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m b/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m
index 7e7cc572b8..eddfd26680 100644
--- a/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m
+++ b/src/objective-c/RxLibrary/private/GRXNSBlockEnumerator.m
@@ -19,14 +19,14 @@
#import "GRXNSBlockEnumerator.h"
@implementation GRXNSBlockEnumerator {
- id (^_block)();
+ id (^_block)(void);
}
- (instancetype)init {
return [self initWithValueSupplier:nil];
}
-- (instancetype)initWithValueSupplier:(id (^)())block {
+- (instancetype)initWithValueSupplier:(id (^)(void))block {
if ((self = [super init])) {
_block = block;
}
diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile
index f6f0c00d5d..9ea2f61927 100644
--- a/src/objective-c/examples/Sample/Podfile
+++ b/src/objective-c/examples/Sample/Podfile
@@ -40,7 +40,7 @@ pre_install do |installer|
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
- # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile
index b08a346ae2..a2c2b82cc9 100644
--- a/src/objective-c/examples/SwiftSample/Podfile
+++ b/src/objective-c/examples/SwiftSample/Podfile
@@ -40,7 +40,7 @@ pre_install do |installer|
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
- # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
diff --git a/src/objective-c/tests/Connectivity/Podfile b/src/objective-c/tests/Connectivity/Podfile
index 27ff935c54..cdbc6dde59 100644
--- a/src/objective-c/tests/Connectivity/Podfile
+++ b/src/objective-c/tests/Connectivity/Podfile
@@ -24,7 +24,7 @@ pre_install do |installer|
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
- # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
index 453b0752c3..16940a4917 100644
--- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
+++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
@@ -39,9 +39,9 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -58,7 +58,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
fullstack_secure_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ (fullstack_secure_fixture_data*)gpr_malloc(sizeof(fullstack_secure_fixture_data));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port);
@@ -81,7 +81,7 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
static void cronet_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args,
stream_engine *cronetEngine) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data;
f->client = grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr,
client_args, NULL);
GPR_ASSERT(f->client != NULL);
@@ -90,7 +90,7 @@ static void cronet_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
static void chttp2_init_server_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
grpc_server_credentials *server_creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data;
if (f->server) {
grpc_server_destroy(f->server);
}
@@ -103,20 +103,19 @@ static void chttp2_init_server_secure_fullstack(
}
static void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data;
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
static void cronet_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_exec_ctx ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
stream_engine *cronetEngine = [Cronet getGlobalEngine];
grpc_channel_args *new_client_args = grpc_channel_args_copy(client_args);
cronet_init_client_secure_fullstack(f, new_client_args, cronetEngine);
- grpc_channel_args_destroy(&ctx, new_client_args);
- grpc_exec_ctx_finish(&ctx);
+ grpc_channel_args_destroy(new_client_args);
}
static int fail_server_auth_check(grpc_channel_args *server_args) {
@@ -171,7 +170,7 @@ static char *roots_filename;
FILE *roots_file;
size_t roots_size = strlen(test_root_cert);
- char *argv[] = {"CoreCronetEnd2EndTests"};
+ char *argv[] = {(char *)"CoreCronetEnd2EndTests"};
grpc_test_init(1, argv);
grpc_end2end_tests_pre_init();
@@ -207,7 +206,7 @@ static char *roots_filename;
}
- (void)testIndividualCase:(char *)test_case {
- char *argv[] = {"h2_ssl", test_case};
+ char *argv[] = {(char *)"h2_ssl", test_case};
for (int i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
grpc_end2end_tests(sizeof(argv) / sizeof(argv[0]), argv, configs[i]);
@@ -217,182 +216,182 @@ static char *roots_filename;
// TODO(mxyan): Use NSStringFromSelector(_cmd) to acquire test name from the
// test case method name, so that bodies of test cases can stay identical
- (void)testAuthorityNotSupported {
- [self testIndividualCase:"authority_not_supported"];
+ [self testIndividualCase:(char *)"authority_not_supported"];
}
- (void)testBadHostname {
- [self testIndividualCase:"bad_hostname"];
+ [self testIndividualCase:(char *)"bad_hostname"];
}
- (void)testBinaryMetadata {
// NOT SUPPORTED
- //[self testIndividualCase:"binary_metadata"];
+ //[self testIndividualCase:(char *)"binary_metadata"];
}
- (void)testCallCreds {
// NOT SUPPORTED
- // [self testIndividualCase:"call_creds"];
+ // [self testIndividualCase:(char *)"call_creds"];
}
- (void)testCancelAfterAccept {
- [self testIndividualCase:"cancel_after_accept"];
+ [self testIndividualCase:(char *)"cancel_after_accept"];
}
- (void)testCancelAfterClientDone {
- [self testIndividualCase:"cancel_after_client_done"];
+ [self testIndividualCase:(char *)"cancel_after_client_done"];
}
- (void)testCancelAfterInvoke {
- [self testIndividualCase:"cancel_after_invoke"];
+ [self testIndividualCase:(char *)"cancel_after_invoke"];
}
- (void)testCancelAfterRoundTrip {
- [self testIndividualCase:"cancel_after_round_trip"];
+ [self testIndividualCase:(char *)"cancel_after_round_trip"];
}
- (void)testCancelBeforeInvoke {
- [self testIndividualCase:"cancel_before_invoke"];
+ [self testIndividualCase:(char *)"cancel_before_invoke"];
}
- (void)testCancelInAVacuum {
- [self testIndividualCase:"cancel_in_a_vacuum"];
+ [self testIndividualCase:(char *)"cancel_in_a_vacuum"];
}
- (void)testCancelWithStatus {
- [self testIndividualCase:"cancel_with_status"];
+ [self testIndividualCase:(char *)"cancel_with_status"];
}
- (void)testCompressedPayload {
- [self testIndividualCase:"compressed_payload"];
+ [self testIndividualCase:(char *)"compressed_payload"];
}
- (void)testConnectivity {
// NOT SUPPORTED
- // [self testIndividualCase:"connectivity"];
+ // [self testIndividualCase:(char *)"connectivity"];
}
- (void)testDefaultHost {
- [self testIndividualCase:"default_host"];
+ [self testIndividualCase:(char *)"default_host"];
}
- (void)testDisappearingServer {
- [self testIndividualCase:"disappearing_server"];
+ [self testIndividualCase:(char *)"disappearing_server"];
}
- (void)testEmptyBatch {
- [self testIndividualCase:"empty_batch"];
+ [self testIndividualCase:(char *)"empty_batch"];
}
- (void)testFilterCausesClose {
// NOT SUPPORTED
- // [self testIndividualCase:"filter_causes_close"];
+ // [self testIndividualCase:(char *)"filter_causes_close"];
}
- (void)testGracefulServerShutdown {
- [self testIndividualCase:"graceful_server_shutdown"];
+ [self testIndividualCase:(char *)"graceful_server_shutdown"];
}
- (void)testHighInitialSeqno {
- [self testIndividualCase:"high_initial_seqno"];
+ [self testIndividualCase:(char *)"high_initial_seqno"];
}
- (void)testHpackSize {
// NOT SUPPORTED
- // [self testIndividualCase:"hpack_size"];
+ // [self testIndividualCase:(char *)"hpack_size"];
}
- (void)testIdempotentRequest {
// NOT SUPPORTED
- // [self testIndividualCase:"idempotent_request"];
+ // [self testIndividualCase:(char *)"idempotent_request"];
}
- (void)testInvokeLargeRequest {
// NOT SUPPORTED (frame size)
- // [self testIndividualCase:"invoke_large_request"];
+ // [self testIndividualCase:(char *)"invoke_large_request"];
}
- (void)testLargeMetadata {
// NOT SUPPORTED
- // [self testIndividualCase:"large_metadata"];
+ // [self testIndividualCase:(char *)"large_metadata"];
}
- (void)testMaxConcurrentStreams {
- [self testIndividualCase:"max_concurrent_streams"];
+ [self testIndividualCase:(char *)"max_concurrent_streams"];
}
- (void)testMaxMessageLength {
// NOT SUPPORTED (close_error)
- // [self testIndividualCase:"max_message_length"];
+ // [self testIndividualCase:(char *)"max_message_length"];
}
- (void)testNegativeDeadline {
- [self testIndividualCase:"negative_deadline"];
+ [self testIndividualCase:(char *)"negative_deadline"];
}
- (void)testNetworkStatusChange {
- [self testIndividualCase:"network_status_change"];
+ [self testIndividualCase:(char *)"network_status_change"];
}
- (void)testNoOp {
- [self testIndividualCase:"no_op"];
+ [self testIndividualCase:(char *)"no_op"];
}
- (void)testPayload {
- [self testIndividualCase:"payload"];
+ [self testIndividualCase:(char *)"payload"];
}
- (void)testPing {
// NOT SUPPORTED
- // [self testIndividualCase:"ping"];
+ // [self testIndividualCase:(char *)"ping"];
}
- (void)testPingPongStreaming {
- [self testIndividualCase:"ping_pong_streaming"];
+ [self testIndividualCase:(char *)"ping_pong_streaming"];
}
- (void)testRegisteredCall {
- [self testIndividualCase:"registered_call"];
+ [self testIndividualCase:(char *)"registered_call"];
}
- (void)testRequestWithFlags {
// NOT SUPPORTED
- // [self testIndividualCase:"request_with_flags"];
+ // [self testIndividualCase:(char *)"request_with_flags"];
}
- (void)testRequestWithPayload {
- [self testIndividualCase:"request_with_payload"];
+ [self testIndividualCase:(char *)"request_with_payload"];
}
- (void)testServerFinishesRequest {
- [self testIndividualCase:"server_finishes_request"];
+ [self testIndividualCase:(char *)"server_finishes_request"];
}
- (void)testShutdownFinishesCalls {
- [self testIndividualCase:"shutdown_finishes_calls"];
+ [self testIndividualCase:(char *)"shutdown_finishes_calls"];
}
- (void)testShutdownFinishesTags {
- [self testIndividualCase:"shutdown_finishes_tags"];
+ [self testIndividualCase:(char *)"shutdown_finishes_tags"];
}
- (void)testSimpleDelayedRequest {
- [self testIndividualCase:"simple_delayed_request"];
+ [self testIndividualCase:(char *)"simple_delayed_request"];
}
- (void)testSimpleMetadata {
- [self testIndividualCase:"simple_metadata"];
+ [self testIndividualCase:(char *)"simple_metadata"];
}
- (void)testSimpleRequest {
- [self testIndividualCase:"simple_request"];
+ [self testIndividualCase:(char *)"simple_request"];
}
- (void)testStreamingErrorResponse {
- [self testIndividualCase:"streaming_error_response"];
+ [self testIndividualCase:(char *)"streaming_error_response"];
}
- (void)testTrailingMetadata {
- [self testIndividualCase:"trailing_metadata"];
+ [self testIndividualCase:(char *)"trailing_metadata"];
}
@end
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index 0d295fb3c0..09ee062596 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -31,9 +31,9 @@
#import <grpc/support/log.h>
#import "src/core/lib/channel/channel_args.h"
-#import "src/core/lib/support/env.h"
-#import "src/core/lib/support/string.h"
-#import "src/core/lib/support/tmpfile.h"
+#import "src/core/lib/gpr/env.h"
+#import "src/core/lib/gpr/string.h"
+#import "src/core/lib/gpr/tmpfile.h"
#import "test/core/end2end/data/ssl_test_data.h"
#import "test/core/util/test_config.h"
@@ -56,7 +56,7 @@ static void drain_cq(grpc_completion_queue *cq) {
+ (void)setUp {
[super setUp];
- char *argv[] = {"CoreCronetEnd2EndTests"};
+ char *argv[] = {(char *)"CoreCronetEnd2EndTests"};
grpc_test_init(1, argv);
grpc_init();
@@ -100,7 +100,7 @@ void init_ctx(SSL_CTX *ctx) {
// Install server certificate
BIO *pem = BIO_new_mem_buf((void *)test_server1_cert,
(int)strlen(test_server1_cert));
- X509 *cert = PEM_read_bio_X509_AUX(pem, NULL, NULL, "");
+ X509 *cert = PEM_read_bio_X509_AUX(pem, NULL, NULL, (char *)"");
SSL_CTX_use_certificate(ctx, cert);
X509_free(cert);
BIO_free(pem);
@@ -108,7 +108,7 @@ void init_ctx(SSL_CTX *ctx) {
// Install server private key
pem =
BIO_new_mem_buf((void *)test_server1_key, (int)strlen(test_server1_key));
- EVP_PKEY *key = PEM_read_bio_PrivateKey(pem, NULL, NULL, "");
+ EVP_PKEY *key = PEM_read_bio_PrivateKey(pem, NULL, NULL, (char *)"");
SSL_CTX_use_PrivateKey(ctx, key);
EVP_PKEY_free(key);
BIO_free(pem);
@@ -258,7 +258,7 @@ unsigned int parse_h2_length(const char *field) {
- (void)packetCoalescing:(BOOL)useCoalescing {
grpc_arg arg;
- arg.key = GRPC_ARG_USE_CRONET_PACKET_COALESCING;
+ arg.key = (char *)GRPC_ARG_USE_CRONET_PACKET_COALESCING;
arg.type = GRPC_ARG_INTEGER;
arg.value.integer = useCoalescing ? 1 : 0;
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m
index 82ac2600fa..3bab7f6671 100644
--- a/src/objective-c/tests/GRPCClientTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -18,6 +18,7 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
+#import <grpc/grpc.h>
#import <GRPCClient/GRPCCall.h>
#import <GRPCClient/GRPCCall+ChannelArg.h>
@@ -30,6 +31,8 @@
#import <RxLibrary/GRXWriter+Immediate.h>
#import <RxLibrary/GRXBufferedPipe.h>
+#import "version.h"
+
#define TEST_TIMEOUT 16
static NSString * const kHostAddress = @"localhost:5050";
@@ -92,6 +95,10 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
@implementation GRPCClientTests
++ (void)setUp {
+ NSLog(@"GRPCClientTests Started");
+}
+
- (void)setUp {
// Add a custom user agent prefix that will be used in test
[GRPCCall setUserAgentPrefix:@"Foo" forHost:kHostAddress];
@@ -266,12 +273,38 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertEqual([value length], 0, @"Non-empty response received: %@", value);
- /* This test needs to be more clever in regards to changing the version of the core.
- XCTAssertEqualObjects(call.responseHeaders[@"x-grpc-test-echo-useragent"],
- @"Foo grpc-objc/0.13.0 grpc-c/0.14.0-dev (ios)",
- @"Did not receive expected user agent %@",
- call.responseHeaders[@"x-grpc-test-echo-useragent"]);
- */
+
+ NSString *userAgent = call.responseHeaders[@"x-grpc-test-echo-useragent"];
+ NSError *error = nil;
+
+ // Test the regex is correct
+ NSString *expectedUserAgent = @"Foo grpc-objc/";
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:GRPC_OBJC_VERSION_STRING];
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:@" grpc-c/"];
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:GRPC_C_VERSION_STRING];
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:@" (ios; chttp2; "];
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:[NSString stringWithUTF8String:grpc_g_stands_for()]];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@")"];
+ XCTAssertEqualObjects(userAgent, expectedUserAgent);
+
+ // Change in format of user-agent field in a direction that does not match the regex will likely
+ // cause problem for certain gRPC users. For details, refer to internal doc https://goo.gl/c2diBc
+ NSRegularExpression *regex =
+ [NSRegularExpression regularExpressionWithPattern:@" grpc-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?/[^ ,]+( \\([^)]*\\))?"
+ options:0
+ error:&error];
+ NSString *customUserAgent =
+ [regex stringByReplacingMatchesInString:userAgent
+ options:0
+ range:NSMakeRange(0, [userAgent length])
+ withTemplate:@""];
+ XCTAssertEqualObjects(customUserAgent, @"Foo");
+
[response fulfill];
} completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index e5fcab26d8..dfa874adab 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -68,6 +68,10 @@
}
@end
+BOOL isRemoteInteropTest(NSString *host) {
+ return [host isEqualToString:@"grpc-test.sandbox.googleapis.com"];
+}
+
#pragma mark Tests
@implementation InteropTests {
@@ -86,6 +90,7 @@
}
+ (void)setUp {
+ NSLog(@"InteropTest Started, class: %@", [[self class] description]);
#ifdef GRPC_COMPILE_WITH_CRONET
// Cronet setup
[Cronet setHttp2Enabled:YES];
@@ -451,4 +456,34 @@
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testCompressedUnaryRPC {
+ // This test needs to be disabled for remote test because interop server grpc-test
+ // does not support compression.
+ if (isRemoteInteropTest(self.class.host)) {
+ return;
+ }
+ XCTAssertNotNil(self.class.host);
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.responseType = RMTPayloadType_Compressable;
+ request.responseSize = 314159;
+ request.payload.body = [NSMutableData dataWithLength:271828];
+ request.expectCompressed.value = YES;
+ [GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:self.class.host];
+
+ [_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+
+ RMTSimpleResponse *expectedResponse = [RMTSimpleResponse message];
+ expectedResponse.payload.type = RMTPayloadType_Compressable;
+ expectedResponse.payload.body = [NSMutableData dataWithLength:314159];
+ XCTAssertEqualObjects(response, expectedResponse);
+
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
@end
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 8f1cb041d8..9e9db1fe6c 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -75,7 +75,7 @@ pre_install do |installer|
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
- # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
index 1796c6d746..ad83481595 100644
--- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
+++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
@@ -47,7 +47,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
# This is needed by all pods that depend on Protobuf:
- 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
+ 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=1',
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
}
diff --git a/src/objective-c/tests/RemoteTestClient/messages.proto b/src/objective-c/tests/RemoteTestClient/messages.proto
index 128efd9337..342e91d5aa 100644
--- a/src/objective-c/tests/RemoteTestClient/messages.proto
+++ b/src/objective-c/tests/RemoteTestClient/messages.proto
@@ -20,34 +20,45 @@ package grpc.testing;
option objc_class_prefix = "RMT";
+// TODO(dgq): Go back to using well-known types once
+// https://github.com/grpc/grpc/issues/6980 has been fixed.
+// import "google/protobuf/wrappers.proto";
+message BoolValue {
+ // The bool value.
+ bool value = 1;
+}
+
+// DEPRECATED, don't use. To be removed shortly.
// The type of payload that should be returned.
enum PayloadType {
// Compressable text format.
COMPRESSABLE = 0;
-
- // Uncompressable binary format.
- UNCOMPRESSABLE = 1;
-
- // Randomly chosen from all other formats defined in this enum.
- RANDOM = 2;
}
// A block of data, to simply increase gRPC message size.
message Payload {
+ // DEPRECATED, don't use. To be removed shortly.
// The type of data in body.
PayloadType type = 1;
// Primary contents of payload.
bytes body = 2;
}
+// A protobuf representation for grpc status. This is used by test
+// clients to specify a status that the server should attempt to return.
+message EchoStatus {
+ int32 code = 1;
+ string message = 2;
+}
+
// Unary request.
message SimpleRequest {
+ // DEPRECATED, don't use. To be removed shortly.
// Desired payload type in the response from the server.
// If response_type is RANDOM, server randomly chooses one from other formats.
PayloadType response_type = 1;
// Desired payload size in the response from the server.
- // If response_type is COMPRESSABLE, this denotes the size before compression.
int32 response_size = 2;
// Optional input payload sent along with the request.
@@ -58,6 +69,18 @@ message SimpleRequest {
// Whether SimpleResponse should include OAuth scope.
bool fill_oauth_scope = 5;
+
+ // Whether to request the server to compress the response. This field is
+ // "nullable" in order to interoperate seamlessly with clients not able to
+ // implement the full compression tests by introspecting the call to verify
+ // the response's compression status.
+ BoolValue response_compressed = 6;
+
+ // Whether server should return a given status
+ EchoStatus response_status = 7;
+
+ // Whether the server should expect this request to be compressed.
+ BoolValue expect_compressed = 8;
}
// Unary response, as configured by the request.
@@ -76,6 +99,12 @@ message StreamingInputCallRequest {
// Optional input payload sent along with the request.
Payload payload = 1;
+ // Whether the server should expect this request to be compressed. This field
+ // is "nullable" in order to interoperate seamlessly with servers not able to
+ // implement the full compression tests by introspecting the call to verify
+ // the request's compression status.
+ BoolValue expect_compressed = 2;
+
// Not expecting any payload from the response.
}
@@ -88,16 +117,22 @@ message StreamingInputCallResponse {
// Configuration for a particular response.
message ResponseParameters {
// Desired payload sizes in responses from the server.
- // If response_type is COMPRESSABLE, this denotes the size before compression.
int32 size = 1;
// Desired interval between consecutive responses in the response stream in
// microseconds.
int32 interval_us = 2;
+
+ // Whether to request the server to compress the response. This field is
+ // "nullable" in order to interoperate seamlessly with clients not able to
+ // implement the full compression tests by introspecting the call to verify
+ // the response's compression status.
+ BoolValue compressed = 3;
}
// Server-streaming request.
message StreamingOutputCallRequest {
+ // DEPRECATED, don't use. To be removed shortly.
// Desired payload type in the response from the server.
// If response_type is RANDOM, the payload from each response in the stream
// might be of different types. This is to simulate a mixed type of payload
@@ -109,6 +144,9 @@ message StreamingOutputCallRequest {
// Optional input payload sent along with the request.
Payload payload = 3;
+
+ // Whether server should return a given status
+ EchoStatus response_status = 7;
}
// Server-streaming response, as configured by the request and parameters.
@@ -116,3 +154,17 @@ message StreamingOutputCallResponse {
// Payload to increase response size.
Payload payload = 1;
}
+
+// For reconnect interop test only.
+// Client tells server what reconnection parameters it used.
+message ReconnectParams {
+ int32 max_reconnect_backoff_ms = 1;
+}
+
+// For reconnect interop test only.
+// Server tells client whether its reconnects are following the spec and the
+// reconnect backoffs it saw.
+message ReconnectInfo {
+ bool passed = 1;
+ repeated int32 backoff_ms = 2;
+}
diff --git a/src/objective-c/tests/RxLibraryUnitTests.m b/src/objective-c/tests/RxLibraryUnitTests.m
index 3a5adbbf37..aa178f8d45 100644
--- a/src/objective-c/tests/RxLibraryUnitTests.m
+++ b/src/objective-c/tests/RxLibraryUnitTests.m
@@ -58,6 +58,10 @@
@implementation RxLibraryUnitTests
++ (void)setUp {
+ NSLog(@"GRPCClientTests Started");
+}
+
#pragma mark Writeable
- (void)testWriteableSingleHandlerIsCalledForValue {
diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
index b01d5ffcea..9a6cb0e7d7 100644
--- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
+++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
@@ -14,7 +14,7 @@
20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */; };
333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */; };
3D7C85F6AA68C4A205E3BA16 /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */; };
- 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m */; };
+ 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */; };
5E8A5DA91D3840B4000F8BC4 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
5EAD6D271E27047400002378 /* CronetUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.m */; };
5EAD6D291E27047400002378 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
@@ -140,10 +140,11 @@
573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; sourceTree = "<group>"; };
5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.release.xcconfig"; sourceTree = "<group>"; };
5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreCronetEnd2EndTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
- 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CoreCronetEnd2EndTests.m; sourceTree = "<group>"; };
+ 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = "<group>"; };
5EAD6D241E27047400002378 /* CronetUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5EAD6D261E27047400002378 /* CronetUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CronetUnitTests.m; sourceTree = "<group>"; };
5EAD6D281E27047400002378 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5EAFE8271F8EFB87007F2189 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
5EE84BF11D4717E40050C6CC /* InteropTestsRemoteWithCronet.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemoteWithCronet.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemoteWithCronet.m; sourceTree = "<group>"; };
5EE84BF51D4717E40050C6CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -342,7 +343,7 @@
5E8A5DA51D3840B4000F8BC4 /* CoreCronetEnd2EndTests */ = {
isa = PBXGroup;
children = (
- 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m */,
+ 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */,
);
path = CoreCronetEnd2EndTests;
sourceTree = "<group>";
@@ -398,6 +399,7 @@
635697C91B14FC11007A7283 /* Tests */ = {
isa = PBXGroup;
children = (
+ 5EAFE8271F8EFB87007F2189 /* version.h */,
6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */,
63E240CC1B6C4D3A005F3B0E /* InteropTests.h */,
635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */,
@@ -740,9 +742,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -755,9 +760,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh",
+ "${PODS_ROOT}/CronetFramework/Cronet.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -770,13 +778,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemote-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
4F5690DC0E6AD6663FE78B8B /* [CP] Embed Pods Frameworks */ = {
@@ -800,13 +811,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalSSL-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
5F14F59509E10C2852014F9E /* [CP] Embed Pods Frameworks */ = {
@@ -830,9 +844,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -845,9 +862,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -860,13 +880,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalCleartext-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
796680C7599CB4ED736DD62A /* [CP] Check Pods Manifest.lock */ = {
@@ -875,13 +898,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
80E2DDD2EC04A4009F45E933 /* [CP] Check Pods Manifest.lock */ = {
@@ -890,13 +916,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-CronetUnitTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
8AD3130D3C58A0FB32FF2A36 /* [CP] Copy Pods Resources */ = {
@@ -905,9 +934,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -935,13 +967,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-AllTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */ = {
@@ -950,9 +985,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -965,9 +1003,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh",
+ "${PODS_ROOT}/CronetFramework/Cronet.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -995,9 +1036,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1010,13 +1054,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-RxLibraryUnitTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
C0F7B1FF6F88CC5FBF362F4C /* [CP] Check Pods Manifest.lock */ = {
@@ -1025,13 +1072,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemoteWithCronet-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
C2E09DC4BD239F71160F0CC1 /* [CP] Copy Pods Resources */ = {
@@ -1040,9 +1090,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1070,9 +1123,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1085,9 +1141,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh",
+ $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle,
);
name = "[CP] Copy Pods Resources";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1100,9 +1159,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh",
+ "${PODS_ROOT}/CronetFramework/Cronet.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1115,13 +1177,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-CoreCronetEnd2EndTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -1131,7 +1196,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m in Sources */,
+ 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1453,6 +1518,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_TESTABILITY = YES;
+ GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
INFOPLIST_FILE = CronetUnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -1502,6 +1568,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_TESTABILITY = YES;
+ GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
INFOPLIST_FILE = CronetUnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -1517,6 +1584,7 @@
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
INFOPLIST_FILE = CronetUnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -1532,6 +1600,7 @@
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
INFOPLIST_FILE = CronetUnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh
index 608ae6884b..cec34787cf 100755
--- a/src/objective-c/tests/run_tests.sh
+++ b/src/objective-c/tests/run_tests.sh
@@ -34,23 +34,50 @@ $BINDIR/interop_server --port=5051 --max_send_message_size=8388608 --use_tls &
# Kill them when this script exits.
trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT
+set -o pipefail
+
# xcodebuild is very verbose. We filter its output and tell Bash to fail if any
# element of the pipe fails.
# TODO(jcanizales): Use xctool instead? Issue #2540.
-set -o pipefail
-XCODEBUILD_FILTER='(^CompileC |^Ld |^.*clang |^ *cd |^ *export |^Libtool |^.*libtool |^CpHeader |^ *builtin-copy )'
+XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )'
+
echo "TIME: $(date)"
-xcodebuild \
- -workspace Tests.xcworkspace \
- -scheme AllTests \
- -destination name="iPhone 6" \
- HOST_PORT_LOCALSSL=localhost:5051 \
- HOST_PORT_LOCAL=localhost:5050 \
- HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
- test \
- | egrep -v "$XCODEBUILD_FILTER" \
- | egrep -v '^$' \
- | egrep -v "(GPBDictionary|GPBArray)" -
+
+# Retry the test for up to 3 times when return code is 65, due to Xcode issue:
+# http://www.openradar.me/29785686
+# The issue seems to be a connectivity issue to Xcode simulator so only retry
+# the first xcodebuild command
+retries=0
+while [ $retries -lt 3 ]; do
+ return_code=0
+ out=$(xcodebuild \
+ -workspace Tests.xcworkspace \
+ -scheme AllTests \
+ -destination name="iPhone 6" \
+ HOST_PORT_LOCALSSL=localhost:5051 \
+ HOST_PORT_LOCAL=localhost:5050 \
+ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
+ test 2>&1 \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" - ) || return_code=$?
+ if [ $return_code == 65 ] && [[ $out == *"DTXProxyChannel error 1"* ]]; then
+ echo "$out"
+ echo "Failed with code 65 (DTXProxyChannel error 1); retry."
+ retries=$(($retries+1))
+ elif [ $return_code == 0 ]; then
+ echo "$out"
+ break
+ else
+ echo "$out"
+ echo "Failed with code $return_code."
+ exit 1
+ fi
+done
+if [ $retries == 3 ]; then
+ echo "Failed with code 65 for 3 times; abort."
+ exit 1
+fi
echo "TIME: $(date)"
xcodebuild \
@@ -82,3 +109,5 @@ xcodebuild \
| egrep -v "$XCODEBUILD_FILTER" \
| egrep -v '^$' \
| egrep -v "(GPBDictionary|GPBArray)" -
+
+exit 0
diff --git a/src/core/ext/census/census_init.c b/src/objective-c/tests/version.h
index d7f719ff8c..d8581b9779 100644
--- a/src/core/ext/census/census_init.c
+++ b/src/objective-c/tests/version.h
@@ -16,18 +16,12 @@
*
*/
-#include "src/core/ext/census/census_interface.h"
+// This file is autogenerated from a template file. Please make
+// modifications to
+// `templates/src/objective-c/GRPCClient/private/version.h.template`
+// instead. This file can be regenerated from the template by running
+// `tools/buildgen/generate_projects.sh`.
-#include <grpc/support/log.h>
-#include "src/core/ext/census/census_rpc_stats.h"
-#include "src/core/ext/census/census_tracing.h"
-void census_init(void) {
- census_tracing_init();
- census_stats_store_init();
-}
-
-void census_shutdown(void) {
- census_stats_store_shutdown();
- census_tracing_shutdown();
-}
+#define GRPC_OBJC_VERSION_STRING @"1.10.0-dev"
+#define GRPC_C_VERSION_STRING @"5.0.0-dev"
diff --git a/src/php/composer.json b/src/php/composer.json
index 3606a18f34..ea21417956 100644
--- a/src/php/composer.json
+++ b/src/php/composer.json
@@ -2,7 +2,7 @@
"name": "grpc/grpc-dev",
"description": "gRPC library for PHP - for Developement use only",
"license": "Apache-2.0",
- "version": "1.7.0",
+ "version": "1.10.0",
"require": {
"php": ">=5.5.0",
"google/protobuf": "^v3.3.0"
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index c71fa8a9e8..b802f04f53 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -99,6 +99,7 @@ zval *grpc_parse_metadata_array(grpc_metadata_array
1 TSRMLS_CC);
efree(str_key);
efree(str_val);
+ PHP_GRPC_FREE_STD_ZVAL(array);
return NULL;
}
php_grpc_add_next_index_stringl(data, str_val,
@@ -127,10 +128,12 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) {
HashTable *inner_array_hash;
zval *value;
zval *inner_array;
+ grpc_metadata_array_init(metadata);
+ metadata->count = 0;
+ metadata->metadata = NULL;
if (Z_TYPE_P(array) != IS_ARRAY) {
return false;
}
- grpc_metadata_array_init(metadata);
array_hash = Z_ARRVAL_P(array);
char *key;
@@ -174,6 +177,18 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) {
return true;
}
+void grpc_php_metadata_array_destroy_including_entries(
+ grpc_metadata_array* array) {
+ size_t i;
+ if (array->metadata) {
+ for (i = 0; i < array->count; i++) {
+ grpc_slice_unref(array->metadata[i].key);
+ grpc_slice_unref(array->metadata[i].value);
+ }
+ }
+ grpc_metadata_array_destroy(array);
+}
+
/* Wraps a grpc_call struct in a PHP object. Owned indicates whether the
struct should be destroyed at the end of the object's lifecycle */
zval *grpc_php_wrap_call(grpc_call *wrapped, bool owned TSRMLS_DC) {
@@ -504,8 +519,8 @@ PHP_METHOD(Call, startBatch) {
}
cleanup:
- grpc_metadata_array_destroy(&metadata);
- grpc_metadata_array_destroy(&trailing_metadata);
+ grpc_php_metadata_array_destroy_including_entries(&metadata);
+ grpc_php_metadata_array_destroy_including_entries(&trailing_metadata);
grpc_metadata_array_destroy(&recv_metadata);
grpc_metadata_array_destroy(&recv_trailing_metadata);
grpc_slice_unref(recv_status_details);
@@ -528,7 +543,9 @@ cleanup:
*/
PHP_METHOD(Call, getPeer) {
wrapped_grpc_call *call = Z_WRAPPED_GRPC_CALL_P(getThis());
- PHP_GRPC_RETURN_STRING(grpc_call_get_peer(call->wrapped), 1);
+ char *peer = grpc_call_get_peer(call->wrapped);
+ PHP_GRPC_RETVAL_STRING(peer, 1);
+ gpr_free(peer);
}
/**
diff --git a/src/php/ext/grpc/call.h b/src/php/ext/grpc/call.h
index 5bde5d5390..104ac301c1 100644
--- a/src/php/ext/grpc/call.h
+++ b/src/php/ext/grpc/call.h
@@ -69,5 +69,6 @@ void grpc_init_call(TSRMLS_D);
/* Populates a grpc_metadata_array with the data in a PHP array object.
Returns true on success and false on failure */
bool create_metadata_array(zval *array, grpc_metadata_array *metadata);
-
+void grpc_php_metadata_array_destroy_including_entries(
+ grpc_metadata_array* array);
#endif /* NET_GRPC_PHP_GRPC_CHANNEL_H_ */
diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c
index 1eee8645df..41c488a79c 100644
--- a/src/php/ext/grpc/call_credentials.c
+++ b/src/php/ext/grpc/call_credentials.c
@@ -35,6 +35,7 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
+#include <grpc/support/string_util.h>
zend_class_entry *grpc_ce_call_credentials;
#if PHP_MAJOR_VERSION >= 7
@@ -119,6 +120,8 @@ PHP_METHOD(CallCredentials, createFromPlugin) {
fci->params, fci->param_count) == FAILURE) {
zend_throw_exception(spl_ce_InvalidArgumentException,
"createFromPlugin expects 1 callback", 1 TSRMLS_CC);
+ free(fci);
+ free(fci_cache);
return;
}
@@ -143,9 +146,12 @@ PHP_METHOD(CallCredentials, createFromPlugin) {
}
/* Callback function for plugin creds API */
-void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data) {
+int plugin_get_metadata(
+ void *ptr, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t *num_creds_md, grpc_status_code *status,
+ const char **error_details) {
TSRMLS_FETCH();
plugin_state *state = (plugin_state *)ptr;
@@ -175,15 +181,21 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context,
/* call the user callback function */
zend_call_function(state->fci, state->fci_cache TSRMLS_CC);
- grpc_status_code code = GRPC_STATUS_OK;
+ *num_creds_md = 0;
+ *status = GRPC_STATUS_OK;
+ *error_details = NULL;
+
+ bool should_return = false;
grpc_metadata_array metadata;
- bool cleanup = true;
if (retval == NULL || Z_TYPE_P(retval) != IS_ARRAY) {
- cleanup = false;
- code = GRPC_STATUS_INVALID_ARGUMENT;
- } else if (!create_metadata_array(retval, &metadata)) {
- code = GRPC_STATUS_INVALID_ARGUMENT;
+ *status = GRPC_STATUS_INVALID_ARGUMENT;
+ should_return = true; // Synchronous return.
+ }
+ if (!create_metadata_array(retval, &metadata)) {
+ *status = GRPC_STATUS_INVALID_ARGUMENT;
+ should_return = true; // Synchronous return.
+ grpc_php_metadata_array_destroy_including_entries(&metadata);
}
if (retval != NULL) {
@@ -196,15 +208,28 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context,
PHP_GRPC_FREE_STD_ZVAL(retval);
#endif
}
+ if (should_return) {
+ return true;
+ }
- /* Pass control back to core */
- cb(user_data, metadata.metadata, metadata.count, code, NULL);
- if (cleanup) {
- for (int i = 0; i < metadata.count; i++) {
+ if (metadata.count > GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX) {
+ *status = GRPC_STATUS_INTERNAL;
+ *error_details = gpr_strdup(
+ "PHP plugin credentials returned too many metadata entries");
+ for (size_t i = 0; i < metadata.count; i++) {
+ // TODO(stanleycheung): Why don't we need to unref the key here?
grpc_slice_unref(metadata.metadata[i].value);
}
- grpc_metadata_array_destroy(&metadata);
+ } else {
+ // Return data to core.
+ *num_creds_md = metadata.count;
+ for (size_t i = 0; i < metadata.count; ++i) {
+ creds_md[i] = metadata.metadata[i];
+ }
}
+
+ grpc_metadata_array_destroy(&metadata);
+ return true; // Synchronous return.
}
/* Cleanup function for plugin creds API */
diff --git a/src/php/ext/grpc/call_credentials.h b/src/php/ext/grpc/call_credentials.h
index 9be8763278..663cc6858d 100755
--- a/src/php/ext/grpc/call_credentials.h
+++ b/src/php/ext/grpc/call_credentials.h
@@ -65,9 +65,12 @@ typedef struct plugin_state {
} plugin_state;
/* Callback function for plugin creds API */
-void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data);
+int plugin_get_metadata(
+ void *ptr, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t *num_creds_md, grpc_status_code *status,
+ const char **error_details);
/* Cleanup function for plugin creds API */
void plugin_destroy_state(void *ptr);
diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c
index dc3acc89bb..4054723b43 100644
--- a/src/php/ext/grpc/channel.c
+++ b/src/php/ext/grpc/channel.c
@@ -41,6 +41,7 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
#include "completion_queue.h"
#include "channel_credentials.h"
@@ -56,22 +57,63 @@ int le_plink;
/* Frees and destroys an instance of wrapped_grpc_channel */
PHP_GRPC_FREE_WRAPPED_FUNC_START(wrapped_grpc_channel)
+ bool is_last_wrapper = false;
+ // In_persistent_list is used when the user don't close the channel.
+ // In this case, le in the list won't be freed.
+ bool in_persistent_list = true;
if (p->wrapper != NULL) {
gpr_mu_lock(&p->wrapper->mu);
if (p->wrapper->wrapped != NULL) {
- php_grpc_zend_resource *rsrc;
- php_grpc_int key_len = strlen(p->wrapper->key);
- // only destroy the channel here if not found in the persistent list
- gpr_mu_lock(&global_persistent_list_mu);
- if (!(PHP_GRPC_PERSISTENT_LIST_FIND(&EG(persistent_list), p->wrapper->key,
- key_len, rsrc))) {
- grpc_channel_destroy(p->wrapper->wrapped);
- free(p->wrapper->target);
- free(p->wrapper->args_hashstr);
+ if (p->wrapper->is_valid) {
+ php_grpc_zend_resource *rsrc;
+ php_grpc_int key_len = strlen(p->wrapper->key);
+ // only destroy the channel here if not found in the persistent list
+ gpr_mu_lock(&global_persistent_list_mu);
+ if (!(PHP_GRPC_PERSISTENT_LIST_FIND(&EG(persistent_list), p->wrapper->key,
+ key_len, rsrc))) {
+ in_persistent_list = false;
+ grpc_channel_destroy(p->wrapper->wrapped);
+ free(p->wrapper->target);
+ free(p->wrapper->args_hashstr);
+ if(p->wrapper->creds_hashstr != NULL){
+ free(p->wrapper->creds_hashstr);
+ p->wrapper->creds_hashstr = NULL;
+ }
+ }
+ gpr_mu_unlock(&global_persistent_list_mu);
}
- gpr_mu_unlock(&global_persistent_list_mu);
+ }
+ p->wrapper->ref_count -= 1;
+ if (p->wrapper->ref_count == 0) {
+ is_last_wrapper = true;
}
gpr_mu_unlock(&p->wrapper->mu);
+ if (is_last_wrapper) {
+ if (in_persistent_list) {
+ // If ref_count==0 and the key still in the list, it means the user
+ // don't call channel->close().persistent list should free the
+ // allocation in such case, as well as related wrapped channel.
+ if (p->wrapper->wrapped != NULL) {
+ gpr_mu_lock(&p->wrapper->mu);
+ grpc_channel_destroy(p->wrapper->wrapped);
+ free(p->wrapper->target);
+ free(p->wrapper->args_hashstr);
+ if(p->wrapper->creds_hashstr != NULL){
+ free(p->wrapper->creds_hashstr);
+ p->wrapper->creds_hashstr = NULL;
+ }
+ p->wrapper->wrapped = NULL;
+ php_grpc_delete_persistent_list_entry(p->wrapper->key,
+ strlen(p->wrapper->key)
+ TSRMLS_CC);
+ gpr_mu_unlock(&p->wrapper->mu);
+ }
+ }
+ gpr_mu_destroy(&p->wrapper->mu);
+ free(p->wrapper->key);
+ free(p->wrapper);
+ }
+ p->wrapper = NULL;
}
PHP_GRPC_FREE_WRAPPED_FUNC_END()
@@ -242,6 +284,7 @@ PHP_METHOD(Channel, __construct) {
// parse the rest of the channel args array
if (php_grpc_read_args_array(args_array, &args TSRMLS_CC) == FAILURE) {
+ efree(args.args);
return;
}
@@ -275,9 +318,16 @@ PHP_METHOD(Channel, __construct) {
channel->wrapper->key = key;
channel->wrapper->target = strdup(target);
channel->wrapper->args_hashstr = strdup(sha1str);
+ channel->wrapper->creds_hashstr = NULL;
+ channel->wrapper->ref_count = 1;
+ channel->wrapper->is_valid = true;
if (creds != NULL && creds->hashstr != NULL) {
- channel->wrapper->creds_hashstr = creds->hashstr;
+ php_grpc_int creds_hashstr_len = strlen(creds->hashstr);
+ char *channel_creds_hashstr = malloc(creds_hashstr_len + 1);
+ strcpy(channel_creds_hashstr, creds->hashstr);
+ channel->wrapper->creds_hashstr = channel_creds_hashstr;
}
+
gpr_mu_init(&channel->wrapper->mu);
smart_str_free(&buf);
@@ -301,7 +351,18 @@ PHP_METHOD(Channel, __construct) {
create_and_add_channel_to_persistent_list(
channel, target, args, creds, key, key_len TSRMLS_CC);
} else {
+ efree(args.args);
+ if (channel->wrapper->creds_hashstr != NULL){
+ free(channel->wrapper->creds_hashstr);
+ channel->wrapper->creds_hashstr = NULL;
+ }
+ free(channel->wrapper->creds_hashstr);
+ free(channel->wrapper->key);
+ free(channel->wrapper->target);
+ free(channel->wrapper->args_hashstr);
+ free(channel->wrapper);
channel->wrapper = le->channel;
+ channel->wrapper->ref_count += 1;
}
}
}
@@ -321,7 +382,8 @@ PHP_METHOD(Channel, getTarget) {
}
char *target = grpc_channel_get_target(channel->wrapper->wrapped);
gpr_mu_unlock(&channel->wrapper->mu);
- PHP_GRPC_RETURN_STRING(target, 1);
+ PHP_GRPC_RETVAL_STRING(target, 1);
+ gpr_free(target);
}
/**
@@ -409,18 +471,46 @@ PHP_METHOD(Channel, watchConnectivityState) {
*/
PHP_METHOD(Channel, close) {
wrapped_grpc_channel *channel = Z_WRAPPED_GRPC_CHANNEL_P(getThis());
- gpr_mu_lock(&channel->wrapper->mu);
- if (channel->wrapper->wrapped != NULL) {
- grpc_channel_destroy(channel->wrapper->wrapped);
- free(channel->wrapper->target);
- free(channel->wrapper->args_hashstr);
- channel->wrapper->wrapped = NULL;
-
- php_grpc_delete_persistent_list_entry(channel->wrapper->key,
- strlen(channel->wrapper->key)
- TSRMLS_CC);
+ bool is_last_wrapper = false;
+ if (channel->wrapper != NULL) {
+ // Channel_wrapper hasn't call close before.
+ gpr_mu_lock(&channel->wrapper->mu);
+ if (channel->wrapper->wrapped != NULL) {
+ if (channel->wrapper->is_valid) {
+ // Wrapped channel hasn't been destoryed by other wrapper.
+ grpc_channel_destroy(channel->wrapper->wrapped);
+ free(channel->wrapper->target);
+ free(channel->wrapper->args_hashstr);
+ if(channel->wrapper->creds_hashstr != NULL){
+ free(channel->wrapper->creds_hashstr);
+ channel->wrapper->creds_hashstr = NULL;
+ }
+ channel->wrapper->wrapped = NULL;
+ channel->wrapper->is_valid = false;
+
+ php_grpc_delete_persistent_list_entry(channel->wrapper->key,
+ strlen(channel->wrapper->key)
+ TSRMLS_CC);
+ }
+ }
+ channel->wrapper->ref_count -= 1;
+ if(channel->wrapper->ref_count == 0){
+ // Mark that the wrapper can be freed because mu should be
+ // destroyed outside the lock.
+ is_last_wrapper = true;
+ }
+ gpr_mu_unlock(&channel->wrapper->mu);
}
- gpr_mu_unlock(&channel->wrapper->mu);
+ gpr_mu_lock(&global_persistent_list_mu);
+ if (is_last_wrapper) {
+ gpr_mu_destroy(&channel->wrapper->mu);
+ free(channel->wrapper->key);
+ free(channel->wrapper);
+ }
+ // Set channel->wrapper to NULL to avoid call close twice for the same
+ // channel.
+ channel->wrapper = NULL;
+ gpr_mu_unlock(&global_persistent_list_mu);
}
// Delete an entry from the persistent list
@@ -435,6 +525,7 @@ void php_grpc_delete_persistent_list_entry(char *key, php_grpc_int key_len
le = (channel_persistent_le_t *)rsrc->ptr;
le->channel = NULL;
php_grpc_zend_hash_del(&EG(persistent_list), key, key_len+1);
+ free(le);
}
gpr_mu_unlock(&global_persistent_list_mu);
}
diff --git a/src/php/ext/grpc/channel.h b/src/php/ext/grpc/channel.h
index 69adc4782c..86bfdea51a 100755
--- a/src/php/ext/grpc/channel.h
+++ b/src/php/ext/grpc/channel.h
@@ -40,6 +40,11 @@ typedef struct _grpc_channel_wrapper {
char *args_hashstr;
char *creds_hashstr;
gpr_mu mu;
+ // is_valid is used to check the wrapped channel has been freed
+ // before to avoid double free.
+ bool is_valid;
+ // ref_count is used to let the last wrapper free related channel and key.
+ size_t ref_count;
} grpc_channel_wrapper;
/* Wrapper struct for grpc_channel that can be associated with a PHP object */
diff --git a/src/php/ext/grpc/channel_credentials.c b/src/php/ext/grpc/channel_credentials.c
index 86e4f46c67..624d7cc75c 100644
--- a/src/php/ext/grpc/channel_credentials.c
+++ b/src/php/ext/grpc/channel_credentials.c
@@ -35,6 +35,7 @@
#include <zend_hash.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
@@ -46,17 +47,23 @@ static char *default_pem_root_certs = NULL;
static grpc_ssl_roots_override_result get_ssl_roots_override(
char **pem_root_certs) {
- *pem_root_certs = default_pem_root_certs;
- if (default_pem_root_certs == NULL) {
+ if (!default_pem_root_certs) {
+ *pem_root_certs = NULL;
return GRPC_SSL_ROOTS_OVERRIDE_FAIL;
}
+ *pem_root_certs = gpr_strdup(default_pem_root_certs);
return GRPC_SSL_ROOTS_OVERRIDE_OK;
}
/* Frees and destroys an instance of wrapped_grpc_channel_credentials */
PHP_GRPC_FREE_WRAPPED_FUNC_START(wrapped_grpc_channel_credentials)
+ if (p->hashstr != NULL) {
+ free(p->hashstr);
+ p->hashstr = NULL;
+ }
if (p->wrapped != NULL) {
grpc_channel_credentials_release(p->wrapped);
+ p->wrapped = NULL;
}
PHP_GRPC_FREE_WRAPPED_FUNC_END()
@@ -101,7 +108,7 @@ PHP_METHOD(ChannelCredentials, setDefaultRootsPem) {
"setDefaultRootsPem expects 1 string", 1 TSRMLS_CC);
return;
}
- default_pem_root_certs = gpr_malloc((pem_roots_length + 1) * sizeof(char));
+ default_pem_root_certs = gpr_realloc(default_pem_root_certs, (pem_roots_length + 1) * sizeof(char));
memcpy(default_pem_root_certs, pem_roots, pem_roots_length + 1);
}
@@ -150,7 +157,7 @@ PHP_METHOD(ChannelCredentials, createSsl) {
}
php_grpc_int hashkey_len = root_certs_length + cert_chain_length;
- char *hashkey = emalloc(hashkey_len);
+ char *hashkey = emalloc(hashkey_len + 1);
if (root_certs_length > 0) {
strcpy(hashkey, pem_root_certs);
}
@@ -197,8 +204,13 @@ PHP_METHOD(ChannelCredentials, createComposite) {
grpc_channel_credentials *creds =
grpc_composite_channel_credentials_create(cred1->wrapped, cred2->wrapped,
NULL);
+ // wrapped_grpc_channel_credentials object should keeps it's own
+ // allocation. Otherwise it conflicts free hashstr with call.c.
+ php_grpc_int cred1_len = strlen(cred1->hashstr);
+ char *cred1_hashstr = malloc(cred1_len+1);
+ strcpy(cred1_hashstr, cred1->hashstr);
zval *creds_object =
- grpc_php_wrap_channel_credentials(creds, cred1->hashstr, true
+ grpc_php_wrap_channel_credentials(creds, cred1_hashstr, true
TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
diff --git a/src/php/ext/grpc/php7_wrapper.h b/src/php/ext/grpc/php7_wrapper.h
index 96091f9dad..2f4a53611c 100644
--- a/src/php/ext/grpc/php7_wrapper.h
+++ b/src/php/ext/grpc/php7_wrapper.h
@@ -33,6 +33,7 @@
#define php_grpc_add_next_index_stringl(data, str, len, b) \
add_next_index_stringl(data, str, len, b)
+#define PHP_GRPC_RETVAL_STRING(val, dup) RETVAL_STRING(val, dup)
#define PHP_GRPC_RETURN_STRING(val, dup) RETURN_STRING(val, dup)
#define PHP_GRPC_MAKE_STD_ZVAL(pzv) MAKE_STD_ZVAL(pzv)
#define PHP_GRPC_FREE_STD_ZVAL(pzv)
@@ -145,6 +146,7 @@ static inline int php_grpc_zend_hash_find(HashTable *ht, char *key, int len,
#define php_grpc_add_next_index_stringl(data, str, len, b) \
add_next_index_stringl(data, str, len)
+#define PHP_GRPC_RETVAL_STRING(val, dup) RETVAL_STRING(val)
#define PHP_GRPC_RETURN_STRING(val, dup) RETURN_STRING(val)
#define PHP_GRPC_MAKE_STD_ZVAL(pzv) \
pzv = (zval *)emalloc(sizeof(zval));
diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c
index 0f2c5b8114..5971babc00 100644
--- a/src/php/ext/grpc/php_grpc.c
+++ b/src/php/ext/grpc/php_grpc.c
@@ -253,7 +253,8 @@ PHP_MSHUTDOWN_FUNCTION(grpc) {
*/
PHP_MINFO_FUNCTION(grpc) {
php_info_print_table_start();
- php_info_print_table_header(2, "grpc support", "enabled");
+ php_info_print_table_row(2, "grpc support", "enabled");
+ php_info_print_table_row(2, "grpc module version", PHP_GRPC_VERSION);
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
diff --git a/src/php/ext/grpc/server.c b/src/php/ext/grpc/server.c
index e46037743d..a65d233017 100644
--- a/src/php/ext/grpc/server.c
+++ b/src/php/ext/grpc/server.c
@@ -169,7 +169,7 @@ PHP_METHOD(Server, requestCall) {
/**
* Add a http2 over tcp listener.
* @param string $addr The address to add
- * @return bool True on success, false on failure
+ * @return int Port on success, 0 on failure
*/
PHP_METHOD(Server, addHttp2Port) {
const char *addr;
@@ -190,7 +190,7 @@ PHP_METHOD(Server, addHttp2Port) {
* Add a secure http2 over tcp listener.
* @param string $addr The address to add
* @param ServerCredentials The ServerCredentials object
- * @return bool True on success, false on failure
+ * @return int Port on success, 0 on failure
*/
PHP_METHOD(Server, addSecureHttp2Port) {
const char *addr;
diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h
index 07d8eee7fe..408f2a4765 100644
--- a/src/php/ext/grpc/version.h
+++ b/src/php/ext/grpc/version.h
@@ -20,6 +20,6 @@
#ifndef VERSION_H
#define VERSION_H
-#define PHP_GRPC_VERSION "1.7.0dev"
+#define PHP_GRPC_VERSION "1.10.0dev"
#endif /* VERSION_H */
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php
index b62c2c2fa9..67378a34a8 100644
--- a/src/php/lib/Grpc/BaseStub.php
+++ b/src/php/lib/Grpc/BaseStub.php
@@ -218,7 +218,7 @@ class BaseStub
* (optional)
* @param array $options An array of options (optional)
*
- * @return SimpleSurfaceActiveCall The active call object
+ * @return UnaryCall The active call object
*/
protected function _simpleRequest($method,
$argument,
@@ -253,7 +253,7 @@ class BaseStub
* (optional)
* @param array $options An array of options (optional)
*
- * @return ClientStreamingSurfaceActiveCall The active call object
+ * @return ClientStreamingCall The active call object
*/
protected function _clientStreamRequest($method,
$deserialize,
@@ -288,7 +288,7 @@ class BaseStub
* (optional)
* @param array $options An array of options (optional)
*
- * @return ServerStreamingSurfaceActiveCall The active call object
+ * @return ServerStreamingCall The active call object
*/
protected function _serverStreamRequest($method,
$argument,
@@ -322,7 +322,7 @@ class BaseStub
* (optional)
* @param array $options An array of options (optional)
*
- * @return BidiStreamingSurfaceActiveCall The active call object
+ * @return BidiStreamingCall The active call object
*/
protected function _bidiRequest($method,
$deserialize,
diff --git a/src/php/tests/qps/client.php b/src/php/tests/qps/client.php
index a785d831b4..08904054eb 100644
--- a/src/php/tests/qps/client.php
+++ b/src/php/tests/qps/client.php
@@ -37,6 +37,7 @@
*/
require dirname(__FILE__).'/vendor/autoload.php';
+require dirname(__FILE__).'/histogram.php';
/**
* Assertion function that always exits with an error code if the assertion is
@@ -63,19 +64,19 @@ function hardAssertIfStatusOk($status)
}
/* Start the actual client */
-
-function qps_client_main($proxy_address) {
- echo "Initiating php client\n";
+function qps_client_main($proxy_address, $server_ind) {
+ echo "[php-client] Initiating php client\n";
$proxystubopts = [];
$proxystubopts['credentials'] = Grpc\ChannelCredentials::createInsecure();
$proxystub = new Grpc\Testing\ProxyClientServiceClient($proxy_address, $proxystubopts);
list($config, $status) = $proxystub->GetConfig(new Grpc\Testing\Void())->wait();
hardAssertIfStatusOk($status);
- hardAssert($config->getClientChannels() == 1, "Only 1 channel supported");
hardAssert($config->getOutstandingRpcsPerChannel() == 1, "Only 1 outstanding RPC supported");
- echo "Got configuration from proxy, target is " . $config->getServerTargets()[0] . "\n";
+ echo "[php-client] Got configuration from proxy, target is '$server_ind'th server" . $config->getServerTargets()[$server_ind] . "\n";
+ $histres = $config->getHistogramParams()->getResolution();
+ $histmax = $config->getHistogramParams()->getMaxPossible();
$stubopts = [];
if ($config->getSecurityParams()) {
@@ -93,10 +94,10 @@ function qps_client_main($proxy_address) {
} else {
$stubopts['credentials'] = Grpc\ChannelCredentials::createInsecure();
}
- echo "Initiating php benchmarking client\n";
+ echo "[php-client] Initiating php benchmarking client\n";
$stub = new Grpc\Testing\BenchmarkServiceClient(
- $config->getServerTargets()[0], $stubopts);
+ $config->getServerTargets()[$server_ind], $stubopts);
$req = new Grpc\Testing\SimpleRequest();
$req->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
@@ -115,8 +116,11 @@ function qps_client_main($proxy_address) {
} else {
$poisson = false;
}
- $metric = new Grpc\Testing\ProxyStat;
- $telemetry = $proxystub->ReportTime();
+ $histogram = new Histogram($histres, $histmax);
+ $histogram->clean();
+ $count = 0;
+ $histogram_result = new Grpc\Testing\HistogramData;
+ $telehist = $proxystub->ReportHist();
if ($config->getRpcType() == Grpc\Testing\RpcType::UNARY) {
while (1) {
if ($poisson) {
@@ -126,8 +130,20 @@ function qps_client_main($proxy_address) {
$startreq = microtime(true);
list($resp,$status) = $stub->UnaryCall($req)->wait();
hardAssertIfStatusOk($status);
- $metric->setLatency(microtime(true)-$startreq);
- $telemetry->write($metric);
+ $histogram->add((microtime(true)-$startreq)*1e9);
+ $count += 1;
+ if ($count == 2000) {
+ $contents = $histogram->contents();
+ $histogram_result->setBucket($contents);
+ $histogram_result->setMinSeen($histogram->minimum());
+ $histogram_result->setMaxSeen($histogram->maximum());
+ $histogram_result->setSum($histogram->sum());
+ $histogram_result->setSumOfSquares($histogram->sum_of_squares());
+ $histogram_result->setCount($histogram->count());
+ $telehist->write($histogram_result);
+ $histogram->clean();
+ $count = 0;
+ }
}
} else {
$stream = $stub->StreamingCall();
@@ -139,8 +155,20 @@ function qps_client_main($proxy_address) {
$startreq = microtime(true);
$stream->write($req);
$resp = $stream->read();
- $metric->setLatency(microtime(true)-$startreq);
- $telemetry->write($metric);
+ $histogram->add((microtime(true)-$startreq)*1e9);
+ $count += 1;
+ if ($count == 2000) {
+ $contents = $histogram->contents();
+ $histogram_result->setBucket($contents);
+ $histogram_result->setMinSeen($histogram->minimum());
+ $histogram_result->setMaxSeen($histogram->maximum());
+ $histogram_result->setSum($histogram->sum());
+ $histogram_result->setSumOfSquares($histogram->sum_of_squares());
+ $histogram_result->setCount($histogram->count());
+ $telehist->write($histogram_result);
+ $histogram->clean();
+ $count = 0;
+ }
}
}
}
@@ -148,4 +176,4 @@ function qps_client_main($proxy_address) {
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
-qps_client_main($argv[1]);
+qps_client_main($argv[1], $argv[2]);
diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php
new file mode 100644
index 0000000000..f9c710cd4e
--- /dev/null
+++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php
@@ -0,0 +1,33 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: src/proto/grpc/core/stats.proto
+
+namespace GPBMetadata\Src\Proto\Grpc\Core;
+
+class Stats
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0a97020a1f7372632f70726f746f2f677270632f636f72652f7374617473" .
+ "2e70726f746f1209677270632e636f726522260a064275636b6574120d0a" .
+ "057374617274180120012801120d0a05636f756e74180220012804222f0a" .
+ "09486973746f6772616d12220a076275636b65747318012003280b32112e" .
+ "677270632e636f72652e4275636b6574225b0a064d6574726963120c0a04" .
+ "6e616d65180120012809120f0a05636f756e74180a20012804480012290a" .
+ "09686973746f6772616d180b2001280b32142e677270632e636f72652e48" .
+ "6973746f6772616d480042070a0576616c7565222b0a0553746174731222" .
+ "0a076d65747269637318012003280b32112e677270632e636f72652e4d65" .
+ "74726963620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php
index efca18a0cb..9b3a7529ec 100644
--- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php
+++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php
@@ -17,108 +17,119 @@ class Control
\GPBMetadata\Src\Proto\Grpc\Testing\Payloads::initOnce();
\GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce();
$pool->internalAddGeneratedFile(hex2bin(
- "0add170a247372632f70726f746f2f677270632f74657374696e672f636f" .
- "6e74726f6c2e70726f746f120c677270632e74657374696e671a25737263" .
- "2f70726f746f2f677270632f74657374696e672f7061796c6f6164732e70" .
- "726f746f1a227372632f70726f746f2f677270632f74657374696e672f73" .
- "746174732e70726f746f22250a0d506f6973736f6e506172616d7312140a" .
- "0c6f6666657265645f6c6f616418012001280122120a10436c6f7365644c" .
- "6f6f70506172616d73227b0a0a4c6f6164506172616d7312350a0b636c6f" .
- "7365645f6c6f6f7018012001280b321e2e677270632e74657374696e672e" .
- "436c6f7365644c6f6f70506172616d734800122e0a07706f6973736f6e18" .
- "022001280b321b2e677270632e74657374696e672e506f6973736f6e5061" .
- "72616d73480042060a046c6f616422430a0e536563757269747950617261" .
- "6d7312130a0b7573655f746573745f6361180120012808121c0a14736572" .
- "7665725f686f73745f6f76657272696465180220012809224d0a0a436861" .
- "6e6e656c417267120c0a046e616d6518012001280912130a097374725f76" .
- "616c7565180220012809480012130a09696e745f76616c75651803200128" .
- "05480042070a0576616c756522a0040a0c436c69656e74436f6e66696712" .
- "160a0e7365727665725f74617267657473180120032809122d0a0b636c69" .
- "656e745f7479706518022001280e32182e677270632e74657374696e672e" .
- "436c69656e745479706512350a0f73656375726974795f706172616d7318" .
- "032001280b321c2e677270632e74657374696e672e536563757269747950" .
- "6172616d7312240a1c6f75747374616e64696e675f727063735f7065725f" .
- "6368616e6e656c18042001280512170a0f636c69656e745f6368616e6e65" .
- "6c73180520012805121c0a146173796e635f636c69656e745f7468726561" .
- "647318072001280512270a087270635f7479706518082001280e32152e67" .
- "7270632e74657374696e672e52706354797065122d0a0b6c6f61645f7061" .
- "72616d73180a2001280b32182e677270632e74657374696e672e4c6f6164" .
- "506172616d7312330a0e7061796c6f61645f636f6e666967180b2001280b" .
- "321b2e677270632e74657374696e672e5061796c6f6164436f6e66696712" .
- "370a10686973746f6772616d5f706172616d73180c2001280b321d2e6772" .
- "70632e74657374696e672e486973746f6772616d506172616d7312110a09" .
- "636f72655f6c697374180d2003280512120a0a636f72655f6c696d697418" .
- "0e2001280512180a106f746865725f636c69656e745f617069180f200128" .
- "09122e0a0c6368616e6e656c5f6172677318102003280b32182e67727063" .
- "2e74657374696e672e4368616e6e656c41726722380a0c436c69656e7453" .
- "746174757312280a05737461747318012001280b32192e677270632e7465" .
- "7374696e672e436c69656e74537461747322150a044d61726b120d0a0572" .
- "6573657418012001280822680a0a436c69656e7441726773122b0a057365" .
- "74757018012001280b321a2e677270632e74657374696e672e436c69656e" .
- "74436f6e666967480012220a046d61726b18022001280b32122e67727063" .
- "2e74657374696e672e4d61726b480042090a076172677479706522b4020a" .
- "0c536572766572436f6e666967122d0a0b7365727665725f747970651801" .
- "2001280e32182e677270632e74657374696e672e53657276657254797065" .
- "12350a0f73656375726974795f706172616d7318022001280b321c2e6772" .
- "70632e74657374696e672e5365637572697479506172616d73120c0a0470" .
- "6f7274180420012805121c0a146173796e635f7365727665725f74687265" .
- "61647318072001280512120a0a636f72655f6c696d697418082001280512" .
- "330a0e7061796c6f61645f636f6e66696718092001280b321b2e67727063" .
- "2e74657374696e672e5061796c6f6164436f6e66696712110a09636f7265" .
- "5f6c697374180a2003280512180a106f746865725f7365727665725f6170" .
- "69180b20012809121c0a137265736f757263655f71756f74615f73697a65" .
- "18e9072001280522680a0a53657276657241726773122b0a057365747570" .
- "18012001280b321a2e677270632e74657374696e672e536572766572436f" .
- "6e666967480012220a046d61726b18022001280b32122e677270632e7465" .
- "7374696e672e4d61726b480042090a076172677479706522550a0c536572" .
- "76657253746174757312280a05737461747318012001280b32192e677270" .
- "632e74657374696e672e5365727665725374617473120c0a04706f727418" .
- "0220012805120d0a05636f726573180320012805220d0a0b436f72655265" .
- "7175657374221d0a0c436f7265526573706f6e7365120d0a05636f726573" .
- "18012001280522060a04566f696422fd010a085363656e6172696f120c0a" .
- "046e616d6518012001280912310a0d636c69656e745f636f6e6669671802" .
- "2001280b321a2e677270632e74657374696e672e436c69656e74436f6e66" .
- "696712130a0b6e756d5f636c69656e747318032001280512310a0d736572" .
- "7665725f636f6e66696718042001280b321a2e677270632e74657374696e" .
- "672e536572766572436f6e66696712130a0b6e756d5f7365727665727318" .
- "052001280512160a0e7761726d75705f7365636f6e647318062001280512" .
- "190a1162656e63686d61726b5f7365636f6e647318072001280512200a18" .
- "737061776e5f6c6f63616c5f776f726b65725f636f756e74180820012805" .
- "22360a095363656e6172696f7312290a097363656e6172696f7318012003" .
- "280b32162e677270632e74657374696e672e5363656e6172696f22f8020a" .
- "155363656e6172696f526573756c7453756d6d617279120b0a0371707318" .
- "0120012801121b0a137170735f7065725f7365727665725f636f72651802" .
- "20012801121a0a127365727665725f73797374656d5f74696d6518032001" .
- "280112180a107365727665725f757365725f74696d65180420012801121a" .
- "0a12636c69656e745f73797374656d5f74696d6518052001280112180a10" .
- "636c69656e745f757365725f74696d6518062001280112120a0a6c617465" .
- "6e63795f353018072001280112120a0a6c6174656e63795f393018082001" .
- "280112120a0a6c6174656e63795f393518092001280112120a0a6c617465" .
- "6e63795f3939180a2001280112130a0b6c6174656e63795f393939180b20" .
- "01280112180a107365727665725f6370755f7573616765180c2001280112" .
- "260a1e7375636365737366756c5f72657175657374735f7065725f736563" .
- "6f6e64180d2001280112220a1a6661696c65645f72657175657374735f70" .
- "65725f7365636f6e64180e200128012283030a0e5363656e6172696f5265" .
- "73756c7412280a087363656e6172696f18012001280b32162e677270632e" .
- "74657374696e672e5363656e6172696f122e0a096c6174656e6369657318" .
- "022001280b321b2e677270632e74657374696e672e486973746f6772616d" .
- "44617461122f0a0c636c69656e745f737461747318032003280b32192e67" .
- "7270632e74657374696e672e436c69656e745374617473122f0a0c736572" .
- "7665725f737461747318042003280b32192e677270632e74657374696e67" .
- "2e536572766572537461747312140a0c7365727665725f636f7265731805" .
- "2003280512340a0773756d6d61727918062001280b32232e677270632e74" .
- "657374696e672e5363656e6172696f526573756c7453756d6d6172791216" .
- "0a0e636c69656e745f7375636365737318072003280812160a0e73657276" .
- "65725f7375636365737318082003280812390a0f726571756573745f7265" .
- "73756c747318092003280b32202e677270632e74657374696e672e526571" .
- "75657374526573756c74436f756e742a410a0a436c69656e745479706512" .
- "0f0a0b53594e435f434c49454e54100012100a0c4153594e435f434c4945" .
- "4e54100112100a0c4f544845525f434c49454e5410022a5b0a0a53657276" .
- "657254797065120f0a0b53594e435f534552564552100012100a0c415359" .
- "4e435f534552564552100112180a144153594e435f47454e455249435f53" .
- "4552564552100212100a0c4f544845525f53455256455210032a230a0752" .
- "70635479706512090a05554e4152591000120d0a0953545245414d494e47" .
- "1001620670726f746f33"
+ "0aa21a0a247372632f70726f746f2f677270632f74657374696e672f636f" .
+ "6e74726f6c2e70726f746f120c677270632e74657374696e671a22737263" .
+ "2f70726f746f2f677270632f74657374696e672f73746174732e70726f74" .
+ "6f22250a0d506f6973736f6e506172616d7312140a0c6f6666657265645f" .
+ "6c6f616418012001280122120a10436c6f7365644c6f6f70506172616d73" .
+ "227b0a0a4c6f6164506172616d7312350a0b636c6f7365645f6c6f6f7018" .
+ "012001280b321e2e677270632e74657374696e672e436c6f7365644c6f6f" .
+ "70506172616d734800122e0a07706f6973736f6e18022001280b321b2e67" .
+ "7270632e74657374696e672e506f6973736f6e506172616d73480042060a" .
+ "046c6f616422560a0e5365637572697479506172616d7312130a0b757365" .
+ "5f746573745f6361180120012808121c0a147365727665725f686f73745f" .
+ "6f7665727269646518022001280912110a09637265645f74797065180320" .
+ "012809224d0a0a4368616e6e656c417267120c0a046e616d651801200128" .
+ "0912130a097374725f76616c7565180220012809480012130a09696e745f" .
+ "76616c7565180320012805480042070a0576616c756522d5040a0c436c69" .
+ "656e74436f6e66696712160a0e7365727665725f74617267657473180120" .
+ "032809122d0a0b636c69656e745f7479706518022001280e32182e677270" .
+ "632e74657374696e672e436c69656e745479706512350a0f736563757269" .
+ "74795f706172616d7318032001280b321c2e677270632e74657374696e67" .
+ "2e5365637572697479506172616d7312240a1c6f75747374616e64696e67" .
+ "5f727063735f7065725f6368616e6e656c18042001280512170a0f636c69" .
+ "656e745f6368616e6e656c73180520012805121c0a146173796e635f636c" .
+ "69656e745f7468726561647318072001280512270a087270635f74797065" .
+ "18082001280e32152e677270632e74657374696e672e5270635479706512" .
+ "2d0a0b6c6f61645f706172616d73180a2001280b32182e677270632e7465" .
+ "7374696e672e4c6f6164506172616d7312330a0e7061796c6f61645f636f" .
+ "6e666967180b2001280b321b2e677270632e74657374696e672e5061796c" .
+ "6f6164436f6e66696712370a10686973746f6772616d5f706172616d7318" .
+ "0c2001280b321d2e677270632e74657374696e672e486973746f6772616d" .
+ "506172616d7312110a09636f72655f6c697374180d2003280512120a0a63" .
+ "6f72655f6c696d6974180e2001280512180a106f746865725f636c69656e" .
+ "745f617069180f20012809122e0a0c6368616e6e656c5f61726773181020" .
+ "03280b32182e677270632e74657374696e672e4368616e6e656c41726712" .
+ "160a0e746872656164735f7065725f6371181120012805121b0a136d6573" .
+ "73616765735f7065725f73747265616d18122001280522380a0c436c6965" .
+ "6e7453746174757312280a05737461747318012001280b32192e67727063" .
+ "2e74657374696e672e436c69656e74537461747322150a044d61726b120d" .
+ "0a05726573657418012001280822680a0a436c69656e7441726773122b0a" .
+ "05736574757018012001280b321a2e677270632e74657374696e672e436c" .
+ "69656e74436f6e666967480012220a046d61726b18022001280b32122e67" .
+ "7270632e74657374696e672e4d61726b480042090a076172677479706522" .
+ "fd020a0c536572766572436f6e666967122d0a0b7365727665725f747970" .
+ "6518012001280e32182e677270632e74657374696e672e53657276657254" .
+ "79706512350a0f73656375726974795f706172616d7318022001280b321c" .
+ "2e677270632e74657374696e672e5365637572697479506172616d73120c" .
+ "0a04706f7274180420012805121c0a146173796e635f7365727665725f74" .
+ "68726561647318072001280512120a0a636f72655f6c696d697418082001" .
+ "280512330a0e7061796c6f61645f636f6e66696718092001280b321b2e67" .
+ "7270632e74657374696e672e5061796c6f6164436f6e66696712110a0963" .
+ "6f72655f6c697374180a2003280512180a106f746865725f736572766572" .
+ "5f617069180b2001280912160a0e746872656164735f7065725f6371180c" .
+ "20012805121c0a137265736f757263655f71756f74615f73697a6518e907" .
+ "20012805122f0a0c6368616e6e656c5f6172677318ea072003280b32182e" .
+ "677270632e74657374696e672e4368616e6e656c41726722680a0a536572" .
+ "76657241726773122b0a05736574757018012001280b321a2e677270632e" .
+ "74657374696e672e536572766572436f6e666967480012220a046d61726b" .
+ "18022001280b32122e677270632e74657374696e672e4d61726b48004209" .
+ "0a076172677479706522550a0c53657276657253746174757312280a0573" .
+ "7461747318012001280b32192e677270632e74657374696e672e53657276" .
+ "65725374617473120c0a04706f7274180220012805120d0a05636f726573" .
+ "180320012805220d0a0b436f726552657175657374221d0a0c436f726552" .
+ "6573706f6e7365120d0a05636f72657318012001280522060a04566f6964" .
+ "22fd010a085363656e6172696f120c0a046e616d6518012001280912310a" .
+ "0d636c69656e745f636f6e66696718022001280b321a2e677270632e7465" .
+ "7374696e672e436c69656e74436f6e66696712130a0b6e756d5f636c6965" .
+ "6e747318032001280512310a0d7365727665725f636f6e66696718042001" .
+ "280b321a2e677270632e74657374696e672e536572766572436f6e666967" .
+ "12130a0b6e756d5f7365727665727318052001280512160a0e7761726d75" .
+ "705f7365636f6e647318062001280512190a1162656e63686d61726b5f73" .
+ "65636f6e647318072001280512200a18737061776e5f6c6f63616c5f776f" .
+ "726b65725f636f756e7418082001280522360a095363656e6172696f7312" .
+ "290a097363656e6172696f7318012003280b32162e677270632e74657374" .
+ "696e672e5363656e6172696f2284040a155363656e6172696f526573756c" .
+ "7453756d6d617279120b0a03717073180120012801121b0a137170735f70" .
+ "65725f7365727665725f636f7265180220012801121a0a12736572766572" .
+ "5f73797374656d5f74696d6518032001280112180a107365727665725f75" .
+ "7365725f74696d65180420012801121a0a12636c69656e745f7379737465" .
+ "6d5f74696d6518052001280112180a10636c69656e745f757365725f7469" .
+ "6d6518062001280112120a0a6c6174656e63795f35301807200128011212" .
+ "0a0a6c6174656e63795f393018082001280112120a0a6c6174656e63795f" .
+ "393518092001280112120a0a6c6174656e63795f3939180a200128011213" .
+ "0a0b6c6174656e63795f393939180b2001280112180a107365727665725f" .
+ "6370755f7573616765180c2001280112260a1e7375636365737366756c5f" .
+ "72657175657374735f7065725f7365636f6e64180d2001280112220a1a66" .
+ "61696c65645f72657175657374735f7065725f7365636f6e64180e200128" .
+ "0112200a18636c69656e745f706f6c6c735f7065725f7265717565737418" .
+ "0f2001280112200a187365727665725f706f6c6c735f7065725f72657175" .
+ "65737418102001280112220a1a7365727665725f717565726965735f7065" .
+ "725f6370755f73656318112001280112220a1a636c69656e745f71756572" .
+ "6965735f7065725f6370755f7365631812200128012283030a0e5363656e" .
+ "6172696f526573756c7412280a087363656e6172696f18012001280b3216" .
+ "2e677270632e74657374696e672e5363656e6172696f122e0a096c617465" .
+ "6e6369657318022001280b321b2e677270632e74657374696e672e486973" .
+ "746f6772616d44617461122f0a0c636c69656e745f737461747318032003" .
+ "280b32192e677270632e74657374696e672e436c69656e74537461747312" .
+ "2f0a0c7365727665725f737461747318042003280b32192e677270632e74" .
+ "657374696e672e536572766572537461747312140a0c7365727665725f63" .
+ "6f72657318052003280512340a0773756d6d61727918062001280b32232e" .
+ "677270632e74657374696e672e5363656e6172696f526573756c7453756d" .
+ "6d61727912160a0e636c69656e745f737563636573731807200328081216" .
+ "0a0e7365727665725f7375636365737318082003280812390a0f72657175" .
+ "6573745f726573756c747318092003280b32202e677270632e7465737469" .
+ "6e672e52657175657374526573756c74436f756e742a410a0a436c69656e" .
+ "7454797065120f0a0b53594e435f434c49454e54100012100a0c4153594e" .
+ "435f434c49454e54100112100a0c4f544845525f434c49454e5410022a5b" .
+ "0a0a53657276657254797065120f0a0b53594e435f534552564552100012" .
+ "100a0c4153594e435f534552564552100112180a144153594e435f47454e" .
+ "455249435f534552564552100212100a0c4f544845525f53455256455210" .
+ "032a720a075270635479706512090a05554e4152591000120d0a09535452" .
+ "45414d494e47100112190a1553545245414d494e475f46524f4d5f434c49" .
+ "454e54100212190a1553545245414d494e475f46524f4d5f534552564552" .
+ "100312170a1353545245414d494e475f424f54485f574159531004620670" .
+ "726f746f33"
));
static::$is_initialized = true;
diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php
index e35944e1d8..e07f73679e 100644
--- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php
+++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php
@@ -15,17 +15,20 @@ class ProxyService
return;
}
\GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
+ \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce();
$pool->internalAddGeneratedFile(hex2bin(
- "0a97020a2a7372632f70726f746f2f677270632f74657374696e672f7072" .
+ "0ad6020a2a7372632f70726f746f2f677270632f74657374696e672f7072" .
"6f78792d736572766963652e70726f746f120c677270632e74657374696e" .
- "671a247372632f70726f746f2f677270632f74657374696e672f636f6e74" .
- "726f6c2e70726f746f221c0a0950726f787953746174120f0a076c617465" .
- "6e6379180120012801328e010a1250726f7879436c69656e745365727669" .
- "6365123b0a09476574436f6e66696712122e677270632e74657374696e67" .
- "2e566f69641a1a2e677270632e74657374696e672e436c69656e74436f6e" .
- "666967123b0a0a5265706f727454696d6512172e677270632e7465737469" .
- "6e672e50726f7879537461741a122e677270632e74657374696e672e566f" .
- "69642801620670726f746f33"
+ "671a227372632f70726f746f2f677270632f74657374696e672f73746174" .
+ "732e70726f746f221c0a0950726f787953746174120f0a076c6174656e63" .
+ "7918012001280132cf010a1250726f7879436c69656e7453657276696365" .
+ "123b0a09476574436f6e66696712122e677270632e74657374696e672e56" .
+ "6f69641a1a2e677270632e74657374696e672e436c69656e74436f6e6669" .
+ "67123b0a0a5265706f727454696d6512172e677270632e74657374696e67" .
+ "2e50726f7879537461741a122e677270632e74657374696e672e566f6964" .
+ "2801123f0a0a5265706f727448697374121b2e677270632e74657374696e" .
+ "672e486973746f6772616d446174611a122e677270632e74657374696e67" .
+ "2e566f69642801620670726f746f33"
));
static::$is_initialized = true;
diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php
index 7a9439a5b9..e4029182c7 100644
--- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php
+++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php
@@ -16,27 +16,40 @@ class Services
}
\GPBMetadata\Src\Proto\Grpc\Testing\Messages::initOnce();
\GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
+ \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce();
$pool->internalAddGeneratedFile(hex2bin(
- "0ad1040a257372632f70726f746f2f677270632f74657374696e672f7365" .
- "7276696365732e70726f746f120c677270632e74657374696e671a257372" .
- "632f70726f746f2f677270632f74657374696e672f6d657373616765732e" .
- "70726f746f1a247372632f70726f746f2f677270632f74657374696e672f" .
- "636f6e74726f6c2e70726f746f32aa010a1042656e63686d61726b536572" .
- "7669636512460a09556e61727943616c6c121b2e677270632e7465737469" .
- "6e672e53696d706c65526571756573741a1c2e677270632e74657374696e" .
- "672e53696d706c65526573706f6e7365124e0a0d53747265616d696e6743" .
- "616c6c121b2e677270632e74657374696e672e53696d706c655265717565" .
- "73741a1c2e677270632e74657374696e672e53696d706c65526573706f6e" .
- "7365280130013297020a0d576f726b65725365727669636512450a095275" .
- "6e53657276657212182e677270632e74657374696e672e53657276657241" .
- "7267731a1a2e677270632e74657374696e672e5365727665725374617475" .
- "732801300112450a0952756e436c69656e7412182e677270632e74657374" .
- "696e672e436c69656e74417267731a1a2e677270632e74657374696e672e" .
- "436c69656e745374617475732801300112420a09436f7265436f756e7412" .
- "192e677270632e74657374696e672e436f7265526571756573741a1a2e67" .
- "7270632e74657374696e672e436f7265526573706f6e736512340a0a5175" .
- "6974576f726b657212122e677270632e74657374696e672e566f69641a12" .
- "2e677270632e74657374696e672e566f6964620670726f746f33"
+ "0aaa070a257372632f70726f746f2f677270632f74657374696e672f7365" .
+ "7276696365732e70726f746f120c677270632e74657374696e671a247372" .
+ "632f70726f746f2f677270632f74657374696e672f636f6e74726f6c2e70" .
+ "726f746f1a227372632f70726f746f2f677270632f74657374696e672f73" .
+ "746174732e70726f746f32a6030a1042656e63686d61726b536572766963" .
+ "6512460a09556e61727943616c6c121b2e677270632e74657374696e672e" .
+ "53696d706c65526571756573741a1c2e677270632e74657374696e672e53" .
+ "696d706c65526573706f6e7365124e0a0d53747265616d696e6743616c6c" .
+ "121b2e677270632e74657374696e672e53696d706c65526571756573741a" .
+ "1c2e677270632e74657374696e672e53696d706c65526573706f6e736528" .
+ "01300112520a1353747265616d696e6746726f6d436c69656e74121b2e67" .
+ "7270632e74657374696e672e53696d706c65526571756573741a1c2e6772" .
+ "70632e74657374696e672e53696d706c65526573706f6e7365280112520a" .
+ "1353747265616d696e6746726f6d536572766572121b2e677270632e7465" .
+ "7374696e672e53696d706c65526571756573741a1c2e677270632e746573" .
+ "74696e672e53696d706c65526573706f6e7365300112520a115374726561" .
+ "6d696e67426f746857617973121b2e677270632e74657374696e672e5369" .
+ "6d706c65526571756573741a1c2e677270632e74657374696e672e53696d" .
+ "706c65526573706f6e7365280130013297020a0d576f726b657253657276" .
+ "69636512450a0952756e53657276657212182e677270632e74657374696e" .
+ "672e536572766572417267731a1a2e677270632e74657374696e672e5365" .
+ "727665725374617475732801300112450a0952756e436c69656e7412182e" .
+ "677270632e74657374696e672e436c69656e74417267731a1a2e67727063" .
+ "2e74657374696e672e436c69656e745374617475732801300112420a0943" .
+ "6f7265436f756e7412192e677270632e74657374696e672e436f72655265" .
+ "71756573741a1a2e677270632e74657374696e672e436f7265526573706f" .
+ "6e736512340a0a51756974576f726b657212122e677270632e7465737469" .
+ "6e672e566f69641a122e677270632e74657374696e672e566f6964325e0a" .
+ "185265706f72745170735363656e6172696f5365727669636512420a0e52" .
+ "65706f72745363656e6172696f121c2e677270632e74657374696e672e53" .
+ "63656e6172696f526573756c741a122e677270632e74657374696e672e56" .
+ "6f6964620670726f746f33"
));
static::$is_initialized = true;
diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php
index 99c0000a52..3d23b75dfa 100644
--- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php
+++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php
@@ -14,28 +14,33 @@ class Stats
if (static::$is_initialized == true) {
return;
}
+ \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce();
$pool->internalAddGeneratedFile(hex2bin(
- "0adf040a227372632f70726f746f2f677270632f74657374696e672f7374" .
- "6174732e70726f746f120c677270632e74657374696e67227a0a0b536572" .
- "766572537461747312140a0c74696d655f656c6170736564180120012801" .
- "12110a0974696d655f7573657218022001280112130a0b74696d655f7379" .
- "7374656d18032001280112160a0e746f74616c5f6370755f74696d651804" .
- "2001280412150a0d69646c655f6370755f74696d65180520012804223b0a" .
- "0f486973746f6772616d506172616d7312120a0a7265736f6c7574696f6e" .
- "18012001280112140a0c6d61785f706f737369626c651802200128012277" .
- "0a0d486973746f6772616d44617461120e0a066275636b65741801200328" .
- "0d12100a086d696e5f7365656e18022001280112100a086d61785f736565" .
- "6e180320012801120b0a0373756d18042001280112160a0e73756d5f6f66" .
- "5f73717561726573180520012801120d0a05636f756e7418062001280122" .
- "380a1252657175657374526573756c74436f756e7412130a0b7374617475" .
- "735f636f6465180120012805120d0a05636f756e7418022001280322b601" .
- "0a0b436c69656e745374617473122e0a096c6174656e6369657318012001" .
- "280b321b2e677270632e74657374696e672e486973746f6772616d446174" .
- "6112140a0c74696d655f656c617073656418022001280112110a0974696d" .
- "655f7573657218032001280112130a0b74696d655f73797374656d180420" .
- "01280112390a0f726571756573745f726573756c747318052003280b3220" .
- "2e677270632e74657374696e672e52657175657374526573756c74436f75" .
- "6e74620670726f746f33"
+ "0ada050a227372632f70726f746f2f677270632f74657374696e672f7374" .
+ "6174732e70726f746f120c677270632e74657374696e6722b7010a0b5365" .
+ "72766572537461747312140a0c74696d655f656c61707365641801200128" .
+ "0112110a0974696d655f7573657218022001280112130a0b74696d655f73" .
+ "797374656d18032001280112160a0e746f74616c5f6370755f74696d6518" .
+ "042001280412150a0d69646c655f6370755f74696d651805200128041215" .
+ "0a0d63715f706f6c6c5f636f756e7418062001280412240a0a636f72655f" .
+ "737461747318072001280b32102e677270632e636f72652e537461747322" .
+ "3b0a0f486973746f6772616d506172616d7312120a0a7265736f6c757469" .
+ "6f6e18012001280112140a0c6d61785f706f737369626c65180220012801" .
+ "22770a0d486973746f6772616d44617461120e0a066275636b6574180120" .
+ "03280d12100a086d696e5f7365656e18022001280112100a086d61785f73" .
+ "65656e180320012801120b0a0373756d18042001280112160a0e73756d5f" .
+ "6f665f73717561726573180520012801120d0a05636f756e741806200128" .
+ "0122380a1252657175657374526573756c74436f756e7412130a0b737461" .
+ "7475735f636f6465180120012805120d0a05636f756e7418022001280322" .
+ "f3010a0b436c69656e745374617473122e0a096c6174656e636965731801" .
+ "2001280b321b2e677270632e74657374696e672e486973746f6772616d44" .
+ "61746112140a0c74696d655f656c617073656418022001280112110a0974" .
+ "696d655f7573657218032001280112130a0b74696d655f73797374656d18" .
+ "042001280112390a0f726571756573745f726573756c747318052003280b" .
+ "32202e677270632e74657374696e672e52657175657374526573756c7443" .
+ "6f756e7412150a0d63715f706f6c6c5f636f756e7418062001280412240a" .
+ "0a636f72655f737461747318072001280b32102e677270632e636f72652e" .
+ "5374617473620670726f746f33"
));
static::$is_initialized = true;
diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Bucket.php b/src/php/tests/qps/generated_code/Grpc/Core/Bucket.php
new file mode 100644
index 0000000000..897d6271c2
--- /dev/null
+++ b/src/php/tests/qps/generated_code/Grpc/Core/Bucket.php
@@ -0,0 +1,75 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: src/proto/grpc/core/stats.proto
+
+namespace Grpc\Core;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>grpc.core.Bucket</code>
+ */
+class Bucket extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Generated from protobuf field <code>double start = 1;</code>
+ */
+ private $start = 0.0;
+ /**
+ * Generated from protobuf field <code>uint64 count = 2;</code>
+ */
+ private $count = 0;
+
+ public function __construct() {
+ \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Generated from protobuf field <code>double start = 1;</code>
+ * @return float
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * Generated from protobuf field <code>double start = 1;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setStart($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->start = $var;
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>uint64 count = 2;</code>
+ * @return int|string
+ */
+ public function getCount()
+ {
+ return $this->count;
+ }
+
+ /**
+ * Generated from protobuf field <code>uint64 count = 2;</code>
+ * @param int|string $var
+ * @return $this
+ */
+ public function setCount($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->count = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Histogram.php b/src/php/tests/qps/generated_code/Grpc/Core/Histogram.php
new file mode 100644
index 0000000000..1902be8e4a
--- /dev/null
+++ b/src/php/tests/qps/generated_code/Grpc/Core/Histogram.php
@@ -0,0 +1,49 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: src/proto/grpc/core/stats.proto
+
+namespace Grpc\Core;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>grpc.core.Histogram</code>
+ */
+class Histogram extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Generated from protobuf field <code>repeated .grpc.core.Bucket buckets = 1;</code>
+ */
+ private $buckets;
+
+ public function __construct() {
+ \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Generated from protobuf field <code>repeated .grpc.core.Bucket buckets = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getBuckets()
+ {
+ return $this->buckets;
+ }
+
+ /**
+ * Generated from protobuf field <code>repeated .grpc.core.Bucket buckets = 1;</code>
+ * @param \Grpc\Core\Bucket[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setBuckets($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Core\Bucket::class);
+ $this->buckets = $arr;
+
+ return $this;
+ }
+
+}
+
diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Metric.php b/src/php/tests/qps/generated_code/Grpc/Core/Metric.php
new file mode 100644
index 0000000000..c3581b7d21
--- /dev/null
+++ b/src/php/tests/qps/generated_code/Grpc/Core/Metric.php
@@ -0,0 +1,102 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: src/proto/grpc/core/stats.proto
+
+namespace Grpc\Core;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>grpc.core.Metric</code>
+ */
+class Metric extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ protected $value;
+
+ public function __construct() {
+ \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>uint64 count = 10;</code>
+ * @return int|string
+ */
+ public function getCount()
+ {
+ return $this->readOneof(10);
+ }
+
+ /**
+ * Generated from protobuf field <code>uint64 count = 10;</code>
+ * @param int|string $var
+ * @return $this
+ */
+ public function setCount($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->writeOneof(10, $var);
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>.grpc.core.Histogram histogram = 11;</code>
+ * @return \Grpc\Core\Histogram
+ */
+ public function getHistogram()
+ {
+ return $this->readOneof(11);
+ }
+
+ /**
+ * Generated from protobuf field <code>.grpc.core.Histogram histogram = 11;</code>
+ * @param \Grpc\Core\Histogram $var
+ * @return $this
+ */
+ public function setHistogram($var)
+ {
+ GPBUtil::checkMessage($var, \Grpc\Core\Histogram::class);
+ $this->writeOneof(11, $var);
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->whichOneof("value");
+ }
+
+}
+
diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Stats.php b/src/php/tests/qps/generated_code/Grpc/Core/Stats.php
new file mode 100644
index 0000000000..e6f3fb0899
--- /dev/null
+++ b/src/php/tests/qps/generated_code/Grpc/Core/Stats.php
@@ -0,0 +1,49 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: src/proto/grpc/core/stats.proto
+
+namespace Grpc\Core;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>grpc.core.Stats</code>
+ */
+class Stats extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Generated from protobuf field <code>repeated .grpc.core.Metric metrics = 1;</code>
+ */
+ private $metrics;
+
+ public function __construct() {
+ \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Generated from protobuf field <code>repeated .grpc.core.Metric metrics = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getMetrics()
+ {
+ return $this->metrics;
+ }
+
+ /**
+ * Generated from protobuf field <code>repeated .grpc.core.Metric metrics = 1;</code>
+ * @param \Grpc\Core\Metric[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setMetrics($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Core\Metric::class);
+ $this->metrics = $arr;
+
+ return $this;
+ }
+
+}
+
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php
index ddf750a94f..fa3e147909 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php
@@ -18,17 +18,19 @@
//
// An integration test service that covers all the method signature permutations
// of unary/streaming requests/responses.
-namespace Grpc\Testing {
+namespace Grpc\Testing;
- class BenchmarkServiceClient extends \Grpc\BaseStub {
+/**
+ */
+class BenchmarkServiceClient extends \Grpc\BaseStub {
/**
* @param string $hostname hostname
* @param array $opts channel options
- * @param Grpc\Channel $channel (optional) re-use channel object
+ * @param \Grpc\Channel $channel (optional) re-use channel object
*/
public function __construct($hostname, $opts, $channel = null) {
- parent::__construct($hostname, $opts, $channel);
+ parent::__construct($hostname, $opts, $channel);
}
/**
@@ -40,24 +42,62 @@ namespace Grpc\Testing {
*/
public function UnaryCall(\Grpc\Testing\SimpleRequest $argument,
$metadata = [], $options = []) {
- return $this->_simpleRequest('/grpc.testing.BenchmarkService/UnaryCall',
- $argument,
- ['\Grpc\Testing\SimpleResponse', 'decode'],
- $metadata, $options);
+ return $this->_simpleRequest('/grpc.testing.BenchmarkService/UnaryCall',
+ $argument,
+ ['\Grpc\Testing\SimpleResponse', 'decode'],
+ $metadata, $options);
}
/**
- * One request followed by one response.
- * The server returns the client payload as-is.
+ * Repeated sequence of one request followed by one response.
+ * Should be called streaming ping-pong
+ * The server returns the client payload as-is on each response
* @param array $metadata metadata
* @param array $options call options
*/
public function StreamingCall($metadata = [], $options = []) {
- return $this->_bidiRequest('/grpc.testing.BenchmarkService/StreamingCall',
- ['\Grpc\Testing\SimpleResponse','decode'],
- $metadata, $options);
+ return $this->_bidiRequest('/grpc.testing.BenchmarkService/StreamingCall',
+ ['\Grpc\Testing\SimpleResponse','decode'],
+ $metadata, $options);
}
- }
+ /**
+ * Single-sided unbounded streaming from client to server
+ * The server returns the client payload as-is once the client does WritesDone
+ * @param array $metadata metadata
+ * @param array $options call options
+ */
+ public function StreamingFromClient($metadata = [], $options = []) {
+ return $this->_clientStreamRequest('/grpc.testing.BenchmarkService/StreamingFromClient',
+ ['\Grpc\Testing\SimpleResponse','decode'],
+ $metadata, $options);
+ }
+
+ /**
+ * Single-sided unbounded streaming from server to client
+ * The server repeatedly returns the client payload as-is
+ * @param \Grpc\Testing\SimpleRequest $argument input argument
+ * @param array $metadata metadata
+ * @param array $options call options
+ */
+ public function StreamingFromServer(\Grpc\Testing\SimpleRequest $argument,
+ $metadata = [], $options = []) {
+ return $this->_serverStreamRequest('/grpc.testing.BenchmarkService/StreamingFromServer',
+ $argument,
+ ['\Grpc\Testing\SimpleResponse', 'decode'],
+ $metadata, $options);
+ }
+
+ /**
+ * Two-sided unbounded streaming between server to client
+ * Both sides send the content of their own choice to the other
+ * @param array $metadata metadata
+ * @param array $options call options
+ */
+ public function StreamingBothWays($metadata = [], $options = []) {
+ return $this->_bidiRequest('/grpc.testing.BenchmarkService/StreamingBothWays',
+ ['\Grpc\Testing\SimpleResponse','decode'],
+ $metadata, $options);
+ }
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php b/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php
index f0497accfb..7eb364b7a0 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php
@@ -9,22 +9,18 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* TODO(dgq): Go back to using well-known types once
* https://github.com/grpc/grpc/issues/6980 has been fixed.
* import "google/protobuf/wrappers.proto";
- * </pre>
*
- * Protobuf type <code>grpc.testing.BoolValue</code>
+ * Generated from protobuf message <code>grpc.testing.BoolValue</code>
*/
class BoolValue extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* The bool value.
- * </pre>
*
- * <code>bool value = 1;</code>
+ * Generated from protobuf field <code>bool value = 1;</code>
*/
private $value = false;
@@ -34,11 +30,10 @@ class BoolValue extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* The bool value.
- * </pre>
*
- * <code>bool value = 1;</code>
+ * Generated from protobuf field <code>bool value = 1;</code>
+ * @return bool
*/
public function getValue()
{
@@ -46,16 +41,18 @@ class BoolValue extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* The bool value.
- * </pre>
*
- * <code>bool value = 1;</code>
+ * Generated from protobuf field <code>bool value = 1;</code>
+ * @param bool $var
+ * @return $this
*/
public function setValue($var)
{
GPBUtil::checkBool($var);
$this->value = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php
index 0057d38748..0511026ba7 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php
@@ -9,16 +9,16 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ByteBufferParams</code>
+ * Generated from protobuf message <code>grpc.testing.ByteBufferParams</code>
*/
class ByteBufferParams extends \Google\Protobuf\Internal\Message
{
/**
- * <code>int32 req_size = 1;</code>
+ * Generated from protobuf field <code>int32 req_size = 1;</code>
*/
private $req_size = 0;
/**
- * <code>int32 resp_size = 2;</code>
+ * Generated from protobuf field <code>int32 resp_size = 2;</code>
*/
private $resp_size = 0;
@@ -28,7 +28,8 @@ class ByteBufferParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 req_size = 1;</code>
+ * Generated from protobuf field <code>int32 req_size = 1;</code>
+ * @return int
*/
public function getReqSize()
{
@@ -36,16 +37,21 @@ class ByteBufferParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 req_size = 1;</code>
+ * Generated from protobuf field <code>int32 req_size = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setReqSize($var)
{
GPBUtil::checkInt32($var);
$this->req_size = $var;
+
+ return $this;
}
/**
- * <code>int32 resp_size = 2;</code>
+ * Generated from protobuf field <code>int32 resp_size = 2;</code>
+ * @return int
*/
public function getRespSize()
{
@@ -53,12 +59,16 @@ class ByteBufferParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 resp_size = 2;</code>
+ * Generated from protobuf field <code>int32 resp_size = 2;</code>
+ * @param int $var
+ * @return $this
*/
public function setRespSize($var)
{
GPBUtil::checkInt32($var);
$this->resp_size = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php b/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php
index d2fe3ae5ff..5c5fb861a4 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php
@@ -9,12 +9,12 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ChannelArg</code>
+ * Generated from protobuf message <code>grpc.testing.ChannelArg</code>
*/
class ChannelArg extends \Google\Protobuf\Internal\Message
{
/**
- * <code>string name = 1;</code>
+ * Generated from protobuf field <code>string name = 1;</code>
*/
private $name = '';
protected $value;
@@ -25,7 +25,8 @@ class ChannelArg extends \Google\Protobuf\Internal\Message
}
/**
- * <code>string name = 1;</code>
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
*/
public function getName()
{
@@ -33,16 +34,21 @@ class ChannelArg extends \Google\Protobuf\Internal\Message
}
/**
- * <code>string name = 1;</code>
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
*/
public function setName($var)
{
GPBUtil::checkString($var, True);
$this->name = $var;
+
+ return $this;
}
/**
- * <code>string str_value = 2;</code>
+ * Generated from protobuf field <code>string str_value = 2;</code>
+ * @return string
*/
public function getStrValue()
{
@@ -50,16 +56,21 @@ class ChannelArg extends \Google\Protobuf\Internal\Message
}
/**
- * <code>string str_value = 2;</code>
+ * Generated from protobuf field <code>string str_value = 2;</code>
+ * @param string $var
+ * @return $this
*/
public function setStrValue($var)
{
GPBUtil::checkString($var, True);
$this->writeOneof(2, $var);
+
+ return $this;
}
/**
- * <code>int32 int_value = 3;</code>
+ * Generated from protobuf field <code>int32 int_value = 3;</code>
+ * @return int
*/
public function getIntValue()
{
@@ -67,14 +78,21 @@ class ChannelArg extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 int_value = 3;</code>
+ * Generated from protobuf field <code>int32 int_value = 3;</code>
+ * @param int $var
+ * @return $this
*/
public function setIntValue($var)
{
GPBUtil::checkInt32($var);
$this->writeOneof(3, $var);
+
+ return $this;
}
+ /**
+ * @return string
+ */
public function getValue()
{
return $this->whichOneof("value");
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php
index c878c5a7bc..ee3fd46f0f 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php
@@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ClientArgs</code>
+ * Generated from protobuf message <code>grpc.testing.ClientArgs</code>
*/
class ClientArgs extends \Google\Protobuf\Internal\Message
{
@@ -21,7 +21,8 @@ class ClientArgs extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClientConfig setup = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientConfig setup = 1;</code>
+ * @return \Grpc\Testing\ClientConfig
*/
public function getSetup()
{
@@ -29,16 +30,21 @@ class ClientArgs extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClientConfig setup = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientConfig setup = 1;</code>
+ * @param \Grpc\Testing\ClientConfig $var
+ * @return $this
*/
- public function setSetup(&$var)
+ public function setSetup($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ClientConfig::class);
$this->writeOneof(1, $var);
+
+ return $this;
}
/**
- * <code>.grpc.testing.Mark mark = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.Mark mark = 2;</code>
+ * @return \Grpc\Testing\Mark
*/
public function getMark()
{
@@ -46,14 +52,21 @@ class ClientArgs extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.Mark mark = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.Mark mark = 2;</code>
+ * @param \Grpc\Testing\Mark $var
+ * @return $this
*/
- public function setMark(&$var)
+ public function setMark($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Mark::class);
$this->writeOneof(2, $var);
+
+ return $this;
}
+ /**
+ * @return string
+ */
public function getArgtype()
{
return $this->whichOneof("argtype");
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php
index 52d6a75fb0..f7bc21587c 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php
@@ -9,96 +9,94 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ClientConfig</code>
+ * Generated from protobuf message <code>grpc.testing.ClientConfig</code>
*/
class ClientConfig extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* List of targets to connect to. At least one target needs to be specified.
- * </pre>
*
- * <code>repeated string server_targets = 1;</code>
+ * Generated from protobuf field <code>repeated string server_targets = 1;</code>
*/
private $server_targets;
/**
- * <code>.grpc.testing.ClientType client_type = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientType client_type = 2;</code>
*/
private $client_type = 0;
/**
- * <code>.grpc.testing.SecurityParams security_params = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.SecurityParams security_params = 3;</code>
*/
private $security_params = null;
/**
- * <pre>
* How many concurrent RPCs to start for each channel.
* For synchronous client, use a separate thread for each outstanding RPC.
- * </pre>
*
- * <code>int32 outstanding_rpcs_per_channel = 4;</code>
+ * Generated from protobuf field <code>int32 outstanding_rpcs_per_channel = 4;</code>
*/
private $outstanding_rpcs_per_channel = 0;
/**
- * <pre>
* Number of independent client channels to create.
* i-th channel will connect to server_target[i % server_targets.size()]
- * </pre>
*
- * <code>int32 client_channels = 5;</code>
+ * Generated from protobuf field <code>int32 client_channels = 5;</code>
*/
private $client_channels = 0;
/**
- * <pre>
* Only for async client. Number of threads to use to start/manage RPCs.
- * </pre>
*
- * <code>int32 async_client_threads = 7;</code>
+ * Generated from protobuf field <code>int32 async_client_threads = 7;</code>
*/
private $async_client_threads = 0;
/**
- * <code>.grpc.testing.RpcType rpc_type = 8;</code>
+ * Generated from protobuf field <code>.grpc.testing.RpcType rpc_type = 8;</code>
*/
private $rpc_type = 0;
/**
- * <pre>
* The requested load for the entire client (aggregated over all the threads).
- * </pre>
*
- * <code>.grpc.testing.LoadParams load_params = 10;</code>
+ * Generated from protobuf field <code>.grpc.testing.LoadParams load_params = 10;</code>
*/
private $load_params = null;
/**
- * <code>.grpc.testing.PayloadConfig payload_config = 11;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadConfig payload_config = 11;</code>
*/
private $payload_config = null;
/**
- * <code>.grpc.testing.HistogramParams histogram_params = 12;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramParams histogram_params = 12;</code>
*/
private $histogram_params = null;
/**
- * <pre>
* Specify the cores we should run the client on, if desired
- * </pre>
*
- * <code>repeated int32 core_list = 13;</code>
+ * Generated from protobuf field <code>repeated int32 core_list = 13;</code>
*/
private $core_list;
/**
- * <code>int32 core_limit = 14;</code>
+ * Generated from protobuf field <code>int32 core_limit = 14;</code>
*/
private $core_limit = 0;
/**
- * <pre>
* If we use an OTHER_CLIENT client_type, this string gives more detail
- * </pre>
*
- * <code>string other_client_api = 15;</code>
+ * Generated from protobuf field <code>string other_client_api = 15;</code>
*/
private $other_client_api = '';
/**
- * <code>repeated .grpc.testing.ChannelArg channel_args = 16;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ChannelArg channel_args = 16;</code>
*/
private $channel_args;
+ /**
+ * Number of threads that share each completion queue
+ *
+ * Generated from protobuf field <code>int32 threads_per_cq = 17;</code>
+ */
+ private $threads_per_cq = 0;
+ /**
+ * Number of messages on a stream before it gets finished/restarted
+ *
+ * Generated from protobuf field <code>int32 messages_per_stream = 18;</code>
+ */
+ private $messages_per_stream = 0;
public function __construct() {
\GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
@@ -106,11 +104,10 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* List of targets to connect to. At least one target needs to be specified.
- * </pre>
*
- * <code>repeated string server_targets = 1;</code>
+ * Generated from protobuf field <code>repeated string server_targets = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getServerTargets()
{
@@ -118,20 +115,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* List of targets to connect to. At least one target needs to be specified.
- * </pre>
*
- * <code>repeated string server_targets = 1;</code>
+ * Generated from protobuf field <code>repeated string server_targets = 1;</code>
+ * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setServerTargets(&$var)
+ public function setServerTargets($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
- $this->server_targets = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
+ $this->server_targets = $arr;
+
+ return $this;
}
/**
- * <code>.grpc.testing.ClientType client_type = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientType client_type = 2;</code>
+ * @return int
*/
public function getClientType()
{
@@ -139,16 +139,21 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClientType client_type = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientType client_type = 2;</code>
+ * @param int $var
+ * @return $this
*/
public function setClientType($var)
{
GPBUtil::checkEnum($var, \Grpc\Testing\ClientType::class);
$this->client_type = $var;
+
+ return $this;
}
/**
- * <code>.grpc.testing.SecurityParams security_params = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.SecurityParams security_params = 3;</code>
+ * @return \Grpc\Testing\SecurityParams
*/
public function getSecurityParams()
{
@@ -156,21 +161,24 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.SecurityParams security_params = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.SecurityParams security_params = 3;</code>
+ * @param \Grpc\Testing\SecurityParams $var
+ * @return $this
*/
- public function setSecurityParams(&$var)
+ public function setSecurityParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\SecurityParams::class);
$this->security_params = $var;
+
+ return $this;
}
/**
- * <pre>
* How many concurrent RPCs to start for each channel.
* For synchronous client, use a separate thread for each outstanding RPC.
- * </pre>
*
- * <code>int32 outstanding_rpcs_per_channel = 4;</code>
+ * Generated from protobuf field <code>int32 outstanding_rpcs_per_channel = 4;</code>
+ * @return int
*/
public function getOutstandingRpcsPerChannel()
{
@@ -178,26 +186,27 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* How many concurrent RPCs to start for each channel.
* For synchronous client, use a separate thread for each outstanding RPC.
- * </pre>
*
- * <code>int32 outstanding_rpcs_per_channel = 4;</code>
+ * Generated from protobuf field <code>int32 outstanding_rpcs_per_channel = 4;</code>
+ * @param int $var
+ * @return $this
*/
public function setOutstandingRpcsPerChannel($var)
{
GPBUtil::checkInt32($var);
$this->outstanding_rpcs_per_channel = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of independent client channels to create.
* i-th channel will connect to server_target[i % server_targets.size()]
- * </pre>
*
- * <code>int32 client_channels = 5;</code>
+ * Generated from protobuf field <code>int32 client_channels = 5;</code>
+ * @return int
*/
public function getClientChannels()
{
@@ -205,25 +214,26 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of independent client channels to create.
* i-th channel will connect to server_target[i % server_targets.size()]
- * </pre>
*
- * <code>int32 client_channels = 5;</code>
+ * Generated from protobuf field <code>int32 client_channels = 5;</code>
+ * @param int $var
+ * @return $this
*/
public function setClientChannels($var)
{
GPBUtil::checkInt32($var);
$this->client_channels = $var;
+
+ return $this;
}
/**
- * <pre>
* Only for async client. Number of threads to use to start/manage RPCs.
- * </pre>
*
- * <code>int32 async_client_threads = 7;</code>
+ * Generated from protobuf field <code>int32 async_client_threads = 7;</code>
+ * @return int
*/
public function getAsyncClientThreads()
{
@@ -231,20 +241,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Only for async client. Number of threads to use to start/manage RPCs.
- * </pre>
*
- * <code>int32 async_client_threads = 7;</code>
+ * Generated from protobuf field <code>int32 async_client_threads = 7;</code>
+ * @param int $var
+ * @return $this
*/
public function setAsyncClientThreads($var)
{
GPBUtil::checkInt32($var);
$this->async_client_threads = $var;
+
+ return $this;
}
/**
- * <code>.grpc.testing.RpcType rpc_type = 8;</code>
+ * Generated from protobuf field <code>.grpc.testing.RpcType rpc_type = 8;</code>
+ * @return int
*/
public function getRpcType()
{
@@ -252,20 +265,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.RpcType rpc_type = 8;</code>
+ * Generated from protobuf field <code>.grpc.testing.RpcType rpc_type = 8;</code>
+ * @param int $var
+ * @return $this
*/
public function setRpcType($var)
{
GPBUtil::checkEnum($var, \Grpc\Testing\RpcType::class);
$this->rpc_type = $var;
+
+ return $this;
}
/**
- * <pre>
* The requested load for the entire client (aggregated over all the threads).
- * </pre>
*
- * <code>.grpc.testing.LoadParams load_params = 10;</code>
+ * Generated from protobuf field <code>.grpc.testing.LoadParams load_params = 10;</code>
+ * @return \Grpc\Testing\LoadParams
*/
public function getLoadParams()
{
@@ -273,20 +289,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* The requested load for the entire client (aggregated over all the threads).
- * </pre>
*
- * <code>.grpc.testing.LoadParams load_params = 10;</code>
+ * Generated from protobuf field <code>.grpc.testing.LoadParams load_params = 10;</code>
+ * @param \Grpc\Testing\LoadParams $var
+ * @return $this
*/
- public function setLoadParams(&$var)
+ public function setLoadParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\LoadParams::class);
$this->load_params = $var;
+
+ return $this;
}
/**
- * <code>.grpc.testing.PayloadConfig payload_config = 11;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadConfig payload_config = 11;</code>
+ * @return \Grpc\Testing\PayloadConfig
*/
public function getPayloadConfig()
{
@@ -294,16 +313,21 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.PayloadConfig payload_config = 11;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadConfig payload_config = 11;</code>
+ * @param \Grpc\Testing\PayloadConfig $var
+ * @return $this
*/
- public function setPayloadConfig(&$var)
+ public function setPayloadConfig($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\PayloadConfig::class);
$this->payload_config = $var;
+
+ return $this;
}
/**
- * <code>.grpc.testing.HistogramParams histogram_params = 12;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramParams histogram_params = 12;</code>
+ * @return \Grpc\Testing\HistogramParams
*/
public function getHistogramParams()
{
@@ -311,20 +335,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.HistogramParams histogram_params = 12;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramParams histogram_params = 12;</code>
+ * @param \Grpc\Testing\HistogramParams $var
+ * @return $this
*/
- public function setHistogramParams(&$var)
+ public function setHistogramParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\HistogramParams::class);
$this->histogram_params = $var;
+
+ return $this;
}
/**
- * <pre>
* Specify the cores we should run the client on, if desired
- * </pre>
*
- * <code>repeated int32 core_list = 13;</code>
+ * Generated from protobuf field <code>repeated int32 core_list = 13;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getCoreList()
{
@@ -332,20 +359,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Specify the cores we should run the client on, if desired
- * </pre>
*
- * <code>repeated int32 core_list = 13;</code>
+ * Generated from protobuf field <code>repeated int32 core_list = 13;</code>
+ * @param int[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setCoreList(&$var)
+ public function setCoreList($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
- $this->core_list = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->core_list = $arr;
+
+ return $this;
}
/**
- * <code>int32 core_limit = 14;</code>
+ * Generated from protobuf field <code>int32 core_limit = 14;</code>
+ * @return int
*/
public function getCoreLimit()
{
@@ -353,20 +383,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 core_limit = 14;</code>
+ * Generated from protobuf field <code>int32 core_limit = 14;</code>
+ * @param int $var
+ * @return $this
*/
public function setCoreLimit($var)
{
GPBUtil::checkInt32($var);
$this->core_limit = $var;
+
+ return $this;
}
/**
- * <pre>
* If we use an OTHER_CLIENT client_type, this string gives more detail
- * </pre>
*
- * <code>string other_client_api = 15;</code>
+ * Generated from protobuf field <code>string other_client_api = 15;</code>
+ * @return string
*/
public function getOtherClientApi()
{
@@ -374,20 +407,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* If we use an OTHER_CLIENT client_type, this string gives more detail
- * </pre>
*
- * <code>string other_client_api = 15;</code>
+ * Generated from protobuf field <code>string other_client_api = 15;</code>
+ * @param string $var
+ * @return $this
*/
public function setOtherClientApi($var)
{
GPBUtil::checkString($var, True);
$this->other_client_api = $var;
+
+ return $this;
}
/**
- * <code>repeated .grpc.testing.ChannelArg channel_args = 16;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ChannelArg channel_args = 16;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getChannelArgs()
{
@@ -395,12 +431,68 @@ class ClientConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated .grpc.testing.ChannelArg channel_args = 16;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ChannelArg channel_args = 16;</code>
+ * @param \Grpc\Testing\ChannelArg[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setChannelArgs($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ChannelArg::class);
+ $this->channel_args = $arr;
+
+ return $this;
+ }
+
+ /**
+ * Number of threads that share each completion queue
+ *
+ * Generated from protobuf field <code>int32 threads_per_cq = 17;</code>
+ * @return int
+ */
+ public function getThreadsPerCq()
+ {
+ return $this->threads_per_cq;
+ }
+
+ /**
+ * Number of threads that share each completion queue
+ *
+ * Generated from protobuf field <code>int32 threads_per_cq = 17;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setThreadsPerCq($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->threads_per_cq = $var;
+
+ return $this;
+ }
+
+ /**
+ * Number of messages on a stream before it gets finished/restarted
+ *
+ * Generated from protobuf field <code>int32 messages_per_stream = 18;</code>
+ * @return int
+ */
+ public function getMessagesPerStream()
+ {
+ return $this->messages_per_stream;
+ }
+
+ /**
+ * Number of messages on a stream before it gets finished/restarted
+ *
+ * Generated from protobuf field <code>int32 messages_per_stream = 18;</code>
+ * @param int $var
+ * @return $this
*/
- public function setChannelArgs(&$var)
+ public function setMessagesPerStream($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ChannelArg::class);
- $this->channel_args = $var;
+ GPBUtil::checkInt32($var);
+ $this->messages_per_stream = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php
index 8b9a0c33a4..f2a7621791 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php
@@ -9,42 +9,48 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ClientStats</code>
+ * Generated from protobuf message <code>grpc.testing.ClientStats</code>
*/
class ClientStats extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Latency histogram. Data points are in nanoseconds.
- * </pre>
*
- * <code>.grpc.testing.HistogramData latencies = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramData latencies = 1;</code>
*/
private $latencies = null;
/**
- * <pre>
* See ServerStats for details.
- * </pre>
*
- * <code>double time_elapsed = 2;</code>
+ * Generated from protobuf field <code>double time_elapsed = 2;</code>
*/
private $time_elapsed = 0.0;
/**
- * <code>double time_user = 3;</code>
+ * Generated from protobuf field <code>double time_user = 3;</code>
*/
private $time_user = 0.0;
/**
- * <code>double time_system = 4;</code>
+ * Generated from protobuf field <code>double time_system = 4;</code>
*/
private $time_system = 0.0;
/**
- * <pre>
* Number of failed requests (one row per status code seen)
- * </pre>
*
- * <code>repeated .grpc.testing.RequestResultCount request_results = 5;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.RequestResultCount request_results = 5;</code>
*/
private $request_results;
+ /**
+ * Number of polls called inside completion queue
+ *
+ * Generated from protobuf field <code>uint64 cq_poll_count = 6;</code>
+ */
+ private $cq_poll_count = 0;
+ /**
+ * Core library stats
+ *
+ * Generated from protobuf field <code>.grpc.core.Stats core_stats = 7;</code>
+ */
+ private $core_stats = null;
public function __construct() {
\GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce();
@@ -52,11 +58,10 @@ class ClientStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Latency histogram. Data points are in nanoseconds.
- * </pre>
*
- * <code>.grpc.testing.HistogramData latencies = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramData latencies = 1;</code>
+ * @return \Grpc\Testing\HistogramData
*/
public function getLatencies()
{
@@ -64,24 +69,25 @@ class ClientStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Latency histogram. Data points are in nanoseconds.
- * </pre>
*
- * <code>.grpc.testing.HistogramData latencies = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramData latencies = 1;</code>
+ * @param \Grpc\Testing\HistogramData $var
+ * @return $this
*/
- public function setLatencies(&$var)
+ public function setLatencies($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\HistogramData::class);
$this->latencies = $var;
+
+ return $this;
}
/**
- * <pre>
* See ServerStats for details.
- * </pre>
*
- * <code>double time_elapsed = 2;</code>
+ * Generated from protobuf field <code>double time_elapsed = 2;</code>
+ * @return float
*/
public function getTimeElapsed()
{
@@ -89,20 +95,23 @@ class ClientStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* See ServerStats for details.
- * </pre>
*
- * <code>double time_elapsed = 2;</code>
+ * Generated from protobuf field <code>double time_elapsed = 2;</code>
+ * @param float $var
+ * @return $this
*/
public function setTimeElapsed($var)
{
GPBUtil::checkDouble($var);
$this->time_elapsed = $var;
+
+ return $this;
}
/**
- * <code>double time_user = 3;</code>
+ * Generated from protobuf field <code>double time_user = 3;</code>
+ * @return float
*/
public function getTimeUser()
{
@@ -110,16 +119,21 @@ class ClientStats extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double time_user = 3;</code>
+ * Generated from protobuf field <code>double time_user = 3;</code>
+ * @param float $var
+ * @return $this
*/
public function setTimeUser($var)
{
GPBUtil::checkDouble($var);
$this->time_user = $var;
+
+ return $this;
}
/**
- * <code>double time_system = 4;</code>
+ * Generated from protobuf field <code>double time_system = 4;</code>
+ * @return float
*/
public function getTimeSystem()
{
@@ -127,20 +141,23 @@ class ClientStats extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double time_system = 4;</code>
+ * Generated from protobuf field <code>double time_system = 4;</code>
+ * @param float $var
+ * @return $this
*/
public function setTimeSystem($var)
{
GPBUtil::checkDouble($var);
$this->time_system = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of failed requests (one row per status code seen)
- * </pre>
*
- * <code>repeated .grpc.testing.RequestResultCount request_results = 5;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.RequestResultCount request_results = 5;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getRequestResults()
{
@@ -148,16 +165,70 @@ class ClientStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of failed requests (one row per status code seen)
- * </pre>
*
- * <code>repeated .grpc.testing.RequestResultCount request_results = 5;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.RequestResultCount request_results = 5;</code>
+ * @param \Grpc\Testing\RequestResultCount[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setRequestResults(&$var)
+ public function setRequestResults($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class);
- $this->request_results = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class);
+ $this->request_results = $arr;
+
+ return $this;
+ }
+
+ /**
+ * Number of polls called inside completion queue
+ *
+ * Generated from protobuf field <code>uint64 cq_poll_count = 6;</code>
+ * @return int|string
+ */
+ public function getCqPollCount()
+ {
+ return $this->cq_poll_count;
+ }
+
+ /**
+ * Number of polls called inside completion queue
+ *
+ * Generated from protobuf field <code>uint64 cq_poll_count = 6;</code>
+ * @param int|string $var
+ * @return $this
+ */
+ public function setCqPollCount($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->cq_poll_count = $var;
+
+ return $this;
+ }
+
+ /**
+ * Core library stats
+ *
+ * Generated from protobuf field <code>.grpc.core.Stats core_stats = 7;</code>
+ * @return \Grpc\Core\Stats
+ */
+ public function getCoreStats()
+ {
+ return $this->core_stats;
+ }
+
+ /**
+ * Core library stats
+ *
+ * Generated from protobuf field <code>.grpc.core.Stats core_stats = 7;</code>
+ * @param \Grpc\Core\Stats $var
+ * @return $this
+ */
+ public function setCoreStats($var)
+ {
+ GPBUtil::checkMessage($var, \Grpc\Core\Stats::class);
+ $this->core_stats = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php
index a59f87a962..3ea40c4dfa 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php
@@ -9,12 +9,12 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ClientStatus</code>
+ * Generated from protobuf message <code>grpc.testing.ClientStatus</code>
*/
class ClientStatus extends \Google\Protobuf\Internal\Message
{
/**
- * <code>.grpc.testing.ClientStats stats = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientStats stats = 1;</code>
*/
private $stats = null;
@@ -24,7 +24,8 @@ class ClientStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClientStats stats = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientStats stats = 1;</code>
+ * @return \Grpc\Testing\ClientStats
*/
public function getStats()
{
@@ -32,12 +33,16 @@ class ClientStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClientStats stats = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientStats stats = 1;</code>
+ * @param \Grpc\Testing\ClientStats $var
+ * @return $this
*/
- public function setStats(&$var)
+ public function setStats($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ClientStats::class);
$this->stats = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php
index 4f59da992f..d1df4f1943 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php
@@ -5,29 +5,25 @@
namespace Grpc\Testing;
/**
- * Protobuf enum <code>grpc.testing.ClientType</code>
+ * Protobuf enum <code>Grpc\Testing\ClientType</code>
*/
class ClientType
{
/**
- * <pre>
* Many languages support a basic distinction between using
* sync or async client, and this allows the specification
- * </pre>
*
- * <code>SYNC_CLIENT = 0;</code>
+ * Generated from protobuf enum <code>SYNC_CLIENT = 0;</code>
*/
const SYNC_CLIENT = 0;
/**
- * <code>ASYNC_CLIENT = 1;</code>
+ * Generated from protobuf enum <code>ASYNC_CLIENT = 1;</code>
*/
const ASYNC_CLIENT = 1;
/**
- * <pre>
* used for some language-specific variants
- * </pre>
*
- * <code>OTHER_CLIENT = 2;</code>
+ * Generated from protobuf enum <code>OTHER_CLIENT = 2;</code>
*/
const OTHER_CLIENT = 2;
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php
index 53f2948af2..2772836f13 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php
@@ -9,12 +9,10 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Once an RPC finishes, immediately start a new one.
* No configuration parameters needed.
- * </pre>
*
- * Protobuf type <code>grpc.testing.ClosedLoopParams</code>
+ * Generated from protobuf message <code>grpc.testing.ClosedLoopParams</code>
*/
class ClosedLoopParams extends \Google\Protobuf\Internal\Message
{
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php
index 6d990f1b06..b9013cdb30 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php
@@ -9,12 +9,10 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* TODO (vpai): Fill this in once the details of complex, representative
* protos are decided
- * </pre>
*
- * Protobuf type <code>grpc.testing.ComplexProtoParams</code>
+ * Generated from protobuf message <code>grpc.testing.ComplexProtoParams</code>
*/
class ComplexProtoParams extends \Google\Protobuf\Internal\Message
{
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php
index 2e078b3fcd..7772572f1c 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php
@@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.CoreRequest</code>
+ * Generated from protobuf message <code>grpc.testing.CoreRequest</code>
*/
class CoreRequest extends \Google\Protobuf\Internal\Message
{
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php
index 85cb3418ad..e0b40ee300 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php
@@ -9,16 +9,14 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.CoreResponse</code>
+ * Generated from protobuf message <code>grpc.testing.CoreResponse</code>
*/
class CoreResponse extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Number of cores available on the server
- * </pre>
*
- * <code>int32 cores = 1;</code>
+ * Generated from protobuf field <code>int32 cores = 1;</code>
*/
private $cores = 0;
@@ -28,11 +26,10 @@ class CoreResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of cores available on the server
- * </pre>
*
- * <code>int32 cores = 1;</code>
+ * Generated from protobuf field <code>int32 cores = 1;</code>
+ * @return int
*/
public function getCores()
{
@@ -40,16 +37,18 @@ class CoreResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of cores available on the server
- * </pre>
*
- * <code>int32 cores = 1;</code>
+ * Generated from protobuf field <code>int32 cores = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setCores($var)
{
GPBUtil::checkInt32($var);
$this->cores = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php b/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php
index 27340fb0ef..6a6623a042 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php
@@ -9,21 +9,19 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* A protobuf representation for grpc status. This is used by test
* clients to specify a status that the server should attempt to return.
- * </pre>
*
- * Protobuf type <code>grpc.testing.EchoStatus</code>
+ * Generated from protobuf message <code>grpc.testing.EchoStatus</code>
*/
class EchoStatus extends \Google\Protobuf\Internal\Message
{
/**
- * <code>int32 code = 1;</code>
+ * Generated from protobuf field <code>int32 code = 1;</code>
*/
private $code = 0;
/**
- * <code>string message = 2;</code>
+ * Generated from protobuf field <code>string message = 2;</code>
*/
private $message = '';
@@ -33,7 +31,8 @@ class EchoStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 code = 1;</code>
+ * Generated from protobuf field <code>int32 code = 1;</code>
+ * @return int
*/
public function getCode()
{
@@ -41,16 +40,21 @@ class EchoStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 code = 1;</code>
+ * Generated from protobuf field <code>int32 code = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setCode($var)
{
GPBUtil::checkInt32($var);
$this->code = $var;
+
+ return $this;
}
/**
- * <code>string message = 2;</code>
+ * Generated from protobuf field <code>string message = 2;</code>
+ * @return string
*/
public function getMessage()
{
@@ -58,12 +62,16 @@ class EchoStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>string message = 2;</code>
+ * Generated from protobuf field <code>string message = 2;</code>
+ * @param string $var
+ * @return $this
*/
public function setMessage($var)
{
GPBUtil::checkString($var, True);
$this->message = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php
index 056da6e5de..136eac75e2 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php
@@ -9,36 +9,34 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Histogram data based on grpc/support/histogram.c
- * </pre>
*
- * Protobuf type <code>grpc.testing.HistogramData</code>
+ * Generated from protobuf message <code>grpc.testing.HistogramData</code>
*/
class HistogramData extends \Google\Protobuf\Internal\Message
{
/**
- * <code>repeated uint32 bucket = 1;</code>
+ * Generated from protobuf field <code>repeated uint32 bucket = 1;</code>
*/
private $bucket;
/**
- * <code>double min_seen = 2;</code>
+ * Generated from protobuf field <code>double min_seen = 2;</code>
*/
private $min_seen = 0.0;
/**
- * <code>double max_seen = 3;</code>
+ * Generated from protobuf field <code>double max_seen = 3;</code>
*/
private $max_seen = 0.0;
/**
- * <code>double sum = 4;</code>
+ * Generated from protobuf field <code>double sum = 4;</code>
*/
private $sum = 0.0;
/**
- * <code>double sum_of_squares = 5;</code>
+ * Generated from protobuf field <code>double sum_of_squares = 5;</code>
*/
private $sum_of_squares = 0.0;
/**
- * <code>double count = 6;</code>
+ * Generated from protobuf field <code>double count = 6;</code>
*/
private $count = 0.0;
@@ -48,7 +46,8 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated uint32 bucket = 1;</code>
+ * Generated from protobuf field <code>repeated uint32 bucket = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getBucket()
{
@@ -56,16 +55,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated uint32 bucket = 1;</code>
+ * Generated from protobuf field <code>repeated uint32 bucket = 1;</code>
+ * @param int[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setBucket(&$var)
+ public function setBucket($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT32);
- $this->bucket = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT32);
+ $this->bucket = $arr;
+
+ return $this;
}
/**
- * <code>double min_seen = 2;</code>
+ * Generated from protobuf field <code>double min_seen = 2;</code>
+ * @return float
*/
public function getMinSeen()
{
@@ -73,16 +77,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double min_seen = 2;</code>
+ * Generated from protobuf field <code>double min_seen = 2;</code>
+ * @param float $var
+ * @return $this
*/
public function setMinSeen($var)
{
GPBUtil::checkDouble($var);
$this->min_seen = $var;
+
+ return $this;
}
/**
- * <code>double max_seen = 3;</code>
+ * Generated from protobuf field <code>double max_seen = 3;</code>
+ * @return float
*/
public function getMaxSeen()
{
@@ -90,16 +99,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double max_seen = 3;</code>
+ * Generated from protobuf field <code>double max_seen = 3;</code>
+ * @param float $var
+ * @return $this
*/
public function setMaxSeen($var)
{
GPBUtil::checkDouble($var);
$this->max_seen = $var;
+
+ return $this;
}
/**
- * <code>double sum = 4;</code>
+ * Generated from protobuf field <code>double sum = 4;</code>
+ * @return float
*/
public function getSum()
{
@@ -107,16 +121,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double sum = 4;</code>
+ * Generated from protobuf field <code>double sum = 4;</code>
+ * @param float $var
+ * @return $this
*/
public function setSum($var)
{
GPBUtil::checkDouble($var);
$this->sum = $var;
+
+ return $this;
}
/**
- * <code>double sum_of_squares = 5;</code>
+ * Generated from protobuf field <code>double sum_of_squares = 5;</code>
+ * @return float
*/
public function getSumOfSquares()
{
@@ -124,16 +143,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double sum_of_squares = 5;</code>
+ * Generated from protobuf field <code>double sum_of_squares = 5;</code>
+ * @param float $var
+ * @return $this
*/
public function setSumOfSquares($var)
{
GPBUtil::checkDouble($var);
$this->sum_of_squares = $var;
+
+ return $this;
}
/**
- * <code>double count = 6;</code>
+ * Generated from protobuf field <code>double count = 6;</code>
+ * @return float
*/
public function getCount()
{
@@ -141,12 +165,16 @@ class HistogramData extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double count = 6;</code>
+ * Generated from protobuf field <code>double count = 6;</code>
+ * @param float $var
+ * @return $this
*/
public function setCount($var)
{
GPBUtil::checkDouble($var);
$this->count = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php
index 836c94b01d..1a1b484f14 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php
@@ -9,28 +9,22 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Histogram params based on grpc/support/histogram.c
- * </pre>
*
- * Protobuf type <code>grpc.testing.HistogramParams</code>
+ * Generated from protobuf message <code>grpc.testing.HistogramParams</code>
*/
class HistogramParams extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* first bucket is [0, 1 + resolution)
- * </pre>
*
- * <code>double resolution = 1;</code>
+ * Generated from protobuf field <code>double resolution = 1;</code>
*/
private $resolution = 0.0;
/**
- * <pre>
* use enough buckets to allow this value
- * </pre>
*
- * <code>double max_possible = 2;</code>
+ * Generated from protobuf field <code>double max_possible = 2;</code>
*/
private $max_possible = 0.0;
@@ -40,11 +34,10 @@ class HistogramParams extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* first bucket is [0, 1 + resolution)
- * </pre>
*
- * <code>double resolution = 1;</code>
+ * Generated from protobuf field <code>double resolution = 1;</code>
+ * @return float
*/
public function getResolution()
{
@@ -52,24 +45,25 @@ class HistogramParams extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* first bucket is [0, 1 + resolution)
- * </pre>
*
- * <code>double resolution = 1;</code>
+ * Generated from protobuf field <code>double resolution = 1;</code>
+ * @param float $var
+ * @return $this
*/
public function setResolution($var)
{
GPBUtil::checkDouble($var);
$this->resolution = $var;
+
+ return $this;
}
/**
- * <pre>
* use enough buckets to allow this value
- * </pre>
*
- * <code>double max_possible = 2;</code>
+ * Generated from protobuf field <code>double max_possible = 2;</code>
+ * @return float
*/
public function getMaxPossible()
{
@@ -77,16 +71,18 @@ class HistogramParams extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* use enough buckets to allow this value
- * </pre>
*
- * <code>double max_possible = 2;</code>
+ * Generated from protobuf field <code>double max_possible = 2;</code>
+ * @param float $var
+ * @return $this
*/
public function setMaxPossible($var)
{
GPBUtil::checkDouble($var);
$this->max_possible = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php
index 1f32e49c8a..04c345f242 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php
@@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.LoadParams</code>
+ * Generated from protobuf message <code>grpc.testing.LoadParams</code>
*/
class LoadParams extends \Google\Protobuf\Internal\Message
{
@@ -21,7 +21,8 @@ class LoadParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClosedLoopParams closed_loop = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClosedLoopParams closed_loop = 1;</code>
+ * @return \Grpc\Testing\ClosedLoopParams
*/
public function getClosedLoop()
{
@@ -29,16 +30,21 @@ class LoadParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ClosedLoopParams closed_loop = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClosedLoopParams closed_loop = 1;</code>
+ * @param \Grpc\Testing\ClosedLoopParams $var
+ * @return $this
*/
- public function setClosedLoop(&$var)
+ public function setClosedLoop($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ClosedLoopParams::class);
$this->writeOneof(1, $var);
+
+ return $this;
}
/**
- * <code>.grpc.testing.PoissonParams poisson = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.PoissonParams poisson = 2;</code>
+ * @return \Grpc\Testing\PoissonParams
*/
public function getPoisson()
{
@@ -46,14 +52,21 @@ class LoadParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.PoissonParams poisson = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.PoissonParams poisson = 2;</code>
+ * @param \Grpc\Testing\PoissonParams $var
+ * @return $this
*/
- public function setPoisson(&$var)
+ public function setPoisson($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\PoissonParams::class);
$this->writeOneof(2, $var);
+
+ return $this;
}
+ /**
+ * @return string
+ */
public function getLoad()
{
return $this->whichOneof("load");
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php b/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php
index ce006efacd..be058d51be 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php
@@ -9,20 +9,16 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Request current stats
- * </pre>
*
- * Protobuf type <code>grpc.testing.Mark</code>
+ * Generated from protobuf message <code>grpc.testing.Mark</code>
*/
class Mark extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* if true, the stats will be reset after taking their snapshot.
- * </pre>
*
- * <code>bool reset = 1;</code>
+ * Generated from protobuf field <code>bool reset = 1;</code>
*/
private $reset = false;
@@ -32,11 +28,10 @@ class Mark extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* if true, the stats will be reset after taking their snapshot.
- * </pre>
*
- * <code>bool reset = 1;</code>
+ * Generated from protobuf field <code>bool reset = 1;</code>
+ * @return bool
*/
public function getReset()
{
@@ -44,16 +39,18 @@ class Mark extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* if true, the stats will be reset after taking their snapshot.
- * </pre>
*
- * <code>bool reset = 1;</code>
+ * Generated from protobuf field <code>bool reset = 1;</code>
+ * @param bool $var
+ * @return $this
*/
public function setReset($var)
{
GPBUtil::checkBool($var);
$this->reset = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php b/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php
index d17c271af7..ad97890c93 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php
@@ -9,29 +9,23 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* A block of data, to simply increase gRPC message size.
- * </pre>
*
- * Protobuf type <code>grpc.testing.Payload</code>
+ * Generated from protobuf message <code>grpc.testing.Payload</code>
*/
class Payload extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* The type of data in body.
- * </pre>
*
- * <code>.grpc.testing.PayloadType type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType type = 1;</code>
*/
private $type = 0;
/**
- * <pre>
* Primary contents of payload.
- * </pre>
*
- * <code>bytes body = 2;</code>
+ * Generated from protobuf field <code>bytes body = 2;</code>
*/
private $body = '';
@@ -41,12 +35,11 @@ class Payload extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* The type of data in body.
- * </pre>
*
- * <code>.grpc.testing.PayloadType type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType type = 1;</code>
+ * @return int
*/
public function getType()
{
@@ -54,25 +47,26 @@ class Payload extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* The type of data in body.
- * </pre>
*
- * <code>.grpc.testing.PayloadType type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType type = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setType($var)
{
GPBUtil::checkEnum($var, \Grpc\Testing\PayloadType::class);
$this->type = $var;
+
+ return $this;
}
/**
- * <pre>
* Primary contents of payload.
- * </pre>
*
- * <code>bytes body = 2;</code>
+ * Generated from protobuf field <code>bytes body = 2;</code>
+ * @return string
*/
public function getBody()
{
@@ -80,16 +74,18 @@ class Payload extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Primary contents of payload.
- * </pre>
*
- * <code>bytes body = 2;</code>
+ * Generated from protobuf field <code>bytes body = 2;</code>
+ * @param string $var
+ * @return $this
*/
public function setBody($var)
{
GPBUtil::checkString($var, False);
$this->body = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php
index a2fe7109ba..748f52da82 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php
@@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.PayloadConfig</code>
+ * Generated from protobuf message <code>grpc.testing.PayloadConfig</code>
*/
class PayloadConfig extends \Google\Protobuf\Internal\Message
{
@@ -21,7 +21,8 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ByteBufferParams bytebuf_params = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ByteBufferParams bytebuf_params = 1;</code>
+ * @return \Grpc\Testing\ByteBufferParams
*/
public function getBytebufParams()
{
@@ -29,16 +30,21 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ByteBufferParams bytebuf_params = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ByteBufferParams bytebuf_params = 1;</code>
+ * @param \Grpc\Testing\ByteBufferParams $var
+ * @return $this
*/
- public function setBytebufParams(&$var)
+ public function setBytebufParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ByteBufferParams::class);
$this->writeOneof(1, $var);
+
+ return $this;
}
/**
- * <code>.grpc.testing.SimpleProtoParams simple_params = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.SimpleProtoParams simple_params = 2;</code>
+ * @return \Grpc\Testing\SimpleProtoParams
*/
public function getSimpleParams()
{
@@ -46,16 +52,21 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.SimpleProtoParams simple_params = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.SimpleProtoParams simple_params = 2;</code>
+ * @param \Grpc\Testing\SimpleProtoParams $var
+ * @return $this
*/
- public function setSimpleParams(&$var)
+ public function setSimpleParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\SimpleProtoParams::class);
$this->writeOneof(2, $var);
+
+ return $this;
}
/**
- * <code>.grpc.testing.ComplexProtoParams complex_params = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.ComplexProtoParams complex_params = 3;</code>
+ * @return \Grpc\Testing\ComplexProtoParams
*/
public function getComplexParams()
{
@@ -63,14 +74,21 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ComplexProtoParams complex_params = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.ComplexProtoParams complex_params = 3;</code>
+ * @param \Grpc\Testing\ComplexProtoParams $var
+ * @return $this
*/
- public function setComplexParams(&$var)
+ public function setComplexParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ComplexProtoParams::class);
$this->writeOneof(3, $var);
+
+ return $this;
}
+ /**
+ * @return string
+ */
public function getPayload()
{
return $this->whichOneof("payload");
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php
index 189ef034b4..d8df1af798 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php
@@ -5,21 +5,17 @@
namespace Grpc\Testing;
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* The type of payload that should be returned.
- * </pre>
*
- * Protobuf enum <code>grpc.testing.PayloadType</code>
+ * Protobuf enum <code>Grpc\Testing\PayloadType</code>
*/
class PayloadType
{
/**
- * <pre>
* Compressable text format.
- * </pre>
*
- * <code>COMPRESSABLE = 0;</code>
+ * Generated from protobuf enum <code>COMPRESSABLE = 0;</code>
*/
const COMPRESSABLE = 0;
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php
index d64edd45f0..6a4047f2ec 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php
@@ -9,21 +9,17 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Parameters of poisson process distribution, which is a good representation
* of activity coming in from independent identical stationary sources.
- * </pre>
*
- * Protobuf type <code>grpc.testing.PoissonParams</code>
+ * Generated from protobuf message <code>grpc.testing.PoissonParams</code>
*/
class PoissonParams extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
- * </pre>
*
- * <code>double offered_load = 1;</code>
+ * Generated from protobuf field <code>double offered_load = 1;</code>
*/
private $offered_load = 0.0;
@@ -33,11 +29,10 @@ class PoissonParams extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
- * </pre>
*
- * <code>double offered_load = 1;</code>
+ * Generated from protobuf field <code>double offered_load = 1;</code>
+ * @return float
*/
public function getOfferedLoad()
{
@@ -45,16 +40,18 @@ class PoissonParams extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
- * </pre>
*
- * <code>double offered_load = 1;</code>
+ * Generated from protobuf field <code>double offered_load = 1;</code>
+ * @param float $var
+ * @return $this
*/
public function setOfferedLoad($var)
{
GPBUtil::checkDouble($var);
$this->offered_load = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php
index a6da2e7aef..5510b57064 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php
@@ -16,17 +16,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-namespace Grpc\Testing {
+namespace Grpc\Testing;
- class ProxyClientServiceClient extends \Grpc\BaseStub {
+/**
+ */
+class ProxyClientServiceClient extends \Grpc\BaseStub {
/**
* @param string $hostname hostname
* @param array $opts channel options
- * @param Grpc\Channel $channel (optional) re-use channel object
+ * @param \Grpc\Channel $channel (optional) re-use channel object
*/
public function __construct($hostname, $opts, $channel = null) {
- parent::__construct($hostname, $opts, $channel);
+ parent::__construct($hostname, $opts, $channel);
}
/**
@@ -36,10 +38,10 @@ namespace Grpc\Testing {
*/
public function GetConfig(\Grpc\Testing\Void $argument,
$metadata = [], $options = []) {
- return $this->_simpleRequest('/grpc.testing.ProxyClientService/GetConfig',
- $argument,
- ['\Grpc\Testing\ClientConfig', 'decode'],
- $metadata, $options);
+ return $this->_simpleRequest('/grpc.testing.ProxyClientService/GetConfig',
+ $argument,
+ ['\Grpc\Testing\ClientConfig', 'decode'],
+ $metadata, $options);
}
/**
@@ -47,11 +49,19 @@ namespace Grpc\Testing {
* @param array $options call options
*/
public function ReportTime($metadata = [], $options = []) {
- return $this->_clientStreamRequest('/grpc.testing.ProxyClientService/ReportTime',
- ['\Grpc\Testing\Void','decode'],
- $metadata, $options);
+ return $this->_clientStreamRequest('/grpc.testing.ProxyClientService/ReportTime',
+ ['\Grpc\Testing\Void','decode'],
+ $metadata, $options);
}
- }
+ /**
+ * @param array $metadata metadata
+ * @param array $options call options
+ */
+ public function ReportHist($metadata = [], $options = []) {
+ return $this->_clientStreamRequest('/grpc.testing.ProxyClientService/ReportHist',
+ ['\Grpc\Testing\Void','decode'],
+ $metadata, $options);
+ }
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php
index ed43be99ce..6fab611534 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php
@@ -9,12 +9,12 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ProxyStat</code>
+ * Generated from protobuf message <code>grpc.testing.ProxyStat</code>
*/
class ProxyStat extends \Google\Protobuf\Internal\Message
{
/**
- * <code>double latency = 1;</code>
+ * Generated from protobuf field <code>double latency = 1;</code>
*/
private $latency = 0.0;
@@ -24,7 +24,8 @@ class ProxyStat extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double latency = 1;</code>
+ * Generated from protobuf field <code>double latency = 1;</code>
+ * @return float
*/
public function getLatency()
{
@@ -32,12 +33,16 @@ class ProxyStat extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double latency = 1;</code>
+ * Generated from protobuf field <code>double latency = 1;</code>
+ * @param float $var
+ * @return $this
*/
public function setLatency($var)
{
GPBUtil::checkDouble($var);
$this->latency = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php
index dfaaa606c3..cd728705fa 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php
@@ -9,22 +9,20 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* For reconnect interop test only.
* Server tells client whether its reconnects are following the spec and the
* reconnect backoffs it saw.
- * </pre>
*
- * Protobuf type <code>grpc.testing.ReconnectInfo</code>
+ * Generated from protobuf message <code>grpc.testing.ReconnectInfo</code>
*/
class ReconnectInfo extends \Google\Protobuf\Internal\Message
{
/**
- * <code>bool passed = 1;</code>
+ * Generated from protobuf field <code>bool passed = 1;</code>
*/
private $passed = false;
/**
- * <code>repeated int32 backoff_ms = 2;</code>
+ * Generated from protobuf field <code>repeated int32 backoff_ms = 2;</code>
*/
private $backoff_ms;
@@ -34,7 +32,8 @@ class ReconnectInfo extends \Google\Protobuf\Internal\Message
}
/**
- * <code>bool passed = 1;</code>
+ * Generated from protobuf field <code>bool passed = 1;</code>
+ * @return bool
*/
public function getPassed()
{
@@ -42,16 +41,21 @@ class ReconnectInfo extends \Google\Protobuf\Internal\Message
}
/**
- * <code>bool passed = 1;</code>
+ * Generated from protobuf field <code>bool passed = 1;</code>
+ * @param bool $var
+ * @return $this
*/
public function setPassed($var)
{
GPBUtil::checkBool($var);
$this->passed = $var;
+
+ return $this;
}
/**
- * <code>repeated int32 backoff_ms = 2;</code>
+ * Generated from protobuf field <code>repeated int32 backoff_ms = 2;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getBackoffMs()
{
@@ -59,12 +63,16 @@ class ReconnectInfo extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated int32 backoff_ms = 2;</code>
+ * Generated from protobuf field <code>repeated int32 backoff_ms = 2;</code>
+ * @param int[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setBackoffMs(&$var)
+ public function setBackoffMs($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
- $this->backoff_ms = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->backoff_ms = $arr;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php
index 9715855783..f91dc410cb 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php
@@ -9,17 +9,15 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* For reconnect interop test only.
* Client tells server what reconnection parameters it used.
- * </pre>
*
- * Protobuf type <code>grpc.testing.ReconnectParams</code>
+ * Generated from protobuf message <code>grpc.testing.ReconnectParams</code>
*/
class ReconnectParams extends \Google\Protobuf\Internal\Message
{
/**
- * <code>int32 max_reconnect_backoff_ms = 1;</code>
+ * Generated from protobuf field <code>int32 max_reconnect_backoff_ms = 1;</code>
*/
private $max_reconnect_backoff_ms = 0;
@@ -29,7 +27,8 @@ class ReconnectParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 max_reconnect_backoff_ms = 1;</code>
+ * Generated from protobuf field <code>int32 max_reconnect_backoff_ms = 1;</code>
+ * @return int
*/
public function getMaxReconnectBackoffMs()
{
@@ -37,12 +36,16 @@ class ReconnectParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 max_reconnect_backoff_ms = 1;</code>
+ * Generated from protobuf field <code>int32 max_reconnect_backoff_ms = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setMaxReconnectBackoffMs($var)
{
GPBUtil::checkInt32($var);
$this->max_reconnect_backoff_ms = $var;
+
+ return $this;
}
}
diff --git a/examples/php/helloworld_grpc_pb.php b/src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php
index ba83ed2614..72d44ffc66 100644
--- a/examples/php/helloworld_grpc_pb.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php
@@ -16,34 +16,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-namespace Helloworld {
+// An integration test service that covers all the method signature permutations
+// of unary/streaming requests/responses.
+namespace Grpc\Testing;
- // The greeting service definition.
- class GreeterClient extends \Grpc\BaseStub {
+/**
+ */
+class ReportQpsScenarioServiceClient extends \Grpc\BaseStub {
/**
* @param string $hostname hostname
* @param array $opts channel options
- * @param Grpc\Channel $channel (optional) re-use channel object
+ * @param \Grpc\Channel $channel (optional) re-use channel object
*/
public function __construct($hostname, $opts, $channel = null) {
- parent::__construct($hostname, $opts, $channel);
+ parent::__construct($hostname, $opts, $channel);
}
/**
- * Sends a greeting
- * @param \Helloworld\HelloRequest $argument input argument
+ * Report results of a QPS test benchmark scenario.
+ * @param \Grpc\Testing\ScenarioResult $argument input argument
* @param array $metadata metadata
* @param array $options call options
*/
- public function SayHello(\Helloworld\HelloRequest $argument,
+ public function ReportScenario(\Grpc\Testing\ScenarioResult $argument,
$metadata = [], $options = []) {
- return $this->_simpleRequest('/helloworld.Greeter/SayHello',
- $argument,
- ['\Helloworld\HelloReply', 'decode'],
- $metadata, $options);
+ return $this->_simpleRequest('/grpc.testing.ReportQpsScenarioService/ReportScenario',
+ $argument,
+ ['\Grpc\Testing\Void', 'decode'],
+ $metadata, $options);
}
- }
-
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php b/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php
index 1be42b2ac9..75fa6cafe2 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php
@@ -9,16 +9,16 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.RequestResultCount</code>
+ * Generated from protobuf message <code>grpc.testing.RequestResultCount</code>
*/
class RequestResultCount extends \Google\Protobuf\Internal\Message
{
/**
- * <code>int32 status_code = 1;</code>
+ * Generated from protobuf field <code>int32 status_code = 1;</code>
*/
private $status_code = 0;
/**
- * <code>int64 count = 2;</code>
+ * Generated from protobuf field <code>int64 count = 2;</code>
*/
private $count = 0;
@@ -28,7 +28,8 @@ class RequestResultCount extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 status_code = 1;</code>
+ * Generated from protobuf field <code>int32 status_code = 1;</code>
+ * @return int
*/
public function getStatusCode()
{
@@ -36,16 +37,21 @@ class RequestResultCount extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 status_code = 1;</code>
+ * Generated from protobuf field <code>int32 status_code = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setStatusCode($var)
{
GPBUtil::checkInt32($var);
$this->status_code = $var;
+
+ return $this;
}
/**
- * <code>int64 count = 2;</code>
+ * Generated from protobuf field <code>int64 count = 2;</code>
+ * @return int|string
*/
public function getCount()
{
@@ -53,12 +59,16 @@ class RequestResultCount extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int64 count = 2;</code>
+ * Generated from protobuf field <code>int64 count = 2;</code>
+ * @param int|string $var
+ * @return $this
*/
public function setCount($var)
{
GPBUtil::checkInt64($var);
$this->count = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php b/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php
index b7a8e5ece7..b2f0a827fe 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php
@@ -9,40 +9,32 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Configuration for a particular response.
- * </pre>
*
- * Protobuf type <code>grpc.testing.ResponseParameters</code>
+ * Generated from protobuf message <code>grpc.testing.ResponseParameters</code>
*/
class ResponseParameters extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Desired payload sizes in responses from the server.
- * </pre>
*
- * <code>int32 size = 1;</code>
+ * Generated from protobuf field <code>int32 size = 1;</code>
*/
private $size = 0;
/**
- * <pre>
* Desired interval between consecutive responses in the response stream in
* microseconds.
- * </pre>
*
- * <code>int32 interval_us = 2;</code>
+ * Generated from protobuf field <code>int32 interval_us = 2;</code>
*/
private $interval_us = 0;
/**
- * <pre>
* Whether to request the server to compress the response. This field is
* "nullable" in order to interoperate seamlessly with clients not able to
* implement the full compression tests by introspecting the call to verify
* the response's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue compressed = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue compressed = 3;</code>
*/
private $compressed = null;
@@ -52,11 +44,10 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Desired payload sizes in responses from the server.
- * </pre>
*
- * <code>int32 size = 1;</code>
+ * Generated from protobuf field <code>int32 size = 1;</code>
+ * @return int
*/
public function getSize()
{
@@ -64,25 +55,26 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Desired payload sizes in responses from the server.
- * </pre>
*
- * <code>int32 size = 1;</code>
+ * Generated from protobuf field <code>int32 size = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setSize($var)
{
GPBUtil::checkInt32($var);
$this->size = $var;
+
+ return $this;
}
/**
- * <pre>
* Desired interval between consecutive responses in the response stream in
* microseconds.
- * </pre>
*
- * <code>int32 interval_us = 2;</code>
+ * Generated from protobuf field <code>int32 interval_us = 2;</code>
+ * @return int
*/
public function getIntervalUs()
{
@@ -90,28 +82,29 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Desired interval between consecutive responses in the response stream in
* microseconds.
- * </pre>
*
- * <code>int32 interval_us = 2;</code>
+ * Generated from protobuf field <code>int32 interval_us = 2;</code>
+ * @param int $var
+ * @return $this
*/
public function setIntervalUs($var)
{
GPBUtil::checkInt32($var);
$this->interval_us = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether to request the server to compress the response. This field is
* "nullable" in order to interoperate seamlessly with clients not able to
* implement the full compression tests by introspecting the call to verify
* the response's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue compressed = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue compressed = 3;</code>
+ * @return \Grpc\Testing\BoolValue
*/
public function getCompressed()
{
@@ -119,19 +112,21 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether to request the server to compress the response. This field is
* "nullable" in order to interoperate seamlessly with clients not able to
* implement the full compression tests by introspecting the call to verify
* the response's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue compressed = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue compressed = 3;</code>
+ * @param \Grpc\Testing\BoolValue $var
+ * @return $this
*/
- public function setCompressed(&$var)
+ public function setCompressed($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class);
$this->compressed = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php b/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php
index 2e664fff47..73a66490ea 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php
@@ -5,17 +5,29 @@
namespace Grpc\Testing;
/**
- * Protobuf enum <code>grpc.testing.RpcType</code>
+ * Protobuf enum <code>Grpc\Testing\RpcType</code>
*/
class RpcType
{
/**
- * <code>UNARY = 0;</code>
+ * Generated from protobuf enum <code>UNARY = 0;</code>
*/
const UNARY = 0;
/**
- * <code>STREAMING = 1;</code>
+ * Generated from protobuf enum <code>STREAMING = 1;</code>
*/
const STREAMING = 1;
+ /**
+ * Generated from protobuf enum <code>STREAMING_FROM_CLIENT = 2;</code>
+ */
+ const STREAMING_FROM_CLIENT = 2;
+ /**
+ * Generated from protobuf enum <code>STREAMING_FROM_SERVER = 3;</code>
+ */
+ const STREAMING_FROM_SERVER = 3;
+ /**
+ * Generated from protobuf enum <code>STREAMING_BOTH_WAYS = 4;</code>
+ */
+ const STREAMING_BOTH_WAYS = 4;
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php b/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php
index 136ed299ea..9ec284b71f 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php
@@ -9,76 +9,58 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* A single performance scenario: input to qps_json_driver
- * </pre>
*
- * Protobuf type <code>grpc.testing.Scenario</code>
+ * Generated from protobuf message <code>grpc.testing.Scenario</code>
*/
class Scenario extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Human readable name for this scenario
- * </pre>
*
- * <code>string name = 1;</code>
+ * Generated from protobuf field <code>string name = 1;</code>
*/
private $name = '';
/**
- * <pre>
* Client configuration
- * </pre>
*
- * <code>.grpc.testing.ClientConfig client_config = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientConfig client_config = 2;</code>
*/
private $client_config = null;
/**
- * <pre>
* Number of clients to start for the test
- * </pre>
*
- * <code>int32 num_clients = 3;</code>
+ * Generated from protobuf field <code>int32 num_clients = 3;</code>
*/
private $num_clients = 0;
/**
- * <pre>
* Server configuration
- * </pre>
*
- * <code>.grpc.testing.ServerConfig server_config = 4;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerConfig server_config = 4;</code>
*/
private $server_config = null;
/**
- * <pre>
* Number of servers to start for the test
- * </pre>
*
- * <code>int32 num_servers = 5;</code>
+ * Generated from protobuf field <code>int32 num_servers = 5;</code>
*/
private $num_servers = 0;
/**
- * <pre>
* Warmup period, in seconds
- * </pre>
*
- * <code>int32 warmup_seconds = 6;</code>
+ * Generated from protobuf field <code>int32 warmup_seconds = 6;</code>
*/
private $warmup_seconds = 0;
/**
- * <pre>
* Benchmark time, in seconds
- * </pre>
*
- * <code>int32 benchmark_seconds = 7;</code>
+ * Generated from protobuf field <code>int32 benchmark_seconds = 7;</code>
*/
private $benchmark_seconds = 0;
/**
- * <pre>
* Number of workers to spawn locally (usually zero)
- * </pre>
*
- * <code>int32 spawn_local_worker_count = 8;</code>
+ * Generated from protobuf field <code>int32 spawn_local_worker_count = 8;</code>
*/
private $spawn_local_worker_count = 0;
@@ -88,11 +70,10 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Human readable name for this scenario
- * </pre>
*
- * <code>string name = 1;</code>
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
*/
public function getName()
{
@@ -100,24 +81,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Human readable name for this scenario
- * </pre>
*
- * <code>string name = 1;</code>
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
*/
public function setName($var)
{
GPBUtil::checkString($var, True);
$this->name = $var;
+
+ return $this;
}
/**
- * <pre>
* Client configuration
- * </pre>
*
- * <code>.grpc.testing.ClientConfig client_config = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientConfig client_config = 2;</code>
+ * @return \Grpc\Testing\ClientConfig
*/
public function getClientConfig()
{
@@ -125,24 +107,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Client configuration
- * </pre>
*
- * <code>.grpc.testing.ClientConfig client_config = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.ClientConfig client_config = 2;</code>
+ * @param \Grpc\Testing\ClientConfig $var
+ * @return $this
*/
- public function setClientConfig(&$var)
+ public function setClientConfig($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ClientConfig::class);
$this->client_config = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of clients to start for the test
- * </pre>
*
- * <code>int32 num_clients = 3;</code>
+ * Generated from protobuf field <code>int32 num_clients = 3;</code>
+ * @return int
*/
public function getNumClients()
{
@@ -150,24 +133,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of clients to start for the test
- * </pre>
*
- * <code>int32 num_clients = 3;</code>
+ * Generated from protobuf field <code>int32 num_clients = 3;</code>
+ * @param int $var
+ * @return $this
*/
public function setNumClients($var)
{
GPBUtil::checkInt32($var);
$this->num_clients = $var;
+
+ return $this;
}
/**
- * <pre>
* Server configuration
- * </pre>
*
- * <code>.grpc.testing.ServerConfig server_config = 4;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerConfig server_config = 4;</code>
+ * @return \Grpc\Testing\ServerConfig
*/
public function getServerConfig()
{
@@ -175,24 +159,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Server configuration
- * </pre>
*
- * <code>.grpc.testing.ServerConfig server_config = 4;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerConfig server_config = 4;</code>
+ * @param \Grpc\Testing\ServerConfig $var
+ * @return $this
*/
- public function setServerConfig(&$var)
+ public function setServerConfig($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ServerConfig::class);
$this->server_config = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of servers to start for the test
- * </pre>
*
- * <code>int32 num_servers = 5;</code>
+ * Generated from protobuf field <code>int32 num_servers = 5;</code>
+ * @return int
*/
public function getNumServers()
{
@@ -200,24 +185,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of servers to start for the test
- * </pre>
*
- * <code>int32 num_servers = 5;</code>
+ * Generated from protobuf field <code>int32 num_servers = 5;</code>
+ * @param int $var
+ * @return $this
*/
public function setNumServers($var)
{
GPBUtil::checkInt32($var);
$this->num_servers = $var;
+
+ return $this;
}
/**
- * <pre>
* Warmup period, in seconds
- * </pre>
*
- * <code>int32 warmup_seconds = 6;</code>
+ * Generated from protobuf field <code>int32 warmup_seconds = 6;</code>
+ * @return int
*/
public function getWarmupSeconds()
{
@@ -225,24 +211,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Warmup period, in seconds
- * </pre>
*
- * <code>int32 warmup_seconds = 6;</code>
+ * Generated from protobuf field <code>int32 warmup_seconds = 6;</code>
+ * @param int $var
+ * @return $this
*/
public function setWarmupSeconds($var)
{
GPBUtil::checkInt32($var);
$this->warmup_seconds = $var;
+
+ return $this;
}
/**
- * <pre>
* Benchmark time, in seconds
- * </pre>
*
- * <code>int32 benchmark_seconds = 7;</code>
+ * Generated from protobuf field <code>int32 benchmark_seconds = 7;</code>
+ * @return int
*/
public function getBenchmarkSeconds()
{
@@ -250,24 +237,25 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Benchmark time, in seconds
- * </pre>
*
- * <code>int32 benchmark_seconds = 7;</code>
+ * Generated from protobuf field <code>int32 benchmark_seconds = 7;</code>
+ * @param int $var
+ * @return $this
*/
public function setBenchmarkSeconds($var)
{
GPBUtil::checkInt32($var);
$this->benchmark_seconds = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of workers to spawn locally (usually zero)
- * </pre>
*
- * <code>int32 spawn_local_worker_count = 8;</code>
+ * Generated from protobuf field <code>int32 spawn_local_worker_count = 8;</code>
+ * @return int
*/
public function getSpawnLocalWorkerCount()
{
@@ -275,16 +263,18 @@ class Scenario extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of workers to spawn locally (usually zero)
- * </pre>
*
- * <code>int32 spawn_local_worker_count = 8;</code>
+ * Generated from protobuf field <code>int32 spawn_local_worker_count = 8;</code>
+ * @param int $var
+ * @return $this
*/
public function setSpawnLocalWorkerCount($var)
{
GPBUtil::checkInt32($var);
$this->spawn_local_worker_count = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php
index 809cd96244..31d9a39a1f 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php
@@ -9,80 +9,62 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Results of a single benchmark scenario.
- * </pre>
*
- * Protobuf type <code>grpc.testing.ScenarioResult</code>
+ * Generated from protobuf message <code>grpc.testing.ScenarioResult</code>
*/
class ScenarioResult extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Inputs used to run the scenario.
- * </pre>
*
- * <code>.grpc.testing.Scenario scenario = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Scenario scenario = 1;</code>
*/
private $scenario = null;
/**
- * <pre>
* Histograms from all clients merged into one histogram.
- * </pre>
*
- * <code>.grpc.testing.HistogramData latencies = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramData latencies = 2;</code>
*/
private $latencies = null;
/**
- * <pre>
* Client stats for each client
- * </pre>
*
- * <code>repeated .grpc.testing.ClientStats client_stats = 3;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ClientStats client_stats = 3;</code>
*/
private $client_stats;
/**
- * <pre>
* Server stats for each server
- * </pre>
*
- * <code>repeated .grpc.testing.ServerStats server_stats = 4;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ServerStats server_stats = 4;</code>
*/
private $server_stats;
/**
- * <pre>
* Number of cores available to each server
- * </pre>
*
- * <code>repeated int32 server_cores = 5;</code>
+ * Generated from protobuf field <code>repeated int32 server_cores = 5;</code>
*/
private $server_cores;
/**
- * <pre>
* An after-the-fact computed summary
- * </pre>
*
- * <code>.grpc.testing.ScenarioResultSummary summary = 6;</code>
+ * Generated from protobuf field <code>.grpc.testing.ScenarioResultSummary summary = 6;</code>
*/
private $summary = null;
/**
- * <pre>
* Information on success or failure of each worker
- * </pre>
*
- * <code>repeated bool client_success = 7;</code>
+ * Generated from protobuf field <code>repeated bool client_success = 7;</code>
*/
private $client_success;
/**
- * <code>repeated bool server_success = 8;</code>
+ * Generated from protobuf field <code>repeated bool server_success = 8;</code>
*/
private $server_success;
/**
- * <pre>
* Number of failed requests (one row per status code seen)
- * </pre>
*
- * <code>repeated .grpc.testing.RequestResultCount request_results = 9;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.RequestResultCount request_results = 9;</code>
*/
private $request_results;
@@ -92,11 +74,10 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Inputs used to run the scenario.
- * </pre>
*
- * <code>.grpc.testing.Scenario scenario = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Scenario scenario = 1;</code>
+ * @return \Grpc\Testing\Scenario
*/
public function getScenario()
{
@@ -104,24 +85,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Inputs used to run the scenario.
- * </pre>
*
- * <code>.grpc.testing.Scenario scenario = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Scenario scenario = 1;</code>
+ * @param \Grpc\Testing\Scenario $var
+ * @return $this
*/
- public function setScenario(&$var)
+ public function setScenario($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Scenario::class);
$this->scenario = $var;
+
+ return $this;
}
/**
- * <pre>
* Histograms from all clients merged into one histogram.
- * </pre>
*
- * <code>.grpc.testing.HistogramData latencies = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramData latencies = 2;</code>
+ * @return \Grpc\Testing\HistogramData
*/
public function getLatencies()
{
@@ -129,24 +111,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Histograms from all clients merged into one histogram.
- * </pre>
*
- * <code>.grpc.testing.HistogramData latencies = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.HistogramData latencies = 2;</code>
+ * @param \Grpc\Testing\HistogramData $var
+ * @return $this
*/
- public function setLatencies(&$var)
+ public function setLatencies($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\HistogramData::class);
$this->latencies = $var;
+
+ return $this;
}
/**
- * <pre>
* Client stats for each client
- * </pre>
*
- * <code>repeated .grpc.testing.ClientStats client_stats = 3;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ClientStats client_stats = 3;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getClientStats()
{
@@ -154,24 +137,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Client stats for each client
- * </pre>
*
- * <code>repeated .grpc.testing.ClientStats client_stats = 3;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ClientStats client_stats = 3;</code>
+ * @param \Grpc\Testing\ClientStats[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setClientStats(&$var)
+ public function setClientStats($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ClientStats::class);
- $this->client_stats = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ClientStats::class);
+ $this->client_stats = $arr;
+
+ return $this;
}
/**
- * <pre>
* Server stats for each server
- * </pre>
*
- * <code>repeated .grpc.testing.ServerStats server_stats = 4;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ServerStats server_stats = 4;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getServerStats()
{
@@ -179,24 +163,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Server stats for each server
- * </pre>
*
- * <code>repeated .grpc.testing.ServerStats server_stats = 4;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ServerStats server_stats = 4;</code>
+ * @param \Grpc\Testing\ServerStats[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setServerStats(&$var)
+ public function setServerStats($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ServerStats::class);
- $this->server_stats = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ServerStats::class);
+ $this->server_stats = $arr;
+
+ return $this;
}
/**
- * <pre>
* Number of cores available to each server
- * </pre>
*
- * <code>repeated int32 server_cores = 5;</code>
+ * Generated from protobuf field <code>repeated int32 server_cores = 5;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getServerCores()
{
@@ -204,24 +189,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of cores available to each server
- * </pre>
*
- * <code>repeated int32 server_cores = 5;</code>
+ * Generated from protobuf field <code>repeated int32 server_cores = 5;</code>
+ * @param int[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setServerCores(&$var)
+ public function setServerCores($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
- $this->server_cores = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->server_cores = $arr;
+
+ return $this;
}
/**
- * <pre>
* An after-the-fact computed summary
- * </pre>
*
- * <code>.grpc.testing.ScenarioResultSummary summary = 6;</code>
+ * Generated from protobuf field <code>.grpc.testing.ScenarioResultSummary summary = 6;</code>
+ * @return \Grpc\Testing\ScenarioResultSummary
*/
public function getSummary()
{
@@ -229,24 +215,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* An after-the-fact computed summary
- * </pre>
*
- * <code>.grpc.testing.ScenarioResultSummary summary = 6;</code>
+ * Generated from protobuf field <code>.grpc.testing.ScenarioResultSummary summary = 6;</code>
+ * @param \Grpc\Testing\ScenarioResultSummary $var
+ * @return $this
*/
- public function setSummary(&$var)
+ public function setSummary($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ScenarioResultSummary::class);
$this->summary = $var;
+
+ return $this;
}
/**
- * <pre>
* Information on success or failure of each worker
- * </pre>
*
- * <code>repeated bool client_success = 7;</code>
+ * Generated from protobuf field <code>repeated bool client_success = 7;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getClientSuccess()
{
@@ -254,20 +241,23 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Information on success or failure of each worker
- * </pre>
*
- * <code>repeated bool client_success = 7;</code>
+ * Generated from protobuf field <code>repeated bool client_success = 7;</code>
+ * @param bool[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setClientSuccess(&$var)
+ public function setClientSuccess($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL);
- $this->client_success = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL);
+ $this->client_success = $arr;
+
+ return $this;
}
/**
- * <code>repeated bool server_success = 8;</code>
+ * Generated from protobuf field <code>repeated bool server_success = 8;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getServerSuccess()
{
@@ -275,20 +265,23 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated bool server_success = 8;</code>
+ * Generated from protobuf field <code>repeated bool server_success = 8;</code>
+ * @param bool[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setServerSuccess(&$var)
+ public function setServerSuccess($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL);
- $this->server_success = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL);
+ $this->server_success = $arr;
+
+ return $this;
}
/**
- * <pre>
* Number of failed requests (one row per status code seen)
- * </pre>
*
- * <code>repeated .grpc.testing.RequestResultCount request_results = 9;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.RequestResultCount request_results = 9;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getRequestResults()
{
@@ -296,16 +289,18 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of failed requests (one row per status code seen)
- * </pre>
*
- * <code>repeated .grpc.testing.RequestResultCount request_results = 9;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.RequestResultCount request_results = 9;</code>
+ * @param \Grpc\Testing\RequestResultCount[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setRequestResults(&$var)
+ public function setRequestResults($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class);
- $this->request_results = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class);
+ $this->request_results = $arr;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php
index 7520cff78e..f7f1c987b5 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php
@@ -9,107 +9,107 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Basic summary that can be computed from ClientStats and ServerStats
* once the scenario has finished.
- * </pre>
*
- * Protobuf type <code>grpc.testing.ScenarioResultSummary</code>
+ * Generated from protobuf message <code>grpc.testing.ScenarioResultSummary</code>
*/
class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Total number of operations per second over all clients.
- * </pre>
*
- * <code>double qps = 1;</code>
+ * Generated from protobuf field <code>double qps = 1;</code>
*/
private $qps = 0.0;
/**
- * <pre>
* QPS per one server core.
- * </pre>
*
- * <code>double qps_per_server_core = 2;</code>
+ * Generated from protobuf field <code>double qps_per_server_core = 2;</code>
*/
private $qps_per_server_core = 0.0;
/**
- * <pre>
- * server load based on system_time (0.85 =&gt; 85%)
- * </pre>
+ * server load based on system_time (0.85 => 85%)
*
- * <code>double server_system_time = 3;</code>
+ * Generated from protobuf field <code>double server_system_time = 3;</code>
*/
private $server_system_time = 0.0;
/**
- * <pre>
- * server load based on user_time (0.85 =&gt; 85%)
- * </pre>
+ * server load based on user_time (0.85 => 85%)
*
- * <code>double server_user_time = 4;</code>
+ * Generated from protobuf field <code>double server_user_time = 4;</code>
*/
private $server_user_time = 0.0;
/**
- * <pre>
- * client load based on system_time (0.85 =&gt; 85%)
- * </pre>
+ * client load based on system_time (0.85 => 85%)
*
- * <code>double client_system_time = 5;</code>
+ * Generated from protobuf field <code>double client_system_time = 5;</code>
*/
private $client_system_time = 0.0;
/**
- * <pre>
- * client load based on user_time (0.85 =&gt; 85%)
- * </pre>
+ * client load based on user_time (0.85 => 85%)
*
- * <code>double client_user_time = 6;</code>
+ * Generated from protobuf field <code>double client_user_time = 6;</code>
*/
private $client_user_time = 0.0;
/**
- * <pre>
* X% latency percentiles (in nanoseconds)
- * </pre>
*
- * <code>double latency_50 = 7;</code>
+ * Generated from protobuf field <code>double latency_50 = 7;</code>
*/
private $latency_50 = 0.0;
/**
- * <code>double latency_90 = 8;</code>
+ * Generated from protobuf field <code>double latency_90 = 8;</code>
*/
private $latency_90 = 0.0;
/**
- * <code>double latency_95 = 9;</code>
+ * Generated from protobuf field <code>double latency_95 = 9;</code>
*/
private $latency_95 = 0.0;
/**
- * <code>double latency_99 = 10;</code>
+ * Generated from protobuf field <code>double latency_99 = 10;</code>
*/
private $latency_99 = 0.0;
/**
- * <code>double latency_999 = 11;</code>
+ * Generated from protobuf field <code>double latency_999 = 11;</code>
*/
private $latency_999 = 0.0;
/**
- * <pre>
* server cpu usage percentage
- * </pre>
*
- * <code>double server_cpu_usage = 12;</code>
+ * Generated from protobuf field <code>double server_cpu_usage = 12;</code>
*/
private $server_cpu_usage = 0.0;
/**
- * <pre>
* Number of requests that succeeded/failed
- * </pre>
*
- * <code>double successful_requests_per_second = 13;</code>
+ * Generated from protobuf field <code>double successful_requests_per_second = 13;</code>
*/
private $successful_requests_per_second = 0.0;
/**
- * <code>double failed_requests_per_second = 14;</code>
+ * Generated from protobuf field <code>double failed_requests_per_second = 14;</code>
*/
private $failed_requests_per_second = 0.0;
+ /**
+ * Number of polls called inside completion queue per request
+ *
+ * Generated from protobuf field <code>double client_polls_per_request = 15;</code>
+ */
+ private $client_polls_per_request = 0.0;
+ /**
+ * Generated from protobuf field <code>double server_polls_per_request = 16;</code>
+ */
+ private $server_polls_per_request = 0.0;
+ /**
+ * Queries per CPU-sec over all servers or clients
+ *
+ * Generated from protobuf field <code>double server_queries_per_cpu_sec = 17;</code>
+ */
+ private $server_queries_per_cpu_sec = 0.0;
+ /**
+ * Generated from protobuf field <code>double client_queries_per_cpu_sec = 18;</code>
+ */
+ private $client_queries_per_cpu_sec = 0.0;
public function __construct() {
\GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
@@ -117,11 +117,10 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Total number of operations per second over all clients.
- * </pre>
*
- * <code>double qps = 1;</code>
+ * Generated from protobuf field <code>double qps = 1;</code>
+ * @return float
*/
public function getQps()
{
@@ -129,24 +128,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Total number of operations per second over all clients.
- * </pre>
*
- * <code>double qps = 1;</code>
+ * Generated from protobuf field <code>double qps = 1;</code>
+ * @param float $var
+ * @return $this
*/
public function setQps($var)
{
GPBUtil::checkDouble($var);
$this->qps = $var;
+
+ return $this;
}
/**
- * <pre>
* QPS per one server core.
- * </pre>
*
- * <code>double qps_per_server_core = 2;</code>
+ * Generated from protobuf field <code>double qps_per_server_core = 2;</code>
+ * @return float
*/
public function getQpsPerServerCore()
{
@@ -154,24 +154,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* QPS per one server core.
- * </pre>
*
- * <code>double qps_per_server_core = 2;</code>
+ * Generated from protobuf field <code>double qps_per_server_core = 2;</code>
+ * @param float $var
+ * @return $this
*/
public function setQpsPerServerCore($var)
{
GPBUtil::checkDouble($var);
$this->qps_per_server_core = $var;
+
+ return $this;
}
/**
- * <pre>
- * server load based on system_time (0.85 =&gt; 85%)
- * </pre>
+ * server load based on system_time (0.85 => 85%)
*
- * <code>double server_system_time = 3;</code>
+ * Generated from protobuf field <code>double server_system_time = 3;</code>
+ * @return float
*/
public function getServerSystemTime()
{
@@ -179,24 +180,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
- * server load based on system_time (0.85 =&gt; 85%)
- * </pre>
+ * server load based on system_time (0.85 => 85%)
*
- * <code>double server_system_time = 3;</code>
+ * Generated from protobuf field <code>double server_system_time = 3;</code>
+ * @param float $var
+ * @return $this
*/
public function setServerSystemTime($var)
{
GPBUtil::checkDouble($var);
$this->server_system_time = $var;
+
+ return $this;
}
/**
- * <pre>
- * server load based on user_time (0.85 =&gt; 85%)
- * </pre>
+ * server load based on user_time (0.85 => 85%)
*
- * <code>double server_user_time = 4;</code>
+ * Generated from protobuf field <code>double server_user_time = 4;</code>
+ * @return float
*/
public function getServerUserTime()
{
@@ -204,24 +206,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
- * server load based on user_time (0.85 =&gt; 85%)
- * </pre>
+ * server load based on user_time (0.85 => 85%)
*
- * <code>double server_user_time = 4;</code>
+ * Generated from protobuf field <code>double server_user_time = 4;</code>
+ * @param float $var
+ * @return $this
*/
public function setServerUserTime($var)
{
GPBUtil::checkDouble($var);
$this->server_user_time = $var;
+
+ return $this;
}
/**
- * <pre>
- * client load based on system_time (0.85 =&gt; 85%)
- * </pre>
+ * client load based on system_time (0.85 => 85%)
*
- * <code>double client_system_time = 5;</code>
+ * Generated from protobuf field <code>double client_system_time = 5;</code>
+ * @return float
*/
public function getClientSystemTime()
{
@@ -229,24 +232,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
- * client load based on system_time (0.85 =&gt; 85%)
- * </pre>
+ * client load based on system_time (0.85 => 85%)
*
- * <code>double client_system_time = 5;</code>
+ * Generated from protobuf field <code>double client_system_time = 5;</code>
+ * @param float $var
+ * @return $this
*/
public function setClientSystemTime($var)
{
GPBUtil::checkDouble($var);
$this->client_system_time = $var;
+
+ return $this;
}
/**
- * <pre>
- * client load based on user_time (0.85 =&gt; 85%)
- * </pre>
+ * client load based on user_time (0.85 => 85%)
*
- * <code>double client_user_time = 6;</code>
+ * Generated from protobuf field <code>double client_user_time = 6;</code>
+ * @return float
*/
public function getClientUserTime()
{
@@ -254,24 +258,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
- * client load based on user_time (0.85 =&gt; 85%)
- * </pre>
+ * client load based on user_time (0.85 => 85%)
*
- * <code>double client_user_time = 6;</code>
+ * Generated from protobuf field <code>double client_user_time = 6;</code>
+ * @param float $var
+ * @return $this
*/
public function setClientUserTime($var)
{
GPBUtil::checkDouble($var);
$this->client_user_time = $var;
+
+ return $this;
}
/**
- * <pre>
* X% latency percentiles (in nanoseconds)
- * </pre>
*
- * <code>double latency_50 = 7;</code>
+ * Generated from protobuf field <code>double latency_50 = 7;</code>
+ * @return float
*/
public function getLatency50()
{
@@ -279,20 +284,23 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* X% latency percentiles (in nanoseconds)
- * </pre>
*
- * <code>double latency_50 = 7;</code>
+ * Generated from protobuf field <code>double latency_50 = 7;</code>
+ * @param float $var
+ * @return $this
*/
public function setLatency50($var)
{
GPBUtil::checkDouble($var);
$this->latency_50 = $var;
+
+ return $this;
}
/**
- * <code>double latency_90 = 8;</code>
+ * Generated from protobuf field <code>double latency_90 = 8;</code>
+ * @return float
*/
public function getLatency90()
{
@@ -300,16 +308,21 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double latency_90 = 8;</code>
+ * Generated from protobuf field <code>double latency_90 = 8;</code>
+ * @param float $var
+ * @return $this
*/
public function setLatency90($var)
{
GPBUtil::checkDouble($var);
$this->latency_90 = $var;
+
+ return $this;
}
/**
- * <code>double latency_95 = 9;</code>
+ * Generated from protobuf field <code>double latency_95 = 9;</code>
+ * @return float
*/
public function getLatency95()
{
@@ -317,16 +330,21 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double latency_95 = 9;</code>
+ * Generated from protobuf field <code>double latency_95 = 9;</code>
+ * @param float $var
+ * @return $this
*/
public function setLatency95($var)
{
GPBUtil::checkDouble($var);
$this->latency_95 = $var;
+
+ return $this;
}
/**
- * <code>double latency_99 = 10;</code>
+ * Generated from protobuf field <code>double latency_99 = 10;</code>
+ * @return float
*/
public function getLatency99()
{
@@ -334,16 +352,21 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double latency_99 = 10;</code>
+ * Generated from protobuf field <code>double latency_99 = 10;</code>
+ * @param float $var
+ * @return $this
*/
public function setLatency99($var)
{
GPBUtil::checkDouble($var);
$this->latency_99 = $var;
+
+ return $this;
}
/**
- * <code>double latency_999 = 11;</code>
+ * Generated from protobuf field <code>double latency_999 = 11;</code>
+ * @return float
*/
public function getLatency999()
{
@@ -351,20 +374,23 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double latency_999 = 11;</code>
+ * Generated from protobuf field <code>double latency_999 = 11;</code>
+ * @param float $var
+ * @return $this
*/
public function setLatency999($var)
{
GPBUtil::checkDouble($var);
$this->latency_999 = $var;
+
+ return $this;
}
/**
- * <pre>
* server cpu usage percentage
- * </pre>
*
- * <code>double server_cpu_usage = 12;</code>
+ * Generated from protobuf field <code>double server_cpu_usage = 12;</code>
+ * @return float
*/
public function getServerCpuUsage()
{
@@ -372,24 +398,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* server cpu usage percentage
- * </pre>
*
- * <code>double server_cpu_usage = 12;</code>
+ * Generated from protobuf field <code>double server_cpu_usage = 12;</code>
+ * @param float $var
+ * @return $this
*/
public function setServerCpuUsage($var)
{
GPBUtil::checkDouble($var);
$this->server_cpu_usage = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of requests that succeeded/failed
- * </pre>
*
- * <code>double successful_requests_per_second = 13;</code>
+ * Generated from protobuf field <code>double successful_requests_per_second = 13;</code>
+ * @return float
*/
public function getSuccessfulRequestsPerSecond()
{
@@ -397,20 +424,23 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of requests that succeeded/failed
- * </pre>
*
- * <code>double successful_requests_per_second = 13;</code>
+ * Generated from protobuf field <code>double successful_requests_per_second = 13;</code>
+ * @param float $var
+ * @return $this
*/
public function setSuccessfulRequestsPerSecond($var)
{
GPBUtil::checkDouble($var);
$this->successful_requests_per_second = $var;
+
+ return $this;
}
/**
- * <code>double failed_requests_per_second = 14;</code>
+ * Generated from protobuf field <code>double failed_requests_per_second = 14;</code>
+ * @return float
*/
public function getFailedRequestsPerSecond()
{
@@ -418,12 +448,112 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message
}
/**
- * <code>double failed_requests_per_second = 14;</code>
+ * Generated from protobuf field <code>double failed_requests_per_second = 14;</code>
+ * @param float $var
+ * @return $this
*/
public function setFailedRequestsPerSecond($var)
{
GPBUtil::checkDouble($var);
$this->failed_requests_per_second = $var;
+
+ return $this;
+ }
+
+ /**
+ * Number of polls called inside completion queue per request
+ *
+ * Generated from protobuf field <code>double client_polls_per_request = 15;</code>
+ * @return float
+ */
+ public function getClientPollsPerRequest()
+ {
+ return $this->client_polls_per_request;
+ }
+
+ /**
+ * Number of polls called inside completion queue per request
+ *
+ * Generated from protobuf field <code>double client_polls_per_request = 15;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setClientPollsPerRequest($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->client_polls_per_request = $var;
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>double server_polls_per_request = 16;</code>
+ * @return float
+ */
+ public function getServerPollsPerRequest()
+ {
+ return $this->server_polls_per_request;
+ }
+
+ /**
+ * Generated from protobuf field <code>double server_polls_per_request = 16;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setServerPollsPerRequest($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->server_polls_per_request = $var;
+
+ return $this;
+ }
+
+ /**
+ * Queries per CPU-sec over all servers or clients
+ *
+ * Generated from protobuf field <code>double server_queries_per_cpu_sec = 17;</code>
+ * @return float
+ */
+ public function getServerQueriesPerCpuSec()
+ {
+ return $this->server_queries_per_cpu_sec;
+ }
+
+ /**
+ * Queries per CPU-sec over all servers or clients
+ *
+ * Generated from protobuf field <code>double server_queries_per_cpu_sec = 17;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setServerQueriesPerCpuSec($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->server_queries_per_cpu_sec = $var;
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>double client_queries_per_cpu_sec = 18;</code>
+ * @return float
+ */
+ public function getClientQueriesPerCpuSec()
+ {
+ return $this->client_queries_per_cpu_sec;
+ }
+
+ /**
+ * Generated from protobuf field <code>double client_queries_per_cpu_sec = 18;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setClientQueriesPerCpuSec($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->client_queries_per_cpu_sec = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php b/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php
index 278f555b76..2146b4776e 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php
@@ -9,16 +9,14 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* A set of scenarios to be run with qps_json_driver
- * </pre>
*
- * Protobuf type <code>grpc.testing.Scenarios</code>
+ * Generated from protobuf message <code>grpc.testing.Scenarios</code>
*/
class Scenarios extends \Google\Protobuf\Internal\Message
{
/**
- * <code>repeated .grpc.testing.Scenario scenarios = 1;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.Scenario scenarios = 1;</code>
*/
private $scenarios;
@@ -28,7 +26,8 @@ class Scenarios extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated .grpc.testing.Scenario scenarios = 1;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.Scenario scenarios = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getScenarios()
{
@@ -36,12 +35,16 @@ class Scenarios extends \Google\Protobuf\Internal\Message
}
/**
- * <code>repeated .grpc.testing.Scenario scenarios = 1;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.Scenario scenarios = 1;</code>
+ * @param \Grpc\Testing\Scenario[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setScenarios(&$var)
+ public function setScenarios($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\Scenario::class);
- $this->scenarios = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\Scenario::class);
+ $this->scenarios = $arr;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php
index 27a5b95cc9..8ce623a4bc 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php
@@ -9,22 +9,24 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* presence of SecurityParams implies use of TLS
- * </pre>
*
- * Protobuf type <code>grpc.testing.SecurityParams</code>
+ * Generated from protobuf message <code>grpc.testing.SecurityParams</code>
*/
class SecurityParams extends \Google\Protobuf\Internal\Message
{
/**
- * <code>bool use_test_ca = 1;</code>
+ * Generated from protobuf field <code>bool use_test_ca = 1;</code>
*/
private $use_test_ca = false;
/**
- * <code>string server_host_override = 2;</code>
+ * Generated from protobuf field <code>string server_host_override = 2;</code>
*/
private $server_host_override = '';
+ /**
+ * Generated from protobuf field <code>string cred_type = 3;</code>
+ */
+ private $cred_type = '';
public function __construct() {
\GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
@@ -32,7 +34,8 @@ class SecurityParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>bool use_test_ca = 1;</code>
+ * Generated from protobuf field <code>bool use_test_ca = 1;</code>
+ * @return bool
*/
public function getUseTestCa()
{
@@ -40,16 +43,21 @@ class SecurityParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>bool use_test_ca = 1;</code>
+ * Generated from protobuf field <code>bool use_test_ca = 1;</code>
+ * @param bool $var
+ * @return $this
*/
public function setUseTestCa($var)
{
GPBUtil::checkBool($var);
$this->use_test_ca = $var;
+
+ return $this;
}
/**
- * <code>string server_host_override = 2;</code>
+ * Generated from protobuf field <code>string server_host_override = 2;</code>
+ * @return string
*/
public function getServerHostOverride()
{
@@ -57,12 +65,38 @@ class SecurityParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>string server_host_override = 2;</code>
+ * Generated from protobuf field <code>string server_host_override = 2;</code>
+ * @param string $var
+ * @return $this
*/
public function setServerHostOverride($var)
{
GPBUtil::checkString($var, True);
$this->server_host_override = $var;
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>string cred_type = 3;</code>
+ * @return string
+ */
+ public function getCredType()
+ {
+ return $this->cred_type;
+ }
+
+ /**
+ * Generated from protobuf field <code>string cred_type = 3;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setCredType($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->cred_type = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php
index 0d84b80124..acf7e18b6d 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php
@@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ServerArgs</code>
+ * Generated from protobuf message <code>grpc.testing.ServerArgs</code>
*/
class ServerArgs extends \Google\Protobuf\Internal\Message
{
@@ -21,7 +21,8 @@ class ServerArgs extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ServerConfig setup = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerConfig setup = 1;</code>
+ * @return \Grpc\Testing\ServerConfig
*/
public function getSetup()
{
@@ -29,16 +30,21 @@ class ServerArgs extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ServerConfig setup = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerConfig setup = 1;</code>
+ * @param \Grpc\Testing\ServerConfig $var
+ * @return $this
*/
- public function setSetup(&$var)
+ public function setSetup($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ServerConfig::class);
$this->writeOneof(1, $var);
+
+ return $this;
}
/**
- * <code>.grpc.testing.Mark mark = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.Mark mark = 2;</code>
+ * @return \Grpc\Testing\Mark
*/
public function getMark()
{
@@ -46,14 +52,21 @@ class ServerArgs extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.Mark mark = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.Mark mark = 2;</code>
+ * @param \Grpc\Testing\Mark $var
+ * @return $this
*/
- public function setMark(&$var)
+ public function setMark($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Mark::class);
$this->writeOneof(2, $var);
+
+ return $this;
}
+ /**
+ * @return string
+ */
public function getArgtype()
{
return $this->whichOneof("argtype");
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php
index e2bcede48c..8bd4c69566 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php
@@ -9,77 +9,73 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ServerConfig</code>
+ * Generated from protobuf message <code>grpc.testing.ServerConfig</code>
*/
class ServerConfig extends \Google\Protobuf\Internal\Message
{
/**
- * <code>.grpc.testing.ServerType server_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerType server_type = 1;</code>
*/
private $server_type = 0;
/**
- * <code>.grpc.testing.SecurityParams security_params = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.SecurityParams security_params = 2;</code>
*/
private $security_params = null;
/**
- * <pre>
* Port on which to listen. Zero means pick unused port.
- * </pre>
*
- * <code>int32 port = 4;</code>
+ * Generated from protobuf field <code>int32 port = 4;</code>
*/
private $port = 0;
/**
- * <pre>
* Only for async server. Number of threads used to serve the requests.
- * </pre>
*
- * <code>int32 async_server_threads = 7;</code>
+ * Generated from protobuf field <code>int32 async_server_threads = 7;</code>
*/
private $async_server_threads = 0;
/**
- * <pre>
* Specify the number of cores to limit server to, if desired
- * </pre>
*
- * <code>int32 core_limit = 8;</code>
+ * Generated from protobuf field <code>int32 core_limit = 8;</code>
*/
private $core_limit = 0;
/**
- * <pre>
* payload config, used in generic server.
* Note this must NOT be used in proto (non-generic) servers. For proto servers,
* 'response sizes' must be configured from the 'response_size' field of the
* 'SimpleRequest' objects in RPC requests.
- * </pre>
*
- * <code>.grpc.testing.PayloadConfig payload_config = 9;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadConfig payload_config = 9;</code>
*/
private $payload_config = null;
/**
- * <pre>
* Specify the cores we should run the server on, if desired
- * </pre>
*
- * <code>repeated int32 core_list = 10;</code>
+ * Generated from protobuf field <code>repeated int32 core_list = 10;</code>
*/
private $core_list;
/**
- * <pre>
* If we use an OTHER_SERVER client_type, this string gives more detail
- * </pre>
*
- * <code>string other_server_api = 11;</code>
+ * Generated from protobuf field <code>string other_server_api = 11;</code>
*/
private $other_server_api = '';
/**
- * <pre>
+ * Number of threads that share each completion queue
+ *
+ * Generated from protobuf field <code>int32 threads_per_cq = 12;</code>
+ */
+ private $threads_per_cq = 0;
+ /**
* Buffer pool size (no buffer pool specified if unset)
- * </pre>
*
- * <code>int32 resource_quota_size = 1001;</code>
+ * Generated from protobuf field <code>int32 resource_quota_size = 1001;</code>
*/
private $resource_quota_size = 0;
+ /**
+ * Generated from protobuf field <code>repeated .grpc.testing.ChannelArg channel_args = 1002;</code>
+ */
+ private $channel_args;
public function __construct() {
\GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
@@ -87,7 +83,8 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ServerType server_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerType server_type = 1;</code>
+ * @return int
*/
public function getServerType()
{
@@ -95,16 +92,21 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ServerType server_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerType server_type = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setServerType($var)
{
GPBUtil::checkEnum($var, \Grpc\Testing\ServerType::class);
$this->server_type = $var;
+
+ return $this;
}
/**
- * <code>.grpc.testing.SecurityParams security_params = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.SecurityParams security_params = 2;</code>
+ * @return \Grpc\Testing\SecurityParams
*/
public function getSecurityParams()
{
@@ -112,20 +114,23 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.SecurityParams security_params = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.SecurityParams security_params = 2;</code>
+ * @param \Grpc\Testing\SecurityParams $var
+ * @return $this
*/
- public function setSecurityParams(&$var)
+ public function setSecurityParams($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\SecurityParams::class);
$this->security_params = $var;
+
+ return $this;
}
/**
- * <pre>
* Port on which to listen. Zero means pick unused port.
- * </pre>
*
- * <code>int32 port = 4;</code>
+ * Generated from protobuf field <code>int32 port = 4;</code>
+ * @return int
*/
public function getPort()
{
@@ -133,24 +138,25 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Port on which to listen. Zero means pick unused port.
- * </pre>
*
- * <code>int32 port = 4;</code>
+ * Generated from protobuf field <code>int32 port = 4;</code>
+ * @param int $var
+ * @return $this
*/
public function setPort($var)
{
GPBUtil::checkInt32($var);
$this->port = $var;
+
+ return $this;
}
/**
- * <pre>
* Only for async server. Number of threads used to serve the requests.
- * </pre>
*
- * <code>int32 async_server_threads = 7;</code>
+ * Generated from protobuf field <code>int32 async_server_threads = 7;</code>
+ * @return int
*/
public function getAsyncServerThreads()
{
@@ -158,24 +164,25 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Only for async server. Number of threads used to serve the requests.
- * </pre>
*
- * <code>int32 async_server_threads = 7;</code>
+ * Generated from protobuf field <code>int32 async_server_threads = 7;</code>
+ * @param int $var
+ * @return $this
*/
public function setAsyncServerThreads($var)
{
GPBUtil::checkInt32($var);
$this->async_server_threads = $var;
+
+ return $this;
}
/**
- * <pre>
* Specify the number of cores to limit server to, if desired
- * </pre>
*
- * <code>int32 core_limit = 8;</code>
+ * Generated from protobuf field <code>int32 core_limit = 8;</code>
+ * @return int
*/
public function getCoreLimit()
{
@@ -183,27 +190,28 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Specify the number of cores to limit server to, if desired
- * </pre>
*
- * <code>int32 core_limit = 8;</code>
+ * Generated from protobuf field <code>int32 core_limit = 8;</code>
+ * @param int $var
+ * @return $this
*/
public function setCoreLimit($var)
{
GPBUtil::checkInt32($var);
$this->core_limit = $var;
+
+ return $this;
}
/**
- * <pre>
* payload config, used in generic server.
* Note this must NOT be used in proto (non-generic) servers. For proto servers,
* 'response sizes' must be configured from the 'response_size' field of the
* 'SimpleRequest' objects in RPC requests.
- * </pre>
*
- * <code>.grpc.testing.PayloadConfig payload_config = 9;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadConfig payload_config = 9;</code>
+ * @return \Grpc\Testing\PayloadConfig
*/
public function getPayloadConfig()
{
@@ -211,27 +219,28 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* payload config, used in generic server.
* Note this must NOT be used in proto (non-generic) servers. For proto servers,
* 'response sizes' must be configured from the 'response_size' field of the
* 'SimpleRequest' objects in RPC requests.
- * </pre>
*
- * <code>.grpc.testing.PayloadConfig payload_config = 9;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadConfig payload_config = 9;</code>
+ * @param \Grpc\Testing\PayloadConfig $var
+ * @return $this
*/
- public function setPayloadConfig(&$var)
+ public function setPayloadConfig($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\PayloadConfig::class);
$this->payload_config = $var;
+
+ return $this;
}
/**
- * <pre>
* Specify the cores we should run the server on, if desired
- * </pre>
*
- * <code>repeated int32 core_list = 10;</code>
+ * Generated from protobuf field <code>repeated int32 core_list = 10;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getCoreList()
{
@@ -239,24 +248,25 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Specify the cores we should run the server on, if desired
- * </pre>
*
- * <code>repeated int32 core_list = 10;</code>
+ * Generated from protobuf field <code>repeated int32 core_list = 10;</code>
+ * @param int[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setCoreList(&$var)
+ public function setCoreList($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
- $this->core_list = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->core_list = $arr;
+
+ return $this;
}
/**
- * <pre>
* If we use an OTHER_SERVER client_type, this string gives more detail
- * </pre>
*
- * <code>string other_server_api = 11;</code>
+ * Generated from protobuf field <code>string other_server_api = 11;</code>
+ * @return string
*/
public function getOtherServerApi()
{
@@ -264,24 +274,51 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* If we use an OTHER_SERVER client_type, this string gives more detail
- * </pre>
*
- * <code>string other_server_api = 11;</code>
+ * Generated from protobuf field <code>string other_server_api = 11;</code>
+ * @param string $var
+ * @return $this
*/
public function setOtherServerApi($var)
{
GPBUtil::checkString($var, True);
$this->other_server_api = $var;
+
+ return $this;
+ }
+
+ /**
+ * Number of threads that share each completion queue
+ *
+ * Generated from protobuf field <code>int32 threads_per_cq = 12;</code>
+ * @return int
+ */
+ public function getThreadsPerCq()
+ {
+ return $this->threads_per_cq;
+ }
+
+ /**
+ * Number of threads that share each completion queue
+ *
+ * Generated from protobuf field <code>int32 threads_per_cq = 12;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setThreadsPerCq($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->threads_per_cq = $var;
+
+ return $this;
}
/**
- * <pre>
* Buffer pool size (no buffer pool specified if unset)
- * </pre>
*
- * <code>int32 resource_quota_size = 1001;</code>
+ * Generated from protobuf field <code>int32 resource_quota_size = 1001;</code>
+ * @return int
*/
public function getResourceQuotaSize()
{
@@ -289,16 +326,40 @@ class ServerConfig extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Buffer pool size (no buffer pool specified if unset)
- * </pre>
*
- * <code>int32 resource_quota_size = 1001;</code>
+ * Generated from protobuf field <code>int32 resource_quota_size = 1001;</code>
+ * @param int $var
+ * @return $this
*/
public function setResourceQuotaSize($var)
{
GPBUtil::checkInt32($var);
$this->resource_quota_size = $var;
+
+ return $this;
+ }
+
+ /**
+ * Generated from protobuf field <code>repeated .grpc.testing.ChannelArg channel_args = 1002;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getChannelArgs()
+ {
+ return $this->channel_args;
+ }
+
+ /**
+ * Generated from protobuf field <code>repeated .grpc.testing.ChannelArg channel_args = 1002;</code>
+ * @param \Grpc\Testing\ChannelArg[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setChannelArgs($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ChannelArg::class);
+ $this->channel_args = $arr;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php
index 98b2af764c..aea2cb0fce 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php
@@ -9,51 +9,53 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ServerStats</code>
+ * Generated from protobuf message <code>grpc.testing.ServerStats</code>
*/
class ServerStats extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* wall clock time change in seconds since last reset
- * </pre>
*
- * <code>double time_elapsed = 1;</code>
+ * Generated from protobuf field <code>double time_elapsed = 1;</code>
*/
private $time_elapsed = 0.0;
/**
- * <pre>
* change in user time (in seconds) used by the server since last reset
- * </pre>
*
- * <code>double time_user = 2;</code>
+ * Generated from protobuf field <code>double time_user = 2;</code>
*/
private $time_user = 0.0;
/**
- * <pre>
* change in server time (in seconds) used by the server process and all
* threads since last reset
- * </pre>
*
- * <code>double time_system = 3;</code>
+ * Generated from protobuf field <code>double time_system = 3;</code>
*/
private $time_system = 0.0;
/**
- * <pre>
* change in total cpu time of the server (data from proc/stat)
- * </pre>
*
- * <code>uint64 total_cpu_time = 4;</code>
+ * Generated from protobuf field <code>uint64 total_cpu_time = 4;</code>
*/
private $total_cpu_time = 0;
/**
- * <pre>
* change in idle time of the server (data from proc/stat)
- * </pre>
*
- * <code>uint64 idle_cpu_time = 5;</code>
+ * Generated from protobuf field <code>uint64 idle_cpu_time = 5;</code>
*/
private $idle_cpu_time = 0;
+ /**
+ * Number of polls called inside completion queue
+ *
+ * Generated from protobuf field <code>uint64 cq_poll_count = 6;</code>
+ */
+ private $cq_poll_count = 0;
+ /**
+ * Core library stats
+ *
+ * Generated from protobuf field <code>.grpc.core.Stats core_stats = 7;</code>
+ */
+ private $core_stats = null;
public function __construct() {
\GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce();
@@ -61,11 +63,10 @@ class ServerStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* wall clock time change in seconds since last reset
- * </pre>
*
- * <code>double time_elapsed = 1;</code>
+ * Generated from protobuf field <code>double time_elapsed = 1;</code>
+ * @return float
*/
public function getTimeElapsed()
{
@@ -73,24 +74,25 @@ class ServerStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* wall clock time change in seconds since last reset
- * </pre>
*
- * <code>double time_elapsed = 1;</code>
+ * Generated from protobuf field <code>double time_elapsed = 1;</code>
+ * @param float $var
+ * @return $this
*/
public function setTimeElapsed($var)
{
GPBUtil::checkDouble($var);
$this->time_elapsed = $var;
+
+ return $this;
}
/**
- * <pre>
* change in user time (in seconds) used by the server since last reset
- * </pre>
*
- * <code>double time_user = 2;</code>
+ * Generated from protobuf field <code>double time_user = 2;</code>
+ * @return float
*/
public function getTimeUser()
{
@@ -98,25 +100,26 @@ class ServerStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* change in user time (in seconds) used by the server since last reset
- * </pre>
*
- * <code>double time_user = 2;</code>
+ * Generated from protobuf field <code>double time_user = 2;</code>
+ * @param float $var
+ * @return $this
*/
public function setTimeUser($var)
{
GPBUtil::checkDouble($var);
$this->time_user = $var;
+
+ return $this;
}
/**
- * <pre>
* change in server time (in seconds) used by the server process and all
* threads since last reset
- * </pre>
*
- * <code>double time_system = 3;</code>
+ * Generated from protobuf field <code>double time_system = 3;</code>
+ * @return float
*/
public function getTimeSystem()
{
@@ -124,25 +127,26 @@ class ServerStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* change in server time (in seconds) used by the server process and all
* threads since last reset
- * </pre>
*
- * <code>double time_system = 3;</code>
+ * Generated from protobuf field <code>double time_system = 3;</code>
+ * @param float $var
+ * @return $this
*/
public function setTimeSystem($var)
{
GPBUtil::checkDouble($var);
$this->time_system = $var;
+
+ return $this;
}
/**
- * <pre>
* change in total cpu time of the server (data from proc/stat)
- * </pre>
*
- * <code>uint64 total_cpu_time = 4;</code>
+ * Generated from protobuf field <code>uint64 total_cpu_time = 4;</code>
+ * @return int|string
*/
public function getTotalCpuTime()
{
@@ -150,24 +154,25 @@ class ServerStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* change in total cpu time of the server (data from proc/stat)
- * </pre>
*
- * <code>uint64 total_cpu_time = 4;</code>
+ * Generated from protobuf field <code>uint64 total_cpu_time = 4;</code>
+ * @param int|string $var
+ * @return $this
*/
public function setTotalCpuTime($var)
{
GPBUtil::checkUint64($var);
$this->total_cpu_time = $var;
+
+ return $this;
}
/**
- * <pre>
* change in idle time of the server (data from proc/stat)
- * </pre>
*
- * <code>uint64 idle_cpu_time = 5;</code>
+ * Generated from protobuf field <code>uint64 idle_cpu_time = 5;</code>
+ * @return int|string
*/
public function getIdleCpuTime()
{
@@ -175,16 +180,70 @@ class ServerStats extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* change in idle time of the server (data from proc/stat)
- * </pre>
*
- * <code>uint64 idle_cpu_time = 5;</code>
+ * Generated from protobuf field <code>uint64 idle_cpu_time = 5;</code>
+ * @param int|string $var
+ * @return $this
*/
public function setIdleCpuTime($var)
{
GPBUtil::checkUint64($var);
$this->idle_cpu_time = $var;
+
+ return $this;
+ }
+
+ /**
+ * Number of polls called inside completion queue
+ *
+ * Generated from protobuf field <code>uint64 cq_poll_count = 6;</code>
+ * @return int|string
+ */
+ public function getCqPollCount()
+ {
+ return $this->cq_poll_count;
+ }
+
+ /**
+ * Number of polls called inside completion queue
+ *
+ * Generated from protobuf field <code>uint64 cq_poll_count = 6;</code>
+ * @param int|string $var
+ * @return $this
+ */
+ public function setCqPollCount($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->cq_poll_count = $var;
+
+ return $this;
+ }
+
+ /**
+ * Core library stats
+ *
+ * Generated from protobuf field <code>.grpc.core.Stats core_stats = 7;</code>
+ * @return \Grpc\Core\Stats
+ */
+ public function getCoreStats()
+ {
+ return $this->core_stats;
+ }
+
+ /**
+ * Core library stats
+ *
+ * Generated from protobuf field <code>.grpc.core.Stats core_stats = 7;</code>
+ * @param \Grpc\Core\Stats $var
+ * @return $this
+ */
+ public function setCoreStats($var)
+ {
+ GPBUtil::checkMessage($var, \Grpc\Core\Stats::class);
+ $this->core_stats = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php
index d293f03fbd..04f2ca7c4a 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php
@@ -9,28 +9,24 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.ServerStatus</code>
+ * Generated from protobuf message <code>grpc.testing.ServerStatus</code>
*/
class ServerStatus extends \Google\Protobuf\Internal\Message
{
/**
- * <code>.grpc.testing.ServerStats stats = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerStats stats = 1;</code>
*/
private $stats = null;
/**
- * <pre>
* the port bound by the server
- * </pre>
*
- * <code>int32 port = 2;</code>
+ * Generated from protobuf field <code>int32 port = 2;</code>
*/
private $port = 0;
/**
- * <pre>
* Number of cores available to the server
- * </pre>
*
- * <code>int32 cores = 3;</code>
+ * Generated from protobuf field <code>int32 cores = 3;</code>
*/
private $cores = 0;
@@ -40,7 +36,8 @@ class ServerStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ServerStats stats = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerStats stats = 1;</code>
+ * @return \Grpc\Testing\ServerStats
*/
public function getStats()
{
@@ -48,20 +45,23 @@ class ServerStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <code>.grpc.testing.ServerStats stats = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.ServerStats stats = 1;</code>
+ * @param \Grpc\Testing\ServerStats $var
+ * @return $this
*/
- public function setStats(&$var)
+ public function setStats($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\ServerStats::class);
$this->stats = $var;
+
+ return $this;
}
/**
- * <pre>
* the port bound by the server
- * </pre>
*
- * <code>int32 port = 2;</code>
+ * Generated from protobuf field <code>int32 port = 2;</code>
+ * @return int
*/
public function getPort()
{
@@ -69,24 +69,25 @@ class ServerStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* the port bound by the server
- * </pre>
*
- * <code>int32 port = 2;</code>
+ * Generated from protobuf field <code>int32 port = 2;</code>
+ * @param int $var
+ * @return $this
*/
public function setPort($var)
{
GPBUtil::checkInt32($var);
$this->port = $var;
+
+ return $this;
}
/**
- * <pre>
* Number of cores available to the server
- * </pre>
*
- * <code>int32 cores = 3;</code>
+ * Generated from protobuf field <code>int32 cores = 3;</code>
+ * @return int
*/
public function getCores()
{
@@ -94,16 +95,18 @@ class ServerStatus extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Number of cores available to the server
- * </pre>
*
- * <code>int32 cores = 3;</code>
+ * Generated from protobuf field <code>int32 cores = 3;</code>
+ * @param int $var
+ * @return $this
*/
public function setCores($var)
{
GPBUtil::checkInt32($var);
$this->cores = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php
index 605c83c3f7..4110e91c18 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php
@@ -5,28 +5,26 @@
namespace Grpc\Testing;
/**
- * Protobuf enum <code>grpc.testing.ServerType</code>
+ * Protobuf enum <code>Grpc\Testing\ServerType</code>
*/
class ServerType
{
/**
- * <code>SYNC_SERVER = 0;</code>
+ * Generated from protobuf enum <code>SYNC_SERVER = 0;</code>
*/
const SYNC_SERVER = 0;
/**
- * <code>ASYNC_SERVER = 1;</code>
+ * Generated from protobuf enum <code>ASYNC_SERVER = 1;</code>
*/
const ASYNC_SERVER = 1;
/**
- * <code>ASYNC_GENERIC_SERVER = 2;</code>
+ * Generated from protobuf enum <code>ASYNC_GENERIC_SERVER = 2;</code>
*/
const ASYNC_GENERIC_SERVER = 2;
/**
- * <pre>
* used for some language-specific variants
- * </pre>
*
- * <code>OTHER_SERVER = 3;</code>
+ * Generated from protobuf enum <code>OTHER_SERVER = 3;</code>
*/
const OTHER_SERVER = 3;
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php
index 29834a3be7..507db598f0 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php
@@ -9,16 +9,16 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.SimpleProtoParams</code>
+ * Generated from protobuf message <code>grpc.testing.SimpleProtoParams</code>
*/
class SimpleProtoParams extends \Google\Protobuf\Internal\Message
{
/**
- * <code>int32 req_size = 1;</code>
+ * Generated from protobuf field <code>int32 req_size = 1;</code>
*/
private $req_size = 0;
/**
- * <code>int32 resp_size = 2;</code>
+ * Generated from protobuf field <code>int32 resp_size = 2;</code>
*/
private $resp_size = 0;
@@ -28,7 +28,8 @@ class SimpleProtoParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 req_size = 1;</code>
+ * Generated from protobuf field <code>int32 req_size = 1;</code>
+ * @return int
*/
public function getReqSize()
{
@@ -36,16 +37,21 @@ class SimpleProtoParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 req_size = 1;</code>
+ * Generated from protobuf field <code>int32 req_size = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setReqSize($var)
{
GPBUtil::checkInt32($var);
$this->req_size = $var;
+
+ return $this;
}
/**
- * <code>int32 resp_size = 2;</code>
+ * Generated from protobuf field <code>int32 resp_size = 2;</code>
+ * @return int
*/
public function getRespSize()
{
@@ -53,12 +59,16 @@ class SimpleProtoParams extends \Google\Protobuf\Internal\Message
}
/**
- * <code>int32 resp_size = 2;</code>
+ * Generated from protobuf field <code>int32 resp_size = 2;</code>
+ * @param int $var
+ * @return $this
*/
public function setRespSize($var)
{
GPBUtil::checkInt32($var);
$this->resp_size = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php
index f84c95319f..e0c2d2d94c 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php
@@ -9,81 +9,63 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Unary request.
- * </pre>
*
- * Protobuf type <code>grpc.testing.SimpleRequest</code>
+ * Generated from protobuf message <code>grpc.testing.SimpleRequest</code>
*/
class SimpleRequest extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* Desired payload type in the response from the server.
* If response_type is RANDOM, server randomly chooses one from other formats.
- * </pre>
*
- * <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType response_type = 1;</code>
*/
private $response_type = 0;
/**
- * <pre>
* Desired payload size in the response from the server.
- * </pre>
*
- * <code>int32 response_size = 2;</code>
+ * Generated from protobuf field <code>int32 response_size = 2;</code>
*/
private $response_size = 0;
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 3;</code>
*/
private $payload = null;
/**
- * <pre>
* Whether SimpleResponse should include username.
- * </pre>
*
- * <code>bool fill_username = 4;</code>
+ * Generated from protobuf field <code>bool fill_username = 4;</code>
*/
private $fill_username = false;
/**
- * <pre>
* Whether SimpleResponse should include OAuth scope.
- * </pre>
*
- * <code>bool fill_oauth_scope = 5;</code>
+ * Generated from protobuf field <code>bool fill_oauth_scope = 5;</code>
*/
private $fill_oauth_scope = false;
/**
- * <pre>
* Whether to request the server to compress the response. This field is
* "nullable" in order to interoperate seamlessly with clients not able to
* implement the full compression tests by introspecting the call to verify
* the response's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue response_compressed = 6;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue response_compressed = 6;</code>
*/
private $response_compressed = null;
/**
- * <pre>
* Whether server should return a given status
- * </pre>
*
- * <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * Generated from protobuf field <code>.grpc.testing.EchoStatus response_status = 7;</code>
*/
private $response_status = null;
/**
- * <pre>
* Whether the server should expect this request to be compressed.
- * </pre>
*
- * <code>.grpc.testing.BoolValue expect_compressed = 8;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue expect_compressed = 8;</code>
*/
private $expect_compressed = null;
@@ -93,13 +75,12 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* Desired payload type in the response from the server.
* If response_type is RANDOM, server randomly chooses one from other formats.
- * </pre>
*
- * <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * @return int
*/
public function getResponseType()
{
@@ -107,26 +88,27 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* Desired payload type in the response from the server.
* If response_type is RANDOM, server randomly chooses one from other formats.
- * </pre>
*
- * <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setResponseType($var)
{
GPBUtil::checkEnum($var, \Grpc\Testing\PayloadType::class);
$this->response_type = $var;
+
+ return $this;
}
/**
- * <pre>
* Desired payload size in the response from the server.
- * </pre>
*
- * <code>int32 response_size = 2;</code>
+ * Generated from protobuf field <code>int32 response_size = 2;</code>
+ * @return int
*/
public function getResponseSize()
{
@@ -134,24 +116,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Desired payload size in the response from the server.
- * </pre>
*
- * <code>int32 response_size = 2;</code>
+ * Generated from protobuf field <code>int32 response_size = 2;</code>
+ * @param int $var
+ * @return $this
*/
public function setResponseSize($var)
{
GPBUtil::checkInt32($var);
$this->response_size = $var;
+
+ return $this;
}
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 3;</code>
+ * @return \Grpc\Testing\Payload
*/
public function getPayload()
{
@@ -159,24 +142,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 3;</code>
+ * @param \Grpc\Testing\Payload $var
+ * @return $this
*/
- public function setPayload(&$var)
+ public function setPayload($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class);
$this->payload = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether SimpleResponse should include username.
- * </pre>
*
- * <code>bool fill_username = 4;</code>
+ * Generated from protobuf field <code>bool fill_username = 4;</code>
+ * @return bool
*/
public function getFillUsername()
{
@@ -184,24 +168,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether SimpleResponse should include username.
- * </pre>
*
- * <code>bool fill_username = 4;</code>
+ * Generated from protobuf field <code>bool fill_username = 4;</code>
+ * @param bool $var
+ * @return $this
*/
public function setFillUsername($var)
{
GPBUtil::checkBool($var);
$this->fill_username = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether SimpleResponse should include OAuth scope.
- * </pre>
*
- * <code>bool fill_oauth_scope = 5;</code>
+ * Generated from protobuf field <code>bool fill_oauth_scope = 5;</code>
+ * @return bool
*/
public function getFillOauthScope()
{
@@ -209,27 +194,28 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether SimpleResponse should include OAuth scope.
- * </pre>
*
- * <code>bool fill_oauth_scope = 5;</code>
+ * Generated from protobuf field <code>bool fill_oauth_scope = 5;</code>
+ * @param bool $var
+ * @return $this
*/
public function setFillOauthScope($var)
{
GPBUtil::checkBool($var);
$this->fill_oauth_scope = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether to request the server to compress the response. This field is
* "nullable" in order to interoperate seamlessly with clients not able to
* implement the full compression tests by introspecting the call to verify
* the response's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue response_compressed = 6;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue response_compressed = 6;</code>
+ * @return \Grpc\Testing\BoolValue
*/
public function getResponseCompressed()
{
@@ -237,27 +223,28 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether to request the server to compress the response. This field is
* "nullable" in order to interoperate seamlessly with clients not able to
* implement the full compression tests by introspecting the call to verify
* the response's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue response_compressed = 6;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue response_compressed = 6;</code>
+ * @param \Grpc\Testing\BoolValue $var
+ * @return $this
*/
- public function setResponseCompressed(&$var)
+ public function setResponseCompressed($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class);
$this->response_compressed = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether server should return a given status
- * </pre>
*
- * <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * Generated from protobuf field <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * @return \Grpc\Testing\EchoStatus
*/
public function getResponseStatus()
{
@@ -265,24 +252,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether server should return a given status
- * </pre>
*
- * <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * Generated from protobuf field <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * @param \Grpc\Testing\EchoStatus $var
+ * @return $this
*/
- public function setResponseStatus(&$var)
+ public function setResponseStatus($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\EchoStatus::class);
$this->response_status = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether the server should expect this request to be compressed.
- * </pre>
*
- * <code>.grpc.testing.BoolValue expect_compressed = 8;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue expect_compressed = 8;</code>
+ * @return \Grpc\Testing\BoolValue
*/
public function getExpectCompressed()
{
@@ -290,16 +278,18 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether the server should expect this request to be compressed.
- * </pre>
*
- * <code>.grpc.testing.BoolValue expect_compressed = 8;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue expect_compressed = 8;</code>
+ * @param \Grpc\Testing\BoolValue $var
+ * @return $this
*/
- public function setExpectCompressed(&$var)
+ public function setExpectCompressed($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class);
$this->expect_compressed = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php
index ccc628ec4c..d49f33746e 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php
@@ -9,37 +9,29 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Unary response, as configured by the request.
- * </pre>
*
- * Protobuf type <code>grpc.testing.SimpleResponse</code>
+ * Generated from protobuf message <code>grpc.testing.SimpleResponse</code>
*/
class SimpleResponse extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Payload to increase message size.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
*/
private $payload = null;
/**
- * <pre>
* The user the request came from, for verifying authentication was
* successful when the client expected it.
- * </pre>
*
- * <code>string username = 2;</code>
+ * Generated from protobuf field <code>string username = 2;</code>
*/
private $username = '';
/**
- * <pre>
* OAuth scope.
- * </pre>
*
- * <code>string oauth_scope = 3;</code>
+ * Generated from protobuf field <code>string oauth_scope = 3;</code>
*/
private $oauth_scope = '';
@@ -49,11 +41,10 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Payload to increase message size.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
+ * @return \Grpc\Testing\Payload
*/
public function getPayload()
{
@@ -61,25 +52,26 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Payload to increase message size.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
+ * @param \Grpc\Testing\Payload $var
+ * @return $this
*/
- public function setPayload(&$var)
+ public function setPayload($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class);
$this->payload = $var;
+
+ return $this;
}
/**
- * <pre>
* The user the request came from, for verifying authentication was
* successful when the client expected it.
- * </pre>
*
- * <code>string username = 2;</code>
+ * Generated from protobuf field <code>string username = 2;</code>
+ * @return string
*/
public function getUsername()
{
@@ -87,25 +79,26 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* The user the request came from, for verifying authentication was
* successful when the client expected it.
- * </pre>
*
- * <code>string username = 2;</code>
+ * Generated from protobuf field <code>string username = 2;</code>
+ * @param string $var
+ * @return $this
*/
public function setUsername($var)
{
GPBUtil::checkString($var, True);
$this->username = $var;
+
+ return $this;
}
/**
- * <pre>
* OAuth scope.
- * </pre>
*
- * <code>string oauth_scope = 3;</code>
+ * Generated from protobuf field <code>string oauth_scope = 3;</code>
+ * @return string
*/
public function getOauthScope()
{
@@ -113,16 +106,18 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* OAuth scope.
- * </pre>
*
- * <code>string oauth_scope = 3;</code>
+ * Generated from protobuf field <code>string oauth_scope = 3;</code>
+ * @param string $var
+ * @return $this
*/
public function setOauthScope($var)
{
GPBUtil::checkString($var, True);
$this->oauth_scope = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php
index d7bbc70779..a7460af83a 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php
@@ -9,31 +9,25 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Client-streaming request.
- * </pre>
*
- * Protobuf type <code>grpc.testing.StreamingInputCallRequest</code>
+ * Generated from protobuf message <code>grpc.testing.StreamingInputCallRequest</code>
*/
class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
*/
private $payload = null;
/**
- * <pre>
* Whether the server should expect this request to be compressed. This field
* is "nullable" in order to interoperate seamlessly with servers not able to
* implement the full compression tests by introspecting the call to verify
* the request's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue expect_compressed = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue expect_compressed = 2;</code>
*/
private $expect_compressed = null;
@@ -43,11 +37,10 @@ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
+ * @return \Grpc\Testing\Payload
*/
public function getPayload()
{
@@ -55,27 +48,28 @@ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
+ * @param \Grpc\Testing\Payload $var
+ * @return $this
*/
- public function setPayload(&$var)
+ public function setPayload($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class);
$this->payload = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether the server should expect this request to be compressed. This field
* is "nullable" in order to interoperate seamlessly with servers not able to
* implement the full compression tests by introspecting the call to verify
* the request's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue expect_compressed = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue expect_compressed = 2;</code>
+ * @return \Grpc\Testing\BoolValue
*/
public function getExpectCompressed()
{
@@ -83,19 +77,21 @@ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether the server should expect this request to be compressed. This field
* is "nullable" in order to interoperate seamlessly with servers not able to
* implement the full compression tests by introspecting the call to verify
* the request's compression status.
- * </pre>
*
- * <code>.grpc.testing.BoolValue expect_compressed = 2;</code>
+ * Generated from protobuf field <code>.grpc.testing.BoolValue expect_compressed = 2;</code>
+ * @param \Grpc\Testing\BoolValue $var
+ * @return $this
*/
- public function setExpectCompressed(&$var)
+ public function setExpectCompressed($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class);
$this->expect_compressed = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php
index fdd1d0dbf8..41f3893aa3 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php
@@ -9,20 +9,16 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Client-streaming response.
- * </pre>
*
- * Protobuf type <code>grpc.testing.StreamingInputCallResponse</code>
+ * Generated from protobuf message <code>grpc.testing.StreamingInputCallResponse</code>
*/
class StreamingInputCallResponse extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Aggregated size of payloads received from the client.
- * </pre>
*
- * <code>int32 aggregated_payload_size = 1;</code>
+ * Generated from protobuf field <code>int32 aggregated_payload_size = 1;</code>
*/
private $aggregated_payload_size = 0;
@@ -32,11 +28,10 @@ class StreamingInputCallResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Aggregated size of payloads received from the client.
- * </pre>
*
- * <code>int32 aggregated_payload_size = 1;</code>
+ * Generated from protobuf field <code>int32 aggregated_payload_size = 1;</code>
+ * @return int
*/
public function getAggregatedPayloadSize()
{
@@ -44,16 +39,18 @@ class StreamingInputCallResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Aggregated size of payloads received from the client.
- * </pre>
*
- * <code>int32 aggregated_payload_size = 1;</code>
+ * Generated from protobuf field <code>int32 aggregated_payload_size = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setAggregatedPayloadSize($var)
{
GPBUtil::checkInt32($var);
$this->aggregated_payload_size = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php
index 2aab5fadad..69d9cecffa 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php
@@ -9,48 +9,38 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Server-streaming request.
- * </pre>
*
- * Protobuf type <code>grpc.testing.StreamingOutputCallRequest</code>
+ * Generated from protobuf message <code>grpc.testing.StreamingOutputCallRequest</code>
*/
class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* Desired payload type in the response from the server.
* If response_type is RANDOM, the payload from each response in the stream
* might be of different types. This is to simulate a mixed type of payload
* stream.
- * </pre>
*
- * <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType response_type = 1;</code>
*/
private $response_type = 0;
/**
- * <pre>
* Configuration for each expected response message.
- * </pre>
*
- * <code>repeated .grpc.testing.ResponseParameters response_parameters = 2;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ResponseParameters response_parameters = 2;</code>
*/
private $response_parameters;
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 3;</code>
*/
private $payload = null;
/**
- * <pre>
* Whether server should return a given status
- * </pre>
*
- * <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * Generated from protobuf field <code>.grpc.testing.EchoStatus response_status = 7;</code>
*/
private $response_status = null;
@@ -60,15 +50,14 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* Desired payload type in the response from the server.
* If response_type is RANDOM, the payload from each response in the stream
* might be of different types. This is to simulate a mixed type of payload
* stream.
- * </pre>
*
- * <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * @return int
*/
public function getResponseType()
{
@@ -76,28 +65,29 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* DEPRECATED, don't use. To be removed shortly.
* Desired payload type in the response from the server.
* If response_type is RANDOM, the payload from each response in the stream
* might be of different types. This is to simulate a mixed type of payload
* stream.
- * </pre>
*
- * <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.PayloadType response_type = 1;</code>
+ * @param int $var
+ * @return $this
*/
public function setResponseType($var)
{
GPBUtil::checkEnum($var, \Grpc\Testing\PayloadType::class);
$this->response_type = $var;
+
+ return $this;
}
/**
- * <pre>
* Configuration for each expected response message.
- * </pre>
*
- * <code>repeated .grpc.testing.ResponseParameters response_parameters = 2;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ResponseParameters response_parameters = 2;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
*/
public function getResponseParameters()
{
@@ -105,24 +95,25 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Configuration for each expected response message.
- * </pre>
*
- * <code>repeated .grpc.testing.ResponseParameters response_parameters = 2;</code>
+ * Generated from protobuf field <code>repeated .grpc.testing.ResponseParameters response_parameters = 2;</code>
+ * @param \Grpc\Testing\ResponseParameters[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
*/
- public function setResponseParameters(&$var)
+ public function setResponseParameters($var)
{
- GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ResponseParameters::class);
- $this->response_parameters = $var;
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ResponseParameters::class);
+ $this->response_parameters = $arr;
+
+ return $this;
}
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 3;</code>
+ * @return \Grpc\Testing\Payload
*/
public function getPayload()
{
@@ -130,24 +121,25 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Optional input payload sent along with the request.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 3;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 3;</code>
+ * @param \Grpc\Testing\Payload $var
+ * @return $this
*/
- public function setPayload(&$var)
+ public function setPayload($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class);
$this->payload = $var;
+
+ return $this;
}
/**
- * <pre>
* Whether server should return a given status
- * </pre>
*
- * <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * Generated from protobuf field <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * @return \Grpc\Testing\EchoStatus
*/
public function getResponseStatus()
{
@@ -155,16 +147,18 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Whether server should return a given status
- * </pre>
*
- * <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * Generated from protobuf field <code>.grpc.testing.EchoStatus response_status = 7;</code>
+ * @param \Grpc\Testing\EchoStatus $var
+ * @return $this
*/
- public function setResponseStatus(&$var)
+ public function setResponseStatus($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\EchoStatus::class);
$this->response_status = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php
index c06c78c9d8..52315bb499 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php
@@ -9,20 +9,16 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * <pre>
* Server-streaming response, as configured by the request and parameters.
- * </pre>
*
- * Protobuf type <code>grpc.testing.StreamingOutputCallResponse</code>
+ * Generated from protobuf message <code>grpc.testing.StreamingOutputCallResponse</code>
*/
class StreamingOutputCallResponse extends \Google\Protobuf\Internal\Message
{
/**
- * <pre>
* Payload to increase response size.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
*/
private $payload = null;
@@ -32,11 +28,10 @@ class StreamingOutputCallResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Payload to increase response size.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
+ * @return \Grpc\Testing\Payload
*/
public function getPayload()
{
@@ -44,16 +39,18 @@ class StreamingOutputCallResponse extends \Google\Protobuf\Internal\Message
}
/**
- * <pre>
* Payload to increase response size.
- * </pre>
*
- * <code>.grpc.testing.Payload payload = 1;</code>
+ * Generated from protobuf field <code>.grpc.testing.Payload payload = 1;</code>
+ * @param \Grpc\Testing\Payload $var
+ * @return $this
*/
- public function setPayload(&$var)
+ public function setPayload($var)
{
GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class);
$this->payload = $var;
+
+ return $this;
}
}
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Void.php b/src/php/tests/qps/generated_code/Grpc/Testing/Void.php
index 38c100845a..623021d99b 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/Void.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/Void.php
@@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;
/**
- * Protobuf type <code>grpc.testing.Void</code>
+ * Generated from protobuf message <code>grpc.testing.Void</code>
*/
class Void extends \Google\Protobuf\Internal\Message
{
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php
index 959d839c80..98c244ff9d 100644
--- a/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php
+++ b/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php
@@ -18,17 +18,19 @@
//
// An integration test service that covers all the method signature permutations
// of unary/streaming requests/responses.
-namespace Grpc\Testing {
+namespace Grpc\Testing;
- class WorkerServiceClient extends \Grpc\BaseStub {
+/**
+ */
+class WorkerServiceClient extends \Grpc\BaseStub {
/**
* @param string $hostname hostname
* @param array $opts channel options
- * @param Grpc\Channel $channel (optional) re-use channel object
+ * @param \Grpc\Channel $channel (optional) re-use channel object
*/
public function __construct($hostname, $opts, $channel = null) {
- parent::__construct($hostname, $opts, $channel);
+ parent::__construct($hostname, $opts, $channel);
}
/**
@@ -42,9 +44,9 @@ namespace Grpc\Testing {
* @param array $options call options
*/
public function RunServer($metadata = [], $options = []) {
- return $this->_bidiRequest('/grpc.testing.WorkerService/RunServer',
- ['\Grpc\Testing\ServerStatus','decode'],
- $metadata, $options);
+ return $this->_bidiRequest('/grpc.testing.WorkerService/RunServer',
+ ['\Grpc\Testing\ServerStatus','decode'],
+ $metadata, $options);
}
/**
@@ -58,9 +60,9 @@ namespace Grpc\Testing {
* @param array $options call options
*/
public function RunClient($metadata = [], $options = []) {
- return $this->_bidiRequest('/grpc.testing.WorkerService/RunClient',
- ['\Grpc\Testing\ClientStatus','decode'],
- $metadata, $options);
+ return $this->_bidiRequest('/grpc.testing.WorkerService/RunClient',
+ ['\Grpc\Testing\ClientStatus','decode'],
+ $metadata, $options);
}
/**
@@ -71,10 +73,10 @@ namespace Grpc\Testing {
*/
public function CoreCount(\Grpc\Testing\CoreRequest $argument,
$metadata = [], $options = []) {
- return $this->_simpleRequest('/grpc.testing.WorkerService/CoreCount',
- $argument,
- ['\Grpc\Testing\CoreResponse', 'decode'],
- $metadata, $options);
+ return $this->_simpleRequest('/grpc.testing.WorkerService/CoreCount',
+ $argument,
+ ['\Grpc\Testing\CoreResponse', 'decode'],
+ $metadata, $options);
}
/**
@@ -85,12 +87,10 @@ namespace Grpc\Testing {
*/
public function QuitWorker(\Grpc\Testing\Void $argument,
$metadata = [], $options = []) {
- return $this->_simpleRequest('/grpc.testing.WorkerService/QuitWorker',
- $argument,
- ['\Grpc\Testing\Void', 'decode'],
- $metadata, $options);
+ return $this->_simpleRequest('/grpc.testing.WorkerService/QuitWorker',
+ $argument,
+ ['\Grpc\Testing\Void', 'decode'],
+ $metadata, $options);
}
- }
-
}
diff --git a/src/php/tests/qps/histogram.php b/src/php/tests/qps/histogram.php
new file mode 100644
index 0000000000..c11a67c618
--- /dev/null
+++ b/src/php/tests/qps/histogram.php
@@ -0,0 +1,93 @@
+<?php
+/*
+ *
+ * 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.
+ *
+ */
+
+// Histogram class for use in performance testing and measurement
+class Histogram {
+ private $resolution;
+ private $max_possible;
+ private $sum;
+ private $sum_of_squares;
+ private $multiplier;
+ private $count;
+ private $min_seen;
+ private $max_seen;
+ private $buckets;
+
+ private function bucket_for($value) {
+ return (int)(log($value) / log($this->multiplier));
+ }
+
+ public function __construct($resolution, $max_possible) {
+ $this->resolution = $resolution;
+ $this->max_possible = $max_possible;
+ $this->sum = 0;
+ $this->sum_of_squares = 0;
+ $this->multiplier = 1+$resolution;
+ $this->count = 0;
+ $this->min_seen = $max_possible;
+ $this->max_seen = 0;
+ $this->buckets = array_fill(0, $this->bucket_for($max_possible)+1, 0);
+ }
+
+ public function add($value) {
+ $this->sum += $value;
+ $this->sum_of_squares += $value * $value;
+ $this->count += 1;
+ if ($value < $this->min_seen) {
+ $this->min_seen = $value;
+ }
+ if ($value > $this->max_seen) {
+ $this->max_seen = $value;
+ }
+ $this->buckets[$this->bucket_for($value)] += 1;
+ }
+
+ public function minimum() {
+ return $this->min_seen;
+ }
+
+ public function maximum() {
+ return $this->max_seen;
+ }
+
+ public function sum() {
+ return $this->sum;
+ }
+
+ public function sum_of_squares() {
+ return $this->sum_of_squares;
+ }
+
+ public function count() {
+ return $this->count;
+ }
+
+ public function contents() {
+ return $this->buckets;
+ }
+
+ public function clean() {
+ $this->sum = 0;
+ $this->sum_of_squares = 0;
+ $this->count = 0;
+ $this->min_seen = $this->max_possible;
+ $this->max_seen = 0;
+ $this->buckets = array_fill(0, $this->bucket_for($this->max_possible)+1, 0);
+ }
+}
diff --git a/src/php/tests/unit_tests/CallCredentials2Test.php b/src/php/tests/unit_tests/CallCredentials2Test.php
index 0a587906fa..1c7e0c0ff6 100644
--- a/src/php/tests/unit_tests/CallCredentials2Test.php
+++ b/src/php/tests/unit_tests/CallCredentials2Test.php
@@ -147,7 +147,7 @@ class CallCredentials2Test extends PHPUnit_Framework_TestCase
$this->assertTrue($event->send_metadata);
$this->assertTrue($event->send_close);
- $this->assertTrue($event->status->code == Grpc\STATUS_UNAUTHENTICATED);
+ $this->assertTrue($event->status->code == Grpc\STATUS_UNAVAILABLE);
}
public function invalidReturnCallbackFunc($context)
@@ -179,6 +179,6 @@ class CallCredentials2Test extends PHPUnit_Framework_TestCase
$this->assertTrue($event->send_metadata);
$this->assertTrue($event->send_close);
- $this->assertTrue($event->status->code == Grpc\STATUS_UNAUTHENTICATED);
+ $this->assertTrue($event->status->code == Grpc\STATUS_UNAVAILABLE);
}
}
diff --git a/src/php/tests/unit_tests/ChannelTest.php b/src/php/tests/unit_tests/ChannelTest.php
index c375a16269..13a770caff 100644
--- a/src/php/tests/unit_tests/ChannelTest.php
+++ b/src/php/tests/unit_tests/ChannelTest.php
@@ -81,10 +81,14 @@ class ChannelTest extends PHPUnit_Framework_TestCase
{
$this->channel = new Grpc\Channel('localhost:0',
['credentials' => Grpc\ChannelCredentials::createInsecure()]);
- $time = new Grpc\Timeval(1000);
- $state = $this->channel->watchConnectivityState(1, $time);
+ $now = Grpc\Timeval::now();
+ $deadline = $now->add(new Grpc\Timeval(100*1000)); // 100ms
+ // we act as if 'CONNECTING'(=1) was the last state
+ // we saw, so the default state of 'IDLE' should be delivered instantly
+ $state = $this->channel->watchConnectivityState(1, $deadline);
$this->assertTrue($state);
- unset($time);
+ unset($now);
+ unset($deadline);
}
public function testClose()
diff --git a/src/proto/grpc/lb/v1/load_balancer.proto b/src/proto/grpc/lb/v1/load_balancer.proto
index 0a33568bd6..75c916defa 100644
--- a/src/proto/grpc/lb/v1/load_balancer.proto
+++ b/src/proto/grpc/lb/v1/load_balancer.proto
@@ -133,11 +133,8 @@ message ServerList {
// unless instructed otherwise via the client_config.
repeated Server servers = 1;
- // Indicates the amount of time that the client should consider this server
- // list as valid. It may be considered stale after waiting this interval of
- // time after receiving the list. If the interval is not positive, the
- // client can assume the list is valid until the next list is received.
- Duration expiration_interval = 3;
+ // Was google.protobuf.Duration expiration_interval.
+ reserved 3;
}
// Contains server information. When the drop field is not true, use the other
diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD
index 36d3782262..7c49fe2472 100644
--- a/src/proto/grpc/testing/BUILD
+++ b/src/proto/grpc/testing/BUILD
@@ -76,7 +76,6 @@ grpc_proto_library(
deps = [
"control_proto",
"messages_proto",
- "stats_proto",
],
)
diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto
index 2ff2e4e8a2..57592662c4 100644
--- a/src/proto/grpc/testing/control.proto
+++ b/src/proto/grpc/testing/control.proto
@@ -108,6 +108,9 @@ message ClientConfig {
// Number of messages on a stream before it gets finished/restarted
int32 messages_per_stream = 18;
+
+ // Use coalescing API when possible.
+ bool use_coalesce_api = 19;
}
message ClientStatus { ClientStats stats = 1; }
diff --git a/src/proto/grpc/testing/echo_messages.proto b/src/proto/grpc/testing/echo_messages.proto
index c5c5fdb3fc..5396a2fd39 100644
--- a/src/proto/grpc/testing/echo_messages.proto
+++ b/src/proto/grpc/testing/echo_messages.proto
@@ -45,6 +45,7 @@ message RequestParams {
bool server_die = 12; // Server should not see a request with this set.
string binary_error_details = 13;
ErrorStatus expected_error = 14;
+ int32 server_sleep_us = 15; // Amount to sleep when invoking server
}
message EchoRequest {
diff --git a/src/proto/grpc/testing/proxy-service.proto b/src/proto/grpc/testing/proxy-service.proto
index 8d0a9498c0..deaabd1365 100644
--- a/src/proto/grpc/testing/proxy-service.proto
+++ b/src/proto/grpc/testing/proxy-service.proto
@@ -15,6 +15,7 @@
syntax = "proto3";
import "src/proto/grpc/testing/control.proto";
+import "src/proto/grpc/testing/stats.proto";
package grpc.testing;
@@ -25,5 +26,6 @@ message ProxyStat {
service ProxyClientService {
rpc GetConfig(Void) returns (ClientConfig);
rpc ReportTime(stream ProxyStat) returns (Void);
+ rpc ReportHist(stream HistogramData) returns (Void);
}
diff --git a/src/proto/grpc/testing/services.proto b/src/proto/grpc/testing/services.proto
index 2e6583d99c..93c21f42d1 100644
--- a/src/proto/grpc/testing/services.proto
+++ b/src/proto/grpc/testing/services.proto
@@ -18,7 +18,6 @@ syntax = "proto3";
import "src/proto/grpc/testing/messages.proto";
import "src/proto/grpc/testing/control.proto";
-import "src/proto/grpc/testing/stats.proto";
package grpc.testing;
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index 5f28e9101f..4c2ebaeaea 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -104,8 +104,8 @@ def _get_grpc_custom_bdist(decorated_basename, target_bdist_basename):
with open(bdist_path, 'w') as bdist_file:
bdist_file.write(bdist_data)
except IOError as error:
- raise CommandError('{}\n\nCould not write grpcio bdist: {}'
- .format(traceback.format_exc(), error.message))
+ raise CommandError('{}\n\nCould not write grpcio bdist: {}'.format(
+ traceback.format_exc(), error.message))
return bdist_path
@@ -141,7 +141,8 @@ class SphinxDocumentation(setuptools.Command):
with open(glossary_filepath, 'a') as glossary_filepath:
glossary_filepath.write(API_GLOSSARY)
sphinx.main(
- ['', os.path.join('doc', 'src'), os.path.join('doc', 'build')])
+ ['', os.path.join('doc', 'src'),
+ os.path.join('doc', 'build')])
class BuildProjectMetadata(setuptools.Command):
@@ -189,10 +190,11 @@ def check_and_update_cythonization(extensions):
for source in extension.sources:
base, file_ext = os.path.splitext(source)
if file_ext == '.pyx':
- generated_pyx_source = next((base + gen_ext
- for gen_ext in ('.c', '.cpp',)
- if os.path.isfile(base + gen_ext)),
- None)
+ generated_pyx_source = next(
+ (base + gen_ext for gen_ext in (
+ '.c',
+ '.cpp',
+ ) if os.path.isfile(base + gen_ext)), None)
if generated_pyx_source:
generated_pyx_sources.append(generated_pyx_source)
else:
@@ -299,10 +301,10 @@ class Gather(setuptools.Command):
"""Command to gather project dependencies."""
description = 'gather dependencies for grpcio'
- user_options = [
- ('test', 't', 'flag indicating to gather test dependencies'),
- ('install', 'i', 'flag indicating to gather install dependencies')
- ]
+ user_options = [('test', 't',
+ 'flag indicating to gather test dependencies'),
+ ('install', 'i',
+ 'flag indicating to gather install dependencies')]
def initialize_options(self):
self.test = False
diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py
index c9f9ac27d9..79793a710e 100644
--- a/src/python/grpcio/grpc/__init__.py
+++ b/src/python/grpcio/grpc/__init__.py
@@ -35,152 +35,152 @@ class FutureCancelledError(Exception):
class Future(six.with_metaclass(abc.ABCMeta)):
"""A representation of a computation in another control flow.
- Computations represented by a Future may be yet to be begun, may be ongoing,
- or may have already completed.
- """
+ Computations represented by a Future may be yet to be begun,
+ may be ongoing, or may have already completed.
+ """
@abc.abstractmethod
def cancel(self):
"""Attempts to cancel the computation.
- This method does not block.
-
- Returns:
- bool:
- Returns True if the computation was canceled.
- Returns False under all other circumstances, for example:
- 1. computation has begun and could not be canceled.
- 2. computation has finished
- 3. computation is scheduled for execution and it is impossible to
- determine its state without blocking.
- """
+ This method does not block.
+
+ Returns:
+ bool:
+ Returns True if the computation was canceled.
+ Returns False under all other circumstances, for example:
+ 1. computation has begun and could not be canceled.
+ 2. computation has finished
+ 3. computation is scheduled for execution and it is impossible
+ to determine its state without blocking.
+ """
raise NotImplementedError()
@abc.abstractmethod
def cancelled(self):
"""Describes whether the computation was cancelled.
- This method does not block.
+ This method does not block.
- Returns:
- bool:
- Returns True if the computation was cancelled before its result became
- available.
- False under all other circumstances, for example:
- 1. computation was not cancelled.
- 2. computation's result is available.
- """
+ Returns:
+ bool:
+ Returns True if the computation was cancelled before its result became
+ available.
+ False under all other circumstances, for example:
+ 1. computation was not cancelled.
+ 2. computation's result is available.
+ """
raise NotImplementedError()
@abc.abstractmethod
def running(self):
"""Describes whether the computation is taking place.
- This method does not block.
+ This method does not block.
- Returns:
- bool:
- Returns True if the computation is scheduled for execution or currently
- executing.
- Returns False if the computation already executed or was cancelled.
- """
+ Returns:
+ bool:
+ Returns True if the computation is scheduled for execution or
+ currently executing.
+ Returns False if the computation already executed or was cancelled.
+ """
raise NotImplementedError()
@abc.abstractmethod
def done(self):
"""Describes whether the computation has taken place.
- This method does not block.
+ This method does not block.
- Returns:
- bool:
- Returns True if the computation already executed or was cancelled.
- Returns False if the computation is scheduled for execution or currently
- executing.
- This is exactly opposite of the running() method's result.
- """
+ Returns:
+ bool:
+ Returns True if the computation already executed or was cancelled.
+ Returns False if the computation is scheduled for execution or
+ currently executing.
+ This is exactly opposite of the running() method's result.
+ """
raise NotImplementedError()
@abc.abstractmethod
def result(self, timeout=None):
"""Returns the result of the computation or raises its exception.
- This method may return immediately or may block.
+ This method may return immediately or may block.
- Args:
- timeout: The length of time in seconds to wait for the computation to
- finish or be cancelled. If None, the call will block until the
- computations's termination.
+ Args:
+ timeout: The length of time in seconds to wait for the computation to
+ finish or be cancelled. If None, the call will block until the
+ computations's termination.
- Returns:
- The return value of the computation.
+ Returns:
+ The return value of the computation.
- Raises:
- FutureTimeoutError: If a timeout value is passed and the computation does
- not terminate within the allotted time.
- FutureCancelledError: If the computation was cancelled.
- Exception: If the computation raised an exception, this call will raise
- the same exception.
- """
+ Raises:
+ FutureTimeoutError: If a timeout value is passed and the computation
+ does not terminate within the allotted time.
+ FutureCancelledError: If the computation was cancelled.
+ Exception: If the computation raised an exception, this call will
+ raise the same exception.
+ """
raise NotImplementedError()
@abc.abstractmethod
def exception(self, timeout=None):
"""Return the exception raised by the computation.
- This method may return immediately or may block.
+ This method may return immediately or may block.
- Args:
- timeout: The length of time in seconds to wait for the computation to
- terminate or be cancelled. If None, the call will block until the
- computations's termination.
+ Args:
+ timeout: The length of time in seconds to wait for the computation to
+ terminate or be cancelled. If None, the call will block until the
+ computations's termination.
- Returns:
- The exception raised by the computation, or None if the computation did
- not raise an exception.
+ Returns:
+ The exception raised by the computation, or None if the computation
+ did not raise an exception.
- Raises:
- FutureTimeoutError: If a timeout value is passed and the computation does
- not terminate within the allotted time.
- FutureCancelledError: If the computation was cancelled.
- """
+ Raises:
+ FutureTimeoutError: If a timeout value is passed and the computation
+ does not terminate within the allotted time.
+ FutureCancelledError: If the computation was cancelled.
+ """
raise NotImplementedError()
@abc.abstractmethod
def traceback(self, timeout=None):
"""Access the traceback of the exception raised by the computation.
- This method may return immediately or may block.
+ This method may return immediately or may block.
- Args:
- timeout: The length of time in seconds to wait for the computation to
- terminate or be cancelled. If None, the call will block until the
- computations's termination.
+ Args:
+ timeout: The length of time in seconds to wait for the computation
+ to terminate or be cancelled. If None, the call will block until
+ the computation's termination.
- Returns:
- The traceback of the exception raised by the computation, or None if the
- computation did not raise an exception.
+ Returns:
+ The traceback of the exception raised by the computation, or None
+ if the computation did not raise an exception.
- Raises:
- FutureTimeoutError: If a timeout value is passed and the computation does
- not terminate within the allotted time.
- FutureCancelledError: If the computation was cancelled.
- """
+ Raises:
+ FutureTimeoutError: If a timeout value is passed and the computation
+ does not terminate within the allotted time.
+ FutureCancelledError: If the computation was cancelled.
+ """
raise NotImplementedError()
@abc.abstractmethod
def add_done_callback(self, fn):
"""Adds a function to be called at completion of the computation.
- The callback will be passed this Future object describing the outcome of
- the computation.
+ The callback will be passed this Future object describing the outcome
+ of the computation.
- If the computation has already completed, the callback will be called
- immediately.
+ If the computation has already completed, the callback will be called
+ immediately.
- Args:
- fn: A callable taking this Future object as its single parameter.
- """
+ Args:
+ fn: A callable taking this Future object as its single parameter.
+ """
raise NotImplementedError()
@@ -191,14 +191,14 @@ class Future(six.with_metaclass(abc.ABCMeta)):
class ChannelConnectivity(enum.Enum):
"""Mirrors grpc_connectivity_state in the gRPC Core.
- Attributes:
- IDLE: The channel is idle.
- CONNECTING: The channel is connecting.
- READY: The channel is ready to conduct RPCs.
- TRANSIENT_FAILURE: The channel has seen a failure from which it expects to
- recover.
- SHUTDOWN: The channel has seen a failure from which it cannot recover.
- """
+ Attributes:
+ IDLE: The channel is idle.
+ CONNECTING: The channel is connecting.
+ READY: The channel is ready to conduct RPCs.
+ TRANSIENT_FAILURE: The channel has seen a failure from which it expects
+ to recover.
+ SHUTDOWN: The channel has seen a failure from which it cannot recover.
+ """
IDLE = (_cygrpc.ConnectivityState.idle, 'idle')
CONNECTING = (_cygrpc.ConnectivityState.connecting, 'connecting')
READY = (_cygrpc.ConnectivityState.ready, 'ready')
@@ -250,44 +250,44 @@ class RpcContext(six.with_metaclass(abc.ABCMeta)):
def is_active(self):
"""Describes whether the RPC is active or has terminated.
- Returns:
- bool:
- True if RPC is active, False otherwise.
- """
+ Returns:
+ bool:
+ True if RPC is active, False otherwise.
+ """
raise NotImplementedError()
@abc.abstractmethod
def time_remaining(self):
"""Describes the length of allowed time remaining for the RPC.
- Returns:
- A nonnegative float indicating the length of allowed time in seconds
- remaining for the RPC to complete before it is considered to have timed
- out, or None if no deadline was specified for the RPC.
- """
+ Returns:
+ A nonnegative float indicating the length of allowed time in seconds
+ remaining for the RPC to complete before it is considered to have
+ timed out, or None if no deadline was specified for the RPC.
+ """
raise NotImplementedError()
@abc.abstractmethod
def cancel(self):
"""Cancels the RPC.
- Idempotent and has no effect if the RPC has already terminated.
- """
+ Idempotent and has no effect if the RPC has already terminated.
+ """
raise NotImplementedError()
@abc.abstractmethod
def add_callback(self, callback):
"""Registers a callback to be called on RPC termination.
- Args:
- callback: A no-parameter callable to be called on RPC termination.
+ Args:
+ callback: A no-parameter callable to be called on RPC termination.
- Returns:
- bool:
- True if the callback was added and will be called later; False if the
- callback was not added and will not be called (because the RPC
- already terminated or some other reason).
- """
+ Returns:
+ bool:
+ True if the callback was added and will be called later; False if
+ the callback was not added and will not be called (because the RPC
+ already terminated or some other reason).
+ """
raise NotImplementedError()
@@ -301,44 +301,208 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
def initial_metadata(self):
"""Accesses the initial metadata sent by the server.
- This method blocks until the value is available.
+ This method blocks until the value is available.
- Returns:
- The initial :term:`metadata`.
- """
+ Returns:
+ The initial :term:`metadata`.
+ """
raise NotImplementedError()
@abc.abstractmethod
def trailing_metadata(self):
"""Accesses the trailing metadata sent by the server.
- This method blocks until the value is available.
+ This method blocks until the value is available.
- Returns:
- The trailing :term:`metadata`.
- """
+ Returns:
+ The trailing :term:`metadata`.
+ """
raise NotImplementedError()
@abc.abstractmethod
def code(self):
"""Accesses the status code sent by the server.
- This method blocks until the value is available.
+ This method blocks until the value is available.
- Returns:
- The StatusCode value for the RPC.
- """
+ Returns:
+ The StatusCode value for the RPC.
+ """
raise NotImplementedError()
@abc.abstractmethod
def details(self):
"""Accesses the details sent by the server.
- This method blocks until the value is available.
+ This method blocks until the value is available.
- Returns:
- The details string of the RPC.
+ Returns:
+ The details string of the RPC.
+ """
+ raise NotImplementedError()
+
+
+############## Invocation-Side Interceptor Interfaces & Classes ##############
+
+
+class ClientCallDetails(six.with_metaclass(abc.ABCMeta)):
+ """Describes an RPC to be invoked.
+
+ This is an EXPERIMENTAL API.
+
+ Attributes:
+ method: The method name of the RPC.
+ timeout: An optional duration of time in seconds to allow for the RPC.
+ metadata: Optional :term:`metadata` to be transmitted to
+ the service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+ """
+
+
+class UnaryUnaryClientInterceptor(six.with_metaclass(abc.ABCMeta)):
+ """Affords intercepting unary-unary invocations.
+
+ This is an EXPERIMENTAL API.
"""
+
+ @abc.abstractmethod
+ def intercept_unary_unary(self, continuation, client_call_details, request):
+ """Intercepts a unary-unary invocation asynchronously.
+
+ Args:
+ continuation: A function that proceeds with the invocation by
+ executing the next interceptor in chain or invoking the
+ actual RPC on the underlying Channel. It is the interceptor's
+ responsibility to call it if it decides to move the RPC forward.
+ The interceptor can use
+ `response_future = continuation(client_call_details, request)`
+ to continue with the RPC. `continuation` returns an object that is
+ both a Call for the RPC and a Future. In the event of RPC
+ completion, the return Call-Future's result value will be
+ the response message of the RPC. Should the event terminate
+ with non-OK status, the returned Call-Future's exception value
+ will be an RpcError.
+ client_call_details: A ClientCallDetails object describing the
+ outgoing RPC.
+ request: The request value for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and a Future.
+ In the event of RPC completion, the return Call-Future's
+ result value will be the response message of the RPC.
+ Should the event terminate with non-OK status, the returned
+ Call-Future's exception value will be an RpcError.
+ """
+ raise NotImplementedError()
+
+
+class UnaryStreamClientInterceptor(six.with_metaclass(abc.ABCMeta)):
+ """Affords intercepting unary-stream invocations.
+
+ This is an EXPERIMENTAL API.
+ """
+
+ @abc.abstractmethod
+ def intercept_unary_stream(self, continuation, client_call_details,
+ request):
+ """Intercepts a unary-stream invocation.
+
+ Args:
+ continuation: A function that proceeds with the invocation by
+ executing the next interceptor in chain or invoking the
+ actual RPC on the underlying Channel. It is the interceptor's
+ responsibility to call it if it decides to move the RPC forward.
+ The interceptor can use
+ `response_iterator = continuation(client_call_details, request)`
+ to continue with the RPC. `continuation` returns an object that is
+ both a Call for the RPC and an iterator for response values.
+ Drawing response values from the returned Call-iterator may
+ raise RpcError indicating termination of the RPC with non-OK
+ status.
+ client_call_details: A ClientCallDetails object describing the
+ outgoing RPC.
+ request: The request value for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and an iterator of
+ response values. Drawing response values from the returned
+ Call-iterator may raise RpcError indicating termination of
+ the RPC with non-OK status.
+ """
+ raise NotImplementedError()
+
+
+class StreamUnaryClientInterceptor(six.with_metaclass(abc.ABCMeta)):
+ """Affords intercepting stream-unary invocations.
+
+ This is an EXPERIMENTAL API.
+ """
+
+ @abc.abstractmethod
+ def intercept_stream_unary(self, continuation, client_call_details,
+ request_iterator):
+ """Intercepts a stream-unary invocation asynchronously.
+
+ Args:
+ continuation: A function that proceeds with the invocation by
+ executing the next interceptor in chain or invoking the
+ actual RPC on the underlying Channel. It is the interceptor's
+ responsibility to call it if it decides to move the RPC forward.
+ The interceptor can use
+ `response_future = continuation(client_call_details,
+ request_iterator)`
+ to continue with the RPC. `continuation` returns an object that is
+ both a Call for the RPC and a Future. In the event of RPC completion,
+ the return Call-Future's result value will be the response message
+ of the RPC. Should the event terminate with non-OK status, the
+ returned Call-Future's exception value will be an RpcError.
+ client_call_details: A ClientCallDetails object describing the
+ outgoing RPC.
+ request_iterator: An iterator that yields request values for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and a Future.
+ In the event of RPC completion, the return Call-Future's
+ result value will be the response message of the RPC.
+ Should the event terminate with non-OK status, the returned
+ Call-Future's exception value will be an RpcError.
+ """
+ raise NotImplementedError()
+
+
+class StreamStreamClientInterceptor(six.with_metaclass(abc.ABCMeta)):
+ """Affords intercepting stream-stream invocations.
+
+ This is an EXPERIMENTAL API.
+ """
+
+ @abc.abstractmethod
+ def intercept_stream_stream(self, continuation, client_call_details,
+ request_iterator):
+ """Intercepts a stream-stream invocation.
+
+ continuation: A function that proceeds with the invocation by
+ executing the next interceptor in chain or invoking the
+ actual RPC on the underlying Channel. It is the interceptor's
+ responsibility to call it if it decides to move the RPC forward.
+ The interceptor can use
+ `response_iterator = continuation(client_call_details,
+ request_iterator)`
+ to continue with the RPC. `continuation` returns an object that is
+ both a Call for the RPC and an iterator for response values.
+ Drawing response values from the returned Call-iterator may
+ raise RpcError indicating termination of the RPC with non-OK
+ status.
+ client_call_details: A ClientCallDetails object describing the
+ outgoing RPC.
+ request_iterator: An iterator that yields request values for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and an iterator of
+ response values. Drawing response values from the returned
+ Call-iterator may raise RpcError indicating termination of
+ the RPC with non-OK status.
+ """
raise NotImplementedError()
@@ -348,26 +512,25 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
class ChannelCredentials(object):
"""An encapsulation of the data required to create a secure Channel.
- This class has no supported interface - it exists to define the type of its
- instances and its instances exist to be passed to other functions. For
- example, ssl_channel_credentials returns an instance, and secure_channel
- consumes an instance of this class.
- """
+ This class has no supported interface - it exists to define the type of its
+ instances and its instances exist to be passed to other functions. For
+ example, ssl_channel_credentials returns an instance of this class and
+ secure_channel requires an instance of this class.
+ """
def __init__(self, credentials):
self._credentials = credentials
class CallCredentials(object):
- """An encapsulation of the data required to assert an identity over a
- channel.
+ """An encapsulation of the data required to assert an identity over a call.
- A CallCredentials may be composed with ChannelCredentials to always assert
- identity for every call over that Channel.
+ A CallCredentials may be composed with ChannelCredentials to always assert
+ identity for every call over that Channel.
- This class has no supported interface - it exists to define the type of its
- instances and its instances exist to be passed to other functions.
- """
+ This class has no supported interface - it exists to define the type of its
+ instances and its instances exist to be passed to other functions.
+ """
def __init__(self, credentials):
self._credentials = credentials
@@ -376,23 +539,22 @@ class CallCredentials(object):
class AuthMetadataContext(six.with_metaclass(abc.ABCMeta)):
"""Provides information to call credentials metadata plugins.
- Attributes:
- service_url: A string URL of the service being called into.
- method_name: A string of the fully qualified method name being called.
- """
+ Attributes:
+ service_url: A string URL of the service being called into.
+ method_name: A string of the fully qualified method name being called.
+ """
class AuthMetadataPluginCallback(six.with_metaclass(abc.ABCMeta)):
"""Callback object received by a metadata plugin."""
def __call__(self, metadata, error):
- """Inform the gRPC runtime of the metadata to construct a
- CallCredentials.
+ """Passes to the gRPC runtime authentication metadata for an RPC.
- Args:
- metadata: The :term:`metadata` used to construct the CallCredentials.
- error: An Exception to indicate error or None to indicate success.
- """
+ Args:
+ metadata: The :term:`metadata` used to construct the CallCredentials.
+ error: An Exception to indicate error or None to indicate success.
+ """
raise NotImplementedError()
@@ -402,28 +564,43 @@ class AuthMetadataPlugin(six.with_metaclass(abc.ABCMeta)):
def __call__(self, context, callback):
"""Implements authentication by passing metadata to a callback.
- Implementations of this method must not block.
+ Implementations of this method must not block.
- Args:
- context: An AuthMetadataContext providing information on the RPC that the
- plugin is being called to authenticate.
- callback: An AuthMetadataPluginCallback to be invoked either synchronously
- or asynchronously.
- """
+ Args:
+ context: An AuthMetadataContext providing information on the RPC that
+ the plugin is being called to authenticate.
+ callback: An AuthMetadataPluginCallback to be invoked either
+ synchronously or asynchronously.
+ """
raise NotImplementedError()
class ServerCredentials(object):
"""An encapsulation of the data required to open a secure port on a Server.
- This class has no supported interface - it exists to define the type of its
- instances and its instances exist to be passed to other functions.
- """
+ This class has no supported interface - it exists to define the type of its
+ instances and its instances exist to be passed to other functions.
+ """
def __init__(self, credentials):
self._credentials = credentials
+class ServerCertificateConfiguration(object):
+ """A certificate configuration for use with an SSL-enabled Server.
+
+ Instances of this class can be returned in the certificate configuration
+ fetching callback.
+
+ This class has no supported interface -- it exists to define the
+ type of its instances and its instances exist to be passed to
+ other functions.
+ """
+
+ def __init__(self, certificate_configuration):
+ self._certificate_configuration = certificate_configuration
+
+
######################## Multi-Callable Interfaces ###########################
@@ -434,61 +611,65 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
def __call__(self, request, timeout=None, metadata=None, credentials=None):
"""Synchronously invokes the underlying RPC.
- Args:
- request: The request value for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- The response value for the RPC.
-
- Raises:
- RpcError: Indicating that the RPC terminated with non-OK status. The
- raised RpcError will also be a Call for the RPC affording the RPC's
- metadata, status code, and details.
- """
+ Args:
+ request: The request value for the RPC.
+ timeout: An optional duration of time in seconds to allow
+ for the RPC.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ The response value for the RPC.
+
+ Raises:
+ RpcError: Indicating that the RPC terminated with non-OK status. The
+ raised RpcError will also be a Call for the RPC affording the RPC's
+ metadata, status code, and details.
+ """
raise NotImplementedError()
@abc.abstractmethod
def with_call(self, request, timeout=None, metadata=None, credentials=None):
"""Synchronously invokes the underlying RPC.
- Args:
- request: The request value for the RPC.
- timeout: An optional durating of time in seconds to allow for the RPC.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- The response value for the RPC and a Call value for the RPC.
-
- Raises:
- RpcError: Indicating that the RPC terminated with non-OK status. The
- raised RpcError will also be a Call for the RPC affording the RPC's
- metadata, status code, and details.
- """
+ Args:
+ request: The request value for the RPC.
+ timeout: An optional durating of time in seconds to allow for
+ the RPC.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ The response value for the RPC and a Call value for the RPC.
+
+ Raises:
+ RpcError: Indicating that the RPC terminated with non-OK status. The
+ raised RpcError will also be a Call for the RPC affording the RPC's
+ metadata, status code, and details.
+ """
raise NotImplementedError()
@abc.abstractmethod
def future(self, request, timeout=None, metadata=None, credentials=None):
"""Asynchronously invokes the underlying RPC.
- Args:
- request: The request value for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- An object that is both a Call for the RPC and a Future. In the event of
- RPC completion, the return Call-Future's result value will be the
- response message of the RPC. Should the event terminate with non-OK
- status, the returned Call-Future's exception value will be an RpcError.
- """
+ Args:
+ request: The request value for the RPC.
+ timeout: An optional duration of time in seconds to allow for
+ the RPC.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and a Future.
+ In the event of RPC completion, the return Call-Future's result
+ value will be the response message of the RPC.
+ Should the event terminate with non-OK status,
+ the returned Call-Future's exception value will be an RpcError.
+ """
raise NotImplementedError()
@@ -499,19 +680,20 @@ class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
def __call__(self, request, timeout=None, metadata=None, credentials=None):
"""Invokes the underlying RPC.
- Args:
- request: The request value for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- If None, the timeout is considered infinite.
- metadata: An optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- An object that is both a Call for the RPC and an iterator of response
- values. Drawing response values from the returned Call-iterator may
- raise RpcError indicating termination of the RPC with non-OK status.
- """
+ Args:
+ request: The request value for the RPC.
+ timeout: An optional duration of time in seconds to allow for
+ the RPC. If None, the timeout is considered infinite.
+ metadata: An optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and an iterator of
+ response values. Drawing response values from the returned
+ Call-iterator may raise RpcError indicating termination of the
+ RPC with non-OK status.
+ """
raise NotImplementedError()
@@ -526,22 +708,23 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
credentials=None):
"""Synchronously invokes the underlying RPC.
- Args:
- request_iterator: An iterator that yields request values for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- If None, the timeout is considered infinite.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- The response value for the RPC.
-
- Raises:
- RpcError: Indicating that the RPC terminated with non-OK status. The
- raised RpcError will also implement grpc.Call, affording methods
- such as metadata, code, and details.
- """
+ Args:
+ request_iterator: An iterator that yields request values for
+ the RPC.
+ timeout: An optional duration of time in seconds to allow for
+ the RPC. If None, the timeout is considered infinite.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ The response value for the RPC.
+
+ Raises:
+ RpcError: Indicating that the RPC terminated with non-OK status. The
+ raised RpcError will also implement grpc.Call, affording methods
+ such as metadata, code, and details.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -552,22 +735,23 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
credentials=None):
"""Synchronously invokes the underlying RPC on the client.
- Args:
- request_iterator: An iterator that yields request values for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- If None, the timeout is considered infinite.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- The response value for the RPC and a Call object for the RPC.
-
- Raises:
- RpcError: Indicating that the RPC terminated with non-OK status. The
- raised RpcError will also be a Call for the RPC affording the RPC's
- metadata, status code, and details.
- """
+ Args:
+ request_iterator: An iterator that yields request values for
+ the RPC.
+ timeout: An optional duration of time in seconds to allow for
+ the RPC. If None, the timeout is considered infinite.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ The response value for the RPC and a Call object for the RPC.
+
+ Raises:
+ RpcError: Indicating that the RPC terminated with non-OK status. The
+ raised RpcError will also be a Call for the RPC affording the RPC's
+ metadata, status code, and details.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -578,20 +762,21 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
credentials=None):
"""Asynchronously invokes the underlying RPC on the client.
- Args:
- request_iterator: An iterator that yields request values for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- If None, the timeout is considered infinite.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- An object that is both a Call for the RPC and a Future. In the event of
- RPC completion, the return Call-Future's result value will be the
- response message of the RPC. Should the event terminate with non-OK
- status, the returned Call-Future's exception value will be an RpcError.
- """
+ Args:
+ request_iterator: An iterator that yields request values for the RPC.
+ timeout: An optional duration of time in seconds to allow for
+ the RPC. If None, the timeout is considered infinite.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and a Future.
+ In the event of RPC completion, the return Call-Future's result value
+ will be the response message of the RPC. Should the event terminate
+ with non-OK status, the returned Call-Future's exception value will
+ be an RpcError.
+ """
raise NotImplementedError()
@@ -606,19 +791,20 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
credentials=None):
"""Invokes the underlying RPC on the client.
- Args:
- request_iterator: An iterator that yields request values for the RPC.
- timeout: An optional duration of time in seconds to allow for the RPC.
- if not specified the timeout is considered infinite.
- metadata: Optional :term:`metadata` to be transmitted to the
- service-side of the RPC.
- credentials: An optional CallCredentials for the RPC.
-
- Returns:
- An object that is both a Call for the RPC and an iterator of response
- values. Drawing response values from the returned Call-iterator may
- raise RpcError indicating termination of the RPC with non-OK status.
- """
+ Args:
+ request_iterator: An iterator that yields request values for the RPC.
+ timeout: An optional duration of time in seconds to allow for
+ the RPC. If not specified, the timeout is considered infinite.
+ metadata: Optional :term:`metadata` to be transmitted to the
+ service-side of the RPC.
+ credentials: An optional CallCredentials for the RPC.
+
+ Returns:
+ An object that is both a Call for the RPC and an iterator of
+ response values. Drawing response values from the returned
+ Call-iterator may raise RpcError indicating termination of the
+ RPC with non-OK status.
+ """
raise NotImplementedError()
@@ -632,31 +818,31 @@ class Channel(six.with_metaclass(abc.ABCMeta)):
def subscribe(self, callback, try_to_connect=False):
"""Subscribe to this Channel's connectivity state machine.
- A Channel may be in any of the states described by ChannelConnectivity.
- This method allows application to monitor the state transitions.
- The typical use case is to debug or gain better visibility into gRPC
- runtime's state.
-
- Args:
- callback: A callable to be invoked with ChannelConnectivity argument.
- ChannelConnectivity describes current state of the channel.
- The callable will be invoked immediately upon subscription and again for
- every change to ChannelConnectivity until it is unsubscribed or this
- Channel object goes out of scope.
- try_to_connect: A boolean indicating whether or not this Channel should
- attempt to connect immediately. If set to False, gRPC runtime decides
- when to connect.
- """
+ A Channel may be in any of the states described by ChannelConnectivity.
+ This method allows application to monitor the state transitions.
+ The typical use case is to debug or gain better visibility into gRPC
+ runtime's state.
+
+ Args:
+ callback: A callable to be invoked with ChannelConnectivity argument.
+ ChannelConnectivity describes current state of the channel.
+ The callable will be invoked immediately upon subscription
+ and again for every change to ChannelConnectivity until it
+ is unsubscribed or this Channel object goes out of scope.
+ try_to_connect: A boolean indicating whether or not this Channel
+ should attempt to connect immediately. If set to False, gRPC
+ runtime decides when to connect.
+ """
raise NotImplementedError()
@abc.abstractmethod
def unsubscribe(self, callback):
"""Unsubscribes a subscribed callback from this Channel's connectivity.
- Args:
- callback: A callable previously registered with this Channel from having
- been passed to its "subscribe" method.
- """
+ Args:
+ callback: A callable previously registered with this Channel from
+ having been passed to its "subscribe" method.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -666,16 +852,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)):
response_deserializer=None):
"""Creates a UnaryUnaryMultiCallable for a unary-unary method.
- Args:
- method: The name of the RPC method.
- request_serializer: Optional behaviour for serializing the request
- message. Request goes unserialized in case None is passed.
- response_deserializer: Optional behaviour for deserializing the response
- message. Response goes undeserialized in case None is passed.
-
- Returns:
- A UnaryUnaryMultiCallable value for the named unary-unary method.
- """
+ Args:
+ method: The name of the RPC method.
+ request_serializer: Optional behaviour for serializing the request
+ message. Request goes unserialized in case None is passed.
+ response_deserializer: Optional behaviour for deserializing the
+ response message. Response goes undeserialized in case None
+ is passed.
+
+ Returns:
+ A UnaryUnaryMultiCallable value for the named unary-unary method.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -685,16 +872,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)):
response_deserializer=None):
"""Creates a UnaryStreamMultiCallable for a unary-stream method.
- Args:
- method: The name of the RPC method.
- request_serializer: Optional behaviour for serializing the request
- message. Request goes unserialized in case None is passed.
- response_deserializer: Optional behaviour for deserializing the response
- message. Response goes undeserialized in case None is passed.
-
- Returns:
- A UnaryStreamMultiCallable value for the name unary-stream method.
- """
+ Args:
+ method: The name of the RPC method.
+ request_serializer: Optional behaviour for serializing the request
+ message. Request goes unserialized in case None is passed.
+ response_deserializer: Optional behaviour for deserializing the
+ response message. Response goes undeserialized in case None is
+ passed.
+
+ Returns:
+ A UnaryStreamMultiCallable value for the name unary-stream method.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -704,16 +892,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)):
response_deserializer=None):
"""Creates a StreamUnaryMultiCallable for a stream-unary method.
- Args:
- method: The name of the RPC method.
- request_serializer: Optional behaviour for serializing the request
- message. Request goes unserialized in case None is passed.
- response_deserializer: Optional behaviour for deserializing the response
- message. Response goes undeserialized in case None is passed.
-
- Returns:
- A StreamUnaryMultiCallable value for the named stream-unary method.
- """
+ Args:
+ method: The name of the RPC method.
+ request_serializer: Optional behaviour for serializing the request
+ message. Request goes unserialized in case None is passed.
+ response_deserializer: Optional behaviour for deserializing the
+ response message. Response goes undeserialized in case None is
+ passed.
+
+ Returns:
+ A StreamUnaryMultiCallable value for the named stream-unary method.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -723,16 +912,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)):
response_deserializer=None):
"""Creates a StreamStreamMultiCallable for a stream-stream method.
- Args:
- method: The name of the RPC method.
- request_serializer: Optional behaviour for serializing the request
- message. Request goes unserialized in case None is passed.
- response_deserializer: Optional behaviour for deserializing the response
- message. Response goes undeserialized in case None is passed.
-
- Returns:
- A StreamStreamMultiCallable value for the named stream-stream method.
- """
+ Args:
+ method: The name of the RPC method.
+ request_serializer: Optional behaviour for serializing the request
+ message. Request goes unserialized in case None is passed.
+ response_deserializer: Optional behaviour for deserializing the
+ response message. Response goes undeserialized in case None
+ is passed.
+
+ Returns:
+ A StreamStreamMultiCallable value for the named stream-stream method.
+ """
raise NotImplementedError()
@@ -746,103 +936,123 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
def invocation_metadata(self):
"""Accesses the metadata from the sent by the client.
- Returns:
- The invocation :term:`metadata`.
- """
+ Returns:
+ The invocation :term:`metadata`.
+ """
raise NotImplementedError()
@abc.abstractmethod
def peer(self):
"""Identifies the peer that invoked the RPC being serviced.
- Returns:
- A string identifying the peer that invoked the RPC being serviced.
- The string format is determined by gRPC runtime.
- """
+ Returns:
+ A string identifying the peer that invoked the RPC being serviced.
+ The string format is determined by gRPC runtime.
+ """
raise NotImplementedError()
@abc.abstractmethod
def peer_identities(self):
"""Gets one or more peer identity(s).
- Equivalent to
- servicer_context.auth_context().get(
- servicer_context.peer_identity_key())
+ Equivalent to
+ servicer_context.auth_context().get(
+ servicer_context.peer_identity_key())
- Returns:
- An iterable of the identities, or None if the call is not authenticated.
- Each identity is returned as a raw bytes type.
- """
+ Returns:
+ An iterable of the identities, or None if the call is not
+ authenticated. Each identity is returned as a raw bytes type.
+ """
raise NotImplementedError()
@abc.abstractmethod
def peer_identity_key(self):
"""The auth property used to identify the peer.
- For example, "x509_common_name" or "x509_subject_alternative_name" are
- used to identify an SSL peer.
+ For example, "x509_common_name" or "x509_subject_alternative_name" are
+ used to identify an SSL peer.
- Returns:
- The auth property (string) that indicates the
- peer identity, or None if the call is not authenticated.
- """
+ Returns:
+ The auth property (string) that indicates the
+ peer identity, or None if the call is not authenticated.
+ """
raise NotImplementedError()
@abc.abstractmethod
def auth_context(self):
"""Gets the auth context for the call.
- Returns:
- A map of strings to an iterable of bytes for each auth property.
- """
+ Returns:
+ A map of strings to an iterable of bytes for each auth property.
+ """
raise NotImplementedError()
@abc.abstractmethod
def send_initial_metadata(self, initial_metadata):
"""Sends the initial metadata value to the client.
- This method need not be called by implementations if they have no
- metadata to add to what the gRPC runtime will transmit.
+ This method need not be called by implementations if they have no
+ metadata to add to what the gRPC runtime will transmit.
- Args:
- initial_metadata: The initial :term:`metadata`.
- """
+ Args:
+ initial_metadata: The initial :term:`metadata`.
+ """
raise NotImplementedError()
@abc.abstractmethod
def set_trailing_metadata(self, trailing_metadata):
"""Sends the trailing metadata for the RPC.
- This method need not be called by implementations if they have no
- metadata to add to what the gRPC runtime will transmit.
+ This method need not be called by implementations if they have no
+ metadata to add to what the gRPC runtime will transmit.
- Args:
- trailing_metadata: The trailing :term:`metadata`.
- """
+ Args:
+ trailing_metadata: The trailing :term:`metadata`.
+ """
+ raise NotImplementedError()
+
+ @abc.abstractmethod
+ def abort(self, code, details):
+ """Raises an exception to terminate the RPC with a non-OK status.
+
+ The code and details passed as arguments will supercede any existing
+ ones.
+
+ Args:
+ code: A StatusCode object to be sent to the client.
+ It must not be StatusCode.OK.
+ details: An ASCII-encodable string to be sent to the client upon
+ termination of the RPC.
+
+ Raises:
+ Exception: An exception is always raised to signal the abortion the
+ RPC to the gRPC runtime.
+ """
raise NotImplementedError()
@abc.abstractmethod
def set_code(self, code):
"""Sets the value to be used as status code upon RPC completion.
- This method need not be called by method implementations if they wish the
- gRPC runtime to determine the status code of the RPC.
+ This method need not be called by method implementations if they wish
+ the gRPC runtime to determine the status code of the RPC.
- Args:
- code: A StatusCode object to be sent to the client.
- """
+ Args:
+ code: A StatusCode object to be sent to the client.
+ """
raise NotImplementedError()
@abc.abstractmethod
def set_details(self, details):
"""Sets the value to be used as detail string upon RPC completion.
- This method need not be called by method implementations if they have no
- details to transmit.
+ This method need not be called by method implementations if they have
+ no details to transmit.
- Args:
- details: An arbitrary string to be sent to the client upon completion.
- """
+ Args:
+ details: An ASCII-encodable string to be sent to the client upon
+ termination of the RPC.
+ """
raise NotImplementedError()
@@ -852,44 +1062,45 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
class RpcMethodHandler(six.with_metaclass(abc.ABCMeta)):
"""An implementation of a single RPC method.
- Attributes:
- request_streaming: Whether the RPC supports exactly one request message or
- any arbitrary number of request messages.
- response_streaming: Whether the RPC supports exactly one response message or
- any arbitrary number of response messages.
- request_deserializer: A callable behavior that accepts a byte string and
- returns an object suitable to be passed to this object's business logic,
- or None to indicate that this object's business logic should be passed the
- raw request bytes.
- response_serializer: A callable behavior that accepts an object produced by
- this object's business logic and returns a byte string, or None to
- indicate that the byte strings produced by this object's business logic
- should be transmitted on the wire as they are.
- unary_unary: This object's application-specific business logic as a callable
- value that takes a request value and a ServicerContext object and returns
- a response value. Only non-None if both request_streaming and
- response_streaming are False.
- unary_stream: This object's application-specific business logic as a
- callable value that takes a request value and a ServicerContext object and
- returns an iterator of response values. Only non-None if request_streaming
- is False and response_streaming is True.
- stream_unary: This object's application-specific business logic as a
- callable value that takes an iterator of request values and a
- ServicerContext object and returns a response value. Only non-None if
- request_streaming is True and response_streaming is False.
- stream_stream: This object's application-specific business logic as a
- callable value that takes an iterator of request values and a
- ServicerContext object and returns an iterator of response values. Only
- non-None if request_streaming and response_streaming are both True.
- """
+ Attributes:
+ request_streaming: Whether the RPC supports exactly one request message
+ or any arbitrary number of request messages.
+ response_streaming: Whether the RPC supports exactly one response message
+ or any arbitrary number of response messages.
+ request_deserializer: A callable behavior that accepts a byte string and
+ returns an object suitable to be passed to this object's business
+ logic, or None to indicate that this object's business logic should be
+ passed the raw request bytes.
+ response_serializer: A callable behavior that accepts an object produced
+ by this object's business logic and returns a byte string, or None to
+ indicate that the byte strings produced by this object's business logic
+ should be transmitted on the wire as they are.
+ unary_unary: This object's application-specific business logic as a
+ callable value that takes a request value and a ServicerContext object
+ and returns a response value. Only non-None if both request_streaming
+ and response_streaming are False.
+ unary_stream: This object's application-specific business logic as a
+ callable value that takes a request value and a ServicerContext object
+ and returns an iterator of response values. Only non-None if
+ request_streaming is False and response_streaming is True.
+ stream_unary: This object's application-specific business logic as a
+ callable value that takes an iterator of request values and a
+ ServicerContext object and returns a response value. Only non-None if
+ request_streaming is True and response_streaming is False.
+ stream_stream: This object's application-specific business logic as a
+ callable value that takes an iterator of request values and a
+ ServicerContext object and returns an iterator of response values.
+ Only non-None if request_streaming and response_streaming are both
+ True.
+ """
class HandlerCallDetails(six.with_metaclass(abc.ABCMeta)):
"""Describes an RPC that has just arrived for service.
- Attributes:
- method: The method name of the RPC.
- invocation_metadata: The :term:`metadata` sent by the client.
- """
+ Attributes:
+ method: The method name of the RPC.
+ invocation_metadata: The :term:`metadata` sent by the client.
+ """
class GenericRpcHandler(six.with_metaclass(abc.ABCMeta)):
@@ -899,33 +1110,61 @@ class GenericRpcHandler(six.with_metaclass(abc.ABCMeta)):
def service(self, handler_call_details):
"""Returns the handler for servicing the RPC.
- Args:
- handler_call_details: A HandlerCallDetails describing the RPC.
+ Args:
+ handler_call_details: A HandlerCallDetails describing the RPC.
- Returns:
- An RpcMethodHandler with which the RPC may be serviced if the
- implementation chooses to service this RPC, or None otherwise.
- """
+ Returns:
+ An RpcMethodHandler with which the RPC may be serviced if the
+ implementation chooses to service this RPC, or None otherwise.
+ """
raise NotImplementedError()
class ServiceRpcHandler(six.with_metaclass(abc.ABCMeta, GenericRpcHandler)):
"""An implementation of RPC methods belonging to a service.
- A service handles RPC methods with structured names of the form
- '/Service.Name/Service.Method', where 'Service.Name' is the value
- returned by service_name(), and 'Service.Method' is the method
- name. A service can have multiple method names, but only a single
- service name.
- """
+ A service handles RPC methods with structured names of the form
+ '/Service.Name/Service.Method', where 'Service.Name' is the value
+ returned by service_name(), and 'Service.Method' is the method
+ name. A service can have multiple method names, but only a single
+ service name.
+ """
@abc.abstractmethod
def service_name(self):
"""Returns this service's name.
- Returns:
- The service name.
+ Returns:
+ The service name.
+ """
+ raise NotImplementedError()
+
+
+#################### Service-Side Interceptor Interfaces #####################
+
+
+class ServerInterceptor(six.with_metaclass(abc.ABCMeta)):
+ """Affords intercepting incoming RPCs on the service-side.
+
+ This is an EXPERIMENTAL API.
"""
+
+ @abc.abstractmethod
+ def intercept_service(self, continuation, handler_call_details):
+ """Intercepts incoming RPCs before handing them over to a handler.
+
+ Args:
+ continuation: A function that takes a HandlerCallDetails and
+ proceeds to invoke the next interceptor in the chain, if any,
+ or the RPC handler lookup logic, with the call details passed
+ as an argument, and returns an RpcMethodHandler instance if
+ the RPC is considered serviced, or None otherwise.
+ handler_call_details: A HandlerCallDetails describing the RPC.
+
+ Returns:
+ An RpcMethodHandler with which the RPC may be serviced if the
+ interceptor chooses to service this RPC, or None otherwise.
+ """
raise NotImplementedError()
@@ -939,83 +1178,84 @@ class Server(six.with_metaclass(abc.ABCMeta)):
def add_generic_rpc_handlers(self, generic_rpc_handlers):
"""Registers GenericRpcHandlers with this Server.
- This method is only safe to call before the server is started.
+ This method is only safe to call before the server is started.
- Args:
- generic_rpc_handlers: An iterable of GenericRpcHandlers that will be used
- to service RPCs.
- """
+ Args:
+ generic_rpc_handlers: An iterable of GenericRpcHandlers that will be
+ used to service RPCs.
+ """
raise NotImplementedError()
@abc.abstractmethod
def add_insecure_port(self, address):
"""Opens an insecure port for accepting RPCs.
- This method may only be called before starting the server.
+ This method may only be called before starting the server.
- Args:
- address: The address for which to open a port.
- if the port is 0, or not specified in the address, then gRPC runtime
- will choose a port.
+ Args:
+ address: The address for which to open a port.
+ if the port is 0, or not specified in the address, then gRPC runtime
+ will choose a port.
- Returns:
- integer:
- An integer port on which server will accept RPC requests.
- """
+ Returns:
+ integer:
+ An integer port on which server will accept RPC requests.
+ """
raise NotImplementedError()
@abc.abstractmethod
def add_secure_port(self, address, server_credentials):
"""Opens a secure port for accepting RPCs.
- This method may only be called before starting the server.
+ This method may only be called before starting the server.
- Args:
- address: The address for which to open a port.
- if the port is 0, or not specified in the address, then gRPC runtime
- will choose a port.
- server_credentials: A ServerCredentials object.
+ Args:
+ address: The address for which to open a port.
+ if the port is 0, or not specified in the address, then gRPC
+ runtime will choose a port.
+ server_credentials: A ServerCredentials object.
- Returns:
- integer:
- An integer port on which server will accept RPC requests.
- """
+ Returns:
+ integer:
+ An integer port on which server will accept RPC requests.
+ """
raise NotImplementedError()
@abc.abstractmethod
def start(self):
"""Starts this Server.
- This method may only be called once. (i.e. it is not idempotent).
- """
+ This method may only be called once. (i.e. it is not idempotent).
+ """
raise NotImplementedError()
@abc.abstractmethod
def stop(self, grace):
"""Stops this Server.
- This method immediately stop service of new RPCs in all cases.
- If a grace period is specified, this method returns immediately
- and all RPCs active at the end of the grace period are aborted.
-
- If a grace period is not specified, then all existing RPCs are
- teriminated immediately and the this method blocks until the last
- RPC handler terminates.
-
- This method is idempotent and may be called at any time. Passing a smaller
- grace value in subsequentcall will have the effect of stopping the Server
- sooner. Passing a larger grace value in subsequent call *will not* have the
- effect of stopping the server later (i.e. the most restrictive grace
- value is used).
-
- Args:
- grace: A duration of time in seconds or None.
-
- Returns:
- A threading.Event that will be set when this Server has completely
- stopped, i.e. when running RPCs either complete or are aborted and
- all handlers have terminated.
- """
+ This method immediately stop service of new RPCs in all cases.
+ If a grace period is specified, this method returns immediately
+ and all RPCs active at the end of the grace period are aborted.
+
+ If a grace period is not specified, then all existing RPCs are
+ teriminated immediately and the this method blocks until the last
+ RPC handler terminates.
+
+ This method is idempotent and may be called at any time.
+ Passing a smaller grace value in subsequent call will have
+ the effect of stopping the Server sooner. Passing a larger
+ grace value in subsequent call *will not* have the effect of
+ stopping the server later (i.e. the most restrictive grace
+ value is used).
+
+ Args:
+ grace: A duration of time in seconds or None.
+
+ Returns:
+ A threading.Event that will be set when this Server has completely
+ stopped, i.e. when running RPCs either complete or are aborted and
+ all handlers have terminated.
+ """
raise NotImplementedError()
@@ -1027,15 +1267,15 @@ def unary_unary_rpc_method_handler(behavior,
response_serializer=None):
"""Creates an RpcMethodHandler for a unary-unary RPC method.
- Args:
- behavior: The implementation of an RPC that accepts one request and returns
- one response.
- request_deserializer: An optional behavior for request deserialization.
- response_serializer: An optional behavior for response serialization.
+ Args:
+ behavior: The implementation of an RPC that accepts one request
+ and returns one response.
+ request_deserializer: An optional behavior for request deserialization.
+ response_serializer: An optional behavior for response serialization.
- Returns:
- An RpcMethodHandler object that is typically used by grpc.Server.
- """
+ Returns:
+ An RpcMethodHandler object that is typically used by grpc.Server.
+ """
from grpc import _utilities # pylint: disable=cyclic-import
return _utilities.RpcMethodHandler(False, False, request_deserializer,
response_serializer, behavior, None,
@@ -1047,15 +1287,15 @@ def unary_stream_rpc_method_handler(behavior,
response_serializer=None):
"""Creates an RpcMethodHandler for a unary-stream RPC method.
- Args:
- behavior: The implementation of an RPC that accepts one request and returns
- an iterator of response values.
- request_deserializer: An optional behavior for request deserialization.
- response_serializer: An optional behavior for response serialization.
+ Args:
+ behavior: The implementation of an RPC that accepts one request
+ and returns an iterator of response values.
+ request_deserializer: An optional behavior for request deserialization.
+ response_serializer: An optional behavior for response serialization.
- Returns:
- An RpcMethodHandler object that is typically used by grpc.Server.
- """
+ Returns:
+ An RpcMethodHandler object that is typically used by grpc.Server.
+ """
from grpc import _utilities # pylint: disable=cyclic-import
return _utilities.RpcMethodHandler(False, True, request_deserializer,
response_serializer, None, behavior,
@@ -1067,15 +1307,15 @@ def stream_unary_rpc_method_handler(behavior,
response_serializer=None):
"""Creates an RpcMethodHandler for a stream-unary RPC method.
- Args:
- behavior: The implementation of an RPC that accepts an iterator of request
- values and returns a single response value.
- request_deserializer: An optional behavior for request deserialization.
- response_serializer: An optional behavior for response serialization.
+ Args:
+ behavior: The implementation of an RPC that accepts an iterator of
+ request values and returns a single response value.
+ request_deserializer: An optional behavior for request deserialization.
+ response_serializer: An optional behavior for response serialization.
- Returns:
- An RpcMethodHandler object that is typically used by grpc.Server.
- """
+ Returns:
+ An RpcMethodHandler object that is typically used by grpc.Server.
+ """
from grpc import _utilities # pylint: disable=cyclic-import
return _utilities.RpcMethodHandler(True, False, request_deserializer,
response_serializer, None, None,
@@ -1087,15 +1327,15 @@ def stream_stream_rpc_method_handler(behavior,
response_serializer=None):
"""Creates an RpcMethodHandler for a stream-stream RPC method.
- Args:
- behavior: The implementation of an RPC that accepts an iterator of request
- values and returns an iterator of response values.
- request_deserializer: An optional behavior for request deserialization.
- response_serializer: An optional behavior for response serialization.
+ Args:
+ behavior: The implementation of an RPC that accepts an iterator of
+ request values and returns an iterator of response values.
+ request_deserializer: An optional behavior for request deserialization.
+ response_serializer: An optional behavior for response serialization.
- Returns:
- An RpcMethodHandler object that is typically used by grpc.Server.
- """
+ Returns:
+ An RpcMethodHandler object that is typically used by grpc.Server.
+ """
from grpc import _utilities # pylint: disable=cyclic-import
return _utilities.RpcMethodHandler(True, True, request_deserializer,
response_serializer, None, None, None,
@@ -1105,15 +1345,16 @@ def stream_stream_rpc_method_handler(behavior,
def method_handlers_generic_handler(service, method_handlers):
"""Creates a GenericRpcHandler from RpcMethodHandlers.
- Args:
- service: The name of the service that is implemented by the method_handlers.
- method_handlers: A dictionary that maps method names to corresponding
- RpcMethodHandler.
+ Args:
+ service: The name of the service that is implemented by the
+ method_handlers.
+ method_handlers: A dictionary that maps method names to corresponding
+ RpcMethodHandler.
- Returns:
- A GenericRpcHandler. This is typically added to the grpc.Server object
- with add_generic_rpc_handlers() before starting the server.
- """
+ Returns:
+ A GenericRpcHandler. This is typically added to the grpc.Server object
+ with add_generic_rpc_handlers() before starting the server.
+ """
from grpc import _utilities # pylint: disable=cyclic-import
return _utilities.DictionaryGenericHandler(service, method_handlers)
@@ -1123,99 +1364,86 @@ def ssl_channel_credentials(root_certificates=None,
certificate_chain=None):
"""Creates a ChannelCredentials for use with an SSL-enabled Channel.
- Args:
- root_certificates: The PEM-encoded root certificates as a byte string,
- or None to retrieve them from a default location chosen by gRPC runtime.
- private_key: The PEM-encoded private key as a byte string, or None if no
- private key should be used.
- certificate_chain: The PEM-encoded certificate chain as a byte string
- to use or or None if no certificate chain should be used.
-
- Returns:
- A ChannelCredentials for use with an SSL-enabled Channel.
- """
- if private_key is not None or certificate_chain is not None:
- pair = _cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
- else:
- pair = None
+ Args:
+ root_certificates: The PEM-encoded root certificates as a byte string,
+ or None to retrieve them from a default location chosen by gRPC
+ runtime.
+ private_key: The PEM-encoded private key as a byte string, or None if no
+ private key should be used.
+ certificate_chain: The PEM-encoded certificate chain as a byte string
+ to use or or None if no certificate chain should be used.
+
+ Returns:
+ A ChannelCredentials for use with an SSL-enabled Channel.
+ """
return ChannelCredentials(
- _cygrpc.channel_credentials_ssl(root_certificates, pair))
+ _cygrpc.SSLChannelCredentials(root_certificates, private_key,
+ certificate_chain))
def metadata_call_credentials(metadata_plugin, name=None):
"""Construct CallCredentials from an AuthMetadataPlugin.
- Args:
- metadata_plugin: An AuthMetadataPlugin to use for authentication.
- name: An optional name for the plugin.
+ Args:
+ metadata_plugin: An AuthMetadataPlugin to use for authentication.
+ name: An optional name for the plugin.
- Returns:
- A CallCredentials.
- """
+ Returns:
+ A CallCredentials.
+ """
from grpc import _plugin_wrapping # pylint: disable=cyclic-import
- if name is None:
- try:
- effective_name = metadata_plugin.__name__
- except AttributeError:
- effective_name = metadata_plugin.__class__.__name__
- else:
- effective_name = name
- return CallCredentials(
- _plugin_wrapping.call_credentials_metadata_plugin(metadata_plugin,
- effective_name))
+ return _plugin_wrapping.metadata_plugin_call_credentials(
+ metadata_plugin, name)
def access_token_call_credentials(access_token):
"""Construct CallCredentials from an access token.
- Args:
- access_token: A string to place directly in the http request
- authorization header, for example
- "authorization: Bearer <access_token>".
+ Args:
+ access_token: A string to place directly in the http request
+ authorization header, for example
+ "authorization: Bearer <access_token>".
- Returns:
- A CallCredentials.
- """
+ Returns:
+ A CallCredentials.
+ """
from grpc import _auth # pylint: disable=cyclic-import
- return metadata_call_credentials(
- _auth.AccessTokenCallCredentials(access_token))
+ from grpc import _plugin_wrapping # pylint: disable=cyclic-import
+ return _plugin_wrapping.metadata_plugin_call_credentials(
+ _auth.AccessTokenAuthMetadataPlugin(access_token), None)
def composite_call_credentials(*call_credentials):
"""Compose multiple CallCredentials to make a new CallCredentials.
- Args:
- *call_credentials: At least two CallCredentials objects.
+ Args:
+ *call_credentials: At least two CallCredentials objects.
- Returns:
- A CallCredentials object composed of the given CallCredentials objects.
- """
- from grpc import _credential_composition # pylint: disable=cyclic-import
- cygrpc_call_credentials = tuple(
- single_call_credentials._credentials
- for single_call_credentials in call_credentials)
+ Returns:
+ A CallCredentials object composed of the given CallCredentials objects.
+ """
return CallCredentials(
- _credential_composition.call(cygrpc_call_credentials))
+ _cygrpc.CompositeCallCredentials(
+ tuple(single_call_credentials._credentials
+ for single_call_credentials in call_credentials)))
def composite_channel_credentials(channel_credentials, *call_credentials):
"""Compose a ChannelCredentials and one or more CallCredentials objects.
- Args:
- channel_credentials: A ChannelCredentials object.
- *call_credentials: One or more CallCredentials objects.
-
- Returns:
- A ChannelCredentials composed of the given ChannelCredentials and
- CallCredentials objects.
- """
- from grpc import _credential_composition # pylint: disable=cyclic-import
- cygrpc_call_credentials = tuple(
- single_call_credentials._credentials
- for single_call_credentials in call_credentials)
+ Args:
+ channel_credentials: A ChannelCredentials object.
+ *call_credentials: One or more CallCredentials objects.
+
+ Returns:
+ A ChannelCredentials composed of the given ChannelCredentials and
+ CallCredentials objects.
+ """
return ChannelCredentials(
- _credential_composition.channel(channel_credentials._credentials,
- cygrpc_call_credentials))
+ _cygrpc.CompositeChannelCredentials(
+ tuple(single_call_credentials._credentials
+ for single_call_credentials in call_credentials),
+ channel_credentials._credentials))
def ssl_server_credentials(private_key_certificate_chain_pairs,
@@ -1223,20 +1451,20 @@ def ssl_server_credentials(private_key_certificate_chain_pairs,
require_client_auth=False):
"""Creates a ServerCredentials for use with an SSL-enabled Server.
- Args:
- private_key_certificate_chain_pairs: A list of pairs of the form
- [PEM-encoded private key, PEM-encoded certificate chain].
- root_certificates: An optional byte string of PEM-encoded client root
- certificates that the server will use to verify client authentication.
- If omitted, require_client_auth must also be False.
- require_client_auth: A boolean indicating whether or not to require
- clients to be authenticated. May only be True if root_certificates
- is not None.
-
- Returns:
- A ServerCredentials for use with an SSL-enabled Server. Typically, this
- object is an argument to add_secure_port() method during server setup.
- """
+ Args:
+ private_key_certificate_chain_pairs: A list of pairs of the form
+ [PEM-encoded private key, PEM-encoded certificate chain].
+ root_certificates: An optional byte string of PEM-encoded client root
+ certificates that the server will use to verify client authentication.
+ If omitted, require_client_auth must also be False.
+ require_client_auth: A boolean indicating whether or not to require
+ clients to be authenticated. May only be True if root_certificates
+ is not None.
+
+ Returns:
+ A ServerCredentials for use with an SSL-enabled Server. Typically, this
+ object is an argument to add_secure_port() method during server setup.
+ """
if len(private_key_certificate_chain_pairs) == 0:
raise ValueError(
'At least one private key-certificate chain pair is required!')
@@ -1252,19 +1480,74 @@ def ssl_server_credentials(private_key_certificate_chain_pairs,
], require_client_auth))
+def ssl_server_certificate_configuration(private_key_certificate_chain_pairs,
+ root_certificates=None):
+ """Creates a ServerCertificateConfiguration for use with a Server.
+
+ Args:
+ private_key_certificate_chain_pairs: A collection of pairs of
+ the form [PEM-encoded private key, PEM-encoded certificate
+ chain].
+ root_certificates: An optional byte string of PEM-encoded client root
+ certificates that the server will use to verify client authentication.
+
+ Returns:
+ A ServerCertificateConfiguration that can be returned in the certificate
+ configuration fetching callback.
+ """
+ if len(private_key_certificate_chain_pairs) == 0:
+ raise ValueError(
+ 'At least one private key-certificate chain pair is required!')
+ else:
+ return ServerCertificateConfiguration(
+ _cygrpc.server_certificate_config_ssl(root_certificates, [
+ _cygrpc.SslPemKeyCertPair(key, pem)
+ for key, pem in private_key_certificate_chain_pairs
+ ]))
+
+
+def dynamic_ssl_server_credentials(initial_certificate_configuration,
+ certificate_configuration_fetcher,
+ require_client_authentication=False):
+ """Creates a ServerCredentials for use with an SSL-enabled Server.
+
+ Args:
+ initial_certificate_configuration (ServerCertificateConfiguration): The
+ certificate configuration with which the server will be initialized.
+ certificate_configuration_fetcher (callable): A callable that takes no
+ arguments and should return a ServerCertificateConfiguration to
+ replace the server's current certificate, or None for no change
+ (i.e., the server will continue its current certificate
+ config). The library will call this callback on *every* new
+ client connection before starting the TLS handshake with the
+ client, thus allowing the user application to optionally
+ return a new ServerCertificateConfiguration that the server will then
+ use for the handshake.
+ require_client_authentication: A boolean indicating whether or not to
+ require clients to be authenticated.
+
+ Returns:
+ A ServerCredentials.
+ """
+ return ServerCredentials(
+ _cygrpc.server_credentials_ssl_dynamic_cert_config(
+ initial_certificate_configuration,
+ certificate_configuration_fetcher, require_client_authentication))
+
+
def channel_ready_future(channel):
"""Creates a Future that tracks when a Channel is ready.
- Cancelling the Future does not affect the channel's state machine.
- It merely decouples the Future from channel state machine.
+ Cancelling the Future does not affect the channel's state machine.
+ It merely decouples the Future from channel state machine.
- Args:
- channel: A Channel object.
+ Args:
+ channel: A Channel object.
- Returns:
- A Future object that matures when the channel connectivity is
- ChannelConnectivity.READY.
- """
+ Returns:
+ A Future object that matures when the channel connectivity is
+ ChannelConnectivity.READY.
+ """
from grpc import _utilities # pylint: disable=cyclic-import
return _utilities.channel_ready_future(channel)
@@ -1272,14 +1555,14 @@ def channel_ready_future(channel):
def insecure_channel(target, options=None):
"""Creates an insecure Channel to a server.
- Args:
- target: The server address
- options: An optional list of key-value pairs (channel args in gRPC runtime)
- to configure the channel.
+ Args:
+ target: The server address
+ options: An optional list of key-value pairs (channel args
+ in gRPC Core runtime) to configure the channel.
- Returns:
- A Channel object.
- """
+ Returns:
+ A Channel object.
+ """
from grpc import _channel # pylint: disable=cyclic-import
return _channel.Channel(target, () if options is None else options, None)
@@ -1287,65 +1570,134 @@ def insecure_channel(target, options=None):
def secure_channel(target, credentials, options=None):
"""Creates a secure Channel to a server.
- Args:
- target: The server address.
- credentials: A ChannelCredentials instance.
- options: An optional list of key-value pairs (channel args in gRPC runtime)
- to configure the channel.
+ Args:
+ target: The server address.
+ credentials: A ChannelCredentials instance.
+ options: An optional list of key-value pairs (channel args
+ in gRPC Core runtime) to configure the channel.
- Returns:
- A Channel object.
- """
+ Returns:
+ A Channel object.
+ """
from grpc import _channel # pylint: disable=cyclic-import
return _channel.Channel(target, () if options is None else options,
credentials._credentials)
+def intercept_channel(channel, *interceptors):
+ """Intercepts a channel through a set of interceptors.
+
+ This is an EXPERIMENTAL API.
+
+ Args:
+ channel: A Channel.
+ interceptors: Zero or more objects of type
+ UnaryUnaryClientInterceptor,
+ UnaryStreamClientInterceptor,
+ StreamUnaryClientInterceptor, or
+ StreamStreamClientInterceptor.
+ Interceptors are given control in the order they are listed.
+
+ Returns:
+ A Channel that intercepts each invocation via the provided interceptors.
+
+ Raises:
+ TypeError: If interceptor does not derive from any of
+ UnaryUnaryClientInterceptor,
+ UnaryStreamClientInterceptor,
+ StreamUnaryClientInterceptor, or
+ StreamStreamClientInterceptor.
+ """
+ from grpc import _interceptor # pylint: disable=cyclic-import
+ return _interceptor.intercept_channel(channel, *interceptors)
+
+
def server(thread_pool,
handlers=None,
+ interceptors=None,
options=None,
maximum_concurrent_rpcs=None):
"""Creates a Server with which RPCs can be serviced.
- Args:
- thread_pool: A futures.ThreadPoolExecutor to be used by the Server
- to execute RPC handlers.
- handlers: An optional list of GenericRpcHandlers used for executing RPCs.
- More handlers may be added by calling add_generic_rpc_handlers any time
- before the server is started.
- options: An optional list of key-value pairs (channel args in gRPC runtime)
- to configure the channel.
- maximum_concurrent_rpcs: The maximum number of concurrent RPCs this server
- will service before returning RESOURCE_EXHAUSTED status, or None to
- indicate no limit.
-
- Returns:
- A Server object.
- """
+ Args:
+ thread_pool: A futures.ThreadPoolExecutor to be used by the Server
+ to execute RPC handlers.
+ handlers: An optional list of GenericRpcHandlers used for executing RPCs.
+ More handlers may be added by calling add_generic_rpc_handlers any time
+ before the server is started.
+ interceptors: An optional list of ServerInterceptor objects that observe
+ and optionally manipulate the incoming RPCs before handing them over to
+ handlers. The interceptors are given control in the order they are
+ specified. This is an EXPERIMENTAL API.
+ options: An optional list of key-value pairs (channel args in gRPC runtime)
+ to configure the channel.
+ maximum_concurrent_rpcs: The maximum number of concurrent RPCs this server
+ will service before returning RESOURCE_EXHAUSTED status, or None to
+ indicate no limit.
+
+ Returns:
+ A Server object.
+ """
from grpc import _server # pylint: disable=cyclic-import
return _server.Server(thread_pool, () if handlers is None else handlers, ()
- if options is None else options,
- maximum_concurrent_rpcs)
+ if interceptors is None else interceptors, () if
+ options is None else options, maximum_concurrent_rpcs)
################################### __all__ #################################
-__all__ = ('FutureTimeoutError', 'FutureCancelledError', 'Future',
- 'ChannelConnectivity', 'StatusCode', 'RpcError', 'RpcContext',
- 'Call', 'ChannelCredentials', 'CallCredentials',
- 'AuthMetadataContext', 'AuthMetadataPluginCallback',
- 'AuthMetadataPlugin', 'ServerCredentials', 'UnaryUnaryMultiCallable',
- 'UnaryStreamMultiCallable', 'StreamUnaryMultiCallable',
- 'StreamStreamMultiCallable', 'Channel', 'ServicerContext',
- 'RpcMethodHandler', 'HandlerCallDetails', 'GenericRpcHandler',
- 'ServiceRpcHandler', 'Server', 'unary_unary_rpc_method_handler',
- 'unary_stream_rpc_method_handler', 'stream_unary_rpc_method_handler',
- 'stream_stream_rpc_method_handler',
- 'method_handlers_generic_handler', 'ssl_channel_credentials',
- 'metadata_call_credentials', 'access_token_call_credentials',
- 'composite_call_credentials', 'composite_channel_credentials',
- 'ssl_server_credentials', 'channel_ready_future', 'insecure_channel',
- 'secure_channel', 'server',)
+__all__ = (
+ 'FutureTimeoutError',
+ 'FutureCancelledError',
+ 'Future',
+ 'ChannelConnectivity',
+ 'StatusCode',
+ 'RpcError',
+ 'RpcContext',
+ 'Call',
+ 'ChannelCredentials',
+ 'CallCredentials',
+ 'AuthMetadataContext',
+ 'AuthMetadataPluginCallback',
+ 'AuthMetadataPlugin',
+ 'ClientCallDetails',
+ 'ServerCertificateConfiguration',
+ 'ServerCredentials',
+ 'UnaryUnaryMultiCallable',
+ 'UnaryStreamMultiCallable',
+ 'StreamUnaryMultiCallable',
+ 'StreamStreamMultiCallable',
+ 'UnaryUnaryClientInterceptor',
+ 'UnaryStreamClientInterceptor',
+ 'StreamUnaryClientInterceptor',
+ 'StreamStreamClientInterceptor',
+ 'Channel',
+ 'ServicerContext',
+ 'RpcMethodHandler',
+ 'HandlerCallDetails',
+ 'GenericRpcHandler',
+ 'ServiceRpcHandler',
+ 'Server',
+ 'ServerInterceptor',
+ 'unary_unary_rpc_method_handler',
+ 'unary_stream_rpc_method_handler',
+ 'stream_unary_rpc_method_handler',
+ 'stream_stream_rpc_method_handler',
+ 'method_handlers_generic_handler',
+ 'ssl_channel_credentials',
+ 'metadata_call_credentials',
+ 'access_token_call_credentials',
+ 'composite_call_credentials',
+ 'composite_channel_credentials',
+ 'ssl_server_credentials',
+ 'ssl_server_certificate_configuration',
+ 'dynamic_ssl_server_credentials',
+ 'channel_ready_future',
+ 'insecure_channel',
+ 'secure_channel',
+ 'intercept_channel',
+ 'server',
+)
############################### Extension Shims ################################
diff --git a/src/python/grpcio/grpc/_auth.py b/src/python/grpcio/grpc/_auth.py
index c6542d0135..c17824563d 100644
--- a/src/python/grpcio/grpc/_auth.py
+++ b/src/python/grpcio/grpc/_auth.py
@@ -54,7 +54,9 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin):
if self._is_jwt:
future = self._pool.submit(
self._credentials.get_access_token,
- additional_claims={'aud': context.service_url})
+ additional_claims={
+ 'aud': context.service_url
+ })
else:
future = self._pool.submit(self._credentials.get_access_token)
future.add_done_callback(_create_get_token_callback(callback))
@@ -63,7 +65,7 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin):
self._pool.shutdown(wait=False)
-class AccessTokenCallCredentials(grpc.AuthMetadataPlugin):
+class AccessTokenAuthMetadataPlugin(grpc.AuthMetadataPlugin):
"""Metadata wrapper for raw access token credentials."""
def __init__(self, access_token):
diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py
index cf4ce0941b..25a4210974 100644
--- a/src/python/grpcio/grpc/_channel.py
+++ b/src/python/grpcio/grpc/_channel.py
@@ -13,10 +13,10 @@
# limitations under the License.
"""Invocation-side implementation of gRPC Python."""
+import logging
import sys
import threading
import time
-import logging
import grpc
from grpc import _common
@@ -27,37 +27,40 @@ from grpc.framework.foundation import callable_util
_USER_AGENT = 'grpc-python/{}'.format(_grpcio_metadata.__version__)
_EMPTY_FLAGS = 0
-_INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))
-
-_UNARY_UNARY_INITIAL_DUE = (cygrpc.OperationType.send_initial_metadata,
- cygrpc.OperationType.send_message,
- cygrpc.OperationType.send_close_from_client,
- cygrpc.OperationType.receive_initial_metadata,
- cygrpc.OperationType.receive_message,
- cygrpc.OperationType.receive_status_on_client,)
-_UNARY_STREAM_INITIAL_DUE = (cygrpc.OperationType.send_initial_metadata,
- cygrpc.OperationType.send_message,
- cygrpc.OperationType.send_close_from_client,
- cygrpc.OperationType.receive_initial_metadata,
- cygrpc.OperationType.receive_status_on_client,)
-_STREAM_UNARY_INITIAL_DUE = (cygrpc.OperationType.send_initial_metadata,
- cygrpc.OperationType.receive_initial_metadata,
- cygrpc.OperationType.receive_message,
- cygrpc.OperationType.receive_status_on_client,)
-_STREAM_STREAM_INITIAL_DUE = (cygrpc.OperationType.send_initial_metadata,
- cygrpc.OperationType.receive_initial_metadata,
- cygrpc.OperationType.receive_status_on_client,)
+
+_UNARY_UNARY_INITIAL_DUE = (
+ cygrpc.OperationType.send_initial_metadata,
+ cygrpc.OperationType.send_message,
+ cygrpc.OperationType.send_close_from_client,
+ cygrpc.OperationType.receive_initial_metadata,
+ cygrpc.OperationType.receive_message,
+ cygrpc.OperationType.receive_status_on_client,
+)
+_UNARY_STREAM_INITIAL_DUE = (
+ cygrpc.OperationType.send_initial_metadata,
+ cygrpc.OperationType.send_message,
+ cygrpc.OperationType.send_close_from_client,
+ cygrpc.OperationType.receive_initial_metadata,
+ cygrpc.OperationType.receive_status_on_client,
+)
+_STREAM_UNARY_INITIAL_DUE = (
+ cygrpc.OperationType.send_initial_metadata,
+ cygrpc.OperationType.receive_initial_metadata,
+ cygrpc.OperationType.receive_message,
+ cygrpc.OperationType.receive_status_on_client,
+)
+_STREAM_STREAM_INITIAL_DUE = (
+ cygrpc.OperationType.send_initial_metadata,
+ cygrpc.OperationType.receive_initial_metadata,
+ cygrpc.OperationType.receive_status_on_client,
+)
_CHANNEL_SUBSCRIPTION_CALLBACK_ERROR_LOG_MESSAGE = (
'Exception calling channel subscription callback!')
def _deadline(timeout):
- if timeout is None:
- return None, _INFINITE_FUTURE
- else:
- deadline = time.time() + timeout
- return deadline, cygrpc.Timespec(deadline)
+ return None if timeout is None else time.time() + timeout
def _unknown_code_details(unknown_cygrpc_code, details):
@@ -122,19 +125,19 @@ def _abort(state, code, details):
state.code = code
state.details = details
if state.initial_metadata is None:
- state.initial_metadata = _common.EMPTY_METADATA
- state.trailing_metadata = _common.EMPTY_METADATA
+ state.initial_metadata = ()
+ state.trailing_metadata = ()
def _handle_event(event, state, response_deserializer):
callbacks = []
for batch_operation in event.batch_operations:
- operation_type = batch_operation.type
+ operation_type = batch_operation.type()
state.due.remove(operation_type)
if operation_type == cygrpc.OperationType.receive_initial_metadata:
- state.initial_metadata = batch_operation.received_metadata
+ state.initial_metadata = batch_operation.initial_metadata()
elif operation_type == cygrpc.OperationType.receive_message:
- serialized_response = batch_operation.received_message.bytes()
+ serialized_response = batch_operation.message()
if serialized_response is not None:
response = _common.deserialize(serialized_response,
response_deserializer)
@@ -144,18 +147,17 @@ def _handle_event(event, state, response_deserializer):
else:
state.response = response
elif operation_type == cygrpc.OperationType.receive_status_on_client:
- state.trailing_metadata = batch_operation.received_metadata
+ state.trailing_metadata = batch_operation.trailing_metadata()
if state.code is None:
code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE.get(
- batch_operation.received_status_code)
+ batch_operation.code())
if code is None:
state.code = grpc.StatusCode.UNKNOWN
state.details = _unknown_code_details(
- batch_operation.received_status_code,
- batch_operation.received_status_details)
+ code, batch_operation.details())
else:
state.code = code
- state.details = batch_operation.received_status_details
+ state.details = batch_operation.details()
callbacks.extend(state.callbacks)
state.callbacks = None
return callbacks
@@ -200,10 +202,9 @@ def _consume_request_iterator(request_iterator, state, call,
_abort(state, grpc.StatusCode.INTERNAL, details)
return
else:
- operations = (cygrpc.operation_send_message(
+ operations = (cygrpc.SendMessageOperation(
serialized_request, _EMPTY_FLAGS),)
- call.start_client_batch(
- cygrpc.Operations(operations), event_handler)
+ call.start_client_batch(operations, event_handler)
state.due.add(cygrpc.OperationType.send_message)
while True:
state.condition.wait()
@@ -217,9 +218,8 @@ def _consume_request_iterator(request_iterator, state, call,
with state.condition:
if state.code is None:
operations = (
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),)
- call.start_client_batch(
- cygrpc.Operations(operations), event_handler)
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),)
+ call.start_client_batch(operations, event_handler)
state.due.add(cygrpc.OperationType.send_close_from_client)
def stop_consumption_thread(timeout): # pylint: disable=unused-argument
@@ -321,8 +321,7 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call):
event_handler = _event_handler(self._state, self._call,
self._response_deserializer)
self._call.start_client_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_message(_EMPTY_FLAGS),)),
+ (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),),
event_handler)
self._state.due.add(cygrpc.OperationType.receive_message)
elif self._state.code is grpc.StatusCode.OK:
@@ -372,14 +371,13 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call):
with self._state.condition:
while self._state.initial_metadata is None:
self._state.condition.wait()
- return _common.to_application_metadata(self._state.initial_metadata)
+ return self._state.initial_metadata
def trailing_metadata(self):
with self._state.condition:
while self._state.trailing_metadata is None:
self._state.condition.wait()
- return _common.to_application_metadata(
- self._state.trailing_metadata)
+ return self._state.trailing_metadata
def code(self):
with self._state.condition:
@@ -417,16 +415,15 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call):
def _start_unary_request(request, timeout, request_serializer):
- deadline, deadline_timespec = _deadline(timeout)
+ deadline = _deadline(timeout)
serialized_request = _common.serialize(request, request_serializer)
if serialized_request is None:
- state = _RPCState((), _common.EMPTY_METADATA, _common.EMPTY_METADATA,
- grpc.StatusCode.INTERNAL,
+ state = _RPCState((), (), (), grpc.StatusCode.INTERNAL,
'Exception serializing request!')
rendezvous = _Rendezvous(state, None, None, deadline)
- return deadline, deadline_timespec, None, rendezvous
+ return deadline, None, rendezvous
else:
- return deadline, deadline_timespec, serialized_request, None
+ return deadline, serialized_request, None
def _end_unary_response_blocking(state, call, with_call, deadline):
@@ -451,36 +448,34 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
self._response_deserializer = response_deserializer
def _prepare(self, request, timeout, metadata):
- deadline, deadline_timespec, serialized_request, rendezvous = (
- _start_unary_request(request, timeout, self._request_serializer))
+ deadline, serialized_request, rendezvous = (_start_unary_request(
+ request, timeout, self._request_serializer))
if serialized_request is None:
- return None, None, None, None, rendezvous
+ return None, None, None, rendezvous
else:
state = _RPCState(_UNARY_UNARY_INITIAL_DUE, None, None, None, None)
operations = (
- cygrpc.operation_send_initial_metadata(
- _common.to_cygrpc_metadata(metadata), _EMPTY_FLAGS),
- cygrpc.operation_send_message(serialized_request, _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
- return state, operations, deadline, deadline_timespec, None
+ cygrpc.SendInitialMetadataOperation(metadata, _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(serialized_request, _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
+ return state, operations, deadline, None
def _blocking(self, request, timeout, metadata, credentials):
- state, operations, deadline, deadline_timespec, rendezvous = self._prepare(
+ state, operations, deadline, rendezvous = self._prepare(
request, timeout, metadata)
if rendezvous:
raise rendezvous
else:
completion_queue = cygrpc.CompletionQueue()
call = self._channel.create_call(None, 0, completion_queue,
- self._method, None,
- deadline_timespec)
+ self._method, None, deadline)
if credentials is not None:
call.set_credentials(credentials._credentials)
- call_error = call.start_client_batch(
- cygrpc.Operations(operations), None)
+ call_error = call.start_client_batch(operations, None)
_check_call_error(call_error, metadata)
_handle_event(completion_queue.poll(), state,
self._response_deserializer)
@@ -497,20 +492,19 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
return _end_unary_response_blocking(state, call, True, deadline)
def future(self, request, timeout=None, metadata=None, credentials=None):
- state, operations, deadline, deadline_timespec, rendezvous = self._prepare(
+ state, operations, deadline, rendezvous = self._prepare(
request, timeout, metadata)
if rendezvous:
return rendezvous
else:
call, drive_call = self._managed_call(None, 0, self._method, None,
- deadline_timespec)
+ deadline)
if credentials is not None:
call.set_credentials(credentials._credentials)
event_handler = _event_handler(state, call,
self._response_deserializer)
with state.condition:
- call_error = call.start_client_batch(
- cygrpc.Operations(operations), event_handler)
+ call_error = call.start_client_batch(operations, event_handler)
if call_error != cygrpc.CallError.ok:
_call_error_set_RPCstate(state, call_error, metadata)
return _Rendezvous(state, None, None, deadline)
@@ -530,32 +524,30 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
self._response_deserializer = response_deserializer
def __call__(self, request, timeout=None, metadata=None, credentials=None):
- deadline, deadline_timespec, serialized_request, rendezvous = (
- _start_unary_request(request, timeout, self._request_serializer))
+ deadline, serialized_request, rendezvous = (_start_unary_request(
+ request, timeout, self._request_serializer))
if serialized_request is None:
raise rendezvous
else:
state = _RPCState(_UNARY_STREAM_INITIAL_DUE, None, None, None, None)
call, drive_call = self._managed_call(None, 0, self._method, None,
- deadline_timespec)
+ deadline)
if credentials is not None:
call.set_credentials(credentials._credentials)
event_handler = _event_handler(state, call,
self._response_deserializer)
with state.condition:
call.start_client_batch(
- cygrpc.Operations((
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- )), event_handler)
+ (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),),
+ event_handler)
operations = (
- cygrpc.operation_send_initial_metadata(
- _common.to_cygrpc_metadata(metadata),
- _EMPTY_FLAGS), cygrpc.operation_send_message(
- serialized_request, _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
- call_error = call.start_client_batch(
- cygrpc.Operations(operations), event_handler)
+ cygrpc.SendInitialMetadataOperation(metadata, _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(serialized_request,
+ _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
+ call_error = call.start_client_batch(operations, event_handler)
if call_error != cygrpc.CallError.ok:
_call_error_set_RPCstate(state, call_error, metadata)
return _Rendezvous(state, None, None, deadline)
@@ -575,25 +567,22 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
self._response_deserializer = response_deserializer
def _blocking(self, request_iterator, timeout, metadata, credentials):
- deadline, deadline_timespec = _deadline(timeout)
+ deadline = _deadline(timeout)
state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None)
completion_queue = cygrpc.CompletionQueue()
call = self._channel.create_call(None, 0, completion_queue,
- self._method, None, deadline_timespec)
+ self._method, None, deadline)
if credentials is not None:
call.set_credentials(credentials._credentials)
with state.condition:
call.start_client_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),)),
- None)
+ (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), None)
operations = (
- cygrpc.operation_send_initial_metadata(
- _common.to_cygrpc_metadata(metadata), _EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
- call_error = call.start_client_batch(
- cygrpc.Operations(operations), None)
+ cygrpc.SendInitialMetadataOperation(metadata, _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
+ call_error = call.start_client_batch(operations, None)
_check_call_error(call_error, metadata)
_consume_request_iterator(request_iterator, state, call,
self._request_serializer)
@@ -629,25 +618,23 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
timeout=None,
metadata=None,
credentials=None):
- deadline, deadline_timespec = _deadline(timeout)
+ deadline = _deadline(timeout)
state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None)
call, drive_call = self._managed_call(None, 0, self._method, None,
- deadline_timespec)
+ deadline)
if credentials is not None:
call.set_credentials(credentials._credentials)
event_handler = _event_handler(state, call, self._response_deserializer)
with state.condition:
call.start_client_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),)),
+ (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),),
event_handler)
operations = (
- cygrpc.operation_send_initial_metadata(
- _common.to_cygrpc_metadata(metadata), _EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
- call_error = call.start_client_batch(
- cygrpc.Operations(operations), event_handler)
+ cygrpc.SendInitialMetadataOperation(metadata, _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
+ call_error = call.start_client_batch(operations, event_handler)
if call_error != cygrpc.CallError.ok:
_call_error_set_RPCstate(state, call_error, metadata)
return _Rendezvous(state, None, None, deadline)
@@ -672,24 +659,22 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
timeout=None,
metadata=None,
credentials=None):
- deadline, deadline_timespec = _deadline(timeout)
+ deadline = _deadline(timeout)
state = _RPCState(_STREAM_STREAM_INITIAL_DUE, None, None, None, None)
call, drive_call = self._managed_call(None, 0, self._method, None,
- deadline_timespec)
+ deadline)
if credentials is not None:
call.set_credentials(credentials._credentials)
event_handler = _event_handler(state, call, self._response_deserializer)
with state.condition:
call.start_client_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),)),
+ (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),),
event_handler)
operations = (
- cygrpc.operation_send_initial_metadata(
- _common.to_cygrpc_metadata(metadata), _EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
- call_error = call.start_client_batch(
- cygrpc.Operations(operations), event_handler)
+ cygrpc.SendInitialMetadataOperation(metadata, _EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
+ call_error = call.start_client_batch(operations, event_handler)
if call_error != cygrpc.CallError.ok:
_call_error_set_RPCstate(state, call_error, metadata)
return _Rendezvous(state, None, None, deadline)
@@ -746,7 +731,8 @@ def _channel_managed_call_management(state):
flags: An integer bitfield of call flags.
method: The RPC method.
host: A host string for the created call.
- deadline: A cygrpc.Timespec to be the deadline of the created call.
+ deadline: A float to be the deadline of the created call or None if the
+ call is to have an infinite deadline.
Returns:
A cygrpc.Call with which to conduct an RPC and a function to call if
@@ -809,7 +795,11 @@ def _deliver(state, initial_connectivity, initial_callbacks):
def _spawn_delivery(state, callbacks):
delivering_thread = threading.Thread(
- target=_deliver, args=(state, state.connectivity, callbacks,))
+ target=_deliver, args=(
+ state,
+ state.connectivity,
+ callbacks,
+ ))
delivering_thread.start()
state.delivering = True
@@ -832,8 +822,8 @@ def _poll_connectivity(state, channel, initial_try_to_connect):
completion_queue = cygrpc.CompletionQueue()
while True:
channel.watch_connectivity_state(connectivity,
- cygrpc.Timespec(time.time() + 0.2),
- completion_queue, None)
+ time.time() + 0.2, completion_queue,
+ None)
event = completion_queue.poll()
with state.lock:
if not state.callbacks_and_connectivities and not state.try_to_connect:
@@ -884,8 +874,8 @@ def _subscribe(state, callback, try_to_connect):
def _unsubscribe(state, callback):
with state.lock:
- for index, (subscribed_callback, unused_connectivity
- ) in enumerate(state.callbacks_and_connectivities):
+ for index, (subscribed_callback, unused_connectivity) in enumerate(
+ state.callbacks_and_connectivities):
if callback == subscribed_callback:
state.callbacks_and_connectivities.pop(index)
break
@@ -893,7 +883,10 @@ def _unsubscribe(state, callback):
def _options(options):
return list(options) + [
- (cygrpc.ChannelArgKey.primary_user_agent_string, _USER_AGENT)
+ (
+ cygrpc.ChannelArgKey.primary_user_agent_string,
+ _USER_AGENT,
+ ),
]
@@ -903,14 +896,13 @@ class Channel(grpc.Channel):
def __init__(self, target, options, credentials):
"""Constructor.
- Args:
- target: The target to which to connect.
- options: Configuration options for the channel.
- credentials: A cygrpc.ChannelCredentials or None.
- """
+ Args:
+ target: The target to which to connect.
+ options: Configuration options for the channel.
+ credentials: A cygrpc.ChannelCredentials or None.
+ """
self._channel = cygrpc.Channel(
- _common.encode(target),
- _common.channel_args(_options(options)), credentials)
+ _common.encode(target), _options(options), credentials)
self._call_state = _ChannelCallState(self._channel)
self._connectivity_state = _ChannelConnectivityState(self._channel)
@@ -930,8 +922,7 @@ class Channel(grpc.Channel):
request_serializer=None,
response_deserializer=None):
return _UnaryUnaryMultiCallable(
- self._channel,
- _channel_managed_call_management(self._call_state),
+ self._channel, _channel_managed_call_management(self._call_state),
_common.encode(method), request_serializer, response_deserializer)
def unary_stream(self,
@@ -939,8 +930,7 @@ class Channel(grpc.Channel):
request_serializer=None,
response_deserializer=None):
return _UnaryStreamMultiCallable(
- self._channel,
- _channel_managed_call_management(self._call_state),
+ self._channel, _channel_managed_call_management(self._call_state),
_common.encode(method), request_serializer, response_deserializer)
def stream_unary(self,
@@ -948,8 +938,7 @@ class Channel(grpc.Channel):
request_serializer=None,
response_deserializer=None):
return _StreamUnaryMultiCallable(
- self._channel,
- _channel_managed_call_management(self._call_state),
+ self._channel, _channel_managed_call_management(self._call_state),
_common.encode(method), request_serializer, response_deserializer)
def stream_stream(self,
@@ -957,8 +946,7 @@ class Channel(grpc.Channel):
request_serializer=None,
response_deserializer=None):
return _StreamStreamMultiCallable(
- self._channel,
- _channel_managed_call_management(self._call_state),
+ self._channel, _channel_managed_call_management(self._call_state),
_common.encode(method), request_serializer, response_deserializer)
def __del__(self):
diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py
index 740d4639db..bbb69ad489 100644
--- a/src/python/grpcio/grpc/_common.py
+++ b/src/python/grpcio/grpc/_common.py
@@ -22,8 +22,6 @@ import six
import grpc
from grpc._cython import cygrpc
-EMPTY_METADATA = cygrpc.Metadata(())
-
CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY = {
cygrpc.ConnectivityState.idle:
grpc.ChannelConnectivity.IDLE,
@@ -81,31 +79,6 @@ def decode(b):
return b.decode('latin1')
-def channel_args(options):
- cygrpc_args = []
- for key, value in options:
- if isinstance(value, six.string_types):
- cygrpc_args.append(cygrpc.ChannelArg(encode(key), encode(value)))
- else:
- cygrpc_args.append(cygrpc.ChannelArg(encode(key), value))
- return cygrpc.ChannelArgs(cygrpc_args)
-
-
-def to_cygrpc_metadata(application_metadata):
- return EMPTY_METADATA if application_metadata is None else cygrpc.Metadata(
- cygrpc.Metadatum(encode(key), encode(value))
- for key, value in application_metadata)
-
-
-def to_application_metadata(cygrpc_metadata):
- if cygrpc_metadata is None:
- return ()
- else:
- return tuple((decode(key), value
- if key[-4:] == b'-bin' else decode(value))
- for key, value in cygrpc_metadata)
-
-
def _transform(message, transformer, exception_message):
if transformer is None:
return message
diff --git a/src/python/grpcio/grpc/_credential_composition.py b/src/python/grpcio/grpc/_credential_composition.py
deleted file mode 100644
index f652cc3ae7..0000000000
--- a/src/python/grpcio/grpc/_credential_composition.py
+++ /dev/null
@@ -1,33 +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.
-
-from grpc._cython import cygrpc
-
-
-def _call(call_credentialses):
- call_credentials_iterator = iter(call_credentialses)
- composition = next(call_credentials_iterator)
- for additional_call_credentials in call_credentials_iterator:
- composition = cygrpc.call_credentials_composite(
- composition, additional_call_credentials)
- return composition
-
-
-def call(call_credentialses):
- return _call(call_credentialses)
-
-
-def channel(channel_credentials, call_credentialses):
- return cygrpc.channel_credentials_composite(channel_credentials,
- _call(call_credentialses))
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi
new file mode 100644
index 0000000000..853bf6f8e0
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi
@@ -0,0 +1,40 @@
+# 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.
+
+
+cdef void* _copy_pointer(void* pointer)
+
+
+cdef void _destroy_pointer(void* pointer)
+
+
+cdef int _compare_pointer(void* first_pointer, void* second_pointer)
+
+
+cdef class _ArgumentProcessor:
+
+ cdef grpc_arg c_argument
+
+ cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references)
+
+
+cdef class _ArgumentsProcessor:
+
+ cdef readonly tuple _arguments
+ cdef list _argument_processors
+ cdef readonly list _references
+ cdef grpc_channel_args _c_arguments
+
+ cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable)
+ cdef un_c(self)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi
new file mode 100644
index 0000000000..65de30884c
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi
@@ -0,0 +1,88 @@
+# 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.
+
+cimport cpython
+
+
+cdef void* _copy_pointer(void* pointer):
+ return pointer
+
+
+cdef void _destroy_pointer(void* pointer):
+ pass
+
+
+cdef int _compare_pointer(void* first_pointer, void* second_pointer):
+ if first_pointer < second_pointer:
+ return -1
+ elif first_pointer > second_pointer:
+ return 1
+ else:
+ return 0
+
+
+cdef class _ArgumentProcessor:
+
+ cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references):
+ key, value = argument
+ cdef bytes encoded_key = _encode(key)
+ if encoded_key is not key:
+ references.append(encoded_key)
+ self.c_argument.key = encoded_key
+ if isinstance(value, int):
+ self.c_argument.type = GRPC_ARG_INTEGER
+ self.c_argument.value.integer = value
+ elif isinstance(value, (bytes, str, unicode,)):
+ self.c_argument.type = GRPC_ARG_STRING
+ encoded_value = _encode(value)
+ if encoded_value is not value:
+ references.append(encoded_value)
+ self.c_argument.value.string = encoded_value
+ elif hasattr(value, '__int__'):
+ # Pointer objects must override __int__() to return
+ # the underlying C address (Python ints are word size). The
+ # lifecycle of the pointer is fixed to the lifecycle of the
+ # python object wrapping it.
+ self.c_argument.type = GRPC_ARG_POINTER
+ self.c_argument.value.pointer.vtable = vtable
+ self.c_argument.value.pointer.address = <void*>(<intptr_t>int(value))
+ else:
+ raise TypeError(
+ 'Expected int, bytes, or behavior, got {}'.format(type(value)))
+
+
+cdef class _ArgumentsProcessor:
+
+ def __cinit__(self, arguments):
+ self._arguments = () if arguments is None else tuple(arguments)
+ self._argument_processors = []
+ self._references = []
+
+ cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable):
+ self._c_arguments.arguments_length = len(self._arguments)
+ if self._c_arguments.arguments_length == 0:
+ return NULL
+ else:
+ self._c_arguments.arguments = <grpc_arg *>gpr_malloc(
+ self._c_arguments.arguments_length * sizeof(grpc_arg))
+ for index, argument in enumerate(self._arguments):
+ argument_processor = _ArgumentProcessor()
+ argument_processor.c(argument, vtable, self._references)
+ self._c_arguments.arguments[index] = argument_processor.c_argument
+ self._argument_processors.append(argument_processor)
+ return &self._c_arguments
+
+ cdef un_c(self):
+ if self._arguments:
+ gpr_free(self._c_arguments.arguments)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
index 752fb330d0..0892215b6d 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
@@ -26,20 +26,13 @@ cdef class Call:
def _start_batch(self, operations, tag, retain_self):
if not self.is_valid:
raise ValueError("invalid call object cannot be used from Python")
- cdef grpc_call_error result
- cdef Operations cy_operations = Operations(operations)
- cdef OperationTag operation_tag = OperationTag(tag)
- if retain_self:
- operation_tag.operation_call = self
- else:
- operation_tag.operation_call = None
- operation_tag.batch_operations = cy_operations
- cpython.Py_INCREF(operation_tag)
- with nogil:
- result = grpc_call_start_batch(
- self.c_call, cy_operations.c_ops, cy_operations.c_nops,
- <cpython.PyObject *>operation_tag, NULL)
- return result
+ cdef _BatchOperationTag batch_operation_tag = _BatchOperationTag(
+ tag, operations, self if retain_self else None)
+ batch_operation_tag.prepare()
+ cpython.Py_INCREF(batch_operation_tag)
+ return grpc_call_start_batch(
+ self.c_call, batch_operation_tag.c_ops, batch_operation_tag.c_nops,
+ <cpython.PyObject *>batch_operation_tag, NULL)
def start_client_batch(self, operations, tag):
# We don't reference this call in the operations tag because
@@ -72,13 +65,12 @@ cdef class Call:
result = grpc_call_cancel(self.c_call, NULL)
return result
- def set_credentials(
- self, CallCredentials call_credentials not None):
- cdef grpc_call_error result
- with nogil:
- result = grpc_call_set_credentials(
- self.c_call, call_credentials.c_credentials)
- return result
+ def set_credentials(self, CallCredentials call_credentials not None):
+ cdef grpc_call_credentials *c_call_credentials = call_credentials.c()
+ cdef grpc_call_error call_error = grpc_call_set_credentials(
+ self.c_call, c_call_credentials)
+ grpc_call_credentials_release(c_call_credentials)
+ return call_error
def peer(self):
cdef char *peer = NULL
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi
index 4b07e71cec..1ba76b7f83 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi
@@ -15,5 +15,7 @@
cdef class Channel:
+ cdef grpc_arg_pointer_vtable _vtable
cdef grpc_channel *c_channel
cdef list references
+ cdef readonly _ArgumentsProcessor _arguments_processor
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
index aeabdba021..a3966497bc 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
@@ -17,32 +17,31 @@ cimport cpython
cdef class Channel:
- def __cinit__(self, bytes target, ChannelArgs arguments,
+ def __cinit__(self, bytes target, object arguments,
ChannelCredentials channel_credentials=None):
grpc_init()
- cdef grpc_channel_args *c_arguments = NULL
- cdef char *c_target = NULL
- self.c_channel = NULL
+ self._vtable.copy = &_copy_pointer
+ self._vtable.destroy = &_destroy_pointer
+ self._vtable.cmp = &_compare_pointer
+ cdef _ArgumentsProcessor arguments_processor = _ArgumentsProcessor(
+ arguments)
+ cdef grpc_channel_args *c_arguments = arguments_processor.c(&self._vtable)
self.references = []
- if len(arguments) > 0:
- c_arguments = &arguments.c_args
- self.references.append(arguments)
c_target = target
if channel_credentials is None:
- with nogil:
- self.c_channel = grpc_insecure_channel_create(c_target, c_arguments,
- NULL)
+ self.c_channel = grpc_insecure_channel_create(c_target, c_arguments, NULL)
else:
- with nogil:
- self.c_channel = grpc_secure_channel_create(
- channel_credentials.c_credentials, c_target, c_arguments, NULL)
- self.references.append(channel_credentials)
+ c_channel_credentials = channel_credentials.c()
+ self.c_channel = grpc_secure_channel_create(
+ c_channel_credentials, c_target, c_arguments, NULL)
+ grpc_channel_credentials_release(c_channel_credentials)
+ arguments_processor.un_c()
self.references.append(target)
self.references.append(arguments)
def create_call(self, Call parent, int flags,
CompletionQueue queue not None,
- method, host, Timespec deadline not None):
+ method, host, object deadline):
if queue.is_shutting_down:
raise ValueError("queue must not be shutting down or shutdown")
cdef grpc_slice method_slice = _slice_from_bytes(method)
@@ -56,14 +55,13 @@ cdef class Channel:
cdef grpc_call *parent_call = NULL
if parent is not None:
parent_call = parent.c_call
- with nogil:
- operation_call.c_call = grpc_channel_create_call(
- self.c_channel, parent_call, flags,
- queue.c_completion_queue, method_slice, host_slice_ptr,
- deadline.c_time, NULL)
- grpc_slice_unref(method_slice)
- if host_slice_ptr:
- grpc_slice_unref(host_slice)
+ operation_call.c_call = grpc_channel_create_call(
+ self.c_channel, parent_call, flags,
+ queue.c_completion_queue, method_slice, host_slice_ptr,
+ _timespec_from_time(deadline), NULL)
+ grpc_slice_unref(method_slice)
+ if host_slice_ptr:
+ grpc_slice_unref(host_slice)
return operation_call
def check_connectivity_state(self, bint try_to_connect):
@@ -75,13 +73,12 @@ cdef class Channel:
def watch_connectivity_state(
self, grpc_connectivity_state last_observed_state,
- Timespec deadline not None, CompletionQueue queue not None, tag):
- cdef OperationTag operation_tag = OperationTag(tag)
- cpython.Py_INCREF(operation_tag)
- with nogil:
- grpc_channel_watch_connectivity_state(
- self.c_channel, last_observed_state, deadline.c_time,
- queue.c_completion_queue, <cpython.PyObject *>operation_tag)
+ object deadline, CompletionQueue queue not None, tag):
+ cdef _ConnectivityTag connectivity_tag = _ConnectivityTag(tag)
+ cpython.Py_INCREF(connectivity_tag)
+ grpc_channel_watch_connectivity_state(
+ self.c_channel, last_observed_state, _timespec_from_time(deadline),
+ queue.c_completion_queue, <cpython.PyObject *>connectivity_tag)
def target(self):
cdef char *target = NULL
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
index 237f430799..40496d1124 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
@@ -37,53 +37,33 @@ cdef class CompletionQueue:
self.is_shutdown = False
cdef _interpret_event(self, grpc_event event):
- cdef OperationTag tag = None
- cdef object user_tag = None
- cdef Call operation_call = None
- cdef CallDetails request_call_details = None
- cdef object request_metadata = None
- cdef Operations batch_operations = None
+ cdef _Tag tag = None
if event.type == GRPC_QUEUE_TIMEOUT:
- return Event(
- event.type, False, None, None, None, None, False, None)
+ # NOTE(nathaniel): For now we coopt ConnectivityEvent here.
+ return ConnectivityEvent(GRPC_QUEUE_TIMEOUT, False, None)
elif event.type == GRPC_QUEUE_SHUTDOWN:
self.is_shutdown = True
- return Event(
- event.type, True, None, None, None, None, False, None)
+ # NOTE(nathaniel): For now we coopt ConnectivityEvent here.
+ return ConnectivityEvent(GRPC_QUEUE_TIMEOUT, True, None)
else:
- if event.tag != NULL:
- tag = <OperationTag>event.tag
- # We receive event tags only after they've been inc-ref'd elsewhere in
- # the code.
- cpython.Py_DECREF(tag)
- if tag.shutting_down_server is not None:
- tag.shutting_down_server.notify_shutdown_complete()
- user_tag = tag.user_tag
- operation_call = tag.operation_call
- request_call_details = tag.request_call_details
- if tag.request_metadata is not None:
- request_metadata = tuple(tag.request_metadata)
- batch_operations = tag.batch_operations
- if tag.is_new_request:
- # Stuff in the tag not explicitly handled by us needs to live through
- # the life of the call
- operation_call.references.extend(tag.references)
- return Event(
- event.type, event.success, user_tag, operation_call,
- request_call_details, request_metadata, tag.is_new_request,
- batch_operations)
+ tag = <_Tag>event.tag
+ # We receive event tags only after they've been inc-ref'd elsewhere in
+ # the code.
+ cpython.Py_DECREF(tag)
+ return tag.event(event)
- def poll(self, Timespec deadline=None):
+ def poll(self, deadline=None):
# We name this 'poll' to avoid problems with CPython's expectations for
# 'special' methods (like next and __next__).
cdef gpr_timespec c_increment
cdef gpr_timespec c_timeout
cdef gpr_timespec c_deadline
+ if deadline is None:
+ c_deadline = gpr_inf_future(GPR_CLOCK_REALTIME)
+ else:
+ c_deadline = _timespec_from_time(deadline)
with nogil:
c_increment = gpr_time_from_millis(_INTERRUPT_CHECK_PERIOD_MS, GPR_TIMESPAN)
- c_deadline = gpr_inf_future(GPR_CLOCK_REALTIME)
- if deadline is not None:
- c_deadline = deadline.c_time
while True:
c_timeout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c_increment)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi
index a0e69dd613..7e9ea33ca0 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi
@@ -12,45 +12,86 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cimport cpython
+cdef class CallCredentials:
-cdef class ChannelCredentials:
+ cdef grpc_call_credentials *c(self)
- cdef grpc_channel_credentials *c_credentials
- cdef grpc_ssl_pem_key_cert_pair c_ssl_pem_key_cert_pair
- cdef list references
+ # TODO(https://github.com/grpc/grpc/issues/12531): remove.
+ cdef grpc_call_credentials *c_credentials
-cdef class CallCredentials:
+cdef int _get_metadata(
+ void *state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t *num_creds_md, grpc_status_code *status,
+ const char **error_details) with gil
- cdef grpc_call_credentials *c_credentials
- cdef list references
+cdef void _destroy(void *state) with gil
-cdef class ServerCredentials:
+cdef class MetadataPluginCallCredentials(CallCredentials):
- cdef grpc_server_credentials *c_credentials
- cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs
- cdef size_t c_ssl_pem_key_cert_pairs_count
- cdef list references
+ cdef readonly object _metadata_plugin
+ cdef readonly bytes _name
+ cdef grpc_call_credentials *c(self)
-cdef class CredentialsMetadataPlugin:
- cdef object plugin_callback
- cdef bytes plugin_name
+cdef grpc_call_credentials *_composition(call_credentialses)
- cdef grpc_metadata_credentials_plugin make_c_plugin(self)
+cdef class CompositeCallCredentials(CallCredentials):
-cdef class AuthMetadataContext:
+ cdef readonly tuple _call_credentialses
- cdef grpc_auth_metadata_context context
+ cdef grpc_call_credentials *c(self)
-cdef void plugin_get_metadata(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data) with gil
+cdef class ChannelCredentials:
+
+ cdef grpc_channel_credentials *c(self)
+
+ # TODO(https://github.com/grpc/grpc/issues/12531): remove.
+ cdef grpc_channel_credentials *c_credentials
+
-cdef void plugin_destroy_c_plugin_state(void *state) with gil
+cdef class SSLChannelCredentials(ChannelCredentials):
+
+ cdef readonly object _pem_root_certificates
+ cdef readonly object _private_key
+ cdef readonly object _certificate_chain
+
+ cdef grpc_channel_credentials *c(self)
+
+
+cdef class CompositeChannelCredentials(ChannelCredentials):
+
+ cdef readonly tuple _call_credentialses
+ cdef readonly ChannelCredentials _channel_credentials
+
+ cdef grpc_channel_credentials *c(self)
+
+
+cdef class ServerCertificateConfig:
+
+ cdef grpc_ssl_server_certificate_config *c_cert_config
+ cdef const char *c_pem_root_certs
+ cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs
+ cdef size_t c_ssl_pem_key_cert_pairs_count
+ cdef list references
+
+
+cdef class ServerCredentials:
+
+ cdef grpc_server_credentials *c_credentials
+ cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs
+ cdef size_t c_ssl_pem_key_cert_pairs_count
+ cdef list references
+ # the cert config related state is used only if this credentials is
+ # created with cert config/fetcher
+ cdef object initial_cert_config
+ cdef object cert_config_fetcher
+ # whether C-core has asked for the initial_cert_config
+ cdef bint initial_cert_config_fetched
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
index 57816f1cab..500086f6cb 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
@@ -14,267 +14,241 @@
cimport cpython
-import traceback
+import grpc
+import threading
-cdef class ChannelCredentials:
+cdef class CallCredentials:
- def __cinit__(self):
- grpc_init()
- self.c_credentials = NULL
- self.c_ssl_pem_key_cert_pair.private_key = NULL
- self.c_ssl_pem_key_cert_pair.certificate_chain = NULL
- self.references = []
+ cdef grpc_call_credentials *c(self):
+ raise NotImplementedError()
- # The object *can* be invalid in Python if we fail to make the credentials
- # (and the core thus returns NULL credentials). Used primarily for debugging.
- @property
- def is_valid(self):
- return self.c_credentials != NULL
- def __dealloc__(self):
- if self.c_credentials != NULL:
- grpc_channel_credentials_release(self.c_credentials)
- grpc_shutdown()
+cdef int _get_metadata(
+ void *state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t *num_creds_md, grpc_status_code *status,
+ const char **error_details) with gil:
+ cdef size_t metadata_count
+ cdef grpc_metadata *c_metadata
+ def callback(metadata, grpc_status_code status, bytes error_details):
+ if status is StatusCode.ok:
+ _store_c_metadata(metadata, &c_metadata, &metadata_count)
+ cb(user_data, c_metadata, metadata_count, status, NULL)
+ _release_c_metadata(c_metadata, metadata_count)
+ else:
+ cb(user_data, NULL, 0, status, error_details)
+ args = context.service_url, context.method_name, callback,
+ threading.Thread(target=<object>state, args=args).start()
+ return 0 # Asynchronous return
+
+
+cdef void _destroy(void *state) with gil:
+ cpython.Py_DECREF(<object>state)
+
+
+cdef class MetadataPluginCallCredentials(CallCredentials):
+
+ def __cinit__(self, metadata_plugin, name):
+ self._metadata_plugin = metadata_plugin
+ self._name = name
+
+ cdef grpc_call_credentials *c(self):
+ cdef grpc_metadata_credentials_plugin c_metadata_plugin
+ c_metadata_plugin.get_metadata = _get_metadata
+ c_metadata_plugin.destroy = _destroy
+ c_metadata_plugin.state = <void *>self._metadata_plugin
+ c_metadata_plugin.type = self._name
+ cpython.Py_INCREF(self._metadata_plugin)
+ return grpc_metadata_credentials_create_from_plugin(c_metadata_plugin, NULL)
+
+
+cdef grpc_call_credentials *_composition(call_credentialses):
+ call_credentials_iterator = iter(call_credentialses)
+ cdef CallCredentials composition = next(call_credentials_iterator)
+ cdef grpc_call_credentials *c_composition = composition.c()
+ cdef CallCredentials additional_call_credentials
+ cdef grpc_call_credentials *c_additional_call_credentials
+ cdef grpc_call_credentials *c_next_composition
+ for additional_call_credentials in call_credentials_iterator:
+ c_additional_call_credentials = additional_call_credentials.c()
+ c_next_composition = grpc_composite_call_credentials_create(
+ c_composition, c_additional_call_credentials, NULL)
+ grpc_call_credentials_release(c_composition)
+ grpc_call_credentials_release(c_additional_call_credentials)
+ c_composition = c_next_composition
+ return c_composition
+
+
+cdef class CompositeCallCredentials(CallCredentials):
+
+ def __cinit__(self, call_credentialses):
+ self._call_credentialses = call_credentialses
+
+ cdef grpc_call_credentials *c(self):
+ return _composition(self._call_credentialses)
-cdef class CallCredentials:
+cdef class ChannelCredentials:
- def __cinit__(self):
- grpc_init()
- self.c_credentials = NULL
- self.references = []
+ cdef grpc_channel_credentials *c(self):
+ raise NotImplementedError()
- # The object *can* be invalid in Python if we fail to make the credentials
- # (and the core thus returns NULL credentials). Used primarily for debugging.
- @property
- def is_valid(self):
- return self.c_credentials != NULL
- def __dealloc__(self):
- if self.c_credentials != NULL:
- grpc_call_credentials_release(self.c_credentials)
- grpc_shutdown()
+cdef class SSLChannelCredentials(ChannelCredentials):
+ def __cinit__(self, pem_root_certificates, private_key, certificate_chain):
+ self._pem_root_certificates = pem_root_certificates
+ self._private_key = private_key
+ self._certificate_chain = certificate_chain
-cdef class ServerCredentials:
+ cdef grpc_channel_credentials *c(self):
+ cdef const char *c_pem_root_certificates
+ cdef grpc_ssl_pem_key_cert_pair c_pem_key_certificate_pair
+ if self._pem_root_certificates is None:
+ c_pem_root_certificates = NULL
+ else:
+ c_pem_root_certificates = self._pem_root_certificates
+ if self._private_key is None and self._certificate_chain is None:
+ return grpc_ssl_credentials_create(
+ c_pem_root_certificates, NULL, NULL)
+ else:
+ c_pem_key_certificate_pair.private_key = self._private_key
+ c_pem_key_certificate_pair.certificate_chain = self._certificate_chain
+ return grpc_ssl_credentials_create(
+ c_pem_root_certificates, &c_pem_key_certificate_pair, NULL)
- def __cinit__(self):
- grpc_init()
- self.c_credentials = NULL
- self.references = []
- def __dealloc__(self):
- if self.c_credentials != NULL:
- grpc_server_credentials_release(self.c_credentials)
- grpc_shutdown()
+cdef class CompositeChannelCredentials(ChannelCredentials):
+
+ def __cinit__(self, call_credentialses, channel_credentials):
+ self._call_credentialses = call_credentialses
+ self._channel_credentials = channel_credentials
+
+ cdef grpc_channel_credentials *c(self):
+ cdef grpc_channel_credentials *c_channel_credentials
+ c_channel_credentials = self._channel_credentials.c()
+ cdef grpc_call_credentials *c_call_credentials_composition = _composition(
+ self._call_credentialses)
+ cdef grpc_channel_credentials *composition
+ c_composition = grpc_composite_channel_credentials_create(
+ c_channel_credentials, c_call_credentials_composition, NULL)
+ grpc_channel_credentials_release(c_channel_credentials)
+ grpc_call_credentials_release(c_call_credentials_composition)
+ return c_composition
-cdef class CredentialsMetadataPlugin:
+cdef class ServerCertificateConfig:
- def __cinit__(self, object plugin_callback, bytes name):
- """
- Args:
- plugin_callback (callable): Callback accepting a service URL (str/bytes)
- and callback object (accepting a MetadataArray,
- grpc_status_code, and a str/bytes error message). This argument
- when called should be non-blocking and eventually call the callback
- object with the appropriate status code/details and metadata (if
- successful).
- name (bytes): Plugin name.
- """
+ def __cinit__(self):
grpc_init()
- if not callable(plugin_callback):
- raise ValueError('expected callable plugin_callback')
- self.plugin_callback = plugin_callback
- self.plugin_name = name
-
- @staticmethod
- cdef grpc_metadata_credentials_plugin make_c_plugin(self):
- cdef grpc_metadata_credentials_plugin result
- result.get_metadata = plugin_get_metadata
- result.destroy = plugin_destroy_c_plugin_state
- result.state = <void *>self
- result.type = self.plugin_name
- cpython.Py_INCREF(self)
- return result
+ self.c_cert_config = NULL
+ self.c_pem_root_certs = NULL
+ self.c_ssl_pem_key_cert_pairs = NULL
+ self.references = []
def __dealloc__(self):
+ grpc_ssl_server_certificate_config_destroy(self.c_cert_config)
+ gpr_free(self.c_ssl_pem_key_cert_pairs)
grpc_shutdown()
-cdef class AuthMetadataContext:
+cdef class ServerCredentials:
def __cinit__(self):
grpc_init()
- self.context.service_url = NULL
- self.context.method_name = NULL
-
- @property
- def service_url(self):
- return self.context.service_url
-
- @property
- def method_name(self):
- return self.context.method_name
+ self.c_credentials = NULL
+ self.references = []
+ self.initial_cert_config = None
+ self.cert_config_fetcher = None
+ self.initial_cert_config_fetched = False
def __dealloc__(self):
+ if self.c_credentials != NULL:
+ grpc_server_credentials_release(self.c_credentials)
grpc_shutdown()
-
-cdef void plugin_get_metadata(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data) with gil:
- called_flag = [False]
- def python_callback(
- Metadata metadata, grpc_status_code status,
- bytes error_details):
- cb(user_data, metadata.c_metadata, metadata.c_count, status, error_details)
- called_flag[0] = True
- cdef CredentialsMetadataPlugin self = <CredentialsMetadataPlugin>state
- cdef AuthMetadataContext cy_context = AuthMetadataContext()
- cy_context.context = context
- try:
- self.plugin_callback(cy_context, python_callback)
- except Exception as error:
- if not called_flag[0]:
- cb(user_data, NULL, 0, StatusCode.unknown,
- traceback.format_exc().encode())
-
-cdef void plugin_destroy_c_plugin_state(void *state) with gil:
- cpython.Py_DECREF(<CredentialsMetadataPlugin>state)
-
-def channel_credentials_google_default():
- cdef ChannelCredentials credentials = ChannelCredentials();
- with nogil:
- credentials.c_credentials = grpc_google_default_credentials_create()
- return credentials
-
-def channel_credentials_ssl(pem_root_certificates,
- SslPemKeyCertPair ssl_pem_key_cert_pair):
- pem_root_certificates = str_to_bytes(pem_root_certificates)
- cdef ChannelCredentials credentials = ChannelCredentials()
- cdef const char *c_pem_root_certificates = NULL
- if pem_root_certificates is not None:
- c_pem_root_certificates = pem_root_certificates
- credentials.references.append(pem_root_certificates)
- if ssl_pem_key_cert_pair is not None:
- with nogil:
- credentials.c_credentials = grpc_ssl_credentials_create(
- c_pem_root_certificates, &ssl_pem_key_cert_pair.c_pair, NULL)
- credentials.references.append(ssl_pem_key_cert_pair)
+cdef const char* _get_c_pem_root_certs(pem_root_certs):
+ if pem_root_certs is None:
+ return NULL
else:
- with nogil:
- credentials.c_credentials = grpc_ssl_credentials_create(
- c_pem_root_certificates, NULL, NULL)
- return credentials
-
-def channel_credentials_composite(
- ChannelCredentials credentials_1 not None,
- CallCredentials credentials_2 not None):
- if not credentials_1.is_valid or not credentials_2.is_valid:
- raise ValueError("passed credentials must both be valid")
- cdef ChannelCredentials credentials = ChannelCredentials()
- with nogil:
- credentials.c_credentials = grpc_composite_channel_credentials_create(
- credentials_1.c_credentials, credentials_2.c_credentials, NULL)
- credentials.references.append(credentials_1)
- credentials.references.append(credentials_2)
- return credentials
-
-def call_credentials_composite(
- CallCredentials credentials_1 not None,
- CallCredentials credentials_2 not None):
- if not credentials_1.is_valid or not credentials_2.is_valid:
- raise ValueError("passed credentials must both be valid")
- cdef CallCredentials credentials = CallCredentials()
- with nogil:
- credentials.c_credentials = grpc_composite_call_credentials_create(
- credentials_1.c_credentials, credentials_2.c_credentials, NULL)
- credentials.references.append(credentials_1)
- credentials.references.append(credentials_2)
- return credentials
-
-def call_credentials_google_compute_engine():
- cdef CallCredentials credentials = CallCredentials()
- with nogil:
- credentials.c_credentials = (
- grpc_google_compute_engine_credentials_create(NULL))
- return credentials
-
-def call_credentials_service_account_jwt_access(
- json_key, Timespec token_lifetime not None):
- json_key = str_to_bytes(json_key)
- cdef CallCredentials credentials = CallCredentials()
- cdef char *json_key_c_string = json_key
- with nogil:
- credentials.c_credentials = (
- grpc_service_account_jwt_access_credentials_create(
- json_key_c_string, token_lifetime.c_time, NULL))
- credentials.references.append(json_key)
- return credentials
-
-def call_credentials_google_refresh_token(json_refresh_token):
- json_refresh_token = str_to_bytes(json_refresh_token)
- cdef CallCredentials credentials = CallCredentials()
- cdef char *json_refresh_token_c_string = json_refresh_token
- with nogil:
- credentials.c_credentials = grpc_google_refresh_token_credentials_create(
- json_refresh_token_c_string, NULL)
- credentials.references.append(json_refresh_token)
- return credentials
+ return pem_root_certs
-def call_credentials_google_iam(authorization_token, authority_selector):
- authorization_token = str_to_bytes(authorization_token)
- authority_selector = str_to_bytes(authority_selector)
- cdef CallCredentials credentials = CallCredentials()
- cdef char *authorization_token_c_string = authorization_token
- cdef char *authority_selector_c_string = authority_selector
- with nogil:
- credentials.c_credentials = grpc_google_iam_credentials_create(
- authorization_token_c_string, authority_selector_c_string, NULL)
- credentials.references.append(authorization_token)
- credentials.references.append(authority_selector)
- return credentials
-
-def call_credentials_metadata_plugin(CredentialsMetadataPlugin plugin):
- cdef CallCredentials credentials = CallCredentials()
- cdef grpc_metadata_credentials_plugin c_plugin = plugin.make_c_plugin()
+cdef grpc_ssl_pem_key_cert_pair* _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs):
+ # return a malloc'ed grpc_ssl_pem_key_cert_pair from a _list_ of SslPemKeyCertPair
+ for pair in pem_key_cert_pairs:
+ if not isinstance(pair, SslPemKeyCertPair):
+ raise TypeError("expected pem_key_cert_pairs to be sequence of "
+ "SslPemKeyCertPair")
+ cdef size_t c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs)
+ cdef grpc_ssl_pem_key_cert_pair* c_ssl_pem_key_cert_pairs = NULL
with nogil:
- credentials.c_credentials = (
- grpc_metadata_credentials_create_from_plugin(c_plugin, NULL))
- # TODO(atash): the following held reference is *probably* never necessary
- credentials.references.append(plugin)
- return credentials
+ c_ssl_pem_key_cert_pairs = (
+ <grpc_ssl_pem_key_cert_pair *>gpr_malloc(
+ sizeof(grpc_ssl_pem_key_cert_pair) * c_ssl_pem_key_cert_pairs_count))
+ for i in range(c_ssl_pem_key_cert_pairs_count):
+ c_ssl_pem_key_cert_pairs[i] = (
+ (<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair)
+ return c_ssl_pem_key_cert_pairs
def server_credentials_ssl(pem_root_certs, pem_key_cert_pairs,
bint force_client_auth):
pem_root_certs = str_to_bytes(pem_root_certs)
- cdef char *c_pem_root_certs = NULL
- if pem_root_certs is not None:
- c_pem_root_certs = pem_root_certs
pem_key_cert_pairs = list(pem_key_cert_pairs)
- for pair in pem_key_cert_pairs:
- if not isinstance(pair, SslPemKeyCertPair):
- raise TypeError("expected pem_key_cert_pairs to be sequence of "
- "SslPemKeyCertPair")
cdef ServerCredentials credentials = ServerCredentials()
- credentials.references.append(pem_key_cert_pairs)
credentials.references.append(pem_root_certs)
+ credentials.references.append(pem_key_cert_pairs)
+ cdef const char * c_pem_root_certs = _get_c_pem_root_certs(pem_root_certs)
credentials.c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs)
- with nogil:
- credentials.c_ssl_pem_key_cert_pairs = (
- <grpc_ssl_pem_key_cert_pair *>gpr_malloc(
- sizeof(grpc_ssl_pem_key_cert_pair) *
- credentials.c_ssl_pem_key_cert_pairs_count
- ))
- for i in range(credentials.c_ssl_pem_key_cert_pairs_count):
- credentials.c_ssl_pem_key_cert_pairs[i] = (
- (<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair)
- credentials.c_credentials = grpc_ssl_server_credentials_create(
- c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs,
- credentials.c_ssl_pem_key_cert_pairs_count,
- GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY if force_client_auth else GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
- NULL)
+ credentials.c_ssl_pem_key_cert_pairs = _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs)
+ cdef grpc_ssl_server_certificate_config *c_cert_config = NULL
+ c_cert_config = grpc_ssl_server_certificate_config_create(
+ c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs,
+ credentials.c_ssl_pem_key_cert_pairs_count)
+ cdef grpc_ssl_server_credentials_options* c_options = NULL
+ # C-core assumes ownership of c_cert_config
+ c_options = grpc_ssl_server_credentials_create_options_using_config(
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ if force_client_auth else
+ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ c_cert_config)
+ # C-core assumes ownership of c_options
+ credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options)
return credentials
+def server_certificate_config_ssl(pem_root_certs, pem_key_cert_pairs):
+ pem_root_certs = str_to_bytes(pem_root_certs)
+ pem_key_cert_pairs = list(pem_key_cert_pairs)
+ cdef ServerCertificateConfig cert_config = ServerCertificateConfig()
+ cert_config.references.append(pem_root_certs)
+ cert_config.references.append(pem_key_cert_pairs)
+ cert_config.c_pem_root_certs = _get_c_pem_root_certs(pem_root_certs)
+ cert_config.c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs)
+ cert_config.c_ssl_pem_key_cert_pairs = _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs)
+ cert_config.c_cert_config = grpc_ssl_server_certificate_config_create(
+ cert_config.c_pem_root_certs, cert_config.c_ssl_pem_key_cert_pairs,
+ cert_config.c_ssl_pem_key_cert_pairs_count)
+ return cert_config
+
+def server_credentials_ssl_dynamic_cert_config(initial_cert_config,
+ cert_config_fetcher,
+ bint force_client_auth):
+ if not isinstance(initial_cert_config, grpc.ServerCertificateConfiguration):
+ raise TypeError(
+ 'initial_cert_config must be a grpc.ServerCertificateConfiguration')
+ if not callable(cert_config_fetcher):
+ raise TypeError('cert_config_fetcher must be callable')
+ cdef ServerCredentials credentials = ServerCredentials()
+ credentials.initial_cert_config = initial_cert_config
+ credentials.cert_config_fetcher = cert_config_fetcher
+ cdef grpc_ssl_server_credentials_options* c_options = NULL
+ c_options = grpc_ssl_server_credentials_create_options_using_config_fetcher(
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ if force_client_auth else
+ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ _server_cert_config_fetcher_wrapper,
+ <void*>credentials)
+ # C-core assumes ownership of c_options
+ credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options)
+ return credentials
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi
new file mode 100644
index 0000000000..686199ecf4
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi
@@ -0,0 +1,45 @@
+# 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.
+
+
+cdef class ConnectivityEvent:
+
+ cdef readonly grpc_completion_type completion_type
+ cdef readonly bint success
+ cdef readonly object tag
+
+
+cdef class RequestCallEvent:
+
+ cdef readonly grpc_completion_type completion_type
+ cdef readonly bint success
+ cdef readonly object tag
+ cdef readonly Call call
+ cdef readonly CallDetails call_details
+ cdef readonly tuple invocation_metadata
+
+
+cdef class BatchOperationEvent:
+
+ cdef readonly grpc_completion_type completion_type
+ cdef readonly bint success
+ cdef readonly object tag
+ cdef readonly object batch_operations
+
+
+cdef class ServerShutdownEvent:
+
+ cdef readonly grpc_completion_type completion_type
+ cdef readonly bint success
+ cdef readonly object tag
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi
new file mode 100644
index 0000000000..af26d27318
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi
@@ -0,0 +1,55 @@
+# 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.
+
+
+cdef class ConnectivityEvent:
+
+ def __cinit__(
+ self, grpc_completion_type completion_type, bint success, object tag):
+ self.completion_type = completion_type
+ self.success = success
+ self.tag = tag
+
+
+cdef class RequestCallEvent:
+
+ def __cinit__(
+ self, grpc_completion_type completion_type, bint success, object tag,
+ Call call, CallDetails call_details, tuple invocation_metadata):
+ self.completion_type = completion_type
+ self.success = success
+ self.tag = tag
+ self.call = call
+ self.call_details = call_details
+ self.invocation_metadata = invocation_metadata
+
+
+cdef class BatchOperationEvent:
+
+ def __cinit__(
+ self, grpc_completion_type completion_type, bint success, object tag,
+ object batch_operations):
+ self.completion_type = completion_type
+ self.success = success
+ self.tag = tag
+ self.batch_operations = batch_operations
+
+
+cdef class ServerShutdownEvent:
+
+ def __cinit__(
+ self, grpc_completion_type completion_type, bint success, object tag):
+ self.completion_type = completion_type
+ self.success = success
+ self.tag = tag
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
index 840af5c43a..30253fc20c 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
@@ -17,6 +17,7 @@ cimport libc.time
# Typedef types with approximately the same semantics to provide their names to
# Cython
+ctypedef unsigned char uint8_t
ctypedef int int32_t
ctypedef unsigned uint32_t
ctypedef long int64_t
@@ -25,6 +26,7 @@ ctypedef long int64_t
cdef extern from "grpc/support/alloc.h":
void *gpr_malloc(size_t size) nogil
+ void *gpr_zalloc(size_t size) nogil
void gpr_free(void *ptr) nogil
void *gpr_realloc(void *p, size_t size) nogil
@@ -36,13 +38,6 @@ cdef extern from "grpc/byte_buffer_reader.h":
pass
-cdef extern from "grpc/impl/codegen/exec_ctx_fwd.h":
-
- struct grpc_exec_ctx:
- # We don't care about the internals
- pass
-
-
cdef extern from "grpc/grpc.h":
ctypedef struct grpc_slice:
@@ -169,7 +164,7 @@ cdef extern from "grpc/grpc.h":
ctypedef struct grpc_arg_pointer_vtable:
void *(*copy)(void *)
- void (*destroy)(grpc_exec_ctx *, void *)
+ void (*destroy)(void *)
int (*cmp)(void *, void *)
ctypedef struct grpc_arg_value_pointer:
@@ -190,6 +185,18 @@ cdef extern from "grpc/grpc.h":
size_t arguments_length "num_args"
grpc_arg *arguments "args"
+ ctypedef enum grpc_compression_level:
+ GRPC_COMPRESS_LEVEL_NONE
+ GRPC_COMPRESS_LEVEL_LOW
+ GRPC_COMPRESS_LEVEL_MED
+ GRPC_COMPRESS_LEVEL_HIGH
+
+ ctypedef enum grpc_stream_compression_level:
+ GRPC_STREAM_COMPRESS_LEVEL_NONE
+ GRPC_STREAM_COMPRESS_LEVEL_LOW
+ GRPC_STREAM_COMPRESS_LEVEL_MED
+ GRPC_STREAM_COMPRESS_LEVEL_HIGH
+
ctypedef enum grpc_call_error:
GRPC_CALL_OK
GRPC_CALL_ERROR
@@ -265,9 +272,14 @@ cdef extern from "grpc/grpc.h":
GRPC_OP_RECV_STATUS_ON_CLIENT
GRPC_OP_RECV_CLOSE_ON_SERVER
+ ctypedef struct grpc_op_send_initial_metadata_maybe_compression_level:
+ uint8_t is_set
+ grpc_compression_level level
+
ctypedef struct grpc_op_data_send_initial_metadata:
size_t count
grpc_metadata *metadata
+ grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level
ctypedef struct grpc_op_data_send_status_from_server:
size_t trailing_metadata_count
@@ -375,6 +387,10 @@ cdef extern from "grpc/grpc.h":
cdef extern from "grpc/grpc_security.h":
+ # Declare this as an enum, this is the only way to make it a const in
+ # cython
+ enum: GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX
+
ctypedef enum grpc_ssl_roots_override_result:
GRPC_SSL_ROOTS_OVERRIDE_OK
GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY
@@ -387,6 +403,42 @@ cdef extern from "grpc/grpc_security.h":
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ ctypedef enum grpc_ssl_certificate_config_reload_status:
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW
+ GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL
+
+ ctypedef struct grpc_ssl_server_certificate_config:
+ # We don't care about the internals
+ pass
+
+ ctypedef struct grpc_ssl_server_credentials_options:
+ # We don't care about the internals
+ pass
+
+ grpc_ssl_server_certificate_config * grpc_ssl_server_certificate_config_create(
+ const char *pem_root_certs,
+ const grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
+ size_t num_key_cert_pairs)
+
+ void grpc_ssl_server_certificate_config_destroy(grpc_ssl_server_certificate_config *config)
+
+ ctypedef grpc_ssl_certificate_config_reload_status (*grpc_ssl_server_certificate_config_callback)(
+ void *user_data,
+ grpc_ssl_server_certificate_config **config)
+
+ grpc_ssl_server_credentials_options *grpc_ssl_server_credentials_create_options_using_config(
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_certificate_config *certificate_config)
+
+ grpc_ssl_server_credentials_options* grpc_ssl_server_credentials_create_options_using_config_fetcher(
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ grpc_ssl_server_certificate_config_callback cb,
+ void *user_data)
+
+ grpc_server_credentials *grpc_ssl_server_credentials_create_with_options(
+ grpc_ssl_server_credentials_options *options)
+
ctypedef struct grpc_ssl_pem_key_cert_pair:
const char *private_key
const char *certificate_chain "cert_chain"
@@ -436,10 +488,6 @@ cdef extern from "grpc/grpc_security.h":
# We don't care about the internals (and in fact don't know them)
pass
- grpc_server_credentials *grpc_ssl_server_credentials_create(
- const char *pem_root_certs,
- grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, int force_client_auth, void *reserved)
void grpc_server_credentials_release(grpc_server_credentials *creds) nogil
int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
@@ -462,9 +510,12 @@ cdef extern from "grpc/grpc_security.h":
grpc_status_code status, const char *error_details)
ctypedef struct grpc_metadata_credentials_plugin:
- void (*get_metadata)(
+ int (*get_metadata)(
void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data)
+ grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t *num_creds_md, grpc_status_code *status,
+ const char **error_details)
void (*destroy)(void *state)
void *state
const char *type
@@ -485,7 +536,7 @@ cdef extern from "grpc/grpc_security.h":
grpc_auth_property_iterator grpc_auth_context_property_iterator(
const grpc_auth_context *ctx)
-
+
grpc_auth_property_iterator grpc_auth_context_peer_identity(
const grpc_auth_context *ctx)
@@ -506,8 +557,9 @@ cdef extern from "grpc/compression.h":
ctypedef enum grpc_compression_algorithm:
GRPC_COMPRESS_NONE
- GRPC_COMPRESS_DEFLATE
- GRPC_COMPRESS_GZIP
+ GRPC_COMPRESS_MESSAGE_DEFLATE
+ GRPC_COMPRESS_MESSAGE_GZIP
+ GRPC_COMPRESS_STREAM_GZIP
GRPC_COMPRESS_ALGORITHMS_COUNT
ctypedef enum grpc_compression_level:
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi
index c8f11f8e19..53e06a1596 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import logging
+
# This function will ascii encode unicode string inputs if neccesary.
# In Python3, unicode strings are the default str type.
@@ -22,3 +24,30 @@ cdef bytes str_to_bytes(object s):
return s.encode('ascii')
else:
raise TypeError('Expected bytes, str, or unicode, not {}'.format(type(s)))
+
+
+# TODO(https://github.com/grpc/grpc/issues/13782): It would be nice for us if
+# the type of metadata that we accept were exactly the same as the type of
+# metadata that we deliver to our users (so "str" for this function's
+# parameter rather than "object"), but would it be nice for our users? Right
+# now we haven't yet heard from enough users to know one way or another.
+cdef bytes _encode(object string_or_none):
+ if string_or_none is None:
+ return b''
+ elif isinstance(string_or_none, (bytes,)):
+ return <bytes>string_or_none
+ elif isinstance(string_or_none, (unicode,)):
+ return string_or_none.encode('ascii')
+ else:
+ raise TypeError('Expected str, not {}'.format(type(string_or_none)))
+
+
+cdef str _decode(bytes bytestring):
+ if isinstance(bytestring, (str,)):
+ return <str>bytestring
+ else:
+ try:
+ return bytestring.decode('utf8')
+ except UnicodeDecodeError:
+ logging.exception('Invalid encoding on %s', bytestring)
+ return bytestring.decode('latin1')
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi
new file mode 100644
index 0000000000..a18c365807
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi
@@ -0,0 +1,26 @@
+# 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.
+
+
+cdef void _store_c_metadata(
+ metadata, grpc_metadata **c_metadata, size_t *c_count)
+
+
+cdef void _release_c_metadata(grpc_metadata *c_metadata, int count)
+
+
+cdef tuple _metadatum(grpc_slice key_slice, grpc_slice value_slice)
+
+
+cdef tuple _metadata(grpc_metadata_array *c_metadata_array)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi
new file mode 100644
index 0000000000..c39fef08fa
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi
@@ -0,0 +1,62 @@
+# Copyright 2017 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import collections
+
+
+_Metadatum = collections.namedtuple('_Metadatum', ('key', 'value',))
+
+
+cdef void _store_c_metadata(
+ metadata, grpc_metadata **c_metadata, size_t *c_count):
+ if metadata is None:
+ c_count[0] = 0
+ c_metadata[0] = NULL
+ else:
+ metadatum_count = len(metadata)
+ if metadatum_count == 0:
+ c_count[0] = 0
+ c_metadata[0] = NULL
+ else:
+ c_count[0] = metadatum_count
+ c_metadata[0] = <grpc_metadata *>gpr_malloc(
+ metadatum_count * sizeof(grpc_metadata))
+ for index, (key, value) in enumerate(metadata):
+ encoded_key = _encode(key)
+ encoded_value = value if encoded_key[-4:] == b'-bin' else _encode(value)
+ c_metadata[0][index].key = _slice_from_bytes(encoded_key)
+ c_metadata[0][index].value = _slice_from_bytes(encoded_value)
+
+
+cdef void _release_c_metadata(grpc_metadata *c_metadata, int count):
+ if 0 < count:
+ for index in range(count):
+ grpc_slice_unref(c_metadata[index].key)
+ grpc_slice_unref(c_metadata[index].value)
+ gpr_free(c_metadata)
+
+
+cdef tuple _metadatum(grpc_slice key_slice, grpc_slice value_slice):
+ cdef bytes key = _slice_bytes(key_slice)
+ cdef bytes value = _slice_bytes(value_slice)
+ return <tuple>_Metadatum(
+ _decode(key), value if key[-4:] == b'-bin' else _decode(value))
+
+
+cdef tuple _metadata(grpc_metadata_array *c_metadata_array):
+ return tuple(
+ _metadatum(
+ c_metadata_array.metadata[index].key,
+ c_metadata_array.metadata[index].value)
+ for index in range(c_metadata_array.count))
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi
new file mode 100644
index 0000000000..bfbe27785b
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi
@@ -0,0 +1,109 @@
+# 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.
+
+
+cdef class Operation:
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+ # TODO(https://github.com/grpc/grpc/issues/7950): Eliminate this!
+ cdef grpc_op c_op
+
+
+cdef class SendInitialMetadataOperation(Operation):
+
+ cdef readonly object _initial_metadata;
+ cdef readonly int _flags
+ cdef grpc_metadata *_c_initial_metadata
+ cdef size_t _c_initial_metadata_count
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class SendMessageOperation(Operation):
+
+ cdef readonly bytes _message
+ cdef readonly int _flags
+ cdef grpc_byte_buffer *_c_message_byte_buffer
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class SendCloseFromClientOperation(Operation):
+
+ cdef readonly int _flags
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class SendStatusFromServerOperation(Operation):
+
+ cdef readonly object _trailing_metadata
+ cdef readonly object _code
+ cdef readonly object _details
+ cdef readonly int _flags
+ cdef grpc_metadata *_c_trailing_metadata
+ cdef size_t _c_trailing_metadata_count
+ cdef grpc_slice _c_details
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class ReceiveInitialMetadataOperation(Operation):
+
+ cdef readonly int _flags
+ cdef tuple _initial_metadata
+ cdef grpc_metadata_array _c_initial_metadata
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class ReceiveMessageOperation(Operation):
+
+ cdef readonly int _flags
+ cdef grpc_byte_buffer *_c_message_byte_buffer
+ cdef bytes _message
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class ReceiveStatusOnClientOperation(Operation):
+
+ cdef readonly int _flags
+ cdef grpc_metadata_array _c_trailing_metadata
+ cdef grpc_status_code _c_code
+ cdef grpc_slice _c_details
+ cdef tuple _trailing_metadata
+ cdef object _code
+ cdef str _details
+
+ cdef void c(self)
+ cdef void un_c(self)
+
+
+cdef class ReceiveCloseOnServerOperation(Operation):
+
+ cdef readonly int _flags
+ cdef object _cancelled
+ cdef int _c_cancelled
+
+ cdef void c(self)
+ cdef void un_c(self)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi
new file mode 100644
index 0000000000..239d0f3f95
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi
@@ -0,0 +1,237 @@
+# 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.
+
+
+cdef class Operation:
+
+ cdef void c(self):
+ raise NotImplementedError()
+
+ cdef void un_c(self):
+ raise NotImplementedError()
+
+
+cdef class SendInitialMetadataOperation(Operation):
+
+ def __cinit__(self, initial_metadata, flags):
+ self._initial_metadata = initial_metadata
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_SEND_INITIAL_METADATA
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_SEND_INITIAL_METADATA
+ self.c_op.flags = self._flags
+ _store_c_metadata(
+ self._initial_metadata, &self._c_initial_metadata,
+ &self._c_initial_metadata_count)
+ self.c_op.data.send_initial_metadata.metadata = self._c_initial_metadata
+ self.c_op.data.send_initial_metadata.count = self._c_initial_metadata_count
+ self.c_op.data.send_initial_metadata.maybe_compression_level.is_set = 0
+
+ cdef void un_c(self):
+ _release_c_metadata(
+ self._c_initial_metadata, self._c_initial_metadata_count)
+
+
+cdef class SendMessageOperation(Operation):
+
+ def __cinit__(self, bytes message, int flags):
+ self._message = message
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_SEND_MESSAGE
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_SEND_MESSAGE
+ self.c_op.flags = self._flags
+ cdef grpc_slice message_slice = grpc_slice_from_copied_buffer(
+ self._message, len(self._message))
+ self._c_message_byte_buffer = grpc_raw_byte_buffer_create(
+ &message_slice, 1)
+ grpc_slice_unref(message_slice)
+ self.c_op.data.send_message.send_message = self._c_message_byte_buffer
+
+ cdef void un_c(self):
+ grpc_byte_buffer_destroy(self._c_message_byte_buffer)
+
+
+cdef class SendCloseFromClientOperation(Operation):
+
+ def __cinit__(self, int flags):
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_SEND_CLOSE_FROM_CLIENT
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_SEND_CLOSE_FROM_CLIENT
+ self.c_op.flags = self._flags
+
+ cdef void un_c(self):
+ pass
+
+
+cdef class SendStatusFromServerOperation(Operation):
+
+ def __cinit__(self, trailing_metadata, code, object details, int flags):
+ self._trailing_metadata = trailing_metadata
+ self._code = code
+ self._details = details
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_SEND_STATUS_FROM_SERVER
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_SEND_STATUS_FROM_SERVER
+ self.c_op.flags = self._flags
+ _store_c_metadata(
+ self._trailing_metadata, &self._c_trailing_metadata,
+ &self._c_trailing_metadata_count)
+ self.c_op.data.send_status_from_server.trailing_metadata = (
+ self._c_trailing_metadata)
+ self.c_op.data.send_status_from_server.trailing_metadata_count = (
+ self._c_trailing_metadata_count)
+ self.c_op.data.send_status_from_server.status = self._code
+ self._c_details = _slice_from_bytes(_encode(self._details))
+ self.c_op.data.send_status_from_server.status_details = &self._c_details
+
+ cdef void un_c(self):
+ grpc_slice_unref(self._c_details)
+ _release_c_metadata(
+ self._c_trailing_metadata, self._c_trailing_metadata_count)
+
+
+cdef class ReceiveInitialMetadataOperation(Operation):
+
+ def __cinit__(self, flags):
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_RECV_INITIAL_METADATA
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_RECV_INITIAL_METADATA
+ self.c_op.flags = self._flags
+ grpc_metadata_array_init(&self._c_initial_metadata)
+ self.c_op.data.receive_initial_metadata.receive_initial_metadata = (
+ &self._c_initial_metadata)
+
+ cdef void un_c(self):
+ self._initial_metadata = _metadata(&self._c_initial_metadata)
+ grpc_metadata_array_destroy(&self._c_initial_metadata)
+
+ def initial_metadata(self):
+ return self._initial_metadata
+
+
+cdef class ReceiveMessageOperation(Operation):
+
+ def __cinit__(self, flags):
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_RECV_MESSAGE
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_RECV_MESSAGE
+ self.c_op.flags = self._flags
+ self.c_op.data.receive_message.receive_message = (
+ &self._c_message_byte_buffer)
+
+ cdef void un_c(self):
+ cdef grpc_byte_buffer_reader message_reader
+ cdef bint message_reader_status
+ cdef grpc_slice message_slice
+ cdef size_t message_slice_length
+ cdef void *message_slice_pointer
+ if self._c_message_byte_buffer != NULL:
+ message_reader_status = grpc_byte_buffer_reader_init(
+ &message_reader, self._c_message_byte_buffer)
+ if message_reader_status:
+ message = bytearray()
+ while grpc_byte_buffer_reader_next(&message_reader, &message_slice):
+ message_slice_pointer = grpc_slice_start_ptr(message_slice)
+ message_slice_length = grpc_slice_length(message_slice)
+ message += (<char *>message_slice_pointer)[:message_slice_length]
+ grpc_slice_unref(message_slice)
+ grpc_byte_buffer_reader_destroy(&message_reader)
+ self._message = bytes(message)
+ else:
+ self._message = None
+ grpc_byte_buffer_destroy(self._c_message_byte_buffer)
+ else:
+ self._message = None
+
+ def message(self):
+ return self._message
+
+
+cdef class ReceiveStatusOnClientOperation(Operation):
+
+ def __cinit__(self, flags):
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_RECV_STATUS_ON_CLIENT
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_RECV_STATUS_ON_CLIENT
+ self.c_op.flags = self._flags
+ grpc_metadata_array_init(&self._c_trailing_metadata)
+ self.c_op.data.receive_status_on_client.trailing_metadata = (
+ &self._c_trailing_metadata)
+ self.c_op.data.receive_status_on_client.status = (
+ &self._c_code)
+ self.c_op.data.receive_status_on_client.status_details = (
+ &self._c_details)
+
+ cdef void un_c(self):
+ self._trailing_metadata = _metadata(&self._c_trailing_metadata)
+ grpc_metadata_array_destroy(&self._c_trailing_metadata)
+ self._code = self._c_code
+ self._details = _decode(_slice_bytes(self._c_details))
+ grpc_slice_unref(self._c_details)
+
+ def trailing_metadata(self):
+ return self._trailing_metadata
+
+ def code(self):
+ return self._code
+
+ def details(self):
+ return self._details
+
+
+cdef class ReceiveCloseOnServerOperation(Operation):
+
+ def __cinit__(self, flags):
+ self._flags = flags
+
+ def type(self):
+ return GRPC_OP_RECV_CLOSE_ON_SERVER
+
+ cdef void c(self):
+ self.c_op.type = GRPC_OP_RECV_CLOSE_ON_SERVER
+ self.c_op.flags = self._flags
+ self.c_op.data.receive_close_on_server.cancelled = &self._c_cancelled
+
+ cdef void un_c(self):
+ self._cancelled = bool(self._c_cancelled)
+
+ def cancelled(self):
+ return self._cancelled
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi
index 9c40ebf0c2..35e1bdb0ae 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi
@@ -18,108 +18,17 @@ cdef grpc_slice _copy_slice(grpc_slice slice) nogil
cdef grpc_slice _slice_from_bytes(bytes value) nogil
-cdef class Timespec:
-
- cdef gpr_timespec c_time
-
-
cdef class CallDetails:
cdef grpc_call_details c_details
-cdef class OperationTag:
-
- cdef object user_tag
- cdef list references
- # This allows CompletionQueue to notify the Python Server object that the
- # underlying GRPC core server has shutdown
- cdef Server shutting_down_server
- cdef Call operation_call
- cdef CallDetails request_call_details
- cdef MetadataArray request_metadata
- cdef Operations batch_operations
- cdef bint is_new_request
-
-
-cdef class Event:
-
- cdef readonly grpc_completion_type type
- cdef readonly bint success
- cdef readonly object tag
-
- # For Server.request_call
- cdef readonly bint is_new_request
- cdef readonly CallDetails request_call_details
- cdef readonly object request_metadata
-
- # For server calls
- cdef readonly Call operation_call
-
- # For Call.start_batch
- cdef readonly Operations batch_operations
-
-
-cdef class ByteBuffer:
-
- cdef grpc_byte_buffer *c_byte_buffer
-
-
cdef class SslPemKeyCertPair:
cdef grpc_ssl_pem_key_cert_pair c_pair
cdef readonly object private_key, certificate_chain
-cdef class ChannelArg:
-
- cdef grpc_arg c_arg
- cdef grpc_arg_pointer_vtable ptr_vtable
- cdef readonly object key, value
-
-
-cdef class ChannelArgs:
-
- cdef grpc_channel_args c_args
- cdef list args
-
-
-cdef class Metadatum:
-
- cdef grpc_metadata c_metadata
- cdef void _copy_metadatum(self, grpc_metadata *destination) nogil
-
-
-cdef class Metadata:
-
- cdef grpc_metadata *c_metadata
- cdef readonly size_t c_count
-
-
-cdef class MetadataArray:
-
- cdef grpc_metadata_array c_metadata_array
-
-
-cdef class Operation:
-
- cdef grpc_op c_op
- cdef ByteBuffer _received_message
- cdef MetadataArray _received_metadata
- cdef grpc_status_code _received_status_code
- cdef grpc_slice _status_details
- cdef int _received_cancelled
- cdef readonly bint is_valid
- cdef object references
-
-
-cdef class Operations:
-
- cdef grpc_op *c_ops
- cdef size_t c_nops
- cdef list operations
-
-
cdef class CompressionOptions:
cdef grpc_compression_options c_options
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
index d860173b5d..1bcea8d347 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
@@ -112,8 +112,8 @@ class OperationType:
class CompressionAlgorithm:
none = GRPC_COMPRESS_NONE
- deflate = GRPC_COMPRESS_DEFLATE
- gzip = GRPC_COMPRESS_GZIP
+ deflate = GRPC_COMPRESS_MESSAGE_DEFLATE
+ gzip = GRPC_COMPRESS_MESSAGE_GZIP
class CompressionLevel:
@@ -123,82 +123,6 @@ class CompressionLevel:
high = GRPC_COMPRESS_LEVEL_HIGH
-cdef class Timespec:
-
- def __cinit__(self, time):
- if time is None:
- with nogil:
- self.c_time = gpr_now(GPR_CLOCK_REALTIME)
- return
- if isinstance(time, int):
- time = float(time)
- if isinstance(time, float):
- if time == float("+inf"):
- with nogil:
- self.c_time = gpr_inf_future(GPR_CLOCK_REALTIME)
- elif time == float("-inf"):
- with nogil:
- self.c_time = gpr_inf_past(GPR_CLOCK_REALTIME)
- else:
- self.c_time.seconds = time
- self.c_time.nanoseconds = (time - float(self.c_time.seconds)) * 1e9
- self.c_time.clock_type = GPR_CLOCK_REALTIME
- elif isinstance(time, Timespec):
- self.c_time = (<Timespec>time).c_time
- else:
- raise TypeError("expected time to be float, int, or Timespec, not {}"
- .format(type(time)))
-
- @property
- def seconds(self):
- # TODO(atash) ensure that everywhere a Timespec is created that it's
- # converted to GPR_CLOCK_REALTIME then and not every time someone wants to
- # read values off in Python.
- cdef gpr_timespec real_time
- with nogil:
- real_time = (
- gpr_convert_clock_type(self.c_time, GPR_CLOCK_REALTIME))
- return real_time.seconds
-
- @property
- def nanoseconds(self):
- cdef gpr_timespec real_time = (
- gpr_convert_clock_type(self.c_time, GPR_CLOCK_REALTIME))
- return real_time.nanoseconds
-
- def __float__(self):
- cdef gpr_timespec real_time = (
- gpr_convert_clock_type(self.c_time, GPR_CLOCK_REALTIME))
- return <double>real_time.seconds + <double>real_time.nanoseconds / 1e9
-
- @staticmethod
- def infinite_future():
- return Timespec(float("+inf"))
-
- @staticmethod
- def infinite_past():
- return Timespec(float("-inf"))
-
- def __richcmp__(Timespec self not None, Timespec other not None, int op):
- cdef gpr_timespec self_c_time = self.c_time
- cdef gpr_timespec other_c_time = other.c_time
- cdef int result = gpr_time_cmp(self_c_time, other_c_time)
- if op == 0: # <
- return result < 0
- elif op == 2: # ==
- return result == 0
- elif op == 4: # >
- return result > 0
- elif op == 1: # <=
- return result <= 0
- elif op == 3: # !=
- return result != 0
- elif op == 5: # >=
- return result >= 0
- else:
- raise ValueError('__richcmp__ `op` contract violated')
-
-
cdef class CallDetails:
def __cinit__(self):
@@ -221,97 +145,7 @@ cdef class CallDetails:
@property
def deadline(self):
- timespec = Timespec(float("-inf"))
- timespec.c_time = self.c_details.deadline
- return timespec
-
-
-cdef class OperationTag:
-
- def __cinit__(self, user_tag):
- self.user_tag = user_tag
- self.references = []
-
-
-cdef class Event:
-
- def __cinit__(self, grpc_completion_type type, bint success,
- object tag, Call operation_call,
- CallDetails request_call_details,
- object request_metadata,
- bint is_new_request,
- Operations batch_operations):
- self.type = type
- self.success = success
- self.tag = tag
- self.operation_call = operation_call
- self.request_call_details = request_call_details
- self.request_metadata = request_metadata
- self.batch_operations = batch_operations
- self.is_new_request = is_new_request
-
-
-cdef class ByteBuffer:
-
- def __cinit__(self, bytes data):
- grpc_init()
- if data is None:
- self.c_byte_buffer = NULL
- return
-
- cdef char *c_data = data
- cdef grpc_slice data_slice
- cdef size_t data_length = len(data)
- with nogil:
- data_slice = grpc_slice_from_copied_buffer(c_data, data_length)
- with nogil:
- self.c_byte_buffer = grpc_raw_byte_buffer_create(
- &data_slice, 1)
- with nogil:
- grpc_slice_unref(data_slice)
-
- def bytes(self):
- cdef grpc_byte_buffer_reader reader
- cdef grpc_slice data_slice
- cdef size_t data_slice_length
- cdef void *data_slice_pointer
- cdef bint reader_status
- if self.c_byte_buffer != NULL:
- with nogil:
- reader_status = grpc_byte_buffer_reader_init(
- &reader, self.c_byte_buffer)
- if not reader_status:
- return None
- result = bytearray()
- with nogil:
- while grpc_byte_buffer_reader_next(&reader, &data_slice):
- data_slice_pointer = grpc_slice_start_ptr(data_slice)
- data_slice_length = grpc_slice_length(data_slice)
- with gil:
- result += (<char *>data_slice_pointer)[:data_slice_length]
- grpc_slice_unref(data_slice)
- with nogil:
- grpc_byte_buffer_reader_destroy(&reader)
- return bytes(result)
- else:
- return None
-
- def __len__(self):
- cdef size_t result
- if self.c_byte_buffer != NULL:
- with nogil:
- result = grpc_byte_buffer_length(self.c_byte_buffer)
- return result
- else:
- return 0
-
- def __str__(self):
- return self.bytes()
-
- def __dealloc__(self):
- if self.c_byte_buffer != NULL:
- grpc_byte_buffer_destroy(self.c_byte_buffer)
- grpc_shutdown()
+ return _time_from_timespec(self.c_details.deadline)
cdef class SslPemKeyCertPair:
@@ -323,438 +157,6 @@ cdef class SslPemKeyCertPair:
self.c_pair.certificate_chain = self.certificate_chain
-
-cdef void* copy_ptr(void* ptr):
- return ptr
-
-
-cdef void destroy_ptr(grpc_exec_ctx* ctx, void* ptr):
- pass
-
-
-cdef int compare_ptr(void* ptr1, void* ptr2):
- if ptr1 < ptr2:
- return -1
- elif ptr1 > ptr2:
- return 1
- else:
- return 0
-
-
-cdef class ChannelArg:
-
- def __cinit__(self, bytes key, value):
- self.key = key
- self.value = value
- self.c_arg.key = self.key
- if isinstance(value, int):
- self.c_arg.type = GRPC_ARG_INTEGER
- self.c_arg.value.integer = self.value
- elif isinstance(value, bytes):
- self.c_arg.type = GRPC_ARG_STRING
- self.c_arg.value.string = self.value
- elif hasattr(value, '__int__'):
- # Pointer objects must override __int__() to return
- # the underlying C address (Python ints are word size). The
- # lifecycle of the pointer is fixed to the lifecycle of the
- # python object wrapping it.
- self.ptr_vtable.copy = &copy_ptr
- self.ptr_vtable.destroy = &destroy_ptr
- self.ptr_vtable.cmp = &compare_ptr
- self.c_arg.type = GRPC_ARG_POINTER
- self.c_arg.value.pointer.vtable = &self.ptr_vtable
- self.c_arg.value.pointer.address = <void*>(<intptr_t>int(self.value))
- else:
- # TODO Add supported pointer types to this message
- raise TypeError('Expected int or bytes, got {}'.format(type(value)))
-
-
-cdef class ChannelArgs:
-
- def __cinit__(self, args):
- grpc_init()
- self.args = list(args)
- for arg in self.args:
- if not isinstance(arg, ChannelArg):
- raise TypeError("expected list of ChannelArg")
- self.c_args.arguments_length = len(self.args)
- with nogil:
- self.c_args.arguments = <grpc_arg *>gpr_malloc(
- self.c_args.arguments_length*sizeof(grpc_arg))
- for i in range(self.c_args.arguments_length):
- self.c_args.arguments[i] = (<ChannelArg>self.args[i]).c_arg
-
- def __dealloc__(self):
- with nogil:
- gpr_free(self.c_args.arguments)
- grpc_shutdown()
-
- def __len__(self):
- # self.args is never stale; it's only updated from this file
- return len(self.args)
-
- def __getitem__(self, size_t i):
- # self.args is never stale; it's only updated from this file
- return self.args[i]
-
-
-cdef class Metadatum:
-
- def __cinit__(self, bytes key, bytes value):
- self.c_metadata.key = _slice_from_bytes(key)
- self.c_metadata.value = _slice_from_bytes(value)
-
- cdef void _copy_metadatum(self, grpc_metadata *destination) nogil:
- destination[0].key = _copy_slice(self.c_metadata.key)
- destination[0].value = _copy_slice(self.c_metadata.value)
-
- @property
- def key(self):
- return _slice_bytes(self.c_metadata.key)
-
- @property
- def value(self):
- return _slice_bytes(self.c_metadata.value)
-
- def __len__(self):
- return 2
-
- def __getitem__(self, size_t i):
- if i == 0:
- return self.key
- elif i == 1:
- return self.value
- else:
- raise IndexError("index must be 0 (key) or 1 (value)")
-
- def __iter__(self):
- return iter((self.key, self.value))
-
- def __dealloc__(self):
- grpc_slice_unref(self.c_metadata.key)
- grpc_slice_unref(self.c_metadata.value)
-
-cdef class _MetadataIterator:
-
- cdef size_t i
- cdef size_t _length
- cdef object _metadatum_indexable
-
- def __cinit__(self, length, metadatum_indexable):
- self._length = length
- self._metadatum_indexable = metadatum_indexable
- self.i = 0
-
- def __iter__(self):
- return self
-
- def __next__(self):
- if self.i < self._length:
- result = self._metadatum_indexable[self.i]
- self.i = self.i + 1
- return result
- else:
- raise StopIteration
-
-
-# TODO(https://github.com/grpc/grpc/issues/7950): Eliminate this; just use an
-# ordinary sequence of pairs of bytestrings all the way down to the
-# grpc_call_start_batch call.
-cdef class Metadata:
- """Metadata being passed from application to core."""
-
- def __cinit__(self, metadata_iterable):
- metadata_sequence = tuple(metadata_iterable)
- cdef size_t count = len(metadata_sequence)
- with nogil:
- grpc_init()
- self.c_metadata = <grpc_metadata *>gpr_malloc(
- count * sizeof(grpc_metadata))
- self.c_count = count
- for index, metadatum in enumerate(metadata_sequence):
- self.c_metadata[index].key = grpc_slice_copy(
- (<Metadatum>metadatum).c_metadata.key)
- self.c_metadata[index].value = grpc_slice_copy(
- (<Metadatum>metadatum).c_metadata.value)
-
- def __dealloc__(self):
- with nogil:
- for index in range(self.c_count):
- grpc_slice_unref(self.c_metadata[index].key)
- grpc_slice_unref(self.c_metadata[index].value)
- gpr_free(self.c_metadata)
- grpc_shutdown()
-
- def __len__(self):
- return self.c_count
-
- def __getitem__(self, size_t index):
- if index < self.c_count:
- key = _slice_bytes(self.c_metadata[index].key)
- value = _slice_bytes(self.c_metadata[index].value)
- return Metadatum(key, value)
- else:
- raise IndexError()
-
- def __iter__(self):
- return _MetadataIterator(self.c_count, self)
-
-
-cdef class MetadataArray:
- """Metadata being passed from core to application."""
-
- def __cinit__(self):
- with nogil:
- grpc_init()
- grpc_metadata_array_init(&self.c_metadata_array)
-
- def __dealloc__(self):
- with nogil:
- grpc_metadata_array_destroy(&self.c_metadata_array)
- grpc_shutdown()
-
- def __len__(self):
- return self.c_metadata_array.count
-
- def __getitem__(self, size_t i):
- if i >= self.c_metadata_array.count:
- raise IndexError
- key = _slice_bytes(self.c_metadata_array.metadata[i].key)
- value = _slice_bytes(self.c_metadata_array.metadata[i].value)
- return Metadatum(key=key, value=value)
-
- def __iter__(self):
- return _MetadataIterator(self.c_metadata_array.count, self)
-
-
-cdef class Operation:
-
- def __cinit__(self):
- grpc_init()
- self.references = []
- self._status_details = grpc_empty_slice()
- self.is_valid = False
-
- @property
- def type(self):
- return self.c_op.type
-
- @property
- def flags(self):
- return self.c_op.flags
-
- @property
- def has_status(self):
- return self.c_op.type == GRPC_OP_RECV_STATUS_ON_CLIENT
-
- @property
- def received_message(self):
- if self.c_op.type != GRPC_OP_RECV_MESSAGE:
- raise TypeError("self must be an operation receiving a message")
- return self._received_message
-
- @property
- def received_message_or_none(self):
- if self.c_op.type != GRPC_OP_RECV_MESSAGE:
- return None
- return self._received_message
-
- @property
- def received_metadata(self):
- if (self.c_op.type != GRPC_OP_RECV_INITIAL_METADATA and
- self.c_op.type != GRPC_OP_RECV_STATUS_ON_CLIENT):
- raise TypeError("self must be an operation receiving metadata")
- # TODO(https://github.com/grpc/grpc/issues/7950): Drop the "all Cython
- # objects must be legitimate for use from Python at any time" policy in
- # place today, shift the policy toward "Operation objects are only usable
- # while their calls are active", and move this making-a-copy-because-this-
- # data-needs-to-live-much-longer-than-the-call-from-which-it-arose to the
- # lowest Python layer.
- return tuple(self._received_metadata)
-
- @property
- def received_status_code(self):
- if self.c_op.type != GRPC_OP_RECV_STATUS_ON_CLIENT:
- raise TypeError("self must be an operation receiving a status code")
- return self._received_status_code
-
- @property
- def received_status_code_or_none(self):
- if self.c_op.type != GRPC_OP_RECV_STATUS_ON_CLIENT:
- return None
- return self._received_status_code
-
- @property
- def received_status_details(self):
- if self.c_op.type != GRPC_OP_RECV_STATUS_ON_CLIENT:
- raise TypeError("self must be an operation receiving status details")
- return _slice_bytes(self._status_details)
-
- @property
- def received_status_details_or_none(self):
- if self.c_op.type != GRPC_OP_RECV_STATUS_ON_CLIENT:
- return None
- return _slice_bytes(self._status_details)
-
- @property
- def received_cancelled(self):
- if self.c_op.type != GRPC_OP_RECV_CLOSE_ON_SERVER:
- raise TypeError("self must be an operation receiving cancellation "
- "information")
- return False if self._received_cancelled == 0 else True
-
- @property
- def received_cancelled_or_none(self):
- if self.c_op.type != GRPC_OP_RECV_CLOSE_ON_SERVER:
- return None
- return False if self._received_cancelled == 0 else True
-
- def __dealloc__(self):
- grpc_slice_unref(self._status_details)
- grpc_shutdown()
-
-def operation_send_initial_metadata(Metadata metadata, int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_SEND_INITIAL_METADATA
- op.c_op.flags = flags
- op.c_op.data.send_initial_metadata.count = metadata.c_count
- op.c_op.data.send_initial_metadata.metadata = metadata.c_metadata
- op.references.append(metadata)
- op.is_valid = True
- return op
-
-def operation_send_message(data, int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_SEND_MESSAGE
- op.c_op.flags = flags
- byte_buffer = ByteBuffer(data)
- op.c_op.data.send_message.send_message = byte_buffer.c_byte_buffer
- op.references.append(byte_buffer)
- op.is_valid = True
- return op
-
-def operation_send_close_from_client(int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_SEND_CLOSE_FROM_CLIENT
- op.c_op.flags = flags
- op.is_valid = True
- return op
-
-def operation_send_status_from_server(
- Metadata metadata, grpc_status_code code, bytes details, int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_SEND_STATUS_FROM_SERVER
- op.c_op.flags = flags
- op.c_op.data.send_status_from_server.trailing_metadata_count = (
- metadata.c_count)
- op.c_op.data.send_status_from_server.trailing_metadata = metadata.c_metadata
- op.c_op.data.send_status_from_server.status = code
- grpc_slice_unref(op._status_details)
- op._status_details = _slice_from_bytes(details)
- op.c_op.data.send_status_from_server.status_details = &op._status_details
- op.references.append(metadata)
- op.is_valid = True
- return op
-
-def operation_receive_initial_metadata(int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_RECV_INITIAL_METADATA
- op.c_op.flags = flags
- op._received_metadata = MetadataArray()
- op.c_op.data.receive_initial_metadata.receive_initial_metadata = (
- &op._received_metadata.c_metadata_array)
- op.is_valid = True
- return op
-
-def operation_receive_message(int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_RECV_MESSAGE
- op.c_op.flags = flags
- op._received_message = ByteBuffer(None)
- # n.b. the c_op.data.receive_message field needs to be deleted by us,
- # anyway, so we just let that be handled by the ByteBuffer() we allocated
- # the line before.
- op.c_op.data.receive_message.receive_message = (
- &op._received_message.c_byte_buffer)
- op.is_valid = True
- return op
-
-def operation_receive_status_on_client(int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_RECV_STATUS_ON_CLIENT
- op.c_op.flags = flags
- op._received_metadata = MetadataArray()
- op.c_op.data.receive_status_on_client.trailing_metadata = (
- &op._received_metadata.c_metadata_array)
- op.c_op.data.receive_status_on_client.status = (
- &op._received_status_code)
- op.c_op.data.receive_status_on_client.status_details = (
- &op._status_details)
- op.is_valid = True
- return op
-
-def operation_receive_close_on_server(int flags):
- cdef Operation op = Operation()
- op.c_op.type = GRPC_OP_RECV_CLOSE_ON_SERVER
- op.c_op.flags = flags
- op.c_op.data.receive_close_on_server.cancelled = &op._received_cancelled
- op.is_valid = True
- return op
-
-
-cdef class _OperationsIterator:
-
- cdef size_t i
- cdef Operations operations
-
- def __cinit__(self, Operations operations not None):
- self.i = 0
- self.operations = operations
-
- def __iter__(self):
- return self
-
- def __next__(self):
- if self.i < len(self.operations):
- result = self.operations[self.i]
- self.i = self.i + 1
- return result
- else:
- raise StopIteration
-
-
-cdef class Operations:
-
- def __cinit__(self, operations):
- grpc_init()
- self.operations = list(operations) # normalize iterable
- self.c_ops = NULL
- self.c_nops = 0
- for operation in self.operations:
- if not isinstance(operation, Operation):
- raise TypeError("expected operations to be iterable of Operation")
- self.c_nops = len(self.operations)
- with nogil:
- self.c_ops = <grpc_op *>gpr_malloc(sizeof(grpc_op)*self.c_nops)
- for i in range(self.c_nops):
- self.c_ops[i] = (<Operation>(self.operations[i])).c_op
-
- def __len__(self):
- return self.c_nops
-
- def __getitem__(self, size_t i):
- # self.operations is never stale; it's only updated from this file
- return self.operations[i]
-
- def __dealloc__(self):
- with nogil:
- gpr_free(self.c_ops)
- grpc_shutdown()
-
- def __iter__(self):
- return _OperationsIterator(self)
-
-
cdef class CompressionOptions:
def __cinit__(self):
@@ -777,8 +179,10 @@ cdef class CompressionOptions:
return result
def to_channel_arg(self):
- return ChannelArg(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
- self.c_options.enabled_algorithms_bitset)
+ return (
+ GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
+ self.c_options.enabled_algorithms_bitset,
+ )
def compression_algorithm_name(grpc_compression_algorithm algorithm):
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
index df4577e124..4588db30d3 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
@@ -15,6 +15,8 @@
cdef class Server:
+ cdef grpc_arg_pointer_vtable _vtable
+ cdef readonly _ArgumentsProcessor _arguments_processor
cdef grpc_server *c_server
cdef bint is_started # start has been called
cdef bint is_shutting_down # shutdown has been called
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
index b8db27469f..707ec742dd 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
@@ -14,21 +14,62 @@
cimport cpython
+import logging
import time
+import grpc
+cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapper(
+ void* user_data, grpc_ssl_server_certificate_config **config) with gil:
+ # This is a credentials.ServerCertificateConfig
+ cdef ServerCertificateConfig cert_config = None
+ if not user_data:
+ raise ValueError('internal error: user_data must be specified')
+ credentials = <ServerCredentials>user_data
+ if not credentials.initial_cert_config_fetched:
+ # C-core is asking for the initial cert config
+ credentials.initial_cert_config_fetched = True
+ cert_config = credentials.initial_cert_config._certificate_configuration
+ else:
+ user_cb = credentials.cert_config_fetcher
+ try:
+ cert_config_wrapper = user_cb()
+ except Exception:
+ logging.exception('Error fetching certificate config')
+ return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL
+ if cert_config_wrapper is None:
+ return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED
+ elif not isinstance(
+ cert_config_wrapper, grpc.ServerCertificateConfiguration):
+ logging.error(
+ 'Error fetching certificate configuration: certificate '
+ 'configuration must be of type grpc.ServerCertificateConfiguration, '
+ 'not %s' % type(cert_config_wrapper).__name__)
+ return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL
+ else:
+ cert_config = cert_config_wrapper._certificate_configuration
+ config[0] = <grpc_ssl_server_certificate_config*>cert_config.c_cert_config
+ # our caller will assume ownership of memory, so we have to recreate
+ # a copy of c_cert_config here
+ cert_config.c_cert_config = grpc_ssl_server_certificate_config_create(
+ cert_config.c_pem_root_certs, cert_config.c_ssl_pem_key_cert_pairs,
+ cert_config.c_ssl_pem_key_cert_pairs_count)
+ return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW
cdef class Server:
- def __cinit__(self, ChannelArgs arguments):
+ def __cinit__(self, object arguments):
grpc_init()
- cdef grpc_channel_args *c_arguments = NULL
self.references = []
self.registered_completion_queues = []
- if len(arguments) > 0:
- c_arguments = &arguments.c_args
- self.references.append(arguments)
- with nogil:
- self.c_server = grpc_server_create(c_arguments, NULL)
+ self._vtable.copy = &_copy_pointer
+ self._vtable.destroy = &_destroy_pointer
+ self._vtable.cmp = &_compare_pointer
+ cdef _ArgumentsProcessor arguments_processor = _ArgumentsProcessor(
+ arguments)
+ cdef grpc_channel_args *c_arguments = arguments_processor.c(&self._vtable)
+ self.c_server = grpc_server_create(c_arguments, NULL)
+ arguments_processor.un_c()
+ self.references.append(arguments)
self.is_started = False
self.is_shutting_down = False
self.is_shutdown = False
@@ -40,23 +81,15 @@ cdef class Server:
raise ValueError("server must be started and not shutting down")
if server_queue not in self.registered_completion_queues:
raise ValueError("server_queue must be a registered completion queue")
- cdef grpc_call_error result
- cdef OperationTag operation_tag = OperationTag(tag)
- operation_tag.operation_call = Call()
- operation_tag.request_call_details = CallDetails()
- operation_tag.request_metadata = MetadataArray()
- operation_tag.references.extend([self, call_queue, server_queue])
- operation_tag.is_new_request = True
- operation_tag.batch_operations = Operations([])
- cpython.Py_INCREF(operation_tag)
- with nogil:
- result = grpc_server_request_call(
- self.c_server, &operation_tag.operation_call.c_call,
- &operation_tag.request_call_details.c_details,
- &operation_tag.request_metadata.c_metadata_array,
- call_queue.c_completion_queue, server_queue.c_completion_queue,
- <cpython.PyObject *>operation_tag)
- return result
+ cdef _RequestCallTag request_call_tag = _RequestCallTag(tag)
+ request_call_tag.prepare()
+ cpython.Py_INCREF(request_call_tag)
+ return grpc_server_request_call(
+ self.c_server, &request_call_tag.call.c_call,
+ &request_call_tag.call_details.c_details,
+ &request_call_tag.c_invocation_metadata,
+ call_queue.c_completion_queue, server_queue.c_completion_queue,
+ <cpython.PyObject *>request_call_tag)
def register_completion_queue(
self, CompletionQueue queue not None):
@@ -76,7 +109,7 @@ cdef class Server:
with nogil:
grpc_server_start(self.c_server)
# Ensure the core has gotten a chance to do the start-up work
- self.backup_shutdown_queue.poll(Timespec(None))
+ self.backup_shutdown_queue.poll(deadline=time.time())
def add_http2_port(self, bytes address,
ServerCredentials server_credentials=None):
@@ -97,16 +130,14 @@ cdef class Server:
cdef _c_shutdown(self, CompletionQueue queue, tag):
self.is_shutting_down = True
- operation_tag = OperationTag(tag)
- operation_tag.shutting_down_server = self
- cpython.Py_INCREF(operation_tag)
+ cdef _ServerShutdownTag server_shutdown_tag = _ServerShutdownTag(tag, self)
+ cpython.Py_INCREF(server_shutdown_tag)
with nogil:
grpc_server_shutdown_and_notify(
self.c_server, queue.c_completion_queue,
- <cpython.PyObject *>operation_tag)
+ <cpython.PyObject *>server_shutdown_tag)
def shutdown(self, CompletionQueue queue not None, tag):
- cdef OperationTag operation_tag
if queue.is_shutting_down:
raise ValueError("queue must be live")
elif not self.is_started:
@@ -119,7 +150,8 @@ cdef class Server:
self._c_shutdown(queue, tag)
cdef notify_shutdown_complete(self):
- # called only by a completion queue on receiving our shutdown operation tag
+ # called only after our server shutdown tag has emerged from a completion
+ # queue.
self.is_shutdown = True
def cancel_all_calls(self):
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi
new file mode 100644
index 0000000000..f9a3b5e8f4
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi
@@ -0,0 +1,58 @@
+# 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.
+
+
+cdef class _Tag:
+
+ cdef object event(self, grpc_event c_event)
+
+
+cdef class _ConnectivityTag(_Tag):
+
+ cdef readonly object _user_tag
+
+ cdef ConnectivityEvent event(self, grpc_event c_event)
+
+
+cdef class _RequestCallTag(_Tag):
+
+ cdef readonly object _user_tag
+ cdef Call call
+ cdef CallDetails call_details
+ cdef grpc_metadata_array c_invocation_metadata
+
+ cdef void prepare(self)
+ cdef RequestCallEvent event(self, grpc_event c_event)
+
+
+cdef class _BatchOperationTag(_Tag):
+
+ cdef object _user_tag
+ cdef readonly object _operations
+ cdef readonly object _retained_call
+ cdef grpc_op *c_ops
+ cdef size_t c_nops
+
+ cdef void prepare(self)
+ cdef BatchOperationEvent event(self, grpc_event c_event)
+
+
+cdef class _ServerShutdownTag(_Tag):
+
+ cdef readonly object _user_tag
+ # This allows CompletionQueue to notify the Python Server object that the
+ # underlying GRPC core server has shutdown
+ cdef readonly Server _shutting_down_server
+
+ cdef ServerShutdownEvent event(self, grpc_event c_event)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi
new file mode 100644
index 0000000000..aaca458442
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi
@@ -0,0 +1,87 @@
+# 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.
+
+
+cdef class _Tag:
+
+ cdef object event(self, grpc_event c_event):
+ raise NotImplementedError()
+
+
+cdef class _ConnectivityTag(_Tag):
+
+ def __cinit__(self, user_tag):
+ self._user_tag = user_tag
+
+ cdef ConnectivityEvent event(self, grpc_event c_event):
+ return ConnectivityEvent(c_event.type, c_event.success, self._user_tag)
+
+
+cdef class _RequestCallTag(_Tag):
+
+ def __cinit__(self, user_tag):
+ self._user_tag = user_tag
+ self.call = None
+ self.call_details = None
+
+ cdef void prepare(self):
+ self.call = Call()
+ self.call_details = CallDetails()
+ grpc_metadata_array_init(&self.c_invocation_metadata)
+
+ cdef RequestCallEvent event(self, grpc_event c_event):
+ cdef tuple invocation_metadata = _metadata(&self.c_invocation_metadata)
+ grpc_metadata_array_destroy(&self.c_invocation_metadata)
+ return RequestCallEvent(
+ c_event.type, c_event.success, self._user_tag, self.call,
+ self.call_details, invocation_metadata)
+
+
+cdef class _BatchOperationTag:
+
+ def __cinit__(self, user_tag, operations, call):
+ self._user_tag = user_tag
+ self._operations = operations
+ self._retained_call = call
+
+ cdef void prepare(self):
+ self.c_nops = 0 if self._operations is None else len(self._operations)
+ if 0 < self.c_nops:
+ self.c_ops = <grpc_op *>gpr_malloc(sizeof(grpc_op) * self.c_nops)
+ for index, operation in enumerate(self._operations):
+ (<Operation>operation).c()
+ self.c_ops[index] = (<Operation>operation).c_op
+
+ cdef BatchOperationEvent event(self, grpc_event c_event):
+ if 0 < self.c_nops:
+ for index, operation in enumerate(self._operations):
+ (<Operation>operation).c_op = self.c_ops[index]
+ (<Operation>operation).un_c()
+ gpr_free(self.c_ops)
+ return BatchOperationEvent(
+ c_event.type, c_event.success, self._user_tag, self._operations)
+ else:
+ return BatchOperationEvent(
+ c_event.type, c_event.success, self._user_tag, ())
+
+
+cdef class _ServerShutdownTag(_Tag):
+
+ def __cinit__(self, user_tag, shutting_down_server):
+ self._user_tag = user_tag
+ self._shutting_down_server = shutting_down_server
+
+ cdef ServerShutdownEvent event(self, grpc_event c_event):
+ self._shutting_down_server.notify_shutdown_complete()
+ return ServerShutdownEvent(c_event.type, c_event.success, self._user_tag) \ No newline at end of file
diff --git a/tools/run_tests/helper_scripts/pre_build_node_electron.sh b/src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi
index 29394d294f..ce67c61eaf 100755..100644
--- a/tools/run_tests/helper_scripts/pre_build_node_electron.sh
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi
@@ -1,6 +1,4 @@
-#!/bin/bash
-
-# Copyright 2016 gRPC authors.
+# 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.
@@ -14,11 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ELECTRON_VERSION=$1
-nvm install 8
-set -ex
+cdef gpr_timespec _timespec_from_time(object time)
-npm install xvfb-maybe
-npm install electron@$ELECTRON_VERSION
+cdef double _time_from_timespec(gpr_timespec timespec)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi
new file mode 100644
index 0000000000..7a668680b8
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi
@@ -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.
+
+
+cdef gpr_timespec _timespec_from_time(object time):
+ cdef gpr_timespec timespec
+ if time is None:
+ return gpr_inf_future(GPR_CLOCK_REALTIME)
+ else:
+ timespec.seconds = time
+ timespec.nanoseconds = (time - float(timespec.seconds)) * 1e9
+ timespec.clock_type = GPR_CLOCK_REALTIME
+ return timespec
+
+
+cdef double _time_from_timespec(gpr_timespec timespec):
+ cdef gpr_timespec real_timespec = gpr_convert_clock_type(
+ timespec, GPR_CLOCK_REALTIME)
+ return <double>real_timespec.seconds + <double>real_timespec.nanoseconds / 1e9
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pxd b/src/python/grpcio/grpc/_cython/cygrpc.pxd
index fc6cc5fb9f..b6a794c6d7 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pxd
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pxd
@@ -14,10 +14,16 @@
include "_cygrpc/grpc.pxi"
+include "_cygrpc/arguments.pxd.pxi"
include "_cygrpc/call.pxd.pxi"
include "_cygrpc/channel.pxd.pxi"
include "_cygrpc/credentials.pxd.pxi"
include "_cygrpc/completion_queue.pxd.pxi"
+include "_cygrpc/event.pxd.pxi"
+include "_cygrpc/metadata.pxd.pxi"
+include "_cygrpc/operation.pxd.pxi"
include "_cygrpc/records.pxd.pxi"
include "_cygrpc/security.pxd.pxi"
include "_cygrpc/server.pxd.pxi"
+include "_cygrpc/tag.pxd.pxi"
+include "_cygrpc/time.pxd.pxi"
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx
index 57165d5f5a..2ee2e6b73e 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pyx
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx
@@ -21,13 +21,19 @@ import sys
# TODO(atash): figure out why the coverage tool gets confused about the Cython
# coverage plugin when the following files don't have a '.pxi' suffix.
include "_cygrpc/grpc_string.pyx.pxi"
+include "_cygrpc/arguments.pyx.pxi"
include "_cygrpc/call.pyx.pxi"
include "_cygrpc/channel.pyx.pxi"
include "_cygrpc/credentials.pyx.pxi"
include "_cygrpc/completion_queue.pyx.pxi"
+include "_cygrpc/event.pyx.pxi"
+include "_cygrpc/metadata.pyx.pxi"
+include "_cygrpc/operation.pyx.pxi"
include "_cygrpc/records.pyx.pxi"
include "_cygrpc/security.pyx.pxi"
include "_cygrpc/server.pyx.pxi"
+include "_cygrpc/tag.pyx.pxi"
+include "_cygrpc/time.pyx.pxi"
#
# initialize gRPC
diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py
index a4eb358c4e..6032828c77 100644
--- a/src/python/grpcio/grpc/_grpcio_metadata.py
+++ b/src/python/grpcio/grpc/_grpcio_metadata.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!!
-__version__ = """1.7.0.dev0"""
+__version__ = """1.10.0.dev0"""
diff --git a/src/python/grpcio/grpc/_interceptor.py b/src/python/grpcio/grpc/_interceptor.py
new file mode 100644
index 0000000000..d029472c68
--- /dev/null
+++ b/src/python/grpcio/grpc/_interceptor.py
@@ -0,0 +1,350 @@
+# 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.
+"""Implementation of gRPC Python interceptors."""
+
+import collections
+import sys
+
+import grpc
+
+
+class _ServicePipeline(object):
+
+ def __init__(self, interceptors):
+ self.interceptors = tuple(interceptors)
+
+ def _continuation(self, thunk, index):
+ return lambda context: self._intercept_at(thunk, index, context)
+
+ def _intercept_at(self, thunk, index, context):
+ if index < len(self.interceptors):
+ interceptor = self.interceptors[index]
+ thunk = self._continuation(thunk, index + 1)
+ return interceptor.intercept_service(thunk, context)
+ else:
+ return thunk(context)
+
+ def execute(self, thunk, context):
+ return self._intercept_at(thunk, 0, context)
+
+
+def service_pipeline(interceptors):
+ return _ServicePipeline(interceptors) if interceptors else None
+
+
+class _ClientCallDetails(
+ collections.namedtuple(
+ '_ClientCallDetails',
+ ('method', 'timeout', 'metadata', 'credentials')),
+ grpc.ClientCallDetails):
+ pass
+
+
+def _unwrap_client_call_details(call_details, default_details):
+ try:
+ method = call_details.method
+ except AttributeError:
+ method = default_details.method
+
+ try:
+ timeout = call_details.timeout
+ except AttributeError:
+ timeout = default_details.timeout
+
+ try:
+ metadata = call_details.metadata
+ except AttributeError:
+ metadata = default_details.metadata
+
+ try:
+ credentials = call_details.credentials
+ except AttributeError:
+ credentials = default_details.credentials
+
+ return method, timeout, metadata, credentials
+
+
+class _LocalFailure(grpc.RpcError, grpc.Future, grpc.Call):
+
+ def __init__(self, exception, traceback):
+ super(_LocalFailure, self).__init__()
+ self._exception = exception
+ self._traceback = traceback
+
+ def initial_metadata(self):
+ return None
+
+ def trailing_metadata(self):
+ return None
+
+ def code(self):
+ return grpc.StatusCode.INTERNAL
+
+ def details(self):
+ return 'Exception raised while intercepting the RPC'
+
+ def cancel(self):
+ return False
+
+ def cancelled(self):
+ return False
+
+ def running(self):
+ return False
+
+ def done(self):
+ return True
+
+ def result(self, ignored_timeout=None):
+ raise self._exception
+
+ def exception(self, ignored_timeout=None):
+ return self._exception
+
+ def traceback(self, ignored_timeout=None):
+ return self._traceback
+
+ def add_done_callback(self, fn):
+ fn(self)
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ raise self._exception
+
+
+class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
+
+ def __init__(self, thunk, method, interceptor):
+ self._thunk = thunk
+ self._method = method
+ self._interceptor = interceptor
+
+ def __call__(self, request, timeout=None, metadata=None, credentials=None):
+ call_future = self.future(
+ request,
+ timeout=timeout,
+ metadata=metadata,
+ credentials=credentials)
+ return call_future.result()
+
+ def with_call(self, request, timeout=None, metadata=None, credentials=None):
+ call_future = self.future(
+ request,
+ timeout=timeout,
+ metadata=metadata,
+ credentials=credentials)
+ return call_future.result(), call_future
+
+ def future(self, request, timeout=None, metadata=None, credentials=None):
+
+ client_call_details = _ClientCallDetails(self._method, timeout,
+ metadata, credentials)
+
+ def continuation(new_details, request):
+ new_method, new_timeout, new_metadata, new_credentials = (
+ _unwrap_client_call_details(new_details, client_call_details))
+ return self._thunk(new_method).future(
+ request,
+ timeout=new_timeout,
+ metadata=new_metadata,
+ credentials=new_credentials)
+
+ try:
+ return self._interceptor.intercept_unary_unary(
+ continuation, client_call_details, request)
+ except Exception as exception: # pylint:disable=broad-except
+ return _LocalFailure(exception, sys.exc_info()[2])
+
+
+class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
+
+ def __init__(self, thunk, method, interceptor):
+ self._thunk = thunk
+ self._method = method
+ self._interceptor = interceptor
+
+ def __call__(self, request, timeout=None, metadata=None, credentials=None):
+ client_call_details = _ClientCallDetails(self._method, timeout,
+ metadata, credentials)
+
+ def continuation(new_details, request):
+ new_method, new_timeout, new_metadata, new_credentials = (
+ _unwrap_client_call_details(new_details, client_call_details))
+ return self._thunk(new_method)(
+ request,
+ timeout=new_timeout,
+ metadata=new_metadata,
+ credentials=new_credentials)
+
+ try:
+ return self._interceptor.intercept_unary_stream(
+ continuation, client_call_details, request)
+ except Exception as exception: # pylint:disable=broad-except
+ return _LocalFailure(exception, sys.exc_info()[2])
+
+
+class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
+
+ def __init__(self, thunk, method, interceptor):
+ self._thunk = thunk
+ self._method = method
+ self._interceptor = interceptor
+
+ def __call__(self,
+ request_iterator,
+ timeout=None,
+ metadata=None,
+ credentials=None):
+ call_future = self.future(
+ request_iterator,
+ timeout=timeout,
+ metadata=metadata,
+ credentials=credentials)
+ return call_future.result()
+
+ def with_call(self,
+ request_iterator,
+ timeout=None,
+ metadata=None,
+ credentials=None):
+ call_future = self.future(
+ request_iterator,
+ timeout=timeout,
+ metadata=metadata,
+ credentials=credentials)
+ return call_future.result(), call_future
+
+ def future(self,
+ request_iterator,
+ timeout=None,
+ metadata=None,
+ credentials=None):
+ client_call_details = _ClientCallDetails(self._method, timeout,
+ metadata, credentials)
+
+ def continuation(new_details, request_iterator):
+ new_method, new_timeout, new_metadata, new_credentials = (
+ _unwrap_client_call_details(new_details, client_call_details))
+ return self._thunk(new_method).future(
+ request_iterator,
+ timeout=new_timeout,
+ metadata=new_metadata,
+ credentials=new_credentials)
+
+ try:
+ return self._interceptor.intercept_stream_unary(
+ continuation, client_call_details, request_iterator)
+ except Exception as exception: # pylint:disable=broad-except
+ return _LocalFailure(exception, sys.exc_info()[2])
+
+
+class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
+
+ def __init__(self, thunk, method, interceptor):
+ self._thunk = thunk
+ self._method = method
+ self._interceptor = interceptor
+
+ def __call__(self,
+ request_iterator,
+ timeout=None,
+ metadata=None,
+ credentials=None):
+ client_call_details = _ClientCallDetails(self._method, timeout,
+ metadata, credentials)
+
+ def continuation(new_details, request_iterator):
+ new_method, new_timeout, new_metadata, new_credentials = (
+ _unwrap_client_call_details(new_details, client_call_details))
+ return self._thunk(new_method)(
+ request_iterator,
+ timeout=new_timeout,
+ metadata=new_metadata,
+ credentials=new_credentials)
+
+ try:
+ return self._interceptor.intercept_stream_stream(
+ continuation, client_call_details, request_iterator)
+ except Exception as exception: # pylint:disable=broad-except
+ return _LocalFailure(exception, sys.exc_info()[2])
+
+
+class _Channel(grpc.Channel):
+
+ def __init__(self, channel, interceptor):
+ self._channel = channel
+ self._interceptor = interceptor
+
+ def subscribe(self, *args, **kwargs):
+ self._channel.subscribe(*args, **kwargs)
+
+ def unsubscribe(self, *args, **kwargs):
+ self._channel.unsubscribe(*args, **kwargs)
+
+ def unary_unary(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
+ thunk = lambda m: self._channel.unary_unary(m, request_serializer, response_deserializer)
+ if isinstance(self._interceptor, grpc.UnaryUnaryClientInterceptor):
+ return _UnaryUnaryMultiCallable(thunk, method, self._interceptor)
+ else:
+ return thunk(method)
+
+ def unary_stream(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
+ thunk = lambda m: self._channel.unary_stream(m, request_serializer, response_deserializer)
+ if isinstance(self._interceptor, grpc.UnaryStreamClientInterceptor):
+ return _UnaryStreamMultiCallable(thunk, method, self._interceptor)
+ else:
+ return thunk(method)
+
+ def stream_unary(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
+ thunk = lambda m: self._channel.stream_unary(m, request_serializer, response_deserializer)
+ if isinstance(self._interceptor, grpc.StreamUnaryClientInterceptor):
+ return _StreamUnaryMultiCallable(thunk, method, self._interceptor)
+ else:
+ return thunk(method)
+
+ def stream_stream(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
+ thunk = lambda m: self._channel.stream_stream(m, request_serializer, response_deserializer)
+ if isinstance(self._interceptor, grpc.StreamStreamClientInterceptor):
+ return _StreamStreamMultiCallable(thunk, method, self._interceptor)
+ else:
+ return thunk(method)
+
+
+def intercept_channel(channel, *interceptors):
+ for interceptor in reversed(list(interceptors)):
+ if not isinstance(interceptor, grpc.UnaryUnaryClientInterceptor) and \
+ not isinstance(interceptor, grpc.UnaryStreamClientInterceptor) and \
+ not isinstance(interceptor, grpc.StreamUnaryClientInterceptor) and \
+ not isinstance(interceptor, grpc.StreamStreamClientInterceptor):
+ raise TypeError('interceptor must be '
+ 'grpc.UnaryUnaryClientInterceptor or '
+ 'grpc.UnaryStreamClientInterceptor or '
+ 'grpc.StreamUnaryClientInterceptor or '
+ 'grpc.StreamStreamClientInterceptor or ')
+ channel = _Channel(channel, interceptor)
+ return channel
diff --git a/src/python/grpcio/grpc/_plugin_wrapping.py b/src/python/grpcio/grpc/_plugin_wrapping.py
index bea2c0f139..6785e5876a 100644
--- a/src/python/grpcio/grpc/_plugin_wrapping.py
+++ b/src/python/grpcio/grpc/_plugin_wrapping.py
@@ -13,6 +13,7 @@
# limitations under the License.
import collections
+import logging
import threading
import grpc
@@ -20,89 +21,80 @@ from grpc import _common
from grpc._cython import cygrpc
-class AuthMetadataContext(
+class _AuthMetadataContext(
collections.namedtuple('AuthMetadataContext', (
- 'service_url', 'method_name',)), grpc.AuthMetadataContext):
+ 'service_url',
+ 'method_name',
+ )), grpc.AuthMetadataContext):
pass
-class AuthMetadataPluginCallback(grpc.AuthMetadataContext):
+class _CallbackState(object):
- def __init__(self, callback):
- self._callback = callback
-
- def __call__(self, metadata, error):
- self._callback(metadata, error)
+ def __init__(self):
+ self.lock = threading.Lock()
+ self.called = False
+ self.exception = None
-class _WrappedCygrpcCallback(object):
+class _AuthMetadataPluginCallback(grpc.AuthMetadataPluginCallback):
- def __init__(self, cygrpc_callback):
- self.is_called = False
- self.error = None
- self.is_called_lock = threading.Lock()
- self.cygrpc_callback = cygrpc_callback
-
- def _invoke_failure(self, error):
- # TODO(atash) translate different Exception superclasses into different
- # status codes.
- self.cygrpc_callback(_common.EMPTY_METADATA, cygrpc.StatusCode.internal,
- _common.encode(str(error)))
-
- def _invoke_success(self, metadata):
- try:
- cygrpc_metadata = _common.to_cygrpc_metadata(metadata)
- except Exception as exception: # pylint: disable=broad-except
- self._invoke_failure(exception)
- return
- self.cygrpc_callback(cygrpc_metadata, cygrpc.StatusCode.ok, b'')
+ def __init__(self, state, callback):
+ self._state = state
+ self._callback = callback
def __call__(self, metadata, error):
- with self.is_called_lock:
- if self.is_called:
- raise RuntimeError('callback should only ever be invoked once')
- if self.error:
- self._invoke_failure(self.error)
- return
- self.is_called = True
+ with self._state.lock:
+ if self._state.exception is None:
+ if self._state.called:
+ raise RuntimeError(
+ 'AuthMetadataPluginCallback invoked more than once!')
+ else:
+ self._state.called = True
+ else:
+ raise RuntimeError(
+ 'AuthMetadataPluginCallback raised exception "{}"!'.format(
+ self._state.exception))
if error is None:
- self._invoke_success(metadata)
+ self._callback(metadata, cygrpc.StatusCode.ok, None)
else:
- self._invoke_failure(error)
-
- def notify_failure(self, error):
- with self.is_called_lock:
- if not self.is_called:
- self.error = error
+ self._callback(None, cygrpc.StatusCode.internal,
+ _common.encode(str(error)))
-class _WrappedPlugin(object):
+class _Plugin(object):
- def __init__(self, plugin):
- self.plugin = plugin
+ def __init__(self, metadata_plugin):
+ self._metadata_plugin = metadata_plugin
- def __call__(self, context, cygrpc_callback):
- wrapped_cygrpc_callback = _WrappedCygrpcCallback(cygrpc_callback)
- wrapped_context = AuthMetadataContext(
- _common.decode(context.service_url),
- _common.decode(context.method_name))
+ def __call__(self, service_url, method_name, callback):
+ context = _AuthMetadataContext(
+ _common.decode(service_url), _common.decode(method_name))
+ callback_state = _CallbackState()
+ try:
+ self._metadata_plugin(context,
+ _AuthMetadataPluginCallback(
+ callback_state, callback))
+ except Exception as exception: # pylint: disable=broad-except
+ logging.exception(
+ 'AuthMetadataPluginCallback "%s" raised exception!',
+ self._metadata_plugin)
+ with callback_state.lock:
+ callback_state.exception = exception
+ if callback_state.called:
+ return
+ callback(None, cygrpc.StatusCode.internal,
+ _common.encode(str(exception)))
+
+
+def metadata_plugin_call_credentials(metadata_plugin, name):
+ if name is None:
try:
- self.plugin(wrapped_context,
- AuthMetadataPluginCallback(wrapped_cygrpc_callback))
- except Exception as error:
- wrapped_cygrpc_callback.notify_failure(error)
- raise
-
-
-def call_credentials_metadata_plugin(plugin, name):
- """
- Args:
- plugin: A callable accepting a grpc.AuthMetadataContext
- object and a callback (itself accepting a list of metadata key/value
- 2-tuples and a None-able exception value). The callback must be eventually
- called, but need not be called in plugin's invocation.
- plugin's invocation must be non-blocking.
- """
- return cygrpc.call_credentials_metadata_plugin(
- cygrpc.CredentialsMetadataPlugin(
- _WrappedPlugin(plugin), _common.encode(name)))
+ effective_name = metadata_plugin.__name__
+ except AttributeError:
+ effective_name = metadata_plugin.__class__.__name__
+ else:
+ effective_name = name
+ return grpc.CallCredentials(
+ cygrpc.MetadataPluginCallCredentials(
+ _Plugin(metadata_plugin), _common.encode(effective_name)))
diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py
index cd59b07c04..c988e0c87c 100644
--- a/src/python/grpcio/grpc/_server.py
+++ b/src/python/grpcio/grpc/_server.py
@@ -23,6 +23,7 @@ import six
import grpc
from grpc import _common
+from grpc import _interceptor
from grpc._cython import cygrpc
from grpc.framework.foundation import callable_util
@@ -49,7 +50,7 @@ _UNEXPECTED_EXIT_SERVER_GRACE = 1.0
def _serialized_request(request_event):
- return request_event.batch_operations[0].received_message.bytes()
+ return request_event.batch_operations[0].message()
def _application_code(code):
@@ -77,7 +78,9 @@ def _details(state):
class _HandlerCallDetails(
collections.namedtuple('_HandlerCallDetails', (
- 'method', 'invocation_metadata',)), grpc.HandlerCallDetails):
+ 'method',
+ 'invocation_metadata',
+ )), grpc.HandlerCallDetails):
pass
@@ -96,6 +99,7 @@ class _RPCState(object):
self.statused = False
self.rpc_errors = []
self.callbacks = []
+ self.abortion = None
def _raise_rpc_error(state):
@@ -128,20 +132,20 @@ def _abort(state, call, code, details):
effective_code = _abortion_code(state, code)
effective_details = details if state.details is None else state.details
if state.initial_metadata_allowed:
- operations = (cygrpc.operation_send_initial_metadata(
- _common.EMPTY_METADATA,
- _EMPTY_FLAGS), cygrpc.operation_send_status_from_server(
- _common.to_cygrpc_metadata(state.trailing_metadata),
- effective_code, effective_details, _EMPTY_FLAGS),)
+ operations = (
+ cygrpc.SendInitialMetadataOperation(None, _EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
+ state.trailing_metadata, effective_code, effective_details,
+ _EMPTY_FLAGS),
+ )
token = _SEND_INITIAL_METADATA_AND_SEND_STATUS_FROM_SERVER_TOKEN
else:
- operations = (cygrpc.operation_send_status_from_server(
- _common.to_cygrpc_metadata(state.trailing_metadata),
- effective_code, effective_details, _EMPTY_FLAGS),)
+ operations = (cygrpc.SendStatusFromServerOperation(
+ state.trailing_metadata, effective_code, effective_details,
+ _EMPTY_FLAGS),)
token = _SEND_STATUS_FROM_SERVER_TOKEN
- call.start_server_batch(
- cygrpc.Operations(operations),
- _send_status_from_server(state, token))
+ call.start_server_batch(operations,
+ _send_status_from_server(state, token))
state.statused = True
state.due.add(token)
@@ -150,8 +154,7 @@ def _receive_close_on_server(state):
def receive_close_on_server(receive_close_on_server_event):
with state.condition:
- if receive_close_on_server_event.batch_operations[
- 0].received_cancelled:
+ if receive_close_on_server_event.batch_operations[0].cancelled():
state.client = _CANCELLED
elif state.client is _OPEN:
state.client = _CLOSED
@@ -217,12 +220,10 @@ class _Context(grpc.ServicerContext):
return self._state.client is not _CANCELLED and not self._state.statused
def time_remaining(self):
- return max(
- float(self._rpc_event.request_call_details.deadline) - time.time(),
- 0)
+ return max(self._rpc_event.call_details.deadline - time.time(), 0)
def cancel(self):
- self._rpc_event.operation_call.cancel()
+ self._rpc_event.call.cancel()
def add_callback(self, callback):
with self._state.condition:
@@ -237,23 +238,23 @@ class _Context(grpc.ServicerContext):
self._state.disable_next_compression = True
def invocation_metadata(self):
- return _common.to_application_metadata(self._rpc_event.request_metadata)
+ return self._rpc_event.invocation_metadata
def peer(self):
- return _common.decode(self._rpc_event.operation_call.peer())
+ return _common.decode(self._rpc_event.call.peer())
def peer_identities(self):
- return cygrpc.peer_identities(self._rpc_event.operation_call)
+ return cygrpc.peer_identities(self._rpc_event.call)
def peer_identity_key(self):
- id_key = cygrpc.peer_identity_key(self._rpc_event.operation_call)
+ id_key = cygrpc.peer_identity_key(self._rpc_event.call)
return id_key if id_key is None else _common.decode(id_key)
def auth_context(self):
return {
_common.decode(key): value
for key, value in six.iteritems(
- cygrpc.auth_context(self._rpc_event.operation_call))
+ cygrpc.auth_context(self._rpc_event.call))
}
def send_initial_metadata(self, initial_metadata):
@@ -262,12 +263,10 @@ class _Context(grpc.ServicerContext):
_raise_rpc_error(self._state)
else:
if self._state.initial_metadata_allowed:
- operation = cygrpc.operation_send_initial_metadata(
- _common.to_cygrpc_metadata(initial_metadata),
- _EMPTY_FLAGS)
- self._rpc_event.operation_call.start_server_batch(
- cygrpc.Operations((operation,)),
- _send_initial_metadata(self._state))
+ operation = cygrpc.SendInitialMetadataOperation(
+ initial_metadata, _EMPTY_FLAGS)
+ self._rpc_event.call.start_server_batch(
+ (operation,), _send_initial_metadata(self._state))
self._state.initial_metadata_allowed = False
self._state.due.add(_SEND_INITIAL_METADATA_TOKEN)
else:
@@ -275,8 +274,20 @@ class _Context(grpc.ServicerContext):
def set_trailing_metadata(self, trailing_metadata):
with self._state.condition:
- self._state.trailing_metadata = _common.to_cygrpc_metadata(
- trailing_metadata)
+ self._state.trailing_metadata = trailing_metadata
+
+ def abort(self, code, details):
+ # treat OK like other invalid arguments: fail the RPC
+ if code == grpc.StatusCode.OK:
+ logging.error(
+ 'abort() called with StatusCode.OK; returning UNKNOWN')
+ code = grpc.StatusCode.UNKNOWN
+ details = ''
+ with self._state.condition:
+ self._state.code = code
+ self._state.details = _common.encode(details)
+ self._state.abortion = Exception()
+ raise self._state.abortion
def set_code(self, code):
with self._state.condition:
@@ -301,8 +312,7 @@ class _RequestIterator(object):
raise StopIteration()
else:
self._call.start_server_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_message(_EMPTY_FLAGS),)),
+ (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),),
_receive_message(self._state, self._call,
self._request_deserializer))
self._state.due.add(_RECEIVE_MESSAGE_TOKEN)
@@ -344,10 +354,9 @@ def _unary_request(rpc_event, state, request_deserializer):
if state.client is _CANCELLED or state.statused:
return None
else:
- rpc_event.operation_call.start_server_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_message(_EMPTY_FLAGS),)),
- _receive_message(state, rpc_event.operation_call,
+ rpc_event.call.start_server_batch(
+ (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),),
+ _receive_message(state, rpc_event.call,
request_deserializer))
state.due.add(_RECEIVE_MESSAGE_TOKEN)
while True:
@@ -355,8 +364,8 @@ def _unary_request(rpc_event, state, request_deserializer):
if state.request is None:
if state.client is _CLOSED:
details = '"{}" requires exactly one request message.'.format(
- rpc_event.request_call_details.method)
- _abort(state, rpc_event.operation_call,
+ rpc_event.call_details.method)
+ _abort(state, rpc_event.call,
cygrpc.StatusCode.unimplemented,
_common.encode(details))
return None
@@ -374,13 +383,16 @@ def _call_behavior(rpc_event, state, behavior, argument, request_deserializer):
context = _Context(rpc_event, state, request_deserializer)
try:
return behavior(argument, context), True
- except Exception as e: # pylint: disable=broad-except
+ except Exception as exception: # pylint: disable=broad-except
with state.condition:
- if e not in state.rpc_errors:
- details = 'Exception calling application: {}'.format(e)
+ if exception is state.abortion:
+ _abort(state, rpc_event.call, cygrpc.StatusCode.unknown,
+ b'RPC Aborted')
+ elif exception not in state.rpc_errors:
+ details = 'Exception calling application: {}'.format(exception)
logging.exception(details)
- _abort(state, rpc_event.operation_call,
- cygrpc.StatusCode.unknown, _common.encode(details))
+ _abort(state, rpc_event.call, cygrpc.StatusCode.unknown,
+ _common.encode(details))
return None, False
@@ -389,13 +401,16 @@ def _take_response_from_response_iterator(rpc_event, state, response_iterator):
return next(response_iterator), True
except StopIteration:
return None, True
- except Exception as e: # pylint: disable=broad-except
+ except Exception as exception: # pylint: disable=broad-except
with state.condition:
- if e not in state.rpc_errors:
- details = 'Exception iterating responses: {}'.format(e)
+ if exception is state.abortion:
+ _abort(state, rpc_event.call, cygrpc.StatusCode.unknown,
+ b'RPC Aborted')
+ elif exception not in state.rpc_errors:
+ details = 'Exception iterating responses: {}'.format(exception)
logging.exception(details)
- _abort(state, rpc_event.operation_call,
- cygrpc.StatusCode.unknown, _common.encode(details))
+ _abort(state, rpc_event.call, cygrpc.StatusCode.unknown,
+ _common.encode(details))
return None, False
@@ -403,7 +418,7 @@ def _serialize_response(rpc_event, state, response, response_serializer):
serialized_response = _common.serialize(response, response_serializer)
if serialized_response is None:
with state.condition:
- _abort(state, rpc_event.operation_call, cygrpc.StatusCode.internal,
+ _abort(state, rpc_event.call, cygrpc.StatusCode.internal,
b'Failed to serialize response!')
return None
else:
@@ -416,18 +431,19 @@ def _send_response(rpc_event, state, serialized_response):
return False
else:
if state.initial_metadata_allowed:
- operations = (cygrpc.operation_send_initial_metadata(
- _common.EMPTY_METADATA, _EMPTY_FLAGS),
- cygrpc.operation_send_message(serialized_response,
- _EMPTY_FLAGS),)
+ operations = (
+ cygrpc.SendInitialMetadataOperation(None, _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(serialized_response,
+ _EMPTY_FLAGS),
+ )
state.initial_metadata_allowed = False
token = _SEND_INITIAL_METADATA_AND_SEND_MESSAGE_TOKEN
else:
- operations = (cygrpc.operation_send_message(serialized_response,
- _EMPTY_FLAGS),)
+ operations = (cygrpc.SendMessageOperation(
+ serialized_response, _EMPTY_FLAGS),)
token = _SEND_MESSAGE_TOKEN
- rpc_event.operation_call.start_server_batch(
- cygrpc.Operations(operations), _send_message(state, token))
+ rpc_event.call.start_server_batch(operations,
+ _send_message(state, token))
state.due.add(token)
while True:
state.condition.wait()
@@ -438,24 +454,21 @@ def _send_response(rpc_event, state, serialized_response):
def _status(rpc_event, state, serialized_response):
with state.condition:
if state.client is not _CANCELLED:
- trailing_metadata = _common.to_cygrpc_metadata(
- state.trailing_metadata)
code = _completion_code(state)
details = _details(state)
operations = [
- cygrpc.operation_send_status_from_server(
- trailing_metadata, code, details, _EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
+ state.trailing_metadata, code, details, _EMPTY_FLAGS),
]
if state.initial_metadata_allowed:
operations.append(
- cygrpc.operation_send_initial_metadata(
- _common.EMPTY_METADATA, _EMPTY_FLAGS))
+ cygrpc.SendInitialMetadataOperation(None, _EMPTY_FLAGS))
if serialized_response is not None:
operations.append(
- cygrpc.operation_send_message(serialized_response,
- _EMPTY_FLAGS))
- rpc_event.operation_call.start_server_batch(
- cygrpc.Operations(operations),
+ cygrpc.SendMessageOperation(serialized_response,
+ _EMPTY_FLAGS))
+ rpc_event.call.start_server_batch(
+ operations,
_send_status_from_server(state, _SEND_STATUS_FROM_SERVER_TOKEN))
state.statused = True
state.due.add(_SEND_STATUS_FROM_SERVER_TOKEN)
@@ -521,7 +534,7 @@ def _handle_unary_stream(rpc_event, state, method_handler, thread_pool):
def _handle_stream_unary(rpc_event, state, method_handler, thread_pool):
- request_iterator = _RequestIterator(state, rpc_event.operation_call,
+ request_iterator = _RequestIterator(state, rpc_event.call,
method_handler.request_deserializer)
return thread_pool.submit(
_unary_response_in_pool, rpc_event, state, method_handler.stream_unary,
@@ -530,7 +543,7 @@ def _handle_stream_unary(rpc_event, state, method_handler, thread_pool):
def _handle_stream_stream(rpc_event, state, method_handler, thread_pool):
- request_iterator = _RequestIterator(state, rpc_event.operation_call,
+ request_iterator = _RequestIterator(state, rpc_event.call,
method_handler.request_deserializer)
return thread_pool.submit(
_stream_response_in_pool, rpc_event, state,
@@ -538,36 +551,44 @@ def _handle_stream_stream(rpc_event, state, method_handler, thread_pool):
method_handler.request_deserializer, method_handler.response_serializer)
-def _find_method_handler(rpc_event, generic_handlers):
- for generic_handler in generic_handlers:
- method_handler = generic_handler.service(
- _HandlerCallDetails(
- _common.decode(rpc_event.request_call_details.method),
- rpc_event.request_metadata))
- if method_handler is not None:
- return method_handler
- else:
+def _find_method_handler(rpc_event, generic_handlers, interceptor_pipeline):
+
+ def query_handlers(handler_call_details):
+ for generic_handler in generic_handlers:
+ method_handler = generic_handler.service(handler_call_details)
+ if method_handler is not None:
+ return method_handler
return None
+ handler_call_details = _HandlerCallDetails(
+ _common.decode(rpc_event.call_details.method),
+ rpc_event.invocation_metadata)
+
+ if interceptor_pipeline is not None:
+ return interceptor_pipeline.execute(query_handlers,
+ handler_call_details)
+ else:
+ return query_handlers(handler_call_details)
+
def _reject_rpc(rpc_event, status, details):
- operations = (cygrpc.operation_send_initial_metadata(_common.EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
- _common.EMPTY_METADATA, status, details, _EMPTY_FLAGS),)
+ operations = (
+ cygrpc.SendInitialMetadataOperation(None, _EMPTY_FLAGS),
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(None, status, details,
+ _EMPTY_FLAGS),
+ )
rpc_state = _RPCState()
- rpc_event.operation_call.start_server_batch(
- operations, lambda ignored_event: (rpc_state, (),))
+ rpc_event.call.start_server_batch(operations,
+ lambda ignored_event: (rpc_state, (),))
return rpc_state
def _handle_with_method_handler(rpc_event, method_handler, thread_pool):
state = _RPCState()
with state.condition:
- rpc_event.operation_call.start_server_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),)),
+ rpc_event.call.start_server_batch(
+ (cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),),
_receive_close_on_server(state))
state.due.add(_RECEIVE_CLOSE_ON_SERVER_TOKEN)
if method_handler.request_streaming:
@@ -586,12 +607,19 @@ def _handle_with_method_handler(rpc_event, method_handler, thread_pool):
method_handler, thread_pool)
-def _handle_call(rpc_event, generic_handlers, thread_pool,
+def _handle_call(rpc_event, generic_handlers, interceptor_pipeline, thread_pool,
concurrency_exceeded):
if not rpc_event.success:
return None, None
- if rpc_event.request_call_details.method is not None:
- method_handler = _find_method_handler(rpc_event, generic_handlers)
+ if rpc_event.call_details.method is not None:
+ try:
+ method_handler = _find_method_handler(rpc_event, generic_handlers,
+ interceptor_pipeline)
+ except Exception as exception: # pylint: disable=broad-except
+ details = 'Exception servicing handler: {}'.format(exception)
+ logging.exception(details)
+ return _reject_rpc(rpc_event, cygrpc.StatusCode.unknown,
+ b'Error in service handler!'), None
if method_handler is None:
return _reject_rpc(rpc_event, cygrpc.StatusCode.unimplemented,
b'Method not found!'), None
@@ -614,12 +642,14 @@ class _ServerStage(enum.Enum):
class _ServerState(object):
- def __init__(self, completion_queue, server, generic_handlers, thread_pool,
- maximum_concurrent_rpcs):
- self.lock = threading.Lock()
+ # pylint: disable=too-many-arguments
+ def __init__(self, completion_queue, server, generic_handlers,
+ interceptor_pipeline, thread_pool, maximum_concurrent_rpcs):
+ self.lock = threading.RLock()
self.completion_queue = completion_queue
self.server = server
self.generic_handlers = list(generic_handlers)
+ self.interceptor_pipeline = interceptor_pipeline
self.thread_pool = thread_pool
self.stage = _ServerStage.STOPPED
self.shutdown_events = None
@@ -684,8 +714,8 @@ def _serve(state):
state.maximum_concurrent_rpcs is not None and
state.active_rpc_count >= state.maximum_concurrent_rpcs)
rpc_state, rpc_future = _handle_call(
- event, state.generic_handlers, state.thread_pool,
- concurrency_exceeded)
+ event, state.generic_handlers, state.interceptor_pipeline,
+ state.thread_pool, concurrency_exceeded)
if rpc_state is not None:
state.rpc_states.add(rpc_state)
if rpc_future is not None:
@@ -728,22 +758,12 @@ def _stop(state, grace):
state.shutdown_events.append(shutdown_event)
if grace is None:
state.server.cancel_all_calls()
- # TODO(https://github.com/grpc/grpc/issues/6597): delete this loop.
- for rpc_state in state.rpc_states:
- with rpc_state.condition:
- rpc_state.client = _CANCELLED
- rpc_state.condition.notify_all()
else:
def cancel_all_calls_after_grace():
shutdown_event.wait(timeout=grace)
with state.lock:
state.server.cancel_all_calls()
- # TODO(https://github.com/grpc/grpc/issues/6597): delete this loop.
- for rpc_state in state.rpc_states:
- with rpc_state.condition:
- rpc_state.client = _CANCELLED
- rpc_state.condition.notify_all()
thread = threading.Thread(target=cancel_all_calls_after_grace)
thread.start()
@@ -773,12 +793,14 @@ def _start(state):
class Server(grpc.Server):
- def __init__(self, thread_pool, generic_handlers, options,
+ # pylint: disable=too-many-arguments
+ def __init__(self, thread_pool, generic_handlers, interceptors, options,
maximum_concurrent_rpcs):
completion_queue = cygrpc.CompletionQueue()
- server = cygrpc.Server(_common.channel_args(options))
+ server = cygrpc.Server(options)
server.register_completion_queue(completion_queue)
self._state = _ServerState(completion_queue, server, generic_handlers,
+ _interceptor.service_pipeline(interceptors),
thread_pool, maximum_concurrent_rpcs)
def add_generic_rpc_handlers(self, generic_rpc_handlers):
@@ -788,8 +810,8 @@ class Server(grpc.Server):
return _add_insecure_port(self._state, _common.encode(address))
def add_secure_port(self, address, server_credentials):
- return _add_secure_port(self._state,
- _common.encode(address), server_credentials)
+ return _add_secure_port(self._state, _common.encode(address),
+ server_credentials)
def start(self):
_start(self._state)
diff --git a/src/python/grpcio/grpc/_utilities.py b/src/python/grpcio/grpc/_utilities.py
index 47cedcc867..25bd1ceae2 100644
--- a/src/python/grpcio/grpc/_utilities.py
+++ b/src/python/grpcio/grpc/_utilities.py
@@ -29,9 +29,15 @@ _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE = (
class RpcMethodHandler(
collections.namedtuple('_RpcMethodHandler', (
- 'request_streaming', 'response_streaming', 'request_deserializer',
- 'response_serializer', 'unary_unary', 'unary_stream',
- 'stream_unary', 'stream_stream',)), grpc.RpcMethodHandler):
+ 'request_streaming',
+ 'response_streaming',
+ 'request_deserializer',
+ 'response_serializer',
+ 'unary_unary',
+ 'unary_stream',
+ 'stream_unary',
+ 'stream_stream',
+ )), grpc.RpcMethodHandler):
pass
diff --git a/src/python/grpcio/grpc/beta/_client_adaptations.py b/src/python/grpcio/grpc/beta/_client_adaptations.py
index 73ce22fa98..cf200a8c13 100644
--- a/src/python/grpcio/grpc/beta/_client_adaptations.py
+++ b/src/python/grpcio/grpc/beta/_client_adaptations.py
@@ -15,6 +15,7 @@
import grpc
from grpc import _common
+from grpc.beta import _metadata
from grpc.beta import interfaces
from grpc.framework.common import cardinality
from grpc.framework.foundation import future
@@ -50,8 +51,7 @@ def _abortion(rpc_error_call):
code = rpc_error_call.code()
pair = _STATUS_CODE_TO_ABORTION_KIND_AND_ABORTION_ERROR_CLASS.get(code)
error_kind = face.Abortion.Kind.LOCAL_FAILURE if pair is None else pair[0]
- return face.Abortion(error_kind,
- rpc_error_call.initial_metadata(),
+ return face.Abortion(error_kind, rpc_error_call.initial_metadata(),
rpc_error_call.trailing_metadata(), code,
rpc_error_call.details())
@@ -157,10 +157,10 @@ class _Rendezvous(future.Future, face.Call):
return _InvocationProtocolContext()
def initial_metadata(self):
- return self._call.initial_metadata()
+ return _metadata.beta(self._call.initial_metadata())
def terminal_metadata(self):
- return self._call.terminal_metadata()
+ return _metadata.beta(self._call.terminal_metadata())
def code(self):
return self._call.code()
@@ -182,14 +182,14 @@ def _blocking_unary_unary(channel, group, method, timeout, with_call,
response, call = multi_callable.with_call(
request,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
return response, _Rendezvous(None, None, call)
else:
return multi_callable(
request,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
except grpc.RpcError as rpc_error_call:
raise _abortion_error(rpc_error_call)
@@ -206,7 +206,7 @@ def _future_unary_unary(channel, group, method, timeout, protocol_options,
response_future = multi_callable.future(
request,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
return _Rendezvous(response_future, None, response_future)
@@ -222,7 +222,7 @@ def _unary_stream(channel, group, method, timeout, protocol_options, metadata,
response_iterator = multi_callable(
request,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
return _Rendezvous(None, response_iterator, response_iterator)
@@ -241,14 +241,14 @@ def _blocking_stream_unary(channel, group, method, timeout, with_call,
response, call = multi_callable.with_call(
request_iterator,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
return response, _Rendezvous(None, None, call)
else:
return multi_callable(
request_iterator,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
except grpc.RpcError as rpc_error_call:
raise _abortion_error(rpc_error_call)
@@ -265,7 +265,7 @@ def _future_stream_unary(channel, group, method, timeout, protocol_options,
response_future = multi_callable.future(
request_iterator,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
return _Rendezvous(response_future, None, response_future)
@@ -281,7 +281,7 @@ def _stream_stream(channel, group, method, timeout, protocol_options, metadata,
response_iterator = multi_callable(
request_iterator,
timeout=timeout,
- metadata=effective_metadata,
+ metadata=_metadata.unbeta(effective_metadata),
credentials=_credentials(protocol_options))
return _Rendezvous(None, response_iterator, response_iterator)
@@ -440,9 +440,14 @@ class _GenericStub(face.GenericStub):
metadata=None,
with_call=None,
protocol_options=None):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _blocking_unary_unary(self._channel, group, method, timeout,
with_call, protocol_options, metadata,
self._metadata_transformer, request,
@@ -455,9 +460,14 @@ class _GenericStub(face.GenericStub):
timeout,
metadata=None,
protocol_options=None):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _future_unary_unary(self._channel, group, method, timeout,
protocol_options, metadata,
self._metadata_transformer, request,
@@ -470,9 +480,14 @@ class _GenericStub(face.GenericStub):
timeout,
metadata=None,
protocol_options=None):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _unary_stream(self._channel, group, method, timeout,
protocol_options, metadata,
self._metadata_transformer, request,
@@ -486,9 +501,14 @@ class _GenericStub(face.GenericStub):
metadata=None,
with_call=None,
protocol_options=None):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _blocking_stream_unary(
self._channel, group, method, timeout, with_call, protocol_options,
metadata, self._metadata_transformer, request_iterator,
@@ -501,9 +521,14 @@ class _GenericStub(face.GenericStub):
timeout,
metadata=None,
protocol_options=None):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _future_stream_unary(
self._channel, group, method, timeout, protocol_options, metadata,
self._metadata_transformer, request_iterator, request_serializer,
@@ -516,9 +541,14 @@ class _GenericStub(face.GenericStub):
timeout,
metadata=None,
protocol_options=None):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _stream_stream(self._channel, group, method, timeout,
protocol_options, metadata,
self._metadata_transformer, request_iterator,
@@ -567,33 +597,53 @@ class _GenericStub(face.GenericStub):
raise NotImplementedError()
def unary_unary(self, group, method):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _UnaryUnaryMultiCallable(
self._channel, group, method, self._metadata_transformer,
request_serializer, response_deserializer)
def unary_stream(self, group, method):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _UnaryStreamMultiCallable(
self._channel, group, method, self._metadata_transformer,
request_serializer, response_deserializer)
def stream_unary(self, group, method):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _StreamUnaryMultiCallable(
self._channel, group, method, self._metadata_transformer,
request_serializer, response_deserializer)
def stream_stream(self, group, method):
- request_serializer = self._request_serializers.get((group, method,))
- response_deserializer = self._response_deserializers.get((group,
- method,))
+ request_serializer = self._request_serializers.get((
+ group,
+ method,
+ ))
+ response_deserializer = self._response_deserializers.get((
+ group,
+ method,
+ ))
return _StreamStreamMultiCallable(
self._channel, group, method, self._metadata_transformer,
request_serializer, response_deserializer)
@@ -623,8 +673,8 @@ class _DynamicStub(face.DynamicStub):
elif method_cardinality is cardinality.Cardinality.STREAM_STREAM:
return self._generic_stub.stream_stream(self._group, attr)
else:
- raise AttributeError('_DynamicStub object has no attribute "%s"!' %
- attr)
+ raise AttributeError(
+ '_DynamicStub object has no attribute "%s"!' % attr)
def __enter__(self):
return self
diff --git a/src/python/grpcio/grpc/beta/_metadata.py b/src/python/grpcio/grpc/beta/_metadata.py
new file mode 100644
index 0000000000..b7c8535285
--- /dev/null
+++ b/src/python/grpcio/grpc/beta/_metadata.py
@@ -0,0 +1,52 @@
+# 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.
+"""API metadata conversion utilities."""
+
+import collections
+
+_Metadatum = collections.namedtuple('_Metadatum', (
+ 'key',
+ 'value',
+))
+
+
+def _beta_metadatum(key, value):
+ beta_key = key if isinstance(key, (bytes,)) else key.encode('ascii')
+ beta_value = value if isinstance(value, (bytes,)) else value.encode('ascii')
+ return _Metadatum(beta_key, beta_value)
+
+
+def _metadatum(beta_key, beta_value):
+ key = beta_key if isinstance(beta_key, (str,)) else beta_key.decode('utf8')
+ if isinstance(beta_value, (str,)) or key[-4:] == '-bin':
+ value = beta_value
+ else:
+ value = beta_value.decode('utf8')
+ return _Metadatum(key, value)
+
+
+def beta(metadata):
+ if metadata is None:
+ return ()
+ else:
+ return tuple(_beta_metadatum(key, value) for key, value in metadata)
+
+
+def unbeta(beta_metadata):
+ if beta_metadata is None:
+ return ()
+ else:
+ return tuple(
+ _metadatum(beta_key, beta_value)
+ for beta_key, beta_value in beta_metadata)
diff --git a/src/python/grpcio/grpc/beta/_server_adaptations.py b/src/python/grpcio/grpc/beta/_server_adaptations.py
index ec363e9bc9..3c04fd7639 100644
--- a/src/python/grpcio/grpc/beta/_server_adaptations.py
+++ b/src/python/grpcio/grpc/beta/_server_adaptations.py
@@ -18,6 +18,7 @@ import threading
import grpc
from grpc import _common
+from grpc.beta import _metadata
from grpc.beta import interfaces
from grpc.framework.common import cardinality
from grpc.framework.common import style
@@ -65,14 +66,15 @@ class _FaceServicerContext(face.ServicerContext):
return _ServerProtocolContext(self._servicer_context)
def invocation_metadata(self):
- return _common.to_cygrpc_metadata(
- self._servicer_context.invocation_metadata())
+ return _metadata.beta(self._servicer_context.invocation_metadata())
def initial_metadata(self, initial_metadata):
- self._servicer_context.send_initial_metadata(initial_metadata)
+ self._servicer_context.send_initial_metadata(
+ _metadata.unbeta(initial_metadata))
def terminal_metadata(self, terminal_metadata):
- self._servicer_context.set_terminal_metadata(terminal_metadata)
+ self._servicer_context.set_terminal_metadata(
+ _metadata.unbeta(terminal_metadata))
def code(self, code):
self._servicer_context.set_code(code)
@@ -243,9 +245,15 @@ def _adapt_stream_stream_event(stream_stream_event):
class _SimpleMethodHandler(
collections.namedtuple('_MethodHandler', (
- 'request_streaming', 'response_streaming', 'request_deserializer',
- 'response_serializer', 'unary_unary', 'unary_stream',
- 'stream_unary', 'stream_stream',)), grpc.RpcMethodHandler):
+ 'request_streaming',
+ 'response_streaming',
+ 'request_deserializer',
+ 'response_serializer',
+ 'unary_unary',
+ 'unary_stream',
+ 'stream_unary',
+ 'stream_stream',
+ )), grpc.RpcMethodHandler):
pass
@@ -253,15 +261,17 @@ def _simple_method_handler(implementation, request_deserializer,
response_serializer):
if implementation.style is style.Service.INLINE:
if implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
- return _SimpleMethodHandler(
- False, False, request_deserializer, response_serializer,
- _adapt_unary_request_inline(implementation.unary_unary_inline),
- None, None, None)
+ return _SimpleMethodHandler(False, False, request_deserializer,
+ response_serializer,
+ _adapt_unary_request_inline(
+ implementation.unary_unary_inline),
+ None, None, None)
elif implementation.cardinality is cardinality.Cardinality.UNARY_STREAM:
- return _SimpleMethodHandler(
- False, True, request_deserializer, response_serializer, None,
- _adapt_unary_request_inline(implementation.unary_stream_inline),
- None, None)
+ return _SimpleMethodHandler(False, True, request_deserializer,
+ response_serializer, None,
+ _adapt_unary_request_inline(
+ implementation.unary_stream_inline),
+ None, None)
elif implementation.cardinality is cardinality.Cardinality.STREAM_UNARY:
return _SimpleMethodHandler(True, False, request_deserializer,
response_serializer, None, None,
@@ -276,26 +286,28 @@ def _simple_method_handler(implementation, request_deserializer,
implementation.stream_stream_inline))
elif implementation.style is style.Service.EVENT:
if implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
- return _SimpleMethodHandler(
- False, False, request_deserializer, response_serializer,
- _adapt_unary_unary_event(implementation.unary_unary_event),
- None, None, None)
+ return _SimpleMethodHandler(False, False, request_deserializer,
+ response_serializer,
+ _adapt_unary_unary_event(
+ implementation.unary_unary_event),
+ None, None, None)
elif implementation.cardinality is cardinality.Cardinality.UNARY_STREAM:
- return _SimpleMethodHandler(
- False, True, request_deserializer, response_serializer, None,
- _adapt_unary_stream_event(implementation.unary_stream_event),
- None, None)
+ return _SimpleMethodHandler(False, True, request_deserializer,
+ response_serializer, None,
+ _adapt_unary_stream_event(
+ implementation.unary_stream_event),
+ None, None)
elif implementation.cardinality is cardinality.Cardinality.STREAM_UNARY:
- return _SimpleMethodHandler(
- True, False, request_deserializer, response_serializer, None,
- None,
- _adapt_stream_unary_event(implementation.stream_unary_event),
- None)
+ return _SimpleMethodHandler(True, False, request_deserializer,
+ response_serializer, None, None,
+ _adapt_stream_unary_event(
+ implementation.stream_unary_event),
+ None)
elif implementation.cardinality is cardinality.Cardinality.STREAM_STREAM:
- return _SimpleMethodHandler(
- True, True, request_deserializer, response_serializer, None,
- None, None,
- _adapt_stream_stream_event(implementation.stream_stream_event))
+ return _SimpleMethodHandler(True, True, request_deserializer,
+ response_serializer, None, None, None,
+ _adapt_stream_stream_event(
+ implementation.stream_stream_event))
def _flatten_method_pair_map(method_pair_map):
@@ -323,10 +335,11 @@ class _GenericRpcHandler(grpc.GenericRpcHandler):
method_implementation = self._method_implementations.get(
handler_call_details.method)
if method_implementation is not None:
- return _simple_method_handler(
- method_implementation,
- self._request_deserializers.get(handler_call_details.method),
- self._response_serializers.get(handler_call_details.method))
+ return _simple_method_handler(method_implementation,
+ self._request_deserializers.get(
+ handler_call_details.method),
+ self._response_serializers.get(
+ handler_call_details.method))
elif self._multi_method_implementation is None:
return None
else:
diff --git a/src/python/grpcio/grpc/beta/implementations.py b/src/python/grpcio/grpc/beta/implementations.py
index e52ce764b5..44dbd61c55 100644
--- a/src/python/grpcio/grpc/beta/implementations.py
+++ b/src/python/grpcio/grpc/beta/implementations.py
@@ -21,6 +21,7 @@ import threading # pylint: disable=unused-import
import grpc
from grpc import _auth
from grpc.beta import _client_adaptations
+from grpc.beta import _metadata
from grpc.beta import _server_adaptations
from grpc.beta import interfaces # pylint: disable=unused-import
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -31,7 +32,18 @@ from grpc.framework.interfaces.face import face # pylint: disable=unused-import
ChannelCredentials = grpc.ChannelCredentials
ssl_channel_credentials = grpc.ssl_channel_credentials
CallCredentials = grpc.CallCredentials
-metadata_call_credentials = grpc.metadata_call_credentials
+
+
+def metadata_call_credentials(metadata_plugin, name=None):
+
+ def plugin(context, callback):
+
+ def wrapped_callback(beta_metadata, error):
+ callback(_metadata.unbeta(beta_metadata), error)
+
+ metadata_plugin(context, wrapped_callback)
+
+ return grpc.metadata_call_credentials(plugin, name=name)
def google_call_credentials(credentials):
@@ -98,8 +110,8 @@ def insecure_channel(host, port):
Returns:
A Channel to the remote host through which RPCs may be conducted.
"""
- channel = grpc.insecure_channel(host
- if port is None else '%s:%d' % (host, port))
+ channel = grpc.insecure_channel(host if port is None else '%s:%d' % (host,
+ port))
return Channel(channel)
diff --git a/src/python/grpcio/grpc/framework/foundation/callable_util.py b/src/python/grpcio/grpc/framework/foundation/callable_util.py
index 5bdfda5301..b9b9c49f17 100644
--- a/src/python/grpcio/grpc/framework/foundation/callable_util.py
+++ b/src/python/grpcio/grpc/framework/foundation/callable_util.py
@@ -50,8 +50,8 @@ class _EasyOutcome(
def _call_logging_exceptions(behavior, message, *args, **kwargs):
try:
- return _EasyOutcome(Outcome.Kind.RETURNED,
- behavior(*args, **kwargs), None)
+ return _EasyOutcome(Outcome.Kind.RETURNED, behavior(*args, **kwargs),
+ None)
except Exception as e: # pylint: disable=broad-except
logging.exception(message)
return _EasyOutcome(Outcome.Kind.RAISED, None, e)
diff --git a/src/python/grpcio/grpc/framework/interfaces/base/utilities.py b/src/python/grpcio/grpc/framework/interfaces/base/utilities.py
index a9163d8588..281db62b5d 100644
--- a/src/python/grpcio/grpc/framework/interfaces/base/utilities.py
+++ b/src/python/grpcio/grpc/framework/interfaces/base/utilities.py
@@ -19,15 +19,22 @@ from grpc.framework.interfaces.base import base
class _Completion(base.Completion,
- collections.namedtuple('_Completion', ('terminal_metadata',
- 'code', 'message',))):
+ collections.namedtuple('_Completion', (
+ 'terminal_metadata',
+ 'code',
+ 'message',
+ ))):
"""A trivial implementation of base.Completion."""
class _Subscription(base.Subscription,
collections.namedtuple('_Subscription', (
- 'kind', 'termination_callback', 'allowance', 'operator',
- 'protocol_receiver',))):
+ 'kind',
+ 'termination_callback',
+ 'allowance',
+ 'operator',
+ 'protocol_receiver',
+ ))):
"""A trivial implementation of base.Subscription."""
diff --git a/src/python/grpcio/grpc/framework/interfaces/face/face.py b/src/python/grpcio/grpc/framework/interfaces/face/face.py
index 0b93ea0f49..5b47f11d0d 100644
--- a/src/python/grpcio/grpc/framework/interfaces/face/face.py
+++ b/src/python/grpcio/grpc/framework/interfaces/face/face.py
@@ -50,13 +50,20 @@ class NoSuchMethodError(Exception):
self.method = method
def __repr__(self):
- return 'face.NoSuchMethodError(%s, %s)' % (self.group, self.method,)
+ return 'face.NoSuchMethodError(%s, %s)' % (
+ self.group,
+ self.method,
+ )
class Abortion(
- collections.namedtuple('Abortion',
- ('kind', 'initial_metadata', 'terminal_metadata',
- 'code', 'details',))):
+ collections.namedtuple('Abortion', (
+ 'kind',
+ 'initial_metadata',
+ 'terminal_metadata',
+ 'code',
+ 'details',
+ ))):
"""A value describing RPC abortion.
Attributes:
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 7b684f2a58..0d87b7427f 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -15,679 +15,669 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!!
CORE_SOURCE_FILES = [
- 'src/core/lib/profiling/basic_timers.c',
- 'src/core/lib/profiling/stap_timers.c',
- 'src/core/lib/support/alloc.c',
- 'src/core/lib/support/arena.c',
- 'src/core/lib/support/atm.c',
- 'src/core/lib/support/avl.c',
- 'src/core/lib/support/backoff.c',
- 'src/core/lib/support/cmdline.c',
- 'src/core/lib/support/cpu_iphone.c',
- 'src/core/lib/support/cpu_linux.c',
- 'src/core/lib/support/cpu_posix.c',
- 'src/core/lib/support/cpu_windows.c',
- 'src/core/lib/support/env_linux.c',
- 'src/core/lib/support/env_posix.c',
- 'src/core/lib/support/env_windows.c',
- 'src/core/lib/support/histogram.c',
- 'src/core/lib/support/host_port.c',
- 'src/core/lib/support/log.c',
- 'src/core/lib/support/log_android.c',
- 'src/core/lib/support/log_linux.c',
- 'src/core/lib/support/log_posix.c',
- 'src/core/lib/support/log_windows.c',
- 'src/core/lib/support/mpscq.c',
- 'src/core/lib/support/murmur_hash.c',
- 'src/core/lib/support/stack_lockfree.c',
- 'src/core/lib/support/string.c',
- 'src/core/lib/support/string_posix.c',
- 'src/core/lib/support/string_util_windows.c',
- 'src/core/lib/support/string_windows.c',
- 'src/core/lib/support/subprocess_posix.c',
- 'src/core/lib/support/subprocess_windows.c',
- 'src/core/lib/support/sync.c',
- 'src/core/lib/support/sync_posix.c',
- 'src/core/lib/support/sync_windows.c',
- 'src/core/lib/support/thd.c',
- 'src/core/lib/support/thd_posix.c',
- 'src/core/lib/support/thd_windows.c',
- 'src/core/lib/support/time.c',
- 'src/core/lib/support/time_posix.c',
- 'src/core/lib/support/time_precise.c',
- 'src/core/lib/support/time_windows.c',
- 'src/core/lib/support/tls_pthread.c',
- 'src/core/lib/support/tmpfile_msys.c',
- 'src/core/lib/support/tmpfile_posix.c',
- 'src/core/lib/support/tmpfile_windows.c',
- 'src/core/lib/support/wrap_memcpy.c',
- 'src/core/lib/surface/init.c',
- 'src/core/lib/channel/channel_args.c',
- 'src/core/lib/channel/channel_stack.c',
- 'src/core/lib/channel/channel_stack_builder.c',
- 'src/core/lib/channel/connected_channel.c',
- 'src/core/lib/channel/handshaker.c',
- 'src/core/lib/channel/handshaker_factory.c',
- 'src/core/lib/channel/handshaker_registry.c',
- 'src/core/lib/compression/compression.c',
- 'src/core/lib/compression/message_compress.c',
- 'src/core/lib/compression/stream_compression.c',
- 'src/core/lib/compression/stream_compression_gzip.c',
- 'src/core/lib/compression/stream_compression_identity.c',
- 'src/core/lib/debug/stats.c',
- 'src/core/lib/debug/stats_data.c',
- 'src/core/lib/http/format_request.c',
- 'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/parser.c',
- 'src/core/lib/iomgr/call_combiner.c',
- 'src/core/lib/iomgr/closure.c',
- 'src/core/lib/iomgr/combiner.c',
- 'src/core/lib/iomgr/endpoint.c',
- 'src/core/lib/iomgr/endpoint_pair_posix.c',
- 'src/core/lib/iomgr/endpoint_pair_uv.c',
- 'src/core/lib/iomgr/endpoint_pair_windows.c',
- 'src/core/lib/iomgr/error.c',
- 'src/core/lib/iomgr/ev_epoll1_linux.c',
- 'src/core/lib/iomgr/ev_epollex_linux.c',
- 'src/core/lib/iomgr/ev_epollsig_linux.c',
- 'src/core/lib/iomgr/ev_poll_posix.c',
- 'src/core/lib/iomgr/ev_posix.c',
- 'src/core/lib/iomgr/ev_windows.c',
- 'src/core/lib/iomgr/exec_ctx.c',
- 'src/core/lib/iomgr/executor.c',
- 'src/core/lib/iomgr/gethostname_fallback.c',
- 'src/core/lib/iomgr/gethostname_host_name_max.c',
- 'src/core/lib/iomgr/gethostname_sysconf.c',
- 'src/core/lib/iomgr/iocp_windows.c',
- 'src/core/lib/iomgr/iomgr.c',
- 'src/core/lib/iomgr/iomgr_posix.c',
- 'src/core/lib/iomgr/iomgr_uv.c',
- 'src/core/lib/iomgr/iomgr_windows.c',
- 'src/core/lib/iomgr/is_epollexclusive_available.c',
- 'src/core/lib/iomgr/load_file.c',
- 'src/core/lib/iomgr/lockfree_event.c',
- 'src/core/lib/iomgr/network_status_tracker.c',
- 'src/core/lib/iomgr/polling_entity.c',
- 'src/core/lib/iomgr/pollset_set_uv.c',
- 'src/core/lib/iomgr/pollset_set_windows.c',
- 'src/core/lib/iomgr/pollset_uv.c',
- 'src/core/lib/iomgr/pollset_windows.c',
- 'src/core/lib/iomgr/resolve_address_posix.c',
- 'src/core/lib/iomgr/resolve_address_uv.c',
- 'src/core/lib/iomgr/resolve_address_windows.c',
- 'src/core/lib/iomgr/resource_quota.c',
- 'src/core/lib/iomgr/sockaddr_utils.c',
- 'src/core/lib/iomgr/socket_factory_posix.c',
- 'src/core/lib/iomgr/socket_mutator.c',
- 'src/core/lib/iomgr/socket_utils_common_posix.c',
- 'src/core/lib/iomgr/socket_utils_linux.c',
- 'src/core/lib/iomgr/socket_utils_posix.c',
- 'src/core/lib/iomgr/socket_utils_uv.c',
- 'src/core/lib/iomgr/socket_utils_windows.c',
- 'src/core/lib/iomgr/socket_windows.c',
- 'src/core/lib/iomgr/tcp_client_posix.c',
- 'src/core/lib/iomgr/tcp_client_uv.c',
- 'src/core/lib/iomgr/tcp_client_windows.c',
- 'src/core/lib/iomgr/tcp_posix.c',
- 'src/core/lib/iomgr/tcp_server_posix.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_common.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c',
- 'src/core/lib/iomgr/tcp_server_uv.c',
- 'src/core/lib/iomgr/tcp_server_windows.c',
- 'src/core/lib/iomgr/tcp_uv.c',
- 'src/core/lib/iomgr/tcp_windows.c',
- 'src/core/lib/iomgr/time_averaged_stats.c',
- 'src/core/lib/iomgr/timer_generic.c',
- 'src/core/lib/iomgr/timer_heap.c',
- 'src/core/lib/iomgr/timer_manager.c',
- 'src/core/lib/iomgr/timer_uv.c',
- 'src/core/lib/iomgr/udp_server.c',
- 'src/core/lib/iomgr/unix_sockets_posix.c',
- 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
- 'src/core/lib/iomgr/wakeup_fd_cv.c',
- 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
- 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
- 'src/core/lib/iomgr/wakeup_fd_pipe.c',
- 'src/core/lib/iomgr/wakeup_fd_posix.c',
- 'src/core/lib/json/json.c',
- 'src/core/lib/json/json_reader.c',
- 'src/core/lib/json/json_string.c',
- 'src/core/lib/json/json_writer.c',
- 'src/core/lib/slice/b64.c',
- 'src/core/lib/slice/percent_encoding.c',
- 'src/core/lib/slice/slice.c',
- 'src/core/lib/slice/slice_buffer.c',
- 'src/core/lib/slice/slice_hash_table.c',
- 'src/core/lib/slice/slice_intern.c',
- 'src/core/lib/slice/slice_string_helpers.c',
- 'src/core/lib/surface/alarm.c',
- 'src/core/lib/surface/api_trace.c',
- 'src/core/lib/surface/byte_buffer.c',
- 'src/core/lib/surface/byte_buffer_reader.c',
- 'src/core/lib/surface/call.c',
- 'src/core/lib/surface/call_details.c',
- 'src/core/lib/surface/call_log_batch.c',
- 'src/core/lib/surface/channel.c',
- 'src/core/lib/surface/channel_init.c',
- 'src/core/lib/surface/channel_ping.c',
- 'src/core/lib/surface/channel_stack_type.c',
- 'src/core/lib/surface/completion_queue.c',
- 'src/core/lib/surface/completion_queue_factory.c',
- 'src/core/lib/surface/event_string.c',
- 'src/core/lib/surface/lame_client.cc',
- 'src/core/lib/surface/metadata_array.c',
- 'src/core/lib/surface/server.c',
- 'src/core/lib/surface/validate_metadata.c',
- 'src/core/lib/surface/version.c',
- 'src/core/lib/transport/bdp_estimator.c',
- 'src/core/lib/transport/byte_stream.c',
- 'src/core/lib/transport/connectivity_state.c',
- 'src/core/lib/transport/error_utils.c',
- 'src/core/lib/transport/metadata.c',
- 'src/core/lib/transport/metadata_batch.c',
- 'src/core/lib/transport/pid_controller.c',
- 'src/core/lib/transport/service_config.c',
- 'src/core/lib/transport/static_metadata.c',
- 'src/core/lib/transport/status_conversion.c',
- 'src/core/lib/transport/timeout_encoding.c',
- 'src/core/lib/transport/transport.c',
- 'src/core/lib/transport/transport_op_string.c',
- 'src/core/lib/debug/trace.c',
- 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
- 'src/core/ext/transport/chttp2/transport/bin_decoder.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/flow_control.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/http2_settings.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
- 'src/core/ext/transport/chttp2/alpn/alpn.c',
- 'src/core/ext/filters/http/client/http_client_filter.c',
- 'src/core/ext/filters/http/http_filters_plugin.c',
- 'src/core/ext/filters/http/message_compress/message_compress_filter.c',
- 'src/core/ext/filters/http/server/http_server_filter.c',
- 'src/core/lib/http/httpcli_security_connector.c',
- 'src/core/lib/security/context/security_context.c',
- 'src/core/lib/security/credentials/composite/composite_credentials.c',
- 'src/core/lib/security/credentials/credentials.c',
- 'src/core/lib/security/credentials/credentials_metadata.c',
- 'src/core/lib/security/credentials/fake/fake_credentials.c',
- 'src/core/lib/security/credentials/google_default/credentials_generic.c',
- 'src/core/lib/security/credentials/google_default/google_default_credentials.c',
- 'src/core/lib/security/credentials/iam/iam_credentials.c',
- 'src/core/lib/security/credentials/jwt/json_token.c',
- 'src/core/lib/security/credentials/jwt/jwt_credentials.c',
- 'src/core/lib/security/credentials/jwt/jwt_verifier.c',
- 'src/core/lib/security/credentials/oauth2/oauth2_credentials.c',
- 'src/core/lib/security/credentials/plugin/plugin_credentials.c',
- 'src/core/lib/security/credentials/ssl/ssl_credentials.c',
- 'src/core/lib/security/transport/client_auth_filter.c',
- 'src/core/lib/security/transport/lb_targets_info.c',
- 'src/core/lib/security/transport/secure_endpoint.c',
- 'src/core/lib/security/transport/security_connector.c',
- 'src/core/lib/security/transport/security_handshaker.c',
- 'src/core/lib/security/transport/server_auth_filter.c',
- 'src/core/lib/security/transport/tsi_error.c',
- 'src/core/lib/security/util/json_util.c',
- 'src/core/lib/surface/init_secure.c',
- 'src/core/tsi/fake_transport_security.c',
- 'src/core/tsi/gts_transport_security.c',
- 'src/core/tsi/ssl_transport_security.c',
- 'src/core/tsi/transport_security_grpc.c',
- 'src/core/tsi/transport_security.c',
- 'src/core/tsi/transport_security_adapter.c',
- 'src/core/ext/transport/chttp2/server/chttp2_server.c',
- 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
- 'src/core/ext/filters/client_channel/channel_connectivity.c',
- 'src/core/ext/filters/client_channel/client_channel.c',
- 'src/core/ext/filters/client_channel/client_channel_factory.c',
- 'src/core/ext/filters/client_channel/client_channel_plugin.c',
- 'src/core/ext/filters/client_channel/connector.c',
- 'src/core/ext/filters/client_channel/http_connect_handshaker.c',
- 'src/core/ext/filters/client_channel/http_proxy.c',
- 'src/core/ext/filters/client_channel/lb_policy.c',
- 'src/core/ext/filters/client_channel/lb_policy_factory.c',
- 'src/core/ext/filters/client_channel/lb_policy_registry.c',
- 'src/core/ext/filters/client_channel/parse_address.c',
- 'src/core/ext/filters/client_channel/proxy_mapper.c',
- 'src/core/ext/filters/client_channel/proxy_mapper_registry.c',
- 'src/core/ext/filters/client_channel/resolver.c',
- 'src/core/ext/filters/client_channel/resolver_factory.c',
- 'src/core/ext/filters/client_channel/resolver_registry.c',
- 'src/core/ext/filters/client_channel/retry_throttle.c',
- 'src/core/ext/filters/client_channel/subchannel.c',
- 'src/core/ext/filters/client_channel/subchannel_index.c',
- 'src/core/ext/filters/client_channel/uri_parser.c',
- 'src/core/ext/filters/deadline/deadline_filter.c',
- 'src/core/ext/transport/chttp2/client/chttp2_connector.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
- 'src/core/ext/transport/inproc/inproc_plugin.c',
- 'src/core/ext/transport/inproc/inproc_transport.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
- 'third_party/nanopb/pb_common.c',
- 'third_party/nanopb/pb_decode.c',
- 'third_party/nanopb/pb_encode.c',
- 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c',
- 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c',
- 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c',
- 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c',
- 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c',
- 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c',
- 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c',
- 'src/core/ext/census/base_resources.c',
- 'src/core/ext/census/context.c',
- 'src/core/ext/census/gen/census.pb.c',
- 'src/core/ext/census/gen/trace_context.pb.c',
- 'src/core/ext/census/grpc_context.c',
- 'src/core/ext/census/grpc_filter.c',
- 'src/core/ext/census/grpc_plugin.c',
- 'src/core/ext/census/initialize.c',
- 'src/core/ext/census/intrusive_hash_map.c',
- 'src/core/ext/census/mlog.c',
- 'src/core/ext/census/operation.c',
- 'src/core/ext/census/placeholders.c',
- 'src/core/ext/census/resource.c',
- 'src/core/ext/census/trace_context.c',
- 'src/core/ext/census/tracing.c',
- 'src/core/ext/filters/max_age/max_age_filter.c',
- 'src/core/ext/filters/message_size/message_size_filter.c',
- 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c',
- 'src/core/ext/filters/workarounds/workaround_utils.c',
- 'src/core/plugin_registry/grpc_plugin_registry.c',
- 'src/boringssl/err_data.c',
- 'third_party/boringssl/crypto/aes/aes.c',
- 'third_party/boringssl/crypto/aes/key_wrap.c',
- 'third_party/boringssl/crypto/aes/mode_wrappers.c',
- 'third_party/boringssl/crypto/asn1/a_bitstr.c',
- 'third_party/boringssl/crypto/asn1/a_bool.c',
- 'third_party/boringssl/crypto/asn1/a_d2i_fp.c',
- 'third_party/boringssl/crypto/asn1/a_dup.c',
- 'third_party/boringssl/crypto/asn1/a_enum.c',
- 'third_party/boringssl/crypto/asn1/a_gentm.c',
- 'third_party/boringssl/crypto/asn1/a_i2d_fp.c',
- 'third_party/boringssl/crypto/asn1/a_int.c',
- 'third_party/boringssl/crypto/asn1/a_mbstr.c',
- 'third_party/boringssl/crypto/asn1/a_object.c',
- 'third_party/boringssl/crypto/asn1/a_octet.c',
- 'third_party/boringssl/crypto/asn1/a_print.c',
- 'third_party/boringssl/crypto/asn1/a_strnid.c',
- 'third_party/boringssl/crypto/asn1/a_time.c',
- 'third_party/boringssl/crypto/asn1/a_type.c',
- 'third_party/boringssl/crypto/asn1/a_utctm.c',
- 'third_party/boringssl/crypto/asn1/a_utf8.c',
- 'third_party/boringssl/crypto/asn1/asn1_lib.c',
- 'third_party/boringssl/crypto/asn1/asn1_par.c',
- 'third_party/boringssl/crypto/asn1/asn_pack.c',
- 'third_party/boringssl/crypto/asn1/f_enum.c',
- 'third_party/boringssl/crypto/asn1/f_int.c',
- 'third_party/boringssl/crypto/asn1/f_string.c',
- 'third_party/boringssl/crypto/asn1/t_bitst.c',
- 'third_party/boringssl/crypto/asn1/tasn_dec.c',
- 'third_party/boringssl/crypto/asn1/tasn_enc.c',
- 'third_party/boringssl/crypto/asn1/tasn_fre.c',
- 'third_party/boringssl/crypto/asn1/tasn_new.c',
- 'third_party/boringssl/crypto/asn1/tasn_typ.c',
- 'third_party/boringssl/crypto/asn1/tasn_utl.c',
- 'third_party/boringssl/crypto/asn1/time_support.c',
- 'third_party/boringssl/crypto/asn1/x_bignum.c',
- 'third_party/boringssl/crypto/asn1/x_long.c',
- 'third_party/boringssl/crypto/base64/base64.c',
- 'third_party/boringssl/crypto/bio/bio.c',
- 'third_party/boringssl/crypto/bio/bio_mem.c',
- 'third_party/boringssl/crypto/bio/connect.c',
- 'third_party/boringssl/crypto/bio/fd.c',
- 'third_party/boringssl/crypto/bio/file.c',
- 'third_party/boringssl/crypto/bio/hexdump.c',
- 'third_party/boringssl/crypto/bio/pair.c',
- 'third_party/boringssl/crypto/bio/printf.c',
- 'third_party/boringssl/crypto/bio/socket.c',
- 'third_party/boringssl/crypto/bio/socket_helper.c',
- 'third_party/boringssl/crypto/bn/add.c',
- 'third_party/boringssl/crypto/bn/asm/x86_64-gcc.c',
- 'third_party/boringssl/crypto/bn/bn.c',
- 'third_party/boringssl/crypto/bn/bn_asn1.c',
- 'third_party/boringssl/crypto/bn/cmp.c',
- 'third_party/boringssl/crypto/bn/convert.c',
- 'third_party/boringssl/crypto/bn/ctx.c',
- 'third_party/boringssl/crypto/bn/div.c',
- 'third_party/boringssl/crypto/bn/exponentiation.c',
- 'third_party/boringssl/crypto/bn/gcd.c',
- 'third_party/boringssl/crypto/bn/generic.c',
- 'third_party/boringssl/crypto/bn/kronecker.c',
- 'third_party/boringssl/crypto/bn/montgomery.c',
- 'third_party/boringssl/crypto/bn/montgomery_inv.c',
- 'third_party/boringssl/crypto/bn/mul.c',
- 'third_party/boringssl/crypto/bn/prime.c',
- 'third_party/boringssl/crypto/bn/random.c',
- 'third_party/boringssl/crypto/bn/rsaz_exp.c',
- 'third_party/boringssl/crypto/bn/shift.c',
- 'third_party/boringssl/crypto/bn/sqrt.c',
- 'third_party/boringssl/crypto/buf/buf.c',
- 'third_party/boringssl/crypto/bytestring/asn1_compat.c',
- 'third_party/boringssl/crypto/bytestring/ber.c',
- 'third_party/boringssl/crypto/bytestring/cbb.c',
- 'third_party/boringssl/crypto/bytestring/cbs.c',
- 'third_party/boringssl/crypto/chacha/chacha.c',
- 'third_party/boringssl/crypto/cipher/aead.c',
- 'third_party/boringssl/crypto/cipher/cipher.c',
- 'third_party/boringssl/crypto/cipher/derive_key.c',
- 'third_party/boringssl/crypto/cipher/e_aes.c',
- 'third_party/boringssl/crypto/cipher/e_chacha20poly1305.c',
- 'third_party/boringssl/crypto/cipher/e_des.c',
- 'third_party/boringssl/crypto/cipher/e_null.c',
- 'third_party/boringssl/crypto/cipher/e_rc2.c',
- 'third_party/boringssl/crypto/cipher/e_rc4.c',
- 'third_party/boringssl/crypto/cipher/e_ssl3.c',
- 'third_party/boringssl/crypto/cipher/e_tls.c',
- 'third_party/boringssl/crypto/cipher/tls_cbc.c',
- 'third_party/boringssl/crypto/cmac/cmac.c',
- 'third_party/boringssl/crypto/conf/conf.c',
- 'third_party/boringssl/crypto/cpu-aarch64-linux.c',
- 'third_party/boringssl/crypto/cpu-arm-linux.c',
- 'third_party/boringssl/crypto/cpu-arm.c',
- 'third_party/boringssl/crypto/cpu-intel.c',
- 'third_party/boringssl/crypto/cpu-ppc64le.c',
- 'third_party/boringssl/crypto/crypto.c',
- 'third_party/boringssl/crypto/curve25519/curve25519.c',
- 'third_party/boringssl/crypto/curve25519/spake25519.c',
- 'third_party/boringssl/crypto/curve25519/x25519-x86_64.c',
- 'third_party/boringssl/crypto/des/des.c',
- 'third_party/boringssl/crypto/dh/check.c',
- 'third_party/boringssl/crypto/dh/dh.c',
- 'third_party/boringssl/crypto/dh/dh_asn1.c',
- 'third_party/boringssl/crypto/dh/params.c',
- 'third_party/boringssl/crypto/digest/digest.c',
- 'third_party/boringssl/crypto/digest/digests.c',
- 'third_party/boringssl/crypto/dsa/dsa.c',
- 'third_party/boringssl/crypto/dsa/dsa_asn1.c',
- 'third_party/boringssl/crypto/ec/ec.c',
- 'third_party/boringssl/crypto/ec/ec_asn1.c',
- 'third_party/boringssl/crypto/ec/ec_key.c',
- 'third_party/boringssl/crypto/ec/ec_montgomery.c',
- 'third_party/boringssl/crypto/ec/oct.c',
- 'third_party/boringssl/crypto/ec/p224-64.c',
- 'third_party/boringssl/crypto/ec/p256-64.c',
- 'third_party/boringssl/crypto/ec/p256-x86_64.c',
- 'third_party/boringssl/crypto/ec/simple.c',
- 'third_party/boringssl/crypto/ec/util-64.c',
- 'third_party/boringssl/crypto/ec/wnaf.c',
- 'third_party/boringssl/crypto/ecdh/ecdh.c',
- 'third_party/boringssl/crypto/ecdsa/ecdsa.c',
- 'third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c',
- 'third_party/boringssl/crypto/engine/engine.c',
- 'third_party/boringssl/crypto/err/err.c',
- 'third_party/boringssl/crypto/evp/digestsign.c',
- 'third_party/boringssl/crypto/evp/evp.c',
- 'third_party/boringssl/crypto/evp/evp_asn1.c',
- 'third_party/boringssl/crypto/evp/evp_ctx.c',
- 'third_party/boringssl/crypto/evp/p_dsa_asn1.c',
- 'third_party/boringssl/crypto/evp/p_ec.c',
- 'third_party/boringssl/crypto/evp/p_ec_asn1.c',
- 'third_party/boringssl/crypto/evp/p_rsa.c',
- 'third_party/boringssl/crypto/evp/p_rsa_asn1.c',
- 'third_party/boringssl/crypto/evp/pbkdf.c',
- 'third_party/boringssl/crypto/evp/print.c',
- 'third_party/boringssl/crypto/evp/sign.c',
- 'third_party/boringssl/crypto/ex_data.c',
- 'third_party/boringssl/crypto/hkdf/hkdf.c',
- 'third_party/boringssl/crypto/hmac/hmac.c',
- 'third_party/boringssl/crypto/lhash/lhash.c',
- 'third_party/boringssl/crypto/md4/md4.c',
- 'third_party/boringssl/crypto/md5/md5.c',
- 'third_party/boringssl/crypto/mem.c',
- 'third_party/boringssl/crypto/modes/cbc.c',
- 'third_party/boringssl/crypto/modes/cfb.c',
- 'third_party/boringssl/crypto/modes/ctr.c',
- 'third_party/boringssl/crypto/modes/gcm.c',
- 'third_party/boringssl/crypto/modes/ofb.c',
- 'third_party/boringssl/crypto/modes/polyval.c',
- 'third_party/boringssl/crypto/obj/obj.c',
- 'third_party/boringssl/crypto/obj/obj_xref.c',
- 'third_party/boringssl/crypto/pem/pem_all.c',
- 'third_party/boringssl/crypto/pem/pem_info.c',
- 'third_party/boringssl/crypto/pem/pem_lib.c',
- 'third_party/boringssl/crypto/pem/pem_oth.c',
- 'third_party/boringssl/crypto/pem/pem_pk8.c',
- 'third_party/boringssl/crypto/pem/pem_pkey.c',
- 'third_party/boringssl/crypto/pem/pem_x509.c',
- 'third_party/boringssl/crypto/pem/pem_xaux.c',
- 'third_party/boringssl/crypto/pkcs8/p5_pbev2.c',
- 'third_party/boringssl/crypto/pkcs8/p8_pkey.c',
- 'third_party/boringssl/crypto/pkcs8/pkcs8.c',
- 'third_party/boringssl/crypto/poly1305/poly1305.c',
- 'third_party/boringssl/crypto/poly1305/poly1305_arm.c',
- 'third_party/boringssl/crypto/poly1305/poly1305_vec.c',
- 'third_party/boringssl/crypto/pool/pool.c',
- 'third_party/boringssl/crypto/rand/deterministic.c',
- 'third_party/boringssl/crypto/rand/fuchsia.c',
- 'third_party/boringssl/crypto/rand/rand.c',
- 'third_party/boringssl/crypto/rand/urandom.c',
- 'third_party/boringssl/crypto/rand/windows.c',
- 'third_party/boringssl/crypto/rc4/rc4.c',
- 'third_party/boringssl/crypto/refcount_c11.c',
- 'third_party/boringssl/crypto/refcount_lock.c',
- 'third_party/boringssl/crypto/rsa/blinding.c',
- 'third_party/boringssl/crypto/rsa/padding.c',
- 'third_party/boringssl/crypto/rsa/rsa.c',
- 'third_party/boringssl/crypto/rsa/rsa_asn1.c',
- 'third_party/boringssl/crypto/rsa/rsa_impl.c',
- 'third_party/boringssl/crypto/sha/sha1-altivec.c',
- 'third_party/boringssl/crypto/sha/sha1.c',
- 'third_party/boringssl/crypto/sha/sha256.c',
- 'third_party/boringssl/crypto/sha/sha512.c',
- 'third_party/boringssl/crypto/stack/stack.c',
- 'third_party/boringssl/crypto/thread.c',
- 'third_party/boringssl/crypto/thread_none.c',
- 'third_party/boringssl/crypto/thread_pthread.c',
- 'third_party/boringssl/crypto/thread_win.c',
- 'third_party/boringssl/crypto/x509/a_digest.c',
- 'third_party/boringssl/crypto/x509/a_sign.c',
- 'third_party/boringssl/crypto/x509/a_strex.c',
- 'third_party/boringssl/crypto/x509/a_verify.c',
- 'third_party/boringssl/crypto/x509/algorithm.c',
- 'third_party/boringssl/crypto/x509/asn1_gen.c',
- 'third_party/boringssl/crypto/x509/by_dir.c',
- 'third_party/boringssl/crypto/x509/by_file.c',
- 'third_party/boringssl/crypto/x509/i2d_pr.c',
- 'third_party/boringssl/crypto/x509/pkcs7.c',
- 'third_party/boringssl/crypto/x509/rsa_pss.c',
- 'third_party/boringssl/crypto/x509/t_crl.c',
- 'third_party/boringssl/crypto/x509/t_req.c',
- 'third_party/boringssl/crypto/x509/t_x509.c',
- 'third_party/boringssl/crypto/x509/t_x509a.c',
- 'third_party/boringssl/crypto/x509/x509.c',
- 'third_party/boringssl/crypto/x509/x509_att.c',
- 'third_party/boringssl/crypto/x509/x509_cmp.c',
- 'third_party/boringssl/crypto/x509/x509_d2.c',
- 'third_party/boringssl/crypto/x509/x509_def.c',
- 'third_party/boringssl/crypto/x509/x509_ext.c',
- 'third_party/boringssl/crypto/x509/x509_lu.c',
- 'third_party/boringssl/crypto/x509/x509_obj.c',
- 'third_party/boringssl/crypto/x509/x509_r2x.c',
- 'third_party/boringssl/crypto/x509/x509_req.c',
- 'third_party/boringssl/crypto/x509/x509_set.c',
- 'third_party/boringssl/crypto/x509/x509_trs.c',
- 'third_party/boringssl/crypto/x509/x509_txt.c',
- 'third_party/boringssl/crypto/x509/x509_v3.c',
- 'third_party/boringssl/crypto/x509/x509_vfy.c',
- 'third_party/boringssl/crypto/x509/x509_vpm.c',
- 'third_party/boringssl/crypto/x509/x509cset.c',
- 'third_party/boringssl/crypto/x509/x509name.c',
- 'third_party/boringssl/crypto/x509/x509rset.c',
- 'third_party/boringssl/crypto/x509/x509spki.c',
- 'third_party/boringssl/crypto/x509/x509type.c',
- 'third_party/boringssl/crypto/x509/x_algor.c',
- 'third_party/boringssl/crypto/x509/x_all.c',
- 'third_party/boringssl/crypto/x509/x_attrib.c',
- 'third_party/boringssl/crypto/x509/x_crl.c',
- 'third_party/boringssl/crypto/x509/x_exten.c',
- 'third_party/boringssl/crypto/x509/x_info.c',
- 'third_party/boringssl/crypto/x509/x_name.c',
- 'third_party/boringssl/crypto/x509/x_pkey.c',
- 'third_party/boringssl/crypto/x509/x_pubkey.c',
- 'third_party/boringssl/crypto/x509/x_req.c',
- 'third_party/boringssl/crypto/x509/x_sig.c',
- 'third_party/boringssl/crypto/x509/x_spki.c',
- 'third_party/boringssl/crypto/x509/x_val.c',
- 'third_party/boringssl/crypto/x509/x_x509.c',
- 'third_party/boringssl/crypto/x509/x_x509a.c',
- 'third_party/boringssl/crypto/x509v3/pcy_cache.c',
- 'third_party/boringssl/crypto/x509v3/pcy_data.c',
- 'third_party/boringssl/crypto/x509v3/pcy_lib.c',
- 'third_party/boringssl/crypto/x509v3/pcy_map.c',
- 'third_party/boringssl/crypto/x509v3/pcy_node.c',
- 'third_party/boringssl/crypto/x509v3/pcy_tree.c',
- 'third_party/boringssl/crypto/x509v3/v3_akey.c',
- 'third_party/boringssl/crypto/x509v3/v3_akeya.c',
- 'third_party/boringssl/crypto/x509v3/v3_alt.c',
- 'third_party/boringssl/crypto/x509v3/v3_bcons.c',
- 'third_party/boringssl/crypto/x509v3/v3_bitst.c',
- 'third_party/boringssl/crypto/x509v3/v3_conf.c',
- 'third_party/boringssl/crypto/x509v3/v3_cpols.c',
- 'third_party/boringssl/crypto/x509v3/v3_crld.c',
- 'third_party/boringssl/crypto/x509v3/v3_enum.c',
- 'third_party/boringssl/crypto/x509v3/v3_extku.c',
- 'third_party/boringssl/crypto/x509v3/v3_genn.c',
- 'third_party/boringssl/crypto/x509v3/v3_ia5.c',
- 'third_party/boringssl/crypto/x509v3/v3_info.c',
- 'third_party/boringssl/crypto/x509v3/v3_int.c',
- 'third_party/boringssl/crypto/x509v3/v3_lib.c',
- 'third_party/boringssl/crypto/x509v3/v3_ncons.c',
- 'third_party/boringssl/crypto/x509v3/v3_pci.c',
- 'third_party/boringssl/crypto/x509v3/v3_pcia.c',
- 'third_party/boringssl/crypto/x509v3/v3_pcons.c',
- 'third_party/boringssl/crypto/x509v3/v3_pku.c',
- 'third_party/boringssl/crypto/x509v3/v3_pmaps.c',
- 'third_party/boringssl/crypto/x509v3/v3_prn.c',
- 'third_party/boringssl/crypto/x509v3/v3_purp.c',
- 'third_party/boringssl/crypto/x509v3/v3_skey.c',
- 'third_party/boringssl/crypto/x509v3/v3_sxnet.c',
- 'third_party/boringssl/crypto/x509v3/v3_utl.c',
- 'third_party/boringssl/ssl/bio_ssl.c',
- 'third_party/boringssl/ssl/custom_extensions.c',
- 'third_party/boringssl/ssl/d1_both.c',
- 'third_party/boringssl/ssl/d1_lib.c',
- 'third_party/boringssl/ssl/d1_pkt.c',
- 'third_party/boringssl/ssl/d1_srtp.c',
- 'third_party/boringssl/ssl/dtls_method.c',
- 'third_party/boringssl/ssl/dtls_record.c',
- 'third_party/boringssl/ssl/handshake_client.c',
- 'third_party/boringssl/ssl/handshake_server.c',
- 'third_party/boringssl/ssl/s3_both.c',
- 'third_party/boringssl/ssl/s3_lib.c',
- 'third_party/boringssl/ssl/s3_pkt.c',
- 'third_party/boringssl/ssl/ssl_aead_ctx.c',
- 'third_party/boringssl/ssl/ssl_asn1.c',
- 'third_party/boringssl/ssl/ssl_buffer.c',
- 'third_party/boringssl/ssl/ssl_cert.c',
- 'third_party/boringssl/ssl/ssl_cipher.c',
- 'third_party/boringssl/ssl/ssl_ecdh.c',
- 'third_party/boringssl/ssl/ssl_file.c',
- 'third_party/boringssl/ssl/ssl_lib.c',
- 'third_party/boringssl/ssl/ssl_privkey.c',
- 'third_party/boringssl/ssl/ssl_privkey_cc.cc',
- 'third_party/boringssl/ssl/ssl_session.c',
- 'third_party/boringssl/ssl/ssl_stat.c',
- 'third_party/boringssl/ssl/ssl_transcript.c',
- 'third_party/boringssl/ssl/ssl_x509.c',
- 'third_party/boringssl/ssl/t1_enc.c',
- 'third_party/boringssl/ssl/t1_lib.c',
- 'third_party/boringssl/ssl/tls13_both.c',
- 'third_party/boringssl/ssl/tls13_client.c',
- 'third_party/boringssl/ssl/tls13_enc.c',
- 'third_party/boringssl/ssl/tls13_server.c',
- 'third_party/boringssl/ssl/tls_method.c',
- 'third_party/boringssl/ssl/tls_record.c',
- 'third_party/zlib/adler32.c',
- 'third_party/zlib/compress.c',
- 'third_party/zlib/crc32.c',
- 'third_party/zlib/deflate.c',
- 'third_party/zlib/gzclose.c',
- 'third_party/zlib/gzlib.c',
- 'third_party/zlib/gzread.c',
- 'third_party/zlib/gzwrite.c',
- 'third_party/zlib/infback.c',
- 'third_party/zlib/inffast.c',
- 'third_party/zlib/inflate.c',
- 'third_party/zlib/inftrees.c',
- 'third_party/zlib/trees.c',
- 'third_party/zlib/uncompr.c',
- 'third_party/zlib/zutil.c',
- 'third_party/cares/cares/ares__close_sockets.c',
- 'third_party/cares/cares/ares__get_hostent.c',
- 'third_party/cares/cares/ares__read_line.c',
- 'third_party/cares/cares/ares__timeval.c',
- 'third_party/cares/cares/ares_cancel.c',
- 'third_party/cares/cares/ares_create_query.c',
- 'third_party/cares/cares/ares_data.c',
- 'third_party/cares/cares/ares_destroy.c',
- 'third_party/cares/cares/ares_expand_name.c',
- 'third_party/cares/cares/ares_expand_string.c',
- 'third_party/cares/cares/ares_fds.c',
- 'third_party/cares/cares/ares_free_hostent.c',
- 'third_party/cares/cares/ares_free_string.c',
- 'third_party/cares/cares/ares_getenv.c',
- 'third_party/cares/cares/ares_gethostbyaddr.c',
- 'third_party/cares/cares/ares_gethostbyname.c',
- 'third_party/cares/cares/ares_getnameinfo.c',
- 'third_party/cares/cares/ares_getopt.c',
- 'third_party/cares/cares/ares_getsock.c',
- 'third_party/cares/cares/ares_init.c',
- 'third_party/cares/cares/ares_library_init.c',
- 'third_party/cares/cares/ares_llist.c',
- 'third_party/cares/cares/ares_mkquery.c',
- 'third_party/cares/cares/ares_nowarn.c',
- 'third_party/cares/cares/ares_options.c',
- 'third_party/cares/cares/ares_parse_a_reply.c',
- 'third_party/cares/cares/ares_parse_aaaa_reply.c',
- 'third_party/cares/cares/ares_parse_mx_reply.c',
- 'third_party/cares/cares/ares_parse_naptr_reply.c',
- 'third_party/cares/cares/ares_parse_ns_reply.c',
- 'third_party/cares/cares/ares_parse_ptr_reply.c',
- 'third_party/cares/cares/ares_parse_soa_reply.c',
- 'third_party/cares/cares/ares_parse_srv_reply.c',
- 'third_party/cares/cares/ares_parse_txt_reply.c',
- 'third_party/cares/cares/ares_platform.c',
- 'third_party/cares/cares/ares_process.c',
- 'third_party/cares/cares/ares_query.c',
- 'third_party/cares/cares/ares_search.c',
- 'third_party/cares/cares/ares_send.c',
- 'third_party/cares/cares/ares_strcasecmp.c',
- 'third_party/cares/cares/ares_strdup.c',
- 'third_party/cares/cares/ares_strerror.c',
- 'third_party/cares/cares/ares_timeout.c',
- 'third_party/cares/cares/ares_version.c',
- 'third_party/cares/cares/ares_writev.c',
- 'third_party/cares/cares/bitncmp.c',
- 'third_party/cares/cares/inet_net_pton.c',
- 'third_party/cares/cares/inet_ntop.c',
- 'third_party/cares/cares/windows_port.c',
+ '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',
+ 'src/core/lib/gpr/cpu_posix.cc',
+ 'src/core/lib/gpr/cpu_windows.cc',
+ 'src/core/lib/gpr/env_linux.cc',
+ 'src/core/lib/gpr/env_posix.cc',
+ 'src/core/lib/gpr/env_windows.cc',
+ 'src/core/lib/gpr/fork.cc',
+ 'src/core/lib/gpr/host_port.cc',
+ 'src/core/lib/gpr/log.cc',
+ 'src/core/lib/gpr/log_android.cc',
+ 'src/core/lib/gpr/log_linux.cc',
+ 'src/core/lib/gpr/log_posix.cc',
+ 'src/core/lib/gpr/log_windows.cc',
+ 'src/core/lib/gpr/mpscq.cc',
+ 'src/core/lib/gpr/murmur_hash.cc',
+ 'src/core/lib/gpr/string.cc',
+ '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',
+ 'src/core/lib/gpr/thd.cc',
+ 'src/core/lib/gpr/thd_posix.cc',
+ 'src/core/lib/gpr/thd_windows.cc',
+ 'src/core/lib/gpr/time.cc',
+ 'src/core/lib/gpr/time_posix.cc',
+ 'src/core/lib/gpr/time_precise.cc',
+ 'src/core/lib/gpr/time_windows.cc',
+ 'src/core/lib/gpr/tls_pthread.cc',
+ '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/wrap_memcpy.cc',
+ 'src/core/lib/profiling/basic_timers.cc',
+ 'src/core/lib/profiling/stap_timers.cc',
+ 'src/core/lib/surface/init.cc',
+ 'src/core/lib/backoff/backoff.cc',
+ 'src/core/lib/channel/channel_args.cc',
+ 'src/core/lib/channel/channel_stack.cc',
+ 'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/connected_channel.cc',
+ 'src/core/lib/channel/handshaker.cc',
+ 'src/core/lib/channel/handshaker_factory.cc',
+ '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',
+ 'src/core/lib/compression/stream_compression_identity.cc',
+ 'src/core/lib/debug/stats.cc',
+ 'src/core/lib/debug/stats_data.cc',
+ 'src/core/lib/http/format_request.cc',
+ 'src/core/lib/http/httpcli.cc',
+ 'src/core/lib/http/parser.cc',
+ 'src/core/lib/iomgr/call_combiner.cc',
+ 'src/core/lib/iomgr/combiner.cc',
+ 'src/core/lib/iomgr/endpoint.cc',
+ 'src/core/lib/iomgr/endpoint_pair_posix.cc',
+ 'src/core/lib/iomgr/endpoint_pair_uv.cc',
+ 'src/core/lib/iomgr/endpoint_pair_windows.cc',
+ 'src/core/lib/iomgr/error.cc',
+ 'src/core/lib/iomgr/ev_epoll1_linux.cc',
+ 'src/core/lib/iomgr/ev_epollex_linux.cc',
+ 'src/core/lib/iomgr/ev_epollsig_linux.cc',
+ 'src/core/lib/iomgr/ev_poll_posix.cc',
+ 'src/core/lib/iomgr/ev_posix.cc',
+ 'src/core/lib/iomgr/ev_windows.cc',
+ 'src/core/lib/iomgr/exec_ctx.cc',
+ 'src/core/lib/iomgr/executor.cc',
+ 'src/core/lib/iomgr/fork_posix.cc',
+ 'src/core/lib/iomgr/fork_windows.cc',
+ 'src/core/lib/iomgr/gethostname_fallback.cc',
+ 'src/core/lib/iomgr/gethostname_host_name_max.cc',
+ 'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/iocp_windows.cc',
+ 'src/core/lib/iomgr/iomgr.cc',
+ 'src/core/lib/iomgr/iomgr_posix.cc',
+ 'src/core/lib/iomgr/iomgr_uv.cc',
+ 'src/core/lib/iomgr/iomgr_windows.cc',
+ 'src/core/lib/iomgr/is_epollexclusive_available.cc',
+ 'src/core/lib/iomgr/load_file.cc',
+ 'src/core/lib/iomgr/lockfree_event.cc',
+ 'src/core/lib/iomgr/network_status_tracker.cc',
+ 'src/core/lib/iomgr/polling_entity.cc',
+ 'src/core/lib/iomgr/pollset_set_uv.cc',
+ 'src/core/lib/iomgr/pollset_set_windows.cc',
+ 'src/core/lib/iomgr/pollset_uv.cc',
+ 'src/core/lib/iomgr/pollset_windows.cc',
+ 'src/core/lib/iomgr/resolve_address_posix.cc',
+ 'src/core/lib/iomgr/resolve_address_uv.cc',
+ 'src/core/lib/iomgr/resolve_address_windows.cc',
+ 'src/core/lib/iomgr/resource_quota.cc',
+ 'src/core/lib/iomgr/sockaddr_utils.cc',
+ 'src/core/lib/iomgr/socket_factory_posix.cc',
+ 'src/core/lib/iomgr/socket_mutator.cc',
+ 'src/core/lib/iomgr/socket_utils_common_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_linux.cc',
+ 'src/core/lib/iomgr/socket_utils_posix.cc',
+ 'src/core/lib/iomgr/socket_utils_uv.cc',
+ 'src/core/lib/iomgr/socket_utils_windows.cc',
+ 'src/core/lib/iomgr/socket_windows.cc',
+ 'src/core/lib/iomgr/tcp_client_posix.cc',
+ 'src/core/lib/iomgr/tcp_client_uv.cc',
+ 'src/core/lib/iomgr/tcp_client_windows.cc',
+ 'src/core/lib/iomgr/tcp_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_posix.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc',
+ 'src/core/lib/iomgr/tcp_server_uv.cc',
+ 'src/core/lib/iomgr/tcp_server_windows.cc',
+ 'src/core/lib/iomgr/tcp_uv.cc',
+ 'src/core/lib/iomgr/tcp_windows.cc',
+ 'src/core/lib/iomgr/time_averaged_stats.cc',
+ 'src/core/lib/iomgr/timer_generic.cc',
+ 'src/core/lib/iomgr/timer_heap.cc',
+ 'src/core/lib/iomgr/timer_manager.cc',
+ 'src/core/lib/iomgr/timer_uv.cc',
+ 'src/core/lib/iomgr/udp_server.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix.cc',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.cc',
+ 'src/core/lib/iomgr/wakeup_fd_cv.cc',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.cc',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.cc',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.cc',
+ 'src/core/lib/iomgr/wakeup_fd_posix.cc',
+ 'src/core/lib/json/json.cc',
+ 'src/core/lib/json/json_reader.cc',
+ 'src/core/lib/json/json_string.cc',
+ 'src/core/lib/json/json_writer.cc',
+ 'src/core/lib/slice/b64.cc',
+ 'src/core/lib/slice/percent_encoding.cc',
+ 'src/core/lib/slice/slice.cc',
+ 'src/core/lib/slice/slice_buffer.cc',
+ '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',
+ 'src/core/lib/surface/call.cc',
+ 'src/core/lib/surface/call_details.cc',
+ 'src/core/lib/surface/call_log_batch.cc',
+ 'src/core/lib/surface/channel.cc',
+ 'src/core/lib/surface/channel_init.cc',
+ 'src/core/lib/surface/channel_ping.cc',
+ 'src/core/lib/surface/channel_stack_type.cc',
+ 'src/core/lib/surface/completion_queue.cc',
+ 'src/core/lib/surface/completion_queue_factory.cc',
+ 'src/core/lib/surface/event_string.cc',
+ 'src/core/lib/surface/lame_client.cc',
+ 'src/core/lib/surface/metadata_array.cc',
+ 'src/core/lib/surface/server.cc',
+ 'src/core/lib/surface/validate_metadata.cc',
+ 'src/core/lib/surface/version.cc',
+ 'src/core/lib/transport/bdp_estimator.cc',
+ 'src/core/lib/transport/byte_stream.cc',
+ 'src/core/lib/transport/connectivity_state.cc',
+ 'src/core/lib/transport/error_utils.cc',
+ 'src/core/lib/transport/metadata.cc',
+ 'src/core/lib/transport/metadata_batch.cc',
+ 'src/core/lib/transport/pid_controller.cc',
+ 'src/core/lib/transport/service_config.cc',
+ 'src/core/lib/transport/static_metadata.cc',
+ 'src/core/lib/transport/status_conversion.cc',
+ 'src/core/lib/transport/timeout_encoding.cc',
+ 'src/core/lib/transport/transport.cc',
+ 'src/core/lib/transport/transport_op_string.cc',
+ 'src/core/lib/debug/trace.cc',
+ 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_decoder.cc',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc',
+ 'src/core/ext/transport/chttp2/transport/flow_control.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_data.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.cc',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.cc',
+ 'src/core/ext/transport/chttp2/transport/http2_settings.cc',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.cc',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.cc',
+ 'src/core/ext/transport/chttp2/transport/parsing.cc',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.cc',
+ '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/ext/transport/chttp2/alpn/alpn.cc',
+ 'src/core/ext/filters/http/client/http_client_filter.cc',
+ 'src/core/ext/filters/http/http_filters_plugin.cc',
+ 'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
+ 'src/core/ext/filters/http/server/http_server_filter.cc',
+ 'src/core/lib/http/httpcli_security_connector.cc',
+ 'src/core/lib/security/context/security_context.cc',
+ 'src/core/lib/security/credentials/composite/composite_credentials.cc',
+ 'src/core/lib/security/credentials/credentials.cc',
+ 'src/core/lib/security/credentials/credentials_metadata.cc',
+ 'src/core/lib/security/credentials/fake/fake_credentials.cc',
+ 'src/core/lib/security/credentials/google_default/credentials_generic.cc',
+ 'src/core/lib/security/credentials/google_default/google_default_credentials.cc',
+ 'src/core/lib/security/credentials/iam/iam_credentials.cc',
+ 'src/core/lib/security/credentials/jwt/json_token.cc',
+ 'src/core/lib/security/credentials/jwt/jwt_credentials.cc',
+ 'src/core/lib/security/credentials/jwt/jwt_verifier.cc',
+ 'src/core/lib/security/credentials/oauth2/oauth2_credentials.cc',
+ 'src/core/lib/security/credentials/plugin/plugin_credentials.cc',
+ 'src/core/lib/security/credentials/ssl/ssl_credentials.cc',
+ 'src/core/lib/security/transport/client_auth_filter.cc',
+ 'src/core/lib/security/transport/lb_targets_info.cc',
+ 'src/core/lib/security/transport/secure_endpoint.cc',
+ 'src/core/lib/security/transport/security_connector.cc',
+ 'src/core/lib/security/transport/security_handshaker.cc',
+ 'src/core/lib/security/transport/server_auth_filter.cc',
+ 'src/core/lib/security/transport/tsi_error.cc',
+ 'src/core/lib/security/util/json_util.cc',
+ 'src/core/lib/surface/init_secure.cc',
+ 'src/core/tsi/alts_transport_security.cc',
+ 'src/core/tsi/fake_transport_security.cc',
+ 'src/core/tsi/ssl_transport_security.cc',
+ 'src/core/tsi/transport_security_grpc.cc',
+ 'src/core/tsi/transport_security.cc',
+ 'src/core/tsi/transport_security_adapter.cc',
+ 'src/core/ext/transport/chttp2/server/chttp2_server.cc',
+ 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc',
+ 'src/core/ext/filters/client_channel/backup_poller.cc',
+ 'src/core/ext/filters/client_channel/channel_connectivity.cc',
+ 'src/core/ext/filters/client_channel/client_channel.cc',
+ 'src/core/ext/filters/client_channel/client_channel_factory.cc',
+ 'src/core/ext/filters/client_channel/client_channel_plugin.cc',
+ 'src/core/ext/filters/client_channel/connector.cc',
+ 'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
+ 'src/core/ext/filters/client_channel/http_proxy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_factory.cc',
+ 'src/core/ext/filters/client_channel/lb_policy_registry.cc',
+ 'src/core/ext/filters/client_channel/parse_address.cc',
+ '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',
+ 'src/core/ext/filters/client_channel/subchannel_index.cc',
+ 'src/core/ext/filters/client_channel/uri_parser.cc',
+ 'src/core/ext/filters/deadline/deadline_filter.cc',
+ 'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc',
+ 'src/core/ext/transport/inproc/inproc_plugin.cc',
+ 'src/core/ext/transport/inproc/inproc_transport.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
+ 'third_party/nanopb/pb_common.c',
+ 'third_party/nanopb/pb_decode.c',
+ 'third_party/nanopb/pb_encode.c',
+ 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc',
+ 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
+ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
+ 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_filter.cc',
+ 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc',
+ 'src/core/ext/census/grpc_context.cc',
+ 'src/core/ext/filters/max_age/max_age_filter.cc',
+ 'src/core/ext/filters/message_size/message_size_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc',
+ 'src/core/ext/filters/workarounds/workaround_utils.cc',
+ 'src/core/plugin_registry/grpc_plugin_registry.cc',
+ 'src/boringssl/err_data.c',
+ 'third_party/boringssl/crypto/aes/aes.c',
+ 'third_party/boringssl/crypto/aes/key_wrap.c',
+ 'third_party/boringssl/crypto/aes/mode_wrappers.c',
+ 'third_party/boringssl/crypto/asn1/a_bitstr.c',
+ 'third_party/boringssl/crypto/asn1/a_bool.c',
+ 'third_party/boringssl/crypto/asn1/a_d2i_fp.c',
+ 'third_party/boringssl/crypto/asn1/a_dup.c',
+ 'third_party/boringssl/crypto/asn1/a_enum.c',
+ 'third_party/boringssl/crypto/asn1/a_gentm.c',
+ 'third_party/boringssl/crypto/asn1/a_i2d_fp.c',
+ 'third_party/boringssl/crypto/asn1/a_int.c',
+ 'third_party/boringssl/crypto/asn1/a_mbstr.c',
+ 'third_party/boringssl/crypto/asn1/a_object.c',
+ 'third_party/boringssl/crypto/asn1/a_octet.c',
+ 'third_party/boringssl/crypto/asn1/a_print.c',
+ 'third_party/boringssl/crypto/asn1/a_strnid.c',
+ 'third_party/boringssl/crypto/asn1/a_time.c',
+ 'third_party/boringssl/crypto/asn1/a_type.c',
+ 'third_party/boringssl/crypto/asn1/a_utctm.c',
+ 'third_party/boringssl/crypto/asn1/a_utf8.c',
+ 'third_party/boringssl/crypto/asn1/asn1_lib.c',
+ 'third_party/boringssl/crypto/asn1/asn1_par.c',
+ 'third_party/boringssl/crypto/asn1/asn_pack.c',
+ 'third_party/boringssl/crypto/asn1/f_enum.c',
+ 'third_party/boringssl/crypto/asn1/f_int.c',
+ 'third_party/boringssl/crypto/asn1/f_string.c',
+ 'third_party/boringssl/crypto/asn1/t_bitst.c',
+ 'third_party/boringssl/crypto/asn1/tasn_dec.c',
+ 'third_party/boringssl/crypto/asn1/tasn_enc.c',
+ 'third_party/boringssl/crypto/asn1/tasn_fre.c',
+ 'third_party/boringssl/crypto/asn1/tasn_new.c',
+ 'third_party/boringssl/crypto/asn1/tasn_typ.c',
+ 'third_party/boringssl/crypto/asn1/tasn_utl.c',
+ 'third_party/boringssl/crypto/asn1/time_support.c',
+ 'third_party/boringssl/crypto/asn1/x_bignum.c',
+ 'third_party/boringssl/crypto/asn1/x_long.c',
+ 'third_party/boringssl/crypto/base64/base64.c',
+ 'third_party/boringssl/crypto/bio/bio.c',
+ 'third_party/boringssl/crypto/bio/bio_mem.c',
+ 'third_party/boringssl/crypto/bio/connect.c',
+ 'third_party/boringssl/crypto/bio/fd.c',
+ 'third_party/boringssl/crypto/bio/file.c',
+ 'third_party/boringssl/crypto/bio/hexdump.c',
+ 'third_party/boringssl/crypto/bio/pair.c',
+ 'third_party/boringssl/crypto/bio/printf.c',
+ 'third_party/boringssl/crypto/bio/socket.c',
+ 'third_party/boringssl/crypto/bio/socket_helper.c',
+ 'third_party/boringssl/crypto/bn/add.c',
+ 'third_party/boringssl/crypto/bn/asm/x86_64-gcc.c',
+ 'third_party/boringssl/crypto/bn/bn.c',
+ 'third_party/boringssl/crypto/bn/bn_asn1.c',
+ 'third_party/boringssl/crypto/bn/cmp.c',
+ 'third_party/boringssl/crypto/bn/convert.c',
+ 'third_party/boringssl/crypto/bn/ctx.c',
+ 'third_party/boringssl/crypto/bn/div.c',
+ 'third_party/boringssl/crypto/bn/exponentiation.c',
+ 'third_party/boringssl/crypto/bn/gcd.c',
+ 'third_party/boringssl/crypto/bn/generic.c',
+ 'third_party/boringssl/crypto/bn/kronecker.c',
+ 'third_party/boringssl/crypto/bn/montgomery.c',
+ 'third_party/boringssl/crypto/bn/montgomery_inv.c',
+ 'third_party/boringssl/crypto/bn/mul.c',
+ 'third_party/boringssl/crypto/bn/prime.c',
+ 'third_party/boringssl/crypto/bn/random.c',
+ 'third_party/boringssl/crypto/bn/rsaz_exp.c',
+ 'third_party/boringssl/crypto/bn/shift.c',
+ 'third_party/boringssl/crypto/bn/sqrt.c',
+ 'third_party/boringssl/crypto/buf/buf.c',
+ 'third_party/boringssl/crypto/bytestring/asn1_compat.c',
+ 'third_party/boringssl/crypto/bytestring/ber.c',
+ 'third_party/boringssl/crypto/bytestring/cbb.c',
+ 'third_party/boringssl/crypto/bytestring/cbs.c',
+ 'third_party/boringssl/crypto/chacha/chacha.c',
+ 'third_party/boringssl/crypto/cipher/aead.c',
+ 'third_party/boringssl/crypto/cipher/cipher.c',
+ 'third_party/boringssl/crypto/cipher/derive_key.c',
+ 'third_party/boringssl/crypto/cipher/e_aes.c',
+ 'third_party/boringssl/crypto/cipher/e_chacha20poly1305.c',
+ 'third_party/boringssl/crypto/cipher/e_des.c',
+ 'third_party/boringssl/crypto/cipher/e_null.c',
+ 'third_party/boringssl/crypto/cipher/e_rc2.c',
+ 'third_party/boringssl/crypto/cipher/e_rc4.c',
+ 'third_party/boringssl/crypto/cipher/e_ssl3.c',
+ 'third_party/boringssl/crypto/cipher/e_tls.c',
+ 'third_party/boringssl/crypto/cipher/tls_cbc.c',
+ 'third_party/boringssl/crypto/cmac/cmac.c',
+ 'third_party/boringssl/crypto/conf/conf.c',
+ 'third_party/boringssl/crypto/cpu-aarch64-linux.c',
+ 'third_party/boringssl/crypto/cpu-arm-linux.c',
+ 'third_party/boringssl/crypto/cpu-arm.c',
+ 'third_party/boringssl/crypto/cpu-intel.c',
+ 'third_party/boringssl/crypto/cpu-ppc64le.c',
+ 'third_party/boringssl/crypto/crypto.c',
+ 'third_party/boringssl/crypto/curve25519/curve25519.c',
+ 'third_party/boringssl/crypto/curve25519/spake25519.c',
+ 'third_party/boringssl/crypto/curve25519/x25519-x86_64.c',
+ 'third_party/boringssl/crypto/des/des.c',
+ 'third_party/boringssl/crypto/dh/check.c',
+ 'third_party/boringssl/crypto/dh/dh.c',
+ 'third_party/boringssl/crypto/dh/dh_asn1.c',
+ 'third_party/boringssl/crypto/dh/params.c',
+ 'third_party/boringssl/crypto/digest/digest.c',
+ 'third_party/boringssl/crypto/digest/digests.c',
+ 'third_party/boringssl/crypto/dsa/dsa.c',
+ 'third_party/boringssl/crypto/dsa/dsa_asn1.c',
+ 'third_party/boringssl/crypto/ec/ec.c',
+ 'third_party/boringssl/crypto/ec/ec_asn1.c',
+ 'third_party/boringssl/crypto/ec/ec_key.c',
+ 'third_party/boringssl/crypto/ec/ec_montgomery.c',
+ 'third_party/boringssl/crypto/ec/oct.c',
+ 'third_party/boringssl/crypto/ec/p224-64.c',
+ 'third_party/boringssl/crypto/ec/p256-64.c',
+ 'third_party/boringssl/crypto/ec/p256-x86_64.c',
+ 'third_party/boringssl/crypto/ec/simple.c',
+ 'third_party/boringssl/crypto/ec/util-64.c',
+ 'third_party/boringssl/crypto/ec/wnaf.c',
+ 'third_party/boringssl/crypto/ecdh/ecdh.c',
+ 'third_party/boringssl/crypto/ecdsa/ecdsa.c',
+ 'third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c',
+ 'third_party/boringssl/crypto/engine/engine.c',
+ 'third_party/boringssl/crypto/err/err.c',
+ 'third_party/boringssl/crypto/evp/digestsign.c',
+ 'third_party/boringssl/crypto/evp/evp.c',
+ 'third_party/boringssl/crypto/evp/evp_asn1.c',
+ 'third_party/boringssl/crypto/evp/evp_ctx.c',
+ 'third_party/boringssl/crypto/evp/p_dsa_asn1.c',
+ 'third_party/boringssl/crypto/evp/p_ec.c',
+ 'third_party/boringssl/crypto/evp/p_ec_asn1.c',
+ 'third_party/boringssl/crypto/evp/p_rsa.c',
+ 'third_party/boringssl/crypto/evp/p_rsa_asn1.c',
+ 'third_party/boringssl/crypto/evp/pbkdf.c',
+ 'third_party/boringssl/crypto/evp/print.c',
+ 'third_party/boringssl/crypto/evp/sign.c',
+ 'third_party/boringssl/crypto/ex_data.c',
+ 'third_party/boringssl/crypto/hkdf/hkdf.c',
+ 'third_party/boringssl/crypto/hmac/hmac.c',
+ 'third_party/boringssl/crypto/lhash/lhash.c',
+ 'third_party/boringssl/crypto/md4/md4.c',
+ 'third_party/boringssl/crypto/md5/md5.c',
+ 'third_party/boringssl/crypto/mem.c',
+ 'third_party/boringssl/crypto/modes/cbc.c',
+ 'third_party/boringssl/crypto/modes/cfb.c',
+ 'third_party/boringssl/crypto/modes/ctr.c',
+ 'third_party/boringssl/crypto/modes/gcm.c',
+ 'third_party/boringssl/crypto/modes/ofb.c',
+ 'third_party/boringssl/crypto/modes/polyval.c',
+ 'third_party/boringssl/crypto/obj/obj.c',
+ 'third_party/boringssl/crypto/obj/obj_xref.c',
+ 'third_party/boringssl/crypto/pem/pem_all.c',
+ 'third_party/boringssl/crypto/pem/pem_info.c',
+ 'third_party/boringssl/crypto/pem/pem_lib.c',
+ 'third_party/boringssl/crypto/pem/pem_oth.c',
+ 'third_party/boringssl/crypto/pem/pem_pk8.c',
+ 'third_party/boringssl/crypto/pem/pem_pkey.c',
+ 'third_party/boringssl/crypto/pem/pem_x509.c',
+ 'third_party/boringssl/crypto/pem/pem_xaux.c',
+ 'third_party/boringssl/crypto/pkcs8/p5_pbev2.c',
+ 'third_party/boringssl/crypto/pkcs8/p8_pkey.c',
+ 'third_party/boringssl/crypto/pkcs8/pkcs8.c',
+ 'third_party/boringssl/crypto/poly1305/poly1305.c',
+ 'third_party/boringssl/crypto/poly1305/poly1305_arm.c',
+ 'third_party/boringssl/crypto/poly1305/poly1305_vec.c',
+ 'third_party/boringssl/crypto/pool/pool.c',
+ 'third_party/boringssl/crypto/rand/deterministic.c',
+ 'third_party/boringssl/crypto/rand/fuchsia.c',
+ 'third_party/boringssl/crypto/rand/rand.c',
+ 'third_party/boringssl/crypto/rand/urandom.c',
+ 'third_party/boringssl/crypto/rand/windows.c',
+ 'third_party/boringssl/crypto/rc4/rc4.c',
+ 'third_party/boringssl/crypto/refcount_c11.c',
+ 'third_party/boringssl/crypto/refcount_lock.c',
+ 'third_party/boringssl/crypto/rsa/blinding.c',
+ 'third_party/boringssl/crypto/rsa/padding.c',
+ 'third_party/boringssl/crypto/rsa/rsa.c',
+ 'third_party/boringssl/crypto/rsa/rsa_asn1.c',
+ 'third_party/boringssl/crypto/rsa/rsa_impl.c',
+ 'third_party/boringssl/crypto/sha/sha1-altivec.c',
+ 'third_party/boringssl/crypto/sha/sha1.c',
+ 'third_party/boringssl/crypto/sha/sha256.c',
+ 'third_party/boringssl/crypto/sha/sha512.c',
+ 'third_party/boringssl/crypto/stack/stack.c',
+ 'third_party/boringssl/crypto/thread.c',
+ 'third_party/boringssl/crypto/thread_none.c',
+ 'third_party/boringssl/crypto/thread_pthread.c',
+ 'third_party/boringssl/crypto/thread_win.c',
+ 'third_party/boringssl/crypto/x509/a_digest.c',
+ 'third_party/boringssl/crypto/x509/a_sign.c',
+ 'third_party/boringssl/crypto/x509/a_strex.c',
+ 'third_party/boringssl/crypto/x509/a_verify.c',
+ 'third_party/boringssl/crypto/x509/algorithm.c',
+ 'third_party/boringssl/crypto/x509/asn1_gen.c',
+ 'third_party/boringssl/crypto/x509/by_dir.c',
+ 'third_party/boringssl/crypto/x509/by_file.c',
+ 'third_party/boringssl/crypto/x509/i2d_pr.c',
+ 'third_party/boringssl/crypto/x509/pkcs7.c',
+ 'third_party/boringssl/crypto/x509/rsa_pss.c',
+ 'third_party/boringssl/crypto/x509/t_crl.c',
+ 'third_party/boringssl/crypto/x509/t_req.c',
+ 'third_party/boringssl/crypto/x509/t_x509.c',
+ 'third_party/boringssl/crypto/x509/t_x509a.c',
+ 'third_party/boringssl/crypto/x509/x509.c',
+ 'third_party/boringssl/crypto/x509/x509_att.c',
+ 'third_party/boringssl/crypto/x509/x509_cmp.c',
+ 'third_party/boringssl/crypto/x509/x509_d2.c',
+ 'third_party/boringssl/crypto/x509/x509_def.c',
+ 'third_party/boringssl/crypto/x509/x509_ext.c',
+ 'third_party/boringssl/crypto/x509/x509_lu.c',
+ 'third_party/boringssl/crypto/x509/x509_obj.c',
+ 'third_party/boringssl/crypto/x509/x509_r2x.c',
+ 'third_party/boringssl/crypto/x509/x509_req.c',
+ 'third_party/boringssl/crypto/x509/x509_set.c',
+ 'third_party/boringssl/crypto/x509/x509_trs.c',
+ 'third_party/boringssl/crypto/x509/x509_txt.c',
+ 'third_party/boringssl/crypto/x509/x509_v3.c',
+ 'third_party/boringssl/crypto/x509/x509_vfy.c',
+ 'third_party/boringssl/crypto/x509/x509_vpm.c',
+ 'third_party/boringssl/crypto/x509/x509cset.c',
+ 'third_party/boringssl/crypto/x509/x509name.c',
+ 'third_party/boringssl/crypto/x509/x509rset.c',
+ 'third_party/boringssl/crypto/x509/x509spki.c',
+ 'third_party/boringssl/crypto/x509/x509type.c',
+ 'third_party/boringssl/crypto/x509/x_algor.c',
+ 'third_party/boringssl/crypto/x509/x_all.c',
+ 'third_party/boringssl/crypto/x509/x_attrib.c',
+ 'third_party/boringssl/crypto/x509/x_crl.c',
+ 'third_party/boringssl/crypto/x509/x_exten.c',
+ 'third_party/boringssl/crypto/x509/x_info.c',
+ 'third_party/boringssl/crypto/x509/x_name.c',
+ 'third_party/boringssl/crypto/x509/x_pkey.c',
+ 'third_party/boringssl/crypto/x509/x_pubkey.c',
+ 'third_party/boringssl/crypto/x509/x_req.c',
+ 'third_party/boringssl/crypto/x509/x_sig.c',
+ 'third_party/boringssl/crypto/x509/x_spki.c',
+ 'third_party/boringssl/crypto/x509/x_val.c',
+ 'third_party/boringssl/crypto/x509/x_x509.c',
+ 'third_party/boringssl/crypto/x509/x_x509a.c',
+ 'third_party/boringssl/crypto/x509v3/pcy_cache.c',
+ 'third_party/boringssl/crypto/x509v3/pcy_data.c',
+ 'third_party/boringssl/crypto/x509v3/pcy_lib.c',
+ 'third_party/boringssl/crypto/x509v3/pcy_map.c',
+ 'third_party/boringssl/crypto/x509v3/pcy_node.c',
+ 'third_party/boringssl/crypto/x509v3/pcy_tree.c',
+ 'third_party/boringssl/crypto/x509v3/v3_akey.c',
+ 'third_party/boringssl/crypto/x509v3/v3_akeya.c',
+ 'third_party/boringssl/crypto/x509v3/v3_alt.c',
+ 'third_party/boringssl/crypto/x509v3/v3_bcons.c',
+ 'third_party/boringssl/crypto/x509v3/v3_bitst.c',
+ 'third_party/boringssl/crypto/x509v3/v3_conf.c',
+ 'third_party/boringssl/crypto/x509v3/v3_cpols.c',
+ 'third_party/boringssl/crypto/x509v3/v3_crld.c',
+ 'third_party/boringssl/crypto/x509v3/v3_enum.c',
+ 'third_party/boringssl/crypto/x509v3/v3_extku.c',
+ 'third_party/boringssl/crypto/x509v3/v3_genn.c',
+ 'third_party/boringssl/crypto/x509v3/v3_ia5.c',
+ 'third_party/boringssl/crypto/x509v3/v3_info.c',
+ 'third_party/boringssl/crypto/x509v3/v3_int.c',
+ 'third_party/boringssl/crypto/x509v3/v3_lib.c',
+ 'third_party/boringssl/crypto/x509v3/v3_ncons.c',
+ 'third_party/boringssl/crypto/x509v3/v3_pci.c',
+ 'third_party/boringssl/crypto/x509v3/v3_pcia.c',
+ 'third_party/boringssl/crypto/x509v3/v3_pcons.c',
+ 'third_party/boringssl/crypto/x509v3/v3_pku.c',
+ 'third_party/boringssl/crypto/x509v3/v3_pmaps.c',
+ 'third_party/boringssl/crypto/x509v3/v3_prn.c',
+ 'third_party/boringssl/crypto/x509v3/v3_purp.c',
+ 'third_party/boringssl/crypto/x509v3/v3_skey.c',
+ 'third_party/boringssl/crypto/x509v3/v3_sxnet.c',
+ 'third_party/boringssl/crypto/x509v3/v3_utl.c',
+ 'third_party/boringssl/ssl/bio_ssl.c',
+ 'third_party/boringssl/ssl/custom_extensions.c',
+ 'third_party/boringssl/ssl/d1_both.c',
+ 'third_party/boringssl/ssl/d1_lib.c',
+ 'third_party/boringssl/ssl/d1_pkt.c',
+ 'third_party/boringssl/ssl/d1_srtp.c',
+ 'third_party/boringssl/ssl/dtls_method.c',
+ 'third_party/boringssl/ssl/dtls_record.c',
+ 'third_party/boringssl/ssl/handshake_client.c',
+ 'third_party/boringssl/ssl/handshake_server.c',
+ 'third_party/boringssl/ssl/s3_both.c',
+ 'third_party/boringssl/ssl/s3_lib.c',
+ 'third_party/boringssl/ssl/s3_pkt.c',
+ 'third_party/boringssl/ssl/ssl_aead_ctx.c',
+ 'third_party/boringssl/ssl/ssl_asn1.c',
+ 'third_party/boringssl/ssl/ssl_buffer.c',
+ 'third_party/boringssl/ssl/ssl_cert.c',
+ 'third_party/boringssl/ssl/ssl_cipher.c',
+ 'third_party/boringssl/ssl/ssl_ecdh.c',
+ 'third_party/boringssl/ssl/ssl_file.c',
+ 'third_party/boringssl/ssl/ssl_lib.c',
+ 'third_party/boringssl/ssl/ssl_privkey.c',
+ 'third_party/boringssl/ssl/ssl_privkey_cc.cc',
+ 'third_party/boringssl/ssl/ssl_session.c',
+ 'third_party/boringssl/ssl/ssl_stat.c',
+ 'third_party/boringssl/ssl/ssl_transcript.c',
+ 'third_party/boringssl/ssl/ssl_x509.c',
+ 'third_party/boringssl/ssl/t1_enc.c',
+ 'third_party/boringssl/ssl/t1_lib.c',
+ 'third_party/boringssl/ssl/tls13_both.c',
+ 'third_party/boringssl/ssl/tls13_client.c',
+ 'third_party/boringssl/ssl/tls13_enc.c',
+ 'third_party/boringssl/ssl/tls13_server.c',
+ 'third_party/boringssl/ssl/tls_method.c',
+ 'third_party/boringssl/ssl/tls_record.c',
+ 'third_party/zlib/adler32.c',
+ 'third_party/zlib/compress.c',
+ 'third_party/zlib/crc32.c',
+ 'third_party/zlib/deflate.c',
+ 'third_party/zlib/gzclose.c',
+ 'third_party/zlib/gzlib.c',
+ 'third_party/zlib/gzread.c',
+ 'third_party/zlib/gzwrite.c',
+ 'third_party/zlib/infback.c',
+ 'third_party/zlib/inffast.c',
+ 'third_party/zlib/inflate.c',
+ 'third_party/zlib/inftrees.c',
+ 'third_party/zlib/trees.c',
+ 'third_party/zlib/uncompr.c',
+ 'third_party/zlib/zutil.c',
+ 'third_party/cares/cares/ares__close_sockets.c',
+ 'third_party/cares/cares/ares__get_hostent.c',
+ 'third_party/cares/cares/ares__read_line.c',
+ 'third_party/cares/cares/ares__timeval.c',
+ 'third_party/cares/cares/ares_cancel.c',
+ 'third_party/cares/cares/ares_create_query.c',
+ 'third_party/cares/cares/ares_data.c',
+ 'third_party/cares/cares/ares_destroy.c',
+ 'third_party/cares/cares/ares_expand_name.c',
+ 'third_party/cares/cares/ares_expand_string.c',
+ 'third_party/cares/cares/ares_fds.c',
+ 'third_party/cares/cares/ares_free_hostent.c',
+ 'third_party/cares/cares/ares_free_string.c',
+ 'third_party/cares/cares/ares_getenv.c',
+ 'third_party/cares/cares/ares_gethostbyaddr.c',
+ 'third_party/cares/cares/ares_gethostbyname.c',
+ 'third_party/cares/cares/ares_getnameinfo.c',
+ 'third_party/cares/cares/ares_getopt.c',
+ 'third_party/cares/cares/ares_getsock.c',
+ 'third_party/cares/cares/ares_init.c',
+ 'third_party/cares/cares/ares_library_init.c',
+ 'third_party/cares/cares/ares_llist.c',
+ 'third_party/cares/cares/ares_mkquery.c',
+ 'third_party/cares/cares/ares_nowarn.c',
+ 'third_party/cares/cares/ares_options.c',
+ 'third_party/cares/cares/ares_parse_a_reply.c',
+ 'third_party/cares/cares/ares_parse_aaaa_reply.c',
+ 'third_party/cares/cares/ares_parse_mx_reply.c',
+ 'third_party/cares/cares/ares_parse_naptr_reply.c',
+ 'third_party/cares/cares/ares_parse_ns_reply.c',
+ 'third_party/cares/cares/ares_parse_ptr_reply.c',
+ 'third_party/cares/cares/ares_parse_soa_reply.c',
+ 'third_party/cares/cares/ares_parse_srv_reply.c',
+ 'third_party/cares/cares/ares_parse_txt_reply.c',
+ 'third_party/cares/cares/ares_platform.c',
+ 'third_party/cares/cares/ares_process.c',
+ 'third_party/cares/cares/ares_query.c',
+ 'third_party/cares/cares/ares_search.c',
+ 'third_party/cares/cares/ares_send.c',
+ 'third_party/cares/cares/ares_strcasecmp.c',
+ 'third_party/cares/cares/ares_strdup.c',
+ 'third_party/cares/cares/ares_strerror.c',
+ 'third_party/cares/cares/ares_timeout.c',
+ 'third_party/cares/cares/ares_version.c',
+ 'third_party/cares/cares/ares_writev.c',
+ 'third_party/cares/cares/bitncmp.c',
+ 'third_party/cares/cares/inet_net_pton.c',
+ 'third_party/cares/cares/inet_ntop.c',
+ 'third_party/cares/cares/windows_port.c',
]
diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py
index 3194a893d7..a654eb026a 100644
--- a/src/python/grpcio/grpc_version.py
+++ b/src/python/grpcio/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!!
-VERSION='1.7.0.dev0'
+VERSION = '1.10.0.dev0'
diff --git a/src/python/grpcio/support.py b/src/python/grpcio/support.py
index 510bf422a0..f2395eb26c 100644
--- a/src/python/grpcio/support.py
+++ b/src/python/grpcio/support.py
@@ -94,7 +94,7 @@ def diagnose_attribute_error(build_ext, error):
_ERROR_DIAGNOSES = {
errors.CompileError: diagnose_compile_error,
- AttributeError: diagnose_attribute_error
+ AttributeError: diagnose_attribute_error,
}
@@ -102,8 +102,10 @@ def diagnose_build_ext_error(build_ext, error, formatted):
diagnostic = _ERROR_DIAGNOSES.get(type(error))
if diagnostic is None:
raise commands.CommandError(
- "\n\nWe could not diagnose your build failure. Please file an issue at "
- "http://www.github.com/grpc/grpc with `[Python install]` in the title."
- "\n\n{}".format(formatted))
+ "\n\nWe could not diagnose your build failure. If you are unable to "
+ "proceed, please file an issue at http://www.github.com/grpc/grpc "
+ "with `[Python install]` in the title; please attach the whole log "
+ "(including everything that may have appeared above the Python "
+ "backtrace).\n\n{}".format(formatted))
else:
diagnostic(build_ext, error)
diff --git a/src/python/grpcio_health_checking/MANIFEST.in b/src/python/grpcio_health_checking/MANIFEST.in
index 5255e4c403..996c74a9d4 100644
--- a/src/python/grpcio_health_checking/MANIFEST.in
+++ b/src/python/grpcio_health_checking/MANIFEST.in
@@ -1,4 +1,3 @@
include grpc_version.py
-include health_commands.py
-graft grpc_health
+recursive-include grpc_health *.py
global-exclude *.pyc
diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py
index ef68bad17a..d3185c6972 100644
--- a/src/python/grpcio_health_checking/grpc_version.py
+++ b/src/python/grpcio_health_checking/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!!
-VERSION='1.7.0.dev0'
+VERSION = '1.10.0.dev0'
diff --git a/src/python/grpcio_health_checking/health_commands.py b/src/python/grpcio_health_checking/health_commands.py
index 19547358a1..933f965aa2 100644
--- a/src/python/grpcio_health_checking/health_commands.py
+++ b/src/python/grpcio_health_checking/health_commands.py
@@ -36,9 +36,9 @@ class CopyProtoModules(setuptools.Command):
def run(self):
if os.path.isfile(HEALTH_PROTO):
- shutil.copyfile(
- HEALTH_PROTO,
- os.path.join(ROOT_DIR, 'grpc_health/v1/health.proto'))
+ shutil.copyfile(HEALTH_PROTO,
+ os.path.join(ROOT_DIR,
+ 'grpc_health/v1/health.proto'))
class BuildPackageProtos(setuptools.Command):
diff --git a/src/python/grpcio_health_checking/setup.py b/src/python/grpcio_health_checking/setup.py
index 1f5e9c5130..60d309ec65 100644
--- a/src/python/grpcio_health_checking/setup.py
+++ b/src/python/grpcio_health_checking/setup.py
@@ -20,10 +20,26 @@ import setuptools
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
-# Break import-style to ensure we can actually find our commands module.
-import health_commands
+# Break import-style to ensure we can actually find our local modules.
import grpc_version
+
+class _NoOpCommand(setuptools.Command):
+ """No-op command."""
+
+ description = ''
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ pass
+
+
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python',
@@ -40,17 +56,28 @@ PACKAGE_DIRECTORIES = {
'': '.',
}
-SETUP_REQUIRES = (
- 'grpcio-tools>={version}'.format(version=grpc_version.VERSION),)
+INSTALL_REQUIRES = (
+ 'protobuf>=3.5.0.post1',
+ 'grpcio>={version}'.format(version=grpc_version.VERSION),
+)
-INSTALL_REQUIRES = ('protobuf>=3.3.0',
- 'grpcio>={version}'.format(version=grpc_version.VERSION),)
-
-COMMAND_CLASS = {
- # Run preprocess from the repository *before* doing any packaging!
- 'preprocess': health_commands.CopyProtoModules,
- 'build_package_protos': health_commands.BuildPackageProtos,
-}
+try:
+ import health_commands as _health_commands
+ # we are in the build environment, otherwise the above import fails
+ SETUP_REQUIRES = (
+ 'grpcio-tools=={version}'.format(version=grpc_version.VERSION),)
+ COMMAND_CLASS = {
+ # Run preprocess from the repository *before* doing any packaging!
+ 'preprocess': _health_commands.CopyProtoModules,
+ 'build_package_protos': _health_commands.BuildPackageProtos,
+ }
+except ImportError:
+ SETUP_REQUIRES = ()
+ COMMAND_CLASS = {
+ # wire up commands to no-op not to break the external dependencies
+ 'preprocess': _NoOpCommand,
+ 'build_package_protos': _NoOpCommand,
+ }
setuptools.setup(
name='grpcio-health-checking',
diff --git a/src/python/grpcio_reflection/MANIFEST.in b/src/python/grpcio_reflection/MANIFEST.in
index 0f2130c0b5..d6fb6ce73a 100644
--- a/src/python/grpcio_reflection/MANIFEST.in
+++ b/src/python/grpcio_reflection/MANIFEST.in
@@ -1,4 +1,3 @@
include grpc_version.py
-include reflection_commands.py
-graft grpc_reflection
+recursive-include grpc_reflection *.py
global-exclude *.pyc
diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
index c598ea96df..0c564f10e5 100644
--- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
+++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
@@ -27,7 +27,8 @@ def _not_found_error():
return reflection_pb2.ServerReflectionResponse(
error_response=reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.NOT_FOUND.value[0],
- error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),))
+ error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
+ ))
def _file_descriptor_response(descriptor):
@@ -70,7 +71,8 @@ class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
def _file_containing_extension(self, containing_type, extension_number):
try:
- message_descriptor = self._pool.FindMessageTypeByName(containing_type)
+ message_descriptor = self._pool.FindMessageTypeByName(
+ containing_type)
extension_descriptor = self._pool.FindExtensionByNumber(
message_descriptor, extension_number)
descriptor = self._pool.FindFileContainingSymbol(
@@ -82,10 +84,13 @@ class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
def _all_extension_numbers_of_type(self, containing_type):
try:
- message_descriptor = self._pool.FindMessageTypeByName(containing_type)
- extension_numbers = tuple(sorted(
- extension.number
- for extension in self._pool.FindAllExtensions(message_descriptor)))
+ message_descriptor = self._pool.FindMessageTypeByName(
+ containing_type)
+ extension_numbers = tuple(
+ sorted(
+ extension.number
+ for extension in self._pool.FindAllExtensions(
+ message_descriptor)))
except KeyError:
return _not_found_error()
else:
@@ -97,10 +102,11 @@ class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
def _list_services(self):
return reflection_pb2.ServerReflectionResponse(
- list_services_response=reflection_pb2.ListServiceResponse(service=[
- reflection_pb2.ServiceResponse(name=service_name)
- for service_name in self._service_names
- ]))
+ list_services_response=reflection_pb2.ListServiceResponse(
+ service=[
+ reflection_pb2.ServiceResponse(name=service_name)
+ for service_name in self._service_names
+ ]))
def ServerReflectionInfo(self, request_iterator, context):
# pylint: disable=unused-argument
@@ -124,7 +130,8 @@ class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
error_response=reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0],
error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]
- .encode(),))
+ .encode(),
+ ))
def enable_server_reflection(service_names, server, pool=None):
diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py
index 55ab959cc5..7203d0d321 100644
--- a/src/python/grpcio_reflection/grpc_version.py
+++ b/src/python/grpcio_reflection/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!!
-VERSION='1.7.0.dev0'
+VERSION = '1.10.0.dev0'
diff --git a/src/python/grpcio_reflection/reflection_commands.py b/src/python/grpcio_reflection/reflection_commands.py
index e2b1aa015b..6f91f6b875 100644
--- a/src/python/grpcio_reflection/reflection_commands.py
+++ b/src/python/grpcio_reflection/reflection_commands.py
@@ -19,7 +19,7 @@ import shutil
import setuptools
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
-HEALTH_PROTO = os.path.join(
+REFLECTION_PROTO = os.path.join(
ROOT_DIR, '../../proto/grpc/reflection/v1alpha/reflection.proto')
@@ -36,9 +36,9 @@ class CopyProtoModules(setuptools.Command):
pass
def run(self):
- if os.path.isfile(HEALTH_PROTO):
+ if os.path.isfile(REFLECTION_PROTO):
shutil.copyfile(
- HEALTH_PROTO,
+ REFLECTION_PROTO,
os.path.join(ROOT_DIR,
'grpc_reflection/v1alpha/reflection.proto'))
diff --git a/src/python/grpcio_reflection/setup.py b/src/python/grpcio_reflection/setup.py
index 9360550afb..10c4c38f19 100644
--- a/src/python/grpcio_reflection/setup.py
+++ b/src/python/grpcio_reflection/setup.py
@@ -21,10 +21,26 @@ import setuptools
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
-# Break import-style to ensure we can actually find our commands module.
-import reflection_commands
+# Break import-style to ensure we can actually find our local modules.
import grpc_version
+
+class _NoOpCommand(setuptools.Command):
+ """No-op command."""
+
+ description = ''
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ pass
+
+
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python',
@@ -41,17 +57,28 @@ PACKAGE_DIRECTORIES = {
'': '.',
}
-SETUP_REQUIRES = (
- 'grpcio-tools>={version}'.format(version=grpc_version.VERSION),)
+INSTALL_REQUIRES = (
+ 'protobuf>=3.5.0.post1',
+ 'grpcio>={version}'.format(version=grpc_version.VERSION),
+)
-INSTALL_REQUIRES = ('protobuf>=3.3.0',
- 'grpcio>={version}'.format(version=grpc_version.VERSION),)
-
-COMMAND_CLASS = {
- # Run preprocess from the repository *before* doing any packaging!
- 'preprocess': reflection_commands.CopyProtoModules,
- 'build_package_protos': reflection_commands.BuildPackageProtos,
-}
+try:
+ import reflection_commands as _reflection_commands
+ # we are in the build environment, otherwise the above import fails
+ SETUP_REQUIRES = (
+ 'grpcio-tools=={version}'.format(version=grpc_version.VERSION),)
+ COMMAND_CLASS = {
+ # Run preprocess from the repository *before* doing any packaging!
+ 'preprocess': _reflection_commands.CopyProtoModules,
+ 'build_package_protos': _reflection_commands.BuildPackageProtos,
+ }
+except ImportError:
+ SETUP_REQUIRES = ()
+ COMMAND_CLASS = {
+ # wire up commands to no-op not to break the external dependencies
+ 'preprocess': _NoOpCommand,
+ 'build_package_protos': _NoOpCommand,
+ }
setuptools.setup(
name='grpcio-reflection',
diff --git a/src/python/grpcio_testing/grpc_testing/__init__.py b/src/python/grpcio_testing/grpc_testing/__init__.py
index 994274500c..e87d0ffc96 100644
--- a/src/python/grpcio_testing/grpc_testing/__init__.py
+++ b/src/python/grpcio_testing/grpc_testing/__init__.py
@@ -495,8 +495,8 @@ class Server(six.with_metaclass(abc.ABCMeta)):
"""A server with which to test a system that services RPCs."""
@abc.abstractmethod
- def invoke_unary_unary(
- self, method_descriptor, invocation_metadata, request, timeout):
+ def invoke_unary_unary(self, method_descriptor, invocation_metadata,
+ request, timeout):
"""Invokes an RPC to be serviced by the system under test.
Args:
@@ -513,8 +513,8 @@ class Server(six.with_metaclass(abc.ABCMeta)):
raise NotImplementedError()
@abc.abstractmethod
- def invoke_unary_stream(
- self, method_descriptor, invocation_metadata, request, timeout):
+ def invoke_unary_stream(self, method_descriptor, invocation_metadata,
+ request, timeout):
"""Invokes an RPC to be serviced by the system under test.
Args:
@@ -531,8 +531,8 @@ class Server(six.with_metaclass(abc.ABCMeta)):
raise NotImplementedError()
@abc.abstractmethod
- def invoke_stream_unary(
- self, method_descriptor, invocation_metadata, timeout):
+ def invoke_stream_unary(self, method_descriptor, invocation_metadata,
+ timeout):
"""Invokes an RPC to be serviced by the system under test.
Args:
@@ -548,8 +548,8 @@ class Server(six.with_metaclass(abc.ABCMeta)):
raise NotImplementedError()
@abc.abstractmethod
- def invoke_stream_stream(
- self, method_descriptor, invocation_metadata, timeout):
+ def invoke_stream_stream(self, method_descriptor, invocation_metadata,
+ timeout):
"""Invokes an RPC to be serviced by the system under test.
Args:
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/__init__.py b/src/python/grpcio_testing/grpc_testing/_channel/__init__.py
index 8011975d0a..7a64cda889 100644
--- a/src/python/grpcio_testing/grpc_testing/_channel/__init__.py
+++ b/src/python/grpcio_testing/grpc_testing/_channel/__init__.py
@@ -20,4 +20,6 @@ from grpc_testing._channel import _channel_state
# pylint: disable=unused-argument
def testing_channel(descriptors, time):
return _channel.TestingChannel(time, _channel_state.State())
+
+
# pylint: enable=unused-argument
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_channel.py b/src/python/grpcio_testing/grpc_testing/_channel/_channel.py
index fbd064db88..b015b8d738 100644
--- a/src/python/grpcio_testing/grpc_testing/_channel/_channel.py
+++ b/src/python/grpcio_testing/grpc_testing/_channel/_channel.py
@@ -32,20 +32,28 @@ class TestingChannel(grpc_testing.Channel):
def unsubscribe(self, callback):
raise NotImplementedError()
- def unary_unary(
- self, method, request_serializer=None, response_deserializer=None):
+ def unary_unary(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
return _multi_callable.UnaryUnary(method, self._state)
- def unary_stream(
- self, method, request_serializer=None, response_deserializer=None):
+ def unary_stream(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
return _multi_callable.UnaryStream(method, self._state)
- def stream_unary(
- self, method, request_serializer=None, response_deserializer=None):
+ def stream_unary(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
return _multi_callable.StreamUnary(method, self._state)
- def stream_stream(
- self, method, request_serializer=None, response_deserializer=None):
+ def stream_stream(self,
+ method,
+ request_serializer=None,
+ response_deserializer=None):
return _multi_callable.StreamStream(method, self._state)
def take_unary_unary(self, method_descriptor):
@@ -59,4 +67,6 @@ class TestingChannel(grpc_testing.Channel):
def take_stream_stream(self, method_descriptor):
return _channel_rpc.stream_stream(self._state, method_descriptor)
+
+
# pylint: enable=unused-argument
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py b/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py
index 762b6a035b..54499b3b55 100644
--- a/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py
+++ b/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py
@@ -27,8 +27,8 @@ class _UnaryUnary(grpc_testing.UnaryUnaryChannelRpc):
self._rpc_state.cancelled()
def terminate(self, response, trailing_metadata, code, details):
- self._rpc_state.terminate_with_response(
- response, trailing_metadata, code, details)
+ self._rpc_state.terminate_with_response(response, trailing_metadata,
+ code, details)
class _UnaryStream(grpc_testing.UnaryStreamChannelRpc):
@@ -67,8 +67,8 @@ class _StreamUnary(grpc_testing.StreamUnaryChannelRpc):
self._rpc_state.cancelled()
def terminate(self, response, trailing_metadata, code, details):
- self._rpc_state.terminate_with_response(
- response, trailing_metadata, code, details)
+ self._rpc_state.terminate_with_response(response, trailing_metadata,
+ code, details)
class _StreamStream(grpc_testing.StreamStreamChannelRpc):
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py b/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py
index 569c41d79d..779d59e59a 100644
--- a/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py
+++ b/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py
@@ -25,11 +25,10 @@ class State(_common.ChannelHandler):
self._condition = threading.Condition()
self._rpc_states = collections.defaultdict(list)
- def invoke_rpc(
- self, method_full_rpc_name, invocation_metadata, requests,
- requests_closed, timeout):
- rpc_state = _rpc_state.State(
- invocation_metadata, requests, requests_closed)
+ def invoke_rpc(self, method_full_rpc_name, invocation_metadata, requests,
+ requests_closed, timeout):
+ rpc_state = _rpc_state.State(invocation_metadata, requests,
+ requests_closed)
with self._condition:
self._rpc_states[method_full_rpc_name].append(rpc_state)
self._condition.notify_all()
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py b/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py
index fe69257f5b..2b2f5761f5 100644
--- a/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py
+++ b/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py
@@ -16,6 +16,7 @@ import grpc
from grpc_testing import _common
from grpc_testing._channel import _invocation
+
# All per-call credentials parameters are unused by this test infrastructure.
# pylint: disable=unused-argument
class UnaryUnary(grpc.UnaryUnaryMultiCallable):
@@ -51,8 +52,8 @@ class UnaryStream(grpc.StreamStreamMultiCallable):
def __call__(self, request, timeout=None, metadata=None, credentials=None):
rpc_handler = self._channel_handler.invoke_rpc(
- self._method_full_rpc_name,
- _common.fuss_with_metadata(metadata), [request], True, timeout)
+ self._method_full_rpc_name, _common.fuss_with_metadata(metadata),
+ [request], True, timeout)
return _invocation.ResponseIteratorCall(rpc_handler)
@@ -68,8 +69,8 @@ class StreamUnary(grpc.StreamUnaryMultiCallable):
metadata=None,
credentials=None):
rpc_handler = self._channel_handler.invoke_rpc(
- self._method_full_rpc_name,
- _common.fuss_with_metadata(metadata), [], False, timeout)
+ self._method_full_rpc_name, _common.fuss_with_metadata(metadata),
+ [], False, timeout)
_invocation.consume_requests(request_iterator, rpc_handler)
return _invocation.blocking_unary_response(rpc_handler)
@@ -79,8 +80,8 @@ class StreamUnary(grpc.StreamUnaryMultiCallable):
metadata=None,
credentials=None):
rpc_handler = self._channel_handler.invoke_rpc(
- self._method_full_rpc_name,
- _common.fuss_with_metadata(metadata), [], False, timeout)
+ self._method_full_rpc_name, _common.fuss_with_metadata(metadata),
+ [], False, timeout)
_invocation.consume_requests(request_iterator, rpc_handler)
return _invocation.blocking_unary_response_with_call(rpc_handler)
@@ -90,8 +91,8 @@ class StreamUnary(grpc.StreamUnaryMultiCallable):
metadata=None,
credentials=None):
rpc_handler = self._channel_handler.invoke_rpc(
- self._method_full_rpc_name,
- _common.fuss_with_metadata(metadata), [], False, timeout)
+ self._method_full_rpc_name, _common.fuss_with_metadata(metadata),
+ [], False, timeout)
_invocation.consume_requests(request_iterator, rpc_handler)
return _invocation.future_call(rpc_handler)
@@ -108,8 +109,10 @@ class StreamStream(grpc.StreamStreamMultiCallable):
metadata=None,
credentials=None):
rpc_handler = self._channel_handler.invoke_rpc(
- self._method_full_rpc_name,
- _common.fuss_with_metadata(metadata), [], False, timeout)
+ self._method_full_rpc_name, _common.fuss_with_metadata(metadata),
+ [], False, timeout)
_invocation.consume_requests(request_iterator, rpc_handler)
return _invocation.ResponseIteratorCall(rpc_handler)
+
+
# pylint: enable=unused-argument
diff --git a/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py b/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py
index e1fa49a2a8..009f675e49 100644
--- a/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py
+++ b/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py
@@ -63,23 +63,22 @@ class State(_common.ChannelRpcHandler):
if self._code is grpc.StatusCode.OK:
if self._responses:
response = self._responses.pop(0)
- return _common.ChannelRpcRead(
- response, None, None, None)
+ return _common.ChannelRpcRead(response, None, None,
+ None)
else:
return _common.ChannelRpcRead(
- None, self._trailing_metadata,
- grpc.StatusCode.OK, self._details)
+ None, self._trailing_metadata, grpc.StatusCode.OK,
+ self._details)
elif self._code is None:
if self._responses:
response = self._responses.pop(0)
- return _common.ChannelRpcRead(
- response, None, None, None)
+ return _common.ChannelRpcRead(response, None, None,
+ None)
else:
self._condition.wait()
else:
- return _common.ChannelRpcRead(
- None, self._trailing_metadata, self._code,
- self._details)
+ return _common.ChannelRpcRead(None, self._trailing_metadata,
+ self._code, self._details)
def termination(self):
with self._condition:
@@ -150,8 +149,8 @@ class State(_common.ChannelRpcHandler):
self._responses.append(response)
self._condition.notify_all()
- def terminate_with_response(
- self, response, trailing_metadata, code, details):
+ def terminate_with_response(self, response, trailing_metadata, code,
+ details):
with self._condition:
if self._initial_metadata is None:
self._initial_metadata = _common.FUSSED_EMPTY_METADATA
@@ -180,8 +179,8 @@ class State(_common.ChannelRpcHandler):
elif self._code is None:
self._condition.wait()
else:
- raise ValueError(
- 'Status code unexpectedly {}!'.format(self._code))
+ raise ValueError('Status code unexpectedly {}!'.format(
+ self._code))
def is_active(self):
raise NotImplementedError()
diff --git a/src/python/grpcio_testing/grpc_testing/_common.py b/src/python/grpcio_testing/grpc_testing/_common.py
index 1517434ca7..cebad31b5c 100644
--- a/src/python/grpcio_testing/grpc_testing/_common.py
+++ b/src/python/grpcio_testing/grpc_testing/_common.py
@@ -20,12 +20,11 @@ import six
def _fuss(tuplified_metadata):
- return tuplified_metadata + (
- (
- 'grpc.metadata_added_by_runtime',
- 'gRPC is allowed to add metadata in transmission and does so.',
- ),
- )
+ return tuplified_metadata + ((
+ 'grpc.metadata_added_by_runtime',
+ 'gRPC is allowed to add metadata in transmission and does so.',
+ ),)
+
FUSSED_EMPTY_METADATA = _fuss(())
@@ -41,16 +40,19 @@ def rpc_names(service_descriptors):
rpc_names_to_descriptors = {}
for service_descriptor in service_descriptors:
for method_descriptor in service_descriptor.methods_by_name.values():
- rpc_name = '/{}/{}'.format(
- service_descriptor.full_name, method_descriptor.name)
+ rpc_name = '/{}/{}'.format(service_descriptor.full_name,
+ method_descriptor.name)
rpc_names_to_descriptors[rpc_name] = method_descriptor
return rpc_names_to_descriptors
class ChannelRpcRead(
- collections.namedtuple(
- 'ChannelRpcRead',
- ('response', 'trailing_metadata', 'code', 'details',))):
+ collections.namedtuple('ChannelRpcRead', (
+ 'response',
+ 'trailing_metadata',
+ 'code',
+ 'details',
+ ))):
pass
@@ -96,15 +98,17 @@ class ChannelRpcHandler(six.with_metaclass(abc.ABCMeta)):
class ChannelHandler(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
- def invoke_rpc(
- self, method_full_rpc_name, invocation_metadata, requests,
- requests_closed, timeout):
+ def invoke_rpc(self, method_full_rpc_name, invocation_metadata, requests,
+ requests_closed, timeout):
raise NotImplementedError()
class ServerRpcRead(
- collections.namedtuple('ServerRpcRead',
- ('request', 'requests_closed', 'terminated',))):
+ collections.namedtuple('ServerRpcRead', (
+ 'request',
+ 'requests_closed',
+ 'terminated',
+ ))):
pass
@@ -138,23 +142,21 @@ class ServerRpcHandler(six.with_metaclass(abc.ABCMeta)):
class Serverish(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
- def invoke_unary_unary(
- self, method_descriptor, handler, invocation_metadata, request,
- deadline):
+ def invoke_unary_unary(self, method_descriptor, handler,
+ invocation_metadata, request, deadline):
raise NotImplementedError()
@abc.abstractmethod
- def invoke_unary_stream(
- self, method_descriptor, handler, invocation_metadata, request,
- deadline):
+ def invoke_unary_stream(self, method_descriptor, handler,
+ invocation_metadata, request, deadline):
raise NotImplementedError()
@abc.abstractmethod
- def invoke_stream_unary(
- self, method_descriptor, handler, invocation_metadata, deadline):
+ def invoke_stream_unary(self, method_descriptor, handler,
+ invocation_metadata, deadline):
raise NotImplementedError()
@abc.abstractmethod
- def invoke_stream_stream(
- self, method_descriptor, handler, invocation_metadata, deadline):
+ def invoke_stream_stream(self, method_descriptor, handler,
+ invocation_metadata, deadline):
raise NotImplementedError()
diff --git a/src/python/grpcio_testing/grpc_testing/_server/__init__.py b/src/python/grpcio_testing/grpc_testing/_server/__init__.py
index 759512949a..5f035a91ca 100644
--- a/src/python/grpcio_testing/grpc_testing/_server/__init__.py
+++ b/src/python/grpcio_testing/grpc_testing/_server/__init__.py
@@ -16,5 +16,5 @@ from grpc_testing._server import _server
def server_from_dictionary(descriptors_to_servicers, time):
- return _server.server_from_descriptor_to_servicers(
- descriptors_to_servicers, time)
+ return _server.server_from_descriptor_to_servicers(descriptors_to_servicers,
+ time)
diff --git a/src/python/grpcio_testing/grpc_testing/_server/_handler.py b/src/python/grpcio_testing/grpc_testing/_server/_handler.py
index b47e04c718..d4f50f6863 100644
--- a/src/python/grpcio_testing/grpc_testing/_server/_handler.py
+++ b/src/python/grpcio_testing/grpc_testing/_server/_handler.py
@@ -171,9 +171,11 @@ class _Handler(Handler):
if self._responses:
self._unary_response = self._responses.pop(0)
return (
- self._unary_response, self._trailing_metadata,
- self._code, self._details,)
-
+ self._unary_response,
+ self._trailing_metadata,
+ self._code,
+ self._details,
+ )
def stream_response_termination(self):
with self._condition:
diff --git a/src/python/grpcio_testing/grpc_testing/_server/_rpc.py b/src/python/grpcio_testing/grpc_testing/_server/_rpc.py
index f81876f4b2..2060e8daff 100644
--- a/src/python/grpcio_testing/grpc_testing/_server/_rpc.py
+++ b/src/python/grpcio_testing/grpc_testing/_server/_rpc.py
@@ -80,9 +80,8 @@ class Rpc(object):
def application_cancel(self):
with self._condition:
- self._abort(
- grpc.StatusCode.CANCELLED,
- 'Cancelled by server-side application!')
+ self._abort(grpc.StatusCode.CANCELLED,
+ 'Cancelled by server-side application!')
def application_exception_abort(self, exception):
with self._condition:
diff --git a/src/python/grpcio_testing/grpc_testing/_server/_server.py b/src/python/grpcio_testing/grpc_testing/_server/_server.py
index 66bcfc13c0..c7effb6b55 100644
--- a/src/python/grpcio_testing/grpc_testing/_server/_server.py
+++ b/src/python/grpcio_testing/grpc_testing/_server/_server.py
@@ -29,28 +29,34 @@ def _implementation(descriptors_to_servicers, method_descriptor):
def _unary_unary_service(request):
+
def service(implementation, rpc, servicer_context):
- _service.unary_unary(
- implementation, rpc, request, servicer_context)
+ _service.unary_unary(implementation, rpc, request, servicer_context)
+
return service
def _unary_stream_service(request):
+
def service(implementation, rpc, servicer_context):
- _service.unary_stream(
- implementation, rpc, request, servicer_context)
+ _service.unary_stream(implementation, rpc, request, servicer_context)
+
return service
def _stream_unary_service(handler):
+
def service(implementation, rpc, servicer_context):
_service.stream_unary(implementation, rpc, handler, servicer_context)
+
return service
def _stream_stream_service(handler):
+
def service(implementation, rpc, servicer_context):
_service.stream_stream(implementation, rpc, handler, servicer_context)
+
return service
@@ -60,42 +66,43 @@ class _Serverish(_common.Serverish):
self._descriptors_to_servicers = descriptors_to_servicers
self._time = time
- def _invoke(
- self, service_behavior, method_descriptor, handler,
- invocation_metadata, deadline):
- implementation = _implementation(
- self._descriptors_to_servicers, method_descriptor)
+ def _invoke(self, service_behavior, method_descriptor, handler,
+ invocation_metadata, deadline):
+ implementation = _implementation(self._descriptors_to_servicers,
+ method_descriptor)
rpc = _rpc.Rpc(handler, invocation_metadata)
if handler.add_termination_callback(rpc.extrinsic_abort):
servicer_context = _servicer_context.ServicerContext(
rpc, self._time, deadline)
service_thread = threading.Thread(
target=service_behavior,
- args=(implementation, rpc, servicer_context,))
+ args=(
+ implementation,
+ rpc,
+ servicer_context,
+ ))
service_thread.start()
- def invoke_unary_unary(
- self, method_descriptor, handler, invocation_metadata, request,
- deadline):
+ def invoke_unary_unary(self, method_descriptor, handler,
+ invocation_metadata, request, deadline):
self._invoke(
_unary_unary_service(request), method_descriptor, handler,
invocation_metadata, deadline)
- def invoke_unary_stream(
- self, method_descriptor, handler, invocation_metadata, request,
- deadline):
+ def invoke_unary_stream(self, method_descriptor, handler,
+ invocation_metadata, request, deadline):
self._invoke(
_unary_stream_service(request), method_descriptor, handler,
invocation_metadata, deadline)
- def invoke_stream_unary(
- self, method_descriptor, handler, invocation_metadata, deadline):
+ def invoke_stream_unary(self, method_descriptor, handler,
+ invocation_metadata, deadline):
self._invoke(
_stream_unary_service(handler), method_descriptor, handler,
invocation_metadata, deadline)
- def invoke_stream_stream(
- self, method_descriptor, handler, invocation_metadata, deadline):
+ def invoke_stream_stream(self, method_descriptor, handler,
+ invocation_metadata, deadline):
self._invoke(
_stream_stream_service(handler), method_descriptor, handler,
invocation_metadata, deadline)
@@ -106,7 +113,8 @@ def _deadline_and_handler(requests_closed, time, timeout):
return None, _handler.handler_without_deadline(requests_closed)
else:
deadline = time.time() + timeout
- handler = _handler.handler_with_deadline(requests_closed, time, deadline)
+ handler = _handler.handler_with_deadline(requests_closed, time,
+ deadline)
return deadline, handler
@@ -116,32 +124,32 @@ class _Server(grpc_testing.Server):
self._serverish = serverish
self._time = time
- def invoke_unary_unary(
- self, method_descriptor, invocation_metadata, request, timeout):
+ def invoke_unary_unary(self, method_descriptor, invocation_metadata,
+ request, timeout):
deadline, handler = _deadline_and_handler(True, self._time, timeout)
self._serverish.invoke_unary_unary(
method_descriptor, handler, invocation_metadata, request, deadline)
return _server_rpc.UnaryUnaryServerRpc(handler)
- def invoke_unary_stream(
- self, method_descriptor, invocation_metadata, request, timeout):
+ def invoke_unary_stream(self, method_descriptor, invocation_metadata,
+ request, timeout):
deadline, handler = _deadline_and_handler(True, self._time, timeout)
self._serverish.invoke_unary_stream(
method_descriptor, handler, invocation_metadata, request, deadline)
return _server_rpc.UnaryStreamServerRpc(handler)
- def invoke_stream_unary(
- self, method_descriptor, invocation_metadata, timeout):
+ def invoke_stream_unary(self, method_descriptor, invocation_metadata,
+ timeout):
deadline, handler = _deadline_and_handler(False, self._time, timeout)
- self._serverish.invoke_stream_unary(
- method_descriptor, handler, invocation_metadata, deadline)
+ self._serverish.invoke_stream_unary(method_descriptor, handler,
+ invocation_metadata, deadline)
return _server_rpc.StreamUnaryServerRpc(handler)
- def invoke_stream_stream(
- self, method_descriptor, invocation_metadata, timeout):
+ def invoke_stream_stream(self, method_descriptor, invocation_metadata,
+ timeout):
deadline, handler = _deadline_and_handler(False, self._time, timeout)
- self._serverish.invoke_stream_stream(
- method_descriptor, handler, invocation_metadata, deadline)
+ self._serverish.invoke_stream_stream(method_descriptor, handler,
+ invocation_metadata, deadline)
return _server_rpc.StreamStreamServerRpc(handler)
diff --git a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py
index 496689ded0..90eeb130d3 100644
--- a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py
+++ b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py
@@ -67,6 +67,9 @@ class ServicerContext(grpc.ServicerContext):
self._rpc.set_trailing_metadata(
_common.fuss_with_metadata(trailing_metadata))
+ def abort(self, code, details):
+ raise NotImplementedError()
+
def set_code(self, code):
self._rpc.set_code(code)
diff --git a/src/python/grpcio_testing/grpc_testing/_time.py b/src/python/grpcio_testing/grpc_testing/_time.py
index 3b1ab4bcd8..afbdad3524 100644
--- a/src/python/grpcio_testing/grpc_testing/_time.py
+++ b/src/python/grpcio_testing/grpc_testing/_time.py
@@ -46,9 +46,11 @@ class _State(object):
class _Delta(
- collections.namedtuple('_Delta',
- ('mature_behaviors', 'earliest_mature_time',
- 'earliest_immature_time',))):
+ collections.namedtuple('_Delta', (
+ 'mature_behaviors',
+ 'earliest_mature_time',
+ 'earliest_immature_time',
+ ))):
pass
diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py
index 592d08efc3..bf9e55e10e 100644
--- a/src/python/grpcio_testing/grpc_version.py
+++ b/src/python/grpcio_testing/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!!
-VERSION='1.7.0.dev0'
+VERSION = '1.10.0.dev0'
diff --git a/src/python/grpcio_testing/setup.py b/src/python/grpcio_testing/setup.py
index 0cc336abd1..5a9d593ec1 100644
--- a/src/python/grpcio_testing/setup.py
+++ b/src/python/grpcio_testing/setup.py
@@ -28,8 +28,10 @@ PACKAGE_DIRECTORIES = {
'': '.',
}
-INSTALL_REQUIRES = ('protobuf>=3.3.0',
- 'grpcio>={version}'.format(version=grpc_version.VERSION),)
+INSTALL_REQUIRES = (
+ 'protobuf>=3.5.0.post1',
+ 'grpcio>={version}'.format(version=grpc_version.VERSION),
+)
setuptools.setup(
name='grpcio-testing',
diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py
index 9e54dc9f75..2583e42016 100644
--- a/src/python/grpcio_tests/grpc_version.py
+++ b/src/python/grpcio_tests/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!!
-VERSION='1.7.0.dev0'
+VERSION = '1.10.0.dev0'
diff --git a/src/python/grpcio_tests/setup.py b/src/python/grpcio_tests/setup.py
index debe14c40e..250df65803 100644
--- a/src/python/grpcio_tests/setup.py
+++ b/src/python/grpcio_tests/setup.py
@@ -41,8 +41,8 @@ INSTALL_REQUIRES = (
'grpcio>={version}'.format(version=grpc_version.VERSION),
'grpcio-tools>={version}'.format(version=grpc_version.VERSION),
'grpcio-health-checking>={version}'.format(version=grpc_version.VERSION),
- 'oauth2client>=1.4.7', 'protobuf>=3.3.0', 'six>=1.10', 'google-auth>=1.0.0',
- 'requests>=2.14.2')
+ 'oauth2client>=1.4.7', 'protobuf>=3.5.0.post1', 'six>=1.10',
+ 'google-auth>=1.0.0', 'requests>=2.14.2')
COMMAND_CLASS = {
# Run `preprocess` *before* doing any packaging!
@@ -99,4 +99,5 @@ setuptools.setup(
tests_require=TESTS_REQUIRE,
test_suite=TEST_SUITE,
test_loader=TEST_LOADER,
- test_runner=TEST_RUNNER,)
+ test_runner=TEST_RUNNER,
+)
diff --git a/src/python/grpcio_tests/tests/_loader.py b/src/python/grpcio_tests/tests/_loader.py
index 281a23c16e..31680916b4 100644
--- a/src/python/grpcio_tests/tests/_loader.py
+++ b/src/python/grpcio_tests/tests/_loader.py
@@ -101,5 +101,5 @@ def iterate_suite_cases(suite):
elif isinstance(item, unittest.TestCase):
yield item
else:
- raise ValueError(
- 'unexpected suite item of type {}'.format(type(item)))
+ raise ValueError('unexpected suite item of type {}'.format(
+ type(item)))
diff --git a/src/python/grpcio_tests/tests/_result.py b/src/python/grpcio_tests/tests/_result.py
index f26fdefc97..9907c4e1f9 100644
--- a/src/python/grpcio_tests/tests/_result.py
+++ b/src/python/grpcio_tests/tests/_result.py
@@ -215,7 +215,8 @@ class AugmentedResult(unittest.TestResult):
Args:
filter (callable): A unary predicate to filter over CaseResult objects.
"""
- return (self.cases[case_id] for case_id in self.cases
+ return (self.cases[case_id]
+ for case_id in self.cases
if filter(self.cases[case_id]))
@@ -285,8 +286,8 @@ class TerminalResult(CoverageResult):
def startTestRun(self):
"""See unittest.TestResult.startTestRun."""
super(TerminalResult, self).startTestRun()
- self.out.write(_Colors.HEADER + 'Testing gRPC Python...\n' +
- _Colors.END)
+ self.out.write(
+ _Colors.HEADER + 'Testing gRPC Python...\n' + _Colors.END)
def stopTestRun(self):
"""See unittest.TestResult.stopTestRun."""
@@ -297,43 +298,43 @@ class TerminalResult(CoverageResult):
def addError(self, test, error):
"""See unittest.TestResult.addError."""
super(TerminalResult, self).addError(test, error)
- self.out.write(_Colors.FAIL + 'ERROR {}\n'.format(test.id()) +
- _Colors.END)
+ self.out.write(
+ _Colors.FAIL + 'ERROR {}\n'.format(test.id()) + _Colors.END)
self.out.flush()
def addFailure(self, test, error):
"""See unittest.TestResult.addFailure."""
super(TerminalResult, self).addFailure(test, error)
- self.out.write(_Colors.FAIL + 'FAILURE {}\n'.format(test.id()) +
- _Colors.END)
+ self.out.write(
+ _Colors.FAIL + 'FAILURE {}\n'.format(test.id()) + _Colors.END)
self.out.flush()
def addSuccess(self, test):
"""See unittest.TestResult.addSuccess."""
super(TerminalResult, self).addSuccess(test)
- self.out.write(_Colors.OK + 'SUCCESS {}\n'.format(test.id()) +
- _Colors.END)
+ self.out.write(
+ _Colors.OK + 'SUCCESS {}\n'.format(test.id()) + _Colors.END)
self.out.flush()
def addSkip(self, test, reason):
"""See unittest.TestResult.addSkip."""
super(TerminalResult, self).addSkip(test, reason)
- self.out.write(_Colors.INFO + 'SKIP {}\n'.format(test.id()) +
- _Colors.END)
+ self.out.write(
+ _Colors.INFO + 'SKIP {}\n'.format(test.id()) + _Colors.END)
self.out.flush()
def addExpectedFailure(self, test, error):
"""See unittest.TestResult.addExpectedFailure."""
super(TerminalResult, self).addExpectedFailure(test, error)
- self.out.write(_Colors.INFO + 'FAILURE_OK {}\n'.format(test.id()) +
- _Colors.END)
+ self.out.write(
+ _Colors.INFO + 'FAILURE_OK {}\n'.format(test.id()) + _Colors.END)
self.out.flush()
def addUnexpectedSuccess(self, test):
"""See unittest.TestResult.addUnexpectedSuccess."""
super(TerminalResult, self).addUnexpectedSuccess(test)
- self.out.write(_Colors.INFO + 'UNEXPECTED_OK {}\n'.format(test.id()) +
- _Colors.END)
+ self.out.write(
+ _Colors.INFO + 'UNEXPECTED_OK {}\n'.format(test.id()) + _Colors.END)
self.out.flush()
diff --git a/src/python/grpcio_tests/tests/_runner.py b/src/python/grpcio_tests/tests/_runner.py
index 8fb4a0e09b..8e27dc6c6d 100644
--- a/src/python/grpcio_tests/tests/_runner.py
+++ b/src/python/grpcio_tests/tests/_runner.py
@@ -181,8 +181,8 @@ class Runner(object):
# Run the tests
result.startTestRun()
for augmented_case in augmented_cases:
- sys.stdout.write(
- 'Running {}\n'.format(augmented_case.case.id()))
+ sys.stdout.write('Running {}\n'.format(
+ augmented_case.case.id()))
sys.stdout.flush()
case_thread = threading.Thread(
target=augmented_case.case.run, args=(result,))
@@ -196,8 +196,8 @@ class Runner(object):
except:
# re-raise the exception after forcing the with-block to end
raise
- result.set_output(augmented_case.case,
- stdout_pipe.output(), stderr_pipe.output())
+ result.set_output(augmented_case.case, stdout_pipe.output(),
+ stderr_pipe.output())
sys.stdout.write(result_out.getvalue())
sys.stdout.flush()
result_out.truncate(0)
diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
index ac31e72409..3cbbb8de33 100644
--- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
+++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
@@ -16,12 +16,11 @@
import unittest
import grpc
-from grpc.framework.foundation import logging_pool
from grpc_health.v1 import health
from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grpc
-from tests.unit.framework.common import test_constants
+from tests.unit import test_common
class HealthServicerTest(unittest.TestCase):
@@ -35,8 +34,7 @@ class HealthServicerTest(unittest.TestCase):
health_pb2.HealthCheckResponse.UNKNOWN)
servicer.set('grpc.test.TestServiceNotServing',
health_pb2.HealthCheckResponse.NOT_SERVING)
- server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(server_pool)
+ self._server = test_common.test_server()
port = self._server.add_insecure_port('[::]:0')
health_pb2_grpc.add_HealthServicer_to_server(servicer, self._server)
self._server.start()
diff --git a/src/python/grpcio_tests/tests/http2/negative_http2_client.py b/src/python/grpcio_tests/tests/http2/negative_http2_client.py
index 8dab5b67f1..e4076827b6 100644
--- a/src/python/grpcio_tests/tests/http2/negative_http2_client.py
+++ b/src/python/grpcio_tests/tests/http2/negative_http2_client.py
@@ -32,14 +32,14 @@ def _validate_payload_type_and_length(response, expected_type, expected_length):
def _expect_status_code(call, expected_code):
if call.code() != expected_code:
- raise ValueError('expected code %s, got %s' %
- (expected_code, call.code()))
+ raise ValueError('expected code %s, got %s' % (expected_code,
+ call.code()))
def _expect_status_details(call, expected_details):
if call.details() != expected_details:
- raise ValueError('expected message %s, got %s' %
- (expected_details, call.details()))
+ raise ValueError('expected message %s, got %s' % (expected_details,
+ call.details()))
def _validate_status_code_and_details(call, expected_code, expected_details):
diff --git a/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py b/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py
index 4136739f05..8d464b2d4b 100644
--- a/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py
+++ b/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py
@@ -13,7 +13,6 @@
# limitations under the License.
"""Insecure client-server interoperability as a unit test."""
-from concurrent import futures
import unittest
import grpc
@@ -22,13 +21,14 @@ from src.proto.grpc.testing import test_pb2_grpc
from tests.interop import _intraop_test_case
from tests.interop import methods
from tests.interop import server
+from tests.unit import test_common
class InsecureIntraopTest(_intraop_test_case.IntraopTestCase,
unittest.TestCase):
def setUp(self):
- self.server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ self.server = test_common.test_server()
test_pb2_grpc.add_TestServiceServicer_to_server(methods.TestService(),
self.server)
port = self.server.add_insecure_port('[::]:0')
diff --git a/src/python/grpcio_tests/tests/interop/_intraop_test_case.py b/src/python/grpcio_tests/tests/interop/_intraop_test_case.py
index ce456a679b..007db7ab41 100644
--- a/src/python/grpcio_tests/tests/interop/_intraop_test_case.py
+++ b/src/python/grpcio_tests/tests/interop/_intraop_test_case.py
@@ -39,8 +39,8 @@ class IntraopTestCase(object):
methods.TestCase.PING_PONG.test_interoperability(self.stub, None)
def testCancelAfterBegin(self):
- methods.TestCase.CANCEL_AFTER_BEGIN.test_interoperability(self.stub,
- None)
+ methods.TestCase.CANCEL_AFTER_BEGIN.test_interoperability(
+ self.stub, None)
def testCancelAfterFirstResponse(self):
methods.TestCase.CANCEL_AFTER_FIRST_RESPONSE.test_interoperability(
diff --git a/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py b/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py
index 6514d77371..c89135998d 100644
--- a/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py
+++ b/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py
@@ -13,7 +13,6 @@
# limitations under the License.
"""Secure client-server interoperability as a unit test."""
-from concurrent import futures
import unittest
import grpc
@@ -22,6 +21,7 @@ from src.proto.grpc.testing import test_pb2_grpc
from tests.interop import _intraop_test_case
from tests.interop import methods
from tests.interop import resources
+from tests.unit import test_common
_SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
@@ -29,20 +29,21 @@ _SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
class SecureIntraopTest(_intraop_test_case.IntraopTestCase, unittest.TestCase):
def setUp(self):
- self.server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ self.server = test_common.test_server()
test_pb2_grpc.add_TestServiceServicer_to_server(methods.TestService(),
self.server)
port = self.server.add_secure_port(
'[::]:0',
- grpc.ssl_server_credentials(
- [(resources.private_key(), resources.certificate_chain())]))
+ grpc.ssl_server_credentials([(resources.private_key(),
+ resources.certificate_chain())]))
self.server.start()
self.stub = test_pb2_grpc.TestServiceStub(
grpc.secure_channel('localhost:{}'.format(port),
grpc.ssl_channel_credentials(
- resources.test_root_certificates()), (
- ('grpc.ssl_target_name_override',
- _SERVER_HOST_OVERRIDE,),)))
+ resources.test_root_certificates()), ((
+ 'grpc.ssl_target_name_override',
+ _SERVER_HOST_OVERRIDE,
+ ),)))
if __name__ == '__main__':
diff --git a/src/python/grpcio_tests/tests/interop/client.py b/src/python/grpcio_tests/tests/interop/client.py
index e520c08290..3780ed9020 100644
--- a/src/python/grpcio_tests/tests/interop/client.py
+++ b/src/python/grpcio_tests/tests/interop/client.py
@@ -29,37 +29,40 @@ def _args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--server_host',
- help='the host to which to connect',
+ default="localhost",
type=str,
- default="localhost")
+ help='the host to which to connect')
parser.add_argument(
- '--server_port', help='the port to which to connect', type=int)
+ '--server_port',
+ type=int,
+ required=True,
+ help='the port to which to connect')
parser.add_argument(
'--test_case',
- help='the test case to execute',
+ default='large_unary',
type=str,
- default="large_unary")
+ help='the test case to execute')
parser.add_argument(
'--use_tls',
- help='require a secure connection',
default=False,
- type=resources.parse_bool)
+ type=resources.parse_bool,
+ help='require a secure connection')
parser.add_argument(
'--use_test_ca',
- help='replace platform root CAs with ca.pem',
default=False,
- type=resources.parse_bool)
+ type=resources.parse_bool,
+ help='replace platform root CAs with ca.pem')
parser.add_argument(
'--server_host_override',
default="foo.test.google.fr",
- help='the server host to which to claim to connect',
- type=str)
+ type=str,
+ help='the server host to which to claim to connect')
parser.add_argument(
- '--oauth_scope', help='scope for OAuth tokens', type=str)
+ '--oauth_scope', type=str, help='scope for OAuth tokens')
parser.add_argument(
'--default_service_account',
- help='email address of the default service account',
- type=str)
+ type=str,
+ help='email address of the default service account')
return parser.parse_args()
@@ -101,8 +104,10 @@ def _stub(args):
channel_credentials = grpc.composite_channel_credentials(
channel_credentials, call_credentials)
- channel = grpc.secure_channel(target, channel_credentials, (
- ('grpc.ssl_target_name_override', args.server_host_override,),))
+ channel = grpc.secure_channel(target, channel_credentials, ((
+ 'grpc.ssl_target_name_override',
+ args.server_host_override,
+ ),))
else:
channel = grpc.insecure_channel(target)
if args.test_case == "unimplemented_service":
diff --git a/src/python/grpcio_tests/tests/interop/methods.py b/src/python/grpcio_tests/tests/interop/methods.py
index ae9a50dd9b..b728ffd704 100644
--- a/src/python/grpcio_tests/tests/interop/methods.py
+++ b/src/python/grpcio_tests/tests/interop/methods.py
@@ -62,9 +62,10 @@ class TestService(test_pb2_grpc.TestServiceServicer):
def UnaryCall(self, request, context):
_maybe_echo_metadata(context)
_maybe_echo_status_and_message(request, context)
- return messages_pb2.SimpleResponse(payload=messages_pb2.Payload(
- type=messages_pb2.COMPRESSABLE,
- body=b'\x00' * request.response_size))
+ return messages_pb2.SimpleResponse(
+ payload=messages_pb2.Payload(
+ type=messages_pb2.COMPRESSABLE,
+ body=b'\x00' * request.response_size))
def StreamingOutputCall(self, request, context):
_maybe_echo_status_and_message(request, context)
@@ -100,14 +101,14 @@ class TestService(test_pb2_grpc.TestServiceServicer):
def _expect_status_code(call, expected_code):
if call.code() != expected_code:
- raise ValueError('expected code %s, got %s' %
- (expected_code, call.code()))
+ raise ValueError('expected code %s, got %s' % (expected_code,
+ call.code()))
def _expect_status_details(call, expected_details):
if call.details() != expected_details:
- raise ValueError('expected message %s, got %s' %
- (expected_details, call.details()))
+ raise ValueError('expected message %s, got %s' % (expected_details,
+ call.details()))
def _validate_status_code_and_details(call, expected_code, expected_details):
@@ -152,26 +153,38 @@ def _large_unary(stub):
def _client_streaming(stub):
- payload_body_sizes = (27182, 8, 1828, 45904,)
+ payload_body_sizes = (
+ 27182,
+ 8,
+ 1828,
+ 45904,
+ )
payloads = (messages_pb2.Payload(body=b'\x00' * size)
for size in payload_body_sizes)
requests = (messages_pb2.StreamingInputCallRequest(payload=payload)
for payload in payloads)
response = stub.StreamingInputCall(requests)
if response.aggregated_payload_size != 74922:
- raise ValueError('incorrect size %d!' %
- response.aggregated_payload_size)
+ raise ValueError(
+ 'incorrect size %d!' % response.aggregated_payload_size)
def _server_streaming(stub):
- sizes = (31415, 9, 2653, 58979,)
+ sizes = (
+ 31415,
+ 9,
+ 2653,
+ 58979,
+ )
request = messages_pb2.StreamingOutputCallRequest(
response_type=messages_pb2.COMPRESSABLE,
- response_parameters=(messages_pb2.ResponseParameters(size=sizes[0]),
- messages_pb2.ResponseParameters(size=sizes[1]),
- messages_pb2.ResponseParameters(size=sizes[2]),
- messages_pb2.ResponseParameters(size=sizes[3]),))
+ response_parameters=(
+ messages_pb2.ResponseParameters(size=sizes[0]),
+ messages_pb2.ResponseParameters(size=sizes[1]),
+ messages_pb2.ResponseParameters(size=sizes[2]),
+ messages_pb2.ResponseParameters(size=sizes[3]),
+ ))
response_iterator = stub.StreamingOutputCall(request)
for index, response in enumerate(response_iterator):
_validate_payload_type_and_length(response, messages_pb2.COMPRESSABLE,
@@ -218,8 +231,18 @@ class _Pipe(object):
def _ping_pong(stub):
- request_response_sizes = (31415, 9, 2653, 58979,)
- request_payload_sizes = (27182, 8, 1828, 45904,)
+ request_response_sizes = (
+ 31415,
+ 9,
+ 2653,
+ 58979,
+ )
+ request_payload_sizes = (
+ 27182,
+ 8,
+ 1828,
+ 45904,
+ )
with _Pipe() as pipe:
response_iterator = stub.FullDuplexCall(pipe)
@@ -247,8 +270,18 @@ def _cancel_after_begin(stub):
def _cancel_after_first_response(stub):
- request_response_sizes = (31415, 9, 2653, 58979,)
- request_payload_sizes = (27182, 8, 1828, 45904,)
+ request_response_sizes = (
+ 31415,
+ 9,
+ 2653,
+ 58979,
+ )
+ request_payload_sizes = (
+ 27182,
+ 8,
+ 1828,
+ 45904,
+ )
with _Pipe() as pipe:
response_iterator = stub.FullDuplexCall(pipe)
@@ -331,14 +364,14 @@ def _status_code_and_message(stub):
def _unimplemented_method(test_service_stub):
- response_future = (
- test_service_stub.UnimplementedCall.future(empty_pb2.Empty()))
+ response_future = (test_service_stub.UnimplementedCall.future(
+ empty_pb2.Empty()))
_expect_status_code(response_future, grpc.StatusCode.UNIMPLEMENTED)
def _unimplemented_service(unimplemented_service_stub):
- response_future = (
- unimplemented_service_stub.UnimplementedCall.future(empty_pb2.Empty()))
+ response_future = (unimplemented_service_stub.UnimplementedCall.future(
+ empty_pb2.Empty()))
_expect_status_code(response_future, grpc.StatusCode.UNIMPLEMENTED)
@@ -392,11 +425,12 @@ def _oauth2_auth_token(stub, args):
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
response = _large_unary_common_behavior(stub, True, True, None)
if wanted_email != response.username:
- raise ValueError('expected username %s, got %s' %
- (wanted_email, response.username))
+ raise ValueError('expected username %s, got %s' % (wanted_email,
+ response.username))
if args.oauth_scope.find(response.oauth_scope) == -1:
- raise ValueError('expected to find oauth scope "{}" in received "{}"'.
- format(response.oauth_scope, args.oauth_scope))
+ raise ValueError(
+ 'expected to find oauth scope "{}" in received "{}"'.format(
+ response.oauth_scope, args.oauth_scope))
def _jwt_token_creds(stub, args):
@@ -404,8 +438,8 @@ def _jwt_token_creds(stub, args):
wanted_email = json.load(open(json_key_filename, 'rb'))['client_email']
response = _large_unary_common_behavior(stub, True, False, None)
if wanted_email != response.username:
- raise ValueError('expected username %s, got %s' %
- (wanted_email, response.username))
+ raise ValueError('expected username %s, got %s' % (wanted_email,
+ response.username))
def _per_rpc_creds(stub, args):
@@ -419,8 +453,8 @@ def _per_rpc_creds(stub, args):
request=google_auth_transport_requests.Request()))
response = _large_unary_common_behavior(stub, True, False, call_credentials)
if wanted_email != response.username:
- raise ValueError('expected username %s, got %s' %
- (wanted_email, response.username))
+ raise ValueError('expected username %s, got %s' % (wanted_email,
+ response.username))
@enum.unique
@@ -479,5 +513,5 @@ class TestCase(enum.Enum):
elif self is TestCase.PER_RPC_CREDS:
_per_rpc_creds(stub, args)
else:
- raise NotImplementedError('Test case "%s" not implemented!' %
- self.name)
+ raise NotImplementedError(
+ 'Test case "%s" not implemented!' % self.name)
diff --git a/src/python/grpcio_tests/tests/interop/server.py b/src/python/grpcio_tests/tests/interop/server.py
index 8ad1f5f7cd..0810de2394 100644
--- a/src/python/grpcio_tests/tests/interop/server.py
+++ b/src/python/grpcio_tests/tests/interop/server.py
@@ -23,28 +23,30 @@ from src.proto.grpc.testing import test_pb2_grpc
from tests.interop import methods
from tests.interop import resources
+from tests.unit import test_common
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
def serve():
parser = argparse.ArgumentParser()
- parser.add_argument('--port', help='the port on which to serve', type=int)
+ parser.add_argument(
+ '--port', type=int, required=True, help='the port on which to serve')
parser.add_argument(
'--use_tls',
- help='require a secure connection',
default=False,
- type=resources.parse_bool)
+ type=resources.parse_bool,
+ help='require a secure connection')
args = parser.parse_args()
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ server = test_common.test_server()
test_pb2_grpc.add_TestServiceServicer_to_server(methods.TestService(),
server)
if args.use_tls:
private_key = resources.private_key()
certificate_chain = resources.certificate_chain()
- credentials = grpc.ssl_server_credentials((
- (private_key, certificate_chain),))
+ credentials = grpc.ssl_server_credentials(((private_key,
+ certificate_chain),))
server.add_secure_port('[::]:{}'.format(args.port), credentials)
else:
server.add_insecure_port('[::]:{}'.format(args.port))
diff --git a/src/python/grpcio_tests/tests/protoc_plugin/_python_plugin_test.py b/src/python/grpcio_tests/tests/protoc_plugin/_python_plugin_test.py
index 5b84001aab..6d85f43130 100644
--- a/src/python/grpcio_tests/tests/protoc_plugin/_python_plugin_test.py
+++ b/src/python/grpcio_tests/tests/protoc_plugin/_python_plugin_test.py
@@ -13,7 +13,6 @@
# limitations under the License.
import collections
-from concurrent import futures
import contextlib
import distutils.spawn
import errno
@@ -28,6 +27,7 @@ import unittest
from six import moves
import grpc
+from tests.unit import test_common
from tests.unit.framework.common import test_constants
import tests.protoc_plugin.protos.payload.test_payload_pb2 as payload_pb2
@@ -119,8 +119,11 @@ class _ServicerMethods(object):
class _Service(
- collections.namedtuple('_Service', ('servicer_methods', 'server',
- 'stub',))):
+ collections.namedtuple('_Service', (
+ 'servicer_methods',
+ 'server',
+ 'stub',
+ ))):
"""A live and running service.
Attributes:
@@ -155,8 +158,7 @@ def _CreateService():
def HalfDuplexCall(self, request_iter, context):
return servicer_methods.HalfDuplexCall(request_iter, context)
- server = grpc.server(
- futures.ThreadPoolExecutor(max_workers=test_constants.POOL_SIZE))
+ server = test_common.test_server()
getattr(service_pb2_grpc, ADD_SERVICER_TO_SERVER_IDENTIFIER)(Servicer(),
server)
port = server.add_insecure_port('[::]:0')
@@ -177,8 +179,7 @@ def _CreateIncompleteService():
class Servicer(getattr(service_pb2_grpc, SERVICER_IDENTIFIER)):
pass
- server = grpc.server(
- futures.ThreadPoolExecutor(max_workers=test_constants.POOL_SIZE))
+ server = test_common.test_server()
getattr(service_pb2_grpc, ADD_SERVICER_TO_SERVER_IDENTIFIER)(Servicer(),
server)
port = server.add_insecure_port('[::]:0')
@@ -299,8 +300,8 @@ class PythonPluginTest(unittest.TestCase):
responses = service.stub.StreamingOutputCall(request)
expected_responses = service.servicer_methods.StreamingOutputCall(
request, 'not a real RpcContext!')
- for expected_response, response in moves.zip_longest(expected_responses,
- responses):
+ for expected_response, response in moves.zip_longest(
+ expected_responses, responses):
self.assertEqual(expected_response, response)
def testStreamingOutputCallExpired(self):
@@ -390,8 +391,8 @@ class PythonPluginTest(unittest.TestCase):
responses = service.stub.FullDuplexCall(_full_duplex_request_iterator())
expected_responses = service.servicer_methods.FullDuplexCall(
_full_duplex_request_iterator(), 'not a real RpcContext!')
- for expected_response, response in moves.zip_longest(expected_responses,
- responses):
+ for expected_response, response in moves.zip_longest(
+ expected_responses, responses):
self.assertEqual(expected_response, response)
def testFullDuplexCallExpired(self):
@@ -441,8 +442,8 @@ class PythonPluginTest(unittest.TestCase):
responses = service.stub.HalfDuplexCall(half_duplex_request_iterator())
expected_responses = service.servicer_methods.HalfDuplexCall(
half_duplex_request_iterator(), 'not a real RpcContext!')
- for expected_response, response in moves.zip_longest(expected_responses,
- responses):
+ for expected_response, response in moves.zip_longest(
+ expected_responses, responses):
self.assertEqual(expected_response, response)
def testHalfDuplexCallWedged(self):
diff --git a/src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py b/src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py
index 7868cdbfb3..ab33775ad3 100644
--- a/src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py
+++ b/src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py
@@ -13,7 +13,6 @@
# limitations under the License.
import abc
-from concurrent import futures
import contextlib
import importlib
import os
@@ -29,7 +28,7 @@ import six
import grpc
from grpc_tools import protoc
-from tests.unit.framework.common import test_constants
+from tests.unit import test_common
_MESSAGES_IMPORT = b'import "messages.proto";'
_SPLIT_NAMESPACE = b'package grpc_protoc_plugin.invocation_testing.split;'
@@ -65,8 +64,8 @@ def _massage_proto_content(proto_content, test_name_bytes,
messages_proto_relative_file_name_bytes):
package_substitution = (b'package grpc_protoc_plugin.invocation_testing.' +
test_name_bytes + b';')
- common_namespace_substituted = proto_content.replace(_COMMON_NAMESPACE,
- package_substitution)
+ common_namespace_substituted = proto_content.replace(
+ _COMMON_NAMESPACE, package_substitution)
split_namespace_substituted = common_namespace_substituted.replace(
_SPLIT_NAMESPACE, package_substitution)
message_import_replaced = split_namespace_substituted.replace(
@@ -164,8 +163,12 @@ class _GrpcBeforeProtoProtocStyle(object):
return pb2_grpc_protoc_exit_code, pb2_protoc_exit_code,
-_PROTOC_STYLES = (_Mid2016ProtocStyle(), _SingleProtocExecutionProtocStyle(),
- _ProtoBeforeGrpcProtocStyle(), _GrpcBeforeProtoProtocStyle(),)
+_PROTOC_STYLES = (
+ _Mid2016ProtocStyle(),
+ _SingleProtocExecutionProtocStyle(),
+ _ProtoBeforeGrpcProtocStyle(),
+ _GrpcBeforeProtoProtocStyle(),
+)
@unittest.skipIf(platform.python_implementation() == 'PyPy',
@@ -181,18 +184,22 @@ class _Test(six.with_metaclass(abc.ABCMeta, unittest.TestCase)):
os.makedirs(self._python_out)
proto_directories_and_names = {
- (self.MESSAGES_PROTO_RELATIVE_DIRECTORY_NAMES,
- self.MESSAGES_PROTO_FILE_NAME,),
- (self.SERVICES_PROTO_RELATIVE_DIRECTORY_NAMES,
- self.SERVICES_PROTO_FILE_NAME,),
+ (
+ self.MESSAGES_PROTO_RELATIVE_DIRECTORY_NAMES,
+ self.MESSAGES_PROTO_FILE_NAME,
+ ),
+ (
+ self.SERVICES_PROTO_RELATIVE_DIRECTORY_NAMES,
+ self.SERVICES_PROTO_FILE_NAME,
+ ),
}
messages_proto_relative_file_name_forward_slashes = '/'.join(
- self.MESSAGES_PROTO_RELATIVE_DIRECTORY_NAMES + (
- self.MESSAGES_PROTO_FILE_NAME,))
- _create_directory_tree(self._proto_path, (
- relative_proto_directory_names
- for relative_proto_directory_names, _ in proto_directories_and_names
- ))
+ self.MESSAGES_PROTO_RELATIVE_DIRECTORY_NAMES +
+ (self.MESSAGES_PROTO_FILE_NAME,))
+ _create_directory_tree(self._proto_path,
+ (relative_proto_directory_names
+ for relative_proto_directory_names, _ in
+ proto_directories_and_names))
self._absolute_proto_file_names = set()
for relative_directory_names, file_name in proto_directories_and_names:
absolute_proto_file_name = path.join(
@@ -201,8 +208,7 @@ class _Test(six.with_metaclass(abc.ABCMeta, unittest.TestCase)):
'tests.protoc_plugin.protos.invocation_testing',
path.join(*relative_directory_names + (file_name,)))
massaged_proto_content = _massage_proto_content(
- raw_proto_content,
- self.NAME.encode(),
+ raw_proto_content, self.NAME.encode(),
messages_proto_relative_file_name_forward_slashes.encode())
with open(absolute_proto_file_name, 'wb') as proto_file:
proto_file.write(massaged_proto_content)
@@ -256,9 +262,7 @@ class _Test(six.with_metaclass(abc.ABCMeta, unittest.TestCase)):
self._protoc()
for services_module in self._services_modules():
- server = grpc.server(
- futures.ThreadPoolExecutor(
- max_workers=test_constants.POOL_SIZE))
+ server = test_common.test_server()
services_module.add_TestServiceServicer_to_server(
_Servicer(self._messages_pb2.Response), server)
port = server.add_insecure_port('[::]:0')
@@ -278,7 +282,9 @@ def _create_test_case_class(split_proto, protoc_style):
if split_proto:
attributes['MESSAGES_PROTO_RELATIVE_DIRECTORY_NAMES'] = (
- 'split_messages', 'sub',)
+ 'split_messages',
+ 'sub',
+ )
attributes['MESSAGES_PROTO_FILE_NAME'] = 'messages.proto'
attributes['SERVICES_PROTO_RELATIVE_DIRECTORY_NAMES'] = (
'split_services',)
@@ -304,7 +310,10 @@ def _create_test_case_class(split_proto, protoc_style):
def _create_test_case_classes():
- for split_proto in (False, True,):
+ for split_proto in (
+ False,
+ True,
+ ):
for protoc_style in _PROTOC_STYLES:
yield _create_test_case_class(split_proto, protoc_style)
diff --git a/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py b/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py
index 424b153ff8..ad0ecf0079 100644
--- a/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py
+++ b/src/python/grpcio_tests/tests/protoc_plugin/beta_python_plugin_test.py
@@ -36,10 +36,28 @@ _RELATIVE_PROTO_PATH = 'relative_proto_path'
_RELATIVE_PYTHON_OUT = 'relative_python_out'
_PROTO_FILES_PATH_COMPONENTS = (
- ('beta_grpc_plugin_test', 'payload', 'test_payload.proto',),
- ('beta_grpc_plugin_test', 'requests', 'r', 'test_requests.proto',),
- ('beta_grpc_plugin_test', 'responses', 'test_responses.proto',),
- ('beta_grpc_plugin_test', 'service', 'test_service.proto',),)
+ (
+ 'beta_grpc_plugin_test',
+ 'payload',
+ 'test_payload.proto',
+ ),
+ (
+ 'beta_grpc_plugin_test',
+ 'requests',
+ 'r',
+ 'test_requests.proto',
+ ),
+ (
+ 'beta_grpc_plugin_test',
+ 'responses',
+ 'test_responses.proto',
+ ),
+ (
+ 'beta_grpc_plugin_test',
+ 'service',
+ 'test_service.proto',
+ ),
+)
_PAYLOAD_PB2 = 'beta_grpc_plugin_test.payload.test_payload_pb2'
_REQUESTS_PB2 = 'beta_grpc_plugin_test.requests.r.test_requests_pb2'
diff --git a/src/python/grpcio_tests/tests/qps/benchmark_client.py b/src/python/grpcio_tests/tests/qps/benchmark_client.py
index 17fa61ea36..e6392a8b8c 100644
--- a/src/python/grpcio_tests/tests/qps/benchmark_client.py
+++ b/src/python/grpcio_tests/tests/qps/benchmark_client.py
@@ -155,7 +155,8 @@ class _SyncStream(object):
_TIMEOUT)
for _ in response_stream:
self._handle_response(
- self, time.time() - self._send_time_queue.get_nowait())
+ self,
+ time.time() - self._send_time_queue.get_nowait())
def stop(self):
self._is_streaming = False
diff --git a/src/python/grpcio_tests/tests/qps/qps_worker.py b/src/python/grpcio_tests/tests/qps/qps_worker.py
index 3e46c0b8c2..54f69db109 100644
--- a/src/python/grpcio_tests/tests/qps/qps_worker.py
+++ b/src/python/grpcio_tests/tests/qps/qps_worker.py
@@ -16,15 +16,15 @@
import argparse
import time
-from concurrent import futures
import grpc
from src.proto.grpc.testing import services_pb2_grpc
from tests.qps import worker_server
+from tests.unit import test_common
def run_worker_server(port):
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=5))
+ server = test_common.test_server()
servicer = worker_server.WorkerServer()
services_pb2_grpc.add_WorkerServiceServicer_to_server(servicer, server)
server.add_insecure_port('[::]:{}'.format(port))
diff --git a/src/python/grpcio_tests/tests/qps/worker_server.py b/src/python/grpcio_tests/tests/qps/worker_server.py
index adb10cbcec..41e2403c8f 100644
--- a/src/python/grpcio_tests/tests/qps/worker_server.py
+++ b/src/python/grpcio_tests/tests/qps/worker_server.py
@@ -28,6 +28,7 @@ from tests.qps import benchmark_server
from tests.qps import client_runner
from tests.qps import histogram
from tests.unit import resources
+from tests.unit import test_common
class WorkerServer(services_pb2_grpc.WorkerServiceServicer):
@@ -68,12 +69,11 @@ class WorkerServer(services_pb2_grpc.WorkerServiceServicer):
server_threads = multiprocessing.cpu_count() * 5
else:
server_threads = config.async_server_threads
- server = grpc.server(
- futures.ThreadPoolExecutor(max_workers=server_threads))
+ server = test_common.test_server(max_workers=server_threads)
if config.server_type == control_pb2.ASYNC_SERVER:
servicer = benchmark_server.BenchmarkServer()
- services_pb2_grpc.add_BenchmarkServiceServicer_to_server(servicer,
- server)
+ services_pb2_grpc.add_BenchmarkServiceServicer_to_server(
+ servicer, server)
elif config.server_type == control_pb2.ASYNC_GENERIC_SERVER:
resp_size = config.payload_config.bytebuf_params.resp_size
servicer = benchmark_server.GenericBenchmarkServer(resp_size)
@@ -87,12 +87,12 @@ class WorkerServer(services_pb2_grpc.WorkerServiceServicer):
'grpc.testing.BenchmarkService', method_implementations)
server.add_generic_rpc_handlers((handler,))
else:
- raise Exception(
- 'Unsupported server type {}'.format(config.server_type))
+ raise Exception('Unsupported server type {}'.format(
+ config.server_type))
if config.HasField('security_params'): # Use SSL
- server_creds = grpc.ssl_server_credentials((
- (resources.private_key(), resources.certificate_chain()),))
+ server_creds = grpc.ssl_server_credentials(
+ ((resources.private_key(), resources.certificate_chain()),))
port = server.add_secure_port('[::]:{}'.format(config.port),
server_creds)
else:
@@ -156,8 +156,8 @@ class WorkerServer(services_pb2_grpc.WorkerServiceServicer):
else:
raise Exception('Async streaming client not supported')
else:
- raise Exception(
- 'Unsupported client type {}'.format(config.client_type))
+ raise Exception('Unsupported client type {}'.format(
+ config.client_type))
# In multi-channel tests, we split the load across all channels
load_factor = float(config.client_channels)
diff --git a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
index a86743fa5a..7ffdba6a67 100644
--- a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
+++ b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
@@ -16,7 +16,6 @@
import unittest
import grpc
-from grpc.framework.foundation import logging_pool
from grpc_reflection.v1alpha import reflection
from grpc_reflection.v1alpha import reflection_pb2
from grpc_reflection.v1alpha import reflection_pb2_grpc
@@ -27,14 +26,20 @@ from google.protobuf import descriptor_pb2
from src.proto.grpc.testing import empty_pb2
from src.proto.grpc.testing.proto2 import empty2_extensions_pb2
-from tests.unit.framework.common import test_constants
+from tests.unit import test_common
_EMPTY_PROTO_FILE_NAME = 'src/proto/grpc/testing/empty.proto'
_EMPTY_PROTO_SYMBOL_NAME = 'grpc.testing.Empty'
_SERVICE_NAMES = ('Angstrom', 'Bohr', 'Curie', 'Dyson', 'Einstein', 'Feynman',
'Galilei')
_EMPTY_EXTENSIONS_SYMBOL_NAME = 'grpc.testing.proto2.EmptyWithExtensions'
-_EMPTY_EXTENSIONS_NUMBERS = (124, 125, 126, 127, 128,)
+_EMPTY_EXTENSIONS_NUMBERS = (
+ 124,
+ 125,
+ 126,
+ 127,
+ 128,
+)
def _file_descriptor_to_proto(descriptor):
@@ -46,8 +51,7 @@ def _file_descriptor_to_proto(descriptor):
class ReflectionServicerTest(unittest.TestCase):
def setUp(self):
- server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(server_pool)
+ self._server = test_common.test_server()
reflection.enable_server_reflection(_SERVICE_NAMES, self._server)
port = self._server.add_insecure_port('[::]:0')
self._server.start()
@@ -56,10 +60,12 @@ class ReflectionServicerTest(unittest.TestCase):
self._stub = reflection_pb2_grpc.ServerReflectionStub(channel)
def testFileByName(self):
- requests = (reflection_pb2.ServerReflectionRequest(
- file_by_filename=_EMPTY_PROTO_FILE_NAME),
- reflection_pb2.ServerReflectionRequest(
- file_by_filename='i-donut-exist'),)
+ requests = (
+ reflection_pb2.ServerReflectionRequest(
+ file_by_filename=_EMPTY_PROTO_FILE_NAME),
+ reflection_pb2.ServerReflectionRequest(
+ file_by_filename='i-donut-exist'),
+ )
responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
expected_responses = (
reflection_pb2.ServerReflectionResponse(
@@ -72,14 +78,18 @@ class ReflectionServicerTest(unittest.TestCase):
error_response=reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.NOT_FOUND.value[0],
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
- )),)
+ )),
+ )
self.assertSequenceEqual(expected_responses, responses)
def testFileBySymbol(self):
- requests = (reflection_pb2.ServerReflectionRequest(
- file_containing_symbol=_EMPTY_PROTO_SYMBOL_NAME
- ), reflection_pb2.ServerReflectionRequest(
- file_containing_symbol='i.donut.exist.co.uk.org.net.me.name.foo'),)
+ requests = (
+ reflection_pb2.ServerReflectionRequest(
+ file_containing_symbol=_EMPTY_PROTO_SYMBOL_NAME),
+ reflection_pb2.ServerReflectionRequest(
+ file_containing_symbol='i.donut.exist.co.uk.org.net.me.name.foo'
+ ),
+ )
responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
expected_responses = (
reflection_pb2.ServerReflectionResponse(
@@ -92,18 +102,23 @@ class ReflectionServicerTest(unittest.TestCase):
error_response=reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.NOT_FOUND.value[0],
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
- )),)
+ )),
+ )
self.assertSequenceEqual(expected_responses, responses)
def testFileContainingExtension(self):
- requests = (reflection_pb2.ServerReflectionRequest(
- file_containing_extension=reflection_pb2.ExtensionRequest(
- containing_type=_EMPTY_EXTENSIONS_SYMBOL_NAME,
- extension_number=125,),
- ), reflection_pb2.ServerReflectionRequest(
- file_containing_extension=reflection_pb2.ExtensionRequest(
- containing_type='i.donut.exist.co.uk.org.net.me.name.foo',
- extension_number=55,),),)
+ requests = (
+ reflection_pb2.ServerReflectionRequest(
+ file_containing_extension=reflection_pb2.ExtensionRequest(
+ containing_type=_EMPTY_EXTENSIONS_SYMBOL_NAME,
+ extension_number=125,
+ ),),
+ reflection_pb2.ServerReflectionRequest(
+ file_containing_extension=reflection_pb2.ExtensionRequest(
+ containing_type='i.donut.exist.co.uk.org.net.me.name.foo',
+ extension_number=55,
+ ),),
+ )
responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
expected_responses = (
reflection_pb2.ServerReflectionResponse(
@@ -116,14 +131,18 @@ class ReflectionServicerTest(unittest.TestCase):
error_response=reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.NOT_FOUND.value[0],
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
- )),)
+ )),
+ )
self.assertSequenceEqual(expected_responses, responses)
def testExtensionNumbersOfType(self):
- requests = (reflection_pb2.ServerReflectionRequest(
- all_extension_numbers_of_type=_EMPTY_EXTENSIONS_SYMBOL_NAME
- ), reflection_pb2.ServerReflectionRequest(
- all_extension_numbers_of_type='i.donut.exist.co.uk.net.name.foo'),)
+ requests = (
+ reflection_pb2.ServerReflectionRequest(
+ all_extension_numbers_of_type=_EMPTY_EXTENSIONS_SYMBOL_NAME),
+ reflection_pb2.ServerReflectionRequest(
+ all_extension_numbers_of_type='i.donut.exist.co.uk.net.name.foo'
+ ),
+ )
responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
expected_responses = (
reflection_pb2.ServerReflectionResponse(
@@ -137,12 +156,12 @@ class ReflectionServicerTest(unittest.TestCase):
error_response=reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.NOT_FOUND.value[0],
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
- )),)
+ )),
+ )
self.assertSequenceEqual(expected_responses, responses)
def testListServices(self):
- requests = (reflection_pb2.ServerReflectionRequest(
- list_services='',),)
+ requests = (reflection_pb2.ServerReflectionRequest(list_services='',),)
responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
expected_responses = (reflection_pb2.ServerReflectionResponse(
valid_host='',
diff --git a/src/python/grpcio_tests/tests/stress/client.py b/src/python/grpcio_tests/tests/stress/client.py
index 40caa3926a..41f2e1b6c2 100644
--- a/src/python/grpcio_tests/tests/stress/client.py
+++ b/src/python/grpcio_tests/tests/stress/client.py
@@ -102,8 +102,10 @@ def _get_channel(target, args):
root_certificates = None # will load default roots.
channel_credentials = grpc.ssl_channel_credentials(
root_certificates=root_certificates)
- options = (('grpc.ssl_target_name_override',
- args.server_host_override,),)
+ options = ((
+ 'grpc.ssl_target_name_override',
+ args.server_host_override,
+ ),)
channel = grpc.secure_channel(
target, channel_credentials, options=options)
else:
diff --git a/src/python/grpcio_tests/tests/testing/_client_application.py b/src/python/grpcio_tests/tests/testing/_client_application.py
index aff32fb4dc..7d0d74c8c4 100644
--- a/src/python/grpcio_tests/tests/testing/_client_application.py
+++ b/src/python/grpcio_tests/tests/testing/_client_application.py
@@ -235,8 +235,8 @@ def run(scenario, channel):
elif scenario is Scenario.INFINITE_REQUEST_STREAM:
return _run_infinite_request_stream(stub)
except grpc.RpcError as rpc_error:
- return Outcome(Outcome.Kind.RPC_ERROR,
- rpc_error.code(), rpc_error.details())
+ return Outcome(Outcome.Kind.RPC_ERROR, rpc_error.code(),
+ rpc_error.details())
_IMPLEMENTATIONS = {
@@ -256,5 +256,5 @@ def run(scenario, channel):
try:
return _IMPLEMENTATIONS[scenario](stub)
except grpc.RpcError as rpc_error:
- return Outcome(Outcome.Kind.RPC_ERROR,
- rpc_error.code(), rpc_error.details())
+ return Outcome(Outcome.Kind.RPC_ERROR, rpc_error.code(),
+ rpc_error.details())
diff --git a/src/python/grpcio_tests/tests/testing/_client_test.py b/src/python/grpcio_tests/tests/testing/_client_test.py
index 172f386d7b..5b051c3939 100644
--- a/src/python/grpcio_tests/tests/testing/_client_test.py
+++ b/src/python/grpcio_tests/tests/testing/_client_test.py
@@ -193,8 +193,10 @@ class ClientTest(unittest.TestCase):
rpc.take_request()
rpc.take_request()
rpc.requests_closed()
- rpc.send_initial_metadata((
- ('my_metadata_key', 'My Metadata Value!',),))
+ rpc.send_initial_metadata(((
+ 'my_metadata_key',
+ 'My Metadata Value!',
+ ),))
for rpc in rpcs[:-1]:
rpc.terminate(_application_common.STREAM_UNARY_RESPONSE, (),
grpc.StatusCode.OK, '')
diff --git a/src/python/grpcio_tests/tests/testing/_server_application.py b/src/python/grpcio_tests/tests/testing/_server_application.py
index 06f09c8cb4..02769ca68d 100644
--- a/src/python/grpcio_tests/tests/testing/_server_application.py
+++ b/src/python/grpcio_tests/tests/testing/_server_application.py
@@ -41,8 +41,10 @@ class FirstServiceServicer(services_pb2_grpc.FirstServiceServicer):
yield services_pb2.Strange()
def StreUn(self, request_iterator, context):
- context.send_initial_metadata((
- ('server_application_metadata_key', 'Hi there!',),))
+ context.send_initial_metadata(((
+ 'server_application_metadata_key',
+ 'Hi there!',
+ ),))
for request in request_iterator:
if request != _application_common.STREAM_UNARY_REQUEST:
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
diff --git a/src/python/grpcio_tests/tests/testing/_server_test.py b/src/python/grpcio_tests/tests/testing/_server_test.py
index 7897bcce01..4f4abd7708 100644
--- a/src/python/grpcio_tests/tests/testing/_server_test.py
+++ b/src/python/grpcio_tests/tests/testing/_server_test.py
@@ -110,14 +110,19 @@ class FirstServiceServicerTest(unittest.TestCase):
second_termination = rpc.termination()
third_termination = rpc.termination()
- for later_initial_metadata in (second_initial_metadata,
- third_initial_metadata,):
+ for later_initial_metadata in (
+ second_initial_metadata,
+ third_initial_metadata,
+ ):
self.assertEqual(first_initial_metadata, later_initial_metadata)
response = first_termination[0]
terminal_metadata = first_termination[1]
code = first_termination[2]
details = first_termination[3]
- for later_termination in (second_termination, third_termination,):
+ for later_termination in (
+ second_termination,
+ third_termination,
+ ):
self.assertEqual(response, later_termination[0])
self.assertEqual(terminal_metadata, later_termination[1])
self.assertIs(code, later_termination[2])
diff --git a/src/python/grpcio_tests/tests/testing/_time_test.py b/src/python/grpcio_tests/tests/testing/_time_test.py
index 797394ae20..9dfe36fb83 100644
--- a/src/python/grpcio_tests/tests/testing/_time_test.py
+++ b/src/python/grpcio_tests/tests/testing/_time_test.py
@@ -105,8 +105,8 @@ class TimeTest(object):
test_event.set, _QUANTUM * (2 + random.random()))
for _ in range(_MANY):
background_noise_futures.append(
- self._time.call_in(threading.Event().set, _QUANTUM * 1000 *
- random.random()))
+ self._time.call_in(threading.Event().set,
+ _QUANTUM * 1000 * random.random()))
self._time.sleep_for(_QUANTUM)
cancelled = set()
for test_event, test_future in possibly_cancelled_futures.items():
diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json
index 8512d5b96f..e033c1063f 100644
--- a/src/python/grpcio_tests/tests/tests.json
+++ b/src/python/grpcio_tests/tests/tests.json
@@ -22,7 +22,7 @@
"unit._api_test.ChannelConnectivityTest",
"unit._api_test.ChannelTest",
"unit._auth_context_test.AuthContextTest",
- "unit._auth_test.AccessTokenCallCredentialsTest",
+ "unit._auth_test.AccessTokenAuthMetadataPluginTest",
"unit._auth_test.GoogleCallCredentialsTest",
"unit._channel_args_test.ChannelArgsTest",
"unit._channel_connectivity_test.ChannelConnectivityTest",
@@ -34,11 +34,13 @@
"unit._cython._no_messages_server_completion_queue_per_call_test.Test",
"unit._cython._no_messages_single_server_completion_queue_test.Test",
"unit._cython._read_some_but_not_all_responses_test.ReadSomeButNotAllResponsesTest",
+ "unit._cython._server_test.Test",
"unit._cython.cygrpc_test.InsecureServerInsecureClient",
"unit._cython.cygrpc_test.SecureServerSecureClient",
"unit._cython.cygrpc_test.TypeSmokeTest",
"unit._empty_message_test.EmptyMessageTest",
"unit._exit_test.ExitTest",
+ "unit._interceptor_test.InterceptorTest",
"unit._invalid_metadata_test.InvalidMetadataTest",
"unit._invocation_defects_test.InvocationDefectsTest",
"unit._metadata_code_details_test.MetadataCodeDetailsTest",
@@ -46,6 +48,10 @@
"unit._reconnect_test.ReconnectTest",
"unit._resource_exhausted_test.ResourceExhaustedTest",
"unit._rpc_test.RPCTest",
+ "unit._server_ssl_cert_config_test.ServerSSLCertConfigFetcherParamsChecks",
+ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestCertConfigReuse",
+ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithClientAuth",
+ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth",
"unit._thread_cleanup_test.CleanupThreadTest",
"unit.beta._beta_features_test.BetaFeaturesTest",
"unit.beta._beta_features_test.ContextManagementAndLifecycleTest",
diff --git a/src/python/grpcio_tests/tests/unit/_api_test.py b/src/python/grpcio_tests/tests/unit/_api_test.py
index a3351aab50..f6245be77d 100644
--- a/src/python/grpcio_tests/tests/unit/_api_test.py
+++ b/src/python/grpcio_tests/tests/unit/_api_test.py
@@ -26,23 +26,57 @@ class AllTest(unittest.TestCase):
def testAll(self):
expected_grpc_code_elements = (
- 'FutureTimeoutError', 'FutureCancelledError', 'Future',
- 'ChannelConnectivity', 'StatusCode', 'RpcError', 'RpcContext',
- 'Call', 'ChannelCredentials', 'CallCredentials',
- 'AuthMetadataContext', 'AuthMetadataPluginCallback',
- 'AuthMetadataPlugin', 'ServerCredentials',
- 'UnaryUnaryMultiCallable', 'UnaryStreamMultiCallable',
- 'StreamUnaryMultiCallable', 'StreamStreamMultiCallable', 'Channel',
- 'ServicerContext', 'RpcMethodHandler', 'HandlerCallDetails',
- 'GenericRpcHandler', 'ServiceRpcHandler', 'Server',
- 'unary_unary_rpc_method_handler', 'unary_stream_rpc_method_handler',
+ 'FutureTimeoutError',
+ 'FutureCancelledError',
+ 'Future',
+ 'ChannelConnectivity',
+ 'StatusCode',
+ 'RpcError',
+ 'RpcContext',
+ 'Call',
+ 'ChannelCredentials',
+ 'CallCredentials',
+ 'AuthMetadataContext',
+ 'AuthMetadataPluginCallback',
+ 'AuthMetadataPlugin',
+ 'ServerCertificateConfiguration',
+ 'ServerCredentials',
+ 'UnaryUnaryMultiCallable',
+ 'UnaryStreamMultiCallable',
+ 'StreamUnaryMultiCallable',
+ 'StreamStreamMultiCallable',
+ 'UnaryUnaryClientInterceptor',
+ 'UnaryStreamClientInterceptor',
+ 'StreamUnaryClientInterceptor',
+ 'StreamStreamClientInterceptor',
+ 'Channel',
+ 'ServicerContext',
+ 'RpcMethodHandler',
+ 'HandlerCallDetails',
+ 'GenericRpcHandler',
+ 'ServiceRpcHandler',
+ 'Server',
+ 'ServerInterceptor',
+ 'unary_unary_rpc_method_handler',
+ 'unary_stream_rpc_method_handler',
'stream_unary_rpc_method_handler',
+ 'ClientCallDetails',
'stream_stream_rpc_method_handler',
- 'method_handlers_generic_handler', 'ssl_channel_credentials',
- 'metadata_call_credentials', 'access_token_call_credentials',
- 'composite_call_credentials', 'composite_channel_credentials',
- 'ssl_server_credentials', 'channel_ready_future',
- 'insecure_channel', 'secure_channel', 'server',)
+ 'method_handlers_generic_handler',
+ 'ssl_channel_credentials',
+ 'metadata_call_credentials',
+ 'access_token_call_credentials',
+ 'composite_call_credentials',
+ 'composite_channel_credentials',
+ 'ssl_server_credentials',
+ 'ssl_server_certificate_configuration',
+ 'dynamic_ssl_server_credentials',
+ 'channel_ready_future',
+ 'insecure_channel',
+ 'secure_channel',
+ 'intercept_channel',
+ 'server',
+ )
six.assertCountEqual(self, expected_grpc_code_elements,
_from_grpc_import_star.GRPC_ELEMENTS)
@@ -51,12 +85,13 @@ class AllTest(unittest.TestCase):
class ChannelConnectivityTest(unittest.TestCase):
def testChannelConnectivity(self):
- self.assertSequenceEqual(
- (grpc.ChannelConnectivity.IDLE, grpc.ChannelConnectivity.CONNECTING,
- grpc.ChannelConnectivity.READY,
- grpc.ChannelConnectivity.TRANSIENT_FAILURE,
- grpc.ChannelConnectivity.SHUTDOWN,),
- tuple(grpc.ChannelConnectivity))
+ self.assertSequenceEqual((
+ grpc.ChannelConnectivity.IDLE,
+ grpc.ChannelConnectivity.CONNECTING,
+ grpc.ChannelConnectivity.READY,
+ grpc.ChannelConnectivity.TRANSIENT_FAILURE,
+ grpc.ChannelConnectivity.SHUTDOWN,
+ ), tuple(grpc.ChannelConnectivity))
class ChannelTest(unittest.TestCase):
diff --git a/src/python/grpcio_tests/tests/unit/_auth_context_test.py b/src/python/grpcio_tests/tests/unit/_auth_context_test.py
index c6a0a23549..468869a03e 100644
--- a/src/python/grpcio_tests/tests/unit/_auth_context_test.py
+++ b/src/python/grpcio_tests/tests/unit/_auth_context_test.py
@@ -18,11 +18,9 @@ import unittest
import grpc
from grpc import _channel
-from grpc.framework.foundation import logging_pool
import six
from tests.unit import test_common
-from tests.unit.framework.common import test_constants
from tests.unit import resources
_REQUEST = b'\x00\x00\x00'
@@ -31,8 +29,12 @@ _RESPONSE = b'\x00\x00\x00'
_UNARY_UNARY = '/test/UnaryUnary'
_SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
-_CLIENT_IDS = (b'*.test.google.fr', b'waterzooi.test.google.be',
- b'*.test.youtube.com', b'192.168.1.3',)
+_CLIENT_IDS = (
+ b'*.test.google.fr',
+ b'waterzooi.test.google.be',
+ b'*.test.youtube.com',
+ b'192.168.1.3',
+)
_ID = 'id'
_ID_KEY = 'id_key'
_AUTH_CTX = 'auth_ctx'
@@ -41,7 +43,10 @@ _PRIVATE_KEY = resources.private_key()
_CERTIFICATE_CHAIN = resources.certificate_chain()
_TEST_ROOT_CERTIFICATES = resources.test_root_certificates()
_SERVER_CERTS = ((_PRIVATE_KEY, _CERTIFICATE_CHAIN),)
-_PROPERTY_OPTIONS = (('grpc.ssl_target_name_override', _SERVER_HOST_OVERRIDE,),)
+_PROPERTY_OPTIONS = ((
+ 'grpc.ssl_target_name_override',
+ _SERVER_HOST_OVERRIDE,
+),)
def handle_unary_unary(request, servicer_context):
@@ -55,12 +60,12 @@ def handle_unary_unary(request, servicer_context):
class AuthContextTest(unittest.TestCase):
def testInsecure(self):
- server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
handler = grpc.method_handlers_generic_handler('test', {
'UnaryUnary':
grpc.unary_unary_rpc_method_handler(handle_unary_unary)
})
- server = grpc.server(server_pool, (handler,))
+ server = test_common.test_server()
+ server.add_generic_rpc_handlers((handler,))
port = server.add_insecure_port('[::]:0')
server.start()
@@ -74,12 +79,12 @@ class AuthContextTest(unittest.TestCase):
self.assertDictEqual({}, auth_data[_AUTH_CTX])
def testSecureNoCert(self):
- server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
handler = grpc.method_handlers_generic_handler('test', {
'UnaryUnary':
grpc.unary_unary_rpc_method_handler(handle_unary_unary)
})
- server = grpc.server(server_pool, (handler,))
+ server = test_common.test_server()
+ server.add_generic_rpc_handlers((handler,))
server_cred = grpc.ssl_server_credentials(_SERVER_CERTS)
port = server.add_secure_port('[::]:0', server_cred)
server.start()
@@ -101,12 +106,12 @@ class AuthContextTest(unittest.TestCase):
}, auth_data[_AUTH_CTX])
def testSecureClientCert(self):
- server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
handler = grpc.method_handlers_generic_handler('test', {
'UnaryUnary':
grpc.unary_unary_rpc_method_handler(handle_unary_unary)
})
- server = grpc.server(server_pool, (handler,))
+ server = test_common.test_server()
+ server.add_generic_rpc_handlers((handler,))
server_cred = grpc.ssl_server_credentials(
_SERVER_CERTS,
root_certificates=_TEST_ROOT_CERTIFICATES,
diff --git a/src/python/grpcio_tests/tests/unit/_auth_test.py b/src/python/grpcio_tests/tests/unit/_auth_test.py
index f61951b80a..e2cb938936 100644
--- a/src/python/grpcio_tests/tests/unit/_auth_test.py
+++ b/src/python/grpcio_tests/tests/unit/_auth_test.py
@@ -61,7 +61,7 @@ class GoogleCallCredentialsTest(unittest.TestCase):
self.assertTrue(callback_event.wait(1.0))
-class AccessTokenCallCredentialsTest(unittest.TestCase):
+class AccessTokenAuthMetadataPluginTest(unittest.TestCase):
def test_google_call_credentials_success(self):
callback_event = threading.Event()
@@ -71,8 +71,8 @@ class AccessTokenCallCredentialsTest(unittest.TestCase):
self.assertIsNone(error)
callback_event.set()
- call_creds = _auth.AccessTokenCallCredentials('token')
- call_creds(None, mock_callback)
+ metadata_plugin = _auth.AccessTokenAuthMetadataPlugin('token')
+ metadata_plugin(None, mock_callback)
self.assertTrue(callback_event.wait(1.0))
diff --git a/src/python/grpcio_tests/tests/unit/_channel_args_test.py b/src/python/grpcio_tests/tests/unit/_channel_args_test.py
index 0a6b512866..1a2d2c0117 100644
--- a/src/python/grpcio_tests/tests/unit/_channel_args_test.py
+++ b/src/python/grpcio_tests/tests/unit/_channel_args_test.py
@@ -24,8 +24,13 @@ class TestPointerWrapper(object):
return 123456
-TEST_CHANNEL_ARGS = (('arg1', b'bytes_val'), ('arg2', 'str_val'), ('arg3', 1),
- (b'arg4', 'str_val'), ('arg6', TestPointerWrapper()),)
+TEST_CHANNEL_ARGS = (
+ ('arg1', b'bytes_val'),
+ ('arg2', 'str_val'),
+ ('arg3', 1),
+ (b'arg4', 'str_val'),
+ ('arg6', TestPointerWrapper()),
+)
class ChannelArgsTest(unittest.TestCase):
diff --git a/src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py b/src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py
index f8c61270ca..f9eb0011dc 100644
--- a/src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py
+++ b/src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py
@@ -83,7 +83,7 @@ class ChannelConnectivityTest(unittest.TestCase):
def test_immediately_connectable_channel_connectivity(self):
thread_pool = _thread_pool.RecordingThreadPool(max_workers=None)
- server = grpc.server(thread_pool)
+ server = grpc.server(thread_pool, options=(('grpc.so_reuseport', 0),))
port = server.add_insecure_port('[::]:0')
server.start()
first_callback = _Callback()
@@ -125,7 +125,7 @@ class ChannelConnectivityTest(unittest.TestCase):
def test_reachable_then_unreachable_channel_connectivity(self):
thread_pool = _thread_pool.RecordingThreadPool(max_workers=None)
- server = grpc.server(thread_pool)
+ server = grpc.server(thread_pool, options=(('grpc.so_reuseport', 0),))
port = server.add_insecure_port('[::]:0')
server.start()
callback = _Callback()
diff --git a/src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py b/src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py
index bdd2d86169..30b486079c 100644
--- a/src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py
+++ b/src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py
@@ -61,7 +61,7 @@ class ChannelReadyFutureTest(unittest.TestCase):
def test_immediately_connectable_channel_connectivity(self):
thread_pool = _thread_pool.RecordingThreadPool(max_workers=None)
- server = grpc.server(thread_pool)
+ server = grpc.server(thread_pool, options=(('grpc.so_reuseport', 0),))
port = server.add_insecure_port('[::]:0')
server.start()
channel = grpc.insecure_channel('localhost:{}'.format(port))
diff --git a/src/python/grpcio_tests/tests/unit/_compression_test.py b/src/python/grpcio_tests/tests/unit/_compression_test.py
index e576a5aca9..7550cd39ba 100644
--- a/src/python/grpcio_tests/tests/unit/_compression_test.py
+++ b/src/python/grpcio_tests/tests/unit/_compression_test.py
@@ -17,7 +17,6 @@ import unittest
import grpc
from grpc import _grpcio_metadata
-from grpc.framework.foundation import logging_pool
from tests.unit import test_common
from tests.unit.framework.common import test_constants
@@ -27,16 +26,16 @@ _STREAM_STREAM = '/test/StreamStream'
def handle_unary(request, servicer_context):
- servicer_context.send_initial_metadata(
- [('grpc-internal-encoding-request', 'gzip')])
+ servicer_context.send_initial_metadata([('grpc-internal-encoding-request',
+ 'gzip')])
return request
def handle_stream(request_iterator, servicer_context):
# TODO(issue:#6891) We should be able to remove this loop,
# and replace with return; yield
- servicer_context.send_initial_metadata(
- [('grpc-internal-encoding-request', 'gzip')])
+ servicer_context.send_initial_metadata([('grpc-internal-encoding-request',
+ 'gzip')])
for request in request_iterator:
yield request
@@ -72,9 +71,8 @@ class _GenericHandler(grpc.GenericRpcHandler):
class CompressionTest(unittest.TestCase):
def setUp(self):
- self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(
- self._server_pool, handlers=(_GenericHandler(),))
+ self._server = test_common.test_server()
+ self._server.add_generic_rpc_handlers((_GenericHandler(),))
self._port = self._server.add_insecure_port('[::]:0')
self._server.start()
diff --git a/src/python/grpcio_tests/tests/unit/_credentials_test.py b/src/python/grpcio_tests/tests/unit/_credentials_test.py
index 097898b987..f487fe66a2 100644
--- a/src/python/grpcio_tests/tests/unit/_credentials_test.py
+++ b/src/python/grpcio_tests/tests/unit/_credentials_test.py
@@ -26,8 +26,8 @@ class CredentialsTest(unittest.TestCase):
third = grpc.access_token_call_credentials('ghi')
first_and_second = grpc.composite_call_credentials(first, second)
- first_second_and_third = grpc.composite_call_credentials(first, second,
- third)
+ first_second_and_third = grpc.composite_call_credentials(
+ first, second, third)
self.assertIsInstance(first_and_second, grpc.CallCredentials)
self.assertIsInstance(first_second_and_third, grpc.CallCredentials)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py b/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py
index 5b97b7b542..3765ce4fb0 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py
@@ -20,9 +20,8 @@ from grpc._cython import cygrpc
from grpc.framework.foundation import logging_pool
from tests.unit.framework.common import test_constants
-_INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))
_EMPTY_FLAGS = 0
-_EMPTY_METADATA = cygrpc.Metadata(())
+_EMPTY_METADATA = ()
_SERVER_SHUTDOWN_TAG = 'server_shutdown'
_REQUEST_CALL_TAG = 'request_call'
@@ -53,7 +52,7 @@ class _Handler(object):
self._state = state
self._lock = threading.Lock()
self._completion_queue = completion_queue
- self._call = rpc_event.operation_call
+ self._call = rpc_event.call
def __call__(self):
with self._state.condition:
@@ -65,12 +64,10 @@ class _Handler(object):
with self._lock:
self._call.start_server_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),)),
+ (cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),),
_RECEIVE_CLOSE_ON_SERVER_TAG)
self._call.start_server_batch(
- cygrpc.Operations(
- (cygrpc.operation_receive_message(_EMPTY_FLAGS),)),
+ (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),),
_RECEIVE_MESSAGE_TAG)
first_event = self._completion_queue.poll()
if _is_cancellation_event(first_event):
@@ -78,14 +75,15 @@ class _Handler(object):
else:
with self._lock:
operations = (
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_send_message(b'\x79\x57', _EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'\x79\x57', _EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
_EMPTY_METADATA, cygrpc.StatusCode.ok, b'test details!',
- _EMPTY_FLAGS),)
- self._call.start_server_batch(
- cygrpc.Operations(operations), _SERVER_COMPLETE_CALL_TAG)
+ _EMPTY_FLAGS),
+ )
+ self._call.start_server_batch(operations,
+ _SERVER_COMPLETE_CALL_TAG)
self._completion_queue.poll()
self._completion_queue.poll()
@@ -143,17 +141,25 @@ class CancelManyCallsTest(unittest.TestCase):
test_constants.THREAD_CONCURRENCY)
server_completion_queue = cygrpc.CompletionQueue()
- server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ server = cygrpc.Server([
+ (
+ b'grpc.so_reuseport',
+ 0,
+ ),
+ ])
server.register_completion_queue(server_completion_queue)
port = server.add_http2_port(b'[::]:0')
server.start()
- channel = cygrpc.Channel('localhost:{}'.format(port).encode(),
- cygrpc.ChannelArgs([]))
+ channel = cygrpc.Channel('localhost:{}'.format(port).encode(), None)
state = _State()
- server_thread_args = (state, server, server_completion_queue,
- server_thread_pool,)
+ server_thread_args = (
+ state,
+ server,
+ server_completion_queue,
+ server_thread_pool,
+ )
server_thread = threading.Thread(target=_serve, args=server_thread_args)
server_thread.start()
@@ -167,20 +173,20 @@ class CancelManyCallsTest(unittest.TestCase):
with client_condition:
client_calls = []
for index in range(test_constants.RPC_CONCURRENCY):
- client_call = channel.create_call(
- None, _EMPTY_FLAGS, client_completion_queue, b'/twinkies',
- None, _INFINITE_FUTURE)
+ client_call = channel.create_call(None, _EMPTY_FLAGS,
+ client_completion_queue,
+ b'/twinkies', None, None)
operations = (
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_send_message(b'\x45\x56', _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),)
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'\x45\x56', _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ )
tag = 'client_complete_call_{0:04d}_tag'.format(index)
- client_call.start_client_batch(
- cygrpc.Operations(operations), tag)
+ client_call.start_client_batch(operations, tag)
client_due.add(tag)
client_calls.append(client_call)
@@ -195,8 +201,8 @@ class CancelManyCallsTest(unittest.TestCase):
state.condition.notify_all()
break
- client_driver.events(test_constants.RPC_CONCURRENCY *
- _SUCCESS_CALL_FRACTION)
+ client_driver.events(
+ test_constants.RPC_CONCURRENCY * _SUCCESS_CALL_FRACTION)
with client_condition:
for client_call in client_calls:
client_call.cancel()
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py b/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py
index 1d57ea7ec1..7305d0fa3f 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_channel_test.py
@@ -22,7 +22,7 @@ from tests.unit.framework.common import test_constants
def _channel_and_completion_queue():
- channel = cygrpc.Channel(b'localhost:54321', cygrpc.ChannelArgs(()))
+ channel = cygrpc.Channel(b'localhost:54321', ())
completion_queue = cygrpc.CompletionQueue()
return channel, completion_queue
@@ -31,9 +31,9 @@ def _connectivity_loop(channel, completion_queue):
for _ in range(100):
connectivity = channel.check_connectivity_state(True)
channel.watch_connectivity_state(connectivity,
- cygrpc.Timespec(time.time() + 0.2),
- completion_queue, None)
- completion_queue.poll(deadline=cygrpc.Timespec(float('+inf')))
+ time.time() + 0.2, completion_queue,
+ None)
+ completion_queue.poll()
def _create_loop_destroy():
@@ -56,7 +56,10 @@ class ChannelTest(unittest.TestCase):
def test_single_channel_lonely_connectivity(self):
channel, completion_queue = _channel_and_completion_queue()
- _in_parallel(_connectivity_loop, (channel, completion_queue,))
+ _in_parallel(_connectivity_loop, (
+ channel,
+ completion_queue,
+ ))
completion_queue.shutdown()
def test_multiple_channels_lonely_connectivity(self):
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_common.py b/src/python/grpcio_tests/tests/unit/_cython/_common.py
index ac66d1db3d..7fd3d19b4e 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_common.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_common.py
@@ -20,20 +20,22 @@ from grpc._cython import cygrpc
RPC_COUNT = 4000
-INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))
EMPTY_FLAGS = 0
-INVOCATION_METADATA = cygrpc.Metadata(
- (cygrpc.Metadatum(b'client-md-key', b'client-md-key'),
- cygrpc.Metadatum(b'client-md-key-bin', b'\x00\x01' * 3000),))
+INVOCATION_METADATA = (
+ ('client-md-key', 'client-md-key'),
+ ('client-md-key-bin', b'\x00\x01' * 3000),
+)
-INITIAL_METADATA = cygrpc.Metadata(
- (cygrpc.Metadatum(b'server-initial-md-key', b'server-initial-md-value'),
- cygrpc.Metadatum(b'server-initial-md-key-bin', b'\x00\x02' * 3000),))
+INITIAL_METADATA = (
+ ('server-initial-md-key', 'server-initial-md-value'),
+ ('server-initial-md-key-bin', b'\x00\x02' * 3000),
+)
-TRAILING_METADATA = cygrpc.Metadata(
- (cygrpc.Metadatum(b'server-trailing-md-key', b'server-trailing-md-value'),
- cygrpc.Metadatum(b'server-trailing-md-key-bin', b'\x00\x03' * 3000),))
+TRAILING_METADATA = (
+ ('server-trailing-md-key', 'server-trailing-md-value'),
+ ('server-trailing-md-key-bin', b'\x00\x03' * 3000),
+)
class QueueDriver(object):
@@ -79,7 +81,10 @@ def execute_many_times(behavior):
class OperationResult(
collections.namedtuple('OperationResult', (
- 'start_batch_result', 'completion_type', 'success',))):
+ 'start_batch_result',
+ 'completion_type',
+ 'success',
+ ))):
pass
@@ -91,12 +96,11 @@ class RpcTest(object):
def setUp(self):
self.server_completion_queue = cygrpc.CompletionQueue()
- self.server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ self.server = cygrpc.Server([(b'grpc.so_reuseport', 0)])
self.server.register_completion_queue(self.server_completion_queue)
port = self.server.add_http2_port(b'[::]:0')
self.server.start()
- self.channel = cygrpc.Channel('localhost:{}'.format(port).encode(),
- cygrpc.ChannelArgs([]))
+ self.channel = cygrpc.Channel('localhost:{}'.format(port).encode(), [])
self._server_shutdown_tag = 'server_shutdown_tag'
self.server_condition = threading.Condition()
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py
index 14cc66675c..7caa98f72d 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py
@@ -41,27 +41,27 @@ class Test(_common.RpcTest, unittest.TestCase):
server_request_call_tag,
})
- client_call = self.channel.create_call(
- None, _common.EMPTY_FLAGS, self.client_completion_queue,
- b'/twinkies', None, _common.INFINITE_FUTURE)
+ client_call = self.channel.create_call(None, _common.EMPTY_FLAGS,
+ self.client_completion_queue,
+ b'/twinkies', None, None)
client_receive_initial_metadata_tag = 'client_receive_initial_metadata_tag'
client_complete_rpc_tag = 'client_complete_rpc_tag'
with self.client_condition:
client_receive_initial_metadata_start_batch_result = (
- client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_receive_initial_metadata(
- _common.EMPTY_FLAGS),
- ]), client_receive_initial_metadata_tag))
+ client_call.start_client_batch([
+ cygrpc.ReceiveInitialMetadataOperation(_common.EMPTY_FLAGS),
+ ], client_receive_initial_metadata_tag))
+ self.assertEqual(cygrpc.CallError.ok,
+ client_receive_initial_metadata_start_batch_result)
client_complete_rpc_start_batch_result = client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_send_initial_metadata(
+ [
+ cygrpc.SendInitialMetadataOperation(
_common.INVOCATION_METADATA, _common.EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(
- _common.EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(
- _common.EMPTY_FLAGS),
- ]), client_complete_rpc_tag)
+ cygrpc.SendCloseFromClientOperation(_common.EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_common.EMPTY_FLAGS),
+ ], client_complete_rpc_tag)
+ self.assertEqual(cygrpc.CallError.ok,
+ client_complete_rpc_start_batch_result)
self.client_driver.add_due({
client_receive_initial_metadata_tag,
client_complete_rpc_tag,
@@ -72,8 +72,8 @@ class Test(_common.RpcTest, unittest.TestCase):
with server_call_condition:
server_send_initial_metadata_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.SendInitialMetadataOperation(
_common.INITIAL_METADATA, _common.EMPTY_FLAGS),
], server_send_initial_metadata_tag))
server_call_driver.add_due({
@@ -84,10 +84,9 @@ class Test(_common.RpcTest, unittest.TestCase):
with server_call_condition:
server_complete_rpc_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_receive_close_on_server(
- _common.EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.ReceiveCloseOnServerOperation(_common.EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
_common.TRAILING_METADATA, cygrpc.StatusCode.ok,
b'test details', _common.EMPTY_FLAGS),
], server_complete_rpc_tag))
@@ -102,27 +101,29 @@ class Test(_common.RpcTest, unittest.TestCase):
client_complete_rpc_event = self.client_driver.event_with_tag(
client_complete_rpc_tag)
- return (_common.OperationResult(server_request_call_start_batch_result,
- server_request_call_event.type,
- server_request_call_event.success),
- _common.OperationResult(
- client_receive_initial_metadata_start_batch_result,
- client_receive_initial_metadata_event.type,
- client_receive_initial_metadata_event.success),
- _common.OperationResult(client_complete_rpc_start_batch_result,
- client_complete_rpc_event.type,
- client_complete_rpc_event.success),
- _common.OperationResult(
- server_send_initial_metadata_start_batch_result,
- server_send_initial_metadata_event.type,
- server_send_initial_metadata_event.success),
- _common.OperationResult(server_complete_rpc_start_batch_result,
- server_complete_rpc_event.type,
- server_complete_rpc_event.success),)
+ return (
+ _common.OperationResult(server_request_call_start_batch_result,
+ server_request_call_event.completion_type,
+ server_request_call_event.success),
+ _common.OperationResult(
+ client_receive_initial_metadata_start_batch_result,
+ client_receive_initial_metadata_event.completion_type,
+ client_receive_initial_metadata_event.success),
+ _common.OperationResult(client_complete_rpc_start_batch_result,
+ client_complete_rpc_event.completion_type,
+ client_complete_rpc_event.success),
+ _common.OperationResult(
+ server_send_initial_metadata_start_batch_result,
+ server_send_initial_metadata_event.completion_type,
+ server_send_initial_metadata_event.success),
+ _common.OperationResult(server_complete_rpc_start_batch_result,
+ server_complete_rpc_event.completion_type,
+ server_complete_rpc_event.success),
+ )
def test_rpcs(self):
- expecteds = [(_common.SUCCESSFUL_OPERATION_RESULT,) *
- 5] * _common.RPC_COUNT
+ expecteds = [(
+ _common.SUCCESSFUL_OPERATION_RESULT,) * 5] * _common.RPC_COUNT
actuallys = _common.execute_many_times(self._do_rpcs)
self.assertSequenceEqual(expecteds, actuallys)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py
index 1e44bcc4dc..8582a39c01 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py
@@ -36,27 +36,23 @@ class Test(_common.RpcTest, unittest.TestCase):
server_request_call_tag,
})
- client_call = self.channel.create_call(
- None, _common.EMPTY_FLAGS, self.client_completion_queue,
- b'/twinkies', None, _common.INFINITE_FUTURE)
+ client_call = self.channel.create_call(None, _common.EMPTY_FLAGS,
+ self.client_completion_queue,
+ b'/twinkies', None, None)
client_receive_initial_metadata_tag = 'client_receive_initial_metadata_tag'
client_complete_rpc_tag = 'client_complete_rpc_tag'
with self.client_condition:
client_receive_initial_metadata_start_batch_result = (
- client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_receive_initial_metadata(
- _common.EMPTY_FLAGS),
- ]), client_receive_initial_metadata_tag))
+ client_call.start_client_batch([
+ cygrpc.ReceiveInitialMetadataOperation(_common.EMPTY_FLAGS),
+ ], client_receive_initial_metadata_tag))
client_complete_rpc_start_batch_result = client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_send_initial_metadata(
+ [
+ cygrpc.SendInitialMetadataOperation(
_common.INVOCATION_METADATA, _common.EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(
- _common.EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(
- _common.EMPTY_FLAGS),
- ]), client_complete_rpc_tag)
+ cygrpc.SendCloseFromClientOperation(_common.EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_common.EMPTY_FLAGS),
+ ], client_complete_rpc_tag)
self.client_driver.add_due({
client_receive_initial_metadata_tag,
client_complete_rpc_tag,
@@ -67,8 +63,8 @@ class Test(_common.RpcTest, unittest.TestCase):
with self.server_condition:
server_send_initial_metadata_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.SendInitialMetadataOperation(
_common.INITIAL_METADATA, _common.EMPTY_FLAGS),
], server_send_initial_metadata_tag))
self.server_driver.add_due({
@@ -79,12 +75,11 @@ class Test(_common.RpcTest, unittest.TestCase):
with self.server_condition:
server_complete_rpc_start_batch_result = (
- server_request_call_event.operation_call.start_server_batch([
- cygrpc.operation_receive_close_on_server(
- _common.EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ server_request_call_event.call.start_server_batch([
+ cygrpc.ReceiveCloseOnServerOperation(_common.EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
_common.TRAILING_METADATA, cygrpc.StatusCode.ok,
- b'test details', _common.EMPTY_FLAGS),
+ 'test details', _common.EMPTY_FLAGS),
], server_complete_rpc_tag))
self.server_driver.add_due({
server_complete_rpc_tag,
@@ -97,27 +92,29 @@ class Test(_common.RpcTest, unittest.TestCase):
client_complete_rpc_event = self.client_driver.event_with_tag(
client_complete_rpc_tag)
- return (_common.OperationResult(server_request_call_start_batch_result,
- server_request_call_event.type,
- server_request_call_event.success),
- _common.OperationResult(
- client_receive_initial_metadata_start_batch_result,
- client_receive_initial_metadata_event.type,
- client_receive_initial_metadata_event.success),
- _common.OperationResult(client_complete_rpc_start_batch_result,
- client_complete_rpc_event.type,
- client_complete_rpc_event.success),
- _common.OperationResult(
- server_send_initial_metadata_start_batch_result,
- server_send_initial_metadata_event.type,
- server_send_initial_metadata_event.success),
- _common.OperationResult(server_complete_rpc_start_batch_result,
- server_complete_rpc_event.type,
- server_complete_rpc_event.success),)
+ return (
+ _common.OperationResult(server_request_call_start_batch_result,
+ server_request_call_event.completion_type,
+ server_request_call_event.success),
+ _common.OperationResult(
+ client_receive_initial_metadata_start_batch_result,
+ client_receive_initial_metadata_event.completion_type,
+ client_receive_initial_metadata_event.success),
+ _common.OperationResult(client_complete_rpc_start_batch_result,
+ client_complete_rpc_event.completion_type,
+ client_complete_rpc_event.success),
+ _common.OperationResult(
+ server_send_initial_metadata_start_batch_result,
+ server_send_initial_metadata_event.completion_type,
+ server_send_initial_metadata_event.success),
+ _common.OperationResult(server_complete_rpc_start_batch_result,
+ server_complete_rpc_event.completion_type,
+ server_complete_rpc_event.success),
+ )
def test_rpcs(self):
- expecteds = [(_common.SUCCESSFUL_OPERATION_RESULT,) *
- 5] * _common.RPC_COUNT
+ expecteds = [(
+ _common.SUCCESSFUL_OPERATION_RESULT,) * 5] * _common.RPC_COUNT
actuallys = _common.execute_many_times(self._do_rpcs)
self.assertSequenceEqual(expecteds, actuallys)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py b/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py
index 0105612b47..bc63b54879 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py
@@ -18,9 +18,8 @@ import unittest
from grpc._cython import cygrpc
-_INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))
_EMPTY_FLAGS = 0
-_EMPTY_METADATA = cygrpc.Metadata(())
+_EMPTY_METADATA = ()
class _ServerDriver(object):
@@ -112,12 +111,14 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
def testReadSomeButNotAllResponses(self):
server_completion_queue = cygrpc.CompletionQueue()
- server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ server = cygrpc.Server([(
+ b'grpc.so_reuseport',
+ 0,
+ )])
server.register_completion_queue(server_completion_queue)
port = server.add_http2_port(b'[::]:0')
server.start()
- channel = cygrpc.Channel('localhost:{}'.format(port).encode(),
- cygrpc.ChannelArgs([]))
+ channel = cygrpc.Channel('localhost:{}'.format(port).encode(), set())
server_shutdown_tag = 'server_shutdown_tag'
server_driver = _ServerDriver(server_completion_queue,
@@ -136,9 +137,12 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
server_send_first_message_tag = 'server_send_first_message_tag'
server_send_second_message_tag = 'server_send_second_message_tag'
server_complete_rpc_tag = 'server_complete_rpc_tag'
- server_call_due = set(
- (server_send_initial_metadata_tag, server_send_first_message_tag,
- server_send_second_message_tag, server_complete_rpc_tag,))
+ server_call_due = set((
+ server_send_initial_metadata_tag,
+ server_send_first_message_tag,
+ server_send_second_message_tag,
+ server_complete_rpc_tag,
+ ))
server_call_completion_queue = cygrpc.CompletionQueue()
server_call_driver = _QueueDriver(server_call_condition,
server_call_completion_queue,
@@ -152,37 +156,35 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
client_call = channel.create_call(None, _EMPTY_FLAGS,
client_completion_queue, b'/twinkies',
- None, _INFINITE_FUTURE)
+ None, None)
client_receive_initial_metadata_tag = 'client_receive_initial_metadata_tag'
client_complete_rpc_tag = 'client_complete_rpc_tag'
with client_condition:
client_receive_initial_metadata_start_batch_result = (
- client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- ]), client_receive_initial_metadata_tag))
+ client_call.start_client_batch([
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
+ ], client_receive_initial_metadata_tag))
client_due.add(client_receive_initial_metadata_tag)
client_complete_rpc_start_batch_result = (
- client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),
- ]), client_complete_rpc_tag))
+ client_call.start_client_batch([
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
+ ], client_complete_rpc_tag))
client_due.add(client_complete_rpc_tag)
server_rpc_event = server_driver.first_event()
with server_call_condition:
server_send_initial_metadata_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(_EMPTY_METADATA,
- _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.SendInitialMetadataOperation(_EMPTY_METADATA,
+ _EMPTY_FLAGS),
], server_send_initial_metadata_tag))
server_send_first_message_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_send_message(b'\x07', _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.SendMessageOperation(b'\x07', _EMPTY_FLAGS),
], server_send_first_message_tag))
server_send_initial_metadata_event = server_call_driver.event_with_tag(
server_send_initial_metadata_tag)
@@ -190,15 +192,15 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
server_send_first_message_tag)
with server_call_condition:
server_send_second_message_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_send_message(b'\x07', _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.SendMessageOperation(b'\x07', _EMPTY_FLAGS),
], server_send_second_message_tag))
server_complete_rpc_start_batch_result = (
- server_rpc_event.operation_call.start_server_batch([
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
- cygrpc.Metadata(()), cygrpc.StatusCode.ok,
- b'test details', _EMPTY_FLAGS),
+ server_rpc_event.call.start_server_batch([
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
+ (), cygrpc.StatusCode.ok, b'test details',
+ _EMPTY_FLAGS),
], server_complete_rpc_tag))
server_send_second_message_event = server_call_driver.event_with_tag(
server_send_second_message_tag)
@@ -209,10 +211,9 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
with client_condition:
client_receive_first_message_tag = 'client_receive_first_message_tag'
client_receive_first_message_start_batch_result = (
- client_call.start_client_batch(
- cygrpc.Operations([
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- ]), client_receive_first_message_tag))
+ client_call.start_client_batch([
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ ], client_receive_first_message_tag))
client_due.add(client_receive_first_message_tag)
client_receive_first_message_event = client_driver.event_with_tag(
client_receive_first_message_tag)
@@ -234,9 +235,8 @@ class ReadSomeButNotAllResponsesTest(unittest.TestCase):
self.assertEqual(cygrpc.CallError.ok, client_call_cancel_result)
self.assertIs(server_rpc_tag, server_rpc_event.tag)
self.assertEqual(cygrpc.CompletionType.operation_complete,
- server_rpc_event.type)
- self.assertIsInstance(server_rpc_event.operation_call, cygrpc.Call)
- self.assertEqual(0, len(server_rpc_event.batch_operations))
+ server_rpc_event.completion_type)
+ self.assertIsInstance(server_rpc_event.call, cygrpc.Call)
if __name__ == '__main__':
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_server_test.py b/src/python/grpcio_tests/tests/unit/_cython/_server_test.py
new file mode 100644
index 0000000000..bbd25457b3
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/_cython/_server_test.py
@@ -0,0 +1,49 @@
+# 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.
+"""Test servers at the level of the Cython API."""
+
+import threading
+import time
+import unittest
+
+from grpc._cython import cygrpc
+
+
+class Test(unittest.TestCase):
+
+ def test_lonely_server(self):
+ server_call_completion_queue = cygrpc.CompletionQueue()
+ server_shutdown_completion_queue = cygrpc.CompletionQueue()
+ server = cygrpc.Server(None)
+ server.register_completion_queue(server_call_completion_queue)
+ server.register_completion_queue(server_shutdown_completion_queue)
+ port = server.add_http2_port(b'[::]:0')
+ server.start()
+
+ server_request_call_tag = 'server_request_call_tag'
+ server_request_call_start_batch_result = server.request_call(
+ server_call_completion_queue, server_call_completion_queue,
+ server_request_call_tag)
+
+ time.sleep(4)
+
+ server_shutdown_tag = 'server_shutdown_tag'
+ server_shutdown_result = server.shutdown(
+ server_shutdown_completion_queue, server_shutdown_tag)
+ server_request_call_event = server_call_completion_queue.poll()
+ server_shutdown_event = server_shutdown_completion_queue.poll()
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
index 18d4a6df64..9045ff58a0 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
@@ -28,97 +28,43 @@ _CALL_CREDENTIALS_METADATA_VALUE = 'call-creds-value'
_EMPTY_FLAGS = 0
-def _metadata_plugin_callback(context, callback):
- callback(
- cygrpc.Metadata([
- cygrpc.Metadatum(_CALL_CREDENTIALS_METADATA_KEY,
- _CALL_CREDENTIALS_METADATA_VALUE)
- ]), cygrpc.StatusCode.ok, b'')
+def _metadata_plugin(context, callback):
+ callback(((
+ _CALL_CREDENTIALS_METADATA_KEY,
+ _CALL_CREDENTIALS_METADATA_VALUE,
+ ),), cygrpc.StatusCode.ok, b'')
class TypeSmokeTest(unittest.TestCase):
- def testStringsInUtilitiesUpDown(self):
- self.assertEqual(0, cygrpc.StatusCode.ok)
- metadatum = cygrpc.Metadatum(b'a', b'b')
- self.assertEqual(b'a', metadatum.key)
- self.assertEqual(b'b', metadatum.value)
- metadata = cygrpc.Metadata([metadatum])
- self.assertEqual(1, len(metadata))
- self.assertEqual(metadatum.key, metadata[0].key)
-
- def testMetadataIteration(self):
- metadata = cygrpc.Metadata(
- [cygrpc.Metadatum(b'a', b'b'), cygrpc.Metadatum(b'c', b'd')])
- iterator = iter(metadata)
- metadatum = next(iterator)
- self.assertIsInstance(metadatum, cygrpc.Metadatum)
- self.assertEqual(metadatum.key, b'a')
- self.assertEqual(metadatum.value, b'b')
- metadatum = next(iterator)
- self.assertIsInstance(metadatum, cygrpc.Metadatum)
- self.assertEqual(metadatum.key, b'c')
- self.assertEqual(metadatum.value, b'd')
- with self.assertRaises(StopIteration):
- next(iterator)
-
- def testOperationsIteration(self):
- operations = cygrpc.Operations(
- [cygrpc.operation_send_message(b'asdf', _EMPTY_FLAGS)])
- iterator = iter(operations)
- operation = next(iterator)
- self.assertIsInstance(operation, cygrpc.Operation)
- # `Operation`s are write-only structures; can't directly debug anything out
- # of them. Just check that we stop iterating.
- with self.assertRaises(StopIteration):
- next(iterator)
-
- def testOperationFlags(self):
- operation = cygrpc.operation_send_message(b'asdf',
- cygrpc.WriteFlag.no_compress)
- self.assertEqual(cygrpc.WriteFlag.no_compress, operation.flags)
-
- def testTimespec(self):
- now = time.time()
- now_timespec_a = cygrpc.Timespec(now)
- now_timespec_b = cygrpc.Timespec(now)
- self.assertAlmostEqual(now, float(now_timespec_a), places=8)
- self.assertEqual(now_timespec_a, now_timespec_b)
- self.assertLess(cygrpc.Timespec(now - 1), cygrpc.Timespec(now))
- self.assertGreater(cygrpc.Timespec(now + 1), cygrpc.Timespec(now))
- self.assertGreaterEqual(cygrpc.Timespec(now + 1), cygrpc.Timespec(now))
- self.assertGreaterEqual(cygrpc.Timespec(now), cygrpc.Timespec(now))
- self.assertLessEqual(cygrpc.Timespec(now - 1), cygrpc.Timespec(now))
- self.assertLessEqual(cygrpc.Timespec(now), cygrpc.Timespec(now))
- self.assertNotEqual(cygrpc.Timespec(now - 1), cygrpc.Timespec(now))
- self.assertNotEqual(cygrpc.Timespec(now + 1), cygrpc.Timespec(now))
-
def testCompletionQueueUpDown(self):
completion_queue = cygrpc.CompletionQueue()
del completion_queue
def testServerUpDown(self):
- server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ server = cygrpc.Server(set([
+ (
+ b'grpc.so_reuseport',
+ 0,
+ ),
+ ]))
del server
def testChannelUpDown(self):
- channel = cygrpc.Channel(b'[::]:0', cygrpc.ChannelArgs([]))
+ channel = cygrpc.Channel(b'[::]:0', None)
del channel
- def testCredentialsMetadataPluginUpDown(self):
- plugin = cygrpc.CredentialsMetadataPlugin(
- lambda ignored_a, ignored_b: None, b'')
- del plugin
-
- def testCallCredentialsFromPluginUpDown(self):
- plugin = cygrpc.CredentialsMetadataPlugin(_metadata_plugin_callback,
- b'')
- call_credentials = cygrpc.call_credentials_metadata_plugin(plugin)
- del plugin
- del call_credentials
+ def test_metadata_plugin_call_credentials_up_down(self):
+ cygrpc.MetadataPluginCallCredentials(_metadata_plugin,
+ b'test plugin name!')
def testServerStartNoExplicitShutdown(self):
- server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ server = cygrpc.Server([
+ (
+ b'grpc.so_reuseport',
+ 0,
+ ),
+ ])
completion_queue = cygrpc.CompletionQueue()
server.register_completion_queue(completion_queue)
port = server.add_http2_port(b'[::]:0')
@@ -128,14 +74,20 @@ class TypeSmokeTest(unittest.TestCase):
def testServerStartShutdown(self):
completion_queue = cygrpc.CompletionQueue()
- server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ server = cygrpc.Server([
+ (
+ b'grpc.so_reuseport',
+ 0,
+ ),
+ ])
server.add_http2_port(b'[::]:0')
server.register_completion_queue(completion_queue)
server.start()
shutdown_tag = object()
server.shutdown(completion_queue, shutdown_tag)
event = completion_queue.poll()
- self.assertEqual(cygrpc.CompletionType.operation_complete, event.type)
+ self.assertEqual(cygrpc.CompletionType.operation_complete,
+ event.completion_type)
self.assertIs(shutdown_tag, event.tag)
del server
del completion_queue
@@ -145,7 +97,12 @@ class ServerClientMixin(object):
def setUpMixin(self, server_credentials, client_credentials, host_override):
self.server_completion_queue = cygrpc.CompletionQueue()
- self.server = cygrpc.Server(cygrpc.ChannelArgs([]))
+ self.server = cygrpc.Server([
+ (
+ b'grpc.so_reuseport',
+ 0,
+ ),
+ ])
self.server.register_completion_queue(self.server_completion_queue)
if server_credentials:
self.port = self.server.add_http2_port(b'[::]:0',
@@ -155,17 +112,16 @@ class ServerClientMixin(object):
self.server.start()
self.client_completion_queue = cygrpc.CompletionQueue()
if client_credentials:
- client_channel_arguments = cygrpc.ChannelArgs([
- cygrpc.ChannelArg(cygrpc.ChannelArgKey.ssl_target_name_override,
- host_override)
- ])
- self.client_channel = cygrpc.Channel(
- 'localhost:{}'.format(self.port).encode(),
- client_channel_arguments, client_credentials)
+ client_channel_arguments = ((
+ cygrpc.ChannelArgKey.ssl_target_name_override,
+ host_override,
+ ),)
+ self.client_channel = cygrpc.Channel('localhost:{}'.format(
+ self.port).encode(), client_channel_arguments,
+ client_credentials)
else:
- self.client_channel = cygrpc.Channel(
- 'localhost:{}'.format(self.port).encode(),
- cygrpc.ChannelArgs([]))
+ self.client_channel = cygrpc.Channel('localhost:{}'.format(
+ self.port).encode(), set())
if host_override:
self.host_argument = None # default host
self.expected_host = host_override
@@ -190,40 +146,37 @@ class ServerClientMixin(object):
def performer():
tag = object()
try:
- call_result = call.start_client_batch(
- cygrpc.Operations(operations), tag)
+ call_result = call.start_client_batch(operations, tag)
self.assertEqual(cygrpc.CallError.ok, call_result)
- event = queue.poll(deadline)
+ event = queue.poll(deadline=deadline)
self.assertEqual(cygrpc.CompletionType.operation_complete,
- event.type)
+ event.completion_type)
self.assertTrue(event.success)
self.assertIs(tag, event.tag)
except Exception as error:
- raise Exception(
- "Error in '{}': {}".format(description, error.message))
+ raise Exception("Error in '{}': {}".format(
+ description, error.message))
return event
return test_utilities.SimpleFuture(performer)
- def testEcho(self):
+ def test_echo(self):
DEADLINE = time.time() + 5
DEADLINE_TOLERANCE = 0.25
- CLIENT_METADATA_ASCII_KEY = b'key'
- CLIENT_METADATA_ASCII_VALUE = b'val'
- CLIENT_METADATA_BIN_KEY = b'key-bin'
+ CLIENT_METADATA_ASCII_KEY = 'key'
+ CLIENT_METADATA_ASCII_VALUE = 'val'
+ CLIENT_METADATA_BIN_KEY = 'key-bin'
CLIENT_METADATA_BIN_VALUE = b'\0' * 1000
- SERVER_INITIAL_METADATA_KEY = b'init_me_me_me'
- SERVER_INITIAL_METADATA_VALUE = b'whodawha?'
- SERVER_TRAILING_METADATA_KEY = b'california_is_in_a_drought'
- SERVER_TRAILING_METADATA_VALUE = b'zomg it is'
+ SERVER_INITIAL_METADATA_KEY = 'init_me_me_me'
+ SERVER_INITIAL_METADATA_VALUE = 'whodawha?'
+ SERVER_TRAILING_METADATA_KEY = 'california_is_in_a_drought'
+ SERVER_TRAILING_METADATA_VALUE = 'zomg it is'
SERVER_STATUS_CODE = cygrpc.StatusCode.ok
- SERVER_STATUS_DETAILS = b'our work is never over'
+ SERVER_STATUS_DETAILS = 'our work is never over'
REQUEST = b'in death a member of project mayhem has a name'
RESPONSE = b'his name is robert paulson'
METHOD = b'twinkies'
- cygrpc_deadline = cygrpc.Timespec(DEADLINE)
-
server_request_tag = object()
request_call_result = self.server.request_call(
self.server_completion_queue, self.server_completion_queue,
@@ -234,89 +187,91 @@ class ServerClientMixin(object):
client_call_tag = object()
client_call = self.client_channel.create_call(
None, 0, self.client_completion_queue, METHOD, self.host_argument,
- cygrpc_deadline)
- client_initial_metadata = cygrpc.Metadata([
- cygrpc.Metadatum(CLIENT_METADATA_ASCII_KEY,
- CLIENT_METADATA_ASCII_VALUE),
- cygrpc.Metadatum(CLIENT_METADATA_BIN_KEY, CLIENT_METADATA_BIN_VALUE)
- ])
+ DEADLINE)
+ client_initial_metadata = (
+ (
+ CLIENT_METADATA_ASCII_KEY,
+ CLIENT_METADATA_ASCII_VALUE,
+ ),
+ (
+ CLIENT_METADATA_BIN_KEY,
+ CLIENT_METADATA_BIN_VALUE,
+ ),
+ )
client_start_batch_result = client_call.start_client_batch([
- cygrpc.operation_send_initial_metadata(client_initial_metadata,
- _EMPTY_FLAGS),
- cygrpc.operation_send_message(REQUEST, _EMPTY_FLAGS),
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS)
+ cygrpc.SendInitialMetadataOperation(client_initial_metadata,
+ _EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(REQUEST, _EMPTY_FLAGS),
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS),
], client_call_tag)
self.assertEqual(cygrpc.CallError.ok, client_start_batch_result)
client_event_future = test_utilities.CompletionQueuePollFuture(
- self.client_completion_queue, cygrpc_deadline)
+ self.client_completion_queue, DEADLINE)
- request_event = self.server_completion_queue.poll(cygrpc_deadline)
+ request_event = self.server_completion_queue.poll(deadline=DEADLINE)
self.assertEqual(cygrpc.CompletionType.operation_complete,
- request_event.type)
- self.assertIsInstance(request_event.operation_call, cygrpc.Call)
+ request_event.completion_type)
+ self.assertIsInstance(request_event.call, cygrpc.Call)
self.assertIs(server_request_tag, request_event.tag)
- self.assertEqual(0, len(request_event.batch_operations))
self.assertTrue(
test_common.metadata_transmitted(client_initial_metadata,
- request_event.request_metadata))
- self.assertEqual(METHOD, request_event.request_call_details.method)
- self.assertEqual(self.expected_host,
- request_event.request_call_details.host)
+ request_event.invocation_metadata))
+ self.assertEqual(METHOD, request_event.call_details.method)
+ self.assertEqual(self.expected_host, request_event.call_details.host)
self.assertLess(
- abs(DEADLINE - float(request_event.request_call_details.deadline)),
+ abs(DEADLINE - request_event.call_details.deadline),
DEADLINE_TOLERANCE)
server_call_tag = object()
- server_call = request_event.operation_call
- server_initial_metadata = cygrpc.Metadata([
- cygrpc.Metadatum(SERVER_INITIAL_METADATA_KEY,
- SERVER_INITIAL_METADATA_VALUE)
- ])
- server_trailing_metadata = cygrpc.Metadata([
- cygrpc.Metadatum(SERVER_TRAILING_METADATA_KEY,
- SERVER_TRAILING_METADATA_VALUE)
- ])
+ server_call = request_event.call
+ server_initial_metadata = ((
+ SERVER_INITIAL_METADATA_KEY,
+ SERVER_INITIAL_METADATA_VALUE,
+ ),)
+ server_trailing_metadata = ((
+ SERVER_TRAILING_METADATA_KEY,
+ SERVER_TRAILING_METADATA_VALUE,
+ ),)
server_start_batch_result = server_call.start_server_batch([
- cygrpc.operation_send_initial_metadata(
- server_initial_metadata,
- _EMPTY_FLAGS), cygrpc.operation_receive_message(_EMPTY_FLAGS),
- cygrpc.operation_send_message(RESPONSE, _EMPTY_FLAGS),
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ cygrpc.SendInitialMetadataOperation(server_initial_metadata,
+ _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(RESPONSE, _EMPTY_FLAGS),
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
server_trailing_metadata, SERVER_STATUS_CODE,
SERVER_STATUS_DETAILS, _EMPTY_FLAGS)
], server_call_tag)
self.assertEqual(cygrpc.CallError.ok, server_start_batch_result)
- server_event = self.server_completion_queue.poll(cygrpc_deadline)
+ server_event = self.server_completion_queue.poll(deadline=DEADLINE)
client_event = client_event_future.result()
self.assertEqual(6, len(client_event.batch_operations))
found_client_op_types = set()
for client_result in client_event.batch_operations:
# we expect each op type to be unique
- self.assertNotIn(client_result.type, found_client_op_types)
- found_client_op_types.add(client_result.type)
- if client_result.type == cygrpc.OperationType.receive_initial_metadata:
+ self.assertNotIn(client_result.type(), found_client_op_types)
+ found_client_op_types.add(client_result.type())
+ if client_result.type(
+ ) == cygrpc.OperationType.receive_initial_metadata:
self.assertTrue(
test_common.metadata_transmitted(
server_initial_metadata,
- client_result.received_metadata))
- elif client_result.type == cygrpc.OperationType.receive_message:
- self.assertEqual(RESPONSE,
- client_result.received_message.bytes())
- elif client_result.type == cygrpc.OperationType.receive_status_on_client:
+ client_result.initial_metadata()))
+ elif client_result.type() == cygrpc.OperationType.receive_message:
+ self.assertEqual(RESPONSE, client_result.message())
+ elif client_result.type(
+ ) == cygrpc.OperationType.receive_status_on_client:
self.assertTrue(
test_common.metadata_transmitted(
server_trailing_metadata,
- client_result.received_metadata))
- self.assertEqual(SERVER_STATUS_DETAILS,
- client_result.received_status_details)
- self.assertEqual(SERVER_STATUS_CODE,
- client_result.received_status_code)
+ client_result.trailing_metadata()))
+ self.assertEqual(SERVER_STATUS_DETAILS, client_result.details())
+ self.assertEqual(SERVER_STATUS_CODE, client_result.code())
self.assertEqual(
set([
cygrpc.OperationType.send_initial_metadata,
@@ -330,13 +285,13 @@ class ServerClientMixin(object):
self.assertEqual(5, len(server_event.batch_operations))
found_server_op_types = set()
for server_result in server_event.batch_operations:
- self.assertNotIn(client_result.type, found_server_op_types)
- found_server_op_types.add(server_result.type)
- if server_result.type == cygrpc.OperationType.receive_message:
- self.assertEqual(REQUEST,
- server_result.received_message.bytes())
- elif server_result.type == cygrpc.OperationType.receive_close_on_server:
- self.assertFalse(server_result.received_cancelled)
+ self.assertNotIn(client_result.type(), found_server_op_types)
+ found_server_op_types.add(server_result.type())
+ if server_result.type() == cygrpc.OperationType.receive_message:
+ self.assertEqual(REQUEST, server_result.message())
+ elif server_result.type(
+ ) == cygrpc.OperationType.receive_close_on_server:
+ self.assertFalse(server_result.cancelled())
self.assertEqual(
set([
cygrpc.OperationType.send_initial_metadata,
@@ -354,8 +309,7 @@ class ServerClientMixin(object):
DEADLINE_TOLERANCE = 0.25
METHOD = b'twinkies'
- cygrpc_deadline = cygrpc.Timespec(DEADLINE)
- empty_metadata = cygrpc.Metadata([])
+ empty_metadata = ()
server_request_tag = object()
self.server.request_call(self.server_completion_queue,
@@ -363,31 +317,29 @@ class ServerClientMixin(object):
server_request_tag)
client_call = self.client_channel.create_call(
None, 0, self.client_completion_queue, METHOD, self.host_argument,
- cygrpc_deadline)
+ DEADLINE)
# Prologue
def perform_client_operations(operations, description):
return self._perform_operations(operations, client_call,
self.client_completion_queue,
- cygrpc_deadline, description)
+ DEADLINE, description)
client_event_future = perform_client_operations([
- cygrpc.operation_send_initial_metadata(empty_metadata,
- _EMPTY_FLAGS),
- cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),
+ cygrpc.SendInitialMetadataOperation(empty_metadata, _EMPTY_FLAGS),
+ cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),
], "Client prologue")
- request_event = self.server_completion_queue.poll(cygrpc_deadline)
- server_call = request_event.operation_call
+ request_event = self.server_completion_queue.poll(deadline=DEADLINE)
+ server_call = request_event.call
def perform_server_operations(operations, description):
return self._perform_operations(operations, server_call,
self.server_completion_queue,
- cygrpc_deadline, description)
+ DEADLINE, description)
server_event_future = perform_server_operations([
- cygrpc.operation_send_initial_metadata(empty_metadata,
- _EMPTY_FLAGS),
+ cygrpc.SendInitialMetadataOperation(empty_metadata, _EMPTY_FLAGS),
], "Server prologue")
client_event_future.result() # force completion
@@ -396,12 +348,12 @@ class ServerClientMixin(object):
# Messaging
for _ in range(10):
client_event_future = perform_client_operations([
- cygrpc.operation_send_message(b'', _EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'', _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
], "Client message")
server_event_future = perform_server_operations([
- cygrpc.operation_send_message(b'', _EMPTY_FLAGS),
- cygrpc.operation_receive_message(_EMPTY_FLAGS),
+ cygrpc.SendMessageOperation(b'', _EMPTY_FLAGS),
+ cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),
], "Server receive")
client_event_future.result() # force completion
@@ -409,13 +361,13 @@ class ServerClientMixin(object):
# Epilogue
client_event_future = perform_client_operations([
- cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),
- cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS)
+ cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),
+ cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS)
], "Client epilogue")
server_event_future = perform_server_operations([
- cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS),
- cygrpc.operation_send_status_from_server(
+ cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),
+ cygrpc.SendStatusFromServerOperation(
empty_metadata, cygrpc.StatusCode.ok, b'', _EMPTY_FLAGS)
], "Server epilogue")
@@ -435,12 +387,13 @@ class InsecureServerInsecureClient(unittest.TestCase, ServerClientMixin):
class SecureServerSecureClient(unittest.TestCase, ServerClientMixin):
def setUp(self):
- server_credentials = cygrpc.server_credentials_ssl(None, [
- cygrpc.SslPemKeyCertPair(resources.private_key(),
- resources.certificate_chain())
- ], False)
- client_credentials = cygrpc.channel_credentials_ssl(
- resources.test_root_certificates(), None)
+ server_credentials = cygrpc.server_credentials_ssl(
+ None, [
+ cygrpc.SslPemKeyCertPair(resources.private_key(),
+ resources.certificate_chain())
+ ], False)
+ client_credentials = cygrpc.SSLChannelCredentials(
+ resources.test_root_certificates(), None, None)
self.setUpMixin(server_credentials, client_credentials,
_SSL_HOST_OVERRIDE)
diff --git a/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py b/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py
index 8e91161f80..4a00b9ef2f 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/test_utilities.py
@@ -49,4 +49,4 @@ class CompletionQueuePollFuture(SimpleFuture):
def __init__(self, completion_queue, deadline):
super(CompletionQueuePollFuture,
- self).__init__(lambda: completion_queue.poll(deadline))
+ self).__init__(lambda: completion_queue.poll(deadline=deadline))
diff --git a/src/python/grpcio_tests/tests/unit/_empty_message_test.py b/src/python/grpcio_tests/tests/unit/_empty_message_test.py
index 62077e7677..c55ef61c13 100644
--- a/src/python/grpcio_tests/tests/unit/_empty_message_test.py
+++ b/src/python/grpcio_tests/tests/unit/_empty_message_test.py
@@ -15,8 +15,8 @@
import unittest
import grpc
-from grpc.framework.foundation import logging_pool
+from tests.unit import test_common
from tests.unit.framework.common import test_constants
_REQUEST = b''
@@ -87,9 +87,8 @@ class _GenericHandler(grpc.GenericRpcHandler):
class EmptyMessageTest(unittest.TestCase):
def setUp(self):
- self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(
- self._server_pool, handlers=(_GenericHandler(),))
+ self._server = test_common.test_server()
+ self._server.add_generic_rpc_handlers((_GenericHandler(),))
port = self._server.add_insecure_port('[::]:0')
self._server.start()
self._channel = grpc.insecure_channel('localhost:%d' % port)
@@ -107,13 +106,13 @@ class EmptyMessageTest(unittest.TestCase):
list(response_iterator))
def testStreamUnary(self):
- response = self._channel.stream_unary(_STREAM_UNARY)(
- iter([_REQUEST] * test_constants.STREAM_LENGTH))
+ response = self._channel.stream_unary(_STREAM_UNARY)(iter(
+ [_REQUEST] * test_constants.STREAM_LENGTH))
self.assertEqual(_RESPONSE, response)
def testStreamStream(self):
- response_iterator = self._channel.stream_stream(_STREAM_STREAM)(
- iter([_REQUEST] * test_constants.STREAM_LENGTH))
+ response_iterator = self._channel.stream_stream(_STREAM_STREAM)(iter(
+ [_REQUEST] * test_constants.STREAM_LENGTH))
self.assertSequenceEqual([_RESPONSE] * test_constants.STREAM_LENGTH,
list(response_iterator))
diff --git a/src/python/grpcio_tests/tests/unit/_exit_scenarios.py b/src/python/grpcio_tests/tests/unit/_exit_scenarios.py
index 7c13dab756..0a0239a63d 100644
--- a/src/python/grpcio_tests/tests/unit/_exit_scenarios.py
+++ b/src/python/grpcio_tests/tests/unit/_exit_scenarios.py
@@ -168,11 +168,11 @@ if __name__ == '__main__':
args = parser.parse_args()
if args.scenario == UNSTARTED_SERVER:
- server = grpc.server(DaemonPool())
+ server = grpc.server(DaemonPool(), options=(('grpc.so_reuseport', 0),))
if args.wait_for_interrupt:
time.sleep(WAIT_TIME)
elif args.scenario == RUNNING_SERVER:
- server = grpc.server(DaemonPool())
+ server = grpc.server(DaemonPool(), options=(('grpc.so_reuseport', 0),))
port = server.add_insecure_port('[::]:0')
server.start()
if args.wait_for_interrupt:
@@ -187,7 +187,7 @@ if __name__ == '__main__':
if args.wait_for_interrupt:
time.sleep(WAIT_TIME)
elif args.scenario == POLL_CONNECTIVITY:
- server = grpc.server(DaemonPool())
+ server = grpc.server(DaemonPool(), options=(('grpc.so_reuseport', 0),))
port = server.add_insecure_port('[::]:0')
server.start()
channel = grpc.insecure_channel('localhost:%d' % port)
@@ -201,7 +201,7 @@ if __name__ == '__main__':
else:
handler = GenericHandler()
- server = grpc.server(DaemonPool())
+ server = grpc.server(DaemonPool(), options=(('grpc.so_reuseport', 0),))
port = server.add_insecure_port('[::]:0')
server.add_generic_rpc_handlers((handler,))
server.start()
diff --git a/src/python/grpcio_tests/tests/unit/_interceptor_test.py b/src/python/grpcio_tests/tests/unit/_interceptor_test.py
new file mode 100644
index 0000000000..3d547b71cd
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/_interceptor_test.py
@@ -0,0 +1,601 @@
+# 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.
+"""Test of gRPC Python interceptors."""
+
+import collections
+import itertools
+import threading
+import unittest
+from concurrent import futures
+
+import grpc
+from grpc.framework.foundation import logging_pool
+
+from tests.unit import test_common
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.common import test_control
+
+_SERIALIZE_REQUEST = lambda bytestring: bytestring * 2
+_DESERIALIZE_REQUEST = lambda bytestring: bytestring[len(bytestring) // 2:]
+_SERIALIZE_RESPONSE = lambda bytestring: bytestring * 3
+_DESERIALIZE_RESPONSE = lambda bytestring: bytestring[:len(bytestring) // 3]
+
+_UNARY_UNARY = '/test/UnaryUnary'
+_UNARY_STREAM = '/test/UnaryStream'
+_STREAM_UNARY = '/test/StreamUnary'
+_STREAM_STREAM = '/test/StreamStream'
+
+
+class _Callback(object):
+
+ def __init__(self):
+ self._condition = threading.Condition()
+ self._value = None
+ self._called = False
+
+ def __call__(self, value):
+ with self._condition:
+ self._value = value
+ self._called = True
+ self._condition.notify_all()
+
+ def value(self):
+ with self._condition:
+ while not self._called:
+ self._condition.wait()
+ return self._value
+
+
+class _Handler(object):
+
+ def __init__(self, control):
+ self._control = control
+
+ def handle_unary_unary(self, request, servicer_context):
+ self._control.control()
+ if servicer_context is not None:
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
+ return request
+
+ def handle_unary_stream(self, request, servicer_context):
+ for _ in range(test_constants.STREAM_LENGTH):
+ self._control.control()
+ yield request
+ self._control.control()
+ if servicer_context is not None:
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
+
+ def handle_stream_unary(self, request_iterator, servicer_context):
+ if servicer_context is not None:
+ servicer_context.invocation_metadata()
+ self._control.control()
+ response_elements = []
+ for request in request_iterator:
+ self._control.control()
+ response_elements.append(request)
+ self._control.control()
+ if servicer_context is not None:
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
+ return b''.join(response_elements)
+
+ def handle_stream_stream(self, request_iterator, servicer_context):
+ self._control.control()
+ if servicer_context is not None:
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
+ for request in request_iterator:
+ self._control.control()
+ yield request
+ self._control.control()
+
+
+class _MethodHandler(grpc.RpcMethodHandler):
+
+ def __init__(self, request_streaming, response_streaming,
+ request_deserializer, response_serializer, unary_unary,
+ unary_stream, stream_unary, stream_stream):
+ self.request_streaming = request_streaming
+ self.response_streaming = response_streaming
+ self.request_deserializer = request_deserializer
+ self.response_serializer = response_serializer
+ self.unary_unary = unary_unary
+ self.unary_stream = unary_stream
+ self.stream_unary = stream_unary
+ self.stream_stream = stream_stream
+
+
+class _GenericHandler(grpc.GenericRpcHandler):
+
+ def __init__(self, handler):
+ self._handler = handler
+
+ def service(self, handler_call_details):
+ if handler_call_details.method == _UNARY_UNARY:
+ return _MethodHandler(False, False, None, None,
+ self._handler.handle_unary_unary, None, None,
+ None)
+ elif handler_call_details.method == _UNARY_STREAM:
+ return _MethodHandler(False, True, _DESERIALIZE_REQUEST,
+ _SERIALIZE_RESPONSE, None,
+ self._handler.handle_unary_stream, None, None)
+ elif handler_call_details.method == _STREAM_UNARY:
+ return _MethodHandler(True, False, _DESERIALIZE_REQUEST,
+ _SERIALIZE_RESPONSE, None, None,
+ self._handler.handle_stream_unary, None)
+ elif handler_call_details.method == _STREAM_STREAM:
+ return _MethodHandler(True, True, None, None, None, None, None,
+ self._handler.handle_stream_stream)
+ else:
+ return None
+
+
+def _unary_unary_multi_callable(channel):
+ return channel.unary_unary(_UNARY_UNARY)
+
+
+def _unary_stream_multi_callable(channel):
+ return channel.unary_stream(
+ _UNARY_STREAM,
+ request_serializer=_SERIALIZE_REQUEST,
+ response_deserializer=_DESERIALIZE_RESPONSE)
+
+
+def _stream_unary_multi_callable(channel):
+ return channel.stream_unary(
+ _STREAM_UNARY,
+ request_serializer=_SERIALIZE_REQUEST,
+ response_deserializer=_DESERIALIZE_RESPONSE)
+
+
+def _stream_stream_multi_callable(channel):
+ return channel.stream_stream(_STREAM_STREAM)
+
+
+class _ClientCallDetails(
+ collections.namedtuple(
+ '_ClientCallDetails',
+ ('method', 'timeout', 'metadata', 'credentials')),
+ grpc.ClientCallDetails):
+ pass
+
+
+class _GenericClientInterceptor(
+ grpc.UnaryUnaryClientInterceptor, grpc.UnaryStreamClientInterceptor,
+ grpc.StreamUnaryClientInterceptor, grpc.StreamStreamClientInterceptor):
+
+ def __init__(self, interceptor_function):
+ self._fn = interceptor_function
+
+ def intercept_unary_unary(self, continuation, client_call_details, request):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, iter((request,)), False, False)
+ response = continuation(new_details, next(new_request_iterator))
+ return postprocess(response) if postprocess else response
+
+ def intercept_unary_stream(self, continuation, client_call_details,
+ request):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, iter((request,)), False, True)
+ response_it = continuation(new_details, new_request_iterator)
+ return postprocess(response_it) if postprocess else response_it
+
+ def intercept_stream_unary(self, continuation, client_call_details,
+ request_iterator):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, request_iterator, True, False)
+ response = continuation(new_details, next(new_request_iterator))
+ return postprocess(response) if postprocess else response
+
+ def intercept_stream_stream(self, continuation, client_call_details,
+ request_iterator):
+ new_details, new_request_iterator, postprocess = self._fn(
+ client_call_details, request_iterator, True, True)
+ response_it = continuation(new_details, new_request_iterator)
+ return postprocess(response_it) if postprocess else response_it
+
+
+class _LoggingInterceptor(
+ grpc.ServerInterceptor, grpc.UnaryUnaryClientInterceptor,
+ grpc.UnaryStreamClientInterceptor, grpc.StreamUnaryClientInterceptor,
+ grpc.StreamStreamClientInterceptor):
+
+ def __init__(self, tag, record):
+ self.tag = tag
+ self.record = record
+
+ def intercept_service(self, continuation, handler_call_details):
+ self.record.append(self.tag + ':intercept_service')
+ return continuation(handler_call_details)
+
+ def intercept_unary_unary(self, continuation, client_call_details, request):
+ self.record.append(self.tag + ':intercept_unary_unary')
+ return continuation(client_call_details, request)
+
+ def intercept_unary_stream(self, continuation, client_call_details,
+ request):
+ self.record.append(self.tag + ':intercept_unary_stream')
+ return continuation(client_call_details, request)
+
+ def intercept_stream_unary(self, continuation, client_call_details,
+ request_iterator):
+ self.record.append(self.tag + ':intercept_stream_unary')
+ return continuation(client_call_details, request_iterator)
+
+ def intercept_stream_stream(self, continuation, client_call_details,
+ request_iterator):
+ self.record.append(self.tag + ':intercept_stream_stream')
+ return continuation(client_call_details, request_iterator)
+
+
+class _DefectiveClientInterceptor(grpc.UnaryUnaryClientInterceptor):
+
+ def intercept_unary_unary(self, ignored_continuation,
+ ignored_client_call_details, ignored_request):
+ raise test_control.Defect()
+
+
+def _wrap_request_iterator_stream_interceptor(wrapper):
+
+ def intercept_call(client_call_details, request_iterator, request_streaming,
+ ignored_response_streaming):
+ if request_streaming:
+ return client_call_details, wrapper(request_iterator), None
+ else:
+ return client_call_details, request_iterator, None
+
+ return _GenericClientInterceptor(intercept_call)
+
+
+def _append_request_header_interceptor(header, value):
+
+ def intercept_call(client_call_details, request_iterator,
+ ignored_request_streaming, ignored_response_streaming):
+ metadata = []
+ if client_call_details.metadata:
+ metadata = list(client_call_details.metadata)
+ metadata.append((
+ header,
+ value,
+ ))
+ client_call_details = _ClientCallDetails(
+ client_call_details.method, client_call_details.timeout, metadata,
+ client_call_details.credentials)
+ return client_call_details, request_iterator, None
+
+ return _GenericClientInterceptor(intercept_call)
+
+
+class _GenericServerInterceptor(grpc.ServerInterceptor):
+
+ def __init__(self, fn):
+ self._fn = fn
+
+ def intercept_service(self, continuation, handler_call_details):
+ return self._fn(continuation, handler_call_details)
+
+
+def _filter_server_interceptor(condition, interceptor):
+
+ def intercept_service(continuation, handler_call_details):
+ if condition(handler_call_details):
+ return interceptor.intercept_service(continuation,
+ handler_call_details)
+ return continuation(handler_call_details)
+
+ return _GenericServerInterceptor(intercept_service)
+
+
+class InterceptorTest(unittest.TestCase):
+
+ def setUp(self):
+ self._control = test_control.PauseFailControl()
+ self._handler = _Handler(self._control)
+ self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
+
+ self._record = []
+ conditional_interceptor = _filter_server_interceptor(
+ lambda x: ('secret', '42') in x.invocation_metadata,
+ _LoggingInterceptor('s3', self._record))
+
+ self._server = grpc.server(
+ self._server_pool,
+ options=(('grpc.so_reuseport', 0),),
+ interceptors=(
+ _LoggingInterceptor('s1', self._record),
+ conditional_interceptor,
+ _LoggingInterceptor('s2', self._record),
+ ))
+ port = self._server.add_insecure_port('[::]:0')
+ self._server.add_generic_rpc_handlers((_GenericHandler(self._handler),))
+ self._server.start()
+
+ self._channel = grpc.insecure_channel('localhost:%d' % port)
+
+ def tearDown(self):
+ self._server.stop(None)
+ self._server_pool.shutdown(wait=True)
+
+ def testTripleRequestMessagesClientInterceptor(self):
+
+ def triple(request_iterator):
+ while True:
+ try:
+ item = next(request_iterator)
+ yield item
+ yield item
+ yield item
+ except StopIteration:
+ break
+
+ interceptor = _wrap_request_iterator_stream_interceptor(triple)
+ channel = grpc.intercept_channel(self._channel, interceptor)
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
+
+ multi_callable = _stream_stream_multi_callable(channel)
+ response_iterator = multi_callable(
+ iter(requests),
+ metadata=(
+ ('test',
+ 'InterceptedStreamRequestBlockingUnaryResponseWithCall'),))
+
+ responses = tuple(response_iterator)
+ self.assertEqual(len(responses), 3 * test_constants.STREAM_LENGTH)
+
+ multi_callable = _stream_stream_multi_callable(self._channel)
+ response_iterator = multi_callable(
+ iter(requests),
+ metadata=(
+ ('test',
+ 'InterceptedStreamRequestBlockingUnaryResponseWithCall'),))
+
+ responses = tuple(response_iterator)
+ self.assertEqual(len(responses), test_constants.STREAM_LENGTH)
+
+ def testDefectiveClientInterceptor(self):
+ interceptor = _DefectiveClientInterceptor()
+ defective_channel = grpc.intercept_channel(self._channel, interceptor)
+
+ request = b'\x07\x08'
+
+ multi_callable = _unary_unary_multi_callable(defective_channel)
+ call_future = multi_callable.future(
+ request,
+ metadata=(('test',
+ 'InterceptedUnaryRequestBlockingUnaryResponse'),))
+
+ self.assertIsNotNone(call_future.exception())
+ self.assertEqual(call_future.code(), grpc.StatusCode.INTERNAL)
+
+ def testInterceptedHeaderManipulationWithServerSideVerification(self):
+ request = b'\x07\x08'
+
+ channel = grpc.intercept_channel(self._channel,
+ _append_request_header_interceptor(
+ 'secret', '42'))
+ channel = grpc.intercept_channel(channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ self._record[:] = []
+
+ multi_callable = _unary_unary_multi_callable(channel)
+ multi_callable.with_call(
+ request,
+ metadata=(
+ ('test',
+ 'InterceptedUnaryRequestBlockingUnaryResponseWithCall'),))
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_unary_unary', 'c2:intercept_unary_unary',
+ 's1:intercept_service', 's3:intercept_service',
+ 's2:intercept_service'
+ ])
+
+ def testInterceptedUnaryRequestBlockingUnaryResponse(self):
+ request = b'\x07\x08'
+
+ self._record[:] = []
+
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _unary_unary_multi_callable(channel)
+ multi_callable(
+ request,
+ metadata=(('test',
+ 'InterceptedUnaryRequestBlockingUnaryResponse'),))
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_unary_unary', 'c2:intercept_unary_unary',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedUnaryRequestBlockingUnaryResponseWithCall(self):
+ request = b'\x07\x08'
+
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ self._record[:] = []
+
+ multi_callable = _unary_unary_multi_callable(channel)
+ multi_callable.with_call(
+ request,
+ metadata=(
+ ('test',
+ 'InterceptedUnaryRequestBlockingUnaryResponseWithCall'),))
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_unary_unary', 'c2:intercept_unary_unary',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedUnaryRequestFutureUnaryResponse(self):
+ request = b'\x07\x08'
+
+ self._record[:] = []
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _unary_unary_multi_callable(channel)
+ response_future = multi_callable.future(
+ request,
+ metadata=(('test', 'InterceptedUnaryRequestFutureUnaryResponse'),))
+ response_future.result()
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_unary_unary', 'c2:intercept_unary_unary',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedUnaryRequestStreamResponse(self):
+ request = b'\x37\x58'
+
+ self._record[:] = []
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _unary_stream_multi_callable(channel)
+ response_iterator = multi_callable(
+ request,
+ metadata=(('test', 'InterceptedUnaryRequestStreamResponse'),))
+ tuple(response_iterator)
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_unary_stream', 'c2:intercept_unary_stream',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedStreamRequestBlockingUnaryResponse(self):
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = iter(requests)
+
+ self._record[:] = []
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _stream_unary_multi_callable(channel)
+ multi_callable(
+ request_iterator,
+ metadata=(('test',
+ 'InterceptedStreamRequestBlockingUnaryResponse'),))
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_stream_unary', 'c2:intercept_stream_unary',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedStreamRequestBlockingUnaryResponseWithCall(self):
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = iter(requests)
+
+ self._record[:] = []
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _stream_unary_multi_callable(channel)
+ multi_callable.with_call(
+ request_iterator,
+ metadata=(
+ ('test',
+ 'InterceptedStreamRequestBlockingUnaryResponseWithCall'),))
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_stream_unary', 'c2:intercept_stream_unary',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedStreamRequestFutureUnaryResponse(self):
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = iter(requests)
+
+ self._record[:] = []
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _stream_unary_multi_callable(channel)
+ response_future = multi_callable.future(
+ request_iterator,
+ metadata=(('test', 'InterceptedStreamRequestFutureUnaryResponse'),))
+ response_future.result()
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_stream_unary', 'c2:intercept_stream_unary',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+ def testInterceptedStreamRequestStreamResponse(self):
+ requests = tuple(
+ b'\x77\x58' for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = iter(requests)
+
+ self._record[:] = []
+ channel = grpc.intercept_channel(self._channel,
+ _LoggingInterceptor(
+ 'c1', self._record),
+ _LoggingInterceptor(
+ 'c2', self._record))
+
+ multi_callable = _stream_stream_multi_callable(channel)
+ response_iterator = multi_callable(
+ request_iterator,
+ metadata=(('test', 'InterceptedStreamRequestStreamResponse'),))
+ tuple(response_iterator)
+
+ self.assertSequenceEqual(self._record, [
+ 'c1:intercept_stream_stream', 'c2:intercept_stream_stream',
+ 's1:intercept_service', 's2:intercept_service'
+ ])
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py b/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py
index 8f4c075e2c..4edf0fc4ad 100644
--- a/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py
+++ b/src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py
@@ -106,8 +106,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertEqual(response_iterator.code(), grpc.StatusCode.INTERNAL)
def testStreamRequestBlockingUnaryResponse(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestBlockingUnaryResponse'),)
expected_error_details = "metadata was invalid: %s" % metadata
with self.assertRaises(ValueError) as exception_context:
@@ -115,8 +115,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertIn(expected_error_details, str(exception_context.exception))
def testStreamRequestBlockingUnaryResponseWithCall(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestBlockingUnaryResponseWithCall'),)
expected_error_details = "metadata was invalid: %s" % metadata
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -125,8 +125,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertIn(expected_error_details, str(exception_context.exception))
def testStreamRequestFutureUnaryResponse(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestFutureUnaryResponse'),)
expected_error_details = "metadata was invalid: %s" % metadata
response_future = self._stream_unary.future(
@@ -141,8 +141,8 @@ class InvalidMetadataTest(unittest.TestCase):
self.assertEqual(response_future.code(), grpc.StatusCode.INTERNAL)
def testStreamRequestStreamResponse(self):
- request_iterator = (b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ request_iterator = (
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
metadata = (('InVaLiD', 'StreamRequestStreamResponse'),)
expected_error_details = "metadata was invalid: %s" % metadata
response_iterator = self._stream_stream(
diff --git a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
index 0a1e50c94c..e40cca8b24 100644
--- a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
+++ b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
@@ -15,11 +15,10 @@
import itertools
import threading
import unittest
-from concurrent import futures
import grpc
-from grpc.framework.foundation import logging_pool
+from tests.unit import test_common
from tests.unit.framework.common import test_constants
from tests.unit.framework.common import test_control
@@ -32,6 +31,7 @@ _UNARY_UNARY = '/test/UnaryUnary'
_UNARY_STREAM = '/test/UnaryStream'
_STREAM_UNARY = '/test/StreamUnary'
_STREAM_STREAM = '/test/StreamStream'
+_DEFECTIVE_GENERIC_RPC_HANDLER = '/test/DefectiveGenericRpcHandler'
class _Callback(object):
@@ -62,7 +62,10 @@ class _Handler(object):
def handle_unary_unary(self, request, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return request
def handle_unary_stream(self, request, servicer_context):
@@ -71,7 +74,10 @@ class _Handler(object):
yield request
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
def handle_stream_unary(self, request_iterator, servicer_context):
if servicer_context is not None:
@@ -83,18 +89,27 @@ class _Handler(object):
response_elements.append(request)
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return b''.join(response_elements)
def handle_stream_stream(self, request_iterator, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
for request in request_iterator:
self._control.control()
yield request
self._control.control()
+ def defective_generic_rpc_handler(self):
+ raise test_control.Defect()
+
class _MethodHandler(grpc.RpcMethodHandler):
@@ -132,6 +147,8 @@ class _GenericHandler(grpc.GenericRpcHandler):
elif handler_call_details.method == _STREAM_STREAM:
return _MethodHandler(True, True, None, None, None, None, None,
self._handler.handle_stream_stream)
+ elif handler_call_details.method == _DEFECTIVE_GENERIC_RPC_HANDLER:
+ return self._handler.defective_generic_rpc_handler()
else:
return None
@@ -176,14 +193,17 @@ def _stream_stream_multi_callable(channel):
return channel.stream_stream(_STREAM_STREAM)
+def _defective_handler_multi_callable(channel):
+ return channel.unary_unary(_DEFECTIVE_GENERIC_RPC_HANDLER)
+
+
class InvocationDefectsTest(unittest.TestCase):
def setUp(self):
self._control = test_control.PauseFailControl()
self._handler = _Handler(self._control)
- self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(self._server_pool)
+ self._server = test_common.test_server()
port = self._server.add_insecure_port('[::]:0')
self._server.add_generic_rpc_handlers((_GenericHandler(self._handler),))
self._server.start()
@@ -200,8 +220,8 @@ class InvocationDefectsTest(unittest.TestCase):
with self.assertRaises(grpc.RpcError):
response = multi_callable(
requests,
- metadata=(
- ('test', 'IterableStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'IterableStreamRequestBlockingUnaryResponse'),))
def testIterableStreamRequestFutureUnaryResponse(self):
requests = [b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH)]
@@ -235,6 +255,18 @@ class InvocationDefectsTest(unittest.TestCase):
for _ in range(test_constants.STREAM_LENGTH // 2 + 1):
next(response_iterator)
+ def testDefectiveGenericRpcHandlerUnaryResponse(self):
+ request = b'\x07\x08'
+ multi_callable = _defective_handler_multi_callable(self._channel)
+
+ with self.assertRaises(grpc.RpcError) as exception_context:
+ response = multi_callable(
+ request,
+ metadata=(('test', 'DefectiveGenericRpcHandlerUnary'),))
+
+ self.assertIs(grpc.StatusCode.UNKNOWN,
+ exception_context.exception.code())
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py b/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py
index 9f72b1fcb5..ca10bd4dab 100644
--- a/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py
+++ b/src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py
@@ -17,7 +17,6 @@ import threading
import unittest
import grpc
-from grpc.framework.foundation import logging_pool
from tests.unit import test_common
from tests.unit.framework.common import test_constants
@@ -29,7 +28,7 @@ _SERIALIZED_RESPONSE = b'\x49\x50\x51'
_REQUEST_SERIALIZER = lambda unused_request: _SERIALIZED_REQUEST
_REQUEST_DESERIALIZER = lambda unused_serialized_request: object()
_RESPONSE_SERIALIZER = lambda unused_response: _SERIALIZED_RESPONSE
-_RESPONSE_DESERIALIZER = lambda unused_serialized_resopnse: object()
+_RESPONSE_DESERIALIZER = lambda unused_serialized_response: object()
_SERVICE = 'test.TestService'
_UNARY_UNARY = 'UnaryUnary'
@@ -37,25 +36,32 @@ _UNARY_STREAM = 'UnaryStream'
_STREAM_UNARY = 'StreamUnary'
_STREAM_STREAM = 'StreamStream'
-_CLIENT_METADATA = (('client-md-key', 'client-md-key'),
- ('client-md-key-bin', b'\x00\x01'))
+_CLIENT_METADATA = (('client-md-key', 'client-md-key'), ('client-md-key-bin',
+ b'\x00\x01'))
-_SERVER_INITIAL_METADATA = (
- ('server-initial-md-key', 'server-initial-md-value'),
- ('server-initial-md-key-bin', b'\x00\x02'))
+_SERVER_INITIAL_METADATA = (('server-initial-md-key',
+ 'server-initial-md-value'),
+ ('server-initial-md-key-bin', b'\x00\x02'))
-_SERVER_TRAILING_METADATA = (
- ('server-trailing-md-key', 'server-trailing-md-value'),
- ('server-trailing-md-key-bin', b'\x00\x03'))
+_SERVER_TRAILING_METADATA = (('server-trailing-md-key',
+ 'server-trailing-md-value'),
+ ('server-trailing-md-key-bin', b'\x00\x03'))
_NON_OK_CODE = grpc.StatusCode.NOT_FOUND
_DETAILS = 'Test details!'
+# calling abort should always fail an RPC, even for "invalid" codes
+_ABORT_CODES = (_NON_OK_CODE, 3, grpc.StatusCode.OK)
+_EXPECTED_CLIENT_CODES = (_NON_OK_CODE, grpc.StatusCode.UNKNOWN,
+ grpc.StatusCode.UNKNOWN)
+_EXPECTED_DETAILS = (_DETAILS, _DETAILS, '')
+
class _Servicer(object):
def __init__(self):
self._lock = threading.Lock()
+ self._abort_call = False
self._code = None
self._details = None
self._exception = False
@@ -67,10 +73,13 @@ class _Servicer(object):
self._received_client_metadata = context.invocation_metadata()
context.send_initial_metadata(_SERVER_INITIAL_METADATA)
context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
- if self._code is not None:
- context.set_code(self._code)
- if self._details is not None:
- context.set_details(self._details)
+ if self._abort_call:
+ context.abort(self._code, self._details)
+ else:
+ if self._code is not None:
+ context.set_code(self._code)
+ if self._details is not None:
+ context.set_details(self._details)
if self._exception:
raise test_control.Defect()
else:
@@ -81,10 +90,13 @@ class _Servicer(object):
self._received_client_metadata = context.invocation_metadata()
context.send_initial_metadata(_SERVER_INITIAL_METADATA)
context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
- if self._code is not None:
- context.set_code(self._code)
- if self._details is not None:
- context.set_details(self._details)
+ if self._abort_call:
+ context.abort(self._code, self._details)
+ else:
+ if self._code is not None:
+ context.set_code(self._code)
+ if self._details is not None:
+ context.set_details(self._details)
for _ in range(test_constants.STREAM_LENGTH // 2):
yield _SERIALIZED_RESPONSE
if self._exception:
@@ -95,14 +107,16 @@ class _Servicer(object):
self._received_client_metadata = context.invocation_metadata()
context.send_initial_metadata(_SERVER_INITIAL_METADATA)
context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
- if self._code is not None:
- context.set_code(self._code)
- if self._details is not None:
- context.set_details(self._details)
# TODO(https://github.com/grpc/grpc/issues/6891): just ignore the
# request iterator.
- for ignored_request in request_iterator:
- pass
+ list(request_iterator)
+ if self._abort_call:
+ context.abort(self._code, self._details)
+ else:
+ if self._code is not None:
+ context.set_code(self._code)
+ if self._details is not None:
+ context.set_details(self._details)
if self._exception:
raise test_control.Defect()
else:
@@ -113,19 +127,25 @@ class _Servicer(object):
self._received_client_metadata = context.invocation_metadata()
context.send_initial_metadata(_SERVER_INITIAL_METADATA)
context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
- if self._code is not None:
- context.set_code(self._code)
- if self._details is not None:
- context.set_details(self._details)
# TODO(https://github.com/grpc/grpc/issues/6891): just ignore the
# request iterator.
- for ignored_request in request_iterator:
- pass
+ list(request_iterator)
+ if self._abort_call:
+ context.abort(self._code, self._details)
+ else:
+ if self._code is not None:
+ context.set_code(self._code)
+ if self._details is not None:
+ context.set_details(self._details)
for _ in range(test_constants.STREAM_LENGTH // 3):
yield object()
if self._exception:
raise test_control.Defect()
+ def set_abort_call(self):
+ with self._lock:
+ self._abort_call = True
+
def set_code(self, code):
with self._lock:
self._code = code
@@ -171,25 +191,41 @@ class MetadataCodeDetailsTest(unittest.TestCase):
def setUp(self):
self._servicer = _Servicer()
- self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(
- self._server_pool, handlers=(_generic_handler(self._servicer),))
+ self._server = test_common.test_server()
+ self._server.add_generic_rpc_handlers(
+ (_generic_handler(self._servicer),))
port = self._server.add_insecure_port('[::]:0')
self._server.start()
channel = grpc.insecure_channel('localhost:{}'.format(port))
self._unary_unary = channel.unary_unary(
- '/'.join(('', _SERVICE, _UNARY_UNARY,)),
+ '/'.join((
+ '',
+ _SERVICE,
+ _UNARY_UNARY,
+ )),
request_serializer=_REQUEST_SERIALIZER,
- response_deserializer=_RESPONSE_DESERIALIZER,)
- self._unary_stream = channel.unary_stream(
- '/'.join(('', _SERVICE, _UNARY_STREAM,)),)
- self._stream_unary = channel.stream_unary(
- '/'.join(('', _SERVICE, _STREAM_UNARY,)),)
+ response_deserializer=_RESPONSE_DESERIALIZER,
+ )
+ self._unary_stream = channel.unary_stream('/'.join((
+ '',
+ _SERVICE,
+ _UNARY_STREAM,
+ )),)
+ self._stream_unary = channel.stream_unary('/'.join((
+ '',
+ _SERVICE,
+ _STREAM_UNARY,
+ )),)
self._stream_stream = channel.stream_stream(
- '/'.join(('', _SERVICE, _STREAM_STREAM,)),
+ '/'.join((
+ '',
+ _SERVICE,
+ _STREAM_STREAM,
+ )),
request_serializer=_REQUEST_SERIALIZER,
- response_deserializer=_RESPONSE_DESERIALIZER,)
+ response_deserializer=_RESPONSE_DESERIALIZER,
+ )
def testSuccessfulUnaryUnary(self):
self._servicer.set_details(_DETAILS)
@@ -212,11 +248,10 @@ class MetadataCodeDetailsTest(unittest.TestCase):
def testSuccessfulUnaryStream(self):
self._servicer.set_details(_DETAILS)
- call = self._unary_stream(
+ response_iterator_call = self._unary_stream(
_SERIALIZED_REQUEST, metadata=_CLIENT_METADATA)
- received_initial_metadata = call.initial_metadata()
- for _ in call:
- pass
+ received_initial_metadata = response_iterator_call.initial_metadata()
+ list(response_iterator_call)
self.assertTrue(
test_common.metadata_transmitted(
@@ -225,10 +260,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
received_initial_metadata))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
- call.trailing_metadata()))
- self.assertIs(grpc.StatusCode.OK, call.code())
- self.assertEqual(_DETAILS, call.details())
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(grpc.StatusCode.OK, response_iterator_call.code())
+ self.assertEqual(_DETAILS, response_iterator_call.details())
def testSuccessfulStreamUnary(self):
self._servicer.set_details(_DETAILS)
@@ -252,12 +288,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
def testSuccessfulStreamStream(self):
self._servicer.set_details(_DETAILS)
- call = self._stream_stream(
+ response_iterator_call = self._stream_stream(
iter([object()] * test_constants.STREAM_LENGTH),
metadata=_CLIENT_METADATA)
- received_initial_metadata = call.initial_metadata()
- for _ in call:
- pass
+ received_initial_metadata = response_iterator_call.initial_metadata()
+ list(response_iterator_call)
self.assertTrue(
test_common.metadata_transmitted(
@@ -266,10 +301,126 @@ class MetadataCodeDetailsTest(unittest.TestCase):
test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
received_initial_metadata))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
- call.trailing_metadata()))
- self.assertIs(grpc.StatusCode.OK, call.code())
- self.assertEqual(_DETAILS, call.details())
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(grpc.StatusCode.OK, response_iterator_call.code())
+ self.assertEqual(_DETAILS, response_iterator_call.details())
+
+ def testAbortedUnaryUnary(self):
+ test_cases = zip(_ABORT_CODES, _EXPECTED_CLIENT_CODES,
+ _EXPECTED_DETAILS)
+ for abort_code, expected_code, expected_details in test_cases:
+ self._servicer.set_code(abort_code)
+ self._servicer.set_details(_DETAILS)
+ self._servicer.set_abort_call()
+
+ with self.assertRaises(grpc.RpcError) as exception_context:
+ self._unary_unary.with_call(object(), metadata=_CLIENT_METADATA)
+
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _CLIENT_METADATA,
+ self._servicer.received_client_metadata()))
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _SERVER_INITIAL_METADATA,
+ exception_context.exception.initial_metadata()))
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ exception_context.exception.trailing_metadata()))
+ self.assertIs(expected_code, exception_context.exception.code())
+ self.assertEqual(expected_details,
+ exception_context.exception.details())
+
+ def testAbortedUnaryStream(self):
+ test_cases = zip(_ABORT_CODES, _EXPECTED_CLIENT_CODES,
+ _EXPECTED_DETAILS)
+ for abort_code, expected_code, expected_details in test_cases:
+ self._servicer.set_code(abort_code)
+ self._servicer.set_details(_DETAILS)
+ self._servicer.set_abort_call()
+
+ response_iterator_call = self._unary_stream(
+ _SERIALIZED_REQUEST, metadata=_CLIENT_METADATA)
+ received_initial_metadata = \
+ response_iterator_call.initial_metadata()
+ with self.assertRaises(grpc.RpcError):
+ self.assertEqual(len(list(response_iterator_call)), 0)
+
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _CLIENT_METADATA,
+ self._servicer.received_client_metadata()))
+ self.assertTrue(
+ test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
+ received_initial_metadata))
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(expected_code, response_iterator_call.code())
+ self.assertEqual(expected_details, response_iterator_call.details())
+
+ def testAbortedStreamUnary(self):
+ test_cases = zip(_ABORT_CODES, _EXPECTED_CLIENT_CODES,
+ _EXPECTED_DETAILS)
+ for abort_code, expected_code, expected_details in test_cases:
+ self._servicer.set_code(abort_code)
+ self._servicer.set_details(_DETAILS)
+ self._servicer.set_abort_call()
+
+ with self.assertRaises(grpc.RpcError) as exception_context:
+ self._stream_unary.with_call(
+ iter([_SERIALIZED_REQUEST] * test_constants.STREAM_LENGTH),
+ metadata=_CLIENT_METADATA)
+
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _CLIENT_METADATA,
+ self._servicer.received_client_metadata()))
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _SERVER_INITIAL_METADATA,
+ exception_context.exception.initial_metadata()))
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ exception_context.exception.trailing_metadata()))
+ self.assertIs(expected_code, exception_context.exception.code())
+ self.assertEqual(expected_details,
+ exception_context.exception.details())
+
+ def testAbortedStreamStream(self):
+ test_cases = zip(_ABORT_CODES, _EXPECTED_CLIENT_CODES,
+ _EXPECTED_DETAILS)
+ for abort_code, expected_code, expected_details in test_cases:
+ self._servicer.set_code(abort_code)
+ self._servicer.set_details(_DETAILS)
+ self._servicer.set_abort_call()
+
+ response_iterator_call = self._stream_stream(
+ iter([object()] * test_constants.STREAM_LENGTH),
+ metadata=_CLIENT_METADATA)
+ received_initial_metadata = \
+ response_iterator_call.initial_metadata()
+ with self.assertRaises(grpc.RpcError):
+ self.assertEqual(len(list(response_iterator_call)), 0)
+
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _CLIENT_METADATA,
+ self._servicer.received_client_metadata()))
+ self.assertTrue(
+ test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
+ received_initial_metadata))
+ self.assertTrue(
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(expected_code, response_iterator_call.code())
+ self.assertEqual(expected_details, response_iterator_call.details())
def testCustomCodeUnaryUnary(self):
self._servicer.set_code(_NON_OK_CODE)
@@ -296,12 +447,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
self._servicer.set_code(_NON_OK_CODE)
self._servicer.set_details(_DETAILS)
- call = self._unary_stream(
+ response_iterator_call = self._unary_stream(
_SERIALIZED_REQUEST, metadata=_CLIENT_METADATA)
- received_initial_metadata = call.initial_metadata()
+ received_initial_metadata = response_iterator_call.initial_metadata()
with self.assertRaises(grpc.RpcError):
- for _ in call:
- pass
+ list(response_iterator_call)
self.assertTrue(
test_common.metadata_transmitted(
@@ -310,10 +460,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
received_initial_metadata))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
- call.trailing_metadata()))
- self.assertIs(_NON_OK_CODE, call.code())
- self.assertEqual(_DETAILS, call.details())
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(_NON_OK_CODE, response_iterator_call.code())
+ self.assertEqual(_DETAILS, response_iterator_call.details())
def testCustomCodeStreamUnary(self):
self._servicer.set_code(_NON_OK_CODE)
@@ -342,13 +493,12 @@ class MetadataCodeDetailsTest(unittest.TestCase):
self._servicer.set_code(_NON_OK_CODE)
self._servicer.set_details(_DETAILS)
- call = self._stream_stream(
+ response_iterator_call = self._stream_stream(
iter([object()] * test_constants.STREAM_LENGTH),
metadata=_CLIENT_METADATA)
- received_initial_metadata = call.initial_metadata()
+ received_initial_metadata = response_iterator_call.initial_metadata()
with self.assertRaises(grpc.RpcError) as exception_context:
- for _ in call:
- pass
+ list(response_iterator_call)
self.assertTrue(
test_common.metadata_transmitted(
@@ -390,12 +540,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
self._servicer.set_details(_DETAILS)
self._servicer.set_exception()
- call = self._unary_stream(
+ response_iterator_call = self._unary_stream(
_SERIALIZED_REQUEST, metadata=_CLIENT_METADATA)
- received_initial_metadata = call.initial_metadata()
+ received_initial_metadata = response_iterator_call.initial_metadata()
with self.assertRaises(grpc.RpcError):
- for _ in call:
- pass
+ list(response_iterator_call)
self.assertTrue(
test_common.metadata_transmitted(
@@ -404,10 +553,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
received_initial_metadata))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
- call.trailing_metadata()))
- self.assertIs(_NON_OK_CODE, call.code())
- self.assertEqual(_DETAILS, call.details())
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(_NON_OK_CODE, response_iterator_call.code())
+ self.assertEqual(_DETAILS, response_iterator_call.details())
def testCustomCodeExceptionStreamUnary(self):
self._servicer.set_code(_NON_OK_CODE)
@@ -438,13 +588,12 @@ class MetadataCodeDetailsTest(unittest.TestCase):
self._servicer.set_details(_DETAILS)
self._servicer.set_exception()
- call = self._stream_stream(
+ response_iterator_call = self._stream_stream(
iter([object()] * test_constants.STREAM_LENGTH),
metadata=_CLIENT_METADATA)
- received_initial_metadata = call.initial_metadata()
+ received_initial_metadata = response_iterator_call.initial_metadata()
with self.assertRaises(grpc.RpcError):
- for _ in call:
- pass
+ list(response_iterator_call)
self.assertTrue(
test_common.metadata_transmitted(
@@ -453,10 +602,11 @@ class MetadataCodeDetailsTest(unittest.TestCase):
test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
received_initial_metadata))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
- call.trailing_metadata()))
- self.assertIs(_NON_OK_CODE, call.code())
- self.assertEqual(_DETAILS, call.details())
+ test_common.metadata_transmitted(
+ _SERVER_TRAILING_METADATA,
+ response_iterator_call.trailing_metadata()))
+ self.assertIs(_NON_OK_CODE, response_iterator_call.code())
+ self.assertEqual(_DETAILS, response_iterator_call.details())
def testCustomCodeReturnNoneUnaryUnary(self):
self._servicer.set_code(_NON_OK_CODE)
diff --git a/src/python/grpcio_tests/tests/unit/_metadata_test.py b/src/python/grpcio_tests/tests/unit/_metadata_test.py
index 557d5273d5..5908421011 100644
--- a/src/python/grpcio_tests/tests/unit/_metadata_test.py
+++ b/src/python/grpcio_tests/tests/unit/_metadata_test.py
@@ -18,7 +18,6 @@ import weakref
import grpc
from grpc import _channel
-from grpc.framework.foundation import logging_pool
from tests.unit import test_common
from tests.unit.framework.common import test_constants
@@ -34,19 +33,54 @@ _UNARY_STREAM = '/test/UnaryStream'
_STREAM_UNARY = '/test/StreamUnary'
_STREAM_STREAM = '/test/StreamStream'
-_CLIENT_METADATA = (('client-md-key', 'client-md-key'),
- ('client-md-key-bin', b'\x00\x01'))
-
-_SERVER_INITIAL_METADATA = (
- ('server-initial-md-key', 'server-initial-md-value'),
- ('server-initial-md-key-bin', b'\x00\x02'))
-
-_SERVER_TRAILING_METADATA = (
- ('server-trailing-md-key', 'server-trailing-md-value'),
- ('server-trailing-md-key-bin', b'\x00\x03'))
-
-
-def user_agent(metadata):
+_INVOCATION_METADATA = (
+ (
+ b'invocation-md-key',
+ u'invocation-md-value',
+ ),
+ (
+ u'invocation-md-key-bin',
+ b'\x00\x01',
+ ),
+)
+_EXPECTED_INVOCATION_METADATA = (
+ (
+ 'invocation-md-key',
+ 'invocation-md-value',
+ ),
+ (
+ 'invocation-md-key-bin',
+ b'\x00\x01',
+ ),
+)
+
+_INITIAL_METADATA = ((b'initial-md-key', u'initial-md-value'),
+ (u'initial-md-key-bin', b'\x00\x02'))
+_EXPECTED_INITIAL_METADATA = (
+ (
+ 'initial-md-key',
+ 'initial-md-value',
+ ),
+ (
+ 'initial-md-key-bin',
+ b'\x00\x02',
+ ),
+)
+
+_TRAILING_METADATA = (
+ (
+ 'server-trailing-md-key',
+ 'server-trailing-md-value',
+ ),
+ (
+ 'server-trailing-md-key-bin',
+ b'\x00\x03',
+ ),
+)
+_EXPECTED_TRAILING_METADATA = _TRAILING_METADATA
+
+
+def _user_agent(metadata):
for key, val in metadata:
if key == 'user-agent':
return val
@@ -54,36 +88,35 @@ def user_agent(metadata):
def validate_client_metadata(test, servicer_context):
+ invocation_metadata = servicer_context.invocation_metadata()
test.assertTrue(
- test_common.metadata_transmitted(
- _CLIENT_METADATA, servicer_context.invocation_metadata()))
- test.assertTrue(
- user_agent(servicer_context.invocation_metadata())
- .startswith('primary-agent ' + _channel._USER_AGENT))
+ test_common.metadata_transmitted(_EXPECTED_INVOCATION_METADATA,
+ invocation_metadata))
+ user_agent = _user_agent(invocation_metadata)
test.assertTrue(
- user_agent(servicer_context.invocation_metadata())
- .endswith('secondary-agent'))
+ user_agent.startswith('primary-agent ' + _channel._USER_AGENT))
+ test.assertTrue(user_agent.endswith('secondary-agent'))
def handle_unary_unary(test, request, servicer_context):
validate_client_metadata(test, servicer_context)
- servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA)
- servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
+ servicer_context.send_initial_metadata(_INITIAL_METADATA)
+ servicer_context.set_trailing_metadata(_TRAILING_METADATA)
return _RESPONSE
def handle_unary_stream(test, request, servicer_context):
validate_client_metadata(test, servicer_context)
- servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA)
- servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
+ servicer_context.send_initial_metadata(_INITIAL_METADATA)
+ servicer_context.set_trailing_metadata(_TRAILING_METADATA)
for _ in range(test_constants.STREAM_LENGTH):
yield _RESPONSE
def handle_stream_unary(test, request_iterator, servicer_context):
validate_client_metadata(test, servicer_context)
- servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA)
- servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
+ servicer_context.send_initial_metadata(_INITIAL_METADATA)
+ servicer_context.set_trailing_metadata(_TRAILING_METADATA)
# TODO(issue:#6891) We should be able to remove this loop
for request in request_iterator:
pass
@@ -92,8 +125,8 @@ def handle_stream_unary(test, request_iterator, servicer_context):
def handle_stream_stream(test, request_iterator, servicer_context):
validate_client_metadata(test, servicer_context)
- servicer_context.send_initial_metadata(_SERVER_INITIAL_METADATA)
- servicer_context.set_trailing_metadata(_SERVER_TRAILING_METADATA)
+ servicer_context.send_initial_metadata(_INITIAL_METADATA)
+ servicer_context.set_trailing_metadata(_TRAILING_METADATA)
# TODO(issue:#6891) We should be able to remove this loop,
# and replace with return; yield
for request in request_iterator:
@@ -142,9 +175,9 @@ class _GenericHandler(grpc.GenericRpcHandler):
class MetadataTest(unittest.TestCase):
def setUp(self):
- self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(
- self._server_pool, handlers=(_GenericHandler(weakref.proxy(self)),))
+ self._server = test_common.test_server()
+ self._server.add_generic_rpc_handlers((_GenericHandler(
+ weakref.proxy(self)),))
port = self._server.add_insecure_port('[::]:0')
self._server.start()
self._channel = grpc.insecure_channel(
@@ -156,50 +189,50 @@ class MetadataTest(unittest.TestCase):
def testUnaryUnary(self):
multi_callable = self._channel.unary_unary(_UNARY_UNARY)
unused_response, call = multi_callable.with_call(
- _REQUEST, metadata=_CLIENT_METADATA)
+ _REQUEST, metadata=_INVOCATION_METADATA)
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_INITIAL_METADATA,
call.initial_metadata()))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_TRAILING_METADATA,
call.trailing_metadata()))
def testUnaryStream(self):
multi_callable = self._channel.unary_stream(_UNARY_STREAM)
- call = multi_callable(_REQUEST, metadata=_CLIENT_METADATA)
+ call = multi_callable(_REQUEST, metadata=_INVOCATION_METADATA)
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_INITIAL_METADATA,
call.initial_metadata()))
for _ in call:
pass
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_TRAILING_METADATA,
call.trailing_metadata()))
def testStreamUnary(self):
multi_callable = self._channel.stream_unary(_STREAM_UNARY)
unused_response, call = multi_callable.with_call(
iter([_REQUEST] * test_constants.STREAM_LENGTH),
- metadata=_CLIENT_METADATA)
+ metadata=_INVOCATION_METADATA)
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_INITIAL_METADATA,
call.initial_metadata()))
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_TRAILING_METADATA,
call.trailing_metadata()))
def testStreamStream(self):
multi_callable = self._channel.stream_stream(_STREAM_STREAM)
call = multi_callable(
iter([_REQUEST] * test_constants.STREAM_LENGTH),
- metadata=_CLIENT_METADATA)
+ metadata=_INVOCATION_METADATA)
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_INITIAL_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_INITIAL_METADATA,
call.initial_metadata()))
for _ in call:
pass
self.assertTrue(
- test_common.metadata_transmitted(_SERVER_TRAILING_METADATA,
+ test_common.metadata_transmitted(_EXPECTED_TRAILING_METADATA,
call.trailing_metadata()))
diff --git a/src/python/grpcio_tests/tests/unit/_reconnect_test.py b/src/python/grpcio_tests/tests/unit/_reconnect_test.py
index 53fd1c2ca4..10aee9fb4f 100644
--- a/src/python/grpcio_tests/tests/unit/_reconnect_test.py
+++ b/src/python/grpcio_tests/tests/unit/_reconnect_test.py
@@ -13,6 +13,7 @@
# limitations under the License.
"""Tests that a channel will reconnect if a connection is dropped"""
+import socket
import unittest
import grpc
@@ -30,6 +31,44 @@ def _handle_unary_unary(unused_request, unused_servicer_context):
return _RESPONSE
+def _get_reuse_socket_option():
+ try:
+ return socket.SO_REUSEPORT
+ except AttributeError:
+ # SO_REUSEPORT is unavailable on Windows, but SO_REUSEADDR
+ # allows forcibly re-binding to a port
+ return socket.SO_REUSEADDR
+
+
+def _pick_and_bind_port(sock_opt):
+ # Reserve a port, when we restart the server we want
+ # to hold onto the port
+ port = 0
+ for address_family in (socket.AF_INET6, socket.AF_INET):
+ try:
+ s = socket.socket(address_family, socket.SOCK_STREAM)
+ except socket.error:
+ continue # this address family is unavailable
+ s.setsockopt(socket.SOL_SOCKET, sock_opt, 1)
+ try:
+ s.bind(('localhost', port))
+ # for socket.SOCK_STREAM sockets, it is necessary to call
+ # listen to get the desired behavior.
+ s.listen(1)
+ port = s.getsockname()[1]
+ except socket.error:
+ # port was not available on the current address family
+ # try again
+ port = 0
+ break
+ finally:
+ s.close()
+ if s:
+ return port if port != 0 else _pick_and_bind_port(sock_opt)
+ else:
+ return None # no address family was available
+
+
class ReconnectTest(unittest.TestCase):
def test_reconnect(self):
@@ -38,8 +77,12 @@ class ReconnectTest(unittest.TestCase):
'UnaryUnary':
grpc.unary_unary_rpc_method_handler(_handle_unary_unary)
})
+ sock_opt = _get_reuse_socket_option()
+ port = _pick_and_bind_port(sock_opt)
+ self.assertIsNotNone(port)
+
server = grpc.server(server_pool, (handler,))
- port = server.add_insecure_port('[::]:0')
+ server.add_insecure_port('[::]:{}'.format(port))
server.start()
channel = grpc.insecure_channel('localhost:%d' % port)
multi_callable = channel.unary_unary(_UNARY_UNARY)
diff --git a/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py b/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py
index e425a0adfe..df4b129018 100644
--- a/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py
+++ b/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py
@@ -139,6 +139,7 @@ class ResourceExhaustedTest(unittest.TestCase):
self._server = grpc.server(
self._server_pool,
handlers=(_GenericHandler(self._trigger),),
+ options=(('grpc.so_reuseport', 0),),
maximum_concurrent_rpcs=test_constants.THREAD_CONCURRENCY)
port = self._server.add_insecure_port('[::]:0')
self._server.start()
diff --git a/src/python/grpcio_tests/tests/unit/_rpc_test.py b/src/python/grpcio_tests/tests/unit/_rpc_test.py
index 74d8541808..54f01d9f8d 100644
--- a/src/python/grpcio_tests/tests/unit/_rpc_test.py
+++ b/src/python/grpcio_tests/tests/unit/_rpc_test.py
@@ -21,6 +21,7 @@ from concurrent import futures
import grpc
from grpc.framework.foundation import logging_pool
+from tests.unit import test_common
from tests.unit.framework.common import test_constants
from tests.unit.framework.common import test_control
@@ -63,7 +64,10 @@ class _Handler(object):
def handle_unary_unary(self, request, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
# TODO(https://github.com/grpc/grpc/issues/8483): test the values
# returned by these methods rather than only "smoke" testing that
# the return after having been called.
@@ -77,7 +81,10 @@ class _Handler(object):
yield request
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
def handle_stream_unary(self, request_iterator, servicer_context):
if servicer_context is not None:
@@ -89,13 +96,19 @@ class _Handler(object):
response_elements.append(request)
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
return b''.join(response_elements)
def handle_stream_stream(self, request_iterator, servicer_context):
self._control.control()
if servicer_context is not None:
- servicer_context.set_trailing_metadata((('testkey', 'testvalue',),))
+ servicer_context.set_trailing_metadata(((
+ 'testkey',
+ 'testvalue',
+ ),))
for request in request_iterator:
self._control.control()
yield request
@@ -169,9 +182,8 @@ class RPCTest(unittest.TestCase):
def setUp(self):
self._control = test_control.PauseFailControl()
self._handler = _Handler(self._control)
- self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- self._server = grpc.server(self._server_pool)
+ self._server = test_common.test_server()
port = self._server.add_insecure_port('[::]:0')
self._server.add_generic_rpc_handlers((_GenericHandler(self._handler),))
self._server.start()
@@ -180,7 +192,6 @@ class RPCTest(unittest.TestCase):
def tearDown(self):
self._server.stop(None)
- self._server_pool.shutdown(wait=True)
def testUnrecognizedMethod(self):
request = b'abc'
@@ -245,8 +256,8 @@ class RPCTest(unittest.TestCase):
self.assertSequenceEqual(expected_responses, responses)
def testSuccessfulStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
request_iterator = iter(requests)
@@ -254,14 +265,14 @@ class RPCTest(unittest.TestCase):
multi_callable = _stream_unary_multi_callable(self._channel)
response = multi_callable(
request_iterator,
- metadata=(
- ('test', 'SuccessfulStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'SuccessfulStreamRequestBlockingUnaryResponse'),))
self.assertEqual(expected_response, response)
def testSuccessfulStreamRequestBlockingUnaryResponseWithCall(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
request_iterator = iter(requests)
@@ -277,8 +288,8 @@ class RPCTest(unittest.TestCase):
self.assertIs(grpc.StatusCode.OK, call.code())
def testSuccessfulStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
request_iterator = iter(requests)
@@ -294,8 +305,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNone(response_future.traceback())
def testSuccessfulStreamRequestStreamResponse(self):
- requests = tuple(b'\x77\x58'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x77\x58' for _ in range(test_constants.STREAM_LENGTH))
expected_responses = tuple(
self._handler.handle_stream_stream(iter(requests), None))
request_iterator = iter(requests)
@@ -327,8 +338,8 @@ class RPCTest(unittest.TestCase):
def testConcurrentBlockingInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
expected_responses = [expected_response
@@ -343,15 +354,15 @@ class RPCTest(unittest.TestCase):
request_iterator,
metadata=(('test', 'ConcurrentBlockingInvocations'),))
response_futures[index] = response_future
- responses = tuple(response_future.result()
- for response_future in response_futures)
+ responses = tuple(
+ response_future.result() for response_future in response_futures)
pool.shutdown(wait=True)
self.assertSequenceEqual(expected_responses, responses)
def testConcurrentFutureInvocations(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
expected_response = self._handler.handle_stream_unary(
iter(requests), None)
expected_responses = [expected_response
@@ -365,8 +376,8 @@ class RPCTest(unittest.TestCase):
request_iterator,
metadata=(('test', 'ConcurrentFutureInvocations'),))
response_futures[index] = response_future
- responses = tuple(response_future.result()
- for response_future in response_futures)
+ responses = tuple(
+ response_future.result() for response_future in response_futures)
self.assertSequenceEqual(expected_responses, responses)
@@ -425,14 +436,14 @@ class RPCTest(unittest.TestCase):
multi_callable = _unary_stream_multi_callable(self._channel)
response_iterator = multi_callable(
request,
- metadata=(
- ('test', 'ConsumingSomeButNotAllStreamResponsesUnaryRequest'),))
+ metadata=(('test',
+ 'ConsumingSomeButNotAllStreamResponsesUnaryRequest'),))
for _ in range(test_constants.STREAM_LENGTH // 2):
next(response_iterator)
def testConsumingSomeButNotAllStreamResponsesStreamRequest(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -444,15 +455,15 @@ class RPCTest(unittest.TestCase):
next(response_iterator)
def testConsumingTooManyStreamResponsesStreamRequest(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
response_iterator = multi_callable(
request_iterator,
- metadata=(
- ('test', 'ConsumingTooManyStreamResponsesStreamRequest'),))
+ metadata=(('test',
+ 'ConsumingTooManyStreamResponsesStreamRequest'),))
for _ in range(test_constants.STREAM_LENGTH):
next(response_iterator)
for _ in range(test_constants.STREAM_LENGTH):
@@ -504,8 +515,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(response_iterator.trailing_metadata())
def testCancelledStreamRequestUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -529,8 +540,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(response_future.trailing_metadata())
def testCancelledStreamRequestStreamResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -556,8 +567,8 @@ class RPCTest(unittest.TestCase):
multi_callable.with_call(
request,
timeout=test_constants.SHORT_TIMEOUT,
- metadata=(
- ('test', 'ExpiredUnaryRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'ExpiredUnaryRequestBlockingUnaryResponse'),))
self.assertIsInstance(exception_context.exception, grpc.Call)
self.assertIsNotNone(exception_context.exception.initial_metadata())
@@ -611,8 +622,8 @@ class RPCTest(unittest.TestCase):
response_iterator.code())
def testExpiredStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x07\x08'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x08' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -621,8 +632,8 @@ class RPCTest(unittest.TestCase):
multi_callable(
request_iterator,
timeout=test_constants.SHORT_TIMEOUT,
- metadata=(
- ('test', 'ExpiredStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'ExpiredStreamRequestBlockingUnaryResponse'),))
self.assertIsInstance(exception_context.exception, grpc.RpcError)
self.assertIsInstance(exception_context.exception, grpc.Call)
@@ -633,8 +644,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(exception_context.exception.trailing_metadata())
def testExpiredStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
callback = _Callback()
@@ -645,8 +656,8 @@ class RPCTest(unittest.TestCase):
timeout=test_constants.SHORT_TIMEOUT,
metadata=(('test', 'ExpiredStreamRequestFutureUnaryResponse'),))
with self.assertRaises(grpc.FutureTimeoutError):
- response_future.result(timeout=test_constants.SHORT_TIMEOUT /
- 2.0)
+ response_future.result(
+ timeout=test_constants.SHORT_TIMEOUT / 2.0)
response_future.add_done_callback(callback)
value_passed_to_callback = callback.value()
@@ -664,8 +675,8 @@ class RPCTest(unittest.TestCase):
self.assertIsNotNone(response_future.trailing_metadata())
def testExpiredStreamRequestStreamResponse(self):
- requests = tuple(b'\x67\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -690,8 +701,8 @@ class RPCTest(unittest.TestCase):
with self.assertRaises(grpc.RpcError) as exception_context:
multi_callable.with_call(
request,
- metadata=(
- ('test', 'FailedUnaryRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'FailedUnaryRequestBlockingUnaryResponse'),))
self.assertIs(grpc.StatusCode.UNKNOWN,
exception_context.exception.code())
@@ -735,8 +746,8 @@ class RPCTest(unittest.TestCase):
exception_context.exception.code())
def testFailedStreamRequestBlockingUnaryResponse(self):
- requests = tuple(b'\x47\x58'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x47\x58' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -744,15 +755,15 @@ class RPCTest(unittest.TestCase):
with self.assertRaises(grpc.RpcError) as exception_context:
multi_callable(
request_iterator,
- metadata=(
- ('test', 'FailedStreamRequestBlockingUnaryResponse'),))
+ metadata=(('test',
+ 'FailedStreamRequestBlockingUnaryResponse'),))
self.assertIs(grpc.StatusCode.UNKNOWN,
exception_context.exception.code())
def testFailedStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
callback = _Callback()
@@ -774,8 +785,8 @@ class RPCTest(unittest.TestCase):
self.assertIs(response_future, value_passed_to_callback)
def testFailedStreamRequestStreamResponse(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
@@ -806,8 +817,8 @@ class RPCTest(unittest.TestCase):
request, metadata=(('test', 'IgnoredUnaryRequestStreamResponse'),))
def testIgnoredStreamRequestFutureUnaryResponse(self):
- requests = tuple(b'\x07\x18'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x07\x18' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_unary_multi_callable(self._channel)
@@ -816,8 +827,8 @@ class RPCTest(unittest.TestCase):
metadata=(('test', 'IgnoredStreamRequestFutureUnaryResponse'),))
def testIgnoredStreamRequestStreamResponse(self):
- requests = tuple(b'\x67\x88'
- for _ in range(test_constants.STREAM_LENGTH))
+ requests = tuple(
+ b'\x67\x88' for _ in range(test_constants.STREAM_LENGTH))
request_iterator = iter(requests)
multi_callable = _stream_stream_multi_callable(self._channel)
diff --git a/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py b/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py
new file mode 100644
index 0000000000..0d78034b7b
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py
@@ -0,0 +1,521 @@
+# 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.
+"""Tests server certificate rotation.
+
+Here we test various aspects of gRPC Python, and in some cases gRPC
+Core by extension, support for server certificate rotation.
+
+* ServerSSLCertReloadTestWithClientAuth: test ability to rotate
+ server's SSL cert for use in future channels with clients while not
+ affecting any existing channel. The server requires client
+ authentication.
+
+* ServerSSLCertReloadTestWithoutClientAuth: like
+ ServerSSLCertReloadTestWithClientAuth except that the server does
+ not authenticate the client.
+
+* ServerSSLCertReloadTestCertConfigReuse: tests gRPC Python's ability
+ to deal with user's reuse of ServerCertificateConfiguration instances.
+"""
+
+import abc
+import collections
+import os
+import six
+import threading
+import unittest
+
+from concurrent import futures
+
+import grpc
+from tests.unit import resources
+from tests.unit import test_common
+from tests.testing import _application_common
+from tests.testing import _server_application
+from tests.testing.proto import services_pb2_grpc
+
+CA_1_PEM = resources.cert_hier_1_root_ca_cert()
+CA_2_PEM = resources.cert_hier_2_root_ca_cert()
+
+CLIENT_KEY_1_PEM = resources.cert_hier_1_client_1_key()
+CLIENT_CERT_CHAIN_1_PEM = (resources.cert_hier_1_client_1_cert() +
+ resources.cert_hier_1_intermediate_ca_cert())
+
+CLIENT_KEY_2_PEM = resources.cert_hier_2_client_1_key()
+CLIENT_CERT_CHAIN_2_PEM = (resources.cert_hier_2_client_1_cert() +
+ resources.cert_hier_2_intermediate_ca_cert())
+
+SERVER_KEY_1_PEM = resources.cert_hier_1_server_1_key()
+SERVER_CERT_CHAIN_1_PEM = (resources.cert_hier_1_server_1_cert() +
+ resources.cert_hier_1_intermediate_ca_cert())
+
+SERVER_KEY_2_PEM = resources.cert_hier_2_server_1_key()
+SERVER_CERT_CHAIN_2_PEM = (resources.cert_hier_2_server_1_cert() +
+ resources.cert_hier_2_intermediate_ca_cert())
+
+# for use with the CertConfigFetcher. Roughly a simple custom mock
+# implementation
+Call = collections.namedtuple('Call', ['did_raise', 'returned_cert_config'])
+
+
+def _create_client_stub(
+ port,
+ expect_success,
+ root_certificates=None,
+ private_key=None,
+ certificate_chain=None,
+):
+ channel = grpc.secure_channel('localhost:{}'.format(port),
+ grpc.ssl_channel_credentials(
+ root_certificates=root_certificates,
+ private_key=private_key,
+ certificate_chain=certificate_chain))
+ if expect_success:
+ # per Nathaniel: there's some robustness issue if we start
+ # using a channel without waiting for it to be actually ready
+ grpc.channel_ready_future(channel).result(timeout=10)
+ return services_pb2_grpc.FirstServiceStub(channel)
+
+
+class CertConfigFetcher(object):
+
+ def __init__(self):
+ self._lock = threading.Lock()
+ self._calls = []
+ self._should_raise = False
+ self._cert_config = None
+
+ def reset(self):
+ with self._lock:
+ self._calls = []
+ self._should_raise = False
+ self._cert_config = None
+
+ def configure(self, should_raise, cert_config):
+ assert not (should_raise and cert_config), (
+ "should not specify both should_raise and a cert_config at the same time"
+ )
+ with self._lock:
+ self._should_raise = should_raise
+ self._cert_config = cert_config
+
+ def getCalls(self):
+ with self._lock:
+ return self._calls
+
+ def __call__(self):
+ with self._lock:
+ if self._should_raise:
+ self._calls.append(Call(True, None))
+ raise ValueError('just for fun, should not affect the test')
+ else:
+ self._calls.append(Call(False, self._cert_config))
+ return self._cert_config
+
+
+class _ServerSSLCertReloadTest(
+ six.with_metaclass(abc.ABCMeta, unittest.TestCase)):
+
+ def __init__(self, *args, **kwargs):
+ super(_ServerSSLCertReloadTest, self).__init__(*args, **kwargs)
+ self.server = None
+ self.port = None
+
+ @abc.abstractmethod
+ def require_client_auth(self):
+ raise NotImplementedError()
+
+ def setUp(self):
+ self.server = test_common.test_server()
+ services_pb2_grpc.add_FirstServiceServicer_to_server(
+ _server_application.FirstServiceServicer(), self.server)
+ switch_cert_on_client_num = 10
+ initial_cert_config = grpc.ssl_server_certificate_configuration(
+ [(SERVER_KEY_1_PEM, SERVER_CERT_CHAIN_1_PEM)],
+ root_certificates=CA_2_PEM)
+ self.cert_config_fetcher = CertConfigFetcher()
+ server_credentials = grpc.dynamic_ssl_server_credentials(
+ initial_cert_config,
+ self.cert_config_fetcher,
+ require_client_authentication=self.require_client_auth())
+ self.port = self.server.add_secure_port('[::]:0', server_credentials)
+ self.server.start()
+
+ def tearDown(self):
+ if self.server:
+ self.server.stop(None)
+
+ def _perform_rpc(self, client_stub, expect_success):
+ # we don't care about the actual response of the rpc; only
+ # whether we can perform it or not, and if not, the status
+ # code must be UNAVAILABLE
+ request = _application_common.UNARY_UNARY_REQUEST
+ if expect_success:
+ response = client_stub.UnUn(request)
+ self.assertEqual(response, _application_common.UNARY_UNARY_RESPONSE)
+ else:
+ with self.assertRaises(grpc.RpcError) as exception_context:
+ client_stub.UnUn(request)
+ self.assertEqual(exception_context.exception.code(),
+ grpc.StatusCode.UNAVAILABLE)
+
+ def _do_one_shot_client_rpc(self,
+ expect_success,
+ root_certificates=None,
+ private_key=None,
+ certificate_chain=None):
+ client_stub = _create_client_stub(
+ self.port,
+ expect_success,
+ root_certificates=root_certificates,
+ private_key=private_key,
+ certificate_chain=certificate_chain)
+ self._perform_rpc(client_stub, expect_success)
+ del client_stub
+
+ def _test(self):
+ # things should work...
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertIsNone(actual_calls[0].returned_cert_config)
+
+ # client should reject server...
+ # fails because client trusts ca2 and so will reject server
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ False,
+ root_certificates=CA_2_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertIsNone(call.returned_cert_config, 'i= {}'.format(i))
+
+ # should work again...
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(True, None)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertTrue(actual_calls[0].did_raise)
+ self.assertIsNone(actual_calls[0].returned_cert_config)
+
+ # if with_client_auth, then client should be rejected by
+ # server because client uses key/cert1, but server trusts ca2,
+ # so server will reject
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ not self.require_client_auth(),
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_1_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_1_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertIsNone(call.returned_cert_config, 'i= {}'.format(i))
+
+ # should work again...
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertIsNone(actual_calls[0].returned_cert_config)
+
+ # now create the "persistent" clients
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ persistent_client_stub_A = _create_client_stub(
+ self.port,
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ self._perform_rpc(persistent_client_stub_A, True)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertIsNone(actual_calls[0].returned_cert_config)
+
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ persistent_client_stub_B = _create_client_stub(
+ self.port,
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ self._perform_rpc(persistent_client_stub_B, True)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertIsNone(actual_calls[0].returned_cert_config)
+
+ # moment of truth!! client should reject server because the
+ # server switch cert...
+ cert_config = grpc.ssl_server_certificate_configuration(
+ [(SERVER_KEY_2_PEM, SERVER_CERT_CHAIN_2_PEM)],
+ root_certificates=CA_1_PEM)
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, cert_config)
+ self._do_one_shot_client_rpc(
+ False,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertEqual(call.returned_cert_config, cert_config,
+ 'i= {}'.format(i))
+
+ # now should work again...
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_2_PEM,
+ private_key=CLIENT_KEY_1_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_1_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertIsNone(actual_calls[0].returned_cert_config)
+
+ # client should be rejected by server if with_client_auth
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ not self.require_client_auth(),
+ root_certificates=CA_2_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertIsNone(call.returned_cert_config, 'i= {}'.format(i))
+
+ # here client should reject server...
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._do_one_shot_client_rpc(
+ False,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertIsNone(call.returned_cert_config, 'i= {}'.format(i))
+
+ # persistent clients should continue to work
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._perform_rpc(persistent_client_stub_A, True)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 0)
+
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, None)
+ self._perform_rpc(persistent_client_stub_B, True)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 0)
+
+
+class ServerSSLCertConfigFetcherParamsChecks(unittest.TestCase):
+
+ def test_check_on_initial_config(self):
+ with self.assertRaises(TypeError):
+ grpc.dynamic_ssl_server_credentials(None, str)
+ with self.assertRaises(TypeError):
+ grpc.dynamic_ssl_server_credentials(1, str)
+
+ def test_check_on_config_fetcher(self):
+ cert_config = grpc.ssl_server_certificate_configuration(
+ [(SERVER_KEY_2_PEM, SERVER_CERT_CHAIN_2_PEM)],
+ root_certificates=CA_1_PEM)
+ with self.assertRaises(TypeError):
+ grpc.dynamic_ssl_server_credentials(cert_config, None)
+ with self.assertRaises(TypeError):
+ grpc.dynamic_ssl_server_credentials(cert_config, 1)
+
+
+class ServerSSLCertReloadTestWithClientAuth(_ServerSSLCertReloadTest):
+
+ def require_client_auth(self):
+ return True
+
+ test = _ServerSSLCertReloadTest._test
+
+
+class ServerSSLCertReloadTestWithoutClientAuth(_ServerSSLCertReloadTest):
+
+ def require_client_auth(self):
+ return False
+
+ test = _ServerSSLCertReloadTest._test
+
+
+class ServerSSLCertReloadTestCertConfigReuse(_ServerSSLCertReloadTest):
+ """Ensures that `ServerCertificateConfiguration` instances can be reused.
+
+ Because gRPC Core takes ownership of the
+ `grpc_ssl_server_certificate_config` encapsulated by
+ `ServerCertificateConfiguration`, this test reuses the same
+ `ServerCertificateConfiguration` instances multiple times to make sure
+ gRPC Python takes care of maintaining the validity of
+ `ServerCertificateConfiguration` instances, so that such instances can be
+ re-used by user application.
+ """
+
+ def require_client_auth(self):
+ return True
+
+ def setUp(self):
+ self.server = test_common.test_server()
+ services_pb2_grpc.add_FirstServiceServicer_to_server(
+ _server_application.FirstServiceServicer(), self.server)
+ self.cert_config_A = grpc.ssl_server_certificate_configuration(
+ [(SERVER_KEY_1_PEM, SERVER_CERT_CHAIN_1_PEM)],
+ root_certificates=CA_2_PEM)
+ self.cert_config_B = grpc.ssl_server_certificate_configuration(
+ [(SERVER_KEY_2_PEM, SERVER_CERT_CHAIN_2_PEM)],
+ root_certificates=CA_1_PEM)
+ self.cert_config_fetcher = CertConfigFetcher()
+ server_credentials = grpc.dynamic_ssl_server_credentials(
+ self.cert_config_A,
+ self.cert_config_fetcher,
+ require_client_authentication=True)
+ self.port = self.server.add_secure_port('[::]:0', server_credentials)
+ self.server.start()
+
+ def test_cert_config_reuse(self):
+
+ # succeed with A
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, self.cert_config_A)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertEqual(actual_calls[0].returned_cert_config,
+ self.cert_config_A)
+
+ # fail with A
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, self.cert_config_A)
+ self._do_one_shot_client_rpc(
+ False,
+ root_certificates=CA_2_PEM,
+ private_key=CLIENT_KEY_1_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_1_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertEqual(call.returned_cert_config, self.cert_config_A,
+ 'i= {}'.format(i))
+
+ # succeed again with A
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, self.cert_config_A)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertEqual(actual_calls[0].returned_cert_config,
+ self.cert_config_A)
+
+ # succeed with B
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, self.cert_config_B)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_2_PEM,
+ private_key=CLIENT_KEY_1_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_1_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertEqual(actual_calls[0].returned_cert_config,
+ self.cert_config_B)
+
+ # fail with B
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, self.cert_config_B)
+ self._do_one_shot_client_rpc(
+ False,
+ root_certificates=CA_1_PEM,
+ private_key=CLIENT_KEY_2_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_2_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertGreaterEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ for i, call in enumerate(actual_calls):
+ self.assertFalse(call.did_raise, 'i= {}'.format(i))
+ self.assertEqual(call.returned_cert_config, self.cert_config_B,
+ 'i= {}'.format(i))
+
+ # succeed again with B
+ self.cert_config_fetcher.reset()
+ self.cert_config_fetcher.configure(False, self.cert_config_B)
+ self._do_one_shot_client_rpc(
+ True,
+ root_certificates=CA_2_PEM,
+ private_key=CLIENT_KEY_1_PEM,
+ certificate_chain=CLIENT_CERT_CHAIN_1_PEM)
+ actual_calls = self.cert_config_fetcher.getCalls()
+ self.assertEqual(len(actual_calls), 1)
+ self.assertFalse(actual_calls[0].did_raise)
+ self.assertEqual(actual_calls[0].returned_cert_config,
+ self.cert_config_B)
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py b/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py
index fe3e71d686..18f5af058a 100644
--- a/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py
+++ b/src/python/grpcio_tests/tests/unit/_thread_cleanup_test.py
@@ -52,7 +52,9 @@ class CleanupThreadTest(unittest.TestCase):
target=target,
name='test-name',
args=('arg1', 'arg2'),
- kwargs={'arg3': 'arg3'})
+ kwargs={
+ 'arg3': 'arg3'
+ })
cleanup_thread.start()
cleanup_thread.join()
self.assertEqual(cleanup_thread.name, 'test-name')
diff --git a/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py b/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py
index eb8dc80a6e..61c03f64ba 100644
--- a/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py
+++ b/src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py
@@ -163,7 +163,10 @@ class BetaFeaturesTest(unittest.TestCase):
self._server = implementations.server(
method_implementations, options=server_options)
server_credentials = implementations.ssl_server_credentials([
- (resources.private_key(), resources.certificate_chain(),),
+ (
+ resources.private_key(),
+ resources.certificate_chain(),
+ ),
])
port = self._server.add_secure_port('[::]:0', server_credentials)
self._server.start()
@@ -289,7 +292,10 @@ class ContextManagementAndLifecycleTest(unittest.TestCase):
self._server_options = implementations.server_options(
thread_pool_size=test_constants.POOL_SIZE)
self._server_credentials = implementations.ssl_server_credentials([
- (resources.private_key(), resources.certificate_chain(),),
+ (
+ resources.private_key(),
+ resources.certificate_chain(),
+ ),
])
self._channel_credentials = implementations.ssl_channel_credentials(
resources.test_root_certificates())
diff --git a/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py b/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py
index e4b81e7e78..c99738e085 100644
--- a/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py
+++ b/src/python/grpcio_tests/tests/unit/beta/_face_interface_test.py
@@ -32,8 +32,11 @@ _SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
class _SerializationBehaviors(
collections.namedtuple('_SerializationBehaviors', (
- 'request_serializers', 'request_deserializers',
- 'response_serializers', 'response_deserializers',))):
+ 'request_serializers',
+ 'request_deserializers',
+ 'response_serializers',
+ 'response_deserializers',
+ ))):
pass
@@ -73,7 +76,10 @@ class _Implementation(test_interfaces.Implementation):
server = implementations.server(
method_implementations, options=server_options)
server_credentials = implementations.ssl_server_credentials([
- (resources.private_key(), resources.certificate_chain(),),
+ (
+ resources.private_key(),
+ resources.certificate_chain(),
+ ),
])
port = server.add_secure_port('[::]:0', server_credentials)
server.start()
@@ -116,9 +122,10 @@ class _Implementation(test_interfaces.Implementation):
def load_tests(loader, tests, pattern):
- return unittest.TestSuite(tests=tuple(
- loader.loadTestsFromTestCase(test_case_class)
- for test_case_class in test_cases.test_cases(_Implementation())))
+ return unittest.TestSuite(
+ tests=tuple(
+ loader.loadTestsFromTestCase(test_case_class)
+ for test_case_class in test_cases.test_cases(_Implementation())))
if __name__ == '__main__':
diff --git a/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py b/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py
index 75a615eeff..5a53766d29 100644
--- a/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py
+++ b/src/python/grpcio_tests/tests/unit/beta/_implementations_test.py
@@ -41,8 +41,8 @@ class CallCredentialsTest(unittest.TestCase):
def test_google_call_credentials(self):
creds = oauth2client_client.GoogleCredentials(
'token', 'client_id', 'secret', 'refresh_token',
- datetime.datetime(2008, 6, 24), 'https://refresh.uri.com/',
- 'user_agent')
+ datetime.datetime(2008, 6,
+ 24), 'https://refresh.uri.com/', 'user_agent')
call_creds = implementations.google_call_credentials(creds)
self.assertIsInstance(call_creds, implementations.CallCredentials)
diff --git a/src/python/grpcio_tests/tests/unit/beta/test_utilities.py b/src/python/grpcio_tests/tests/unit/beta/test_utilities.py
index 65da0f2020..c8d920d35e 100644
--- a/src/python/grpcio_tests/tests/unit/beta/test_utilities.py
+++ b/src/python/grpcio_tests/tests/unit/beta/test_utilities.py
@@ -33,6 +33,8 @@ def not_really_secure_channel(host, port, channel_credentials,
conducted.
"""
target = '%s:%d' % (host, port)
- channel = grpc.secure_channel(target, channel_credentials, (
- ('grpc.ssl_target_name_override', server_host_override,),))
+ channel = grpc.secure_channel(target, channel_credentials, ((
+ 'grpc.ssl_target_name_override',
+ server_host_override,
+ ),))
return implementations.Channel(channel)
diff --git a/src/python/grpcio_tests/tests/unit/credentials/README b/src/python/grpcio_tests/tests/unit/credentials/README
deleted file mode 100644
index cb20dcb49f..0000000000
--- a/src/python/grpcio_tests/tests/unit/credentials/README
+++ /dev/null
@@ -1 +0,0 @@
-These are test keys *NOT* to be used in production.
diff --git a/src/python/grpcio_tests/tests/unit/credentials/README.md b/src/python/grpcio_tests/tests/unit/credentials/README.md
new file mode 100644
index 0000000000..100b43c1aa
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/README.md
@@ -0,0 +1,15 @@
+These are test keys *NOT* to be used in production.
+
+The `certificate_hierarchy_1` and `certificate_hierarchy_2` contain
+two disjoint but similarly organized certificate hierarchies. Each
+contains:
+
+* The respective root CA cert in `certs/ca.cert.pem`
+
+* The intermediate CA cert in
+ `intermediate/certs/intermediate.cert.pem`, signed by the root CA
+
+* A client cert and a server cert--both signed by the intermediate
+ CA--in `intermediate/certs/client.cert.pem` and
+ `intermediate/certs/localhost-1.cert.pem`; the corresponding keys
+ are in `intermediate/private`
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/certs/ca.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/certs/ca.cert.pem
new file mode 100644
index 0000000000..604b86fdff
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/certs/ca.cert.pem
@@ -0,0 +1,31 @@
+-----BEGIN CERTIFICATE-----
+MIIFZDCCA0ygAwIBAgIJAKfkDFZ6+Ly/MA0GCSqGSIb3DQEBCwUAMD8xCzAJBgNV
+BAYTAnVzMQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UECgwFZHVtbXkxEDAOBgNVBAMM
+B3Jvb3QgY2EwHhcNMTcxMTAyMDAzNzA1WhcNMzcxMDI4MDAzNzA1WjA/MQswCQYD
+VQQGEwJ1czEOMAwGA1UECAwFZHVtbXkxDjAMBgNVBAoMBWR1bW15MRAwDgYDVQQD
+DAdyb290IGNhMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxlSUuSbi
+o66tT2ZCqu9wNqSX8VhAJkmrAT5y6m2V0VlQ8Gz7ddynW5UVSmtvDNTebZ15FrvO
+6Ng7QnwXXNs/dEzl6oMe6AKDZpuWScVkiqH1UYWBkMLRygWCTEYpSTWTpZWk1zxj
+DJ2LlIoO1X/ufLyLOfy2a2XEz8ICzJePmqVca6fmfEtCTj1/8FcwCBF6YlUWVzlR
+wewjanQo/lorTYbub+Q6LGxPXZ8W0qoKZzLDSD9cnj4pcJzGGFeu9KkNaW4rldZG
+t7mTGQqIRc98dDRc9Jb7PqL8tMPLidw1KErUi05ofxggc5vqNnj4xBl6aX6b/EYN
+rBLzO2e0FazX6TwNKwwg68vbOanpDq5LVmIUH8bY1zNZ+JPBGO9pXlAA0YwLx86r
+R7YhQ431ZpJ2KGnY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rom2Yn/DUXFwrJLBiNJ1dd1JyDxpqpJ74ZQy+/
+pSRWMTRM5SuC7lYARx5rYPmp6cZJWyWRH/3r7bwS699/W965pa5nug==
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem
new file mode 100644
index 0000000000..44bc562599
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem
@@ -0,0 +1,28 @@
+-----BEGIN CERTIFICATE-----
+MIIExzCCAq+gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCdXMx
+DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEYMBYGA1UEAwwPaW50ZXJt
+ZWRpYXRlIGNhMB4XDTE3MTEwMjAwMzcwNloXDTI3MTAzMTAwMzcwNlowPjELMAkG
+A1UEBhMCdXMxDjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEPMA0GA1UE
+AwwGY2xpZW50MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwquL6gtP
+R7P9xJK76FTj8fI5TSJa3cAMt1p6CmessjHQq7nQ6DWLGVi4XIt9Sc/1C3rXupOe
+90Ok4L0tsuVZH78Wn0EBmBH7S4IbhU9P+aJ9mcigepj1lnxWqoVblgeJYKMOOwAf
+pAKUNMWDSm+nCfwE+R5d8d8cfA41Awq1jTRjOVpiJq6aoKfs791a1ZkZde3kFrNV
+AVjC06GgA1lZd3sHf94hmLeC+xJztRXVE9e+7dcc7nFDH0t5DIKYBAklsHg77mZa
+3IK4aOZew7Lm6diPoMnAzXh2rWpJU6RrEE29gIkJBsF8CL1Ndg9MzssCg6KBjoai
+Vt5dJ+4TSEGCOwIDAQABo4HFMIHCMAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQD
+AgWgMDMGCWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBDbGllbnQgQ2Vy
+dGlmaWNhdGUwHQYDVR0OBBYEFPeuKDCswk8jaH9tl6X+uXjo+WM1MB8GA1UdIwQY
+MBaAFCoqYgmKh3CUafVp+paXxfz+He+FMA4GA1UdDwEB/wQEAwIF4DAdBgNVHSUE
+FjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwDQYJKoZIhvcNAQELBQADggIBADYAp8XS
+UjMEpX/zVjRWpAAT4HNEJylCV1QNyhBIAyx38A6xJYuFIx966Htd6W9/Rw4sUY6y
+F4pOmnLCRxIPqFzzMYcBHSpynlcu5G7zqIod3wYIk7BNlB0AzkZn6yD8bM1y5Plf
+myzQVDEGggrDtaW2EehhNIB+wOmbRGITjIcZUEr8V4BlLXkCqOuxauxl82d5/k2w
+LAhjOb9d1VW6RT8+Lcn6drhHZdvtSCe8Z27BcXhaQLL8366mhbigKYJt5adD0KOx
+pl0MQcoL1Rth5cJEj+1/lgUaxcnvh7TaIIGEx0h3olQXsTxSTypU/nww2Ic41xdG
+xl3xvHsxe20IvOOAMRfS/LPW7MCtQ3k0BqB/rAQvmB0r5YITLlMJuBqg+zjYrG/j
+s5szSGAz9r0leFuPraeuZA41d9UBTAJMoVrrQZ4xVHMXQi1oz9E9KlIdbO9+spvC
+ulfO+D+Z4a9trYSWhnQL2dSHT0+kHqJ/8GipiUNP/yAC76dRpDVR3xtYNr73iw0j
+hyDsVjihTD8JBebs3axnt+Bc+FwoCCd6CVcsggfGUNhu/N5LS78b13PcaRzrUNjU
+Eh+8cJvMLst+UQzePlyazzpn7jjN3KsBzWUkbnXCtUs2qRMn8f2gZqliDo7JSFvy
+WtBSCYpikOivuJSQUlrHQ8NaXeddyWQzLY79
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem
new file mode 100644
index 0000000000..98e13669c0
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem
@@ -0,0 +1,31 @@
+-----BEGIN CERTIFICATE-----
+MIIFaDCCA1CgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzELMAkGA1UEBhMCdXMx
+DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEQMA4GA1UEAwwHcm9vdCBj
+YTAeFw0xNzExMDIwMDM3MDZaFw0yNzEwMzEwMDM3MDZaMEcxCzAJBgNVBAYTAnVz
+MQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UECgwFZHVtbXkxGDAWBgNVBAMMD2ludGVy
+bWVkaWF0ZSBjYTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAOOxzve7
+CG2P9SvKfXkJVTXkj4y79JSZ77Kud/TiPfDbHTqZWKuLTXkOCkCCxfpuJvWXnnj5
+1AeLCdKx9hEwJQeU23EXDt1K+RsRyl09SXtPNnJnqHD1mUHRQR28vGX5ctrQzK8J
+Sa6/mHW4bX8ol100npbgVMDnM4IDfLYcsv4BXMICGkSHOW6Gn0zJaeHzRVPpmnK/
+0k/GQAcIrU2sZ39kVlVQkWq3HJC28cNL/P04hjh4gAf0evo/k9VrEtxPWYMfiPDt
+kOAKueoPv/VTA/zL5t8lyzfhrhxvsJxFg/klapPXK0gLLbhsHyOhnkbrzvmSR4Rw
+xubYJ2dDK0DKx+BIZqlFznjP9BvOtvtuVVMyqg9cfgc7J/OjvAguO0f93MLSfIWP
+uISqv7Llt/Blvy/xI5owvOKVc/hm3d+5pqjWBC1HkVwo4qugpWmM49dFWl4kc4c7
+ayYUjTmcgoj1ZR89w4Off/bPd1A6gXqSkw2VQfgFF+uOos84fP1V+zPWhp3UDY3P
+bFeJtuTdv1gR5w1jCIq6xVJ+UsyDZBaYP7yBBRiNzS1/yXJpnXrvHmDfUeQHLBPR
+N0nbMjqXJ1dVpZwydiI0Qx9DnJtOaq/spUreXr8+PU2jeQdCCAN21MB1umr2gZBJ
+8MZBStTgE7SDByfGmGfp7B5/s/r4O/rNc4WzAgMBAAGjZjBkMB0GA1UdDgQWBBQq
+KmIJiodwlGn1afqWl8X8/h3vhTAfBgNVHSMEGDAWgBSVhLUME20woGVjTdPFUsY3
+TQNKGjASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG
+9w0BAQsFAAOCAgEAvzLu/Jc8DlfCltVufC54UZ8DVwUfxdGapNBGv4icrs1wMV3S
+xqdaLO+vSp9NeEufi724+/hj4URapW9kSt2TMD7BNJ61QSATZFJajxTFgGa0Zz95
+RBDw8/b5Arz/2pOF4VX+FJ+wqHvoH/2A0T+fwz8hLORhxZHv/cUN6kif4FKCwryQ
+s89e694kXkEiJfquvu7DR9hYCLOJwzMOOJiTnjz3hlQg4WGu7Z8ZvqzCM+how1hr
+nYbUx6a+HfoUf79AHJB0N1EsEEetJ+omvTdrrayCvy1bHA3QgHlJ28QZIJ7MzX9E
+n11/xQ95iTuSp8iWurzjTjbrm7eHnGUh+5QubYLXOzbqKzNZu72w0uvWv6ptIudU
+usttltiwW8H9kP0ArWTcZDPhhPfS9impFlhiPDk1wUv2/7g+Zz1OaOb7IiSH0s8y
+FG72AB8ucJ5dNa/2q5dJiM8Gm5CbiVw5RXTBjlfTTkNeM6LBI3dRghpPdU7Kbfhn
+xYs9vnRZeRMJHrcodLuwVcpY/gyeJ0k5LD6eIPCJmatkYZ122isYyMX8lL2P5aR+
+7d2hhqcOCproOrtThjp6nW2jWTB+R/O2+s6mhKSPgfbY2cdky1Y9FSJxSNayb9B8
+eQ+A29iOHrGVAA0R/rvw119rLAYxjXzToM28owx7IyXKrBaU4RMv5yokgag=
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem
new file mode 100644
index 0000000000..f15f1cf5c2
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem
@@ -0,0 +1,30 @@
+-----BEGIN CERTIFICATE-----
+MIIFFzCCAv+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCdXMx
+DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEYMBYGA1UEAwwPaW50ZXJt
+ZWRpYXRlIGNhMB4XDTE3MTEwMjAwMzcwNloXDTI3MTAzMTAwMzcwNlowTTELMAkG
+A1UEBhMCdXMxDjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEKMAgGA1UE
+CwwBMTESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
+MIIBCgKCAQEArRAy0Nim9P883BAisXdFoKmgHGTtcLH/SzwkkPWTFHz0rHU1Klwz
+w8u3OkRyvgoQp7DqkohboNMDwg5VrOOcfKwtM2GZ5jixo+YKvJ25oj8Jfr+40baz
+nyWTmOcfoviKrb7u2T9BPEEz5og+lXRDAsTFATGaQDX2LN3Dd9KIw+7sWY+gc3Zi
+13HHaWYhtmfJjzFbH1vDxHKCdSdgtPyEhqcJ4OC6wbgp/mQ01VlPAr08kRfkC8mT
+TS7atqc410irKViF3sWi4YNPf7LuBrjo75FIIOp+sQgZE6xwOuZ/9bT2Zx/IUtCC
+TqzVgZI0s5NVlINtWR6eyyxQ1uDKTs4xrQIDAQABo4IBBTCCAQEwCQYDVR0TBAIw
+ADARBglghkgBhvhCAQEEBAMCBkAwMwYJYIZIAYb4QgENBCYWJE9wZW5TU0wgR2Vu
+ZXJhdGVkIFNlcnZlciBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUDE8pwi7aELJjvyNT
+ed81/KIgGfowaAYDVR0jBGEwX4AUKipiCYqHcJRp9Wn6lpfF/P4d74WhQ6RBMD8x
+CzAJBgNVBAYTAnVzMQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UECgwFZHVtbXkxEDAO
+BgNVBAMMB3Jvb3QgY2GCAhAAMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggr
+BgEFBQcDATANBgkqhkiG9w0BAQsFAAOCAgEA2cvXxJw120Z9oWXyGwR6CH7TcXoy
+1i77B1M5j0Krvkjh2/MkEU+JxpZcrhAgZODK9wMPeIUIpJNw2t6Hg+vigpInu7pY
+MXR4IA5XLnhGV/hueXa0JLia5FG1TISxr4piW6Jd9P2pOt3ECm3Url/F0OeFF/74
+jGaAlWkbhqWJ9M7Gd4QP2wUNm0P4CwAqS9DC6dnMz+JXTakEUirOpmq7U8UKT+5N
+QS1K4WuH671n4MiYye3+UoRYt4zPjOzN+QxzvAMtkUBspPmWD6txmD5tKUYDECqn
+0sSbY6ytD30OTHIbICFp40arOffmEEJSriL+uQNPPmvqMxX1G2kUFGm15NLPs8Xa
+J7ChrAaJzssN5J3myZUbDfCuxmTkWg+hGvGmxLraVNWc3fzKFmdszSkXrGIdf2HR
+gZeFI3w6M4Ktx3KctXlsjwqQTYZI/WwLOEpsrHQBPBLQhISyNw4xjZ4MxK8SFZuQ
+IiGps/do0eEgeQ+o3gD1dIXt8YxFIxrgk0pzJONpXGgv/cZrukbLNTBdkTSkIwtx
+TXKdiJbO17H24MvW+UxFdsIoJXmfQZWdQC3p+Dl0iP+K80aI6WbaysmToHuOi216
+e49nmiM72Izul2zmBi7Cq2nRQbHAETsFfqC34FzJlx0aP8WS953IBD0jNi1BB+AX
+BxwiZ1rPjeMvekI=
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/client.key.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/client.key.pem
new file mode 100644
index 0000000000..d8a21632ab
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/client.key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEAwquL6gtPR7P9xJK76FTj8fI5TSJa3cAMt1p6CmessjHQq7nQ
+6DWLGVi4XIt9Sc/1C3rXupOe90Ok4L0tsuVZH78Wn0EBmBH7S4IbhU9P+aJ9mcig
+epj1lnxWqoVblgeJYKMOOwAfpAKUNMWDSm+nCfwE+R5d8d8cfA41Awq1jTRjOVpi
+Jq6aoKfs791a1ZkZde3kFrNVAVjC06GgA1lZd3sHf94hmLeC+xJztRXVE9e+7dcc
+7nFDH0t5DIKYBAklsHg77mZa3IK4aOZew7Lm6diPoMnAzXh2rWpJU6RrEE29gIkJ
+BsF8CL1Ndg9MzssCg6KBjoaiVt5dJ+4TSEGCOwIDAQABAoIBABECKAFU56JeKYfp
+Qh20fQ4Amd0RaVsCkpnaf9s037PaAl9eptADDZozVDhRv6qZTtGn8/1LNJJqCJfS
+L5H30+egLHvRlDATMh+QyJLHMTegaNTs4IiVoK97QZ84c54SHoCg/ndNNXaA+y35
+K9VvF+sZZ93UN2UQl06Hdz5Cy0YA7L5HIIH3Ezk0ArAw4AarLil5mv4yEz2ApZhm
+Tw4I4yNfxB7tZeP+ekNg0XXRL1quA0tGblp+A5fAFfVMDplqqB2d3/KxPR9FSEOi
+4PzBZ5Mq2wQBPIaNog5um9qkw6VKxjl5sQGhP1GGTA8iZqR9iM2+xh57xdCZm3g3
+jcr+aPECgYEA42mXTsF/4oBQtU6hh/sOCMWHhxAPstKpQHFMKGYLHKEJ/V1qq0Sd
+d0kswAYCmH5G9ookzu5p7pNf0hUUHO5EwelpSZ3FEmtIM+oBwSnDk3vGuadYXN5X
+fPuVUla65B1F9SSwapYNBUAiRgrY69Knca2rkTSdcZQaBuWmo684UQcCgYEA2yRE
+P23I/9N6AVhKB/zTRtil1AxnTW8o+j7AE4q1o+xly7DS7DT34INaLKLiuG6ylV1F
+UoTiqmWqH3A7m3o3Id2AnVf/oDoKV78LCXRF3dJJWvzrPdob2fLlwyjgqXYvmD3O
+UH/OFY2blYcAHOYib1Y1AAhHPlXiHA52BYZtnC0CgYAVjjitWmII0ijURrPA8+cM
+pcyG3NrgFF++n/6cBbAf8pPD1Er8GPDkEaeQPAGa+r03OTjr9GVOG+IFQ8I4S81w
+o/M66x129XxOj2vDJ3ZGUIExr88MXnbkfeRVfasRXET5S5T9RWPOj5mwEe8lyz3b
+5J5SkS4rSeJ9rN7yvPUVmQKBgAvrrB67LRzldxSNpfFLSn7nGBYx2oi2zEbYlQA7
+ImhZWqw64S5iLz2yR3x4G9cmhmZjnXrAqcfVIez14PgzLL6V2wI0ID6qCZf+V25b
+OdW4M69UZMOHks5HTUJRfe8Z87rXWdq9KQu5GUaIAnSP/D2MNfPbf2yfpV4bV0Yz
+qtC9AoGAD3/XXaeGCdV5DPomEmehp84JXU2q/YECRvph46tr4jArG67PCvx2m84B
++W6my4Yi7QJcW4gC0gsdAuxbJl4Y7MCZBnTtNIRCRnHEIciKITJ/+brFln5QUgyn
+WnXEPN8q7VjSVXGrljFuLWkzi2Vh8iZDgourNfW+iYDGCJjx1H0=
+-----END RSA PRIVATE KEY-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem
new file mode 100644
index 0000000000..aa83f1a4a2
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEArRAy0Nim9P883BAisXdFoKmgHGTtcLH/SzwkkPWTFHz0rHU1
+Klwzw8u3OkRyvgoQp7DqkohboNMDwg5VrOOcfKwtM2GZ5jixo+YKvJ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ErnOBXPXNmbkrfcLkAxclJJS6Gf/9u9KIla2Iy2YjmrMh4uoO65Yo2eV4bVD
+A031nzWM8jUE4PzEYEjRCQKBgHDdTj6KiQg0Yg0DUabjcNEZasCpRSJhAyDkdmZi
+5OzKWnuxQvFowF1hdM/aQ/f9Vg7gYJ1lLIeBWf9NOv+3f3RzmrHVh2N/vbxSETIb
+PSH9l5WeDEauG8fhY66q8EuR7sPk3ftTX98YPqEJ/n8Ktz5COO8GH2umKInEKNXc
+UGW1AoGAfENy7vInNv0tzFWPSYdFgesvzo7e8mXyVO8hCyWvY3rxW2on7qfLF3Z9
+fHjd7P9gULja0n1kvmxwUC3u20RrvpY59F4hfi+ji2EiubS9Yhszd2e1CLeRMkln
+ojDjnflN32ZbWVHX/i6g3Dabq9JOD0FsOaOlriLMuofdA6jTUFE=
+-----END RSA PRIVATE KEY-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/certs/ca.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/certs/ca.cert.pem
new file mode 100644
index 0000000000..212b5862cb
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/certs/ca.cert.pem
@@ -0,0 +1,31 @@
+-----BEGIN CERTIFICATE-----
+MIIFZDCCA0ygAwIBAgIJALhSfZ8i0rWTMA0GCSqGSIb3DQEBCwUAMD8xCzAJBgNV
+BAYTAnVzMQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UECgwFZHVtbXkxEDAOBgNVBAMM
+B3Jvb3QgY2EwHhcNMTcxMTAyMDAzNzU4WhcNMzcxMDI4MDAzNzU4WjA/MQswCQYD
+VQQGEwJ1czEOMAwGA1UECAwFZHVtbXkxDjAMBgNVBAoMBWR1bW15MRAwDgYDVQQD
+DAdyb290IGNhMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArHaQ3uyp
+wVaVPZDYvy/EJbnP7KbZNPBvKpQCDEqg9B2TPaC8W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5HQr6iG7QQgoGD/DPLgbBudlO
+kEos9fmXxiX60RLziKCE/DAxI3YWPvG3WhIWnVj22Oz6apz2pYWpOKwlaihNYrhq
+8xc02vIFwKh+t7D+wF4KHfduyMJ/wKVc5dzpNbTgkZePPKSB7QgbsMeRqbdPoXQF
+pMuzfj8VCWzpqBeHqE/adSCZhzeTrnyiYavF4T2vkSC5KJu+MHmbZ3nU9bcnnEy+
+24oEv9cEAiYNkvftbD+5ByEtkcBB2uT47sbiGrAeco+GxFGUVqi1IjObqrkIrPzV
+OjQhTZV6qgYCOuniJiGfoiMeHqdaDybpqo1bIrxSlvGRNcVoOsKt2/KP1DzW4ARZ
+hoRvayU2apHz/T5TAailqAW2MsrjGRaVHQTmeZKag8CKtAcjWzui0J2DnfXxUMn8
+R3ruFu3xJduOT1VghT9L9udvX9YhPCIKVL9+B5eFX9eMV6N7hUnVug==
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem
new file mode 100644
index 0000000000..b6f4280168
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem
@@ -0,0 +1,28 @@
+-----BEGIN CERTIFICATE-----
+MIIExzCCAq+gAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCdXMx
+DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEYMBYGA1UEAwwPaW50ZXJt
+ZWRpYXRlIGNhMB4XDTE3MTEwMjAwMzgwMFoXDTI3MTAzMTAwMzgwMFowPjELMAkG
+A1UEBhMCdXMxDjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEPMA0GA1UE
+AwwGY2xpZW50MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyxZFTLqv
+Gd9S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CVwq0xyqOP3ZqTsTjudTveTBaTZNhTbCjDbaV7ga47TcH9/
++OZ3fQKjt2LAC6162wgEFZf10nUgaAXvSlI74gru93vEwWd8Pd3sWfGwuAFX3oKI
+JuwL2kxEuoZQmeRiVJu6KQb+Im7d5CIoWViDmfxcSDJfdtSePTqmDURIx87fw14Z
+XBWJP4PiK5PRmG/L0cGiDckmDKm/MuD13Z2I/NMl81GNY/q3WY2O7BmddPpAG5dr
+sc5hOqA9+jX08XbxKnfBPYllK5skYMkFH5tN
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem
new file mode 100644
index 0000000000..4305e5333f
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem
@@ -0,0 +1,31 @@
+-----BEGIN CERTIFICATE-----
+MIIFaDCCA1CgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzELMAkGA1UEBhMCdXMx
+DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEQMA4GA1UEAwwHcm9vdCBj
+YTAeFw0xNzExMDIwMDM3NTlaFw0yNzEwMzEwMDM3NTlaMEcxCzAJBgNVBAYTAnVz
+MQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UECgwFZHVtbXkxGDAWBgNVBAMMD2ludGVy
+bWVkaWF0ZSBjYTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKuM2iFz
+CCKmbs4uLj/8wjtxf+jFmkwzN4Pps4hqJ3NJqWB326LhzWyqM4WiTAJWE02wSJbS
+16RPfbjkVC77OI4+PUdwqxU9vNAP/95w0h6hBSFtkysuT5VVUt5jiY7wnUKgqTCi
+MYhYOl+HEP32O4cnxAazkUKKvtyrd4/PvejJ9zz+iYexRnaaGfOFR3co7jQ5QK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sR9SMIkBfYVRxXgWwlvr8JYnd2h/Ef5K9fI32nGfje+7/0kPEjNyjehri7sV4Sjt
+zzkDiFO+JklrRuLBPMFYOokq6Pcko32FKlE82pe8QkMDS8Sk//9PqCTK9ceB7y6E
+NYLNBW/X9SAw/TR5kdRinHHgHyEug7N4+DCU3lU1wl72ZjoiGE7V6c2AssFC2VcE
+E+WYxJT1ROJ1/5+U6BKdaIpTwMtRIFRomOEI66iOwOSEwqLIztkqxwpQ7THraWKm
+2W5e54u/efapIDcQFnP3E8r7TD0PdIeU6mD28o0+WiK3uL/OZpvyKaHPeFU=
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem
new file mode 100644
index 0000000000..2850e42fe9
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem
@@ -0,0 +1,30 @@
+-----BEGIN CERTIFICATE-----
+MIIFFzCCAv+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCdXMx
+DjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEYMBYGA1UEAwwPaW50ZXJt
+ZWRpYXRlIGNhMB4XDTE3MTEwMjAwMzc1OVoXDTI3MTAzMTAwMzc1OVowTTELMAkG
+A1UEBhMCdXMxDjAMBgNVBAgMBWR1bW15MQ4wDAYDVQQKDAVkdW1teTEKMAgGA1UE
+CwwBMTESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
+MIIBCgKCAQEAycY/7H1xk3/XHZRopULV7YsOzPIrMG25zoACbpDZxjS0I+2r1c7V
+wnvE8TszAkloLi+Skku5CYC7IvVEEEuKuIuV+8M48FJEwlCPge8LPiy18C+npCEd
+fgDzCV/O9DfJj6Uai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YytcYBTYLizsAxd5g7j9z8UXrmVQ4mWbh2+xKiG+9aVOzCZ09AYi6
+WVK2aRcMQshgkkqPOloN9OeQNCE8Exf7N/zHsBhygorJXoD/PFgnV1VZm8xkOdiJ
+zTb3bpGdmL5+bzzS6wP8Q7pGZGYdlnB7JNO8oMYPPtzX8OOx92BTkPnqJnnRWTpR
+SjMEEdQe8K7iXxejQkjaAq5BlwaAOjCjPTqYomECcYjC0WaXsmrPcnZwSqpnHZZ2
+OiINYJub5cvBLNo=
+-----END CERTIFICATE-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/client.key.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/client.key.pem
new file mode 100644
index 0000000000..a4c5fd4a56
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/client.key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAyxZFTLqvGd9SpFAykyRyLQgHcR5hgD55mz+9fl1OfnMoAc7y
+TdPVLksDLmeFUlxcvCtLHysJklIBX62c6LzbsVcfLg/DPJlQxFnkhJCRKen4fp7x
+9h62qqJkDFVXsiEFza9L1lsN4OwqU8i4RRgZ/xggM/s/wVBtynioeW9QADNmKZ1n
+6HVKkYwdOynbFSggYfFrL3HL54bC9roZUETin0G5wZ9QU+srgivT0a/KC3ourBYH
+XAI40iHuuOBf3syDVJ6xId/r3UO3qkiQ5q7pwglg+8Nx7Q3CFtGZY3ewxSSSDo6B
+OyweGYMsBaxMO3EyTqecyfXn3n4XPqwmDalWYQIDAQABAoIBAFhIOR3OtVlw3BLz
+jdiq6jsrF1kUFNxTzDcxsSUiWIHde1G17Vzpre0uzJY6iBkyb1mZFFHbOpDxtwkp
+hmEh3/qqXbJ/RaatGxAP56e81G28+LnKTHJqDYwFhapa2wFjG4u7HSN0d4cEAq5j
+Pb9DZ+GdUjpmiON3HBL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XxCCGMkiQmEs4X5kSXXRYgXfNgAD0FX
+-----END RSA PRIVATE KEY-----
diff --git a/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem
new file mode 100644
index 0000000000..8cba174841
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEAycY/7H1xk3/XHZRopULV7YsOzPIrMG25zoACbpDZxjS0I+2r
+1c7VwnvE8TszAkloLi+Skku5CYC7IvVEEEuKuIuV+8M48FJEwlCPge8LPiy18C+n
+pCEdfgDzCV/O9DfJj6UaiCUayVE7UujXoke7AlKQEJcqvnD/CoTv2Y8jV1A6mPf6
+CTEISl1BMeFSmeFyvZll+xJ8Up1KfQZxKhtpP1s/rp6ZNlqSs1LM5+vcDHHZ6COT
+bq7t2vvcmGDTqeCLsqicBg1kJyMPRtqa0bNPj2bcVtcK0Ndfn6eL2hi+EoBy2nIX
+i6aGPpXf85b9bCLd5pZI80nHzFlhdvV+SxqrfwIDAQABAoIBAQC022161aoTEtjH
+m7n8v56vUCCRFVQfEYsljFohrtZ0sdLyDVwjxkSWEYiizXRYTWIDXALd/N+7o9aZ
+bAx5Kq0J45wpUYBc8PDO15T6W0DRlxPxWVXDaSddRQ6TTXxcLREPH2dbtx5+asBo
+/Woi/Haki0q0hDr8/p2sWSH/+SwtWpOezGVlrWrkMeIhlBwHZfdHVoZvSx65Uv7x
+WU07vsjrbXNDwf+2fmklAQrzhedCeh8loGyjtN3cfrTjrE1zqpEsHnlZcJxe6sRB
+1nOqpoUnpZXklDDIYC8EmeubmDJ0jnXOQCDDep3MzVcnZGyF5E/+szaa1NL70Ayj
+rbKk1Y3ZAoGBAPy/1ym7Cjl4OGHN2fdkR6iL68ebJozpr+eTSxDNLuBSi5IJxJyG
+1+B4+v1u0RwZ3DjrSQsO5DCbZ+DHU6O/DAJK2CxUED+M+G2kRyffailRQmNzjpRG
+75dIhSkSRYH8vdvEOnGpeQBZwBcCRH/2YUMlZeSfx9fHJhk1nyUxJeHjAoGBAMxe
+k+cBb0zYok+Ww1xTwOdq0PwKj0oDsEg8hOdWc8pH0SlOAB4BI5kmfd1JDMHfRc49
+7tpNqjsPrnlb9xd8l0281Lj2NoVSE5KX1JtsOsKecQsvHH5zRk4eJ3h/mNixpjfe
+79Zc/O40T4rWpQRqhat+WHveJC0/ON4AH4uT0BK1AoGBAPcTioCu6YXYsjVaCJPB
+IhPwBGOylfL2lxDoel9IVWTRDMOMbPkfEHXNjn6lECJKXW//Af6fZg7mPJwN/wN5
+xYGQLNbYrrGRW2HDUBP4YU1WtHGIC3+EAL+BEztdMzmpGuh1YTSvmSvwkMltXA1D
+iz0amArw72lOsz29n3+6FfBFAoGAIpRqMC8k9vq80/yth6TAQifnvo3G2v4uyLo8
+vqv5IaPvNy70hB8rN9G0gEnI99Dgjdoa3SNBB4dKvUwbTgUN0OB/meBHL13I5Af+
+uGGiu6V1eS/6gUbeAX/Gq/PjF99PQareKAZJ4cBGKTbSayHfBjp1nFflBSbqZ13b
++JEFJvUCgYBOs2J2XXamPbI7gu7B2TE9j/62v0SJyoHq2LHMmYUDRuPdPk3eKCt3
+283w+E8XUIFbctaxsbo8msNjjvV22D/Nci3d87aPe8bn1SVto3GnTuwnOpRq3E+3
+wAarqrhiZbGZSCcAkEOk7FlxAwYnCM6paqMxDEMCJ4qChMM42E9ZyQ==
+-----END RSA PRIVATE KEY-----
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index 45fd321ed6..5d8679aa62 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -70,8 +70,8 @@ class TestCase(
self.implementation.destantiate(self._memo)
def testSuccessfulUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -81,8 +81,8 @@ class TestCase(
test_messages.verify(request, response, self)
def testSuccessfulUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -93,8 +93,8 @@ class TestCase(
test_messages.verify(request, responses, self)
def testSuccessfulStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -104,8 +104,8 @@ class TestCase(
test_messages.verify(requests, response, self)
def testSuccessfulStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -116,8 +116,8 @@ class TestCase(
test_messages.verify(requests, responses, self)
def testSequentialInvocations(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -134,8 +134,8 @@ class TestCase(
def testParallelInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -158,8 +158,8 @@ class TestCase(
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -197,8 +197,8 @@ class TestCase(
raise NotImplementedError()
def testExpiredUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -208,8 +208,8 @@ class TestCase(
request, _3069_test_constant.REALLY_SHORT_TIMEOUT)
def testExpiredUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -220,33 +220,33 @@ class TestCase(
list(response_iterator)
def testExpiredStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
with self._control.pause(), self.assertRaises(
face.ExpirationError):
- self._invoker.blocking(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ self._invoker.blocking(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
def testExpiredStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
with self._control.pause(), self.assertRaises(
face.ExpirationError):
- response_iterator = self._invoker.blocking(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_iterator = self._invoker.blocking(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
list(response_iterator)
def testFailedUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -255,8 +255,8 @@ class TestCase(
request, test_constants.LONG_TIMEOUT)
def testFailedUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -266,8 +266,8 @@ class TestCase(
list(response_iterator)
def testFailedStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -276,8 +276,8 @@ class TestCase(
iter(requests), test_constants.LONG_TIMEOUT)
def testFailedStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py
index 0e399c4bc4..b1c33da43a 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_digest.py
@@ -34,11 +34,15 @@ _IDENTITY = lambda x: x
class TestServiceDigest(
collections.namedtuple('TestServiceDigest', (
- 'methods', 'inline_method_implementations',
- 'event_method_implementations', 'multi_method_implementation',
- 'unary_unary_messages_sequences', 'unary_stream_messages_sequences',
+ 'methods',
+ 'inline_method_implementations',
+ 'event_method_implementations',
+ 'multi_method_implementation',
+ 'unary_unary_messages_sequences',
+ 'unary_stream_messages_sequences',
'stream_unary_messages_sequences',
- 'stream_stream_messages_sequences',))):
+ 'stream_stream_messages_sequences',
+ ))):
"""A transformation of a service.TestService.
Attributes:
@@ -421,8 +425,8 @@ def digest(service, control, pool):
events.update(stream_unary.events)
events.update(stream_stream.events)
- return TestServiceDigest(
- methods, inlines, events,
- _MultiMethodImplementation(adaptations, control, pool),
- unary_unary.messages, unary_stream.messages, stream_unary.messages,
- stream_stream.messages)
+ return TestServiceDigest(methods, inlines, events,
+ _MultiMethodImplementation(adaptations, control,
+ pool),
+ unary_unary.messages, unary_stream.messages,
+ stream_unary.messages, stream_stream.messages)
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index bc65bf4c80..3d9b2816aa 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -134,8 +134,8 @@ class TestCase(
self._digest_pool.shutdown(wait=True)
def testSuccessfulUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -151,8 +151,8 @@ class TestCase(
self.assertIsNone(response_future.traceback())
def testSuccessfulUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -163,8 +163,8 @@ class TestCase(
test_messages.verify(request, responses, self)
def testSuccessfulStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -185,8 +185,8 @@ class TestCase(
self.assertIsNone(response_future.traceback())
def testSuccessfulStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -201,8 +201,8 @@ class TestCase(
test_messages.verify(requests, responses, self)
def testSequentialInvocations(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -220,8 +220,8 @@ class TestCase(
test_messages.verify(second_request, second_response, self)
def testParallelInvocations(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -236,8 +236,8 @@ class TestCase(
test_messages.verify(first_request, first_response, self)
test_messages.verify(second_request, second_response, self)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -258,8 +258,8 @@ class TestCase(
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -282,8 +282,8 @@ class TestCase(
pool.shutdown(wait=True)
def testCancelledUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -305,8 +305,8 @@ class TestCase(
response_future.traceback()
def testCancelledUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -319,8 +319,8 @@ class TestCase(
next(response_iterator)
def testCancelledStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -342,8 +342,8 @@ class TestCase(
response_future.traceback()
def testCancelledStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -356,8 +356,8 @@ class TestCase(
next(response_iterator)
def testExpiredUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -376,8 +376,8 @@ class TestCase(
self.assertIsNotNone(response_future.traceback())
def testExpiredUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -388,16 +388,16 @@ class TestCase(
list(response_iterator)
def testExpiredStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
with self._control.pause():
- response_future = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_future = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
response_future.add_done_callback(callback)
self.assertIs(callback.future(), response_future)
self.assertIsInstance(response_future.exception(),
@@ -409,21 +409,21 @@ class TestCase(
self.assertIsNotNone(response_future.traceback())
def testExpiredStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
with self._control.pause():
- response_iterator = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_iterator = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
with self.assertRaises(face.ExpirationError):
list(response_iterator)
def testFailedUnaryRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -448,8 +448,8 @@ class TestCase(
self.assertIsNotNone(abortion_callback.future())
def testFailedUnaryRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.unary_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -464,17 +464,17 @@ class TestCase(
list(response_iterator)
def testFailedStreamRequestUnaryResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_unary_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
abortion_callback = _Callback()
with self._control.fail():
- response_future = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_future = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
response_future.add_done_callback(callback)
response_future.add_abortion_callback(abortion_callback)
@@ -491,8 +491,8 @@ class TestCase(
self.assertIsNotNone(abortion_callback.future())
def testFailedStreamRequestStreamResponse(self):
- for (group, method), test_messages_sequence in (
- six.iteritems(self._digest.stream_stream_messages_sequences)):
+ for (group, method), test_messages_sequence in (six.iteritems(
+ self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -502,7 +502,7 @@ class TestCase(
# expiration of the RPC.
with self._control.fail(), self.assertRaises(
face.ExpirationError):
- response_iterator = self._invoker.future(group, method)(
- iter(requests),
- _3069_test_constant.REALLY_SHORT_TIMEOUT)
+ response_iterator = self._invoker.future(
+ group, method)(iter(requests),
+ _3069_test_constant.REALLY_SHORT_TIMEOUT)
list(response_iterator)
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py
index fd55f4e09f..efc93d56b0 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_invocation.py
@@ -191,5 +191,8 @@ def invoker_constructors():
Returns:
A sequence of InvokerConstructors.
"""
- return (_GenericInvokerConstructor(), _MultiCallableInvokerConstructor(),
- _DynamicInvokerConstructor(),)
+ return (
+ _GenericInvokerConstructor(),
+ _MultiCallableInvokerConstructor(),
+ _DynamicInvokerConstructor(),
+ )
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py
index 69c7ac2d73..a84e02a79a 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/_stock_service.py
@@ -33,8 +33,8 @@ def _get_last_trade_price(stock_request, stock_reply_callback, control, active):
if active():
stock_reply_callback(
stock_pb2.StockReply(
- symbol=stock_request.symbol, price=_price(
- stock_request.symbol)))
+ symbol=stock_request.symbol,
+ price=_price(stock_request.symbol)))
else:
raise abandonment.Abandoned()
diff --git a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py
index d1c5b8f76b..cff4b7cdea 100644
--- a/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py
+++ b/src/python/grpcio_tests/tests/unit/framework/interfaces/face/test_cases.py
@@ -24,7 +24,8 @@ from tests.unit.framework.interfaces.face import test_interfaces # pylint: disa
_TEST_CASE_SUPERCLASSES = (
_blocking_invocation_inline_service.TestCase,
- _future_invocation_asynchronous_event_service.TestCase,)
+ _future_invocation_asynchronous_event_service.TestCase,
+)
def test_cases(implementation):
@@ -42,8 +43,9 @@ def test_cases(implementation):
for invoker_constructor in _invocation.invoker_constructors():
for super_class in _TEST_CASE_SUPERCLASSES:
test_case_classes.append(
- type(invoker_constructor.name() + super_class.NAME, (
- super_class,), {
+ type(
+ invoker_constructor.name() + super_class.NAME,
+ (super_class,), {
'implementation': implementation,
'invoker_constructor': invoker_constructor,
'__module__': implementation.__module__,
diff --git a/src/python/grpcio_tests/tests/unit/resources.py b/src/python/grpcio_tests/tests/unit/resources.py
index 823d2307d3..51a8979f58 100644
--- a/src/python/grpcio_tests/tests/unit/resources.py
+++ b/src/python/grpcio_tests/tests/unit/resources.py
@@ -11,7 +11,7 @@
# 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.
-"""Constants and functions for data used in interoperability testing."""
+"""Constants and functions for data used in testing."""
import os
@@ -34,3 +34,83 @@ def private_key():
def certificate_chain():
return pkg_resources.resource_string(__name__,
_CERTIFICATE_CHAIN_RESOURCE_PATH)
+
+
+def cert_hier_1_root_ca_cert():
+ return pkg_resources.resource_string(
+ __name__, 'credentials/certificate_hierarchy_1/certs/ca.cert.pem')
+
+
+def cert_hier_1_intermediate_ca_cert():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_1/intermediate/certs/intermediate.cert.pem'
+ )
+
+
+def cert_hier_1_client_1_key():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_1/intermediate/private/client.key.pem'
+ )
+
+
+def cert_hier_1_client_1_cert():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_1/intermediate/certs/client.cert.pem'
+ )
+
+
+def cert_hier_1_server_1_key():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_1/intermediate/private/localhost-1.key.pem'
+ )
+
+
+def cert_hier_1_server_1_cert():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_1/intermediate/certs/localhost-1.cert.pem'
+ )
+
+
+def cert_hier_2_root_ca_cert():
+ return pkg_resources.resource_string(
+ __name__, 'credentials/certificate_hierarchy_2/certs/ca.cert.pem')
+
+
+def cert_hier_2_intermediate_ca_cert():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_2/intermediate/certs/intermediate.cert.pem'
+ )
+
+
+def cert_hier_2_client_1_key():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_2/intermediate/private/client.key.pem'
+ )
+
+
+def cert_hier_2_client_1_cert():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_2/intermediate/certs/client.cert.pem'
+ )
+
+
+def cert_hier_2_server_1_key():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_2/intermediate/private/localhost-1.key.pem'
+ )
+
+
+def cert_hier_2_server_1_cert():
+ return pkg_resources.resource_string(
+ __name__,
+ 'credentials/certificate_hierarchy_2/intermediate/certs/localhost-1.cert.pem'
+ )
diff --git a/src/python/grpcio_tests/tests/unit/test_common.py b/src/python/grpcio_tests/tests/unit/test_common.py
index ed71cc996b..61717ae135 100644
--- a/src/python/grpcio_tests/tests/unit/test_common.py
+++ b/src/python/grpcio_tests/tests/unit/test_common.py
@@ -15,12 +15,25 @@
import collections
+from concurrent import futures
import grpc
import six
-INVOCATION_INITIAL_METADATA = (('0', 'abc'), ('1', 'def'), ('2', 'ghi'),)
-SERVICE_INITIAL_METADATA = (('3', 'jkl'), ('4', 'mno'), ('5', 'pqr'),)
-SERVICE_TERMINAL_METADATA = (('6', 'stu'), ('7', 'vwx'), ('8', 'yza'),)
+INVOCATION_INITIAL_METADATA = (
+ ('0', 'abc'),
+ ('1', 'def'),
+ ('2', 'ghi'),
+)
+SERVICE_INITIAL_METADATA = (
+ ('3', 'jkl'),
+ ('4', 'mno'),
+ ('5', 'pqr'),
+)
+SERVICE_TERMINAL_METADATA = (
+ ('6', 'stu'),
+ ('7', 'vwx'),
+ ('8', 'yza'),
+)
DETAILS = 'test details'
@@ -79,6 +92,18 @@ def test_secure_channel(target, channel_credentials, server_host_override):
An implementations.Channel to the remote host through which RPCs may be
conducted.
"""
- channel = grpc.secure_channel(target, channel_credentials, (
- ('grpc.ssl_target_name_override', server_host_override,),))
+ channel = grpc.secure_channel(target, channel_credentials, ((
+ 'grpc.ssl_target_name_override',
+ server_host_override,
+ ),))
return channel
+
+
+def test_server(max_workers=10):
+ """Creates an insecure grpc server.
+
+ These servers have SO_REUSEPORT disabled to prevent cross-talk.
+ """
+ return grpc.server(
+ futures.ThreadPoolExecutor(max_workers=max_workers),
+ options=(('grpc.so_reuseport', 0),))
diff --git a/src/ruby/README.md b/src/ruby/README.md
index 5c7dae654a..f6fce3ed22 100644
--- a/src/ruby/README.md
+++ b/src/ruby/README.md
@@ -22,6 +22,12 @@ BUILD FROM SOURCE
---------------------
- Clone this repository
+- Init submodules
+
+```sh
+git submodule update --init
+```
+
- Install Ruby 2.x. Consider doing this with [RVM](http://rvm.io), it's a nice way of controlling
the exact ruby version that's used.
```sh
diff --git a/src/ruby/end2end/channel_closing_client.rb b/src/ruby/end2end/channel_closing_client.rb
index 8f6888c203..62c742158a 100755
--- a/src/ruby/end2end/channel_closing_client.rb
+++ b/src/ruby/end2end/channel_closing_client.rb
@@ -44,7 +44,7 @@ def main
ch = GRPC::Core::Channel.new("localhost:#{server_port}", {},
:this_channel_is_insecure)
- srv = GRPC::RpcServer.new
+ srv = new_rpc_server_for_testing
thd = Thread.new do
srv.add_http2_port("0.0.0.0:#{client_control_port}", :this_port_is_insecure)
srv.handle(ChannelClosingClientController.new(ch))
diff --git a/src/ruby/end2end/channel_closing_driver.rb b/src/ruby/end2end/channel_closing_driver.rb
index 0ceb3667eb..57544b0398 100755
--- a/src/ruby/end2end/channel_closing_driver.rb
+++ b/src/ruby/end2end/channel_closing_driver.rb
@@ -23,13 +23,11 @@ def main
STDERR.puts 'start server'
server_runner = ServerRunner.new(EchoServerImpl)
server_port = server_runner.run
-
- sleep 1
-
STDERR.puts 'start client'
control_stub, client_pid = start_client('channel_closing_client.rb',
server_port)
-
+ # sleep to allow time for the client to get into
+ # the middle of a "watch connectivity state" call
sleep 3
begin
diff --git a/src/ruby/end2end/channel_state_driver.rb b/src/ruby/end2end/channel_state_driver.rb
index 98339baebe..f4b1cd2bb8 100755
--- a/src/ruby/end2end/channel_state_driver.rb
+++ b/src/ruby/end2end/channel_state_driver.rb
@@ -22,14 +22,11 @@ def main
STDERR.puts 'start server'
server_runner = ServerRunner.new(EchoServerImpl)
server_port = server_runner.run
-
- sleep 1
-
STDERR.puts 'start client'
_, client_pid = start_client('channel_state_client.rb', server_port)
-
+ # sleep to allow time for the client to get into
+ # the middle of a "watch connectivity state" call
sleep 3
-
Process.kill('SIGTERM', client_pid)
begin
diff --git a/src/ruby/end2end/end2end_common.rb b/src/ruby/end2end/end2end_common.rb
index a1b824fcbf..ffbaa1986d 100755
--- a/src/ruby/end2end/end2end_common.rb
+++ b/src/ruby/end2end/end2end_common.rb
@@ -29,6 +29,9 @@ require 'optparse'
require 'thread'
require 'timeout'
require 'English' # see https://github.com/bbatsov/rubocop/issues/1747
+require_relative '../spec/support/helpers'
+
+include GRPC::Spec::Helpers
# GreeterServer is simple server that implements the Helloworld Greeter server.
class EchoServerImpl < Echo::EchoServer::Service
@@ -40,12 +43,13 @@ end
# ServerRunner starts an "echo server" that test clients can make calls to
class ServerRunner
- def initialize(service_impl)
+ def initialize(service_impl, rpc_server_args: {})
@service_impl = service_impl
+ @rpc_server_args = rpc_server_args
end
def run
- @srv = GRPC::RpcServer.new
+ @srv = new_rpc_server_for_testing(@rpc_server_args)
port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
@srv.handle(@service_impl)
@@ -75,7 +79,6 @@ def start_client(client_main, server_port)
client_path,
"--client_control_port=#{client_control_port}",
"--server_port=#{server_port}")
- sleep 1
control_stub = ClientControl::ClientController::Stub.new(
"localhost:#{client_control_port}", :this_channel_is_insecure)
[control_stub, client_pid]
diff --git a/src/ruby/end2end/forking_client_driver.rb b/src/ruby/end2end/forking_client_driver.rb
index 63565395f7..5cf1d73112 100755
--- a/src/ruby/end2end/forking_client_driver.rb
+++ b/src/ruby/end2end/forking_client_driver.rb
@@ -20,12 +20,6 @@ def main
STDERR.puts 'start server'
server_runner = ServerRunner.new(EchoServerImpl)
server_port = server_runner.run
-
- # TODO(apolcyn) Can we get rid of this sleep?
- # Without it, an immediate call to the just started EchoServer
- # fails with UNAVAILABLE
- sleep 1
-
STDERR.puts 'start client'
_, client_pid = start_client('forking_client_client.rb',
server_port)
diff --git a/src/ruby/end2end/grpc_class_init_client.rb b/src/ruby/end2end/grpc_class_init_client.rb
index c35719a71f..ff40350cfa 100755
--- a/src/ruby/end2end/grpc_class_init_client.rb
+++ b/src/ruby/end2end/grpc_class_init_client.rb
@@ -54,7 +54,7 @@ def run_concurrency_stress_test(test_proc)
test_proc.call
- fail 'exception thrown while child thread initing class'
+ fail '(expected) exception thrown while child thread initing class'
end
# default (no gc_stress and no concurrency_stress)
diff --git a/src/ruby/end2end/killed_client_thread_driver.rb b/src/ruby/end2end/killed_client_thread_driver.rb
index fce5d13e82..370f7e686b 100755
--- a/src/ruby/end2end/killed_client_thread_driver.rb
+++ b/src/ruby/end2end/killed_client_thread_driver.rb
@@ -17,56 +17,46 @@
require_relative './end2end_common'
# Service that sleeps for a long time upon receiving an 'echo request'
-# Also, this notifies @call_started_cv once it has received a request.
+# Also, this calls it's callback upon receiving an RPC as a method
+# of synchronization/waiting for the child to start.
class SleepingEchoServerImpl < Echo::EchoServer::Service
- def initialize(call_started, call_started_mu, call_started_cv)
- @call_started = call_started
- @call_started_mu = call_started_mu
- @call_started_cv = call_started_cv
+ def initialize(received_rpc_callback)
+ @received_rpc_callback = received_rpc_callback
end
def echo(echo_req, _)
- @call_started_mu.synchronize do
- @call_started.set_true
- @call_started_cv.signal
- end
- sleep 1000
+ @received_rpc_callback.call
+ # sleep forever to get the client stuck waiting
+ sleep
Echo::EchoReply.new(response: echo_req.request)
end
end
-# Mutable boolean
-class BoolHolder
- attr_reader :val
-
- def init
- @val = false
- end
-
- def set_true
- @val = true
- end
-end
-
def main
STDERR.puts 'start server'
- call_started = BoolHolder.new
- call_started_mu = Mutex.new
- call_started_cv = ConditionVariable.new
+ client_started = false
+ client_started_mu = Mutex.new
+ client_started_cv = ConditionVariable.new
+ received_rpc_callback = proc do
+ client_started_mu.synchronize do
+ client_started = true
+ client_started_cv.signal
+ end
+ end
- service_impl = SleepingEchoServerImpl.new(call_started,
- call_started_mu,
- call_started_cv)
- server_runner = ServerRunner.new(service_impl)
+ service_impl = SleepingEchoServerImpl.new(received_rpc_callback)
+ # RPCs against the server will all be hanging, so kill thread
+ # pool workers immediately rather than after waiting for a second.
+ rpc_server_args = { poll_period: 0, pool_keep_alive: 0 }
+ server_runner = ServerRunner.new(service_impl, rpc_server_args: rpc_server_args)
server_port = server_runner.run
-
STDERR.puts 'start client'
_, client_pid = start_client('killed_client_thread_client.rb',
server_port)
- call_started_mu.synchronize do
- call_started_cv.wait(call_started_mu) until call_started.val
+ client_started_mu.synchronize do
+ client_started_cv.wait(client_started_mu) until client_started
end
# SIGTERM the child process now that it's
diff --git a/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb b/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb
new file mode 100755
index 0000000000..3668b95a05
--- /dev/null
+++ b/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+#
+# 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.
+
+this_dir = File.expand_path(File.dirname(__FILE__))
+protos_lib_dir = File.join(this_dir, 'lib')
+grpc_lib_dir = File.join(File.dirname(this_dir), 'lib')
+$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir)
+$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir)
+$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir)
+
+GC.stress = 0x04
+
+require 'grpc'
+
+GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure)
+GRPC::Core::Server.new({})
+GRPC::Core::ChannelCredentials.new
+GRPC::Core::CallCredentials.new(proc { |noop| noop })
+GRPC::Core::CompressionOptions.new
diff --git a/src/ruby/end2end/multiple_killed_watching_threads_driver.rb b/src/ruby/end2end/multiple_killed_watching_threads_driver.rb
index 94d5e9da2d..8f078cfbed 100755
--- a/src/ruby/end2end/multiple_killed_watching_threads_driver.rb
+++ b/src/ruby/end2end/multiple_killed_watching_threads_driver.rb
@@ -20,29 +20,42 @@ Thread.abort_on_exception = true
include GRPC::Core::ConnectivityStates
-def watch_state(ch)
+def watch_state(ch, sleep_time)
thd = Thread.new do
state = ch.connectivity_state(false)
fail "non-idle state: #{state}" unless state == IDLE
ch.watch_connectivity_state(IDLE, Time.now + 360)
end
- sleep 0.1
+ # sleep to get the thread into the middle of a
+ # "watch connectivity state" call
+ sleep sleep_time
thd.kill
end
-def main
+def run_multiple_killed_watches(num_threads, sleep_time)
channels = []
- 10.times do
+ num_threads.times do
ch = GRPC::Core::Channel.new('dummy_host',
nil, :this_channel_is_insecure)
- watch_state(ch)
+ watch_state(ch, sleep_time)
channels << ch
end
# checking state should still be safe to call
channels.each do |c|
- fail unless c.connectivity_state(false) == FATAL_FAILURE
+ connectivity_state = c.connectivity_state(false)
+ # The state should be FATAL_FAILURE in the case that it was interrupted
+ # while watching connectivity state, and IDLE if it we never started
+ # watching the channel's connectivity state
+ unless [FATAL_FAILURE, IDLE].include?(connectivity_state)
+ fail "unexpected connectivity state: #{connectivity_state}"
+ end
end
end
+def main
+ run_multiple_killed_watches(10, 0.1)
+ run_multiple_killed_watches(1000, 0.001)
+end
+
main
diff --git a/src/ruby/end2end/sig_handling_client.rb b/src/ruby/end2end/sig_handling_client.rb
index 41b5f334be..6cd289a29b 100755
--- a/src/ruby/end2end/sig_handling_client.rb
+++ b/src/ruby/end2end/sig_handling_client.rb
@@ -30,16 +30,18 @@ class SigHandlingClientController < ClientControl::ClientController::Service
end
def shutdown(_, _)
- Thread.new do
- # TODO(apolcyn) There is a race between stopping the
- # server and the "shutdown" rpc completing,
- # See if stop method on server can end active RPC cleanly, to
- # avoid this sleep.
- sleep 3
+ # Spawn a new thread because RpcServer#stop is
+ # synchronous and blocks until either this RPC has finished,
+ # or the server's "poll_period" seconds have passed.
+ @shutdown_thread = Thread.new do
@srv.stop
end
ClientControl::Void.new
end
+
+ def join_shutdown_thread
+ @shutdown_thread.join
+ end
end
def main
@@ -62,13 +64,23 @@ def main
STDERR.puts 'SIGINT received'
end
- srv = GRPC::RpcServer.new
+ # The "shutdown" RPC should end very quickly.
+ # Allow a few seconds to be safe.
+ srv = new_rpc_server_for_testing(poll_period: 3)
srv.add_http2_port("0.0.0.0:#{client_control_port}",
:this_port_is_insecure)
stub = Echo::EchoServer::Stub.new("localhost:#{server_port}",
:this_channel_is_insecure)
- srv.handle(SigHandlingClientController.new(srv, stub))
- srv.run
+ control_service = SigHandlingClientController.new(srv, stub)
+ srv.handle(control_service)
+ server_thread = Thread.new do
+ srv.run
+ end
+ srv.wait_till_running
+ # send a first RPC to notify the parent process that we've started
+ stub.echo(Echo::EchoRequest.new(request: 'client/child started'))
+ server_thread.join
+ control_service.join_shutdown_thread
end
main
diff --git a/src/ruby/end2end/sig_handling_driver.rb b/src/ruby/end2end/sig_handling_driver.rb
index 291bf29424..0ad1cbd661 100755
--- a/src/ruby/end2end/sig_handling_driver.rb
+++ b/src/ruby/end2end/sig_handling_driver.rb
@@ -19,17 +19,42 @@
require_relative './end2end_common'
+# A service that calls back it's received_rpc_callback
+# upon receiving an RPC. Used for synchronization/waiting
+# for child process to start.
+class ClientStartedService < Echo::EchoServer::Service
+ def initialize(received_rpc_callback)
+ @received_rpc_callback = received_rpc_callback
+ end
+
+ def echo(echo_req, _)
+ @received_rpc_callback.call unless @received_rpc_callback.nil?
+ @received_rpc_callback = nil
+ Echo::EchoReply.new(response: echo_req.request)
+ end
+end
+
def main
STDERR.puts 'start server'
- server_runner = ServerRunner.new(EchoServerImpl)
- server_port = server_runner.run
-
- sleep 1
+ client_started = false
+ client_started_mu = Mutex.new
+ client_started_cv = ConditionVariable.new
+ received_rpc_callback = proc do
+ client_started_mu.synchronize do
+ client_started = true
+ client_started_cv.signal
+ end
+ end
+ client_started_service = ClientStartedService.new(received_rpc_callback)
+ server_runner = ServerRunner.new(client_started_service)
+ server_port = server_runner.run
STDERR.puts 'start client'
control_stub, client_pid = start_client('sig_handling_client.rb', server_port)
- sleep 1
+ client_started_mu.synchronize do
+ client_started_cv.wait(client_started_mu) until client_started
+ end
count = 0
while count < 5
diff --git a/src/ruby/end2end/sig_int_during_channel_watch_driver.rb b/src/ruby/end2end/sig_int_during_channel_watch_driver.rb
index b054f0f5f3..2df22f48a2 100755
--- a/src/ruby/end2end/sig_int_during_channel_watch_driver.rb
+++ b/src/ruby/end2end/sig_int_during_channel_watch_driver.rb
@@ -23,13 +23,9 @@ def main
STDERR.puts 'start server'
server_runner = ServerRunner.new(EchoServerImpl)
server_port = server_runner.run
-
- sleep 1
-
STDERR.puts 'start client'
_, client_pid = start_client('sig_int_during_channel_watch_client.rb',
server_port)
-
# give time for the client to get into the middle
# of a channel state watch call
sleep 1
diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb
index e5ab02b9fc..c1a0c56841 100644
--- a/src/ruby/ext/grpc/extconf.rb
+++ b/src/ruby/ext/grpc/extconf.rb
@@ -41,6 +41,7 @@ LIB_DIRS = [
]
windows = RUBY_PLATFORM =~ /mingw|mswin/
+bsd = RUBY_PLATFORM =~ /bsd/
grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
@@ -60,7 +61,7 @@ ENV['EMBED_ZLIB'] = 'true'
ENV['EMBED_CARES'] = 'true'
ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG']
ENV['ARCH_FLAGS'] = '-arch i386 -arch x86_64' if RUBY_PLATFORM =~ /darwin/
-ENV['CFLAGS'] = '-DGPR_BACKWARDS_COMPATIBILITY_MODE'
+ENV['CPPFLAGS'] = '-DGPR_BACKWARDS_COMPATIBILITY_MODE'
output_dir = File.expand_path(RbConfig::CONFIG['topdir'])
grpc_lib_dir = File.join(output_dir, 'libs', grpc_config)
@@ -70,7 +71,8 @@ unless windows
puts 'Building internal gRPC into ' + grpc_lib_dir
nproc = 4
nproc = Etc.nprocessors * 2 if Etc.respond_to? :nprocessors
- system("make -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q=")
+ make = bsd ? 'gmake' : 'make'
+ system("#{make} -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q=")
exit 1 unless $? == 0
end
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c
index 8aa7a7eb03..e11c7e82a8 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.c
+++ b/src/ruby/ext/grpc/rb_byte_buffer.c
@@ -26,14 +26,14 @@
#include <grpc/slice.h>
#include "rb_grpc.h"
-grpc_byte_buffer *grpc_rb_s_to_byte_buffer(char *string, size_t length) {
+grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char* string, size_t length) {
grpc_slice slice = grpc_slice_from_copied_buffer(string, length);
- grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1);
+ grpc_byte_buffer* buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
return buffer;
}
-VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
+VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer* buffer) {
VALUE rb_string;
grpc_byte_buffer_reader reader;
grpc_slice next;
@@ -46,7 +46,7 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
return Qnil;
}
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
- rb_str_cat(rb_string, (const char *)GRPC_SLICE_START_PTR(next),
+ rb_str_cat(rb_string, (const char*)GRPC_SLICE_START_PTR(next),
GRPC_SLICE_LENGTH(next));
grpc_slice_unref(next);
}
@@ -59,6 +59,6 @@ VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice) {
rb_raise(rb_eRuntimeError,
"attempt to convert uninitialized grpc_slice to ruby string");
}
- return rb_str_new((char *)GRPC_SLICE_START_PTR(slice),
+ return rb_str_new((char*)GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
}
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.h b/src/ruby/ext/grpc/rb_byte_buffer.h
index c64a9900a0..9cb58aa85b 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.h
+++ b/src/ruby/ext/grpc/rb_byte_buffer.h
@@ -24,10 +24,10 @@
#include <grpc/grpc.h>
/* Converts a char* with a length to a grpc_byte_buffer */
-grpc_byte_buffer *grpc_rb_s_to_byte_buffer(char *string, size_t length);
+grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char* string, size_t length);
/* Converts a grpc_byte_buffer to a ruby string */
-VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer);
+VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer* buffer);
/* Converts a grpc_slice to a ruby string */
VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice);
diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c
index 5550bb7d5f..7f3ca2a8e7 100644
--- a/src/ruby/ext/grpc/rb_call.c
+++ b/src/ruby/ext/grpc/rb_call.c
@@ -24,7 +24,6 @@
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/support/alloc.h>
-#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "rb_byte_buffer.h"
@@ -81,11 +80,11 @@ static VALUE sym_status;
static VALUE sym_cancelled;
typedef struct grpc_rb_call {
- grpc_call *wrapped;
- grpc_completion_queue *queue;
+ grpc_call* wrapped;
+ grpc_completion_queue* queue;
} grpc_rb_call;
-static void destroy_call(grpc_rb_call *call) {
+static void destroy_call(grpc_rb_call* call) {
/* Ensure that we only try to destroy the call once */
if (call->wrapped != NULL) {
grpc_call_unref(call->wrapped);
@@ -96,18 +95,19 @@ static void destroy_call(grpc_rb_call *call) {
}
/* Destroys a Call. */
-static void grpc_rb_call_destroy(void *p) {
+static void grpc_rb_call_destroy(void* p) {
if (p == NULL) {
return;
}
- destroy_call((grpc_rb_call *)p);
+ destroy_call((grpc_rb_call*)p);
+ xfree(p);
}
-static size_t md_ary_datasize(const void *p) {
- const grpc_metadata_array *const ary = (grpc_metadata_array *)p;
+static size_t md_ary_datasize(const void* p) {
+ const grpc_metadata_array* const ary = (grpc_metadata_array*)p;
size_t i, datasize = sizeof(grpc_metadata_array);
for (i = 0; i < ary->count; ++i) {
- const grpc_metadata *const md = &ary->metadata[i];
+ const grpc_metadata* const md = &ary->metadata[i];
datasize += GRPC_SLICE_LENGTH(md->key);
datasize += GRPC_SLICE_LENGTH(md->value);
}
@@ -150,9 +150,9 @@ static const rb_data_type_t grpc_call_data_type = {"grpc_call",
VALUE rb_error_code_details;
/* Obtains the error detail string for given error code */
-const char *grpc_call_error_detail_of(grpc_call_error err) {
+const char* grpc_call_error_detail_of(grpc_call_error err) {
VALUE detail_ref = rb_hash_aref(rb_error_code_details, UINT2NUM(err));
- const char *detail = "unknown error code!";
+ const char* detail = "unknown error code!";
if (detail_ref != Qnil) {
detail = StringValueCStr(detail_ref);
}
@@ -162,7 +162,7 @@ const char *grpc_call_error_detail_of(grpc_call_error err) {
/* Called by clients to cancel an RPC on the server.
Can be called multiple times, from any thread. */
static VALUE grpc_rb_call_cancel(VALUE self) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
// This call has been closed
@@ -186,7 +186,7 @@ static VALUE grpc_rb_call_cancel(VALUE self) {
* message. */
static VALUE grpc_rb_call_cancel_with_status(VALUE self, VALUE status_code,
VALUE details) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
// This call has been closed
@@ -216,10 +216,11 @@ static VALUE grpc_rb_call_cancel_with_status(VALUE self, VALUE status_code,
processed.
*/
static VALUE grpc_rb_call_close(VALUE self) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
if (call != NULL) {
destroy_call(call);
+ xfree(RTYPEDDATA_DATA(self));
RTYPEDDATA_DATA(self) = NULL;
}
return Qnil;
@@ -228,8 +229,8 @@ static VALUE grpc_rb_call_close(VALUE self) {
/* Called to obtain the peer that this call is connected to. */
static VALUE grpc_rb_call_get_peer(VALUE self) {
VALUE res = Qnil;
- grpc_rb_call *call = NULL;
- char *peer = NULL;
+ grpc_rb_call* call = NULL;
+ char* peer = NULL;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot get peer value on closed call");
return Qnil;
@@ -244,9 +245,9 @@ static VALUE grpc_rb_call_get_peer(VALUE self) {
/* Called to obtain the x509 cert of an authenticated peer. */
static VALUE grpc_rb_call_get_peer_cert(VALUE self) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
VALUE res = Qnil;
- grpc_auth_context *ctx = NULL;
+ grpc_auth_context* ctx = NULL;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot get peer cert on closed call");
return Qnil;
@@ -262,7 +263,7 @@ static VALUE grpc_rb_call_get_peer_cert(VALUE self) {
{
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == NULL) {
return Qnil;
}
@@ -377,8 +378,8 @@ static VALUE grpc_rb_call_set_write_flag(VALUE self, VALUE write_flag) {
Sets credentials on a call */
static VALUE grpc_rb_call_set_credentials(VALUE self, VALUE credentials) {
- grpc_rb_call *call = NULL;
- grpc_call_credentials *creds;
+ grpc_rb_call* call = NULL;
+ grpc_call_credentials* creds;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot set credentials of closed call");
@@ -405,12 +406,12 @@ static VALUE grpc_rb_call_set_credentials(VALUE self, VALUE credentials) {
grpc_rb_md_ary_capacity_hash_cb
*/
static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
- grpc_metadata_array *md_ary = NULL;
+ grpc_metadata_array* md_ary = NULL;
long array_length;
long i;
grpc_slice key_slice;
grpc_slice value_slice;
- char *tmp_str = NULL;
+ char* tmp_str = NULL;
if (TYPE(key) == T_SYMBOL) {
key_slice = grpc_slice_from_static_string(rb_id2name(SYM2ID(key)));
@@ -480,7 +481,7 @@ static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
*/
static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val,
VALUE md_ary_obj) {
- grpc_metadata_array *md_ary = NULL;
+ grpc_metadata_array* md_ary = NULL;
(void)key;
@@ -501,7 +502,7 @@ static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val,
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
a grpc_metadata_array.
*/
-void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary) {
+void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array* md_ary) {
VALUE md_ary_obj = Qnil;
if (md_ary_hash == Qnil) {
return; /* Do nothing if the expected has value is nil */
@@ -522,7 +523,7 @@ void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary) {
}
/* Converts a metadata array to a hash. */
-VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary) {
+VALUE grpc_rb_md_ary_to_h(grpc_metadata_array* md_ary) {
VALUE key = Qnil;
VALUE new_ary = Qnil;
VALUE value = Qnil;
@@ -585,7 +586,7 @@ static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val,
struct to the 'send_status_from_server' portion of an op.
*/
static void grpc_rb_op_update_status_from_server(
- grpc_op *op, grpc_metadata_array *md_ary, grpc_slice *send_status_details,
+ grpc_op* op, grpc_metadata_array* md_ary, grpc_slice* send_status_details,
VALUE status) {
VALUE code = rb_struct_aref(status, sym_code);
VALUE details = rb_struct_aref(status, sym_details);
@@ -625,7 +626,7 @@ typedef struct run_batch_stack {
grpc_metadata_array send_trailing_metadata;
/* Data being received */
- grpc_byte_buffer *recv_message;
+ grpc_byte_buffer* recv_message;
grpc_metadata_array recv_metadata;
grpc_metadata_array recv_trailing_metadata;
int recv_cancelled;
@@ -637,7 +638,7 @@ typedef struct run_batch_stack {
/* grpc_run_batch_stack_init ensures the run_batch_stack is properly
* initialized */
-static void grpc_run_batch_stack_init(run_batch_stack *st,
+static void grpc_run_batch_stack_init(run_batch_stack* st,
unsigned write_flag) {
MEMZERO(st, run_batch_stack, 1);
grpc_metadata_array_init(&st->send_metadata);
@@ -649,7 +650,7 @@ static void grpc_run_batch_stack_init(run_batch_stack *st,
}
void grpc_rb_metadata_array_destroy_including_entries(
- grpc_metadata_array *array) {
+ grpc_metadata_array* array) {
size_t i;
if (array->metadata) {
for (i = 0; i < array->count; i++) {
@@ -662,7 +663,7 @@ void grpc_rb_metadata_array_destroy_including_entries(
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
* cleaned up */
-static void grpc_run_batch_stack_cleanup(run_batch_stack *st) {
+static void grpc_run_batch_stack_cleanup(run_batch_stack* st) {
size_t i = 0;
grpc_rb_metadata_array_destroy_including_entries(&st->send_metadata);
@@ -691,7 +692,7 @@ static void grpc_run_batch_stack_cleanup(run_batch_stack *st) {
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
* ops_hash */
-static void grpc_run_batch_stack_fill_ops(run_batch_stack *st, VALUE ops_hash) {
+static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) {
VALUE this_op = Qnil;
VALUE this_value = Qnil;
VALUE ops_ary = rb_ary_new();
@@ -758,7 +759,7 @@ static void grpc_run_batch_stack_fill_ops(run_batch_stack *st, VALUE ops_hash) {
/* grpc_run_batch_stack_build_result fills constructs a ruby BatchResult struct
after the results have run */
-static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
+static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
size_t i = 0;
VALUE result = rb_struct_new(grpc_rb_sBatchResult, Qnil, Qnil, Qnil, Qnil,
Qnil, Qnil, Qnil, Qnil, NULL);
@@ -821,14 +822,14 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
Only one operation of each type can be active at once in any given
batch */
static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
- run_batch_stack *st = NULL;
- grpc_rb_call *call = NULL;
+ run_batch_stack* st = NULL;
+ grpc_rb_call* call = NULL;
grpc_event ev;
grpc_call_error err;
VALUE result = Qnil;
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
unsigned write_flag = 0;
- void *tag = (void *)&st;
+ void* tag = (void*)&st;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
@@ -995,8 +996,8 @@ void Init_grpc_call() {
rb_define_method(grpc_rb_cCall, "metadata=", grpc_rb_call_set_metadata, 1);
rb_define_method(grpc_rb_cCall, "trailing_metadata",
grpc_rb_call_get_trailing_metadata, 0);
- rb_define_method(grpc_rb_cCall, "trailing_metadata=",
- grpc_rb_call_set_trailing_metadata, 1);
+ rb_define_method(grpc_rb_cCall,
+ "trailing_metadata=", grpc_rb_call_set_trailing_metadata, 1);
rb_define_method(grpc_rb_cCall, "write_flag", grpc_rb_call_get_write_flag, 0);
rb_define_method(grpc_rb_cCall, "write_flag=", grpc_rb_call_set_write_flag,
1);
@@ -1033,15 +1034,15 @@ void Init_grpc_call() {
}
/* Gets the call from the ruby object */
-grpc_call *grpc_rb_get_wrapped_call(VALUE v) {
- grpc_rb_call *call = NULL;
+grpc_call* grpc_rb_get_wrapped_call(VALUE v) {
+ grpc_rb_call* call = NULL;
TypedData_Get_Struct(v, grpc_rb_call, &grpc_call_data_type, call);
return call->wrapped;
}
/* Obtains the wrapped object for a given call */
-VALUE grpc_rb_wrap_call(grpc_call *c, grpc_completion_queue *q) {
- grpc_rb_call *wrapper;
+VALUE grpc_rb_wrap_call(grpc_call* c, grpc_completion_queue* q) {
+ grpc_rb_call* wrapper;
if (c == NULL || q == NULL) {
return Qnil;
}
diff --git a/src/ruby/ext/grpc/rb_call.h b/src/ruby/ext/grpc/rb_call.h
index bfe8035e0f..a2202eb8d3 100644
--- a/src/ruby/ext/grpc/rb_call.h
+++ b/src/ruby/ext/grpc/rb_call.h
@@ -24,24 +24,24 @@
#include <grpc/grpc.h>
/* Gets the wrapped call from a VALUE. */
-grpc_call *grpc_rb_get_wrapped_call(VALUE v);
+grpc_call* grpc_rb_get_wrapped_call(VALUE v);
/* Gets the VALUE corresponding to given grpc_call. */
-VALUE grpc_rb_wrap_call(grpc_call *c, grpc_completion_queue *q);
+VALUE grpc_rb_wrap_call(grpc_call* c, grpc_completion_queue* q);
/* Provides the details of an call error */
-const char *grpc_call_error_detail_of(grpc_call_error err);
+const char* grpc_call_error_detail_of(grpc_call_error err);
/* Converts a metadata array to a hash. */
-VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary);
+VALUE grpc_rb_md_ary_to_h(grpc_metadata_array* md_ary);
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
a grpc_metadata_array.
*/
-void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary);
+void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array* md_ary);
void grpc_rb_metadata_array_destroy_including_entries(
- grpc_metadata_array *md_ary);
+ grpc_metadata_array* md_ary);
/* grpc_rb_eCallError is the ruby class of the exception thrown during call
operations. */
diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c
index 049a869bdc..be32597592 100644
--- a/src/ruby/ext/grpc/rb_call_credentials.c
+++ b/src/ruby/ext/grpc/rb_call_credentials.c
@@ -44,13 +44,13 @@ typedef struct grpc_rb_call_credentials {
VALUE mark;
/* The actual credentials */
- grpc_call_credentials *wrapped;
+ grpc_call_credentials* wrapped;
} grpc_rb_call_credentials;
typedef struct callback_params {
VALUE get_metadata;
grpc_auth_metadata_context context;
- void *user_data;
+ void* user_data;
grpc_credentials_plugin_metadata_cb callback;
} callback_params;
@@ -82,8 +82,8 @@ static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
return result;
}
-static void grpc_rb_call_credentials_callback_with_gil(void *param) {
- callback_params *const params = (callback_params *)param;
+static void grpc_rb_call_credentials_callback_with_gil(void* param) {
+ callback_params* const params = (callback_params*)param;
VALUE auth_uri = rb_str_new_cstr(params->context.service_url);
/* Pass the arguments to the proc in a hash, which currently only has they key
'auth_uri' */
@@ -93,7 +93,7 @@ static void grpc_rb_call_credentials_callback_with_gil(void *param) {
grpc_metadata_array md_ary;
grpc_status_code status;
VALUE details;
- char *error_details;
+ char* error_details;
grpc_metadata_array_init(&md_ary);
rb_hash_aset(args, ID2SYM(rb_intern("jwt_aud_uri")), auth_uri);
rb_ary_push(callback_args, params->get_metadata);
@@ -112,31 +112,35 @@ static void grpc_rb_call_credentials_callback_with_gil(void *param) {
gpr_free(params);
}
-static void grpc_rb_call_credentials_plugin_get_metadata(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data) {
- callback_params *params = gpr_malloc(sizeof(callback_params));
+static int grpc_rb_call_credentials_plugin_get_metadata(
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
+ callback_params* params = gpr_malloc(sizeof(callback_params));
params->get_metadata = (VALUE)state;
params->context = context;
params->user_data = user_data;
params->callback = cb;
grpc_rb_event_queue_enqueue(grpc_rb_call_credentials_callback_with_gil,
- (void *)(params));
+ (void*)(params));
+ return 0; // Async return.
}
-static void grpc_rb_call_credentials_plugin_destroy(void *state) {
+static void grpc_rb_call_credentials_plugin_destroy(void* state) {
(void)state;
// Not sure what needs to be done here
}
/* Destroys the credentials instances. */
-static void grpc_rb_call_credentials_free(void *p) {
- grpc_rb_call_credentials *wrapper;
+static void grpc_rb_call_credentials_free(void* p) {
+ grpc_rb_call_credentials* wrapper;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_call_credentials *)p;
+ wrapper = (grpc_rb_call_credentials*)p;
grpc_call_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
@@ -144,12 +148,12 @@ static void grpc_rb_call_credentials_free(void *p) {
}
/* Protects the mark object from GC */
-static void grpc_rb_call_credentials_mark(void *p) {
- grpc_rb_call_credentials *wrapper = NULL;
+static void grpc_rb_call_credentials_mark(void* p) {
+ grpc_rb_call_credentials* wrapper = NULL;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_call_credentials *)p;
+ wrapper = (grpc_rb_call_credentials*)p;
if (wrapper->mark != Qnil) {
rb_gc_mark(wrapper->mark);
}
@@ -171,7 +175,7 @@ static rb_data_type_t grpc_rb_call_credentials_data_type = {
/* Allocates CallCredentials instances.
Provides safe initial defaults for the instance fields. */
static VALUE grpc_rb_call_credentials_alloc(VALUE cls) {
- grpc_rb_call_credentials *wrapper = ALLOC(grpc_rb_call_credentials);
+ grpc_rb_call_credentials* wrapper = ALLOC(grpc_rb_call_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_rb_call_credentials_data_type,
@@ -181,9 +185,9 @@ static VALUE grpc_rb_call_credentials_alloc(VALUE cls) {
/* Creates a wrapping object for a given call credentials. This should only be
* called with grpc_call_credentials objects that are not already associated
* with any Ruby object */
-VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials *c, VALUE mark) {
+VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials* c, VALUE mark) {
VALUE rb_wrapper;
- grpc_rb_call_credentials *wrapper;
+ grpc_rb_call_credentials* wrapper;
if (c == NULL) {
return Qnil;
}
@@ -204,8 +208,8 @@ static ID id_callback;
proc: (required) Proc that generates auth metadata
Initializes CallCredential instances. */
static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
- grpc_rb_call_credentials *wrapper = NULL;
- grpc_call_credentials *creds = NULL;
+ grpc_rb_call_credentials* wrapper = NULL;
+ grpc_call_credentials* creds = NULL;
grpc_metadata_credentials_plugin plugin;
grpc_ruby_once_init();
@@ -219,7 +223,7 @@ static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
rb_raise(rb_eTypeError, "Argument to CallCredentials#new must be a proc");
return Qnil;
}
- plugin.state = (void *)proc;
+ plugin.state = (void*)proc;
plugin.type = "";
creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL);
@@ -235,11 +239,11 @@ static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
return self;
}
-static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv,
+static VALUE grpc_rb_call_credentials_compose(int argc, VALUE* argv,
VALUE self) {
- grpc_call_credentials *creds;
- grpc_call_credentials *other;
- grpc_call_credentials *prev = NULL;
+ grpc_call_credentials* creds;
+ grpc_call_credentials* other;
+ grpc_call_credentials* prev = NULL;
VALUE mark;
if (argc == 0) {
return self;
@@ -278,8 +282,8 @@ void Init_grpc_call_credentials() {
}
/* Gets the wrapped grpc_call_credentials from the ruby wrapper */
-grpc_call_credentials *grpc_rb_get_wrapped_call_credentials(VALUE v) {
- grpc_rb_call_credentials *wrapper = NULL;
+grpc_call_credentials* grpc_rb_get_wrapped_call_credentials(VALUE v) {
+ grpc_rb_call_credentials* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_call_credentials,
&grpc_rb_call_credentials_data_type, wrapper);
return wrapper->wrapped;
diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c
index f0af54d9e5..1d11a53aa7 100644
--- a/src/ruby/ext/grpc/rb_channel.c
+++ b/src/ruby/ext/grpc/rb_channel.c
@@ -54,9 +54,9 @@ static VALUE grpc_rb_cChannel = Qnil;
static VALUE grpc_rb_cChannelArgs;
typedef struct bg_watched_channel {
- grpc_channel *channel;
+ grpc_channel* channel;
// these fields must only be accessed under global_connection_polling_mu
- struct bg_watched_channel *next;
+ struct bg_watched_channel* next;
int channel_destroyed;
int refcount;
} bg_watched_channel;
@@ -67,7 +67,7 @@ typedef struct grpc_rb_channel {
/* The actual channel (protected in a wrapper to tell when it's safe to
* destroy) */
- bg_watched_channel *bg_wrapped;
+ bg_watched_channel* bg_wrapped;
} grpc_rb_channel;
typedef enum { CONTINUOUS_WATCH, WATCH_STATE_API } watch_state_op_type;
@@ -82,40 +82,40 @@ typedef struct watch_state_op {
int called_back;
} api_callback_args;
struct {
- bg_watched_channel *bg;
+ bg_watched_channel* bg;
} continuous_watch_callback_args;
} op;
} watch_state_op;
-static bg_watched_channel *bg_watched_channel_list_head = NULL;
+static bg_watched_channel* bg_watched_channel_list_head = NULL;
static void grpc_rb_channel_try_register_connection_polling(
- bg_watched_channel *bg);
-static void *wait_until_channel_polling_thread_started_no_gil(void *);
-static void wait_until_channel_polling_thread_started_unblocking_func(void *);
-static void *channel_init_try_register_connection_polling_without_gil(
- void *arg);
+ bg_watched_channel* bg);
+static void* wait_until_channel_polling_thread_started_no_gil(void*);
+static void wait_until_channel_polling_thread_started_unblocking_func(void*);
+static void* channel_init_try_register_connection_polling_without_gil(
+ void* arg);
typedef struct channel_init_try_register_stack {
- grpc_channel *channel;
- grpc_rb_channel *wrapper;
+ grpc_channel* channel;
+ grpc_rb_channel* wrapper;
} channel_init_try_register_stack;
-static grpc_completion_queue *channel_polling_cq;
+static grpc_completion_queue* channel_polling_cq;
static gpr_mu global_connection_polling_mu;
static gpr_cv global_connection_polling_cv;
static int abort_channel_polling = 0;
static int channel_polling_thread_started = 0;
-static int bg_watched_channel_list_lookup(bg_watched_channel *bg);
-static bg_watched_channel *bg_watched_channel_list_create_and_add(
- grpc_channel *channel);
-static void bg_watched_channel_list_free_and_remove(bg_watched_channel *bg);
-static void run_poll_channels_loop_unblocking_func(void *arg);
+static int bg_watched_channel_list_lookup(bg_watched_channel* bg);
+static bg_watched_channel* bg_watched_channel_list_create_and_add(
+ grpc_channel* channel);
+static void bg_watched_channel_list_free_and_remove(bg_watched_channel* bg);
+static void run_poll_channels_loop_unblocking_func(void* arg);
// Needs to be called under global_connection_polling_mu
static void grpc_rb_channel_watch_connection_state_op_complete(
- watch_state_op *op, int success) {
+ watch_state_op* op, int success) {
GPR_ASSERT(!op->op.api_callback_args.called_back);
op->op.api_callback_args.called_back = 1;
op->op.api_callback_args.success = success;
@@ -124,7 +124,7 @@ static void grpc_rb_channel_watch_connection_state_op_complete(
}
/* Avoids destroying a channel twice. */
-static void grpc_rb_channel_safe_destroy(bg_watched_channel *bg) {
+static void grpc_rb_channel_safe_destroy(bg_watched_channel* bg) {
gpr_mu_lock(&global_connection_polling_mu);
GPR_ASSERT(bg_watched_channel_list_lookup(bg));
if (!bg->channel_destroyed) {
@@ -138,18 +138,18 @@ static void grpc_rb_channel_safe_destroy(bg_watched_channel *bg) {
gpr_mu_unlock(&global_connection_polling_mu);
}
-static void *channel_safe_destroy_without_gil(void *arg) {
- grpc_rb_channel_safe_destroy((bg_watched_channel *)arg);
+static void* channel_safe_destroy_without_gil(void* arg) {
+ grpc_rb_channel_safe_destroy((bg_watched_channel*)arg);
return NULL;
}
/* Destroys Channel instances. */
-static void grpc_rb_channel_free(void *p) {
- grpc_rb_channel *ch = NULL;
+static void grpc_rb_channel_free(void* p) {
+ grpc_rb_channel* ch = NULL;
if (p == NULL) {
return;
};
- ch = (grpc_rb_channel *)p;
+ ch = (grpc_rb_channel*)p;
if (ch->bg_wrapped != NULL) {
/* assumption made here: it's ok to directly gpr_mu_lock the global
@@ -164,12 +164,12 @@ static void grpc_rb_channel_free(void *p) {
}
/* Protects the mark object from GC */
-static void grpc_rb_channel_mark(void *p) {
- grpc_rb_channel *channel = NULL;
+static void grpc_rb_channel_mark(void* p) {
+ grpc_rb_channel* channel = NULL;
if (p == NULL) {
return;
}
- channel = (grpc_rb_channel *)p;
+ channel = (grpc_rb_channel*)p;
if (channel->credentials != Qnil) {
rb_gc_mark(channel->credentials);
}
@@ -189,7 +189,7 @@ static rb_data_type_t grpc_channel_data_type = {"grpc_channel",
/* Allocates grpc_rb_channel instances. */
static VALUE grpc_rb_channel_alloc(VALUE cls) {
- grpc_rb_channel *wrapper = ALLOC(grpc_rb_channel);
+ grpc_rb_channel* wrapper = ALLOC(grpc_rb_channel);
wrapper->bg_wrapped = NULL;
wrapper->credentials = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_channel_data_type, wrapper);
@@ -203,14 +203,14 @@ static VALUE grpc_rb_channel_alloc(VALUE cls) {
secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds)
Creates channel instances. */
-static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
+static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
VALUE channel_args = Qnil;
VALUE credentials = Qnil;
VALUE target = Qnil;
- grpc_rb_channel *wrapper = NULL;
- grpc_channel *ch = NULL;
- grpc_channel_credentials *creds = NULL;
- char *target_chars = NULL;
+ grpc_rb_channel* wrapper = NULL;
+ grpc_channel* ch = NULL;
+ grpc_channel_credentials* creds = NULL;
+ char* target_chars = NULL;
grpc_channel_args args;
channel_init_try_register_stack stack;
int stop_waiting_for_thread_start = 0;
@@ -262,13 +262,13 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
}
typedef struct get_state_stack {
- bg_watched_channel *bg;
+ bg_watched_channel* bg;
int try_to_connect;
int out;
} get_state_stack;
-static void *get_state_without_gil(void *arg) {
- get_state_stack *stack = (get_state_stack *)arg;
+static void* get_state_without_gil(void* arg) {
+ get_state_stack* stack = (get_state_stack*)arg;
gpr_mu_lock(&global_connection_polling_mu);
GPR_ASSERT(abort_channel_polling || channel_polling_thread_started);
@@ -292,10 +292,10 @@ static void *get_state_without_gil(void *arg) {
constants defined in GRPC::Core::ConnectivityStates.
It also tries to connect if the chennel is idle in the second form. */
-static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
+static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
VALUE self) {
VALUE try_to_connect_param = Qfalse;
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
get_state_stack stack;
/* "01" == 0 mandatory args, 1 (try_to_connect) is optional */
@@ -315,22 +315,22 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
}
typedef struct watch_state_stack {
- grpc_channel *channel;
+ grpc_channel* channel;
gpr_timespec deadline;
int last_state;
} watch_state_stack;
-static void *wait_for_watch_state_op_complete_without_gvl(void *arg) {
- watch_state_stack *stack = (watch_state_stack *)arg;
- watch_state_op *op = NULL;
- void *success = (void *)0;
+static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
+ watch_state_stack* stack = (watch_state_stack*)arg;
+ watch_state_op* op = NULL;
+ void* success = (void*)0;
gpr_mu_lock(&global_connection_polling_mu);
// its unsafe to do a "watch" after "channel polling abort" because the cq has
// been shut down.
if (abort_channel_polling) {
gpr_mu_unlock(&global_connection_polling_mu);
- return (void *)0;
+ return (void*)0;
}
op = gpr_zalloc(sizeof(watch_state_op));
op->op_type = WATCH_STATE_API;
@@ -343,15 +343,15 @@ static void *wait_for_watch_state_op_complete_without_gvl(void *arg) {
gpr_inf_future(GPR_CLOCK_REALTIME));
}
if (op->op.api_callback_args.success) {
- success = (void *)1;
+ success = (void*)1;
}
gpr_free(op);
gpr_mu_unlock(&global_connection_polling_mu);
return success;
}
-static void wait_for_watch_state_op_complete_unblocking_func(void *arg) {
- bg_watched_channel *bg = (bg_watched_channel *)arg;
+static void wait_for_watch_state_op_complete_unblocking_func(void* arg) {
+ bg_watched_channel* bg = (bg_watched_channel*)arg;
gpr_mu_lock(&global_connection_polling_mu);
if (!bg->channel_destroyed) {
grpc_channel_destroy(bg->channel);
@@ -370,9 +370,9 @@ static void wait_for_watch_state_op_complete_unblocking_func(void *arg) {
static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
VALUE last_state,
VALUE deadline) {
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
watch_state_stack stack;
- void *op_success = 0;
+ void* op_success = 0;
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
@@ -405,15 +405,15 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
VALUE method, VALUE host,
VALUE deadline) {
VALUE res = Qnil;
- grpc_rb_channel *wrapper = NULL;
- grpc_call *call = NULL;
- grpc_call *parent_call = NULL;
- grpc_completion_queue *cq = NULL;
+ grpc_rb_channel* wrapper = NULL;
+ grpc_call* call = NULL;
+ grpc_call* parent_call = NULL;
+ grpc_completion_queue* cq = NULL;
int flags = GRPC_PROPAGATE_DEFAULTS;
grpc_slice method_slice;
grpc_slice host_slice;
- grpc_slice *host_slice_ptr = NULL;
- char *tmp_str = NULL;
+ grpc_slice* host_slice_ptr = NULL;
+ char* tmp_str = NULL;
if (host != Qnil) {
host_slice =
@@ -466,7 +466,7 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
/* Note this is an API-level call; a wrapped channel's finalizer doesn't call
* this */
static VALUE grpc_rb_channel_destroy(VALUE self) {
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
if (wrapper->bg_wrapped != NULL) {
@@ -480,9 +480,9 @@ static VALUE grpc_rb_channel_destroy(VALUE self) {
/* Called to obtain the target that this channel accesses. */
static VALUE grpc_rb_channel_get_target(VALUE self) {
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
VALUE res = Qnil;
- char *target = NULL;
+ char* target = NULL;
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
target = grpc_channel_get_target(wrapper->bg_wrapped->channel);
@@ -493,8 +493,8 @@ static VALUE grpc_rb_channel_get_target(VALUE self) {
}
/* Needs to be called under global_connection_polling_mu */
-static int bg_watched_channel_list_lookup(bg_watched_channel *target) {
- bg_watched_channel *cur = bg_watched_channel_list_head;
+static int bg_watched_channel_list_lookup(bg_watched_channel* target) {
+ bg_watched_channel* cur = bg_watched_channel_list_head;
while (cur != NULL) {
if (cur == target) {
@@ -507,9 +507,9 @@ static int bg_watched_channel_list_lookup(bg_watched_channel *target) {
}
/* Needs to be called under global_connection_polling_mu */
-static bg_watched_channel *bg_watched_channel_list_create_and_add(
- grpc_channel *channel) {
- bg_watched_channel *watched = gpr_zalloc(sizeof(bg_watched_channel));
+static bg_watched_channel* bg_watched_channel_list_create_and_add(
+ grpc_channel* channel) {
+ bg_watched_channel* watched = gpr_zalloc(sizeof(bg_watched_channel));
watched->channel = channel;
watched->next = bg_watched_channel_list_head;
@@ -520,8 +520,8 @@ static bg_watched_channel *bg_watched_channel_list_create_and_add(
/* Needs to be called under global_connection_polling_mu */
static void bg_watched_channel_list_free_and_remove(
- bg_watched_channel *target) {
- bg_watched_channel *bg = NULL;
+ bg_watched_channel* target) {
+ bg_watched_channel* bg = NULL;
GPR_ASSERT(bg_watched_channel_list_lookup(target));
GPR_ASSERT(target->channel_destroyed && target->refcount == 0);
@@ -544,10 +544,10 @@ static void bg_watched_channel_list_free_and_remove(
/* Initialize a grpc_rb_channel's "protected grpc_channel" and try to push
* it onto the background thread for constant watches. */
-static void *channel_init_try_register_connection_polling_without_gil(
- void *arg) {
- channel_init_try_register_stack *stack =
- (channel_init_try_register_stack *)arg;
+static void* channel_init_try_register_connection_polling_without_gil(
+ void* arg) {
+ channel_init_try_register_stack* stack =
+ (channel_init_try_register_stack*)arg;
gpr_mu_lock(&global_connection_polling_mu);
stack->wrapper->bg_wrapped =
@@ -559,9 +559,9 @@ static void *channel_init_try_register_connection_polling_without_gil(
// Needs to be called under global_connection_poolling_mu
static void grpc_rb_channel_try_register_connection_polling(
- bg_watched_channel *bg) {
+ bg_watched_channel* bg) {
grpc_connectivity_state conn_state;
- watch_state_op *op = NULL;
+ watch_state_op* op = NULL;
GPR_ASSERT(channel_polling_thread_started || abort_channel_polling);
@@ -597,10 +597,10 @@ static void grpc_rb_channel_try_register_connection_polling(
// indicates process shutdown.
// In the worst case, this stops polling channel connectivity
// early and falls back to current behavior.
-static void *run_poll_channels_loop_no_gil(void *arg) {
+static void* run_poll_channels_loop_no_gil(void* arg) {
grpc_event event;
- watch_state_op *op = NULL;
- bg_watched_channel *bg = NULL;
+ watch_state_op* op = NULL;
+ bg_watched_channel* bg = NULL;
(void)arg;
gpr_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop_no_gil - begin");
@@ -618,15 +618,15 @@ static void *run_poll_channels_loop_no_gil(void *arg) {
}
gpr_mu_lock(&global_connection_polling_mu);
if (event.type == GRPC_OP_COMPLETE) {
- op = (watch_state_op *)event.tag;
+ op = (watch_state_op*)event.tag;
if (op->op_type == CONTINUOUS_WATCH) {
- bg = (bg_watched_channel *)op->op.continuous_watch_callback_args.bg;
+ bg = (bg_watched_channel*)op->op.continuous_watch_callback_args.bg;
bg->refcount--;
grpc_rb_channel_try_register_connection_polling(bg);
gpr_free(op);
} else if (op->op_type == WATCH_STATE_API) {
grpc_rb_channel_watch_connection_state_op_complete(
- (watch_state_op *)event.tag, event.success);
+ (watch_state_op*)event.tag, event.success);
} else {
GPR_ASSERT(0);
}
@@ -641,8 +641,8 @@ static void *run_poll_channels_loop_no_gil(void *arg) {
}
// Notify the channel polling loop to cleanup and shutdown.
-static void run_poll_channels_loop_unblocking_func(void *arg) {
- bg_watched_channel *bg = NULL;
+static void run_poll_channels_loop_unblocking_func(void* arg) {
+ bg_watched_channel* bg = NULL;
(void)arg;
gpr_mu_lock(&global_connection_polling_mu);
@@ -686,8 +686,8 @@ static VALUE run_poll_channels_loop(VALUE arg) {
return Qnil;
}
-static void *wait_until_channel_polling_thread_started_no_gil(void *arg) {
- int *stop_waiting = (int *)arg;
+static void* wait_until_channel_polling_thread_started_no_gil(void* arg) {
+ int* stop_waiting = (int*)arg;
gpr_log(GPR_DEBUG, "GRPC_RUBY: wait for channel polling thread to start");
gpr_mu_lock(&global_connection_polling_mu);
while (!channel_polling_thread_started && !abort_channel_polling &&
@@ -701,8 +701,8 @@ static void *wait_until_channel_polling_thread_started_no_gil(void *arg) {
}
static void wait_until_channel_polling_thread_started_unblocking_func(
- void *arg) {
- int *stop_waiting = (int *)arg;
+ void* arg) {
+ int* stop_waiting = (int*)arg;
gpr_mu_lock(&global_connection_polling_mu);
gpr_log(GPR_DEBUG,
"GRPC_RUBY: interrupt wait for channel polling thread to start");
@@ -711,7 +711,7 @@ static void wait_until_channel_polling_thread_started_unblocking_func(
gpr_mu_unlock(&global_connection_polling_mu);
}
-static void *set_abort_channel_polling_without_gil(void *arg) {
+static void* set_abort_channel_polling_without_gil(void* arg) {
(void)arg;
gpr_mu_lock(&global_connection_polling_mu);
abort_channel_polling = 1;
@@ -822,8 +822,8 @@ void Init_grpc_channel() {
}
/* Gets the wrapped channel from the ruby wrapper */
-grpc_channel *grpc_rb_get_wrapped_channel(VALUE v) {
- grpc_rb_channel *wrapper = NULL;
+grpc_channel* grpc_rb_get_wrapped_channel(VALUE v) {
+ grpc_rb_channel* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_channel, &grpc_channel_data_type, wrapper);
return wrapper->bg_wrapped->channel;
}
diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c
index 83601ca694..b23a32caf1 100644
--- a/src/ruby/ext/grpc/rb_channel_credentials.c
+++ b/src/ruby/ext/grpc/rb_channel_credentials.c
@@ -35,7 +35,7 @@
grpc_channel_credentials. */
static VALUE grpc_rb_cChannelCredentials = Qnil;
-static char *pem_root_certs = NULL;
+static char* pem_root_certs = NULL;
/* grpc_rb_channel_credentials wraps a grpc_channel_credentials. It provides a
* mark object that is used to hold references to any objects used to create
@@ -45,16 +45,16 @@ typedef struct grpc_rb_channel_credentials {
VALUE mark;
/* The actual credentials */
- grpc_channel_credentials *wrapped;
+ grpc_channel_credentials* wrapped;
} grpc_rb_channel_credentials;
/* Destroys the credentials instances. */
-static void grpc_rb_channel_credentials_free(void *p) {
- grpc_rb_channel_credentials *wrapper = NULL;
+static void grpc_rb_channel_credentials_free(void* p) {
+ grpc_rb_channel_credentials* wrapper = NULL;
if (p == NULL) {
return;
};
- wrapper = (grpc_rb_channel_credentials *)p;
+ wrapper = (grpc_rb_channel_credentials*)p;
grpc_channel_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
@@ -62,12 +62,12 @@ static void grpc_rb_channel_credentials_free(void *p) {
}
/* Protects the mark object from GC */
-static void grpc_rb_channel_credentials_mark(void *p) {
- grpc_rb_channel_credentials *wrapper = NULL;
+static void grpc_rb_channel_credentials_mark(void* p) {
+ grpc_rb_channel_credentials* wrapper = NULL;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_channel_credentials *)p;
+ wrapper = (grpc_rb_channel_credentials*)p;
if (wrapper->mark != Qnil) {
rb_gc_mark(wrapper->mark);
@@ -90,7 +90,7 @@ static rb_data_type_t grpc_rb_channel_credentials_data_type = {
/* Allocates ChannelCredential instances.
Provides safe initial defaults for the instance fields. */
static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
- grpc_rb_channel_credentials *wrapper = ALLOC(grpc_rb_channel_credentials);
+ grpc_rb_channel_credentials* wrapper = ALLOC(grpc_rb_channel_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_rb_channel_credentials_data_type,
@@ -100,10 +100,10 @@ static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
/* Creates a wrapping object for a given channel credentials. This should only
* be called with grpc_channel_credentials objects that are not already
* associated with any Ruby object. */
-VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials *c,
+VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials* c,
VALUE mark) {
VALUE rb_wrapper;
- grpc_rb_channel_credentials *wrapper;
+ grpc_rb_channel_credentials* wrapper;
if (c == NULL) {
return Qnil;
}
@@ -136,15 +136,15 @@ static ID id_pem_cert_chain;
pem_private_key: (optional) PEM encoding of the client's private key
pem_cert_chain: (optional) PEM encoding of the client's cert chain
Initializes Credential instances. */
-static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv,
+static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv,
VALUE self) {
VALUE pem_root_certs = Qnil;
VALUE pem_private_key = Qnil;
VALUE pem_cert_chain = Qnil;
- grpc_rb_channel_credentials *wrapper = NULL;
- grpc_channel_credentials *creds = NULL;
+ grpc_rb_channel_credentials* wrapper = NULL;
+ grpc_channel_credentials* creds = NULL;
grpc_ssl_pem_key_cert_pair key_cert_pair;
- const char *pem_root_certs_cstr = NULL;
+ const char* pem_root_certs_cstr = NULL;
MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
grpc_ruby_once_init();
@@ -180,11 +180,11 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv,
return self;
}
-static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
+static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE* argv,
VALUE self) {
- grpc_channel_credentials *creds;
- grpc_call_credentials *other;
- grpc_channel_credentials *prev = NULL;
+ grpc_channel_credentials* creds;
+ grpc_call_credentials* other;
+ grpc_channel_credentials* prev = NULL;
VALUE mark;
if (argc == 0) {
return self;
@@ -210,7 +210,7 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
}
static grpc_ssl_roots_override_result get_ssl_roots_override(
- char **pem_root_certs_ptr) {
+ char** pem_root_certs_ptr) {
*pem_root_certs_ptr = pem_root_certs;
if (pem_root_certs == NULL) {
return GRPC_SSL_ROOTS_OVERRIDE_FAIL;
@@ -220,7 +220,7 @@ static grpc_ssl_roots_override_result get_ssl_roots_override(
}
static VALUE grpc_rb_set_default_roots_pem(VALUE self, VALUE roots) {
- char *roots_ptr = StringValueCStr(roots);
+ char* roots_ptr = StringValueCStr(roots);
size_t length = strlen(roots_ptr);
(void)self;
pem_root_certs = gpr_malloc((length + 1) * sizeof(char));
@@ -255,8 +255,8 @@ void Init_grpc_channel_credentials() {
}
/* Gets the wrapped grpc_channel_credentials from the ruby wrapper */
-grpc_channel_credentials *grpc_rb_get_wrapped_channel_credentials(VALUE v) {
- grpc_rb_channel_credentials *wrapper = NULL;
+grpc_channel_credentials* grpc_rb_get_wrapped_channel_credentials(VALUE v) {
+ grpc_rb_channel_credentials* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_channel_credentials,
&grpc_rb_channel_credentials_data_type, wrapper);
return wrapper->wrapped;
diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c
index 4283c27429..64264f5b15 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.c
+++ b/src/ruby/ext/grpc/rb_completion_queue.c
@@ -30,16 +30,16 @@
/* Used to allow grpc_completion_queue_next call to release the GIL */
typedef struct next_call_stack {
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
grpc_event event;
gpr_timespec timeout;
- void *tag;
+ void* tag;
volatile int interrupted;
} next_call_stack;
/* Calls grpc_completion_queue_pluck without holding the ruby GIL */
-static void *grpc_rb_completion_queue_pluck_no_gil(void *param) {
- next_call_stack *const next_call = (next_call_stack *)param;
+static void* grpc_rb_completion_queue_pluck_no_gil(void* param) {
+ next_call_stack* const next_call = (next_call_stack*)param;
gpr_timespec increment = gpr_time_from_millis(20, GPR_TIMESPAN);
gpr_timespec deadline;
do {
@@ -55,7 +55,7 @@ static void *grpc_rb_completion_queue_pluck_no_gil(void *param) {
}
/* Helper function to free a completion queue. */
-void grpc_rb_completion_queue_destroy(grpc_completion_queue *cq) {
+void grpc_rb_completion_queue_destroy(grpc_completion_queue* cq) {
/* Every function that adds an event to a queue also synchronously plucks
that event from the queue, and holds a reference to the Ruby object that
holds the queue, so we only get to this point if all of those functions
@@ -64,15 +64,15 @@ void grpc_rb_completion_queue_destroy(grpc_completion_queue *cq) {
grpc_completion_queue_destroy(cq);
}
-static void unblock_func(void *param) {
- next_call_stack *const next_call = (next_call_stack *)param;
+static void unblock_func(void* param) {
+ next_call_stack* const next_call = (next_call_stack*)param;
next_call->interrupted = 1;
}
/* Does the same thing as grpc_completion_queue_pluck, while properly releasing
the GVL and handling interrupts */
-grpc_event rb_completion_queue_pluck(grpc_completion_queue *queue, void *tag,
- gpr_timespec deadline, void *reserved) {
+grpc_event rb_completion_queue_pluck(grpc_completion_queue* queue, void* tag,
+ gpr_timespec deadline, void* reserved) {
next_call_stack next_call;
MEMZERO(&next_call, next_call_stack, 1);
next_call.cq = queue;
@@ -91,8 +91,8 @@ grpc_event rb_completion_queue_pluck(grpc_completion_queue *queue, void *tag,
do {
next_call.interrupted = 0;
rb_thread_call_without_gvl(grpc_rb_completion_queue_pluck_no_gil,
- (void *)&next_call, unblock_func,
- (void *)&next_call);
+ (void*)&next_call, unblock_func,
+ (void*)&next_call);
/* If an interrupt prevented pluck from returning useful information, then
any plucks that did complete must have timed out */
} while (next_call.interrupted && next_call.event.type == GRPC_QUEUE_TIMEOUT);
diff --git a/src/ruby/ext/grpc/rb_completion_queue.h b/src/ruby/ext/grpc/rb_completion_queue.h
index 011b849e3f..8c29089b9b 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.h
+++ b/src/ruby/ext/grpc/rb_completion_queue.h
@@ -23,14 +23,14 @@
#include <grpc/grpc.h>
-void grpc_rb_completion_queue_destroy(grpc_completion_queue *cq);
+void grpc_rb_completion_queue_destroy(grpc_completion_queue* cq);
/**
* Makes the implementation of CompletionQueue#pluck available in other files
*
* This avoids having code that holds the GIL repeated at multiple sites.
*/
-grpc_event rb_completion_queue_pluck(grpc_completion_queue *queue, void *tag,
- gpr_timespec deadline, void *reserved);
+grpc_event rb_completion_queue_pluck(grpc_completion_queue* queue, void* tag,
+ gpr_timespec deadline, void* reserved);
#endif /* GRPC_RB_COMPLETION_QUEUE_H_ */
diff --git a/src/ruby/ext/grpc/rb_compression_options.c b/src/ruby/ext/grpc/rb_compression_options.c
index 3365b1784d..a7e37099af 100644
--- a/src/ruby/ext/grpc/rb_compression_options.c
+++ b/src/ruby/ext/grpc/rb_compression_options.c
@@ -23,6 +23,7 @@
#include "rb_grpc_imports.generated.h"
#include <grpc/compression.h>
+#include <grpc/compression_ruby.h>
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/grpc_types.h>
@@ -47,17 +48,17 @@ static VALUE id_compress_level_high = Qnil;
* Ruby objects and don't have a mark for GC. */
typedef struct grpc_rb_compression_options {
/* The actual compression options that's being wrapped */
- grpc_compression_options *wrapped;
+ grpc_compression_options* wrapped;
} grpc_rb_compression_options;
/* Destroys the compression options instances and free the
* wrapped grpc compression options. */
-static void grpc_rb_compression_options_free(void *p) {
- grpc_rb_compression_options *wrapper = NULL;
+static void grpc_rb_compression_options_free(void* p) {
+ grpc_rb_compression_options* wrapper = NULL;
if (p == NULL) {
return;
};
- wrapper = (grpc_rb_compression_options *)p;
+ wrapper = (grpc_rb_compression_options*)p;
if (wrapper->wrapped != NULL) {
gpr_free(wrapper->wrapped);
@@ -85,7 +86,7 @@ static rb_data_type_t grpc_rb_compression_options_data_type = {
Allocate the wrapped grpc compression options and
initialize it here too. */
static VALUE grpc_rb_compression_options_alloc(VALUE cls) {
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
grpc_ruby_once_init();
@@ -103,7 +104,7 @@ static VALUE grpc_rb_compression_options_alloc(VALUE cls) {
VALUE grpc_rb_compression_options_disable_compression_algorithm_internal(
VALUE self, VALUE algorithm_to_disable) {
grpc_compression_algorithm compression_algorithm = 0;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -145,7 +146,7 @@ grpc_compression_level grpc_rb_compression_options_level_name_to_value_internal(
/* Sets the default compression level, given the name of a compression level.
* Throws an error if no algorithm matched. */
void grpc_rb_compression_options_set_default_level(
- grpc_compression_options *options, VALUE new_level_name) {
+ grpc_compression_options* options, VALUE new_level_name) {
options->default_level.level =
grpc_rb_compression_options_level_name_to_value_internal(new_level_name);
options->default_level.is_set = 1;
@@ -156,10 +157,10 @@ void grpc_rb_compression_options_set_default_level(
* algorithm_value is an out parameter.
* Raises an error if the name of the algorithm passed in is invalid. */
void grpc_rb_compression_options_algorithm_name_to_value_internal(
- grpc_compression_algorithm *algorithm_value, VALUE algorithm_name) {
+ grpc_compression_algorithm* algorithm_value, VALUE algorithm_name) {
grpc_slice name_slice;
VALUE algorithm_name_as_string = Qnil;
- char *tmp_str = NULL;
+ char* tmp_str = NULL;
Check_Type(algorithm_name, T_SYMBOL);
@@ -174,7 +175,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(name_slice, algorithm_value)) {
+ if (!grpc_compression_algorithm_parse_ruby(name_slice, algorithm_value)) {
tmp_str = grpc_slice_to_c_string(name_slice);
rb_raise(rb_eNameError, "Invalid compression algorithm name: %s", tmp_str);
}
@@ -186,7 +187,7 @@ void grpc_rb_compression_options_algorithm_name_to_value_internal(
* readable algorithm name. */
VALUE grpc_rb_compression_options_is_algorithm_enabled(VALUE self,
VALUE algorithm_name) {
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
grpc_compression_algorithm internal_algorithm_value;
TypedData_Get_Struct(self, grpc_rb_compression_options,
@@ -204,7 +205,7 @@ VALUE grpc_rb_compression_options_is_algorithm_enabled(VALUE self,
/* Sets the default algorithm to the name of the algorithm passed in.
* Raises an error if the name is not a valid compression algorithm name. */
void grpc_rb_compression_options_set_default_algorithm(
- grpc_compression_options *options, VALUE algorithm_name) {
+ grpc_compression_options* options, VALUE algorithm_name) {
grpc_rb_compression_options_algorithm_name_to_value_internal(
&options->default_algorithm.algorithm, algorithm_name);
options->default_algorithm.is_set = 1;
@@ -214,7 +215,7 @@ void grpc_rb_compression_options_set_default_algorithm(
* algorithm.
* Fails if the algorithm name is invalid. */
void grpc_rb_compression_options_disable_algorithm(
- grpc_compression_options *compression_options, VALUE algorithm_name) {
+ grpc_compression_options* compression_options, VALUE algorithm_name) {
grpc_compression_algorithm internal_algorithm_value;
grpc_rb_compression_options_algorithm_name_to_value_internal(
@@ -226,8 +227,8 @@ void grpc_rb_compression_options_disable_algorithm(
/* Provides a ruby hash of GRPC core channel argument key-values that
* correspond to the compression settings on this instance. */
VALUE grpc_rb_compression_options_to_hash(VALUE self) {
- grpc_rb_compression_options *wrapper = NULL;
- grpc_compression_options *compression_options = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
+ grpc_compression_options* compression_options = NULL;
VALUE channel_arg_hash = rb_hash_new();
VALUE key = Qnil;
VALUE value = Qnil;
@@ -284,9 +285,9 @@ VALUE grpc_rb_compression_options_level_value_to_name_internal(
* Fails if the enum value is invalid. */
VALUE grpc_rb_compression_options_algorithm_value_to_name_internal(
grpc_compression_algorithm internal_value) {
- char *algorithm_name = NULL;
+ char* algorithm_name = NULL;
- if (!grpc_compression_algorithm_name(internal_value, &algorithm_name)) {
+ if (!grpc_compression_algorithm_name_ruby(internal_value, &algorithm_name)) {
rb_raise(rb_eArgError, "Failed to convert algorithm value to name");
}
@@ -297,7 +298,7 @@ VALUE grpc_rb_compression_options_algorithm_value_to_name_internal(
* Returns nil if no algorithm has been set. */
VALUE grpc_rb_compression_options_get_default_algorithm(VALUE self) {
grpc_compression_algorithm internal_value;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -316,7 +317,7 @@ VALUE grpc_rb_compression_options_get_default_algorithm(VALUE self) {
* A nil return value means that it hasn't been set. */
VALUE grpc_rb_compression_options_get_default_level(VALUE self) {
grpc_compression_level internal_value;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -335,7 +336,7 @@ VALUE grpc_rb_compression_options_get_default_level(VALUE self) {
VALUE grpc_rb_compression_options_get_disabled_algorithms(VALUE self) {
VALUE disabled_algorithms = rb_ary_new();
grpc_compression_algorithm internal_value;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -363,8 +364,8 @@ VALUE grpc_rb_compression_options_get_disabled_algorithms(VALUE self) {
* channel_arg hash = Hash.new[...]
* channel_arg_hash_with_compression_options = channel_arg_hash.merge(options)
*/
-VALUE grpc_rb_compression_options_init(int argc, VALUE *argv, VALUE self) {
- grpc_rb_compression_options *wrapper = NULL;
+VALUE grpc_rb_compression_options_init(int argc, VALUE* argv, VALUE self) {
+ grpc_rb_compression_options* wrapper = NULL;
VALUE default_algorithm = Qnil;
VALUE default_level = Qnil;
VALUE disabled_algorithms = Qnil;
diff --git a/src/ruby/ext/grpc/rb_event_thread.c b/src/ruby/ext/grpc/rb_event_thread.c
index b0bcb6f31e..281e41c9a8 100644
--- a/src/ruby/ext/grpc/rb_event_thread.c
+++ b/src/ruby/ext/grpc/rb_event_thread.c
@@ -31,15 +31,15 @@
typedef struct grpc_rb_event {
// callback will be called with argument while holding the GVL
- void (*callback)(void *);
- void *argument;
+ void (*callback)(void*);
+ void* argument;
- struct grpc_rb_event *next;
+ struct grpc_rb_event* next;
} grpc_rb_event;
typedef struct grpc_rb_event_queue {
- grpc_rb_event *head;
- grpc_rb_event *tail;
+ grpc_rb_event* head;
+ grpc_rb_event* tail;
gpr_mu mu;
gpr_cv cv;
@@ -50,8 +50,8 @@ typedef struct grpc_rb_event_queue {
static grpc_rb_event_queue event_queue;
-void grpc_rb_event_queue_enqueue(void (*callback)(void *), void *argument) {
- grpc_rb_event *event = gpr_malloc(sizeof(grpc_rb_event));
+void grpc_rb_event_queue_enqueue(void (*callback)(void*), void* argument) {
+ grpc_rb_event* event = gpr_malloc(sizeof(grpc_rb_event));
event->callback = callback;
event->argument = argument;
event->next = NULL;
@@ -66,8 +66,8 @@ void grpc_rb_event_queue_enqueue(void (*callback)(void *), void *argument) {
gpr_mu_unlock(&event_queue.mu);
}
-static grpc_rb_event *grpc_rb_event_queue_dequeue() {
- grpc_rb_event *event;
+static grpc_rb_event* grpc_rb_event_queue_dequeue() {
+ grpc_rb_event* event;
if (event_queue.head == NULL) {
event = NULL;
} else {
@@ -86,8 +86,8 @@ static void grpc_rb_event_queue_destroy() {
gpr_cv_destroy(&event_queue.cv);
}
-static void *grpc_rb_wait_for_event_no_gil(void *param) {
- grpc_rb_event *event = NULL;
+static void* grpc_rb_wait_for_event_no_gil(void* param) {
+ grpc_rb_event* event = NULL;
(void)param;
gpr_mu_lock(&event_queue.mu);
while (!event_queue.abort) {
@@ -102,7 +102,7 @@ static void *grpc_rb_wait_for_event_no_gil(void *param) {
return NULL;
}
-static void grpc_rb_event_unblocking_func(void *arg) {
+static void grpc_rb_event_unblocking_func(void* arg) {
(void)arg;
gpr_mu_lock(&event_queue.mu);
event_queue.abort = true;
@@ -113,10 +113,10 @@ static void grpc_rb_event_unblocking_func(void *arg) {
/* This is the implementation of the thread that handles auth metadata plugin
* events */
static VALUE grpc_rb_event_thread(VALUE arg) {
- grpc_rb_event *event;
+ grpc_rb_event* event;
(void)arg;
while (true) {
- event = (grpc_rb_event *)rb_thread_call_without_gvl(
+ event = (grpc_rb_event*)rb_thread_call_without_gvl(
grpc_rb_wait_for_event_no_gil, NULL, grpc_rb_event_unblocking_func,
NULL);
if (event == NULL) {
diff --git a/src/ruby/ext/grpc/rb_event_thread.h b/src/ruby/ext/grpc/rb_event_thread.h
index 5bfecb9a68..fa9c14e169 100644
--- a/src/ruby/ext/grpc/rb_event_thread.h
+++ b/src/ruby/ext/grpc/rb_event_thread.h
@@ -18,4 +18,4 @@
void grpc_rb_event_queue_thread_start();
-void grpc_rb_event_queue_enqueue(void (*callback)(void *), void *argument);
+void grpc_rb_event_queue_enqueue(void (*callback)(void*), void* argument);
diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c
index 933a3ac152..f065a857db 100644
--- a/src/ruby/ext/grpc/rb_grpc.c
+++ b/src/ruby/ext/grpc/rb_grpc.c
@@ -90,9 +90,9 @@ static ID id_tv_nsec;
*/
gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) {
gpr_timespec t;
- gpr_timespec *time_const;
- const char *tstr = interval ? "time interval" : "time";
- const char *want = " want <secs from epoch>|<Time>|<GRPC::TimeConst.*>";
+ gpr_timespec* time_const;
+ const char* tstr = interval ? "time interval" : "time";
+ const char* want = " want <secs from epoch>|<Time>|<GRPC::TimeConst.*>";
t.clock_type = GPR_CLOCK_REALTIME;
switch (TYPE(time)) {
@@ -201,7 +201,7 @@ static ID id_to_s;
/* Converts a wrapped time constant to a standard time. */
static VALUE grpc_rb_time_val_to_time(VALUE self) {
- gpr_timespec *time_const = NULL;
+ gpr_timespec* time_const = NULL;
gpr_timespec real_time;
TypedData_Get_Struct(self, gpr_timespec, &grpc_rb_timespec_data_type,
time_const);
@@ -236,15 +236,15 @@ static void Init_grpc_time_consts() {
rb_define_const(
grpc_rb_mTimeConsts, "ZERO",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&zero_realtime));
+ (void*)&zero_realtime));
rb_define_const(
grpc_rb_mTimeConsts, "INFINITE_FUTURE",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&inf_future_realtime));
+ (void*)&inf_future_realtime));
rb_define_const(
grpc_rb_mTimeConsts, "INFINITE_PAST",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&inf_past_realtime));
+ (void*)&inf_past_realtime));
rb_define_method(grpc_rb_cTimeVal, "to_time", grpc_rb_time_val_to_time, 0);
rb_define_method(grpc_rb_cTimeVal, "inspect", grpc_rb_time_val_inspect, 0);
rb_define_method(grpc_rb_cTimeVal, "to_s", grpc_rb_time_val_to_s, 0);
@@ -315,8 +315,8 @@ void Init_grpc_c() {
return;
}
- bg_thread_init_rb_mu = rb_mutex_new();
rb_global_variable(&bg_thread_init_rb_mu);
+ bg_thread_init_rb_mu = rb_mutex_new();
grpc_rb_mGRPC = rb_define_module("GRPC");
grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index 70831494fa..5473c52bb5 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -22,44 +22,17 @@
#include "rb_grpc_imports.generated.h"
-census_initialize_type census_initialize_import;
-census_shutdown_type census_shutdown_import;
-census_supported_type census_supported_import;
-census_enabled_type census_enabled_import;
-census_context_create_type census_context_create_import;
-census_context_destroy_type census_context_destroy_import;
-census_context_get_status_type census_context_get_status_import;
-census_context_initialize_iterator_type census_context_initialize_iterator_import;
-census_context_next_tag_type census_context_next_tag_import;
-census_context_get_tag_type census_context_get_tag_import;
-census_context_encode_type census_context_encode_import;
-census_context_decode_type census_context_decode_import;
-census_trace_mask_type census_trace_mask_import;
-census_set_trace_mask_type census_set_trace_mask_import;
-census_start_rpc_op_timestamp_type census_start_rpc_op_timestamp_import;
-census_start_client_rpc_op_type census_start_client_rpc_op_import;
-census_set_rpc_client_peer_type census_set_rpc_client_peer_import;
-census_start_server_rpc_op_type census_start_server_rpc_op_import;
-census_start_op_type census_start_op_import;
-census_end_op_type census_end_op_import;
-census_trace_print_type census_trace_print_import;
-census_trace_scan_start_type census_trace_scan_start_import;
-census_get_trace_record_type census_get_trace_record_import;
-census_trace_scan_end_type census_trace_scan_end_import;
-census_define_resource_type census_define_resource_import;
-census_delete_resource_type census_delete_resource_import;
-census_resource_id_type census_resource_id_import;
-census_record_values_type census_record_values_import;
+grpc_compression_algorithm_is_message_type grpc_compression_algorithm_is_message_import;
+grpc_compression_algorithm_is_stream_type grpc_compression_algorithm_is_stream_import;
grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
-grpc_stream_compression_algorithm_name_type grpc_stream_compression_algorithm_name_import;
grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
-grpc_stream_compression_algorithm_for_level_type grpc_stream_compression_algorithm_for_level_import;
grpc_compression_options_init_type grpc_compression_options_init_import;
grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import;
grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import;
grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import;
-grpc_compression_options_is_stream_compression_algorithm_enabled_type grpc_compression_options_is_stream_compression_algorithm_enabled_import;
+grpc_compression_algorithm_parse_ruby_type grpc_compression_algorithm_parse_ruby_import;
+grpc_compression_algorithm_name_ruby_type grpc_compression_algorithm_name_ruby_import;
grpc_metadata_array_init_type grpc_metadata_array_init_import;
grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import;
grpc_call_details_init_type grpc_call_details_init_import;
@@ -77,6 +50,8 @@ grpc_completion_queue_next_type grpc_completion_queue_next_import;
grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import;
grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import;
grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import;
+grpc_completion_queue_thread_local_cache_init_type grpc_completion_queue_thread_local_cache_init_import;
+grpc_completion_queue_thread_local_cache_flush_type grpc_completion_queue_thread_local_cache_flush_import;
grpc_alarm_create_type grpc_alarm_create_import;
grpc_alarm_set_type grpc_alarm_set_import;
grpc_alarm_cancel_type grpc_alarm_cancel_import;
@@ -153,8 +128,14 @@ grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_impor
grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import;
grpc_secure_channel_create_type grpc_secure_channel_create_import;
grpc_server_credentials_release_type grpc_server_credentials_release_import;
+grpc_ssl_server_certificate_config_create_type grpc_ssl_server_certificate_config_create_import;
+grpc_ssl_server_certificate_config_destroy_type grpc_ssl_server_certificate_config_destroy_import;
grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
+grpc_ssl_server_credentials_create_options_using_config_type grpc_ssl_server_credentials_create_options_using_config_import;
+grpc_ssl_server_credentials_create_options_using_config_fetcher_type grpc_ssl_server_credentials_create_options_using_config_fetcher_import;
+grpc_ssl_server_credentials_options_destroy_type grpc_ssl_server_credentials_options_destroy_import;
+grpc_ssl_server_credentials_create_with_options_type grpc_ssl_server_credentials_create_with_options_import;
grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
grpc_call_set_credentials_type grpc_call_set_credentials_import;
grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
@@ -192,7 +173,6 @@ grpc_slice_default_eq_impl_type grpc_slice_default_eq_impl_import;
grpc_slice_eq_type grpc_slice_eq_import;
grpc_slice_cmp_type grpc_slice_cmp_import;
grpc_slice_str_cmp_type grpc_slice_str_cmp_import;
-grpc_slice_buf_cmp_type grpc_slice_buf_cmp_import;
grpc_slice_buf_start_eq_type grpc_slice_buf_start_eq_import;
grpc_slice_rchr_type grpc_slice_rchr_import;
grpc_slice_chr_type grpc_slice_chr_import;
@@ -244,21 +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_histogram_create_type gpr_histogram_create_import;
-gpr_histogram_destroy_type gpr_histogram_destroy_import;
-gpr_histogram_add_type gpr_histogram_add_import;
-gpr_histogram_merge_type gpr_histogram_merge_import;
-gpr_histogram_percentile_type gpr_histogram_percentile_import;
-gpr_histogram_mean_type gpr_histogram_mean_import;
-gpr_histogram_stddev_type gpr_histogram_stddev_import;
-gpr_histogram_variance_type gpr_histogram_variance_import;
-gpr_histogram_maximum_type gpr_histogram_maximum_import;
-gpr_histogram_minimum_type gpr_histogram_minimum_import;
-gpr_histogram_count_type gpr_histogram_count_import;
-gpr_histogram_sum_type gpr_histogram_sum_import;
-gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import;
-gpr_histogram_get_contents_type gpr_histogram_get_contents_import;
-gpr_histogram_merge_contents_type gpr_histogram_merge_contents_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;
@@ -330,44 +295,17 @@ gpr_sleep_until_type gpr_sleep_until_import;
gpr_timespec_to_micros_type gpr_timespec_to_micros_import;
void grpc_rb_load_imports(HMODULE library) {
- census_initialize_import = (census_initialize_type) GetProcAddress(library, "census_initialize");
- census_shutdown_import = (census_shutdown_type) GetProcAddress(library, "census_shutdown");
- census_supported_import = (census_supported_type) GetProcAddress(library, "census_supported");
- census_enabled_import = (census_enabled_type) GetProcAddress(library, "census_enabled");
- census_context_create_import = (census_context_create_type) GetProcAddress(library, "census_context_create");
- census_context_destroy_import = (census_context_destroy_type) GetProcAddress(library, "census_context_destroy");
- census_context_get_status_import = (census_context_get_status_type) GetProcAddress(library, "census_context_get_status");
- census_context_initialize_iterator_import = (census_context_initialize_iterator_type) GetProcAddress(library, "census_context_initialize_iterator");
- census_context_next_tag_import = (census_context_next_tag_type) GetProcAddress(library, "census_context_next_tag");
- census_context_get_tag_import = (census_context_get_tag_type) GetProcAddress(library, "census_context_get_tag");
- census_context_encode_import = (census_context_encode_type) GetProcAddress(library, "census_context_encode");
- census_context_decode_import = (census_context_decode_type) GetProcAddress(library, "census_context_decode");
- census_trace_mask_import = (census_trace_mask_type) GetProcAddress(library, "census_trace_mask");
- census_set_trace_mask_import = (census_set_trace_mask_type) GetProcAddress(library, "census_set_trace_mask");
- census_start_rpc_op_timestamp_import = (census_start_rpc_op_timestamp_type) GetProcAddress(library, "census_start_rpc_op_timestamp");
- census_start_client_rpc_op_import = (census_start_client_rpc_op_type) GetProcAddress(library, "census_start_client_rpc_op");
- census_set_rpc_client_peer_import = (census_set_rpc_client_peer_type) GetProcAddress(library, "census_set_rpc_client_peer");
- census_start_server_rpc_op_import = (census_start_server_rpc_op_type) GetProcAddress(library, "census_start_server_rpc_op");
- census_start_op_import = (census_start_op_type) GetProcAddress(library, "census_start_op");
- census_end_op_import = (census_end_op_type) GetProcAddress(library, "census_end_op");
- census_trace_print_import = (census_trace_print_type) GetProcAddress(library, "census_trace_print");
- census_trace_scan_start_import = (census_trace_scan_start_type) GetProcAddress(library, "census_trace_scan_start");
- census_get_trace_record_import = (census_get_trace_record_type) GetProcAddress(library, "census_get_trace_record");
- census_trace_scan_end_import = (census_trace_scan_end_type) GetProcAddress(library, "census_trace_scan_end");
- census_define_resource_import = (census_define_resource_type) GetProcAddress(library, "census_define_resource");
- census_delete_resource_import = (census_delete_resource_type) GetProcAddress(library, "census_delete_resource");
- census_resource_id_import = (census_resource_id_type) GetProcAddress(library, "census_resource_id");
- census_record_values_import = (census_record_values_type) GetProcAddress(library, "census_record_values");
+ grpc_compression_algorithm_is_message_import = (grpc_compression_algorithm_is_message_type) GetProcAddress(library, "grpc_compression_algorithm_is_message");
+ grpc_compression_algorithm_is_stream_import = (grpc_compression_algorithm_is_stream_type) GetProcAddress(library, "grpc_compression_algorithm_is_stream");
grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse");
grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name");
- grpc_stream_compression_algorithm_name_import = (grpc_stream_compression_algorithm_name_type) GetProcAddress(library, "grpc_stream_compression_algorithm_name");
grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level");
- grpc_stream_compression_algorithm_for_level_import = (grpc_stream_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_stream_compression_algorithm_for_level");
grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init");
grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm");
grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm");
grpc_compression_options_is_algorithm_enabled_import = (grpc_compression_options_is_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_algorithm_enabled");
- grpc_compression_options_is_stream_compression_algorithm_enabled_import = (grpc_compression_options_is_stream_compression_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_stream_compression_algorithm_enabled");
+ grpc_compression_algorithm_parse_ruby_import = (grpc_compression_algorithm_parse_ruby_type) GetProcAddress(library, "grpc_compression_algorithm_parse_ruby");
+ grpc_compression_algorithm_name_ruby_import = (grpc_compression_algorithm_name_ruby_type) GetProcAddress(library, "grpc_compression_algorithm_name_ruby");
grpc_metadata_array_init_import = (grpc_metadata_array_init_type) GetProcAddress(library, "grpc_metadata_array_init");
grpc_metadata_array_destroy_import = (grpc_metadata_array_destroy_type) GetProcAddress(library, "grpc_metadata_array_destroy");
grpc_call_details_init_import = (grpc_call_details_init_type) GetProcAddress(library, "grpc_call_details_init");
@@ -385,6 +323,8 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_completion_queue_pluck_import = (grpc_completion_queue_pluck_type) GetProcAddress(library, "grpc_completion_queue_pluck");
grpc_completion_queue_shutdown_import = (grpc_completion_queue_shutdown_type) GetProcAddress(library, "grpc_completion_queue_shutdown");
grpc_completion_queue_destroy_import = (grpc_completion_queue_destroy_type) GetProcAddress(library, "grpc_completion_queue_destroy");
+ grpc_completion_queue_thread_local_cache_init_import = (grpc_completion_queue_thread_local_cache_init_type) GetProcAddress(library, "grpc_completion_queue_thread_local_cache_init");
+ grpc_completion_queue_thread_local_cache_flush_import = (grpc_completion_queue_thread_local_cache_flush_type) GetProcAddress(library, "grpc_completion_queue_thread_local_cache_flush");
grpc_alarm_create_import = (grpc_alarm_create_type) GetProcAddress(library, "grpc_alarm_create");
grpc_alarm_set_import = (grpc_alarm_set_type) GetProcAddress(library, "grpc_alarm_set");
grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel");
@@ -461,8 +401,14 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin");
grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create");
grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release");
+ grpc_ssl_server_certificate_config_create_import = (grpc_ssl_server_certificate_config_create_type) GetProcAddress(library, "grpc_ssl_server_certificate_config_create");
+ grpc_ssl_server_certificate_config_destroy_import = (grpc_ssl_server_certificate_config_destroy_type) GetProcAddress(library, "grpc_ssl_server_certificate_config_destroy");
grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create");
grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex");
+ grpc_ssl_server_credentials_create_options_using_config_import = (grpc_ssl_server_credentials_create_options_using_config_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_options_using_config");
+ grpc_ssl_server_credentials_create_options_using_config_fetcher_import = (grpc_ssl_server_credentials_create_options_using_config_fetcher_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_options_using_config_fetcher");
+ grpc_ssl_server_credentials_options_destroy_import = (grpc_ssl_server_credentials_options_destroy_type) GetProcAddress(library, "grpc_ssl_server_credentials_options_destroy");
+ grpc_ssl_server_credentials_create_with_options_import = (grpc_ssl_server_credentials_create_with_options_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_with_options");
grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port");
grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials");
grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor");
@@ -500,7 +446,6 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_slice_eq_import = (grpc_slice_eq_type) GetProcAddress(library, "grpc_slice_eq");
grpc_slice_cmp_import = (grpc_slice_cmp_type) GetProcAddress(library, "grpc_slice_cmp");
grpc_slice_str_cmp_import = (grpc_slice_str_cmp_type) GetProcAddress(library, "grpc_slice_str_cmp");
- grpc_slice_buf_cmp_import = (grpc_slice_buf_cmp_type) GetProcAddress(library, "grpc_slice_buf_cmp");
grpc_slice_buf_start_eq_import = (grpc_slice_buf_start_eq_type) GetProcAddress(library, "grpc_slice_buf_start_eq");
grpc_slice_rchr_import = (grpc_slice_rchr_type) GetProcAddress(library, "grpc_slice_rchr");
grpc_slice_chr_import = (grpc_slice_chr_type) GetProcAddress(library, "grpc_slice_chr");
@@ -552,21 +497,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_histogram_create_import = (gpr_histogram_create_type) GetProcAddress(library, "gpr_histogram_create");
- gpr_histogram_destroy_import = (gpr_histogram_destroy_type) GetProcAddress(library, "gpr_histogram_destroy");
- gpr_histogram_add_import = (gpr_histogram_add_type) GetProcAddress(library, "gpr_histogram_add");
- gpr_histogram_merge_import = (gpr_histogram_merge_type) GetProcAddress(library, "gpr_histogram_merge");
- gpr_histogram_percentile_import = (gpr_histogram_percentile_type) GetProcAddress(library, "gpr_histogram_percentile");
- gpr_histogram_mean_import = (gpr_histogram_mean_type) GetProcAddress(library, "gpr_histogram_mean");
- gpr_histogram_stddev_import = (gpr_histogram_stddev_type) GetProcAddress(library, "gpr_histogram_stddev");
- gpr_histogram_variance_import = (gpr_histogram_variance_type) GetProcAddress(library, "gpr_histogram_variance");
- gpr_histogram_maximum_import = (gpr_histogram_maximum_type) GetProcAddress(library, "gpr_histogram_maximum");
- gpr_histogram_minimum_import = (gpr_histogram_minimum_type) GetProcAddress(library, "gpr_histogram_minimum");
- gpr_histogram_count_import = (gpr_histogram_count_type) GetProcAddress(library, "gpr_histogram_count");
- gpr_histogram_sum_import = (gpr_histogram_sum_type) GetProcAddress(library, "gpr_histogram_sum");
- gpr_histogram_sum_of_squares_import = (gpr_histogram_sum_of_squares_type) GetProcAddress(library, "gpr_histogram_sum_of_squares");
- gpr_histogram_get_contents_import = (gpr_histogram_get_contents_type) GetProcAddress(library, "gpr_histogram_get_contents");
- gpr_histogram_merge_contents_import = (gpr_histogram_merge_contents_type) GetProcAddress(library, "gpr_histogram_merge_contents");
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");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index 868772cfc8..d701d2f571 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -25,8 +25,8 @@
#include <windows.h>
-#include <grpc/census.h>
#include <grpc/compression.h>
+#include <grpc/compression_ruby.h>
#include <grpc/grpc.h>
#include <grpc/grpc_posix.h>
#include <grpc/grpc_security.h>
@@ -37,7 +37,6 @@
#include <grpc/support/avl.h>
#include <grpc/support/cmdline.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
@@ -47,130 +46,49 @@
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-typedef int(*census_initialize_type)(int features);
-extern census_initialize_type census_initialize_import;
-#define census_initialize census_initialize_import
-typedef void(*census_shutdown_type)(void);
-extern census_shutdown_type census_shutdown_import;
-#define census_shutdown census_shutdown_import
-typedef int(*census_supported_type)(void);
-extern census_supported_type census_supported_import;
-#define census_supported census_supported_import
-typedef int(*census_enabled_type)(void);
-extern census_enabled_type census_enabled_import;
-#define census_enabled census_enabled_import
-typedef census_context *(*census_context_create_type)(const census_context *base, const census_tag *tags, int ntags, census_context_status const **status);
-extern census_context_create_type census_context_create_import;
-#define census_context_create census_context_create_import
-typedef void(*census_context_destroy_type)(census_context *context);
-extern census_context_destroy_type census_context_destroy_import;
-#define census_context_destroy census_context_destroy_import
-typedef const census_context_status *(*census_context_get_status_type)(const census_context *context);
-extern census_context_get_status_type census_context_get_status_import;
-#define census_context_get_status census_context_get_status_import
-typedef void(*census_context_initialize_iterator_type)(const census_context *context, census_context_iterator *iterator);
-extern census_context_initialize_iterator_type census_context_initialize_iterator_import;
-#define census_context_initialize_iterator census_context_initialize_iterator_import
-typedef int(*census_context_next_tag_type)(census_context_iterator *iterator, census_tag *tag);
-extern census_context_next_tag_type census_context_next_tag_import;
-#define census_context_next_tag census_context_next_tag_import
-typedef int(*census_context_get_tag_type)(const census_context *context, const char *key, census_tag *tag);
-extern census_context_get_tag_type census_context_get_tag_import;
-#define census_context_get_tag census_context_get_tag_import
-typedef size_t(*census_context_encode_type)(const census_context *context, char *buffer, size_t buf_size);
-extern census_context_encode_type census_context_encode_import;
-#define census_context_encode census_context_encode_import
-typedef census_context *(*census_context_decode_type)(const char *buffer, size_t size);
-extern census_context_decode_type census_context_decode_import;
-#define census_context_decode census_context_decode_import
-typedef int(*census_trace_mask_type)(const census_context *context);
-extern census_trace_mask_type census_trace_mask_import;
-#define census_trace_mask census_trace_mask_import
-typedef void(*census_set_trace_mask_type)(int trace_mask);
-extern census_set_trace_mask_type census_set_trace_mask_import;
-#define census_set_trace_mask census_set_trace_mask_import
-typedef census_timestamp(*census_start_rpc_op_timestamp_type)(void);
-extern census_start_rpc_op_timestamp_type census_start_rpc_op_timestamp_import;
-#define census_start_rpc_op_timestamp census_start_rpc_op_timestamp_import
-typedef census_context *(*census_start_client_rpc_op_type)(const census_context *context, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, const census_timestamp *start_time);
-extern census_start_client_rpc_op_type census_start_client_rpc_op_import;
-#define census_start_client_rpc_op census_start_client_rpc_op_import
-typedef void(*census_set_rpc_client_peer_type)(census_context *context, const char *peer);
-extern census_set_rpc_client_peer_type census_set_rpc_client_peer_import;
-#define census_set_rpc_client_peer census_set_rpc_client_peer_import
-typedef census_context *(*census_start_server_rpc_op_type)(const char *buffer, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, census_timestamp *start_time);
-extern census_start_server_rpc_op_type census_start_server_rpc_op_import;
-#define census_start_server_rpc_op census_start_server_rpc_op_import
-typedef census_context *(*census_start_op_type)(census_context *context, const char *family, const char *name, int trace_mask);
-extern census_start_op_type census_start_op_import;
-#define census_start_op census_start_op_import
-typedef void(*census_end_op_type)(census_context *context, int status);
-extern census_end_op_type census_end_op_import;
-#define census_end_op census_end_op_import
-typedef void(*census_trace_print_type)(census_context *context, uint32_t type, const char *buffer, size_t n);
-extern census_trace_print_type census_trace_print_import;
-#define census_trace_print census_trace_print_import
-typedef int(*census_trace_scan_start_type)(int consume);
-extern census_trace_scan_start_type census_trace_scan_start_import;
-#define census_trace_scan_start census_trace_scan_start_import
-typedef int(*census_get_trace_record_type)(census_trace_record *trace_record);
-extern census_get_trace_record_type census_get_trace_record_import;
-#define census_get_trace_record census_get_trace_record_import
-typedef void(*census_trace_scan_end_type)();
-extern census_trace_scan_end_type census_trace_scan_end_import;
-#define census_trace_scan_end census_trace_scan_end_import
-typedef int32_t(*census_define_resource_type)(const uint8_t *resource_pb, size_t resource_pb_size);
-extern census_define_resource_type census_define_resource_import;
-#define census_define_resource census_define_resource_import
-typedef void(*census_delete_resource_type)(int32_t resource_id);
-extern census_delete_resource_type census_delete_resource_import;
-#define census_delete_resource census_delete_resource_import
-typedef int32_t(*census_resource_id_type)(const char *name);
-extern census_resource_id_type census_resource_id_import;
-#define census_resource_id census_resource_id_import
-typedef void(*census_record_values_type)(census_context *context, census_value *values, size_t nvalues);
-extern census_record_values_type census_record_values_import;
-#define census_record_values census_record_values_import
-typedef int(*grpc_compression_algorithm_parse_type)(grpc_slice value, grpc_compression_algorithm *algorithm);
+typedef int(*grpc_compression_algorithm_is_message_type)(grpc_compression_algorithm algorithm);
+extern grpc_compression_algorithm_is_message_type grpc_compression_algorithm_is_message_import;
+#define grpc_compression_algorithm_is_message grpc_compression_algorithm_is_message_import
+typedef int(*grpc_compression_algorithm_is_stream_type)(grpc_compression_algorithm algorithm);
+extern grpc_compression_algorithm_is_stream_type grpc_compression_algorithm_is_stream_import;
+#define grpc_compression_algorithm_is_stream grpc_compression_algorithm_is_stream_import
+typedef int(*grpc_compression_algorithm_parse_type)(grpc_slice value, grpc_compression_algorithm* algorithm);
extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
#define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import
-typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, const char **name);
+typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, const char** name);
extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
-typedef int(*grpc_stream_compression_algorithm_name_type)(grpc_stream_compression_algorithm algorithm, const char **name);
-extern grpc_stream_compression_algorithm_name_type grpc_stream_compression_algorithm_name_import;
-#define grpc_stream_compression_algorithm_name grpc_stream_compression_algorithm_name_import
typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
-typedef grpc_stream_compression_algorithm(*grpc_stream_compression_algorithm_for_level_type)(grpc_stream_compression_level level, uint32_t accepted_stream_encodings);
-extern grpc_stream_compression_algorithm_for_level_type grpc_stream_compression_algorithm_for_level_import;
-#define grpc_stream_compression_algorithm_for_level grpc_stream_compression_algorithm_for_level_import
-typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);
+typedef void(*grpc_compression_options_init_type)(grpc_compression_options* opts);
extern grpc_compression_options_init_type grpc_compression_options_init_import;
#define grpc_compression_options_init grpc_compression_options_init_import
-typedef void(*grpc_compression_options_enable_algorithm_type)(grpc_compression_options *opts, grpc_compression_algorithm algorithm);
+typedef void(*grpc_compression_options_enable_algorithm_type)(grpc_compression_options* opts, grpc_compression_algorithm algorithm);
extern grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import;
#define grpc_compression_options_enable_algorithm grpc_compression_options_enable_algorithm_import
-typedef void(*grpc_compression_options_disable_algorithm_type)(grpc_compression_options *opts, grpc_compression_algorithm algorithm);
+typedef void(*grpc_compression_options_disable_algorithm_type)(grpc_compression_options* opts, grpc_compression_algorithm algorithm);
extern grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import;
#define grpc_compression_options_disable_algorithm grpc_compression_options_disable_algorithm_import
-typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options *opts, grpc_compression_algorithm algorithm);
+typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options* opts, grpc_compression_algorithm algorithm);
extern grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import;
#define grpc_compression_options_is_algorithm_enabled grpc_compression_options_is_algorithm_enabled_import
-typedef int(*grpc_compression_options_is_stream_compression_algorithm_enabled_type)(const grpc_compression_options *opts, grpc_stream_compression_algorithm algorithm);
-extern grpc_compression_options_is_stream_compression_algorithm_enabled_type grpc_compression_options_is_stream_compression_algorithm_enabled_import;
-#define grpc_compression_options_is_stream_compression_algorithm_enabled grpc_compression_options_is_stream_compression_algorithm_enabled_import
-typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array *array);
+typedef int(*grpc_compression_algorithm_parse_ruby_type)(grpc_slice value, grpc_compression_algorithm* algorithm);
+extern grpc_compression_algorithm_parse_ruby_type grpc_compression_algorithm_parse_ruby_import;
+#define grpc_compression_algorithm_parse_ruby grpc_compression_algorithm_parse_ruby_import
+typedef int(*grpc_compression_algorithm_name_ruby_type)(grpc_compression_algorithm algorithm, const char** name);
+extern grpc_compression_algorithm_name_ruby_type grpc_compression_algorithm_name_ruby_import;
+#define grpc_compression_algorithm_name_ruby grpc_compression_algorithm_name_ruby_import
+typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array* array);
extern grpc_metadata_array_init_type grpc_metadata_array_init_import;
#define grpc_metadata_array_init grpc_metadata_array_init_import
-typedef void(*grpc_metadata_array_destroy_type)(grpc_metadata_array *array);
+typedef void(*grpc_metadata_array_destroy_type)(grpc_metadata_array* array);
extern grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import;
#define grpc_metadata_array_destroy grpc_metadata_array_destroy_import
-typedef void(*grpc_call_details_init_type)(grpc_call_details *details);
+typedef void(*grpc_call_details_init_type)(grpc_call_details* details);
extern grpc_call_details_init_type grpc_call_details_init_import;
#define grpc_call_details_init grpc_call_details_init_import
-typedef void(*grpc_call_details_destroy_type)(grpc_call_details *details);
+typedef void(*grpc_call_details_destroy_type)(grpc_call_details* details);
extern grpc_call_details_destroy_type grpc_call_details_destroy_import;
#define grpc_call_details_destroy grpc_call_details_destroy_import
typedef void(*grpc_register_plugin_type)(void (*init)(void), void (*destroy)(void));
@@ -182,145 +100,151 @@ extern grpc_init_type grpc_init_import;
typedef void(*grpc_shutdown_type)(void);
extern grpc_shutdown_type grpc_shutdown_import;
#define grpc_shutdown grpc_shutdown_import
-typedef const char *(*grpc_version_string_type)(void);
+typedef const char*(*grpc_version_string_type)(void);
extern grpc_version_string_type grpc_version_string_import;
#define grpc_version_string grpc_version_string_import
-typedef const char *(*grpc_g_stands_for_type)(void);
+typedef const char*(*grpc_g_stands_for_type)(void);
extern grpc_g_stands_for_type grpc_g_stands_for_import;
#define grpc_g_stands_for grpc_g_stands_for_import
-typedef const grpc_completion_queue_factory *(*grpc_completion_queue_factory_lookup_type)(const grpc_completion_queue_attributes *attributes);
+typedef const grpc_completion_queue_factory*(*grpc_completion_queue_factory_lookup_type)(const grpc_completion_queue_attributes* attributes);
extern grpc_completion_queue_factory_lookup_type grpc_completion_queue_factory_lookup_import;
#define grpc_completion_queue_factory_lookup grpc_completion_queue_factory_lookup_import
-typedef grpc_completion_queue *(*grpc_completion_queue_create_for_next_type)(void *reserved);
+typedef grpc_completion_queue*(*grpc_completion_queue_create_for_next_type)(void* reserved);
extern grpc_completion_queue_create_for_next_type grpc_completion_queue_create_for_next_import;
#define grpc_completion_queue_create_for_next grpc_completion_queue_create_for_next_import
-typedef grpc_completion_queue *(*grpc_completion_queue_create_for_pluck_type)(void *reserved);
+typedef grpc_completion_queue*(*grpc_completion_queue_create_for_pluck_type)(void* reserved);
extern grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import;
#define grpc_completion_queue_create_for_pluck grpc_completion_queue_create_for_pluck_import
-typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(const grpc_completion_queue_factory *factory, const grpc_completion_queue_attributes *attributes, void *reserved);
+typedef grpc_completion_queue*(*grpc_completion_queue_create_type)(const grpc_completion_queue_factory* factory, const grpc_completion_queue_attributes* attributes, void* reserved);
extern grpc_completion_queue_create_type grpc_completion_queue_create_import;
#define grpc_completion_queue_create grpc_completion_queue_create_import
-typedef grpc_event(*grpc_completion_queue_next_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved);
+typedef grpc_event(*grpc_completion_queue_next_type)(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved);
extern grpc_completion_queue_next_type grpc_completion_queue_next_import;
#define grpc_completion_queue_next grpc_completion_queue_next_import
-typedef grpc_event(*grpc_completion_queue_pluck_type)(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved);
+typedef grpc_event(*grpc_completion_queue_pluck_type)(grpc_completion_queue* cq, void* tag, gpr_timespec deadline, void* reserved);
extern grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import;
#define grpc_completion_queue_pluck grpc_completion_queue_pluck_import
-typedef void(*grpc_completion_queue_shutdown_type)(grpc_completion_queue *cq);
+typedef void(*grpc_completion_queue_shutdown_type)(grpc_completion_queue* cq);
extern grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import;
#define grpc_completion_queue_shutdown grpc_completion_queue_shutdown_import
-typedef void(*grpc_completion_queue_destroy_type)(grpc_completion_queue *cq);
+typedef void(*grpc_completion_queue_destroy_type)(grpc_completion_queue* cq);
extern grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import;
#define grpc_completion_queue_destroy grpc_completion_queue_destroy_import
-typedef grpc_alarm *(*grpc_alarm_create_type)(void *reserved);
+typedef void(*grpc_completion_queue_thread_local_cache_init_type)(grpc_completion_queue* cq);
+extern grpc_completion_queue_thread_local_cache_init_type grpc_completion_queue_thread_local_cache_init_import;
+#define grpc_completion_queue_thread_local_cache_init grpc_completion_queue_thread_local_cache_init_import
+typedef int(*grpc_completion_queue_thread_local_cache_flush_type)(grpc_completion_queue* cq, void** tag, int* ok);
+extern grpc_completion_queue_thread_local_cache_flush_type grpc_completion_queue_thread_local_cache_flush_import;
+#define grpc_completion_queue_thread_local_cache_flush grpc_completion_queue_thread_local_cache_flush_import
+typedef grpc_alarm*(*grpc_alarm_create_type)(void* reserved);
extern grpc_alarm_create_type grpc_alarm_create_import;
#define grpc_alarm_create grpc_alarm_create_import
-typedef void(*grpc_alarm_set_type)(grpc_alarm *alarm, grpc_completion_queue *cq, gpr_timespec deadline, void *tag, void *reserved);
+typedef void(*grpc_alarm_set_type)(grpc_alarm* alarm, grpc_completion_queue* cq, gpr_timespec deadline, void* tag, void* reserved);
extern grpc_alarm_set_type grpc_alarm_set_import;
#define grpc_alarm_set grpc_alarm_set_import
-typedef void(*grpc_alarm_cancel_type)(grpc_alarm *alarm, void *reserved);
+typedef void(*grpc_alarm_cancel_type)(grpc_alarm* alarm, void* reserved);
extern grpc_alarm_cancel_type grpc_alarm_cancel_import;
#define grpc_alarm_cancel grpc_alarm_cancel_import
-typedef void(*grpc_alarm_destroy_type)(grpc_alarm *alarm, void *reserved);
+typedef void(*grpc_alarm_destroy_type)(grpc_alarm* alarm, void* reserved);
extern grpc_alarm_destroy_type grpc_alarm_destroy_import;
#define grpc_alarm_destroy grpc_alarm_destroy_import
-typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel *channel, int try_to_connect);
+typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel* channel, int try_to_connect);
extern grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
#define grpc_channel_check_connectivity_state grpc_channel_check_connectivity_state_import
-typedef int(*grpc_channel_num_external_connectivity_watchers_type)(grpc_channel *channel);
+typedef int(*grpc_channel_num_external_connectivity_watchers_type)(grpc_channel* channel);
extern grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
#define grpc_channel_num_external_connectivity_watchers grpc_channel_num_external_connectivity_watchers_import
-typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
+typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel* channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue* cq, void* tag);
extern grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
#define grpc_channel_watch_connectivity_state grpc_channel_watch_connectivity_state_import
-typedef int(*grpc_channel_support_connectivity_watcher_type)(grpc_channel *channel);
+typedef int(*grpc_channel_support_connectivity_watcher_type)(grpc_channel* channel);
extern grpc_channel_support_connectivity_watcher_type grpc_channel_support_connectivity_watcher_import;
#define grpc_channel_support_connectivity_watcher grpc_channel_support_connectivity_watcher_import
-typedef grpc_call *(*grpc_channel_create_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, grpc_slice method, const grpc_slice *host, gpr_timespec deadline, void *reserved);
+typedef grpc_call*(*grpc_channel_create_call_type)(grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, grpc_completion_queue* completion_queue, grpc_slice method, const grpc_slice* host, gpr_timespec deadline, void* reserved);
extern grpc_channel_create_call_type grpc_channel_create_call_import;
#define grpc_channel_create_call grpc_channel_create_call_import
-typedef void(*grpc_channel_ping_type)(grpc_channel *channel, grpc_completion_queue *cq, void *tag, void *reserved);
+typedef void(*grpc_channel_ping_type)(grpc_channel* channel, grpc_completion_queue* cq, void* tag, void* reserved);
extern grpc_channel_ping_type grpc_channel_ping_import;
#define grpc_channel_ping grpc_channel_ping_import
-typedef void *(*grpc_channel_register_call_type)(grpc_channel *channel, const char *method, const char *host, void *reserved);
+typedef void*(*grpc_channel_register_call_type)(grpc_channel* channel, const char* method, const char* host, void* reserved);
extern grpc_channel_register_call_type grpc_channel_register_call_import;
#define grpc_channel_register_call grpc_channel_register_call_import
-typedef grpc_call *(*grpc_channel_create_registered_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, void *registered_call_handle, gpr_timespec deadline, void *reserved);
+typedef grpc_call*(*grpc_channel_create_registered_call_type)(grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, grpc_completion_queue* completion_queue, void* registered_call_handle, gpr_timespec deadline, void* reserved);
extern grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import;
#define grpc_channel_create_registered_call grpc_channel_create_registered_call_import
-typedef void *(*grpc_call_arena_alloc_type)(grpc_call *call, size_t size);
+typedef void*(*grpc_call_arena_alloc_type)(grpc_call* call, size_t size);
extern grpc_call_arena_alloc_type grpc_call_arena_alloc_import;
#define grpc_call_arena_alloc grpc_call_arena_alloc_import
-typedef grpc_call_error(*grpc_call_start_batch_type)(grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved);
+typedef grpc_call_error(*grpc_call_start_batch_type)(grpc_call* call, const grpc_op* ops, size_t nops, void* tag, void* reserved);
extern grpc_call_start_batch_type grpc_call_start_batch_import;
#define grpc_call_start_batch grpc_call_start_batch_import
-typedef char *(*grpc_call_get_peer_type)(grpc_call *call);
+typedef char*(*grpc_call_get_peer_type)(grpc_call* call);
extern grpc_call_get_peer_type grpc_call_get_peer_import;
#define grpc_call_get_peer grpc_call_get_peer_import
-typedef void(*grpc_census_call_set_context_type)(grpc_call *call, struct census_context *context);
+typedef void(*grpc_census_call_set_context_type)(grpc_call* call, struct census_context* context);
extern grpc_census_call_set_context_type grpc_census_call_set_context_import;
#define grpc_census_call_set_context grpc_census_call_set_context_import
-typedef struct census_context *(*grpc_census_call_get_context_type)(grpc_call *call);
+typedef struct census_context*(*grpc_census_call_get_context_type)(grpc_call* call);
extern grpc_census_call_get_context_type grpc_census_call_get_context_import;
#define grpc_census_call_get_context grpc_census_call_get_context_import
-typedef char *(*grpc_channel_get_target_type)(grpc_channel *channel);
+typedef char*(*grpc_channel_get_target_type)(grpc_channel* channel);
extern grpc_channel_get_target_type grpc_channel_get_target_import;
#define grpc_channel_get_target grpc_channel_get_target_import
-typedef void(*grpc_channel_get_info_type)(grpc_channel *channel, const grpc_channel_info *channel_info);
+typedef void(*grpc_channel_get_info_type)(grpc_channel* channel, const grpc_channel_info* channel_info);
extern grpc_channel_get_info_type grpc_channel_get_info_import;
#define grpc_channel_get_info grpc_channel_get_info_import
-typedef grpc_channel *(*grpc_insecure_channel_create_type)(const char *target, const grpc_channel_args *args, void *reserved);
+typedef grpc_channel*(*grpc_insecure_channel_create_type)(const char* target, const grpc_channel_args* args, void* reserved);
extern grpc_insecure_channel_create_type grpc_insecure_channel_create_import;
#define grpc_insecure_channel_create grpc_insecure_channel_create_import
-typedef grpc_channel *(*grpc_lame_client_channel_create_type)(const char *target, grpc_status_code error_code, const char *error_message);
+typedef grpc_channel*(*grpc_lame_client_channel_create_type)(const char* target, grpc_status_code error_code, const char* error_message);
extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import;
#define grpc_lame_client_channel_create grpc_lame_client_channel_create_import
-typedef void(*grpc_channel_destroy_type)(grpc_channel *channel);
+typedef void(*grpc_channel_destroy_type)(grpc_channel* channel);
extern grpc_channel_destroy_type grpc_channel_destroy_import;
#define grpc_channel_destroy grpc_channel_destroy_import
-typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call *call, void *reserved);
+typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved);
extern grpc_call_cancel_type grpc_call_cancel_import;
#define grpc_call_cancel grpc_call_cancel_import
-typedef grpc_call_error(*grpc_call_cancel_with_status_type)(grpc_call *call, grpc_status_code status, const char *description, void *reserved);
+typedef grpc_call_error(*grpc_call_cancel_with_status_type)(grpc_call* call, grpc_status_code status, const char* description, void* reserved);
extern grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import;
#define grpc_call_cancel_with_status grpc_call_cancel_with_status_import
-typedef void(*grpc_call_ref_type)(grpc_call *call);
+typedef void(*grpc_call_ref_type)(grpc_call* call);
extern grpc_call_ref_type grpc_call_ref_import;
#define grpc_call_ref grpc_call_ref_import
-typedef void(*grpc_call_unref_type)(grpc_call *call);
+typedef void(*grpc_call_unref_type)(grpc_call* call);
extern grpc_call_unref_type grpc_call_unref_import;
#define grpc_call_unref grpc_call_unref_import
-typedef grpc_call_error(*grpc_server_request_call_type)(grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new);
+typedef grpc_call_error(*grpc_server_request_call_type)(grpc_server* server, grpc_call** call, grpc_call_details* details, grpc_metadata_array* request_metadata, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag_new);
extern grpc_server_request_call_type grpc_server_request_call_import;
#define grpc_server_request_call grpc_server_request_call_import
-typedef void *(*grpc_server_register_method_type)(grpc_server *server, const char *method, const char *host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags);
+typedef void*(*grpc_server_register_method_type)(grpc_server* server, const char* method, const char* host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags);
extern grpc_server_register_method_type grpc_server_register_method_import;
#define grpc_server_register_method grpc_server_register_method_import
-typedef grpc_call_error(*grpc_server_request_registered_call_type)(grpc_server *server, void *registered_method, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *request_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new);
+typedef grpc_call_error(*grpc_server_request_registered_call_type)(grpc_server* server, void* registered_method, grpc_call** call, gpr_timespec* deadline, grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag_new);
extern grpc_server_request_registered_call_type grpc_server_request_registered_call_import;
#define grpc_server_request_registered_call grpc_server_request_registered_call_import
-typedef grpc_server *(*grpc_server_create_type)(const grpc_channel_args *args, void *reserved);
+typedef grpc_server*(*grpc_server_create_type)(const grpc_channel_args* args, void* reserved);
extern grpc_server_create_type grpc_server_create_import;
#define grpc_server_create grpc_server_create_import
-typedef void(*grpc_server_register_completion_queue_type)(grpc_server *server, grpc_completion_queue *cq, void *reserved);
+typedef void(*grpc_server_register_completion_queue_type)(grpc_server* server, grpc_completion_queue* cq, void* reserved);
extern grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import;
#define grpc_server_register_completion_queue grpc_server_register_completion_queue_import
-typedef int(*grpc_server_add_insecure_http2_port_type)(grpc_server *server, const char *addr);
+typedef int(*grpc_server_add_insecure_http2_port_type)(grpc_server* server, const char* addr);
extern grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import;
#define grpc_server_add_insecure_http2_port grpc_server_add_insecure_http2_port_import
-typedef void(*grpc_server_start_type)(grpc_server *server);
+typedef void(*grpc_server_start_type)(grpc_server* server);
extern grpc_server_start_type grpc_server_start_import;
#define grpc_server_start grpc_server_start_import
-typedef void(*grpc_server_shutdown_and_notify_type)(grpc_server *server, grpc_completion_queue *cq, void *tag);
+typedef void(*grpc_server_shutdown_and_notify_type)(grpc_server* server, grpc_completion_queue* cq, void* tag);
extern grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import;
#define grpc_server_shutdown_and_notify grpc_server_shutdown_and_notify_import
-typedef void(*grpc_server_cancel_all_calls_type)(grpc_server *server);
+typedef void(*grpc_server_cancel_all_calls_type)(grpc_server* server);
extern grpc_server_cancel_all_calls_type grpc_server_cancel_all_calls_import;
#define grpc_server_cancel_all_calls grpc_server_cancel_all_calls_import
-typedef void(*grpc_server_destroy_type)(grpc_server *server);
+typedef void(*grpc_server_destroy_type)(grpc_server* server);
extern grpc_server_destroy_type grpc_server_destroy_import;
#define grpc_server_destroy grpc_server_destroy_import
-typedef int(*grpc_tracer_set_enabled_type)(const char *name, int enabled);
+typedef int(*grpc_tracer_set_enabled_type)(const char* name, int enabled);
extern grpc_tracer_set_enabled_type grpc_tracer_set_enabled_import;
#define grpc_tracer_set_enabled grpc_tracer_set_enabled_import
typedef int(*grpc_header_key_is_legal_type)(grpc_slice slice);
@@ -332,157 +256,175 @@ extern grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_
typedef int(*grpc_is_binary_header_type)(grpc_slice slice);
extern grpc_is_binary_header_type grpc_is_binary_header_import;
#define grpc_is_binary_header grpc_is_binary_header_import
-typedef const char *(*grpc_call_error_to_string_type)(grpc_call_error error);
+typedef const char*(*grpc_call_error_to_string_type)(grpc_call_error error);
extern grpc_call_error_to_string_type grpc_call_error_to_string_import;
#define grpc_call_error_to_string grpc_call_error_to_string_import
-typedef grpc_resource_quota *(*grpc_resource_quota_create_type)(const char *trace_name);
+typedef grpc_resource_quota*(*grpc_resource_quota_create_type)(const char* trace_name);
extern grpc_resource_quota_create_type grpc_resource_quota_create_import;
#define grpc_resource_quota_create grpc_resource_quota_create_import
-typedef void(*grpc_resource_quota_ref_type)(grpc_resource_quota *resource_quota);
+typedef void(*grpc_resource_quota_ref_type)(grpc_resource_quota* resource_quota);
extern grpc_resource_quota_ref_type grpc_resource_quota_ref_import;
#define grpc_resource_quota_ref grpc_resource_quota_ref_import
-typedef void(*grpc_resource_quota_unref_type)(grpc_resource_quota *resource_quota);
+typedef void(*grpc_resource_quota_unref_type)(grpc_resource_quota* resource_quota);
extern grpc_resource_quota_unref_type grpc_resource_quota_unref_import;
#define grpc_resource_quota_unref grpc_resource_quota_unref_import
-typedef void(*grpc_resource_quota_resize_type)(grpc_resource_quota *resource_quota, size_t new_size);
+typedef void(*grpc_resource_quota_resize_type)(grpc_resource_quota* resource_quota, size_t new_size);
extern grpc_resource_quota_resize_type grpc_resource_quota_resize_import;
#define grpc_resource_quota_resize grpc_resource_quota_resize_import
-typedef const grpc_arg_pointer_vtable *(*grpc_resource_quota_arg_vtable_type)(void);
+typedef const grpc_arg_pointer_vtable*(*grpc_resource_quota_arg_vtable_type)(void);
extern grpc_resource_quota_arg_vtable_type grpc_resource_quota_arg_vtable_import;
#define grpc_resource_quota_arg_vtable grpc_resource_quota_arg_vtable_import
-typedef grpc_channel *(*grpc_insecure_channel_create_from_fd_type)(const char *target, int fd, const grpc_channel_args *args);
+typedef grpc_channel*(*grpc_insecure_channel_create_from_fd_type)(const char* target, int fd, const grpc_channel_args* args);
extern grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import;
#define grpc_insecure_channel_create_from_fd grpc_insecure_channel_create_from_fd_import
-typedef void(*grpc_server_add_insecure_channel_from_fd_type)(grpc_server *server, void *reserved, int fd);
+typedef void(*grpc_server_add_insecure_channel_from_fd_type)(grpc_server* server, void* reserved, int fd);
extern grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import;
#define grpc_server_add_insecure_channel_from_fd grpc_server_add_insecure_channel_from_fd_import
typedef void(*grpc_use_signal_type)(int signum);
extern grpc_use_signal_type grpc_use_signal_import;
#define grpc_use_signal grpc_use_signal_import
-typedef const grpc_auth_property *(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator *it);
+typedef const grpc_auth_property*(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator* it);
extern grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import;
#define grpc_auth_property_iterator_next grpc_auth_property_iterator_next_import
-typedef grpc_auth_property_iterator(*grpc_auth_context_property_iterator_type)(const grpc_auth_context *ctx);
+typedef grpc_auth_property_iterator(*grpc_auth_context_property_iterator_type)(const grpc_auth_context* ctx);
extern grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import;
#define grpc_auth_context_property_iterator grpc_auth_context_property_iterator_import
-typedef grpc_auth_property_iterator(*grpc_auth_context_peer_identity_type)(const grpc_auth_context *ctx);
+typedef grpc_auth_property_iterator(*grpc_auth_context_peer_identity_type)(const grpc_auth_context* ctx);
extern grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import;
#define grpc_auth_context_peer_identity grpc_auth_context_peer_identity_import
-typedef grpc_auth_property_iterator(*grpc_auth_context_find_properties_by_name_type)(const grpc_auth_context *ctx, const char *name);
+typedef grpc_auth_property_iterator(*grpc_auth_context_find_properties_by_name_type)(const grpc_auth_context* ctx, const char* name);
extern grpc_auth_context_find_properties_by_name_type grpc_auth_context_find_properties_by_name_import;
#define grpc_auth_context_find_properties_by_name grpc_auth_context_find_properties_by_name_import
-typedef const char *(*grpc_auth_context_peer_identity_property_name_type)(const grpc_auth_context *ctx);
+typedef const char*(*grpc_auth_context_peer_identity_property_name_type)(const grpc_auth_context* ctx);
extern grpc_auth_context_peer_identity_property_name_type grpc_auth_context_peer_identity_property_name_import;
#define grpc_auth_context_peer_identity_property_name grpc_auth_context_peer_identity_property_name_import
-typedef int(*grpc_auth_context_peer_is_authenticated_type)(const grpc_auth_context *ctx);
+typedef int(*grpc_auth_context_peer_is_authenticated_type)(const grpc_auth_context* ctx);
extern grpc_auth_context_peer_is_authenticated_type grpc_auth_context_peer_is_authenticated_import;
#define grpc_auth_context_peer_is_authenticated grpc_auth_context_peer_is_authenticated_import
-typedef grpc_auth_context *(*grpc_call_auth_context_type)(grpc_call *call);
+typedef grpc_auth_context*(*grpc_call_auth_context_type)(grpc_call* call);
extern grpc_call_auth_context_type grpc_call_auth_context_import;
#define grpc_call_auth_context grpc_call_auth_context_import
-typedef void(*grpc_auth_context_release_type)(grpc_auth_context *context);
+typedef void(*grpc_auth_context_release_type)(grpc_auth_context* context);
extern grpc_auth_context_release_type grpc_auth_context_release_import;
#define grpc_auth_context_release grpc_auth_context_release_import
-typedef void(*grpc_auth_context_add_property_type)(grpc_auth_context *ctx, const char *name, const char *value, size_t value_length);
+typedef void(*grpc_auth_context_add_property_type)(grpc_auth_context* ctx, const char* name, const char* value, size_t value_length);
extern grpc_auth_context_add_property_type grpc_auth_context_add_property_import;
#define grpc_auth_context_add_property grpc_auth_context_add_property_import
-typedef void(*grpc_auth_context_add_cstring_property_type)(grpc_auth_context *ctx, const char *name, const char *value);
+typedef void(*grpc_auth_context_add_cstring_property_type)(grpc_auth_context* ctx, const char* name, const char* value);
extern grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import;
#define grpc_auth_context_add_cstring_property grpc_auth_context_add_cstring_property_import
-typedef int(*grpc_auth_context_set_peer_identity_property_name_type)(grpc_auth_context *ctx, const char *name);
+typedef int(*grpc_auth_context_set_peer_identity_property_name_type)(grpc_auth_context* ctx, const char* name);
extern grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import;
#define grpc_auth_context_set_peer_identity_property_name grpc_auth_context_set_peer_identity_property_name_import
-typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials *creds);
+typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials* creds);
extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
#define grpc_channel_credentials_release grpc_channel_credentials_release_import
-typedef grpc_channel_credentials *(*grpc_google_default_credentials_create_type)(void);
+typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(void);
extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import
typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb);
extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
#define grpc_set_ssl_roots_override_callback grpc_set_ssl_roots_override_callback_import
-typedef grpc_channel_credentials *(*grpc_ssl_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, void *reserved);
+typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, void* reserved);
extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import
-typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials *creds);
+typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
#define grpc_call_credentials_release grpc_call_credentials_release_import
-typedef grpc_channel_credentials *(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, void *reserved);
+typedef grpc_channel_credentials*(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved);
extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
#define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import
-typedef grpc_call_credentials *(*grpc_composite_call_credentials_create_type)(grpc_call_credentials *creds1, grpc_call_credentials *creds2, void *reserved);
+typedef grpc_call_credentials*(*grpc_composite_call_credentials_create_type)(grpc_call_credentials* creds1, grpc_call_credentials* creds2, void* reserved);
extern grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import;
#define grpc_composite_call_credentials_create grpc_composite_call_credentials_create_import
-typedef grpc_call_credentials *(*grpc_google_compute_engine_credentials_create_type)(void *reserved);
+typedef grpc_call_credentials*(*grpc_google_compute_engine_credentials_create_type)(void* reserved);
extern grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import;
#define grpc_google_compute_engine_credentials_create grpc_google_compute_engine_credentials_create_import
-typedef gpr_timespec(*grpc_max_auth_token_lifetime_type)();
+typedef gpr_timespec(*grpc_max_auth_token_lifetime_type)(void);
extern grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import;
#define grpc_max_auth_token_lifetime grpc_max_auth_token_lifetime_import
-typedef grpc_call_credentials *(*grpc_service_account_jwt_access_credentials_create_type)(const char *json_key, gpr_timespec token_lifetime, void *reserved);
+typedef grpc_call_credentials*(*grpc_service_account_jwt_access_credentials_create_type)(const char* json_key, gpr_timespec token_lifetime, void* reserved);
extern grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import;
#define grpc_service_account_jwt_access_credentials_create grpc_service_account_jwt_access_credentials_create_import
-typedef grpc_call_credentials *(*grpc_google_refresh_token_credentials_create_type)(const char *json_refresh_token, void *reserved);
+typedef grpc_call_credentials*(*grpc_google_refresh_token_credentials_create_type)(const char* json_refresh_token, void* reserved);
extern grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import;
#define grpc_google_refresh_token_credentials_create grpc_google_refresh_token_credentials_create_import
-typedef grpc_call_credentials *(*grpc_access_token_credentials_create_type)(const char *access_token, void *reserved);
+typedef grpc_call_credentials*(*grpc_access_token_credentials_create_type)(const char* access_token, void* reserved);
extern grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import;
#define grpc_access_token_credentials_create grpc_access_token_credentials_create_import
-typedef grpc_call_credentials *(*grpc_google_iam_credentials_create_type)(const char *authorization_token, const char *authority_selector, void *reserved);
+typedef grpc_call_credentials*(*grpc_google_iam_credentials_create_type)(const char* authorization_token, const char* authority_selector, void* reserved);
extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import;
#define grpc_google_iam_credentials_create grpc_google_iam_credentials_create_import
-typedef grpc_call_credentials *(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, void *reserved);
+typedef grpc_call_credentials*(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, void* reserved);
extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import;
#define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import
-typedef grpc_channel *(*grpc_secure_channel_create_type)(grpc_channel_credentials *creds, const char *target, const grpc_channel_args *args, void *reserved);
+typedef grpc_channel*(*grpc_secure_channel_create_type)(grpc_channel_credentials* creds, const char* target, const grpc_channel_args* args, void* reserved);
extern grpc_secure_channel_create_type grpc_secure_channel_create_import;
#define grpc_secure_channel_create grpc_secure_channel_create_import
-typedef void(*grpc_server_credentials_release_type)(grpc_server_credentials *creds);
+typedef void(*grpc_server_credentials_release_type)(grpc_server_credentials* creds);
extern grpc_server_credentials_release_type grpc_server_credentials_release_import;
#define grpc_server_credentials_release grpc_server_credentials_release_import
-typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved);
+typedef grpc_ssl_server_certificate_config*(*grpc_ssl_server_certificate_config_create_type)(const char* pem_root_certs, const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs);
+extern grpc_ssl_server_certificate_config_create_type grpc_ssl_server_certificate_config_create_import;
+#define grpc_ssl_server_certificate_config_create grpc_ssl_server_certificate_config_create_import
+typedef void(*grpc_ssl_server_certificate_config_destroy_type)(grpc_ssl_server_certificate_config* config);
+extern grpc_ssl_server_certificate_config_destroy_type grpc_ssl_server_certificate_config_destroy_import;
+#define grpc_ssl_server_certificate_config_destroy grpc_ssl_server_certificate_config_destroy_import
+typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void* reserved);
extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import
-typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_ex_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved);
+typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void* reserved);
extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import
-typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds);
+typedef grpc_ssl_server_credentials_options*(*grpc_ssl_server_credentials_create_options_using_config_type)(grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config* certificate_config);
+extern grpc_ssl_server_credentials_create_options_using_config_type grpc_ssl_server_credentials_create_options_using_config_import;
+#define grpc_ssl_server_credentials_create_options_using_config grpc_ssl_server_credentials_create_options_using_config_import
+typedef grpc_ssl_server_credentials_options*(*grpc_ssl_server_credentials_create_options_using_config_fetcher_type)(grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config_callback cb, void* user_data);
+extern grpc_ssl_server_credentials_create_options_using_config_fetcher_type grpc_ssl_server_credentials_create_options_using_config_fetcher_import;
+#define grpc_ssl_server_credentials_create_options_using_config_fetcher grpc_ssl_server_credentials_create_options_using_config_fetcher_import
+typedef void(*grpc_ssl_server_credentials_options_destroy_type)(grpc_ssl_server_credentials_options* options);
+extern grpc_ssl_server_credentials_options_destroy_type grpc_ssl_server_credentials_options_destroy_import;
+#define grpc_ssl_server_credentials_options_destroy grpc_ssl_server_credentials_options_destroy_import
+typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_with_options_type)(grpc_ssl_server_credentials_options* options);
+extern grpc_ssl_server_credentials_create_with_options_type grpc_ssl_server_credentials_create_with_options_import;
+#define grpc_ssl_server_credentials_create_with_options grpc_ssl_server_credentials_create_with_options_import
+typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server* server, const char* addr, grpc_server_credentials* creds);
extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
#define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import
-typedef grpc_call_error(*grpc_call_set_credentials_type)(grpc_call *call, grpc_call_credentials *creds);
+typedef grpc_call_error(*grpc_call_set_credentials_type)(grpc_call* call, grpc_call_credentials* creds);
extern grpc_call_set_credentials_type grpc_call_set_credentials_import;
#define grpc_call_set_credentials grpc_call_set_credentials_import
-typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials *creds, grpc_auth_metadata_processor processor);
+typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials* creds, grpc_auth_metadata_processor processor);
extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
#define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import
-typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(grpc_slice *slices, size_t nslices);
+typedef grpc_byte_buffer*(*grpc_raw_byte_buffer_create_type)(grpc_slice* slices, size_t nslices);
extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
#define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import
-typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression);
+typedef grpc_byte_buffer*(*grpc_raw_compressed_byte_buffer_create_type)(grpc_slice* slices, size_t nslices, grpc_compression_algorithm compression);
extern grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import;
#define grpc_raw_compressed_byte_buffer_create grpc_raw_compressed_byte_buffer_create_import
-typedef grpc_byte_buffer *(*grpc_byte_buffer_copy_type)(grpc_byte_buffer *bb);
+typedef grpc_byte_buffer*(*grpc_byte_buffer_copy_type)(grpc_byte_buffer* bb);
extern grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import;
#define grpc_byte_buffer_copy grpc_byte_buffer_copy_import
-typedef size_t(*grpc_byte_buffer_length_type)(grpc_byte_buffer *bb);
+typedef size_t(*grpc_byte_buffer_length_type)(grpc_byte_buffer* bb);
extern grpc_byte_buffer_length_type grpc_byte_buffer_length_import;
#define grpc_byte_buffer_length grpc_byte_buffer_length_import
-typedef void(*grpc_byte_buffer_destroy_type)(grpc_byte_buffer *byte_buffer);
+typedef void(*grpc_byte_buffer_destroy_type)(grpc_byte_buffer* byte_buffer);
extern grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import;
#define grpc_byte_buffer_destroy grpc_byte_buffer_destroy_import
-typedef int(*grpc_byte_buffer_reader_init_type)(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer);
+typedef int(*grpc_byte_buffer_reader_init_type)(grpc_byte_buffer_reader* reader, grpc_byte_buffer* buffer);
extern grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import;
#define grpc_byte_buffer_reader_init grpc_byte_buffer_reader_init_import
-typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader *reader);
+typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader* reader);
extern grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import;
#define grpc_byte_buffer_reader_destroy grpc_byte_buffer_reader_destroy_import
-typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, grpc_slice *slice);
+typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader* reader, grpc_slice* slice);
extern grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import;
#define grpc_byte_buffer_reader_next grpc_byte_buffer_reader_next_import
-typedef grpc_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader);
+typedef grpc_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader* reader);
extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
#define grpc_byte_buffer_reader_readall grpc_byte_buffer_reader_readall_import
-typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader);
+typedef grpc_byte_buffer*(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader* reader);
extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
#define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import
typedef grpc_slice(*grpc_slice_ref_type)(grpc_slice s);
@@ -494,13 +436,13 @@ extern grpc_slice_unref_type grpc_slice_unref_import;
typedef grpc_slice(*grpc_slice_copy_type)(grpc_slice s);
extern grpc_slice_copy_type grpc_slice_copy_import;
#define grpc_slice_copy grpc_slice_copy_import
-typedef grpc_slice(*grpc_slice_new_type)(void *p, size_t len, void (*destroy)(void *));
+typedef grpc_slice(*grpc_slice_new_type)(void* p, size_t len, void (*destroy)(void*));
extern grpc_slice_new_type grpc_slice_new_import;
#define grpc_slice_new grpc_slice_new_import
-typedef grpc_slice(*grpc_slice_new_with_user_data_type)(void *p, size_t len, void (*destroy)(void *), void *user_data);
+typedef grpc_slice(*grpc_slice_new_with_user_data_type)(void* p, size_t len, void (*destroy)(void*), void* user_data);
extern grpc_slice_new_with_user_data_type grpc_slice_new_with_user_data_import;
#define grpc_slice_new_with_user_data grpc_slice_new_with_user_data_import
-typedef grpc_slice(*grpc_slice_new_with_len_type)(void *p, size_t len, void (*destroy)(void *, size_t));
+typedef grpc_slice(*grpc_slice_new_with_len_type)(void* p, size_t len, void (*destroy)(void*, size_t));
extern grpc_slice_new_with_len_type grpc_slice_new_with_len_import;
#define grpc_slice_new_with_len grpc_slice_new_with_len_import
typedef grpc_slice(*grpc_slice_malloc_type)(size_t length);
@@ -512,16 +454,16 @@ extern grpc_slice_malloc_large_type grpc_slice_malloc_large_import;
typedef grpc_slice(*grpc_slice_intern_type)(grpc_slice slice);
extern grpc_slice_intern_type grpc_slice_intern_import;
#define grpc_slice_intern grpc_slice_intern_import
-typedef grpc_slice(*grpc_slice_from_copied_string_type)(const char *source);
+typedef grpc_slice(*grpc_slice_from_copied_string_type)(const char* source);
extern grpc_slice_from_copied_string_type grpc_slice_from_copied_string_import;
#define grpc_slice_from_copied_string grpc_slice_from_copied_string_import
-typedef grpc_slice(*grpc_slice_from_copied_buffer_type)(const char *source, size_t len);
+typedef grpc_slice(*grpc_slice_from_copied_buffer_type)(const char* source, size_t len);
extern grpc_slice_from_copied_buffer_type grpc_slice_from_copied_buffer_import;
#define grpc_slice_from_copied_buffer grpc_slice_from_copied_buffer_import
-typedef grpc_slice(*grpc_slice_from_static_string_type)(const char *source);
+typedef grpc_slice(*grpc_slice_from_static_string_type)(const char* source);
extern grpc_slice_from_static_string_type grpc_slice_from_static_string_import;
#define grpc_slice_from_static_string grpc_slice_from_static_string_import
-typedef grpc_slice(*grpc_slice_from_static_buffer_type)(const void *source, size_t len);
+typedef grpc_slice(*grpc_slice_from_static_buffer_type)(const void* source, size_t len);
extern grpc_slice_from_static_buffer_type grpc_slice_from_static_buffer_import;
#define grpc_slice_from_static_buffer grpc_slice_from_static_buffer_import
typedef grpc_slice(*grpc_slice_sub_type)(grpc_slice s, size_t begin, size_t end);
@@ -530,13 +472,13 @@ extern grpc_slice_sub_type grpc_slice_sub_import;
typedef grpc_slice(*grpc_slice_sub_no_ref_type)(grpc_slice s, size_t begin, size_t end);
extern grpc_slice_sub_no_ref_type grpc_slice_sub_no_ref_import;
#define grpc_slice_sub_no_ref grpc_slice_sub_no_ref_import
-typedef grpc_slice(*grpc_slice_split_tail_type)(grpc_slice *s, size_t split);
+typedef grpc_slice(*grpc_slice_split_tail_type)(grpc_slice* s, size_t split);
extern grpc_slice_split_tail_type grpc_slice_split_tail_import;
#define grpc_slice_split_tail grpc_slice_split_tail_import
-typedef grpc_slice(*grpc_slice_split_tail_maybe_ref_type)(grpc_slice *s, size_t split, grpc_slice_ref_whom ref_whom);
+typedef grpc_slice(*grpc_slice_split_tail_maybe_ref_type)(grpc_slice* s, size_t split, grpc_slice_ref_whom ref_whom);
extern grpc_slice_split_tail_maybe_ref_type grpc_slice_split_tail_maybe_ref_import;
#define grpc_slice_split_tail_maybe_ref grpc_slice_split_tail_maybe_ref_import
-typedef grpc_slice(*grpc_slice_split_head_type)(grpc_slice *s, size_t split);
+typedef grpc_slice(*grpc_slice_split_head_type)(grpc_slice* s, size_t split);
extern grpc_slice_split_head_type grpc_slice_split_head_import;
#define grpc_slice_split_head grpc_slice_split_head_import
typedef grpc_slice(*grpc_empty_slice_type)(void);
@@ -554,13 +496,10 @@ extern grpc_slice_eq_type grpc_slice_eq_import;
typedef int(*grpc_slice_cmp_type)(grpc_slice a, grpc_slice b);
extern grpc_slice_cmp_type grpc_slice_cmp_import;
#define grpc_slice_cmp grpc_slice_cmp_import
-typedef int(*grpc_slice_str_cmp_type)(grpc_slice a, const char *b);
+typedef int(*grpc_slice_str_cmp_type)(grpc_slice a, const char* b);
extern grpc_slice_str_cmp_type grpc_slice_str_cmp_import;
#define grpc_slice_str_cmp grpc_slice_str_cmp_import
-typedef int(*grpc_slice_buf_cmp_type)(grpc_slice a, const void *b, size_t blen);
-extern grpc_slice_buf_cmp_type grpc_slice_buf_cmp_import;
-#define grpc_slice_buf_cmp grpc_slice_buf_cmp_import
-typedef int(*grpc_slice_buf_start_eq_type)(grpc_slice a, const void *b, size_t blen);
+typedef int(*grpc_slice_buf_start_eq_type)(grpc_slice a, const void* b, size_t blen);
extern grpc_slice_buf_start_eq_type grpc_slice_buf_start_eq_import;
#define grpc_slice_buf_start_eq grpc_slice_buf_start_eq_import
typedef int(*grpc_slice_rchr_type)(grpc_slice s, char c);
@@ -581,130 +520,130 @@ extern grpc_slice_is_equivalent_type grpc_slice_is_equivalent_import;
typedef grpc_slice(*grpc_slice_dup_type)(grpc_slice a);
extern grpc_slice_dup_type grpc_slice_dup_import;
#define grpc_slice_dup grpc_slice_dup_import
-typedef char *(*grpc_slice_to_c_string_type)(grpc_slice s);
+typedef char*(*grpc_slice_to_c_string_type)(grpc_slice s);
extern grpc_slice_to_c_string_type grpc_slice_to_c_string_import;
#define grpc_slice_to_c_string grpc_slice_to_c_string_import
-typedef void(*grpc_slice_buffer_init_type)(grpc_slice_buffer *sb);
+typedef void(*grpc_slice_buffer_init_type)(grpc_slice_buffer* sb);
extern grpc_slice_buffer_init_type grpc_slice_buffer_init_import;
#define grpc_slice_buffer_init grpc_slice_buffer_init_import
-typedef void(*grpc_slice_buffer_destroy_type)(grpc_slice_buffer *sb);
+typedef void(*grpc_slice_buffer_destroy_type)(grpc_slice_buffer* sb);
extern grpc_slice_buffer_destroy_type grpc_slice_buffer_destroy_import;
#define grpc_slice_buffer_destroy grpc_slice_buffer_destroy_import
-typedef void(*grpc_slice_buffer_add_type)(grpc_slice_buffer *sb, grpc_slice slice);
+typedef void(*grpc_slice_buffer_add_type)(grpc_slice_buffer* sb, grpc_slice slice);
extern grpc_slice_buffer_add_type grpc_slice_buffer_add_import;
#define grpc_slice_buffer_add grpc_slice_buffer_add_import
-typedef size_t(*grpc_slice_buffer_add_indexed_type)(grpc_slice_buffer *sb, grpc_slice slice);
+typedef size_t(*grpc_slice_buffer_add_indexed_type)(grpc_slice_buffer* sb, grpc_slice slice);
extern grpc_slice_buffer_add_indexed_type grpc_slice_buffer_add_indexed_import;
#define grpc_slice_buffer_add_indexed grpc_slice_buffer_add_indexed_import
-typedef void(*grpc_slice_buffer_addn_type)(grpc_slice_buffer *sb, grpc_slice *slices, size_t n);
+typedef void(*grpc_slice_buffer_addn_type)(grpc_slice_buffer* sb, grpc_slice* slices, size_t n);
extern grpc_slice_buffer_addn_type grpc_slice_buffer_addn_import;
#define grpc_slice_buffer_addn grpc_slice_buffer_addn_import
-typedef uint8_t *(*grpc_slice_buffer_tiny_add_type)(grpc_slice_buffer *sb, size_t len);
+typedef uint8_t*(*grpc_slice_buffer_tiny_add_type)(grpc_slice_buffer* sb, size_t len);
extern grpc_slice_buffer_tiny_add_type grpc_slice_buffer_tiny_add_import;
#define grpc_slice_buffer_tiny_add grpc_slice_buffer_tiny_add_import
-typedef void(*grpc_slice_buffer_pop_type)(grpc_slice_buffer *sb);
+typedef void(*grpc_slice_buffer_pop_type)(grpc_slice_buffer* sb);
extern grpc_slice_buffer_pop_type grpc_slice_buffer_pop_import;
#define grpc_slice_buffer_pop grpc_slice_buffer_pop_import
-typedef void(*grpc_slice_buffer_reset_and_unref_type)(grpc_slice_buffer *sb);
+typedef void(*grpc_slice_buffer_reset_and_unref_type)(grpc_slice_buffer* sb);
extern grpc_slice_buffer_reset_and_unref_type grpc_slice_buffer_reset_and_unref_import;
#define grpc_slice_buffer_reset_and_unref grpc_slice_buffer_reset_and_unref_import
-typedef void(*grpc_slice_buffer_swap_type)(grpc_slice_buffer *a, grpc_slice_buffer *b);
+typedef void(*grpc_slice_buffer_swap_type)(grpc_slice_buffer* a, grpc_slice_buffer* b);
extern grpc_slice_buffer_swap_type grpc_slice_buffer_swap_import;
#define grpc_slice_buffer_swap grpc_slice_buffer_swap_import
-typedef void(*grpc_slice_buffer_move_into_type)(grpc_slice_buffer *src, grpc_slice_buffer *dst);
+typedef void(*grpc_slice_buffer_move_into_type)(grpc_slice_buffer* src, grpc_slice_buffer* dst);
extern grpc_slice_buffer_move_into_type grpc_slice_buffer_move_into_import;
#define grpc_slice_buffer_move_into grpc_slice_buffer_move_into_import
-typedef void(*grpc_slice_buffer_trim_end_type)(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *garbage);
+typedef void(*grpc_slice_buffer_trim_end_type)(grpc_slice_buffer* src, size_t n, grpc_slice_buffer* garbage);
extern grpc_slice_buffer_trim_end_type grpc_slice_buffer_trim_end_import;
#define grpc_slice_buffer_trim_end grpc_slice_buffer_trim_end_import
-typedef void(*grpc_slice_buffer_move_first_type)(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *dst);
+typedef void(*grpc_slice_buffer_move_first_type)(grpc_slice_buffer* src, size_t n, grpc_slice_buffer* dst);
extern grpc_slice_buffer_move_first_type grpc_slice_buffer_move_first_import;
#define grpc_slice_buffer_move_first grpc_slice_buffer_move_first_import
-typedef void(*grpc_slice_buffer_move_first_no_ref_type)(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *dst);
+typedef void(*grpc_slice_buffer_move_first_no_ref_type)(grpc_slice_buffer* src, size_t n, grpc_slice_buffer* dst);
extern grpc_slice_buffer_move_first_no_ref_type grpc_slice_buffer_move_first_no_ref_import;
#define grpc_slice_buffer_move_first_no_ref grpc_slice_buffer_move_first_no_ref_import
-typedef void(*grpc_slice_buffer_move_first_into_buffer_type)(grpc_exec_ctx *exec_ctx, grpc_slice_buffer *src, size_t n, void *dst);
+typedef void(*grpc_slice_buffer_move_first_into_buffer_type)(grpc_slice_buffer* src, size_t n, void* dst);
extern grpc_slice_buffer_move_first_into_buffer_type grpc_slice_buffer_move_first_into_buffer_import;
#define grpc_slice_buffer_move_first_into_buffer grpc_slice_buffer_move_first_into_buffer_import
-typedef grpc_slice(*grpc_slice_buffer_take_first_type)(grpc_slice_buffer *src);
+typedef grpc_slice(*grpc_slice_buffer_take_first_type)(grpc_slice_buffer* src);
extern grpc_slice_buffer_take_first_type grpc_slice_buffer_take_first_import;
#define grpc_slice_buffer_take_first grpc_slice_buffer_take_first_import
-typedef void(*grpc_slice_buffer_undo_take_first_type)(grpc_slice_buffer *src, grpc_slice slice);
+typedef void(*grpc_slice_buffer_undo_take_first_type)(grpc_slice_buffer* src, grpc_slice slice);
extern grpc_slice_buffer_undo_take_first_type grpc_slice_buffer_undo_take_first_import;
#define grpc_slice_buffer_undo_take_first grpc_slice_buffer_undo_take_first_import
-typedef void *(*gpr_malloc_type)(size_t size);
+typedef void*(*gpr_malloc_type)(size_t size);
extern gpr_malloc_type gpr_malloc_import;
#define gpr_malloc gpr_malloc_import
-typedef void *(*gpr_zalloc_type)(size_t size);
+typedef void*(*gpr_zalloc_type)(size_t size);
extern gpr_zalloc_type gpr_zalloc_import;
#define gpr_zalloc gpr_zalloc_import
-typedef void(*gpr_free_type)(void *ptr);
+typedef void(*gpr_free_type)(void* ptr);
extern gpr_free_type gpr_free_import;
#define gpr_free gpr_free_import
-typedef void *(*gpr_realloc_type)(void *p, size_t size);
+typedef void*(*gpr_realloc_type)(void* p, size_t size);
extern gpr_realloc_type gpr_realloc_import;
#define gpr_realloc gpr_realloc_import
-typedef void *(*gpr_malloc_aligned_type)(size_t size, size_t alignment_log);
+typedef void*(*gpr_malloc_aligned_type)(size_t size, size_t alignment);
extern gpr_malloc_aligned_type gpr_malloc_aligned_import;
#define gpr_malloc_aligned gpr_malloc_aligned_import
-typedef void(*gpr_free_aligned_type)(void *ptr);
+typedef void(*gpr_free_aligned_type)(void* ptr);
extern gpr_free_aligned_type gpr_free_aligned_import;
#define gpr_free_aligned gpr_free_aligned_import
typedef void(*gpr_set_allocation_functions_type)(gpr_allocation_functions functions);
extern gpr_set_allocation_functions_type gpr_set_allocation_functions_import;
#define gpr_set_allocation_functions gpr_set_allocation_functions_import
-typedef gpr_allocation_functions(*gpr_get_allocation_functions_type)();
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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);
+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, char **value);
+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);
+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);
+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);
+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);
+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);
+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);
@@ -713,187 +652,142 @@ 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 gpr_histogram *(*gpr_histogram_create_type)(double resolution, double max_bucket_start);
-extern gpr_histogram_create_type gpr_histogram_create_import;
-#define gpr_histogram_create gpr_histogram_create_import
-typedef void(*gpr_histogram_destroy_type)(gpr_histogram *h);
-extern gpr_histogram_destroy_type gpr_histogram_destroy_import;
-#define gpr_histogram_destroy gpr_histogram_destroy_import
-typedef void(*gpr_histogram_add_type)(gpr_histogram *h, double x);
-extern gpr_histogram_add_type gpr_histogram_add_import;
-#define gpr_histogram_add gpr_histogram_add_import
-typedef int(*gpr_histogram_merge_type)(gpr_histogram *dst, const gpr_histogram *src);
-extern gpr_histogram_merge_type gpr_histogram_merge_import;
-#define gpr_histogram_merge gpr_histogram_merge_import
-typedef double(*gpr_histogram_percentile_type)(gpr_histogram *histogram, double percentile);
-extern gpr_histogram_percentile_type gpr_histogram_percentile_import;
-#define gpr_histogram_percentile gpr_histogram_percentile_import
-typedef double(*gpr_histogram_mean_type)(gpr_histogram *histogram);
-extern gpr_histogram_mean_type gpr_histogram_mean_import;
-#define gpr_histogram_mean gpr_histogram_mean_import
-typedef double(*gpr_histogram_stddev_type)(gpr_histogram *histogram);
-extern gpr_histogram_stddev_type gpr_histogram_stddev_import;
-#define gpr_histogram_stddev gpr_histogram_stddev_import
-typedef double(*gpr_histogram_variance_type)(gpr_histogram *histogram);
-extern gpr_histogram_variance_type gpr_histogram_variance_import;
-#define gpr_histogram_variance gpr_histogram_variance_import
-typedef double(*gpr_histogram_maximum_type)(gpr_histogram *histogram);
-extern gpr_histogram_maximum_type gpr_histogram_maximum_import;
-#define gpr_histogram_maximum gpr_histogram_maximum_import
-typedef double(*gpr_histogram_minimum_type)(gpr_histogram *histogram);
-extern gpr_histogram_minimum_type gpr_histogram_minimum_import;
-#define gpr_histogram_minimum gpr_histogram_minimum_import
-typedef double(*gpr_histogram_count_type)(gpr_histogram *histogram);
-extern gpr_histogram_count_type gpr_histogram_count_import;
-#define gpr_histogram_count gpr_histogram_count_import
-typedef double(*gpr_histogram_sum_type)(gpr_histogram *histogram);
-extern gpr_histogram_sum_type gpr_histogram_sum_import;
-#define gpr_histogram_sum gpr_histogram_sum_import
-typedef double(*gpr_histogram_sum_of_squares_type)(gpr_histogram *histogram);
-extern gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import;
-#define gpr_histogram_sum_of_squares gpr_histogram_sum_of_squares_import
-typedef const uint32_t *(*gpr_histogram_get_contents_type)(gpr_histogram *histogram, size_t *count);
-extern gpr_histogram_get_contents_type gpr_histogram_get_contents_import;
-#define gpr_histogram_get_contents gpr_histogram_get_contents_import
-typedef void(*gpr_histogram_merge_contents_type)(gpr_histogram *histogram, const uint32_t *data, size_t data_count, double min_seen, double max_seen, double sum, double sum_of_squares, double count);
-extern gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import;
-#define gpr_histogram_merge_contents gpr_histogram_merge_contents_import
-typedef int(*gpr_join_host_port_type)(char **out, const char *host, int port);
+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);
+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);
+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
-typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
+typedef void(*gpr_log_type)(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
extern gpr_log_type gpr_log_import;
#define gpr_log gpr_log_import
-typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message);
+typedef void(*gpr_log_message_type)(const char* file, int line, gpr_log_severity severity, const char* message);
extern gpr_log_message_type gpr_log_message_import;
#define gpr_log_message gpr_log_message_import
typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print);
extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
#define gpr_set_log_verbosity gpr_set_log_verbosity_import
-typedef void(*gpr_log_verbosity_init_type)();
+typedef void(*gpr_log_verbosity_init_type)(void);
extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
#define gpr_log_verbosity_init gpr_log_verbosity_init_import
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
-typedef char *(*gpr_format_message_type)(int messageid);
+typedef char*(*gpr_format_message_type)(int messageid);
extern gpr_format_message_type gpr_format_message_import;
#define gpr_format_message gpr_format_message_import
-typedef char *(*gpr_strdup_type)(const char *src);
+typedef char*(*gpr_strdup_type)(const char* src);
extern gpr_strdup_type gpr_strdup_import;
#define gpr_strdup gpr_strdup_import
-typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...) GPR_PRINT_FORMAT_CHECK(2, 3);
+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)();
+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);
+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);
+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);
+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);
+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);
+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
-typedef void(*gpr_mu_destroy_type)(gpr_mu *mu);
+typedef void(*gpr_mu_destroy_type)(gpr_mu* mu);
extern gpr_mu_destroy_type gpr_mu_destroy_import;
#define gpr_mu_destroy gpr_mu_destroy_import
-typedef void(*gpr_mu_lock_type)(gpr_mu *mu);
+typedef void(*gpr_mu_lock_type)(gpr_mu* mu);
extern gpr_mu_lock_type gpr_mu_lock_import;
#define gpr_mu_lock gpr_mu_lock_import
-typedef void(*gpr_mu_unlock_type)(gpr_mu *mu);
+typedef void(*gpr_mu_unlock_type)(gpr_mu* mu);
extern gpr_mu_unlock_type gpr_mu_unlock_import;
#define gpr_mu_unlock gpr_mu_unlock_import
-typedef int(*gpr_mu_trylock_type)(gpr_mu *mu);
+typedef int(*gpr_mu_trylock_type)(gpr_mu* mu);
extern gpr_mu_trylock_type gpr_mu_trylock_import;
#define gpr_mu_trylock gpr_mu_trylock_import
-typedef void(*gpr_cv_init_type)(gpr_cv *cv);
+typedef void(*gpr_cv_init_type)(gpr_cv* cv);
extern gpr_cv_init_type gpr_cv_init_import;
#define gpr_cv_init gpr_cv_init_import
-typedef void(*gpr_cv_destroy_type)(gpr_cv *cv);
+typedef void(*gpr_cv_destroy_type)(gpr_cv* cv);
extern gpr_cv_destroy_type gpr_cv_destroy_import;
#define gpr_cv_destroy gpr_cv_destroy_import
-typedef int(*gpr_cv_wait_type)(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline);
+typedef int(*gpr_cv_wait_type)(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline);
extern gpr_cv_wait_type gpr_cv_wait_import;
#define gpr_cv_wait gpr_cv_wait_import
-typedef void(*gpr_cv_signal_type)(gpr_cv *cv);
+typedef void(*gpr_cv_signal_type)(gpr_cv* cv);
extern gpr_cv_signal_type gpr_cv_signal_import;
#define gpr_cv_signal gpr_cv_signal_import
-typedef void(*gpr_cv_broadcast_type)(gpr_cv *cv);
+typedef void(*gpr_cv_broadcast_type)(gpr_cv* cv);
extern gpr_cv_broadcast_type gpr_cv_broadcast_import;
#define gpr_cv_broadcast gpr_cv_broadcast_import
-typedef void(*gpr_once_init_type)(gpr_once *once, void (*init_routine)(void));
+typedef void(*gpr_once_init_type)(gpr_once* once, void (*init_routine)(void));
extern gpr_once_init_type gpr_once_init_import;
#define gpr_once_init gpr_once_init_import
-typedef void(*gpr_event_init_type)(gpr_event *ev);
+typedef void(*gpr_event_init_type)(gpr_event* ev);
extern gpr_event_init_type gpr_event_init_import;
#define gpr_event_init gpr_event_init_import
-typedef void(*gpr_event_set_type)(gpr_event *ev, void *value);
+typedef void(*gpr_event_set_type)(gpr_event* ev, void* value);
extern gpr_event_set_type gpr_event_set_import;
#define gpr_event_set gpr_event_set_import
-typedef void *(*gpr_event_get_type)(gpr_event *ev);
+typedef void*(*gpr_event_get_type)(gpr_event* ev);
extern gpr_event_get_type gpr_event_get_import;
#define gpr_event_get gpr_event_get_import
-typedef void *(*gpr_event_wait_type)(gpr_event *ev, gpr_timespec abs_deadline);
+typedef void*(*gpr_event_wait_type)(gpr_event* ev, gpr_timespec abs_deadline);
extern gpr_event_wait_type gpr_event_wait_import;
#define gpr_event_wait gpr_event_wait_import
-typedef void(*gpr_ref_init_type)(gpr_refcount *r, int n);
+typedef void(*gpr_ref_init_type)(gpr_refcount* r, int n);
extern gpr_ref_init_type gpr_ref_init_import;
#define gpr_ref_init gpr_ref_init_import
-typedef void(*gpr_ref_type)(gpr_refcount *r);
+typedef void(*gpr_ref_type)(gpr_refcount* r);
extern gpr_ref_type gpr_ref_import;
#define gpr_ref gpr_ref_import
-typedef void(*gpr_ref_non_zero_type)(gpr_refcount *r);
+typedef void(*gpr_ref_non_zero_type)(gpr_refcount* r);
extern gpr_ref_non_zero_type gpr_ref_non_zero_import;
#define gpr_ref_non_zero gpr_ref_non_zero_import
-typedef void(*gpr_refn_type)(gpr_refcount *r, int n);
+typedef void(*gpr_refn_type)(gpr_refcount* r, int n);
extern gpr_refn_type gpr_refn_import;
#define gpr_refn gpr_refn_import
-typedef int(*gpr_unref_type)(gpr_refcount *r);
+typedef int(*gpr_unref_type)(gpr_refcount* r);
extern gpr_unref_type gpr_unref_import;
#define gpr_unref gpr_unref_import
-typedef int(*gpr_ref_is_unique_type)(gpr_refcount *r);
+typedef int(*gpr_ref_is_unique_type)(gpr_refcount* r);
extern gpr_ref_is_unique_type gpr_ref_is_unique_import;
#define gpr_ref_is_unique gpr_ref_is_unique_import
-typedef void(*gpr_stats_init_type)(gpr_stats_counter *c, intptr_t n);
+typedef void(*gpr_stats_init_type)(gpr_stats_counter* c, intptr_t n);
extern gpr_stats_init_type gpr_stats_init_import;
#define gpr_stats_init gpr_stats_init_import
-typedef void(*gpr_stats_inc_type)(gpr_stats_counter *c, intptr_t inc);
+typedef void(*gpr_stats_inc_type)(gpr_stats_counter* c, intptr_t inc);
extern gpr_stats_inc_type gpr_stats_inc_import;
#define gpr_stats_inc gpr_stats_inc_import
-typedef intptr_t(*gpr_stats_read_type)(const gpr_stats_counter *c);
+typedef intptr_t(*gpr_stats_read_type)(const gpr_stats_counter* c);
extern gpr_stats_read_type gpr_stats_read_import;
#define gpr_stats_read gpr_stats_read_import
-typedef int(*gpr_thd_new_type)(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg, const gpr_thd_options *options);
+typedef int(*gpr_thd_new_type)(gpr_thd_id* t, const char* thd_name, void (*thd_body)(void* arg), void* arg, const gpr_thd_options* options);
extern gpr_thd_new_type gpr_thd_new_import;
#define gpr_thd_new gpr_thd_new_import
typedef gpr_thd_options(*gpr_thd_options_default_type)(void);
extern gpr_thd_options_default_type gpr_thd_options_default_import;
#define gpr_thd_options_default gpr_thd_options_default_import
-typedef void(*gpr_thd_options_set_detached_type)(gpr_thd_options *options);
+typedef void(*gpr_thd_options_set_detached_type)(gpr_thd_options* options);
extern gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import;
#define gpr_thd_options_set_detached gpr_thd_options_set_detached_import
-typedef void(*gpr_thd_options_set_joinable_type)(gpr_thd_options *options);
+typedef void(*gpr_thd_options_set_joinable_type)(gpr_thd_options* options);
extern gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import;
#define gpr_thd_options_set_joinable gpr_thd_options_set_joinable_import
-typedef int(*gpr_thd_options_is_detached_type)(const gpr_thd_options *options);
+typedef int(*gpr_thd_options_is_detached_type)(const gpr_thd_options* options);
extern gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import;
#define gpr_thd_options_is_detached gpr_thd_options_is_detached_import
-typedef int(*gpr_thd_options_is_joinable_type)(const gpr_thd_options *options);
+typedef int(*gpr_thd_options_is_joinable_type)(const gpr_thd_options* options);
extern gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import;
#define gpr_thd_options_is_joinable gpr_thd_options_is_joinable_import
typedef gpr_thd_id(*gpr_thd_currentid_type)(void);
diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c
index e96de4f2f9..160c1533ba 100644
--- a/src/ruby/ext/grpc/rb_server.c
+++ b/src/ruby/ext/grpc/rb_server.c
@@ -44,12 +44,12 @@ static VALUE id_insecure_server;
/* grpc_rb_server wraps a grpc_server. */
typedef struct grpc_rb_server {
/* The actual server */
- grpc_server *wrapped;
- grpc_completion_queue *queue;
+ grpc_server* wrapped;
+ grpc_completion_queue* queue;
gpr_atm shutdown_started;
} grpc_rb_server;
-static void destroy_server(grpc_rb_server *server, gpr_timespec deadline) {
+static void destroy_server(grpc_rb_server* server, gpr_timespec deadline) {
grpc_event ev;
// This can be started by app or implicitly by GC. Avoid a race between these.
if (gpr_atm_full_fetch_add(&server->shutdown_started, (gpr_atm)1) == 0) {
@@ -70,13 +70,13 @@ static void destroy_server(grpc_rb_server *server, gpr_timespec deadline) {
}
/* Destroys server instances. */
-static void grpc_rb_server_free(void *p) {
- grpc_rb_server *svr = NULL;
+static void grpc_rb_server_free(void* p) {
+ grpc_rb_server* svr = NULL;
gpr_timespec deadline;
if (p == NULL) {
return;
};
- svr = (grpc_rb_server *)p;
+ svr = (grpc_rb_server*)p;
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(2, GPR_TIMESPAN));
@@ -105,7 +105,7 @@ static const rb_data_type_t grpc_rb_server_data_type = {
/* Allocates grpc_rb_server instances. */
static VALUE grpc_rb_server_alloc(VALUE cls) {
- grpc_rb_server *wrapper = ALLOC(grpc_rb_server);
+ grpc_rb_server* wrapper = ALLOC(grpc_rb_server);
wrapper->wrapped = NULL;
wrapper->shutdown_started = (gpr_atm)0;
return TypedData_Wrap_Struct(cls, &grpc_rb_server_data_type, wrapper);
@@ -117,9 +117,9 @@ static VALUE grpc_rb_server_alloc(VALUE cls) {
Initializes server instances. */
static VALUE grpc_rb_server_init(VALUE self, VALUE channel_args) {
- grpc_completion_queue *cq = NULL;
- grpc_rb_server *wrapper = NULL;
- grpc_server *srv = NULL;
+ grpc_completion_queue* cq = NULL;
+ grpc_rb_server* wrapper = NULL;
+ grpc_server* srv = NULL;
grpc_channel_args args;
MEMZERO(&args, grpc_channel_args, 1);
@@ -153,7 +153,7 @@ typedef struct request_call_stack {
/* grpc_request_call_stack_init ensures the request_call_stack is properly
* initialized */
-static void grpc_request_call_stack_init(request_call_stack *st) {
+static void grpc_request_call_stack_init(request_call_stack* st) {
MEMZERO(st, request_call_stack, 1);
grpc_metadata_array_init(&st->md_ary);
grpc_call_details_init(&st->details);
@@ -161,7 +161,7 @@ static void grpc_request_call_stack_init(request_call_stack *st) {
/* grpc_request_call_stack_cleanup ensures the request_call_stack is properly
* cleaned up */
-static void grpc_request_call_stack_cleanup(request_call_stack *st) {
+static void grpc_request_call_stack_cleanup(request_call_stack* st) {
grpc_metadata_array_destroy(&st->md_ary);
grpc_call_details_destroy(&st->details);
}
@@ -171,14 +171,14 @@ static void grpc_request_call_stack_cleanup(request_call_stack *st) {
Requests notification of a new call on a server. */
static VALUE grpc_rb_server_request_call(VALUE self) {
- grpc_rb_server *s = NULL;
- grpc_call *call = NULL;
+ grpc_rb_server* s = NULL;
+ grpc_call* call = NULL;
grpc_event ev;
grpc_call_error err;
request_call_stack st;
VALUE result;
- void *tag = (void *)&st;
- grpc_completion_queue *call_queue =
+ void* tag = (void*)&st;
+ grpc_completion_queue* call_queue =
grpc_completion_queue_create_for_pluck(NULL);
gpr_timespec deadline;
@@ -222,7 +222,7 @@ static VALUE grpc_rb_server_request_call(VALUE self) {
}
static VALUE grpc_rb_server_start(VALUE self) {
- grpc_rb_server *s = NULL;
+ grpc_rb_server* s = NULL;
TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
if (s->wrapped == NULL) {
rb_raise(rb_eRuntimeError, "destroyed!");
@@ -244,10 +244,10 @@ static VALUE grpc_rb_server_start(VALUE self) {
server.destroy(timeout)
Destroys server instances. */
-static VALUE grpc_rb_server_destroy(int argc, VALUE *argv, VALUE self) {
+static VALUE grpc_rb_server_destroy(int argc, VALUE* argv, VALUE self) {
VALUE timeout = Qnil;
gpr_timespec deadline;
- grpc_rb_server *s = NULL;
+ grpc_rb_server* s = NULL;
/* "01" == 0 mandatory args, 1 (timeout) is optional */
rb_scan_args(argc, argv, "01", &timeout);
@@ -277,8 +277,8 @@ static VALUE grpc_rb_server_destroy(int argc, VALUE *argv, VALUE self) {
Adds a http2 port to server */
static VALUE grpc_rb_server_add_http2_port(VALUE self, VALUE port,
VALUE rb_creds) {
- grpc_rb_server *s = NULL;
- grpc_server_credentials *creds = NULL;
+ grpc_rb_server* s = NULL;
+ grpc_server_credentials* creds = NULL;
int recvd_port = 0;
TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
@@ -335,8 +335,8 @@ void Init_grpc_server() {
}
/* Gets the wrapped server from the ruby wrapper */
-grpc_server *grpc_rb_get_wrapped_server(VALUE v) {
- grpc_rb_server *wrapper = NULL;
+grpc_server* grpc_rb_get_wrapped_server(VALUE v) {
+ grpc_rb_server* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_server, &grpc_rb_server_data_type, wrapper);
return wrapper->wrapped;
}
diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c
index 6d7b54c5d6..368d5c2fd8 100644
--- a/src/ruby/ext/grpc/rb_server_credentials.c
+++ b/src/ruby/ext/grpc/rb_server_credentials.c
@@ -38,16 +38,16 @@ typedef struct grpc_rb_server_credentials {
/* Holder of ruby objects involved in constructing the server credentials */
VALUE mark;
/* The actual server credentials */
- grpc_server_credentials *wrapped;
+ grpc_server_credentials* wrapped;
} grpc_rb_server_credentials;
/* Destroys the server credentials instances. */
-static void grpc_rb_server_credentials_free(void *p) {
- grpc_rb_server_credentials *wrapper = NULL;
+static void grpc_rb_server_credentials_free(void* p) {
+ grpc_rb_server_credentials* wrapper = NULL;
if (p == NULL) {
return;
};
- wrapper = (grpc_rb_server_credentials *)p;
+ wrapper = (grpc_rb_server_credentials*)p;
/* Delete the wrapped object if the mark object is Qnil, which indicates that
no other object is the actual owner. */
@@ -60,12 +60,12 @@ static void grpc_rb_server_credentials_free(void *p) {
}
/* Protects the mark object from GC */
-static void grpc_rb_server_credentials_mark(void *p) {
- grpc_rb_server_credentials *wrapper = NULL;
+static void grpc_rb_server_credentials_mark(void* p) {
+ grpc_rb_server_credentials* wrapper = NULL;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_server_credentials *)p;
+ wrapper = (grpc_rb_server_credentials*)p;
/* If it's not already cleaned up, mark the mark object */
if (wrapper->mark != Qnil) {
@@ -90,7 +90,7 @@ static const rb_data_type_t grpc_rb_server_credentials_data_type = {
Provides safe initial defaults for the instance fields. */
static VALUE grpc_rb_server_credentials_alloc(VALUE cls) {
- grpc_rb_server_credentials *wrapper = ALLOC(grpc_rb_server_credentials);
+ grpc_rb_server_credentials* wrapper = ALLOC(grpc_rb_server_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_rb_server_credentials_data_type,
@@ -128,9 +128,9 @@ static VALUE sym_private_key;
static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
VALUE pem_key_certs,
VALUE force_client_auth) {
- grpc_rb_server_credentials *wrapper = NULL;
- grpc_server_credentials *creds = NULL;
- grpc_ssl_pem_key_cert_pair *key_cert_pairs = NULL;
+ grpc_rb_server_credentials* wrapper = NULL;
+ grpc_server_credentials* creds = NULL;
+ grpc_ssl_pem_key_cert_pair* key_cert_pairs = NULL;
VALUE cert = Qnil;
VALUE key = Qnil;
VALUE key_cert = Qnil;
@@ -235,8 +235,8 @@ void Init_grpc_server_credentials() {
}
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */
-grpc_server_credentials *grpc_rb_get_wrapped_server_credentials(VALUE v) {
- grpc_rb_server_credentials *wrapper = NULL;
+grpc_server_credentials* grpc_rb_get_wrapped_server_credentials(VALUE v) {
+ grpc_rb_server_credentials* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_server_credentials,
&grpc_rb_server_credentials_data_type, wrapper);
return wrapper->wrapped;
diff --git a/src/ruby/lib/grpc.rb b/src/ruby/lib/grpc.rb
index 98bfc0a0fa..37b0392072 100644
--- a/src/ruby/lib/grpc.rb
+++ b/src/ruby/lib/grpc.rb
@@ -24,6 +24,7 @@ require_relative 'grpc/generic/active_call'
require_relative 'grpc/generic/client_stub'
require_relative 'grpc/generic/service'
require_relative 'grpc/generic/rpc_server'
+require_relative 'grpc/generic/interceptors'
begin
file = File.open(ssl_roots_path)
diff --git a/src/ruby/lib/grpc/generic/active_call.rb b/src/ruby/lib/grpc/generic/active_call.rb
index 10eb70b4a7..8c3aa284aa 100644
--- a/src/ruby/lib/grpc/generic/active_call.rb
+++ b/src/ruby/lib/grpc/generic/active_call.rb
@@ -154,6 +154,15 @@ module GRPC
Operation.new(self)
end
+ ##
+ # Returns a restricted view of this ActiveCall for use in interceptors
+ #
+ # @return [InterceptableView]
+ #
+ def interceptable
+ InterceptableView.new(self)
+ end
+
def receive_and_check_status
batch_result = @call.run_batch(RECV_STATUS_ON_CLIENT => nil)
set_input_stream_done
@@ -515,15 +524,27 @@ module GRPC
# This does not mean that must necessarily be one. E.g, the replies
# produced by gen_each_reply could ignore the received_msgs
#
- # @param gen_each_reply [Proc] generates the BiDi stream replies
- def run_server_bidi(gen_each_reply)
- bd = BidiCall.new(@call,
- @marshal,
- @unmarshal,
- metadata_received: @metadata_received,
- req_view: MultiReqView.new(self))
-
- bd.run_on_server(gen_each_reply, proc { set_input_stream_done })
+ # @param mth [Proc] generates the BiDi stream replies
+ # @param interception_ctx [InterceptionContext]
+ #
+ def run_server_bidi(mth, interception_ctx)
+ view = multi_req_view
+ bidi_call = BidiCall.new(
+ @call,
+ @marshal,
+ @unmarshal,
+ metadata_received: @metadata_received,
+ req_view: view
+ )
+ requests = bidi_call.read_next_loop(proc { set_input_stream_done }, false)
+ interception_ctx.intercept!(
+ :bidi_streamer,
+ call: view,
+ method: mth,
+ requests: requests
+ ) do
+ bidi_call.run_on_server(mth, requests)
+ end
end
# Waits till an operation completes
@@ -645,5 +666,9 @@ module GRPC
Operation = view_class(:cancel, :cancelled?, :deadline, :execute,
:metadata, :status, :start_call, :wait, :write_flag,
:write_flag=, :trailing_metadata)
+
+ # InterceptableView further limits access to an ActiveCall's methods
+ # for use in interceptors on the client, exposing only the deadline
+ InterceptableView = view_class(:deadline)
end
end
diff --git a/src/ruby/lib/grpc/generic/bidi_call.rb b/src/ruby/lib/grpc/generic/bidi_call.rb
index c2239d0178..3bdcc0062e 100644
--- a/src/ruby/lib/grpc/generic/bidi_call.rb
+++ b/src/ruby/lib/grpc/generic/bidi_call.rb
@@ -87,23 +87,32 @@ module GRPC
# This does not mean that must necessarily be one. E.g, the replies
# produced by gen_each_reply could ignore the received_msgs
#
- # @param gen_each_reply [Proc] generates the BiDi stream replies.
- # @param set_input_steam_done [Proc] call back to call when
- # the reads have been completely read through.
- def run_on_server(gen_each_reply, set_input_stream_done)
+ # @param [Proc] gen_each_reply generates the BiDi stream replies.
+ # @param [Enumerable] requests The enumerable of requests to run
+ def run_on_server(gen_each_reply, requests)
+ replies = nil
+
# Pass in the optional call object parameter if possible
if gen_each_reply.arity == 1
- replys = gen_each_reply.call(
- read_loop(set_input_stream_done, is_client: false))
+ replies = gen_each_reply.call(requests)
elsif gen_each_reply.arity == 2
- replys = gen_each_reply.call(
- read_loop(set_input_stream_done, is_client: false),
- @req_view)
+ replies = gen_each_reply.call(requests, @req_view)
else
fail 'Illegal arity of reply generator'
end
- write_loop(replys, is_client: false)
+ write_loop(replies, is_client: false)
+ end
+
+ ##
+ # Read the next stream iteration
+ #
+ # @param [Proc] finalize_stream callback to call when the reads have been
+ # completely read through.
+ # @param [Boolean] is_client If this is a client or server request
+ #
+ def read_next_loop(finalize_stream, is_client = false)
+ read_loop(finalize_stream, is_client: is_client)
end
private
diff --git a/src/ruby/lib/grpc/generic/client_stub.rb b/src/ruby/lib/grpc/generic/client_stub.rb
index 75a95a4e94..9a50f8a99d 100644
--- a/src/ruby/lib/grpc/generic/client_stub.rb
+++ b/src/ruby/lib/grpc/generic/client_stub.rb
@@ -89,17 +89,23 @@ module GRPC
# used within a gRPC server.
# @param channel_args [Hash] the channel arguments. Note: this argument is
# ignored if the channel_override argument is provided.
+ # @param interceptors [Array<GRPC::ClientInterceptor>] An array of
+ # GRPC::ClientInterceptor objects that will be used for
+ # intercepting calls before they are executed
+ # Interceptors are an EXPERIMENTAL API.
def initialize(host, creds,
channel_override: nil,
timeout: nil,
propagate_mask: nil,
- channel_args: {})
+ channel_args: {},
+ interceptors: [])
@ch = ClientStub.setup_channel(channel_override, host, creds,
channel_args)
alt_host = channel_args[Core::Channel::SSL_TARGET]
@host = alt_host.nil? ? host : alt_host
@propagate_mask = propagate_mask
@timeout = timeout.nil? ? DEFAULT_TIMEOUT : timeout
+ @interceptors = InterceptorRegistry.new(interceptors)
end
# request_response sends a request to a GRPC server, and returns the
@@ -149,16 +155,29 @@ module GRPC
deadline: deadline,
parent: parent,
credentials: credentials)
- return c.request_response(req, metadata: metadata) unless return_op
-
- # return the operation view of the active_call; define #execute as a
- # new method for this instance that invokes #request_response.
- c.merge_metadata_to_send(metadata)
- op = c.operation
- op.define_singleton_method(:execute) do
- c.request_response(req, metadata: metadata)
+ interception_context = @interceptors.build_context
+ intercept_args = {
+ method: method,
+ request: req,
+ call: c.interceptable,
+ metadata: metadata
+ }
+ if return_op
+ # return the operation view of the active_call; define #execute as a
+ # new method for this instance that invokes #request_response.
+ c.merge_metadata_to_send(metadata)
+ op = c.operation
+ op.define_singleton_method(:execute) do
+ interception_context.intercept!(:request_response, intercept_args) do
+ c.request_response(req, metadata: metadata)
+ end
+ end
+ op
+ else
+ interception_context.intercept!(:request_response, intercept_args) do
+ c.request_response(req, metadata: metadata)
+ end
end
- op
end
# client_streamer sends a stream of requests to a GRPC server, and
@@ -213,16 +232,29 @@ module GRPC
deadline: deadline,
parent: parent,
credentials: credentials)
- return c.client_streamer(requests, metadata: metadata) unless return_op
-
- # return the operation view of the active_call; define #execute as a
- # new method for this instance that invokes #client_streamer.
- c.merge_metadata_to_send(metadata)
- op = c.operation
- op.define_singleton_method(:execute) do
- c.client_streamer(requests)
+ interception_context = @interceptors.build_context
+ intercept_args = {
+ method: method,
+ requests: requests,
+ call: c.interceptable,
+ metadata: metadata
+ }
+ if return_op
+ # return the operation view of the active_call; define #execute as a
+ # new method for this instance that invokes #client_streamer.
+ c.merge_metadata_to_send(metadata)
+ op = c.operation
+ op.define_singleton_method(:execute) do
+ interception_context.intercept!(:client_streamer, intercept_args) do
+ c.client_streamer(requests)
+ end
+ end
+ op
+ else
+ interception_context.intercept!(:client_streamer, intercept_args) do
+ c.client_streamer(requests, metadata: metadata)
+ end
end
- op
end
# server_streamer sends one request to the GRPC server, which yields a
@@ -292,16 +324,29 @@ module GRPC
deadline: deadline,
parent: parent,
credentials: credentials)
- return c.server_streamer(req, metadata: metadata, &blk) unless return_op
-
- # return the operation view of the active_call; define #execute
- # as a new method for this instance that invokes #server_streamer
- c.merge_metadata_to_send(metadata)
- op = c.operation
- op.define_singleton_method(:execute) do
- c.server_streamer(req, &blk)
+ interception_context = @interceptors.build_context
+ intercept_args = {
+ method: method,
+ request: req,
+ call: c.interceptable,
+ metadata: metadata
+ }
+ if return_op
+ # return the operation view of the active_call; define #execute
+ # as a new method for this instance that invokes #server_streamer
+ c.merge_metadata_to_send(metadata)
+ op = c.operation
+ op.define_singleton_method(:execute) do
+ interception_context.intercept!(:server_streamer, intercept_args) do
+ c.server_streamer(req, &blk)
+ end
+ end
+ op
+ else
+ interception_context.intercept!(:server_streamer, intercept_args) do
+ c.server_streamer(req, metadata: metadata, &blk)
+ end
end
- op
end
# bidi_streamer sends a stream of requests to the GRPC server, and yields
@@ -405,17 +450,29 @@ module GRPC
deadline: deadline,
parent: parent,
credentials: credentials)
- return c.bidi_streamer(requests, metadata: metadata,
- &blk) unless return_op
-
- # return the operation view of the active_call; define #execute
- # as a new method for this instance that invokes #bidi_streamer
- c.merge_metadata_to_send(metadata)
- op = c.operation
- op.define_singleton_method(:execute) do
- c.bidi_streamer(requests, &blk)
+ interception_context = @interceptors.build_context
+ intercept_args = {
+ method: method,
+ requests: requests,
+ call: c.interceptable,
+ metadata: metadata
+ }
+ if return_op
+ # return the operation view of the active_call; define #execute
+ # as a new method for this instance that invokes #bidi_streamer
+ c.merge_metadata_to_send(metadata)
+ op = c.operation
+ op.define_singleton_method(:execute) do
+ interception_context.intercept!(:bidi_streamer, intercept_args) do
+ c.bidi_streamer(requests, &blk)
+ end
+ end
+ op
+ else
+ interception_context.intercept!(:bidi_streamer, intercept_args) do
+ c.bidi_streamer(requests, metadata: metadata, &blk)
+ end
end
- op
end
private
diff --git a/src/ruby/lib/grpc/generic/interceptor_registry.rb b/src/ruby/lib/grpc/generic/interceptor_registry.rb
new file mode 100644
index 0000000000..b241eb9a86
--- /dev/null
+++ b/src/ruby/lib/grpc/generic/interceptor_registry.rb
@@ -0,0 +1,53 @@
+# 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.
+
+# GRPC contains the General RPC module.
+module GRPC
+ ##
+ # Represents a registry of added interceptors available for enumeration.
+ # The registry can be used for both server and client interceptors.
+ # This class is internal to gRPC and not meant for public usage.
+ #
+ class InterceptorRegistry
+ ##
+ # An error raised when an interceptor is attempted to be added
+ # that does not extend GRPC::Interceptor
+ #
+ class DescendantError < StandardError; end
+
+ ##
+ # Initialize the registry with an empty interceptor list
+ # This is an EXPERIMENTAL API.
+ #
+ def initialize(interceptors = [])
+ @interceptors = []
+ interceptors.each do |i|
+ base = GRPC::Interceptor
+ unless i.class.ancestors.include?(base)
+ fail DescendantError, "Interceptors must descend from #{base}"
+ end
+ @interceptors << i
+ end
+ end
+
+ ##
+ # Builds an interception context from this registry
+ #
+ # @return [InterceptionContext]
+ #
+ def build_context
+ InterceptionContext.new(@interceptors)
+ end
+ end
+end
diff --git a/src/ruby/lib/grpc/generic/interceptors.rb b/src/ruby/lib/grpc/generic/interceptors.rb
new file mode 100644
index 0000000000..24482f3451
--- /dev/null
+++ b/src/ruby/lib/grpc/generic/interceptors.rb
@@ -0,0 +1,186 @@
+# 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.
+require_relative 'interceptor_registry'
+
+# GRPC contains the General RPC module.
+module GRPC
+ ##
+ # Base class for interception in GRPC
+ #
+ class Interceptor
+ ##
+ # @param [Hash] options A hash of options that will be used
+ # by the interceptor. This is an EXPERIMENTAL API.
+ #
+ def initialize(options = {})
+ @options = options || {}
+ end
+ end
+
+ ##
+ # ClientInterceptor allows for wrapping outbound gRPC client stub requests.
+ # This is an EXPERIMENTAL API.
+ #
+ class ClientInterceptor < Interceptor
+ ##
+ # Intercept a unary request response call
+ #
+ # @param [Object] request
+ # @param [GRPC::ActiveCall] call
+ # @param [Method] method
+ # @param [Hash] metadata
+ #
+ def request_response(request: nil, call: nil, method: nil, metadata: nil)
+ GRPC.logger.debug "Intercepting request response method #{method}" \
+ " for request #{request} with call #{call} and metadata: #{metadata}"
+ yield
+ end
+
+ ##
+ # Intercept a client streaming call
+ #
+ # @param [Enumerable] requests
+ # @param [GRPC::ActiveCall] call
+ # @param [Method] method
+ # @param [Hash] metadata
+ #
+ def client_streamer(requests: nil, call: nil, method: nil, metadata: nil)
+ GRPC.logger.debug "Intercepting client streamer method #{method}" \
+ " for requests #{requests} with call #{call} and metadata: #{metadata}"
+ yield
+ end
+
+ ##
+ # Intercept a server streaming call
+ #
+ # @param [Object] request
+ # @param [GRPC::ActiveCall] call
+ # @param [Method] method
+ # @param [Hash] metadata
+ #
+ def server_streamer(request: nil, call: nil, method: nil, metadata: nil)
+ GRPC.logger.debug "Intercepting server streamer method #{method}" \
+ " for request #{request} with call #{call} and metadata: #{metadata}"
+ yield
+ end
+
+ ##
+ # Intercept a BiDi streaming call
+ #
+ # @param [Enumerable] requests
+ # @param [GRPC::ActiveCall] call
+ # @param [Method] method
+ # @param [Hash] metadata
+ #
+ def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil)
+ GRPC.logger.debug "Intercepting bidi streamer method #{method}" \
+ " for requests #{requests} with call #{call} and metadata: #{metadata}"
+ yield
+ end
+ end
+
+ ##
+ # ServerInterceptor allows for wrapping gRPC server execution handling.
+ # This is an EXPERIMENTAL API.
+ #
+ class ServerInterceptor < Interceptor
+ ##
+ # Intercept a unary request response call.
+ #
+ # @param [Object] request
+ # @param [GRPC::ActiveCall::SingleReqView] call
+ # @param [Method] method
+ #
+ def request_response(request: nil, call: nil, method: nil)
+ GRPC.logger.debug "Intercepting request response method #{method}" \
+ " for request #{request} with call #{call}"
+ yield
+ end
+
+ ##
+ # Intercept a client streaming call
+ #
+ # @param [GRPC::ActiveCall::MultiReqView] call
+ # @param [Method] method
+ #
+ def client_streamer(call: nil, method: nil)
+ GRPC.logger.debug "Intercepting client streamer method #{method}" \
+ " with call #{call}"
+ yield
+ end
+
+ ##
+ # Intercept a server streaming call
+ #
+ # @param [Object] request
+ # @param [GRPC::ActiveCall::SingleReqView] call
+ # @param [Method] method
+ #
+ def server_streamer(request: nil, call: nil, method: nil)
+ GRPC.logger.debug "Intercepting server streamer method #{method}" \
+ " for request #{request} with call #{call}"
+ yield
+ end
+
+ ##
+ # Intercept a BiDi streaming call
+ #
+ # @param [Enumerable<Object>] requests
+ # @param [GRPC::ActiveCall::MultiReqView] call
+ # @param [Method] method
+ #
+ def bidi_streamer(requests: nil, call: nil, method: nil)
+ GRPC.logger.debug "Intercepting bidi streamer method #{method}" \
+ " for requests #{requests} with call #{call}"
+ yield
+ end
+ end
+
+ ##
+ # Represents the context in which an interceptor runs. Used to provide an
+ # injectable mechanism for handling interception. This is an EXPERIMENTAL API.
+ #
+ class InterceptionContext
+ ##
+ # @param [Array<GRPC::Interceptor>]
+ #
+ def initialize(interceptors = [])
+ @interceptors = interceptors.dup
+ end
+
+ ##
+ # Intercept the call and fire out to interceptors in a FIFO execution.
+ # This is an EXPERIMENTAL API.
+ #
+ # @param [Symbol] type The request type
+ # @param [Hash] args The arguments for the call
+ #
+ def intercept!(type, args = {})
+ return yield if @interceptors.none?
+
+ i = @interceptors.pop
+ return yield unless i
+
+ i.send(type, args) do
+ if @interceptors.any?
+ intercept!(type, args) do
+ yield
+ end
+ else
+ yield
+ end
+ end
+ end
+ end
+end
diff --git a/src/ruby/lib/grpc/generic/rpc_desc.rb b/src/ruby/lib/grpc/generic/rpc_desc.rb
index 6fb6c412fb..5fd1805aab 100644
--- a/src/ruby/lib/grpc/generic/rpc_desc.rb
+++ b/src/ruby/lib/grpc/generic/rpc_desc.rb
@@ -47,43 +47,85 @@ module GRPC
proc { |o| unmarshal_class.method(unmarshal_method).call(o) }
end
- def handle_request_response(active_call, mth)
+ def handle_request_response(active_call, mth, inter_ctx)
req = active_call.read_unary_request
- resp = mth.call(req, active_call.single_req_view)
- active_call.server_unary_response(
- resp, trailing_metadata: active_call.output_metadata)
+ call = active_call.single_req_view
+
+ inter_ctx.intercept!(
+ :request_response,
+ method: mth,
+ call: call,
+ request: req
+ ) do
+ resp = mth.call(req, call)
+ active_call.server_unary_response(
+ resp,
+ trailing_metadata: active_call.output_metadata
+ )
+ end
end
- def handle_client_streamer(active_call, mth)
- resp = mth.call(active_call.multi_req_view)
- active_call.server_unary_response(
- resp, trailing_metadata: active_call.output_metadata)
+ def handle_client_streamer(active_call, mth, inter_ctx)
+ call = active_call.multi_req_view
+
+ inter_ctx.intercept!(
+ :client_streamer,
+ method: mth,
+ call: call
+ ) do
+ resp = mth.call(call)
+ active_call.server_unary_response(
+ resp,
+ trailing_metadata: active_call.output_metadata
+ )
+ end
end
- def handle_server_streamer(active_call, mth)
+ def handle_server_streamer(active_call, mth, inter_ctx)
req = active_call.read_unary_request
- replys = mth.call(req, active_call.single_req_view)
- replys.each { |r| active_call.remote_send(r) }
- send_status(active_call, OK, 'OK', active_call.output_metadata)
+ call = active_call.single_req_view
+
+ inter_ctx.intercept!(
+ :server_streamer,
+ method: mth,
+ call: call,
+ request: req
+ ) do
+ replies = mth.call(req, call)
+ replies.each { |r| active_call.remote_send(r) }
+ send_status(active_call, OK, 'OK', active_call.output_metadata)
+ end
end
- def handle_bidi_streamer(active_call, mth)
- active_call.run_server_bidi(mth)
+ ##
+ # @param [GRPC::ActiveCall] active_call
+ # @param [Method] mth
+ # @param [Array<GRPC::InterceptionContext>] inter_ctx
+ #
+ def handle_bidi_streamer(active_call, mth, inter_ctx)
+ active_call.run_server_bidi(mth, inter_ctx)
send_status(active_call, OK, 'OK', active_call.output_metadata)
end
- def run_server_method(active_call, mth)
+ ##
+ # @param [GRPC::ActiveCall] active_call The current active call object
+ # for the request
+ # @param [Method] mth The current RPC method being called
+ # @param [GRPC::InterceptionContext] inter_ctx The interception context
+ # being executed
+ #
+ def run_server_method(active_call, mth, inter_ctx = InterceptionContext.new)
# While a server method is running, it might be cancelled, its deadline
# might be reached, the handler could throw an unknown error, or a
# well-behaved handler could throw a StatusError.
if request_response?
- handle_request_response(active_call, mth)
+ handle_request_response(active_call, mth, inter_ctx)
elsif client_streamer?
- handle_client_streamer(active_call, mth)
+ handle_client_streamer(active_call, mth, inter_ctx)
elsif server_streamer?
- handle_server_streamer(active_call, mth)
+ handle_server_streamer(active_call, mth, inter_ctx)
else # is a bidi_stream
- handle_bidi_streamer(active_call, mth)
+ handle_bidi_streamer(active_call, mth, inter_ctx)
end
rescue BadStatus => e
# this is raised by handlers that want GRPC to send an application error
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb
index 33b3cea1fc..c80c7fcd32 100644
--- a/src/ruby/lib/grpc/generic/rpc_server.rb
+++ b/src/ruby/lib/grpc/generic/rpc_server.rb
@@ -92,9 +92,13 @@ module GRPC
# Stops the jobs in the pool
def stop
GRPC.logger.info('stopping, will wait for all the workers to exit')
- schedule { throw :exit } while ready_for_work?
- @stop_mutex.synchronize do # wait @keep_alive for works to stop
+ @stop_mutex.synchronize do # wait @keep_alive seconds for workers to stop
@stopped = true
+ loop do
+ break unless ready_for_work?
+ worker_queue = @ready_workers.pop
+ worker_queue << [proc { throw :exit }, []]
+ end
@stop_cond.wait(@stop_mutex, @keep_alive) if @workers.size > 0
end
forcibly_stop_workers
@@ -138,7 +142,10 @@ module GRPC
end
# there shouldn't be any work given to this thread while its busy
fail('received a task while busy') unless worker_queue.empty?
- @ready_workers << worker_queue
+ @stop_mutex.synchronize do
+ return if @stopped
+ @ready_workers << worker_queue
+ end
end
end
end
@@ -186,8 +193,13 @@ module GRPC
# * max_waiting_requests: Deprecated due to internal changes to the thread
# pool. This is still an argument for compatibility but is ignored.
#
- # * poll_period: when present, the server polls for new events with this
- # period
+ # * poll_period: The amount of time in seconds to wait for
+ # currently-serviced RPC's to finish before cancelling them when shutting
+ # down the server.
+ #
+ # * pool_keep_alive: The amount of time in seconds to wait
+ # for currently busy thread-pool threads to finish before
+ # forcing an abrupt exit to each thread.
#
# * connect_md_proc:
# when non-nil is a proc for determining metadata to to send back the client
@@ -196,22 +208,31 @@ module GRPC
#
# * server_args:
# A server arguments hash to be passed down to the underlying core server
- def initialize(pool_size:DEFAULT_POOL_SIZE,
- max_waiting_requests:DEFAULT_MAX_WAITING_REQUESTS,
- poll_period:DEFAULT_POLL_PERIOD,
- connect_md_proc:nil,
- server_args:{})
+ #
+ # * interceptors:
+ # Am array of GRPC::ServerInterceptor objects that will be used for
+ # intercepting server handlers to provide extra functionality.
+ # Interceptors are an EXPERIMENTAL API.
+ #
+ def initialize(pool_size: DEFAULT_POOL_SIZE,
+ max_waiting_requests: DEFAULT_MAX_WAITING_REQUESTS,
+ poll_period: DEFAULT_POLL_PERIOD,
+ pool_keep_alive: GRPC::RpcServer::DEFAULT_POOL_SIZE,
+ connect_md_proc: nil,
+ server_args: {},
+ interceptors: [])
@connect_md_proc = RpcServer.setup_connect_md_proc(connect_md_proc)
@max_waiting_requests = max_waiting_requests
@poll_period = poll_period
@pool_size = pool_size
- @pool = Pool.new(@pool_size)
+ @pool = Pool.new(@pool_size, keep_alive: pool_keep_alive)
@run_cond = ConditionVariable.new
@run_mutex = Mutex.new
# running_state can take 4 values: :not_started, :running, :stopping, and
# :stopped. State transitions can only proceed in that order.
@running_state = :not_started
@server = Core::Server.new(server_args)
+ @interceptors = InterceptorRegistry.new(interceptors)
end
# stops a running server
@@ -374,7 +395,11 @@ module GRPC
@pool.schedule(active_call) do |ac|
c, mth = ac
begin
- rpc_descs[mth].run_server_method(c, rpc_handlers[mth])
+ rpc_descs[mth].run_server_method(
+ c,
+ rpc_handlers[mth],
+ @interceptors.build_context
+ )
rescue StandardError
c.send_status(GRPC::Core::StatusCodes::INTERNAL,
'Server handler failed')
@@ -382,7 +407,7 @@ module GRPC
end
end
rescue Core::CallError, RuntimeError => e
- # these might happen for various reasonse. The correct behaviour of
+ # these might happen for various reasons. The correct behavior of
# the server is to log them and continue, if it's not shutting down.
if running_state == :running
GRPC.logger.warn("server call failed: #{e}")
diff --git a/src/ruby/lib/grpc/google_rpc_status_utils.rb b/src/ruby/lib/grpc/google_rpc_status_utils.rb
index fdadd6b76e..f253b082b6 100644
--- a/src/ruby/lib/grpc/google_rpc_status_utils.rb
+++ b/src/ruby/lib/grpc/google_rpc_status_utils.rb
@@ -19,10 +19,17 @@ require 'google/rpc/status_pb'
module GRPC
# GoogleRpcStatusUtils provides utilities to convert between a
# GRPC::Core::Status and a deserialized Google::Rpc::Status proto
+ # Returns nil if the grpc-status-details-bin trailer could not be
+ # converted to a GoogleRpcStatus due to the server not providing
+ # the necessary trailers.
+ # Raises an error if the server did provide the necessary trailers
+ # but they fail to deseriliaze into a GoogleRpcStatus protobuf.
class GoogleRpcStatusUtils
def self.extract_google_rpc_status(status)
fail ArgumentError, 'bad type' unless status.is_a? Struct::Status
- Google::Rpc::Status.decode(status.metadata['grpc-status-details-bin'])
+ grpc_status_details_bin_trailer = 'grpc-status-details-bin'
+ return nil if status.metadata[grpc_status_details_bin_trailer].nil?
+ Google::Rpc::Status.decode(status.metadata[grpc_status_details_bin_trailer])
end
end
end
diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb
index 228c01a92c..9d9f2f4968 100644
--- a/src/ruby/lib/grpc/version.rb
+++ b/src/ruby/lib/grpc/version.rb
@@ -14,5 +14,5 @@
# GRPC contains the General RPC module.
module GRPC
- VERSION = '1.7.0.dev'
+ VERSION = '1.10.0.dev'
end
diff --git a/src/ruby/pb/grpc/health/checker.rb b/src/ruby/pb/grpc/health/checker.rb
index f23db39da5..c492455d8f 100644
--- a/src/ruby/pb/grpc/health/checker.rb
+++ b/src/ruby/pb/grpc/health/checker.rb
@@ -48,6 +48,20 @@ module Grpc
@status_mutex.synchronize { @statuses["#{service}"] = status }
end
+ # Adds given health status for all given services
+ def set_status_for_services(status, *services)
+ @status_mutex.synchronize do
+ services.each { |service| @statuses["#{service}"] = status }
+ end
+ end
+
+ # Adds health status for each service given within hash
+ def add_statuses(service_statuses = {})
+ @status_mutex.synchronize do
+ service_statuses.each_pair { |service, status| @statuses["#{service}"] = status }
+ end
+ end
+
# Clears the status for the given service.
def clear_status(service)
@status_mutex.synchronize { @statuses.delete("#{service}") }
diff --git a/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb b/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb
index 683370121e..ab50d9b3a5 100644
--- a/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb
+++ b/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb
@@ -34,6 +34,7 @@ module Grpc
self.service_name = 'grpc.testing.duplicate.EchoTestService'
rpc :Echo, Grpc::Testing::EchoRequest, Grpc::Testing::EchoResponse
+ rpc :ResponseStream, Grpc::Testing::EchoRequest, stream(Grpc::Testing::EchoResponse)
end
Stub = Service.rpc_stub_class
diff --git a/src/ruby/qps/histogram.rb b/src/ruby/qps/histogram.rb
index 1a27e17218..e48fb842be 100644
--- a/src/ruby/qps/histogram.rb
+++ b/src/ruby/qps/histogram.rb
@@ -16,6 +16,8 @@
# Histogram class for use in performance testing and measurement
+require 'thread'
+
class Histogram
# Determine the bucket index for a given value
# @param {number} value The value to check
@@ -27,6 +29,7 @@ class Histogram
# @param {number} resolution The resolution of the histogram
# @param {number} max_possible The maximum value for the histogram
def initialize(resolution, max_possible)
+ @lock = Mutex.new
@resolution=resolution
@max_possible=max_possible
@sum=0
@@ -70,4 +73,16 @@ class Histogram
def contents
@buckets
end
+
+ def merge(hist)
+ @lock.synchronize do
+ @min_seen = hist.min_seen
+ @max_seen = hist.max_seen
+ @sum += hist.sum
+ @sum_of_squares += hist.sum_of_squares
+ @count += hist.count
+ received_bucket = hist.bucket.to_a
+ @buckets = @buckets.map.with_index{ |m,i| m + received_bucket[i].to_i }
+ end
+ end
end
diff --git a/src/ruby/qps/proxy-worker.rb b/src/ruby/qps/proxy-worker.rb
index 488610ae74..4c7c510fdb 100755
--- a/src/ruby/qps/proxy-worker.rb
+++ b/src/ruby/qps/proxy-worker.rb
@@ -31,8 +31,10 @@ require 'src/proto/grpc/testing/services_services_pb'
require 'src/proto/grpc/testing/proxy-service_services_pb'
class ProxyBenchmarkClientServiceImpl < Grpc::Testing::ProxyClientService::Service
- def initialize(port)
+ def initialize(port, c_ext, php_client_bin)
@mytarget = "localhost:" + port.to_s
+ @use_c_ext = c_ext
+ @php_client_bin = php_client_bin
end
def setup(config)
@config = config
@@ -40,26 +42,49 @@ class ProxyBenchmarkClientServiceImpl < Grpc::Testing::ProxyClientService::Servi
@histmax = config.histogram_params.max_possible
@histogram = Histogram.new(@histres, @histmax)
@start_time = Time.now
- # TODO(vjpai): Support multiple client channels by spawning off a PHP client per channel
- command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " + File.expand_path(File.dirname(__FILE__)) + "/../../php/tests/qps/client.php " + @mytarget
- puts "Starting command: " + command
- @php_pid = spawn(command)
+ @php_pid = Array.new(@config.client_channels)
+ (0..@config.client_channels-1).each do |chan|
+ Thread.new {
+ if @use_c_ext
+ puts "Use protobuf c extension"
+ command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) +
+ "/../../php/tests/qps/vendor/google/protobuf/php/ext/google/protobuf/modules/protobuf.so " +
+ "-d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " +
+ File.expand_path(File.dirname(__FILE__)) + "/" + @php_client_bin + " " + @mytarget + " #{chan%@config.server_targets.length}"
+ else
+ puts "Use protobuf php extension"
+ command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " +
+ File.expand_path(File.dirname(__FILE__)) + "/" + @php_client_bin + " " + @mytarget + " #{chan%@config.server_targets.length}"
+ end
+ puts "[ruby proxy] Starting #{chan}th php-client command use c protobuf #{@use_c_ext}: " + command
+ @php_pid[chan] = spawn(command)
+ while true
+ sleep
+ end
+ }
+ end
end
def stop
- Process.kill("TERM", @php_pid)
- Process.wait(@php_pid)
+ (0..@config.client_channels-1).each do |chan|
+ Process.kill("TERM", @php_pid[chan])
+ Process.wait(@php_pid[chan])
+ end
end
def get_config(_args, _call)
- puts "Answering get_config"
@config
end
def report_time(call)
- puts "Starting a time reporting stream"
call.each_remote_read do |lat|
@histogram.add((lat.latency)*1e9)
end
Grpc::Testing::Void.new
end
+ def report_hist(call)
+ call.each_remote_read do |lat|
+ @histogram.merge(lat)
+ end
+ Grpc::Testing::Void.new
+ end
def mark(reset)
lat = Grpc::Testing::HistogramData.new(
bucket: @histogram.contents,
@@ -121,22 +146,31 @@ end
def proxymain
options = {
- 'driver_port' => 0
+ 'driver_port' => 0,
+ 'php_client_bin' => '../../php/tests/qps/client.php'
}
OptionParser.new do |opts|
opts.banner = 'Usage: [--driver_port <port>]'
opts.on('--driver_port PORT', '<port>') do |v|
options['driver_port'] = v
end
+ opts.on("-c", "--[no-]use_protobuf_c_extension", "Use protobuf C-extention") do |c|
+ options[:c_ext] = c
+ end
+ opts.on("-b", "--php_client_bin [FILE]",
+ "PHP client to execute; path relative to this script") do |c|
+ options['php_client_bin'] = c
+ end
end.parse!
# Configure any errors with client or server child threads to surface
Thread.abort_on_exception = true
- s = GRPC::RpcServer.new
+ # Make sure proxy_server can handle the large number of calls in benchmarks
+ s = GRPC::RpcServer.new(pool_size: 1024)
port = s.add_http2_port("0.0.0.0:" + options['driver_port'].to_s,
:this_port_is_insecure)
- bmc = ProxyBenchmarkClientServiceImpl.new(port)
+ bmc = ProxyBenchmarkClientServiceImpl.new(port, options[:c_ext], options['php_client_bin'])
s.handle(bmc)
s.handle(ProxyWorkerServiceImpl.new(s, bmc))
s.run
diff --git a/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb b/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb
index d238198cca..583b2ea655 100644
--- a/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb
+++ b/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb
@@ -4,6 +4,7 @@
require 'google/protobuf'
require 'src/proto/grpc/testing/control_pb'
+require 'src/proto/grpc/testing/stats_pb'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "grpc.testing.ProxyStat" do
optional :latency, :double, 1
diff --git a/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb b/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb
index 484cf05f92..e7bb59b8a0 100644
--- a/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb
+++ b/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb
@@ -32,6 +32,7 @@ module Grpc
rpc :GetConfig, Void, ClientConfig
rpc :ReportTime, stream(ProxyStat), Void
+ rpc :ReportHist, stream(HistogramData), Void
end
Stub = Service.rpc_stub_class
diff --git a/src/ruby/qps/worker.rb b/src/ruby/qps/worker.rb
index 21e8815890..8258487418 100755
--- a/src/ruby/qps/worker.rb
+++ b/src/ruby/qps/worker.rb
@@ -77,8 +77,7 @@ class WorkerServiceImpl < Grpc::Testing::WorkerService::Service
Grpc::Testing::CoreResponse.new(cores: cpu_cores)
end
def quit_worker(_args, _call)
- Thread.new {
- sleep 3
+ @shutdown_thread = Thread.new {
@server.stop
}
Grpc::Testing::Void.new
@@ -87,6 +86,9 @@ class WorkerServiceImpl < Grpc::Testing::WorkerService::Service
@server = s
@server_port = sp
end
+ def join_shutdown_thread
+ @shutdown_thread.join
+ end
end
def main
@@ -107,11 +109,13 @@ def main
# Configure any errors with client or server child threads to surface
Thread.abort_on_exception = true
- s = GRPC::RpcServer.new
+ s = GRPC::RpcServer.new(poll_period: 3)
s.add_http2_port("0.0.0.0:" + options['driver_port'].to_s,
:this_port_is_insecure)
- s.handle(WorkerServiceImpl.new(s, options['server_port'].to_i))
+ worker_service = WorkerServiceImpl.new(s, options['server_port'].to_i)
+ s.handle(worker_service)
s.run
+ worker_service.join_shutdown_thread
end
main
diff --git a/src/ruby/spec/channel_connection_spec.rb b/src/ruby/spec/channel_connection_spec.rb
index c76056606b..5c31f41065 100644
--- a/src/ruby/spec/channel_connection_spec.rb
+++ b/src/ruby/spec/channel_connection_spec.rb
@@ -11,47 +11,15 @@
# 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.
-
-require 'grpc'
+require 'spec_helper'
require 'timeout'
include Timeout
include GRPC::Core
-
-# A test message
-class EchoMsg
- def self.marshal(_o)
- ''
- end
-
- def self.unmarshal(_o)
- EchoMsg.new
- end
-end
-
-# A test service with an echo implementation.
-class EchoService
- include GRPC::GenericService
- rpc :an_rpc, EchoMsg, EchoMsg
- attr_reader :received_md
-
- def initialize(**kw)
- @trailing_metadata = kw
- @received_md = []
- end
-
- def an_rpc(req, call)
- GRPC.logger.info('echo service received a request')
- call.output_metadata.update(@trailing_metadata)
- @received_md << call.metadata unless call.metadata.nil?
- req
- end
-end
-
-EchoStub = EchoService.rpc_stub_class
+include GRPC::Spec::Helpers
def start_server(port = 0)
- @srv = GRPC::RpcServer.new(pool_size: 1)
+ @srv = new_rpc_server_for_testing(pool_size: 1)
server_port = @srv.add_http2_port("localhost:#{port}", :this_port_is_insecure)
@srv.handle(EchoService)
@server_thd = Thread.new { @srv.run }
diff --git a/src/ruby/spec/client_auth_spec.rb b/src/ruby/spec/client_auth_spec.rb
index 79c9192aa5..b955ad231e 100644
--- a/src/ruby/spec/client_auth_spec.rb
+++ b/src/ruby/spec/client_auth_spec.rb
@@ -95,7 +95,7 @@ describe 'client-server auth' do
server_opts = {
poll_period: 1
}
- @srv = RpcServer.new(**server_opts)
+ @srv = new_rpc_server_for_testing(**server_opts)
port = @srv.add_http2_port('0.0.0.0:0', create_server_creds)
@srv.handle(SslTestService)
@srv_thd = Thread.new { @srv.run }
diff --git a/src/ruby/spec/client_server_spec.rb b/src/ruby/spec/client_server_spec.rb
index adab8c9d14..14ad369ac8 100644
--- a/src/ruby/spec/client_server_spec.rb
+++ b/src/ruby/spec/client_server_spec.rb
@@ -542,7 +542,7 @@ end
describe 'the http client/server' do
before(:example) do
server_host = '0.0.0.0:0'
- @server = GRPC::Core::Server.new(nil)
+ @server = new_core_server_for_testing(nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@server.start
@ch = Channel.new("0.0.0.0:#{server_port}", nil, :this_channel_is_insecure)
@@ -574,7 +574,7 @@ describe 'the secure http client/server' do
server_host = '0.0.0.0:0'
server_creds = GRPC::Core::ServerCredentials.new(
nil, [{ private_key: certs[1], cert_chain: certs[2] }], false)
- @server = GRPC::Core::Server.new(nil)
+ @server = new_core_server_for_testing(nil)
server_port = @server.add_http2_port(server_host, server_creds)
@server.start
args = { Channel::SSL_TARGET => 'foo.test.google.fr' }
diff --git a/src/ruby/spec/generic/active_call_spec.rb b/src/ruby/spec/generic/active_call_spec.rb
index a00df9236d..135d1f28bf 100644
--- a/src/ruby/spec/generic/active_call_spec.rb
+++ b/src/ruby/spec/generic/active_call_spec.rb
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require 'grpc'
+require 'spec_helper'
include GRPC::Core::StatusCodes
@@ -40,7 +40,7 @@ describe GRPC::ActiveCall do
before(:each) do
@pass_through = proc { |x| x }
host = '0.0.0.0:0'
- @server = GRPC::Core::Server.new(nil)
+ @server = new_core_server_for_testing(nil)
server_port = @server.add_http2_port(host, :this_port_is_insecure)
@server.start
@ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
@@ -82,6 +82,16 @@ describe GRPC::ActiveCall do
end
end
end
+
+ describe '#interceptable' do
+ it 'exposes a fixed subset of the ActiveCall.methods' do
+ want = %w(deadline)
+ v = @client_call.interceptable
+ want.each do |w|
+ expect(v.methods.include?(w))
+ end
+ end
+ end
end
describe '#remote_send' do
@@ -609,9 +619,11 @@ describe GRPC::ActiveCall do
msgs
end
+ int_ctx = GRPC::InterceptionContext.new
+
@server_thread = Thread.new do
@server_call.run_server_bidi(
- fake_gen_each_reply_with_no_call_param)
+ fake_gen_each_reply_with_no_call_param, int_ctx)
@server_call.send_status(@server_status)
end
end
@@ -624,10 +636,11 @@ describe GRPC::ActiveCall do
call_param.send_initial_metadata
msgs
end
+ int_ctx = GRPC::InterceptionContext.new
@server_thread = Thread.new do
@server_call.run_server_bidi(
- fake_gen_each_reply_with_call_param)
+ fake_gen_each_reply_with_call_param, int_ctx)
@server_call.send_status(@server_status)
end
end
diff --git a/src/ruby/spec/generic/client_interceptors_spec.rb b/src/ruby/spec/generic/client_interceptors_spec.rb
new file mode 100644
index 0000000000..f292715e4d
--- /dev/null
+++ b/src/ruby/spec/generic/client_interceptors_spec.rb
@@ -0,0 +1,153 @@
+# 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.
+require 'spec_helper'
+
+describe 'Client Interceptors' do
+ let(:interceptor) { TestClientInterceptor.new }
+ let(:interceptors_opts) { { interceptors: [interceptor] } }
+ let(:request) { EchoMsg.new }
+ let(:service) { EchoService }
+
+ before(:each) do
+ build_rpc_server
+ end
+
+ context 'when a client interceptor is added' do
+ context 'with a request/response call' do
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:request_response)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:request_response)
+ .once.and_call_original
+ expect(stub.an_rpc(request)).to be_a(EchoMsg)
+ end
+ end
+
+ it 'can modify outgoing metadata', server: true do
+ expect(interceptor).to receive(:request_response)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:request_response)
+ .with(request, metadata: { 'foo' => 'bar_from_request_response' })
+ .once.and_call_original
+ expect(stub.an_rpc(request)).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ context 'with a client streaming call' do
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:client_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:client_streamer)
+ .once.and_call_original
+ requests = [EchoMsg.new, EchoMsg.new]
+ expect(stub.a_client_streaming_rpc(requests)).to be_a(EchoMsg)
+ end
+ end
+
+ it 'can modify outgoing metadata', server: true do
+ expect(interceptor).to receive(:client_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ requests = [EchoMsg.new, EchoMsg.new]
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:client_streamer)
+ .with(requests, metadata: { 'foo' => 'bar_from_client_streamer' })
+ .once.and_call_original
+ expect(stub.a_client_streaming_rpc(requests)).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ context 'with a server streaming call' do
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:server_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ request = EchoMsg.new
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:server_streamer)
+ .once.and_call_original
+ responses = stub.a_server_streaming_rpc(request)
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ it 'can modify outgoing metadata', server: true do
+ expect(interceptor).to receive(:server_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ request = EchoMsg.new
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:server_streamer)
+ .with(request, metadata: { 'foo' => 'bar_from_server_streamer' })
+ .once.and_call_original
+ responses = stub.a_server_streaming_rpc(request)
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ end
+ end
+ end
+
+ context 'with a bidi call' do
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:bidi_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:bidi_streamer)
+ .once.and_call_original
+ requests = [EchoMsg.new, EchoMsg.new]
+ responses = stub.a_bidi_rpc(requests)
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ it 'can modify outgoing metadata', server: true do
+ expect(interceptor).to receive(:bidi_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub, opts: interceptors_opts)
+ requests = [EchoMsg.new, EchoMsg.new]
+ expect_any_instance_of(GRPC::ActiveCall).to receive(:bidi_streamer)
+ .with(requests, metadata: { 'foo' => 'bar_from_bidi_streamer' })
+ .once.and_call_original
+ responses = stub.a_bidi_rpc(requests)
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/src/ruby/spec/generic/client_stub_spec.rb b/src/ruby/spec/generic/client_stub_spec.rb
index 9539e56c0f..5353b534f4 100644
--- a/src/ruby/spec/generic/client_stub_spec.rb
+++ b/src/ruby/spec/generic/client_stub_spec.rb
@@ -228,7 +228,7 @@ describe 'ClientStub' do
th.join
end
- it 'should receive UNAUTHENTICATED if call credentials plugin fails' do
+ it 'should receive UNAVAILABLE if call credentials plugin fails' do
server_port = create_secure_test_server
th = run_request_response(@sent_msg, @resp, @pass)
@@ -252,7 +252,7 @@ describe 'ClientStub' do
unauth_error_occured = false
begin
get_response(stub, credentials: creds)
- rescue GRPC::Unauthenticated => e
+ rescue GRPC::Unavailable => e
unauth_error_occured = true
expect(e.details.include?(error_message)).to be true
end
@@ -888,12 +888,12 @@ describe 'ClientStub' do
secure_credentials = GRPC::Core::ServerCredentials.new(
nil, [{ private_key: certs[1], cert_chain: certs[2] }], false)
- @server = GRPC::Core::Server.new(nil)
+ @server = new_core_server_for_testing(nil)
@server.add_http2_port('0.0.0.0:0', secure_credentials)
end
def create_test_server
- @server = GRPC::Core::Server.new(nil)
+ @server = new_core_server_for_testing(nil)
@server.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
end
diff --git a/src/ruby/spec/generic/interceptor_registry_spec.rb b/src/ruby/spec/generic/interceptor_registry_spec.rb
new file mode 100644
index 0000000000..eb75d1e0b2
--- /dev/null
+++ b/src/ruby/spec/generic/interceptor_registry_spec.rb
@@ -0,0 +1,65 @@
+# 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.
+require 'spec_helper'
+
+describe GRPC::InterceptorRegistry do
+ let(:server) { new_rpc_server_for_testing }
+ let(:interceptor) { TestServerInterceptor.new }
+ let(:interceptors) { [interceptor] }
+ let(:registry) { described_class.new(interceptors) }
+
+ describe 'initialization' do
+ subject { registry }
+
+ context 'with an interceptor extending GRPC::ServerInterceptor' do
+ it 'should add the interceptor to the registry' do
+ subject
+ is = registry.instance_variable_get('@interceptors')
+ expect(is.count).to eq 1
+ expect(is.first).to eq interceptor
+ end
+ end
+
+ context 'with multiple interceptors' do
+ let(:interceptor2) { TestServerInterceptor.new }
+ let(:interceptor3) { TestServerInterceptor.new }
+ let(:interceptors) { [interceptor, interceptor2, interceptor3] }
+
+ it 'should maintain order of insertion when iterated against' do
+ subject
+ is = registry.instance_variable_get('@interceptors')
+ expect(is.count).to eq 3
+ is.each_with_index do |i, idx|
+ case idx
+ when 0
+ expect(i).to eq interceptor
+ when 1
+ expect(i).to eq interceptor2
+ when 2
+ expect(i).to eq interceptor3
+ end
+ end
+ end
+ end
+
+ context 'with an interceptor not extending GRPC::ServerInterceptor' do
+ let(:interceptor) { Class }
+ let(:err) { GRPC::InterceptorRegistry::DescendantError }
+
+ it 'should raise an InvalidArgument exception' do
+ expect { subject }.to raise_error(err)
+ end
+ end
+ end
+end
diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb
index b887eaaf4e..e072d0c45f 100644
--- a/src/ruby/spec/generic/rpc_server_spec.rb
+++ b/src/ruby/spec/generic/rpc_server_spec.rb
@@ -11,8 +11,7 @@
# 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.
-
-require 'grpc'
+require 'spec_helper'
def load_test_certs
test_root = File.join(File.dirname(File.dirname(__FILE__)), 'testdata')
@@ -28,17 +27,6 @@ def check_md(wanted_md, received_md)
end
end
-# A test message
-class EchoMsg
- def self.marshal(_o)
- ''
- end
-
- def self.unmarshal(_o)
- EchoMsg.new
- end
-end
-
# A test service with no methods.
class EmptyService
include GRPC::GenericService
@@ -50,27 +38,6 @@ class NoRpcImplementation
rpc :an_rpc, EchoMsg, EchoMsg
end
-# A test service with an echo implementation.
-class EchoService
- include GRPC::GenericService
- rpc :an_rpc, EchoMsg, EchoMsg
- attr_reader :received_md
-
- def initialize(**kw)
- @trailing_metadata = kw
- @received_md = []
- end
-
- def an_rpc(req, call)
- GRPC.logger.info('echo service received a request')
- call.output_metadata.update(@trailing_metadata)
- @received_md << call.metadata unless call.metadata.nil?
- req
- end
-end
-
-EchoStub = EchoService.rpc_stub_class
-
# A test service with an implementation that fails with BadStatus
class FailingService
include GRPC::GenericService
@@ -205,7 +172,7 @@ describe GRPC::RpcServer do
it 'can be created with just some args' do
opts = { server_args: { a_channel_arg: 'an_arg' } }
blk = proc do
- RpcServer.new(**opts)
+ new_rpc_server_for_testing(**opts)
end
expect(&blk).not_to raise_error
end
@@ -216,7 +183,7 @@ describe GRPC::RpcServer do
server_args: { a_channel_arg: 'an_arg' },
creds: Object.new
}
- RpcServer.new(**opts)
+ new_rpc_server_for_testing(**opts)
end
expect(&blk).to raise_error
end
@@ -225,7 +192,7 @@ describe GRPC::RpcServer do
describe '#stopped?' do
before(:each) do
opts = { server_args: { a_channel_arg: 'an_arg' }, poll_period: 1.5 }
- @srv = RpcServer.new(**opts)
+ @srv = new_rpc_server_for_testing(**opts)
@srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
end
@@ -257,7 +224,7 @@ describe GRPC::RpcServer do
opts = {
server_args: { a_channel_arg: 'an_arg' }
}
- r = RpcServer.new(**opts)
+ r = new_rpc_server_for_testing(**opts)
expect(r.running?).to be(false)
end
@@ -266,7 +233,7 @@ describe GRPC::RpcServer do
server_args: { a_channel_arg: 'an_arg' },
poll_period: 2
}
- r = RpcServer.new(**opts)
+ r = new_rpc_server_for_testing(**opts)
r.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
expect { r.run }.to raise_error(RuntimeError)
end
@@ -276,7 +243,7 @@ describe GRPC::RpcServer do
server_args: { a_channel_arg: 'an_arg' },
poll_period: 2.5
}
- r = RpcServer.new(**opts)
+ r = new_rpc_server_for_testing(**opts)
r.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
r.handle(EchoService)
t = Thread.new { r.run }
@@ -290,7 +257,7 @@ describe GRPC::RpcServer do
describe '#handle' do
before(:each) do
@opts = { server_args: { a_channel_arg: 'an_arg' }, poll_period: 1 }
- @srv = RpcServer.new(**@opts)
+ @srv = new_rpc_server_for_testing(**@opts)
@srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
end
@@ -336,7 +303,7 @@ describe GRPC::RpcServer do
server_opts = {
poll_period: 1
}
- @srv = RpcServer.new(**server_opts)
+ @srv = new_rpc_server_for_testing(**server_opts)
server_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
@host = "localhost:#{server_port}"
@ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
@@ -507,7 +474,7 @@ describe GRPC::RpcServer do
poll_period: 1,
max_waiting_requests: 1
}
- alt_srv = RpcServer.new(**opts)
+ alt_srv = new_rpc_server_for_testing(**opts)
alt_srv.handle(SlowService)
alt_port = alt_srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
alt_host = "0.0.0.0:#{alt_port}"
@@ -571,7 +538,7 @@ describe GRPC::RpcServer do
poll_period: 1,
connect_md_proc: test_md_proc
}
- @srv = RpcServer.new(**server_opts)
+ @srv = new_rpc_server_for_testing(**server_opts)
alt_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
@alt_host = "0.0.0.0:#{alt_port}"
end
@@ -606,7 +573,7 @@ describe GRPC::RpcServer do
server_opts = {
poll_period: 1
}
- @srv = RpcServer.new(**server_opts)
+ @srv = new_rpc_server_for_testing(**server_opts)
alt_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
@alt_host = "0.0.0.0:#{alt_port}"
end
@@ -657,7 +624,7 @@ describe GRPC::RpcServer do
server_opts = {
poll_period: 1
}
- @srv = RpcServer.new(**server_opts)
+ @srv = new_rpc_server_for_testing(**server_opts)
alt_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
@alt_host = "0.0.0.0:#{alt_port}"
diff --git a/src/ruby/spec/generic/server_interceptors_spec.rb b/src/ruby/spec/generic/server_interceptors_spec.rb
new file mode 100644
index 0000000000..eb86686084
--- /dev/null
+++ b/src/ruby/spec/generic/server_interceptors_spec.rb
@@ -0,0 +1,218 @@
+# 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.
+require 'spec_helper'
+
+describe 'Server Interceptors' do
+ let(:interceptor) { TestServerInterceptor.new }
+ let(:request) { EchoMsg.new }
+ let(:trailing_metadata) { {} }
+ let(:service) { EchoService.new(trailing_metadata) }
+ let(:interceptors) { [] }
+
+ before(:each) do
+ build_rpc_server(server_opts: { interceptors: interceptors })
+ end
+
+ context 'when a server interceptor is added' do
+ let(:interceptors) { [interceptor] }
+ let(:client_metadata) { { client_md: 'test' } }
+ let(:client_call_opts) { { metadata: client_metadata, return_op: true } }
+
+ context 'with a request/response call' do
+ let(:trailing_metadata) { { server_om: 'from_request_response' } }
+
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:request_response)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect(stub.an_rpc(request)).to be_a(EchoMsg)
+ end
+ end
+
+ it 'can modify trailing metadata', server: true do
+ expect(interceptor).to receive(:request_response)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect_any_instance_of(GRPC::ActiveCall).to(
+ receive(:request_response).with(request, metadata: client_metadata)
+ .once.and_call_original
+ )
+ op = stub.an_rpc(request, client_call_opts)
+ msg = op.execute
+ expect(op.trailing_metadata).to eq(
+ 'interc' => 'from_request_response',
+ 'server_om' => 'from_request_response'
+ )
+ expect(msg).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ context 'with a client streaming call' do
+ let(:trailing_metadata) { { server_om: 'from_client_streamer' } }
+ let(:requests) { [EchoMsg.new, EchoMsg.new] }
+
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:client_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect(stub.a_client_streaming_rpc(requests)).to be_a(EchoMsg)
+ end
+ end
+
+ it 'can modify trailing metadata', server: true do
+ expect(interceptor).to receive(:client_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect_any_instance_of(GRPC::ActiveCall).to(
+ receive(:client_streamer).with(requests)
+ .once.and_call_original
+ )
+ op = stub.a_client_streaming_rpc(requests, client_call_opts)
+ msg = op.execute
+ expect(op.trailing_metadata).to eq(
+ 'interc' => 'from_client_streamer',
+ 'server_om' => 'from_client_streamer'
+ )
+ expect(msg).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ context 'with a server streaming call' do
+ let(:trailing_metadata) { { server_om: 'from_server_streamer' } }
+ let(:request) { EchoMsg.new }
+
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:server_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ responses = stub.a_server_streaming_rpc(request)
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ it 'can modify trailing metadata', server: true do
+ expect(interceptor).to receive(:server_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect_any_instance_of(GRPC::ActiveCall).to(
+ receive(:server_streamer).with(request)
+ .once.and_call_original
+ )
+ op = stub.a_server_streaming_rpc(request, client_call_opts)
+ responses = op.execute
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ expect(op.trailing_metadata).to eq(
+ 'interc' => 'from_server_streamer',
+ 'server_om' => 'from_server_streamer'
+ )
+ end
+ end
+ end
+
+ context 'with a bidi call' do
+ let(:trailing_metadata) { { server_om: 'from_bidi_streamer' } }
+ let(:requests) { [EchoMsg.new, EchoMsg.new] }
+
+ it 'should be called', server: true do
+ expect(interceptor).to receive(:bidi_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ responses = stub.a_bidi_rpc(requests)
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ it 'can modify trailing metadata', server: true do
+ expect(interceptor).to receive(:bidi_streamer)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect_any_instance_of(GRPC::ActiveCall).to(
+ receive(:bidi_streamer).with(requests)
+ .once.and_call_original
+ )
+ op = stub.a_bidi_rpc(requests, client_call_opts)
+ responses = op.execute
+ responses.each do |r|
+ expect(r).to be_a(EchoMsg)
+ end
+ expect(op.trailing_metadata).to eq(
+ 'interc' => 'from_bidi_streamer',
+ 'server_om' => 'from_bidi_streamer'
+ )
+ end
+ end
+ end
+ end
+
+ context 'when multiple interceptors are added' do
+ let(:interceptor2) { TestServerInterceptor.new }
+ let(:interceptor3) { TestServerInterceptor.new }
+ let(:interceptors) do
+ [
+ interceptor,
+ interceptor2,
+ interceptor3
+ ]
+ end
+
+ it 'each should be called', server: true do
+ expect(interceptor).to receive(:request_response)
+ .once.and_call_original
+ expect(interceptor2).to receive(:request_response)
+ .once.and_call_original
+ expect(interceptor3).to receive(:request_response)
+ .once.and_call_original
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect(stub.an_rpc(request)).to be_a(EchoMsg)
+ end
+ end
+ end
+
+ context 'when an interceptor is not added' do
+ it 'should not be called', server: true do
+ expect(interceptor).to_not receive(:call)
+
+ run_services_on_server(@server, services: [service]) do
+ stub = build_insecure_stub(EchoStub)
+ expect(stub.an_rpc(request)).to be_a(EchoMsg)
+ end
+ end
+ end
+end
diff --git a/src/ruby/spec/google_rpc_status_utils_spec.rb b/src/ruby/spec/google_rpc_status_utils_spec.rb
index fe221c30dd..3263589b6a 100644
--- a/src/ruby/spec/google_rpc_status_utils_spec.rb
+++ b/src/ruby/spec/google_rpc_status_utils_spec.rb
@@ -19,6 +19,7 @@ require_relative '../pb/src/proto/grpc/testing/messages_pb'
require 'google/protobuf/well_known_types'
include GRPC::Core
+include GRPC::Spec::Helpers
describe 'conversion from a status struct to a google protobuf status' do
it 'fails if the input is not a status struct' do
@@ -31,12 +32,11 @@ describe 'conversion from a status struct to a google protobuf status' do
expect(exception.message.include?('bad type')).to be true
end
- it 'fails with some error if the header key is missing' do
+ it 'returns nil if the header key is missing' do
status = Struct::Status.new(1, 'details', key: 'val')
expect(status.metadata.nil?).to be false
- expect do
- GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
- end.to raise_error(StandardError)
+ expect(GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
+ status)).to be(nil)
end
it 'fails with some error if the header key fails to deserialize' do
@@ -151,7 +151,7 @@ GoogleRpcStatusTestStub = GoogleRpcStatusTestService.rpc_stub_class
describe 'receving a google rpc status from a remote endpoint' do
def start_server(encoded_rpc_status)
- @srv = GRPC::RpcServer.new(pool_size: 1)
+ @srv = new_rpc_server_for_testing(pool_size: 1)
@server_port = @srv.add_http2_port('localhost:0',
:this_port_is_insecure)
@srv.handle(GoogleRpcStatusTestService.new(encoded_rpc_status))
@@ -221,3 +221,73 @@ describe 'receving a google rpc status from a remote endpoint' do
status_from_exception)).to eq(rpc_status)
end
end
+
+# A test service that fails without explicitly setting the
+# grpc-status-details-bin trailer. Tests assumptions about value
+# of grpc-status-details-bin on the client side when the trailer wasn't
+# set explicitly.
+class NoStatusDetailsBinTestService
+ include GRPC::GenericService
+ rpc :an_rpc, EchoMsg, EchoMsg
+
+ def an_rpc(_, _)
+ fail GRPC::Unknown
+ end
+end
+
+NoStatusDetailsBinTestServiceStub = NoStatusDetailsBinTestService.rpc_stub_class
+
+describe 'when the endpoint doesnt send grpc-status-details-bin' do
+ def start_server
+ @srv = new_rpc_server_for_testing(pool_size: 1)
+ @server_port = @srv.add_http2_port('localhost:0',
+ :this_port_is_insecure)
+ @srv.handle(NoStatusDetailsBinTestService)
+ @server_thd = Thread.new { @srv.run }
+ @srv.wait_till_running
+ end
+
+ def stop_server
+ expect(@srv.stopped?).to be(false)
+ @srv.stop
+ @server_thd.join
+ expect(@srv.stopped?).to be(true)
+ end
+
+ before(:each) do
+ start_server
+ end
+
+ after(:each) do
+ stop_server
+ end
+
+ it 'should receive nil when we extract try to extract a google '\
+ 'rpc status from a BadStatus exception that didnt have it' do
+ stub = NoStatusDetailsBinTestServiceStub.new("localhost:#{@server_port}",
+ :this_channel_is_insecure)
+ begin
+ stub.an_rpc(EchoMsg.new)
+ rescue GRPC::Unknown => e
+ rpc_status = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
+ e.to_status)
+ end
+ expect(rpc_status).to be(nil)
+ end
+
+ it 'should receive nil when we extract try to extract a google '\
+ 'rpc status from an op views status object that didnt have it' do
+ stub = NoStatusDetailsBinTestServiceStub.new("localhost:#{@server_port}",
+ :this_channel_is_insecure)
+ op = stub.an_rpc(EchoMsg.new, return_op: true)
+ begin
+ op.execute
+ rescue GRPC::Unknown => e
+ status_from_exception = e.to_status
+ end
+ expect(GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
+ status_from_exception)).to be(nil)
+ expect(GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
+ op.status)).to be nil
+ end
+end
diff --git a/src/ruby/spec/pb/health/checker_spec.rb b/src/ruby/spec/pb/health/checker_spec.rb
index 6c9e206c3f..58a602327c 100644
--- a/src/ruby/spec/pb/health/checker_spec.rb
+++ b/src/ruby/spec/pb/health/checker_spec.rb
@@ -99,6 +99,35 @@ describe Grpc::Health::Checker do
end
end
+ context 'method `add_statuses`' do
+ it 'should add status to each service' do
+ checker = Grpc::Health::Checker.new
+ checker.add_statuses(
+ 'service1' => ServingStatus::SERVING,
+ 'service2' => ServingStatus::NOT_SERVING
+ )
+ service1_health = checker.check(HCReq.new(service: 'service1'), nil)
+ service2_health = checker.check(HCReq.new(service: 'service2'), nil)
+ expect(service1_health).to eq(HCResp.new(status: ServingStatus::SERVING))
+ expect(service2_health).to eq(HCResp.new(status: ServingStatus::NOT_SERVING))
+ end
+ end
+
+ context 'method `set_status_for_services`' do
+ it 'should add given status to all given services' do
+ checker = Grpc::Health::Checker.new
+ checker.set_status_for_services(
+ ServingStatus::SERVING,
+ 'service1',
+ 'service2'
+ )
+ service1_health = checker.check(HCReq.new(service: 'service1'), nil)
+ service2_health = checker.check(HCReq.new(service: 'service2'), nil)
+ expect(service1_health).to eq(HCResp.new(status: ServingStatus::SERVING))
+ expect(service2_health).to eq(HCResp.new(status: ServingStatus::SERVING))
+ end
+ end
+
context 'method `check`' do
success_tests.each do |t|
it "should fail with NOT_FOUND when #{t[:desc]}" do
@@ -163,7 +192,7 @@ describe Grpc::Health::Checker do
server_opts = {
poll_period: 1
}
- @srv = RpcServer.new(**server_opts)
+ @srv = new_rpc_server_for_testing(**server_opts)
server_port = @srv.add_http2_port(server_host, :this_port_is_insecure)
@host = "localhost:#{server_port}"
@ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
diff --git a/src/ruby/spec/server_spec.rb b/src/ruby/spec/server_spec.rb
index c0a59572b1..a0d27b66f5 100644
--- a/src/ruby/spec/server_spec.rb
+++ b/src/ruby/spec/server_spec.rb
@@ -30,12 +30,12 @@ describe Server do
describe '#start' do
it 'runs without failing' do
- blk = proc { Server.new(nil).start }
+ blk = proc { new_core_server_for_testing(nil).start }
expect(&blk).to_not raise_error
end
it 'fails if the server is closed' do
- s = Server.new(nil)
+ s = new_core_server_for_testing(nil)
s.close
expect { s.start }.to raise_error(RuntimeError)
end
@@ -85,7 +85,7 @@ describe Server do
describe 'for insecure servers' do
it 'runs without failing' do
blk = proc do
- s = Server.new(nil)
+ s = new_core_server_for_testing(nil)
s.add_http2_port('localhost:0', :this_port_is_insecure)
s.close
end
@@ -93,7 +93,7 @@ describe Server do
end
it 'fails if the server is closed' do
- s = Server.new(nil)
+ s = new_core_server_for_testing(nil)
s.close
blk = proc do
s.add_http2_port('localhost:0', :this_port_is_insecure)
@@ -106,7 +106,7 @@ describe Server do
let(:cert) { create_test_cert }
it 'runs without failing' do
blk = proc do
- s = Server.new(nil)
+ s = new_core_server_for_testing(nil)
s.add_http2_port('localhost:0', cert)
s.close
end
@@ -114,7 +114,7 @@ describe Server do
end
it 'fails if the server is closed' do
- s = Server.new(nil)
+ s = new_core_server_for_testing(nil)
s.close
blk = proc { s.add_http2_port('localhost:0', cert) }
expect(&blk).to raise_error(RuntimeError)
@@ -124,7 +124,7 @@ describe Server do
shared_examples '#new' do
it 'takes nil channel args' do
- expect { Server.new(nil) }.to_not raise_error
+ expect { new_core_server_for_testing(nil) }.to_not raise_error
end
it 'does not take a hash with bad keys as channel args' do
@@ -175,14 +175,14 @@ describe Server do
describe '#new with an insecure channel' do
def construct_with_args(a)
- proc { Server.new(a) }
+ proc { new_core_server_for_testing(a) }
end
it_behaves_like '#new'
end
def start_a_server
- s = Server.new(nil)
+ s = new_core_server_for_testing(nil)
s.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
s.start
s
diff --git a/src/ruby/spec/spec_helper.rb b/src/ruby/spec/spec_helper.rb
index 6e1eba1945..8fe9e6e808 100644
--- a/src/ruby/spec/spec_helper.rb
+++ b/src/ruby/spec/spec_helper.rb
@@ -32,6 +32,9 @@ require 'rspec'
require 'logging'
require 'rspec/logging_helper'
+require_relative 'support/services'
+require_relative 'support/helpers'
+
# GRPC is the general RPC module
#
# Configure its logging for fine-grained log control during test runs
@@ -49,6 +52,7 @@ Logging.logger['GRPC::BidiCall'].level = :info
RSpec.configure do |config|
include RSpec::LoggingHelper
config.capture_log_messages # comment this out to see logs during test runs
+ include GRPC::Spec::Helpers
end
RSpec::Expectations.configuration.warn_about_potential_false_positives = false
diff --git a/src/ruby/spec/support/helpers.rb b/src/ruby/spec/support/helpers.rb
new file mode 100644
index 0000000000..29028df8b7
--- /dev/null
+++ b/src/ruby/spec/support/helpers.rb
@@ -0,0 +1,107 @@
+# 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.
+
+# GRPC contains the General RPC module.
+module GRPC
+ ##
+ # GRPC RSpec base module
+ #
+ module Spec
+ ##
+ # A module that is used for providing generic helpers across the
+ # GRPC test suite
+ #
+ module Helpers
+ # Shortcut syntax for a GRPC RPC Server
+ RpcServer = GRPC::RpcServer
+
+ ##
+ # Build an RPC server used for testing
+ #
+ def build_rpc_server(server_opts: {},
+ client_opts: {})
+ @server = new_rpc_server_for_testing({ poll_period: 1 }.merge(server_opts))
+ @port = @server.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
+ @host = "0.0.0.0:#{@port}"
+ @client_opts = client_opts
+ @server
+ end
+
+ ##
+ # Run services on an RPC server, yielding to allow testing within
+ #
+ # @param [RpcServer] server
+ # @param [Array<Class>] services
+ #
+ def run_services_on_server(server, services: [])
+ services.each do |s|
+ server.handle(s)
+ end
+ t = Thread.new { server.run }
+ server.wait_till_running
+
+ yield
+
+ server.stop
+ t.join
+ end
+
+ ##
+ # Build an insecure stub from a given stub class
+ #
+ # @param [Class] klass
+ # @param [String] host
+ #
+ def build_insecure_stub(klass, host: nil, opts: nil)
+ host ||= @host
+ opts ||= @client_opts
+ klass.new(host, :this_channel_is_insecure, **opts)
+ end
+
+ ##
+ # Build an RPCServer for use in tests. Adds args
+ # that are useful for all tests.
+ #
+ # @param [Hash] server_opts
+ #
+ def new_rpc_server_for_testing(server_opts = {})
+ server_opts[:server_args] ||= {}
+ update_server_args_hash(server_opts[:server_args])
+ RpcServer.new(**server_opts)
+ end
+
+ ##
+ # Build an GRPC::Core::Server for use in tests. Adds args
+ # that are useful for all tests.
+ #
+ # @param [Hash] server_args
+ #
+ def new_core_server_for_testing(server_args)
+ server_args.nil? && server_args = {}
+ update_server_args_hash(server_args)
+ GRPC::Core::Server.new(server_args)
+ end
+
+ def update_server_args_hash(server_args)
+ so_reuseport_arg = 'grpc.so_reuseport'
+ unless server_args[so_reuseport_arg].nil?
+ fail 'Unexpected. grpc.so_reuseport already set.'
+ end
+ # Run tests without so_reuseport to eliminate the chance of
+ # cross-talk.
+ server_args[so_reuseport_arg] = 0
+ end
+ end
+ end
+end
diff --git a/src/ruby/spec/support/services.rb b/src/ruby/spec/support/services.rb
new file mode 100644
index 0000000000..27cc8e61ac
--- /dev/null
+++ b/src/ruby/spec/support/services.rb
@@ -0,0 +1,147 @@
+# 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.
+
+# Test stubs for various scenarios
+require 'grpc'
+
+# A test message
+class EchoMsg
+ def self.marshal(_o)
+ ''
+ end
+
+ def self.unmarshal(_o)
+ EchoMsg.new
+ end
+end
+
+# A test service with an echo implementation.
+class EchoService
+ include GRPC::GenericService
+ rpc :an_rpc, EchoMsg, EchoMsg
+ rpc :a_client_streaming_rpc, stream(EchoMsg), EchoMsg
+ rpc :a_server_streaming_rpc, EchoMsg, stream(EchoMsg)
+ rpc :a_bidi_rpc, stream(EchoMsg), stream(EchoMsg)
+ attr_reader :received_md
+
+ def initialize(**kw)
+ @trailing_metadata = kw
+ @received_md = []
+ end
+
+ def an_rpc(req, call)
+ GRPC.logger.info('echo service received a request')
+ call.output_metadata.update(@trailing_metadata)
+ @received_md << call.metadata unless call.metadata.nil?
+ req
+ end
+
+ def a_client_streaming_rpc(call)
+ # iterate through requests so call can complete
+ call.output_metadata.update(@trailing_metadata)
+ call.each_remote_read.each { |r| p r }
+ EchoMsg.new
+ end
+
+ def a_server_streaming_rpc(_req, call)
+ call.output_metadata.update(@trailing_metadata)
+ [EchoMsg.new, EchoMsg.new]
+ end
+
+ def a_bidi_rpc(requests, call)
+ call.output_metadata.update(@trailing_metadata)
+ requests.each { |r| p r }
+ [EchoMsg.new, EchoMsg.new]
+ end
+end
+
+EchoStub = EchoService.rpc_stub_class
+
+# For testing server interceptors
+class TestServerInterceptor < GRPC::ServerInterceptor
+ def request_response(request:, call:, method:)
+ p "Received request/response call at method #{method}" \
+ " with request #{request} for call #{call}"
+ call.output_metadata[:interc] = 'from_request_response'
+ p "[GRPC::Ok] (#{method.owner.name}.#{method.name})"
+ yield
+ end
+
+ def client_streamer(call:, method:)
+ call.output_metadata[:interc] = 'from_client_streamer'
+ call.each_remote_read.each do |r|
+ p "In interceptor: #{r}"
+ end
+ p "Received client streamer call at method #{method} for call #{call}"
+ yield
+ end
+
+ def server_streamer(request:, call:, method:)
+ p "Received server streamer call at method #{method} with request" \
+ " #{request} for call #{call}"
+ call.output_metadata[:interc] = 'from_server_streamer'
+ yield
+ end
+
+ def bidi_streamer(requests:, call:, method:)
+ requests.each do |r|
+ p "Bidi request: #{r}"
+ end
+ p "Received bidi streamer call at method #{method} with requests" \
+ " #{requests} for call #{call}"
+ call.output_metadata[:interc] = 'from_bidi_streamer'
+ yield
+ end
+end
+
+# For testing client interceptors
+class TestClientInterceptor < GRPC::ClientInterceptor
+ def request_response(request:, call:, method:, metadata: {})
+ p "Intercepted request/response call at method #{method}" \
+ " with request #{request} for call #{call}" \
+ " and metadata: #{metadata}"
+ metadata['foo'] = 'bar_from_request_response'
+ yield
+ end
+
+ def client_streamer(requests:, call:, method:, metadata: {})
+ p "Received client streamer call at method #{method}" \
+ " with requests #{requests} for call #{call}" \
+ " and metadata: #{metadata}"
+ requests.each do |r|
+ p "In client interceptor: #{r}"
+ end
+ metadata['foo'] = 'bar_from_client_streamer'
+ yield
+ end
+
+ def server_streamer(request:, call:, method:, metadata: {})
+ p "Received server streamer call at method #{method}" \
+ " with request #{request} for call #{call}" \
+ " and metadata: #{metadata}"
+ metadata['foo'] = 'bar_from_server_streamer'
+ yield
+ end
+
+ def bidi_streamer(requests:, call:, method:, metadata: {})
+ p "Received bidi streamer call at method #{method}" \
+ "with requests #{requests} for call #{call}" \
+ " and metadata: #{metadata}"
+ requests.each do |r|
+ p "In client interceptor: #{r}"
+ end
+ metadata['foo'] = 'bar_from_bidi_streamer'
+ yield
+ end
+end
diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb
index ea0c4ae56c..2682294bd2 100644
--- a/src/ruby/tools/version.rb
+++ b/src/ruby/tools/version.rb
@@ -14,6 +14,6 @@
module GRPC
module Tools
- VERSION = '1.7.0.dev'
+ VERSION = '1.10.0.dev'
end
end
diff --git a/summerofcode/ideas.md b/summerofcode/ideas.md
index d87cf1b8fa..d89bc372cc 100644
--- a/summerofcode/ideas.md
+++ b/summerofcode/ideas.md
@@ -11,44 +11,26 @@ to know the gRPC code and team!
**Required skills for all projects:** git version control, collaborative
software development on github.com, and software development in at least one
-of gRPC's ten languages on at least one of Linux, Mac OS X, and Windows.
+of gRPC's ten languages on at least one of Linux, macOS, and Windows.
-------------------------------------
-gRPC C Core:
+gRPC Core:
-1. Port gRPC to one of the major BSD platforms ([FreeBSD](https://freebsd.org), [NetBSD](https://netbsd.org), and [OpenBSD](https://openbsd.org)) and create packages for them. Add [kqueue](https://www.freebsd.org/cgi/man.cgi?query=kqueue) support in the process.
- * **Required skills:** C programming language, BSD operating system.
- * **Likely mentors:** [Craig Tiller](https://github.com/ctiller),
- [Nicolas Noble](https://github.com/nicolasnoble),
- [Vijay Pai](https://github.com/vjpai).
-1. Fix gRPC C-core's URI parser. The current parser does not qualify as a standard parser according to [RFC3986]( https://tools.ietf.org/html/rfc3986). Write test suites to verify this and make changes necessary to make the URI parser compliant.
- * **Required skills:** C programming language, HTTP standard compliance.
- * **Likely mentors:** [Craig Tiller](https://github.com/ctiller).
-1. HPACK compression efficiency evaluation - Figure out how to benchmark gRPC's compression efficiency (both in terms of bytes on the wire and cpu cycles). Implement benchmarks. Potentially extend this to other full-stack gRPC implementations (Java and Go).
- * **Required skills:** C programming language, software performance benchmarking, potentially Java and Go.
- * **Likely mentors:** [Craig Tiller](https://github.com/ctiller).
+1. Implement ["early OK" semantics](https://github.com/grpc/grpc/issues/7032). The gRPC wire protocol allows servers to complete an RPC with OK status without having processed all requests ever sent to the client; it's the gRPC Core that currently restricts applications from so behaving. This behavioral gap in the gRPC Core should be filled in.
+ * **Required skills:** C programming language, C++ programming language.
+ * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Nicolas Noble](https://github.com/nicolasnoble).
+1. [Make channel-connectivity-watching cancellable](https://github.com/grpc/grpc/issues/3064). Anything worth waiting for is worth cancelling. The fact that channel connectivity is currently poll-based means that clean shutdown of gRPC channels can take as long as the poll interval. No one should have to wait two hundred milliseconds to garbage-collect an object.
+ * **Required skills:** C programming language, C++ programming language, Python programming language.
+ * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Vijay Pai](https://github.com/vjpai).
gRPC Python:
-1. Port gRPC Python to [PyPy](http://pypy.org). Investigate the state of [Cython support](http://docs.cython.org/src/userguide/pypy.html) to do this or potentially explore [cffi](https://cffi.readthedocs.org/en/latest/).
- * **Required skills:** Python programming language, PyPy Python interpreter.
- * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm).
-1. Develop and test Python 3.5 Support for gRPC. Make necessary changes to port gRPC and package it for supported platforms.
- * **Required skills:** Python programming language, Python 3.5 interpreter.
- * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm).
-
-gRPC Ruby/Java:
+1. Support static type-checking of both gRPC Python itself and of code that uses gRPC Python. No one likes dynamic typing and Python is finally outgrowing it! There are probably errors in the implementation of gRPC Python that [pytype](https://github.com/google/pytype) or [mypy](http://mypy-lang.org/) could detect. There are certainly errors in other code that uses gRPC Python that they could detect.
+ * **Required skills:** Python programming language, open source development across multiple repositories and projects.
+ * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Kailash Sethuraman](https://github.com/hsaliak), [Ken Payson](https://github.com/kpayson64), [Mehrdad Afshari](https://github.com/mehrdada).
-1. [jRuby](http://jruby.org) support for gRPC. Develop a jRuby wrapper for gRPC based on grpc-java and ensure that it is API compatible with the existing Ruby implementation and passes all tests.
- * **Required skills:** Java programming language, Ruby programming language.
- * **Likely mentors:** [Michael Lumish](https://github.com/murgatroid99), [Eric Anderson](https://github.com/ejona86).
-
-
-gRPC Wire Protocol:
-
-1. Develop a [Wireshark](https://wireshark.org) plugin for the gRPC protocol. Provide documentation and tutorials for this plugin.
- * **Bonus:** consider set-up and use with mobile clients.
- * **Required skills:** Wireshark software.
- * **Likely mentors:** [Nicolas Noble](https://github.com/nicolasnoble).
+1. [Enable building of gRPC Python with Bazel](https://github.com/grpc/grpc/issues/8079). Bazel is the designated replacement for our constellation of crufty build scripts, but it's still under active development itself. Up for a challenge? gRPC Python could easily be the most complex codebase to be built with Bazel.
+ * **Required skills:** Python programming language, Bazel toolchain, Cython, open source development across multiple repositories and projects.
+ * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Ken Payson](https://github.com/kpayson64), [Mehrdad Afshari](https://github.com/mehrdada).
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 567bd3b7f8..de0f2eb328 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -48,7 +48,10 @@
deps.append("${_gRPC_CARES_LIBRARIES}")
deps.append("${_gRPC_ALLTARGETS_LIBRARIES}")
for d in target_dict.get('deps', []):
- deps.append(d)
+ if d == 'benchmark':
+ deps.append("${_gRPC_BENCHMARK_LIBRARIES}")
+ else:
+ deps.append(d)
if target_dict.build == 'test' and target_dict.language == 'c++':
deps.append("${_gRPC_GFLAGS_LIBRARIES}")
return deps
@@ -73,7 +76,7 @@
set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}</%text>")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
project(<%text>${PACKAGE_NAME}</%text> C CXX)
-
+
set(gRPC_INSTALL_BINDIR "<%text>${CMAKE_INSTALL_PREFIX}</%text>/bin" CACHE PATH "Installation directory for executables")
set(gRPC_INSTALL_LIBDIR "<%text>${CMAKE_INSTALL_PREFIX}</%text>/lib" CACHE PATH "Installation directory for libraries")
set(gRPC_INSTALL_INCLUDEDIR "<%text>${CMAKE_INSTALL_PREFIX}</%text>/include" CACHE PATH "Installation directory for headers")
@@ -90,6 +93,10 @@
set(gRPC_INSTALL <%text>${gRPC_INSTALL_default}</%text> CACHE BOOL
"Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"")
+ # Providers for third-party dependencies (gRPC_*_PROVIDER properties):
+ # "module": build the dependency using sources from git submodule (under third_party)
+ # "package": use cmake's find_package functionality to locate a pre-installed dependency
+
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@@ -147,181 +154,12 @@
set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf")
endif()
- if("<%text>${gRPC_ZLIB_PROVIDER}</%text>" STREQUAL "module")
- if(NOT ZLIB_ROOT_DIR)
- set(ZLIB_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/zlib)
- endif()
- set(ZLIB_INCLUDE_DIR "<%text>${ZLIB_ROOT_DIR}</%text>")
- if(EXISTS "<%text>${ZLIB_ROOT_DIR}</%text>/CMakeLists.txt")
- # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218
- include_directories(<%text>${ZLIB_INCLUDE_DIR}</%text>)
-
- add_subdirectory(<%text>${ZLIB_ROOT_DIR}</%text> third_party/zlib)
- if(TARGET zlibstatic)
- set(_gRPC_ZLIB_LIBRARIES zlibstatic)
- endif()
- else()
- message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
- elseif("<%text>${gRPC_ZLIB_PROVIDER}</%text>" STREQUAL "package")
- find_package(ZLIB REQUIRED)
- set(_gRPC_ZLIB_LIBRARIES <%text>${ZLIB_LIBRARIES}</%text>)
- set(_gRPC_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
- endif()
-
- if("<%text>${gRPC_CARES_PROVIDER}</%text>" STREQUAL "module")
- if(NOT CARES_ROOT_DIR)
- set(CARES_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/cares/cares)
- endif()
- set(CARES_SHARED OFF CACHE BOOL "disable shared library")
- set(CARES_STATIC ON CACHE BOOL "link cares statically")
- set(CARES_INCLUDE_DIR "<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/cares/cares")
- add_subdirectory(third_party/cares/cares)
- if(TARGET c-ares)
- set(_gRPC_CARES_LIBRARIES c-ares)
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
- elseif("<%text>${gRPC_CARES_PROVIDER}</%text>" STREQUAL "package")
- find_package(c-ares REQUIRED CONFIG)
- if(TARGET c-ares::cares)
- set(_gRPC_CARES_LIBRARIES c-ares::cares)
- endif()
- set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
- endif()
-
- if("<%text>${gRPC_PROTOBUF_PROVIDER}</%text>" STREQUAL "module")
- # Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
- # Disable them unless they are explicitly requested from the cmake command line (when we assume
- # gmock is downloaded to the right location inside protobuf).
- if(NOT protobuf_BUILD_TESTS)
- set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
- endif()
- # Disable building protobuf with zlib. Building protobuf with zlib breaks
- # the build if zlib is not installed on the system.
- if(NOT protobuf_WITH_ZLIB)
- set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.")
- endif()
- if(NOT PROTOBUF_ROOT_DIR)
- set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/protobuf)
- endif()
- set(PROTOBUF_WELLKNOWN_IMPORT_DIR <%text>${PROTOBUF_ROOT_DIR}</%text>/src)
- if(EXISTS "<%text>${PROTOBUF_ROOT_DIR}</%text>/cmake/CMakeLists.txt")
- set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
- add_subdirectory(<%text>${PROTOBUF_ROOT_DIR}</%text>/cmake third_party/protobuf)
- if(TARGET <%text>${_gRPC_PROTOBUF_LIBRARY_NAME}</%text>)
- set(_gRPC_PROTOBUF_LIBRARIES <%text>${_gRPC_PROTOBUF_LIBRARY_NAME}</%text>)
- endif()
- if(TARGET libprotoc)
- set(_gRPC_PROTOBUF_PROTOC_LIBRARIES libprotoc)
- endif()
- if(TARGET protoc)
- set(_gRPC_PROTOBUF_PROTOC protoc)
- set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
- endif()
- else()
- message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
- elseif("<%text>${gRPC_PROTOBUF_PROVIDER}</%text>" STREQUAL "package")
- find_package(Protobuf REQUIRED <%text>${gRPC_PROTOBUF_PACKAGE_TYPE}</%text>)
- if(Protobuf_FOUND OR PROTOBUF_FOUND)
- if(TARGET protobuf::<%text>${_gRPC_PROTOBUF_LIBRARY_NAME}</%text>)
- set(_gRPC_PROTOBUF_LIBRARIES protobuf::<%text>${_gRPC_PROTOBUF_LIBRARY_NAME}</%text>)
- else()
- set(_gRPC_PROTOBUF_LIBRARIES <%text>${PROTOBUF_LIBRARIES}</%text>)
- endif()
- if(TARGET protobuf::libprotoc)
- set(_gRPC_PROTOBUF_PROTOC_LIBRARIES protobuf::libprotoc)
- else()
- set(_gRPC_PROTOBUF_PROTOC_LIBRARIES <%text>${PROTOBUF_PROTOC_LIBRARIES}</%text>)
- endif()
- if(TARGET protobuf::protoc)
- set(_gRPC_PROTOBUF_PROTOC protobuf::protoc)
- set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protobuf::protoc>)
- else()
- set(_gRPC_PROTOBUF_PROTOC <%text>${PROTOBUF_PROTOC_EXECUTABLE}</%text>)
- set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE <%text>${PROTOBUF_PROTOC_EXECUTABLE}</%text>)
- endif()
- set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf <%text>${gRPC_PROTOBUF_PACKAGE_TYPE}</%text>)\nendif()")
- endif()
- if(PROTOBUF_FOUND)
- include_directories(<%text>${PROTOBUF_INCLUDE_DIRS}</%text>)
- endif()
- set(PROTOBUF_WELLKNOWN_IMPORT_DIR /usr/local/include)
- endif()
-
- if("<%text>${gRPC_SSL_PROVIDER}</%text>" STREQUAL "module")
- if(NOT BORINGSSL_ROOT_DIR)
- set(BORINGSSL_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/boringssl)
- endif()
- if(EXISTS "<%text>${BORINGSSL_ROOT_DIR}</%text>/CMakeLists.txt")
- set(OPENSSL_NO_ASM ON) # make boringssl buildable with Visual Studio
- add_subdirectory(<%text>${BORINGSSL_ROOT_DIR}</%text> third_party/boringssl)
- if(TARGET ssl)
- set(_gRPC_SSL_LIBRARIES ssl)
- endif()
- else()
- message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
- endif()
- if(gRPC_INSTALL)
- message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
- set(gRPC_INSTALL FALSE)
- endif()
- elseif("<%text>${gRPC_SSL_PROVIDER}</%text>" STREQUAL "package")
- find_package(OpenSSL REQUIRED)
- set(_gRPC_SSL_LIBRARIES <%text>${OPENSSL_LIBRARIES}</%text>)
- set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()")
- endif()
-
- if("<%text>${gRPC_GFLAGS_PROVIDER}</%text>" STREQUAL "module")
- if(NOT GFLAGS_ROOT_DIR)
- set(GFLAGS_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/gflags)
- endif()
- if(EXISTS "<%text>${GFLAGS_ROOT_DIR}</%text>/CMakeLists.txt")
- add_subdirectory(<%text>${GFLAGS_ROOT_DIR}</%text> third_party/gflags)
- if(TARGET gflags_static)
- set(_gRPC_GFLAGS_LIBRARIES gflags_static)
- endif()
- else()
- message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
- endif()
- elseif("<%text>${gRPC_GFLAGS_PROVIDER}</%text>" STREQUAL "package")
- find_package(gflags)
- if(TARGET gflags::gflags)
- set(_gRPC_GFLAGS_LIBRARIES gflags::gflags)
- endif()
- set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags)\nendif()")
- endif()
-
- if("<%text>${gRPC_BENCHMARK_PROVIDER}</%text>" STREQUAL "module")
- if(NOT BENCHMARK_ROOT_DIR)
- set(BENCHMARK_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/benchmark)
- endif()
- if(EXISTS "<%text>${BENCHMARK_ROOT_DIR}</%text>/CMakeLists.txt")
- add_subdirectory(<%text>${BENCHMARK_ROOT_DIR}</%text> third_party/benchmark)
- if(TARGET benchmark)
- set(_gRPC_BENCHMARK_LIBRARIES benchmark)
- endif()
- else()
- message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
- endif()
- elseif("<%text>${gRPC_BENCHMARK_PROVIDER}</%text>" STREQUAL "package")
- find_package(benchmark)
- if(TARGET benchmark::benchmark)
- set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark)
- endif()
- set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark)\nendif()")
- endif()
+ include(cmake/zlib.cmake)
+ include(cmake/cares.cmake)
+ include(cmake/protobuf.cmake)
+ include(cmake/ssl.cmake)
+ include(cmake/gflags.cmake)
+ include(cmake/benchmark.cmake)
if(NOT MSVC)
set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS}</%text> -std=c99")
@@ -359,7 +197,7 @@
return()
endif()
- set(_protobuf_include_path -I . -I <%text>${PROTOBUF_WELLKNOWN_IMPORT_DIR}</%text>)
+ set(_protobuf_include_path -I . -I <%text>${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}</%text>)
foreach(FIL <%text>${ARGN}</%text>)
get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE)
get_filename_component(FIL_WE <%text>${FIL}</%text> NAME_WE)
@@ -444,7 +282,7 @@
% for lib in libs:
% if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl:
% if not lib.get('build_system', []) or 'cmake' in lib.get('build_system', []):
- % if not lib.name in ['benchmark', 'z']: # we build these using CMake instead
+ % if not lib.name in ['ares', 'benchmark', 'z']: # we build these using CMake instead
% if lib.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
${cc_library(lib)}
@@ -514,14 +352,12 @@
target_include_directories(${lib.name}
PUBLIC <%text>$<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include></%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
- PRIVATE <%text>${BORINGSSL_ROOT_DIR}</%text>/include
- PRIVATE <%text>${PROTOBUF_ROOT_DIR}</%text>/src
- PRIVATE <%text>${ZLIB_INCLUDE_DIR}</%text>
- PRIVATE <%text>${BENCHMARK}</%text>/include
- PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/zlib
- PRIVATE <%text>${CARES_INCLUDE_DIR}</%text>
- PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/cares/cares
- PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/gflags/include
+ PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
% if lib.build in ['test', 'private'] and lib.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
@@ -585,14 +421,12 @@
target_include_directories(${tgt.name}
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include
- PRIVATE <%text>${BORINGSSL_ROOT_DIR}</%text>/include
- PRIVATE <%text>${PROTOBUF_ROOT_DIR}</%text>/src
- PRIVATE <%text>${BENCHMARK_ROOT_DIR}</%text>/include
- PRIVATE <%text>${ZLIB_ROOT_DIR}</%text>
- PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/zlib
- PRIVATE <%text>${CARES_INCLUDE_DIR}</%text>
- PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/cares/cares
- PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/gflags/include
+ PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR}</%text>
% if tgt.build in ['test', 'private'] and tgt.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
diff --git a/templates/Makefile.template b/templates/Makefile.template
index 0588787910..b8e26b646b 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -215,7 +215,7 @@
ifeq ($(SYSTEM),Darwin)
CXXFLAGS += -stdlib=libc++
endif
- % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
+ % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'COREFLAGS', 'LDFLAGS', 'DEFINES']:
% if defaults.get('global', []).get(arg, None) is not None:
${arg} += ${defaults.get('global').get(arg)}
% endif
@@ -563,7 +563,6 @@
ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
ZLIB_MERGE_OBJS = $(LIBZ_OBJS)
CPPFLAGS += -Ithird_party/zlib
- LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
else
ifeq ($(HAS_PKG_CONFIG),true)
CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
@@ -594,7 +593,6 @@
CARES_MERGE_OBJS = $(LIBARES_OBJS)
CARES_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libares.a
CPPFLAGS := -Ithird_party/cares -Ithird_party/cares/cares $(CPPFLAGS)
- LDFLAGS := -L$(LIBDIR)/$(CONFIG)/c-ares $(LDFLAGS)
else
ifeq ($(HAS_PKG_CONFIG),true)
PC_REQUIRES_GRPC += libcares
@@ -896,10 +894,10 @@
$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
$(E) "[MAKE] Building protobuf"
+ $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
$(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g $(PROTOBUF_LDFLAGS_EXTRA)" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g $(PROTOBUF_CPPFLAGS_EXTRA)" ./configure --disable-shared --enable-static $(PROTOBUF_CONFIG_OPTS))
$(Q)$(MAKE) -C third_party/protobuf clean
$(Q)$(MAKE) -C third_party/protobuf
- $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
$(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
$(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
$(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
@@ -1268,6 +1266,16 @@
$(Q) mkdir -p `dirname $@`
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
+ $(OBJDIR)/$(CONFIG)/src/core/%.o : src/core/%.cc
+ $(E) "[CXX] Compiling $<"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
+
+ $(OBJDIR)/$(CONFIG)/test/core/%.o : test/core/%.cc
+ $(E) "[CXX] Compiling $<"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
+
$(OBJDIR)/$(CONFIG)/%.o : %.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
@@ -1373,14 +1381,14 @@
install-pkg-config_c: pc_c pc_c_unsecure
$(E) "[INSTALL] Installing C pkg-config files"
$(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
$(E) "[INSTALL] Installing C++ pkg-config files"
$(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
- $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
+ $(Q) $(INSTALL) -m 0644 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
install-certs: etc/roots.pem
$(E) "[INSTALL] Installing root certificates"
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
deleted file mode 100644
index adb7d9f774..0000000000
--- a/templates/binding.gyp.template
+++ /dev/null
@@ -1,371 +0,0 @@
-%YAML 1.2
---- |
- # GRPC Node gyp file
- # This currently builds the Node extension and dependencies
- # This file has been automatically generated from a template file.
- # Please look at the templates directory instead.
- # This file can be regenerated from the template by running
- # tools/buildgen/generate_projects.sh
-
- # 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.
-
- # Some of this file is built with the help of
- # https://n8.io/converting-a-c-library-to-gyp/
- {
- 'variables': {
- 'runtime%': 'node',
- # Some Node installations use the system installation of OpenSSL, and on
- # some systems, the system OpenSSL still does not have ALPN support. This
- # will let users recompile gRPC to work without ALPN.
- 'grpc_alpn%': 'true',
- # Indicates that the library should be built with gcov.
- 'grpc_gcov%': 'false',
- # Indicates that the library should be built with compatibility for musl
- # libc, so that it can run on Alpine Linux. This is only necessary if not
- # building on Alpine Linux
- 'grpc_alpine%': 'false'
- },
- 'target_defaults': {
- 'configurations': {
- % for name, args in configs.iteritems():
- % if name in ['dbg', 'opt']:
- '${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
- % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
- % if args.get(arg, None) is not None:
- '${prop}': [
- % for item in args.get(arg).split():
- '${item}',
- % endfor
- ],
- % endif
- % endfor
- },
- % endif
- % endfor
- },
- % for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
- % if defaults['global'].get(arg, None) is not None:
- '${prop}': [
- % for item in defaults['global'].get(arg).split():
- '${item}',
- % endfor
- ],
- % endif
- % endfor
- 'cflags_c': [
- '-Werror',
- '-std=c99'
- ],
- 'cflags_cc': [
- '-Werror',
- '-std=c++11'
- ],
- 'include_dirs': [
- '.',
- 'include'
- ],
- 'defines': [
- 'GPR_BACKWARDS_COMPATIBILITY_MODE',
- 'GRPC_ARES=0',
- 'GRPC_UV'
- ],
- 'conditions': [
- ['grpc_gcov=="true"', {
- % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
- % if configs['gcov'].get(arg, None) is not None:
- '${prop}': [
- % for item in configs['gcov'].get(arg).split():
- '${item}',
- % endfor
- ],
- % endif
- % endfor
- }],
- ['grpc_alpine=="true"', {
- 'defines': [
- 'GPR_MUSL_LIBC_COMPAT'
- ]
- }],
- ['OS!="win" and runtime=="electron"', {
- "defines": [
- 'OPENSSL_NO_THREADS'
- ]
- }],
- # This is the condition for using boringssl
- ['OS=="win" or runtime=="electron"', {
- "include_dirs": [
- "third_party/boringssl/include"
- ],
- "defines": [
- 'OPENSSL_NO_ASM'
- ]
- }, {
- 'conditions': [
- ["target_arch=='ia32'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
- }],
- ["target_arch=='x64'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
- }],
- ["target_arch=='arm'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
- }],
- ['grpc_alpn=="true"', {
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=1'
- ],
- }, {
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=0'
- ],
- }]
- ],
- 'include_dirs': [
- '<(node_root_dir)/deps/openssl/openssl/include',
- ]
- }],
- ['OS == "win"', {
- "include_dirs": [
- "third_party/zlib",
- "third_party/cares/cares"
- ],
- "defines": [
- '_WIN32_WINNT=0x0600',
- 'WIN32_LEAN_AND_MEAN',
- '_HAS_EXCEPTIONS=0',
- 'UNICODE',
- '_UNICODE',
- 'NOMINMAX',
- ],
- "msvs_settings": {
- 'VCCLCompilerTool': {
- 'RuntimeLibrary': 1, # static debug
- }
- },
- "libraries": [
- "ws2_32"
- ]
- }, { # OS != "win"
- 'include_dirs': [
- '<(node_root_dir)/deps/zlib',
- '<(node_root_dir)/deps/cares/include'
- ]
- }],
- ['OS == "mac"', {
- 'xcode_settings': {
- % if defaults['global'].get('CPPFLAGS', None) is not None:
- 'OTHER_CFLAGS': [
- % for item in defaults['global'].get('CPPFLAGS').split():
- '${item}',
- % endfor
- ],
- 'OTHER_CPLUSPLUSFLAGS': [
- % for item in defaults['global'].get('CPPFLAGS').split():
- '${item}',
- % endfor
- '-stdlib=libc++',
- '-std=c++11',
- '-Wno-error=deprecated-declarations'
- ],
- % endif
- },
- }]
- ]
- },
- 'conditions': [
- ['OS=="win" or runtime=="electron"', {
- 'targets': [
- % for module in node_modules:
- % for lib in libs:
- % if lib.name in module.transitive_deps and lib.name == 'boringssl':
- {
- 'target_name': '${lib.name}',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- % for dep in getattr(lib, 'deps', []):
- '${dep}',
- % endfor
- ],
- 'sources': [
- % for source in lib.src:
- '${source}',
- % endfor
- ],
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ]
- },
- % endif
- % endfor
- % endfor
- ],
- }],
- ['OS == "win" and runtime!="electron"', {
- 'targets': [
- {
- # IMPORTANT WINDOWS BUILD INFORMATION
- # This library does not build on Windows without modifying the Node
- # development packages that node-gyp downloads in order to build.
- # Due to https://github.com/nodejs/node/issues/4932, the headers for
- # BoringSSL conflict with the OpenSSL headers included by default
- # when including the Node headers. The remedy for this is to remove
- # the OpenSSL headers, from the downloaded Node development package,
- # which is typically located in `.node-gyp` in your home directory.
- #
- # This is not true of Electron, which does not have OpenSSL headers.
- 'target_name': 'WINDOWS_BUILD_WARNING',
- 'rules': [
- {
- 'rule_name': 'WINDOWS_BUILD_WARNING',
- 'extension': 'S',
- 'inputs': [
- 'package.json'
- ],
- 'outputs': [
- 'ignore_this_part'
- ],
- 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
- }
- ]
- },
- ]
- }],
- ['OS == "win"', {
- 'targets': [
- # Only want to compile zlib under Windows
- % for module in node_modules:
- % for lib in libs:
- % if lib.name in module.transitive_deps and lib.name == 'z':
- {
- 'target_name': '${lib.name}',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- % for dep in getattr(lib, 'deps', []):
- '${dep}',
- % endfor
- ],
- 'sources': [
- % for source in lib.src:
- '${source}',
- % endfor
- ]
- },
- % endif
- % endfor
- % endfor
- ]
- }]
- ],
- 'targets': [
- % for module in node_modules:
- % for lib in libs:
- % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
- {
- 'target_name': '${lib.name}',
- 'product_prefix': 'lib',
- 'type': 'static_library',
- 'dependencies': [
- % for dep in getattr(lib, 'deps', []):
- '${dep}',
- % endfor
- ],
- 'sources': [
- % for source in lib.src:
- '${source}',
- % endfor
- ],
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ]
- },
- % endif
- % endfor
- {
- 'include_dirs': [
- "<!(node -e \"require('nan')\")"
- ],
- 'cflags': [
- '-pthread',
- '-zdefs',
- '-Wno-error=deprecated-declarations'
- ],
- "conditions": [
- ['OS=="win" or runtime=="electron"', {
- 'dependencies': [
- % for dep in getattr(module, 'deps', []):
- % if dep == 'boringssl':
- "${dep}",
- % endif
- % endfor
- ]
- }],
- ['OS=="win"', {
- 'dependencies': [
- % for dep in getattr(module, 'deps', []):
- % if dep == 'z':
- "${dep}",
- % endif
- % endfor
- ]
- }],
- ['OS=="linux"', {
- 'ldflags': [
- '-Wl,-wrap,memcpy'
- ]
- }],
- ['OS == "mac"', {
- 'xcode_settings': {
- 'MACOSX_DEPLOYMENT_TARGET': '10.9'
- }
- }]
- ],
- "target_name": "${module.name}",
- "sources": [
- % for source in module.src:
- "${source}",
- % endfor
- ],
- "dependencies": [
- % for dep in getattr(module, 'deps', []):
- % if dep not in ('boringssl', 'z'):
- "${dep}",
- % endif
- % endfor
- ]
- },
- % endfor
- {
- "target_name": "action_after_build",
- "type": "none",
- "dependencies": [ "<(module_name)" ],
- "copies": [
- {
- "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
- "destination": "<(module_path)"
- }
- ]
- }
- ]
- }
diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template
new file mode 100644
index 0000000000..78adb27915
--- /dev/null
+++ b/templates/gRPC-C++.podspec.template
@@ -0,0 +1,193 @@
+%YAML 1.2
+--- |
+ # This file has been automatically generated from a template file.
+ # Please make modifications to `templates/gRPC-C++.podspec.template`
+ # instead. This file can be regenerated from the template by running
+ # `tools/buildgen/generate_projects.sh`.
+
+ # gRPC C++ CocoaPods podspec
+ #
+ # 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.
+
+ <%!
+ def grpc_lib_files(libs, expect_libs, groups):
+ out = []
+ for lib in libs:
+ if lib.name in expect_libs:
+ for group in groups:
+ out += lib.get(group, [])
+ return out
+
+ def grpc_private_files(libs):
+ out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers", "src"))
+ return out
+
+ def grpc_private_headers(libs):
+ out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers",))
+ return out
+
+ def grpc_public_headers(libs):
+ out = grpc_lib_files(libs, ("grpc", "gpr"), ("public_headers",))
+ return out
+
+ def grpcpp_proto_files(filegroups):
+ out = grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src", "public_headers"))
+ excl_files = grpc_lib_files(filegroups, ("grpc++_codegen_base",), ("headers", "src", "public_headers"))
+ out = [file for file in out if file not in excl_files]
+ return out
+
+ def grpcpp_private_files(libs, filegroups):
+ out = grpc_lib_files(libs, ("grpc++",), ("headers", "src"))
+ excl_files = grpc_private_files(libs)
+
+ # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
+ excl_files += grpcpp_proto_files(filegroups)
+ out = [file for file in out if file not in excl_files]
+
+ # Since some C++ source files directly included private headers in C core, we include all the
+ # C core headers in C++ Implementation subspec as well.
+ out += [file for file in grpc_private_headers(libs) if not file.startswith("third_party/nanopb/")]
+ return out
+
+ def grpcpp_private_headers(libs, filegroups):
+ out = grpc_lib_files(libs, ("grpc++",), ("headers",))
+
+ # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
+ excl_files = grpcpp_proto_files(filegroups)
+ out = [file for file in out if file not in excl_files]
+
+ # Since some C++ source files directly included private headers in C core, we intentionally
+ # keep the C core headers in \a out. But we should exclude nanopb headers.
+ out = [file for file in out if not file.startswith("third_party/nanopb/")]
+ return out
+
+ def grpcpp_public_headers(libs, filegroups):
+ out = grpc_lib_files(libs, ("grpc++",), ("public_headers",))
+ excl_files = grpc_public_headers(libs)
+
+ # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
+ excl_files += grpcpp_proto_files(filegroups)
+
+ out = [file for file in out if file not in excl_files]
+ return out
+
+ def grpc_test_util_files(libs):
+ out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("src", "headers"))
+ return out
+
+ def grpc_test_util_headers(libs):
+ out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("headers",))
+ return out
+
+ def grpcpp_test_util_files(libs, filegroups):
+ out = grpc_lib_files(libs, ("grpc++_test_util",), ("src", "headers"))
+ excl_files = grpc_test_util_files(libs) + grpcpp_private_files(libs, filegroups)
+
+ # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
+ excl_files += grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src"))
+ excl_files += ["test/cpp/util/byte_buffer_proto_helper.cc",
+ "test/cpp/util/byte_buffer_proto_helper.h",
+ "test/cpp/end2end/test_service_impl.cc",
+ "test/cpp/end2end/test_service_impl.h"]
+ excl_files += [file for file in out if file.endswith(".proto")]
+
+ out = [file for file in out if not file in excl_files]
+
+ # Since some C++ test files directly included private headers in C core, we intentionally add these header
+ # files to this subspec
+ out += grpc_test_util_headers(libs)
+
+ return out
+
+ def ruby_multiline_list(files, indent):
+ return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
+ %>
+ Pod::Spec.new do |s|
+ s.name = 'gRPC-C++'
+ # TODO (mxyan): use version that match gRPC version when pod is stabilized
+ # version = '${settings.version}'
+ version = '0.0.1'
+ s.version = version
+ s.summary = 'gRPC C++ library'
+ s.homepage = 'https://grpc.io'
+ s.license = 'Apache License, Version 2.0'
+ s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
+
+ grpc_version = '${settings.version}'
+
+ s.source = {
+ :git => 'https://github.com/grpc/grpc.git',
+ :tag => "v#{grpc_version}",
+ }
+
+ s.ios.deployment_target = '7.0'
+ s.osx.deployment_target = '10.9'
+ s.requires_arc = false
+
+ # Add include prefix `grpc++` (i.e. `#include <grpc++/xxx.h>`).
+ s.header_dir = 'grpc++'
+
+ s.pod_target_xcconfig = {
+ 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
+ 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
+ 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
+ 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
+
+ # If we don't set these two settings, `include/grpc/support/time.h` and
+ # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # build.
+ 'USE_HEADERMAP' => 'NO',
+ 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ }
+
+ s.libraries = 'c++'
+
+ s.default_subspecs = 'Interface', 'Implementation'
+
+ s.subspec 'Interface' do |ss|
+ ss.header_mappings_dir = 'include/grpc++'
+
+ ss.source_files = ${ruby_multiline_list(grpcpp_public_headers(libs, filegroups), 22)}
+ end
+
+ s.subspec 'Implementation' do |ss|
+ ss.header_mappings_dir = '.'
+ ss.dependency "#{s.name}/Interface", version
+ ss.dependency 'gRPC-Core', grpc_version
+ ss.dependency 'nanopb', '~> 0.3'
+
+ ss.source_files = ${ruby_multiline_list(grpcpp_private_files(libs, filegroups), 22)}
+
+ ss.private_header_files = ${ruby_multiline_list(grpcpp_private_headers(libs, filegroups), 30)}
+ end
+
+ s.subspec 'Tests' do |ss|
+ ss.header_mappings_dir = '.'
+
+ ss.dependency "#{s.name}/Interface", version
+ ss.dependency "#{s.name}/Implementation", version
+ ss.dependency "gRPC-Core/Tests", grpc_version
+
+ ss.source_files = ${ruby_multiline_list(grpcpp_test_util_files(libs, filegroups), 22)}
+ end
+
+ s.prepare_command = <<-END_OF_COMMAND
+ find src/cpp/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/cpp/ -name "*.back" -type f -delete
+ find src/core/ -regex ".*\.h" -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/core/ -name "*.back" -type f -delete
+ END_OF_COMMAND
+ end
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index 6077f8098d..2be7692e04 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -22,27 +22,51 @@
# limitations under the License.
<%!
- def grpc_private_files(libs):
+ def grpc_lib_files(libs, expect_libs, groups):
out = []
for lib in libs:
- if lib.name in ("grpc", "gpr"):
- out += lib.get('headers', [])
- out += lib.get('src', [])
- return [f for f in out if not f.startswith("third_party/nanopb/")]
+ if lib.name in expect_libs:
+ for group in groups:
+ out += lib.get(group, [])
+ return out
+
+ def grpc_private_files(libs):
+ out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers", "src"))
+ return [file for file in out if not file.startswith("third_party/nanopb/")]
def grpc_public_headers(libs):
- out = []
- for lib in libs:
- if lib.name in ("grpc", "gpr"):
- out += lib.get('public_headers', [])
+ out = grpc_lib_files(libs, ("grpc", "gpr"), ("public_headers",))
return out
def grpc_private_headers(libs):
- out = []
- for lib in libs:
- if lib.name in ("grpc", "gpr"):
- out += lib.get('headers', [])
- return [f for f in out if not f.startswith("third_party/nanopb/")]
+ out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers",))
+ return [file for file in out if not file.startswith("third_party/nanopb/")]
+
+ def grpc_cronet_files(libs):
+ out = grpc_lib_files(libs, ("grpc_cronet",), ("src", "headers"))
+ excl = grpc_private_files(libs)
+ excl += [
+ # We do not need cronet dedicated plugin registry
+ "src/core/plugin_registry/grpc_cronet_plugin_registry.cc",
+ # We do not need dummy cronet API for ObjC
+ "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc",
+ ]
+ return [file for file in out if not file in excl]
+
+ def grpc_cronet_public_headers(libs):
+ out = grpc_lib_files(libs, ("grpc_cronet",), ("public_headers",))
+ excl = grpc_public_headers(libs)
+ return [file for file in out if not file in excl]
+
+ def grpc_test_util_files(libs):
+ out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("src", "headers"))
+ excl = grpc_private_files(libs)
+ return [file for file in out if not file in excl]
+
+ def end2end_tests_files(libs):
+ out = grpc_lib_files(libs, ("end2end_tests",), ("src", "headers"))
+ excl = grpc_private_files(libs)
+ return [file for file in out if not file in excl]
def ruby_multiline_list(files, indent):
return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
@@ -61,6 +85,10 @@
:tag => "v#{version}",
}
+ # gRPC podspecs depend on fix for https://github.com/CocoaPods/CocoaPods/issues/6024,
+ # which was released in Cocoapods v1.2.0.
+ s.cocoapods_version = '>= 1.2.0'
+
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.requires_arc = false
@@ -107,14 +135,17 @@
'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
# If we don't set these two settings, `include/grpc/support/time.h` and
- # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
# build.
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
}
s.default_subspecs = 'Interface', 'Implementation'
s.compiler_flags = '-DGRPC_ARES=0'
+ s.libraries = 'c++'
# Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its
# sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't
@@ -146,7 +177,7 @@
s.subspec 'Cronet-Interface' do |ss|
ss.header_mappings_dir = 'include/grpc'
- ss.source_files = 'include/grpc/grpc_cronet.h'
+ ss.source_files = ${ruby_multiline_list(grpc_cronet_public_headers(libs), 22)}
end
s.subspec 'Cronet-Implementation' do |ss|
@@ -156,9 +187,7 @@
ss.dependency "#{s.name}/Implementation", version
ss.dependency "#{s.name}/Cronet-Interface", version
- ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c',
- 'src/core/ext/transport/cronet/transport/cronet_transport.{c,h}',
- 'third_party/objective_c/Cronet/bidirectional_stream_c.h'
+ ss.source_files = ${ruby_multiline_list(grpc_cronet_files(libs), 22)}
end
s.subspec 'Tests' do |ss|
@@ -167,21 +196,12 @@
ss.dependency "#{s.name}/Interface", version
ss.dependency "#{s.name}/Implementation", version
- ss.source_files = 'test/core/end2end/cq_verifier.{c,h}',
- 'test/core/end2end/end2end_tests.{c,h}',
- 'test/core/end2end/end2end_test_utils.c',
- 'test/core/end2end/tests/*.{c,h}',
- 'test/core/end2end/fixtures/*.h',
- 'test/core/end2end/data/*.{c,h}',
- 'test/core/util/debugger_macros.{c,h}',
- 'test/core/util/test_config.{c,h}',
- 'test/core/util/port.h',
- 'test/core/util/port.c',
- 'test/core/util/port_server_client.{c,h}'
+ ss.source_files = ${ruby_multiline_list(grpc_test_util_files(libs), 22)},
+ ${ruby_multiline_list(end2end_tests_files(libs), 22)}
end
# TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path?
s.prepare_command = <<-END_OF_COMMAND
- find src/core/ -type f -exec sed -E -i '.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/core/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
END_OF_COMMAND
end
diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template
index 4d99f6e19f..d2dcc429ef 100644
--- a/templates/gRPC-ProtoRPC.podspec.template
+++ b/templates/gRPC-ProtoRPC.podspec.template
@@ -54,5 +54,6 @@
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
}
end
diff --git a/templates/gRPC-RxLibrary.podspec.template b/templates/gRPC-RxLibrary.podspec.template
index de4ee1e438..14147d7dc1 100644
--- a/templates/gRPC-RxLibrary.podspec.template
+++ b/templates/gRPC-RxLibrary.podspec.template
@@ -46,4 +46,8 @@
s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
s.private_header_files = "#{src_dir}/private/*.h"
s.header_mappings_dir = "#{src_dir}"
+
+ s.pod_target_xcconfig = {
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
+ }
end
diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template
index 5c92f9f9c4..6616e74bd7 100644
--- a/templates/gRPC.podspec.template
+++ b/templates/gRPC.podspec.template
@@ -52,6 +52,7 @@
s.pod_target_xcconfig = {
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
+ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
}
s.subspec 'Main' do |ss|
@@ -65,10 +66,13 @@
end
s.subspec 'GID' do |ss|
+ ss.ios.deployment_target = '7.0'
+
ss.header_mappings_dir = "#{src_dir}"
ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}"
+ ss.dependency "#{s.name}/Main", version
ss.dependency 'Google/SignIn'
end
end
diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template
index 215d5f9df9..fb54de1c8e 100644
--- a/templates/grpc.gemspec.template
+++ b/templates/grpc.gemspec.template
@@ -30,7 +30,7 @@
s.platform = Gem::Platform::RUBY
s.add_dependency 'google-protobuf', '~> 3.1'
- s.add_dependency 'googleauth', '~> 0.5.1'
+ s.add_dependency 'googleauth', '>= 0.5.1', '< 0.7'
s.add_dependency 'googleapis-common-protos-types', '~> 1.0.0'
s.add_development_dependency 'bundler', '~> 1.9'
diff --git a/templates/include/grpc/module.modulemap.template b/templates/include/grpc/module.modulemap.template
new file mode 100644
index 0000000000..e18bc3de50
--- /dev/null
+++ b/templates/include/grpc/module.modulemap.template
@@ -0,0 +1,58 @@
+%YAML 1.2
+--- |
+ <%!
+ # TODO (mxyan): Make this list from build.yaml
+ textual_headers = ["include/grpc/support/atm_gcc_atomic.h",
+ "include/grpc/support/atm_gcc_sync.h",
+ "include/grpc/support/atm_windows.h",
+ "include/grpc/support/sync_custom.h",
+ "include/grpc/support/sync_posix.h",
+ "include/grpc/support/sync_windows.h",
+ "include/grpc/support/tls_gcc.h",
+ "include/grpc/support/tls_msvc.h",
+ "include/grpc/support/tls_pthread.h",
+ "include/grpc/impl/codegen/atm_gcc_atomic.h",
+ "include/grpc/impl/codegen/atm_gcc_sync.h",
+ "include/grpc/impl/codegen/atm_windows.h",
+ "include/grpc/impl/codegen/sync_custom.h",
+ "include/grpc/impl/codegen/sync_posix.h",
+ "include/grpc/impl/codegen/sync_windows.h"]
+
+ def grpc_public_headers_no_dir(libs):
+ out = []
+ for lib in libs:
+ if lib.name in ("grpc", "gpr"):
+ out += lib.get('public_headers', [])
+ out = [f for f in out if f not in textual_headers]
+ out = [hdr.split('/', 2)[2] for hdr in out]
+ return out
+
+ # Generate the list of platform-specific headers as textual headers so that
+ # they are not built when the module is built but only when they are named by
+ # an #include directive.
+ def grpc_public_textual_headers_no_dir(libs):
+ out = []
+ for lib in libs:
+ if lib.name in ("grpc", "gpr"):
+ out += lib.get('public_headers', [])
+ out = [f for f in out if f in textual_headers]
+ out = [hdr.split('/', 2)[2] for hdr in out]
+ return out
+
+ def header_lines(files):
+ return ('\n ').join('header "%s"' % f for f in files)
+
+ def textual_header_lines(files):
+ return ('\n ').join('textual header "%s"' % f for f in files)
+ %>
+ framework module grpc {
+ umbrella header "grpc.h"
+
+ ${header_lines(grpc_public_headers_no_dir(libs))}
+
+ ${textual_header_lines(grpc_public_textual_headers_no_dir(libs))}
+
+ export *
+ module * { export * }
+ }
+
diff --git a/templates/package.json.template b/templates/package.json.template
deleted file mode 100644
index 50893d3a54..0000000000
--- a/templates/package.json.template
+++ /dev/null
@@ -1,105 +0,0 @@
-%YAML 1.2
---- |
- {
- "name": "grpc",
- "version": "${settings.node_version}",
- "author": "Google Inc.",
- "description": "gRPC Library for Node",
- "homepage": "https://grpc.io/",
- "repository": {
- "type": "git",
- "url": "https://github.com/grpc/grpc.git"
- },
- "bugs": "https://github.com/grpc/grpc/issues",
- "contributors": [
- {
- "name": "Michael Lumish",
- "email": "mlumish@google.com"
- }
- ],
- "directories": {
- "lib": "src/node/src"
- },
- "scripts": {
- "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore",
- "test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
- "electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
- "gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
- "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
- "install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build --library=static_library"
- },
- "bundledDependencies": [
- "node-pre-gyp"
- ],
- "dependencies": {
- "arguejs": "^0.2.3",
- "lodash": "^4.15.0",
- "nan": "^2.0.0",
- "node-pre-gyp": "^0.6.35",
- "protobufjs": "^5.0.0"
- },
- "devDependencies": {
- "async": "^2.0.1",
- "body-parser": "^1.15.2",
- "electron-mocha": "^3.1.1",
- "express": "^4.14.0",
- "google-auth-library": "^0.9.2",
- "google-protobuf": "^3.0.0",
- "istanbul": "^0.4.4",
- "jsdoc": "^3.3.2",
- "jshint": "^2.5.0",
- "minimist": "^1.1.0",
- "mocha": "^3.0.2",
- "mocha-jenkins-reporter": "^0.2.3",
- "poisson-process": "^0.2.1"
- },
- "engines": {
- "node": ">=4"
- },
- "binary": {
- "module_name": "grpc_node",
- "module_path": "src/node/extension_binary/{node_abi}-{platform}-{arch}",
- "host": "https://storage.googleapis.com/",
- "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
- "package_name": "{node_abi}-{platform}-{arch}.tar.gz"
- },
- "files": [
- "LICENSE",
- "src/node/README.md",
- "src/proto",
- "etc",
- "src/node/index.js",
- "src/node/src",
- "src/node/ext",
- "include/grpc",
- "src/core",
- "src/boringssl",
- "src/zlib",
- "third_party/nanopb",
- "third_party/zlib",
- "third_party/boringssl",
- "binding.gyp"
- ],
- "main": "src/node/index.js",
- "license": "Apache-2.0",
- "jshintConfig": {
- "bitwise": true,
- "curly": true,
- "eqeqeq": true,
- "esnext": true,
- "freeze": true,
- "immed": true,
- "indent": 2,
- "latedef": "nofunc",
- "maxlen": 80,
- "mocha": true,
- "newcap": true,
- "node": true,
- "noarg": true,
- "quotmark": "single",
- "strict": true,
- "trailing": true,
- "undef": true,
- "unused": "vars"
- }
- }
diff --git a/templates/package.xml.template b/templates/package.xml.template
index f10f75b8c0..7f201970b3 100644
--- a/templates/package.xml.template
+++ b/templates/package.xml.template
@@ -12,24 +12,19 @@
<email>grpc-packages@google.com</email>
<active>yes</active>
</lead>
- <date>2017-08-24</date>
+ <date>2018-01-19</date>
<time>16:06:07</time>
<version>
<release>${settings.php_version.php()}</release>
<api>${settings.php_version.php()}</api>
</version>
<stability>
- <release>beta</release>
- <api>beta</api>
+ <release>${settings.php_version.php_stability()}</release>
+ <api>${settings.php_version.php_stability()}</api>
</stability>
<license>Apache 2.0</license>
<notes>
- - Channel are now by default persistent #11878
- - Some bug fixes from 1.4 branch #12109, #12123
- - Fixed hang bug when fork() was used #11814
- - License changed to Apache 2.0
- - Added support for php_namespace option in codegen plugin #11886
- - Updated gRPC C Core library version 1.6
+ - TBD
</notes>
<contents>
<dir baseinstalldir="/" name="/">
diff --git a/templates/src/core/lib/surface/version.c.template b/templates/src/core/lib/surface/version.cc.template
index d2efa565e5..d9fa4479db 100644
--- a/templates/src/core/lib/surface/version.c.template
+++ b/templates/src/core/lib/surface/version.cc.template
@@ -23,6 +23,6 @@
#include <grpc/grpc.h>
- const char *grpc_version_string(void) { return "${settings.core_version}"; }
+ const char* grpc_version_string(void) { return "${settings.core_version}"; }
- const char *grpc_g_stands_for(void) { return "${settings.g_stands_for}"; }
+ const char* grpc_g_stands_for(void) { return "${settings.g_stands_for}"; }
diff --git a/templates/src/core/plugin_registry.template b/templates/src/core/plugin_registry.template
index cf0f4f523e..805ae9049f 100644
--- a/templates/src/core/plugin_registry.template
+++ b/templates/src/core/plugin_registry.template
@@ -2,7 +2,7 @@
---
foreach: libs
cond: selected.get('generate_plugin_registry', False)
-output_name: ${selected.name}_plugin_registry.c
+output_name: ${selected.name}_plugin_registry.cc
template: |
/*
*
@@ -25,8 +25,8 @@ template: |
#include <grpc/grpc.h>
%for plugin in selected.plugins:
- extern void ${plugin}_init(void);
- extern void ${plugin}_shutdown(void);
+ void ${plugin}_init(void);
+ void ${plugin}_shutdown(void);
%endfor
void grpc_register_built_in_plugins(void) {
diff --git a/templates/src/cpp/common/version_cc.cc.template b/templates/src/cpp/common/version_cc.cc.template
index d2e19fe264..9882878727 100644
--- a/templates/src/cpp/common/version_cc.cc.template
+++ b/templates/src/cpp/common/version_cc.cc.template
@@ -25,4 +25,4 @@
namespace grpc {
grpc::string Version() { return "${settings.cpp_version}"; }
- }
+ } // namespace grpc
diff --git a/templates/src/node/health_check/package.json.template b/templates/src/node/health_check/package.json.template
deleted file mode 100644
index 2bc6b13632..0000000000
--- a/templates/src/node/health_check/package.json.template
+++ /dev/null
@@ -1,31 +0,0 @@
-%YAML 1.2
---- |
- {
- "name": "grpc-health-check",
- "version": "${settings.node_version}",
- "author": "Google Inc.",
- "description": "Health check service for use with gRPC",
- "repository": {
- "type": "git",
- "url": "https://github.com/grpc/grpc.git"
- },
- "bugs": "https://github.com/grpc/grpc/issues",
- "contributors": [
- {
- "name": "Michael Lumish",
- "email": "mlumish@google.com"
- }
- ],
- "dependencies": {
- "grpc": "^${settings.node_version}",
- "lodash": "^3.9.3",
- "google-protobuf": "^3.0.0"
- },
- "files": [
- "LICENSE",
- "health.js",
- "v1"
- ],
- "main": "src/node/index.js",
- "license": "Apache-2.0"
- }
diff --git a/templates/src/node/tools/package.json.template b/templates/src/node/tools/package.json.template
deleted file mode 100644
index 74f68e4b81..0000000000
--- a/templates/src/node/tools/package.json.template
+++ /dev/null
@@ -1,43 +0,0 @@
-%YAML 1.2
---- |
- {
- "name": "grpc-tools",
- "version": "${settings.node_version}",
- "author": "Google Inc.",
- "description": "Tools for developing with gRPC on Node.js",
- "homepage": "https://grpc.io/",
- "repository": {
- "type": "git",
- "url": "https://github.com/grpc/grpc.git"
- },
- "bugs": "https://github.com/grpc/grpc/issues",
- "contributors": [
- {
- "name": "Michael Lumish",
- "email": "mlumish@google.com"
- }
- ],
- "bin": {
- "grpc_tools_node_protoc": "./bin/protoc.js",
- "grpc_tools_node_protoc_plugin": "./bin/protoc_plugin.js"
- },
- "scripts": {
- "install": "./node_modules/.bin/node-pre-gyp install"
- },
- "bundledDependencies": ["node-pre-gyp"],
- "binary": {
- "module_name": "grpc_tools",
- "host": "https://storage.googleapis.com/",
- "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
- "package_name": "{platform}-{arch}.tar.gz",
- "module_path": "bin"
- },
- "files": [
- "index.js",
- "bin/protoc.js",
- "bin/protoc_plugin.js",
- "bin/google/protobuf",
- "LICENSE"
- ],
- "main": "index.js"
- }
diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template
index 196c405468..5c1358f7c3 100644
--- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template
+++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template
@@ -103,7 +103,7 @@
s.preserve_paths = plugin
# Restrict the protoc version to the one supported by this plugin.
- s.dependency '!ProtoCompiler', '3.4.0'
+ s.dependency '!ProtoCompiler', '3.5.0'
# For the Protobuf dependency not to complain:
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
diff --git a/templates/src/objective-c/tests/version.h.template b/templates/src/objective-c/tests/version.h.template
new file mode 100644
index 0000000000..72774ab99c
--- /dev/null
+++ b/templates/src/objective-c/tests/version.h.template
@@ -0,0 +1,29 @@
+%YAML 1.2
+--- |
+ /*
+ *
+ * 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.
+ *
+ */
+
+ // This file is autogenerated from a template file. Please make
+ // modifications to
+ // `templates/src/objective-c/GRPCClient/private/version.h.template`
+ // instead. This file can be regenerated from the template by running
+ // `tools/buildgen/generate_projects.sh`.
+
+
+ #define GRPC_OBJC_VERSION_STRING @"${settings.version}"
+ #define GRPC_C_VERSION_STRING @"${settings.core_version}"
diff --git a/templates/src/python/grpcio/grpc_core_dependencies.py.template b/templates/src/python/grpcio/grpc_core_dependencies.py.template
index 02e066cf8f..6295ed3081 100644
--- a/templates/src/python/grpcio/grpc_core_dependencies.py.template
+++ b/templates/src/python/grpcio/grpc_core_dependencies.py.template
@@ -20,7 +20,7 @@
% for lib in libs:
% if lib.name in python_dependencies.transitive_deps:
% for src in lib.src:
- '${src}',
+ '${src}',
% endfor
% endif
% endfor
diff --git a/templates/src/python/grpcio/grpc_version.py.template b/templates/src/python/grpcio/grpc_version.py.template
index 38ae54d619..5e5d22126e 100644
--- a/templates/src/python/grpcio/grpc_version.py.template
+++ b/templates/src/python/grpcio/grpc_version.py.template
@@ -16,4 +16,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!!
- VERSION='${settings.python_version.pep440()}'
+ VERSION = '${settings.python_version.pep440()}'
diff --git a/templates/src/python/grpcio_health_checking/grpc_version.py.template b/templates/src/python/grpcio_health_checking/grpc_version.py.template
index 558b2d152b..ffb81acc89 100644
--- a/templates/src/python/grpcio_health_checking/grpc_version.py.template
+++ b/templates/src/python/grpcio_health_checking/grpc_version.py.template
@@ -16,4 +16,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!!
- VERSION='${settings.python_version.pep440()}'
+ VERSION = '${settings.python_version.pep440()}'
diff --git a/templates/src/python/grpcio_reflection/grpc_version.py.template b/templates/src/python/grpcio_reflection/grpc_version.py.template
index 8fb42a4859..cc99533a43 100644
--- a/templates/src/python/grpcio_reflection/grpc_version.py.template
+++ b/templates/src/python/grpcio_reflection/grpc_version.py.template
@@ -16,4 +16,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!!
- VERSION='${settings.python_version.pep440()}'
+ VERSION = '${settings.python_version.pep440()}'
diff --git a/templates/src/python/grpcio_testing/grpc_version.py.template b/templates/src/python/grpcio_testing/grpc_version.py.template
index 74db811d60..a49392e5b1 100644
--- a/templates/src/python/grpcio_testing/grpc_version.py.template
+++ b/templates/src/python/grpcio_testing/grpc_version.py.template
@@ -16,4 +16,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!!
- VERSION='${settings.python_version.pep440()}'
+ VERSION = '${settings.python_version.pep440()}'
diff --git a/templates/src/python/grpcio_tests/grpc_version.py.template b/templates/src/python/grpcio_tests/grpc_version.py.template
index 16fc92e536..851fb7bce1 100644
--- a/templates/src/python/grpcio_tests/grpc_version.py.template
+++ b/templates/src/python/grpcio_tests/grpc_version.py.template
@@ -16,4 +16,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!!
- VERSION='${settings.python_version.pep440()}'
+ VERSION = '${settings.python_version.pep440()}'
diff --git a/templates/test/core/end2end/end2end_nosec_tests.c.template b/templates/test/core/end2end/end2end_nosec_tests.cc.template
index 3719ded75d..3719ded75d 100644
--- a/templates/test/core/end2end/end2end_nosec_tests.c.template
+++ b/templates/test/core/end2end/end2end_nosec_tests.cc.template
diff --git a/templates/test/core/end2end/end2end_tests.c.template b/templates/test/core/end2end/end2end_tests.cc.template
index e6a49f2795..e6a49f2795 100644
--- a/templates/test/core/end2end/end2end_tests.c.template
+++ b/templates/test/core/end2end/end2end_tests.cc.template
diff --git a/templates/test/core/surface/public_headers_must_be_c89.c.template b/templates/test/core/surface/public_headers_must_be_c89.c.template
index dcaa59bb30..6e4a83666e 100644
--- a/templates/test/core/surface/public_headers_must_be_c89.c.template
+++ b/templates/test/core/surface/public_headers_must_be_c89.c.template
@@ -35,9 +35,21 @@
assert(hdr[0:len(pfx)] == pfx)
hdrs.add(hdr[len(pfx):])
hdrs = sorted(list(hdrs))
+ fns = list()
+ for api in c_apis:
+ if is_platform_header(api.header):
+ continue
+ fns.append(api.name)
%>\
% for hdr in hdrs:
#include <${hdr}>
% endfor
- int main(int argc, char **argv) { return 0; }
+ #include <stdio.h>
+
+ int main(int argc, char **argv) {
+ % for fn in fns:
+ printf("%lx", (unsigned long) ${fn});
+ % endfor
+ return 0;
+ }
diff --git a/templates/test/cpp/naming/create_private_dns_zone.sh.template b/templates/test/cpp/naming/create_private_dns_zone.sh.template
new file mode 100644
index 0000000000..14324b098c
--- /dev/null
+++ b/templates/test/cpp/naming/create_private_dns_zone.sh.template
@@ -0,0 +1,4 @@
+%YAML 1.2
+--- |
+ <%namespace file="create_private_dns_zone_defs.include" import="*"/>\
+ ${create_private_dns_zone(resolver_gce_integration_tests_zone_id, resolver_tests_common_zone_name)}
diff --git a/templates/test/cpp/naming/create_private_dns_zone_defs.include b/templates/test/cpp/naming/create_private_dns_zone_defs.include
new file mode 100644
index 0000000000..465dd6394b
--- /dev/null
+++ b/templates/test/cpp/naming/create_private_dns_zone_defs.include
@@ -0,0 +1,32 @@
+<%def name="create_private_dns_zone(resolver_gce_integration_tests_zone_id, resolver_tests_common_zone_name)">#!/bin/bash
+# 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.
+
+# This file is auto-generated
+
+set -ex
+
+cd $(dirname $0)/../../..
+
+gcloud alpha dns managed-zones create \\
+
+ ${resolver_gce_integration_tests_zone_id} \\
+
+ --dns-name=${resolver_tests_common_zone_name} \\
+
+ --description="GCE-DNS-private-zone-for-GRPC-testing" \\
+
+ --visibility=private \\
+
+ --networks=default</%def>
diff --git a/templates/test/cpp/naming/private_dns_zone_init.sh.template b/templates/test/cpp/naming/private_dns_zone_init.sh.template
new file mode 100644
index 0000000000..d5ffd04add
--- /dev/null
+++ b/templates/test/cpp/naming/private_dns_zone_init.sh.template
@@ -0,0 +1,4 @@
+%YAML 1.2
+--- |
+ <%namespace file="private_dns_zone_init_defs.include" import="*"/>\
+ ${private_dns_zone_init(all_integration_test_records, resolver_gce_integration_tests_zone_id, resolver_tests_common_zone_name)}
diff --git a/templates/test/cpp/naming/private_dns_zone_init_defs.include b/templates/test/cpp/naming/private_dns_zone_init_defs.include
new file mode 100644
index 0000000000..06bc8adb94
--- /dev/null
+++ b/templates/test/cpp/naming/private_dns_zone_init_defs.include
@@ -0,0 +1,40 @@
+<%def name="private_dns_zone_init(records,resolver_gce_integration_tests_zone_id,resolver_tests_common_zone_name)">#!/bin/bash
+# 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.
+
+# This file is auto-generated
+
+set -ex
+
+cd $(dirname $0)/../../..
+
+gcloud dns record-sets transaction start -z=${resolver_gce_integration_tests_zone_id}
+
+% for r in records:
+gcloud dns record-sets transaction add \\
+
+ -z=${resolver_gce_integration_tests_zone_id} \\
+
+ --name=${r['name']}.${resolver_tests_common_zone_name} \\
+
+ --type=${r['type']} \\
+
+ --ttl=${r['ttl']} \\
+
+ ${r['data']}
+
+% endfor
+gcloud dns record-sets transaction describe -z=${resolver_gce_integration_tests_zone_id}
+gcloud dns record-sets transaction execute -z=${resolver_gce_integration_tests_zone_id}
+gcloud dns record-sets list -z=${resolver_gce_integration_tests_zone_id}</%def>
diff --git a/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include b/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include
new file mode 100644
index 0000000000..2413ec57d0
--- /dev/null
+++ b/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include
@@ -0,0 +1,64 @@
+<%def name="resolver_gce_integration_tests(tests, records, resolver_tests_common_zone_name)">#!/bin/bash
+# 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.
+
+# This file is auto-generated
+
+set -ex
+
+if [[ "$GRPC_DNS_RESOLVER" == "" ]]; then
+ export GRPC_DNS_RESOLVER=ares
+elif [[ "$GRPC_DNS_RESOLVER" != ares ]]; then
+ echo "Unexpected: GRPC_DNS_RESOLVER=$GRPC_DNS_RESOLVER. This test only works with c-ares resolver"
+ exit 1
+fi
+
+cd $(dirname $0)/../../..
+
+if [[ "$CONFIG" == "" ]]; then
+ export CONFIG=opt
+fi
+make resolver_component_test
+echo "Sanity check DNS records are resolveable with dig:"
+EXIT_CODE=0
+
+% for r in records:
+ONE_FAILED=0
+dig ${r['type']} ${r['name']}.${resolver_tests_common_zone_name} | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig ${r['type']} ${r['name']}.${resolver_tests_common_zone_name} FAILED"
+ exit 1
+fi
+
+% endfor
+echo "Sanity check PASSED. Run resolver tests:"
+
+% for test in tests:
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \\
+
+ --target_name='${test['target_name']}' \\
+
+ --expected_addrs='${test['expected_addrs']}' \\
+
+ --expected_chosen_service_config='${test['expected_chosen_service_config']}' \\
+
+ --expected_lb_policy='${test['expected_lb_policy']}' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: ${test['target_name']} FAILED"
+ EXIT_CODE=1
+fi
+
+% endfor
+exit $EXIT_CODE</%def>
diff --git a/templates/test/cpp/naming/resolver_gce_integration_tests_runner.sh.template b/templates/test/cpp/naming/resolver_gce_integration_tests_runner.sh.template
new file mode 100644
index 0000000000..c728784d29
--- /dev/null
+++ b/templates/test/cpp/naming/resolver_gce_integration_tests_runner.sh.template
@@ -0,0 +1,4 @@
+%YAML 1.2
+--- |
+ <%namespace file="resolver_gce_integration_tests_defs.include" import="*"/>\
+ ${resolver_gce_integration_tests(resolver_gce_integration_test_cases, all_integration_test_records, resolver_tests_common_zone_name)}
diff --git a/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template b/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template
index aacb3ecc8f..e25791dd0e 100644
--- a/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template
+++ b/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template
@@ -16,4 +16,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!!
- VERSION='${settings.python_version.pep440()}'
+ VERSION = '${settings.python_version.pep440()}'
diff --git a/templates/tools/dockerfile/clang5.include b/templates/tools/dockerfile/clang5.include
new file mode 100644
index 0000000000..11ff442787
--- /dev/null
+++ b/templates/tools/dockerfile/clang5.include
@@ -0,0 +1,7 @@
+RUN apt-get update && apt-get -y install wget xz-utils
+RUN wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN tar xf clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-format /usr/local/bin/clang-format
+ENV CLANG_FORMAT=clang-format
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-tidy /usr/local/bin/clang-tidy
+ENV CLANG_TIDY=clang-tidy
diff --git a/templates/tools/dockerfile/clang_format.include b/templates/tools/dockerfile/clang_format.include
deleted file mode 100644
index 81bd2be797..0000000000
--- a/templates/tools/dockerfile/clang_format.include
+++ /dev/null
@@ -1,5 +0,0 @@
-RUN apt-get update && apt-get -y install wget
-RUN echo "deb http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main" >> /etc/apt/sources.list
-RUN echo "deb-src http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main" >> /etc/apt/sources.list
-RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add -
-RUN apt-get update && apt-get -y install clang-format-3.8
diff --git a/templates/tools/dockerfile/csharp_build_interop.sh.include b/templates/tools/dockerfile/csharp_build_interop.sh.include
new file mode 100755
index 0000000000..d36e81c8a9
--- /dev/null
+++ b/templates/tools/dockerfile/csharp_build_interop.sh.include
@@ -0,0 +1,32 @@
+#!/bin/bash
+# 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.
+#
+# Builds C# interop server and client in a base image.
+set -e
+
+mkdir -p /var/local/git
+git clone /var/local/jenkins/grpc /var/local/git/grpc
+# clone gRPC submodules, use data from locally cloned submodules where possible
+(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc ${'\\'}
+&& git submodule update --init --reference /var/local/jenkins/grpc/<%text>${name}</%text> ${'\\'}
+<%text>${name}</%text>')
+
+# copy service account keys if available
+cp -r /var/local/jenkins/service_account $HOME || true
+
+cd /var/local/git/grpc
+
+# build C# interop client & server
+tools/run_tests/run_tests.py -l csharp -c dbg --build_only
diff --git a/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template b/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template
index 1ab667c95d..4f24a025c6 100644
--- a/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template
+++ b/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template
@@ -16,8 +16,8 @@
FROM debian:jessie
- <%include file="../clang_format.include"/>
+ <%include file="../clang5.include"/>
ADD clang_format_all_the_things.sh /
CMD ["echo 'Run with tools/distrib/clang_format_code.sh'"]
- \ No newline at end of file
+
diff --git a/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template b/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template
new file mode 100644
index 0000000000..f5bceaa5f3
--- /dev/null
+++ b/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template
@@ -0,0 +1,24 @@
+%YAML 1.2
+--- |
+ # Copyright 2015 gRPC authors.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+
+ FROM debian:jessie
+
+ <%include file="../clang5.include"/>
+ <%include file="../python_deps.include"/>
+ ADD clang_tidy_all_the_things.sh /
+ CMD ["echo 'Run with tools/distrib/clang_tidy_code.sh'"]
+
+
diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_csharp/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_csharp/build_interop.sh.template
new file mode 100644
index 0000000000..71aae5b9f9
--- /dev/null
+++ b/templates/tools/dockerfile/interoptest/grpc_interop_csharp/build_interop.sh.template
@@ -0,0 +1,3 @@
+%YAML 1.2
+--- |
+ <%include file="../../csharp_build_interop.sh.include"/> \ No newline at end of file
diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile.template
new file mode 100644
index 0000000000..a1f1283de0
--- /dev/null
+++ b/templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile.template
@@ -0,0 +1,26 @@
+%YAML 1.2
+--- |
+ # Copyright 2015 gRPC authors.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+
+ FROM debian:jessie
+
+ <%include file="../../apt_get_basic.include"/>
+ <%include file="../../python_deps.include"/>
+ <%include file="../../csharp_deps.include"/>
+ <%include file="../../csharp_dotnetcli_deps.include"/>
+ <%include file="../../run_tests_addons.include"/>
+ # Define the default command.
+ CMD ["bash"]
+
diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh.template
new file mode 100644
index 0000000000..71aae5b9f9
--- /dev/null
+++ b/templates/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh.template
@@ -0,0 +1,3 @@
+%YAML 1.2
+--- |
+ <%include file="../../csharp_build_interop.sh.include"/> \ No newline at end of file
diff --git a/templates/tools/dockerfile/python_deps.include b/templates/tools/dockerfile/python_deps.include
index 94b854ad21..cd1af22b43 100644
--- a/templates/tools/dockerfile/python_deps.include
+++ b/templates/tools/dockerfile/python_deps.include
@@ -9,6 +9,6 @@ RUN apt-get update && apt-get install -y ${'\\'}
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
diff --git a/templates/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile.template b/templates/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile.template
new file mode 100644
index 0000000000..d5055cfc8e
--- /dev/null
+++ b/templates/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile.template
@@ -0,0 +1,26 @@
+%YAML 1.2
+--- |
+ # Copyright 2015 gRPC authors.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+
+ FROM ubuntu:17.10
+
+ <%include file="../../apt_get_basic.include"/>
+ <%include file="../../gcp_api_libraries.include"/>
+ <%include file="../../python_deps.include"/>
+ <%include file="../../cxx_deps.include"/>
+ <%include file="../../run_tests_addons.include"/>
+
+ # Define the default command.
+ CMD ["bash"]
diff --git a/templates/tools/dockerfile/test/multilang_jessie_x64/Dockerfile.template b/templates/tools/dockerfile/test/multilang_jessie_x64/Dockerfile.template
index 6cad474a20..0d47aa91f3 100644
--- a/templates/tools/dockerfile/test/multilang_jessie_x64/Dockerfile.template
+++ b/templates/tools/dockerfile/test/multilang_jessie_x64/Dockerfile.template
@@ -19,6 +19,7 @@
<%include file="../../apt_get_basic.include"/>
<%include file="../../gcp_api_libraries.include"/>
<%include file="../../csharp_deps.include"/>
+ <%include file="../../csharp_dotnetcli_deps.include"/>
<%include file="../../cxx_deps.include"/>
<%include file="../../node_deps.include"/>
<%include file="../../php_deps.include"/>
diff --git a/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template b/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template
index aa34a694fb..af85a54235 100644
--- a/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template
+++ b/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template
@@ -32,5 +32,8 @@
<%include file="../../python_deps.include"/>
<%include file="../../node_deps.include"/>
<%include file="../../run_tests_addons.include"/>
+ # Install Mako to generate files in grpc/grpc-node
+ RUN pip install Mako
+
# Define the default command.
CMD ["bash"]
diff --git a/templates/tools/dockerfile/test/sanity/Dockerfile.template b/templates/tools/dockerfile/test/sanity/Dockerfile.template
index bf34c0ab0f..7453e6c460 100644
--- a/templates/tools/dockerfile/test/sanity/Dockerfile.template
+++ b/templates/tools/dockerfile/test/sanity/Dockerfile.template
@@ -19,6 +19,7 @@
<%include file="../../apt_get_basic.include"/>
<%include file="../../gcp_api_libraries.include"/>
<%include file="../../python_deps.include"/>
+ <%include file="../../cxx_deps.include"/>
#========================
# Sanity test dependencies
RUN apt-get update && apt-get install -y ${"\\"}
@@ -28,7 +29,8 @@
libtool ${"\\"}
curl ${"\\"}
python-virtualenv ${"\\"}
- python-lxml
+ python-lxml ${"\\"}
+ shellcheck
RUN pip install simplejson mako
#======================================
@@ -51,7 +53,7 @@
RUN chmod +x ./bazel-0.4.4-installer-linux-x86_64.sh
RUN ./bazel-0.4.4-installer-linux-x86_64.sh
- <%include file="../../clang_format.include"/>
+ <%include file="../../clang5.include"/>
<%include file="../../run_tests_addons.include"/>
# Define the default command.
diff --git a/templates/tools/run_tests/generated/tests.json.template b/templates/tools/run_tests/generated/tests.json.template
index 10ab2e445a..c5dc26faa7 100644
--- a/templates/tools/run_tests/generated/tests.json.template
+++ b/templates/tools/run_tests/generated/tests.json.template
@@ -9,11 +9,13 @@
"platforms": tgt.platforms,
"ci_platforms": tgt.ci_platforms,
"gtest": tgt.gtest,
+ "benchmark": tgt.get("benchmark", False),
"exclude_configs": tgt.get("exclude_configs", []),
"exclude_iomgrs": tgt.get("exclude_iomgrs", []),
"args": tgt.get("args", []),
"flaky": tgt.flaky,
- "cpu_cost": tgt.get("cpu_cost", 1.0)}
+ "cpu_cost": tgt.get("cpu_cost", 1.0),
+ "uses_polling": tgt.get("uses_polling", True)}
timeout_seconds = tgt.get("timeout_seconds", None)
if timeout_seconds:
out['timeout_seconds'] = timeout_seconds
diff --git a/tools/run_tests/helper_scripts/build_node_electron.sh b/test/core/backoff/BUILD
index 424da2c6e3..6fbd6542d4 100755..100644
--- a/tools/run_tests/helper_scripts/build_node_electron.sh
+++ b/test/core/backoff/BUILD
@@ -1,5 +1,3 @@
-#!/bin/bash
-
# Copyright 2016 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,19 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ELECTRON_VERSION=$1
-source ~/.nvm/nvm.sh
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")
-nvm use 8
-set -ex
+licenses(["notice"]) # Apache v2
-# change to grpc repo root
-cd $(dirname $0)/../..
+package(
+ features = [
+ "-layering_check",
+ "-parse_headers",
+ ],
+)
-export npm_config_target=$ELECTRON_VERSION
-export npm_config_disturl=https://atom.io/download/atom-shell
-export npm_config_runtime=electron
-export npm_config_build_from_source=true
-mkdir -p ~/.electron-gyp
-HOME=~/.electron-gyp npm update --prefer-online
-HOME=~/.electron-gyp npm install --unsafe-perm
+grpc_cc_test(
+ name = "backoff_test",
+ srcs = ["backoff_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc
new file mode 100644
index 0000000000..2e61243831
--- /dev/null
+++ b/test/core/backoff/backoff_test.cc
@@ -0,0 +1,176 @@
+/*
+ *
+ * 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 "src/core/lib/backoff/backoff.h"
+
+#include <algorithm>
+
+#include <grpc/support/log.h>
+#include <grpc/support/useful.h>
+
+#include <gtest/gtest.h>
+#include "test/core/util/test_config.h"
+
+namespace grpc {
+namespace testing {
+namespace {
+
+using grpc_core::BackOff;
+
+TEST(BackOffTest, ConstantBackOff) {
+ const grpc_millis initial_backoff = 200;
+ const double multiplier = 1.0;
+ const double jitter = 0.0;
+ const grpc_millis max_backoff = 1000;
+ grpc_core::ExecCtx exec_ctx;
+ BackOff::Options options;
+ options.set_initial_backoff(initial_backoff)
+ .set_multiplier(multiplier)
+ .set_jitter(jitter)
+ .set_max_backoff(max_backoff);
+ BackOff backoff(options);
+
+ grpc_millis next_attempt_start_time = backoff.NextAttemptTime();
+ EXPECT_EQ(next_attempt_start_time - grpc_core::ExecCtx::Get()->Now(),
+ initial_backoff);
+ for (int i = 0; i < 10000; i++) {
+ next_attempt_start_time = backoff.NextAttemptTime();
+ EXPECT_EQ(next_attempt_start_time - grpc_core::ExecCtx::Get()->Now(),
+ initial_backoff);
+ }
+}
+
+TEST(BackOffTest, MinConnect) {
+ const grpc_millis initial_backoff = 100;
+ const double multiplier = 1.0;
+ const double jitter = 0.0;
+ const grpc_millis max_backoff = 1000;
+ grpc_core::ExecCtx exec_ctx;
+ BackOff::Options options;
+ options.set_initial_backoff(initial_backoff)
+ .set_multiplier(multiplier)
+ .set_jitter(jitter)
+ .set_max_backoff(max_backoff);
+ BackOff backoff(options);
+ grpc_millis next = backoff.NextAttemptTime();
+ EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);
+}
+
+TEST(BackOffTest, NoJitterBackOff) {
+ const grpc_millis initial_backoff = 2;
+ const double multiplier = 2.0;
+ const double jitter = 0.0;
+ const grpc_millis max_backoff = 513;
+ BackOff::Options options;
+ options.set_initial_backoff(initial_backoff)
+ .set_multiplier(multiplier)
+ .set_jitter(jitter)
+ .set_max_backoff(max_backoff);
+ BackOff backoff(options);
+ // x_1 = 2
+ // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
+ grpc_core::ExecCtx exec_ctx;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(0);
+ grpc_millis next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 2);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 6);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 14);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 30);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 62);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 126);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 254);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 510);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 1022);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ // Hit the maximum timeout. From this point onwards, retries will increase
+ // only by max timeout.
+ EXPECT_EQ(next, 1535);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 2048);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
+ next = backoff.NextAttemptTime();
+ EXPECT_EQ(next, 2561);
+}
+
+TEST(BackOffTest, JitterBackOff) {
+ const grpc_millis initial_backoff = 500;
+ grpc_millis current_backoff = initial_backoff;
+ const grpc_millis max_backoff = 1000;
+ const double multiplier = 1.0;
+ const double jitter = 0.1;
+ BackOff::Options options;
+ options.set_initial_backoff(initial_backoff)
+ .set_multiplier(multiplier)
+ .set_jitter(jitter)
+ .set_max_backoff(max_backoff);
+ BackOff backoff(options);
+
+ backoff.SetRandomSeed(0); // force consistent PRNG
+
+ grpc_core::ExecCtx exec_ctx;
+ grpc_millis next = backoff.NextAttemptTime();
+ EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);
+
+ grpc_millis expected_next_lower_bound =
+ (grpc_millis)((double)current_backoff * (1 - jitter));
+ grpc_millis expected_next_upper_bound =
+ (grpc_millis)((double)current_backoff * (1 + jitter));
+
+ for (int i = 0; i < 10000; i++) {
+ next = backoff.NextAttemptTime();
+ // next-now must be within (jitter*100)% of the current backoff (which
+ // increases by * multiplier up to max_backoff).
+ const grpc_millis timeout_millis = next - grpc_core::ExecCtx::Get()->Now();
+ EXPECT_GE(timeout_millis, expected_next_lower_bound);
+ EXPECT_LE(timeout_millis, expected_next_upper_bound);
+ current_backoff = std::min(
+ (grpc_millis)((double)current_backoff * multiplier), max_backoff);
+ expected_next_lower_bound =
+ (grpc_millis)((double)current_backoff * (1 - jitter));
+ expected_next_upper_bound =
+ (grpc_millis)((double)current_backoff * (1 + jitter));
+ }
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.cc
index 383d1240cb..dd8d88170e 100644
--- a/test/core/bad_client/bad_client.c
+++ b/test/core/bad_client/bad_client.cc
@@ -28,102 +28,105 @@
#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_stack.h"
+#include "src/core/lib/gpr/murmur_hash.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/murmur_hash.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
typedef struct {
- grpc_server *server;
- grpc_completion_queue *cq;
+ grpc_server* server;
+ grpc_completion_queue* cq;
grpc_bad_client_server_side_validator validator;
- void *registered_method;
+ void* registered_method;
gpr_event done_thd;
gpr_event done_write;
} thd_args;
-static void thd_func(void *arg) {
- thd_args *a = (thd_args *)arg;
+static void thd_func(void* arg) {
+ thd_args* a = (thd_args*)arg;
a->validator(a->server, a->cq, a->registered_method);
- gpr_event_set(&a->done_thd, (void *)1);
+ gpr_event_set(&a->done_thd, (void*)1);
}
-static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- thd_args *a = (thd_args *)arg;
- gpr_event_set(&a->done_write, (void *)1);
+static void done_write(void* arg, grpc_error* error) {
+ thd_args* a = (thd_args*)arg;
+ gpr_event_set(&a->done_write, (void*)1);
}
-static void server_setup_transport(void *ts, grpc_transport *transport) {
- thd_args *a = (thd_args *)ts;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_server_setup_transport(&exec_ctx, a->server, transport, NULL,
+static void server_setup_transport(void* ts, grpc_transport* transport) {
+ thd_args* a = (thd_args*)ts;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_server_setup_transport(a->server, transport, nullptr,
grpc_server_get_channel_args(a->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void read_done(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- gpr_event *read_done = (gpr_event *)arg;
- gpr_event_set(read_done, (void *)1);
+static void read_done(void* arg, grpc_error* error) {
+ gpr_event* read_done = (gpr_event*)arg;
+ gpr_event_set(read_done, (void*)1);
}
void grpc_run_bad_client_test(
grpc_bad_client_server_side_validator server_validator,
grpc_bad_client_client_stream_validator client_validator,
- const char *client_payload, size_t client_payload_length, uint32_t flags) {
+ const char* client_payload, size_t client_payload_length, uint32_t flags) {
grpc_endpoint_pair sfd;
thd_args a;
gpr_thd_id id;
- char *hex;
- grpc_transport *transport;
+ char* hex;
+ grpc_transport* transport;
grpc_slice slice =
grpc_slice_from_copied_buffer(client_payload, client_payload_length);
grpc_slice_buffer outgoing;
grpc_closure done_write_closure;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_completion_queue *shutdown_cq;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_completion_queue* shutdown_cq;
- hex = gpr_dump(client_payload, client_payload_length,
- GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ if (client_payload_length < 4 * 1024) {
+ hex = gpr_dump(client_payload, client_payload_length,
+ GPR_DUMP_HEX | GPR_DUMP_ASCII);
- /* Add a debug log */
- gpr_log(GPR_INFO, "TEST: %s", hex);
+ /* Add a debug log */
+ gpr_log(GPR_INFO, "TEST: %s", hex);
- gpr_free(hex);
+ gpr_free(hex);
+ } else {
+ gpr_log(GPR_INFO, "TEST: (%" PRIdPTR " byte long string)",
+ client_payload_length);
+ }
/* Init grpc */
grpc_init();
/* Create endpoints */
- sfd = grpc_iomgr_create_endpoint_pair("fixture", NULL);
+ sfd = grpc_iomgr_create_endpoint_pair("fixture", nullptr);
/* Create server, completion events */
- a.server = grpc_server_create(NULL, NULL);
- a.cq = grpc_completion_queue_create_for_next(NULL);
+ a.server = grpc_server_create(nullptr, nullptr);
+ a.cq = grpc_completion_queue_create_for_next(nullptr);
gpr_event_init(&a.done_thd);
gpr_event_init(&a.done_write);
a.validator = server_validator;
- grpc_server_register_completion_queue(a.server, a.cq, NULL);
+ grpc_server_register_completion_queue(a.server, a.cq, nullptr);
a.registered_method =
grpc_server_register_method(a.server, GRPC_BAD_CLIENT_REGISTERED_METHOD,
GRPC_BAD_CLIENT_REGISTERED_HOST,
GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0);
grpc_server_start(a.server);
- transport = grpc_create_chttp2_transport(&exec_ctx, NULL, sfd.server, 0);
+ transport = grpc_create_chttp2_transport(nullptr, sfd.server, false);
server_setup_transport(&a, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
/* Bind everything into the same pollset */
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd.client, grpc_cq_pollset(a.cq));
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd.server, grpc_cq_pollset(a.cq));
+ grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq));
+ grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq));
/* Check a ground truth */
GPR_ASSERT(grpc_server_has_open_connections(a.server));
/* Start validator */
- gpr_thd_new(&id, thd_func, &a, NULL);
+ gpr_thd_new(&id, "grpc_bad_client", thd_func, &a, nullptr);
grpc_slice_buffer_init(&outgoing);
grpc_slice_buffer_add(&outgoing, slice);
@@ -131,27 +134,29 @@ void grpc_run_bad_client_test(
grpc_schedule_on_exec_ctx);
/* Write data */
- grpc_endpoint_write(&exec_ctx, sfd.client, &outgoing, &done_write_closure);
- grpc_exec_ctx_finish(&exec_ctx);
-
- /* Await completion */
- GPR_ASSERT(
- gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(5)));
+ grpc_endpoint_write(sfd.client, &outgoing, &done_write_closure);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ /* Await completion, unless the request is large and write may not finish
+ * before the peer shuts down. */
+ if (!(flags & GRPC_BAD_CLIENT_LARGE_REQUEST)) {
+ GPR_ASSERT(
+ gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(5)));
+ }
if (flags & GRPC_BAD_CLIENT_DISCONNECT) {
grpc_endpoint_shutdown(
- &exec_ctx, sfd.client,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
- grpc_endpoint_destroy(&exec_ctx, sfd.client);
- grpc_exec_ctx_finish(&exec_ctx);
- sfd.client = NULL;
+ sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
+ grpc_endpoint_destroy(sfd.client);
+ grpc_core::ExecCtx::Get()->Flush();
+ sfd.client = nullptr;
}
GPR_ASSERT(gpr_event_wait(&a.done_thd, grpc_timeout_seconds_to_deadline(5)));
- if (sfd.client != NULL) {
+ if (sfd.client != nullptr) {
// Validate client stream, if requested.
- if (client_validator != NULL) {
+ if (client_validator != nullptr) {
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
grpc_slice_buffer incoming;
grpc_slice_buffer_init(&incoming);
@@ -162,40 +167,41 @@ void grpc_run_bad_client_test(
grpc_closure read_done_closure;
GRPC_CLOSURE_INIT(&read_done_closure, read_done, &read_done_event,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, sfd.client, &incoming,
- &read_done_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_read(sfd.client, &incoming, &read_done_closure);
+ grpc_core::ExecCtx::Get()->Flush();
do {
GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0);
- GPR_ASSERT(grpc_completion_queue_next(
- a.cq, grpc_timeout_milliseconds_to_deadline(100), NULL)
- .type == GRPC_QUEUE_TIMEOUT);
+ GPR_ASSERT(
+ grpc_completion_queue_next(
+ a.cq, grpc_timeout_milliseconds_to_deadline(100), nullptr)
+ .type == GRPC_QUEUE_TIMEOUT);
} while (!gpr_event_get(&read_done_event));
if (client_validator(&incoming)) break;
gpr_log(GPR_INFO,
"client validator failed; trying additional read "
"in case we didn't get all the data");
}
- grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
+ grpc_slice_buffer_destroy_internal(&incoming);
}
// Shutdown.
grpc_endpoint_shutdown(
- &exec_ctx, sfd.client,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- grpc_endpoint_destroy(&exec_ctx, sfd.client);
- grpc_exec_ctx_finish(&exec_ctx);
+ sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ grpc_endpoint_destroy(sfd.client);
+ grpc_core::ExecCtx::Get()->Flush();
}
- shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
- grpc_server_shutdown_and_notify(a.server, shutdown_cq, NULL);
- GPR_ASSERT(grpc_completion_queue_pluck(
- shutdown_cq, NULL, grpc_timeout_seconds_to_deadline(1), NULL)
+ GPR_ASSERT(
+ gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(1)));
+ shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
+ grpc_server_shutdown_and_notify(a.server, shutdown_cq, nullptr);
+ GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, nullptr,
+ grpc_timeout_seconds_to_deadline(1),
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_server_destroy(a.server);
grpc_completion_queue_destroy(a.cq);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
+ grpc_slice_buffer_destroy_internal(&outgoing);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h
index 22f1a3abc7..d3abfac2aa 100644
--- a/test/core/bad_client/bad_client.h
+++ b/test/core/bad_client/bad_client.h
@@ -28,15 +28,16 @@
#define GRPC_BAD_CLIENT_REGISTERED_METHOD "/registered/bar"
#define GRPC_BAD_CLIENT_REGISTERED_HOST "localhost"
-typedef void (*grpc_bad_client_server_side_validator)(grpc_server *server,
- grpc_completion_queue *cq,
- void *registered_method);
+typedef void (*grpc_bad_client_server_side_validator)(grpc_server* server,
+ grpc_completion_queue* cq,
+ void* registered_method);
// Returns false if we need to read more data.
typedef bool (*grpc_bad_client_client_stream_validator)(
- grpc_slice_buffer *incoming);
+ grpc_slice_buffer* incoming);
#define GRPC_BAD_CLIENT_DISCONNECT 1
+#define GRPC_BAD_CLIENT_LARGE_REQUEST 2
/* Test runner.
@@ -46,7 +47,7 @@ typedef bool (*grpc_bad_client_client_stream_validator)(
void grpc_run_bad_client_test(
grpc_bad_client_server_side_validator server_validator,
grpc_bad_client_client_stream_validator client_validator,
- const char *client_payload, size_t client_payload_length, uint32_t flags);
+ const char* client_payload, size_t client_payload_length, uint32_t flags);
#define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, \
flags) \
diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py
index dbd52777e1..14c8a27334 100755
--- a/test/core/bad_client/gen_build_yaml.py
+++ b/test/core/bad_client/gen_build_yaml.py
@@ -30,7 +30,7 @@ BAD_CLIENT_TESTS = {
'headers': default_test_options._replace(cpu_cost=0.2),
'initial_settings_frame': default_test_options._replace(cpu_cost=0.2),
'head_of_line_blocking': default_test_options,
- 'large_metadata': default_test_options,
+ # 'large_metadata': default_test_options, #disabling as per issue #11745
'server_registered_method': default_test_options,
'simple_request': default_test_options,
'window_overflow': default_test_options,
@@ -46,7 +46,7 @@ def main():
'build': 'private',
'language': 'c',
'src': [
- 'test/core/bad_client/bad_client.c'
+ 'test/core/bad_client/bad_client.cc'
],
'headers': [
'test/core/bad_client/bad_client.h'
@@ -66,7 +66,7 @@ def main():
'build': 'test',
'language': 'c',
'secure': 'no',
- 'src': ['test/core/bad_client/tests/%s.c' % t],
+ 'src': ['test/core/bad_client/tests/%s.cc' % t],
'vs_proj_dir': 'test',
'exclude_iomgrs': ['uv'],
'deps': [
diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl
index 1aeb81c00d..022edf3ff3 100755
--- a/test/core/bad_client/generate_tests.bzl
+++ b/test/core/bad_client/generate_tests.bzl
@@ -28,7 +28,7 @@ BAD_CLIENT_TESTS = {
'headers': test_options(),
'initial_settings_frame': test_options(),
'head_of_line_blocking': test_options(),
- 'large_metadata': test_options(),
+ # 'large_metadata': test_options(), # disabling as per issue #11745
'server_registered_method': test_options(),
'simple_request': test_options(),
'window_overflow': test_options(),
@@ -38,16 +38,14 @@ BAD_CLIENT_TESTS = {
def grpc_bad_client_tests():
native.cc_library(
name = 'bad_client_test',
- srcs = ['bad_client.c'],
+ srcs = ['bad_client.cc'],
hdrs = ['bad_client.h'],
- copts = ['-std=c99'],
deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier']
)
for t, topt in BAD_CLIENT_TESTS.items():
native.cc_test(
name = '%s_bad_client_test' % t,
- srcs = ['tests/%s.c' % t],
+ srcs = ['tests/%s.cc' % t],
deps = [':bad_client_test'],
- copts = ['-std=c99'],
)
diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.cc
index 7d9a103e43..eeaf4c9974 100644
--- a/test/core/bad_client/tests/badreq.c
+++ b/test/core/bad_client/tests/badreq.cc
@@ -20,6 +20,8 @@
#include <string.h>
+#include <grpc/grpc.h>
+
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
@@ -27,21 +29,23 @@
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \
"\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
/* invalid content type */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL, PFX_STR
+ verifier, nullptr,
+ PFX_STR
"\x00\x00\xc2\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
"\x10\x07:scheme\x04http"
@@ -56,7 +60,8 @@ int main(int argc, char **argv) {
/* invalid te */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL, PFX_STR
+ verifier, nullptr,
+ PFX_STR
"\x00\x00\xcb\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
"\x10\x07:scheme\x04http"
@@ -73,7 +78,8 @@ int main(int argc, char **argv) {
/* two path headers */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL, PFX_STR
+ verifier, nullptr,
+ PFX_STR
"\x00\x00\xd9\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
"\x10\x05:path\x08/foo/bah"
@@ -90,7 +96,8 @@ int main(int argc, char **argv) {
/* bad accept-encoding algorithm */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL, PFX_STR
+ verifier, nullptr,
+ PFX_STR
"\x00\x00\xd2\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
"\x10\x07:scheme\x04http"
@@ -106,7 +113,8 @@ int main(int argc, char **argv) {
/* bad grpc-encoding algorithm */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL, PFX_STR
+ verifier, nullptr,
+ PFX_STR
"\x00\x00\xf5\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
"\x10\x07:scheme\x04http"
@@ -121,5 +129,6 @@ int main(int argc, char **argv) {
"\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)",
GRPC_BAD_CLIENT_DISCONNECT);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/connection_prefix.c b/test/core/bad_client/tests/connection_prefix.c
deleted file mode 100644
index 6cc4b72314..0000000000
--- a/test/core/bad_client/tests/connection_prefix.c
+++ /dev/null
@@ -1,60 +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/surface/server.h"
-#include "test/core/bad_client/bad_client.h"
-
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
- while (grpc_server_has_open_connections(server)) {
- GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
- .type == GRPC_QUEUE_TIMEOUT);
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
-
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRIX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI *X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTPX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0X", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\rX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\nX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\rX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\r\nX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\r\nSX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\r\nSMX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\r\nSM\rX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\r\nSM\r\nX", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "PRI * HTTP/2.0\r\n\r\nSM\r\n\rX",
- 0);
- return 0;
-}
diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc
new file mode 100644
index 0000000000..4aab234d3e
--- /dev/null
+++ b/test/core/bad_client/tests/connection_prefix.cc
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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/surface/server.h"
+#include "test/core/bad_client/bad_client.h"
+
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
+ while (grpc_server_has_open_connections(server)) {
+ GPR_ASSERT(grpc_completion_queue_next(
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
+ .type == GRPC_QUEUE_TIMEOUT);
+ }
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRIX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI *X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTPX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0X", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\rX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\nX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\rX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nSX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nSMX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nSM\rX", 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nSM\r\nX",
+ 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, "PRI * HTTP/2.0\r\n\r\nSM\r\n\rX",
+ 0);
+
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/bad_client/tests/head_of_line_blocking.c b/test/core/bad_client/tests/head_of_line_blocking.cc
index 04485d501f..f56c4d71dd 100644
--- a/test/core/bad_client/tests/head_of_line_blocking.c
+++ b/test/core/bad_client/tests/head_of_line_blocking.cc
@@ -20,6 +20,7 @@
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/surface/server.h"
@@ -65,16 +66,16 @@ static const char prefix[] =
"\x01\x00\x00\x27\x10"
"";
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
grpc_call_error error;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(cq);
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(cq);
grpc_metadata_array request_metadata_recv;
gpr_timespec deadline;
- grpc_byte_buffer *payload = NULL;
+ grpc_byte_buffer* payload = nullptr;
grpc_metadata_array_init(&request_metadata_recv);
@@ -85,7 +86,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq,
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
- GPR_ASSERT(payload != NULL);
+ GPR_ASSERT(payload != nullptr);
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_unref(s);
@@ -93,22 +94,23 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq,
cq_verifier_destroy(cqv);
}
-char *g_buffer;
+char* g_buffer;
size_t g_cap = 0;
size_t g_count = 0;
-static void addbuf(const void *data, size_t len) {
+static void addbuf(const void* data, size_t len) {
if (g_count + len > g_cap) {
g_cap = GPR_MAX(g_count + len, g_cap * 2);
- g_buffer = gpr_realloc(g_buffer, g_cap);
+ g_buffer = static_cast<char*>(gpr_realloc(g_buffer, g_cap));
}
memcpy(g_buffer + g_count, data, len);
g_count += len;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int i;
grpc_test_init(argc, argv);
+ grpc_init();
#define NUM_FRAMES 10
#define FRAME_SIZE 1000
@@ -129,8 +131,9 @@ int main(int argc, char **argv) {
addbuf(hdr, sizeof(hdr));
addbuf(msg, FRAME_SIZE);
}
- grpc_run_bad_client_test(verifier, NULL, g_buffer, g_count, 0);
+ grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count, 0);
gpr_free(g_buffer);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/headers.c b/test/core/bad_client/tests/headers.cc
index c704dbbcb6..2aa1b280ce 100644
--- a/test/core/bad_client/tests/headers.c
+++ b/test/core/bad_client/tests/headers.cc
@@ -23,264 +23,311 @@
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \
"\x00\x00\x00\x04\x00\x00\x00\x00\x00"
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
/* partial http2 header prefixes */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x01",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x01\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x01\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x01\x04",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x01\x04",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x01\x05",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x01\x05",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x01\x04\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR "\x00\x00\x00\x01\x04\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x01\x04\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
/* test adding prioritization data */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x01\x01\x24\x00\x00\x00\x01"
"\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x02\x01\x24\x00\x00\x00\x01"
"\x00\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x24\x00\x00\x00\x01"
"\x00\x00\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x01\x24\x00\x00\x00\x01"
"\x00\x00\x00\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x24\x00\x00\x00\x01"
"",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x24\x00\x00\x00\x01"
"\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x24\x00\x00\x00\x01"
"\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x24\x00\x00\x00\x01"
"\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x24\x00\x00\x00\x01"
"\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x24\x00\x00\x00\x01"
"\x00\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
/* test looking up an invalid index */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x01\x01\x04\x00\x00\x00\x01"
"\xfe",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x01\x04\x00\x00\x00\x01"
"\x7f\x7f\x01"
"a",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x01\x04\x00\x00\x00\x01"
"\x0f\x7f\x01"
"a",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x01\x04\x00\x00\x00\x01"
"\x1f\x7f\x01"
"a",
0);
/* test nvr, not indexed in static table */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x04\x00\x00\x00\x01"
"\x01\x01"
"a",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x04\x00\x00\x00\x01"
"\x11\x01"
"a",
GRPC_BAD_CLIENT_DISCONNECT);
/* illegal op code */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x01\x01\x04\x00\x00\x00\x01"
"\x80",
0);
/* parse some long indices */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x02\x01\x04\x00\x00\x00\x01"
"\xff\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x04\x00\x00\x00\x01"
"\xff\x80\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x06\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x07\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x80\x00",
0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x80",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x80\x80",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x80\x80\x00",
0);
/* overflow on byte 4 */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x06\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x7f",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x06\x01\x04\x00\x00\x00\x01"
"\xff\xff\xff\xff\xff\x0f",
GRPC_BAD_CLIENT_DISCONNECT);
/* overflow after byte 4 */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x08\x01\x04\x00\x00\x00\x01"
"\xff\x80\x80\x80\x80\x80\x80\x02",
0);
/* end of headers mid-opcode */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x01\x01\x04\x00\x00\x00\x01"
"\x01",
GRPC_BAD_CLIENT_DISCONNECT);
/* dynamic table size update: set to default */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x04\x00\x00\x00\x01"
"\x3f\xe1\x1f",
GRPC_BAD_CLIENT_DISCONNECT);
/* dynamic table size update: set too large */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x04\x00\x00\x00\x01"
"\x3f\xf1\x1f",
0);
/* dynamic table size update: set twice */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x01\x04\x00\x00\x00\x01"
"\x20\x3f\xe1\x1f",
GRPC_BAD_CLIENT_DISCONNECT);
/* dynamic table size update: set thrice */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x03\x01\x04\x00\x00\x00\x01"
"\x20\x20\x20",
0);
/* non-ending header followed by continuation frame */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x00\x01\x00\x00\x00\x00\x01"
"\x00\x00\x00\x09\x04\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
/* non-ending header followed by non-continuation frame */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x00\x01\x00\x00\x00\x00\x01"
"\x00\x00\x00\x00\x04\x00\x00\x00\x01",
0);
/* non-ending header followed by a continuation frame for a different stream
*/
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x00\x01\x04\x00\x00\x00\x01"
"\x00\x00\x00\x01\x00\x00\x00\x00\x03"
"\x00\x00\x00\x09\x04\x00\x00\x00\x01",
0);
/* opening with a continuation frame */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x09\x04\x00\x00\x00\x01", 0);
/* three header frames */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x00\x01\x04\x00\x00\x00\x01"
"\x00\x00\x00\x01\x04\x00\x00\x00\x01"
"\x00\x00\x00\x01\x04\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
/* an invalid header found with fuzzing */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x01\x39\x67\xed\x1d\x64",
GRPC_BAD_CLIENT_DISCONNECT);
/* a badly encoded timeout value */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x19\x01\x04\x00\x00\x00\x01"
"\x10\x0cgrpc-timeout\x0a"
"15 seconds",
GRPC_BAD_CLIENT_DISCONNECT);
/* a badly encoded timeout value: twice (catches caching) */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x19\x01\x04\x00\x00\x00\x01"
"\x10\x0cgrpc-timeout\x0a"
"15 seconds"
@@ -289,5 +336,6 @@ int main(int argc, char **argv) {
"15 seconds",
GRPC_BAD_CLIENT_DISCONNECT);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.cc
index 0696ef9383..0220000ece 100644
--- a/test/core/bad_client/tests/initial_settings_frame.c
+++ b/test/core/bad_client/tests/initial_settings_frame.cc
@@ -22,87 +22,91 @@
#define PFX_STR "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
#define ONE_SETTING_HDR "\x00\x00\x06\x04\x00\x00\x00\x00\x00"
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
/* various partial prefixes */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x06",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x06",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x06",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x06",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x06",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x06",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x04",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x04\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x04\x01",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04\x01",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x04\xff",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04\xff",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x04\x00\x00",
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR "\x00\x00\x00\x04\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x04\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
/* must not send frames with stream id != 0 */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00\x01", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x04\x00\x40\x00\x00\x00", 0);
/* settings frame must be a multiple of six bytes long */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x01\x04\x00\x00\x00\x00\x00", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x02\x04\x00\x00\x00\x00\x00", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x03\x04\x00\x00\x00\x00\x00", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x04\x04\x00\x00\x00\x00\x00", 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x05\x04\x00\x00\x00\x00\x00", 0);
/* some settings values are illegal */
/* max frame size = 0 */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR ONE_SETTING_HDR "\x00\x05\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR ONE_SETTING_HDR "\x00\x06\xff\xff\xff\xff",
GRPC_BAD_CLIENT_DISCONNECT);
/* update intiial window size */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR ONE_SETTING_HDR "\x00\x04\x00\x01\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
/* ack with data */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x00\x04\x00\x00\x00\x00\x00"
"\x00\x00\x01\x04\x01\x00\x00\x00\x00",
0);
/* settings frame with invalid flags */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x04\x10\x00\x00\x00\x00", 0);
/* unknown settings should be ignored */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR ONE_SETTING_HDR "\x00\x99\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.cc
index ca3d234be9..ff3e9eb932 100644
--- a/test/core/bad_client/tests/large_metadata.c
+++ b/test/core/bad_client/tests/large_metadata.cc
@@ -22,7 +22,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
@@ -93,14 +93,14 @@
"\x10\x02te\x08trailers" \
"\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void server_verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void server_verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
grpc_call_error error;
- grpc_call *s;
+ grpc_call* s;
grpc_call_details call_details;
- cq_verifier *cqv = cq_verifier_create(cq);
+ cq_verifier* cqv = cq_verifier_create(cq);
grpc_metadata_array request_metadata_recv;
grpc_call_details_init(&call_details);
@@ -121,13 +121,13 @@ static void server_verifier(grpc_server *server, grpc_completion_queue *cq,
cq_verifier_destroy(cqv);
}
-static void server_verifier_sends_too_much_metadata(grpc_server *server,
- grpc_completion_queue *cq,
- void *registered_method) {
+static void server_verifier_sends_too_much_metadata(grpc_server* server,
+ grpc_completion_queue* cq,
+ void* registered_method) {
grpc_call_error error;
- grpc_call *s;
+ grpc_call* s;
grpc_call_details call_details;
- cq_verifier *cqv = cq_verifier_create(cq);
+ cq_verifier* cqv = cq_verifier_create(cq);
grpc_metadata_array request_metadata_recv;
grpc_call_details_init(&call_details);
@@ -154,8 +154,8 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server,
op.data.send_initial_metadata.count = 1;
op.data.send_initial_metadata.metadata = &meta;
op.flags = 0;
- op.reserved = NULL;
- error = grpc_call_start_batch(s, &op, 1, tag(102), NULL);
+ op.reserved = nullptr;
+ error = grpc_call_start_batch(s, &op, 1, tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 0); // Operation fails.
cq_verify(cqv);
@@ -167,10 +167,10 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server,
cq_verifier_destroy(cqv);
}
-static bool client_validator(grpc_slice_buffer *incoming) {
+static bool client_validator(grpc_slice_buffer* incoming) {
for (size_t i = 0; i < incoming->count; ++i) {
- const char *s = (const char *)GRPC_SLICE_START_PTR(incoming->slices[i]);
- char *hex = gpr_dump(s, GRPC_SLICE_LENGTH(incoming->slices[i]),
+ const char* s = (const char*)GRPC_SLICE_START_PTR(incoming->slices[i]);
+ char* hex = gpr_dump(s, GRPC_SLICE_LENGTH(incoming->slices[i]),
GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "RESPONSE SLICE %" PRIdPTR ": %s", i, hex);
gpr_free(hex);
@@ -183,7 +183,7 @@ static bool client_validator(grpc_slice_buffer *incoming) {
GPR_ASSERT(last_frame_buffer.count == 1);
grpc_slice last_frame = last_frame_buffer.slices[0];
- const uint8_t *p = GRPC_SLICE_START_PTR(last_frame);
+ const uint8_t* p = GRPC_SLICE_START_PTR(last_frame);
bool success =
// Length == 4
*p++ != 0 || *p++ != 0 || *p++ != 4 ||
@@ -204,7 +204,7 @@ static bool client_validator(grpc_slice_buffer *incoming) {
return success;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int i;
grpc_test_init(argc, argv);
@@ -213,14 +213,14 @@ int main(int argc, char **argv) {
gpr_strvec headers;
gpr_strvec_init(&headers);
for (i = 0; i < NUM_HEADERS; ++i) {
- char *str;
+ char* str;
gpr_asprintf(&str, "%s%02d%s",
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR, i,
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_END_STR);
gpr_strvec_add(&headers, str);
}
size_t headers_len;
- const char *client_headers = gpr_strvec_flatten(&headers, &headers_len);
+ const char* client_headers = gpr_strvec_flatten(&headers, &headers_len);
gpr_strvec_destroy(&headers);
char client_payload[PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE] =
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR;
@@ -229,7 +229,7 @@ int main(int argc, char **argv) {
client_headers, headers_len);
GRPC_RUN_BAD_CLIENT_TEST(server_verifier, client_validator, client_payload,
0);
- gpr_free((void *)client_headers);
+ gpr_free((void*)client_headers);
// Test sending more metadata than the client will accept.
GRPC_RUN_BAD_CLIENT_TEST(server_verifier_sends_too_much_metadata,
diff --git a/test/core/bad_client/tests/server_registered_method.c b/test/core/bad_client/tests/server_registered_method.cc
index f52350302b..c2dc9c66af 100644
--- a/test/core/bad_client/tests/server_registered_method.c
+++ b/test/core/bad_client/tests/server_registered_method.cc
@@ -38,16 +38,16 @@
"\x10\x02te\x08trailers" \
"\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier_succeeds(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
grpc_call_error error;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(cq);
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(cq);
grpc_metadata_array request_metadata_recv;
gpr_timespec deadline;
- grpc_byte_buffer *payload = NULL;
+ grpc_byte_buffer* payload = nullptr;
grpc_metadata_array_init(&request_metadata_recv);
@@ -58,7 +58,7 @@ static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq,
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
- GPR_ASSERT(payload != NULL);
+ GPR_ASSERT(payload != nullptr);
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_unref(s);
@@ -66,59 +66,64 @@ static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq,
cq_verifier_destroy(cqv);
}
-static void verifier_fails(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier_fails(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
/* body generated with
* tools/codegen/core/gen_server_registered_method_bad_client_test_body.py */
- GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, nullptr,
PFX_STR "\x00\x00\x00\x00\x00\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, nullptr,
PFX_STR "\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, nullptr,
+ PFX_STR
"\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
- GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, nullptr,
+ PFX_STR
"\x00\x00\x03\x00\x00\x00\x00\x00\x01\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_fails, NULL,
+ verifier_fails, nullptr,
PFX_STR "\x00\x00\x04\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_succeeds, NULL,
+ verifier_succeeds, nullptr,
PFX_STR "\x00\x00\x05\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00", 0);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_fails, NULL,
+ verifier_fails, nullptr,
PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_succeeds, NULL,
+ verifier_succeeds, nullptr,
PFX_STR "\x00\x00\x06\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00",
0);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_fails, NULL,
+ verifier_fails, nullptr,
PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02",
GRPC_BAD_CLIENT_DISCONNECT);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_fails, NULL,
+ verifier_fails, nullptr,
PFX_STR "\x00\x00\x06\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00",
GRPC_BAD_CLIENT_DISCONNECT);
GRPC_RUN_BAD_CLIENT_TEST(
- verifier_succeeds, NULL, PFX_STR
+ verifier_succeeds, nullptr,
+ PFX_STR
"\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00",
0);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.cc
index a516632819..c80fc5cb4a 100644
--- a/test/core/bad_client/tests/simple_request.c
+++ b/test/core/bad_client/tests/simple_request.cc
@@ -20,6 +20,8 @@
#include <string.h>
+#include <grpc/grpc.h>
+
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
@@ -83,14 +85,14 @@
"\x10\x0cgrpc-timeout\x02" \
"5S"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
grpc_call_error error;
- grpc_call *s;
+ grpc_call* s;
grpc_call_details call_details;
- cq_verifier *cqv = cq_verifier_create(cq);
+ cq_verifier* cqv = cq_verifier_create(cq);
grpc_metadata_array request_metadata_recv;
grpc_call_details_init(&call_details);
@@ -111,56 +113,60 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq,
cq_verifier_destroy(cqv);
}
-static void failure_verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void failure_verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
/* basic request: check that things are working */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR, 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR_UNUSUAL, 0);
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR_UNUSUAL2, 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR, 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR_UNUSUAL, 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR_UNUSUAL2, 0);
/* push an illegal data frame */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR
"\x00\x00\x05\x00\x00\x00\x00\x00\x01"
"\x34\x00\x00\x00\x00",
0);
/* push a data frame with bad flags */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x00\x02\x00\x00\x00\x01", 0);
/* push a window update with a bad length */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
PFX_STR "\x00\x00\x01\x08\x00\x00\x00\x00\x01", 0);
/* push a window update with bad flags */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
PFX_STR "\x00\x00\x00\x08\x10\x00\x00\x00\x01", 0);
/* push a window update with bad data */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL, PFX_STR
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
+ PFX_STR
"\x00\x00\x04\x08\x00\x00\x00\x00\x01"
"\xff\xff\xff\xff",
0);
/* push a short goaway */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
PFX_STR "\x00\x00\x04\x07\x00\x00\x00\x00\x00", 0);
/* disconnect before sending goaway */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
PFX_STR "\x00\x01\x12\x07\x00\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
/* push a rst_stream with a bad length */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
PFX_STR "\x00\x00\x01\x03\x00\x00\x00\x00\x01", 0);
/* push a rst_stream with bad flags */
- GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, nullptr,
PFX_STR "\x00\x00\x00\x03\x10\x00\x00\x00\x01", 0);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/unknown_frame.c b/test/core/bad_client/tests/unknown_frame.cc
index 448803d12b..b1b618a43f 100644
--- a/test/core/bad_client/tests/unknown_frame.c
+++ b/test/core/bad_client/tests/unknown_frame.cc
@@ -23,22 +23,24 @@
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \
"\x00\x00\x00\x04\x00\x00\x00\x00\x00"
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
+ grpc_init();
grpc_test_init(argc, argv);
/* test adding prioritization data */
- GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR "\x00\x00\x00\x88\x00\x00\x00\x00\x01",
GRPC_BAD_CLIENT_DISCONNECT);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_client/tests/window_overflow.c b/test/core/bad_client/tests/window_overflow.cc
index 1f29bd32fb..ed8279c951 100644
--- a/test/core/bad_client/tests/window_overflow.c
+++ b/test/core/bad_client/tests/window_overflow.cc
@@ -20,6 +20,7 @@
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/surface/server.h"
@@ -42,36 +43,37 @@
"\x10\x02te\x08trailers" \
"\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)"
-static void verifier(grpc_server *server, grpc_completion_queue *cq,
- void *registered_method) {
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
while (grpc_server_has_open_connections(server)) {
GPR_ASSERT(grpc_completion_queue_next(
- cq, grpc_timeout_milliseconds_to_deadline(20), NULL)
+ cq, grpc_timeout_milliseconds_to_deadline(20), nullptr)
.type == GRPC_QUEUE_TIMEOUT);
}
}
-char *g_buffer;
+char* g_buffer;
size_t g_cap = 0;
size_t g_count = 0;
-static void addbuf(const void *data, size_t len) {
+static void addbuf(const void* data, size_t len) {
if (g_count + len > g_cap) {
g_cap = GPR_MAX(g_count + len, g_cap * 2);
- g_buffer = gpr_realloc(g_buffer, g_cap);
+ g_buffer = static_cast<char*>(gpr_realloc(g_buffer, g_cap));
}
memcpy(g_buffer + g_count, data, len);
g_count += len;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int i, j;
#define MAX_FRAME_SIZE 16384
#define MESSAGES_PER_FRAME (MAX_FRAME_SIZE / 5)
#define FRAME_SIZE (MESSAGES_PER_FRAME * 5)
-#define SEND_SIZE (100 * 1024)
+#define SEND_SIZE (6 * 1024 * 1024)
#define NUM_FRAMES (SEND_SIZE / FRAME_SIZE + 1)
grpc_test_init(argc, argv);
+ grpc_init();
addbuf(PFX_STR, sizeof(PFX_STR) - 1);
for (i = 0; i < NUM_FRAMES; i++) {
@@ -90,8 +92,10 @@ int main(int argc, char **argv) {
addbuf(message, sizeof(message));
}
}
- grpc_run_bad_client_test(verifier, NULL, g_buffer, g_count, 0);
+ grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count,
+ GRPC_BAD_CLIENT_LARGE_REQUEST);
gpr_free(g_buffer);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.cc
index 793627bcdc..8a7960b5ed 100644
--- a/test/core/bad_ssl/bad_ssl_test.c
+++ b/test/core/bad_ssl/bad_ssl_test.cc
@@ -26,19 +26,19 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#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/test_config.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void run_test(const char *target, size_t nops) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(NULL, NULL, NULL);
- grpc_channel *channel;
- grpc_call *c;
+static void run_test(const char* target, size_t nops) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_channel* channel;
+ grpc_call* c;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
@@ -46,15 +46,16 @@ static void run_test(const char *target, size_t nops) {
grpc_status_code status;
grpc_call_error error;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- cq_verifier *cqv = cq_verifier_create(cq);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ cq_verifier* cqv = cq_verifier_create(cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
grpc_channel_args args;
args.num_args = 1;
@@ -63,36 +64,36 @@ static void run_test(const char *target, size_t nops) {
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
- channel = grpc_secure_channel_create(ssl_creds, target, &args, NULL);
+ channel = grpc_secure_channel_create(ssl_creds, target, &args, nullptr);
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234");
- c = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ c = grpc_channel_create_call(channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), &host,
- deadline, NULL);
+ deadline, nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, nops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, nops, tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -111,18 +112,18 @@ static void run_test(const char *target, size_t nops) {
grpc_channel_credentials_release(ssl_creds);
}
-int main(int argc, char **argv) {
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
- char *lunder = strrchr(me, '_');
- char *tmp;
+int main(int argc, char** argv) {
+ char* me = argv[0];
+ char* lslash = strrchr(me, '/');
+ char* lunder = strrchr(me, '_');
+ char* tmp;
char root[1024];
char test[64];
int port = grpc_pick_unused_port_or_die();
- char *args[10];
+ char* args[10];
int status;
size_t i;
- gpr_subprocess *svr;
+ gpr_subprocess* svr;
/* figure out where we are */
if (lslash) {
memcpy(root, me, (size_t)(lslash - me));
@@ -141,9 +142,9 @@ int main(int argc, char **argv) {
/* start the server */
gpr_asprintf(&args[0], "%s/bad_ssl_%s_server%s", root, test,
gpr_subprocess_binary_extension());
- args[1] = "--bind";
+ args[1] = const_cast<char*>("--bind");
gpr_join_host_port(&args[2], "::", port);
- svr = gpr_subprocess_create(4, (const char **)args);
+ svr = gpr_subprocess_create(4, (const char**)args);
gpr_free(args[0]);
for (i = 3; i <= 4; i++) {
diff --git a/test/core/bad_ssl/gen_build_yaml.py b/test/core/bad_ssl/gen_build_yaml.py
index 30fdb5ea02..6b78e9c7aa 100755
--- a/test/core/bad_ssl/gen_build_yaml.py
+++ b/test/core/bad_ssl/gen_build_yaml.py
@@ -38,7 +38,7 @@ def main():
'name': 'bad_ssl_test_server',
'build': 'private',
'language': 'c',
- 'src': ['test/core/bad_ssl/server_common.c'],
+ 'src': ['test/core/bad_ssl/server_common.cc'],
'headers': ['test/core/bad_ssl/server_common.h'],
'vs_proj_dir': 'test',
'platforms': ['linux', 'posix', 'mac'],
@@ -56,7 +56,7 @@ def main():
'build': 'test',
'language': 'c',
'run': False,
- 'src': ['test/core/bad_ssl/servers/%s.c' % t],
+ 'src': ['test/core/bad_ssl/servers/%s.cc' % t],
'vs_proj_dir': 'test/bad_ssl',
'platforms': ['linux', 'posix', 'mac'],
'deps': [
@@ -73,7 +73,7 @@ def main():
'cpu_cost': BAD_CLIENT_TESTS[t].cpu_cost,
'build': 'test',
'language': 'c',
- 'src': ['test/core/bad_ssl/bad_ssl_test.c'],
+ 'src': ['test/core/bad_ssl/bad_ssl_test.cc'],
'vs_proj_dir': 'test',
'platforms': ['linux', 'posix', 'mac'],
'deps': [
diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl
index b61fabc051..b7cb8f86e6 100755
--- a/test/core/bad_ssl/generate_tests.bzl
+++ b/test/core/bad_ssl/generate_tests.bzl
@@ -24,14 +24,14 @@ BAD_SSL_TESTS = ['cert', 'alpn']
def grpc_bad_ssl_tests():
native.cc_library(
name = 'bad_ssl_test_server',
- srcs = ['server_common.c'],
+ srcs = ['server_common.cc'],
hdrs = ['server_common.h'],
deps = ['//test/core/util:grpc_test_util', '//:grpc', '//test/core/end2end:ssl_test_data']
)
for t in BAD_SSL_TESTS:
native.cc_test(
name = 'bad_ssl_%s_server' % t,
- srcs = ['servers/%s.c' % t],
+ srcs = ['servers/%s.cc' % t],
deps = [':bad_ssl_test_server'],
)
diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.cc
index 0588d43c38..08842b8350 100644
--- a/test/core/bad_ssl/server_common.c
+++ b/test/core/bad_ssl/server_common.cc
@@ -32,9 +32,9 @@ static int got_sigint = 0;
static void sigint_handler(int x) { got_sigint = 1; }
-const char *bad_ssl_addr(int argc, char **argv) {
- gpr_cmdline *cl;
- char *addr = NULL;
+const char* bad_ssl_addr(int argc, char** argv) {
+ gpr_cmdline* cl;
+ const char* addr = nullptr;
cl = gpr_cmdline_create("test server");
gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr);
gpr_cmdline_parse(cl, argc, argv);
@@ -43,49 +43,50 @@ const char *bad_ssl_addr(int argc, char **argv) {
return addr;
}
-void bad_ssl_run(grpc_server *server) {
+void bad_ssl_run(grpc_server* server) {
int shutdown_started = 0;
int shutdown_finished = 0;
grpc_event ev;
grpc_call_error error;
- grpc_call *s = NULL;
+ grpc_call* s = nullptr;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_completion_queue *shutdown_cq;
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_completion_queue* shutdown_cq;
grpc_call_details_init(&call_details);
grpc_metadata_array_init(&request_metadata_recv);
- grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_server_register_completion_queue(server, cq, nullptr);
grpc_server_start(server);
error = grpc_server_request_call(server, &s, &call_details,
- &request_metadata_recv, cq, cq, (void *)1);
+ &request_metadata_recv, cq, cq, (void*)1);
GPR_ASSERT(GRPC_CALL_OK == error);
signal(SIGINT, sigint_handler);
while (!shutdown_finished) {
if (got_sigint && !shutdown_started) {
gpr_log(GPR_INFO, "Shutting down due to SIGINT");
- shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
- grpc_server_shutdown_and_notify(server, shutdown_cq, NULL);
- GPR_ASSERT(
- grpc_completion_queue_pluck(shutdown_cq, NULL,
- grpc_timeout_seconds_to_deadline(5), NULL)
- .type == GRPC_OP_COMPLETE);
+ shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
+ grpc_server_shutdown_and_notify(server, shutdown_cq, nullptr);
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ shutdown_cq, nullptr, grpc_timeout_seconds_to_deadline(5),
+ nullptr)
+ .type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_completion_queue_shutdown(cq);
shutdown_started = 1;
}
ev = grpc_completion_queue_next(
- cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_micros(1000000, GPR_TIMESPAN)),
- NULL);
+ cq,
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ nullptr);
switch (ev.type) {
case GRPC_OP_COMPLETE:
- GPR_ASSERT(ev.tag == (void *)1);
+ GPR_ASSERT(ev.tag == (void*)1);
GPR_ASSERT(ev.success == 0);
break;
case GRPC_QUEUE_SHUTDOWN:
@@ -97,7 +98,7 @@ void bad_ssl_run(grpc_server *server) {
}
}
- GPR_ASSERT(s == NULL);
+ GPR_ASSERT(s == nullptr);
grpc_call_details_destroy(&call_details);
grpc_metadata_array_destroy(&request_metadata_recv);
}
diff --git a/test/core/bad_ssl/server_common.h b/test/core/bad_ssl/server_common.h
index 35d51b1cb4..e1933b973e 100644
--- a/test/core/bad_ssl/server_common.h
+++ b/test/core/bad_ssl/server_common.h
@@ -21,7 +21,7 @@
#include <grpc/grpc.h>
-const char *bad_ssl_addr(int argc, char **argv);
-void bad_ssl_run(grpc_server *server);
+const char* bad_ssl_addr(int argc, char** argv);
+void bad_ssl_run(grpc_server* server);
#endif /* GRPC_TEST_CORE_BAD_SSL_SERVER_H */
diff --git a/test/core/bad_ssl/servers/alpn.c b/test/core/bad_ssl/servers/alpn.cc
index 3179054aff..23954d82fd 100644
--- a/test/core/bad_ssl/servers/alpn.c
+++ b/test/core/bad_ssl/servers/alpn.cc
@@ -31,9 +31,9 @@
* a protocol that the connecting client does not support. It does this by
* overriding the functions declared in alpn.c from the core library. */
-static const char *const fake_versions[] = {"not-h2"};
+static const char* const fake_versions[] = {"not-h2"};
-int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
+int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size) {
size_t i;
for (i = 0; i < GPR_ARRAY_SIZE(fake_versions); i++) {
if (!strncmp(version, fake_versions[i], size)) return 1;
@@ -45,22 +45,22 @@ size_t grpc_chttp2_num_alpn_versions(void) {
return GPR_ARRAY_SIZE(fake_versions);
}
-const char *grpc_chttp2_get_alpn_version_index(size_t i) {
+const char* grpc_chttp2_get_alpn_version_index(size_t i) {
GPR_ASSERT(i < GPR_ARRAY_SIZE(fake_versions));
return fake_versions[i];
}
-int main(int argc, char **argv) {
- const char *addr = bad_ssl_addr(argc, argv);
+int main(int argc, char** argv) {
+ const char* addr = bad_ssl_addr(argc, argv);
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds;
- grpc_server *server;
+ grpc_server_credentials* ssl_creds;
+ grpc_server* server;
grpc_init();
- ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL);
- server = grpc_server_create(NULL, NULL);
+ ssl_creds = grpc_ssl_server_credentials_create(nullptr, &pem_key_cert_pair, 1,
+ 0, nullptr);
+ server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
grpc_server_credentials_release(ssl_creds);
diff --git a/test/core/bad_ssl/servers/cert.c b/test/core/bad_ssl/servers/cert.cc
index a1f3048164..a51dd34e4b 100644
--- a/test/core/bad_ssl/servers/cert.c
+++ b/test/core/bad_ssl/servers/cert.cc
@@ -31,11 +31,11 @@
/* This server will present an untrusted cert to the connecting client,
* causing the SSL handshake to fail */
-int main(int argc, char **argv) {
- const char *addr = bad_ssl_addr(argc, argv);
+int main(int argc, char** argv) {
+ const char* addr = bad_ssl_addr(argc, argv);
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
- grpc_server_credentials *ssl_creds;
- grpc_server *server;
+ grpc_server_credentials* ssl_creds;
+ grpc_server* server;
grpc_slice cert_slice, key_slice;
grpc_init();
@@ -46,12 +46,12 @@ int main(int argc, char **argv) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file",
grpc_load_file("src/core/tsi/test_creds/badserver.key", 1, &key_slice)));
- pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
+ pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
- ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL);
- server = grpc_server_create(NULL, NULL);
+ ssl_creds = grpc_ssl_server_credentials_create(nullptr, &pem_key_cert_pair, 1,
+ 0, nullptr);
+ server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
grpc_server_credentials_release(ssl_creds);
diff --git a/test/core/census/BUILD b/test/core/census/BUILD
deleted file mode 100644
index 24fd2807d0..0000000000
--- a/test/core/census/BUILD
+++ /dev/null
@@ -1,82 +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.
-
-load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary", "grpc_package")
-
-grpc_package(name = "test/core/census")
-
-licenses(["notice"]) # Apache v2
-
-grpc_cc_test(
- name = "context_test",
- srcs = ["context_test.c"],
- language = "C",
- deps = [
- "//:gpr",
- "//:grpc",
- "//test/core/util:gpr_test_util",
- "//test/core/util:grpc_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "mlog_test",
- srcs = ["mlog_test.c"],
- language = "C",
- deps = [
- "//:gpr",
- "//:grpc",
- "//test/core/util:gpr_test_util",
- "//test/core/util:grpc_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "resource_test",
- srcs = ["resource_test.c"],
- language = "C",
- data = [
- ":data/resource_empty_name.pb",
- ":data/resource_full.pb",
- ":data/resource_minimal_good.pb",
- ":data/resource_no_name.pb",
- ":data/resource_no_numerator.pb",
- ":data/resource_no_unit.pb",
- ],
- deps = [
- "//:gpr",
- "//:grpc",
- "//test/core/util:gpr_test_util",
- "//test/core/util:grpc_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "trace_context_test",
- srcs = ["trace_context_test.c"],
- language = "C",
- data = [
- ":data/context_empty.pb",
- ":data/context_full.pb",
- ":data/context_no_span_options.pb",
- ":data/context_span_only.pb",
- ":data/context_trace_only.pb",
- ],
- deps = [
- "//:gpr",
- "//:grpc",
- "//test/core/util:gpr_test_util",
- "//test/core/util:grpc_test_util",
- ],
-)
diff --git a/test/core/census/README b/test/core/census/README
deleted file mode 100644
index d5363b7233..0000000000
--- a/test/core/census/README
+++ /dev/null
@@ -1,7 +0,0 @@
-Test source and data files for Census.
-
-binary proto files (*.pb) in data directory are generated from the *.txt file,
-via:
-
-BASE="filename"
-cat $BASE.txt | protoc --encode=google.census.Resource census.proto > $BASE.pb
diff --git a/test/core/census/context_test.c b/test/core/census/context_test.c
deleted file mode 100644
index ca5a6ec5cd..0000000000
--- a/test/core/census/context_test.c
+++ /dev/null
@@ -1,363 +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.
- *
- */
-
-// Test census_context functions, including encoding/decoding
-
-#include <grpc/census.h>
-#include <grpc/support/log.h>
-#include <grpc/support/time.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "test/core/util/test_config.h"
-
-// A set of tags Used to create a basic context for testing. Note that
-// replace_add_delete_test() relies on specific offsets into this array - if
-// you add or delete entries, you will also need to change the test.
-#define BASIC_TAG_COUNT 8
-static census_tag basic_tags[BASIC_TAG_COUNT] = {
- /* 0 */ {"key0", "tag value", 0},
- /* 1 */ {"k1", "a", CENSUS_TAG_PROPAGATE},
- /* 2 */ {"k2", "a longer tag value supercalifragilisticexpialiadocious",
- CENSUS_TAG_STATS},
- /* 3 */ {"key_three", "", 0},
- /* 4 */ {"a_really_really_really_really_long_key_4", "random",
- CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS},
- /* 5 */ {"k5", "v5", CENSUS_TAG_PROPAGATE},
- /* 6 */ {"k6", "v6", CENSUS_TAG_STATS},
- /* 7 */ {"k7", "v7", CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS}};
-
-// Set of tags used to modify the basic context. Note that
-// replace_add_delete_test() relies on specific offsets into this array - if
-// you add or delete entries, you will also need to change the test. Other
-// tests that rely on specific instances have XXX_XXX_OFFSET definitions (also
-// change the defines below if you add/delete entires).
-#define MODIFY_TAG_COUNT 10
-static census_tag modify_tags[MODIFY_TAG_COUNT] = {
-#define REPLACE_VALUE_OFFSET 0
- /* 0 */ {"key0", "replace key0", 0}, // replaces tag value only
-#define ADD_TAG_OFFSET 1
- /* 1 */ {"new_key", "xyzzy", CENSUS_TAG_STATS}, // new tag
-#define DELETE_TAG_OFFSET 2
- /* 2 */ {"k5", NULL, 0}, // should delete tag
- /* 3 */ {"k5", NULL, 0}, // try deleting already-deleted tag
- /* 4 */ {"non-existent", NULL, 0}, // delete non-existent tag
-#define REPLACE_FLAG_OFFSET 5
- /* 5 */ {"k1", "a", 0}, // change flags only
- /* 6 */ {"k7", "bar", CENSUS_TAG_STATS}, // change flags and value
- /* 7 */ {"k2", "", CENSUS_TAG_PROPAGATE}, // more value and flags change
- /* 8 */ {"k5", "bar", 0}, // add back tag, with different value
- /* 9 */ {"foo", "bar", CENSUS_TAG_PROPAGATE}, // another new tag
-};
-
-// Utility function to compare tags. Returns true if all fields match.
-static bool compare_tag(const census_tag *t1, const census_tag *t2) {
- return (strcmp(t1->key, t2->key) == 0 && strcmp(t1->value, t2->value) == 0 &&
- t1->flags == t2->flags);
-}
-
-// Utility function to validate a tag exists in context.
-static bool validate_tag(const census_context *context, const census_tag *tag) {
- census_tag tag2;
- if (census_context_get_tag(context, tag->key, &tag2) != 1) return false;
- return compare_tag(tag, &tag2);
-}
-
-// Create an empty context.
-static void empty_test(void) {
- struct census_context *context = census_context_create(NULL, NULL, 0, NULL);
- GPR_ASSERT(context != NULL);
- const census_context_status *status = census_context_get_status(context);
- census_context_status expected = {0, 0, 0, 0, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
-}
-
-// Test create and iteration over basic context.
-static void basic_test(void) {
- const census_context_status *status;
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, &status);
- census_context_status expected = {4, 4, 0, 8, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_iterator it;
- census_context_initialize_iterator(context, &it);
- census_tag tag;
- while (census_context_next_tag(&it, &tag)) {
- // can't rely on tag return order: make sure it matches exactly one.
- int matches = 0;
- for (int i = 0; i < BASIC_TAG_COUNT; i++) {
- if (compare_tag(&tag, &basic_tags[i])) matches++;
- }
- GPR_ASSERT(matches == 1);
- }
- census_context_destroy(context);
-}
-
-// Test census_context_get_tag().
-static void lookup_by_key_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- census_tag tag;
- for (int i = 0; i < BASIC_TAG_COUNT; i++) {
- GPR_ASSERT(census_context_get_tag(context, basic_tags[i].key, &tag) == 1);
- GPR_ASSERT(compare_tag(&tag, &basic_tags[i]));
- }
- // non-existent keys
- GPR_ASSERT(census_context_get_tag(context, "key", &tag) == 0);
- GPR_ASSERT(census_context_get_tag(context, "key01", &tag) == 0);
- GPR_ASSERT(census_context_get_tag(context, "k9", &tag) == 0);
- GPR_ASSERT(census_context_get_tag(context, "random", &tag) == 0);
- GPR_ASSERT(census_context_get_tag(context, "", &tag) == 0);
- census_context_destroy(context);
-}
-
-// Try creating context with invalid entries.
-static void invalid_test(void) {
- char key[300];
- memset(key, 'k', 299);
- key[299] = 0;
- char value[300];
- memset(value, 'v', 299);
- value[299] = 0;
- census_tag tag = {key, value, 0};
- // long keys, short value. Key lengths (including terminator) should be
- // <= 255 (CENSUS_MAX_TAG_KV_LEN)
- value[3] = 0;
- GPR_ASSERT(strlen(value) == 3);
- GPR_ASSERT(strlen(key) == 299);
- const census_context_status *status;
- struct census_context *context =
- census_context_create(NULL, &tag, 1, &status);
- census_context_status expected = {0, 0, 0, 0, 0, 1, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
- key[CENSUS_MAX_TAG_KV_LEN] = 0;
- GPR_ASSERT(strlen(key) == CENSUS_MAX_TAG_KV_LEN);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
- key[CENSUS_MAX_TAG_KV_LEN - 1] = 0;
- GPR_ASSERT(strlen(key) == CENSUS_MAX_TAG_KV_LEN - 1);
- context = census_context_create(NULL, &tag, 1, &status);
- census_context_status expected2 = {0, 1, 0, 1, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected2, sizeof(expected2)) == 0);
- census_context_destroy(context);
- // now try with long values
- value[3] = 'v';
- GPR_ASSERT(strlen(value) == 299);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
- value[CENSUS_MAX_TAG_KV_LEN] = 0;
- GPR_ASSERT(strlen(value) == CENSUS_MAX_TAG_KV_LEN);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
- value[CENSUS_MAX_TAG_KV_LEN - 1] = 0;
- GPR_ASSERT(strlen(value) == CENSUS_MAX_TAG_KV_LEN - 1);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected2, sizeof(expected2)) == 0);
- census_context_destroy(context);
- // 0 length key.
- key[0] = 0;
- GPR_ASSERT(strlen(key) == 0);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
- // invalid key character
- key[0] = 31; // 32 (' ') is the first valid character value
- key[1] = 0;
- GPR_ASSERT(strlen(key) == 1);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
- // invalid value character
- key[0] = ' ';
- value[5] = 127; // 127 (DEL) is ('~' + 1)
- value[8] = 0;
- GPR_ASSERT(strlen(key) == 1);
- GPR_ASSERT(strlen(value) == 8);
- context = census_context_create(NULL, &tag, 1, &status);
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_context_destroy(context);
-}
-
-// Make a copy of a context
-static void copy_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_context_status *status;
- struct census_context *context2 =
- census_context_create(context, NULL, 0, &status);
- census_context_status expected = {4, 4, 0, 0, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- for (int i = 0; i < BASIC_TAG_COUNT; i++) {
- census_tag tag;
- GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) == 1);
- GPR_ASSERT(compare_tag(&tag, &basic_tags[i]));
- }
- census_context_destroy(context);
- census_context_destroy(context2);
-}
-
-// replace a single tag value
-static void replace_value_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_context_status *status;
- struct census_context *context2 = census_context_create(
- context, modify_tags + REPLACE_VALUE_OFFSET, 1, &status);
- census_context_status expected = {4, 4, 0, 0, 1, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag tag;
- GPR_ASSERT(census_context_get_tag(
- context2, modify_tags[REPLACE_VALUE_OFFSET].key, &tag) == 1);
- GPR_ASSERT(compare_tag(&tag, &modify_tags[REPLACE_VALUE_OFFSET]));
- census_context_destroy(context);
- census_context_destroy(context2);
-}
-
-// replace a single tags flags
-static void replace_flags_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_context_status *status;
- struct census_context *context2 = census_context_create(
- context, modify_tags + REPLACE_FLAG_OFFSET, 1, &status);
- census_context_status expected = {3, 5, 0, 0, 1, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag tag;
- GPR_ASSERT(census_context_get_tag(
- context2, modify_tags[REPLACE_FLAG_OFFSET].key, &tag) == 1);
- GPR_ASSERT(compare_tag(&tag, &modify_tags[REPLACE_FLAG_OFFSET]));
- census_context_destroy(context);
- census_context_destroy(context2);
-}
-
-// delete a single tag.
-static void delete_tag_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_context_status *status;
- struct census_context *context2 = census_context_create(
- context, modify_tags + DELETE_TAG_OFFSET, 1, &status);
- census_context_status expected = {3, 4, 1, 0, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag tag;
- GPR_ASSERT(census_context_get_tag(
- context2, modify_tags[DELETE_TAG_OFFSET].key, &tag) == 0);
- census_context_destroy(context);
- census_context_destroy(context2);
-}
-
-// add a single new tag.
-static void add_tag_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_context_status *status;
- struct census_context *context2 =
- census_context_create(context, modify_tags + ADD_TAG_OFFSET, 1, &status);
- census_context_status expected = {4, 5, 0, 1, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag tag;
- GPR_ASSERT(census_context_get_tag(context2, modify_tags[ADD_TAG_OFFSET].key,
- &tag) == 1);
- GPR_ASSERT(compare_tag(&tag, &modify_tags[ADD_TAG_OFFSET]));
- census_context_destroy(context);
- census_context_destroy(context2);
-}
-
-// test many changes at once.
-static void replace_add_delete_test(void) {
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_context_status *status;
- struct census_context *context2 =
- census_context_create(context, modify_tags, MODIFY_TAG_COUNT, &status);
- census_context_status expected = {3, 7, 1, 3, 4, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- // validate context contents. Use specific indices into the two arrays
- // holding tag values.
- GPR_ASSERT(validate_tag(context2, &basic_tags[3]));
- GPR_ASSERT(validate_tag(context2, &basic_tags[4]));
- GPR_ASSERT(validate_tag(context2, &basic_tags[6]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[0]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[1]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[5]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[6]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[7]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[8]));
- GPR_ASSERT(validate_tag(context2, &modify_tags[9]));
- GPR_ASSERT(!validate_tag(context2, &basic_tags[0]));
- GPR_ASSERT(!validate_tag(context2, &basic_tags[1]));
- GPR_ASSERT(!validate_tag(context2, &basic_tags[2]));
- GPR_ASSERT(!validate_tag(context2, &basic_tags[5]));
- GPR_ASSERT(!validate_tag(context2, &basic_tags[7]));
- census_context_destroy(context);
- census_context_destroy(context2);
-}
-
-#define BUF_SIZE 200
-
-// test encode/decode.
-static void encode_decode_test(void) {
- char buffer[BUF_SIZE];
- struct census_context *context =
- census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- // Test with too small a buffer
- GPR_ASSERT(census_context_encode(context, buffer, 2) == 0);
- // Test with sufficient buffer
- size_t buf_used = census_context_encode(context, buffer, BUF_SIZE);
- GPR_ASSERT(buf_used != 0);
- census_context *context2 = census_context_decode(buffer, buf_used);
- GPR_ASSERT(context2 != NULL);
- const census_context_status *status = census_context_get_status(context2);
- census_context_status expected = {4, 0, 0, 0, 0, 0, 0};
- GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- for (int i = 0; i < BASIC_TAG_COUNT; i++) {
- census_tag tag;
- if (CENSUS_TAG_IS_PROPAGATED(basic_tags[i].flags)) {
- GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) ==
- 1);
- GPR_ASSERT(compare_tag(&tag, &basic_tags[i]));
- } else {
- GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) ==
- 0);
- }
- }
- census_context_destroy(context2);
- census_context_destroy(context);
-}
-
-int main(int argc, char *argv[]) {
- grpc_test_init(argc, argv);
- empty_test();
- basic_test();
- lookup_by_key_test();
- invalid_test();
- copy_test();
- replace_value_test();
- replace_flags_test();
- delete_tag_test();
- add_tag_test();
- replace_add_delete_test();
- encode_decode_test();
- return 0;
-}
diff --git a/test/core/census/data/context_empty.pb b/test/core/census/data/context_empty.pb
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/core/census/data/context_empty.pb
+++ /dev/null
diff --git a/test/core/census/data/context_empty.txt b/test/core/census/data/context_empty.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/core/census/data/context_empty.txt
+++ /dev/null
diff --git a/test/core/census/data/context_full.pb b/test/core/census/data/context_full.pb
deleted file mode 100644
index 7b5895cbf1..0000000000
--- a/test/core/census/data/context_full.pb
+++ /dev/null
Binary files differ
diff --git a/test/core/census/data/context_full.txt b/test/core/census/data/context_full.txt
deleted file mode 100644
index 7d8df37ea1..0000000000
--- a/test/core/census/data/context_full.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-trace_id_hi : 5
-trace_id_lo : 1
-span_id : 7
-span_options : 1
diff --git a/test/core/census/data/context_no_span_options.pb b/test/core/census/data/context_no_span_options.pb
deleted file mode 100644
index 4b3425ac01..0000000000
--- a/test/core/census/data/context_no_span_options.pb
+++ /dev/null
Binary files differ
diff --git a/test/core/census/data/context_no_span_options.txt b/test/core/census/data/context_no_span_options.txt
deleted file mode 100644
index 4c8398ffd0..0000000000
--- a/test/core/census/data/context_no_span_options.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-trace_id_hi : 5
-trace_id_lo : 1
-span_id : 7
diff --git a/test/core/census/data/context_span_only.pb b/test/core/census/data/context_span_only.pb
deleted file mode 100644
index a9315be91a..0000000000
--- a/test/core/census/data/context_span_only.pb
+++ /dev/null
Binary files differ
diff --git a/test/core/census/data/context_span_only.txt b/test/core/census/data/context_span_only.txt
deleted file mode 100644
index 4e473fce53..0000000000
--- a/test/core/census/data/context_span_only.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-span_id : 7
-span_options : 1
diff --git a/test/core/census/data/context_trace_only.pb b/test/core/census/data/context_trace_only.pb
deleted file mode 100644
index aabb325f92..0000000000
--- a/test/core/census/data/context_trace_only.pb
+++ /dev/null
Binary files differ
diff --git a/test/core/census/data/context_trace_only.txt b/test/core/census/data/context_trace_only.txt
deleted file mode 100644
index e48a6d7457..0000000000
--- a/test/core/census/data/context_trace_only.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-trace_id_hi : 5
-trace_id_lo : 1
-span_options : 1
diff --git a/test/core/census/data/resource_empty_name.pb b/test/core/census/data/resource_empty_name.pb
deleted file mode 100644
index 4d547445fa..0000000000
--- a/test/core/census/data/resource_empty_name.pb
+++ /dev/null
@@ -1 +0,0 @@
- \ No newline at end of file
diff --git a/test/core/census/data/resource_empty_name.txt b/test/core/census/data/resource_empty_name.txt
deleted file mode 100644
index 271fd3274c..0000000000
--- a/test/core/census/data/resource_empty_name.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# Name is present, but empty.
-name : ''
-unit {
- numerator : SECS
-}
diff --git a/test/core/census/data/resource_full.pb b/test/core/census/data/resource_full.pb
deleted file mode 100644
index e4c6a2aef5..0000000000
--- a/test/core/census/data/resource_full.pb
+++ /dev/null
@@ -1,2 +0,0 @@
-
- full_resource"A resource with everything defined \ No newline at end of file
diff --git a/test/core/census/data/resource_full.txt b/test/core/census/data/resource_full.txt
deleted file mode 100644
index 1aa2fafe3a..0000000000
--- a/test/core/census/data/resource_full.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# A full resource definition - all fields filled out.
-name : 'full_resource'
-description : 'A resource with everything defined'
-unit {
- # Megabits per second.
- prefix : 6
- numerator : BITS
- denominator : SECS
-}
diff --git a/test/core/census/data/resource_minimal_good.pb b/test/core/census/data/resource_minimal_good.pb
deleted file mode 100644
index 7100c462bf..0000000000
--- a/test/core/census/data/resource_minimal_good.pb
+++ /dev/null
@@ -1,2 +0,0 @@
-
- minimal_good \ No newline at end of file
diff --git a/test/core/census/data/resource_minimal_good.txt b/test/core/census/data/resource_minimal_good.txt
deleted file mode 100644
index a7a7e71dd6..0000000000
--- a/test/core/census/data/resource_minimal_good.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# A minimal "good" Resource definition: has a name and numerator/unit.
-name : 'minimal_good'
-unit {
- numerator : SECS
-}
diff --git a/test/core/census/data/resource_no_name.pb b/test/core/census/data/resource_no_name.pb
deleted file mode 100644
index 4d547445fa..0000000000
--- a/test/core/census/data/resource_no_name.pb
+++ /dev/null
@@ -1 +0,0 @@
- \ No newline at end of file
diff --git a/test/core/census/data/resource_no_name.txt b/test/core/census/data/resource_no_name.txt
deleted file mode 100644
index 8f12a91d35..0000000000
--- a/test/core/census/data/resource_no_name.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# The minimal good Resource without a name.
-unit {
- numerator : SECS
-}
diff --git a/test/core/census/data/resource_no_numerator.pb b/test/core/census/data/resource_no_numerator.pb
deleted file mode 100644
index 2a5cceee70..0000000000
--- a/test/core/census/data/resource_no_numerator.pb
+++ /dev/null
@@ -1,2 +0,0 @@
-
-resource_no_numeratorýÿÿÿÿÿÿÿÿ \ No newline at end of file
diff --git a/test/core/census/data/resource_no_numerator.txt b/test/core/census/data/resource_no_numerator.txt
deleted file mode 100644
index fc1fec74a2..0000000000
--- a/test/core/census/data/resource_no_numerator.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Resource without a numerator
-name : 'resource_no_numerator'
-unit {
- prefix : -3
- denominator : SECS
-}
diff --git a/test/core/census/data/resource_no_unit.pb b/test/core/census/data/resource_no_unit.pb
deleted file mode 100644
index 9dca2620e0..0000000000
--- a/test/core/census/data/resource_no_unit.pb
+++ /dev/null
@@ -1,2 +0,0 @@
-
-resource_no_unit \ No newline at end of file
diff --git a/test/core/census/data/resource_no_unit.txt b/test/core/census/data/resource_no_unit.txt
deleted file mode 100644
index c5d5115ceb..0000000000
--- a/test/core/census/data/resource_no_unit.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# The minimal good resource without a unit
-name : 'resource_no_unit'
diff --git a/test/core/census/intrusive_hash_map_test.c b/test/core/census/intrusive_hash_map_test.c
deleted file mode 100644
index 0826b55c63..0000000000
--- a/test/core/census/intrusive_hash_map_test.c
+++ /dev/null
@@ -1,284 +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 "src/core/ext/census/intrusive_hash_map.h"
-
-#include <grpc/support/log.h>
-#include <grpc/support/useful.h>
-#include "test/core/util/test_config.h"
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* The initial size of an intrusive hash map will be 2 to this power. */
-static const uint32_t kInitialLog2Size = 4;
-
-/* Simple object used for testing intrusive_hash_map. */
-typedef struct object { uint64_t val; } object;
-
-/* Helper function to allocate and initialize object. */
-static __inline object *make_new_object(uint64_t val) {
- object *obj = (object *)gpr_malloc(sizeof(object));
- obj->val = val;
- return obj;
-}
-
-/* Wrapper struct for object. */
-typedef struct ptr_item {
- INTRUSIVE_HASH_MAP_HEADER;
- object *obj;
-} ptr_item;
-
-/* Helper function that creates a new hash map item. It is up to the user to
- * free the item that was allocated. */
-static __inline ptr_item *make_ptr_item(uint64_t key, uint64_t value) {
- ptr_item *new_item = (ptr_item *)gpr_malloc(sizeof(ptr_item));
- new_item->IHM_key = key;
- new_item->IHM_hash_link = NULL;
- new_item->obj = make_new_object(value);
- return new_item;
-}
-
-/* Helper function to deallocate ptr_item. */
-static void free_ptr_item(void *ptr) { gpr_free(((ptr_item *)ptr)->obj); }
-
-/* Simple string object used for testing intrusive_hash_map. */
-typedef struct string_item {
- INTRUSIVE_HASH_MAP_HEADER;
- // User data.
- char buf[32];
- uint16_t len;
-} string_item;
-
-/* Helper function to allocate and initialize string object. */
-static string_item *make_string_item(uint64_t key, const char *buf,
- uint16_t len) {
- string_item *item = (string_item *)gpr_malloc(sizeof(string_item));
- item->IHM_key = key;
- item->IHM_hash_link = NULL;
- item->len = len;
- memcpy(item->buf, buf, sizeof(char) * len);
- return item;
-}
-
-/* Helper function for comparing two string objects. */
-static bool compare_string_item(const string_item *A, const string_item *B) {
- if (A->IHM_key != B->IHM_key || A->len != B->len)
- return false;
- else {
- for (int i = 0; i < A->len; ++i) {
- if (A->buf[i] != B->buf[i]) return false;
- }
- }
-
- return true;
-}
-
-void test_empty() {
- intrusive_hash_map hash_map;
- intrusive_hash_map_init(&hash_map, kInitialLog2Size);
- GPR_ASSERT(0 == intrusive_hash_map_size(&hash_map));
- GPR_ASSERT(intrusive_hash_map_empty(&hash_map));
- intrusive_hash_map_free(&hash_map, NULL);
-}
-
-void test_single_item() {
- intrusive_hash_map hash_map;
- intrusive_hash_map_init(&hash_map, kInitialLog2Size);
-
- ptr_item *new_item = make_ptr_item(10, 20);
- bool ok = intrusive_hash_map_insert(&hash_map, (hm_item *)new_item);
- GPR_ASSERT(ok);
-
- ptr_item *item1 =
- (ptr_item *)intrusive_hash_map_find(&hash_map, (uint64_t)10);
- GPR_ASSERT(item1->obj->val == 20);
- GPR_ASSERT(item1 == new_item);
-
- ptr_item *item2 =
- (ptr_item *)intrusive_hash_map_erase(&hash_map, (uint64_t)10);
- GPR_ASSERT(item2 == new_item);
-
- gpr_free(new_item->obj);
- gpr_free(new_item);
- GPR_ASSERT(0 == intrusive_hash_map_size(&hash_map));
- intrusive_hash_map_free(&hash_map, &free_ptr_item);
-}
-
-void test_two_items() {
- intrusive_hash_map hash_map;
- intrusive_hash_map_init(&hash_map, kInitialLog2Size);
-
- string_item *new_item1 = make_string_item(10, "test1", 5);
- bool ok = intrusive_hash_map_insert(&hash_map, (hm_item *)new_item1);
- GPR_ASSERT(ok);
- string_item *new_item2 = make_string_item(20, "test2", 5);
- ok = intrusive_hash_map_insert(&hash_map, (hm_item *)new_item2);
- GPR_ASSERT(ok);
-
- string_item *item1 =
- (string_item *)intrusive_hash_map_find(&hash_map, (uint64_t)10);
- GPR_ASSERT(compare_string_item(new_item1, item1));
- GPR_ASSERT(item1 == new_item1);
- string_item *item2 =
- (string_item *)intrusive_hash_map_find(&hash_map, (uint64_t)20);
- GPR_ASSERT(compare_string_item(new_item2, item2));
- GPR_ASSERT(item2 == new_item2);
-
- item1 = (string_item *)intrusive_hash_map_erase(&hash_map, (uint64_t)10);
- GPR_ASSERT(item1 == new_item1);
- item2 = (string_item *)intrusive_hash_map_erase(&hash_map, (uint64_t)20);
- GPR_ASSERT(item2 == new_item2);
-
- gpr_free(new_item1);
- gpr_free(new_item2);
- GPR_ASSERT(0 == intrusive_hash_map_size(&hash_map));
- intrusive_hash_map_free(&hash_map, NULL);
-}
-
-// Test resetting and clearing the hash map.
-void test_reset_clear() {
- intrusive_hash_map hash_map;
- intrusive_hash_map_init(&hash_map, kInitialLog2Size);
-
- // Add some data to the hash_map.
- for (uint64_t i = 0; i < 3; ++i) {
- intrusive_hash_map_insert(&hash_map, (hm_item *)make_ptr_item(i, i));
- }
- GPR_ASSERT(3 == intrusive_hash_map_size(&hash_map));
-
- // Test find.
- for (uint64_t i = 0; i < 3; ++i) {
- ptr_item *item = (ptr_item *)intrusive_hash_map_find(&hash_map, i);
- GPR_ASSERT(item != NULL);
- GPR_ASSERT(item->IHM_key == i && item->obj->val == i);
- }
-
- intrusive_hash_map_clear(&hash_map, &free_ptr_item);
- GPR_ASSERT(intrusive_hash_map_empty(&hash_map));
- intrusive_hash_map_free(&hash_map, &free_ptr_item);
-}
-
-// Check that the hash_map contains every key between [min_value, max_value]
-// (inclusive).
-void check_hash_map_values(intrusive_hash_map *hash_map, uint64_t min_value,
- uint64_t max_value) {
- GPR_ASSERT(intrusive_hash_map_size(hash_map) == max_value - min_value + 1);
-
- for (uint64_t i = min_value; i <= max_value; ++i) {
- ptr_item *item = (ptr_item *)intrusive_hash_map_find(hash_map, i);
- GPR_ASSERT(item != NULL);
- GPR_ASSERT(item->obj->val == i);
- }
-}
-
-// Add many items and cause the hash_map to extend.
-void test_extend() {
- intrusive_hash_map hash_map;
- intrusive_hash_map_init(&hash_map, kInitialLog2Size);
-
- const uint64_t kNumValues = (1 << 16);
-
- for (uint64_t i = 0; i < kNumValues; ++i) {
- ptr_item *item = make_ptr_item(i, i);
- bool ok = intrusive_hash_map_insert(&hash_map, (hm_item *)item);
- GPR_ASSERT(ok);
- if (i % 1000 == 0) {
- check_hash_map_values(&hash_map, 0, i);
- }
- }
-
- for (uint64_t i = 0; i < kNumValues; ++i) {
- ptr_item *item = (ptr_item *)intrusive_hash_map_find(&hash_map, i);
- GPR_ASSERT(item != NULL);
- GPR_ASSERT(item->IHM_key == i && item->obj->val == i);
- ptr_item *item2 = (ptr_item *)intrusive_hash_map_erase(&hash_map, i);
- GPR_ASSERT(item == item2);
- gpr_free(item->obj);
- gpr_free(item);
- }
-
- GPR_ASSERT(intrusive_hash_map_empty(&hash_map));
- intrusive_hash_map_free(&hash_map, &free_ptr_item);
-}
-
-void test_stress() {
- intrusive_hash_map hash_map;
- intrusive_hash_map_init(&hash_map, kInitialLog2Size);
- size_t n = 0;
-
- // Randomly add and insert entries 1000000 times.
- for (uint64_t i = 0; i < 1000000; ++i) {
- int op = rand() & 0x1;
-
- switch (op) {
- // Case 0 is insertion of entry.
- case 0: {
- uint64_t key = (uint64_t)(rand() % 10000);
- ptr_item *item = make_ptr_item(key, key);
- bool ok = intrusive_hash_map_insert(&hash_map, (hm_item *)item);
- if (ok) {
- n++;
- } else {
- gpr_free(item->obj);
- gpr_free(item);
- }
- break;
- }
- // Case 1 is removal of entry.
- case 1: {
- uint64_t key = (uint64_t)(rand() % 10000);
- ptr_item *item = (ptr_item *)intrusive_hash_map_find(&hash_map, key);
- if (item != NULL) {
- n--;
- GPR_ASSERT(key == item->obj->val);
- ptr_item *item2 =
- (ptr_item *)intrusive_hash_map_erase(&hash_map, key);
- GPR_ASSERT(item == item2);
- gpr_free(item->obj);
- gpr_free(item);
- }
- break;
- }
- }
- }
- // Check size
- GPR_ASSERT(n == intrusive_hash_map_size(&hash_map));
-
- // Clean the hash_map up.
- intrusive_hash_map_clear(&hash_map, &free_ptr_item);
- GPR_ASSERT(intrusive_hash_map_empty(&hash_map));
- intrusive_hash_map_free(&hash_map, &free_ptr_item);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- gpr_time_init();
- srand((unsigned)gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
-
- test_empty();
- test_single_item();
- test_two_items();
- test_reset_clear();
- test_extend();
- test_stress();
-
- return 0;
-}
diff --git a/test/core/census/mlog_test.c b/test/core/census/mlog_test.c
deleted file mode 100644
index 968fd91da4..0000000000
--- a/test/core/census/mlog_test.c
+++ /dev/null
@@ -1,574 +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/census/mlog.h"
-#include <grpc/support/cpu.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-#include <grpc/support/time.h>
-#include <grpc/support/useful.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "test/core/util/test_config.h"
-
-// Change this to non-zero if you want more output.
-#define VERBOSE 0
-
-// Log size to use for all tests.
-#define LOG_SIZE_IN_MB 1
-#define LOG_SIZE_IN_BYTES (LOG_SIZE_IN_MB << 20)
-
-// Fills in 'record' of size 'size'. Each byte in record is filled in with the
-// same value. The value is extracted from 'record' pointer.
-static void write_record(char* record, size_t size) {
- char data = (char)((uintptr_t)record % 255);
- memset(record, data, size);
-}
-
-// Reads fixed size records. Returns the number of records read in
-// 'num_records'.
-static void read_records(size_t record_size, const char* buffer,
- size_t buffer_size, int* num_records) {
- GPR_ASSERT(buffer_size >= record_size);
- GPR_ASSERT(buffer_size % record_size == 0);
- *num_records = (int)(buffer_size / record_size);
- for (int i = 0; i < *num_records; ++i) {
- const char* record = buffer + (record_size * (size_t)i);
- char data = (char)((uintptr_t)record % 255);
- for (size_t j = 0; j < record_size; ++j) {
- GPR_ASSERT(data == record[j]);
- }
- }
-}
-
-// Tries to write the specified number of records. Stops when the log gets
-// full. Returns the number of records written. Spins for random
-// number of times, up to 'max_spin_count', between writes.
-static int write_records_to_log(int writer_id, size_t record_size,
- int num_records, int max_spin_count) {
- int counter = 0;
- for (int i = 0; i < num_records; ++i) {
- int spin_count = max_spin_count ? rand() % max_spin_count : 0;
- if (VERBOSE && (counter++ == num_records / 10)) {
- printf(" Writer %d: %d out of %d written\n", writer_id, i, num_records);
- counter = 0;
- }
- char* record = (char*)(census_log_start_write(record_size));
- if (record == NULL) {
- return i;
- }
- write_record(record, record_size);
- census_log_end_write(record, record_size);
- for (int j = 0; j < spin_count; ++j) {
- GPR_ASSERT(j >= 0);
- }
- }
- return num_records;
-}
-
-// Performs a single read iteration. Returns the number of records read.
-static int perform_read_iteration(size_t record_size) {
- const void* read_buffer = NULL;
- size_t bytes_available;
- int records_read = 0;
- census_log_init_reader();
- while ((read_buffer = census_log_read_next(&bytes_available))) {
- int num_records = 0;
- read_records(record_size, (const char*)read_buffer, bytes_available,
- &num_records);
- records_read += num_records;
- }
- return records_read;
-}
-
-// Asserts that the log is empty.
-static void assert_log_empty(void) {
- census_log_init_reader();
- size_t bytes_available;
- GPR_ASSERT(census_log_read_next(&bytes_available) == NULL);
-}
-
-// Fills the log and verifies data. If 'no fragmentation' is true, records
-// are sized such that CENSUS_LOG_2_MAX_RECORD_SIZE is a multiple of record
-// size. If not a circular log, verifies that the number of records written
-// match the number of records read.
-static void fill_log(size_t log_size, int no_fragmentation, int circular_log) {
- size_t size;
- if (no_fragmentation) {
- int log2size = rand() % (CENSUS_LOG_2_MAX_RECORD_SIZE + 1);
- size = ((size_t)1 << log2size);
- } else {
- while (1) {
- size = 1 + ((size_t)rand() % CENSUS_LOG_MAX_RECORD_SIZE);
- if (CENSUS_LOG_MAX_RECORD_SIZE % size) {
- break;
- }
- }
- }
- int records_written =
- write_records_to_log(0 /* writer id */, size,
- (int)((log_size / size) * 2), 0 /* spin count */);
- int records_read = perform_read_iteration(size);
- if (!circular_log) {
- GPR_ASSERT(records_written == records_read);
- }
- assert_log_empty();
-}
-
-// Structure to pass args to writer_thread
-typedef struct writer_thread_args {
- // Index of this thread in the writers vector.
- int index;
- // Record size.
- size_t record_size;
- // Number of records to write.
- int num_records;
- // Used to signal when writer is complete
- gpr_cv* done;
- gpr_mu* mu;
- int* count;
-} writer_thread_args;
-
-// Writes the given number of records of random size (up to kMaxRecordSize) and
-// random data to the specified log.
-static void writer_thread(void* arg) {
- writer_thread_args* args = (writer_thread_args*)arg;
- // Maximum number of times to spin between writes.
- static const int MAX_SPIN_COUNT = 50;
- int records_written = 0;
- if (VERBOSE) {
- printf(" Writer %d starting\n", args->index);
- }
- while (records_written < args->num_records) {
- records_written += write_records_to_log(args->index, args->record_size,
- args->num_records - records_written,
- MAX_SPIN_COUNT);
- if (records_written < args->num_records) {
- // Ran out of log space. Sleep for a bit and let the reader catch up.
- // This should never happen for circular logs.
- if (VERBOSE) {
- printf(
- " Writer %d stalled due to out-of-space: %d out of %d "
- "written\n",
- args->index, records_written, args->num_records);
- }
- gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(10));
- }
- }
- // Done. Decrement count and signal.
- gpr_mu_lock(args->mu);
- (*args->count)--;
- gpr_cv_signal(args->done);
- if (VERBOSE) {
- printf(" Writer %d done\n", args->index);
- }
- gpr_mu_unlock(args->mu);
-}
-
-// struct to pass args to reader_thread
-typedef struct reader_thread_args {
- // Record size.
- size_t record_size;
- // Interval between read iterations.
- int read_iteration_interval_in_msec;
- // Total number of records.
- int total_records;
- // Signalled when reader should stop.
- gpr_cv stop;
- int stop_flag;
- // Used to signal when reader has finished
- gpr_cv* done;
- gpr_mu* mu;
- int running;
-} reader_thread_args;
-
-// Reads and verifies the specified number of records. Reader can also be
-// stopped via gpr_cv_signal(&args->stop). Sleeps for 'read_interval_in_msec'
-// between read iterations.
-static void reader_thread(void* arg) {
- reader_thread_args* args = (reader_thread_args*)arg;
- if (VERBOSE) {
- printf(" Reader starting\n");
- }
- gpr_timespec interval = gpr_time_from_micros(
- args->read_iteration_interval_in_msec * 1000, GPR_TIMESPAN);
- gpr_mu_lock(args->mu);
- int records_read = 0;
- int num_iterations = 0;
- int counter = 0;
- while (!args->stop_flag && records_read < args->total_records) {
- gpr_cv_wait(&args->stop, args->mu, interval);
- if (!args->stop_flag) {
- records_read += perform_read_iteration(args->record_size);
- GPR_ASSERT(records_read <= args->total_records);
- if (VERBOSE && (counter++ == 100000)) {
- printf(" Reader: %d out of %d read\n", records_read,
- args->total_records);
- counter = 0;
- }
- ++num_iterations;
- }
- }
- // Done
- args->running = 0;
- gpr_cv_signal(args->done);
- if (VERBOSE) {
- printf(" Reader: records: %d, iterations: %d\n", records_read,
- num_iterations);
- }
- gpr_mu_unlock(args->mu);
-}
-
-// Creates NUM_WRITERS writers where each writer writes NUM_RECORDS_PER_WRITER
-// records. Also, starts a reader that iterates over and reads blocks every
-// READ_ITERATION_INTERVAL_IN_MSEC.
-// Number of writers.
-#define NUM_WRITERS 5
-static void multiple_writers_single_reader(int circular_log) {
- // Sleep interval between read iterations.
- static const int READ_ITERATION_INTERVAL_IN_MSEC = 10;
- // Maximum record size.
- static const size_t MAX_RECORD_SIZE = 20;
- // Number of records written by each writer. This is sized such that we
- // will write through the entire log ~10 times.
- const int NUM_RECORDS_PER_WRITER =
- (int)((10 * census_log_remaining_space()) / (MAX_RECORD_SIZE / 2)) /
- NUM_WRITERS;
- size_t record_size = ((size_t)rand() % MAX_RECORD_SIZE) + 1;
- // Create and start writers.
- writer_thread_args writers[NUM_WRITERS];
- int writers_count = NUM_WRITERS;
- gpr_cv writers_done;
- gpr_mu writers_mu; // protects writers_done and writers_count
- gpr_cv_init(&writers_done);
- gpr_mu_init(&writers_mu);
- gpr_thd_id id;
- for (int i = 0; i < NUM_WRITERS; ++i) {
- writers[i].index = i;
- writers[i].record_size = record_size;
- writers[i].num_records = NUM_RECORDS_PER_WRITER;
- writers[i].done = &writers_done;
- writers[i].count = &writers_count;
- writers[i].mu = &writers_mu;
- gpr_thd_new(&id, &writer_thread, &writers[i], NULL);
- }
- // Start reader.
- gpr_cv reader_done;
- gpr_mu reader_mu; // protects reader_done and reader.running
- reader_thread_args reader;
- reader.record_size = record_size;
- reader.read_iteration_interval_in_msec = READ_ITERATION_INTERVAL_IN_MSEC;
- reader.total_records = NUM_WRITERS * NUM_RECORDS_PER_WRITER;
- reader.stop_flag = 0;
- gpr_cv_init(&reader.stop);
- gpr_cv_init(&reader_done);
- reader.done = &reader_done;
- gpr_mu_init(&reader_mu);
- reader.mu = &reader_mu;
- reader.running = 1;
- gpr_thd_new(&id, &reader_thread, &reader, NULL);
- // Wait for writers to finish.
- gpr_mu_lock(&writers_mu);
- while (writers_count != 0) {
- gpr_cv_wait(&writers_done, &writers_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
- }
- gpr_mu_unlock(&writers_mu);
- gpr_mu_destroy(&writers_mu);
- gpr_cv_destroy(&writers_done);
- gpr_mu_lock(&reader_mu);
- if (circular_log) {
- // Stop reader.
- reader.stop_flag = 1;
- gpr_cv_signal(&reader.stop);
- }
- // wait for reader to finish
- while (reader.running) {
- gpr_cv_wait(&reader_done, &reader_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
- }
- if (circular_log) {
- // Assert that there were no out-of-space errors.
- GPR_ASSERT(0 == census_log_out_of_space_count());
- }
- gpr_mu_unlock(&reader_mu);
- gpr_mu_destroy(&reader_mu);
- gpr_cv_destroy(&reader_done);
- if (VERBOSE) {
- printf(" Reader: finished\n");
- }
-}
-
-static void setup_test(int circular_log) {
- census_log_initialize(LOG_SIZE_IN_MB, circular_log);
- // GPR_ASSERT(census_log_remaining_space() == LOG_SIZE_IN_BYTES);
-}
-
-// Attempts to create a record of invalid size (size >
-// CENSUS_LOG_MAX_RECORD_SIZE).
-void test_invalid_record_size(void) {
- static const size_t INVALID_SIZE = CENSUS_LOG_MAX_RECORD_SIZE + 1;
- static const size_t VALID_SIZE = 1;
- printf("Starting test: invalid record size\n");
- setup_test(0);
- void* record = census_log_start_write(INVALID_SIZE);
- GPR_ASSERT(record == NULL);
- // Now try writing a valid record.
- record = census_log_start_write(VALID_SIZE);
- GPR_ASSERT(record != NULL);
- census_log_end_write(record, VALID_SIZE);
- // Verifies that available space went down by one block. In theory, this
- // check can fail if the thread is context switched to a new CPU during the
- // start_write execution (multiple blocks get allocated), but this has not
- // been observed in practice.
- // GPR_ASSERT(LOG_SIZE_IN_BYTES - CENSUS_LOG_MAX_RECORD_SIZE ==
- // census_log_remaining_space());
- census_log_shutdown();
-}
-
-// Tests end_write() with a different size than what was specified in
-// start_write().
-void test_end_write_with_different_size(void) {
- static const size_t START_WRITE_SIZE = 10;
- static const size_t END_WRITE_SIZE = 7;
- printf("Starting test: end write with different size\n");
- setup_test(0);
- void* record_written = census_log_start_write(START_WRITE_SIZE);
- GPR_ASSERT(record_written != NULL);
- census_log_end_write(record_written, END_WRITE_SIZE);
- census_log_init_reader();
- size_t bytes_available;
- const void* record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_written == record_read);
- GPR_ASSERT(END_WRITE_SIZE == bytes_available);
- assert_log_empty();
- census_log_shutdown();
-}
-
-// Verifies that pending records are not available via read_next().
-void test_read_pending_record(void) {
- static const size_t PR_RECORD_SIZE = 1024;
- printf("Starting test: read pending record\n");
- setup_test(0);
- // Start a write.
- void* record_written = census_log_start_write(PR_RECORD_SIZE);
- GPR_ASSERT(record_written != NULL);
- // As write is pending, read should fail.
- census_log_init_reader();
- size_t bytes_available;
- const void* record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_read == NULL);
- // A read followed by end_write() should succeed.
- census_log_end_write(record_written, PR_RECORD_SIZE);
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_written == record_read);
- GPR_ASSERT(PR_RECORD_SIZE == bytes_available);
- assert_log_empty();
- census_log_shutdown();
-}
-
-// Tries reading beyond pending write.
-void test_read_beyond_pending_record(void) {
- printf("Starting test: read beyond pending record\n");
- setup_test(0);
- // Start a write.
- const size_t incomplete_record_size = 10;
- void* incomplete_record = census_log_start_write(incomplete_record_size);
- GPR_ASSERT(incomplete_record != NULL);
- const size_t complete_record_size = 20;
- void* complete_record = census_log_start_write(complete_record_size);
- GPR_ASSERT(complete_record != NULL);
- GPR_ASSERT(complete_record != incomplete_record);
- census_log_end_write(complete_record, complete_record_size);
- // Now iterate over blocks to read completed records.
- census_log_init_reader();
- size_t bytes_available;
- const void* record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(complete_record == record_read);
- GPR_ASSERT(complete_record_size == bytes_available);
- // Complete first record.
- census_log_end_write(incomplete_record, incomplete_record_size);
- // Have read past the incomplete record, so read_next() should return NULL.
- // NB: this test also assumes our thread did not get switched to a different
- // CPU between the two start_write calls
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_read == NULL);
- // Reset reader to get the newly completed record.
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(incomplete_record == record_read);
- GPR_ASSERT(incomplete_record_size == bytes_available);
- assert_log_empty();
- census_log_shutdown();
-}
-
-// Tests scenario where block being read is detached from a core and put on the
-// dirty list.
-void test_detached_while_reading(void) {
- printf("Starting test: detached while reading\n");
- setup_test(0);
- // Start a write.
- static const size_t DWR_RECORD_SIZE = 10;
- void* record_written = census_log_start_write(DWR_RECORD_SIZE);
- GPR_ASSERT(record_written != NULL);
- census_log_end_write(record_written, DWR_RECORD_SIZE);
- // Read this record.
- census_log_init_reader();
- size_t bytes_available;
- const void* record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_read != NULL);
- GPR_ASSERT(DWR_RECORD_SIZE == bytes_available);
- // Now fill the log. This will move the block being read from core-local
- // array to the dirty list.
- while ((record_written = census_log_start_write(DWR_RECORD_SIZE))) {
- census_log_end_write(record_written, DWR_RECORD_SIZE);
- }
-
- // In this iteration, read_next() should only traverse blocks in the
- // core-local array. Therefore, we expect at most gpr_cpu_num_cores() more
- // blocks. As log is full, if read_next() is traversing the dirty list, we
- // will get more than gpr_cpu_num_cores() blocks.
- int block_read = 0;
- while ((record_read = census_log_read_next(&bytes_available))) {
- ++block_read;
- GPR_ASSERT(block_read <= (int)gpr_cpu_num_cores());
- }
- census_log_shutdown();
-}
-
-// Fills non-circular log with records sized such that size is a multiple of
-// CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation).
-void test_fill_log_no_fragmentation(void) {
- printf("Starting test: fill log no fragmentation\n");
- const int circular = 0;
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
- census_log_shutdown();
-}
-
-// Fills circular log with records sized such that size is a multiple of
-// CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation).
-void test_fill_circular_log_no_fragmentation(void) {
- printf("Starting test: fill circular log no fragmentation\n");
- const int circular = 1;
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
- census_log_shutdown();
-}
-
-// Fills non-circular log with records that may straddle end of a block.
-void test_fill_log_with_straddling_records(void) {
- printf("Starting test: fill log with straddling records\n");
- const int circular = 0;
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
- census_log_shutdown();
-}
-
-// Fills circular log with records that may straddle end of a block.
-void test_fill_circular_log_with_straddling_records(void) {
- printf("Starting test: fill circular log with straddling records\n");
- const int circular = 1;
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
- census_log_shutdown();
-}
-
-// Tests scenario where multiple writers and a single reader are using a log
-// that is configured to discard old records.
-void test_multiple_writers_circular_log(void) {
- printf("Starting test: multiple writers circular log\n");
- const int circular = 1;
- setup_test(circular);
- multiple_writers_single_reader(circular);
- census_log_shutdown();
-}
-
-// Tests scenario where multiple writers and a single reader are using a log
-// that is configured to discard old records.
-void test_multiple_writers(void) {
- printf("Starting test: multiple writers\n");
- const int circular = 0;
- setup_test(circular);
- multiple_writers_single_reader(circular);
- census_log_shutdown();
-}
-
-// Repeat the straddling records and multiple writers tests with a small log.
-void test_small_log(void) {
- printf("Starting test: small log\n");
- const int circular = 0;
- census_log_initialize(0, circular);
- size_t log_size = census_log_remaining_space();
- GPR_ASSERT(log_size > 0);
- fill_log(log_size, 0, circular);
- census_log_shutdown();
- census_log_initialize(0, circular);
- multiple_writers_single_reader(circular);
- census_log_shutdown();
-}
-
-void test_performance(void) {
- for (size_t write_size = 1; write_size < CENSUS_LOG_MAX_RECORD_SIZE;
- write_size *= 2) {
- setup_test(0);
- gpr_timespec start_time = gpr_now(GPR_CLOCK_REALTIME);
- int nrecords = 0;
- while (1) {
- void* record = census_log_start_write(write_size);
- if (record == NULL) {
- break;
- }
- census_log_end_write(record, write_size);
- nrecords++;
- }
- gpr_timespec write_time =
- gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start_time);
- double write_time_micro =
- (double)write_time.tv_sec * 1000000 + (double)write_time.tv_nsec / 1000;
- census_log_shutdown();
- printf(
- "Wrote %d %d byte records in %.3g microseconds: %g records/us "
- "(%g ns/record), %g gigabytes/s\n",
- nrecords, (int)write_size, write_time_micro,
- nrecords / write_time_micro, 1000 * write_time_micro / nrecords,
- (double)((int)write_size * nrecords) / write_time_micro / 1000);
- }
-}
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- gpr_time_init();
- srand((unsigned)gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- test_invalid_record_size();
- test_end_write_with_different_size();
- test_read_pending_record();
- test_read_beyond_pending_record();
- test_detached_while_reading();
- test_fill_log_no_fragmentation();
- test_fill_circular_log_no_fragmentation();
- test_fill_log_with_straddling_records();
- test_fill_circular_log_with_straddling_records();
- test_small_log();
- test_multiple_writers();
- test_multiple_writers_circular_log();
- test_performance();
- return 0;
-}
diff --git a/test/core/census/resource_test.c b/test/core/census/resource_test.c
deleted file mode 100644
index 48fc43e45b..0000000000
--- a/test/core/census/resource_test.c
+++ /dev/null
@@ -1,154 +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 "src/core/ext/census/resource.h"
-#include <grpc/census.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/useful.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "src/core/ext/census/base_resources.h"
-#include "test/core/util/test_config.h"
-
-// Test all the functionality for dealing with Resources.
-
-// Just startup and shutdown resources subsystem.
-static void test_enable_disable() {
- initialize_resources();
- shutdown_resources();
-}
-
-// A blank/empty initialization should not work.
-static void test_empty_definition() {
- initialize_resources();
- int32_t rid = census_define_resource(NULL, 0);
- GPR_ASSERT(rid == -1);
- uint8_t buffer[50] = {0};
- rid = census_define_resource(buffer, 50);
- GPR_ASSERT(rid == -1);
- shutdown_resources();
-}
-
-// Given a file name, read raw proto and define the resource included within.
-// Returns resource id from census_define_resource().
-static int32_t define_resource_from_file(const char *file) {
-#define BUF_SIZE 512
- uint8_t buffer[BUF_SIZE];
- FILE *input = fopen(file, "rb");
- GPR_ASSERT(input != NULL);
- size_t nbytes = fread(buffer, 1, BUF_SIZE, input);
- GPR_ASSERT(nbytes != 0 && nbytes < BUF_SIZE && feof(input) && !ferror(input));
- int32_t rid = census_define_resource(buffer, nbytes);
- GPR_ASSERT(fclose(input) == 0);
- return rid;
-}
-
-// Test definition of a single resource, using a proto read from a file. The
-// `succeed` parameter indicates whether we expect the definition to succeed or
-// fail. `name` is used to check that the returned resource can be looked up by
-// name.
-static void test_define_single_resource(const char *file, const char *name,
- bool succeed) {
- gpr_log(GPR_INFO, "Test defining resource \"%s\"\n", name);
- initialize_resources();
- int32_t rid = define_resource_from_file(file);
- if (succeed) {
- GPR_ASSERT(rid >= 0);
- int32_t rid2 = census_resource_id(name);
- GPR_ASSERT(rid == rid2);
- } else {
- GPR_ASSERT(rid < 0);
- }
- shutdown_resources();
-}
-
-// Try deleting various resources (both those that exist and those that don't).
-static void test_delete_resource(const char *minimal_good, const char *full) {
- initialize_resources();
- // Try deleting resource before any are defined.
- census_delete_resource(0);
- // Create and check a couple of resources.
- int32_t rid1 = define_resource_from_file(minimal_good);
- int32_t rid2 = define_resource_from_file(full);
- GPR_ASSERT(rid1 >= 0 && rid2 >= 0 && rid1 != rid2);
- int32_t rid3 = census_resource_id("minimal_good");
- int32_t rid4 = census_resource_id("full_resource");
- GPR_ASSERT(rid1 == rid3 && rid2 == rid4);
- // Try deleting non-existant resources.
- census_delete_resource(-1);
- census_delete_resource(rid1 + rid2 + 1);
- census_delete_resource(10000000);
- // Delete one of the previously defined resources and check for deletion.
- census_delete_resource(rid1);
- rid3 = census_resource_id("minimal_good");
- GPR_ASSERT(rid3 < 0);
- // Check that re-adding works.
- rid1 = define_resource_from_file(minimal_good);
- GPR_ASSERT(rid1 >= 0);
- rid3 = census_resource_id("minimal_good");
- GPR_ASSERT(rid1 == rid3);
- shutdown_resources();
-}
-
-// Test define base resources.
-static void test_base_resources() {
- initialize_resources();
- define_base_resources();
- int32_t rid1 = census_resource_id("client_rpc_latency");
- int32_t rid2 = census_resource_id("server_rpc_latency");
- GPR_ASSERT(rid1 >= 0 && rid2 >= 0 && rid1 != rid2);
- shutdown_resources();
-}
-
-int main(int argc, char **argv) {
- const char *resource_empty_name_pb, *resource_full_pb,
- *resource_minimal_good_pb, *resource_no_name_pb,
- *resource_no_numerator_pb, *resource_no_unit_pb;
- if (argc == 7) {
- resource_empty_name_pb = argv[1];
- resource_full_pb = argv[2];
- resource_minimal_good_pb = argv[3];
- resource_no_name_pb = argv[4];
- resource_no_numerator_pb = argv[5];
- resource_no_unit_pb = argv[6];
- } else {
- GPR_ASSERT(argc == 1);
- resource_empty_name_pb = "test/core/census/data/resource_empty_name.pb";
- resource_full_pb = "test/core/census/data/resource_full.pb";
- resource_minimal_good_pb = "test/core/census/data/resource_minimal_good.pb";
- resource_no_name_pb = "test/core/census/data/resource_no_name.pb";
- resource_no_numerator_pb = "test/core/census/data/resource_no_numerator.pb";
- resource_no_unit_pb = "test/core/census/data/resource_no_unit.pb";
- }
- grpc_test_init(argc, argv);
- test_enable_disable();
- test_empty_definition();
- test_define_single_resource(resource_minimal_good_pb, "minimal_good", true);
- test_define_single_resource(resource_full_pb, "full_resource", true);
- test_define_single_resource(resource_no_name_pb, "resource_no_name", false);
- test_define_single_resource(resource_no_numerator_pb, "resource_no_numerator",
- false);
- test_define_single_resource(resource_no_unit_pb, "resource_no_unit", false);
- test_define_single_resource(resource_empty_name_pb, "resource_empty_name",
- false);
- test_delete_resource(resource_minimal_good_pb, resource_full_pb);
- test_base_resources();
- return 0;
-}
diff --git a/test/core/census/trace_context_test.c b/test/core/census/trace_context_test.c
deleted file mode 100644
index 6eb831a85e..0000000000
--- a/test/core/census/trace_context_test.c
+++ /dev/null
@@ -1,215 +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 <grpc/census.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/useful.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "src/core/ext/census/base_resources.h"
-#include "src/core/ext/census/resource.h"
-#include "test/core/util/test_config.h"
-
-#include "src/core/ext/census/gen/trace_context.pb.h"
-#include "src/core/ext/census/trace_context.h"
-#include "third_party/nanopb/pb_decode.h"
-#include "third_party/nanopb/pb_encode.h"
-
-#define BUF_SIZE 256
-
-/* Encodes a TraceContext structure (ctxt1) to a buffer, and then decodes it
-to a second TraceContext (ctxt2). Validates that the resulting TraceContext
-has a span_id, trace_id, and that the values are equal to those in initial
-TraceContext. On success, returns true. If encode_trace_context returns 0,
-decode_trace_context fails, or the resulting TraceContext is missing a trace_id
-or span_id, it will return false. */
-bool validate_encode_decode_context(google_trace_TraceContext *ctxt1,
- uint8_t *buffer, size_t buf_size) {
- google_trace_TraceContext ctxt2 = google_trace_TraceContext_init_zero;
- size_t msg_length;
-
- msg_length = encode_trace_context(ctxt1, buffer, buf_size);
- if (msg_length == 0) {
- return false;
- }
-
- if (!decode_trace_context(&ctxt2, buffer, msg_length)) {
- return false;
- }
-
- if (!ctxt2.has_trace_id_hi || !ctxt2.has_trace_id_lo || !ctxt2.has_span_id) {
- return false;
- }
-
- GPR_ASSERT(ctxt1->trace_id_hi == ctxt2.trace_id_hi &&
- ctxt1->trace_id_lo == ctxt2.trace_id_lo &&
- ctxt1->span_id == ctxt2.span_id &&
- ctxt1->has_span_options == ctxt2.has_span_options &&
- (ctxt1->has_span_options
- ? ctxt1->span_options == ctxt2.span_options
- : true));
-
- return true;
-}
-
-/* Decodes a proto-encoded TraceContext from a buffer. If decode_trace_context
-fails or the resulting TraceContext is missing a trace_id or span_id it will
-return false, otherwise returns true. */
-bool validate_decode_context(google_trace_TraceContext *ctxt, uint8_t *buffer,
- size_t msg_length) {
- // Validate the decoding of a context written to buffer.
- if (!decode_trace_context(ctxt, buffer, msg_length)) {
- return false;
- }
-
- if (!ctxt->has_trace_id_hi || !ctxt->has_trace_id_lo || !ctxt->has_span_id) {
- return false;
- }
-
- return true;
-}
-
-/* Read an encoded trace context from a file. Validates that the decoding
-gives the expected result (succeed). */
-static void read_and_validate_context_from_file(google_trace_TraceContext *ctxt,
- const char *file,
- const bool succeed) {
- uint8_t buffer[BUF_SIZE];
- FILE *input = fopen(file, "rb");
- GPR_ASSERT(input != NULL);
- size_t nbytes = fread(buffer, 1, BUF_SIZE, input);
- GPR_ASSERT(nbytes <= BUF_SIZE && feof(input) && !ferror(input));
- bool res = validate_decode_context(ctxt, buffer, nbytes);
- GPR_ASSERT(res == succeed);
- GPR_ASSERT(fclose(input) == 0);
-}
-
-// Test full proto-buffer.
-static void test_full() {
- google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero;
- read_and_validate_context_from_file(
- &ctxt, "test/core/census/data/context_full.pb", true);
-}
-
-// Test empty proto-buffer.
-static void test_empty() {
- google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero;
- read_and_validate_context_from_file(
- &ctxt, "test/core/census/data/context_empty.pb", false);
-}
-
-// Test proto-buffer with only trace_id.
-static void test_trace_only() {
- google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero;
- read_and_validate_context_from_file(
- &ctxt, "test/core/census/data/context_trace_only.pb", false);
-}
-
-// Test proto-buffer with only span_id.
-static void test_span_only() {
- google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero;
- read_and_validate_context_from_file(
- &ctxt, "test/core/census/data/context_span_only.pb", false);
-}
-
-// Test proto-buffer without span_options value.
-static void test_no_span_options() {
- google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero;
- read_and_validate_context_from_file(
- &ctxt, "test/core/census/data/context_no_span_options.pb", true);
- GPR_ASSERT(ctxt.has_span_options == false && ctxt.span_options == 0);
-}
-
-static void test_encode_decode() {
- uint8_t buffer[BUF_SIZE] = {0};
-
- google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero;
- ctxt1.has_trace_id_hi = true;
- ctxt1.has_trace_id_lo = true;
- ctxt1.trace_id_lo = 1;
- ctxt1.trace_id_hi = 2;
- ctxt1.has_span_id = true;
- ctxt1.span_id = 3;
- validate_encode_decode_context(&ctxt1, buffer, sizeof(buffer));
-
- // Missing trace_id. This should fail.
- google_trace_TraceContext ctxt2 = google_trace_TraceContext_init_zero;
- ctxt2.has_trace_id_hi = false;
- ctxt2.has_trace_id_lo = false;
- ctxt2.has_span_id = true;
- validate_encode_decode_context(&ctxt2, buffer, sizeof(buffer));
-}
-
-// Test a corrupted proto-buffer. This should fail.
-static void test_corrupt() {
- uint8_t buffer[BUF_SIZE] = {0};
- google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero;
- size_t msg_length;
-
- ctxt1.has_trace_id_hi = true;
- ctxt1.has_trace_id_lo = true;
- ctxt1.trace_id_lo = 1;
- ctxt1.trace_id_hi = 2;
- ctxt1.has_span_id = true;
- ctxt1.span_id = 3;
- ctxt1.has_span_options = true;
- ctxt1.span_options = SPAN_OPTIONS_IS_SAMPLED;
- msg_length = encode_trace_context(&ctxt1, buffer, sizeof(buffer));
-
- /* Corrupt some bytes. 255 (0xFF) should be illegal for the first byte of the
- proto encoded object. */
- buffer[0] = 255;
-
- bool res = validate_decode_context(&ctxt1, buffer, msg_length);
- GPR_ASSERT(res == false);
-}
-
-static void test_buffer_size() {
- // This buffer is too small. This should fail.
- uint8_t buffer[16] = {0};
- google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero;
- size_t msg_length;
-
- ctxt1.has_trace_id_hi = true;
- ctxt1.has_trace_id_lo = true;
- ctxt1.trace_id_lo = 1;
- ctxt1.trace_id_hi = 2;
- ctxt1.has_span_id = true;
- ctxt1.span_id = 3;
- ctxt1.has_span_options = true;
- ctxt1.span_options = SPAN_OPTIONS_IS_SAMPLED;
- msg_length = encode_trace_context(&ctxt1, buffer, sizeof(buffer));
-
- GPR_ASSERT(msg_length == 0);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- test_full();
- test_empty();
- test_trace_only();
- test_span_only();
- test_encode_decode();
- test_corrupt();
- test_no_span_options();
- test_buffer_size();
-
- return 0;
-}
diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD
index 5ac77c449b..92f5907aac 100644
--- a/test/core/channel/BUILD
+++ b/test/core/channel/BUILD
@@ -20,8 +20,8 @@ licenses(["notice"]) # Apache v2
grpc_cc_test(
name = "channel_args_test",
- srcs = ["channel_args_test.c"],
- language = "C",
+ srcs = ["channel_args_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -32,8 +32,8 @@ grpc_cc_test(
grpc_cc_test(
name = "channel_stack_test",
- srcs = ["channel_stack_test.c"],
- language = "C",
+ srcs = ["channel_stack_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +44,8 @@ grpc_cc_test(
grpc_cc_test(
name = "channel_stack_builder_test",
- srcs = ["channel_stack_builder_test.c"],
- language = "C",
+ srcs = ["channel_stack_builder_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.cc
index deaf2933ec..5b0a770c84 100644
--- a/test/core/channel/channel_args_test.c
+++ b/test/core/channel/channel_args_test.cc
@@ -26,24 +26,24 @@
#include "test/core/util/test_config.h"
static void test_create(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_arg arg_int;
grpc_arg arg_string;
grpc_arg to_add[2];
- grpc_channel_args *ch_args;
+ grpc_channel_args* ch_args;
- arg_int.key = "int_arg";
+ arg_int.key = const_cast<char*>("int_arg");
arg_int.type = GRPC_ARG_INTEGER;
arg_int.value.integer = 123;
- arg_string.key = "str key";
+ arg_string.key = const_cast<char*>("str key");
arg_string.type = GRPC_ARG_STRING;
- arg_string.value.string = "str value";
+ arg_string.value.string = const_cast<char*>("str value");
to_add[0] = arg_int;
to_add[1] = arg_string;
- ch_args = grpc_channel_args_copy_and_add(NULL, to_add, 2);
+ ch_args = grpc_channel_args_copy_and_add(nullptr, to_add, 2);
GPR_ASSERT(ch_args->num_args == 2);
GPR_ASSERT(strcmp(ch_args->args[0].key, arg_int.key) == 0);
@@ -55,32 +55,31 @@ static void test_create(void) {
GPR_ASSERT(strcmp(ch_args->args[1].value.string, arg_string.value.string) ==
0);
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_set_compression_algorithm(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *ch_args;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args* ch_args;
- ch_args =
- grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_GZIP);
+ ch_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, GRPC_COMPRESS_MESSAGE_GZIP);
GPR_ASSERT(ch_args->num_args == 1);
GPR_ASSERT(strcmp(ch_args->args[0].key,
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER);
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_compression_algorithm_states(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate,
+ *ch_args_wo_gzip_deflate_gzip;
unsigned states_bitset;
size_t i;
- ch_args = grpc_channel_args_copy_and_add(NULL, NULL, 0);
+ ch_args = grpc_channel_args_copy_and_add(nullptr, nullptr, 0);
/* by default, all enabled */
states_bitset =
(unsigned)grpc_channel_args_compression_algorithm_get_states(ch_args);
@@ -89,61 +88,66 @@ static void test_compression_algorithm_states(void) {
GPR_ASSERT(GPR_BITGET(states_bitset, i));
}
- /* disable gzip and deflate */
+ /* disable message/gzip and message/deflate and stream/gzip */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args, GRPC_COMPRESS_GZIP, 0);
+ &ch_args, GRPC_COMPRESS_MESSAGE_GZIP, 0);
GPR_ASSERT(ch_args == ch_args_wo_gzip);
ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
+ &ch_args_wo_gzip, GRPC_COMPRESS_MESSAGE_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
+ ch_args_wo_gzip_deflate_gzip =
+ grpc_channel_args_compression_algorithm_set_state(
+ &ch_args_wo_gzip_deflate, GRPC_COMPRESS_STREAM_GZIP, 0);
+ GPR_ASSERT(ch_args_wo_gzip_deflate == ch_args_wo_gzip_deflate_gzip);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
ch_args_wo_gzip_deflate);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
- if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) {
+ if (i == GRPC_COMPRESS_MESSAGE_GZIP || i == GRPC_COMPRESS_MESSAGE_DEFLATE ||
+ i == GRPC_COMPRESS_STREAM_GZIP) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
} else {
GPR_ASSERT(GPR_BITGET(states_bitset, i) != 0);
}
}
- /* re-enabled gzip only */
+ /* re-enabled message/gzip and stream/gzip only */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
- GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
+ &ch_args_wo_gzip_deflate_gzip, GRPC_COMPRESS_MESSAGE_GZIP, 1);
+ ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
+ &ch_args_wo_gzip, GRPC_COMPRESS_STREAM_GZIP, 1);
+ GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate_gzip);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
ch_args_wo_gzip);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
- if (i == GRPC_COMPRESS_DEFLATE) {
+ if (i == GRPC_COMPRESS_MESSAGE_DEFLATE) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
} else {
GPR_ASSERT(GPR_BITGET(states_bitset, i) != 0);
}
}
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_set_socket_mutator(void) {
- grpc_channel_args *ch_args;
+ grpc_channel_args* ch_args;
grpc_socket_mutator mutator;
- grpc_socket_mutator_init(&mutator, NULL);
+ grpc_socket_mutator_init(&mutator, nullptr);
- ch_args = grpc_channel_args_set_socket_mutator(NULL, &mutator);
+ ch_args = grpc_channel_args_set_socket_mutator(nullptr, &mutator);
GPR_ASSERT(ch_args->num_args == 1);
GPR_ASSERT(strcmp(ch_args->args[0].key, GRPC_ARG_SOCKET_MUTATOR) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_POINTER);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(ch_args);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_create();
diff --git a/test/core/channel/channel_stack_builder_test.c b/test/core/channel/channel_stack_builder_test.cc
index 682efd1438..ef6db81b0b 100644
--- a/test/core/channel/channel_stack_builder_test.c
+++ b/test/core/channel/channel_stack_builder_test.cc
@@ -29,50 +29,46 @@
#include "src/core/lib/surface/channel_init.h"
#include "test/core/util/test_config.h"
-static grpc_error *channel_init_func(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* channel_init_func(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static grpc_error *call_init_func(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+static grpc_error* call_init_func(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void channel_destroy_func(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void channel_destroy_func(grpc_channel_element* elem) {}
-static void call_destroy_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {}
+static void call_destroy_func(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {}
-static void call_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {}
+static void call_func(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {}
-static void channel_func(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_transport_op *op) {
+static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
bool g_replacement_fn_called = false;
bool g_original_fn_called = false;
-void set_arg_once_fn(grpc_channel_stack *channel_stack,
- grpc_channel_element *elem, void *arg) {
- bool *called = arg;
+void set_arg_once_fn(grpc_channel_stack* channel_stack,
+ grpc_channel_element* elem, void* arg) {
+ bool* called = static_cast<bool*>(arg);
// Make sure this function is only called once per arg.
GPR_ASSERT(*called == false);
*called = true;
}
static void test_channel_stack_builder_filter_replace(void) {
- grpc_channel *channel =
- grpc_insecure_channel_create("target name isn't used", NULL, NULL);
- GPR_ASSERT(channel != NULL);
+ grpc_channel* channel =
+ grpc_insecure_channel_create("target name isn't used", nullptr, nullptr);
+ GPR_ASSERT(channel != nullptr);
// Make sure the high priority filter has been created.
GPR_ASSERT(g_replacement_fn_called);
// ... and that the low priority one hasn't.
@@ -106,10 +102,10 @@ const grpc_channel_filter original_filter = {
grpc_channel_next_get_info,
"filter_name"};
-static bool add_replacement_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
- const grpc_channel_filter *filter = arg;
+static bool add_replacement_filter(grpc_channel_stack_builder* builder,
+ void* arg) {
+ const grpc_channel_filter* filter =
+ static_cast<const grpc_channel_filter*>(arg);
// Get rid of any other version of the filter, as determined by having the
// same name.
GPR_ASSERT(grpc_channel_stack_builder_remove_filter(builder, filter->name));
@@ -117,26 +113,25 @@ static bool add_replacement_filter(grpc_exec_ctx *exec_ctx,
builder, filter, set_arg_once_fn, &g_replacement_fn_called);
}
-static bool add_original_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
+static bool add_original_filter(grpc_channel_stack_builder* builder,
+ void* arg) {
return grpc_channel_stack_builder_prepend_filter(
- builder, (const grpc_channel_filter *)arg, set_arg_once_fn,
+ builder, (const grpc_channel_filter*)arg, set_arg_once_fn,
&g_original_fn_called);
}
static void init_plugin(void) {
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
add_original_filter,
- (void *)&original_filter);
+ (void*)&original_filter);
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
add_replacement_filter,
- (void *)&replacement_filter);
+ (void*)&replacement_filter);
}
static void destroy_plugin(void) {}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_register_plugin(init_plugin, destroy_plugin);
grpc_init();
diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c
deleted file mode 100644
index 7c3614b4a2..0000000000
--- a/test/core/channel/channel_stack_test.c
+++ /dev/null
@@ -1,157 +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/channel/channel_stack.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-
-#include "src/core/lib/slice/slice_internal.h"
-#include "test/core/util/test_config.h"
-
-static grpc_error *channel_init_func(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
- GPR_ASSERT(args->channel_args->num_args == 1);
- GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER);
- GPR_ASSERT(0 == strcmp(args->channel_args->args[0].key, "test_key"));
- GPR_ASSERT(args->channel_args->args[0].value.integer == 42);
- GPR_ASSERT(args->is_first);
- GPR_ASSERT(args->is_last);
- *(int *)(elem->channel_data) = 0;
- return GRPC_ERROR_NONE;
-}
-
-static grpc_error *call_init_func(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- ++*(int *)(elem->channel_data);
- *(int *)(elem->call_data) = 0;
- return GRPC_ERROR_NONE;
-}
-
-static void channel_destroy_func(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
-
-static void call_destroy_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
- ++*(int *)(elem->channel_data);
-}
-
-static void call_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- ++*(int *)(elem->call_data);
-}
-
-static void channel_func(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_transport_op *op) {
- ++*(int *)(elem->channel_data);
-}
-
-static void free_channel(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_channel_stack_destroy(exec_ctx, arg);
- gpr_free(arg);
-}
-
-static void free_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- grpc_call_stack_destroy(exec_ctx, arg, NULL, NULL);
- gpr_free(arg);
-}
-
-static void test_create_channel_stack(void) {
- const grpc_channel_filter filter = {
- call_func,
- channel_func,
- sizeof(int),
- call_init_func,
- grpc_call_stack_ignore_set_pollset_or_pollset_set,
- call_destroy_func,
- sizeof(int),
- channel_init_func,
- channel_destroy_func,
- grpc_channel_next_get_info,
- "some_test_filter"};
- const grpc_channel_filter *filters = &filter;
- grpc_channel_stack *channel_stack;
- grpc_call_stack *call_stack;
- grpc_channel_element *channel_elem;
- grpc_call_element *call_elem;
- grpc_arg arg;
- grpc_channel_args chan_args;
- int *channel_data;
- int *call_data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice path = grpc_slice_from_static_string("/service/method");
-
- arg.type = GRPC_ARG_INTEGER;
- arg.key = "test_key";
- arg.value.integer = 42;
-
- chan_args.num_args = 1;
- chan_args.args = &arg;
-
- channel_stack = gpr_malloc(grpc_channel_stack_size(&filters, 1));
- grpc_channel_stack_init(&exec_ctx, 1, free_channel, channel_stack, &filters,
- 1, &chan_args, NULL, "test", channel_stack);
- GPR_ASSERT(channel_stack->count == 1);
- channel_elem = grpc_channel_stack_element(channel_stack, 0);
- channel_data = (int *)channel_elem->channel_data;
- GPR_ASSERT(*channel_data == 0);
-
- call_stack = gpr_malloc(channel_stack->call_stack_size);
- const grpc_call_element_args args = {
- .call_stack = call_stack,
- .server_transport_data = NULL,
- .context = NULL,
- .path = path,
- .start_time = gpr_now(GPR_CLOCK_MONOTONIC),
- .deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC),
- .arena = NULL};
- grpc_error *error = grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- free_call, call_stack, &args);
- GPR_ASSERT(error == GRPC_ERROR_NONE);
- GPR_ASSERT(call_stack->count == 1);
- call_elem = grpc_call_stack_element(call_stack, 0);
- GPR_ASSERT(call_elem->filter == channel_elem->filter);
- GPR_ASSERT(call_elem->channel_data == channel_elem->channel_data);
- call_data = (int *)call_elem->call_data;
- GPR_ASSERT(*call_data == 0);
- GPR_ASSERT(*channel_data == 1);
-
- GRPC_CALL_STACK_UNREF(&exec_ctx, call_stack, "done");
- grpc_exec_ctx_flush(&exec_ctx);
- GPR_ASSERT(*channel_data == 2);
-
- GRPC_CHANNEL_STACK_UNREF(&exec_ctx, channel_stack, "done");
-
- grpc_slice_unref_internal(&exec_ctx, path);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- grpc_init();
- test_create_channel_stack();
- grpc_shutdown();
- return 0;
-}
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
new file mode 100644
index 0000000000..ef43facd6e
--- /dev/null
+++ b/test/core/channel/channel_stack_test.cc
@@ -0,0 +1,155 @@
+/*
+ *
+ * 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/channel/channel_stack.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/slice/slice_internal.h"
+#include "test/core/util/test_config.h"
+
+static grpc_error* channel_init_func(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ GPR_ASSERT(args->channel_args->num_args == 1);
+ GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER);
+ GPR_ASSERT(0 == strcmp(args->channel_args->args[0].key, "test_key"));
+ GPR_ASSERT(args->channel_args->args[0].value.integer == 42);
+ GPR_ASSERT(args->is_first);
+ GPR_ASSERT(args->is_last);
+ *(int*)(elem->channel_data) = 0;
+ return GRPC_ERROR_NONE;
+}
+
+static grpc_error* call_init_func(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ ++*(int*)(elem->channel_data);
+ *(int*)(elem->call_data) = 0;
+ return GRPC_ERROR_NONE;
+}
+
+static void channel_destroy_func(grpc_channel_element* elem) {}
+
+static void call_destroy_func(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ ++*(int*)(elem->channel_data);
+}
+
+static void call_func(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
+ ++*(int*)(elem->call_data);
+}
+
+static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
+ ++*(int*)(elem->channel_data);
+}
+
+static void free_channel(void* arg, grpc_error* error) {
+ grpc_channel_stack_destroy(static_cast<grpc_channel_stack*>(arg));
+ gpr_free(arg);
+}
+
+static void free_call(void* arg, grpc_error* error) {
+ grpc_call_stack_destroy(static_cast<grpc_call_stack*>(arg), nullptr, nullptr);
+ gpr_free(arg);
+}
+
+static void test_create_channel_stack(void) {
+ const grpc_channel_filter filter = {
+ call_func,
+ channel_func,
+ sizeof(int),
+ call_init_func,
+ grpc_call_stack_ignore_set_pollset_or_pollset_set,
+ call_destroy_func,
+ sizeof(int),
+ channel_init_func,
+ channel_destroy_func,
+ grpc_channel_next_get_info,
+ "some_test_filter"};
+ const grpc_channel_filter* filters = &filter;
+ grpc_channel_stack* channel_stack;
+ grpc_call_stack* call_stack;
+ grpc_channel_element* channel_elem;
+ grpc_call_element* call_elem;
+ grpc_arg arg;
+ grpc_channel_args chan_args;
+ int* channel_data;
+ int* call_data;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice path = grpc_slice_from_static_string("/service/method");
+
+ arg.type = GRPC_ARG_INTEGER;
+ arg.key = const_cast<char*>("test_key");
+ arg.value.integer = 42;
+
+ chan_args.num_args = 1;
+ chan_args.args = &arg;
+
+ channel_stack = static_cast<grpc_channel_stack*>(
+ gpr_malloc(grpc_channel_stack_size(&filters, 1)));
+ grpc_channel_stack_init(1, free_channel, channel_stack, &filters, 1,
+ &chan_args, nullptr, "test", channel_stack);
+ GPR_ASSERT(channel_stack->count == 1);
+ channel_elem = grpc_channel_stack_element(channel_stack, 0);
+ channel_data = (int*)channel_elem->channel_data;
+ GPR_ASSERT(*channel_data == 0);
+
+ call_stack =
+ static_cast<grpc_call_stack*>(gpr_malloc(channel_stack->call_stack_size));
+ const grpc_call_element_args args = {
+ call_stack, /* call_stack */
+ nullptr, /* server_transport_data */
+ nullptr, /* context */
+ path, /* path */
+ gpr_now(GPR_CLOCK_MONOTONIC), /* start_time */
+ GRPC_MILLIS_INF_FUTURE, /* deadline */
+ nullptr, /* arena */
+ nullptr /* call_combiner */
+ };
+ grpc_error* error =
+ grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
+ GPR_ASSERT(call_stack->count == 1);
+ call_elem = grpc_call_stack_element(call_stack, 0);
+ GPR_ASSERT(call_elem->filter == channel_elem->filter);
+ GPR_ASSERT(call_elem->channel_data == channel_elem->channel_data);
+ call_data = (int*)call_elem->call_data;
+ GPR_ASSERT(*call_data == 0);
+ GPR_ASSERT(*channel_data == 1);
+
+ GRPC_CALL_STACK_UNREF(call_stack, "done");
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(*channel_data == 2);
+
+ GRPC_CHANNEL_STACK_UNREF(channel_stack, "done");
+
+ grpc_slice_unref_internal(path);
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ test_create_channel_stack();
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.cc
index b4528346f7..f02c8180f2 100644
--- a/test/core/channel/minimal_stack_is_minimal_test.c
+++ b/test/core/channel/minimal_stack_is_minimal_test.cc
@@ -35,15 +35,15 @@
#include <string.h>
#include "src/core/lib/channel/channel_stack_builder.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/transport_impl.h"
#include "test/core/util/test_config.h"
// use CHECK_STACK instead
-static int check_stack(const char *file, int line, const char *transport_name,
- grpc_channel_args *init_args,
+static int check_stack(const char* file, int line, const char* transport_name,
+ grpc_channel_args* init_args,
unsigned channel_stack_type, ...);
// arguments: const char *transport_name - the name of the transport type to
@@ -55,17 +55,17 @@ static int check_stack(const char *file, int line, const char *transport_name,
// filters to instantiate, terminated with NULL
#define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__)
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
int errors = 0;
// tests with a minimal stack
- grpc_arg minimal_stack_arg = {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MINIMAL_STACK,
- .value.integer = 1};
- grpc_channel_args minimal_stack_args = {.num_args = 1,
- .args = &minimal_stack_arg};
+ grpc_arg minimal_stack_arg;
+ minimal_stack_arg.type = GRPC_ARG_INTEGER;
+ minimal_stack_arg.key = const_cast<char*>(GRPC_ARG_MINIMAL_STACK);
+ minimal_stack_arg.value.integer = 1;
+ grpc_channel_args minimal_stack_args = {1, &minimal_stack_arg};
errors += CHECK_STACK("unknown", &minimal_stack_args,
GRPC_CLIENT_DIRECT_CHANNEL, "connected", NULL);
errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL,
@@ -79,26 +79,27 @@ int main(int argc, char **argv) {
"http-client", "connected", NULL);
errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL,
"server", "http-server", "connected", NULL);
- errors += CHECK_STACK(NULL, &minimal_stack_args, GRPC_CLIENT_CHANNEL,
+ errors += CHECK_STACK(nullptr, &minimal_stack_args, GRPC_CLIENT_CHANNEL,
"client-channel", NULL);
// tests with a default stack
- errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL,
+ errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_DIRECT_CHANNEL,
"message_size", "deadline", "connected", NULL);
- errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "message_size",
- "connected", NULL);
- errors += CHECK_STACK("unknown", NULL, GRPC_SERVER_CHANNEL, "server",
+ errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_SUBCHANNEL,
+ "message_size", "connected", NULL);
+ errors += CHECK_STACK("unknown", nullptr, GRPC_SERVER_CHANNEL, "server",
"message_size", "deadline", "connected", NULL);
- errors += CHECK_STACK("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL,
+ errors += CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_DIRECT_CHANNEL,
"message_size", "deadline", "http-client",
"message_compress", "connected", NULL);
- errors += CHECK_STACK("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "message_size",
- "http-client", "message_compress", "connected", NULL);
- errors += CHECK_STACK("chttp2", NULL, GRPC_SERVER_CHANNEL, "server",
+ errors +=
+ CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_SUBCHANNEL, "message_size",
+ "http-client", "message_compress", "connected", NULL);
+ errors += CHECK_STACK("chttp2", nullptr, GRPC_SERVER_CHANNEL, "server",
"message_size", "deadline", "http-server",
"message_compress", "connected", NULL);
- errors +=
- CHECK_STACK(NULL, NULL, GRPC_CLIENT_CHANNEL, "client-channel", NULL);
+ errors += CHECK_STACK(nullptr, nullptr, GRPC_CLIENT_CHANNEL, "client-channel",
+ NULL);
GPR_ASSERT(errors == 0);
grpc_shutdown();
@@ -109,25 +110,25 @@ int main(int argc, char **argv) {
* End of tests definitions, start of test infrastructure
*/
-static int check_stack(const char *file, int line, const char *transport_name,
- grpc_channel_args *init_args,
+static int check_stack(const char* file, int line, const char* transport_name,
+ grpc_channel_args* init_args,
unsigned channel_stack_type, ...) {
// create dummy channel stack
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
- grpc_transport_vtable fake_transport_vtable = {.name = transport_name};
- grpc_transport fake_transport = {.vtable = &fake_transport_vtable};
+ grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
+ grpc_transport_vtable fake_transport_vtable;
+ memset(&fake_transport_vtable, 0, sizeof(grpc_transport_vtable));
+ fake_transport_vtable.name = transport_name;
+ grpc_transport fake_transport = {&fake_transport_vtable};
grpc_channel_stack_builder_set_target(builder, "foo.test.google.fr");
- grpc_channel_args *channel_args = grpc_channel_args_copy(init_args);
- if (transport_name != NULL) {
+ grpc_channel_args* channel_args = grpc_channel_args_copy(init_args);
+ if (transport_name != nullptr) {
grpc_channel_stack_builder_set_transport(builder, &fake_transport);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_stack_builder_set_channel_arguments(&exec_ctx, builder,
- channel_args);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_stack_builder_set_channel_arguments(builder, channel_args);
GPR_ASSERT(grpc_channel_init_create_stack(
- &exec_ctx, builder, (grpc_channel_stack_type)channel_stack_type));
- grpc_exec_ctx_finish(&exec_ctx);
+ builder, (grpc_channel_stack_type)channel_stack_type));
}
// build up our expectation list
@@ -136,26 +137,26 @@ static int check_stack(const char *file, int line, const char *transport_name,
va_list args;
va_start(args, channel_stack_type);
for (;;) {
- char *a = va_arg(args, char *);
- if (a == NULL) break;
+ char* a = va_arg(args, char*);
+ if (a == nullptr) break;
if (v.count != 0) gpr_strvec_add(&v, gpr_strdup(", "));
gpr_strvec_add(&v, gpr_strdup(a));
}
va_end(args);
- char *expect = gpr_strvec_flatten(&v, NULL);
+ char* expect = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
// build up our "got" list
gpr_strvec_init(&v);
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_first(builder);
while (grpc_channel_stack_builder_move_next(it)) {
- const char *name = grpc_channel_stack_builder_iterator_filter_name(it);
- if (name == NULL) continue;
+ const char* name = grpc_channel_stack_builder_iterator_filter_name(it);
+ if (name == nullptr) continue;
if (v.count != 0) gpr_strvec_add(&v, gpr_strdup(", "));
gpr_strvec_add(&v, gpr_strdup(name));
}
- char *got = gpr_strvec_flatten(&v, NULL);
+ char* got = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
grpc_channel_stack_builder_iterator_destroy(it);
@@ -170,7 +171,7 @@ static int check_stack(const char *file, int line, const char *transport_name,
gpr_strvec_add(&v, gpr_strdup("="));
switch (channel_args->args[i].type) {
case GRPC_ARG_INTEGER: {
- char *tmp;
+ char* tmp;
gpr_asprintf(&tmp, "%d", channel_args->args[i].value.integer);
gpr_strvec_add(&v, tmp);
break;
@@ -179,7 +180,7 @@ static int check_stack(const char *file, int line, const char *transport_name,
gpr_strvec_add(&v, gpr_strdup(channel_args->args[i].value.string));
break;
case GRPC_ARG_POINTER: {
- char *tmp;
+ char* tmp;
gpr_asprintf(&tmp, "%p", channel_args->args[i].value.pointer.p);
gpr_strvec_add(&v, tmp);
break;
@@ -187,15 +188,17 @@ static int check_stack(const char *file, int line, const char *transport_name,
}
}
gpr_strvec_add(&v, gpr_strdup("}"));
- char *args_str = gpr_strvec_flatten(&v, NULL);
+ char* args_str = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR,
"**************************************************");
- gpr_log(file, line, GPR_LOG_SEVERITY_ERROR,
- "FAILED transport=%s; stack_type=%s; channel_args=%s:",
- transport_name, grpc_channel_stack_type_string(channel_stack_type),
- args_str);
+ gpr_log(
+ file, line, GPR_LOG_SEVERITY_ERROR,
+ "FAILED transport=%s; stack_type=%s; channel_args=%s:", transport_name,
+ grpc_channel_stack_type_string(
+ static_cast<grpc_channel_stack_type>(channel_stack_type)),
+ args_str);
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "EXPECTED: %s", expect);
gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "GOT: %s", got);
result = 1;
@@ -207,10 +210,9 @@ static int check_stack(const char *file, int line, const char *transport_name,
gpr_free(expect);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_stack_builder_destroy(&exec_ctx, builder);
- grpc_channel_args_destroy(&exec_ctx, channel_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_stack_builder_destroy(builder);
+ grpc_channel_args_destroy(channel_args);
}
return result;
diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD
index c4a93238f2..ec72e0ea72 100644
--- a/test/core/client_channel/BUILD
+++ b/test/core/client_channel/BUILD
@@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "uri_fuzzer_test",
- srcs = ["uri_fuzzer_test.c"],
- language = "C",
+ srcs = ["uri_fuzzer_test.cc"],
+ language = "C++",
corpus = "uri_corpus",
deps = [
"//:gpr",
@@ -34,8 +34,8 @@ grpc_fuzzer(
grpc_cc_test(
name = "lb_policies_test",
- srcs = ["lb_policies_test.c"],
- language = "C",
+ srcs = ["lb_policies_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.cc
index ba37cd673f..716c63b9d0 100644
--- a/test/core/client_channel/lb_policies_test.c
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -30,7 +30,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/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
@@ -41,39 +41,39 @@
typedef struct servers_fixture {
size_t num_servers;
- grpc_server **servers;
- grpc_call **server_calls;
- grpc_completion_queue *cq;
- grpc_completion_queue *shutdown_cq;
- char **servers_hostports;
- grpc_metadata_array *request_metadata_recv;
+ grpc_server** servers;
+ grpc_call** server_calls;
+ grpc_completion_queue* cq;
+ grpc_completion_queue* shutdown_cq;
+ char** servers_hostports;
+ grpc_metadata_array* request_metadata_recv;
} servers_fixture;
typedef struct request_sequences {
size_t n; /* number of iterations */
- int *connections; /* indexed by the interation number, value is the index of
+ int* connections; /* indexed by the interation number, value is the index of
the server it connected to or -1 if none */
- int *connectivity_states; /* indexed by the interation number, value is the
- client connectivity state */
+ /* indexed by the interation number, value is the client connectivity state */
+ grpc_connectivity_state* connectivity_states;
} request_sequences;
-typedef void (*verifier_fn)(const servers_fixture *, grpc_channel *,
- const request_sequences *, const size_t);
+typedef void (*verifier_fn)(const servers_fixture*, grpc_channel*,
+ const request_sequences*, const size_t);
typedef struct test_spec {
size_t num_iters;
size_t num_servers;
- int **kill_at;
- int **revive_at;
+ int** kill_at;
+ int** revive_at;
- const char *description;
+ const char* description;
verifier_fn verifier;
} test_spec;
-static void test_spec_reset(test_spec *spec) {
+static void test_spec_reset(test_spec* spec) {
size_t i, j;
for (i = 0; i < spec->num_iters; i++) {
@@ -84,25 +84,26 @@ static void test_spec_reset(test_spec *spec) {
}
}
-static test_spec *test_spec_create(size_t num_iters, size_t num_servers) {
- test_spec *spec;
+static test_spec* test_spec_create(size_t num_iters, size_t num_servers) {
+ test_spec* spec;
size_t i;
- spec = gpr_malloc(sizeof(test_spec));
+ spec = static_cast<test_spec*>(gpr_malloc(sizeof(test_spec)));
spec->num_iters = num_iters;
spec->num_servers = num_servers;
- spec->kill_at = gpr_malloc(sizeof(int *) * num_iters);
- spec->revive_at = gpr_malloc(sizeof(int *) * num_iters);
+ spec->kill_at = static_cast<int**>(gpr_malloc(sizeof(int*) * num_iters));
+ spec->revive_at = static_cast<int**>(gpr_malloc(sizeof(int*) * num_iters));
for (i = 0; i < num_iters; i++) {
- spec->kill_at[i] = gpr_malloc(sizeof(int) * num_servers);
- spec->revive_at[i] = gpr_malloc(sizeof(int) * num_servers);
+ spec->kill_at[i] = static_cast<int*>(gpr_malloc(sizeof(int) * num_servers));
+ spec->revive_at[i] =
+ static_cast<int*>(gpr_malloc(sizeof(int) * num_servers));
}
test_spec_reset(spec);
return spec;
}
-static void test_spec_destroy(test_spec *spec) {
+static void test_spec_destroy(test_spec* spec) {
size_t i;
for (i = 0; i < spec->num_iters; i++) {
gpr_free(spec->kill_at[i]);
@@ -115,29 +116,29 @@ static void test_spec_destroy(test_spec *spec) {
gpr_free(spec);
}
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static gpr_timespec n_millis_time(int n) {
return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(n, GPR_TIMESPAN));
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, n_millis_time(5000), NULL);
+ ev = grpc_completion_queue_next(cq, n_millis_time(5000), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void kill_server(const servers_fixture *f, size_t i) {
+static void kill_server(const servers_fixture* f, size_t i) {
gpr_log(GPR_INFO, "KILLING SERVER %" PRIuPTR, i);
- GPR_ASSERT(f->servers[i] != NULL);
+ GPR_ASSERT(f->servers[i] != nullptr);
grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(10000),
- n_millis_time(5000), NULL)
+ n_millis_time(5000), nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->servers[i]);
- f->servers[i] = NULL;
+ f->servers[i] = nullptr;
}
typedef struct request_data {
@@ -145,19 +146,19 @@ typedef struct request_data {
grpc_metadata_array trailing_metadata_recv;
grpc_slice details;
grpc_status_code status;
- grpc_call_details *call_details;
+ grpc_call_details* call_details;
} request_data;
-static void revive_server(const servers_fixture *f, request_data *rdata,
+static void revive_server(const servers_fixture* f, request_data* rdata,
size_t i) {
int got_port;
gpr_log(GPR_INFO, "RAISE AGAIN SERVER %" PRIuPTR, i);
- GPR_ASSERT(f->servers[i] == NULL);
+ GPR_ASSERT(f->servers[i] == nullptr);
gpr_log(GPR_DEBUG, "revive: %s", f->servers_hostports[i]);
- f->servers[i] = grpc_server_create(NULL, NULL);
- grpc_server_register_completion_queue(f->servers[i], f->cq, NULL);
+ f->servers[i] = grpc_server_create(nullptr, nullptr);
+ grpc_server_register_completion_queue(f->servers[i], f->cq, nullptr);
GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port(
f->servers[i], f->servers_hostports[i])) > 0);
grpc_server_start(f->servers[i]);
@@ -169,39 +170,43 @@ static void revive_server(const servers_fixture *f, request_data *rdata,
f->cq, tag(1000 + (int)i)));
}
-static servers_fixture *setup_servers(const char *server_host,
- request_data *rdata,
+static servers_fixture* setup_servers(const char* server_host,
+ request_data* rdata,
const size_t num_servers) {
- servers_fixture *f = gpr_malloc(sizeof(servers_fixture));
+ servers_fixture* f =
+ static_cast<servers_fixture*>(gpr_malloc(sizeof(servers_fixture)));
size_t i;
f->num_servers = num_servers;
- f->server_calls = gpr_malloc(sizeof(grpc_call *) * num_servers);
- f->request_metadata_recv =
- gpr_malloc(sizeof(grpc_metadata_array) * num_servers);
+ f->server_calls =
+ static_cast<grpc_call**>(gpr_malloc(sizeof(grpc_call*) * num_servers));
+ f->request_metadata_recv = static_cast<grpc_metadata_array*>(
+ gpr_malloc(sizeof(grpc_metadata_array) * num_servers));
/* Create servers. */
- f->servers = gpr_malloc(sizeof(grpc_server *) * num_servers);
- f->servers_hostports = gpr_malloc(sizeof(char *) * num_servers);
- f->cq = grpc_completion_queue_create_for_next(NULL);
- f->shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f->servers = static_cast<grpc_server**>(
+ gpr_malloc(sizeof(grpc_server*) * num_servers));
+ f->servers_hostports =
+ static_cast<char**>(gpr_malloc(sizeof(char*) * num_servers));
+ f->cq = grpc_completion_queue_create_for_next(nullptr);
+ f->shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
for (i = 0; i < num_servers; i++) {
grpc_metadata_array_init(&f->request_metadata_recv[i]);
gpr_join_host_port(&f->servers_hostports[i], server_host,
grpc_pick_unused_port_or_die());
- f->servers[i] = 0;
+ f->servers[i] = nullptr;
revive_server(f, rdata, i);
}
return f;
}
-static void teardown_servers(servers_fixture *f) {
+static void teardown_servers(servers_fixture* f) {
size_t i;
/* Destroy server. */
for (i = 0; i < f->num_servers; i++) {
- if (f->servers[i] == NULL) continue;
+ if (f->servers[i] == nullptr) continue;
grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(10000),
- n_millis_time(5000), NULL)
+ n_millis_time(5000), nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->servers[i]);
}
@@ -226,28 +231,29 @@ static void teardown_servers(servers_fixture *f) {
static request_sequences request_sequences_create(size_t n) {
request_sequences res;
res.n = n;
- res.connections = gpr_malloc(sizeof(*res.connections) * n);
- res.connectivity_states = gpr_malloc(sizeof(*res.connectivity_states) * n);
+ res.connections = static_cast<int*>(gpr_malloc(sizeof(*res.connections) * n));
+ res.connectivity_states = static_cast<grpc_connectivity_state*>(
+ gpr_malloc(sizeof(*res.connectivity_states) * n));
memset(res.connections, 0, sizeof(*res.connections) * n);
memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n);
return res;
}
-static void request_sequences_destroy(const request_sequences *rseqs) {
+static void request_sequences_destroy(const request_sequences* rseqs) {
gpr_free(rseqs->connections);
gpr_free(rseqs->connectivity_states);
}
/** Returns connection sequence (server indices), which must be freed */
-static request_sequences perform_request(servers_fixture *f,
- grpc_channel *client,
- request_data *rdata,
- const test_spec *spec) {
- grpc_call *c;
+static request_sequences perform_request(servers_fixture* f,
+ grpc_channel* client,
+ request_data* rdata,
+ const test_spec* spec) {
+ grpc_call* c;
int s_idx;
- int *s_valid;
+ int* s_valid;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
int was_cancelled;
size_t i, iter_num;
grpc_event ev;
@@ -255,10 +261,10 @@ static request_sequences perform_request(servers_fixture *f,
int completed_client;
const request_sequences sequences = request_sequences_create(spec->num_iters);
- s_valid = gpr_malloc(sizeof(int) * f->num_servers);
+ s_valid = static_cast<int*>(gpr_malloc(sizeof(int) * f->num_servers));
for (iter_num = 0; iter_num < spec->num_iters; iter_num++) {
- cq_verifier *cqv = cq_verifier_create(f->cq);
+ cq_verifier* cqv = cq_verifier_create(f->cq);
was_cancelled = 2;
for (i = 0; i < f->num_servers; i++) {
@@ -280,9 +286,10 @@ static request_sequences perform_request(servers_fixture *f,
memset(s_valid, 0, f->num_servers * sizeof(int));
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr");
- c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
- grpc_slice_from_static_string("/foo"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ c = grpc_channel_create_call(client, nullptr, GRPC_PROPAGATE_DEFAULTS,
+ f->cq, grpc_slice_from_static_string("/foo"),
+ &host, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(c);
completed_client = 0;
@@ -291,17 +298,17 @@ static request_sequences perform_request(servers_fixture *f,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&rdata->initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata =
@@ -309,16 +316,16 @@ static request_sequences perform_request(servers_fixture *f,
op->data.recv_status_on_client.status = &rdata->status;
op->data.recv_status_on_client.status_details = &rdata->details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, (size_t)(op - ops),
+ tag(1), nullptr));
s_idx = -1;
- while (
- (ev = grpc_completion_queue_next(
- f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT), NULL))
- .type != GRPC_QUEUE_TIMEOUT) {
+ while ((ev = grpc_completion_queue_next(
+ f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT),
+ nullptr))
+ .type != GRPC_QUEUE_TIMEOUT) {
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
read_tag = ((int)(intptr_t)ev.tag);
const grpc_connectivity_state conn_state =
@@ -346,7 +353,7 @@ static request_sequences perform_request(servers_fixture *f,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -354,16 +361,16 @@ static request_sequences perform_request(servers_fixture *f,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(f->server_calls[s_idx],
ops, (size_t)(op - ops),
- tag(102), NULL));
+ tag(102), nullptr));
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
if (!completed_client) {
@@ -388,17 +395,17 @@ static request_sequences perform_request(servers_fixture *f,
&f->request_metadata_recv[s_idx], f->cq,
f->cq, tag(1000 + (int)s_idx)));
} else { /* no response from server */
- grpc_call_cancel(c, NULL);
+ grpc_call_cancel(c, nullptr);
if (!completed_client) {
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
}
}
- GPR_ASSERT(
- grpc_completion_queue_next(
- f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT), NULL)
- .type == GRPC_QUEUE_TIMEOUT);
+ GPR_ASSERT(grpc_completion_queue_next(
+ f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT),
+ nullptr)
+ .type == GRPC_QUEUE_TIMEOUT);
grpc_metadata_array_destroy(&rdata->initial_metadata_recv);
grpc_metadata_array_destroy(&rdata->trailing_metadata_recv);
@@ -418,15 +425,16 @@ static request_sequences perform_request(servers_fixture *f,
return sequences;
}
-static grpc_call **perform_multirequest(servers_fixture *f,
- grpc_channel *client,
+static grpc_call** perform_multirequest(servers_fixture* f,
+ grpc_channel* client,
size_t concurrent_calls) {
- grpc_call **calls;
+ grpc_call** calls;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
size_t i;
- calls = gpr_malloc(sizeof(grpc_call *) * concurrent_calls);
+ calls = static_cast<grpc_call**>(
+ gpr_malloc(sizeof(grpc_call*) * concurrent_calls));
for (i = 0; i < f->num_servers; i++) {
kill_server(f, i);
}
@@ -436,54 +444,55 @@ static grpc_call **perform_multirequest(servers_fixture *f,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr");
for (i = 0; i < concurrent_calls; i++) {
- calls[i] =
- grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
- grpc_slice_from_static_string("/foo"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ calls[i] = grpc_channel_create_call(
+ client, nullptr, GRPC_PROPAGATE_DEFAULTS, f->cq,
+ grpc_slice_from_static_string("/foo"), &host,
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(calls[i]);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[i], ops,
(size_t)(op - ops), tag(1),
- NULL));
+ nullptr));
}
return calls;
}
-void run_spec(const test_spec *spec) {
- grpc_channel *client;
- char *client_hostport;
- char *servers_hostports_str;
+void run_spec(const test_spec* spec) {
+ grpc_channel* client;
+ char* client_hostport;
+ char* servers_hostports_str;
request_data rdata;
- servers_fixture *f;
+ servers_fixture* f;
grpc_channel_args args;
grpc_arg arg_array[2];
- rdata.call_details =
- gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
+ rdata.call_details = static_cast<grpc_call_details*>(
+ gpr_malloc(sizeof(grpc_call_details) * spec->num_servers));
f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
/* Create client. */
- servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports,
- f->num_servers, ",", NULL);
+ servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports,
+ f->num_servers, ",", nullptr);
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
- arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
- arg_array[1].value.string = "round_robin";
+ arg_array[1].key = const_cast<char*>(GRPC_ARG_LB_POLICY_NAME);
+ arg_array[1].value.string = const_cast<char*>("round_robin");
args.num_args = 2;
args.args = arg_array;
- client = grpc_insecure_channel_create(client_hostport, &args, NULL);
+ client = grpc_insecure_channel_create(client_hostport, &args, nullptr);
gpr_log(GPR_INFO, "Testing '%s' with servers=%s client=%s", spec->description,
servers_hostports_str, client_hostport);
@@ -501,30 +510,32 @@ void run_spec(const test_spec *spec) {
teardown_servers(f);
}
-static grpc_channel *create_client(const servers_fixture *f) {
- grpc_channel *client;
- char *client_hostport;
- char *servers_hostports_str;
+static grpc_channel* create_client(const servers_fixture* f) {
+ grpc_channel* client;
+ char* client_hostport;
+ char* servers_hostports_str;
grpc_arg arg_array[3];
grpc_channel_args args;
- servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports,
- f->num_servers, ",", NULL);
+ servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports,
+ f->num_servers, ",", nullptr);
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
- arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
- arg_array[1].value.string = "ROUND_ROBIN";
+ arg_array[1].key = const_cast<char*>(GRPC_ARG_LB_POLICY_NAME);
+ arg_array[1].value.string = const_cast<char*>("ROUND_ROBIN");
arg_array[2].type = GRPC_ARG_INTEGER;
- arg_array[2].key = GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS;
+ arg_array[2].key =
+ const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS);
arg_array[2].value.integer = 0;
args.num_args = GPR_ARRAY_SIZE(arg_array);
args.args = arg_array;
- client = grpc_insecure_channel_create(client_hostport, &args, NULL);
+ client = grpc_insecure_channel_create(client_hostport, &args, nullptr);
gpr_free(client_hostport);
gpr_free(servers_hostports_str);
@@ -532,21 +543,22 @@ static grpc_channel *create_client(const servers_fixture *f) {
}
static void test_ping() {
- grpc_channel *client;
+ grpc_channel* client;
request_data rdata;
- servers_fixture *f;
- cq_verifier *cqv;
+ servers_fixture* f;
+ cq_verifier* cqv;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
const size_t num_servers = 1;
int i;
- rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * num_servers);
+ rdata.call_details = static_cast<grpc_call_details*>(
+ gpr_malloc(sizeof(grpc_call_details) * num_servers));
f = setup_servers("127.0.0.1", &rdata, num_servers);
cqv = cq_verifier_create(f->cq);
client = create_client(f);
- grpc_channel_ping(client, f->cq, tag(0), NULL);
+ grpc_channel_ping(client, f->cq, tag(0), nullptr);
CQ_EXPECT_COMPLETION(cqv, tag(0), 0);
/* check that we're still in idle, and start connecting */
@@ -566,7 +578,7 @@ static void test_ping() {
}
for (i = 1; i <= 5; i++) {
- grpc_channel_ping(client, f->cq, tag(i), NULL);
+ grpc_channel_ping(client, f->cq, tag(i), nullptr);
CQ_EXPECT_COMPLETION(cqv, tag(i), 1);
cq_verify(cqv);
}
@@ -580,20 +592,19 @@ static void test_ping() {
static void test_pending_calls(size_t concurrent_calls) {
size_t i;
- grpc_call **calls;
- grpc_channel *client;
+ grpc_call** calls;
+ grpc_channel* client;
request_data rdata;
- servers_fixture *f;
- test_spec *spec = test_spec_create(0, 4);
- rdata.call_details =
- gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
+ servers_fixture* f;
+ test_spec* spec = test_spec_create(0, 4);
+ rdata.call_details = static_cast<grpc_call_details*>(
+ gpr_malloc(sizeof(grpc_call_details) * spec->num_servers));
f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
client = create_client(f);
calls = perform_multirequest(f, client, concurrent_calls);
- grpc_call_cancel(
- calls[0],
- NULL); /* exercise the cancel pick path whilst there are pending picks */
+ grpc_call_cancel(calls[0], nullptr); /* exercise the cancel pick path whilst
+ there are pending picks */
gpr_free(rdata.call_details);
@@ -609,8 +620,8 @@ static void test_pending_calls(size_t concurrent_calls) {
}
static void test_get_channel_info() {
- grpc_channel *channel =
- grpc_insecure_channel_create("ipv4:127.0.0.1:1234", NULL, NULL);
+ grpc_channel* channel =
+ grpc_insecure_channel_create("ipv4:127.0.0.1:1234", nullptr, nullptr);
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
// First, request no fields. This is a no-op.
@@ -618,44 +629,44 @@ static void test_get_channel_info() {
memset(&channel_info, 0, sizeof(channel_info));
grpc_channel_get_info(channel, &channel_info);
// Request LB policy name.
- char *lb_policy_name = NULL;
+ char* lb_policy_name = nullptr;
channel_info.lb_policy_name = &lb_policy_name;
grpc_channel_get_info(channel, &channel_info);
- GPR_ASSERT(lb_policy_name != NULL);
+ GPR_ASSERT(lb_policy_name != nullptr);
GPR_ASSERT(strcmp(lb_policy_name, "pick_first") == 0);
gpr_free(lb_policy_name);
// Request service config, which does not exist, so we'll get nothing back.
memset(&channel_info, 0, sizeof(channel_info));
- char *service_config_json = "dummy_string";
+ char* service_config_json = const_cast<char*>("dummy_string");
channel_info.service_config_json = &service_config_json;
grpc_channel_get_info(channel, &channel_info);
- GPR_ASSERT(service_config_json == NULL);
+ GPR_ASSERT(service_config_json == nullptr);
// Recreate the channel such that it has a service config.
grpc_channel_destroy(channel);
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
- arg.value.string = "{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}";
- grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
- channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL);
+ arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG);
+ arg.value.string =
+ const_cast<char*>("{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}");
+ grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
+ channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
// Now request the service config again.
grpc_channel_get_info(channel, &channel_info);
- GPR_ASSERT(service_config_json != NULL);
+ GPR_ASSERT(service_config_json != nullptr);
GPR_ASSERT(strcmp(service_config_json, arg.value.string) == 0);
gpr_free(service_config_json);
// Clean up.
grpc_channel_destroy(channel);
}
-static void print_failed_expectations(const int *expected_connection_sequence,
- const int *actual_connection_sequence,
+static void print_failed_expectations(const int* expected_connection_sequence,
+ const int* actual_connection_sequence,
const size_t expected_seq_length,
const size_t num_iters) {
size_t i;
@@ -667,16 +678,16 @@ static void print_failed_expectations(const int *expected_connection_sequence,
}
}
-static void verify_vanilla_round_robin(const servers_fixture *f,
- grpc_channel *client,
- const request_sequences *sequences,
+static void verify_vanilla_round_robin(const servers_fixture* f,
+ grpc_channel* client,
+ const request_sequences* sequences,
const size_t num_iters) {
const size_t expected_seq_length = f->num_servers;
/* verify conn. seq. expectation */
/* get the first sequence of "num_servers" elements */
- int *expected_connection_sequence =
- gpr_malloc(sizeof(int) * expected_seq_length);
+ int* expected_connection_sequence =
+ static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length));
memcpy(expected_connection_sequence, sequences->connections,
sizeof(int) * expected_seq_length);
@@ -695,7 +706,8 @@ static void verify_vanilla_round_robin(const servers_fixture *f,
/* All servers are available, therefore all client subchannels are READY, even
* when we only need one for the client channel state to be READY */
for (size_t i = 0; i < sequences->n; i++) {
- const grpc_connectivity_state actual = sequences->connectivity_states[i];
+ const grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]);
const grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -713,15 +725,16 @@ static void verify_vanilla_round_robin(const servers_fixture *f,
/* At the start of the second iteration, all but the first and last servers (as
* given in "f") are killed */
static void verify_vanishing_floor_round_robin(
- const servers_fixture *f, grpc_channel *client,
- const request_sequences *sequences, const size_t num_iters) {
- int *expected_connection_sequence;
+ const servers_fixture* f, grpc_channel* client,
+ const request_sequences* sequences, const size_t num_iters) {
+ int* expected_connection_sequence;
const size_t expected_seq_length = 2;
size_t i;
/* verify conn. seq. expectation */
/* copy the first full sequence (without -1s) */
- expected_connection_sequence = gpr_malloc(sizeof(int) * expected_seq_length);
+ expected_connection_sequence =
+ static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length));
memcpy(expected_connection_sequence, sequences->connections + 2,
expected_seq_length * sizeof(int));
@@ -750,7 +763,8 @@ static void verify_vanishing_floor_round_robin(
/* There's always at least one subchannel READY (connected), therefore the
* overall state of the client channel is READY at all times. */
for (i = 0; i < sequences->n; i++) {
- const grpc_connectivity_state actual = sequences->connectivity_states[i];
+ const grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]);
const grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -765,9 +779,9 @@ static void verify_vanishing_floor_round_robin(
gpr_free(expected_connection_sequence);
}
-static void verify_total_carnage_round_robin(const servers_fixture *f,
- grpc_channel *client,
- const request_sequences *sequences,
+static void verify_total_carnage_round_robin(const servers_fixture* f,
+ grpc_channel* client,
+ const request_sequences* sequences,
const size_t num_iters) {
for (size_t i = 0; i < num_iters; i++) {
const int actual = sequences->connections[i];
@@ -785,7 +799,8 @@ static void verify_total_carnage_round_robin(const servers_fixture *f,
* Note that all other states (IDLE, CONNECTING, TRANSIENT_FAILURE) are still
* possible, as the policy transitions while attempting to reconnect. */
for (size_t i = 0; i < sequences->n; i++) {
- const grpc_connectivity_state actual = sequences->connectivity_states[i];
+ const grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]);
if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
gpr_log(GPR_ERROR,
"CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state "
@@ -797,15 +812,16 @@ static void verify_total_carnage_round_robin(const servers_fixture *f,
}
static void verify_partial_carnage_round_robin(
- const servers_fixture *f, grpc_channel *client,
- const request_sequences *sequences, const size_t num_iters) {
- int *expected_connection_sequence;
+ const servers_fixture* f, grpc_channel* client,
+ const request_sequences* sequences, const size_t num_iters) {
+ int* expected_connection_sequence;
size_t i;
const size_t expected_seq_length = f->num_servers;
/* verify conn. seq. expectation */
/* get the first sequence of "num_servers" elements */
- expected_connection_sequence = gpr_malloc(sizeof(int) * expected_seq_length);
+ expected_connection_sequence =
+ static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length));
memcpy(expected_connection_sequence, sequences->connections,
sizeof(int) * expected_seq_length);
@@ -827,7 +843,8 @@ static void verify_partial_carnage_round_robin(
/* We can assert that the first client channel state should be READY, when all
* servers were available */
- grpc_connectivity_state actual = sequences->connectivity_states[0];
+ grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[0]);
grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -841,7 +858,8 @@ static void verify_partial_carnage_round_robin(
/* ... and that the last one shouldn't be READY (or SHUTDOWN): all servers are
* gone. It may be all other states (IDLE, CONNECTING, TRANSIENT_FAILURE), as
* the policy transitions while attempting to reconnect. */
- actual = sequences->connectivity_states[num_iters - 1];
+ actual = static_cast<grpc_connectivity_state>(
+ sequences->connectivity_states[num_iters - 1]);
for (i = 0; i < sequences->n; i++) {
if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
gpr_log(GPR_ERROR,
@@ -854,9 +872,9 @@ static void verify_partial_carnage_round_robin(
gpr_free(expected_connection_sequence);
}
-static void dump_array(const char *desc, const int *data, const size_t count) {
+static void dump_array(const char* desc, const int* data, const size_t count) {
gpr_strvec s;
- char *tmp;
+ char* tmp;
size_t i;
gpr_strvec_init(&s);
gpr_strvec_add(&s, gpr_strdup(desc));
@@ -865,15 +883,15 @@ static void dump_array(const char *desc, const int *data, const size_t count) {
gpr_asprintf(&tmp, " %d", data[i]);
gpr_strvec_add(&s, tmp);
}
- tmp = gpr_strvec_flatten(&s, NULL);
+ tmp = gpr_strvec_flatten(&s, nullptr);
gpr_strvec_destroy(&s);
gpr_log(GPR_DEBUG, "%s", tmp);
gpr_free(tmp);
}
-static void verify_rebirth_round_robin(const servers_fixture *f,
- grpc_channel *client,
- const request_sequences *sequences,
+static void verify_rebirth_round_robin(const servers_fixture* f,
+ grpc_channel* client,
+ const request_sequences* sequences,
const size_t num_iters) {
dump_array("actual_connection_sequence", sequences->connections, num_iters);
@@ -894,7 +912,8 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
/* We can assert that the first client channel state should be READY, when all
* servers were available; same thing for the last one. In the middle
* somewhere there must exist at least one TRANSIENT_FAILURE */
- grpc_connectivity_state actual = sequences->connectivity_states[0];
+ grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[0]);
grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -905,7 +924,8 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
abort();
}
- actual = sequences->connectivity_states[num_iters - 1];
+ actual = static_cast<grpc_connectivity_state>(
+ sequences->connectivity_states[num_iters - 1]);
expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -931,14 +951,15 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
"instead:");
for (size_t i = 0; i < num_iters; i++) {
gpr_log(GPR_ERROR, "[%d]: %s", (int)i,
- grpc_connectivity_state_name(sequences->connectivity_states[i]));
+ grpc_connectivity_state_name(static_cast<grpc_connectivity_state>(
+ sequences->connectivity_states[i])));
}
}
}
-int main(int argc, char **argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- test_spec *spec;
+int main(int argc, char** argv) {
+ grpc_core::ExecCtx exec_ctx;
+ test_spec* spec;
size_t i;
const size_t NUM_ITERS = 10;
const size_t NUM_SERVERS = 4;
@@ -947,9 +968,9 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_tracer_set_enabled("round_robin", 1);
- GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist",
- NULL) == NULL);
- GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, NULL, NULL) == NULL);
+ GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", nullptr) ==
+ nullptr);
+ GPR_ASSERT(grpc_lb_policy_create(nullptr, nullptr) == nullptr);
spec = test_spec_create(NUM_ITERS, NUM_SERVERS);
/* everything is fine, all servers stay up the whole time and life's peachy
@@ -1003,7 +1024,6 @@ int main(int argc, char **argv) {
test_ping();
test_get_channel_info();
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/client_channel/parse_address_test.c b/test/core/client_channel/parse_address_test.cc
index d011176869..6d56961d84 100644
--- a/test/core/client_channel/parse_address_test.c
+++ b/test/core/client_channel/parse_address_test.cc
@@ -24,6 +24,7 @@
#include <sys/un.h>
#endif
+#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
@@ -32,70 +33,70 @@
#ifdef GRPC_HAVE_UNIX_SOCKET
-static void test_grpc_parse_unix(const char *uri_text, const char *pathname) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
GPR_ASSERT(1 == grpc_parse_unix(uri, &addr));
- struct sockaddr_un *addr_un = (struct sockaddr_un *)addr.addr;
+ struct sockaddr_un* addr_un = (struct sockaddr_un*)addr.addr;
GPR_ASSERT(AF_UNIX == addr_un->sun_family);
GPR_ASSERT(0 == strcmp(addr_un->sun_path, pathname));
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
#else /* GRPC_HAVE_UNIX_SOCKET */
-static void test_grpc_parse_unix(const char *uri_text, const char *pathname) {}
+static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {}
#endif /* GRPC_HAVE_UNIX_SOCKET */
-static void test_grpc_parse_ipv4(const char *uri_text, const char *host,
+static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
unsigned short port) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
char ntop_buf[INET_ADDRSTRLEN];
GPR_ASSERT(1 == grpc_parse_ipv4(uri, &addr));
- struct sockaddr_in *addr_in = (struct sockaddr_in *)addr.addr;
+ struct sockaddr_in* addr_in = (struct sockaddr_in*)addr.addr;
GPR_ASSERT(AF_INET == addr_in->sin_family);
- GPR_ASSERT(NULL != grpc_inet_ntop(AF_INET, &addr_in->sin_addr, ntop_buf,
- sizeof(ntop_buf)));
+ GPR_ASSERT(nullptr != grpc_inet_ntop(AF_INET, &addr_in->sin_addr, ntop_buf,
+ sizeof(ntop_buf)));
GPR_ASSERT(0 == strcmp(ntop_buf, host));
GPR_ASSERT(ntohs(addr_in->sin_port) == port);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void test_grpc_parse_ipv6(const char *uri_text, const char *host,
+static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
unsigned short port, uint32_t scope_id) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
char ntop_buf[INET6_ADDRSTRLEN];
GPR_ASSERT(1 == grpc_parse_ipv6(uri, &addr));
- struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr.addr;
+ struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*)addr.addr;
GPR_ASSERT(AF_INET6 == addr_in6->sin6_family);
- GPR_ASSERT(NULL != grpc_inet_ntop(AF_INET6, &addr_in6->sin6_addr, ntop_buf,
- sizeof(ntop_buf)));
+ GPR_ASSERT(nullptr != grpc_inet_ntop(AF_INET6, &addr_in6->sin6_addr, ntop_buf,
+ sizeof(ntop_buf)));
GPR_ASSERT(0 == strcmp(ntop_buf, host));
GPR_ASSERT(ntohs(addr_in6->sin6_port) == port);
GPR_ASSERT(addr_in6->sin6_scope_id == scope_id);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_grpc_parse_unix("unix:/path/name", "/path/name");
test_grpc_parse_ipv4("ipv4:192.0.2.1:12345", "192.0.2.1", 12345);
test_grpc_parse_ipv6("ipv6:[2001:db8::1]:12345", "2001:db8::1", 12345, 0);
test_grpc_parse_ipv6("ipv6:[2001:db8::1%252]:12345", "2001:db8::1", 12345, 2);
+
+ grpc_shutdown();
}
diff --git a/test/core/client_channel/resolvers/BUILD b/test/core/client_channel/resolvers/BUILD
index 0907e06623..b5269c7ef0 100644
--- a/test/core/client_channel/resolvers/BUILD
+++ b/test/core/client_channel/resolvers/BUILD
@@ -20,8 +20,8 @@ licenses(["notice"]) # Apache v2
grpc_cc_test(
name = "dns_resolver_connectivity_test",
- srcs = ["dns_resolver_connectivity_test.c"],
- language = "C",
+ srcs = ["dns_resolver_connectivity_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -32,8 +32,8 @@ grpc_cc_test(
grpc_cc_test(
name = "dns_resolver_test",
- srcs = ["dns_resolver_test.c"],
- language = "C",
+ srcs = ["dns_resolver_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +44,8 @@ grpc_cc_test(
grpc_cc_test(
name = "sockaddr_resolver_test",
- srcs = ["sockaddr_resolver_test.c"],
- language = "C",
+ srcs = ["sockaddr_resolver_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -56,8 +56,8 @@ grpc_cc_test(
grpc_cc_test(
name = "fake_resolver_test",
- srcs = ["fake_resolver_test.c"],
- language = "C",
+ srcs = ["fake_resolver_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
deleted file mode 100644
index 364e180963..0000000000
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+++ /dev/null
@@ -1,180 +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 <string.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-
-#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
-#include "src/core/ext/filters/client_channel/resolver.h"
-#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/iomgr/combiner.h"
-#include "src/core/lib/iomgr/resolve_address.h"
-#include "src/core/lib/iomgr/timer.h"
-#include "test/core/util/test_config.h"
-
-static gpr_mu g_mu;
-static bool g_fail_resolution = true;
-static grpc_combiner *g_combiner;
-
-static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {
- gpr_mu_lock(&g_mu);
- GPR_ASSERT(0 == strcmp("test", addr));
- grpc_error *error = GRPC_ERROR_NONE;
- if (g_fail_resolution) {
- g_fail_resolution = false;
- gpr_mu_unlock(&g_mu);
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
- } else {
- gpr_mu_unlock(&g_mu);
- *addrs = gpr_malloc(sizeof(**addrs));
- (*addrs)->naddrs = 1;
- (*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs));
- (*addrs)->addrs[0].len = 123;
- }
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
-}
-
-static grpc_ares_request *my_dns_lookup_ares(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **lb_addrs, bool check_grpclb,
- char **service_config_json) {
- gpr_mu_lock(&g_mu);
- GPR_ASSERT(0 == strcmp("test", addr));
- grpc_error *error = GRPC_ERROR_NONE;
- if (g_fail_resolution) {
- g_fail_resolution = false;
- gpr_mu_unlock(&g_mu);
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
- } else {
- gpr_mu_unlock(&g_mu);
- *lb_addrs = grpc_lb_addresses_create(1, NULL);
- grpc_lb_addresses_set_address(*lb_addrs, 0, NULL, 0, false, NULL, NULL);
- }
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
- return NULL;
-}
-
-static grpc_resolver *create_resolver(grpc_exec_ctx *exec_ctx,
- const char *name) {
- grpc_resolver_factory *factory = grpc_resolver_factory_lookup("dns");
- grpc_uri *uri = grpc_uri_parse(exec_ctx, name, 0);
- GPR_ASSERT(uri);
- grpc_resolver_args args;
- memset(&args, 0, sizeof(args));
- args.uri = uri;
- args.combiner = g_combiner;
- grpc_resolver *resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
- grpc_resolver_factory_unref(factory);
- grpc_uri_destroy(uri);
- return resolver;
-}
-
-static void on_done(grpc_exec_ctx *exec_ctx, void *ev, grpc_error *error) {
- gpr_event_set(ev, (void *)1);
-}
-
-// interleave waiting for an event with a timer check
-static bool wait_loop(int deadline_seconds, gpr_event *ev) {
- while (deadline_seconds) {
- gpr_log(GPR_DEBUG, "Test: waiting for %d more seconds", deadline_seconds);
- if (gpr_event_wait(ev, grpc_timeout_seconds_to_deadline(1))) return true;
- deadline_seconds--;
-
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_timer_check(&exec_ctx, gpr_now(GPR_CLOCK_MONOTONIC), NULL);
- grpc_exec_ctx_finish(&exec_ctx);
- }
- return false;
-}
-
-typedef struct next_args {
- grpc_resolver *resolver;
- grpc_channel_args **result;
- grpc_closure *on_complete;
-} next_args;
-
-static void call_resolver_next_now_lock_taken(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_error *error_unused) {
- next_args *a = arg;
- grpc_resolver_next_locked(exec_ctx, a->resolver, a->result, a->on_complete);
- gpr_free(a);
-}
-
-static void call_resolver_next_after_locking(grpc_exec_ctx *exec_ctx,
- grpc_resolver *resolver,
- grpc_channel_args **result,
- grpc_closure *on_complete) {
- next_args *a = gpr_malloc(sizeof(*a));
- a->resolver = resolver;
- a->result = result;
- a->on_complete = on_complete;
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(
- call_resolver_next_now_lock_taken, a,
- grpc_combiner_scheduler(resolver->combiner)),
- GRPC_ERROR_NONE);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
-
- grpc_init();
- gpr_mu_init(&g_mu);
- g_combiner = grpc_combiner_create();
- grpc_resolve_address = my_resolve_address;
- grpc_dns_lookup_ares = my_dns_lookup_ares;
- grpc_channel_args *result = (grpc_channel_args *)1;
-
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resolver *resolver = create_resolver(&exec_ctx, "dns:test");
- gpr_event ev1;
- gpr_event_init(&ev1);
- call_resolver_next_after_locking(
- &exec_ctx, resolver, &result,
- GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush(&exec_ctx);
- GPR_ASSERT(wait_loop(5, &ev1));
- GPR_ASSERT(result == NULL);
-
- gpr_event ev2;
- gpr_event_init(&ev2);
- call_resolver_next_after_locking(
- &exec_ctx, resolver, &result,
- GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush(&exec_ctx);
- GPR_ASSERT(wait_loop(30, &ev2));
- GPR_ASSERT(result != NULL);
-
- grpc_channel_args_destroy(&exec_ctx, result);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test");
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
-
- grpc_shutdown();
- gpr_mu_destroy(&g_mu);
-}
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
new file mode 100644
index 0000000000..18a795fbcb
--- /dev/null
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -0,0 +1,178 @@
+/*
+ *
+ * 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 <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+
+#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
+#include "src/core/ext/filters/client_channel/resolver.h"
+#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/iomgr/combiner.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/timer.h"
+#include "test/core/util/test_config.h"
+
+static gpr_mu g_mu;
+static bool g_fail_resolution = true;
+static grpc_combiner* g_combiner;
+
+static void my_resolve_address(const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) {
+ gpr_mu_lock(&g_mu);
+ GPR_ASSERT(0 == strcmp("test", addr));
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (g_fail_resolution) {
+ g_fail_resolution = false;
+ gpr_mu_unlock(&g_mu);
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
+ } else {
+ gpr_mu_unlock(&g_mu);
+ *addrs = static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(**addrs)));
+ (*addrs)->naddrs = 1;
+ (*addrs)->addrs = static_cast<grpc_resolved_address*>(
+ gpr_malloc(sizeof(*(*addrs)->addrs)));
+ (*addrs)->addrs[0].len = 123;
+ }
+ GRPC_CLOSURE_SCHED(on_done, error);
+}
+
+static grpc_ares_request* my_dns_lookup_ares(
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb,
+ char** service_config_json) {
+ gpr_mu_lock(&g_mu);
+ GPR_ASSERT(0 == strcmp("test", addr));
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (g_fail_resolution) {
+ g_fail_resolution = false;
+ gpr_mu_unlock(&g_mu);
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
+ } else {
+ gpr_mu_unlock(&g_mu);
+ *lb_addrs = grpc_lb_addresses_create(1, nullptr);
+ grpc_lb_addresses_set_address(*lb_addrs, 0, nullptr, 0, false, nullptr,
+ nullptr);
+ }
+ GRPC_CLOSURE_SCHED(on_done, error);
+ return nullptr;
+}
+
+static grpc_resolver* create_resolver(const char* name) {
+ grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns");
+ grpc_uri* uri = grpc_uri_parse(name, 0);
+ GPR_ASSERT(uri);
+ grpc_resolver_args args;
+ memset(&args, 0, sizeof(args));
+ args.uri = uri;
+ args.combiner = g_combiner;
+ grpc_resolver* resolver =
+ grpc_resolver_factory_create_resolver(factory, &args);
+ grpc_resolver_factory_unref(factory);
+ grpc_uri_destroy(uri);
+ return resolver;
+}
+
+static void on_done(void* ev, grpc_error* error) {
+ gpr_event_set((gpr_event*)ev, (void*)1);
+}
+
+// interleave waiting for an event with a timer check
+static bool wait_loop(int deadline_seconds, gpr_event* ev) {
+ while (deadline_seconds) {
+ gpr_log(GPR_DEBUG, "Test: waiting for %d more seconds", deadline_seconds);
+ if (gpr_event_wait(ev, grpc_timeout_seconds_to_deadline(1))) return true;
+ deadline_seconds--;
+
+ grpc_core::ExecCtx exec_ctx;
+ grpc_timer_check(nullptr);
+ }
+ return false;
+}
+
+typedef struct next_args {
+ grpc_resolver* resolver;
+ grpc_channel_args** result;
+ grpc_closure* on_complete;
+} next_args;
+
+static void call_resolver_next_now_lock_taken(void* arg,
+ grpc_error* error_unused) {
+ next_args* a = static_cast<next_args*>(arg);
+ grpc_resolver_next_locked(a->resolver, a->result, a->on_complete);
+ gpr_free(a);
+}
+
+static void call_resolver_next_after_locking(grpc_resolver* resolver,
+ grpc_channel_args** result,
+ grpc_closure* on_complete) {
+ next_args* a = static_cast<next_args*>(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);
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+
+ grpc_init();
+ gpr_mu_init(&g_mu);
+ g_combiner = grpc_combiner_create();
+ grpc_resolve_address = my_resolve_address;
+ grpc_dns_lookup_ares = my_dns_lookup_ares;
+ grpc_channel_args* result = (grpc_channel_args*)1;
+
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resolver* 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));
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(wait_loop(5, &ev1));
+ GPR_ASSERT(result == nullptr);
+
+ 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));
+ 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");
+ }
+
+ grpc_shutdown();
+ gpr_mu_destroy(&g_mu);
+}
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.c b/test/core/client_channel/resolvers/dns_resolver_test.cc
index a14926f173..80667908ef 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_test.cc
@@ -25,45 +25,43 @@
#include "src/core/lib/iomgr/combiner.h"
#include "test/core/util/test_config.h"
-static grpc_combiner *g_combiner;
+static grpc_combiner* g_combiner;
-static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
+static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
- grpc_resolver *resolver;
+ 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));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver != NULL);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ GPR_ASSERT(resolver != nullptr);
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void test_fails(grpc_resolver_factory *factory, const char *string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
+static void test_fails(grpc_resolver_factory* factory, const char* string) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
- grpc_resolver *resolver;
+ 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));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver == NULL);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
- grpc_resolver_factory *dns;
+int main(int argc, char** argv) {
+ grpc_resolver_factory* dns;
grpc_test_init(argc, argv);
grpc_init();
@@ -82,9 +80,8 @@ int main(int argc, char **argv) {
grpc_resolver_factory_unref(dns);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
}
grpc_shutdown();
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.c b/test/core/client_channel/resolvers/fake_resolver_test.cc
index 9b0854d6d8..d85cbb1d03 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.c
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -32,10 +32,10 @@
#include "test/core/util/test_config.h"
-static grpc_resolver *build_fake_resolver(
- grpc_exec_ctx *exec_ctx, grpc_combiner *combiner,
- grpc_fake_resolver_response_generator *response_generator) {
- grpc_resolver_factory *factory = grpc_resolver_factory_lookup("fake");
+static grpc_resolver* build_fake_resolver(
+ grpc_combiner* combiner,
+ grpc_fake_resolver_response_generator* response_generator) {
+ grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake");
grpc_arg generator_arg =
grpc_fake_resolver_response_generator_arg(response_generator);
grpc_resolver_args args;
@@ -43,95 +43,93 @@ static grpc_resolver *build_fake_resolver(
grpc_channel_args channel_args = {1, &generator_arg};
args.args = &channel_args;
args.combiner = combiner;
- grpc_resolver *resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
+ grpc_resolver* resolver =
+ grpc_resolver_factory_create_resolver(factory, &args);
grpc_resolver_factory_unref(factory);
return resolver;
}
typedef struct on_resolution_arg {
- grpc_channel_args *resolver_result;
- grpc_channel_args *expected_resolver_result;
+ grpc_channel_args* resolver_result;
+ grpc_channel_args* expected_resolver_result;
gpr_event ev;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- on_resolution_arg *res = arg;
+void on_resolution_cb(void* arg, grpc_error* error) {
+ on_resolution_arg* res = static_cast<on_resolution_arg*>(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.
- const grpc_lb_addresses *actual_lb_addresses =
+ const grpc_lb_addresses* actual_lb_addresses =
grpc_lb_addresses_find_channel_arg(res->resolver_result);
- const grpc_lb_addresses *expected_lb_addresses =
+ const grpc_lb_addresses* expected_lb_addresses =
grpc_lb_addresses_find_channel_arg(res->expected_resolver_result);
GPR_ASSERT(
grpc_lb_addresses_cmp(actual_lb_addresses, expected_lb_addresses) == 0);
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
- grpc_channel_args_destroy(exec_ctx, res->expected_resolver_result);
- gpr_event_set(&res->ev, (void *)1);
+ grpc_channel_args_destroy(res->resolver_result);
+ grpc_channel_args_destroy(res->expected_resolver_result);
+ gpr_event_set(&res->ev, (void*)1);
}
static void test_fake_resolver() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_combiner *combiner = grpc_combiner_create();
+ 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* response_generator =
grpc_fake_resolver_response_generator_create();
- grpc_resolver *resolver =
- build_fake_resolver(&exec_ctx, combiner, response_generator);
- GPR_ASSERT(resolver != NULL);
+ grpc_resolver* resolver = build_fake_resolver(combiner, response_generator);
+ GPR_ASSERT(resolver != nullptr);
// Setup expectations.
- grpc_uri *uris[] = {grpc_uri_parse(&exec_ctx, "ipv4:10.2.1.1:1234", true),
- grpc_uri_parse(&exec_ctx, "ipv4:127.0.0.1:4321", true)};
- char *balancer_names[] = {"name1", "name2"};
+ grpc_uri* uris[] = {grpc_uri_parse("ipv4:10.2.1.1:1234", true),
+ grpc_uri_parse("ipv4:127.0.0.1:4321", true)};
+ const char* balancer_names[] = {"name1", "name2"};
const bool is_balancer[] = {true, false};
- grpc_lb_addresses *addresses = grpc_lb_addresses_create(3, NULL);
+ grpc_lb_addresses* addresses = grpc_lb_addresses_create(3, nullptr);
for (size_t i = 0; i < GPR_ARRAY_SIZE(uris); ++i) {
grpc_lb_addresses_set_address_from_uri(
- addresses, i, uris[i], is_balancer[i], balancer_names[i], NULL);
+ addresses, i, uris[i], is_balancer[i], balancer_names[i], nullptr);
grpc_uri_destroy(uris[i]);
}
const grpc_arg addresses_arg =
grpc_lb_addresses_create_channel_arg(addresses);
- grpc_channel_args *results =
- grpc_channel_args_copy_and_add(NULL, &addresses_arg, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_channel_args* results =
+ grpc_channel_args_copy_and_add(nullptr, &addresses_arg, 1);
+ grpc_lb_addresses_destroy(addresses);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
on_res_arg.expected_resolver_result = results;
gpr_event_init(&on_res_arg.ev);
- grpc_closure *on_resolution = GRPC_CLOSURE_CREATE(
+ grpc_closure* on_resolution = GRPC_CLOSURE_CREATE(
on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner));
// Set resolver results and trigger first resolution. on_resolution_cb
// performs the checks.
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, results);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results);
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Setup update.
- grpc_uri *uris_update[] = {
- grpc_uri_parse(&exec_ctx, "ipv4:192.168.1.0:31416", true)};
- char *balancer_names_update[] = {"name3"};
+ grpc_uri* uris_update[] = {grpc_uri_parse("ipv4:192.168.1.0:31416", true)};
+ const char* balancer_names_update[] = {"name3"};
const bool is_balancer_update[] = {false};
- grpc_lb_addresses *addresses_update = grpc_lb_addresses_create(1, NULL);
+ grpc_lb_addresses* addresses_update = grpc_lb_addresses_create(1, nullptr);
for (size_t i = 0; i < GPR_ARRAY_SIZE(uris_update); ++i) {
grpc_lb_addresses_set_address_from_uri(addresses_update, i, uris_update[i],
is_balancer_update[i],
- balancer_names_update[i], NULL);
+ balancer_names_update[i], nullptr);
grpc_uri_destroy(uris_update[i]);
}
grpc_arg addresses_update_arg =
grpc_lb_addresses_create_channel_arg(addresses_update);
- grpc_channel_args *results_update =
- grpc_channel_args_copy_and_add(NULL, &addresses_update_arg, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses_update);
+ grpc_channel_args* results_update =
+ grpc_channel_args_copy_and_add(nullptr, &addresses_update_arg, 1);
+ grpc_lb_addresses_destroy(addresses_update);
// Setup expectations for the update.
on_resolution_arg on_res_arg_update;
@@ -142,31 +140,31 @@ static void test_fake_resolver() {
grpc_combiner_scheduler(combiner));
// Set updated resolver results and trigger a second resolution.
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, results_update);
- grpc_resolver_next_locked(&exec_ctx, resolver,
- &on_res_arg_update.resolver_result, on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results_update);
+ grpc_resolver_next_locked(resolver, &on_res_arg_update.resolver_result,
+ on_resolution);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg_update.ev,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Requesting a new resolution without re-senting the response shouldn't
// trigger the resolution callback.
memset(&on_res_arg, 0, sizeof(on_res_arg));
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
+
+ GRPC_COMBINER_UNREF(combiner, "test_fake_resolver");
+ GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "test_fake_resolver");
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_fake_resolver");
- grpc_exec_ctx_finish(&exec_ctx);
grpc_fake_resolver_response_generator_unref(response_generator);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.c b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
index 8b88619164..07ee133ee3 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.c
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -28,63 +28,64 @@
#include "test/core/util/test_config.h"
-static grpc_combiner *g_combiner;
+static grpc_combiner* g_combiner;
typedef struct on_resolution_arg {
- char *expected_server_name;
- grpc_channel_args *resolver_result;
+ char* expected_server_name;
+ grpc_channel_args* resolver_result;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- on_resolution_arg *res = arg;
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
+void on_resolution_cb(void* arg, grpc_error* error) {
+ on_resolution_arg* res = static_cast<on_resolution_arg*>(arg);
+ grpc_channel_args_destroy(res->resolver_result);
}
-static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
+static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
- grpc_resolver *resolver;
+ 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));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver != NULL);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ GPR_ASSERT(resolver != nullptr);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
on_res_arg.expected_server_name = uri->path;
- grpc_closure *on_resolution = GRPC_CLOSURE_CREATE(
+ grpc_closure* on_resolution = GRPC_CLOSURE_CREATE(
on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
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) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
+static void test_fails(grpc_resolver_factory* factory, const char* string) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
- grpc_resolver *resolver;
+ 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));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver == NULL);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
+ GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_resolver_factory *ipv4, *ipv6;
grpc_test_init(argc, argv);
grpc_init();
@@ -112,9 +113,8 @@ int main(int argc, char **argv) {
grpc_resolver_factory_unref(ipv6);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
}
grpc_shutdown();
diff --git a/test/core/client_channel/uri_fuzzer_test.c b/test/core/client_channel/uri_fuzzer_test.cc
index e51d0031ec..ee38453166 100644
--- a/test/core/client_channel/uri_fuzzer_test.c
+++ b/test/core/client_channel/uri_fuzzer_test.cc
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/filters/client_channel/uri_parser.h"
@@ -28,17 +29,23 @@
bool squelch = true;
bool leak_check = true;
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- char *s = gpr_malloc(size + 1);
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ char* s = static_cast<char*>(gpr_malloc(size + 1));
memcpy(s, data, size);
s[size] = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *x;
- if ((x = grpc_uri_parse(&exec_ctx, s, 1))) {
- grpc_uri_destroy(x);
+ grpc_init();
+
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* x;
+ if ((x = grpc_uri_parse(s, 1))) {
+ grpc_uri_destroy(x);
+ }
+
+ gpr_free(s);
}
- grpc_exec_ctx_finish(&exec_ctx);
- gpr_free(s);
+
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/client_channel/uri_parser_test.c b/test/core/client_channel/uri_parser_test.cc
index f53cae196b..254bfddfb3 100644
--- a/test/core/client_channel/uri_parser_test.c
+++ b/test/core/client_channel/uri_parser_test.cc
@@ -20,37 +20,37 @@
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "test/core/util/test_config.h"
-static void test_succeeds(const char *uri_text, const char *scheme,
- const char *authority, const char *path,
- const char *query, const char *fragment) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+static void test_succeeds(const char* uri_text, const char* scheme,
+ const char* authority, const char* path,
+ const char* query, const char* fragment) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp(scheme, uri->scheme));
GPR_ASSERT(0 == strcmp(authority, uri->authority));
GPR_ASSERT(0 == strcmp(path, uri->path));
GPR_ASSERT(0 == strcmp(query, uri->query));
GPR_ASSERT(0 == strcmp(fragment, uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
-static void test_fails(const char *uri_text) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(NULL == grpc_uri_parse(&exec_ctx, uri_text, 0));
- grpc_exec_ctx_finish(&exec_ctx);
+static void test_fails(const char* uri_text) {
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(nullptr == grpc_uri_parse(uri_text, 0));
}
static void test_query_parts() {
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- const char *uri_text = "http://foo/path?a&b=B&c=&#frag";
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx exec_ctx;
+ const char* uri_text = "http://foo/path?a&b=B&c=&#frag";
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -60,7 +60,7 @@ static void test_query_parts() {
GPR_ASSERT(4 == uri->num_query_parts);
GPR_ASSERT(0 == strcmp("a", uri->query_parts[0]));
- GPR_ASSERT(NULL == uri->query_parts_values[0]);
+ GPR_ASSERT(nullptr == uri->query_parts_values[0]);
GPR_ASSERT(0 == strcmp("b", uri->query_parts[1]));
GPR_ASSERT(0 == strcmp("B", uri->query_parts_values[1]));
@@ -69,22 +69,22 @@ static void test_query_parts() {
GPR_ASSERT(0 == strcmp("", uri->query_parts_values[2]));
GPR_ASSERT(0 == strcmp("", uri->query_parts[3]));
- GPR_ASSERT(NULL == uri->query_parts_values[3]);
+ GPR_ASSERT(nullptr == uri->query_parts_values[3]);
- GPR_ASSERT(NULL == grpc_uri_get_query_arg(uri, "a"));
+ GPR_ASSERT(nullptr == grpc_uri_get_query_arg(uri, "a"));
GPR_ASSERT(0 == strcmp("B", grpc_uri_get_query_arg(uri, "b")));
GPR_ASSERT(0 == strcmp("", grpc_uri_get_query_arg(uri, "c")));
- GPR_ASSERT(NULL == grpc_uri_get_query_arg(uri, ""));
+ GPR_ASSERT(nullptr == grpc_uri_get_query_arg(uri, ""));
GPR_ASSERT(0 == strcmp("frag", uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
{
/* test the current behavior of multiple query part values */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- const char *uri_text = "http://auth/path?foo=bar=baz&foobar==";
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx exec_ctx;
+ const char* uri_text = "http://auth/path?foo=bar=baz&foobar==";
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -96,14 +96,13 @@ static void test_query_parts() {
GPR_ASSERT(0 == strcmp("bar", grpc_uri_get_query_arg(uri, "foo")));
GPR_ASSERT(0 == strcmp("", grpc_uri_get_query_arg(uri, "foobar")));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_uri_destroy(uri);
}
{
/* empty query */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- const char *uri_text = "http://foo/path";
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx exec_ctx;
+ const char* uri_text = "http://foo/path";
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -111,16 +110,17 @@ static void test_query_parts() {
GPR_ASSERT(0 == strcmp("/path", uri->path));
GPR_ASSERT(0 == strcmp("", uri->query));
GPR_ASSERT(0 == uri->num_query_parts);
- GPR_ASSERT(NULL == uri->query_parts);
- GPR_ASSERT(NULL == uri->query_parts_values);
+ GPR_ASSERT(nullptr == uri->query_parts);
+ GPR_ASSERT(nullptr == uri->query_parts_values);
GPR_ASSERT(0 == strcmp("", uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_succeeds("http://www.google.com", "http", "www.google.com", "", "", "");
test_succeeds("dns:///foo", "dns", "", "/foo", "", "");
test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "", "",
@@ -148,5 +148,6 @@ int main(int argc, char **argv) {
test_fails("http://foo?bar#lol#");
test_query_parts();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/compression/BUILD b/test/core/compression/BUILD
index 1ab6e35f0d..b60390dbfe 100644
--- a/test/core/compression/BUILD
+++ b/test/core/compression/BUILD
@@ -20,8 +20,8 @@ licenses(["notice"]) # Apache v2
grpc_cc_test(
name = "algorithm_test",
- srcs = ["algorithm_test.c"],
- language = "C",
+ srcs = ["algorithm_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -32,8 +32,8 @@ grpc_cc_test(
grpc_cc_test(
name = "compression_test",
- srcs = ["compression_test.c"],
- language = "C",
+ srcs = ["compression_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +44,20 @@ grpc_cc_test(
grpc_cc_test(
name = "message_compress_test",
- srcs = ["message_compress_test.c"],
- language = "C",
+ srcs = ["message_compress_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "stream_compress_test",
+ srcs = ["stream_compression_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/compression/algorithm_test.c b/test/core/compression/algorithm_test.cc
index a11e6e90ac..1699d27142 100644
--- a/test/core/compression/algorithm_test.c
+++ b/test/core/compression/algorithm_test.cc
@@ -29,17 +29,19 @@
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/util/test_config.h"
+const uint32_t message_prefix_length = 8;
+const uint32_t stream_prefix_length = 7;
static void test_algorithm_mesh(void) {
int i;
gpr_log(GPR_DEBUG, "test_algorithm_mesh");
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
- const char *name;
+ const char* name;
grpc_compression_algorithm parsed;
grpc_slice mdstr;
grpc_mdelem mdelem;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(
grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name));
GPR_ASSERT(grpc_compression_algorithm_parse(
@@ -48,12 +50,28 @@ static void test_algorithm_mesh(void) {
mdstr = grpc_slice_from_copied_string(name);
GPR_ASSERT(grpc_slice_eq(mdstr, grpc_compression_algorithm_slice(parsed)));
GPR_ASSERT(parsed == grpc_compression_algorithm_from_slice(mdstr));
- mdelem = grpc_compression_encoding_mdelem(parsed);
- GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr));
- GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- GRPC_MDELEM_UNREF(&exec_ctx, mdelem);
- grpc_exec_ctx_finish(&exec_ctx);
+ if (parsed == 0) {
+ continue;
+ } else if (grpc_compression_algorithm_is_message(parsed)) {
+ mdelem = grpc_message_compression_encoding_mdelem(
+ grpc_compression_algorithm_to_message_compression_algorithm(parsed));
+ grpc_slice value = GRPC_MDVALUE(mdelem);
+ GPR_ASSERT(0 == memcmp(&name[message_prefix_length],
+ GRPC_SLICE_START_PTR(value),
+ GRPC_SLICE_LENGTH(value)));
+ GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING));
+ } else {
+ mdelem = grpc_stream_compression_encoding_mdelem(
+ grpc_compression_algorithm_to_stream_compression_algorithm(parsed));
+ grpc_slice value = GRPC_MDVALUE(mdelem);
+ GPR_ASSERT(0 == memcmp(&name[stream_prefix_length],
+ GRPC_SLICE_START_PTR(value),
+ GRPC_SLICE_LENGTH(value)));
+ GPR_ASSERT(
+ grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_CONTENT_ENCODING));
+ }
+ grpc_slice_unref_internal(mdstr);
+ GRPC_MDELEM_UNREF(mdelem);
}
/* test failure */
@@ -62,15 +80,17 @@ static void test_algorithm_mesh(void) {
}
static void test_algorithm_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_slice mdstr;
gpr_log(GPR_DEBUG, "test_algorithm_failure");
GPR_ASSERT(grpc_compression_algorithm_name(GRPC_COMPRESS_ALGORITHMS_COUNT,
- NULL) == 0);
- GPR_ASSERT(grpc_compression_algorithm_name(GRPC_COMPRESS_ALGORITHMS_COUNT + 1,
- NULL) == 0);
+ nullptr) == 0);
+ GPR_ASSERT(
+ grpc_compression_algorithm_name(static_cast<grpc_compression_algorithm>(
+ GRPC_COMPRESS_ALGORITHMS_COUNT + 1),
+ nullptr) == 0);
mdstr = grpc_slice_from_static_string("this-is-an-invalid-algorithm");
GPR_ASSERT(grpc_compression_algorithm_from_slice(mdstr) ==
GRPC_COMPRESS_ALGORITHMS_COUNT);
@@ -78,13 +98,13 @@ static void test_algorithm_failure(void) {
grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT),
grpc_empty_slice()));
GPR_ASSERT(grpc_slice_eq(
- grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT + 1),
+ grpc_compression_algorithm_slice(static_cast<grpc_compression_algorithm>(
+ static_cast<int>(GRPC_COMPRESS_ALGORITHMS_COUNT) + 1)),
grpc_empty_slice()));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.cc
index 326a800300..e49a93a4b6 100644
--- a/test/core/compression/compression_test.c
+++ b/test/core/compression/compression_test.cc
@@ -28,15 +28,17 @@
static void test_compression_algorithm_parse(void) {
size_t i;
- const char *valid_names[] = {"identity", "gzip", "deflate"};
+ const char* valid_names[] = {"identity", "message/gzip", "message/deflate",
+ "stream/gzip"};
const grpc_compression_algorithm valid_algorithms[] = {
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE};
- const char *invalid_names[] = {"gzip2", "foo", "", "2gzip"};
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP};
+ const char* invalid_names[] = {"gzip2", "foo", "", "2gzip"};
gpr_log(GPR_DEBUG, "test_compression_algorithm_parse");
for (i = 0; i < GPR_ARRAY_SIZE(valid_names); i++) {
- const char *valid_name = valid_names[i];
+ const char* valid_name = valid_names[i];
grpc_compression_algorithm algorithm;
const int success = grpc_compression_algorithm_parse(
grpc_slice_from_static_string(valid_name), &algorithm);
@@ -45,7 +47,7 @@ static void test_compression_algorithm_parse(void) {
}
for (i = 0; i < GPR_ARRAY_SIZE(invalid_names); i++) {
- const char *invalid_name = invalid_names[i];
+ const char* invalid_name = invalid_names[i];
grpc_compression_algorithm algorithm;
int success;
success = grpc_compression_algorithm_parse(
@@ -57,11 +59,13 @@ static void test_compression_algorithm_parse(void) {
static void test_compression_algorithm_name(void) {
int success;
- const char *name;
+ const char* name;
size_t i;
- const char *valid_names[] = {"identity", "gzip", "deflate"};
+ const char* valid_names[] = {"identity", "message/gzip", "message/deflate",
+ "stream/gzip"};
const grpc_compression_algorithm valid_algorithms[] = {
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE};
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP};
gpr_log(GPR_DEBUG, "test_compression_algorithm_name");
@@ -106,21 +110,21 @@ static void test_compression_algorithm_for_level(void) {
/* accept only gzip */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
@@ -129,21 +133,21 @@ static void test_compression_algorithm_for_level(void) {
/* accept only deflate */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
@@ -152,22 +156,70 @@ static void test_compression_algorithm_for_level(void) {
/* accept gzip and deflate */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
+ }
+
+ {
+ /* accept stream gzip */
+ uint32_t accepted_encodings = 0;
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP);
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
+ }
+
+ {
+ /* accept all algorithms */
+ uint32_t accepted_encodings = 0;
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP);
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
@@ -181,28 +233,34 @@ static void test_compression_enable_disable_algorithm(void) {
grpc_compression_options_init(&options);
for (algorithm = GRPC_COMPRESS_NONE;
- algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) {
+ algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT;
+ algorithm = static_cast<grpc_compression_algorithm>(
+ static_cast<int>(algorithm) + 1)) {
/* all algorithms are enabled by default */
GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options,
algorithm) != 0);
}
/* disable one by one */
for (algorithm = GRPC_COMPRESS_NONE;
- algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) {
+ algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT;
+ algorithm = static_cast<grpc_compression_algorithm>(
+ static_cast<int>(algorithm) + 1)) {
grpc_compression_options_disable_algorithm(&options, algorithm);
GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options,
algorithm) == 0);
}
/* re-enable one by one */
for (algorithm = GRPC_COMPRESS_NONE;
- algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) {
+ algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT;
+ algorithm = static_cast<grpc_compression_algorithm>(
+ static_cast<int>(algorithm) + 1)) {
grpc_compression_options_enable_algorithm(&options, algorithm);
GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options,
algorithm) != 0);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_init();
test_compression_algorithm_parse();
test_compression_algorithm_name();
diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.cc
index f7f4893dee..bab32e0cc5 100644
--- a/test/core/compression/message_compress_test.c
+++ b/test/core/compression/message_compress_test.cc
@@ -25,8 +25,8 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/murmur_hash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/murmur_hash.h"
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
@@ -39,7 +39,7 @@ typedef enum {
} compressability;
static void assert_passthrough(grpc_slice value,
- grpc_compression_algorithm algorithm,
+ grpc_message_compression_algorithm algorithm,
grpc_slice_split_mode uncompressed_split_mode,
grpc_slice_split_mode compressed_split_mode,
compressability compress_result_check) {
@@ -49,17 +49,19 @@ static void assert_passthrough(grpc_slice value,
grpc_slice_buffer output;
grpc_slice final;
int was_compressed;
- const char *algorithm_name;
-
- GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algorithm_name) != 0);
- gpr_log(
- GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR
- " value_hash=0x%08x "
- "algorithm='%s' uncompressed_split='%s' compressed_split='%s'",
- GRPC_SLICE_LENGTH(value), gpr_murmur_hash3(GRPC_SLICE_START_PTR(value),
- GRPC_SLICE_LENGTH(value), 0),
- algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode),
- grpc_slice_split_mode_name(compressed_split_mode));
+ const char* algorithm_name;
+
+ GPR_ASSERT(
+ grpc_message_compression_algorithm_name(algorithm, &algorithm_name) != 0);
+ gpr_log(GPR_INFO,
+ "assert_passthrough: value_length=%" PRIuPTR
+ " value_hash=0x%08x "
+ "algorithm='%s' uncompressed_split='%s' compressed_split='%s'",
+ GRPC_SLICE_LENGTH(value),
+ gpr_murmur_hash3(GRPC_SLICE_START_PTR(value),
+ GRPC_SLICE_LENGTH(value), 0),
+ algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode),
+ grpc_slice_split_mode_name(compressed_split_mode));
grpc_slice_buffer_init(&input);
grpc_slice_buffer_init(&compressed_raw);
@@ -69,10 +71,8 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slices_to_buffer(uncompressed_split_mode, &value, 1, &input);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed =
- grpc_msg_compress(&exec_ctx, algorithm, &input, &compressed_raw);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ was_compressed = grpc_msg_compress(algorithm, &input, &compressed_raw);
}
GPR_ASSERT(input.count > 0);
@@ -91,11 +91,10 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slice_buffer(compressed_split_mode, &compressed_raw, &compressed);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_msg_decompress(
- &exec_ctx, was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed,
+ was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, &compressed,
&output));
- grpc_exec_ctx_finish(&exec_ctx);
}
final = grpc_slice_merge(output.slices, output.count);
@@ -115,8 +114,8 @@ static grpc_slice repeated(char c, size_t length) {
}
static compressability get_compressability(
- test_value id, grpc_compression_algorithm algorithm) {
- if (algorithm == GRPC_COMPRESS_NONE) return SHOULD_NOT_COMPRESS;
+ test_value id, grpc_message_compression_algorithm algorithm) {
+ if (algorithm == GRPC_MESSAGE_COMPRESS_NONE) return SHOULD_NOT_COMPRESS;
switch (id) {
case ONE_A:
return SHOULD_NOT_COMPRESS;
@@ -148,17 +147,18 @@ static grpc_slice create_test_value(test_value id) {
static void test_tiny_data_compress(void) {
grpc_slice_buffer input;
grpc_slice_buffer output;
- grpc_compression_algorithm i;
grpc_slice_buffer_init(&input);
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_A));
- for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
- if (i == GRPC_COMPRESS_NONE) continue;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_compress(&exec_ctx, i, &input, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ for (int i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) {
+ if (i == GRPC_MESSAGE_COMPRESS_NONE) continue;
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(0 == grpc_msg_compress(
+
+ static_cast<grpc_message_compression_algorithm>(i),
+ &input, &output));
GPR_ASSERT(1 == output.count);
}
@@ -178,9 +178,9 @@ static void test_bad_decompression_data_crc(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
/* compress it */
- grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_GZIP, &input, &corrupted);
+ grpc_msg_compress(GRPC_MESSAGE_COMPRESS_GZIP, &input, &corrupted);
/* corrupt the output by smashing the CRC */
GPR_ASSERT(corrupted.count > 1);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8);
@@ -188,9 +188,8 @@ static void test_bad_decompression_data_crc(void) {
memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
/* try (and fail) to decompress the corrupted compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_GZIP, &corrupted,
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_GZIP, &corrupted,
&output));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -209,10 +208,9 @@ static void test_bad_decompression_data_trailing_garbage(void) {
"\x78\xda\x63\x60\x60\x60\x00\x00\x00\x04\x00\x01\x99", 13));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(
+ 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -228,10 +226,9 @@ static void test_bad_decompression_data_stream(void) {
grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(
+ 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -247,15 +244,16 @@ static void test_bad_compression_algorithm(void) {
grpc_slice_buffer_add(
&input, grpc_slice_from_copied_string("Never gonna give you up"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed = grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT,
+ grpc_core::ExecCtx exec_ctx;
+ was_compressed = grpc_msg_compress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT,
&input, &output);
GPR_ASSERT(0 == was_compressed);
- was_compressed = grpc_msg_compress(
- &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
+ was_compressed =
+ grpc_msg_compress(static_cast<grpc_message_compression_algorithm>(
+ GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123),
+ &input, &output);
GPR_ASSERT(0 == was_compressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -271,21 +269,22 @@ static void test_bad_decompression_algorithm(void) {
grpc_slice_buffer_add(&input,
grpc_slice_from_copied_string(
"I'm not really compressed but it doesn't matter"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_decompressed = grpc_msg_decompress(
- &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ grpc_core::ExecCtx exec_ctx;
+ was_decompressed = grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT,
+ &input, &output);
GPR_ASSERT(0 == was_decompressed);
- was_decompressed = grpc_msg_decompress(
- &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
+ was_decompressed =
+ grpc_msg_decompress(static_cast<grpc_message_compression_algorithm>(
+ GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123),
+ &input, &output);
GPR_ASSERT(0 == was_decompressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
unsigned i, j, k, m;
grpc_slice_split_mode uncompressed_split_modes[] = {
GRPC_SLICE_SPLIT_IDENTITY, GRPC_SLICE_SPLIT_ONE_BYTE};
@@ -296,12 +295,18 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
- for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
+ for (i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) {
for (j = 0; j < GPR_ARRAY_SIZE(uncompressed_split_modes); j++) {
for (k = 0; k < GPR_ARRAY_SIZE(compressed_split_modes); k++) {
for (m = 0; m < TEST_VALUE_COUNT; m++) {
- grpc_slice slice = create_test_value(m);
- assert_passthrough(slice, i, j, k, get_compressability(m, i));
+ grpc_slice slice = create_test_value(static_cast<test_value>(m));
+ assert_passthrough(
+ slice, static_cast<grpc_message_compression_algorithm>(i),
+ static_cast<grpc_slice_split_mode>(j),
+ static_cast<grpc_slice_split_mode>(k),
+ get_compressability(
+ static_cast<test_value>(m),
+ static_cast<grpc_message_compression_algorithm>(i)));
grpc_slice_unref(slice);
}
}
diff --git a/test/core/compression/stream_compression_test.c b/test/core/compression/stream_compression_test.cc
index afed6cd6b5..2f30b7fc19 100644
--- a/test/core/compression/stream_compression_test.c
+++ b/test/core/compression/stream_compression_test.cc
@@ -25,7 +25,7 @@
#include "src/core/lib/compression/stream_compression.h"
-static void generate_random_payload(char *payload, size_t size) {
+static void generate_random_payload(char* payload, size_t size) {
size_t i;
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
for (i = 0; i < size - 1; ++i) {
@@ -34,8 +34,8 @@ static void generate_random_payload(char *payload, size_t size) {
payload[size - 1] = '\0';
}
-static bool slice_buffer_equals_string(grpc_slice_buffer *buf,
- const char *str) {
+static bool slice_buffer_equals_string(grpc_slice_buffer* buf,
+ const char* str) {
size_t i;
if (buf->length != strlen(str)) {
return false;
@@ -43,8 +43,8 @@ static bool slice_buffer_equals_string(grpc_slice_buffer *buf,
size_t pointer = 0;
for (i = 0; i < buf->count; i++) {
size_t slice_len = GRPC_SLICE_LENGTH(buf->slices[i]);
- if (0 != strncmp(str + pointer,
- (char *)GRPC_SLICE_START_PTR(buf->slices[i]), slice_len)) {
+ if (0 != strncmp(str + pointer, (char*)GRPC_SLICE_START_PTR(buf->slices[i]),
+ slice_len)) {
return false;
}
pointer += slice_len;
@@ -58,15 +58,15 @@ static void test_stream_compression_simple_compress_decompress() {
grpc_slice_buffer_init(&source);
grpc_slice_buffer_init(&relay);
grpc_slice_buffer_init(&sink);
- grpc_stream_compression_context *compress_ctx =
+ grpc_stream_compression_context* compress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS);
- grpc_stream_compression_context *decompress_ctx =
+ grpc_stream_compression_context* decompress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
grpc_slice slice = grpc_slice_from_static_string(test_str);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH));
bool end_of_context;
@@ -91,15 +91,15 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
grpc_slice_buffer_init(&source);
grpc_slice_buffer_init(&relay);
grpc_slice_buffer_init(&sink);
- grpc_stream_compression_context *compress_ctx =
+ grpc_stream_compression_context* compress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS);
- grpc_stream_compression_context *decompress_ctx =
+ grpc_stream_compression_context* decompress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
grpc_slice slice = grpc_slice_from_static_string(test_str);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH));
grpc_stream_compression_context_destroy(compress_ctx);
@@ -112,7 +112,7 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
GPR_ASSERT(output_size == max_output_size);
GPR_ASSERT(end_of_context == false);
grpc_slice slice_recv = grpc_slice_buffer_take_first(&sink);
- char *str_recv = (char *)GRPC_SLICE_START_PTR(slice_recv);
+ char* str_recv = (char*)GRPC_SLICE_START_PTR(slice_recv);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_recv) == max_output_size);
GPR_ASSERT(0 == strncmp(test_str, str_recv, max_output_size));
grpc_slice_unref(slice_recv);
@@ -134,21 +134,22 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
#define LARGE_DATA_SIZE (1024 * 1024)
static void
test_stream_compression_simple_compress_decompress_with_large_data() {
- char *test_str = gpr_malloc(LARGE_DATA_SIZE * sizeof(char));
+ char* test_str =
+ static_cast<char*>(gpr_malloc(LARGE_DATA_SIZE * sizeof(char)));
generate_random_payload(test_str, LARGE_DATA_SIZE);
grpc_slice_buffer source, relay, sink;
grpc_slice_buffer_init(&source);
grpc_slice_buffer_init(&relay);
grpc_slice_buffer_init(&sink);
- grpc_stream_compression_context *compress_ctx =
+ grpc_stream_compression_context* compress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS);
- grpc_stream_compression_context *decompress_ctx =
+ grpc_stream_compression_context* decompress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
grpc_slice slice = grpc_slice_from_static_string(test_str);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH));
bool end_of_context;
@@ -174,12 +175,12 @@ static void test_stream_compression_drop_context() {
grpc_slice_buffer_init(&source);
grpc_slice_buffer_init(&relay);
grpc_slice_buffer_init(&sink);
- grpc_stream_compression_context *compress_ctx =
+ grpc_stream_compression_context* compress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS);
grpc_slice slice = grpc_slice_from_static_string(test_str);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH));
grpc_stream_compression_context_destroy(compress_ctx);
@@ -188,7 +189,7 @@ static void test_stream_compression_drop_context() {
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS);
slice = grpc_slice_from_static_string(test_str2);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH));
grpc_stream_compression_context_destroy(compress_ctx);
@@ -207,7 +208,7 @@ static void test_stream_compression_drop_context() {
grpc_slice_unref(slice2);
grpc_slice_buffer_add(&relay, slice3);
- grpc_stream_compression_context *decompress_ctx =
+ grpc_stream_compression_context* decompress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
bool end_of_context;
@@ -243,16 +244,16 @@ static void test_stream_compression_sync_flush() {
grpc_slice_buffer_init(&source);
grpc_slice_buffer_init(&relay);
grpc_slice_buffer_init(&sink);
- grpc_stream_compression_context *compress_ctx =
+ grpc_stream_compression_context* compress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS);
grpc_slice slice = grpc_slice_from_static_string(test_str);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_SYNC));
- grpc_stream_compression_context *decompress_ctx =
+ grpc_stream_compression_context* decompress_ctx =
grpc_stream_compression_context_create(
GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
bool end_of_context;
@@ -267,7 +268,7 @@ static void test_stream_compression_sync_flush() {
grpc_slice_buffer_init(&sink);
slice = grpc_slice_from_static_string(test_str2);
grpc_slice_buffer_add(&source, slice);
- GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, NULL,
+ GPR_ASSERT(grpc_stream_compress(compress_ctx, &source, &relay, nullptr,
~(size_t)0,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH));
grpc_stream_compression_context_destroy(compress_ctx);
@@ -284,7 +285,7 @@ static void test_stream_compression_sync_flush() {
grpc_slice_buffer_destroy(&sink);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_init();
test_stream_compression_simple_compress_decompress();
test_stream_compression_simple_compress_decompress_with_output_size_constraint();
diff --git a/test/core/debug/stats_test.cc b/test/core/debug/stats_test.cc
index c85ab3598a..e60e54b2fd 100644
--- a/test/core/debug/stats_test.cc
+++ b/test/core/debug/stats_test.cc
@@ -16,11 +16,13 @@
*
*/
-extern "C" {
#include "src/core/lib/debug/stats.h"
-}
+
+#include <mutex>
+#include <thread>
#include <grpc/grpc.h>
+#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <gtest/gtest.h>
@@ -47,9 +49,8 @@ TEST(StatsTest, IncCounters) {
for (int i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_COUNTER(&exec_ctx, (grpc_stats_counters)i);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_STATS_INC_COUNTER((grpc_stats_counters)i);
EXPECT_EQ(snapshot.delta().counters[i], 1);
}
@@ -58,9 +59,8 @@ TEST(StatsTest, IncCounters) {
TEST(StatsTest, IncSpecificCounter) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_SYSCALL_POLL(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_STATS_INC_SYSCALL_POLL();
EXPECT_EQ(snapshot.delta().counters[GRPC_STATS_COUNTER_SYSCALL_POLL], 1);
}
@@ -79,38 +79,65 @@ static int FindExpectedBucket(int i, int j) {
grpc_stats_histo_bucket_boundaries[i] - 1;
}
-TEST(StatsTest, IncHistogram) {
- for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
- std::vector<int> test_values;
- for (int j = -1000;
- j <
- grpc_stats_histo_bucket_boundaries[i]
- [grpc_stats_histo_buckets[i] - 1] +
- 1000;
- j++) {
- test_values.push_back(j);
- }
- std::random_shuffle(test_values.begin(), test_values.end());
- if (test_values.size() > 10000) {
- test_values.resize(10000);
- }
+class HistogramTest : public ::testing::TestWithParam<int> {};
+
+TEST_P(HistogramTest, IncHistogram) {
+ const int kHistogram = GetParam();
+ std::vector<std::thread> threads;
+ int cur_bucket = 0;
+ auto run = [kHistogram](const std::vector<int>& test_values,
+ int expected_bucket) {
+ gpr_log(GPR_DEBUG, "expected_bucket:%d nvalues=%" PRIdPTR, expected_bucket,
+ test_values.size());
for (auto j : test_values) {
Snapshot snapshot;
- int expected_bucket = FindExpectedBucket(i, j);
-
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_stats_inc_histogram[i](&exec_ctx, j);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_stats_inc_histogram[kHistogram](j);
auto delta = snapshot.delta();
- EXPECT_EQ(delta.histograms[grpc_stats_histo_start[i] + expected_bucket],
- 1);
+ EXPECT_EQ(
+ delta
+ .histograms[grpc_stats_histo_start[kHistogram] + expected_bucket],
+ 1)
+ << "\nhistogram:" << kHistogram
+ << "\nexpected_bucket:" << expected_bucket << "\nj:" << j;
+ }
+ };
+ std::vector<int> test_values;
+ // largest bucket boundary for current histogram type.
+ int max_bucket_boundary =
+ grpc_stats_histo_bucket_boundaries[kHistogram]
+ [grpc_stats_histo_buckets[kHistogram] -
+ 1];
+ for (int j = -1000; j < max_bucket_boundary + 1000;) {
+ int expected_bucket = FindExpectedBucket(kHistogram, j);
+ if (cur_bucket != expected_bucket) {
+ threads.emplace_back(
+ [test_values, run, cur_bucket]() { run(test_values, cur_bucket); });
+ cur_bucket = expected_bucket;
+ test_values.clear();
+ }
+ test_values.push_back(j);
+ if (j < max_bucket_boundary &&
+ FindExpectedBucket(kHistogram, j + 1000) == expected_bucket &&
+ FindExpectedBucket(kHistogram, j - 1000) == expected_bucket) {
+ // if we are far from bucket boundary, skip values to speed-up the tests
+ j += 500;
+ } else {
+ j++;
}
}
+ run(test_values, cur_bucket);
+ for (auto& t : threads) {
+ t.join();
+ }
}
+INSTANTIATE_TEST_CASE_P(HistogramTestCases, HistogramTest,
+ ::testing::Range<int>(0, GRPC_STATS_HISTOGRAM_COUNT));
+
} // namespace testing
} // namespace grpc
diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD
index 49bfc43646..f8281bfe6f 100644
--- a/test/core/end2end/BUILD
+++ b/test/core/end2end/BUILD
@@ -22,9 +22,9 @@ load(":generate_tests.bzl", "grpc_end2end_tests")
grpc_cc_library(
name = "cq_verifier",
- srcs = ["cq_verifier.c"],
+ srcs = ["cq_verifier.cc"],
hdrs = ["cq_verifier.h"],
- language = "C",
+ language = "C++",
visibility = ["//test:__subpackages__"],
deps = [
"//:gpr",
@@ -36,22 +36,22 @@ grpc_cc_library(
grpc_cc_library(
name = "ssl_test_data",
srcs = [
- "data/client_certs.c",
- "data/server1_cert.c",
- "data/server1_key.c",
- "data/test_root_cert.c",
+ "data/client_certs.cc",
+ "data/server1_cert.cc",
+ "data/server1_key.cc",
+ "data/test_root_cert.cc",
],
hdrs = ["data/ssl_test_data.h"],
- language = "C",
+ language = "C++",
visibility = ["//test:__subpackages__"],
)
grpc_cc_library(
name = "http_proxy",
- srcs = ["fixtures/http_proxy_fixture.c"],
+ srcs = ["fixtures/http_proxy_fixture.cc"],
hdrs = ["fixtures/http_proxy_fixture.h"],
- language = "C",
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -61,9 +61,9 @@ grpc_cc_library(
grpc_cc_library(
name = "proxy",
- srcs = ["fixtures/proxy.c"],
+ srcs = ["fixtures/proxy.cc"],
hdrs = ["fixtures/proxy.h"],
- language = "C",
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.cc
index eeabc769d3..a8e5e291c8 100644
--- a/test/core/end2end/bad_server_response_test.c
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -31,10 +31,10 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -62,8 +62,6 @@
#define HTTP2_DETAIL_MSG(STATUS_CODE) \
"Received http2 header with status: " #STATUS_CODE
-#define UNPARSEABLE_DETAIL_MSG "Failed parsing HTTP/2"
-
#define HTTP1_DETAIL_MSG "Trying to connect an http1.x server"
/* TODO(zyc) Check the content of incomming data instead of using this length */
@@ -72,17 +70,17 @@
#define SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD (size_t)200
struct rpc_state {
- char *target;
- grpc_completion_queue *cq;
- grpc_channel *channel;
- grpc_call *call;
+ char* target;
+ grpc_completion_queue* cq;
+ grpc_channel* channel;
+ grpc_call* call;
size_t incoming_data_length;
grpc_slice_buffer temp_incoming_buffer;
grpc_slice_buffer outgoing_buffer;
- grpc_endpoint *tcp;
+ grpc_endpoint* tcp;
gpr_atm done_atm;
bool write_done;
- const char *response_payload;
+ const char* response_payload;
size_t response_payload_length;
};
@@ -91,30 +89,30 @@ static struct rpc_state state;
static grpc_closure on_read;
static grpc_closure on_write;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+static void done_write(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
gpr_atm_rel_store(&state.done_atm, 1);
}
-static void handle_write(grpc_exec_ctx *exec_ctx) {
+static void handle_write() {
grpc_slice slice = grpc_slice_from_copied_buffer(
state.response_payload, state.response_payload_length);
grpc_slice_buffer_reset_and_unref(&state.outgoing_buffer);
grpc_slice_buffer_add(&state.outgoing_buffer, slice);
- grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write);
+ grpc_endpoint_write(state.tcp, &state.outgoing_buffer, &on_write);
}
-static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+static void handle_read(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
state.incoming_data_length += state.temp_incoming_buffer.length;
size_t i;
for (i = 0; i < state.temp_incoming_buffer.count; i++) {
- char *dump = grpc_dump_slice(state.temp_incoming_buffer.slices[i],
+ char* dump = grpc_dump_slice(state.temp_incoming_buffer.slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Server received: %s", dump);
gpr_free(dump);
@@ -125,26 +123,25 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD);
if (state.incoming_data_length >=
SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD) {
- handle_write(exec_ctx);
+ handle_write();
} else {
- grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
- &on_read);
+ grpc_endpoint_read(state.tcp, &state.temp_incoming_buffer, &on_read);
}
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
+static void on_connect(void* arg, grpc_endpoint* tcp,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- test_tcp_server *server = (test_tcp_server *)arg;
- GRPC_CLOSURE_INIT(&on_read, handle_read, NULL, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_INIT(&on_write, done_write, NULL, grpc_schedule_on_exec_ctx);
+ test_tcp_server* server = (test_tcp_server*)arg;
+ GRPC_CLOSURE_INIT(&on_read, handle_read, nullptr, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&on_write, done_write, nullptr, grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&state.temp_incoming_buffer);
grpc_slice_buffer_init(&state.outgoing_buffer);
state.tcp = tcp;
state.incoming_data_length = 0;
- grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset);
- grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read);
+ grpc_endpoint_add_to_pollset(tcp, server->pollset);
+ grpc_endpoint_read(tcp, &state.temp_incoming_buffer, &on_read);
}
static gpr_timespec n_sec_deadline(int seconds) {
@@ -153,25 +150,25 @@ static gpr_timespec n_sec_deadline(int seconds) {
}
static void start_rpc(int target_port, grpc_status_code expected_status,
- const char *expected_detail) {
+ const char* expected_detail) {
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_call_error error;
- cq_verifier *cqv;
+ cq_verifier* cqv;
grpc_slice details;
- state.cq = grpc_completion_queue_create_for_next(NULL);
+ state.cq = grpc_completion_queue_create_for_next(nullptr);
cqv = cq_verifier_create(state.cq);
gpr_join_host_port(&state.target, "127.0.0.1", target_port);
- state.channel = grpc_insecure_channel_create(state.target, NULL, NULL);
+ state.channel = grpc_insecure_channel_create(state.target, nullptr, nullptr);
grpc_slice host = grpc_slice_from_static_string("localhost");
state.call = grpc_channel_create_call(
- state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq,
+ state.channel, nullptr, GRPC_PROPAGATE_DEFAULTS, state.cq,
grpc_slice_from_static_string("/Service/Method"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -181,26 +178,26 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(state.call, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(state.call, ops, (size_t)(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
@@ -208,8 +205,10 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
cq_verify(cqv);
GPR_ASSERT(status == expected_status);
- GPR_ASSERT(-1 != grpc_slice_slice(details, grpc_slice_from_static_string(
- expected_detail)));
+ if (expected_detail != nullptr) {
+ GPR_ASSERT(-1 != grpc_slice_slice(details, grpc_slice_from_static_string(
+ expected_detail)));
+ }
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
@@ -217,14 +216,14 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
cq_verifier_destroy(cqv);
}
-static void cleanup_rpc(grpc_exec_ctx *exec_ctx) {
+static void cleanup_rpc() {
grpc_event ev;
- grpc_slice_buffer_destroy_internal(exec_ctx, &state.temp_incoming_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &state.outgoing_buffer);
+ grpc_slice_buffer_destroy_internal(&state.temp_incoming_buffer);
+ grpc_slice_buffer_destroy_internal(&state.outgoing_buffer);
grpc_call_unref(state.call);
grpc_completion_queue_shutdown(state.cq);
do {
- ev = grpc_completion_queue_next(state.cq, n_sec_deadline(1), NULL);
+ ev = grpc_completion_queue_next(state.cq, n_sec_deadline(1), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(state.cq);
grpc_channel_destroy(state.channel);
@@ -232,12 +231,12 @@ static void cleanup_rpc(grpc_exec_ctx *exec_ctx) {
}
typedef struct {
- test_tcp_server *server;
- gpr_event *signal_when_done;
+ test_tcp_server* server;
+ gpr_event* signal_when_done;
} poll_args;
-static void actually_poll_server(void *arg) {
- poll_args *pa = (poll_args *)arg;
+static void actually_poll_server(void* arg) {
+ poll_args* pa = (poll_args*)arg;
gpr_timespec deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&state.done_atm) != 0;
@@ -250,27 +249,27 @@ static void actually_poll_server(void *arg) {
}
test_tcp_server_poll(pa->server, 1);
}
- gpr_event_set(pa->signal_when_done, (void *)1);
+ gpr_event_set(pa->signal_when_done, (void*)1);
gpr_free(pa);
}
-static void poll_server_until_read_done(test_tcp_server *server,
- gpr_event *signal_when_done) {
+static void poll_server_until_read_done(test_tcp_server* server,
+ gpr_event* signal_when_done) {
gpr_atm_rel_store(&state.done_atm, 0);
state.write_done = 0;
gpr_thd_id id;
- poll_args *pa = (poll_args *)gpr_malloc(sizeof(*pa));
+ poll_args* pa = (poll_args*)gpr_malloc(sizeof(*pa));
pa->server = server;
pa->signal_when_done = signal_when_done;
- gpr_thd_new(&id, actually_poll_server, pa, NULL);
+ gpr_thd_new(&id, "grpc_poll_server", actually_poll_server, pa, nullptr);
}
-static void run_test(const char *response_payload,
+static void run_test(const char* response_payload,
size_t response_payload_length,
grpc_status_code expected_status,
- const char *expected_detail) {
+ const char* expected_detail) {
test_tcp_server test_server;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_event ev;
grpc_init();
@@ -287,18 +286,19 @@ static void run_test(const char *response_payload,
gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
/* clean up */
- grpc_endpoint_shutdown(&exec_ctx, state.tcp,
+ grpc_endpoint_shutdown(state.tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- grpc_endpoint_destroy(&exec_ctx, state.tcp);
- cleanup_rpc(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_destroy(state.tcp);
+ cleanup_rpc();
+ grpc_core::ExecCtx::Get()->Flush();
test_tcp_server_destroy(&test_server);
grpc_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
/* status defined in hpack static table */
run_test(HTTP2_RESP(204), sizeof(HTTP2_RESP(204)) - 1, GRPC_STATUS_CANCELLED,
@@ -330,12 +330,13 @@ int main(int argc, char **argv) {
HTTP2_DETAIL_MSG(502));
/* unparseable response */
- run_test(UNPARSEABLE_RESP, sizeof(UNPARSEABLE_RESP) - 1,
- GRPC_STATUS_UNAVAILABLE, UNPARSEABLE_DETAIL_MSG);
+ run_test(UNPARSEABLE_RESP, sizeof(UNPARSEABLE_RESP) - 1, GRPC_STATUS_UNKNOWN,
+ nullptr);
/* http1 response */
run_test(HTTP1_RESP, sizeof(HTTP1_RESP) - 1, GRPC_STATUS_UNAVAILABLE,
HTTP1_DETAIL_MSG);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.cc
index 40227dece4..ca6d17e7c8 100644
--- a/test/core/end2end/connection_refused_test.c
+++ b/test/core/end2end/connection_refused_test.cc
@@ -33,15 +33,15 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static void *tag(intptr_t i) { return (void *)i; }
+static void* tag(intptr_t i) { return (void*)i; }
static void run_test(bool wait_for_ready, bool use_service_config) {
- grpc_channel *chan;
- grpc_call *call;
- grpc_completion_queue *cq;
- cq_verifier *cqv;
+ grpc_channel* chan;
+ grpc_call* call;
+ grpc_completion_queue* cq;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_slice details;
@@ -53,17 +53,17 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_metadata_array_init(&trailing_metadata_recv);
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
cqv = cq_verifier_create(cq);
/* if using service config, create channel args */
- grpc_channel_args *args = NULL;
+ grpc_channel_args* args = nullptr;
if (use_service_config) {
GPR_ASSERT(wait_for_ready);
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
- arg.value.string =
+ arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG);
+ arg.value.string = const_cast<char*>(
"{\n"
" \"methodConfig\": [ {\n"
" \"name\": [\n"
@@ -71,21 +71,22 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
" ],\n"
" \"waitForReady\": true\n"
" } ]\n"
- "}";
+ "}");
args = grpc_channel_args_copy_and_add(args, &arg, 1);
}
/* create a call, channel to a port which will refuse connection */
int port = grpc_pick_unused_port_or_die();
- char *addr;
+ char* addr;
gpr_join_host_port(&addr, "127.0.0.1", port);
gpr_log(GPR_INFO, "server: %s", addr);
- chan = grpc_insecure_channel_create(addr, args, NULL);
+ chan = grpc_insecure_channel_create(addr, args, nullptr);
grpc_slice host = grpc_slice_from_static_string("nonexistant");
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2);
- call = grpc_channel_create_call(
- chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
- grpc_slice_from_static_string("/service/method"), &host, deadline, NULL);
+ call =
+ grpc_channel_create_call(chan, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_slice_from_static_string("/service/method"),
+ &host, deadline, nullptr);
gpr_free(addr);
@@ -96,17 +97,18 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
op->flags = (wait_for_ready && !use_service_config)
? GRPC_INITIAL_METADATA_WAIT_FOR_READY
: 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
- call, ops, (size_t)(op - ops), tag(1), NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops), tag(1),
+ nullptr));
/* verify that all tags get completed */
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
@@ -118,9 +120,9 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
}
grpc_completion_queue_shutdown(cq);
- while (
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type != GRPC_QUEUE_SHUTDOWN)
+ while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type != GRPC_QUEUE_SHUTDOWN)
;
grpc_completion_queue_destroy(cq);
grpc_call_unref(call);
@@ -131,15 +133,14 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_metadata_array_destroy(&trailing_metadata_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (args != NULL) grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ if (args != nullptr) grpc_channel_args_destroy(args);
}
grpc_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_test(false /* wait_for_ready */, false /* use_service_config */);
run_test(true /* wait_for_ready */, false /* use_service_config */);
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.cc
index bb978923b2..7bf8ae0f6e 100644
--- a/test/core/end2end/cq_verifier.c
+++ b/test/core/end2end/cq_verifier.cc
@@ -29,7 +29,7 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/event_string.h"
#define ROOT_EXPECTATION 1000
@@ -38,43 +38,43 @@
typedef struct metadata {
size_t count;
size_t cap;
- char **keys;
- char **values;
+ char** keys;
+ char** values;
} metadata;
/* details what we expect to find on a single event - and forms a linked
list to detail other expectations */
typedef struct expectation {
- struct expectation *next;
- const char *file;
+ struct expectation* next;
+ const char* file;
int line;
grpc_completion_type type;
- void *tag;
+ void* tag;
int success;
} expectation;
/* the verifier itself */
struct cq_verifier {
/* bound completion queue */
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
/* start of expectation list */
- expectation *first_expectation;
+ expectation* first_expectation;
};
-cq_verifier *cq_verifier_create(grpc_completion_queue *cq) {
- cq_verifier *v = (cq_verifier *)gpr_malloc(sizeof(cq_verifier));
+cq_verifier* cq_verifier_create(grpc_completion_queue* cq) {
+ cq_verifier* v = (cq_verifier*)gpr_malloc(sizeof(cq_verifier));
v->cq = cq;
- v->first_expectation = NULL;
+ v->first_expectation = nullptr;
return v;
}
-void cq_verifier_destroy(cq_verifier *v) {
+void cq_verifier_destroy(cq_verifier* v) {
cq_verify(v);
gpr_free(v);
}
-static int has_metadata(const grpc_metadata *md, size_t count, const char *key,
- const char *value) {
+static int has_metadata(const grpc_metadata* md, size_t count, const char* key,
+ const char* value) {
size_t i;
for (i = 0; i < count; i++) {
if (0 == grpc_slice_str_cmp(md[i].key, key) &&
@@ -85,12 +85,12 @@ static int has_metadata(const grpc_metadata *md, size_t count, const char *key,
return 0;
}
-int contains_metadata(grpc_metadata_array *array, const char *key,
- const char *value) {
+int contains_metadata(grpc_metadata_array* array, const char* key,
+ const char* value) {
return has_metadata(array->metadata, array->count, key, value);
}
-static int has_metadata_slices(const grpc_metadata *md, size_t count,
+static int has_metadata_slices(const grpc_metadata* md, size_t count,
grpc_slice key, grpc_slice value) {
size_t i;
for (i = 0; i < count; i++) {
@@ -101,15 +101,15 @@ static int has_metadata_slices(const grpc_metadata *md, size_t count,
return 0;
}
-int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key,
+int contains_metadata_slices(grpc_metadata_array* array, grpc_slice key,
grpc_slice value) {
return has_metadata_slices(array->metadata, array->count, key, value);
}
-static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) {
+static grpc_slice merge_slices(grpc_slice* slices, size_t nslices) {
size_t i;
size_t len = 0;
- uint8_t *cursor;
+ uint8_t* cursor;
grpc_slice out;
for (i = 0; i < nslices; i++) {
@@ -128,7 +128,7 @@ static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) {
return out;
}
-int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) {
+int raw_byte_buffer_eq_slice(grpc_byte_buffer* rbb, grpc_slice b) {
grpc_slice a;
int ok;
@@ -144,9 +144,9 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) {
return ok;
}
-int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b) {
+int byte_buffer_eq_slice(grpc_byte_buffer* bb, grpc_slice b) {
grpc_byte_buffer_reader reader;
- grpc_byte_buffer *rbb;
+ grpc_byte_buffer* rbb;
int res;
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb) &&
@@ -159,9 +159,9 @@ int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b) {
return res;
}
-int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) {
+int byte_buffer_eq_string(grpc_byte_buffer* bb, const char* str) {
grpc_byte_buffer_reader reader;
- grpc_byte_buffer *rbb;
+ grpc_byte_buffer* rbb;
int res;
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb) &&
@@ -174,10 +174,10 @@ int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) {
return res;
}
-static bool is_probably_integer(void *p) { return ((uintptr_t)p) < 1000000; }
+static bool is_probably_integer(void* p) { return ((uintptr_t)p) < 1000000; }
-static void expectation_to_strvec(gpr_strvec *buf, expectation *e) {
- char *tmp;
+static void expectation_to_strvec(gpr_strvec* buf, expectation* e) {
+ char* tmp;
if (is_probably_integer(e->tag)) {
gpr_asprintf(&tmp, "tag(%" PRIdPTR ") ", (intptr_t)e->tag);
@@ -200,29 +200,29 @@ static void expectation_to_strvec(gpr_strvec *buf, expectation *e) {
}
}
-static void expectations_to_strvec(gpr_strvec *buf, cq_verifier *v) {
- expectation *e;
+static void expectations_to_strvec(gpr_strvec* buf, cq_verifier* v) {
+ expectation* e;
- for (e = v->first_expectation; e != NULL; e = e->next) {
+ for (e = v->first_expectation; e != nullptr; e = e->next) {
expectation_to_strvec(buf, e);
gpr_strvec_add(buf, gpr_strdup("\n"));
}
}
-static void fail_no_event_received(cq_verifier *v) {
+static void fail_no_event_received(cq_verifier* v) {
gpr_strvec buf;
- char *msg;
+ char* msg;
gpr_strvec_init(&buf);
gpr_strvec_add(&buf, gpr_strdup("no event received, but expected:\n"));
expectations_to_strvec(&buf, v);
- msg = gpr_strvec_flatten(&buf, NULL);
+ msg = gpr_strvec_flatten(&buf, nullptr);
gpr_log(GPR_ERROR, "%s", msg);
gpr_strvec_destroy(&buf);
gpr_free(msg);
abort();
}
-static void verify_matches(expectation *e, grpc_event *ev) {
+static void verify_matches(expectation* e, grpc_event* ev) {
GPR_ASSERT(e->type == ev->type);
switch (e->type) {
case GRPC_OP_COMPLETE:
@@ -230,7 +230,7 @@ static void verify_matches(expectation *e, grpc_event *ev) {
gpr_strvec expected;
gpr_strvec_init(&expected);
expectation_to_strvec(&expected, e);
- char *s = gpr_strvec_flatten(&expected, NULL);
+ char* s = gpr_strvec_flatten(&expected, nullptr);
gpr_strvec_destroy(&expected);
gpr_log(GPR_ERROR, "actual success does not match expected: %s", s);
gpr_free(s);
@@ -248,34 +248,34 @@ static void verify_matches(expectation *e, grpc_event *ev) {
}
}
-void cq_verify(cq_verifier *v) {
+void cq_verify(cq_verifier* v) {
const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
- while (v->first_expectation != NULL) {
- grpc_event ev = grpc_completion_queue_next(v->cq, deadline, NULL);
+ while (v->first_expectation != nullptr) {
+ grpc_event ev = grpc_completion_queue_next(v->cq, deadline, nullptr);
if (ev.type == GRPC_QUEUE_TIMEOUT) {
fail_no_event_received(v);
break;
}
- expectation *e;
- expectation *prev = NULL;
- for (e = v->first_expectation; e != NULL; e = e->next) {
+ expectation* e;
+ expectation* prev = nullptr;
+ for (e = v->first_expectation; e != nullptr; e = e->next) {
if (e->tag == ev.tag) {
verify_matches(e, &ev);
if (e == v->first_expectation) v->first_expectation = e->next;
- if (prev != NULL) prev->next = e->next;
+ if (prev != nullptr) prev->next = e->next;
gpr_free(e);
break;
}
prev = e;
}
- if (e == NULL) {
- char *s = grpc_event_string(&ev);
+ if (e == nullptr) {
+ char* s = grpc_event_string(&ev);
gpr_log(GPR_ERROR, "cq returned unexpected event: %s", s);
gpr_free(s);
gpr_strvec expectations;
gpr_strvec_init(&expectations);
expectations_to_strvec(&expectations, v);
- s = gpr_strvec_flatten(&expectations, NULL);
+ s = gpr_strvec_flatten(&expectations, nullptr);
gpr_strvec_destroy(&expectations);
gpr_log(GPR_ERROR, "expected tags:\n%s", s);
gpr_free(s);
@@ -284,28 +284,29 @@ void cq_verify(cq_verifier *v) {
}
}
-void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec) {
+void cq_verify_empty_timeout(cq_verifier* v, int timeout_sec) {
gpr_timespec deadline =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(timeout_sec, GPR_TIMESPAN));
grpc_event ev;
- GPR_ASSERT(v->first_expectation == NULL && "expectation queue must be empty");
+ GPR_ASSERT(v->first_expectation == nullptr &&
+ "expectation queue must be empty");
- ev = grpc_completion_queue_next(v->cq, deadline, NULL);
+ ev = grpc_completion_queue_next(v->cq, deadline, nullptr);
if (ev.type != GRPC_QUEUE_TIMEOUT) {
- char *s = grpc_event_string(&ev);
+ char* s = grpc_event_string(&ev);
gpr_log(GPR_ERROR, "unexpected event (expected nothing): %s", s);
gpr_free(s);
abort();
}
}
-void cq_verify_empty(cq_verifier *v) { cq_verify_empty_timeout(v, 1); }
+void cq_verify_empty(cq_verifier* v) { cq_verify_empty_timeout(v, 1); }
-static void add(cq_verifier *v, const char *file, int line,
- grpc_completion_type type, void *tag, bool success) {
- expectation *e = (expectation *)gpr_malloc(sizeof(expectation));
+static void add(cq_verifier* v, const char* file, int line,
+ grpc_completion_type type, void* tag, bool success) {
+ expectation* e = (expectation*)gpr_malloc(sizeof(expectation));
e->type = type;
e->file = file;
e->line = line;
@@ -315,7 +316,7 @@ static void add(cq_verifier *v, const char *file, int line,
v->first_expectation = e;
}
-void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag,
+void cq_expect_completion(cq_verifier* v, const char* file, int line, void* tag,
bool success) {
add(v, file, line, GRPC_OP_COMPLETE, tag, success);
}
diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h
index cc80b58c90..959f849cb1 100644
--- a/test/core/end2end/cq_verifier.h
+++ b/test/core/end2end/cq_verifier.h
@@ -30,33 +30,33 @@
typedef struct cq_verifier cq_verifier;
/* construct/destroy a cq_verifier */
-cq_verifier *cq_verifier_create(grpc_completion_queue *cq);
-void cq_verifier_destroy(cq_verifier *v);
+cq_verifier* cq_verifier_create(grpc_completion_queue* cq);
+void cq_verifier_destroy(cq_verifier* v);
/* ensure all expected events (and only those events) are present on the
bound completion queue */
-void cq_verify(cq_verifier *v);
+void cq_verify(cq_verifier* v);
/* ensure that the completion queue is empty */
-void cq_verify_empty(cq_verifier *v);
+void cq_verify_empty(cq_verifier* v);
/* ensure that the completion queue is empty, waiting up to \a timeout secs. */
-void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec);
+void cq_verify_empty_timeout(cq_verifier* v, int timeout_sec);
/* Various expectation matchers
Any functions taking ... expect a NULL terminated list of key/value pairs
(each pair using two parameter slots) of metadata that MUST be present in
the event. */
-void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag,
+void cq_expect_completion(cq_verifier* v, const char* file, int line, void* tag,
bool success);
#define CQ_EXPECT_COMPLETION(v, tag, success) \
cq_expect_completion(v, __FILE__, __LINE__, tag, success)
-int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b);
-int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string);
-int contains_metadata(grpc_metadata_array *array, const char *key,
- const char *value);
-int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key,
+int byte_buffer_eq_slice(grpc_byte_buffer* bb, grpc_slice b);
+int byte_buffer_eq_string(grpc_byte_buffer* byte_buffer, const char* string);
+int contains_metadata(grpc_metadata_array* array, const char* key,
+ const char* value);
+int contains_metadata_slices(grpc_metadata_array* array, grpc_slice key,
grpc_slice value);
#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */
diff --git a/test/core/end2end/cq_verifier_internal.h b/test/core/end2end/cq_verifier_internal.h
index 0aa8dc6b1c..0629e0e5a7 100644
--- a/test/core/end2end/cq_verifier_internal.h
+++ b/test/core/end2end/cq_verifier_internal.h
@@ -23,10 +23,10 @@
typedef struct expectation expectation;
-expectation *cq_verifier_get_first_expectation(cq_verifier *v);
+expectation* cq_verifier_get_first_expectation(cq_verifier* v);
-void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e);
+void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e);
-grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds);
+grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds);
#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_INTERNAL_H */
diff --git a/test/core/end2end/cq_verifier_native.c b/test/core/end2end/cq_verifier_native.cc
index f19b15c465..e93956b188 100644
--- a/test/core/end2end/cq_verifier_native.c
+++ b/test/core/end2end/cq_verifier_native.cc
@@ -19,41 +19,42 @@
/* This check is for testing only. */
#ifndef GRPC_UV
+#include <grpc/support/alloc.h>
+
#include "test/core/end2end/cq_verifier_internal.h"
/* the verifier itself */
struct cq_verifier {
/* bound completion queue */
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
/* start of expectation list */
- expectation *first_expectation;
- uv_timer_t timer;
+ expectation* first_expectation;
};
-cq_verifier *cq_verifier_create(grpc_completion_queue *cq) {
- cq_verifier *v = gpr_malloc(sizeof(cq_verifier));
+cq_verifier* cq_verifier_create(grpc_completion_queue* cq) {
+ cq_verifier* v = static_cast<cq_verifier*>(gpr_malloc(sizeof(cq_verifier)));
v->cq = cq;
- cq_verifier_set_first_expectation(v, NULL);
+ cq_verifier_set_first_expectation(v, nullptr);
return v;
}
-void cq_verifier_destroy(cq_verifier *v) {
+void cq_verifier_destroy(cq_verifier* v) {
cq_verify(v);
gpr_free(v);
}
-expectation *cq_verifier_get_first_expectation(cq_verifier *v) {
+expectation* cq_verifier_get_first_expectation(cq_verifier* v) {
return v->first_expectation;
}
-void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) {
+void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e) {
v->first_expectation = e;
}
-grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) {
+grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds) {
const gpr_timespec deadline =
grpc_timeout_seconds_to_deadline(timeout_seconds);
- return grpc_completion_queue_next(v->cq, deadline, NULL);
+ return grpc_completion_queue_next(v->cq, deadline, nullptr);
}
#endif /* GRPC_UV */
diff --git a/test/core/end2end/cq_verifier_uv.c b/test/core/end2end/cq_verifier_uv.cc
index fc873b784f..e23b3ae2a0 100644
--- a/test/core/end2end/cq_verifier_uv.c
+++ b/test/core/end2end/cq_verifier_uv.cc
@@ -36,56 +36,56 @@ typedef enum timer_state {
/* the verifier itself */
struct cq_verifier {
/* bound completion queue */
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
/* start of expectation list */
- expectation *first_expectation;
+ expectation* first_expectation;
uv_timer_t timer;
};
-cq_verifier *cq_verifier_create(grpc_completion_queue *cq) {
- cq_verifier *v = gpr_malloc(sizeof(cq_verifier));
+cq_verifier* cq_verifier_create(grpc_completion_queue* cq) {
+ cq_verifier* v = static_cast<cq_verifier*>(gpr_malloc(sizeof(cq_verifier)));
v->cq = cq;
v->first_expectation = NULL;
uv_timer_init(uv_default_loop(), &v->timer);
- v->timer.data = (void *)TIMER_STARTED;
+ v->timer.data = (void*)TIMER_STARTED;
return v;
}
-static void timer_close_cb(uv_handle_t *handle) {
- handle->data = (void *)TIMER_CLOSED;
+static void timer_close_cb(uv_handle_t* handle) {
+ handle->data = (void*)TIMER_CLOSED;
}
-void cq_verifier_destroy(cq_verifier *v) {
+void cq_verifier_destroy(cq_verifier* v) {
cq_verify(v);
- uv_close((uv_handle_t *)&v->timer, timer_close_cb);
- while ((timer_state)v->timer.data != TIMER_CLOSED) {
+ uv_close((uv_handle_t*)&v->timer, timer_close_cb);
+ while (reinterpret_cast<timer_state>(v->timer.data) != TIMER_CLOSED) {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
gpr_free(v);
}
-expectation *cq_verifier_get_first_expectation(cq_verifier *v) {
+expectation* cq_verifier_get_first_expectation(cq_verifier* v) {
return v->first_expectation;
}
-void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) {
+void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e) {
v->first_expectation = e;
}
-static void timer_run_cb(uv_timer_t *timer) {
- timer->data = (void *)TIMER_TRIGGERED;
+static void timer_run_cb(uv_timer_t* timer) {
+ timer->data = (void*)TIMER_TRIGGERED;
}
-grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) {
+grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds) {
uint64_t timeout_ms =
timeout_seconds < 0 ? 0 : (uint64_t)timeout_seconds * 1000;
grpc_event ev;
- v->timer.data = (void *)TIMER_STARTED;
+ v->timer.data = (void*)TIMER_STARTED;
uv_timer_start(&v->timer, timer_run_cb, timeout_ms, 0);
ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC),
NULL);
// Stop the loop if the timer goes off or we get a non-timeout event
- while (((timer_state)v->timer.data != TIMER_TRIGGERED) &&
+ while ((reinterpret_cast<timer_state>(v->timer.data) != TIMER_TRIGGERED) &&
ev.type == GRPC_QUEUE_TIMEOUT) {
uv_run(uv_default_loop(), UV_RUN_ONCE);
ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC),
diff --git a/test/core/end2end/data/client_certs.c b/test/core/end2end/data/client_certs.cc
index 78770674c4..46fc13927c 100644
--- a/test/core/end2end/data/client_certs.c
+++ b/test/core/end2end/data/client_certs.cc
@@ -16,7 +16,7 @@
*
*/
-const char test_self_signed_client_cert[] = {
+extern const char test_self_signed_client_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6f, 0x44, 0x43, 0x43,
@@ -100,7 +100,7 @@ const char test_self_signed_client_cert[] = {
0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x0a, 0x00};
-const char test_self_signed_client_key[] = {
+extern const char test_self_signed_client_key[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x50,
0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x64, 0x77, 0x49, 0x42,
@@ -179,7 +179,7 @@ const char test_self_signed_client_key[] = {
0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x00};
-const char test_signed_client_cert[] = {
+extern const char test_signed_client_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x48, 0x7a, 0x43, 0x43,
@@ -248,7 +248,7 @@ const char test_signed_client_cert[] = {
0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00};
-const char test_signed_client_key[] = {
+extern const char test_signed_client_key[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x50,
0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x65, 0x51, 0x49, 0x42,
diff --git a/test/core/end2end/data/server1_cert.c b/test/core/end2end/data/server1_cert.cc
index 8d149607b6..0943244ecc 100644
--- a/test/core/end2end/data/server1_cert.c
+++ b/test/core/end2end/data/server1_cert.cc
@@ -16,7 +16,7 @@
*
*/
-const char test_server1_cert[] = {
+extern const char test_server1_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6e, 0x44, 0x43, 0x43,
diff --git a/test/core/end2end/data/server1_key.c b/test/core/end2end/data/server1_key.cc
index eee5cc6d82..8f3ad15c26 100644
--- a/test/core/end2end/data/server1_key.c
+++ b/test/core/end2end/data/server1_key.cc
@@ -16,7 +16,7 @@
*
*/
-const char test_server1_key[] = {
+extern const char test_server1_key[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52,
0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b,
0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43,
diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h
index e9c7dbceb2..303f3a6eda 100644
--- a/test/core/end2end/data/ssl_test_data.h
+++ b/test/core/end2end/data/ssl_test_data.h
@@ -19,10 +19,6 @@
#ifndef GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H
#define GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const char test_root_cert[];
extern const char test_server1_cert[];
extern const char test_server1_key[];
@@ -31,8 +27,4 @@ extern const char test_self_signed_client_key[];
extern const char test_signed_client_cert[];
extern const char test_signed_client_key[];
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */
diff --git a/test/core/end2end/data/test_root_cert.c b/test/core/end2end/data/test_root_cert.cc
index ef39ca56ab..b4771b2cb8 100644
--- a/test/core/end2end/data/test_root_cert.c
+++ b/test/core/end2end/data/test_root_cert.cc
@@ -16,7 +16,7 @@
*
*/
-const char test_root_cert[] = {
+extern const char test_root_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x49, 0x7a, 0x43, 0x43,
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.cc
index f9150f145a..bb30547cd2 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.cc
@@ -29,46 +29,60 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
/* This test exercises IPv4, IPv6, and dualstack sockets in various ways. */
-static void *tag(intptr_t i) { return (void *)i; }
+static void* tag(intptr_t i) { return (void*)i; }
-static gpr_timespec ms_from_now(int ms) {
- return grpc_timeout_milliseconds_to_deadline(ms);
-}
-
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, ms_from_now(5000), NULL);
+ ev = grpc_completion_queue_next(
+ cq, grpc_timeout_milliseconds_to_deadline(5000), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void do_nothing(void *ignored) {}
+static void do_nothing(void* ignored) {}
+
+static void log_resolved_addrs(const char* label, const char* hostname) {
+ grpc_resolved_addresses* res = nullptr;
+ grpc_error* error = grpc_blocking_resolve_address(hostname, "80", &res);
+ if (error != GRPC_ERROR_NONE || res == nullptr) {
+ GRPC_LOG_IF_ERROR(hostname, error);
+ return;
+ }
+ for (size_t i = 0; i < res->naddrs; ++i) {
+ char* addr_str = grpc_sockaddr_to_uri(&res->addrs[i]);
+ gpr_log(GPR_INFO, "%s: %s", label, addr_str);
+ gpr_free(addr_str);
+ }
+ grpc_resolved_addresses_destroy(res);
+}
-void test_connect(const char *server_host, const char *client_host, int port,
+void test_connect(const char* server_host, const char* client_host, int port,
int expect_ok) {
- char *client_hostport;
- char *server_hostport;
- grpc_channel *client;
- grpc_server *server;
- grpc_completion_queue *cq;
- grpc_completion_queue *shutdown_cq;
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv;
+ char* client_hostport;
+ char* server_hostport;
+ grpc_channel* client;
+ grpc_server* server;
+ grpc_completion_queue* cq;
+ grpc_completion_queue* shutdown_cq;
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv;
gpr_timespec deadline;
int got_port;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -77,7 +91,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
grpc_slice details;
int was_cancelled = 2;
grpc_call_details call_details;
- char *peer;
+ char* peer;
int picked_port = 0;
if (port == 0) {
@@ -93,9 +107,9 @@ void test_connect(const char *server_host, const char *client_host, int port,
grpc_call_details_init(&call_details);
/* Create server. */
- cq = grpc_completion_queue_create_for_next(NULL);
- server = grpc_server_create(NULL, NULL);
- grpc_server_register_completion_queue(server, cq, NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
+ server = grpc_server_create(nullptr, nullptr);
+ grpc_server_register_completion_queue(server, cq, nullptr);
GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port(
server, server_hostport)) > 0);
if (port == 0) {
@@ -112,20 +126,21 @@ void test_connect(const char *server_host, const char *client_host, int port,
size_t i;
grpc_slice uri_slice;
grpc_slice_buffer uri_parts;
- char **hosts_with_port;
+ char** hosts_with_port;
uri_slice =
- grpc_slice_new((char *)client_host, strlen(client_host), do_nothing);
+ grpc_slice_new((char*)client_host, strlen(client_host), do_nothing);
grpc_slice_buffer_init(&uri_parts);
grpc_slice_split(uri_slice, ",", &uri_parts);
- hosts_with_port = gpr_malloc(sizeof(char *) * uri_parts.count);
+ hosts_with_port =
+ static_cast<char**>(gpr_malloc(sizeof(char*) * uri_parts.count));
for (i = 0; i < uri_parts.count; i++) {
- char *uri_part_str = grpc_slice_to_c_string(uri_parts.slices[i]);
+ char* uri_part_str = grpc_slice_to_c_string(uri_parts.slices[i]);
gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port);
gpr_free(uri_part_str);
}
- client_hostport = gpr_strjoin_sep((const char **)hosts_with_port,
- uri_parts.count, ",", NULL);
+ client_hostport = gpr_strjoin_sep((const char**)hosts_with_port,
+ uri_parts.count, ",", nullptr);
for (i = 0; i < uri_parts.count; i++) {
gpr_free(hosts_with_port[i]);
}
@@ -135,28 +150,30 @@ void test_connect(const char *server_host, const char *client_host, int port,
} else {
gpr_join_host_port(&client_hostport, client_host, port);
}
- client = grpc_insecure_channel_create(client_hostport, NULL, NULL);
+ client = grpc_insecure_channel_create(client_hostport, nullptr, nullptr);
gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)",
server_hostport, client_hostport, expect_ok ? "success" : "failure");
+ log_resolved_addrs("server resolved addr", server_host);
+ log_resolved_addrs("client resolved addr", client_host);
gpr_free(client_hostport);
gpr_free(server_hostport);
if (expect_ok) {
/* Normal deadline, shouldn't be reached. */
- deadline = ms_from_now(60000);
+ deadline = grpc_timeout_milliseconds_to_deadline(60000);
} else {
/* Give up faster when failure is expected.
BUG: Setting this to 1000 reveals a memory leak (b/18608927). */
- deadline = ms_from_now(1500);
+ deadline = grpc_timeout_milliseconds_to_deadline(3000);
}
/* Send a trivial request. */
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr");
- c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ c = grpc_channel_create_call(client, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), &host,
- deadline, NULL);
+ deadline, nullptr);
GPR_ASSERT(c);
memset(ops, 0, sizeof(ops));
@@ -164,25 +181,25 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = expect_ok ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
if (expect_ok) {
@@ -210,7 +227,8 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -234,6 +252,8 @@ void test_connect(const char *server_host, const char *client_host, int port,
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
+ gpr_log(GPR_INFO, "status: %d (expected: %d)", status,
+ GRPC_STATUS_UNAVAILABLE);
GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
}
@@ -245,11 +265,11 @@ void test_connect(const char *server_host, const char *client_host, int port,
grpc_channel_destroy(client);
/* Destroy server. */
- shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(server);
grpc_completion_queue_destroy(shutdown_cq);
@@ -268,18 +288,18 @@ void test_connect(const char *server_host, const char *client_host, int port,
}
}
-int external_dns_works(const char *host) {
- grpc_resolved_addresses *res = NULL;
- grpc_error *error = grpc_blocking_resolve_address(host, "80", &res);
+int external_dns_works(const char* host) {
+ grpc_resolved_addresses* res = nullptr;
+ grpc_error* error = grpc_blocking_resolve_address(host, "80", &res);
GRPC_ERROR_UNREF(error);
- if (res != NULL) {
+ if (res != nullptr) {
grpc_resolved_addresses_destroy(res);
return 1;
}
return 0;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int do_ipv6 = 1;
grpc_test_init(argc, argv);
@@ -352,6 +372,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_nosec_tests.cc
index ca9443b642..6318550ad8 100644
--- a/test/core/end2end/end2end_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.cc
@@ -38,8 +38,6 @@ extern void bad_ping(grpc_end2end_test_config config);
extern void bad_ping_pre_init(void);
extern void binary_metadata(grpc_end2end_test_config config);
extern void binary_metadata_pre_init(void);
-extern void call_creds(grpc_end2end_test_config config);
-extern void call_creds_pre_init(void);
extern void cancel_after_accept(grpc_end2end_test_config config);
extern void cancel_after_accept_pre_init(void);
extern void cancel_after_client_done(grpc_end2end_test_config config);
@@ -70,6 +68,8 @@ extern void filter_causes_close(grpc_end2end_test_config config);
extern void filter_causes_close_pre_init(void);
extern void filter_latency(grpc_end2end_test_config config);
extern void filter_latency_pre_init(void);
+extern void filter_status_code(grpc_end2end_test_config config);
+extern void filter_status_code_pre_init(void);
extern void graceful_server_shutdown(grpc_end2end_test_config config);
extern void graceful_server_shutdown_pre_init(void);
extern void high_initial_seqno(grpc_end2end_test_config config);
@@ -157,7 +157,6 @@ void grpc_end2end_tests_pre_init(void) {
bad_hostname_pre_init();
bad_ping_pre_init();
binary_metadata_pre_init();
- call_creds_pre_init();
cancel_after_accept_pre_init();
cancel_after_client_done_pre_init();
cancel_after_invoke_pre_init();
@@ -173,6 +172,7 @@ void grpc_end2end_tests_pre_init(void) {
filter_call_init_fails_pre_init();
filter_causes_close_pre_init();
filter_latency_pre_init();
+ filter_status_code_pre_init();
graceful_server_shutdown_pre_init();
high_initial_seqno_pre_init();
hpack_size_pre_init();
@@ -225,7 +225,6 @@ void grpc_end2end_tests(int argc, char **argv,
bad_hostname(config);
bad_ping(config);
binary_metadata(config);
- call_creds(config);
cancel_after_accept(config);
cancel_after_client_done(config);
cancel_after_invoke(config);
@@ -241,6 +240,7 @@ void grpc_end2end_tests(int argc, char **argv,
filter_call_init_fails(config);
filter_causes_close(config);
filter_latency(config);
+ filter_status_code(config);
graceful_server_shutdown(config);
high_initial_seqno(config);
hpack_size(config);
@@ -300,10 +300,6 @@ void grpc_end2end_tests(int argc, char **argv,
binary_metadata(config);
continue;
}
- if (0 == strcmp("call_creds", argv[i])) {
- call_creds(config);
- continue;
- }
if (0 == strcmp("cancel_after_accept", argv[i])) {
cancel_after_accept(config);
continue;
@@ -364,6 +360,10 @@ void grpc_end2end_tests(int argc, char **argv,
filter_latency(config);
continue;
}
+ if (0 == strcmp("filter_status_code", argv[i])) {
+ filter_status_code(config);
+ continue;
+ }
if (0 == strcmp("graceful_server_shutdown", argv[i])) {
graceful_server_shutdown(config);
continue;
diff --git a/test/core/end2end/end2end_test_utils.c b/test/core/end2end/end2end_test_utils.cc
index c1f119548a..51d2730f0e 100644
--- a/test/core/end2end/end2end_test_utils.c
+++ b/test/core/end2end/end2end_test_utils.cc
@@ -22,27 +22,27 @@
#include <grpc/support/log.h>
-const char *get_host_override_string(const char *str,
+const char* get_host_override_string(const char* str,
grpc_end2end_test_config config) {
if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
return str;
} else {
- return NULL;
+ return nullptr;
}
}
-const grpc_slice *get_host_override_slice(const char *str,
+const grpc_slice* get_host_override_slice(const char* str,
grpc_end2end_test_config config) {
- const char *r = get_host_override_string(str, config);
- if (r != NULL) {
+ const char* r = get_host_override_string(str, config);
+ if (r != nullptr) {
static grpc_slice ret;
ret = grpc_slice_from_static_string(r);
return &ret;
}
- return NULL;
+ return nullptr;
}
-void validate_host_override_string(const char *pattern, grpc_slice str,
+void validate_host_override_string(const char* pattern, grpc_slice str,
grpc_end2end_test_config config) {
if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern));
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_tests.cc
index 3236feea56..9d8dfd6723 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_tests.cc
@@ -38,6 +38,8 @@ extern void bad_ping(grpc_end2end_test_config config);
extern void bad_ping_pre_init(void);
extern void binary_metadata(grpc_end2end_test_config config);
extern void binary_metadata_pre_init(void);
+extern void call_creds(grpc_end2end_test_config config);
+extern void call_creds_pre_init(void);
extern void cancel_after_accept(grpc_end2end_test_config config);
extern void cancel_after_accept_pre_init(void);
extern void cancel_after_client_done(grpc_end2end_test_config config);
@@ -68,6 +70,8 @@ extern void filter_causes_close(grpc_end2end_test_config config);
extern void filter_causes_close_pre_init(void);
extern void filter_latency(grpc_end2end_test_config config);
extern void filter_latency_pre_init(void);
+extern void filter_status_code(grpc_end2end_test_config config);
+extern void filter_status_code_pre_init(void);
extern void graceful_server_shutdown(grpc_end2end_test_config config);
extern void graceful_server_shutdown_pre_init(void);
extern void high_initial_seqno(grpc_end2end_test_config config);
@@ -155,6 +159,7 @@ void grpc_end2end_tests_pre_init(void) {
bad_hostname_pre_init();
bad_ping_pre_init();
binary_metadata_pre_init();
+ call_creds_pre_init();
cancel_after_accept_pre_init();
cancel_after_client_done_pre_init();
cancel_after_invoke_pre_init();
@@ -170,6 +175,7 @@ void grpc_end2end_tests_pre_init(void) {
filter_call_init_fails_pre_init();
filter_causes_close_pre_init();
filter_latency_pre_init();
+ filter_status_code_pre_init();
graceful_server_shutdown_pre_init();
high_initial_seqno_pre_init();
hpack_size_pre_init();
@@ -222,6 +228,7 @@ void grpc_end2end_tests(int argc, char **argv,
bad_hostname(config);
bad_ping(config);
binary_metadata(config);
+ call_creds(config);
cancel_after_accept(config);
cancel_after_client_done(config);
cancel_after_invoke(config);
@@ -237,6 +244,7 @@ void grpc_end2end_tests(int argc, char **argv,
filter_call_init_fails(config);
filter_causes_close(config);
filter_latency(config);
+ filter_status_code(config);
graceful_server_shutdown(config);
high_initial_seqno(config);
hpack_size(config);
@@ -296,6 +304,10 @@ void grpc_end2end_tests(int argc, char **argv,
binary_metadata(config);
continue;
}
+ if (0 == strcmp("call_creds", argv[i])) {
+ call_creds(config);
+ continue;
+ }
if (0 == strcmp("cancel_after_accept", argv[i])) {
cancel_after_accept(config);
continue;
@@ -356,6 +368,10 @@ void grpc_end2end_tests(int argc, char **argv,
filter_latency(config);
continue;
}
+ if (0 == strcmp("filter_status_code", argv[i])) {
+ filter_status_code(config);
+ continue;
+ }
if (0 == strcmp("graceful_server_shutdown", argv[i])) {
graceful_server_shutdown(config);
continue;
diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h
index 87269ec468..b42d90b55c 100644
--- a/test/core/end2end/end2end_tests.h
+++ b/test/core/end2end/end2end_tests.h
@@ -38,40 +38,40 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config;
#define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check"
struct grpc_end2end_test_fixture {
- grpc_completion_queue *cq;
- grpc_completion_queue *shutdown_cq;
- grpc_server *server;
- grpc_channel *client;
- void *fixture_data;
+ grpc_completion_queue* cq;
+ grpc_completion_queue* shutdown_cq;
+ grpc_server* server;
+ grpc_channel* client;
+ void* fixture_data;
};
struct grpc_end2end_test_config {
/* A descriptive name for this test fixture. */
- const char *name;
+ const char* name;
/* Which features are supported by this fixture. See feature flags above. */
uint32_t feature_mask;
- grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args *client_args,
- grpc_channel_args *server_args);
- void (*init_client)(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args);
- void (*init_server)(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args);
- void (*tear_down_data)(grpc_end2end_test_fixture *f);
+ grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args* client_args,
+ grpc_channel_args* server_args);
+ void (*init_client)(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args);
+ void (*init_server)(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args);
+ void (*tear_down_data)(grpc_end2end_test_fixture* f);
};
void grpc_end2end_tests_pre_init(void);
-void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config);
+void grpc_end2end_tests(int argc, char** argv, grpc_end2end_test_config config);
-const char *get_host_override_string(const char *str,
+const char* get_host_override_string(const char* str,
grpc_end2end_test_config config);
/* Returns a pointer to a statically allocated slice: future invocations
overwrite past invocations, not threadsafe, etc... */
-const grpc_slice *get_host_override_slice(const char *str,
+const grpc_slice* get_host_override_slice(const char* str,
grpc_end2end_test_config config);
-void validate_host_override_string(const char *pattern, grpc_slice str,
+void validate_host_override_string(const char* pattern, grpc_slice str,
grpc_end2end_test_config config);
#endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */
diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.cc
index 9870ccb34a..75c80aa1ff 100644
--- a/test/core/end2end/fixtures/h2_census.c
+++ b/test/core/end2end/fixtures/h2_census.cc
@@ -37,21 +37,22 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
@@ -59,60 +60,63 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
static grpc_arg make_census_enable_arg(void) {
grpc_arg arg;
arg.type = GRPC_ARG_INTEGER;
- arg.key = GRPC_ARG_ENABLE_CENSUS;
+ arg.key = const_cast<char*>(GRPC_ARG_ENABLE_CENSUS);
arg.value.integer = 1;
return arg;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
grpc_arg arg = make_census_enable_arg();
client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1);
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
}
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
grpc_arg arg = make_census_enable_arg();
if (f->server) {
grpc_server_destroy(f->server);
}
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
- f->server = grpc_server_create(server_args, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(server_args);
}
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack+census",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.cc
index 9866dea7eb..3625afefcd 100644
--- a/test/core/end2end/fixtures/h2_compress.c
+++ b/test/core/end2end/fixtures/h2_compress.cc
@@ -37,84 +37,86 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_compression_fixture_data {
- char *localaddr;
- grpc_channel_args *client_args_compression;
- grpc_channel_args *server_args_compression;
+ char* localaddr;
+ grpc_channel_args* client_args_compression;
+ grpc_channel_args* server_args_compression;
} fullstack_compression_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_compression_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_compression_fixture_data));
+ fullstack_compression_fixture_data* ffd =
+ static_cast<fullstack_compression_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_compression_fixture_data)));
memset(ffd, 0, sizeof(fullstack_compression_fixture_data));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
memset(&f, 0, sizeof(f));
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_compression_fixture_data *ffd = f->fixture_data;
- if (ffd->client_args_compression != NULL) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
- grpc_exec_ctx_finish(&exec_ctx);
+void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_compression_fixture_data* ffd =
+ static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
+ if (ffd->client_args_compression != nullptr) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(ffd->client_args_compression);
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
- client_args, GRPC_COMPRESS_GZIP);
- f->client = grpc_insecure_channel_create(ffd->localaddr,
- ffd->client_args_compression, NULL);
+ client_args, GRPC_COMPRESS_MESSAGE_GZIP);
+ f->client = grpc_insecure_channel_create(
+ ffd->localaddr, ffd->client_args_compression, nullptr);
}
-void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_compression_fixture_data *ffd = f->fixture_data;
- if (ffd->server_args_compression != NULL) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
- grpc_exec_ctx_finish(&exec_ctx);
+void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_compression_fixture_data* ffd =
+ static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
+ if (ffd->server_args_compression != nullptr) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(ffd->server_args_compression);
}
ffd->server_args_compression = grpc_channel_args_set_compression_algorithm(
- server_args, GRPC_COMPRESS_GZIP);
+ server_args, GRPC_COMPRESS_MESSAGE_GZIP);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(ffd->server_args_compression, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(ffd->server_args_compression, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- fullstack_compression_fixture_data *ffd = f->fixture_data;
- grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
- grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
+void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) {
+ grpc_core::ExecCtx exec_ctx;
+ fullstack_compression_fixture_data* ffd =
+ static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
+ grpc_channel_args_destroy(ffd->client_args_compression);
+ grpc_channel_args_destroy(ffd->server_args_compression);
gpr_free(ffd->localaddr);
gpr_free(ffd);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack_compression",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack_compression,
chttp2_init_client_fullstack_compression,
chttp2_init_server_fullstack_compression,
chttp2_tear_down_fullstack_compression},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.cc
index e622d952be..87d4668d50 100644
--- a/test/core/end2end/fixtures/h2_fakesec.c
+++ b/test/core/end2end/fixtures/h2_fakesec.cc
@@ -31,75 +31,79 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_secure_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_secure_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_secure_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-static void process_auth_failure(void *state, grpc_auth_context *ctx,
- const grpc_metadata *md, size_t md_count,
+static void process_auth_failure(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
- void *user_data) {
- GPR_ASSERT(state == NULL);
- cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
+ void* user_data) {
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
- grpc_channel_credentials *creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args,
+ grpc_channel_credentials* creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
f->client =
- grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
- GPR_ASSERT(f->client != NULL);
+ grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr);
+ GPR_ASSERT(f->client != nullptr);
grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
- grpc_server_credentials *server_creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args,
+ grpc_server_credentials* server_creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
-void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
static void chttp2_init_client_fake_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_channel_credentials *fake_ts_creds =
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
+ grpc_channel_credentials* fake_ts_creds =
grpc_fake_transport_security_credentials_create();
chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds);
}
-static int fail_server_auth_check(grpc_channel_args *server_args) {
+static int fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
- if (server_args == NULL) return 0;
+ if (server_args == nullptr) return 0;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {
@@ -110,11 +114,12 @@ static int fail_server_auth_check(grpc_channel_args *server_args) {
}
static void chttp2_init_server_fake_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
- grpc_server_credentials *fake_ts_creds =
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args) {
+ grpc_server_credentials* fake_ts_creds =
grpc_fake_transport_security_server_credentials_create();
if (fail_server_auth_check(server_args)) {
- grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL};
+ grpc_auth_metadata_processor processor = {process_auth_failure, nullptr,
+ nullptr};
grpc_server_credentials_set_auth_metadata_processor(fake_ts_creds,
processor);
}
@@ -135,7 +140,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_secure_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.cc
index e82c120221..9157ab04d0 100644
--- a/test/core/end2end/fixtures/h2_fd.c
+++ b/test/core/end2end/fixtures/h2_fd.cc
@@ -35,7 +35,9 @@
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include "test/core/util/test_config.h"
-typedef struct { int fd_pair[2]; } sp_fixture_data;
+typedef struct {
+ int fd_pair[2];
+} sp_fixture_data;
static void create_sockets(int sv[2]) {
int flags;
@@ -49,49 +51,46 @@ static void create_sockets(int sv[2]) {
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
- sp_fixture_data *fixture_data = gpr_malloc(sizeof(*fixture_data));
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
+ sp_fixture_data* fixture_data =
+ static_cast<sp_fixture_data*>(gpr_malloc(sizeof(*fixture_data)));
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
f.fixture_data = fixture_data;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
create_sockets(fixture_data->fd_pair);
return f;
}
-static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- sp_fixture_data *sfd = f->fixture_data;
+static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ grpc_core::ExecCtx exec_ctx;
+ sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data);
GPR_ASSERT(!f->client);
f->client = grpc_insecure_channel_create_from_fd(
"fixture_client", sfd->fd_pair[0], client_args);
GPR_ASSERT(f->client);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- sp_fixture_data *sfd = f->fixture_data;
+static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ grpc_core::ExecCtx exec_ctx;
+ sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data);
GPR_ASSERT(!f->server);
- f->server = grpc_server_create(server_args, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
GPR_ASSERT(f->server);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- grpc_server_add_insecure_channel_from_fd(f->server, NULL, sfd->fd_pair[1]);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_server_add_insecure_channel_from_fd(f->server, nullptr, sfd->fd_pair[1]);
}
-static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
+static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
gpr_free(f->fixture_data);
}
@@ -102,7 +101,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_init_server_socketpair, chttp2_tear_down_socketpair},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
@@ -120,6 +119,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.cc
index c764bd704a..b080591e85 100644
--- a/test/core/end2end/fixtures/h2_full+pipe.c
+++ b/test/core/end2end/fixtures/h2_full+pipe.cc
@@ -42,60 +42,66 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_allow_specialized_wakeup_fd = 0;
@@ -115,6 +121,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_WAKEUP_FD */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_WAKEUP_FD */
diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.cc
index 7eb29e0d32..7104fbc581 100644
--- a/test/core/end2end/fixtures/h2_full+trace.c
+++ b/test/core/end2end/fixtures/h2_full+trace.cc
@@ -35,67 +35,73 @@
#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/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
/* force tracing on, with a value to force many
diff --git a/test/core/end2end/fixtures/h2_full+workarounds.c b/test/core/end2end/fixtures/h2_full+workarounds.cc
index a98e5ad57f..237841d185 100644
--- a/test/core/end2end/fixtures/h2_full+workarounds.c
+++ b/test/core/end2end/fixtures/h2_full+workarounds.cc
@@ -36,77 +36,82 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static char *workarounds_arg[GRPC_MAX_WORKAROUND_ID] = {
- GRPC_ARG_WORKAROUND_CRONET_COMPRESSION};
+static char* workarounds_arg[GRPC_MAX_WORKAROUND_ID] = {
+ const_cast<char*>(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION)};
typedef struct fullstack_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- fullstack_fixture_data *ffd = f->fixture_data;
+ grpc_core::ExecCtx exec_ctx;
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
grpc_arg args[GRPC_MAX_WORKAROUND_ID];
for (i = 0; i < GRPC_MAX_WORKAROUND_ID; i++) {
args[i].key = workarounds_arg[i];
args[i].type = GRPC_ARG_INTEGER;
args[i].value.integer = 1;
}
- grpc_channel_args *server_args_new =
+ grpc_channel_args* server_args_new =
grpc_channel_args_copy_and_add(server_args, args, GRPC_MAX_WORKAROUND_ID);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args_new, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args_new, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
- grpc_channel_args_destroy(&exec_ctx, server_args_new);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(server_args_new);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER |
- FEATURE_MASK_SUPPORTS_WORKAROUNDS,
+ {"chttp2/fullstack",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER |
+ FEATURE_MASK_SUPPORTS_WORKAROUNDS,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.cc
index ae68bd9698..6d15c28662 100644
--- a/test/core/end2end/fixtures/h2_full.c
+++ b/test/core/end2end/fixtures/h2_full.cc
@@ -36,60 +36,66 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.cc
index 6145892365..e8e81f0930 100644
--- a/test/core/end2end/fixtures/h2_http_proxy.c
+++ b/test/core/end2end/fixtures/h2_http_proxy.cc
@@ -31,7 +31,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/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/fixtures/http_proxy_fixture.h"
@@ -39,15 +39,16 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- char *server_addr;
- grpc_end2end_http_proxy *proxy;
+ char* server_addr;
+ grpc_end2end_http_proxy* proxy;
} fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
const int server_port = grpc_pick_unused_port_or_die();
gpr_join_host_port(&ffd->server_addr, "localhost", server_port);
@@ -56,21 +57,22 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
ffd->proxy = grpc_end2end_http_proxy_create(client_args);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
- char *proxy_uri;
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ char* proxy_uri;
/* If testing for proxy auth, add credentials to proxy uri */
- const grpc_arg *proxy_auth_arg =
+ const grpc_arg* proxy_auth_arg =
grpc_channel_args_find(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
- if (proxy_auth_arg == NULL || proxy_auth_arg->type != GRPC_ARG_STRING) {
+ if (proxy_auth_arg == nullptr || proxy_auth_arg->type != GRPC_ARG_STRING) {
gpr_asprintf(&proxy_uri, "http://%s",
grpc_end2end_http_proxy_get_proxy_name(ffd->proxy));
} else {
@@ -79,24 +81,27 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
}
gpr_setenv("http_proxy", proxy_uri);
gpr_free(proxy_uri);
- f->client = grpc_insecure_channel_create(ffd->server_addr, client_args, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->server_addr, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->server_addr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->server_addr);
grpc_end2end_http_proxy_destroy(ffd->proxy);
gpr_free(ffd);
@@ -104,14 +109,15 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.cc
index 8a05bb722a..fda5f4b052 100644
--- a/test/core/end2end/fixtures/h2_load_reporting.c
+++ b/test/core/end2end/fixtures/h2_load_reporting.cc
@@ -38,54 +38,57 @@
#include "test/core/util/test_config.h"
typedef struct load_reporting_fixture_data {
- char *localaddr;
+ char* localaddr;
} load_reporting_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- load_reporting_fixture_data *ffd =
- gpr_malloc(sizeof(load_reporting_fixture_data));
+ load_reporting_fixture_data* ffd = static_cast<load_reporting_fixture_data*>(
+ gpr_malloc(sizeof(load_reporting_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_load_reporting(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- load_reporting_fixture_data *ffd = f->fixture_data;
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+void chttp2_init_client_load_reporting(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ load_reporting_fixture_data* ffd =
+ static_cast<load_reporting_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_load_reporting(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- load_reporting_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ load_reporting_fixture_data* ffd =
+ static_cast<load_reporting_fixture_data*>(f->fixture_data);
grpc_arg arg = grpc_load_reporting_enable_arg();
if (f->server) {
grpc_server_destroy(f->server);
}
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
- f->server = grpc_server_create(server_args, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(server_args);
}
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_load_reporting(grpc_end2end_test_fixture *f) {
- load_reporting_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_load_reporting(grpc_end2end_test_fixture* f) {
+ load_reporting_fixture_data* ffd =
+ static_cast<load_reporting_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
@@ -100,7 +103,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_init_server_load_reporting, chttp2_tear_down_load_reporting},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.cc
index ee1d0b1416..5fed4434de 100644
--- a/test/core/end2end/fixtures/h2_oauth2.c
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -32,16 +32,16 @@
#include "test/core/util/test_config.h"
static const char oauth2_md[] = "Bearer aaslkfjs424535asdf";
-static const char *client_identity_property_name = "smurf_name";
-static const char *client_identity = "Brainy Smurf";
+static const char* client_identity_property_name = "smurf_name";
+static const char* client_identity = "Brainy Smurf";
typedef struct fullstack_secure_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_secure_fixture_data;
-static const grpc_metadata *find_metadata(const grpc_metadata *md,
- size_t md_count, const char *key,
- const char *value) {
+static const grpc_metadata* find_metadata(const grpc_metadata* md,
+ size_t md_count, const char* key,
+ const char* value) {
size_t i;
for (i = 0; i < md_count; i++) {
if (grpc_slice_str_cmp(md[i].key, key) == 0 &&
@@ -49,116 +49,123 @@ static const grpc_metadata *find_metadata(const grpc_metadata *md,
return &md[i];
}
}
- return NULL;
+ return nullptr;
}
-typedef struct { size_t pseudo_refcount; } test_processor_state;
+typedef struct {
+ size_t pseudo_refcount;
+} test_processor_state;
-static void process_oauth2_success(void *state, grpc_auth_context *ctx,
- const grpc_metadata *md, size_t md_count,
+static void process_oauth2_success(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
- void *user_data) {
- const grpc_metadata *oauth2 =
+ void* user_data) {
+ const grpc_metadata* oauth2 =
find_metadata(md, md_count, "authorization", oauth2_md);
- test_processor_state *s;
+ test_processor_state* s;
- GPR_ASSERT(state != NULL);
- s = (test_processor_state *)state;
+ GPR_ASSERT(state != nullptr);
+ s = (test_processor_state*)state;
GPR_ASSERT(s->pseudo_refcount == 1);
- GPR_ASSERT(oauth2 != NULL);
+ GPR_ASSERT(oauth2 != nullptr);
grpc_auth_context_add_cstring_property(ctx, client_identity_property_name,
client_identity);
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
ctx, client_identity_property_name) == 1);
- cb(user_data, oauth2, 1, NULL, 0, GRPC_STATUS_OK, NULL);
+ cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_OK, nullptr);
}
-static void process_oauth2_failure(void *state, grpc_auth_context *ctx,
- const grpc_metadata *md, size_t md_count,
+static void process_oauth2_failure(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
- void *user_data) {
- const grpc_metadata *oauth2 =
+ void* user_data) {
+ const grpc_metadata* oauth2 =
find_metadata(md, md_count, "authorization", oauth2_md);
- test_processor_state *s;
- GPR_ASSERT(state != NULL);
- s = (test_processor_state *)state;
+ test_processor_state* s;
+ GPR_ASSERT(state != nullptr);
+ s = (test_processor_state*)state;
GPR_ASSERT(s->pseudo_refcount == 1);
- GPR_ASSERT(oauth2 != NULL);
- cb(user_data, oauth2, 1, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
+ GPR_ASSERT(oauth2 != nullptr);
+ cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_secure_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
static void chttp2_init_client_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
- grpc_channel_credentials *creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args,
+ grpc_channel_credentials* creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
f->client =
- grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
- GPR_ASSERT(f->client != NULL);
+ grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr);
+ GPR_ASSERT(f->client != nullptr);
grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
- grpc_server_credentials *server_creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args,
+ grpc_server_credentials* server_creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
-void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create(
- &exec_ctx, "authorization", oauth2_md, true /* is_async */);
- grpc_channel_credentials *ssl_oauth2_creds =
- grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
+ "authorization", oauth2_md, true /* is_async */);
+ grpc_channel_credentials* ssl_oauth2_creds =
+ grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds,
+ nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds);
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_channel_args_destroy(new_client_args);
grpc_channel_credentials_release(ssl_creds);
grpc_call_credentials_release(oauth2_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static int fail_server_auth_check(grpc_channel_args *server_args) {
+static int fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
- if (server_args == NULL) return 0;
+ if (server_args == nullptr) return 0;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {
@@ -168,14 +175,15 @@ static int fail_server_auth_check(grpc_channel_args *server_args) {
return 0;
}
-static void processor_destroy(void *state) {
- test_processor_state *s = (test_processor_state *)state;
+static void processor_destroy(void* state) {
+ test_processor_state* s = (test_processor_state*)state;
GPR_ASSERT((s->pseudo_refcount--) == 1);
gpr_free(s);
}
static grpc_auth_metadata_processor test_processor_create(int failing) {
- test_processor_state *s = gpr_malloc(sizeof(*s));
+ test_processor_state* s =
+ static_cast<test_processor_state*>(gpr_malloc(sizeof(*s)));
grpc_auth_metadata_processor result;
s->pseudo_refcount = 1;
result.state = s;
@@ -189,11 +197,11 @@ static grpc_auth_metadata_processor test_processor_create(int failing) {
}
static void chttp2_init_server_simple_ssl_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args) {
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_key_cert_pair, 1, 0, nullptr);
grpc_server_credentials_set_auth_metadata_processor(
ssl_creds, test_processor_create(fail_server_auth_check(server_args)));
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
@@ -213,7 +221,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_secure_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.cc
index 069130baf4..295654cb6a 100644
--- a/test/core/end2end/fixtures/h2_proxy.c
+++ b/test/core/end2end/fixtures/h2_proxy.cc
@@ -37,77 +37,82 @@
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- grpc_end2end_proxy *proxy;
+ grpc_end2end_proxy* proxy;
} fullstack_fixture_data;
-static grpc_server *create_proxy_server(const char *port,
- grpc_channel_args *server_args) {
- grpc_server *s = grpc_server_create(server_args, NULL);
+static grpc_server* create_proxy_server(const char* port,
+ grpc_channel_args* server_args) {
+ grpc_server* s = grpc_server_create(server_args, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(s, port));
return s;
}
-static grpc_channel *create_proxy_client(const char *target,
- grpc_channel_args *client_args) {
- return grpc_insecure_channel_create(target, client_args, NULL);
+static grpc_channel* create_proxy_client(const char* target,
+ grpc_channel_args* client_args) {
+ return grpc_insecure_channel_create(target, client_args, nullptr);
}
static const grpc_end2end_proxy_def proxy_def = {create_proxy_server,
create_proxy_client};
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
f->client = grpc_insecure_channel_create(
- grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, NULL);
+ grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, nullptr);
GPR_ASSERT(f->client);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(
f->server, grpc_end2end_proxy_get_server_port(ffd->proxy)));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
grpc_end2end_proxy_destroy(ffd->proxy);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_REQUEST_PROXYING |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack+proxy",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_REQUEST_PROXYING |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.cc
index 39ccb84b52..236780b8d3 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.c
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -36,9 +36,9 @@
#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/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/iomgr.h"
-#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
@@ -48,78 +48,72 @@
/* chttp2 transport that is immediately available (used for testing
connected_channel without a client_channel */
-static void server_setup_transport(void *ts, grpc_transport *transport) {
- grpc_end2end_test_fixture *f = ts;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq));
- grpc_server_setup_transport(&exec_ctx, f->server, transport, NULL,
+static void server_setup_transport(void* ts, grpc_transport* transport) {
+ grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
- grpc_end2end_test_fixture *f;
- grpc_channel_args *client_args;
+ grpc_end2end_test_fixture* f;
+ grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts,
- grpc_transport *transport) {
- sp_client_setup *cs = ts;
+static void client_setup_transport(void* ts, grpc_transport* transport) {
+ sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
- grpc_endpoint_pair *sfd = gpr_malloc(sizeof(grpc_endpoint_pair));
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
+ grpc_endpoint_pair* sfd =
+ static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair)));
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
f.fixture_data = sfd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
- *sfd = grpc_iomgr_create_endpoint_pair("fixture", NULL);
+ *sfd = grpc_iomgr_create_endpoint_pair("fixture", nullptr);
return f;
}
-static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_transport *transport;
+static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, true);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
-static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_transport *transport;
+static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_transport* transport;
GPR_ASSERT(!f->server);
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, false);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
-static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
+static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
gpr_free(f->fixture_data);
}
@@ -130,9 +124,8 @@ static grpc_end2end_test_config configs[] = {
chttp2_init_server_socketpair, chttp2_tear_down_socketpair},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
/* force tracing on, with a value to force many
code paths in trace.c to be taken */
@@ -146,7 +139,6 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
grpc_init();
- grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0));
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1));
diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.cc
index 03566ead9b..b68279fd71 100644
--- a/test/core/end2end/fixtures/h2_sockpair.c
+++ b/test/core/end2end/fixtures/h2_sockpair.cc
@@ -42,78 +42,72 @@
/* chttp2 transport that is immediately available (used for testing
connected_channel without a client_channel */
-static void server_setup_transport(void *ts, grpc_transport *transport) {
- grpc_end2end_test_fixture *f = ts;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq));
- grpc_server_setup_transport(&exec_ctx, f->server, transport, NULL,
+static void server_setup_transport(void* ts, grpc_transport* transport) {
+ grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
- grpc_end2end_test_fixture *f;
- grpc_channel_args *client_args;
+ grpc_end2end_test_fixture* f;
+ grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts,
- grpc_transport *transport) {
- sp_client_setup *cs = ts;
+static void client_setup_transport(void* ts, grpc_transport* transport) {
+ sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
- grpc_endpoint_pair *sfd = gpr_malloc(sizeof(grpc_endpoint_pair));
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
+ grpc_endpoint_pair* sfd =
+ static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair)));
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
f.fixture_data = sfd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
- *sfd = grpc_iomgr_create_endpoint_pair("fixture", NULL);
+ *sfd = grpc_iomgr_create_endpoint_pair("fixture", nullptr);
return f;
}
-static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_transport *transport;
+static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, true);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
-static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_transport *transport;
+static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_transport* transport;
GPR_ASSERT(!f->server);
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, false);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
-static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
+static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
gpr_free(f->fixture_data);
}
@@ -124,7 +118,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_init_server_socketpair, chttp2_tear_down_socketpair},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
index c75a3876d5..350be138ca 100644
--- a/test/core/end2end/fixtures/h2_sockpair_1byte.c
+++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
@@ -42,88 +42,83 @@
/* chttp2 transport that is immediately available (used for testing
connected_channel without a client_channel */
-static void server_setup_transport(void *ts, grpc_transport *transport) {
- grpc_end2end_test_fixture *f = ts;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq));
- grpc_server_setup_transport(&exec_ctx, f->server, transport, NULL,
+static void server_setup_transport(void* ts, grpc_transport* transport) {
+ grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
- grpc_end2end_test_fixture *f;
- grpc_channel_args *client_args;
+ grpc_end2end_test_fixture* f;
+ grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts,
- grpc_transport *transport) {
- sp_client_setup *cs = ts;
+static void client_setup_transport(void* ts, grpc_transport* transport) {
+ sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
- grpc_endpoint_pair *sfd = gpr_malloc(sizeof(grpc_endpoint_pair));
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
+ grpc_endpoint_pair* sfd =
+ static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair)));
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
f.fixture_data = sfd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
-
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = 1},
- {.key = GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = 1},
- {.key = GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = 1}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
+
+ grpc_arg a[3];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER;
+ a[0].value.integer = 1;
+ a[1].key = const_cast<char*>(GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE);
+ a[1].type = GRPC_ARG_INTEGER;
+ a[1].value.integer = 1;
+ a[2].key = const_cast<char*>(GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE);
+ a[2].type = GRPC_ARG_INTEGER;
+ a[2].value.integer = 1;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
*sfd = grpc_iomgr_create_endpoint_pair("fixture", &args);
return f;
}
-static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_transport *transport;
+static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, true);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
-static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_pair *sfd = f->fixture_data;
- grpc_transport *transport;
+static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
+ grpc_transport* transport;
GPR_ASSERT(!f->server);
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, false);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
-static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
+static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
gpr_free(f->fixture_data);
}
@@ -135,7 +130,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_socketpair},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
g_fixture_slowdown_factor = 2;
diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.cc
index 0bac464e69..8c5c8a2f3f 100644
--- a/test/core/end2end/fixtures/h2_ssl.c
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -26,94 +26,98 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
typedef struct fullstack_secure_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_secure_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_secure_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-static void process_auth_failure(void *state, grpc_auth_context *ctx,
- const grpc_metadata *md, size_t md_count,
+static void process_auth_failure(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
- void *user_data) {
- GPR_ASSERT(state == NULL);
- cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
+ void* user_data) {
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
- grpc_channel_credentials *creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args,
+ grpc_channel_credentials* creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
f->client =
- grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
- GPR_ASSERT(f->client != NULL);
+ grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr);
+ GPR_ASSERT(f->client != nullptr);
grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
- grpc_server_credentials *server_creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args,
+ grpc_server_credentials* server_creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
-void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
static void chttp2_init_client_simple_ssl_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(NULL, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
}
-static int fail_server_auth_check(grpc_channel_args *server_args) {
+static int fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
- if (server_args == NULL) return 0;
+ if (server_args == nullptr) return 0;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {
@@ -124,13 +128,14 @@ static int fail_server_auth_check(grpc_channel_args *server_args) {
}
static void chttp2_init_server_simple_ssl_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args) {
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_cert_key_pair, 1, 0, nullptr);
if (fail_server_auth_check(server_args)) {
- grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL};
+ grpc_auth_metadata_processor processor = {process_auth_failure, nullptr,
+ nullptr};
grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor);
}
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
@@ -150,19 +155,19 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_secure_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
- FILE *roots_file;
+ FILE* roots_file;
size_t roots_size = strlen(test_root_cert);
- char *roots_filename;
+ char* roots_filename;
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
/* Set the SSL roots env var. */
roots_file = gpr_tmpfile("chttp2_simple_ssl_fullstack_test", &roots_filename);
- GPR_ASSERT(roots_filename != NULL);
- GPR_ASSERT(roots_file != NULL);
+ GPR_ASSERT(roots_filename != nullptr);
+ GPR_ASSERT(roots_file != nullptr);
GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size);
fclose(roots_file);
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename);
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index 8bc7183510..3f0646cf0f 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.c
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -26,48 +26,48 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/end2end/fixtures/proxy.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
typedef struct fullstack_secure_fixture_data {
- grpc_end2end_proxy *proxy;
+ grpc_end2end_proxy* proxy;
} fullstack_secure_fixture_data;
-static grpc_server *create_proxy_server(const char *port,
- grpc_channel_args *server_args) {
- grpc_server *s = grpc_server_create(server_args, NULL);
+static grpc_server* create_proxy_server(const char* port,
+ grpc_channel_args* server_args) {
+ grpc_server* s = grpc_server_create(server_args, nullptr);
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_cert_key_pair, 1, 0, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(s, port, ssl_creds));
grpc_server_credentials_release(ssl_creds);
return s;
}
-static grpc_channel *create_proxy_client(const char *target,
- grpc_channel_args *client_args) {
- grpc_channel *channel;
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(NULL, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
+static grpc_channel* create_proxy_client(const char* target,
+ grpc_channel_args* client_args) {
+ grpc_channel* channel;
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
channel =
- grpc_secure_channel_create(ssl_creds, target, new_client_args, NULL);
+ grpc_secure_channel_create(ssl_creds, target, new_client_args, nullptr);
grpc_channel_credentials_release(ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
return channel;
}
@@ -76,81 +76,85 @@ static const grpc_end2end_proxy_def proxy_def = {create_proxy_server,
create_proxy_client};
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
- fullstack_secure_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f));
ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-static void process_auth_failure(void *state, grpc_auth_context *ctx,
- const grpc_metadata *md, size_t md_count,
+static void process_auth_failure(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
- void *user_data) {
- GPR_ASSERT(state == NULL);
- cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
+ void* user_data) {
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
- grpc_channel_credentials *creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args,
+ grpc_channel_credentials* creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
f->client = grpc_secure_channel_create(
creds, grpc_end2end_proxy_get_client_target(ffd->proxy), client_args,
- NULL);
- GPR_ASSERT(f->client != NULL);
+ nullptr);
+ GPR_ASSERT(f->client != nullptr);
grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
- grpc_server_credentials *server_creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args,
+ grpc_server_credentials* server_creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(
f->server, grpc_end2end_proxy_get_server_port(ffd->proxy), server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
-void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_end2end_proxy_destroy(ffd->proxy);
gpr_free(ffd);
}
static void chttp2_init_client_simple_ssl_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(NULL, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
}
-static int fail_server_auth_check(grpc_channel_args *server_args) {
+static int fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
- if (server_args == NULL) return 0;
+ if (server_args == nullptr) return 0;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {
@@ -161,13 +165,14 @@ static int fail_server_auth_check(grpc_channel_args *server_args) {
}
static void chttp2_init_server_simple_ssl_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args) {
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_cert_key_pair, 1, 0, nullptr);
if (fail_server_auth_check(server_args)) {
- grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL};
+ grpc_auth_metadata_processor processor = {process_auth_failure, nullptr,
+ nullptr};
grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor);
}
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
@@ -188,19 +193,19 @@ static grpc_end2end_test_config configs[] = {
chttp2_tear_down_secure_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
- FILE *roots_file;
+ FILE* roots_file;
size_t roots_size = strlen(test_root_cert);
- char *roots_filename;
+ char* roots_filename;
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
/* Set the SSL roots env var. */
roots_file = gpr_tmpfile("chttp2_simple_ssl_fullstack_test", &roots_filename);
- GPR_ASSERT(roots_filename != NULL);
- GPR_ASSERT(roots_file != NULL);
+ GPR_ASSERT(roots_filename != nullptr);
+ GPR_ASSERT(roots_file != nullptr);
GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size);
fclose(roots_file);
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename);
diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.cc
index 05a31985e7..1944dd84a3 100644
--- a/test/core/end2end/fixtures/h2_uds.c
+++ b/test/core/end2end/fixtures/h2_uds.cc
@@ -33,68 +33,74 @@
#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/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
typedef struct fullstack_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_fixture_data;
static int unique = 1;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
- fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data));
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_asprintf(&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(),
unique++);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
- f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL);
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
}
-void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
-void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
+ {"chttp2/fullstack_uds",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.c b/test/core/end2end/fixtures/http_proxy_fixture.cc
index a4cfc77bcb..8ec97df3e4 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.c
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -34,6 +34,7 @@
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/combiner.h"
@@ -49,7 +50,6 @@
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/port.h"
struct grpc_end2end_http_proxy {
@@ -68,6 +68,9 @@ struct grpc_end2end_http_proxy {
// Connection handling
//
+// proxy_connection structure is only accessed in the closures which are all
+// scheduled under the same combiner lock. So there is is no need for a mutex to
+// protect this structure.
typedef struct proxy_connection {
grpc_end2end_http_proxy* proxy;
@@ -78,6 +81,8 @@ typedef struct proxy_connection {
grpc_pollset_set* pollset_set;
+ // NOTE: All the closures execute under proxy->combiner lock. Which means
+ // there will not be any data-races between the closures
grpc_closure on_read_request_done;
grpc_closure on_server_connect_done;
grpc_closure on_write_response_done;
@@ -86,11 +91,20 @@ typedef struct proxy_connection {
grpc_closure on_server_read_done;
grpc_closure on_server_write_done;
+ bool client_read_failed : 1;
+ bool client_write_failed : 1;
+ bool client_shutdown : 1;
+ bool server_read_failed : 1;
+ bool server_write_failed : 1;
+ bool server_shutdown : 1;
+
grpc_slice_buffer client_read_buffer;
grpc_slice_buffer client_deferred_write_buffer;
+ bool client_is_writing;
grpc_slice_buffer client_write_buffer;
grpc_slice_buffer server_read_buffer;
grpc_slice_buffer server_deferred_write_buffer;
+ bool server_is_writing;
grpc_slice_buffer server_write_buffer;
grpc_http_parser http_parser;
@@ -102,24 +116,21 @@ static void proxy_connection_ref(proxy_connection* conn, const char* reason) {
}
// Helper function to destroy the proxy connection.
-static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
- proxy_connection* conn, const char* reason) {
+static void proxy_connection_unref(proxy_connection* conn, const char* reason) {
if (gpr_unref(&conn->refcount)) {
gpr_log(GPR_DEBUG, "endpoints: %p %p", conn->client_endpoint,
conn->server_endpoint);
- grpc_endpoint_destroy(exec_ctx, conn->client_endpoint);
- if (conn->server_endpoint != NULL) {
- grpc_endpoint_destroy(exec_ctx, conn->server_endpoint);
+ grpc_endpoint_destroy(conn->client_endpoint);
+ if (conn->server_endpoint != nullptr) {
+ grpc_endpoint_destroy(conn->server_endpoint);
}
- grpc_pollset_set_destroy(exec_ctx, conn->pollset_set);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &conn->client_deferred_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &conn->server_deferred_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_write_buffer);
+ grpc_pollset_set_destroy(conn->pollset_set);
+ grpc_slice_buffer_destroy_internal(&conn->client_read_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->client_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->client_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_read_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_write_buffer);
grpc_http_parser_destroy(&conn->http_parser);
grpc_http_request_destroy(&conn->http_request);
gpr_unref(&conn->proxy->users);
@@ -127,30 +138,59 @@ static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
}
}
+enum failure_type {
+ SETUP_FAILED, // To be used before we start proxying.
+ CLIENT_READ_FAILED,
+ CLIENT_WRITE_FAILED,
+ SERVER_READ_FAILED,
+ SERVER_WRITE_FAILED,
+};
+
// Helper function to shut down the proxy connection.
-// Does NOT take ownership of a reference to error.
-static void proxy_connection_failed(grpc_exec_ctx* exec_ctx,
- proxy_connection* conn, bool is_client,
- const char* prefix, grpc_error* error) {
- const char* msg = grpc_error_string(error);
- gpr_log(GPR_INFO, "%s: %s", prefix, msg);
-
- grpc_endpoint_shutdown(exec_ctx, conn->client_endpoint,
- GRPC_ERROR_REF(error));
- if (conn->server_endpoint != NULL) {
- grpc_endpoint_shutdown(exec_ctx, conn->server_endpoint,
- GRPC_ERROR_REF(error));
+static void proxy_connection_failed(proxy_connection* conn,
+ failure_type failure, const char* prefix,
+ grpc_error* error) {
+ gpr_log(GPR_INFO, "%s: %s", prefix, grpc_error_string(error));
+ // Decide whether we should shut down the client and server.
+ bool shutdown_client = false;
+ bool shutdown_server = false;
+ if (failure == SETUP_FAILED) {
+ shutdown_client = true;
+ shutdown_server = true;
+ } else {
+ if ((failure == CLIENT_READ_FAILED && conn->client_write_failed) ||
+ (failure == CLIENT_WRITE_FAILED && conn->client_read_failed) ||
+ (failure == SERVER_READ_FAILED && !conn->client_is_writing)) {
+ shutdown_client = true;
+ }
+ if ((failure == SERVER_READ_FAILED && conn->server_write_failed) ||
+ (failure == SERVER_WRITE_FAILED && conn->server_read_failed) ||
+ (failure == CLIENT_READ_FAILED && !conn->server_is_writing)) {
+ shutdown_server = true;
+ }
+ }
+ // If we decided to shut down either one and have not yet done so, do so.
+ if (shutdown_client && !conn->client_shutdown) {
+ grpc_endpoint_shutdown(conn->client_endpoint, GRPC_ERROR_REF(error));
+ conn->client_shutdown = true;
}
- proxy_connection_unref(exec_ctx, conn, "conn_failed");
+ if (shutdown_server && !conn->server_shutdown &&
+ (conn->server_endpoint != nullptr)) {
+ grpc_endpoint_shutdown(conn->server_endpoint, GRPC_ERROR_REF(error));
+ conn->server_shutdown = true;
+ }
+ // Unref the connection.
+ proxy_connection_unref(conn, "conn_failed");
+ GRPC_ERROR_UNREF(error);
}
// Callback for writing proxy data to the client.
-static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_client_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
+ conn->client_is_writing = false;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy client write", error);
+ proxy_connection_failed(conn, CLIENT_WRITE_FAILED,
+ "HTTP proxy client write", GRPC_ERROR_REF(error));
return;
}
// Clear write buffer (the data we just wrote).
@@ -160,22 +200,22 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
if (conn->client_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer,
&conn->client_write_buffer);
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ conn->client_is_writing = true;
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done);
} else {
// No more writes. Unref the connection.
- proxy_connection_unref(exec_ctx, conn, "write_done");
+ proxy_connection_unref(conn, "write_done");
}
}
// Callback for writing proxy data to the backend server.
-static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
+ conn->server_is_writing = false;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, false /* is_client */,
- "HTTP proxy server write", error);
+ proxy_connection_failed(conn, SERVER_WRITE_FAILED,
+ "HTTP proxy server write", GRPC_ERROR_REF(error));
return;
}
// Clear write buffer (the data we just wrote).
@@ -185,23 +225,22 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
if (conn->server_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer,
&conn->server_write_buffer);
- grpc_endpoint_write(exec_ctx, conn->server_endpoint,
- &conn->server_write_buffer,
+ conn->server_is_writing = true;
+ grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done);
} else {
// No more writes. Unref the connection.
- proxy_connection_unref(exec_ctx, conn, "server_write");
+ proxy_connection_unref(conn, "server_write");
}
}
// Callback for reading data from the client, which will be proxied to
// the backend server.
-static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_client_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy client read", error);
+ proxy_connection_failed(conn, CLIENT_READ_FAILED, "HTTP proxy client read",
+ GRPC_ERROR_REF(error));
return;
}
// If there is already a pending write (i.e., server_write_buffer is
@@ -210,30 +249,29 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
// the current write is finished.
//
// Otherwise, move the read data into the write buffer and write it.
- if (conn->server_write_buffer.length > 0) {
+ if (conn->server_is_writing) {
grpc_slice_buffer_move_into(&conn->client_read_buffer,
&conn->server_deferred_write_buffer);
} else {
grpc_slice_buffer_move_into(&conn->client_read_buffer,
&conn->server_write_buffer);
proxy_connection_ref(conn, "client_read");
- grpc_endpoint_write(exec_ctx, conn->server_endpoint,
- &conn->server_write_buffer,
+ conn->server_is_writing = true;
+ grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done);
}
// Read more data.
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done);
}
// Callback for reading data from the backend server, which will be
// proxied to the client.
-static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, false /* is_client */,
- "HTTP proxy server read", error);
+ proxy_connection_failed(conn, SERVER_READ_FAILED, "HTTP proxy server read",
+ GRPC_ERROR_REF(error));
return;
}
// If there is already a pending write (i.e., client_write_buffer is
@@ -242,29 +280,29 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
// the current write is finished.
//
// Otherwise, move the read data into the write buffer and write it.
- if (conn->client_write_buffer.length > 0) {
+ if (conn->client_is_writing) {
grpc_slice_buffer_move_into(&conn->server_read_buffer,
&conn->client_deferred_write_buffer);
} else {
grpc_slice_buffer_move_into(&conn->server_read_buffer,
&conn->client_write_buffer);
proxy_connection_ref(conn, "server_read");
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ conn->client_is_writing = true;
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done);
}
// Read more data.
- grpc_endpoint_read(exec_ctx, conn->server_endpoint, &conn->server_read_buffer,
+ grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done);
}
// Callback to write the HTTP response for the CONNECT request.
-static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_write_response_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
+ conn->client_is_writing = false;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy write response", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy write response",
+ GRPC_ERROR_REF(error));
return;
}
// Clear write buffer.
@@ -274,17 +312,16 @@ static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
// for the other one.
proxy_connection_ref(conn, "client_read");
proxy_connection_ref(conn, "server_read");
- proxy_connection_unref(exec_ctx, conn, "write_response");
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ proxy_connection_unref(conn, "write_response");
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done);
- grpc_endpoint_read(exec_ctx, conn->server_endpoint, &conn->server_read_buffer,
+ grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done);
}
// Callback to connect to the backend server specified by the HTTP
// CONNECT request.
-static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_connect_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
// TODO(roth): Technically, in this case, we should handle the error
@@ -292,8 +329,8 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
// connection failed. However, for the purposes of this test code,
// it's fine to pretend this is a client-side error, which will
// cause the client connection to be dropped.
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy server connect", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy server connect",
+ GRPC_ERROR_REF(error));
return;
}
// We've established a connection, so send back a 200 response code to
@@ -302,8 +339,8 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice slice =
grpc_slice_from_copied_string("HTTP/1.0 200 connected\r\n\r\n");
grpc_slice_buffer_add(&conn->client_write_buffer, slice);
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ conn->client_is_writing = true;
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_write_response_done);
}
@@ -312,20 +349,18 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
* Basic <base64_encoded_expected_cred>
* Returns true if it matches, false otherwise
*/
-static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
- char* proxy_auth_header_val,
+static bool proxy_auth_header_matches(char* proxy_auth_header_val,
char* expected_cred) {
- GPR_ASSERT(proxy_auth_header_val != NULL);
- GPR_ASSERT(expected_cred != NULL);
+ GPR_ASSERT(proxy_auth_header_val != nullptr);
+ GPR_ASSERT(expected_cred != nullptr);
if (strncmp(proxy_auth_header_val, "Basic ", 6) != 0) {
return false;
}
proxy_auth_header_val += 6;
- grpc_slice decoded_slice =
- grpc_base64_decode(exec_ctx, proxy_auth_header_val, 0);
+ grpc_slice decoded_slice = grpc_base64_decode(proxy_auth_header_val, 0);
const bool header_matches =
grpc_slice_str_cmp(decoded_slice, expected_cred) == 0;
- grpc_slice_unref_internal(exec_ctx, decoded_slice);
+ grpc_slice_unref_internal(decoded_slice);
return header_matches;
}
@@ -335,24 +370,23 @@ static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
// the client indicating that the request failed. However, for the purposes
// of this test code, it's fine to pretend this is a client-side error,
// which will cause the client connection to be dropped.
-static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_read_request_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn,
grpc_error_string(error));
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy read request", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy read request",
+ GRPC_ERROR_REF(error));
return;
}
// Read request and feed it to the parser.
for (size_t i = 0; i < conn->client_read_buffer.count; ++i) {
if (GRPC_SLICE_LENGTH(conn->client_read_buffer.slices[i]) > 0) {
- error = grpc_http_parser_parse(&conn->http_parser,
- conn->client_read_buffer.slices[i], NULL);
+ error = grpc_http_parser_parse(
+ &conn->http_parser, conn->client_read_buffer.slices[i], nullptr);
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy request parse", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy request parse",
+ GRPC_ERROR_REF(error));
GRPC_ERROR_UNREF(error);
return;
}
@@ -361,8 +395,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_reset_and_unref(&conn->client_read_buffer);
// If we're not done reading the request, read more data.
if (conn->http_parser.state != GRPC_HTTP_BODY) {
- grpc_endpoint_read(exec_ctx, conn->client_endpoint,
- &conn->client_read_buffer, &conn->on_read_request_done);
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
+ &conn->on_read_request_done);
return;
}
// Make sure we got a CONNECT request.
@@ -372,56 +406,55 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
conn->http_request.method);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy read request", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy read request",
+ GRPC_ERROR_REF(error));
GRPC_ERROR_UNREF(error);
return;
}
// If proxy auth is being used, check if the header is present and as expected
const grpc_arg* proxy_auth_arg = grpc_channel_args_find(
conn->proxy->channel_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
- if (proxy_auth_arg != NULL && proxy_auth_arg->type == GRPC_ARG_STRING) {
+ if (proxy_auth_arg != nullptr && proxy_auth_arg->type == GRPC_ARG_STRING) {
bool client_authenticated = false;
for (size_t i = 0; i < conn->http_request.hdr_count; i++) {
if (strcmp(conn->http_request.hdrs[i].key, "Proxy-Authorization") == 0) {
client_authenticated = proxy_auth_header_matches(
- exec_ctx, conn->http_request.hdrs[i].value,
- proxy_auth_arg->value.string);
+ conn->http_request.hdrs[i].value, proxy_auth_arg->value.string);
break;
}
}
if (!client_authenticated) {
const char* msg = "HTTP Connect could not verify authentication";
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(msg);
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy read request", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy read request",
+ GRPC_ERROR_REF(error));
GRPC_ERROR_UNREF(error);
return;
}
}
// Resolve address.
- grpc_resolved_addresses* resolved_addresses = NULL;
+ grpc_resolved_addresses* resolved_addresses = nullptr;
error = grpc_blocking_resolve_address(conn->http_request.path, "80",
&resolved_addresses);
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy DNS lookup", error);
+ proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy DNS lookup",
+ GRPC_ERROR_REF(error));
GRPC_ERROR_UNREF(error);
return;
}
GPR_ASSERT(resolved_addresses->naddrs >= 1);
// Connect to requested address.
// The connection callback inherits our reference to conn.
- const gpr_timespec deadline = gpr_time_add(
- gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(10, GPR_TIMESPAN));
- grpc_tcp_client_connect(exec_ctx, &conn->on_server_connect_done,
- &conn->server_endpoint, conn->pollset_set, NULL,
+ const grpc_millis deadline =
+ grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC;
+ grpc_tcp_client_connect(&conn->on_server_connect_done, &conn->server_endpoint,
+ conn->pollset_set, nullptr,
&resolved_addresses->addrs[0], deadline);
grpc_resolved_addresses_destroy(resolved_addresses);
}
-static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* endpoint, grpc_pollset* accepting_pollset,
+static void on_accept(void* arg, grpc_endpoint* endpoint,
+ grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
@@ -432,8 +465,8 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
conn->proxy = proxy;
gpr_ref_init(&conn->refcount, 1);
conn->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, conn->pollset_set, proxy->pollset);
- grpc_endpoint_add_to_pollset_set(exec_ctx, endpoint, conn->pollset_set);
+ grpc_pollset_set_add_pollset(conn->pollset_set, proxy->pollset);
+ grpc_endpoint_add_to_pollset_set(endpoint, conn->pollset_set);
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_server_connect_done, on_server_connect_done, conn,
@@ -450,13 +483,15 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
grpc_combiner_scheduler(conn->proxy->combiner));
grpc_slice_buffer_init(&conn->client_read_buffer);
grpc_slice_buffer_init(&conn->client_deferred_write_buffer);
+ conn->client_is_writing = false;
grpc_slice_buffer_init(&conn->client_write_buffer);
grpc_slice_buffer_init(&conn->server_read_buffer);
grpc_slice_buffer_init(&conn->server_deferred_write_buffer);
+ conn->server_is_writing = false;
grpc_slice_buffer_init(&conn->server_write_buffer);
grpc_http_parser_init(&conn->http_parser, GRPC_HTTP_REQUEST,
&conn->http_request);
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_read_request_done);
}
@@ -466,26 +501,23 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
static void thread_main(void* arg) {
grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
do {
gpr_ref(&proxy->users);
- const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- const gpr_timespec deadline =
- gpr_time_add(now, gpr_time_from_seconds(1, GPR_TIMESPAN));
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(proxy->mu);
GRPC_LOG_IF_ERROR(
"grpc_pollset_work",
- grpc_pollset_work(&exec_ctx, proxy->pollset, &worker, now, deadline));
+ grpc_pollset_work(proxy->pollset, &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC));
gpr_mu_unlock(proxy->mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
} while (!gpr_unref(&proxy->users));
- grpc_exec_ctx_finish(&exec_ctx);
}
grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_channel_args* args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_end2end_http_proxy* proxy =
(grpc_end2end_http_proxy*)gpr_malloc(sizeof(*proxy));
memset(proxy, 0, sizeof(*proxy));
@@ -497,8 +529,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name);
// Create TCP server.
proxy->channel_args = grpc_channel_args_copy(args);
- grpc_error* error = grpc_tcp_server_create(
- &exec_ctx, NULL, proxy->channel_args, &proxy->server);
+ grpc_error* error =
+ grpc_tcp_server_create(nullptr, proxy->channel_args, &proxy->server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
// Bind to port.
grpc_resolved_address resolved_addr;
@@ -513,37 +545,35 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
// Start server.
proxy->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(proxy->pollset, &proxy->mu);
- grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept,
- proxy);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(proxy->server, &proxy->pollset, 1, on_accept, proxy);
+
// Start proxy thread.
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- GPR_ASSERT(gpr_thd_new(&proxy->thd, thread_main, proxy, &opt));
+ GPR_ASSERT(
+ gpr_thd_new(&proxy->thd, "grpc_http_proxy", thread_main, proxy, &opt));
return proxy;
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_pollset(void* arg, grpc_error* error) {
grpc_pollset* pollset = (grpc_pollset*)arg;
- grpc_pollset_destroy(exec_ctx, pollset);
+ grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
gpr_unref(&proxy->users); // Signal proxy thread to shutdown.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_thd_join(proxy->thd);
- grpc_tcp_server_shutdown_listeners(&exec_ctx, proxy->server);
- grpc_tcp_server_unref(&exec_ctx, proxy->server);
+ grpc_tcp_server_shutdown_listeners(proxy->server);
+ grpc_tcp_server_unref(proxy->server);
gpr_free(proxy->proxy_name);
- grpc_channel_args_destroy(&exec_ctx, proxy->channel_args);
- grpc_pollset_shutdown(&exec_ctx, proxy->pollset,
+ grpc_channel_args_destroy(proxy->channel_args);
+ grpc_pollset_shutdown(proxy->pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset,
grpc_schedule_on_exec_ctx));
- GRPC_COMBINER_UNREF(&exec_ctx, proxy->combiner, "test");
+ GRPC_COMBINER_UNREF(proxy->combiner, "test");
gpr_free(proxy);
- grpc_exec_ctx_finish(&exec_ctx);
}
const char* grpc_end2end_http_proxy_get_proxy_name(
diff --git a/test/core/end2end/fixtures/inproc.c b/test/core/end2end/fixtures/inproc.cc
index 6f742f0293..b748fbf09a 100644
--- a/test/core/end2end/fixtures/inproc.c
+++ b/test/core/end2end/fixtures/inproc.cc
@@ -40,36 +40,37 @@ typedef struct inproc_fixture_data {
} inproc_fixture_data;
static grpc_end2end_test_fixture inproc_create_fixture(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
- inproc_fixture_data *ffd = gpr_malloc(sizeof(inproc_fixture_data));
+ inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>(
+ gpr_malloc(sizeof(inproc_fixture_data)));
memset(&f, 0, sizeof(f));
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-void inproc_init_client(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args) {
- f->client = grpc_inproc_channel_create(f->server, client_args, NULL);
+void inproc_init_client(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ f->client = grpc_inproc_channel_create(f->server, client_args, nullptr);
GPR_ASSERT(f->client);
}
-void inproc_init_server(grpc_end2end_test_fixture *f,
- grpc_channel_args *server_args) {
+void inproc_init_server(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
}
-void inproc_tear_down(grpc_end2end_test_fixture *f) {
- inproc_fixture_data *ffd = f->fixture_data;
+void inproc_tear_down(grpc_end2end_test_fixture* f) {
+ inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>(f->fixture_data);
gpr_free(ffd);
}
@@ -79,7 +80,7 @@ static grpc_end2end_test_config configs[] = {
inproc_init_client, inproc_init_server, inproc_tear_down},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.cc
index 9ad862728f..b1698c804c 100644
--- a/test/core/end2end/fixtures/proxy.c
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -31,37 +31,37 @@
struct grpc_end2end_proxy {
gpr_thd_id thd;
- char *proxy_port;
- char *server_port;
- grpc_completion_queue *cq;
- grpc_server *server;
- grpc_channel *client;
+ char* proxy_port;
+ char* server_port;
+ grpc_completion_queue* cq;
+ grpc_server* server;
+ grpc_channel* client;
int shutdown;
/* requested call */
- grpc_call *new_call;
+ grpc_call* new_call;
grpc_call_details new_call_details;
grpc_metadata_array new_call_metadata;
};
typedef struct {
- void (*func)(void *arg, int success);
- void *arg;
+ void (*func)(void* arg, int success);
+ void* arg;
} closure;
typedef struct {
gpr_refcount refs;
- grpc_end2end_proxy *proxy;
+ grpc_end2end_proxy* proxy;
- grpc_call *c2p;
- grpc_call *p2s;
+ grpc_call* c2p;
+ grpc_call* p2s;
grpc_metadata_array c2p_initial_metadata;
grpc_metadata_array p2s_initial_metadata;
- grpc_byte_buffer *c2p_msg;
- grpc_byte_buffer *p2s_msg;
+ grpc_byte_buffer* c2p_msg;
+ grpc_byte_buffer* p2s_msg;
grpc_metadata_array p2s_trailing_metadata;
grpc_status_code p2s_status;
@@ -70,17 +70,17 @@ typedef struct {
int c2p_server_cancelled;
} proxy_call;
-static void thread_main(void *arg);
-static void request_call(grpc_end2end_proxy *proxy);
+static void thread_main(void* arg);
+static void request_call(grpc_end2end_proxy* proxy);
-grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
gpr_thd_options opt = gpr_thd_options_default();
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();
- grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)gpr_malloc(sizeof(*proxy));
+ grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)gpr_malloc(sizeof(*proxy));
memset(proxy, 0, sizeof(*proxy));
gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port);
@@ -89,36 +89,37 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port,
proxy->server_port);
- proxy->cq = grpc_completion_queue_create_for_next(NULL);
+ proxy->cq = grpc_completion_queue_create_for_next(nullptr);
proxy->server = def->create_server(proxy->proxy_port, server_args);
proxy->client = def->create_client(proxy->server_port, client_args);
- grpc_server_register_completion_queue(proxy->server, proxy->cq, NULL);
+ grpc_server_register_completion_queue(proxy->server, proxy->cq, nullptr);
grpc_server_start(proxy->server);
grpc_call_details_init(&proxy->new_call_details);
gpr_thd_options_set_joinable(&opt);
- GPR_ASSERT(gpr_thd_new(&proxy->thd, thread_main, proxy, &opt));
+ GPR_ASSERT(
+ gpr_thd_new(&proxy->thd, "grpc_end2end_proxy", thread_main, proxy, &opt));
request_call(proxy);
return proxy;
}
-static closure *new_closure(void (*func)(void *arg, int success), void *arg) {
- closure *cl = (closure *)gpr_malloc(sizeof(*cl));
+static closure* new_closure(void (*func)(void* arg, int success), void* arg) {
+ closure* cl = (closure*)gpr_malloc(sizeof(*cl));
cl->func = func;
cl->arg = arg;
return cl;
}
-static void shutdown_complete(void *arg, int success) {
- grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg;
+static void shutdown_complete(void* arg, int success) {
+ grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg;
proxy->shutdown = 1;
grpc_completion_queue_shutdown(proxy->cq);
}
-void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) {
+void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) {
grpc_server_shutdown_and_notify(proxy->server, proxy->cq,
new_closure(shutdown_complete, proxy));
gpr_thd_join(proxy->thd);
@@ -131,7 +132,7 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) {
gpr_free(proxy);
}
-static void unrefpc(proxy_call *pc, const char *reason) {
+static void unrefpc(proxy_call* pc, const char* reason) {
if (gpr_unref(&pc->refs)) {
grpc_call_unref(pc->c2p);
grpc_call_unref(pc->p2s);
@@ -143,15 +144,15 @@ static void unrefpc(proxy_call *pc, const char *reason) {
}
}
-static void refpc(proxy_call *pc, const char *reason) { gpr_ref(&pc->refs); }
+static void refpc(proxy_call* pc, const char* reason) { gpr_ref(&pc->refs); }
-static void on_c2p_sent_initial_metadata(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_c2p_sent_initial_metadata(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
unrefpc(pc, "on_c2p_sent_initial_metadata");
}
-static void on_p2s_recv_initial_metadata(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_p2s_recv_initial_metadata(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
grpc_op op;
grpc_call_error err;
@@ -159,27 +160,28 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) {
if (!pc->proxy->shutdown) {
op.op = GRPC_OP_SEND_INITIAL_METADATA;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
op.data.send_initial_metadata.count = pc->p2s_initial_metadata.count;
op.data.send_initial_metadata.metadata = pc->p2s_initial_metadata.metadata;
refpc(pc, "on_c2p_sent_initial_metadata");
- err = grpc_call_start_batch(
- pc->c2p, &op, 1, new_closure(on_c2p_sent_initial_metadata, pc), NULL);
+ err = grpc_call_start_batch(pc->c2p, &op, 1,
+ new_closure(on_c2p_sent_initial_metadata, pc),
+ nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
}
unrefpc(pc, "on_p2s_recv_initial_metadata");
}
-static void on_p2s_sent_initial_metadata(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_p2s_sent_initial_metadata(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
unrefpc(pc, "on_p2s_sent_initial_metadata");
}
-static void on_c2p_recv_msg(void *arg, int success);
+static void on_c2p_recv_msg(void* arg, int success);
-static void on_p2s_sent_message(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_p2s_sent_message(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
grpc_op op;
grpc_call_error err;
@@ -187,55 +189,59 @@ static void on_p2s_sent_message(void *arg, int success) {
if (!pc->proxy->shutdown && success) {
op.op = GRPC_OP_RECV_MESSAGE;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
op.data.recv_message.recv_message = &pc->c2p_msg;
refpc(pc, "on_c2p_recv_msg");
err = grpc_call_start_batch(pc->c2p, &op, 1,
- new_closure(on_c2p_recv_msg, pc), NULL);
+ new_closure(on_c2p_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
}
unrefpc(pc, "on_p2s_sent_message");
}
-static void on_p2s_sent_close(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_p2s_sent_close(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
unrefpc(pc, "on_p2s_sent_close");
}
-static void on_c2p_recv_msg(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_c2p_recv_msg(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
grpc_op op;
grpc_call_error err;
if (!pc->proxy->shutdown && success) {
- if (pc->c2p_msg != NULL) {
+ if (pc->c2p_msg != nullptr) {
op.op = GRPC_OP_SEND_MESSAGE;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
op.data.send_message.send_message = pc->c2p_msg;
refpc(pc, "on_p2s_sent_message");
- err = grpc_call_start_batch(pc->p2s, &op, 1,
- new_closure(on_p2s_sent_message, pc), NULL);
+ err = grpc_call_start_batch(
+ pc->p2s, &op, 1, new_closure(on_p2s_sent_message, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
} else {
op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
refpc(pc, "on_p2s_sent_close");
err = grpc_call_start_batch(pc->p2s, &op, 1,
- new_closure(on_p2s_sent_close, pc), NULL);
+ new_closure(on_p2s_sent_close, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
}
+ } else {
+ if (pc->c2p_msg != nullptr) {
+ grpc_byte_buffer_destroy(pc->c2p_msg);
+ }
}
unrefpc(pc, "on_c2p_recv_msg");
}
-static void on_p2s_recv_msg(void *arg, int success);
+static void on_p2s_recv_msg(void* arg, int success);
-static void on_c2p_sent_message(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_c2p_sent_message(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
grpc_op op;
grpc_call_error err;
@@ -243,30 +249,30 @@ static void on_c2p_sent_message(void *arg, int success) {
if (!pc->proxy->shutdown && success) {
op.op = GRPC_OP_RECV_MESSAGE;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
op.data.recv_message.recv_message = &pc->p2s_msg;
refpc(pc, "on_p2s_recv_msg");
err = grpc_call_start_batch(pc->p2s, &op, 1,
- new_closure(on_p2s_recv_msg, pc), NULL);
+ new_closure(on_p2s_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
}
unrefpc(pc, "on_c2p_sent_message");
}
-static void on_p2s_recv_msg(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_p2s_recv_msg(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
grpc_op op;
grpc_call_error err;
if (!pc->proxy->shutdown && success && pc->p2s_msg) {
op.op = GRPC_OP_SEND_MESSAGE;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
op.data.send_message.send_message = pc->p2s_msg;
refpc(pc, "on_c2p_sent_message");
err = grpc_call_start_batch(pc->c2p, &op, 1,
- new_closure(on_c2p_sent_message, pc), NULL);
+ new_closure(on_c2p_sent_message, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
} else {
grpc_byte_buffer_destroy(pc->p2s_msg);
@@ -274,13 +280,13 @@ static void on_p2s_recv_msg(void *arg, int success) {
unrefpc(pc, "on_p2s_recv_msg");
}
-static void on_c2p_sent_status(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_c2p_sent_status(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
unrefpc(pc, "on_c2p_sent_status");
}
-static void on_p2s_status(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_p2s_status(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
grpc_op op;
grpc_call_error err;
@@ -288,7 +294,7 @@ static void on_p2s_status(void *arg, int success) {
GPR_ASSERT(success);
op.op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op.flags = 0;
- op.reserved = NULL;
+ op.reserved = nullptr;
op.data.send_status_from_server.trailing_metadata_count =
pc->p2s_trailing_metadata.count;
op.data.send_status_from_server.trailing_metadata =
@@ -297,26 +303,26 @@ static void on_p2s_status(void *arg, int success) {
op.data.send_status_from_server.status_details = &pc->p2s_status_details;
refpc(pc, "on_c2p_sent_status");
err = grpc_call_start_batch(pc->c2p, &op, 1,
- new_closure(on_c2p_sent_status, pc), NULL);
+ new_closure(on_c2p_sent_status, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
}
unrefpc(pc, "on_p2s_status");
}
-static void on_c2p_closed(void *arg, int success) {
- proxy_call *pc = (proxy_call *)arg;
+static void on_c2p_closed(void* arg, int success) {
+ proxy_call* pc = (proxy_call*)arg;
unrefpc(pc, "on_c2p_closed");
}
-static void on_new_call(void *arg, int success) {
- grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg;
+static void on_new_call(void* arg, int success) {
+ grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg;
grpc_call_error err;
if (success) {
grpc_op op;
memset(&op, 0, sizeof(op));
- proxy_call *pc = (proxy_call *)gpr_malloc(sizeof(*pc));
+ proxy_call* pc = (proxy_call*)gpr_malloc(sizeof(*pc));
memset(pc, 0, sizeof(*pc));
pc->proxy = proxy;
GPR_SWAP(grpc_metadata_array, pc->c2p_initial_metadata,
@@ -325,18 +331,19 @@ static void on_new_call(void *arg, int success) {
pc->p2s = grpc_channel_create_call(
proxy->client, pc->c2p, GRPC_PROPAGATE_DEFAULTS, proxy->cq,
proxy->new_call_details.method, &proxy->new_call_details.host,
- proxy->new_call_details.deadline, NULL);
+ proxy->new_call_details.deadline, nullptr);
gpr_ref_init(&pc->refs, 1);
- op.reserved = NULL;
+ op.reserved = nullptr;
op.op = GRPC_OP_RECV_INITIAL_METADATA;
op.flags = 0;
op.data.recv_initial_metadata.recv_initial_metadata =
&pc->p2s_initial_metadata;
refpc(pc, "on_p2s_recv_initial_metadata");
- err = grpc_call_start_batch(
- pc->p2s, &op, 1, new_closure(on_p2s_recv_initial_metadata, pc), NULL);
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_recv_initial_metadata, pc),
+ nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
op.op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -344,8 +351,9 @@ static void on_new_call(void *arg, int success) {
op.data.send_initial_metadata.count = pc->c2p_initial_metadata.count;
op.data.send_initial_metadata.metadata = pc->c2p_initial_metadata.metadata;
refpc(pc, "on_p2s_sent_initial_metadata");
- err = grpc_call_start_batch(
- pc->p2s, &op, 1, new_closure(on_p2s_sent_initial_metadata, pc), NULL);
+ err = grpc_call_start_batch(pc->p2s, &op, 1,
+ new_closure(on_p2s_sent_initial_metadata, pc),
+ nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
op.op = GRPC_OP_RECV_MESSAGE;
@@ -353,7 +361,7 @@ static void on_new_call(void *arg, int success) {
op.data.recv_message.recv_message = &pc->c2p_msg;
refpc(pc, "on_c2p_recv_msg");
err = grpc_call_start_batch(pc->c2p, &op, 1,
- new_closure(on_c2p_recv_msg, pc), NULL);
+ new_closure(on_c2p_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
op.op = GRPC_OP_RECV_MESSAGE;
@@ -361,7 +369,7 @@ static void on_new_call(void *arg, int success) {
op.data.recv_message.recv_message = &pc->p2s_msg;
refpc(pc, "on_p2s_recv_msg");
err = grpc_call_start_batch(pc->p2s, &op, 1,
- new_closure(on_p2s_recv_msg, pc), NULL);
+ new_closure(on_p2s_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
op.op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -372,7 +380,7 @@ static void on_new_call(void *arg, int success) {
op.data.recv_status_on_client.status_details = &pc->p2s_status_details;
refpc(pc, "on_p2s_status");
err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc),
- NULL);
+ nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
op.op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -380,7 +388,7 @@ static void on_new_call(void *arg, int success) {
op.data.recv_close_on_server.cancelled = &pc->c2p_server_cancelled;
refpc(pc, "on_c2p_closed");
err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_closed, pc),
- NULL);
+ nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
request_call(proxy);
@@ -390,12 +398,12 @@ static void on_new_call(void *arg, int success) {
unrefpc(pc, "init");
} else {
- GPR_ASSERT(proxy->new_call == NULL);
+ GPR_ASSERT(proxy->new_call == nullptr);
}
}
-static void request_call(grpc_end2end_proxy *proxy) {
- proxy->new_call = NULL;
+static void request_call(grpc_end2end_proxy* proxy) {
+ proxy->new_call = nullptr;
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
proxy->server, &proxy->new_call,
&proxy->new_call_details,
@@ -403,12 +411,12 @@ static void request_call(grpc_end2end_proxy *proxy) {
proxy->cq, new_closure(on_new_call, proxy)));
}
-static void thread_main(void *arg) {
- grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg;
- closure *cl;
+static void thread_main(void* arg) {
+ grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg;
+ closure* cl;
for (;;) {
grpc_event ev = grpc_completion_queue_next(
- proxy->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ proxy->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
switch (ev.type) {
case GRPC_QUEUE_TIMEOUT:
gpr_log(GPR_ERROR, "Should never reach here");
@@ -416,7 +424,7 @@ static void thread_main(void *arg) {
case GRPC_QUEUE_SHUTDOWN:
return;
case GRPC_OP_COMPLETE:
- cl = (closure *)ev.tag;
+ cl = (closure*)ev.tag;
cl->func(cl->arg, ev.success);
gpr_free(cl);
break;
@@ -424,10 +432,10 @@ static void thread_main(void *arg) {
}
}
-const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy) {
+const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy) {
return proxy->proxy_port;
}
-const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy) {
+const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy) {
return proxy->server_port;
}
diff --git a/test/core/end2end/fixtures/proxy.h b/test/core/end2end/fixtures/proxy.h
index 89b965c903..18ad763ea7 100644
--- a/test/core/end2end/fixtures/proxy.h
+++ b/test/core/end2end/fixtures/proxy.h
@@ -26,18 +26,18 @@
typedef struct grpc_end2end_proxy grpc_end2end_proxy;
typedef struct grpc_end2end_proxy_def {
- grpc_server *(*create_server)(const char *port,
- grpc_channel_args *server_args);
- grpc_channel *(*create_client)(const char *target,
- grpc_channel_args *client_args);
+ grpc_server* (*create_server)(const char* port,
+ grpc_channel_args* server_args);
+ grpc_channel* (*create_client)(const char* target,
+ grpc_channel_args* client_args);
} grpc_end2end_proxy_def;
-grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args);
-void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy);
+grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args);
+void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy);
-const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy);
-const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy);
+const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy);
+const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy);
#endif /* GRPC_TEST_CORE_END2END_FIXTURES_PROXY_H */
diff --git a/test/core/end2end/fuzzers/BUILD b/test/core/end2end/fuzzers/BUILD
index 4ed9a70578..d33e2b0ff4 100644
--- a/test/core/end2end/fuzzers/BUILD
+++ b/test/core/end2end/fuzzers/BUILD
@@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "api_fuzzer",
- srcs = ["api_fuzzer.c"],
- language = "C",
+ srcs = ["api_fuzzer.cc"],
+ language = "C++",
corpus = "api_fuzzer_corpus",
deps = [
"//:gpr",
@@ -35,8 +35,8 @@ grpc_fuzzer(
grpc_fuzzer(
name = "client_fuzzer",
- srcs = ["client_fuzzer.c"],
- language = "C",
+ srcs = ["client_fuzzer.cc"],
+ language = "C++",
corpus = "client_fuzzer_corpus",
deps = [
"//:gpr",
@@ -47,8 +47,8 @@ grpc_fuzzer(
grpc_fuzzer(
name = "server_fuzzer",
- srcs = ["server_fuzzer.c"],
- language = "C",
+ srcs = ["server_fuzzer.cc"],
+ language = "C++",
corpus = "server_fuzzer_corpus",
deps = [
"//:gpr",
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.cc
index 1228c9fe9a..14c155502a 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -28,13 +28,13 @@
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/end2end/data/ssl_test_data.h"
@@ -46,21 +46,23 @@
bool squelch = true;
bool leak_check = true;
-static void dont_log(gpr_log_func_args *args) {}
+static void dont_log(gpr_log_func_args* args) {}
////////////////////////////////////////////////////////////////////////////////
// global state
static gpr_timespec g_now;
-static grpc_server *g_server;
-static grpc_channel *g_channel;
-static grpc_resource_quota *g_resource_quota;
+static grpc_server* g_server;
+static grpc_channel* g_channel;
+static grpc_resource_quota* g_resource_quota;
extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
static gpr_timespec now_impl(gpr_clock_type clock_type) {
GPR_ASSERT(clock_type != GPR_TIMESPAN);
- return g_now;
+ gpr_timespec ts = g_now;
+ ts.clock_type = clock_type;
+ return ts;
}
////////////////////////////////////////////////////////////////////////////////
@@ -68,33 +70,33 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) {
// past the end (avoiding needing to check everywhere)
typedef struct {
- const uint8_t *cur;
- const uint8_t *end;
+ const uint8_t* cur;
+ const uint8_t* end;
} input_stream;
-static uint8_t next_byte(input_stream *inp) {
+static uint8_t next_byte(input_stream* inp) {
if (inp->cur == inp->end) {
return 0;
}
return *inp->cur++;
}
-static void end(input_stream *inp) { inp->cur = inp->end; }
+static void end(input_stream* inp) { inp->cur = inp->end; }
-static char *read_string(input_stream *inp, bool *special) {
- char *str = NULL;
+static char* read_string(input_stream* inp, bool* special) {
+ char* str = nullptr;
size_t cap = 0;
size_t sz = 0;
char c;
do {
if (cap == sz) {
cap = GPR_MAX(3 * cap / 2, cap + 8);
- str = gpr_realloc(str, cap);
+ str = static_cast<char*>(gpr_realloc(str, cap));
}
c = (char)next_byte(inp);
str[sz++] = c;
} while (c != 0 && c != 1);
- if (special != NULL) {
+ if (special != nullptr) {
*special = (c == 1);
}
if (c == 1) {
@@ -103,16 +105,16 @@ static char *read_string(input_stream *inp, bool *special) {
return str;
}
-static void read_buffer(input_stream *inp, char **buffer, size_t *length,
- bool *special) {
+static void read_buffer(input_stream* inp, char** buffer, size_t* length,
+ bool* special) {
*length = next_byte(inp);
if (*length == 255) {
- if (special != NULL) *special = true;
+ if (special != nullptr) *special = true;
*length = next_byte(inp);
} else {
- if (special != NULL) *special = false;
+ if (special != nullptr) *special = false;
}
- *buffer = gpr_malloc(*length);
+ *buffer = static_cast<char*>(gpr_malloc(*length));
for (size_t i = 0; i < *length; i++) {
(*buffer)[i] = (char)next_byte(inp);
}
@@ -124,16 +126,16 @@ static grpc_slice maybe_intern(grpc_slice s, bool intern) {
return r;
}
-static grpc_slice read_string_like_slice(input_stream *inp) {
+static grpc_slice read_string_like_slice(input_stream* inp) {
bool special;
- char *s = read_string(inp, &special);
+ char* s = read_string(inp, &special);
grpc_slice r = maybe_intern(grpc_slice_from_copied_string(s), special);
gpr_free(s);
return r;
}
-static grpc_slice read_buffer_like_slice(input_stream *inp) {
- char *buffer;
+static grpc_slice read_buffer_like_slice(input_stream* inp) {
+ char* buffer;
size_t length;
bool special;
read_buffer(inp, &buffer, &length, &special);
@@ -143,7 +145,7 @@ static grpc_slice read_buffer_like_slice(input_stream *inp) {
return r;
}
-static uint32_t read_uint22(input_stream *inp) {
+static uint32_t read_uint22(input_stream* inp) {
uint8_t b = next_byte(inp);
uint32_t x = b & 0x7f;
if (b & 0x80) {
@@ -158,7 +160,7 @@ static uint32_t read_uint22(input_stream *inp) {
return x;
}
-static uint32_t read_uint32(input_stream *inp) {
+static uint32_t read_uint32(input_stream* inp) {
uint8_t b = next_byte(inp);
uint32_t x = b & 0x7f;
if (b & 0x80) {
@@ -182,29 +184,29 @@ static uint32_t read_uint32(input_stream *inp) {
return x;
}
-static grpc_byte_buffer *read_message(input_stream *inp) {
+static grpc_byte_buffer* read_message(input_stream* inp) {
grpc_slice slice = grpc_slice_malloc(read_uint22(inp));
memset(GRPC_SLICE_START_PTR(slice), 0, GRPC_SLICE_LENGTH(slice));
- grpc_byte_buffer *out = grpc_raw_byte_buffer_create(&slice, 1);
+ grpc_byte_buffer* out = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
return out;
}
-static int read_int(input_stream *inp) { return (int)read_uint32(inp); }
+static int read_int(input_stream* inp) { return (int)read_uint32(inp); }
-static grpc_channel_args *read_args(input_stream *inp) {
+static grpc_channel_args* read_args(input_stream* inp) {
size_t n = next_byte(inp);
- grpc_arg *args = gpr_malloc(sizeof(*args) * n);
+ grpc_arg* args = static_cast<grpc_arg*>(gpr_malloc(sizeof(*args) * n));
for (size_t i = 0; i < n; i++) {
switch (next_byte(inp)) {
case 1:
args[i].type = GRPC_ARG_STRING;
- args[i].key = read_string(inp, NULL);
- args[i].value.string = read_string(inp, NULL);
+ args[i].key = read_string(inp, nullptr);
+ args[i].value.string = read_string(inp, nullptr);
break;
case 2:
args[i].type = GRPC_ARG_INTEGER;
- args[i].key = read_string(inp, NULL);
+ args[i].key = read_string(inp, nullptr);
args[i].value.integer = read_int(inp);
break;
case 3:
@@ -220,7 +222,8 @@ static grpc_channel_args *read_args(input_stream *inp) {
break;
}
}
- grpc_channel_args *a = gpr_malloc(sizeof(*a));
+ grpc_channel_args* a =
+ static_cast<grpc_channel_args*>(gpr_malloc(sizeof(*a)));
a->args = args;
a->num_args = n;
return a;
@@ -228,95 +231,104 @@ static grpc_channel_args *read_args(input_stream *inp) {
typedef struct cred_artifact_ctx {
int num_release;
- char *release[3];
+ char* release[3];
} cred_artifact_ctx;
#define CRED_ARTIFACT_CTX_INIT \
{ \
0, { 0 } \
}
-static void cred_artifact_ctx_finish(cred_artifact_ctx *ctx) {
+static void cred_artifact_ctx_finish(cred_artifact_ctx* ctx) {
for (int i = 0; i < ctx->num_release; i++) {
gpr_free(ctx->release[i]);
}
}
-static const char *read_cred_artifact(cred_artifact_ctx *ctx, input_stream *inp,
- const char **builtins,
+static const char* read_cred_artifact(cred_artifact_ctx* ctx, input_stream* inp,
+ const char** builtins,
size_t num_builtins) {
uint8_t b = next_byte(inp);
- if (b == 0) return NULL;
- if (b == 1) return ctx->release[ctx->num_release++] = read_string(inp, NULL);
+ if (b == 0) return nullptr;
+ if (b == 1)
+ return ctx->release[ctx->num_release++] = read_string(inp, nullptr);
if (b >= num_builtins + 1) {
end(inp);
- return NULL;
+ return nullptr;
}
return builtins[b - 1];
}
-static grpc_channel_credentials *read_ssl_channel_creds(input_stream *inp) {
+static grpc_channel_credentials* read_ssl_channel_creds(input_stream* inp) {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
- static const char *builtin_root_certs[] = {test_root_cert};
- static const char *builtin_private_keys[] = {
+ static const char* builtin_root_certs[] = {test_root_cert};
+ static const char* builtin_private_keys[] = {
test_server1_key, test_self_signed_client_key, test_signed_client_key};
- static const char *builtin_cert_chains[] = {
+ static const char* builtin_cert_chains[] = {
test_server1_cert, test_self_signed_client_cert, test_signed_client_cert};
- const char *root_certs = read_cred_artifact(
+ const char* root_certs = read_cred_artifact(
&ctx, inp, builtin_root_certs, GPR_ARRAY_SIZE(builtin_root_certs));
- const char *private_key = read_cred_artifact(
+ const char* private_key = read_cred_artifact(
&ctx, inp, builtin_private_keys, GPR_ARRAY_SIZE(builtin_private_keys));
- const char *certs = read_cred_artifact(&ctx, inp, builtin_cert_chains,
+ const char* certs = read_cred_artifact(&ctx, inp, builtin_cert_chains,
GPR_ARRAY_SIZE(builtin_cert_chains));
grpc_ssl_pem_key_cert_pair key_cert_pair = {private_key, certs};
- grpc_channel_credentials *creds = grpc_ssl_credentials_create(
- root_certs, private_key != NULL && certs != NULL ? &key_cert_pair : NULL,
- NULL);
+ grpc_channel_credentials* creds = grpc_ssl_credentials_create(
+ root_certs,
+ private_key != nullptr && certs != nullptr ? &key_cert_pair : nullptr,
+ nullptr);
cred_artifact_ctx_finish(&ctx);
return creds;
}
-static grpc_call_credentials *read_call_creds(input_stream *inp) {
+static grpc_call_credentials* read_call_creds(input_stream* inp, int depth) {
+ if (depth > 64) {
+ // prevent creating infinitely deep call creds
+ end(inp);
+ return nullptr;
+ }
switch (next_byte(inp)) {
default:
end(inp);
- return NULL;
+ return nullptr;
case 0:
- return NULL;
+ return nullptr;
case 1: {
- grpc_call_credentials *c1 = read_call_creds(inp);
- grpc_call_credentials *c2 = read_call_creds(inp);
- if (c1 != NULL && c2 != NULL) {
- grpc_call_credentials *out =
- grpc_composite_call_credentials_create(c1, c2, NULL);
+ grpc_call_credentials* c1 = read_call_creds(inp, depth + 1);
+ grpc_call_credentials* c2 = read_call_creds(inp, depth + 1);
+ if (c1 != nullptr && c2 != nullptr) {
+ grpc_call_credentials* out =
+ grpc_composite_call_credentials_create(c1, c2, nullptr);
grpc_call_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
- } else if (c1 != NULL) {
+ } else if (c1 != nullptr) {
return c1;
- } else if (c2 != NULL) {
+ } else if (c2 != nullptr) {
return c2;
} else {
- return NULL;
+ return nullptr;
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
case 2: {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
- const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0);
- grpc_call_credentials *out =
- access_token == NULL ? NULL : grpc_access_token_credentials_create(
- access_token, NULL);
+ const char* access_token = read_cred_artifact(&ctx, inp, nullptr, 0);
+ grpc_call_credentials* out =
+ access_token == nullptr
+ ? nullptr
+ : grpc_access_token_credentials_create(access_token, nullptr);
cred_artifact_ctx_finish(&ctx);
return out;
}
case 3: {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
- const char *auth_token = read_cred_artifact(&ctx, inp, NULL, 0);
- const char *auth_selector = read_cred_artifact(&ctx, inp, NULL, 0);
- grpc_call_credentials *out = auth_token == NULL || auth_selector == NULL
- ? NULL
- : grpc_google_iam_credentials_create(
- auth_token, auth_selector, NULL);
+ const char* auth_token = read_cred_artifact(&ctx, inp, nullptr, 0);
+ const char* auth_selector = read_cred_artifact(&ctx, inp, nullptr, 0);
+ grpc_call_credentials* out =
+ auth_token == nullptr || auth_selector == nullptr
+ ? nullptr
+ : grpc_google_iam_credentials_create(auth_token, auth_selector,
+ nullptr);
cred_artifact_ctx_finish(&ctx);
return out;
}
@@ -324,17 +336,17 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) {
}
}
-static grpc_channel_credentials *read_channel_creds(input_stream *inp) {
+static grpc_channel_credentials* read_channel_creds(input_stream* inp) {
switch (next_byte(inp)) {
case 0:
return read_ssl_channel_creds(inp);
break;
case 1: {
- grpc_channel_credentials *c1 = read_channel_creds(inp);
- grpc_call_credentials *c2 = read_call_creds(inp);
- if (c1 != NULL && c2 != NULL) {
- grpc_channel_credentials *out =
- grpc_composite_channel_credentials_create(c1, c2, NULL);
+ grpc_channel_credentials* c1 = read_channel_creds(inp);
+ grpc_call_credentials* c2 = read_call_creds(inp, 0);
+ if (c1 != nullptr && c2 != nullptr) {
+ grpc_channel_credentials* out =
+ grpc_composite_channel_credentials_create(c1, c2, nullptr);
grpc_channel_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
@@ -342,52 +354,54 @@ static grpc_channel_credentials *read_channel_creds(input_stream *inp) {
return c1;
} else if (c2) {
grpc_call_credentials_release(c2);
- return NULL;
+ return nullptr;
} else {
- return NULL;
+ return nullptr;
}
- GPR_UNREACHABLE_CODE(return NULL);
+ GPR_UNREACHABLE_CODE(return nullptr);
}
case 2:
- return NULL;
+ return nullptr;
default:
end(inp);
- return NULL;
+ return nullptr;
}
}
-static bool is_eof(input_stream *inp) { return inp->cur == inp->end; }
+static bool is_eof(input_stream* inp) { return inp->cur == inp->end; }
////////////////////////////////////////////////////////////////////////////////
// dns resolution
typedef struct addr_req {
grpc_timer timer;
- char *addr;
- grpc_closure *on_done;
- grpc_resolved_addresses **addrs;
- grpc_lb_addresses **lb_addrs;
+ char* addr;
+ grpc_closure* on_done;
+ grpc_resolved_addresses** addrs;
+ grpc_lb_addresses** lb_addrs;
} addr_req;
-static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- addr_req *r = arg;
+static void finish_resolve(void* arg, grpc_error* error) {
+ addr_req* r = static_cast<addr_req*>(arg);
if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) {
- if (r->addrs != NULL) {
- grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs));
+ if (r->addrs != nullptr) {
+ grpc_resolved_addresses* addrs =
+ static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(*addrs)));
addrs->naddrs = 1;
- addrs->addrs = gpr_malloc(sizeof(*addrs->addrs));
+ addrs->addrs = static_cast<grpc_resolved_address*>(
+ gpr_malloc(sizeof(*addrs->addrs)));
addrs->addrs[0].len = 0;
*r->addrs = addrs;
- } else if (r->lb_addrs != NULL) {
- grpc_lb_addresses *lb_addrs = grpc_lb_addresses_create(1, NULL);
- grpc_lb_addresses_set_address(lb_addrs, 0, NULL, 0, NULL, NULL, NULL);
+ } else if (r->lb_addrs != nullptr) {
+ grpc_lb_addresses* lb_addrs = grpc_lb_addresses_create(1, nullptr);
+ grpc_lb_addresses_set_address(lb_addrs, 0, nullptr, 0, false, nullptr,
+ nullptr);
*r->lb_addrs = lb_addrs;
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->on_done, GRPC_ERROR_NONE);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done,
+ GRPC_CLOSURE_SCHED(r->on_done,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Resolution failed", &error, 1));
}
@@ -396,39 +410,36 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(r);
}
-void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addresses) {
- addr_req *r = gpr_malloc(sizeof(*r));
+void my_resolve_address(const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addresses) {
+ addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = addresses;
- r->lb_addrs = NULL;
+ r->lb_addrs = nullptr;
grpc_timer_init(
- exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(1, GPR_TIMESPAN)),
- GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx),
- gpr_now(GPR_CLOCK_MONOTONIC));
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
+ GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
}
-grpc_ares_request *my_dns_lookup_ares(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **lb_addrs, bool check_grpclb,
- char **service_config_json) {
- addr_req *r = gpr_malloc(sizeof(*r));
+grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs,
+ bool check_grpclb,
+ char** service_config_json) {
+ addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
- r->addrs = NULL;
+ r->addrs = nullptr;
r->lb_addrs = lb_addrs;
grpc_timer_init(
- exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(1, GPR_TIMESPAN)),
- GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx),
- gpr_now(GPR_CLOCK_MONOTONIC));
- return NULL;
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
+ GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
+ return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
@@ -436,110 +447,109 @@ grpc_ares_request *my_dns_lookup_ares(
// defined in tcp_client_posix.c
extern void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr, gpr_timespec deadline);
+ grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr, grpc_millis deadline);
-static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_endpoint **ep, gpr_timespec deadline);
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline);
typedef struct {
grpc_timer timer;
- grpc_closure *closure;
- grpc_endpoint **ep;
+ grpc_closure* closure;
+ grpc_endpoint** ep;
gpr_timespec deadline;
} future_connect;
-static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- future_connect *fc = arg;
+static void do_connect(void* arg, grpc_error* error) {
+ future_connect* fc = static_cast<future_connect*>(arg);
if (error != GRPC_ERROR_NONE) {
- *fc->ep = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_REF(error));
- } else if (g_server != NULL) {
- grpc_endpoint *client;
- grpc_endpoint *server;
- grpc_passthru_endpoint_create(&client, &server, g_resource_quota, NULL);
+ *fc->ep = nullptr;
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_REF(error));
+ } else if (g_server != nullptr) {
+ grpc_endpoint* client;
+ grpc_endpoint* server;
+ grpc_passthru_endpoint_create(&client, &server, g_resource_quota, nullptr);
*fc->ep = client;
- grpc_transport *transport =
- grpc_create_chttp2_transport(exec_ctx, NULL, server, 0);
- grpc_server_setup_transport(exec_ctx, g_server, transport, NULL, NULL);
- grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL);
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(nullptr, server, false);
+ grpc_server_setup_transport(g_server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_NONE);
} else {
- sched_connect(exec_ctx, fc->closure, fc->ep, fc->deadline);
+ sched_connect(fc->closure, fc->ep, fc->deadline);
}
gpr_free(fc);
}
-static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_endpoint **ep, gpr_timespec deadline) {
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
- *ep = NULL;
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Connect deadline exceeded"));
+ *ep = nullptr;
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Connect deadline exceeded"));
return;
}
- future_connect *fc = gpr_malloc(sizeof(*fc));
+ future_connect* fc = static_cast<future_connect*>(gpr_malloc(sizeof(*fc)));
fc->closure = closure;
fc->ep = ep;
fc->deadline = deadline;
grpc_timer_init(
- exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_millis(1, GPR_TIMESPAN)),
- GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx),
- gpr_now(GPR_CLOCK_MONOTONIC));
+ &fc->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
+ GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx));
}
-static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,
- grpc_closure *closure, grpc_endpoint **ep,
- grpc_pollset_set *interested_parties,
- const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr,
- gpr_timespec deadline) {
- sched_connect(exec_ctx, closure, ep, deadline);
+static void my_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
+ sched_connect(closure, ep,
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC));
}
////////////////////////////////////////////////////////////////////////////////
// test driver
typedef struct validator {
- void (*validate)(void *arg, bool success);
- void *arg;
+ void (*validate)(void* arg, bool success);
+ void* arg;
} validator;
-static validator *create_validator(void (*validate)(void *arg, bool success),
- void *arg) {
- validator *v = gpr_malloc(sizeof(*v));
+static validator* create_validator(void (*validate)(void* arg, bool success),
+ void* arg) {
+ validator* v = static_cast<validator*>(gpr_malloc(sizeof(*v)));
v->validate = validate;
v->arg = arg;
return v;
}
-static void assert_success_and_decrement(void *counter, bool success) {
+static void assert_success_and_decrement(void* counter, bool success) {
GPR_ASSERT(success);
- --*(int *)counter;
+ --*(int*)counter;
}
-static void decrement(void *counter, bool success) { --*(int *)counter; }
+static void decrement(void* counter, bool success) { --*(int*)counter; }
typedef struct connectivity_watch {
- int *counter;
+ int* counter;
gpr_timespec deadline;
} connectivity_watch;
-static connectivity_watch *make_connectivity_watch(gpr_timespec s,
- int *counter) {
- connectivity_watch *o = gpr_malloc(sizeof(*o));
+static connectivity_watch* make_connectivity_watch(gpr_timespec s,
+ int* counter) {
+ connectivity_watch* o =
+ static_cast<connectivity_watch*>(gpr_malloc(sizeof(*o)));
o->deadline = s;
o->counter = counter;
return o;
}
-static void validate_connectivity_watch(void *p, bool success) {
- connectivity_watch *w = p;
+static void validate_connectivity_watch(void* p, bool success) {
+ connectivity_watch* w = static_cast<connectivity_watch*>(p);
if (!success) {
GPR_ASSERT(gpr_time_cmp(gpr_now(w->deadline.clock_type), w->deadline) >= 0);
}
@@ -547,8 +557,8 @@ static void validate_connectivity_watch(void *p, bool success) {
gpr_free(w);
}
-static void free_non_null(void *p) {
- GPR_ASSERT(p != NULL);
+static void free_non_null(void* p) {
+ GPR_ASSERT(p != nullptr);
gpr_free(p);
}
@@ -558,8 +568,8 @@ typedef enum { ROOT, CLIENT, SERVER, PENDING_SERVER } call_state_type;
typedef struct call_state {
call_state_type type;
- grpc_call *call;
- grpc_byte_buffer *recv_message;
+ grpc_call* call;
+ grpc_byte_buffer* recv_message;
grpc_status_code status;
grpc_metadata_array recv_initial_metadata;
grpc_metadata_array recv_trailing_metadata;
@@ -567,7 +577,7 @@ typedef struct call_state {
int cancelled;
int pending_ops;
grpc_call_details call_details;
- grpc_byte_buffer *send_message;
+ grpc_byte_buffer* send_message;
// starts at 0, individual flags from DONE_FLAG_xxx are set
// as different operations are completed
uint64_t done_flags;
@@ -575,23 +585,23 @@ typedef struct call_state {
// array of pointers to free later
size_t num_to_free;
size_t cap_to_free;
- void **to_free;
+ void** to_free;
// array of slices to unref
size_t num_slices_to_unref;
size_t cap_slices_to_unref;
- grpc_slice **slices_to_unref;
+ grpc_slice** slices_to_unref;
- struct call_state *next;
- struct call_state *prev;
+ struct call_state* next;
+ struct call_state* prev;
} call_state;
-static call_state *g_active_call;
+static call_state* g_active_call;
-static call_state *new_call(call_state *sibling, call_state_type type) {
- call_state *c = gpr_malloc(sizeof(*c));
+static call_state* new_call(call_state* sibling, call_state_type type) {
+ call_state* c = static_cast<call_state*>(gpr_malloc(sizeof(*c)));
memset(c, 0, sizeof(*c));
- if (sibling != NULL) {
+ if (sibling != nullptr) {
c->next = sibling;
c->prev = sibling->prev;
c->next->prev = c->prev->next = c;
@@ -602,10 +612,10 @@ static call_state *new_call(call_state *sibling, call_state_type type) {
return c;
}
-static call_state *maybe_delete_call_state(call_state *call) {
- call_state *next = call->next;
+static call_state* maybe_delete_call_state(call_state* call) {
+ call_state* next = call->next;
- if (call->call != NULL) return next;
+ if (call->call != nullptr) return next;
if (call->pending_ops != 0) return next;
if (call == g_active_call) {
@@ -635,33 +645,34 @@ static call_state *maybe_delete_call_state(call_state *call) {
return next;
}
-static void add_to_free(call_state *call, void *p) {
+static void add_to_free(call_state* call, void* p) {
if (call->num_to_free == call->cap_to_free) {
call->cap_to_free = GPR_MAX(8, 2 * call->cap_to_free);
- call->to_free =
- gpr_realloc(call->to_free, sizeof(*call->to_free) * call->cap_to_free);
+ call->to_free = static_cast<void**>(
+ gpr_realloc(call->to_free, sizeof(*call->to_free) * call->cap_to_free));
}
call->to_free[call->num_to_free++] = p;
}
-static grpc_slice *add_slice_to_unref(call_state *call, grpc_slice s) {
+static grpc_slice* add_slice_to_unref(call_state* call, grpc_slice s) {
if (call->num_slices_to_unref == call->cap_slices_to_unref) {
call->cap_slices_to_unref = GPR_MAX(8, 2 * call->cap_slices_to_unref);
- call->slices_to_unref =
- gpr_realloc(call->slices_to_unref,
- sizeof(*call->slices_to_unref) * call->cap_slices_to_unref);
+ call->slices_to_unref = static_cast<grpc_slice**>(gpr_realloc(
+ call->slices_to_unref,
+ sizeof(*call->slices_to_unref) * call->cap_slices_to_unref));
}
call->slices_to_unref[call->num_slices_to_unref] =
- gpr_malloc(sizeof(grpc_slice));
+ static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice)));
*call->slices_to_unref[call->num_slices_to_unref++] = s;
return call->slices_to_unref[call->num_slices_to_unref - 1];
}
-static void read_metadata(input_stream *inp, size_t *count,
- grpc_metadata **metadata, call_state *cs) {
+static void read_metadata(input_stream* inp, size_t* count,
+ grpc_metadata** metadata, call_state* cs) {
*count = next_byte(inp);
if (*count) {
- *metadata = gpr_malloc(*count * sizeof(**metadata));
+ *metadata =
+ static_cast<grpc_metadata*>(gpr_malloc(*count * sizeof(**metadata)));
memset(*metadata, 0, *count * sizeof(**metadata));
for (size_t i = 0; i < *count; i++) {
(*metadata)[i].key = read_string_like_slice(inp);
@@ -671,23 +682,23 @@ static void read_metadata(input_stream *inp, size_t *count,
add_slice_to_unref(cs, (*metadata)[i].value);
}
} else {
- *metadata = gpr_malloc(1);
+ *metadata = static_cast<grpc_metadata*>(gpr_malloc(1));
}
add_to_free(cs, *metadata);
}
-static call_state *destroy_call(call_state *call) {
+static call_state* destroy_call(call_state* call) {
grpc_call_unref(call->call);
- call->call = NULL;
+ call->call = nullptr;
return maybe_delete_call_state(call);
}
-static void finished_request_call(void *csp, bool success) {
- call_state *cs = csp;
+static void finished_request_call(void* csp, bool success) {
+ call_state* cs = static_cast<call_state*>(csp);
GPR_ASSERT(cs->pending_ops > 0);
--cs->pending_ops;
if (success) {
- GPR_ASSERT(cs->call != NULL);
+ GPR_ASSERT(cs->call != nullptr);
cs->type = SERVER;
} else {
maybe_delete_call_state(cs);
@@ -695,25 +706,25 @@ static void finished_request_call(void *csp, bool success) {
}
typedef struct {
- call_state *cs;
+ call_state* cs;
uint8_t has_ops;
} batch_info;
-static void finished_batch(void *p, bool success) {
- batch_info *bi = p;
+static void finished_batch(void* p, bool success) {
+ batch_info* bi = static_cast<batch_info*>(p);
--bi->cs->pending_ops;
if ((bi->has_ops & (1u << GRPC_OP_RECV_MESSAGE)) &&
(bi->cs->done_flags & DONE_FLAG_CALL_CLOSED)) {
- GPR_ASSERT(bi->cs->recv_message == NULL);
+ GPR_ASSERT(bi->cs->recv_message == nullptr);
}
if ((bi->has_ops & (1u << GRPC_OP_RECV_MESSAGE) &&
- bi->cs->recv_message != NULL)) {
+ bi->cs->recv_message != nullptr)) {
grpc_byte_buffer_destroy(bi->cs->recv_message);
- bi->cs->recv_message = NULL;
+ bi->cs->recv_message = nullptr;
}
if ((bi->has_ops & (1u << GRPC_OP_SEND_MESSAGE))) {
grpc_byte_buffer_destroy(bi->cs->send_message);
- bi->cs->send_message = NULL;
+ bi->cs->send_message = nullptr;
}
if ((bi->has_ops & (1u << GRPC_OP_RECV_STATUS_ON_CLIENT)) ||
(bi->has_ops & (1u << GRPC_OP_RECV_CLOSE_ON_SERVER))) {
@@ -723,18 +734,18 @@ static void finished_batch(void *p, bool success) {
gpr_free(bi);
}
-static validator *make_finished_batch_validator(call_state *cs,
+static validator* make_finished_batch_validator(call_state* cs,
uint8_t has_ops) {
- batch_info *bi = gpr_malloc(sizeof(*bi));
+ batch_info* bi = static_cast<batch_info*>(gpr_malloc(sizeof(*bi)));
bi->cs = cs;
bi->has_ops = has_ops;
return create_validator(finished_batch, bi);
}
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_test_only_set_slice_hash_seed(0);
- char *grpc_trace_fuzzer = gpr_getenv("GRPC_TRACE_FUZZER");
- if (squelch && grpc_trace_fuzzer == NULL) gpr_set_log_function(dont_log);
+ char* grpc_trace_fuzzer = gpr_getenv("GRPC_TRACE_FUZZER");
+ if (squelch && grpc_trace_fuzzer == nullptr) gpr_set_log_function(dont_log);
gpr_free(grpc_trace_fuzzer);
input_stream inp = {data, data + size};
grpc_tcp_client_connect_impl = my_tcp_client_connect;
@@ -742,49 +753,49 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_init();
grpc_timer_manager_set_threading(false);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(false);
}
grpc_resolve_address = my_resolve_address;
grpc_dns_lookup_ares = my_dns_lookup_ares;
- GPR_ASSERT(g_channel == NULL);
- GPR_ASSERT(g_server == NULL);
+ GPR_ASSERT(g_channel == nullptr);
+ GPR_ASSERT(g_server == nullptr);
bool server_shutdown = false;
int pending_server_shutdowns = 0;
int pending_channel_watches = 0;
int pending_pings = 0;
- g_active_call = new_call(NULL, ROOT);
+ g_active_call = new_call(nullptr, ROOT);
g_resource_quota = grpc_resource_quota_create("api_fuzzer");
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
- while (!is_eof(&inp) || g_channel != NULL || g_server != NULL ||
+ while (!is_eof(&inp) || g_channel != nullptr || g_server != nullptr ||
pending_channel_watches > 0 || pending_pings > 0 ||
g_active_call->type != ROOT || g_active_call->next != g_active_call) {
if (is_eof(&inp)) {
- if (g_channel != NULL) {
+ if (g_channel != nullptr) {
grpc_channel_destroy(g_channel);
- g_channel = NULL;
+ g_channel = nullptr;
}
- if (g_server != NULL) {
+ if (g_server != nullptr) {
if (!server_shutdown) {
grpc_server_shutdown_and_notify(
- g_server, cq, create_validator(assert_success_and_decrement,
- &pending_server_shutdowns));
+ g_server, cq,
+ create_validator(assert_success_and_decrement,
+ &pending_server_shutdowns));
server_shutdown = true;
pending_server_shutdowns++;
} else if (pending_server_shutdowns == 0) {
grpc_server_destroy(g_server);
- g_server = NULL;
+ g_server = nullptr;
}
}
- call_state *s = g_active_call;
+ call_state* s = g_active_call;
do {
- if (s->type != PENDING_SERVER && s->call != NULL) {
+ if (s->type != PENDING_SERVER && s->call != nullptr) {
s = destroy_call(s);
} else {
s = s->next;
@@ -804,10 +815,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// tickle completion queue
case 0: {
grpc_event ev = grpc_completion_queue_next(
- cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ cq, gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
switch (ev.type) {
case GRPC_OP_COMPLETE: {
- validator *v = ev.tag;
+ validator* v = static_cast<validator*>(ev.tag);
v->validate(v->arg, ev.success);
gpr_free(v);
break;
@@ -828,17 +839,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// create an insecure channel
case 2: {
- if (g_channel == NULL) {
- char *target = read_string(&inp, NULL);
- char *target_uri;
+ if (g_channel == nullptr) {
+ char* target = read_string(&inp, nullptr);
+ char* target_uri;
gpr_asprintf(&target_uri, "dns:%s", target);
- grpc_channel_args *args = read_args(&inp);
- g_channel = grpc_insecure_channel_create(target_uri, args, NULL);
- GPR_ASSERT(g_channel != NULL);
+ grpc_channel_args* args = read_args(&inp);
+ g_channel = grpc_insecure_channel_create(target_uri, args, nullptr);
+ GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
@@ -849,9 +859,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// destroy a channel
case 3: {
- if (g_channel != NULL) {
+ if (g_channel != nullptr) {
grpc_channel_destroy(g_channel);
- g_channel = NULL;
+ g_channel = nullptr;
} else {
end(&inp);
}
@@ -859,16 +869,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// bring up a server
case 4: {
- if (g_server == NULL) {
- grpc_channel_args *args = read_args(&inp);
- g_server = grpc_server_create(args, NULL);
- GPR_ASSERT(g_server != NULL);
+ if (g_server == nullptr) {
+ grpc_channel_args* args = read_args(&inp);
+ g_server = grpc_server_create(args, nullptr);
+ GPR_ASSERT(g_server != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
- grpc_server_register_completion_queue(g_server, cq, NULL);
+ grpc_server_register_completion_queue(g_server, cq, nullptr);
grpc_server_start(g_server);
server_shutdown = false;
GPR_ASSERT(pending_server_shutdowns == 0);
@@ -879,10 +888,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// begin server shutdown
case 5: {
- if (g_server != NULL) {
+ if (g_server != nullptr) {
grpc_server_shutdown_and_notify(
- g_server, cq, create_validator(assert_success_and_decrement,
- &pending_server_shutdowns));
+ g_server, cq,
+ create_validator(assert_success_and_decrement,
+ &pending_server_shutdowns));
pending_server_shutdowns++;
server_shutdown = true;
} else {
@@ -892,7 +902,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// cancel all calls if shutdown
case 6: {
- if (g_server != NULL && server_shutdown) {
+ if (g_server != nullptr && server_shutdown) {
grpc_server_cancel_all_calls(g_server);
} else {
end(&inp);
@@ -901,10 +911,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// destroy server
case 7: {
- if (g_server != NULL && server_shutdown &&
+ if (g_server != nullptr && server_shutdown &&
pending_server_shutdowns == 0) {
grpc_server_destroy(g_server);
- g_server = NULL;
+ g_server = nullptr;
} else {
end(&inp);
}
@@ -912,7 +922,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// check connectivity
case 8: {
- if (g_channel != NULL) {
+ if (g_channel != nullptr) {
uint8_t try_to_connect = next_byte(&inp);
if (try_to_connect == 0 || try_to_connect == 1) {
grpc_channel_check_connectivity_state(g_channel, try_to_connect);
@@ -926,7 +936,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// watch connectivity
case 9: {
- if (g_channel != NULL) {
+ if (g_channel != nullptr) {
grpc_connectivity_state st =
grpc_channel_check_connectivity_state(g_channel, 0);
if (st != GRPC_CHANNEL_SHUTDOWN) {
@@ -948,10 +958,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// create a call
case 10: {
bool ok = true;
- if (g_channel == NULL) ok = false;
- grpc_call *parent_call = NULL;
+ if (g_channel == nullptr) ok = false;
+ grpc_call* parent_call = nullptr;
if (g_active_call->type != ROOT) {
- if (g_active_call->call == NULL || g_active_call->type == CLIENT) {
+ if (g_active_call->call == nullptr || g_active_call->type == CLIENT) {
end(&inp);
break;
}
@@ -968,10 +978,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN));
if (ok) {
- call_state *cs = new_call(g_active_call, CLIENT);
+ call_state* cs = new_call(g_active_call, CLIENT);
cs->call =
grpc_channel_create_call(g_channel, parent_call, propagation_mask,
- cq, method, &host, deadline, NULL);
+ cq, method, &host, deadline, nullptr);
} else {
end(&inp);
}
@@ -987,7 +997,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// queue some ops on a call
case 12: {
if (g_active_call->type == PENDING_SERVER ||
- g_active_call->type == ROOT || g_active_call->call == NULL) {
+ g_active_call->type == ROOT || g_active_call->call == nullptr) {
end(&inp);
break;
}
@@ -996,11 +1006,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
end(&inp);
break;
}
- grpc_op *ops = gpr_malloc(sizeof(grpc_op) * num_ops);
+ grpc_op* ops =
+ static_cast<grpc_op*>(gpr_malloc(sizeof(grpc_op) * num_ops));
if (num_ops > 0) memset(ops, 0, sizeof(grpc_op) * num_ops);
bool ok = true;
size_t i;
- grpc_op *op;
+ grpc_op* op;
uint8_t has_ops = 0;
for (i = 0; i < num_ops; i++) {
op = &ops[i];
@@ -1019,7 +1030,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
break;
case GRPC_OP_SEND_MESSAGE:
op->op = GRPC_OP_SEND_MESSAGE;
- if (g_active_call->send_message != NULL) {
+ if (g_active_call->send_message != nullptr) {
ok = false;
} else {
has_ops |= 1 << GRPC_OP_SEND_MESSAGE;
@@ -1039,7 +1050,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
&op->data.send_status_from_server.trailing_metadata_count,
&op->data.send_status_from_server.trailing_metadata,
g_active_call);
- op->data.send_status_from_server.status = next_byte(&inp);
+ op->data.send_status_from_server.status =
+ static_cast<grpc_status_code>(next_byte(&inp));
op->data.send_status_from_server.status_details =
add_slice_to_unref(g_active_call,
read_buffer_like_slice(&inp));
@@ -1070,14 +1082,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
&g_active_call->cancelled;
break;
}
- op->reserved = NULL;
+ op->reserved = nullptr;
op->flags = read_uint32(&inp);
}
if (ok) {
- validator *v = make_finished_batch_validator(g_active_call, has_ops);
+ validator* v = make_finished_batch_validator(g_active_call, has_ops);
g_active_call->pending_ops++;
- grpc_call_error error =
- grpc_call_start_batch(g_active_call->call, ops, num_ops, v, NULL);
+ grpc_call_error error = grpc_call_start_batch(
+ g_active_call->call, ops, num_ops, v, nullptr);
if (error != GRPC_CALL_OK) {
v->validate(v->arg, false);
gpr_free(v);
@@ -1087,7 +1099,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
if (!ok && (has_ops & (1 << GRPC_OP_SEND_MESSAGE))) {
grpc_byte_buffer_destroy(g_active_call->send_message);
- g_active_call->send_message = NULL;
+ g_active_call->send_message = nullptr;
}
gpr_free(ops);
@@ -1095,8 +1107,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// cancel current call
case 13: {
- if (g_active_call->type != ROOT && g_active_call->call != NULL) {
- grpc_call_cancel(g_active_call->call, NULL);
+ if (g_active_call->type != ROOT && g_active_call->call != nullptr) {
+ grpc_call_cancel(g_active_call->call, nullptr);
} else {
end(&inp);
}
@@ -1104,7 +1116,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// get a calls peer
case 14: {
- if (g_active_call->type != ROOT && g_active_call->call != NULL) {
+ if (g_active_call->type != ROOT && g_active_call->call != nullptr) {
free_non_null(grpc_call_get_peer(g_active_call->call));
} else {
end(&inp);
@@ -1113,7 +1125,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// get a channels target
case 15: {
- if (g_channel != NULL) {
+ if (g_channel != nullptr) {
free_non_null(grpc_channel_get_target(g_channel));
} else {
end(&inp);
@@ -1122,10 +1134,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// send a ping on a channel
case 16: {
- if (g_channel != NULL) {
+ if (g_channel != nullptr) {
pending_pings++;
grpc_channel_ping(g_channel, cq,
- create_validator(decrement, &pending_pings), NULL);
+ create_validator(decrement, &pending_pings),
+ nullptr);
} else {
end(&inp);
}
@@ -1133,27 +1146,27 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// enable a tracer
case 17: {
- char *tracer = read_string(&inp, NULL);
+ char* tracer = read_string(&inp, nullptr);
grpc_tracer_set_enabled(tracer, 1);
gpr_free(tracer);
break;
}
// disable a tracer
case 18: {
- char *tracer = read_string(&inp, NULL);
+ char* tracer = read_string(&inp, nullptr);
grpc_tracer_set_enabled(tracer, 0);
gpr_free(tracer);
break;
}
// request a server call
case 19: {
- if (g_server == NULL) {
+ if (g_server == nullptr) {
end(&inp);
break;
}
- call_state *cs = new_call(g_active_call, PENDING_SERVER);
+ call_state* cs = new_call(g_active_call, PENDING_SERVER);
cs->pending_ops++;
- validator *v = create_validator(finished_request_call, cs);
+ validator* v = create_validator(finished_request_call, cs);
grpc_call_error error =
grpc_server_request_call(g_server, &cs->call, &cs->call_details,
&cs->recv_initial_metadata, cq, cq, v);
@@ -1167,7 +1180,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
case 20: {
if (g_active_call->type != ROOT &&
g_active_call->type != PENDING_SERVER &&
- g_active_call->call != NULL) {
+ g_active_call->call != nullptr) {
destroy_call(g_active_call);
} else {
end(&inp);
@@ -1181,18 +1194,18 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// create a secure channel
case 22: {
- if (g_channel == NULL) {
- char *target = read_string(&inp, NULL);
- char *target_uri;
+ if (g_channel == nullptr) {
+ char* target = read_string(&inp, nullptr);
+ char* target_uri;
gpr_asprintf(&target_uri, "dns:%s", target);
- grpc_channel_args *args = read_args(&inp);
- grpc_channel_credentials *creds = read_channel_creds(&inp);
- g_channel = grpc_secure_channel_create(creds, target_uri, args, NULL);
- GPR_ASSERT(g_channel != NULL);
+ grpc_channel_args* args = read_args(&inp);
+ grpc_channel_credentials* creds = read_channel_creds(&inp);
+ g_channel =
+ grpc_secure_channel_create(creds, target_uri, args, nullptr);
+ GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
@@ -1205,15 +1218,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
}
- GPR_ASSERT(g_channel == NULL);
- GPR_ASSERT(g_server == NULL);
+ GPR_ASSERT(g_channel == nullptr);
+ GPR_ASSERT(g_server == nullptr);
GPR_ASSERT(g_active_call->type == ROOT);
GPR_ASSERT(g_active_call->next == g_active_call);
gpr_free(g_active_call);
grpc_completion_queue_shutdown(cq);
GPR_ASSERT(
- grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL)
+ grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), nullptr)
.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5
new file mode 100644
index 0000000000..1745798b68
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5
Binary files differ
diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c
deleted file mode 100644
index 88ba6bad83..0000000000
--- a/test/core/end2end/fuzzers/client_fuzzer.c
+++ /dev/null
@@ -1,157 +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 <string.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/surface/channel.h"
-#include "test/core/util/memory_counters.h"
-#include "test/core/util/mock_endpoint.h"
-
-bool squelch = true;
-bool leak_check = true;
-
-static void discard_write(grpc_slice slice) {}
-
-static void *tag(int n) { return (void *)(uintptr_t)n; }
-
-static void dont_log(gpr_log_func_args *args) {}
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- grpc_test_only_set_slice_hash_seed(0);
- struct grpc_memory_counters counters;
- if (squelch) gpr_set_log_function(dont_log);
- if (leak_check) grpc_memory_counters_init();
- grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
-
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("client_fuzzer");
- grpc_endpoint *mock_endpoint =
- grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
-
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_transport *transport =
- grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 1);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
-
- grpc_channel *channel = grpc_channel_create(
- &exec_ctx, "test-target", NULL, GRPC_CLIENT_DIRECT_CHANNEL, transport);
- grpc_slice host = grpc_slice_from_static_string("localhost");
- grpc_call *call = grpc_channel_create_call(
- channel, NULL, 0, cq, grpc_slice_from_static_string("/foo"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
-
- grpc_metadata_array initial_metadata_recv;
- grpc_metadata_array_init(&initial_metadata_recv);
- grpc_byte_buffer *response_payload_recv = NULL;
- grpc_metadata_array trailing_metadata_recv;
- grpc_metadata_array_init(&trailing_metadata_recv);
- grpc_status_code status;
- grpc_slice details = grpc_empty_slice();
-
- grpc_op ops[6];
- memset(ops, 0, sizeof(ops));
- grpc_op *op = ops;
- op->op = GRPC_OP_SEND_INITIAL_METADATA;
- op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_INITIAL_METADATA;
- op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_MESSAGE;
- op->data.recv_message.recv_message = &response_payload_recv;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
- op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
- op->data.recv_status_on_client.status = &status;
- op->data.recv_status_on_client.status_details = &details;
- op->flags = 0;
- op->reserved = NULL;
- op++;
- grpc_call_error error =
- grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), NULL);
- int requested_calls = 1;
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char *)data, size));
-
- grpc_event ev;
- while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
- switch (ev.type) {
- case GRPC_QUEUE_TIMEOUT:
- goto done;
- case GRPC_QUEUE_SHUTDOWN:
- break;
- case GRPC_OP_COMPLETE:
- requested_calls--;
- break;
- }
- }
-
-done:
- if (requested_calls) {
- grpc_call_cancel(call, NULL);
- }
- for (int i = 0; i < requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- }
- grpc_completion_queue_shutdown(cq);
- for (int i = 0; i < requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
- }
- grpc_call_unref(call);
- grpc_completion_queue_destroy(cq);
- grpc_metadata_array_destroy(&initial_metadata_recv);
- grpc_metadata_array_destroy(&trailing_metadata_recv);
- grpc_slice_unref(details);
- grpc_channel_destroy(channel);
- if (response_payload_recv != NULL) {
- grpc_byte_buffer_destroy(response_payload_recv);
- }
- grpc_shutdown();
- if (leak_check) {
- counters = grpc_memory_counters_snapshot();
- grpc_memory_counters_destroy();
- GPR_ASSERT(counters.total_size_relative == 0);
- }
- return 0;
-}
diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
new file mode 100644
index 0000000000..c17d581d8b
--- /dev/null
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -0,0 +1,162 @@
+/*
+ *
+ * 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 <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/surface/channel.h"
+#include "test/core/util/memory_counters.h"
+#include "test/core/util/mock_endpoint.h"
+
+bool squelch = true;
+bool leak_check = true;
+
+static void discard_write(grpc_slice slice) {}
+
+static void* tag(int n) { return (void*)(uintptr_t)n; }
+
+static void dont_log(gpr_log_func_args* args) {}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ grpc_test_only_set_slice_hash_seed(0);
+ struct grpc_memory_counters counters;
+ if (squelch) gpr_set_log_function(dont_log);
+ if (leak_check) grpc_memory_counters_init();
+ grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(false);
+
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("client_fuzzer");
+ grpc_endpoint* mock_endpoint =
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
+
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, true);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
+
+ grpc_channel* channel = grpc_channel_create(
+ "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_slice host = grpc_slice_from_static_string("localhost");
+ grpc_call* call = grpc_channel_create_call(
+ channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host,
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
+
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_byte_buffer* response_payload_recv = nullptr;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_status_code status;
+ grpc_slice details = grpc_empty_slice();
+
+ grpc_op ops[6];
+ memset(ops, 0, sizeof(ops));
+ grpc_op* op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata =
+ &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message = &response_payload_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ grpc_call_error error =
+ grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
+ int requested_calls = 1;
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ grpc_mock_endpoint_put_read(
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
+
+ grpc_event ev;
+ while (1) {
+ grpc_core::ExecCtx::Get()->Flush();
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ switch (ev.type) {
+ case GRPC_QUEUE_TIMEOUT:
+ goto done;
+ case GRPC_QUEUE_SHUTDOWN:
+ break;
+ case GRPC_OP_COMPLETE:
+ requested_calls--;
+ break;
+ }
+ }
+
+ done:
+ if (requested_calls) {
+ grpc_call_cancel(call, nullptr);
+ }
+ for (int i = 0; i < requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+ }
+ grpc_completion_queue_shutdown(cq);
+ for (int i = 0; i < requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
+ }
+ grpc_call_unref(call);
+ grpc_completion_queue_destroy(cq);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_slice_unref(details);
+ grpc_channel_destroy(channel);
+ if (response_payload_recv != nullptr) {
+ grpc_byte_buffer_destroy(response_payload_recv);
+ }
+ }
+ grpc_shutdown();
+ if (leak_check) {
+ counters = grpc_memory_counters_snapshot();
+ grpc_memory_counters_destroy();
+ GPR_ASSERT(counters.total_size_relative == 0);
+ }
+ return 0;
+}
diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary
index 7c77512aa9..a87e49ee52 100644
--- a/test/core/end2end/fuzzers/hpack.dictionary
+++ b/test/core/end2end/fuzzers/hpack.dictionary
@@ -28,6 +28,9 @@
"\x1Egrpc.max_request_message_bytes"
"\x1Fgrpc.max_response_message_bytes"
"$/grpc.lb.v1.LoadBalancer/BalanceLoad"
+"\x0Fmessage/deflate"
+"\x0Cmessage/gzip"
+"\x0Bstream/gzip"
"\x010"
"\x011"
"\x012"
diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c
deleted file mode 100644
index ef4c0a4bfd..0000000000
--- a/test/core/end2end/fuzzers/server_fuzzer.c
+++ /dev/null
@@ -1,123 +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 <grpc/grpc.h>
-
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/surface/server.h"
-#include "test/core/util/memory_counters.h"
-#include "test/core/util/mock_endpoint.h"
-
-bool squelch = true;
-bool leak_check = true;
-
-static void discard_write(grpc_slice slice) {}
-
-static void *tag(int n) { return (void *)(uintptr_t)n; }
-static int detag(void *p) { return (int)(uintptr_t)p; }
-
-static void dont_log(gpr_log_func_args *args) {}
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- grpc_test_only_set_slice_hash_seed(0);
- struct grpc_memory_counters counters;
- if (squelch) gpr_set_log_function(dont_log);
- if (leak_check) grpc_memory_counters_init();
- grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
-
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("server_fuzzer");
- grpc_endpoint *mock_endpoint =
- grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char *)data, size));
-
- grpc_server *server = grpc_server_create(NULL, NULL);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(server, cq, NULL);
- // TODO(ctiller): add registered methods (one for POST, one for PUT)
- // void *registered_method =
- // grpc_server_register_method(server, "/reg", NULL, 0);
- grpc_server_start(server);
- grpc_transport *transport =
- grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 0);
- grpc_server_setup_transport(&exec_ctx, server, transport, NULL, NULL);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
-
- grpc_call *call1 = NULL;
- grpc_call_details call_details1;
- grpc_metadata_array request_metadata1;
- grpc_call_details_init(&call_details1);
- grpc_metadata_array_init(&request_metadata1);
- int requested_calls = 0;
-
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_server_request_call(server, &call1, &call_details1,
- &request_metadata1, cq, cq, tag(1)));
- requested_calls++;
-
- grpc_event ev;
- while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
- switch (ev.type) {
- case GRPC_QUEUE_TIMEOUT:
- goto done;
- case GRPC_QUEUE_SHUTDOWN:
- break;
- case GRPC_OP_COMPLETE:
- switch (detag(ev.tag)) {
- case 1:
- requested_calls--;
- // TODO(ctiller): keep reading that call!
- break;
- }
- }
- }
-
-done:
- if (call1 != NULL) grpc_call_unref(call1);
- grpc_call_details_destroy(&call_details1);
- grpc_metadata_array_destroy(&request_metadata1);
- grpc_server_shutdown_and_notify(server, cq, tag(0xdead));
- grpc_server_cancel_all_calls(server);
- for (int i = 0; i <= requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- }
- grpc_completion_queue_shutdown(cq);
- for (int i = 0; i <= requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
- }
- grpc_server_destroy(server);
- grpc_completion_queue_destroy(cq);
- grpc_shutdown();
- if (leak_check) {
- counters = grpc_memory_counters_snapshot();
- grpc_memory_counters_destroy();
- GPR_ASSERT(counters.total_size_relative == 0);
- }
- return 0;
-}
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
new file mode 100644
index 0000000000..61c55e0afd
--- /dev/null
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -0,0 +1,127 @@
+/*
+ *
+ * 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 <grpc/grpc.h>
+
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/surface/server.h"
+#include "test/core/util/memory_counters.h"
+#include "test/core/util/mock_endpoint.h"
+
+bool squelch = true;
+bool leak_check = true;
+
+static void discard_write(grpc_slice slice) {}
+
+static void* tag(int n) { return (void*)(uintptr_t)n; }
+static int detag(void* p) { return (int)(uintptr_t)p; }
+
+static void dont_log(gpr_log_func_args* args) {}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ grpc_test_only_set_slice_hash_seed(0);
+ struct grpc_memory_counters counters;
+ if (squelch) gpr_set_log_function(dont_log);
+ if (leak_check) grpc_memory_counters_init();
+ grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_executor_set_threading(false);
+
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("server_fuzzer");
+ grpc_endpoint* mock_endpoint =
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_mock_endpoint_put_read(
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
+
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server, cq, nullptr);
+ // TODO(ctiller): add registered methods (one for POST, one for PUT)
+ // void *registered_method =
+ // grpc_server_register_method(server, "/reg", NULL, 0);
+ grpc_server_start(server);
+ grpc_transport* transport =
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, false);
+ grpc_server_setup_transport(server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
+
+ grpc_call* call1 = nullptr;
+ grpc_call_details call_details1;
+ grpc_metadata_array request_metadata1;
+ grpc_call_details_init(&call_details1);
+ grpc_metadata_array_init(&request_metadata1);
+ int requested_calls = 0;
+
+ GPR_ASSERT(GRPC_CALL_OK ==
+ grpc_server_request_call(server, &call1, &call_details1,
+ &request_metadata1, cq, cq, tag(1)));
+ requested_calls++;
+
+ grpc_event ev;
+ while (1) {
+ grpc_core::ExecCtx::Get()->Flush();
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ switch (ev.type) {
+ case GRPC_QUEUE_TIMEOUT:
+ goto done;
+ case GRPC_QUEUE_SHUTDOWN:
+ break;
+ case GRPC_OP_COMPLETE:
+ switch (detag(ev.tag)) {
+ case 1:
+ requested_calls--;
+ // TODO(ctiller): keep reading that call!
+ break;
+ }
+ }
+ }
+
+ done:
+ if (call1 != nullptr) grpc_call_unref(call1);
+ grpc_call_details_destroy(&call_details1);
+ grpc_metadata_array_destroy(&request_metadata1);
+ grpc_server_shutdown_and_notify(server, cq, tag(0xdead));
+ grpc_server_cancel_all_calls(server);
+ for (int i = 0; i <= requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+ }
+ grpc_completion_queue_shutdown(cq);
+ for (int i = 0; i <= requested_calls; i++) {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
+ }
+ grpc_server_destroy(server);
+ grpc_completion_queue_destroy(cq);
+ }
+ grpc_shutdown();
+ if (leak_check) {
+ counters = grpc_memory_counters_snapshot();
+ grpc_memory_counters_destroy();
+ GPR_ASSERT(counters.total_size_relative == 0);
+ }
+ return 0;
+}
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 33fd97f3bd..e7cf97b2d0 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -24,15 +24,15 @@ import hashlib
FixtureOptions = collections.namedtuple(
'FixtureOptions',
- 'fullstack includes_proxy dns_resolver name_resolution secure platforms ci_mac tracing exclude_configs exclude_iomgrs large_writes enables_compression supports_compression is_inproc is_http2 supports_proxy_auth')
+ 'fullstack includes_proxy dns_resolver name_resolution secure platforms ci_mac tracing exclude_configs exclude_iomgrs large_writes enables_compression supports_compression is_inproc is_http2 supports_proxy_auth supports_write_buffering')
default_unsecure_fixture_options = FixtureOptions(
- True, False, True, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [], True, False, True, False, True, False)
+ True, False, True, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [], True, False, True, False, True, False, True)
socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False)
default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True)
uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'])
fd_unsecure_fixture_options = default_unsecure_fixture_options._replace(
dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'])
-inproc_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False)
+inproc_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False, supports_write_buffering=False)
# maps fixture name to whether it requires the security library
END2END_FIXTURES = {
@@ -60,7 +60,6 @@ END2END_FIXTURES = {
'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace(
ci_mac=False, tracing=True, large_writes=False, exclude_iomgrs=['uv']),
'h2_ssl': default_secure_fixture_options,
- 'h2_ssl_cert': default_secure_fixture_options,
'h2_ssl_proxy': default_secure_fixture_options._replace(
includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']),
'h2_uds': uds_fixture_options,
@@ -69,8 +68,8 @@ END2END_FIXTURES = {
TestOptions = collections.namedtuple(
'TestOptions',
- 'needs_fullstack needs_dns needs_names proxyable secure traceable cpu_cost exclude_iomgrs large_writes flaky allows_compression needs_compression exclude_inproc needs_http2 needs_proxy_auth')
-default_test_options = TestOptions(False, False, False, True, False, True, 1.0, [], False, False, True, False, False, False, False)
+ 'needs_fullstack needs_dns needs_names proxyable secure traceable cpu_cost exclude_iomgrs large_writes flaky allows_compression needs_compression exclude_inproc needs_http2 needs_proxy_auth needs_write_buffering')
+default_test_options = TestOptions(False, False, False, True, False, True, 1.0, [], False, False, True, False, False, False, False, False)
connectivity_test_options = default_test_options._replace(needs_fullstack=True)
LOWCPU = 0.1
@@ -102,6 +101,7 @@ END2END_TESTS = {
'filter_causes_close': default_test_options._replace(cpu_cost=LOWCPU),
'filter_call_init_fails': default_test_options,
'filter_latency': default_test_options._replace(cpu_cost=LOWCPU),
+ 'filter_status_code': default_test_options._replace(cpu_cost=LOWCPU),
'graceful_server_shutdown': default_test_options._replace(cpu_cost=LOWCPU,exclude_inproc=True),
'hpack_size': default_test_options._replace(proxyable=False,
traceable=False,
@@ -147,8 +147,10 @@ END2END_TESTS = {
'streaming_error_response': default_test_options._replace(cpu_cost=LOWCPU),
'trailing_metadata': default_test_options,
'workaround_cronet_compression': default_test_options,
- 'write_buffering': default_test_options._replace(cpu_cost=LOWCPU),
- 'write_buffering_at_end': default_test_options._replace(cpu_cost=LOWCPU),
+ 'write_buffering': default_test_options._replace(cpu_cost=LOWCPU,
+ needs_write_buffering=True),
+ 'write_buffering_at_end': default_test_options._replace(cpu_cost=LOWCPU,
+ needs_write_buffering=True),
}
@@ -186,6 +188,9 @@ def compatible(f, t):
if END2END_TESTS[t].needs_proxy_auth:
if not END2END_FIXTURES[f].supports_proxy_auth:
return False
+ if END2END_TESTS[t].needs_write_buffering:
+ if not END2END_FIXTURES[f].supports_write_buffering:
+ return False
return True
@@ -216,9 +221,9 @@ def main():
'build': 'private',
'language': 'c',
'secure': True,
- 'src': ['test/core/end2end/end2end_tests.c',
- 'test/core/end2end/end2end_test_utils.c'] + [
- 'test/core/end2end/tests/%s.c' % t
+ 'src': ['test/core/end2end/end2end_tests.cc',
+ 'test/core/end2end/end2end_test_utils.cc'] + [
+ 'test/core/end2end/tests/%s.cc' % t
for t in sorted(END2END_TESTS.keys())],
'headers': ['test/core/end2end/tests/cancel_test_helpers.h',
'test/core/end2end/end2end_tests.h'],
@@ -231,9 +236,9 @@ def main():
'build': 'private',
'language': 'c',
'secure': False,
- 'src': ['test/core/end2end/end2end_nosec_tests.c',
- 'test/core/end2end/end2end_test_utils.c'] + [
- 'test/core/end2end/tests/%s.c' % t
+ 'src': ['test/core/end2end/end2end_nosec_tests.cc',
+ 'test/core/end2end/end2end_test_utils.cc'] + [
+ 'test/core/end2end/tests/%s.cc' % t
for t in sorted(END2END_TESTS.keys())
if not END2END_TESTS[t].secure],
'headers': ['test/core/end2end/tests/cancel_test_helpers.h',
@@ -248,7 +253,7 @@ def main():
'build': 'test',
'language': 'c',
'run': False,
- 'src': ['test/core/end2end/fixtures/%s.c' % f],
+ 'src': ['test/core/end2end/fixtures/%s.cc' % f],
'platforms': END2END_FIXTURES[f].platforms,
'ci_platforms': (END2END_FIXTURES[f].platforms
if END2END_FIXTURES[f].ci_mac else without(
@@ -265,7 +270,7 @@ def main():
'build': 'test',
'language': 'c',
'secure': False,
- 'src': ['test/core/end2end/fixtures/%s.c' % f],
+ 'src': ['test/core/end2end/fixtures/%s.cc' % f],
'run': False,
'platforms': END2END_FIXTURES[f].platforms,
'ci_platforms': (END2END_FIXTURES[f].platforms
diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl
index 9bbba26108..1d759e1ecb 100755
--- a/test/core/end2end/generate_tests.bzl
+++ b/test/core/end2end/generate_tests.bzl
@@ -21,7 +21,8 @@ load("//bazel:grpc_build_system.bzl", "grpc_sh_test", "grpc_cc_binary", "grpc_cc
def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True,
name_resolution=True, secure=True, tracing=False,
platforms=['windows', 'linux', 'mac', 'posix'],
- is_inproc=False, is_http2=True, supports_proxy_auth=False):
+ is_inproc=False, is_http2=True, supports_proxy_auth=False,
+ supports_write_buffering=True):
return struct(
fullstack=fullstack,
includes_proxy=includes_proxy,
@@ -31,7 +32,8 @@ def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True,
tracing=tracing,
is_inproc=is_inproc,
is_http2=is_http2,
- supports_proxy_auth=supports_proxy_auth
+ supports_proxy_auth=supports_proxy_auth,
+ supports_write_buffering=supports_write_buffering
#platforms=platforms
)
@@ -56,20 +58,19 @@ END2END_FIXTURES = {
'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False,
tracing=True),
'h2_ssl': fixture_options(secure=True),
- 'h2_ssl_cert': fixture_options(secure=True),
'h2_ssl_proxy': fixture_options(includes_proxy=True, secure=True),
'h2_uds': fixture_options(dns_resolver=False,
platforms=['linux', 'mac', 'posix']),
'inproc': fixture_options(fullstack=False, dns_resolver=False,
name_resolution=False, is_inproc=True,
- is_http2=False),
+ is_http2=False, supports_write_buffering=False),
}
def test_options(needs_fullstack=False, needs_dns=False, needs_names=False,
proxyable=True, secure=False, traceable=False,
exclude_inproc=False, needs_http2=False,
- needs_proxy_auth=False):
+ needs_proxy_auth=False, needs_write_buffering=False):
return struct(
needs_fullstack=needs_fullstack,
needs_dns=needs_dns,
@@ -79,7 +80,8 @@ def test_options(needs_fullstack=False, needs_dns=False, needs_names=False,
traceable=traceable,
exclude_inproc=exclude_inproc,
needs_http2=needs_http2,
- needs_proxy_auth=needs_proxy_auth
+ needs_proxy_auth=needs_proxy_auth,
+ needs_write_buffering=needs_write_buffering
)
@@ -144,9 +146,10 @@ END2END_TESTS = {
'trailing_metadata': test_options(),
'authority_not_supported': test_options(),
'filter_latency': test_options(),
+ 'filter_status_code': test_options(),
'workaround_cronet_compression': test_options(),
- 'write_buffering': test_options(),
- 'write_buffering_at_end': test_options(),
+ 'write_buffering': test_options(needs_write_buffering=True),
+ 'write_buffering_at_end': test_options(needs_write_buffering=True),
}
@@ -175,20 +178,23 @@ def compatible(fopt, topt):
if topt.needs_proxy_auth:
if not fopt.supports_proxy_auth:
return False
+ if topt.needs_write_buffering:
+ if not fopt.supports_write_buffering:
+ return False
return True
def grpc_end2end_tests():
grpc_cc_library(
name = 'end2end_tests',
- srcs = ['end2end_tests.c', 'end2end_test_utils.c'] + [
- 'tests/%s.c' % t
+ srcs = ['end2end_tests.cc', 'end2end_test_utils.cc'] + [
+ 'tests/%s.cc' % t
for t in sorted(END2END_TESTS.keys())],
hdrs = [
'tests/cancel_test_helpers.h',
'end2end_tests.h'
],
- language = "C",
+ language = "C++",
deps = [
':cq_verifier',
':ssl_test_data',
@@ -200,8 +206,8 @@ def grpc_end2end_tests():
for f, fopt in END2END_FIXTURES.items():
grpc_cc_binary(
name = '%s_test' % f,
- srcs = ['fixtures/%s.c' % f],
- language = "C",
+ srcs = ['fixtures/%s.cc' % f],
+ language = "C++",
deps = [
':end2end_tests',
'//test/core/util:grpc_test_util',
diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.cc
index c3aca13249..f23d87ea68 100644
--- a/test/core/end2end/goaway_server_test.c
+++ b/test/core/end2end/goaway_server_test.cc
@@ -35,21 +35,20 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static void *tag(intptr_t i) { return (void *)i; }
+static void* tag(intptr_t i) { return (void*)i; }
static gpr_mu g_mu;
static int g_resolve_port = -1;
-static void (*iomgr_resolve_address)(grpc_exec_ctx *exec_ctx, const char *addr,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addresses);
-
-static grpc_ares_request *(*iomgr_dns_lookup_ares)(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addresses, bool check_grpclb,
- char **service_config_json);
+static void (*iomgr_resolve_address)(const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addresses);
+
+static grpc_ares_request* (*iomgr_dns_lookup_ares)(
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addresses, bool check_grpclb,
+ char** service_config_json);
static void set_resolve_port(int port) {
gpr_mu_lock(&g_mu);
@@ -57,73 +56,74 @@ static void set_resolve_port(int port) {
gpr_mu_unlock(&g_mu);
}
-static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
- const char *default_port,
- grpc_pollset_set *interested_parties,
- grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {
+static void my_resolve_address(const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_resolved_addresses** addrs) {
if (0 != strcmp(addr, "test")) {
- iomgr_resolve_address(exec_ctx, addr, default_port, interested_parties,
- on_done, addrs);
+ iomgr_resolve_address(addr, default_port, interested_parties, on_done,
+ addrs);
return;
}
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
gpr_mu_lock(&g_mu);
if (g_resolve_port < 0) {
gpr_mu_unlock(&g_mu);
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
- *addrs = gpr_malloc(sizeof(**addrs));
+ *addrs = static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(**addrs)));
(*addrs)->naddrs = 1;
- (*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs));
+ (*addrs)->addrs = static_cast<grpc_resolved_address*>(
+ gpr_malloc(sizeof(*(*addrs)->addrs)));
memset((*addrs)->addrs, 0, sizeof(*(*addrs)->addrs));
- struct sockaddr_in *sa = (struct sockaddr_in *)(*addrs)->addrs[0].addr;
+ struct sockaddr_in* sa = (struct sockaddr_in*)(*addrs)->addrs[0].addr;
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = htonl(0x7f000001);
sa->sin_port = htons((uint16_t)g_resolve_port);
(*addrs)->addrs[0].len = sizeof(*sa);
gpr_mu_unlock(&g_mu);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
-static grpc_ares_request *my_dns_lookup_ares(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **lb_addrs, bool check_grpclb,
- char **service_config_json) {
+static grpc_ares_request* my_dns_lookup_ares(
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb,
+ char** service_config_json) {
if (0 != strcmp(addr, "test")) {
- return iomgr_dns_lookup_ares(exec_ctx, dns_server, addr, default_port,
+ return iomgr_dns_lookup_ares(dns_server, addr, default_port,
interested_parties, on_done, lb_addrs,
check_grpclb, service_config_json);
}
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
gpr_mu_lock(&g_mu);
if (g_resolve_port < 0) {
gpr_mu_unlock(&g_mu);
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
- *lb_addrs = grpc_lb_addresses_create(1, NULL);
- struct sockaddr_in *sa = gpr_zalloc(sizeof(struct sockaddr_in));
+ *lb_addrs = grpc_lb_addresses_create(1, nullptr);
+ struct sockaddr_in* sa = static_cast<struct sockaddr_in*>(
+ gpr_zalloc(sizeof(struct sockaddr_in)));
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = htonl(0x7f000001);
sa->sin_port = htons((uint16_t)g_resolve_port);
- grpc_lb_addresses_set_address(*lb_addrs, 0, sa, sizeof(*sa), false, NULL,
- NULL);
+ grpc_lb_addresses_set_address(*lb_addrs, 0, sa, sizeof(*sa), false, nullptr,
+ nullptr);
gpr_free(sa);
gpr_mu_unlock(&g_mu);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
- return NULL;
+ GRPC_CLOSURE_SCHED(on_done, error);
+ return nullptr;
}
-int main(int argc, char **argv) {
- grpc_completion_queue *cq;
- cq_verifier *cqv;
+int main(int argc, char** argv) {
+ grpc_completion_queue* cq;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_test_init(argc, argv);
@@ -155,42 +155,44 @@ int main(int argc, char **argv) {
grpc_metadata_array_init(&request_metadata2);
grpc_call_details_init(&request_details2);
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
cqv = cq_verifier_create(cq);
/* reserve two ports */
int port1 = grpc_pick_unused_port_or_die();
int port2 = grpc_pick_unused_port_or_die();
- char *addr;
+ char* addr;
grpc_channel_args client_args;
grpc_arg arg_array[1];
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = 1000;
client_args.args = arg_array;
client_args.num_args = 1;
/* create a channel that picks first amongst the servers */
- grpc_channel *chan = grpc_insecure_channel_create("test", &client_args, NULL);
+ grpc_channel* chan =
+ grpc_insecure_channel_create("test", &client_args, nullptr);
/* and an initial call to them */
grpc_slice host = grpc_slice_from_static_string("127.0.0.1");
- grpc_call *call1 =
- grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_call* call1 =
+ grpc_channel_create_call(chan, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), &host,
- grpc_timeout_seconds_to_deadline(20), NULL);
+ grpc_timeout_seconds_to_deadline(20), nullptr);
/* send initial metadata to probe connectivity */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = NULL;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call1, ops,
(size_t)(op - ops),
- tag(0x101), NULL));
+ tag(0x101), nullptr));
/* and receive status to probe termination */
memset(ops, 0, sizeof(ops));
op = ops;
@@ -199,22 +201,22 @@ int main(int argc, char **argv) {
op->data.recv_status_on_client.status = &status1;
op->data.recv_status_on_client.status_details = &details1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call1, ops,
(size_t)(op - ops),
- tag(0x102), NULL));
+ tag(0x102), nullptr));
/* bring a server up on the first port */
- grpc_server *server1 = grpc_server_create(NULL, NULL);
+ grpc_server* server1 = grpc_server_create(nullptr, nullptr);
gpr_asprintf(&addr, "127.0.0.1:%d", port1);
grpc_server_add_insecure_http2_port(server1, addr);
- grpc_server_register_completion_queue(server1, cq, NULL);
+ grpc_server_register_completion_queue(server1, cq, nullptr);
gpr_free(addr);
grpc_server_start(server1);
/* request a call to the server */
- grpc_call *server_call1;
+ grpc_call* server_call1;
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(server1, &server_call1, &request_details1,
&request_metadata1, cq, cq, tag(0x301)));
@@ -241,7 +243,7 @@ int main(int argc, char **argv) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(server_call1, ops,
(size_t)(op - ops),
- tag(0x302), NULL));
+ tag(0x302), nullptr));
/* shutdown first server:
* we should see a connectivity change and then nothing */
@@ -252,21 +254,21 @@ int main(int argc, char **argv) {
cq_verify_empty(cqv);
/* and a new call: should go through to server2 when we start it */
- grpc_call *call2 =
- grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_call* call2 =
+ grpc_channel_create_call(chan, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), &host,
- grpc_timeout_seconds_to_deadline(20), NULL);
+ grpc_timeout_seconds_to_deadline(20), nullptr);
/* send initial metadata to probe connectivity */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = NULL;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call2, ops,
(size_t)(op - ops),
- tag(0x201), NULL));
+ tag(0x201), nullptr));
/* and receive status to probe termination */
memset(ops, 0, sizeof(ops));
op = ops;
@@ -275,23 +277,23 @@ int main(int argc, char **argv) {
op->data.recv_status_on_client.status = &status2;
op->data.recv_status_on_client.status_details = &details2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call2, ops,
(size_t)(op - ops),
- tag(0x202), NULL));
+ tag(0x202), nullptr));
/* and bring up second server */
set_resolve_port(port2);
- grpc_server *server2 = grpc_server_create(NULL, NULL);
+ grpc_server* server2 = grpc_server_create(nullptr, nullptr);
gpr_asprintf(&addr, "127.0.0.1:%d", port2);
grpc_server_add_insecure_http2_port(server2, addr);
- grpc_server_register_completion_queue(server2, cq, NULL);
+ grpc_server_register_completion_queue(server2, cq, nullptr);
gpr_free(addr);
grpc_server_start(server2);
/* request a call to the server */
- grpc_call *server_call2;
+ grpc_call* server_call2;
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(server2, &server_call2, &request_details2,
&request_metadata2, cq, cq, tag(0x401)));
@@ -310,14 +312,14 @@ int main(int argc, char **argv) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(server_call2, ops,
(size_t)(op - ops),
- tag(0x402), NULL));
+ tag(0x402), nullptr));
/* shutdown second server: we should see nothing */
grpc_server_shutdown_and_notify(server2, cq, tag(0xdead2));
cq_verify_empty(cqv);
- grpc_call_cancel(call1, NULL);
- grpc_call_cancel(call2, NULL);
+ grpc_call_cancel(call1, nullptr);
+ grpc_call_cancel(call2, nullptr);
/* now everything else should finish */
CQ_EXPECT_COMPLETION(cqv, tag(0x102), 1);
diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/h2_ssl_cert_test.cc
index 9b1ddadfe4..9adb96e926 100644
--- a/test/core/end2end/fixtures/h2_ssl_cert.c
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -26,80 +26,87 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-extern void simple_request(grpc_end2end_test_config config);
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace testing {
typedef struct fullstack_secure_fixture_data {
- char *localaddr;
+ char* localaddr;
} fullstack_secure_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
- grpc_channel_args *client_args, grpc_channel_args *server_args) {
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
- fullstack_secure_fixture_data *ffd =
- gpr_malloc(sizeof(fullstack_secure_fixture_data));
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(NULL);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
-static void process_auth_failure(void *state, grpc_auth_context *ctx,
- const grpc_metadata *md, size_t md_count,
+static void process_auth_failure(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
- void *user_data) {
- GPR_ASSERT(state == NULL);
- cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
+ void* user_data) {
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
- grpc_channel_credentials *creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* client_args,
+ grpc_channel_credentials* creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
f->client =
- grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
- GPR_ASSERT(f->client != NULL);
+ grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr);
+ GPR_ASSERT(f->client != nullptr);
grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
- grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
- grpc_server_credentials *server_creds) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+ grpc_end2end_test_fixture* f, grpc_channel_args* server_args,
+ grpc_server_credentials* server_creds) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
- f->server = grpc_server_create(server_args, NULL);
- grpc_server_register_completion_queue(f->server, f->cq, NULL);
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
-void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
- fullstack_secure_fixture_data *ffd = f->fixture_data;
+void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_secure_fixture_data* ffd =
+ static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
-static int fail_server_auth_check(grpc_channel_args *server_args) {
+static int fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
- if (server_args == NULL) return 0;
+ if (server_args == nullptr) return 0;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {
@@ -117,7 +124,7 @@ static int fail_server_auth_check(grpc_channel_args *server_args) {
grpc_end2end_test_fixture * f, grpc_channel_args * server_args) { \
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, \
test_server1_cert}; \
- grpc_server_credentials *ssl_creds = \
+ grpc_server_credentials* ssl_creds = \
grpc_ssl_server_credentials_create_ex( \
test_root_cert, &pem_cert_key_pair, 1, REQUEST_TYPE, NULL); \
if (fail_server_auth_check(server_args)) { \
@@ -143,14 +150,14 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
#define CLIENT_INIT(cert_type) \
static void CLIENT_INIT_NAME(cert_type)(grpc_end2end_test_fixture * f, \
grpc_channel_args * client_args) { \
- grpc_channel_credentials *ssl_creds = NULL; \
+ grpc_channel_credentials* ssl_creds = NULL; \
grpc_ssl_pem_key_cert_pair self_signed_client_key_cert_pair = { \
test_self_signed_client_key, test_self_signed_client_cert}; \
grpc_ssl_pem_key_cert_pair signed_client_key_cert_pair = { \
test_signed_client_key, test_signed_client_cert}; \
grpc_ssl_pem_key_cert_pair bad_client_key_cert_pair = { \
test_self_signed_client_key, test_signed_client_cert}; \
- grpc_ssl_pem_key_cert_pair *key_cert_pair = NULL; \
+ grpc_ssl_pem_key_cert_pair* key_cert_pair = NULL; \
switch (cert_type) { \
case SELF_SIGNED: \
key_cert_pair = &self_signed_client_key_cert_pair; \
@@ -166,16 +173,16 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
} \
ssl_creds = \
grpc_ssl_credentials_create(test_root_cert, key_cert_pair, NULL); \
- grpc_arg ssl_name_override = {GRPC_ARG_STRING, \
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, \
- {"foo.test.google.fr"}}; \
- grpc_channel_args *new_client_args = \
+ grpc_arg ssl_name_override = { \
+ GRPC_ARG_STRING, \
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), \
+ {const_cast<char*>("foo.test.google.fr")}}; \
+ grpc_channel_args* new_client_args = \
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \
{ \
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; \
- grpc_channel_args_destroy(&exec_ctx, new_client_args); \
- grpc_exec_ctx_finish(&exec_ctx); \
+ grpc_core::ExecCtx exec_ctx; \
+ grpc_channel_args_destroy(new_client_args); \
} \
}
@@ -189,15 +196,17 @@ CLIENT_INIT(BAD_CERT_PAIR)
typedef enum { SUCCESS, FAIL } test_result;
-#define SSL_TEST(request_type, cert_type, result) \
- { \
- {TEST_NAME(request_type, cert_type, result), \
- FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \
- FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \
- chttp2_create_fixture_secure_fullstack, CLIENT_INIT_NAME(cert_type), \
- SERVER_INIT_NAME(request_type), chttp2_tear_down_secure_fullstack}, \
- result \
+#define SSL_TEST(request_type, cert_type, result) \
+ { \
+ {TEST_NAME(request_type, cert_type, result), \
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \
+ FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \
+ chttp2_create_fixture_secure_fullstack, \
+ CLIENT_INIT_NAME(cert_type), \
+ SERVER_INIT_NAME(request_type), \
+ chttp2_tear_down_secure_fullstack}, \
+ result \
}
/* All test configurations */
@@ -246,19 +255,7 @@ static grpc_end2end_test_config_wrapper configs[] = {
BAD_CERT_PAIR, FAIL),
};
-static void *tag(intptr_t t) { return (void *)t; }
-
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
- grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_server(&f, server_args);
- config.init_client(&f, client_args);
- return f;
-}
+static void* tag(intptr_t t) { return (void*)t; }
static gpr_timespec n_seconds_time(int n) {
return grpc_timeout_seconds_to_deadline(n);
@@ -266,33 +263,47 @@ static gpr_timespec n_seconds_time(int n) {
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_time(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
+ /* Perform a completion queue next, so that any pending operations can be
+ * finished, and resources can be released. This is so that, shutdown does not
+ * hang. For example, the server might be stuck in the handshaking code, which
+ * keeps a ref to a listener. Unless, it is unref'd, shutdown won't be able
+ * to proceed.
+ *
+ * (If shutdown times out, it is probably because 100ms wasn't enough. In that
+ * case, the deadline can be increased. Or, we could simply have another
+ * thread for the server to poll the completion queue while the shutdown
+ * progresses.)
+ */
+ GPR_ASSERT(grpc_completion_queue_next(
+ f->cq, grpc_timeout_milliseconds_to_deadline(100), nullptr)
+ .type == GRPC_QUEUE_TIMEOUT);
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_client(f);
+ shutdown_server(f);
grpc_completion_queue_shutdown(f->cq);
drain_cq(f->cq);
@@ -302,27 +313,27 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_fixture f,
test_result expected_result) {
- grpc_call *c;
+ grpc_call* c;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_call_error error;
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234");
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"), &host,
- deadline, NULL);
+ deadline, nullptr);
GPR_ASSERT(c);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = NULL;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), expected_result == SUCCESS);
@@ -332,40 +343,57 @@ static void simple_request_body(grpc_end2end_test_fixture f,
cq_verifier_destroy(cqv);
}
-int main(int argc, char **argv) {
- size_t i;
- FILE *roots_file;
+class H2SslCertTest
+ : public ::testing::TestWithParam<grpc_end2end_test_config_wrapper> {
+ protected:
+ H2SslCertTest() {
+ gpr_log(GPR_INFO, "SSL_CERT_tests/%s", GetParam().config.name);
+ }
+ void SetUp() override {
+ fixture_ = GetParam().config.create_fixture(nullptr, nullptr);
+ GetParam().config.init_server(&fixture_, nullptr);
+ GetParam().config.init_client(&fixture_, nullptr);
+ }
+ void TearDown() override {
+ end_test(&fixture_);
+ GetParam().config.tear_down_data(&fixture_);
+ }
+
+ grpc_end2end_test_fixture fixture_;
+};
+
+TEST_P(H2SslCertTest, SimpleRequestBody) {
+ simple_request_body(fixture_, GetParam().result);
+}
+
+INSTANTIATE_TEST_CASE_P(H2SslCert, H2SslCertTest, ::testing::ValuesIn(configs));
+
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ FILE* roots_file;
size_t roots_size = strlen(test_root_cert);
- char *roots_filename;
+ char* roots_filename;
grpc_test_init(argc, argv);
- grpc_end2end_tests_pre_init();
-
/* Set the SSL roots env var. */
roots_file =
gpr_tmpfile("chttp2_simple_ssl_cert_fullstack_test", &roots_filename);
- GPR_ASSERT(roots_filename != NULL);
- GPR_ASSERT(roots_file != NULL);
+ GPR_ASSERT(roots_filename != nullptr);
+ GPR_ASSERT(roots_file != nullptr);
GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size);
fclose(roots_file);
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename);
grpc_init();
-
- for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
- grpc_end2end_test_fixture f =
- begin_test(configs[i].config, "SSL_CERT_tests", NULL, NULL);
-
- simple_request_body(f, configs[i].result);
- end_test(&f);
- configs[i].config.tear_down_data(&f);
- }
-
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
grpc_shutdown();
/* Cleanup. */
remove(roots_filename);
gpr_free(roots_filename);
- return 0;
+ return ret;
}
diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.cc
index bf0d08adec..cb6b4c08ef 100644
--- a/test/core/end2end/invalid_call_argument_test.c
+++ b/test/core/end2end/invalid_call_argument_test.cc
@@ -30,22 +30,22 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static void *tag(intptr_t i) { return (void *)i; }
+static void* tag(intptr_t i) { return (void*)i; }
struct test_state {
int is_client;
- grpc_channel *chan;
- grpc_call *call;
+ grpc_channel* chan;
+ grpc_call* call;
gpr_timespec deadline;
- grpc_completion_queue *cq;
- cq_verifier *cqv;
+ grpc_completion_queue* cq;
+ cq_verifier* cqv;
grpc_op ops[6];
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_slice details;
- grpc_call *server_call;
- grpc_server *server;
+ grpc_call* server_call;
+ grpc_server* server;
grpc_metadata_array server_initial_metadata_recv;
grpc_call_details call_details;
};
@@ -54,13 +54,13 @@ static struct test_state g_state;
static void prepare_test(int is_client) {
int port = grpc_pick_unused_port_or_die();
- char *server_hostport;
- grpc_op *op;
+ char* server_hostport;
+ grpc_op* op;
g_state.is_client = is_client;
grpc_metadata_array_init(&g_state.initial_metadata_recv);
grpc_metadata_array_init(&g_state.trailing_metadata_recv);
g_state.deadline = grpc_timeout_seconds_to_deadline(5);
- g_state.cq = grpc_completion_queue_create_for_next(NULL);
+ g_state.cq = grpc_completion_queue_create_for_next(nullptr);
g_state.cqv = cq_verifier_create(g_state.cq);
g_state.details = grpc_empty_slice();
memset(g_state.ops, 0, sizeof(g_state.ops));
@@ -68,36 +68,39 @@ static void prepare_test(int is_client) {
if (is_client) {
/* create a call, channel to a non existant server */
g_state.chan =
- grpc_insecure_channel_create("nonexistant:54321", NULL, NULL);
+ grpc_insecure_channel_create("nonexistant:54321", nullptr, nullptr);
grpc_slice host = grpc_slice_from_static_string("nonexistant");
g_state.call = grpc_channel_create_call(
- g_state.chan, NULL, GRPC_PROPAGATE_DEFAULTS, g_state.cq,
- grpc_slice_from_static_string("/Foo"), &host, g_state.deadline, NULL);
+ g_state.chan, nullptr, GRPC_PROPAGATE_DEFAULTS, g_state.cq,
+ grpc_slice_from_static_string("/Foo"), &host, g_state.deadline,
+ nullptr);
} else {
- g_state.server = grpc_server_create(NULL, NULL);
- grpc_server_register_completion_queue(g_state.server, g_state.cq, NULL);
+ g_state.server = grpc_server_create(nullptr, nullptr);
+ grpc_server_register_completion_queue(g_state.server, g_state.cq, nullptr);
gpr_join_host_port(&server_hostport, "0.0.0.0", port);
grpc_server_add_insecure_http2_port(g_state.server, server_hostport);
grpc_server_start(g_state.server);
gpr_free(server_hostport);
gpr_join_host_port(&server_hostport, "localhost", port);
- g_state.chan = grpc_insecure_channel_create(server_hostport, NULL, NULL);
+ g_state.chan =
+ grpc_insecure_channel_create(server_hostport, nullptr, nullptr);
gpr_free(server_hostport);
grpc_slice host = grpc_slice_from_static_string("bar");
g_state.call = grpc_channel_create_call(
- g_state.chan, NULL, GRPC_PROPAGATE_DEFAULTS, g_state.cq,
- grpc_slice_from_static_string("/Foo"), &host, g_state.deadline, NULL);
+ g_state.chan, nullptr, GRPC_PROPAGATE_DEFAULTS, g_state.cq,
+ grpc_slice_from_static_string("/Foo"), &host, g_state.deadline,
+ nullptr);
grpc_metadata_array_init(&g_state.server_initial_metadata_recv);
grpc_call_details_init(&g_state.call_details);
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->flags = 0;
- op->reserved = NULL;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops,
(size_t)(op - g_state.ops),
- tag(1), NULL));
+ tag(1), nullptr));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(g_state.server, &g_state.server_call,
&g_state.call_details,
@@ -110,7 +113,7 @@ static void prepare_test(int is_client) {
}
static void cleanup_test() {
- grpc_completion_queue *shutdown_cq;
+ grpc_completion_queue* shutdown_cq;
grpc_call_unref(g_state.call);
cq_verifier_destroy(g_state.cqv);
grpc_channel_destroy(g_state.chan);
@@ -119,12 +122,12 @@ static void cleanup_test() {
grpc_metadata_array_destroy(&g_state.trailing_metadata_recv);
if (!g_state.is_client) {
- shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_call_unref(g_state.server_call);
grpc_server_shutdown_and_notify(g_state.server, shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_server_destroy(g_state.server);
@@ -133,7 +136,7 @@ static void cleanup_test() {
}
grpc_completion_queue_shutdown(g_state.cq);
while (grpc_completion_queue_next(g_state.cq,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr)
.type != GRPC_QUEUE_SHUTDOWN)
;
grpc_completion_queue_destroy(g_state.cq);
@@ -144,14 +147,14 @@ static void test_non_null_reserved_on_start_batch() {
prepare_test(1);
GPR_ASSERT(GRPC_CALL_ERROR ==
- grpc_call_start_batch(g_state.call, NULL, 0, NULL, tag(1)));
+ grpc_call_start_batch(g_state.call, nullptr, 0, nullptr, tag(1)));
cleanup_test();
}
static void test_non_null_reserved_on_op() {
gpr_log(GPR_INFO, "test_non_null_reserved_on_op");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
@@ -162,25 +165,26 @@ static void test_non_null_reserved_on_op() {
op++;
GPR_ASSERT(GRPC_CALL_ERROR ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_send_initial_metadata_more_than_once() {
gpr_log(GPR_INFO, "test_send_initial_metadata_more_than_once");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops,
(size_t)(op - g_state.ops),
- tag(1), NULL));
+ tag(1), nullptr));
CQ_EXPECT_COMPLETION(g_state.cqv, tag(1), 0);
cq_verify(g_state.cqv);
@@ -188,83 +192,87 @@ static void test_send_initial_metadata_more_than_once() {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_too_many_metadata() {
gpr_log(GPR_INFO, "test_too_many_metadata");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = (size_t)INT_MAX + 1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_METADATA ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_send_null_message() {
gpr_log(GPR_INFO, "test_send_null_message");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
- op->data.send_message.send_message = NULL;
+ op->data.send_message.send_message = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_MESSAGE ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_send_messages_at_the_same_time() {
gpr_log(GPR_INFO, "test_send_messages_at_the_same_time");
- grpc_op *op;
+ grpc_op* op;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
- op->data.send_message.send_message = tag(2);
+ op->data.send_message.send_message = static_cast<grpc_byte_buffer*>(tag(2));
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
grpc_byte_buffer_destroy(request_payload);
cleanup_test();
}
@@ -272,7 +280,7 @@ static void test_send_messages_at_the_same_time() {
static void test_send_server_status_from_client() {
gpr_log(GPR_INFO, "test_send_server_status_from_client");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
@@ -282,29 +290,30 @@ static void test_send_server_status_from_client() {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_CLIENT ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_receive_initial_metadata_twice_at_client() {
gpr_log(GPR_INFO, "test_receive_initial_metadata_twice_at_client");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&g_state.initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops,
(size_t)(op - g_state.ops),
- tag(1), NULL));
+ tag(1), nullptr));
CQ_EXPECT_COMPLETION(g_state.cqv, tag(1), 0);
cq_verify(g_state.cqv);
op = g_state.ops;
@@ -312,77 +321,81 @@ static void test_receive_initial_metadata_twice_at_client() {
op->data.recv_initial_metadata.recv_initial_metadata =
&g_state.initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_receive_message_with_invalid_flags() {
gpr_log(GPR_INFO, "test_receive_message_with_invalid_flags");
- grpc_op *op;
- grpc_byte_buffer *payload = NULL;
+ grpc_op* op;
+ grpc_byte_buffer* payload = nullptr;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &payload;
op->flags = 1;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_receive_two_messages_at_the_same_time() {
gpr_log(GPR_INFO, "test_receive_two_messages_at_the_same_time");
- grpc_op *op;
- grpc_byte_buffer *payload = NULL;
+ grpc_op* op;
+ grpc_byte_buffer* payload = nullptr;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_recv_close_on_server_from_client() {
gpr_log(GPR_INFO, "test_recv_close_on_server_from_client");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
- op->data.recv_close_on_server.cancelled = NULL;
+ op->data.recv_close_on_server.cancelled = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_CLIENT ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_recv_status_on_client_twice() {
gpr_log(GPR_INFO, "test_recv_status_on_client_twice");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
@@ -392,49 +405,51 @@ static void test_recv_status_on_client_twice() {
op->data.recv_status_on_client.status = &g_state.status;
op->data.recv_status_on_client.status_details = &g_state.details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops,
(size_t)(op - g_state.ops),
- tag(1), NULL));
+ tag(1), nullptr));
CQ_EXPECT_COMPLETION(g_state.cqv, tag(1), 1);
cq_verify(g_state.cqv);
op = g_state.ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
- op->data.recv_status_on_client.trailing_metadata = NULL;
- op->data.recv_status_on_client.status = NULL;
- op->data.recv_status_on_client.status_details = NULL;
+ op->data.recv_status_on_client.trailing_metadata = nullptr;
+ op->data.recv_status_on_client.status = nullptr;
+ op->data.recv_status_on_client.status_details = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
static void test_send_close_from_client_on_server() {
gpr_log(GPR_INFO, "test_send_close_from_client_on_server");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_SERVER ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
static void test_recv_status_on_client_from_server() {
gpr_log(GPR_INFO, "test_recv_status_on_client_from_server");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
@@ -444,18 +459,19 @@ static void test_recv_status_on_client_from_server() {
op->data.recv_status_on_client.status = &g_state.status;
op->data.recv_status_on_client.status_details = &g_state.details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_SERVER ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
static void test_send_status_from_server_with_invalid_flags() {
gpr_log(GPR_INFO, "test_send_status_from_server_with_invalid_flags");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
@@ -465,18 +481,19 @@ static void test_send_status_from_server_with_invalid_flags() {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 1;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
static void test_too_many_trailing_metadata() {
gpr_log(GPR_INFO, "test_too_many_trailing_metadata");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
@@ -487,18 +504,19 @@ static void test_too_many_trailing_metadata() {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_METADATA ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
static void test_send_server_status_twice() {
gpr_log(GPR_INFO, "test_send_server_status_twice");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
@@ -508,59 +526,62 @@ static void test_send_server_status_twice() {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
static void test_recv_close_on_server_with_invalid_flags() {
gpr_log(GPR_INFO, "test_recv_close_on_server_with_invalid_flags");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
- op->data.recv_close_on_server.cancelled = NULL;
+ op->data.recv_close_on_server.cancelled = nullptr;
op->flags = 1;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
static void test_recv_close_on_server_twice() {
gpr_log(GPR_INFO, "test_recv_close_on_server_twice");
- grpc_op *op;
+ grpc_op* op;
prepare_test(0);
op = g_state.ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
- op->data.recv_close_on_server.cancelled = NULL;
+ op->data.recv_close_on_server.cancelled = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
- op->data.recv_close_on_server.cancelled = NULL;
+ op->data.recv_close_on_server.cancelled = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS ==
grpc_call_start_batch(g_state.server_call, g_state.ops,
- (size_t)(op - g_state.ops), tag(2), NULL));
+ (size_t)(op - g_state.ops), tag(2),
+ nullptr));
cleanup_test();
}
@@ -571,22 +592,23 @@ static void test_invalid_initial_metadata_reserved_key() {
metadata.key = grpc_slice_from_static_string(":start_with_colon");
metadata.value = grpc_slice_from_static_string("value");
- grpc_op *op;
+ grpc_op* op;
prepare_test(1);
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = &metadata;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_ERROR_INVALID_METADATA ==
grpc_call_start_batch(g_state.call, g_state.ops,
- (size_t)(op - g_state.ops), tag(1), NULL));
+ (size_t)(op - g_state.ops), tag(1),
+ nullptr));
cleanup_test();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_invalid_initial_metadata_reserved_key();
diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.cc
index f231c62dd0..dfa3b48b52 100644
--- a/test/core/end2end/multiple_server_queues_test.c
+++ b/test/core/end2end/multiple_server_queues_test.cc
@@ -19,13 +19,13 @@
#include <grpc/grpc.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
- grpc_completion_queue *cq1;
- grpc_completion_queue *cq2;
- grpc_completion_queue *cq3;
+int main(int argc, char** argv) {
+ grpc_completion_queue* cq1;
+ grpc_completion_queue* cq2;
+ grpc_completion_queue* cq3;
grpc_completion_queue_attributes attr;
- grpc_server *server;
+ grpc_server* server;
grpc_test_init(argc, argv);
grpc_init();
@@ -34,33 +34,33 @@ int main(int argc, char **argv) {
attr.cq_completion_type = GRPC_CQ_NEXT;
attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING;
cq1 = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
attr.cq_polling_type = GRPC_CQ_NON_LISTENING;
cq2 = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
attr.cq_polling_type = GRPC_CQ_NON_POLLING;
cq3 = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
- server = grpc_server_create(NULL, NULL);
- grpc_server_register_completion_queue(server, cq1, NULL);
+ server = grpc_server_create(nullptr, nullptr);
+ grpc_server_register_completion_queue(server, cq1, nullptr);
grpc_server_add_insecure_http2_port(server, "[::]:0");
- grpc_server_register_completion_queue(server, cq2, NULL);
- grpc_server_register_completion_queue(server, cq3, NULL);
+ grpc_server_register_completion_queue(server, cq2, nullptr);
+ grpc_server_register_completion_queue(server, cq3, nullptr);
grpc_server_start(server);
- grpc_server_shutdown_and_notify(server, cq2, NULL);
+ grpc_server_shutdown_and_notify(server, cq2, nullptr);
grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL); /* cue queue hang */
+ nullptr); /* cue queue hang */
grpc_completion_queue_shutdown(cq1);
grpc_completion_queue_shutdown(cq2);
grpc_completion_queue_shutdown(cq3);
- grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- grpc_completion_queue_next(cq3, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
+ grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
+ grpc_completion_queue_next(cq3, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_server_destroy(server);
grpc_completion_queue_destroy(cq1);
diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.cc
index 962499bb4f..6113885171 100644
--- a/test/core/end2end/no_server_test.c
+++ b/test/core/end2end/no_server_test.cc
@@ -25,16 +25,16 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/test_config.h"
-static void *tag(intptr_t i) { return (void *)i; }
+static void* tag(intptr_t i) { return (void*)i; }
-int main(int argc, char **argv) {
- grpc_channel *chan;
- grpc_call *call;
+int main(int argc, char** argv) {
+ grpc_channel* chan;
+ grpc_call* call;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2);
- grpc_completion_queue *cq;
- cq_verifier *cqv;
+ grpc_completion_queue* cq;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_slice details;
@@ -44,32 +44,33 @@ int main(int argc, char **argv) {
grpc_metadata_array_init(&trailing_metadata_recv);
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
cqv = cq_verifier_create(cq);
/* create a call, channel to a non existant server */
- chan = grpc_insecure_channel_create("nonexistant:54321", NULL, NULL);
+ chan = grpc_insecure_channel_create("nonexistant:54321", nullptr, nullptr);
grpc_slice host = grpc_slice_from_static_string("nonexistant");
- call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ call = grpc_channel_create_call(chan, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/Foo"), &host,
- deadline, NULL);
+ deadline, nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
- call, ops, (size_t)(op - ops), tag(1), NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops), tag(1),
+ nullptr));
/* verify that all tags get completed */
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
@@ -77,9 +78,9 @@ int main(int argc, char **argv) {
GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED);
grpc_completion_queue_shutdown(cq);
- while (
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type != GRPC_QUEUE_SHUTDOWN)
+ while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type != GRPC_QUEUE_SHUTDOWN)
;
grpc_completion_queue_destroy(cq);
grpc_call_unref(call);
diff --git a/test/core/end2end/tests/authority_not_supported.c b/test/core/end2end/tests/authority_not_supported.cc
index b54d6d0d6f..9c8545058c 100644
--- a/test/core/end2end/tests/authority_not_supported.c
+++ b/test/core/end2end/tests/authority_not_supported.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,36 +86,36 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Request/response with metadata and payload.*/
static void test_with_authority_header(grpc_end2end_test_config config) {
- grpc_call *c;
+ grpc_call* c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"),
grpc_slice_from_static_string("val1"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key2"),
grpc_slice_from_static_string("val2"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_end2end_test_fixture f =
- begin_test(config, "test_with_authority_header", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_with_authority_header", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr");
gpr_timespec deadline = five_seconds_from_now();
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"), &host,
- deadline, NULL);
+ deadline, nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -127,35 +127,35 @@ static void test_with_authority_header(grpc_end2end_test_config config) {
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_c;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.cc
index 32093f2ecf..85e9ba1307 100644
--- a/test/core/end2end/tests/bad_hostname.c
+++ b/test/core/end2end/tests/bad_hostname.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -87,10 +87,10 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void simple_request_body(grpc_end2end_test_fixture f) {
- grpc_call *c;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -101,9 +101,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_slice host = grpc_slice_from_static_string("slartibartfast.local");
gpr_timespec deadline = five_seconds_from_now();
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"), &host,
- deadline, NULL);
+ deadline, nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -116,25 +116,25 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -156,7 +156,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
simple_request_body(f);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/bad_ping.c b/test/core/end2end/tests/bad_ping.cc
index c97d11b306..30a1b8de77 100644
--- a/test/core/end2end/tests/bad_ping.c
+++ b/test/core/end2end/tests/bad_ping.cc
@@ -31,29 +31,29 @@
#define MAX_PING_STRIKES 1
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5),
- NULL);
+ nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -64,41 +64,41 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void test_bad_ping(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
- grpc_arg client_a[] = {
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS,
- .value.integer = 10},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA,
- .value.integer = 0},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_BDP_PROBE,
- .value.integer = 0}};
- grpc_arg server_a[] = {
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS,
- .value.integer = 300000 /* 5 minutes */},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MAX_PING_STRIKES,
- .value.integer = MAX_PING_STRIKES},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_BDP_PROBE,
- .value.integer = 0}};
- grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(client_a),
- .args = client_a};
- grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
- .args = server_a};
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_arg client_a[3];
+ client_a[0].type = GRPC_ARG_INTEGER;
+ client_a[0].key =
+ const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS);
+ client_a[0].value.integer = 10;
+ client_a[1].type = GRPC_ARG_INTEGER;
+ client_a[1].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA);
+ client_a[1].value.integer = 0;
+ client_a[2].type = GRPC_ARG_INTEGER;
+ client_a[2].key = const_cast<char*>(GRPC_ARG_HTTP2_BDP_PROBE);
+ client_a[2].value.integer = 0;
+ grpc_arg server_a[3];
+ server_a[0].type = GRPC_ARG_INTEGER;
+ server_a[0].key =
+ const_cast<char*>(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS);
+ server_a[0].value.integer = 300000 /* 5 minutes */;
+ server_a[1].type = GRPC_ARG_INTEGER;
+ server_a[1].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_PING_STRIKES);
+ server_a[1].value.integer = MAX_PING_STRIKES;
+ server_a[2].type = GRPC_ARG_INTEGER;
+ server_a[2].key = const_cast<char*>(GRPC_ARG_HTTP2_BDP_PROBE);
+ server_a[2].value.integer = 0;
+ grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
config.init_client(&f, &client_args);
config.init_server(&f, &server_args);
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -109,10 +109,10 @@ static void test_bad_ping(grpc_end2end_test_config config) {
int was_cancelled = 2;
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -124,27 +124,27 @@ static void test_bad_ping(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -155,14 +155,16 @@ static void test_bad_ping(grpc_end2end_test_config config) {
cq_verify(cqv);
// Send too many pings to the server to trigger the punishment:
- // The first ping is sent after data frames, it won't trigger a ping strike.
- // Each of the following pings will trigger a ping strike, and we need at
- // least (MAX_PING_STRIKES + 1) strikes to trigger the punishment. So
- // (MAX_PING_STRIKES + 2) pings are needed here.
+ // Each ping will trigger a ping strike, and we need at least MAX_PING_STRIKES
+ // strikes to trigger the punishment. So (MAX_PING_STRIKES + 1) pings are
+ // needed here.
int i;
- for (i = 200; i < 202 + MAX_PING_STRIKES; i++) {
- grpc_channel_ping(f.client, f.cq, tag(i), NULL);
- CQ_EXPECT_COMPLETION(cqv, tag(i), 1);
+ for (i = 1; i <= MAX_PING_STRIKES + 1; i++) {
+ grpc_channel_ping(f.client, f.cq, tag(200 + i), nullptr);
+ CQ_EXPECT_COMPLETION(cqv, tag(200 + i), 1);
+ if (i == MAX_PING_STRIKES + 1) {
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ }
cq_verify(cqv);
}
@@ -171,7 +173,7 @@ static void test_bad_ping(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -179,18 +181,17 @@ static void test_bad_ping(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
- CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
@@ -202,7 +203,6 @@ static void test_bad_ping(grpc_end2end_test_config config) {
// The connection should be closed immediately after the misbehaved pings,
// the in-progress RPC should fail.
GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
- GPR_ASSERT(0 == grpc_slice_str_cmp(details, "Endpoint read failed"));
GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
validate_host_override_string("foo.test.google.fr:1234", call_details.host,
config);
diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.cc
index e949daee1d..381671e331 100644
--- a/test/core/end2end/tests/binary_metadata.c
+++ b/test/core/end2end/tests/binary_metadata.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -87,48 +87,49 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Request/response with metadata and payload.*/
static void test_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
grpc_metadata meta_c[2] = {
{grpc_slice_from_static_string("key1-bin"),
grpc_slice_from_static_string(
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key2-bin"),
grpc_slice_from_static_string(
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_metadata meta_s[2] = {
{grpc_slice_from_static_string("key3-bin"),
grpc_slice_from_static_string(
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key4-bin"),
grpc_slice_from_static_string(
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"),
0,
- {{NULL, NULL, NULL, NULL}}}};
- grpc_end2end_test_fixture f = begin_test(
- config, "test_request_response_with_metadata_and_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ {{nullptr, nullptr, nullptr, nullptr}}}};
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_request_response_with_metadata_and_payload",
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -137,10 +138,10 @@ static void test_request_response_with_metadata_and_payload(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -154,35 +155,35 @@ static void test_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_c;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -198,14 +199,14 @@ static void test_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_s;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -216,12 +217,12 @@ static void test_request_response_with_metadata_and_payload(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -244,9 +245,9 @@ static void test_request_response_with_metadata_and_payload(
"\xfd\xfe\xff");
op->data.send_status_from_server.status_details = &status_string;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.cc
index 600005c9a9..c5ea101c53 100644
--- a/test/core/end2end/tests/call_creds.c
+++ b/test/core/end2end/tests/call_creds.cc
@@ -27,8 +27,8 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
static const char iam_token[] = "token";
@@ -38,24 +38,26 @@ static const char overridden_iam_selector[] = "overridden_selector";
typedef enum { NONE, OVERRIDE, DESTROY } override_mode;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
int fail_server_auth_check) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
- f = config.create_fixture(NULL, NULL);
- config.init_client(&f, NULL);
+ f = config.create_fixture(nullptr, nullptr);
+ config.init_client(&f, nullptr);
if (fail_server_auth_check) {
grpc_arg fail_auth_arg = {
- GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL}};
+ GRPC_ARG_STRING,
+ const_cast<char*>(FAIL_AUTH_CHECK_SERVER_ARG_NAME),
+ {nullptr}};
grpc_channel_args args;
args.num_args = 1;
args.args = &fail_auth_arg;
config.init_server(&f, &args);
} else {
- config.init_server(&f, NULL);
+ config.init_server(&f, nullptr);
}
return f;
}
@@ -68,31 +70,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -102,79 +104,79 @@ static void end_test(grpc_end2end_test_fixture *f) {
grpc_completion_queue_destroy(f->shutdown_cq);
}
-static void print_auth_context(int is_client, const grpc_auth_context *ctx) {
- const grpc_auth_property *p;
+static void print_auth_context(int is_client, const grpc_auth_context* ctx) {
+ const grpc_auth_property* p;
grpc_auth_property_iterator it;
gpr_log(GPR_INFO, "%s peer:", is_client ? "client" : "server");
gpr_log(GPR_INFO, "\tauthenticated: %s",
grpc_auth_context_peer_is_authenticated(ctx) ? "YES" : "NO");
it = grpc_auth_context_peer_identity(ctx);
- while ((p = grpc_auth_property_iterator_next(&it)) != NULL) {
+ while ((p = grpc_auth_property_iterator_next(&it)) != nullptr) {
gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value);
}
gpr_log(GPR_INFO, "\tall properties:");
it = grpc_auth_context_property_iterator(ctx);
- while ((p = grpc_auth_property_iterator_next(&it)) != NULL) {
+ while ((p = grpc_auth_property_iterator_next(&it)) != nullptr) {
gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value);
}
}
static void request_response_with_payload_and_call_creds(
- const char *test_name, grpc_end2end_test_config config,
+ const char* test_name, grpc_end2end_test_config config,
override_mode mode) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
grpc_end2end_test_fixture f;
- cq_verifier *cqv;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- grpc_call_credentials *creds = NULL;
- grpc_auth_context *s_auth_context = NULL;
- grpc_auth_context *c_auth_context = NULL;
+ grpc_call_credentials* creds = nullptr;
+ grpc_auth_context* s_auth_context = nullptr;
+ grpc_auth_context* c_auth_context = nullptr;
f = begin_test(config, test_name, 0);
cqv = cq_verifier_create(f.cq);
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
- creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL);
- GPR_ASSERT(creds != NULL);
+ creds = grpc_google_iam_credentials_create(iam_token, iam_selector, nullptr);
+ GPR_ASSERT(creds != nullptr);
GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
switch (mode) {
case NONE:
break;
case OVERRIDE:
grpc_call_credentials_release(creds);
- creds = grpc_google_iam_credentials_create(overridden_iam_token,
- overridden_iam_selector, NULL);
- GPR_ASSERT(creds != NULL);
+ creds = grpc_google_iam_credentials_create(
+ overridden_iam_token, overridden_iam_selector, nullptr);
+ GPR_ASSERT(creds != nullptr);
GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
break;
case DESTROY:
- GPR_ASSERT(grpc_call_set_credentials(c, NULL) == GRPC_CALL_OK);
+ GPR_ASSERT(grpc_call_set_credentials(c, nullptr) == GRPC_CALL_OK);
break;
}
grpc_call_credentials_release(creds);
@@ -189,35 +191,35 @@ static void request_response_with_payload_and_call_creds(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -227,31 +229,31 @@ static void request_response_with_payload_and_call_creds(
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
s_auth_context = grpc_call_auth_context(s);
- GPR_ASSERT(s_auth_context != NULL);
+ GPR_ASSERT(s_auth_context != nullptr);
print_auth_context(0, s_auth_context);
grpc_auth_context_release(s_auth_context);
c_auth_context = grpc_call_auth_context(c);
- GPR_ASSERT(c_auth_context != NULL);
+ GPR_ASSERT(c_auth_context != nullptr);
print_auth_context(1, c_auth_context);
grpc_auth_context_release(c_auth_context);
/* Cannot set creds on the server call object. */
- GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK);
+ GPR_ASSERT(grpc_call_set_credentials(s, nullptr) != GRPC_CALL_OK);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -262,12 +264,12 @@ static void request_response_with_payload_and_call_creds(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -275,9 +277,9 @@ static void request_response_with_payload_and_call_creds(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -369,11 +371,11 @@ static void test_request_response_with_payload_and_deleted_call_creds(
static void test_request_with_server_rejecting_client_creds(
grpc_end2end_test_config config) {
grpc_op ops[6];
- grpc_op *op;
- grpc_call *c;
+ grpc_op* op;
+ grpc_call* c;
grpc_end2end_test_fixture f;
gpr_timespec deadline = five_seconds_from_now();
- cq_verifier *cqv;
+ cq_verifier* cqv;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -381,25 +383,25 @@ static void test_request_with_server_rejecting_client_creds(
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_call_credentials *creds;
+ grpc_call_credentials* creds;
f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1);
cqv = cq_verifier_create(f.cq);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
- creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL);
- GPR_ASSERT(creds != NULL);
+ creds = grpc_google_iam_credentials_create(iam_token, iam_selector, nullptr);
+ GPR_ASSERT(creds != nullptr);
GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
grpc_call_credentials_release(creds);
@@ -415,33 +417,33 @@ static void test_request_with_server_rejecting_client_creds(
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(error == GRPC_CALL_OK);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.cc
index c3ac0c3201..f59caf7e35 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -35,14 +35,14 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
cancellation_mode mode,
bool use_service_config,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s/%s/%s", test_name, config.name,
mode.name, use_service_config ? "service_config" : "client_api");
@@ -60,31 +60,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -99,9 +99,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
cancellation_mode mode,
bool use_service_config) {
grpc_op ops[6];
- grpc_op *op;
- grpc_call *c;
- grpc_call *s;
+ grpc_op* op;
+ grpc_call* c;
+ grpc_call* s;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -109,47 +109,48 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
- grpc_channel_args *args = NULL;
+ grpc_channel_args* args = nullptr;
if (use_service_config) {
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
- arg.value.string =
+ arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG);
+ arg.value.string = const_cast<char*>(
"{\n"
" \"methodConfig\": [ {\n"
" \"name\": [\n"
- " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " { \"service\": \"service\", \"method\": \"method\" },\n"
+ " { \"service\": \"unused\" }\n"
" ],\n"
" \"timeout\": \"5s\"\n"
" } ]\n"
- "}";
+ "}");
args = grpc_channel_args_copy_and_add(args, &arg, 1);
}
grpc_end2end_test_fixture f = begin_test(config, "cancel_after_accept", mode,
- use_service_config, args, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ use_service_config, args, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
gpr_timespec deadline = use_service_config
? gpr_inf_future(GPR_CLOCK_MONOTONIC)
: five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/service/method"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -164,29 +165,29 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error = grpc_server_request_call(f.server, &s, &call_details,
@@ -200,27 +201,27 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -243,10 +244,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call_unref(c);
grpc_call_unref(s);
- if (args != NULL) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ if (args != nullptr) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.cc
index 0e2a751d83..9b832d435d 100644
--- a/test/core/end2end/tests/cancel_after_client_done.c
+++ b/test/core/end2end/tests/cancel_after_client_done.cc
@@ -29,13 +29,13 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
cancellation_mode mode,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s/%s", test_name, config.name,
mode.name);
@@ -53,31 +53,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -91,12 +91,13 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_cancel_after_accept_and_writes_closed(
grpc_end2end_test_config config, cancellation_mode mode) {
grpc_op ops[6];
- grpc_op *op;
- grpc_call *c;
- grpc_call *s;
- grpc_end2end_test_fixture f = begin_test(
- config, "test_cancel_after_accept_and_writes_closed", mode, NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_op* op;
+ grpc_call* c;
+ grpc_call* s;
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_cancel_after_accept_and_writes_closed", mode,
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -104,24 +105,24 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -136,33 +137,33 @@ static void test_cancel_after_accept_and_writes_closed(
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error = grpc_server_request_call(f.server, &s, &call_details,
@@ -176,27 +177,27 @@ static void test_cancel_after_accept_and_writes_closed(
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.cc
index aad9fdbf94..d3891b160e 100644
--- a/test/core/end2end/tests/cancel_after_invoke.c
+++ b/test/core/end2end/tests/cancel_after_invoke.cc
@@ -29,14 +29,14 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
cancellation_mode mode,
size_t test_ops,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s/%s [%" PRIdPTR " ops]", test_name,
config.name, mode.name, test_ops);
@@ -54,31 +54,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
grpc_event ev = grpc_completion_queue_next(
- f->cq, grpc_timeout_seconds_to_deadline(5), NULL);
+ f->cq, grpc_timeout_seconds_to_deadline(5), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag(1000));
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -92,11 +92,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_cancel_after_invoke(grpc_end2end_test_config config,
cancellation_mode mode, size_t test_ops) {
grpc_op ops[6];
- grpc_op *op;
- grpc_call *c;
+ grpc_op* op;
+ grpc_call* c;
grpc_end2end_test_fixture f = begin_test(config, "test_cancel_after_invoke",
- mode, test_ops, NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ mode, test_ops, nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -104,18 +104,18 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -130,36 +130,36 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, test_ops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, test_ops, tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
diff --git a/test/core/end2end/tests/cancel_after_round_trip.c b/test/core/end2end/tests/cancel_after_round_trip.cc
index bc41bd3a6d..b10b93978d 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.c
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -35,14 +35,14 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
cancellation_mode mode,
bool use_service_config,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s/%s/%s", test_name, config.name,
mode.name, use_service_config ? "service_config" : "client_api");
@@ -60,31 +60,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -99,9 +99,9 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
cancellation_mode mode,
bool use_service_config) {
grpc_op ops[6];
- grpc_op *op;
- grpc_call *c;
- grpc_call *s;
+ grpc_op* op;
+ grpc_call* c;
+ grpc_call* s;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -109,26 +109,26 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload1 =
+ grpc_byte_buffer* response_payload1 =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- grpc_byte_buffer *response_payload2 =
+ grpc_byte_buffer* response_payload2 =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
- grpc_channel_args *args = NULL;
+ grpc_channel_args* args = nullptr;
if (use_service_config) {
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
- arg.value.string =
+ arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG);
+ arg.value.string = const_cast<char*>(
"{\n"
" \"methodConfig\": [ {\n"
" \"name\": [\n"
@@ -136,22 +136,23 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
" ],\n"
" \"timeout\": \"5s\"\n"
" } ]\n"
- "}";
+ "}");
args = grpc_channel_args_copy_and_add(args, &arg, 1);
}
- grpc_end2end_test_fixture f = begin_test(
- config, "cancel_after_round_trip", mode, use_service_config, args, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f =
+ begin_test(config, "cancel_after_round_trip", mode, use_service_config,
+ args, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
gpr_timespec deadline = use_service_config
? gpr_inf_future(GPR_CLOCK_MONOTONIC)
: five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/service/method"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -164,24 +165,24 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -196,19 +197,19 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -217,8 +218,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
grpc_byte_buffer_destroy(request_payload_recv);
grpc_byte_buffer_destroy(response_payload_recv);
- request_payload_recv = NULL;
- response_payload_recv = NULL;
+ request_payload_recv = nullptr;
+ response_payload_recv = nullptr;
memset(ops, 0, sizeof(ops));
op = ops;
@@ -227,31 +228,31 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -276,10 +277,9 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
grpc_call_unref(c);
grpc_call_unref(s);
- if (args != NULL) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ if (args != nullptr) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(args);
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.cc
index 397e8b8ba6..1112375176 100644
--- a/test/core/end2end/tests/cancel_before_invoke.c
+++ b/test/core/end2end/tests/cancel_before_invoke.cc
@@ -28,13 +28,13 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
size_t num_ops,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s [%" PRIdPTR " ops]", test_name,
config.name, num_ops);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -90,11 +90,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_cancel_before_invoke(grpc_end2end_test_config config,
size_t test_ops) {
grpc_op ops[6];
- grpc_op *op;
- grpc_call *c;
+ grpc_op* op;
+ grpc_call* c;
grpc_end2end_test_fixture f =
- begin_test(config, "cancel_before_invoke", test_ops, NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "cancel_before_invoke", test_ops, nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -102,21 +102,21 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, nullptr));
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -130,33 +130,33 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, test_ops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, test_ops, tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.cc
index cd9551bef9..a6c534eb08 100644
--- a/test/core/end2end/tests/cancel_in_a_vacuum.c
+++ b/test/core/end2end/tests/cancel_in_a_vacuum.cc
@@ -29,13 +29,13 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
cancellation_mode mode,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s/%s", test_name, config.name,
mode.name);
@@ -53,31 +53,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -90,20 +90,20 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Cancel and do nothing */
static void test_cancel_in_a_vacuum(grpc_end2end_test_config config,
cancellation_mode mode) {
- grpc_call *c;
+ grpc_call* c;
grpc_end2end_test_fixture f =
- begin_test(config, "test_cancel_in_a_vacuum", mode, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.cq);
+ begin_test(config, "test_cancel_in_a_vacuum", mode, nullptr, nullptr);
+ cq_verifier* v_client = cq_verifier_create(f.cq);
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
grpc_call_unref(c);
diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h
index d85616b153..477d19929d 100644
--- a/test/core/end2end/tests/cancel_test_helpers.h
+++ b/test/core/end2end/tests/cancel_test_helpers.h
@@ -20,13 +20,13 @@
#define GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H
typedef struct {
- const char *name;
- grpc_call_error (*initiate_cancel)(grpc_call *call, void *reserved);
+ const char* name;
+ grpc_call_error (*initiate_cancel)(grpc_call* call, void* reserved);
grpc_status_code expect_status;
- const char *expect_details;
+ const char* expect_details;
} cancellation_mode;
-static grpc_call_error wait_for_deadline(grpc_call *call, void *reserved) {
+static grpc_call_error wait_for_deadline(grpc_call* call, void* reserved) {
(void)reserved;
return GRPC_CALL_OK;
}
diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.cc
index ab8c4f4187..7937fd161f 100644
--- a/test/core/end2end/tests/cancel_with_status.c
+++ b/test/core/end2end/tests/cancel_with_status.cc
@@ -28,16 +28,16 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
+ const char* test_name,
size_t num_ops,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s [%" PRIdPTR " ops]", test_name,
config.name, num_ops);
@@ -55,31 +55,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
grpc_event ev = grpc_completion_queue_next(
- f->cq, grpc_timeout_seconds_to_deadline(5), NULL);
+ f->cq, grpc_timeout_seconds_to_deadline(5), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag(1000));
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -91,10 +91,10 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f, size_t num_ops) {
- grpc_call *c;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
@@ -105,10 +105,10 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -121,29 +121,29 @@ static void simple_request_body(grpc_end2end_test_config config,
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(num_ops <= (size_t)(op - ops));
- error = grpc_call_start_batch(c, ops, num_ops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, num_ops, tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- char *dynamic_string = gpr_strdup("xyz");
+ char* dynamic_string = gpr_strdup("xyz");
grpc_call_cancel_with_status(c, GRPC_STATUS_UNIMPLEMENTED,
- (const char *)dynamic_string, NULL);
+ (const char*)dynamic_string, nullptr);
// The API of \a description allows for it to be a dynamic/non-const
// string, test this guarantee.
gpr_free(dynamic_string);
@@ -167,7 +167,8 @@ static void test_invoke_simple_request(grpc_end2end_test_config config,
size_t num_ops) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", num_ops, NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", num_ops, nullptr,
+ nullptr);
simple_request_body(config, f, num_ops);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.cc
index ce86e97b83..c08653b1c8 100644
--- a/test/core/end2end/tests/compressed_payload.c
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -36,12 +36,12 @@
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -58,31 +58,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -93,30 +93,30 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void request_for_disabled_algorithm(
- grpc_end2end_test_config config, const char *test_name,
+ grpc_end2end_test_config config, const char* test_name,
uint32_t send_flags_bitmask,
grpc_compression_algorithm algorithm_to_disable,
grpc_compression_algorithm requested_client_compression_algorithm,
- grpc_status_code expected_error, grpc_metadata *client_metadata) {
- grpc_call *c;
- grpc_call *s;
+ grpc_status_code expected_error, grpc_metadata* client_metadata) {
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer *request_payload;
- grpc_channel_args *client_args;
- grpc_channel_args *server_args;
+ grpc_byte_buffer* request_payload;
+ grpc_channel_args* client_args;
+ grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- cq_verifier *cqv;
+ cq_verifier* cqv;
char str[1024];
memset(str, 'x', 1023);
@@ -125,14 +125,13 @@ static void request_for_disabled_algorithm(
request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
client_args = grpc_channel_args_set_compression_algorithm(
- NULL, requested_client_compression_algorithm);
+ nullptr, requested_client_compression_algorithm);
server_args =
- grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_NONE);
+ grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
server_args = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ &server_args, algorithm_to_disable, false);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -140,10 +139,10 @@ static void request_for_disabled_algorithm(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -159,54 +158,55 @@ static void request_for_disabled_algorithm(
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- if (client_metadata != NULL) {
+ if (client_metadata != nullptr) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = client_metadata;
} else {
op->data.send_initial_metadata.count = 0;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), true);
cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), false);
@@ -215,13 +215,12 @@ static void request_for_disabled_algorithm(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), true);
- CQ_EXPECT_COMPLETION(cqv, tag(1), true);
cq_verify(cqv);
/* call was cancelled (closed) ... */
@@ -229,9 +228,9 @@ static void request_for_disabled_algorithm(
/* with a certain error */
GPR_ASSERT(status == expected_error);
- const char *algo_name = NULL;
+ const char* algo_name = nullptr;
GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name));
- char *expected_details = NULL;
+ char* expected_details = nullptr;
gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.",
algo_name);
/* and we expect a specific reason for it */
@@ -257,10 +256,9 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -268,36 +266,36 @@ static void request_for_disabled_algorithm(
}
static void request_with_payload_template(
- grpc_end2end_test_config config, const char *test_name,
+ grpc_end2end_test_config config, const char* test_name,
uint32_t client_send_flags_bitmask,
grpc_compression_algorithm default_client_channel_compression_algorithm,
grpc_compression_algorithm default_server_channel_compression_algorithm,
grpc_compression_algorithm expected_algorithm_from_client,
grpc_compression_algorithm expected_algorithm_from_server,
- grpc_metadata *client_init_metadata, bool set_server_level,
+ grpc_metadata* client_init_metadata, bool set_server_level,
grpc_compression_level server_compression_level,
bool send_message_before_initial_metadata) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer *request_payload = NULL;
- grpc_channel_args *client_args;
- grpc_channel_args *server_args;
+ grpc_byte_buffer* request_payload = nullptr;
+ grpc_channel_args* client_args;
+ grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload;
- grpc_byte_buffer *response_payload_recv;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload;
+ grpc_byte_buffer* response_payload_recv;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- cq_verifier *cqv;
+ cq_verifier* cqv;
char request_str[1024];
char response_str[1024];
@@ -312,19 +310,19 @@ static void request_with_payload_template(
grpc_slice_from_copied_string(response_str);
client_args = grpc_channel_args_set_compression_algorithm(
- NULL, default_client_channel_compression_algorithm);
+ nullptr, default_client_channel_compression_algorithm);
server_args = grpc_channel_args_set_compression_algorithm(
- NULL, default_server_channel_compression_algorithm);
+ nullptr, default_server_channel_compression_algorithm);
f = begin_test(config, test_name, client_args, server_args);
cqv = cq_verifier_create(f.cq);
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -339,9 +337,9 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = client_send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
}
@@ -349,28 +347,28 @@ static void request_with_payload_template(
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- if (client_init_metadata != NULL) {
+ if (client_init_metadata != nullptr) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = client_init_metadata;
} else {
op->data.send_initial_metadata.count = 0;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -385,9 +383,9 @@ static void request_with_payload_template(
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_NONE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_DEFLATE) != 0);
+ GRPC_COMPRESS_MESSAGE_DEFLATE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_GZIP) != 0);
+ GRPC_COMPRESS_MESSAGE_GZIP) != 0);
memset(ops, 0, sizeof(ops));
op = ops;
@@ -399,14 +397,14 @@ static void request_with_payload_template(
server_compression_level;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (int i = 0; i < 2; i++) {
@@ -419,9 +417,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = client_send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error =
+ grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
}
@@ -431,9 +430,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -449,9 +449,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -459,9 +460,9 @@ static void request_with_payload_template(
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -493,9 +494,9 @@ static void request_with_payload_template(
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -506,9 +507,9 @@ static void request_with_payload_template(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -536,10 +537,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -550,8 +550,9 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_exceptionally_uncompressed_payload",
- GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, NULL, false,
+ GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE,
+ GRPC_COMPRESS_MESSAGE_GZIP, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
@@ -560,26 +561,26 @@ static void test_invoke_request_with_uncompressed_payload(
request_with_payload_template(
config, "test_invoke_request_with_uncompressed_payload", 0,
GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
- GRPC_COMPRESS_NONE, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE,
- false);
+ GRPC_COMPRESS_NONE, nullptr, false,
+ /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
static void test_invoke_request_with_compressed_payload(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload", 0,
- GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
- GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE,
- false);
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, nullptr, false,
+ /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
static void test_invoke_request_with_send_message_before_initial_metadata(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload", 0,
- GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
- GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE,
- true);
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, nullptr, false,
+ /* ignored */ GRPC_COMPRESS_LEVEL_NONE, true);
}
static void test_invoke_request_with_server_level(
@@ -587,7 +588,7 @@ static void test_invoke_request_with_server_level(
request_with_payload_template(
config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE,
GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */,
- NULL, true, GRPC_COMPRESS_LEVEL_HIGH, false);
+ nullptr, true, GRPC_COMPRESS_LEVEL_HIGH, false);
}
static void test_invoke_request_with_compressed_payload_md_override(
@@ -596,7 +597,8 @@ static void test_invoke_request_with_compressed_payload_md_override(
grpc_metadata identity_compression_override;
gzip_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
- gzip_compression_override.value = grpc_slice_from_static_string("gzip");
+ gzip_compression_override.value =
+ grpc_slice_from_static_string("message/gzip");
memset(&gzip_compression_override.internal_data, 0,
sizeof(gzip_compression_override.internal_data));
@@ -609,21 +611,22 @@ static void test_invoke_request_with_compressed_payload_md_override(
/* Channel default NONE (aka IDENTITY), call override to GZIP */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_1", 0,
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP,
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP,
GRPC_COMPRESS_NONE, &gzip_compression_override, false,
/*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
/* Channel default DEFLATE, call override to GZIP */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_2", 0,
- GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP,
- GRPC_COMPRESS_NONE, &gzip_compression_override, false,
+ GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_NONE,
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE,
+ &gzip_compression_override, false,
/*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
/* Channel default DEFLATE, call override to NONE (aka IDENTITY) */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_3", 0,
- GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
+ GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
GRPC_COMPRESS_NONE, &identity_compression_override, false,
/*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
}
@@ -632,7 +635,8 @@ static void test_invoke_request_with_disabled_algorithm(
grpc_end2end_test_config config) {
request_for_disabled_algorithm(
config, "test_invoke_request_with_disabled_algorithm", 0,
- GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_STATUS_UNIMPLEMENTED, NULL);
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_STATUS_UNIMPLEMENTED, nullptr);
}
void compressed_payload(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/connectivity.c b/test/core/end2end/tests/connectivity.cc
index 610243ee3a..da65080bc0 100644
--- a/test/core/end2end/tests/connectivity.c
+++ b/test/core/end2end/tests/connectivity.cc
@@ -25,30 +25,30 @@
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
typedef struct {
gpr_event started;
- grpc_channel *channel;
- grpc_completion_queue *cq;
+ grpc_channel* channel;
+ grpc_completion_queue* cq;
} child_events;
-static void child_thread(void *arg) {
- child_events *ce = (child_events *)arg;
+static void child_thread(void* arg) {
+ child_events* ce = (child_events*)arg;
grpc_event ev;
- gpr_event_set(&ce->started, (void *)1);
+ gpr_event_set(&ce->started, (void*)1);
gpr_log(GPR_DEBUG, "verifying");
ev = grpc_completion_queue_next(ce->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag(1));
GPR_ASSERT(ev.success == 0);
}
static void test_connectivity(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
grpc_connectivity_state state;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
child_events ce;
gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
@@ -56,7 +56,8 @@ static void test_connectivity(grpc_end2end_test_config config) {
grpc_channel_args client_args;
grpc_arg arg_array[1];
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = 1000;
client_args.args = arg_array;
client_args.num_args = 1;
@@ -67,7 +68,8 @@ static void test_connectivity(grpc_end2end_test_config config) {
ce.cq = f.cq;
gpr_event_init(&ce.started);
gpr_thd_options_set_joinable(&thdopt);
- GPR_ASSERT(gpr_thd_new(&thdid, child_thread, &ce, &thdopt));
+ GPR_ASSERT(
+ gpr_thd_new(&thdid, "grpc_connectivity", child_thread, &ce, &thdopt));
gpr_event_wait(&ce.started, gpr_inf_future(GPR_CLOCK_MONOTONIC));
@@ -114,7 +116,7 @@ static void test_connectivity(grpc_end2end_test_config config) {
gpr_log(GPR_DEBUG, "*** STARTING SERVER ***");
/* now let's bring up a server to connect to */
- config.init_server(&f, NULL);
+ config.init_server(&f, nullptr);
gpr_log(GPR_DEBUG, "*** STARTED SERVER ***");
diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.cc
index d1db9b342a..7c94420540 100644
--- a/test/core/end2end/tests/default_host.c
+++ b/test/core/end2end/tests/default_host.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -87,11 +87,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void simple_request_body(grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -100,16 +100,16 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- char *peer;
+ char* peer;
gpr_timespec deadline = five_seconds_from_now();
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- grpc_slice_from_static_string("/foo"), NULL,
- deadline, NULL);
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ grpc_slice_from_static_string("/foo"), nullptr,
+ deadline, nullptr);
GPR_ASSERT(c);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
gpr_free(peer);
@@ -123,25 +123,25 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(error == GRPC_CALL_OK);
error =
@@ -152,11 +152,11 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_verify(cqv);
peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "server_peer=%s", peer);
gpr_free(peer);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
@@ -165,7 +165,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -173,14 +173,14 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(error == GRPC_CALL_OK);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -208,7 +208,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
simple_request_body(f);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.cc
index 19e4c05605..29fb19463f 100644
--- a/test/core/end2end/tests/disappearing_server.c
+++ b/test/core/end2end/tests/disappearing_server.cc
@@ -28,7 +28,7 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static gpr_timespec n_seconds_from_now(int n) {
return grpc_timeout_seconds_to_deadline(n);
@@ -38,26 +38,26 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -70,12 +70,12 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void do_request_and_shutdown_server(grpc_end2end_test_config config,
- grpc_end2end_test_fixture *f,
- cq_verifier *cqv) {
- grpc_call *c;
- grpc_call *s;
+ grpc_end2end_test_fixture* f,
+ cq_verifier* cqv) {
+ grpc_call* c;
+ grpc_call* s;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -87,10 +87,10 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
+ f->client, nullptr, GRPC_PROPAGATE_DEFAULTS, f->cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -103,25 +103,25 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -140,7 +140,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -148,14 +148,14 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -181,19 +181,19 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
}
static void disappearing_server_test(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
gpr_log(GPR_INFO, "Running test: %s/%s", "disappearing_server_test",
config.name);
- config.init_client(&f, NULL);
- config.init_server(&f, NULL);
+ config.init_client(&f, nullptr);
+ config.init_server(&f, nullptr);
do_request_and_shutdown_server(config, &f, cqv);
/* now destroy and recreate the server */
- config.init_server(&f, NULL);
+ config.init_server(&f, nullptr);
do_request_and_shutdown_server(config, &f, cqv);
diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.cc
index ee57c16780..c41e65ddd2 100644
--- a/test/core/end2end/tests/empty_batch.c
+++ b/test/core/end2end/tests/empty_batch.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -88,20 +88,20 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void empty_batch_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_call_error error;
- grpc_op *op = NULL;
+ grpc_op* op = nullptr;
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
- error = grpc_call_start_batch(c, op, 0, tag(1), NULL);
+ error = grpc_call_start_batch(c, op, 0, tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
cq_verify(cqv);
@@ -114,7 +114,7 @@ static void empty_batch_body(grpc_end2end_test_config config,
static void test_invoke_empty_body(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_empty_body", NULL, NULL);
+ f = begin_test(config, "test_invoke_empty_body", nullptr, nullptr);
empty_batch_body(config, f);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.cc
index 09e9dbcd7b..8f46f0bb91 100644
--- a/test/core/end2end/tests/filter_call_init_fails.c
+++ b/test/core/end2end/tests/filter_call_init_fails.cc
@@ -38,12 +38,12 @@ static bool g_enable_server_channel_filter = false;
static bool g_enable_client_channel_filter = false;
static bool g_enable_client_subchannel_filter = false;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -60,31 +60,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -97,21 +97,21 @@ static void end_test(grpc_end2end_test_fixture *f) {
// Simple request via a SERVER_CHANNEL filter that always fails to
// initialize the call.
static void test_server_channel_filter(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "filter_call_init_fails", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "filter_call_init_fails", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -119,10 +119,10 @@ static void test_server_channel_filter(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -134,32 +134,32 @@ static void test_server_channel_filter(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -193,31 +193,31 @@ static void test_server_channel_filter(grpc_end2end_test_config config) {
// Simple request via a CLIENT_CHANNEL or CLIENT_DIRECT_CHANNEL filter
// that always fails to initialize the call.
static void test_client_channel_filter(grpc_end2end_test_config config) {
- grpc_call *c;
+ grpc_call* c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_from_now();
grpc_end2end_test_fixture f =
- begin_test(config, "filter_call_init_fails", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "filter_call_init_fails", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -229,32 +229,32 @@ static void test_client_channel_filter(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -283,31 +283,31 @@ static void test_client_channel_filter(grpc_end2end_test_config config) {
// Simple request via a CLIENT_SUBCHANNEL filter that always fails to
// initialize the call.
static void test_client_subchannel_filter(grpc_end2end_test_config config) {
- grpc_call *c;
+ grpc_call* c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_from_now();
grpc_end2end_test_fixture f =
- begin_test(config, "filter_call_init_fails", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "filter_call_init_fails", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -319,33 +319,33 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -363,13 +363,13 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
details = grpc_empty_slice();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -399,26 +399,23 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
* Test filter - always fails to initialize a call
*/
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("access denied"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_PERMISSION_DENIED);
}
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {}
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {}
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_filter = {
grpc_call_next_op,
@@ -437,19 +434,18 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_server_channel_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
+static bool maybe_add_server_channel_filter(grpc_channel_stack_builder* builder,
+ void* arg) {
if (g_enable_server_channel_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
// can't add it at the very end, because the connected channel filter
// must be the last one. So we add it right before the last one.
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_last(builder);
GPR_ASSERT(grpc_channel_stack_builder_move_prev(it));
const bool retval = grpc_channel_stack_builder_add_filter_before(
- it, &test_filter, NULL, NULL);
+ it, &test_filter, nullptr, nullptr);
grpc_channel_stack_builder_iterator_destroy(it);
return retval;
} else {
@@ -457,19 +453,18 @@ static bool maybe_add_server_channel_filter(grpc_exec_ctx *exec_ctx,
}
}
-static bool maybe_add_client_channel_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder,
- void *arg) {
+static bool maybe_add_client_channel_filter(grpc_channel_stack_builder* builder,
+ void* arg) {
if (g_enable_client_channel_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
// can't add it at the very end, because the connected channel filter
// must be the last one. So we add it right before the last one.
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_last(builder);
GPR_ASSERT(grpc_channel_stack_builder_move_prev(it));
const bool retval = grpc_channel_stack_builder_add_filter_before(
- it, &test_filter, NULL, NULL);
+ it, &test_filter, nullptr, nullptr);
grpc_channel_stack_builder_iterator_destroy(it);
return retval;
} else {
@@ -478,17 +473,17 @@ static bool maybe_add_client_channel_filter(grpc_exec_ctx *exec_ctx,
}
static bool maybe_add_client_subchannel_filter(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
if (g_enable_client_subchannel_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
// can't add it at the very end, because the client channel filter
// must be the last one. So we add it right before the last one.
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_last(builder);
GPR_ASSERT(grpc_channel_stack_builder_move_prev(it));
const bool retval = grpc_channel_stack_builder_add_filter_before(
- it, &test_filter, NULL, NULL);
+ it, &test_filter, nullptr, nullptr);
grpc_channel_stack_builder_iterator_destroy(it);
return retval;
} else {
@@ -498,13 +493,13 @@ static bool maybe_add_client_subchannel_filter(
static void init_plugin(void) {
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
- maybe_add_server_channel_filter, NULL);
+ maybe_add_server_channel_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
- maybe_add_client_channel_filter, NULL);
+ maybe_add_client_channel_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
- maybe_add_client_subchannel_filter, NULL);
+ maybe_add_client_subchannel_filter, nullptr);
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
- maybe_add_client_channel_filter, NULL);
+ maybe_add_client_channel_filter, nullptr);
}
static void destroy_plugin(void) {}
diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.cc
index ee7aeb3f33..ec8f9dbe00 100644
--- a/test/core/end2end/tests/filter_causes_close.c
+++ b/test/core/end2end/tests/filter_causes_close.cc
@@ -33,12 +33,12 @@
static bool g_enable_filter = false;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -55,31 +55,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -91,21 +91,21 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Simple request via a server filter that always closes the stream.*/
static void test_request(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "filter_causes_close", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "filter_causes_close", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -113,10 +113,10 @@ static void test_request(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -128,32 +128,32 @@ static void test_request(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -189,16 +189,19 @@ static void test_request(grpc_end2end_test_config config) {
* Test filter - always closes incoming requests
*/
-typedef struct { grpc_closure *recv_im_ready; } call_data;
+typedef struct {
+ grpc_closure* recv_im_ready;
+} call_data;
-typedef struct { uint8_t unused; } channel_data;
+typedef struct {
+ uint8_t unused;
+} channel_data;
-static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_call_element *elem = (grpc_call_element *)arg;
- call_data *calld = (call_data *)elem->call_data;
+static void recv_im_ready(void* arg, grpc_error* error) {
+ grpc_call_element* elem = (grpc_call_element*)arg;
+ call_data* calld = (call_data*)elem->call_data;
GRPC_CLOSURE_RUN(
- exec_ctx, calld->recv_im_ready,
+ calld->recv_im_ready,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failure that's not preventable.", &error, 1),
GRPC_ERROR_INT_GRPC_STATUS,
@@ -206,36 +209,32 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
}
static void start_transport_stream_op_batch(
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- call_data *calld = (call_data *)elem->call_data;
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
+ call_data* calld = (call_data*)elem->call_data;
if (op->recv_initial_metadata) {
calld->recv_im_ready =
op->payload->recv_initial_metadata.recv_initial_metadata_ready;
op->payload->recv_initial_metadata.recv_initial_metadata_ready =
GRPC_CLOSURE_CREATE(recv_im_ready, elem, grpc_schedule_on_exec_ctx);
}
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {}
+static void destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {}
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_filter = {
start_transport_stream_op_batch,
@@ -254,11 +253,10 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder, void *arg) {
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
if (g_enable_filter) {
return grpc_channel_stack_builder_prepend_filter(builder, &test_filter,
- NULL, NULL);
+ nullptr, nullptr);
} else {
return true;
}
@@ -266,7 +264,7 @@ static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
static void init_plugin(void) {
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, 0, maybe_add_filter,
- NULL);
+ nullptr);
}
static void destroy_plugin(void) {}
diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.cc
index c24934f05d..845cbc01cf 100644
--- a/test/core/end2end/tests/filter_latency.c
+++ b/test/core/end2end/tests/filter_latency.cc
@@ -40,12 +40,12 @@ static gpr_mu g_mu;
static gpr_timespec g_client_latency;
static gpr_timespec g_server_latency;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -62,31 +62,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -98,21 +98,21 @@ static void end_test(grpc_end2end_test_fixture *f) {
// Simple request via a server filter that saves the reported latency value.
static void test_request(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "filter_latency", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "filter_latency", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -127,9 +127,9 @@ static void test_request(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
- get_host_override_slice("foo.test.google.fr", config), deadline, NULL);
+ get_host_override_slice("foo.test.google.fr", config), deadline, nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -141,32 +141,32 @@ static void test_request(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -182,7 +182,7 @@ static void test_request(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -190,14 +190,14 @@ static void test_request(grpc_end2end_test_config config) {
grpc_slice status_string = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_string;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -247,38 +247,33 @@ static void test_request(grpc_end2end_test_config config) {
* Test latency filter
*/
-static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
+static void client_destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
gpr_mu_lock(&g_mu);
g_client_latency = final_info->stats.latency;
gpr_mu_unlock(&g_mu);
}
-static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *ignored) {
+static void server_destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
gpr_mu_lock(&g_mu);
g_server_latency = final_info->stats.latency;
gpr_mu_unlock(&g_mu);
}
-static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_client_filter = {
grpc_call_next_op,
@@ -310,19 +305,18 @@ static const grpc_channel_filter test_server_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
- grpc_channel_stack_builder *builder, void *arg) {
- grpc_channel_filter *filter = (grpc_channel_filter *)arg;
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_filter* filter = (grpc_channel_filter*)arg;
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
// can't add it at the very end, because the connected channel filter
// must be the last one. So we add it right before the last one.
- grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_last(builder);
GPR_ASSERT(grpc_channel_stack_builder_move_prev(it));
- const bool retval =
- grpc_channel_stack_builder_add_filter_before(it, filter, NULL, NULL);
+ const bool retval = grpc_channel_stack_builder_add_filter_before(
+ it, filter, nullptr, nullptr);
grpc_channel_stack_builder_iterator_destroy(it);
return retval;
} else {
@@ -334,13 +328,13 @@ static void init_plugin(void) {
gpr_mu_init(&g_mu);
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
maybe_add_filter,
- (void *)&test_client_filter);
+ (void*)&test_client_filter);
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
maybe_add_filter,
- (void *)&test_client_filter);
+ (void*)&test_client_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
maybe_add_filter,
- (void *)&test_server_filter);
+ (void*)&test_server_filter);
}
static void destroy_plugin(void) { gpr_mu_destroy(&g_mu); }
diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc
new file mode 100644
index 0000000000..61c658b95a
--- /dev/null
+++ b/test/core/end2end/tests/filter_status_code.cc
@@ -0,0 +1,378 @@
+/*
+ *
+ * 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 "test/core/end2end/end2end_tests.h"
+
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/channel/channel_stack_builder.h"
+#include "src/core/lib/surface/call.h"
+#include "src/core/lib/surface/channel_init.h"
+#include "test/core/end2end/cq_verifier.h"
+
+static bool g_enable_filter = false;
+static gpr_mu g_mu;
+static grpc_call_stack* g_client_call_stack;
+static grpc_call_stack* g_server_call_stack;
+static bool g_client_code_recv;
+static bool g_server_code_recv;
+static gpr_cv g_client_code_cv;
+static gpr_cv g_server_code_cv;
+static grpc_status_code g_client_status_code;
+static grpc_status_code g_server_status_code;
+
+static void* tag(intptr_t t) { return (void*)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_from_now(int n) {
+ return grpc_timeout_seconds_to_deadline(n);
+}
+
+static gpr_timespec five_seconds_from_now(void) {
+ return n_seconds_from_now(5);
+}
+
+static void drain_cq(grpc_completion_queue* cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture* f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
+ grpc_timeout_seconds_to_deadline(5),
+ nullptr)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = nullptr;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture* f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = nullptr;
+}
+
+static void end_test(grpc_end2end_test_fixture* f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_destroy(f->shutdown_cq);
+}
+
+// Simple request via a server filter that saves the reported status code.
+static void test_request(grpc_end2end_test_config config) {
+ grpc_call* c;
+ grpc_call* s;
+ grpc_end2end_test_fixture f =
+ begin_test(config, "filter_status_code", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op* op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ grpc_slice details;
+ int was_cancelled = 2;
+
+ gpr_mu_lock(&g_mu);
+ g_client_call_stack = nullptr;
+ g_server_call_stack = nullptr;
+ g_client_status_code = GRPC_STATUS_OK;
+ g_server_status_code = GRPC_STATUS_OK;
+ gpr_mu_unlock(&g_mu);
+
+ gpr_timespec deadline = five_seconds_from_now();
+ c = grpc_channel_create_call(
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ grpc_slice_from_static_string("/foo"),
+ get_host_override_slice("foo.test.google.fr", config), deadline, nullptr);
+ GPR_ASSERT(c);
+ gpr_mu_lock(&g_mu);
+ g_client_call_stack = grpc_call_get_call_stack(c);
+ gpr_mu_unlock(&g_mu);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->data.send_initial_metadata.metadata = nullptr;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ error =
+ grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ gpr_mu_lock(&g_mu);
+ g_server_call_stack = grpc_call_get_call_stack(s);
+ gpr_mu_unlock(&g_mu);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
+ grpc_slice status_string = grpc_slice_from_static_string("xyz");
+ op->data.send_status_from_server.status_details = &status_string;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
+
+ grpc_slice_unref(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_unref(s);
+ grpc_call_unref(c);
+
+ cq_verifier_destroy(cqv);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+
+ // Perform checks after test tear-down
+ // Guards against the case that there's outstanding channel-related work on a
+ // call prior to verification
+ gpr_mu_lock(&g_mu);
+ if (!g_client_code_recv) {
+ GPR_ASSERT(gpr_cv_wait(&g_client_code_cv, &g_mu,
+ grpc_timeout_seconds_to_deadline(3)) == 0);
+ }
+ if (!g_server_code_recv) {
+ GPR_ASSERT(gpr_cv_wait(&g_server_code_cv, &g_mu,
+ grpc_timeout_seconds_to_deadline(3)) == 0);
+ }
+ GPR_ASSERT(g_client_status_code == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT(g_server_status_code == GRPC_STATUS_UNIMPLEMENTED);
+ gpr_mu_unlock(&g_mu);
+}
+
+/*******************************************************************************
+ * Test status_code filter
+ */
+
+typedef struct final_status_data {
+ grpc_call_stack* call;
+} final_status_data;
+
+static grpc_error* init_call_elem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ final_status_data* data = (final_status_data*)elem->call_data;
+ data->call = args->call_stack;
+ return GRPC_ERROR_NONE;
+}
+
+static void client_destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ final_status_data* data = (final_status_data*)elem->call_data;
+ gpr_mu_lock(&g_mu);
+ // Some fixtures, like proxies, will spawn intermidiate calls
+ // We only want the results from our explicit calls
+ if (data->call == g_client_call_stack) {
+ g_client_status_code = final_info->final_status;
+ g_client_code_recv = true;
+ gpr_cv_signal(&g_client_code_cv);
+ }
+ gpr_mu_unlock(&g_mu);
+}
+
+static void server_destroy_call_elem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* ignored) {
+ final_status_data* data = (final_status_data*)elem->call_data;
+ gpr_mu_lock(&g_mu);
+ // Some fixtures, like proxies, will spawn intermidiate calls
+ // We only want the results from our explicit calls
+ if (data->call == g_server_call_stack) {
+ g_server_status_code = final_info->final_status;
+ g_server_code_recv = true;
+ gpr_cv_signal(&g_server_code_cv);
+ }
+ gpr_mu_unlock(&g_mu);
+}
+
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
+ return GRPC_ERROR_NONE;
+}
+
+static void destroy_channel_elem(grpc_channel_element* elem) {}
+
+static const grpc_channel_filter test_client_filter = {
+ grpc_call_next_op,
+ grpc_channel_next_op,
+ sizeof(final_status_data),
+ init_call_elem,
+ grpc_call_stack_ignore_set_pollset_or_pollset_set,
+ client_destroy_call_elem,
+ 0,
+ init_channel_elem,
+ destroy_channel_elem,
+ grpc_channel_next_get_info,
+ "client_filter_status_code"};
+
+static const grpc_channel_filter test_server_filter = {
+ grpc_call_next_op,
+ grpc_channel_next_op,
+ sizeof(final_status_data),
+ init_call_elem,
+ grpc_call_stack_ignore_set_pollset_or_pollset_set,
+ server_destroy_call_elem,
+ 0,
+ init_channel_elem,
+ destroy_channel_elem,
+ grpc_channel_next_get_info,
+ "server_filter_status_code"};
+
+/*******************************************************************************
+ * Registration
+ */
+
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_filter* filter = (grpc_channel_filter*)arg;
+ if (g_enable_filter) {
+ // Want to add the filter as close to the end as possible, to make
+ // sure that all of the filters work well together. However, we
+ // can't add it at the very end, because the
+ // connected_channel/client_channel filter must be the last one.
+ // So we add it right before the last one.
+ grpc_channel_stack_builder_iterator* it =
+ grpc_channel_stack_builder_create_iterator_at_last(builder);
+ GPR_ASSERT(grpc_channel_stack_builder_move_prev(it));
+ const bool retval = grpc_channel_stack_builder_add_filter_before(
+ it, filter, nullptr, nullptr);
+ grpc_channel_stack_builder_iterator_destroy(it);
+ return retval;
+ } else {
+ return true;
+ }
+}
+
+static void init_plugin(void) {
+ gpr_mu_init(&g_mu);
+ gpr_cv_init(&g_client_code_cv);
+ gpr_cv_init(&g_server_code_cv);
+ g_client_code_recv = false;
+ g_server_code_recv = false;
+
+ grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
+ maybe_add_filter,
+ (void*)&test_client_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
+ maybe_add_filter,
+ (void*)&test_client_filter);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
+ maybe_add_filter,
+ (void*)&test_server_filter);
+}
+
+static void destroy_plugin(void) {
+ gpr_cv_destroy(&g_client_code_cv);
+ gpr_cv_destroy(&g_server_code_cv);
+ gpr_mu_destroy(&g_mu);
+}
+
+void filter_status_code(grpc_end2end_test_config config) {
+ g_enable_filter = true;
+ test_request(config);
+ g_enable_filter = false;
+}
+
+void filter_status_code_pre_init(void) {
+ grpc_register_plugin(init_plugin, destroy_plugin);
+}
diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.cc
index 9b3ff98195..bf11b49fa4 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.c
+++ b/test/core/end2end/tests/graceful_server_shutdown.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,26 +50,26 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -82,13 +82,14 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_early_server_shutdown_finishes_inflight_calls(
grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
- grpc_end2end_test_fixture f = begin_test(
- config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_early_server_shutdown_finishes_inflight_calls",
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -100,10 +101,10 @@ static void test_early_server_shutdown_finishes_inflight_calls(
gpr_timespec deadline = n_seconds_from_now(10);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -115,27 +116,27 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -154,7 +155,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -162,14 +163,14 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.cc
index 04b94838bb..d4d4f5a817 100644
--- a/test/core/end2end/tests/high_initial_seqno.c
+++ b/test/core/end2end/tests/high_initial_seqno.cc
@@ -29,15 +29,15 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -54,31 +54,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -90,11 +90,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -106,10 +106,10 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -122,25 +122,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -155,7 +155,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -163,14 +163,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -208,10 +208,10 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config,
grpc_end2end_test_fixture f;
grpc_arg client_arg;
grpc_channel_args client_args;
- char *name;
+ char* name;
client_arg.type = GRPC_ARG_INTEGER;
- client_arg.key = GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER;
+ client_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER);
client_arg.value.integer = initial_sequence_number;
client_args.num_args = 1;
@@ -219,7 +219,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config,
gpr_asprintf(&name, "test_invoke_requests first_seqno=%d",
initial_sequence_number);
- f = begin_test(config, name, &client_args, NULL);
+ f = begin_test(config, name, &client_args, nullptr);
for (i = 0; i < 10; i++) {
simple_request_body(config, f);
gpr_log(GPR_INFO, "Running test: Passed simple request %d", i);
diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.cc
index 9358c119b1..0d6ec01e36 100644
--- a/test/core/end2end/tests/hpack_size.c
+++ b/test/core/end2end/tests/hpack_size.cc
@@ -29,12 +29,12 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-const char *hobbits[][2] = {
+const char* hobbits[][2] = {
{"Adaldrida", "Brandybuck"}, {"Adamanta", "Took"},
{"Adalgrim", "Took"}, {"Adelard", "Took"},
{"Amaranth", "Brandybuck"}, {"Andwise", "Roper"},
@@ -171,13 +171,13 @@ const char *hobbits[][2] = {
{"Wiseman", "Gamwich"}*/
};
-const char *dragons[] = {"Ancalagon", "Glaurung", "Scatha",
+const char* dragons[] = {"Ancalagon", "Glaurung", "Scatha",
"Smaug the Magnificent"};
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -194,31 +194,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -230,11 +230,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f, size_t index) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -258,10 +258,10 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -275,25 +275,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->data.send_initial_metadata.count = GPR_ARRAY_SIZE(extra_metadata);
op->data.send_initial_metadata.metadata = extra_metadata;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -308,7 +308,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -316,14 +316,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -357,23 +357,23 @@ static void test_size(grpc_end2end_test_config config, int encode_size,
grpc_channel_args server_args;
grpc_arg client_arg;
grpc_channel_args client_args;
- char *name;
+ char* name;
server_arg.type = GRPC_ARG_INTEGER;
- server_arg.key = GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER;
+ server_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER);
server_arg.value.integer = decode_size;
server_args.num_args = 1;
server_args.args = &server_arg;
client_arg.type = GRPC_ARG_INTEGER;
- client_arg.key = GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER;
+ client_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER);
client_arg.value.integer = encode_size;
client_args.num_args = 1;
client_args.args = &client_arg;
gpr_asprintf(&name, "test_size:e=%d:d=%d", encode_size, decode_size);
- f = begin_test(config, name, encode_size != 4096 ? &client_args : NULL,
- decode_size != 4096 ? &server_args : NULL);
+ f = begin_test(config, name, encode_size != 4096 ? &client_args : nullptr,
+ decode_size != 4096 ? &server_args : nullptr);
for (i = 0; i < 4 * GPR_ARRAY_SIZE(hobbits); i++) {
simple_request_body(config, f, i);
}
diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.cc
index 829ece6631..7487e4d83d 100644
--- a/test/core/end2end/tests/idempotent_request.c
+++ b/test/core/end2end/tests/idempotent_request.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -88,11 +88,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -101,18 +101,18 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- char *peer;
+ char* peer;
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
gpr_free(peer);
@@ -126,25 +126,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -155,11 +155,11 @@ static void simple_request_body(grpc_end2end_test_config config,
cq_verify(cqv);
peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "server_peer=%s", peer);
gpr_free(peer);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
@@ -168,7 +168,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -176,14 +176,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -213,7 +213,7 @@ static void simple_request_body(grpc_end2end_test_config config,
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
simple_request_body(config, f);
end_test(&f);
config.tear_down_data(&f);
@@ -222,7 +222,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) {
static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
+ begin_test(config, "test_invoke_10_simple_requests", nullptr, nullptr);
for (i = 0; i < 10; i++) {
simple_request_body(config, f);
gpr_log(GPR_INFO, "Passed simple request %d", i);
diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.cc
index ff269fa3ee..8a67e3c2b1 100644
--- a/test/core/end2end/tests/invoke_large_request.c
+++ b/test/core/end2end/tests/invoke_large_request.cc
@@ -29,12 +29,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -47,31 +47,31 @@ static gpr_timespec n_seconds_from_now(int n) {
return grpc_timeout_seconds_to_deadline(n);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, n_seconds_from_now(5), NULL);
+ ev = grpc_completion_queue_next(cq, n_seconds_from_now(5), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -89,17 +89,17 @@ static grpc_slice large_slice(void) {
static void test_invoke_large_request(grpc_end2end_test_config config,
int max_frame_size, int lookahead_bytes) {
- char *name;
+ char* name;
gpr_asprintf(&name,
"test_invoke_large_request:max_frame_size=%d:lookahead_bytes=%d",
max_frame_size, lookahead_bytes);
grpc_arg args[2];
args[0].type = GRPC_ARG_INTEGER;
- args[0].key = GRPC_ARG_HTTP2_MAX_FRAME_SIZE;
+ args[0].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_FRAME_SIZE);
args[0].value.integer = max_frame_size;
args[1].type = GRPC_ARG_INTEGER;
- args[1].key = GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES;
+ args[1].key = const_cast<char*>(GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES);
args[1].value.integer = lookahead_bytes;
grpc_channel_args channel_args = {GPR_ARRAY_SIZE(args), args};
@@ -109,20 +109,20 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
grpc_slice request_payload_slice = large_slice();
grpc_slice response_payload_slice = large_slice();
- grpc_call *c;
- grpc_call *s;
- grpc_byte_buffer *request_payload =
+ grpc_call* c;
+ grpc_call* s;
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -131,10 +131,10 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
gpr_timespec deadline = n_seconds_from_now(30);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -147,35 +147,35 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -190,14 +190,14 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -208,12 +208,12 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -221,9 +221,9 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/keepalive_timeout.c b/test/core/end2end/tests/keepalive_timeout.cc
index 8d01f23c00..6482b86825 100644
--- a/test/core/end2end/tests/keepalive_timeout.c
+++ b/test/core/end2end/tests/keepalive_timeout.cc
@@ -28,16 +28,16 @@
#include <grpc/support/useful.h>
#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/iomgr/exec_ctx.h"
-#include "src/core/lib/support/env.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -54,31 +54,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
- five_seconds_from_now(), NULL)
+ five_seconds_from_now(), nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -91,35 +91,35 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client sends a request, server replies with a payload, then waits for the
keepalive watchdog timeouts before returning status. */
static void test_keepalive_timeout(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- grpc_arg keepalive_args[] = {{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_KEEPALIVE_TIME_MS,
- .value.integer = 1500},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_KEEPALIVE_TIMEOUT_MS,
- .value.integer = 0},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_BDP_PROBE,
- .value.integer = 0}};
-
- grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(keepalive_args),
- .args = keepalive_args};
+ grpc_arg keepalive_arg_elems[3];
+ keepalive_arg_elems[0].type = GRPC_ARG_INTEGER;
+ keepalive_arg_elems[0].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_TIME_MS);
+ keepalive_arg_elems[0].value.integer = 1500;
+ keepalive_arg_elems[1].type = GRPC_ARG_INTEGER;
+ keepalive_arg_elems[1].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_TIMEOUT_MS);
+ keepalive_arg_elems[1].value.integer = 0;
+ keepalive_arg_elems[2].type = GRPC_ARG_INTEGER;
+ keepalive_arg_elems[2].key = const_cast<char*>(GRPC_ARG_HTTP2_BDP_PROBE);
+ keepalive_arg_elems[2].value.integer = 0;
+ grpc_channel_args keepalive_args = {GPR_ARRAY_SIZE(keepalive_arg_elems),
+ keepalive_arg_elems};
grpc_end2end_test_fixture f =
- begin_test(config, "keepalive_timeout", &client_args, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "keepalive_timeout", &keepalive_args, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -130,10 +130,10 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -154,7 +154,7 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -171,7 +171,7 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -185,15 +185,15 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
cq_verify(cqv);
- char *details_str = grpc_slice_to_c_string(details);
- char *method_str = grpc_slice_to_c_string(call_details.method);
- GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
+ char* details_str = grpc_slice_to_c_string(details);
+ char* method_str = grpc_slice_to_c_string(call_details.method);
+ GPR_ASSERT(status == GRPC_STATUS_INTERNAL);
GPR_ASSERT(0 == grpc_slice_str_cmp(details, "keepalive watchdog timeout"));
GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
validate_host_override_string("foo.test.google.fr:1234", call_details.host,
diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.cc
index 81a45d827a..8ddf433ac0 100644
--- a/test/core/end2end/tests/large_metadata.c
+++ b/test/core/end2end/tests/large_metadata.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,27 +86,28 @@ static void end_test(grpc_end2end_test_fixture *f) {
// Request with a large amount of metadata.
static void test_request_with_large_metadata(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_metadata meta;
const size_t large_size = 64 * 1024;
- grpc_arg arg = {GRPC_ARG_INTEGER,
- GRPC_ARG_MAX_METADATA_SIZE,
- {.integer = (int)large_size + 1024}};
+ grpc_arg arg;
+ arg.type = GRPC_ARG_INTEGER;
+ arg.key = const_cast<char*>(GRPC_ARG_MAX_METADATA_SIZE);
+ arg.value.integer = (int)large_size + 1024;
grpc_channel_args args = {1, &arg};
grpc_end2end_test_fixture f =
begin_test(config, "test_request_with_large_metadata", &args, &args);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -115,10 +116,10 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
meta.key = grpc_slice_from_static_string("key");
@@ -137,30 +138,30 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = &meta;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -177,14 +178,14 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -197,7 +198,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -205,9 +206,9 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.cc
index 7b503790db..e056bd547b 100644
--- a/test/core/end2end/tests/load_reporting_hook.c
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -36,16 +36,16 @@
enum { TIMEOUT = 200000 };
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
typedef struct {
gpr_mu mu;
intptr_t channel_id;
intptr_t call_id;
- char *initial_md_str;
- char *trailing_md_str;
- char *method_name;
+ char* initial_md_str;
+ char* trailing_md_str;
+ char* method_name;
uint64_t incoming_bytes;
uint64_t outgoing_bytes;
@@ -56,9 +56,9 @@ typedef struct {
} load_reporting_data;
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
@@ -77,31 +77,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -113,25 +113,25 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void request_response_with_payload(
grpc_end2end_test_config config, grpc_end2end_test_fixture f,
- const char *method_name, const char *request_msg, const char *response_msg,
- grpc_metadata *initial_lr_metadata, grpc_metadata *trailing_lr_metadata) {
+ const char* method_name, const char* request_msg, const char* response_msg,
+ grpc_metadata* initial_lr_metadata, grpc_metadata* trailing_lr_metadata) {
grpc_slice request_payload_slice = grpc_slice_from_static_string(request_msg);
grpc_slice response_payload_slice =
grpc_slice_from_static_string(response_msg);
- grpc_call *c;
- grpc_call *s;
- grpc_byte_buffer *request_payload =
+ grpc_call* c;
+ grpc_call* s;
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -140,10 +140,10 @@ static void request_response_with_payload(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string(method_name),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -154,39 +154,39 @@ static void request_response_with_payload(
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- GPR_ASSERT(initial_lr_metadata != NULL);
+ GPR_ASSERT(initial_lr_metadata != nullptr);
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = initial_lr_metadata;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -201,14 +201,14 @@ static void request_response_with_payload(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -219,24 +219,24 @@ static void request_response_with_payload(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
- GPR_ASSERT(trailing_lr_metadata != NULL);
+ GPR_ASSERT(trailing_lr_metadata != nullptr);
op->data.send_status_from_server.trailing_metadata_count = 1;
op->data.send_status_from_server.trailing_metadata = trailing_lr_metadata;
op->data.send_status_from_server.status = GRPC_STATUS_OK;
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -264,7 +264,7 @@ static void request_response_with_payload(
/* override the default for testing purposes */
extern void (*g_load_reporting_fn)(
- const grpc_load_reporting_call_data *call_data);
+ const grpc_load_reporting_call_data* call_data);
static void test_load_reporting_hook(grpc_end2end_test_config config) {
/* TODO(dgq): this test is currently a noop until LR is fully defined.
@@ -272,15 +272,15 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
/* Introduce load reporting for the server through its arguments */
grpc_arg arg = grpc_load_reporting_enable_arg();
- grpc_channel_args *lr_server_args =
- grpc_channel_args_copy_and_add(NULL, &arg, 1);
+ grpc_channel_args* lr_server_args =
+ grpc_channel_args_copy_and_add(nullptr, &arg, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "test_load_reporting_hook", NULL, lr_server_args);
+ begin_test(config, "test_load_reporting_hook", nullptr, lr_server_args);
- const char *method_name = "/gRPCFTW";
- const char *request_msg = "the msg from the client";
- const char *response_msg = "... and the response from the server";
+ const char* method_name = "/gRPCFTW";
+ const char* request_msg = "the msg from the client";
+ const char* response_msg = "... and the response from the server";
grpc_metadata initial_lr_metadata;
grpc_metadata trailing_lr_metadata;
@@ -300,9 +300,8 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
&trailing_lr_metadata);
end_test(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, lr_server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(lr_server_args);
}
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.cc
index d18c13997c..c0539739e1 100644
--- a/test/core/end2end/tests/max_concurrent_streams.c
+++ b/test/core/end2end/tests/max_concurrent_streams.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,11 +86,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -102,10 +102,10 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -118,25 +118,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -151,7 +151,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -159,14 +159,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -196,13 +196,13 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
grpc_arg server_arg;
grpc_channel_args server_args;
- grpc_call *c1;
- grpc_call *c2;
- grpc_call *s1;
- grpc_call *s2;
+ grpc_call* c1;
+ grpc_call* c2;
+ grpc_call* s1;
+ grpc_call* s2;
int live_call;
gpr_timespec deadline;
- cq_verifier *cqv;
+ cq_verifier* cqv;
grpc_event ev;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
@@ -216,19 +216,19 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
grpc_status_code status2;
grpc_slice details2;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
int was_cancelled;
int got_client_start;
int got_server_start;
- server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS;
+ server_arg.key = const_cast<char*>(GRPC_ARG_MAX_CONCURRENT_STREAMS);
server_arg.type = GRPC_ARG_INTEGER;
server_arg.value.integer = 1;
server_args.num_args = 1;
server_args.args = &server_arg;
- f = begin_test(config, "test_max_concurrent_streams", NULL, &server_args);
+ f = begin_test(config, "test_max_concurrent_streams", nullptr, &server_args);
cqv = cq_verifier_create(f.cq);
grpc_metadata_array_init(&request_metadata_recv);
@@ -248,16 +248,16 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
the first completes */
deadline = n_seconds_from_now(1000);
c1 = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/alpha"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c1);
c2 = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/beta"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c2);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -269,13 +269,13 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL);
+ error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -285,15 +285,15 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->data.recv_status_on_client.status = &status1;
op->data.recv_status_on_client.status_details = &details1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL);
+ error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -301,13 +301,13 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL);
+ error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -317,15 +317,15 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->data.recv_status_on_client.status = &status2;
op->data.recv_status_on_client.status_details = &details2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL);
+ error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
got_client_start = 0;
@@ -333,7 +333,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
live_call = -1;
while (!got_client_start || !got_server_start) {
ev = grpc_completion_queue_next(f.cq, grpc_timeout_seconds_to_deadline(3),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.success);
if (ev.tag == tag(101)) {
@@ -357,12 +357,12 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -370,9 +370,9 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -395,21 +395,21 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), NULL);
+ error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(live_call + 2), 1);
@@ -441,11 +441,11 @@ static void test_max_concurrent_streams_with_timeout_on_first(
grpc_end2end_test_fixture f;
grpc_arg server_arg;
grpc_channel_args server_args;
- grpc_call *c1;
- grpc_call *c2;
- grpc_call *s1;
- grpc_call *s2;
- cq_verifier *cqv;
+ grpc_call* c1;
+ grpc_call* c2;
+ grpc_call* s1;
+ grpc_call* s2;
+ cq_verifier* cqv;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
grpc_metadata_array initial_metadata_recv1;
@@ -458,10 +458,10 @@ static void test_max_concurrent_streams_with_timeout_on_first(
grpc_status_code status2;
grpc_slice details2 = grpc_empty_slice();
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
int was_cancelled;
- server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS;
+ server_arg.key = const_cast<char*>(GRPC_ARG_MAX_CONCURRENT_STREAMS);
server_arg.type = GRPC_ARG_INTEGER;
server_arg.value.integer = 1;
@@ -469,7 +469,7 @@ static void test_max_concurrent_streams_with_timeout_on_first(
server_args.args = &server_arg;
f = begin_test(config, "test_max_concurrent_streams_with_timeout_on_first",
- NULL, &server_args);
+ nullptr, &server_args);
cqv = cq_verifier_create(f.cq);
grpc_metadata_array_init(&request_metadata_recv);
@@ -488,16 +488,16 @@ static void test_max_concurrent_streams_with_timeout_on_first(
/* start two requests - ensuring that the second is not accepted until
the first completes */
c1 = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/alpha"),
get_host_override_slice("foo.test.google.fr:1234", config),
- n_seconds_from_now(3), NULL);
+ n_seconds_from_now(3), nullptr);
GPR_ASSERT(c1);
c2 = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/beta"),
get_host_override_slice("foo.test.google.fr:1234", config),
- n_seconds_from_now(1000), NULL);
+ n_seconds_from_now(1000), nullptr);
GPR_ASSERT(c2);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -509,13 +509,13 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL);
+ error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -525,15 +525,15 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->data.recv_status_on_client.status = &status1;
op->data.recv_status_on_client.status_details = &details1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL);
+ error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -545,13 +545,13 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL);
+ error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -561,15 +561,15 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->data.recv_status_on_client.status = &status2;
op->data.recv_status_on_client.status_details = &details2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL);
+ error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
grpc_call_details_destroy(&call_details);
@@ -589,12 +589,12 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -602,9 +602,9 @@ static void test_max_concurrent_streams_with_timeout_on_first(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), NULL);
+ error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(402), 1);
@@ -636,10 +636,10 @@ static void test_max_concurrent_streams_with_timeout_on_second(
grpc_end2end_test_fixture f;
grpc_arg server_arg;
grpc_channel_args server_args;
- grpc_call *c1;
- grpc_call *c2;
- grpc_call *s1;
- cq_verifier *cqv;
+ grpc_call* c1;
+ grpc_call* c2;
+ grpc_call* s1;
+ cq_verifier* cqv;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
grpc_metadata_array initial_metadata_recv1;
@@ -652,10 +652,10 @@ static void test_max_concurrent_streams_with_timeout_on_second(
grpc_status_code status2;
grpc_slice details2 = grpc_empty_slice();
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
int was_cancelled;
- server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS;
+ server_arg.key = const_cast<char*>(GRPC_ARG_MAX_CONCURRENT_STREAMS);
server_arg.type = GRPC_ARG_INTEGER;
server_arg.value.integer = 1;
@@ -663,7 +663,7 @@ static void test_max_concurrent_streams_with_timeout_on_second(
server_args.args = &server_arg;
f = begin_test(config, "test_max_concurrent_streams_with_timeout_on_second",
- NULL, &server_args);
+ nullptr, &server_args);
cqv = cq_verifier_create(f.cq);
grpc_metadata_array_init(&request_metadata_recv);
@@ -683,16 +683,16 @@ static void test_max_concurrent_streams_with_timeout_on_second(
the first completes , and the second request will timeout in the
concurrent_list */
c1 = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/alpha"),
get_host_override_slice("foo.test.google.fr:1234", config),
- n_seconds_from_now(1000), NULL);
+ n_seconds_from_now(1000), nullptr);
GPR_ASSERT(c1);
c2 = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/beta"),
get_host_override_slice("foo.test.google.fr:1234", config),
- n_seconds_from_now(3), NULL);
+ n_seconds_from_now(3), nullptr);
GPR_ASSERT(c2);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -704,13 +704,13 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL);
+ error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -720,15 +720,15 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->data.recv_status_on_client.status = &status1;
op->data.recv_status_on_client.status_details = &details1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv1;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL);
+ error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -740,13 +740,13 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL);
+ error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -756,15 +756,15 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->data.recv_status_on_client.status = &status2;
op->data.recv_status_on_client.status_details = &details2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv2;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL);
+ error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the second request is time out*/
@@ -782,12 +782,12 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -795,9 +795,9 @@ static void test_max_concurrent_streams_with_timeout_on_second(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(302), 1);
diff --git a/test/core/end2end/tests/max_connection_age.c b/test/core/end2end/tests/max_connection_age.cc
index 4119087619..ddccfc3b51 100644
--- a/test/core/end2end/tests/max_connection_age.c
+++ b/test/core/end2end/tests/max_connection_age.cc
@@ -45,29 +45,29 @@
/* The grace period for the test to observe the channel shutdown process */
#define IMMEDIATE_SHUTDOWN_GRACE_TIME_MS 3000
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5),
- NULL);
+ nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -78,28 +78,28 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
- grpc_arg server_a[] = {{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_AGE_MS,
- .value.integer = MAX_CONNECTION_AGE_MS},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS,
- .value.integer = MAX_CONNECTION_AGE_GRACE_MS},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_IDLE_MS,
- .value.integer = MAX_CONNECTION_IDLE_MS}};
- grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
- .args = server_a};
-
- config.init_client(&f, NULL);
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_arg server_a[3];
+ server_a[0].type = GRPC_ARG_INTEGER;
+ server_a[0].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_MS);
+ server_a[0].value.integer = MAX_CONNECTION_AGE_MS;
+ server_a[1].type = GRPC_ARG_INTEGER;
+ server_a[1].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS);
+ server_a[1].value.integer = MAX_CONNECTION_AGE_GRACE_MS;
+ server_a[2].type = GRPC_ARG_INTEGER;
+ server_a[2].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_IDLE_MS);
+ server_a[2].value.integer = MAX_CONNECTION_IDLE_MS;
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
+
+ config.init_client(&f, nullptr);
config.init_server(&f, &server_args);
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(CALL_DEADLINE_S);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -110,10 +110,10 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
int was_cancelled = 2;
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -125,27 +125,27 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -175,7 +175,7 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -183,14 +183,14 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), true);
cq_verify(cqv);
@@ -203,8 +203,7 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
/* The connection should be closed immediately after the max age grace period,
the in-progress RPC should fail. */
- GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
- GPR_ASSERT(0 == grpc_slice_str_cmp(details, "Endpoint read failed"));
+ GPR_ASSERT(status == GRPC_STATUS_INTERNAL);
GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
validate_host_override_string("foo.test.google.fr:1234", call_details.host,
config);
@@ -222,28 +221,28 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
}
static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
- grpc_arg server_a[] = {{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_AGE_MS,
- .value.integer = MAX_CONNECTION_AGE_MS},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS,
- .value.integer = INT_MAX},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_IDLE_MS,
- .value.integer = MAX_CONNECTION_IDLE_MS}};
- grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
- .args = server_a};
-
- config.init_client(&f, NULL);
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_arg server_a[3];
+ server_a[0].type = GRPC_ARG_INTEGER;
+ server_a[0].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_MS);
+ server_a[0].value.integer = MAX_CONNECTION_AGE_MS;
+ server_a[1].type = GRPC_ARG_INTEGER;
+ server_a[1].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS);
+ server_a[1].value.integer = INT_MAX;
+ server_a[2].type = GRPC_ARG_INTEGER;
+ server_a[2].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_IDLE_MS);
+ server_a[2].value.integer = MAX_CONNECTION_IDLE_MS;
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
+
+ config.init_client(&f, nullptr);
config.init_server(&f, &server_args);
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(CALL_DEADLINE_S);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -254,10 +253,10 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
int was_cancelled = 2;
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -269,27 +268,27 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -311,7 +310,7 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -319,14 +318,14 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), true);
diff --git a/test/core/end2end/tests/max_connection_idle.c b/test/core/end2end/tests/max_connection_idle.cc
index f26b0be40e..293ff7d1f2 100644
--- a/test/core/end2end/tests/max_connection_idle.c
+++ b/test/core/end2end/tests/max_connection_idle.cc
@@ -32,23 +32,23 @@
#define MAX_CONNECTION_IDLE_MS 500
#define MAX_CONNECTION_AGE_MS 9999
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5),
- NULL);
+ nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
static void simple_request_body(grpc_end2end_test_config config,
- grpc_end2end_test_fixture *f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f->cq);
+ grpc_end2end_test_fixture* f) {
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f->cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -57,18 +57,18 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- char *peer;
+ char* peer;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
c = grpc_channel_create_call(
- f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
+ f->client, nullptr, GRPC_PROPAGATE_DEFAULTS, f->cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
gpr_free(peer);
@@ -82,25 +82,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -111,11 +111,11 @@ static void simple_request_body(grpc_end2end_test_config config,
cq_verify(cqv);
peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "server_peer=%s", peer);
gpr_free(peer);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
@@ -124,7 +124,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -132,14 +132,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -167,23 +167,24 @@ static void simple_request_body(grpc_end2end_test_config config,
}
static void test_max_connection_idle(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- cq_verifier *cqv = cq_verifier_create(f.cq);
-
- grpc_arg client_a[] = {{.type = GRPC_ARG_INTEGER,
- .key = "grpc.testing.fixed_reconnect_backoff_ms",
- .value.integer = 1000}};
- grpc_arg server_a[] = {{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_IDLE_MS,
- .value.integer = MAX_CONNECTION_IDLE_MS},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_MAX_CONNECTION_AGE_MS,
- .value.integer = MAX_CONNECTION_AGE_MS}};
- grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(client_a),
- .args = client_a};
- grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
- .args = server_a};
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+
+ grpc_arg client_a[1];
+ client_a[0].type = GRPC_ARG_INTEGER;
+ client_a[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
+ client_a[0].value.integer = 1000;
+ grpc_arg server_a[2];
+ server_a[0].type = GRPC_ARG_INTEGER;
+ server_a[0].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_IDLE_MS);
+ server_a[0].value.integer = MAX_CONNECTION_IDLE_MS;
+ server_a[1].type = GRPC_ARG_INTEGER;
+ server_a[1].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_MS);
+ server_a[1].value.integer = MAX_CONNECTION_AGE_MS;
+ grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
config.init_client(&f, &client_args);
config.init_server(&f, &server_args);
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.cc
index 01eb8d365e..e581f1fc20 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -34,18 +34,18 @@
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
// We intentionally do not pass the client and server args to
// create_fixture(), since we don't want the limit enforced on the
// proxy, only on the backend server.
- f = config.create_fixture(NULL, NULL);
+ f = config.create_fixture(nullptr, nullptr);
config.init_server(&f, server_args);
config.init_client(&f, client_args);
return f;
@@ -59,31 +59,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
grpc_event ev = grpc_completion_queue_next(
- f->cq, grpc_timeout_seconds_to_deadline(5), NULL);
+ f->cq, grpc_timeout_seconds_to_deadline(5), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag(1000));
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -106,16 +106,16 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
send_limit, use_service_config, use_string_json_value);
grpc_end2end_test_fixture f;
- grpc_call *c = NULL;
- grpc_call *s = NULL;
- cq_verifier *cqv;
+ grpc_call* c = nullptr;
+ grpc_call* s = nullptr;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *recv_payload = NULL;
+ grpc_byte_buffer* recv_payload = nullptr;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -125,41 +125,44 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
grpc_slice details;
int was_cancelled = 2;
- grpc_channel_args *client_args = NULL;
- grpc_channel_args *server_args = NULL;
+ grpc_channel_args* client_args = nullptr;
+ grpc_channel_args* server_args = nullptr;
if (use_service_config) {
// We don't currently support service configs on the server side.
GPR_ASSERT(send_limit);
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
+ arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG);
arg.value.string =
use_string_json_value
- ? "{\n"
- " \"methodConfig\": [ {\n"
- " \"name\": [\n"
- " { \"service\": \"service\", \"method\": \"method\" }\n"
- " ],\n"
- " \"maxRequestMessageBytes\": \"5\"\n"
- " } ]\n"
- "}"
- : "{\n"
- " \"methodConfig\": [ {\n"
- " \"name\": [\n"
- " { \"service\": \"service\", \"method\": \"method\" }\n"
- " ],\n"
- " \"maxRequestMessageBytes\": 5\n"
- " } ]\n"
- "}";
- client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
+ ? const_cast<char*>(
+ "{\n"
+ " \"methodConfig\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"maxRequestMessageBytes\": \"5\"\n"
+ " } ]\n"
+ "}")
+ : const_cast<char*>(
+ "{\n"
+ " \"methodConfig\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"maxRequestMessageBytes\": 5\n"
+ " } ]\n"
+ "}");
+ client_args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
} else {
// Set limit via channel args.
grpc_arg arg;
- arg.key = send_limit ? GRPC_ARG_MAX_SEND_MESSAGE_LENGTH
- : GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH;
+ arg.key = send_limit
+ ? const_cast<char*>(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH)
+ : const_cast<char*>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH);
arg.type = GRPC_ARG_INTEGER;
arg.value.integer = 5;
- grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
+ grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
if (send_limit) {
client_args = args;
} else {
@@ -170,19 +173,18 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
f = begin_test(config, "test_max_request_message_length", client_args,
server_args);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (client_args != NULL) grpc_channel_args_destroy(&exec_ctx, client_args);
- if (server_args != NULL) grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ if (client_args != nullptr) grpc_channel_args_destroy(client_args);
+ if (server_args != nullptr) grpc_channel_args_destroy(server_args);
}
cqv = cq_verifier_create(f.cq);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/service/method"),
get_host_override_slice("foo.test.google.fr:1234", config),
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -195,30 +197,30 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
if (send_limit) {
@@ -239,14 +241,14 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &recv_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -275,7 +277,7 @@ done:
grpc_byte_buffer_destroy(recv_payload);
grpc_call_unref(c);
- if (s != NULL) grpc_call_unref(s);
+ if (s != nullptr) grpc_call_unref(s);
cq_verifier_destroy(cqv);
@@ -296,16 +298,16 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
send_limit, use_service_config, use_string_json_value);
grpc_end2end_test_fixture f;
- grpc_call *c = NULL;
- grpc_call *s = NULL;
- cq_verifier *cqv;
+ grpc_call* c = nullptr;
+ grpc_call* s = nullptr;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- grpc_byte_buffer *recv_payload = NULL;
+ grpc_byte_buffer* recv_payload = nullptr;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -315,15 +317,15 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
grpc_slice details;
int was_cancelled = 2;
- grpc_channel_args *client_args = NULL;
- grpc_channel_args *server_args = NULL;
+ grpc_channel_args* client_args = nullptr;
+ grpc_channel_args* server_args = nullptr;
if (use_service_config) {
// We don't currently support service configs on the server side.
GPR_ASSERT(!send_limit);
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
- arg.value.string =
+ arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG);
+ arg.value.string = const_cast<char*>(
use_string_json_value
? "{\n"
" \"methodConfig\": [ {\n"
@@ -340,16 +342,17 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
" ],\n"
" \"maxResponseMessageBytes\": 5\n"
" } ]\n"
- "}";
- client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
+ "}");
+ client_args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
} else {
// Set limit via channel args.
grpc_arg arg;
- arg.key = send_limit ? GRPC_ARG_MAX_SEND_MESSAGE_LENGTH
- : GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH;
+ arg.key = send_limit
+ ? const_cast<char*>(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH)
+ : const_cast<char*>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH);
arg.type = GRPC_ARG_INTEGER;
arg.value.integer = 5;
- grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
+ grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
if (send_limit) {
server_args = args;
} else {
@@ -360,18 +363,17 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
f = begin_test(config, "test_max_response_message_length", client_args,
server_args);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (client_args != NULL) grpc_channel_args_destroy(&exec_ctx, client_args);
- if (server_args != NULL) grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ if (client_args != nullptr) grpc_channel_args_destroy(client_args);
+ if (server_args != nullptr) grpc_channel_args_destroy(server_args);
}
cqv = cq_verifier_create(f.cq);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/service/method"),
get_host_override_slice("foo.test.google.fr:1234", config),
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -384,30 +386,30 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &recv_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -422,17 +424,17 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -440,9 +442,9 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -469,7 +471,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
grpc_byte_buffer_destroy(recv_payload);
grpc_call_unref(c);
- if (s != NULL) grpc_call_unref(s);
+ if (s != nullptr) grpc_call_unref(s);
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.cc
index c8667f4f4d..b752bf9482 100644
--- a/test/core/end2end/tests/negative_deadline.c
+++ b/test/core/end2end/tests/negative_deadline.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -88,10 +88,10 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f, size_t num_ops) {
- grpc_call *c;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
@@ -102,10 +102,10 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_REALTIME);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -118,24 +118,24 @@ static void simple_request_body(grpc_end2end_test_config config,
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
GPR_ASSERT(num_ops <= (size_t)(op - ops));
- error = grpc_call_start_batch(c, ops, num_ops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, num_ops, tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -156,7 +156,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config,
size_t num_ops) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
simple_request_body(config, f, num_ops);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.cc
index 4d77174e22..7d0318fda6 100644
--- a/test/core/end2end/tests/network_status_change.c
+++ b/test/core/end2end/tests/network_status_change.cc
@@ -31,12 +31,12 @@
/* this is a private API but exposed here for testing*/
extern void grpc_network_status_shutdown_all_endpoints();
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -53,31 +53,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(500);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -89,21 +89,21 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client sends a request with payload, server reads then returns status. */
static void test_invoke_network_status_change(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_invoke_request_with_payload", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -112,10 +112,10 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -128,30 +128,30 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -164,14 +164,14 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -184,7 +184,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -192,9 +192,9 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.cc
index f7d50c24dd..d89918bd3e 100644
--- a/test/core/end2end/tests/no_logging.c
+++ b/test/core/end2end/tests/no_logging.cc
@@ -28,18 +28,18 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/error.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
enum { TIMEOUT = 200000 };
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-extern void gpr_default_log(gpr_log_func_args *args);
+void gpr_default_log(gpr_log_func_args* args);
-static void test_no_log(gpr_log_func_args *args) {
- char *message = NULL;
+static void test_no_log(gpr_log_func_args* args) {
+ char* message = nullptr;
gpr_asprintf(&message, "Unwanted log: %s", args->message);
args->message = message;
gpr_default_log(args);
@@ -47,7 +47,7 @@ static void test_no_log(gpr_log_func_args *args) {
abort();
}
-static void test_no_error_log(gpr_log_func_args *args) {
+static void test_no_error_log(gpr_log_func_args* args) {
if (args->severity == GPR_LOG_SEVERITY_ERROR) {
test_no_log(args);
}
@@ -55,15 +55,15 @@ static void test_no_error_log(gpr_log_func_args *args) {
static gpr_atm g_log_func = (gpr_atm)gpr_default_log;
-static void log_dispatcher_func(gpr_log_func_args *args) {
+static void log_dispatcher_func(gpr_log_func_args* args) {
gpr_log_func log_func = (gpr_log_func)gpr_atm_no_barrier_load(&g_log_func);
log_func(args);
}
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -80,31 +80,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -116,11 +116,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -129,18 +129,18 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- char *peer;
+ char* peer;
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_free(peer);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -153,25 +153,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -182,10 +182,10 @@ static void simple_request_body(grpc_end2end_test_config config,
cq_verify(cqv);
peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_free(peer);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_free(peer);
memset(ops, 0, sizeof(ops));
@@ -193,7 +193,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -201,14 +201,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -239,7 +239,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
f = begin_test(config, "test_invoke_simple_request_with_no_error_logging",
- NULL, NULL);
+ nullptr, nullptr);
simple_request_body(config, f);
end_test(&f);
config.tear_down_data(&f);
@@ -249,7 +249,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_10_simple_requests_with_no_error_logging",
- NULL, NULL);
+ nullptr, nullptr);
for (i = 0; i < 10; i++) {
simple_request_body(config, f);
gpr_log(GPR_INFO, "Passed simple request %d", i);
@@ -273,7 +273,7 @@ static void test_no_error_logging_in_entire_process(
static void test_no_logging_in_one_request(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f =
- begin_test(config, "test_no_logging_in_last_request", NULL, NULL);
+ begin_test(config, "test_no_logging_in_last_request", nullptr, nullptr);
for (i = 0; i < 10; i++) {
simple_request_body(config, f);
}
diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.cc
index 8400c27486..18c2367ac4 100644
--- a/test/core/end2end/tests/no_op.c
+++ b/test/core/end2end/tests/no_op.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -85,7 +85,7 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void test_no_op(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = begin_test(config, "no-op", NULL, NULL);
+ grpc_end2end_test_fixture f = begin_test(config, "no-op", nullptr, nullptr);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.cc
index d98eed68e0..2e9513b9cb 100644
--- a/test/core/end2end/tests/payload.c
+++ b/test/core/end2end/tests/payload.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -89,9 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
static grpc_slice generate_random_slice() {
size_t i;
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
- char *output;
+ char* output;
const size_t output_size = 1024 * 1024;
- output = (char *)gpr_malloc(output_size);
+ output = (char*)gpr_malloc(output_size);
for (i = 0; i < output_size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}
@@ -109,20 +109,20 @@ static void request_response_with_payload(grpc_end2end_test_config config,
grpc_slice request_payload_slice = generate_random_slice();
grpc_slice response_payload_slice = generate_random_slice();
- grpc_call *c;
- grpc_call *s;
- grpc_byte_buffer *request_payload =
+ grpc_call* c;
+ grpc_call* s;
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -131,10 +131,10 @@ static void request_response_with_payload(grpc_end2end_test_config config,
gpr_timespec deadline = n_seconds_from_now(60);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -147,35 +147,35 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -190,14 +190,14 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -208,12 +208,12 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -221,9 +221,9 @@ static void request_response_with_payload(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -262,7 +262,7 @@ static void request_response_with_payload(grpc_end2end_test_config config,
static void test_invoke_request_response_with_payload(
grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(
- config, "test_invoke_request_response_with_payload", NULL, NULL);
+ config, "test_invoke_request_response_with_payload", nullptr, nullptr);
request_response_with_payload(config, f);
end_test(&f);
config.tear_down_data(&f);
@@ -272,7 +272,7 @@ static void test_invoke_10_request_response_with_payload(
grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f = begin_test(
- config, "test_invoke_10_request_response_with_payload", NULL, NULL);
+ config, "test_invoke_10_request_response_with_payload", nullptr, nullptr);
for (i = 0; i < 10; i++) {
request_response_with_payload(config, f);
}
diff --git a/test/core/end2end/tests/ping.c b/test/core/end2end/tests/ping.cc
index 23c82569ba..725a425fbf 100644
--- a/test/core/end2end/tests/ping.c
+++ b/test/core/end2end/tests/ping.cc
@@ -28,41 +28,41 @@
#define PING_NUM 5
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static void test_ping(grpc_end2end_test_config config,
int min_time_between_pings_ms) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
int i;
- grpc_arg client_a[] = {
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS,
- .value.integer = 10},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA,
- .value.integer = 0},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS,
- .value.integer = 1}};
- grpc_arg server_a[] = {
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS,
- .value.integer = 0},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS,
- .value.integer = 1}};
- grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(client_a),
- .args = client_a};
- grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
- .args = server_a};
+ grpc_arg client_a[3];
+ client_a[0].type = GRPC_ARG_INTEGER;
+ client_a[0].key =
+ const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS);
+ client_a[0].value.integer = 10;
+ client_a[1].type = GRPC_ARG_INTEGER;
+ client_a[1].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA);
+ client_a[1].value.integer = 0;
+ client_a[2].type = GRPC_ARG_INTEGER;
+ client_a[2].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS);
+ client_a[2].value.integer = 1;
+ grpc_arg server_a[2];
+ server_a[0].type = GRPC_ARG_INTEGER;
+ server_a[0].key =
+ const_cast<char*>(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS);
+ server_a[0].value.integer = 0;
+ server_a[1].type = GRPC_ARG_INTEGER;
+ server_a[1].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS);
+ server_a[1].value.integer = 1;
+ grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
config.init_client(&f, &client_args);
config.init_server(&f, &server_args);
- grpc_channel_ping(f.client, f.cq, tag(0), NULL);
+ grpc_channel_ping(f.client, f.cq, tag(0), nullptr);
CQ_EXPECT_COMPLETION(cqv, tag(0), 0);
/* check that we're still in idle, and start connecting */
@@ -86,7 +86,7 @@ static void test_ping(grpc_end2end_test_config config,
}
for (i = 1; i <= PING_NUM; i++) {
- grpc_channel_ping(f.client, f.cq, tag(i), NULL);
+ grpc_channel_ping(f.client, f.cq, tag(i), nullptr);
CQ_EXPECT_COMPLETION(cqv, tag(i), 1);
cq_verify(cqv);
}
diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.cc
index 1c44262c3d..ec7981fdcb 100644
--- a/test/core/end2end/tests/ping_pong_streaming.c
+++ b/test/core/end2end/tests/ping_pong_streaming.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -88,12 +88,12 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_pingpong_streaming(grpc_end2end_test_config config,
int messages) {
grpc_end2end_test_fixture f =
- begin_test(config, "test_pingpong_streaming", NULL, NULL);
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_pingpong_streaming", nullptr, nullptr);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -102,10 +102,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- grpc_byte_buffer *request_payload;
- grpc_byte_buffer *request_payload_recv;
- grpc_byte_buffer *response_payload;
- grpc_byte_buffer *response_payload_recv;
+ grpc_byte_buffer* request_payload;
+ grpc_byte_buffer* request_payload_recv;
+ grpc_byte_buffer* response_payload;
+ grpc_byte_buffer* response_payload_recv;
int i;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
@@ -114,10 +114,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -130,21 +130,21 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -159,14 +159,14 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < messages; i++) {
@@ -178,14 +178,14 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -193,9 +193,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
cq_verify(cqv);
@@ -205,9 +206,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -226,9 +228,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -239,9 +241,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/proxy_auth.c b/test/core/end2end/tests/proxy_auth.cc
index d922049bcb..495151b592 100644
--- a/test/core/end2end/tests/proxy_auth.c
+++ b/test/core/end2end/tests/proxy_auth.cc
@@ -32,15 +32,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -57,31 +57,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -93,11 +93,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -106,18 +106,18 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- char *peer;
+ char* peer;
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
gpr_free(peer);
@@ -131,25 +131,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -160,11 +160,11 @@ static void simple_request_body(grpc_end2end_test_config config,
cq_verify(cqv);
peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "server_peer=%s", peer);
gpr_free(peer);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
@@ -173,7 +173,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -181,14 +181,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -217,12 +217,13 @@ static void simple_request_body(grpc_end2end_test_config config,
static void test_invoke_proxy_auth(grpc_end2end_test_config config) {
/* Indicate that the proxy requires user auth */
- grpc_arg client_arg = {.type = GRPC_ARG_STRING,
- .key = GRPC_ARG_HTTP_PROXY_AUTH_CREDS,
- .value.string = GRPC_TEST_HTTP_PROXY_AUTH_CREDS};
- grpc_channel_args client_args = {.num_args = 1, .args = &client_arg};
+ grpc_arg client_arg;
+ client_arg.type = GRPC_ARG_STRING;
+ client_arg.key = const_cast<char*>(GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
+ client_arg.value.string = const_cast<char*>(GRPC_TEST_HTTP_PROXY_AUTH_CREDS);
+ grpc_channel_args client_args = {1, &client_arg};
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_proxy_auth", &client_args, NULL);
+ begin_test(config, "test_invoke_proxy_auth", &client_args, nullptr);
simple_request_body(config, f);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.cc
index 4598029818..cefa89db4d 100644
--- a/test/core/end2end/tests/registered_call.c
+++ b/test/core/end2end/tests/registered_call.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -87,12 +87,12 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void simple_request_body(grpc_end2end_test_config config,
- grpc_end2end_test_fixture f, void *rc) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f, void* rc) {
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -104,7 +104,7 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_registered_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, deadline, NULL);
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, deadline, nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -117,25 +117,25 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -150,7 +150,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -158,14 +158,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -193,10 +193,10 @@ static void simple_request_body(grpc_end2end_test_config config,
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_simple_request", NULL, NULL);
- void *rc = grpc_channel_register_call(
+ begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
+ void* rc = grpc_channel_register_call(
f.client, "/foo",
- get_host_override_string("foo.test.google.fr:1234", config), NULL);
+ get_host_override_string("foo.test.google.fr:1234", config), nullptr);
simple_request_body(config, f, rc);
end_test(&f);
@@ -206,10 +206,10 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) {
static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
- void *rc = grpc_channel_register_call(
+ begin_test(config, "test_invoke_10_simple_requests", nullptr, nullptr);
+ void* rc = grpc_channel_register_call(
f.client, "/foo",
- get_host_override_string("foo.test.google.fr:1234", config), NULL);
+ get_host_override_string("foo.test.google.fr:1234", config), nullptr);
for (i = 0; i < 10; i++) {
simple_request_body(config, f, rc);
diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.cc
index dfb7d58743..984d8b10f1 100644
--- a/test/core/end2end/tests/request_with_flags.c
+++ b/test/core/end2end/tests/request_with_flags.cc
@@ -29,12 +29,12 @@
#include "src/core/lib/transport/byte_stream.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -51,31 +51,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,22 +86,22 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void test_invoke_request_with_flags(
- grpc_end2end_test_config config, uint32_t *flags_for_op,
+ grpc_end2end_test_config config, uint32_t* flags_for_op,
grpc_call_error call_start_batch_expected_result) {
- grpc_call *c;
+ grpc_call* c;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_flags", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_invoke_request_with_flags", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -110,10 +110,10 @@ static void test_invoke_request_with_flags(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -126,31 +126,31 @@ static void test_invoke_request_with_flags(
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = flags_for_op[op->op];
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = flags_for_op[op->op];
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = flags_for_op[op->op];
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = flags_for_op[op->op];
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = flags_for_op[op->op];
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
expectation = call_start_batch_expected_result;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(expectation == error);
if (expectation == GRPC_CALL_OK) {
diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.cc
index 575e54c7d9..b3b9ee5726 100644
--- a/test/core/end2end/tests/request_with_payload.c
+++ b/test/core/end2end/tests/request_with_payload.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,21 +86,21 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client sends a request with payload, server reads then returns status. */
static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_invoke_request_with_payload", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -109,10 +109,10 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -125,30 +125,30 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -162,14 +162,14 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -180,7 +180,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -188,9 +188,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.cc
index 93befeee0c..0ee014f97d 100644
--- a/test/core/end2end/tests/resource_quota_server.c
+++ b/test/core/end2end/tests/resource_quota_server.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -89,9 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
static grpc_slice generate_random_slice() {
size_t i;
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
- char *output;
+ char* output;
const size_t output_size = 1024 * 1024;
- output = (char *)gpr_malloc(output_size);
+ output = (char*)gpr_malloc(output_size);
for (i = 0; i < output_size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}
@@ -106,7 +106,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
FEATURE_MASK_DOES_NOT_SUPPORT_RESOURCE_QUOTA_SERVER) {
return;
}
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("test_server");
grpc_resource_quota_resize(resource_quota, 5 * 1024 * 1024);
@@ -117,40 +117,40 @@ void resource_quota_server(grpc_end2end_test_config config) {
#define SERVER_END_BASE_TAG 0x4000
grpc_arg arg;
- arg.key = GRPC_ARG_RESOURCE_QUOTA;
+ arg.key = const_cast<char*>(GRPC_ARG_RESOURCE_QUOTA);
arg.type = GRPC_ARG_POINTER;
arg.value.pointer.p = resource_quota;
arg.value.pointer.vtable = grpc_resource_quota_arg_vtable();
grpc_channel_args args = {1, &arg};
grpc_end2end_test_fixture f =
- begin_test(config, "resource_quota_server", NULL, &args);
+ begin_test(config, "resource_quota_server", nullptr, &args);
/* Create large request and response bodies. These are big enough to require
* multiple round trips to deliver to the peer, and their exact contents of
* will be verified on completion. */
grpc_slice request_payload_slice = generate_random_slice();
- grpc_call **client_calls =
- (grpc_call **)malloc(sizeof(grpc_call *) * NUM_CALLS);
- grpc_call **server_calls =
- (grpc_call **)malloc(sizeof(grpc_call *) * NUM_CALLS);
- grpc_metadata_array *initial_metadata_recv =
- (grpc_metadata_array *)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
- grpc_metadata_array *trailing_metadata_recv =
- (grpc_metadata_array *)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
- grpc_metadata_array *request_metadata_recv =
- (grpc_metadata_array *)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
- grpc_call_details *call_details =
- (grpc_call_details *)malloc(sizeof(grpc_call_details) * NUM_CALLS);
- grpc_status_code *status =
- (grpc_status_code *)malloc(sizeof(grpc_status_code) * NUM_CALLS);
- grpc_slice *details = (grpc_slice *)malloc(sizeof(grpc_slice) * NUM_CALLS);
- grpc_byte_buffer **request_payload =
- (grpc_byte_buffer **)malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS);
- grpc_byte_buffer **request_payload_recv =
- (grpc_byte_buffer **)malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS);
- int *was_cancelled = (int *)malloc(sizeof(int) * NUM_CALLS);
+ grpc_call** client_calls =
+ (grpc_call**)malloc(sizeof(grpc_call*) * NUM_CALLS);
+ grpc_call** server_calls =
+ (grpc_call**)malloc(sizeof(grpc_call*) * NUM_CALLS);
+ grpc_metadata_array* initial_metadata_recv =
+ (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
+ grpc_metadata_array* trailing_metadata_recv =
+ (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
+ grpc_metadata_array* request_metadata_recv =
+ (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
+ grpc_call_details* call_details =
+ (grpc_call_details*)malloc(sizeof(grpc_call_details) * NUM_CALLS);
+ grpc_status_code* status =
+ (grpc_status_code*)malloc(sizeof(grpc_status_code) * NUM_CALLS);
+ grpc_slice* details = (grpc_slice*)malloc(sizeof(grpc_slice) * NUM_CALLS);
+ grpc_byte_buffer** request_payload =
+ (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS);
+ grpc_byte_buffer** request_payload_recv =
+ (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS);
+ int* was_cancelled = (int*)malloc(sizeof(int) * NUM_CALLS);
grpc_call_error error;
int pending_client_calls = 0;
int pending_server_start_calls = 0;
@@ -162,7 +162,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
int unavailable = 0;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
for (int i = 0; i < NUM_CALLS; i++) {
grpc_metadata_array_init(&initial_metadata_recv[i]);
@@ -170,7 +170,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
grpc_metadata_array_init(&request_metadata_recv[i]);
grpc_call_details_init(&call_details[i]);
request_payload[i] = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- request_payload_recv[i] = NULL;
+ request_payload_recv[i] = nullptr;
was_cancelled[i] = 0;
}
@@ -185,32 +185,32 @@ void resource_quota_server(grpc_end2end_test_config config) {
for (int i = 0; i < NUM_CALLS; i++) {
client_calls[i] = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr", config),
- n_seconds_from_now(60), NULL);
+ n_seconds_from_now(60), nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload[i];
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv[i];
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata =
@@ -218,10 +218,10 @@ void resource_quota_server(grpc_end2end_test_config config) {
op->data.recv_status_on_client.status = &status[i];
op->data.recv_status_on_client.status_details = &details[i];
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
error = grpc_call_start_batch(client_calls[i], ops, (size_t)(op - ops),
- tag(CLIENT_BASE_TAG + i), NULL);
+ tag(CLIENT_BASE_TAG + i), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
pending_client_calls++;
@@ -231,7 +231,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
pending_server_end_calls >
0) {
grpc_event ev =
- grpc_completion_queue_next(f.cq, n_seconds_from_now(60), NULL);
+ grpc_completion_queue_next(f.cq, n_seconds_from_now(60), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
int ev_tag = (int)(intptr_t)ev.tag;
@@ -278,16 +278,16 @@ void resource_quota_server(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv[call_id];
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
error =
grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
- tag(SERVER_RECV_BASE_TAG + call_id), NULL);
+ tag(SERVER_RECV_BASE_TAG + call_id), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(pending_server_start_calls > 0);
@@ -303,12 +303,12 @@ void resource_quota_server(grpc_end2end_test_config config) {
GPR_ASSERT(call_id < NUM_CALLS);
if (ev.success) {
- if (request_payload_recv[call_id] != NULL) {
+ if (request_payload_recv[call_id] != nullptr) {
grpc_byte_buffer_destroy(request_payload_recv[call_id]);
- request_payload_recv[call_id] = NULL;
+ request_payload_recv[call_id] = nullptr;
}
} else {
- GPR_ASSERT(request_payload_recv[call_id] == NULL);
+ GPR_ASSERT(request_payload_recv[call_id] == nullptr);
}
memset(ops, 0, sizeof(ops));
@@ -316,7 +316,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled[call_id];
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -324,11 +324,11 @@ void resource_quota_server(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
error =
grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
- tag(SERVER_END_BASE_TAG + call_id), NULL);
+ tag(SERVER_END_BASE_TAG + call_id), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(pending_server_recv_calls > 0);
diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.cc
index 49b9f27396..743b3aeb91 100644
--- a/test/core/end2end/tests/server_finishes_request.c
+++ b/test/core/end2end/tests/server_finishes_request.cc
@@ -27,15 +27,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -88,11 +88,11 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -104,10 +104,10 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -120,21 +120,21 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -149,7 +149,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -157,14 +157,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -193,7 +193,7 @@ static void simple_request_body(grpc_end2end_test_config config,
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
simple_request_body(config, f);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.cc
index cef571b490..fce23f3b6a 100644
--- a/test/core/end2end/tests/shutdown_finishes_calls.c
+++ b/test/core/end2end/tests/shutdown_finishes_calls.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,20 +50,20 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_client(f);
grpc_completion_queue_shutdown(f->cq);
@@ -75,13 +75,14 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_early_server_shutdown_finishes_inflight_calls(
grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
- grpc_end2end_test_fixture f = begin_test(
- config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_early_server_shutdown_finishes_inflight_calls",
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -93,10 +94,10 @@ static void test_early_server_shutdown_finishes_inflight_calls(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -108,27 +109,27 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->data.send_initial_metadata.metadata = NULL;
+ op->data.send_initial_metadata.metadata = nullptr;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -143,9 +144,9 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* shutdown and destroy the server */
@@ -159,7 +160,9 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_server_destroy(f.server);
- GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
+ // new code should give INTERNAL, some older code will give UNAVAILABLE
+ GPR_ASSERT(status == GRPC_STATUS_INTERNAL ||
+ status == GRPC_STATUS_UNAVAILABLE);
GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
validate_host_override_string("foo.test.google.fr:1234", call_details.host,
config);
diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.cc
index 7914cc95ba..de64eba612 100644
--- a/test/core/end2end/tests/shutdown_finishes_tags.c
+++ b/test/core/end2end/tests/shutdown_finishes_tags.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,20 +50,20 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_client(f);
grpc_completion_queue_shutdown(f->cq);
@@ -76,9 +76,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_early_server_shutdown_finishes_tags(
grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(
- config, "test_early_server_shutdown_finishes_tags", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
- grpc_call *s = (grpc_call *)(uintptr_t)1;
+ config, "test_early_server_shutdown_finishes_tags", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_call* s = (grpc_call*)(uintptr_t)1;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
@@ -94,7 +94,7 @@ static void test_early_server_shutdown_finishes_tags(
CQ_EXPECT_COMPLETION(cqv, tag(101), 0);
CQ_EXPECT_COMPLETION(cqv, tag(1000), 1);
cq_verify(cqv);
- GPR_ASSERT(s == NULL);
+ GPR_ASSERT(s == nullptr);
grpc_server_destroy(f.server);
diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.cc
index faa5c193dc..d8034dcf6d 100644
--- a/test/core/end2end/tests/simple_cacheable_request.c
+++ b/test/core/end2end/tests/simple_cacheable_request.cc
@@ -30,12 +30,12 @@
enum { TIMEOUT = 200000 };
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -52,31 +52,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -89,43 +89,43 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Request/response with metadata and payload.*/
static void test_cacheable_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"),
grpc_slice_from_static_string("val1"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key2"),
grpc_slice_from_static_string("val2"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_metadata meta_s[2] = {{grpc_slice_from_static_string("key3"),
grpc_slice_from_static_string("val3"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key4"),
grpc_slice_from_static_string("val4"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_end2end_test_fixture f = begin_test(
- config, "test_cacheable_request_response_with_metadata_and_payload", NULL,
- NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ config, "test_cacheable_request_response_with_metadata_and_payload",
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -134,10 +134,10 @@ static void test_cacheable_request_response_with_metadata_and_payload(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -151,35 +151,35 @@ static void test_cacheable_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_c;
op->flags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -195,14 +195,14 @@ static void test_cacheable_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_s;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -213,12 +213,12 @@ static void test_cacheable_request_response_with_metadata_and_payload(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -226,9 +226,9 @@ static void test_cacheable_request_response_with_metadata_and_payload(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.cc
index c3f66a07aa..0ad224f579 100644
--- a/test/core/end2end/tests/simple_delayed_request.c
+++ b/test/core/end2end/tests/simple_delayed_request.cc
@@ -28,7 +28,7 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static gpr_timespec n_seconds_from_now(int n) {
return grpc_timeout_seconds_to_deadline(n);
@@ -38,31 +38,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -73,15 +73,15 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void simple_delayed_request_body(grpc_end2end_test_config config,
- grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args,
+ grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args,
long delay_us) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f->cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f->cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -96,10 +96,10 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
+ f->client, nullptr, GRPC_PROPAGATE_DEFAULTS, f->cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -112,25 +112,25 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -145,7 +145,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -153,14 +153,14 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -191,16 +191,17 @@ static void test_simple_delayed_request_short(grpc_end2end_test_config config) {
grpc_channel_args client_args;
grpc_arg arg_array[1];
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = 1000;
client_args.args = arg_array;
client_args.num_args = 1;
gpr_log(GPR_INFO, "Running test: %s/%s", "test_simple_delayed_request_short",
config.name);
- f = config.create_fixture(NULL, NULL);
+ f = config.create_fixture(nullptr, nullptr);
- simple_delayed_request_body(config, &f, &client_args, NULL, 100000);
+ simple_delayed_request_body(config, &f, &client_args, nullptr, 100000);
end_test(&f);
config.tear_down_data(&f);
}
@@ -210,16 +211,17 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) {
grpc_channel_args client_args;
grpc_arg arg_array[1];
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = 1000;
client_args.args = arg_array;
client_args.num_args = 1;
gpr_log(GPR_INFO, "Running test: %s/%s", "test_simple_delayed_request_long",
config.name);
- f = config.create_fixture(NULL, NULL);
+ f = config.create_fixture(nullptr, nullptr);
/* This timeout should be longer than a single retry */
- simple_delayed_request_body(config, &f, &client_args, NULL, 1500000);
+ simple_delayed_request_body(config, &f, &client_args, nullptr, 1500000);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.cc
index 17e7f696e2..1a741169d4 100644
--- a/test/core/end2end/tests/simple_metadata.c
+++ b/test/core/end2end/tests/simple_metadata.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -87,42 +87,43 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Request/response with metadata and payload.*/
static void test_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"),
grpc_slice_from_static_string("val1"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key2"),
grpc_slice_from_static_string("val2"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_metadata meta_s[2] = {{grpc_slice_from_static_string("key3"),
grpc_slice_from_static_string("val3"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key4"),
grpc_slice_from_static_string("val4"),
0,
- {{NULL, NULL, NULL, NULL}}}};
- grpc_end2end_test_fixture f = begin_test(
- config, "test_request_response_with_metadata_and_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ {{nullptr, nullptr, nullptr, nullptr}}}};
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_request_response_with_metadata_and_payload",
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -131,10 +132,10 @@ static void test_request_response_with_metadata_and_payload(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -148,35 +149,35 @@ static void test_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_c;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -192,14 +193,14 @@ static void test_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_s;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -210,12 +211,12 @@ static void test_request_response_with_metadata_and_payload(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -223,9 +224,9 @@ static void test_request_response_with_metadata_and_payload(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.cc
index 7ce7e1f285..ae93f79c9d 100644
--- a/test/core/end2end/tests/simple_request.c
+++ b/test/core/end2end/tests/simple_request.cc
@@ -28,15 +28,15 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -53,31 +53,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -89,35 +89,38 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void simple_request_body(grpc_end2end_test_config config,
grpc_end2end_test_fixture f) {
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
grpc_call_details call_details;
grpc_status_code status;
+ const char* error_string;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- char *peer;
- grpc_stats_data *before = gpr_malloc(sizeof(grpc_stats_data));
- grpc_stats_data *after = gpr_malloc(sizeof(grpc_stats_data));
+ char* peer;
+ grpc_stats_data* before =
+ static_cast<grpc_stats_data*>(gpr_malloc(sizeof(grpc_stats_data)));
+ grpc_stats_data* after =
+ static_cast<grpc_stats_data*>(gpr_malloc(sizeof(grpc_stats_data)));
grpc_stats_collect(before);
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
gpr_free(peer);
@@ -131,25 +134,26 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.error_string = &error_string;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -160,11 +164,11 @@ static void simple_request_body(grpc_end2end_test_config config,
cq_verify(cqv);
peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "server_peer=%s", peer);
gpr_free(peer);
peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
+ GPR_ASSERT(peer != nullptr);
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
@@ -173,7 +177,7 @@ static void simple_request_body(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -181,14 +185,14 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -197,6 +201,15 @@ static void simple_request_body(grpc_end2end_test_config config,
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
+ // the following sanity check makes sure that the requested error string is
+ // correctly populated by the core. It looks for certain substrings that are
+ // not likely to change much. Some parts of the error, like time created,
+ // obviously are not checked.
+ GPR_ASSERT(nullptr != strstr(error_string, "xyz"));
+ GPR_ASSERT(nullptr != strstr(error_string, "description"));
+ GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer"));
+ GPR_ASSERT(nullptr != strstr(error_string, "grpc_message"));
+ GPR_ASSERT(nullptr != strstr(error_string, "grpc_status"));
GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
validate_host_override_string("foo.test.google.fr:1234", call_details.host,
config);
@@ -204,6 +217,7 @@ static void simple_request_body(grpc_end2end_test_config config,
GPR_ASSERT(was_cancelled == 1);
grpc_slice_unref(details);
+ gpr_free((void*)error_string);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
grpc_metadata_array_destroy(&request_metadata_recv);
@@ -216,7 +230,7 @@ static void simple_request_body(grpc_end2end_test_config config,
grpc_stats_collect(after);
- char *stats = grpc_stats_data_as_json(after);
+ char* stats = grpc_stats_data_as_json(after);
gpr_log(GPR_DEBUG, "%s", stats);
gpr_free(stats);
@@ -237,7 +251,7 @@ static void simple_request_body(grpc_end2end_test_config config,
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
simple_request_body(config, f);
end_test(&f);
config.tear_down_data(&f);
@@ -246,7 +260,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) {
static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
+ begin_test(config, "test_invoke_10_simple_requests", nullptr, nullptr);
for (i = 0; i < 10; i++) {
simple_request_body(config, f);
gpr_log(GPR_INFO, "Running test: Passed simple request %d", i);
diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.c b/test/core/end2end/tests/stream_compression_compressed_payload.cc
index 094c4de1c0..9a384441f0 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.c
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -36,12 +36,12 @@
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -58,31 +58,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -93,30 +93,30 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void request_for_disabled_algorithm(
- grpc_end2end_test_config config, const char *test_name,
+ grpc_end2end_test_config config, const char* test_name,
uint32_t send_flags_bitmask,
- grpc_stream_compression_algorithm algorithm_to_disable,
- grpc_stream_compression_algorithm requested_client_compression_algorithm,
- grpc_status_code expected_error, grpc_metadata *client_metadata) {
- grpc_call *c;
- grpc_call *s;
+ grpc_compression_algorithm algorithm_to_disable,
+ grpc_compression_algorithm requested_client_compression_algorithm,
+ grpc_status_code expected_error, grpc_metadata* client_metadata) {
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer *request_payload;
- grpc_channel_args *client_args;
- grpc_channel_args *server_args;
+ grpc_byte_buffer* request_payload;
+ grpc_channel_args* client_args;
+ grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- cq_verifier *cqv;
+ cq_verifier* cqv;
char str[1024];
memset(str, 'x', 1023);
@@ -124,15 +124,14 @@ static void request_for_disabled_algorithm(
request_payload_slice = grpc_slice_from_copied_string(str);
request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- client_args = grpc_channel_args_set_stream_compression_algorithm(
- NULL, requested_client_compression_algorithm);
- server_args = grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_NONE);
+ client_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, requested_client_compression_algorithm);
+ server_args =
+ grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- server_args = grpc_channel_args_stream_compression_algorithm_set_state(
- &exec_ctx, &server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ server_args = grpc_channel_args_compression_algorithm_set_state(
+ &server_args, algorithm_to_disable, false);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -140,10 +139,10 @@ static void request_for_disabled_algorithm(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -159,54 +158,55 @@ static void request_for_disabled_algorithm(
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- if (client_metadata != NULL) {
+ if (client_metadata != nullptr) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = client_metadata;
} else {
op->data.send_initial_metadata.count = 0;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), true);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), true);
cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), false);
@@ -215,13 +215,12 @@ static void request_for_disabled_algorithm(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), true);
- CQ_EXPECT_COMPLETION(cqv, tag(1), true);
cq_verify(cqv);
/* call was cancelled (closed) ... */
@@ -229,12 +228,11 @@ static void request_for_disabled_algorithm(
/* with a certain error */
GPR_ASSERT(status == expected_error);
- const char *algo_name = NULL;
- GPR_ASSERT(
- grpc_stream_compression_algorithm_name(algorithm_to_disable, &algo_name));
- char *expected_details = NULL;
- gpr_asprintf(&expected_details,
- "Stream compression algorithm '%s' is disabled.", algo_name);
+ const char* algo_name = nullptr;
+ GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name));
+ char* expected_details = nullptr;
+ gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.",
+ algo_name);
/* and we expect a specific reason for it */
GPR_ASSERT(0 == grpc_slice_str_cmp(details, expected_details));
gpr_free(expected_details);
@@ -258,10 +256,9 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -269,40 +266,38 @@ static void request_for_disabled_algorithm(
}
static void request_with_payload_template(
- grpc_end2end_test_config config, const char *test_name,
+ grpc_end2end_test_config config, const char* test_name,
uint32_t client_send_flags_bitmask,
- grpc_stream_compression_algorithm
- default_client_channel_compression_algorithm,
- grpc_stream_compression_algorithm
- default_server_channel_compression_algorithm,
- grpc_stream_compression_algorithm expected_client_compression_algorithm,
- grpc_stream_compression_algorithm expected_server_compression_algorithm,
- grpc_metadata *client_init_metadata, bool set_server_level,
- grpc_stream_compression_level server_compression_level,
+ grpc_compression_algorithm default_client_channel_compression_algorithm,
+ grpc_compression_algorithm default_server_channel_compression_algorithm,
+ grpc_compression_algorithm expected_client_compression_algorithm,
+ grpc_compression_algorithm expected_server_compression_algorithm,
+ grpc_metadata* client_init_metadata, bool set_server_level,
+ grpc_compression_level server_compression_level,
bool send_message_before_initial_metadata,
bool set_default_server_message_compression_algorithm,
grpc_compression_algorithm default_server_message_compression_algorithm) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer *request_payload = NULL;
- grpc_channel_args *client_args;
- grpc_channel_args *server_args;
+ grpc_byte_buffer* request_payload = nullptr;
+ grpc_channel_args* client_args;
+ grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload;
- grpc_byte_buffer *response_payload_recv;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload;
+ grpc_byte_buffer* response_payload_recv;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- cq_verifier *cqv;
+ cq_verifier* cqv;
char request_str[1024];
char response_str[1024];
@@ -316,14 +311,14 @@ static void request_with_payload_template(
grpc_slice response_payload_slice =
grpc_slice_from_copied_string(response_str);
- client_args = grpc_channel_args_set_stream_compression_algorithm(
- NULL, default_client_channel_compression_algorithm);
+ client_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, default_client_channel_compression_algorithm);
if (set_default_server_message_compression_algorithm) {
server_args = grpc_channel_args_set_compression_algorithm(
- NULL, default_server_message_compression_algorithm);
+ nullptr, default_server_message_compression_algorithm);
} else {
- server_args = grpc_channel_args_set_stream_compression_algorithm(
- NULL, default_server_channel_compression_algorithm);
+ server_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, default_server_channel_compression_algorithm);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -331,10 +326,10 @@ static void request_with_payload_template(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -349,9 +344,9 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = client_send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
}
@@ -359,28 +354,28 @@ static void request_with_payload_template(
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- if (client_init_metadata != NULL) {
+ if (client_init_metadata != nullptr) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = client_init_metadata;
} else {
op->data.send_initial_metadata.count = 0;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -395,37 +390,32 @@ static void request_with_payload_template(
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_NONE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_DEFLATE) != 0);
+ GRPC_COMPRESS_MESSAGE_DEFLATE) != 0);
+ GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
+ GRPC_COMPRESS_MESSAGE_GZIP) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_GZIP) != 0);
- GPR_ASSERT(
- GPR_BITCOUNT(grpc_call_test_only_get_stream_encodings_accepted_by_peer(
- s)) == GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT);
- GPR_ASSERT(
- GPR_BITGET(grpc_call_test_only_get_stream_encodings_accepted_by_peer(s),
- GRPC_STREAM_COMPRESS_NONE) != 0);
- GPR_ASSERT(
- GPR_BITGET(grpc_call_test_only_get_stream_encodings_accepted_by_peer(s),
- GRPC_STREAM_COMPRESS_GZIP) != 0);
+ GRPC_COMPRESS_STREAM_GZIP) != 0);
+ GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer(
+ s)) == GRPC_COMPRESS_ALGORITHMS_COUNT);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
if (set_server_level) {
- op->data.send_initial_metadata.maybe_stream_compression_level.is_set = true;
- op->data.send_initial_metadata.maybe_stream_compression_level.level =
+ op->data.send_initial_metadata.maybe_compression_level.is_set = true;
+ op->data.send_initial_metadata.maybe_compression_level.level =
server_compression_level;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (int i = 0; i < 2; i++) {
@@ -438,9 +428,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = client_send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error =
+ grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
}
@@ -450,9 +441,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -466,9 +458,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -476,9 +469,9 @@ static void request_with_payload_template(
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -501,9 +494,9 @@ static void request_with_payload_template(
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -514,9 +507,9 @@ static void request_with_payload_template(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -544,10 +537,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -558,30 +550,20 @@ static void test_invoke_request_with_compressed_payload(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload", 0,
- GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP,
- GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, NULL,
+ GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP,
+ GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, nullptr,
false, /* ignored */
- GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE);
+ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE);
}
static void test_invoke_request_with_send_message_before_initial_metadata(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_send_message_before_initial_metadata",
- 0, GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP,
- GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, NULL,
+ 0, GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP,
+ GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, nullptr,
false, /* ignored */
- GRPC_STREAM_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE);
-}
-
-static void test_invoke_request_with_server_level(
- grpc_end2end_test_config config) {
- request_with_payload_template(
- config, "test_invoke_request_with_server_level", 0,
- GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE,
- GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_GZIP,
- /* ignored */ NULL, true, GRPC_STREAM_COMPRESS_LEVEL_HIGH, false, false,
- GRPC_COMPRESS_NONE);
+ GRPC_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE);
}
static void test_invoke_request_with_compressed_payload_md_override(
@@ -591,7 +573,8 @@ static void test_invoke_request_with_compressed_payload_md_override(
gzip_compression_override.key =
GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST;
- gzip_compression_override.value = grpc_slice_from_static_string("gzip");
+ gzip_compression_override.value =
+ grpc_slice_from_static_string("stream/gzip");
memset(&gzip_compression_override.internal_data, 0,
sizeof(gzip_compression_override.internal_data));
@@ -605,49 +588,31 @@ static void test_invoke_request_with_compressed_payload_md_override(
/* Channel default NONE (aka IDENTITY), call override to stream GZIP */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_1", 0,
- GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE,
- GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_NONE,
- &gzip_compression_override, false,
- /*ignored*/ GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false,
- GRPC_COMPRESS_NONE);
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_STREAM_GZIP,
+ GRPC_COMPRESS_NONE, &gzip_compression_override, false,
+ /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE);
/* Channel default stream GZIP, call override to NONE (aka IDENTITY) */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_3", 0,
- GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_NONE,
- GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE,
- &identity_compression_override, false,
- /*ignored*/ GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false,
- GRPC_COMPRESS_NONE);
+ GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
+ GRPC_COMPRESS_NONE, &identity_compression_override, false,
+ /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE);
}
static void test_invoke_request_with_disabled_algorithm(
grpc_end2end_test_config config) {
request_for_disabled_algorithm(
config, "test_invoke_request_with_disabled_algorithm", 0,
- GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP,
- GRPC_STATUS_UNIMPLEMENTED, NULL);
-}
-
-static void test_stream_compression_override_message_compression(
- grpc_end2end_test_config config) {
- grpc_stream_compression_level level = GRPC_STREAM_COMPRESS_LEVEL_MED;
- request_with_payload_template(
- config, "test_stream_compression_override_message_compression", 0,
- GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE,
- GRPC_STREAM_COMPRESS_NONE,
- grpc_stream_compression_algorithm_for_level(
- level, (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1),
- /* ignored */ NULL, true, level, false, true, GRPC_COMPRESS_GZIP);
+ GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP,
+ GRPC_STATUS_UNIMPLEMENTED, nullptr);
}
void stream_compression_compressed_payload(grpc_end2end_test_config config) {
test_invoke_request_with_compressed_payload(config);
test_invoke_request_with_send_message_before_initial_metadata(config);
- test_invoke_request_with_server_level(config);
test_invoke_request_with_compressed_payload_md_override(config);
test_invoke_request_with_disabled_algorithm(config);
- test_stream_compression_override_message_compression(config);
}
void stream_compression_compressed_payload_pre_init(void) {}
diff --git a/test/core/end2end/tests/stream_compression_payload.c b/test/core/end2end/tests/stream_compression_payload.cc
index e47d2aa93c..9a27957fee 100644
--- a/test/core/end2end/tests/stream_compression_payload.c
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -23,7 +23,6 @@
#include <grpc/byte_buffer.h>
#include <grpc/compression.h>
-#include <grpc/compression.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@@ -32,12 +31,12 @@
#include "src/core/lib/surface/call.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -54,31 +53,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -93,9 +92,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
static grpc_slice generate_random_slice() {
size_t i;
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
- char *output;
+ char* output;
const size_t output_size = 1024 * 1024;
- output = (char *)gpr_malloc(output_size);
+ output = (char*)gpr_malloc(output_size);
for (i = 0; i < output_size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}
@@ -113,20 +112,20 @@ static void request_response_with_payload(grpc_end2end_test_config config,
grpc_slice request_payload_slice = generate_random_slice();
grpc_slice response_payload_slice = generate_random_slice();
- grpc_call *c;
- grpc_call *s;
- grpc_byte_buffer *request_payload =
+ grpc_call* c;
+ grpc_call* s;
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -135,10 +134,10 @@ static void request_response_with_payload(grpc_end2end_test_config config,
gpr_timespec deadline = n_seconds_from_now(60);
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -151,35 +150,35 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -194,14 +193,14 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -212,12 +211,12 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -225,9 +224,9 @@ static void request_response_with_payload(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -265,12 +264,10 @@ static void request_response_with_payload(grpc_end2end_test_config config,
payload and status. */
static void test_invoke_request_response_with_payload(
grpc_end2end_test_config config) {
- grpc_channel_args *client_args =
- grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_GZIP);
- grpc_channel_args *server_args =
- grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_GZIP);
+ grpc_channel_args* client_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, GRPC_COMPRESS_STREAM_GZIP);
+ grpc_channel_args* server_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, GRPC_COMPRESS_STREAM_GZIP);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_request_response_with_payload",
client_args, server_args);
@@ -278,10 +275,9 @@ static void test_invoke_request_response_with_payload(
end_test(&f);
config.tear_down_data(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
}
@@ -289,7 +285,7 @@ static void test_invoke_10_request_response_with_payload(
grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f = begin_test(
- config, "test_invoke_10_request_response_with_payload", NULL, NULL);
+ config, "test_invoke_10_request_response_with_payload", nullptr, nullptr);
for (i = 0; i < 10; i++) {
request_response_with_payload(config, f);
}
diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.c b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
index 4c1a34cc64..4dc306b79e 100644
--- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.c
+++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
@@ -31,12 +31,12 @@
#include "src/core/lib/surface/call.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -53,31 +53,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -90,19 +90,17 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client pings and server pongs. Repeat messages rounds before finishing. */
static void test_pingpong_streaming(grpc_end2end_test_config config,
int messages) {
- grpc_channel_args *client_args =
- grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_GZIP);
- grpc_channel_args *server_args =
- grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_GZIP);
+ grpc_channel_args* client_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, GRPC_COMPRESS_STREAM_GZIP);
+ grpc_channel_args* server_args = grpc_channel_args_set_compression_algorithm(
+ nullptr, GRPC_COMPRESS_STREAM_GZIP);
grpc_end2end_test_fixture f =
begin_test(config, "test_pingpong_streaming", client_args, server_args);
- grpc_call *c;
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -111,10 +109,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- grpc_byte_buffer *request_payload;
- grpc_byte_buffer *request_payload_recv;
- grpc_byte_buffer *response_payload;
- grpc_byte_buffer *response_payload_recv;
+ grpc_byte_buffer* request_payload;
+ grpc_byte_buffer* request_payload_recv;
+ grpc_byte_buffer* response_payload;
+ grpc_byte_buffer* response_payload_recv;
int i;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
@@ -123,10 +121,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -139,21 +137,21 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -168,14 +166,14 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < messages; i++) {
@@ -187,14 +185,14 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -202,9 +200,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
cq_verify(cqv);
@@ -214,9 +213,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -235,9 +235,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -248,9 +248,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -273,10 +273,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
end_test(&f);
config.tear_down_data(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
}
diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.cc
index 9d562b9090..6ad1cec086 100644
--- a/test/core/end2end/tests/streaming_error_response.c
+++ b/test/core/end2end/tests/streaming_error_response.cc
@@ -31,12 +31,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args,
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args,
bool request_status_early) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s/request_status_early=%s", test_name,
@@ -55,31 +55,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -91,36 +91,37 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client sends a request with payload, server reads then returns status. */
static void test(grpc_end2end_test_config config, bool request_status_early) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice response_payload1_slice = grpc_slice_from_copied_string("hello");
- grpc_byte_buffer *response_payload1 =
+ grpc_byte_buffer* response_payload1 =
grpc_raw_byte_buffer_create(&response_payload1_slice, 1);
grpc_slice response_payload2_slice = grpc_slice_from_copied_string("world");
- grpc_byte_buffer *response_payload2 =
+ grpc_byte_buffer* response_payload2 =
grpc_raw_byte_buffer_create(&response_payload2_slice, 1);
- grpc_end2end_test_fixture f = begin_test(config, "streaming_error_response",
- NULL, NULL, request_status_early);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f =
+ begin_test(config, "streaming_error_response", nullptr, nullptr,
+ request_status_early);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *response_payload1_recv = NULL;
- grpc_byte_buffer *response_payload2_recv = NULL;
+ grpc_byte_buffer* response_payload1_recv = nullptr;
+ grpc_byte_buffer* response_payload2_recv = nullptr;
grpc_call_details call_details;
- grpc_status_code status;
+ grpc_status_code status = GRPC_STATUS_OK;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -148,7 +149,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->data.recv_status_on_client.status_details = &details;
op++;
}
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -165,7 +166,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload1;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -179,11 +180,10 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload2;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
- cq_verify(cqv);
if (!request_status_early) {
memset(ops, 0, sizeof(ops));
@@ -191,7 +191,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload2_recv;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -209,7 +209,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(104), 1);
@@ -226,14 +226,14 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
cq_verify(cqv);
- GPR_ASSERT(response_payload1_recv != NULL);
- GPR_ASSERT(response_payload2_recv != NULL);
+ GPR_ASSERT(response_payload1_recv != nullptr);
+ GPR_ASSERT(response_payload2_recv != nullptr);
}
GPR_ASSERT(status == GRPC_STATUS_FAILED_PRECONDITION);
diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.cc
index 7aa78a04b8..afc56c8dfa 100644
--- a/test/core/end2end/tests/trailing_metadata.c
+++ b/test/core/end2end/tests/trailing_metadata.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -87,50 +87,51 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Request/response with metadata and payload.*/
static void test_request_response_with_metadata_and_payload(
grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
grpc_slice response_payload_slice =
grpc_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
+ grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"),
grpc_slice_from_static_string("val1"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key2"),
grpc_slice_from_static_string("val2"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_metadata meta_s[2] = {{grpc_slice_from_static_string("key3"),
grpc_slice_from_static_string("val3"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key4"),
grpc_slice_from_static_string("val4"),
0,
- {{NULL, NULL, NULL, NULL}}}};
+ {{nullptr, nullptr, nullptr, nullptr}}}};
grpc_metadata meta_t[2] = {{grpc_slice_from_static_string("key5"),
grpc_slice_from_static_string("val5"),
0,
- {{NULL, NULL, NULL, NULL}}},
+ {{nullptr, nullptr, nullptr, nullptr}}},
{grpc_slice_from_static_string("key6"),
grpc_slice_from_static_string("val6"),
0,
- {{NULL, NULL, NULL, NULL}}}};
- grpc_end2end_test_fixture f = begin_test(
- config, "test_request_response_with_metadata_and_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ {{nullptr, nullptr, nullptr, nullptr}}}};
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_request_response_with_metadata_and_payload",
+ nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -139,10 +140,10 @@ static void test_request_response_with_metadata_and_payload(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -156,35 +157,35 @@ static void test_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_c;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -200,14 +201,14 @@ static void test_request_response_with_metadata_and_payload(
op->data.send_initial_metadata.count = 2;
op->data.send_initial_metadata.metadata = meta_s;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -218,12 +219,12 @@ static void test_request_response_with_metadata_and_payload(
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 2;
@@ -232,9 +233,9 @@ static void test_request_response_with_metadata_and_payload(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/workaround_cronet_compression.c b/test/core/end2end/tests/workaround_cronet_compression.cc
index 44e8e04643..97ab814d27 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.c
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -36,12 +36,12 @@
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -58,31 +58,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -93,36 +93,36 @@ static void end_test(grpc_end2end_test_fixture *f) {
}
static void request_with_payload_template(
- grpc_end2end_test_config config, const char *test_name,
+ grpc_end2end_test_config config, const char* test_name,
uint32_t client_send_flags_bitmask,
grpc_compression_algorithm default_client_channel_compression_algorithm,
grpc_compression_algorithm default_server_channel_compression_algorithm,
grpc_compression_algorithm expected_algorithm_from_client,
grpc_compression_algorithm expected_algorithm_from_server,
- grpc_metadata *client_init_metadata, bool set_server_level,
+ grpc_metadata* client_init_metadata, bool set_server_level,
grpc_compression_level server_compression_level,
- char *user_agent_override) {
- grpc_call *c;
- grpc_call *s;
+ char* user_agent_override) {
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer *request_payload;
- grpc_channel_args *client_args;
- grpc_channel_args *server_args;
+ grpc_byte_buffer* request_payload;
+ grpc_channel_args* client_args;
+ grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv = NULL;
- grpc_byte_buffer *response_payload;
- grpc_byte_buffer *response_payload_recv;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_byte_buffer* response_payload;
+ grpc_byte_buffer* response_payload_recv;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
int was_cancelled = 2;
- cq_verifier *cqv;
+ cq_verifier* cqv;
char request_str[1024];
char response_str[1024];
@@ -137,20 +137,19 @@ static void request_with_payload_template(
grpc_slice_from_copied_string(response_str);
client_args = grpc_channel_args_set_compression_algorithm(
- NULL, default_client_channel_compression_algorithm);
+ nullptr, default_client_channel_compression_algorithm);
server_args = grpc_channel_args_set_compression_algorithm(
- NULL, default_server_channel_compression_algorithm);
+ nullptr, default_server_channel_compression_algorithm);
if (user_agent_override) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *client_args_old = client_args;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args* client_args_old = client_args;
grpc_arg arg;
- arg.key = GRPC_ARG_PRIMARY_USER_AGENT_STRING;
+ arg.key = const_cast<char*>(GRPC_ARG_PRIMARY_USER_AGENT_STRING);
arg.type = GRPC_ARG_STRING;
arg.value.string = user_agent_override;
client_args = grpc_channel_args_copy_and_add(client_args_old, &arg, 1);
- grpc_channel_args_destroy(&exec_ctx, client_args_old);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(client_args_old);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -158,10 +157,10 @@ static void request_with_payload_template(
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -172,28 +171,28 @@ static void request_with_payload_template(
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- if (client_init_metadata != NULL) {
+ if (client_init_metadata != nullptr) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = client_init_metadata;
} else {
op->data.send_initial_metadata.count = 0;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -208,9 +207,9 @@ static void request_with_payload_template(
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_NONE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_DEFLATE) != 0);
+ GRPC_COMPRESS_MESSAGE_DEFLATE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_GZIP) != 0);
+ GRPC_COMPRESS_MESSAGE_GZIP) != 0);
memset(ops, 0, sizeof(ops));
op = ops;
@@ -222,14 +221,14 @@ static void request_with_payload_template(
server_compression_level;
}
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (int i = 0; i < 2; i++) {
@@ -241,14 +240,14 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = client_send_flags_bitmask;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -256,9 +255,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
cq_verify(cqv);
@@ -273,9 +273,10 @@ static void request_with_payload_template(
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -306,9 +307,9 @@ static void request_with_payload_template(
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -319,9 +320,9 @@ static void request_with_payload_template(
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -349,10 +350,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -360,18 +360,21 @@ static void request_with_payload_template(
}
typedef struct workaround_cronet_compression_config {
- char *user_agent_override;
+ char* user_agent_override;
grpc_compression_algorithm expected_algorithm_from_server;
} workaround_cronet_compression_config;
static workaround_cronet_compression_config workaround_configs[] = {
- {NULL, GRPC_COMPRESS_GZIP},
- {"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; cronet_http; gentle)",
+ {nullptr, GRPC_COMPRESS_MESSAGE_GZIP},
+ {const_cast<char*>(
+ "grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; cronet_http; gentle)"),
GRPC_COMPRESS_NONE},
- {"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; chttp2; gentle)",
- GRPC_COMPRESS_GZIP},
- {"grpc-objc/1.4.0 grpc-c/3.0.0-dev (ios; cronet_http; gentle)",
- GRPC_COMPRESS_GZIP}};
+ {const_cast<char*>(
+ "grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; chttp2; gentle)"),
+ GRPC_COMPRESS_MESSAGE_GZIP},
+ {const_cast<char*>(
+ "grpc-objc/1.4.0 grpc-c/3.0.0-dev (ios; cronet_http; gentle)"),
+ GRPC_COMPRESS_MESSAGE_GZIP}};
static const size_t workaround_configs_num =
sizeof(workaround_configs) / sizeof(*workaround_configs);
@@ -380,8 +383,9 @@ static void test_workaround_cronet_compression(
for (uint32_t i = 0; i < workaround_configs_num; i++) {
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload", 0,
- GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
- workaround_configs[i].expected_algorithm_from_server, NULL, false,
+ GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_MESSAGE_GZIP,
+ workaround_configs[i].expected_algorithm_from_server, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE,
workaround_configs[i].user_agent_override);
}
diff --git a/test/core/end2end/tests/write_buffering.c b/test/core/end2end/tests/write_buffering.cc
index d7d1e5fa3d..40821dd6f0 100644
--- a/test/core/end2end/tests/write_buffering.c
+++ b/test/core/end2end/tests/write_buffering.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,25 +86,25 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client sends a request with payload, server reads then returns status. */
static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice1 =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload1 =
+ grpc_byte_buffer* request_payload1 =
grpc_raw_byte_buffer_create(&request_payload_slice1, 1);
grpc_slice request_payload_slice2 = grpc_slice_from_copied_string("abc123");
- grpc_byte_buffer *request_payload2 =
+ grpc_byte_buffer* request_payload2 =
grpc_raw_byte_buffer_create(&request_payload_slice2, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_invoke_request_with_payload", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv1 = NULL;
- grpc_byte_buffer *request_payload_recv2 = NULL;
+ grpc_byte_buffer* request_payload_recv1 = nullptr;
+ grpc_byte_buffer* request_payload_recv2 = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -113,10 +113,10 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -129,7 +129,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -137,9 +137,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -155,7 +155,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.send_message.send_message = request_payload1;
op->flags = GRPC_WRITE_BUFFER_HINT;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -163,7 +163,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* recv message should not succeed yet - it's buffered at the client still */
@@ -172,7 +172,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv1;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
@@ -187,7 +187,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.send_message.send_message = request_payload2;
op->flags = 0;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* now the first send should match up with the first recv */
@@ -201,7 +201,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv2;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(104), true);
@@ -211,23 +211,23 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -235,9 +235,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(105), 1);
diff --git a/test/core/end2end/tests/write_buffering_at_end.c b/test/core/end2end/tests/write_buffering_at_end.cc
index 6113843390..1b9dc9632b 100644
--- a/test/core/end2end/tests/write_buffering_at_end.c
+++ b/test/core/end2end/tests/write_buffering_at_end.cc
@@ -28,12 +28,12 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
@@ -50,31 +50,31 @@ static gpr_timespec five_seconds_from_now(void) {
return n_seconds_from_now(5);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL);
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
+static void shutdown_server(grpc_end2end_test_fixture* f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
+static void shutdown_client(grpc_end2end_test_fixture* f) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
-static void end_test(grpc_end2end_test_fixture *f) {
+static void end_test(grpc_end2end_test_fixture* f) {
shutdown_server(f);
shutdown_client(f);
@@ -86,22 +86,22 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client sends a request with payload, server reads then returns status. */
static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_call *s;
+ grpc_call* c;
+ grpc_call* s;
grpc_slice request_payload_slice =
grpc_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
+ grpc_byte_buffer* request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ begin_test(config, "test_invoke_request_with_payload", nullptr, nullptr);
+ cq_verifier* cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
- grpc_byte_buffer *request_payload_recv1 = NULL;
- grpc_byte_buffer *request_payload_recv2 = NULL;
+ grpc_byte_buffer* request_payload_recv1 = nullptr;
+ grpc_byte_buffer* request_payload_recv2 = nullptr;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@@ -110,10 +110,10 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_from_now();
c = grpc_channel_create_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr:1234", config), deadline,
- NULL);
+ nullptr);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -126,7 +126,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -134,9 +134,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -152,7 +152,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.send_message.send_message = request_payload;
op->flags = GRPC_WRITE_BUFFER_HINT;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -160,7 +160,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* recv message should not succeed yet - it's buffered at the client still */
@@ -169,7 +169,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv1;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
@@ -182,7 +182,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* now the first send should match up with the first recv */
@@ -196,7 +196,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv2;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(104), true);
@@ -209,16 +209,16 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
@@ -226,9 +226,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(105), 1);
@@ -242,7 +242,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
config);
GPR_ASSERT(was_cancelled == 0);
GPR_ASSERT(byte_buffer_eq_string(request_payload_recv1, "hello world"));
- GPR_ASSERT(request_payload_recv2 == NULL);
+ GPR_ASSERT(request_payload_recv2 == nullptr);
grpc_slice_unref(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
diff --git a/test/core/fling/BUILD b/test/core/fling/BUILD
index 27b2b5bec6..268e94aacc 100644
--- a/test/core/fling/BUILD
+++ b/test/core/fling/BUILD
@@ -23,8 +23,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_cc_binary(
name = "client",
testonly = 1,
- srcs = ["client.c"],
- language = "C",
+ srcs = ["client.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -37,8 +37,8 @@ grpc_cc_binary(
grpc_cc_binary(
name = "server",
testonly = 1,
- srcs = ["server.c"],
- language = "C",
+ srcs = ["server.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -50,7 +50,7 @@ grpc_cc_binary(
grpc_cc_test(
name = "fling",
- srcs = ["fling_test.c"],
+ srcs = ["fling_test.cc"],
data = [
":client",
":server",
@@ -66,7 +66,7 @@ grpc_cc_test(
grpc_cc_test(
name = "fling_stream",
- srcs = ["fling_stream_test.c"],
+ srcs = ["fling_stream_test.cc"],
data = [
":client",
":server",
diff --git a/test/core/fling/client.c b/test/core/fling/client.cc
index be7bfc2280..28e62e0e83 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.cc
@@ -22,28 +22,28 @@
#include <string.h>
#include <grpc/support/cmdline.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/profiling/timers.h"
#include "test/core/util/grpc_profiler.h"
+#include "test/core/util/histogram.h"
#include "test/core/util/test_config.h"
-static gpr_histogram *histogram;
-static grpc_byte_buffer *the_buffer;
-static grpc_channel *channel;
-static grpc_completion_queue *cq;
-static grpc_call *call;
+static grpc_histogram* histogram;
+static grpc_byte_buffer* the_buffer;
+static grpc_channel* channel;
+static grpc_completion_queue* cq;
+static grpc_call* call;
static grpc_op ops[6];
static grpc_op stream_init_ops[2];
static grpc_op stream_step_ops[2];
static grpc_metadata_array initial_metadata_recv;
static grpc_metadata_array trailing_metadata_recv;
-static grpc_byte_buffer *response_payload_recv = NULL;
+static grpc_byte_buffer* response_payload_recv = nullptr;
static grpc_status_code status;
static grpc_slice details;
-static grpc_op *op;
+static grpc_op* op;
static void init_ping_pong_request(void) {
grpc_metadata_array_init(&initial_metadata_recv);
@@ -77,16 +77,16 @@ static void step_ping_pong_request(void) {
GPR_TIMER_BEGIN("ping_pong", 1);
grpc_slice host = grpc_slice_from_static_string("localhost");
call = grpc_channel_create_call(
- channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/Reflector/reflectUnary"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
- (size_t)(op - ops),
- (void *)1, NULL));
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ (size_t)(op - ops), (void*)1,
+ nullptr));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_call_unref(call);
grpc_byte_buffer_destroy(response_payload_recv);
- call = NULL;
+ call = nullptr;
GPR_TIMER_END("ping_pong", 1);
}
@@ -96,17 +96,17 @@ static void init_ping_pong_stream(void) {
grpc_call_error error;
grpc_slice host = grpc_slice_from_static_string("localhost");
call = grpc_channel_create_call(
- channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/Reflector/reflectStream"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
stream_init_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
stream_init_ops[0].data.send_initial_metadata.count = 0;
stream_init_ops[1].op = GRPC_OP_RECV_INITIAL_METADATA;
stream_init_ops[1].data.recv_initial_metadata.recv_initial_metadata =
&initial_metadata_recv;
- error = grpc_call_start_batch(call, stream_init_ops, 2, (void *)1, NULL);
+ error = grpc_call_start_batch(call, stream_init_ops, 2, (void*)1, nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -119,9 +119,9 @@ static void init_ping_pong_stream(void) {
static void step_ping_pong_stream(void) {
grpc_call_error error;
GPR_TIMER_BEGIN("ping_pong", 1);
- error = grpc_call_start_batch(call, stream_step_ops, 2, (void *)1, NULL);
+ error = grpc_call_start_batch(call, stream_step_ops, 2, (void*)1, nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_byte_buffer_destroy(response_payload_recv);
GPR_TIMER_END("ping_pong", 1);
}
@@ -132,7 +132,7 @@ static double now(void) {
}
typedef struct {
- const char *name;
+ const char* name;
void (*init)();
void (*do_one_step)();
} scenario;
@@ -142,20 +142,20 @@ static const scenario scenarios[] = {
{"ping-pong-stream", init_ping_pong_stream, step_ping_pong_stream},
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_slice slice = grpc_slice_from_copied_string("x");
double start, stop;
unsigned i;
- char *fake_argv[1];
+ char* fake_argv[1];
int payload_size = 1;
int secure = 0;
- char *target = "localhost:443";
- gpr_cmdline *cl;
+ const char* target = "localhost:443";
+ gpr_cmdline* cl;
grpc_event event;
- char *scenario_name = "ping-pong-request";
- scenario sc = {NULL, NULL, NULL};
+ const char* scenario_name = "ping-pong-request";
+ scenario sc = {nullptr, nullptr, nullptr};
gpr_timers_set_log_filename("latency_trace.fling_client.txt");
@@ -186,16 +186,18 @@ int main(int argc, char **argv) {
}
if (!sc.name) {
fprintf(stderr, "unsupported scenario '%s'. Valid are:", scenario_name);
+ fflush(stderr);
for (i = 0; i < GPR_ARRAY_SIZE(scenarios); i++) {
fprintf(stderr, " %s", scenarios[i].name);
+ fflush(stderr);
}
return 1;
}
- channel = grpc_insecure_channel_create(target, NULL, NULL);
- cq = grpc_completion_queue_create_for_next(NULL);
+ channel = grpc_insecure_channel_create(target, nullptr, nullptr);
+ cq = grpc_completion_queue_create_for_next(nullptr);
the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size);
- histogram = gpr_histogram_create(0.01, 60e9);
+ histogram = grpc_histogram_create(0.01, 60e9);
sc.init();
@@ -213,7 +215,7 @@ int main(int argc, char **argv) {
start = now();
sc.do_one_step();
stop = now();
- gpr_histogram_add(histogram, stop - start);
+ grpc_histogram_add(histogram, stop - start);
}
grpc_profiler_stop();
@@ -225,18 +227,18 @@ int main(int argc, char **argv) {
grpc_completion_queue_shutdown(cq);
do {
event = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
} while (event.type != GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
grpc_byte_buffer_destroy(the_buffer);
grpc_slice_unref(slice);
gpr_log(GPR_INFO, "latency (50/95/99/99.9): %f/%f/%f/%f",
- gpr_histogram_percentile(histogram, 50),
- gpr_histogram_percentile(histogram, 95),
- gpr_histogram_percentile(histogram, 99),
- gpr_histogram_percentile(histogram, 99.9));
- gpr_histogram_destroy(histogram);
+ grpc_histogram_percentile(histogram, 50),
+ grpc_histogram_percentile(histogram, 95),
+ grpc_histogram_percentile(histogram, 99),
+ grpc_histogram_percentile(histogram, 99.9));
+ grpc_histogram_destroy(histogram);
grpc_shutdown();
diff --git a/test/core/fling/fling_test.c b/test/core/fling/fling_stream_test.cc
index 90b48e7737..b5a5ce816e 100644
--- a/test/core/fling/fling_test.c
+++ b/test/core/fling/fling_stream_test.cc
@@ -23,15 +23,15 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/port.h"
-int main(int argc, char **argv) {
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
+int main(int argc, char** argv) {
+ char* me = argv[0];
+ char* lslash = strrchr(me, '/');
char root[1024];
int port = grpc_pick_unused_port_or_die();
- char *args[10];
+ char* args[10];
int status;
gpr_subprocess *svr, *cli;
/* figure out where we are */
@@ -44,22 +44,22 @@ int main(int argc, char **argv) {
/* start the server */
gpr_asprintf(&args[0], "%s/fling_server%s", root,
gpr_subprocess_binary_extension());
- args[1] = "--bind";
+ args[1] = const_cast<char*>("--bind");
gpr_join_host_port(&args[2], "::", port);
- args[3] = "--no-secure";
- svr = gpr_subprocess_create(4, (const char **)args);
+ args[3] = const_cast<char*>("--no-secure");
+ svr = gpr_subprocess_create(4, (const char**)args);
gpr_free(args[0]);
gpr_free(args[2]);
/* start the client */
gpr_asprintf(&args[0], "%s/fling_client%s", root,
gpr_subprocess_binary_extension());
- args[1] = "--target";
+ args[1] = const_cast<char*>("--target");
gpr_join_host_port(&args[2], "127.0.0.1", port);
- args[3] = "--scenario=ping-pong-request";
- args[4] = "--no-secure";
- args[5] = 0;
- cli = gpr_subprocess_create(6, (const char **)args);
+ args[3] = const_cast<char*>("--scenario=ping-pong-stream");
+ args[4] = const_cast<char*>("--no-secure");
+ args[5] = nullptr;
+ cli = gpr_subprocess_create(6, (const char**)args);
gpr_free(args[0]);
gpr_free(args[2]);
diff --git a/test/core/fling/fling_stream_test.c b/test/core/fling/fling_test.cc
index 566d9ae6f0..3792e45c42 100644
--- a/test/core/fling/fling_stream_test.c
+++ b/test/core/fling/fling_test.cc
@@ -23,15 +23,15 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/port.h"
-int main(int argc, char **argv) {
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
+int main(int argc, const char** argv) {
+ const char* me = argv[0];
+ const char* lslash = strrchr(me, '/');
char root[1024];
int port = grpc_pick_unused_port_or_die();
- char *args[10];
+ char* args[10];
int status;
gpr_subprocess *svr, *cli;
/* figure out where we are */
@@ -44,22 +44,22 @@ int main(int argc, char **argv) {
/* start the server */
gpr_asprintf(&args[0], "%s/fling_server%s", root,
gpr_subprocess_binary_extension());
- args[1] = "--bind";
+ args[1] = const_cast<char*>("--bind");
gpr_join_host_port(&args[2], "::", port);
- args[3] = "--no-secure";
- svr = gpr_subprocess_create(4, (const char **)args);
+ args[3] = const_cast<char*>("--no-secure");
+ svr = gpr_subprocess_create(4, (const char**)args);
gpr_free(args[0]);
gpr_free(args[2]);
/* start the client */
gpr_asprintf(&args[0], "%s/fling_client%s", root,
gpr_subprocess_binary_extension());
- args[1] = "--target";
+ args[1] = const_cast<char*>("--target");
gpr_join_host_port(&args[2], "127.0.0.1", port);
- args[3] = "--scenario=ping-pong-stream";
- args[4] = "--no-secure";
- args[5] = 0;
- cli = gpr_subprocess_create(6, (const char **)args);
+ args[3] = const_cast<char*>("--scenario=ping-pong-request");
+ args[4] = const_cast<char*>("--no-secure");
+ args[5] = nullptr;
+ cli = gpr_subprocess_create(6, (const char**)args);
gpr_free(args[0]);
gpr_free(args[2]);
diff --git a/test/core/fling/server.c b/test/core/fling/server.cc
index b3a7fa21ec..f3a8a1ccf8 100644
--- a/test/core/fling/server.c
+++ b/test/core/fling/server.cc
@@ -40,15 +40,15 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static grpc_completion_queue *cq;
-static grpc_server *server;
-static grpc_call *call;
+static grpc_completion_queue* cq;
+static grpc_server* server;
+static grpc_call* call;
static grpc_call_details call_details;
static grpc_metadata_array request_metadata_recv;
static grpc_metadata_array initial_metadata_send;
-static grpc_byte_buffer *payload_buffer = NULL;
+static grpc_byte_buffer* payload_buffer = nullptr;
/* Used to drain the terminal read in unary calls. */
-static grpc_byte_buffer *terminal_buffer = NULL;
+static grpc_byte_buffer* terminal_buffer = nullptr;
static grpc_op read_op;
static grpc_op metadata_send_op;
@@ -58,7 +58,7 @@ static int was_cancelled = 2;
static grpc_op unary_ops[6];
static int got_sigint = 0;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
typedef enum {
FLING_SERVER_NEW_REQUEST = 1,
@@ -84,7 +84,7 @@ static void request_call(void) {
}
static void handle_unary_method(void) {
- grpc_op *op;
+ grpc_op* op;
grpc_call_error error;
grpc_metadata_array_init(&initial_metadata_send);
@@ -97,7 +97,7 @@ static void handle_unary_method(void) {
op->data.recv_message.recv_message = &terminal_buffer;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
- if (payload_buffer == NULL) {
+ if (payload_buffer == nullptr) {
gpr_log(GPR_INFO, "NULL payload buffer !!!");
}
op->data.send_message.send_message = payload_buffer;
@@ -105,24 +105,24 @@ static void handle_unary_method(void) {
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.status = GRPC_STATUS_OK;
op->data.send_status_from_server.trailing_metadata_count = 0;
- op->data.send_status_from_server.status_details = NULL;
+ op->data.send_status_from_server.status_details = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op++;
error = grpc_call_start_batch(call, unary_ops, (size_t)(op - unary_ops),
- tag(FLING_SERVER_BATCH_OPS_FOR_UNARY), NULL);
+ tag(FLING_SERVER_BATCH_OPS_FOR_UNARY), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
}
static void send_initial_metadata(void) {
grpc_call_error error;
- void *tagarg = tag(FLING_SERVER_SEND_INIT_METADATA_FOR_STREAMING);
+ void* tagarg = tag(FLING_SERVER_SEND_INIT_METADATA_FOR_STREAMING);
grpc_metadata_array_init(&initial_metadata_send);
metadata_send_op.op = GRPC_OP_SEND_INITIAL_METADATA;
metadata_send_op.data.send_initial_metadata.count = 0;
- error = grpc_call_start_batch(call, &metadata_send_op, 1, tagarg, NULL);
+ error = grpc_call_start_batch(call, &metadata_send_op, 1, tagarg, nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
}
@@ -132,34 +132,34 @@ static void start_read_op(int t) {
/* Starting read at server */
read_op.op = GRPC_OP_RECV_MESSAGE;
read_op.data.recv_message.recv_message = &payload_buffer;
- error = grpc_call_start_batch(call, &read_op, 1, tag(t), NULL);
+ error = grpc_call_start_batch(call, &read_op, 1, tag(t), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
}
static void start_write_op(void) {
grpc_call_error error;
- void *tagarg = tag(FLING_SERVER_WRITE_FOR_STREAMING);
+ void* tagarg = tag(FLING_SERVER_WRITE_FOR_STREAMING);
/* Starting write at server */
write_op.op = GRPC_OP_SEND_MESSAGE;
- if (payload_buffer == NULL) {
+ if (payload_buffer == nullptr) {
gpr_log(GPR_INFO, "NULL payload buffer !!!");
}
write_op.data.send_message.send_message = payload_buffer;
- error = grpc_call_start_batch(call, &write_op, 1, tagarg, NULL);
+ error = grpc_call_start_batch(call, &write_op, 1, tagarg, nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
}
static void start_send_status(void) {
grpc_call_error error;
- void *tagarg = tag(FLING_SERVER_SEND_STATUS_FOR_STREAMING);
+ void* tagarg = tag(FLING_SERVER_SEND_STATUS_FOR_STREAMING);
status_op[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER;
status_op[0].data.send_status_from_server.status = GRPC_STATUS_OK;
status_op[0].data.send_status_from_server.trailing_metadata_count = 0;
- status_op[0].data.send_status_from_server.status_details = NULL;
+ status_op[0].data.send_status_from_server.status_details = nullptr;
status_op[1].op = GRPC_OP_RECV_CLOSE_ON_SERVER;
status_op[1].data.recv_close_on_server.cancelled = &was_cancelled;
- error = grpc_call_start_batch(call, status_op, 2, tagarg, NULL);
+ error = grpc_call_start_batch(call, status_op, 2, tagarg, nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
}
@@ -167,19 +167,19 @@ static void start_send_status(void) {
When that is resolved, please remove the #include <unistd.h> above. */
static void sigint_handler(int x) { _exit(0); }
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_event ev;
- call_state *s;
- char *addr_buf = NULL;
- gpr_cmdline *cl;
- grpc_completion_queue *shutdown_cq;
+ call_state* s;
+ char* addr_buf = nullptr;
+ gpr_cmdline* cl;
+ grpc_completion_queue* shutdown_cq;
int shutdown_started = 0;
int shutdown_finished = 0;
int secure = 0;
- char *addr = NULL;
+ const char* addr = nullptr;
- char *fake_argv[1];
+ char* fake_argv[1];
gpr_timers_set_log_filename("latency_trace.fling_server.txt");
@@ -196,30 +196,30 @@ int main(int argc, char **argv) {
gpr_cmdline_parse(cl, argc, argv);
gpr_cmdline_destroy(cl);
- if (addr == NULL) {
+ if (addr == nullptr) {
gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die());
addr = addr_buf;
}
gpr_log(GPR_INFO, "creating server on: %s", addr);
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
if (secure) {
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
- NULL, &pem_key_cert_pair, 1, 0, NULL);
- server = grpc_server_create(NULL, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_key_cert_pair, 1, 0, nullptr);
+ server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
grpc_server_credentials_release(ssl_creds);
} else {
- server = grpc_server_create(NULL, NULL);
+ server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr));
}
- grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_server_register_completion_queue(server, cq, nullptr);
grpc_server_start(server);
gpr_free(addr_buf);
- addr = addr_buf = NULL;
+ addr = addr_buf = nullptr;
grpc_call_details_init(&call_details);
@@ -231,28 +231,29 @@ int main(int argc, char **argv) {
if (got_sigint && !shutdown_started) {
gpr_log(GPR_INFO, "Shutting down due to SIGINT");
- shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000));
- GPR_ASSERT(
- grpc_completion_queue_pluck(shutdown_cq, tag(1000),
- grpc_timeout_seconds_to_deadline(5), NULL)
- .type == GRPC_OP_COMPLETE);
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ shutdown_cq, tag(1000),
+ grpc_timeout_seconds_to_deadline(5), nullptr)
+ .type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_completion_queue_shutdown(cq);
shutdown_started = 1;
}
ev = grpc_completion_queue_next(
- cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_micros(1000000, GPR_TIMESPAN)),
- NULL);
- s = ev.tag;
+ cq,
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ nullptr);
+ s = static_cast<call_state*>(ev.tag);
switch (ev.type) {
case GRPC_OP_COMPLETE:
switch ((intptr_t)s) {
case FLING_SERVER_NEW_REQUEST:
- if (call != NULL) {
+ if (call != nullptr) {
if (0 == grpc_slice_str_cmp(call_details.method,
"/Reflector/reflectStream")) {
/* Received streaming call. Send metadata here. */
@@ -269,7 +270,7 @@ int main(int argc, char **argv) {
*/
break;
case FLING_SERVER_READ_FOR_STREAMING:
- if (payload_buffer != NULL) {
+ if (payload_buffer != nullptr) {
/* Received payload from client. */
start_write_op();
} else {
@@ -280,7 +281,7 @@ int main(int argc, char **argv) {
case FLING_SERVER_WRITE_FOR_STREAMING:
/* Write completed at server */
grpc_byte_buffer_destroy(payload_buffer);
- payload_buffer = NULL;
+ payload_buffer = nullptr;
start_read_op(FLING_SERVER_READ_FOR_STREAMING);
break;
case FLING_SERVER_SEND_INIT_METADATA_FOR_STREAMING:
@@ -300,7 +301,7 @@ int main(int argc, char **argv) {
case FLING_SERVER_BATCH_OPS_FOR_UNARY:
/* Finished unary call. */
grpc_byte_buffer_destroy(payload_buffer);
- payload_buffer = NULL;
+ payload_buffer = nullptr;
grpc_call_unref(call);
if (!shutdown_started) request_call();
break;
diff --git a/test/core/support/BUILD b/test/core/gpr/BUILD
index 096576e13c..1be1036d04 100644
--- a/test/core/support/BUILD
+++ b/test/core/gpr/BUILD
@@ -16,12 +16,12 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_c
licenses(["notice"]) # Apache v2
-grpc_package(name = "test/core/support")
+grpc_package(name = "test/core/gpr")
grpc_cc_test(
name = "alloc_test",
- srcs = ["alloc_test.c"],
- language = "C",
+ srcs = ["alloc_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -30,18 +30,8 @@ grpc_cc_test(
grpc_cc_test(
name = "avl_test",
- srcs = ["avl_test.c"],
- language = "C",
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "backoff_test",
- srcs = ["backoff_test.c"],
- language = "C",
+ srcs = ["avl_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -50,8 +40,8 @@ grpc_cc_test(
grpc_cc_test(
name = "cmdline_test",
- srcs = ["cmdline_test.c"],
- language = "C",
+ srcs = ["cmdline_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -60,8 +50,8 @@ grpc_cc_test(
grpc_cc_test(
name = "cpu_test",
- srcs = ["cpu_test.c"],
- language = "C",
+ srcs = ["cpu_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -70,18 +60,8 @@ grpc_cc_test(
grpc_cc_test(
name = "env_test",
- srcs = ["env_test.c"],
- language = "C",
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "histogram_test",
- srcs = ["histogram_test.c"],
- language = "C",
+ srcs = ["env_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -90,8 +70,8 @@ grpc_cc_test(
grpc_cc_test(
name = "host_port_test",
- srcs = ["host_port_test.c"],
- language = "C",
+ srcs = ["host_port_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -100,8 +80,8 @@ grpc_cc_test(
grpc_cc_test(
name = "log_test",
- srcs = ["log_test.c"],
- language = "C",
+ srcs = ["log_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -110,8 +90,8 @@ grpc_cc_test(
grpc_cc_test(
name = "mpscq_test",
- srcs = ["mpscq_test.c"],
- language = "C",
+ srcs = ["mpscq_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -120,18 +100,8 @@ grpc_cc_test(
grpc_cc_test(
name = "murmur_hash_test",
- srcs = ["murmur_hash_test.c"],
- language = "C",
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "stack_lockfree_test",
- srcs = ["stack_lockfree_test.c"],
- language = "C",
+ srcs = ["murmur_hash_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -140,8 +110,8 @@ grpc_cc_test(
grpc_cc_test(
name = "string_test",
- srcs = ["string_test.c"],
- language = "C",
+ srcs = ["string_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -150,8 +120,8 @@ grpc_cc_test(
grpc_cc_test(
name = "spinlock_test",
- srcs = ["spinlock_test.c"],
- language = "C",
+ srcs = ["spinlock_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -160,8 +130,8 @@ grpc_cc_test(
grpc_cc_test(
name = "sync_test",
- srcs = ["sync_test.c"],
- language = "C",
+ srcs = ["sync_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -170,8 +140,8 @@ grpc_cc_test(
grpc_cc_test(
name = "thd_test",
- srcs = ["thd_test.c"],
- language = "C",
+ srcs = ["thd_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -180,8 +150,8 @@ grpc_cc_test(
grpc_cc_test(
name = "time_test",
- srcs = ["time_test.c"],
- language = "C",
+ srcs = ["time_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -190,8 +160,8 @@ grpc_cc_test(
grpc_cc_test(
name = "tls_test",
- srcs = ["tls_test.c"],
- language = "C",
+ srcs = ["tls_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
@@ -200,8 +170,8 @@ grpc_cc_test(
grpc_cc_test(
name = "useful_test",
- srcs = ["useful_test.c"],
- language = "C",
+ srcs = ["useful_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
diff --git a/test/core/support/alloc_test.c b/test/core/gpr/alloc_test.cc
index 088ae7d944..bf4471c36f 100644
--- a/test/core/support/alloc_test.c
+++ b/test/core/gpr/alloc_test.cc
@@ -16,40 +16,54 @@
*
*/
+#include <string.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+
#include "test/core/util/test_config.h"
-static void *fake_malloc(size_t size) { return (void *)size; }
+static void* fake_malloc(size_t size) { return (void*)size; }
-static void *fake_realloc(void *addr, size_t size) { return (void *)size; }
+static void* fake_realloc(void* addr, size_t size) { return (void*)size; }
-static void fake_free(void *addr) {
- *((intptr_t *)addr) = (intptr_t)0xdeadd00d;
-}
+static void fake_free(void* addr) { *((intptr_t*)addr) = (intptr_t)0xdeadd00d; }
static void test_custom_allocs() {
const gpr_allocation_functions default_fns = gpr_get_allocation_functions();
intptr_t addr_to_free = 0;
- char *i;
- gpr_allocation_functions fns = {fake_malloc, NULL, fake_realloc, fake_free};
+ char* i;
+ gpr_allocation_functions fns = {fake_malloc, nullptr, fake_realloc,
+ fake_free};
gpr_set_allocation_functions(fns);
- GPR_ASSERT((void *)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef));
- GPR_ASSERT((void *)(size_t)0xcafed00d == gpr_realloc(0, 0xcafed00d));
+ GPR_ASSERT((void*)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef));
+ GPR_ASSERT((void*)(size_t)0xcafed00d == gpr_realloc(nullptr, 0xcafed00d));
gpr_free(&addr_to_free);
GPR_ASSERT(addr_to_free == (intptr_t)0xdeadd00d);
/* Restore and check we don't get funky values and that we don't leak */
gpr_set_allocation_functions(default_fns);
- GPR_ASSERT((void *)sizeof(*i) != (i = gpr_malloc(sizeof(*i))));
- GPR_ASSERT((void *)2 != (i = gpr_realloc(i, 2)));
+ GPR_ASSERT((void*)sizeof(*i) !=
+ (i = static_cast<char*>(gpr_malloc(sizeof(*i)))));
+ GPR_ASSERT((void*)2 != (i = static_cast<char*>(gpr_realloc(i, 2))));
gpr_free(i);
}
-int main(int argc, char **argv) {
+static void test_malloc_aligned() {
+ for (size_t size = 1; size <= 256; ++size) {
+ void* ptr = gpr_malloc_aligned(size, 16);
+ GPR_ASSERT(ptr != nullptr);
+ GPR_ASSERT(((intptr_t)ptr & 0xf) == 0);
+ memset(ptr, 0, size);
+ gpr_free_aligned(ptr);
+ }
+}
+
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_custom_allocs();
+ test_malloc_aligned();
return 0;
}
diff --git a/test/core/support/arena_test.c b/test/core/gpr/arena_test.cc
index afb309280f..62a3f8bf50 100644
--- a/test/core/support/arena_test.c
+++ b/test/core/gpr/arena_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/arena.h"
+#include "src/core/lib/gpr/arena.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -27,15 +27,15 @@
#include <inttypes.h>
#include <string.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
static void test_noop(void) { gpr_arena_destroy(gpr_arena_create(1)); }
-static void test(const char *name, size_t init_size, const size_t *allocs,
+static void test(const char* name, size_t init_size, const size_t* allocs,
size_t nallocs) {
gpr_strvec v;
- char *s;
+ char* s;
gpr_strvec_init(&v);
gpr_asprintf(&s, "test '%s': %" PRIdPTR " <- {", name, init_size);
gpr_strvec_add(&v, s);
@@ -44,15 +44,17 @@ static void test(const char *name, size_t init_size, const size_t *allocs,
gpr_strvec_add(&v, s);
}
gpr_strvec_add(&v, gpr_strdup("}"));
- s = gpr_strvec_flatten(&v, NULL);
+ s = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
gpr_log(GPR_INFO, "%s", s);
gpr_free(s);
- gpr_arena *a = gpr_arena_create(init_size);
- void **ps = gpr_zalloc(sizeof(*ps) * nallocs);
+ gpr_arena* a = gpr_arena_create(init_size);
+ void** ps = static_cast<void**>(gpr_zalloc(sizeof(*ps) * nallocs));
for (size_t i = 0; i < nallocs; i++) {
ps[i] = gpr_arena_alloc(a, allocs[i]);
+ // ensure the returned address is aligned
+ GPR_ASSERT(((intptr_t)ps[i] & 0xf) == 0);
// ensure no duplicate results
for (size_t j = 0; j < i; j++) {
GPR_ASSERT(ps[i] != ps[j]);
@@ -71,20 +73,20 @@ static void test(const char *name, size_t init_size, const size_t *allocs,
#define CONCURRENT_TEST_THREADS 100
size_t concurrent_test_iterations() {
- if (sizeof(void *) < 8) return 1000;
+ if (sizeof(void*) < 8) return 1000;
return 100000;
}
typedef struct {
gpr_event ev_start;
- gpr_arena *arena;
+ gpr_arena* arena;
} concurrent_test_args;
-static void concurrent_test_body(void *arg) {
- concurrent_test_args *a = arg;
+static void concurrent_test_body(void* arg) {
+ concurrent_test_args* a = static_cast<concurrent_test_args*>(arg);
gpr_event_wait(&a->ev_start, gpr_inf_future(GPR_CLOCK_REALTIME));
for (size_t i = 0; i < concurrent_test_iterations(); i++) {
- *(char *)gpr_arena_alloc(a->arena, 1) = (char)i;
+ *(char*)gpr_arena_alloc(a->arena, 1) = (char)i;
}
}
@@ -100,10 +102,11 @@ static void concurrent_test(void) {
for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) {
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&thds[i], concurrent_test_body, &args, &opt);
+ gpr_thd_new(&thds[i], "grpc_concurrent_test", concurrent_test_body, &args,
+ &opt);
}
- gpr_event_set(&args.ev_start, (void *)1);
+ gpr_event_set(&args.ev_start, (void*)1);
for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) {
gpr_thd_join(thds[i]);
@@ -112,7 +115,7 @@ static void concurrent_test(void) {
gpr_arena_destroy(args.arena);
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
test_noop();
diff --git a/test/core/gpr/avl_test.cc b/test/core/gpr/avl_test.cc
new file mode 100644
index 0000000000..345db557b9
--- /dev/null
+++ b/test/core/gpr/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 <grpc/support/avl.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/useful.h>
+
+#include "test/core/util/test_config.h"
+
+static int* box(int x) {
+ int* b = static_cast<int*>(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/test/core/support/cmdline_test.c b/test/core/gpr/cmdline_test.cc
index 72e7c7f9fc..172efda8a0 100644
--- a/test/core/support/cmdline_test.c
+++ b/test/core/gpr/cmdline_test.cc
@@ -29,13 +29,14 @@
static void test_simple_int(void) {
int x = 1;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "-foo", "3"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("-foo"),
+ const_cast<char*>("3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_int(cl, "foo", NULL, &x);
+ 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);
@@ -44,13 +45,13 @@ static void test_simple_int(void) {
static void test_eq_int(void) {
int x = 1;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "-foo=3"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("-foo=3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_int(cl, "foo", NULL, &x);
+ 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);
@@ -59,13 +60,14 @@ static void test_eq_int(void) {
static void test_2dash_int(void) {
int x = 1;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo", "3"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo"),
+ const_cast<char*>("3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_int(cl, "foo", NULL, &x);
+ 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);
@@ -74,13 +76,13 @@ static void test_2dash_int(void) {
static void test_2dash_eq_int(void) {
int x = 1;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo=3"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_int(cl, "foo", NULL, &x);
+ 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);
@@ -88,60 +90,62 @@ static void test_2dash_eq_int(void) {
}
static void test_simple_string(void) {
- char *x = NULL;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "-foo", "3"};
+ const char* x = nullptr;
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("-foo"),
+ const_cast<char*>("3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_string(cl, "foo", NULL, &x);
- GPR_ASSERT(x == NULL);
+ 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) {
- char *x = NULL;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "-foo=3"};
+ const char* x = nullptr;
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("-foo=3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_string(cl, "foo", NULL, &x);
- GPR_ASSERT(x == NULL);
+ 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) {
- char *x = NULL;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo", "3"};
+ const char* x = nullptr;
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo"),
+ const_cast<char*>("3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_string(cl, "foo", NULL, &x);
- GPR_ASSERT(x == NULL);
+ 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) {
- char *x = NULL;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo=3"};
+ const char* x = nullptr;
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=3")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_string(cl, "foo", NULL, &x);
- GPR_ASSERT(x == NULL);
+ 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);
@@ -149,13 +153,13 @@ static void test_2dash_eq_string(void) {
static void test_flag_on(void) {
int x = 2;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_flag(cl, "foo", NULL, &x);
+ 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);
@@ -164,13 +168,13 @@ static void test_flag_on(void) {
static void test_flag_no(void) {
int x = 2;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--no-foo"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--no-foo")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_flag(cl, "foo", NULL, &x);
+ 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);
@@ -179,13 +183,13 @@ static void test_flag_no(void) {
static void test_flag_val_1(void) {
int x = 2;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo=1"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=1")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_flag(cl, "foo", NULL, &x);
+ 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);
@@ -194,13 +198,13 @@ static void test_flag_val_1(void) {
static void test_flag_val_0(void) {
int x = 2;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo=0"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=0")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_flag(cl, "foo", NULL, &x);
+ 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);
@@ -209,13 +213,13 @@ static void test_flag_val_0(void) {
static void test_flag_val_true(void) {
int x = 2;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo=true"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=true")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_flag(cl, "foo", NULL, &x);
+ 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);
@@ -224,13 +228,13 @@ static void test_flag_val_true(void) {
static void test_flag_val_false(void) {
int x = 2;
- gpr_cmdline *cl;
- char *args[] = {(char *)__FILE__, "--foo=false"};
+ gpr_cmdline* cl;
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=false")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_flag(cl, "foo", NULL, &x);
+ 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);
@@ -238,19 +242,21 @@ static void test_flag_val_false(void) {
}
static void test_many(void) {
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- char *args[] = {(char *)__FILE__, "--str", "hello", "-x=4", "-no-flag"};
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--str"),
+ const_cast<char*>("hello"), const_cast<char*>("-x=4"),
+ const_cast<char*>("-no-flag")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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"));
@@ -258,22 +264,23 @@ static void test_many(void) {
gpr_cmdline_destroy(cl);
}
-static void extra_arg_cb(void *user_data, const char *arg) {
- int *count = user_data;
- GPR_ASSERT(arg != NULL);
+static void extra_arg_cb(void* user_data, const char* arg) {
+ int* count = static_cast<int*>(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;
+ gpr_cmdline* cl;
int count = 0;
- char *args[] = {(char *)__FILE__, "a", "b", "c"};
+ char* args[] = {(char*)__FILE__, const_cast<char*>("a"),
+ const_cast<char*>("b"), const_cast<char*>("c")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ 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);
@@ -282,13 +289,15 @@ static void test_extra(void) {
}
static void test_extra_dashdash(void) {
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
int count = 0;
- char *args[] = {(char *)__FILE__, "--", "a", "b", "c"};
+ char* args[] = {(char*)__FILE__, const_cast<char*>("--"),
+ const_cast<char*>("a"), const_cast<char*>("b"),
+ const_cast<char*>("c")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ 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);
@@ -297,21 +306,21 @@ static void test_extra_dashdash(void) {
}
static void test_usage(void) {
- gpr_cmdline *cl;
- char *usage;
+ gpr_cmdline* cl;
+ char* usage;
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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,
- NULL);
+ nullptr);
usage = gpr_cmdline_usage_string(cl, "test");
GPR_ASSERT(0 == strcmp(usage,
@@ -329,23 +338,23 @@ static void test_usage(void) {
}
static void test_help(void) {
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
- char *help[] = {(char *)__FILE__, "-h"};
+ char* help[] = {(char*)__FILE__, const_cast<char*>("-h")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ cl = gpr_cmdline_create(nullptr);
gpr_cmdline_set_survive_failure(cl);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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,
- NULL);
+ nullptr);
GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(help), help));
@@ -353,23 +362,23 @@ static void test_help(void) {
}
static void test_badargs1(void) {
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
- char *bad_arg_name[] = {(char *)__FILE__, "--y"};
+ char* bad_arg_name[] = {(char*)__FILE__, const_cast<char*>("--y")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ cl = gpr_cmdline_create(nullptr);
gpr_cmdline_set_survive_failure(cl);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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,
- NULL);
+ nullptr);
GPR_ASSERT(0 ==
gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_arg_name), bad_arg_name));
@@ -378,23 +387,24 @@ static void test_badargs1(void) {
}
static void test_badargs2(void) {
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
- char *bad_int_value[] = {(char *)__FILE__, "--x", "henry"};
+ char* bad_int_value[] = {(char*)__FILE__, const_cast<char*>("--x"),
+ const_cast<char*>("henry")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ cl = gpr_cmdline_create(nullptr);
gpr_cmdline_set_survive_failure(cl);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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,
- NULL);
+ nullptr);
GPR_ASSERT(
0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_int_value), bad_int_value));
@@ -403,23 +413,23 @@ static void test_badargs2(void) {
}
static void test_badargs3(void) {
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
- char *bad_bool_value[] = {(char *)__FILE__, "--flag=henry"};
+ char* bad_bool_value[] = {(char*)__FILE__, const_cast<char*>("--flag=henry")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ cl = gpr_cmdline_create(nullptr);
gpr_cmdline_set_survive_failure(cl);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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,
- NULL);
+ nullptr);
GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value),
bad_bool_value));
@@ -428,23 +438,23 @@ static void test_badargs3(void) {
}
static void test_badargs4(void) {
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- char *str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
- char *bad_bool_value[] = {(char *)__FILE__, "--no-str"};
+ char* bad_bool_value[] = {(char*)__FILE__, const_cast<char*>("--no-str")};
LOG_TEST();
- cl = gpr_cmdline_create(NULL);
+ cl = gpr_cmdline_create(nullptr);
gpr_cmdline_set_survive_failure(cl);
- gpr_cmdline_add_string(cl, "str", NULL, &str);
- gpr_cmdline_add_int(cl, "x", NULL, &x);
- gpr_cmdline_add_flag(cl, "flag", NULL, &flag);
+ 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,
- NULL);
+ nullptr);
GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value),
bad_bool_value));
@@ -452,7 +462,7 @@ static void test_badargs4(void) {
gpr_cmdline_destroy(cl);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_simple_int();
test_eq_int();
diff --git a/test/core/support/cpu_test.c b/test/core/gpr/cpu_test.cc
index 72db53fa49..87cdc0fb50 100644
--- a/test/core/support/cpu_test.c
+++ b/test/core/gpr/cpu_test.cc
@@ -57,18 +57,18 @@ struct cpu_test {
uint32_t ncores;
int is_done;
gpr_cv done_cv;
- int *used; /* is this core used? */
+ int* used; /* is this core used? */
unsigned r; /* random number */
};
-static void worker_thread(void *arg) {
- struct cpu_test *ct = (struct cpu_test *)arg;
+static void worker_thread(void* arg) {
+ struct cpu_test* ct = (struct cpu_test*)arg;
uint32_t cpu;
unsigned r = 12345678;
unsigned i, j;
/* Avoid repetitive division calculations */
int64_t max_i = 1000 / grpc_test_slowdown_factor();
- int64_t max_j = 1000000 / grpc_test_slowdown_factor();
+ int64_t max_j = 1000 / grpc_test_slowdown_factor();
for (i = 0; i < max_i; i++) {
/* run for a bit - just calculate something random. */
for (j = 0; j < max_j; j++) {
@@ -104,31 +104,35 @@ static void cpu_test(void) {
ct.ncores = gpr_cpu_num_cores();
GPR_ASSERT(ct.ncores > 0);
ct.nthreads = (int)ct.ncores * 3;
- ct.used = gpr_malloc(ct.ncores * sizeof(int));
+ ct.used = static_cast<int*>(gpr_malloc(ct.ncores * sizeof(int)));
memset(ct.used, 0, ct.ncores * sizeof(int));
gpr_mu_init(&ct.mu);
gpr_cv_init(&ct.done_cv);
ct.is_done = 0;
for (i = 0; i < ct.ncores * 3; i++) {
- GPR_ASSERT(gpr_thd_new(&thd, &worker_thread, &ct, NULL));
+ GPR_ASSERT(
+ gpr_thd_new(&thd, "grpc_cpu_test", &worker_thread, &ct, nullptr));
}
gpr_mu_lock(&ct.mu);
while (!ct.is_done) {
- gpr_cv_wait(&ct.done_cv, &ct.mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&ct.done_cv, &ct.mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&ct.mu);
fprintf(stderr, "Saw cores [");
+ fflush(stderr);
for (i = 0; i < ct.ncores; i++) {
if (ct.used[i]) {
fprintf(stderr, "%d,", i);
+ fflush(stderr);
cores_seen++;
}
}
fprintf(stderr, "] (%d/%d)\n", cores_seen, ct.ncores);
+ fflush(stderr);
gpr_free(ct.used);
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
cpu_test();
return 0;
diff --git a/test/core/support/env_test.c b/test/core/gpr/env_test.cc
index 661a546720..3f4b493239 100644
--- a/test/core/support/env_test.c
+++ b/test/core/gpr/env_test.cc
@@ -22,27 +22,27 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
static void test_setenv_getenv(void) {
- const char *name = "FOO";
- const char *value = "BAR";
- char *retrieved_value;
+ const char* name = "FOO";
+ const char* value = "BAR";
+ char* retrieved_value;
LOG_TEST_NAME("test_setenv_getenv");
gpr_setenv(name, value);
retrieved_value = gpr_getenv(name);
- GPR_ASSERT(retrieved_value != NULL);
+ GPR_ASSERT(retrieved_value != nullptr);
GPR_ASSERT(strcmp(value, retrieved_value) == 0);
gpr_free(retrieved_value);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_setenv_getenv();
return 0;
diff --git a/test/core/support/host_port_test.c b/test/core/gpr/host_port_test.cc
index 2ff3bcf68e..42dd56524f 100644
--- a/test/core/support/host_port_test.c
+++ b/test/core/gpr/host_port_test.cc
@@ -23,9 +23,9 @@
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
-static void join_host_port_expect(const char *host, int port,
- const char *expected) {
- char *buf;
+static void join_host_port_expect(const char* host, int port,
+ const char* expected) {
+ char* buf;
int len;
len = gpr_join_host_port(&buf, host, port);
GPR_ASSERT(len >= 0);
@@ -48,7 +48,7 @@ static void test_join_host_port_garbage(void) {
join_host_port_expect("::]", 107, "[::]]:107");
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_join_host_port();
diff --git a/test/core/support/log_test.c b/test/core/gpr/log_test.cc
index c221ff6783..839ff0aef9 100644
--- a/test/core/support/log_test.c
+++ b/test/core/gpr/log_test.cc
@@ -21,22 +21,22 @@
#include <stdbool.h>
#include <string.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "test/core/util/test_config.h"
static bool log_func_reached = false;
-static void test_callback(gpr_log_func_args *args) {
+static void test_callback(gpr_log_func_args* args) {
GPR_ASSERT(0 == strcmp(__FILE__, args->file));
GPR_ASSERT(args->severity == GPR_LOG_SEVERITY_INFO);
GPR_ASSERT(0 == strcmp(args->message, "hello 1 2 3"));
}
-static void test_should_log(gpr_log_func_args *args) {
+static void test_should_log(gpr_log_func_args* args) {
log_func_reached = true;
}
-static void test_should_not_log(gpr_log_func_args *args) { GPR_ASSERT(false); }
+static void test_should_not_log(gpr_log_func_args* args) { GPR_ASSERT(false); }
#define test_log_function_reached(SEVERITY) \
gpr_set_log_function(test_should_log); \
@@ -52,7 +52,7 @@ static void test_should_not_log(gpr_log_func_args *args) { GPR_ASSERT(false); }
gpr_log_message(SEVERITY, "hello 1 2 3"); \
gpr_log(SEVERITY, "hello %d %d %d", 1, 2, 3);
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
/* test logging at various verbosity levels */
gpr_log(GPR_DEBUG, "%s", "hello world");
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
gpr_set_log_function(test_callback);
gpr_log_message(GPR_INFO, "hello 1 2 3");
gpr_log(GPR_INFO, "hello %d %d %d", 1, 2, 3);
- gpr_set_log_function(NULL);
+ gpr_set_log_function(nullptr);
/* gpr_log_verbosity_init() will be effective only once, and only before
* gpr_set_log_verbosity() is called */
diff --git a/test/core/support/mpscq_test.c b/test/core/gpr/mpscq_test.cc
index 5e7dc9fca5..5a8177543c 100644
--- a/test/core/support/mpscq_test.c
+++ b/test/core/gpr/mpscq_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/mpscq.h"
+#include "src/core/lib/gpr/mpscq.h"
#include <stdlib.h>
@@ -30,11 +30,11 @@
typedef struct test_node {
gpr_mpscq_node node;
size_t i;
- size_t *ctr;
+ size_t* ctr;
} test_node;
-static test_node *new_node(size_t i, size_t *ctr) {
- test_node *n = gpr_malloc(sizeof(test_node));
+static test_node* new_node(size_t i, size_t* ctr) {
+ test_node* n = static_cast<test_node*>(gpr_malloc(sizeof(test_node)));
n->i = i;
n->ctr = ctr;
return n;
@@ -45,10 +45,10 @@ static void test_serial(void) {
gpr_mpscq q;
gpr_mpscq_init(&q);
for (size_t i = 0; i < 10000000; i++) {
- gpr_mpscq_push(&q, &new_node(i, NULL)->node);
+ gpr_mpscq_push(&q, &new_node(i, nullptr)->node);
}
for (size_t i = 0; i < 10000000; i++) {
- test_node *n = (test_node *)gpr_mpscq_pop(&q);
+ test_node* n = (test_node*)gpr_mpscq_pop(&q);
GPR_ASSERT(n);
GPR_ASSERT(n->i == i);
gpr_free(n);
@@ -57,14 +57,14 @@ static void test_serial(void) {
typedef struct {
size_t ctr;
- gpr_mpscq *q;
- gpr_event *start;
+ gpr_mpscq* q;
+ gpr_event* start;
} thd_args;
#define THREAD_ITERATIONS 10000
-static void test_thread(void *args) {
- thd_args *a = args;
+static void test_thread(void* args) {
+ thd_args* a = static_cast<thd_args*>(args);
gpr_event_wait(a->start, gpr_inf_future(GPR_CLOCK_REALTIME));
for (size_t i = 1; i <= THREAD_ITERATIONS; i++) {
gpr_mpscq_push(a->q, &new_node(i, &a->ctr)->node);
@@ -85,17 +85,18 @@ static void test_mt(void) {
ta[i].ctr = 0;
ta[i].q = &q;
ta[i].start = &start;
- GPR_ASSERT(gpr_thd_new(&thds[i], test_thread, &ta[i], &options));
+ GPR_ASSERT(
+ gpr_thd_new(&thds[i], "grpc_mt_test", test_thread, &ta[i], &options));
}
size_t num_done = 0;
size_t spins = 0;
- gpr_event_set(&start, (void *)1);
+ gpr_event_set(&start, (void*)1);
while (num_done != GPR_ARRAY_SIZE(thds)) {
- gpr_mpscq_node *n;
- while ((n = gpr_mpscq_pop(&q)) == NULL) {
+ gpr_mpscq_node* n;
+ while ((n = gpr_mpscq_pop(&q)) == nullptr) {
spins++;
}
- test_node *tn = (test_node *)n;
+ test_node* tn = (test_node*)n;
GPR_ASSERT(*tn->ctr == tn->i - 1);
*tn->ctr = tn->i;
if (tn->i == THREAD_ITERATIONS) num_done++;
@@ -109,17 +110,17 @@ static void test_mt(void) {
}
typedef struct {
- thd_args *ta;
+ thd_args* ta;
size_t num_thds;
gpr_mu mu;
size_t num_done;
size_t spins;
- gpr_mpscq *q;
- gpr_event *start;
+ gpr_mpscq* q;
+ gpr_event* start;
} pull_args;
-static void pull_thread(void *arg) {
- pull_args *pa = arg;
+static void pull_thread(void* arg) {
+ pull_args* pa = static_cast<pull_args*>(arg);
gpr_event_wait(pa->start, gpr_inf_future(GPR_CLOCK_REALTIME));
for (;;) {
@@ -128,11 +129,11 @@ static void pull_thread(void *arg) {
gpr_mu_unlock(&pa->mu);
return;
}
- gpr_mpscq_node *n;
- while ((n = gpr_mpscq_pop(pa->q)) == NULL) {
+ gpr_mpscq_node* n;
+ while ((n = gpr_mpscq_pop(pa->q)) == nullptr) {
pa->spins++;
}
- test_node *tn = (test_node *)n;
+ test_node* tn = (test_node*)n;
GPR_ASSERT(*tn->ctr == tn->i - 1);
*tn->ctr = tn->i;
if (tn->i == THREAD_ITERATIONS) pa->num_done++;
@@ -156,7 +157,8 @@ static void test_mt_multipop(void) {
ta[i].ctr = 0;
ta[i].q = &q;
ta[i].start = &start;
- GPR_ASSERT(gpr_thd_new(&thds[i], test_thread, &ta[i], &options));
+ GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_multipop_test", test_thread, &ta[i],
+ &options));
}
pull_args pa;
pa.ta = ta;
@@ -169,9 +171,10 @@ static void test_mt_multipop(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) {
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
- GPR_ASSERT(gpr_thd_new(&pull_thds[i], pull_thread, &pa, &options));
+ GPR_ASSERT(gpr_thd_new(&pull_thds[i], "grpc_multipop_pull", pull_thread,
+ &pa, &options));
}
- gpr_event_set(&start, (void *)1);
+ gpr_event_set(&start, (void*)1);
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) {
gpr_thd_join(pull_thds[i]);
}
@@ -182,7 +185,7 @@ static void test_mt_multipop(void) {
gpr_mpscq_destroy(&q);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_serial();
test_mt();
diff --git a/test/core/support/murmur_hash_test.c b/test/core/gpr/murmur_hash_test.cc
index 5677515d04..d920dd3f95 100644
--- a/test/core/support/murmur_hash_test.c
+++ b/test/core/gpr/murmur_hash_test.cc
@@ -16,14 +16,14 @@
*
*/
-#include "src/core/lib/support/murmur_hash.h"
+#include "src/core/lib/gpr/murmur_hash.h"
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "test/core/util/test_config.h"
#include <string.h>
-typedef uint32_t (*hash_func)(const void *key, size_t len, uint32_t seed);
+typedef uint32_t (*hash_func)(const void* key, size_t len, uint32_t seed);
/* From smhasher:
This should hopefully be a thorough and uambiguous test of whether a hash
@@ -63,7 +63,7 @@ static void verification_test(hash_func hash, uint32_t expected) {
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
/* basic tests to verify that things don't crash */
gpr_murmur_hash3("", 0, 0);
diff --git a/test/core/support/spinlock_test.c b/test/core/gpr/spinlock_test.cc
index b236a88ab7..77e3dfbede 100644
--- a/test/core/support/spinlock_test.c
+++ b/test/core/gpr/spinlock_test.cc
@@ -18,7 +18,7 @@
/* Test of gpr synchronization support. */
-#include "src/core/lib/support/spinlock.h"
+#include "src/core/lib/gpr/spinlock.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -32,7 +32,7 @@
/* Tests for gpr_spinlock. */
struct test {
int thread_count; /* number of threads */
- gpr_thd_id *threads;
+ gpr_thd_id* threads;
int64_t iterations; /* number of iterations per thread */
int64_t counter;
@@ -42,10 +42,11 @@ struct test {
};
/* Return pointer to a new struct test. */
-static struct test *test_new(int threads, int64_t iterations, int incr_step) {
- struct test *m = gpr_malloc(sizeof(*m));
+static struct test* test_new(int threads, int64_t iterations, int incr_step) {
+ struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m)));
m->thread_count = threads;
- m->threads = gpr_malloc(sizeof(*m->threads) * (size_t)threads);
+ m->threads = static_cast<gpr_thd_id*>(
+ gpr_malloc(sizeof(*m->threads) * (size_t)threads));
m->iterations = iterations;
m->counter = 0;
m->thread_count = 0;
@@ -55,23 +56,24 @@ static struct test *test_new(int threads, int64_t iterations, int incr_step) {
}
/* Return pointer to a new struct test. */
-static void test_destroy(struct test *m) {
+static void test_destroy(struct test* m) {
gpr_free(m->threads);
gpr_free(m);
}
/* Create m->threads threads, each running (*body)(m) */
-static void test_create_threads(struct test *m, void (*body)(void *arg)) {
+static void test_create_threads(struct test* m, void (*body)(void* arg)) {
int i;
for (i = 0; i != m->thread_count; i++) {
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- GPR_ASSERT(gpr_thd_new(&m->threads[i], body, m, &opt));
+ GPR_ASSERT(
+ gpr_thd_new(&m->threads[i], "grpc_create_threads", body, m, &opt));
}
}
/* Wait until all threads report done. */
-static void test_wait(struct test *m) {
+static void test_wait(struct test* m) {
int i;
for (i = 0; i != m->thread_count; i++) {
gpr_thd_join(m->threads[i]);
@@ -84,24 +86,27 @@ static void test_wait(struct test *m) {
incr_step controls by how much m->refcount should be incremented/decremented
(if at all) each time in the tests.
*/
-static void test(const char *name, void (*body)(void *m), int timeout_s,
+static void test(const char* name, void (*body)(void* m), int timeout_s,
int incr_step) {
int64_t iterations = 1024;
- struct test *m;
+ struct test* m;
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
+ fflush(stderr);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
if (iterations < INT64_MAX / 2) iterations <<= 1;
fprintf(stderr, " %ld", (long)iterations);
+ fflush(stderr);
m = test_new(10, iterations, incr_step);
test_create_threads(m, body);
test_wait(m);
if (m->counter != m->thread_count * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
(long)m->counter, m->thread_count, (long)m->iterations);
+ fflush(stderr);
GPR_ASSERT(0);
}
test_destroy(m);
@@ -109,11 +114,12 @@ static void test(const char *name, void (*body)(void *m), int timeout_s,
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
(int)time_taken.tv_nsec);
+ fflush(stderr);
}
/* Increment m->counter on each iteration; then mark thread as done. */
-static void inc(void *v /*=m*/) {
- struct test *m = v;
+static void inc(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations; i++) {
gpr_spinlock_lock(&m->mu);
@@ -124,8 +130,8 @@ static void inc(void *v /*=m*/) {
/* Increment m->counter under lock acquired with trylock, m->iterations times;
then mark thread as done. */
-static void inctry(void *v /*=m*/) {
- struct test *m = v;
+static void inctry(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations;) {
if (gpr_spinlock_trylock(&m->mu)) {
@@ -138,7 +144,7 @@ static void inctry(void *v /*=m*/) {
/* ------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
test("spinlock", &inc, 1, 1);
test("spinlock try", &inctry, 1, 1);
diff --git a/test/core/support/string_test.c b/test/core/gpr/string_test.cc
index bee2139477..57068eb2c9 100644
--- a/test/core/support/string_test.c
+++ b/test/core/gpr/string_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include <limits.h>
#include <stddef.h>
@@ -32,8 +32,8 @@
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
static void test_strdup(void) {
- static const char *src1 = "hello world";
- char *dst1;
+ static const char* src1 = "hello world";
+ char* dst1;
LOG_TEST_NAME("test_strdup");
@@ -41,12 +41,12 @@ static void test_strdup(void) {
GPR_ASSERT(0 == strcmp(src1, dst1));
gpr_free(dst1);
- GPR_ASSERT(NULL == gpr_strdup(NULL));
+ GPR_ASSERT(nullptr == gpr_strdup(nullptr));
}
-static void expect_dump(const char *buf, size_t len, uint32_t flags,
- const char *result) {
- char *got = gpr_dump(buf, len, flags);
+static void expect_dump(const char* buf, size_t len, uint32_t flags,
+ const char* result) {
+ char* got = gpr_dump(buf, len, flags);
GPR_ASSERT(0 == strcmp(got, result));
gpr_free(got);
}
@@ -61,12 +61,12 @@ static void test_dump(void) {
expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'");
}
-static void test_pu32_fail(const char *s) {
+static void test_pu32_fail(const char* s) {
uint32_t out;
GPR_ASSERT(!gpr_parse_bytes_to_uint32(s, strlen(s), &out));
}
-static void test_pu32_succeed(const char *s, uint32_t want) {
+static void test_pu32_succeed(const char* s, uint32_t want) {
uint32_t out;
GPR_ASSERT(gpr_parse_bytes_to_uint32(s, strlen(s), &out));
GPR_ASSERT(out == want);
@@ -107,7 +107,7 @@ static void test_parse_uint32(void) {
}
static void test_asprintf(void) {
- char *buf;
+ char* buf;
int i, j;
LOG_TEST_NAME("test_asprintf");
@@ -132,9 +132,9 @@ static void test_asprintf(void) {
}
static void test_strjoin(void) {
- const char *parts[4] = {"one", "two", "three", "four"};
+ const char* parts[4] = {"one", "two", "three", "four"};
size_t joined_len;
- char *joined;
+ char* joined;
LOG_TEST_NAME("test_strjoin");
@@ -152,9 +152,9 @@ static void test_strjoin(void) {
}
static void test_strjoin_sep(void) {
- const char *parts[4] = {"one", "two", "three", "four"};
+ const char* parts[4] = {"one", "two", "three", "four"};
size_t joined_len;
- char *joined;
+ char* joined;
LOG_TEST_NAME("test_strjoin_sep");
@@ -179,7 +179,7 @@ static void test_strjoin_sep(void) {
}
static void test_ltoa() {
- char *str;
+ char* str;
char buf[GPR_LTOA_MIN_BUFSIZE];
LOG_TEST_NAME("test_ltoa");
@@ -226,7 +226,7 @@ static void test_int64toa() {
}
static void test_leftpad() {
- char *padded;
+ char* padded;
LOG_TEST_NAME("test_leftpad");
@@ -271,12 +271,12 @@ static void test_stricmp(void) {
static void test_memrchr(void) {
LOG_TEST_NAME("test_memrchr");
- GPR_ASSERT(NULL == gpr_memrchr(NULL, 'a', 0));
- GPR_ASSERT(NULL == gpr_memrchr("", 'a', 0));
- GPR_ASSERT(NULL == gpr_memrchr("hello", 'b', 5));
- GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'h', 5), "hello"));
- GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'o', 5), "o"));
- GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'l', 5), "lo"));
+ GPR_ASSERT(nullptr == gpr_memrchr(nullptr, 'a', 0));
+ GPR_ASSERT(nullptr == gpr_memrchr("", 'a', 0));
+ GPR_ASSERT(nullptr == gpr_memrchr("hello", 'b', 5));
+ GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'h', 5), "hello"));
+ GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'o', 5), "o"));
+ GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'l', 5), "lo"));
}
static void test_is_true(void) {
@@ -289,12 +289,12 @@ static void test_is_true(void) {
GPR_ASSERT(true == gpr_is_true("yes"));
GPR_ASSERT(true == gpr_is_true("YES"));
GPR_ASSERT(true == gpr_is_true("1"));
- GPR_ASSERT(false == gpr_is_true(NULL));
+ GPR_ASSERT(false == gpr_is_true(nullptr));
GPR_ASSERT(false == gpr_is_true(""));
GPR_ASSERT(false == gpr_is_true("0"));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_strdup();
test_dump();
diff --git a/test/core/support/sync_test.c b/test/core/gpr/sync_test.cc
index 178d77edcd..768f96d093 100644
--- a/test/core/support/sync_test.c
+++ b/test/core/gpr/sync_test.cc
@@ -47,7 +47,7 @@ typedef struct queue {
} queue;
/* Initialize *q. */
-void queue_init(queue *q) {
+void queue_init(queue* q) {
gpr_mu_init(&q->mu);
gpr_cv_init(&q->non_empty);
gpr_cv_init(&q->non_full);
@@ -56,14 +56,14 @@ void queue_init(queue *q) {
}
/* Free storage associated with *q. */
-void queue_destroy(queue *q) {
+void queue_destroy(queue* q) {
gpr_mu_destroy(&q->mu);
gpr_cv_destroy(&q->non_empty);
gpr_cv_destroy(&q->non_full);
}
/* Wait until there is room in *q, then append x to *q. */
-void queue_append(queue *q, int x) {
+void queue_append(queue* q, int x) {
gpr_mu_lock(&q->mu);
/* To wait for a predicate without a deadline, loop on the negation of the
predicate, and use gpr_cv_wait(..., gpr_inf_future(GPR_CLOCK_REALTIME))
@@ -73,7 +73,7 @@ void queue_append(queue *q, int x) {
corresponding condition variable. The predicate must be on state
protected by the lock. */
while (q->length == N) {
- gpr_cv_wait(&q->non_full, &q->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&q->non_full, &q->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
if (q->length == 0) { /* Wake threads blocked in queue_remove(). */
/* It's normal to use gpr_cv_broadcast() or gpr_signal() while
@@ -87,7 +87,7 @@ void queue_append(queue *q, int x) {
/* If it can be done without blocking, append x to *q and return non-zero.
Otherwise return 0. */
-int queue_try_append(queue *q, int x) {
+int queue_try_append(queue* q, int x) {
int result = 0;
if (gpr_mu_trylock(&q->mu)) {
if (q->length != N) {
@@ -106,7 +106,7 @@ int queue_try_append(queue *q, int x) {
/* Wait until the *q is non-empty or deadline abs_deadline passes. If the
queue is non-empty, remove its head entry, place it in *head, and return
non-zero. Otherwise return 0. */
-int queue_remove(queue *q, int *head, gpr_timespec abs_deadline) {
+int queue_remove(queue* q, int* head, gpr_timespec abs_deadline) {
int result = 0;
gpr_mu_lock(&q->mu);
/* To wait for a predicate with a deadline, loop on the negation of the
@@ -156,8 +156,8 @@ struct test {
};
/* Return pointer to a new struct test. */
-static struct test *test_new(int threads, int64_t iterations, int incr_step) {
- struct test *m = gpr_malloc(sizeof(*m));
+static struct test* test_new(int threads, int64_t iterations, int incr_step) {
+ struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m)));
m->threads = threads;
m->iterations = iterations;
m->counter = 0;
@@ -176,7 +176,7 @@ static struct test *test_new(int threads, int64_t iterations, int incr_step) {
}
/* Return pointer to a new struct test. */
-static void test_destroy(struct test *m) {
+static void test_destroy(struct test* m) {
gpr_mu_destroy(&m->mu);
gpr_cv_destroy(&m->cv);
gpr_cv_destroy(&m->done_cv);
@@ -185,25 +185,25 @@ static void test_destroy(struct test *m) {
}
/* Create m->threads threads, each running (*body)(m) */
-static void test_create_threads(struct test *m, void (*body)(void *arg)) {
+static void test_create_threads(struct test* m, void (*body)(void* arg)) {
gpr_thd_id id;
int i;
for (i = 0; i != m->threads; i++) {
- GPR_ASSERT(gpr_thd_new(&id, body, m, NULL));
+ GPR_ASSERT(gpr_thd_new(&id, "grpc_create_threads", body, m, nullptr));
}
}
/* Wait until all threads report done. */
-static void test_wait(struct test *m) {
+static void test_wait(struct test* m) {
gpr_mu_lock(&m->mu);
while (m->done != 0) {
- gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&m->mu);
}
/* Get an integer thread id in the raneg 0..threads-1 */
-static int thread_id(struct test *m) {
+static int thread_id(struct test* m) {
int id;
gpr_mu_lock(&m->mu);
id = m->thread_count++;
@@ -213,7 +213,7 @@ static int thread_id(struct test *m) {
/* Indicate that a thread is done, by decrementing m->done
and signalling done_cv if m->done==0. */
-static void mark_thread_done(struct test *m) {
+static void mark_thread_done(struct test* m) {
gpr_mu_lock(&m->mu);
GPR_ASSERT(m->done != 0);
m->done--;
@@ -229,22 +229,23 @@ static void mark_thread_done(struct test *m) {
incr_step controls by how much m->refcount should be incremented/decremented
(if at all) each time in the tests.
*/
-static void test(const char *name, void (*body)(void *m),
- void (*extra)(void *m), int timeout_s, int incr_step) {
- int64_t iterations = 1024;
- struct test *m;
+static void test(const char* name, void (*body)(void* m),
+ void (*extra)(void* m), int timeout_s, int incr_step) {
+ int64_t iterations = 256;
+ struct test* m;
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
+ fflush(stderr);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
- iterations <<= 1;
fprintf(stderr, " %ld", (long)iterations);
+ fflush(stderr);
m = test_new(10, iterations, incr_step);
- if (extra != NULL) {
+ if (extra != nullptr) {
gpr_thd_id id;
- GPR_ASSERT(gpr_thd_new(&id, extra, m, NULL));
+ GPR_ASSERT(gpr_thd_new(&id, name, extra, m, nullptr));
m->done++; /* one more thread to wait for */
}
test_create_threads(m, body);
@@ -252,18 +253,21 @@ static void test(const char *name, void (*body)(void *m),
if (m->counter != m->threads * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
(long)m->counter, m->threads, (long)m->iterations);
+ fflush(stderr);
GPR_ASSERT(0);
}
test_destroy(m);
+ iterations <<= 1;
}
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
(int)time_taken.tv_nsec);
+ fflush(stderr);
}
/* Increment m->counter on each iteration; then mark thread as done. */
-static void inc(void *v /*=m*/) {
- struct test *m = v;
+static void inc(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations; i++) {
gpr_mu_lock(&m->mu);
@@ -275,8 +279,8 @@ static void inc(void *v /*=m*/) {
/* Increment m->counter under lock acquired with trylock, m->iterations times;
then mark thread as done. */
-static void inctry(void *v /*=m*/) {
- struct test *m = v;
+static void inctry(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations;) {
if (gpr_mu_trylock(&m->mu)) {
@@ -290,14 +294,14 @@ static void inctry(void *v /*=m*/) {
/* Increment counter only when (m->counter%m->threads)==m->thread_id; then mark
thread as done. */
-static void inc_by_turns(void *v /*=m*/) {
- struct test *m = v;
+static void inc_by_turns(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
int id = thread_id(m);
for (i = 0; i != m->iterations; i++) {
gpr_mu_lock(&m->mu);
while ((m->counter % m->threads) != id) {
- gpr_cv_wait(&m->cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&m->cv, &m->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
m->counter++;
gpr_cv_broadcast(&m->cv);
@@ -308,13 +312,13 @@ static void inc_by_turns(void *v /*=m*/) {
/* Wait a millisecond and increment counter on each iteration;
then mark thread as done. */
-static void inc_with_1ms_delay(void *v /*=m*/) {
- struct test *m = v;
+static void inc_with_1ms_delay(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations; i++) {
gpr_timespec deadline;
gpr_mu_lock(&m->mu);
- deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(1000, GPR_TIMESPAN));
while (!gpr_cv_wait(&m->cv, &m->mu, deadline)) {
}
@@ -326,14 +330,14 @@ static void inc_with_1ms_delay(void *v /*=m*/) {
/* Wait a millisecond and increment counter on each iteration, using an event
for timing; then mark thread as done. */
-static void inc_with_1ms_delay_event(void *v /*=m*/) {
- struct test *m = v;
+static void inc_with_1ms_delay_event(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations; i++) {
gpr_timespec deadline;
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(1000, GPR_TIMESPAN));
- GPR_ASSERT(gpr_event_wait(&m->event, deadline) == NULL);
+ GPR_ASSERT(gpr_event_wait(&m->event, deadline) == nullptr);
gpr_mu_lock(&m->mu);
m->counter++;
gpr_mu_unlock(&m->mu);
@@ -344,8 +348,8 @@ static void inc_with_1ms_delay_event(void *v /*=m*/) {
/* Produce m->iterations elements on queue m->q, then mark thread as done.
Even threads use queue_append(), and odd threads use queue_try_append()
until it succeeds. */
-static void many_producers(void *v /*=m*/) {
- struct test *m = v;
+static void many_producers(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
int x = thread_id(m);
if ((x & 1) == 0) {
@@ -364,28 +368,28 @@ static void many_producers(void *v /*=m*/) {
/* Consume elements from m->q until m->threads*m->iterations are seen,
wait an extra second to confirm that no more elements are arriving,
then mark thread as done. */
-static void consumer(void *v /*=m*/) {
- struct test *m = v;
+static void consumer(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t n = m->iterations * m->threads;
int64_t i;
int value;
for (i = 0; i != n; i++) {
- queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_REALTIME));
+ queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_lock(&m->mu);
m->counter = n;
gpr_mu_unlock(&m->mu);
GPR_ASSERT(
!queue_remove(&m->q, &value,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(1000000, GPR_TIMESPAN))));
mark_thread_done(m);
}
/* Increment m->stats_counter m->iterations times, transfer counter value to
m->counter, then mark thread as done. */
-static void statsinc(void *v /*=m*/) {
- struct test *m = v;
+static void statsinc(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations; i++) {
gpr_stats_inc(&m->stats_counter, 1);
@@ -399,8 +403,8 @@ static void statsinc(void *v /*=m*/) {
/* Increment m->refcount by m->incr_step for m->iterations times. Decrement
m->thread_refcount once, and if it reaches zero, set m->event to (void*)1;
then mark thread as done. */
-static void refinc(void *v /*=m*/) {
- struct test *m = v;
+static void refinc(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t i;
for (i = 0; i != m->iterations; i++) {
if (m->incr_step == 1) {
@@ -410,7 +414,7 @@ static void refinc(void *v /*=m*/) {
}
}
if (gpr_unref(&m->thread_refcount)) {
- gpr_event_set(&m->event, (void *)1);
+ gpr_event_set(&m->event, (void*)1);
}
mark_thread_done(m);
}
@@ -418,13 +422,13 @@ static void refinc(void *v /*=m*/) {
/* Wait until m->event is set to (void *)1, then decrement m->refcount by 1
(m->threads * m->iterations * m->incr_step) times, and ensure that the last
decrement caused the counter to reach zero, then mark thread as done. */
-static void refcheck(void *v /*=m*/) {
- struct test *m = v;
+static void refcheck(void* v /*=m*/) {
+ struct test* m = static_cast<struct test*>(v);
int64_t n = m->iterations * m->threads * m->incr_step;
int64_t i;
GPR_ASSERT(gpr_event_wait(&m->event, gpr_inf_future(GPR_CLOCK_REALTIME)) ==
- (void *)1);
- GPR_ASSERT(gpr_event_get(&m->event) == (void *)1);
+ (void*)1);
+ GPR_ASSERT(gpr_event_get(&m->event) == (void*)1);
for (i = 1; i != n; i++) {
GPR_ASSERT(!gpr_unref(&m->refcount));
m->counter++;
@@ -436,18 +440,18 @@ static void refcheck(void *v /*=m*/) {
/* ------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
- test("mutex", &inc, NULL, 1, 1);
- test("mutex try", &inctry, NULL, 1, 1);
- test("cv", &inc_by_turns, NULL, 1, 1);
- test("timedcv", &inc_with_1ms_delay, NULL, 1, 1);
+ test("mutex", &inc, nullptr, 1, 1);
+ test("mutex try", &inctry, nullptr, 1, 1);
+ test("cv", &inc_by_turns, nullptr, 1, 1);
+ test("timedcv", &inc_with_1ms_delay, nullptr, 1, 1);
test("queue", &many_producers, &consumer, 10, 1);
- test("stats_counter", &statsinc, NULL, 1, 1);
+ test("stats_counter", &statsinc, nullptr, 1, 1);
test("refcount by 1", &refinc, &refcheck, 1, 1);
test("refcount by 3", &refinc, &refcheck, 1, 3); /* incr_step of 3 is an
arbitrary choice. Any
number > 1 is okay here */
- test("timedevent", &inc_with_1ms_delay_event, NULL, 1, 1);
+ test("timedevent", &inc_with_1ms_delay_event, nullptr, 1, 1);
return 0;
}
diff --git a/test/core/support/thd_test.c b/test/core/gpr/thd_test.cc
index 2c578a242c..b755bf18f3 100644
--- a/test/core/support/thd_test.c
+++ b/test/core/gpr/thd_test.cc
@@ -36,8 +36,8 @@ struct test {
};
/* A Thread body. Decrement t->n, and if is becomes zero, set t->done. */
-static void thd_body(void *v) {
- struct test *t = v;
+static void thd_body(void* v) {
+ struct test* t = static_cast<struct test*>(v);
gpr_mu_lock(&t->mu);
t->n--;
if (t->n == 0) {
@@ -47,7 +47,7 @@ static void thd_body(void *v) {
gpr_mu_unlock(&t->mu);
}
-static void thd_body_joinable(void *v) {}
+static void thd_body_joinable(void* v) {}
/* Test thread options work as expected */
static void test_options(void) {
@@ -74,7 +74,7 @@ static void test(void) {
t.n = NUM_THREADS;
t.is_done = 0;
for (i = 0; i < NUM_THREADS; i++) {
- GPR_ASSERT(gpr_thd_new(&thd, &thd_body, &t, NULL));
+ GPR_ASSERT(gpr_thd_new(&thd, "grpc_thread_test", &thd_body, &t, nullptr));
}
gpr_mu_lock(&t.mu);
while (!t.is_done) {
@@ -84,7 +84,8 @@ static void test(void) {
GPR_ASSERT(t.n == 0);
gpr_thd_options_set_joinable(&options);
for (i = 0; i < NUM_THREADS; i++) {
- GPR_ASSERT(gpr_thd_new(&thds[i], &thd_body_joinable, NULL, &options));
+ GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_joinable_thread_test",
+ &thd_body_joinable, nullptr, &options));
}
for (i = 0; i < NUM_THREADS; i++) {
gpr_thd_join(thds[i]);
@@ -93,7 +94,7 @@ static void test(void) {
/* ------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
test_options();
test();
diff --git a/test/core/support/time_test.c b/test/core/gpr/time_test.cc
index 74b5ef6114..b2b4dce58e 100644
--- a/test/core/support/time_test.c
+++ b/test/core/gpr/time_test.cc
@@ -28,15 +28,15 @@
#include <string.h>
#include "test/core/util/test_config.h"
-static void to_fp(void *arg, const char *buf, size_t len) {
- fwrite(buf, 1, len, (FILE *)arg);
+static void to_fp(void* arg, const char* buf, size_t len) {
+ fwrite(buf, 1, len, (FILE*)arg);
}
/* Convert gpr_intmax x to ascii base b (2..16), and write with
(*writer)(arg, ...), zero padding to "chars" digits). */
static void i_to_s(intmax_t x, int base, int chars,
- void (*writer)(void *arg, const char *buf, size_t len),
- void *arg) {
+ void (*writer)(void* arg, const char* buf, size_t len),
+ void* arg) {
char buf[64];
char fmt[32];
GPR_ASSERT(base == 16 || base == 10);
@@ -47,8 +47,8 @@ static void i_to_s(intmax_t x, int base, int chars,
/* Convert ts to ascii, and write with (*writer)(arg, ...). */
static void ts_to_s(gpr_timespec t,
- void (*writer)(void *arg, const char *buf, size_t len),
- void *arg) {
+ void (*writer)(void* arg, const char* buf, size_t len),
+ void* arg) {
if (t.tv_sec < 0 && t.tv_nsec != 0) {
t.tv_sec++;
t.tv_nsec = GPR_NS_PER_SEC - t.tv_nsec;
@@ -66,21 +66,28 @@ static void test_values(void) {
x = gpr_inf_future(GPR_CLOCK_REALTIME);
fprintf(stderr, "far future ");
+ fflush(stderr);
i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
GPR_ASSERT(x.tv_sec == INT64_MAX);
fprintf(stderr, "far future ");
+ fflush(stderr);
ts_to_s(x, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
x = gpr_inf_past(GPR_CLOCK_REALTIME);
fprintf(stderr, "far past ");
+ fflush(stderr);
i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
GPR_ASSERT(x.tv_sec == INT64_MIN);
fprintf(stderr, "far past ");
+ fflush(stderr);
ts_to_s(x, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
for (i = 1; i != 1000 * 1000 * 1000; i *= 10) {
x = gpr_time_from_micros(i, GPR_TIMESPAN);
@@ -135,15 +142,19 @@ static void test_add_sub(void) {
if (gpr_time_cmp(gpr_time_from_micros(sum * k, GPR_TIMESPAN), sumt) !=
0) {
fprintf(stderr, "i %d j %d sum %d sumt ", i, j, sum);
+ fflush(stderr);
ts_to_s(sumt, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
GPR_ASSERT(0);
}
if (gpr_time_cmp(gpr_time_from_micros(diff * k, GPR_TIMESPAN), difft) !=
0) {
fprintf(stderr, "i %d j %d diff %d diff ", i, j, diff);
+ fflush(stderr);
ts_to_s(sumt, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
GPR_ASSERT(0);
}
}
@@ -241,7 +252,7 @@ static void test_cmp_extreme(void) {
GPR_ASSERT(gpr_time_cmp(t1, t2) == 0);
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
test_values();
diff --git a/test/core/support/tls_test.c b/test/core/gpr/tls_test.cc
index 5529d5cf59..743b10f090 100644
--- a/test/core/support/tls_test.c
+++ b/test/core/gpr/tls_test.cc
@@ -30,7 +30,7 @@
GPR_TLS_DECL(test_var);
-static void thd_body(void *arg) {
+static void thd_body(void* arg) {
intptr_t i;
GPR_ASSERT(gpr_tls_get(&test_var) == 0);
@@ -44,7 +44,7 @@ static void thd_body(void *arg) {
/* ------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
gpr_thd_options opt = gpr_thd_options_default();
int i;
gpr_thd_id threads[NUM_THREADS];
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
gpr_thd_options_set_joinable(&opt);
for (i = 0; i < NUM_THREADS; i++) {
- gpr_thd_new(&threads[i], thd_body, NULL, &opt);
+ gpr_thd_new(&threads[i], "grpc_tls_test", thd_body, nullptr, &opt);
}
for (i = 0; i < NUM_THREADS; i++) {
gpr_thd_join(threads[i]);
diff --git a/test/core/support/useful_test.c b/test/core/gpr/useful_test.cc
index 2f84f485fc..2f86010d77 100644
--- a/test/core/support/useful_test.c
+++ b/test/core/gpr/useful_test.cc
@@ -21,7 +21,7 @@
#include <grpc/support/useful.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int four[4];
int five[5];
uint32_t bitset = 0;
diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD
new file mode 100644
index 0000000000..1c11e0bdb5
--- /dev/null
+++ b/test/core/gprpp/BUILD
@@ -0,0 +1,96 @@
+# 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.
+
+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/gprpp")
+
+grpc_cc_test(
+ name = "manual_constructor_test",
+ srcs = ["manual_constructor_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:gpr++_base",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "memory_test",
+ srcs = ["memory_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ language = "C++",
+ deps = [
+ "//:gpr++_base",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "inlined_vector_test",
+ srcs = ["inlined_vector_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ language = "C++",
+ deps = [
+ "//:inlined_vector",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "orphanable_test",
+ srcs = ["orphanable_test.cc"],
+ language = "C++",
+ deps = [
+ "//:orphanable",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "ref_counted_test",
+ srcs = ["ref_counted_test.cc"],
+ language = "C++",
+ deps = [
+ "//:ref_counted",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "ref_counted_ptr_test",
+ srcs = ["ref_counted_ptr_test.cc"],
+ language = "C++",
+ deps = [
+ "//:ref_counted",
+ "//:ref_counted_ptr",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc
new file mode 100644
index 0000000000..b900afaf3d
--- /dev/null
+++ b/test/core/gprpp/inlined_vector_test.cc
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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 "src/core/lib/gprpp/inlined_vector.h"
+#include <gtest/gtest.h>
+#include "src/core/lib/gprpp/memory.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+
+TEST(InlinedVectorTest, CreateAndIterate) {
+ const int kNumElements = 9;
+ InlinedVector<int, 2> v;
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(i);
+ }
+ EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(i, v[i]);
+ }
+}
+
+TEST(InlinedVectorTest, ValuesAreInlined) {
+ const int kNumElements = 5;
+ InlinedVector<int, 10> v;
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(i);
+ }
+ EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(i, v[i]);
+ }
+}
+
+TEST(InlinedVectorTest, PushBackWithMove) {
+ InlinedVector<UniquePtr<int>, 1> v;
+ UniquePtr<int> i = MakeUnique<int>(3);
+ v.push_back(std::move(i));
+ EXPECT_EQ(nullptr, i.get());
+ EXPECT_EQ(1UL, v.size());
+ EXPECT_EQ(3, *v[0]);
+}
+
+TEST(InlinedVectorTest, EmplaceBack) {
+ InlinedVector<UniquePtr<int>, 1> v;
+ v.emplace_back(New<int>(3));
+ EXPECT_EQ(1UL, v.size());
+ EXPECT_EQ(3, *v[0]);
+}
+
+TEST(InlinedVectorTest, ClearAndRepopulate) {
+ const int kNumElements = 10;
+ InlinedVector<int, 5> v;
+ EXPECT_EQ(0UL, v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(i);
+ EXPECT_EQ(i + 1UL, v.size());
+ }
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(i, v[i]);
+ }
+ v.clear();
+ EXPECT_EQ(0UL, v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(kNumElements + i);
+ EXPECT_EQ(i + 1UL, v.size());
+ }
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(kNumElements + i, v[i]);
+ }
+}
+
+TEST(InlinedVectorTest, ConstIndexOperator) {
+ const int kNumElements = 10;
+ InlinedVector<int, 5> v;
+ EXPECT_EQ(0UL, v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(i);
+ EXPECT_EQ(i + 1UL, v.size());
+ }
+ auto const_func = [kNumElements](const InlinedVector<int, 5>& v) {
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(i, v[i]);
+ }
+ };
+ const_func(v);
+}
+
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/gprpp/manual_constructor_test.cc b/test/core/gprpp/manual_constructor_test.cc
new file mode 100644
index 0000000000..f06c3cab06
--- /dev/null
+++ b/test/core/gprpp/manual_constructor_test.cc
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+/* Test of gpr synchronization support. */
+
+#include "src/core/lib/gprpp/manual_constructor.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <cstring>
+#include "src/core/lib/gprpp/abstract.h"
+#include "test/core/util/test_config.h"
+
+class A {
+ public:
+ A() {}
+ virtual ~A() {}
+ virtual const char* foo() { return "A_foo"; }
+ virtual const char* bar() { return "A_bar"; }
+ GRPC_ABSTRACT_BASE_CLASS
+};
+
+class B : public A {
+ public:
+ B() {}
+ ~B() {}
+ const char* foo() override { return "B_foo"; }
+ char get_junk() { return junk[0]; }
+
+ private:
+ char junk[1000];
+};
+
+class C : public B {
+ public:
+ C() {}
+ ~C() {}
+ virtual const char* bar() { return "C_bar"; }
+ char get_more_junk() { return more_junk[0]; }
+
+ private:
+ char more_junk[1000];
+};
+
+class D : public A {
+ public:
+ virtual const char* bar() { return "D_bar"; }
+};
+
+static void basic_test() {
+ grpc_core::PolymorphicManualConstructor<A, B> poly;
+ poly.Init<B>();
+ GPR_ASSERT(!strcmp(poly->foo(), "B_foo"));
+ GPR_ASSERT(!strcmp(poly->bar(), "A_bar"));
+}
+
+static void complex_test() {
+ grpc_core::PolymorphicManualConstructor<A, B, C, D> polyB;
+ polyB.Init<B>();
+ GPR_ASSERT(!strcmp(polyB->foo(), "B_foo"));
+ GPR_ASSERT(!strcmp(polyB->bar(), "A_bar"));
+
+ grpc_core::PolymorphicManualConstructor<A, B, C, D> polyC;
+ polyC.Init<C>();
+ GPR_ASSERT(!strcmp(polyC->foo(), "B_foo"));
+ GPR_ASSERT(!strcmp(polyC->bar(), "C_bar"));
+
+ grpc_core::PolymorphicManualConstructor<A, B, C, D> polyD;
+ polyD.Init<D>();
+ GPR_ASSERT(!strcmp(polyD->foo(), "A_foo"));
+ GPR_ASSERT(!strcmp(polyD->bar(), "D_bar"));
+}
+
+/* ------------------------------------------------- */
+
+int main(int argc, char* argv[]) {
+ grpc_test_init(argc, argv);
+ basic_test();
+ complex_test();
+ return 0;
+}
diff --git a/test/core/support/memory_test.cc b/test/core/gprpp/memory_test.cc
index 79ab631a78..180c36fad7 100644
--- a/test/core/support/memory_test.cc
+++ b/test/core/gprpp/memory_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/memory.h"
+#include "src/core/lib/gprpp/memory.h"
#include <gtest/gtest.h>
#include "test/core/util/test_config.h"
diff --git a/test/core/gprpp/orphanable_test.cc b/test/core/gprpp/orphanable_test.cc
new file mode 100644
index 0000000000..ff2f6d8bc2
--- /dev/null
+++ b/test/core/gprpp/orphanable_test.cc
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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 "src/core/lib/gprpp/orphanable.h"
+
+#include <gtest/gtest.h>
+
+#include "src/core/lib/gprpp/memory.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+namespace {
+
+class Foo : public Orphanable {
+ public:
+ Foo() : Foo(0) {}
+ explicit Foo(int value) : value_(value) {}
+ void Orphan() override { Delete(this); }
+ int value() const { return value_; }
+
+ private:
+ int value_;
+};
+
+TEST(Orphanable, Basic) {
+ Foo* foo = New<Foo>();
+ foo->Orphan();
+}
+
+TEST(OrphanablePtr, Basic) {
+ OrphanablePtr<Foo> foo(New<Foo>());
+ EXPECT_EQ(0, foo->value());
+}
+
+TEST(MakeOrphanable, DefaultConstructor) {
+ auto foo = MakeOrphanable<Foo>();
+ EXPECT_EQ(0, foo->value());
+}
+
+TEST(MakeOrphanable, WithParameters) {
+ auto foo = MakeOrphanable<Foo>(5);
+ EXPECT_EQ(5, foo->value());
+}
+
+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(); }
+
+ private:
+ int value_;
+};
+
+TEST(OrphanablePtr, InternallyRefCounted) {
+ auto bar = MakeOrphanable<Bar>();
+ bar->StartWork();
+ bar->FinishWork();
+}
+
+// Note: We use DebugOnlyTraceFlag instead of TraceFlag to ensure that
+// things build properly in both debug and non-debug cases.
+DebugOnlyTraceFlag baz_tracer(true, "baz");
+
+class Baz : public InternallyRefCountedWithTracing {
+ public:
+ Baz() : Baz(0) {}
+ explicit Baz(int 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"); }
+
+ private:
+ int value_;
+};
+
+TEST(OrphanablePtr, InternallyRefCountedWithTracing) {
+ auto baz = MakeOrphanable<Baz>();
+ baz->StartWork();
+ baz->FinishWork();
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc
new file mode 100644
index 0000000000..f1f13f3183
--- /dev/null
+++ b/test/core/gprpp/ref_counted_ptr_test.cc
@@ -0,0 +1,185 @@
+/*
+ *
+ * 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 "src/core/lib/gprpp/ref_counted_ptr.h"
+
+#include <gtest/gtest.h>
+
+#include <grpc/support/log.h>
+
+#include "src/core/lib/gprpp/memory.h"
+#include "src/core/lib/gprpp/ref_counted.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+namespace {
+
+class Foo : public RefCounted {
+ public:
+ Foo() : value_(0) {}
+
+ explicit Foo(int value) : value_(value) {}
+
+ int value() const { return value_; }
+
+ private:
+ int value_;
+};
+
+TEST(RefCountedPtr, DefaultConstructor) { RefCountedPtr<Foo> foo; }
+
+TEST(RefCountedPtr, ExplicitConstructorEmpty) {
+ RefCountedPtr<Foo> foo(nullptr);
+}
+
+TEST(RefCountedPtr, ExplicitConstructor) { RefCountedPtr<Foo> foo(New<Foo>()); }
+
+TEST(RefCountedPtr, MoveConstructor) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ RefCountedPtr<Foo> foo2(std::move(foo));
+ EXPECT_EQ(nullptr, foo.get());
+ EXPECT_NE(nullptr, foo2.get());
+}
+
+TEST(RefCountedPtr, MoveAssignment) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ RefCountedPtr<Foo> foo2 = std::move(foo);
+ EXPECT_EQ(nullptr, foo.get());
+ EXPECT_NE(nullptr, foo2.get());
+}
+
+TEST(RefCountedPtr, CopyConstructor) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ RefCountedPtr<Foo> foo2(foo);
+ EXPECT_NE(nullptr, foo.get());
+ EXPECT_EQ(foo.get(), foo2.get());
+}
+
+TEST(RefCountedPtr, CopyAssignment) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ RefCountedPtr<Foo> foo2 = foo;
+ EXPECT_NE(nullptr, foo.get());
+ EXPECT_EQ(foo.get(), foo2.get());
+}
+
+TEST(RefCountedPtr, CopyAssignmentWhenEmpty) {
+ RefCountedPtr<Foo> foo;
+ RefCountedPtr<Foo> foo2;
+ foo2 = foo;
+ EXPECT_EQ(nullptr, foo.get());
+ EXPECT_EQ(nullptr, foo2.get());
+}
+
+TEST(RefCountedPtr, CopyAssignmentToSelf) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ foo = foo;
+}
+
+TEST(RefCountedPtr, EnclosedScope) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ {
+ RefCountedPtr<Foo> foo2(std::move(foo));
+ EXPECT_EQ(nullptr, foo.get());
+ EXPECT_NE(nullptr, foo2.get());
+ }
+ EXPECT_EQ(nullptr, foo.get());
+}
+
+TEST(RefCountedPtr, ResetFromNullToNonNull) {
+ RefCountedPtr<Foo> foo;
+ EXPECT_EQ(nullptr, foo.get());
+ foo.reset(New<Foo>());
+ EXPECT_NE(nullptr, foo.get());
+}
+
+TEST(RefCountedPtr, ResetFromNonNullToNonNull) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ EXPECT_NE(nullptr, foo.get());
+ Foo* original = foo.get();
+ foo.reset(New<Foo>());
+ EXPECT_NE(nullptr, foo.get());
+ EXPECT_NE(original, foo.get());
+}
+
+TEST(RefCountedPtr, ResetFromNonNullToNull) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ EXPECT_NE(nullptr, foo.get());
+ foo.reset();
+ EXPECT_EQ(nullptr, foo.get());
+}
+
+TEST(RefCountedPtr, ResetFromNullToNull) {
+ RefCountedPtr<Foo> foo;
+ EXPECT_EQ(nullptr, foo.get());
+ foo.reset(nullptr);
+ EXPECT_EQ(nullptr, foo.get());
+}
+
+TEST(RefCountedPtr, DerefernceOperators) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ foo->value();
+ Foo& foo_ref = *foo;
+ foo_ref.value();
+}
+
+TEST(RefCountedPtr, EqualityOperators) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ RefCountedPtr<Foo> bar = foo;
+ RefCountedPtr<Foo> empty;
+ // Test equality between RefCountedPtrs.
+ EXPECT_EQ(foo, bar);
+ EXPECT_NE(foo, empty);
+ // Test equality with bare pointers.
+ EXPECT_EQ(foo, foo.get());
+ EXPECT_EQ(empty, nullptr);
+ EXPECT_NE(foo, nullptr);
+}
+
+TEST(MakeRefCounted, NoArgs) {
+ RefCountedPtr<Foo> foo = MakeRefCounted<Foo>();
+ EXPECT_EQ(0, foo->value());
+}
+
+TEST(MakeRefCounted, Args) {
+ RefCountedPtr<Foo> foo = MakeRefCounted<Foo>(3);
+ EXPECT_EQ(3, foo->value());
+}
+
+TraceFlag foo_tracer(true, "foo");
+
+class FooWithTracing : public RefCountedWithTracing {
+ public:
+ FooWithTracing() : RefCountedWithTracing(&foo_tracer) {}
+};
+
+TEST(RefCountedPtr, RefCountedWithTracing) {
+ RefCountedPtr<FooWithTracing> foo(New<FooWithTracing>());
+ foo->Ref(DEBUG_LOCATION, "foo");
+ foo->Unref(DEBUG_LOCATION, "foo");
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/gprpp/ref_counted_test.cc b/test/core/gprpp/ref_counted_test.cc
new file mode 100644
index 0000000000..b1b0fee5c0
--- /dev/null
+++ b/test/core/gprpp/ref_counted_test.cc
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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 "src/core/lib/gprpp/ref_counted.h"
+
+#include <gtest/gtest.h>
+
+#include "src/core/lib/gprpp/memory.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+namespace {
+
+class Foo : public RefCounted {
+ public:
+ Foo() {}
+};
+
+TEST(RefCounted, Basic) {
+ Foo* foo = New<Foo>();
+ foo->Unref();
+}
+
+TEST(RefCounted, ExtraRef) {
+ Foo* foo = New<Foo>();
+ foo->Ref();
+ foo->Unref();
+ foo->Unref();
+}
+
+// Note: We use DebugOnlyTraceFlag instead of TraceFlag to ensure that
+// things build properly in both debug and non-debug cases.
+DebugOnlyTraceFlag foo_tracer(true, "foo");
+
+class FooWithTracing : public RefCountedWithTracing {
+ public:
+ FooWithTracing() : RefCountedWithTracing(&foo_tracer) {}
+};
+
+TEST(RefCountedWithTracing, Basic) {
+ FooWithTracing* foo = New<FooWithTracing>();
+ foo->Ref(DEBUG_LOCATION, "extra_ref");
+ foo->Unref(DEBUG_LOCATION, "extra_ref");
+ // Can use the no-argument methods, too.
+ foo->Ref();
+ foo->Unref();
+ foo->Unref(DEBUG_LOCATION, "original_ref");
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/handshake/BUILD b/test/core/handshake/BUILD
index 8e462cfc5b..a3276b9343 100644
--- a/test/core/handshake/BUILD
+++ b/test/core/handshake/BUILD
@@ -20,8 +20,8 @@ licenses(["notice"]) # Apache v2
grpc_cc_test(
name = "client_ssl",
- srcs = ["client_ssl.c"],
- language = "C",
+ srcs = ["client_ssl.cc"],
+ language = "C++",
data = [
"//src/core/tsi/test_creds:ca.pem",
"//src/core/tsi/test_creds:server1.key",
@@ -35,16 +35,47 @@ grpc_cc_test(
],
)
+grpc_cc_library(
+ name = "server_ssl_common",
+ hdrs = ["server_ssl_common.h"],
+ srcs = ["server_ssl_common.cc"],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
grpc_cc_test(
name = "server_ssl",
- srcs = ["server_ssl.c"],
- language = "C",
+ srcs = ["server_ssl.cc"],
+ language = "C++",
+ data = [
+ "//src/core/tsi/test_creds:ca.pem",
+ "//src/core/tsi/test_creds:server1.key",
+ "//src/core/tsi/test_creds:server1.pem",
+ ],
+ deps = [
+ ":server_ssl_common",
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "handshake_server_with_readahead_handshaker",
+ srcs = ["readahead_handshaker_server_ssl.cc"],
+ language = "C++",
data = [
"//src/core/tsi/test_creds:ca.pem",
"//src/core/tsi/test_creds:server1.key",
"//src/core/tsi/test_creds:server1.pem",
],
deps = [
+ ":server_ssl_common",
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.cc
index de660fe1c4..2302e3da2f 100644
--- a/test/core/handshake/client_ssl.c
+++ b/test/core/handshake/client_ssl.cc
@@ -46,13 +46,13 @@
// Arguments for TLS server thread.
typedef struct {
int socket;
- char *alpn_preferred;
+ char* alpn_preferred;
} server_args;
// Based on https://wiki.openssl.org/index.php/Simple_TLS_Server.
// Pick an arbitrary unused port and return it in *out_port. Return
// an fd>=0 on success.
-static int create_socket(int *out_port) {
+static int create_socket(int* out_port) {
int s;
struct sockaddr_in addr;
socklen_t addr_len;
@@ -68,7 +68,7 @@ static int create_socket(int *out_port) {
return -1;
}
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ if (bind(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
perror("Unable to bind");
gpr_log(GPR_ERROR, "%s", "Unable to bind to any port");
close(s);
@@ -82,7 +82,7 @@ static int create_socket(int *out_port) {
}
addr_len = sizeof(addr);
- if (getsockname(s, (struct sockaddr *)&addr, &addr_len) != 0 ||
+ if (getsockname(s, (struct sockaddr*)&addr, &addr_len) != 0 ||
addr_len > sizeof(addr)) {
perror("getsockname");
gpr_log(GPR_ERROR, "%s", "Unable to get socket local address");
@@ -96,19 +96,19 @@ static int create_socket(int *out_port) {
// Server callback during ALPN negotiation. See man page for
// SSL_CTX_set_alpn_select_cb.
-static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len,
- const uint8_t *in, unsigned in_len, void *arg) {
- const uint8_t *alpn_preferred = (const uint8_t *)arg;
+static int alpn_select_cb(SSL* ssl, const uint8_t** out, uint8_t* out_len,
+ const uint8_t* in, unsigned in_len, void* arg) {
+ const uint8_t* alpn_preferred = (const uint8_t*)arg;
*out = alpn_preferred;
- *out_len = (uint8_t)strlen((char *)alpn_preferred);
+ *out_len = (uint8_t)strlen((char*)alpn_preferred);
// Validate that the ALPN list includes "h2" and "grpc-exp", that "grpc-exp"
// precedes "h2".
bool grpc_exp_seen = false;
bool h2_seen = false;
- const char *inp = (const char *)in;
- const char *in_end = inp + in_len;
+ const char* inp = (const char*)in;
+ const char* in_end = inp + in_len;
while (inp < in_end) {
const size_t length = (size_t)*inp++;
if (length == strlen("grpc-exp") && strncmp(inp, "grpc-exp", length) == 0) {
@@ -132,14 +132,14 @@ static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len,
// Minimal TLS server. This is largely based on the example at
// https://wiki.openssl.org/index.php/Simple_TLS_Server and the gRPC core
// internals in src/core/tsi/ssl_transport_security.c.
-static void server_thread(void *arg) {
- const server_args *args = (server_args *)arg;
+static void server_thread(void* arg) {
+ const server_args* args = (server_args*)arg;
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
- const SSL_METHOD *method = TLSv1_2_server_method();
- SSL_CTX *ctx = SSL_CTX_new(method);
+ const SSL_METHOD* method = TLSv1_2_server_method();
+ SSL_CTX* ctx = SSL_CTX_new(method);
if (!ctx) {
perror("Unable to create SSL context");
ERR_print_errors_fp(stderr);
@@ -158,7 +158,7 @@ static void server_thread(void *arg) {
// Set the cipher list to match the one expressed in
// src/core/tsi/ssl_transport_security.c.
- const char *cipher_list =
+ const char* cipher_list =
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-"
"SHA384:ECDHE-RSA-AES256-GCM-SHA384";
if (!SSL_CTX_set_cipher_list(ctx, cipher_list)) {
@@ -175,14 +175,14 @@ static void server_thread(void *arg) {
gpr_log(GPR_INFO, "Server listening");
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
- const int client = accept(sock, (struct sockaddr *)&addr, &len);
+ const int client = accept(sock, (struct sockaddr*)&addr, &len);
if (client < 0) {
perror("Unable to accept");
abort();
}
// Establish a SSL* and accept at SSL layer.
- SSL *ssl = SSL_new(ctx);
+ SSL* ssl = SSL_new(ctx);
GPR_ASSERT(ssl);
SSL_set_fd(ssl, client);
if (SSL_accept(ssl) <= 0) {
@@ -208,7 +208,7 @@ static void server_thread(void *arg) {
// establishes a TLS handshake via the core library to the server. The TLS
// server validates ALPN aspects of the handshake and supplies the protocol
// specified in the server_alpn_preferred argument to the client.
-static bool client_ssl_test(char *server_alpn_preferred) {
+static bool client_ssl_test(char* server_alpn_preferred) {
bool success = true;
grpc_init();
@@ -230,9 +230,9 @@ static bool client_ssl_test(char *server_alpn_preferred) {
gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
gpr_thd_options_set_joinable(&thdopt);
- server_args args = {.socket = server_socket,
- .alpn_preferred = server_alpn_preferred};
- GPR_ASSERT(gpr_thd_new(&thdid, server_thread, &args, &thdopt));
+ server_args args = {server_socket, server_alpn_preferred};
+ GPR_ASSERT(gpr_thd_new(&thdid, "grpc_client_ssl_test", server_thread, &args,
+ &thdopt));
// Load key pair and establish client SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
@@ -243,24 +243,25 @@ static bool client_ssl_test(char *server_alpn_preferred) {
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
- const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
- pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, NULL);
+ const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, nullptr);
// Establish a channel pointing at the TLS server. Since the gRPC runtime is
// lazy, this won't necessarily establish a connection yet.
- char *target;
+ char* target;
gpr_asprintf(&target, "127.0.0.1:%d", port);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
grpc_channel_args grpc_args;
grpc_args.num_args = 1;
grpc_args.args = &ssl_name_override;
- grpc_channel *channel =
- grpc_secure_channel_create(ssl_creds, target, &grpc_args, NULL);
+ grpc_channel* channel =
+ grpc_secure_channel_create(ssl_creds, target, &grpc_args, nullptr);
GPR_ASSERT(channel);
gpr_free(target);
@@ -274,13 +275,13 @@ static bool client_ssl_test(char *server_alpn_preferred) {
// completed and we know that the client's ALPN list satisfied the server.
int retries = 10;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
while (state != GRPC_CHANNEL_READY && retries-- > 0) {
grpc_channel_watch_connectivity_state(
- channel, state, grpc_timeout_seconds_to_deadline(3), cq, NULL);
+ channel, state, grpc_timeout_seconds_to_deadline(3), cq, nullptr);
gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(5);
- grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, NULL);
+ grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
state =
grpc_channel_check_connectivity_state(channel, 0 /* try_to_connect */);
@@ -303,21 +304,21 @@ static bool client_ssl_test(char *server_alpn_preferred) {
return success;
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
// Handshake succeeeds when the server has grpc-exp as the ALPN preference.
- GPR_ASSERT(client_ssl_test("grpc-exp"));
+ GPR_ASSERT(client_ssl_test(const_cast<char*>("grpc-exp")));
// Handshake succeeeds when the server has h2 as the ALPN preference. This
// covers legacy gRPC servers which don't support grpc-exp.
- GPR_ASSERT(client_ssl_test("h2"));
+ GPR_ASSERT(client_ssl_test(const_cast<char*>("h2")));
// Handshake fails when the server uses a fake protocol as its ALPN
// preference. This validates the client is correctly validating ALPN returns
// and sanity checks the client_ssl_test.
- GPR_ASSERT(!client_ssl_test("foo"));
+ GPR_ASSERT(!client_ssl_test(const_cast<char*>("foo")));
return 0;
}
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/handshake/readahead_handshaker_server_ssl.cc b/test/core/handshake/readahead_handshaker_server_ssl.cc
new file mode 100644
index 0000000000..599e0e16e2
--- /dev/null
+++ b/test/core/handshake/readahead_handshaker_server_ssl.cc
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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 <arpa/inet.h>
+#include <openssl/err.h>
+#include <openssl/ssl.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include "src/core/lib/iomgr/load_file.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#include "src/core/lib/channel/handshaker_factory.h"
+#include "src/core/lib/channel/handshaker_registry.h"
+#include "src/core/lib/security/transport/security_handshaker.h"
+
+#include "test/core/handshake/server_ssl_common.h"
+
+/* The purpose of this test is to exercise the case when a
+ * grpc *security_handshaker* begins its handshake with data already
+ * in the read buffer of the handshaker arg. This scenario is created by
+ * adding a fake "readahead" handshaker at the beginning of the server's
+ * handshaker list, which just reads from the connection and then places
+ * read bytes into the read buffer of the handshake arg (to be passed down
+ * to the security_handshaker). This test is meant to protect code relying on
+ * this functionality that lives outside of this repo. */
+
+static void readahead_handshaker_destroy(grpc_handshaker* handshaker) {
+ gpr_free(handshaker);
+}
+
+static void readahead_handshaker_shutdown(grpc_handshaker* handshaker,
+ grpc_error* error) {}
+
+static void readahead_handshaker_do_handshake(
+ grpc_handshaker* handshaker, grpc_tcp_server_acceptor* acceptor,
+ grpc_closure* on_handshake_done, grpc_handshaker_args* args) {
+ grpc_endpoint_read(args->endpoint, args->read_buffer, on_handshake_done);
+}
+
+const grpc_handshaker_vtable readahead_handshaker_vtable = {
+ readahead_handshaker_destroy, readahead_handshaker_shutdown,
+ readahead_handshaker_do_handshake};
+
+static grpc_handshaker* readahead_handshaker_create() {
+ grpc_handshaker* h = (grpc_handshaker*)gpr_zalloc(sizeof(grpc_handshaker));
+ grpc_handshaker_init(&readahead_handshaker_vtable, h);
+ return h;
+}
+
+static void readahead_handshaker_factory_add_handshakers(
+ grpc_handshaker_factory* hf, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_handshake_manager_add(handshake_mgr, readahead_handshaker_create());
+}
+
+static void readahead_handshaker_factory_destroy(
+ grpc_handshaker_factory* handshaker_factory) {}
+
+static const grpc_handshaker_factory_vtable
+ readahead_handshaker_factory_vtable = {
+ readahead_handshaker_factory_add_handshakers,
+ readahead_handshaker_factory_destroy};
+
+int main(int argc, char* argv[]) {
+ grpc_handshaker_factory readahead_handshaker_factory = {
+ &readahead_handshaker_factory_vtable};
+ grpc_init();
+ grpc_handshaker_factory_register(true /* at_start */, HANDSHAKER_SERVER,
+ &readahead_handshaker_factory);
+ const char* full_alpn_list[] = {"grpc-exp", "h2"};
+ GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/handshake/server_ssl.cc b/test/core/handshake/server_ssl.cc
new file mode 100644
index 0000000000..736d3e578e
--- /dev/null
+++ b/test/core/handshake/server_ssl.cc
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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 <arpa/inet.h>
+#include <openssl/err.h>
+#include <openssl/ssl.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include "src/core/lib/iomgr/load_file.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#include "test/core/handshake/server_ssl_common.h"
+
+int main(int argc, char* argv[]) {
+ // Handshake succeeeds when the client supplies the standard ALPN list.
+ const char* full_alpn_list[] = {"grpc-exp", "h2"};
+ GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
+ // Handshake succeeeds when the client supplies only h2 as the ALPN list. This
+ // covers legacy gRPC clients which don't support grpc-exp.
+ const char* h2_only_alpn_list[] = {"h2"};
+ GPR_ASSERT(server_ssl_test(h2_only_alpn_list, 1, "h2"));
+ // Handshake succeeds when the client supplies superfluous ALPN entries and
+ // also when h2 precedes gprc-exp.
+ const char* extra_alpn_list[] = {"foo", "h2", "bar", "grpc-exp"};
+ GPR_ASSERT(server_ssl_test(extra_alpn_list, 4, "h2"));
+ // Handshake fails when the client uses a fake protocol as its only ALPN
+ // preference. This validates the server is correctly validating ALPN
+ // and sanity checks the server_ssl_test.
+ const char* fake_alpn_list[] = {"foo"};
+ GPR_ASSERT(!server_ssl_test(fake_alpn_list, 1, "foo"));
+ return 0;
+}
diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl_common.cc
index 85a8b4de41..0bf453a204 100644
--- a/test/core/handshake/server_ssl.c
+++ b/test/core/handshake/server_ssl_common.cc
@@ -16,6 +16,8 @@
*
*/
+#include "test/core/handshake/server_ssl_common.h"
+
#include <arpa/inet.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
@@ -55,7 +57,7 @@ static int create_socket(int port) {
return -1;
}
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
perror("Unable to connect");
return -1;
}
@@ -64,8 +66,8 @@ static int create_socket(int port) {
}
// Simple gRPC server. This listens until client_handshake_complete occurs.
-static void server_thread(void *arg) {
- const int port = *(int *)arg;
+static void server_thread(void* arg) {
+ const int port = *(int*)arg;
// Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
@@ -76,22 +78,22 @@ static void server_thread(void *arg) {
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
- const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
- pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
- grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
- ca_cert, &pem_key_cert_pair, 1, 0, NULL);
+ const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ ca_cert, &pem_key_cert_pair, 1, 0, nullptr);
// Start server listening on local port.
- char *addr;
+ char* addr;
gpr_asprintf(&addr, "127.0.0.1:%d", port);
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
free(addr);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
- grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_server_register_completion_queue(server, cq, nullptr);
grpc_server_start(server);
// Wait a bounded number of time until client_handshake_complete is set,
@@ -99,16 +101,16 @@ static void server_thread(void *arg) {
int retries = 10;
while (!gpr_event_get(&client_handshake_complete) && retries-- > 0) {
const gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(1);
- grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, NULL);
+ grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
}
gpr_log(GPR_INFO, "Shutting down server");
- grpc_server_shutdown_and_notify(server, cq, NULL);
+ grpc_server_shutdown_and_notify(server, cq, nullptr);
grpc_completion_queue_shutdown(cq);
const gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(5);
- grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, NULL);
+ grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
grpc_server_destroy(server);
@@ -123,8 +125,8 @@ static void server_thread(void *arg) {
// TLS handshake via a minimal TLS client. The TLS client has configurable (via
// alpn_list) ALPN settings and can probe at the supported ALPN preferences
// using this (via alpn_expected).
-static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
- const char *alpn_expected) {
+bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len,
+ const char* alpn_expected) {
bool success = true;
grpc_init();
@@ -135,13 +137,14 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
gpr_thd_options_set_joinable(&thdopt);
- GPR_ASSERT(gpr_thd_new(&thdid, server_thread, &port, &thdopt));
+ GPR_ASSERT(
+ gpr_thd_new(&thdid, "grpc_ssl_test", server_thread, &port, &thdopt));
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
- const SSL_METHOD *method = TLSv1_2_client_method();
- SSL_CTX *ctx = SSL_CTX_new(method);
+ const SSL_METHOD* method = TLSv1_2_client_method();
+ SSL_CTX* ctx = SSL_CTX_new(method);
if (!ctx) {
perror("Unable to create SSL context");
ERR_print_errors_fp(stderr);
@@ -160,7 +163,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
// Set the cipher list to match the one expressed in
// src/core/tsi/ssl_transport_security.c.
- const char *cipher_list =
+ const char* cipher_list =
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-"
"SHA384:ECDHE-RSA-AES256-GCM-SHA384";
if (!SSL_CTX_set_cipher_list(ctx, cipher_list)) {
@@ -175,8 +178,9 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
for (unsigned int i = 0; i < alpn_list_len; ++i) {
alpn_protos_len += (unsigned int)strlen(alpn_list[i]);
}
- unsigned char *alpn_protos = gpr_malloc(alpn_protos_len);
- unsigned char *p = alpn_protos;
+ unsigned char* alpn_protos =
+ static_cast<unsigned char*>(gpr_malloc(alpn_protos_len));
+ unsigned char* p = alpn_protos;
for (unsigned int i = 0; i < alpn_list_len; ++i) {
const uint8_t len = (uint8_t)strlen(alpn_list[i]);
*p++ = len;
@@ -199,7 +203,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
gpr_log(GPR_INFO, "Connected to server on port %d", port);
// Establish a SSL* and connect at SSL layer.
- SSL *ssl = SSL_new(ctx);
+ SSL* ssl = SSL_new(ctx);
GPR_ASSERT(ssl);
SSL_set_fd(ssl, sock);
if (SSL_connect(ssl) <= 0) {
@@ -209,12 +213,12 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
} else {
gpr_log(GPR_INFO, "Handshake successful.");
// Validate ALPN preferred by server matches alpn_expected.
- const unsigned char *alpn_selected;
+ const unsigned char* alpn_selected;
unsigned int alpn_selected_len;
SSL_get0_alpn_selected(ssl, &alpn_selected, &alpn_selected_len);
if (strlen(alpn_expected) != alpn_selected_len ||
- strncmp((const char *)alpn_selected, alpn_expected,
- alpn_selected_len) != 0) {
+ strncmp((const char*)alpn_selected, alpn_expected, alpn_selected_len) !=
+ 0) {
gpr_log(GPR_ERROR, "Unexpected ALPN protocol preference");
success = false;
}
@@ -233,23 +237,3 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
return success;
}
-
-int main(int argc, char *argv[]) {
- // Handshake succeeeds when the client supplies the standard ALPN list.
- const char *full_alpn_list[] = {"grpc-exp", "h2"};
- GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
- // Handshake succeeeds when the client supplies only h2 as the ALPN list. This
- // covers legacy gRPC clients which don't support grpc-exp.
- const char *h2_only_alpn_list[] = {"h2"};
- GPR_ASSERT(server_ssl_test(h2_only_alpn_list, 1, "h2"));
- // Handshake succeeds when the client supplies superfluous ALPN entries and
- // also when h2 precedes gprc-exp.
- const char *extra_alpn_list[] = {"foo", "h2", "bar", "grpc-exp"};
- GPR_ASSERT(server_ssl_test(extra_alpn_list, 4, "h2"));
- // Handshake fails when the client uses a fake protocol as its only ALPN
- // preference. This validates the server is correctly validating ALPN
- // and sanity checks the server_ssl_test.
- const char *fake_alpn_list[] = {"foo"};
- GPR_ASSERT(!server_ssl_test(fake_alpn_list, 1, "foo"));
- return 0;
-}
diff --git a/test/core/handshake/server_ssl_common.h b/test/core/handshake/server_ssl_common.h
new file mode 100644
index 0000000000..77865a408f
--- /dev/null
+++ b/test/core/handshake/server_ssl_common.h
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef GRPC_SERVER_SSL_COMMON_H
+#define GRPC_SERVER_SSL_COMMON_H
+
+#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include "src/core/lib/iomgr/load_file.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len,
+ const char* alpn_expected);
+
+#endif // GRPC_SERVER_SSL_COMMON_H
diff --git a/test/core/http/BUILD b/test/core/http/BUILD
index fffdac5e08..03b8f4edfe 100644
--- a/test/core/http/BUILD
+++ b/test/core/http/BUILD
@@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "response_fuzzer",
- srcs = ["response_fuzzer.c"],
- language = "C",
+ srcs = ["response_fuzzer.cc"],
+ language = "C++",
corpus = "response_corpus",
deps = [
"//:gpr",
@@ -34,8 +34,8 @@ grpc_fuzzer(
grpc_fuzzer(
name = "request_fuzzer",
- srcs = ["request_fuzzer.c"],
- language = "C",
+ srcs = ["request_fuzzer.cc"],
+ language = "C++",
corpus = "request_corpus",
deps = [
"//:gpr",
@@ -64,9 +64,14 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_cc_test(
name = "httpcli_test",
- srcs = ["httpcli_test.c"],
- language = "C",
- data = ["test_server.py"],
+ srcs = ["httpcli_test.cc"],
+ language = "C++",
+ data = [
+ "python_wrapper.sh",
+ "test_server.py",
+ "//src/core/tsi/test_creds:server1.pem",
+ "//src/core/tsi/test_creds:server1.key"
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -78,9 +83,15 @@ grpc_cc_test(
grpc_cc_test(
name = "httpscli_test",
- srcs = ["httpscli_test.c"],
- language = "C",
- data = ["test_server.py"],
+ srcs = ["httpscli_test.cc"],
+ language = "C++",
+ data = [
+ "python_wrapper.sh",
+ "test_server.py",
+ "//src/core/tsi/test_creds:ca.pem",
+ "//src/core/tsi/test_creds:server1.pem",
+ "//src/core/tsi/test_creds:server1.key"
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -92,8 +103,8 @@ grpc_cc_test(
grpc_cc_test(
name = "parser_test",
- srcs = ["parser_test.c"],
- language = "C",
+ srcs = ["parser_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/http/format_request_test.c b/test/core/http/format_request_test.cc
index 0279a1b5e3..353e138b2a 100644
--- a/test/core/http/format_request_test.c
+++ b/test/core/http/format_request_test.cc
@@ -24,13 +24,13 @@
#include "test/core/util/test_config.h"
static void test_format_get_request(void) {
- grpc_http_header hdr = {"x-yz", "abc"};
+ grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")};
grpc_httpcli_request req;
grpc_slice slice;
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char*>("example.com");
+ req.http.path = const_cast<char*>("/index.html");
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
@@ -49,15 +49,15 @@ static void test_format_get_request(void) {
}
static void test_format_post_request(void) {
- grpc_http_header hdr = {"x-yz", "abc"};
+ grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")};
grpc_httpcli_request req;
grpc_slice slice;
char body_bytes[] = "fake body";
size_t body_len = 9;
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char*>("example.com");
+ req.http.path = const_cast<char*>("/index.html");
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
@@ -79,17 +79,17 @@ static void test_format_post_request(void) {
}
static void test_format_post_request_no_body(void) {
- grpc_http_header hdr = {"x-yz", "abc"};
+ grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")};
grpc_httpcli_request req;
grpc_slice slice;
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char*>("example.com");
+ req.http.path = const_cast<char*>("/index.html");
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
- slice = grpc_httpcli_format_post_request(&req, NULL, 0);
+ slice = grpc_httpcli_format_post_request(&req, nullptr, 0);
GPR_ASSERT(0 == grpc_slice_str_cmp(slice,
"POST /index.html HTTP/1.0\r\n"
@@ -110,13 +110,13 @@ static void test_format_post_request_content_type_override(void) {
char body_bytes[] = "fake%20body";
size_t body_len = 11;
- hdrs[0].key = "x-yz";
- hdrs[0].value = "abc";
- hdrs[1].key = "Content-Type";
- hdrs[1].value = "application/x-www-form-urlencoded";
+ hdrs[0].key = const_cast<char*>("x-yz");
+ hdrs[0].value = const_cast<char*>("abc");
+ hdrs[1].key = const_cast<char*>("Content-Type");
+ hdrs[1].value = const_cast<char*>("application/x-www-form-urlencoded");
memset(&req, 0, sizeof(req));
- req.host = "example.com";
- req.http.path = "/index.html";
+ req.host = const_cast<char*>("example.com");
+ req.http.path = const_cast<char*>("/index.html");
req.http.hdr_count = 2;
req.http.hdrs = hdrs;
@@ -137,13 +137,15 @@ static void test_format_post_request_content_type_override(void) {
grpc_slice_unref(slice);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_format_get_request();
test_format_post_request();
test_format_post_request_no_body();
test_format_post_request_content_type_override();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
deleted file mode 100644
index 8a53903763..0000000000
--- a/test/core/http/httpcli_test.c
+++ /dev/null
@@ -1,210 +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/http/httpcli.h"
-
-#include <string.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/subprocess.h>
-#include <grpc/support/sync.h>
-#include "src/core/lib/iomgr/iomgr.h"
-#include "test/core/util/port.h"
-#include "test/core/util/test_config.h"
-
-static int g_done = 0;
-static grpc_httpcli_context g_context;
-static gpr_mu *g_mu;
-static grpc_polling_entity g_pops;
-
-static gpr_timespec n_seconds_time(int seconds) {
- return grpc_timeout_seconds_to_deadline(seconds);
-}
-
-static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- const char *expect =
- "<html><head><title>Hello world!</title></head>"
- "<body><p>This is a test</p></body></html>";
- grpc_http_response *response = arg;
- GPR_ASSERT(response);
- GPR_ASSERT(response->status == 200);
- GPR_ASSERT(response->body_length == strlen(expect));
- GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
- gpr_mu_lock(g_mu);
- g_done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&g_pops), NULL)));
- gpr_mu_unlock(g_mu);
-}
-
-static void test_get(int port) {
- grpc_httpcli_request req;
- char *host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- g_done = 0;
- gpr_log(GPR_INFO, "test_get");
-
- gpr_asprintf(&host, "localhost:%d", port);
- gpr_log(GPR_INFO, "requesting from %s", host);
-
- memset(&req, 0, sizeof(req));
- req.host = host;
- req.http.path = "/get";
- req.handshaker = &grpc_httpcli_plaintext;
-
- grpc_http_response response;
- memset(&response, 0, sizeof(response));
- grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
- grpc_httpcli_get(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
- GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
- &response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- gpr_mu_lock(g_mu);
- while (!g_done) {
- grpc_pollset_worker *worker = NULL;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(1))));
- gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
- gpr_mu_lock(g_mu);
- }
- gpr_mu_unlock(g_mu);
- gpr_free(host);
- grpc_http_response_destroy(&response);
-}
-
-static void test_post(int port) {
- grpc_httpcli_request req;
- char *host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- g_done = 0;
- gpr_log(GPR_INFO, "test_post");
-
- gpr_asprintf(&host, "localhost:%d", port);
- gpr_log(GPR_INFO, "posting to %s", host);
-
- memset(&req, 0, sizeof(req));
- req.host = host;
- req.http.path = "/post";
- req.handshaker = &grpc_httpcli_plaintext;
-
- grpc_http_response response;
- memset(&response, 0, sizeof(response));
- grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
- grpc_httpcli_post(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
- n_seconds_time(15),
- GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
- &response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- gpr_mu_lock(g_mu);
- while (!g_done) {
- grpc_pollset_worker *worker = NULL;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(1))));
- gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
- gpr_mu_lock(g_mu);
- }
- gpr_mu_unlock(g_mu);
- gpr_free(host);
- grpc_http_response_destroy(&response);
-}
-
-static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(p));
-}
-
-int main(int argc, char **argv) {
- grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_subprocess *server;
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
- char *args[4];
- int port = grpc_pick_unused_port_or_die();
- int arg_shift = 0;
- /* figure out where we are */
- char *root;
- if (lslash) {
- root = gpr_malloc((size_t)(lslash - me + 1));
- memcpy(root, me, (size_t)(lslash - me));
- root[lslash - me] = 0;
- } else {
- root = gpr_strdup(".");
- }
-
- GPR_ASSERT(argc <= 2);
- if (argc == 2) {
- args[0] = gpr_strdup(argv[1]);
- } else {
- arg_shift = 1;
- gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
- gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root);
- }
-
- /* start the server */
- args[1 + arg_shift] = "--port";
- gpr_asprintf(&args[2 + arg_shift], "%d", port);
- server = gpr_subprocess_create(3 + arg_shift, (const char **)args);
- GPR_ASSERT(server);
- gpr_free(args[0]);
- if (arg_shift) gpr_free(args[1]);
- gpr_free(args[2 + arg_shift]);
- gpr_free(root);
-
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(5, GPR_TIMESPAN)));
-
- grpc_test_init(argc, argv);
- grpc_init();
- grpc_httpcli_context_init(&g_context);
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(pollset, &g_mu);
- g_pops = grpc_polling_entity_create_from_pollset(pollset);
-
- test_get(port);
- test_post(port);
-
- grpc_httpcli_context_destroy(&exec_ctx, &g_context);
- GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_shutdown();
-
- gpr_free(grpc_polling_entity_pollset(&g_pops));
-
- gpr_subprocess_destroy(server);
-
- return 0;
-}
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
new file mode 100644
index 0000000000..6ad0753f7e
--- /dev/null
+++ b/test/core/http/httpcli_test.cc
@@ -0,0 +1,215 @@
+/*
+ *
+ * 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/http/httpcli.h"
+
+#include <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/subprocess.h>
+#include <grpc/support/sync.h>
+#include "src/core/lib/iomgr/iomgr.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+static int g_done = 0;
+static grpc_httpcli_context g_context;
+static gpr_mu* g_mu;
+static grpc_polling_entity g_pops;
+
+static grpc_millis n_seconds_time(int seconds) {
+ return grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(seconds));
+}
+
+static void on_finish(void* arg, grpc_error* error) {
+ const char* expect =
+ "<html><head><title>Hello world!</title></head>"
+ "<body><p>This is a test</p></body></html>";
+ grpc_http_response* response = static_cast<grpc_http_response*>(arg);
+ GPR_ASSERT(response);
+ GPR_ASSERT(response->status == 200);
+ GPR_ASSERT(response->body_length == strlen(expect));
+ GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
+ gpr_mu_lock(g_mu);
+ g_done = 1;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "pollset_kick",
+ grpc_pollset_kick(grpc_polling_entity_pollset(&g_pops), nullptr)));
+ gpr_mu_unlock(g_mu);
+}
+
+static void test_get(int port) {
+ grpc_httpcli_request req;
+ char* host;
+ grpc_core::ExecCtx exec_ctx;
+
+ g_done = 0;
+ gpr_log(GPR_INFO, "test_get");
+
+ gpr_asprintf(&host, "localhost:%d", port);
+ gpr_log(GPR_INFO, "requesting from %s", host);
+
+ memset(&req, 0, sizeof(req));
+ req.host = host;
+ req.http.path = const_cast<char*>("/get");
+ req.handshaker = &grpc_httpcli_plaintext;
+
+ grpc_http_response response;
+ memset(&response, 0, sizeof(response));
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get");
+ grpc_httpcli_get(
+ &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
+ &response);
+ grpc_resource_quota_unref_internal(resource_quota);
+ gpr_mu_lock(g_mu);
+ while (!g_done) {
+ grpc_pollset_worker* worker = nullptr;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
+ gpr_mu_unlock(g_mu);
+
+ gpr_mu_lock(g_mu);
+ }
+ gpr_mu_unlock(g_mu);
+ gpr_free(host);
+ grpc_http_response_destroy(&response);
+}
+
+static void test_post(int port) {
+ grpc_httpcli_request req;
+ char* host;
+ grpc_core::ExecCtx exec_ctx;
+
+ g_done = 0;
+ gpr_log(GPR_INFO, "test_post");
+
+ gpr_asprintf(&host, "localhost:%d", port);
+ gpr_log(GPR_INFO, "posting to %s", host);
+
+ memset(&req, 0, sizeof(req));
+ req.host = host;
+ req.http.path = const_cast<char*>("/post");
+ req.handshaker = &grpc_httpcli_plaintext;
+
+ grpc_http_response response;
+ memset(&response, 0, sizeof(response));
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post");
+ grpc_httpcli_post(
+ &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15),
+ GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
+ &response);
+ grpc_resource_quota_unref_internal(resource_quota);
+ gpr_mu_lock(g_mu);
+ while (!g_done) {
+ grpc_pollset_worker* worker = nullptr;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
+ gpr_mu_unlock(g_mu);
+
+ gpr_mu_lock(g_mu);
+ }
+ gpr_mu_unlock(g_mu);
+ gpr_free(host);
+ grpc_http_response_destroy(&response);
+}
+
+static void destroy_pops(void* p, grpc_error* error) {
+ grpc_pollset_destroy(
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p)));
+}
+
+int main(int argc, char** argv) {
+ gpr_subprocess* server;
+ grpc_test_init(argc, argv);
+ grpc_init();
+ {
+ grpc_closure destroyed;
+ grpc_core::ExecCtx exec_ctx;
+ char* me = argv[0];
+ char* lslash = strrchr(me, '/');
+ char* args[4];
+ int port = grpc_pick_unused_port_or_die();
+ int arg_shift = 0;
+ /* figure out where we are */
+ char* root;
+ if (lslash != nullptr) {
+ /* Hack for bazel target */
+ if ((unsigned)(lslash - me) >= (sizeof("http") - 1) &&
+ strncmp(me + (lslash - me) - sizeof("http") + 1, "http",
+ sizeof("http") - 1) == 0) {
+ lslash = me + (lslash - me) - sizeof("http");
+ }
+ root = static_cast<char*>(
+ gpr_malloc((size_t)(lslash - me + sizeof("/../.."))));
+ memcpy(root, me, (size_t)(lslash - me));
+ memcpy(root + (lslash - me), "/../..", sizeof("/../.."));
+ } else {
+ root = gpr_strdup(".");
+ }
+
+ GPR_ASSERT(argc <= 2);
+ if (argc == 2) {
+ args[0] = gpr_strdup(argv[1]);
+ } else {
+ arg_shift = 1;
+ gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root);
+ gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root);
+ }
+
+ /* start the server */
+ args[1 + arg_shift] = const_cast<char*>("--port");
+ gpr_asprintf(&args[2 + arg_shift], "%d", port);
+ server = gpr_subprocess_create(3 + arg_shift, (const char**)args);
+ GPR_ASSERT(server);
+ gpr_free(args[0]);
+ if (arg_shift) gpr_free(args[1]);
+ gpr_free(args[2 + arg_shift]);
+ gpr_free(root);
+
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(5, GPR_TIMESPAN)));
+
+ grpc_httpcli_context_init(&g_context);
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(pollset, &g_mu);
+ g_pops = grpc_polling_entity_create_from_pollset(pollset);
+
+ test_get(port);
+ test_post(port);
+
+ grpc_httpcli_context_destroy(&g_context);
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
+ }
+ grpc_shutdown();
+
+ gpr_free(grpc_polling_entity_pollset(&g_pops));
+
+ gpr_subprocess_destroy(server);
+
+ return 0;
+}
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.cc
index c7455bd8df..92193bb442 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.cc
@@ -21,29 +21,32 @@
#include <string.h>
#include <grpc/grpc.h>
+#include <grpc/grpc_security_constants.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
#include <grpc/support/sync.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
static int g_done = 0;
static grpc_httpcli_context g_context;
-static gpr_mu *g_mu;
+static gpr_mu* g_mu;
static grpc_polling_entity g_pops;
-static gpr_timespec n_seconds_time(int seconds) {
- return grpc_timeout_seconds_to_deadline(seconds);
+static grpc_millis n_seconds_time(int seconds) {
+ return grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(seconds));
}
-static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- const char *expect =
+static void on_finish(void* arg, grpc_error* error) {
+ const char* expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
- grpc_http_response *response = arg;
+ grpc_http_response* response = static_cast<grpc_http_response*>(arg);
GPR_ASSERT(response);
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
@@ -52,14 +55,14 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
g_done = 1;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&g_pops), NULL)));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&g_pops), nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_get(int port) {
grpc_httpcli_request req;
- char *host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ char* host;
+ grpc_core::ExecCtx exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_get");
@@ -69,28 +72,26 @@ static void test_get(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
- req.ssl_host_override = "foo.test.google.fr";
- req.http.path = "/get";
+ req.ssl_host_override = const_cast<char*>("foo.test.google.fr");
+ req.http.path = const_cast<char*>("/get");
req.handshaker = &grpc_httpcli_ssl;
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get");
grpc_httpcli_get(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(1))));
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -100,8 +101,8 @@ static void test_get(int port) {
static void test_post(int port) {
grpc_httpcli_request req;
- char *host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ char* host;
+ grpc_core::ExecCtx exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_post");
@@ -111,29 +112,26 @@ static void test_post(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
- req.ssl_host_override = "foo.test.google.fr";
- req.http.path = "/post";
+ req.ssl_host_override = const_cast<char*>("foo.test.google.fr");
+ req.http.path = const_cast<char*>("/post");
req.handshaker = &grpc_httpcli_ssl;
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
+ grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post");
grpc_httpcli_post(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
- n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(1))));
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -141,25 +139,32 @@ static void test_post(int port) {
grpc_http_response_destroy(&response);
}
-static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(p));
+static void destroy_pops(void* p, grpc_error* error) {
+ grpc_pollset_destroy(
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p)));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_subprocess *server;
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
- char *args[5];
+ gpr_subprocess* server;
+ char* me = argv[0];
+ char* lslash = strrchr(me, '/');
+ char* args[5];
int port = grpc_pick_unused_port_or_die();
int arg_shift = 0;
/* figure out where we are */
- char *root;
- if (lslash) {
- root = gpr_malloc((size_t)(lslash - me + 1));
+ char* root;
+ if (lslash != nullptr) {
+ /* Hack for bazel target */
+ if ((unsigned)(lslash - me) >= (sizeof("http") - 1) &&
+ strncmp(me + (lslash - me) - sizeof("http") + 1, "http",
+ sizeof("http") - 1) == 0) {
+ lslash = me + (lslash - me) - sizeof("http");
+ }
+ root = static_cast<char*>(
+ gpr_malloc((size_t)(lslash - me + sizeof("/../.."))));
memcpy(root, me, (size_t)(lslash - me));
- root[lslash - me] = 0;
+ memcpy(root + (lslash - me), "/../..", sizeof("/../.."));
} else {
root = gpr_strdup(".");
}
@@ -169,15 +174,21 @@ int main(int argc, char **argv) {
args[0] = gpr_strdup(argv[1]);
} else {
arg_shift = 1;
- gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
- gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root);
+ gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root);
+ gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root);
}
+ /* Set the environment variable for the SSL certificate file */
+ char* pem_file;
+ gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root);
+ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file);
+ gpr_free(pem_file);
+
/* start the server */
- args[1 + arg_shift] = "--port";
+ args[1 + arg_shift] = const_cast<char*>("--port");
gpr_asprintf(&args[2 + arg_shift], "%d", port);
- args[3 + arg_shift] = "--ssl";
- server = gpr_subprocess_create(4 + arg_shift, (const char **)args);
+ args[3 + arg_shift] = const_cast<char*>("--ssl");
+ server = gpr_subprocess_create(4 + arg_shift, (const char**)args);
GPR_ASSERT(server);
gpr_free(args[0]);
if (arg_shift) gpr_free(args[1]);
@@ -190,19 +201,21 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
grpc_httpcli_context_init(&g_context);
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &g_mu);
g_pops = grpc_polling_entity_create_from_pollset(pollset);
test_get(port);
test_post(port);
- grpc_httpcli_context_destroy(&exec_ctx, &g_context);
- GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_httpcli_context_destroy(&g_context);
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
+ }
grpc_shutdown();
gpr_free(grpc_polling_entity_pollset(&g_pops));
diff --git a/test/core/http/parser_test.c b/test/core/http/parser_test.cc
index a7044c03bc..18f19856bd 100644
--- a/test/core/http/parser_test.c
+++ b/test/core/http/parser_test.cc
@@ -21,6 +21,7 @@
#include <stdarg.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -29,14 +30,16 @@
#include "test/core/util/test_config.h"
static void test_request_succeeds(grpc_slice_split_mode split_mode,
- char *request_text, char *expect_method,
+ const char* request_text,
+ const char* expect_method,
grpc_http_version expect_version,
- char *expect_path, char *expect_body, ...) {
+ const char* expect_path,
+ const char* expect_body, ...) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(request_text);
size_t num_slices;
size_t i;
- grpc_slice *slices;
+ grpc_slice* slices;
va_list args;
grpc_http_request request;
memset(&request, 0, sizeof(request));
@@ -47,7 +50,7 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
for (i = 0; i < num_slices; i++) {
- GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) ==
+ GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], nullptr) ==
GRPC_ERROR_NONE);
grpc_slice_unref(slices[i]);
}
@@ -58,7 +61,7 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
GPR_ASSERT(0 == strcmp(expect_path, request.path));
GPR_ASSERT(expect_version == request.version);
- if (expect_body != NULL) {
+ if (expect_body != nullptr) {
GPR_ASSERT(strlen(expect_body) == request.body_length);
GPR_ASSERT(0 == memcmp(expect_body, request.body, request.body_length));
} else {
@@ -68,12 +71,12 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
va_start(args, expect_body);
i = 0;
for (;;) {
- char *expect_key;
- char *expect_value;
- expect_key = va_arg(args, char *);
+ char* expect_key;
+ char* expect_value;
+ expect_key = va_arg(args, char*);
if (!expect_key) break;
GPR_ASSERT(i < request.hdr_count);
- expect_value = va_arg(args, char *);
+ expect_value = va_arg(args, char*);
GPR_ASSERT(expect_value);
GPR_ASSERT(0 == strcmp(expect_key, request.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, request.hdrs[i].value));
@@ -87,13 +90,14 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
gpr_free(slices);
}
-static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
- int expect_status, char *expect_body, ...) {
+static void test_succeeds(grpc_slice_split_mode split_mode,
+ const char* response_text, int expect_status,
+ const char* expect_body, ...) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(response_text);
size_t num_slices;
size_t i;
- grpc_slice *slices;
+ grpc_slice* slices;
va_list args;
grpc_http_response response;
memset(&response, 0, sizeof(response));
@@ -104,7 +108,7 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
for (i = 0; i < num_slices; i++) {
- GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) ==
+ GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], nullptr) ==
GRPC_ERROR_NONE);
grpc_slice_unref(slices[i]);
}
@@ -112,7 +116,7 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
GPR_ASSERT(GRPC_HTTP_RESPONSE == parser.type);
GPR_ASSERT(expect_status == response.status);
- if (expect_body != NULL) {
+ if (expect_body != nullptr) {
GPR_ASSERT(strlen(expect_body) == response.body_length);
GPR_ASSERT(0 == memcmp(expect_body, response.body, response.body_length));
} else {
@@ -122,12 +126,12 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
va_start(args, expect_body);
i = 0;
for (;;) {
- char *expect_key;
- char *expect_value;
- expect_key = va_arg(args, char *);
+ char* expect_key;
+ char* expect_value;
+ expect_key = va_arg(args, char*);
if (!expect_key) break;
GPR_ASSERT(i < response.hdr_count);
- expect_value = va_arg(args, char *);
+ expect_value = va_arg(args, char*);
GPR_ASSERT(expect_value);
GPR_ASSERT(0 == strcmp(expect_key, response.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, response.hdrs[i].value));
@@ -141,13 +145,14 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
gpr_free(slices);
}
-static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
+static void test_fails(grpc_slice_split_mode split_mode,
+ const char* response_text) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(response_text);
size_t num_slices;
size_t i;
- grpc_slice *slices;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_slice* slices;
+ grpc_error* error = GRPC_ERROR_NONE;
grpc_http_response response;
memset(&response, 0, sizeof(response));
@@ -158,7 +163,7 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
for (i = 0; i < num_slices; i++) {
if (GRPC_ERROR_NONE == error) {
- error = grpc_http_parser_parse(&parser, slices[i], NULL);
+ error = grpc_http_parser_parse(&parser, slices[i], nullptr);
}
grpc_slice_unref(slices[i]);
}
@@ -174,13 +179,13 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
}
static void test_request_fails(grpc_slice_split_mode split_mode,
- char *request_text) {
+ const char* request_text) {
grpc_http_parser parser;
grpc_slice input_slice = grpc_slice_from_copied_string(request_text);
size_t num_slices;
size_t i;
- grpc_slice *slices;
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_slice* slices;
+ grpc_error* error = GRPC_ERROR_NONE;
grpc_http_request request;
memset(&request, 0, sizeof(request));
@@ -191,7 +196,7 @@ static void test_request_fails(grpc_slice_split_mode split_mode,
for (i = 0; i < num_slices; i++) {
if (error == GRPC_ERROR_NONE) {
- error = grpc_http_parser_parse(&parser, slices[i], NULL);
+ error = grpc_http_parser_parse(&parser, slices[i], nullptr);
}
grpc_slice_unref(slices[i]);
}
@@ -206,13 +211,14 @@ static void test_request_fails(grpc_slice_split_mode split_mode,
gpr_free(slices);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
const grpc_slice_split_mode split_modes[] = {GRPC_SLICE_SPLIT_IDENTITY,
GRPC_SLICE_SPLIT_ONE_BYTE};
char *tmp1, *tmp2;
grpc_test_init(argc, argv);
+ grpc_init();
for (i = 0; i < GPR_ARRAY_SIZE(split_modes); i++) {
test_succeeds(split_modes[i],
@@ -224,7 +230,7 @@ int main(int argc, char **argv) {
test_succeeds(split_modes[i],
"HTTP/1.0 404 Not Found\r\n"
"\r\n",
- 404, NULL, NULL);
+ 404, nullptr, NULL);
test_succeeds(split_modes[i],
"HTTP/1.1 200 OK\r\n"
"xyz: abc\r\n"
@@ -239,7 +245,7 @@ int main(int argc, char **argv) {
test_request_succeeds(split_modes[i],
"GET / HTTP/1.0\r\n"
"\r\n",
- "GET", GRPC_HTTP_HTTP10, "/", NULL, NULL);
+ "GET", GRPC_HTTP_HTTP10, "/", nullptr, NULL);
test_request_succeeds(split_modes[i],
"GET / HTTP/1.0\r\n"
"\r\n"
@@ -286,7 +292,8 @@ int main(int argc, char **argv) {
test_request_fails(split_modes[i], "GET / HTTP/1.2\r\n");
test_request_fails(split_modes[i], "GET / HTTP/1.0\n");
- tmp1 = gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
+ tmp1 =
+ static_cast<char*>(gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH));
memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1);
tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0;
gpr_asprintf(&tmp2, "HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1);
@@ -295,5 +302,6 @@ int main(int argc, char **argv) {
gpr_free(tmp2);
}
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/http/python_wrapper.sh b/test/core/http/python_wrapper.sh
new file mode 120000
index 0000000000..9ed6e3293f
--- /dev/null
+++ b/test/core/http/python_wrapper.sh
@@ -0,0 +1 @@
+../../../tools/distrib/python_wrapper.sh \ No newline at end of file
diff --git a/test/core/http/request_fuzzer.c b/test/core/http/request_fuzzer.cc
index aefe9eb0f9..9798cfb33c 100644
--- a/test/core/http/request_fuzzer.c
+++ b/test/core/http/request_fuzzer.cc
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/http/parser.h"
@@ -27,16 +28,18 @@
bool squelch = true;
bool leak_check = true;
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_http_parser parser;
grpc_http_request request;
+ grpc_init();
memset(&request, 0, sizeof(request));
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
- grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size);
- GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL));
+ grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
+ GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, nullptr));
GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser));
grpc_slice_unref(slice);
grpc_http_parser_destroy(&parser);
grpc_http_request_destroy(&request);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/http/response_fuzzer.c b/test/core/http/response_fuzzer.cc
index d5bb67500d..fc0904b1db 100644
--- a/test/core/http/response_fuzzer.c
+++ b/test/core/http/response_fuzzer.cc
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/http/parser.h"
@@ -26,16 +27,18 @@
bool squelch = true;
bool leak_check = true;
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_http_parser parser;
grpc_http_response response;
+ grpc_init();
memset(&response, 0, sizeof(response));
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
- grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size);
- GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL));
+ grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
+ GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, nullptr));
GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser));
grpc_slice_unref(slice);
grpc_http_parser_destroy(&parser);
grpc_http_response_destroy(&response);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD
index 7620d1de21..41e2607646 100644
--- a/test/core/iomgr/BUILD
+++ b/test/core/iomgr/BUILD
@@ -22,9 +22,9 @@ grpc_package(name = "test/core/iomgr", visibility = "public") # Useful for third
grpc_cc_library(
name = "endpoint_tests",
- srcs = ["endpoint_tests.c"],
+ srcs = ["endpoint_tests.cc"],
hdrs = ["endpoint_tests.h"],
- language = "C",
+ language = "C++",
visibility = ["//test:__subpackages__"],
deps = [
"//:gpr",
@@ -36,8 +36,8 @@ grpc_cc_library(
grpc_cc_test(
name = "combiner_test",
- srcs = ["combiner_test.c"],
- language = "C",
+ srcs = ["combiner_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -48,8 +48,8 @@ grpc_cc_test(
grpc_cc_test(
name = "endpoint_pair_test",
- srcs = ["endpoint_pair_test.c"],
- language = "C",
+ srcs = ["endpoint_pair_test.cc"],
+ language = "C++",
deps = [
":endpoint_tests",
"//:gpr",
@@ -61,20 +61,20 @@ grpc_cc_test(
grpc_cc_test(
name = "ev_epollsig_linux_test",
- srcs = ["ev_epollsig_linux_test.c"],
+ srcs = ["ev_epollsig_linux_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
- language = "C",
+ language = "C++",
)
grpc_cc_test(
name = "fd_conservation_posix_test",
- srcs = ["fd_conservation_posix_test.c"],
- language = "C",
+ srcs = ["fd_conservation_posix_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -85,8 +85,8 @@ grpc_cc_test(
grpc_cc_test(
name = "fd_posix_test",
- srcs = ["fd_posix_test.c"],
- language = "C",
+ srcs = ["fd_posix_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -97,8 +97,8 @@ grpc_cc_test(
grpc_cc_test(
name = "load_file_test",
- srcs = ["load_file_test.c"],
- language = "C",
+ srcs = ["load_file_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -109,8 +109,8 @@ grpc_cc_test(
grpc_cc_test(
name = "pollset_set_test",
- srcs = ["pollset_set_test.c"],
- language = "C",
+ srcs = ["pollset_set_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -121,8 +121,8 @@ grpc_cc_test(
grpc_cc_test(
name = "resolve_address_posix_test",
- srcs = ["resolve_address_posix_test.c"],
- language = "C",
+ srcs = ["resolve_address_posix_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -133,8 +133,8 @@ grpc_cc_test(
grpc_cc_test(
name = "resolve_address_test",
- srcs = ["resolve_address_test.c"],
- language = "C",
+ srcs = ["resolve_address_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -145,8 +145,8 @@ grpc_cc_test(
grpc_cc_test(
name = "resource_quota_test",
- srcs = ["resource_quota_test.c"],
- language = "C",
+ srcs = ["resource_quota_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -157,8 +157,8 @@ grpc_cc_test(
grpc_cc_test(
name = "sockaddr_utils_test",
- srcs = ["sockaddr_utils_test.c"],
- language = "C",
+ srcs = ["sockaddr_utils_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -169,8 +169,8 @@ grpc_cc_test(
grpc_cc_test(
name = "socket_utils_test",
- srcs = ["socket_utils_test.c"],
- language = "C",
+ srcs = ["socket_utils_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -181,8 +181,8 @@ grpc_cc_test(
grpc_cc_test(
name = "tcp_client_posix_test",
- srcs = ["tcp_client_posix_test.c"],
- language = "C",
+ srcs = ["tcp_client_posix_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -193,8 +193,8 @@ grpc_cc_test(
grpc_cc_test(
name = "tcp_posix_test",
- srcs = ["tcp_posix_test.c"],
- language = "C",
+ srcs = ["tcp_posix_test.cc"],
+ language = "C++",
deps = [
":endpoint_tests",
"//:gpr",
@@ -206,8 +206,8 @@ grpc_cc_test(
grpc_cc_test(
name = "tcp_server_posix_test",
- srcs = ["tcp_server_posix_test.c"],
- language = "C",
+ srcs = ["tcp_server_posix_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -218,8 +218,8 @@ grpc_cc_test(
grpc_cc_test(
name = "time_averaged_stats_test",
- srcs = ["time_averaged_stats_test.c"],
- language = "C",
+ srcs = ["time_averaged_stats_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -230,8 +230,8 @@ grpc_cc_test(
grpc_cc_test(
name = "timer_heap_test",
- srcs = ["timer_heap_test.c"],
- language = "C",
+ srcs = ["timer_heap_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -242,8 +242,8 @@ grpc_cc_test(
grpc_cc_test(
name = "timer_list_test",
- srcs = ["timer_list_test.c"],
- language = "C",
+ srcs = ["timer_list_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -254,8 +254,8 @@ grpc_cc_test(
grpc_cc_test(
name = "udp_server_test",
- srcs = ["udp_server_test.c"],
- language = "C",
+ srcs = ["udp_server_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -266,8 +266,8 @@ grpc_cc_test(
grpc_cc_test(
name = "wakeup_fd_cv_test",
- srcs = ["wakeup_fd_cv_test.c"],
- language = "C",
+ srcs = ["wakeup_fd_cv_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/iomgr/combiner_test.c b/test/core/iomgr/combiner_test.cc
index 38f512de0e..891008c774 100644
--- a/test/core/iomgr/combiner_test.c
+++ b/test/core/iomgr/combiner_test.cc
@@ -28,82 +28,75 @@
static void test_no_op(void) {
gpr_log(GPR_DEBUG, "test_no_op");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, grpc_combiner_create(), "test_no_op");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_COMBINER_UNREF(grpc_combiner_create(), "test_no_op");
}
-static void set_event_to_true(grpc_exec_ctx *exec_ctx, void *value,
- grpc_error *error) {
- gpr_event_set(value, (void *)1);
+static void set_event_to_true(void* value, grpc_error* error) {
+ gpr_event_set(static_cast<gpr_event*>(value), (void*)1);
}
static void test_execute_one(void) {
gpr_log(GPR_DEBUG, "test_execute_one");
- grpc_combiner *lock = grpc_combiner_create();
+ grpc_combiner* lock = grpc_combiner_create();
gpr_event done;
gpr_event_init(&done);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(set_event_to_true, &done,
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &done,
grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&done, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_one");
- grpc_exec_ctx_finish(&exec_ctx);
+ nullptr);
+ GRPC_COMBINER_UNREF(lock, "test_execute_one");
}
typedef struct {
size_t ctr;
- grpc_combiner *lock;
+ grpc_combiner* lock;
gpr_event done;
} thd_args;
typedef struct {
- size_t *ctr;
+ size_t* ctr;
size_t value;
} ex_args;
-static void check_one(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) {
- ex_args *args = a;
+static void check_one(void* a, grpc_error* error) {
+ ex_args* args = static_cast<ex_args*>(a);
GPR_ASSERT(*args->ctr == args->value - 1);
*args->ctr = args->value;
gpr_free(a);
}
-static void execute_many_loop(void *a) {
- thd_args *args = a;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+static void execute_many_loop(void* a) {
+ thd_args* args = static_cast<thd_args*>(a);
+ grpc_core::ExecCtx exec_ctx;
size_t n = 1;
for (size_t i = 0; i < 10; i++) {
for (size_t j = 0; j < 10000; j++) {
- ex_args *c = gpr_malloc(sizeof(*c));
+ ex_args* c = static_cast<ex_args*>(gpr_malloc(sizeof(*c)));
c->ctr = &args->ctr;
c->value = n++;
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(
check_one, c, grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
// sleep for a little bit, to test a combiner draining and another thread
// picking it up
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100));
}
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_execute_many(void) {
gpr_log(GPR_DEBUG, "test_execute_many");
- grpc_combiner *lock = grpc_combiner_create();
+ grpc_combiner* lock = grpc_combiner_create();
gpr_thd_id thds[100];
thd_args ta[GPR_ARRAY_SIZE(thds)];
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
@@ -112,49 +105,47 @@ static void test_execute_many(void) {
ta[i].ctr = 0;
ta[i].lock = lock;
gpr_event_init(&ta[i].done);
- GPR_ASSERT(gpr_thd_new(&thds[i], execute_many_loop, &ta[i], &options));
+ GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_execute_many", execute_many_loop,
+ &ta[i], &options));
}
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
GPR_ASSERT(gpr_event_wait(&ta[i].done,
- gpr_inf_future(GPR_CLOCK_REALTIME)) != NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME)) != nullptr);
gpr_thd_join(thds[i]);
}
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_many");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_COMBINER_UNREF(lock, "test_execute_many");
}
static gpr_event got_in_finally;
-static void in_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- gpr_event_set(&got_in_finally, (void *)1);
+static void in_finally(void* arg, grpc_error* error) {
+ gpr_event_set(&got_in_finally, (void*)1);
}
-static void add_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(in_finally, arg,
- grpc_combiner_finally_scheduler(arg)),
+static void add_finally(void* arg, grpc_error* error) {
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(in_finally, arg,
+ grpc_combiner_finally_scheduler(
+ static_cast<grpc_combiner*>(arg))),
GRPC_ERROR_NONE);
}
static void test_execute_finally(void) {
gpr_log(GPR_DEBUG, "test_execute_finally");
- grpc_combiner *lock = grpc_combiner_create();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_combiner* lock = grpc_combiner_create();
+ grpc_core::ExecCtx exec_ctx;
gpr_event_init(&got_in_finally);
GRPC_CLOSURE_SCHED(
- &exec_ctx,
GRPC_CLOSURE_CREATE(add_finally, lock, grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&got_in_finally,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_finally");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
+ GRPC_COMBINER_UNREF(lock, "test_execute_finally");
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_no_op();
diff --git a/test/core/iomgr/endpoint_pair_test.c b/test/core/iomgr/endpoint_pair_test.cc
index f2ce3d0d12..90dd40d9c4 100644
--- a/test/core/iomgr/endpoint_pair_test.c
+++ b/test/core/iomgr/endpoint_pair_test.cc
@@ -25,26 +25,26 @@
#include "test/core/iomgr/endpoint_tests.h"
#include "test/core/util/test_config.h"
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static void clean_up(void) {}
static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
size_t slice_size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_endpoint_test_fixture f;
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER;
+ a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
grpc_endpoint_pair p = grpc_iomgr_create_endpoint_pair("test", &args);
f.client_ep = p.client;
f.server_ep = p.server;
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
return f;
}
@@ -53,23 +53,23 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_endpoint_pair, clean_up},
};
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
- grpc_endpoint_tests(configs[0], g_pollset, g_mu);
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_endpoint_tests(configs[0], g_pollset, g_mu);
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+ }
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.cc
index f8570edde7..8ccae52067 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -46,14 +46,14 @@
*/
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
-size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) {
+size_t count_slices(grpc_slice* slices, size_t nslices, int* current_data) {
size_t num_bytes = 0;
size_t i;
size_t j;
- unsigned char *buf;
+ unsigned char* buf;
for (i = 0; i < nslices; ++i) {
buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
@@ -66,7 +66,7 @@ size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) {
}
static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config,
- const char *test_name,
+ const char* test_name,
size_t slice_size) {
gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
return config.create_fixture(slice_size);
@@ -74,14 +74,14 @@ static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config,
static void end_test(grpc_endpoint_test_config config) { config.clean_up(); }
-static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
- size_t *num_blocks, uint8_t *current_data) {
+static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
+ size_t* num_blocks, uint8_t* current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0);
- grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices);
+ grpc_slice* slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * nslices);
size_t num_bytes_left = num_bytes;
size_t i;
size_t j;
- unsigned char *buf;
+ unsigned char* buf;
*num_blocks = nslices;
for (i = 0; i < nslices; ++i) {
@@ -99,8 +99,8 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
}
struct read_and_write_test_state {
- grpc_endpoint *read_ep;
- grpc_endpoint *write_ep;
+ grpc_endpoint* read_ep;
+ grpc_endpoint* write_ep;
size_t target_bytes;
size_t bytes_read;
size_t current_write_size;
@@ -115,10 +115,9 @@ struct read_and_write_test_state {
grpc_closure done_write;
};
-static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx,
- void *data, grpc_error *error) {
- struct read_and_write_test_state *state =
- (struct read_and_write_test_state *)data;
+static void read_and_write_test_read_handler(void* data, grpc_error* error) {
+ struct read_and_write_test_state* state =
+ (struct read_and_write_test_state*)data;
state->bytes_read += count_slices(
state->incoming.slices, state->incoming.count, &state->current_read_data);
@@ -126,20 +125,17 @@ static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx,
gpr_log(GPR_INFO, "Read handler done");
gpr_mu_lock(g_mu);
state->read_done = 1 + (error == GRPC_ERROR_NONE);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
} else if (error == GRPC_ERROR_NONE) {
- grpc_endpoint_read(exec_ctx, state->read_ep, &state->incoming,
- &state->done_read);
+ grpc_endpoint_read(state->read_ep, &state->incoming, &state->done_read);
}
}
-static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx,
- void *data, grpc_error *error) {
- struct read_and_write_test_state *state =
- (struct read_and_write_test_state *)data;
- grpc_slice *slices = NULL;
+static void read_and_write_test_write_handler(void* data, grpc_error* error) {
+ struct read_and_write_test_state* state =
+ (struct read_and_write_test_state*)data;
+ grpc_slice* slices = nullptr;
size_t nslices;
if (error == GRPC_ERROR_NONE) {
@@ -153,7 +149,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx,
&state->current_write_data);
grpc_slice_buffer_reset_and_unref(&state->outgoing);
grpc_slice_buffer_addn(&state->outgoing, slices, nslices);
- grpc_endpoint_write(exec_ctx, state->write_ep, &state->outgoing,
+ grpc_endpoint_write(state->write_ep, &state->outgoing,
&state->done_write);
gpr_free(slices);
return;
@@ -163,8 +159,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx,
gpr_log(GPR_INFO, "Write handler done");
gpr_mu_lock(g_mu);
state->write_done = 1 + (error == GRPC_ERROR_NONE);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
}
@@ -176,19 +171,22 @@ static void read_and_write_test(grpc_endpoint_test_config config,
size_t num_bytes, size_t write_size,
size_t slice_size, bool shutdown) {
struct read_and_write_test_state state;
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
grpc_endpoint_test_fixture f =
begin_test(config, "read_and_write_test", slice_size);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR
- " slice_size=%" PRIuPTR " shutdown=%d",
+ grpc_core::ExecCtx exec_ctx;
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
+ gpr_log(GPR_DEBUG,
+ "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR " slice_size=%" PRIuPTR
+ " shutdown=%d",
num_bytes, write_size, slice_size, shutdown);
if (shutdown) {
gpr_log(GPR_INFO, "Start read and write shutdown test");
} else {
- gpr_log(GPR_INFO, "Start read and write test with %" PRIuPTR
- " bytes, slice size %" PRIuPTR,
+ gpr_log(GPR_INFO,
+ "Start read and write test with %" PRIuPTR
+ " bytes, slice size %" PRIuPTR,
num_bytes, slice_size);
}
@@ -214,67 +212,57 @@ static void read_and_write_test(grpc_endpoint_test_config config,
for the first iteration as for later iterations. It does the right thing
even when bytes_written is unsigned. */
state.bytes_written -= state.current_write_size;
- read_and_write_test_write_handler(&exec_ctx, &state, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ read_and_write_test_write_handler(&state, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_endpoint_read(&exec_ctx, state.read_ep, &state.incoming,
- &state.done_read);
+ grpc_endpoint_read(state.read_ep, &state.incoming, &state.done_read);
if (shutdown) {
gpr_log(GPR_DEBUG, "shutdown read");
grpc_endpoint_shutdown(
- &exec_ctx, state.read_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ state.read_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
gpr_log(GPR_DEBUG, "shutdown write");
grpc_endpoint_shutdown(
- &exec_ctx, state.write_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ state.write_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!state.read_done || !state.write_done) {
- grpc_pollset_worker *worker = NULL;
- GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) < 0);
+ grpc_pollset_worker* worker = nullptr;
+ GPR_ASSERT(grpc_core::ExecCtx::Get()->Now() < deadline);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
end_test(config);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.outgoing);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, state.read_ep);
- grpc_endpoint_destroy(&exec_ctx, state.write_ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.outgoing);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(state.read_ep);
+ grpc_endpoint_destroy(state.write_ep);
}
-static void inc_on_failure(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void inc_on_failure(void* arg, grpc_error* error) {
gpr_mu_lock(g_mu);
- *(int *)arg += (error != GRPC_ERROR_NONE);
- GPR_ASSERT(
- GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ *(int*)arg += (error != GRPC_ERROR_NONE);
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count,
- int want_fail_count) {
- grpc_exec_ctx_flush(exec_ctx);
+static void wait_for_fail_count(int* fail_count, int want_fail_count) {
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
- while (gpr_time_cmp(gpr_now(deadline.clock_type), deadline) < 0 &&
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
+ while (grpc_core::ExecCtx::Get()->Now() < deadline &&
*fail_count < want_fail_count) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(exec_ctx, g_pollset, &worker,
- gpr_now(deadline.clock_type), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(*fail_count == want_fail_count);
@@ -289,37 +277,36 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_slice_buffer slice_buffer;
grpc_slice_buffer_init(&slice_buffer);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_read(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 0);
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
+ wait_for_fail_count(&fail_count, 0);
+ grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- wait_for_fail_count(&exec_ctx, &fail_count, 1);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
+ wait_for_fail_count(&fail_count, 1);
+ grpc_endpoint_read(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 2);
+ wait_for_fail_count(&fail_count, 2);
grpc_slice_buffer_add(&slice_buffer, grpc_slice_from_copied_string("a"));
- grpc_endpoint_write(&exec_ctx, f.client_ep, &slice_buffer,
+ grpc_endpoint_write(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 3);
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
+ wait_for_fail_count(&fail_count, 3);
+ grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- wait_for_fail_count(&exec_ctx, &fail_count, 3);
+ wait_for_fail_count(&fail_count, 3);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &slice_buffer);
+ grpc_slice_buffer_destroy_internal(&slice_buffer);
- grpc_endpoint_destroy(&exec_ctx, f.client_ep);
- grpc_endpoint_destroy(&exec_ctx, f.server_ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_destroy(f.client_ep);
+ grpc_endpoint_destroy(f.server_ep);
}
void grpc_endpoint_tests(grpc_endpoint_test_config config,
- grpc_pollset *pollset, gpr_mu *mu) {
+ grpc_pollset* pollset, gpr_mu* mu) {
size_t i;
g_pollset = pollset;
g_mu = mu;
@@ -330,6 +317,6 @@ void grpc_endpoint_tests(grpc_endpoint_test_config config,
for (i = 1; i < 1000; i = GPR_MAX(i + 1, i * 5 / 4)) {
read_and_write_test(config, 40320, i, i, false);
}
- g_pollset = NULL;
- g_mu = NULL;
+ g_pollset = nullptr;
+ g_mu = nullptr;
}
diff --git a/test/core/iomgr/endpoint_tests.h b/test/core/iomgr/endpoint_tests.h
index def29d3224..227eeb997c 100644
--- a/test/core/iomgr/endpoint_tests.h
+++ b/test/core/iomgr/endpoint_tests.h
@@ -27,17 +27,17 @@ typedef struct grpc_endpoint_test_config grpc_endpoint_test_config;
typedef struct grpc_endpoint_test_fixture grpc_endpoint_test_fixture;
struct grpc_endpoint_test_fixture {
- grpc_endpoint *client_ep;
- grpc_endpoint *server_ep;
+ grpc_endpoint* client_ep;
+ grpc_endpoint* server_ep;
};
struct grpc_endpoint_test_config {
- const char *name;
+ const char* name;
grpc_endpoint_test_fixture (*create_fixture)(size_t slice_size);
void (*clean_up)();
};
void grpc_endpoint_tests(grpc_endpoint_test_config config,
- grpc_pollset *pollset, gpr_mu *mu);
+ grpc_pollset* pollset, gpr_mu* mu);
#endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */
diff --git a/test/core/iomgr/error_test.c b/test/core/iomgr/error_test.cc
index 51f8af1957..51f8af1957 100644
--- a/test/core/iomgr/error_test.c
+++ b/test/core/iomgr/error_test.cc
diff --git a/test/core/iomgr/ev_epollsig_linux_test.c b/test/core/iomgr/ev_epollsig_linux_test.cc
index cca07bf002..262470300e 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.c
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -18,7 +18,7 @@
#include "src/core/lib/iomgr/port.h"
/* This test only relevant on linux systems where epoll() is available */
-#ifdef GRPC_LINUX_EPOLL
+#ifdef GRPC_LINUX_EPOLL_CREATE1
#include "src/core/lib/iomgr/ev_epollsig_linux.h"
#include "src/core/lib/iomgr/ev_posix.h"
@@ -36,17 +36,17 @@
#include "test/core/util/test_config.h"
typedef struct test_pollset {
- grpc_pollset *pollset;
- gpr_mu *mu;
+ grpc_pollset* pollset;
+ gpr_mu* mu;
} test_pollset;
typedef struct test_fd {
int inner_fd;
- grpc_fd *fd;
+ grpc_fd* fd;
} test_fd;
/* num_fds should be an even number */
-static void test_fd_init(test_fd *tfds, int *fds, int num_fds) {
+static void test_fd_init(test_fd* tfds, int* fds, int num_fds) {
int i;
int r;
@@ -70,73 +70,71 @@ static void test_fd_init(test_fd *tfds, int *fds, int num_fds) {
}
}
-static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds,
- int num_fds) {
+static void test_fd_cleanup(test_fd* tfds, int num_fds) {
int release_fd;
int i;
for (i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd,
- false /* already_closed */, "test_fd_cleanup");
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
+ "test_fd_cleanup");
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(release_fd == tfds[i].inner_fd);
close(tfds[i].inner_fd);
}
}
-static void test_pollset_init(test_pollset *pollsets, int num_pollsets) {
+static void test_pollset_init(test_pollset* pollsets, int num_pollsets) {
int i;
for (i = 0; i < num_pollsets; i++) {
- pollsets[i].pollset = gpr_zalloc(grpc_pollset_size());
+ pollsets[i].pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollsets[i].pollset, &pollsets[i].mu);
}
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx,
- test_pollset *pollsets, int num_pollsets) {
+static void test_pollset_cleanup(test_pollset* pollsets, int num_pollsets) {
grpc_closure destroyed;
int i;
for (i = 0; i < num_pollsets; i++) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, pollsets[i].pollset, &destroyed);
+ grpc_pollset_shutdown(pollsets[i].pollset, &destroyed);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(pollsets[i].pollset);
}
}
-/*
- * Cases to test:
- * case 1) Polling islands of both fd and pollset are NULL
- * case 2) Polling island of fd is NULL but that of pollset is not-NULL
- * case 3) Polling island of fd is not-NULL but that of pollset is NULL
- * case 4) Polling islands of both fd and pollset are not-NULL and:
- * case 4.1) Polling islands of fd and pollset are equal
- * case 4.2) Polling islands of fd and pollset are NOT-equal (This results
- * in a merge)
- * */
+ /*
+ * Cases to test:
+ * case 1) Polling islands of both fd and pollset are NULL
+ * case 2) Polling island of fd is NULL but that of pollset is not-NULL
+ * case 3) Polling island of fd is not-NULL but that of pollset is NULL
+ * case 4) Polling islands of both fd and pollset are not-NULL and:
+ * case 4.1) Polling islands of fd and pollset are equal
+ * case 4.2) Polling islands of fd and pollset are NOT-equal (This results
+ * in a merge)
+ * */
#define NUM_FDS 8
#define NUM_POLLSETS 4
static void test_add_fd_to_pollset() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
test_fd tfds[NUM_FDS];
int fds[NUM_FDS];
test_pollset pollsets[NUM_POLLSETS];
- void *expected_pi = NULL;
+ void* expected_pi = nullptr;
int i;
test_fd_init(tfds, fds, NUM_FDS);
@@ -169,33 +167,33 @@ static void test_add_fd_to_pollset() {
/* == Step 1 == */
for (i = 0; i <= 2; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[0].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (i = 3; i <= 4; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[1].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (i = 5; i <= 7; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[2].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* == Step 2 == */
for (i = 0; i <= 1; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[3].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[3].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* == Step 3 == */
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].pollset, tfds[0].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[1].pollset, tfds[0].fd);
+ grpc_core::ExecCtx::Get()->Flush();
/* == Step 4 == */
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].pollset, tfds[3].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[2].pollset, tfds[3].fd);
+ grpc_core::ExecCtx::Get()->Flush();
/* All polling islands are merged at this point */
@@ -212,50 +210,45 @@ static void test_add_fd_to_pollset() {
expected_pi, grpc_pollset_get_polling_island(pollsets[i].pollset)));
}
- test_fd_cleanup(&exec_ctx, tfds, NUM_FDS);
- test_pollset_cleanup(&exec_ctx, pollsets, NUM_POLLSETS);
- grpc_exec_ctx_finish(&exec_ctx);
+ test_fd_cleanup(tfds, NUM_FDS);
+ test_pollset_cleanup(pollsets, NUM_POLLSETS);
}
#undef NUM_FDS
#undef NUM_POLLSETS
typedef struct threading_shared {
- gpr_mu *mu;
- grpc_pollset *pollset;
- grpc_wakeup_fd *wakeup_fd;
- grpc_fd *wakeup_desc;
+ gpr_mu* mu;
+ grpc_pollset* pollset;
+ grpc_wakeup_fd* wakeup_fd;
+ grpc_fd* wakeup_desc;
grpc_closure on_wakeup;
int wakeups;
} threading_shared;
static __thread int thread_wakeups = 0;
-static void test_threading_loop(void *arg) {
- threading_shared *shared = arg;
+static void test_threading_loop(void* arg) {
+ threading_shared* shared = static_cast<threading_shared*>(arg);
while (thread_wakeups < 1000000) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_worker *worker;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_worker* worker;
gpr_mu_lock(shared->mu);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, shared->pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ grpc_pollset_work(shared->pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(shared->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
-static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- threading_shared *shared = arg;
+static void test_threading_wakeup(void* arg, grpc_error* error) {
+ threading_shared* shared = static_cast<threading_shared*>(arg);
++shared->wakeups;
++thread_wakeups;
if (error == GRPC_ERROR_NONE) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"consume_wakeup", grpc_wakeup_fd_consume_wakeup(shared->wakeup_fd)));
- grpc_fd_notify_on_read(exec_ctx, shared->wakeup_desc, &shared->on_wakeup);
+ grpc_fd_notify_on_read(shared->wakeup_desc, &shared->on_wakeup);
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_next",
grpc_wakeup_fd_wakeup(shared->wakeup_fd)));
}
@@ -263,14 +256,14 @@ static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg,
static void test_threading(void) {
threading_shared shared;
- shared.pollset = gpr_zalloc(grpc_pollset_size());
+ shared.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(shared.pollset, &shared.mu);
gpr_thd_id thds[10];
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&thds[i], test_threading_loop, &shared, &opt);
+ gpr_thd_new(&thds[i], "test_thread", test_threading_loop, &shared, &opt);
}
grpc_wakeup_fd fd;
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&fd)));
@@ -278,13 +271,12 @@ static void test_threading(void) {
shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup");
shared.wakeups = 0;
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_add_fd(&exec_ctx, shared.pollset, shared.wakeup_desc);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_add_fd(shared.pollset, shared.wakeup_desc);
grpc_fd_notify_on_read(
- &exec_ctx, shared.wakeup_desc,
+ shared.wakeup_desc,
GRPC_CLOSURE_INIT(&shared.on_wakeup, test_threading_wakeup, &shared,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
}
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_first",
grpc_wakeup_fd_wakeup(shared.wakeup_fd)));
@@ -294,39 +286,39 @@ static void test_threading(void) {
fd.read_fd = 0;
grpc_wakeup_fd_destroy(&fd);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_fd_shutdown(&exec_ctx, shared.wakeup_desc, GRPC_ERROR_CANCELLED);
- grpc_fd_orphan(&exec_ctx, shared.wakeup_desc, NULL, NULL,
+ grpc_core::ExecCtx exec_ctx;
+ grpc_fd_shutdown(shared.wakeup_desc, GRPC_ERROR_CANCELLED);
+ grpc_fd_orphan(shared.wakeup_desc, nullptr, nullptr,
false /* already_closed */, "done");
- grpc_pollset_shutdown(&exec_ctx, shared.pollset,
+ grpc_pollset_shutdown(shared.pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_free(shared.pollset);
}
-int main(int argc, char **argv) {
- const char *poll_strategy = NULL;
+int main(int argc, char** argv) {
+ const char* poll_strategy = nullptr;
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- poll_strategy = grpc_get_poll_strategy_name();
- if (poll_strategy != NULL && strcmp(poll_strategy, "epollsig") == 0) {
- test_add_fd_to_pollset();
- test_threading();
- } else {
- gpr_log(GPR_INFO,
- "Skipping the test. The test is only relevant for 'epollsig' "
- "strategy. and the current strategy is: '%s'",
- poll_strategy);
+ {
+ grpc_core::ExecCtx exec_ctx;
+
+ poll_strategy = grpc_get_poll_strategy_name();
+ if (poll_strategy != nullptr && strcmp(poll_strategy, "epollsig") == 0) {
+ test_add_fd_to_pollset();
+ test_threading();
+ } else {
+ gpr_log(GPR_INFO,
+ "Skipping the test. The test is only relevant for 'epollsig' "
+ "strategy. and the current strategy is: '%s'",
+ poll_strategy);
+ }
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
-#else /* defined(GRPC_LINUX_EPOLL) */
-int main(int argc, char **argv) { return 0; }
-#endif /* !defined(GRPC_LINUX_EPOLL) */
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
+int main(int argc, char** argv) { return 0; }
+#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/test/core/iomgr/fd_conservation_posix_test.c b/test/core/iomgr/fd_conservation_posix_test.cc
index d29b1e8e41..4866e350d5 100644
--- a/test/core/iomgr/fd_conservation_posix_test.c
+++ b/test/core/iomgr/fd_conservation_posix_test.cc
@@ -24,33 +24,34 @@
#include "src/core/lib/iomgr/iomgr.h"
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int i;
struct rlimit rlim;
grpc_endpoint_pair p;
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- /* set max # of file descriptors to a low value, and
- verify we can create and destroy many more than this number
- of descriptors */
- rlim.rlim_cur = rlim.rlim_max = 10;
- GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim));
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("fd_conservation_posix_test");
-
- for (i = 0; i < 100; i++) {
- p = grpc_iomgr_create_endpoint_pair("test", NULL);
- grpc_endpoint_destroy(&exec_ctx, p.client);
- grpc_endpoint_destroy(&exec_ctx, p.server);
- grpc_exec_ctx_flush(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+
+ /* set max # of file descriptors to a low value, and
+ verify we can create and destroy many more than this number
+ of descriptors */
+ rlim.rlim_cur = rlim.rlim_max = 10;
+ GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim));
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("fd_conservation_posix_test");
+
+ for (i = 0; i < 100; i++) {
+ p = grpc_iomgr_create_endpoint_pair("test", nullptr);
+ grpc_endpoint_destroy(p.client);
+ grpc_endpoint_destroy(p.server);
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+
+ grpc_resource_quota_unref(resource_quota);
}
- grpc_resource_quota_unref(resource_quota);
-
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.cc
index 881277a8d6..cf75517538 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -46,8 +46,8 @@
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "test/core/util/test_config.h"
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
/* buffer size used to send and receive data.
1024 is the minimal value to set TCP send and receive buffer. */
@@ -56,8 +56,8 @@ static grpc_pollset *g_pollset;
/* Create a test socket with the right properties for testing.
port is the TCP port to listen or connect to.
Return a socket FD and sockaddr_in. */
-static void create_test_socket(int port, int *socket_fd,
- struct sockaddr_in *sin) {
+static void create_test_socket(int port, int* socket_fd,
+ struct sockaddr_in* sin) {
int fd;
int one = 1;
int buffer_size_bytes = BUF_SIZE;
@@ -82,20 +82,20 @@ static void create_test_socket(int port, int *socket_fd,
}
/* Dummy gRPC callback */
-void no_op_cb(void *arg, int success) {}
+void no_op_cb(void* arg, int success) {}
/* =======An upload server to test notify_on_read===========
The server simply reads and counts a stream of bytes. */
/* An upload server. */
typedef struct {
- grpc_fd *em_fd; /* listening fd */
+ grpc_fd* em_fd; /* listening fd */
ssize_t read_bytes_total; /* total number of received bytes */
int done; /* set to 1 when a server finishes serving */
grpc_closure listen_closure;
} server;
-static void server_init(server *sv) {
+static void server_init(server* sv) {
sv->read_bytes_total = 0;
sv->done = 0;
}
@@ -103,37 +103,36 @@ static void server_init(server *sv) {
/* An upload session.
Created when a new upload request arrives in the server. */
typedef struct {
- server *sv; /* not owned by a single session */
- grpc_fd *em_fd; /* fd to read upload bytes */
+ server* sv; /* not owned by a single session */
+ grpc_fd* em_fd; /* fd to read upload bytes */
char read_buf[BUF_SIZE]; /* buffer to store upload bytes */
grpc_closure session_read_closure;
} session;
/* Called when an upload session can be safely shutdown.
Close session FD and start to shutdown listen FD. */
-static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */
+static void session_shutdown_cb(void* arg, /*session */
bool success) {
- session *se = arg;
- server *sv = se->sv;
- grpc_fd_orphan(exec_ctx, se->em_fd, NULL, NULL, false /* already_closed */,
- "a");
+ session* se = static_cast<session*>(arg);
+ server* sv = se->sv;
+ grpc_fd_orphan(se->em_fd, nullptr, nullptr, false /* already_closed */, "a");
gpr_free(se);
/* Start to shutdown listen fd. */
- grpc_fd_shutdown(exec_ctx, sv->em_fd,
+ grpc_fd_shutdown(sv->em_fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("session_shutdown_cb"));
}
/* Called when data become readable in a session. */
-static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */
- grpc_error *error) {
- session *se = arg;
+static void session_read_cb(void* arg, /*session */
+ grpc_error* error) {
+ session* se = static_cast<session*>(arg);
int fd = grpc_fd_wrapped_fd(se->em_fd);
ssize_t read_once = 0;
ssize_t read_total = 0;
if (error != GRPC_ERROR_NONE) {
- session_shutdown_cb(exec_ctx, arg, 1);
+ session_shutdown_cb(arg, 1);
return;
}
@@ -148,7 +147,7 @@ static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */
It is possible to read nothing due to spurious edge event or data has
been drained, In such a case, read() returns -1 and set errno to EAGAIN. */
if (read_once == 0) {
- session_shutdown_cb(exec_ctx, arg, 1);
+ session_shutdown_cb(arg, 1);
} else if (read_once == -1) {
if (errno == EAGAIN) {
/* An edge triggered event is cached in the kernel until next poll.
@@ -159,7 +158,7 @@ static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */
TODO(chenw): in multi-threaded version, callback and polling can be
run in different threads. polling may catch a persist read edge event
before notify_on_read is called. */
- grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
+ grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
} else {
gpr_log(GPR_ERROR, "Unhandled read error %s", strerror(errno));
abort();
@@ -169,50 +168,48 @@ static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */
/* Called when the listen FD can be safely shutdown.
Close listen FD and signal that server can be shutdown. */
-static void listen_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg /*server */,
- int success) {
- server *sv = arg;
+static void listen_shutdown_cb(void* arg /*server */, int success) {
+ server* sv = static_cast<server*>(arg);
- grpc_fd_orphan(exec_ctx, sv->em_fd, NULL, NULL, false /* already_closed */,
- "b");
+ grpc_fd_orphan(sv->em_fd, nullptr, nullptr, false /* already_closed */, "b");
gpr_mu_lock(g_mu);
sv->done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
/* Called when a new TCP connection request arrives in the listening port. */
-static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/
- grpc_error *error) {
- server *sv = arg;
+static void listen_cb(void* arg, /*=sv_arg*/
+ grpc_error* error) {
+ server* sv = static_cast<server*>(arg);
int fd;
int flags;
- session *se;
+ session* se;
struct sockaddr_storage ss;
socklen_t slen = sizeof(ss);
- grpc_fd *listen_em_fd = sv->em_fd;
+ grpc_fd* listen_em_fd = sv->em_fd;
if (error != GRPC_ERROR_NONE) {
- listen_shutdown_cb(exec_ctx, arg, 1);
+ listen_shutdown_cb(arg, 1);
return;
}
- fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr *)&ss, &slen);
+ fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr*)&ss, &slen);
GPR_ASSERT(fd >= 0);
GPR_ASSERT(fd < FD_SETSIZE);
flags = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
- se = gpr_malloc(sizeof(*se));
+ se = static_cast<session*>(gpr_malloc(sizeof(*se)));
se->sv = sv;
se->em_fd = grpc_fd_create(fd, "listener");
- grpc_pollset_add_fd(exec_ctx, g_pollset, se->em_fd);
+ grpc_pollset_add_fd(g_pollset, se->em_fd);
GRPC_CLOSURE_INIT(&se->session_read_closure, session_read_cb, se,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
+ grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
- grpc_fd_notify_on_read(exec_ctx, listen_em_fd, &sv->listen_closure);
+ grpc_fd_notify_on_read(listen_em_fd, &sv->listen_closure);
}
/* Max number of connections pending to be accepted by listen(). */
@@ -222,7 +219,7 @@ static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/
listen_cb() is registered to be interested in reading from listen_fd.
When connection request arrives, listen_cb() is called to accept the
connection request. */
-static int server_start(grpc_exec_ctx *exec_ctx, server *sv) {
+static int server_start(server* sv) {
int port = 0;
int fd;
struct sockaddr_in sin;
@@ -230,34 +227,32 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) {
create_test_socket(port, &fd, &sin);
addr_len = sizeof(sin);
- GPR_ASSERT(bind(fd, (struct sockaddr *)&sin, addr_len) == 0);
- GPR_ASSERT(getsockname(fd, (struct sockaddr *)&sin, &addr_len) == 0);
+ GPR_ASSERT(bind(fd, (struct sockaddr*)&sin, addr_len) == 0);
+ GPR_ASSERT(getsockname(fd, (struct sockaddr*)&sin, &addr_len) == 0);
port = ntohs(sin.sin_port);
GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0);
sv->em_fd = grpc_fd_create(fd, "server");
- grpc_pollset_add_fd(exec_ctx, g_pollset, sv->em_fd);
+ grpc_pollset_add_fd(g_pollset, sv->em_fd);
/* Register to be interested in reading from listen_fd. */
GRPC_CLOSURE_INIT(&sv->listen_closure, listen_cb, sv,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sv->em_fd, &sv->listen_closure);
+ grpc_fd_notify_on_read(sv->em_fd, &sv->listen_closure);
return port;
}
/* Wait and shutdown a sever. */
-static void server_wait_and_shutdown(server *sv) {
+static void server_wait_and_shutdown(server* sv) {
gpr_mu_lock(g_mu);
while (!sv->done) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_worker *worker = NULL;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -272,7 +267,7 @@ static void server_wait_and_shutdown(server *sv) {
/* An upload client. */
typedef struct {
- grpc_fd *em_fd;
+ grpc_fd* em_fd;
char write_buf[CLIENT_WRITE_BUF_SIZE];
ssize_t write_bytes_total;
/* Number of times that the client fills up the write buffer and calls
@@ -283,7 +278,7 @@ typedef struct {
grpc_closure write_closure;
} client;
-static void client_init(client *cl) {
+static void client_init(client* cl) {
memset(cl->write_buf, 0, sizeof(cl->write_buf));
cl->write_bytes_total = 0;
cl->client_write_cnt = 0;
@@ -291,26 +286,24 @@ static void client_init(client *cl) {
}
/* Called when a client upload session is ready to shutdown. */
-static void client_session_shutdown_cb(grpc_exec_ctx *exec_ctx,
- void *arg /*client */, int success) {
- client *cl = arg;
- grpc_fd_orphan(exec_ctx, cl->em_fd, NULL, NULL, false /* already_closed */,
- "c");
+static void client_session_shutdown_cb(void* arg /*client */, int success) {
+ client* cl = static_cast<client*>(arg);
+ grpc_fd_orphan(cl->em_fd, nullptr, nullptr, false /* already_closed */, "c");
cl->done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
}
/* Write as much as possible, then register notify_on_write. */
-static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
- grpc_error *error) {
- client *cl = arg;
+static void client_session_write(void* arg, /*client */
+ grpc_error* error) {
+ client* cl = static_cast<client*>(arg);
int fd = grpc_fd_wrapped_fd(cl->em_fd);
ssize_t write_once = 0;
if (error != GRPC_ERROR_NONE) {
gpr_mu_lock(g_mu);
- client_session_shutdown_cb(exec_ctx, arg, 1);
+ client_session_shutdown_cb(arg, 1);
gpr_mu_unlock(g_mu);
return;
}
@@ -325,10 +318,10 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) {
GRPC_CLOSURE_INIT(&cl->write_closure, client_session_write, cl,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, cl->em_fd, &cl->write_closure);
+ grpc_fd_notify_on_write(cl->em_fd, &cl->write_closure);
cl->client_write_cnt++;
} else {
- client_session_shutdown_cb(exec_ctx, arg, 1);
+ client_session_shutdown_cb(arg, 1);
}
gpr_mu_unlock(g_mu);
} else {
@@ -338,11 +331,11 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
}
/* Start a client to send a stream of bytes. */
-static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) {
+static void client_start(client* cl, int port) {
int fd;
struct sockaddr_in sin;
create_test_socket(port, &fd, &sin);
- if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
+ if (connect(fd, (struct sockaddr*)&sin, sizeof(sin)) == -1) {
if (errno == EINPROGRESS) {
struct pollfd pfd;
pfd.fd = fd;
@@ -359,24 +352,22 @@ static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) {
}
cl->em_fd = grpc_fd_create(fd, "client");
- grpc_pollset_add_fd(exec_ctx, g_pollset, cl->em_fd);
+ grpc_pollset_add_fd(g_pollset, cl->em_fd);
- client_session_write(exec_ctx, cl, GRPC_ERROR_NONE);
+ client_session_write(cl, GRPC_ERROR_NONE);
}
/* Wait for the signal to shutdown a client. */
-static void client_wait_and_shutdown(client *cl) {
+static void client_wait_and_shutdown(client* cl) {
gpr_mu_lock(g_mu);
while (!cl->done) {
- grpc_pollset_worker *worker = NULL;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_worker* worker = nullptr;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -389,13 +380,13 @@ static void test_grpc_fd(void) {
server sv;
client cl;
int port;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
server_init(&sv);
- port = server_start(&exec_ctx, &sv);
+ port = server_start(&sv);
client_init(&cl);
- client_start(&exec_ctx, &cl, port);
- grpc_exec_ctx_finish(&exec_ctx);
+ client_start(&cl, port);
+
client_wait_and_shutdown(&cl);
server_wait_and_shutdown(&sv);
GPR_ASSERT(sv.read_bytes_total == cl.write_bytes_total);
@@ -406,31 +397,29 @@ typedef struct fd_change_data {
grpc_iomgr_cb_func cb_that_ran;
} fd_change_data;
-void init_change_data(fd_change_data *fdc) { fdc->cb_that_ran = NULL; }
+void init_change_data(fd_change_data* fdc) { fdc->cb_that_ran = nullptr; }
-void destroy_change_data(fd_change_data *fdc) {}
+void destroy_change_data(fd_change_data* fdc) {}
-static void first_read_callback(grpc_exec_ctx *exec_ctx,
- void *arg /* fd_change_data */,
- grpc_error *error) {
- fd_change_data *fdc = arg;
+static void first_read_callback(void* arg /* fd_change_data */,
+ grpc_error* error) {
+ fd_change_data* fdc = static_cast<fd_change_data*>(arg);
gpr_mu_lock(g_mu);
fdc->cb_that_ran = first_read_callback;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void second_read_callback(grpc_exec_ctx *exec_ctx,
- void *arg /* fd_change_data */,
- grpc_error *error) {
- fd_change_data *fdc = arg;
+static void second_read_callback(void* arg /* fd_change_data */,
+ grpc_error* error) {
+ fd_change_data* fdc = static_cast<fd_change_data*>(arg);
gpr_mu_lock(g_mu);
fdc->cb_that_ran = second_read_callback;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -439,7 +428,7 @@ static void second_read_callback(grpc_exec_ctx *exec_ctx,
point is to have two different function pointers and two different data
pointers and make sure that changing both really works. */
static void test_grpc_fd_change(void) {
- grpc_fd *em_fd;
+ grpc_fd* em_fd;
fd_change_data a, b;
int flags;
int sv[2];
@@ -447,7 +436,7 @@ static void test_grpc_fd_change(void) {
ssize_t result;
grpc_closure first_closure;
grpc_closure second_closure;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GRPC_CLOSURE_INIT(&first_closure, first_read_callback, &a,
grpc_schedule_on_exec_ctx);
@@ -464,25 +453,23 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change");
- grpc_pollset_add_fd(&exec_ctx, g_pollset, em_fd);
+ grpc_pollset_add_fd(g_pollset, em_fd);
/* Register the first callback, then make its FD readable */
- grpc_fd_notify_on_read(&exec_ctx, em_fd, &first_closure);
+ grpc_fd_notify_on_read(em_fd, &first_closure);
data = 0;
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
/* And now wait for it to run. */
gpr_mu_lock(g_mu);
- while (a.cb_that_ran == NULL) {
- grpc_pollset_worker *worker = NULL;
+ while (a.cb_that_ran == nullptr) {
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(a.cb_that_ran == first_read_callback);
@@ -494,60 +481,58 @@ static void test_grpc_fd_change(void) {
/* Now register a second callback with distinct change data, and do the same
thing again. */
- grpc_fd_notify_on_read(&exec_ctx, em_fd, &second_closure);
+ grpc_fd_notify_on_read(em_fd, &second_closure);
data = 0;
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
gpr_mu_lock(g_mu);
- while (b.cb_that_ran == NULL) {
- grpc_pollset_worker *worker = NULL;
+ while (b.cb_that_ran == nullptr) {
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
/* Except now we verify that second_read_callback ran instead */
GPR_ASSERT(b.cb_that_ran == second_read_callback);
gpr_mu_unlock(g_mu);
- grpc_fd_orphan(&exec_ctx, em_fd, NULL, NULL, false /* already_closed */, "d");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fd_orphan(em_fd, nullptr, nullptr, false /* already_closed */, "d");
+
destroy_change_data(&a);
destroy_change_data(&b);
close(sv[1]);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
- test_grpc_fd();
- test_grpc_fd_change();
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_flush(&exec_ctx);
- gpr_free(g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(g_pollset, &g_mu);
+ test_grpc_fd();
+ test_grpc_fd_change();
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+ grpc_core::ExecCtx::Get()->Flush();
+ gpr_free(g_pollset);
+ }
grpc_shutdown();
return 0;
}
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.cc
index 537c3430b1..38c8710535 100644
--- a/test/core/iomgr/load_file_test.c
+++ b/test/core/iomgr/load_file_test.cc
@@ -19,13 +19,14 @@
#include <stdio.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/iomgr/load_file.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
@@ -33,17 +34,17 @@
static const char prefix[] = "file_test";
static void test_load_empty_file(void) {
- FILE *tmp = NULL;
+ FILE* tmp = nullptr;
grpc_slice slice;
grpc_slice slice_with_null_term;
- grpc_error *error;
- char *tmp_name;
+ grpc_error* error;
+ char* tmp_name;
LOG_TEST_NAME("test_load_empty_file");
tmp = gpr_tmpfile(prefix, &tmp_name);
- GPR_ASSERT(tmp_name != NULL);
- GPR_ASSERT(tmp != NULL);
+ GPR_ASSERT(tmp_name != nullptr);
+ GPR_ASSERT(tmp != nullptr);
fclose(tmp);
error = grpc_load_file(tmp_name, 0, &slice);
@@ -62,16 +63,16 @@ static void test_load_empty_file(void) {
}
static void test_load_failure(void) {
- FILE *tmp = NULL;
+ FILE* tmp = nullptr;
grpc_slice slice;
- grpc_error *error;
- char *tmp_name;
+ grpc_error* error;
+ char* tmp_name;
LOG_TEST_NAME("test_load_failure");
tmp = gpr_tmpfile(prefix, &tmp_name);
- GPR_ASSERT(tmp_name != NULL);
- GPR_ASSERT(tmp != NULL);
+ GPR_ASSERT(tmp_name != nullptr);
+ GPR_ASSERT(tmp != nullptr);
fclose(tmp);
remove(tmp_name);
@@ -84,18 +85,18 @@ static void test_load_failure(void) {
}
static void test_load_small_file(void) {
- FILE *tmp = NULL;
+ FILE* tmp = nullptr;
grpc_slice slice;
grpc_slice slice_with_null_term;
- grpc_error *error;
- char *tmp_name;
- const char *blah = "blah";
+ grpc_error* error;
+ char* tmp_name;
+ const char* blah = "blah";
LOG_TEST_NAME("test_load_small_file");
tmp = gpr_tmpfile(prefix, &tmp_name);
- GPR_ASSERT(tmp_name != NULL);
- GPR_ASSERT(tmp != NULL);
+ GPR_ASSERT(tmp_name != nullptr);
+ GPR_ASSERT(tmp != nullptr);
GPR_ASSERT(fwrite(blah, 1, strlen(blah), tmp) == strlen(blah));
fclose(tmp);
@@ -107,7 +108,7 @@ static void test_load_small_file(void) {
error = grpc_load_file(tmp_name, 1, &slice_with_null_term);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1));
- GPR_ASSERT(strcmp((const char *)GRPC_SLICE_START_PTR(slice_with_null_term),
+ GPR_ASSERT(strcmp((const char*)GRPC_SLICE_START_PTR(slice_with_null_term),
blah) == 0);
remove(tmp_name);
@@ -117,13 +118,13 @@ static void test_load_small_file(void) {
}
static void test_load_big_file(void) {
- FILE *tmp = NULL;
+ FILE* tmp = nullptr;
grpc_slice slice;
- grpc_error *error;
- char *tmp_name;
+ grpc_error* error;
+ char* tmp_name;
static const size_t buffer_size = 124631;
- unsigned char *buffer = gpr_malloc(buffer_size);
- unsigned char *current;
+ unsigned char* buffer = static_cast<unsigned char*>(gpr_malloc(buffer_size));
+ unsigned char* current;
size_t i;
LOG_TEST_NAME("test_load_big_file");
@@ -131,8 +132,8 @@ static void test_load_big_file(void) {
memset(buffer, 42, buffer_size);
tmp = gpr_tmpfile(prefix, &tmp_name);
- GPR_ASSERT(tmp != NULL);
- GPR_ASSERT(tmp_name != NULL);
+ GPR_ASSERT(tmp != nullptr);
+ GPR_ASSERT(tmp_name != nullptr);
GPR_ASSERT(fwrite(buffer, 1, buffer_size, tmp) == buffer_size);
fclose(tmp);
@@ -150,11 +151,13 @@ static void test_load_big_file(void) {
gpr_free(buffer);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_load_empty_file();
test_load_failure();
test_load_small_file();
test_load_big_file();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.cc
index 70efca8b16..7d2f59bed4 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -18,7 +18,7 @@
#include "src/core/lib/iomgr/port.h"
/* This test only relevant on linux systems where epoll is available */
-#ifdef GRPC_LINUX_EPOLL
+#ifdef GRPC_LINUX_EPOLL_CREATE1
#include <errno.h>
#include <string.h>
@@ -37,20 +37,21 @@
* test_pollset_set
*/
-typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set;
+typedef struct test_pollset_set {
+ grpc_pollset_set* pss;
+} test_pollset_set;
-void init_test_pollset_sets(test_pollset_set *pollset_sets, const int num_pss) {
+void init_test_pollset_sets(test_pollset_set* pollset_sets, const int num_pss) {
for (int i = 0; i < num_pss; i++) {
pollset_sets[i].pss = grpc_pollset_set_create();
}
}
-void cleanup_test_pollset_sets(grpc_exec_ctx *exec_ctx,
- test_pollset_set *pollset_sets,
+void cleanup_test_pollset_sets(test_pollset_set* pollset_sets,
const int num_pss) {
for (int i = 0; i < num_pss; i++) {
- grpc_pollset_set_destroy(exec_ctx, pollset_sets[i].pss);
- pollset_sets[i].pss = NULL;
+ grpc_pollset_set_destroy(pollset_sets[i].pss);
+ pollset_sets[i].pss = nullptr;
}
}
@@ -59,34 +60,33 @@ void cleanup_test_pollset_sets(grpc_exec_ctx *exec_ctx,
*/
typedef struct test_pollset {
- grpc_pollset *ps;
- gpr_mu *mu;
+ grpc_pollset* ps;
+ gpr_mu* mu;
} test_pollset;
-static void init_test_pollsets(test_pollset *pollsets, const int num_pollsets) {
+static void init_test_pollsets(test_pollset* pollsets, const int num_pollsets) {
for (int i = 0; i < num_pollsets; i++) {
- pollsets[i].ps = gpr_zalloc(grpc_pollset_size());
+ pollsets[i].ps =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu);
}
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
- test_pollset *pollsets,
+static void cleanup_test_pollsets(test_pollset* pollsets,
const int num_pollsets) {
grpc_closure destroyed;
for (int i = 0; i < num_pollsets; i++) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed);
+ grpc_pollset_shutdown(pollsets[i].ps, &destroyed);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(pollsets[i].ps);
- pollsets[i].ps = NULL;
+ pollsets[i].ps = nullptr;
}
}
@@ -95,65 +95,62 @@ static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
*/
typedef struct test_fd {
- grpc_fd *fd;
+ grpc_fd* fd;
grpc_wakeup_fd wakeup_fd;
bool is_on_readable_called; /* Is on_readable closure is called ? */
grpc_closure on_readable; /* Closure to call when this fd is readable */
} test_fd;
-void on_readable(grpc_exec_ctx *exec_ctx, void *tfd, grpc_error *error) {
- ((test_fd *)tfd)->is_on_readable_called = true;
+void on_readable(void* tfd, grpc_error* error) {
+ ((test_fd*)tfd)->is_on_readable_called = true;
}
-static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) {
+static void reset_test_fd(test_fd* tfd) {
tfd->is_on_readable_called = false;
GRPC_CLOSURE_INIT(&tfd->on_readable, on_readable, tfd,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
+ grpc_fd_notify_on_read(tfd->fd, &tfd->on_readable);
}
-static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
- const int num_fds) {
+static void init_test_fds(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
"test_fd");
- reset_test_fd(exec_ctx, &tfds[i]);
+ reset_test_fd(&tfds[i]);
}
}
-static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
- const int num_fds) {
+static void cleanup_test_fds(test_fd* tfds, const int num_fds) {
int release_fd;
for (int i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd cleanup"));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
* calls close() on the underlying fd. In our case, we are using
* grpc_wakeup_fd and we would like to destroy it ourselves (by calling
* grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the
* underlying fd, call it with a non-NULL 'release_fd' parameter */
- grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd,
- false /* already_closed */, "test_fd_cleanup");
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
+ "test_fd_cleanup");
+ grpc_core::ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd);
}
}
-static void make_test_fds_readable(test_fd *tfds, const int num_fds) {
+static void make_test_fds_readable(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd));
}
}
-static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds,
- const int num_fds) {
+static void verify_readable_and_reset(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
/* Verify that the on_readable callback was called */
GPR_ASSERT(tfds[i].is_on_readable_called);
@@ -161,7 +158,7 @@ static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds,
/* Reset the tfd[i] structure */
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_wakeup_fd_consume_wakeup(&tfds[i].wakeup_fd));
- reset_test_fd(exec_ctx, &tfds[i]);
+ reset_test_fd(&tfds[i]);
}
}
@@ -202,9 +199,9 @@ static void pollset_set_test_basic() {
* |
* +---> FD9 (Added after PS2 is added to PSS0)
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_worker *worker;
- gpr_timespec deadline;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_worker* worker;
+ grpc_millis deadline;
test_fd tfds[10];
test_pollset pollsets[3];
@@ -213,34 +210,33 @@ static void pollset_set_test_basic() {
const int num_ps = GPR_ARRAY_SIZE(pollsets);
const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
init_test_pollset_sets(pollset_sets, num_pss);
/* Construct the pollset_set/pollset/fd tree (see diagram above) */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[2].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[3].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[4].fd);
+ grpc_pollset_add_fd(pollsets[0].ps, tfds[2].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[3].fd);
+ grpc_pollset_add_fd(pollsets[2].ps, tfds[4].fd);
- grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
+ grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[2].ps);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[6].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[7].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[8].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[9].fd);
+ grpc_pollset_add_fd(pollsets[0].ps, tfds[7].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[8].fd);
+ grpc_pollset_add_fd(pollsets[2].ps, tfds[9].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* Test that if any FD in the above structure is readable, it is observable by
* doing grpc_pollset_work on any pollset
@@ -257,37 +253,35 @@ static void pollset_set_test_basic() {
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollsets[i].mu);
- deadline = grpc_timeout_milliseconds_to_deadline(2);
+ deadline = grpc_timespec_to_millis_round_up(
+ grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ grpc_pollset_work(pollsets[i].ps, &worker, deadline));
gpr_mu_unlock(pollsets[i].mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* Test tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
- grpc_exec_ctx_flush(&exec_ctx);
-
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
-
- grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, pollset_sets, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[6].fd);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[2].ps);
+
+ grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(pollsets, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
}
/* Same FD added multiple times to the pollset_set tree */
@@ -307,9 +301,9 @@ void pollset_set_test_dup_fds() {
* | +--> FD2
* +---> FD1
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_worker *worker;
- gpr_timespec deadline;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_worker* worker;
+ grpc_millis deadline;
test_fd tfds[3];
test_pollset pollset;
@@ -318,51 +312,48 @@ void pollset_set_test_dup_fds() {
const int num_ps = 1;
const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(&pollset, num_ps);
init_test_pollset_sets(pollset_sets, num_pss);
/* Construct the structure */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[2].fd);
+ grpc_pollset_add_fd(pollset.ps, tfds[1].fd);
+ grpc_pollset_add_fd(pollset.ps, tfds[2].fd);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
+ grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
/* Test. Make all FDs readable and make sure that can be observed by doing a
* grpc_pollset_work on the pollset 'PS' */
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollset.mu);
- deadline = grpc_timeout_milliseconds_to_deadline(2);
+ deadline = grpc_timespec_to_millis_round_up(
+ grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollset.ps, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ grpc_pollset_work(pollset.ps, &worker, deadline));
gpr_mu_unlock(pollset.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
/* Tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
-
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, &pollset, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, pollset_sets, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
+
+ grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(&pollset, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
}
/* Pollset_set with an empty pollset */
@@ -380,9 +371,9 @@ void pollset_set_test_empty_pollset() {
* |
* +---> FD2
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_worker *worker;
- gpr_timespec deadline;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_worker* worker;
+ grpc_millis deadline;
test_fd tfds[3];
test_pollset pollsets[2];
@@ -391,68 +382,67 @@ void pollset_set_test_empty_pollset() {
const int num_ps = GPR_ARRAY_SIZE(pollsets);
const int num_pss = 1;
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
init_test_pollset_sets(&pollset_set, num_pss);
/* Construct the structure */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[2].fd);
+ grpc_pollset_set_add_fd(pollset_set.pss, tfds[0].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[1].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[2].fd);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[1].ps);
/* Test. Make all FDs readable and make sure that can be observed by doing
* grpc_pollset_work on the empty pollset 'PS0' */
make_test_fds_readable(tfds, num_fds);
gpr_mu_lock(pollsets[0].mu);
- deadline = grpc_timeout_milliseconds_to_deadline(2);
+ deadline = grpc_timespec_to_millis_round_up(
+ grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ grpc_pollset_work(pollsets[0].ps, &worker, deadline));
gpr_mu_unlock(pollsets[0].mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
/* Tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, &pollset_set, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_set.pss, tfds[0].fd);
+ grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[1].ps);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(pollsets, num_ps);
+ cleanup_test_pollset_sets(&pollset_set, num_pss);
}
-int main(int argc, char **argv) {
- const char *poll_strategy = grpc_get_poll_strategy_name();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
-
- if (poll_strategy != NULL &&
- (strcmp(poll_strategy, "epoll") == 0 ||
- strcmp(poll_strategy, "epoll-threadpool") == 0)) {
- pollset_set_test_basic();
- pollset_set_test_dup_fds();
- pollset_set_test_empty_pollset();
- } else {
- gpr_log(GPR_INFO,
- "Skipping the test. The test is only relevant for 'epoll' "
- "strategy. and the current strategy is: '%s'",
- poll_strategy);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ const char* poll_strategy = grpc_get_poll_strategy_name();
+
+ if (poll_strategy != nullptr &&
+ (strcmp(poll_strategy, "epollsig") == 0 ||
+ strcmp(poll_strategy, "epoll-threadpool") == 0)) {
+ pollset_set_test_basic();
+ pollset_set_test_dup_fds();
+ pollset_set_test_empty_pollset();
+ } else {
+ gpr_log(GPR_INFO,
+ "Skipping the test. The test is only relevant for 'epoll' "
+ "strategy. and the current strategy is: '%s'",
+ poll_strategy);
+ }
}
-
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
-#else /* defined(GRPC_LINUX_EPOLL) */
-int main(int argc, char **argv) { return 0; }
-#endif /* !defined(GRPC_LINUX_EPOLL) */
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
+int main(int argc, char** argv) { return 0; }
+#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c
deleted file mode 100644
index e4be99f03c..0000000000
--- a/test/core/iomgr/resolve_address_posix_test.c
+++ /dev/null
@@ -1,172 +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 "src/core/lib/iomgr/resolve_address.h"
-
-#include <string.h>
-#include <sys/un.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-#include <grpc/support/time.h>
-#include <grpc/support/useful.h>
-
-#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/iomgr/iomgr.h"
-#include "test/core/util/test_config.h"
-
-static gpr_timespec test_deadline(void) {
- return grpc_timeout_seconds_to_deadline(100);
-}
-
-typedef struct args_struct {
- gpr_event ev;
- grpc_resolved_addresses *addrs;
- gpr_atm done_atm;
- gpr_mu *mu;
- grpc_pollset *pollset;
- grpc_pollset_set *pollset_set;
-} args_struct;
-
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
-
-void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) {
- gpr_event_init(&args->ev);
- args->pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(args->pollset, &args->mu);
- args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
- args->addrs = NULL;
-}
-
-void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
- GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
- grpc_resolved_addresses_destroy(args->addrs);
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
- grpc_closure do_nothing_cb;
- GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, NULL,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
- // exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
- gpr_free(args->pollset);
-}
-
-static gpr_timespec n_sec_deadline(int seconds) {
- return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(seconds, GPR_TIMESPAN));
-}
-
-static void actually_poll(void *argsp) {
- args_struct *args = argsp;
- gpr_timespec deadline = n_sec_deadline(10);
- while (true) {
- bool done = gpr_atm_acq_load(&args->done_atm) != 0;
- if (done) {
- break;
- }
- gpr_timespec time_left =
- gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME));
- gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done,
- time_left.tv_sec, time_left.tv_nsec);
- GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0);
- grpc_pollset_worker *worker = NULL;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1)));
- gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
- }
- gpr_event_set(&args->ev, (void *)1);
-}
-
-static void poll_pollset_until_request_done(args_struct *args) {
- gpr_atm_rel_store(&args->done_atm, 0);
- gpr_thd_id id;
- gpr_thd_new(&id, actually_poll, args, NULL);
-}
-
-static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp,
- grpc_error *err) {
- args_struct *args = argsp;
- GPR_ASSERT(err == GRPC_ERROR_NONE);
- GPR_ASSERT(args->addrs != NULL);
- GPR_ASSERT(args->addrs->naddrs > 0);
- gpr_atm_rel_store(&args->done_atm, 1);
-}
-
-static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) {
- args_struct *args = argsp;
- GPR_ASSERT(err != GRPC_ERROR_NONE);
- gpr_atm_rel_store(&args->done_atm, 1);
-}
-
-static void test_unix_socket(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- poll_pollset_until_request_done(&args);
- grpc_resolve_address(
- &exec_ctx, "unix:/path/name", NULL, args.pollset_set,
- GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void test_unix_socket_path_name_too_long(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- const char prefix[] = "unix:/path/name";
- size_t path_name_length =
- GPR_ARRAY_SIZE(((struct sockaddr_un *)0)->sun_path) + 6;
- char *path_name = gpr_malloc(sizeof(char) * path_name_length);
- memset(path_name, 'a', path_name_length);
- memcpy(path_name, prefix, strlen(prefix) - 1);
- path_name[path_name_length - 1] = '\0';
-
- poll_pollset_until_request_done(&args);
- grpc_resolve_address(
- &exec_ctx, path_name, NULL, args.pollset_set,
- GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- gpr_free(path_name);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- test_unix_socket();
- test_unix_socket_path_name_too_long();
- grpc_executor_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_shutdown();
- return 0;
-}
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
new file mode 100644
index 0000000000..e36315333c
--- /dev/null
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -0,0 +1,168 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/resolve_address.h"
+
+#include <string.h>
+#include <sys/un.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/iomgr/iomgr.h"
+#include "test/core/util/test_config.h"
+
+static gpr_timespec test_deadline(void) {
+ return grpc_timeout_seconds_to_deadline(100);
+}
+
+typedef struct args_struct {
+ gpr_event ev;
+ grpc_resolved_addresses* addrs;
+ gpr_atm done_atm;
+ gpr_mu* mu;
+ grpc_pollset* pollset;
+ grpc_pollset_set* pollset_set;
+} args_struct;
+
+static void do_nothing(void* arg, grpc_error* error) {}
+
+void args_init(args_struct* args) {
+ gpr_event_init(&args->ev);
+ args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(args->pollset, &args->mu);
+ args->pollset_set = grpc_pollset_set_create();
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
+ args->addrs = nullptr;
+}
+
+void args_finish(args_struct* args) {
+ GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
+ grpc_resolved_addresses_destroy(args->addrs);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
+ grpc_closure do_nothing_cb;
+ GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
+ // exec_ctx needs to be flushed before calling grpc_pollset_destroy()
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
+ gpr_free(args->pollset);
+}
+
+static grpc_millis n_sec_deadline(int seconds) {
+ return grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(seconds));
+}
+
+static void actually_poll(void* argsp) {
+ args_struct* args = static_cast<args_struct*>(argsp);
+ grpc_millis deadline = n_sec_deadline(10);
+ while (true) {
+ grpc_core::ExecCtx exec_ctx;
+ bool done = gpr_atm_acq_load(&args->done_atm) != 0;
+ if (done) {
+ break;
+ }
+ grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
+ gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
+ GPR_ASSERT(time_left >= 0);
+ grpc_pollset_worker* worker = nullptr;
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker,
+ n_sec_deadline(1)));
+ gpr_mu_unlock(args->mu);
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+ gpr_event_set(&args->ev, (void*)1);
+}
+
+static void poll_pollset_until_request_done(args_struct* args) {
+ gpr_atm_rel_store(&args->done_atm, 0);
+ gpr_thd_id id;
+ gpr_thd_new(&id, "grpc_poll_pollset", actually_poll, args, nullptr);
+}
+
+static void must_succeed(void* argsp, grpc_error* err) {
+ args_struct* args = static_cast<args_struct*>(argsp);
+ GPR_ASSERT(err == GRPC_ERROR_NONE);
+ GPR_ASSERT(args->addrs != nullptr);
+ GPR_ASSERT(args->addrs->naddrs > 0);
+ gpr_atm_rel_store(&args->done_atm, 1);
+}
+
+static void must_fail(void* argsp, grpc_error* err) {
+ args_struct* args = static_cast<args_struct*>(argsp);
+ GPR_ASSERT(err != GRPC_ERROR_NONE);
+ gpr_atm_rel_store(&args->done_atm, 1);
+}
+
+static void test_unix_socket(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ poll_pollset_until_request_done(&args);
+ grpc_resolve_address(
+ "unix:/path/name", nullptr, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ args_finish(&args);
+}
+
+static void test_unix_socket_path_name_too_long(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ const char prefix[] = "unix:/path/name";
+ size_t path_name_length =
+ GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) + 6;
+ char* path_name =
+ static_cast<char*>(gpr_malloc(sizeof(char) * path_name_length));
+ memset(path_name, 'a', path_name_length);
+ memcpy(path_name, prefix, strlen(prefix) - 1);
+ path_name[path_name_length - 1] = '\0';
+
+ poll_pollset_until_request_done(&args);
+ grpc_resolve_address(
+ path_name, nullptr, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ gpr_free(path_name);
+ args_finish(&args);
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ {
+ grpc_core::ExecCtx exec_ctx;
+ test_unix_socket();
+ test_unix_socket_path_name_too_long();
+ }
+
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c
deleted file mode 100644
index 1110c04b6e..0000000000
--- a/test/core/iomgr/resolve_address_test.c
+++ /dev/null
@@ -1,270 +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/iomgr/resolve_address.h"
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/time.h>
-#include "src/core/lib/iomgr/executor.h"
-#include "src/core/lib/iomgr/iomgr.h"
-#include "test/core/util/test_config.h"
-
-static gpr_timespec test_deadline(void) {
- return grpc_timeout_seconds_to_deadline(100);
-}
-
-typedef struct args_struct {
- gpr_event ev;
- grpc_resolved_addresses *addrs;
- gpr_atm done_atm;
- gpr_mu *mu;
- grpc_pollset *pollset;
- grpc_pollset_set *pollset_set;
-} args_struct;
-
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
-
-void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) {
- gpr_event_init(&args->ev);
- args->pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(args->pollset, &args->mu);
- args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
- args->addrs = NULL;
- gpr_atm_rel_store(&args->done_atm, 0);
-}
-
-void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
- GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
- grpc_resolved_addresses_destroy(args->addrs);
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
- grpc_closure do_nothing_cb;
- GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, NULL,
- grpc_schedule_on_exec_ctx);
- gpr_mu_lock(args->mu);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
- gpr_mu_unlock(args->mu);
- // exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
- gpr_free(args->pollset);
-}
-
-static gpr_timespec n_sec_deadline(int seconds) {
- return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(seconds, GPR_TIMESPAN));
-}
-
-static void poll_pollset_until_request_done(args_struct *args) {
- gpr_timespec deadline = n_sec_deadline(10);
- while (true) {
- bool done = gpr_atm_acq_load(&args->done_atm) != 0;
- if (done) {
- break;
- }
- gpr_timespec time_left =
- gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME));
- gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done,
- time_left.tv_sec, time_left.tv_nsec);
- GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0);
- grpc_pollset_worker *worker = NULL;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1)));
- gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
- }
- gpr_event_set(&args->ev, (void *)1);
-}
-
-static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp,
- grpc_error *err) {
- args_struct *args = argsp;
- GPR_ASSERT(err == GRPC_ERROR_NONE);
- GPR_ASSERT(args->addrs != NULL);
- GPR_ASSERT(args->addrs->naddrs > 0);
- gpr_atm_rel_store(&args->done_atm, 1);
- gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, NULL));
- gpr_mu_unlock(args->mu);
-}
-
-static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) {
- args_struct *args = argsp;
- GPR_ASSERT(err != GRPC_ERROR_NONE);
- gpr_atm_rel_store(&args->done_atm, 1);
- gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, NULL));
- gpr_mu_unlock(args->mu);
-}
-
-static void test_localhost(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, "localhost:1", NULL, args.pollset_set,
- GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void test_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, "localhost", "1", args.pollset_set,
- GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void test_non_numeric_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, "localhost", "https", args.pollset_set,
- GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void test_missing_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, "localhost", NULL, args.pollset_set,
- GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void test_ipv6_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, "[2001:db8::1]:1", NULL, args.pollset_set,
- GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void test_ipv6_without_port(void) {
- const char *const kCases[] = {
- "2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]",
- };
- unsigned i;
- for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, kCases[i], "80", args.pollset_set,
- GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
- }
-}
-
-static void test_invalid_ip_addresses(void) {
- const char *const kCases[] = {
- "293.283.1238.3:1", "[2001:db8::11111]:1",
- };
- unsigned i;
- for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, kCases[i], NULL, args.pollset_set,
- GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
- }
-}
-
-static void test_unparseable_hostports(void) {
- const char *const kCases[] = {
- "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1",
- };
- unsigned i;
- for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- args_struct args;
- args_init(&exec_ctx, &args);
- grpc_resolve_address(
- &exec_ctx, kCases[i], "1", args.pollset_set,
- GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
- &args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
- poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- test_localhost();
- test_default_port();
- test_non_numeric_default_port();
- test_missing_default_port();
- test_ipv6_with_port();
- test_ipv6_without_port();
- test_invalid_ip_addresses();
- test_unparseable_hostports();
- grpc_executor_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_shutdown();
- return 0;
-}
diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc
new file mode 100644
index 0000000000..a0dc484f3e
--- /dev/null
+++ b/test/core/iomgr/resolve_address_test.cc
@@ -0,0 +1,260 @@
+/*
+ *
+ * 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/iomgr/resolve_address.h"
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/time.h>
+#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/iomgr/iomgr.h"
+#include "test/core/util/test_config.h"
+
+static gpr_timespec test_deadline(void) {
+ return grpc_timeout_seconds_to_deadline(100);
+}
+
+typedef struct args_struct {
+ gpr_event ev;
+ grpc_resolved_addresses* addrs;
+ gpr_atm done_atm;
+ gpr_mu* mu;
+ grpc_pollset* pollset;
+ grpc_pollset_set* pollset_set;
+} args_struct;
+
+static void do_nothing(void* arg, grpc_error* error) {}
+
+void args_init(args_struct* args) {
+ gpr_event_init(&args->ev);
+ args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(args->pollset, &args->mu);
+ args->pollset_set = grpc_pollset_set_create();
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
+ args->addrs = nullptr;
+ gpr_atm_rel_store(&args->done_atm, 0);
+}
+
+void args_finish(args_struct* args) {
+ GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
+ grpc_resolved_addresses_destroy(args->addrs);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
+ grpc_closure do_nothing_cb;
+ GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
+ grpc_schedule_on_exec_ctx);
+ gpr_mu_lock(args->mu);
+ grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
+ gpr_mu_unlock(args->mu);
+ // exec_ctx needs to be flushed before calling grpc_pollset_destroy()
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
+ gpr_free(args->pollset);
+}
+
+static grpc_millis n_sec_deadline(int seconds) {
+ return grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(seconds));
+}
+
+static void poll_pollset_until_request_done(args_struct* args) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_millis deadline = n_sec_deadline(10);
+ while (true) {
+ bool done = gpr_atm_acq_load(&args->done_atm) != 0;
+ if (done) {
+ break;
+ }
+ grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
+ gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
+ GPR_ASSERT(time_left >= 0);
+ grpc_pollset_worker* worker = nullptr;
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker,
+ n_sec_deadline(1)));
+ gpr_mu_unlock(args->mu);
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+ gpr_event_set(&args->ev, (void*)1);
+}
+
+static void must_succeed(void* argsp, grpc_error* err) {
+ args_struct* args = static_cast<args_struct*>(argsp);
+ GPR_ASSERT(err == GRPC_ERROR_NONE);
+ GPR_ASSERT(args->addrs != nullptr);
+ GPR_ASSERT(args->addrs->naddrs > 0);
+ gpr_atm_rel_store(&args->done_atm, 1);
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
+ gpr_mu_unlock(args->mu);
+}
+
+static void must_fail(void* argsp, grpc_error* err) {
+ args_struct* args = static_cast<args_struct*>(argsp);
+ GPR_ASSERT(err != GRPC_ERROR_NONE);
+ gpr_atm_rel_store(&args->done_atm, 1);
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
+ gpr_mu_unlock(args->mu);
+}
+
+static void test_localhost(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ "localhost:1", nullptr, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+}
+
+static void test_default_port(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ "localhost", "1", args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+}
+
+static void test_non_numeric_default_port(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ "localhost", "https", args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+}
+
+static void test_missing_default_port(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ "localhost", nullptr, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+}
+
+static void test_ipv6_with_port(void) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ "[2001:db8::1]:1", nullptr, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+}
+
+static void test_ipv6_without_port(void) {
+ const char* const kCases[] = {
+ "2001:db8::1",
+ "2001:db8::1.2.3.4",
+ "[2001:db8::1]",
+ };
+ unsigned i;
+ for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ kCases[i], "80", args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+ }
+}
+
+static void test_invalid_ip_addresses(void) {
+ const char* const kCases[] = {
+ "293.283.1238.3:1",
+ "[2001:db8::11111]:1",
+ };
+ unsigned i;
+ for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ kCases[i], nullptr, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+ }
+}
+
+static void test_unparseable_hostports(void) {
+ const char* const kCases[] = {
+ "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1",
+ };
+ unsigned i;
+ for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ grpc_resolve_address(
+ kCases[i], "1", args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ poll_pollset_until_request_done(&args);
+ args_finish(&args);
+ }
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+ test_localhost();
+ test_default_port();
+ test_non_numeric_default_port();
+ test_missing_default_port();
+ test_ipv6_with_port();
+ test_ipv6_without_port();
+ test_invalid_ip_addresses();
+ test_unparseable_hostports();
+ grpc_executor_shutdown();
+ }
+
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/iomgr/resource_quota_test.c b/test/core/iomgr/resource_quota_test.cc
index b588f3d120..07682d2630 100644
--- a/test/core/iomgr/resource_quota_test.c
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -27,14 +27,14 @@
gpr_mu g_mu;
gpr_cv g_cv;
-static void inc_int_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) {
+static void inc_int_cb(void* a, grpc_error* error) {
gpr_mu_lock(&g_mu);
- ++*(int *)a;
+ ++*(int*)a;
gpr_cv_signal(&g_cv);
gpr_mu_unlock(&g_mu);
}
-static void assert_counter_becomes(int *ctr, int value) {
+static void assert_counter_becomes(int* ctr, int value) {
gpr_mu_lock(&g_mu);
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
while (*ctr != value) {
@@ -43,50 +43,49 @@ static void assert_counter_becomes(int *ctr, int value) {
gpr_mu_unlock(&g_mu);
}
-static void set_event_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) {
- gpr_event_set((gpr_event *)a, (void *)1);
+static void set_event_cb(void* a, grpc_error* error) {
+ gpr_event_set((gpr_event*)a, (void*)1);
}
-grpc_closure *set_event(gpr_event *ev) {
+grpc_closure* set_event(gpr_event* ev) {
return GRPC_CLOSURE_CREATE(set_event_cb, ev, grpc_schedule_on_exec_ctx);
}
typedef struct {
size_t size;
- grpc_resource_user *resource_user;
- grpc_closure *then;
+ grpc_resource_user* resource_user;
+ grpc_closure* then;
} reclaimer_args;
-static void reclaimer_cb(grpc_exec_ctx *exec_ctx, void *args,
- grpc_error *error) {
+
+static void reclaimer_cb(void* args, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
- reclaimer_args *a = args;
- grpc_resource_user_free(exec_ctx, a->resource_user, a->size);
- grpc_resource_user_finish_reclamation(exec_ctx, a->resource_user);
- GRPC_CLOSURE_RUN(exec_ctx, a->then, GRPC_ERROR_NONE);
+ reclaimer_args* a = static_cast<reclaimer_args*>(args);
+ grpc_resource_user_free(a->resource_user, a->size);
+ grpc_resource_user_finish_reclamation(a->resource_user);
+ GRPC_CLOSURE_RUN(a->then, GRPC_ERROR_NONE);
gpr_free(a);
}
-grpc_closure *make_reclaimer(grpc_resource_user *resource_user, size_t size,
- grpc_closure *then) {
- reclaimer_args *a = gpr_malloc(sizeof(*a));
+
+grpc_closure* make_reclaimer(grpc_resource_user* resource_user, size_t size,
+ grpc_closure* then) {
+ reclaimer_args* a = static_cast<reclaimer_args*>(gpr_malloc(sizeof(*a)));
a->size = size;
a->resource_user = resource_user;
a->then = then;
return GRPC_CLOSURE_CREATE(reclaimer_cb, a, grpc_schedule_on_exec_ctx);
}
-static void unused_reclaimer_cb(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void unused_reclaimer_cb(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_RUN(exec_ctx, arg, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE);
}
-grpc_closure *make_unused_reclaimer(grpc_closure *then) {
+grpc_closure* make_unused_reclaimer(grpc_closure* then) {
return GRPC_CLOSURE_CREATE(unused_reclaimer_cb, then,
grpc_schedule_on_exec_ctx);
}
-static void destroy_user(grpc_resource_user *usr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+static void destroy_user(grpc_resource_user* usr) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_unref(usr);
}
static void test_no_op(void) {
@@ -96,7 +95,7 @@ static void test_no_op(void) {
static void test_resize_then_destroy(void) {
gpr_log(GPR_INFO, "** test_resize_then_destroy **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_resize_then_destroy");
grpc_resource_quota_resize(q, 1024 * 1024);
grpc_resource_quota_unref(q);
@@ -104,28 +103,26 @@ static void test_resize_then_destroy(void) {
static void test_resource_user_no_op(void) {
gpr_log(GPR_INFO, "** test_resource_user_no_op **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_resource_user_no_op");
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
grpc_resource_quota_unref(q);
destroy_user(usr);
}
static void test_instant_alloc_then_free(void) {
gpr_log(GPR_INFO, "** test_instant_alloc_then_free **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_instant_alloc_then_free");
grpc_resource_quota_resize(q, 1024 * 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -133,15 +130,14 @@ static void test_instant_alloc_then_free(void) {
static void test_instant_alloc_free_pair(void) {
gpr_log(GPR_INFO, "** test_instant_alloc_free_pair **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_instant_alloc_free_pair");
grpc_resource_quota_resize(q, 1024 * 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL);
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, nullptr);
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -149,23 +145,22 @@ static void test_instant_alloc_free_pair(void) {
static void test_simple_async_alloc(void) {
gpr_log(GPR_INFO, "** test_simple_async_alloc **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_simple_async_alloc");
grpc_resource_quota_resize(q, 1024 * 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -173,26 +168,26 @@ static void test_simple_async_alloc(void) {
static void test_async_alloc_blocked_by_size(void) {
gpr_log(GPR_INFO, "** test_async_alloc_blocked_by_size **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_async_alloc_blocked_by_size");
grpc_resource_quota_resize(q, 1);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
gpr_event ev;
gpr_event_init(&ev);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(
- &ev, grpc_timeout_milliseconds_to_deadline(100)) == NULL);
+ &ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr);
}
grpc_resource_quota_resize(q, 1024);
- GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) != NULL);
+ GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
+ nullptr);
;
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -200,39 +195,37 @@ static void test_async_alloc_blocked_by_size(void) {
static void test_scavenge(void) {
gpr_log(GPR_INFO, "** test_scavenge **");
- grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge");
+ grpc_resource_quota* q = grpc_resource_quota_create("test_scavenge");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1");
- grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2");
+ grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1");
+ grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2");
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr1, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr1, 1024);
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -241,40 +234,39 @@ static void test_scavenge(void) {
static void test_scavenge_blocked(void) {
gpr_log(GPR_INFO, "** test_scavenge_blocked **");
- grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge_blocked");
+ grpc_resource_quota* q = grpc_resource_quota_create("test_scavenge_blocked");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1");
- grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2");
+ grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1");
+ grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2");
gpr_event ev;
{
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(
- &ev, grpc_timeout_milliseconds_to_deadline(100)) == NULL);
+ &ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr1, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr1, 1024);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -283,45 +275,42 @@ static void test_scavenge_blocked(void) {
static void test_blocked_until_scheduled_reclaim(void) {
gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_blocked_until_scheduled_reclaim");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaim_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -329,46 +318,43 @@ static void test_blocked_until_scheduled_reclaim(void) {
static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim_and_scavenge **");
- grpc_resource_quota *q = grpc_resource_quota_create(
+ grpc_resource_quota* q = grpc_resource_quota_create(
"test_blocked_until_scheduled_reclaim_and_scavenge");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1");
- grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2");
+ grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1");
+ grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2");
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr1, false,
- make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr1, false, make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaim_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -377,45 +363,42 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
static void test_blocked_until_scheduled_destructive_reclaim(void) {
gpr_log(GPR_INFO, "** test_blocked_until_scheduled_destructive_reclaim **");
- grpc_resource_quota *q = grpc_resource_quota_create(
+ grpc_resource_quota* q = grpc_resource_quota_create(
"test_blocked_until_scheduled_destructive_reclaim");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaim_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -423,43 +406,42 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
static void test_unused_reclaim_is_cancelled(void) {
gpr_log(GPR_INFO, "** test_unused_reclaim_is_cancelled **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_unused_reclaim_is_cancelled");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
gpr_event benign_done;
gpr_event_init(&benign_done);
gpr_event destructive_done;
gpr_event_init(&destructive_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false, make_unused_reclaimer(set_event(&benign_done)));
+ usr, false, make_unused_reclaimer(set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_unused_reclaimer(set_event(&destructive_done)));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
GPR_ASSERT(gpr_event_wait(&benign_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
}
static void test_benign_reclaim_is_preferred(void) {
gpr_log(GPR_INFO, "** test_benign_reclaim_is_preferred **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_benign_reclaim_is_preferred");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
gpr_event benign_done;
gpr_event_init(&benign_done);
gpr_event destructive_done;
@@ -467,62 +449,59 @@ static void test_benign_reclaim_is_preferred(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&benign_done)));
+ usr, false, make_reclaimer(usr, 1024, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_unused_reclaimer(set_event(&destructive_done)));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&benign_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
GPR_ASSERT(gpr_event_wait(&benign_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
}
static void test_multiple_reclaims_can_be_triggered(void) {
gpr_log(GPR_INFO, "** test_multiple_reclaims_can_be_triggered **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_multiple_reclaims_can_be_triggered");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
gpr_event benign_done;
gpr_event_init(&benign_done);
gpr_event destructive_done;
@@ -530,78 +509,72 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 512, set_event(&benign_done)));
+ usr, false, make_reclaimer(usr, 512, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_reclaimer(usr, 512, set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_reclaimer(usr, 512, set_event(&destructive_done)));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&benign_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
GPR_ASSERT(gpr_event_wait(&benign_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
}
static void test_resource_user_stays_allocated_until_memory_released(void) {
gpr_log(GPR_INFO,
"** test_resource_user_stays_allocated_until_memory_released **");
- grpc_resource_quota *q = grpc_resource_quota_create(
+ grpc_resource_quota* q = grpc_resource_quota_create(
"test_resource_user_stays_allocated_until_memory_released");
grpc_resource_quota_resize(q, 1024 * 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_quota_unref(q);
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_resource_user_unref(usr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
}
@@ -612,50 +585,50 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
"** "
"test_resource_user_stays_allocated_and_reclaimers_unrun_until_"
"memory_released **");
- grpc_resource_quota *q = grpc_resource_quota_create(
+ grpc_resource_quota* q = grpc_resource_quota_create(
"test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_"
"released");
grpc_resource_quota_resize(q, 1024);
for (int i = 0; i < 10; i++) {
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
gpr_event reclaimer_cancelled;
gpr_event_init(&reclaimer_cancelled);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_unused_reclaimer(set_event(&reclaimer_cancelled)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_unused_reclaimer(set_event(&reclaimer_cancelled)));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(gpr_event_wait(&allocated,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
+ 5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_unref(usr);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) !=
+ nullptr);
}
}
grpc_resource_quota_unref(q);
@@ -663,48 +636,47 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
static void test_reclaimers_can_be_posted_repeatedly(void) {
gpr_log(GPR_INFO, "** test_reclaimers_can_be_posted_repeatedly **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_reclaimers_can_be_posted_repeatedly");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&allocated,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
}
for (int i = 0; i < 10; i++) {
gpr_event reclaimer_done;
gpr_event_init(&reclaimer_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(gpr_event_wait(&allocated,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
+ 5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) !=
+ nullptr);
}
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -713,10 +685,10 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
static void test_one_slice(void) {
gpr_log(GPR_INFO, "** test_one_slice **");
- grpc_resource_quota *q = grpc_resource_quota_create("test_one_slice");
+ grpc_resource_quota* q = grpc_resource_quota_create("test_one_slice");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
grpc_resource_user_slice_allocator alloc;
int num_allocs = 0;
@@ -727,16 +699,15 @@ static void test_one_slice(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+ grpc_core::ExecCtx::Get()->Flush();
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -745,11 +716,11 @@ static void test_one_slice(void) {
static void test_one_slice_deleted_late(void) {
gpr_log(GPR_INFO, "** test_one_slice_deleted_late **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_one_slice_deleted_late");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
grpc_resource_user_slice_allocator alloc;
int num_allocs = 0;
@@ -760,40 +731,38 @@ static void test_one_slice_deleted_late(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+ grpc_core::ExecCtx::Get()->Flush();
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_unref(usr);
}
grpc_resource_quota_unref(q);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
}
static void test_resize_to_zero(void) {
gpr_log(GPR_INFO, "** test_resize_to_zero **");
- grpc_resource_quota *q = grpc_resource_quota_create("test_resize_to_zero");
+ grpc_resource_quota* q = grpc_resource_quota_create("test_resize_to_zero");
grpc_resource_quota_resize(q, 0);
grpc_resource_quota_unref(q);
}
static void test_negative_rq_free_pool(void) {
gpr_log(GPR_INFO, "** test_negative_rq_free_pool **");
- grpc_resource_quota *q =
+ grpc_resource_quota* q =
grpc_resource_quota_create("test_negative_rq_free_pool");
grpc_resource_quota_resize(q, 1024);
- grpc_resource_user *usr = grpc_resource_user_create(q, "usr");
+ grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
grpc_resource_user_slice_allocator alloc;
int num_allocs = 0;
@@ -804,9 +773,9 @@ static void test_negative_rq_free_pool(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+ grpc_core::ExecCtx::Get()->Flush();
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
@@ -817,20 +786,18 @@ static void test_negative_rq_free_pool(void) {
GPR_ASSERT(grpc_resource_quota_get_memory_pressure(q) > 1 - eps);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resource_user_unref(usr);
}
grpc_resource_quota_unref(q);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
gpr_mu_init(&g_mu);
diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.cc
index e4a4ddaa99..a445714851 100644
--- a/test/core/iomgr/sockaddr_utils_test.c
+++ b/test/core/iomgr/sockaddr_utils_test.cc
@@ -20,8 +20,8 @@
using that endpoint. Because of various transitive includes in uv.h,
including windows.h on Windows, uv.h must be included before other system
headers. Therefore, sockaddr.h must always be included first */
-#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/sockaddr.h"
#include <errno.h>
#include <string.h>
@@ -31,9 +31,9 @@
#include <grpc/support/port_platform.h>
#include "test/core/util/test_config.h"
-static grpc_resolved_address make_addr4(const uint8_t *data, size_t data_len) {
+static grpc_resolved_address make_addr4(const uint8_t* data, size_t data_len) {
grpc_resolved_address resolved_addr4;
- struct sockaddr_in *addr4 = (struct sockaddr_in *)resolved_addr4.addr;
+ struct sockaddr_in* addr4 = (struct sockaddr_in*)resolved_addr4.addr;
memset(&resolved_addr4, 0, sizeof(resolved_addr4));
addr4->sin_family = AF_INET;
GPR_ASSERT(data_len == sizeof(addr4->sin_addr.s_addr));
@@ -43,9 +43,9 @@ static grpc_resolved_address make_addr4(const uint8_t *data, size_t data_len) {
return resolved_addr4;
}
-static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) {
+static grpc_resolved_address make_addr6(const uint8_t* data, size_t data_len) {
grpc_resolved_address resolved_addr6;
- struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)resolved_addr6.addr;
+ struct sockaddr_in6* addr6 = (struct sockaddr_in6*)resolved_addr6.addr;
memset(&resolved_addr6, 0, sizeof(resolved_addr6));
addr6->sin6_family = AF_INET6;
GPR_ASSERT(data_len == sizeof(addr6->sin6_addr.s6_addr));
@@ -55,8 +55,8 @@ static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) {
return resolved_addr6;
}
-static void set_addr6_scope_id(grpc_resolved_address *addr, uint32_t scope_id) {
- struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr->addr;
+static void set_addr6_scope_id(grpc_resolved_address* addr, uint32_t scope_id) {
+ struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr->addr;
GPR_ASSERT(addr6->sin6_family == AF_INET6);
addr6->sin6_scope_id = scope_id;
}
@@ -81,21 +81,21 @@ static void test_sockaddr_is_v4mapped(void) {
/* v4mapped input should succeed. */
input6 = make_addr6(kMapped, sizeof(kMapped));
- GPR_ASSERT(grpc_sockaddr_is_v4mapped(&input6, NULL));
+ GPR_ASSERT(grpc_sockaddr_is_v4mapped(&input6, nullptr));
GPR_ASSERT(grpc_sockaddr_is_v4mapped(&input6, &output4));
expect4 = make_addr4(kIPv4, sizeof(kIPv4));
GPR_ASSERT(memcmp(&expect4, &output4, sizeof(expect4)) == 0);
/* Non-v4mapped input should fail. */
input6 = make_addr6(kNotQuiteMapped, sizeof(kNotQuiteMapped));
- GPR_ASSERT(!grpc_sockaddr_is_v4mapped(&input6, NULL));
+ GPR_ASSERT(!grpc_sockaddr_is_v4mapped(&input6, nullptr));
GPR_ASSERT(!grpc_sockaddr_is_v4mapped(&input6, &output4));
/* Output is unchanged. */
GPR_ASSERT(memcmp(&expect4, &output4, sizeof(expect4)) == 0);
/* Plain IPv4 input should also fail. */
input4 = make_addr4(kIPv4, sizeof(kIPv4));
- GPR_ASSERT(!grpc_sockaddr_is_v4mapped(&input4, NULL));
+ GPR_ASSERT(!grpc_sockaddr_is_v4mapped(&input4, nullptr));
}
static void test_sockaddr_to_v4mapped(void) {
@@ -128,9 +128,9 @@ static void test_sockaddr_is_wildcard(void) {
grpc_resolved_address wild6;
grpc_resolved_address wild_mapped;
grpc_resolved_address dummy;
- struct sockaddr_in *wild4_addr;
- struct sockaddr_in6 *wild6_addr;
- struct sockaddr_in6 *wild_mapped_addr;
+ struct sockaddr_in* wild4_addr;
+ struct sockaddr_in6* wild6_addr;
+ struct sockaddr_in6* wild_mapped_addr;
int port;
gpr_log(GPR_INFO, "%s", "test_sockaddr_is_wildcard");
@@ -143,7 +143,7 @@ static void test_sockaddr_is_wildcard(void) {
port = -1;
GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild4, &port));
GPR_ASSERT(port == 555);
- wild4_addr = (struct sockaddr_in *)&wild4.addr;
+ wild4_addr = (struct sockaddr_in*)&wild4.addr;
memset(&wild4_addr->sin_addr.s_addr, 0xbd, 1);
GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild4, &port));
@@ -151,7 +151,7 @@ static void test_sockaddr_is_wildcard(void) {
port = -1;
GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild6, &port));
GPR_ASSERT(port == 555);
- wild6_addr = (struct sockaddr_in6 *)&wild6.addr;
+ wild6_addr = (struct sockaddr_in6*)&wild6.addr;
memset(&wild6_addr->sin6_addr.s6_addr, 0xbd, 1);
GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild6, &port));
@@ -159,7 +159,7 @@ static void test_sockaddr_is_wildcard(void) {
port = -1;
GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild_mapped, &port));
GPR_ASSERT(port == 555);
- wild_mapped_addr = (struct sockaddr_in6 *)&wild_mapped.addr;
+ wild_mapped_addr = (struct sockaddr_in6*)&wild_mapped.addr;
memset(&wild_mapped_addr->sin6_addr.s6_addr, 0xbd, 1);
GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild_mapped, &port));
@@ -170,25 +170,25 @@ static void test_sockaddr_is_wildcard(void) {
GPR_ASSERT(port == -1);
}
-static void expect_sockaddr_str(const char *expected,
- grpc_resolved_address *addr, int normalize) {
+static void expect_sockaddr_str(const char* expected,
+ grpc_resolved_address* addr, int normalize) {
int result;
- char *str;
+ char* str;
gpr_log(GPR_INFO, " expect_sockaddr_str(%s)", expected);
result = grpc_sockaddr_to_string(&str, addr, normalize);
- GPR_ASSERT(str != NULL);
+ GPR_ASSERT(str != nullptr);
GPR_ASSERT(result >= 0);
GPR_ASSERT((size_t)result == strlen(str));
GPR_ASSERT(strcmp(expected, str) == 0);
gpr_free(str);
}
-static void expect_sockaddr_uri(const char *expected,
- grpc_resolved_address *addr) {
- char *str;
+static void expect_sockaddr_uri(const char* expected,
+ grpc_resolved_address* addr) {
+ char* str;
gpr_log(GPR_INFO, " expect_sockaddr_uri(%s)", expected);
str = grpc_sockaddr_to_uri(addr);
- GPR_ASSERT(str != NULL);
+ GPR_ASSERT(str != nullptr);
GPR_ASSERT(strcmp(expected, str) == 0);
gpr_free(str);
}
@@ -197,7 +197,7 @@ static void test_sockaddr_to_string(void) {
grpc_resolved_address input4;
grpc_resolved_address input6;
grpc_resolved_address dummy;
- struct sockaddr *dummy_addr;
+ struct sockaddr* dummy_addr;
gpr_log(GPR_INFO, "%s", "test_sockaddr_to_string");
@@ -234,18 +234,18 @@ static void test_sockaddr_to_string(void) {
expect_sockaddr_uri("ipv6:[::fffe:c000:263]:12345", &input6);
memset(&dummy, 0, sizeof(dummy));
- dummy_addr = (struct sockaddr *)dummy.addr;
+ dummy_addr = (struct sockaddr*)dummy.addr;
dummy_addr->sa_family = 123;
expect_sockaddr_str("(sockaddr family=123)", &dummy, 0);
expect_sockaddr_str("(sockaddr family=123)", &dummy, 1);
- GPR_ASSERT(grpc_sockaddr_to_uri(&dummy) == NULL);
+ GPR_ASSERT(grpc_sockaddr_to_uri(&dummy) == nullptr);
}
static void test_sockaddr_set_get_port(void) {
grpc_resolved_address input4;
grpc_resolved_address input6;
grpc_resolved_address dummy;
- struct sockaddr *dummy_addr;
+ struct sockaddr* dummy_addr;
gpr_log(GPR_DEBUG, "test_sockaddr_set_get_port");
@@ -260,13 +260,13 @@ static void test_sockaddr_set_get_port(void) {
GPR_ASSERT(grpc_sockaddr_get_port(&input6) == 54321);
memset(&dummy, 0, sizeof(dummy));
- dummy_addr = (struct sockaddr *)dummy.addr;
+ dummy_addr = (struct sockaddr*)dummy.addr;
dummy_addr->sa_family = 123;
GPR_ASSERT(grpc_sockaddr_get_port(&dummy) == 0);
GPR_ASSERT(grpc_sockaddr_set_port(&dummy, 1234) == 0);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_sockaddr_is_v4mapped();
diff --git a/test/core/iomgr/socket_utils_test.c b/test/core/iomgr/socket_utils_test.cc
index 30f0c943dc..49c6f799e7 100644
--- a/test/core/iomgr/socket_utils_test.c
+++ b/test/core/iomgr/socket_utils_test.cc
@@ -39,10 +39,10 @@ struct test_socket_mutator {
int option_value;
};
-static bool mutate_fd(int fd, grpc_socket_mutator *mutator) {
+static bool mutate_fd(int fd, grpc_socket_mutator* mutator) {
int newval;
socklen_t intlen = sizeof(newval);
- struct test_socket_mutator *m = (struct test_socket_mutator *)mutator;
+ struct test_socket_mutator* m = (struct test_socket_mutator*)mutator;
if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &m->option_value,
sizeof(m->option_value))) {
@@ -57,24 +57,24 @@ static bool mutate_fd(int fd, grpc_socket_mutator *mutator) {
return true;
}
-static void destroy_test_mutator(grpc_socket_mutator *mutator) {
- struct test_socket_mutator *m = (struct test_socket_mutator *)mutator;
+static void destroy_test_mutator(grpc_socket_mutator* mutator) {
+ struct test_socket_mutator* m = (struct test_socket_mutator*)mutator;
gpr_free(m);
}
-static int compare_test_mutator(grpc_socket_mutator *a,
- grpc_socket_mutator *b) {
- struct test_socket_mutator *ma = (struct test_socket_mutator *)a;
- struct test_socket_mutator *mb = (struct test_socket_mutator *)b;
+static int compare_test_mutator(grpc_socket_mutator* a,
+ grpc_socket_mutator* b) {
+ struct test_socket_mutator* ma = (struct test_socket_mutator*)a;
+ struct test_socket_mutator* mb = (struct test_socket_mutator*)b;
return GPR_ICMP(ma->option_value, mb->option_value);
}
static const grpc_socket_mutator_vtable mutator_vtable = {
mutate_fd, compare_test_mutator, destroy_test_mutator};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int sock;
- grpc_error *err;
+ grpc_error* err;
grpc_test_init(argc, argv);
sock = socket(PF_INET, SOCK_STREAM, 0);
@@ -103,20 +103,20 @@ int main(int argc, char **argv) {
mutator.option_value = IPTOS_LOWDELAY;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"set_socket_with_mutator",
- grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator)));
+ grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator)));
mutator.option_value = IPTOS_THROUGHPUT;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"set_socket_with_mutator",
- grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator)));
+ grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator)));
mutator.option_value = IPTOS_RELIABILITY;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"set_socket_with_mutator",
- grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator)));
+ grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator)));
mutator.option_value = -1;
- err = grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator);
+ err = grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator);
GPR_ASSERT(err != GRPC_ERROR_NONE);
GRPC_ERROR_UNREF(err);
@@ -127,6 +127,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.cc
index 1032da942b..40a050ed9f 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -40,52 +40,50 @@
#include "src/core/lib/iomgr/timer.h"
#include "test/core/util/test_config.h"
-static grpc_pollset_set *g_pollset_set;
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static grpc_pollset_set* g_pollset_set;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static int g_connections_complete = 0;
-static grpc_endpoint *g_connecting = NULL;
+static grpc_endpoint* g_connecting = nullptr;
-static gpr_timespec test_deadline(void) {
- return grpc_timeout_seconds_to_deadline(10);
+static grpc_millis test_deadline(void) {
+ return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
}
static void finish_connection() {
gpr_mu_lock(g_mu);
g_connections_complete++;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(&exec_ctx, g_pollset, NULL)));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
+
gpr_mu_unlock(g_mu);
}
-static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- GPR_ASSERT(g_connecting != NULL);
+static void must_succeed(void* arg, grpc_error* error) {
+ GPR_ASSERT(g_connecting != nullptr);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(
- exec_ctx, g_connecting,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
- grpc_endpoint_destroy(exec_ctx, g_connecting);
- g_connecting = NULL;
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
+ g_connecting = nullptr;
finish_connection();
}
-static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- GPR_ASSERT(g_connecting == NULL);
+static void must_fail(void* arg, grpc_error* error) {
+ GPR_ASSERT(g_connecting == nullptr);
GPR_ASSERT(error != GRPC_ERROR_NONE);
finish_connection();
}
void test_succeeds(void) {
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int svr_fd;
int r;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_succeeds");
@@ -97,7 +95,7 @@ void test_succeeds(void) {
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(
- 0 == bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len));
+ 0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len));
GPR_ASSERT(0 == listen(svr_fd, 1));
gpr_mu_lock(g_mu);
@@ -105,17 +103,16 @@ void test_succeeds(void) {
gpr_mu_unlock(g_mu);
/* connect to it */
- GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)addr,
- (socklen_t *)&resolved_addr.len) == 0);
- GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL,
- &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
+ GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr,
+ (socklen_t*)&resolved_addr.len) == 0);
+ GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, nullptr,
+ &resolved_addr, GRPC_MILLIS_INF_FUTURE);
/* await the connection */
do {
resolved_addr.len = sizeof(addr);
- r = accept(svr_fd, (struct sockaddr *)addr,
- (socklen_t *)&resolved_addr.len);
+ r = accept(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len);
} while (r == -1 && errno == EINTR);
GPR_ASSERT(r >= 0);
close(r);
@@ -123,28 +120,26 @@ void test_succeeds(void) {
gpr_mu_lock(g_mu);
while (g_connections_complete == connections_complete_before) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- grpc_timeout_seconds_to_deadline(5))));
+ grpc_pollset_work(g_pollset, &worker,
+ grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void test_fails(void) {
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_fails");
@@ -157,61 +152,61 @@ void test_fails(void) {
gpr_mu_unlock(g_mu);
/* connect to a broken address */
- GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL,
- &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
+ GRPC_CLOSURE_INIT(&done, must_fail, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, nullptr,
+ &resolved_addr, GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
/* wait for the connection callback to finish */
while (g_connections_complete == connections_complete_before) {
- grpc_pollset_worker *worker = NULL;
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec polling_deadline = test_deadline();
- switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
+ grpc_pollset_worker* worker = nullptr;
+ grpc_millis polling_deadline = test_deadline();
+ switch (grpc_timer_check(&polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
- polling_deadline = now;
+ polling_deadline = 0;
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- now, polling_deadline)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset_set = grpc_pollset_set_create();
- g_pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
- grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
- test_succeeds();
- gpr_log(GPR_ERROR, "End of first test");
- test_fails();
- grpc_pollset_set_destroy(&exec_ctx, g_pollset_set);
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset_set = grpc_pollset_set_create();
+ g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_pollset_set_add_pollset(g_pollset_set, g_pollset);
+
+ test_succeeds();
+ gpr_log(GPR_ERROR, "End of first test");
+ test_fails();
+ grpc_pollset_set_destroy(g_pollset_set);
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+ }
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
@@ -219,6 +214,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.cc
index 0f1db4705b..0c6250ed7f 100644
--- a/test/core/iomgr/tcp_client_uv_test.c
+++ b/test/core/iomgr/tcp_client_uv_test.cc
@@ -37,58 +37,57 @@
#include "src/core/lib/iomgr/timer.h"
#include "test/core/util/test_config.h"
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static int g_connections_complete = 0;
-static grpc_endpoint *g_connecting = NULL;
+static grpc_endpoint* g_connecting = NULL;
-static gpr_timespec test_deadline(void) {
- return grpc_timeout_seconds_to_deadline(10);
+static grpc_millis test_deadline(void) {
+ return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
}
-static void finish_connection(grpc_exec_ctx *exec_ctx) {
+static void finish_connection() {
gpr_mu_lock(g_mu);
g_connections_complete++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
gpr_mu_unlock(g_mu);
}
-static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting != NULL);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(
- exec_ctx, g_connecting,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
- grpc_endpoint_destroy(exec_ctx, g_connecting);
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
g_connecting = NULL;
- finish_connection(exec_ctx);
+ finish_connection();
}
-static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting == NULL);
GPR_ASSERT(error != GRPC_ERROR_NONE);
- finish_connection(exec_ctx);
+ finish_connection();
}
-static void close_cb(uv_handle_t *handle) { gpr_free(handle); }
+static void close_cb(uv_handle_t* handle) { gpr_free(handle); }
-static void connection_cb(uv_stream_t *server, int status) {
- uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t));
+static void connection_cb(uv_stream_t* server, int status) {
+ uv_tcp_t* client_handle =
+ static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
GPR_ASSERT(0 == status);
GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), client_handle));
- GPR_ASSERT(0 == uv_accept(server, (uv_stream_t *)client_handle));
- uv_close((uv_handle_t *)client_handle, close_cb);
+ GPR_ASSERT(0 == uv_accept(server, (uv_stream_t*)client_handle));
+ uv_close((uv_handle_t*)client_handle, close_cb);
}
void test_succeeds(void) {
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- uv_tcp_t *svr_handle = gpr_malloc(sizeof(uv_tcp_t));
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ uv_tcp_t* svr_handle = static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_succeeds");
@@ -98,48 +97,46 @@ void test_succeeds(void) {
/* create a dummy server */
GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), svr_handle));
- GPR_ASSERT(0 == uv_tcp_bind(svr_handle, (struct sockaddr *)addr, 0));
- GPR_ASSERT(0 == uv_listen((uv_stream_t *)svr_handle, 1, connection_cb));
+ GPR_ASSERT(0 == uv_tcp_bind(svr_handle, (struct sockaddr*)addr, 0));
+ GPR_ASSERT(0 == uv_listen((uv_stream_t*)svr_handle, 1, connection_cb));
gpr_mu_lock(g_mu);
connections_complete_before = g_connections_complete;
gpr_mu_unlock(g_mu);
/* connect to it */
- GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr *)addr,
- (int *)&resolved_addr.len) == 0);
+ GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr*)addr,
+ (int*)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
- &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
+ grpc_tcp_client_connect(&done, &g_connecting, NULL, NULL, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
while (g_connections_complete == connections_complete_before) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- grpc_timeout_seconds_to_deadline(5))));
+ grpc_pollset_work(g_pollset, &worker,
+ grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
// This will get cleaned up when the pollset runs again or gets shutdown
- uv_close((uv_handle_t *)svr_handle, close_cb);
+ uv_close((uv_handle_t*)svr_handle, close_cb);
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void test_fails(void) {
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_fails");
@@ -153,57 +150,55 @@ void test_fails(void) {
/* connect to a broken address */
GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
- &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
+ grpc_tcp_client_connect(&done, &g_connecting, NULL, NULL, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
/* wait for the connection callback to finish */
while (g_connections_complete == connections_complete_before) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = NULL;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec polling_deadline = test_deadline();
- switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
+ grpc_millis polling_deadline = test_deadline();
+ switch (grpc_timer_check(&polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
- polling_deadline = now;
+ polling_deadline = grpc_timespec_to_millis_round_up(now);
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- now, polling_deadline)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = gpr_malloc(grpc_pollset_size());
+ g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
@@ -211,6 +206,6 @@ int main(int argc, char **argv) {
#else /* GRPC_UV */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_UV */
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.cc
index cfb3cf897c..f4acba8302 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -40,8 +40,8 @@
#include "test/core/iomgr/endpoint_tests.h"
#include "test/core/util/test_config.h"
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
/*
General test notes:
@@ -89,7 +89,7 @@ static ssize_t fill_socket(int fd) {
static size_t fill_socket_partial(int fd, size_t bytes) {
ssize_t write_bytes;
size_t total_bytes = 0;
- unsigned char *buf = (unsigned char *)gpr_malloc(bytes);
+ unsigned char* buf = (unsigned char*)gpr_malloc(bytes);
unsigned i;
for (i = 0; i < bytes; ++i) {
buf[i] = (uint8_t)(i % 256);
@@ -108,18 +108,18 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
}
struct read_socket_state {
- grpc_endpoint *ep;
+ grpc_endpoint* ep;
size_t read_bytes;
size_t target_read_bytes;
grpc_slice_buffer incoming;
grpc_closure read_cb;
};
-static size_t count_slices(grpc_slice *slices, size_t nslices,
- int *current_data) {
+static size_t count_slices(grpc_slice* slices, size_t nslices,
+ int* current_data) {
size_t num_bytes = 0;
unsigned i, j;
- unsigned char *buf;
+ unsigned char* buf;
for (i = 0; i < nslices; ++i) {
buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
@@ -131,9 +131,8 @@ static size_t count_slices(grpc_slice *slices, size_t nslices,
return num_bytes;
}
-static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *error) {
- struct read_socket_state *state = (struct read_socket_state *)user_data;
+static void read_cb(void* user_data, grpc_error* error) {
+ struct read_socket_state* state = (struct read_socket_state*)user_data;
size_t read_bytes;
int current_data;
@@ -147,11 +146,11 @@ static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data,
gpr_log(GPR_INFO, "Read %" PRIuPTR " bytes of %" PRIuPTR, read_bytes,
state->target_read_bytes);
if (state->read_bytes >= state->target_read_bytes) {
- GPR_ASSERT(GRPC_LOG_IF_ERROR("kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
} else {
- grpc_endpoint_read(exec_ctx, state->ep, &state->incoming, &state->read_cb);
+ grpc_endpoint_read(state->ep, &state->incoming, &state->read_cb);
gpr_mu_unlock(g_mu);
}
}
@@ -159,24 +158,24 @@ static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data,
/* Write to a socket, then read from it using the grpc_tcp API. */
static void read_test(size_t num_bytes, size_t slice_size) {
int sv[2];
- grpc_endpoint *ep;
+ grpc_endpoint* ep;
struct read_socket_state state;
size_t written_bytes;
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR,
num_bytes, slice_size);
create_sockets(sv);
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args,
- "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -187,48 +186,46 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(ep);
}
/* Write to a socket until it fills up, then read from it using the grpc_tcp
API. */
static void large_read_test(size_t slice_size) {
int sv[2];
- grpc_endpoint *ep;
+ grpc_endpoint* ep;
struct read_socket_state state;
ssize_t written_bytes;
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size);
create_sockets(sv);
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "large_read_test"),
- &args, "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER;
+ a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket(sv[0]);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -239,39 +236,36 @@ static void large_read_test(size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(ep);
}
struct write_socket_state {
- grpc_endpoint *ep;
+ grpc_endpoint* ep;
int write_done;
};
-static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
- size_t *num_blocks, uint8_t *current_data) {
+static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
+ size_t* num_blocks, uint8_t* current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u);
- grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices);
+ grpc_slice* slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * nslices);
size_t num_bytes_left = num_bytes;
unsigned i, j;
- unsigned char *buf;
+ unsigned char* buf;
*num_blocks = nslices;
for (i = 0; i < nslices; ++i) {
@@ -288,41 +282,40 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
return slices;
}
-static void write_done(grpc_exec_ctx *exec_ctx,
- void *user_data /* write_socket_state */,
- grpc_error *error) {
- struct write_socket_state *state = (struct write_socket_state *)user_data;
+static void write_done(void* user_data /* write_socket_state */,
+ grpc_error* error) {
+ struct write_socket_state* state = (struct write_socket_state*)user_data;
gpr_log(GPR_INFO, "Write done callback called");
gpr_mu_lock(g_mu);
gpr_log(GPR_INFO, "Signalling write done");
state->write_done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
- unsigned char *buf = (unsigned char *)gpr_malloc(read_size);
+ unsigned char* buf = (unsigned char*)gpr_malloc(read_size);
ssize_t bytes_read;
size_t bytes_left = num_bytes;
int flags;
int current = 0;
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
flags = fcntl(fd, F_GETFL, 0);
GPR_ASSERT(fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == 0);
for (;;) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(g_mu);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- grpc_timeout_milliseconds_to_deadline(10))));
+ grpc_pollset_work(g_pollset, &worker,
+ grpc_timespec_to_millis_round_up(
+ grpc_timeout_milliseconds_to_deadline(10)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
do {
bytes_read =
read(fd, buf, bytes_left > read_size ? read_size : bytes_left);
@@ -346,15 +339,16 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
socket in parallel with the read. */
static void write_test(size_t num_bytes, size_t slice_size) {
int sv[2];
- grpc_endpoint *ep;
+ grpc_endpoint* ep;
struct write_socket_state state;
size_t num_blocks;
- grpc_slice *slices;
+ grpc_slice* slices;
uint8_t current_data = 0;
grpc_slice_buffer outgoing;
grpc_closure write_done_closure;
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_INFO,
"Start write test with %" PRIuPTR " bytes, slice size %" PRIuPTR,
@@ -362,13 +356,12 @@ static void write_test(size_t num_bytes, size_t slice_size) {
create_sockets(sv);
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "write_test"), &args,
- "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
state.ep = ep;
state.write_done = 0;
@@ -380,47 +373,45 @@ static void write_test(size_t num_bytes, size_t slice_size) {
GRPC_CLOSURE_INIT(&write_done_closure, write_done, &state,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_write(&exec_ctx, ep, &outgoing, &write_done_closure);
+ grpc_endpoint_write(ep, &outgoing, &write_done_closure);
drain_socket_blocking(sv[0], num_bytes, num_bytes);
gpr_mu_lock(g_mu);
for (;;) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (state.write_done) {
break;
}
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
- grpc_endpoint_destroy(&exec_ctx, ep);
+ grpc_slice_buffer_destroy_internal(&outgoing);
+ grpc_endpoint_destroy(ep);
gpr_free(slices);
- grpc_exec_ctx_finish(&exec_ctx);
}
-void on_fd_released(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *errors) {
- int *done = (int *)arg;
+void on_fd_released(void* arg, grpc_error* errors) {
+ int* done = (int*)arg;
*done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
}
/* Do a read_test, then release fd and try to read/write again. Verify that
grpc_tcp_fd() is available before the fd is released. */
static void release_fd_test(size_t num_bytes, size_t slice_size) {
int sv[2];
- grpc_endpoint *ep;
+ grpc_endpoint* ep;
struct read_socket_state state;
size_t written_bytes;
int fd;
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
+ grpc_core::ExecCtx exec_ctx;
grpc_closure fd_released_cb;
int fd_released_done = 0;
GRPC_CLOSURE_INIT(&fd_released_cb, &on_fd_released, &fd_released_done,
@@ -432,14 +423,14 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
create_sockets(sv);
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args,
- "test");
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER;
+ a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -450,40 +441,35 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: read=%" PRIdPTR " target=%" PRIdPTR,
state.read_bytes, state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_tcp_destroy_and_release_fd(&exec_ctx, ep, &fd, &fd_released_cb);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_tcp_destroy_and_release_fd(ep, &fd, &fd_released_cb);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!fd_released_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: fd_released_done=%d", fd_released_done);
}
gpr_mu_unlock(g_mu);
GPR_ASSERT(fd_released_done == 1);
GPR_ASSERT(fd == sv[1]);
- grpc_exec_ctx_finish(&exec_ctx);
written_bytes = fill_socket_partial(sv[0], num_bytes);
drain_socket_blocking(fd, written_bytes, written_bytes);
@@ -521,24 +507,23 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
size_t slice_size) {
int sv[2];
grpc_endpoint_test_fixture f;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
create_sockets(sv);
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("tcp_posix_test_socketpair");
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
- f.client_ep = grpc_tcp_create(
- &exec_ctx, grpc_fd_create(sv[0], "fixture:client"), &args, "test");
- f.server_ep = grpc_tcp_create(
- &exec_ctx, grpc_fd_create(sv[1], "fixture:server"), &args, "test");
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER;
+ a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
+ f.client_ep =
+ grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"), &args, "test");
+ f.server_ep =
+ grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"), &args, "test");
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
return f;
}
@@ -547,24 +532,26 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up},
};
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
- grpc_endpoint_tests(configs[0], g_pollset, g_mu);
- run_tests();
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_endpoint_tests(configs[0], g_pollset, g_mu);
+ run_tests();
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
+ grpc_core::ExecCtx::Get()->Flush();
+ }
grpc_shutdown();
gpr_free(g_pollset);
@@ -573,6 +560,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.cc
index 4d84608376..3c9ca2109e 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -47,20 +47,20 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static int g_nconnects = 0;
typedef struct {
/* Owns a ref to server. */
- grpc_tcp_server *server;
+ grpc_tcp_server* server;
unsigned port_index;
unsigned fd_index;
int server_fd;
} on_connect_result;
typedef struct {
- grpc_tcp_server *server;
+ grpc_tcp_server* server;
/* arg is this server_weak_ref. */
grpc_closure server_shutdown;
@@ -78,10 +78,10 @@ typedef struct {
test_addr addrs[MAX_ADDRS];
} test_addrs;
-static on_connect_result g_result = {NULL, 0, 0, -1};
+static on_connect_result g_result = {nullptr, 0, 0, -1};
static char family_name_buf[1024];
-static const char *sock_family_name(int family) {
+static const char* sock_family_name(int family) {
if (family == AF_INET) {
return "AF_INET";
} else if (family == AF_INET6) {
@@ -94,15 +94,15 @@ static const char *sock_family_name(int family) {
}
}
-static void on_connect_result_init(on_connect_result *result) {
- result->server = NULL;
+static void on_connect_result_init(on_connect_result* result) {
+ result->server = nullptr;
result->port_index = 0;
result->fd_index = 0;
result->server_fd = -1;
}
-static void on_connect_result_set(on_connect_result *result,
- const grpc_tcp_server_acceptor *acceptor) {
+static void on_connect_result_set(on_connect_result* result,
+ const grpc_tcp_server_acceptor* acceptor) {
result->server = grpc_tcp_server_ref(acceptor->from_server);
result->port_index = acceptor->port_index;
result->fd_index = acceptor->fd_index;
@@ -110,14 +110,13 @@ static void on_connect_result_set(on_connect_result *result,
result->server, acceptor->port_index, acceptor->fd_index);
}
-static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- server_weak_ref *weak_ref = arg;
- weak_ref->server = NULL;
+static void server_weak_ref_shutdown(void* arg, grpc_error* error) {
+ server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
+ weak_ref->server = nullptr;
}
-static void server_weak_ref_init(server_weak_ref *weak_ref) {
- weak_ref->server = NULL;
+static void server_weak_ref_init(server_weak_ref* weak_ref) {
+ weak_ref->server = nullptr;
GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown,
weak_ref, grpc_schedule_on_exec_ctx);
}
@@ -127,14 +126,14 @@ static void server_weak_ref_init(server_weak_ref *weak_ref) {
weak_ref->server_shutdown has returned. A strong ref on grpc_tcp_server
should be held until server_weak_ref_set() returns to avoid a race where the
server is deleted before the shutdown_starting cb is added. */
-static void server_weak_ref_set(server_weak_ref *weak_ref,
- grpc_tcp_server *server) {
+static void server_weak_ref_set(server_weak_ref* weak_ref,
+ grpc_tcp_server* server) {
grpc_tcp_server_shutdown_starting_add(server, &weak_ref->server_shutdown);
weak_ref->server = server;
}
-static void test_addr_init_str(test_addr *addr) {
- char *str = NULL;
+static void test_addr_init_str(test_addr* addr) {
+ char* str = nullptr;
if (grpc_sockaddr_to_string(&str, &addr->addr, 0) != -1) {
size_t str_len;
memcpy(addr->str, str, (str_len = strnlen(str, sizeof(addr->str) - 1)));
@@ -145,12 +144,11 @@ static void test_addr_init_str(test_addr *addr) {
}
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *pollset,
- grpc_tcp_server_acceptor *acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp,
+static void on_connect(void* arg, grpc_endpoint* tcp, grpc_pollset* pollset,
+ grpc_tcp_server_acceptor* acceptor) {
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
@@ -159,38 +157,33 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_mu_lock(g_mu);
g_result = temp_result;
g_nconnects++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_start");
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(s, nullptr, 0, on_connect, nullptr);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -201,17 +194,15 @@ static void test_no_op_with_port(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port_and_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port = -1;
@@ -222,19 +213,19 @@ static void test_no_op_with_port_and_start(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_start(s, nullptr, 0, on_connect, nullptr);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
-static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
- on_connect_result *result) {
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
+static grpc_error* tcp_connect(const test_addr* remote,
+ on_connect_result* result) {
+ grpc_millis deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
int clifd;
int nconnects_before;
- const struct sockaddr *remote_addr =
- (const struct sockaddr *)remote->addr.addr;
+ const struct sockaddr* remote_addr =
+ (const struct sockaddr*)remote->addr.addr;
gpr_log(GPR_INFO, "Connecting to %s", remote->str);
gpr_mu_lock(g_mu);
@@ -253,18 +244,17 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
}
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
- gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
- grpc_pollset_worker *worker = NULL;
- grpc_error *err;
- if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)) !=
+ deadline > grpc_core::ExecCtx::Get()->Now()) {
+ grpc_pollset_worker* worker = nullptr;
+ grpc_error* err;
+ if ((err = grpc_pollset_work(g_pollset, &worker, deadline)) !=
GRPC_ERROR_NONE) {
gpr_mu_unlock(g_mu);
close(clifd);
return err;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -279,7 +269,7 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
gpr_mu_unlock(g_mu);
gpr_log(GPR_INFO, "Result (%d, %d) fd %d", result->port_index,
result->fd_index, result->server_fd);
- grpc_tcp_server_unref(exec_ctx, result->server);
+ grpc_tcp_server_unref(result->server);
return GRPC_ERROR_NONE;
}
@@ -290,24 +280,24 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
each destination address, set grpc_resolved_address::len=0 for failures, but
don't fail the overall unitest. */
static void test_connect(size_t num_connects,
- const grpc_channel_args *channel_args,
- test_addrs *dst_addrs, bool test_dst_addrs) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ const grpc_channel_args* channel_args,
+ test_addrs* dst_addrs, bool test_dst_addrs) {
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
- struct sockaddr_storage *const addr =
- (struct sockaddr_storage *)resolved_addr.addr;
- struct sockaddr_storage *const addr1 =
- (struct sockaddr_storage *)resolved_addr1.addr;
+ struct sockaddr_storage* const addr =
+ (struct sockaddr_storage*)resolved_addr.addr;
+ struct sockaddr_storage* const addr1 =
+ (struct sockaddr_storage*)resolved_addr1.addr;
unsigned svr_fd_count;
int port;
int svr_port;
unsigned svr1_fd_count;
int svr1_port;
- grpc_tcp_server *s;
+ grpc_tcp_server* s;
const unsigned num_ports = 2;
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, channel_args, &s));
+ grpc_tcp_server_create(nullptr, channel_args, &s));
unsigned port_num;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -316,8 +306,8 @@ static void test_connect(size_t num_connects,
gpr_log(GPR_INFO,
"clients=%lu, num chan args=%lu, remote IP=%s, test_dst_addrs=%d",
(unsigned long)num_connects,
- (unsigned long)(channel_args != NULL ? channel_args->num_args : 0),
- dst_addrs != NULL ? "<specific>" : "::", test_dst_addrs);
+ (unsigned long)(channel_args != nullptr ? channel_args->num_args : 0),
+ dst_addrs != nullptr ? "<specific>" : "::", test_dst_addrs);
memset(&resolved_addr, 0, sizeof(resolved_addr));
memset(&resolved_addr1, 0, sizeof(resolved_addr1));
resolved_addr.len = sizeof(struct sockaddr_storage);
@@ -352,9 +342,9 @@ static void test_connect(size_t num_connects,
svr1_fd_count = grpc_tcp_server_port_fd_count(s, 1);
GPR_ASSERT(svr1_fd_count >= 1);
- grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL);
+ grpc_tcp_server_start(s, &g_pollset, 1, on_connect, nullptr);
- if (dst_addrs != NULL) {
+ if (dst_addrs != nullptr) {
int ports[] = {svr_port, svr1_port};
for (port_num = 0; port_num < num_ports; ++port_num) {
size_t dst_idx;
@@ -362,7 +352,7 @@ static void test_connect(size_t num_connects,
for (dst_idx = 0; dst_idx < dst_addrs->naddrs; ++dst_idx) {
test_addr dst = dst_addrs->addrs[dst_idx];
on_connect_result result;
- grpc_error *err;
+ grpc_error* err;
if (dst.addr.len == 0) {
gpr_log(GPR_DEBUG, "Skipping test of non-functional local IP %s",
dst.str);
@@ -372,7 +362,7 @@ static void test_connect(size_t num_connects,
test_addr_init_str(&dst);
++num_tested;
on_connect_result_init(&result);
- if ((err = tcp_connect(&exec_ctx, &dst, &result)) == GRPC_ERROR_NONE &&
+ if ((err = tcp_connect(&dst, &result)) == GRPC_ERROR_NONE &&
result.server_fd >= 0 && result.server == s) {
continue;
}
@@ -394,8 +384,8 @@ static void test_connect(size_t num_connects,
test_addr dst;
GPR_ASSERT(fd >= 0);
dst.addr.len = sizeof(dst.addr.addr);
- GPR_ASSERT(getsockname(fd, (struct sockaddr *)dst.addr.addr,
- (socklen_t *)&dst.addr.len) == 0);
+ GPR_ASSERT(getsockname(fd, (struct sockaddr*)dst.addr.addr,
+ (socklen_t*)&dst.addr.len) == 0);
GPR_ASSERT(dst.addr.len <= sizeof(dst.addr.addr));
test_addr_init_str(&dst);
gpr_log(GPR_INFO, "(%d, %d) fd %d family %s listening on %s", port_num,
@@ -403,8 +393,8 @@ static void test_connect(size_t num_connects,
for (connect_num = 0; connect_num < num_connects; ++connect_num) {
on_connect_result result;
on_connect_result_init(&result);
- GPR_ASSERT(GRPC_LOG_IF_ERROR("tcp_connect",
- tcp_connect(&exec_ctx, &dst, &result)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("tcp_connect", tcp_connect(&dst, &result)));
GPR_ASSERT(result.server_fd == fd);
GPR_ASSERT(result.port_index == port_num);
GPR_ASSERT(result.fd_index == fd_num);
@@ -417,85 +407,89 @@ static void test_connect(size_t num_connects,
}
}
/* Weak ref to server valid until final unref. */
- GPR_ASSERT(weak_ref.server != NULL);
+ GPR_ASSERT(weak_ref.server != nullptr);
GPR_ASSERT(grpc_tcp_server_port_fd(s, 0, 0) >= 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
+ grpc_core::ExecCtx::Get()->Flush();
/* Weak ref lost. */
- GPR_ASSERT(weak_ref.server == NULL);
+ GPR_ASSERT(weak_ref.server == nullptr);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_arg chan_args[] = {
- {GRPC_ARG_INTEGER, GRPC_ARG_EXPAND_WILDCARD_ADDRS, {.integer = 1}}};
+ grpc_arg chan_args[1];
+ chan_args[0].type = GRPC_ARG_INTEGER;
+ chan_args[0].key = const_cast<char*>(GRPC_ARG_EXPAND_WILDCARD_ADDRS);
+ chan_args[0].value.integer = 1;
const grpc_channel_args channel_args = {1, chan_args};
- struct ifaddrs *ifa = NULL;
- struct ifaddrs *ifa_it;
+ struct ifaddrs* ifa = nullptr;
+ struct ifaddrs* ifa_it;
// Zalloc dst_addrs to avoid oversized frames.
- test_addrs *dst_addrs = gpr_zalloc(sizeof(*dst_addrs));
+ test_addrs* dst_addrs =
+ static_cast<test_addrs*>(gpr_zalloc(sizeof(*dst_addrs)));
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(g_pollset, &g_mu);
+
+ test_no_op();
+ test_no_op_with_start();
+ test_no_op_with_port();
+ test_no_op_with_port_and_start();
+
+ if (getifaddrs(&ifa) != 0 || ifa == nullptr) {
+ gpr_log(GPR_ERROR, "getifaddrs: %s", strerror(errno));
+ return EXIT_FAILURE;
+ }
+ dst_addrs->naddrs = 0;
+ for (ifa_it = ifa; ifa_it != nullptr && dst_addrs->naddrs < MAX_ADDRS;
+ ifa_it = ifa_it->ifa_next) {
+ if (ifa_it->ifa_addr == nullptr) {
+ continue;
+ } else if (ifa_it->ifa_addr->sa_family == AF_INET) {
+ dst_addrs->addrs[dst_addrs->naddrs].addr.len =
+ sizeof(struct sockaddr_in);
+ } else if (ifa_it->ifa_addr->sa_family == AF_INET6) {
+ dst_addrs->addrs[dst_addrs->naddrs].addr.len =
+ sizeof(struct sockaddr_in6);
+ } else {
+ continue;
+ }
+ memcpy(dst_addrs->addrs[dst_addrs->naddrs].addr.addr, ifa_it->ifa_addr,
+ dst_addrs->addrs[dst_addrs->naddrs].addr.len);
+ GPR_ASSERT(
+ grpc_sockaddr_set_port(&dst_addrs->addrs[dst_addrs->naddrs].addr, 0));
+ test_addr_init_str(&dst_addrs->addrs[dst_addrs->naddrs]);
+ ++dst_addrs->naddrs;
+ }
+ freeifaddrs(ifa);
+ ifa = nullptr;
- test_no_op();
- test_no_op_with_start();
- test_no_op_with_port();
- test_no_op_with_port_and_start();
+ /* Connect to same addresses as listeners. */
+ test_connect(1, nullptr, nullptr, false);
+ test_connect(10, nullptr, nullptr, false);
- if (getifaddrs(&ifa) != 0 || ifa == NULL) {
- gpr_log(GPR_ERROR, "getifaddrs: %s", strerror(errno));
- return EXIT_FAILURE;
- }
- dst_addrs->naddrs = 0;
- for (ifa_it = ifa; ifa_it != NULL && dst_addrs->naddrs < MAX_ADDRS;
- ifa_it = ifa_it->ifa_next) {
- if (ifa_it->ifa_addr == NULL) {
- continue;
- } else if (ifa_it->ifa_addr->sa_family == AF_INET) {
- dst_addrs->addrs[dst_addrs->naddrs].addr.len = sizeof(struct sockaddr_in);
- } else if (ifa_it->ifa_addr->sa_family == AF_INET6) {
- dst_addrs->addrs[dst_addrs->naddrs].addr.len =
- sizeof(struct sockaddr_in6);
- } else {
- continue;
- }
- memcpy(dst_addrs->addrs[dst_addrs->naddrs].addr.addr, ifa_it->ifa_addr,
- dst_addrs->addrs[dst_addrs->naddrs].addr.len);
- GPR_ASSERT(
- grpc_sockaddr_set_port(&dst_addrs->addrs[dst_addrs->naddrs].addr, 0));
- test_addr_init_str(&dst_addrs->addrs[dst_addrs->naddrs]);
- ++dst_addrs->naddrs;
+ /* Set dst_addrs->addrs[i].len=0 for dst_addrs that are unreachable with a
+ "::" listener. */
+ test_connect(1, nullptr, dst_addrs, true);
+
+ /* Test connect(2) with dst_addrs. */
+ test_connect(1, &channel_args, dst_addrs, false);
+ /* Test connect(2) with dst_addrs. */
+ test_connect(10, &channel_args, dst_addrs, false);
+
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
}
- freeifaddrs(ifa);
- ifa = NULL;
-
- /* Connect to same addresses as listeners. */
- test_connect(1, NULL, NULL, false);
- test_connect(10, NULL, NULL, false);
-
- /* Set dst_addrs->addrs[i].len=0 for dst_addrs that are unreachable with a
- "::" listener. */
- test_connect(1, NULL, dst_addrs, true);
-
- /* Test connect(2) with dst_addrs. */
- test_connect(1, &channel_args, dst_addrs, false);
- /* Test connect(2) with dst_addrs. */
- test_connect(10, &channel_args, dst_addrs, false);
-
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(dst_addrs);
gpr_free(g_pollset);
@@ -504,6 +498,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.cc
index bd8ccb4f60..35d62b51b7 100644
--- a/test/core/iomgr/tcp_server_uv_test.c
+++ b/test/core/iomgr/tcp_server_uv_test.cc
@@ -41,19 +41,19 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static int g_nconnects = 0;
typedef struct on_connect_result {
/* Owns a ref to server. */
- grpc_tcp_server *server;
+ grpc_tcp_server* server;
unsigned port_index;
unsigned fd_index;
} on_connect_result;
typedef struct server_weak_ref {
- grpc_tcp_server *server;
+ grpc_tcp_server* server;
/* arg is this server_weak_ref. */
grpc_closure server_shutdown;
@@ -61,26 +61,25 @@ typedef struct server_weak_ref {
static on_connect_result g_result = {NULL, 0, 0};
-static void on_connect_result_init(on_connect_result *result) {
+static void on_connect_result_init(on_connect_result* result) {
result->server = NULL;
result->port_index = 0;
result->fd_index = 0;
}
-static void on_connect_result_set(on_connect_result *result,
- const grpc_tcp_server_acceptor *acceptor) {
+static void on_connect_result_set(on_connect_result* result,
+ const grpc_tcp_server_acceptor* acceptor) {
result->server = grpc_tcp_server_ref(acceptor->from_server);
result->port_index = acceptor->port_index;
result->fd_index = acceptor->fd_index;
}
-static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- server_weak_ref *weak_ref = arg;
+static void server_weak_ref_shutdown(void* arg, grpc_error* error) {
+ server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
weak_ref->server = NULL;
}
-static void server_weak_ref_init(server_weak_ref *weak_ref) {
+static void server_weak_ref_init(server_weak_ref* weak_ref) {
weak_ref->server = NULL;
GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown,
weak_ref, grpc_schedule_on_exec_ctx);
@@ -91,18 +90,17 @@ static void server_weak_ref_init(server_weak_ref *weak_ref) {
weak_ref->server_shutdown has returned. A strong ref on grpc_tcp_server
should be held until server_weak_ref_set() returns to avoid a race where the
server is deleted before the shutdown_starting cb is added. */
-static void server_weak_ref_set(server_weak_ref *weak_ref,
- grpc_tcp_server *server) {
+static void server_weak_ref_set(server_weak_ref* weak_ref,
+ grpc_tcp_server* server) {
grpc_tcp_server_shutdown_starting_add(server, &weak_ref->server_shutdown);
weak_ref->server = server;
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *pollset,
- grpc_tcp_server_acceptor *acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp,
+static void on_connect(void* arg, grpc_endpoint* tcp, grpc_pollset* pollset,
+ grpc_tcp_server_acceptor* acceptor) {
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
@@ -111,38 +109,33 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_mu_lock(g_mu);
g_result = temp_result;
g_nconnects++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_start");
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -153,17 +146,15 @@ static void test_no_op_with_port(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port_and_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port;
@@ -174,24 +165,25 @@ static void test_no_op_with_port_and_start(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
-static void connect_cb(uv_connect_t *req, int status) {
+static void connect_cb(uv_connect_t* req, int status) {
GPR_ASSERT(status == 0);
gpr_free(req);
}
-static void close_cb(uv_handle_t *handle) { gpr_free(handle); }
+static void close_cb(uv_handle_t* handle) { gpr_free(handle); }
-static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote,
- socklen_t remote_len, on_connect_result *result) {
+static void tcp_connect(const struct sockaddr* remote, socklen_t remote_len,
+ on_connect_result* result) {
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
- uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t));
- uv_connect_t *req = gpr_malloc(sizeof(uv_connect_t));
+ uv_tcp_t* client_handle =
+ static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
+ uv_connect_t* req =
+ static_cast<uv_connect_t*>(gpr_malloc(sizeof(uv_connect_t)));
int nconnects_before;
gpr_mu_lock(g_mu);
@@ -203,18 +195,18 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote,
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ grpc_pollset_work(g_pollset, &worker,
+ grpc_timespec_to_millis_round_up(deadline))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
GPR_ASSERT(g_nconnects == nconnects_before + 1);
- uv_close((uv_handle_t *)client_handle, close_cb);
+ uv_close((uv_handle_t*)client_handle, close_cb);
*result = g_result;
gpr_mu_unlock(g_mu);
@@ -222,17 +214,16 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote,
/* Tests a tcp server with multiple ports. */
static void test_connect(unsigned n) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
- struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
- struct sockaddr_storage *addr1 =
- (struct sockaddr_storage *)resolved_addr1.addr;
+ struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
+ struct sockaddr_storage* addr1 =
+ (struct sockaddr_storage*)resolved_addr1.addr;
int svr_port;
int svr1_port;
- grpc_tcp_server *s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ grpc_tcp_server* s;
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
unsigned i;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -246,7 +237,7 @@ static void test_connect(unsigned n) {
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_tcp_server_add_port(s, &resolved_addr, &svr_port));
GPR_ASSERT(svr_port > 0);
- GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr) == 0);
+ GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr)) == 0);
/* Cannot use wildcard (port==0), because add_port() will try to reuse the
same port as a previous add_port(). */
svr1_port = grpc_pick_unused_port_or_die();
@@ -255,51 +246,48 @@ static void test_connect(unsigned n) {
GRPC_ERROR_NONE &&
svr_port == svr1_port);
- grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL);
+ grpc_tcp_server_start(s, &g_pollset, 1, on_connect, NULL);
- GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr1) == 0);
+ GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr1) == 0);
for (i = 0; i < n; i++) {
on_connect_result result;
on_connect_result_init(&result);
- tcp_connect(&exec_ctx, (struct sockaddr *)addr,
- (socklen_t)resolved_addr.len, &result);
+ tcp_connect((struct sockaddr*)addr, (socklen_t)resolved_addr.len, &result);
GPR_ASSERT(result.port_index == 0);
GPR_ASSERT(result.server == s);
if (weak_ref.server == NULL) {
server_weak_ref_set(&weak_ref, result.server);
}
- grpc_tcp_server_unref(&exec_ctx, result.server);
+ grpc_tcp_server_unref(result.server);
on_connect_result_init(&result);
- tcp_connect(&exec_ctx, (struct sockaddr *)addr1,
- (socklen_t)resolved_addr1.len, &result);
+ tcp_connect((struct sockaddr*)addr1, (socklen_t)resolved_addr1.len,
+ &result);
GPR_ASSERT(result.port_index == 1);
GPR_ASSERT(result.server == s);
- grpc_tcp_server_unref(&exec_ctx, result.server);
+ grpc_tcp_server_unref(result.server);
}
/* Weak ref to server valid until final unref. */
GPR_ASSERT(weak_ref.server != NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == NULL);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = gpr_malloc(grpc_pollset_size());
+ g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
test_no_op();
@@ -311,8 +299,8 @@ int main(int argc, char **argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
@@ -320,6 +308,6 @@ int main(int argc, char **argv) {
#else /* GRPC_UV */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_UV */
diff --git a/test/core/iomgr/time_averaged_stats_test.c b/test/core/iomgr/time_averaged_stats_test.cc
index 508e3c5bf8..b932e62d1f 100644
--- a/test/core/iomgr/time_averaged_stats_test.c
+++ b/test/core/iomgr/time_averaged_stats_test.cc
@@ -179,7 +179,7 @@ static void some_regress_some_persist_test(void) {
EXPECT_DOUBLE_EQ(2.8304, tas.aggregate_total_weight);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
no_regress_no_persist_test_1();
no_regress_no_persist_test_2();
diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.cc
index ee5a474fd1..f0ab4343cb 100644
--- a/test/core/iomgr/timer_heap_test.c
+++ b/test/core/iomgr/timer_heap_test.cc
@@ -34,8 +34,9 @@
static gpr_atm random_deadline(void) { return rand(); }
-static grpc_timer *create_test_elements(size_t num_elements) {
- grpc_timer *elems = gpr_malloc(num_elements * sizeof(grpc_timer));
+static grpc_timer* create_test_elements(size_t num_elements) {
+ grpc_timer* elems =
+ static_cast<grpc_timer*>(gpr_malloc(num_elements * sizeof(grpc_timer)));
size_t i;
for (i = 0; i < num_elements; i++) {
elems[i].deadline = random_deadline();
@@ -43,7 +44,7 @@ static grpc_timer *create_test_elements(size_t num_elements) {
return elems;
}
-static int contains(grpc_timer_heap *pq, grpc_timer *el) {
+static int contains(grpc_timer_heap* pq, grpc_timer* el) {
size_t i;
for (i = 0; i < pq->timer_count; i++) {
if (pq->timers[i] == el) return 1;
@@ -51,7 +52,7 @@ static int contains(grpc_timer_heap *pq, grpc_timer *el) {
return 0;
}
-static void check_valid(grpc_timer_heap *pq) {
+static void check_valid(grpc_timer_heap* pq) {
size_t i;
for (i = 0; i < pq->timer_count; ++i) {
size_t left_child = 1u + 2u * i;
@@ -74,8 +75,8 @@ static void test1(void) {
const size_t num_test_elements = 200;
const size_t num_test_operations = 10000;
size_t i;
- grpc_timer *test_elements = create_test_elements(num_test_elements);
- uint8_t *inpq = gpr_malloc(num_test_elements);
+ grpc_timer* test_elements = create_test_elements(num_test_elements);
+ uint8_t* inpq = static_cast<uint8_t*>(gpr_malloc(num_test_elements));
gpr_log(GPR_INFO, "test1");
@@ -102,7 +103,7 @@ static void test1(void) {
for (i = 0; i < num_test_operations; ++i) {
size_t elem_num = (size_t)rand() % num_test_elements;
- grpc_timer *el = &test_elements[elem_num];
+ grpc_timer* el = &test_elements[elem_num];
if (!inpq[elem_num]) { /* not in pq */
GPR_ASSERT(!contains(&pq, el));
el->deadline = random_deadline();
@@ -133,9 +134,10 @@ typedef struct {
bool inserted;
} elem_struct;
-static elem_struct *search_elems(elem_struct *elems, size_t count,
+static elem_struct* search_elems(elem_struct* elems, size_t count,
bool inserted) {
- size_t *search_order = gpr_malloc(count * sizeof(*search_order));
+ size_t* search_order =
+ static_cast<size_t*>(gpr_malloc(count * sizeof(*search_order)));
for (size_t i = 0; i < count; i++) {
search_order[i] = i;
}
@@ -144,8 +146,8 @@ static elem_struct *search_elems(elem_struct *elems, size_t count,
size_t b = (size_t)rand() % count;
GPR_SWAP(size_t, search_order[a], search_order[b]);
}
- elem_struct *out = NULL;
- for (size_t i = 0; out == NULL && i < count; i++) {
+ elem_struct* out = nullptr;
+ for (size_t i = 0; out == nullptr && i < count; i++) {
if (elems[search_order[i]].inserted == inserted) {
out = &elems[search_order[i]];
}
@@ -160,7 +162,8 @@ static void test2(void) {
grpc_timer_heap pq;
static const size_t elems_size = 1000;
- elem_struct *elems = gpr_malloc(elems_size * sizeof(elem_struct));
+ elem_struct* elems =
+ static_cast<elem_struct*>(gpr_malloc(elems_size * sizeof(elem_struct)));
size_t num_inserted = 0;
grpc_timer_heap_init(&pq);
@@ -170,8 +173,8 @@ static void test2(void) {
int r = rand() % 1000;
if (r <= 550) {
/* 55% of the time we try to add something */
- elem_struct *el = search_elems(elems, GPR_ARRAY_SIZE(elems), false);
- if (el != NULL) {
+ elem_struct* el = search_elems(elems, GPR_ARRAY_SIZE(elems), false);
+ if (el != nullptr) {
el->elem.deadline = random_deadline();
grpc_timer_heap_add(&pq, &el->elem);
el->inserted = true;
@@ -180,8 +183,8 @@ static void test2(void) {
}
} else if (r <= 650) {
/* 10% of the time we try to remove something */
- elem_struct *el = search_elems(elems, GPR_ARRAY_SIZE(elems), true);
- if (el != NULL) {
+ elem_struct* el = search_elems(elems, GPR_ARRAY_SIZE(elems), true);
+ if (el != nullptr) {
grpc_timer_heap_remove(&pq, &el->elem);
el->inserted = false;
num_inserted--;
@@ -190,7 +193,7 @@ static void test2(void) {
} else {
/* the remaining times we pop */
if (num_inserted > 0) {
- grpc_timer *top = grpc_timer_heap_top(&pq);
+ grpc_timer* top = grpc_timer_heap_top(&pq);
grpc_timer_heap_pop(&pq);
for (size_t i = 0; i < elems_size; i++) {
if (top == &elems[i].elem) {
@@ -204,10 +207,10 @@ static void test2(void) {
}
if (num_inserted) {
- gpr_atm *min_deadline = NULL;
+ gpr_atm* min_deadline = nullptr;
for (size_t i = 0; i < elems_size; i++) {
if (elems[i].inserted) {
- if (min_deadline == NULL) {
+ if (min_deadline == nullptr) {
min_deadline = &elems[i].elem.deadline;
} else {
if (elems[i].elem.deadline < *min_deadline) {
@@ -246,7 +249,7 @@ static void shrink_test(void) {
/* Remove elements until the Size is 1/4 the original size. */
while (pq.timer_count > num_elements / 4) {
- grpc_timer *const te = pq.timers[pq.timer_count - 1];
+ grpc_timer* const te = pq.timers[pq.timer_count - 1];
grpc_timer_heap_remove(&pq, te);
gpr_free(te);
}
@@ -263,7 +266,7 @@ static void shrink_test(void) {
expected_size = pq.timer_count;
while (pq.timer_count > 0) {
const size_t which = (size_t)rand() % pq.timer_count;
- grpc_timer *te = pq.timers[which];
+ grpc_timer* te = pq.timers[which];
grpc_timer_heap_remove(&pq, te);
gpr_free(te);
expected_size--;
@@ -283,7 +286,7 @@ static void shrink_test(void) {
grpc_timer_heap_destroy(&pq);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int i;
grpc_test_init(argc, argv);
@@ -299,6 +302,6 @@ int main(int argc, char **argv) {
#else /* GRPC_TIMER_USE_GENERIC */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_TIMER_USE_GENERIC */
diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c
deleted file mode 100644
index 5f8b01fdc4..0000000000
--- a/test/core/iomgr/timer_list_test.c
+++ /dev/null
@@ -1,182 +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/iomgr/port.h"
-
-// This test only works with the generic timer implementation
-#ifdef GRPC_TIMER_USE_GENERIC
-
-#include "src/core/lib/iomgr/timer.h"
-
-#include <string.h>
-
-#include <grpc/support/log.h>
-#include "src/core/lib/debug/trace.h"
-#include "test/core/util/test_config.h"
-
-#define MAX_CB 30
-
-extern grpc_tracer_flag grpc_timer_trace;
-extern grpc_tracer_flag grpc_timer_check_trace;
-
-static int cb_called[MAX_CB][2];
-
-static void cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++;
-}
-
-static void add_test(void) {
- gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
- int i;
- grpc_timer timers[20];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- gpr_log(GPR_INFO, "add_test");
-
- grpc_timer_list_init(start);
- grpc_timer_trace.value = 1;
- grpc_timer_check_trace.value = 1;
- memset(cb_called, 0, sizeof(cb_called));
-
- /* 10 ms timers. will expire in the current epoch */
- for (i = 0; i < 10; i++) {
- grpc_timer_init(
- &exec_ctx, &timers[i],
- gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
- start);
- }
-
- /* 1010 ms timers. will expire in the next epoch */
- for (i = 10; i < 20; i++) {
- grpc_timer_init(
- &exec_ctx, &timers[i],
- gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
- start);
- }
-
- /* collect timers. Only the first batch should be ready. */
- GPR_ASSERT(grpc_timer_check(
- &exec_ctx,
- gpr_time_add(start, gpr_time_from_millis(500, GPR_TIMESPAN)),
- NULL) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
- for (i = 0; i < 20; i++) {
- GPR_ASSERT(cb_called[i][1] == (i < 10));
- GPR_ASSERT(cb_called[i][0] == 0);
- }
-
- GPR_ASSERT(grpc_timer_check(
- &exec_ctx,
- gpr_time_add(start, gpr_time_from_millis(600, GPR_TIMESPAN)),
- NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
- grpc_exec_ctx_finish(&exec_ctx);
- for (i = 0; i < 30; i++) {
- GPR_ASSERT(cb_called[i][1] == (i < 10));
- GPR_ASSERT(cb_called[i][0] == 0);
- }
-
- /* collect the rest of the timers */
- GPR_ASSERT(grpc_timer_check(
- &exec_ctx,
- gpr_time_add(start, gpr_time_from_millis(1500, GPR_TIMESPAN)),
- NULL) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
- for (i = 0; i < 30; i++) {
- GPR_ASSERT(cb_called[i][1] == (i < 20));
- GPR_ASSERT(cb_called[i][0] == 0);
- }
-
- GPR_ASSERT(grpc_timer_check(
- &exec_ctx,
- gpr_time_add(start, gpr_time_from_millis(1600, GPR_TIMESPAN)),
- NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
- for (i = 0; i < 30; i++) {
- GPR_ASSERT(cb_called[i][1] == (i < 20));
- GPR_ASSERT(cb_called[i][0] == 0);
- }
-
- grpc_timer_list_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static gpr_timespec tfm(int m) {
- return gpr_time_from_millis(m, GPR_CLOCK_REALTIME);
-}
-
-/* Cleaning up a list with pending timers. */
-void destruction_test(void) {
- grpc_timer timers[5];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- gpr_log(GPR_INFO, "destruction_test");
-
- grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_trace.value = 1;
- grpc_timer_check_trace.value = 1;
- memset(cb_called, 0, sizeof(cb_called));
-
- grpc_timer_init(
- &exec_ctx, &timers[0], tfm(100),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx),
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(
- &exec_ctx, &timers[1], tfm(3),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx),
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(
- &exec_ctx, &timers[2], tfm(100),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx),
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(
- &exec_ctx, &timers[3], tfm(3),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx),
- gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_init(
- &exec_ctx, &timers[4], tfm(1),
- GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx),
- gpr_time_0(GPR_CLOCK_REALTIME));
- GPR_ASSERT(grpc_timer_check(&exec_ctx, tfm(2), NULL) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(1 == cb_called[4][1]);
- grpc_timer_cancel(&exec_ctx, &timers[0]);
- grpc_timer_cancel(&exec_ctx, &timers[3]);
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(1 == cb_called[0][0]);
- GPR_ASSERT(1 == cb_called[3][0]);
-
- grpc_timer_list_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(1 == cb_called[1][0]);
- GPR_ASSERT(1 == cb_called[2][0]);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
- add_test();
- destruction_test();
- return 0;
-}
-
-#else /* GRPC_TIMER_USE_GENERIC */
-
-int main(int argc, char **argv) { return 1; }
-
-#endif /* GRPC_TIMER_USE_GENERIC */
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc
new file mode 100644
index 0000000000..deb8c4d87e
--- /dev/null
+++ b/test/core/iomgr/timer_list_test.cc
@@ -0,0 +1,167 @@
+/*
+ *
+ * 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/iomgr/port.h"
+
+// This test only works with the generic timer implementation
+#ifdef GRPC_TIMER_USE_GENERIC
+
+#include "src/core/lib/iomgr/timer.h"
+
+#include <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
+#include "src/core/lib/debug/trace.h"
+#include "test/core/util/test_config.h"
+#include "test/core/util/tracer_util.h"
+
+#define MAX_CB 30
+
+extern grpc_core::TraceFlag grpc_timer_trace;
+extern grpc_core::TraceFlag grpc_timer_check_trace;
+
+static int cb_called[MAX_CB][2];
+
+static void cb(void* arg, grpc_error* error) {
+ cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++;
+}
+
+static void add_test(void) {
+ int i;
+ grpc_timer timers[20];
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_log(GPR_INFO, "add_test");
+
+ grpc_timer_list_init();
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace);
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace);
+ memset(cb_called, 0, sizeof(cb_called));
+
+ grpc_millis start = grpc_core::ExecCtx::Get()->Now();
+
+ /* 10 ms timers. will expire in the current epoch */
+ for (i = 0; i < 10; i++) {
+ grpc_timer_init(
+ &timers[i], start + 10,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx));
+ }
+
+ /* 1010 ms timers. will expire in the next epoch */
+ for (i = 10; i < 20; i++) {
+ grpc_timer_init(
+ &timers[i], start + 1010,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx));
+ }
+
+ /* collect timers. Only the first batch should be ready. */
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 500);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+ grpc_core::ExecCtx::Get()->Flush();
+ for (i = 0; i < 20; i++) {
+ GPR_ASSERT(cb_called[i][1] == (i < 10));
+ GPR_ASSERT(cb_called[i][0] == 0);
+ }
+
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 600);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_CHECKED_AND_EMPTY);
+ grpc_core::ExecCtx::Get()->Flush();
+ for (i = 0; i < 30; i++) {
+ GPR_ASSERT(cb_called[i][1] == (i < 10));
+ GPR_ASSERT(cb_called[i][0] == 0);
+ }
+
+ /* collect the rest of the timers */
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 1500);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+ grpc_core::ExecCtx::Get()->Flush();
+ for (i = 0; i < 30; i++) {
+ GPR_ASSERT(cb_called[i][1] == (i < 20));
+ GPR_ASSERT(cb_called[i][0] == 0);
+ }
+
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 1600);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_CHECKED_AND_EMPTY);
+ for (i = 0; i < 30; i++) {
+ GPR_ASSERT(cb_called[i][1] == (i < 20));
+ GPR_ASSERT(cb_called[i][0] == 0);
+ }
+
+ grpc_timer_list_shutdown();
+}
+
+/* Cleaning up a list with pending timers. */
+void destruction_test(void) {
+ grpc_timer timers[5];
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_log(GPR_INFO, "destruction_test");
+
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(0);
+ grpc_timer_list_init();
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace);
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace);
+ memset(cb_called, 0, sizeof(cb_called));
+
+ grpc_timer_init(
+ &timers[0], 100,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)0, grpc_schedule_on_exec_ctx));
+ grpc_timer_init(
+ &timers[1], 3,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)1, grpc_schedule_on_exec_ctx));
+ grpc_timer_init(
+ &timers[2], 100,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)2, grpc_schedule_on_exec_ctx));
+ grpc_timer_init(
+ &timers[3], 3,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)3, grpc_schedule_on_exec_ctx));
+ grpc_timer_init(
+ &timers[4], 1,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx));
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(2);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(1 == cb_called[4][1]);
+ grpc_timer_cancel(&timers[0]);
+ grpc_timer_cancel(&timers[3]);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(1 == cb_called[0][0]);
+ GPR_ASSERT(1 == cb_called[3][0]);
+
+ grpc_timer_list_shutdown();
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(1 == cb_called[1][0]);
+ GPR_ASSERT(1 == cb_called[2][0]);
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_core::ExecCtx::GlobalInit();
+ gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
+ add_test();
+ destruction_test();
+ grpc_core::ExecCtx::GlobalShutdown();
+ return 0;
+}
+
+#else /* GRPC_TIMER_USE_GENERIC */
+
+int main(int argc, char** argv) { return 1; }
+
+#endif /* GRPC_TIMER_USE_GENERIC */
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.cc
index 1d051bea62..09f0283013 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.cc
@@ -43,14 +43,20 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
-static grpc_pollset *g_pollset;
-static gpr_mu *g_mu;
+static grpc_pollset* g_pollset;
+static gpr_mu* g_mu;
static int g_number_of_reads = 0;
static int g_number_of_writes = 0;
static int g_number_of_bytes_read = 0;
static int g_number_of_orphan_calls = 0;
+static int g_number_of_starts = 0;
-static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) {
+int rcv_buf_size = 1024;
+int snd_buf_size = 1024;
+
+static void on_start(grpc_fd* emfd, void* user_data) { g_number_of_starts++; }
+
+static bool on_read(grpc_fd* emfd) {
char read_buffer[512];
ssize_t byte_count;
@@ -61,24 +67,27 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) {
g_number_of_reads++;
g_number_of_bytes_read += (int)byte_count;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
+ return false;
}
-static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) {
+static void on_write(grpc_fd* emfd, void* user_data,
+ grpc_closure* notify_on_write_closure) {
gpr_mu_lock(g_mu);
g_number_of_writes++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
- grpc_closure *closure, void *user_data) {
+static void on_fd_orphaned(grpc_fd* emfd, grpc_closure* closure,
+ void* user_data) {
gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d",
grpc_fd_wrapped_fd(emfd));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
g_number_of_orphan_calls++;
}
@@ -89,27 +98,27 @@ struct test_socket_factory {
};
typedef struct test_socket_factory test_socket_factory;
-static int test_socket_factory_socket(grpc_socket_factory *factory, int domain,
+static int test_socket_factory_socket(grpc_socket_factory* factory, int domain,
int type, int protocol) {
- test_socket_factory *f = (test_socket_factory *)factory;
+ test_socket_factory* f = (test_socket_factory*)factory;
f->number_of_socket_calls++;
return socket(domain, type, protocol);
}
-static int test_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
- const grpc_resolved_address *addr) {
- test_socket_factory *f = (test_socket_factory *)factory;
+static int test_socket_factory_bind(grpc_socket_factory* factory, int sockfd,
+ const grpc_resolved_address* addr) {
+ test_socket_factory* f = (test_socket_factory*)factory;
f->number_of_bind_calls++;
- return bind(sockfd, (struct sockaddr *)addr->addr, (socklen_t)addr->len);
+ return bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len);
}
-static int test_socket_factory_compare(grpc_socket_factory *a,
- grpc_socket_factory *b) {
+static int test_socket_factory_compare(grpc_socket_factory* a,
+ grpc_socket_factory* b) {
return GPR_ICMP(a, b);
}
-static void test_socket_factory_destroy(grpc_socket_factory *factory) {
- test_socket_factory *f = (test_socket_factory *)factory;
+static void test_socket_factory_destroy(grpc_socket_factory* factory) {
+ test_socket_factory* f = (test_socket_factory*)factory;
gpr_free(f);
}
@@ -117,117 +126,142 @@ static const grpc_socket_factory_vtable test_socket_factory_vtable = {
test_socket_factory_socket, test_socket_factory_bind,
test_socket_factory_compare, test_socket_factory_destroy};
-static test_socket_factory *test_socket_factory_create(void) {
- test_socket_factory *factory = gpr_malloc(sizeof(test_socket_factory));
+static test_socket_factory* test_socket_factory_create(void) {
+ test_socket_factory* factory = static_cast<test_socket_factory*>(
+ gpr_malloc(sizeof(test_socket_factory)));
grpc_socket_factory_init(&factory->base, &test_socket_factory_vtable);
factory->number_of_socket_calls = 0;
factory->number_of_bind_calls = 0;
return factory;
}
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
+}
+
+static void shutdown_and_destroy_pollset() {
+ gpr_mu_lock(g_mu);
+ auto closure = GRPC_CLOSURE_CREATE(destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, closure);
+ gpr_mu_unlock(g_mu);
+ /* Flush exec_ctx to run |destroyed| */
+ grpc_core::ExecCtx::Get()->Flush();
+}
+
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_udp_server *s = grpc_udp_server_create(NULL);
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_udp_server* s = grpc_udp_server_create(nullptr);
+ LOG_TEST("test_no_op");
+ grpc_udp_server_destroy(s, nullptr);
+ shutdown_and_destroy_pollset();
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_udp_server *s = grpc_udp_server_create(NULL);
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_start");
- grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_start(s, nullptr, 0, nullptr);
+ grpc_udp_server_destroy(s, nullptr);
+ shutdown_and_destroy_pollset();
}
static void test_no_op_with_port(void) {
+ grpc_pollset_init(g_pollset, &g_mu);
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_udp_server *s = grpc_udp_server_create(NULL);
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
on_fd_orphaned));
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which should have been orphaned. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
+ shutdown_and_destroy_pollset();
}
static void test_no_op_with_port_and_socket_factory(void) {
+ grpc_pollset_init(g_pollset, &g_mu);
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
- test_socket_factory *socket_factory = test_socket_factory_create();
+ test_socket_factory* socket_factory = test_socket_factory_create();
grpc_arg socket_factory_arg =
grpc_socket_factory_to_arg(&socket_factory->base);
- grpc_channel_args *channel_args =
- grpc_channel_args_copy_and_add(NULL, &socket_factory_arg, 1);
- grpc_udp_server *s = grpc_udp_server_create(channel_args);
- grpc_channel_args_destroy(&exec_ctx, channel_args);
+ grpc_channel_args* channel_args =
+ grpc_channel_args_copy_and_add(nullptr, &socket_factory_arg, 1);
+ grpc_udp_server* s = grpc_udp_server_create(channel_args);
+ grpc_channel_args_destroy(channel_args);
LOG_TEST("test_no_op_with_port_and_socket_factory");
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
on_fd_orphaned));
GPR_ASSERT(socket_factory->number_of_socket_calls == 1);
GPR_ASSERT(socket_factory->number_of_bind_calls == 1);
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
+
grpc_socket_factory_unref(&socket_factory->base);
/* The server had a single FD, which should have been orphaned. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
+ shutdown_and_destroy_pollset();
}
static void test_no_op_with_port_and_start(void) {
+ grpc_pollset_init(g_pollset, &g_mu);
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_udp_server *s = grpc_udp_server_create(NULL);
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_port_and_start");
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
on_fd_orphaned));
- grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
-
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_start(s, nullptr, 0, nullptr);
+ GPR_ASSERT(g_number_of_starts == 1);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
+ shutdown_and_destroy_pollset();
}
static void test_receive(int number_of_clients) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
+ struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int clifd, svrfd;
- grpc_udp_server *s = grpc_udp_server_create(NULL);
+ grpc_udp_server* s = grpc_udp_server_create(nullptr);
int i;
- int number_of_reads_before;
- gpr_timespec deadline;
- grpc_pollset *pollsets[1];
+ grpc_millis deadline;
+ grpc_pollset* pollsets[1];
LOG_TEST("test_receive");
gpr_log(GPR_INFO, "clients=%d", number_of_clients);
@@ -237,91 +271,78 @@ static void test_receive(int number_of_clients) {
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_storage);
addr->ss_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
on_fd_orphaned));
svrfd = grpc_udp_server_get_fd(s, 0);
GPR_ASSERT(svrfd >= 0);
- GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)addr,
- (socklen_t *)&resolved_addr.len) == 0);
+ GPR_ASSERT(getsockname(svrfd, (struct sockaddr*)addr,
+ (socklen_t*)&resolved_addr.len) == 0);
GPR_ASSERT(resolved_addr.len <= sizeof(struct sockaddr_storage));
pollsets[0] = g_pollset;
- grpc_udp_server_start(&exec_ctx, s, pollsets, 1, NULL);
+ grpc_udp_server_start(s, pollsets, 1, nullptr);
gpr_mu_lock(g_mu);
for (i = 0; i < number_of_clients; i++) {
- deadline = grpc_timeout_seconds_to_deadline(10);
+ deadline =
+ grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
- number_of_reads_before = g_number_of_reads;
+ int number_of_bytes_read_before = g_number_of_bytes_read;
/* Create a socket, send a packet to the UDP server. */
clifd = socket(addr->ss_family, SOCK_DGRAM, 0);
GPR_ASSERT(clifd >= 0);
- GPR_ASSERT(connect(clifd, (struct sockaddr *)addr,
+ GPR_ASSERT(connect(clifd, (struct sockaddr*)addr,
(socklen_t)resolved_addr.len) == 0);
GPR_ASSERT(5 == write(clifd, "hello", 5));
- while (g_number_of_reads == number_of_reads_before &&
- gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
- grpc_pollset_worker *worker = NULL;
+ while (g_number_of_bytes_read < (number_of_bytes_read_before + 5) &&
+ deadline > grpc_core::ExecCtx::Get()->Now()) {
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
- GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1);
close(clifd);
}
GPR_ASSERT(g_number_of_bytes_read == 5 * number_of_clients);
gpr_mu_unlock(g_mu);
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
-
- /* The write callback should have fired a few times. */
- GPR_ASSERT(g_number_of_writes > 0);
+ shutdown_and_destroy_pollset();
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, p);
-}
-
-int main(int argc, char **argv) {
- grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
-
- test_no_op();
- test_no_op_with_start();
- test_no_op_with_port();
- test_no_op_with_port_and_socket_factory();
- test_no_op_with_port_and_start();
- test_receive(1);
- test_receive(10);
-
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
- gpr_free(g_pollset);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+
+ test_no_op();
+ test_no_op_with_start();
+ test_no_op_with_port();
+ test_no_op_with_port_and_socket_factory();
+ test_no_op_with_port_and_start();
+ test_receive(1);
+ test_receive(10);
+
+ gpr_free(g_pollset);
+ }
grpc_shutdown();
return 0;
}
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/wakeup_fd_cv_test.c b/test/core/iomgr/wakeup_fd_cv_test.cc
index 0b211274f2..c092a8f3bf 100644
--- a/test/core/iomgr/wakeup_fd_cv_test.c
+++ b/test/core/iomgr/wakeup_fd_cv_test.cc
@@ -27,12 +27,12 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_posix.h"
-#include "src/core/lib/support/env.h"
typedef struct poll_args {
- struct pollfd *fds;
+ struct pollfd* fds;
nfds_t nfds;
int timeout;
int result;
@@ -57,7 +57,7 @@ void reset_socket_event() {
}
// Mocks posix poll() function
-int mock_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
+int mock_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
int res = 0;
gpr_timespec poll_time;
gpr_mu_lock(&poll_mu);
@@ -84,8 +84,8 @@ int mock_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
return res;
}
-void background_poll(void *args) {
- poll_args *pargs = (poll_args *)args;
+void background_poll(void* args) {
+ poll_args* pargs = (poll_args*)args;
pargs->result = grpc_poll_function(pargs->fds, pargs->nfds, pargs->timeout);
}
@@ -138,7 +138,7 @@ void test_poll_cv_trigger(void) {
opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&t_id, &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
// Wakeup wakeup_fd not listening for events
GPR_ASSERT(grpc_wakeup_fd_wakeup(&cvfd1) == GRPC_ERROR_NONE);
@@ -154,7 +154,7 @@ void test_poll_cv_trigger(void) {
// Pollin on socket fd
pargs.timeout = -1;
pargs.result = -2;
- gpr_thd_new(&t_id, &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
trigger_socket_event();
gpr_thd_join(t_id);
GPR_ASSERT(pargs.result == 1);
@@ -168,7 +168,7 @@ void test_poll_cv_trigger(void) {
// Pollin on wakeup fd
reset_socket_event();
pargs.result = -2;
- gpr_thd_new(&t_id, &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
GPR_ASSERT(grpc_wakeup_fd_wakeup(&cvfd2) == GRPC_ERROR_NONE);
gpr_thd_join(t_id);
@@ -182,7 +182,7 @@ void test_poll_cv_trigger(void) {
// Pollin on wakeupfd before poll()
pargs.result = -2;
- gpr_thd_new(&t_id, &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
gpr_thd_join(t_id);
GPR_ASSERT(pargs.result == 1);
@@ -199,7 +199,7 @@ void test_poll_cv_trigger(void) {
reset_socket_event();
GPR_ASSERT(grpc_wakeup_fd_consume_wakeup(&cvfd1) == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_wakeup_fd_consume_wakeup(&cvfd2) == GRPC_ERROR_NONE);
- gpr_thd_new(&t_id, &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
gpr_thd_join(t_id);
GPR_ASSERT(pargs.result == 0);
@@ -211,7 +211,7 @@ void test_poll_cv_trigger(void) {
GPR_ASSERT(pfds[5].revents == 0);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
gpr_setenv("GRPC_POLL_STRATEGY", "poll-cv");
grpc_poll_function = &mock_poll;
gpr_mu_init(&poll_mu);
@@ -229,6 +229,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) { return 1; }
+int main(int argc, char** argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/json/BUILD b/test/core/json/BUILD
index 3ff7918677..b8b36c0652 100644
--- a/test/core/json/BUILD
+++ b/test/core/json/BUILD
@@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "json_fuzzer",
- srcs = ["fuzzer.c"],
- language = "C",
+ srcs = ["fuzzer.cc"],
+ language = "C++",
corpus = "corpus",
deps = [
"//:gpr",
@@ -35,8 +35,8 @@ grpc_fuzzer(
grpc_cc_binary(
name = "json_rewrite",
testonly = 1,
- srcs = ["json_rewrite.c"],
- language = "C",
+ srcs = ["json_rewrite.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -47,8 +47,8 @@ grpc_cc_binary(
grpc_cc_test(
name = "json_rewrite_test",
- srcs = ["json_rewrite_test.c"],
- language = "C",
+ srcs = ["json_rewrite_test.cc"],
+ language = "C++",
data = [
"rewrite_test_input.json",
"rewrite_test_output_condensed.json",
@@ -65,8 +65,8 @@ grpc_cc_test(
grpc_cc_test(
name = "json_stream_error_test",
- srcs = ["json_stream_error_test.c"],
- language = "C",
+ srcs = ["json_stream_error_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -77,8 +77,8 @@ grpc_cc_test(
grpc_cc_test(
name = "json_test",
- srcs = ["json_test.c"],
- language = "C",
+ srcs = ["json_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/json/fuzzer.c b/test/core/json/fuzzer.cc
index b825904d41..6dafabb95b 100644
--- a/test/core/json/fuzzer.c
+++ b/test/core/json/fuzzer.cc
@@ -29,13 +29,13 @@
bool squelch = true;
bool leak_check = true;
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- char *s;
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ char* s;
struct grpc_memory_counters counters;
grpc_memory_counters_init();
- s = gpr_malloc(size);
+ s = static_cast<char*>(gpr_malloc(size));
memcpy(s, data, size);
- grpc_json *x;
+ grpc_json* x;
if ((x = grpc_json_parse_string_with_len(s, size))) {
grpc_json_destroy(x);
}
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.cc
index dfe32f5adf..6891a57f9f 100644
--- a/test/core/json/json_rewrite.c
+++ b/test/core/json/json_rewrite.cc
@@ -26,37 +26,39 @@
#include "src/core/lib/json/json_reader.h"
#include "src/core/lib/json/json_writer.h"
-typedef struct json_writer_userdata { FILE *out; } json_writer_userdata;
+typedef struct json_writer_userdata {
+ FILE* out;
+} json_writer_userdata;
typedef struct stacked_container {
grpc_json_type type;
- struct stacked_container *next;
+ struct stacked_container* next;
} stacked_container;
typedef struct json_reader_userdata {
- FILE *in;
- grpc_json_writer *writer;
- char *scratchpad;
- char *ptr;
+ FILE* in;
+ grpc_json_writer* writer;
+ char* scratchpad;
+ char* ptr;
size_t free_space;
size_t allocated;
size_t string_len;
- stacked_container *top;
+ stacked_container* top;
} json_reader_userdata;
-static void json_writer_output_char(void *userdata, char c) {
- json_writer_userdata *state = userdata;
+static void json_writer_output_char(void* userdata, char c) {
+ json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata);
fputc(c, state->out);
}
-static void json_writer_output_string(void *userdata, const char *str) {
- json_writer_userdata *state = userdata;
+static void json_writer_output_string(void* userdata, const char* str) {
+ json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata);
fputs(str, state->out);
}
-static void json_writer_output_string_with_len(void *userdata, const char *str,
+static void json_writer_output_string_with_len(void* userdata, const char* str,
size_t len) {
- json_writer_userdata *state = userdata;
+ json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata);
fwrite(str, len, 1, state->out);
}
@@ -64,29 +66,30 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char,
json_writer_output_string,
json_writer_output_string_with_len};
-static void check_string(json_reader_userdata *state, size_t needed) {
+static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
needed = (needed + 0xffu) & ~0xffu;
- state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
+ state->scratchpad = static_cast<char*>(
+ gpr_realloc(state->scratchpad, state->allocated + needed));
state->free_space += needed;
state->allocated += needed;
}
-static void json_reader_string_clear(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_string_clear(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
state->free_space = state->allocated;
state->string_len = 0;
}
-static void json_reader_string_add_char(void *userdata, uint32_t c) {
- json_reader_userdata *state = userdata;
+static void json_reader_string_add_char(void* userdata, uint32_t c) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
check_string(state, 1);
GPR_ASSERT(c < 256);
state->scratchpad[state->string_len++] = (char)c;
}
-static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
+static void json_reader_string_add_utf32(void* userdata, uint32_t c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) {
@@ -113,18 +116,19 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
}
}
-static uint32_t json_reader_read_char(void *userdata) {
+static uint32_t json_reader_read_char(void* userdata) {
int r;
- json_reader_userdata *state = userdata;
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
return (uint32_t)r;
}
-static void json_reader_container_begins(void *userdata, grpc_json_type type) {
- json_reader_userdata *state = userdata;
- stacked_container *container = gpr_malloc(sizeof(stacked_container));
+static void json_reader_container_begins(void* userdata, grpc_json_type type) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
+ stacked_container* container =
+ static_cast<stacked_container*>(gpr_malloc(sizeof(stacked_container)));
container->type = type;
container->next = state->top;
@@ -133,9 +137,9 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) {
grpc_json_writer_container_begins(state->writer, type);
}
-static grpc_json_type json_reader_container_ends(void *userdata) {
- json_reader_userdata *state = userdata;
- stacked_container *container = state->top;
+static grpc_json_type json_reader_container_ends(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
+ stacked_container* container = state->top;
grpc_json_writer_container_ends(state->writer, container->type);
state->top = container->next;
@@ -143,22 +147,22 @@ static grpc_json_type json_reader_container_ends(void *userdata) {
return state->top ? state->top->type : GRPC_JSON_TOP_LEVEL;
}
-static void json_reader_set_key(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_key(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_object_key(state->writer, state->scratchpad);
}
-static void json_reader_set_string(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_string(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_value_string(state->writer, state->scratchpad);
}
-static int json_reader_set_number(void *userdata) {
- json_reader_userdata *state = userdata;
+static int json_reader_set_number(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, state->scratchpad,
state->string_len);
@@ -166,20 +170,20 @@ static int json_reader_set_number(void *userdata) {
return 1;
}
-static void json_reader_set_true(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_true(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "true", 4);
}
-static void json_reader_set_false(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_false(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "false", 5);
}
-static void json_reader_set_null(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_null(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "null", 4);
}
@@ -192,7 +196,7 @@ static grpc_json_reader_vtable reader_vtable = {
json_reader_set_number, json_reader_set_true,
json_reader_set_false, json_reader_set_null};
-int rewrite(FILE *in, FILE *out, int indent) {
+int rewrite(FILE* in, FILE* out, int indent) {
grpc_json_writer writer;
grpc_json_reader reader;
grpc_json_reader_status status;
@@ -201,8 +205,8 @@ int rewrite(FILE *in, FILE *out, int indent) {
reader_user.writer = &writer;
reader_user.in = in;
- reader_user.top = NULL;
- reader_user.scratchpad = NULL;
+ reader_user.top = nullptr;
+ reader_user.scratchpad = nullptr;
reader_user.string_len = 0;
reader_user.free_space = 0;
reader_user.allocated = 0;
@@ -216,7 +220,7 @@ int rewrite(FILE *in, FILE *out, int indent) {
free(reader_user.scratchpad);
while (reader_user.top) {
- stacked_container *container = reader_user.top;
+ stacked_container* container = reader_user.top;
reader_user.top = container->next;
free(container);
}
@@ -224,12 +228,12 @@ int rewrite(FILE *in, FILE *out, int indent) {
return status == GRPC_JSON_DONE;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int indent = 2;
- gpr_cmdline *cl;
+ gpr_cmdline* cl;
- cl = gpr_cmdline_create(NULL);
- gpr_cmdline_add_int(cl, "indent", NULL, &indent);
+ cl = gpr_cmdline_create(nullptr);
+ gpr_cmdline_add_int(cl, "indent", nullptr, &indent);
gpr_cmdline_parse(cl, argc, argv);
gpr_cmdline_destroy(cl);
diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.cc
index a654971b34..3104afc442 100644
--- a/test/core/json/json_rewrite_test.c
+++ b/test/core/json/json_rewrite_test.cc
@@ -27,27 +27,29 @@
#include "src/core/lib/json/json_reader.h"
#include "src/core/lib/json/json_writer.h"
-typedef struct json_writer_userdata { FILE *cmp; } json_writer_userdata;
+typedef struct json_writer_userdata {
+ FILE* cmp;
+} json_writer_userdata;
typedef struct stacked_container {
grpc_json_type type;
- struct stacked_container *next;
+ struct stacked_container* next;
} stacked_container;
typedef struct json_reader_userdata {
- FILE *in;
- grpc_json_writer *writer;
- char *scratchpad;
- char *ptr;
+ FILE* in;
+ grpc_json_writer* writer;
+ char* scratchpad;
+ char* ptr;
size_t free_space;
size_t allocated;
size_t string_len;
- stacked_container *top;
+ stacked_container* top;
int did_eagain;
} json_reader_userdata;
-static void json_writer_output_char(void *userdata, char c) {
- json_writer_userdata *state = userdata;
+static void json_writer_output_char(void* userdata, char c) {
+ json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata);
int cmp = fgetc(state->cmp);
/* treat CRLF as LF */
@@ -57,13 +59,13 @@ static void json_writer_output_char(void *userdata, char c) {
GPR_ASSERT(cmp == c);
}
-static void json_writer_output_string(void *userdata, const char *str) {
+static void json_writer_output_string(void* userdata, const char* str) {
while (*str) {
json_writer_output_char(userdata, *str++);
}
}
-static void json_writer_output_string_with_len(void *userdata, const char *str,
+static void json_writer_output_string_with_len(void* userdata, const char* str,
size_t len) {
size_t i;
for (i = 0; i < len; i++) {
@@ -75,29 +77,30 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char,
json_writer_output_string,
json_writer_output_string_with_len};
-static void check_string(json_reader_userdata *state, size_t needed) {
+static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
needed = (needed + 0xffu) & ~0xffu;
- state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
+ state->scratchpad = static_cast<char*>(
+ gpr_realloc(state->scratchpad, state->allocated + needed));
state->free_space += needed;
state->allocated += needed;
}
-static void json_reader_string_clear(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_string_clear(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
state->free_space = state->allocated;
state->string_len = 0;
}
-static void json_reader_string_add_char(void *userdata, uint32_t c) {
- json_reader_userdata *state = userdata;
+static void json_reader_string_add_char(void* userdata, uint32_t c) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
check_string(state, 1);
GPR_ASSERT(c <= 256);
state->scratchpad[state->string_len++] = (char)c;
}
-static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
+static void json_reader_string_add_utf32(void* userdata, uint32_t c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ffu) {
@@ -124,9 +127,9 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) {
}
}
-static uint32_t json_reader_read_char(void *userdata) {
+static uint32_t json_reader_read_char(void* userdata) {
int r;
- json_reader_userdata *state = userdata;
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
if (!state->did_eagain) {
state->did_eagain = 1;
@@ -140,9 +143,10 @@ static uint32_t json_reader_read_char(void *userdata) {
return (uint32_t)r;
}
-static void json_reader_container_begins(void *userdata, grpc_json_type type) {
- json_reader_userdata *state = userdata;
- stacked_container *container = gpr_malloc(sizeof(stacked_container));
+static void json_reader_container_begins(void* userdata, grpc_json_type type) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
+ stacked_container* container =
+ static_cast<stacked_container*>(gpr_malloc(sizeof(stacked_container)));
container->type = type;
container->next = state->top;
@@ -151,9 +155,9 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) {
grpc_json_writer_container_begins(state->writer, type);
}
-static grpc_json_type json_reader_container_ends(void *userdata) {
- json_reader_userdata *state = userdata;
- stacked_container *container = state->top;
+static grpc_json_type json_reader_container_ends(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
+ stacked_container* container = state->top;
grpc_json_writer_container_ends(state->writer, container->type);
state->top = container->next;
@@ -161,22 +165,22 @@ static grpc_json_type json_reader_container_ends(void *userdata) {
return state->top ? state->top->type : GRPC_JSON_TOP_LEVEL;
}
-static void json_reader_set_key(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_key(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_object_key(state->writer, state->scratchpad);
}
-static void json_reader_set_string(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_string(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
json_reader_string_add_char(userdata, 0);
grpc_json_writer_value_string(state->writer, state->scratchpad);
}
-static int json_reader_set_number(void *userdata) {
- json_reader_userdata *state = userdata;
+static int json_reader_set_number(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, state->scratchpad,
state->string_len);
@@ -184,20 +188,20 @@ static int json_reader_set_number(void *userdata) {
return 1;
}
-static void json_reader_set_true(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_true(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "true", 4);
}
-static void json_reader_set_false(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_false(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "false", 5);
}
-static void json_reader_set_null(void *userdata) {
- json_reader_userdata *state = userdata;
+static void json_reader_set_null(void* userdata) {
+ json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
grpc_json_writer_value_raw_with_len(state->writer, "null", 4);
}
@@ -210,7 +214,7 @@ static grpc_json_reader_vtable reader_vtable = {
json_reader_set_number, json_reader_set_true,
json_reader_set_false, json_reader_set_null};
-int rewrite_and_compare(FILE *in, FILE *cmp, int indent) {
+int rewrite_and_compare(FILE* in, FILE* cmp, int indent) {
grpc_json_writer writer;
grpc_json_reader reader;
grpc_json_reader_status status;
@@ -222,8 +226,8 @@ int rewrite_and_compare(FILE *in, FILE *cmp, int indent) {
reader_user.writer = &writer;
reader_user.in = in;
- reader_user.top = NULL;
- reader_user.scratchpad = NULL;
+ reader_user.top = nullptr;
+ reader_user.scratchpad = nullptr;
reader_user.string_len = 0;
reader_user.free_space = 0;
reader_user.allocated = 0;
@@ -240,7 +244,7 @@ int rewrite_and_compare(FILE *in, FILE *cmp, int indent) {
free(reader_user.scratchpad);
while (reader_user.top) {
- stacked_container *container = reader_user.top;
+ stacked_container* container = reader_user.top;
reader_user.top = container->next;
free(container);
}
@@ -249,8 +253,8 @@ int rewrite_and_compare(FILE *in, FILE *cmp, int indent) {
}
typedef struct test_file {
- const char *input;
- const char *cmp;
+ const char* input;
+ const char* cmp;
int indent;
} test_file;
@@ -269,9 +273,9 @@ void test_rewrites() {
unsigned i;
for (i = 0; i < GPR_ARRAY_SIZE(test_files); i++) {
- test_file *test = test_files + i;
- FILE *input = fopen(test->input, "rb");
- FILE *cmp = fopen(test->cmp, "rb");
+ test_file* test = test_files + i;
+ FILE* input = fopen(test->input, "rb");
+ FILE* cmp = fopen(test->cmp, "rb");
int status;
gpr_log(GPR_INFO, "Testing file %s against %s using indent=%i", test->input,
test->cmp, test->indent);
@@ -282,7 +286,7 @@ void test_rewrites() {
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_rewrites();
gpr_log(GPR_INFO, "json_rewrite_test success");
diff --git a/test/core/json/json_stream_error_test.c b/test/core/json/json_stream_error_test.cc
index 379cd5d078..b367d3fbf7 100644
--- a/test/core/json/json_stream_error_test.c
+++ b/test/core/json/json_stream_error_test.cc
@@ -29,27 +29,27 @@
static int g_string_clear_once = 0;
-static void string_clear(void *userdata) {
+static void string_clear(void* userdata) {
GPR_ASSERT(!g_string_clear_once);
g_string_clear_once = 1;
}
-static uint32_t read_char(void *userdata) { return GRPC_JSON_READ_CHAR_ERROR; }
+static uint32_t read_char(void* userdata) { return GRPC_JSON_READ_CHAR_ERROR; }
static grpc_json_reader_vtable reader_vtable = {
- string_clear, NULL, NULL, read_char, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL};
+ string_clear, nullptr, nullptr, read_char, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
static void read_error() {
grpc_json_reader reader;
grpc_json_reader_status status;
- grpc_json_reader_init(&reader, &reader_vtable, NULL);
+ grpc_json_reader_init(&reader, &reader_vtable, nullptr);
status = grpc_json_reader_run(&reader);
GPR_ASSERT(status == GRPC_JSON_READ_ERROR);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
read_error();
gpr_log(GPR_INFO, "json_stream_error success");
diff --git a/test/core/json/json_test.c b/test/core/json/json_test.cc
index bbc6f7a4e6..902f1cd90e 100644
--- a/test/core/json/json_test.c
+++ b/test/core/json/json_test.cc
@@ -22,14 +22,14 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/json/json.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
typedef struct testing_pair {
- const char *input;
- const char *output;
+ const char* input;
+ const char* output;
} testing_pair;
static testing_pair testing_pairs[] = {
@@ -52,7 +52,8 @@ static testing_pair testing_pairs[] = {
{"{\"\\ud834\\udd1e\":0}", "{\"\\ud834\\udd1e\":0}"},
/* Testing nested empty containers. */
{
- " [ [ ] , { } , [ ] ] ", "[[],{},[]]",
+ " [ [ ] , { } , [ ] ] ",
+ "[[],{},[]]",
},
/* Testing escapes and control chars in key strings. */
{" { \"\\u007f\x7f\\n\\r\\\"\\f\\b\\\\a , b\": 1, \"\": 0 } ",
@@ -69,86 +70,86 @@ static testing_pair testing_pairs[] = {
/* Testing invalid parsing. */
/* Testing plain invalid things, exercising the state machine. */
- {"\\", NULL},
- {"nu ll", NULL},
- {"{\"foo\": bar}", NULL},
- {"{\"foo\": bar\"x\"}", NULL},
- {"fals", NULL},
- {"0,0 ", NULL},
- {"\"foo\",[]", NULL},
+ {"\\", nullptr},
+ {"nu ll", nullptr},
+ {"{\"foo\": bar}", nullptr},
+ {"{\"foo\": bar\"x\"}", nullptr},
+ {"fals", nullptr},
+ {"0,0 ", nullptr},
+ {"\"foo\",[]", nullptr},
/* Testing unterminated string. */
- {"\"\\x", NULL},
+ {"\"\\x", nullptr},
/* Testing invalid UTF-16 number. */
- {"\"\\u123x", NULL},
- {"{\"\\u123x", NULL},
+ {"\"\\u123x", nullptr},
+ {"{\"\\u123x", nullptr},
/* Testing imbalanced surrogate pairs. */
- {"\"\\ud834f", NULL},
- {"{\"\\ud834f\":0}", NULL},
- {"\"\\ud834\\n", NULL},
- {"{\"\\ud834\\n\":0}", NULL},
- {"\"\\udd1ef", NULL},
- {"{\"\\udd1ef\":0}", NULL},
- {"\"\\ud834\\ud834\"", NULL},
- {"{\"\\ud834\\ud834\"\":0}", NULL},
- {"\"\\ud834\\u1234\"", NULL},
- {"{\"\\ud834\\u1234\"\":0}", NULL},
- {"\"\\ud834]\"", NULL},
- {"{\"\\ud834]\"\":0}", NULL},
- {"\"\\ud834 \"", NULL},
- {"{\"\\ud834 \"\":0}", NULL},
- {"\"\\ud834\\\\\"", NULL},
- {"{\"\\ud834\\\\\"\":0}", NULL},
+ {"\"\\ud834f", nullptr},
+ {"{\"\\ud834f\":0}", nullptr},
+ {"\"\\ud834\\n", nullptr},
+ {"{\"\\ud834\\n\":0}", nullptr},
+ {"\"\\udd1ef", nullptr},
+ {"{\"\\udd1ef\":0}", nullptr},
+ {"\"\\ud834\\ud834\"", nullptr},
+ {"{\"\\ud834\\ud834\"\":0}", nullptr},
+ {"\"\\ud834\\u1234\"", nullptr},
+ {"{\"\\ud834\\u1234\"\":0}", nullptr},
+ {"\"\\ud834]\"", nullptr},
+ {"{\"\\ud834]\"\":0}", nullptr},
+ {"\"\\ud834 \"", nullptr},
+ {"{\"\\ud834 \"\":0}", nullptr},
+ {"\"\\ud834\\\\\"", nullptr},
+ {"{\"\\ud834\\\\\"\":0}", nullptr},
/* Testing embedded invalid whitechars. */
- {"\"\n\"", NULL},
- {"\"\t\"", NULL},
+ {"\"\n\"", nullptr},
+ {"\"\t\"", nullptr},
/* Testing empty json data. */
- {"", NULL},
+ {"", nullptr},
/* Testing extra characters after end of parsing. */
- {"{},", NULL},
+ {"{},", nullptr},
/* Testing imbalanced containers. */
- {"{}}", NULL},
- {"[]]", NULL},
- {"{{}", NULL},
- {"[[]", NULL},
- {"[}", NULL},
- {"{]", NULL},
+ {"{}}", nullptr},
+ {"[]]", nullptr},
+ {"{{}", nullptr},
+ {"[[]", nullptr},
+ {"[}", nullptr},
+ {"{]", nullptr},
/* Testing bad containers. */
- {"{x}", NULL},
- {"{x=0,y}", NULL},
+ {"{x}", nullptr},
+ {"{x=0,y}", nullptr},
/* Testing trailing comma. */
- {"{,}", NULL},
- {"[1,2,3,4,]", NULL},
- {"{\"a\": 1, }", NULL},
+ {"{,}", nullptr},
+ {"[1,2,3,4,]", nullptr},
+ {"{\"a\": 1, }", nullptr},
/* Testing after-ending characters. */
- {"{}x", NULL},
+ {"{}x", nullptr},
/* Testing having a key syntax in an array. */
- {"[\"x\":0]", NULL},
+ {"[\"x\":0]", nullptr},
/* Testing invalid numbers. */
- {"1.", NULL},
- {"1e", NULL},
- {".12", NULL},
- {"1.x", NULL},
- {"1.12x", NULL},
- {"1ex", NULL},
- {"1e12x", NULL},
- {".12x", NULL},
- {"000", NULL},
+ {"1.", nullptr},
+ {"1e", nullptr},
+ {".12", nullptr},
+ {"1.x", nullptr},
+ {"1.12x", nullptr},
+ {"1ex", nullptr},
+ {"1e12x", nullptr},
+ {".12x", nullptr},
+ {"000", nullptr},
};
static void test_pairs() {
unsigned i;
for (i = 0; i < GPR_ARRAY_SIZE(testing_pairs); i++) {
- testing_pair *pair = testing_pairs + i;
- char *scratchpad = gpr_strdup(pair->input);
- grpc_json *json;
+ testing_pair* pair = testing_pairs + i;
+ char* scratchpad = gpr_strdup(pair->input);
+ grpc_json* json;
gpr_log(GPR_INFO, "parsing string %i - should %s", i,
pair->output ? "succeed" : "fail");
json = grpc_json_parse_string(scratchpad);
if (pair->output) {
- char *output;
+ char* output;
GPR_ASSERT(json);
output = grpc_json_dump_to_string(json, 0);
@@ -168,9 +169,9 @@ static void test_pairs() {
}
static void test_atypical() {
- char *scratchpad = gpr_strdup("[[],[],[]]");
- grpc_json *json = grpc_json_parse_string(scratchpad);
- grpc_json *brother;
+ char* scratchpad = gpr_strdup("[[],[],[]]");
+ grpc_json* json = grpc_json_parse_string(scratchpad);
+ grpc_json* brother;
GPR_ASSERT(json);
GPR_ASSERT(json->child);
@@ -182,7 +183,7 @@ static void test_atypical() {
gpr_free(scratchpad);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_pairs();
test_atypical();
diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.cc
index 6392554d85..ca841434aa 100644
--- a/test/core/memory_usage/client.c
+++ b/test/core/memory_usage/client.cc
@@ -28,20 +28,20 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/memory_counters.h"
#include "test/core/util/test_config.h"
-static grpc_channel *channel;
-static grpc_completion_queue *cq;
+static grpc_channel* channel;
+static grpc_completion_queue* cq;
static grpc_op metadata_ops[2];
static grpc_op status_ops[2];
static grpc_op snapshot_ops[6];
-static grpc_op *op;
+static grpc_op* op;
typedef struct {
- grpc_call *call;
+ grpc_call* call;
grpc_metadata_array initial_metadata_recv;
grpc_status_code status;
grpc_slice details;
@@ -52,7 +52,7 @@ typedef struct {
// calls and 1 extra for the snapshot calls.
static fling_call calls[10001];
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
// A call is intentionally divided into two steps. First step is to initiate a
// call (i.e send and recv metadata). A call is outstanding after we initated,
@@ -73,15 +73,15 @@ static void init_ping_pong_request(int call_idx) {
grpc_slice hostname = grpc_slice_from_static_string("localhost");
calls[call_idx].call = grpc_channel_create_call(
- channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
+ channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/Reflector/reflectUnary"), &hostname,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
metadata_ops,
(size_t)(op - metadata_ops),
- tag(call_idx), NULL));
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ tag(call_idx), nullptr));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
}
// Second step is to finish the call (i.e recv status) and destroy the call.
@@ -100,13 +100,13 @@ static void finish_ping_pong_request(int call_idx) {
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
status_ops,
(size_t)(op - status_ops),
- tag(call_idx), NULL));
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ tag(call_idx), nullptr));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv);
grpc_metadata_array_destroy(&calls[call_idx].trailing_metadata_recv);
grpc_slice_unref(calls[call_idx].details);
grpc_call_unref(calls[call_idx].call);
- calls[call_idx].call = NULL;
+ calls[call_idx].call = nullptr;
}
static struct grpc_memory_counters send_snapshot_request(int call_idx,
@@ -114,7 +114,7 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx,
grpc_metadata_array_init(&calls[call_idx].initial_metadata_recv);
grpc_metadata_array_init(&calls[call_idx].trailing_metadata_recv);
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
memset(snapshot_ops, 0, sizeof(snapshot_ops));
op = snapshot_ops;
@@ -140,12 +140,13 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx,
grpc_slice hostname = grpc_slice_from_static_string("localhost");
calls[call_idx].call = grpc_channel_create_call(
- channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, call_type, &hostname,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
- calls[call_idx].call, snapshot_ops,
- (size_t)(op - snapshot_ops), (void *)0, NULL));
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, call_type, &hostname,
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call,
+ snapshot_ops,
+ (size_t)(op - snapshot_ops),
+ (void*)nullptr, nullptr));
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_byte_buffer_reader reader;
grpc_byte_buffer_reader_init(&reader, response_payload_recv);
@@ -153,16 +154,16 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx,
struct grpc_memory_counters snapshot;
snapshot.total_size_absolute =
- ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
->total_size_absolute;
snapshot.total_allocs_absolute =
- ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
->total_allocs_absolute;
snapshot.total_size_relative =
- ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
->total_size_relative;
snapshot.total_allocs_relative =
- ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response))
+ ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
->total_allocs_relative;
grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv);
@@ -173,18 +174,18 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx,
grpc_slice_unref(calls[call_idx].details);
calls[call_idx].details = grpc_empty_slice();
grpc_call_unref(calls[call_idx].call);
- calls[call_idx].call = NULL;
+ calls[call_idx].call = nullptr;
return snapshot;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_memory_counters_init();
grpc_slice slice = grpc_slice_from_copied_string("x");
- char *fake_argv[1];
+ char* fake_argv[1];
- char *target = "localhost:443";
- gpr_cmdline *cl;
+ const char* target = "localhost:443";
+ gpr_cmdline* cl;
grpc_event event;
grpc_init();
@@ -208,11 +209,11 @@ int main(int argc, char **argv) {
calls[k].details = grpc_empty_slice();
}
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
struct grpc_memory_counters client_channel_start =
grpc_memory_counters_snapshot();
- channel = grpc_insecure_channel_create(target, NULL, NULL);
+ channel = grpc_insecure_channel_create(target, nullptr, nullptr);
int call_idx = 0;
@@ -251,9 +252,10 @@ int main(int argc, char **argv) {
do {
event = grpc_completion_queue_next(
- cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_micros(10000, GPR_TIMESPAN)),
- NULL);
+ cq,
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(10000, GPR_TIMESPAN)),
+ nullptr);
} while (event.type != GRPC_QUEUE_TIMEOUT);
// second step - recv status and destroy call
@@ -273,7 +275,7 @@ int main(int argc, char **argv) {
do {
event = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
} while (event.type != GRPC_QUEUE_SHUTDOWN);
grpc_slice_unref(slice);
@@ -301,11 +303,11 @@ int main(int argc, char **argv) {
server_calls_end.total_size_relative -
after_server_create.total_size_relative);
- const char *csv_file = "memory_usage.csv";
- FILE *csv = fopen(csv_file, "w");
+ const char* csv_file = "memory_usage.csv";
+ FILE* csv = fopen(csv_file, "w");
if (csv) {
- char *env_build = gpr_getenv("BUILD_NUMBER");
- char *env_job = gpr_getenv("JOB_NAME");
+ char* env_build = gpr_getenv("BUILD_NUMBER");
+ char* env_job = gpr_getenv("JOB_NAME");
fprintf(csv, "%f,%zi,%zi,%f,%zi,%s,%s\n",
(double)(client_calls_inflight.total_size_relative -
client_benchmark_calls_start.total_size_relative) /
@@ -319,7 +321,8 @@ int main(int argc, char **argv) {
benchmark_iterations,
server_calls_end.total_size_relative -
after_server_create.total_size_relative,
- env_build == NULL ? "" : env_build, env_job == NULL ? "" : env_job);
+ env_build == nullptr ? "" : env_build,
+ env_job == nullptr ? "" : env_job);
fclose(csv);
gpr_log(GPR_INFO, "Summary written to %s", csv_file);
}
diff --git a/test/core/memory_usage/memory_usage_test.c b/test/core/memory_usage/memory_usage_test.cc
index f4ee6c65e3..fb6d290130 100644
--- a/test/core/memory_usage/memory_usage_test.c
+++ b/test/core/memory_usage/memory_usage_test.cc
@@ -23,15 +23,15 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/port.h"
-int main(int argc, char **argv) {
- char *me = argv[0];
- char *lslash = strrchr(me, '/');
+int main(int argc, char** argv) {
+ char* me = argv[0];
+ char* lslash = strrchr(me, '/');
char root[1024];
int port = grpc_pick_unused_port_or_die();
- char *args[10];
+ char* args[10];
int status;
gpr_subprocess *svr, *cli;
/* figure out where we are */
@@ -44,21 +44,21 @@ int main(int argc, char **argv) {
/* start the server */
gpr_asprintf(&args[0], "%s/memory_profile_server%s", root,
gpr_subprocess_binary_extension());
- args[1] = "--bind";
+ args[1] = const_cast<char*>("--bind");
gpr_join_host_port(&args[2], "::", port);
- args[3] = "--no-secure";
- svr = gpr_subprocess_create(4, (const char **)args);
+ args[3] = const_cast<char*>("--no-secure");
+ svr = gpr_subprocess_create(4, (const char**)args);
gpr_free(args[0]);
gpr_free(args[2]);
/* start the client */
gpr_asprintf(&args[0], "%s/memory_profile_client%s", root,
gpr_subprocess_binary_extension());
- args[1] = "--target";
+ args[1] = const_cast<char*>("--target");
gpr_join_host_port(&args[2], "127.0.0.1", port);
- args[3] = "--warmup=1000";
- args[4] = "--benchmark=9000";
- cli = gpr_subprocess_create(5, (const char **)args);
+ args[3] = const_cast<char*>("--warmup=1000");
+ args[4] = const_cast<char*>("--benchmark=9000");
+ cli = gpr_subprocess_create(5, (const char**)args);
gpr_free(args[0]);
gpr_free(args[2]);
diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.cc
index b25341ead2..45aeaea661 100644
--- a/test/core/memory_usage/server.c
+++ b/test/core/memory_usage/server.cc
@@ -39,17 +39,17 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static grpc_completion_queue *cq;
-static grpc_server *server;
+static grpc_completion_queue* cq;
+static grpc_server* server;
static grpc_op metadata_ops[2];
static grpc_op snapshot_ops[5];
static grpc_op status_op;
static int got_sigint = 0;
-static grpc_byte_buffer *payload_buffer = NULL;
-static grpc_byte_buffer *terminal_buffer = NULL;
+static grpc_byte_buffer* payload_buffer = nullptr;
+static grpc_byte_buffer* terminal_buffer = nullptr;
static int was_cancelled = 2;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
typedef enum {
FLING_SERVER_NEW_REQUEST = 1,
@@ -62,7 +62,7 @@ typedef enum {
typedef struct {
fling_server_tags state;
- grpc_call *call;
+ grpc_call* call;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
grpc_metadata_array initial_metadata_send;
@@ -82,33 +82,35 @@ static void request_call_unary(int call_idx) {
&calls[call_idx].request_metadata_recv, cq, cq, &calls[call_idx]);
}
-static void send_initial_metadata_unary(void *tag) {
- grpc_metadata_array_init(&(*(fling_call *)tag).initial_metadata_send);
+static void send_initial_metadata_unary(void* tag) {
+ grpc_metadata_array_init(&(*(fling_call*)tag).initial_metadata_send);
metadata_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
metadata_ops[0].data.send_initial_metadata.count = 0;
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call,
- metadata_ops, 1, tag, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call,
+ metadata_ops, 1, tag,
+ nullptr));
}
-static void send_status(void *tag) {
+static void send_status(void* tag) {
status_op.op = GRPC_OP_SEND_STATUS_FROM_SERVER;
status_op.data.send_status_from_server.status = GRPC_STATUS_OK;
status_op.data.send_status_from_server.trailing_metadata_count = 0;
grpc_slice details = grpc_slice_from_static_string("");
status_op.data.send_status_from_server.status_details = &details;
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call,
- &status_op, 1, tag, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call,
+ &status_op, 1, tag,
+ nullptr));
}
-static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) {
- grpc_op *op;
+static void send_snapshot(void* tag, struct grpc_memory_counters* snapshot) {
+ grpc_op* op;
grpc_slice snapshot_slice =
grpc_slice_new(snapshot, sizeof(*snapshot), gpr_free);
payload_buffer = grpc_raw_byte_buffer_create(&snapshot_slice, 1);
- grpc_metadata_array_init(&(*(fling_call *)tag).initial_metadata_send);
+ grpc_metadata_array_init(&(*(fling_call*)tag).initial_metadata_send);
op = snapshot_ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -118,7 +120,7 @@ static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) {
op->data.recv_message.recv_message = &terminal_buffer;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
- if (payload_buffer == NULL) {
+ if (payload_buffer == nullptr) {
gpr_log(GPR_INFO, "NULL payload buffer !!!");
}
op->data.send_message.send_message = payload_buffer;
@@ -134,26 +136,26 @@ static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) {
op++;
GPR_ASSERT(GRPC_CALL_OK ==
- grpc_call_start_batch((*(fling_call *)tag).call, snapshot_ops,
- (size_t)(op - snapshot_ops), tag, NULL));
+ grpc_call_start_batch((*(fling_call*)tag).call, snapshot_ops,
+ (size_t)(op - snapshot_ops), tag, nullptr));
}
/* We have some sort of deadlock, so let's not exit gracefully for now.
When that is resolved, please remove the #include <unistd.h> above. */
static void sigint_handler(int x) { _exit(0); }
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_memory_counters_init();
grpc_event ev;
- char *addr_buf = NULL;
- gpr_cmdline *cl;
- grpc_completion_queue *shutdown_cq;
+ char* addr_buf = nullptr;
+ gpr_cmdline* cl;
+ grpc_completion_queue* shutdown_cq;
int shutdown_started = 0;
int shutdown_finished = 0;
int secure = 0;
- char *addr = NULL;
+ const char* addr = nullptr;
- char *fake_argv[1];
+ char* fake_argv[1];
GPR_ASSERT(argc >= 1);
fake_argv[0] = argv[0];
@@ -168,37 +170,37 @@ int main(int argc, char **argv) {
gpr_cmdline_parse(cl, argc, argv);
gpr_cmdline_destroy(cl);
- if (addr == NULL) {
+ if (addr == nullptr) {
gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die());
addr = addr_buf;
}
gpr_log(GPR_INFO, "creating server on: %s", addr);
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
struct grpc_memory_counters before_server_create =
grpc_memory_counters_snapshot();
if (secure) {
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
- NULL, &pem_key_cert_pair, 1, 0, NULL);
- server = grpc_server_create(NULL, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_key_cert_pair, 1, 0, nullptr);
+ server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
grpc_server_credentials_release(ssl_creds);
} else {
- server = grpc_server_create(NULL, NULL);
+ server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr));
}
- grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_server_register_completion_queue(server, cq, nullptr);
grpc_server_start(server);
struct grpc_memory_counters after_server_create =
grpc_memory_counters_snapshot();
gpr_free(addr_buf);
- addr = addr_buf = NULL;
+ addr = addr_buf = nullptr;
// initialize call instances
for (int i = 0; i < (int)(sizeof(calls) / sizeof(fling_call)); i++) {
@@ -217,21 +219,22 @@ int main(int argc, char **argv) {
if (got_sigint && !shutdown_started) {
gpr_log(GPR_INFO, "Shutting down due to SIGINT");
- shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
+ shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000));
- GPR_ASSERT(
- grpc_completion_queue_pluck(shutdown_cq, tag(1000),
- grpc_timeout_seconds_to_deadline(5), NULL)
- .type == GRPC_OP_COMPLETE);
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ shutdown_cq, tag(1000),
+ grpc_timeout_seconds_to_deadline(5), nullptr)
+ .type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_completion_queue_shutdown(cq);
shutdown_started = 1;
}
ev = grpc_completion_queue_next(
- cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_micros(1000000, GPR_TIMESPAN)),
- NULL);
- fling_call *s = ev.tag;
+ cq,
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ nullptr);
+ fling_call* s = static_cast<fling_call*>(ev.tag);
switch (ev.type) {
case GRPC_OP_COMPLETE:
switch (s->state) {
@@ -286,6 +289,7 @@ int main(int argc, char **argv) {
}
// no break here since we want to continue to case
// FLING_SERVER_SEND_STATUS_SNAPSHOT to destroy the snapshot call
+ /* fallthrough */
case FLING_SERVER_SEND_STATUS_SNAPSHOT:
grpc_byte_buffer_destroy(payload_buffer);
grpc_byte_buffer_destroy(terminal_buffer);
@@ -293,8 +297,8 @@ int main(int argc, char **argv) {
grpc_call_details_destroy(&s->call_details);
grpc_metadata_array_destroy(&s->initial_metadata_send);
grpc_metadata_array_destroy(&s->request_metadata_recv);
- terminal_buffer = NULL;
- payload_buffer = NULL;
+ terminal_buffer = nullptr;
+ payload_buffer = nullptr;
break;
}
break;
diff --git a/test/core/nanopb/BUILD b/test/core/nanopb/BUILD
index f332207e2d..1497f829ab 100644
--- a/test/core/nanopb/BUILD
+++ b/test/core/nanopb/BUILD
@@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "fuzzer_response",
- srcs = ["fuzzer_response.c"],
- language = "C",
+ srcs = ["fuzzer_response.cc"],
+ language = "C++",
corpus = "corpus_response",
deps = [
"//:gpr",
@@ -34,8 +34,8 @@ grpc_fuzzer(
grpc_fuzzer(
name = "fuzzer_serverlist",
- srcs = ["fuzzer_serverlist.c"],
- language = "C",
+ srcs = ["fuzzer_serverlist.cc"],
+ language = "C++",
corpus = "corpus_serverlist",
deps = [
"//:gpr",
diff --git a/test/core/nanopb/fuzzer_response.c b/test/core/nanopb/fuzzer_response.cc
index c9b63979a1..3a70dea5e9 100644
--- a/test/core/nanopb/fuzzer_response.c
+++ b/test/core/nanopb/fuzzer_response.cc
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
@@ -26,15 +27,17 @@
bool squelch = true;
bool leak_check = true;
-static void dont_log(gpr_log_func_args *args) {}
+static void dont_log(gpr_log_func_args* args) {}
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ grpc_init();
if (squelch) gpr_set_log_function(dont_log);
- grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size);
- grpc_grpclb_initial_response *response;
+ grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
+ grpc_grpclb_initial_response* response;
if ((response = grpc_grpclb_initial_response_parse(slice))) {
grpc_grpclb_initial_response_destroy(response);
}
grpc_slice_unref(slice);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/nanopb/fuzzer_serverlist.c b/test/core/nanopb/fuzzer_serverlist.cc
index dd70f0c331..d0af117ef9 100644
--- a/test/core/nanopb/fuzzer_serverlist.c
+++ b/test/core/nanopb/fuzzer_serverlist.cc
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
@@ -26,15 +27,17 @@
bool squelch = true;
bool leak_check = true;
-static void dont_log(gpr_log_func_args *args) {}
+static void dont_log(gpr_log_func_args* args) {}
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ grpc_init();
if (squelch) gpr_set_log_function(dont_log);
- grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size);
- grpc_grpclb_serverlist *serverlist;
+ grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
+ grpc_grpclb_serverlist* serverlist;
if ((serverlist = grpc_grpclb_response_parse_serverlist(slice))) {
grpc_grpclb_destroy_serverlist(serverlist);
}
grpc_slice_unref(slice);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/network_benchmarks/BUILD b/test/core/network_benchmarks/BUILD
index 0e15393030..e1b4953608 100644
--- a/test/core/network_benchmarks/BUILD
+++ b/test/core/network_benchmarks/BUILD
@@ -22,8 +22,8 @@ licenses(["notice"]) # Apache v2
grpc_cc_binary(
name = "low_level_ping_pong",
- srcs = ["low_level_ping_pong.c"],
- language = "C",
+ srcs = ["low_level_ping_pong.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.cc
index 1550003eb9..fb982a10fd 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.c
+++ b/test/core/network_benchmarks/low_level_ping_pong.cc
@@ -36,13 +36,13 @@
#include <grpc/support/alloc.h>
#include <grpc/support/cmdline.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
+#include "test/core/util/histogram.h"
typedef struct fd_pair {
int read_fd;
@@ -52,11 +52,11 @@ typedef struct fd_pair {
typedef struct thread_args {
fd_pair fds;
size_t msg_size;
- int (*read_bytes)(struct thread_args *args, char *buf);
- int (*write_bytes)(struct thread_args *args, char *buf);
- int (*setup)(struct thread_args *args);
+ int (*read_bytes)(struct thread_args* args, char* buf);
+ int (*write_bytes)(struct thread_args* args, char* buf);
+ int (*setup)(struct thread_args* args);
int epoll_fd;
- char *strategy_name;
+ const char* strategy_name;
} thread_args;
/*
@@ -67,7 +67,7 @@ typedef struct thread_args {
*/
/* Basic call to read() */
-static int read_bytes(int fd, char *buf, size_t read_size, int spin) {
+static int read_bytes(int fd, char* buf, size_t read_size, int spin) {
size_t bytes_read = 0;
ssize_t err;
do {
@@ -89,16 +89,16 @@ static int read_bytes(int fd, char *buf, size_t read_size, int spin) {
return 0;
}
-static int blocking_read_bytes(thread_args *args, char *buf) {
+static int blocking_read_bytes(thread_args* args, char* buf) {
return read_bytes(args->fds.read_fd, buf, args->msg_size, 0);
}
-static int spin_read_bytes(thread_args *args, char *buf) {
+static int spin_read_bytes(thread_args* args, char* buf) {
return read_bytes(args->fds.read_fd, buf, args->msg_size, 1);
}
/* Call poll() to monitor a non-blocking fd */
-static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) {
+static int poll_read_bytes(int fd, char* buf, size_t read_size, int spin) {
struct pollfd pfd;
size_t bytes_read = 0;
int err;
@@ -131,17 +131,17 @@ static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) {
return 0;
}
-static int poll_read_bytes_blocking(struct thread_args *args, char *buf) {
+static int poll_read_bytes_blocking(struct thread_args* args, char* buf) {
return poll_read_bytes(args->fds.read_fd, buf, args->msg_size, 0);
}
-static int poll_read_bytes_spin(struct thread_args *args, char *buf) {
+static int poll_read_bytes_spin(struct thread_args* args, char* buf) {
return poll_read_bytes(args->fds.read_fd, buf, args->msg_size, 1);
}
#ifdef __linux__
/* Call epoll_wait() to monitor a non-blocking fd */
-static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) {
+static int epoll_read_bytes(struct thread_args* args, char* buf, int spin) {
struct epoll_event ev;
size_t bytes_read = 0;
int err;
@@ -174,11 +174,11 @@ static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) {
return 0;
}
-static int epoll_read_bytes_blocking(struct thread_args *args, char *buf) {
+static int epoll_read_bytes_blocking(struct thread_args* args, char* buf) {
return epoll_read_bytes(args, buf, 0);
}
-static int epoll_read_bytes_spin(struct thread_args *args, char *buf) {
+static int epoll_read_bytes_spin(struct thread_args* args, char* buf) {
return epoll_read_bytes(args, buf, 1);
}
#endif /* __linux__ */
@@ -187,7 +187,7 @@ static int epoll_read_bytes_spin(struct thread_args *args, char *buf) {
At this point we only have one strategy, since in the common case these
writes go directly out to the kernel.
*/
-static int blocking_write_bytes(struct thread_args *args, char *buf) {
+static int blocking_write_bytes(struct thread_args* args, char* buf) {
size_t bytes_written = 0;
ssize_t err;
size_t write_size = args->msg_size;
@@ -214,7 +214,7 @@ static int blocking_write_bytes(struct thread_args *args, char *buf) {
These are called at the beginning of the client and server thread, depending
on the scenario we're using.
*/
-static int set_socket_nonblocking(thread_args *args) {
+static int set_socket_nonblocking(thread_args* args) {
if (!GRPC_LOG_IF_ERROR("Unable to set read socket nonblocking",
grpc_set_socket_nonblocking(args->fds.read_fd, 1))) {
return -1;
@@ -226,11 +226,11 @@ static int set_socket_nonblocking(thread_args *args) {
return 0;
}
-static int do_nothing(thread_args *args) { return 0; }
+static int do_nothing(thread_args* args) { return 0; }
#ifdef __linux__
/* Special case for epoll, where we need to create the fd ahead of time. */
-static int epoll_setup(thread_args *args) {
+static int epoll_setup(thread_args* args) {
int epoll_fd;
struct epoll_event ev;
set_socket_nonblocking(args);
@@ -251,8 +251,8 @@ static int epoll_setup(thread_args *args) {
}
#endif
-static void server_thread(thread_args *args) {
- char *buf = gpr_malloc(args->msg_size);
+static void server_thread(thread_args* args) {
+ char* buf = static_cast<char*>(gpr_malloc(args->msg_size));
if (args->setup(args) < 0) {
gpr_log(GPR_ERROR, "Setup failed");
}
@@ -270,19 +270,19 @@ static void server_thread(thread_args *args) {
}
}
-static void server_thread_wrap(void *arg) {
- thread_args *args = arg;
+static void server_thread_wrap(void* arg) {
+ thread_args* args = static_cast<thread_args*>(arg);
server_thread(args);
}
-static void print_histogram(gpr_histogram *histogram) {
+static void print_histogram(grpc_histogram* histogram) {
/* TODO(klempner): Print more detailed information, such as detailed histogram
buckets */
gpr_log(GPR_INFO, "latency (50/95/99/99.9): %f/%f/%f/%f",
- gpr_histogram_percentile(histogram, 50),
- gpr_histogram_percentile(histogram, 95),
- gpr_histogram_percentile(histogram, 99),
- gpr_histogram_percentile(histogram, 99.9));
+ grpc_histogram_percentile(histogram, 50),
+ grpc_histogram_percentile(histogram, 95),
+ grpc_histogram_percentile(histogram, 99),
+ grpc_histogram_percentile(histogram, 99.9));
}
static double now(void) {
@@ -290,10 +290,10 @@ static double now(void) {
return 1e9 * (double)tv.tv_sec + (double)tv.tv_nsec;
}
-static void client_thread(thread_args *args) {
- char *buf = gpr_malloc(args->msg_size * sizeof(char));
+static void client_thread(thread_args* args) {
+ char* buf = static_cast<char*>(gpr_malloc(args->msg_size * sizeof(char)));
memset(buf, 0, args->msg_size * sizeof(char));
- gpr_histogram *histogram = gpr_histogram_create(0.01, 60e9);
+ grpc_histogram* histogram = grpc_histogram_create(0.01, 60e9);
double start_time;
double end_time;
double interval;
@@ -316,17 +316,17 @@ static void client_thread(thread_args *args) {
end_time = now();
if (i > kNumIters / 2) {
interval = end_time - start_time;
- gpr_histogram_add(histogram, interval);
+ grpc_histogram_add(histogram, interval);
}
}
print_histogram(histogram);
error:
gpr_free(buf);
- gpr_histogram_destroy(histogram);
+ grpc_histogram_destroy(histogram);
}
/* This roughly matches tcp_server's create_listening_socket */
-static int create_listening_socket(struct sockaddr *port, socklen_t len) {
+static int create_listening_socket(struct sockaddr* port, socklen_t len) {
int fd = socket(port->sa_family, SOCK_STREAM, 0);
if (fd < 0) {
gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
@@ -370,7 +370,7 @@ error:
return -1;
}
-static int connect_client(struct sockaddr *addr, socklen_t len) {
+static int connect_client(struct sockaddr* addr, socklen_t len) {
int fd = socket(addr->sa_family, SOCK_STREAM, 0);
int err;
if (fd < 0) {
@@ -405,7 +405,7 @@ error:
}
static int accept_server(int listen_fd) {
- int fd = accept(listen_fd, NULL, NULL);
+ int fd = accept(listen_fd, nullptr, nullptr);
if (fd < 0) {
gpr_log(GPR_ERROR, "Accept failed: %s", strerror(errno));
return -1;
@@ -413,13 +413,13 @@ static int accept_server(int listen_fd) {
return fd;
}
-static int create_sockets_tcp(fd_pair *client_fds, fd_pair *server_fds) {
+static int create_sockets_tcp(fd_pair* client_fds, fd_pair* server_fds) {
int listen_fd = -1;
int client_fd = -1;
int server_fd = -1;
struct sockaddr_in port;
- struct sockaddr *sa_port = (struct sockaddr *)&port;
+ struct sockaddr* sa_port = (struct sockaddr*)&port;
port.sin_family = AF_INET;
port.sin_port = 0;
@@ -463,7 +463,7 @@ error:
return -1;
}
-static int create_sockets_socketpair(fd_pair *client_fds, fd_pair *server_fds) {
+static int create_sockets_socketpair(fd_pair* client_fds, fd_pair* server_fds) {
int fds[2];
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
gpr_log(GPR_ERROR, "socketpair: %s", strerror(errno));
@@ -477,7 +477,7 @@ static int create_sockets_socketpair(fd_pair *client_fds, fd_pair *server_fds) {
return 0;
}
-static int create_sockets_pipe(fd_pair *client_fds, fd_pair *server_fds) {
+static int create_sockets_pipe(fd_pair* client_fds, fd_pair* server_fds) {
int cfds[2];
int sfds[2];
if (pipe(cfds) < 0) {
@@ -497,7 +497,7 @@ static int create_sockets_pipe(fd_pair *client_fds, fd_pair *server_fds) {
return 0;
}
-static const char *read_strategy_usage =
+static const char* read_strategy_usage =
"Strategy for doing reads, which is one of:\n"
" blocking: blocking read calls\n"
" same_thread_poll: poll() call on same thread \n"
@@ -511,13 +511,13 @@ static const char *read_strategy_usage =
#endif
"";
-static const char *socket_type_usage =
+static const char* socket_type_usage =
"Type of socket used, one of:\n"
" tcp: fds are endpoints of a TCP connection\n"
" socketpair: fds come from socketpair()\n"
" pipe: fds come from pipe()\n";
-void print_usage(char *argv0) {
+void print_usage(char* argv0) {
fprintf(stderr, "%s usage:\n\n", argv0);
fprintf(stderr, "%s read_strategy socket_type msg_size\n\n", argv0);
fprintf(stderr, "where read_strategy is one of:\n");
@@ -535,12 +535,13 @@ void print_usage(char *argv0) {
fprintf(stderr, " tcp: fds are endpoints of a TCP connection\n");
fprintf(stderr, " socketpair: fds come from socketpair()\n");
fprintf(stderr, " pipe: fds come from pipe()\n");
+ fflush(stderr);
}
typedef struct test_strategy {
- char *name;
- int (*read_strategy)(struct thread_args *args, char *buf);
- int (*setup)(struct thread_args *args);
+ const char* name;
+ int (*read_strategy)(struct thread_args* args, char* buf);
+ int (*setup)(struct thread_args* args);
} test_strategy;
static test_strategy test_strategies[] = {
@@ -553,9 +554,10 @@ static test_strategy test_strategies[] = {
{"spin_read", spin_read_bytes, set_socket_nonblocking},
{"spin_poll", poll_read_bytes_spin, set_socket_nonblocking}};
-static char *socket_types[] = {"tcp", "socketpair", "pipe"};
+static const char* socket_types[] = {"tcp", "socketpair", "pipe"};
-int create_socket(char *socket_type, fd_pair *client_fds, fd_pair *server_fds) {
+int create_socket(const char* socket_type, fd_pair* client_fds,
+ fd_pair* server_fds) {
if (strcmp(socket_type, "tcp") == 0) {
create_sockets_tcp(client_fds, server_fds);
} else if (strcmp(socket_type, "socketpair") == 0) {
@@ -564,13 +566,14 @@ int create_socket(char *socket_type, fd_pair *client_fds, fd_pair *server_fds) {
create_sockets_pipe(client_fds, server_fds);
} else {
fprintf(stderr, "Invalid socket type %s\n", socket_type);
+ fflush(stderr);
return -1;
}
return 0;
}
-static int run_benchmark(char *socket_type, thread_args *client_args,
- thread_args *server_args) {
+static int run_benchmark(const char* socket_type, thread_args* client_args,
+ thread_args* server_args) {
gpr_thd_id tid;
int rv = 0;
@@ -582,7 +585,7 @@ static int run_benchmark(char *socket_type, thread_args *client_args,
gpr_log(GPR_INFO, "Starting test %s %s %zu", client_args->strategy_name,
socket_type, client_args->msg_size);
- gpr_thd_new(&tid, server_thread_wrap, server_args, NULL);
+ gpr_thd_new(&tid, "server_thread", server_thread_wrap, server_args, nullptr);
client_thread(client_args);
return 0;
}
@@ -591,12 +594,14 @@ static int run_all_benchmarks(size_t msg_size) {
int error = 0;
size_t i;
for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) {
- test_strategy *strategy = &test_strategies[i];
+ test_strategy* strategy = &test_strategies[i];
size_t j;
for (j = 0; j < GPR_ARRAY_SIZE(socket_types); ++j) {
- thread_args *client_args = gpr_malloc(sizeof(thread_args));
- thread_args *server_args = gpr_malloc(sizeof(thread_args));
- char *socket_type = socket_types[j];
+ thread_args* client_args =
+ static_cast<thread_args*>(gpr_malloc(sizeof(thread_args)));
+ thread_args* server_args =
+ static_cast<thread_args*>(gpr_malloc(sizeof(thread_args)));
+ const char* socket_type = socket_types[j];
client_args->read_bytes = strategy->read_strategy;
client_args->write_bytes = blocking_write_bytes;
@@ -617,17 +622,19 @@ static int run_all_benchmarks(size_t msg_size) {
return error;
}
-int main(int argc, char **argv) {
- thread_args *client_args = gpr_malloc(sizeof(thread_args));
- thread_args *server_args = gpr_malloc(sizeof(thread_args));
+int main(int argc, char** argv) {
+ thread_args* client_args =
+ static_cast<thread_args*>(gpr_malloc(sizeof(thread_args)));
+ thread_args* server_args =
+ static_cast<thread_args*>(gpr_malloc(sizeof(thread_args)));
int msg_size = -1;
- char *read_strategy = NULL;
- char *socket_type = NULL;
+ const char* read_strategy = nullptr;
+ const char* socket_type = nullptr;
size_t i;
- const test_strategy *strategy = NULL;
+ const test_strategy* strategy = nullptr;
int error = 0;
- gpr_cmdline *cmdline =
+ gpr_cmdline* cmdline =
gpr_cmdline_create("low_level_ping_pong network benchmarking tool");
gpr_cmdline_add_int(cmdline, "msg_size", "Size of sent messages", &msg_size);
@@ -642,16 +649,17 @@ int main(int argc, char **argv) {
msg_size = 50;
}
- if (read_strategy == NULL) {
+ if (read_strategy == nullptr) {
gpr_log(GPR_INFO, "No strategy specified, running all benchmarks");
return run_all_benchmarks((size_t)msg_size);
}
- if (socket_type == NULL) {
+ if (socket_type == nullptr) {
socket_type = "tcp";
}
if (msg_size <= 0) {
fprintf(stderr, "msg_size must be > 0\n");
+ fflush(stderr);
print_usage(argv[0]);
return -1;
}
@@ -661,8 +669,9 @@ int main(int argc, char **argv) {
strategy = &test_strategies[i];
}
}
- if (strategy == NULL) {
+ if (strategy == nullptr) {
fprintf(stderr, "Invalid read strategy %s\n", read_strategy);
+ fflush(stderr);
return -1;
}
diff --git a/test/core/security/BUILD b/test/core/security/BUILD
index dc41759922..7cd3ae58da 100644
--- a/test/core/security/BUILD
+++ b/test/core/security/BUILD
@@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "ssl_server_fuzzer",
- srcs = ["ssl_server_fuzzer.c"],
- language = "C",
+ srcs = ["ssl_server_fuzzer.cc"],
+ language = "C++",
corpus = "corpus",
deps = [
"//:gpr",
@@ -35,17 +35,17 @@ grpc_fuzzer(
grpc_cc_library(
name = "oauth2_utils",
- srcs = ["oauth2_utils.c"],
+ srcs = ["oauth2_utils.cc"],
hdrs = ["oauth2_utils.h"],
- language = "C",
+ language = "C++",
deps = ["//:grpc"],
visibility = ["//test/cpp:__subpackages__"],
)
grpc_cc_test(
name = "auth_context_test",
- srcs = ["auth_context_test.c"],
- language = "C",
+ srcs = ["auth_context_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -56,8 +56,8 @@ grpc_cc_test(
grpc_cc_test(
name = "credentials_test",
- srcs = ["credentials_test.c"],
- language = "C",
+ srcs = ["credentials_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -68,8 +68,8 @@ grpc_cc_test(
grpc_cc_test(
name = "secure_endpoint_test",
- srcs = ["secure_endpoint_test.c"],
- language = "C",
+ srcs = ["secure_endpoint_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -81,8 +81,8 @@ grpc_cc_test(
grpc_cc_test(
name = "security_connector_test",
- srcs = ["security_connector_test.c"],
- language = "C",
+ srcs = ["security_connector_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -91,10 +91,22 @@ grpc_cc_test(
],
)
+grpc_cc_test(
+ name = "ssl_credentials_test",
+ srcs = ["ssl_credentials_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ]
+)
+
grpc_cc_binary(
name = "create_jwt",
- srcs = ["create_jwt.c"],
- language = "C",
+ srcs = ["create_jwt.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -103,8 +115,8 @@ grpc_cc_binary(
grpc_cc_binary(
name = "fetch_oauth2",
- srcs = ["fetch_oauth2.c"],
- language = "C",
+ srcs = ["fetch_oauth2.cc"],
+ language = "C++",
deps = [
":oauth2_utils",
"//:gpr",
@@ -114,8 +126,8 @@ grpc_cc_binary(
grpc_cc_binary(
name = "verify_jwt",
- srcs = ["verify_jwt.c"],
- language = "C",
+ srcs = ["verify_jwt.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/security/auth_context_test.c b/test/core/security/auth_context_test.cc
index 88daf28c99..58f0d8e1c2 100644
--- a/test/core/security/auth_context_test.c
+++ b/test/core/security/auth_context_test.cc
@@ -18,38 +18,38 @@
#include <string.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
#include <grpc/support/log.h>
static void test_empty_context(void) {
- grpc_auth_context *ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(nullptr);
grpc_auth_property_iterator it;
gpr_log(GPR_INFO, "test_empty_context");
- GPR_ASSERT(ctx != NULL);
- GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == NULL);
+ GPR_ASSERT(ctx != nullptr);
+ GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == nullptr);
it = grpc_auth_context_peer_identity(ctx);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_property_iterator(ctx);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_find_properties_by_name(ctx, "foo");
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(ctx, "bar") ==
0);
- GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == NULL);
+ GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == nullptr);
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
static void test_simple_context(void) {
- grpc_auth_context *ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(nullptr);
grpc_auth_property_iterator it;
size_t i;
gpr_log(GPR_INFO, "test_simple_context");
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
grpc_auth_context_add_cstring_property(ctx, "name", "chapi");
grpc_auth_context_add_cstring_property(ctx, "name", "chapo");
grpc_auth_context_add_cstring_property(ctx, "foo", "bar");
@@ -61,29 +61,29 @@ static void test_simple_context(void) {
strcmp(grpc_auth_context_peer_identity_property_name(ctx), "name") == 0);
it = grpc_auth_context_property_iterator(ctx);
for (i = 0; i < ctx->properties.count; i++) {
- const grpc_auth_property *p = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* p = grpc_auth_property_iterator_next(&it);
GPR_ASSERT(p == &ctx->properties.array[i]);
}
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_find_properties_by_name(ctx, "foo");
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[2]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_peer_identity(ctx);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[0]);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[1]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
static void test_chained_context(void) {
- grpc_auth_context *chained = grpc_auth_context_create(NULL);
- grpc_auth_context *ctx = grpc_auth_context_create(chained);
+ grpc_auth_context* chained = grpc_auth_context_create(nullptr);
+ grpc_auth_context* ctx = grpc_auth_context_create(chained);
grpc_auth_property_iterator it;
size_t i;
@@ -101,21 +101,21 @@ static void test_chained_context(void) {
strcmp(grpc_auth_context_peer_identity_property_name(ctx), "name") == 0);
it = grpc_auth_context_property_iterator(ctx);
for (i = 0; i < ctx->properties.count; i++) {
- const grpc_auth_property *p = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* p = grpc_auth_property_iterator_next(&it);
GPR_ASSERT(p == &ctx->properties.array[i]);
}
for (i = 0; i < chained->properties.count; i++) {
- const grpc_auth_property *p = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* p = grpc_auth_property_iterator_next(&it);
GPR_ASSERT(p == &chained->properties.array[i]);
}
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_find_properties_by_name(ctx, "foo");
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[2]);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&chained->properties.array[1]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_peer_identity(ctx);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
@@ -124,12 +124,12 @@ static void test_chained_context(void) {
&ctx->properties.array[1]);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&chained->properties.array[0]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_empty_context();
test_simple_context();
diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.cc
index 93ea27f425..56ae9c891c 100644
--- a/test/core/security/create_jwt.c
+++ b/test/core/security/create_jwt.cc
@@ -27,38 +27,40 @@
#include <grpc/support/cmdline.h>
#include <grpc/support/log.h>
-void create_jwt(const char *json_key_file_path, const char *service_url,
- const char *scope) {
+void create_jwt(const char* json_key_file_path, const char* service_url,
+ const char* scope) {
grpc_auth_json_key key;
- char *jwt;
+ char* jwt;
grpc_slice json_key_data;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file(json_key_file_path, 1, &json_key_data)));
key = grpc_auth_json_key_create_from_string(
- (const char *)GRPC_SLICE_START_PTR(json_key_data));
+ (const char*)GRPC_SLICE_START_PTR(json_key_data));
grpc_slice_unref(json_key_data);
if (!grpc_auth_json_key_is_valid(&key)) {
fprintf(stderr, "Could not parse json key.\n");
+ fflush(stderr);
exit(1);
}
jwt = grpc_jwt_encode_and_sign(
- &key, service_url == NULL ? GRPC_JWT_OAUTH2_AUDIENCE : service_url,
+ &key, service_url == nullptr ? GRPC_JWT_OAUTH2_AUDIENCE : service_url,
grpc_max_auth_token_lifetime(), scope);
grpc_auth_json_key_destruct(&key);
- if (jwt == NULL) {
+ if (jwt == nullptr) {
fprintf(stderr, "Could not create JWT.\n");
+ fflush(stderr);
exit(1);
}
fprintf(stdout, "%s\n", jwt);
gpr_free(jwt);
}
-int main(int argc, char **argv) {
- char *scope = NULL;
- char *json_key_file_path = NULL;
- char *service_url = NULL;
+int main(int argc, char** argv) {
+ const char* scope = nullptr;
+ const char* json_key_file_path = nullptr;
+ const char* service_url = nullptr;
grpc_init();
- gpr_cmdline *cl = gpr_cmdline_create("create_jwt");
+ gpr_cmdline* cl = gpr_cmdline_create("create_jwt");
gpr_cmdline_add_string(cl, "json_key", "File path of the json key.",
&json_key_file_path);
gpr_cmdline_add_string(cl, "scope",
@@ -70,18 +72,21 @@ int main(int argc, char **argv) {
&service_url);
gpr_cmdline_parse(cl, argc, argv);
- if (json_key_file_path == NULL) {
+ if (json_key_file_path == nullptr) {
fprintf(stderr, "Missing --json_key option.\n");
+ fflush(stderr);
exit(1);
}
- if (scope != NULL) {
- if (service_url != NULL) {
+ if (scope != nullptr) {
+ if (service_url != nullptr) {
fprintf(stderr,
"Options --scope and --service_url are mutually exclusive.\n");
+ fflush(stderr);
exit(1);
}
- } else if (service_url == NULL) {
+ } else if (service_url == nullptr) {
fprintf(stderr, "Need one of --service_url or --scope options.\n");
+ fflush(stderr);
exit(1);
}
diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.cc
index 441c431135..90310469aa 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.cc
@@ -24,27 +24,31 @@
#include <stdlib.h>
#include <string.h>
+#include <grpc/slice.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/http/httpcli.h"
#include "src/core/lib/security/credentials/composite/composite_credentials.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
#include "src/core/lib/security/credentials/google_default/google_default_credentials.h"
#include "src/core/lib/security/credentials/jwt/jwt_credentials.h"
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
+#include "src/core/lib/security/transport/auth_filters.h"
#include "test/core/util/test_config.h"
/* -- Mock channel credentials. -- */
-static grpc_channel_credentials *grpc_mock_channel_credentials_create(
- const grpc_channel_credentials_vtable *vtable) {
- grpc_channel_credentials *c = gpr_malloc(sizeof(*c));
+static grpc_channel_credentials* grpc_mock_channel_credentials_create(
+ const grpc_channel_credentials_vtable* vtable) {
+ grpc_channel_credentials* c =
+ static_cast<grpc_channel_credentials*>(gpr_malloc(sizeof(*c)));
memset(c, 0, sizeof(*c));
c->type = "mock";
c->vtable = vtable;
@@ -118,12 +122,12 @@ static const char test_method[] = "ThisIsNotAMethod";
/* -- Utils. -- */
-static char *test_json_key_str(void) {
+static char* test_json_key_str(void) {
size_t result_len = strlen(test_json_key_str_part1) +
strlen(test_json_key_str_part2) +
strlen(test_json_key_str_part3);
- char *result = gpr_malloc(result_len + 1);
- char *current = result;
+ char* result = static_cast<char*>(gpr_malloc(result_len + 1));
+ char* current = result;
strcpy(result, test_json_key_str_part1);
current += strlen(test_json_key_str_part1);
strcpy(current, test_json_key_str_part2);
@@ -132,11 +136,11 @@ static char *test_json_key_str(void) {
return result;
}
-static grpc_httpcli_response http_response(int status, const char *body) {
+static grpc_httpcli_response http_response(int status, const char* body) {
grpc_httpcli_response response;
memset(&response, 0, sizeof(grpc_httpcli_response));
response.status = status;
- response.body = gpr_strdup((char *)body);
+ response.body = gpr_strdup((char*)body);
response.body_length = strlen(body);
return response;
}
@@ -144,41 +148,37 @@ static grpc_httpcli_response http_response(int status, const char *body) {
/* -- Tests. -- */
static void test_empty_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
- GPR_ASSERT(md_array.md == NULL);
+ GPR_ASSERT(md_array.md == nullptr);
GPR_ASSERT(md_array.size == 0);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_add_to_empty_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
- const char *key = "hello";
- const char *value = "there blah blah blah blah blah blah blah";
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ const char* key = "hello";
+ const char* value = "there blah blah blah blah blah blah blah";
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
grpc_credentials_mdelem_array_add(&md_array, md);
GPR_ASSERT(md_array.size == 1);
GPR_ASSERT(grpc_mdelem_eq(md, md_array.md[0]));
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_add_abunch_to_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
- const char *key = "hello";
- const char *value = "there blah blah blah blah blah blah blah";
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ const char* key = "hello";
+ const char* value = "there blah blah blah blah blah blah blah";
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
size_t num_entries = 1000;
for (size_t i = 0; i < num_entries; ++i) {
grpc_credentials_mdelem_array_add(&md_array, md);
@@ -186,136 +186,126 @@ static void test_add_abunch_to_md_array(void) {
for (size_t i = 0; i < num_entries; ++i) {
GPR_ASSERT(grpc_mdelem_eq(md_array.md[i], md));
}
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
- GRPC_CREDENTIALS_OK);
- GPR_ASSERT(token_lifetime.tv_sec == 3599);
- GPR_ASSERT(token_lifetime.tv_nsec == 0);
+ &response, &token_md, &token_lifetime) == GRPC_CREDENTIALS_OK);
+ GPR_ASSERT(token_lifetime == 3599 * GPR_MS_PER_SEC);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(token_md), "authorization") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(token_md),
"Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") ==
0);
- GRPC_MDELEM_UNREF(&exec_ctx, token_md);
+ GRPC_MDELEM_UNREF(token_md);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(401, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200, "");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200,
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200,
"{"
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200,
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
" \"expires_in\":3599, "
"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
- gpr_timespec token_lifetime;
+ grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200,
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
- const char *key;
- const char *value;
+ const char* key;
+ const char* value;
} expected_md;
typedef struct {
- grpc_error *expected_error;
- const expected_md *expected;
+ grpc_error* expected_error;
+ const expected_md* expected;
size_t expected_size;
grpc_credentials_mdelem_array md_array;
grpc_closure on_request_metadata;
- grpc_call_credentials *creds;
+ grpc_call_credentials* creds;
grpc_polling_entity pollent;
} request_metadata_state;
-static void check_metadata(const expected_md *expected,
- grpc_credentials_mdelem_array *md_array) {
+static void check_metadata(const expected_md* expected,
+ grpc_credentials_mdelem_array* md_array) {
for (size_t i = 0; i < md_array->size; ++i) {
size_t j;
for (j = 0; j < md_array->size; ++j) {
@@ -333,9 +323,8 @@ static void check_metadata(const expected_md *expected,
}
}
-static void check_request_metadata(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- request_metadata_state *state = (request_metadata_state *)arg;
+static void check_request_metadata(void* arg, grpc_error* error) {
+ request_metadata_state* state = (request_metadata_state*)arg;
gpr_log(GPR_INFO, "expected_error: %s",
grpc_error_string(state->expected_error));
gpr_log(GPR_INFO, "actual_error: %s", grpc_error_string(error));
@@ -355,16 +344,16 @@ static void check_request_metadata(grpc_exec_ctx *exec_ctx, void *arg,
state->expected_size, state->md_array.size);
GPR_ASSERT(state->md_array.size == state->expected_size);
check_metadata(state->expected, &state->md_array);
- grpc_credentials_mdelem_array_destroy(exec_ctx, &state->md_array);
- grpc_pollset_set_destroy(exec_ctx,
- grpc_polling_entity_pollset_set(&state->pollent));
+ grpc_credentials_mdelem_array_destroy(&state->md_array);
+ grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&state->pollent));
gpr_free(state);
}
-static request_metadata_state *make_request_metadata_state(
- grpc_error *expected_error, const expected_md *expected,
+static request_metadata_state* make_request_metadata_state(
+ grpc_error* expected_error, const expected_md* expected,
size_t expected_size) {
- request_metadata_state *state = gpr_zalloc(sizeof(*state));
+ request_metadata_state* state =
+ static_cast<request_metadata_state*>(gpr_zalloc(sizeof(*state)));
state->expected_error = expected_error;
state->expected = expected;
state->expected_size = expected_size;
@@ -375,130 +364,123 @@ static request_metadata_state *make_request_metadata_state(
return state;
}
-static void run_request_metadata_test(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds,
+static void run_request_metadata_test(grpc_call_credentials* creds,
grpc_auth_metadata_context auth_md_ctx,
- request_metadata_state *state) {
- grpc_error *error = GRPC_ERROR_NONE;
+ request_metadata_state* state) {
+ grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, creds, &state->pollent, auth_md_ctx, &state->md_array,
+ creds, &state->pollent, auth_md_ctx, &state->md_array,
&state->on_request_metadata, &error)) {
// Synchronous result. Invoke the callback directly.
- check_request_metadata(exec_ctx, state, error);
+ check_request_metadata(state, error);
GRPC_ERROR_UNREF(error);
}
}
static void test_google_iam_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
test_google_iam_authority_selector}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
- grpc_call_credentials *creds = grpc_google_iam_credentials_create(
+ grpc_call_credentials* creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
}
static void test_access_token_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
- grpc_call_credentials *creds =
- grpc_access_token_credentials_create("blah", NULL);
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_call_credentials* creds =
+ grpc_access_token_credentials_create("blah", nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
}
static grpc_security_status check_channel_oauth2_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
- grpc_call_credentials *call_creds, const char *target,
- const grpc_channel_args *args, grpc_channel_security_connector **sc,
- grpc_channel_args **new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
GPR_ASSERT(strcmp(c->type, "mock") == 0);
- GPR_ASSERT(call_creds != NULL);
+ GPR_ASSERT(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
return GRPC_SECURITY_OK;
}
static void test_channel_oauth2_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *new_args;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
- NULL, check_channel_oauth2_create_security_connector, NULL};
- grpc_channel_credentials *channel_creds =
+ nullptr, check_channel_oauth2_create_security_connector, nullptr};
+ grpc_channel_credentials* channel_creds =
grpc_mock_channel_credentials_create(&vtable);
- grpc_call_credentials *oauth2_creds =
- grpc_access_token_credentials_create("blah", NULL);
- grpc_channel_credentials *channel_oauth2_creds =
+ grpc_call_credentials* oauth2_creds =
+ grpc_access_token_credentials_create("blah", nullptr);
+ grpc_channel_credentials* channel_oauth2_creds =
grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
- NULL);
+ nullptr);
grpc_channel_credentials_release(channel_creds);
grpc_call_credentials_release(oauth2_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_creds, NULL, NULL, NULL,
- &new_args) == GRPC_SECURITY_OK);
+ channel_oauth2_creds, nullptr, nullptr, nullptr, &new_args) ==
+ GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_google_iam_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {
{GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token},
{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
test_google_iam_authority_selector}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create(
- &exec_ctx, "authorization", test_oauth2_bearer_token, 0);
- grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create(
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
+ "authorization", test_oauth2_bearer_token, 0);
+ grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
- grpc_call_credentials *composite_creds =
+ nullptr);
+ grpc_call_credentials* composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
- NULL);
- grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
- grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
+ nullptr);
+ grpc_call_credentials_unref(oauth2_creds);
+ grpc_call_credentials_unref(google_iam_creds);
GPR_ASSERT(
strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
- const grpc_call_credentials_array *creds_array =
+ const grpc_call_credentials_array* creds_array =
grpc_composite_call_credentials_get_credentials(composite_creds);
GPR_ASSERT(creds_array->num_creds == 2);
GPR_ASSERT(strcmp(creds_array->creds_array[0]->type,
GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
GPR_ASSERT(strcmp(creds_array->creds_array[1]->type,
GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0);
- run_request_metadata_test(&exec_ctx, composite_creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, composite_creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(composite_creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(composite_creds);
}
static grpc_security_status
check_channel_oauth2_google_iam_create_security_connector(
- grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
- grpc_call_credentials *call_creds, const char *target,
- const grpc_channel_args *args, grpc_channel_security_connector **sc,
- grpc_channel_args **new_args) {
- const grpc_call_credentials_array *creds_array;
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
+ const grpc_call_credentials_array* creds_array;
GPR_ASSERT(strcmp(c->type, "mock") == 0);
- GPR_ASSERT(call_creds != NULL);
+ GPR_ASSERT(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) ==
0);
creds_array = grpc_composite_call_credentials_get_credentials(call_creds);
@@ -510,38 +492,38 @@ check_channel_oauth2_google_iam_create_security_connector(
}
static void test_channel_oauth2_google_iam_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *new_args;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
- NULL, check_channel_oauth2_google_iam_create_security_connector, NULL};
- grpc_channel_credentials *channel_creds =
+ nullptr, check_channel_oauth2_google_iam_create_security_connector,
+ nullptr};
+ grpc_channel_credentials* channel_creds =
grpc_mock_channel_credentials_create(&vtable);
- grpc_call_credentials *oauth2_creds =
- grpc_access_token_credentials_create("blah", NULL);
- grpc_channel_credentials *channel_oauth2_creds =
+ grpc_call_credentials* oauth2_creds =
+ grpc_access_token_credentials_create("blah", nullptr);
+ grpc_channel_credentials* channel_oauth2_creds =
grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
- NULL);
- grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create(
+ nullptr);
+ grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
- grpc_channel_credentials *channel_oauth2_iam_creds =
+ nullptr);
+ grpc_channel_credentials* channel_oauth2_iam_creds =
grpc_composite_channel_credentials_create(channel_oauth2_creds,
- google_iam_creds, NULL);
+ google_iam_creds, nullptr);
grpc_channel_credentials_release(channel_creds);
grpc_call_credentials_release(oauth2_creds);
grpc_channel_credentials_release(channel_oauth2_creds);
grpc_call_credentials_release(google_iam_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_iam_creds, NULL, NULL, NULL,
+ channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_compute_engine_http_request(
- const grpc_httpcli_request *request) {
+ const grpc_httpcli_request* request) {
GPR_ASSERT(request->handshaker != &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
GPR_ASSERT(
@@ -554,95 +536,90 @@ static void validate_compute_engine_http_request(
}
static int compute_engine_httpcli_get_success_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int compute_engine_httpcli_get_failure_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size, gpr_timespec deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
- GPR_ASSERT("HTTP POST should not be called" == NULL);
+ const grpc_httpcli_request* request, const char* body_bytes,
+ size_t body_size, grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
+ GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- gpr_timespec deadline,
- grpc_closure *on_done,
- grpc_httpcli_response *response) {
- GPR_ASSERT("HTTP GET should not be called" == NULL);
+static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
+ grpc_millis deadline,
+ grpc_closure* on_done,
+ grpc_httpcli_response* response) {
+ GPR_ASSERT("HTTP GET should not be called" == nullptr);
return 1;
}
static void test_compute_engine_creds_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- grpc_call_credentials *creds =
- grpc_google_compute_engine_credentials_create(NULL);
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_call_credentials* creds =
+ grpc_google_compute_engine_credentials_create(nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
/* First request: http get should be called. */
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void test_compute_engine_creds_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- request_metadata_state *state = make_request_metadata_state(
+ grpc_core::ExecCtx exec_ctx;
+ request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
- NULL, 0);
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- grpc_call_credentials *creds =
- grpc_google_compute_engine_credentials_create(NULL);
+ nullptr, 0);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ grpc_call_credentials* creds =
+ grpc_google_compute_engine_credentials_create(nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void validate_refresh_token_http_request(
- const grpc_httpcli_request *request, const char *body, size_t body_size) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size) {
/* The content of the assertion is tested extensively in json_token_test. */
- char *expected_body = NULL;
- GPR_ASSERT(body != NULL);
+ char* expected_body = nullptr;
+ GPR_ASSERT(body != nullptr);
GPR_ASSERT(body_size != 0);
gpr_asprintf(&expected_body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
"32555999999.apps.googleusercontent.com",
@@ -662,133 +639,131 @@ static void validate_refresh_token_http_request(
}
static int refresh_token_httpcli_post_success(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body, size_t body_size, gpr_timespec deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int refresh_token_httpcli_post_failure(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body, size_t body_size, gpr_timespec deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(403, "Not Authorized.");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_refresh_token_creds_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- grpc_call_credentials *creds = grpc_google_refresh_token_credentials_create(
- test_refresh_token_str, NULL);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create(
+ test_refresh_token_str, nullptr);
/* First request: http get should be called. */
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void test_refresh_token_creds_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- request_metadata_state *state = make_request_metadata_state(
+ grpc_core::ExecCtx exec_ctx;
+ request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
- NULL, 0);
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- grpc_call_credentials *creds = grpc_google_refresh_token_credentials_create(
- test_refresh_token_str, NULL);
+ nullptr, 0);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create(
+ test_refresh_token_str, nullptr);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_failure);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void validate_jwt_encode_and_sign_params(
- const grpc_auth_json_key *json_key, const char *scope,
+ const grpc_auth_json_key* json_key, const char* scope,
gpr_timespec token_lifetime) {
GPR_ASSERT(grpc_auth_json_key_is_valid(json_key));
- GPR_ASSERT(json_key->private_key != NULL);
+ GPR_ASSERT(json_key->private_key != nullptr);
GPR_ASSERT(RSA_check_key(json_key->private_key));
- GPR_ASSERT(json_key->type != NULL &&
+ GPR_ASSERT(json_key->type != nullptr &&
strcmp(json_key->type, "service_account") == 0);
- GPR_ASSERT(json_key->private_key_id != NULL &&
+ GPR_ASSERT(json_key->private_key_id != nullptr &&
strcmp(json_key->private_key_id,
"e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0);
- GPR_ASSERT(json_key->client_id != NULL &&
+ GPR_ASSERT(json_key->client_id != nullptr &&
strcmp(json_key->client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps."
"googleusercontent.com") == 0);
- GPR_ASSERT(json_key->client_email != NULL &&
+ GPR_ASSERT(json_key->client_email != nullptr &&
strcmp(json_key->client_email,
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- if (scope != NULL) GPR_ASSERT(strcmp(scope, test_scope) == 0);
+ if (scope != nullptr) GPR_ASSERT(strcmp(scope, test_scope) == 0);
GPR_ASSERT(!gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()));
}
-static char *encode_and_sign_jwt_success(const grpc_auth_json_key *json_key,
- const char *audience,
+static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key,
+ const char* audience,
gpr_timespec token_lifetime,
- const char *scope) {
+ const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
return gpr_strdup(test_signed_jwt);
}
-static char *encode_and_sign_jwt_failure(const grpc_auth_json_key *json_key,
- const char *audience,
+static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key,
+ const char* audience,
gpr_timespec token_lifetime,
- const char *scope) {
+ const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
- return NULL;
+ return nullptr;
}
-static char *encode_and_sign_jwt_should_not_be_called(
- const grpc_auth_json_key *json_key, const char *audience,
- gpr_timespec token_lifetime, const char *scope) {
- GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == NULL);
- return NULL;
+static char* encode_and_sign_jwt_should_not_be_called(
+ const grpc_auth_json_key* json_key, const char* audience,
+ gpr_timespec token_lifetime, const char* scope) {
+ GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == nullptr);
+ return nullptr;
}
-static grpc_service_account_jwt_access_credentials *creds_as_jwt(
- grpc_call_credentials *creds) {
- GPR_ASSERT(creds != NULL);
+static grpc_service_account_jwt_access_credentials* creds_as_jwt(
+ grpc_call_credentials* creds) {
+ GPR_ASSERT(creds != nullptr);
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_JWT) == 0);
- return (grpc_service_account_jwt_access_credentials *)creds;
+ return (grpc_service_account_jwt_access_credentials*)creds;
}
static void test_jwt_creds_lifetime(void) {
- char *json_key_string = test_json_key_str();
+ char* json_key_string = test_json_key_str();
// Max lifetime.
- grpc_call_credentials *jwt_creds =
+ grpc_call_credentials* jwt_creds =
grpc_service_account_jwt_access_credentials_create(
- json_key_string, grpc_max_auth_token_lifetime(), NULL);
+ json_key_string, grpc_max_auth_token_lifetime(), nullptr);
GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime,
grpc_max_auth_token_lifetime()) == 0);
grpc_call_credentials_release(jwt_creds);
@@ -797,7 +772,7 @@ static void test_jwt_creds_lifetime(void) {
gpr_timespec token_lifetime = {10, 0, GPR_TIMESPAN};
GPR_ASSERT(gpr_time_cmp(grpc_max_auth_token_lifetime(), token_lifetime) > 0);
jwt_creds = grpc_service_account_jwt_access_credentials_create(
- json_key_string, token_lifetime, NULL);
+ json_key_string, token_lifetime, nullptr);
GPR_ASSERT(
gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime, token_lifetime) == 0);
grpc_call_credentials_release(jwt_creds);
@@ -806,7 +781,7 @@ static void test_jwt_creds_lifetime(void) {
gpr_timespec add_to_max = {10, 0, GPR_TIMESPAN};
token_lifetime = gpr_time_add(grpc_max_auth_token_lifetime(), add_to_max);
jwt_creds = grpc_service_account_jwt_access_credentials_create(
- json_key_string, token_lifetime, NULL);
+ json_key_string, token_lifetime, nullptr);
GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime,
grpc_max_auth_token_lifetime()) == 0);
grpc_call_credentials_release(jwt_creds);
@@ -815,31 +790,31 @@ static void test_jwt_creds_lifetime(void) {
}
static void test_jwt_creds_success(void) {
- char *json_key_string = test_json_key_str();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- char *expected_md_value;
+ char* json_key_string = test_json_key_str();
+ grpc_core::ExecCtx exec_ctx;
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ char* expected_md_value;
gpr_asprintf(&expected_md_value, "Bearer %s", test_signed_jwt);
expected_md emd[] = {{"authorization", expected_md_value}};
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create(
- json_key_string, grpc_max_auth_token_lifetime(), NULL);
+ json_key_string, grpc_max_auth_token_lifetime(), nullptr);
/* First request: jwt_encode_and_sign should be called. */
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(
encode_and_sign_jwt_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Third request: Different service url so jwt_encode_and_sign should be
called again (no caching). */
@@ -847,43 +822,42 @@ static void test_jwt_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
auth_md_ctx.service_url = other_test_service_url;
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
gpr_free(json_key_string);
gpr_free(expected_md_value);
- grpc_jwt_encode_and_sign_set_override(NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_encode_and_sign_set_override(nullptr);
}
static void test_jwt_creds_signing_failure(void) {
- char *json_key_string = test_json_key_str();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- request_metadata_state *state = make_request_metadata_state(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT."), NULL, 0);
- grpc_call_credentials *creds =
+ char* json_key_string = test_json_key_str();
+ grpc_core::ExecCtx exec_ctx;
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ request_metadata_state* state = make_request_metadata_state(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT."), nullptr,
+ 0);
+ grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create(
- json_key_string, grpc_max_auth_token_lifetime(), NULL);
+ json_key_string, grpc_max_auth_token_lifetime(), nullptr);
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_failure);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
+ run_request_metadata_test(creds, auth_md_ctx, state);
gpr_free(json_key_string);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_jwt_encode_and_sign_set_override(NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+ grpc_jwt_encode_and_sign_set_override(nullptr);
}
static void set_google_default_creds_env_var_with_file_contents(
- const char *file_prefix, const char *contents) {
+ const char* file_prefix, const char* contents) {
size_t contents_len = strlen(contents);
- char *creds_file_name;
- FILE *creds_file = gpr_tmpfile(file_prefix, &creds_file_name);
- GPR_ASSERT(creds_file_name != NULL);
- GPR_ASSERT(creds_file != NULL);
+ char* creds_file_name;
+ FILE* creds_file = gpr_tmpfile(file_prefix, &creds_file_name);
+ GPR_ASSERT(creds_file_name != nullptr);
+ GPR_ASSERT(creds_file != nullptr);
GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len);
fclose(creds_file);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, creds_file_name);
@@ -891,71 +865,69 @@ static void set_google_default_creds_env_var_with_file_contents(
}
static void test_google_default_creds_auth_key(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_service_account_jwt_access_credentials *jwt;
- grpc_composite_channel_credentials *creds;
- char *json_key = test_json_key_str();
+ grpc_core::ExecCtx exec_ctx;
+ grpc_service_account_jwt_access_credentials* jwt;
+ grpc_composite_channel_credentials* creds;
+ char* json_key = test_json_key_str();
grpc_flush_cached_google_default_credentials();
set_google_default_creds_env_var_with_file_contents(
"json_key_google_default_creds", json_key);
gpr_free(json_key);
- creds = (grpc_composite_channel_credentials *)
+ creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
- GPR_ASSERT(creds != NULL);
- jwt = (grpc_service_account_jwt_access_credentials *)creds->call_creds;
+ GPR_ASSERT(creds != nullptr);
+ jwt = (grpc_service_account_jwt_access_credentials*)creds->call_creds;
GPR_ASSERT(
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
0);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_google_default_creds_refresh_token(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_google_refresh_token_credentials *refresh;
- grpc_composite_channel_credentials *creds;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_google_refresh_token_credentials* refresh;
+ grpc_composite_channel_credentials* creds;
grpc_flush_cached_google_default_credentials();
set_google_default_creds_env_var_with_file_contents(
"refresh_token_google_default_creds", test_refresh_token_str);
- creds = (grpc_composite_channel_credentials *)
+ creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
- GPR_ASSERT(creds != NULL);
- refresh = (grpc_google_refresh_token_credentials *)creds->call_creds;
+ GPR_ASSERT(creds != nullptr);
+ refresh = (grpc_google_refresh_token_credentials*)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish(&exec_ctx);
}
static int default_creds_gce_detection_httpcli_get_success_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, "");
- grpc_http_header *headers = gpr_malloc(sizeof(*headers) * 1);
+ grpc_http_header* headers =
+ static_cast<grpc_http_header*>(gpr_malloc(sizeof(*headers) * 1));
headers[0].key = gpr_strdup("Metadata-Flavor");
headers[0].value = gpr_strdup("Google");
response->hdr_count = 1;
response->hdrs = headers;
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static char *null_well_known_creds_path_getter(void) { return NULL; }
+static char* null_well_known_creds_path_getter(void) { return nullptr; }
static void test_google_default_creds_gce(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
grpc_flush_cached_google_default_credentials();
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
grpc_override_well_known_credentials_path_getter(
@@ -965,44 +937,42 @@ static void test_google_default_creds_gce(void) {
grpc_httpcli_set_override(
default_creds_gce_detection_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- grpc_composite_channel_credentials *creds =
- (grpc_composite_channel_credentials *)
+ grpc_composite_channel_credentials* creds =
+ (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
/* Verify that the default creds actually embeds a GCE creds. */
- GPR_ASSERT(creds != NULL);
- GPR_ASSERT(creds->call_creds != NULL);
+ GPR_ASSERT(creds != nullptr);
+ GPR_ASSERT(creds->call_creds != nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds->call_creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds->call_creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Check that we get a cached creds if we call
grpc_google_default_credentials_create again.
GCE detection should not occur anymore either. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_channel_credentials *cached_creds =
+ grpc_channel_credentials* cached_creds =
grpc_google_default_credentials_create();
GPR_ASSERT(cached_creds == &creds->base);
/* Cleanup. */
- grpc_channel_credentials_unref(&exec_ctx, cached_creds);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
- grpc_httpcli_set_override(NULL, NULL);
- grpc_override_well_known_credentials_path_getter(NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_credentials_unref(cached_creds);
+ grpc_channel_credentials_unref(&creds->base);
+ grpc_httpcli_set_override(nullptr, nullptr);
+ grpc_override_well_known_credentials_path_getter(nullptr);
}
static int default_creds_gce_detection_httpcli_get_failure_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
/* No magic header. */
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
*response = http_response(200, "");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -1016,16 +986,16 @@ static void test_no_google_default_creds(void) {
grpc_httpcli_set_override(
default_creds_gce_detection_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
- GPR_ASSERT(grpc_google_default_credentials_create() == NULL);
+ GPR_ASSERT(grpc_google_default_credentials_create() == nullptr);
/* Try a cached one. GCE detection should not occur anymore. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- GPR_ASSERT(grpc_google_default_credentials_create() == NULL);
+ GPR_ASSERT(grpc_google_default_credentials_create() == nullptr);
/* Cleanup. */
- grpc_httpcli_set_override(NULL, NULL);
- grpc_override_well_known_credentials_path_getter(NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
+ grpc_override_well_known_credentials_path_getter(nullptr);
}
typedef enum {
@@ -1036,107 +1006,114 @@ typedef enum {
static const expected_md plugin_md[] = {{"foo", "bar"}, {"hi", "there"}};
-static void plugin_get_metadata_success(void *state,
- grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data) {
- size_t i;
- grpc_metadata md[GPR_ARRAY_SIZE(plugin_md)];
- plugin_state *s = (plugin_state *)state;
+static int plugin_get_metadata_success(
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0);
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);
- GPR_ASSERT(context.channel_auth_context == NULL);
- GPR_ASSERT(context.reserved == NULL);
+ GPR_ASSERT(context.channel_auth_context == nullptr);
+ GPR_ASSERT(context.reserved == nullptr);
+ GPR_ASSERT(GPR_ARRAY_SIZE(plugin_md) <
+ GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX);
+ plugin_state* s = (plugin_state*)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
- for (i = 0; i < GPR_ARRAY_SIZE(plugin_md); i++) {
- memset(&md[i], 0, sizeof(grpc_metadata));
- md[i].key = grpc_slice_from_copied_string(plugin_md[i].key);
- md[i].value = grpc_slice_from_copied_string(plugin_md[i].value);
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(plugin_md); ++i) {
+ memset(&creds_md[i], 0, sizeof(grpc_metadata));
+ creds_md[i].key = grpc_slice_from_copied_string(plugin_md[i].key);
+ creds_md[i].value = grpc_slice_from_copied_string(plugin_md[i].value);
}
- cb(user_data, md, GPR_ARRAY_SIZE(md), GRPC_STATUS_OK, NULL);
+ *num_creds_md = GPR_ARRAY_SIZE(plugin_md);
+ return true; // Synchronous return.
}
-static const char *plugin_error_details = "Could not get metadata for plugin.";
+static const char* plugin_error_details = "Could not get metadata for plugin.";
-static void plugin_get_metadata_failure(void *state,
- grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb,
- void *user_data) {
- plugin_state *s = (plugin_state *)state;
+static int plugin_get_metadata_failure(
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0);
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);
- GPR_ASSERT(context.channel_auth_context == NULL);
- GPR_ASSERT(context.reserved == NULL);
+ GPR_ASSERT(context.channel_auth_context == nullptr);
+ GPR_ASSERT(context.reserved == nullptr);
+ plugin_state* s = (plugin_state*)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
- cb(user_data, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, plugin_error_details);
+ *status = GRPC_STATUS_UNAUTHENTICATED;
+ *error_details = gpr_strdup(plugin_error_details);
+ return true; // Synchronous return.
}
-static void plugin_destroy(void *state) {
- plugin_state *s = (plugin_state *)state;
+static void plugin_destroy(void* state) {
+ plugin_state* s = (plugin_state*)state;
*s = PLUGIN_DESTROY_CALLED_STATE;
}
static void test_metadata_plugin_success(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- request_metadata_state *md_state = make_request_metadata_state(
+ grpc_core::ExecCtx exec_ctx;
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ request_metadata_state* md_state = make_request_metadata_state(
GRPC_ERROR_NONE, plugin_md, GPR_ARRAY_SIZE(plugin_md));
plugin.state = &state;
plugin.get_metadata = plugin_get_metadata_success;
plugin.destroy = plugin_destroy;
- grpc_call_credentials *creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
+ grpc_call_credentials* creds =
+ grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
+ run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
static void test_metadata_plugin_failure(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
- char *expected_error;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
+ char* expected_error;
gpr_asprintf(&expected_error,
"Getting metadata from plugin failed with error: %s",
plugin_error_details);
- request_metadata_state *md_state = make_request_metadata_state(
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), NULL, 0);
+ request_metadata_state* md_state = make_request_metadata_state(
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), nullptr, 0);
gpr_free(expected_error);
plugin.state = &state;
plugin.get_metadata = plugin_get_metadata_failure;
plugin.destroy = plugin_destroy;
- grpc_call_credentials *creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
+ grpc_call_credentials* creds =
+ grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
+ run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
static void test_get_well_known_google_credentials_file_path(void) {
- char *path;
- char *home = gpr_getenv("HOME");
+ char* path;
+ char* home = gpr_getenv("HOME");
path = grpc_get_well_known_google_credentials_file_path();
- GPR_ASSERT(path != NULL);
+ GPR_ASSERT(path != nullptr);
gpr_free(path);
#if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV)
unsetenv("HOME");
path = grpc_get_well_known_google_credentials_file_path();
- GPR_ASSERT(path == NULL);
+ GPR_ASSERT(path == nullptr);
gpr_setenv("HOME", home);
gpr_free(path);
#endif /* GPR_POSIX_ENV || GPR_LINUX_ENV */
@@ -1144,35 +1121,104 @@ static void test_get_well_known_google_credentials_file_path(void) {
}
static void test_channel_creds_duplicate_without_call_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
- grpc_channel_credentials *channel_creds =
+ grpc_channel_credentials* channel_creds =
grpc_fake_transport_security_credentials_create();
- grpc_channel_credentials *dup =
+ grpc_channel_credentials* dup =
grpc_channel_credentials_duplicate_without_call_credentials(
channel_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, dup);
+ grpc_channel_credentials_unref(dup);
- grpc_call_credentials *call_creds =
- grpc_access_token_credentials_create("blah", NULL);
- grpc_channel_credentials *composite_creds =
+ grpc_call_credentials* call_creds =
+ grpc_access_token_credentials_create("blah", nullptr);
+ grpc_channel_credentials* composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
- NULL);
- grpc_call_credentials_unref(&exec_ctx, call_creds);
+ nullptr);
+ grpc_call_credentials_unref(call_creds);
dup = grpc_channel_credentials_duplicate_without_call_credentials(
composite_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, dup);
+ grpc_channel_credentials_unref(dup);
- grpc_channel_credentials_unref(&exec_ctx, channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, composite_creds);
+ grpc_channel_credentials_unref(channel_creds);
+ grpc_channel_credentials_unref(composite_creds);
+}
- grpc_exec_ctx_finish(&exec_ctx);
+typedef struct {
+ const char* url_scheme;
+ const char* call_host;
+ const char* call_method;
+ const char* desired_service_url;
+ const char* desired_method_name;
+} auth_metadata_context_test_case;
+
+static void test_auth_metadata_context(void) {
+ auth_metadata_context_test_case test_cases[] = {
+ // No service nor method.
+ {"https", "www.foo.com", "", "https://www.foo.com", ""},
+ // No method.
+ {"https", "www.foo.com", "/Service", "https://www.foo.com/Service", ""},
+ // Empty service and method.
+ {"https", "www.foo.com", "//", "https://www.foo.com/", ""},
+ // Empty method.
+ {"https", "www.foo.com", "/Service/", "https://www.foo.com/Service", ""},
+ // Malformed url.
+ {"https", "www.foo.com:", "/Service/", "https://www.foo.com:/Service",
+ ""},
+ // https, default explicit port.
+ {"https", "www.foo.com:443", "/Service/FooMethod",
+ "https://www.foo.com/Service", "FooMethod"},
+ // https, default implicit port.
+ {"https", "www.foo.com", "/Service/FooMethod",
+ "https://www.foo.com/Service", "FooMethod"},
+ // https with ipv6 literal, default explicit port.
+ {"https", "[1080:0:0:0:8:800:200C:417A]:443", "/Service/FooMethod",
+ "https://[1080:0:0:0:8:800:200C:417A]/Service", "FooMethod"},
+ // https with ipv6 literal, default implicit port.
+ {"https", "[1080:0:0:0:8:800:200C:443]", "/Service/FooMethod",
+ "https://[1080:0:0:0:8:800:200C:443]/Service", "FooMethod"},
+ // https, custom port.
+ {"https", "www.foo.com:8888", "/Service/FooMethod",
+ "https://www.foo.com:8888/Service", "FooMethod"},
+ // https with ipv6 literal, custom port.
+ {"https", "[1080:0:0:0:8:800:200C:417A]:8888", "/Service/FooMethod",
+ "https://[1080:0:0:0:8:800:200C:417A]:8888/Service", "FooMethod"},
+ // custom url scheme, https default port.
+ {"blah", "www.foo.com:443", "/Service/FooMethod",
+ "blah://www.foo.com:443/Service", "FooMethod"}};
+ for (uint32_t i = 0; i < GPR_ARRAY_SIZE(test_cases); i++) {
+ const char* url_scheme = test_cases[i].url_scheme;
+ grpc_slice call_host =
+ grpc_slice_from_copied_string(test_cases[i].call_host);
+ grpc_slice call_method =
+ grpc_slice_from_copied_string(test_cases[i].call_method);
+ grpc_auth_metadata_context auth_md_context;
+ memset(&auth_md_context, 0, sizeof(auth_md_context));
+ grpc_auth_metadata_context_build(url_scheme, call_host, call_method,
+ nullptr, &auth_md_context);
+ if (strcmp(auth_md_context.service_url,
+ test_cases[i].desired_service_url) != 0) {
+ gpr_log(GPR_ERROR, "Invalid service url, want: %s, got %s.",
+ test_cases[i].desired_service_url, auth_md_context.service_url);
+ GPR_ASSERT(false);
+ }
+ if (strcmp(auth_md_context.method_name,
+ test_cases[i].desired_method_name) != 0) {
+ gpr_log(GPR_ERROR, "Invalid method name, want: %s, got %s.",
+ test_cases[i].desired_method_name, auth_md_context.method_name);
+ GPR_ASSERT(false);
+ }
+ GPR_ASSERT(auth_md_context.channel_auth_context == nullptr);
+ grpc_slice_unref(call_host);
+ grpc_slice_unref(call_method);
+ grpc_auth_metadata_context_reset(&auth_md_context);
+ }
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_empty_md_array();
@@ -1205,6 +1251,7 @@ int main(int argc, char **argv) {
test_metadata_plugin_failure();
test_get_well_known_google_credentials_file_path();
test_channel_creds_duplicate_without_call_creds();
+ test_auth_metadata_context();
grpc_shutdown();
return 0;
}
diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.cc
index 3998cb51cd..cb28a0487c 100644
--- a/test/core/security/fetch_oauth2.c
+++ b/test/core/security/fetch_oauth2.cc
@@ -31,24 +31,24 @@
#include "src/core/lib/security/credentials/credentials.h"
#include "test/core/security/oauth2_utils.h"
-static grpc_call_credentials *create_refresh_token_creds(
- const char *json_refresh_token_file_path) {
+static grpc_call_credentials* create_refresh_token_creds(
+ const char* json_refresh_token_file_path) {
grpc_slice refresh_token;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file",
grpc_load_file(json_refresh_token_file_path, 1, &refresh_token)));
return grpc_google_refresh_token_credentials_create(
- (const char *)GRPC_SLICE_START_PTR(refresh_token), NULL);
+ (const char*)GRPC_SLICE_START_PTR(refresh_token), nullptr);
}
-int main(int argc, char **argv) {
- grpc_call_credentials *creds = NULL;
- char *json_key_file_path = NULL;
- char *json_refresh_token_file_path = NULL;
- char *token = NULL;
+int main(int argc, char** argv) {
+ grpc_call_credentials* creds = nullptr;
+ char* json_key_file_path = nullptr;
+ const char* json_refresh_token_file_path = nullptr;
+ char* token = nullptr;
int use_gce = 0;
- char *scope = NULL;
- gpr_cmdline *cl = gpr_cmdline_create("fetch_oauth2");
+ char* scope = nullptr;
+ gpr_cmdline* cl = gpr_cmdline_create("fetch_oauth2");
gpr_cmdline_add_string(cl, "json_refresh_token",
"File path of the json refresh token.",
&json_refresh_token_file_path);
@@ -60,26 +60,27 @@ int main(int argc, char **argv) {
grpc_init();
- if (json_key_file_path != NULL && json_refresh_token_file_path != NULL) {
+ if (json_key_file_path != nullptr &&
+ json_refresh_token_file_path != nullptr) {
gpr_log(GPR_ERROR,
"--json_key and --json_refresh_token are mutually exclusive.");
exit(1);
}
if (use_gce) {
- if (json_key_file_path != NULL || scope != NULL) {
+ if (json_key_file_path != nullptr || scope != nullptr) {
gpr_log(GPR_INFO,
"Ignoring json key and scope to get a token from the GCE "
"metadata server.");
}
- creds = grpc_google_compute_engine_credentials_create(NULL);
- if (creds == NULL) {
+ creds = grpc_google_compute_engine_credentials_create(nullptr);
+ if (creds == nullptr) {
gpr_log(GPR_ERROR, "Could not create gce credentials.");
exit(1);
}
- } else if (json_refresh_token_file_path != NULL) {
+ } else if (json_refresh_token_file_path != nullptr) {
creds = create_refresh_token_creds(json_refresh_token_file_path);
- if (creds == NULL) {
+ if (creds == nullptr) {
gpr_log(GPR_ERROR,
"Could not create refresh token creds. %s does probably not "
"contain a valid json refresh token.",
@@ -90,10 +91,10 @@ int main(int argc, char **argv) {
gpr_log(GPR_ERROR, "Missing --gce or --json_refresh_token option.");
exit(1);
}
- GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(creds != nullptr);
token = grpc_test_fetch_oauth2_token_with_credentials(creds);
- if (token != NULL) {
+ if (token != nullptr) {
printf("Got token: %s.\n", token);
gpr_free(token);
}
diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.cc
index 6573f70e72..aac9cc0029 100644
--- a/test/core/security/json_token_test.c
+++ b/test/core/security/json_token_test.cc
@@ -77,12 +77,13 @@ static const char test_scope[] = "myperm1 myperm2";
static const char test_service_url[] = "https://foo.com/foo.v1";
-static char *test_json_key_str(const char *bad_part3) {
- const char *part3 = bad_part3 != NULL ? bad_part3 : test_json_key_str_part3;
+static char* test_json_key_str(const char* bad_part3) {
+ const char* part3 =
+ bad_part3 != nullptr ? bad_part3 : test_json_key_str_part3;
size_t result_len = strlen(test_json_key_str_part1) +
strlen(test_json_key_str_part2) + strlen(part3);
- char *result = gpr_malloc(result_len + 1);
- char *current = result;
+ char* result = static_cast<char*>(gpr_malloc(result_len + 1));
+ char* current = result;
strcpy(result, test_json_key_str_part1);
current += strlen(test_json_key_str_part1);
strcpy(current, test_json_key_str_part2);
@@ -92,24 +93,24 @@ static char *test_json_key_str(const char *bad_part3) {
}
static void test_parse_json_key_success(void) {
- char *json_string = test_json_key_str(NULL);
+ char* json_string = test_json_key_str(nullptr);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(grpc_auth_json_key_is_valid(&json_key));
- GPR_ASSERT(json_key.type != NULL &&
+ GPR_ASSERT(json_key.type != nullptr &&
strcmp(json_key.type, "service_account") == 0);
- GPR_ASSERT(json_key.private_key_id != NULL &&
+ GPR_ASSERT(json_key.private_key_id != nullptr &&
strcmp(json_key.private_key_id,
"e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0);
- GPR_ASSERT(json_key.client_id != NULL &&
+ GPR_ASSERT(json_key.client_id != nullptr &&
strcmp(json_key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps."
"googleusercontent.com") == 0);
- GPR_ASSERT(json_key.client_email != NULL &&
+ GPR_ASSERT(json_key.client_email != nullptr &&
strcmp(json_key.client_email,
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- GPR_ASSERT(json_key.private_key != NULL);
+ GPR_ASSERT(json_key.private_key != nullptr);
gpr_free(json_string);
grpc_auth_json_key_destruct(&json_key);
}
@@ -122,7 +123,7 @@ static void test_parse_json_key_failure_bad_json(void) {
"com\", \"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\", \"type\": \"service_account\" ";
- char *json_string = test_json_key_str(non_closing_part3);
+ char* json_string = test_json_key_str(non_closing_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -138,7 +139,7 @@ static void test_parse_json_key_failure_no_type(void) {
"com\", \"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\" }";
- char *json_string = test_json_key_str(no_type_part3);
+ char* json_string = test_json_key_str(no_type_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -153,7 +154,7 @@ static void test_parse_json_key_failure_no_client_id(void) {
"\"777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount."
"com\", "
"\"type\": \"service_account\" }";
- char *json_string = test_json_key_str(no_client_id_part3);
+ char* json_string = test_json_key_str(no_client_id_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -167,7 +168,7 @@ static void test_parse_json_key_failure_no_client_email(void) {
"\"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\", \"type\": \"service_account\" }";
- char *json_string = test_json_key_str(no_client_email_part3);
+ char* json_string = test_json_key_str(no_client_email_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -182,7 +183,7 @@ static void test_parse_json_key_failure_no_private_key_id(void) {
"com\", \"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\", \"type\": \"service_account\" }";
- char *json_string = test_json_key_str(no_private_key_id_part3);
+ char* json_string = test_json_key_str(no_private_key_id_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -204,35 +205,35 @@ static void test_parse_json_key_failure_no_private_key(void) {
grpc_auth_json_key_destruct(&json_key);
}
-static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
- char **scratchpad) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- char *b64;
- char *decoded;
- grpc_json *json;
+static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
+ char** scratchpad) {
+ grpc_core::ExecCtx exec_ctx;
+ char* b64;
+ char* decoded;
+ grpc_json* json;
grpc_slice slice;
- b64 = gpr_malloc(len + 1);
+ b64 = static_cast<char*>(gpr_malloc(len + 1));
strncpy(b64, str, len);
b64[len] = '\0';
- slice = grpc_base64_decode(&exec_ctx, b64, 1);
+ slice = grpc_base64_decode(b64, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
- decoded = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
- strncpy(decoded, (const char *)GRPC_SLICE_START_PTR(slice),
+ decoded = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1));
+ strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
decoded[GRPC_SLICE_LENGTH(slice)] = '\0';
json = grpc_json_parse_string(decoded);
gpr_free(b64);
*scratchpad = decoded;
grpc_slice_unref(slice);
- grpc_exec_ctx_finish(&exec_ctx);
+
return json;
}
-static void check_jwt_header(grpc_json *header) {
- grpc_json *ptr;
- grpc_json *alg = NULL;
- grpc_json *typ = NULL;
- grpc_json *kid = NULL;
+static void check_jwt_header(grpc_json* header) {
+ grpc_json* ptr;
+ grpc_json* alg = nullptr;
+ grpc_json* typ = nullptr;
+ grpc_json* kid = nullptr;
for (ptr = header->child; ptr; ptr = ptr->next) {
if (strcmp(ptr->key, "alg") == 0) {
@@ -243,32 +244,32 @@ static void check_jwt_header(grpc_json *header) {
kid = ptr;
}
}
- GPR_ASSERT(alg != NULL);
+ GPR_ASSERT(alg != nullptr);
GPR_ASSERT(alg->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(alg->value, "RS256") == 0);
- GPR_ASSERT(typ != NULL);
+ GPR_ASSERT(typ != nullptr);
GPR_ASSERT(typ->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(typ->value, "JWT") == 0);
- GPR_ASSERT(kid != NULL);
+ GPR_ASSERT(kid != nullptr);
GPR_ASSERT(kid->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(kid->value, "e6b5137873db8d2ef81e06a47289e6434ec8a165") ==
0);
}
-static void check_jwt_claim(grpc_json *claim, const char *expected_audience,
- const char *expected_scope) {
+static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
+ const char* expected_scope) {
gpr_timespec expiration = gpr_time_0(GPR_CLOCK_REALTIME);
gpr_timespec issue_time = gpr_time_0(GPR_CLOCK_REALTIME);
gpr_timespec parsed_lifetime;
- grpc_json *iss = NULL;
- grpc_json *scope = NULL;
- grpc_json *aud = NULL;
- grpc_json *exp = NULL;
- grpc_json *iat = NULL;
- grpc_json *sub = NULL;
- grpc_json *ptr;
+ grpc_json* iss = nullptr;
+ grpc_json* scope = nullptr;
+ grpc_json* aud = nullptr;
+ grpc_json* exp = nullptr;
+ grpc_json* iat = nullptr;
+ grpc_json* sub = nullptr;
+ grpc_json* ptr;
for (ptr = claim->child; ptr; ptr = ptr->next) {
if (strcmp(ptr->key, "iss") == 0) {
@@ -286,7 +287,7 @@ static void check_jwt_claim(grpc_json *claim, const char *expected_audience,
}
}
- GPR_ASSERT(iss != NULL);
+ GPR_ASSERT(iss != nullptr);
GPR_ASSERT(iss->type == GRPC_JSON_STRING);
GPR_ASSERT(
strcmp(
@@ -294,117 +295,116 @@ static void check_jwt_claim(grpc_json *claim, const char *expected_audience,
"777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount.com") ==
0);
- if (expected_scope != NULL) {
- GPR_ASSERT(scope != NULL);
- GPR_ASSERT(sub == NULL);
+ if (expected_scope != nullptr) {
+ GPR_ASSERT(scope != nullptr);
+ GPR_ASSERT(sub == nullptr);
GPR_ASSERT(scope->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(scope->value, expected_scope) == 0);
} else {
/* Claims without scope must have a sub. */
- GPR_ASSERT(scope == NULL);
- GPR_ASSERT(sub != NULL);
+ GPR_ASSERT(scope == nullptr);
+ GPR_ASSERT(sub != nullptr);
GPR_ASSERT(sub->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(iss->value, sub->value) == 0);
}
- GPR_ASSERT(aud != NULL);
+ GPR_ASSERT(aud != nullptr);
GPR_ASSERT(aud->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(aud->value, expected_audience) == 0);
- GPR_ASSERT(exp != NULL);
+ GPR_ASSERT(exp != nullptr);
GPR_ASSERT(exp->type == GRPC_JSON_NUMBER);
- expiration.tv_sec = strtol(exp->value, NULL, 10);
+ expiration.tv_sec = strtol(exp->value, nullptr, 10);
- GPR_ASSERT(iat != NULL);
+ GPR_ASSERT(iat != nullptr);
GPR_ASSERT(iat->type == GRPC_JSON_NUMBER);
- issue_time.tv_sec = strtol(iat->value, NULL, 10);
+ issue_time.tv_sec = strtol(iat->value, nullptr, 10);
parsed_lifetime = gpr_time_sub(expiration, issue_time);
GPR_ASSERT(parsed_lifetime.tv_sec == grpc_max_auth_token_lifetime().tv_sec);
}
-static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
- const char *signed_data,
+static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
+ const char* signed_data,
size_t signed_data_size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
- EVP_PKEY *key = EVP_PKEY_new();
+ EVP_MD_CTX* md_ctx = EVP_MD_CTX_create();
+ EVP_PKEY* key = EVP_PKEY_new();
- grpc_slice sig = grpc_base64_decode(&exec_ctx, b64_signature, 1);
+ grpc_slice sig = grpc_base64_decode(b64_signature, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128);
- GPR_ASSERT(md_ctx != NULL);
- GPR_ASSERT(key != NULL);
+ GPR_ASSERT(md_ctx != nullptr);
+ GPR_ASSERT(key != nullptr);
EVP_PKEY_set1_RSA(key, rsa_key);
- GPR_ASSERT(EVP_DigestVerifyInit(md_ctx, NULL, EVP_sha256(), NULL, key) == 1);
+ GPR_ASSERT(
+ EVP_DigestVerifyInit(md_ctx, nullptr, EVP_sha256(), nullptr, key) == 1);
GPR_ASSERT(EVP_DigestVerifyUpdate(md_ctx, signed_data, signed_data_size) ==
1);
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig),
GRPC_SLICE_LENGTH(sig)) == 1);
- grpc_slice_unref_internal(&exec_ctx, sig);
- if (key != NULL) EVP_PKEY_free(key);
- if (md_ctx != NULL) EVP_MD_CTX_destroy(md_ctx);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(sig);
+ if (key != nullptr) EVP_PKEY_free(key);
+ if (md_ctx != nullptr) EVP_MD_CTX_destroy(md_ctx);
}
-static char *service_account_creds_jwt_encode_and_sign(
- const grpc_auth_json_key *key) {
+static char* service_account_creds_jwt_encode_and_sign(
+ const grpc_auth_json_key* key) {
return grpc_jwt_encode_and_sign(key, GRPC_JWT_OAUTH2_AUDIENCE,
grpc_max_auth_token_lifetime(), test_scope);
}
-static char *jwt_creds_jwt_encode_and_sign(const grpc_auth_json_key *key) {
+static char* jwt_creds_jwt_encode_and_sign(const grpc_auth_json_key* key) {
return grpc_jwt_encode_and_sign(key, test_service_url,
- grpc_max_auth_token_lifetime(), NULL);
+ grpc_max_auth_token_lifetime(), nullptr);
}
-static void service_account_creds_check_jwt_claim(grpc_json *claim) {
+static void service_account_creds_check_jwt_claim(grpc_json* claim) {
check_jwt_claim(claim, GRPC_JWT_OAUTH2_AUDIENCE, test_scope);
}
-static void jwt_creds_check_jwt_claim(grpc_json *claim) {
- check_jwt_claim(claim, test_service_url, NULL);
+static void jwt_creds_check_jwt_claim(grpc_json* claim) {
+ check_jwt_claim(claim, test_service_url, nullptr);
}
static void test_jwt_encode_and_sign(
- char *(*jwt_encode_and_sign_func)(const grpc_auth_json_key *),
- void (*check_jwt_claim_func)(grpc_json *)) {
- char *json_string = test_json_key_str(NULL);
- grpc_json *parsed_header = NULL;
- grpc_json *parsed_claim = NULL;
- char *scratchpad;
+ char* (*jwt_encode_and_sign_func)(const grpc_auth_json_key*),
+ void (*check_jwt_claim_func)(grpc_json*)) {
+ char* json_string = test_json_key_str(nullptr);
+ grpc_json* parsed_header = nullptr;
+ grpc_json* parsed_claim = nullptr;
+ char* scratchpad;
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
- const char *b64_signature;
+ const char* b64_signature;
size_t offset = 0;
- char *jwt = jwt_encode_and_sign_func(&json_key);
- const char *dot = strchr(jwt, '.');
- GPR_ASSERT(dot != NULL);
+ char* jwt = jwt_encode_and_sign_func(&json_key);
+ const char* dot = strchr(jwt, '.');
+ GPR_ASSERT(dot != nullptr);
parsed_header =
parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
- GPR_ASSERT(parsed_header != NULL);
+ GPR_ASSERT(parsed_header != nullptr);
check_jwt_header(parsed_header);
offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_header);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
- GPR_ASSERT(dot != NULL);
+ GPR_ASSERT(dot != nullptr);
parsed_claim = parse_json_part_from_jwt(
jwt + offset, (size_t)(dot - (jwt + offset)), &scratchpad);
- GPR_ASSERT(parsed_claim != NULL);
+ GPR_ASSERT(parsed_claim != nullptr);
check_jwt_claim_func(parsed_claim);
offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_claim);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
- GPR_ASSERT(dot == NULL); /* no more part. */
+ GPR_ASSERT(dot == nullptr); /* no more part. */
b64_signature = jwt + offset;
check_jwt_signature(b64_signature, json_key.private_key, jwt, offset - 1);
@@ -427,15 +427,15 @@ static void test_parse_refresh_token_success(void) {
grpc_auth_refresh_token refresh_token =
grpc_auth_refresh_token_create_from_string(test_refresh_token_str);
GPR_ASSERT(grpc_auth_refresh_token_is_valid(&refresh_token));
- GPR_ASSERT(refresh_token.type != NULL &&
+ GPR_ASSERT(refresh_token.type != nullptr &&
(strcmp(refresh_token.type, "authorized_user") == 0));
- GPR_ASSERT(refresh_token.client_id != NULL &&
+ GPR_ASSERT(refresh_token.client_id != nullptr &&
(strcmp(refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0));
GPR_ASSERT(
- refresh_token.client_secret != NULL &&
+ refresh_token.client_secret != nullptr &&
(strcmp(refresh_token.client_secret, "EmssLNjJy1332hD4KFsecret") == 0));
- GPR_ASSERT(refresh_token.refresh_token != NULL &&
+ GPR_ASSERT(refresh_token.refresh_token != nullptr &&
(strcmp(refresh_token.refresh_token,
"1/Blahblasj424jladJDSGNf-u4Sua3HDA2ngjd42") == 0));
grpc_auth_refresh_token_destruct(&refresh_token);
@@ -481,8 +481,9 @@ static void test_parse_refresh_token_failure_no_refresh_token(void) {
GPR_ASSERT(!grpc_auth_refresh_token_is_valid(&refresh_token));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_parse_json_key_success();
test_parse_json_key_failure_bad_json();
test_parse_json_key_failure_no_type();
@@ -497,5 +498,6 @@ int main(int argc, char **argv) {
test_parse_refresh_token_failure_no_client_id();
test_parse_refresh_token_failure_no_client_secret();
test_parse_refresh_token_failure_no_refresh_token();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.cc
index 9b17fb516d..e219260b1d 100644
--- a/test/core/security/jwt_verifier_test.c
+++ b/test/core/security/jwt_verifier_test.cc
@@ -167,19 +167,19 @@ static const char invalid_claims[] =
typedef struct {
grpc_jwt_verifier_status expected_status;
- const char *expected_issuer;
- const char *expected_subject;
+ const char* expected_issuer;
+ const char* expected_subject;
} verifier_test_config;
static void test_jwt_issuer_email_domain(void) {
- const char *d = grpc_jwt_issuer_email_domain("https://foo.com");
- GPR_ASSERT(d == NULL);
+ const char* d = grpc_jwt_issuer_email_domain("https://foo.com");
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("foo.com");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("@");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("bar@foo");
GPR_ASSERT(strcmp(d, "foo") == 0);
d = grpc_jwt_issuer_email_domain("bar@foo.com");
@@ -196,22 +196,22 @@ static void test_jwt_issuer_email_domain(void) {
d = grpc_jwt_issuer_email_domain("@foo");
GPR_ASSERT(strcmp(d, "foo") == 0);
d = grpc_jwt_issuer_email_domain("bar@.");
- GPR_ASSERT(d != NULL);
+ GPR_ASSERT(d != nullptr);
d = grpc_jwt_issuer_email_domain("bar@..");
- GPR_ASSERT(d != NULL);
+ GPR_ASSERT(d != nullptr);
d = grpc_jwt_issuer_email_domain("bar@...");
- GPR_ASSERT(d != NULL);
+ GPR_ASSERT(d != nullptr);
}
static void test_claims_success(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- GPR_ASSERT(json != NULL);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ GPR_ASSERT(json != nullptr);
+ grpc_core::ExecCtx exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
GPR_ASSERT(strcmp(grpc_jwt_claims_issuer(claims), "blah.foo.com") == 0);
@@ -219,22 +219,21 @@ static void test_claims_success(void) {
GPR_ASSERT(strcmp(grpc_jwt_claims_id(claims), "jwtuniqueid") == 0);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_OK);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_expired_claims_failure(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(expired_claims);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
- GPR_ASSERT(json != NULL);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(json != nullptr);
+ grpc_core::ExecCtx exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
GPR_ASSERT(strcmp(grpc_jwt_claims_issuer(claims), "blah.foo.com") == 0);
@@ -246,54 +245,50 @@ static void test_expired_claims_failure(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_TIME_CONSTRAINT_FAILURE);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == NULL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == nullptr);
}
static void test_bad_audience_claims_failure(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- GPR_ASSERT(json != NULL);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ GPR_ASSERT(json != nullptr);
+ grpc_core::ExecCtx exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_bad_subject_claims_failure(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_with_bad_subject);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- GPR_ASSERT(json != NULL);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ GPR_ASSERT(json != nullptr);
+ grpc_core::ExecCtx exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_BAD_SUBJECT);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
-static char *json_key_str(const char *last_part) {
+static char* json_key_str(const char* last_part) {
size_t result_len = strlen(json_key_str_part1) + strlen(json_key_str_part2) +
strlen(last_part);
- char *result = gpr_malloc(result_len + 1);
- char *current = result;
+ char* result = static_cast<char*>(gpr_malloc(result_len + 1));
+ char* current = result;
strcpy(result, json_key_str_part1);
current += strlen(json_key_str_part1);
strcpy(current, json_key_str_part2);
@@ -302,18 +297,18 @@ static char *json_key_str(const char *last_part) {
return result;
}
-static char *good_google_email_keys(void) {
+static char* good_google_email_keys(void) {
size_t result_len = strlen(good_google_email_keys_part1) +
strlen(good_google_email_keys_part2);
- char *result = gpr_malloc(result_len + 1);
- char *current = result;
+ char* result = static_cast<char*>(gpr_malloc(result_len + 1));
+ char* current = result;
strcpy(result, good_google_email_keys_part1);
current += strlen(good_google_email_keys_part1);
strcpy(current, good_google_email_keys_part2);
return result;
}
-static grpc_httpcli_response http_response(int status, char *body) {
+static grpc_httpcli_response http_response(int status, char* body) {
grpc_httpcli_response response;
memset(&response, 0, sizeof(grpc_httpcli_response));
response.status = status;
@@ -323,17 +318,16 @@ static grpc_httpcli_response http_response(int status, char *body) {
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size, gpr_timespec deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
- GPR_ASSERT("HTTP POST should not be called" == NULL);
+ const grpc_httpcli_request* request, const char* body_bytes,
+ size_t body_size, grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
+ GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
static int httpcli_get_google_keys_for_email(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, good_google_email_keys());
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
@@ -341,200 +335,194 @@ static int httpcli_get_google_keys_for_email(
"/robot/v1/metadata/x509/"
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static void on_verification_success(grpc_exec_ctx *exec_ctx, void *user_data,
+static void on_verification_success(void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
- GPR_ASSERT(claims != NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(claims != nullptr);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), expected_audience) == 0);
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
}
static void test_jwt_verifier_google_email_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
+ char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
grpc_httpcli_set_override(httpcli_get_google_keys_for_email,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
- on_verification_success, (void *)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
+ on_verification_success, (void*)expected_user_data);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_custom_keys_for_email(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/jwk/foo@bar.com") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_custom_email_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(&custom_mapping, 1);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_custom_email_issuer);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(&custom_mapping, 1);
+ char* jwt = nullptr;
+ char* key_str = json_key_str(json_key_str_part3_for_custom_email_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
grpc_httpcli_set_override(httpcli_get_custom_keys_for_email,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
- on_verification_success, (void *)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
+ on_verification_success, (void*)expected_user_data);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
-static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+static int httpcli_get_jwk_set(const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/oauth2/v3/certs") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- gpr_timespec deadline,
- grpc_closure *on_done,
- grpc_httpcli_response *response) {
+static int httpcli_get_openid_config(const grpc_httpcli_request* request,
+ grpc_millis deadline,
+ grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_openid_config));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "accounts.google.com") == 0);
GPR_ASSERT(strcmp(request->http.path, GRPC_OPENID_CONFIG_URL_SUFFIX) == 0);
grpc_httpcli_set_override(httpcli_get_jwk_set,
httpcli_post_should_not_be_called);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_url_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_url_issuer);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
+ char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
grpc_httpcli_set_override(httpcli_get_openid_config,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
- on_verification_success, (void *)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
+ on_verification_success, (void*)expected_user_data);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
-static void on_verification_key_retrieval_error(grpc_exec_ctx *exec_ctx,
- void *user_data,
+static void on_verification_key_retrieval_error(void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
- GPR_ASSERT(claims == NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(claims == nullptr);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
}
-static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- gpr_timespec deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+static int httpcli_get_bad_json(const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_url_issuer_bad_config(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_url_issuer);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
+ char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
grpc_httpcli_set_override(httpcli_get_bad_json,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
- (void *)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ (void*)expected_user_data);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void test_jwt_verifier_bad_json_key(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
+ char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
grpc_httpcli_set_override(httpcli_get_bad_json,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
- (void *)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ (void*)expected_user_data);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
-static void corrupt_jwt_sig(char *jwt) {
+static void corrupt_jwt_sig(char* jwt) {
grpc_slice sig;
- char *bad_b64_sig;
- uint8_t *sig_bytes;
- char *last_dot = strrchr(jwt, '.');
- GPR_ASSERT(last_dot != NULL);
+ char* bad_b64_sig;
+ uint8_t* sig_bytes;
+ char* last_dot = strrchr(jwt, '.');
+ GPR_ASSERT(last_dot != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- sig = grpc_base64_decode(&exec_ctx, last_dot + 1, 1);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ sig = grpc_base64_decode(last_dot + 1, 1);
}
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
sig_bytes = GRPC_SLICE_START_PTR(sig);
@@ -546,74 +534,72 @@ static void corrupt_jwt_sig(char *jwt) {
grpc_slice_unref(sig);
}
-static void on_verification_bad_signature(grpc_exec_ctx *exec_ctx,
- void *user_data,
+static void on_verification_bad_signature(void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
- GPR_ASSERT(claims == NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(claims == nullptr);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
}
static void test_jwt_verifier_bad_signature(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_url_issuer);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
+ char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
grpc_httpcli_set_override(httpcli_get_openid_config,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
corrupt_jwt_sig(jwt);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_bad_signature,
- (void *)expected_user_data);
+ (void*)expected_user_data);
gpr_free(jwt);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_httpcli_set_override(nullptr, nullptr);
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- gpr_timespec deadline,
- grpc_closure *on_done,
- grpc_httpcli_response *response) {
+static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
+ grpc_millis deadline,
+ grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT(0);
return 1;
}
-static void on_verification_bad_format(grpc_exec_ctx *exec_ctx, void *user_data,
+static void on_verification_bad_format(void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
- GPR_ASSERT(claims == NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(claims == nullptr);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
}
static void test_jwt_verifier_bad_format(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, "bad jwt",
- expected_audience, on_verification_bad_format,
- (void *)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_jwt_verifier_verify(verifier, nullptr, "bad jwt", expected_audience,
+ on_verification_bad_format,
+ (void*)expected_user_data);
+ grpc_jwt_verifier_destroy(verifier);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_httpcli_set_override(nullptr, nullptr);
}
/* find verification key: bad jks, cannot find key in jks */
/* bad signature custom provided email*/
/* bad key */
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_jwt_issuer_email_domain();
diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.cc
index d240403a29..0d3a1279af 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.cc
@@ -30,90 +30,85 @@
#include "src/core/lib/security/credentials/credentials.h"
typedef struct {
- gpr_mu *mu;
+ gpr_mu* mu;
grpc_polling_entity pops;
bool is_done;
- char *token;
+ char* token;
grpc_credentials_mdelem_array md_array;
grpc_closure closure;
} oauth2_request;
-static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- oauth2_request *request = (oauth2_request *)arg;
- char *token = NULL;
+static void on_oauth2_response(void* arg, grpc_error* error) {
+ oauth2_request* request = (oauth2_request*)arg;
+ char* token = nullptr;
grpc_slice token_slice;
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Fetching token failed: %s", grpc_error_string(error));
} else {
GPR_ASSERT(request->md_array.size == 1);
token_slice = GRPC_MDVALUE(request->md_array.md[0]);
- token = (char *)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1);
+ token = (char*)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1);
memcpy(token, GRPC_SLICE_START_PTR(token_slice),
GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0';
}
- grpc_credentials_mdelem_array_destroy(exec_ctx, &request->md_array);
+ grpc_credentials_mdelem_array_destroy(&request->md_array);
gpr_mu_lock(request->mu);
request->is_done = true;
request->token = token;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&request->pops),
- NULL));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&request->pops), nullptr));
gpr_mu_unlock(request->mu);
}
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused,
- grpc_error *error) {}
+static void do_nothing(void* unused, grpc_error* error) {}
-char *grpc_test_fetch_oauth2_token_with_credentials(
- grpc_call_credentials *creds) {
+char* grpc_test_fetch_oauth2_token_with_credentials(
+ grpc_call_credentials* creds) {
oauth2_request request;
memset(&request, 0, sizeof(request));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_closure do_nothing_closure;
- grpc_auth_metadata_context null_ctx = {"", "", NULL, NULL};
+ grpc_auth_metadata_context null_ctx = {"", "", nullptr, nullptr};
- grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &request.mu);
request.pops = grpc_polling_entity_create_from_pollset(pollset);
request.is_done = false;
- GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL,
+ GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&request.closure, on_oauth2_response, &request,
grpc_schedule_on_exec_ctx);
- grpc_error *error = GRPC_ERROR_NONE;
- if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, creds, &request.pops, null_ctx, &request.md_array,
- &request.closure, &error)) {
+ grpc_error* error = GRPC_ERROR_NONE;
+ if (grpc_call_credentials_get_request_metadata(creds, &request.pops, null_ctx,
+ &request.md_array,
+ &request.closure, &error)) {
// Synchronous result; invoke callback directly.
- on_oauth2_response(&exec_ctx, &request, error);
+ on_oauth2_response(&request, error);
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(request.mu);
while (!request.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx,
- grpc_polling_entity_pollset(&request.pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC)))) {
+ grpc_pollset_work(grpc_polling_entity_pollset(&request.pops),
+ &worker, GRPC_MILLIS_INF_FUTURE))) {
request.is_done = true;
}
}
gpr_mu_unlock(request.mu);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&request.pops),
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&request.pops),
&do_nothing_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(grpc_polling_entity_pollset(&request.pops));
return request.token;
}
diff --git a/test/core/security/oauth2_utils.h b/test/core/security/oauth2_utils.h
index 15f68bd6d8..5ad2e398e1 100644
--- a/test/core/security/oauth2_utils.h
+++ b/test/core/security/oauth2_utils.h
@@ -21,17 +21,9 @@
#include "src/core/lib/security/credentials/credentials.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Fetch oauth2 access token with a credentials object. Does not take ownership.
Returns NULL on a failure. The caller should call gpr_free on the token. */
-char *grpc_test_fetch_oauth2_token_with_credentials(
- grpc_call_credentials *creds);
-
-#ifdef __cplusplus
-}
-#endif
+char* grpc_test_fetch_oauth2_token_with_credentials(
+ grpc_call_credentials* creds);
#endif /* GRPC_TEST_CORE_SECURITY_OAUTH2_UTILS_H */
diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.cc
index 3144717a85..a90f997bda 100644
--- a/test/core/security/print_google_default_creds_token.c
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -27,13 +27,13 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
+#include "src/core/lib/gpr/string.h"
#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 "src/core/lib/support/string.h"
typedef struct {
- gpr_mu *mu;
+ gpr_mu* mu;
grpc_polling_entity pops;
bool is_done;
@@ -41,13 +41,13 @@ typedef struct {
grpc_closure on_request_metadata;
} synchronizer;
-static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- synchronizer *sync = arg;
+static void on_metadata_response(void* arg, grpc_error* error) {
+ synchronizer* sync = static_cast<synchronizer*>(arg);
if (error != GRPC_ERROR_NONE) {
fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error));
+ fflush(stderr);
} else {
- char *token;
+ char* token;
GPR_ASSERT(sync->md_array.size == 1);
token = grpc_slice_to_c_string(GRPC_MDVALUE(sync->md_array.md[0]));
printf("\nGot token: %s\n\n", token);
@@ -57,19 +57,20 @@ static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *arg,
sync->is_done = true;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&sync->pops),
- NULL));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&sync->pops), nullptr));
gpr_mu_unlock(sync->mu);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int result = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
synchronizer sync;
- grpc_channel_credentials *creds = NULL;
- char *service_url = "https://test.foo.google.com/Foo";
+ grpc_channel_credentials* creds = nullptr;
+ const char* service_url = "https://test.foo.google.com/Foo";
grpc_auth_metadata_context context;
- gpr_cmdline *cl = gpr_cmdline_create("print_google_default_creds_token");
+ gpr_cmdline* cl = gpr_cmdline_create("print_google_default_creds_token");
+ grpc_pollset* pollset = nullptr;
+ grpc_error* error = nullptr;
gpr_cmdline_add_string(cl, "service_url",
"Service URL for the token request.", &service_url);
gpr_cmdline_parse(cl, argc, argv);
@@ -79,48 +80,44 @@ int main(int argc, char **argv) {
grpc_init();
creds = grpc_google_default_credentials_create();
- if (creds == NULL) {
+ if (creds == nullptr) {
fprintf(stderr, "\nCould not find default credentials.\n\n");
+ fflush(stderr);
result = 1;
goto end;
}
memset(&sync, 0, sizeof(sync));
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
+ pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &sync.mu);
sync.pops = grpc_polling_entity_create_from_pollset(pollset);
sync.is_done = false;
GRPC_CLOSURE_INIT(&sync.on_request_metadata, on_metadata_response, &sync,
grpc_schedule_on_exec_ctx);
- grpc_error *error = GRPC_ERROR_NONE;
+ error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds,
- &sync.pops, context, &sync.md_array, &sync.on_request_metadata,
- &error)) {
+ ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops,
+ context, &sync.md_array, &sync.on_request_metadata, &error)) {
// Synchronous response. Invoke callback directly.
- on_metadata_response(&exec_ctx, &sync, error);
+ on_metadata_response(&sync, error);
GRPC_ERROR_UNREF(error);
}
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx,
- grpc_polling_entity_pollset(&sync.pops), &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))))
+ grpc_pollset_work(grpc_polling_entity_pollset(&sync.pops), &worker,
+ GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_finish(&exec_ctx);
-
grpc_channel_credentials_release(creds);
gpr_free(grpc_polling_entity_pollset(&sync.pops));
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.cc
index 839a05fa9b..38c78fed42 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.cc
@@ -32,50 +32,53 @@
#include "src/core/tsi/fake_transport_security.h"
#include "test/core/util/test_config.h"
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
- size_t slice_size, grpc_slice *leftover_slices, size_t leftover_nslices,
+ size_t slice_size, grpc_slice* leftover_slices, size_t leftover_nslices,
bool use_zero_copy_protector) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- tsi_frame_protector *fake_read_protector =
- tsi_create_fake_frame_protector(NULL);
- tsi_frame_protector *fake_write_protector =
- tsi_create_fake_frame_protector(NULL);
- tsi_zero_copy_grpc_protector *fake_read_zero_copy_protector =
- use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL)
- : NULL;
- tsi_zero_copy_grpc_protector *fake_write_zero_copy_protector =
- use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL)
- : NULL;
+ grpc_core::ExecCtx exec_ctx;
+ tsi_frame_protector* fake_read_protector =
+ tsi_create_fake_frame_protector(nullptr);
+ tsi_frame_protector* fake_write_protector =
+ tsi_create_fake_frame_protector(nullptr);
+ tsi_zero_copy_grpc_protector* fake_read_zero_copy_protector =
+ use_zero_copy_protector
+ ? tsi_create_fake_zero_copy_grpc_protector(nullptr)
+ : nullptr;
+ tsi_zero_copy_grpc_protector* fake_write_zero_copy_protector =
+ use_zero_copy_protector
+ ? tsi_create_fake_zero_copy_grpc_protector(nullptr)
+ : nullptr;
grpc_endpoint_test_fixture f;
grpc_endpoint_pair tcp;
- grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE,
- .type = GRPC_ARG_INTEGER,
- .value.integer = (int)slice_size}};
- grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
+ grpc_arg a[1];
+ a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
+ a[0].type = GRPC_ARG_INTEGER;
+ a[0].value.integer = (int)slice_size;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
tcp = grpc_iomgr_create_endpoint_pair("fixture", &args);
- grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.client, g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.server, g_pollset);
if (leftover_nslices == 0) {
f.client_ep = grpc_secure_endpoint_create(fake_read_protector,
fake_read_zero_copy_protector,
- tcp.client, NULL, 0);
+ tcp.client, nullptr, 0);
} else {
unsigned i;
tsi_result result;
size_t still_pending_size;
size_t total_buffer_size = 8192;
size_t buffer_size = total_buffer_size;
- uint8_t *encrypted_buffer = (uint8_t *)gpr_malloc(buffer_size);
- uint8_t *cur = encrypted_buffer;
+ uint8_t* encrypted_buffer = (uint8_t*)gpr_malloc(buffer_size);
+ uint8_t* cur = encrypted_buffer;
grpc_slice encrypted_leftover;
for (i = 0; i < leftover_nslices; i++) {
grpc_slice plain = leftover_slices[i];
- uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain);
+ uint8_t* message_bytes = GRPC_SLICE_START_PTR(plain);
size_t message_size = GRPC_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = buffer_size;
@@ -103,7 +106,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
buffer_size -= protected_buffer_size_to_send;
} while (still_pending_size > 0);
encrypted_leftover = grpc_slice_from_copied_buffer(
- (const char *)encrypted_buffer, total_buffer_size - buffer_size);
+ (const char*)encrypted_buffer, total_buffer_size - buffer_size);
f.client_ep = grpc_secure_endpoint_create(
fake_read_protector, fake_read_zero_copy_protector, tcp.client,
&encrypted_leftover, 1);
@@ -113,21 +116,21 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
f.server_ep = grpc_secure_endpoint_create(fake_write_protector,
fake_write_zero_copy_protector,
- tcp.server, NULL, 0);
- grpc_exec_ctx_finish(&exec_ctx);
+ tcp.server, nullptr, 0);
+
return f;
}
static grpc_endpoint_test_fixture
secure_endpoint_create_fixture_tcp_socketpair_noleftover(size_t slice_size) {
- return secure_endpoint_create_fixture_tcp_socketpair(slice_size, NULL, 0,
+ return secure_endpoint_create_fixture_tcp_socketpair(slice_size, nullptr, 0,
false);
}
static grpc_endpoint_test_fixture
secure_endpoint_create_fixture_tcp_socketpair_noleftover_zero_copy(
size_t slice_size) {
- return secure_endpoint_create_fixture_tcp_socketpair(slice_size, NULL, 0,
+ return secure_endpoint_create_fixture_tcp_socketpair(slice_size, nullptr, 0,
true);
}
@@ -162,65 +165,62 @@ static grpc_endpoint_test_config configs[] = {
clean_up},
};
-static void inc_call_ctr(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- ++*(int *)arg;
-}
+static void inc_call_ctr(void* arg, grpc_error* error) { ++*(int*)arg; }
static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
grpc_slice_buffer incoming;
grpc_slice s =
grpc_slice_from_copied_string("hello world 12345678900987654321");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
int n = 0;
grpc_closure done_closure;
gpr_log(GPR_INFO, "Start test left over");
grpc_slice_buffer_init(&incoming);
GRPC_CLOSURE_INIT(&done_closure, inc_call_ctr, &n, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming, &done_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_read(f.client_ep, &incoming, &done_closure);
+
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(n == 1);
GPR_ASSERT(incoming.count == 1);
GPR_ASSERT(grpc_slice_eq(s, incoming.slices[0]));
grpc_endpoint_shutdown(
- &exec_ctx, f.client_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
+ f.client_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
grpc_endpoint_shutdown(
- &exec_ctx, f.server_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
- grpc_endpoint_destroy(&exec_ctx, f.client_ep);
- grpc_endpoint_destroy(&exec_ctx, f.server_ep);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_slice_unref_internal(&exec_ctx, s);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
+ f.server_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
+ grpc_endpoint_destroy(f.client_ep);
+ grpc_endpoint_destroy(f.server_ep);
+
+ grpc_slice_unref_internal(s);
+ grpc_slice_buffer_destroy_internal(&incoming);
clean_up();
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
-
grpc_init();
- g_pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(g_pollset, &g_mu);
- grpc_endpoint_tests(configs[0], g_pollset, g_mu);
- grpc_endpoint_tests(configs[1], g_pollset, g_mu);
- test_leftover(configs[2], 1);
- test_leftover(configs[3], 1);
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+
+ {
+ grpc_core::ExecCtx exec_ctx;
+ g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset_init(g_pollset, &g_mu);
+ grpc_endpoint_tests(configs[0], g_pollset, g_mu);
+ grpc_endpoint_tests(configs[1], g_pollset, g_mu);
+ test_leftover(configs[2], 1);
+ test_leftover(configs[3], 1);
+ GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+ }
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.cc
index eecf0f462b..6eaef2bf49 100644
--- a/test/core/security/security_connector_test.c
+++ b/test/core/security/security_connector_test.cc
@@ -25,35 +25,35 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/transport/security_connector.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "src/core/tsi/ssl_transport_security.h"
#include "src/core/tsi/transport_security.h"
#include "test/core/util/test_config.h"
-static int check_transport_security_type(const grpc_auth_context *ctx) {
+static int check_transport_security_type(const grpc_auth_context* ctx) {
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
- if (prop == NULL) return 0;
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
+ if (prop == nullptr) return 0;
if (strncmp(prop->value, GRPC_SSL_TRANSPORT_SECURITY_TYPE,
prop->value_length) != 0) {
return 0;
}
/* Check that we have only one property with this name. */
- if (grpc_auth_property_iterator_next(&it) != NULL) return 0;
+ if (grpc_auth_property_iterator_next(&it) != nullptr) return 0;
return 1;
}
-static int check_peer_property(const tsi_peer *peer,
- const tsi_peer_property *expected) {
+static int check_peer_property(const tsi_peer* peer,
+ const tsi_peer_property* expected) {
size_t i;
for (i = 0; i < peer->property_count; i++) {
- const tsi_peer_property *prop = &peer->properties[i];
+ const tsi_peer_property* prop = &peer->properties[i];
if ((strcmp(prop->name, expected->name) == 0) &&
(prop->value.length == expected->value.length) &&
(memcmp(prop->value.data, expected->value.data,
@@ -64,12 +64,12 @@ static int check_peer_property(const tsi_peer *peer,
return 0; /* Not found... */
}
-static int check_ssl_peer_equivalence(const tsi_peer *original,
- const tsi_peer *reconstructed) {
+static int check_ssl_peer_equivalence(const tsi_peer* original,
+ const tsi_peer* reconstructed) {
/* The reconstructed peer only has CN, SAN and pem cert properties. */
size_t i;
for (i = 0; i < original->property_count; i++) {
- const tsi_peer_property *prop = &original->properties[i];
+ const tsi_peer_property* prop = &original->properties[i];
if ((strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) ||
(strcmp(prop->name, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) ==
0) ||
@@ -83,13 +83,13 @@ static int check_ssl_peer_equivalence(const tsi_peer *original,
static void test_unauthenticated_ssl_peer(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
+ grpc_auth_context* ctx;
GPR_ASSERT(tsi_construct_peer(1, &peer) == TSI_OK);
GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
&peer.properties[0]) == TSI_OK);
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(!grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_transport_security_type(ctx));
@@ -101,18 +101,18 @@ static void test_unauthenticated_ssl_peer(void) {
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
-static int check_identity(const grpc_auth_context *ctx,
- const char *expected_property_name,
- const char **expected_identities,
+static int check_identity(const grpc_auth_context* ctx,
+ const char* expected_property_name,
+ const char** expected_identities,
size_t num_identities) {
grpc_auth_property_iterator it;
- const grpc_auth_property *prop;
+ const grpc_auth_property* prop;
size_t i;
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
it = grpc_auth_context_peer_identity(ctx);
for (i = 0; i < num_identities; i++) {
prop = grpc_auth_property_iterator_next(&it);
- if (prop == NULL) {
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "Expected identity value %s not found.",
expected_identities[i]);
return 0;
@@ -131,12 +131,12 @@ static int check_identity(const grpc_auth_context *ctx,
return 1;
}
-static int check_x509_cn(const grpc_auth_context *ctx,
- const char *expected_cn) {
+static int check_x509_cn(const grpc_auth_context* ctx,
+ const char* expected_cn) {
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_CN_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
- if (prop == NULL) {
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "CN property not found.");
return 0;
}
@@ -144,19 +144,19 @@ static int check_x509_cn(const grpc_auth_context *ctx,
gpr_log(GPR_ERROR, "Expected CN %s and got %s", expected_cn, prop->value);
return 0;
}
- if (grpc_auth_property_iterator_next(&it) != NULL) {
+ if (grpc_auth_property_iterator_next(&it) != nullptr) {
gpr_log(GPR_ERROR, "Expected only one property for CN.");
return 0;
}
return 1;
}
-static int check_x509_pem_cert(const grpc_auth_context *ctx,
- const char *expected_pem_cert) {
+static int check_x509_pem_cert(const grpc_auth_context* ctx,
+ const char* expected_pem_cert) {
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
- if (prop == NULL) {
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "Pem certificate property not found.");
return 0;
}
@@ -165,7 +165,7 @@ static int check_x509_pem_cert(const grpc_auth_context *ctx,
prop->value);
return 0;
}
- if (grpc_auth_property_iterator_next(&it) != NULL) {
+ if (grpc_auth_property_iterator_next(&it) != nullptr) {
gpr_log(GPR_ERROR, "Expected only one property for pem cert.");
return 0;
}
@@ -175,9 +175,9 @@ static int check_x509_pem_cert(const grpc_auth_context *ctx,
static void test_cn_only_ssl_peer_to_auth_context(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_pem_cert = "pem_cert1";
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_pem_cert = "pem_cert1";
GPR_ASSERT(tsi_construct_peer(3, &peer) == TSI_OK);
GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
@@ -189,7 +189,7 @@ static void test_cn_only_ssl_peer_to_auth_context(void) {
TSI_X509_PEM_CERT_PROPERTY, expected_pem_cert,
&peer.properties[2]) == TSI_OK);
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_identity(ctx, GRPC_X509_CN_PROPERTY_NAME, &expected_cn, 1));
GPR_ASSERT(check_transport_security_type(ctx));
@@ -207,10 +207,10 @@ static void test_cn_only_ssl_peer_to_auth_context(void) {
static void test_cn_and_one_san_ssl_peer_to_auth_context(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_san = "san1";
- const char *expected_pem_cert = "pem_cert1";
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_san = "san1";
+ const char* expected_pem_cert = "pem_cert1";
GPR_ASSERT(tsi_construct_peer(4, &peer) == TSI_OK);
GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
@@ -225,7 +225,7 @@ static void test_cn_and_one_san_ssl_peer_to_auth_context(void) {
TSI_X509_PEM_CERT_PROPERTY, expected_pem_cert,
&peer.properties[3]) == TSI_OK);
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(
check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, &expected_san, 1));
@@ -244,10 +244,10 @@ static void test_cn_and_one_san_ssl_peer_to_auth_context(void) {
static void test_cn_and_multiple_sans_ssl_peer_to_auth_context(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_sans[] = {"san1", "san2", "san3"};
- const char *expected_pem_cert = "pem_cert1";
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_sans[] = {"san1", "san2", "san3"};
+ const char* expected_pem_cert = "pem_cert1";
size_t i;
GPR_ASSERT(tsi_construct_peer(3 + GPR_ARRAY_SIZE(expected_sans), &peer) ==
TSI_OK);
@@ -266,7 +266,7 @@ static void test_cn_and_multiple_sans_ssl_peer_to_auth_context(void) {
expected_sans[i], &peer.properties[3 + i]) == TSI_OK);
}
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, expected_sans,
GPR_ARRAY_SIZE(expected_sans)));
@@ -286,10 +286,10 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_pem_cert = "pem_cert1";
- const char *expected_sans[] = {"san1", "san2", "san3"};
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_pem_cert = "pem_cert1";
+ const char* expected_sans[] = {"san1", "san2", "san3"};
size_t i;
GPR_ASSERT(tsi_construct_peer(5 + GPR_ARRAY_SIZE(expected_sans), &peer) ==
TSI_OK);
@@ -312,7 +312,7 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
expected_sans[i], &peer.properties[5 + i]) == TSI_OK);
}
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, expected_sans,
GPR_ARRAY_SIZE(expected_sans)));
@@ -328,24 +328,24 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
-static const char *roots_for_override_api = "roots for override api";
+static const char* roots_for_override_api = "roots for override api";
static grpc_ssl_roots_override_result override_roots_success(
- char **pem_root_certs) {
+ char** pem_root_certs) {
*pem_root_certs = gpr_strdup(roots_for_override_api);
return GRPC_SSL_ROOTS_OVERRIDE_OK;
}
static grpc_ssl_roots_override_result override_roots_permanent_failure(
- char **pem_root_certs) {
+ char** pem_root_certs) {
return GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY;
}
static void test_default_ssl_roots(void) {
- const char *roots_for_env_var = "roots for env var";
+ const char* roots_for_env_var = "roots for env var";
- char *roots_env_var_file_path;
- FILE *roots_env_var_file =
+ char* roots_env_var_file_path;
+ FILE* roots_env_var_file =
gpr_tmpfile("test_roots_for_env_var", &roots_env_var_file_path);
fwrite(roots_for_env_var, 1, strlen(roots_for_env_var), roots_env_var_file);
fclose(roots_env_var_file);
@@ -355,7 +355,7 @@ static void test_default_ssl_roots(void) {
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, "");
grpc_set_ssl_roots_override_callback(override_roots_success);
grpc_slice roots = grpc_get_default_ssl_roots_for_testing();
- char *roots_contents = grpc_slice_to_c_string(roots);
+ char* roots_contents = grpc_slice_to_c_string(roots);
grpc_slice_unref(roots);
GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0);
gpr_free(roots_contents);
@@ -389,7 +389,7 @@ static void test_default_ssl_roots(void) {
gpr_free(roots_env_var_file_path);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
diff --git a/test/core/security/ssl_credentials_test.cc b/test/core/security/ssl_credentials_test.cc
new file mode 100644
index 0000000000..9edcf42d3a
--- /dev/null
+++ b/test/core/security/ssl_credentials_test.cc
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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 <stdio.h>
+#include <string.h>
+
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
+#include "src/core/tsi/ssl_transport_security.h"
+#include "test/core/util/test_config.h"
+
+static void test_convert_grpc_to_tsi_cert_pairs() {
+ grpc_ssl_pem_key_cert_pair grpc_pairs[] = {{"private_key1", "cert_chain1"},
+ {"private_key2", "cert_chain2"},
+ {"private_key3", "cert_chain3"}};
+ const size_t num_pairs = 3;
+
+ {
+ tsi_ssl_pem_key_cert_pair* tsi_pairs =
+ grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, 0);
+ GPR_ASSERT(tsi_pairs == nullptr);
+ }
+
+ {
+ tsi_ssl_pem_key_cert_pair* tsi_pairs =
+ grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, num_pairs);
+
+ GPR_ASSERT(tsi_pairs != nullptr);
+ for (size_t i = 0; i < num_pairs; i++) {
+ GPR_ASSERT(strncmp(grpc_pairs[i].private_key, tsi_pairs[i].private_key,
+ strlen(grpc_pairs[i].private_key)) == 0);
+ GPR_ASSERT(strncmp(grpc_pairs[i].cert_chain, tsi_pairs[i].cert_chain,
+ strlen(grpc_pairs[i].cert_chain)) == 0);
+ }
+
+ grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_pairs, num_pairs);
+ }
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ test_convert_grpc_to_tsi_cert_pairs();
+
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c
deleted file mode 100644
index 9858b11c7c..0000000000
--- a/test/core/security/ssl_server_fuzzer.c
+++ /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 <grpc/grpc.h>
-#include <grpc/grpc_security.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/iomgr/load_file.h"
-#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/security/transport/security_connector.h"
-#include "test/core/end2end/data/ssl_test_data.h"
-#include "test/core/util/memory_counters.h"
-#include "test/core/util/mock_endpoint.h"
-
-bool squelch = true;
-// ssl has an array of global gpr_mu's that are never released.
-// Turning this on will fail the leak check.
-bool leak_check = false;
-
-static void discard_write(grpc_slice slice) {}
-
-static void dont_log(gpr_log_func_args *args) {}
-
-struct handshake_state {
- bool done_callback_called;
-};
-
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = arg;
- struct handshake_state *state = args->user_data;
- GPR_ASSERT(state->done_callback_called == false);
- state->done_callback_called = true;
- // The fuzzer should not pass the handshake.
- GPR_ASSERT(error != GRPC_ERROR_NONE);
-}
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- struct grpc_memory_counters counters;
- if (squelch) gpr_set_log_function(dont_log);
- if (leak_check) grpc_memory_counters_init();
- grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("ssl_server_fuzzer");
- grpc_endpoint *mock_endpoint =
- grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
-
- grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char *)data, size));
-
- // Load key pair and establish server SSL credentials.
- grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
- grpc_slice ca_slice, cert_slice, key_slice;
- ca_slice = grpc_slice_from_static_string(test_root_cert);
- cert_slice = grpc_slice_from_static_string(test_server1_cert);
- key_slice = grpc_slice_from_static_string(test_server1_key);
- const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
- pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
- grpc_server_credentials *creds = grpc_ssl_server_credentials_create(
- ca_cert, &pem_key_cert_pair, 1, 0, NULL);
-
- // Create security connector
- grpc_server_security_connector *sc = NULL;
- grpc_security_status status =
- grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
- GPR_ASSERT(status == GRPC_SECURITY_OK);
- gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(1, GPR_TIMESPAN));
-
- struct handshake_state state;
- state.done_callback_called = false;
- grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
- grpc_server_security_connector_add_handshakers(&exec_ctx, sc, handshake_mgr);
- grpc_handshake_manager_do_handshake(
- &exec_ctx, handshake_mgr, mock_endpoint, NULL /* channel_args */,
- deadline, NULL /* acceptor */, on_handshake_done, &state);
- grpc_exec_ctx_flush(&exec_ctx);
-
- // If the given string happens to be part of the correct client hello, the
- // server will wait for more data. Explicitly fail the server by shutting down
- // the endpoint.
- if (!state.done_callback_called) {
- grpc_endpoint_shutdown(
- &exec_ctx, mock_endpoint,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
- grpc_exec_ctx_flush(&exec_ctx);
- }
-
- GPR_ASSERT(state.done_callback_called);
-
- grpc_handshake_manager_destroy(&exec_ctx, handshake_mgr);
- GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "test");
- grpc_server_credentials_release(creds);
- grpc_slice_unref(cert_slice);
- grpc_slice_unref(key_slice);
- grpc_slice_unref(ca_slice);
- grpc_exec_ctx_flush(&exec_ctx);
-
- grpc_shutdown();
- if (leak_check) {
- counters = grpc_memory_counters_snapshot();
- grpc_memory_counters_destroy();
- GPR_ASSERT(counters.total_size_relative == 0);
- }
- return 0;
-}
diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc
new file mode 100644
index 0000000000..6e30698562
--- /dev/null
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -0,0 +1,129 @@
+/*
+ *
+ * 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 <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/iomgr/load_file.h"
+#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/security/transport/security_connector.h"
+#include "test/core/end2end/data/ssl_test_data.h"
+#include "test/core/util/memory_counters.h"
+#include "test/core/util/mock_endpoint.h"
+
+bool squelch = true;
+// ssl has an array of global gpr_mu's that are never released.
+// Turning this on will fail the leak check.
+bool leak_check = false;
+
+static void discard_write(grpc_slice slice) {}
+
+static void dont_log(gpr_log_func_args* args) {}
+
+struct handshake_state {
+ bool done_callback_called;
+};
+
+static void on_handshake_done(void* arg, grpc_error* error) {
+ grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg);
+ struct handshake_state* state =
+ static_cast<struct handshake_state*>(args->user_data);
+ GPR_ASSERT(state->done_callback_called == false);
+ state->done_callback_called = true;
+ // The fuzzer should not pass the handshake.
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ struct grpc_memory_counters counters;
+ if (squelch) gpr_set_log_function(dont_log);
+ if (leak_check) grpc_memory_counters_init();
+ grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("ssl_server_fuzzer");
+ grpc_endpoint* mock_endpoint =
+ grpc_mock_endpoint_create(discard_write, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
+
+ grpc_mock_endpoint_put_read(
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
+
+ // Load key pair and establish server SSL credentials.
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
+ grpc_slice ca_slice, cert_slice, key_slice;
+ ca_slice = grpc_slice_from_static_string(test_root_cert);
+ cert_slice = grpc_slice_from_static_string(test_server1_cert);
+ key_slice = grpc_slice_from_static_string(test_server1_key);
+ const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key =
+ (const char*)GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain =
+ (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ grpc_server_credentials* creds = grpc_ssl_server_credentials_create(
+ ca_cert, &pem_key_cert_pair, 1, 0, nullptr);
+
+ // Create security connector
+ grpc_server_security_connector* sc = nullptr;
+ grpc_security_status status =
+ grpc_server_credentials_create_security_connector(creds, &sc);
+ GPR_ASSERT(status == GRPC_SECURITY_OK);
+ grpc_millis deadline = GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now();
+
+ struct handshake_state state;
+ state.done_callback_called = false;
+ grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
+ grpc_server_security_connector_add_handshakers(sc, handshake_mgr);
+ grpc_handshake_manager_do_handshake(
+ handshake_mgr, nullptr /* interested_parties */, mock_endpoint,
+ nullptr /* channel_args */, deadline, nullptr /* acceptor */,
+ on_handshake_done, &state);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // If the given string happens to be part of the correct client hello, the
+ // server will wait for more data. Explicitly fail the server by shutting
+ // down the endpoint.
+ if (!state.done_callback_called) {
+ grpc_endpoint_shutdown(
+ mock_endpoint,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+
+ GPR_ASSERT(state.done_callback_called);
+
+ grpc_handshake_manager_destroy(handshake_mgr);
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "test");
+ grpc_server_credentials_release(creds);
+ grpc_slice_unref(cert_slice);
+ grpc_slice_unref(key_slice);
+ grpc_slice_unref(ca_slice);
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+
+ grpc_shutdown();
+ if (leak_check) {
+ counters = grpc_memory_counters_snapshot();
+ grpc_memory_counters_destroy();
+ GPR_ASSERT(counters.total_size_relative == 0);
+ }
+ return 0;
+}
diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.cc
index 5faa6352a8..5d32ce0cdb 100644
--- a/test/core/security/verify_jwt.c
+++ b/test/core/security/verify_jwt.cc
@@ -30,94 +30,93 @@
#include "src/core/lib/security/credentials/jwt/jwt_verifier.h"
typedef struct {
- grpc_pollset *pollset;
- gpr_mu *mu;
+ grpc_pollset* pollset;
+ gpr_mu* mu;
int is_done;
int success;
} synchronizer;
-static void print_usage_and_exit(gpr_cmdline *cl, const char *argv0) {
- char *usage = gpr_cmdline_usage_string(cl, argv0);
+static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) {
+ char* usage = gpr_cmdline_usage_string(cl, argv0);
fprintf(stderr, "%s", usage);
+ fflush(stderr);
gpr_free(usage);
gpr_cmdline_destroy(cl);
exit(1);
}
-static void on_jwt_verification_done(grpc_exec_ctx *exec_ctx, void *user_data,
+static void on_jwt_verification_done(void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
- synchronizer *sync = user_data;
+ grpc_jwt_claims* claims) {
+ synchronizer* sync = static_cast<synchronizer*>(user_data);
sync->success = (status == GRPC_JWT_VERIFIER_OK);
if (sync->success) {
- char *claims_str;
- GPR_ASSERT(claims != NULL);
+ char* claims_str;
+ GPR_ASSERT(claims != nullptr);
claims_str =
- grpc_json_dump_to_string((grpc_json *)grpc_jwt_claims_json(claims), 2);
+ grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2);
printf("Claims: \n\n%s\n", claims_str);
gpr_free(claims_str);
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
} else {
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
fprintf(stderr, "Verification failed with error %s\n",
grpc_jwt_verifier_status_to_string(status));
+ fflush(stderr);
}
gpr_mu_lock(sync->mu);
sync->is_done = 1;
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, sync->pollset, NULL));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(sync->pollset, nullptr));
gpr_mu_unlock(sync->mu);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
synchronizer sync;
- grpc_jwt_verifier *verifier;
- gpr_cmdline *cl;
- char *jwt = NULL;
- char *aud = NULL;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_jwt_verifier* verifier;
+ gpr_cmdline* cl;
+ const char* jwt = nullptr;
+ const char* aud = nullptr;
+ grpc_core::ExecCtx exec_ctx;
grpc_init();
cl = gpr_cmdline_create("JWT verifier tool");
gpr_cmdline_add_string(cl, "jwt", "JSON web token to verify", &jwt);
gpr_cmdline_add_string(cl, "aud", "Audience for the JWT", &aud);
gpr_cmdline_parse(cl, argc, argv);
- if (jwt == NULL || aud == NULL) {
+ if (jwt == nullptr || aud == nullptr) {
print_usage_and_exit(cl, argv[0]);
}
- verifier = grpc_jwt_verifier_create(NULL, 0);
+ verifier = grpc_jwt_verifier_create(nullptr, 0);
grpc_init();
- sync.pollset = gpr_zalloc(grpc_pollset_size());
+ sync.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(sync.pollset, &sync.mu);
sync.is_done = 0;
- grpc_jwt_verifier_verify(&exec_ctx, verifier, sync.pollset, jwt, aud,
+ grpc_jwt_verifier_verify(verifier, sync.pollset, jwt, aud,
on_jwt_verification_done, &sync);
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, sync.pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC))))
+ grpc_pollset_work(sync.pollset, &worker, GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
gpr_free(sync.pollset);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_cmdline_destroy(cl);
grpc_shutdown();
return !sync.success;
diff --git a/test/core/slice/BUILD b/test/core/slice/BUILD
index f86a3a6082..ba2b553e0b 100644
--- a/test/core/slice/BUILD
+++ b/test/core/slice/BUILD
@@ -21,10 +21,22 @@ licenses(["notice"]) # Apache v2
load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
+ name = "percent_encode_fuzzer",
+ srcs = ["percent_encode_fuzzer.cc"],
+ language = "C++",
+ corpus = "percent_encode_corpus",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_fuzzer(
name = "percent_decode_fuzzer",
- srcs = ["percent_decode_fuzzer.c"],
- language = "C",
- corpus = "response_corpus",
+ srcs = ["percent_decode_fuzzer.cc"],
+ language = "C++",
+ corpus = "percent_decode_corpus",
deps = [
"//:gpr",
"//:grpc",
@@ -34,8 +46,8 @@ grpc_fuzzer(
grpc_cc_test(
name = "percent_encoding_test",
- srcs = ["percent_encoding_test.c"],
- language = "C",
+ srcs = ["percent_encoding_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -46,15 +58,15 @@ grpc_cc_test(
grpc_cc_test(
name = "slice_test",
- srcs = ["slice_test.c"],
+ srcs = ["slice_test.cc"],
deps = ["//:grpc", "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util"],
- language = "C",
+ language = "C++",
)
grpc_cc_test(
name = "slice_string_helpers_test",
- srcs = ["slice_string_helpers_test.c"],
- language = "C",
+ srcs = ["slice_string_helpers_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -65,22 +77,22 @@ grpc_cc_test(
grpc_cc_test(
name = "slice_buffer_test",
- srcs = ["slice_buffer_test.c"],
+ srcs = ["slice_buffer_test.cc"],
deps = ["//:grpc", "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util"],
- language = "C",
+ language = "C++",
)
grpc_cc_test(
name = "slice_hash_table_test",
- srcs = ["slice_hash_table_test.c"],
+ srcs = ["slice_hash_table_test.cc"],
deps = ["//:grpc", "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util"],
- language = "C",
+ language = "C++",
)
grpc_cc_test(
name = "b64_test",
- srcs = ["b64_test.c"],
- language = "C",
+ srcs = ["b64_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/slice/b64_test.c b/test/core/slice/b64_test.cc
index bd375aa6a7..94785fd1e2 100644
--- a/test/core/slice/b64_test.c
+++ b/test/core/slice/b64_test.cc
@@ -20,6 +20,7 @@
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -27,8 +28,8 @@
#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
-static int buffers_are_equal(const unsigned char *buf1,
- const unsigned char *buf2, size_t size) {
+static int buffers_are_equal(const unsigned char* buf1,
+ const unsigned char* buf2, size_t size) {
size_t i;
for (i = 0; i < size; i++) {
if (buf1[i] != buf2[i]) {
@@ -41,38 +42,37 @@ static int buffers_are_equal(const unsigned char *buf1,
}
static void test_simple_encode_decode_b64(int url_safe, int multiline) {
- const char *hello = "hello";
- char *hello_b64 =
+ const char* hello = "hello";
+ char* hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello));
- GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello,
+ GPR_ASSERT(strncmp((const char*)GRPC_SLICE_START_PTR(hello_slice), hello,
GRPC_SLICE_LENGTH(hello_slice)) == 0);
- grpc_slice_unref_internal(&exec_ctx, hello_slice);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(hello_slice);
+
gpr_free(hello_b64);
}
static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
unsigned char orig[256];
size_t i;
- char *b64;
+ char* b64;
grpc_slice orig_decoded;
for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded),
sizeof(orig) - i));
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
gpr_free(b64);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -111,28 +111,27 @@ static void test_full_range_encode_decode_b64_urlsafe_multiline(void) {
static void test_url_safe_unsafe_mismatch_failure(void) {
unsigned char orig[256];
size_t i;
- char *b64;
+ char* b64;
grpc_slice orig_decoded;
int url_safe = 1;
for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe);
+ orig_decoded = grpc_base64_decode(b64, !url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(orig_decoded);
}
static void test_rfc4648_test_vectors(void) {
- char *b64;
+ char* b64;
b64 = grpc_base64_encode("", 0, 0, 0);
GPR_ASSERT(strcmp("", b64) == 0);
@@ -166,44 +165,44 @@ static void test_rfc4648_test_vectors(void) {
static void test_unpadded_decode(void) {
grpc_slice decoded;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0);
+ grpc_core::ExecCtx exec_ctx;
+ decoded = grpc_base64_decode("Zm9vYmFy", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0);
+ decoded = grpc_base64_decode("Zm9vYmE", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0);
+ decoded = grpc_base64_decode("Zm9vYg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0);
+ decoded = grpc_base64_decode("Zm9v", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0);
+ decoded = grpc_base64_decode("Zm8", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zg", 0);
+ decoded = grpc_base64_decode("Zg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "", 0);
+ decoded = grpc_base64_decode("", 0);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
- grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_simple_encode_decode_b64_no_multiline();
test_simple_encode_decode_b64_multiline();
test_simple_encode_decode_b64_urlsafe_no_multiline();
@@ -215,5 +214,6 @@ int main(int argc, char **argv) {
test_url_safe_unsafe_mismatch_failure();
test_rfc4648_test_vectors();
test_unpadded_decode();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/slice/percent_decode_fuzzer.c b/test/core/slice/percent_decode_fuzzer.cc
index ad4e3fed7a..81eb031014 100644
--- a/test/core/slice/percent_decode_fuzzer.c
+++ b/test/core/slice/percent_decode_fuzzer.cc
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -29,10 +30,11 @@
bool squelch = true;
bool leak_check = true;
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
struct grpc_memory_counters counters;
+ grpc_init();
grpc_memory_counters_init();
- grpc_slice input = grpc_slice_from_copied_buffer((const char *)data, size);
+ grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size);
grpc_slice output;
if (grpc_strict_percent_decode_slice(
input, grpc_url_percent_encoding_unreserved_bytes, &output)) {
@@ -46,6 +48,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_slice_unref(input);
counters = grpc_memory_counters_snapshot();
grpc_memory_counters_destroy();
+ grpc_shutdown();
GPR_ASSERT(counters.total_size_relative == 0);
return 0;
}
diff --git a/test/core/slice/percent_encode_fuzzer.c b/test/core/slice/percent_encode_fuzzer.cc
index db3dc3bb3f..201ae2790e 100644
--- a/test/core/slice/percent_encode_fuzzer.c
+++ b/test/core/slice/percent_encode_fuzzer.cc
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -29,10 +30,11 @@
bool squelch = true;
bool leak_check = true;
-static void test(const uint8_t *data, size_t size, const uint8_t *dict) {
+static void test(const uint8_t* data, size_t size, const uint8_t* dict) {
struct grpc_memory_counters counters;
+ grpc_init();
grpc_memory_counters_init();
- grpc_slice input = grpc_slice_from_copied_buffer((const char *)data, size);
+ grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size);
grpc_slice output = grpc_percent_encode_slice(input, dict);
grpc_slice decoded_output;
// encoder must always produce decodable output
@@ -48,10 +50,11 @@ static void test(const uint8_t *data, size_t size, const uint8_t *dict) {
grpc_slice_unref(permissive_decoded_output);
counters = grpc_memory_counters_snapshot();
grpc_memory_counters_destroy();
+ grpc_shutdown();
GPR_ASSERT(counters.total_size_relative == 0);
}
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
test(data, size, grpc_url_percent_encoding_unreserved_bytes);
test(data, size, grpc_compatible_percent_encoding_unreserved_bytes);
return 0;
diff --git a/test/core/slice/percent_encoding_test.c b/test/core/slice/percent_encoding_test.cc
index fcc8d33db3..e8d04fcc83 100644
--- a/test/core/slice/percent_encoding_test.c
+++ b/test/core/slice/percent_encoding_test.cc
@@ -18,11 +18,12 @@
#include "src/core/lib/slice/percent_encoding.h"
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
#define TEST_VECTOR(raw, encoded, dict) \
@@ -33,10 +34,10 @@
permissive_unencoded, \
sizeof(permissive_unencoded) - 1, dict)
-static void test_vector(const char *raw, size_t raw_length, const char *encoded,
- size_t encoded_length, const uint8_t *dict) {
- char *raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded_msg =
+static void test_vector(const char* raw, size_t raw_length, const char* encoded,
+ size_t encoded_length, const uint8_t* dict) {
+ char* raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* encoded_msg =
gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", raw_msg, encoded_msg);
gpr_free(raw_msg);
@@ -52,11 +53,11 @@ static void test_vector(const char *raw, size_t raw_length, const char *encoded,
grpc_slice encoded2raw_permissive_slice =
grpc_permissive_percent_decode_slice(encoded_slice);
- char *raw2encoded_msg =
+ char* raw2encoded_msg =
grpc_dump_slice(raw2encoded_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded2raw_msg =
+ char* encoded2raw_msg =
grpc_dump_slice(encoded2raw_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded2raw_permissive_msg = grpc_dump_slice(
+ char* encoded2raw_permissive_msg = grpc_dump_slice(
encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG,
"Result:\nraw2encoded = %s\nencoded2raw = %s\nencoded2raw_permissive "
@@ -77,15 +78,15 @@ static void test_vector(const char *raw, size_t raw_length, const char *encoded,
grpc_slice_unref(encoded_slice);
}
-static void test_nonconformant_vector(const char *encoded,
+static void test_nonconformant_vector(const char* encoded,
size_t encoded_length,
- const char *permissive_unencoded,
+ const char* permissive_unencoded,
size_t permissive_unencoded_length,
- const uint8_t *dict) {
- char *permissive_unencoded_msg =
+ const uint8_t* dict) {
+ char* permissive_unencoded_msg =
gpr_dump(permissive_unencoded, permissive_unencoded_length,
GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded_msg =
+ char* encoded_msg =
gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg,
encoded_msg);
@@ -102,7 +103,7 @@ static void test_nonconformant_vector(const char *encoded,
grpc_slice encoded2raw_permissive_slice =
grpc_permissive_percent_decode_slice(encoded_slice);
- char *encoded2raw_permissive_msg = grpc_dump_slice(
+ char* encoded2raw_permissive_msg = grpc_dump_slice(
encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s",
encoded2raw_permissive_msg);
@@ -116,8 +117,9 @@ static void test_nonconformant_vector(const char *encoded,
grpc_slice_unref(encoded_slice);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
TEST_VECTOR(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~",
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~",
@@ -140,5 +142,6 @@ int main(int argc, char **argv) {
grpc_url_percent_encoding_unreserved_bytes);
TEST_NONCONFORMANT_VECTOR("\0", "\0",
grpc_url_percent_encoding_unreserved_bytes);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/slice/slice_buffer_test.c b/test/core/slice/slice_buffer_test.cc
index 2fba496bd0..e59986730b 100644
--- a/test/core/slice/slice_buffer_test.c
+++ b/test/core/slice/slice_buffer_test.cc
@@ -16,6 +16,7 @@
*
*/
+#include <grpc/grpc.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
@@ -104,11 +105,13 @@ void test_slice_buffer_move_first() {
GPR_ASSERT(dst.length == dst_len);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_slice_buffer_add();
test_slice_buffer_move_first();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/slice/slice_hash_table_test.c b/test/core/slice/slice_hash_table_test.cc
index f3689aac64..9fad9a614e 100644
--- a/test/core/slice/slice_hash_table_test.c
+++ b/test/core/slice/slice_hash_table_test.cc
@@ -28,8 +28,8 @@
#include "test/core/util/test_config.h"
typedef struct {
- char* key;
- char* value;
+ const char* key;
+ const char* value;
} test_entry;
static void populate_entries(const test_entry* input, size_t num_entries,
@@ -44,8 +44,9 @@ static void check_values(const test_entry* input, size_t num_entries,
grpc_slice_hash_table* table) {
for (size_t i = 0; i < num_entries; ++i) {
grpc_slice key = grpc_slice_from_static_string(input[i].key);
- char* actual = grpc_slice_hash_table_get(table, key);
- GPR_ASSERT(actual != NULL);
+ const char* actual =
+ static_cast<const char*>(grpc_slice_hash_table_get(table, key));
+ GPR_ASSERT(actual != nullptr);
GPR_ASSERT(strcmp(actual, input[i].value) == 0);
grpc_slice_unref(key);
}
@@ -54,20 +55,19 @@ static void check_values(const test_entry* input, size_t num_entries,
static void check_non_existent_value(const char* key_string,
grpc_slice_hash_table* table) {
grpc_slice key = grpc_slice_from_static_string(key_string);
- GPR_ASSERT(grpc_slice_hash_table_get(table, key) == NULL);
+ GPR_ASSERT(grpc_slice_hash_table_get(table, key) == nullptr);
grpc_slice_unref(key);
}
-static void destroy_string(grpc_exec_ctx* exec_ctx, void* value) {
- gpr_free(value);
-}
+static void destroy_string(void* value) { gpr_free(value); }
static grpc_slice_hash_table* create_table_from_entries(
const test_entry* test_entries, size_t num_test_entries,
int (*value_cmp_fn)(void*, void*)) {
// Construct table.
grpc_slice_hash_table_entry* entries =
- gpr_zalloc(sizeof(*entries) * num_test_entries);
+ static_cast<grpc_slice_hash_table_entry*>(
+ gpr_zalloc(sizeof(*entries) * num_test_entries));
populate_entries(test_entries, num_test_entries, entries);
grpc_slice_hash_table* table = grpc_slice_hash_table_create(
num_test_entries, entries, destroy_string, value_cmp_fn);
@@ -114,19 +114,18 @@ static void test_slice_hash_table() {
};
const size_t num_entries = GPR_ARRAY_SIZE(test_entries);
grpc_slice_hash_table* table =
- create_table_from_entries(test_entries, num_entries, NULL);
+ create_table_from_entries(test_entries, num_entries, nullptr);
// Check contents of table.
check_values(test_entries, num_entries, table);
check_non_existent_value("XX", table);
// Clean up.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_hash_table_unref(table);
}
static int value_cmp_fn(void* a, void* b) {
- const char* a_str = a;
- const char* b_str = b;
+ const char* a_str = static_cast<const char*>(a);
+ const char* b_str = static_cast<const char*>(b);
return strcmp(a_str, b_str);
}
@@ -147,10 +146,9 @@ static void test_slice_hash_table_eq() {
create_table_from_entries(test_entries_b, num_entries_b, value_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_a, table_b) == 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b);
}
static void test_slice_hash_table_not_eq() {
@@ -219,23 +217,24 @@ static void test_slice_hash_table_not_eq() {
create_table_from_entries(test_entries_h, num_entries_h, pointer_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_g, table_h) != 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_larger);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_smaller);
- grpc_slice_hash_table_unref(&exec_ctx, table_c);
- grpc_slice_hash_table_unref(&exec_ctx, table_d);
- grpc_slice_hash_table_unref(&exec_ctx, table_e);
- grpc_slice_hash_table_unref(&exec_ctx, table_f);
- grpc_slice_hash_table_unref(&exec_ctx, table_g);
- grpc_slice_hash_table_unref(&exec_ctx, table_h);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b_larger);
+ grpc_slice_hash_table_unref(table_b_smaller);
+ grpc_slice_hash_table_unref(table_c);
+ grpc_slice_hash_table_unref(table_d);
+ grpc_slice_hash_table_unref(table_e);
+ grpc_slice_hash_table_unref(table_f);
+ grpc_slice_hash_table_unref(table_g);
+ grpc_slice_hash_table_unref(table_h);
}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_core::ExecCtx::GlobalInit();
test_slice_hash_table();
test_slice_hash_table_eq();
test_slice_hash_table_not_eq();
+ grpc_core::ExecCtx::GlobalShutdown();
return 0;
}
diff --git a/test/core/slice/slice_string_helpers_test.c b/test/core/slice/slice_string_helpers_test.cc
index 504acf8f84..1e38f8daca 100644
--- a/test/core/slice/slice_string_helpers_test.c
+++ b/test/core/slice/slice_string_helpers_test.cc
@@ -28,22 +28,22 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
static void expect_slice_dump(grpc_slice slice, uint32_t flags,
- const char *result) {
- char *got = grpc_dump_slice(slice, flags);
+ const char* result) {
+ char* got = grpc_dump_slice(slice, flags);
GPR_ASSERT(0 == strcmp(got, result));
gpr_free(got);
grpc_slice_unref(slice);
}
static void test_dump_slice(void) {
- static const char *text = "HELLO WORLD!";
- static const char *long_text =
+ static const char* text = "HELLO WORLD!";
+ static const char* long_text =
"It was a bright cold day in April, and the clocks were striking "
"thirteen. Winston Smith, his chin nuzzled into his breast in an effort "
"to escape the vile wind, slipped quickly through the glass doors of "
@@ -62,12 +62,13 @@ static void test_dump_slice(void) {
}
static void test_strsplit(void) {
- grpc_slice_buffer *parts;
+ grpc_slice_buffer* parts;
grpc_slice str;
LOG_TEST_NAME("test_strsplit");
- parts = gpr_malloc(sizeof(grpc_slice_buffer));
+ parts =
+ static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(grpc_slice_buffer)));
grpc_slice_buffer_init(parts);
str = grpc_slice_from_copied_string("one, two, three, four");
@@ -127,9 +128,77 @@ static void test_strsplit(void) {
gpr_free(parts);
}
-int main(int argc, char **argv) {
+static void test_strsplit_nospace(void) {
+ grpc_slice_buffer* parts;
+ grpc_slice str;
+
+ LOG_TEST_NAME("test_strsplit_nospace");
+
+ parts =
+ static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(grpc_slice_buffer)));
+ grpc_slice_buffer_init(parts);
+
+ str = grpc_slice_from_copied_string("one ,two, three , four");
+ grpc_slice_split_without_space(str, ",", parts);
+ GPR_ASSERT(4 == parts->count);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "two"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[2], "three"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[3], "four"));
+ grpc_slice_buffer_reset_and_unref(parts);
+ grpc_slice_unref(str);
+
+ /* separator not present in string */
+ str = grpc_slice_from_copied_string("one two three four ");
+ grpc_slice_split_without_space(str, ",", parts);
+ GPR_ASSERT(1 == parts->count);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one two three four"));
+ grpc_slice_buffer_reset_and_unref(parts);
+ grpc_slice_unref(str);
+
+ /* separator at the end */
+ str = grpc_slice_from_copied_string("foo,");
+ grpc_slice_split_without_space(str, ",", parts);
+ GPR_ASSERT(2 == parts->count);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "foo"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], ""));
+ grpc_slice_buffer_reset_and_unref(parts);
+ grpc_slice_unref(str);
+
+ /* separator at the beginning */
+ str = grpc_slice_from_copied_string(" , foo");
+ grpc_slice_split_without_space(str, ",", parts);
+ GPR_ASSERT(2 == parts->count);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "foo"));
+ grpc_slice_buffer_reset_and_unref(parts);
+ grpc_slice_unref(str);
+
+ /* standalone separator */
+ str = grpc_slice_from_copied_string(", ");
+ grpc_slice_split_without_space(str, ", ", parts);
+ GPR_ASSERT(2 == parts->count);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], ""));
+ grpc_slice_buffer_reset_and_unref(parts);
+ grpc_slice_unref(str);
+
+ /* empty input */
+ str = grpc_slice_from_copied_string("");
+ grpc_slice_split_without_space(str, ",", parts);
+ GPR_ASSERT(1 == parts->count);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
+ grpc_slice_buffer_reset_and_unref(parts);
+ grpc_slice_unref(str);
+
+ grpc_slice_buffer_destroy(parts);
+ gpr_free(parts);
+}
+
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_dump_slice();
test_strsplit();
+ test_strsplit_nospace();
return 0;
}
diff --git a/test/core/slice/slice_test.c b/test/core/slice/slice_test.cc
index cda37fb8d9..e40154dd0e 100644
--- a/test/core/slice/slice_test.c
+++ b/test/core/slice/slice_test.cc
@@ -43,17 +43,17 @@ static void test_slice_malloc_returns_something_sensible(void) {
slice = grpc_slice_malloc(length);
/* If there is a length, slice.data must be non-NULL. If length is zero
we don't care. */
- if (length) {
- GPR_ASSERT(GRPC_SLICE_START_PTR(slice));
+ if (length > GRPC_SLICE_INLINED_SIZE) {
+ GPR_ASSERT(slice.data.refcounted.bytes);
}
/* Returned slice length must be what was requested. */
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == length);
/* If the slice has a refcount, it must be destroyable. */
if (slice.refcount) {
- GPR_ASSERT(slice.refcount->vtable != NULL);
- GPR_ASSERT(slice.refcount->vtable->ref != NULL);
- GPR_ASSERT(slice.refcount->vtable->unref != NULL);
- GPR_ASSERT(slice.refcount->vtable->hash != NULL);
+ GPR_ASSERT(slice.refcount->vtable != nullptr);
+ GPR_ASSERT(slice.refcount->vtable->ref != nullptr);
+ GPR_ASSERT(slice.refcount->vtable->unref != nullptr);
+ GPR_ASSERT(slice.refcount->vtable->hash != nullptr);
}
/* We must be able to write to every byte of the data */
for (i = 0; i < length; i++) {
@@ -64,7 +64,7 @@ static void test_slice_malloc_returns_something_sensible(void) {
}
}
-static void do_nothing(void *ignored) {}
+static void do_nothing(void* ignored) {}
static void test_slice_new_returns_something_sensible(void) {
uint8_t x;
@@ -77,7 +77,7 @@ static void test_slice_new_returns_something_sensible(void) {
}
/* destroy function that sets a mark to indicate it was called. */
-static void set_mark(void *p) { *((int *)p) = 1; }
+static void set_mark(void* p) { *((int*)p) = 1; }
static void test_slice_new_with_user_data(void) {
int marker = 0;
@@ -99,7 +99,7 @@ static void test_slice_new_with_user_data(void) {
static int do_nothing_with_len_1_calls = 0;
-static void do_nothing_with_len_1(void *ignored, size_t len) {
+static void do_nothing_with_len_1(void* ignored, size_t len) {
GPR_ASSERT(len == 1);
do_nothing_with_len_1_calls++;
}
@@ -228,7 +228,7 @@ static void test_slice_split_tail_works(size_t length) {
}
static void test_slice_from_copied_string_works(void) {
- static const char *text = "HELLO WORLD!";
+ static const char* text = "HELLO WORLD!";
grpc_slice slice;
LOG_TEST_NAME("test_slice_from_copied_string_works");
@@ -289,9 +289,10 @@ static void test_static_slice_copy_interning(void) {
grpc_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
unsigned length;
grpc_test_init(argc, argv);
+ grpc_init();
test_slice_malloc_returns_something_sensible();
test_slice_new_returns_something_sensible();
test_slice_new_with_user_data();
@@ -305,5 +306,6 @@ int main(int argc, char **argv) {
test_slice_interning();
test_static_slice_interning();
test_static_slice_copy_interning();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c
deleted file mode 100644
index 229a5e55f9..0000000000
--- a/test/core/statistics/census_log_tests.c
+++ /dev/null
@@ -1,576 +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/census/census_log.h"
-#include <grpc/support/cpu.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-#include <grpc/support/time.h>
-#include <grpc/support/useful.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "test/core/util/test_config.h"
-
-/* Fills in 'record' of size 'size'. Each byte in record is filled in with the
- same value. The value is extracted from 'record' pointer. */
-static void write_record(char *record, size_t size) {
- char data = (uintptr_t)record % 255;
- memset(record, data, size);
-}
-
-/* Reads fixed size records. Returns the number of records read in
- 'num_records'. */
-static void read_records(size_t record_size, const char *buffer,
- size_t buffer_size, int32_t *num_records) {
- int32_t ix;
- GPR_ASSERT(buffer_size >= record_size);
- GPR_ASSERT(buffer_size % record_size == 0);
- *num_records = buffer_size / record_size;
- for (ix = 0; ix < *num_records; ++ix) {
- size_t jx;
- const char *record = buffer + (record_size * ix);
- char data = (uintptr_t)record % 255;
- for (jx = 0; jx < record_size; ++jx) {
- GPR_ASSERT(data == record[jx]);
- }
- }
-}
-
-/* Tries to write the specified number of records. Stops when the log gets
- full. Returns the number of records written. Spins for random
- number of times, up to 'max_spin_count', between writes. */
-static size_t write_records_to_log(int writer_id, int32_t record_size,
- int32_t num_records,
- int32_t max_spin_count) {
- int32_t ix;
- int counter = 0;
- for (ix = 0; ix < num_records; ++ix) {
- int32_t jx;
- int32_t spin_count = max_spin_count ? rand() % max_spin_count : 0;
- char *record;
- if (counter++ == num_records / 10) {
- printf(" Writer %d: %d out of %d written\n", writer_id, ix,
- num_records);
- counter = 0;
- }
- record = (char *)(census_log_start_write(record_size));
- if (record == NULL) {
- return ix;
- }
- write_record(record, record_size);
- census_log_end_write(record, record_size);
- for (jx = 0; jx < spin_count; ++jx) {
- GPR_ASSERT(jx >= 0);
- }
- }
- return num_records;
-}
-
-/* Performs a single read iteration. Returns the number of records read. */
-static size_t perform_read_iteration(size_t record_size) {
- const void *read_buffer = NULL;
- size_t bytes_available;
- size_t records_read = 0;
- census_log_init_reader();
- while ((read_buffer = census_log_read_next(&bytes_available))) {
- int32_t num_records = 0;
- read_records(record_size, (const char *)read_buffer, bytes_available,
- &num_records);
- records_read += num_records;
- }
- return records_read;
-}
-
-/* Asserts that the log is empty. */
-static void assert_log_empty(void) {
- size_t bytes_available;
- census_log_init_reader();
- GPR_ASSERT(census_log_read_next(&bytes_available) == NULL);
-}
-
-/* Given log size and record size, computes the minimum usable space. */
-static int32_t min_usable_space(size_t log_size, size_t record_size) {
- int32_t usable_space;
- int32_t num_blocks =
- GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, gpr_cpu_num_cores());
- int32_t waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size;
- /* In the worst case, all except one core-local block is full. */
- int32_t num_full_blocks = num_blocks - 1;
- usable_space = (int32_t)log_size -
- (num_full_blocks * CENSUS_LOG_MAX_RECORD_SIZE) -
- ((num_blocks - num_full_blocks) * waste_per_block);
- GPR_ASSERT(usable_space > 0);
- return usable_space;
-}
-
-/* Fills the log and verifies data. If 'no fragmentation' is true, records
- are sized such that CENSUS_LOG_2_MAX_RECORD_SIZE is a multiple of record
- size. If not a circular log, verifies that the number of records written
- match the number of records read. */
-static void fill_log(size_t log_size, int no_fragmentation, int circular_log) {
- int size;
- int32_t records_written;
- int32_t usable_space;
- int32_t records_read;
- if (no_fragmentation) {
- int log2size = rand() % (CENSUS_LOG_2_MAX_RECORD_SIZE + 1);
- size = (1 << log2size);
- } else {
- while (1) {
- size = 1 + (rand() % CENSUS_LOG_MAX_RECORD_SIZE);
- if (CENSUS_LOG_MAX_RECORD_SIZE % size) {
- break;
- }
- }
- }
- printf(" Fill record size: %d\n", size);
- records_written = write_records_to_log(
- 0 /* writer id */, size, (log_size / size) * 2, 0 /* spin count */);
- usable_space = min_usable_space(log_size, size);
- GPR_ASSERT(records_written * size >= usable_space);
- records_read = perform_read_iteration(size);
- if (!circular_log) {
- GPR_ASSERT(records_written == records_read);
- }
- assert_log_empty();
-}
-
-/* Structure to pass args to writer_thread */
-typedef struct writer_thread_args {
- /* Index of this thread in the writers vector. */
- int index;
- /* Record size. */
- size_t record_size;
- /* Number of records to write. */
- int32_t num_records;
- /* Used to signal when writer is complete */
- gpr_cv *done;
- gpr_mu *mu;
- int *count;
-} writer_thread_args;
-
-/* Writes the given number of records of random size (up to kMaxRecordSize) and
- random data to the specified log. */
-static void writer_thread(void *arg) {
- writer_thread_args *args = (writer_thread_args *)arg;
- /* Maximum number of times to spin between writes. */
- static const int32_t MAX_SPIN_COUNT = 50;
- int records_written = 0;
- printf(" Writer: %d\n", args->index);
- while (records_written < args->num_records) {
- records_written += write_records_to_log(args->index, args->record_size,
- args->num_records - records_written,
- MAX_SPIN_COUNT);
- if (records_written < args->num_records) {
- /* Ran out of log space. Sleep for a bit and let the reader catch up.
- This should never happen for circular logs. */
- printf(" Writer stalled due to out-of-space: %d out of %d written\n",
- records_written, args->num_records);
- gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(10));
- }
- }
- /* Done. Decrement count and signal. */
- gpr_mu_lock(args->mu);
- (*args->count)--;
- gpr_cv_broadcast(args->done);
- printf(" Writer done: %d\n", args->index);
- gpr_mu_unlock(args->mu);
-}
-
-/* struct to pass args to reader_thread */
-typedef struct reader_thread_args {
- /* Record size. */
- size_t record_size;
- /* Interval between read iterations. */
- int32_t read_iteration_interval_in_msec;
- /* Total number of records. */
- int32_t total_records;
- /* Signalled when reader should stop. */
- gpr_cv stop;
- int stop_flag;
- /* Used to signal when reader has finished */
- gpr_cv *done;
- gpr_mu *mu;
- int running;
-} reader_thread_args;
-
-/* Reads and verifies the specified number of records. Reader can also be
- stopped via gpr_cv_signal(&args->stop). Sleeps for 'read_interval_in_msec'
- between read iterations. */
-static void reader_thread(void *arg) {
- int32_t records_read = 0;
- reader_thread_args *args = (reader_thread_args *)arg;
- int32_t num_iterations = 0;
- gpr_timespec interval;
- int counter = 0;
- printf(" Reader starting\n");
- interval = gpr_time_from_micros(
- (int64_t)args->read_iteration_interval_in_msec * 1000, GPR_TIMESPAN);
- gpr_mu_lock(args->mu);
- while (!args->stop_flag && records_read < args->total_records) {
- gpr_cv_wait(&args->stop, args->mu, interval);
- if (!args->stop_flag) {
- records_read += perform_read_iteration(args->record_size);
- GPR_ASSERT(records_read <= args->total_records);
- if (counter++ == 100000) {
- printf(" Reader: %d out of %d read\n", records_read,
- args->total_records);
- counter = 0;
- }
- ++num_iterations;
- }
- }
- /* Done */
- args->running = 0;
- gpr_cv_broadcast(args->done);
- printf(" Reader: records: %d, iterations: %d\n", records_read,
- num_iterations);
- gpr_mu_unlock(args->mu);
-}
-
-/* Creates NUM_WRITERS writers where each writer writes NUM_RECORDS_PER_WRITER
- records. Also, starts a reader that iterates over and reads blocks every
- READ_ITERATION_INTERVAL_IN_MSEC. */
-/* Number of writers. */
-#define NUM_WRITERS 5
-static void multiple_writers_single_reader(int circular_log) {
- /* Sleep interval between read iterations. */
- static const int32_t READ_ITERATION_INTERVAL_IN_MSEC = 10;
- /* Number of records written by each writer. */
- static const int32_t NUM_RECORDS_PER_WRITER = 10 * 1024 * 1024;
- /* Maximum record size. */
- static const size_t MAX_RECORD_SIZE = 10;
- int ix;
- gpr_thd_id id;
- gpr_cv writers_done;
- int writers_count = NUM_WRITERS;
- gpr_mu writers_mu; /* protects writers_done and writers_count */
- writer_thread_args writers[NUM_WRITERS];
- gpr_cv reader_done;
- gpr_mu reader_mu; /* protects reader_done and reader.running */
- reader_thread_args reader;
- int32_t record_size = 1 + rand() % MAX_RECORD_SIZE;
- printf(" Record size: %d\n", record_size);
- /* Create and start writers. */
- gpr_cv_init(&writers_done);
- gpr_mu_init(&writers_mu);
- for (ix = 0; ix < NUM_WRITERS; ++ix) {
- writers[ix].index = ix;
- writers[ix].record_size = record_size;
- writers[ix].num_records = NUM_RECORDS_PER_WRITER;
- writers[ix].done = &writers_done;
- writers[ix].count = &writers_count;
- writers[ix].mu = &writers_mu;
- gpr_thd_new(&id, &writer_thread, &writers[ix], NULL);
- }
- /* Start reader. */
- reader.record_size = record_size;
- reader.read_iteration_interval_in_msec = READ_ITERATION_INTERVAL_IN_MSEC;
- reader.total_records = NUM_WRITERS * NUM_RECORDS_PER_WRITER;
- reader.stop_flag = 0;
- gpr_cv_init(&reader.stop);
- gpr_cv_init(&reader_done);
- reader.done = &reader_done;
- gpr_mu_init(&reader_mu);
- reader.mu = &reader_mu;
- reader.running = 1;
- gpr_thd_new(&id, &reader_thread, &reader, NULL);
- /* Wait for writers to finish. */
- gpr_mu_lock(&writers_mu);
- while (writers_count != 0) {
- gpr_cv_wait(&writers_done, &writers_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
- }
- gpr_mu_unlock(&writers_mu);
- gpr_mu_destroy(&writers_mu);
- gpr_cv_destroy(&writers_done);
- gpr_mu_lock(&reader_mu);
- if (circular_log) {
- /* Stop reader. */
- reader.stop_flag = 1;
- gpr_cv_signal(&reader.stop);
- }
- /* wait for reader to finish */
- while (reader.running) {
- gpr_cv_wait(&reader_done, &reader_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
- }
- if (circular_log) {
- /* Assert that there were no out-of-space errors. */
- GPR_ASSERT(0 == census_log_out_of_space_count());
- }
- gpr_mu_unlock(&reader_mu);
- gpr_mu_destroy(&reader_mu);
- gpr_cv_destroy(&reader_done);
- printf(" Reader: finished\n");
-}
-
-/* Log sizes to use for all tests. */
-#define LOG_SIZE_IN_MB 1
-#define LOG_SIZE_IN_BYTES (LOG_SIZE_IN_MB << 20)
-
-static void setup_test(int circular_log) {
- census_log_initialize(LOG_SIZE_IN_MB, circular_log);
- GPR_ASSERT(census_log_remaining_space() == LOG_SIZE_IN_BYTES);
-}
-
-/* Attempts to create a record of invalid size (size >
- CENSUS_LOG_MAX_RECORD_SIZE). */
-void test_invalid_record_size(void) {
- static const size_t INVALID_SIZE = CENSUS_LOG_MAX_RECORD_SIZE + 1;
- static const size_t VALID_SIZE = 1;
- void *record;
- printf("Starting test: invalid record size\n");
- setup_test(0);
- record = census_log_start_write(INVALID_SIZE);
- GPR_ASSERT(record == NULL);
- /* Now try writing a valid record. */
- record = census_log_start_write(VALID_SIZE);
- GPR_ASSERT(record != NULL);
- census_log_end_write(record, VALID_SIZE);
- /* Verifies that available space went down by one block. In theory, this
- check can fail if the thread is context switched to a new CPU during the
- start_write execution (multiple blocks get allocated), but this has not
- been observed in practice. */
- GPR_ASSERT(LOG_SIZE_IN_BYTES - CENSUS_LOG_MAX_RECORD_SIZE ==
- census_log_remaining_space());
- census_log_shutdown();
-}
-
-/* Tests end_write() with a different size than what was specified in
- start_write(). */
-void test_end_write_with_different_size(void) {
- static const size_t START_WRITE_SIZE = 10;
- static const size_t END_WRITE_SIZE = 7;
- void *record_written;
- const void *record_read;
- size_t bytes_available;
- printf("Starting test: end write with different size\n");
- setup_test(0);
- record_written = census_log_start_write(START_WRITE_SIZE);
- GPR_ASSERT(record_written != NULL);
- census_log_end_write(record_written, END_WRITE_SIZE);
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_written == record_read);
- GPR_ASSERT(END_WRITE_SIZE == bytes_available);
- assert_log_empty();
- census_log_shutdown();
-}
-
-/* Verifies that pending records are not available via read_next(). */
-void test_read_pending_record(void) {
- static const size_t PR_RECORD_SIZE = 1024;
- size_t bytes_available;
- const void *record_read;
- void *record_written;
- printf("Starting test: read pending record\n");
- setup_test(0);
- /* Start a write. */
- record_written = census_log_start_write(PR_RECORD_SIZE);
- GPR_ASSERT(record_written != NULL);
- /* As write is pending, read should fail. */
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_read == NULL);
- /* A read followed by end_write() should succeed. */
- census_log_end_write(record_written, PR_RECORD_SIZE);
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_written == record_read);
- GPR_ASSERT(PR_RECORD_SIZE == bytes_available);
- assert_log_empty();
- census_log_shutdown();
-}
-
-/* Tries reading beyond pending write. */
-void test_read_beyond_pending_record(void) {
- /* Start a write. */
- uint32_t incomplete_record_size = 10;
- uint32_t complete_record_size = 20;
- size_t bytes_available;
- void *complete_record;
- const void *record_read;
- void *incomplete_record;
- printf("Starting test: read beyond pending record\n");
- setup_test(0);
- incomplete_record = census_log_start_write(incomplete_record_size);
- GPR_ASSERT(incomplete_record != NULL);
- complete_record = census_log_start_write(complete_record_size);
- GPR_ASSERT(complete_record != NULL);
- GPR_ASSERT(complete_record != incomplete_record);
- census_log_end_write(complete_record, complete_record_size);
- /* Now iterate over blocks to read completed records. */
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(complete_record == record_read);
- GPR_ASSERT(complete_record_size == bytes_available);
- /* Complete first record. */
- census_log_end_write(incomplete_record, incomplete_record_size);
- /* Have read past the incomplete record, so read_next() should return NULL. */
- /* NB: this test also assumes our thread did not get switched to a different
- CPU between the two start_write calls */
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_read == NULL);
- /* Reset reader to get the newly completed record. */
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(incomplete_record == record_read);
- GPR_ASSERT(incomplete_record_size == bytes_available);
- assert_log_empty();
- census_log_shutdown();
-}
-
-/* Tests scenario where block being read is detached from a core and put on the
- dirty list. */
-void test_detached_while_reading(void) {
- static const size_t DWR_RECORD_SIZE = 10;
- size_t bytes_available;
- const void *record_read;
- void *record_written;
- uint32_t block_read = 0;
- printf("Starting test: detached while reading\n");
- setup_test(0);
- /* Start a write. */
- record_written = census_log_start_write(DWR_RECORD_SIZE);
- GPR_ASSERT(record_written != NULL);
- census_log_end_write(record_written, DWR_RECORD_SIZE);
- /* Read this record. */
- census_log_init_reader();
- record_read = census_log_read_next(&bytes_available);
- GPR_ASSERT(record_read != NULL);
- GPR_ASSERT(DWR_RECORD_SIZE == bytes_available);
- /* Now fill the log. This will move the block being read from core-local
- array to the dirty list. */
- while ((record_written = census_log_start_write(DWR_RECORD_SIZE))) {
- census_log_end_write(record_written, DWR_RECORD_SIZE);
- }
-
- /* In this iteration, read_next() should only traverse blocks in the
- core-local array. Therefore, we expect at most gpr_cpu_num_cores() more
- blocks. As log is full, if read_next() is traversing the dirty list, we
- will get more than gpr_cpu_num_cores() blocks. */
- while ((record_read = census_log_read_next(&bytes_available))) {
- ++block_read;
- GPR_ASSERT(block_read <= gpr_cpu_num_cores());
- }
- census_log_shutdown();
-}
-
-/* Fills non-circular log with records sized such that size is a multiple of
- CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation). */
-void test_fill_log_no_fragmentation(void) {
- const int circular = 0;
- printf("Starting test: fill log no fragmentation\n");
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
- census_log_shutdown();
-}
-
-/* Fills circular log with records sized such that size is a multiple of
- CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation). */
-void test_fill_circular_log_no_fragmentation(void) {
- const int circular = 1;
- printf("Starting test: fill circular log no fragmentation\n");
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
- census_log_shutdown();
-}
-
-/* Fills non-circular log with records that may straddle end of a block. */
-void test_fill_log_with_straddling_records(void) {
- const int circular = 0;
- printf("Starting test: fill log with straddling records\n");
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
- census_log_shutdown();
-}
-
-/* Fills circular log with records that may straddle end of a block. */
-void test_fill_circular_log_with_straddling_records(void) {
- const int circular = 1;
- printf("Starting test: fill circular log with straddling records\n");
- setup_test(circular);
- fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
- census_log_shutdown();
-}
-
-/* Tests scenario where multiple writers and a single reader are using a log
- that is configured to discard old records. */
-void test_multiple_writers_circular_log(void) {
- const int circular = 1;
- printf("Starting test: multiple writers circular log\n");
- setup_test(circular);
- multiple_writers_single_reader(circular);
- census_log_shutdown();
-}
-
-/* Tests scenario where multiple writers and a single reader are using a log
- that is configured to discard old records. */
-void test_multiple_writers(void) {
- const int circular = 0;
- printf("Starting test: multiple writers\n");
- setup_test(circular);
- multiple_writers_single_reader(circular);
- census_log_shutdown();
-}
-
-/* Repeat the straddling records and multiple writers tests with a small log. */
-void test_small_log(void) {
- size_t log_size;
- const int circular = 0;
- printf("Starting test: small log\n");
- census_log_initialize(0, circular);
- log_size = census_log_remaining_space();
- GPR_ASSERT(log_size > 0);
- fill_log(log_size, 0, circular);
- census_log_shutdown();
- census_log_initialize(0, circular);
- multiple_writers_single_reader(circular);
- census_log_shutdown();
-}
-
-void test_performance(void) {
- int write_size = 1;
- for (; write_size < CENSUS_LOG_MAX_RECORD_SIZE; write_size *= 2) {
- gpr_timespec write_time;
- gpr_timespec start_time;
- double write_time_micro = 0.0;
- int nrecords = 0;
- setup_test(0);
- start_time = gpr_now(GPR_CLOCK_REALTIME);
- while (1) {
- void *record = census_log_start_write(write_size);
- if (record == NULL) {
- break;
- }
- census_log_end_write(record, write_size);
- nrecords++;
- }
- write_time = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start_time);
- write_time_micro = write_time.tv_sec * 1000000 + write_time.tv_nsec / 1000;
- census_log_shutdown();
- printf(
- "Wrote %d %d byte records in %.3g microseconds: %g records/us "
- "(%g ns/record), %g gigabytes/s\n",
- nrecords, write_size, write_time_micro, nrecords / write_time_micro,
- 1000 * write_time_micro / nrecords,
- (write_size * nrecords) / write_time_micro / 1000);
- }
-}
diff --git a/test/core/statistics/census_stub_test.c b/test/core/statistics/census_stub_test.cc
index f38d571abd..507ae0a9fa 100644
--- a/test/core/statistics/census_stub_test.c
+++ b/test/core/statistics/census_stub_test.cc
@@ -28,7 +28,7 @@
/* Tests census noop stubs in a simulated rpc flow */
void test_census_stubs(void) {
census_op_id op_id;
- census_rpc_stats *stats = census_rpc_stats_create_empty();
+ census_rpc_stats* stats = census_rpc_stats_create_empty();
census_aggregated_rpc_stats data_map = {0, NULL};
/* Initializes census library at server start up time. */
@@ -55,7 +55,7 @@ void test_census_stubs(void) {
census_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_census_stubs();
return 0;
diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c
deleted file mode 100644
index d714e15091..0000000000
--- a/test/core/statistics/hash_table_test.c
+++ /dev/null
@@ -1,286 +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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "src/core/ext/census/hash_table.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/time.h>
-#include "src/core/lib/support/murmur_hash.h"
-#include "src/core/lib/support/string.h"
-#include "test/core/util/test_config.h"
-
-static uint64_t hash64(const void *k) {
- size_t len = strlen(k);
- uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0);
- return higher << 32 |
- gpr_murmur_hash3((const char *)(k) + len / 2, len - len / 2, 0);
-}
-
-static int cmp_str_keys(const void *k1, const void *k2) {
- return strcmp((const char *)k1, (const char *)k2);
-}
-
-static uint64_t force_collision(const void *k) {
- return (1997 + hash64(k) % 3);
-}
-
-static void free_data(void *data) { gpr_free(data); }
-
-/* Basic tests that empty hash table can be created and destroyed. */
-static void test_create_table(void) {
- /* Create table with uint64 key type */
- census_ht *ht = NULL;
- census_ht_option ht_options = {
- CENSUS_HT_UINT64, 1999, NULL, NULL, NULL, NULL};
- ht = census_ht_create(&ht_options);
- GPR_ASSERT(ht != NULL);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- census_ht_destroy(ht);
- /* Create table with pointer key type */
- ht = NULL;
- ht_options.key_type = CENSUS_HT_POINTER;
- ht_options.hash = &hash64;
- ht_options.compare_keys = &cmp_str_keys;
- ht = census_ht_create(&ht_options);
- GPR_ASSERT(ht != NULL);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- census_ht_destroy(ht);
-}
-
-static void test_table_with_int_key(void) {
- census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
- uint64_t i = 0;
- uint64_t sum_of_keys = 0;
- size_t num_elements;
- census_ht_kv *elements = NULL;
- GPR_ASSERT(ht != NULL);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- elements = census_ht_get_all_elements(ht, &num_elements);
- GPR_ASSERT(num_elements == 0);
- GPR_ASSERT(elements == NULL);
- for (i = 0; i < 20; ++i) {
- census_ht_key key;
- key.val = i;
- census_ht_insert(ht, key, (void *)(intptr_t)i);
- GPR_ASSERT(census_ht_get_size(ht) == i + 1);
- }
- for (i = 0; i < 20; i++) {
- uint64_t *val = NULL;
- census_ht_key key;
- key.val = i;
- val = census_ht_find(ht, key);
- GPR_ASSERT(val == (void *)(intptr_t)i);
- }
- elements = census_ht_get_all_elements(ht, &num_elements);
- GPR_ASSERT(elements != NULL);
- GPR_ASSERT(num_elements == 20);
- for (i = 0; i < num_elements; i++) {
- sum_of_keys += elements[i].k.val;
- }
- GPR_ASSERT(sum_of_keys == 190);
- gpr_free(elements);
- census_ht_destroy(ht);
-}
-
-/* Test that there is no memory leak when keys and values are owned by table. */
-static void test_value_and_key_deleter(void) {
- census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
- &cmp_str_keys, &free_data, &free_data};
- census_ht *ht = census_ht_create(&opt);
- census_ht_key key;
- char *val = NULL;
- char *val2 = NULL;
- key.ptr = gpr_malloc(100);
- val = gpr_malloc(10);
- strcpy(val, "value");
- strcpy(key.ptr, "some string as a key");
- GPR_ASSERT(ht != NULL);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- census_ht_insert(ht, key, val);
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- val = census_ht_find(ht, key);
- GPR_ASSERT(val != NULL);
- GPR_ASSERT(strcmp(val, "value") == 0);
- /* Insert same key different value, old value is overwritten. */
- val2 = gpr_malloc(10);
- strcpy(val2, "v2");
- census_ht_insert(ht, key, val2);
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- val2 = census_ht_find(ht, key);
- GPR_ASSERT(val2 != NULL);
- GPR_ASSERT(strcmp(val2, "v2") == 0);
- census_ht_destroy(ht);
-}
-
-/* Test simple insert and erase operations. */
-static void test_simple_add_and_erase(void) {
- census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
- GPR_ASSERT(ht != NULL);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- {
- census_ht_key key;
- int val = 3;
- key.val = 2;
- census_ht_insert(ht, key, (void *)&val);
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- census_ht_erase(ht, key);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- /* Erasing a key from an empty table should be noop. */
- census_ht_erase(ht, key);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- /* Erasing a non-existant key from a table should be noop. */
- census_ht_insert(ht, key, (void *)&val);
- key.val = 3;
- census_ht_insert(ht, key, (void *)&val);
- key.val = 9;
- census_ht_insert(ht, key, (void *)&val);
- GPR_ASSERT(census_ht_get_size(ht) == 3);
- key.val = 1;
- census_ht_erase(ht, key);
- /* size unchanged after deleting non-existant key. */
- GPR_ASSERT(census_ht_get_size(ht) == 3);
- /* size decrease by 1 after deleting an existant key. */
- key.val = 2;
- census_ht_erase(ht, key);
- GPR_ASSERT(census_ht_get_size(ht) == 2);
- }
- census_ht_destroy(ht);
-}
-
-static void test_insertion_and_deletion_with_high_collision_rate(void) {
- census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision,
- &cmp_str_keys, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
- char key_str[1000][GPR_LTOA_MIN_BUFSIZE];
- uint64_t val = 0;
- unsigned i = 0;
- for (i = 0; i < 1000; i++) {
- census_ht_key key;
- key.ptr = key_str[i];
- gpr_ltoa(i, key_str[i]);
- census_ht_insert(ht, key, (void *)(&val));
- gpr_log(GPR_INFO, "%d\n", i);
- GPR_ASSERT(census_ht_get_size(ht) == (i + 1));
- }
- for (i = 0; i < 1000; i++) {
- census_ht_key key;
- key.ptr = key_str[i];
- census_ht_erase(ht, key);
- GPR_ASSERT(census_ht_get_size(ht) == (999 - i));
- }
- census_ht_destroy(ht);
-}
-
-static void test_table_with_string_key(void) {
- census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
- &cmp_str_keys, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
- const char *keys[] = {
- "k1", "a", "000", "apple", "banana_a_long_long_long_banana",
- "%$", "111", "foo", "b"};
- const int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
- int i = 0;
- GPR_ASSERT(ht != NULL);
- GPR_ASSERT(census_ht_get_size(ht) == 0);
- for (i = 0; i < 9; i++) {
- census_ht_key key;
- key.ptr = (void *)(keys[i]);
- census_ht_insert(ht, key, (void *)(vals + i));
- }
- GPR_ASSERT(census_ht_get_size(ht) == 9);
- for (i = 0; i < 9; i++) {
- census_ht_key key;
- int *val_ptr;
- key.ptr = (void *)(keys[i]);
- val_ptr = census_ht_find(ht, key);
- GPR_ASSERT(*val_ptr == vals[i]);
- }
- {
- /* inserts duplicate keys */
- census_ht_key key;
- int *val_ptr = NULL;
- key.ptr = (void *)(keys[2]);
- census_ht_insert(ht, key, (void *)(vals + 8));
- /* expect value to be over written by new insertion */
- GPR_ASSERT(census_ht_get_size(ht) == 9);
- val_ptr = census_ht_find(ht, key);
- GPR_ASSERT(*val_ptr == vals[8]);
- }
- for (i = 0; i < 9; i++) {
- census_ht_key key;
- int *val_ptr;
- uint32_t expected_tbl_sz = 9 - i;
- GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz);
- key.ptr = (void *)(keys[i]);
- val_ptr = census_ht_find(ht, key);
- GPR_ASSERT(val_ptr != NULL);
- census_ht_erase(ht, key);
- GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz - 1);
- val_ptr = census_ht_find(ht, key);
- GPR_ASSERT(val_ptr == NULL);
- }
- census_ht_destroy(ht);
-}
-
-static void test_insertion_with_same_key(void) {
- census_ht_option opt = {CENSUS_HT_UINT64, 11, NULL, NULL, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
- census_ht_key key;
- const char vals[] = {'a', 'b', 'c'};
- char *val_ptr;
- key.val = 3;
- census_ht_insert(ht, key, (void *)&(vals[0]));
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- val_ptr = (char *)census_ht_find(ht, key);
- GPR_ASSERT(val_ptr != NULL);
- GPR_ASSERT(*val_ptr == 'a');
- key.val = 4;
- val_ptr = (char *)census_ht_find(ht, key);
- GPR_ASSERT(val_ptr == NULL);
- key.val = 3;
- census_ht_insert(ht, key, (void *)&(vals[1]));
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- val_ptr = (char *)census_ht_find(ht, key);
- GPR_ASSERT(val_ptr != NULL);
- GPR_ASSERT(*val_ptr == 'b');
- census_ht_insert(ht, key, (void *)&(vals[2]));
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- val_ptr = (char *)census_ht_find(ht, key);
- GPR_ASSERT(val_ptr != NULL);
- GPR_ASSERT(*val_ptr == 'c');
- census_ht_destroy(ht);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- test_create_table();
- test_simple_add_and_erase();
- test_table_with_int_key();
- test_table_with_string_key();
- test_value_and_key_deleter();
- test_insertion_with_same_key();
- test_insertion_and_deletion_with_high_collision_rate();
- return 0;
-}
diff --git a/test/core/statistics/multiple_writers_circular_buffer_test.c b/test/core/statistics/multiple_writers_circular_buffer_test.cc
index 8abd76c3d1..6d3411289e 100644
--- a/test/core/statistics/multiple_writers_circular_buffer_test.c
+++ b/test/core/statistics/multiple_writers_circular_buffer_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_multiple_writers_circular_log();
diff --git a/test/core/statistics/multiple_writers_test.c b/test/core/statistics/multiple_writers_test.cc
index de800e0d8a..47410ab105 100644
--- a/test/core/statistics/multiple_writers_test.c
+++ b/test/core/statistics/multiple_writers_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_multiple_writers();
diff --git a/test/core/statistics/performance_test.c b/test/core/statistics/performance_test.cc
index 6104acb612..9d4fd6ef90 100644
--- a/test/core/statistics/performance_test.c
+++ b/test/core/statistics/performance_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_performance();
diff --git a/test/core/statistics/quick_test.c b/test/core/statistics/quick_test.cc
index 1e044b6b59..91ecdde818 100644
--- a/test/core/statistics/quick_test.c
+++ b/test/core/statistics/quick_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_invalid_record_size();
diff --git a/test/core/statistics/rpc_stats_test.c b/test/core/statistics/rpc_stats_test.cc
index 01ac5a19ab..aead5cfdca 100644
--- a/test/core/statistics/rpc_stats_test.c
+++ b/test/core/statistics/rpc_stats_test.cc
@@ -39,7 +39,7 @@ static void test_init_shutdown(void) {
}
static void test_create_and_destroy(void) {
- census_rpc_stats *stats = NULL;
+ census_rpc_stats* stats = NULL;
census_aggregated_rpc_stats agg_stats = {0, NULL};
stats = census_rpc_stats_create_empty();
@@ -54,7 +54,7 @@ static void test_create_and_destroy(void) {
GPR_ASSERT(agg_stats.num_entries == 0);
GPR_ASSERT(agg_stats.stats == NULL);
agg_stats.num_entries = 1;
- agg_stats.stats = (census_per_method_rpc_stats *)gpr_malloc(
+ agg_stats.stats = (census_per_method_rpc_stats*)gpr_malloc(
sizeof(census_per_method_rpc_stats));
agg_stats.stats[0].method = gpr_strdup("foo");
census_aggregated_rpc_stats_set_empty(&agg_stats);
@@ -172,7 +172,7 @@ static void test_record_stats_with_trace_store_uninitialized(void) {
census_stats_store_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_init_shutdown();
test_create_and_destroy();
diff --git a/test/core/statistics/small_log_test.c b/test/core/statistics/small_log_test.cc
index 4bcc35c37e..fb8dfc9988 100644
--- a/test/core/statistics/small_log_test.c
+++ b/test/core/statistics/small_log_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_small_log();
diff --git a/test/core/statistics/trace_test.c b/test/core/statistics/trace_test.c
deleted file mode 100644
index 63da9f71d3..0000000000
--- a/test/core/statistics/trace_test.c
+++ /dev/null
@@ -1,240 +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 <stdio.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-#include <grpc/support/time.h>
-#include <grpc/support/useful.h>
-#include "src/core/ext/census/census_interface.h"
-#include "src/core/ext/census/census_tracing.h"
-#include "src/core/ext/census/census_tracing.h"
-#include "test/core/util/test_config.h"
-
-/* Ensure all possible state transitions are called without causing problem */
-static void test_init_shutdown(void) {
- census_tracing_init();
- census_tracing_init();
- census_tracing_shutdown();
- census_tracing_shutdown();
- census_tracing_init();
-}
-
-static void test_start_op_generates_locally_unique_ids(void) {
-/* Check that ids generated within window size of 1000 are unique.
- TODO(hongyu): Replace O(n^2) duplicate detection algorithm with O(nlogn)
- algorithm. Enhance the test to larger window size (>10^6) */
-#define WINDOW_SIZE 1000
- census_op_id ids[WINDOW_SIZE];
- int i;
- census_init();
- for (i = 0; i < WINDOW_SIZE; i++) {
- ids[i] = census_tracing_start_op();
- census_tracing_end_op(ids[i]);
- }
- for (i = 0; i < WINDOW_SIZE - 1; i++) {
- int j;
- for (j = i + 1; j < WINDOW_SIZE; j++) {
- GPR_ASSERT(ids[i].upper != ids[j].upper || ids[i].lower != ids[j].lower);
- }
- }
-#undef WINDOW_SIZE
- census_shutdown();
-}
-
-static void test_get_trace_method_name(void) {
- census_op_id id;
- const char write_name[] = "service/method";
- census_tracing_init();
- id = census_tracing_start_op();
- census_add_method_tag(id, write_name);
- census_internal_lock_trace_store();
- {
- const char *read_name =
- census_get_trace_method_name(census_get_trace_obj_locked(id));
- GPR_ASSERT(strcmp(read_name, write_name) == 0);
- }
- census_internal_unlock_trace_store();
- census_tracing_shutdown();
-}
-
-typedef struct thd_arg {
- int num_done;
- gpr_cv done;
- gpr_mu mu;
-} thd_arg;
-
-static void mimic_trace_op_sequences(void *arg) {
- census_op_id id;
- const char *method_name = "service_foo/method_bar";
- int i = 0;
- const int num_iter = 200;
- thd_arg *args = (thd_arg *)arg;
- GPR_ASSERT(args != NULL);
- gpr_log(GPR_INFO, "Start trace op sequence thread.");
- for (i = 0; i < num_iter; i++) {
- id = census_tracing_start_op();
- census_add_method_tag(id, method_name);
- /* pretend doing 1us work. */
- gpr_sleep_until(GRPC_TIMEOUT_MICROS_TO_DEADLINE(1));
- census_tracing_end_op(id);
- }
- gpr_log(GPR_INFO, "End trace op sequence thread.");
- gpr_mu_lock(&args->mu);
- args->num_done += 1;
- gpr_cv_broadcast(&args->done);
- gpr_mu_unlock(&args->mu);
-}
-
-static void test_concurrency(void) {
-#define NUM_THREADS 1000
- gpr_thd_id tid[NUM_THREADS];
- int i = 0;
- thd_arg arg;
- arg.num_done = 0;
- gpr_mu_init(&arg.mu);
- gpr_cv_init(&arg.done);
- census_tracing_init();
- for (i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(tid + i, mimic_trace_op_sequences, &arg, NULL);
- }
- gpr_mu_lock(&arg.mu);
- while (arg.num_done < NUM_THREADS) {
- gpr_log(GPR_INFO, "num done %d", arg.num_done);
- gpr_cv_wait(&arg.done, &arg.mu, gpr_inf_future(GPR_CLOCK_REALTIME));
- }
- gpr_mu_unlock(&arg.mu);
- census_tracing_shutdown();
-#undef NUM_THREADS
-}
-
-static void test_add_method_tag_to_unknown_op_id(void) {
- census_op_id unknown_id = {0xDEAD, 0xBEEF};
- int ret = 0;
- census_tracing_init();
- ret = census_add_method_tag(unknown_id, "foo");
- GPR_ASSERT(ret != 0);
- census_tracing_shutdown();
-}
-
-static void test_trace_print(void) {
- census_op_id id;
- int i;
- const char *annotation_txt[4] = {"abc", "", "$%^ *()_"};
- char long_txt[CENSUS_MAX_ANNOTATION_LENGTH + 10];
-
- memset(long_txt, 'a', GPR_ARRAY_SIZE(long_txt));
- long_txt[CENSUS_MAX_ANNOTATION_LENGTH + 9] = '\0';
- annotation_txt[3] = long_txt;
-
- census_tracing_init();
- id = census_tracing_start_op();
- /* Adds large number of annotations to each trace */
- for (i = 0; i < 1000; i++) {
- census_tracing_print(id,
- annotation_txt[i % GPR_ARRAY_SIZE(annotation_txt)]);
- }
- census_tracing_end_op(id);
-
- census_tracing_shutdown();
-}
-
-/* Returns 1 if two ids are equal, otherwise returns 0. */
-static int ids_equal(census_op_id id1, census_op_id id2) {
- return (id1.upper == id2.upper) && (id1.lower == id2.lower);
-}
-
-static void test_get_active_ops(void) {
- census_op_id id_1, id_2, id_3;
- census_trace_obj **active_ops;
- const char *annotation_txt[] = {"annotation 1", "a2"};
- int i = 0;
- int n = 0;
-
- gpr_log(GPR_INFO, "test_get_active_ops");
- census_tracing_init();
- /* No active ops before calling start_op(). */
- active_ops = census_get_active_ops(&n);
- GPR_ASSERT(active_ops == NULL);
- GPR_ASSERT(n == 0);
-
- /* Starts one op */
- id_1 = census_tracing_start_op();
- census_add_method_tag(id_1, "foo_1");
- active_ops = census_get_active_ops(&n);
- GPR_ASSERT(active_ops != NULL);
- GPR_ASSERT(n == 1);
- GPR_ASSERT(ids_equal(active_ops[0]->id, id_1));
- census_trace_obj_destroy(active_ops[0]);
- gpr_free(active_ops);
- active_ops = NULL;
-
- /* Start the second and the third ops */
- id_2 = census_tracing_start_op();
- census_add_method_tag(id_2, "foo_2");
- id_3 = census_tracing_start_op();
- census_add_method_tag(id_3, "foo_3");
-
- active_ops = census_get_active_ops(&n);
- GPR_ASSERT(n == 3);
- for (i = 0; i < 3; i++) {
- census_trace_obj_destroy(active_ops[i]);
- }
- gpr_free(active_ops);
- active_ops = NULL;
-
- /* End the second op and add annotations to the third ops */
- census_tracing_end_op(id_2);
- census_tracing_print(id_3, annotation_txt[0]);
- census_tracing_print(id_3, annotation_txt[1]);
-
- active_ops = census_get_active_ops(&n);
- GPR_ASSERT(active_ops != NULL);
- GPR_ASSERT(n == 2);
- for (i = 0; i < 2; i++) {
- census_trace_obj_destroy(active_ops[i]);
- }
- gpr_free(active_ops);
- active_ops = NULL;
-
- /* End all ops. */
- census_tracing_end_op(id_1);
- census_tracing_end_op(id_3);
- active_ops = census_get_active_ops(&n);
- GPR_ASSERT(active_ops == NULL);
- GPR_ASSERT(n == 0);
-
- census_tracing_shutdown();
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- test_init_shutdown();
- test_start_op_generates_locally_unique_ids();
- test_get_trace_method_name();
- test_concurrency();
- test_add_method_tag_to_unknown_op_id();
- test_trace_print();
- test_get_active_ops();
- return 0;
-}
diff --git a/test/core/statistics/window_stats_test.c b/test/core/statistics/window_stats_test.c
deleted file mode 100644
index 254c14a6a8..0000000000
--- a/test/core/statistics/window_stats_test.c
+++ /dev/null
@@ -1,303 +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/census/window_stats.h"
-#include <grpc/support/log.h>
-#include <grpc/support/time.h>
-#include <stdlib.h>
-#include "test/core/util/test_config.h"
-
-typedef struct test_stat {
- double value1;
- int value2;
-} test_stat;
-
-void add_test_stat(void *base, const void *addme) {
- test_stat *b = (test_stat *)base;
- const test_stat *a = (const test_stat *)addme;
- b->value1 += a->value1;
- b->value2 += a->value2;
-}
-
-void add_proportion_test_stat(double p, void *base, const void *addme) {
- test_stat *b = (test_stat *)base;
- const test_stat *a = (const test_stat *)addme;
- b->value1 += p * a->value1;
- b->value2 += p * a->value2 + 0.5; /* +0.5 is poor mans (no c99) round() */
-}
-
-const struct census_window_stats_stat_info kMyStatInfo = {
- sizeof(test_stat), NULL, add_test_stat, add_proportion_test_stat};
-
-const gpr_timespec kMilliSecInterval = {0, 1000000};
-const gpr_timespec kSecInterval = {1, 0};
-const gpr_timespec kMinInterval = {60, 0};
-const gpr_timespec kHourInterval = {3600, 0};
-const gpr_timespec kPrimeInterval = {0, 101};
-
-static int compare_double(double a, double b, double epsilon) {
- if (a >= b) {
- return (a > b + epsilon) ? 1 : 0;
- } else {
- return (b > a + epsilon) ? -1 : 0;
- }
-}
-
-void empty_test(void) {
- census_window_stats_sums result;
- const gpr_timespec zero = {0, 0};
- test_stat sum;
- struct census_window_stats *stats =
- census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo);
- GPR_ASSERT(stats != NULL);
- result.statistic = &sum;
- census_window_stats_get_sums(stats, zero, &result);
- GPR_ASSERT(result.count == 0 && sum.value1 == 0 && sum.value2 == 0);
- census_window_stats_get_sums(stats, gpr_now(GPR_CLOCK_REALTIME), &result);
- GPR_ASSERT(result.count == 0 && sum.value1 == 0 && sum.value2 == 0);
- census_window_stats_destroy(stats);
-}
-
-void one_interval_test(void) {
- const test_stat value = {0.1, 4};
- const double epsilon = 1e10 - 11;
- gpr_timespec when = {0, 0};
- census_window_stats_sums result;
- test_stat sum;
- /* granularity == 5 so width of internal windows should be 12s */
- struct census_window_stats *stats =
- census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo);
- GPR_ASSERT(stats != NULL);
- /* phase 1: insert a single value at t=0s, and check that various measurement
- times result in expected output values */
- census_window_stats_add(stats, when, &value);
- result.statistic = &sum;
- /* when = 0s, values extracted should be everything */
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 1, epsilon) == 0 &&
- compare_double(sum.value1, value.value1, epsilon) == 0 &&
- sum.value2 == value.value2);
- /* when = 6,30,60s, should be all of the data */
- when.tv_sec = 6;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 1.0, epsilon) == 0 &&
- compare_double(sum.value1, value.value1, epsilon) == 0 &&
- sum.value2 == value.value2);
- /* when == 30s,60s, should be all of the data */
- when.tv_sec = 30;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 1.0, epsilon) == 0 &&
- compare_double(sum.value1, value.value1, epsilon) == 0 &&
- sum.value2 == value.value2);
- when.tv_sec = 60;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 1.0, epsilon) == 0 &&
- compare_double(sum.value1, value.value1, epsilon) == 0 &&
- sum.value2 == value.value2);
- /* when = 66s, should be half (only take half of bottom bucket) */
- when.tv_sec = 66;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 0.5, epsilon) == 0 &&
- compare_double(sum.value1, value.value1 / 2, epsilon) == 0 &&
- sum.value2 == value.value2 / 2);
- /* when = 72s, should be completely out of window */
- when.tv_sec = 72;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 0, epsilon) == 0 &&
- compare_double(sum.value1, 0, epsilon) == 0 && sum.value2 == 0);
-
- /* phase 2: tear down and do as before, but inserting two values */
- census_window_stats_destroy(stats);
- stats = census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo);
- GPR_ASSERT(stats != NULL);
- when.tv_sec = 0;
- when.tv_nsec = 17;
- census_window_stats_add(stats, when, &value);
- when.tv_sec = 1;
- census_window_stats_add(stats, when, &value);
- when.tv_sec = 0;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 0, epsilon) == 0 &&
- compare_double(sum.value1, 0, epsilon) == 0 && sum.value2 == 0);
- /* time = 3s, 30s, should get all data */
- when.tv_sec = 3;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 2, epsilon) == 0 &&
- compare_double(sum.value1, 2 * value.value1, epsilon) == 0 &&
- sum.value2 == 2 * value.value2);
- when.tv_sec = 30;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(compare_double(result.count, 2, epsilon) == 0 &&
- compare_double(sum.value1, 2 * value.value1, epsilon) == 0 &&
- sum.value2 == 2 * value.value2);
-
- /* phase 3: insert into "middle" bucket, and force a shift, pushing out
- the two values in bottom bucket */
- when.tv_sec = 30;
- census_window_stats_add(stats, when, &value);
- when.tv_sec = 76;
- census_window_stats_add(stats, when, &value);
- when.tv_sec = 0;
- census_window_stats_get_sums(stats, when, &result);
- GPR_ASSERT(result.count == 0 && sum.value1 == 0 && sum.value2 == 0);
- when.tv_sec = 30;
- census_window_stats_get_sums(stats, when, &result);
- /* half of the single value in the 30 second bucket */
- GPR_ASSERT(compare_double(result.count, 0.5, epsilon) == 0 &&
- compare_double(sum.value1, value.value1 / 2, epsilon) == 0 &&
- sum.value2 == value.value2 / 2);
- when.tv_sec = 74;
- census_window_stats_get_sums(stats, when, &result);
- /* half of the 76 second bucket, all of the 30 second bucket */
- GPR_ASSERT(compare_double(result.count, 1.5, epsilon) == 0 &&
- compare_double(sum.value1, value.value1 * 1.5, epsilon) == 0 &&
- sum.value2 == value.value2 / 2 * 3);
- when.tv_sec = 76;
- census_window_stats_get_sums(stats, when, &result);
- /* >=76s, get all of the 76 second bucket, all of the 30 second bucket */
- GPR_ASSERT(compare_double(result.count, 2, epsilon) == 0 &&
- compare_double(sum.value1, value.value1 * 2, epsilon) == 0 &&
- sum.value2 == value.value2 * 2);
- when.tv_sec = 78;
- census_window_stats_get_sums(stats, when, &result);
- /* half of the 76 second bucket, all of the 30 second bucket */
- GPR_ASSERT(compare_double(result.count, 2, epsilon) == 0 &&
- compare_double(sum.value1, value.value1 * 2, epsilon) == 0 &&
- sum.value2 == value.value2 * 2);
- census_window_stats_destroy(stats);
-}
-
-void many_interval_test(void) {
- gpr_timespec intervals[4];
- const test_stat value = {123.45, 8};
- const double epsilon = 1e10 - 11;
- gpr_timespec when = {3600, 0}; /* one hour */
- census_window_stats_sums result[4];
- test_stat sums[4];
- int i;
- struct census_window_stats *stats;
- intervals[0] = kMilliSecInterval;
- intervals[1] = kSecInterval;
- intervals[2] = kMinInterval;
- intervals[3] = kHourInterval;
- for (i = 0; i < 4; i++) {
- result[i].statistic = &sums[i];
- }
- stats = census_window_stats_create(4, intervals, 100, &kMyStatInfo);
- GPR_ASSERT(stats != NULL);
- /* add 10 stats within half of each time range */
- for (i = 0; i < 10; i++) {
- when.tv_sec += 180; /* covers 30 min of one hour range */
- census_window_stats_add(stats, when, &value);
- }
- when.tv_sec += 120;
- for (i = 0; i < 10; i++) {
- when.tv_sec += 3; /* covers 30 sec of one minute range */
- census_window_stats_add(stats, when, &value);
- }
- when.tv_sec += 2;
- for (i = 0; i < 10; i++) {
- when.tv_nsec += 50000000; /* covers 0.5s of 1s range */
- census_window_stats_add(stats, when, &value);
- }
- when.tv_nsec += 2000000;
- for (i = 0; i < 10; i++) {
- when.tv_nsec += 50000; /* covers 0.5 ms of 1 ms range */
- census_window_stats_add(stats, when, &value);
- }
- when.tv_nsec += 20000;
- census_window_stats_get_sums(stats, when, result);
- GPR_ASSERT(compare_double(result[0].count, 10, epsilon) == 0 &&
- compare_double(sums[0].value1, value.value1 * 10, epsilon) == 0 &&
- sums[0].value2 == value.value2 * 10);
- when.tv_nsec += 20000000;
- census_window_stats_get_sums(stats, when, result);
- GPR_ASSERT(compare_double(result[1].count, 20, epsilon) == 0 &&
- compare_double(sums[1].value1, value.value1 * 20, epsilon) == 0 &&
- sums[1].value2 == value.value2 * 20);
- when.tv_sec += 2;
- census_window_stats_get_sums(stats, when, result);
- GPR_ASSERT(compare_double(result[2].count, 30, epsilon) == 0 &&
- compare_double(sums[2].value1, value.value1 * 30, epsilon) == 0 &&
- sums[2].value2 == value.value2 * 30);
- when.tv_sec += 72;
- census_window_stats_get_sums(stats, when, result);
- GPR_ASSERT(compare_double(result[3].count, 40, epsilon) == 0 &&
- compare_double(sums[3].value1, value.value1 * 40, epsilon) == 0 &&
- sums[3].value2 == value.value2 * 40);
- census_window_stats_destroy(stats);
-}
-
-void rolling_time_test(void) {
- const test_stat value = {0.1, 4};
- gpr_timespec when = {0, 0};
- census_window_stats_sums result;
- test_stat sum;
- int i;
- gpr_timespec increment = {0, 0};
- struct census_window_stats *stats =
- census_window_stats_create(1, &kMinInterval, 7, &kMyStatInfo);
- GPR_ASSERT(stats != NULL);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- for (i = 0; i < 100000; i++) {
- increment.tv_nsec = rand() % 100000000; /* up to 1/10th second */
- when = gpr_time_add(when, increment);
- census_window_stats_add(stats, when, &value);
- }
- result.statistic = &sum;
- census_window_stats_get_sums(stats, when, &result);
- /* With 1/20th second average between samples, we expect 20*60 = 1200
- samples on average. Make sure we are within 100 of that. */
- GPR_ASSERT(compare_double(result.count, 1200, 100) == 0);
- census_window_stats_destroy(stats);
-}
-
-#include <stdio.h>
-void infinite_interval_test(void) {
- const test_stat value = {0.1, 4};
- gpr_timespec when = {0, 0};
- census_window_stats_sums result;
- test_stat sum;
- int i;
- const int count = 100000;
- gpr_timespec increment = {0, 0};
- struct census_window_stats *stats = census_window_stats_create(
- 1, &gpr_inf_future(GPR_CLOCK_REALTIME), 10, &kMyStatInfo);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- for (i = 0; i < count; i++) {
- increment.tv_sec = rand() % 21600; /* 6 hours */
- when = gpr_time_add(when, increment);
- census_window_stats_add(stats, when, &value);
- }
- result.statistic = &sum;
- census_window_stats_get_sums(stats, when, &result);
- /* The only thing it makes sense to compare for "infinite" periods is the
- total counts */
- GPR_ASSERT(result.count == count);
- census_window_stats_destroy(stats);
-}
-
-int main(int argc, char *argv[]) {
- grpc_test_init(argc, argv);
- empty_test();
- one_interval_test();
- many_interval_test();
- rolling_time_test();
- infinite_interval_test();
- return 0;
-}
diff --git a/test/core/support/avl_test.c b/test/core/support/avl_test.c
deleted file mode 100644
index 37424d6405..0000000000
--- a/test/core/support/avl_test.c
+++ /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 <grpc/support/avl.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/useful.h>
-
-#include "test/core/util/test_config.h"
-
-static int *box(int x) {
- int *b = 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, NULL) == value);
- gpr_free(k);
-}
-
-static void check_negget(gpr_avl avl, int key) {
- int *k = box(key);
- GPR_ASSERT(gpr_avl_get(avl, k, NULL) == NULL);
- gpr_free(k);
-}
-
-static gpr_avl remove_int(gpr_avl avl, int key) {
- int *k = box(key);
- avl = gpr_avl_remove(avl, k, NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(2), box(22), NULL);
- avl = gpr_avl_add(avl, box(3), box(33), NULL);
- check_get(avl, 1, 11);
- check_get(avl, 2, 22);
- check_get(avl, 3, 33);
- check_negget(avl, 4);
- gpr_avl_unref(avl, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(4), box(2), NULL);
- avl = gpr_avl_add(avl, box(3), box(3), NULL);
- 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, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(3), box(2), NULL);
- avl = gpr_avl_add(avl, box(4), box(3), NULL);
- 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, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(4), box(2), NULL);
- avl = gpr_avl_add(avl, box(5), box(3), NULL);
- 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, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(5), box(2), NULL);
- avl = gpr_avl_add(avl, box(4), box(3), NULL);
- 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, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(4), box(2), NULL);
- avl = gpr_avl_add(avl, box(3), box(3), NULL);
- avl = gpr_avl_add(avl, box(2), box(4), NULL);
- avl = gpr_avl_add(avl, box(1), box(5), NULL);
- 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, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(1), box(2), NULL);
- check_get(avl, 1, 2);
- check_negget(avl, 2);
- gpr_avl_unref(avl, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(4), box(2), NULL);
- avl = gpr_avl_add(avl, box(5), box(3), NULL);
-
- avl3 = remove_int(gpr_avl_ref(avl, NULL), 3);
- avl4 = remove_int(gpr_avl_ref(avl, NULL), 4);
- avl5 = remove_int(gpr_avl_ref(avl, NULL), 5);
- avln = remove_int(gpr_avl_ref(avl, NULL), 1);
-
- gpr_avl_unref(avl, NULL);
-
- check_negget(avl3, 3);
- check_get(avl3, 4, 2);
- check_get(avl3, 5, 3);
- gpr_avl_unref(avl3, NULL);
-
- check_get(avl4, 3, 1);
- check_negget(avl4, 4);
- check_get(avl4, 5, 3);
- gpr_avl_unref(avl4, NULL);
-
- check_get(avl5, 3, 1);
- check_get(avl5, 4, 2);
- check_negget(avl5, 5);
- gpr_avl_unref(avl5, NULL);
-
- check_get(avln, 3, 1);
- check_get(avln, 4, 2);
- check_get(avln, 5, 3);
- gpr_avl_unref(avln, NULL);
-}
-
-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), NULL);
- avl = remove_int(avl, 643);
- avl = remove_int(avl, 983);
- avl = gpr_avl_add(avl, box(985), box(4), NULL);
- avl = gpr_avl_add(avl, box(640), box(5), NULL);
- avl = gpr_avl_add(avl, box(41), box(6), NULL);
- avl = gpr_avl_add(avl, box(112), box(7), NULL);
- avl = gpr_avl_add(avl, box(342), box(8), NULL);
- avl = remove_int(avl, 1013);
- avl = gpr_avl_add(avl, box(434), box(10), NULL);
- avl = gpr_avl_add(avl, box(520), box(11), NULL);
- avl = gpr_avl_add(avl, box(231), box(12), NULL);
- avl = gpr_avl_add(avl, box(852), box(13), NULL);
- avl = remove_int(avl, 461);
- avl = gpr_avl_add(avl, box(108), box(15), NULL);
- avl = gpr_avl_add(avl, box(806), box(16), NULL);
- avl = gpr_avl_add(avl, box(827), box(17), NULL);
- avl = remove_int(avl, 796);
- avl = gpr_avl_add(avl, box(340), box(19), NULL);
- avl = gpr_avl_add(avl, box(498), box(20), NULL);
- avl = gpr_avl_add(avl, box(203), box(21), NULL);
- avl = gpr_avl_add(avl, box(751), box(22), NULL);
- avl = gpr_avl_add(avl, box(150), box(23), NULL);
- avl = remove_int(avl, 237);
- avl = gpr_avl_add(avl, box(830), box(25), NULL);
- avl = remove_int(avl, 1007);
- avl = remove_int(avl, 394);
- avl = gpr_avl_add(avl, box(65), box(28), NULL);
- avl = remove_int(avl, 904);
- avl = remove_int(avl, 123);
- avl = gpr_avl_add(avl, box(238), box(31), NULL);
- avl = gpr_avl_add(avl, box(184), box(32), NULL);
- avl = remove_int(avl, 331);
- avl = gpr_avl_add(avl, box(827), box(34), NULL);
-
- check_get(avl, 830, 25);
-
- gpr_avl_unref(avl, NULL);
-}
-
-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), NULL);
- avl = remove_int(avl, 415);
- avl = gpr_avl_add(avl, box(953), box(3), NULL);
- avl = gpr_avl_add(avl, box(101), box(4), NULL);
- avl = gpr_avl_add(avl, box(516), box(5), NULL);
- avl = gpr_avl_add(avl, box(547), box(6), NULL);
- avl = gpr_avl_add(avl, box(467), box(7), NULL);
- avl = gpr_avl_add(avl, box(793), box(8), NULL);
- avl = remove_int(avl, 190);
- avl = gpr_avl_add(avl, box(687), box(10), NULL);
- avl = gpr_avl_add(avl, box(242), box(11), NULL);
- avl = gpr_avl_add(avl, box(142), box(12), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(622), box(18), NULL);
- avl = remove_int(avl, 513);
- avl = remove_int(avl, 429);
- avl = gpr_avl_add(avl, box(205), box(21), NULL);
- avl = remove_int(avl, 663);
- avl = remove_int(avl, 953);
- avl = remove_int(avl, 892);
- avl = gpr_avl_add(avl, box(236), box(25), NULL);
- avl = remove_int(avl, 982);
- avl = remove_int(avl, 201);
- avl = remove_int(avl, 684);
- avl = gpr_avl_add(avl, box(572), box(29), NULL);
- avl = remove_int(avl, 817);
- avl = gpr_avl_add(avl, box(970), box(31), NULL);
- avl = remove_int(avl, 347);
- avl = remove_int(avl, 574);
- avl = gpr_avl_add(avl, box(752), box(34), NULL);
- avl = gpr_avl_add(avl, box(670), box(35), NULL);
- avl = gpr_avl_add(avl, box(69), box(36), NULL);
- avl = remove_int(avl, 111);
- avl = remove_int(avl, 523);
- avl = gpr_avl_add(avl, box(141), box(39), NULL);
- avl = remove_int(avl, 159);
- avl = gpr_avl_add(avl, box(947), box(41), NULL);
- avl = gpr_avl_add(avl, box(855), box(42), NULL);
- avl = remove_int(avl, 218);
- avl = remove_int(avl, 6);
- avl = gpr_avl_add(avl, box(753), box(45), NULL);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 799);
- avl = gpr_avl_add(avl, box(572), box(48), NULL);
- avl = remove_int(avl, 376);
- avl = remove_int(avl, 413);
- avl = gpr_avl_add(avl, box(458), box(51), NULL);
- avl = remove_int(avl, 897);
- avl = gpr_avl_add(avl, box(191), box(53), NULL);
- avl = gpr_avl_add(avl, box(609), box(54), NULL);
- 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), NULL);
- avl = remove_int(avl, 641);
- avl = gpr_avl_add(avl, box(462), box(62), NULL);
- avl = remove_int(avl, 359);
- avl = remove_int(avl, 767);
- avl = gpr_avl_add(avl, box(310), box(65), NULL);
- avl = remove_int(avl, 757);
- avl = remove_int(avl, 639);
- avl = remove_int(avl, 314);
- avl = gpr_avl_add(avl, box(2), box(69), NULL);
- avl = remove_int(avl, 138);
- avl = gpr_avl_add(avl, box(669), box(71), NULL);
- avl = remove_int(avl, 477);
- avl = gpr_avl_add(avl, box(366), box(73), NULL);
- avl = gpr_avl_add(avl, box(612), box(74), NULL);
- avl = gpr_avl_add(avl, box(106), box(75), NULL);
- avl = remove_int(avl, 161);
- avl = gpr_avl_add(avl, box(388), box(77), NULL);
- avl = gpr_avl_add(avl, box(141), box(78), NULL);
- avl = remove_int(avl, 633);
- avl = remove_int(avl, 459);
- avl = gpr_avl_add(avl, box(40), box(81), NULL);
- avl = remove_int(avl, 689);
- avl = gpr_avl_add(avl, box(823), box(83), NULL);
- avl = remove_int(avl, 485);
- avl = gpr_avl_add(avl, box(903), box(85), NULL);
- avl = gpr_avl_add(avl, box(592), box(86), NULL);
- avl = remove_int(avl, 448);
- avl = gpr_avl_add(avl, box(56), box(88), NULL);
- avl = remove_int(avl, 333);
- avl = gpr_avl_add(avl, box(189), box(90), NULL);
- avl = gpr_avl_add(avl, box(103), box(91), NULL);
- avl = remove_int(avl, 164);
- avl = remove_int(avl, 974);
- avl = gpr_avl_add(avl, box(215), box(94), NULL);
- avl = remove_int(avl, 189);
- avl = remove_int(avl, 504);
- avl = gpr_avl_add(avl, box(868), box(97), NULL);
- avl = remove_int(avl, 909);
- avl = remove_int(avl, 148);
- avl = remove_int(avl, 469);
- avl = gpr_avl_add(avl, box(994), box(101), NULL);
- avl = gpr_avl_add(avl, box(576), box(102), NULL);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 209);
- avl = gpr_avl_add(avl, box(276), box(105), NULL);
- avl = remove_int(avl, 856);
- avl = gpr_avl_add(avl, box(750), box(107), NULL);
- avl = remove_int(avl, 871);
- avl = gpr_avl_add(avl, box(301), box(109), NULL);
- avl = remove_int(avl, 260);
- avl = remove_int(avl, 737);
- avl = remove_int(avl, 719);
- avl = gpr_avl_add(avl, box(933), box(113), NULL);
- avl = gpr_avl_add(avl, box(225), box(114), NULL);
- avl = gpr_avl_add(avl, box(975), box(115), NULL);
- avl = gpr_avl_add(avl, box(86), box(116), NULL);
- avl = remove_int(avl, 732);
- avl = gpr_avl_add(avl, box(340), box(118), NULL);
- avl = gpr_avl_add(avl, box(271), box(119), NULL);
- avl = remove_int(avl, 206);
- avl = gpr_avl_add(avl, box(949), box(121), NULL);
- avl = gpr_avl_add(avl, box(927), box(122), NULL);
- avl = gpr_avl_add(avl, box(34), box(123), NULL);
- avl = gpr_avl_add(avl, box(351), box(124), NULL);
- avl = remove_int(avl, 836);
- avl = gpr_avl_add(avl, box(825), box(126), NULL);
- avl = gpr_avl_add(avl, box(352), box(127), NULL);
- avl = remove_int(avl, 107);
- avl = remove_int(avl, 101);
- avl = gpr_avl_add(avl, box(320), box(130), NULL);
- avl = gpr_avl_add(avl, box(3), box(131), NULL);
- avl = remove_int(avl, 998);
- avl = remove_int(avl, 44);
- avl = gpr_avl_add(avl, box(525), box(134), NULL);
- avl = gpr_avl_add(avl, box(864), box(135), NULL);
- avl = gpr_avl_add(avl, box(863), box(136), NULL);
- avl = remove_int(avl, 770);
- avl = gpr_avl_add(avl, box(440), box(138), NULL);
- avl = remove_int(avl, 516);
- avl = gpr_avl_add(avl, box(116), box(140), NULL);
- avl = remove_int(avl, 380);
- avl = gpr_avl_add(avl, box(878), box(142), NULL);
- avl = remove_int(avl, 439);
- avl = gpr_avl_add(avl, box(994), box(144), NULL);
- avl = remove_int(avl, 294);
- avl = remove_int(avl, 593);
- avl = gpr_avl_add(avl, box(696), box(147), NULL);
- avl = remove_int(avl, 8);
- avl = gpr_avl_add(avl, box(881), box(149), NULL);
- avl = remove_int(avl, 32);
- avl = remove_int(avl, 242);
- avl = gpr_avl_add(avl, box(487), box(152), NULL);
- avl = gpr_avl_add(avl, box(637), box(153), NULL);
- avl = gpr_avl_add(avl, box(793), box(154), NULL);
- avl = gpr_avl_add(avl, box(696), box(155), NULL);
- avl = remove_int(avl, 458);
- avl = gpr_avl_add(avl, box(828), box(157), NULL);
- avl = remove_int(avl, 784);
- avl = remove_int(avl, 274);
- avl = gpr_avl_add(avl, box(783), box(160), NULL);
- avl = remove_int(avl, 21);
- avl = gpr_avl_add(avl, box(866), box(162), NULL);
- avl = remove_int(avl, 919);
- avl = gpr_avl_add(avl, box(435), box(164), NULL);
- avl = remove_int(avl, 385);
- avl = gpr_avl_add(avl, box(475), box(166), NULL);
- avl = remove_int(avl, 339);
- avl = gpr_avl_add(avl, box(615), box(168), NULL);
- avl = remove_int(avl, 866);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 271);
- avl = gpr_avl_add(avl, box(590), box(172), NULL);
- avl = gpr_avl_add(avl, box(852), box(173), NULL);
- avl = remove_int(avl, 318);
- avl = remove_int(avl, 82);
- avl = gpr_avl_add(avl, box(672), box(176), NULL);
- avl = remove_int(avl, 430);
- avl = gpr_avl_add(avl, box(821), box(178), NULL);
- avl = gpr_avl_add(avl, box(365), box(179), NULL);
- avl = remove_int(avl, 78);
- avl = gpr_avl_add(avl, box(700), box(181), NULL);
- avl = gpr_avl_add(avl, box(353), box(182), NULL);
- avl = remove_int(avl, 492);
- avl = gpr_avl_add(avl, box(991), box(184), NULL);
- avl = remove_int(avl, 330);
- avl = gpr_avl_add(avl, box(873), box(186), NULL);
- avl = remove_int(avl, 589);
- avl = gpr_avl_add(avl, box(676), box(188), NULL);
- avl = gpr_avl_add(avl, box(790), box(189), NULL);
- avl = remove_int(avl, 521);
- avl = remove_int(avl, 47);
- avl = gpr_avl_add(avl, box(976), box(192), NULL);
- avl = gpr_avl_add(avl, box(683), box(193), NULL);
- avl = remove_int(avl, 803);
- avl = remove_int(avl, 1006);
- avl = gpr_avl_add(avl, box(775), box(196), NULL);
- avl = gpr_avl_add(avl, box(411), box(197), NULL);
- avl = gpr_avl_add(avl, box(697), box(198), NULL);
- avl = remove_int(avl, 50);
- avl = gpr_avl_add(avl, box(213), box(200), NULL);
- avl = remove_int(avl, 714);
- avl = gpr_avl_add(avl, box(981), box(202), NULL);
- avl = gpr_avl_add(avl, box(502), box(203), NULL);
- avl = gpr_avl_add(avl, box(697), box(204), NULL);
- avl = gpr_avl_add(avl, box(603), box(205), NULL);
- avl = gpr_avl_add(avl, box(117), box(206), NULL);
- avl = remove_int(avl, 363);
- avl = gpr_avl_add(avl, box(104), box(208), NULL);
- avl = remove_int(avl, 842);
- avl = gpr_avl_add(avl, box(48), box(210), NULL);
- avl = remove_int(avl, 764);
- avl = gpr_avl_add(avl, box(482), box(212), NULL);
- avl = gpr_avl_add(avl, box(928), box(213), NULL);
- avl = gpr_avl_add(avl, box(30), box(214), NULL);
- avl = gpr_avl_add(avl, box(820), box(215), NULL);
- avl = gpr_avl_add(avl, box(334), box(216), NULL);
- avl = remove_int(avl, 306);
- avl = gpr_avl_add(avl, box(789), box(218), NULL);
- avl = remove_int(avl, 924);
- avl = gpr_avl_add(avl, box(53), box(220), NULL);
- avl = remove_int(avl, 657);
- avl = gpr_avl_add(avl, box(130), box(222), NULL);
- avl = gpr_avl_add(avl, box(239), box(223), NULL);
- avl = remove_int(avl, 20);
- avl = gpr_avl_add(avl, box(117), box(225), NULL);
- avl = remove_int(avl, 882);
- avl = remove_int(avl, 891);
- avl = gpr_avl_add(avl, box(9), box(228), NULL);
- avl = gpr_avl_add(avl, box(496), box(229), NULL);
- avl = gpr_avl_add(avl, box(750), box(230), NULL);
- avl = gpr_avl_add(avl, box(283), box(231), NULL);
- avl = gpr_avl_add(avl, box(802), box(232), NULL);
- avl = remove_int(avl, 352);
- avl = gpr_avl_add(avl, box(374), box(234), NULL);
- avl = gpr_avl_add(avl, box(6), box(235), NULL);
- avl = gpr_avl_add(avl, box(756), box(236), NULL);
- avl = gpr_avl_add(avl, box(597), box(237), NULL);
- avl = gpr_avl_add(avl, box(661), box(238), NULL);
- avl = remove_int(avl, 96);
- avl = gpr_avl_add(avl, box(894), box(240), NULL);
- avl = remove_int(avl, 749);
- avl = gpr_avl_add(avl, box(71), box(242), NULL);
- avl = remove_int(avl, 68);
- avl = gpr_avl_add(avl, box(388), box(244), NULL);
- avl = remove_int(avl, 119);
- avl = remove_int(avl, 856);
- avl = gpr_avl_add(avl, box(176), box(247), NULL);
- avl = gpr_avl_add(avl, box(993), box(248), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(484), box(258), NULL);
- avl = remove_int(avl, 837);
- avl = gpr_avl_add(avl, box(388), box(260), NULL);
- avl = remove_int(avl, 987);
- avl = gpr_avl_add(avl, box(336), box(262), NULL);
- avl = remove_int(avl, 855);
- avl = gpr_avl_add(avl, box(668), box(264), NULL);
- avl = remove_int(avl, 648);
- avl = gpr_avl_add(avl, box(193), box(266), NULL);
- avl = remove_int(avl, 939);
- avl = gpr_avl_add(avl, box(740), box(268), NULL);
- avl = gpr_avl_add(avl, box(503), box(269), NULL);
- avl = gpr_avl_add(avl, box(765), box(270), NULL);
- avl = remove_int(avl, 924);
- avl = remove_int(avl, 513);
- avl = gpr_avl_add(avl, box(161), box(273), NULL);
- avl = gpr_avl_add(avl, box(502), box(274), NULL);
- avl = gpr_avl_add(avl, box(846), box(275), NULL);
- avl = remove_int(avl, 931);
- avl = gpr_avl_add(avl, box(87), box(277), NULL);
- avl = gpr_avl_add(avl, box(949), box(278), NULL);
- avl = gpr_avl_add(avl, box(548), box(279), NULL);
- avl = gpr_avl_add(avl, box(951), box(280), NULL);
- avl = remove_int(avl, 1018);
- avl = remove_int(avl, 568);
- avl = gpr_avl_add(avl, box(138), box(283), NULL);
- avl = gpr_avl_add(avl, box(202), box(284), NULL);
- avl = gpr_avl_add(avl, box(157), box(285), NULL);
- avl = gpr_avl_add(avl, box(264), box(286), NULL);
- avl = gpr_avl_add(avl, box(370), box(287), NULL);
- 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), NULL);
- avl = remove_int(avl, 354);
- avl = gpr_avl_add(avl, box(134), box(297), NULL);
- avl = remove_int(avl, 781);
- avl = remove_int(avl, 183);
- avl = gpr_avl_add(avl, box(914), box(300), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(699), box(307), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(265), box(315), NULL);
- avl = gpr_avl_add(avl, box(268), box(316), NULL);
- avl = gpr_avl_add(avl, box(103), box(317), NULL);
- avl = gpr_avl_add(avl, box(440), box(318), NULL);
- avl = remove_int(avl, 777);
- avl = gpr_avl_add(avl, box(670), box(320), NULL);
- avl = remove_int(avl, 506);
- avl = remove_int(avl, 487);
- avl = gpr_avl_add(avl, box(421), box(323), NULL);
- avl = remove_int(avl, 514);
- avl = gpr_avl_add(avl, box(701), box(325), NULL);
- avl = remove_int(avl, 949);
- avl = remove_int(avl, 872);
- avl = remove_int(avl, 139);
- avl = gpr_avl_add(avl, box(781), box(329), NULL);
- avl = gpr_avl_add(avl, box(543), box(330), NULL);
- avl = gpr_avl_add(avl, box(147), box(331), NULL);
- avl = remove_int(avl, 190);
- avl = gpr_avl_add(avl, box(453), box(333), NULL);
- 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), NULL);
- avl = remove_int(avl, 812);
- avl = gpr_avl_add(avl, box(431), box(340), NULL);
- avl = gpr_avl_add(avl, box(8), box(341), NULL);
- avl = remove_int(avl, 843);
- avl = gpr_avl_add(avl, box(831), box(343), NULL);
- avl = remove_int(avl, 472);
- avl = remove_int(avl, 157);
- avl = gpr_avl_add(avl, box(612), box(346), NULL);
- avl = gpr_avl_add(avl, box(802), box(347), NULL);
- avl = remove_int(avl, 554);
- avl = gpr_avl_add(avl, box(409), box(349), NULL);
- avl = gpr_avl_add(avl, box(439), box(350), NULL);
- avl = gpr_avl_add(avl, box(725), box(351), NULL);
- avl = gpr_avl_add(avl, box(568), box(352), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(950), box(358), NULL);
- avl = gpr_avl_add(avl, box(532), box(359), NULL);
- avl = gpr_avl_add(avl, box(832), box(360), NULL);
- avl = remove_int(avl, 390);
- avl = gpr_avl_add(avl, box(993), box(362), NULL);
- avl = remove_int(avl, 198);
- avl = remove_int(avl, 401);
- avl = gpr_avl_add(avl, box(316), box(365), NULL);
- avl = remove_int(avl, 843);
- avl = gpr_avl_add(avl, box(541), box(367), NULL);
- avl = gpr_avl_add(avl, box(505), box(368), NULL);
- avl = remove_int(avl, 445);
- avl = remove_int(avl, 256);
- avl = gpr_avl_add(avl, box(232), box(371), NULL);
- avl = remove_int(avl, 577);
- avl = remove_int(avl, 558);
- avl = gpr_avl_add(avl, box(910), box(374), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(655), box(381), NULL);
- avl = remove_int(avl, 557);
- avl = remove_int(avl, 102);
- avl = remove_int(avl, 165);
- avl = gpr_avl_add(avl, box(191), box(385), NULL);
- avl = remove_int(avl, 30);
- avl = gpr_avl_add(avl, box(406), box(387), NULL);
- avl = gpr_avl_add(avl, box(66), box(388), NULL);
- avl = gpr_avl_add(avl, box(87), box(389), NULL);
- avl = remove_int(avl, 7);
- avl = remove_int(avl, 671);
- avl = gpr_avl_add(avl, box(234), box(392), NULL);
- avl = remove_int(avl, 463);
- avl = gpr_avl_add(avl, box(75), box(394), NULL);
- avl = gpr_avl_add(avl, box(487), box(395), NULL);
- avl = remove_int(avl, 203);
- avl = gpr_avl_add(avl, box(711), box(397), NULL);
- avl = remove_int(avl, 291);
- avl = remove_int(avl, 798);
- avl = remove_int(avl, 337);
- avl = gpr_avl_add(avl, box(877), box(401), NULL);
- avl = gpr_avl_add(avl, box(388), box(402), NULL);
- avl = remove_int(avl, 975);
- avl = gpr_avl_add(avl, box(200), box(404), NULL);
- avl = gpr_avl_add(avl, box(408), box(405), NULL);
- avl = gpr_avl_add(avl, box(3), box(406), NULL);
- avl = gpr_avl_add(avl, box(971), box(407), NULL);
- 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), NULL);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 364);
- avl = gpr_avl_add(avl, box(215), box(415), NULL);
- avl = remove_int(avl, 778);
- avl = remove_int(avl, 45);
- avl = gpr_avl_add(avl, box(328), box(418), NULL);
- avl = gpr_avl_add(avl, box(597), box(419), NULL);
- avl = remove_int(avl, 34);
- avl = gpr_avl_add(avl, box(736), box(421), NULL);
- avl = remove_int(avl, 37);
- avl = gpr_avl_add(avl, box(275), box(423), NULL);
- avl = gpr_avl_add(avl, box(70), box(424), NULL);
- avl = gpr_avl_add(avl, box(771), box(425), NULL);
- avl = remove_int(avl, 536);
- avl = remove_int(avl, 421);
- avl = gpr_avl_add(avl, box(186), box(428), NULL);
- avl = gpr_avl_add(avl, box(788), box(429), NULL);
- avl = gpr_avl_add(avl, box(224), box(430), NULL);
- avl = remove_int(avl, 228);
- avl = gpr_avl_add(avl, box(48), box(432), NULL);
- avl = gpr_avl_add(avl, box(120), box(433), NULL);
- avl = gpr_avl_add(avl, box(269), box(434), NULL);
- avl = gpr_avl_add(avl, box(904), box(435), NULL);
- avl = remove_int(avl, 699);
- avl = gpr_avl_add(avl, box(340), box(437), NULL);
- avl = remove_int(avl, 276);
- avl = gpr_avl_add(avl, box(591), box(439), NULL);
- avl = gpr_avl_add(avl, box(778), box(440), NULL);
- avl = remove_int(avl, 490);
- avl = remove_int(avl, 973);
- avl = gpr_avl_add(avl, box(294), box(443), NULL);
- avl = gpr_avl_add(avl, box(323), box(444), NULL);
- avl = remove_int(avl, 685);
- avl = gpr_avl_add(avl, box(38), box(446), NULL);
- avl = gpr_avl_add(avl, box(525), box(447), NULL);
- avl = remove_int(avl, 162);
- avl = gpr_avl_add(avl, box(462), box(449), NULL);
- avl = gpr_avl_add(avl, box(340), box(450), NULL);
- avl = remove_int(avl, 734);
- avl = remove_int(avl, 959);
- avl = gpr_avl_add(avl, box(752), box(453), NULL);
- avl = gpr_avl_add(avl, box(667), box(454), NULL);
- avl = remove_int(avl, 558);
- avl = remove_int(avl, 657);
- avl = gpr_avl_add(avl, box(711), box(457), NULL);
- avl = remove_int(avl, 937);
- avl = gpr_avl_add(avl, box(741), box(459), NULL);
- avl = gpr_avl_add(avl, box(40), box(460), NULL);
- avl = remove_int(avl, 784);
- avl = gpr_avl_add(avl, box(292), box(462), NULL);
- avl = remove_int(avl, 164);
- avl = remove_int(avl, 931);
- avl = remove_int(avl, 886);
- avl = gpr_avl_add(avl, box(968), box(466), NULL);
- avl = remove_int(avl, 263);
- avl = gpr_avl_add(avl, box(647), box(468), NULL);
- avl = gpr_avl_add(avl, box(92), box(469), NULL);
- avl = remove_int(avl, 310);
- avl = gpr_avl_add(avl, box(711), box(471), NULL);
- avl = gpr_avl_add(avl, box(675), box(472), NULL);
- avl = remove_int(avl, 549);
- avl = gpr_avl_add(avl, box(380), box(474), NULL);
- avl = remove_int(avl, 825);
- avl = gpr_avl_add(avl, box(668), box(476), NULL);
- avl = remove_int(avl, 498);
- avl = gpr_avl_add(avl, box(870), box(478), NULL);
- avl = gpr_avl_add(avl, box(391), box(479), NULL);
- avl = gpr_avl_add(avl, box(264), box(480), NULL);
- 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), NULL);
- avl = remove_int(avl, 849);
- avl = remove_int(avl, 47);
- avl = gpr_avl_add(avl, box(299), box(490), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(524), box(496), NULL);
- avl = remove_int(avl, 210);
- avl = remove_int(avl, 299);
- avl = gpr_avl_add(avl, box(823), box(499), NULL);
- avl = remove_int(avl, 479);
- avl = remove_int(avl, 96);
- avl = remove_int(avl, 1013);
- avl = gpr_avl_add(avl, box(768), box(503), NULL);
- avl = remove_int(avl, 638);
- avl = remove_int(avl, 20);
- avl = gpr_avl_add(avl, box(663), box(506), NULL);
- avl = remove_int(avl, 882);
- avl = gpr_avl_add(avl, box(745), box(508), NULL);
- avl = remove_int(avl, 352);
- avl = gpr_avl_add(avl, box(10), box(510), NULL);
- avl = remove_int(avl, 484);
- avl = gpr_avl_add(avl, box(420), box(512), NULL);
- avl = gpr_avl_add(avl, box(884), box(513), NULL);
- avl = gpr_avl_add(avl, box(993), box(514), NULL);
- avl = gpr_avl_add(avl, box(251), box(515), NULL);
- avl = remove_int(avl, 222);
- avl = gpr_avl_add(avl, box(734), box(517), NULL);
- avl = gpr_avl_add(avl, box(952), box(518), NULL);
- 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), NULL);
- avl = remove_int(avl, 897);
- avl = gpr_avl_add(avl, box(719), box(526), NULL);
- avl = gpr_avl_add(avl, box(622), box(527), NULL);
- avl = remove_int(avl, 28);
- avl = remove_int(avl, 836);
- avl = remove_int(avl, 142);
- avl = gpr_avl_add(avl, box(445), box(531), NULL);
- avl = gpr_avl_add(avl, box(410), box(532), NULL);
- avl = remove_int(avl, 575);
- avl = gpr_avl_add(avl, box(634), box(534), NULL);
- avl = gpr_avl_add(avl, box(906), box(535), NULL);
- avl = remove_int(avl, 649);
- avl = gpr_avl_add(avl, box(813), box(537), NULL);
- avl = remove_int(avl, 702);
- avl = remove_int(avl, 732);
- avl = gpr_avl_add(avl, box(105), box(540), NULL);
- avl = gpr_avl_add(avl, box(867), box(541), NULL);
- avl = remove_int(avl, 964);
- avl = remove_int(avl, 941);
- avl = gpr_avl_add(avl, box(947), box(544), NULL);
- avl = remove_int(avl, 990);
- avl = gpr_avl_add(avl, box(816), box(546), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(786), box(552), NULL);
- avl = gpr_avl_add(avl, box(526), box(553), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(749), box(559), NULL);
- avl = gpr_avl_add(avl, box(194), box(560), NULL);
- avl = remove_int(avl, 517);
- avl = gpr_avl_add(avl, box(102), box(562), NULL);
- avl = remove_int(avl, 189);
- avl = gpr_avl_add(avl, box(927), box(564), NULL);
- avl = remove_int(avl, 846);
- avl = remove_int(avl, 130);
- avl = gpr_avl_add(avl, box(694), box(567), NULL);
- avl = remove_int(avl, 750);
- avl = gpr_avl_add(avl, box(357), box(569), NULL);
- avl = remove_int(avl, 431);
- avl = remove_int(avl, 91);
- avl = gpr_avl_add(avl, box(640), box(572), NULL);
- avl = remove_int(avl, 4);
- avl = gpr_avl_add(avl, box(81), box(574), NULL);
- avl = gpr_avl_add(avl, box(595), box(575), NULL);
- avl = remove_int(avl, 444);
- avl = remove_int(avl, 262);
- avl = remove_int(avl, 11);
- avl = gpr_avl_add(avl, box(192), box(579), NULL);
- avl = gpr_avl_add(avl, box(158), box(580), NULL);
- avl = remove_int(avl, 401);
- avl = remove_int(avl, 918);
- avl = gpr_avl_add(avl, box(180), box(583), NULL);
- avl = remove_int(avl, 268);
- avl = gpr_avl_add(avl, box(1012), box(585), NULL);
- avl = gpr_avl_add(avl, box(90), box(586), NULL);
- avl = gpr_avl_add(avl, box(946), box(587), NULL);
- avl = remove_int(avl, 719);
- avl = gpr_avl_add(avl, box(874), box(589), NULL);
- avl = gpr_avl_add(avl, box(679), box(590), NULL);
- avl = remove_int(avl, 53);
- avl = remove_int(avl, 534);
- avl = gpr_avl_add(avl, box(646), box(593), NULL);
- avl = gpr_avl_add(avl, box(767), box(594), NULL);
- avl = gpr_avl_add(avl, box(460), box(595), NULL);
- avl = gpr_avl_add(avl, box(852), box(596), NULL);
- avl = gpr_avl_add(avl, box(189), box(597), NULL);
- avl = remove_int(avl, 932);
- avl = remove_int(avl, 366);
- avl = remove_int(avl, 907);
- avl = gpr_avl_add(avl, box(875), box(601), NULL);
- avl = gpr_avl_add(avl, box(434), box(602), NULL);
- avl = gpr_avl_add(avl, box(704), box(603), NULL);
- avl = gpr_avl_add(avl, box(724), box(604), NULL);
- avl = gpr_avl_add(avl, box(930), box(605), NULL);
- avl = gpr_avl_add(avl, box(1000), box(606), NULL);
- avl = remove_int(avl, 479);
- avl = gpr_avl_add(avl, box(275), box(608), NULL);
- avl = remove_int(avl, 32);
- avl = gpr_avl_add(avl, box(939), box(610), NULL);
- avl = remove_int(avl, 943);
- avl = remove_int(avl, 329);
- avl = gpr_avl_add(avl, box(490), box(613), NULL);
- 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), NULL);
- avl = remove_int(avl, 751);
- avl = gpr_avl_add(avl, box(568), box(620), NULL);
- avl = gpr_avl_add(avl, box(120), box(621), NULL);
- avl = gpr_avl_add(avl, box(617), box(622), NULL);
- avl = gpr_avl_add(avl, box(32), box(623), NULL);
- avl = remove_int(avl, 701);
- avl = gpr_avl_add(avl, box(910), box(625), NULL);
- 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), NULL);
- 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), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(6), box(642), NULL);
- avl = gpr_avl_add(avl, box(680), box(643), NULL);
- avl = remove_int(avl, 741);
- avl = remove_int(avl, 309);
- avl = remove_int(avl, 272);
- avl = gpr_avl_add(avl, box(249), box(647), NULL);
- avl = remove_int(avl, 97);
- avl = remove_int(avl, 850);
- avl = gpr_avl_add(avl, box(915), box(650), NULL);
- avl = gpr_avl_add(avl, box(816), box(651), NULL);
- avl = gpr_avl_add(avl, box(45), box(652), NULL);
- avl = gpr_avl_add(avl, box(168), box(653), NULL);
- avl = remove_int(avl, 153);
- avl = remove_int(avl, 239);
- avl = gpr_avl_add(avl, box(684), box(656), NULL);
- avl = gpr_avl_add(avl, box(208), box(657), NULL);
- avl = gpr_avl_add(avl, box(681), box(658), NULL);
- avl = gpr_avl_add(avl, box(609), box(659), NULL);
- avl = gpr_avl_add(avl, box(645), box(660), NULL);
- avl = remove_int(avl, 799);
- avl = gpr_avl_add(avl, box(955), box(662), NULL);
- avl = gpr_avl_add(avl, box(946), box(663), NULL);
- avl = gpr_avl_add(avl, box(744), box(664), NULL);
- avl = gpr_avl_add(avl, box(201), box(665), NULL);
- avl = gpr_avl_add(avl, box(136), box(666), NULL);
- avl = remove_int(avl, 357);
- avl = gpr_avl_add(avl, box(974), box(668), NULL);
- avl = remove_int(avl, 485);
- avl = gpr_avl_add(avl, box(1009), box(670), NULL);
- avl = gpr_avl_add(avl, box(517), box(671), NULL);
- avl = remove_int(avl, 491);
- avl = gpr_avl_add(avl, box(336), box(673), NULL);
- avl = gpr_avl_add(avl, box(589), box(674), NULL);
- 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), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(25), box(685), NULL);
- avl = remove_int(avl, 278);
- avl = gpr_avl_add(avl, box(191), box(687), NULL);
- avl = remove_int(avl, 243);
- avl = remove_int(avl, 918);
- avl = remove_int(avl, 449);
- avl = gpr_avl_add(avl, box(19), box(691), NULL);
- avl = gpr_avl_add(avl, box(762), box(692), NULL);
- avl = gpr_avl_add(avl, box(13), box(693), NULL);
- avl = gpr_avl_add(avl, box(151), box(694), NULL);
- avl = gpr_avl_add(avl, box(152), box(695), NULL);
- avl = gpr_avl_add(avl, box(793), box(696), NULL);
- avl = remove_int(avl, 862);
- avl = remove_int(avl, 890);
- avl = gpr_avl_add(avl, box(687), box(699), NULL);
- avl = gpr_avl_add(avl, box(509), box(700), NULL);
- avl = gpr_avl_add(avl, box(973), box(701), NULL);
- avl = remove_int(avl, 230);
- avl = gpr_avl_add(avl, box(532), box(703), NULL);
- avl = remove_int(avl, 668);
- avl = gpr_avl_add(avl, box(281), box(705), NULL);
- avl = gpr_avl_add(avl, box(867), box(706), NULL);
- avl = gpr_avl_add(avl, box(359), box(707), NULL);
- avl = remove_int(avl, 425);
- avl = gpr_avl_add(avl, box(691), box(709), NULL);
- avl = gpr_avl_add(avl, box(163), box(710), NULL);
- avl = gpr_avl_add(avl, box(502), box(711), NULL);
- avl = remove_int(avl, 674);
- avl = gpr_avl_add(avl, box(697), box(713), NULL);
- avl = remove_int(avl, 271);
- avl = gpr_avl_add(avl, box(968), box(715), NULL);
- avl = gpr_avl_add(avl, box(48), box(716), NULL);
- avl = remove_int(avl, 543);
- avl = gpr_avl_add(avl, box(35), box(718), NULL);
- avl = gpr_avl_add(avl, box(751), box(719), NULL);
- avl = gpr_avl_add(avl, box(478), box(720), NULL);
- avl = remove_int(avl, 797);
- avl = remove_int(avl, 309);
- avl = gpr_avl_add(avl, box(927), box(723), NULL);
- avl = remove_int(avl, 504);
- avl = gpr_avl_add(avl, box(286), box(725), NULL);
- avl = gpr_avl_add(avl, box(413), box(726), NULL);
- avl = gpr_avl_add(avl, box(599), box(727), NULL);
- avl = remove_int(avl, 105);
- avl = remove_int(avl, 605);
- avl = gpr_avl_add(avl, box(632), box(730), NULL);
- avl = gpr_avl_add(avl, box(133), box(731), NULL);
- avl = remove_int(avl, 443);
- avl = gpr_avl_add(avl, box(958), box(733), NULL);
- avl = gpr_avl_add(avl, box(729), box(734), NULL);
- avl = remove_int(avl, 158);
- avl = gpr_avl_add(avl, box(694), box(736), NULL);
- avl = gpr_avl_add(avl, box(505), box(737), NULL);
- avl = remove_int(avl, 63);
- avl = remove_int(avl, 714);
- avl = gpr_avl_add(avl, box(1002), box(740), NULL);
- avl = remove_int(avl, 211);
- avl = gpr_avl_add(avl, box(765), box(742), NULL);
- avl = gpr_avl_add(avl, box(455), box(743), NULL);
- avl = remove_int(avl, 59);
- avl = remove_int(avl, 224);
- avl = gpr_avl_add(avl, box(586), box(746), NULL);
- avl = gpr_avl_add(avl, box(348), box(747), NULL);
- avl = remove_int(avl, 10);
- avl = remove_int(avl, 484);
- avl = gpr_avl_add(avl, box(968), box(750), NULL);
- avl = gpr_avl_add(avl, box(923), box(751), NULL);
- avl = remove_int(avl, 573);
- avl = remove_int(avl, 617);
- avl = gpr_avl_add(avl, box(812), box(754), NULL);
- avl = gpr_avl_add(avl, box(179), box(755), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(927), box(761), NULL);
- avl = gpr_avl_add(avl, box(454), box(762), NULL);
- avl = gpr_avl_add(avl, box(217), box(763), NULL);
- avl = remove_int(avl, 534);
- avl = gpr_avl_add(avl, box(180), box(765), NULL);
- avl = gpr_avl_add(avl, box(319), box(766), NULL);
- avl = remove_int(avl, 92);
- avl = gpr_avl_add(avl, box(483), box(768), NULL);
- 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), NULL);
- avl = remove_int(avl, 807);
- avl = gpr_avl_add(avl, box(463), box(775), NULL);
- avl = gpr_avl_add(avl, box(271), box(776), NULL);
- avl = gpr_avl_add(avl, box(644), box(777), NULL);
- avl = remove_int(avl, 618);
- avl = gpr_avl_add(avl, box(166), box(779), NULL);
- avl = gpr_avl_add(avl, box(538), box(780), NULL);
- avl = remove_int(avl, 606);
- avl = gpr_avl_add(avl, box(425), box(782), NULL);
- avl = remove_int(avl, 725);
- avl = remove_int(avl, 383);
- avl = gpr_avl_add(avl, box(155), box(785), NULL);
- avl = remove_int(avl, 889);
- avl = gpr_avl_add(avl, box(653), box(787), NULL);
- avl = remove_int(avl, 386);
- avl = gpr_avl_add(avl, box(142), box(789), NULL);
- avl = remove_int(avl, 107);
- avl = remove_int(avl, 603);
- avl = remove_int(avl, 971);
- avl = gpr_avl_add(avl, box(80), box(793), NULL);
- avl = gpr_avl_add(avl, box(61), box(794), NULL);
- avl = gpr_avl_add(avl, box(693), box(795), NULL);
- avl = gpr_avl_add(avl, box(592), box(796), NULL);
- avl = gpr_avl_add(avl, box(433), box(797), NULL);
- avl = gpr_avl_add(avl, box(973), box(798), NULL);
- avl = remove_int(avl, 901);
- avl = remove_int(avl, 340);
- avl = remove_int(avl, 709);
- avl = gpr_avl_add(avl, box(224), box(802), NULL);
- avl = remove_int(avl, 120);
- avl = remove_int(avl, 271);
- avl = gpr_avl_add(avl, box(780), box(805), NULL);
- avl = gpr_avl_add(avl, box(867), box(806), NULL);
- avl = gpr_avl_add(avl, box(756), box(807), NULL);
- avl = gpr_avl_add(avl, box(583), box(808), NULL);
- avl = gpr_avl_add(avl, box(356), box(809), NULL);
- avl = gpr_avl_add(avl, box(58), box(810), NULL);
- avl = remove_int(avl, 219);
- avl = gpr_avl_add(avl, box(301), box(812), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(479), box(822), NULL);
- avl = gpr_avl_add(avl, box(323), box(823), NULL);
- avl = gpr_avl_add(avl, box(802), box(824), NULL);
- avl = remove_int(avl, 682);
- avl = remove_int(avl, 705);
- avl = remove_int(avl, 487);
- avl = gpr_avl_add(avl, box(530), box(828), NULL);
- avl = gpr_avl_add(avl, box(232), box(829), NULL);
- avl = remove_int(avl, 627);
- avl = gpr_avl_add(avl, box(396), box(831), NULL);
- avl = gpr_avl_add(avl, box(61), box(832), NULL);
- avl = gpr_avl_add(avl, box(932), box(833), NULL);
- avl = gpr_avl_add(avl, box(108), box(834), NULL);
- avl = gpr_avl_add(avl, box(524), box(835), NULL);
- avl = remove_int(avl, 390);
- avl = remove_int(avl, 307);
- avl = gpr_avl_add(avl, box(722), box(838), NULL);
- avl = gpr_avl_add(avl, box(907), box(839), NULL);
- avl = remove_int(avl, 286);
- avl = remove_int(avl, 337);
- avl = remove_int(avl, 443);
- avl = gpr_avl_add(avl, box(973), box(843), NULL);
- avl = remove_int(avl, 930);
- avl = remove_int(avl, 242);
- avl = gpr_avl_add(avl, box(997), box(846), NULL);
- avl = gpr_avl_add(avl, box(689), box(847), NULL);
- avl = remove_int(avl, 318);
- avl = gpr_avl_add(avl, box(703), box(849), NULL);
- avl = gpr_avl_add(avl, box(868), box(850), NULL);
- avl = gpr_avl_add(avl, box(200), box(851), NULL);
- avl = gpr_avl_add(avl, box(960), box(852), NULL);
- avl = gpr_avl_add(avl, box(80), box(853), NULL);
- avl = remove_int(avl, 113);
- avl = gpr_avl_add(avl, box(135), box(855), NULL);
- avl = remove_int(avl, 529);
- avl = gpr_avl_add(avl, box(366), box(857), NULL);
- avl = remove_int(avl, 272);
- avl = gpr_avl_add(avl, box(921), box(859), NULL);
- avl = remove_int(avl, 497);
- avl = gpr_avl_add(avl, box(712), box(861), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(29), box(867), NULL);
- avl = gpr_avl_add(avl, box(180), box(868), NULL);
- avl = gpr_avl_add(avl, box(983), box(869), NULL);
- avl = gpr_avl_add(avl, box(72), box(870), NULL);
- avl = gpr_avl_add(avl, box(693), box(871), NULL);
- avl = gpr_avl_add(avl, box(567), box(872), NULL);
- avl = remove_int(avl, 549);
- avl = remove_int(avl, 351);
- avl = gpr_avl_add(avl, box(1019), box(875), NULL);
- avl = remove_int(avl, 585);
- avl = remove_int(avl, 294);
- avl = remove_int(avl, 61);
- avl = gpr_avl_add(avl, box(409), box(879), NULL);
- avl = gpr_avl_add(avl, box(984), box(880), NULL);
- avl = gpr_avl_add(avl, box(830), box(881), NULL);
- avl = remove_int(avl, 579);
- avl = gpr_avl_add(avl, box(672), box(883), NULL);
- avl = remove_int(avl, 968);
-
- gpr_avl_unref(avl, NULL);
-}
-
-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), NULL);
- avl = gpr_avl_add(avl, box(494), box(3), NULL);
- avl = gpr_avl_add(avl, box(226), box(4), NULL);
- avl = remove_int(avl, 524);
- avl = gpr_avl_add(avl, box(540), box(6), NULL);
- avl = remove_int(avl, 1008);
- avl = gpr_avl_add(avl, box(502), box(8), NULL);
- avl = remove_int(avl, 267);
- avl = remove_int(avl, 764);
- avl = remove_int(avl, 443);
- avl = gpr_avl_add(avl, box(8), box(12), NULL);
- avl = remove_int(avl, 291);
- avl = remove_int(avl, 796);
- avl = remove_int(avl, 1002);
- avl = gpr_avl_add(avl, box(778), box(16), NULL);
- avl = remove_int(avl, 621);
- avl = remove_int(avl, 891);
- avl = remove_int(avl, 880);
- avl = gpr_avl_add(avl, box(197), box(20), NULL);
- avl = gpr_avl_add(avl, box(441), box(21), NULL);
- avl = gpr_avl_add(avl, box(719), box(22), NULL);
- avl = remove_int(avl, 109);
- avl = gpr_avl_add(avl, box(458), box(24), NULL);
- avl = remove_int(avl, 86);
- avl = gpr_avl_add(avl, box(897), box(26), NULL);
- avl = gpr_avl_add(avl, box(997), box(27), NULL);
- avl = remove_int(avl, 235);
- avl = remove_int(avl, 425);
- avl = remove_int(avl, 186);
- avl = gpr_avl_add(avl, box(887), box(31), NULL);
- avl = gpr_avl_add(avl, box(1005), box(32), NULL);
- avl = gpr_avl_add(avl, box(778), box(33), NULL);
- avl = gpr_avl_add(avl, box(575), box(34), NULL);
- avl = remove_int(avl, 966);
- avl = remove_int(avl, 1015);
- avl = gpr_avl_add(avl, box(486), box(37), NULL);
- avl = gpr_avl_add(avl, box(809), box(38), NULL);
- avl = gpr_avl_add(avl, box(907), box(39), NULL);
- avl = gpr_avl_add(avl, box(971), box(40), NULL);
- avl = remove_int(avl, 441);
- avl = remove_int(avl, 498);
- avl = gpr_avl_add(avl, box(727), box(43), NULL);
- avl = remove_int(avl, 679);
- avl = remove_int(avl, 740);
- avl = remove_int(avl, 532);
- avl = gpr_avl_add(avl, box(805), box(47), NULL);
- avl = remove_int(avl, 64);
- avl = gpr_avl_add(avl, box(362), box(49), NULL);
- avl = gpr_avl_add(avl, box(170), box(50), NULL);
- avl = gpr_avl_add(avl, box(389), box(51), NULL);
- avl = gpr_avl_add(avl, box(689), box(52), NULL);
- avl = remove_int(avl, 871);
- avl = gpr_avl_add(avl, box(447), box(54), NULL);
- avl = remove_int(avl, 718);
- avl = gpr_avl_add(avl, box(724), box(56), NULL);
- avl = remove_int(avl, 215);
- avl = gpr_avl_add(avl, box(550), box(58), NULL);
- avl = remove_int(avl, 932);
- avl = gpr_avl_add(avl, box(47), box(60), NULL);
- avl = remove_int(avl, 46);
- avl = remove_int(avl, 229);
- avl = gpr_avl_add(avl, box(68), box(63), NULL);
- avl = gpr_avl_add(avl, box(387), box(64), NULL);
- avl = remove_int(avl, 933);
- avl = remove_int(avl, 736);
- avl = remove_int(avl, 719);
- avl = gpr_avl_add(avl, box(150), box(68), NULL);
- avl = remove_int(avl, 875);
- avl = remove_int(avl, 298);
- avl = gpr_avl_add(avl, box(991), box(71), NULL);
- avl = remove_int(avl, 705);
- avl = gpr_avl_add(avl, box(197), box(73), NULL);
- avl = gpr_avl_add(avl, box(101), box(74), NULL);
- avl = remove_int(avl, 436);
- avl = gpr_avl_add(avl, box(755), box(76), NULL);
- avl = gpr_avl_add(avl, box(727), box(77), NULL);
- avl = remove_int(avl, 309);
- avl = remove_int(avl, 253);
- avl = gpr_avl_add(avl, box(203), box(80), NULL);
- avl = remove_int(avl, 231);
- avl = gpr_avl_add(avl, box(461), box(82), NULL);
- avl = remove_int(avl, 316);
- avl = remove_int(avl, 493);
- avl = gpr_avl_add(avl, box(184), box(85), NULL);
- avl = remove_int(avl, 737);
- avl = gpr_avl_add(avl, box(790), box(87), NULL);
- avl = gpr_avl_add(avl, box(335), box(88), NULL);
- avl = remove_int(avl, 649);
- avl = gpr_avl_add(avl, box(69), box(90), NULL);
- avl = remove_int(avl, 585);
- avl = remove_int(avl, 543);
- avl = gpr_avl_add(avl, box(784), box(93), NULL);
- avl = gpr_avl_add(avl, box(60), box(94), NULL);
- avl = gpr_avl_add(avl, box(525), box(95), NULL);
- avl = gpr_avl_add(avl, box(177), box(96), NULL);
- avl = gpr_avl_add(avl, box(178), box(97), NULL);
- avl = gpr_avl_add(avl, box(683), box(98), NULL);
- avl = gpr_avl_add(avl, box(226), box(99), NULL);
- avl = gpr_avl_add(avl, box(662), box(100), NULL);
- avl = remove_int(avl, 944);
- avl = gpr_avl_add(avl, box(562), box(102), NULL);
- avl = gpr_avl_add(avl, box(793), box(103), NULL);
- avl = remove_int(avl, 673);
- avl = gpr_avl_add(avl, box(310), box(105), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(483), box(111), NULL);
- avl = gpr_avl_add(avl, box(84), box(112), NULL);
- avl = remove_int(avl, 109);
- avl = gpr_avl_add(avl, box(132), box(114), NULL);
- avl = gpr_avl_add(avl, box(920), box(115), NULL);
- avl = remove_int(avl, 746);
- avl = gpr_avl_add(avl, box(145), box(117), NULL);
- avl = gpr_avl_add(avl, box(526), box(118), NULL);
- avl = remove_int(avl, 158);
- avl = gpr_avl_add(avl, box(332), box(120), NULL);
- avl = gpr_avl_add(avl, box(918), box(121), NULL);
- avl = remove_int(avl, 339);
- avl = gpr_avl_add(avl, box(809), box(123), NULL);
- avl = gpr_avl_add(avl, box(742), box(124), NULL);
- avl = gpr_avl_add(avl, box(718), box(125), NULL);
- avl = remove_int(avl, 988);
- avl = remove_int(avl, 531);
- avl = remove_int(avl, 840);
- avl = gpr_avl_add(avl, box(816), box(129), NULL);
- avl = gpr_avl_add(avl, box(976), box(130), NULL);
- avl = remove_int(avl, 743);
- avl = remove_int(avl, 528);
- avl = remove_int(avl, 982);
- avl = gpr_avl_add(avl, box(803), box(134), NULL);
- avl = gpr_avl_add(avl, box(205), box(135), NULL);
- avl = gpr_avl_add(avl, box(584), box(136), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(333), box(143), NULL);
- avl = remove_int(avl, 439);
- avl = gpr_avl_add(avl, box(35), box(145), NULL);
- avl = gpr_avl_add(avl, box(837), box(146), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(116), box(154), NULL);
- avl = gpr_avl_add(avl, box(446), box(155), NULL);
- avl = remove_int(avl, 91);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 537);
- avl = gpr_avl_add(avl, box(448), box(159), NULL);
- avl = remove_int(avl, 155);
- avl = remove_int(avl, 344);
- avl = remove_int(avl, 237);
- avl = gpr_avl_add(avl, box(309), box(163), NULL);
- avl = gpr_avl_add(avl, box(434), box(164), NULL);
- avl = gpr_avl_add(avl, box(277), box(165), NULL);
- avl = remove_int(avl, 233);
- avl = gpr_avl_add(avl, box(275), box(167), NULL);
- avl = gpr_avl_add(avl, box(218), box(168), NULL);
- avl = gpr_avl_add(avl, box(76), box(169), NULL);
- avl = gpr_avl_add(avl, box(898), box(170), NULL);
- avl = remove_int(avl, 771);
- avl = gpr_avl_add(avl, box(237), box(172), NULL);
- avl = remove_int(avl, 327);
- avl = gpr_avl_add(avl, box(499), box(174), NULL);
- 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), NULL);
- avl = remove_int(avl, 389);
- avl = gpr_avl_add(avl, box(708), box(183), NULL);
- avl = gpr_avl_add(avl, box(594), box(184), NULL);
- avl = gpr_avl_add(avl, box(942), box(185), NULL);
- avl = gpr_avl_add(avl, box(282), box(186), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(161), box(197), NULL);
- avl = remove_int(avl, 484);
- avl = gpr_avl_add(avl, box(72), box(199), NULL);
- avl = remove_int(avl, 629);
- avl = gpr_avl_add(avl, box(522), box(201), NULL);
- avl = remove_int(avl, 679);
- avl = gpr_avl_add(avl, box(407), box(203), NULL);
- avl = remove_int(avl, 693);
- avl = gpr_avl_add(avl, box(424), box(205), NULL);
- avl = gpr_avl_add(avl, box(651), box(206), NULL);
- avl = gpr_avl_add(avl, box(927), box(207), NULL);
- avl = remove_int(avl, 553);
- avl = gpr_avl_add(avl, box(128), box(209), NULL);
- avl = gpr_avl_add(avl, box(616), box(210), NULL);
- avl = gpr_avl_add(avl, box(690), box(211), NULL);
- avl = remove_int(avl, 241);
- avl = remove_int(avl, 179);
- avl = gpr_avl_add(avl, box(697), box(214), NULL);
- avl = remove_int(avl, 779);
- avl = gpr_avl_add(avl, box(241), box(216), NULL);
- avl = remove_int(avl, 190);
- avl = remove_int(avl, 210);
- avl = gpr_avl_add(avl, box(711), box(219), NULL);
- avl = remove_int(avl, 251);
- avl = remove_int(avl, 61);
- avl = gpr_avl_add(avl, box(800), box(222), NULL);
- avl = remove_int(avl, 551);
- avl = gpr_avl_add(avl, box(61), box(224), NULL);
- avl = gpr_avl_add(avl, box(656), box(225), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(125), box(231), NULL);
- avl = remove_int(avl, 107);
- avl = gpr_avl_add(avl, box(938), box(233), NULL);
- avl = gpr_avl_add(avl, box(914), box(234), NULL);
- avl = gpr_avl_add(avl, box(197), box(235), NULL);
- avl = remove_int(avl, 736);
- avl = gpr_avl_add(avl, box(20), box(237), NULL);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 841);
- avl = gpr_avl_add(avl, box(226), box(240), NULL);
- avl = remove_int(avl, 963);
- avl = remove_int(avl, 796);
- avl = remove_int(avl, 728);
- avl = gpr_avl_add(avl, box(855), box(244), NULL);
- avl = gpr_avl_add(avl, box(769), box(245), NULL);
- avl = gpr_avl_add(avl, box(631), box(246), NULL);
- avl = remove_int(avl, 648);
- avl = gpr_avl_add(avl, box(187), box(248), NULL);
- avl = gpr_avl_add(avl, box(31), box(249), NULL);
- avl = remove_int(avl, 163);
- avl = gpr_avl_add(avl, box(218), box(251), NULL);
- avl = gpr_avl_add(avl, box(488), box(252), NULL);
- avl = gpr_avl_add(avl, box(387), box(253), NULL);
- avl = gpr_avl_add(avl, box(809), box(254), NULL);
- avl = gpr_avl_add(avl, box(997), box(255), NULL);
- avl = remove_int(avl, 678);
- avl = gpr_avl_add(avl, box(368), box(257), NULL);
- avl = gpr_avl_add(avl, box(220), box(258), NULL);
- avl = gpr_avl_add(avl, box(373), box(259), NULL);
- 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), NULL);
- avl = remove_int(avl, 254);
- avl = remove_int(avl, 456);
- avl = gpr_avl_add(avl, box(906), box(267), NULL);
- avl = remove_int(avl, 711);
- avl = gpr_avl_add(avl, box(632), box(269), NULL);
- avl = remove_int(avl, 474);
- avl = gpr_avl_add(avl, box(508), box(271), NULL);
- avl = gpr_avl_add(avl, box(518), box(272), NULL);
- avl = remove_int(avl, 579);
- avl = remove_int(avl, 948);
- avl = gpr_avl_add(avl, box(789), box(275), NULL);
- avl = gpr_avl_add(avl, box(48), box(276), NULL);
- avl = gpr_avl_add(avl, box(256), box(277), NULL);
- avl = gpr_avl_add(avl, box(754), box(278), NULL);
- avl = remove_int(avl, 215);
- avl = gpr_avl_add(avl, box(679), box(280), NULL);
- avl = gpr_avl_add(avl, box(606), box(281), NULL);
- avl = remove_int(avl, 941);
- avl = remove_int(avl, 31);
- avl = gpr_avl_add(avl, box(758), box(284), NULL);
- avl = remove_int(avl, 101);
- avl = gpr_avl_add(avl, box(244), box(286), NULL);
- avl = gpr_avl_add(avl, box(337), box(287), NULL);
- avl = gpr_avl_add(avl, box(461), box(288), NULL);
- avl = remove_int(avl, 476);
- avl = gpr_avl_add(avl, box(845), box(290), NULL);
- avl = remove_int(avl, 160);
- avl = gpr_avl_add(avl, box(690), box(292), NULL);
- avl = remove_int(avl, 931);
- avl = gpr_avl_add(avl, box(869), box(294), NULL);
- avl = gpr_avl_add(avl, box(1019), box(295), NULL);
- avl = remove_int(avl, 591);
- avl = remove_int(avl, 635);
- avl = remove_int(avl, 67);
- avl = gpr_avl_add(avl, box(113), box(299), NULL);
- avl = remove_int(avl, 305);
- avl = gpr_avl_add(avl, box(10), box(301), NULL);
- avl = remove_int(avl, 823);
- avl = remove_int(avl, 288);
- avl = remove_int(avl, 239);
- avl = gpr_avl_add(avl, box(646), box(305), NULL);
- avl = gpr_avl_add(avl, box(1006), box(306), NULL);
- avl = gpr_avl_add(avl, box(954), box(307), NULL);
- avl = gpr_avl_add(avl, box(199), box(308), NULL);
- avl = gpr_avl_add(avl, box(69), box(309), NULL);
- avl = gpr_avl_add(avl, box(984), box(310), NULL);
- avl = remove_int(avl, 568);
- avl = remove_int(avl, 666);
- avl = remove_int(avl, 37);
- avl = gpr_avl_add(avl, box(845), box(314), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(335), box(323), NULL);
- avl = gpr_avl_add(avl, box(961), box(324), NULL);
- avl = gpr_avl_add(avl, box(73), box(325), NULL);
- avl = remove_int(avl, 469);
- avl = gpr_avl_add(avl, box(449), box(327), NULL);
- avl = remove_int(avl, 821);
- avl = gpr_avl_add(avl, box(845), box(329), NULL);
- avl = remove_int(avl, 637);
- avl = gpr_avl_add(avl, box(769), box(331), NULL);
- avl = gpr_avl_add(avl, box(901), box(332), NULL);
- avl = remove_int(avl, 142);
- avl = remove_int(avl, 361);
- avl = remove_int(avl, 876);
- avl = gpr_avl_add(avl, box(614), box(336), NULL);
- avl = gpr_avl_add(avl, box(729), box(337), NULL);
- avl = remove_int(avl, 120);
- avl = remove_int(avl, 473);
- avl = remove_int(avl, 445);
- avl = gpr_avl_add(avl, box(978), box(341), NULL);
- avl = gpr_avl_add(avl, box(164), box(342), NULL);
- avl = gpr_avl_add(avl, box(1), box(343), NULL);
- avl = remove_int(avl, 890);
- avl = gpr_avl_add(avl, box(605), box(345), NULL);
- avl = gpr_avl_add(avl, box(178), box(346), NULL);
- avl = gpr_avl_add(avl, box(481), box(347), NULL);
- avl = gpr_avl_add(avl, box(772), box(348), NULL);
- avl = remove_int(avl, 824);
- avl = remove_int(avl, 167);
- avl = remove_int(avl, 151);
- avl = gpr_avl_add(avl, box(698), box(352), NULL);
- avl = gpr_avl_add(avl, box(202), box(353), NULL);
- avl = gpr_avl_add(avl, box(921), box(354), NULL);
- avl = gpr_avl_add(avl, box(875), box(355), NULL);
- avl = remove_int(avl, 197);
- avl = remove_int(avl, 232);
- avl = gpr_avl_add(avl, box(209), box(358), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(113), box(365), NULL);
- avl = remove_int(avl, 767);
- avl = gpr_avl_add(avl, box(586), box(367), NULL);
- avl = gpr_avl_add(avl, box(121), box(368), NULL);
- avl = remove_int(avl, 235);
- avl = remove_int(avl, 439);
- avl = remove_int(avl, 360);
- avl = gpr_avl_add(avl, box(916), box(372), NULL);
- avl = remove_int(avl, 999);
- avl = gpr_avl_add(avl, box(825), box(374), NULL);
- avl = gpr_avl_add(avl, box(177), box(375), NULL);
- avl = remove_int(avl, 204);
- avl = remove_int(avl, 92);
- avl = gpr_avl_add(avl, box(794), box(378), NULL);
- avl = gpr_avl_add(avl, box(463), box(379), NULL);
- avl = gpr_avl_add(avl, box(472), box(380), NULL);
- avl = remove_int(avl, 235);
- avl = gpr_avl_add(avl, box(840), box(382), NULL);
- avl = remove_int(avl, 657);
- avl = gpr_avl_add(avl, box(586), box(384), NULL);
- avl = gpr_avl_add(avl, box(979), box(385), NULL);
- avl = remove_int(avl, 979);
- avl = gpr_avl_add(avl, box(639), box(387), NULL);
- avl = remove_int(avl, 907);
- avl = remove_int(avl, 973);
- avl = gpr_avl_add(avl, box(913), box(390), NULL);
- avl = gpr_avl_add(avl, box(566), box(391), NULL);
- avl = gpr_avl_add(avl, box(883), box(392), NULL);
- avl = gpr_avl_add(avl, box(552), box(393), NULL);
- avl = gpr_avl_add(avl, box(16), box(394), NULL);
- avl = remove_int(avl, 60);
- avl = gpr_avl_add(avl, box(567), box(396), NULL);
- avl = gpr_avl_add(avl, box(705), box(397), NULL);
- avl = gpr_avl_add(avl, box(94), box(398), NULL);
- avl = remove_int(avl, 321);
- avl = gpr_avl_add(avl, box(207), box(400), NULL);
- avl = gpr_avl_add(avl, box(682), box(401), NULL);
- avl = gpr_avl_add(avl, box(592), box(402), NULL);
- avl = gpr_avl_add(avl, box(10), box(403), NULL);
- avl = remove_int(avl, 911);
- avl = remove_int(avl, 161);
- avl = gpr_avl_add(avl, box(86), box(406), NULL);
- avl = remove_int(avl, 893);
- avl = remove_int(avl, 362);
- avl = gpr_avl_add(avl, box(599), box(409), NULL);
- avl = remove_int(avl, 413);
- avl = gpr_avl_add(avl, box(867), box(411), NULL);
- avl = remove_int(avl, 955);
- avl = gpr_avl_add(avl, box(341), box(413), NULL);
- avl = gpr_avl_add(avl, box(887), box(414), NULL);
- avl = remove_int(avl, 706);
- avl = gpr_avl_add(avl, box(939), box(416), NULL);
- 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), NULL);
- avl = remove_int(avl, 848);
- avl = gpr_avl_add(avl, box(235), box(423), NULL);
- avl = remove_int(avl, 617);
- avl = gpr_avl_add(avl, box(565), box(425), NULL);
- avl = remove_int(avl, 469);
- avl = gpr_avl_add(avl, box(988), box(427), NULL);
- avl = remove_int(avl, 957);
- avl = gpr_avl_add(avl, box(426), box(429), NULL);
- avl = remove_int(avl, 967);
- avl = gpr_avl_add(avl, box(890), box(431), NULL);
- avl = gpr_avl_add(avl, box(473), box(432), NULL);
- 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), NULL);
- avl = remove_int(avl, 882);
- avl = remove_int(avl, 782);
- avl = gpr_avl_add(avl, box(408), box(442), NULL);
- avl = gpr_avl_add(avl, box(728), box(443), NULL);
- avl = remove_int(avl, 27);
- avl = gpr_avl_add(avl, box(137), box(445), NULL);
- avl = gpr_avl_add(avl, box(239), box(446), NULL);
- avl = remove_int(avl, 854);
- avl = gpr_avl_add(avl, box(104), box(448), NULL);
- avl = gpr_avl_add(avl, box(823), box(449), NULL);
- avl = gpr_avl_add(avl, box(524), box(450), NULL);
- avl = gpr_avl_add(avl, box(995), box(451), NULL);
- avl = remove_int(avl, 422);
- avl = remove_int(avl, 220);
- avl = gpr_avl_add(avl, box(856), box(454), NULL);
- avl = remove_int(avl, 332);
- avl = gpr_avl_add(avl, box(679), box(456), NULL);
- avl = remove_int(avl, 18);
- avl = gpr_avl_add(avl, box(837), box(458), NULL);
- avl = remove_int(avl, 405);
- avl = remove_int(avl, 877);
- avl = remove_int(avl, 835);
- avl = gpr_avl_add(avl, box(547), box(462), NULL);
- avl = remove_int(avl, 805);
- avl = remove_int(avl, 862);
- avl = gpr_avl_add(avl, box(75), box(465), NULL);
- avl = remove_int(avl, 41);
- avl = gpr_avl_add(avl, box(310), box(467), NULL);
- avl = remove_int(avl, 855);
- avl = gpr_avl_add(avl, box(20), box(469), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(96), box(475), NULL);
- avl = remove_int(avl, 854);
- avl = gpr_avl_add(avl, box(65), box(477), NULL);
- avl = gpr_avl_add(avl, box(573), box(478), NULL);
- avl = gpr_avl_add(avl, box(4), box(479), NULL);
- avl = gpr_avl_add(avl, box(451), box(480), NULL);
- avl = gpr_avl_add(avl, box(774), box(481), NULL);
- avl = gpr_avl_add(avl, box(126), box(482), NULL);
- avl = remove_int(avl, 956);
- avl = remove_int(avl, 591);
- avl = remove_int(avl, 644);
- avl = gpr_avl_add(avl, box(304), box(486), NULL);
- avl = remove_int(avl, 620);
- avl = remove_int(avl, 394);
- avl = gpr_avl_add(avl, box(1002), box(489), NULL);
- avl = gpr_avl_add(avl, box(837), box(490), NULL);
- avl = remove_int(avl, 485);
- avl = gpr_avl_add(avl, box(1005), box(492), NULL);
- avl = remove_int(avl, 21);
- avl = gpr_avl_add(avl, box(396), box(494), NULL);
- avl = remove_int(avl, 966);
- avl = gpr_avl_add(avl, box(105), box(496), NULL);
- avl = gpr_avl_add(avl, box(316), box(497), NULL);
- avl = remove_int(avl, 776);
- avl = gpr_avl_add(avl, box(188), box(499), NULL);
- avl = remove_int(avl, 200);
- avl = gpr_avl_add(avl, box(98), box(501), NULL);
- avl = gpr_avl_add(avl, box(831), box(502), NULL);
- avl = gpr_avl_add(avl, box(227), box(503), NULL);
- avl = gpr_avl_add(avl, box(220), box(504), NULL);
- avl = remove_int(avl, 715);
- avl = remove_int(avl, 279);
- avl = gpr_avl_add(avl, box(701), box(507), NULL);
- avl = gpr_avl_add(avl, box(726), box(508), NULL);
- avl = gpr_avl_add(avl, box(815), box(509), NULL);
- avl = gpr_avl_add(avl, box(749), box(510), NULL);
- 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), NULL);
- avl = remove_int(avl, 59);
- avl = gpr_avl_add(avl, box(168), box(517), NULL);
- avl = remove_int(avl, 337);
- avl = gpr_avl_add(avl, box(69), box(519), NULL);
- avl = remove_int(avl, 600);
- avl = gpr_avl_add(avl, box(591), box(521), NULL);
- avl = gpr_avl_add(avl, box(960), box(522), NULL);
- avl = gpr_avl_add(avl, box(116), box(523), NULL);
- avl = remove_int(avl, 991);
- avl = gpr_avl_add(avl, box(760), box(525), NULL);
- avl = gpr_avl_add(avl, box(664), box(526), NULL);
- avl = gpr_avl_add(avl, box(547), box(527), NULL);
- avl = remove_int(avl, 922);
- avl = gpr_avl_add(avl, box(290), box(529), NULL);
- avl = gpr_avl_add(avl, box(859), box(530), NULL);
- avl = gpr_avl_add(avl, box(49), box(531), NULL);
- avl = remove_int(avl, 455);
- avl = remove_int(avl, 786);
- avl = gpr_avl_add(avl, box(613), box(534), NULL);
- avl = gpr_avl_add(avl, box(326), box(535), NULL);
- avl = remove_int(avl, 615);
- avl = gpr_avl_add(avl, box(45), box(537), NULL);
- avl = gpr_avl_add(avl, box(162), box(538), NULL);
- avl = gpr_avl_add(avl, box(189), box(539), NULL);
- avl = remove_int(avl, 68);
- avl = remove_int(avl, 846);
- avl = gpr_avl_add(avl, box(608), box(542), NULL);
- avl = remove_int(avl, 821);
- avl = gpr_avl_add(avl, box(978), box(544), NULL);
- avl = gpr_avl_add(avl, box(892), box(545), NULL);
- avl = remove_int(avl, 924);
- avl = gpr_avl_add(avl, box(708), box(547), NULL);
- avl = remove_int(avl, 135);
- avl = remove_int(avl, 124);
- avl = gpr_avl_add(avl, box(301), box(550), NULL);
- avl = gpr_avl_add(avl, box(939), box(551), NULL);
- avl = gpr_avl_add(avl, box(344), box(552), NULL);
- avl = remove_int(avl, 443);
- avl = remove_int(avl, 122);
- avl = gpr_avl_add(avl, box(636), box(555), NULL);
- avl = remove_int(avl, 558);
- avl = gpr_avl_add(avl, box(923), box(557), NULL);
- avl = remove_int(avl, 827);
- avl = gpr_avl_add(avl, box(649), box(559), NULL);
- avl = gpr_avl_add(avl, box(808), box(560), NULL);
- avl = remove_int(avl, 570);
- avl = remove_int(avl, 434);
- avl = gpr_avl_add(avl, box(40), box(563), NULL);
- avl = gpr_avl_add(avl, box(725), box(564), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(512), box(572), NULL);
- 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), NULL);
- avl = remove_int(avl, 770);
- avl = remove_int(avl, 776);
- avl = gpr_avl_add(avl, box(602), box(581), NULL);
- avl = remove_int(avl, 251);
- avl = gpr_avl_add(avl, box(303), box(583), NULL);
- avl = remove_int(avl, 837);
- avl = gpr_avl_add(avl, box(714), box(585), NULL);
- avl = remove_int(avl, 800);
- avl = gpr_avl_add(avl, box(266), box(587), NULL);
- avl = gpr_avl_add(avl, box(555), box(588), NULL);
- avl = remove_int(avl, 604);
- avl = remove_int(avl, 163);
- avl = remove_int(avl, 497);
- avl = gpr_avl_add(avl, box(296), box(592), NULL);
- avl = remove_int(avl, 129);
- avl = gpr_avl_add(avl, box(656), box(594), NULL);
- avl = remove_int(avl, 769);
- avl = remove_int(avl, 941);
- avl = gpr_avl_add(avl, box(775), box(597), NULL);
- avl = gpr_avl_add(avl, box(846), box(598), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(575), box(604), NULL);
- avl = gpr_avl_add(avl, box(620), box(605), NULL);
- avl = remove_int(avl, 100);
- avl = remove_int(avl, 667);
- avl = gpr_avl_add(avl, box(138), box(608), NULL);
- avl = gpr_avl_add(avl, box(566), box(609), NULL);
- avl = gpr_avl_add(avl, box(673), box(610), NULL);
- avl = gpr_avl_add(avl, box(178), box(611), NULL);
- avl = remove_int(avl, 659);
- avl = gpr_avl_add(avl, box(759), box(613), NULL);
- avl = gpr_avl_add(avl, box(1008), box(614), NULL);
- avl = remove_int(avl, 116);
- avl = gpr_avl_add(avl, box(608), box(616), NULL);
- avl = gpr_avl_add(avl, box(339), box(617), NULL);
- avl = gpr_avl_add(avl, box(197), box(618), NULL);
- avl = remove_int(avl, 25);
- avl = remove_int(avl, 628);
- avl = gpr_avl_add(avl, box(487), box(621), NULL);
- avl = remove_int(avl, 739);
- avl = remove_int(avl, 100);
- avl = remove_int(avl, 928);
- avl = gpr_avl_add(avl, box(647), box(625), NULL);
- avl = remove_int(avl, 978);
- avl = remove_int(avl, 143);
- avl = remove_int(avl, 755);
- avl = gpr_avl_add(avl, box(71), box(629), NULL);
- avl = remove_int(avl, 205);
- avl = gpr_avl_add(avl, box(501), box(631), NULL);
- 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), NULL);
- avl = remove_int(avl, 264);
- avl = gpr_avl_add(avl, box(69), box(639), NULL);
- avl = remove_int(avl, 73);
- avl = gpr_avl_add(avl, box(745), box(641), NULL);
- avl = remove_int(avl, 518);
- avl = remove_int(avl, 641);
- avl = remove_int(avl, 768);
- avl = gpr_avl_add(avl, box(988), box(645), NULL);
- avl = gpr_avl_add(avl, box(899), box(646), NULL);
- avl = remove_int(avl, 763);
- avl = remove_int(avl, 281);
- avl = remove_int(avl, 496);
- avl = gpr_avl_add(avl, box(445), box(650), NULL);
- avl = remove_int(avl, 905);
- avl = gpr_avl_add(avl, box(275), box(652), NULL);
- avl = gpr_avl_add(avl, box(137), box(653), NULL);
- avl = remove_int(avl, 642);
- avl = gpr_avl_add(avl, box(708), box(655), NULL);
- avl = remove_int(avl, 922);
- avl = gpr_avl_add(avl, box(743), box(657), NULL);
- avl = remove_int(avl, 295);
- avl = remove_int(avl, 665);
- avl = remove_int(avl, 48);
- avl = gpr_avl_add(avl, box(1012), box(661), NULL);
- avl = remove_int(avl, 71);
- avl = remove_int(avl, 523);
- avl = gpr_avl_add(avl, box(319), box(664), NULL);
- avl = remove_int(avl, 632);
- avl = gpr_avl_add(avl, box(137), box(666), NULL);
- avl = gpr_avl_add(avl, box(686), box(667), NULL);
- avl = gpr_avl_add(avl, box(724), box(668), NULL);
- avl = gpr_avl_add(avl, box(952), box(669), NULL);
- avl = gpr_avl_add(avl, box(5), box(670), NULL);
- avl = remove_int(avl, 35);
- avl = gpr_avl_add(avl, box(43), box(672), NULL);
- avl = gpr_avl_add(avl, box(320), box(673), NULL);
- avl = gpr_avl_add(avl, box(115), box(674), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(605), box(680), NULL);
- avl = gpr_avl_add(avl, box(152), box(681), NULL);
- avl = gpr_avl_add(avl, box(113), box(682), NULL);
- avl = remove_int(avl, 131);
- avl = remove_int(avl, 637);
- avl = gpr_avl_add(avl, box(156), box(685), NULL);
- avl = remove_int(avl, 696);
- avl = gpr_avl_add(avl, box(546), box(687), NULL);
- 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), NULL);
- avl = remove_int(avl, 924);
- avl = gpr_avl_add(avl, box(825), box(703), NULL);
- avl = remove_int(avl, 888);
- avl = remove_int(avl, 931);
- avl = gpr_avl_add(avl, box(285), box(706), NULL);
- avl = remove_int(avl, 62);
- avl = remove_int(avl, 444);
- avl = remove_int(avl, 946);
- avl = gpr_avl_add(avl, box(122), box(710), NULL);
- avl = gpr_avl_add(avl, box(846), box(711), NULL);
- avl = remove_int(avl, 628);
- avl = gpr_avl_add(avl, box(511), box(713), NULL);
- avl = gpr_avl_add(avl, box(398), box(714), NULL);
- avl = remove_int(avl, 730);
- avl = gpr_avl_add(avl, box(797), box(716), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(1015), box(726), NULL);
- avl = remove_int(avl, 813);
- avl = gpr_avl_add(avl, box(213), box(728), NULL);
- avl = remove_int(avl, 468);
- avl = remove_int(avl, 365);
- avl = remove_int(avl, 399);
- avl = gpr_avl_add(avl, box(380), box(732), NULL);
- avl = remove_int(avl, 835);
- avl = remove_int(avl, 970);
- avl = gpr_avl_add(avl, box(700), box(735), NULL);
- avl = gpr_avl_add(avl, box(807), box(736), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(332), box(744), NULL);
- avl = remove_int(avl, 686);
- avl = remove_int(avl, 206);
- avl = remove_int(avl, 835);
- avl = gpr_avl_add(avl, box(334), box(748), NULL);
- avl = remove_int(avl, 171);
- avl = gpr_avl_add(avl, box(1002), box(750), NULL);
- avl = gpr_avl_add(avl, box(779), box(751), NULL);
- avl = gpr_avl_add(avl, box(307), box(752), NULL);
- avl = gpr_avl_add(avl, box(127), box(753), NULL);
- avl = gpr_avl_add(avl, box(251), box(754), NULL);
- 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), NULL);
- avl = remove_int(avl, 43);
- avl = gpr_avl_add(avl, box(871), box(762), NULL);
- avl = gpr_avl_add(avl, box(580), box(763), NULL);
- avl = remove_int(avl, 501);
- avl = remove_int(avl, 462);
- avl = remove_int(avl, 599);
- avl = gpr_avl_add(avl, box(240), box(767), NULL);
- avl = gpr_avl_add(avl, box(285), box(768), NULL);
- avl = gpr_avl_add(avl, box(472), box(769), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(552), box(778), NULL);
- avl = remove_int(avl, 19);
- avl = remove_int(avl, 803);
- avl = gpr_avl_add(avl, box(508), box(781), NULL);
- 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), NULL);
- 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), NULL);
- 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), NULL);
- avl = remove_int(avl, 38);
- avl = remove_int(avl, 595);
- avl = gpr_avl_add(avl, box(213), box(799), NULL);
- avl = remove_int(avl, 7);
- avl = remove_int(avl, 620);
- avl = gpr_avl_add(avl, box(946), box(802), NULL);
- avl = remove_int(avl, 145);
- avl = gpr_avl_add(avl, box(628), box(804), NULL);
- avl = remove_int(avl, 972);
- avl = gpr_avl_add(avl, box(728), box(806), NULL);
- avl = remove_int(avl, 91);
- avl = gpr_avl_add(avl, box(136), box(808), NULL);
- avl = gpr_avl_add(avl, box(841), box(809), NULL);
- avl = gpr_avl_add(avl, box(265), box(810), NULL);
- avl = gpr_avl_add(avl, box(701), box(811), NULL);
- avl = gpr_avl_add(avl, box(27), box(812), NULL);
- avl = remove_int(avl, 72);
- avl = remove_int(avl, 14);
- avl = gpr_avl_add(avl, box(286), box(815), NULL);
- avl = remove_int(avl, 996);
- avl = remove_int(avl, 998);
- avl = gpr_avl_add(avl, box(466), box(818), NULL);
- 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), NULL);
- avl = remove_int(avl, 812);
- avl = gpr_avl_add(avl, box(577), box(829), NULL);
- avl = remove_int(avl, 624);
- avl = remove_int(avl, 847);
- avl = remove_int(avl, 745);
- avl = gpr_avl_add(avl, box(491), box(833), NULL);
- avl = gpr_avl_add(avl, box(941), box(834), NULL);
- avl = remove_int(avl, 258);
- avl = gpr_avl_add(avl, box(410), box(836), NULL);
- avl = gpr_avl_add(avl, box(80), box(837), NULL);
- avl = gpr_avl_add(avl, box(196), box(838), NULL);
- avl = gpr_avl_add(avl, box(5), box(839), NULL);
- avl = remove_int(avl, 782);
- avl = gpr_avl_add(avl, box(827), box(841), NULL);
- avl = remove_int(avl, 472);
- avl = remove_int(avl, 664);
- avl = gpr_avl_add(avl, box(409), box(844), NULL);
- avl = gpr_avl_add(avl, box(62), box(845), NULL);
- 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), NULL);
- avl = remove_int(avl, 587);
- avl = remove_int(avl, 350);
- avl = gpr_avl_add(avl, box(980), box(855), NULL);
- avl = gpr_avl_add(avl, box(992), box(856), NULL);
- avl = gpr_avl_add(avl, box(818), box(857), NULL);
- avl = remove_int(avl, 853);
- avl = remove_int(avl, 701);
- avl = gpr_avl_add(avl, box(675), box(860), NULL);
- avl = remove_int(avl, 248);
- avl = remove_int(avl, 649);
- avl = gpr_avl_add(avl, box(508), box(863), NULL);
- avl = remove_int(avl, 927);
- avl = gpr_avl_add(avl, box(957), box(865), NULL);
- avl = gpr_avl_add(avl, box(698), box(866), NULL);
- avl = gpr_avl_add(avl, box(388), box(867), NULL);
- avl = gpr_avl_add(avl, box(532), box(868), NULL);
- avl = gpr_avl_add(avl, box(681), box(869), NULL);
- avl = remove_int(avl, 544);
- avl = remove_int(avl, 991);
- avl = remove_int(avl, 397);
- avl = gpr_avl_add(avl, box(954), box(873), NULL);
- avl = gpr_avl_add(avl, box(219), box(874), NULL);
- avl = gpr_avl_add(avl, box(465), box(875), NULL);
- avl = remove_int(avl, 371);
- avl = gpr_avl_add(avl, box(601), box(877), NULL);
- avl = gpr_avl_add(avl, box(543), box(878), NULL);
- avl = remove_int(avl, 329);
- avl = gpr_avl_add(avl, box(560), box(880), NULL);
- avl = remove_int(avl, 898);
- avl = gpr_avl_add(avl, box(455), box(882), NULL);
- avl = remove_int(avl, 313);
- avl = gpr_avl_add(avl, box(215), box(884), NULL);
- avl = remove_int(avl, 846);
- avl = gpr_avl_add(avl, box(608), box(886), NULL);
- avl = remove_int(avl, 248);
- avl = gpr_avl_add(avl, box(575), box(888), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(329), box(894), NULL);
- avl = gpr_avl_add(avl, box(326), box(895), NULL);
- avl = remove_int(avl, 746);
- avl = remove_int(avl, 99);
- avl = gpr_avl_add(avl, box(464), box(898), NULL);
- avl = gpr_avl_add(avl, box(141), box(899), NULL);
- avl = remove_int(avl, 383);
- avl = gpr_avl_add(avl, box(414), box(901), NULL);
- avl = gpr_avl_add(avl, box(777), box(902), NULL);
- avl = remove_int(avl, 972);
- avl = remove_int(avl, 841);
- avl = remove_int(avl, 100);
- avl = gpr_avl_add(avl, box(828), box(906), NULL);
- avl = remove_int(avl, 785);
- avl = gpr_avl_add(avl, box(1008), box(908), NULL);
- avl = gpr_avl_add(avl, box(46), box(909), NULL);
- avl = remove_int(avl, 399);
- avl = gpr_avl_add(avl, box(178), box(911), NULL);
- avl = gpr_avl_add(avl, box(573), box(912), NULL);
- avl = remove_int(avl, 299);
- avl = gpr_avl_add(avl, box(690), box(914), NULL);
- avl = gpr_avl_add(avl, box(692), box(915), NULL);
- 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), NULL);
- avl = remove_int(avl, 328);
- avl = gpr_avl_add(avl, box(89), box(923), NULL);
- avl = remove_int(avl, 867);
- avl = remove_int(avl, 626);
- avl = remove_int(avl, 507);
- avl = gpr_avl_add(avl, box(365), box(927), NULL);
- avl = gpr_avl_add(avl, box(58), box(928), NULL);
- avl = gpr_avl_add(avl, box(70), box(929), NULL);
- avl = remove_int(avl, 81);
- avl = remove_int(avl, 797);
- avl = gpr_avl_add(avl, box(846), box(932), NULL);
- avl = remove_int(avl, 642);
- avl = gpr_avl_add(avl, box(777), box(934), NULL);
- avl = remove_int(avl, 107);
- avl = gpr_avl_add(avl, box(691), box(936), NULL);
- avl = gpr_avl_add(avl, box(820), box(937), NULL);
- avl = gpr_avl_add(avl, box(202), box(938), NULL);
- avl = gpr_avl_add(avl, box(308), box(939), NULL);
- avl = gpr_avl_add(avl, box(20), box(940), NULL);
- avl = remove_int(avl, 289);
- avl = gpr_avl_add(avl, box(714), box(942), NULL);
- avl = gpr_avl_add(avl, box(584), box(943), NULL);
- avl = remove_int(avl, 294);
- avl = gpr_avl_add(avl, box(496), box(945), NULL);
- avl = gpr_avl_add(avl, box(394), box(946), NULL);
- avl = gpr_avl_add(avl, box(860), box(947), NULL);
- avl = gpr_avl_add(avl, box(58), box(948), NULL);
- avl = remove_int(avl, 784);
- avl = remove_int(avl, 584);
- avl = remove_int(avl, 708);
- avl = gpr_avl_add(avl, box(142), box(952), NULL);
- avl = gpr_avl_add(avl, box(247), box(953), NULL);
- avl = gpr_avl_add(avl, box(389), box(954), NULL);
- avl = remove_int(avl, 390);
- avl = gpr_avl_add(avl, box(465), box(956), NULL);
- avl = gpr_avl_add(avl, box(936), box(957), NULL);
- avl = gpr_avl_add(avl, box(309), box(958), NULL);
- 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), NULL);
- avl = remove_int(avl, 82);
- avl = gpr_avl_add(avl, box(728), box(968), NULL);
- avl = remove_int(avl, 852);
- avl = gpr_avl_add(avl, box(884), box(970), NULL);
- avl = gpr_avl_add(avl, box(502), box(971), NULL);
- avl = remove_int(avl, 898);
- avl = remove_int(avl, 481);
- avl = gpr_avl_add(avl, box(911), box(974), NULL);
- 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), NULL);
- avl = remove_int(avl, 25);
- avl = remove_int(avl, 697);
- avl = gpr_avl_add(avl, box(645), box(986), NULL);
- avl = gpr_avl_add(avl, box(211), box(987), NULL);
- avl = gpr_avl_add(avl, box(589), box(988), NULL);
- avl = remove_int(avl, 702);
- avl = gpr_avl_add(avl, box(53), box(990), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(834), box(998), NULL);
- avl = gpr_avl_add(avl, box(514), box(999), NULL);
- avl = gpr_avl_add(avl, box(75), box(1000), NULL);
- avl = remove_int(avl, 745);
- avl = gpr_avl_add(avl, box(362), box(1002), NULL);
- avl = remove_int(avl, 215);
- avl = gpr_avl_add(avl, box(624), box(1004), NULL);
- avl = remove_int(avl, 404);
- avl = remove_int(avl, 359);
- avl = remove_int(avl, 491);
- avl = gpr_avl_add(avl, box(903), box(1008), NULL);
- avl = gpr_avl_add(avl, box(240), box(1009), NULL);
- avl = remove_int(avl, 95);
- avl = gpr_avl_add(avl, box(119), box(1011), NULL);
- avl = gpr_avl_add(avl, box(857), box(1012), NULL);
- avl = remove_int(avl, 39);
- avl = remove_int(avl, 866);
- avl = gpr_avl_add(avl, box(503), box(1015), NULL);
- avl = gpr_avl_add(avl, box(740), box(1016), NULL);
- 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), NULL);
- avl = remove_int(avl, 638);
- avl = gpr_avl_add(avl, box(299), box(1025), NULL);
- avl = gpr_avl_add(avl, box(584), box(1026), NULL);
- avl = remove_int(avl, 863);
- avl = gpr_avl_add(avl, box(612), box(1028), NULL);
- avl = gpr_avl_add(avl, box(62), box(1029), NULL);
- avl = gpr_avl_add(avl, box(432), box(1030), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(644), box(1036), NULL);
- avl = remove_int(avl, 638);
- avl = gpr_avl_add(avl, box(13), box(1038), NULL);
- avl = remove_int(avl, 66);
- avl = remove_int(avl, 82);
- avl = gpr_avl_add(avl, box(362), box(1041), NULL);
- avl = gpr_avl_add(avl, box(783), box(1042), NULL);
- avl = remove_int(avl, 60);
- avl = gpr_avl_add(avl, box(80), box(1044), NULL);
- avl = gpr_avl_add(avl, box(825), box(1045), NULL);
- avl = gpr_avl_add(avl, box(688), box(1046), NULL);
- avl = gpr_avl_add(avl, box(662), box(1047), NULL);
- avl = remove_int(avl, 156);
- avl = remove_int(avl, 376);
- avl = remove_int(avl, 99);
- avl = gpr_avl_add(avl, box(526), box(1051), NULL);
- avl = gpr_avl_add(avl, box(168), box(1052), NULL);
- avl = remove_int(avl, 646);
- avl = remove_int(avl, 380);
- avl = remove_int(avl, 833);
- avl = gpr_avl_add(avl, box(53), box(1056), NULL);
- avl = remove_int(avl, 105);
- avl = gpr_avl_add(avl, box(373), box(1058), NULL);
- avl = gpr_avl_add(avl, box(184), box(1059), NULL);
- avl = remove_int(avl, 288);
- avl = gpr_avl_add(avl, box(966), box(1061), NULL);
- avl = remove_int(avl, 158);
- avl = gpr_avl_add(avl, box(406), box(1063), NULL);
- avl = remove_int(avl, 470);
- avl = gpr_avl_add(avl, box(283), box(1065), NULL);
- avl = gpr_avl_add(avl, box(838), box(1066), NULL);
- avl = gpr_avl_add(avl, box(288), box(1067), NULL);
- avl = gpr_avl_add(avl, box(950), box(1068), NULL);
- avl = gpr_avl_add(avl, box(163), box(1069), NULL);
- avl = remove_int(avl, 623);
- avl = remove_int(avl, 769);
- avl = gpr_avl_add(avl, box(144), box(1072), NULL);
- avl = gpr_avl_add(avl, box(489), box(1073), NULL);
- avl = remove_int(avl, 15);
- avl = gpr_avl_add(avl, box(971), box(1075), NULL);
- avl = remove_int(avl, 660);
- avl = gpr_avl_add(avl, box(255), box(1077), NULL);
- avl = remove_int(avl, 494);
- avl = gpr_avl_add(avl, box(109), box(1079), NULL);
- avl = gpr_avl_add(avl, box(420), box(1080), NULL);
- avl = gpr_avl_add(avl, box(509), box(1081), NULL);
- avl = remove_int(avl, 178);
- avl = gpr_avl_add(avl, box(216), box(1083), NULL);
- avl = gpr_avl_add(avl, box(707), box(1084), NULL);
- avl = gpr_avl_add(avl, box(411), box(1085), NULL);
- avl = gpr_avl_add(avl, box(352), box(1086), NULL);
- avl = remove_int(avl, 983);
- avl = gpr_avl_add(avl, box(6), box(1088), NULL);
- avl = gpr_avl_add(avl, box(1014), box(1089), NULL);
- avl = remove_int(avl, 98);
- avl = remove_int(avl, 325);
- avl = gpr_avl_add(avl, box(851), box(1092), NULL);
- avl = remove_int(avl, 553);
- avl = gpr_avl_add(avl, box(218), box(1094), NULL);
- avl = gpr_avl_add(avl, box(261), box(1095), NULL);
- avl = remove_int(avl, 31);
- avl = gpr_avl_add(avl, box(872), box(1097), NULL);
- avl = remove_int(avl, 543);
- avl = remove_int(avl, 314);
- avl = remove_int(avl, 443);
- avl = gpr_avl_add(avl, box(533), box(1101), NULL);
- 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), NULL);
- avl = remove_int(avl, 622);
- avl = gpr_avl_add(avl, box(352), box(1112), NULL);
- avl = remove_int(avl, 182);
- avl = gpr_avl_add(avl, box(534), box(1114), NULL);
- avl = gpr_avl_add(avl, box(97), box(1115), NULL);
- avl = gpr_avl_add(avl, box(198), box(1116), NULL);
- avl = remove_int(avl, 750);
- avl = gpr_avl_add(avl, box(98), box(1118), NULL);
- avl = remove_int(avl, 943);
- avl = gpr_avl_add(avl, box(254), box(1120), NULL);
- avl = gpr_avl_add(avl, box(30), box(1121), NULL);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 475);
- avl = remove_int(avl, 82);
- avl = gpr_avl_add(avl, box(789), box(1125), NULL);
- avl = gpr_avl_add(avl, box(402), box(1126), NULL);
- avl = remove_int(avl, 1019);
- avl = gpr_avl_add(avl, box(858), box(1128), NULL);
- avl = gpr_avl_add(avl, box(625), box(1129), NULL);
- avl = remove_int(avl, 675);
- avl = remove_int(avl, 323);
- avl = gpr_avl_add(avl, box(329), box(1132), NULL);
- avl = remove_int(avl, 929);
- avl = remove_int(avl, 44);
- avl = gpr_avl_add(avl, box(443), box(1135), NULL);
- avl = gpr_avl_add(avl, box(653), box(1136), NULL);
- avl = gpr_avl_add(avl, box(750), box(1137), NULL);
- avl = gpr_avl_add(avl, box(252), box(1138), NULL);
- avl = gpr_avl_add(avl, box(449), box(1139), NULL);
- 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), NULL);
- avl = remove_int(avl, 806);
- avl = gpr_avl_add(avl, box(455), box(1146), NULL);
- avl = remove_int(avl, 31);
- avl = gpr_avl_add(avl, box(154), box(1148), NULL);
- avl = gpr_avl_add(avl, box(189), box(1149), NULL);
- avl = remove_int(avl, 786);
- avl = gpr_avl_add(avl, box(496), box(1151), NULL);
- avl = gpr_avl_add(avl, box(81), box(1152), NULL);
- avl = gpr_avl_add(avl, box(59), box(1153), NULL);
- avl = remove_int(avl, 424);
- avl = remove_int(avl, 668);
- avl = gpr_avl_add(avl, box(723), box(1156), NULL);
- avl = gpr_avl_add(avl, box(822), box(1157), NULL);
- avl = gpr_avl_add(avl, box(354), box(1158), NULL);
- avl = remove_int(avl, 738);
- avl = gpr_avl_add(avl, box(686), box(1160), NULL);
- avl = gpr_avl_add(avl, box(43), box(1161), NULL);
- avl = gpr_avl_add(avl, box(625), box(1162), NULL);
- avl = gpr_avl_add(avl, box(902), box(1163), NULL);
- avl = gpr_avl_add(avl, box(12), box(1164), NULL);
- avl = gpr_avl_add(avl, box(977), box(1165), NULL);
- avl = gpr_avl_add(avl, box(699), box(1166), NULL);
- avl = gpr_avl_add(avl, box(189), box(1167), NULL);
- 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), NULL);
- avl = remove_int(avl, 758);
- avl = remove_int(avl, 222);
- avl = gpr_avl_add(avl, box(975), box(1175), NULL);
- avl = remove_int(avl, 993);
- avl = gpr_avl_add(avl, box(2), box(1177), NULL);
- avl = gpr_avl_add(avl, box(70), box(1178), NULL);
- avl = remove_int(avl, 350);
- avl = remove_int(avl, 972);
- avl = remove_int(avl, 880);
- avl = gpr_avl_add(avl, box(753), box(1182), NULL);
- avl = remove_int(avl, 404);
- avl = gpr_avl_add(avl, box(294), box(1184), NULL);
- avl = remove_int(avl, 474);
- avl = gpr_avl_add(avl, box(228), box(1186), NULL);
- avl = gpr_avl_add(avl, box(484), box(1187), NULL);
- avl = remove_int(avl, 238);
- avl = remove_int(avl, 53);
- avl = remove_int(avl, 691);
- avl = gpr_avl_add(avl, box(345), box(1191), NULL);
- avl = remove_int(avl, 0);
- avl = gpr_avl_add(avl, box(230), box(1193), NULL);
- avl = remove_int(avl, 227);
- avl = remove_int(avl, 152);
- avl = gpr_avl_add(avl, box(884), box(1196), NULL);
- avl = remove_int(avl, 823);
- avl = remove_int(avl, 53);
- avl = gpr_avl_add(avl, box(1015), box(1199), NULL);
- avl = gpr_avl_add(avl, box(697), box(1200), NULL);
- avl = gpr_avl_add(avl, box(376), box(1201), NULL);
- avl = remove_int(avl, 411);
- avl = gpr_avl_add(avl, box(888), box(1203), NULL);
- avl = remove_int(avl, 55);
- avl = gpr_avl_add(avl, box(85), box(1205), NULL);
- avl = remove_int(avl, 947);
- avl = remove_int(avl, 382);
- avl = remove_int(avl, 777);
- avl = gpr_avl_add(avl, box(1017), box(1209), NULL);
- avl = gpr_avl_add(avl, box(169), box(1210), NULL);
- avl = gpr_avl_add(avl, box(156), box(1211), NULL);
- avl = remove_int(avl, 153);
- avl = remove_int(avl, 642);
- avl = remove_int(avl, 158);
- avl = gpr_avl_add(avl, box(554), box(1215), NULL);
- avl = gpr_avl_add(avl, box(76), box(1216), NULL);
- avl = gpr_avl_add(avl, box(756), box(1217), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(712), box(1227), NULL);
- avl = gpr_avl_add(avl, box(474), box(1228), NULL);
- avl = gpr_avl_add(avl, box(882), box(1229), NULL);
- avl = gpr_avl_add(avl, box(965), box(1230), NULL);
- avl = remove_int(avl, 464);
- avl = gpr_avl_add(avl, box(319), box(1232), NULL);
- avl = gpr_avl_add(avl, box(504), box(1233), NULL);
- avl = remove_int(avl, 818);
- avl = gpr_avl_add(avl, box(884), box(1235), NULL);
- avl = gpr_avl_add(avl, box(813), box(1236), NULL);
- avl = gpr_avl_add(avl, box(795), box(1237), NULL);
- avl = remove_int(avl, 306);
- avl = gpr_avl_add(avl, box(799), box(1239), NULL);
- avl = remove_int(avl, 534);
- avl = gpr_avl_add(avl, box(480), box(1241), NULL);
- avl = gpr_avl_add(avl, box(656), box(1242), NULL);
- avl = gpr_avl_add(avl, box(709), box(1243), NULL);
- avl = gpr_avl_add(avl, box(500), box(1244), NULL);
- avl = remove_int(avl, 740);
- avl = gpr_avl_add(avl, box(980), box(1246), NULL);
- avl = gpr_avl_add(avl, box(458), box(1247), NULL);
- avl = remove_int(avl, 377);
- avl = remove_int(avl, 338);
- avl = gpr_avl_add(avl, box(554), box(1250), NULL);
- avl = gpr_avl_add(avl, box(504), box(1251), NULL);
- avl = gpr_avl_add(avl, box(603), box(1252), NULL);
- avl = gpr_avl_add(avl, box(761), box(1253), NULL);
- avl = remove_int(avl, 431);
- avl = gpr_avl_add(avl, box(707), box(1255), NULL);
- avl = gpr_avl_add(avl, box(673), box(1256), NULL);
- 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), NULL);
- avl = remove_int(avl, 858);
- avl = remove_int(avl, 997);
- avl = gpr_avl_add(avl, box(519), box(1267), NULL);
- avl = remove_int(avl, 614);
- avl = remove_int(avl, 462);
- avl = remove_int(avl, 792);
- avl = gpr_avl_add(avl, box(987), box(1271), NULL);
- avl = gpr_avl_add(avl, box(309), box(1272), NULL);
- avl = remove_int(avl, 747);
- avl = gpr_avl_add(avl, box(621), box(1274), NULL);
- avl = gpr_avl_add(avl, box(450), box(1275), NULL);
- avl = remove_int(avl, 265);
- avl = remove_int(avl, 8);
- avl = remove_int(avl, 383);
- avl = gpr_avl_add(avl, box(238), box(1279), NULL);
- avl = remove_int(avl, 241);
- avl = gpr_avl_add(avl, box(180), box(1281), NULL);
- avl = gpr_avl_add(avl, box(411), box(1282), NULL);
- avl = gpr_avl_add(avl, box(791), box(1283), NULL);
- avl = gpr_avl_add(avl, box(955), box(1284), NULL);
- avl = remove_int(avl, 24);
- avl = remove_int(avl, 375);
- avl = gpr_avl_add(avl, box(140), box(1287), NULL);
- avl = remove_int(avl, 949);
- avl = gpr_avl_add(avl, box(301), box(1289), NULL);
- avl = gpr_avl_add(avl, box(0), box(1290), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(127), box(1296), NULL);
- avl = gpr_avl_add(avl, box(279), box(1297), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(304), box(1304), NULL);
- avl = gpr_avl_add(avl, box(1), box(1305), NULL);
- avl = gpr_avl_add(avl, box(339), box(1306), NULL);
- 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), NULL);
- avl = remove_int(avl, 85);
- avl = gpr_avl_add(avl, box(964), box(1314), NULL);
- avl = gpr_avl_add(avl, box(559), box(1315), NULL);
- avl = remove_int(avl, 167);
- avl = gpr_avl_add(avl, box(866), box(1317), NULL);
- avl = remove_int(avl, 275);
- avl = gpr_avl_add(avl, box(173), box(1319), NULL);
- avl = gpr_avl_add(avl, box(765), box(1320), NULL);
- avl = remove_int(avl, 883);
- avl = gpr_avl_add(avl, box(547), box(1322), NULL);
- avl = gpr_avl_add(avl, box(847), box(1323), NULL);
- avl = remove_int(avl, 817);
- avl = remove_int(avl, 850);
- avl = remove_int(avl, 718);
- avl = gpr_avl_add(avl, box(806), box(1327), NULL);
- avl = gpr_avl_add(avl, box(360), box(1328), NULL);
- avl = remove_int(avl, 991);
- avl = gpr_avl_add(avl, box(493), box(1330), NULL);
- avl = remove_int(avl, 516);
- avl = gpr_avl_add(avl, box(361), box(1332), NULL);
- avl = remove_int(avl, 355);
- avl = gpr_avl_add(avl, box(512), box(1334), NULL);
- avl = gpr_avl_add(avl, box(191), box(1335), NULL);
- avl = remove_int(avl, 703);
- avl = gpr_avl_add(avl, box(333), box(1337), NULL);
- avl = remove_int(avl, 481);
- avl = gpr_avl_add(avl, box(501), box(1339), NULL);
- avl = remove_int(avl, 532);
- avl = remove_int(avl, 510);
- avl = gpr_avl_add(avl, box(793), box(1342), NULL);
- avl = gpr_avl_add(avl, box(234), box(1343), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(702), box(1349), NULL);
- avl = gpr_avl_add(avl, box(149), box(1350), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(455), box(1358), NULL);
- avl = remove_int(avl, 782);
- avl = remove_int(avl, 682);
- avl = gpr_avl_add(avl, box(243), box(1361), NULL);
- avl = gpr_avl_add(avl, box(109), box(1362), NULL);
- avl = gpr_avl_add(avl, box(452), box(1363), NULL);
- avl = remove_int(avl, 151);
- avl = gpr_avl_add(avl, box(159), box(1365), NULL);
- avl = remove_int(avl, 1023);
- avl = gpr_avl_add(avl, box(129), box(1367), NULL);
- avl = gpr_avl_add(avl, box(537), box(1368), NULL);
- avl = remove_int(avl, 321);
- avl = gpr_avl_add(avl, box(740), box(1370), NULL);
- avl = remove_int(avl, 45);
- avl = remove_int(avl, 136);
- avl = gpr_avl_add(avl, box(229), box(1373), NULL);
- avl = remove_int(avl, 772);
- avl = gpr_avl_add(avl, box(181), box(1375), NULL);
- avl = remove_int(avl, 175);
- avl = gpr_avl_add(avl, box(817), box(1377), NULL);
- avl = remove_int(avl, 956);
- avl = gpr_avl_add(avl, box(675), box(1379), NULL);
- avl = gpr_avl_add(avl, box(375), box(1380), NULL);
- avl = remove_int(avl, 384);
- avl = gpr_avl_add(avl, box(1016), box(1382), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(293), box(1389), NULL);
- avl = remove_int(avl, 207);
- avl = remove_int(avl, 46);
- avl = gpr_avl_add(avl, box(899), box(1392), NULL);
- avl = gpr_avl_add(avl, box(666), box(1393), NULL);
- avl = gpr_avl_add(avl, box(85), box(1394), NULL);
- avl = gpr_avl_add(avl, box(914), box(1395), NULL);
- avl = gpr_avl_add(avl, box(128), box(1396), NULL);
- avl = gpr_avl_add(avl, box(835), box(1397), NULL);
- avl = gpr_avl_add(avl, box(787), box(1398), NULL);
- avl = gpr_avl_add(avl, box(649), box(1399), NULL);
- avl = gpr_avl_add(avl, box(723), box(1400), NULL);
- avl = remove_int(avl, 874);
- avl = gpr_avl_add(avl, box(778), box(1402), NULL);
- avl = gpr_avl_add(avl, box(1015), box(1403), NULL);
- avl = gpr_avl_add(avl, box(59), box(1404), NULL);
- avl = gpr_avl_add(avl, box(259), box(1405), NULL);
- avl = gpr_avl_add(avl, box(758), box(1406), NULL);
- avl = remove_int(avl, 648);
- avl = gpr_avl_add(avl, box(145), box(1408), NULL);
- avl = gpr_avl_add(avl, box(440), box(1409), NULL);
- avl = remove_int(avl, 608);
- avl = remove_int(avl, 690);
- avl = gpr_avl_add(avl, box(605), box(1412), NULL);
- avl = remove_int(avl, 856);
- avl = remove_int(avl, 608);
- avl = gpr_avl_add(avl, box(829), box(1415), NULL);
- avl = gpr_avl_add(avl, box(660), box(1416), NULL);
- avl = remove_int(avl, 596);
- avl = gpr_avl_add(avl, box(519), box(1418), NULL);
- avl = gpr_avl_add(avl, box(35), box(1419), NULL);
- avl = gpr_avl_add(avl, box(871), box(1420), NULL);
- avl = remove_int(avl, 845);
- avl = gpr_avl_add(avl, box(600), box(1422), NULL);
- avl = gpr_avl_add(avl, box(215), box(1423), NULL);
- avl = remove_int(avl, 761);
- avl = gpr_avl_add(avl, box(975), box(1425), NULL);
- avl = remove_int(avl, 987);
- avl = gpr_avl_add(avl, box(58), box(1427), NULL);
- avl = remove_int(avl, 119);
- avl = gpr_avl_add(avl, box(937), box(1429), NULL);
- avl = gpr_avl_add(avl, box(372), box(1430), NULL);
- avl = gpr_avl_add(avl, box(11), box(1431), NULL);
- avl = gpr_avl_add(avl, box(398), box(1432), NULL);
- avl = gpr_avl_add(avl, box(423), box(1433), NULL);
- avl = remove_int(avl, 171);
- avl = gpr_avl_add(avl, box(473), box(1435), NULL);
- 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), NULL);
- 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), NULL);
- avl = remove_int(avl, 152);
- avl = gpr_avl_add(avl, box(61), box(1448), NULL);
- avl = remove_int(avl, 929);
- avl = remove_int(avl, 9);
- avl = gpr_avl_add(avl, box(251), box(1451), NULL);
- avl = gpr_avl_add(avl, box(672), box(1452), NULL);
- avl = gpr_avl_add(avl, box(66), box(1453), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(495), box(1459), NULL);
- avl = remove_int(avl, 450);
- avl = gpr_avl_add(avl, box(533), box(1461), NULL);
- avl = gpr_avl_add(avl, box(414), box(1462), NULL);
- avl = remove_int(avl, 74);
- avl = remove_int(avl, 236);
- avl = gpr_avl_add(avl, box(707), box(1465), NULL);
- avl = gpr_avl_add(avl, box(357), box(1466), NULL);
- avl = gpr_avl_add(avl, box(1007), box(1467), NULL);
- avl = gpr_avl_add(avl, box(811), box(1468), NULL);
- avl = gpr_avl_add(avl, box(418), box(1469), NULL);
- avl = gpr_avl_add(avl, box(164), box(1470), NULL);
- avl = gpr_avl_add(avl, box(622), box(1471), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(202), box(1478), NULL);
- avl = gpr_avl_add(avl, box(312), box(1479), NULL);
- avl = remove_int(avl, 274);
- avl = gpr_avl_add(avl, box(684), box(1481), NULL);
- avl = gpr_avl_add(avl, box(954), box(1482), NULL);
- avl = gpr_avl_add(avl, box(637), box(1483), NULL);
- avl = remove_int(avl, 716);
- avl = gpr_avl_add(avl, box(198), box(1485), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(862), box(1491), NULL);
- avl = remove_int(avl, 527);
- avl = gpr_avl_add(avl, box(945), box(1493), NULL);
- avl = remove_int(avl, 355);
- avl = remove_int(avl, 144);
- avl = gpr_avl_add(avl, box(229), box(1496), NULL);
- avl = gpr_avl_add(avl, box(237), box(1497), NULL);
- avl = remove_int(avl, 471);
- avl = remove_int(avl, 901);
- avl = gpr_avl_add(avl, box(905), box(1500), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(552), box(1506), NULL);
- avl = gpr_avl_add(avl, box(30), box(1507), NULL);
- avl = gpr_avl_add(avl, box(445), box(1508), NULL);
- avl = remove_int(avl, 785);
- avl = remove_int(avl, 185);
- avl = gpr_avl_add(avl, box(405), box(1511), NULL);
- avl = gpr_avl_add(avl, box(733), box(1512), NULL);
- avl = gpr_avl_add(avl, box(573), box(1513), NULL);
- avl = gpr_avl_add(avl, box(492), box(1514), NULL);
- avl = gpr_avl_add(avl, box(343), box(1515), NULL);
- avl = gpr_avl_add(avl, box(527), box(1516), NULL);
- avl = gpr_avl_add(avl, box(596), box(1517), NULL);
- avl = gpr_avl_add(avl, box(519), box(1518), NULL);
- avl = remove_int(avl, 243);
- avl = remove_int(avl, 722);
- avl = gpr_avl_add(avl, box(772), box(1521), NULL);
- avl = remove_int(avl, 152);
- avl = remove_int(avl, 305);
- avl = gpr_avl_add(avl, box(754), box(1524), NULL);
- avl = gpr_avl_add(avl, box(373), box(1525), NULL);
- avl = remove_int(avl, 995);
- avl = gpr_avl_add(avl, box(329), box(1527), NULL);
- avl = remove_int(avl, 397);
- avl = gpr_avl_add(avl, box(884), box(1529), NULL);
- avl = remove_int(avl, 329);
- avl = remove_int(avl, 240);
- avl = gpr_avl_add(avl, box(566), box(1532), NULL);
- avl = gpr_avl_add(avl, box(232), box(1533), NULL);
- avl = remove_int(avl, 993);
- avl = gpr_avl_add(avl, box(888), box(1535), NULL);
- avl = remove_int(avl, 242);
- avl = gpr_avl_add(avl, box(941), box(1537), NULL);
- avl = remove_int(avl, 415);
- avl = gpr_avl_add(avl, box(992), box(1539), NULL);
- avl = remove_int(avl, 289);
- avl = gpr_avl_add(avl, box(60), box(1541), NULL);
- avl = gpr_avl_add(avl, box(97), box(1542), NULL);
- avl = remove_int(avl, 965);
- avl = remove_int(avl, 267);
- avl = remove_int(avl, 360);
- avl = gpr_avl_add(avl, box(5), box(1546), NULL);
- avl = remove_int(avl, 429);
- avl = gpr_avl_add(avl, box(412), box(1548), NULL);
- avl = remove_int(avl, 632);
- avl = remove_int(avl, 113);
- avl = gpr_avl_add(avl, box(48), box(1551), NULL);
- avl = gpr_avl_add(avl, box(108), box(1552), NULL);
- avl = gpr_avl_add(avl, box(750), box(1553), NULL);
- avl = remove_int(avl, 188);
- avl = gpr_avl_add(avl, box(668), box(1555), NULL);
- avl = remove_int(avl, 37);
- avl = remove_int(avl, 737);
- avl = gpr_avl_add(avl, box(93), box(1558), NULL);
- avl = gpr_avl_add(avl, box(628), box(1559), NULL);
- avl = gpr_avl_add(avl, box(480), box(1560), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(469), box(1567), NULL);
- avl = remove_int(avl, 349);
- avl = gpr_avl_add(avl, box(768), box(1569), NULL);
- avl = gpr_avl_add(avl, box(915), box(1570), NULL);
- avl = remove_int(avl, 1014);
- avl = gpr_avl_add(avl, box(117), box(1572), NULL);
- avl = remove_int(avl, 62);
- avl = gpr_avl_add(avl, box(382), box(1574), NULL);
- avl = remove_int(avl, 571);
- avl = gpr_avl_add(avl, box(655), box(1576), NULL);
- avl = gpr_avl_add(avl, box(323), box(1577), NULL);
- avl = remove_int(avl, 869);
- avl = remove_int(avl, 151);
- avl = gpr_avl_add(avl, box(1019), box(1580), NULL);
- avl = gpr_avl_add(avl, box(984), box(1581), NULL);
- avl = gpr_avl_add(avl, box(870), box(1582), NULL);
- avl = gpr_avl_add(avl, box(376), box(1583), NULL);
- avl = remove_int(avl, 625);
- avl = gpr_avl_add(avl, box(733), box(1585), NULL);
- avl = remove_int(avl, 532);
- avl = remove_int(avl, 444);
- avl = gpr_avl_add(avl, box(428), box(1588), NULL);
- avl = gpr_avl_add(avl, box(860), box(1589), NULL);
- avl = gpr_avl_add(avl, box(173), box(1590), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(639), box(1596), NULL);
- avl = remove_int(avl, 431);
- avl = gpr_avl_add(avl, box(993), box(1598), NULL);
- avl = remove_int(avl, 681);
- avl = remove_int(avl, 927);
- avl = gpr_avl_add(avl, box(87), box(1601), NULL);
- avl = gpr_avl_add(avl, box(91), box(1602), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(951), box(1609), NULL);
- avl = gpr_avl_add(avl, box(146), box(1610), NULL);
- avl = gpr_avl_add(avl, box(482), box(1611), NULL);
- avl = gpr_avl_add(avl, box(71), box(1612), NULL);
- avl = remove_int(avl, 246);
- avl = remove_int(avl, 696);
- avl = gpr_avl_add(avl, box(636), box(1615), NULL);
- avl = gpr_avl_add(avl, box(295), box(1616), NULL);
- avl = remove_int(avl, 11);
- avl = remove_int(avl, 231);
- avl = gpr_avl_add(avl, box(905), box(1619), NULL);
- avl = gpr_avl_add(avl, box(993), box(1620), NULL);
- avl = gpr_avl_add(avl, box(433), box(1621), NULL);
- avl = gpr_avl_add(avl, box(117), box(1622), NULL);
- avl = gpr_avl_add(avl, box(467), box(1623), NULL);
- avl = remove_int(avl, 419);
- avl = gpr_avl_add(avl, box(179), box(1625), NULL);
- avl = remove_int(avl, 926);
- avl = remove_int(avl, 326);
- avl = gpr_avl_add(avl, box(551), box(1628), NULL);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 476);
- avl = remove_int(avl, 823);
- avl = gpr_avl_add(avl, box(350), box(1632), NULL);
- avl = gpr_avl_add(avl, box(133), box(1633), NULL);
- avl = remove_int(avl, 906);
- avl = gpr_avl_add(avl, box(827), box(1635), NULL);
- avl = gpr_avl_add(avl, box(201), box(1636), NULL);
- avl = remove_int(avl, 124);
- avl = remove_int(avl, 662);
- avl = gpr_avl_add(avl, box(314), box(1639), NULL);
- avl = gpr_avl_add(avl, box(986), box(1640), NULL);
- avl = gpr_avl_add(avl, box(622), box(1641), NULL);
- avl = remove_int(avl, 130);
- avl = gpr_avl_add(avl, box(861), box(1643), NULL);
- avl = remove_int(avl, 497);
- avl = remove_int(avl, 905);
- avl = gpr_avl_add(avl, box(502), box(1646), NULL);
- avl = remove_int(avl, 721);
- avl = gpr_avl_add(avl, box(514), box(1648), NULL);
- avl = gpr_avl_add(avl, box(410), box(1649), NULL);
- avl = remove_int(avl, 869);
- avl = remove_int(avl, 247);
- avl = gpr_avl_add(avl, box(450), box(1652), NULL);
- avl = remove_int(avl, 364);
- avl = gpr_avl_add(avl, box(963), box(1654), NULL);
- avl = gpr_avl_add(avl, box(146), box(1655), NULL);
- avl = remove_int(avl, 147);
- avl = remove_int(avl, 789);
- avl = gpr_avl_add(avl, box(693), box(1658), NULL);
- avl = gpr_avl_add(avl, box(959), box(1659), NULL);
- avl = remove_int(avl, 478);
- avl = gpr_avl_add(avl, box(116), box(1661), NULL);
- avl = gpr_avl_add(avl, box(520), box(1662), NULL);
- avl = gpr_avl_add(avl, box(809), box(1663), NULL);
- avl = gpr_avl_add(avl, box(667), box(1664), NULL);
- avl = gpr_avl_add(avl, box(406), box(1665), NULL);
- avl = remove_int(avl, 409);
- avl = gpr_avl_add(avl, box(558), box(1667), NULL);
- avl = gpr_avl_add(avl, box(0), box(1668), NULL);
- avl = gpr_avl_add(avl, box(948), box(1669), NULL);
- avl = gpr_avl_add(avl, box(576), box(1670), NULL);
- avl = remove_int(avl, 864);
- avl = remove_int(avl, 840);
- avl = remove_int(avl, 1001);
- avl = gpr_avl_add(avl, box(232), box(1674), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(648), box(1680), NULL);
- avl = gpr_avl_add(avl, box(761), box(1681), NULL);
- avl = remove_int(avl, 293);
- avl = remove_int(avl, 893);
- avl = gpr_avl_add(avl, box(194), box(1684), NULL);
- avl = remove_int(avl, 233);
- avl = gpr_avl_add(avl, box(888), box(1686), NULL);
- 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), NULL);
- avl = remove_int(avl, 634);
- avl = remove_int(avl, 335);
- avl = gpr_avl_add(avl, box(718), box(1694), NULL);
- avl = gpr_avl_add(avl, box(463), box(1695), NULL);
- avl = gpr_avl_add(avl, box(233), box(1696), NULL);
- 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), NULL);
- avl = remove_int(avl, 329);
- avl = gpr_avl_add(avl, box(716), box(1705), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(212), box(1714), NULL);
- avl = gpr_avl_add(avl, box(266), box(1715), NULL);
- avl = gpr_avl_add(avl, box(238), box(1716), NULL);
- avl = remove_int(avl, 153);
- avl = gpr_avl_add(avl, box(585), box(1718), NULL);
- avl = remove_int(avl, 121);
- avl = gpr_avl_add(avl, box(534), box(1720), NULL);
- avl = remove_int(avl, 579);
- avl = gpr_avl_add(avl, box(127), box(1722), NULL);
- avl = gpr_avl_add(avl, box(399), box(1723), NULL);
- avl = remove_int(avl, 417);
- avl = gpr_avl_add(avl, box(978), box(1725), NULL);
- avl = gpr_avl_add(avl, box(768), box(1726), NULL);
- avl = remove_int(avl, 985);
- avl = gpr_avl_add(avl, box(536), box(1728), NULL);
- avl = gpr_avl_add(avl, box(449), box(1729), NULL);
- avl = gpr_avl_add(avl, box(586), box(1730), NULL);
- avl = remove_int(avl, 998);
- avl = remove_int(avl, 394);
- avl = remove_int(avl, 141);
- avl = gpr_avl_add(avl, box(889), box(1734), NULL);
- avl = gpr_avl_add(avl, box(871), box(1735), NULL);
- avl = gpr_avl_add(avl, box(76), box(1736), NULL);
- avl = gpr_avl_add(avl, box(549), box(1737), NULL);
- avl = gpr_avl_add(avl, box(757), box(1738), NULL);
- avl = remove_int(avl, 908);
- avl = gpr_avl_add(avl, box(789), box(1740), NULL);
- avl = remove_int(avl, 224);
- avl = gpr_avl_add(avl, box(407), box(1742), NULL);
- avl = gpr_avl_add(avl, box(381), box(1743), NULL);
- avl = gpr_avl_add(avl, box(561), box(1744), NULL);
- avl = gpr_avl_add(avl, box(667), box(1745), NULL);
- avl = gpr_avl_add(avl, box(522), box(1746), NULL);
- avl = gpr_avl_add(avl, box(948), box(1747), NULL);
- avl = remove_int(avl, 770);
- avl = gpr_avl_add(avl, box(872), box(1749), NULL);
- avl = gpr_avl_add(avl, box(327), box(1750), NULL);
- avl = remove_int(avl, 10);
- avl = gpr_avl_add(avl, box(122), box(1752), NULL);
- avl = remove_int(avl, 606);
- avl = gpr_avl_add(avl, box(485), box(1754), NULL);
- avl = remove_int(avl, 6);
- avl = gpr_avl_add(avl, box(329), box(1756), NULL);
- avl = gpr_avl_add(avl, box(783), box(1757), NULL);
- avl = remove_int(avl, 416);
- avl = gpr_avl_add(avl, box(656), box(1759), NULL);
- avl = gpr_avl_add(avl, box(971), box(1760), NULL);
- avl = gpr_avl_add(avl, box(77), box(1761), NULL);
- avl = gpr_avl_add(avl, box(942), box(1762), NULL);
- avl = remove_int(avl, 361);
- avl = gpr_avl_add(avl, box(66), box(1764), NULL);
- avl = gpr_avl_add(avl, box(299), box(1765), NULL);
- avl = gpr_avl_add(avl, box(929), box(1766), NULL);
- avl = gpr_avl_add(avl, box(797), box(1767), NULL);
- avl = remove_int(avl, 869);
- avl = remove_int(avl, 907);
- avl = gpr_avl_add(avl, box(870), box(1770), NULL);
- avl = remove_int(avl, 580);
- avl = remove_int(avl, 120);
- avl = gpr_avl_add(avl, box(913), box(1773), NULL);
- avl = remove_int(avl, 480);
- avl = gpr_avl_add(avl, box(489), box(1775), NULL);
- avl = remove_int(avl, 845);
- avl = gpr_avl_add(avl, box(896), box(1777), NULL);
- avl = remove_int(avl, 567);
- avl = remove_int(avl, 427);
- avl = gpr_avl_add(avl, box(443), box(1780), NULL);
- avl = gpr_avl_add(avl, box(3), box(1781), NULL);
- avl = remove_int(avl, 12);
- avl = gpr_avl_add(avl, box(376), box(1783), NULL);
- avl = gpr_avl_add(avl, box(155), box(1784), NULL);
- avl = gpr_avl_add(avl, box(188), box(1785), NULL);
- avl = gpr_avl_add(avl, box(149), box(1786), NULL);
- avl = gpr_avl_add(avl, box(178), box(1787), NULL);
- avl = remove_int(avl, 84);
- avl = gpr_avl_add(avl, box(805), box(1789), NULL);
- avl = gpr_avl_add(avl, box(612), box(1790), NULL);
- avl = remove_int(avl, 991);
- avl = gpr_avl_add(avl, box(837), box(1792), NULL);
- avl = remove_int(avl, 173);
- avl = remove_int(avl, 72);
- avl = gpr_avl_add(avl, box(1014), box(1795), NULL);
- avl = remove_int(avl, 303);
- avl = gpr_avl_add(avl, box(865), box(1797), NULL);
- avl = gpr_avl_add(avl, box(793), box(1798), NULL);
- avl = remove_int(avl, 173);
- avl = remove_int(avl, 477);
- avl = gpr_avl_add(avl, box(950), box(1801), NULL);
- avl = gpr_avl_add(avl, box(105), box(1802), NULL);
- avl = gpr_avl_add(avl, box(895), box(1803), NULL);
- avl = gpr_avl_add(avl, box(171), box(1804), NULL);
- avl = gpr_avl_add(avl, box(753), box(1805), NULL);
- avl = gpr_avl_add(avl, box(946), box(1806), NULL);
- avl = remove_int(avl, 194);
- avl = remove_int(avl, 559);
- avl = remove_int(avl, 116);
- avl = gpr_avl_add(avl, box(968), box(1810), NULL);
- avl = remove_int(avl, 124);
- avl = remove_int(avl, 99);
- avl = gpr_avl_add(avl, box(563), box(1813), NULL);
- avl = remove_int(avl, 182);
- avl = gpr_avl_add(avl, box(816), box(1815), NULL);
- avl = remove_int(avl, 73);
- avl = remove_int(avl, 261);
- avl = gpr_avl_add(avl, box(847), box(1818), NULL);
- avl = gpr_avl_add(avl, box(368), box(1819), NULL);
- avl = gpr_avl_add(avl, box(808), box(1820), NULL);
- avl = gpr_avl_add(avl, box(779), box(1821), NULL);
- avl = remove_int(avl, 818);
- avl = gpr_avl_add(avl, box(466), box(1823), NULL);
- avl = remove_int(avl, 316);
- avl = gpr_avl_add(avl, box(986), box(1825), NULL);
- avl = gpr_avl_add(avl, box(688), box(1826), NULL);
- avl = gpr_avl_add(avl, box(509), box(1827), NULL);
- avl = gpr_avl_add(avl, box(51), box(1828), NULL);
- avl = remove_int(avl, 655);
- avl = remove_int(avl, 785);
- avl = remove_int(avl, 893);
- avl = gpr_avl_add(avl, box(167), box(1832), NULL);
- avl = remove_int(avl, 13);
- avl = remove_int(avl, 263);
- avl = gpr_avl_add(avl, box(1009), box(1835), NULL);
- 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), NULL);
- avl = remove_int(avl, 267);
- avl = gpr_avl_add(avl, box(676), box(1842), NULL);
- avl = gpr_avl_add(avl, box(231), box(1843), NULL);
- avl = gpr_avl_add(avl, box(824), box(1844), NULL);
- avl = remove_int(avl, 961);
- avl = gpr_avl_add(avl, box(311), box(1846), NULL);
- avl = gpr_avl_add(avl, box(420), box(1847), NULL);
- avl = gpr_avl_add(avl, box(960), box(1848), NULL);
- avl = gpr_avl_add(avl, box(468), box(1849), NULL);
- avl = gpr_avl_add(avl, box(815), box(1850), NULL);
- avl = remove_int(avl, 247);
- avl = remove_int(avl, 194);
- avl = gpr_avl_add(avl, box(546), box(1853), NULL);
- avl = remove_int(avl, 222);
- avl = remove_int(avl, 914);
- avl = remove_int(avl, 741);
- avl = gpr_avl_add(avl, box(470), box(1857), NULL);
- avl = gpr_avl_add(avl, box(933), box(1858), NULL);
- avl = gpr_avl_add(avl, box(97), box(1859), NULL);
- avl = remove_int(avl, 564);
- avl = remove_int(avl, 295);
- avl = gpr_avl_add(avl, box(864), box(1862), NULL);
- avl = remove_int(avl, 329);
- avl = gpr_avl_add(avl, box(124), box(1864), NULL);
- avl = gpr_avl_add(avl, box(1000), box(1865), NULL);
- avl = gpr_avl_add(avl, box(228), box(1866), NULL);
- avl = gpr_avl_add(avl, box(187), box(1867), NULL);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 306);
- avl = remove_int(avl, 884);
- avl = gpr_avl_add(avl, box(449), box(1871), NULL);
- avl = gpr_avl_add(avl, box(353), box(1872), NULL);
- avl = gpr_avl_add(avl, box(994), box(1873), NULL);
- avl = gpr_avl_add(avl, box(596), box(1874), NULL);
- avl = gpr_avl_add(avl, box(996), box(1875), NULL);
- avl = gpr_avl_add(avl, box(101), box(1876), NULL);
- avl = gpr_avl_add(avl, box(1012), box(1877), NULL);
- avl = gpr_avl_add(avl, box(982), box(1878), NULL);
- avl = gpr_avl_add(avl, box(742), box(1879), NULL);
- avl = remove_int(avl, 92);
- avl = remove_int(avl, 1022);
- avl = gpr_avl_add(avl, box(941), box(1882), NULL);
- avl = remove_int(avl, 742);
- avl = remove_int(avl, 919);
- avl = gpr_avl_add(avl, box(588), box(1885), NULL);
- avl = remove_int(avl, 221);
- avl = gpr_avl_add(avl, box(356), box(1887), NULL);
- avl = gpr_avl_add(avl, box(932), box(1888), NULL);
- avl = remove_int(avl, 837);
- avl = gpr_avl_add(avl, box(394), box(1890), NULL);
- avl = gpr_avl_add(avl, box(642), box(1891), NULL);
- avl = gpr_avl_add(avl, box(52), box(1892), NULL);
- avl = gpr_avl_add(avl, box(437), box(1893), NULL);
- avl = gpr_avl_add(avl, box(948), box(1894), NULL);
- avl = gpr_avl_add(avl, box(93), box(1895), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(952), box(1901), NULL);
- avl = gpr_avl_add(avl, box(510), box(1902), NULL);
- avl = remove_int(avl, 876);
- avl = remove_int(avl, 612);
- avl = gpr_avl_add(avl, box(923), box(1905), NULL);
- avl = gpr_avl_add(avl, box(475), box(1906), NULL);
- avl = remove_int(avl, 478);
- avl = remove_int(avl, 148);
- avl = gpr_avl_add(avl, box(538), box(1909), NULL);
- avl = remove_int(avl, 47);
- avl = gpr_avl_add(avl, box(89), box(1911), NULL);
- avl = remove_int(avl, 723);
- avl = gpr_avl_add(avl, box(687), box(1913), NULL);
- avl = gpr_avl_add(avl, box(480), box(1914), NULL);
- avl = gpr_avl_add(avl, box(149), box(1915), NULL);
- avl = remove_int(avl, 68);
- avl = remove_int(avl, 862);
- avl = remove_int(avl, 363);
- avl = gpr_avl_add(avl, box(996), box(1919), NULL);
- avl = remove_int(avl, 380);
- avl = gpr_avl_add(avl, box(957), box(1921), NULL);
- avl = remove_int(avl, 413);
- avl = gpr_avl_add(avl, box(360), box(1923), NULL);
- avl = gpr_avl_add(avl, box(304), box(1924), NULL);
- avl = gpr_avl_add(avl, box(634), box(1925), NULL);
- avl = gpr_avl_add(avl, box(506), box(1926), NULL);
- avl = remove_int(avl, 248);
- avl = gpr_avl_add(avl, box(124), box(1928), NULL);
- avl = gpr_avl_add(avl, box(181), box(1929), NULL);
- avl = remove_int(avl, 507);
- avl = gpr_avl_add(avl, box(141), box(1931), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(906), box(1937), NULL);
- avl = gpr_avl_add(avl, box(44), box(1938), NULL);
- avl = remove_int(avl, 949);
- avl = remove_int(avl, 117);
- avl = gpr_avl_add(avl, box(700), box(1941), NULL);
- avl = gpr_avl_add(avl, box(258), box(1942), NULL);
- avl = remove_int(avl, 828);
- avl = gpr_avl_add(avl, box(860), box(1944), NULL);
- avl = gpr_avl_add(avl, box(987), box(1945), NULL);
- avl = gpr_avl_add(avl, box(316), box(1946), NULL);
- avl = gpr_avl_add(avl, box(919), box(1947), NULL);
- avl = remove_int(avl, 84);
- avl = gpr_avl_add(avl, box(473), box(1949), NULL);
- avl = remove_int(avl, 127);
- avl = remove_int(avl, 829);
- avl = remove_int(avl, 829);
- avl = gpr_avl_add(avl, box(488), box(1953), NULL);
- avl = gpr_avl_add(avl, box(954), box(1954), NULL);
- avl = remove_int(avl, 198);
- avl = remove_int(avl, 972);
- avl = remove_int(avl, 670);
- avl = gpr_avl_add(avl, box(822), box(1958), NULL);
- avl = remove_int(avl, 589);
- avl = remove_int(avl, 459);
- avl = gpr_avl_add(avl, box(1003), box(1961), NULL);
- avl = gpr_avl_add(avl, box(657), box(1962), NULL);
- avl = gpr_avl_add(avl, box(477), box(1963), NULL);
- avl = gpr_avl_add(avl, box(923), box(1964), NULL);
- avl = remove_int(avl, 496);
- avl = remove_int(avl, 99);
- avl = gpr_avl_add(avl, box(127), box(1967), NULL);
- avl = gpr_avl_add(avl, box(1013), box(1968), NULL);
- avl = gpr_avl_add(avl, box(778), box(1969), NULL);
- 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), NULL);
- 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), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(412), box(1986), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(408), box(1992), NULL);
- avl = gpr_avl_add(avl, box(841), box(1993), NULL);
- avl = remove_int(avl, 593);
- avl = gpr_avl_add(avl, box(582), box(1995), NULL);
- avl = gpr_avl_add(avl, box(597), box(1996), NULL);
- avl = remove_int(avl, 49);
- avl = remove_int(avl, 835);
- avl = gpr_avl_add(avl, box(417), box(1999), NULL);
- avl = gpr_avl_add(avl, box(191), box(2000), NULL);
- avl = remove_int(avl, 406);
- avl = gpr_avl_add(avl, box(30), box(2002), NULL);
- avl = remove_int(avl, 841);
- avl = remove_int(avl, 50);
- avl = gpr_avl_add(avl, box(967), box(2005), NULL);
- avl = gpr_avl_add(avl, box(849), box(2006), NULL);
- avl = remove_int(avl, 608);
- avl = gpr_avl_add(avl, box(306), box(2008), NULL);
- avl = remove_int(avl, 779);
- avl = gpr_avl_add(avl, box(897), box(2010), NULL);
- avl = gpr_avl_add(avl, box(147), box(2011), NULL);
- avl = remove_int(avl, 982);
- avl = gpr_avl_add(avl, box(470), box(2013), NULL);
- avl = remove_int(avl, 951);
- avl = gpr_avl_add(avl, box(388), box(2015), NULL);
- 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), NULL);
- avl = remove_int(avl, 671);
- avl = gpr_avl_add(avl, box(1020), box(2022), NULL);
- avl = remove_int(avl, 277);
- avl = gpr_avl_add(avl, box(681), box(2024), NULL);
- avl = gpr_avl_add(avl, box(179), box(2025), NULL);
- avl = gpr_avl_add(avl, box(370), box(2026), NULL);
- avl = gpr_avl_add(avl, box(0), box(2027), NULL);
- avl = remove_int(avl, 523);
- avl = gpr_avl_add(avl, box(99), box(2029), NULL);
- avl = gpr_avl_add(avl, box(334), box(2030), NULL);
- avl = gpr_avl_add(avl, box(569), box(2031), NULL);
- avl = gpr_avl_add(avl, box(257), box(2032), NULL);
- avl = remove_int(avl, 572);
- avl = gpr_avl_add(avl, box(805), box(2034), NULL);
- avl = gpr_avl_add(avl, box(143), box(2035), NULL);
- avl = gpr_avl_add(avl, box(670), box(2036), NULL);
- avl = remove_int(avl, 42);
- avl = gpr_avl_add(avl, box(46), box(2038), NULL);
- avl = remove_int(avl, 970);
- avl = gpr_avl_add(avl, box(353), box(2040), NULL);
- avl = remove_int(avl, 258);
- avl = gpr_avl_add(avl, box(451), box(2042), NULL);
- avl = gpr_avl_add(avl, box(28), box(2043), NULL);
- avl = gpr_avl_add(avl, box(729), box(2044), NULL);
- avl = gpr_avl_add(avl, box(401), box(2045), NULL);
- avl = gpr_avl_add(avl, box(614), box(2046), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(980), box(2052), NULL);
- avl = gpr_avl_add(avl, box(990), box(2053), NULL);
- avl = gpr_avl_add(avl, box(355), box(2054), NULL);
- avl = remove_int(avl, 730);
- avl = remove_int(avl, 37);
- avl = gpr_avl_add(avl, box(407), box(2057), NULL);
- avl = gpr_avl_add(avl, box(222), box(2058), NULL);
- avl = gpr_avl_add(avl, box(439), box(2059), NULL);
- avl = gpr_avl_add(avl, box(563), box(2060), NULL);
- avl = remove_int(avl, 992);
- avl = remove_int(avl, 786);
- avl = gpr_avl_add(avl, box(1), box(2063), NULL);
- avl = gpr_avl_add(avl, box(473), box(2064), NULL);
- avl = gpr_avl_add(avl, box(992), box(2065), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(35), box(2071), NULL);
- avl = remove_int(avl, 843);
- avl = gpr_avl_add(avl, box(855), box(2073), NULL);
- avl = remove_int(avl, 878);
- avl = gpr_avl_add(avl, box(993), box(2075), NULL);
- avl = gpr_avl_add(avl, box(87), box(2076), NULL);
- avl = gpr_avl_add(avl, box(572), box(2077), NULL);
- avl = remove_int(avl, 896);
- avl = gpr_avl_add(avl, box(849), box(2079), NULL);
- avl = remove_int(avl, 597);
- avl = gpr_avl_add(avl, box(472), box(2081), NULL);
- avl = remove_int(avl, 778);
- avl = remove_int(avl, 934);
- avl = remove_int(avl, 314);
- avl = gpr_avl_add(avl, box(101), box(2085), NULL);
- avl = remove_int(avl, 938);
- avl = remove_int(avl, 1010);
- avl = gpr_avl_add(avl, box(579), box(2088), NULL);
- avl = remove_int(avl, 798);
- avl = remove_int(avl, 88);
- avl = gpr_avl_add(avl, box(851), box(2091), NULL);
- avl = remove_int(avl, 705);
- avl = gpr_avl_add(avl, box(26), box(2093), NULL);
- avl = remove_int(avl, 973);
- avl = gpr_avl_add(avl, box(923), box(2095), NULL);
- avl = remove_int(avl, 668);
- avl = gpr_avl_add(avl, box(310), box(2097), NULL);
- avl = gpr_avl_add(avl, box(269), box(2098), NULL);
- avl = remove_int(avl, 173);
- avl = gpr_avl_add(avl, box(279), box(2100), NULL);
- avl = remove_int(avl, 203);
- avl = gpr_avl_add(avl, box(411), box(2102), NULL);
- avl = remove_int(avl, 950);
- avl = gpr_avl_add(avl, box(6), box(2104), NULL);
- avl = remove_int(avl, 400);
- avl = remove_int(avl, 468);
- avl = remove_int(avl, 271);
- avl = gpr_avl_add(avl, box(627), box(2108), NULL);
- 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), NULL);
- avl = remove_int(avl, 194);
- avl = remove_int(avl, 18);
- avl = gpr_avl_add(avl, box(727), box(2120), NULL);
- avl = remove_int(avl, 295);
- avl = gpr_avl_add(avl, box(645), box(2122), NULL);
- avl = remove_int(avl, 321);
- avl = remove_int(avl, 863);
- avl = gpr_avl_add(avl, box(824), box(2125), NULL);
- avl = gpr_avl_add(avl, box(651), box(2126), NULL);
- avl = gpr_avl_add(avl, box(804), box(2127), NULL);
- avl = remove_int(avl, 307);
- avl = gpr_avl_add(avl, box(867), box(2129), NULL);
- avl = remove_int(avl, 384);
- avl = gpr_avl_add(avl, box(819), box(2131), NULL);
- avl = remove_int(avl, 674);
- avl = gpr_avl_add(avl, box(76), box(2133), NULL);
- avl = remove_int(avl, 898);
- avl = gpr_avl_add(avl, box(45), box(2135), NULL);
- avl = gpr_avl_add(avl, box(512), box(2136), NULL);
- 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), NULL);
- avl = remove_int(avl, 509);
- avl = remove_int(avl, 301);
- avl = gpr_avl_add(avl, box(861), box(2146), NULL);
- avl = gpr_avl_add(avl, box(918), box(2147), NULL);
- avl = remove_int(avl, 992);
- avl = gpr_avl_add(avl, box(356), box(2149), NULL);
- avl = remove_int(avl, 64);
- avl = remove_int(avl, 444);
- avl = remove_int(avl, 741);
- avl = gpr_avl_add(avl, box(710), box(2153), NULL);
- avl = gpr_avl_add(avl, box(264), box(2154), NULL);
- avl = remove_int(avl, 347);
- avl = remove_int(avl, 250);
- avl = gpr_avl_add(avl, box(82), box(2157), NULL);
- avl = gpr_avl_add(avl, box(571), box(2158), NULL);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 622);
- avl = gpr_avl_add(avl, box(950), box(2161), NULL);
- avl = gpr_avl_add(avl, box(94), box(2162), NULL);
- avl = remove_int(avl, 970);
- avl = gpr_avl_add(avl, box(815), box(2164), NULL);
- avl = remove_int(avl, 930);
- avl = remove_int(avl, 703);
- avl = gpr_avl_add(avl, box(432), box(2167), NULL);
- avl = remove_int(avl, 544);
- avl = gpr_avl_add(avl, box(21), box(2169), NULL);
- avl = gpr_avl_add(avl, box(186), box(2170), NULL);
- avl = remove_int(avl, 143);
- avl = gpr_avl_add(avl, box(425), box(2172), NULL);
- avl = remove_int(avl, 769);
- avl = gpr_avl_add(avl, box(656), box(2174), NULL);
- avl = remove_int(avl, 29);
- avl = gpr_avl_add(avl, box(464), box(2176), NULL);
- avl = remove_int(avl, 713);
- avl = gpr_avl_add(avl, box(800), box(2178), NULL);
- avl = remove_int(avl, 621);
- avl = gpr_avl_add(avl, box(962), box(2180), NULL);
- avl = remove_int(avl, 448);
- avl = gpr_avl_add(avl, box(878), box(2182), NULL);
- avl = remove_int(avl, 39);
- avl = remove_int(avl, 999);
- avl = gpr_avl_add(avl, box(182), box(2185), NULL);
- avl = gpr_avl_add(avl, box(429), box(2186), NULL);
- avl = gpr_avl_add(avl, box(598), box(2187), NULL);
- avl = remove_int(avl, 551);
- avl = gpr_avl_add(avl, box(827), box(2189), NULL);
- avl = gpr_avl_add(avl, box(809), box(2190), NULL);
- avl = remove_int(avl, 438);
- avl = remove_int(avl, 811);
- avl = gpr_avl_add(avl, box(808), box(2193), NULL);
- avl = gpr_avl_add(avl, box(788), box(2194), NULL);
- avl = remove_int(avl, 156);
- avl = gpr_avl_add(avl, box(933), box(2196), NULL);
- avl = gpr_avl_add(avl, box(344), box(2197), NULL);
- avl = remove_int(avl, 460);
- avl = gpr_avl_add(avl, box(161), box(2199), NULL);
- avl = gpr_avl_add(avl, box(444), box(2200), NULL);
- avl = remove_int(avl, 597);
- avl = remove_int(avl, 668);
- avl = gpr_avl_add(avl, box(703), box(2203), NULL);
- avl = remove_int(avl, 515);
- avl = gpr_avl_add(avl, box(380), box(2205), NULL);
- avl = gpr_avl_add(avl, box(338), box(2206), NULL);
- 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), NULL);
- avl = remove_int(avl, 450);
- avl = gpr_avl_add(avl, box(411), box(2213), NULL);
- avl = gpr_avl_add(avl, box(117), box(2214), NULL);
- avl = gpr_avl_add(avl, box(322), box(2215), NULL);
- avl = gpr_avl_add(avl, box(915), box(2216), NULL);
- avl = gpr_avl_add(avl, box(410), box(2217), NULL);
- avl = gpr_avl_add(avl, box(66), box(2218), NULL);
- avl = remove_int(avl, 756);
- avl = remove_int(avl, 596);
- avl = gpr_avl_add(avl, box(882), box(2221), NULL);
- avl = gpr_avl_add(avl, box(930), box(2222), NULL);
- avl = gpr_avl_add(avl, box(36), box(2223), NULL);
- avl = remove_int(avl, 742);
- avl = gpr_avl_add(avl, box(539), box(2225), NULL);
- avl = gpr_avl_add(avl, box(596), box(2226), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(493), box(2233), NULL);
- avl = gpr_avl_add(avl, box(839), box(2234), NULL);
- avl = remove_int(avl, 774);
- avl = gpr_avl_add(avl, box(337), box(2236), NULL);
- avl = remove_int(avl, 322);
- avl = gpr_avl_add(avl, box(16), box(2238), NULL);
- 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), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(138), box(2249), NULL);
- avl = gpr_avl_add(avl, box(437), box(2250), NULL);
- avl = gpr_avl_add(avl, box(275), box(2251), NULL);
- avl = remove_int(avl, 520);
- avl = gpr_avl_add(avl, box(1019), box(2253), NULL);
- avl = remove_int(avl, 955);
- avl = gpr_avl_add(avl, box(270), box(2255), NULL);
- avl = remove_int(avl, 680);
- avl = remove_int(avl, 698);
- avl = gpr_avl_add(avl, box(735), box(2258), NULL);
- avl = gpr_avl_add(avl, box(400), box(2259), NULL);
- avl = remove_int(avl, 991);
- avl = gpr_avl_add(avl, box(263), box(2261), NULL);
- avl = remove_int(avl, 704);
- avl = gpr_avl_add(avl, box(757), box(2263), NULL);
- avl = remove_int(avl, 194);
- avl = remove_int(avl, 616);
- avl = remove_int(avl, 784);
- avl = gpr_avl_add(avl, box(382), box(2267), NULL);
- avl = gpr_avl_add(avl, box(464), box(2268), NULL);
- avl = gpr_avl_add(avl, box(817), box(2269), NULL);
- avl = remove_int(avl, 445);
- avl = gpr_avl_add(avl, box(412), box(2271), NULL);
- avl = remove_int(avl, 525);
- avl = gpr_avl_add(avl, box(299), box(2273), NULL);
- avl = gpr_avl_add(avl, box(464), box(2274), NULL);
- avl = gpr_avl_add(avl, box(715), box(2275), NULL);
- avl = remove_int(avl, 58);
- avl = remove_int(avl, 218);
- avl = gpr_avl_add(avl, box(961), box(2278), NULL);
- avl = gpr_avl_add(avl, box(491), box(2279), NULL);
- avl = remove_int(avl, 846);
- avl = gpr_avl_add(avl, box(762), box(2281), NULL);
- avl = remove_int(avl, 974);
- avl = remove_int(avl, 887);
- avl = gpr_avl_add(avl, box(498), box(2284), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(1021), box(2290), NULL);
- avl = remove_int(avl, 155);
- avl = remove_int(avl, 128);
- avl = gpr_avl_add(avl, box(819), box(2293), NULL);
- avl = gpr_avl_add(avl, box(324), box(2294), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(474), box(2301), NULL);
- avl = gpr_avl_add(avl, box(719), box(2302), NULL);
- avl = gpr_avl_add(avl, box(236), box(2303), NULL);
- avl = remove_int(avl, 818);
- avl = gpr_avl_add(avl, box(727), box(2305), NULL);
- avl = remove_int(avl, 892);
- avl = remove_int(avl, 871);
- avl = remove_int(avl, 231);
- avl = gpr_avl_add(avl, box(62), box(2309), NULL);
- avl = gpr_avl_add(avl, box(953), box(2310), NULL);
- avl = remove_int(avl, 701);
- avl = gpr_avl_add(avl, box(193), box(2312), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(751), box(2318), NULL);
- avl = remove_int(avl, 525);
- avl = gpr_avl_add(avl, box(217), box(2320), NULL);
- avl = remove_int(avl, 336);
- avl = gpr_avl_add(avl, box(86), box(2322), NULL);
- avl = gpr_avl_add(avl, box(81), box(2323), NULL);
- avl = gpr_avl_add(avl, box(850), box(2324), NULL);
- avl = remove_int(avl, 872);
- avl = gpr_avl_add(avl, box(402), box(2326), NULL);
- avl = gpr_avl_add(avl, box(54), box(2327), NULL);
- avl = gpr_avl_add(avl, box(980), box(2328), NULL);
- avl = gpr_avl_add(avl, box(845), box(2329), NULL);
- avl = remove_int(avl, 1004);
- avl = remove_int(avl, 273);
- avl = remove_int(avl, 879);
- avl = gpr_avl_add(avl, box(354), box(2333), NULL);
- avl = gpr_avl_add(avl, box(58), box(2334), NULL);
- avl = gpr_avl_add(avl, box(127), box(2335), NULL);
- avl = remove_int(avl, 84);
- avl = gpr_avl_add(avl, box(360), box(2337), NULL);
- 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), NULL);
- avl = remove_int(avl, 558);
- avl = remove_int(avl, 958);
- avl = gpr_avl_add(avl, box(822), box(2345), NULL);
- avl = remove_int(avl, 1004);
- avl = remove_int(avl, 747);
- avl = gpr_avl_add(avl, box(631), box(2348), NULL);
- avl = gpr_avl_add(avl, box(442), box(2349), NULL);
- avl = remove_int(avl, 957);
- avl = remove_int(avl, 964);
- avl = gpr_avl_add(avl, box(10), box(2352), NULL);
- avl = remove_int(avl, 189);
- avl = gpr_avl_add(avl, box(742), box(2354), NULL);
- avl = remove_int(avl, 108);
- avl = gpr_avl_add(avl, box(1014), box(2356), NULL);
- avl = remove_int(avl, 266);
- avl = remove_int(avl, 623);
- avl = remove_int(avl, 697);
- avl = gpr_avl_add(avl, box(180), box(2360), NULL);
- avl = remove_int(avl, 472);
- avl = gpr_avl_add(avl, box(567), box(2362), NULL);
- avl = remove_int(avl, 1020);
- avl = remove_int(avl, 273);
- avl = gpr_avl_add(avl, box(864), box(2365), NULL);
- avl = gpr_avl_add(avl, box(1009), box(2366), NULL);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 81);
- avl = gpr_avl_add(avl, box(653), box(2369), NULL);
- 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), NULL);
- 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), NULL);
- avl = gpr_avl_add(avl, box(925), box(2383), NULL);
- avl = remove_int(avl, 994);
- avl = remove_int(avl, 324);
- avl = gpr_avl_add(avl, box(291), box(2386), NULL);
- avl = remove_int(avl, 94);
- avl = remove_int(avl, 795);
- avl = remove_int(avl, 42);
- avl = gpr_avl_add(avl, box(613), box(2390), NULL);
- avl = remove_int(avl, 289);
- avl = gpr_avl_add(avl, box(980), box(2392), NULL);
- avl = remove_int(avl, 316);
- avl = gpr_avl_add(avl, box(281), box(2394), NULL);
- avl = gpr_avl_add(avl, box(1006), box(2395), NULL);
- avl = remove_int(avl, 776);
- avl = gpr_avl_add(avl, box(108), box(2397), NULL);
- avl = gpr_avl_add(avl, box(918), box(2398), NULL);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 563);
- avl = gpr_avl_add(avl, box(925), box(2401), NULL);
- avl = remove_int(avl, 448);
- avl = remove_int(avl, 198);
- avl = remove_int(avl, 1);
- avl = gpr_avl_add(avl, box(160), box(2405), NULL);
- avl = remove_int(avl, 515);
- avl = gpr_avl_add(avl, box(284), box(2407), NULL);
- avl = gpr_avl_add(avl, box(225), box(2408), NULL);
- avl = remove_int(avl, 304);
- avl = gpr_avl_add(avl, box(714), box(2410), NULL);
- avl = gpr_avl_add(avl, box(708), box(2411), NULL);
- avl = gpr_avl_add(avl, box(624), box(2412), NULL);
- 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), NULL);
- avl = remove_int(avl, 280);
- avl = remove_int(avl, 25);
- avl = remove_int(avl, 633);
- avl = gpr_avl_add(avl, box(897), box(2421), NULL);
- 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), NULL);
- avl = remove_int(avl, 948);
- avl = remove_int(avl, 74);
- avl = remove_int(avl, 571);
- avl = gpr_avl_add(avl, box(486), box(2435), NULL);
- avl = gpr_avl_add(avl, box(285), box(2436), NULL);
- avl = remove_int(avl, 304);
- avl = remove_int(avl, 516);
- avl = gpr_avl_add(avl, box(758), box(2439), NULL);
- avl = gpr_avl_add(avl, box(776), box(2440), NULL);
- avl = remove_int(avl, 696);
- avl = gpr_avl_add(avl, box(104), box(2442), NULL);
- avl = gpr_avl_add(avl, box(700), box(2443), NULL);
- avl = gpr_avl_add(avl, box(114), box(2444), NULL);
- avl = gpr_avl_add(avl, box(567), box(2445), NULL);
- avl = remove_int(avl, 620);
- avl = gpr_avl_add(avl, box(270), box(2447), NULL);
- avl = remove_int(avl, 730);
- avl = gpr_avl_add(avl, box(749), box(2449), NULL);
- avl = gpr_avl_add(avl, box(443), box(2450), NULL);
- avl = remove_int(avl, 457);
- avl = gpr_avl_add(avl, box(571), box(2452), NULL);
- avl = gpr_avl_add(avl, box(626), box(2453), NULL);
- avl = remove_int(avl, 638);
- avl = remove_int(avl, 313);
-
- gpr_avl_unref(avl, NULL);
-}
-
-static void test_stress(int amount_of_stress) {
- int added[1024];
- int i, j;
- int deletions = 0;
- gpr_avl avl;
-
- unsigned seed = (unsigned)time(NULL);
-
- gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed);
-
- srand((unsigned)time(NULL));
- 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), NULL);
- } 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, NULL);
-}
-
-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/support/backoff_test.c b/test/core/support/backoff_test.c
deleted file mode 100644
index 23e3005af0..0000000000
--- a/test/core/support/backoff_test.c
+++ /dev/null
@@ -1,143 +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 "src/core/lib/support/backoff.h"
-
-#include <grpc/support/log.h>
-
-#include "test/core/util/test_config.h"
-
-static void test_constant_backoff(void) {
- gpr_backoff backoff;
- gpr_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */,
- 0.0 /* jitter */, 100 /* min timeout */,
- 1000 /* max timeout */);
-
- gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
- gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
- for (int i = 0; i < 10000; i++) {
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
- now = next;
- }
-}
-
-static void test_min_connect(void) {
- gpr_backoff backoff;
- gpr_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */,
- 0.0 /* jitter */, 200 /* min timeout */,
- 1000 /* max timeout */);
-
- gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
- gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
-}
-
-static void test_no_jitter_backoff(void) {
- gpr_backoff backoff;
- gpr_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */,
- 0.0 /* jitter */, 1 /* min timeout */,
- 513 /* max timeout */);
- // x_1 = 2
- // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
- gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
- gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(6, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(14, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(30, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(62, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(126, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(254, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(510, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1022, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- // Hit the maximum timeout. From this point onwards, retries will increase
- // only by max timeout.
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1535, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2048, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2561, GPR_TIMESPAN), next) == 0);
-}
-
-static void test_jitter_backoff(void) {
- const int64_t initial_timeout = 500;
- const double jitter = 0.1;
- gpr_backoff backoff;
- gpr_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter,
- 100 /* min timeout */, 1000 /* max timeout */);
-
- backoff.rng_state = 0; // force consistent PRNG
-
- gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
- gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 500);
-
- int64_t expected_next_lower_bound =
- (int64_t)((double)initial_timeout * (1 - jitter));
- int64_t expected_next_upper_bound =
- (int64_t)((double)initial_timeout * (1 + jitter));
-
- for (int i = 0; i < 10000; i++) {
- next = gpr_backoff_step(&backoff, now);
-
- // next-now must be within (jitter*100)% of the previous timeout.
- const int64_t timeout_millis = gpr_time_to_millis(gpr_time_sub(next, now));
- GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
- GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
-
- expected_next_lower_bound =
- (int64_t)((double)timeout_millis * (1 - jitter));
- expected_next_upper_bound =
- (int64_t)((double)timeout_millis * (1 + jitter));
- now = next;
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- gpr_time_init();
-
- test_constant_backoff();
- test_min_connect();
- test_no_jitter_backoff();
- test_jitter_backoff();
-
- return 0;
-}
diff --git a/test/core/support/histogram_test.c b/test/core/support/histogram_test.c
deleted file mode 100644
index 0ee5d5cdd1..0000000000
--- a/test/core/support/histogram_test.c
+++ /dev/null
@@ -1,163 +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 <grpc/support/histogram.h>
-#include <grpc/support/log.h>
-
-#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x);
-
-static void test_no_op(void) {
- gpr_histogram_destroy(gpr_histogram_create(0.01, 60e9));
-}
-
-static void expect_percentile(gpr_histogram *h, double percentile,
- double min_expect, double max_expect) {
- double got = gpr_histogram_percentile(h, percentile);
- gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got,
- max_expect);
- GPR_ASSERT(min_expect <= got);
- GPR_ASSERT(got <= max_expect);
-}
-
-static void test_simple(void) {
- gpr_histogram *h;
-
- LOG_TEST("test_simple");
-
- h = gpr_histogram_create(0.01, 60e9);
- gpr_histogram_add(h, 10000);
- gpr_histogram_add(h, 10000);
- gpr_histogram_add(h, 11000);
- gpr_histogram_add(h, 11000);
-
- expect_percentile(h, 50, 10001, 10999);
- GPR_ASSERT(gpr_histogram_mean(h) == 10500);
-
- gpr_histogram_destroy(h);
-}
-
-static void test_percentile(void) {
- gpr_histogram *h;
- double last;
- double i;
- double cur;
-
- LOG_TEST("test_percentile");
-
- h = gpr_histogram_create(0.05, 1e9);
- gpr_histogram_add(h, 2.5);
- gpr_histogram_add(h, 2.5);
- gpr_histogram_add(h, 8);
- gpr_histogram_add(h, 4);
-
- GPR_ASSERT(gpr_histogram_count(h) == 4);
- GPR_ASSERT(gpr_histogram_minimum(h) == 2.5);
- GPR_ASSERT(gpr_histogram_maximum(h) == 8);
- GPR_ASSERT(gpr_histogram_sum(h) == 17);
- GPR_ASSERT(gpr_histogram_sum_of_squares(h) == 92.5);
- GPR_ASSERT(gpr_histogram_mean(h) == 4.25);
- GPR_ASSERT(gpr_histogram_variance(h) == 5.0625);
- GPR_ASSERT(gpr_histogram_stddev(h) == 2.25);
-
- expect_percentile(h, -10, 2.5, 2.5);
- expect_percentile(h, 0, 2.5, 2.5);
- expect_percentile(h, 12.5, 2.5, 2.5);
- expect_percentile(h, 25, 2.5, 2.5);
- expect_percentile(h, 37.5, 2.5, 2.8);
- expect_percentile(h, 50, 3.0, 3.5);
- expect_percentile(h, 62.5, 3.5, 4.5);
- expect_percentile(h, 75, 5, 7.9);
- expect_percentile(h, 100, 8, 8);
- expect_percentile(h, 110, 8, 8);
-
- /* test monotonicity */
- last = 0.0;
- for (i = 0; i < 100.0; i += 0.01) {
- cur = gpr_histogram_percentile(h, i);
- GPR_ASSERT(cur >= last);
- last = cur;
- }
-
- gpr_histogram_destroy(h);
-}
-
-static void test_merge(void) {
- gpr_histogram *h1, *h2;
- double last;
- double i;
- double cur;
-
- LOG_TEST("test_merge");
-
- h1 = gpr_histogram_create(0.05, 1e9);
- gpr_histogram_add(h1, 2.5);
- gpr_histogram_add(h1, 2.5);
- gpr_histogram_add(h1, 8);
- gpr_histogram_add(h1, 4);
-
- h2 = gpr_histogram_create(0.01, 1e9);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 0);
- gpr_histogram_destroy(h2);
-
- h2 = gpr_histogram_create(0.05, 1e10);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 0);
- gpr_histogram_destroy(h2);
-
- h2 = gpr_histogram_create(0.05, 1e9);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 1);
- GPR_ASSERT(gpr_histogram_count(h1) == 4);
- GPR_ASSERT(gpr_histogram_minimum(h1) == 2.5);
- GPR_ASSERT(gpr_histogram_maximum(h1) == 8);
- GPR_ASSERT(gpr_histogram_sum(h1) == 17);
- GPR_ASSERT(gpr_histogram_sum_of_squares(h1) == 92.5);
- GPR_ASSERT(gpr_histogram_mean(h1) == 4.25);
- GPR_ASSERT(gpr_histogram_variance(h1) == 5.0625);
- GPR_ASSERT(gpr_histogram_stddev(h1) == 2.25);
- gpr_histogram_destroy(h2);
-
- h2 = gpr_histogram_create(0.05, 1e9);
- gpr_histogram_add(h2, 7.0);
- gpr_histogram_add(h2, 17.0);
- gpr_histogram_add(h2, 1.0);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 1);
- GPR_ASSERT(gpr_histogram_count(h1) == 7);
- GPR_ASSERT(gpr_histogram_minimum(h1) == 1.0);
- GPR_ASSERT(gpr_histogram_maximum(h1) == 17.0);
- GPR_ASSERT(gpr_histogram_sum(h1) == 42.0);
- GPR_ASSERT(gpr_histogram_sum_of_squares(h1) == 431.5);
- GPR_ASSERT(gpr_histogram_mean(h1) == 6.0);
-
- /* test monotonicity */
- last = 0.0;
- for (i = 0; i < 100.0; i += 0.01) {
- cur = gpr_histogram_percentile(h1, i);
- GPR_ASSERT(cur >= last);
- last = cur;
- }
-
- gpr_histogram_destroy(h1);
- gpr_histogram_destroy(h2);
-}
-
-int main(void) {
- test_no_op();
- test_simple();
- test_percentile();
- test_merge();
- return 0;
-}
diff --git a/test/core/support/stack_lockfree_test.c b/test/core/support/stack_lockfree_test.c
deleted file mode 100644
index 4b1f60ce01..0000000000
--- a/test/core/support/stack_lockfree_test.c
+++ /dev/null
@@ -1,140 +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/support/stack_lockfree.h"
-
-#include <stdlib.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-#include "test/core/util/test_config.h"
-
-/* max stack size supported */
-#define MAX_STACK_SIZE 65534
-
-#define MAX_THREADS 32
-
-static void test_serial_sized(size_t size) {
- gpr_stack_lockfree *stack = gpr_stack_lockfree_create(size);
- size_t i;
- size_t j;
-
- /* First try popping empty */
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
-
- /* Now add one item and check it */
- gpr_stack_lockfree_push(stack, 3);
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == 3);
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
-
- /* Now add repeatedly more items and check them */
- for (i = 1; i < size; i *= 2) {
- for (j = 0; j <= i; j++) {
- GPR_ASSERT(gpr_stack_lockfree_push(stack, (int)j) == (j == 0));
- }
- for (j = 0; j <= i; j++) {
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == (int)(i - j));
- }
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
- }
-
- gpr_stack_lockfree_destroy(stack);
-}
-
-static void test_serial() {
- size_t i;
- for (i = 128; i < MAX_STACK_SIZE; i *= 2) {
- test_serial_sized(i);
- }
- test_serial_sized(MAX_STACK_SIZE);
-}
-
-struct test_arg {
- gpr_stack_lockfree *stack;
- int stack_size;
- int nthreads;
- int rank;
- int sum;
-};
-
-static void test_mt_body(void *v) {
- struct test_arg *arg = (struct test_arg *)v;
- int lo, hi;
- int i;
- int res;
- lo = arg->rank * arg->stack_size / arg->nthreads;
- hi = (arg->rank + 1) * arg->stack_size / arg->nthreads;
- for (i = lo; i < hi; i++) {
- gpr_stack_lockfree_push(arg->stack, i);
- if ((res = gpr_stack_lockfree_pop(arg->stack)) != -1) {
- arg->sum += res;
- }
- }
- while ((res = gpr_stack_lockfree_pop(arg->stack)) != -1) {
- arg->sum += res;
- }
-}
-
-static void test_mt_sized(size_t size, int nth) {
- gpr_stack_lockfree *stack;
- struct test_arg args[MAX_THREADS];
- gpr_thd_id thds[MAX_THREADS];
- int sum;
- int i;
- gpr_thd_options options = gpr_thd_options_default();
-
- stack = gpr_stack_lockfree_create(size);
- for (i = 0; i < nth; i++) {
- args[i].stack = stack;
- args[i].stack_size = (int)size;
- args[i].nthreads = nth;
- args[i].rank = i;
- args[i].sum = 0;
- }
- gpr_thd_options_set_joinable(&options);
- for (i = 0; i < nth; i++) {
- GPR_ASSERT(gpr_thd_new(&thds[i], test_mt_body, &args[i], &options));
- }
- sum = 0;
- for (i = 0; i < nth; i++) {
- gpr_thd_join(thds[i]);
- sum = sum + args[i].sum;
- }
- GPR_ASSERT((unsigned)sum == ((unsigned)size * (size - 1)) / 2);
- gpr_stack_lockfree_destroy(stack);
-}
-
-static void test_mt() {
- size_t size;
- int nth;
- for (nth = 1; nth < MAX_THREADS; nth++) {
- for (size = 128; size < MAX_STACK_SIZE; size *= 2) {
- test_mt_sized(size, nth);
- }
- test_mt_sized(MAX_STACK_SIZE, nth);
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- test_serial();
- test_mt();
- return 0;
-}
diff --git a/test/core/surface/BUILD b/test/core/surface/BUILD
index 17db7737f7..6cec7feabc 100644
--- a/test/core/surface/BUILD
+++ b/test/core/surface/BUILD
@@ -20,8 +20,8 @@ grpc_package(name = "test/core/surface")
grpc_cc_test(
name = "alarm_test",
- srcs = ["alarm_test.c"],
- language = "C",
+ srcs = ["alarm_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -32,8 +32,8 @@ grpc_cc_test(
grpc_cc_test(
name = "grpc_byte_buffer_reader_test",
- srcs = ["byte_buffer_reader_test.c"],
- language = "C",
+ srcs = ["byte_buffer_reader_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +44,8 @@ grpc_cc_test(
grpc_cc_test(
name = "channel_create_test",
- srcs = ["channel_create_test.c"],
- language = "C",
+ srcs = ["channel_create_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -56,8 +56,8 @@ grpc_cc_test(
grpc_cc_test(
name = "grpc_completion_queue_test",
- srcs = ["completion_queue_test.c"],
- language = "C",
+ srcs = ["completion_queue_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -68,8 +68,8 @@ grpc_cc_test(
grpc_cc_test(
name = "concurrent_connectivity_test",
- srcs = ["concurrent_connectivity_test.c"],
- language = "C",
+ srcs = ["concurrent_connectivity_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -80,8 +80,8 @@ grpc_cc_test(
grpc_cc_test(
name = "init_test",
- srcs = ["init_test.c"],
- language = "C",
+ srcs = ["init_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -92,8 +92,8 @@ grpc_cc_test(
grpc_cc_test(
name = "grpc_invalid_channel_args_test",
- srcs = ["invalid_channel_args_test.c"],
- language = "C",
+ srcs = ["invalid_channel_args_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -104,8 +104,8 @@ grpc_cc_test(
grpc_cc_test(
name = "lame_client_test",
- srcs = ["lame_client_test.c"],
- language = "C",
+ srcs = ["lame_client_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -129,8 +129,8 @@ grpc_cc_test(
grpc_cc_test(
name = "secure_channel_create_test",
- srcs = ["secure_channel_create_test.c"],
- language = "C",
+ srcs = ["secure_channel_create_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -141,8 +141,8 @@ grpc_cc_test(
grpc_cc_test(
name = "sequential_connectivity_test",
- srcs = ["sequential_connectivity_test.c"],
- language = "C",
+ srcs = ["sequential_connectivity_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -154,8 +154,8 @@ grpc_cc_test(
grpc_cc_test(
name = "server_chttp2_test",
- srcs = ["server_chttp2_test.c"],
- language = "C",
+ srcs = ["server_chttp2_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -166,8 +166,8 @@ grpc_cc_test(
grpc_cc_test(
name = "server_test",
- srcs = ["server_test.c"],
- language = "C",
+ srcs = ["server_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.cc
index 4fd7cb93c6..67fc6833a5 100644
--- a/test/core/surface/alarm_test.c
+++ b/test/core/surface/alarm_test.cc
@@ -25,78 +25,89 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void *create_test_tag(void) {
+static void* create_test_tag(void) {
static intptr_t i = 0;
- return (void *)(++i);
+ return (void*)(++i);
}
/* helper for tests to shutdown correctly and tersely */
-static void shutdown_and_destroy(grpc_completion_queue *cc) {
+static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_event ev;
grpc_completion_queue_shutdown(cc);
- ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ /* By the time grpc_completion_queue_shutdown runs, the cq's internal
+ pending event counter might not have been updated yet by a previous
+ cq_end_op_for_next (which releases a completed event first and only later
+ updates the pending event counter), so we can't rely on a no-polling
+ cq_next to never return GRPC_QUEUE_TIMEOUT. Using a deadline in the future
+ solves the problem. See https://github.com/grpc/grpc/issues/13693.
+ */
+ ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2),
+ nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
static void test_alarm(void) {
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
LOG_TEST("test_alarm");
- cc = grpc_completion_queue_create_for_next(NULL);
+ cc = grpc_completion_queue_create_for_next(nullptr);
{
/* regular expiry */
grpc_event ev;
- void *tag = create_test_tag();
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(1), tag, NULL);
+ void* tag = create_test_tag();
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(1), tag,
+ nullptr);
ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm_destroy(alarm, nullptr);
}
{
/* cancellation */
grpc_event ev;
- void *tag = create_test_tag();
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, NULL);
+ void* tag = create_test_tag();
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag,
+ nullptr);
- grpc_alarm_cancel(alarm, NULL);
+ grpc_alarm_cancel(alarm, nullptr);
ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success == 0);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm_destroy(alarm, nullptr);
}
{
/* alarm_destroy before cq_next */
grpc_event ev;
- void *tag = create_test_tag();
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, NULL);
+ void* tag = create_test_tag();
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag,
+ nullptr);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm_destroy(alarm, nullptr);
ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success == 0);
}
{
/* alarm_destroy before set */
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_destroy(alarm, nullptr);
}
shutdown_and_destroy(cc);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_alarm();
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.cc
index a6b4c86abc..91662b027a 100644
--- a/test/core/surface/byte_buffer_reader_test.c
+++ b/test/core/surface/byte_buffer_reader_test.cc
@@ -36,7 +36,7 @@
static void test_read_one_slice(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice first_slice, second_slice;
int first_code, second_code;
@@ -58,7 +58,7 @@ static void test_read_one_slice(void) {
static void test_read_one_slice_malloc(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice first_slice, second_slice;
int first_code, second_code;
@@ -81,7 +81,7 @@ static void test_read_one_slice_malloc(void) {
static void test_read_none_compressed_slice(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice first_slice, second_slice;
int first_code, second_code;
@@ -103,13 +103,13 @@ static void test_read_none_compressed_slice(void) {
static void test_read_corrupted_slice(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
LOG_TEST("test_read_corrupted_slice");
slice = grpc_slice_from_copied_string("test");
buffer = grpc_raw_byte_buffer_create(&slice, 1);
- buffer->data.raw.compression = GRPC_COMPRESS_GZIP; /* lies! */
+ buffer->data.raw.compression = GRPC_COMPRESS_MESSAGE_GZIP; /* lies! */
grpc_slice_unref(slice);
GPR_ASSERT(!grpc_byte_buffer_reader_init(&reader, buffer));
grpc_byte_buffer_destroy(buffer);
@@ -120,7 +120,7 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
grpc_slice input_slice;
grpc_slice_buffer sliceb_in;
grpc_slice_buffer sliceb_out;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice read_slice;
size_t read_count = 0;
@@ -132,10 +132,11 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
memset(GRPC_SLICE_START_PTR(input_slice), 'a', input_size);
grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(
- grpc_msg_compress(&exec_ctx, algorithm, &sliceb_in, &sliceb_out));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(grpc_msg_compress(
+
+ grpc_compression_algorithm_to_message_compression_algorithm(algorithm),
+ &sliceb_in, &sliceb_out));
}
buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices,
@@ -160,13 +161,13 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
static void test_read_gzip_compressed_slice(void) {
const size_t INPUT_SIZE = 2048;
LOG_TEST("test_read_gzip_compressed_slice");
- read_compressed_slice(GRPC_COMPRESS_GZIP, INPUT_SIZE);
+ read_compressed_slice(GRPC_COMPRESS_MESSAGE_GZIP, INPUT_SIZE);
}
static void test_read_deflate_compressed_slice(void) {
const size_t INPUT_SIZE = 2048;
LOG_TEST("test_read_deflate_compressed_slice");
- read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE);
+ read_compressed_slice(GRPC_COMPRESS_MESSAGE_DEFLATE, INPUT_SIZE);
}
static void test_byte_buffer_from_reader(void) {
@@ -195,17 +196,17 @@ static void test_byte_buffer_from_reader(void) {
}
static void test_readall(void) {
- char *lotsa_as[512];
- char *lotsa_bs[1024];
+ char* lotsa_as[512];
+ char* lotsa_bs[1024];
grpc_slice slices[2];
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice slice_out;
LOG_TEST("test_readall");
- memset(lotsa_as, 'a', 512);
- memset(lotsa_bs, 'b', 1024);
+ memset(lotsa_as, 'a', 512 * sizeof(lotsa_as[0]));
+ memset(lotsa_bs, 'b', 1024 * sizeof(lotsa_bs[0]));
/* use slices large enough to overflow inlining */
slices[0] = grpc_slice_malloc(512);
memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512);
@@ -229,18 +230,18 @@ static void test_readall(void) {
}
static void test_byte_buffer_copy(void) {
- char *lotsa_as[512];
- char *lotsa_bs[1024];
+ char* lotsa_as[512];
+ char* lotsa_bs[1024];
grpc_slice slices[2];
- grpc_byte_buffer *buffer;
- grpc_byte_buffer *copied_buffer;
+ grpc_byte_buffer* buffer;
+ grpc_byte_buffer* copied_buffer;
grpc_byte_buffer_reader reader;
grpc_slice slice_out;
LOG_TEST("test_byte_buffer_copy");
- memset(lotsa_as, 'a', 512);
- memset(lotsa_bs, 'b', 1024);
+ memset(lotsa_as, 'a', 512 * sizeof(lotsa_as[0]));
+ memset(lotsa_bs, 'b', 1024 * sizeof(lotsa_bs[0]));
/* use slices large enough to overflow inlining */
slices[0] = grpc_slice_malloc(512);
memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512);
@@ -265,7 +266,7 @@ static void test_byte_buffer_copy(void) {
grpc_byte_buffer_destroy(copied_buffer);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_read_one_slice();
test_read_one_slice_malloc();
diff --git a/test/core/surface/channel_create_test.c b/test/core/surface/channel_create_test.cc
index a6884750e7..37247f89d0 100644
--- a/test/core/surface/channel_create_test.c
+++ b/test/core/surface/channel_create_test.cc
@@ -27,24 +27,23 @@
#include "test/core/util/test_config.h"
void test_unknown_scheme_target(void) {
- grpc_channel *chan;
+ grpc_channel* chan;
/* avoid default prefix */
grpc_resolver_registry_shutdown();
grpc_resolver_registry_init();
- chan = grpc_insecure_channel_create("blah://blah", NULL, NULL);
- GPR_ASSERT(chan != NULL);
+ chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr);
+ GPR_ASSERT(chan != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_element *elem =
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_channel_destroy(chan);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_unknown_scheme_target();
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.cc
index e6372a379c..fefbb3c185 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.cc
@@ -27,25 +27,25 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void *create_test_tag(void) {
+static void* create_test_tag(void) {
static intptr_t i = 0;
- return (void *)(++i);
+ return (void*)(++i);
}
/* helper for tests to shutdown correctly and tersely */
-static void shutdown_and_destroy(grpc_completion_queue *cc) {
+static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_event ev;
grpc_completion_queue_shutdown(cc);
switch (grpc_get_cq_completion_type(cc)) {
case GRPC_CQ_NEXT: {
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
break;
}
case GRPC_CQ_PLUCK: {
- ev = grpc_completion_queue_pluck(cc, create_test_tag(),
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, create_test_tag(), gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
break;
}
default: {
@@ -72,7 +72,7 @@ static void test_no_op(void) {
attr.cq_completion_type = completion_types[i];
attr.cq_polling_type = polling_types[j];
shutdown_and_destroy(grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL));
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr));
}
}
}
@@ -81,7 +81,7 @@ static void test_pollset_conversion(void) {
grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK};
grpc_cq_polling_type polling_types[] = {GRPC_CQ_DEFAULT_POLLING,
GRPC_CQ_NON_LISTENING};
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
grpc_completion_queue_attributes attr;
LOG_TEST("test_pollset_conversion");
@@ -92,8 +92,8 @@ static void test_pollset_conversion(void) {
attr.cq_completion_type = completion_types[i];
attr.cq_polling_type = polling_types[j];
cq = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
- GPR_ASSERT(grpc_cq_pollset(cq) != NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+ GPR_ASSERT(grpc_cq_pollset(cq) != nullptr);
shutdown_and_destroy(cq);
}
}
@@ -102,7 +102,7 @@ static void test_pollset_conversion(void) {
static void test_wait_empty(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
grpc_event event;
@@ -113,55 +113,123 @@ static void test_wait_empty(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
- event = grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+ event =
+ grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
}
}
-static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *c) {}
+static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {}
static void test_cq_end_op(void) {
grpc_event ev;
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_cq_completion completion;
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
- void *tag = create_test_tag();
+ void* tag = create_test_tag();
LOG_TEST("test_cq_end_op");
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx exec_ctx;
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
GPR_ASSERT(grpc_cq_begin_op(cc, tag));
- grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completion);
+ grpc_cq_end_op(cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, nullptr,
+ &completion);
- ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
+ }
+}
+
+static void test_cq_tls_cache_full(void) {
+ grpc_event ev;
+ grpc_completion_queue* cc;
+ grpc_cq_completion completion;
+ grpc_cq_polling_type polling_types[] = {
+ GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
+ grpc_completion_queue_attributes attr;
+ void* tag = create_test_tag();
+ void* res_tag;
+ int ok;
+
+ LOG_TEST("test_cq_tls_cache_full");
+
+ attr.version = 1;
+ attr.cq_completion_type = GRPC_CQ_NEXT;
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
+ grpc_core::ExecCtx exec_ctx; // Reset exec_ctx
+ attr.cq_polling_type = polling_types[i];
+ cc = grpc_completion_queue_create(
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+
+ grpc_completion_queue_thread_local_cache_init(cc);
+ GPR_ASSERT(grpc_cq_begin_op(cc, tag));
+ grpc_cq_end_op(cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, nullptr,
+ &completion);
+
+ ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
+
+ GPR_ASSERT(
+ grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 1);
+ GPR_ASSERT(res_tag == tag);
+ GPR_ASSERT(ok);
+
+ ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
+
+ shutdown_and_destroy(cc);
+ }
+}
+
+static void test_cq_tls_cache_empty(void) {
+ grpc_completion_queue* cc;
+ grpc_cq_polling_type polling_types[] = {
+ GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
+ grpc_completion_queue_attributes attr;
+ void* res_tag;
+ int ok;
+
+ LOG_TEST("test_cq_tls_cache_empty");
+
+ attr.version = 1;
+ attr.cq_completion_type = GRPC_CQ_NEXT;
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
+ grpc_core::ExecCtx exec_ctx; // Reset exec_ctx
+ attr.cq_polling_type = polling_types[i];
+ cc = grpc_completion_queue_create(
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+
+ GPR_ASSERT(
+ grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
+ grpc_completion_queue_thread_local_cache_init(cc);
+ GPR_ASSERT(
+ grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
+ shutdown_and_destroy(cc);
}
}
static void test_shutdown_then_next_polling(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
grpc_event event;
LOG_TEST("test_shutdown_then_next_polling");
@@ -171,10 +239,10 @@ static void test_shutdown_then_next_polling(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_shutdown(cc);
- event =
- grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ event = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@@ -183,7 +251,7 @@ static void test_shutdown_then_next_polling(void) {
static void test_shutdown_then_next_with_timeout(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
grpc_event event;
LOG_TEST("test_shutdown_then_next_with_timeout");
@@ -193,11 +261,11 @@ static void test_shutdown_then_next_with_timeout(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_shutdown(cc);
event = grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@@ -205,14 +273,12 @@ static void test_shutdown_then_next_with_timeout(void) {
static void test_pluck(void) {
grpc_event ev;
- grpc_completion_queue *cc;
- void *tags[128];
+ grpc_completion_queue* cc;
+ void* tags[128];
grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
unsigned i, j;
LOG_TEST("test_pluck");
@@ -227,37 +293,37 @@ static void test_pluck(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_PLUCK;
for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) {
- exec_ctx = init_exec_ctx; // reset exec_ctx
+ grpc_core::ExecCtx exec_ctx; // reset exec_ctx
attr.cq_polling_type = polling_types[pidx];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
- grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
- ev = grpc_completion_queue_pluck(cc, tags[i],
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, tags[i], gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.tag == tags[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
- grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
ev = grpc_completion_queue_pluck(cc, tags[GPR_ARRAY_SIZE(tags) - i - 1],
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(ev.tag == tags[GPR_ARRAY_SIZE(tags) - i - 1]);
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -265,7 +331,7 @@ static void test_pluck_after_shutdown(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_event ev;
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
LOG_TEST("test_pluck_after_shutdown");
@@ -275,21 +341,21 @@ static void test_pluck_after_shutdown(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_shutdown(cc);
- ev = grpc_completion_queue_pluck(cc, NULL,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
}
struct thread_state {
- grpc_completion_queue *cc;
- void *tag;
+ grpc_completion_queue* cc;
+ void* tag;
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_no_op();
@@ -300,6 +366,8 @@ int main(int argc, char **argv) {
test_cq_end_op();
test_pluck();
test_pluck_after_shutdown();
+ test_cq_tls_cache_full();
+ test_cq_tls_cache_empty();
grpc_shutdown();
return 0;
}
diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.cc
index 9996b6b840..4a9e818b45 100644
--- a/test/core/surface/completion_queue_threading_test.c
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -28,25 +28,25 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void *create_test_tag(void) {
+static void* create_test_tag(void) {
static intptr_t i = 0;
- return (void *)(++i);
+ return (void*)(++i);
}
/* helper for tests to shutdown correctly and tersely */
-static void shutdown_and_destroy(grpc_completion_queue *cc) {
+static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_event ev;
grpc_completion_queue_shutdown(cc);
switch (grpc_get_cq_completion_type(cc)) {
case GRPC_CQ_NEXT: {
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
break;
}
case GRPC_CQ_PLUCK: {
- ev = grpc_completion_queue_pluck(cc, create_test_tag(),
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, create_test_tag(), gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
break;
}
default: {
@@ -59,34 +59,33 @@ static void shutdown_and_destroy(grpc_completion_queue *cc) {
grpc_completion_queue_destroy(cc);
}
-static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *c) {}
+static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {}
struct thread_state {
- grpc_completion_queue *cc;
- void *tag;
+ grpc_completion_queue* cc;
+ void* tag;
};
-static void pluck_one(void *arg) {
- struct thread_state *state = arg;
+static void pluck_one(void* arg) {
+ struct thread_state* state = static_cast<struct thread_state*>(arg);
grpc_completion_queue_pluck(state->cc, state->tag,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
}
static void test_too_many_plucks(void) {
grpc_event ev;
- grpc_completion_queue *cc;
- void *tags[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
+ grpc_completion_queue* cc;
+ void* tags[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
gpr_thd_id thread_ids[GPR_ARRAY_SIZE(tags)];
struct thread_state thread_states[GPR_ARRAY_SIZE(tags)];
gpr_thd_options thread_options = gpr_thd_options_default();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
unsigned i, j;
LOG_TEST("test_too_many_plucks");
- cc = grpc_completion_queue_create_for_pluck(NULL);
+ cc = grpc_completion_queue_create_for_pluck(nullptr);
gpr_thd_options_set_joinable(&thread_options);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -96,20 +95,21 @@ static void test_too_many_plucks(void) {
}
thread_states[i].cc = cc;
thread_states[i].tag = tags[i];
- gpr_thd_new(thread_ids + i, pluck_one, thread_states + i, &thread_options);
+ gpr_thd_new(thread_ids + i, "grpc_pluck_test", pluck_one, thread_states + i,
+ &thread_options);
}
/* wait until all other threads are plucking */
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1000));
ev = grpc_completion_queue_pluck(cc, create_test_tag(),
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
- grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -117,81 +117,78 @@ static void test_too_many_plucks(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
#define TEST_THREAD_EVENTS 10000
typedef struct test_thread_options {
gpr_event on_started;
- gpr_event *phase1;
+ gpr_event* phase1;
gpr_event on_phase1_done;
- gpr_event *phase2;
+ gpr_event* phase2;
gpr_event on_finished;
size_t events_triggered;
int id;
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
} test_thread_options;
gpr_timespec ten_seconds_time(void) {
return grpc_timeout_seconds_to_deadline(10);
}
-static void free_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *completion) {
+static void free_completion(void* arg, grpc_cq_completion* completion) {
gpr_free(completion);
}
-static void producer_thread(void *arg) {
- test_thread_options *opt = arg;
+static void producer_thread(void* arg) {
+ test_thread_options* opt = static_cast<test_thread_options*>(arg);
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- GPR_ASSERT(grpc_cq_begin_op(opt->cc, (void *)(intptr_t)1));
+ GPR_ASSERT(grpc_cq_begin_op(opt->cc, (void*)(intptr_t)1));
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_op(&exec_ctx, opt->cc, (void *)(intptr_t)1, GRPC_ERROR_NONE,
- free_completion, NULL,
- gpr_malloc(sizeof(grpc_cq_completion)));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_cq_end_op(opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
+ free_completion, nullptr,
+ static_cast<grpc_cq_completion*>(
+ gpr_malloc(sizeof(grpc_cq_completion))));
opt->events_triggered++;
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(intptr_t)1);
- grpc_exec_ctx_finish(&exec_ctx);
+ gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
}
-static void consumer_thread(void *arg) {
- test_thread_options *opt = arg;
+static void consumer_thread(void* arg) {
+ test_thread_options* opt = static_cast<test_thread_options*>(arg);
grpc_event ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
for (;;) {
- ev = grpc_completion_queue_next(opt->cc,
- gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ ev = grpc_completion_queue_next(
+ opt->cc, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
switch (ev.type) {
case GRPC_OP_COMPLETE:
GPR_ASSERT(ev.success);
@@ -199,7 +196,7 @@ static void consumer_thread(void *arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
return;
case GRPC_QUEUE_TIMEOUT:
gpr_log(GPR_ERROR, "Invalid timeout received");
@@ -209,11 +206,11 @@ static void consumer_thread(void *arg) {
}
static void test_threading(size_t producers, size_t consumers) {
- test_thread_options *options =
- gpr_malloc((producers + consumers) * sizeof(test_thread_options));
+ test_thread_options* options = static_cast<test_thread_options*>(
+ gpr_malloc((producers + consumers) * sizeof(test_thread_options)));
gpr_event phase1 = GPR_EVENT_INIT;
gpr_event phase2 = GPR_EVENT_INIT;
- grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cc = grpc_completion_queue_create_for_next(nullptr);
size_t i;
size_t total_consumed = 0;
static int optid = 101;
@@ -233,15 +230,16 @@ static void test_threading(size_t producers, size_t consumers) {
options[i].cc = cc;
options[i].id = optid++;
GPR_ASSERT(gpr_thd_new(&id,
+ i < producers ? "grpc_producer" : "grpc_consumer",
i < producers ? producer_thread : consumer_thread,
- options + i, NULL));
+ options + i, nullptr));
gpr_event_wait(&options[i].on_started, ten_seconds_time());
}
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void *)(intptr_t)1);
+ gpr_event_set(&phase1, (void*)(intptr_t)1);
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -251,7 +249,7 @@ static void test_threading(size_t producers, size_t consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void *)(intptr_t)1);
+ gpr_event_set(&phase2, (void*)(intptr_t)1);
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
@@ -280,7 +278,7 @@ static void test_threading(size_t producers, size_t consumers) {
gpr_free(options);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_too_many_plucks();
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.cc
index ec2cd8610b..235d136376 100644
--- a/test/core/surface/concurrent_connectivity_test.c
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -49,28 +49,31 @@
#define NUM_OUTER_LOOPS_SHORT_TIMEOUTS 10
#define NUM_INNER_LOOPS_SHORT_TIMEOUTS 100
#define DELAY_MILLIS_SHORT_TIMEOUTS 1
-// in a successful test run, POLL_MILLIS should never be reached beause all runs
-// should
-// end after the shorter delay_millis
+// in a successful test run, POLL_MILLIS should never be reached because all
+// runs should end after the shorter delay_millis
#define POLL_MILLIS_SHORT_TIMEOUTS 30000
+// it should never take longer that this to shutdown the server
+#define SERVER_SHUTDOWN_TIMEOUT 30000
-static void *tag(int n) { return (void *)(uintptr_t)n; }
-static int detag(void *p) { return (int)(uintptr_t)p; }
+static void* tag(int n) { return (void*)(uintptr_t)n; }
+static int detag(void* p) { return (int)(uintptr_t)p; }
-void create_loop_destroy(void *addr) {
+void create_loop_destroy(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS; ++i) {
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_channel* chan =
+ grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS; ++j) {
gpr_timespec later_time =
grpc_timeout_milliseconds_to_deadline(DELAY_MILLIS);
grpc_connectivity_state state =
grpc_channel_check_connectivity_state(chan, 1);
- grpc_channel_watch_connectivity_state(chan, state, later_time, cq, NULL);
+ grpc_channel_watch_connectivity_state(chan, state, later_time, cq,
+ nullptr);
gpr_timespec poll_time =
grpc_timeout_milliseconds_to_deadline(POLL_MILLIS);
- GPR_ASSERT(grpc_completion_queue_next(cq, poll_time, NULL).type ==
+ GPR_ASSERT(grpc_completion_queue_next(cq, poll_time, nullptr).type ==
GRPC_OP_COMPLETE);
/* check that the watcher from "watch state" was free'd */
GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(chan) == 0);
@@ -81,47 +84,47 @@ void create_loop_destroy(void *addr) {
}
struct server_thread_args {
- char *addr;
- grpc_server *server;
- grpc_completion_queue *cq;
- grpc_pollset *pollset;
- gpr_mu *mu;
+ char* addr;
+ grpc_server* server;
+ grpc_completion_queue* cq;
+ grpc_pollset* pollset;
+ gpr_mu* mu;
gpr_event ready;
gpr_atm stop;
};
-void server_thread(void *vargs) {
- struct server_thread_args *args = (struct server_thread_args *)vargs;
+void server_thread(void* vargs) {
+ struct server_thread_args* args = (struct server_thread_args*)vargs;
grpc_event ev;
- gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- ev = grpc_completion_queue_next(args->cq, deadline, NULL);
+ gpr_timespec deadline =
+ grpc_timeout_milliseconds_to_deadline(SERVER_SHUTDOWN_TIMEOUT);
+ ev = grpc_completion_queue_next(args->cq, deadline, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(detag(ev.tag) == 0xd1e);
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
+static void on_connect(void* vargs, grpc_endpoint* tcp,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- struct server_thread_args *args = (struct server_thread_args *)vargs;
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ struct server_thread_args* args = (struct server_thread_args*)vargs;
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, NULL));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
-void bad_server_thread(void *vargs) {
- struct server_thread_args *args = (struct server_thread_args *)vargs;
+void bad_server_thread(void* vargs) {
+ struct server_thread_args* args = (struct server_thread_args*)vargs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
+ struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int port;
- grpc_tcp_server *s;
- grpc_error *error = grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s);
+ grpc_tcp_server* s;
+ grpc_error* error = grpc_tcp_server_create(nullptr, nullptr, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&resolved_addr, 0, sizeof(resolved_addr));
addr->ss_family = AF_INET;
@@ -130,37 +133,32 @@ void bad_server_thread(void *vargs) {
GPR_ASSERT(port > 0);
gpr_asprintf(&args->addr, "localhost:%d", port);
- grpc_tcp_server_start(&exec_ctx, s, &args->pollset, 1, on_connect, args);
- gpr_event_set(&args->ready, (void *)1);
+ grpc_tcp_server_start(s, &args->pollset, 1, on_connect, args);
+ gpr_event_set(&args->ready, (void*)1);
gpr_mu_lock(args->mu);
while (gpr_atm_acq_load(&args->stop) == 0) {
- gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
- gpr_timespec deadline =
- gpr_time_add(now, gpr_time_from_millis(100, GPR_TIMESPAN));
-
- grpc_pollset_worker *worker = NULL;
- if (!GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- now, deadline))) {
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 100;
+
+ grpc_pollset_worker* worker = nullptr;
+ if (!GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(args->pollset, &worker, deadline))) {
gpr_atm_rel_store(&args->stop, 1);
}
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(args->mu);
}
gpr_mu_unlock(args->mu);
- grpc_tcp_server_unref(&exec_ctx, s);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
gpr_free(args->addr);
}
-static void done_pollset_shutdown(grpc_exec_ctx *exec_ctx, void *pollset,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, pollset);
+static void done_pollset_shutdown(void* pollset, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(pollset));
gpr_free(pollset);
}
@@ -173,14 +171,15 @@ int run_concurrent_connectivity_test() {
gpr_thd_id threads[NUM_THREADS];
gpr_thd_id server;
- char *localhost = gpr_strdup("localhost:54321");
+ char* localhost = gpr_strdup("localhost:54321");
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
/* First round, no server */
gpr_log(GPR_DEBUG, "Wave 1");
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], create_loop_destroy, localhost, &options);
+ gpr_thd_new(&threads[i], "grpc_wave_1", create_loop_destroy, localhost,
+ &options);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -191,15 +190,16 @@ int run_concurrent_connectivity_test() {
gpr_log(GPR_DEBUG, "Wave 2");
int port = grpc_pick_unused_port_or_die();
gpr_asprintf(&args.addr, "localhost:%d", port);
- args.server = grpc_server_create(NULL, NULL);
+ args.server = grpc_server_create(nullptr, nullptr);
grpc_server_add_insecure_http2_port(args.server, args.addr);
- args.cq = grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(args.server, args.cq, NULL);
+ args.cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(args.server, args.cq, nullptr);
grpc_server_start(args.server);
- gpr_thd_new(&server, server_thread, &args, &options);
+ gpr_thd_new(&server, "grpc_wave_2_server", server_thread, &args, &options);
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], create_loop_destroy, args.addr, &options);
+ gpr_thd_new(&threads[i], "grpc_wave_2", create_loop_destroy, args.addr,
+ &options);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -213,14 +213,16 @@ int run_concurrent_connectivity_test() {
/* Third round, bogus tcp server */
gpr_log(GPR_DEBUG, "Wave 3");
- args.pollset = gpr_zalloc(grpc_pollset_size());
+ args.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args.pollset, &args.mu);
gpr_event_init(&args.ready);
- gpr_thd_new(&server, bad_server_thread, &args, &options);
+ gpr_thd_new(&server, "grpc_wave_3_server", bad_server_thread, &args,
+ &options);
gpr_event_wait(&args.ready, gpr_inf_future(GPR_CLOCK_MONOTONIC));
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], create_loop_destroy, args.addr, &options);
+ gpr_thd_new(&threads[i], "grpc_wave_3", create_loop_destroy, args.addr,
+ &options);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -228,20 +230,22 @@ int run_concurrent_connectivity_test() {
gpr_atm_rel_store(&args.stop, 1);
gpr_thd_join(server);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_shutdown(&exec_ctx, args.pollset,
- GRPC_CLOSURE_CREATE(done_pollset_shutdown, args.pollset,
- grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_pollset_shutdown(
+ args.pollset, GRPC_CLOSURE_CREATE(done_pollset_shutdown, args.pollset,
+ grpc_schedule_on_exec_ctx));
+ }
grpc_shutdown();
return 0;
}
-void watches_with_short_timeouts(void *addr) {
+void watches_with_short_timeouts(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS_SHORT_TIMEOUTS; ++i) {
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_channel* chan =
+ grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS_SHORT_TIMEOUTS; ++j) {
gpr_timespec later_time =
@@ -249,10 +253,11 @@ void watches_with_short_timeouts(void *addr) {
grpc_connectivity_state state =
grpc_channel_check_connectivity_state(chan, 0);
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
- grpc_channel_watch_connectivity_state(chan, state, later_time, cq, NULL);
+ grpc_channel_watch_connectivity_state(chan, state, later_time, cq,
+ nullptr);
gpr_timespec poll_time =
grpc_timeout_milliseconds_to_deadline(POLL_MILLIS_SHORT_TIMEOUTS);
- grpc_event ev = grpc_completion_queue_next(cq, poll_time, NULL);
+ grpc_event ev = grpc_completion_queue_next(cq, poll_time, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.success == false);
/* check that the watcher from "watch state" was free'd */
@@ -271,12 +276,13 @@ int run_concurrent_watches_with_short_timeouts_test() {
gpr_thd_id threads[NUM_THREADS];
- char *localhost = gpr_strdup("localhost:54321");
+ char* localhost = gpr_strdup("localhost:54321");
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], watches_with_short_timeouts, localhost, &options);
+ gpr_thd_new(&threads[i], "grpc_short_watches", watches_with_short_timeouts,
+ localhost, &options);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -287,7 +293,7 @@ int run_concurrent_watches_with_short_timeouts_test() {
return 0;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_concurrent_connectivity_test();
diff --git a/test/core/surface/init_test.c b/test/core/surface/init_test.cc
index a9e80575af..5749bc8b36 100644
--- a/test/core/surface/init_test.c
+++ b/test/core/surface/init_test.cc
@@ -53,13 +53,13 @@ static void test_plugin() {
}
static void test_repeatedly() {
- for (int i = 0; i < 100000; i++) {
+ for (int i = 0; i < 1000; i++) {
grpc_init();
grpc_shutdown();
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test(1);
test(2);
diff --git a/test/core/surface/invalid_channel_args_test.c b/test/core/surface/invalid_channel_args_test.cc
index 84d7627d29..7c5f1f0352 100644
--- a/test/core/surface/invalid_channel_args_test.c
+++ b/test/core/surface/invalid_channel_args_test.cc
@@ -24,10 +24,10 @@
#include <grpc/support/string_util.h>
#include "test/core/util/test_config.h"
-static char *g_last_log_error_message = NULL;
-static const char *g_file_name = "channel.c";
+static char* g_last_log_error_message = nullptr;
+static const char* g_file_name = "channel.cc";
-static int ends_with(const char *src, const char *suffix) {
+static int ends_with(const char* src, const char* suffix) {
size_t src_len = strlen(src);
size_t suffix_len = strlen(suffix);
if (src_len < suffix_len) {
@@ -36,46 +36,46 @@ static int ends_with(const char *src, const char *suffix) {
return strcmp(src + src_len - suffix_len, suffix) == 0;
}
-static void log_error_sink(gpr_log_func_args *args) {
+static void log_error_sink(gpr_log_func_args* args) {
if (args->severity == GPR_LOG_SEVERITY_ERROR &&
ends_with(args->file, g_file_name)) {
g_last_log_error_message = gpr_strdup(args->message);
}
}
-static void verify_last_error(const char *message) {
- if (message == NULL) {
- GPR_ASSERT(g_last_log_error_message == NULL);
+static void verify_last_error(const char* message) {
+ if (message == nullptr) {
+ GPR_ASSERT(g_last_log_error_message == nullptr);
return;
}
GPR_ASSERT(strcmp(message, g_last_log_error_message) == 0);
gpr_free(g_last_log_error_message);
- g_last_log_error_message = NULL;
+ g_last_log_error_message = nullptr;
}
-static char *compose_error_string(const char *key, const char *message) {
- char *ret;
+static char* compose_error_string(const char* key, const char* message) {
+ char* ret;
gpr_asprintf(&ret, "%s%s", key, message);
return ret;
}
-static void one_test(grpc_channel_args *args, char *expected_error_message) {
- grpc_channel *chan =
- grpc_insecure_channel_create("nonexistant:54321", args, NULL);
+static void one_test(grpc_channel_args* args, char* expected_error_message) {
+ grpc_channel* chan =
+ grpc_insecure_channel_create("nonexistant:54321", args, nullptr);
verify_last_error(expected_error_message);
gpr_free(expected_error_message);
grpc_channel_destroy(chan);
}
-static void test_no_error_message(void) { one_test(NULL, NULL); }
+static void test_no_error_message(void) { one_test(nullptr, nullptr); }
static void test_default_authority_type(void) {
grpc_arg client_arg;
grpc_channel_args client_args;
- char *expected_error_message;
+ char* expected_error_message;
client_arg.type = GRPC_ARG_INTEGER;
- client_arg.key = GRPC_ARG_DEFAULT_AUTHORITY;
+ client_arg.key = const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY);
client_arg.value.integer = 0;
client_args.num_args = 1;
@@ -88,10 +88,10 @@ static void test_default_authority_type(void) {
static void test_ssl_name_override_type(void) {
grpc_arg client_arg;
grpc_channel_args client_args;
- char *expected_error_message;
+ char* expected_error_message;
client_arg.type = GRPC_ARG_INTEGER;
- client_arg.key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG;
+ client_arg.key = const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
client_arg.value.integer = 0;
client_args.num_args = 1;
@@ -104,14 +104,14 @@ static void test_ssl_name_override_type(void) {
static void test_ssl_name_override_failed(void) {
grpc_arg client_arg[2];
grpc_channel_args client_args;
- char *expected_error_message;
+ char* expected_error_message;
client_arg[0].type = GRPC_ARG_STRING;
- client_arg[0].key = GRPC_ARG_DEFAULT_AUTHORITY;
- client_arg[0].value.string = "default";
+ client_arg[0].key = const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY);
+ client_arg[0].value.string = const_cast<char*>("default");
client_arg[1].type = GRPC_ARG_STRING;
- client_arg[1].key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG;
- client_arg[1].value.string = "ssl";
+ client_arg[1].key = const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
+ client_arg[1].value.string = const_cast<char*>("ssl");
client_args.num_args = 2;
client_args.args = client_arg;
@@ -121,7 +121,7 @@ static void test_ssl_name_override_failed(void) {
one_test(&client_args, expected_error_message);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
gpr_set_log_function(log_error_sink);
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.cc
index f623e1a743..4bf40569e6 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.cc
@@ -30,53 +30,50 @@
grpc_closure transport_op_cb;
-static void *tag(intptr_t x) { return (void *)x; }
+static void* tag(intptr_t x) { return (void*)x; }
-void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_connectivity_state *state = arg;
+void verify_connectivity(void* arg, grpc_error* error) {
+ grpc_connectivity_state* state = static_cast<grpc_connectivity_state*>(arg);
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == *state);
GPR_ASSERT(error == GRPC_ERROR_NONE);
}
-void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+void do_nothing(void* arg, grpc_error* error) {}
-void test_transport_op(grpc_channel *channel) {
- grpc_transport_op *op;
- grpc_channel_element *elem;
+void test_transport_op(grpc_channel* channel) {
+ grpc_transport_op* op;
+ grpc_channel_element* elem;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GRPC_CLOSURE_INIT(&transport_op_cb, verify_connectivity, &state,
grpc_schedule_on_exec_ctx);
- op = grpc_make_transport_op(NULL);
+ op = grpc_make_transport_op(nullptr);
op->on_connectivity_state_change = &transport_op_cb;
op->connectivity_state = &state;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->start_transport_op(elem, op);
- GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, NULL,
+ GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(&transport_op_cb);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->start_transport_op(elem, op);
}
-int main(int argc, char **argv) {
- grpc_channel *chan;
- grpc_call *call;
- grpc_completion_queue *cq;
- cq_verifier *cqv;
+int main(int argc, char** argv) {
+ grpc_channel* chan;
+ grpc_call* call;
+ grpc_completion_queue* cq;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- char *peer;
+ char* peer;
grpc_test_init(argc, argv);
grpc_init();
@@ -93,12 +90,13 @@ int main(int argc, char **argv) {
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN ==
grpc_channel_check_connectivity_state(chan, 0));
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
grpc_slice host = grpc_slice_from_static_string("anywhere");
- call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
- grpc_slice_from_static_string("/Foo"), &host,
- grpc_timeout_seconds_to_deadline(100), NULL);
+ call =
+ grpc_channel_create_call(chan, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_slice_from_static_string("/Foo"), &host,
+ grpc_timeout_seconds_to_deadline(100), nullptr);
GPR_ASSERT(call);
cqv = cq_verifier_create(cq);
@@ -107,14 +105,14 @@ int main(int argc, char **argv) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
@@ -128,9 +126,9 @@ int main(int argc, char **argv) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
diff --git a/test/core/surface/num_external_connectivity_watchers_test.c b/test/core/surface/num_external_connectivity_watchers_test.cc
index 16401bb7ac..9cdd299ae3 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.c
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -30,28 +30,28 @@
#include "test/core/util/test_config.h"
typedef struct test_fixture {
- const char *name;
- grpc_channel *(*create_channel)(const char *addr);
+ const char* name;
+ grpc_channel* (*create_channel)(const char* addr);
} test_fixture;
static size_t next_tag = 1;
-static void channel_idle_start_watch(grpc_channel *channel,
- grpc_completion_queue *cq) {
+static void channel_idle_start_watch(grpc_channel* channel,
+ grpc_completion_queue* cq) {
gpr_timespec connect_deadline = grpc_timeout_milliseconds_to_deadline(1);
GPR_ASSERT(grpc_channel_check_connectivity_state(channel, 0) ==
GRPC_CHANNEL_IDLE);
grpc_channel_watch_connectivity_state(
- channel, GRPC_CHANNEL_IDLE, connect_deadline, cq, (void *)(next_tag++));
+ channel, GRPC_CHANNEL_IDLE, connect_deadline, cq, (void*)(next_tag++));
gpr_log(GPR_DEBUG, "number of active connect watchers: %d",
grpc_channel_num_external_connectivity_watchers(channel));
}
-static void channel_idle_poll_for_timeout(grpc_channel *channel,
- grpc_completion_queue *cq) {
- grpc_event ev =
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+static void channel_idle_poll_for_timeout(grpc_channel* channel,
+ grpc_completion_queue* cq) {
+ grpc_event ev = grpc_completion_queue_next(
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
/* expect watch_connectivity_state to end with a timeout */
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
@@ -63,17 +63,17 @@ static void channel_idle_poll_for_timeout(grpc_channel *channel,
/* Test and use the "num_external_watchers" call to make sure
* that "connectivity watcher" structs are free'd just after, if
* their corresponding timeouts occur. */
-static void run_timeouts_test(const test_fixture *fixture) {
+static void run_timeouts_test(const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
- char *addr;
+ char* addr;
grpc_init();
gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die());
- grpc_channel *channel = fixture->create_channel(addr);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_channel* channel = fixture->create_channel(addr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
/* start 1 watcher and then let it time out */
channel_idle_start_watch(channel, cq);
@@ -105,9 +105,9 @@ static void run_timeouts_test(const test_fixture *fixture) {
grpc_channel_destroy(channel);
grpc_completion_queue_shutdown(cq);
- GPR_ASSERT(
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type == GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
grpc_shutdown();
@@ -117,17 +117,17 @@ static void run_timeouts_test(const test_fixture *fixture) {
/* An edge scenario; sets channel state to explicitly, and outside
* of a polling call. */
static void run_channel_shutdown_before_timeout_test(
- const test_fixture *fixture) {
+ const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
- char *addr;
+ char* addr;
grpc_init();
gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die());
- grpc_channel *channel = fixture->create_channel(addr);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_channel* channel = fixture->create_channel(addr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
/* start 1 watcher and then shut down the channel before the timer goes off */
GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(channel) == 0);
@@ -138,57 +138,59 @@ static void run_channel_shutdown_before_timeout_test(
GRPC_CHANNEL_IDLE);
grpc_channel_watch_connectivity_state(channel, GRPC_CHANNEL_IDLE,
- connect_deadline, cq, (void *)1);
+ connect_deadline, cq, (void*)1);
grpc_channel_destroy(channel);
- grpc_event ev =
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_event ev = grpc_completion_queue_next(
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
/* expect success with a state transition to CHANNEL_SHUTDOWN */
GPR_ASSERT(ev.success == true);
grpc_completion_queue_shutdown(cq);
- GPR_ASSERT(
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type == GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
grpc_shutdown();
gpr_free(addr);
}
-static grpc_channel *insecure_test_create_channel(const char *addr) {
- return grpc_insecure_channel_create(addr, NULL, NULL);
+static grpc_channel* insecure_test_create_channel(const char* addr) {
+ return grpc_insecure_channel_create(addr, nullptr, nullptr);
}
static const test_fixture insecure_test = {
- "insecure", insecure_test_create_channel,
+ "insecure",
+ insecure_test_create_channel,
};
-static grpc_channel *secure_test_create_channel(const char *addr) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
- grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1);
- grpc_channel *channel =
- grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
+static grpc_channel* secure_test_create_channel(const char* addr) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
+ grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1);
+ grpc_channel* channel =
+ grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
grpc_channel_credentials_release(ssl_creds);
return channel;
}
static const test_fixture secure_test = {
- "secure", secure_test_create_channel,
+ "secure",
+ secure_test_create_channel,
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_timeouts_test(&insecure_test);
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index d36d116afb..f4de5d7d8a 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -20,6 +20,8 @@
#include <grpc/byte_buffer_reader.h>
#include <grpc/census.h>
#include <grpc/compression.h>
+#include <grpc/compression_ruby.h>
+#include <grpc/fork.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/grpc_security_constants.h>
@@ -28,7 +30,7 @@
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/connectivity_state.h>
-#include <grpc/impl/codegen/exec_ctx_fwd.h>
+#include <grpc/impl/codegen/fork.h>
#include <grpc/impl/codegen/gpr_slice.h>
#include <grpc/impl/codegen/gpr_types.h>
#include <grpc/impl/codegen/grpc_types.h>
@@ -48,7 +50,6 @@
#include <grpc/support/avl.h>
#include <grpc/support/cmdline.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@@ -63,4 +64,275 @@
#include <grpc/support/useful.h>
#include <grpc/support/workaround_list.h>
-int main(int argc, char **argv) { return 0; }
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ printf("%lx", (unsigned long) grpc_compression_algorithm_is_message);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_is_stream);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_parse);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_name);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_for_level);
+ printf("%lx", (unsigned long) grpc_compression_options_init);
+ printf("%lx", (unsigned long) grpc_compression_options_enable_algorithm);
+ printf("%lx", (unsigned long) grpc_compression_options_disable_algorithm);
+ printf("%lx", (unsigned long) grpc_compression_options_is_algorithm_enabled);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_parse_ruby);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_name_ruby);
+ printf("%lx", (unsigned long) grpc_metadata_array_init);
+ printf("%lx", (unsigned long) grpc_metadata_array_destroy);
+ printf("%lx", (unsigned long) grpc_call_details_init);
+ printf("%lx", (unsigned long) grpc_call_details_destroy);
+ printf("%lx", (unsigned long) grpc_register_plugin);
+ printf("%lx", (unsigned long) grpc_init);
+ printf("%lx", (unsigned long) grpc_shutdown);
+ printf("%lx", (unsigned long) grpc_version_string);
+ printf("%lx", (unsigned long) grpc_g_stands_for);
+ printf("%lx", (unsigned long) grpc_completion_queue_factory_lookup);
+ printf("%lx", (unsigned long) grpc_completion_queue_create_for_next);
+ printf("%lx", (unsigned long) grpc_completion_queue_create_for_pluck);
+ printf("%lx", (unsigned long) grpc_completion_queue_create);
+ printf("%lx", (unsigned long) grpc_completion_queue_next);
+ printf("%lx", (unsigned long) grpc_completion_queue_pluck);
+ printf("%lx", (unsigned long) grpc_completion_queue_shutdown);
+ printf("%lx", (unsigned long) grpc_completion_queue_destroy);
+ printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_init);
+ printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_flush);
+ printf("%lx", (unsigned long) grpc_alarm_create);
+ printf("%lx", (unsigned long) grpc_alarm_set);
+ printf("%lx", (unsigned long) grpc_alarm_cancel);
+ printf("%lx", (unsigned long) grpc_alarm_destroy);
+ printf("%lx", (unsigned long) grpc_channel_check_connectivity_state);
+ printf("%lx", (unsigned long) grpc_channel_num_external_connectivity_watchers);
+ printf("%lx", (unsigned long) grpc_channel_watch_connectivity_state);
+ printf("%lx", (unsigned long) grpc_channel_support_connectivity_watcher);
+ printf("%lx", (unsigned long) grpc_channel_create_call);
+ printf("%lx", (unsigned long) grpc_channel_ping);
+ printf("%lx", (unsigned long) grpc_channel_register_call);
+ printf("%lx", (unsigned long) grpc_channel_create_registered_call);
+ printf("%lx", (unsigned long) grpc_call_arena_alloc);
+ printf("%lx", (unsigned long) grpc_call_start_batch);
+ printf("%lx", (unsigned long) grpc_call_get_peer);
+ printf("%lx", (unsigned long) grpc_census_call_set_context);
+ printf("%lx", (unsigned long) grpc_census_call_get_context);
+ printf("%lx", (unsigned long) grpc_channel_get_target);
+ printf("%lx", (unsigned long) grpc_channel_get_info);
+ printf("%lx", (unsigned long) grpc_insecure_channel_create);
+ printf("%lx", (unsigned long) grpc_lame_client_channel_create);
+ printf("%lx", (unsigned long) grpc_channel_destroy);
+ printf("%lx", (unsigned long) grpc_call_cancel);
+ printf("%lx", (unsigned long) grpc_call_cancel_with_status);
+ printf("%lx", (unsigned long) grpc_call_ref);
+ printf("%lx", (unsigned long) grpc_call_unref);
+ printf("%lx", (unsigned long) grpc_server_request_call);
+ printf("%lx", (unsigned long) grpc_server_register_method);
+ printf("%lx", (unsigned long) grpc_server_request_registered_call);
+ printf("%lx", (unsigned long) grpc_server_create);
+ printf("%lx", (unsigned long) grpc_server_register_completion_queue);
+ printf("%lx", (unsigned long) grpc_server_add_insecure_http2_port);
+ printf("%lx", (unsigned long) grpc_server_start);
+ printf("%lx", (unsigned long) grpc_server_shutdown_and_notify);
+ printf("%lx", (unsigned long) grpc_server_cancel_all_calls);
+ printf("%lx", (unsigned long) grpc_server_destroy);
+ printf("%lx", (unsigned long) grpc_tracer_set_enabled);
+ printf("%lx", (unsigned long) grpc_header_key_is_legal);
+ printf("%lx", (unsigned long) grpc_header_nonbin_value_is_legal);
+ printf("%lx", (unsigned long) grpc_is_binary_header);
+ printf("%lx", (unsigned long) grpc_call_error_to_string);
+ printf("%lx", (unsigned long) grpc_resource_quota_create);
+ printf("%lx", (unsigned long) grpc_resource_quota_ref);
+ printf("%lx", (unsigned long) grpc_resource_quota_unref);
+ printf("%lx", (unsigned long) grpc_resource_quota_resize);
+ printf("%lx", (unsigned long) grpc_resource_quota_arg_vtable);
+ printf("%lx", (unsigned long) grpc_auth_property_iterator_next);
+ printf("%lx", (unsigned long) grpc_auth_context_property_iterator);
+ printf("%lx", (unsigned long) grpc_auth_context_peer_identity);
+ printf("%lx", (unsigned long) grpc_auth_context_find_properties_by_name);
+ printf("%lx", (unsigned long) grpc_auth_context_peer_identity_property_name);
+ printf("%lx", (unsigned long) grpc_auth_context_peer_is_authenticated);
+ printf("%lx", (unsigned long) grpc_call_auth_context);
+ printf("%lx", (unsigned long) grpc_auth_context_release);
+ printf("%lx", (unsigned long) grpc_auth_context_add_property);
+ printf("%lx", (unsigned long) grpc_auth_context_add_cstring_property);
+ printf("%lx", (unsigned long) grpc_auth_context_set_peer_identity_property_name);
+ printf("%lx", (unsigned long) grpc_channel_credentials_release);
+ printf("%lx", (unsigned long) grpc_google_default_credentials_create);
+ printf("%lx", (unsigned long) grpc_set_ssl_roots_override_callback);
+ printf("%lx", (unsigned long) grpc_ssl_credentials_create);
+ printf("%lx", (unsigned long) grpc_call_credentials_release);
+ printf("%lx", (unsigned long) grpc_composite_channel_credentials_create);
+ printf("%lx", (unsigned long) grpc_composite_call_credentials_create);
+ printf("%lx", (unsigned long) grpc_google_compute_engine_credentials_create);
+ printf("%lx", (unsigned long) grpc_max_auth_token_lifetime);
+ printf("%lx", (unsigned long) grpc_service_account_jwt_access_credentials_create);
+ printf("%lx", (unsigned long) grpc_google_refresh_token_credentials_create);
+ printf("%lx", (unsigned long) grpc_access_token_credentials_create);
+ printf("%lx", (unsigned long) grpc_google_iam_credentials_create);
+ printf("%lx", (unsigned long) grpc_metadata_credentials_create_from_plugin);
+ printf("%lx", (unsigned long) grpc_secure_channel_create);
+ printf("%lx", (unsigned long) grpc_server_credentials_release);
+ printf("%lx", (unsigned long) grpc_ssl_server_certificate_config_create);
+ printf("%lx", (unsigned long) grpc_ssl_server_certificate_config_destroy);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_ex);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_options_using_config);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_options_using_config_fetcher);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_options_destroy);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_with_options);
+ printf("%lx", (unsigned long) grpc_server_add_secure_http2_port);
+ printf("%lx", (unsigned long) grpc_call_set_credentials);
+ printf("%lx", (unsigned long) grpc_server_credentials_set_auth_metadata_processor);
+ printf("%lx", (unsigned long) grpc_raw_byte_buffer_create);
+ printf("%lx", (unsigned long) grpc_raw_compressed_byte_buffer_create);
+ printf("%lx", (unsigned long) grpc_byte_buffer_copy);
+ printf("%lx", (unsigned long) grpc_byte_buffer_length);
+ printf("%lx", (unsigned long) grpc_byte_buffer_destroy);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_init);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_destroy);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_next);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_readall);
+ printf("%lx", (unsigned long) grpc_raw_byte_buffer_from_reader);
+ printf("%lx", (unsigned long) grpc_slice_ref);
+ printf("%lx", (unsigned long) grpc_slice_unref);
+ printf("%lx", (unsigned long) grpc_slice_copy);
+ printf("%lx", (unsigned long) grpc_slice_new);
+ printf("%lx", (unsigned long) grpc_slice_new_with_user_data);
+ printf("%lx", (unsigned long) grpc_slice_new_with_len);
+ printf("%lx", (unsigned long) grpc_slice_malloc);
+ printf("%lx", (unsigned long) grpc_slice_malloc_large);
+ printf("%lx", (unsigned long) grpc_slice_intern);
+ printf("%lx", (unsigned long) grpc_slice_from_copied_string);
+ printf("%lx", (unsigned long) grpc_slice_from_copied_buffer);
+ printf("%lx", (unsigned long) grpc_slice_from_static_string);
+ printf("%lx", (unsigned long) grpc_slice_from_static_buffer);
+ printf("%lx", (unsigned long) grpc_slice_sub);
+ printf("%lx", (unsigned long) grpc_slice_sub_no_ref);
+ printf("%lx", (unsigned long) grpc_slice_split_tail);
+ printf("%lx", (unsigned long) grpc_slice_split_tail_maybe_ref);
+ printf("%lx", (unsigned long) grpc_slice_split_head);
+ printf("%lx", (unsigned long) grpc_empty_slice);
+ printf("%lx", (unsigned long) grpc_slice_default_hash_impl);
+ printf("%lx", (unsigned long) grpc_slice_default_eq_impl);
+ printf("%lx", (unsigned long) grpc_slice_eq);
+ printf("%lx", (unsigned long) grpc_slice_cmp);
+ printf("%lx", (unsigned long) grpc_slice_str_cmp);
+ printf("%lx", (unsigned long) grpc_slice_buf_start_eq);
+ printf("%lx", (unsigned long) grpc_slice_rchr);
+ printf("%lx", (unsigned long) grpc_slice_chr);
+ printf("%lx", (unsigned long) grpc_slice_slice);
+ printf("%lx", (unsigned long) grpc_slice_hash);
+ printf("%lx", (unsigned long) grpc_slice_is_equivalent);
+ printf("%lx", (unsigned long) grpc_slice_dup);
+ printf("%lx", (unsigned long) grpc_slice_to_c_string);
+ printf("%lx", (unsigned long) grpc_slice_buffer_init);
+ printf("%lx", (unsigned long) grpc_slice_buffer_destroy);
+ printf("%lx", (unsigned long) grpc_slice_buffer_add);
+ printf("%lx", (unsigned long) grpc_slice_buffer_add_indexed);
+ printf("%lx", (unsigned long) grpc_slice_buffer_addn);
+ printf("%lx", (unsigned long) grpc_slice_buffer_tiny_add);
+ printf("%lx", (unsigned long) grpc_slice_buffer_pop);
+ printf("%lx", (unsigned long) grpc_slice_buffer_reset_and_unref);
+ printf("%lx", (unsigned long) grpc_slice_buffer_swap);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_into);
+ printf("%lx", (unsigned long) grpc_slice_buffer_trim_end);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_first);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_first_no_ref);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_first_into_buffer);
+ printf("%lx", (unsigned long) grpc_slice_buffer_take_first);
+ printf("%lx", (unsigned long) grpc_slice_buffer_undo_take_first);
+ printf("%lx", (unsigned long) gpr_malloc);
+ printf("%lx", (unsigned long) gpr_zalloc);
+ printf("%lx", (unsigned long) gpr_free);
+ printf("%lx", (unsigned long) gpr_realloc);
+ printf("%lx", (unsigned long) gpr_malloc_aligned);
+ 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);
+ 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);
+ 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);
+ printf("%lx", (unsigned long) gpr_set_log_verbosity);
+ printf("%lx", (unsigned long) gpr_log_verbosity_init);
+ 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);
+ printf("%lx", (unsigned long) gpr_mu_unlock);
+ printf("%lx", (unsigned long) gpr_mu_trylock);
+ printf("%lx", (unsigned long) gpr_cv_init);
+ printf("%lx", (unsigned long) gpr_cv_destroy);
+ printf("%lx", (unsigned long) gpr_cv_wait);
+ printf("%lx", (unsigned long) gpr_cv_signal);
+ printf("%lx", (unsigned long) gpr_cv_broadcast);
+ printf("%lx", (unsigned long) gpr_once_init);
+ printf("%lx", (unsigned long) gpr_event_init);
+ printf("%lx", (unsigned long) gpr_event_set);
+ printf("%lx", (unsigned long) gpr_event_get);
+ printf("%lx", (unsigned long) gpr_event_wait);
+ printf("%lx", (unsigned long) gpr_ref_init);
+ printf("%lx", (unsigned long) gpr_ref);
+ printf("%lx", (unsigned long) gpr_ref_non_zero);
+ printf("%lx", (unsigned long) gpr_refn);
+ printf("%lx", (unsigned long) gpr_unref);
+ printf("%lx", (unsigned long) gpr_ref_is_unique);
+ printf("%lx", (unsigned long) gpr_stats_init);
+ printf("%lx", (unsigned long) gpr_stats_inc);
+ printf("%lx", (unsigned long) gpr_stats_read);
+ printf("%lx", (unsigned long) gpr_thd_new);
+ printf("%lx", (unsigned long) gpr_thd_options_default);
+ printf("%lx", (unsigned long) gpr_thd_options_set_detached);
+ printf("%lx", (unsigned long) gpr_thd_options_set_joinable);
+ printf("%lx", (unsigned long) gpr_thd_options_is_detached);
+ printf("%lx", (unsigned long) gpr_thd_options_is_joinable);
+ printf("%lx", (unsigned long) gpr_thd_currentid);
+ printf("%lx", (unsigned long) gpr_thd_join);
+ printf("%lx", (unsigned long) gpr_time_0);
+ printf("%lx", (unsigned long) gpr_inf_future);
+ printf("%lx", (unsigned long) gpr_inf_past);
+ printf("%lx", (unsigned long) gpr_time_init);
+ printf("%lx", (unsigned long) gpr_now);
+ printf("%lx", (unsigned long) gpr_convert_clock_type);
+ printf("%lx", (unsigned long) gpr_time_cmp);
+ printf("%lx", (unsigned long) gpr_time_max);
+ printf("%lx", (unsigned long) gpr_time_min);
+ printf("%lx", (unsigned long) gpr_time_add);
+ printf("%lx", (unsigned long) gpr_time_sub);
+ printf("%lx", (unsigned long) gpr_time_from_micros);
+ printf("%lx", (unsigned long) gpr_time_from_nanos);
+ printf("%lx", (unsigned long) gpr_time_from_millis);
+ printf("%lx", (unsigned long) gpr_time_from_seconds);
+ printf("%lx", (unsigned long) gpr_time_from_minutes);
+ printf("%lx", (unsigned long) gpr_time_from_hours);
+ printf("%lx", (unsigned long) gpr_time_to_millis);
+ printf("%lx", (unsigned long) gpr_time_similar);
+ printf("%lx", (unsigned long) gpr_sleep_until);
+ printf("%lx", (unsigned long) gpr_timespec_to_micros);
+ return 0;
+}
diff --git a/test/core/surface/secure_channel_create_test.c b/test/core/surface/secure_channel_create_test.cc
index 0c45135501..fa22cd6873 100644
--- a/test/core/surface/secure_channel_create_test.c
+++ b/test/core/surface/secure_channel_create_test.cc
@@ -30,47 +30,46 @@
void test_unknown_scheme_target(void) {
grpc_resolver_registry_shutdown();
grpc_resolver_registry_init();
- grpc_channel_credentials *creds =
+ grpc_channel_credentials* creds =
grpc_fake_transport_security_credentials_create();
- grpc_channel *chan =
- grpc_secure_channel_create(creds, "blah://blah", NULL, NULL);
- grpc_channel_element *elem =
+ grpc_channel* chan =
+ grpc_secure_channel_create(creds, "blah://blah", nullptr, nullptr);
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_channel_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
+ grpc_channel_credentials_unref(creds);
}
void test_security_connector_already_in_arg(void) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
- arg.value.pointer.p = NULL;
- arg.key = GRPC_ARG_SECURITY_CONNECTOR;
+ arg.value.pointer.p = nullptr;
+ arg.key = const_cast<char*>(GRPC_ARG_SECURITY_CONNECTOR);
grpc_channel_args args;
args.num_args = 1;
args.args = &arg;
- grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, &args, NULL);
- grpc_channel_element *elem =
+ grpc_channel* chan =
+ grpc_secure_channel_create(nullptr, nullptr, &args, nullptr);
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
}
void test_null_creds(void) {
- grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL);
- grpc_channel_element *elem =
+ grpc_channel* chan =
+ grpc_secure_channel_create(nullptr, nullptr, nullptr, nullptr);
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_security_connector_already_in_arg();
diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.cc
index d5fd2db81b..ac49bd9823 100644
--- a/test/core/surface/sequential_connectivity_test.c
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -30,50 +30,50 @@
#include "test/core/util/test_config.h"
typedef struct test_fixture {
- const char *name;
- void (*add_server_port)(grpc_server *server, const char *addr);
- grpc_channel *(*create_channel)(const char *addr);
+ const char* name;
+ void (*add_server_port)(grpc_server* server, const char* addr);
+ grpc_channel* (*create_channel)(const char* addr);
} test_fixture;
#define NUM_CONNECTIONS 1000
typedef struct {
- grpc_server *server;
- grpc_completion_queue *cq;
+ grpc_server* server;
+ grpc_completion_queue* cq;
} server_thread_args;
-static void server_thread_func(void *args) {
- server_thread_args *a = args;
+static void server_thread_func(void* args) {
+ server_thread_args* a = static_cast<server_thread_args*>(args);
grpc_event ev = grpc_completion_queue_next(
- a->cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ a->cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- GPR_ASSERT(ev.tag == NULL);
+ GPR_ASSERT(ev.tag == nullptr);
GPR_ASSERT(ev.success == true);
}
-static void run_test(const test_fixture *fixture) {
+static void run_test(const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
grpc_init();
- char *addr;
+ char* addr;
gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die());
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
fixture->add_server_port(server, addr);
- grpc_completion_queue *server_cq =
- grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(server, server_cq, NULL);
+ grpc_completion_queue* server_cq =
+ grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server, server_cq, nullptr);
grpc_server_start(server);
server_thread_args sta = {server, server_cq};
gpr_thd_id server_thread;
gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&thdopt);
- gpr_thd_new(&server_thread, server_thread_func, &sta, &thdopt);
+ gpr_thd_new(&server_thread, "grpc_server", server_thread_func, &sta, &thdopt);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel *channels[NUM_CONNECTIONS];
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_channel* channels[NUM_CONNECTIONS];
for (size_t i = 0; i < NUM_CONNECTIONS; i++) {
channels[i] = fixture->create_channel(addr);
@@ -82,31 +82,31 @@ static void run_test(const test_fixture *fixture) {
while ((state = grpc_channel_check_connectivity_state(channels[i], 1)) !=
GRPC_CHANNEL_READY) {
grpc_channel_watch_connectivity_state(channels[i], state,
- connect_deadline, cq, NULL);
+ connect_deadline, cq, nullptr);
grpc_event ev = grpc_completion_queue_next(
- cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
/* check that the watcher from "watch state" was free'd */
GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(channels[i]) ==
0);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- GPR_ASSERT(ev.tag == NULL);
+ GPR_ASSERT(ev.tag == nullptr);
GPR_ASSERT(ev.success == true);
}
}
- grpc_server_shutdown_and_notify(server, server_cq, NULL);
+ grpc_server_shutdown_and_notify(server, server_cq, nullptr);
gpr_thd_join(server_thread);
grpc_completion_queue_shutdown(server_cq);
grpc_completion_queue_shutdown(cq);
while (grpc_completion_queue_next(server_cq,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr)
.type != GRPC_QUEUE_SHUTDOWN)
;
- while (
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type != GRPC_QUEUE_SHUTDOWN)
+ while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type != GRPC_QUEUE_SHUTDOWN)
;
for (size_t i = 0; i < NUM_CONNECTIONS; i++) {
@@ -121,51 +121,55 @@ static void run_test(const test_fixture *fixture) {
gpr_free(addr);
}
-static void insecure_test_add_port(grpc_server *server, const char *addr) {
+static void insecure_test_add_port(grpc_server* server, const char* addr) {
grpc_server_add_insecure_http2_port(server, addr);
}
-static grpc_channel *insecure_test_create_channel(const char *addr) {
- return grpc_insecure_channel_create(addr, NULL, NULL);
+static grpc_channel* insecure_test_create_channel(const char* addr) {
+ return grpc_insecure_channel_create(addr, nullptr, nullptr);
}
static const test_fixture insecure_test = {
- "insecure", insecure_test_add_port, insecure_test_create_channel,
+ "insecure",
+ insecure_test_add_port,
+ insecure_test_create_channel,
};
-static void secure_test_add_port(grpc_server *server, const char *addr) {
+static void secure_test_add_port(grpc_server* server, const char* addr) {
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_cert_key_pair, 1, 0, nullptr);
grpc_server_add_secure_http2_port(server, addr, ssl_creds);
grpc_server_credentials_release(ssl_creds);
}
-static grpc_channel *secure_test_create_channel(const char *addr) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
- grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1);
- grpc_channel *channel =
- grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
+static grpc_channel* secure_test_create_channel(const char* addr) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
+ grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1);
+ grpc_channel* channel =
+ grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
grpc_channel_credentials_release(ssl_creds);
return channel;
}
static const test_fixture secure_test = {
- "secure", secure_test_add_port, secure_test_create_channel,
+ "secure",
+ secure_test_add_port,
+ secure_test_create_channel,
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_test(&insecure_test);
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.cc
index cd8931e0d7..96eaa6a7a9 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.cc
@@ -29,8 +29,8 @@
#include "test/core/util/test_config.h"
void test_unparsable_target(void) {
- grpc_channel_args args = {0, NULL};
- grpc_server *server = grpc_server_create(&args, NULL);
+ grpc_channel_args args = {0, nullptr};
+ grpc_server* server = grpc_server_create(&args, nullptr);
int port = grpc_server_add_insecure_http2_port(server, "[");
GPR_ASSERT(port == 0);
grpc_server_destroy(server);
@@ -39,15 +39,15 @@ void test_unparsable_target(void) {
void test_add_same_port_twice() {
grpc_arg a;
a.type = GRPC_ARG_INTEGER;
- a.key = GRPC_ARG_ALLOW_REUSEPORT;
+ a.key = const_cast<char*>(GRPC_ARG_ALLOW_REUSEPORT);
a.value.integer = 0;
grpc_channel_args args = {1, &a};
int port = grpc_pick_unused_port_or_die();
- char *addr = NULL;
- grpc_completion_queue *cq = grpc_completion_queue_create_for_pluck(NULL);
- grpc_server *server = grpc_server_create(&args, NULL);
- grpc_server_credentials *fake_creds =
+ char* addr = nullptr;
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr);
+ grpc_server* server = grpc_server_create(&args, nullptr);
+ grpc_server_credentials* fake_creds =
grpc_fake_transport_security_server_credentials_create();
gpr_join_host_port(&addr, "localhost", port);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds));
@@ -55,14 +55,14 @@ void test_add_same_port_twice() {
grpc_server_credentials_release(fake_creds);
gpr_free(addr);
- grpc_server_shutdown_and_notify(server, cq, NULL);
- grpc_completion_queue_pluck(cq, NULL, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ grpc_server_shutdown_and_notify(server, cq, nullptr);
+ grpc_completion_queue_pluck(cq, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr);
grpc_server_destroy(server);
grpc_completion_queue_destroy(cq);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_unparsable_target();
diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.cc
index 4c185cd8ea..969b8cb11b 100644
--- a/test/core/surface/server_test.c
+++ b/test/core/surface/server_test.cc
@@ -28,40 +28,42 @@
#include "test/core/util/test_config.h"
void test_register_method_fail(void) {
- grpc_server *server = grpc_server_create(NULL, NULL);
- void *method;
- void *method_old;
- method =
- grpc_server_register_method(server, NULL, NULL, GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method == NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
+ void* method;
+ void* method_old;
+ method = grpc_server_register_method(server, nullptr, nullptr,
+ GRPC_SRM_PAYLOAD_NONE, 0);
+ GPR_ASSERT(method == nullptr);
method_old =
grpc_server_register_method(server, "m", "h", GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method_old != NULL);
+ GPR_ASSERT(method_old != nullptr);
method = grpc_server_register_method(
server, "m", "h", GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0);
- GPR_ASSERT(method == NULL);
+ GPR_ASSERT(method == nullptr);
method_old =
grpc_server_register_method(server, "m2", "h2", GRPC_SRM_PAYLOAD_NONE,
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST);
- GPR_ASSERT(method_old != NULL);
+ GPR_ASSERT(method_old != nullptr);
method =
grpc_server_register_method(server, "m2", "h2", GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method == NULL);
+ GPR_ASSERT(method == nullptr);
method = grpc_server_register_method(
server, "m2", "h2", GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER,
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST);
- GPR_ASSERT(method == NULL);
+ GPR_ASSERT(method == nullptr);
grpc_server_destroy(server);
}
void test_request_call_on_no_server_cq(void) {
- grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL);
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_completion_queue* cc = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE ==
- grpc_server_request_call(server, NULL, NULL, NULL, cc, cc, NULL));
+ grpc_server_request_call(server, nullptr, nullptr, nullptr, cc, cc,
+ nullptr));
GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE ==
- grpc_server_request_registered_call(server, NULL, NULL, NULL, NULL,
- NULL, cc, cc, NULL));
+ grpc_server_request_registered_call(server, nullptr, nullptr,
+ nullptr, nullptr, nullptr, cc,
+ cc, nullptr));
grpc_completion_queue_destroy(cc);
grpc_server_destroy(server);
}
@@ -69,93 +71,94 @@ void test_request_call_on_no_server_cq(void) {
void test_bind_server_twice(void) {
grpc_arg a;
a.type = GRPC_ARG_INTEGER;
- a.key = GRPC_ARG_ALLOW_REUSEPORT;
+ a.key = const_cast<char*>(GRPC_ARG_ALLOW_REUSEPORT);
a.value.integer = 0;
grpc_channel_args args = {1, &a};
- char *addr;
- grpc_server *server1 = grpc_server_create(&args, NULL);
- grpc_server *server2 = grpc_server_create(&args, NULL);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ char* addr;
+ grpc_server* server1 = grpc_server_create(&args, nullptr);
+ grpc_server* server2 = grpc_server_create(&args, nullptr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
int port = grpc_pick_unused_port_or_die();
gpr_asprintf(&addr, "[::]:%d", port);
- grpc_server_register_completion_queue(server1, cq, NULL);
- grpc_server_register_completion_queue(server2, cq, NULL);
- GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, NULL));
+ grpc_server_register_completion_queue(server1, cq, nullptr);
+ grpc_server_register_completion_queue(server2, cq, nullptr);
+ GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, nullptr));
GPR_ASSERT(port == grpc_server_add_insecure_http2_port(server1, addr));
GPR_ASSERT(0 == grpc_server_add_insecure_http2_port(server2, addr));
- grpc_server_credentials *fake_creds =
+ grpc_server_credentials* fake_creds =
grpc_fake_transport_security_server_credentials_create();
GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, fake_creds));
grpc_server_credentials_release(fake_creds);
- grpc_server_shutdown_and_notify(server1, cq, NULL);
- grpc_server_shutdown_and_notify(server2, cq, NULL);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ grpc_server_shutdown_and_notify(server1, cq, nullptr);
+ grpc_server_shutdown_and_notify(server2, cq, nullptr);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
grpc_server_destroy(server1);
grpc_server_destroy(server2);
grpc_completion_queue_destroy(cq);
gpr_free(addr);
}
-void test_bind_server_to_addr(const char *host, bool secure) {
+void test_bind_server_to_addr(const char* host, bool secure) {
int port = grpc_pick_unused_port_or_die();
- char *addr;
+ char* addr;
gpr_join_host_port(&addr, host, port);
gpr_log(GPR_INFO, "Test bind to %s", addr);
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
if (secure) {
- grpc_server_credentials *fake_creds =
+ grpc_server_credentials* fake_creds =
grpc_fake_transport_security_server_credentials_create();
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds));
grpc_server_credentials_release(fake_creds);
} else {
GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr));
}
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server, cq, nullptr);
grpc_server_start(server);
- grpc_server_shutdown_and_notify(server, cq, NULL);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ grpc_server_shutdown_and_notify(server, cq, nullptr);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
grpc_server_destroy(server);
grpc_completion_queue_destroy(cq);
gpr_free(addr);
}
-static int external_dns_works(const char *host) {
- grpc_resolved_addresses *res = NULL;
- grpc_error *error = grpc_blocking_resolve_address(host, "80", &res);
+static int external_dns_works(const char* host) {
+ grpc_resolved_addresses* res = nullptr;
+ grpc_error* error = grpc_blocking_resolve_address(host, "80", &res);
GRPC_ERROR_UNREF(error);
- if (res != NULL) {
+ if (res != nullptr) {
grpc_resolved_addresses_destroy(res);
return 1;
}
return 0;
}
-static void test_bind_server_to_addrs(const char **addrs, size_t n) {
+static void test_bind_server_to_addrs(const char** addrs, size_t n) {
for (size_t i = 0; i < n; i++) {
test_bind_server_to_addr(addrs[i], false);
test_bind_server_to_addr(addrs[i], true);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_register_method_fail();
test_request_call_on_no_server_cq();
test_bind_server_twice();
- static const char *addrs[] = {
+ static const char* addrs[] = {
"::1", "127.0.0.1", "::ffff:127.0.0.1", "localhost", "0.0.0.0", "::",
};
test_bind_server_to_addrs(addrs, GPR_ARRAY_SIZE(addrs));
if (external_dns_works("loopback46.unittest.grpc.io")) {
- static const char *dns_addrs[] = {
- "loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io",
+ static const char* dns_addrs[] = {
+ "loopback46.unittest.grpc.io",
+ "loopback4.unittest.grpc.io",
};
test_bind_server_to_addrs(dns_addrs, GPR_ARRAY_SIZE(dns_addrs));
}
diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD
index 12e36132c8..b31d4ff899 100644
--- a/test/core/transport/BUILD
+++ b/test/core/transport/BUILD
@@ -20,20 +20,23 @@ grpc_package(name = "test/core/transport")
grpc_cc_test(
name = "bdp_estimator_test",
- srcs = ["bdp_estimator_test.c"],
- language = "C",
+ srcs = ["bdp_estimator_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
grpc_cc_test(
name = "byte_stream_test",
- srcs = ["byte_stream_test.c"],
- language = "C",
+ srcs = ["byte_stream_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +47,8 @@ grpc_cc_test(
grpc_cc_test(
name = "connectivity_state_test",
- srcs = ["connectivity_state_test.c"],
- language = "C",
+ srcs = ["connectivity_state_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -56,8 +59,8 @@ grpc_cc_test(
grpc_cc_test(
name = "metadata_test",
- srcs = ["metadata_test.c"],
- language = "C",
+ srcs = ["metadata_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -68,20 +71,23 @@ grpc_cc_test(
grpc_cc_test(
name = "pid_controller_test",
- srcs = ["pid_controller_test.c"],
- language = "C",
+ srcs = ["pid_controller_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
grpc_cc_test(
name = "status_conversion_test",
- srcs = ["status_conversion_test.c"],
- language = "C",
+ srcs = ["status_conversion_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -92,8 +98,8 @@ grpc_cc_test(
grpc_cc_test(
name = "stream_owned_slice_test",
- srcs = ["stream_owned_slice_test.c"],
- language = "C",
+ srcs = ["stream_owned_slice_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -104,8 +110,8 @@ grpc_cc_test(
grpc_cc_test(
name = "timeout_encoding_test",
- srcs = ["timeout_encoding_test.c"],
- language = "C",
+ srcs = ["timeout_encoding_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c
deleted file mode 100644
index dda48f45b1..0000000000
--- a/test/core/transport/bdp_estimator_test.c
+++ /dev/null
@@ -1,144 +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 "src/core/lib/transport/bdp_estimator.h"
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-#include <limits.h>
-#include "src/core/lib/support/string.h"
-#include "test/core/util/test_config.h"
-
-static void test_noop(void) {
- gpr_log(GPR_INFO, "test_noop");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
-}
-
-static void test_get_estimate_no_samples(void) {
- gpr_log(GPR_INFO, "test_get_estimate_no_samples");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static void add_samples(grpc_bdp_estimator *estimator, int64_t *samples,
- size_t n) {
- grpc_bdp_estimator_add_incoming_bytes(estimator, 1234567);
- GPR_ASSERT(grpc_bdp_estimator_need_ping(estimator) == true);
- grpc_bdp_estimator_schedule_ping(estimator);
- grpc_bdp_estimator_start_ping(estimator);
- for (size_t i = 0; i < n; i++) {
- grpc_bdp_estimator_add_incoming_bytes(estimator, samples[i]);
- GPR_ASSERT(grpc_bdp_estimator_need_ping(estimator) == false);
- }
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_millis(1, GPR_TIMESPAN)));
- grpc_bdp_estimator_complete_ping(estimator);
-}
-
-static void add_sample(grpc_bdp_estimator *estimator, int64_t sample) {
- add_samples(estimator, &sample, 1);
-}
-
-static void test_get_estimate_1_sample(void) {
- gpr_log(GPR_INFO, "test_get_estimate_1_sample");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- add_sample(&est, 100);
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static void test_get_estimate_2_samples(void) {
- gpr_log(GPR_INFO, "test_get_estimate_2_samples");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- add_sample(&est, 100);
- add_sample(&est, 100);
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static int64_t get_estimate(grpc_bdp_estimator *estimator) {
- int64_t out;
- GPR_ASSERT(grpc_bdp_estimator_get_estimate(estimator, &out));
- return out;
-}
-
-static void test_get_estimate_3_samples(void) {
- gpr_log(GPR_INFO, "test_get_estimate_3_samples");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- add_sample(&est, 100);
- add_sample(&est, 100);
- add_sample(&est, 100);
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static int64_t next_pow_2(int64_t v) {
- v--;
- v |= v >> 1;
- v |= v >> 2;
- v |= v >> 4;
- v |= v >> 8;
- v |= v >> 16;
- v |= v >> 32;
- v++;
- return v;
-}
-
-static void test_get_estimate_random_values(size_t n) {
- gpr_log(GPR_INFO, "test_get_estimate_random_values(%" PRIdPTR ")", n);
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- const int kMaxSample = 65535;
- int min = kMaxSample;
- int max = 0;
- for (size_t i = 0; i < n; i++) {
- int sample = rand() % (kMaxSample + 1);
- if (sample < min) min = sample;
- if (sample > max) max = sample;
- add_sample(&est, sample);
- if (i >= 3) {
- gpr_log(GPR_DEBUG, "est:%" PRId64 " min:%d max:%d", get_estimate(&est),
- min, max);
- GPR_ASSERT(get_estimate(&est) <= GPR_MAX(65536, 2 * next_pow_2(max)));
- }
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- grpc_init();
- test_noop();
- test_get_estimate_no_samples();
- test_get_estimate_1_sample();
- test_get_estimate_2_samples();
- test_get_estimate_3_samples();
- for (size_t i = 3; i < 1000; i = i * 3 / 2) {
- test_get_estimate_random_values(i);
- }
- grpc_shutdown();
- return 0;
-}
diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc
new file mode 100644
index 0000000000..3afcad7f17
--- /dev/null
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -0,0 +1,148 @@
+/*
+ *
+ * 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 "src/core/lib/transport/bdp_estimator.h"
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+#include <gtest/gtest.h>
+#include <limits.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/timer_manager.h"
+#include "test/core/util/test_config.h"
+
+extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
+
+namespace grpc_core {
+namespace testing {
+namespace {
+int g_clock = 0;
+
+gpr_timespec fake_gpr_now(gpr_clock_type clock_type) {
+ gpr_timespec ts;
+ ts.tv_sec = g_clock;
+ ts.tv_nsec = 0;
+ ts.clock_type = clock_type;
+ return ts;
+}
+
+void inc_time(void) { g_clock += 30; }
+} // namespace
+
+TEST(BdpEstimatorTest, NoOp) { BdpEstimator est("test"); }
+
+TEST(BdpEstimatorTest, EstimateBdpNoSamples) {
+ BdpEstimator est("test");
+ est.EstimateBdp();
+}
+
+namespace {
+void AddSamples(BdpEstimator* estimator, int64_t* samples, size_t n) {
+ estimator->AddIncomingBytes(1234567);
+ inc_time();
+ grpc_core::ExecCtx exec_ctx;
+ estimator->SchedulePing();
+ estimator->StartPing();
+ for (size_t i = 0; i < n; i++) {
+ estimator->AddIncomingBytes(samples[i]);
+ }
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(1, GPR_TIMESPAN)));
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ estimator->CompletePing();
+}
+
+void AddSample(BdpEstimator* estimator, int64_t sample) {
+ AddSamples(estimator, &sample, 1);
+}
+} // namespace
+
+TEST(BdpEstimatorTest, GetEstimate1Sample) {
+ BdpEstimator est("test");
+ AddSample(&est, 100);
+ est.EstimateBdp();
+}
+
+TEST(BdpEstimatorTest, GetEstimate2Samples) {
+ BdpEstimator est("test");
+ AddSample(&est, 100);
+ AddSample(&est, 100);
+ est.EstimateBdp();
+}
+
+TEST(BdpEstimatorTest, GetEstimate3Samples) {
+ BdpEstimator est("test");
+ AddSample(&est, 100);
+ AddSample(&est, 100);
+ AddSample(&est, 100);
+ est.EstimateBdp();
+}
+
+namespace {
+int64_t NextPow2(int64_t v) {
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v |= v >> 32;
+ v++;
+ return v;
+}
+} // namespace
+
+class BdpEstimatorRandomTest : public ::testing::TestWithParam<size_t> {};
+
+TEST_P(BdpEstimatorRandomTest, GetEstimateRandomValues) {
+ BdpEstimator est("test");
+ const int kMaxSample = 65535;
+ int min = kMaxSample;
+ int max = 0;
+ for (size_t i = 0; i < GetParam(); i++) {
+ int sample = rand() % (kMaxSample + 1);
+ if (sample < min) min = sample;
+ if (sample > max) max = sample;
+ AddSample(&est, sample);
+ if (i >= 3) {
+ EXPECT_LE(est.EstimateBdp(), GPR_MAX(65536, 2 * NextPow2(max)))
+ << " min:" << min << " max:" << max << " sample:" << sample;
+ }
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(TooManyNames, BdpEstimatorRandomTest,
+ ::testing::Values(3, 4, 6, 9, 13, 19, 28, 42, 63, 94,
+ 141, 211, 316, 474, 711));
+
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ gpr_now_impl = grpc_core::testing::fake_gpr_now;
+ grpc_init();
+ grpc_timer_manager_set_threading(false);
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
+}
diff --git a/test/core/transport/byte_stream_test.c b/test/core/transport/byte_stream_test.cc
index a0c5f961cf..2aab6e9262 100644
--- a/test/core/transport/byte_stream_test.c
+++ b/test/core/transport/byte_stream_test.cc
@@ -18,6 +18,7 @@
#include "src/core/lib/transport/byte_stream.h"
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
@@ -30,14 +31,13 @@
// grpc_slice_buffer_stream tests
//
-static void not_called_closure(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void not_called_closure(void* arg, grpc_error* error) {
GPR_ASSERT(false);
}
static void test_slice_buffer_stream_basic(void) {
gpr_log(GPR_DEBUG, "test_slice_buffer_stream_basic");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
// Create and populate slice buffer.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -53,27 +53,25 @@ static void test_slice_buffer_stream_basic(void) {
grpc_slice_buffer_stream_init(&stream, &buffer, 0);
GPR_ASSERT(stream.base.length == 6);
grpc_closure closure;
- GRPC_CLOSURE_INIT(&closure, not_called_closure, NULL,
+ GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read each slice. Note that next() always returns synchronously.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_slice_buffer_stream_shutdown(void) {
gpr_log(GPR_DEBUG, "test_slice_buffer_stream_shutdown");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
// Create and populate slice buffer.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -89,32 +87,28 @@ static void test_slice_buffer_stream_shutdown(void) {
grpc_slice_buffer_stream_init(&stream, &buffer, 0);
GPR_ASSERT(stream.base.length == 6);
grpc_closure closure;
- GRPC_CLOSURE_INIT(&closure, not_called_closure, NULL,
+ GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read the first slice.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Now shutdown.
- grpc_error *shutdown_error =
+ grpc_error* shutdown_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown error");
- grpc_byte_stream_shutdown(&exec_ctx, &stream.base,
- GRPC_ERROR_REF(shutdown_error));
+ grpc_byte_stream_shutdown(&stream.base, GRPC_ERROR_REF(shutdown_error));
// After shutdown, the next pull() should return the error.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == shutdown_error);
GRPC_ERROR_UNREF(error);
GRPC_ERROR_UNREF(shutdown_error);
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
//
@@ -123,7 +117,7 @@ static void test_slice_buffer_stream_shutdown(void) {
static void test_caching_byte_stream_basic(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_basic");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -142,29 +136,27 @@ static void test_caching_byte_stream_basic(void) {
grpc_caching_byte_stream stream;
grpc_caching_byte_stream_init(&stream, &cache);
grpc_closure closure;
- GRPC_CLOSURE_INIT(&closure, not_called_closure, NULL,
+ GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read each slice. Note that next() always returns synchronously,
// because the underlying byte stream always does.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_caching_byte_stream_reset(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_reset");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -183,37 +175,34 @@ static void test_caching_byte_stream_reset(void) {
grpc_caching_byte_stream stream;
grpc_caching_byte_stream_init(&stream, &cache);
grpc_closure closure;
- GRPC_CLOSURE_INIT(&closure, not_called_closure, NULL,
+ GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read one slice.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Reset the caching stream. The reads should start over from the
// first slice.
grpc_caching_byte_stream_reset(&stream);
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_caching_byte_stream_shared_cache(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_shared_cache");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -234,46 +223,44 @@ static void test_caching_byte_stream_shared_cache(void) {
grpc_caching_byte_stream stream2;
grpc_caching_byte_stream_init(&stream2, &cache);
grpc_closure closure;
- GRPC_CLOSURE_INIT(&closure, not_called_closure, NULL,
+ GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read one slice from stream1.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream1.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Read all slices from stream2.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream2.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream2.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream2.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream2.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Now read the second slice from stream1.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream1.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[1], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream1.base);
- grpc_byte_stream_destroy(&exec_ctx, &stream2.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream1.base);
+ grpc_byte_stream_destroy(&stream2.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
+ grpc_init();
grpc_test_init(argc, argv);
test_slice_buffer_stream_basic();
test_slice_buffer_stream_shutdown();
test_caching_byte_stream_basic();
test_caching_byte_stream_reset();
test_caching_byte_stream_shared_cache();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/chttp2/BUILD b/test/core/transport/chttp2/BUILD
index 6081940243..6eff716b01 100644
--- a/test/core/transport/chttp2/BUILD
+++ b/test/core/transport/chttp2/BUILD
@@ -22,7 +22,7 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "hpack_parser_fuzzer",
- srcs = ["hpack_parser_fuzzer_test.c"],
+ srcs = ["hpack_parser_fuzzer_test.cc"],
corpus = "hpack_parser_corpus",
deps = [
"//:grpc",
@@ -32,8 +32,8 @@ grpc_fuzzer(
grpc_cc_test(
name = "alpn_test",
- srcs = ["alpn_test.c"],
- language = "C",
+ srcs = ["alpn_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +44,8 @@ grpc_cc_test(
grpc_cc_test(
name = "bin_decoder_test",
- srcs = ["bin_decoder_test.c"],
- language = "C",
+ srcs = ["bin_decoder_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -56,8 +56,8 @@ grpc_cc_test(
grpc_cc_test(
name = "bin_encoder_test",
- srcs = ["bin_encoder_test.c"],
- language = "C",
+ srcs = ["bin_encoder_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -68,8 +68,8 @@ grpc_cc_test(
grpc_cc_test(
name = "hpack_encoder_test",
- srcs = ["hpack_encoder_test.c"],
- language = "C",
+ srcs = ["hpack_encoder_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -80,8 +80,8 @@ grpc_cc_test(
grpc_cc_test(
name = "hpack_parser_test",
- srcs = ["hpack_parser_test.c"],
- language = "C",
+ srcs = ["hpack_parser_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -92,8 +92,8 @@ grpc_cc_test(
grpc_cc_test(
name = "hpack_table_test",
- srcs = ["hpack_table_test.c"],
- language = "C",
+ srcs = ["hpack_table_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -104,8 +104,8 @@ grpc_cc_test(
grpc_cc_test(
name = "stream_map_test",
- srcs = ["stream_map_test.c"],
- language = "C",
+ srcs = ["stream_map_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -115,9 +115,24 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "settings_timeout_test",
+ srcs = ["settings_timeout_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
name = "varint_test",
- srcs = ["varint_test.c"],
- language = "C",
+ srcs = ["varint_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/transport/chttp2/alpn_test.c b/test/core/transport/chttp2/alpn_test.cc
index 72c30c40eb..a43377393e 100644
--- a/test/core/transport/chttp2/alpn_test.c
+++ b/test/core/transport/chttp2/alpn_test.cc
@@ -33,7 +33,7 @@ static void test_alpn_failure(void) {
// First index in ALPN supported version list of a given protocol. Returns a
// value one beyond the last valid element index if not found.
-static size_t alpn_version_index(const char *version, size_t size) {
+static size_t alpn_version_index(const char* version, size_t size) {
size_t i;
for (i = 0; i < grpc_chttp2_num_alpn_versions(); ++i) {
if (!strncmp(version, grpc_chttp2_get_alpn_version_index(i), size)) {
@@ -48,7 +48,7 @@ static void test_alpn_grpc_before_h2(void) {
GPR_ASSERT(alpn_version_index("grpc-exp", 8) < alpn_version_index("h2", 2));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_alpn_success();
test_alpn_failure();
diff --git a/test/core/transport/chttp2/bin_decoder_test.c b/test/core/transport/chttp2/bin_decoder_test.c
deleted file mode 100644
index 775161ec91..0000000000
--- a/test/core/transport/chttp2/bin_decoder_test.c
+++ /dev/null
@@ -1,143 +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 "src/core/ext/transport/chttp2/transport/bin_decoder.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
-
-static int all_ok = 1;
-
-static void expect_slice_eq(grpc_exec_ctx *exec_ctx, grpc_slice expected,
- grpc_slice slice, char *debug, int line) {
- if (!grpc_slice_eq(slice, expected)) {
- char *hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs,
- he);
- gpr_free(hs);
- gpr_free(he);
- all_ok = 0;
- }
- grpc_slice_unref_internal(exec_ctx, expected);
- grpc_slice_unref_internal(exec_ctx, slice);
-}
-
-static grpc_slice base64_encode(grpc_exec_ctx *exec_ctx, const char *s) {
- grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out = grpc_chttp2_base64_encode(ss);
- grpc_slice_unref_internal(exec_ctx, ss);
- return out;
-}
-
-static grpc_slice base64_decode(grpc_exec_ctx *exec_ctx, const char *s) {
- grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out = grpc_chttp2_base64_decode(exec_ctx, ss);
- grpc_slice_unref_internal(exec_ctx, ss);
- return out;
-}
-
-static grpc_slice base64_decode_with_length(grpc_exec_ctx *exec_ctx,
- const char *s,
- size_t output_length) {
- grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out =
- grpc_chttp2_base64_decode_with_length(exec_ctx, ss, output_length);
- grpc_slice_unref_internal(exec_ctx, ss);
- return out;
-}
-
-#define EXPECT_SLICE_EQ(exec_ctx, expected, slice) \
- expect_slice_eq( \
- exec_ctx, grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), \
- slice, #slice, __LINE__);
-
-#define ENCODE_AND_DECODE(exec_ctx, s) \
- EXPECT_SLICE_EQ(exec_ctx, s, \
- grpc_chttp2_base64_decode_with_length( \
- exec_ctx, base64_encode(exec_ctx, s), strlen(s)));
-
-int main(int argc, char **argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- /* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which
- takes encoded base64 strings without pad chars, but output length is
- required. */
- /* Base64 test vectors from RFC 4648 */
- ENCODE_AND_DECODE(&exec_ctx, "");
- ENCODE_AND_DECODE(&exec_ctx, "f");
- ENCODE_AND_DECODE(&exec_ctx, "foo");
- ENCODE_AND_DECODE(&exec_ctx, "fo");
- ENCODE_AND_DECODE(&exec_ctx, "foob");
- ENCODE_AND_DECODE(&exec_ctx, "fooba");
- ENCODE_AND_DECODE(&exec_ctx, "foobar");
-
- ENCODE_AND_DECODE(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5");
-
- /* Base64 test vectors from RFC 4648, with pad chars */
- /* BASE64("") = "" */
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, ""));
- /* BASE64("f") = "Zg==" */
- EXPECT_SLICE_EQ(&exec_ctx, "f", base64_decode(&exec_ctx, "Zg=="));
- /* BASE64("fo") = "Zm8=" */
- EXPECT_SLICE_EQ(&exec_ctx, "fo", base64_decode(&exec_ctx, "Zm8="));
- /* BASE64("foo") = "Zm9v" */
- EXPECT_SLICE_EQ(&exec_ctx, "foo", base64_decode(&exec_ctx, "Zm9v"));
- /* BASE64("foob") = "Zm9vYg==" */
- EXPECT_SLICE_EQ(&exec_ctx, "foob", base64_decode(&exec_ctx, "Zm9vYg=="));
- /* BASE64("fooba") = "Zm9vYmE=" */
- EXPECT_SLICE_EQ(&exec_ctx, "fooba", base64_decode(&exec_ctx, "Zm9vYmE="));
- /* BASE64("foobar") = "Zm9vYmFy" */
- EXPECT_SLICE_EQ(&exec_ctx, "foobar", base64_decode(&exec_ctx, "Zm9vYmFy"));
-
- EXPECT_SLICE_EQ(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5",
- base64_decode(&exec_ctx, "wMHCw8TF"));
-
- // Test illegal input length in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "a"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "ab"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "abc"));
-
- // Test illegal charactors in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm:v"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm=v"));
-
- // Test output_length longer than max possible output length in
- // grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode_with_length(&exec_ctx, "Zg", 2));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm8", 3));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm9v", 4));
-
- // Test illegal charactors in grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm:v", 3));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm=v", 3));
-
- grpc_exec_ctx_finish(&exec_ctx);
-
- return all_ok ? 0 : 1;
-}
diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc
new file mode 100644
index 0000000000..283eebbacf
--- /dev/null
+++ b/test/core/transport/chttp2/bin_decoder_test.cc
@@ -0,0 +1,137 @@
+/*
+ *
+ * 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 "src/core/ext/transport/chttp2/transport/bin_decoder.h"
+
+#include <string.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+
+static int all_ok = 1;
+
+static void expect_slice_eq(grpc_slice expected, grpc_slice slice,
+ const char* debug, int line) {
+ if (!grpc_slice_eq(slice, expected)) {
+ char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs,
+ he);
+ gpr_free(hs);
+ gpr_free(he);
+ all_ok = 0;
+ }
+ grpc_slice_unref_internal(expected);
+ grpc_slice_unref_internal(slice);
+}
+
+static grpc_slice base64_encode(const char* s) {
+ grpc_slice ss = grpc_slice_from_copied_string(s);
+ grpc_slice out = grpc_chttp2_base64_encode(ss);
+ grpc_slice_unref_internal(ss);
+ return out;
+}
+
+static grpc_slice base64_decode(const char* s) {
+ grpc_slice ss = grpc_slice_from_copied_string(s);
+ grpc_slice out = grpc_chttp2_base64_decode(ss);
+ grpc_slice_unref_internal(ss);
+ return out;
+}
+
+static grpc_slice base64_decode_with_length(const char* s,
+ size_t output_length) {
+ grpc_slice ss = grpc_slice_from_copied_string(s);
+ grpc_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length);
+ grpc_slice_unref_internal(ss);
+ return out;
+}
+
+#define EXPECT_SLICE_EQ(expected, slice) \
+ expect_slice_eq( \
+ grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \
+ #slice, __LINE__);
+
+#define ENCODE_AND_DECODE(s) \
+ EXPECT_SLICE_EQ( \
+ s, grpc_chttp2_base64_decode_with_length(base64_encode(s), strlen(s)));
+
+int main(int argc, char** argv) {
+ grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+
+ /* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which
+ takes encoded base64 strings without pad chars, but output length is
+ required. */
+ /* Base64 test vectors from RFC 4648 */
+ ENCODE_AND_DECODE("");
+ ENCODE_AND_DECODE("f");
+ ENCODE_AND_DECODE("foo");
+ ENCODE_AND_DECODE("fo");
+ ENCODE_AND_DECODE("foob");
+ ENCODE_AND_DECODE("fooba");
+ ENCODE_AND_DECODE("foobar");
+
+ ENCODE_AND_DECODE("\xc0\xc1\xc2\xc3\xc4\xc5");
+
+ /* Base64 test vectors from RFC 4648, with pad chars */
+ /* BASE64("") = "" */
+ EXPECT_SLICE_EQ("", base64_decode(""));
+ /* BASE64("f") = "Zg==" */
+ EXPECT_SLICE_EQ("f", base64_decode("Zg=="));
+ /* BASE64("fo") = "Zm8=" */
+ EXPECT_SLICE_EQ("fo", base64_decode("Zm8="));
+ /* BASE64("foo") = "Zm9v" */
+ EXPECT_SLICE_EQ("foo", base64_decode("Zm9v"));
+ /* BASE64("foob") = "Zm9vYg==" */
+ EXPECT_SLICE_EQ("foob", base64_decode("Zm9vYg=="));
+ /* BASE64("fooba") = "Zm9vYmE=" */
+ EXPECT_SLICE_EQ("fooba", base64_decode("Zm9vYmE="));
+ /* BASE64("foobar") = "Zm9vYmFy" */
+ EXPECT_SLICE_EQ("foobar", base64_decode("Zm9vYmFy"));
+
+ EXPECT_SLICE_EQ("\xc0\xc1\xc2\xc3\xc4\xc5", base64_decode("wMHCw8TF"));
+
+ // Test illegal input length in grpc_chttp2_base64_decode
+ EXPECT_SLICE_EQ("", base64_decode("a"));
+ EXPECT_SLICE_EQ("", base64_decode("ab"));
+ EXPECT_SLICE_EQ("", base64_decode("abc"));
+
+ // Test illegal charactors in grpc_chttp2_base64_decode
+ EXPECT_SLICE_EQ("", base64_decode("Zm:v"));
+ EXPECT_SLICE_EQ("", base64_decode("Zm=v"));
+
+ // Test output_length longer than max possible output length in
+ // grpc_chttp2_base64_decode_with_length
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zg", 2));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm8", 3));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm9v", 4));
+
+ // Test illegal charactors in grpc_chttp2_base64_decode_with_length
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm:v", 3));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm=v", 3));
+ }
+ grpc_shutdown();
+ return all_ok ? 0 : 1;
+}
diff --git a/test/core/transport/chttp2/bin_encoder_test.c b/test/core/transport/chttp2/bin_encoder_test.cc
index acadcf6c89..bd62b0e479 100644
--- a/test/core/transport/chttp2/bin_encoder_test.c
+++ b/test/core/transport/chttp2/bin_encoder_test.cc
@@ -26,16 +26,16 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
static int all_ok = 1;
-static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug,
- int line) {
+static void expect_slice_eq(grpc_slice expected, grpc_slice slice,
+ const char* debug, int line) {
if (!grpc_slice_eq(slice, expected)) {
- char *hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs,
he);
gpr_free(hs);
@@ -46,14 +46,14 @@ static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug,
grpc_slice_unref(slice);
}
-static grpc_slice B64(const char *s) {
+static grpc_slice B64(const char* s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
grpc_slice out = grpc_chttp2_base64_encode(ss);
grpc_slice_unref(ss);
return out;
}
-static grpc_slice HUFF(const char *s) {
+static grpc_slice HUFF(const char* s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
grpc_slice out = grpc_chttp2_huffman_compress(ss);
grpc_slice_unref(ss);
@@ -65,15 +65,15 @@ static grpc_slice HUFF(const char *s) {
grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \
#slice, __LINE__);
-static void expect_combined_equiv(const char *s, size_t len, int line) {
+static void expect_combined_equiv(const char* s, size_t len, int line) {
grpc_slice input = grpc_slice_from_copied_buffer(s, len);
grpc_slice base64 = grpc_chttp2_base64_encode(input);
grpc_slice expect = grpc_chttp2_huffman_compress(base64);
grpc_slice got = grpc_chttp2_base64_encode_and_huffman_compress(input);
if (!grpc_slice_eq(expect, got)) {
- char *t = grpc_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *e = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *g = grpc_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* t = grpc_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* e = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* g = grpc_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "FAILED:%d:\ntest: %s\ngot: %s\nwant: %s", line, t, g,
e);
gpr_free(t);
@@ -90,7 +90,7 @@ static void expect_combined_equiv(const char *s, size_t len, int line) {
#define EXPECT_COMBINED_EQUIV(x) \
expect_combined_equiv(x, sizeof(x) - 1, __LINE__)
-static void expect_binary_header(const char *hdr, int binary) {
+static void expect_binary_header(const char* hdr, int binary) {
if (grpc_is_binary_header(grpc_slice_from_static_string(hdr)) != binary) {
gpr_log(GPR_ERROR, "FAILED: expected header '%s' to be %s", hdr,
binary ? "binary" : "not binary");
@@ -98,7 +98,9 @@ static void expect_binary_header(const char *hdr, int binary) {
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
+ grpc_init();
+
/* Base64 test vectors from RFC 4648, with padding removed */
/* BASE64("") = "" */
EXPECT_SLICE_EQ("", B64(""));
@@ -169,5 +171,6 @@ int main(int argc, char **argv) {
expect_binary_header("foo-bar", 0);
expect_binary_header("-bin", 0);
+ grpc_shutdown();
return all_ok ? 0 : 1;
}
diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.cc
index ed51dd1859..a40bd643ec 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.c
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -26,9 +26,9 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/util/parse_hexstring.h"
#include "test/core/util/slice_splitter.h"
@@ -39,39 +39,48 @@
grpc_chttp2_hpack_compressor g_compressor;
int g_failure = 0;
-void **to_delete = NULL;
+void** to_delete = nullptr;
size_t num_to_delete = 0;
size_t cap_to_delete = 0;
+typedef struct {
+ bool eof;
+ bool use_true_binary_metadata;
+ bool only_intern_key;
+} verify_params;
+
/* verify that the output generated by encoding the stream matches the
hexstring passed in */
-static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
- bool use_true_binary_metadata, size_t expect_window_used,
- const char *expected, size_t nheaders, ...) {
+static void verify(const verify_params params, const char* expected,
+ size_t nheaders, ...) {
grpc_slice_buffer output;
grpc_slice merged;
grpc_slice expect = parse_hexstring(expected);
size_t i;
va_list l;
- grpc_linked_mdelem *e = gpr_malloc(sizeof(*e) * nheaders);
+ grpc_linked_mdelem* e =
+ static_cast<grpc_linked_mdelem*>(gpr_malloc(sizeof(*e) * nheaders));
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
va_start(l, nheaders);
for (i = 0; i < nheaders; i++) {
- char *key = va_arg(l, char *);
- char *value = va_arg(l, char *);
+ char* key = va_arg(l, char*);
+ char* value = va_arg(l, char*);
if (i) {
e[i - 1].next = &e[i];
e[i].prev = &e[i - 1];
}
+ grpc_slice value_slice = grpc_slice_from_static_string(value);
+ if (!params.only_intern_key) {
+ value_slice = grpc_slice_intern(value_slice);
+ }
e[i].md = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
- grpc_slice_intern(grpc_slice_from_static_string(value)));
+ grpc_slice_intern(grpc_slice_from_static_string(key)), value_slice);
}
- e[0].prev = NULL;
- e[nheaders - 1].next = NULL;
+ e[0].prev = nullptr;
+ e[nheaders - 1].next = nullptr;
va_end(l);
b.list.head = &e[0];
@@ -80,7 +89,8 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
if (cap_to_delete == num_to_delete) {
cap_to_delete = GPR_MAX(2 * cap_to_delete, 1000);
- to_delete = gpr_realloc(to_delete, sizeof(*to_delete) * cap_to_delete);
+ to_delete = static_cast<void**>(
+ gpr_realloc(to_delete, sizeof(*to_delete) * cap_to_delete));
}
to_delete[num_to_delete++] = e;
@@ -89,21 +99,20 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
grpc_encode_header_options hopt = {
- .stream_id = 0xdeadbeef,
- .is_eof = eof,
- .use_true_binary_metadata = use_true_binary_metadata,
- .max_frame_size = 16384,
- .stats = &stats,
+ 0xdeadbeef, /* stream_id */
+ params.eof, /* is_eof */
+ params.use_true_binary_metadata, /* use_true_binary_metadata */
+ 16384, /* max_frame_size */
+ &stats /* stats */
};
- grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt,
- &output);
+ grpc_chttp2_encode_header(&g_compressor, nullptr, 0, &b, &hopt, &output);
merged = grpc_slice_merge(output.slices, output.count);
- grpc_slice_buffer_destroy_internal(exec_ctx, &output);
- grpc_metadata_batch_destroy(exec_ctx, &b);
+ grpc_slice_buffer_destroy_internal(&output);
+ grpc_metadata_batch_destroy(&b);
if (!grpc_slice_eq(merged, expect)) {
- char *expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *got_str = grpc_dump_slice(merged, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ char* got_str = grpc_dump_slice(merged, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "mismatched output for %s", expected);
gpr_log(GPR_ERROR, "EXPECT: %s", expect_str);
gpr_log(GPR_ERROR, "GOT: %s", got_str);
@@ -112,38 +121,37 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
g_failure = 1;
}
- grpc_slice_unref_internal(exec_ctx, merged);
- grpc_slice_unref_internal(exec_ctx, expect);
+ grpc_slice_unref_internal(merged);
+ grpc_slice_unref_internal(expect);
}
-static void test_basic_headers(grpc_exec_ctx *exec_ctx) {
+static void test_basic_headers() {
int i;
- verify(exec_ctx, 0, false, false, 0, "000005 0104 deadbeef 40 0161 0161", 1,
- "a", "a");
- verify(exec_ctx, 0, false, false, 0, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, 0, false, false, 0, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, 0, false, false, 0, "000006 0104 deadbeef be 40 0162 0163",
- 2, "a", "a", "b", "c");
- verify(exec_ctx, 0, false, false, 0, "000002 0104 deadbeef bf be", 2, "a",
- "a", "b", "c");
- verify(exec_ctx, 0, false, false, 0, "000004 0104 deadbeef 7f 00 0164", 1,
- "a", "d");
+ verify_params params = {
+ false,
+ false,
+ false,
+ };
+ verify(params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
+ verify(params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(params, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a", "b", "c");
+ verify(params, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
+ verify(params, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
/* flush out what's there to make a few values look very popular */
for (i = 0; i < 350; i++) {
- verify(exec_ctx, 0, false, false, 0, "000003 0104 deadbeef c0 bf be", 3,
- "a", "a", "b", "c", "a", "d");
+ verify(params, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b", "c", "a",
+ "d");
}
- verify(exec_ctx, 0, false, false, 0, "000006 0104 deadbeef c0 00 016b 0176",
- 2, "a", "a", "k", "v");
+ verify(params, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a", "k", "v");
/* this could be 000004 0104 deadbeef 0f 30 0176 also */
- verify(exec_ctx, 0, false, false, 0, "000004 0104 deadbeef 0f 2f 0176", 1,
- "a", "v");
+ verify(params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
}
-static void encode_int_to_str(int i, char *p) {
+static void encode_int_to_str(int i, char* p) {
p[0] = (char)('a' + i % 26);
i /= 26;
GPR_ASSERT(i < 26);
@@ -151,10 +159,16 @@ static void encode_int_to_str(int i, char *p) {
p[2] = 0;
}
-static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) {
+static void test_decode_table_overflow() {
int i;
char key[3], value[3];
- char *expect;
+ char* expect;
+
+ verify_params params = {
+ false,
+ false,
+ false,
+ };
for (i = 0; i < 114; i++) {
encode_int_to_str(i, key);
@@ -174,34 +188,34 @@ static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) {
}
if (i > 0) {
- verify(exec_ctx, 0, false, false, 0, expect, 2, "aa", "ba", key, value);
+ verify(params, expect, 2, "aa", "ba", key, value);
} else {
- verify(exec_ctx, 0, false, false, 0, expect, 1, key, value);
+ verify(params, expect, 1, key, value);
}
gpr_free(expect);
}
/* if the above passes, then we must have just knocked this pair out of the
decoder stack, and so we'll be forced to re-encode it */
- verify(exec_ctx, 0, false, false, 0, "000007 0104 deadbeef 40 026161 026261",
- 1, "aa", "ba");
+ verify(params, "000007 0104 deadbeef 40 026161 026261", 1, "aa", "ba");
}
-static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
- const char *key,
- const char *value) {
+static void verify_table_size_change_match_elem_size(const char* key,
+ const char* value,
+ bool use_true_binary) {
grpc_slice_buffer output;
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
+ grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, use_true_binary);
size_t initial_table_size = g_compressor.table_size;
- grpc_linked_mdelem *e = gpr_malloc(sizeof(*e));
+ grpc_linked_mdelem* e =
+ static_cast<grpc_linked_mdelem*>(gpr_malloc(sizeof(*e)));
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
e[0].md = elem;
- e[0].prev = NULL;
- e[0].next = NULL;
+ e[0].prev = nullptr;
+ e[0].next = nullptr;
b.list.head = &e[0];
b.list.tail = &e[0];
b.list.count = 1;
@@ -209,35 +223,47 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
- grpc_encode_header_options hopt = {.stream_id = 0xdeadbeef,
- .is_eof = false,
- .use_true_binary_metadata = false,
- .max_frame_size = 16384,
- .stats = &stats};
- grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt,
- &output);
- grpc_slice_buffer_destroy_internal(exec_ctx, &output);
- grpc_metadata_batch_destroy(exec_ctx, &b);
+ grpc_encode_header_options hopt = {
+ 0xdeadbeef, /* stream_id */
+ false, /* is_eof */
+ use_true_binary, /* use_true_binary_metadata */
+ 16384, /* max_frame_size */
+ &stats /* stats */};
+ grpc_chttp2_encode_header(&g_compressor, nullptr, 0, &b, &hopt, &output);
+ grpc_slice_buffer_destroy_internal(&output);
+ grpc_metadata_batch_destroy(&b);
GPR_ASSERT(g_compressor.table_size == elem_size + initial_table_size);
gpr_free(e);
}
-static void test_encode_header_size(grpc_exec_ctx *exec_ctx) {
- verify_table_size_change_match_elem_size(exec_ctx, "hello", "world");
- verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world");
+static void test_encode_header_size() {
+ verify_table_size_change_match_elem_size("hello", "world", false);
+ verify_table_size_change_match_elem_size("hello-bin", "world", false);
+ verify_table_size_change_match_elem_size("true-binary-bin",
+ "I_am_true_binary_value", true);
+}
+
+static void test_interned_key_indexed() {
+ int i;
+ verify_params params = {false, false, true};
+ verify(params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2, "a", "b",
+ "a", "c");
+ for (i = 0; i < 10; i++) {
+ verify(params, "000008 0104 deadbeef 0f2f 0162 0f2f 0163", 2, "a", "b", "a",
+ "c");
+ }
}
-static void run_test(void (*test)(grpc_exec_ctx *exec_ctx), const char *name) {
+static void run_test(void (*test)(), const char* name) {
gpr_log(GPR_INFO, "RUN TEST: %s", name);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_chttp2_hpack_compressor_init(&g_compressor);
- test(&exec_ctx);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &g_compressor);
- grpc_exec_ctx_finish(&exec_ctx);
+ test();
+ grpc_chttp2_hpack_compressor_destroy(&g_compressor);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
size_t i;
grpc_test_only_set_slice_hash_seed(0);
grpc_test_init(argc, argv);
@@ -245,6 +271,7 @@ int main(int argc, char **argv) {
TEST(test_basic_headers);
TEST(test_decode_table_overflow);
TEST(test_encode_header_size);
+ TEST(test_interned_key_indexed);
grpc_shutdown();
for (i = 0; i < num_to_delete; i++) {
gpr_free(to_delete[i]);
diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
index 03834084cb..9a195daee0 100644
--- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.c
+++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
@@ -29,23 +29,22 @@
bool squelch = true;
bool leak_check = true;
-static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
-}
-static void dont_log(gpr_log_func_args *args) {}
+static void onhdr(void* ud, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); }
+static void dont_log(gpr_log_func_args* args) {}
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_test_only_set_slice_hash_seed(0);
if (squelch) gpr_set_log_function(dont_log);
grpc_init();
grpc_chttp2_hpack_parser parser;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- parser.on_header = onhdr;
- GRPC_ERROR_UNREF(grpc_chttp2_hpack_parser_parse(
- &exec_ctx, &parser, grpc_slice_from_static_buffer(data, size)));
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_exec_ctx_finish(&exec_ctx);
+ {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_chttp2_hpack_parser_init(&parser);
+ parser.on_header = onhdr;
+ GRPC_ERROR_UNREF(grpc_chttp2_hpack_parser_parse(
+ &parser, grpc_slice_from_static_buffer(data, size)));
+ grpc_chttp2_hpack_parser_destroy(&parser);
+ }
grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.cc
index 0946c05261..9d3456a873 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.cc
@@ -28,25 +28,27 @@
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
-typedef struct { va_list args; } test_checker;
+typedef struct {
+ va_list args;
+} test_checker;
-static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) {
+static void onhdr(void* ud, grpc_mdelem md) {
const char *ekey, *evalue;
- test_checker *chk = ud;
- ekey = va_arg(chk->args, char *);
+ test_checker* chk = static_cast<test_checker*>(ud);
+ ekey = va_arg(chk->args, char*);
GPR_ASSERT(ekey);
- evalue = va_arg(chk->args, char *);
+ evalue = va_arg(chk->args, char*);
GPR_ASSERT(evalue);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0);
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
-static void test_vector(grpc_chttp2_hpack_parser *parser,
- grpc_slice_split_mode mode, const char *hexstring,
+static void test_vector(grpc_chttp2_hpack_parser* parser,
+ grpc_slice_split_mode mode, const char* hexstring,
... /* char *key, char *value */) {
grpc_slice input = parse_hexstring(hexstring);
- grpc_slice *slices;
+ grpc_slice* slices;
size_t nslices;
size_t i;
test_checker chk;
@@ -60,10 +62,9 @@ static void test_vector(grpc_chttp2_hpack_parser *parser,
grpc_slice_unref(input);
for (i = 0; i < nslices; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_chttp2_hpack_parser_parse(&exec_ctx, parser, slices[i]) ==
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(grpc_chttp2_hpack_parser_parse(parser, slices[i]) ==
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
}
for (i = 0; i < nslices; i++) {
@@ -71,16 +72,16 @@ static void test_vector(grpc_chttp2_hpack_parser *parser,
}
gpr_free(slices);
- GPR_ASSERT(NULL == va_arg(chk.args, char *));
+ GPR_ASSERT(nullptr == va_arg(chk.args, char*));
va_end(chk.args);
}
static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser parser;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.2.1 */
test_vector(&parser, mode,
"400a 6375 7374 6f6d 2d6b 6579 0d63 7573"
@@ -96,9 +97,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
"password", "secret", NULL);
/* D.2.4 */
test_vector(&parser, mode, "82", ":method", "GET", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.3.1 */
test_vector(&parser, mode,
"8286 8441 0f77 7777 2e65 7861 6d70 6c65"
@@ -116,9 +117,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.4.1 */
test_vector(&parser, mode,
"8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4"
@@ -136,11 +137,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.5.1 */
test_vector(&parser, mode,
"4803 3330 3258 0770 7269 7661 7465 611d"
@@ -170,11 +171,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.6.1 */
test_vector(&parser, mode,
"4882 6402 5885 aec3 771a 4b61 96d0 7abe"
@@ -201,12 +202,10 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hpack_parser_destroy(&parser);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_vectors(GRPC_SLICE_SPLIT_MERGE_ALL);
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.cc
index 430ece33c7..e316cf63a0 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.cc
@@ -26,28 +26,28 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_slice mdstr,
- const char *str) {
+static void assert_str(const grpc_chttp2_hptbl* tbl, grpc_slice mdstr,
+ const char* str) {
GPR_ASSERT(grpc_slice_str_cmp(mdstr, str) == 0);
}
-static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx,
- const char *key, const char *value) {
+static void assert_index(const grpc_chttp2_hptbl* tbl, uint32_t idx,
+ const char* key, const char* value) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(tbl, idx);
assert_str(tbl, GRPC_MDKEY(md), key);
assert_str(tbl, GRPC_MDVALUE(md), value);
}
static void test_static_lookup(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_chttp2_hptbl tbl;
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ grpc_chttp2_hptbl_init(&tbl);
LOG_TEST("test_static_lookup");
assert_index(&tbl, 1, ":authority", "");
@@ -112,30 +112,28 @@ static void test_static_lookup(void) {
assert_index(&tbl, 60, "via", "");
assert_index(&tbl, 61, "www-authenticate", "");
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
static void test_many_additions(void) {
grpc_chttp2_hptbl tbl;
int i;
- char *key;
- char *value;
+ char* key;
+ char* value;
LOG_TEST("test_many_additions");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_chttp2_hptbl_init(&tbl);
for (i = 0; i < 100000; i++) {
grpc_mdelem elem;
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_copied_string(key),
+ grpc_slice_from_copied_string(value));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -148,25 +146,23 @@ static void test_many_additions(void) {
}
}
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
-static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl,
- const char *key,
- const char *value) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl* tbl,
+ const char* key,
+ const char* value) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
return r;
}
static void test_find(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_chttp2_hptbl tbl;
uint32_t i;
char buffer[32];
@@ -175,21 +171,19 @@ static void test_find(void) {
LOG_TEST("test_find");
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("xyz"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("123"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
- elem = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("x"),
+ grpc_chttp2_hptbl_init(&tbl);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("xyz"));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("123"));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("x"),
grpc_slice_from_static_string("1"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -238,11 +232,10 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
int64_ttoa(i, buffer);
- elem = grpc_mdelem_from_slices(&exec_ctx,
- grpc_slice_from_static_string("test"),
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("test"),
grpc_slice_from_copied_string(buffer));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
}
r = find_simple(&tbl, "abc", "123");
@@ -270,11 +263,10 @@ static void test_find(void) {
GPR_ASSERT(r.index != 0);
GPR_ASSERT(r.has_value == 0);
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_static_lookup();
diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc
new file mode 100644
index 0000000000..d7d6ee7508
--- /dev/null
+++ b/test/core/transport/chttp2/settings_timeout_test.cc
@@ -0,0 +1,254 @@
+/*
+ *
+ * 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 <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include <functional>
+#include <memory>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/iomgr/pollset.h"
+#include "src/core/lib/iomgr/pollset_set.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/tcp_client.h"
+#include "src/core/lib/slice/slice_internal.h"
+
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace test {
+namespace {
+
+// A gRPC server, running in its own thread.
+class ServerThread {
+ public:
+ explicit ServerThread(const char* address) : address_(address) {}
+
+ void Start() {
+ // Start server with 1-second handshake timeout.
+ grpc_arg arg;
+ arg.type = GRPC_ARG_INTEGER;
+ arg.key = const_cast<char*>(GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS);
+ arg.value.integer = 1000;
+ grpc_channel_args args = {1, &arg};
+ server_ = grpc_server_create(&args, nullptr);
+ ASSERT_TRUE(grpc_server_add_insecure_http2_port(server_, address_));
+ cq_ = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server_, cq_, nullptr);
+ grpc_server_start(server_);
+ thread_.reset(new std::thread(std::bind(&ServerThread::Serve, this)));
+ }
+
+ void Shutdown() {
+ grpc_completion_queue* shutdown_cq =
+ grpc_completion_queue_create_for_pluck(nullptr);
+ grpc_server_shutdown_and_notify(server_, shutdown_cq, nullptr);
+ GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, nullptr,
+ grpc_timeout_seconds_to_deadline(1),
+ nullptr)
+ .type == GRPC_OP_COMPLETE);
+ grpc_completion_queue_destroy(shutdown_cq);
+ grpc_server_destroy(server_);
+ grpc_completion_queue_destroy(cq_);
+ thread_->join();
+ }
+
+ private:
+ void Serve() {
+ // The completion queue should not return anything other than shutdown.
+ grpc_event ev = grpc_completion_queue_next(
+ cq_, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
+ ASSERT_EQ(GRPC_QUEUE_SHUTDOWN, ev.type);
+ }
+
+ const char* address_; // Do not own.
+ grpc_server* server_ = nullptr;
+ grpc_completion_queue* cq_ = nullptr;
+ std::unique_ptr<std::thread> thread_;
+};
+
+// A TCP client that connects to the server, reads data until the server
+// closes, and then terminates.
+class Client {
+ public:
+ explicit Client(const char* server_address)
+ : server_address_(server_address) {}
+
+ void Connect() {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_resolved_addresses* server_addresses = nullptr;
+ grpc_error* error =
+ grpc_blocking_resolve_address(server_address_, "80", &server_addresses);
+ ASSERT_EQ(GRPC_ERROR_NONE, error) << grpc_error_string(error);
+ ASSERT_GE(server_addresses->naddrs, 1UL);
+ pollset_ = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset_init(pollset_, &mu_);
+ grpc_pollset_set* pollset_set = grpc_pollset_set_create();
+ grpc_pollset_set_add_pollset(pollset_set, pollset_);
+ EventState state;
+ grpc_tcp_client_connect(state.closure(), &endpoint_, pollset_set,
+ nullptr /* channel_args */, server_addresses->addrs,
+ 1000);
+ ASSERT_TRUE(PollUntilDone(
+ &state,
+ grpc_timespec_to_millis_round_up(gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ ASSERT_EQ(GRPC_ERROR_NONE, state.error());
+ grpc_pollset_set_destroy(pollset_set);
+ grpc_endpoint_add_to_pollset(endpoint_, pollset_);
+ grpc_resolved_addresses_destroy(server_addresses);
+ }
+
+ // Reads until an error is returned.
+ // Returns true if an error was encountered before the deadline.
+ bool ReadUntilError() {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_slice_buffer read_buffer;
+ grpc_slice_buffer_init(&read_buffer);
+ bool retval = true;
+ // Use a deadline of 3 seconds, which is a lot more than we should
+ // need for a 1-second timeout, but this helps avoid flakes.
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 3000;
+ while (true) {
+ EventState state;
+ grpc_endpoint_read(endpoint_, &read_buffer, state.closure());
+ if (!PollUntilDone(&state, deadline)) {
+ retval = false;
+ break;
+ }
+ if (state.error() != GRPC_ERROR_NONE) break;
+ gpr_log(GPR_INFO, "client read %" PRIuPTR " bytes", read_buffer.length);
+ grpc_slice_buffer_reset_and_unref_internal(&read_buffer);
+ }
+ grpc_endpoint_shutdown(endpoint_,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown"));
+ grpc_slice_buffer_destroy_internal(&read_buffer);
+ return retval;
+ }
+
+ void Shutdown() {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_endpoint_destroy(endpoint_);
+ grpc_pollset_shutdown(pollset_,
+ GRPC_CLOSURE_CREATE(&Client::PollsetDestroy, pollset_,
+ grpc_schedule_on_exec_ctx));
+ }
+
+ private:
+ // State used to wait for an I/O event.
+ class EventState {
+ public:
+ EventState() {
+ GRPC_CLOSURE_INIT(&closure_, &EventState::OnEventDone, this,
+ grpc_schedule_on_exec_ctx);
+ }
+
+ ~EventState() { GRPC_ERROR_UNREF(error_); }
+
+ grpc_closure* closure() { return &closure_; }
+
+ bool done() const { return done_; }
+
+ // Caller does NOT take ownership of the error.
+ grpc_error* error() const { return error_; }
+
+ private:
+ static void OnEventDone(void* arg, grpc_error* error) {
+ gpr_log(GPR_INFO, "OnEventDone(): %s", grpc_error_string(error));
+ EventState* state = (EventState*)arg;
+ state->error_ = GRPC_ERROR_REF(error);
+ state->done_ = true;
+ }
+
+ grpc_closure closure_;
+ bool done_ = false;
+ grpc_error* error_ = GRPC_ERROR_NONE;
+ };
+
+ // Returns true if done, or false if deadline exceeded.
+ bool PollUntilDone(EventState* state, grpc_millis deadline) {
+ while (true) {
+ grpc_pollset_worker* worker = nullptr;
+ gpr_mu_lock(mu_);
+ GRPC_LOG_IF_ERROR(
+ "grpc_pollset_work",
+ grpc_pollset_work(pollset_, &worker,
+ grpc_core::ExecCtx::Get()->Now() + 1000));
+ gpr_mu_unlock(mu_);
+ if (state != nullptr && state->done()) return true;
+ if (grpc_core::ExecCtx::Get()->Now() >= deadline) return false;
+ }
+ }
+
+ static void PollsetDestroy(void* arg, grpc_error* error) {
+ grpc_pollset* pollset = (grpc_pollset*)arg;
+ grpc_pollset_destroy(pollset);
+ gpr_free(pollset);
+ }
+
+ const char* server_address_; // Do not own.
+ grpc_endpoint* endpoint_;
+ gpr_mu* mu_;
+ grpc_pollset* pollset_;
+};
+
+TEST(SettingsTimeout, Basic) {
+ // Construct server address string.
+ const int server_port = grpc_pick_unused_port_or_die();
+ char* server_address_string;
+ gpr_asprintf(&server_address_string, "localhost:%d", server_port);
+ // Start server.
+ gpr_log(GPR_INFO, "starting server on %s", server_address_string);
+ ServerThread server_thread(server_address_string);
+ server_thread.Start();
+ // Create client and connect to server.
+ gpr_log(GPR_INFO, "starting client connect");
+ Client client(server_address_string);
+ client.Connect();
+ // Client read. Should fail due to server dropping connection.
+ gpr_log(GPR_INFO, "starting client read");
+ EXPECT_TRUE(client.ReadUntilError());
+ // Shut down client.
+ gpr_log(GPR_INFO, "shutting down client");
+ client.Shutdown();
+ // Shut down server.
+ gpr_log(GPR_INFO, "shutting down server");
+ server_thread.Shutdown();
+ // Clean up.
+ gpr_free(server_address_string);
+}
+
+} // namespace
+} // namespace test
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ grpc_test_init(argc, argv);
+ grpc_init();
+ int result = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return result;
+}
diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.cc
index ae2583ab84..9b21cb2364 100644
--- a/test/core/transport/chttp2/stream_map_test.c
+++ b/test/core/transport/chttp2/stream_map_test.cc
@@ -39,7 +39,7 @@ static void test_empty_find(void) {
LOG_TEST("test_empty_find");
grpc_chttp2_stream_map_init(&map, 8);
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 39128));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 39128));
grpc_chttp2_stream_map_destroy(&map);
}
@@ -51,18 +51,18 @@ static void test_double_deletion(void) {
grpc_chttp2_stream_map_init(&map, 8);
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
- grpc_chttp2_stream_map_add(&map, 1, (void *)1);
- GPR_ASSERT((void *)1 == grpc_chttp2_stream_map_find(&map, 1));
+ grpc_chttp2_stream_map_add(&map, 1, (void*)1);
+ GPR_ASSERT((void*)1 == grpc_chttp2_stream_map_find(&map, 1));
GPR_ASSERT(1 == grpc_chttp2_stream_map_size(&map));
- GPR_ASSERT((void *)1 == grpc_chttp2_stream_map_delete(&map, 1));
+ GPR_ASSERT((void*)1 == grpc_chttp2_stream_map_delete(&map, 1));
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 1));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_delete(&map, 1));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 1));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_delete(&map, 1));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 1));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_delete(&map, 1));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_delete(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_delete(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_delete(&map, 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1));
grpc_chttp2_stream_map_destroy(&map);
}
@@ -78,11 +78,11 @@ static void test_basic_add_find(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 8);
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
}
GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, n + 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 0));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, n + 1));
for (i = 1; i <= n; i++) {
got = (uintptr_t)grpc_chttp2_stream_map_find(&map, i);
GPR_ASSERT(i == got);
@@ -91,26 +91,26 @@ static void test_basic_add_find(uint32_t n) {
}
/* verify that for_each gets the right values during test_delete_evens_XXX */
-static void verify_for_each(void *user_data, uint32_t stream_id, void *ptr) {
- uint32_t *for_each_check = user_data;
+static void verify_for_each(void* user_data, uint32_t stream_id, void* ptr) {
+ uint32_t* for_each_check = static_cast<uint32_t*>(user_data);
GPR_ASSERT(ptr);
GPR_ASSERT(*for_each_check == stream_id);
*for_each_check += 2;
}
-static void check_delete_evens(grpc_chttp2_stream_map *map, uint32_t n) {
+static void check_delete_evens(grpc_chttp2_stream_map* map, uint32_t n) {
uint32_t for_each_check = 1;
uint32_t i;
size_t got;
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, 0));
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, n + 1));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(map, 0));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(map, n + 1));
for (i = 1; i <= n; i++) {
if (i & 1) {
got = (uintptr_t)grpc_chttp2_stream_map_find(map, i);
GPR_ASSERT(i == got);
} else {
- GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, i));
+ GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(map, i));
}
}
@@ -133,12 +133,11 @@ static void test_delete_evens_sweep(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
}
for (i = 1; i <= n; i++) {
if ((i & 1) == 0) {
- GPR_ASSERT((void *)(uintptr_t)i ==
- grpc_chttp2_stream_map_delete(&map, i));
+ GPR_ASSERT((void*)(uintptr_t)i == grpc_chttp2_stream_map_delete(&map, i));
}
}
check_delete_evens(&map, n);
@@ -156,7 +155,7 @@ static void test_delete_evens_incremental(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
if ((i & 1) == 0) {
grpc_chttp2_stream_map_delete(&map, i);
}
@@ -178,10 +177,10 @@ static void test_periodic_compaction(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 16);
GPR_ASSERT(map.capacity == 16);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
if (i > 8) {
del = i - 8;
- GPR_ASSERT((void *)(uintptr_t)del ==
+ GPR_ASSERT((void*)(uintptr_t)del ==
grpc_chttp2_stream_map_delete(&map, del));
}
}
@@ -189,7 +188,7 @@ static void test_periodic_compaction(uint32_t n) {
grpc_chttp2_stream_map_destroy(&map);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
uint32_t n = 1;
uint32_t prev = 1;
uint32_t tmp;
diff --git a/test/core/transport/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.cc
index 0986a2cde6..36760d0c72 100644
--- a/test/core/transport/chttp2/varint_test.c
+++ b/test/core/transport/chttp2/varint_test.cc
@@ -18,13 +18,14 @@
#include "src/core/ext/transport/chttp2/transport/varint.h"
+#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or,
- const char *expect_bytes, size_t expect_length) {
+ const char* expect_bytes, size_t expect_length) {
uint32_t nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits);
grpc_slice expect =
grpc_slice_from_copied_buffer(expect_bytes, expect_length);
@@ -42,13 +43,15 @@ static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or,
#define TEST_VARINT(value, prefix_bits, prefix_or, expect) \
test_varint(value, prefix_bits, prefix_or, expect, sizeof(expect) - 1)
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
TEST_VARINT(0, 1, 0, "\x00");
TEST_VARINT(128, 1, 0, "\x7f\x01");
TEST_VARINT(16384, 1, 0, "\x7f\x81\x7f");
TEST_VARINT(2097152, 1, 0, "\x7f\x81\xff\x7f");
TEST_VARINT(268435456, 1, 0, "\x7f\x81\xff\xff\x7f");
TEST_VARINT(0xffffffff, 1, 0, "\x7f\x80\xff\xff\xff\x0f");
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/connectivity_state_test.c b/test/core/transport/connectivity_state_test.cc
index 4ef8683107..f5894599e5 100644
--- a/test/core/transport/connectivity_state_test.c
+++ b/test/core/transport/connectivity_state_test.cc
@@ -23,19 +23,19 @@
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
+#include "test/core/util/tracer_util.h"
-#define THE_ARG ((void *)(size_t)0xcafebabe)
+#define THE_ARG ((void*)(size_t)0xcafebabe)
int g_counter;
-static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(arg == THE_ARG);
g_counter++;
}
-static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(error != GRPC_ERROR_NONE);
GPR_ASSERT(arg == THE_ARG);
g_counter++;
@@ -58,89 +58,89 @@ static void test_connectivity_state_name(void) {
static void test_check(void) {
grpc_connectivity_state_tracker tracker;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_error *error;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_error* error;
gpr_log(GPR_DEBUG, "test_check");
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
GPR_ASSERT(grpc_connectivity_state_get(&tracker, &error) ==
GRPC_CHANNEL_IDLE);
GPR_ASSERT(grpc_connectivity_state_check(&tracker) == GRPC_CHANNEL_IDLE);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
}
static void test_subscribe_then_unsubscribe(void) {
grpc_connectivity_state_tracker tracker;
- grpc_closure *closure =
+ grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_then_unsubscribe");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
- GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker,
- &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
+ closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, NULL,
- closure);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_connectivity_state_notify_on_state_change(&tracker, nullptr, closure);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 1);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
}
static void test_subscribe_then_destroy(void) {
grpc_connectivity_state_tracker tracker;
- grpc_closure *closure =
+ grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_succeed, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
- GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker,
- &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
+ closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
+
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
static void test_subscribe_with_failure_then_destroy(void) {
grpc_connectivity_state_tracker tracker;
- grpc_closure *closure =
+ grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_SHUTDOWN;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_SHUTDOWN, "xxx");
GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change(
- &exec_ctx, &tracker, &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ &tracker, &state, closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_connectivity_state_trace.value = 1;
+ grpc_init();
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_connectivity_state_trace);
test_connectivity_state_name();
test_check();
test_subscribe_then_unsubscribe();
test_subscribe_then_destroy();
test_subscribe_with_failure_then_destroy();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.cc
index cb06fce30b..7d943fd5c7 100644
--- a/test/core/transport/metadata_test.c
+++ b/test/core/transport/metadata_test.cc
@@ -27,8 +27,8 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/util/test_config.h"
@@ -60,15 +60,15 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
m1 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
m2 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
m3 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("c"), intern_values));
GPR_ASSERT(grpc_mdelem_eq(m1, m2));
GPR_ASSERT(!grpc_mdelem_eq(m3, m1));
@@ -77,10 +77,10 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(m1), "a") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m1), "b") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m3), "c") == 0);
- GRPC_MDELEM_UNREF(&exec_ctx, m1);
- GRPC_MDELEM_UNREF(&exec_ctx, m2);
- GRPC_MDELEM_UNREF(&exec_ctx, m3);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(m1);
+ GRPC_MDELEM_UNREF(m2);
+ GRPC_MDELEM_UNREF(m3);
+
grpc_shutdown();
}
@@ -95,53 +95,50 @@ static void test_create_many_ephemeral_metadata(bool intern_keys,
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
/* add, and immediately delete a bunch of different elements */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_from_slices(
- &exec_ctx,
- maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
- maybe_intern(grpc_slice_from_copied_string(buffer),
- intern_values)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_from_slices(
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_copied_string(buffer), intern_values)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
}
static void test_create_many_persistant_metadata(void) {
char buffer[GPR_LTOA_MIN_BUFSIZE];
long i;
- grpc_mdelem *created = gpr_malloc(sizeof(grpc_mdelem) * MANY);
+ grpc_mdelem* created =
+ static_cast<grpc_mdelem*>(gpr_malloc(sizeof(grpc_mdelem) * MANY));
grpc_mdelem md;
gpr_log(GPR_INFO, "test_create_many_persistant_metadata");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
/* add phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
created[i] = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")),
+ grpc_slice_intern(grpc_slice_from_static_string("a")),
grpc_slice_intern(grpc_slice_from_static_string(buffer)));
}
/* verify phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")),
+ grpc_slice_intern(grpc_slice_from_static_string("a")),
grpc_slice_intern(grpc_slice_from_static_string(buffer)));
GPR_ASSERT(grpc_mdelem_eq(md, created[i]));
- GRPC_MDELEM_UNREF(&exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
/* cleanup phase */
for (i = 0; i < MANY; i++) {
- GRPC_MDELEM_UNREF(&exec_ctx, created[i]);
+ GRPC_MDELEM_UNREF(created[i]);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
gpr_free(created);
@@ -154,31 +151,25 @@ static void test_spin_creating_the_same_thing(bool intern_keys,
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem a, b, c;
GRPC_MDELEM_UNREF(
- &exec_ctx,
a = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
GRPC_MDELEM_UNREF(
- &exec_ctx,
b = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
GRPC_MDELEM_UNREF(
- &exec_ctx,
c = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
if (intern_keys && intern_values) {
GPR_ASSERT(a.payload == b.payload);
GPR_ASSERT(a.payload == c.payload);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
}
@@ -187,16 +178,16 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem a, b, c;
a = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
b = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
c = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
GPR_ASSERT(grpc_mdelem_eq(a, a));
GPR_ASSERT(grpc_mdelem_eq(b, b));
@@ -215,25 +206,26 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
GPR_ASSERT(a.payload != c.payload);
GPR_ASSERT(b.payload != c.payload);
}
- GRPC_MDELEM_UNREF(&exec_ctx, a);
- GRPC_MDELEM_UNREF(&exec_ctx, b);
- GRPC_MDELEM_UNREF(&exec_ctx, c);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(a);
+ GRPC_MDELEM_UNREF(b);
+ GRPC_MDELEM_UNREF(c);
+
grpc_shutdown();
}
static void test_things_stick_around(void) {
size_t i, j;
- char *buffer;
+ char* buffer;
size_t nstrs = 1000;
- grpc_slice *strs = gpr_malloc(sizeof(grpc_slice) * nstrs);
- size_t *shuf = gpr_malloc(sizeof(size_t) * nstrs);
+ grpc_slice* strs =
+ static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * nstrs));
+ size_t* shuf = static_cast<size_t*>(gpr_malloc(sizeof(size_t) * nstrs));
grpc_slice test;
gpr_log(GPR_INFO, "test_things_stick_around");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
for (i = 0; i < nstrs; i++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x", i);
@@ -244,7 +236,7 @@ static void test_things_stick_around(void) {
for (i = 0; i < nstrs; i++) {
grpc_slice_ref_internal(strs[i]);
- grpc_slice_unref_internal(&exec_ctx, strs[i]);
+ grpc_slice_unref_internal(strs[i]);
}
for (i = 0; i < nstrs; i++) {
@@ -256,75 +248,73 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- grpc_slice_unref_internal(&exec_ctx, strs[shuf[i]]);
+ grpc_slice_unref_internal(strs[shuf[i]]);
for (j = i + 1; j < nstrs; j++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x",
shuf[j]);
test = grpc_slice_intern(grpc_slice_from_static_string(buffer));
GPR_ASSERT(grpc_slice_is_equivalent(test, strs[shuf[j]]));
- grpc_slice_unref_internal(&exec_ctx, test);
+ grpc_slice_unref_internal(test);
gpr_free(buffer);
}
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(strs);
gpr_free(shuf);
}
static void test_user_data_works(void) {
- int *ud1;
- int *ud2;
+ int* ud1;
+ int* ud2;
grpc_mdelem md;
gpr_log(GPR_INFO, "test_user_data_works");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- ud1 = gpr_malloc(sizeof(int));
+ grpc_core::ExecCtx exec_ctx;
+ ud1 = static_cast<int*>(gpr_malloc(sizeof(int)));
*ud1 = 1;
- ud2 = gpr_malloc(sizeof(int));
+ ud2 = static_cast<int*>(gpr_malloc(sizeof(int)));
*ud2 = 2;
md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("123")));
grpc_mdelem_set_user_data(md, gpr_free, ud1);
grpc_mdelem_set_user_data(md, gpr_free, ud2);
GPR_ASSERT(grpc_mdelem_get_user_data(md, gpr_free) == ud1);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
grpc_shutdown();
}
-static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key,
- const char *value, bool intern_key,
- bool intern_value) {
+static void verify_ascii_header_size(const char* key, const char* value,
+ bool intern_key, bool intern_value) {
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
+ maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_string(value), intern_value));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
size_t expected_size = 32 + strlen(key) + strlen(value);
GPR_ASSERT(expected_size == elem_size);
- GRPC_MDELEM_UNREF(exec_ctx, elem);
+ GRPC_MDELEM_UNREF(elem);
}
-static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key,
- const uint8_t *value, size_t value_len,
- bool intern_key, bool intern_value) {
+static void verify_binary_header_size(const char* key, const uint8_t* value,
+ size_t value_len, bool intern_key,
+ bool intern_value) {
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
+ maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_buffer(value, value_len),
intern_value));
GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem)));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
grpc_slice value_slice =
- grpc_slice_from_copied_buffer((const char *)value, value_len);
+ grpc_slice_from_copied_buffer((const char*)value, value_len);
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded);
GPR_ASSERT(expected_size == elem_size);
- grpc_slice_unref_internal(exec_ctx, value_slice);
- grpc_slice_unref_internal(exec_ctx, base64_encoded);
- GRPC_MDELEM_UNREF(exec_ctx, elem);
+ grpc_slice_unref_internal(value_slice);
+ grpc_slice_unref_internal(base64_encoded);
+ GRPC_MDELEM_UNREF(elem);
}
#define BUFFER_SIZE 64
@@ -332,27 +322,23 @@ static void test_mdelem_sizes_in_hpack(bool intern_key, bool intern_value) {
gpr_log(GPR_INFO, "test_mdelem_size: intern_key=%d intern_value=%d",
intern_key, intern_value);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
uint8_t binary_value[BUFFER_SIZE] = {0};
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
binary_value[i] = i;
}
- verify_ascii_header_size(&exec_ctx, "hello", "world", intern_key,
- intern_value);
- verify_ascii_header_size(&exec_ctx, "hello",
- "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", intern_key,
- intern_value);
- verify_ascii_header_size(&exec_ctx, ":scheme", "http", intern_key,
- intern_value);
+ verify_ascii_header_size("hello", "world", intern_key, intern_value);
+ verify_ascii_header_size("hello", "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ intern_key, intern_value);
+ verify_ascii_header_size(":scheme", "http", intern_key, intern_value);
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
- verify_binary_header_size(&exec_ctx, "hello-bin", binary_value, i,
- intern_key, intern_value);
+ verify_binary_header_size("hello-bin", binary_value, i, intern_key,
+ intern_value);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -360,13 +346,13 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
gpr_log(GPR_INFO, "test_static_metadata: dup_key=%d dup_value=%d", dup_key,
dup_value);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) {
grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[i],
GRPC_MDELEM_STORAGE_STATIC);
grpc_mdelem q =
- grpc_mdelem_from_slices(&exec_ctx, maybe_dup(GRPC_MDKEY(p), dup_key),
+ grpc_mdelem_from_slices(maybe_dup(GRPC_MDKEY(p), dup_key),
maybe_dup(GRPC_MDVALUE(p), dup_value));
GPR_ASSERT(grpc_mdelem_eq(p, q));
if (dup_key || dup_value) {
@@ -374,16 +360,16 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
} else {
GPR_ASSERT(p.payload == q.payload);
}
- GRPC_MDELEM_UNREF(&exec_ctx, p);
- GRPC_MDELEM_UNREF(&exec_ctx, q);
+ GRPC_MDELEM_UNREF(p);
+ GRPC_MDELEM_UNREF(q);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_no_op();
for (int k = 0; k <= 1; k++) {
for (int v = 0; v <= 1; v++) {
@@ -398,5 +384,6 @@ int main(int argc, char **argv) {
test_create_many_persistant_metadata();
test_things_stick_around();
test_user_data_works();
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/pid_controller_test.c b/test/core/transport/pid_controller_test.c
deleted file mode 100644
index 831c4b41ce..0000000000
--- a/test/core/transport/pid_controller_test.c
+++ /dev/null
@@ -1,78 +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 "src/core/lib/transport/pid_controller.h"
-
-#include <float.h>
-#include <math.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
-#include "test/core/util/test_config.h"
-
-static void test_noop(void) {
- gpr_log(GPR_INFO, "test_noop");
- grpc_pid_controller pid;
- grpc_pid_controller_init(
- &pid, (grpc_pid_controller_args){.gain_p = 1,
- .gain_i = 1,
- .gain_d = 1,
- .initial_control_value = 1,
- .min_control_value = DBL_MIN,
- .max_control_value = DBL_MAX,
- .integral_range = DBL_MAX});
-}
-
-static void test_simple_convergence(double gain_p, double gain_i, double gain_d,
- double dt, double set_point, double start) {
- gpr_log(GPR_INFO,
- "test_simple_convergence(p=%lf, i=%lf, d=%lf); dt=%lf set_point=%lf "
- "start=%lf",
- gain_p, gain_i, gain_d, dt, set_point, start);
- grpc_pid_controller pid;
- grpc_pid_controller_init(
- &pid, (grpc_pid_controller_args){.gain_p = gain_p,
- .gain_i = gain_i,
- .gain_d = gain_d,
- .initial_control_value = start,
- .min_control_value = DBL_MIN,
- .max_control_value = DBL_MAX,
- .integral_range = DBL_MAX});
-
- for (int i = 0; i < 100000; i++) {
- grpc_pid_controller_update(&pid, set_point - grpc_pid_controller_last(&pid),
- 1);
- }
-
- GPR_ASSERT(fabs(set_point - grpc_pid_controller_last(&pid)) < 0.1);
- if (gain_i > 0) {
- GPR_ASSERT(fabs(pid.error_integral) < 0.1);
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- test_noop();
- test_simple_convergence(0.2, 0, 0, 1, 100, 0);
- test_simple_convergence(0.2, 0.1, 0, 1, 100, 0);
- test_simple_convergence(0.2, 0.1, 0.1, 1, 100, 0);
- return 0;
-}
diff --git a/test/core/transport/pid_controller_test.cc b/test/core/transport/pid_controller_test.cc
new file mode 100644
index 0000000000..1a499c2fb7
--- /dev/null
+++ b/test/core/transport/pid_controller_test.cc
@@ -0,0 +1,91 @@
+/*
+ *
+ * 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 "src/core/lib/transport/pid_controller.h"
+
+#include <float.h>
+#include <math.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+#include <gtest/gtest.h>
+#include "src/core/lib/gpr/string.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+
+TEST(PidController, NoOp) {
+ PidController pid(PidController::Args()
+ .set_gain_p(1)
+ .set_gain_i(1)
+ .set_gain_d(1)
+ .set_initial_control_value(1));
+}
+
+struct SimpleConvergenceTestArgs {
+ double gain_p;
+ double gain_i;
+ double gain_d;
+ double dt;
+ double set_point;
+ double start;
+};
+
+std::ostream& operator<<(std::ostream& out, SimpleConvergenceTestArgs args) {
+ return out << "gain_p:" << args.gain_p << " gain_i:" << args.gain_i
+ << " gain_d:" << args.gain_d << " dt:" << args.dt
+ << " set_point:" << args.set_point << " start:" << args.start;
+}
+
+class SimpleConvergenceTest
+ : public ::testing::TestWithParam<SimpleConvergenceTestArgs> {};
+
+TEST_P(SimpleConvergenceTest, Converges) {
+ PidController pid(PidController::Args()
+ .set_gain_p(GetParam().gain_p)
+ .set_gain_i(GetParam().gain_i)
+ .set_gain_d(GetParam().gain_d)
+ .set_initial_control_value(GetParam().start));
+
+ for (int i = 0; i < 100000; i++) {
+ pid.Update(GetParam().set_point - pid.last_control_value(), GetParam().dt);
+ }
+
+ EXPECT_LT(fabs(GetParam().set_point - pid.last_control_value()), 0.1);
+ if (GetParam().gain_i > 0) {
+ EXPECT_LT(fabs(pid.error_integral()), 0.1);
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(
+ X, SimpleConvergenceTest,
+ ::testing::Values(SimpleConvergenceTestArgs{0.2, 0, 0, 1, 100, 0},
+ SimpleConvergenceTestArgs{0.2, 0.1, 0, 1, 100, 0},
+ SimpleConvergenceTestArgs{0.2, 0.1, 0.1, 1, 100, 0}));
+
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/transport/status_conversion_test.c b/test/core/transport/status_conversion_test.cc
index 89558964c1..1ed6ccfba6 100644
--- a/test/core/transport/status_conversion_test.c
+++ b/test/core/transport/status_conversion_test.cc
@@ -22,17 +22,22 @@
#define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \
GPR_ASSERT(grpc_status_to_http2_error(a) == (b))
-#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \
- GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b))
+#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \
+ do { \
+ grpc_core::ExecCtx exec_ctx; \
+ GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)); \
+ \
+ } while (0)
#define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \
GPR_ASSERT(grpc_status_to_http2_status(a) == (b))
#define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \
GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b))
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int i;
grpc_test_init(argc, argv);
+ grpc_init();
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL);
@@ -79,7 +84,7 @@ int main(int argc, char **argv) {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200);
- const gpr_timespec before_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE;
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline,
GRPC_STATUS_INTERNAL);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, before_deadline,
@@ -107,7 +112,7 @@ int main(int argc, char **argv) {
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, before_deadline,
GRPC_STATUS_PERMISSION_DENIED);
- const gpr_timespec after_deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ const grpc_millis after_deadline = 0;
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, after_deadline,
GRPC_STATUS_INTERNAL);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, after_deadline,
@@ -124,6 +129,11 @@ int main(int argc, char **argv) {
GRPC_STATUS_INTERNAL);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_REFUSED_STREAM, after_deadline,
GRPC_STATUS_UNAVAILABLE);
+ // We only have millisecond granularity in our timing code. This sleeps for 5
+ // millis to ensure that the status conversion code will pick up the fact
+ // that the deadline has expired.
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(5, GPR_TIMESPAN)));
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CANCEL, after_deadline,
GRPC_STATUS_DEADLINE_EXCEEDED);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_COMPRESSION_ERROR, after_deadline,
@@ -153,5 +163,7 @@ int main(int argc, char **argv) {
grpc_http2_status_to_grpc_status(i);
}
+ grpc_shutdown();
+
return 0;
}
diff --git a/test/core/transport/stream_owned_slice_test.c b/test/core/transport/stream_owned_slice_test.cc
index 774ad4e72e..7831f67a04 100644
--- a/test/core/transport/stream_owned_slice_test.c
+++ b/test/core/transport/stream_owned_slice_test.cc
@@ -20,16 +20,18 @@
#include "test/core/util/test_config.h"
+#include <grpc/grpc.h>
#include <grpc/support/log.h>
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
uint8_t buffer[] = "abc123";
grpc_stream_refcount r;
- GRPC_STREAM_REF_INIT(&r, 1, do_nothing, NULL, "test");
+ GRPC_STREAM_REF_INIT(&r, 1, do_nothing, nullptr, "test");
GPR_ASSERT(r.refs.count == 1);
grpc_slice slice =
grpc_slice_from_stream_owned_buffer(&r, buffer, sizeof(buffer));
@@ -39,5 +41,6 @@ int main(int argc, char **argv) {
grpc_slice_unref(slice);
GPR_ASSERT(r.refs.count == 1);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c
deleted file mode 100644
index 6388ffbcec..0000000000
--- a/test/core/transport/timeout_encoding_test.c
+++ /dev/null
@@ -1,148 +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/transport/timeout_encoding.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
-#include "test/core/util/test_config.h"
-
-#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-
-static void assert_encodes_as(gpr_timespec ts, const char *s) {
- char buffer[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
- grpc_http2_encode_timeout(ts, buffer);
- gpr_log(GPR_INFO, "check '%s' == '%s'", buffer, s);
- GPR_ASSERT(0 == strcmp(buffer, s));
-}
-
-void test_encoding(void) {
- LOG_TEST("test_encoding");
- assert_encodes_as(gpr_time_from_micros(-1, GPR_TIMESPAN), "1n");
- assert_encodes_as(gpr_time_from_seconds(-10, GPR_TIMESPAN), "1n");
- assert_encodes_as(gpr_time_from_nanos(10, GPR_TIMESPAN), "10n");
- assert_encodes_as(gpr_time_from_nanos(999999999, GPR_TIMESPAN), "1S");
- assert_encodes_as(gpr_time_from_micros(1, GPR_TIMESPAN), "1u");
- assert_encodes_as(gpr_time_from_micros(10, GPR_TIMESPAN), "10u");
- assert_encodes_as(gpr_time_from_micros(100, GPR_TIMESPAN), "100u");
- assert_encodes_as(gpr_time_from_micros(890, GPR_TIMESPAN), "890u");
- assert_encodes_as(gpr_time_from_micros(900, GPR_TIMESPAN), "900u");
- assert_encodes_as(gpr_time_from_micros(901, GPR_TIMESPAN), "901u");
- assert_encodes_as(gpr_time_from_millis(1, GPR_TIMESPAN), "1m");
- assert_encodes_as(gpr_time_from_millis(2, GPR_TIMESPAN), "2m");
- assert_encodes_as(gpr_time_from_micros(10001, GPR_TIMESPAN), "10100u");
- assert_encodes_as(gpr_time_from_micros(999999, GPR_TIMESPAN), "1S");
- assert_encodes_as(gpr_time_from_millis(1000, GPR_TIMESPAN), "1S");
- assert_encodes_as(gpr_time_from_millis(2000, GPR_TIMESPAN), "2S");
- assert_encodes_as(gpr_time_from_millis(2500, GPR_TIMESPAN), "2500m");
- assert_encodes_as(gpr_time_from_millis(59900, GPR_TIMESPAN), "59900m");
- assert_encodes_as(gpr_time_from_seconds(50, GPR_TIMESPAN), "50S");
- assert_encodes_as(gpr_time_from_seconds(59, GPR_TIMESPAN), "59S");
- assert_encodes_as(gpr_time_from_seconds(60, GPR_TIMESPAN), "1M");
- assert_encodes_as(gpr_time_from_seconds(80, GPR_TIMESPAN), "80S");
- assert_encodes_as(gpr_time_from_seconds(90, GPR_TIMESPAN), "90S");
- assert_encodes_as(gpr_time_from_minutes(2, GPR_TIMESPAN), "2M");
- assert_encodes_as(gpr_time_from_minutes(20, GPR_TIMESPAN), "20M");
- assert_encodes_as(gpr_time_from_hours(1, GPR_TIMESPAN), "1H");
- assert_encodes_as(gpr_time_from_hours(10, GPR_TIMESPAN), "10H");
- assert_encodes_as(gpr_time_from_seconds(1000000000, GPR_TIMESPAN),
- "1000000000S");
-}
-
-static void assert_decodes_as(const char *buffer, gpr_timespec expected) {
- gpr_timespec got;
- gpr_log(GPR_INFO, "check decoding '%s'", buffer);
- GPR_ASSERT(1 == grpc_http2_decode_timeout(
- grpc_slice_from_static_string(buffer), &got));
- GPR_ASSERT(0 == gpr_time_cmp(got, expected));
-}
-
-void decode_suite(char ext,
- gpr_timespec (*answer)(int64_t x, gpr_clock_type clock)) {
- long test_vals[] = {1, 12, 123, 1234, 12345, 123456,
- 1234567, 12345678, 123456789, 98765432, 9876543, 987654,
- 98765, 9876, 987, 98, 9};
- unsigned i;
- char *input;
- for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) {
- gpr_asprintf(&input, "%ld%c", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
- gpr_free(input);
-
- gpr_asprintf(&input, " %ld%c", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
- gpr_free(input);
-
- gpr_asprintf(&input, "%ld %c", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
- gpr_free(input);
-
- gpr_asprintf(&input, "%ld %c ", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
- gpr_free(input);
- }
-}
-
-void test_decoding(void) {
- LOG_TEST("test_decoding");
- decode_suite('n', gpr_time_from_nanos);
- decode_suite('u', gpr_time_from_micros);
- decode_suite('m', gpr_time_from_millis);
- decode_suite('S', gpr_time_from_seconds);
- decode_suite('M', gpr_time_from_minutes);
- decode_suite('H', gpr_time_from_hours);
- assert_decodes_as("1000000000S",
- gpr_time_from_seconds(1000 * 1000 * 1000, GPR_TIMESPAN));
- assert_decodes_as("1000000000000000000000u", gpr_inf_future(GPR_TIMESPAN));
- assert_decodes_as("1000000001S", gpr_inf_future(GPR_TIMESPAN));
- assert_decodes_as("2000000001S", gpr_inf_future(GPR_TIMESPAN));
- assert_decodes_as("9999999999S", gpr_inf_future(GPR_TIMESPAN));
-}
-
-static void assert_decoding_fails(const char *s) {
- gpr_timespec x;
- GPR_ASSERT(0 ==
- grpc_http2_decode_timeout(grpc_slice_from_static_string(s), &x));
-}
-
-void test_decoding_fails(void) {
- LOG_TEST("test_decoding_fails");
- assert_decoding_fails("");
- assert_decoding_fails(" ");
- assert_decoding_fails("x");
- assert_decoding_fails("1");
- assert_decoding_fails("1x");
- assert_decoding_fails("1ux");
- assert_decoding_fails("!");
- assert_decoding_fails("n1");
- assert_decoding_fails("-1u");
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- test_encoding();
- test_decoding();
- test_decoding_fails();
- return 0;
-}
diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc
new file mode 100644
index 0000000000..e94be138dd
--- /dev/null
+++ b/test/core/transport/timeout_encoding_test.cc
@@ -0,0 +1,161 @@
+/*
+ *
+ * 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/transport/timeout_encoding.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/murmur_hash.h"
+#include "src/core/lib/gpr/string.h"
+#include "test/core/util/test_config.h"
+
+#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
+
+static void assert_encodes_as(grpc_millis ts, const char* s) {
+ char buffer[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
+ grpc_http2_encode_timeout(ts, buffer);
+ gpr_log(GPR_INFO, "check '%s' == '%s'", buffer, s);
+ GPR_ASSERT(0 == strcmp(buffer, s));
+}
+
+void test_encoding(void) {
+ LOG_TEST("test_encoding");
+ assert_encodes_as(-1, "1n");
+ assert_encodes_as(-10, "1n");
+ assert_encodes_as(1, "1m");
+ assert_encodes_as(10, "10m");
+ assert_encodes_as(100, "100m");
+ assert_encodes_as(890, "890m");
+ assert_encodes_as(900, "900m");
+ assert_encodes_as(901, "901m");
+ assert_encodes_as(1000, "1S");
+ assert_encodes_as(2000, "2S");
+ assert_encodes_as(2500, "2500m");
+ assert_encodes_as(59900, "59900m");
+ assert_encodes_as(50000, "50S");
+ assert_encodes_as(59000, "59S");
+ assert_encodes_as(60000, "1M");
+ assert_encodes_as(80000, "80S");
+ assert_encodes_as(90000, "90S");
+ assert_encodes_as(120000, "2M");
+ assert_encodes_as(20 * 60 * GPR_MS_PER_SEC, "20M");
+ assert_encodes_as(60 * 60 * GPR_MS_PER_SEC, "1H");
+ assert_encodes_as(10 * 60 * 60 * GPR_MS_PER_SEC, "10H");
+}
+
+static void assert_decodes_as(const char* buffer, grpc_millis expected) {
+ grpc_millis got;
+ uint32_t hash = gpr_murmur_hash3(buffer, strlen(buffer), 0);
+ gpr_log(GPR_INFO, "check decoding '%s' (hash=0x%x)", buffer, hash);
+ GPR_ASSERT(1 == grpc_http2_decode_timeout(
+ grpc_slice_from_static_string(buffer), &got));
+ if (got != expected) {
+ gpr_log(GPR_ERROR, "got:'%" PRIdPTR "' != expected:'%" PRIdPTR "'", got,
+ expected);
+ abort();
+ }
+}
+
+void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) {
+ long test_vals[] = {1, 12, 123, 1234, 12345, 123456,
+ 1234567, 12345678, 123456789, 98765432, 9876543, 987654,
+ 98765, 9876, 987, 98, 9};
+ unsigned i;
+ char* input;
+ for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) {
+ gpr_asprintf(&input, "%ld%c", test_vals[i], ext);
+ assert_decodes_as(input, answer(test_vals[i]));
+ gpr_free(input);
+
+ gpr_asprintf(&input, " %ld%c", test_vals[i], ext);
+ assert_decodes_as(input, answer(test_vals[i]));
+ gpr_free(input);
+
+ gpr_asprintf(&input, "%ld %c", test_vals[i], ext);
+ assert_decodes_as(input, answer(test_vals[i]));
+ gpr_free(input);
+
+ gpr_asprintf(&input, "%ld %c ", test_vals[i], ext);
+ assert_decodes_as(input, answer(test_vals[i]));
+ gpr_free(input);
+ }
+}
+
+static grpc_millis millis_from_nanos(int64_t x) {
+ return (grpc_millis)(x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0));
+}
+static grpc_millis millis_from_micros(int64_t x) {
+ return (grpc_millis)(x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0));
+}
+static grpc_millis millis_from_millis(int64_t x) { return (grpc_millis)x; }
+static grpc_millis millis_from_seconds(int64_t x) {
+ return (grpc_millis)(x * GPR_MS_PER_SEC);
+}
+static grpc_millis millis_from_minutes(int64_t x) {
+ return (grpc_millis)(x * 60 * GPR_MS_PER_SEC);
+}
+static grpc_millis millis_from_hours(int64_t x) {
+ return (grpc_millis)(x * 3600 * GPR_MS_PER_SEC);
+}
+
+void test_decoding(void) {
+ LOG_TEST("test_decoding");
+ decode_suite('n', millis_from_nanos);
+ decode_suite('u', millis_from_micros);
+ decode_suite('m', millis_from_millis);
+ decode_suite('S', millis_from_seconds);
+ decode_suite('M', millis_from_minutes);
+ decode_suite('H', millis_from_hours);
+ assert_decodes_as("1000000000S", millis_from_seconds(1000 * 1000 * 1000));
+ assert_decodes_as("1000000000000000000000u", GRPC_MILLIS_INF_FUTURE);
+ assert_decodes_as("1000000001S", GRPC_MILLIS_INF_FUTURE);
+ assert_decodes_as("2000000001S", GRPC_MILLIS_INF_FUTURE);
+ assert_decodes_as("9999999999S", GRPC_MILLIS_INF_FUTURE);
+}
+
+static void assert_decoding_fails(const char* s) {
+ grpc_millis x;
+ GPR_ASSERT(0 ==
+ grpc_http2_decode_timeout(grpc_slice_from_static_string(s), &x));
+}
+
+void test_decoding_fails(void) {
+ LOG_TEST("test_decoding_fails");
+ assert_decoding_fails("");
+ assert_decoding_fails(" ");
+ assert_decoding_fails("x");
+ assert_decoding_fails("1");
+ assert_decoding_fails("1x");
+ assert_decoding_fails("1ux");
+ assert_decoding_fails("!");
+ assert_decoding_fails("n1");
+ assert_decoding_fails("-1u");
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ test_encoding();
+ test_decoding();
+ test_decoding_fails();
+ return 0;
+}
diff --git a/test/core/tsi/BUILD b/test/core/tsi/BUILD
index 0c5509dda6..e28c0b5f84 100644
--- a/test/core/tsi/BUILD
+++ b/test/core/tsi/BUILD
@@ -20,7 +20,7 @@ grpc_package(name = "test/core/tsi")
grpc_cc_library(
name = "transport_security_test_lib",
- srcs = ["transport_security_test_lib.c"],
+ srcs = ["transport_security_test_lib.cc"],
hdrs = ["transport_security_test_lib.h"],
deps = [
"//:grpc",
@@ -30,8 +30,8 @@ grpc_cc_library(
grpc_cc_test(
name = "fake_transport_security_test",
- srcs = ["fake_transport_security_test.c"],
- language = "C",
+ srcs = ["fake_transport_security_test.cc"],
+ language = "C++",
deps = [
":transport_security_test_lib",
"//:grpc",
@@ -44,7 +44,7 @@ grpc_cc_test(
grpc_cc_test(
name = "ssl_transport_security_test",
- srcs = ["ssl_transport_security_test.c"],
+ srcs = ["ssl_transport_security_test.cc"],
data = [
"//src/core/tsi/test_creds:badclient.key",
"//src/core/tsi/test_creds:badclient.pem",
@@ -58,7 +58,7 @@ grpc_cc_test(
"//src/core/tsi/test_creds:server1.key",
"//src/core/tsi/test_creds:server1.pem",
],
- language = "C",
+ language = "C++",
deps = [
":transport_security_test_lib",
"//:grpc",
@@ -70,8 +70,8 @@ grpc_cc_test(
grpc_cc_test(
name = "transport_security_test",
- srcs = ["transport_security_test.c"],
- language = "C",
+ srcs = ["transport_security_test.cc"],
+ language = "C++",
deps = [
"//:grpc",
"//:gpr",
diff --git a/test/core/tsi/fake_transport_security_test.c b/test/core/tsi/fake_transport_security_test.cc
index 11be8802b7..73643fc9fd 100644
--- a/test/core/tsi/fake_transport_security_test.c
+++ b/test/core/tsi/fake_transport_security_test.cc
@@ -33,66 +33,67 @@ typedef struct fake_tsi_test_fixture {
tsi_test_fixture base;
} fake_tsi_test_fixture;
-static void fake_test_setup_handshakers(tsi_test_fixture *fixture) {
+static void fake_test_setup_handshakers(tsi_test_fixture* fixture) {
fixture->client_handshaker =
tsi_create_fake_handshaker(true /* is_client. */);
fixture->server_handshaker =
tsi_create_fake_handshaker(false /* is_client. */);
}
-static void validate_handshaker_peers(tsi_handshaker_result *result) {
- GPR_ASSERT(result != NULL);
+static void validate_handshaker_peers(tsi_handshaker_result* result) {
+ GPR_ASSERT(result != nullptr);
tsi_peer peer;
GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == TSI_OK);
- const tsi_peer_property *property =
+ const tsi_peer_property* property =
tsi_peer_get_property_by_name(&peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY);
- GPR_ASSERT(property != NULL);
+ GPR_ASSERT(property != nullptr);
GPR_ASSERT(memcmp(property->value.data, TSI_FAKE_CERTIFICATE_TYPE,
property->value.length) == 0);
tsi_peer_destruct(&peer);
}
-static void fake_test_check_handshaker_peers(tsi_test_fixture *fixture) {
+static void fake_test_check_handshaker_peers(tsi_test_fixture* fixture) {
validate_handshaker_peers(fixture->client_result);
validate_handshaker_peers(fixture->server_result);
}
-static void fake_test_destruct(tsi_test_fixture *fixture) {}
+static void fake_test_destruct(tsi_test_fixture* fixture) {}
static const struct tsi_test_fixture_vtable vtable = {
fake_test_setup_handshakers, fake_test_check_handshaker_peers,
fake_test_destruct};
-static tsi_test_fixture *fake_tsi_test_fixture_create() {
- fake_tsi_test_fixture *fake_fixture = gpr_zalloc(sizeof(*fake_fixture));
+static tsi_test_fixture* fake_tsi_test_fixture_create() {
+ fake_tsi_test_fixture* fake_fixture =
+ static_cast<fake_tsi_test_fixture*>(gpr_zalloc(sizeof(*fake_fixture)));
tsi_test_fixture_init(&fake_fixture->base);
fake_fixture->base.vtable = &vtable;
return &fake_fixture->base;
}
void fake_tsi_test_do_handshake_tiny_handshake_buffer() {
- tsi_test_fixture *fixture = fake_tsi_test_fixture_create();
+ tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
fixture->handshake_buffer_size = TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void fake_tsi_test_do_handshake_small_handshake_buffer() {
- tsi_test_fixture *fixture = fake_tsi_test_fixture_create();
+ tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
fixture->handshake_buffer_size = TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void fake_tsi_test_do_handshake() {
- tsi_test_fixture *fixture = fake_tsi_test_fixture_create();
+ tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void fake_tsi_test_do_round_trip_for_all_configs() {
- unsigned int *bit_array =
- gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS);
+ unsigned int* bit_array = static_cast<unsigned int*>(
+ gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS));
const unsigned int mask = 1U << (TSI_TEST_NUM_OF_ARGUMENTS - 1);
for (unsigned int val = 0; val < TSI_TEST_NUM_OF_COMBINATIONS; val++) {
unsigned int v = val;
@@ -100,8 +101,8 @@ void fake_tsi_test_do_round_trip_for_all_configs() {
bit_array[ind] = (v & mask) ? 1 : 0;
v <<= 1;
}
- tsi_test_fixture *fixture = fake_tsi_test_fixture_create();
- fake_tsi_test_fixture *fake_fixture = (fake_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
+ fake_tsi_test_fixture* fake_fixture = (fake_tsi_test_fixture*)fixture;
tsi_test_frame_protector_config_destroy(fake_fixture->base.config);
fake_fixture->base.config = tsi_test_frame_protector_config_create(
bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4],
@@ -120,9 +121,9 @@ void fake_tsi_test_do_round_trip_odd_buffer_size() {
for (size_t ind3 = 0; ind3 < size; ind3++) {
for (size_t ind4 = 0; ind4 < size; ind4++) {
for (size_t ind5 = 0; ind5 < size; ind5++) {
- tsi_test_fixture *fixture = fake_tsi_test_fixture_create();
- fake_tsi_test_fixture *fake_fixture =
- (fake_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
+ fake_tsi_test_fixture* fake_fixture =
+ (fake_tsi_test_fixture*)fixture;
tsi_test_frame_protector_config_set_buffer_size(
fake_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2],
odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]);
@@ -135,7 +136,7 @@ void fake_tsi_test_do_round_trip_odd_buffer_size() {
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
fake_tsi_test_do_handshake_tiny_handshake_buffer();
diff --git a/test/core/tsi/ssl_transport_security_test.c b/test/core/tsi/ssl_transport_security_test.cc
index 2399b054b1..bf54383c54 100644
--- a/test/core/tsi/ssl_transport_security_test.c
+++ b/test/core/tsi/ssl_transport_security_test.cc
@@ -52,8 +52,8 @@ typedef enum AlpnMode {
typedef struct ssl_alpn_lib {
AlpnMode alpn_mode;
- char **server_alpn_protocols;
- char **client_alpn_protocols;
+ char** server_alpn_protocols;
+ char** client_alpn_protocols;
uint16_t num_server_alpn_protocols;
uint16_t num_client_alpn_protocols;
} ssl_alpn_lib;
@@ -61,9 +61,9 @@ typedef struct ssl_alpn_lib {
typedef struct ssl_key_cert_lib {
bool use_bad_server_cert;
bool use_bad_client_cert;
- char *root_cert;
- tsi_ssl_pem_key_cert_pair *server_pem_key_cert_pairs;
- tsi_ssl_pem_key_cert_pair *bad_server_pem_key_cert_pairs;
+ char* root_cert;
+ tsi_ssl_pem_key_cert_pair* server_pem_key_cert_pairs;
+ tsi_ssl_pem_key_cert_pair* bad_server_pem_key_cert_pairs;
tsi_ssl_pem_key_cert_pair client_pem_key_cert_pair;
tsi_ssl_pem_key_cert_pair bad_client_pem_key_cert_pair;
uint16_t server_num_key_cert_pairs;
@@ -72,29 +72,29 @@ typedef struct ssl_key_cert_lib {
typedef struct ssl_tsi_test_fixture {
tsi_test_fixture base;
- ssl_key_cert_lib *key_cert_lib;
- ssl_alpn_lib *alpn_lib;
+ ssl_key_cert_lib* key_cert_lib;
+ ssl_alpn_lib* alpn_lib;
bool force_client_auth;
- char *server_name_indication;
- tsi_ssl_server_handshaker_factory *server_handshaker_factory;
- tsi_ssl_client_handshaker_factory *client_handshaker_factory;
+ char* server_name_indication;
+ tsi_ssl_server_handshaker_factory* server_handshaker_factory;
+ tsi_ssl_client_handshaker_factory* client_handshaker_factory;
} ssl_tsi_test_fixture;
-static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) {
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
- GPR_ASSERT(ssl_fixture != NULL);
- GPR_ASSERT(ssl_fixture->key_cert_lib != NULL);
- GPR_ASSERT(ssl_fixture->alpn_lib != NULL);
- ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib;
- ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib;
+static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) {
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ GPR_ASSERT(ssl_fixture != nullptr);
+ GPR_ASSERT(ssl_fixture->key_cert_lib != nullptr);
+ GPR_ASSERT(ssl_fixture->alpn_lib != nullptr);
+ ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib;
+ ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib;
/* Create client handshaker factory. */
- tsi_ssl_pem_key_cert_pair *client_key_cert_pair = NULL;
+ tsi_ssl_pem_key_cert_pair* client_key_cert_pair = nullptr;
if (ssl_fixture->force_client_auth) {
client_key_cert_pair = key_cert_lib->use_bad_client_cert
? &key_cert_lib->bad_client_pem_key_cert_pair
: &key_cert_lib->client_pem_key_cert_pair;
}
- char **client_alpn_protocols = NULL;
+ char** client_alpn_protocols = nullptr;
uint16_t num_client_alpn_protocols = 0;
if (alpn_lib->alpn_mode == ALPN_CLIENT_NO_SERVER ||
alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ||
@@ -103,12 +103,11 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) {
num_client_alpn_protocols = alpn_lib->num_client_alpn_protocols;
}
GPR_ASSERT(tsi_create_ssl_client_handshaker_factory(
- client_key_cert_pair, key_cert_lib->root_cert, NULL,
- (const char **)client_alpn_protocols,
- num_client_alpn_protocols,
+ client_key_cert_pair, key_cert_lib->root_cert, nullptr,
+ (const char**)client_alpn_protocols, num_client_alpn_protocols,
&ssl_fixture->client_handshaker_factory) == TSI_OK);
/* Create server handshaker factory. */
- char **server_alpn_protocols = NULL;
+ char** server_alpn_protocols = nullptr;
uint16_t num_server_alpn_protocols = 0;
if (alpn_lib->alpn_mode == ALPN_SERVER_NO_CLIENT ||
alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ||
@@ -126,19 +125,19 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) {
key_cert_lib->use_bad_server_cert
? key_cert_lib->bad_server_num_key_cert_pairs
: key_cert_lib->server_num_key_cert_pairs,
- key_cert_lib->root_cert, ssl_fixture->force_client_auth, NULL,
- (const char **)server_alpn_protocols,
+ key_cert_lib->root_cert, ssl_fixture->force_client_auth,
+ nullptr, (const char**)server_alpn_protocols,
num_server_alpn_protocols,
&ssl_fixture->server_handshaker_factory) == TSI_OK);
/* Create server and client handshakers. */
- tsi_handshaker *client_handshaker = NULL;
+ tsi_handshaker* client_handshaker = nullptr;
GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker(
ssl_fixture->client_handshaker_factory,
ssl_fixture->server_name_indication,
&client_handshaker) == TSI_OK);
ssl_fixture->base.client_handshaker =
tsi_create_adapter_handshaker(client_handshaker);
- tsi_handshaker *server_handshaker = NULL;
+ tsi_handshaker* server_handshaker = nullptr;
GPR_ASSERT(tsi_ssl_server_handshaker_factory_create_handshaker(
ssl_fixture->server_handshaker_factory, &server_handshaker) ==
TSI_OK);
@@ -146,45 +145,45 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) {
tsi_create_adapter_handshaker(server_handshaker);
}
-static void check_alpn(ssl_tsi_test_fixture *ssl_fixture,
- const tsi_peer *peer) {
- GPR_ASSERT(ssl_fixture != NULL);
- GPR_ASSERT(ssl_fixture->alpn_lib != NULL);
- ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib;
- const tsi_peer_property *alpn_property =
+static void check_alpn(ssl_tsi_test_fixture* ssl_fixture,
+ const tsi_peer* peer) {
+ GPR_ASSERT(ssl_fixture != nullptr);
+ GPR_ASSERT(ssl_fixture->alpn_lib != nullptr);
+ ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib;
+ const tsi_peer_property* alpn_property =
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
if (alpn_lib->alpn_mode != ALPN_CLIENT_SERVER_OK) {
- GPR_ASSERT(alpn_property == NULL);
+ GPR_ASSERT(alpn_property == nullptr);
} else {
- GPR_ASSERT(alpn_property != NULL);
- const char *expected_match = "baz";
+ GPR_ASSERT(alpn_property != nullptr);
+ const char* expected_match = "baz";
GPR_ASSERT(memcmp(alpn_property->value.data, expected_match,
alpn_property->value.length) == 0);
}
}
-static const tsi_peer_property *
-check_basic_authenticated_peer_and_get_common_name(const tsi_peer *peer) {
- const tsi_peer_property *cert_type_property =
+static const tsi_peer_property*
+check_basic_authenticated_peer_and_get_common_name(const tsi_peer* peer) {
+ const tsi_peer_property* cert_type_property =
tsi_peer_get_property_by_name(peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY);
- GPR_ASSERT(cert_type_property != NULL);
+ GPR_ASSERT(cert_type_property != nullptr);
GPR_ASSERT(memcmp(cert_type_property->value.data, TSI_X509_CERTIFICATE_TYPE,
cert_type_property->value.length) == 0);
- const tsi_peer_property *property = tsi_peer_get_property_by_name(
+ const tsi_peer_property* property = tsi_peer_get_property_by_name(
peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY);
- GPR_ASSERT(property != NULL);
+ GPR_ASSERT(property != nullptr);
return property;
}
-void check_server0_peer(tsi_peer *peer) {
- const tsi_peer_property *property =
+void check_server0_peer(tsi_peer* peer) {
+ const tsi_peer_property* property =
check_basic_authenticated_peer_and_get_common_name(peer);
- const char *expected_match = "*.test.google.com.au";
+ const char* expected_match = "*.test.google.com.au";
GPR_ASSERT(memcmp(property->value.data, expected_match,
property->value.length) == 0);
GPR_ASSERT(tsi_peer_get_property_by_name(
peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) ==
- NULL);
+ nullptr);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.test.google.com.au") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.com.au") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.blah") == 0);
@@ -194,9 +193,9 @@ void check_server0_peer(tsi_peer *peer) {
tsi_peer_destruct(peer);
}
-static bool check_subject_alt_name(tsi_peer *peer, const char *name) {
+static bool check_subject_alt_name(tsi_peer* peer, const char* name) {
for (size_t i = 0; i < peer->property_count; i++) {
- const tsi_peer_property *prop = &peer->properties[i];
+ const tsi_peer_property* prop = &peer->properties[i];
if (strcmp(prop->name, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) ==
0) {
if (memcmp(prop->value.data, name, prop->value.length) == 0) {
@@ -207,10 +206,10 @@ static bool check_subject_alt_name(tsi_peer *peer, const char *name) {
return false;
}
-void check_server1_peer(tsi_peer *peer) {
- const tsi_peer_property *property =
+void check_server1_peer(tsi_peer* peer) {
+ const tsi_peer_property* property =
check_basic_authenticated_peer_and_get_common_name(peer);
- const char *expected_match = "*.test.google.com";
+ const char* expected_match = "*.test.google.com";
GPR_ASSERT(memcmp(property->value.data, expected_match,
property->value.length) == 0);
GPR_ASSERT(check_subject_alt_name(peer, "*.test.google.fr") == 1);
@@ -226,29 +225,29 @@ void check_server1_peer(tsi_peer *peer) {
tsi_peer_destruct(peer);
}
-static void check_client_peer(ssl_tsi_test_fixture *ssl_fixture,
- tsi_peer *peer) {
- GPR_ASSERT(ssl_fixture != NULL);
- GPR_ASSERT(ssl_fixture->alpn_lib != NULL);
- ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib;
+static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture,
+ tsi_peer* peer) {
+ GPR_ASSERT(ssl_fixture != nullptr);
+ GPR_ASSERT(ssl_fixture->alpn_lib != nullptr);
+ ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib;
if (!ssl_fixture->force_client_auth) {
GPR_ASSERT(peer->property_count ==
(alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ? 1 : 0));
} else {
- const tsi_peer_property *property =
+ const tsi_peer_property* property =
check_basic_authenticated_peer_and_get_common_name(peer);
- const char *expected_match = "testclient";
+ const char* expected_match = "testclient";
GPR_ASSERT(memcmp(property->value.data, expected_match,
property->value.length) == 0);
}
tsi_peer_destruct(peer);
}
-static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) {
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
- GPR_ASSERT(ssl_fixture != NULL);
- GPR_ASSERT(ssl_fixture->key_cert_lib != NULL);
- ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib;
+static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) {
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ GPR_ASSERT(ssl_fixture != nullptr);
+ GPR_ASSERT(ssl_fixture->key_cert_lib != nullptr);
+ ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib;
tsi_peer peer;
bool expect_success =
!(key_cert_lib->use_bad_server_cert ||
@@ -258,13 +257,13 @@ static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) {
ssl_fixture->base.client_result, &peer) == TSI_OK);
check_alpn(ssl_fixture, &peer);
- if (ssl_fixture->server_name_indication != NULL) {
+ if (ssl_fixture->server_name_indication != nullptr) {
check_server1_peer(&peer);
} else {
check_server0_peer(&peer);
}
} else {
- GPR_ASSERT(ssl_fixture->base.client_result == NULL);
+ GPR_ASSERT(ssl_fixture->base.client_result == nullptr);
}
if (expect_success) {
GPR_ASSERT(tsi_handshaker_result_extract_peer(
@@ -272,22 +271,22 @@ static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) {
check_alpn(ssl_fixture, &peer);
check_client_peer(ssl_fixture, &peer);
} else {
- GPR_ASSERT(ssl_fixture->base.server_result == NULL);
+ GPR_ASSERT(ssl_fixture->base.server_result == nullptr);
}
}
static void ssl_test_pem_key_cert_pair_destroy(tsi_ssl_pem_key_cert_pair kp) {
- gpr_free((void *)kp.private_key);
- gpr_free((void *)kp.cert_chain);
+ gpr_free((void*)kp.private_key);
+ gpr_free((void*)kp.cert_chain);
}
-static void ssl_test_destruct(tsi_test_fixture *fixture) {
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
- if (ssl_fixture == NULL) {
+static void ssl_test_destruct(tsi_test_fixture* fixture) {
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ if (ssl_fixture == nullptr) {
return;
}
/* Destroy ssl_alpn_lib. */
- ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib;
+ ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib;
for (size_t i = 0; i < alpn_lib->num_server_alpn_protocols; i++) {
gpr_free(alpn_lib->server_alpn_protocols[i]);
}
@@ -298,7 +297,7 @@ static void ssl_test_destruct(tsi_test_fixture *fixture) {
gpr_free(alpn_lib->client_alpn_protocols);
gpr_free(alpn_lib);
/* Destroy ssl_key_cert_lib. */
- ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib;
+ ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib;
for (size_t i = 0; i < key_cert_lib->server_num_key_cert_pairs; i++) {
ssl_test_pem_key_cert_pair_destroy(
key_cert_lib->server_pem_key_cert_pairs[i]);
@@ -325,26 +324,28 @@ static const struct tsi_test_fixture_vtable vtable = {
ssl_test_setup_handshakers, ssl_test_check_handshaker_peers,
ssl_test_destruct};
-static char *load_file(const char *dir_path, const char *file_name) {
- char *file_path =
- gpr_zalloc(sizeof(char) * (strlen(dir_path) + strlen(file_name) + 1));
+static char* load_file(const char* dir_path, const char* file_name) {
+ char* file_path = static_cast<char*>(
+ gpr_zalloc(sizeof(char) * (strlen(dir_path) + strlen(file_name) + 1)));
memcpy(file_path, dir_path, strlen(dir_path));
memcpy(file_path + strlen(dir_path), file_name, strlen(file_name));
grpc_slice slice;
GPR_ASSERT(grpc_load_file(file_path, 1, &slice) == GRPC_ERROR_NONE);
- char *data = grpc_slice_to_c_string(slice);
+ char* data = grpc_slice_to_c_string(slice);
grpc_slice_unref(slice);
gpr_free(file_path);
return data;
}
-static tsi_test_fixture *ssl_tsi_test_fixture_create() {
- ssl_tsi_test_fixture *ssl_fixture = gpr_zalloc(sizeof(*ssl_fixture));
+static tsi_test_fixture* ssl_tsi_test_fixture_create() {
+ ssl_tsi_test_fixture* ssl_fixture =
+ static_cast<ssl_tsi_test_fixture*>(gpr_zalloc(sizeof(*ssl_fixture)));
tsi_test_fixture_init(&ssl_fixture->base);
ssl_fixture->base.test_unused_bytes = false;
ssl_fixture->base.vtable = &vtable;
/* Create ssl_key_cert_lib. */
- ssl_key_cert_lib *key_cert_lib = gpr_zalloc(sizeof(*key_cert_lib));
+ ssl_key_cert_lib* key_cert_lib =
+ static_cast<ssl_key_cert_lib*>(gpr_zalloc(sizeof(*key_cert_lib)));
key_cert_lib->use_bad_server_cert = false;
key_cert_lib->use_bad_client_cert = false;
key_cert_lib->server_num_key_cert_pairs =
@@ -352,11 +353,13 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() {
key_cert_lib->bad_server_num_key_cert_pairs =
SSL_TSI_TEST_BAD_SERVER_KEY_CERT_PAIRS_NUM;
key_cert_lib->server_pem_key_cert_pairs =
- gpr_malloc(sizeof(tsi_ssl_pem_key_cert_pair) *
- key_cert_lib->server_num_key_cert_pairs);
+ static_cast<tsi_ssl_pem_key_cert_pair*>(
+ gpr_malloc(sizeof(tsi_ssl_pem_key_cert_pair) *
+ key_cert_lib->server_num_key_cert_pairs));
key_cert_lib->bad_server_pem_key_cert_pairs =
- gpr_malloc(sizeof(tsi_ssl_pem_key_cert_pair) *
- key_cert_lib->bad_server_num_key_cert_pairs);
+ static_cast<tsi_ssl_pem_key_cert_pair*>(
+ gpr_malloc(sizeof(tsi_ssl_pem_key_cert_pair) *
+ key_cert_lib->bad_server_num_key_cert_pairs));
key_cert_lib->server_pem_key_cert_pairs[0].private_key =
load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "server0.key");
key_cert_lib->server_pem_key_cert_pairs[0].cert_chain =
@@ -380,11 +383,12 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() {
key_cert_lib->root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem");
ssl_fixture->key_cert_lib = key_cert_lib;
/* Create ssl_alpn_lib. */
- ssl_alpn_lib *alpn_lib = gpr_zalloc(sizeof(*alpn_lib));
+ ssl_alpn_lib* alpn_lib =
+ static_cast<ssl_alpn_lib*>(gpr_zalloc(sizeof(*alpn_lib)));
alpn_lib->server_alpn_protocols =
- gpr_zalloc(sizeof(char *) * SSL_TSI_TEST_ALPN_NUM);
+ static_cast<char**>(gpr_zalloc(sizeof(char*) * SSL_TSI_TEST_ALPN_NUM));
alpn_lib->client_alpn_protocols =
- gpr_zalloc(sizeof(char *) * SSL_TSI_TEST_ALPN_NUM);
+ static_cast<char**>(gpr_zalloc(sizeof(char*) * SSL_TSI_TEST_ALPN_NUM));
alpn_lib->server_alpn_protocols[0] = gpr_strdup(SSL_TSI_TEST_ALPN1);
alpn_lib->server_alpn_protocols[1] = gpr_strdup(SSL_TSI_TEST_ALPN3);
alpn_lib->client_alpn_protocols[0] = gpr_strdup(SSL_TSI_TEST_ALPN2);
@@ -394,34 +398,34 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() {
alpn_lib->alpn_mode = NO_ALPN;
ssl_fixture->alpn_lib = alpn_lib;
ssl_fixture->base.vtable = &vtable;
- ssl_fixture->server_name_indication = NULL;
+ ssl_fixture->server_name_indication = nullptr;
ssl_fixture->force_client_auth = false;
return &ssl_fixture->base;
}
void ssl_tsi_test_do_handshake_tiny_handshake_buffer() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
fixture->handshake_buffer_size = TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_small_handshake_buffer() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
fixture->handshake_buffer_size = TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_with_client_authentication() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->force_client_auth = true;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -429,33 +433,35 @@ void ssl_tsi_test_do_handshake_with_client_authentication() {
void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() {
/* server1 cert contains "waterzooi.test.google.be" in SAN. */
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
- ssl_fixture->server_name_indication = "waterzooi.test.google.be";
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_fixture->server_name_indication =
+ const_cast<char*>("waterzooi.test.google.be");
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain() {
/* server1 cert contains "*.test.google.fr" in SAN. */
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
- ssl_fixture->server_name_indication = "juju.test.google.fr";
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_fixture->server_name_indication =
+ const_cast<char*>("juju.test.google.fr");
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_with_bad_server_cert() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->key_cert_lib->use_bad_server_cert = true;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_with_bad_client_cert() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->key_cert_lib->use_bad_client_cert = true;
ssl_fixture->force_client_auth = true;
tsi_test_do_handshake(fixture);
@@ -463,40 +469,40 @@ void ssl_tsi_test_do_handshake_with_bad_client_cert() {
}
void ssl_tsi_test_do_handshake_alpn_client_no_server() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_NO_SERVER;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_alpn_server_no_client() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->alpn_lib->alpn_mode = ALPN_SERVER_NO_CLIENT;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_alpn_client_server_mismatch() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_MISMATCH;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_handshake_alpn_client_server_ok() {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_OK;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
}
void ssl_tsi_test_do_round_trip_for_all_configs() {
- unsigned int *bit_array =
- gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS);
+ unsigned int* bit_array = static_cast<unsigned int*>(
+ gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS));
const unsigned int mask = 1U << (TSI_TEST_NUM_OF_ARGUMENTS - 1);
for (unsigned int val = 0; val < TSI_TEST_NUM_OF_COMBINATIONS; val++) {
unsigned int v = val;
@@ -504,8 +510,8 @@ void ssl_tsi_test_do_round_trip_for_all_configs() {
bit_array[ind] = (v & mask) ? 1 : 0;
v <<= 1;
}
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
tsi_test_frame_protector_config_destroy(ssl_fixture->base.config);
ssl_fixture->base.config = tsi_test_frame_protector_config_create(
bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4],
@@ -524,8 +530,8 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() {
for (size_t ind3 = 0; ind3 < size; ind3++) {
for (size_t ind4 = 0; ind4 < size; ind4++) {
for (size_t ind5 = 0; ind5 < size; ind5++) {
- tsi_test_fixture *fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture;
+ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
+ ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
tsi_test_frame_protector_config_set_buffer_size(
ssl_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2],
odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]);
@@ -538,14 +544,14 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() {
}
}
-static const tsi_ssl_handshaker_factory_vtable *original_vtable;
+static const tsi_ssl_handshaker_factory_vtable* original_vtable;
static bool handshaker_factory_destructor_called;
static void ssl_tsi_test_handshaker_factory_destructor(
- tsi_ssl_handshaker_factory *factory) {
- GPR_ASSERT(factory != NULL);
+ tsi_ssl_handshaker_factory* factory) {
+ GPR_ASSERT(factory != nullptr);
handshaker_factory_destructor_called = true;
- if (original_vtable != NULL && original_vtable->destroy != NULL) {
+ if (original_vtable != nullptr && original_vtable->destroy != nullptr) {
original_vtable->destroy(factory);
}
}
@@ -555,20 +561,20 @@ static tsi_ssl_handshaker_factory_vtable test_handshaker_factory_vtable = {
void test_tsi_ssl_client_handshaker_factory_refcounting() {
int i;
- const char *cert_chain =
+ const char* cert_chain =
load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "client.pem");
- tsi_ssl_client_handshaker_factory *client_handshaker_factory;
+ tsi_ssl_client_handshaker_factory* client_handshaker_factory;
GPR_ASSERT(tsi_create_ssl_client_handshaker_factory(
- NULL, cert_chain, NULL, NULL, 0, &client_handshaker_factory) ==
- TSI_OK);
+ nullptr, cert_chain, nullptr, nullptr, 0,
+ &client_handshaker_factory) == TSI_OK);
handshaker_factory_destructor_called = false;
original_vtable = tsi_ssl_handshaker_factory_swap_vtable(
- (tsi_ssl_handshaker_factory *)client_handshaker_factory,
+ (tsi_ssl_handshaker_factory*)client_handshaker_factory,
&test_handshaker_factory_vtable);
- tsi_handshaker *handshaker[3];
+ tsi_handshaker* handshaker[3];
for (i = 0; i < 3; ++i) {
GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker(
@@ -588,14 +594,14 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() {
tsi_handshaker_destroy(handshaker[2]);
GPR_ASSERT(handshaker_factory_destructor_called);
- gpr_free((void *)cert_chain);
+ gpr_free((void*)cert_chain);
}
void test_tsi_ssl_server_handshaker_factory_refcounting() {
int i;
- tsi_ssl_server_handshaker_factory *server_handshaker_factory;
- tsi_handshaker *handshaker[3];
- const char *cert_chain =
+ tsi_ssl_server_handshaker_factory* server_handshaker_factory;
+ tsi_handshaker* handshaker[3];
+ const char* cert_chain =
load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "server0.pem");
tsi_ssl_pem_key_cert_pair cert_pair;
@@ -604,12 +610,12 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() {
load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "server0.key");
GPR_ASSERT(tsi_create_ssl_server_handshaker_factory(
- &cert_pair, 1, cert_chain, 0, NULL, NULL, 0,
+ &cert_pair, 1, cert_chain, 0, nullptr, nullptr, 0,
&server_handshaker_factory) == TSI_OK);
handshaker_factory_destructor_called = false;
original_vtable = tsi_ssl_handshaker_factory_swap_vtable(
- (tsi_ssl_handshaker_factory *)server_handshaker_factory,
+ (tsi_ssl_handshaker_factory*)server_handshaker_factory,
&test_handshaker_factory_vtable);
for (i = 0; i < 3; ++i) {
@@ -635,12 +641,12 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() {
/* Attempting to create a handshaker factory with invalid parameters should fail
* but not crash. */
void test_tsi_ssl_client_handshaker_factory_bad_params() {
- const char *cert_chain = "This is not a valid PEM file.";
+ const char* cert_chain = "This is not a valid PEM file.";
- tsi_ssl_client_handshaker_factory *client_handshaker_factory;
+ tsi_ssl_client_handshaker_factory* client_handshaker_factory;
GPR_ASSERT(tsi_create_ssl_client_handshaker_factory(
- NULL, cert_chain, NULL, NULL, 0, &client_handshaker_factory) ==
- TSI_INVALID_ARGUMENT);
+ nullptr, cert_chain, nullptr, nullptr, 0,
+ &client_handshaker_factory) == TSI_INVALID_ARGUMENT);
tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory);
}
@@ -650,7 +656,7 @@ void ssl_tsi_test_handshaker_factory_internals() {
test_tsi_ssl_client_handshaker_factory_bad_params();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
ssl_tsi_test_do_handshake_tiny_handshake_buffer();
@@ -661,9 +667,15 @@ int main(int argc, char **argv) {
ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain();
ssl_tsi_test_do_handshake_with_bad_server_cert();
ssl_tsi_test_do_handshake_with_bad_client_cert();
- ssl_tsi_test_do_handshake_alpn_client_no_server();
+ // TODO: BoringSSL and OpenSSL have different behaviors on handling mismatched
+ // ALPN. Re-enable this test if we can detect in the runtime which SSL library
+ // is used.
+ // ssl_tsi_test_do_handshake_alpn_client_no_server();
ssl_tsi_test_do_handshake_alpn_server_no_client();
- ssl_tsi_test_do_handshake_alpn_client_server_mismatch();
+ // TODO: BoringSSL and OpenSSL have different behaviors on handling mismatched
+ // ALPN. Re-enable this test if we can detect in the runtime which SSL library
+ // is used.
+ // ssl_tsi_test_do_handshake_alpn_client_server_mismatch();
ssl_tsi_test_do_handshake_alpn_client_server_ok();
ssl_tsi_test_do_round_trip_for_all_configs();
ssl_tsi_test_do_round_trip_odd_buffer_size();
diff --git a/test/core/tsi/transport_security_test.c b/test/core/tsi/transport_security_test.cc
index 27932a8169..42e17df25d 100644
--- a/test/core/tsi/transport_security_test.c
+++ b/test/core/tsi/transport_security_test.cc
@@ -27,7 +27,7 @@
#include <openssl/crypto.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/tsi/fake_transport_security.h"
#include "src/core/tsi/ssl_transport_security.h"
#include "test/core/util/test_config.h"
@@ -37,46 +37,46 @@ typedef struct {
int expected;
/* Host name to match. */
- const char *host_name;
+ const char* host_name;
/* Common name (CN). */
- const char *common_name;
+ const char* common_name;
/* Comma separated list of certificate names to match against. Any occurrence
of '#' will be replaced with a null character before processing. */
- const char *dns_names;
+ const char* dns_names;
/* Comma separated list of IP SANs to match aggainst */
- const char *ip_names;
+ const char* ip_names;
} cert_name_test_entry;
/* Largely inspired from:
chromium/src/net/cert/x509_certificate_unittest.cc.
TODO(jboeuf) uncomment test cases as we fix tsi_ssl_peer_matches_name. */
const cert_name_test_entry cert_name_test_entries[] = {
- {1, "foo.com", "foo.com", NULL, NULL},
- {1, "f", "f", NULL, NULL},
- {0, "h", "i", NULL, NULL},
- {1, "bar.foo.com", "*.foo.com", NULL, NULL},
+ {1, "foo.com", "foo.com", nullptr, nullptr},
+ {1, "f", "f", nullptr, nullptr},
+ {0, "h", "i", nullptr, nullptr},
+ {1, "bar.foo.com", "*.foo.com", nullptr, nullptr},
{1, "www.test.fr", "common.name",
- "*.test.com,*.test.co.uk,*.test.de,*.test.fr", NULL},
+ "*.test.com,*.test.co.uk,*.test.de,*.test.fr", nullptr},
/*
{1, "wwW.tESt.fr", "common.name", ",*.*,*.test.de,*.test.FR,www"},
*/
- {0, "f.uk", ".uk", NULL, NULL},
- {0, "w.bar.foo.com", "?.bar.foo.com", NULL, NULL},
- {0, "www.foo.com", "(www|ftp).foo.com", NULL, NULL},
- {0, "www.foo.com", "www.foo.com#", NULL, NULL}, /* # = null char. */
- {0, "www.foo.com", "", "www.foo.com#*.foo.com,#,#", NULL},
- {0, "www.house.example", "ww.house.example", NULL, NULL},
- {0, "test.org", "", "www.test.org,*.test.org,*.org", NULL},
- {0, "w.bar.foo.com", "w*.bar.foo.com", NULL, NULL},
- {0, "www.bar.foo.com", "ww*ww.bar.foo.com", NULL, NULL},
- {0, "wwww.bar.foo.com", "ww*ww.bar.foo.com", NULL, NULL},
- {0, "wwww.bar.foo.com", "w*w.bar.foo.com", NULL, NULL},
- {0, "wwww.bar.foo.com", "w*w.bar.foo.c0m", NULL, NULL},
- {0, "WALLY.bar.foo.com", "wa*.bar.foo.com", NULL, NULL},
- {0, "wally.bar.foo.com", "*Ly.bar.foo.com", NULL, NULL},
+ {0, "f.uk", ".uk", nullptr, nullptr},
+ {0, "w.bar.foo.com", "?.bar.foo.com", nullptr, nullptr},
+ {0, "www.foo.com", "(www|ftp).foo.com", nullptr, nullptr},
+ {0, "www.foo.com", "www.foo.com#", nullptr, nullptr}, /* # = null char. */
+ {0, "www.foo.com", "", "www.foo.com#*.foo.com,#,#", nullptr},
+ {0, "www.house.example", "ww.house.example", nullptr, nullptr},
+ {0, "test.org", "", "www.test.org,*.test.org,*.org", nullptr},
+ {0, "w.bar.foo.com", "w*.bar.foo.com", nullptr, nullptr},
+ {0, "www.bar.foo.com", "ww*ww.bar.foo.com", nullptr, nullptr},
+ {0, "wwww.bar.foo.com", "ww*ww.bar.foo.com", nullptr, nullptr},
+ {0, "wwww.bar.foo.com", "w*w.bar.foo.com", nullptr, nullptr},
+ {0, "wwww.bar.foo.com", "w*w.bar.foo.c0m", nullptr, nullptr},
+ {0, "WALLY.bar.foo.com", "wa*.bar.foo.com", nullptr, nullptr},
+ {0, "wally.bar.foo.com", "*Ly.bar.foo.com", nullptr, nullptr},
/*
{1, "ww%57.foo.com", "", "www.foo.com"},
{1, "www&.foo.com", "www%26.foo.com", NULL},
@@ -84,134 +84,138 @@ const cert_name_test_entry cert_name_test_entries[] = {
/* Common name must not be used if subject alternative name was provided. */
{0, "www.test.co.jp", "www.test.co.jp",
- "*.test.de,*.jp,www.test.co.uk,www.*.co.jp", NULL},
+ "*.test.de,*.jp,www.test.co.uk,www.*.co.jp", nullptr},
{0, "www.bar.foo.com", "www.bar.foo.com",
- "*.foo.com,*.*.foo.com,*.*.bar.foo.com,*..bar.foo.com,", NULL},
+ "*.foo.com,*.*.foo.com,*.*.bar.foo.com,*..bar.foo.com,", nullptr},
/* IDN tests */
- {1, "xn--poema-9qae5a.com.br", "xn--poema-9qae5a.com.br", NULL, NULL},
- {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", NULL, NULL},
+ {1, "xn--poema-9qae5a.com.br", "xn--poema-9qae5a.com.br", nullptr, nullptr},
+ {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", nullptr,
+ nullptr},
{0, "xn--poema-9qae5a.com.br", "",
"*.xn--poema-9qae5a.com.br,"
"xn--poema-*.com.br,"
"xn--*-9qae5a.com.br,"
"*--poema-9qae5a.com.br",
- NULL},
+ nullptr},
/* The following are adapted from the examples quoted from
http://tools.ietf.org/html/rfc6125#section-6.4.3
(e.g., *.example.com would match foo.example.com but
not bar.foo.example.com or example.com). */
- {1, "foo.example.com", "*.example.com", NULL, NULL},
- {0, "bar.foo.example.com", "*.example.com", NULL, NULL},
- {0, "example.com", "*.example.com", NULL, NULL},
+ {1, "foo.example.com", "*.example.com", nullptr, nullptr},
+ {0, "bar.foo.example.com", "*.example.com", nullptr, nullptr},
+ {0, "example.com", "*.example.com", nullptr, nullptr},
/* Partial wildcards are disallowed, though RFC 2818 rules allow them.
That is, forms such as baz*.example.net, *baz.example.net, and
b*z.example.net should NOT match domains. Instead, the wildcard must
always be the left-most label, and only a single label. */
- {0, "baz1.example.net", "baz*.example.net", NULL, NULL},
- {0, "foobaz.example.net", "*baz.example.net", NULL, NULL},
- {0, "buzz.example.net", "b*z.example.net", NULL, NULL},
- {0, "www.test.example.net", "www.*.example.net", NULL, NULL},
+ {0, "baz1.example.net", "baz*.example.net", nullptr, nullptr},
+ {0, "foobaz.example.net", "*baz.example.net", nullptr, nullptr},
+ {0, "buzz.example.net", "b*z.example.net", nullptr, nullptr},
+ {0, "www.test.example.net", "www.*.example.net", nullptr, nullptr},
/* Wildcards should not be valid for public registry controlled domains,
and unknown/unrecognized domains, at least three domain components must
be present. */
- {1, "www.test.example", "*.test.example", NULL, NULL},
- {1, "test.example.co.uk", "*.example.co.uk", NULL, NULL},
- {0, "test.example", "*.example", NULL, NULL},
+ {1, "www.test.example", "*.test.example", nullptr, nullptr},
+ {1, "test.example.co.uk", "*.example.co.uk", nullptr, nullptr},
+ {0, "test.example", "*.example", nullptr, nullptr},
/*
{0, "example.co.uk", "*.co.uk", NULL},
*/
- {0, "foo.com", "*.com", NULL, NULL},
- {0, "foo.us", "*.us", NULL, NULL},
- {0, "foo", "*", NULL, NULL},
+ {0, "foo.com", "*.com", nullptr, nullptr},
+ {0, "foo.us", "*.us", nullptr, nullptr},
+ {0, "foo", "*", nullptr, nullptr},
/* IDN variants of wildcards and registry controlled domains. */
- {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", NULL, NULL},
- {1, "test.example.xn--mgbaam7a8h", "*.example.xn--mgbaam7a8h", NULL, NULL},
+ {1, "www.xn--poema-9qae5a.com.br", "*.xn--poema-9qae5a.com.br", nullptr,
+ nullptr},
+ {1, "test.example.xn--mgbaam7a8h", "*.example.xn--mgbaam7a8h", nullptr,
+ nullptr},
/*
{0, "xn--poema-9qae5a.com.br", "*.com.br", NULL},
*/
- {0, "example.xn--mgbaam7a8h", "*.xn--mgbaam7a8h", NULL, NULL},
+ {0, "example.xn--mgbaam7a8h", "*.xn--mgbaam7a8h", nullptr, nullptr},
/* Wildcards should be permissible for 'private' registry controlled
domains. */
- {1, "www.appspot.com", "*.appspot.com", NULL, NULL},
- {1, "foo.s3.amazonaws.com", "*.s3.amazonaws.com", NULL, NULL},
+ {1, "www.appspot.com", "*.appspot.com", nullptr, nullptr},
+ {1, "foo.s3.amazonaws.com", "*.s3.amazonaws.com", nullptr, nullptr},
/* Multiple wildcards are not valid. */
- {0, "foo.example.com", "*.*.com", NULL, NULL},
- {0, "foo.bar.example.com", "*.bar.*.com", NULL, NULL},
+ {0, "foo.example.com", "*.*.com", nullptr, nullptr},
+ {0, "foo.bar.example.com", "*.bar.*.com", nullptr, nullptr},
/* Absolute vs relative DNS name tests. Although not explicitly specified
in RFC 6125, absolute reference names (those ending in a .) should
match either absolute or relative presented names. */
- {1, "foo.com", "foo.com.", NULL, NULL},
- {1, "foo.com.", "foo.com", NULL, NULL},
- {1, "foo.com.", "foo.com.", NULL, NULL},
- {1, "f", "f.", NULL, NULL},
- {1, "f.", "f", NULL, NULL},
- {1, "f.", "f.", NULL, NULL},
- {1, "www-3.bar.foo.com", "*.bar.foo.com.", NULL, NULL},
- {1, "www-3.bar.foo.com.", "*.bar.foo.com", NULL, NULL},
- {1, "www-3.bar.foo.com.", "*.bar.foo.com.", NULL, NULL},
- {0, ".", ".", NULL, NULL},
- {0, "example.com", "*.com.", NULL, NULL},
- {0, "example.com.", "*.com", NULL, NULL},
- {0, "example.com.", "*.com.", NULL, NULL},
- {0, "foo.", "*.", NULL, NULL},
- {0, "foo", "*.", NULL, NULL},
+ {1, "foo.com", "foo.com.", nullptr, nullptr},
+ {1, "foo.com.", "foo.com", nullptr, nullptr},
+ {1, "foo.com.", "foo.com.", nullptr, nullptr},
+ {1, "f", "f.", nullptr, nullptr},
+ {1, "f.", "f", nullptr, nullptr},
+ {1, "f.", "f.", nullptr, nullptr},
+ {1, "www-3.bar.foo.com", "*.bar.foo.com.", nullptr, nullptr},
+ {1, "www-3.bar.foo.com.", "*.bar.foo.com", nullptr, nullptr},
+ {1, "www-3.bar.foo.com.", "*.bar.foo.com.", nullptr, nullptr},
+ {0, ".", ".", nullptr, nullptr},
+ {0, "example.com", "*.com.", nullptr, nullptr},
+ {0, "example.com.", "*.com", nullptr, nullptr},
+ {0, "example.com.", "*.com.", nullptr, nullptr},
+ {0, "foo.", "*.", nullptr, nullptr},
+ {0, "foo", "*.", nullptr, nullptr},
/*
{0, "foo.co.uk", "*.co.uk.", NULL},
{0, "foo.co.uk.", "*.co.uk.", NULL},
*/
/* An empty CN is OK. */
- {1, "test.foo.com", "", "test.foo.com", NULL},
+ {1, "test.foo.com", "", "test.foo.com", nullptr},
/* An IP should not be used for the CN. */
- {0, "173.194.195.139", "173.194.195.139", NULL, NULL},
+ {0, "173.194.195.139", "173.194.195.139", nullptr, nullptr},
/* An IP can be used if the SAN IP is present */
- {1, "173.194.195.139", "foo.example.com", NULL, "173.194.195.139"},
- {0, "173.194.195.139", "foo.example.com", NULL, "8.8.8.8"},
- {0, "173.194.195.139", "foo.example.com", NULL, "8.8.8.8,8.8.4.4"},
- {1, "173.194.195.139", "foo.example.com", NULL, "8.8.8.8,173.194.195.139"},
- {0, "173.194.195.139", "foo.example.com", NULL, "173.194.195.13"},
- {0, "2001:db8:a0b:12f0::1", "foo.example.com", NULL, "173.194.195.13"},
- {1, "2001:db8:a0b:12f0::1", "foo.example.com", NULL,
+ {1, "173.194.195.139", "foo.example.com", nullptr, "173.194.195.139"},
+ {0, "173.194.195.139", "foo.example.com", nullptr, "8.8.8.8"},
+ {0, "173.194.195.139", "foo.example.com", nullptr, "8.8.8.8,8.8.4.4"},
+ {1, "173.194.195.139", "foo.example.com", nullptr,
+ "8.8.8.8,173.194.195.139"},
+ {0, "173.194.195.139", "foo.example.com", nullptr, "173.194.195.13"},
+ {0, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr, "173.194.195.13"},
+ {1, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr,
"2001:db8:a0b:12f0::1"},
- {0, "2001:db8:a0b:12f0::1", "foo.example.com", NULL,
+ {0, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr,
"2001:db8:a0b:12f0::2"},
- {1, "2001:db8:a0b:12f0::1", "foo.example.com", NULL,
+ {1, "2001:db8:a0b:12f0::1", "foo.example.com", nullptr,
"2001:db8:a0b:12f0::2,2001:db8:a0b:12f0::1,8.8.8.8"},
};
typedef struct name_list {
- const char *name;
- struct name_list *next;
+ const char* name;
+ struct name_list* next;
} name_list;
typedef struct {
size_t name_count;
- char *buffer;
- name_list *names;
+ char* buffer;
+ name_list* names;
} parsed_names;
-name_list *name_list_add(const char *n) {
- name_list *result = gpr_malloc(sizeof(name_list));
+name_list* name_list_add(const char* n) {
+ name_list* result = static_cast<name_list*>(gpr_malloc(sizeof(name_list)));
result->name = n;
- result->next = NULL;
+ result->next = nullptr;
return result;
}
-static parsed_names parse_names(const char *names_str) {
+static parsed_names parse_names(const char* names_str) {
parsed_names result;
- name_list *current_nl;
+ name_list* current_nl;
size_t i;
memset(&result, 0, sizeof(parsed_names));
- if (names_str == 0) return result;
+ if (names_str == nullptr) return result;
result.name_count = 1;
result.buffer = gpr_strdup(names_str);
result.names = name_list_add(result.buffer);
@@ -228,18 +232,18 @@ static parsed_names parse_names(const char *names_str) {
return result;
}
-static void destruct_parsed_names(parsed_names *pdn) {
- name_list *nl = pdn->names;
- if (pdn->buffer != NULL) gpr_free(pdn->buffer);
- while (nl != NULL) {
- name_list *to_be_free = nl;
+static void destruct_parsed_names(parsed_names* pdn) {
+ name_list* nl = pdn->names;
+ if (pdn->buffer != nullptr) gpr_free(pdn->buffer);
+ while (nl != nullptr) {
+ name_list* to_be_free = nl;
nl = nl->next;
gpr_free(to_be_free);
}
}
-static char *processed_name(const char *name) {
- char *result = gpr_strdup(name);
+static char* processed_name(const char* name) {
+ char* result = gpr_strdup(name);
size_t i;
for (i = 0; i < strlen(result); i++) {
if (result[i] == '#') {
@@ -250,10 +254,10 @@ static char *processed_name(const char *name) {
}
static tsi_peer peer_from_cert_name_test_entry(
- const cert_name_test_entry *entry) {
+ const cert_name_test_entry* entry) {
size_t i;
tsi_peer peer;
- name_list *nl;
+ name_list* nl;
parsed_names dns_entries = parse_names(entry->dns_names);
parsed_names ip_entries = parse_names(entry->ip_names);
nl = dns_entries.names;
@@ -264,8 +268,8 @@ static tsi_peer peer_from_cert_name_test_entry(
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, entry->common_name,
&peer.properties[0]) == TSI_OK);
i = 1;
- while (nl != NULL) {
- char *processed = processed_name(nl->name);
+ while (nl != nullptr) {
+ char* processed = processed_name(nl->name);
GPR_ASSERT(tsi_construct_string_peer_property(
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed,
strlen(nl->name), &peer.properties[i++]) == TSI_OK);
@@ -274,8 +278,8 @@ static tsi_peer peer_from_cert_name_test_entry(
}
nl = ip_entries.names;
- while (nl != NULL) {
- char *processed = processed_name(nl->name);
+ while (nl != nullptr) {
+ char* processed = processed_name(nl->name);
GPR_ASSERT(tsi_construct_string_peer_property(
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed,
strlen(nl->name), &peer.properties[i++]) == TSI_OK);
@@ -287,26 +291,26 @@ static tsi_peer peer_from_cert_name_test_entry(
return peer;
}
-char *cert_name_test_entry_to_string(const cert_name_test_entry *entry) {
- char *s;
+char* cert_name_test_entry_to_string(const cert_name_test_entry* entry) {
+ char* s;
gpr_asprintf(&s,
"{ success = %s, host_name = %s, common_name = %s, dns_names = "
"%s, ip_names = %s}",
entry->expected ? "true" : "false", entry->host_name,
entry->common_name,
- entry->dns_names != NULL ? entry->dns_names : "",
- entry->ip_names != NULL ? entry->ip_names : "");
+ entry->dns_names != nullptr ? entry->dns_names : "",
+ entry->ip_names != nullptr ? entry->ip_names : "");
return s;
}
static void test_peer_matches_name(void) {
size_t i = 0;
for (i = 0; i < GPR_ARRAY_SIZE(cert_name_test_entries); i++) {
- const cert_name_test_entry *entry = &cert_name_test_entries[i];
+ const cert_name_test_entry* entry = &cert_name_test_entries[i];
tsi_peer peer = peer_from_cert_name_test_entry(entry);
int result = tsi_ssl_peer_matches_name(&peer, entry->host_name);
if (result != entry->expected) {
- char *entry_str = cert_name_test_entry_to_string(entry);
+ char* entry_str = cert_name_test_entry_to_string(entry);
gpr_log(GPR_ERROR, "%s", entry_str);
gpr_free(entry_str);
GPR_ASSERT(0); /* Unexpected result. */
@@ -317,7 +321,7 @@ static void test_peer_matches_name(void) {
typedef struct {
tsi_result res;
- const char *str;
+ const char* str;
} tsi_result_string_pair;
static void test_result_strings(void) {
@@ -344,38 +348,39 @@ static void test_result_strings(void) {
}
static void test_protector_invalid_args(void) {
- GPR_ASSERT(tsi_frame_protector_protect(NULL, NULL, NULL, NULL, NULL) ==
- TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_frame_protector_protect_flush(NULL, NULL, NULL, NULL) ==
- TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_frame_protector_unprotect(NULL, NULL, NULL, NULL, NULL) ==
- TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_frame_protector_protect(nullptr, nullptr, nullptr, nullptr,
+ nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_frame_protector_protect_flush(
+ nullptr, nullptr, nullptr, nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_frame_protector_unprotect(nullptr, nullptr, nullptr, nullptr,
+ nullptr) == TSI_INVALID_ARGUMENT);
}
static void test_handshaker_invalid_args(void) {
- GPR_ASSERT(tsi_handshaker_get_result(NULL) == TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_extract_peer(NULL, NULL) == TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_create_frame_protector(NULL, NULL, NULL) ==
- TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_process_bytes_from_peer(NULL, NULL, NULL) ==
- TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_get_bytes_to_send_to_peer(NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_handshaker_get_result(nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_extract_peer(nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
- GPR_ASSERT(tsi_handshaker_next(NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL) ==
+ GPR_ASSERT(tsi_handshaker_create_frame_protector(nullptr, nullptr, nullptr) ==
TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_process_bytes_from_peer(
+ nullptr, nullptr, nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_get_bytes_to_send_to_peer(
+ nullptr, nullptr, nullptr) == TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_next(nullptr, nullptr, 0, nullptr, nullptr, nullptr,
+ nullptr, nullptr) == TSI_INVALID_ARGUMENT);
}
static void test_handshaker_invalid_state(void) {
- tsi_handshaker *h = tsi_create_fake_handshaker(0);
+ tsi_handshaker* h = tsi_create_fake_handshaker(0);
tsi_peer peer;
- tsi_frame_protector *p;
+ tsi_frame_protector* p;
GPR_ASSERT(tsi_handshaker_extract_peer(h, &peer) == TSI_FAILED_PRECONDITION);
- GPR_ASSERT(tsi_handshaker_create_frame_protector(h, NULL, &p) ==
+ GPR_ASSERT(tsi_handshaker_create_frame_protector(h, nullptr, &p) ==
TSI_FAILED_PRECONDITION);
tsi_handshaker_destroy(h);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_peer_matches_name();
test_result_strings();
diff --git a/test/core/tsi/transport_security_test_lib.c b/test/core/tsi/transport_security_test_lib.cc
index 7d66e110f2..3537366de9 100644
--- a/test/core/tsi/transport_security_test_lib.c
+++ b/test/core/tsi/transport_security_test_lib.cc
@@ -23,55 +23,74 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/thd.h>
#include "src/core/lib/security/transport/tsi_error.h"
#include "test/core/tsi/transport_security_test_lib.h"
+static void notification_signal(tsi_test_fixture* fixture) {
+ gpr_mu_lock(&fixture->mu);
+ fixture->notified = true;
+ gpr_cv_signal(&fixture->cv);
+ gpr_mu_unlock(&fixture->mu);
+}
+
+static void notification_wait(tsi_test_fixture* fixture) {
+ gpr_mu_lock(&fixture->mu);
+ while (!fixture->notified) {
+ gpr_cv_wait(&fixture->cv, &fixture->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ }
+ fixture->notified = false;
+ gpr_mu_unlock(&fixture->mu);
+}
+
typedef struct handshaker_args {
- tsi_test_fixture *fixture;
- unsigned char *handshake_buffer;
+ tsi_test_fixture* fixture;
+ unsigned char* handshake_buffer;
size_t handshake_buffer_size;
bool is_client;
bool transferred_data;
bool appended_unused_bytes;
- grpc_error *error;
+ grpc_error* error;
} handshaker_args;
-static handshaker_args *handshaker_args_create(tsi_test_fixture *fixture,
+static handshaker_args* handshaker_args_create(tsi_test_fixture* fixture,
bool is_client) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->config != NULL);
- handshaker_args *args = gpr_zalloc(sizeof(*args));
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->config != nullptr);
+ handshaker_args* args =
+ static_cast<handshaker_args*>(gpr_zalloc(sizeof(*args)));
args->fixture = fixture;
args->handshake_buffer_size = fixture->handshake_buffer_size;
- args->handshake_buffer = gpr_zalloc(args->handshake_buffer_size);
+ args->handshake_buffer =
+ static_cast<unsigned char*>(gpr_zalloc(args->handshake_buffer_size));
args->is_client = is_client;
args->error = GRPC_ERROR_NONE;
return args;
}
-static void handshaker_args_destroy(handshaker_args *args) {
+static void handshaker_args_destroy(handshaker_args* args) {
gpr_free(args->handshake_buffer);
GRPC_ERROR_UNREF(args->error);
gpr_free(args);
}
-static void do_handshaker_next(handshaker_args *args);
+static void do_handshaker_next(handshaker_args* args);
-static void setup_handshakers(tsi_test_fixture *fixture) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->vtable != NULL);
- GPR_ASSERT(fixture->vtable->setup_handshakers != NULL);
+static void setup_handshakers(tsi_test_fixture* fixture) {
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->vtable != nullptr);
+ GPR_ASSERT(fixture->vtable->setup_handshakers != nullptr);
fixture->vtable->setup_handshakers(fixture);
}
-static void check_unused_bytes(tsi_test_fixture *fixture) {
- tsi_handshaker_result *result_with_unused_bytes =
+static void check_unused_bytes(tsi_test_fixture* fixture) {
+ tsi_handshaker_result* result_with_unused_bytes =
fixture->has_client_finished_first ? fixture->server_result
: fixture->client_result;
- tsi_handshaker_result *result_without_unused_bytes =
+ tsi_handshaker_result* result_without_unused_bytes =
fixture->has_client_finished_first ? fixture->client_result
: fixture->server_result;
- const unsigned char *bytes = NULL;
+ const unsigned char* bytes = nullptr;
size_t bytes_size = 0;
GPR_ASSERT(tsi_handshaker_result_get_unused_bytes(
result_with_unused_bytes, &bytes, &bytes_size) == TSI_OK);
@@ -80,18 +99,19 @@ static void check_unused_bytes(tsi_test_fixture *fixture) {
GPR_ASSERT(tsi_handshaker_result_get_unused_bytes(
result_without_unused_bytes, &bytes, &bytes_size) == TSI_OK);
GPR_ASSERT(bytes_size == 0);
- GPR_ASSERT(bytes == NULL);
+ GPR_ASSERT(bytes == nullptr);
}
-static void check_handshake_results(tsi_test_fixture *fixture) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->vtable != NULL);
- GPR_ASSERT(fixture->vtable->check_handshaker_peers != NULL);
+static void check_handshake_results(tsi_test_fixture* fixture) {
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->vtable != nullptr);
+ GPR_ASSERT(fixture->vtable->check_handshaker_peers != nullptr);
/* Check handshaker peers. */
fixture->vtable->check_handshaker_peers(fixture);
/* Check unused bytes. */
if (fixture->test_unused_bytes) {
- if (fixture->server_result != NULL && fixture->client_result != NULL) {
+ if (fixture->server_result != nullptr &&
+ fixture->client_result != nullptr) {
check_unused_bytes(fixture);
}
fixture->bytes_written_to_server_channel = 0;
@@ -101,52 +121,53 @@ static void check_handshake_results(tsi_test_fixture *fixture) {
}
}
-static void send_bytes_to_peer(tsi_test_fixture *fixture,
- const unsigned char *buf, size_t buf_size,
+static void send_bytes_to_peer(tsi_test_fixture* fixture,
+ const unsigned char* buf, size_t buf_size,
bool is_client) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(buf != NULL);
- uint8_t *channel =
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(buf != nullptr);
+ uint8_t* channel =
is_client ? fixture->server_channel : fixture->client_channel;
- GPR_ASSERT(channel != NULL);
- size_t *bytes_written = is_client ? &fixture->bytes_written_to_server_channel
+ GPR_ASSERT(channel != nullptr);
+ size_t* bytes_written = is_client ? &fixture->bytes_written_to_server_channel
: &fixture->bytes_written_to_client_channel;
- GPR_ASSERT(bytes_written != NULL);
+ GPR_ASSERT(bytes_written != nullptr);
GPR_ASSERT(*bytes_written + buf_size <= TSI_TEST_DEFAULT_CHANNEL_SIZE);
/* Write data to channel. */
memcpy(channel + *bytes_written, buf, buf_size);
*bytes_written += buf_size;
}
-static void maybe_append_unused_bytes(handshaker_args *args) {
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
- tsi_test_fixture *fixture = args->fixture;
+static void maybe_append_unused_bytes(handshaker_args* args) {
+ GPR_ASSERT(args != nullptr);
+ GPR_ASSERT(args->fixture != nullptr);
+ tsi_test_fixture* fixture = args->fixture;
if (fixture->test_unused_bytes && !args->appended_unused_bytes) {
args->appended_unused_bytes = true;
- send_bytes_to_peer(fixture, (const unsigned char *)TSI_TEST_UNUSED_BYTES,
+ send_bytes_to_peer(fixture, (const unsigned char*)TSI_TEST_UNUSED_BYTES,
strlen(TSI_TEST_UNUSED_BYTES), args->is_client);
- if (fixture->client_result != NULL && fixture->server_result == NULL) {
+ if (fixture->client_result != nullptr &&
+ fixture->server_result == nullptr) {
fixture->has_client_finished_first = true;
}
}
}
-static void receive_bytes_from_peer(tsi_test_fixture *fixture,
- unsigned char **buf, size_t *buf_size,
+static void receive_bytes_from_peer(tsi_test_fixture* fixture,
+ unsigned char** buf, size_t* buf_size,
bool is_client) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(*buf != NULL);
- GPR_ASSERT(buf_size != NULL);
- uint8_t *channel =
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(*buf != nullptr);
+ GPR_ASSERT(buf_size != nullptr);
+ uint8_t* channel =
is_client ? fixture->client_channel : fixture->server_channel;
- GPR_ASSERT(channel != NULL);
- size_t *bytes_read = is_client ? &fixture->bytes_read_from_client_channel
+ GPR_ASSERT(channel != nullptr);
+ size_t* bytes_read = is_client ? &fixture->bytes_read_from_client_channel
: &fixture->bytes_read_from_server_channel;
- size_t *bytes_written = is_client ? &fixture->bytes_written_to_client_channel
+ size_t* bytes_written = is_client ? &fixture->bytes_written_to_client_channel
: &fixture->bytes_written_to_server_channel;
- GPR_ASSERT(bytes_read != NULL);
- GPR_ASSERT(bytes_written != NULL);
+ GPR_ASSERT(bytes_read != nullptr);
+ GPR_ASSERT(bytes_written != nullptr);
size_t to_read = *buf_size < *bytes_written - *bytes_read
? *buf_size
: *bytes_written - *bytes_read;
@@ -156,21 +177,22 @@ static void receive_bytes_from_peer(tsi_test_fixture *fixture,
*bytes_read += to_read;
}
-static void send_message_to_peer(tsi_test_fixture *fixture,
- tsi_frame_protector *protector,
+static void send_message_to_peer(tsi_test_fixture* fixture,
+ tsi_frame_protector* protector,
bool is_client) {
/* Initialization. */
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->config != NULL);
- GPR_ASSERT(protector != NULL);
- tsi_test_frame_protector_config *config = fixture->config;
- unsigned char *protected_buffer = gpr_zalloc(config->protected_buffer_size);
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->config != nullptr);
+ GPR_ASSERT(protector != nullptr);
+ tsi_test_frame_protector_config* config = fixture->config;
+ unsigned char* protected_buffer =
+ static_cast<unsigned char*>(gpr_zalloc(config->protected_buffer_size));
size_t message_size =
is_client ? config->client_message_size : config->server_message_size;
- uint8_t *message =
+ uint8_t* message =
is_client ? config->client_message : config->server_message;
- GPR_ASSERT(message != NULL);
- const unsigned char *message_bytes = (const unsigned char *)message;
+ GPR_ASSERT(message != nullptr);
+ const unsigned char* message_bytes = (const unsigned char*)message;
tsi_result result = TSI_OK;
/* Do protect and send protected data to peer. */
while (message_size > 0 && result == TSI_OK) {
@@ -205,25 +227,26 @@ static void send_message_to_peer(tsi_test_fixture *fixture,
gpr_free(protected_buffer);
}
-static void receive_message_from_peer(tsi_test_fixture *fixture,
- tsi_frame_protector *protector,
- unsigned char *message,
- size_t *bytes_received, bool is_client) {
+static void receive_message_from_peer(tsi_test_fixture* fixture,
+ tsi_frame_protector* protector,
+ unsigned char* message,
+ size_t* bytes_received, bool is_client) {
/* Initialization. */
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(protector != NULL);
- GPR_ASSERT(message != NULL);
- GPR_ASSERT(bytes_received != NULL);
- GPR_ASSERT(fixture->config != NULL);
- tsi_test_frame_protector_config *config = fixture->config;
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(protector != nullptr);
+ GPR_ASSERT(message != nullptr);
+ GPR_ASSERT(bytes_received != nullptr);
+ GPR_ASSERT(fixture->config != nullptr);
+ tsi_test_frame_protector_config* config = fixture->config;
size_t read_offset = 0;
size_t message_offset = 0;
size_t read_from_peer_size = 0;
tsi_result result = TSI_OK;
bool done = false;
- unsigned char *read_buffer = gpr_zalloc(config->read_buffer_allocated_size);
- unsigned char *message_buffer =
- gpr_zalloc(config->message_buffer_allocated_size);
+ unsigned char* read_buffer = static_cast<unsigned char*>(
+ gpr_zalloc(config->read_buffer_allocated_size));
+ unsigned char* message_buffer = static_cast<unsigned char*>(
+ gpr_zalloc(config->message_buffer_allocated_size));
/* Do unprotect on data received from peer. */
while (!done && result == TSI_OK) {
/* Receive data from peer. */
@@ -261,29 +284,31 @@ static void receive_message_from_peer(tsi_test_fixture *fixture,
gpr_free(message_buffer);
}
-grpc_error *on_handshake_next_done(tsi_result result, void *user_data,
- const unsigned char *bytes_to_send,
+grpc_error* on_handshake_next_done(tsi_result result, void* user_data,
+ const unsigned char* bytes_to_send,
size_t bytes_to_send_size,
- tsi_handshaker_result *handshaker_result) {
- handshaker_args *args = (handshaker_args *)user_data;
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
- tsi_test_fixture *fixture = args->fixture;
- grpc_error *error = GRPC_ERROR_NONE;
+ tsi_handshaker_result* handshaker_result) {
+ handshaker_args* args = (handshaker_args*)user_data;
+ GPR_ASSERT(args != nullptr);
+ GPR_ASSERT(args->fixture != nullptr);
+ tsi_test_fixture* fixture = args->fixture;
+ grpc_error* error = GRPC_ERROR_NONE;
/* Read more data if we need to. */
if (result == TSI_INCOMPLETE_DATA) {
GPR_ASSERT(bytes_to_send_size == 0);
+ notification_signal(fixture);
return error;
}
if (result != TSI_OK) {
+ notification_signal(fixture);
return grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
}
/* Update handshaker result. */
- if (handshaker_result != NULL) {
- tsi_handshaker_result **result_to_write =
+ if (handshaker_result != nullptr) {
+ tsi_handshaker_result** result_to_write =
args->is_client ? &fixture->client_result : &fixture->server_result;
- GPR_ASSERT(*result_to_write == NULL);
+ GPR_ASSERT(*result_to_write == nullptr);
*result_to_write = handshaker_result;
}
/* Send data to peer, if needed. */
@@ -292,68 +317,76 @@ grpc_error *on_handshake_next_done(tsi_result result, void *user_data,
args->is_client);
args->transferred_data = true;
}
- if (handshaker_result != NULL) {
+ if (handshaker_result != nullptr) {
maybe_append_unused_bytes(args);
}
+ notification_signal(fixture);
return error;
}
static void on_handshake_next_done_wrapper(
- tsi_result result, void *user_data, const unsigned char *bytes_to_send,
- size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result) {
- handshaker_args *args = (handshaker_args *)user_data;
+ tsi_result result, void* user_data, const unsigned char* bytes_to_send,
+ size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
+ handshaker_args* args = (handshaker_args*)user_data;
args->error = on_handshake_next_done(result, user_data, bytes_to_send,
bytes_to_send_size, handshaker_result);
}
-static bool is_handshake_finished_properly(handshaker_args *args) {
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
- tsi_test_fixture *fixture = args->fixture;
- if ((args->is_client && fixture->client_result != NULL) ||
- (!args->is_client && fixture->server_result != NULL)) {
+static bool is_handshake_finished_properly(handshaker_args* args) {
+ GPR_ASSERT(args != nullptr);
+ GPR_ASSERT(args->fixture != nullptr);
+ tsi_test_fixture* fixture = args->fixture;
+ if ((args->is_client && fixture->client_result != nullptr) ||
+ (!args->is_client && fixture->server_result != nullptr)) {
return true;
}
return false;
}
-static void do_handshaker_next(handshaker_args *args) {
+static void do_handshaker_next(handshaker_args* args) {
/* Initialization. */
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
- tsi_test_fixture *fixture = args->fixture;
- tsi_handshaker *handshaker =
+ GPR_ASSERT(args != nullptr);
+ GPR_ASSERT(args->fixture != nullptr);
+ tsi_test_fixture* fixture = args->fixture;
+ tsi_handshaker* handshaker =
args->is_client ? fixture->client_handshaker : fixture->server_handshaker;
if (is_handshake_finished_properly(args)) {
return;
}
- tsi_handshaker_result *handshaker_result = NULL;
- unsigned char *bytes_to_send = NULL;
+ tsi_handshaker_result* handshaker_result = nullptr;
+ unsigned char* bytes_to_send = nullptr;
size_t bytes_to_send_size = 0;
+ tsi_result result = TSI_OK;
/* Receive data from peer, if available. */
- size_t buf_size = args->handshake_buffer_size;
- receive_bytes_from_peer(args->fixture, &args->handshake_buffer, &buf_size,
- args->is_client);
- if (buf_size > 0) {
- args->transferred_data = true;
- }
- /* Peform handshaker next. */
- tsi_result result = tsi_handshaker_next(
- handshaker, args->handshake_buffer, buf_size,
- (const unsigned char **)&bytes_to_send, &bytes_to_send_size,
- &handshaker_result, &on_handshake_next_done_wrapper, args);
- if (result != TSI_ASYNC) {
- args->error = on_handshake_next_done(result, args, bytes_to_send,
- bytes_to_send_size, handshaker_result);
- }
+ do {
+ size_t buf_size = args->handshake_buffer_size;
+ receive_bytes_from_peer(args->fixture, &args->handshake_buffer, &buf_size,
+ args->is_client);
+ if (buf_size > 0) {
+ args->transferred_data = true;
+ }
+ /* Peform handshaker next. */
+ result = tsi_handshaker_next(handshaker, args->handshake_buffer, buf_size,
+ (const unsigned char**)&bytes_to_send,
+ &bytes_to_send_size, &handshaker_result,
+ &on_handshake_next_done_wrapper, args);
+ if (result != TSI_ASYNC) {
+ args->error = on_handshake_next_done(
+ result, args, bytes_to_send, bytes_to_send_size, handshaker_result);
+ if (args->error != GRPC_ERROR_NONE) {
+ return;
+ }
+ }
+ } while (result == TSI_INCOMPLETE_DATA);
+ notification_wait(fixture);
}
-void tsi_test_do_handshake(tsi_test_fixture *fixture) {
+void tsi_test_do_handshake(tsi_test_fixture* fixture) {
/* Initializaiton. */
setup_handshakers(fixture);
- handshaker_args *client_args =
+ handshaker_args* client_args =
handshaker_args_create(fixture, true /* is_client */);
- handshaker_args *server_args =
+ handshaker_args* server_args =
handshaker_args_create(fixture, false /* is_client */);
/* Do handshake. */
do {
@@ -368,7 +401,8 @@ void tsi_test_do_handshake(tsi_test_fixture *fixture) {
break;
}
GPR_ASSERT(client_args->transferred_data || server_args->transferred_data);
- } while (fixture->client_result == NULL || fixture->server_result == NULL);
+ } while (fixture->client_result == nullptr ||
+ fixture->server_result == nullptr);
/* Verify handshake results. */
check_handshake_results(fixture);
/* Cleanup. */
@@ -376,13 +410,13 @@ void tsi_test_do_handshake(tsi_test_fixture *fixture) {
handshaker_args_destroy(server_args);
}
-void tsi_test_do_round_trip(tsi_test_fixture *fixture) {
+void tsi_test_do_round_trip(tsi_test_fixture* fixture) {
/* Initialization. */
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->config != NULL);
- tsi_test_frame_protector_config *config = fixture->config;
- tsi_frame_protector *client_frame_protector = NULL;
- tsi_frame_protector *server_frame_protector = NULL;
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->config != nullptr);
+ tsi_test_frame_protector_config* config = fixture->config;
+ tsi_frame_protector* client_frame_protector = nullptr;
+ tsi_frame_protector* server_frame_protector = nullptr;
/* Perform handshake. */
tsi_test_do_handshake(fixture);
/* Create frame protectors.*/
@@ -391,7 +425,7 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) {
GPR_ASSERT(tsi_handshaker_result_create_frame_protector(
fixture->client_result,
client_max_output_protected_frame_size == 0
- ? NULL
+ ? nullptr
: &client_max_output_protected_frame_size,
&client_frame_protector) == TSI_OK);
size_t server_max_output_protected_frame_size =
@@ -399,13 +433,13 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) {
GPR_ASSERT(tsi_handshaker_result_create_frame_protector(
fixture->server_result,
server_max_output_protected_frame_size == 0
- ? NULL
+ ? nullptr
: &server_max_output_protected_frame_size,
&server_frame_protector) == TSI_OK);
/* Client sends a message to server. */
send_message_to_peer(fixture, client_frame_protector, true /* is_client */);
- unsigned char *server_received_message =
- gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE);
+ unsigned char* server_received_message =
+ static_cast<unsigned char*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE));
size_t server_received_message_size = 0;
receive_message_from_peer(
fixture, server_frame_protector, server_received_message,
@@ -415,8 +449,8 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) {
server_received_message_size) == 0);
/* Server sends a message to client. */
send_message_to_peer(fixture, server_frame_protector, false /* is_client */);
- unsigned char *client_received_message =
- gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE);
+ unsigned char* client_received_message =
+ static_cast<unsigned char*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE));
size_t client_received_message_size = 0;
receive_message_from_peer(
fixture, client_frame_protector, client_received_message,
@@ -431,17 +465,18 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) {
gpr_free(client_received_message);
}
-static unsigned char *generate_random_message(size_t size) {
+static unsigned char* generate_random_message(size_t size) {
size_t i;
unsigned char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
- unsigned char *output = gpr_zalloc(sizeof(unsigned char) * size);
+ unsigned char* output =
+ static_cast<unsigned char*>(gpr_zalloc(sizeof(unsigned char) * size));
for (i = 0; i < size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}
return output;
}
-tsi_test_frame_protector_config *tsi_test_frame_protector_config_create(
+tsi_test_frame_protector_config* tsi_test_frame_protector_config_create(
bool use_default_read_buffer_allocated_size,
bool use_default_message_buffer_allocated_size,
bool use_default_protected_buffer_size, bool use_default_client_message,
@@ -449,7 +484,9 @@ tsi_test_frame_protector_config *tsi_test_frame_protector_config_create(
bool use_default_client_max_output_protected_frame_size,
bool use_default_server_max_output_protected_frame_size,
bool use_default_handshake_buffer_size) {
- tsi_test_frame_protector_config *config = gpr_zalloc(sizeof(*config));
+ tsi_test_frame_protector_config* config =
+ static_cast<tsi_test_frame_protector_config*>(
+ gpr_zalloc(sizeof(*config)));
/* Set the value for read_buffer_allocated_size. */
config->read_buffer_allocated_size =
use_default_read_buffer_allocated_size
@@ -498,11 +535,11 @@ tsi_test_frame_protector_config *tsi_test_frame_protector_config_create(
}
void tsi_test_frame_protector_config_set_buffer_size(
- tsi_test_frame_protector_config *config, size_t read_buffer_allocated_size,
+ tsi_test_frame_protector_config* config, size_t read_buffer_allocated_size,
size_t message_buffer_allocated_size, size_t protected_buffer_size,
size_t client_max_output_protected_frame_size,
size_t server_max_output_protected_frame_size) {
- GPR_ASSERT(config != NULL);
+ GPR_ASSERT(config != nullptr);
config->read_buffer_allocated_size = read_buffer_allocated_size;
config->message_buffer_allocated_size = message_buffer_allocated_size;
config->protected_buffer_size = protected_buffer_size;
@@ -513,29 +550,34 @@ void tsi_test_frame_protector_config_set_buffer_size(
}
void tsi_test_frame_protector_config_destroy(
- tsi_test_frame_protector_config *config) {
- GPR_ASSERT(config != NULL);
+ tsi_test_frame_protector_config* config) {
+ GPR_ASSERT(config != nullptr);
gpr_free(config->client_message);
gpr_free(config->server_message);
gpr_free(config);
}
-void tsi_test_fixture_init(tsi_test_fixture *fixture) {
+void tsi_test_fixture_init(tsi_test_fixture* fixture) {
fixture->config = tsi_test_frame_protector_config_create(
true, true, true, true, true, true, true, true);
fixture->handshake_buffer_size = TSI_TEST_DEFAULT_BUFFER_SIZE;
- fixture->client_channel = gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE);
- fixture->server_channel = gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE);
+ fixture->client_channel =
+ static_cast<uint8_t*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE));
+ fixture->server_channel =
+ static_cast<uint8_t*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE));
fixture->bytes_written_to_client_channel = 0;
fixture->bytes_written_to_server_channel = 0;
fixture->bytes_read_from_client_channel = 0;
fixture->bytes_read_from_server_channel = 0;
fixture->test_unused_bytes = true;
fixture->has_client_finished_first = false;
+ gpr_mu_init(&fixture->mu);
+ gpr_cv_init(&fixture->cv);
+ fixture->notified = false;
}
-void tsi_test_fixture_destroy(tsi_test_fixture *fixture) {
- GPR_ASSERT(fixture != NULL);
+void tsi_test_fixture_destroy(tsi_test_fixture* fixture) {
+ GPR_ASSERT(fixture != nullptr);
tsi_test_frame_protector_config_destroy(fixture->config);
tsi_handshaker_destroy(fixture->client_handshaker);
tsi_handshaker_destroy(fixture->server_handshaker);
@@ -543,8 +585,10 @@ void tsi_test_fixture_destroy(tsi_test_fixture *fixture) {
tsi_handshaker_result_destroy(fixture->server_result);
gpr_free(fixture->client_channel);
gpr_free(fixture->server_channel);
- GPR_ASSERT(fixture->vtable != NULL);
- GPR_ASSERT(fixture->vtable->destruct != NULL);
+ GPR_ASSERT(fixture->vtable != nullptr);
+ GPR_ASSERT(fixture->vtable->destruct != nullptr);
fixture->vtable->destruct(fixture);
+ gpr_mu_destroy(&fixture->mu);
+ gpr_cv_destroy(&fixture->cv);
gpr_free(fixture);
}
diff --git a/test/core/tsi/transport_security_test_lib.h b/test/core/tsi/transport_security_test_lib.h
index 8ae2024ee4..9b07448cc5 100644
--- a/test/core/tsi/transport_security_test_lib.h
+++ b/test/core/tsi/transport_security_test_lib.h
@@ -21,6 +21,8 @@
#include "src/core/tsi/transport_security_interface.h"
+#include <grpc/support/sync.h>
+
#define TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE 32
#define TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE 128
#define TSI_TEST_SMALL_READ_BUFFER_ALLOCATED_SIZE 41
@@ -53,29 +55,29 @@ typedef struct tsi_test_frame_protector_config tsi_test_frame_protector_config;
/* V-table for tsi_test_fixture operations that are implemented differently in
different TSI implementations. */
typedef struct tsi_test_fixture_vtable {
- void (*setup_handshakers)(tsi_test_fixture *fixture);
- void (*check_handshaker_peers)(tsi_test_fixture *fixture);
- void (*destruct)(tsi_test_fixture *fixture);
-} tranport_security_test_vtable;
+ void (*setup_handshakers)(tsi_test_fixture* fixture);
+ void (*check_handshaker_peers)(tsi_test_fixture* fixture);
+ void (*destruct)(tsi_test_fixture* fixture);
+} tsi_test_fixture_vtable;
struct tsi_test_fixture {
- const struct tsi_test_fixture_vtable *vtable;
+ const tsi_test_fixture_vtable* vtable;
/* client/server TSI handshaker used to perform TSI handshakes, and will get
instantiated during the call to setup_handshakers. */
- tsi_handshaker *client_handshaker;
- tsi_handshaker *server_handshaker;
+ tsi_handshaker* client_handshaker;
+ tsi_handshaker* server_handshaker;
/* client/server TSI handshaker results used to store the result of TSI
handshake. If the handshake fails, the result will store NULL upon
finishing the handshake. */
- tsi_handshaker_result *client_result;
- tsi_handshaker_result *server_result;
+ tsi_handshaker_result* client_result;
+ tsi_handshaker_result* server_result;
/* size of buffer used to store data received from the peer. */
size_t handshake_buffer_size;
/* simulated channels between client and server. If the server (client)
wants to send data to the client (server), he will write data to
client_channel (server_channel), which will be read by client (server). */
- uint8_t *client_channel;
- uint8_t *server_channel;
+ uint8_t* client_channel;
+ uint8_t* server_channel;
/* size of data written to the client/server channel. */
size_t bytes_written_to_client_channel;
size_t bytes_written_to_server_channel;
@@ -83,7 +85,7 @@ struct tsi_test_fixture {
size_t bytes_read_from_client_channel;
size_t bytes_read_from_server_channel;
/* tsi_test_frame_protector_config instance */
- tsi_test_frame_protector_config *config;
+ tsi_test_frame_protector_config* config;
/* a flag indicating if client has finished TSI handshake first (i.e., before
server).
The flag should be referred if and only if TSI handshake finishes
@@ -95,6 +97,13 @@ struct tsi_test_fixture {
(https://github.com/grpc/grpc/issues/12164).
*/
bool test_unused_bytes;
+ /* These objects will be used coordinate client/server handshakers with TSI
+ thread to perform TSI handshakes in an asynchronous manner (for GTS TSI
+ implementations).
+ */
+ gpr_cv cv;
+ gpr_mu mu;
+ bool notified;
};
struct tsi_test_frame_protector_config {
@@ -108,8 +117,8 @@ struct tsi_test_frame_protector_config {
size_t client_max_output_protected_frame_size;
size_t server_max_output_protected_frame_size;
/* pointer that points to client/server message to be protected. */
- uint8_t *client_message;
- uint8_t *server_message;
+ uint8_t* client_message;
+ uint8_t* server_message;
/* size of client/server message. */
size_t client_message_size;
size_t server_message_size;
@@ -120,7 +129,7 @@ struct tsi_test_frame_protector_config {
corresponding parameter with a default value or not. If it's false, it will
be set with a specific value which is usually much smaller than the default.
Both values are defined with #define directive. */
-tsi_test_frame_protector_config *tsi_test_frame_protector_config_create(
+tsi_test_frame_protector_config* tsi_test_frame_protector_config_create(
bool use_default_read_buffer_allocated_size,
bool use_default_message_buffer_allocated_size,
bool use_default_protected_buffer_size, bool use_default_client_message,
@@ -132,34 +141,34 @@ tsi_test_frame_protector_config *tsi_test_frame_protector_config_create(
/* This method sets different buffer and frame sizes of a
tsi_test_frame_protector_config instance with user provided values. */
void tsi_test_frame_protector_config_set_buffer_size(
- tsi_test_frame_protector_config *config, size_t read_buffer_allocated_size,
+ tsi_test_frame_protector_config* config, size_t read_buffer_allocated_size,
size_t message_buffer_allocated_size, size_t protected_buffer_size,
size_t client_max_output_protected_frame_size,
size_t server_max_output_protected_frame_size);
/* This method destroys a tsi_test_frame_protector_config instance. */
void tsi_test_frame_protector_config_destroy(
- tsi_test_frame_protector_config *config);
+ tsi_test_frame_protector_config* config);
/* This method initializes members of tsi_test_fixture instance.
Note that the struct instance should be allocated before making
this call. */
-void tsi_test_fixture_init(tsi_test_fixture *fixture);
+void tsi_test_fixture_init(tsi_test_fixture* fixture);
/* This method destroys a tsi_test_fixture instance. Note that the
fixture intance must be dynamically allocated and will be freed by
this function. */
-void tsi_test_fixture_destroy(tsi_test_fixture *fixture);
+void tsi_test_fixture_destroy(tsi_test_fixture* fixture);
/* This method performs a full TSI handshake between a client and a server.
Note that the test library will implement the new TSI handshaker API to
perform handshakes. */
-void tsi_test_do_handshake(tsi_test_fixture *fixture);
+void tsi_test_do_handshake(tsi_test_fixture* fixture);
/* This method performs a round trip test between the client and the server.
That is, the client sends a protected message to a server who receives the
message, and unprotects it. The same operation is triggered again with
the client and server switching its role. */
-void tsi_test_do_round_trip(tsi_test_fixture *fixture);
+void tsi_test_do_round_trip(tsi_test_fixture* fixture);
#endif // GRPC_TEST_CORE_TSI_TRANSPORT_SECURITY_TEST_LIB_H_
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
index 10eefe159a..2237cfc173 100644
--- a/test/core/util/BUILD
+++ b/test/core/util/BUILD
@@ -16,13 +16,16 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_c
licenses(["notice"]) # Apache v2
-grpc_package(name = "test/core/util", visibility = "public")
+grpc_package(
+ name = "test/core/util",
+ visibility = "public",
+)
grpc_cc_library(
name = "gpr_test_util",
srcs = [
- "memory_counters.c",
- "test_config.c",
+ "memory_counters.cc",
+ "test_config.cc",
],
hdrs = [
"memory_counters.h",
@@ -32,23 +35,39 @@ grpc_cc_library(
)
grpc_cc_library(
- name = "grpc_test_util_base",
+ name = "grpc_debugger_macros",
srcs = [
- "debugger_macros.c",
- "grpc_profiler.c",
- "mock_endpoint.c",
- "parse_hexstring.c",
- "passthru_endpoint.c",
- "port.c",
- "port_server_client.c",
- "reconnect_server.c",
- "slice_splitter.c",
- "test_tcp_server.c",
- "trickle_endpoint.c",
+ "debugger_macros.cc",
],
hdrs = [
"debugger_macros.h",
+ ],
+ deps = [
+ ":gpr_test_util",
+ "//:grpc_common",
+ ],
+)
+
+grpc_cc_library(
+ name = "grpc_test_util_base",
+ srcs = [
+ "grpc_profiler.cc",
+ "histogram.cc",
+ "mock_endpoint.cc",
+ "parse_hexstring.cc",
+ "passthru_endpoint.cc",
+ "port.cc",
+ "port_isolated_runtime_environment.cc",
+ "port_server_client.cc",
+ "reconnect_server.cc",
+ "slice_splitter.cc",
+ "test_tcp_server.cc",
+ "tracer_util.cc",
+ "trickle_endpoint.cc",
+ ],
+ hdrs = [
"grpc_profiler.h",
+ "histogram.h",
"mock_endpoint.h",
"parse_hexstring.h",
"passthru_endpoint.h",
@@ -57,11 +76,13 @@ grpc_cc_library(
"reconnect_server.h",
"slice_splitter.h",
"test_tcp_server.h",
+ "tracer_util.h",
"trickle_endpoint.h",
],
- language = "C",
+ language = "C++",
deps = [
":gpr_test_util",
+ ":grpc_debugger_macros",
"//:grpc_common",
],
)
@@ -70,7 +91,7 @@ grpc_cc_library(
name = "grpc_test_util",
srcs = [],
hdrs = [],
- language = "C",
+ language = "C++",
deps = [
":grpc_test_util_base",
"//:grpc",
@@ -81,7 +102,7 @@ grpc_cc_library(
name = "grpc_test_util_unsecure",
srcs = [],
hdrs = [],
- language = "C",
+ language = "C++",
deps = [
":grpc_test_util_base",
"//:grpc_unsecure",
@@ -89,15 +110,35 @@ grpc_cc_library(
)
grpc_cc_library(
- name = "one_corpus_entry_fuzzer",
- srcs = ["one_corpus_entry_fuzzer.c"],
+ name = "fuzzer_corpus_test",
+ testonly = 1,
+ srcs = ["fuzzer_corpus_test.cc"],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
deps = [
":gpr_test_util",
"//:grpc",
],
)
+grpc_cc_test(
+ name = "histogram_test",
+ srcs = ["histogram_test.cc"],
+ language = "C++",
+ deps = [
+ ":grpc_test_util",
+ "//:gpr",
+ ],
+)
+
sh_library(
name = "fuzzer_one_entry_runner",
srcs = ["fuzzer_one_entry_runner.sh"],
)
+
+sh_library(
+ name = "run_with_poller_sh",
+ srcs = ["run_with_poller.sh"],
+)
diff --git a/test/core/util/debugger_macros.c b/test/core/util/debugger_macros.cc
index ebe74f1fd6..bb96fc7054 100644
--- a/test/core/util/debugger_macros.c
+++ b/test/core/util/debugger_macros.cc
@@ -31,26 +31,28 @@
void grpc_summon_debugger_macros() {}
-grpc_stream *grpc_transport_stream_from_call(grpc_call *call) {
- grpc_call_stack *cs = grpc_call_get_call_stack(call);
+grpc_stream* grpc_transport_stream_from_call(grpc_call* call) {
+ grpc_call_stack* cs = grpc_call_get_call_stack(call);
for (;;) {
- grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1);
+ grpc_call_element* el = grpc_call_stack_element(cs, cs->count - 1);
if (el->filter == &grpc_client_channel_filter) {
- grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el);
- if (scc == NULL) {
+ grpc_subchannel_call* scc = grpc_client_channel_get_subchannel_call(el);
+ if (scc == nullptr) {
fprintf(stderr, "No subchannel-call");
- return NULL;
+ fflush(stderr);
+ return nullptr;
}
cs = grpc_subchannel_call_get_call_stack(scc);
} else if (el->filter == &grpc_connected_filter) {
return grpc_connected_channel_get_stream(el);
} else {
fprintf(stderr, "Unrecognized filter: %s", el->filter->name);
- return NULL;
+ fflush(stderr);
+ return nullptr;
}
}
}
-grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) {
- return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call);
+grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call) {
+ return (grpc_chttp2_stream*)grpc_transport_stream_from_call(call);
}
diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc
new file mode 100644
index 0000000000..7849321257
--- /dev/null
+++ b/test/core/util/fuzzer_corpus_test.cc
@@ -0,0 +1,143 @@
+/*
+ *
+ * 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 <stdbool.h>
+
+#include <dirent.h>
+#include <gflags/gflags.h>
+#include <grpc/support/log.h>
+#include <gtest/gtest.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "src/core/lib/iomgr/load_file.h"
+#include "test/core/util/test_config.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
+extern bool squelch;
+extern bool leak_check;
+
+// In some distros, gflags is in the namespace google, and in some others,
+// in gflags. This hack is enabling us to find both.
+namespace google {}
+namespace gflags {}
+using namespace google;
+using namespace gflags;
+
+DEFINE_string(file, "", "Use this file as test data");
+DEFINE_string(directory, "", "Use this directory as test data");
+
+class FuzzerCorpusTest : public ::testing::TestWithParam<std::string> {};
+
+TEST_P(FuzzerCorpusTest, RunOneExample) {
+ gpr_log(GPR_DEBUG, "Example file: %s", GetParam().c_str());
+ grpc_slice buffer;
+ squelch = false;
+ leak_check = false;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(GetParam().c_str(), 0, &buffer)));
+ LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer),
+ GRPC_SLICE_LENGTH(buffer));
+ grpc_slice_unref(buffer);
+}
+
+class ExampleGenerator
+ : public ::testing::internal::ParamGeneratorInterface<std::string> {
+ public:
+ virtual ::testing::internal::ParamIteratorInterface<std::string>* Begin()
+ const;
+ virtual ::testing::internal::ParamIteratorInterface<std::string>* End() const;
+
+ private:
+ void Materialize() const {
+ if (examples_.empty()) {
+ if (!FLAGS_file.empty()) examples_.push_back(FLAGS_file);
+ if (!FLAGS_directory.empty()) {
+ DIR* dp;
+ struct dirent* ep;
+ dp = opendir(FLAGS_directory.c_str());
+
+ if (dp != nullptr) {
+ while ((ep = readdir(dp)) != nullptr) {
+ if (ep->d_type == DT_REG) {
+ examples_.push_back(FLAGS_directory + "/" + ep->d_name);
+ }
+ }
+
+ (void)closedir(dp);
+ } else {
+ perror("Couldn't open the directory");
+ abort();
+ }
+ }
+ }
+ }
+
+ mutable std::vector<std::string> examples_;
+};
+
+class ExampleIterator
+ : public ::testing::internal::ParamIteratorInterface<std::string> {
+ public:
+ ExampleIterator(const ExampleGenerator& base_,
+ std::vector<std::string>::const_iterator begin)
+ : base_(base_), begin_(begin), current_(begin) {}
+
+ virtual const ExampleGenerator* BaseGenerator() const { return &base_; }
+
+ virtual void Advance() { current_++; }
+ virtual ExampleIterator* Clone() const { return new ExampleIterator(*this); }
+ virtual const std::string* Current() const { return &*current_; }
+
+ virtual bool Equals(const ParamIteratorInterface<std::string>& other) const {
+ return &base_ == other.BaseGenerator() &&
+ current_ == dynamic_cast<const ExampleIterator*>(&other)->current_;
+ }
+
+ private:
+ ExampleIterator(const ExampleIterator& other)
+ : base_(other.base_), begin_(other.begin_), current_(other.current_) {}
+
+ const ExampleGenerator& base_;
+ const std::vector<std::string>::const_iterator begin_;
+ std::vector<std::string>::const_iterator current_;
+};
+
+::testing::internal::ParamIteratorInterface<std::string>*
+ExampleGenerator::Begin() const {
+ Materialize();
+ return new ExampleIterator(*this, examples_.begin());
+}
+
+::testing::internal::ParamIteratorInterface<std::string>*
+ExampleGenerator::End() const {
+ Materialize();
+ return new ExampleIterator(*this, examples_.end());
+}
+
+INSTANTIATE_TEST_CASE_P(
+ CorpusExamples, FuzzerCorpusTest,
+ ::testing::internal::ParamGenerator<std::string>(new ExampleGenerator));
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ParseCommandLineFlags(&argc, &argv, true);
+ ::testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/util/grpc_fuzzer.bzl b/test/core/util/grpc_fuzzer.bzl
index 41f6cdc8ba..b8b270ecd0 100644
--- a/test/core/util/grpc_fuzzer.bzl
+++ b/test/core/util/grpc_fuzzer.bzl
@@ -12,19 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//bazel:grpc_build_system.bzl", "grpc_cc_binary")
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
def grpc_fuzzer(name, corpus, srcs = [], deps = [], **kwargs):
- grpc_cc_binary(
- name = '%s/one_entry.bin' % name,
+ grpc_cc_test(
+ name = name,
srcs = srcs,
- deps = deps + ["//test/core/util:one_corpus_entry_fuzzer"],
+ deps = deps + ["//test/core/util:fuzzer_corpus_test"],
+ data = native.glob([corpus + "/**"]),
+ external_deps = [
+ 'gtest',
+ ],
**kwargs
)
- for entry in native.glob(['%s/*' % corpus]):
- native.sh_test(
- name = '%s/one_entry/%s' % (name, entry),
- data = [':%s/one_entry.bin' % name, entry],
- srcs = ['//test/core/util:fuzzer_one_entry_runner'],
- args = ['$(location :%s/one_entry.bin)' % name, '$(location %s)' % entry]
- )
diff --git a/test/core/util/grpc_profiler.c b/test/core/util/grpc_profiler.cc
index 47b0270e29..88f233598b 100644
--- a/test/core/util/grpc_profiler.c
+++ b/test/core/util/grpc_profiler.cc
@@ -21,13 +21,13 @@
#if GRPC_HAVE_PERFTOOLS
#include <gperftools/profiler.h>
-void grpc_profiler_start(const char *filename) { ProfilerStart(filename); }
+void grpc_profiler_start(const char* filename) { ProfilerStart(filename); }
void grpc_profiler_stop() { ProfilerStop(); }
#else
#include <grpc/support/log.h>
-void grpc_profiler_start(const char *filename) {
+void grpc_profiler_start(const char* filename) {
static int printed_warning = 0;
if (!printed_warning) {
gpr_log(GPR_DEBUG,
diff --git a/test/core/util/grpc_profiler.h b/test/core/util/grpc_profiler.h
index 8809f55207..f9ddd2242e 100644
--- a/test/core/util/grpc_profiler.h
+++ b/test/core/util/grpc_profiler.h
@@ -19,15 +19,7 @@
#ifndef GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H
#define GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-void grpc_profiler_start(const char *filename);
+void grpc_profiler_start(const char* filename);
void grpc_profiler_stop();
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
#endif /* GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H */
diff --git a/src/core/lib/support/histogram.c b/test/core/util/histogram.cc
index 6d5ead9aa6..2f916f831d 100644
--- a/src/core/lib/support/histogram.c
+++ b/test/core/util/histogram.cc
@@ -16,8 +16,6 @@
*
*/
-#include <grpc/support/histogram.h>
-
#include <math.h>
#include <stddef.h>
#include <string.h>
@@ -27,12 +25,14 @@
#include <grpc/support/port_platform.h>
#include <grpc/support/useful.h>
+#include "test/core/util/histogram.h"
+
/* Histograms are stored with exponentially increasing bucket sizes.
The first bucket is [0, m) where m = 1 + resolution
Bucket n (n>=1) contains [m**n, m**(n+1))
There are sufficient buckets to reach max_bucket_start */
-struct gpr_histogram {
+struct grpc_histogram {
/* Sum of all values seen so far */
double sum;
/* Sum of squares of all values seen so far */
@@ -51,29 +51,29 @@ struct gpr_histogram {
/* number of buckets */
size_t num_buckets;
/* the buckets themselves */
- uint32_t *buckets;
+ uint32_t* buckets;
};
/* determine a bucket index given a value - does no bounds checking */
-static size_t bucket_for_unchecked(gpr_histogram *h, double x) {
+static size_t bucket_for_unchecked(grpc_histogram* h, double x) {
return (size_t)(log(x) * h->one_on_log_multiplier);
}
/* bounds checked version of the above */
-static size_t bucket_for(gpr_histogram *h, double x) {
+static size_t bucket_for(grpc_histogram* h, double x) {
size_t bucket = bucket_for_unchecked(h, GPR_CLAMP(x, 1.0, h->max_possible));
GPR_ASSERT(bucket < h->num_buckets);
return bucket;
}
/* at what value does a bucket start? */
-static double bucket_start(gpr_histogram *h, double x) {
+static double bucket_start(grpc_histogram* h, double x) {
return pow(h->multiplier, x);
}
-gpr_histogram *gpr_histogram_create(double resolution,
- double max_bucket_start) {
- gpr_histogram *h = (gpr_histogram *)gpr_malloc(sizeof(gpr_histogram));
+grpc_histogram* grpc_histogram_create(double resolution,
+ double max_bucket_start) {
+ grpc_histogram* h = (grpc_histogram*)gpr_malloc(sizeof(grpc_histogram));
GPR_ASSERT(resolution > 0.0);
GPR_ASSERT(max_bucket_start > resolution);
h->sum = 0.0;
@@ -87,16 +87,16 @@ gpr_histogram *gpr_histogram_create(double resolution,
h->num_buckets = bucket_for_unchecked(h, max_bucket_start) + 1;
GPR_ASSERT(h->num_buckets > 1);
GPR_ASSERT(h->num_buckets < 100000000);
- h->buckets = (uint32_t *)gpr_zalloc(sizeof(uint32_t) * h->num_buckets);
+ h->buckets = (uint32_t*)gpr_zalloc(sizeof(uint32_t) * h->num_buckets);
return h;
}
-void gpr_histogram_destroy(gpr_histogram *h) {
+void grpc_histogram_destroy(grpc_histogram* h) {
gpr_free(h->buckets);
gpr_free(h);
}
-void gpr_histogram_add(gpr_histogram *h, double x) {
+void grpc_histogram_add(grpc_histogram* h, double x) {
h->sum += x;
h->sum_of_squares += x * x;
h->count++;
@@ -109,22 +109,22 @@ void gpr_histogram_add(gpr_histogram *h, double x) {
h->buckets[bucket_for(h, x)]++;
}
-int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src) {
+int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src) {
if ((dst->num_buckets != src->num_buckets) ||
(dst->multiplier != src->multiplier)) {
/* Fail because these histograms don't match */
return 0;
}
- gpr_histogram_merge_contents(dst, src->buckets, src->num_buckets,
- src->min_seen, src->max_seen, src->sum,
- src->sum_of_squares, src->count);
+ grpc_histogram_merge_contents(dst, src->buckets, src->num_buckets,
+ src->min_seen, src->max_seen, src->sum,
+ src->sum_of_squares, src->count);
return 1;
}
-void gpr_histogram_merge_contents(gpr_histogram *dst, const uint32_t *data,
- size_t data_count, double min_seen,
- double max_seen, double sum,
- double sum_of_squares, double count) {
+void grpc_histogram_merge_contents(grpc_histogram* dst, const uint32_t* data,
+ size_t data_count, double min_seen,
+ double max_seen, double sum,
+ double sum_of_squares, double count) {
size_t i;
GPR_ASSERT(dst->num_buckets == data_count);
dst->sum += sum;
@@ -141,7 +141,7 @@ void gpr_histogram_merge_contents(gpr_histogram *dst, const uint32_t *data,
}
}
-static double threshold_for_count_below(gpr_histogram *h, double count_below) {
+static double threshold_for_count_below(grpc_histogram* h, double count_below) {
double count_so_far;
double lower_bound;
double upper_bound;
@@ -183,46 +183,45 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) {
should lie */
lower_bound = bucket_start(h, (double)lower_idx);
upper_bound = bucket_start(h, (double)(lower_idx + 1));
- return GPR_CLAMP(upper_bound -
- (upper_bound - lower_bound) *
- (count_so_far - count_below) /
- h->buckets[lower_idx],
+ return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) *
+ (count_so_far - count_below) /
+ h->buckets[lower_idx],
h->min_seen, h->max_seen);
}
}
-double gpr_histogram_percentile(gpr_histogram *h, double percentile) {
+double grpc_histogram_percentile(grpc_histogram* h, double percentile) {
return threshold_for_count_below(h, h->count * percentile / 100.0);
}
-double gpr_histogram_mean(gpr_histogram *h) {
+double grpc_histogram_mean(grpc_histogram* h) {
GPR_ASSERT(h->count != 0);
return h->sum / h->count;
}
-double gpr_histogram_stddev(gpr_histogram *h) {
- return sqrt(gpr_histogram_variance(h));
+double grpc_histogram_stddev(grpc_histogram* h) {
+ return sqrt(grpc_histogram_variance(h));
}
-double gpr_histogram_variance(gpr_histogram *h) {
+double grpc_histogram_variance(grpc_histogram* h) {
if (h->count == 0) return 0.0;
return (h->sum_of_squares * h->count - h->sum * h->sum) /
(h->count * h->count);
}
-double gpr_histogram_maximum(gpr_histogram *h) { return h->max_seen; }
+double grpc_histogram_maximum(grpc_histogram* h) { return h->max_seen; }
-double gpr_histogram_minimum(gpr_histogram *h) { return h->min_seen; }
+double grpc_histogram_minimum(grpc_histogram* h) { return h->min_seen; }
-double gpr_histogram_count(gpr_histogram *h) { return h->count; }
+double grpc_histogram_count(grpc_histogram* h) { return h->count; }
-double gpr_histogram_sum(gpr_histogram *h) { return h->sum; }
+double grpc_histogram_sum(grpc_histogram* h) { return h->sum; }
-double gpr_histogram_sum_of_squares(gpr_histogram *h) {
+double grpc_histogram_sum_of_squares(grpc_histogram* h) {
return h->sum_of_squares;
}
-const uint32_t *gpr_histogram_get_contents(gpr_histogram *h, size_t *size) {
+const uint32_t* grpc_histogram_get_contents(grpc_histogram* h, size_t* size) {
*size = h->num_buckets;
return h->buckets;
}
diff --git a/test/core/util/histogram.h b/test/core/util/histogram.h
new file mode 100644
index 0000000000..9d4985e64f
--- /dev/null
+++ b/test/core/util/histogram.h
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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_HISTOGRAM_H
+#define GRPC_SUPPORT_HISTOGRAM_H
+
+#include <grpc/support/port_platform.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct grpc_histogram grpc_histogram;
+
+grpc_histogram* grpc_histogram_create(double resolution,
+ double max_bucket_start);
+void grpc_histogram_destroy(grpc_histogram* h);
+void grpc_histogram_add(grpc_histogram* h, double x);
+
+/** The following merges the second histogram into the first. It only works
+ if they have the same buckets and resolution. Returns 0 on failure, 1
+ on success */
+int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src);
+
+double grpc_histogram_percentile(grpc_histogram* histogram, double percentile);
+double grpc_histogram_mean(grpc_histogram* histogram);
+double grpc_histogram_stddev(grpc_histogram* histogram);
+double grpc_histogram_variance(grpc_histogram* histogram);
+double grpc_histogram_maximum(grpc_histogram* histogram);
+double grpc_histogram_minimum(grpc_histogram* histogram);
+double grpc_histogram_count(grpc_histogram* histogram);
+double grpc_histogram_sum(grpc_histogram* histogram);
+double grpc_histogram_sum_of_squares(grpc_histogram* histogram);
+
+const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram,
+ size_t* count);
+void grpc_histogram_merge_contents(grpc_histogram* histogram,
+ const uint32_t* data, size_t data_count,
+ double min_seen, double max_seen, double sum,
+ double sum_of_squares, double count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRPC_SUPPORT_HISTOGRAM_H */
diff --git a/test/core/util/histogram_test.cc b/test/core/util/histogram_test.cc
new file mode 100644
index 0000000000..b96ac7d841
--- /dev/null
+++ b/test/core/util/histogram_test.cc
@@ -0,0 +1,163 @@
+/*
+ *
+ * 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/histogram.h"
+#include <grpc/support/log.h>
+
+#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x);
+
+static void test_no_op(void) {
+ grpc_histogram_destroy(grpc_histogram_create(0.01, 60e9));
+}
+
+static void expect_percentile(grpc_histogram* h, double percentile,
+ double min_expect, double max_expect) {
+ double got = grpc_histogram_percentile(h, percentile);
+ gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got,
+ max_expect);
+ GPR_ASSERT(min_expect <= got);
+ GPR_ASSERT(got <= max_expect);
+}
+
+static void test_simple(void) {
+ grpc_histogram* h;
+
+ LOG_TEST("test_simple");
+
+ h = grpc_histogram_create(0.01, 60e9);
+ grpc_histogram_add(h, 10000);
+ grpc_histogram_add(h, 10000);
+ grpc_histogram_add(h, 11000);
+ grpc_histogram_add(h, 11000);
+
+ expect_percentile(h, 50, 10001, 10999);
+ GPR_ASSERT(grpc_histogram_mean(h) == 10500);
+
+ grpc_histogram_destroy(h);
+}
+
+static void test_percentile(void) {
+ grpc_histogram* h;
+ double last;
+ double i;
+ double cur;
+
+ LOG_TEST("test_percentile");
+
+ h = grpc_histogram_create(0.05, 1e9);
+ grpc_histogram_add(h, 2.5);
+ grpc_histogram_add(h, 2.5);
+ grpc_histogram_add(h, 8);
+ grpc_histogram_add(h, 4);
+
+ GPR_ASSERT(grpc_histogram_count(h) == 4);
+ GPR_ASSERT(grpc_histogram_minimum(h) == 2.5);
+ GPR_ASSERT(grpc_histogram_maximum(h) == 8);
+ GPR_ASSERT(grpc_histogram_sum(h) == 17);
+ GPR_ASSERT(grpc_histogram_sum_of_squares(h) == 92.5);
+ GPR_ASSERT(grpc_histogram_mean(h) == 4.25);
+ GPR_ASSERT(grpc_histogram_variance(h) == 5.0625);
+ GPR_ASSERT(grpc_histogram_stddev(h) == 2.25);
+
+ expect_percentile(h, -10, 2.5, 2.5);
+ expect_percentile(h, 0, 2.5, 2.5);
+ expect_percentile(h, 12.5, 2.5, 2.5);
+ expect_percentile(h, 25, 2.5, 2.5);
+ expect_percentile(h, 37.5, 2.5, 2.8);
+ expect_percentile(h, 50, 3.0, 3.5);
+ expect_percentile(h, 62.5, 3.5, 4.5);
+ expect_percentile(h, 75, 5, 7.9);
+ expect_percentile(h, 100, 8, 8);
+ expect_percentile(h, 110, 8, 8);
+
+ /* test monotonicity */
+ last = 0.0;
+ for (i = 0; i < 100.0; i += 0.01) {
+ cur = grpc_histogram_percentile(h, i);
+ GPR_ASSERT(cur >= last);
+ last = cur;
+ }
+
+ grpc_histogram_destroy(h);
+}
+
+static void test_merge(void) {
+ grpc_histogram *h1, *h2;
+ double last;
+ double i;
+ double cur;
+
+ LOG_TEST("test_merge");
+
+ h1 = grpc_histogram_create(0.05, 1e9);
+ grpc_histogram_add(h1, 2.5);
+ grpc_histogram_add(h1, 2.5);
+ grpc_histogram_add(h1, 8);
+ grpc_histogram_add(h1, 4);
+
+ h2 = grpc_histogram_create(0.01, 1e9);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 0);
+ grpc_histogram_destroy(h2);
+
+ h2 = grpc_histogram_create(0.05, 1e10);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 0);
+ grpc_histogram_destroy(h2);
+
+ h2 = grpc_histogram_create(0.05, 1e9);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 1);
+ GPR_ASSERT(grpc_histogram_count(h1) == 4);
+ GPR_ASSERT(grpc_histogram_minimum(h1) == 2.5);
+ GPR_ASSERT(grpc_histogram_maximum(h1) == 8);
+ GPR_ASSERT(grpc_histogram_sum(h1) == 17);
+ GPR_ASSERT(grpc_histogram_sum_of_squares(h1) == 92.5);
+ GPR_ASSERT(grpc_histogram_mean(h1) == 4.25);
+ GPR_ASSERT(grpc_histogram_variance(h1) == 5.0625);
+ GPR_ASSERT(grpc_histogram_stddev(h1) == 2.25);
+ grpc_histogram_destroy(h2);
+
+ h2 = grpc_histogram_create(0.05, 1e9);
+ grpc_histogram_add(h2, 7.0);
+ grpc_histogram_add(h2, 17.0);
+ grpc_histogram_add(h2, 1.0);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 1);
+ GPR_ASSERT(grpc_histogram_count(h1) == 7);
+ GPR_ASSERT(grpc_histogram_minimum(h1) == 1.0);
+ GPR_ASSERT(grpc_histogram_maximum(h1) == 17.0);
+ GPR_ASSERT(grpc_histogram_sum(h1) == 42.0);
+ GPR_ASSERT(grpc_histogram_sum_of_squares(h1) == 431.5);
+ GPR_ASSERT(grpc_histogram_mean(h1) == 6.0);
+
+ /* test monotonicity */
+ last = 0.0;
+ for (i = 0; i < 100.0; i += 0.01) {
+ cur = grpc_histogram_percentile(h1, i);
+ GPR_ASSERT(cur >= last);
+ last = cur;
+ }
+
+ grpc_histogram_destroy(h1);
+ grpc_histogram_destroy(h2);
+}
+
+int main(void) {
+ test_no_op();
+ test_simple();
+ test_percentile();
+ test_merge();
+ return 0;
+}
diff --git a/test/core/util/memory_counters.c b/test/core/util/memory_counters.cc
index 9fb3ffe095..32d7b89c9a 100644
--- a/test/core/util/memory_counters.c
+++ b/test/core/util/memory_counters.cc
@@ -27,9 +27,9 @@
static struct grpc_memory_counters g_memory_counters;
static gpr_allocation_functions g_old_allocs;
-static void *guard_malloc(size_t size);
-static void *guard_realloc(void *vptr, size_t size);
-static void guard_free(void *vptr);
+static void* guard_malloc(size_t size);
+static void* guard_realloc(void* vptr, size_t size);
+static void guard_free(void* vptr);
#ifdef GPR_LOW_LEVEL_COUNTERS
/* hide these from the microbenchmark atomic stats */
@@ -41,39 +41,39 @@ static void guard_free(void *vptr);
#define NO_BARRIER_LOAD(x) gpr_atm_no_barrier_load(x)
#endif
-static void *guard_malloc(size_t size) {
- size_t *ptr;
- if (!size) return NULL;
+static void* guard_malloc(size_t size) {
+ size_t* ptr;
+ if (!size) return nullptr;
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1);
- ptr = (size_t *)g_old_allocs.malloc_fn(size + sizeof(size));
+ ptr = (size_t*)g_old_allocs.malloc_fn(size + sizeof(size));
*ptr++ = size;
return ptr;
}
-static void *guard_realloc(void *vptr, size_t size) {
- size_t *ptr = (size_t *)vptr;
- if (vptr == NULL) {
+static void* guard_realloc(void* vptr, size_t size) {
+ size_t* ptr = (size_t*)vptr;
+ if (vptr == nullptr) {
return guard_malloc(size);
}
if (size == 0) {
guard_free(vptr);
- return NULL;
+ return nullptr;
}
--ptr;
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1);
- ptr = (size_t *)g_old_allocs.realloc_fn(ptr, size + sizeof(size));
+ ptr = (size_t*)g_old_allocs.realloc_fn(ptr, size + sizeof(size));
*ptr++ = size;
return ptr;
}
-static void guard_free(void *vptr) {
- size_t *ptr = (size_t *)vptr;
+static void guard_free(void* vptr) {
+ size_t* ptr = (size_t*)vptr;
if (!vptr) return;
--ptr;
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr);
@@ -81,7 +81,7 @@ static void guard_free(void *vptr) {
g_old_allocs.free_fn(ptr);
}
-struct gpr_allocation_functions g_guard_allocs = {guard_malloc, NULL,
+struct gpr_allocation_functions g_guard_allocs = {guard_malloc, nullptr,
guard_realloc, guard_free};
void grpc_memory_counters_init() {
diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.cc
index bd386b2148..4b35a581b1 100644
--- a/test/core/util/mock_endpoint.c
+++ b/test/core/util/mock_endpoint.cc
@@ -35,18 +35,18 @@ typedef struct grpc_mock_endpoint {
gpr_mu mu;
void (*on_write)(grpc_slice slice);
grpc_slice_buffer read_buffer;
- grpc_slice_buffer *on_read_out;
- grpc_closure *on_read;
- grpc_resource_user *resource_user;
+ grpc_slice_buffer* on_read_out;
+ grpc_closure* on_read;
+ grpc_resource_user* resource_user;
} grpc_mock_endpoint;
-static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
+static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -54,83 +54,90 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_mu_unlock(&m->mu);
}
-static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
+static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
}
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
-static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset) {}
+static void me_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
-static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset) {}
+static void me_add_to_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {}
-static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
+static void me_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {}
+
+static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->on_read) {
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read,
+ GRPC_CLOSURE_SCHED(m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint Shutdown", &why, 1));
- m->on_read = NULL;
+ m->on_read = nullptr;
}
gpr_mu_unlock(&m->mu);
- grpc_resource_user_shutdown(exec_ctx, m->resource_user);
+ grpc_resource_user_shutdown(m->resource_user);
GRPC_ERROR_UNREF(why);
}
-static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
+static void me_destroy(grpc_endpoint* ep) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
grpc_slice_buffer_destroy(&m->read_buffer);
- grpc_resource_user_unref(exec_ctx, m->resource_user);
+ grpc_resource_user_unref(m->resource_user);
gpr_free(m);
}
-static char *me_get_peer(grpc_endpoint *ep) {
+static char* me_get_peer(grpc_endpoint* ep) {
return gpr_strdup("fake:mock_endpoint");
}
-static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
+static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
return m->resource_user;
}
-static int me_get_fd(grpc_endpoint *ep) { return -1; }
+static int me_get_fd(grpc_endpoint* ep) { return -1; }
static const grpc_endpoint_vtable vtable = {
- me_read, me_write, me_add_to_pollset, me_add_to_pollset_set,
- me_shutdown, me_destroy, me_get_resource_user, me_get_peer,
+ me_read,
+ me_write,
+ me_add_to_pollset,
+ me_add_to_pollset_set,
+ me_delete_from_pollset_set,
+ me_shutdown,
+ me_destroy,
+ me_get_resource_user,
+ me_get_peer,
me_get_fd,
};
-grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
- grpc_resource_quota *resource_quota) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)gpr_malloc(sizeof(*m));
+grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
+ grpc_resource_quota* resource_quota) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)gpr_malloc(sizeof(*m));
m->base.vtable = &vtable;
- char *name;
+ char* name;
gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m);
m->resource_user = grpc_resource_user_create(resource_quota, name);
gpr_free(name);
grpc_slice_buffer_init(&m->read_buffer);
gpr_mu_init(&m->mu);
m->on_write = on_write;
- m->on_read = NULL;
+ m->on_read = nullptr;
return &m->base;
}
-void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice slice) {
- grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
+void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) {
+ grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
- if (m->on_read != NULL) {
+ if (m->on_read != nullptr) {
grpc_slice_buffer_add(m->on_read_out, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, GRPC_ERROR_NONE);
- m->on_read = NULL;
+ GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE);
+ m->on_read = nullptr;
} else {
grpc_slice_buffer_add(&m->read_buffer, slice);
}
diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h
index 73b08dca31..6521d3e8e8 100644
--- a/test/core/util/mock_endpoint.h
+++ b/test/core/util/mock_endpoint.h
@@ -21,10 +21,9 @@
#include "src/core/lib/iomgr/endpoint.h"
-grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
- grpc_resource_quota *resource_quota);
-void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *mock_endpoint,
+grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
+ grpc_resource_quota* resource_quota);
+void grpc_mock_endpoint_put_read(grpc_endpoint* mock_endpoint,
grpc_slice slice);
#endif
diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.cc
index 42467390f2..c745eb5dc6 100644
--- a/test/core/util/one_corpus_entry_fuzzer.c
+++ b/test/core/util/one_corpus_entry_fuzzer.cc
@@ -18,22 +18,30 @@
#include <stdbool.h>
+#include <grpc/grpc.h>
+
#include <grpc/support/log.h>
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/load_file.h"
-extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
extern bool squelch;
extern bool leak_check;
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_slice buffer;
squelch = false;
leak_check = false;
+ /* TODO(yashkt) Calling grpc_init breaks tests. Fix the tests and replace
+ * grpc_core::ExecCtx::GlobalInit with grpc_init and GlobalShutdown with
+ * grpc_shutdown */
GPR_ASSERT(
GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer)));
LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer),
GRPC_SLICE_LENGTH(buffer));
+ grpc_core::ExecCtx::GlobalInit();
grpc_slice_unref(buffer);
+ grpc_core::ExecCtx::GlobalShutdown();
return 0;
}
diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.cc
index 346b871b67..622642a298 100644
--- a/test/core/util/parse_hexstring.c
+++ b/test/core/util/parse_hexstring.cc
@@ -19,10 +19,10 @@
#include "test/core/util/parse_hexstring.h"
#include <grpc/support/log.h>
-grpc_slice parse_hexstring(const char *hexstring) {
+grpc_slice parse_hexstring(const char* hexstring) {
size_t nibbles = 0;
- const char *p = 0;
- uint8_t *out;
+ const char* p = nullptr;
+ uint8_t* out;
uint8_t temp;
grpc_slice slice;
diff --git a/test/core/util/parse_hexstring.h b/test/core/util/parse_hexstring.h
index deab747dd1..b7d54c1711 100644
--- a/test/core/util/parse_hexstring.h
+++ b/test/core/util/parse_hexstring.h
@@ -21,6 +21,6 @@
#include <grpc/slice.h>
-grpc_slice parse_hexstring(const char *hexstring);
+grpc_slice parse_hexstring(const char* hexstring);
#endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */
diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.cc
index 38a47584d5..5f127cb960 100644
--- a/test/core/util/passthru_endpoint.c
+++ b/test/core/util/passthru_endpoint.cc
@@ -37,34 +37,34 @@ typedef struct passthru_endpoint passthru_endpoint;
typedef struct {
grpc_endpoint base;
- passthru_endpoint *parent;
+ passthru_endpoint* parent;
grpc_slice_buffer read_buffer;
- grpc_slice_buffer *on_read_out;
- grpc_closure *on_read;
- grpc_resource_user *resource_user;
+ grpc_slice_buffer* on_read_out;
+ grpc_closure* on_read;
+ grpc_resource_user* resource_user;
} half;
struct passthru_endpoint {
gpr_mu mu;
int halves;
- grpc_passthru_endpoint_stats *stats;
+ grpc_passthru_endpoint_stats* stats;
grpc_passthru_endpoint_stats
- dummy_stats; // used if constructor stats == NULL
+ dummy_stats; // used if constructor stats == nullptr
bool shutdown;
half client;
half server;
};
-static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- half *m = (half *)ep;
+static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ half* m = (half*)ep;
gpr_mu_lock(&m->parent->mu);
if (m->parent->shutdown) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
+ cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
} else if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -72,25 +72,25 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_mu_unlock(&m->parent->mu);
}
-static half *other_half(half *h) {
+static half* other_half(half* h) {
if (h == &h->parent->client) return &h->parent->server;
return &h->parent->client;
}
-static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- half *m = other_half((half *)ep);
+static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ half* m = other_half((half*)ep);
gpr_mu_lock(&m->parent->mu);
- grpc_error *error = GRPC_ERROR_NONE;
- m->parent->stats->num_writes++;
+ grpc_error* error = GRPC_ERROR_NONE;
+ gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1);
if (m->parent->shutdown) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
- } else if (m->on_read != NULL) {
+ } else if (m->on_read != nullptr) {
for (size_t i = 0; i < slices->count; i++) {
grpc_slice_buffer_add(m->on_read_out, grpc_slice_copy(slices->slices[i]));
}
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, GRPC_ERROR_NONE);
- m->on_read = NULL;
+ GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE);
+ m->on_read = nullptr;
} else {
for (size_t i = 0; i < slices->count; i++) {
grpc_slice_buffer_add(&m->read_buffer,
@@ -98,95 +98,103 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
}
}
gpr_mu_unlock(&m->parent->mu);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset) {}
+static void me_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
-static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset) {}
+static void me_add_to_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {}
-static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- half *m = (half *)ep;
+static void me_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {}
+
+static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ half* m = (half*)ep;
gpr_mu_lock(&m->parent->mu);
m->parent->shutdown = true;
if (m->on_read) {
GRPC_CLOSURE_SCHED(
- exec_ctx, m->on_read,
+ m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
- m->on_read = NULL;
+ m->on_read = nullptr;
}
m = other_half(m);
if (m->on_read) {
GRPC_CLOSURE_SCHED(
- exec_ctx, m->on_read,
+ m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
- m->on_read = NULL;
+ m->on_read = nullptr;
}
gpr_mu_unlock(&m->parent->mu);
- grpc_resource_user_shutdown(exec_ctx, m->resource_user);
+ grpc_resource_user_shutdown(m->resource_user);
GRPC_ERROR_UNREF(why);
}
-static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
- passthru_endpoint *p = ((half *)ep)->parent;
+static void me_destroy(grpc_endpoint* ep) {
+ passthru_endpoint* p = ((half*)ep)->parent;
gpr_mu_lock(&p->mu);
if (0 == --p->halves) {
gpr_mu_unlock(&p->mu);
gpr_mu_destroy(&p->mu);
- grpc_slice_buffer_destroy_internal(exec_ctx, &p->client.read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &p->server.read_buffer);
- grpc_resource_user_unref(exec_ctx, p->client.resource_user);
- grpc_resource_user_unref(exec_ctx, p->server.resource_user);
+ grpc_slice_buffer_destroy_internal(&p->client.read_buffer);
+ grpc_slice_buffer_destroy_internal(&p->server.read_buffer);
+ grpc_resource_user_unref(p->client.resource_user);
+ grpc_resource_user_unref(p->server.resource_user);
gpr_free(p);
} else {
gpr_mu_unlock(&p->mu);
}
}
-static char *me_get_peer(grpc_endpoint *ep) {
- passthru_endpoint *p = ((half *)ep)->parent;
- return ((half *)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint")
- : gpr_strdup("fake:mock_server_endpoint");
+static char* me_get_peer(grpc_endpoint* ep) {
+ passthru_endpoint* p = ((half*)ep)->parent;
+ return ((half*)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint")
+ : gpr_strdup("fake:mock_server_endpoint");
}
-static int me_get_fd(grpc_endpoint *ep) { return -1; }
+static int me_get_fd(grpc_endpoint* ep) { return -1; }
-static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) {
- half *m = (half *)ep;
+static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) {
+ half* m = (half*)ep;
return m->resource_user;
}
static const grpc_endpoint_vtable vtable = {
- me_read, me_write, me_add_to_pollset, me_add_to_pollset_set,
- me_shutdown, me_destroy, me_get_resource_user, me_get_peer,
+ me_read,
+ me_write,
+ me_add_to_pollset,
+ me_add_to_pollset_set,
+ me_delete_from_pollset_set,
+ me_shutdown,
+ me_destroy,
+ me_get_resource_user,
+ me_get_peer,
me_get_fd,
};
-static void half_init(half *m, passthru_endpoint *parent,
- grpc_resource_quota *resource_quota,
- const char *half_name) {
+static void half_init(half* m, passthru_endpoint* parent,
+ grpc_resource_quota* resource_quota,
+ const char* half_name) {
m->base.vtable = &vtable;
m->parent = parent;
grpc_slice_buffer_init(&m->read_buffer);
- m->on_read = NULL;
- char *name;
+ m->on_read = nullptr;
+ char* name;
gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name,
(intptr_t)parent);
m->resource_user = grpc_resource_user_create(resource_quota, name);
gpr_free(name);
}
-void grpc_passthru_endpoint_create(grpc_endpoint **client,
- grpc_endpoint **server,
- grpc_resource_quota *resource_quota,
- grpc_passthru_endpoint_stats *stats) {
- passthru_endpoint *m = (passthru_endpoint *)gpr_malloc(sizeof(*m));
+void grpc_passthru_endpoint_create(grpc_endpoint** client,
+ grpc_endpoint** server,
+ grpc_resource_quota* resource_quota,
+ grpc_passthru_endpoint_stats* stats) {
+ passthru_endpoint* m = (passthru_endpoint*)gpr_malloc(sizeof(*m));
m->halves = 2;
m->shutdown = 0;
- m->stats = stats == NULL ? &m->dummy_stats : stats;
+ m->stats = stats == nullptr ? &m->dummy_stats : stats;
memset(m->stats, 0, sizeof(*m->stats));
half_init(&m->client, m, resource_quota, "client");
half_init(&m->server, m, resource_quota, "server");
diff --git a/test/core/util/passthru_endpoint.h b/test/core/util/passthru_endpoint.h
index da769024a5..bddd8ea6a2 100644
--- a/test/core/util/passthru_endpoint.h
+++ b/test/core/util/passthru_endpoint.h
@@ -19,13 +19,17 @@
#ifndef MOCK_ENDPOINT_H
#define MOCK_ENDPOINT_H
+#include <grpc/support/atm.h>
+
#include "src/core/lib/iomgr/endpoint.h"
-typedef struct { int num_writes; } grpc_passthru_endpoint_stats;
+typedef struct {
+ gpr_atm num_writes;
+} grpc_passthru_endpoint_stats;
-void grpc_passthru_endpoint_create(grpc_endpoint **client,
- grpc_endpoint **server,
- grpc_resource_quota *resource_quota,
- grpc_passthru_endpoint_stats *stats);
+void grpc_passthru_endpoint_create(grpc_endpoint** client,
+ grpc_endpoint** server,
+ grpc_resource_quota* resource_quota,
+ grpc_passthru_endpoint_stats* stats);
#endif
diff --git a/test/core/util/port.c b/test/core/util/port.cc
index 61f2e5018f..9d02b673ed 100644
--- a/test/core/util/port.c
+++ b/test/core/util/port.cc
@@ -36,7 +36,7 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "test/core/util/port_server_client.h"
-static int *chosen_ports = NULL;
+static int* chosen_ports = nullptr;
static size_t num_chosen_ports = 0;
static int free_chosen_port(int port) {
@@ -71,12 +71,12 @@ static void free_chosen_ports(void) {
}
static void chose_port(int port) {
- if (chosen_ports == NULL) {
+ if (chosen_ports == nullptr) {
atexit(free_chosen_ports);
}
num_chosen_ports++;
chosen_ports =
- (int *)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports);
+ (int*)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports);
chosen_ports[num_chosen_ports - 1] = port;
}
@@ -123,9 +123,9 @@ void grpc_recycle_unused_port(int port) {
}
void grpc_set_pick_port_functions(grpc_pick_port_functions functions) {
- GPR_ASSERT(functions.pick_unused_port_fn != NULL);
- GPR_ASSERT(functions.pick_unused_port_or_die_fn != NULL);
- GPR_ASSERT(functions.recycle_unused_port_fn != NULL);
+ GPR_ASSERT(functions.pick_unused_port_fn != nullptr);
+ GPR_ASSERT(functions.pick_unused_port_or_die_fn != nullptr);
+ GPR_ASSERT(functions.recycle_unused_port_fn != nullptr);
g_pick_port_functions = functions;
}
diff --git a/test/core/util/port.h b/test/core/util/port.h
index 602099dea6..3a4cf4467a 100644
--- a/test/core/util/port.h
+++ b/test/core/util/port.h
@@ -19,10 +19,6 @@
#ifndef GRPC_TEST_CORE_UTIL_PORT_H
#define GRPC_TEST_CORE_UTIL_PORT_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_pick_port_functions {
int (*pick_unused_port_fn)(void);
int (*pick_unused_port_or_die_fn)(void);
@@ -45,8 +41,4 @@ void grpc_recycle_unused_port(int port);
/** Request the family of pick_port functions in \a functions be used. */
void grpc_set_pick_port_functions(grpc_pick_port_functions functions);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_TEST_CORE_UTIL_PORT_H */
diff --git a/test/core/util/port_isolated_runtime_environment.cc b/test/core/util/port_isolated_runtime_environment.cc
new file mode 100644
index 0000000000..5f0585e9fb
--- /dev/null
+++ b/test/core/util/port_isolated_runtime_environment.cc
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+/* When running tests on remote machines, the framework takes a round-robin pick
+ * of a port within certain range. There is no need to recycle ports.
+ */
+#include "src/core/lib/iomgr/port.h"
+#include "test/core/util/test_config.h"
+#if defined(GRPC_PORT_ISOLATED_RUNTIME)
+
+#include "test/core/util/port.h"
+
+#define LOWER_PORT 49152
+static int s_allocated_port = LOWER_PORT;
+
+int grpc_pick_unused_port_or_die(void) {
+ int allocated_port = s_allocated_port++;
+ if (s_allocated_port == 65536) {
+ s_allocated_port = LOWER_PORT;
+ }
+
+ return allocated_port;
+}
+
+void grpc_recycle_unused_port(int port) { (void)port; }
+
+#endif /* GRPC_PORT_ISOLATED_RUNTIME */
diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.cc
index ba4028dbee..7e76c8063f 100644
--- a/test/core/util/port_server_client.c
+++ b/test/core/util/port_server_client.cc
@@ -35,27 +35,24 @@
#include "src/core/lib/http/httpcli.h"
typedef struct freereq {
- gpr_mu *mu;
+ gpr_mu* mu;
grpc_polling_entity pops;
int done;
} freereq;
-static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset *pollset = grpc_polling_entity_pollset((grpc_polling_entity *)p);
- grpc_pollset_destroy(exec_ctx, pollset);
+static void destroy_pops_and_shutdown(void* p, grpc_error* error) {
+ grpc_pollset* pollset = grpc_polling_entity_pollset((grpc_polling_entity*)p);
+ grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
-static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- freereq *pr = (freereq *)arg;
+static void freed_port_from_server(void* arg, grpc_error* error) {
+ freereq* pr = (freereq*)arg;
gpr_mu_lock(pr->mu);
pr->done = 1;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- NULL));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -64,9 +61,9 @@ void grpc_free_port_using_server(int port) {
grpc_httpcli_request req;
grpc_httpcli_response rsp;
freereq pr;
- char *path;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_closure *shutdown_closure;
+ char* path;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_closure* shutdown_closure;
grpc_init();
@@ -74,43 +71,43 @@ void grpc_free_port_using_server(int port) {
memset(&req, 0, sizeof(req));
memset(&rsp, 0, sizeof(rsp));
- grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
grpc_schedule_on_exec_ctx);
- req.host = GRPC_PORT_SERVER_ADDRESS;
+ req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
gpr_asprintf(&path, "/drop/%d", port);
req.http.path = path;
grpc_httpcli_context_init(&context);
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/free");
- grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
- grpc_timeout_seconds_to_deadline(30),
+ grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(freed_port_from_server, &pr,
grpc_schedule_on_exec_ctx),
&rsp);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (!pr.done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- grpc_timeout_seconds_to_deadline(1)))) {
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.done = 1;
}
}
gpr_mu_unlock(pr.mu);
- grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(path);
grpc_http_response_destroy(&rsp);
@@ -118,26 +115,25 @@ void grpc_free_port_using_server(int port) {
}
typedef struct portreq {
- gpr_mu *mu;
+ gpr_mu* mu;
grpc_polling_entity pops;
int port;
int retries;
- char *server;
- grpc_httpcli_context *ctx;
+ char* server;
+ grpc_httpcli_context* ctx;
grpc_httpcli_response response;
} portreq;
-static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void got_port_from_server(void* arg, grpc_error* error) {
size_t i;
int port = 0;
- portreq *pr = (portreq *)arg;
+ portreq* pr = (portreq*)arg;
int failed = 0;
- grpc_httpcli_response *response = &pr->response;
+ grpc_httpcli_response* response = &pr->response;
if (error != GRPC_ERROR_NONE) {
failed = 1;
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", msg);
} else if (response->status != 200) {
@@ -154,8 +150,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
pr->port = 0;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- NULL));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
return;
}
@@ -167,17 +162,17 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
GPR_TIMESPAN)));
pr->retries++;
req.host = pr->server;
- req.http.path = "/get";
+ req.http.path = const_cast<char*>("/get");
grpc_http_response_destroy(&pr->response);
memset(&pr->response, 0, sizeof(pr->response));
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/pick_retry");
- grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req,
- grpc_timeout_seconds_to_deadline(10),
+ grpc_httpcli_get(pr->ctx, &pr->pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, pr,
grpc_schedule_on_exec_ctx),
&pr->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
return;
}
GPR_ASSERT(response);
@@ -191,8 +186,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
pr->port = port;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- NULL));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -200,53 +194,55 @@ int grpc_pick_port_using_server(void) {
grpc_httpcli_context context;
grpc_httpcli_request req;
portreq pr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_closure *shutdown_closure;
+ grpc_closure* shutdown_closure;
grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+ memset(&pr, 0, sizeof(pr));
+ memset(&req, 0, sizeof(req));
+ grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset_init(pollset, &pr.mu);
+ pr.pops = grpc_polling_entity_create_from_pollset(pollset);
+ shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
+ grpc_schedule_on_exec_ctx);
+ pr.port = -1;
+ pr.server = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
+ pr.ctx = &context;
+
+ req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
+ req.http.path = const_cast<char*>("/get");
+
+ grpc_httpcli_context_init(&context);
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("port_server_client/pick");
+ grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
+ GRPC_CLOSURE_CREATE(got_port_from_server, &pr,
+ grpc_schedule_on_exec_ctx),
+ &pr.response);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
+ gpr_mu_lock(pr.mu);
+ while (pr.port == -1) {
+ grpc_pollset_worker* worker = nullptr;
+ if (!GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
+ pr.port = 0;
+ }
+ }
+ gpr_mu_unlock(pr.mu);
- memset(&pr, 0, sizeof(pr));
- memset(&req, 0, sizeof(req));
- grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
- grpc_pollset_init(pollset, &pr.mu);
- pr.pops = grpc_polling_entity_create_from_pollset(pollset);
- shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
- grpc_schedule_on_exec_ctx);
- pr.port = -1;
- pr.server = GRPC_PORT_SERVER_ADDRESS;
- pr.ctx = &context;
-
- req.host = GRPC_PORT_SERVER_ADDRESS;
- req.http.path = "/get";
+ grpc_http_response_destroy(&pr.response);
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
+ shutdown_closure);
- grpc_httpcli_context_init(&context);
- grpc_resource_quota *resource_quota =
- grpc_resource_quota_create("port_server_client/pick");
- grpc_httpcli_get(
- &exec_ctx, &context, &pr.pops, resource_quota, &req,
- grpc_timeout_seconds_to_deadline(30),
- GRPC_CLOSURE_CREATE(got_port_from_server, &pr, grpc_schedule_on_exec_ctx),
- &pr.response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_flush(&exec_ctx);
- gpr_mu_lock(pr.mu);
- while (pr.port == -1) {
- grpc_pollset_worker *worker = NULL;
- if (!GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- &worker, gpr_now(GPR_CLOCK_MONOTONIC),
- grpc_timeout_seconds_to_deadline(1)))) {
- pr.port = 0;
- }
+ grpc_core::ExecCtx::Get()->Flush();
}
- gpr_mu_unlock(pr.mu);
-
- grpc_http_response_destroy(&pr.response);
- grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- shutdown_closure);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return pr.port;
diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.cc
index 9c56e02e8e..bcafc4e898 100644
--- a/test/core/util/reconnect_server.c
+++ b/test/core/util/reconnect_server.cc
@@ -31,11 +31,11 @@
#include "test/core/util/port.h"
#include "test/core/util/test_tcp_server.h"
-static void pretty_print_backoffs(reconnect_server *server) {
+static void pretty_print_backoffs(reconnect_server* server) {
gpr_timespec diff;
int i = 1;
double expected_backoff = 1000.0, backoff;
- timestamp_list *head = server->head;
+ timestamp_list* head = server->head;
gpr_log(GPR_INFO, "reconnect server: new connection");
for (head = server->head; head && head->next; head = head->next, i++) {
diff = gpr_time_sub(head->next->timestamp, head->timestamp);
@@ -55,25 +55,25 @@ static void pretty_print_backoffs(reconnect_server *server) {
}
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
+static void on_connect(void* arg, grpc_endpoint* tcp,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- char *peer;
- char *last_colon;
- reconnect_server *server = (reconnect_server *)arg;
+ char* peer;
+ char* last_colon;
+ reconnect_server* server = (reconnect_server*)arg;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
- timestamp_list *new_tail;
+ timestamp_list* new_tail;
peer = grpc_endpoint_get_peer(tcp);
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
if (peer) {
last_colon = strrchr(peer, ':');
- if (server->peer == NULL) {
+ if (server->peer == nullptr) {
server->peer = peer;
} else {
- if (last_colon == NULL) {
+ if (last_colon == nullptr) {
gpr_log(GPR_ERROR, "peer does not contain a ':'");
} else if (strncmp(server->peer, peer, (size_t)(last_colon - peer)) !=
0) {
@@ -82,10 +82,10 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_free(peer);
}
}
- new_tail = gpr_malloc(sizeof(timestamp_list));
+ new_tail = static_cast<timestamp_list*>(gpr_malloc(sizeof(timestamp_list)));
new_tail->timestamp = now;
- new_tail->next = NULL;
- if (server->tail == NULL) {
+ new_tail->next = nullptr;
+ if (server->tail == nullptr) {
server->head = new_tail;
server->tail = new_tail;
} else {
@@ -95,35 +95,35 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
pretty_print_backoffs(server);
}
-void reconnect_server_init(reconnect_server *server) {
+void reconnect_server_init(reconnect_server* server) {
test_tcp_server_init(&server->tcp_server, on_connect, server);
- server->head = NULL;
- server->tail = NULL;
- server->peer = NULL;
+ server->head = nullptr;
+ server->tail = nullptr;
+ server->peer = nullptr;
server->max_reconnect_backoff_ms = 0;
}
-void reconnect_server_start(reconnect_server *server, int port) {
+void reconnect_server_start(reconnect_server* server, int port) {
test_tcp_server_start(&server->tcp_server, port);
}
-void reconnect_server_poll(reconnect_server *server, int seconds) {
+void reconnect_server_poll(reconnect_server* server, int seconds) {
test_tcp_server_poll(&server->tcp_server, seconds);
}
-void reconnect_server_clear_timestamps(reconnect_server *server) {
- timestamp_list *new_head = server->head;
+void reconnect_server_clear_timestamps(reconnect_server* server) {
+ timestamp_list* new_head = server->head;
while (server->head) {
new_head = server->head->next;
gpr_free(server->head);
server->head = new_head;
}
- server->tail = NULL;
+ server->tail = nullptr;
gpr_free(server->peer);
- server->peer = NULL;
+ server->peer = nullptr;
}
-void reconnect_server_destroy(reconnect_server *server) {
+void reconnect_server_destroy(reconnect_server* server) {
reconnect_server_clear_timestamps(server);
test_tcp_server_destroy(&server->tcp_server);
}
diff --git a/test/core/util/reconnect_server.h b/test/core/util/reconnect_server.h
index 38db729108..d15abe529d 100644
--- a/test/core/util/reconnect_server.h
+++ b/test/core/util/reconnect_server.h
@@ -23,31 +23,23 @@
#include <grpc/support/time.h>
#include "test/core/util/test_tcp_server.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct timestamp_list {
gpr_timespec timestamp;
- struct timestamp_list *next;
+ struct timestamp_list* next;
} timestamp_list;
typedef struct reconnect_server {
test_tcp_server tcp_server;
- timestamp_list *head;
- timestamp_list *tail;
- char *peer;
+ timestamp_list* head;
+ timestamp_list* tail;
+ char* peer;
int max_reconnect_backoff_ms;
} reconnect_server;
-void reconnect_server_init(reconnect_server *server);
-void reconnect_server_start(reconnect_server *server, int port);
-void reconnect_server_poll(reconnect_server *server, int seconds);
-void reconnect_server_destroy(reconnect_server *server);
-void reconnect_server_clear_timestamps(reconnect_server *server);
-
-#ifdef __cplusplus
-}
-#endif
+void reconnect_server_init(reconnect_server* server);
+void reconnect_server_start(reconnect_server* server, int port);
+void reconnect_server_poll(reconnect_server* server, int seconds);
+void reconnect_server_destroy(reconnect_server* server);
+void reconnect_server_clear_timestamps(reconnect_server* server);
#endif /* GRPC_TEST_CORE_UTIL_RECONNECT_SERVER_H */
diff --git a/tools/run_tests/performance/run_worker_node.sh b/test/core/util/run_with_poller.sh
index 1286c831fb..05791457a2 100755
--- a/tools/run_tests/performance/run_worker_node.sh
+++ b/test/core/util/run_with_poller.sh
@@ -1,5 +1,5 @@
-#!/bin/bash
-# Copyright 2015 gRPC authors.
+#!/bin/sh
+# 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.
@@ -13,11 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-source ~/.nvm/nvm.sh
-nvm use 8
-
set -ex
-
-cd $(dirname $0)/../../..
-
-node src/node/performance/worker.js $@
+export GRPC_POLL_STRATEGY=$1
+shift
+$@
diff --git a/test/core/util/slice_splitter.c b/test/core/util/slice_splitter.cc
index 6fcef9acce..7225b6dc03 100644
--- a/test/core/util/slice_splitter.c
+++ b/test/core/util/slice_splitter.cc
@@ -23,7 +23,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/useful.h>
-const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) {
+const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode) {
switch (mode) {
case GRPC_SLICE_SPLIT_IDENTITY:
return "identity";
@@ -35,9 +35,9 @@ const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) {
return "error";
}
-void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
- size_t src_slice_count, grpc_slice **dst_slices,
- size_t *dst_slice_count) {
+void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices,
+ size_t src_slice_count, grpc_slice** dst_slices,
+ size_t* dst_slice_count) {
size_t i, j;
size_t length;
@@ -45,7 +45,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
case GRPC_SLICE_SPLIT_IDENTITY:
*dst_slice_count = src_slice_count;
*dst_slices =
- (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * src_slice_count);
+ (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * src_slice_count);
for (i = 0; i < src_slice_count; i++) {
(*dst_slices)[i] = src_slices[i];
grpc_slice_ref((*dst_slices)[i]);
@@ -57,7 +57,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
for (i = 0; i < src_slice_count; i++) {
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
- *dst_slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice));
+ *dst_slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice));
**dst_slices = grpc_slice_malloc(length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
@@ -73,7 +73,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
*dst_slice_count = length;
- *dst_slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * length);
+ *dst_slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) {
@@ -86,9 +86,9 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
}
void grpc_split_slices_to_buffer(grpc_slice_split_mode mode,
- grpc_slice *src_slices, size_t src_slice_count,
- grpc_slice_buffer *dst) {
- grpc_slice *slices;
+ grpc_slice* src_slices, size_t src_slice_count,
+ grpc_slice_buffer* dst) {
+ grpc_slice* slices;
size_t nslices;
size_t i;
grpc_split_slices(mode, src_slices, src_slice_count, &slices, &nslices);
@@ -99,13 +99,13 @@ void grpc_split_slices_to_buffer(grpc_slice_split_mode mode,
gpr_free(slices);
}
-void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer *src,
- grpc_slice_buffer *dst) {
+void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src,
+ grpc_slice_buffer* dst) {
grpc_split_slices_to_buffer(mode, src->slices, src->count, dst);
}
-grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) {
- uint8_t *out = NULL;
+grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) {
+ uint8_t* out = nullptr;
size_t length = 0;
size_t capacity = 0;
size_t i;
@@ -113,7 +113,7 @@ grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) {
for (i = 0; i < nslices; i++) {
if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) {
capacity = GPR_MAX(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length);
- out = (uint8_t *)gpr_realloc(out, capacity);
+ out = (uint8_t*)gpr_realloc(out, capacity);
}
memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]),
GRPC_SLICE_LENGTH(slices[i]));
diff --git a/test/core/util/slice_splitter.h b/test/core/util/slice_splitter.h
index 713eca93d2..65b9f6f7df 100644
--- a/test/core/util/slice_splitter.h
+++ b/test/core/util/slice_splitter.h
@@ -36,18 +36,18 @@ typedef enum {
/* allocates *dst_slices; caller must unref all slices in dst_slices then free
it */
-void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
- size_t src_slice_count, grpc_slice **dst_slices,
- size_t *dst_slice_count);
+void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices,
+ size_t src_slice_count, grpc_slice** dst_slices,
+ size_t* dst_slice_count);
void grpc_split_slices_to_buffer(grpc_slice_split_mode mode,
- grpc_slice *src_slices, size_t src_slice_count,
- grpc_slice_buffer *dst);
-void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer *src,
- grpc_slice_buffer *dst);
+ grpc_slice* src_slices, size_t src_slice_count,
+ grpc_slice_buffer* dst);
+void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src,
+ grpc_slice_buffer* dst);
-grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices);
+grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices);
-const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode);
+const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode);
#endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */
diff --git a/test/core/util/test_config.c b/test/core/util/test_config.cc
index 536045e1c3..6b410440c2 100644
--- a/test/core/util/test_config.c
+++ b/test/core/util/test_config.cc
@@ -27,8 +27,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
int64_t g_fixture_slowdown_factor = 1;
int64_t g_poller_slowdown_factor = 1;
@@ -59,7 +59,7 @@ static unsigned seed(void) { return (unsigned)_getpid(); }
static void print_current_stack() {
typedef USHORT(WINAPI * CaptureStackBackTraceType)(
- __in ULONG, __in ULONG, __out PVOID *, __out_opt PULONG);
+ __in ULONG, __in ULONG, __out PVOID*, __out_opt PULONG);
CaptureStackBackTraceType func = (CaptureStackBackTraceType)(GetProcAddress(
LoadLibrary(_T("kernel32.dll")), "RtlCaptureStackBackTrace"));
@@ -71,15 +71,15 @@ static void print_current_stack() {
// than 63.
#define MAX_CALLERS 62
- void *callers_stack[MAX_CALLERS];
+ void* callers_stack[MAX_CALLERS];
unsigned short frames;
- SYMBOL_INFOW *symbol;
+ SYMBOL_INFOW* symbol;
HANDLE process;
process = GetCurrentProcess();
SymInitialize(process, NULL, TRUE);
frames = (func)(0, MAX_CALLERS, callers_stack, NULL);
symbol =
- (SYMBOL_INFOW *)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1);
+ (SYMBOL_INFOW*)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1);
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFOW);
@@ -133,8 +133,8 @@ static void print_stack_from_context(CONTEXT c) {
HANDLE process = GetCurrentProcess();
HANDLE thread = GetCurrentThread();
- SYMBOL_INFOW *symbol =
- (SYMBOL_INFOW *)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1);
+ SYMBOL_INFOW* symbol =
+ (SYMBOL_INFOW*)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1);
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFOW);
@@ -151,7 +151,7 @@ static void print_stack_from_context(CONTEXT c) {
free(symbol);
}
-static LONG crash_handler(struct _EXCEPTION_POINTERS *ex_info) {
+static LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) {
fprintf(stderr, "Exception handler called, dumping information\n");
bool try_to_print_stack = true;
PEXCEPTION_RECORD exrec = ex_info->ExceptionRecord;
@@ -176,7 +176,7 @@ static LONG crash_handler(struct _EXCEPTION_POINTERS *ex_info) {
static void abort_handler(int sig) {
fprintf(stderr, "Abort handler called.\n");
- print_current_stack(NULL);
+ print_current_stack();
if (IsDebuggerPresent()) {
__debugbreak();
} else {
@@ -202,8 +202,8 @@ static void install_crash_handler() {
#define SIGNAL_NAMES_LENGTH 32
-static const char *const signal_names[] = {
- NULL, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP",
+static const char* const signal_names[] = {
+ nullptr, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP",
"SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV",
"SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD",
"SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG",
@@ -215,7 +215,7 @@ static char g_alt_stack[GPR_MAX(MINSIGSTKSZ, 65536)];
#define MAX_FRAMES 32
/* signal safe output */
-static void output_string(const char *string) {
+static void output_string(const char* string) {
size_t len = strlen(string);
ssize_t r;
@@ -230,8 +230,8 @@ static void output_num(long num) {
output_string(buf);
}
-static void crash_handler(int signum, siginfo_t *info, void *data) {
- void *addrlist[MAX_FRAMES + 1];
+static void crash_handler(int signum, siginfo_t* info, void* data) {
+ void* addrlist[MAX_FRAMES + 1];
int addrlen;
output_string("\n\n\n*******************************\nCaught signal ");
@@ -263,15 +263,15 @@ static void install_crash_handler() {
memset(&sa, 0, sizeof(sa));
ss.ss_size = sizeof(g_alt_stack);
ss.ss_sp = g_alt_stack;
- GPR_ASSERT(sigaltstack(&ss, NULL) == 0);
+ GPR_ASSERT(sigaltstack(&ss, nullptr) == 0);
sa.sa_flags = (int)(SA_SIGINFO | SA_ONSTACK | SA_RESETHAND);
sa.sa_sigaction = crash_handler;
- GPR_ASSERT(sigaction(SIGILL, &sa, NULL) == 0);
- GPR_ASSERT(sigaction(SIGABRT, &sa, NULL) == 0);
- GPR_ASSERT(sigaction(SIGBUS, &sa, NULL) == 0);
- GPR_ASSERT(sigaction(SIGSEGV, &sa, NULL) == 0);
- GPR_ASSERT(sigaction(SIGTERM, &sa, NULL) == 0);
- GPR_ASSERT(sigaction(SIGQUIT, &sa, NULL) == 0);
+ GPR_ASSERT(sigaction(SIGILL, &sa, nullptr) == 0);
+ GPR_ASSERT(sigaction(SIGABRT, &sa, nullptr) == 0);
+ GPR_ASSERT(sigaction(SIGBUS, &sa, nullptr) == 0);
+ GPR_ASSERT(sigaction(SIGSEGV, &sa, nullptr) == 0);
+ GPR_ASSERT(sigaction(SIGTERM, &sa, nullptr) == 0);
+ GPR_ASSERT(sigaction(SIGQUIT, &sa, nullptr) == 0);
}
#else
static void install_crash_handler() {}
@@ -376,11 +376,11 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms) {
GPR_TIMESPAN));
}
-void grpc_test_init(int argc, char **argv) {
+void grpc_test_init(int argc, char** argv) {
install_crash_handler();
{ /* poll-cv poll strategy runs much more slowly than anything else */
- char *s = gpr_getenv("GRPC_POLL_STRATEGY");
- if (s != NULL && 0 == strcmp(s, "poll-cv")) {
+ char* s = gpr_getenv("GRPC_POLL_STRATEGY");
+ if (s != nullptr && 0 == strcmp(s, "poll-cv")) {
g_poller_slowdown_factor = 5;
}
gpr_free(s);
diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h
index 051d7e9a3d..5b3d34799e 100644
--- a/test/core/util/test_config.h
+++ b/test/core/util/test_config.h
@@ -21,10 +21,6 @@
#include <grpc/support/time.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
extern int64_t g_fixture_slowdown_factor;
extern int64_t g_poller_slowdown_factor;
@@ -37,14 +33,10 @@ gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s);
/* Converts a given timeout (in milliseconds) to a deadline. */
gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms);
-#ifndef GRPC_TEST_CUSTOM_PICK_PORT
+#if !defined(GRPC_TEST_CUSTOM_PICK_PORT) && !defined(GRPC_PORT_ISOLATED_RUNTIME)
#define GRPC_TEST_PICK_PORT
#endif
-void grpc_test_init(int argc, char **argv);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+void grpc_test_init(int argc, char** argv);
#endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */
diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.cc
index d3a1de8a3b..5f6af4e707 100644
--- a/test/core/util/test_tcp_server.c
+++ b/test/core/util/test_tcp_server.cc
@@ -31,77 +31,71 @@
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/tcp_server.h"
#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
-static void on_server_destroyed(grpc_exec_ctx *exec_ctx, void *data,
- grpc_error *error) {
- test_tcp_server *server = data;
+static void on_server_destroyed(void* data, grpc_error* error) {
+ test_tcp_server* server = static_cast<test_tcp_server*>(data);
server->shutdown = 1;
}
-void test_tcp_server_init(test_tcp_server *server,
- grpc_tcp_server_cb on_connect, void *user_data) {
+void test_tcp_server_init(test_tcp_server* server,
+ grpc_tcp_server_cb on_connect, void* user_data) {
grpc_init();
- server->tcp_server = NULL;
+ server->tcp_server = nullptr;
GRPC_CLOSURE_INIT(&server->shutdown_complete, on_server_destroyed, server,
grpc_schedule_on_exec_ctx);
server->shutdown = 0;
- server->pollset = gpr_zalloc(grpc_pollset_size());
+ server->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(server->pollset, &server->mu);
server->on_connect = on_connect;
server->cb_data = user_data;
}
-void test_tcp_server_start(test_tcp_server *server, int port) {
+void test_tcp_server_start(test_tcp_server* server, int port) {
grpc_resolved_address resolved_addr;
- struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+ struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int port_added;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
addr->sin_family = AF_INET;
addr->sin_port = htons((uint16_t)port);
memset(&addr->sin_addr, 0, sizeof(addr->sin_addr));
- grpc_error *error = grpc_tcp_server_create(
- &exec_ctx, &server->shutdown_complete, NULL, &server->tcp_server);
+ grpc_error* error = grpc_tcp_server_create(&server->shutdown_complete,
+ nullptr, &server->tcp_server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
error =
grpc_tcp_server_add_port(server->tcp_server, &resolved_addr, &port_added);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(port_added == port);
- grpc_tcp_server_start(&exec_ctx, server->tcp_server, &server->pollset, 1,
+ grpc_tcp_server_start(server->tcp_server, &server->pollset, 1,
server->on_connect, server->cb_data);
gpr_log(GPR_INFO, "test tcp server listening on 0.0.0.0:%d", port);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
-void test_tcp_server_poll(test_tcp_server *server, int seconds) {
- grpc_pollset_worker *worker = NULL;
- gpr_timespec deadline =
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(seconds, GPR_TIMESPAN));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+void test_tcp_server_poll(test_tcp_server* server, int seconds) {
+ grpc_pollset_worker* worker = nullptr;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_millis deadline = grpc_timespec_to_millis_round_up(
+ grpc_timeout_seconds_to_deadline(seconds));
gpr_mu_lock(server->mu);
GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, server->pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), deadline));
+ grpc_pollset_work(server->pollset, &worker, deadline));
gpr_mu_unlock(server->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
-static void finish_pollset(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, arg);
+static void do_nothing(void* arg, grpc_error* error) {}
+static void finish_pollset(void* arg, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(arg));
}
-void test_tcp_server_destroy(test_tcp_server *server) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+void test_tcp_server_destroy(test_tcp_server* server) {
+ grpc_core::ExecCtx exec_ctx;
gpr_timespec shutdown_deadline;
grpc_closure do_nothing_cb;
- grpc_tcp_server_unref(&exec_ctx, server->tcp_server);
- GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, NULL,
+ grpc_tcp_server_unref(server->tcp_server);
+ GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(5, GPR_TIMESPAN));
@@ -109,10 +103,10 @@ void test_tcp_server_destroy(test_tcp_server *server) {
gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) {
test_tcp_server_poll(server, 1);
}
- grpc_pollset_shutdown(&exec_ctx, server->pollset,
+ grpc_pollset_shutdown(server->pollset,
GRPC_CLOSURE_CREATE(finish_pollset, server->pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(server->pollset);
grpc_shutdown();
}
diff --git a/test/core/util/test_tcp_server.h b/test/core/util/test_tcp_server.h
index bd62992a09..58140388da 100644
--- a/test/core/util/test_tcp_server.h
+++ b/test/core/util/test_tcp_server.h
@@ -23,19 +23,19 @@
#include "src/core/lib/iomgr/tcp_server.h"
typedef struct test_tcp_server {
- grpc_tcp_server *tcp_server;
+ grpc_tcp_server* tcp_server;
grpc_closure shutdown_complete;
int shutdown;
- gpr_mu *mu;
- grpc_pollset *pollset;
+ gpr_mu* mu;
+ grpc_pollset* pollset;
grpc_tcp_server_cb on_connect;
- void *cb_data;
+ void* cb_data;
} test_tcp_server;
-void test_tcp_server_init(test_tcp_server *server,
- grpc_tcp_server_cb on_connect, void *user_data);
-void test_tcp_server_start(test_tcp_server *server, int port);
-void test_tcp_server_poll(test_tcp_server *server, int seconds);
-void test_tcp_server_destroy(test_tcp_server *server);
+void test_tcp_server_init(test_tcp_server* server,
+ grpc_tcp_server_cb on_connect, void* user_data);
+void test_tcp_server_start(test_tcp_server* server, int port);
+void test_tcp_server_poll(test_tcp_server* server, int seconds);
+void test_tcp_server_destroy(test_tcp_server* server);
#endif /* GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H */
diff --git a/test/core/util/tracer_util.cc b/test/core/util/tracer_util.cc
new file mode 100644
index 0000000000..34a132daa7
--- /dev/null
+++ b/test/core/util/tracer_util.cc
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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/test_config.h"
+
+#include "src/core/lib/debug/trace.h"
+
+namespace grpc_core {
+namespace testing {
+
+void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag) {
+ flag->set_enabled(1);
+}
+
+} // namespace testing
+} // namespace grpc_core
diff --git a/src/node/ext/timeval.h b/test/core/util/tracer_util.h
index 17d7f1642b..0b432ffa46 100644
--- a/src/node/ext/timeval.h
+++ b/test/core/util/tracer_util.h
@@ -16,18 +16,17 @@
*
*/
-#ifndef NET_GRPC_NODE_TIMEVAL_H_
-#define NET_GRPC_NODE_TIMEVAL_H_
+#ifndef GRPC_TEST_CORE_UTIL_TRACER_UTIL_H
+#define GRPC_TEST_CORE_UTIL_TRACER_UTIL_H
-#include "grpc/support/time.h"
+namespace grpc_core {
+class TraceFlag;
-namespace grpc {
-namespace node {
+namespace testing {
+// enables the TraceFlag passed to it. Used for testing purposes.
+void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag);
-double TimespecToMilliseconds(gpr_timespec time);
-gpr_timespec MillisecondsToTimespec(double millis);
+} // namespace testing
+} // namespace grpc_core
-} // namespace node
-} // namespace grpc
-
-#endif // NET_GRPC_NODE_TIMEVAL_H_
+#endif /* GRPC_TEST_CORE_UTIL_TRACER_UTIL_H */
diff --git a/test/core/util/trickle_endpoint.c b/test/core/util/trickle_endpoint.cc
index fc066f9d80..f95ed62463 100644
--- a/test/core/util/trickle_endpoint.c
+++ b/test/core/util/trickle_endpoint.cc
@@ -34,37 +34,37 @@
typedef struct {
grpc_endpoint base;
double bytes_per_second;
- grpc_endpoint *wrapped;
+ grpc_endpoint* wrapped;
gpr_timespec last_write;
gpr_mu mu;
grpc_slice_buffer write_buffer;
grpc_slice_buffer writing_buffer;
- grpc_error *error;
+ grpc_error* error;
bool writing;
- grpc_closure *write_cb;
+ grpc_closure* write_cb;
} trickle_endpoint;
-static void te_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
- grpc_endpoint_read(exec_ctx, te->wrapped, slices, cb);
+static void te_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
+ grpc_endpoint_read(te->wrapped, slices, cb);
}
-static void maybe_call_write_cb_locked(grpc_exec_ctx *exec_ctx,
- trickle_endpoint *te) {
- if (te->write_cb != NULL && (te->error != GRPC_ERROR_NONE ||
- te->write_buffer.length <= WRITE_BUFFER_SIZE)) {
- GRPC_CLOSURE_SCHED(exec_ctx, te->write_cb, GRPC_ERROR_REF(te->error));
- te->write_cb = NULL;
+static void maybe_call_write_cb_locked(trickle_endpoint* te) {
+ if (te->write_cb != nullptr &&
+ (te->error != GRPC_ERROR_NONE ||
+ te->write_buffer.length <= WRITE_BUFFER_SIZE)) {
+ GRPC_CLOSURE_SCHED(te->write_cb, GRPC_ERROR_REF(te->error));
+ te->write_cb = nullptr;
}
}
-static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
- GPR_ASSERT(te->write_cb == NULL);
+ GPR_ASSERT(te->write_cb == nullptr);
if (te->write_buffer.length == 0) {
te->last_write = gpr_now(GPR_CLOCK_MONOTONIC);
}
@@ -73,80 +73,89 @@ static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
grpc_slice_copy(slices->slices[i]));
}
te->write_cb = cb;
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
gpr_mu_unlock(&te->mu);
}
-static void te_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
- grpc_endpoint_add_to_pollset(exec_ctx, te->wrapped, pollset);
+static void te_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
+ grpc_endpoint_add_to_pollset(te->wrapped, pollset);
}
-static void te_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset_set) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
- grpc_endpoint_add_to_pollset_set(exec_ctx, te->wrapped, pollset_set);
+static void te_add_to_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
+ grpc_endpoint_add_to_pollset_set(te->wrapped, pollset_set);
}
-static void te_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+static void te_delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset_set) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
+ grpc_endpoint_delete_from_pollset_set(te->wrapped, pollset_set);
+}
+
+static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
if (te->error == GRPC_ERROR_NONE) {
te->error = GRPC_ERROR_REF(why);
}
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
gpr_mu_unlock(&te->mu);
- grpc_endpoint_shutdown(exec_ctx, te->wrapped, why);
+ grpc_endpoint_shutdown(te->wrapped, why);
}
-static void te_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
- grpc_endpoint_destroy(exec_ctx, te->wrapped);
+static void te_destroy(grpc_endpoint* ep) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
+ grpc_endpoint_destroy(te->wrapped);
gpr_mu_destroy(&te->mu);
- grpc_slice_buffer_destroy_internal(exec_ctx, &te->write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &te->writing_buffer);
+ grpc_slice_buffer_destroy_internal(&te->write_buffer);
+ grpc_slice_buffer_destroy_internal(&te->writing_buffer);
GRPC_ERROR_UNREF(te->error);
gpr_free(te);
}
-static grpc_resource_user *te_get_resource_user(grpc_endpoint *ep) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+static grpc_resource_user* te_get_resource_user(grpc_endpoint* ep) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
return grpc_endpoint_get_resource_user(te->wrapped);
}
-static char *te_get_peer(grpc_endpoint *ep) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+static char* te_get_peer(grpc_endpoint* ep) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
return grpc_endpoint_get_peer(te->wrapped);
}
-static int te_get_fd(grpc_endpoint *ep) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+static int te_get_fd(grpc_endpoint* ep) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
return grpc_endpoint_get_fd(te->wrapped);
}
-static void te_finish_write(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- trickle_endpoint *te = (trickle_endpoint *)arg;
+static void te_finish_write(void* arg, grpc_error* error) {
+ trickle_endpoint* te = (trickle_endpoint*)arg;
gpr_mu_lock(&te->mu);
te->writing = false;
grpc_slice_buffer_reset_and_unref(&te->writing_buffer);
gpr_mu_unlock(&te->mu);
}
-static const grpc_endpoint_vtable vtable = {
- te_read, te_write, te_add_to_pollset, te_add_to_pollset_set,
- te_shutdown, te_destroy, te_get_resource_user, te_get_peer,
- te_get_fd};
-
-grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap,
+static const grpc_endpoint_vtable vtable = {te_read,
+ te_write,
+ te_add_to_pollset,
+ te_add_to_pollset_set,
+ te_delete_from_pollset_set,
+ te_shutdown,
+ te_destroy,
+ te_get_resource_user,
+ te_get_peer,
+ te_get_fd};
+
+grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
double bytes_per_second) {
- trickle_endpoint *te = (trickle_endpoint *)gpr_malloc(sizeof(*te));
+ trickle_endpoint* te = (trickle_endpoint*)gpr_malloc(sizeof(*te));
te->base.vtable = &vtable;
te->wrapped = wrap;
te->bytes_per_second = bytes_per_second;
- te->write_cb = NULL;
+ te->write_cb = nullptr;
gpr_mu_init(&te->mu);
grpc_slice_buffer_init(&te->write_buffer);
grpc_slice_buffer_init(&te->writing_buffer);
@@ -159,9 +168,8 @@ static double ts2dbl(gpr_timespec s) {
return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec;
}
-size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *ep) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
if (!te->writing && te->write_buffer.length > 0) {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
@@ -175,9 +183,9 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx,
te->writing = true;
te->last_write = now;
grpc_endpoint_write(
- exec_ctx, te->wrapped, &te->writing_buffer,
+ te->wrapped, &te->writing_buffer,
GRPC_CLOSURE_CREATE(te_finish_write, te, grpc_schedule_on_exec_ctx));
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
}
}
size_t backlog = te->write_buffer.length;
@@ -185,8 +193,8 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx,
return backlog;
}
-size_t grpc_trickle_get_backlog(grpc_endpoint *ep) {
- trickle_endpoint *te = (trickle_endpoint *)ep;
+size_t grpc_trickle_get_backlog(grpc_endpoint* ep) {
+ trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
size_t backlog = te->write_buffer.length;
gpr_mu_unlock(&te->mu);
diff --git a/test/core/util/trickle_endpoint.h b/test/core/util/trickle_endpoint.h
index 78f1eeeda2..cd07de905a 100644
--- a/test/core/util/trickle_endpoint.h
+++ b/test/core/util/trickle_endpoint.h
@@ -21,13 +21,12 @@
#include "src/core/lib/iomgr/endpoint.h"
-grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap,
+grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
double bytes_per_second);
/* Allow up to \a bytes through the endpoint. Returns the new backlog. */
-size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx,
- grpc_endpoint *endpoint);
+size_t grpc_trickle_endpoint_trickle(grpc_endpoint* endpoint);
-size_t grpc_trickle_get_backlog(grpc_endpoint *endpoint);
+size_t grpc_trickle_get_backlog(grpc_endpoint* endpoint);
#endif
diff --git a/test/cpp/client/BUILD b/test/cpp/client/BUILD
new file mode 100644
index 0000000000..12825e88c2
--- /dev/null
+++ b/test/cpp/client/BUILD
@@ -0,0 +1,51 @@
+# 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.
+
+licenses(["notice"]) # Apache v2
+
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package")
+
+grpc_package(name = "test/cpp/client")
+
+grpc_cc_test(
+ name = "credentials_test",
+ srcs = ["credentials_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ ],
+)
+
+grpc_cc_test(
+ name = "client_channel_stress_test",
+ srcs = ["client_channel_stress_test.cc"],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//:grpc_resolver_fake",
+ "//src/proto/grpc/lb/v1:load_balancer_proto",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/end2end:test_service_impl",
+ "//test/cpp/util:test_util",
+ ],
+)
diff --git a/test/cpp/client/client_channel_stress_test.cc b/test/cpp/client/client_channel_stress_test.cc
new file mode 100644
index 0000000000..80d1583333
--- /dev/null
+++ b/test/cpp/client/client_channel_stress_test.cc
@@ -0,0 +1,328 @@
+/*
+ *
+ * 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 <atomic>
+#include <memory>
+#include <mutex>
+#include <random>
+#include <sstream>
+#include <thread>
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/end2end/test_service_impl.h"
+
+#include "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h"
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+
+using grpc::lb::v1::LoadBalanceRequest;
+using grpc::lb::v1::LoadBalanceResponse;
+using grpc::lb::v1::LoadBalancer;
+
+namespace grpc {
+namespace testing {
+namespace {
+
+const size_t kNumBackends = 10;
+const size_t kNumBalancers = 5;
+const size_t kNumClientThreads = 100;
+const int kResolutionUpdateIntervalMs = 50;
+const int kServerlistUpdateIntervalMs = 10;
+const int kTestDurationSec = 30;
+
+using BackendServiceImpl = TestServiceImpl;
+
+class BalancerServiceImpl : public LoadBalancer::Service {
+ public:
+ using Stream = ServerReaderWriter<LoadBalanceResponse, LoadBalanceRequest>;
+
+ explicit BalancerServiceImpl(const std::vector<int>& all_backend_ports)
+ : all_backend_ports_(all_backend_ports) {}
+
+ Status BalanceLoad(ServerContext* context, Stream* stream) override {
+ gpr_log(GPR_INFO, "LB[%p]: Start BalanceLoad.", this);
+ LoadBalanceRequest request;
+ stream->Read(&request);
+ while (!shutdown_) {
+ stream->Write(BuildRandomResponseForBackends());
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(kServerlistUpdateIntervalMs));
+ }
+ gpr_log(GPR_INFO, "LB[%p]: Finish BalanceLoad.", this);
+ return Status::OK;
+ }
+
+ void Shutdown() { shutdown_ = true; }
+
+ private:
+ grpc::string Ip4ToPackedString(const char* ip_str) {
+ struct in_addr ip4;
+ GPR_ASSERT(inet_pton(AF_INET, ip_str, &ip4) == 1);
+ return grpc::string(reinterpret_cast<const char*>(&ip4), sizeof(ip4));
+ }
+
+ LoadBalanceResponse BuildRandomResponseForBackends() {
+ // Generate a random serverlist with varying size (if N =
+ // all_backend_ports_.size(), num_non_drop_entry is in [0, 2N],
+ // num_drop_entry is in [0, N]), order, duplicate, and drop rate.
+ size_t num_non_drop_entry =
+ std::rand() % (all_backend_ports_.size() * 2 + 1);
+ size_t num_drop_entry = std::rand() % (all_backend_ports_.size() + 1);
+ std::vector<int> random_backend_indices;
+ for (size_t i = 0; i < num_non_drop_entry; ++i) {
+ random_backend_indices.push_back(std::rand() % all_backend_ports_.size());
+ }
+ for (size_t i = 0; i < num_drop_entry; ++i) {
+ random_backend_indices.push_back(-1);
+ }
+ std::shuffle(random_backend_indices.begin(), random_backend_indices.end(),
+ std::mt19937(std::random_device()()));
+ // Build the response according to the random list generated above.
+ LoadBalanceResponse response;
+ for (int index : random_backend_indices) {
+ auto* server = response.mutable_server_list()->add_servers();
+ if (index < 0) {
+ server->set_drop(true);
+ server->set_load_balance_token("load_balancing");
+ } else {
+ server->set_ip_address(Ip4ToPackedString("127.0.0.1"));
+ server->set_port(all_backend_ports_[index]);
+ }
+ }
+ return response;
+ }
+
+ std::atomic_bool shutdown_{false};
+ const std::vector<int> all_backend_ports_;
+};
+
+class ClientChannelStressTest {
+ public:
+ void Run() {
+ Start();
+ // Keep updating resolution for the test duration.
+ gpr_log(GPR_INFO, "Start updating resolution.");
+ const auto wait_duration =
+ std::chrono::milliseconds(kResolutionUpdateIntervalMs);
+ std::vector<AddressData> addresses;
+ auto start_time = std::chrono::steady_clock::now();
+ while (true) {
+ if (std::chrono::duration_cast<std::chrono::seconds>(
+ std::chrono::steady_clock::now() - start_time)
+ .count() > kTestDurationSec) {
+ break;
+ }
+ // Generate a random subset of balancers.
+ addresses.clear();
+ for (const auto& balancer_server : balancer_servers_) {
+ // Select each address with probability of 0.8.
+ if (std::rand() % 10 < 8) {
+ addresses.emplace_back(AddressData{balancer_server.port_, true, ""});
+ }
+ }
+ std::shuffle(addresses.begin(), addresses.end(),
+ std::mt19937(std::random_device()()));
+ SetNextResolution(addresses);
+ std::this_thread::sleep_for(wait_duration);
+ }
+ gpr_log(GPR_INFO, "Finish updating resolution.");
+ Shutdown();
+ }
+
+ private:
+ template <typename T>
+ struct ServerThread {
+ explicit ServerThread(const grpc::string& type,
+ const grpc::string& server_host, T* service)
+ : type_(type), service_(service) {
+ std::mutex mu;
+ // We need to acquire the lock here in order to prevent the notify_one
+ // by ServerThread::Start from firing before the wait below is hit.
+ std::unique_lock<std::mutex> lock(mu);
+ port_ = grpc_pick_unused_port_or_die();
+ gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_);
+ std::condition_variable cond;
+ thread_.reset(new std::thread(
+ std::bind(&ServerThread::Start, this, server_host, &mu, &cond)));
+ cond.wait(lock);
+ gpr_log(GPR_INFO, "%s server startup complete", type_.c_str());
+ }
+
+ void Start(const grpc::string& server_host, std::mutex* mu,
+ std::condition_variable* cond) {
+ // We need to acquire the lock here in order to prevent the notify_one
+ // below from firing before its corresponding wait is executed.
+ std::lock_guard<std::mutex> lock(*mu);
+ std::ostringstream server_address;
+ server_address << server_host << ":" << port_;
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address.str(),
+ InsecureServerCredentials());
+ builder.RegisterService(service_);
+ server_ = builder.BuildAndStart();
+ cond->notify_one();
+ }
+
+ void Shutdown() {
+ gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str());
+ server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0));
+ thread_->join();
+ gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str());
+ }
+
+ int port_;
+ grpc::string type_;
+ std::unique_ptr<Server> server_;
+ T* service_;
+ std::unique_ptr<std::thread> thread_;
+ };
+
+ struct AddressData {
+ int port;
+ bool is_balancer;
+ grpc::string balancer_name;
+ };
+
+ void SetNextResolution(const std::vector<AddressData>& address_data) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_lb_addresses* addresses =
+ grpc_lb_addresses_create(address_data.size(), nullptr);
+ for (size_t i = 0; i < address_data.size(); ++i) {
+ char* lb_uri_str;
+ gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", address_data[i].port);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
+ GPR_ASSERT(lb_uri != nullptr);
+ grpc_lb_addresses_set_address_from_uri(
+ addresses, i, lb_uri, address_data[i].is_balancer,
+ address_data[i].balancer_name.c_str(), nullptr);
+ grpc_uri_destroy(lb_uri);
+ gpr_free(lb_uri_str);
+ }
+ 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);
+ grpc_lb_addresses_destroy(addresses);
+ }
+
+ void KeepSendingRequests() {
+ gpr_log(GPR_INFO, "Start sending requests.");
+ while (!shutdown_) {
+ ClientContext context;
+ context.set_deadline(grpc_timeout_milliseconds_to_deadline(1000));
+ EchoRequest request;
+ request.set_message("test");
+ EchoResponse response;
+ {
+ std::lock_guard<std::mutex> lock(stub_mutex_);
+ stub_->Echo(&context, request, &response);
+ }
+ }
+ gpr_log(GPR_INFO, "Finish sending requests.");
+ }
+
+ void CreateStub() {
+ ChannelArguments args;
+ response_generator_ = grpc_fake_resolver_response_generator_create();
+ args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR,
+ response_generator_);
+ std::ostringstream uri;
+ uri << "fake:///servername_not_used";
+ channel_ =
+ CreateCustomChannel(uri.str(), InsecureChannelCredentials(), args);
+ stub_ = grpc::testing::EchoTestService::NewStub(channel_);
+ }
+
+ void Start() {
+ // Start the backends.
+ std::vector<int> backend_ports;
+ for (size_t i = 0; i < kNumBackends; ++i) {
+ backends_.emplace_back(new BackendServiceImpl());
+ backend_servers_.emplace_back(ServerThread<BackendServiceImpl>(
+ "backend", server_host_, backends_.back().get()));
+ backend_ports.push_back(backend_servers_.back().port_);
+ }
+ // Start the load balancers.
+ for (size_t i = 0; i < kNumBalancers; ++i) {
+ balancers_.emplace_back(new BalancerServiceImpl(backend_ports));
+ balancer_servers_.emplace_back(ServerThread<BalancerServiceImpl>(
+ "balancer", server_host_, balancers_.back().get()));
+ }
+ // Start sending RPCs in multiple threads.
+ CreateStub();
+ for (size_t i = 0; i < kNumClientThreads; ++i) {
+ client_threads_.emplace_back(
+ std::thread(&ClientChannelStressTest::KeepSendingRequests, this));
+ }
+ }
+
+ void Shutdown() {
+ shutdown_ = true;
+ for (size_t i = 0; i < client_threads_.size(); ++i) {
+ client_threads_[i].join();
+ }
+ for (size_t i = 0; i < balancers_.size(); ++i) {
+ balancers_[i]->Shutdown();
+ balancer_servers_[i].Shutdown();
+ }
+ 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};
+ const grpc::string server_host_ = "localhost";
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::mutex stub_mutex_;
+ std::vector<std::unique_ptr<BackendServiceImpl>> backends_;
+ std::vector<std::unique_ptr<BalancerServiceImpl>> balancers_;
+ std::vector<ServerThread<BackendServiceImpl>> backend_servers_;
+ std::vector<ServerThread<BalancerServiceImpl>> balancer_servers_;
+ grpc_fake_resolver_response_generator* response_generator_;
+ std::vector<std::thread> client_threads_;
+};
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_init();
+ grpc_test_init(argc, argv);
+ grpc::testing::ClientChannelStressTest test;
+ test.Run();
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj b/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..1d332ba7ce
--- /dev/null
+++ b/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj
@@ -0,0 +1,533 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 48;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 2D3F2189E2CDF493639A17C5 /* libPods-test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B1FD20127AB0F23D6AB570 /* libPods-test.a */; };
+ 5E63948A1FDB64B50051E9AA /* server_context_test_spouse_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */; };
+ 5EFA5F731FEDB36700EBF4B7 /* generic.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EFA5F721FEDB36700EBF4B7 /* generic.mm */; };
+ D0F8FABF3ECF587C207C12F3 /* libPods-generic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-generic.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E63947F1FDB5EA10051E9AA /* test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = test.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E6394831FDB5EA10051E9AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = server_context_test_spouse_test.mm; sourceTree = "<group>"; };
+ 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = generic.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5EFA5F721FEDB36700EBF4B7 /* generic.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = generic.mm; sourceTree = "<group>"; };
+ 5EFA5F741FEDB36700EBF4B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.release.xcconfig"; path = "Pods/Target Support Files/Pods-test/Pods-test.release.xcconfig"; sourceTree = "<group>"; };
+ 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.debug.xcconfig"; path = "Pods/Target Support Files/Pods-test/Pods-test.debug.xcconfig"; sourceTree = "<group>"; };
+ 99B1FD20127AB0F23D6AB570 /* libPods-test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-test.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-generic.release.xcconfig"; path = "Pods/Target Support Files/Pods-generic/Pods-generic.release.xcconfig"; sourceTree = "<group>"; };
+ D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-generic.debug.xcconfig"; path = "Pods/Target Support Files/Pods-generic/Pods-generic.debug.xcconfig"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 5E63947C1FDB5EA10051E9AA /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 2D3F2189E2CDF493639A17C5 /* libPods-test.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EFA5F6D1FEDB36700EBF4B7 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D0F8FABF3ECF587C207C12F3 /* libPods-generic.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 4439BD4D56FD5738BF780F8E /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */,
+ 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */,
+ D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */,
+ B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */,
+ );
+ name = Pods;
+ sourceTree = "<group>";
+ };
+ 5E63944B1FDB5D9B0051E9AA = {
+ isa = PBXGroup;
+ children = (
+ 5E63947F1FDB5EA10051E9AA /* test.xctest */,
+ 5E6394801FDB5EA10051E9AA /* test */,
+ 4439BD4D56FD5738BF780F8E /* Pods */,
+ 5EFA5F711FEDB36700EBF4B7 /* generic */,
+ C2E6603B58413BD724AFB400 /* Frameworks */,
+ 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */,
+ );
+ sourceTree = "<group>";
+ };
+ 5E6394801FDB5EA10051E9AA /* test */ = {
+ isa = PBXGroup;
+ children = (
+ 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */,
+ 5E6394831FDB5EA10051E9AA /* Info.plist */,
+ );
+ path = test;
+ sourceTree = "<group>";
+ };
+ 5EFA5F711FEDB36700EBF4B7 /* generic */ = {
+ isa = PBXGroup;
+ children = (
+ 5EFA5F721FEDB36700EBF4B7 /* generic.mm */,
+ 5EFA5F741FEDB36700EBF4B7 /* Info.plist */,
+ );
+ path = generic;
+ sourceTree = "<group>";
+ };
+ C2E6603B58413BD724AFB400 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 99B1FD20127AB0F23D6AB570 /* libPods-test.a */,
+ 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 5E63947E1FDB5EA10051E9AA /* test */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5E6394841FDB5EA10051E9AA /* Build configuration list for PBXNativeTarget "test" */;
+ buildPhases = (
+ 6D8317CF72F9E252442662F8 /* [CP] Check Pods Manifest.lock */,
+ 5E63947B1FDB5EA10051E9AA /* Sources */,
+ 5E63947C1FDB5EA10051E9AA /* Frameworks */,
+ 5E63947D1FDB5EA10051E9AA /* Resources */,
+ B972D278DA2A2BF12386177C /* [CP] Embed Pods Frameworks */,
+ 3C2FE7A8DBA8BBCB2923B173 /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = test;
+ productName = test;
+ productReference = 5E63947F1FDB5EA10051E9AA /* test.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+ 5EFA5F6F1FEDB36700EBF4B7 /* generic */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5EFA5F751FEDB36700EBF4B7 /* Build configuration list for PBXNativeTarget "generic" */;
+ buildPhases = (
+ 4844599DC62113265AB660B3 /* [CP] Check Pods Manifest.lock */,
+ 5EFA5F6C1FEDB36700EBF4B7 /* Sources */,
+ 5EFA5F6D1FEDB36700EBF4B7 /* Frameworks */,
+ 5EFA5F6E1FEDB36700EBF4B7 /* Resources */,
+ 11E4716E0919C734CC6AA8C2 /* [CP] Embed Pods Frameworks */,
+ 9E149E84C3AA06289FE1F244 /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = generic;
+ productName = generic;
+ productReference = 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 5E63944C1FDB5D9B0051E9AA /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0910;
+ ORGANIZATIONNAME = gRPC;
+ TargetAttributes = {
+ 5E63947E1FDB5EA10051E9AA = {
+ CreatedOnToolsVersion = 9.1;
+ ProvisioningStyle = Automatic;
+ };
+ 5EFA5F6F1FEDB36700EBF4B7 = {
+ CreatedOnToolsVersion = 9.2;
+ ProvisioningStyle = Automatic;
+ };
+ };
+ };
+ buildConfigurationList = 5E63944F1FDB5D9B0051E9AA /* Build configuration list for PBXProject "GRPCCppTests" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 5E63944B1FDB5D9B0051E9AA;
+ productRefGroup = 5E63944B1FDB5D9B0051E9AA;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 5E63947E1FDB5EA10051E9AA /* test */,
+ 5EFA5F6F1FEDB36700EBF4B7 /* generic */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 5E63947D1FDB5EA10051E9AA /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EFA5F6E1FEDB36700EBF4B7 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 11E4716E0919C734CC6AA8C2 /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-generic/Pods-generic-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 3C2FE7A8DBA8BBCB2923B173 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-test/Pods-test-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 4844599DC62113265AB660B3 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-generic-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 6D8317CF72F9E252442662F8 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-test-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 9E149E84C3AA06289FE1F244 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-generic/Pods-generic-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ B972D278DA2A2BF12386177C /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-test/Pods-test-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 5E63947B1FDB5EA10051E9AA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E63948A1FDB64B50051E9AA /* server_context_test_spouse_test.mm in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EFA5F6C1FEDB36700EBF4B7 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5EFA5F731FEDB36700EBF4B7 /* generic.mm in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 5E6394731FDB5D9B0051E9AA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = ../../../include;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.1;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ USER_HEADER_SEARCH_PATHS = ../../..;
+ };
+ name = Debug;
+ };
+ 5E6394741FDB5D9B0051E9AA /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = ../../../include;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.1;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ USER_HEADER_SEARCH_PATHS = ../../..;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 5E6394851FDB5EA10051E9AA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"${PODS_ROOT}/Headers/Public\"",
+ "\"${PODS_ROOT}/Headers/Public/BoringSSL\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-C++\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-Core\"",
+ "\"${PODS_ROOT}/Headers/Public/nanopb\"",
+ );
+ INFOPLIST_FILE = test/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.test;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5E6394861FDB5EA10051E9AA /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"${PODS_ROOT}/Headers/Public\"",
+ "\"${PODS_ROOT}/Headers/Public/BoringSSL\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-C++\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-Core\"",
+ "\"${PODS_ROOT}/Headers/Public/nanopb\"",
+ );
+ INFOPLIST_FILE = test/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.test;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+ 5EFA5F761FEDB36700EBF4B7 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ INFOPLIST_FILE = generic/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.generic;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5EFA5F771FEDB36700EBF4B7 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ INFOPLIST_FILE = generic/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.generic;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 5E63944F1FDB5D9B0051E9AA /* Build configuration list for PBXProject "GRPCCppTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E6394731FDB5D9B0051E9AA /* Debug */,
+ 5E6394741FDB5D9B0051E9AA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5E6394841FDB5EA10051E9AA /* Build configuration list for PBXNativeTarget "test" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E6394851FDB5EA10051E9AA /* Debug */,
+ 5E6394861FDB5EA10051E9AA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5EFA5F751FEDB36700EBF4B7 /* Build configuration list for PBXNativeTarget "generic" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5EFA5F761FEDB36700EBF4B7 /* Debug */,
+ 5EFA5F771FEDB36700EBF4B7 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 5E63944C1FDB5D9B0051E9AA /* Project object */;
+}
diff --git a/test/cpp/cocoapods/Podfile b/test/cpp/cocoapods/Podfile
new file mode 100644
index 0000000000..8d8cdaaadd
--- /dev/null
+++ b/test/cpp/cocoapods/Podfile
@@ -0,0 +1,71 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+# Location of gRPC's repo root relative to this file.
+GRPC_LOCAL_SRC = '../../..'
+
+%w(
+ test
+ generic
+).each do |target_name|
+ target target_name do
+ pod 'gRPC-Core', :path => GRPC_LOCAL_SRC
+ pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC
+ pod 'gRPC-C++', :path => GRPC_LOCAL_SRC
+ pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
+ end
+end
+
+# gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's
+# pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded
+# and before they are installed in the user project.
+#
+# This podspec searches for the gRPC core library headers under "$(PODS_ROOT)/gRPC-Core", where
+# Cocoapods normally places the downloaded sources. When doing local development of the libraries,
+# though, Cocoapods just takes the sources from whatever directory was specified using `:path`, and
+# doesn't copy them under $(PODS_ROOT). When using static libraries, one can sometimes rely on the
+# symbolic links to the pods headers that Cocoapods creates under "$(PODS_ROOT)/Headers". But those
+# aren't created when using dynamic frameworks. So our solution is to modify the podspec on the fly
+# to point at the local directory where the sources are.
+#
+# TODO(jcanizales): Send a PR to Cocoapods to get rid of this need.
+pre_install do |installer|
+ # This is the gRPC-Core podspec object, as initialized by its podspec file.
+ grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec
+
+ # Copied from gRPC-Core.podspec, except for the adjusted src_root:
+ src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
+ grpc_core_spec.pod_target_xcconfig = {
+ 'GRPC_SRC_ROOT' => src_root,
+ 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
+ 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
+ # If we don't set these two settings, `include/grpc/support/time.h` and
+ # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # build.
+ 'USE_HEADERMAP' => 'NO',
+ 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ }
+end
+
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
+ end
+
+ # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include
+ # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core'
+ # and require the same error suppresion.
+ if target.name.start_with?('gRPC-Core')
+ target.build_configurations.each do |config|
+ # TODO(zyc): Remove this setting after the issue is resolved
+ # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
+ # function" warning
+ config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
+ config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
+ end
+ end
+ end
+end
diff --git a/test/cpp/cocoapods/generic/Info.plist b/test/cpp/cocoapods/generic/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/test/cpp/cocoapods/generic/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/test/cpp/cocoapods/generic/generic.mm b/test/cpp/cocoapods/generic/generic.mm
new file mode 100644
index 0000000000..30b43ec375
--- /dev/null
+++ b/test/cpp/cocoapods/generic/generic.mm
@@ -0,0 +1,244 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#include <sstream>
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/generic/async_generic_service.h>
+#include <grpc++/generic/generic_stub.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc++/support/slice.h>
+#include <grpc/grpc.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+using std::chrono::system_clock;
+using namespace grpc;
+
+void* tag(int i) { return (void*)(intptr_t)i; }
+
+static grpc_slice merge_slices(grpc_slice* slices, size_t nslices) {
+ size_t i;
+ size_t len = 0;
+ uint8_t* cursor;
+ grpc_slice out;
+
+ for (i = 0; i < nslices; i++) {
+ len += GRPC_SLICE_LENGTH(slices[i]);
+ }
+
+ out = grpc_slice_malloc(len);
+ cursor = GRPC_SLICE_START_PTR(out);
+
+ for (i = 0; i < nslices; i++) {
+ memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]),
+ GRPC_SLICE_LENGTH(slices[i]));
+ cursor += GRPC_SLICE_LENGTH(slices[i]);
+ }
+
+ return out;
+}
+
+int byte_buffer_eq_string(ByteBuffer* bb, const char* str) {
+ int res;
+
+ std::vector<Slice> slices;
+ bb->Dump(&slices);
+ grpc_slice* c_slices = new grpc_slice[slices.size()];
+ for (int i = 0; i < slices.size(); i++) {
+ c_slices[i] = slices[i].c_slice();
+ }
+ grpc_slice a = merge_slices(c_slices, slices.size());
+ grpc_slice b = grpc_slice_from_copied_string(str);
+ res =
+ (GRPC_SLICE_LENGTH(a) == GRPC_SLICE_LENGTH(b)) &&
+ (0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b),
+ GRPC_SLICE_LENGTH(a)));
+ grpc_slice_unref(a);
+ grpc_slice_unref(b);
+ for (int i = 0; i < slices.size(); i++) {
+ grpc_slice_unref(c_slices[i]);
+ }
+ delete [] c_slices;
+
+ return res;
+}
+
+@interface GenericTest : XCTestCase
+
+@end
+
+@implementation GenericTest {
+ grpc::string server_host_;
+ CompletionQueue cli_cq_;
+ std::unique_ptr<ServerCompletionQueue> srv_cq_;
+ std::unique_ptr<GenericStub> generic_stub_;
+ std::unique_ptr<Server> server_;
+ AsyncGenericService generic_service_;
+ std::ostringstream server_address_;
+}
+
+- (void)verify_ok:(grpc::CompletionQueue*)cq
+ i:(int)i
+ expect_ok:(bool)expect_ok {
+ bool ok;
+ void* got_tag;
+ XCTAssertTrue(cq->Next(&got_tag, &ok));
+ XCTAssertEqual(expect_ok, ok);
+ XCTAssertEqual(tag(i), got_tag);
+}
+
+- (void)server_ok:(int)i { [self verify_ok:srv_cq_.get() i:i expect_ok:true]; }
+- (void)client_ok:(int)i { [self verify_ok:&cli_cq_ i:i expect_ok:true]; }
+- (void)server_fail:(int)i { [self verify_ok:srv_cq_.get() i:i expect_ok:false]; }
+- (void)client_fail:(int)i { [self verify_ok:&cli_cq_ i:i expect_ok:false]; }
+
+- (void)setUp {
+ [super setUp];
+
+ server_host_ = "localhost";
+ int port = grpc_pick_unused_port_or_die();
+ server_address_ << server_host_ << ":" << port;
+ // Setup server
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address_.str(),
+ InsecureServerCredentials());
+ builder.RegisterAsyncGenericService(&generic_service_);
+ // Include a second call to RegisterAsyncGenericService to make sure that
+ // we get an error in the log, since it is not allowed to have 2 async
+ // generic services
+ builder.RegisterAsyncGenericService(&generic_service_);
+ srv_cq_ = builder.AddCompletionQueue();
+ server_ = builder.BuildAndStart();
+}
+
+- (void)tearDown {
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
+ server_->Shutdown();
+ void* ignored_tag;
+ bool ignored_ok;
+ cli_cq_.Shutdown();
+ srv_cq_->Shutdown();
+ while (cli_cq_.Next(&ignored_tag, &ignored_ok));
+ while (srv_cq_->Next(&ignored_tag, &ignored_ok));
+ [super tearDown];
+}
+
+- (void)ResetStub {
+ std::shared_ptr<Channel> channel =
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
+ generic_stub_.reset(new GenericStub(channel));
+}
+
+- (void)SendRpc:(int)num_rpcs {
+ [self SendRpc:num_rpcs check_deadline:false deadline:gpr_inf_future(GPR_CLOCK_MONOTONIC)];
+ }
+
+- (void)SendRpc:(int)num_rpcs
+ check_deadline:(bool)check_deadline
+ deadline:(gpr_timespec)deadline {
+ const grpc::string kMethodName("/grpc.cpp.test.util.EchoTestService/Echo");
+ for (int i = 0; i < num_rpcs; i++) {
+ Status recv_status;
+
+ ClientContext cli_ctx;
+ GenericServerContext srv_ctx;
+ GenericServerAsyncReaderWriter stream(&srv_ctx);
+
+ // The string needs to be long enough to test heap-based slice.
+ /*send_request.set_message("Hello world. Hello world. Hello world.");*/
+
+ if (check_deadline) {
+ cli_ctx.set_deadline(deadline);
+ }
+
+ std::unique_ptr<GenericClientAsyncReaderWriter> call =
+ generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1));
+ [self client_ok:1];
+ Slice send_slice = Slice("hello world", 11);
+ std::unique_ptr<ByteBuffer> send_buffer =
+ std::unique_ptr<ByteBuffer>(new ByteBuffer(&send_slice, 1));
+ call->Write(*send_buffer, tag(2));
+ // Send ByteBuffer can be destroyed after calling Write.
+ send_buffer.reset();
+ [self client_ok:2];
+ call->WritesDone(tag(3));
+ [self client_ok:3];
+
+ generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(),
+ srv_cq_.get(), tag(4));
+
+ [self verify_ok:srv_cq_.get() i:4 expect_ok:true];
+ XCTAssertEqual(server_host_, srv_ctx.host().substr(0, server_host_.length()));
+ XCTAssertEqual(kMethodName, srv_ctx.method());
+
+ if (check_deadline) {
+ XCTAssertTrue(gpr_time_similar(deadline, srv_ctx.raw_deadline(),
+ gpr_time_from_millis(1000, GPR_TIMESPAN)));
+ }
+
+ ByteBuffer recv_buffer;
+ stream.Read(&recv_buffer, tag(5));
+ [self server_ok:5];
+ XCTAssertTrue(byte_buffer_eq_string(&recv_buffer, "hello world"));
+
+ send_buffer = std::unique_ptr<ByteBuffer>(new ByteBuffer(recv_buffer));
+ stream.Write(*send_buffer, tag(6));
+ send_buffer.reset();
+ [self server_ok:6];
+
+ stream.Finish(Status::OK, tag(7));
+ [self server_ok:7];
+
+ recv_buffer.Clear();
+ call->Read(&recv_buffer, tag(8));
+ [self client_ok:8];
+ XCTAssertTrue(byte_buffer_eq_string(&recv_buffer, "hello world"));
+
+ call->Finish(&recv_status, tag(9));
+ [self client_ok:9];
+
+ XCTAssertTrue(recv_status.ok());
+ }
+}
+
+- (void)testSimpleRpc {
+ [self ResetStub];
+ [self SendRpc:1];
+}
+
+- (void)testSequentialRpcs {
+ [self ResetStub];
+ [self SendRpc:10];
+}
+
++ (void)setUp {
+ grpc_test_init(0, NULL);
+}
+
+@end
+
diff --git a/test/cpp/cocoapods/test/Info.plist b/test/cpp/cocoapods/test/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/test/cpp/cocoapods/test/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/test/cpp/cocoapods/test/server_context_test_spouse_test.mm b/test/cpp/cocoapods/test/server_context_test_spouse_test.mm
new file mode 100644
index 0000000000..fd6878efbf
--- /dev/null
+++ b/test/cpp/cocoapods/test/server_context_test_spouse_test.mm
@@ -0,0 +1,100 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+// Hack TEST macro of gTest and make they conform XCTest style. We only
+// need test name (b), not test case name (a).
+#define TEST(a,b) - (void)test ## b
+#define ASSERT_TRUE XCTAssert
+#define ASSERT_EQ XCTAssertEqual
+
+#import <XCTest/XCTest.h>
+
+#include <grpc++/test/server_context_test_spouse.h>
+
+#include <cstring>
+#include <vector>
+
+#include <grpc++/impl/grpc_library.h>
+
+static grpc::internal::GrpcLibraryInitializer g_initializer;
+
+const char key1[] = "metadata-key1";
+const char key2[] = "metadata-key2";
+const char val1[] = "metadata-val1";
+const char val2[] = "metadata-val2";
+
+bool ClientMetadataContains(const grpc::ServerContext& context,
+ const grpc::string_ref& key,
+ const grpc::string_ref& value) {
+ const auto& client_metadata = context.client_metadata();
+ for (auto iter = client_metadata.begin(); iter != client_metadata.end();
+ ++iter) {
+ if (iter->first == key && iter->second == value) {
+ return true;
+ }
+ }
+ return false;
+}
+
+@interface ServerContextTestSpouseTest : XCTestCase
+
+@end
+
+@implementation ServerContextTestSpouseTest
+
+TEST(ServerContextTestSpouseTest, ClientMetadata) {
+ grpc::ServerContext context;
+ grpc::testing::ServerContextTestSpouse spouse(&context);
+
+ spouse.AddClientMetadata(key1, val1);
+ ASSERT_TRUE(ClientMetadataContains(context, key1, val1));
+
+ spouse.AddClientMetadata(key2, val2);
+ ASSERT_TRUE(ClientMetadataContains(context, key1, val1));
+ ASSERT_TRUE(ClientMetadataContains(context, key2, val2));
+}
+
+TEST(ServerContextTestSpouseTest, InitialMetadata) {
+ grpc::ServerContext context;
+ grpc::testing::ServerContextTestSpouse spouse(&context);
+ std::multimap<grpc::string, grpc::string> metadata;
+
+ context.AddInitialMetadata(key1, val1);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key1, val1));
+ ASSERT_EQ(metadata, spouse.GetInitialMetadata());
+
+ context.AddInitialMetadata(key2, val2);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key2, val2));
+ ASSERT_EQ(metadata, spouse.GetInitialMetadata());
+}
+
+TEST(ServerContextTestSpouseTest, TrailingMetadata) {
+ grpc::ServerContext context;
+ grpc::testing::ServerContextTestSpouse spouse(&context);
+ std::multimap<grpc::string, grpc::string> metadata;
+
+ context.AddTrailingMetadata(key1, val1);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key1, val1));
+ ASSERT_EQ(metadata, spouse.GetTrailingMetadata());
+
+ context.AddTrailingMetadata(key2, val2);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key2, val2));
+ ASSERT_EQ(metadata, spouse.GetTrailingMetadata());
+}
+
+@end
diff --git a/test/cpp/codegen/BUILD b/test/cpp/codegen/BUILD
index 8de46be816..1388dbc650 100644
--- a/test/cpp/codegen/BUILD
+++ b/test/cpp/codegen/BUILD
@@ -14,7 +14,7 @@
licenses(["notice"]) # Apache v2
-load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package")
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package", "grpc_cc_binary", "grpc_sh_test")
grpc_package(name = "test/cpp/codegen")
@@ -51,17 +51,14 @@ grpc_cc_test(
],
external_deps = [
"gtest",
+ "protobuf",
],
)
-grpc_cc_test(
+grpc_cc_binary(
name = "golden_file_test",
+ testonly = True,
srcs = ["golden_file_test.cc"],
- args = ["--generated_file_path=$(GENDIR)/src/proto/grpc/testing/"],
- data = [
- ":compiler_test_golden",
- "//src/proto/grpc/testing:_compiler_test_proto_grpc_codegen",
- ],
deps = [
"//:grpc++",
"//src/proto/grpc/testing:compiler_test_proto",
@@ -72,3 +69,14 @@ grpc_cc_test(
"gflags",
],
)
+
+grpc_sh_test(
+ name = "run_golden_file_test",
+ srcs = ["run_golden_file_test.sh"],
+ data = [
+ ":golden_file_test",
+ ":compiler_test_golden",
+ ":compiler_test_mock_golden",
+ "//src/proto/grpc/testing:_compiler_test_proto_grpc_codegen",
+ ],
+)
diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden
index 3d664e8825..026a94112a 100644
--- a/test/cpp/codegen/compiler_test_golden
+++ b/test/cpp/codegen/compiler_test_golden
@@ -39,7 +39,6 @@
namespace grpc {
class CompletionQueue;
class Channel;
-class RpcService;
class ServerCompletionQueue;
class ServerContext;
} // namespace grpc
@@ -169,10 +168,10 @@ class ServiceA final {
::grpc::ClientReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4Raw(::grpc::ClientContext* context) override;
::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* AsyncMethodA4Raw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* PrepareAsyncMethodA4Raw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) override;
- const ::grpc::RpcMethod rpcmethod_MethodA1_;
- const ::grpc::RpcMethod rpcmethod_MethodA2_;
- const ::grpc::RpcMethod rpcmethod_MethodA3_;
- const ::grpc::RpcMethod rpcmethod_MethodA4_;
+ const ::grpc::internal::RpcMethod rpcmethod_MethodA1_;
+ const ::grpc::internal::RpcMethod rpcmethod_MethodA2_;
+ const ::grpc::internal::RpcMethod rpcmethod_MethodA3_;
+ const ::grpc::internal::RpcMethod rpcmethod_MethodA4_;
};
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
@@ -352,7 +351,7 @@ class ServiceA final {
public:
WithStreamedUnaryMethod_MethodA1() {
::grpc::Service::MarkMethodStreamed(0,
- new ::grpc::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodA1<BaseClass>::StreamedMethodA1, this, std::placeholders::_1, std::placeholders::_2)));
+ new ::grpc::internal::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodA1<BaseClass>::StreamedMethodA1, this, std::placeholders::_1, std::placeholders::_2)));
}
~WithStreamedUnaryMethod_MethodA1() override {
BaseClassMustBeDerivedFromService(this);
@@ -373,7 +372,7 @@ class ServiceA final {
public:
WithSplitStreamingMethod_MethodA3() {
::grpc::Service::MarkMethodStreamed(2,
- new ::grpc::SplitServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithSplitStreamingMethod_MethodA3<BaseClass>::StreamedMethodA3, this, std::placeholders::_1, std::placeholders::_2)));
+ new ::grpc::internal::SplitServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithSplitStreamingMethod_MethodA3<BaseClass>::StreamedMethodA3, this, std::placeholders::_1, std::placeholders::_2)));
}
~WithSplitStreamingMethod_MethodA3() override {
BaseClassMustBeDerivedFromService(this);
@@ -427,7 +426,7 @@ class ServiceB final {
std::shared_ptr< ::grpc::ChannelInterface> channel_;
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
- const ::grpc::RpcMethod rpcmethod_MethodB1_;
+ const ::grpc::internal::RpcMethod rpcmethod_MethodB1_;
};
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
@@ -484,7 +483,7 @@ class ServiceB final {
public:
WithStreamedUnaryMethod_MethodB1() {
::grpc::Service::MarkMethodStreamed(0,
- new ::grpc::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodB1<BaseClass>::StreamedMethodB1, this, std::placeholders::_1, std::placeholders::_2)));
+ new ::grpc::internal::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodB1<BaseClass>::StreamedMethodB1, this, std::placeholders::_1, std::placeholders::_2)));
}
~WithStreamedUnaryMethod_MethodB1() override {
BaseClassMustBeDerivedFromService(this);
diff --git a/test/cpp/codegen/golden_file_test.cc b/test/cpp/codegen/golden_file_test.cc
index 5df1b8a16b..7e4d15a7c9 100644
--- a/test/cpp/codegen/golden_file_test.cc
+++ b/test/cpp/codegen/golden_file_test.cc
@@ -22,6 +22,13 @@
#include <gflags/gflags.h>
#include <gtest/gtest.h>
+// In some distros, gflags is in the namespace google, and in some others,
+// in gflags. This hack is enabling us to find both.
+namespace google {}
+namespace gflags {}
+using namespace google;
+using namespace gflags;
+
DEFINE_string(
generated_file_path, "",
"path to the directory containing generated files compiler_test.grpc.pb.h"
@@ -58,9 +65,9 @@ TEST(GoldenMockFileTest, TestGeneratedMockFile) {
kMockGoldenFilePath);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- ::google::ParseCommandLineFlags(&argc, &argv, true);
+ ParseCommandLineFlags(&argc, &argv, true);
if (FLAGS_generated_file_path.empty()) {
FLAGS_generated_file_path = "gens/src/proto/grpc/testing/";
}
diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc
index fd05c90e9d..cc355bb24a 100644
--- a/test/cpp/codegen/proto_utils_test.cc
+++ b/test/cpp/codegen/proto_utils_test.cc
@@ -16,15 +16,16 @@
*
*/
+#include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/proto_utils.h>
#include <grpc++/impl/grpc_library.h>
+#include <grpc/impl/codegen/byte_buffer.h>
+#include <grpc/slice.h>
#include <gtest/gtest.h>
namespace grpc {
namespace internal {
-static GrpcLibraryInitializer g_gli_initializer;
-
// Provide access to GrpcBufferWriter internals.
class GrpcBufferWriterPeer {
public:
@@ -44,35 +45,120 @@ class ProtoUtilsTest : public ::testing::Test {};
// GrpcBufferWriter Next()/Backup() invocations could result in a dangling
// pointer returned by Next() due to the interaction between grpc_slice inlining
// and GRPC_SLICE_START_PTR.
-TEST_F(ProtoUtilsTest, BackupNext) {
- // Ensure the GrpcBufferWriter internals are initialized.
- g_gli_initializer.summon();
-
+TEST_F(ProtoUtilsTest, TinyBackupThenNext) {
grpc_byte_buffer* bp;
- GrpcBufferWriter writer(&bp, 8192);
+ const int block_size = 1024;
+ GrpcBufferWriter writer(&bp, block_size, 8192);
GrpcBufferWriterPeer peer(&writer);
void* data;
int size;
// Allocate a slice.
ASSERT_TRUE(writer.Next(&data, &size));
- EXPECT_EQ(8192, size);
- // Return a single byte. Before the fix that this test acts as a regression
- // for, this would have resulted in an inlined backup slice.
+ EXPECT_EQ(block_size, size);
+ // Return a single byte.
writer.BackUp(1);
- EXPECT_TRUE(!peer.have_backup());
- // On the next allocation, the slice is non-inlined.
+ EXPECT_FALSE(peer.have_backup());
+ // On the next allocation, the returned slice is non-inlined.
ASSERT_TRUE(writer.Next(&data, &size));
- EXPECT_TRUE(peer.slice().refcount != NULL);
+ EXPECT_TRUE(peer.slice().refcount != nullptr);
+ EXPECT_EQ(block_size, size);
// Cleanup.
g_core_codegen_interface->grpc_byte_buffer_destroy(bp);
}
+namespace {
+
+// Set backup_size to 0 to indicate no backup is needed.
+void BufferWriterTest(int block_size, int total_size, int backup_size) {
+ grpc_byte_buffer* bp;
+ GrpcBufferWriter writer(&bp, block_size, total_size);
+
+ int written_size = 0;
+ void* data;
+ int size = 0;
+ bool backed_up_entire_slice = false;
+
+ while (written_size < total_size) {
+ EXPECT_TRUE(writer.Next(&data, &size));
+ EXPECT_GT(size, 0);
+ EXPECT_TRUE(data);
+ int write_size = size;
+ bool should_backup = false;
+ if (backup_size > 0 && size > backup_size) {
+ write_size = size - backup_size;
+ should_backup = true;
+ } else if (size == backup_size && !backed_up_entire_slice) {
+ // only backup entire slice once.
+ backed_up_entire_slice = true;
+ should_backup = true;
+ write_size = 0;
+ }
+ // May need a last backup.
+ if (write_size + written_size > total_size) {
+ write_size = total_size - written_size;
+ should_backup = true;
+ backup_size = size - write_size;
+ ASSERT_GT(backup_size, 0);
+ }
+ for (int i = 0; i < write_size; i++) {
+ ((uint8_t*)data)[i] = written_size % 128;
+ written_size++;
+ }
+ if (should_backup) {
+ writer.BackUp(backup_size);
+ }
+ }
+ EXPECT_EQ(grpc_byte_buffer_length(bp), (size_t)total_size);
+
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader, bp);
+ int read_bytes = 0;
+ while (read_bytes < total_size) {
+ grpc_slice s;
+ EXPECT_TRUE(grpc_byte_buffer_reader_next(&reader, &s));
+ for (size_t i = 0; i < GRPC_SLICE_LENGTH(s); i++) {
+ EXPECT_EQ(GRPC_SLICE_START_PTR(s)[i], read_bytes % 128);
+ read_bytes++;
+ }
+ grpc_slice_unref(s);
+ }
+ EXPECT_EQ(read_bytes, total_size);
+ grpc_byte_buffer_reader_destroy(&reader);
+ grpc_byte_buffer_destroy(bp);
+}
+
+TEST(WriterTest, TinyBlockTinyBackup) {
+ for (int i = 2; i < (int)GRPC_SLICE_INLINED_SIZE; i++) {
+ BufferWriterTest(i, 256, 1);
+ }
+}
+
+TEST(WriterTest, SmallBlockTinyBackup) { BufferWriterTest(64, 256, 1); }
+
+TEST(WriterTest, SmallBlockNoBackup) { BufferWriterTest(64, 256, 0); }
+
+TEST(WriterTest, SmallBlockFullBackup) { BufferWriterTest(64, 256, 64); }
+
+TEST(WriterTest, LargeBlockTinyBackup) { BufferWriterTest(4096, 8192, 1); }
+
+TEST(WriterTest, LargeBlockNoBackup) { BufferWriterTest(4096, 8192, 0); }
+
+TEST(WriterTest, LargeBlockFullBackup) { BufferWriterTest(4096, 8192, 4096); }
+
+TEST(WriterTest, LargeBlockLargeBackup) { BufferWriterTest(4096, 8192, 4095); }
+
+} // namespace
} // namespace internal
} // namespace grpc
int main(int argc, char** argv) {
+ // Ensure the GrpcBufferWriter internals are initialized.
+ grpc::internal::GrpcLibraryInitializer init;
+ init.summon();
+ grpc::GrpcLibraryCodegen lib;
+
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/test/cpp/codegen/run_golden_file_test.sh b/test/cpp/codegen/run_golden_file_test.sh
new file mode 100755
index 0000000000..cdfaa96a1c
--- /dev/null
+++ b/test/cpp/codegen/run_golden_file_test.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# 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.
+
+set -ex
+
+GENERATED_FILES_PATH="$TEST_SRCDIR/../../../../../genfiles/src/proto/grpc/testing/"
+test/cpp/codegen/golden_file_test --generated_file_path="$GENERATED_FILES_PATH"
diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_cpp_test.cc
index 212972d25d..7adc3102f4 100644
--- a/test/cpp/common/alarm_cpp_test.cc
+++ b/test/cpp/common/alarm_cpp_test.cc
@@ -142,7 +142,7 @@ TEST(AlarmTest, ZeroExpiry) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(0));
+ (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -158,7 +158,7 @@ TEST(AlarmTest, NegativeExpiry) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(0));
+ (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
diff --git a/test/cpp/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc
index e25d2a7597..fce409aa2f 100644
--- a/test/cpp/common/auth_property_iterator_test.cc
+++ b/test/cpp/common/auth_property_iterator_test.cc
@@ -22,9 +22,7 @@
#include "src/cpp/common/secure_auth_context.h"
#include "test/cpp/util/string_ref_helper.h"
-extern "C" {
#include "src/core/lib/security/context/security_context.h"
-}
using ::grpc::testing::ToString;
@@ -42,7 +40,7 @@ class TestAuthPropertyIterator : public AuthPropertyIterator {
class AuthPropertyIteratorTest : public ::testing::Test {
protected:
void SetUp() override {
- ctx_ = grpc_auth_context_create(NULL);
+ ctx_ = grpc_auth_context_create(nullptr);
grpc_auth_context_add_cstring_property(ctx_, "name", "chapi");
grpc_auth_context_add_cstring_property(ctx_, "name", "chapo");
grpc_auth_context_add_cstring_property(ctx_, "foo", "bar");
diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc
index cfe64f11b1..f330c01281 100644
--- a/test/cpp/common/channel_arguments_test.cc
+++ b/test/cpp/common/channel_arguments_test.cc
@@ -23,10 +23,8 @@
#include <grpc/support/useful.h>
#include <gtest/gtest.h>
-extern "C" {
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/socket_mutator.h"
-}
namespace grpc {
namespace testing {
@@ -72,7 +70,7 @@ grpc_socket_mutator_vtable test_mutator_vtable = {
TestSocketMutator::TestSocketMutator() {
grpc_socket_mutator_init(this, &test_mutator_vtable);
}
-}
+} // namespace
class ChannelArgumentsTest : public ::testing::Test {
protected:
@@ -251,5 +249,8 @@ TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ grpc_init();
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
}
diff --git a/test/cpp/common/channel_filter_test.cc b/test/cpp/common/channel_filter_test.cc
index 638518107b..7bdd53f9e7 100644
--- a/test/cpp/common/channel_filter_test.cc
+++ b/test/cpp/common/channel_filter_test.cc
@@ -28,7 +28,7 @@ class MyChannelData : public ChannelData {
public:
MyChannelData() {}
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) override {
(void)args->channel_args; // Make sure field is available.
return GRPC_ERROR_NONE;
@@ -39,7 +39,7 @@ class MyCallData : public CallData {
public:
MyCallData() {}
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ grpc_error* Init(grpc_call_element* elem,
const grpc_call_element_args* args) override {
(void)args->path; // Make sure field is available.
return GRPC_ERROR_NONE;
diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc
index 91c7a3b5df..7a0530c20a 100644
--- a/test/cpp/common/secure_auth_context_test.cc
+++ b/test/cpp/common/secure_auth_context_test.cc
@@ -22,9 +22,7 @@
#include <gtest/gtest.h>
#include "test/cpp/util/string_ref_helper.h"
-extern "C" {
#include "src/core/lib/security/context/security_context.h"
-}
using grpc::testing::ToString;
@@ -44,7 +42,7 @@ TEST_F(SecureAuthContextTest, EmptyContext) {
}
TEST_F(SecureAuthContextTest, Properties) {
- grpc_auth_context* ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(nullptr);
SecureAuthContext context(ctx, true);
context.AddProperty("name", "chapi");
context.AddProperty("name", "chapo");
@@ -62,7 +60,7 @@ TEST_F(SecureAuthContextTest, Properties) {
}
TEST_F(SecureAuthContextTest, Iterators) {
- grpc_auth_context* ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(nullptr);
SecureAuthContext context(ctx, true);
context.AddProperty("name", "chapi");
context.AddProperty("name", "chapo");
diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD
index b29a13d4fb..27e8da1ff1 100644
--- a/test/cpp/end2end/BUILD
+++ b/test/cpp/end2end/BUILD
@@ -14,27 +14,33 @@
licenses(["notice"]) # Apache v2
-load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package")
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package", "grpc_cc_binary")
-grpc_package(name = "test/cpp/end2end", visibility = "public") # Allows external users to implement end2end tests.
+grpc_package(
+ name = "test/cpp/end2end",
+ visibility = "public",
+) # Allows external users to implement end2end tests.
grpc_cc_library(
name = "test_service_impl",
testonly = True,
srcs = ["test_service_impl.cc"],
hdrs = ["test_service_impl.h"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//src/proto/grpc/testing:echo_proto",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "async_end2end_test",
srcs = ["async_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -47,14 +53,17 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "client_crash_test",
srcs = ["client_crash_test.cc"],
+ data = [
+ ":client_crash_test_server",
+ ],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -66,14 +75,16 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
-grpc_cc_test(
+grpc_cc_binary(
name = "client_crash_test_server",
+ testonly = True,
srcs = ["client_crash_test_server.cc"],
+ external_deps = [
+ "gflags",
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -85,16 +96,15 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gflags",
- "gtest",
- ],
)
grpc_cc_library(
name = "end2end_test_lib",
- srcs = ["end2end_test.cc"],
testonly = True,
+ srcs = ["end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -107,40 +117,76 @@ grpc_cc_library(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+)
+
+grpc_cc_test(
+ name = "server_early_return_test",
+ srcs = ["server_early_return_test.cc"],
external_deps = [
"gtest",
],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
)
grpc_cc_test(
name = "end2end_test",
deps = [
- ":end2end_test_lib"
+ ":end2end_test_lib",
],
)
grpc_cc_test(
- name = "filter_end2end_test",
- srcs = ["filter_end2end_test.cc"],
+ name = "exception_test",
+ srcs = ["exception_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
- "//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+)
+
+grpc_cc_test(
+ name = "filter_end2end_test",
+ srcs = ["filter_end2end_test.cc"],
external_deps = [
"gtest",
],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
)
grpc_cc_test(
name = "generic_end2end_test",
srcs = ["generic_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -152,14 +198,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "hybrid_end2end_test",
srcs = ["hybrid_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -172,14 +218,15 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "mock_test",
srcs = ["mock_test.cc"],
+ external_deps = [
+ "gmock",
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -192,15 +239,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gmock",
- "gtest",
- ],
)
grpc_cc_test(
name = "client_lb_end2end_test",
srcs = ["client_lb_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -213,37 +259,38 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "grpclb_end2end_test",
srcs = ["grpclb_end2end_test.cc"],
+ external_deps = [
+ "gmock",
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
"//:grpc",
"//:grpc++",
+ "//:grpc_resolver_fake",
"//src/proto/grpc/lb/v1:load_balancer_proto",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
- "//:grpc_resolver_fake",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gmock",
- "gtest",
- ],
)
grpc_cc_test(
name = "proto_server_reflection_test",
srcs = ["proto_server_reflection_test.cc"],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -258,15 +305,14 @@ grpc_cc_test(
"//test/cpp/util:grpc++_proto_reflection_desc_db",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- "gflags",
- ],
)
grpc_cc_test(
name = "server_builder_plugin_test",
srcs = ["server_builder_plugin_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -279,14 +325,17 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "server_crash_test",
srcs = ["server_crash_test.cc"],
+ data = [
+ ":server_crash_test_client",
+ ],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -298,14 +347,16 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
-grpc_cc_test(
+grpc_cc_binary(
name = "server_crash_test_client",
+ testonly = True,
srcs = ["server_crash_test_client.cc"],
+ external_deps = [
+ "gflags",
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -317,15 +368,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gflags",
- "gtest",
- ],
)
grpc_cc_test(
name = "shutdown_test",
srcs = ["shutdown_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -337,14 +387,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "streaming_throughput_test",
srcs = ["streaming_throughput_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -356,14 +406,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "thread_stress_test",
srcs = ["thread_stress_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -375,7 +425,4 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 41090d161a..44cd81a6a4 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -28,11 +28,13 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/tls.h>
+#include "src/core/lib/gpr/env.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"
@@ -99,10 +101,26 @@ class PollingOverrider {
class Verifier {
public:
- explicit Verifier(bool spin) : spin_(spin) {}
+ explicit Verifier(bool spin) : spin_(spin), lambda_run_(false) {}
// Expect sets the expected ok value for a specific tag
Verifier& Expect(int i, bool expect_ok) {
- expectations_[tag(i)] = expect_ok;
+ return ExpectUnless(i, expect_ok, false);
+ }
+ // ExpectUnless sets the expected ok value for a specific tag
+ // unless the tag was already marked seen (as a result of ExpectMaybe)
+ Verifier& ExpectUnless(int i, bool expect_ok, bool seen) {
+ if (!seen) {
+ expectations_[tag(i)] = expect_ok;
+ }
+ return *this;
+ }
+ // ExpectMaybe sets the expected ok value for a specific tag, but does not
+ // require it to appear
+ // If it does, sets *seen to true
+ Verifier& ExpectMaybe(int i, bool expect_ok, bool* seen) {
+ if (!*seen) {
+ maybe_expectations_[tag(i)] = MaybeExpect{expect_ok, seen};
+ }
return *this;
}
@@ -122,15 +140,22 @@ class Verifier {
} else {
EXPECT_TRUE(cq->Next(&got_tag, &ok));
}
- auto it = expectations_.find(got_tag);
- EXPECT_TRUE(it != expectations_.end());
- if (!ignore_ok) {
- EXPECT_EQ(it->second, ok);
- }
- expectations_.erase(it);
+ GotTag(got_tag, ok, ignore_ok);
return detag(got_tag);
}
+ template <typename T>
+ CompletionQueue::NextStatus DoOnceThenAsyncNext(
+ CompletionQueue* cq, void** got_tag, bool* ok, T deadline,
+ std::function<void(void)> lambda) {
+ if (lambda_run_) {
+ return cq->AsyncNext(got_tag, ok, deadline);
+ } else {
+ lambda_run_ = true;
+ return cq->DoThenAsyncNext(lambda, got_tag, ok, deadline);
+ }
+ }
+
// Verify keeps calling Next until all currently set
// expected tags are complete
void Verify(CompletionQueue* cq) { Verify(cq, false); }
@@ -138,11 +163,12 @@ class Verifier {
// This version of Verify allows optionally ignoring the
// outcome of the expectation
void Verify(CompletionQueue* cq, bool ignore_ok) {
- GPR_ASSERT(!expectations_.empty());
+ GPR_ASSERT(!expectations_.empty() || !maybe_expectations_.empty());
while (!expectations_.empty()) {
Next(cq, ignore_ok);
}
}
+
// This version of Verify stops after a certain deadline
void Verify(CompletionQueue* cq,
std::chrono::system_clock::time_point deadline) {
@@ -177,17 +203,86 @@ class Verifier {
EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline),
CompletionQueue::GOT_EVENT);
}
- auto it = expectations_.find(got_tag);
- EXPECT_TRUE(it != expectations_.end());
- EXPECT_EQ(it->second, ok);
- expectations_.erase(it);
+ GotTag(got_tag, ok, false);
+ }
+ }
+ }
+
+ // This version of Verify stops after a certain deadline, and uses the
+ // DoThenAsyncNext API
+ // to call the lambda
+ void Verify(CompletionQueue* cq,
+ std::chrono::system_clock::time_point deadline,
+ std::function<void(void)> lambda) {
+ if (expectations_.empty()) {
+ bool ok;
+ void* got_tag;
+ if (spin_) {
+ while (std::chrono::system_clock::now() < deadline) {
+ EXPECT_EQ(DoOnceThenAsyncNext(cq, &got_tag, &ok, deadline, lambda),
+ CompletionQueue::TIMEOUT);
+ }
+ } else {
+ EXPECT_EQ(DoOnceThenAsyncNext(cq, &got_tag, &ok, deadline, lambda),
+ CompletionQueue::TIMEOUT);
+ }
+ } else {
+ while (!expectations_.empty()) {
+ bool ok;
+ void* got_tag;
+ if (spin_) {
+ for (;;) {
+ GPR_ASSERT(std::chrono::system_clock::now() < deadline);
+ auto r = DoOnceThenAsyncNext(
+ cq, &got_tag, &ok, gpr_time_0(GPR_CLOCK_REALTIME), lambda);
+ if (r == CompletionQueue::TIMEOUT) continue;
+ if (r == CompletionQueue::GOT_EVENT) break;
+ gpr_log(GPR_ERROR, "unexpected result from AsyncNext");
+ abort();
+ }
+ } else {
+ EXPECT_EQ(DoOnceThenAsyncNext(cq, &got_tag, &ok, deadline, lambda),
+ CompletionQueue::GOT_EVENT);
+ }
+ GotTag(got_tag, ok, false);
}
}
}
private:
+ void GotTag(void* got_tag, bool ok, bool ignore_ok) {
+ auto it = expectations_.find(got_tag);
+ if (it != expectations_.end()) {
+ if (!ignore_ok) {
+ EXPECT_EQ(it->second, ok);
+ }
+ expectations_.erase(it);
+ } else {
+ auto it2 = maybe_expectations_.find(got_tag);
+ if (it2 != maybe_expectations_.end()) {
+ if (it2->second.seen != nullptr) {
+ EXPECT_FALSE(*it2->second.seen);
+ *it2->second.seen = true;
+ }
+ if (!ignore_ok) {
+ EXPECT_EQ(it2->second.ok, ok);
+ }
+ } else {
+ gpr_log(GPR_ERROR, "Unexpected tag: %p", tag);
+ abort();
+ }
+ }
+ }
+
+ struct MaybeExpect {
+ bool ok;
+ bool* seen;
+ };
+
std::map<void*, bool> expectations_;
+ std::map<void*, MaybeExpect> maybe_expectations_;
bool spin_;
+ bool lambda_run_;
};
bool plugin_has_sync_methods(std::unique_ptr<ServerBuilderPlugin>& plugin) {
@@ -223,11 +318,8 @@ class TestScenario {
bool disable_blocking;
bool inproc;
bool health_check_service;
- // Although the below grpc::string's are logically const, we can't declare
- // them const because of a limitation in the way old compilers (e.g., gcc-4.4)
- // manage vector insertion using a copy constructor
- grpc::string credentials_type;
- grpc::string message_content;
+ const grpc::string credentials_type;
+ const grpc::string message_content;
};
static std::ostream& operator<<(std::ostream& out,
@@ -366,9 +458,18 @@ TEST_P(AsyncEnd2endTest, SequentialRpcs) {
}
TEST_P(AsyncEnd2endTest, ReconnectChannel) {
+ // GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS is set to 100ms in main()
if (GetParam().inproc) {
return;
}
+ int poller_slowdown_factor = 1;
+ // It needs 2 pollset_works to reconnect the channel with polling engine
+ // "poll"
+ char* s = gpr_getenv("GRPC_POLL_STRATEGY");
+ if (s != nullptr && 0 == strcmp(s, "poll")) {
+ poller_slowdown_factor = 2;
+ }
+ gpr_free(s);
ResetStub();
SendRpc(1);
server_->Shutdown();
@@ -378,10 +479,13 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) {
while (cq_->Next(&ignored_tag, &ignored_ok))
;
BuildAndStartServer();
- // It needs more than kConnectivityCheckIntervalMsec time to reconnect the
- // channel.
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_millis(1600, GPR_TIMESPAN)));
+ // It needs more than GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS time to
+ // reconnect the channel.
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(
+ 300 * poller_slowdown_factor * grpc_test_slowdown_factor(),
+ GPR_TIMESPAN)));
SendRpc(1);
}
@@ -455,6 +559,60 @@ TEST_P(AsyncEnd2endTest, AsyncNextRpc) {
EXPECT_TRUE(recv_status.ok());
}
+// Test a simple RPC using the async version of Next
+TEST_P(AsyncEnd2endTest, DoThenAsyncNextRpc) {
+ ResetStub();
+
+ EchoRequest send_request;
+ EchoRequest recv_request;
+ EchoResponse send_response;
+ EchoResponse recv_response;
+ Status recv_status;
+
+ ClientContext cli_ctx;
+ ServerContext srv_ctx;
+ grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx);
+
+ send_request.set_message(GetParam().message_content);
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
+
+ std::chrono::system_clock::time_point time_now(
+ std::chrono::system_clock::now());
+ std::chrono::system_clock::time_point time_limit(
+ std::chrono::system_clock::now() + std::chrono::seconds(10));
+ Verifier(GetParam().disable_blocking).Verify(cq_.get(), time_now);
+ Verifier(GetParam().disable_blocking).Verify(cq_.get(), time_now);
+
+ auto resp_writer_ptr = &response_writer;
+ auto lambda_2 = [&, this, resp_writer_ptr]() {
+ gpr_log(GPR_ERROR, "CALLED");
+ service_->RequestEcho(&srv_ctx, &recv_request, resp_writer_ptr, cq_.get(),
+ cq_.get(), tag(2));
+ };
+
+ Verifier(GetParam().disable_blocking)
+ .Expect(2, true)
+ .Verify(cq_.get(), time_limit, lambda_2);
+ EXPECT_EQ(send_request.message(), recv_request.message());
+
+ auto recv_resp_ptr = &recv_response;
+ auto status_ptr = &recv_status;
+ send_response.set_message(recv_request.message());
+ auto lambda_3 = [&, this, resp_writer_ptr, send_response]() {
+ resp_writer_ptr->Finish(send_response, Status::OK, tag(3));
+ };
+ response_reader->Finish(recv_resp_ptr, status_ptr, tag(4));
+ Verifier(GetParam().disable_blocking)
+ .Expect(3, true)
+ .Expect(4, true)
+ .Verify(cq_.get(), std::chrono::system_clock::time_point::max(),
+ lambda_3);
+
+ EXPECT_EQ(send_response.message(), recv_response.message());
+ EXPECT_TRUE(recv_status.ok());
+}
+
// Two pings and a final pong.
TEST_P(AsyncEnd2endTest, SimpleClientStreaming) {
ResetStub();
@@ -539,31 +697,19 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) {
cli_stream->Write(send_request, tag(3));
- // 65536(64KB) is the default flow control window size. Should change this
- // number when default flow control window size changes. For the write of
- // send_request larger than the flow control window size, tag:3 will not come
- // up until server read is initiated. For write of send_request smaller than
- // the flow control window size, the request can take the free ride with
- // initial metadata due to coalescing, thus write tag:3 will come up here.
- if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
- Verifier(GetParam().disable_blocking)
- .Expect(2, true)
- .Expect(3, true)
- .Verify(cq_.get());
- } else {
- Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
- }
+ bool seen3 = false;
+
+ Verifier(GetParam().disable_blocking)
+ .Expect(2, true)
+ .ExpectMaybe(3, true, &seen3)
+ .Verify(cq_.get());
srv_stream.Read(&recv_request, tag(4));
- if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
- Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
- } else {
- Verifier(GetParam().disable_blocking)
- .Expect(3, true)
- .Expect(4, true)
- .Verify(cq_.get());
- }
+ Verifier(GetParam().disable_blocking)
+ .ExpectUnless(3, true, seen3)
+ .Expect(4, true)
+ .Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
@@ -834,31 +980,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) {
cli_stream->WriteLast(send_request, WriteOptions(), tag(3));
- // 65536(64KB) is the default flow control window size. Should change this
- // number when default flow control window size changes. For the write of
- // send_request larger than the flow control window size, tag:3 will not come
- // up until server read is initiated. For write of send_request smaller than
- // the flow control window size, the request can take the free ride with
- // initial metadata due to coalescing, thus write tag:3 will come up here.
- if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
- Verifier(GetParam().disable_blocking)
- .Expect(2, true)
- .Expect(3, true)
- .Verify(cq_.get());
- } else {
- Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
- }
+ bool seen3 = false;
+
+ Verifier(GetParam().disable_blocking)
+ .Expect(2, true)
+ .ExpectMaybe(3, true, &seen3)
+ .Verify(cq_.get());
srv_stream.Read(&recv_request, tag(4));
- if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
- Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
- } else {
- Verifier(GetParam().disable_blocking)
- .Expect(3, true)
- .Expect(4, true)
- .Verify(cq_.get());
- }
+ Verifier(GetParam().disable_blocking)
+ .ExpectUnless(3, true, seen3)
+ .Expect(4, true)
+ .Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
srv_stream.Read(&recv_request, tag(5));
@@ -902,31 +1036,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) {
cli_stream->WriteLast(send_request, WriteOptions(), tag(3));
- // 65536(64KB) is the default flow control window size. Should change this
- // number when default flow control window size changes. For the write of
- // send_request larger than the flow control window size, tag:3 will not come
- // up until server read is initiated. For write of send_request smaller than
- // the flow control window size, the request can take the free ride with
- // initial metadata due to coalescing, thus write tag:3 will come up here.
- if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
- Verifier(GetParam().disable_blocking)
- .Expect(2, true)
- .Expect(3, true)
- .Verify(cq_.get());
- } else {
- Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
- }
+ bool seen3 = false;
+
+ Verifier(GetParam().disable_blocking)
+ .Expect(2, true)
+ .ExpectMaybe(3, true, &seen3)
+ .Verify(cq_.get());
srv_stream.Read(&recv_request, tag(4));
- if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
- Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
- } else {
- Verifier(GetParam().disable_blocking)
- .Expect(3, true)
- .Expect(4, true)
- .Verify(cq_.get());
- }
+ Verifier(GetParam().disable_blocking)
+ .ExpectUnless(3, true, seen3)
+ .Expect(4, true)
+ .Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
srv_stream.Read(&recv_request, tag(5));
@@ -1305,7 +1427,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
ServerTryCancelRequestPhase server_try_cancel) {
ResetStub();
- EchoRequest send_request;
EchoRequest recv_request;
EchoResponse send_response;
EchoResponse recv_response;
@@ -1316,31 +1437,24 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx);
// Initiate the 'RequestStream' call on client
+ CompletionQueue cli_cq;
+
std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream(
- stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1)));
- Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get());
+ stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq, tag(1)));
// On the server, request to be notified of 'RequestStream' calls
// and receive the 'RequestStream' call just made by the client
srv_ctx.AsyncNotifyWhenDone(tag(11));
service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
+ std::thread t1([this, &cli_cq] {
+ Verifier(GetParam().disable_blocking).Expect(1, true).Verify(&cli_cq);
+ });
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
-
- // Client sends 3 messages (tags 3, 4 and 5)
- for (int tag_idx = 3; tag_idx <= 5; tag_idx++) {
- send_request.set_message("Ping " + grpc::to_string(tag_idx));
- cli_stream->Write(send_request, tag(tag_idx));
- Verifier(GetParam().disable_blocking)
- .Expect(tag_idx, true)
- .Verify(cq_.get());
- }
- cli_stream->WritesDone(tag(6));
- Verifier(GetParam().disable_blocking).Expect(6, true).Verify(cq_.get());
+ t1.join();
bool expected_server_cq_result = true;
- bool ignore_cq_result = false;
- bool want_done_tag = false;
+ bool expected_client_cq_result = true;
if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
srv_ctx.TryCancel();
@@ -1348,10 +1462,36 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
EXPECT_TRUE(srv_ctx.IsCancelled());
// Since cancellation is done before server reads any results, we know
- // for sure that all cq results will return false from this point forward
+ // for sure that all server cq results will return false from this
+ // point forward
expected_server_cq_result = false;
+ expected_client_cq_result = false;
}
+ bool ignore_client_cq_result =
+ (server_try_cancel == CANCEL_DURING_PROCESSING) ||
+ (server_try_cancel == CANCEL_BEFORE_PROCESSING);
+
+ std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result,
+ &ignore_client_cq_result, this] {
+ EchoRequest send_request;
+ // Client sends 3 messages (tags 3, 4 and 5)
+ for (int tag_idx = 3; tag_idx <= 5; tag_idx++) {
+ send_request.set_message("Ping " + grpc::to_string(tag_idx));
+ cli_stream->Write(send_request, tag(tag_idx));
+ Verifier(GetParam().disable_blocking)
+ .Expect(tag_idx, expected_client_cq_result)
+ .Verify(&cli_cq, ignore_client_cq_result);
+ }
+ cli_stream->WritesDone(tag(6));
+ // Ignore ok on WritesDone since cancel can affect it
+ Verifier(GetParam().disable_blocking)
+ .Expect(6, expected_client_cq_result)
+ .Verify(&cli_cq, ignore_client_cq_result);
+ });
+
+ bool ignore_cq_result = false;
+ bool want_done_tag = false;
std::thread* server_try_cancel_thd = nullptr;
auto verif = Verifier(GetParam().disable_blocking);
@@ -1388,6 +1528,8 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
}
}
+ cli_thread.join();
+
if (server_try_cancel_thd != nullptr) {
server_try_cancel_thd->join();
delete server_try_cancel_thd;
@@ -1416,9 +1558,15 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Client will see the cancellation
cli_stream->Finish(&recv_status, tag(10));
- Verifier(GetParam().disable_blocking).Expect(10, true).Verify(cq_.get());
+ Verifier(GetParam().disable_blocking).Expect(10, true).Verify(&cli_cq);
EXPECT_FALSE(recv_status.ok());
EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code());
+
+ cli_cq.Shutdown();
+ void* dummy_tag;
+ bool dummy_ok;
+ while (cli_cq.Next(&dummy_tag, &dummy_ok)) {
+ }
}
// Helper for testing server-streaming RPCs which are cancelled on the server.
@@ -1440,7 +1588,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
EchoRequest send_request;
EchoRequest recv_request;
EchoResponse send_response;
- EchoResponse recv_response;
Status recv_status;
ClientContext cli_ctx;
ServerContext srv_ctx;
@@ -1448,20 +1595,29 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
send_request.set_message("Ping");
// Initiate the 'ResponseStream' call on the client
+ CompletionQueue cli_cq;
std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream(
- stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1)));
- Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get());
+ stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq, tag(1)));
// On the server, request to be notified of 'ResponseStream' calls and
// receive the call just made by the client
srv_ctx.AsyncNotifyWhenDone(tag(11));
service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream,
cq_.get(), cq_.get(), tag(2));
+
+ std::thread t1([this, &cli_cq] {
+ Verifier(GetParam().disable_blocking).Expect(1, true).Verify(&cli_cq);
+ });
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
+ t1.join();
+
EXPECT_EQ(send_request.message(), recv_request.message());
bool expected_cq_result = true;
bool ignore_cq_result = false;
bool want_done_tag = false;
+ bool expected_client_cq_result = true;
+ bool ignore_client_cq_result =
+ (server_try_cancel != CANCEL_BEFORE_PROCESSING);
if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
srv_ctx.TryCancel();
@@ -1471,8 +1627,21 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// We know for sure that all cq results will be false from this point
// since the server cancelled the RPC
expected_cq_result = false;
+ expected_client_cq_result = false;
}
+ std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result,
+ &ignore_client_cq_result, this] {
+ // Client attempts to read the three messages from the server
+ for (int tag_idx = 6; tag_idx <= 8; tag_idx++) {
+ EchoResponse recv_response;
+ cli_stream->Read(&recv_response, tag(tag_idx));
+ Verifier(GetParam().disable_blocking)
+ .Expect(tag_idx, expected_client_cq_result)
+ .Verify(&cli_cq, ignore_client_cq_result);
+ }
+ });
+
std::thread* server_try_cancel_thd = nullptr;
auto verif = Verifier(GetParam().disable_blocking);
@@ -1520,10 +1689,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
srv_ctx.TryCancel();
want_done_tag = true;
verif.Expect(11, true);
-
- // Client reads may fail bacause it is notified that the stream is
- // cancelled.
- ignore_cq_result = true;
}
if (want_done_tag) {
@@ -1532,13 +1697,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
want_done_tag = false;
}
- // Client attemts to read the three messages from the server
- for (int tag_idx = 6; tag_idx <= 8; tag_idx++) {
- cli_stream->Read(&recv_response, tag(tag_idx));
- Verifier(GetParam().disable_blocking)
- .Expect(tag_idx, expected_cq_result)
- .Verify(cq_.get(), ignore_cq_result);
- }
+ cli_thread.join();
// The RPC has been cancelled at this point for sure (i.e irrespective of
// the value of `server_try_cancel` is). So, from this point forward, we
@@ -1550,9 +1709,15 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Client will see the cancellation
cli_stream->Finish(&recv_status, tag(10));
- Verifier(GetParam().disable_blocking).Expect(10, true).Verify(cq_.get());
+ Verifier(GetParam().disable_blocking).Expect(10, true).Verify(&cli_cq);
EXPECT_FALSE(recv_status.ok());
EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code());
+
+ cli_cq.Shutdown();
+ void* dummy_tag;
+ bool dummy_ok;
+ while (cli_cq.Next(&dummy_tag, &dummy_ok)) {
+ }
}
// Helper for testing bidirectinal-streaming RPCs which are cancelled on the
@@ -1585,38 +1750,52 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Initiate the call from the client side
std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>>
cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1)));
- Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get());
// On the server, request to be notified of the 'BidiStream' call and
// receive the call just made by the client
srv_ctx.AsyncNotifyWhenDone(tag(11));
service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
- Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
+ Verifier(GetParam().disable_blocking)
+ .Expect(1, true)
+ .Expect(2, true)
+ .Verify(cq_.get());
+
+ auto verif = Verifier(GetParam().disable_blocking);
// Client sends the first and the only message
send_request.set_message("Ping");
cli_stream->Write(send_request, tag(3));
- Verifier(GetParam().disable_blocking).Expect(3, true).Verify(cq_.get());
+ verif.Expect(3, true);
bool expected_cq_result = true;
bool ignore_cq_result = false;
bool want_done_tag = false;
+ int got_tag, got_tag2;
+ bool tag_3_done = false;
+
if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
srv_ctx.TryCancel();
- Verifier(GetParam().disable_blocking).Expect(11, true).Verify(cq_.get());
- EXPECT_TRUE(srv_ctx.IsCancelled());
-
- // We know for sure that all cq results will be false from this point
- // since the server cancelled the RPC
+ verif.Expect(11, true);
+ // We know for sure that all server cq results will be false from
+ // this point since the server cancelled the RPC. However, we can't
+ // say for sure about the client
expected_cq_result = false;
+ ignore_cq_result = true;
+
+ do {
+ got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT(((got_tag == 3) && !tag_3_done) || (got_tag == 11));
+ if (got_tag == 3) {
+ tag_3_done = true;
+ }
+ } while (got_tag != 11);
+ EXPECT_TRUE(srv_ctx.IsCancelled());
}
std::thread* server_try_cancel_thd = nullptr;
- auto verif = Verifier(GetParam().disable_blocking);
-
if (server_try_cancel == CANCEL_DURING_PROCESSING) {
server_try_cancel_thd =
new std::thread(&ServerContext::TryCancel, &srv_ctx);
@@ -1631,39 +1810,42 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
verif.Expect(11, true);
}
- int got_tag;
srv_stream.Read(&recv_request, tag(4));
verif.Expect(4, expected_cq_result);
- got_tag = verif.Next(cq_.get(), ignore_cq_result);
- GPR_ASSERT((got_tag == 4) || (got_tag == 11 && want_done_tag));
- if (got_tag == 11) {
+ got_tag = tag_3_done ? 3 : verif.Next(cq_.get(), ignore_cq_result);
+ got_tag2 = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 3) || (got_tag == 4) ||
+ (got_tag == 11 && want_done_tag));
+ GPR_ASSERT((got_tag2 == 3) || (got_tag2 == 4) ||
+ (got_tag2 == 11 && want_done_tag));
+ // If we get 3 and 4, we don't need to wait for 11, but if
+ // we get 11, we should also clear 3 and 4
+ if (got_tag + got_tag2 != 7) {
EXPECT_TRUE(srv_ctx.IsCancelled());
want_done_tag = false;
- // Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 4);
+ got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 3) || (got_tag == 4));
}
send_response.set_message("Pong");
srv_stream.Write(send_response, tag(5));
verif.Expect(5, expected_cq_result);
- got_tag = verif.Next(cq_.get(), ignore_cq_result);
- GPR_ASSERT((got_tag == 5) || (got_tag == 11 && want_done_tag));
- if (got_tag == 11) {
- EXPECT_TRUE(srv_ctx.IsCancelled());
- want_done_tag = false;
- // Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 5);
- }
cli_stream->Read(&recv_response, tag(6));
verif.Expect(6, expected_cq_result);
got_tag = verif.Next(cq_.get(), ignore_cq_result);
- GPR_ASSERT((got_tag == 6) || (got_tag == 11 && want_done_tag));
- if (got_tag == 11) {
+ got_tag2 = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 5) || (got_tag == 6) ||
+ (got_tag == 11 && want_done_tag));
+ GPR_ASSERT((got_tag2 == 5) || (got_tag2 == 6) ||
+ (got_tag2 == 11 && want_done_tag));
+ // If we get 5 and 6, we don't need to wait for 11, but if
+ // we get 11, we should also clear 5 and 6
+ if (got_tag + got_tag2 != 11) {
EXPECT_TRUE(srv_ctx.IsCancelled());
want_done_tag = false;
- // Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 6);
+ got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 5) || (got_tag == 6));
}
// This is expected to succeed in all cases
@@ -1788,7 +1970,7 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking,
GPR_ASSERT(!credentials_types.empty());
messages.push_back("Hello");
- for (int sz = 1; sz < test_big_limit; sz *= 2) {
+ for (int sz = 1; sz <= test_big_limit; sz *= 32) {
grpc::string big_msg;
for (int i = 0; i < sz * 1024; i++) {
char c = 'a' + (i % 26);
@@ -1831,6 +2013,9 @@ INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel,
} // namespace grpc
int main(int argc, char** argv) {
+ // Change the backup poll interval from 5s to 100ms to speed up the
+ // ReconnectChannel test
+ gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "100");
grpc_test_init(argc, argv);
gpr_tls_init(&g_is_async_end2end_test);
::testing::InitGoogleTest(&argc, argv);
diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc
index 4d2304feca..f34b27511b 100644
--- a/test/cpp/end2end/client_crash_test.cc
+++ b/test/cpp/end2end/client_crash_test.cc
@@ -56,7 +56,8 @@ class CrashTest : public ::testing::Test {
addr_stream << "localhost:" << port;
auto addr = addr_stream.str();
server_.reset(new SubProcess({
- g_root + "/client_crash_test_server", "--address=" + addr,
+ g_root + "/client_crash_test_server",
+ "--address=" + addr,
}));
GPR_ASSERT(server_);
return grpc::testing::EchoTestService::NewStub(
diff --git a/test/cpp/end2end/client_crash_test_server.cc b/test/cpp/end2end/client_crash_test_server.cc
index 01dcd40f9a..887504d308 100644
--- a/test/cpp/end2end/client_crash_test_server.cc
+++ b/test/cpp/end2end/client_crash_test_server.cc
@@ -68,8 +68,8 @@ void RunServer() {
std::cout << "Server listening on " << FLAGS_address << std::endl;
server->Wait();
}
-}
-}
+} // namespace testing
+} // namespace grpc
int main(int argc, char** argv) {
ParseCommandLineFlags(&argc, &argv, true);
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index c236f76e89..328ad86061 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <memory>
#include <mutex>
+#include <random>
#include <thread>
#include <grpc++/channel.h>
@@ -28,15 +29,16 @@
#include <grpc++/server_builder.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-extern "C" {
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/ext/filters/client_channel/subchannel_index.h"
-}
+#include "src/core/lib/backoff/backoff.h"
+#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@@ -49,10 +51,33 @@ using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
+// defined in tcp_client_posix.c
+extern void (*grpc_tcp_client_connect_impl)(
+ grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr, grpc_millis deadline);
+
+const auto original_tcp_connect_fn = grpc_tcp_client_connect_impl;
+
namespace grpc {
namespace testing {
namespace {
+gpr_atm g_connection_delay_ms;
+
+void tcp_client_connect_with_delay(grpc_closure* closure, grpc_endpoint** ep,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
+ const int delay_ms = gpr_atm_acq_load(&g_connection_delay_ms);
+ if (delay_ms > 0) {
+ gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(delay_ms));
+ }
+ original_tcp_connect_fn(closure, ep, interested_parties, channel_args, addr,
+ deadline + delay_ms);
+}
+
// Subclass of TestServiceImpl that increments a request counter for
// every call to the Echo RPC.
class MyTestServiceImpl : public TestServiceImpl {
@@ -86,7 +111,11 @@ class MyTestServiceImpl : public TestServiceImpl {
class ClientLbEnd2endTest : public ::testing::Test {
protected:
ClientLbEnd2endTest()
- : server_host_("localhost"), kRequestMessage_("Live long and prosper.") {}
+ : server_host_("localhost"), kRequestMessage_("Live long and prosper.") {
+ // Make the backup poller poll very frequently in order to pick up
+ // updates from all the subchannels's FDs.
+ gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "1");
+ }
void SetUp() override {
response_generator_ = grpc_fake_resolver_response_generator_create();
@@ -109,50 +138,50 @@ class ClientLbEnd2endTest : public ::testing::Test {
}
void SetNextResolution(const std::vector<int>& ports) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_lb_addresses* addresses = grpc_lb_addresses_create(ports.size(), NULL);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_lb_addresses* addresses =
+ grpc_lb_addresses_create(ports.size(), nullptr);
for (size_t i = 0; i < ports.size(); ++i) {
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", ports[i]);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
- GPR_ASSERT(lb_uri != NULL);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
+ GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(addresses, i, lb_uri,
false /* is balancer */,
- "" /* balancer name */, NULL);
+ "" /* balancer name */, nullptr);
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(NULL, &fake_addresses, 1);
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator_, fake_result);
- grpc_channel_args_destroy(&exec_ctx, fake_result);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
- grpc_exec_ctx_finish(&exec_ctx);
+ 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_lb_addresses_destroy(addresses);
}
- void ResetStub(const grpc::string& lb_policy_name = "") {
- ChannelArguments args;
+ std::vector<int> GetServersPorts() {
+ std::vector<int> ports;
+ for (const auto& server : servers_) ports.push_back(server->port_);
+ return ports;
+ }
+
+ void ResetStub(const std::vector<int>& ports,
+ const grpc::string& lb_policy_name,
+ ChannelArguments args = ChannelArguments()) {
if (lb_policy_name.size() > 0) {
args.SetLoadBalancingPolicyName(lb_policy_name);
} // else, default to pick first
args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR,
response_generator_);
- args.SetInt("grpc.testing.fixed_reconnect_backoff_ms", 2000);
- std::ostringstream uri;
- uri << "fake:///";
- for (size_t i = 0; i < servers_.size() - 1; ++i) {
- uri << "127.0.0.1:" << servers_[i]->port_ << ",";
- }
- uri << "127.0.0.1:" << servers_[servers_.size() - 1]->port_;
channel_ =
- CreateCustomChannel(uri.str(), InsecureChannelCredentials(), args);
+ CreateCustomChannel("fake:///", InsecureChannelCredentials(), args);
stub_ = grpc::testing::EchoTestService::NewStub(channel_);
}
- Status SendRpc(EchoResponse* response = nullptr) {
+ bool SendRpc(EchoResponse* response = nullptr) {
const bool local_response = (response == nullptr);
if (local_response) response = new EchoResponse;
EchoRequest request;
@@ -160,19 +189,19 @@ class ClientLbEnd2endTest : public ::testing::Test {
ClientContext context;
Status status = stub_->Echo(&context, request, response);
if (local_response) delete response;
- return status;
+ return status.ok();
}
void CheckRpcSendOk() {
EchoResponse response;
- const Status status = SendRpc(&response);
- EXPECT_TRUE(status.ok());
+ const bool success = SendRpc(&response);
+ EXPECT_TRUE(success);
EXPECT_EQ(response.message(), kRequestMessage_);
}
void CheckRpcSendFailure() {
- const Status status = SendRpc();
- EXPECT_FALSE(status.ok());
+ const bool success = SendRpc();
+ EXPECT_FALSE(success);
}
struct ServerData {
@@ -263,7 +292,7 @@ TEST_F(ClientLbEnd2endTest, PickFirst) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub(); // implicit pick first
+ ResetStub(GetServersPorts(), ""); // test that pick first is the default.
std::vector<int> ports;
for (size_t i = 0; i < servers_.size(); ++i) {
ports.emplace_back(servers_[i]->port_);
@@ -287,11 +316,63 @@ TEST_F(ClientLbEnd2endTest, PickFirst) {
EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName());
}
+TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) {
+ ChannelArguments args;
+ constexpr int kInitialBackOffMs = 100;
+ args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs);
+ const std::vector<int> ports = {grpc_pick_unused_port_or_die()};
+ const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC);
+ ResetStub(ports, "pick_first", args);
+ SetNextResolution(ports);
+ // The channel won't become connected (there's no server).
+ ASSERT_FALSE(channel_->WaitForConnected(
+ grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2)));
+ // Bring up a server on the chosen port.
+ StartServers(1, ports);
+ // Now it will.
+ ASSERT_TRUE(channel_->WaitForConnected(
+ grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2)));
+ const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC);
+ const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0));
+ gpr_log(GPR_DEBUG, "Waited %ld milliseconds", waited_ms);
+ // We should have waited at least kInitialBackOffMs. We substract one to
+ // account for test and precision accuracy drift.
+ EXPECT_GE(waited_ms, kInitialBackOffMs - 1);
+ // But not much more.
+ EXPECT_GT(
+ gpr_time_cmp(
+ grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 1.10), t1),
+ 0);
+}
+
+TEST_F(ClientLbEnd2endTest, PickFirstBackOffMinReconnect) {
+ ChannelArguments args;
+ constexpr int kMinReconnectBackOffMs = 1000;
+ args.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, kMinReconnectBackOffMs);
+ const std::vector<int> ports = {grpc_pick_unused_port_or_die()};
+ ResetStub(ports, "pick_first", args);
+ SetNextResolution(ports);
+ // Make connection delay a 10% longer than it's willing to in order to make
+ // sure we are hitting the codepath that waits for the min reconnect backoff.
+ gpr_atm_rel_store(&g_connection_delay_ms, kMinReconnectBackOffMs * 1.10);
+ grpc_tcp_client_connect_impl = tcp_client_connect_with_delay;
+ const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC);
+ channel_->WaitForConnected(
+ grpc_timeout_milliseconds_to_deadline(kMinReconnectBackOffMs * 2));
+ const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC);
+ const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0));
+ gpr_log(GPR_DEBUG, "Waited %ld ms", waited_ms);
+ // We should have waited at least kMinReconnectBackOffMs. We substract one to
+ // account for test and precision accuracy drift.
+ EXPECT_GE(waited_ms, kMinReconnectBackOffMs - 1);
+ gpr_atm_rel_store(&g_connection_delay_ms, 0);
+}
+
TEST_F(ClientLbEnd2endTest, PickFirstUpdates) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub(); // implicit pick first
+ ResetStub(GetServersPorts(), "pick_first");
std::vector<int> ports;
// Perform one RPC against the first server.
@@ -305,7 +386,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) {
ports.clear();
SetNextResolution(ports);
gpr_log(GPR_INFO, "****** SET none *******");
- grpc_connectivity_state channel_state = GRPC_CHANNEL_INIT;
+ grpc_connectivity_state channel_state;
do {
channel_state = channel_->GetState(true /* try to connect */);
} while (channel_state == GRPC_CHANNEL_READY);
@@ -337,7 +418,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub(); // implicit pick first
+ ResetStub(GetServersPorts(), "pick_first");
std::vector<int> ports;
// Perform one RPC against the first server.
@@ -367,7 +448,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub(); // implicit pick first
+ ResetStub(GetServersPorts(), "pick_first");
std::vector<int> ports;
for (size_t i = 0; i < servers_.size(); ++i) {
ports.emplace_back(servers_[i]->port_);
@@ -376,7 +457,8 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
grpc_subchannel_index_test_only_set_force_creation(force_creation);
gpr_log(GPR_INFO, "Force subchannel creation: %d", force_creation);
for (size_t i = 0; i < 1000; ++i) {
- std::random_shuffle(ports.begin(), ports.end());
+ std::shuffle(ports.begin(), ports.end(),
+ std::mt19937(std::random_device()()));
SetNextResolution(ports);
if (i % 10 == 0) CheckRpcSendOk();
}
@@ -389,7 +471,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub("round_robin");
+ ResetStub(GetServersPorts(), "round_robin");
std::vector<int> ports;
for (const auto& server : servers_) {
ports.emplace_back(server->port_);
@@ -420,7 +502,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub("round_robin");
+ ResetStub(GetServersPorts(), "round_robin");
std::vector<int> ports;
// Start with a single server.
@@ -481,7 +563,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) {
// An empty update will result in the channel going into TRANSIENT_FAILURE.
ports.clear();
SetNextResolution(ports);
- grpc_connectivity_state channel_state = GRPC_CHANNEL_INIT;
+ grpc_connectivity_state channel_state;
do {
channel_state = channel_->GetState(true /* try to connect */);
} while (channel_state == GRPC_CHANNEL_READY);
@@ -503,7 +585,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) {
TEST_F(ClientLbEnd2endTest, RoundRobinUpdateInError) {
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub("round_robin");
+ ResetStub(GetServersPorts(), "round_robin");
std::vector<int> ports;
// Start with a single server.
@@ -535,13 +617,14 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
- ResetStub("round_robin");
+ ResetStub(GetServersPorts(), "round_robin");
std::vector<int> ports;
for (size_t i = 0; i < servers_.size(); ++i) {
ports.emplace_back(servers_[i]->port_);
}
for (size_t i = 0; i < 1000; ++i) {
- std::random_shuffle(ports.begin(), ports.end());
+ std::shuffle(ports.begin(), ports.end(),
+ std::mt19937(std::random_device()()));
SetNextResolution(ports);
if (i % 10 == 0) CheckRpcSendOk();
}
@@ -562,22 +645,71 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) {
ports.push_back(grpc_pick_unused_port_or_die());
}
StartServers(kNumServers, ports);
- ResetStub("round_robin");
+ ResetStub(GetServersPorts(), "round_robin");
SetNextResolution(ports);
// Send a number of RPCs, which succeed.
for (size_t i = 0; i < 100; ++i) {
CheckRpcSendOk();
}
// Kill all servers
+ gpr_log(GPR_INFO, "****** ABOUT TO KILL SERVERS *******");
for (size_t i = 0; i < servers_.size(); ++i) {
servers_[i]->Shutdown(false);
}
- // Client request should fail.
- CheckRpcSendFailure();
+ gpr_log(GPR_INFO, "****** SERVERS KILLED *******");
+ gpr_log(GPR_INFO, "****** SENDING DOOMED REQUESTS *******");
+ // Client requests should fail. Send enough to tickle all subchannels.
+ for (size_t i = 0; i < servers_.size(); ++i) CheckRpcSendFailure();
+ gpr_log(GPR_INFO, "****** DOOMED REQUESTS SENT *******");
// Bring servers back up on the same port (we aren't recreating the channel).
+ gpr_log(GPR_INFO, "****** RESTARTING SERVERS *******");
StartServers(kNumServers, ports);
- // Client request should succeed.
- CheckRpcSendOk();
+ gpr_log(GPR_INFO, "****** SERVERS RESTARTED *******");
+ gpr_log(GPR_INFO, "****** SENDING REQUEST TO SUCCEED *******");
+ // Client request should eventually (but still fairly soon) succeed.
+ const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
+ gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
+ while (gpr_time_cmp(deadline, now) > 0) {
+ if (SendRpc()) break;
+ now = gpr_now(GPR_CLOCK_MONOTONIC);
+ }
+ GPR_ASSERT(gpr_time_cmp(deadline, now) > 0);
+}
+
+TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) {
+ const int kNumServers = 3;
+ StartServers(kNumServers);
+ const auto ports = GetServersPorts();
+ ResetStub(ports, "round_robin");
+ SetNextResolution(ports);
+ for (size_t i = 0; i < kNumServers; ++i) WaitForServer(i);
+ for (size_t i = 0; i < servers_.size(); ++i) {
+ CheckRpcSendOk();
+ EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i;
+ }
+ // One request should have gone to each server.
+ for (size_t i = 0; i < servers_.size(); ++i) {
+ EXPECT_EQ(1, servers_[i]->service_.request_count());
+ }
+ const auto pre_death = servers_[0]->service_.request_count();
+ // Kill the first server.
+ servers_[0]->Shutdown(true);
+ // Client request still succeed. May need retrying if RR had returned a pick
+ // before noticing the change in the server's connectivity.
+ while (!SendRpc())
+ ; // Retry until success.
+ // Send a bunch of RPCs that should succeed.
+ for (int i = 0; i < 10 * kNumServers; ++i) CheckRpcSendOk();
+ const auto post_death = servers_[0]->service_.request_count();
+ // No requests have gone to the deceased server.
+ EXPECT_EQ(pre_death, post_death);
+ // Bring the first server back up.
+ servers_[0].reset(new ServerData(server_host_, ports[0]));
+ // Requests should start arriving at the first server either right away (if
+ // the server managed to start before the RR policy retried the subchannel) or
+ // after the subchannel retry delay otherwise (RR's subchannel retried before
+ // the server was fully back up).
+ WaitForServer(0);
}
} // namespace
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index e54cd03ca2..2edd10898c 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -30,10 +30,12 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@@ -198,10 +200,7 @@ class TestScenario {
void Log() const;
bool use_proxy;
bool inproc;
- // Although the below grpc::string is logically const, we can't declare
- // them const because of a limitation in the way old compilers (e.g., gcc-4.4)
- // manage vector insertion using a copy constructor
- grpc::string credentials_type;
+ const grpc::string credentials_type;
};
static std::ostream& operator<<(std::ostream& out,
@@ -223,7 +222,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
End2endTest()
: is_server_started_(false),
kMaxMessageSize_(8192),
- special_service_("special") {
+ special_service_("special"),
+ first_picked_port_(0) {
GetParam().Log();
}
@@ -232,10 +232,14 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
server_->Shutdown();
if (proxy_server_) proxy_server_->Shutdown();
}
+ if (first_picked_port_ > 0) {
+ grpc_recycle_unused_port(first_picked_port_);
+ }
}
void StartServer(const std::shared_ptr<AuthMetadataProcessor>& processor) {
int port = grpc_pick_unused_port_or_die();
+ first_picked_port_ = port;
server_address_ << "127.0.0.1:" << port;
// Setup server
BuildAndStartServer(processor);
@@ -331,6 +335,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
TestServiceImpl special_service_;
TestServiceImplDupPkg dup_pkg_service_;
grpc::string user_agent_prefix_;
+ int first_picked_port_;
};
static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
@@ -345,7 +350,7 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
char bytes[8] = {'\0', '\1', '\2', '\3', '\4', '\5', '\6', (char)i};
context.AddMetadata("custom-bin", grpc::string(bytes, 8));
}
- context.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+ context.set_compression_algorithm(GRPC_COMPRESS_MESSAGE_GZIP);
Status s = stub->Echo(&context, request, &response);
EXPECT_EQ(response.message(), request.message());
EXPECT_TRUE(s.ok());
@@ -701,13 +706,24 @@ TEST_P(End2endTest, ReconnectChannel) {
if (GetParam().inproc) {
return;
}
+ int poller_slowdown_factor = 1;
+ // It needs 2 pollset_works to reconnect the channel with polling engine
+ // "poll"
+ char* s = gpr_getenv("GRPC_POLL_STRATEGY");
+ if (s != nullptr && 0 == strcmp(s, "poll")) {
+ poller_slowdown_factor = 2;
+ }
+ gpr_free(s);
ResetStub();
SendRpc(stub_.get(), 1, false);
RestartServer(std::shared_ptr<AuthMetadataProcessor>());
- // It needs more than kConnectivityCheckIntervalMsec time to reconnect the
- // channel.
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_millis(1600, GPR_TIMESPAN)));
+ // It needs more than GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS time to
+ // reconnect the channel.
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(
+ 300 * poller_slowdown_factor * grpc_test_slowdown_factor(),
+ GPR_TIMESPAN)));
SendRpc(stub_.get(), 1, false);
}
@@ -724,6 +740,7 @@ TEST_P(End2endTest, RequestStreamOneRequest) {
Status s = stream->Finish();
EXPECT_EQ(response.message(), request.message());
EXPECT_TRUE(s.ok());
+ EXPECT_TRUE(context.debug_error_string().empty());
}
TEST_P(End2endTest, RequestStreamOneRequestWithCoalescingApi) {
@@ -1069,31 +1086,6 @@ TEST_P(End2endTest, RpcMaxMessageSize) {
EXPECT_FALSE(s.ok());
}
-// Client sends 20 requests and the server returns CANCELLED status after
-// reading 10 requests.
-TEST_P(End2endTest, RequestStreamServerEarlyCancelTest) {
- ResetStub();
- EchoRequest request;
- EchoResponse response;
- ClientContext context;
-
- context.AddMetadata(kServerCancelAfterReads, "10");
- auto stream = stub_->RequestStream(&context, &response);
- request.set_message("hello");
- int send_messages = 20;
- while (send_messages > 10) {
- EXPECT_TRUE(stream->Write(request));
- send_messages--;
- }
- while (send_messages > 0) {
- stream->Write(request);
- send_messages--;
- }
- stream->WritesDone();
- Status s = stream->Finish();
- EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
-}
-
void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream,
gpr_event* ev) {
EchoResponse resp;
@@ -1131,7 +1123,7 @@ TEST_P(End2endTest, ChannelState) {
CompletionQueue cq;
std::chrono::system_clock::time_point deadline =
std::chrono::system_clock::now() + std::chrono::milliseconds(10);
- channel_->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, &cq, NULL);
+ channel_->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, &cq, nullptr);
void* tag;
bool ok = true;
cq.Next(&tag, &ok);
@@ -1241,6 +1233,13 @@ TEST_P(End2endTest, ExpectErrorTest) {
EXPECT_EQ(iter->code(), s.error_code());
EXPECT_EQ(iter->error_message(), s.error_message());
EXPECT_EQ(iter->binary_error_details(), s.error_details());
+ EXPECT_TRUE(context.debug_error_string().find("created") !=
+ std::string::npos);
+ EXPECT_TRUE(context.debug_error_string().find("file") != std::string::npos);
+ EXPECT_TRUE(context.debug_error_string().find("line") != std::string::npos);
+ EXPECT_TRUE(context.debug_error_string().find("status") !=
+ std::string::npos);
+ EXPECT_TRUE(context.debug_error_string().find("13") != std::string::npos);
}
}
@@ -1283,10 +1282,19 @@ TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) {
EchoResponse response;
request.set_message("Hello");
request.mutable_param()->set_skip_cancelled_check(true);
+ // Let server sleep for 40 ms first to guarantee expiry.
+ // 40 ms might seem a bit extreme but the timer manager would have been just
+ // initialized (when ResetStub() was called) and there are some warmup costs
+ // i.e the timer thread many not have even started. There might also be other
+ // delays in the timer manager thread (in acquiring locks, timer data
+ // structure manipulations, starting backup timer threads) that add to the
+ // delays. 40ms is still not enough in some cases but this significantly
+ // reduces the test flakes
+ request.mutable_param()->set_server_sleep_us(40 * 1000);
ClientContext context;
std::chrono::system_clock::time_point deadline =
- std::chrono::system_clock::now() + std::chrono::microseconds(10);
+ std::chrono::system_clock::now() + std::chrono::milliseconds(1);
context.set_deadline(deadline);
Status s = stub_->Echo(&context, request, &response);
EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.error_code());
@@ -1410,6 +1418,10 @@ TEST_P(ProxyEnd2endTest, HugeResponse) {
}
TEST_P(ProxyEnd2endTest, Peer) {
+ // Peer is not meaningful for inproc
+ if (GetParam().inproc) {
+ return;
+ }
ResetStub();
EchoRequest request;
EchoResponse response;
@@ -1571,7 +1583,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
}
TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
@@ -1588,7 +1600,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
}
TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
@@ -1606,7 +1618,7 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
EXPECT_EQ(s.error_message(),
grpc::string("Getting metadata from plugin failed with error: ") +
kTestCredsPluginErrorMsg);
@@ -1667,12 +1679,40 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
EXPECT_EQ(s.error_message(),
grpc::string("Getting metadata from plugin failed with error: ") +
kTestCredsPluginErrorMsg);
}
+TEST_P(SecureEnd2endTest, CompositeCallCreds) {
+ ResetStub();
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+ const char kMetadataKey1[] = "call-creds-key1";
+ const char kMetadataKey2[] = "call-creds-key2";
+ const char kMetadataVal1[] = "call-creds-val1";
+ const char kMetadataVal2[] = "call-creds-val2";
+
+ context.set_credentials(CompositeCallCredentials(
+ MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>(
+ new TestMetadataCredentialsPlugin(kMetadataKey1, kMetadataVal1, true,
+ true))),
+ MetadataCredentialsFromPlugin(std::unique_ptr<MetadataCredentialsPlugin>(
+ new TestMetadataCredentialsPlugin(kMetadataKey2, kMetadataVal2, true,
+ true)))));
+ request.set_message("Hello");
+ request.mutable_param()->set_echo_metadata(true);
+
+ Status s = stub_->Echo(&context, request, &response);
+ EXPECT_TRUE(s.ok());
+ EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(),
+ kMetadataKey1, kMetadataVal1));
+ EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(),
+ kMetadataKey2, kMetadataVal2));
+}
+
TEST_P(SecureEnd2endTest, ClientAuthContext) {
ResetStub();
EchoRequest request;
@@ -1750,11 +1790,10 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
credentials_types.push_back(kInsecureCredentialsType);
}
GPR_ASSERT(!credentials_types.empty());
- for (auto it = credentials_types.begin(); it != credentials_types.end();
- ++it) {
- scenarios.emplace_back(false, false, *it);
+ for (const auto& cred : credentials_types) {
+ scenarios.emplace_back(false, false, cred);
if (use_proxy) {
- scenarios.emplace_back(true, false, *it);
+ scenarios.emplace_back(true, false, cred);
}
}
if (test_inproc && insec_ok()) {
@@ -1773,7 +1812,7 @@ INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest,
INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(true, true,
- true, false)));
+ true, true)));
INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(false, false,
@@ -1788,6 +1827,7 @@ INSTANTIATE_TEST_CASE_P(ResourceQuotaEnd2end, ResourceQuotaEnd2endTest,
} // namespace grpc
int main(int argc, char** argv) {
+ gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "200");
grpc_test_init(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
diff --git a/test/cpp/end2end/exception_test.cc b/test/cpp/end2end/exception_test.cc
new file mode 100644
index 0000000000..76272ad08a
--- /dev/null
+++ b/test/cpp/end2end/exception_test.cc
@@ -0,0 +1,119 @@
+/*
+ *
+ * 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 <exception>
+#include <memory>
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc/impl/codegen/port_platform.h>
+
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/test_config.h"
+
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace testing {
+
+const char* kErrorMessage = "This service caused an exception";
+
+#if GRPC_ALLOW_EXCEPTIONS
+class ExceptingServiceImpl : public ::grpc::testing::EchoTestService::Service {
+ public:
+ Status Echo(ServerContext* server_context, const EchoRequest* request,
+ EchoResponse* response) override {
+ throw - 1;
+ }
+ Status RequestStream(ServerContext* context,
+ ServerReader<EchoRequest>* reader,
+ EchoResponse* response) override {
+ throw ServiceException();
+ }
+
+ private:
+ class ServiceException final : public std::exception {
+ public:
+ ServiceException() {}
+
+ private:
+ const char* what() const noexcept override { return kErrorMessage; }
+ };
+};
+
+class ExceptionTest : public ::testing::Test {
+ protected:
+ ExceptionTest() {}
+
+ void SetUp() override {
+ ServerBuilder builder;
+ builder.RegisterService(&service_);
+ server_ = builder.BuildAndStart();
+ }
+
+ void TearDown() override { server_->Shutdown(); }
+
+ void ResetStub() {
+ channel_ = server_->InProcessChannel(ChannelArguments());
+ stub_ = grpc::testing::EchoTestService::NewStub(channel_);
+ }
+
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+ ExceptingServiceImpl service_;
+};
+
+TEST_F(ExceptionTest, Unary) {
+ ResetStub();
+ EchoRequest request;
+ EchoResponse response;
+ request.set_message("test");
+ ClientContext context;
+
+ Status s = stub_->Echo(&context, request, &response);
+ EXPECT_FALSE(s.ok());
+ EXPECT_EQ(s.error_code(), StatusCode::UNKNOWN);
+}
+
+TEST_F(ExceptionTest, RequestStream) {
+ ResetStub();
+ EchoResponse response;
+ ClientContext context;
+
+ auto stream = stub_->RequestStream(&context, &response);
+ stream->WritesDone();
+ Status s = stream->Finish();
+
+ EXPECT_FALSE(s.ok());
+ EXPECT_EQ(s.error_code(), StatusCode::UNKNOWN);
+}
+
+#endif // GRPC_ALLOW_EXCEPTIONS
+
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc
index f260ea0016..be99a1aea4 100644
--- a/test/cpp/end2end/filter_end2end_test.cc
+++ b/test/cpp/end2end/filter_end2end_test.cc
@@ -100,7 +100,7 @@ int GetCallCounterValue() {
class ChannelDataImpl : public ChannelData {
public:
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) {
IncrementConnectionCounter();
return GRPC_ERROR_NONE;
@@ -109,13 +109,12 @@ class ChannelDataImpl : public ChannelData {
class CallDataImpl : public CallData {
public:
- void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ void StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op) override {
// Incrementing the counter could be done from Init(), but we want
// to test that the individual methods are actually called correctly.
if (op->recv_initial_metadata() != nullptr) IncrementCallCounter();
- grpc_call_next_op(exec_ctx, elem, op->op());
+ grpc_call_next_op(elem, op->op());
}
};
@@ -266,7 +265,7 @@ TEST_F(FilterEnd2endTest, SimpleBidiStreaming) {
GenericServerContext srv_ctx;
GenericServerAsyncReaderWriter srv_stream(&srv_ctx);
- cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+ cli_ctx.set_compression_algorithm(GRPC_COMPRESS_MESSAGE_GZIP);
send_request.set_message("Hello");
std::unique_ptr<GenericClientAsyncReaderWriter> cli_stream =
generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1));
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index 33b35108d2..bf432844cb 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -145,7 +145,7 @@ class GenericEnd2endTest : public ::testing::Test {
if (check_deadline) {
EXPECT_TRUE(gpr_time_similar(deadline, srv_ctx.raw_deadline(),
- gpr_time_from_millis(100, GPR_TIMESPAN)));
+ gpr_time_from_millis(1000, GPR_TIMESPAN)));
}
ByteBuffer recv_buffer;
@@ -216,9 +216,10 @@ TEST_F(GenericEnd2endTest, SequentialUnaryRpcs) {
std::unique_ptr<ByteBuffer> cli_send_buffer =
SerializeToByteBuffer(&send_request);
+ // Use the same cq as server so that events can be polled in time.
std::unique_ptr<GenericClientAsyncResponseReader> call =
generic_stub_->PrepareUnaryCall(&cli_ctx, kMethodName,
- *cli_send_buffer.get(), &cli_cq_);
+ *cli_send_buffer.get(), srv_cq_.get());
call->StartCall();
ByteBuffer cli_recv_buffer;
call->Finish(&cli_recv_buffer, &recv_status, tag(1));
@@ -226,7 +227,7 @@ TEST_F(GenericEnd2endTest, SequentialUnaryRpcs) {
generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(),
srv_cq_.get(), tag(4));
- verify_ok(srv_cq_.get(), 4, true);
+ server_ok(4);
EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length()));
EXPECT_EQ(kMethodName, srv_ctx.method());
@@ -245,7 +246,7 @@ TEST_F(GenericEnd2endTest, SequentialUnaryRpcs) {
stream.Finish(Status::OK, tag(7));
server_ok(7);
- client_ok(1);
+ verify_ok(srv_cq_.get(), 1, true);
EXPECT_TRUE(ParseFromByteBuffer(&cli_recv_buffer, &recv_response));
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok());
@@ -267,7 +268,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
GenericServerContext srv_ctx;
GenericServerAsyncReaderWriter srv_stream(&srv_ctx);
- cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+ cli_ctx.set_compression_algorithm(GRPC_COMPRESS_MESSAGE_GZIP);
send_request.set_message("Hello");
std::unique_ptr<GenericClientAsyncReaderWriter> cli_stream =
generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1));
@@ -321,8 +322,9 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
TEST_F(GenericEnd2endTest, Deadline) {
ResetStub();
- SendRpc(1, true, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_seconds(10, GPR_TIMESPAN)));
+ SendRpc(1, true,
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_seconds(10, GPR_TIMESPAN)));
}
} // namespace
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index 77ed155292..78527587cf 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -33,10 +33,9 @@
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-extern "C" {
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/sockaddr.h"
-}
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -221,30 +220,31 @@ class BalancerServiceImpl : public BalancerService {
if (client_load_reporting_interval_seconds_ > 0) {
request.Clear();
- stream->Read(&request);
- gpr_log(GPR_INFO, "LB[%p]: recv client load report msg: '%s'", this,
- request.DebugString().c_str());
- GPR_ASSERT(request.has_client_stats());
- // We need to acquire the lock here in order to prevent the notify_one
- // below from firing before its corresponding wait is executed.
- std::lock_guard<std::mutex> lock(mu_);
- client_stats_.num_calls_started +=
- request.client_stats().num_calls_started();
- client_stats_.num_calls_finished +=
- request.client_stats().num_calls_finished();
- client_stats_.num_calls_finished_with_client_failed_to_send +=
- request.client_stats()
- .num_calls_finished_with_client_failed_to_send();
- client_stats_.num_calls_finished_known_received +=
- request.client_stats().num_calls_finished_known_received();
- for (const auto& drop_token_count :
- request.client_stats().calls_finished_with_drop()) {
- client_stats_
- .drop_token_counts[drop_token_count.load_balance_token()] +=
- drop_token_count.num_calls();
+ if (stream->Read(&request)) {
+ gpr_log(GPR_INFO, "LB[%p]: recv client load report msg: '%s'", this,
+ request.DebugString().c_str());
+ GPR_ASSERT(request.has_client_stats());
+ // We need to acquire the lock here in order to prevent the notify_one
+ // below from firing before its corresponding wait is executed.
+ std::lock_guard<std::mutex> lock(mu_);
+ client_stats_.num_calls_started +=
+ request.client_stats().num_calls_started();
+ client_stats_.num_calls_finished +=
+ request.client_stats().num_calls_finished();
+ client_stats_.num_calls_finished_with_client_failed_to_send +=
+ request.client_stats()
+ .num_calls_finished_with_client_failed_to_send();
+ client_stats_.num_calls_finished_known_received +=
+ request.client_stats().num_calls_finished_known_received();
+ for (const auto& drop_token_count :
+ request.client_stats().calls_finished_with_drop()) {
+ client_stats_
+ .drop_token_counts[drop_token_count.load_balance_token()] +=
+ drop_token_count.num_calls();
+ }
+ load_report_ready_ = true;
+ load_report_cond_.notify_one();
}
- load_report_ready_ = true;
- load_report_cond_.notify_one();
}
done:
gpr_log(GPR_INFO, "LB[%p]: done", this);
@@ -332,8 +332,11 @@ class GrpclbEnd2endTest : public ::testing::Test {
num_backends_(num_backends),
num_balancers_(num_balancers),
client_load_reporting_interval_seconds_(
- client_load_reporting_interval_seconds),
- kRequestMessage_("Live long and prosper.") {}
+ client_load_reporting_interval_seconds) {
+ // Make the backup poller poll very frequently in order to pick up
+ // updates from all the subchannels's FDs.
+ gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "1");
+ }
void SetUp() override {
response_generator_ = grpc_fake_resolver_response_generator_create();
@@ -351,11 +354,6 @@ class GrpclbEnd2endTest : public ::testing::Test {
"balancer", server_host_, balancers_.back().get()));
}
ResetStub();
- std::vector<AddressData> addresses;
- for (size_t i = 0; i < balancer_servers_.size(); ++i) {
- addresses.emplace_back(AddressData{balancer_servers_[i].port_, true, ""});
- }
- SetNextResolution(addresses);
}
void TearDown() override {
@@ -368,8 +366,17 @@ class GrpclbEnd2endTest : public ::testing::Test {
grpc_fake_resolver_response_generator_unref(response_generator_);
}
- void ResetStub() {
+ void SetNextResolutionAllBalancers() {
+ std::vector<AddressData> addresses;
+ for (size_t i = 0; i < balancer_servers_.size(); ++i) {
+ addresses.emplace_back(AddressData{balancer_servers_[i].port_, true, ""});
+ }
+ SetNextResolution(addresses);
+ }
+
+ void ResetStub(int fallback_timeout = 0) {
ChannelArguments args;
+ args.SetGrpclbFallbackTimeout(fallback_timeout);
args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR,
response_generator_);
std::ostringstream uri;
@@ -448,13 +455,13 @@ class GrpclbEnd2endTest : public ::testing::Test {
};
void SetNextResolution(const std::vector<AddressData>& address_data) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(address_data.size(), nullptr);
for (size_t i = 0; i < address_data.size(); ++i) {
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", address_data[i].port);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(
addresses, i, lb_uri, address_data[i].is_balancer,
@@ -464,16 +471,15 @@ class GrpclbEnd2endTest : public ::testing::Test {
}
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(
- &exec_ctx, response_generator_, &fake_result);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator_,
+ &fake_result);
+ grpc_lb_addresses_destroy(addresses);
}
- const std::vector<int> GetBackendPorts() const {
+ const std::vector<int> GetBackendPorts(const size_t start_index = 0) const {
std::vector<int> backend_ports;
- for (const auto& bs : backend_servers_) {
- backend_ports.push_back(bs.port_);
+ for (size_t i = start_index; i < backend_servers_.size(); ++i) {
+ backend_ports.push_back(backend_servers_[i].port_);
}
return backend_ports;
}
@@ -558,7 +564,6 @@ class GrpclbEnd2endTest : public ::testing::Test {
std::unique_ptr<std::thread> thread_;
};
- const grpc::string kMessage_ = "Live long and prosper.";
const grpc::string server_host_;
const size_t num_backends_;
const size_t num_balancers_;
@@ -570,7 +575,7 @@ class GrpclbEnd2endTest : public ::testing::Test {
std::vector<ServerThread<BackendService>> backend_servers_;
std::vector<ServerThread<BalancerService>> balancer_servers_;
grpc_fake_resolver_response_generator* response_generator_;
- const grpc::string kRequestMessage_;
+ const grpc::string kRequestMessage_ = "Live long and prosper.";
};
class SingleBalancerTest : public GrpclbEnd2endTest {
@@ -579,6 +584,7 @@ class SingleBalancerTest : public GrpclbEnd2endTest {
};
TEST_F(SingleBalancerTest, Vanilla) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
@@ -606,6 +612,7 @@ TEST_F(SingleBalancerTest, Vanilla) {
}
TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) {
+ SetNextResolutionAllBalancers();
const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor();
const int kCallDeadlineMs = 1000 * grpc_test_slowdown_factor();
@@ -642,7 +649,183 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) {
EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName());
}
+TEST_F(SingleBalancerTest, Fallback) {
+ SetNextResolutionAllBalancers();
+ const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor();
+ const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor();
+ const size_t kNumBackendInResolution = backends_.size() / 2;
+
+ ResetStub(kFallbackTimeoutMs);
+ std::vector<AddressData> addresses;
+ addresses.emplace_back(AddressData{balancer_servers_[0].port_, true, ""});
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ addresses.emplace_back(AddressData{backend_servers_[i].port_, false, ""});
+ }
+ SetNextResolution(addresses);
+
+ // Send non-empty serverlist only after kServerlistDelayMs.
+ ScheduleResponseForBalancer(
+ 0,
+ BalancerServiceImpl::BuildResponseForBackends(
+ GetBackendPorts(kNumBackendInResolution /* start_index */), {}),
+ kServerlistDelayMs);
+
+ // Wait until all the fallback backends are reachable.
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ WaitForBackend(i);
+ }
+
+ // The first request.
+ gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH ==========");
+ CheckRpcSendOk(kNumBackendInResolution);
+ gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH ==========");
+
+ // Fallback is used: each backend returned by the resolver should have
+ // gotten one request.
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ EXPECT_EQ(1U, backend_servers_[i].service_->request_count());
+ }
+ for (size_t i = kNumBackendInResolution; i < backends_.size(); ++i) {
+ EXPECT_EQ(0U, backend_servers_[i].service_->request_count());
+ }
+
+ // Wait until the serverlist reception has been processed and all backends
+ // in the serverlist are reachable.
+ for (size_t i = kNumBackendInResolution; i < backends_.size(); ++i) {
+ WaitForBackend(i);
+ }
+
+ // Send out the second request.
+ gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH ==========");
+ CheckRpcSendOk(backends_.size() - kNumBackendInResolution);
+ gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH ==========");
+
+ // Serverlist is used: each backend returned by the balancer should
+ // have gotten one request.
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ EXPECT_EQ(0U, backend_servers_[i].service_->request_count());
+ }
+ for (size_t i = kNumBackendInResolution; i < backends_.size(); ++i) {
+ EXPECT_EQ(1U, backend_servers_[i].service_->request_count());
+ }
+
+ balancers_[0]->NotifyDoneWithServerlists();
+ // The balancer got a single request.
+ EXPECT_EQ(1U, balancer_servers_[0].service_->request_count());
+ // and sent a single response.
+ EXPECT_EQ(1U, balancer_servers_[0].service_->response_count());
+}
+
+TEST_F(SingleBalancerTest, FallbackUpdate) {
+ SetNextResolutionAllBalancers();
+ const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor();
+ const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor();
+ const size_t kNumBackendInResolution = backends_.size() / 3;
+ const size_t kNumBackendInResolutionUpdate = backends_.size() / 3;
+
+ ResetStub(kFallbackTimeoutMs);
+ std::vector<AddressData> addresses;
+ addresses.emplace_back(AddressData{balancer_servers_[0].port_, true, ""});
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ addresses.emplace_back(AddressData{backend_servers_[i].port_, false, ""});
+ }
+ SetNextResolution(addresses);
+
+ // Send non-empty serverlist only after kServerlistDelayMs.
+ ScheduleResponseForBalancer(
+ 0,
+ BalancerServiceImpl::BuildResponseForBackends(
+ GetBackendPorts(kNumBackendInResolution +
+ kNumBackendInResolutionUpdate /* start_index */),
+ {}),
+ kServerlistDelayMs);
+
+ // Wait until all the fallback backends are reachable.
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ WaitForBackend(i);
+ }
+
+ // The first request.
+ gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH ==========");
+ CheckRpcSendOk(kNumBackendInResolution);
+ gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH ==========");
+
+ // Fallback is used: each backend returned by the resolver should have
+ // gotten one request.
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ EXPECT_EQ(1U, backend_servers_[i].service_->request_count());
+ }
+ for (size_t i = kNumBackendInResolution; i < backends_.size(); ++i) {
+ EXPECT_EQ(0U, backend_servers_[i].service_->request_count());
+ }
+
+ addresses.clear();
+ addresses.emplace_back(AddressData{balancer_servers_[0].port_, true, ""});
+ for (size_t i = kNumBackendInResolution;
+ i < kNumBackendInResolution + kNumBackendInResolutionUpdate; ++i) {
+ addresses.emplace_back(AddressData{backend_servers_[i].port_, false, ""});
+ }
+ SetNextResolution(addresses);
+
+ // Wait until the resolution update has been processed and all the new
+ // fallback backends are reachable.
+ for (size_t i = kNumBackendInResolution;
+ i < kNumBackendInResolution + kNumBackendInResolutionUpdate; ++i) {
+ WaitForBackend(i);
+ }
+
+ // Send out the second request.
+ gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH ==========");
+ CheckRpcSendOk(kNumBackendInResolutionUpdate);
+ gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH ==========");
+
+ // The resolution update is used: each backend in the resolution update should
+ // have gotten one request.
+ for (size_t i = 0; i < kNumBackendInResolution; ++i) {
+ EXPECT_EQ(0U, backend_servers_[i].service_->request_count());
+ }
+ for (size_t i = kNumBackendInResolution;
+ i < kNumBackendInResolution + kNumBackendInResolutionUpdate; ++i) {
+ EXPECT_EQ(1U, backend_servers_[i].service_->request_count());
+ }
+ for (size_t i = kNumBackendInResolution + kNumBackendInResolutionUpdate;
+ i < backends_.size(); ++i) {
+ EXPECT_EQ(0U, backend_servers_[i].service_->request_count());
+ }
+
+ // Wait until the serverlist reception has been processed and all backends
+ // in the serverlist are reachable.
+ for (size_t i = kNumBackendInResolution + kNumBackendInResolutionUpdate;
+ i < backends_.size(); ++i) {
+ WaitForBackend(i);
+ }
+
+ // Send out the third request.
+ gpr_log(GPR_INFO, "========= BEFORE THIRD BATCH ==========");
+ CheckRpcSendOk(backends_.size() - kNumBackendInResolution -
+ kNumBackendInResolutionUpdate);
+ gpr_log(GPR_INFO, "========= DONE WITH THIRD BATCH ==========");
+
+ // Serverlist is used: each backend returned by the balancer should
+ // have gotten one request.
+ for (size_t i = 0;
+ i < kNumBackendInResolution + kNumBackendInResolutionUpdate; ++i) {
+ EXPECT_EQ(0U, backend_servers_[i].service_->request_count());
+ }
+ for (size_t i = kNumBackendInResolution + kNumBackendInResolutionUpdate;
+ i < backends_.size(); ++i) {
+ EXPECT_EQ(1U, backend_servers_[i].service_->request_count());
+ }
+
+ balancers_[0]->NotifyDoneWithServerlists();
+ // The balancer got a single request.
+ EXPECT_EQ(1U, balancer_servers_[0].service_->request_count());
+ // and sent a single response.
+ EXPECT_EQ(1U, balancer_servers_[0].service_->response_count());
+}
+
TEST_F(SingleBalancerTest, BackendsRestart) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
@@ -682,6 +865,7 @@ class UpdatesTest : public GrpclbEnd2endTest {
};
TEST_F(UpdatesTest, UpdateBalancers) {
+ SetNextResolutionAllBalancers();
const std::vector<int> first_backend{GetBackendPorts()[0]};
const std::vector<int> second_backend{GetBackendPorts()[1]};
ScheduleResponseForBalancer(
@@ -744,6 +928,7 @@ TEST_F(UpdatesTest, UpdateBalancers) {
// verify that the LB channel inside grpclb keeps the initial connection (which
// by definition is also present in the update).
TEST_F(UpdatesTest, UpdateBalancersRepeated) {
+ SetNextResolutionAllBalancers();
const std::vector<int> first_backend{GetBackendPorts()[0]};
const std::vector<int> second_backend{GetBackendPorts()[0]};
@@ -814,6 +999,9 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) {
}
TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) {
+ std::vector<AddressData> addresses;
+ addresses.emplace_back(AddressData{balancer_servers_[0].port_, true, ""});
+ SetNextResolution(addresses);
const std::vector<int> first_backend{GetBackendPorts()[0]};
const std::vector<int> second_backend{GetBackendPorts()[1]};
@@ -855,7 +1043,7 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) {
EXPECT_EQ(0U, balancer_servers_[2].service_->request_count());
EXPECT_EQ(0U, balancer_servers_[2].service_->response_count());
- std::vector<AddressData> addresses;
+ addresses.clear();
addresses.emplace_back(AddressData{balancer_servers_[1].port_, true, ""});
gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 ==========");
SetNextResolution(addresses);
@@ -880,8 +1068,14 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) {
balancers_[2]->NotifyDoneWithServerlists();
EXPECT_EQ(1U, balancer_servers_[0].service_->request_count());
EXPECT_EQ(1U, balancer_servers_[0].service_->response_count());
- EXPECT_EQ(1U, balancer_servers_[1].service_->request_count());
- EXPECT_EQ(1U, balancer_servers_[1].service_->response_count());
+ // The second balancer, published as part of the first update, may end up
+ // getting two requests (that is, 1 <= #req <= 2) if the LB call retry timer
+ // firing races with the arrival of the update containing the second
+ // balancer.
+ EXPECT_GE(balancer_servers_[1].service_->request_count(), 1U);
+ EXPECT_GE(balancer_servers_[1].service_->response_count(), 1U);
+ EXPECT_LE(balancer_servers_[1].service_->request_count(), 2U);
+ EXPECT_LE(balancer_servers_[1].service_->response_count(), 2U);
EXPECT_EQ(0U, balancer_servers_[2].service_->request_count());
EXPECT_EQ(0U, balancer_servers_[2].service_->response_count());
// Check LB policy name for the channel.
@@ -889,6 +1083,7 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) {
}
TEST_F(SingleBalancerTest, Drop) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
const int num_of_drop_by_rate_limiting_addresses = 1;
const int num_of_drop_by_load_balancing_addresses = 2;
@@ -896,10 +1091,11 @@ TEST_F(SingleBalancerTest, Drop) {
num_of_drop_by_load_balancing_addresses;
const int num_total_addresses = num_backends_ + num_of_drop_addresses;
ScheduleResponseForBalancer(
- 0, BalancerServiceImpl::BuildResponseForBackends(
- GetBackendPorts(),
- {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
- {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
+ 0,
+ BalancerServiceImpl::BuildResponseForBackends(
+ GetBackendPorts(),
+ {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
+ {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
0);
// Wait until all backends are ready.
WaitForAllBackends();
@@ -914,7 +1110,7 @@ TEST_F(SingleBalancerTest, Drop) {
} else {
EXPECT_TRUE(status.ok()) << "code=" << status.error_code()
<< " message=" << status.error_message();
- EXPECT_EQ(response.message(), kMessage_);
+ EXPECT_EQ(response.message(), kRequestMessage_);
}
}
EXPECT_EQ(kNumRpcsPerAddress * num_of_drop_addresses, num_drops);
@@ -931,13 +1127,15 @@ TEST_F(SingleBalancerTest, Drop) {
}
TEST_F(SingleBalancerTest, DropAllFirst) {
+ SetNextResolutionAllBalancers();
// All registered addresses are marked as "drop".
const int num_of_drop_by_rate_limiting_addresses = 1;
const int num_of_drop_by_load_balancing_addresses = 1;
ScheduleResponseForBalancer(
- 0, BalancerServiceImpl::BuildResponseForBackends(
- {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
- {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
+ 0,
+ BalancerServiceImpl::BuildResponseForBackends(
+ {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
+ {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
0);
const Status status = SendRpc();
EXPECT_FALSE(status.ok());
@@ -945,15 +1143,17 @@ TEST_F(SingleBalancerTest, DropAllFirst) {
}
TEST_F(SingleBalancerTest, DropAll) {
+ SetNextResolutionAllBalancers();
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
0);
const int num_of_drop_by_rate_limiting_addresses = 1;
const int num_of_drop_by_load_balancing_addresses = 1;
ScheduleResponseForBalancer(
- 0, BalancerServiceImpl::BuildResponseForBackends(
- {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
- {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
+ 0,
+ BalancerServiceImpl::BuildResponseForBackends(
+ {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
+ {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
1000);
// First call succeeds.
@@ -974,6 +1174,7 @@ class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest {
};
TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
@@ -1008,6 +1209,7 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) {
}
TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 3;
const int num_of_drop_by_rate_limiting_addresses = 2;
const int num_of_drop_by_load_balancing_addresses = 1;
@@ -1015,10 +1217,11 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) {
num_of_drop_by_load_balancing_addresses;
const int num_total_addresses = num_backends_ + num_of_drop_addresses;
ScheduleResponseForBalancer(
- 0, BalancerServiceImpl::BuildResponseForBackends(
- GetBackendPorts(),
- {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
- {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
+ 0,
+ BalancerServiceImpl::BuildResponseForBackends(
+ GetBackendPorts(),
+ {{"rate_limiting", num_of_drop_by_rate_limiting_addresses},
+ {"load_balancing", num_of_drop_by_load_balancing_addresses}}),
0);
// Wait until all backends are ready.
int num_warmup_ok = 0;
@@ -1038,7 +1241,7 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) {
} else {
EXPECT_TRUE(status.ok()) << "code=" << status.error_code()
<< " message=" << status.error_message();
- EXPECT_EQ(response.message(), kMessage_);
+ EXPECT_EQ(response.message(), kRequestMessage_);
}
}
EXPECT_EQ(kNumRpcsPerAddress * num_of_drop_addresses, num_drops);
diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc
index 0b63c25055..175ecea2b3 100644
--- a/test/cpp/end2end/mock_test.cc
+++ b/test/cpp/end2end/mock_test.cc
@@ -43,20 +43,20 @@
#include <iostream>
-using namespace std;
+using ::testing::AtLeast;
+using ::testing::DoAll;
+using ::testing::Invoke;
+using ::testing::Return;
+using ::testing::SaveArg;
+using ::testing::SetArgPointee;
+using ::testing::WithArg;
+using ::testing::_;
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using grpc::testing::EchoTestService;
using grpc::testing::MockClientReaderWriter;
using std::chrono::system_clock;
-using ::testing::AtLeast;
-using ::testing::SetArgPointee;
-using ::testing::SaveArg;
-using ::testing::_;
-using ::testing::Return;
-using ::testing::Invoke;
-using ::testing::WithArg;
-using ::testing::DoAll;
+using std::vector;
namespace grpc {
namespace testing {
diff --git a/test/cpp/end2end/server_builder_plugin_test.cc b/test/cpp/end2end/server_builder_plugin_test.cc
index 2951a2ebcf..a1ce4ebc81 100644
--- a/test/cpp/end2end/server_builder_plugin_test.cc
+++ b/test/cpp/end2end/server_builder_plugin_test.cc
@@ -251,7 +251,7 @@ TEST_P(ServerBuilderPluginTest, PluginWithServiceTest) {
EchoResponse response;
request.set_message("Hello hello hello hello");
ClientContext context;
- context.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+ context.set_compression_algorithm(GRPC_COMPRESS_MESSAGE_GZIP);
Status s = stub_->Echo(&context, request, &response);
EXPECT_EQ(response.message(), request.message());
EXPECT_TRUE(s.ok());
diff --git a/test/cpp/end2end/server_early_return_test.cc b/test/cpp/end2end/server_early_return_test.cc
new file mode 100644
index 0000000000..6fd26fcdb6
--- /dev/null
+++ b/test/cpp/end2end/server_early_return_test.cc
@@ -0,0 +1,233 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/security/credentials.h>
+#include <grpc++/security/server_credentials.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/util/string_ref_helper.h"
+
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace testing {
+namespace {
+
+const char kServerReturnStatusCode[] = "server_return_status_code";
+const char kServerDelayBeforeReturnUs[] = "server_delay_before_return_us";
+const char kServerReturnAfterNReads[] = "server_return_after_n_reads";
+
+class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
+ public:
+ // Unused methods are not implemented.
+
+ Status RequestStream(ServerContext* context,
+ ServerReader<EchoRequest>* reader,
+ EchoResponse* response) override {
+ int server_return_status_code =
+ GetIntValueFromMetadata(context, kServerReturnStatusCode, 0);
+ int server_delay_before_return_us =
+ GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0);
+ int server_return_after_n_reads =
+ GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0);
+
+ EchoRequest request;
+ while (server_return_after_n_reads--) {
+ EXPECT_TRUE(reader->Read(&request));
+ }
+
+ response->set_message("response msg");
+
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN)));
+
+ return Status(static_cast<StatusCode>(server_return_status_code), "");
+ }
+
+ Status BidiStream(
+ ServerContext* context,
+ ServerReaderWriter<EchoResponse, EchoRequest>* stream) override {
+ int server_return_status_code =
+ GetIntValueFromMetadata(context, kServerReturnStatusCode, 0);
+ int server_delay_before_return_us =
+ GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0);
+ int server_return_after_n_reads =
+ GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0);
+
+ EchoRequest request;
+ EchoResponse response;
+ while (server_return_after_n_reads--) {
+ EXPECT_TRUE(stream->Read(&request));
+ response.set_message(request.message());
+ EXPECT_TRUE(stream->Write(response));
+ }
+
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN)));
+
+ return Status(static_cast<StatusCode>(server_return_status_code), "");
+ }
+
+ int GetIntValueFromMetadata(ServerContext* context, const char* key,
+ int default_value) {
+ auto metadata = context->client_metadata();
+ if (metadata.find(key) != metadata.end()) {
+ std::istringstream iss(ToString(metadata.find(key)->second));
+ iss >> default_value;
+ }
+ return default_value;
+ }
+};
+
+class ServerEarlyReturnTest : public ::testing::Test {
+ protected:
+ ServerEarlyReturnTest() : picked_port_(0) {}
+
+ void SetUp() override {
+ int port = grpc_pick_unused_port_or_die();
+ picked_port_ = port;
+ server_address_ << "127.0.0.1:" << port;
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address_.str(),
+ InsecureServerCredentials());
+ builder.RegisterService(&service_);
+ server_ = builder.BuildAndStart();
+
+ channel_ =
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
+ stub_ = grpc::testing::EchoTestService::NewStub(channel_);
+ }
+
+ void TearDown() override {
+ server_->Shutdown();
+ if (picked_port_ > 0) {
+ grpc_recycle_unused_port(picked_port_);
+ }
+ }
+
+ // Client sends 20 requests and the server returns after reading 10 requests.
+ // If return_cancel is true, server returns CANCELLED status. Otherwise it
+ // returns OK.
+ void DoBidiStream(bool return_cancelled) {
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+
+ context.AddMetadata(kServerReturnAfterNReads, "10");
+ if (return_cancelled) {
+ // "1" means CANCELLED
+ context.AddMetadata(kServerReturnStatusCode, "1");
+ }
+ context.AddMetadata(kServerDelayBeforeReturnUs, "10000");
+
+ auto stream = stub_->BidiStream(&context);
+
+ for (int i = 0; i < 20; i++) {
+ request.set_message(grpc::string("hello") + grpc::to_string(i));
+ bool write_ok = stream->Write(request);
+ bool read_ok = stream->Read(&response);
+ if (i < 10) {
+ EXPECT_TRUE(write_ok);
+ EXPECT_TRUE(read_ok);
+ EXPECT_EQ(response.message(), request.message());
+ } else {
+ EXPECT_FALSE(read_ok);
+ }
+ }
+
+ stream->WritesDone();
+ EXPECT_FALSE(stream->Read(&response));
+
+ Status s = stream->Finish();
+ if (return_cancelled) {
+ EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
+ } else {
+ EXPECT_TRUE(s.ok());
+ }
+ }
+
+ void DoRequestStream(bool return_cancelled) {
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+
+ context.AddMetadata(kServerReturnAfterNReads, "10");
+ if (return_cancelled) {
+ // "1" means CANCELLED
+ context.AddMetadata(kServerReturnStatusCode, "1");
+ }
+ context.AddMetadata(kServerDelayBeforeReturnUs, "10000");
+
+ auto stream = stub_->RequestStream(&context, &response);
+ for (int i = 0; i < 20; i++) {
+ request.set_message(grpc::string("hello") + grpc::to_string(i));
+ bool written = stream->Write(request);
+ if (i < 10) {
+ EXPECT_TRUE(written);
+ }
+ }
+ stream->WritesDone();
+ Status s = stream->Finish();
+ if (return_cancelled) {
+ EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
+ } else {
+ EXPECT_TRUE(s.ok());
+ }
+ }
+
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+ std::ostringstream server_address_;
+ TestServiceImpl service_;
+ int picked_port_;
+};
+
+TEST_F(ServerEarlyReturnTest, BidiStreamEarlyOk) { DoBidiStream(false); }
+
+TEST_F(ServerEarlyReturnTest, BidiStreamEarlyCancel) { DoBidiStream(true); }
+
+TEST_F(ServerEarlyReturnTest, RequestStreamEarlyOK) { DoRequestStream(false); }
+TEST_F(ServerEarlyReturnTest, RequestStreamEarlyCancel) {
+ DoRequestStream(true);
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc
index 14ba7c96cc..9119102f7a 100644
--- a/test/cpp/end2end/shutdown_test.cc
+++ b/test/cpp/end2end/shutdown_test.cc
@@ -28,7 +28,7 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc
index 4fa98c24f5..875a27b5f5 100644
--- a/test/cpp/end2end/test_service_impl.cc
+++ b/test/cpp/end2end/test_service_impl.cc
@@ -73,6 +73,14 @@ void CheckServerAuthContext(
Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request,
EchoResponse* response) {
+ // A bit of sleep to make sure that short deadline tests fail
+ if (request->has_param() && request->param().server_sleep_us() > 0) {
+ gpr_sleep_until(
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_micros(request->param().server_sleep_us(),
+ GPR_TIMESPAN)));
+ }
+
if (request->has_param() && request->param().server_die()) {
gpr_log(GPR_ERROR, "The request should not reach application handler.");
GPR_ASSERT(0);
@@ -173,13 +181,6 @@ Status TestServiceImpl::RequestStream(ServerContext* context,
int server_try_cancel = GetIntValueFromMetadata(
kServerTryCancelRequest, context->client_metadata(), DO_NOT_CANCEL);
- // If 'cancel_after_reads' is set in the metadata AND non-zero, the server
- // will cancel the RPC (by just returning Status::CANCELLED - doesn't call
- // ServerContext::TryCancel()) after reading the number of records specified
- // by the 'cancel_after_reads' value set in the metadata.
- int cancel_after_reads = GetIntValueFromMetadata(
- kServerCancelAfterReads, context->client_metadata(), 0);
-
EchoRequest request;
response->set_message("");
@@ -196,12 +197,6 @@ Status TestServiceImpl::RequestStream(ServerContext* context,
int num_msgs_read = 0;
while (reader->Read(&request)) {
- if (cancel_after_reads == 1) {
- gpr_log(GPR_INFO, "return cancel status");
- return Status::CANCELLED;
- } else if (cancel_after_reads > 0) {
- cancel_after_reads--;
- }
response->mutable_message()->append(request.message());
}
gpr_log(GPR_INFO, "Read: %d messages", num_msgs_read);
diff --git a/test/cpp/end2end/test_service_impl.h b/test/cpp/end2end/test_service_impl.h
index e485769bb2..070f357139 100644
--- a/test/cpp/end2end/test_service_impl.h
+++ b/test/cpp/end2end/test_service_impl.h
@@ -31,7 +31,6 @@ namespace testing {
const int kServerDefaultResponseStreamsToSend = 3;
const char* const kServerResponseStreamsToSend = "server_responses_to_send";
-const char* const kServerCancelAfterReads = "cancel_after_reads";
const char* const kServerTryCancelRequest = "server_try_cancel";
const char* const kDebugInfoTrailerKey = "debug-info-bin";
const char* const kServerFinishAfterNReads = "server_finish_after_n_reads";
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index f990a7ed9d..90b2eddbbb 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -50,23 +50,6 @@ const int kNumRpcs = 1000; // Number of RPCs per thread
namespace grpc {
namespace testing {
-namespace {
-
-// When echo_deadline is requested, deadline seen in the ServerContext is set in
-// the response in seconds.
-void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
- EchoResponse* response) {
- if (request->has_param() && request->param().echo_deadline()) {
- gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
- if (context->deadline() != system_clock::time_point::max()) {
- Timepoint2Timespec(context->deadline(), &deadline);
- }
- response->mutable_param()->set_request_deadline(deadline.tv_sec);
- }
-}
-
-} // namespace
-
class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
public:
TestServiceImpl() : signal_client_(false) {}
@@ -74,29 +57,6 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
Status Echo(ServerContext* context, const EchoRequest* request,
EchoResponse* response) override {
response->set_message(request->message());
- MaybeEchoDeadline(context, request, response);
- if (request->has_param() && request->param().client_cancel_after_us()) {
- {
- std::unique_lock<std::mutex> lock(mu_);
- signal_client_ = true;
- }
- while (!context->IsCancelled()) {
- gpr_sleep_until(gpr_time_add(
- gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_micros(request->param().client_cancel_after_us(),
- GPR_TIMESPAN)));
- }
- return Status::CANCELLED;
- } else if (request->has_param() &&
- request->param().server_cancel_after_us()) {
- gpr_sleep_until(gpr_time_add(
- gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_micros(request->param().server_cancel_after_us(),
- GPR_TIMESPAN)));
- return Status::CANCELLED;
- } else {
- EXPECT_FALSE(context->IsCancelled());
- }
return Status::OK;
}
diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc
index 6b0350e1f9..1f2ef0c2de 100644
--- a/test/cpp/grpclb/grpclb_api_test.cc
+++ b/test/cpp/grpclb/grpclb_api_test.cc
@@ -17,6 +17,7 @@
*/
#include <grpc++/impl/codegen/config.h>
+#include <grpc/grpc.h>
#include <gtest/gtest.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
@@ -48,7 +49,7 @@ grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) {
} else {
abort();
}
- GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != NULL);
+ GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != nullptr);
return ip_str;
}
@@ -98,9 +99,6 @@ TEST_F(GrpclbTest, ParseResponseServerList) {
server->set_port(54321);
server->set_load_balance_token("load_balancing");
server->set_drop(true);
- auto* expiration_interval = serverlist->mutable_expiration_interval();
- expiration_interval->set_seconds(888);
- expiration_interval->set_nanos(999);
const grpc::string encoded_response = response.SerializeAsString();
const grpc_slice encoded_slice = grpc_slice_from_copied_buffer(
@@ -121,11 +119,6 @@ TEST_F(GrpclbTest, ParseResponseServerList) {
EXPECT_STREQ(c_serverlist->servers[1]->load_balance_token, "load_balancing");
EXPECT_TRUE(c_serverlist->servers[1]->drop);
- EXPECT_TRUE(c_serverlist->expiration_interval.has_seconds);
- EXPECT_EQ(c_serverlist->expiration_interval.seconds, 888);
- EXPECT_TRUE(c_serverlist->expiration_interval.has_nanos);
- EXPECT_EQ(c_serverlist->expiration_interval.nanos, 999);
-
grpc_slice_unref(encoded_slice);
grpc_grpclb_destroy_serverlist(c_serverlist);
}
@@ -135,5 +128,8 @@ TEST_F(GrpclbTest, ParseResponseServerList) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ grpc_init();
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
}
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index e740ea513a..d241594af1 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -35,21 +35,21 @@
#include <grpc/support/time.h>
#include <grpc++/impl/codegen/config.h>
-extern "C" {
+
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#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/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-}
#include "src/proto/grpc/lb/v1/load_balancer.pb.h"
@@ -87,19 +87,19 @@ namespace grpc {
namespace {
typedef struct client_fixture {
- grpc_channel *client;
- char *server_uri;
- grpc_completion_queue *cq;
+ grpc_channel* client;
+ char* server_uri;
+ grpc_completion_queue* cq;
} client_fixture;
typedef struct server_fixture {
- grpc_server *server;
- grpc_call *server_call;
- grpc_completion_queue *cq;
- char *servers_hostport;
- const char *balancer_name;
+ grpc_server* server;
+ grpc_call* server_call;
+ grpc_completion_queue* cq;
+ char* servers_hostport;
+ const char* balancer_name;
int port;
- const char *lb_token_prefix;
+ const char* lb_token_prefix;
gpr_thd_id tid;
int num_calls_serviced;
} server_fixture;
@@ -111,12 +111,11 @@ typedef struct test_fixture {
int lb_server_update_delay_ms;
} test_fixture;
-static void *tag(intptr_t t) { return (void *)t; }
+static void* tag(intptr_t t) { return (void*)t; }
-static grpc_slice build_response_payload_slice(
- const char *host, int *ports, size_t nports,
- int64_t expiration_interval_secs, int32_t expiration_interval_nanos,
- const char *token_prefix) {
+static grpc_slice build_response_payload_slice(const char* host, int* ports,
+ size_t nports,
+ const char* token_prefix) {
// server_list {
// servers {
// ip_address: <in_addr/6 bytes of an IP>
@@ -126,24 +125,15 @@ static grpc_slice build_response_payload_slice(
// ...
// }
grpc::lb::v1::LoadBalanceResponse response;
- auto *serverlist = response.mutable_server_list();
+ auto* serverlist = response.mutable_server_list();
- if (expiration_interval_secs > 0 || expiration_interval_nanos > 0) {
- auto *expiration_interval = serverlist->mutable_expiration_interval();
- if (expiration_interval_secs > 0) {
- expiration_interval->set_seconds(expiration_interval_secs);
- }
- if (expiration_interval_nanos > 0) {
- expiration_interval->set_nanos(expiration_interval_nanos);
- }
- }
for (size_t i = 0; i < nports; i++) {
- auto *server = serverlist->add_servers();
+ auto* server = serverlist->add_servers();
// TODO(dgq): test ipv6
struct in_addr ip4;
GPR_ASSERT(inet_pton(AF_INET, host, &ip4) == 1);
server->set_ip_address(
- string(reinterpret_cast<const char *>(&ip4), sizeof(ip4)));
+ string(reinterpret_cast<const char*>(&ip4), sizeof(ip4)));
server->set_port(ports[i]);
// Missing tokens are acceptable. Test that path.
if (strlen(token_prefix) > 0) {
@@ -151,15 +141,15 @@ static grpc_slice build_response_payload_slice(
server->set_load_balance_token(token_data);
}
}
- const string &enc_resp = response.SerializeAsString();
+ const string& enc_resp = response.SerializeAsString();
return grpc_slice_from_copied_buffer(enc_resp.data(), enc_resp.size());
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5),
- NULL);
+ nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
@@ -168,18 +158,18 @@ static void sleep_ms(int delay_ms) {
gpr_time_from_millis(delay_ms, GPR_TIMESPAN)));
}
-static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
+static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
int update_delay_ms) {
- grpc_call *s;
- cq_verifier *cqv = cq_verifier_create(sf->cq);
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(sf->cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array request_metadata_recv;
grpc_call_details call_details;
grpc_call_error error;
int was_cancelled = 2;
- grpc_byte_buffer *request_payload_recv;
- grpc_byte_buffer *response_payload;
+ grpc_byte_buffer* request_payload_recv;
+ grpc_byte_buffer* response_payload;
memset(ops, 0, sizeof(ops));
grpc_metadata_array_init(&request_metadata_recv);
@@ -198,16 +188,16 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
// make sure we've received the initial metadata from the grpclb request.
GPR_ASSERT(request_metadata_recv.count > 0);
- GPR_ASSERT(request_metadata_recv.metadata != NULL);
+ GPR_ASSERT(request_metadata_recv.metadata != nullptr);
// receive request for backends
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(202), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(202), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(202), 1);
cq_verify(cqv);
@@ -232,14 +222,14 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 201", sf->servers_hostport,
sf->balancer_name);
@@ -248,13 +238,13 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
if (i == 0) {
// First half of the ports.
response_payload_slice = build_response_payload_slice(
- "127.0.0.1", ports, nports / 2, -1, -1, sf->lb_token_prefix);
+ "127.0.0.1", ports, nports / 2, sf->lb_token_prefix);
} else {
// Second half of the ports.
sleep_ms(update_delay_ms);
response_payload_slice = build_response_payload_slice(
- "127.0.0.1", ports + (nports / 2), (nports + 1) / 2 /* ceil */, -1,
- -1, "" /* this half doesn't get to receive an LB token */);
+ "127.0.0.1", ports + (nports / 2), (nports + 1) / 2 /* ceil */,
+ "" /* this half doesn't get to receive an LB token */);
}
response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1);
@@ -262,9 +252,10 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(203), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(203), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(203), 1);
cq_verify(cqv);
@@ -284,9 +275,9 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(204), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(204), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(201), 1);
@@ -303,17 +294,17 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
grpc_call_details_destroy(&call_details);
}
-static void start_backend_server(server_fixture *sf) {
- grpc_call *s;
- cq_verifier *cqv;
+static void start_backend_server(server_fixture* sf) {
+ grpc_call* s;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array request_metadata_recv;
grpc_call_details call_details;
grpc_call_error error;
int was_cancelled;
- grpc_byte_buffer *request_payload_recv;
- grpc_byte_buffer *response_payload;
+ grpc_byte_buffer* request_payload_recv;
+ grpc_byte_buffer* response_payload;
grpc_event ev;
while (true) {
@@ -328,8 +319,8 @@ static void start_backend_server(server_fixture *sf) {
tag(100));
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "Server[%s] up", sf->servers_hostport);
- ev = grpc_completion_queue_next(sf->cq,
- grpc_timeout_seconds_to_deadline(60), NULL);
+ ev = grpc_completion_queue_next(
+ sf->cq, grpc_timeout_seconds_to_deadline(60), nullptr);
if (!ev.success) {
gpr_log(GPR_INFO, "Server[%s] being torn down", sf->servers_hostport);
cq_verifier_destroy(cqv);
@@ -339,8 +330,9 @@ static void start_backend_server(server_fixture *sf) {
}
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
const string expected_token =
- strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix +
- std::to_string(sf->port);
+ strlen(sf->lb_token_prefix) == 0
+ ? ""
+ : sf->lb_token_prefix + std::to_string(sf->port);
GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token",
expected_token.c_str()));
@@ -350,14 +342,15 @@ static void start_backend_server(server_fixture *sf) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "Server[%s] after tag 101", sf->servers_hostport);
@@ -368,15 +361,16 @@ static void start_backend_server(server_fixture *sf) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
ev = grpc_completion_queue_next(
- sf->cq, grpc_timeout_seconds_to_deadline(3), NULL);
+ sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr);
if (ev.type == GRPC_OP_COMPLETE && ev.success) {
GPR_ASSERT(ev.tag = tag(102));
- if (request_payload_recv == NULL) {
+ if (request_payload_recv == nullptr) {
exit = true;
gpr_log(GPR_INFO,
"Server[%s] recv \"close\" from client, exiting. Call #%d",
@@ -397,13 +391,13 @@ static void start_backend_server(server_fixture *sf) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
ev = grpc_completion_queue_next(
- sf->cq, grpc_timeout_seconds_to_deadline(3), NULL);
+ sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr);
if (ev.type == GRPC_OP_COMPLETE && ev.success) {
GPR_ASSERT(ev.tag = tag(103));
} else {
@@ -431,9 +425,10 @@ static void start_backend_server(server_fixture *sf) {
grpc_slice_from_static_string("Backend server out a-ok");
op->data.send_status_from_server.status_details = &status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
+ error =
+ grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -449,18 +444,18 @@ static void start_backend_server(server_fixture *sf) {
}
}
-static void perform_request(client_fixture *cf) {
- grpc_call *c;
- cq_verifier *cqv = cq_verifier_create(cf->cq);
+static void perform_request(client_fixture* cf) {
+ grpc_call* c;
+ cq_verifier* cqv = cq_verifier_create(cf->cq);
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- grpc_byte_buffer *request_payload;
- grpc_byte_buffer *response_payload_recv;
+ grpc_byte_buffer* request_payload;
+ grpc_byte_buffer* response_payload_recv;
int i;
memset(ops, 0, sizeof(ops));
@@ -468,13 +463,13 @@ static void perform_request(client_fixture *cf) {
grpc_slice_from_copied_string("hello world");
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234");
- c = grpc_channel_create_call(cf->client, NULL, GRPC_PROPAGATE_DEFAULTS,
+ c = grpc_channel_create_call(cf->client, nullptr, GRPC_PROPAGATE_DEFAULTS,
cf->cq, grpc_slice_from_static_string("/foo"),
&host, grpc_timeout_seconds_to_deadline(5),
- NULL);
+ nullptr);
gpr_log(GPR_INFO, "Call 0x%" PRIxPTR " created", (intptr_t)c);
GPR_ASSERT(c);
- char *peer;
+ char* peer;
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -483,21 +478,21 @@ static void perform_request(client_fixture *cf) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < 4; i++) {
@@ -507,14 +502,14 @@ static void perform_request(client_fixture *cf) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -531,9 +526,9 @@ static void perform_request(client_fixture *cf) {
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -555,73 +550,72 @@ static void perform_request(client_fixture *cf) {
}
#define BALANCERS_NAME "lb.name"
-static void setup_client(const server_fixture *lb_server,
- const server_fixture *backends, client_fixture *cf) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+static void setup_client(const server_fixture* lb_server,
+ const server_fixture* backends, client_fixture* cf) {
+ grpc_core::ExecCtx exec_ctx;
- char *expected_target_names = NULL;
- const char *backends_name = lb_server->servers_hostport;
+ char* expected_target_names = nullptr;
+ 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* response_generator =
grpc_fake_resolver_response_generator_create();
- grpc_lb_addresses *addresses = grpc_lb_addresses_create(1, NULL);
- char *lb_uri_str;
+ grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, nullptr);
+ char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:%s", lb_server->servers_hostport);
- grpc_uri *lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
- GPR_ASSERT(lb_uri != NULL);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
+ GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(addresses, 0, lb_uri, true,
- lb_server->balancer_name, NULL);
+ lb_server->balancer_name, nullptr);
grpc_uri_destroy(lb_uri);
gpr_free(lb_uri_str);
gpr_asprintf(&cf->server_uri, "fake:///%s", lb_server->servers_hostport);
const grpc_arg fake_addresses =
grpc_lb_addresses_create_channel_arg(addresses);
- grpc_channel_args *fake_result =
- grpc_channel_args_copy_and_add(NULL, &fake_addresses, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_channel_args* fake_result =
+ grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
+ grpc_lb_addresses_destroy(addresses);
const grpc_arg new_args[] = {
grpc_fake_transport_expected_targets_arg(expected_target_names),
grpc_fake_resolver_response_generator_arg(response_generator)};
- grpc_channel_args *args =
- grpc_channel_args_copy_and_add(NULL, new_args, GPR_ARRAY_SIZE(new_args));
+ grpc_channel_args* args = grpc_channel_args_copy_and_add(
+ nullptr, new_args, GPR_ARRAY_SIZE(new_args));
gpr_free(expected_target_names);
- cf->cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel_credentials *fake_creds =
+ 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, NULL);
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, fake_result);
- grpc_channel_args_destroy(&exec_ctx, fake_result);
- grpc_channel_credentials_unref(&exec_ctx, fake_creds);
- grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ 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);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void teardown_client(client_fixture *cf) {
+static void teardown_client(client_fixture* cf) {
grpc_completion_queue_shutdown(cf->cq);
drain_cq(cf->cq);
grpc_completion_queue_destroy(cf->cq);
- cf->cq = NULL;
+ cf->cq = nullptr;
grpc_channel_destroy(cf->client);
- cf->client = NULL;
+ cf->client = nullptr;
gpr_free(cf->server_uri);
}
-static void setup_server(const char *host, server_fixture *sf) {
+static void setup_server(const char* host, server_fixture* sf) {
int assigned_port;
- sf->cq = grpc_completion_queue_create_for_next(NULL);
- const char *colon_idx = strchr(host, ':');
+ sf->cq = grpc_completion_queue_create_for_next(nullptr);
+ const char* colon_idx = strchr(host, ':');
if (colon_idx) {
- const char *port_str = colon_idx + 1;
+ const char* port_str = colon_idx + 1;
sf->port = atoi(port_str);
sf->servers_hostport = gpr_strdup(host);
} else {
@@ -629,11 +623,11 @@ static void setup_server(const char *host, server_fixture *sf) {
gpr_join_host_port(&sf->servers_hostport, host, sf->port);
}
- grpc_server_credentials *server_creds =
+ grpc_server_credentials* server_creds =
grpc_fake_transport_security_server_credentials_create();
- sf->server = grpc_server_create(NULL, NULL);
- grpc_server_register_completion_queue(sf->server, sf->cq, NULL);
+ sf->server = grpc_server_create(nullptr, nullptr);
+ grpc_server_register_completion_queue(sf->server, sf->cq, nullptr);
GPR_ASSERT((assigned_port = grpc_server_add_secure_http2_port(
sf->server, sf->servers_hostport, server_creds)) > 0);
grpc_server_credentials_release(server_creds);
@@ -641,23 +635,23 @@ static void setup_server(const char *host, server_fixture *sf) {
grpc_server_start(sf->server);
}
-static void teardown_server(server_fixture *sf) {
+static void teardown_server(server_fixture* sf) {
if (!sf->server) return;
gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport);
- grpc_completion_queue *shutdown_cq =
- grpc_completion_queue_create_for_pluck(NULL);
+ grpc_completion_queue* shutdown_cq =
+ grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(sf->server, shutdown_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000),
grpc_timeout_seconds_to_deadline(5),
- NULL)
+ nullptr)
.type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_server_destroy(sf->server);
gpr_thd_join(sf->tid);
- sf->server = NULL;
+ sf->server = nullptr;
grpc_completion_queue_shutdown(sf->cq);
drain_cq(sf->cq);
grpc_completion_queue_destroy(sf->cq);
@@ -666,13 +660,13 @@ static void teardown_server(server_fixture *sf) {
gpr_free(sf->servers_hostport);
}
-static void fork_backend_server(void *arg) {
- server_fixture *sf = static_cast<server_fixture *>(arg);
+static void fork_backend_server(void* arg) {
+ server_fixture* sf = static_cast<server_fixture*>(arg);
start_backend_server(sf);
}
-static void fork_lb_server(void *arg) {
- test_fixture *tf = static_cast<test_fixture *>(arg);
+static void fork_lb_server(void* arg) {
+ test_fixture* tf = static_cast<test_fixture*>(arg);
int ports[NUM_BACKENDS];
for (int i = 0; i < NUM_BACKENDS; i++) {
ports[i] = tf->lb_backends[i].port;
@@ -698,19 +692,20 @@ static test_fixture setup_test_fixture(int lb_server_update_delay_ms) {
tf.lb_backends[i].lb_token_prefix = "";
}
setup_server("127.0.0.1", &tf.lb_backends[i]);
- gpr_thd_new(&tf.lb_backends[i].tid, fork_backend_server, &tf.lb_backends[i],
- &options);
+ gpr_thd_new(&tf.lb_backends[i].tid, "grpclb_backend", fork_backend_server,
+ &tf.lb_backends[i], &options);
}
tf.lb_server.lb_token_prefix = LB_TOKEN_PREFIX;
tf.lb_server.balancer_name = BALANCERS_NAME;
setup_server("127.0.0.1", &tf.lb_server);
- gpr_thd_new(&tf.lb_server.tid, fork_lb_server, &tf.lb_server, &options);
+ gpr_thd_new(&tf.lb_server.tid, "grpclb_server", fork_lb_server, &tf.lb_server,
+ &options);
setup_client(&tf.lb_server, tf.lb_backends, &tf.client);
return tf;
}
-static void teardown_test_fixture(test_fixture *tf) {
+static void teardown_test_fixture(test_fixture* tf) {
teardown_client(&tf->client);
for (int i = 0; i < NUM_BACKENDS; ++i) {
teardown_server(&tf->lb_backends[i]);
@@ -787,9 +782,12 @@ TEST(GrpclbTest, InvalidAddressInServerlist) {}
} // namespace
} // namespace grpc
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc_test_init(argc, argv);
+ // Make the backup poller poll very frequently in order to pick up
+ // updates from all the subchannels's FDs.
+ gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "1");
grpc_init();
const auto result = RUN_ALL_TESTS();
grpc_shutdown();
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 716fb96382..8958b9884d 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/cpp/interop/client_helper.h"
#include "test/cpp/interop/interop_client.h"
#include "test/cpp/util/test_config.h"
diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc
index 1e04e57d09..7a9e3ced6a 100644
--- a/test/cpp/interop/http2_client.cc
+++ b/test/cpp/interop/http2_client.cc
@@ -30,7 +30,7 @@
#include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/interop/http2_client.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/cpp/util/create_test_channel.h"
#include "test/cpp/util/test_config.h"
@@ -217,7 +217,7 @@ int main(int argc, char** argv) {
"goaway", "max_streams", "ping",
"rst_after_data", "rst_after_header", "rst_during_data"};
char* joined_testcases =
- gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL);
+ gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", nullptr);
gpr_log(GPR_ERROR, "Unsupported test case %s. Valid options are\n%s",
FLAGS_test_case.c_str(), joined_testcases);
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index af97fe0940..6b59584353 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -122,7 +122,8 @@ InteropClient::InteropClient(std::shared_ptr<Channel> channel,
: serviceStub_(channel, new_stub_every_test_case),
do_not_abort_on_transient_failures_(do_not_abort_on_transient_failures) {}
-bool InteropClient::AssertStatusOk(const Status& s) {
+bool InteropClient::AssertStatusOk(const Status& s,
+ const grpc::string& optional_debug_string) {
if (s.ok()) {
return true;
}
@@ -131,17 +132,21 @@ bool InteropClient::AssertStatusOk(const Status& s) {
// already checked for s.ok() above). So, the following will call abort()
// (unless s.error_code() corresponds to a transient failure and
// 'do_not_abort_on_transient_failures' is true)
- return AssertStatusCode(s, StatusCode::OK);
+ return AssertStatusCode(s, StatusCode::OK, optional_debug_string);
}
-bool InteropClient::AssertStatusCode(const Status& s,
- StatusCode expected_code) {
+bool InteropClient::AssertStatusCode(
+ const Status& s, StatusCode expected_code,
+ const grpc::string& optional_debug_string) {
if (s.error_code() == expected_code) {
return true;
}
- gpr_log(GPR_ERROR, "Error status code: %d (expected: %d), message: %s",
- s.error_code(), expected_code, s.error_message().c_str());
+ gpr_log(GPR_ERROR,
+ "Error status code: %d (expected: %d), message: %s,"
+ " debug string: %s",
+ s.error_code(), expected_code, s.error_message().c_str(),
+ optional_debug_string.c_str());
// In case of transient transient/retryable failures (like a broken
// connection) we may or may not abort (see TransientFailureOrAbort())
@@ -161,7 +166,7 @@ bool InteropClient::DoEmpty() {
Status s = serviceStub_.Get()->EmptyCall(&context, request, &response);
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -184,14 +189,14 @@ bool InteropClient::PerformLargeUnary(SimpleRequest* request,
request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize);
if (request->has_expect_compressed()) {
if (request->expect_compressed().value()) {
- context.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+ context.set_compression_algorithm(GRPC_COMPRESS_MESSAGE_GZIP);
} else {
context.set_compression_algorithm(GRPC_COMPRESS_NONE);
}
}
Status s = serviceStub_.Get()->UnaryCall(&context, *request, response);
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -241,7 +246,7 @@ bool InteropClient::DoOauth2AuthToken(const grpc::string& username,
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response);
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -269,7 +274,7 @@ bool InteropClient::DoPerRpcCreds(const grpc::string& json_key) {
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response);
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -412,7 +417,7 @@ bool InteropClient::DoRequestStreaming() {
GPR_ASSERT(stream->WritesDone());
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -451,7 +456,7 @@ bool InteropClient::DoResponseStreaming() {
}
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -492,7 +497,7 @@ bool InteropClient::DoClientCompressedStreaming() {
StreamingInputCallRequest request;
StreamingInputCallResponse response;
- context.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+ context.set_compression_algorithm(GRPC_COMPRESS_MESSAGE_GZIP);
std::unique_ptr<ClientWriter<StreamingInputCallRequest>> stream(
serviceStub_.Get()->StreamingInputCall(&context, &response));
@@ -516,7 +521,7 @@ bool InteropClient::DoClientCompressedStreaming() {
GPR_ASSERT(stream->WritesDone());
s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -578,7 +583,7 @@ bool InteropClient::DoServerCompressedStreaming() {
}
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
return true;
@@ -619,7 +624,7 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() {
}
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -666,7 +671,7 @@ bool InteropClient::DoHalfDuplex() {
}
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -710,7 +715,7 @@ bool InteropClient::DoPingPong() {
GPR_ASSERT(!stream->Read(&response));
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -732,7 +737,8 @@ bool InteropClient::DoCancelAfterBegin() {
context.TryCancel();
Status s = stream->Finish();
- if (!AssertStatusCode(s, StatusCode::CANCELLED)) {
+ if (!AssertStatusCode(s, StatusCode::CANCELLED,
+ context.debug_error_string())) {
return false;
}
@@ -790,7 +796,8 @@ bool InteropClient::DoTimeoutOnSleepingServer() {
stream->Write(request);
Status s = stream->Finish();
- if (!AssertStatusCode(s, StatusCode::DEADLINE_EXCEEDED)) {
+ if (!AssertStatusCode(s, StatusCode::DEADLINE_EXCEEDED,
+ context.debug_error_string())) {
return false;
}
@@ -810,7 +817,7 @@ bool InteropClient::DoEmptyStream() {
GPR_ASSERT(stream->Read(&response) == false);
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -833,7 +840,8 @@ bool InteropClient::DoStatusWithMessage() {
requested_status->set_code(test_code);
requested_status->set_message(test_msg);
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response);
- if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN)) {
+ if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN,
+ context.debug_error_string())) {
return false;
}
GPR_ASSERT(s.error_message() == test_msg);
@@ -853,7 +861,8 @@ bool InteropClient::DoStatusWithMessage() {
while (stream->Read(&streaming_response))
;
s = stream->Finish();
- if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN)) {
+ if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN,
+ context.debug_error_string())) {
return false;
}
GPR_ASSERT(s.error_message() == test_msg);
@@ -880,7 +889,7 @@ bool InteropClient::DoCacheableUnary() {
context1.AddMetadata("x-user-ip", "1.2.3.4");
Status s1 =
serviceStub_.Get()->CacheableUnaryCall(&context1, request, &response1);
- if (!AssertStatusOk(s1)) {
+ if (!AssertStatusOk(s1, context1.debug_error_string())) {
return false;
}
gpr_log(GPR_DEBUG, "response 1 payload: %s",
@@ -893,7 +902,7 @@ bool InteropClient::DoCacheableUnary() {
context2.AddMetadata("x-user-ip", "1.2.3.4");
Status s2 =
serviceStub_.Get()->CacheableUnaryCall(&context2, request, &response2);
- if (!AssertStatusOk(s2)) {
+ if (!AssertStatusOk(s2, context2.debug_error_string())) {
return false;
}
gpr_log(GPR_DEBUG, "response 2 payload: %s",
@@ -915,7 +924,7 @@ bool InteropClient::DoCacheableUnary() {
context3.AddMetadata("x-user-ip", "1.2.3.4");
Status s3 =
serviceStub_.Get()->CacheableUnaryCall(&context3, request1, &response3);
- if (!AssertStatusOk(s3)) {
+ if (!AssertStatusOk(s3, context3.debug_error_string())) {
return false;
}
gpr_log(GPR_DEBUG, "response 3 payload: %s",
@@ -946,7 +955,7 @@ bool InteropClient::DoCustomMetadata() {
request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize);
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response);
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -997,7 +1006,7 @@ bool InteropClient::DoCustomMetadata() {
GPR_ASSERT(!stream->Read(&response));
Status s = stream->Finish();
- if (!AssertStatusOk(s)) {
+ if (!AssertStatusOk(s, context.debug_error_string())) {
return false;
}
@@ -1028,7 +1037,8 @@ bool InteropClient::DoUnimplementedService() {
Status s = stub->UnimplementedCall(&context, request, &response);
- if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED)) {
+ if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED,
+ context.debug_error_string())) {
return false;
}
@@ -1046,7 +1056,8 @@ bool InteropClient::DoUnimplementedMethod() {
Status s =
serviceStub_.Get()->UnimplementedCall(&context, request, &response);
- if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED)) {
+ if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED,
+ context.debug_error_string())) {
return false;
}
diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h
index 57e8ba63f5..b8bb134c20 100644
--- a/test/cpp/interop/interop_client.h
+++ b/test/cpp/interop/interop_client.h
@@ -103,8 +103,10 @@ class InteropClient {
/// Run \a custom_check_fn as an additional check.
bool PerformLargeUnary(SimpleRequest* request, SimpleResponse* response,
CheckerFn custom_checks_fn);
- bool AssertStatusOk(const Status& s);
- bool AssertStatusCode(const Status& s, StatusCode expected_code);
+ bool AssertStatusOk(const Status& s,
+ const grpc::string& optional_debug_string);
+ bool AssertStatusCode(const Status& s, StatusCode expected_code,
+ const grpc::string& optional_debug_string);
bool TransientFailureOrAbort();
ServiceStub serviceStub_;
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc
index 4149724b1e..7cfdb2f9e9 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -31,7 +31,7 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/transport/byte_stream.h"
#include "src/proto/grpc/testing/empty.pb.h"
#include "src/proto/grpc/testing/messages.pb.h"
@@ -51,8 +51,9 @@ using grpc::ServerCredentials;
using grpc::ServerReader;
using grpc::ServerReaderWriter;
using grpc::ServerWriter;
-using grpc::WriteOptions;
using grpc::SslServerCredentialsOptions;
+using grpc::Status;
+using grpc::WriteOptions;
using grpc::testing::InteropServerContextInspector;
using grpc::testing::Payload;
using grpc::testing::SimpleRequest;
@@ -62,7 +63,6 @@ using grpc::testing::StreamingInputCallResponse;
using grpc::testing::StreamingOutputCallRequest;
using grpc::testing::StreamingOutputCallResponse;
using grpc::testing::TestService;
-using grpc::Status;
const char kEchoInitialMetadataKey[] = "x-grpc-test-echo-initial";
const char kEchoTrailingBinMetadataKey[] = "x-grpc-test-echo-trailing-bin";
@@ -317,9 +317,15 @@ class TestServiceImpl : public TestService::Service {
void grpc::testing::interop::RunServer(
std::shared_ptr<ServerCredentials> creds) {
- GPR_ASSERT(FLAGS_port != 0);
+ RunServer(creds, FLAGS_port, nullptr);
+}
+
+void grpc::testing::interop::RunServer(
+ std::shared_ptr<ServerCredentials> creds, const int port,
+ ServerStartedCondition* server_started_condition) {
+ GPR_ASSERT(port != 0);
std::ostringstream server_address;
- server_address << "0.0.0.0:" << FLAGS_port;
+ server_address << "0.0.0.0:" << port;
TestServiceImpl service;
SimpleRequest request;
@@ -333,6 +339,14 @@ void grpc::testing::interop::RunServer(
}
std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str());
+
+ // Signal that the server has started.
+ if (server_started_condition) {
+ std::unique_lock<std::mutex> lock(server_started_condition->mutex);
+ server_started_condition->server_started = true;
+ server_started_condition->condition.notify_all();
+ }
+
while (!gpr_atm_no_barrier_load(&g_got_sigint)) {
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(5, GPR_TIMESPAN)));
diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc
index c18fe1ec1f..563b7abb5e 100644
--- a/test/cpp/interop/interop_test.cc
+++ b/test/cpp/interop/interop_test.cc
@@ -37,10 +37,8 @@
#include "test/core/util/port.h"
#include "test/cpp/util/test_config.h"
-extern "C" {
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
-#include "src/core/lib/support/string.h"
-}
DEFINE_string(extra_server_flags, "", "Extra flags to pass to server.");
diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc
index 50af8fcc8a..5e257e1b38 100644
--- a/test/cpp/interop/reconnect_interop_server.cc
+++ b/test/cpp/interop/reconnect_interop_server.cc
@@ -53,9 +53,9 @@ using grpc::ServerWriter;
using grpc::SslServerCredentialsOptions;
using grpc::Status;
using grpc::testing::Empty;
-using grpc::testing::ReconnectService;
using grpc::testing::ReconnectInfo;
using grpc::testing::ReconnectParams;
+using grpc::testing::ReconnectService;
static bool got_sigint = false;
diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h
index 6af003fe93..1bf7db1e14 100644
--- a/test/cpp/interop/server_helper.h
+++ b/test/cpp/interop/server_helper.h
@@ -19,6 +19,7 @@
#ifndef GRPC_TEST_CPP_INTEROP_SERVER_HELPER_H
#define GRPC_TEST_CPP_INTEROP_SERVER_HELPER_H
+#include <condition_variable>
#include <memory>
#include <grpc/compression.h>
@@ -50,8 +51,27 @@ class InteropServerContextInspector {
namespace interop {
extern gpr_atm g_got_sigint;
+
+struct ServerStartedCondition {
+ std::mutex mutex;
+ std::condition_variable condition;
+ bool server_started = false;
+};
+
+/// Run gRPC interop server using port FLAGS_port.
+///
+/// \param creds The credentials associated with the server.
void RunServer(std::shared_ptr<ServerCredentials> creds);
+/// Run gRPC interop server.
+///
+/// \param creds The credentials associated with the server.
+/// \param port Port to use for the server.
+/// \param server_started_condition (optional) Struct holding mutex, condition
+/// variable, and condition used to notify when the server has started.
+void RunServer(std::shared_ptr<ServerCredentials> creds, int port,
+ ServerStartedCondition* server_started_condition);
+
} // namespace interop
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc
index 9cc5a8168b..4b39dc3211 100644
--- a/test/cpp/interop/stress_test.cc
+++ b/test/cpp/interop/stress_test.cc
@@ -36,9 +36,7 @@
#include "test/cpp/util/metrics_server.h"
#include "test/cpp/util/test_config.h"
-extern "C" {
extern void gpr_default_log(gpr_log_func_args* args);
-}
DEFINE_int32(metrics_port, 8081, "The metrics server port.");
@@ -106,13 +104,13 @@ DEFINE_bool(use_test_ca, false, "False to use SSL roots for google");
DEFINE_string(server_host_override, "foo.test.google.fr",
"Override the server host which is sent in HTTP header");
-using grpc::testing::kTestCaseList;
using grpc::testing::MetricsService;
using grpc::testing::MetricsServiceImpl;
using grpc::testing::StressTestInteropClient;
using grpc::testing::TestCaseType;
using grpc::testing::UNKNOWN_TEST;
using grpc::testing::WeightedRandomTestSelector;
+using grpc::testing::kTestCaseList;
static int log_level = GPR_LOG_SEVERITY_DEBUG;
@@ -230,7 +228,7 @@ int main(int argc, char** argv) {
log_level = FLAGS_log_level;
gpr_set_log_function(TestLogFunction);
- srand(time(NULL));
+ srand(time(nullptr));
// Parse the server addresses
std::vector<grpc::string> server_addresses;
@@ -257,6 +255,7 @@ int main(int argc, char** argv) {
gpr_log(GPR_INFO, "Starting test(s)..");
std::vector<std::thread> test_threads;
+ std::vector<std::unique_ptr<StressTestInteropClient>> clients;
// Create and start the test threads.
// Note that:
@@ -282,9 +281,9 @@ int main(int argc, char** argv) {
// Create stub(s) for each channel
for (int stub_idx = 0; stub_idx < FLAGS_num_stubs_per_channel;
stub_idx++) {
- StressTestInteropClient* client = new StressTestInteropClient(
+ clients.emplace_back(new StressTestInteropClient(
++thread_idx, *it, channel, test_selector, FLAGS_test_duration_secs,
- FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures);
+ FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures));
bool is_already_created = false;
// QpsGauge name
@@ -293,7 +292,7 @@ int main(int argc, char** argv) {
server_idx, channel_idx, stub_idx);
test_threads.emplace_back(std::thread(
- &StressTestInteropClient::MainLoop, client,
+ &StressTestInteropClient::MainLoop, clients.back().get(),
metrics_service.CreateQpsGauge(buffer, &is_already_created)));
// The QpsGauge should not have been already created
diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc
index 165b74670d..69c8c1c029 100644
--- a/test/cpp/microbenchmarks/bm_arena.cc
+++ b/test/cpp/microbenchmarks/bm_arena.cc
@@ -18,9 +18,7 @@
/* Benchmark arenas */
-extern "C" {
-#include "src/core/lib/support/arena.h"
-}
+#include "src/core/lib/gpr/arena.h"
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index cadc9b2a11..5c2c38c27d 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -29,7 +29,6 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
-extern "C" {
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/deadline/deadline_filter.h"
#include "src/core/ext/filters/http/client/http_client_filter.h"
@@ -43,15 +42,14 @@ extern "C" {
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/transport_impl.h"
-}
#include "src/cpp/client/create_channel_internal.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/microbenchmarks/helpers.h"
-auto &force_library_initialization = Library::get();
+auto& force_library_initialization = Library::get();
-void BM_Zalloc(benchmark::State &state) {
+void BM_Zalloc(benchmark::State& state) {
// speed of light for call creation is zalloc, so benchmark a few interesting
// sizes
TrackCounters track_counters;
@@ -80,20 +78,20 @@ BENCHMARK(BM_Zalloc)
class BaseChannelFixture {
public:
- BaseChannelFixture(grpc_channel *channel) : channel_(channel) {}
+ BaseChannelFixture(grpc_channel* channel) : channel_(channel) {}
~BaseChannelFixture() { grpc_channel_destroy(channel_); }
- grpc_channel *channel() const { return channel_; }
+ grpc_channel* channel() const { return channel_; }
private:
- grpc_channel *const channel_;
+ grpc_channel* const channel_;
};
class InsecureChannel : public BaseChannelFixture {
public:
InsecureChannel()
: BaseChannelFixture(
- grpc_insecure_channel_create("localhost:1234", NULL, NULL)) {}
+ grpc_insecure_channel_create("localhost:1234", nullptr, nullptr)) {}
};
class LameChannel : public BaseChannelFixture {
@@ -104,17 +102,17 @@ class LameChannel : public BaseChannelFixture {
};
template <class Fixture>
-static void BM_CallCreateDestroy(benchmark::State &state) {
+static void BM_CallCreateDestroy(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- void *method_hdl =
- grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL);
+ void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar",
+ nullptr, nullptr);
while (state.KeepRunning()) {
grpc_call_unref(grpc_channel_create_registered_call(
- fixture.channel(), NULL, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl,
- deadline, NULL));
+ fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl,
+ deadline, nullptr));
}
grpc_completion_queue_destroy(cq);
track_counters.Finish(state);
@@ -126,11 +124,11 @@ BENCHMARK_TEMPLATE(BM_CallCreateDestroy, LameChannel);
////////////////////////////////////////////////////////////////////////////////
// Benchmarks isolating individual filters
-static void *tag(int i) {
- return reinterpret_cast<void *>(static_cast<intptr_t>(i));
+static void* tag(int i) {
+ return reinterpret_cast<void*>(static_cast<intptr_t>(i));
}
-static void BM_LameChannelCallCreateCpp(benchmark::State &state) {
+static void BM_LameChannelCallCreateCpp(benchmark::State& state) {
TrackCounters track_counters;
auto stub =
grpc::testing::EchoTestService::NewStub(grpc::CreateChannelInternal(
@@ -145,7 +143,7 @@ static void BM_LameChannelCallCreateCpp(benchmark::State &state) {
grpc::ClientContext cli_ctx;
auto reader = stub->AsyncEcho(&cli_ctx, send_request, &cq);
reader->Finish(&recv_response, &recv_status, tag(0));
- void *t;
+ void* t;
bool ok;
GPR_ASSERT(cq.Next(&t, &ok));
GPR_ASSERT(ok);
@@ -154,16 +152,16 @@ static void BM_LameChannelCallCreateCpp(benchmark::State &state) {
}
BENCHMARK(BM_LameChannelCallCreateCpp);
-static void do_nothing(void *ignored) {}
+static void do_nothing(void* ignored) {}
-static void BM_LameChannelCallCreateCore(benchmark::State &state) {
+static void BM_LameChannelCallCreateCore(benchmark::State& state) {
TrackCounters track_counters;
- grpc_channel *channel;
- grpc_completion_queue *cq;
+ grpc_channel* channel;
+ grpc_completion_queue* cq;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_status_code status;
grpc_slice details;
grpc::testing::EchoRequest send_request;
@@ -172,23 +170,23 @@ static void BM_LameChannelCallCreateCore(benchmark::State &state) {
channel = grpc_lame_client_channel_create(
"localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah");
- cq = grpc_completion_queue_create_for_next(NULL);
- void *rc = grpc_channel_register_call(
- channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
+ void* rc = grpc_channel_register_call(
+ channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- grpc_call *call = grpc_channel_create_registered_call(
- channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_call* call = grpc_channel_create_registered_call(
+ channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc,
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
- grpc_byte_buffer *request_payload_send =
+ grpc_byte_buffer* request_payload_send =
grpc_raw_byte_buffer_create(&send_request_slice, 1);
// Fill in call ops
grpc_op ops[6];
memset(ops, 0, sizeof(ops));
- grpc_op *op = ops;
+ grpc_op* op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
@@ -212,9 +210,9 @@ static void BM_LameChannelCallCreateCore(benchmark::State &state) {
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
(size_t)(op - ops),
- (void *)1, NULL));
+ (void*)1, nullptr));
grpc_event ev = grpc_completion_queue_next(
- cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN);
GPR_ASSERT(ev.success != 0);
grpc_call_unref(call);
@@ -230,14 +228,14 @@ static void BM_LameChannelCallCreateCore(benchmark::State &state) {
}
BENCHMARK(BM_LameChannelCallCreateCore);
-static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) {
+static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) {
TrackCounters track_counters;
- grpc_channel *channel;
- grpc_completion_queue *cq;
+ grpc_channel* channel;
+ grpc_completion_queue* cq;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
- grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_status_code status;
grpc_slice details;
grpc::testing::EchoRequest send_request;
@@ -246,23 +244,23 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) {
channel = grpc_lame_client_channel_create(
"localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah");
- cq = grpc_completion_queue_create_for_next(NULL);
- void *rc = grpc_channel_register_call(
- channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
+ void* rc = grpc_channel_register_call(
+ channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- grpc_call *call = grpc_channel_create_registered_call(
- channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_call* call = grpc_channel_create_registered_call(
+ channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc,
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
- grpc_byte_buffer *request_payload_send =
+ grpc_byte_buffer* request_payload_send =
grpc_raw_byte_buffer_create(&send_request_slice, 1);
// Fill in call ops
grpc_op ops[3];
memset(ops, 0, sizeof(ops));
- grpc_op *op = ops;
+ grpc_op* op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
@@ -273,7 +271,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
(size_t)(op - ops),
- (void *)0, NULL));
+ (void*)nullptr, nullptr));
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
@@ -291,13 +289,13 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) {
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
(size_t)(op - ops),
- (void *)1, NULL));
+ (void*)1, nullptr));
grpc_event ev = grpc_completion_queue_next(
- cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN);
GPR_ASSERT(ev.success == 0);
ev = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN);
GPR_ASSERT(ev.success != 0);
grpc_call_unref(call);
@@ -313,31 +311,25 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) {
}
BENCHMARK(BM_LameChannelCallCreateCoreSeparateBatch);
-static void FilterDestroy(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- gpr_free(arg);
-}
+static void FilterDestroy(void* arg, grpc_error* error) { gpr_free(arg); }
-static void DoNothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+static void DoNothing(void* arg, grpc_error* error) {}
class FakeClientChannelFactory : public grpc_client_channel_factory {
public:
FakeClientChannelFactory() { vtable = &vtable_; }
private:
- static void NoRef(grpc_client_channel_factory *factory) {}
- static void NoUnref(grpc_exec_ctx *exec_ctx,
- grpc_client_channel_factory *factory) {}
- static grpc_subchannel *CreateSubchannel(grpc_exec_ctx *exec_ctx,
- grpc_client_channel_factory *factory,
- const grpc_subchannel_args *args) {
+ static void NoRef(grpc_client_channel_factory* factory) {}
+ static void NoUnref(grpc_client_channel_factory* factory) {}
+ static grpc_subchannel* CreateSubchannel(grpc_client_channel_factory* factory,
+ const grpc_subchannel_args* args) {
return nullptr;
}
- static grpc_channel *CreateClientChannel(grpc_exec_ctx *exec_ctx,
- grpc_client_channel_factory *factory,
- const char *target,
+ static grpc_channel* CreateClientChannel(grpc_client_channel_factory* factory,
+ const char* target,
grpc_client_channel_type type,
- const grpc_channel_args *args) {
+ const grpc_channel_args* args) {
return nullptr;
}
@@ -347,11 +339,11 @@ class FakeClientChannelFactory : public grpc_client_channel_factory {
const grpc_client_channel_factory_vtable FakeClientChannelFactory::vtable_ = {
NoRef, NoUnref, CreateSubchannel, CreateClientChannel};
-static grpc_arg StringArg(const char *key, const char *value) {
+static grpc_arg StringArg(const char* key, const char* value) {
grpc_arg a;
a.type = GRPC_ARG_STRING;
- a.key = const_cast<char *>(key);
- a.value.string = const_cast<char *>(value);
+ a.key = const_cast<char*>(key);
+ a.value.string = const_cast<char*>(value);
return a;
}
@@ -360,45 +352,41 @@ enum FixtureFlags : uint32_t {
REQUIRES_TRANSPORT = 2,
};
-template <const grpc_channel_filter *kFilter, uint32_t kFlags>
+template <const grpc_channel_filter* kFilter, uint32_t kFlags>
struct Fixture {
- const grpc_channel_filter *filter = kFilter;
+ const grpc_channel_filter* filter = kFilter;
const uint32_t flags = kFlags;
};
namespace dummy_filter {
-static void StartTransportStreamOp(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {}
+static void StartTransportStreamOp(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {}
-static void StartTransportOp(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_transport_op *op) {}
+static void StartTransportOp(grpc_channel_element* elem,
+ grpc_transport_op* op) {}
-static grpc_error *InitCallElem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
+static grpc_error* InitCallElem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {}
+static void SetPollsetOrPollsetSet(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {}
-static void DestroyCallElem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_sched_closure) {}
+static void DestroyCallElem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_sched_closure) {}
-grpc_error *InitChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+grpc_error* InitChannelElem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-void DestroyChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {}
+void DestroyChannelElem(grpc_channel_element* elem) {}
-void GetChannelInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {}
+void GetChannelInfo(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {}
static const grpc_channel_filter dummy_filter = {StartTransportStreamOp,
StartTransportOp,
@@ -421,44 +409,41 @@ namespace dummy_transport {
size_t sizeof_stream; /* = sizeof(transport stream) */
/* name of this transport implementation */
-const char *name;
+const char* name;
/* implementation of grpc_transport_init_stream */
-int InitStream(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_stream_refcount *refcount,
- const void *server_data, gpr_arena *arena) {
+int InitStream(grpc_transport* self, grpc_stream* stream,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
return 0;
}
/* implementation of grpc_transport_set_pollset */
-void SetPollset(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_pollset *pollset) {}
+void SetPollset(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset* pollset) {}
/* implementation of grpc_transport_set_pollset */
-void SetPollsetSet(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_pollset_set *pollset_set) {}
+void SetPollsetSet(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset_set* pollset_set) {}
/* implementation of grpc_transport_perform_stream_op */
-void PerformStreamOp(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_transport_stream_op_batch *op) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE);
+void PerformStreamOp(grpc_transport* self, grpc_stream* stream,
+ grpc_transport_stream_op_batch* op) {
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
}
/* implementation of grpc_transport_perform_op */
-void PerformOp(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_transport_op *op) {}
+void PerformOp(grpc_transport* self, grpc_transport_op* op) {}
/* implementation of grpc_transport_destroy_stream */
-void DestroyStream(grpc_exec_ctx *exec_ctx, grpc_transport *self,
- grpc_stream *stream, grpc_closure *then_sched_closure) {}
+void DestroyStream(grpc_transport* self, grpc_stream* stream,
+ grpc_closure* then_sched_closure) {}
/* implementation of grpc_transport_destroy */
-void Destroy(grpc_exec_ctx *exec_ctx, grpc_transport *self) {}
+void Destroy(grpc_transport* self) {}
/* implementation of grpc_transport_get_endpoint */
-grpc_endpoint *GetEndpoint(grpc_exec_ctx *exec_ctx, grpc_transport *self) {
- return nullptr;
-}
+grpc_endpoint* GetEndpoint(grpc_transport* self) { return nullptr; }
static const grpc_transport_vtable dummy_transport_vtable = {
0, "dummy_http2", InitStream,
@@ -474,8 +459,8 @@ class NoOp {
public:
class Op {
public:
- Op(grpc_exec_ctx *exec_ctx, NoOp *p, grpc_call_stack *s) {}
- void Finish(grpc_exec_ctx *exec_ctx) {}
+ Op(NoOp* p, grpc_call_stack* s) {}
+ void Finish() {}
};
};
@@ -491,13 +476,11 @@ class SendEmptyMetadata {
class Op {
public:
- Op(grpc_exec_ctx *exec_ctx, SendEmptyMetadata *p, grpc_call_stack *s) {
+ Op(SendEmptyMetadata* p, grpc_call_stack* s) {
grpc_metadata_batch_init(&batch_);
p->op_payload_.send_initial_metadata.send_initial_metadata = &batch_;
}
- void Finish(grpc_exec_ctx *exec_ctx) {
- grpc_metadata_batch_destroy(exec_ctx, &batch_);
- }
+ void Finish() { grpc_metadata_batch_destroy(&batch_); }
private:
grpc_metadata_batch batch_;
@@ -516,7 +499,7 @@ class SendEmptyMetadata {
// Fixture<> template to specify this), and TestOp defines some unit of work to
// perform on said filter.
template <class Fixture, class TestOp>
-static void BM_IsolatedFilter(benchmark::State &state) {
+static void BM_IsolatedFilter(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
std::ostringstream label;
@@ -529,7 +512,7 @@ static void BM_IsolatedFilter(benchmark::State &state) {
grpc_channel_args channel_args = {args.size(), &args[0]};
- std::vector<const grpc_channel_filter *> filters;
+ std::vector<const grpc_channel_filter*> filters;
if (fixture.filter != nullptr) {
filters.push_back(fixture.filter);
}
@@ -538,31 +521,31 @@ static void BM_IsolatedFilter(benchmark::State &state) {
label << " #has_dummy_filter";
}
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
size_t channel_size = grpc_channel_stack_size(
- filters.size() == 0 ? NULL : &filters[0], filters.size());
- grpc_channel_stack *channel_stack =
- static_cast<grpc_channel_stack *>(gpr_zalloc(channel_size));
+ filters.size() == 0 ? nullptr : &filters[0], filters.size());
+ grpc_channel_stack* channel_stack =
+ static_cast<grpc_channel_stack*>(gpr_zalloc(channel_size));
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"channel_stack_init",
- grpc_channel_stack_init(&exec_ctx, 1, FilterDestroy, channel_stack,
- &filters[0], filters.size(), &channel_args,
+ grpc_channel_stack_init(1, FilterDestroy, channel_stack, &filters[0],
+ filters.size(), &channel_args,
fixture.flags & REQUIRES_TRANSPORT
? &dummy_transport::dummy_transport
: nullptr,
"CHANNEL", channel_stack)));
- grpc_exec_ctx_flush(&exec_ctx);
- grpc_call_stack *call_stack = static_cast<grpc_call_stack *>(
- gpr_zalloc(channel_stack->call_stack_size));
- gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_call_stack* call_stack =
+ static_cast<grpc_call_stack*>(gpr_zalloc(channel_stack->call_stack_size));
+ grpc_millis deadline = GRPC_MILLIS_INF_FUTURE;
gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC);
grpc_slice method = grpc_slice_from_static_string("/foo/bar");
grpc_call_final_info final_info;
TestOp test_op_data;
grpc_call_element_args call_args;
call_args.call_stack = call_stack;
- call_args.server_transport_data = NULL;
- call_args.context = NULL;
+ call_args.server_transport_data = nullptr;
+ call_args.context = nullptr;
call_args.path = method;
call_args.start_time = start_time;
call_args.deadline = deadline;
@@ -570,12 +553,12 @@ static void BM_IsolatedFilter(benchmark::State &state) {
call_args.arena = gpr_arena_create(kArenaSize);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- GRPC_ERROR_UNREF(grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- DoNothing, NULL, &call_args));
- typename TestOp::Op op(&exec_ctx, &test_op_data, call_stack);
- grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, NULL);
- op.Finish(&exec_ctx);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_ERROR_UNREF(
+ grpc_call_stack_init(channel_stack, 1, DoNothing, nullptr, &call_args));
+ typename TestOp::Op op(&test_op_data, call_stack);
+ grpc_call_stack_destroy(call_stack, &final_info, nullptr);
+ op.Finish();
+ grpc_core::ExecCtx::Get()->Flush();
// recreate arena every 64k iterations to avoid oom
if (0 == (state.iterations() & 0xffff)) {
gpr_arena_destroy(call_args.arena);
@@ -583,8 +566,8 @@ static void BM_IsolatedFilter(benchmark::State &state) {
}
}
gpr_arena_destroy(call_args.arena);
- grpc_channel_stack_destroy(&exec_ctx, channel_stack);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_stack_destroy(channel_stack);
+
gpr_free(channel_stack);
gpr_free(call_stack);
@@ -630,62 +613,60 @@ BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, SendEmptyMetadata);
namespace isolated_call_filter {
-typedef struct { grpc_call_combiner *call_combiner; } call_data;
+typedef struct {
+ grpc_call_combiner* call_combiner;
+} call_data;
-static void StartTransportStreamOp(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_transport_stream_op_batch *op) {
- call_data *calld = static_cast<call_data *>(elem->call_data);
+static void StartTransportStreamOp(grpc_call_element* elem,
+ grpc_transport_stream_op_batch* op) {
+ call_data* calld = static_cast<call_data*>(elem->call_data);
if (op->recv_initial_metadata) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE, "recv_initial_metadata");
}
if (op->recv_message) {
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_START(calld->call_combiner,
op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE, "recv_message");
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
}
-static void StartTransportOp(grpc_exec_ctx *exec_ctx,
- grpc_channel_element *elem,
- grpc_transport_op *op) {
+static void StartTransportOp(grpc_channel_element* elem,
+ grpc_transport_op* op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
-static grpc_error *InitCallElem(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- const grpc_call_element_args *args) {
- call_data *calld = static_cast<call_data *>(elem->call_data);
+static grpc_error* InitCallElem(grpc_call_element* elem,
+ const grpc_call_element_args* args) {
+ call_data* calld = static_cast<call_data*>(elem->call_data);
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
-static void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx,
- grpc_call_element *elem,
- grpc_polling_entity *pollent) {}
+static void SetPollsetOrPollsetSet(grpc_call_element* elem,
+ grpc_polling_entity* pollent) {}
-static void DestroyCallElem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
- const grpc_call_final_info *final_info,
- grpc_closure *then_sched_closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, then_sched_closure, GRPC_ERROR_NONE);
+static void DestroyCallElem(grpc_call_element* elem,
+ const grpc_call_final_info* final_info,
+ grpc_closure* then_sched_closure) {
+ GRPC_CLOSURE_SCHED(then_sched_closure, GRPC_ERROR_NONE);
}
-grpc_error *InitChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- grpc_channel_element_args *args) {
+grpc_error* InitChannelElem(grpc_channel_element* elem,
+ grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-void DestroyChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {}
+void DestroyChannelElem(grpc_channel_element* elem) {}
-void GetChannelInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
- const grpc_channel_info *channel_info) {}
+void GetChannelInfo(grpc_channel_element* elem,
+ const grpc_channel_info* channel_info) {}
static const grpc_channel_filter isolated_call_filter = {
StartTransportStreamOp,
@@ -704,57 +685,56 @@ static const grpc_channel_filter isolated_call_filter = {
class IsolatedCallFixture : public TrackCounters {
public:
IsolatedCallFixture() {
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder_set_name(builder, "dummy");
grpc_channel_stack_builder_set_target(builder, "dummy_target");
GPR_ASSERT(grpc_channel_stack_builder_append_filter(
- builder, &isolated_call_filter::isolated_call_filter, NULL, NULL));
+ builder, &isolated_call_filter::isolated_call_filter, nullptr,
+ nullptr));
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- channel_ = grpc_channel_create_with_builder(&exec_ctx, builder,
- GRPC_CLIENT_CHANNEL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ channel_ = grpc_channel_create_with_builder(builder, GRPC_CLIENT_CHANNEL);
}
- cq_ = grpc_completion_queue_create_for_next(NULL);
+ cq_ = grpc_completion_queue_create_for_next(nullptr);
}
- void Finish(benchmark::State &state) {
+ void Finish(benchmark::State& state) {
grpc_completion_queue_destroy(cq_);
grpc_channel_destroy(channel_);
TrackCounters::Finish(state);
}
- grpc_channel *channel() const { return channel_; }
- grpc_completion_queue *cq() const { return cq_; }
+ grpc_channel* channel() const { return channel_; }
+ grpc_completion_queue* cq() const { return cq_; }
private:
- grpc_completion_queue *cq_;
- grpc_channel *channel_;
+ grpc_completion_queue* cq_;
+ grpc_channel* channel_;
};
-static void BM_IsolatedCall_NoOp(benchmark::State &state) {
+static void BM_IsolatedCall_NoOp(benchmark::State& state) {
IsolatedCallFixture fixture;
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- void *method_hdl =
- grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL);
+ void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar",
+ nullptr, nullptr);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
grpc_call_unref(grpc_channel_create_registered_call(
fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(),
- method_hdl, deadline, NULL));
+ method_hdl, deadline, nullptr));
}
fixture.Finish(state);
}
BENCHMARK(BM_IsolatedCall_NoOp);
-static void BM_IsolatedCall_Unary(benchmark::State &state) {
+static void BM_IsolatedCall_Unary(benchmark::State& state) {
IsolatedCallFixture fixture;
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- void *method_hdl =
- grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL);
+ void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar",
+ nullptr, nullptr);
grpc_slice slice = grpc_slice_from_static_string("hello world");
- grpc_byte_buffer *send_message = grpc_raw_byte_buffer_create(&slice, 1);
- grpc_byte_buffer *recv_message = NULL;
+ grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1);
+ grpc_byte_buffer* recv_message = nullptr;
grpc_status_code status_code;
grpc_slice status_details = grpc_empty_slice();
grpc_metadata_array recv_initial_metadata;
@@ -778,12 +758,12 @@ static void BM_IsolatedCall_Unary(benchmark::State &state) {
ops[5].data.recv_status_on_client.trailing_metadata = &recv_trailing_metadata;
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- grpc_call *call = grpc_channel_create_registered_call(
+ grpc_call* call = grpc_channel_create_registered_call(
fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(),
- method_hdl, deadline, NULL);
- grpc_call_start_batch(call, ops, 6, tag(1), NULL);
+ method_hdl, deadline, nullptr);
+ grpc_call_start_batch(call, ops, 6, tag(1), nullptr);
grpc_completion_queue_next(fixture.cq(),
- gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
grpc_call_unref(call);
}
fixture.Finish(state);
@@ -793,13 +773,13 @@ static void BM_IsolatedCall_Unary(benchmark::State &state) {
}
BENCHMARK(BM_IsolatedCall_Unary);
-static void BM_IsolatedCall_StreamingSend(benchmark::State &state) {
+static void BM_IsolatedCall_StreamingSend(benchmark::State& state) {
IsolatedCallFixture fixture;
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- void *method_hdl =
- grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL);
+ void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar",
+ nullptr, nullptr);
grpc_slice slice = grpc_slice_from_static_string("hello world");
- grpc_byte_buffer *send_message = grpc_raw_byte_buffer_create(&slice, 1);
+ grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1);
grpc_metadata_array recv_initial_metadata;
grpc_metadata_array_init(&recv_initial_metadata);
grpc_metadata_array recv_trailing_metadata;
@@ -810,20 +790,20 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State &state) {
ops[1].op = GRPC_OP_RECV_INITIAL_METADATA;
ops[1].data.recv_initial_metadata.recv_initial_metadata =
&recv_initial_metadata;
- grpc_call *call = grpc_channel_create_registered_call(
+ grpc_call* call = grpc_channel_create_registered_call(
fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(),
- method_hdl, deadline, NULL);
- grpc_call_start_batch(call, ops, 2, tag(1), NULL);
+ method_hdl, deadline, nullptr);
+ grpc_call_start_batch(call, ops, 2, tag(1), nullptr);
grpc_completion_queue_next(fixture.cq(), gpr_inf_future(GPR_CLOCK_MONOTONIC),
- NULL);
+ nullptr);
memset(ops, 0, sizeof(ops));
ops[0].op = GRPC_OP_SEND_MESSAGE;
ops[0].data.send_message.send_message = send_message;
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- grpc_call_start_batch(call, ops, 1, tag(2), NULL);
+ grpc_call_start_batch(call, ops, 1, tag(2), nullptr);
grpc_completion_queue_next(fixture.cq(),
- gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
}
grpc_call_unref(call);
fixture.Finish(state);
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index adbfa4d796..4b7310389c 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -22,50 +22,102 @@
#include <grpc/support/log.h>
#include <string.h>
#include <sstream>
-extern "C" {
+
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/transport/static_metadata.h"
-}
+#include "src/core/lib/transport/timeout_encoding.h"
+
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
-auto &force_library_initialization = Library::get();
+auto& force_library_initialization = Library::get();
+
+static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
+ grpc_slice s = grpc_slice_malloc(bytes.size());
+ uint8_t* p = GRPC_SLICE_START_PTR(s);
+ for (auto b : bytes) {
+ *p++ = b;
+ }
+ return s;
+}
////////////////////////////////////////////////////////////////////////////////
// HPACK encoder
//
-static void BM_HpackEncoderInitDestroy(benchmark::State &state) {
+static void BM_HpackEncoderInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_chttp2_hpack_compressor c;
while (state.KeepRunning()) {
grpc_chttp2_hpack_compressor_init(&c);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackEncoderInitDestroy);
+static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
+ TrackCounters track_counters;
+ grpc_core::ExecCtx exec_ctx;
+ grpc_millis saved_now = grpc_core::ExecCtx::Get()->Now();
+
+ grpc_metadata_batch b;
+ grpc_metadata_batch_init(&b);
+ b.deadline = saved_now + 30 * 1000;
+
+ grpc_chttp2_hpack_compressor c;
+ grpc_chttp2_hpack_compressor_init(&c);
+ grpc_transport_one_way_stats stats;
+ memset(&stats, 0, sizeof(stats));
+ grpc_slice_buffer outbuf;
+ grpc_slice_buffer_init(&outbuf);
+ while (state.KeepRunning()) {
+ grpc_encode_header_options hopt = {
+ static_cast<uint32_t>(state.iterations()),
+ true,
+ false,
+ (size_t)1024,
+ &stats,
+ };
+ grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_slice_buffer_reset_and_unref_internal(&outbuf);
+ grpc_core::ExecCtx::Get()->Flush();
+ }
+ grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_slice_buffer_destroy_internal(&outbuf);
+
+ std::ostringstream label;
+ label << "framing_bytes/iter:"
+ << (static_cast<double>(stats.framing_bytes) /
+ static_cast<double>(state.iterations()))
+ << " header_bytes/iter:"
+ << (static_cast<double>(stats.header_bytes) /
+ static_cast<double>(state.iterations()));
+ track_counters.AddLabel(label.str());
+ track_counters.Finish(state);
+}
+BENCHMARK(BM_HpackEncoderEncodeDeadline);
+
template <class Fixture>
-static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
+static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
static bool logged_representative_output = false;
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
- std::vector<grpc_mdelem> elems = Fixture::GetElems(&exec_ctx);
+ std::vector<grpc_mdelem> elems = Fixture::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(&exec_ctx, &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
grpc_chttp2_hpack_compressor c;
@@ -82,29 +134,30 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
(size_t)state.range(1),
&stats,
};
- grpc_chttp2_encode_header(&exec_ctx, &c, NULL, 0, &b, &hopt, &outbuf);
+ grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
if (!logged_representative_output && state.iterations() > 3) {
logged_representative_output = true;
for (size_t i = 0; i < outbuf.count; i++) {
- char *s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX);
+ char* s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX);
gpr_log(GPR_DEBUG, "%" PRIdPTR ": %s", i, s);
gpr_free(s);
}
}
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_slice_buffer_reset_and_unref_internal(&outbuf);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_metadata_batch_destroy(&exec_ctx, &b);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;
- label << "framing_bytes/iter:" << (static_cast<double>(stats.framing_bytes) /
- static_cast<double>(state.iterations()))
- << " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) /
- static_cast<double>(state.iterations()));
- state.SetLabel(label.str());
+ label << "framing_bytes/iter:"
+ << (static_cast<double>(stats.framing_bytes) /
+ static_cast<double>(state.iterations()))
+ << " header_bytes/iter:"
+ << (static_cast<double>(stats.header_bytes) /
+ static_cast<double>(state.iterations()));
+ track_counters.AddLabel(label.str());
track_counters.Finish(state);
}
@@ -113,15 +166,13 @@ namespace hpack_encoder_fixtures {
class EmptyBatch {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
- return {};
- }
+ static std::vector<grpc_mdelem> GetElems() { return {}; }
};
class SingleStaticElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE};
}
};
@@ -129,9 +180,9 @@ class SingleStaticElem {
class SingleInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("def")))};
}
};
@@ -140,10 +191,10 @@ template <int kLength, bool kTrueBinary>
class SingleInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
grpc_slice bytes = MakeBytes();
std::vector<grpc_mdelem> out = {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
grpc_slice_intern(bytes))};
grpc_slice_unref(bytes);
return out;
@@ -162,9 +213,9 @@ class SingleInternedBinaryElem {
class SingleInternedKeyElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_from_static_string("def"))};
}
};
@@ -172,9 +223,8 @@ class SingleInternedKeyElem {
class SingleNonInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
- return {grpc_mdelem_from_slices(exec_ctx,
- grpc_slice_from_static_string("abc"),
+ static std::vector<grpc_mdelem> GetElems() {
+ return {grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
grpc_slice_from_static_string("def"))};
}
};
@@ -183,9 +233,9 @@ template <int kLength, bool kTrueBinary>
class SingleNonInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
- return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_from_static_string("abc-bin"), MakeBytes())};
+ static std::vector<grpc_mdelem> GetElems() {
+ return {grpc_mdelem_from_slices(grpc_slice_from_static_string("abc-bin"),
+ MakeBytes())};
}
private:
@@ -201,20 +251,61 @@ class SingleNonInternedBinaryElem {
class RepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
- GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST,
+ GRPC_MDELEM_SCHEME_HTTP,
+ GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ "grpc-c/3.0.0-dev (linux; chttp2; green)")))};
+ }
+};
+
+// This fixture reflects how initial metadata are sent by a production client,
+// with non-indexed :path and binary headers. The metadata here are the same as
+// the corresponding parser benchmark below.
+class MoreRepresentativeClientInitialMetadata {
+ public:
+ static constexpr bool kEnableTrueBinary = true;
+ static std::vector<grpc_mdelem> GetElems() {
+ return {
+ GRPC_MDELEM_SCHEME_HTTP,
+ GRPC_MDELEM_METHOD_POST,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ "/grpc.test.FooService/BarMethod"))),
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ "foo.test.google.fr:1234"))),
+ grpc_mdelem_from_slices(
+ GRPC_MDSTR_GRPC_TRACE_BIN,
+ grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27\x28"
+ "\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30")),
+ grpc_mdelem_from_slices(
+ GRPC_MDSTR_GRPC_TAGS_BIN,
+ grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13")),
+ GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
+ GRPC_MDELEM_TE_TRAILERS,
+ GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
+ grpc_mdelem_from_slices(
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -223,7 +314,7 @@ class RepresentativeClientInitialMetadata {
class RepresentativeServerInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_STATUS_200,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP};
@@ -233,7 +324,7 @@ class RepresentativeServerInitialMetadata {
class RepresentativeServerTrailingMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_GRPC_STATUS_0};
}
};
@@ -317,6 +408,9 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
RepresentativeClientInitialMetadata)
->Args({0, 16384});
BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
+ MoreRepresentativeClientInitialMetadata)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
RepresentativeServerInitialMetadata)
->Args({0, 16384});
BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
@@ -329,62 +423,52 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
// HPACK parser
//
-static void BM_HpackParserInitDestroy(benchmark::State &state) {
+static void BM_HpackParserInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_chttp2_hpack_parser p;
while (state.KeepRunning()) {
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_hpack_parser_init(&p);
+ grpc_chttp2_hpack_parser_destroy(&p);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackParserInitDestroy);
-static void UnrefHeader(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
+static void UnrefHeader(void* user_data, grpc_mdelem md) {
+ GRPC_MDELEM_UNREF(md);
}
-template <class Fixture>
-static void BM_HpackParserParseHeader(benchmark::State &state) {
+template <class Fixture, void (*OnHeader)(void*, grpc_mdelem)>
+static void BM_HpackParserParseHeader(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
std::vector<grpc_slice> init_slices = Fixture::GetInitSlices();
std::vector<grpc_slice> benchmark_slices = Fixture::GetBenchmarkSlices();
grpc_chttp2_hpack_parser p;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
- p.on_header = UnrefHeader;
+ grpc_chttp2_hpack_parser_init(&p);
+ p.on_header = OnHeader;
p.on_header_user_data = nullptr;
for (auto slice : init_slices) {
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
while (state.KeepRunning()) {
for (auto slice : benchmark_slices) {
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (auto slice : init_slices) grpc_slice_unref(slice);
for (auto slice : benchmark_slices) grpc_slice_unref(slice);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hpack_parser_destroy(&p);
+
track_counters.Finish(state);
}
namespace hpack_parser_fixtures {
-static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
- grpc_slice s = grpc_slice_malloc(bytes.size());
- uint8_t *p = GRPC_SLICE_START_PTR(s);
- for (auto b : bytes) {
- *p++ = b;
- }
- return s;
-}
-
class EmptyBatch {
public:
static std::vector<grpc_slice> GetInitSlices() { return {}; }
@@ -572,6 +656,54 @@ class RepresentativeClientInitialMetadata {
}
};
+// This fixture reflects how initial metadata are sent by a production client,
+// with non-indexed :path and binary headers. The metadata here are the same as
+// the corresponding encoder benchmark above.
+class MoreRepresentativeClientInitialMetadata {
+ public:
+ static std::vector<grpc_slice> GetInitSlices() {
+ return {MakeSlice(
+ {0x40, 0x07, ':', 's', 'c', 'h', 'e', 'm', 'e', 0x04, 'h', 't',
+ 't', 'p', 0x40, 0x07, ':', 'm', 'e', 't', 'h', 'o', 'd', 0x04,
+ 'P', 'O', 'S', 'T', 0x40, 0x05, ':', 'p', 'a', 't', 'h', 0x1f,
+ '/', 'g', 'r', 'p', 'c', '.', 't', 'e', 's', 't', '.', 'F',
+ 'o', 'o', 'S', 'e', 'r', 'v', 'i', 'c', 'e', '/', 'B', 'a',
+ 'r', 'M', 'e', 't', 'h', 'o', 'd', 0x40, 0x0a, ':', 'a', 'u',
+ 't', 'h', 'o', 'r', 'i', 't', 'y', 0x09, 'l', 'o', 'c', 'a',
+ 'l', 'h', 'o', 's', 't', 0x40, 0x0e, 'g', 'r', 'p', 'c', '-',
+ 't', 'r', 'a', 'c', 'e', '-', 'b', 'i', 'n', 0x31, 0x00, 0x01,
+ 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+ 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x40,
+ 0x0d, 'g', 'r', 'p', 'c', '-', 't', 'a', 'g', 's', '-', 'b',
+ 'i', 'n', 0x14, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x40,
+ 0x0c, 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p',
+ 'e', 0x10, 'a', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o',
+ 'n', '/', 'g', 'r', 'p', 'c', 0x40, 0x14, 'g', 'r', 'p', 'c',
+ '-', 'a', 'c', 'c', 'e', 'p', 't', '-', 'e', 'n', 'c', 'o',
+ 'd', 'i', 'n', 'g', 0x15, 'i', 'd', 'e', 'n', 't', 'i', 't',
+ 'y', ',', 'd', 'e', 'f', 'l', 'a', 't', 'e', ',', 'g', 'z',
+ 'i', 'p', 0x40, 0x02, 't', 'e', 0x08, 't', 'r', 'a', 'i', 'l',
+ 'e', 'r', 's', 0x40, 0x0a, 'u', 's', 'e', 'r', '-', 'a', 'g',
+ 'e', 'n', 't', 0x22, 'b', 'a', 'd', '-', 'c', 'l', 'i', 'e',
+ 'n', 't', ' ', 'g', 'r', 'p', 'c', '-', 'c', '/', '0', '.',
+ '1', '2', '.', '0', '.', '0', ' ', '(', 'l', 'i', 'n', 'u',
+ 'x', ')'})};
+ }
+ static std::vector<grpc_slice> GetBenchmarkSlices() {
+ return {MakeSlice(
+ {0xc7, 0xc6, 0xc5, 0xc4, 0x7f, 0x04, 0x31, 0x00, 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
+ 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x7f, 0x03, 0x14, 0x00,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0xc1, 0xc0, 0xbf, 0xbe})};
+ }
+};
+
class RepresentativeServerInitialMetadata {
public:
static std::vector<grpc_slice> GetInitSlices() {
@@ -625,30 +757,96 @@ class RepresentativeServerTrailingMetadata {
}
};
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, EmptyBatch);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleStaticElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleStaticElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleStaticElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleInternedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleInternedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleInternedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<1, false>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<3, false>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<10, false>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<31, false>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<100, false>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<1, true>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<3, true>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<10, true>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<31, true>);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<100, true>);
+static void free_timeout(void* p) { gpr_free(p); }
+
+// New implementation.
+static void OnHeaderNew(void* user_data, grpc_mdelem md) {
+ if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
+ grpc_millis* cached_timeout =
+ static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
+ grpc_millis timeout;
+ if (cached_timeout != nullptr) {
+ timeout = *cached_timeout;
+ } else {
+ if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
+ gpr_free(val);
+ timeout = GRPC_MILLIS_INF_FUTURE;
+ }
+ if (GRPC_MDELEM_IS_INTERNED(md)) {
+ /* not already parsed: parse it now, and store the
+ * result away */
+ cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
+ *cached_timeout = timeout;
+ grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
+ }
+ }
+ benchmark::DoNotOptimize(timeout);
+ GRPC_MDELEM_UNREF(md);
+ } else {
+ GPR_ASSERT(0);
+ }
+}
+
+// Send the same deadline repeatedly
+class SameDeadline {
+ public:
+ static std::vector<grpc_slice> GetInitSlices() {
+ return {
+ grpc_slice_from_static_string("@\x0cgrpc-timeout\x03"
+ "30S")};
+ }
+ static std::vector<grpc_slice> GetBenchmarkSlices() {
+ // Use saved key and literal value.
+ return {MakeSlice({0x0f, 0x2f, 0x03, '3', '0', 'S'})};
+ }
+};
+
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, EmptyBatch, UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleStaticElem,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleStaticElem,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleStaticElem,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleInternedElem,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleInternedElem,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleInternedElem,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedElem, UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<1, false>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<3, false>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<10, false>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<31, false>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<100, false>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<1, true>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<3, true>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<10, true>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<31, true>,
+ UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<100, true>,
+ UnrefHeader);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
- RepresentativeClientInitialMetadata);
+ RepresentativeClientInitialMetadata, UnrefHeader);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
- RepresentativeServerInitialMetadata);
+ MoreRepresentativeClientInitialMetadata, UnrefHeader);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
- RepresentativeServerTrailingMetadata);
+ RepresentativeServerInitialMetadata, UnrefHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ RepresentativeServerTrailingMetadata, UnrefHeader);
+
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, SameDeadline, OnHeaderNew);
} // namespace hpack_parser_fixtures
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index 070034fe33..fcb1677d09 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -26,18 +26,16 @@
#include <memory>
#include <queue>
#include <sstream>
-extern "C" {
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/resource_quota.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/static_metadata.h"
-}
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
-auto &force_library_initialization = Library::get();
+auto& force_library_initialization = Library::get();
////////////////////////////////////////////////////////////////////////////////
// Helper classes
@@ -46,15 +44,21 @@ auto &force_library_initialization = Library::get();
class DummyEndpoint : public grpc_endpoint {
public:
DummyEndpoint() {
- static const grpc_endpoint_vtable my_vtable = {
- read, write, add_to_pollset, add_to_pollset_set,
- shutdown, destroy, get_resource_user, get_peer,
- get_fd};
+ static const grpc_endpoint_vtable my_vtable = {read,
+ write,
+ add_to_pollset,
+ add_to_pollset_set,
+ delete_from_pollset_set,
+ shutdown,
+ destroy,
+ get_resource_user,
+ get_peer,
+ get_fd};
grpc_endpoint::vtable = &my_vtable;
ru_ = grpc_resource_user_create(Library::get().rq(), "dummy_endpoint");
}
- void PushInput(grpc_exec_ctx *exec_ctx, grpc_slice slice) {
+ void PushInput(grpc_slice slice) {
if (read_cb_ == nullptr) {
GPR_ASSERT(!have_slice_);
buffered_slice_ = slice;
@@ -62,97 +66,90 @@ class DummyEndpoint : public grpc_endpoint {
return;
}
grpc_slice_buffer_add(slices_, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, read_cb_, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(read_cb_, GRPC_ERROR_NONE);
read_cb_ = nullptr;
}
private:
- grpc_resource_user *ru_;
- grpc_closure *read_cb_ = nullptr;
- grpc_slice_buffer *slices_ = nullptr;
+ grpc_resource_user* ru_;
+ grpc_closure* read_cb_ = nullptr;
+ grpc_slice_buffer* slices_ = nullptr;
bool have_slice_ = false;
grpc_slice buffered_slice_;
- void QueueRead(grpc_exec_ctx *exec_ctx, grpc_slice_buffer *slices,
- grpc_closure *cb) {
+ void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) {
GPR_ASSERT(read_cb_ == nullptr);
if (have_slice_) {
have_slice_ = false;
grpc_slice_buffer_add(slices, buffered_slice_);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
return;
}
read_cb_ = cb;
slices_ = slices;
}
- static void read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- static_cast<DummyEndpoint *>(ep)->QueueRead(exec_ctx, slices, cb);
+ static void read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ static_cast<DummyEndpoint*>(ep)->QueueRead(slices, cb);
}
- static void write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_slice_buffer *slices, grpc_closure *cb) {
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ static void write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
- static grpc_workqueue *get_workqueue(grpc_endpoint *ep) { return NULL; }
+ static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return nullptr; }
+
+ static void add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
- static void add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset *pollset) {}
+ static void add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset) {
+ }
- static void add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_pollset_set *pollset) {}
+ static void delete_from_pollset_set(grpc_endpoint* ep,
+ grpc_pollset_set* pollset) {}
- static void shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
- grpc_error *why) {
- grpc_resource_user_shutdown(exec_ctx,
- static_cast<DummyEndpoint *>(ep)->ru_);
- GRPC_CLOSURE_SCHED(exec_ctx, static_cast<DummyEndpoint *>(ep)->read_cb_,
- why);
+ static void shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_resource_user_shutdown(static_cast<DummyEndpoint*>(ep)->ru_);
+ GRPC_CLOSURE_SCHED(static_cast<DummyEndpoint*>(ep)->read_cb_, why);
}
- static void destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) {
- grpc_resource_user_unref(exec_ctx, static_cast<DummyEndpoint *>(ep)->ru_);
- delete static_cast<DummyEndpoint *>(ep);
+ static void destroy(grpc_endpoint* ep) {
+ grpc_resource_user_unref(static_cast<DummyEndpoint*>(ep)->ru_);
+ delete static_cast<DummyEndpoint*>(ep);
}
- static grpc_resource_user *get_resource_user(grpc_endpoint *ep) {
- return static_cast<DummyEndpoint *>(ep)->ru_;
+ static grpc_resource_user* get_resource_user(grpc_endpoint* ep) {
+ return static_cast<DummyEndpoint*>(ep)->ru_;
}
- static char *get_peer(grpc_endpoint *ep) { return gpr_strdup("test"); }
- static int get_fd(grpc_endpoint *ep) { return 0; }
+ static char* get_peer(grpc_endpoint* ep) { return gpr_strdup("test"); }
+ static int get_fd(grpc_endpoint* ep) { return 0; }
};
class Fixture {
public:
- Fixture(const grpc::ChannelArguments &args, bool client) {
+ Fixture(const grpc::ChannelArguments& args, bool client) {
grpc_channel_args c_args = args.c_channel_args();
ep_ = new DummyEndpoint;
- t_ = grpc_create_chttp2_transport(exec_ctx(), &c_args, ep_, client);
- grpc_chttp2_transport_start_reading(exec_ctx(), t_, NULL);
+ t_ = grpc_create_chttp2_transport(&c_args, ep_, client);
+ grpc_chttp2_transport_start_reading(t_, nullptr, nullptr);
FlushExecCtx();
}
- void FlushExecCtx() { grpc_exec_ctx_flush(&exec_ctx_); }
+ void FlushExecCtx() { grpc_core::ExecCtx::Get()->Flush(); }
- ~Fixture() {
- grpc_transport_destroy(&exec_ctx_, t_);
- grpc_exec_ctx_finish(&exec_ctx_);
- }
+ ~Fixture() { grpc_transport_destroy(t_); }
- grpc_chttp2_transport *chttp2_transport() {
- return reinterpret_cast<grpc_chttp2_transport *>(t_);
+ grpc_chttp2_transport* chttp2_transport() {
+ return reinterpret_cast<grpc_chttp2_transport*>(t_);
}
- grpc_transport *transport() { return t_; }
- grpc_exec_ctx *exec_ctx() { return &exec_ctx_; }
+ grpc_transport* transport() { return t_; }
- void PushInput(grpc_slice slice) { ep_->PushInput(exec_ctx(), slice); }
+ void PushInput(grpc_slice slice) { ep_->PushInput(slice); }
private:
- DummyEndpoint *ep_;
- grpc_exec_ctx exec_ctx_ = GRPC_EXEC_CTX_INIT;
- grpc_transport *t_;
+ DummyEndpoint* ep_;
+ grpc_transport* t_;
};
class Closure : public grpc_closure {
@@ -162,37 +159,37 @@ class Closure : public grpc_closure {
template <class F>
std::unique_ptr<Closure> MakeClosure(
- F f, grpc_closure_scheduler *sched = grpc_schedule_on_exec_ctx) {
+ F f, grpc_closure_scheduler* sched = grpc_schedule_on_exec_ctx) {
struct C : public Closure {
- C(const F &f, grpc_closure_scheduler *sched) : f_(f) {
+ C(const F& f, grpc_closure_scheduler* sched) : f_(f) {
GRPC_CLOSURE_INIT(this, Execute, this, sched);
}
F f_;
- static void Execute(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- static_cast<C *>(arg)->f_(exec_ctx, error);
+ static void Execute(void* arg, grpc_error* error) {
+ static_cast<C*>(arg)->f_(error);
}
};
return std::unique_ptr<Closure>(new C(f, sched));
}
template <class F>
-grpc_closure *MakeOnceClosure(
- F f, grpc_closure_scheduler *sched = grpc_schedule_on_exec_ctx) {
+grpc_closure* MakeOnceClosure(
+ F f, grpc_closure_scheduler* sched = grpc_schedule_on_exec_ctx) {
struct C : public grpc_closure {
- C(const F &f) : f_(f) {}
+ C(const F& f) : f_(f) {}
F f_;
- static void Execute(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- static_cast<C *>(arg)->f_(exec_ctx, error);
- delete static_cast<C *>(arg);
+ static void Execute(void* arg, grpc_error* error) {
+ static_cast<C*>(arg)->f_(error);
+ delete static_cast<C*>(arg);
}
};
- auto *c = new C{f};
+ auto* c = new C{f};
return GRPC_CLOSURE_INIT(c, C::Execute, c, sched);
}
class Stream {
public:
- Stream(Fixture *f) : f_(f) {
+ Stream(Fixture* f) : f_(f) {
stream_size_ = grpc_transport_stream_size(f->transport());
stream_ = gpr_malloc(stream_size_);
arena_ = gpr_arena_create(4096);
@@ -204,7 +201,7 @@ class Stream {
gpr_arena_destroy(arena_);
}
- void Init(benchmark::State &state) {
+ void Init(benchmark::State& state) {
GRPC_STREAM_REF_INIT(&refcount_, 1, &Stream::FinishDestroy, this,
"test_stream");
gpr_event_init(&done_);
@@ -213,45 +210,44 @@ class Stream {
gpr_arena_destroy(arena_);
arena_ = gpr_arena_create(4096);
}
- grpc_transport_init_stream(f_->exec_ctx(), f_->transport(),
- static_cast<grpc_stream *>(stream_), &refcount_,
- NULL, arena_);
+ grpc_transport_init_stream(f_->transport(),
+ static_cast<grpc_stream*>(stream_), &refcount_,
+ nullptr, arena_);
}
- void DestroyThen(grpc_exec_ctx *exec_ctx, grpc_closure *closure) {
+ void DestroyThen(grpc_closure* closure) {
destroy_closure_ = closure;
#ifndef NDEBUG
- grpc_stream_unref(exec_ctx, &refcount_, "DestroyThen");
+ grpc_stream_unref(&refcount_, "DestroyThen");
#else
- grpc_stream_unref(exec_ctx, &refcount_);
+ grpc_stream_unref(&refcount_);
#endif
}
- void Op(grpc_exec_ctx *exec_ctx, grpc_transport_stream_op_batch *op) {
- grpc_transport_perform_stream_op(exec_ctx, f_->transport(),
- static_cast<grpc_stream *>(stream_), op);
+ void Op(grpc_transport_stream_op_batch* op) {
+ grpc_transport_perform_stream_op(f_->transport(),
+ static_cast<grpc_stream*>(stream_), op);
}
- grpc_chttp2_stream *chttp2_stream() {
- return static_cast<grpc_chttp2_stream *>(stream_);
+ grpc_chttp2_stream* chttp2_stream() {
+ return static_cast<grpc_chttp2_stream*>(stream_);
}
private:
- static void FinishDestroy(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- auto stream = static_cast<Stream *>(arg);
- grpc_transport_destroy_stream(exec_ctx, stream->f_->transport(),
- static_cast<grpc_stream *>(stream->stream_),
+ static void FinishDestroy(void* arg, grpc_error* error) {
+ auto stream = static_cast<Stream*>(arg);
+ grpc_transport_destroy_stream(stream->f_->transport(),
+ static_cast<grpc_stream*>(stream->stream_),
stream->destroy_closure_);
- gpr_event_set(&stream->done_, (void *)1);
+ gpr_event_set(&stream->done_, (void*)1);
}
- Fixture *f_;
+ Fixture* f_;
grpc_stream_refcount refcount_;
- gpr_arena *arena_;
+ gpr_arena* arena_;
size_t stream_size_;
- void *stream_;
- grpc_closure *destroy_closure_ = nullptr;
+ void* stream_;
+ grpc_closure* destroy_closure_ = nullptr;
gpr_event done_;
};
@@ -259,8 +255,9 @@ class Stream {
// Benchmarks
//
-static void BM_StreamCreateDestroy(benchmark::State &state) {
+static void BM_StreamCreateDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -269,14 +266,13 @@ static void BM_StreamCreateDestroy(benchmark::State &state) {
op.cancel_stream = true;
op.payload = &op_payload;
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- std::unique_ptr<Closure> next =
- MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
- if (!state.KeepRunning()) return;
- s.Init(state);
- s.Op(exec_ctx, &op);
- s.DestroyThen(exec_ctx, next.get());
- });
- GRPC_CLOSURE_RUN(f.exec_ctx(), next.get(), GRPC_ERROR_NONE);
+ std::unique_ptr<Closure> next = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ s.Init(state);
+ s.Op(&op);
+ s.DestroyThen(next.get());
+ });
+ GRPC_CLOSURE_RUN(next.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
track_counters.Finish(state);
}
@@ -284,28 +280,30 @@ BENCHMARK(BM_StreamCreateDestroy);
class RepresentativeClientInitialMetadata {
public:
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
- GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST,
+ GRPC_MDELEM_SCHEME_HTTP,
+ GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
};
template <class Metadata>
-static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) {
+static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -321,42 +319,42 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) {
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
- b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- std::vector<grpc_mdelem> elems = Metadata::GetElems(f.exec_ctx());
+ b.deadline = GRPC_MILLIS_INF_FUTURE;
+ std::vector<grpc_mdelem> elems = Metadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
f.FlushExecCtx();
- start = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
+ start = MakeClosure([&](grpc_error* error) {
if (!state.KeepRunning()) return;
s.Init(state);
reset_op();
op.on_complete = done.get();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
- s.Op(exec_ctx, &op);
+ s.Op(&op);
});
- done = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
+ done = MakeClosure([&](grpc_error* error) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(exec_ctx, &op);
- s.DestroyThen(exec_ctx, start.get());
+ s.Op(&op);
+ s.DestroyThen(start.get());
});
- GRPC_CLOSURE_SCHED(f.exec_ctx(), start.get(), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(start.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
+ grpc_metadata_batch_destroy(&b);
track_counters.Finish(state);
}
BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
RepresentativeClientInitialMetadata);
-static void BM_TransportEmptyOp(benchmark::State &state) {
+static void BM_TransportEmptyOp(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
@@ -367,21 +365,19 @@ static void BM_TransportEmptyOp(benchmark::State &state) {
memset(&op, 0, sizeof(op));
op.payload = &op_payload;
};
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
- if (!state.KeepRunning()) return;
- reset_op();
- op.on_complete = c.get();
- s.Op(exec_ctx, &op);
- });
- GRPC_CLOSURE_SCHED(f.exec_ctx(), c.get(), GRPC_ERROR_NONE);
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ reset_op();
+ op.on_complete = c.get();
+ s.Op(&op);
+ });
+ GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
reset_op();
op.cancel_stream = true;
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(f.exec_ctx(), &op);
- s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx *exec_ctx,
- grpc_error *error) {}));
+ s.Op(&op);
+ s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
track_counters.Finish(state);
}
@@ -389,8 +385,9 @@ BENCHMARK(BM_TransportEmptyOp);
std::vector<std::unique_ptr<gpr_event>> done_events;
-static void BM_TransportStreamSend(benchmark::State &state) {
+static void BM_TransportStreamSend(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto s = std::unique_ptr<Stream>(new Stream(&f));
s->Init(state);
@@ -410,42 +407,39 @@ static void BM_TransportStreamSend(benchmark::State &state) {
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
- b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ b.deadline = GRPC_MILLIS_INF_FUTURE;
std::vector<grpc_mdelem> elems =
- RepresentativeClientInitialMetadata::GetElems(f.exec_ctx());
+ RepresentativeClientInitialMetadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
- gpr_event *bm_done = new gpr_event;
+ gpr_event* bm_done = new gpr_event;
gpr_event_init(bm_done);
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
- if (!state.KeepRunning()) {
- gpr_event_set(bm_done, (void *)1);
- return;
- }
- // force outgoing window to be yuge
- s->chttp2_stream()->flow_control.remote_window_delta =
- 1024 * 1024 * 1024;
- f.chttp2_transport()->flow_control.remote_window = 1024 * 1024 * 1024;
- grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0);
- reset_op();
- op.on_complete = c.get();
- op.send_message = true;
- op.payload->send_message.send_message = &send_stream.base;
- s->Op(exec_ctx, &op);
- });
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) {
+ gpr_event_set(bm_done, (void*)1);
+ return;
+ }
+ // force outgoing window to be yuge
+ s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
+ f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
+ grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0);
+ reset_op();
+ op.on_complete = c.get();
+ op.send_message = true;
+ op.payload->send_message.send_message = &send_stream.base;
+ s->Op(&op);
+ });
reset_op();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
op.on_complete = c.get();
- s->Op(f.exec_ctx(), &op);
+ s->Op(&op);
f.FlushExecCtx();
gpr_event_wait(bm_done, gpr_inf_future(GPR_CLOCK_REALTIME));
@@ -454,13 +448,12 @@ static void BM_TransportStreamSend(benchmark::State &state) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s->Op(f.exec_ctx(), &op);
- s->DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx *exec_ctx,
- grpc_error *error) {}));
+ s->Op(&op);
+ s->DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
s.reset();
track_counters.Finish(state);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
+ grpc_metadata_batch_destroy(&b);
grpc_slice_buffer_destroy(&send_buffer);
}
BENCHMARK(BM_TransportStreamSend)->Range(0, 128 * 1024 * 1024);
@@ -522,15 +515,16 @@ static grpc_slice CreateIncomingDataSlice(size_t length, size_t frame_size) {
return grpc_slice_from_copied_buffer(framed.data(), framed.size());
}
-static void BM_TransportStreamRecv(benchmark::State &state) {
+static void BM_TransportStreamRecv(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
grpc_transport_stream_op_batch_payload op_payload;
memset(&op_payload, 0, sizeof(op_payload));
grpc_transport_stream_op_batch op;
- grpc_byte_stream *recv_stream;
+ grpc_byte_stream* recv_stream;
grpc_slice incoming_data = CreateIncomingDataSlice(state.range(0), 16384);
auto reset_op = [&]() {
@@ -542,18 +536,16 @@ static void BM_TransportStreamRecv(benchmark::State &state) {
grpc_metadata_batch_init(&b);
grpc_metadata_batch b_recv;
grpc_metadata_batch_init(&b_recv);
- b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ b.deadline = GRPC_MILLIS_INF_FUTURE;
std::vector<grpc_mdelem> elems =
- RepresentativeClientInitialMetadata::GetElems(f.exec_ctx());
+ RepresentativeClientInitialMetadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
- std::unique_ptr<Closure> do_nothing =
- MakeClosure([](grpc_exec_ctx *exec_ctx, grpc_error *error) {});
+ std::unique_ptr<Closure> do_nothing = MakeClosure([](grpc_error* error) {});
uint32_t received;
@@ -562,52 +554,49 @@ static void BM_TransportStreamRecv(benchmark::State &state) {
std::unique_ptr<Closure> drain_continue;
grpc_slice recv_slice;
- std::unique_ptr<Closure> c = MakeClosure([&](grpc_exec_ctx *exec_ctx,
- grpc_error *error) {
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
if (!state.KeepRunning()) return;
// force outgoing window to be yuge
- s.chttp2_stream()->flow_control.local_window_delta = 1024 * 1024 * 1024;
- s.chttp2_stream()->flow_control.announced_window_delta = 1024 * 1024 * 1024;
- f.chttp2_transport()->flow_control.announced_window = 1024 * 1024 * 1024;
+ s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
+ f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
received = 0;
reset_op();
op.on_complete = do_nothing.get();
op.recv_message = true;
op.payload->recv_message.recv_message = &recv_stream;
op.payload->recv_message.recv_message_ready = drain_start.get();
- s.Op(exec_ctx, &op);
+ s.Op(&op);
f.PushInput(grpc_slice_ref(incoming_data));
});
- drain_start = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
- if (recv_stream == NULL) {
+ drain_start = MakeClosure([&](grpc_error* error) {
+ if (recv_stream == nullptr) {
GPR_ASSERT(!state.KeepRunning());
return;
}
- GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE);
});
- drain = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
+ drain = MakeClosure([&](grpc_error* error) {
do {
if (received == recv_stream->length) {
- grpc_byte_stream_destroy(exec_ctx, recv_stream);
- GRPC_CLOSURE_SCHED(exec_ctx, c.get(), GRPC_ERROR_NONE);
+ grpc_byte_stream_destroy(recv_stream);
+ GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
return;
}
- } while (grpc_byte_stream_next(exec_ctx, recv_stream,
- recv_stream->length - received,
+ } while (grpc_byte_stream_next(recv_stream, recv_stream->length - received,
drain_continue.get()) &&
GRPC_ERROR_NONE ==
- grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice) &&
+ grpc_byte_stream_pull(recv_stream, &recv_slice) &&
(received += GRPC_SLICE_LENGTH(recv_slice),
- grpc_slice_unref_internal(exec_ctx, recv_slice), true));
+ grpc_slice_unref_internal(recv_slice), true));
});
- drain_continue = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) {
- grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice);
+ drain_continue = MakeClosure([&](grpc_error* error) {
+ grpc_byte_stream_pull(recv_stream, &recv_slice);
received += GRPC_SLICE_LENGTH(recv_slice);
- grpc_slice_unref_internal(exec_ctx, recv_slice);
- GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE);
+ grpc_slice_unref_internal(recv_slice);
+ GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE);
});
reset_op();
@@ -618,7 +607,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) {
op.payload->recv_initial_metadata.recv_initial_metadata_ready =
do_nothing.get();
op.on_complete = c.get();
- s.Op(f.exec_ctx(), &op);
+ s.Op(&op);
f.PushInput(SLICE_FROM_BUFFER(
"\x00\x00\x00\x04\x00\x00\x00\x00\x00"
// Generated using:
@@ -636,13 +625,12 @@ static void BM_TransportStreamRecv(benchmark::State &state) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(f.exec_ctx(), &op);
- s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx *exec_ctx,
- grpc_error *error) {}));
+ s.Op(&op);
+ s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
track_counters.Finish(state);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b_recv);
+ grpc_metadata_batch_destroy(&b);
+ grpc_metadata_batch_destroy(&b_recv);
grpc_slice_unref(incoming_data);
}
BENCHMARK(BM_TransportStreamRecv)->Range(0, 128 * 1024 * 1024);
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 41649b8a73..6d88faecc0 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -22,12 +22,10 @@
#include <grpc/grpc.h>
#include <sstream>
-extern "C" {
+#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/spinlock.h"
-}
#include "test/cpp/microbenchmarks/helpers.h"
@@ -36,8 +34,7 @@ auto& force_library_initialization = Library::get();
static void BM_NoOpExecCtx(benchmark::State& state) {
TrackCounters track_counters;
while (state.KeepRunning()) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
}
track_counters.Finish(state);
}
@@ -45,23 +42,23 @@ BENCHMARK(BM_NoOpExecCtx);
static void BM_WellFlushed(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_WellFlushed);
-static void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void DoNothing(void* arg, grpc_error* error) {}
static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
while (state.KeepRunning()) {
benchmark::DoNotOptimize(
- GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx));
+ GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx));
}
track_counters.Finish(state);
}
@@ -71,13 +68,13 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) {
TrackCounters track_counters;
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
benchmark::DoNotOptimize(GRPC_CLOSURE_INIT(
- &c, DoNothing, NULL, grpc_combiner_scheduler(combiner)));
+ &c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)));
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAgainstCombiner);
@@ -85,40 +82,40 @@ BENCHMARK(BM_ClosureInitAgainstCombiner);
static void BM_ClosureRunOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
- GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_RUN(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureRunOnExecCtx);
static void BM_ClosureCreateAndRun(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_RUN(&exec_ctx, GRPC_CLOSURE_CREATE(DoNothing, NULL,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(
+ GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx),
+ GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureCreateAndRun);
static void BM_ClosureInitAndRun(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_closure c;
while (state.KeepRunning()) {
- GRPC_CLOSURE_RUN(&exec_ctx, GRPC_CLOSURE_INIT(&c, DoNothing, NULL,
- grpc_schedule_on_exec_ctx),
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(
+ GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx),
+ GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAndRun);
@@ -126,13 +123,13 @@ BENCHMARK(BM_ClosureInitAndRun);
static void BM_ClosureSchedOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
- GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnExecCtx);
@@ -141,15 +138,15 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c1;
grpc_closure c2;
- GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnExecCtx);
@@ -159,17 +156,17 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) {
grpc_closure c1;
grpc_closure c2;
grpc_closure c3;
- GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnExecCtx);
@@ -179,13 +176,13 @@ static void BM_AcquireMutex(benchmark::State& state) {
// for comparison with the combiner stuff below
gpr_mu mu;
gpr_mu_init(&mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
gpr_mu_lock(&mu);
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireMutex);
@@ -195,16 +192,16 @@ static void BM_TryAcquireMutex(benchmark::State& state) {
// for comparison with the combiner stuff below
gpr_mu mu;
gpr_mu_init(&mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
if (gpr_mu_trylock(&mu)) {
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
} else {
abort();
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireMutex);
@@ -213,13 +210,13 @@ static void BM_AcquireSpinlock(benchmark::State& state) {
TrackCounters track_counters;
// for comparison with the combiner stuff below
gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
gpr_spinlock_lock(&mu);
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireSpinlock);
@@ -228,16 +225,16 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) {
TrackCounters track_counters;
// for comparison with the combiner stuff below
gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
if (gpr_spinlock_trylock(&mu)) {
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
} else {
abort();
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireSpinlock);
@@ -246,14 +243,14 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) {
TrackCounters track_counters;
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c;
- GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnCombiner);
@@ -263,16 +260,16 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) {
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c1;
grpc_closure c2;
- GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner));
- GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnCombiner);
@@ -283,18 +280,18 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) {
grpc_closure c1;
grpc_closure c2;
grpc_closure c3;
- GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner));
- GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner));
- GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnCombiner);
@@ -305,17 +302,19 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) {
grpc_combiner* combiner2 = grpc_combiner_create();
grpc_closure c1;
grpc_closure c2;
- GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner1));
- GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner2));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner1));
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner2));
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner1, "finished");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner2, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner1, "finished");
+ GRPC_COMBINER_UNREF(combiner2, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnTwoCombiners);
@@ -328,21 +327,25 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) {
grpc_closure c2;
grpc_closure c3;
grpc_closure c4;
- GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner1));
- GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner2));
- GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_combiner_scheduler(combiner1));
- GRPC_CLOSURE_INIT(&c4, DoNothing, NULL, grpc_combiner_scheduler(combiner2));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner1));
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner2));
+ GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner1));
+ GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner2));
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c4, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c4, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner1, "finished");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner2, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner1, "finished");
+ GRPC_COMBINER_UNREF(combiner2, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched4OnTwoCombiners);
@@ -356,13 +359,11 @@ class Rescheduler {
GRPC_CLOSURE_INIT(&closure_, Step, this, scheduler);
}
- void ScheduleFirst(grpc_exec_ctx* exec_ctx) {
- GRPC_CLOSURE_SCHED(exec_ctx, &closure_, GRPC_ERROR_NONE);
- }
+ void ScheduleFirst() { GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); }
void ScheduleFirstAgainstDifferentScheduler(
- grpc_exec_ctx* exec_ctx, grpc_closure_scheduler* scheduler) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(Step, this, scheduler),
+ grpc_closure_scheduler* scheduler) {
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(Step, this, scheduler),
GRPC_ERROR_NONE);
}
@@ -370,47 +371,46 @@ class Rescheduler {
benchmark::State& state_;
grpc_closure closure_;
- static void Step(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void Step(void* arg, grpc_error* error) {
Rescheduler* self = static_cast<Rescheduler*>(arg);
if (self->state_.KeepRunning()) {
- GRPC_CLOSURE_SCHED(exec_ctx, &self->closure_, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE);
}
}
};
static void BM_ClosureReschedOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
Rescheduler r(state, grpc_schedule_on_exec_ctx);
- r.ScheduleFirst(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirst();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnExecCtx);
static void BM_ClosureReschedOnCombiner(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_scheduler(combiner));
- r.ScheduleFirst(&exec_ctx);
- grpc_exec_ctx_flush(&exec_ctx);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirst();
+ grpc_core::ExecCtx::Get()->Flush();
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombiner);
static void BM_ClosureReschedOnCombinerFinally(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_finally_scheduler(combiner));
- r.ScheduleFirstAgainstDifferentScheduler(&exec_ctx,
- grpc_combiner_scheduler(combiner));
- grpc_exec_ctx_flush(&exec_ctx);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirstAgainstDifferentScheduler(grpc_combiner_scheduler(combiner));
+ grpc_core::ExecCtx::Get()->Flush();
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombinerFinally);
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index a0c0414f2f..97242598f1 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -26,9 +26,7 @@
#include <grpc/support/log.h>
#include "test/cpp/microbenchmarks/helpers.h"
-extern "C" {
#include "src/core/lib/surface/completion_queue.h"
-}
namespace grpc {
namespace testing {
@@ -49,7 +47,7 @@ static void BM_CreateDestroyCpp2(benchmark::State& state) {
TrackCounters track_counters;
while (state.KeepRunning()) {
grpc_completion_queue* core_cq =
- grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue_create_for_next(nullptr);
CompletionQueue cq(core_cq);
}
track_counters.Finish(state);
@@ -61,16 +59,17 @@ static void BM_CreateDestroyCore(benchmark::State& state) {
while (state.KeepRunning()) {
// TODO: sreek Templatize this benchmark and pass completion type and
// polling type as parameters
- grpc_completion_queue_destroy(grpc_completion_queue_create_for_next(NULL));
+ grpc_completion_queue_destroy(
+ grpc_completion_queue_create_for_next(nullptr));
}
track_counters.Finish(state);
}
BENCHMARK(BM_CreateDestroyCore);
-static void DoneWithCompletionOnStack(grpc_exec_ctx* exec_ctx, void* arg,
+static void DoneWithCompletionOnStack(void* arg,
grpc_cq_completion* completion) {}
-class DummyTag final : public CompletionQueueTag {
+class DummyTag final : public internal::CompletionQueueTag {
public:
bool FinalizeResult(void** tag, bool* status) override { return true; }
};
@@ -82,11 +81,11 @@ static void BM_Pass1Cpp(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_cq_completion completion;
DummyTag dummy_tag;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag));
- grpc_cq_end_op(&exec_ctx, c_cq, &dummy_tag, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, NULL, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(c_cq, &dummy_tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
void* tag;
bool ok;
cq.Next(&tag, &ok);
@@ -98,16 +97,16 @@ BENCHMARK(BM_Pass1Cpp);
static void BM_Pass1Core(benchmark::State& state) {
TrackCounters track_counters;
// TODO: sreek Templatize this benchmark and pass polling_type as a param
- grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
grpc_cq_completion completion;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_cq_begin_op(cq, NULL));
- grpc_cq_end_op(&exec_ctx, cq, NULL, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, NULL, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_completion_queue_next(cq, deadline, NULL);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(grpc_cq_begin_op(cq, nullptr));
+ grpc_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
+ grpc_completion_queue_next(cq, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
track_counters.Finish(state);
@@ -117,16 +116,16 @@ BENCHMARK(BM_Pass1Core);
static void BM_Pluck1Core(benchmark::State& state) {
TrackCounters track_counters;
// TODO: sreek Templatize this benchmark and pass polling_type as a param
- grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr);
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
grpc_cq_completion completion;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_cq_begin_op(cq, NULL));
- grpc_cq_end_op(&exec_ctx, cq, NULL, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, NULL, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_completion_queue_pluck(cq, NULL, deadline, NULL);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(grpc_cq_begin_op(cq, nullptr));
+ grpc_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
+ grpc_completion_queue_pluck(cq, nullptr, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
track_counters.Finish(state);
@@ -136,10 +135,10 @@ BENCHMARK(BM_Pluck1Core);
static void BM_EmptyCore(benchmark::State& state) {
TrackCounters track_counters;
// TODO: sreek Templatize this benchmark and pass polling_type as a param
- grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
- grpc_completion_queue_next(cq, deadline, NULL);
+ grpc_completion_queue_next(cq, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
track_counters.Finish(state);
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 5c9405f583..874c834931 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -25,11 +25,9 @@
#include <grpc/support/log.h>
#include "test/cpp/microbenchmarks/helpers.h"
-extern "C" {
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/surface/completion_queue.h"
-}
struct grpc_pollset {
gpr_mu mu;
@@ -45,9 +43,8 @@ static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
static const grpc_event_engine_vtable* g_old_vtable;
-static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_closure* closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+static void pollset_shutdown(grpc_pollset* ps, grpc_closure* closure) {
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
@@ -55,36 +52,31 @@ static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
*mu = &ps->mu;
}
-static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* ps) {
- gpr_mu_destroy(&ps->mu);
-}
+static void pollset_destroy(grpc_pollset* ps) { gpr_mu_destroy(&ps->mu); }
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
- grpc_pollset_worker* worker) {
+static grpc_error* pollset_kick(grpc_pollset* p, grpc_pollset_worker* worker) {
return GRPC_ERROR_NONE;
}
/* Callback when the tag is dequeued from the completion queue. Does nothing */
-static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* cq_completion) {
+static void cq_done_cb(void* done_arg, grpc_cq_completion* cq_completion) {
gpr_free(cq_completion);
}
/* Queues a completion tag if deadline is > 0.
* Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_pollset_worker** worker, gpr_timespec now,
- gpr_timespec deadline) {
- if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) {
+static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
+ grpc_millis deadline) {
+ if (deadline == 0) {
gpr_log(GPR_DEBUG, "no-op");
return GRPC_ERROR_NONE;
}
gpr_mu_unlock(&ps->mu);
GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
- grpc_cq_end_op(exec_ctx, g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, NULL,
+ grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
}
@@ -110,7 +102,7 @@ static void setup() {
g_old_vtable = grpc_get_event_engine_test_only();
grpc_set_event_engine_test_only(&g_vtable);
- g_cq = grpc_completion_queue_create_for_next(NULL);
+ g_cq = grpc_completion_queue_create_for_next(nullptr);
}
static void teardown() {
@@ -118,7 +110,7 @@ static void teardown() {
/* Drain any events */
gpr_timespec deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
- while (grpc_completion_queue_next(g_cq, deadline, NULL).type !=
+ while (grpc_completion_queue_next(g_cq, deadline, nullptr).type !=
GRPC_QUEUE_SHUTDOWN) {
/* Do nothing */
}
@@ -153,7 +145,7 @@ static void BM_Cq_Throughput(benchmark::State& state) {
}
while (state.KeepRunning()) {
- GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, NULL).type ==
+ GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type ==
GRPC_OP_COMPLETE);
}
diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc
index bd5f02e172..d12f475a49 100644
--- a/test/cpp/microbenchmarks/bm_error.cc
+++ b/test/cpp/microbenchmarks/bm_error.cc
@@ -21,10 +21,8 @@
#include <benchmark/benchmark.h>
#include <memory>
-extern "C" {
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/transport/error_utils.h"
-}
#include "test/cpp/microbenchmarks/helpers.h"
@@ -159,39 +157,39 @@ BENCHMARK(BM_ErrorGetPresentInt);
// Fixtures for tests: generate different kinds of errors
class ErrorNone {
public:
- gpr_timespec deadline() const { return deadline_; }
+ grpc_millis deadline() const { return deadline_; }
grpc_error* error() const { return GRPC_ERROR_NONE; }
private:
- const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
};
class ErrorCancelled {
public:
- gpr_timespec deadline() const { return deadline_; }
+ grpc_millis deadline() const { return deadline_; }
grpc_error* error() const { return GRPC_ERROR_CANCELLED; }
private:
- const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
};
class SimpleError {
public:
- gpr_timespec deadline() const { return deadline_; }
+ grpc_millis deadline() const { return deadline_; }
grpc_error* error() const { return error_.get(); }
private:
- const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
ErrorPtr error_{GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error")};
};
class ErrorWithGrpcStatus {
public:
- gpr_timespec deadline() const { return deadline_; }
+ grpc_millis deadline() const { return deadline_; }
grpc_error* error() const { return error_.get(); }
private:
- const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
ErrorPtr error_{grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNIMPLEMENTED)};
@@ -199,11 +197,11 @@ class ErrorWithGrpcStatus {
class ErrorWithHttpError {
public:
- gpr_timespec deadline() const { return deadline_; }
+ grpc_millis deadline() const { return deadline_; }
grpc_error* error() const { return error_.get(); }
private:
- const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
ErrorPtr error_{grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR,
GRPC_HTTP2_COMPRESSION_ERROR)};
@@ -211,11 +209,11 @@ class ErrorWithHttpError {
class ErrorWithNestedGrpcStatus {
public:
- gpr_timespec deadline() const { return deadline_; }
+ grpc_millis deadline() const { return deadline_; }
grpc_error* error() const { return error_.get(); }
private:
- const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE;
ErrorPtr nested_error_{grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNIMPLEMENTED)};
@@ -248,12 +246,14 @@ template <class Fixture>
static void BM_ErrorGetStatus(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
grpc_status_code status;
grpc_slice slice;
grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice,
- NULL);
+ nullptr, nullptr);
}
+
track_counters.Finish(state);
}
@@ -261,11 +261,13 @@ template <class Fixture>
static void BM_ErrorGetStatusCode(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
grpc_status_code status;
- grpc_error_get_status(fixture.error(), fixture.deadline(), &status, NULL,
- NULL);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), &status, nullptr,
+ nullptr, nullptr);
}
+
track_counters.Finish(state);
}
@@ -273,11 +275,13 @@ template <class Fixture>
static void BM_ErrorHttpError(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
grpc_http2_error_code error;
- grpc_error_get_status(fixture.error(), fixture.deadline(), NULL, NULL,
- &error);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), nullptr, nullptr,
+ &error, nullptr);
}
+
track_counters.Finish(state);
}
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
index 2656566a50..d6d7d41e5e 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -21,16 +21,16 @@
#include <benchmark/benchmark.h>
#include <gflags/gflags.h>
#include <fstream>
+
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/ext/transport/chttp2/transport/internal.h"
+#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/profiling/timers.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/trickle_endpoint.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
#include "test/cpp/microbenchmarks/fullstack_fixtures.h"
#include "test/cpp/util/test_config.h"
-extern "C" {
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/ext/transport/chttp2/transport/internal.h"
-#include "test/core/util/trickle_endpoint.h"
-}
DEFINE_bool(log, false, "Log state to CSV files");
DEFINE_int32(
@@ -45,6 +45,22 @@ DEFINE_int32(warmup_max_time_seconds, 10,
namespace grpc {
namespace testing {
+gpr_atm g_now_us = 0;
+
+static gpr_timespec fake_now(gpr_clock_type clock_type) {
+ gpr_timespec t;
+ gpr_atm now = gpr_atm_no_barrier_load(&g_now_us);
+ t.tv_sec = now / GPR_US_PER_SEC;
+ t.tv_nsec = (now % GPR_US_PER_SEC) * GPR_NS_PER_US;
+ t.clock_type = clock_type;
+ return t;
+}
+
+static void inc_time() {
+ gpr_atm_no_barrier_fetch_add(&g_now_us, 100);
+ grpc_timer_manager_tick();
+}
+
static void* tag(intptr_t x) { return reinterpret_cast<void*>(x); }
template <class A0>
@@ -119,23 +135,27 @@ class TrickledCHTTP2 : public EndpointPairFixture {
? static_cast<grpc_chttp2_stream*>(server->stream_map.values[0])
: nullptr;
write_csv(
- log_.get(), static_cast<double>(now.tv_sec) +
- 1e-9 * static_cast<double>(now.tv_nsec),
+ log_.get(),
+ static_cast<double>(now.tv_sec) +
+ 1e-9 * static_cast<double>(now.tv_nsec),
iteration, grpc_trickle_get_backlog(endpoint_pair_.client),
grpc_trickle_get_backlog(endpoint_pair_.server),
client->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != nullptr,
client->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != nullptr,
server->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != nullptr,
server->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != nullptr,
- client->flow_control.remote_window, server->flow_control.remote_window,
- client->flow_control.announced_window,
- server->flow_control.announced_window,
- client_stream ? client_stream->flow_control.remote_window_delta : -1,
- server_stream ? server_stream->flow_control.remote_window_delta : -1,
- client_stream ? client_stream->flow_control.local_window_delta : -1,
- server_stream ? server_stream->flow_control.local_window_delta : -1,
- client_stream ? client_stream->flow_control.announced_window_delta : -1,
- server_stream ? server_stream->flow_control.announced_window_delta : -1,
+ client->flow_control->remote_window_,
+ server->flow_control->remote_window_,
+ client->flow_control->announced_window_,
+ server->flow_control->announced_window_,
+ client_stream ? client_stream->flow_control->remote_window_delta_ : -1,
+ server_stream ? server_stream->flow_control->remote_window_delta_ : -1,
+ client_stream ? client_stream->flow_control->local_window_delta_ : -1,
+ server_stream ? server_stream->flow_control->local_window_delta_ : -1,
+ client_stream ? client_stream->flow_control->announced_window_delta_
+ : -1,
+ server_stream ? server_stream->flow_control->announced_window_delta_
+ : -1,
client->settings[GRPC_PEER_SETTINGS]
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
client->settings[GRPC_LOCAL_SETTINGS]
@@ -157,12 +177,13 @@ class TrickledCHTTP2 : public EndpointPairFixture {
}
void Step(bool update_stats) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
+ inc_time();
size_t client_backlog =
- grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.client);
+ grpc_trickle_endpoint_trickle(endpoint_pair_.client);
size_t server_backlog =
- grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.server);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_trickle_endpoint_trickle(endpoint_pair_.server);
+
if (update_stats) {
UpdateStats((grpc_chttp2_transport*)client_transport_, &client_stats_,
client_backlog);
@@ -195,10 +216,10 @@ class TrickledCHTTP2 : public EndpointPairFixture {
void UpdateStats(grpc_chttp2_transport* t, Stats* s,
size_t backlog) GPR_ATTRIBUTE_NO_TSAN {
if (backlog == 0) {
- if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != NULL) {
+ if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != nullptr) {
s->streams_stalled_due_to_stream_flow_control++;
}
- if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != NULL) {
+ if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != nullptr) {
s->streams_stalled_due_to_transport_flow_control++;
}
}
@@ -212,9 +233,8 @@ static void TrickleCQNext(TrickledCHTTP2* fixture, void** t, bool* ok,
int64_t iteration) {
while (true) {
fixture->Log(iteration);
- switch (fixture->cq()->AsyncNext(
- t, ok, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_micros(100, GPR_TIMESPAN)))) {
+ switch (
+ fixture->cq()->AsyncNext(t, ok, gpr_inf_past(GPR_CLOCK_MONOTONIC))) {
case CompletionQueue::TIMEOUT:
fixture->Step(iteration != -1);
break;
@@ -289,9 +309,15 @@ static void BM_PumpStreamServerToClient_Trickle(benchmark::State& state) {
inner_loop(false);
}
response_rw.Finish(Status::OK, tag(1));
- need_tags = (1 << 0) | (1 << 1);
+ grpc::Status status;
+ request_rw->Finish(&status, tag(2));
+ need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
TrickleCQNext(fixture.get(), &t, &ok, -1);
+ if (t == tag(0) && ok) {
+ request_rw->Read(&recv_response, tag(0));
+ continue;
+ }
int i = (int)(intptr_t)t;
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
@@ -416,11 +442,15 @@ static void UnaryTrickleArgs(benchmark::internal::Benchmark* b) {
}
}
BENCHMARK(BM_PumpUnbalancedUnary_Trickle)->Apply(UnaryTrickleArgs);
-}
-}
+} // namespace testing
+} // namespace grpc
+
+extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
int main(int argc, char** argv) {
::benchmark::Initialize(&argc, argv);
::grpc::testing::InitTest(&argc, &argv, false);
+ grpc_timer_manager_set_threading(false);
+ gpr_now_impl = ::grpc::testing::fake_now;
::benchmark::RunSpecifiedBenchmarks();
}
diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc
index 360bbabe13..f1e7890fc0 100644
--- a/test/cpp/microbenchmarks/bm_metadata.cc
+++ b/test/cpp/microbenchmarks/bm_metadata.cc
@@ -21,10 +21,8 @@
#include <benchmark/benchmark.h>
#include <grpc/grpc.h>
-extern "C" {
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
-}
#include "test/cpp/microbenchmarks/helpers.h"
@@ -92,11 +90,11 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_from_static_string("key");
gpr_slice v = grpc_slice_from_static_string("value");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlices);
@@ -105,11 +103,11 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -121,13 +119,13 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex(
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem seed = grpc_mdelem_create(&exec_ctx, k, v, NULL);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- GRPC_MDELEM_UNREF(&exec_ctx, seed);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(seed);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -138,11 +136,11 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_from_static_string("value");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -154,14 +152,12 @@ static void BM_MetadataFromNonInternedSlicesWithBackingStore(
gpr_slice k = grpc_slice_from_static_string("key");
gpr_slice v = grpc_slice_from_static_string("value");
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlicesWithBackingStore);
@@ -172,14 +168,12 @@ static void BM_MetadataFromInternedSlicesWithBackingStore(
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -192,14 +186,12 @@ static void BM_MetadataFromInternedKeyWithBackingStore(
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_from_static_string("value");
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -209,11 +201,11 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = GRPC_MDSTR_STATUS;
gpr_slice v = GRPC_MDSTR_200;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -224,11 +216,11 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed(
TrackCounters track_counters;
gpr_slice k = GRPC_MDSTR_STATUS;
gpr_slice v = GRPC_MDSTR_GZIP;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -237,16 +229,15 @@ BENCHMARK(BM_MetadataFromStaticMetadataStringsNotIndexed);
static void BM_MetadataRefUnrefExternal(benchmark::State& state) {
TrackCounters track_counters;
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"),
- grpc_slice_from_static_string("b"),
- reinterpret_cast<grpc_mdelem_data*>(backing_store));
+ grpc_core::ExecCtx exec_ctx;
+ grpc_mdelem el = grpc_mdelem_create(
+ grpc_slice_from_static_string("a"), grpc_slice_from_static_string("b"),
+ reinterpret_cast<grpc_mdelem_data*>(backing_store));
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefExternal);
@@ -254,47 +245,47 @@ BENCHMARK(BM_MetadataRefUnrefExternal);
static void BM_MetadataRefUnrefInterned(benchmark::State& state) {
TrackCounters track_counters;
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
grpc_mdelem el = grpc_mdelem_create(
- &exec_ctx, k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store));
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store));
grpc_slice_unref(k);
grpc_slice_unref(v);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefInterned);
static void BM_MetadataRefUnrefAllocated(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"),
- grpc_slice_from_static_string("b"), NULL);
+ grpc_mdelem_create(grpc_slice_from_static_string("a"),
+ grpc_slice_from_static_string("b"), nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefAllocated);
static void BM_MetadataRefUnrefStatic(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, NULL);
+ grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefStatic);
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 1fc1f2f83b..d9d5164cce 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -23,12 +23,10 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-extern "C" {
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-}
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
@@ -43,8 +41,8 @@ extern "C" {
auto& force_library_initialization = Library::get();
-static void shutdown_ps(grpc_exec_ctx* exec_ctx, void* ps, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(ps));
+static void shutdown_ps(void* ps, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(ps));
}
static void BM_CreateDestroyPollset(benchmark::State& state) {
@@ -52,7 +50,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
size_t ps_sz = grpc_pollset_size();
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_malloc(ps_sz));
gpr_mu* mu;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
@@ -60,11 +58,11 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
memset(ps, 0, ps_sz);
grpc_pollset_init(ps, &mu);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@@ -116,19 +114,17 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_timespec now = gpr_time_0(GPR_CLOCK_MONOTONIC);
- gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ grpc_core::ExecCtx exec_ctx;
gpr_mu_lock(mu);
while (state.KeepRunning()) {
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0));
}
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@@ -140,23 +136,23 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_wakeup_fd wakeup_fd;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd)));
grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
while (state.KeepRunning()) {
- grpc_pollset_add_fd(&exec_ctx, ps, fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(ps, fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_fd_orphan(&exec_ctx, fd, NULL, NULL, false /* already_closed */, "xxx");
+ grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx");
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@@ -173,7 +169,7 @@ Closure* MakeClosure(F f, grpc_closure_scheduler* scheduler) {
C(F f, grpc_closure_scheduler* scheduler) : f_(f) {
GRPC_CLOSURE_INIT(this, C::cbfn, this, scheduler);
}
- static void cbfn(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void cbfn(void* arg, grpc_error* error) {
C* p = static_cast<C*>(arg);
p->f_();
}
@@ -222,13 +218,11 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- gpr_timespec now = gpr_time_0(GPR_CLOCK_MONOTONIC);
- gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ grpc_core::ExecCtx exec_ctx;
grpc_wakeup_fd wakeup_fd;
GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd));
grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read");
- grpc_pollset_add_fd(&exec_ctx, ps, wakeup);
+ grpc_pollset_add_fd(ps, wakeup);
bool done = false;
Closure* continue_closure = MakeClosure(
[&]() {
@@ -238,24 +232,23 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
return;
}
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
},
grpc_schedule_on_exec_ctx);
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
gpr_mu_lock(mu);
while (!done) {
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE));
}
- grpc_fd_orphan(&exec_ctx, wakeup, NULL, NULL, false /* already_closed */,
- "done");
+ grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done");
wakeup_fd.read_fd = 0;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&wakeup_fd);
gpr_free(ps);
track_counters.Finish(state);
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index ecd28c3f8a..d1ede755a5 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -25,9 +25,9 @@
#include <grpc++/security/server_credentials.h>
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
+#include <grpc/support/atm.h>
#include <grpc/support/log.h>
-extern "C" {
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/endpoint.h"
@@ -39,7 +39,6 @@ extern "C" {
#include "src/core/lib/surface/server.h"
#include "test/core/util/passthru_endpoint.h"
#include "test/core/util/port.h"
-}
#include "src/cpp/client/create_channel_internal.h"
#include "test/cpp/microbenchmarks/helpers.h"
@@ -85,7 +84,7 @@ class FullstackFixture : public BaseFixture {
}
virtual ~FullstackFixture() {
- server_->Shutdown();
+ server_->Shutdown(gpr_inf_past(GPR_CLOCK_MONOTONIC));
cq_->Shutdown();
void* tag;
bool ok;
@@ -167,7 +166,7 @@ class EndpointPairFixture : public BaseFixture {
fixture_configuration.ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
/* add server endpoint to server_
* */
@@ -175,19 +174,19 @@ class EndpointPairFixture : public BaseFixture {
const grpc_channel_args* server_args =
grpc_server_get_channel_args(server_->c_server());
server_transport_ = grpc_create_chttp2_transport(
- &exec_ctx, server_args, endpoints.server, 0 /* is_client */);
+ server_args, endpoints.server, false /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]);
+ grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server_->c_server(),
- server_transport_, NULL, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_, NULL);
+ grpc_server_setup_transport(server_->c_server(), server_transport_,
+ nullptr, server_args);
+ grpc_chttp2_transport_start_reading(server_transport_, nullptr, nullptr);
}
/* create channel */
@@ -198,21 +197,18 @@ class EndpointPairFixture : public BaseFixture {
grpc_channel_args c_args = args.c_channel_args();
client_transport_ =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_create_chttp2_transport(&c_args, endpoints.client, true);
GPR_ASSERT(client_transport_);
- grpc_channel* channel =
- grpc_channel_create(&exec_ctx, "target", &c_args,
- GRPC_CLIENT_DIRECT_CHANNEL, client_transport_);
- grpc_chttp2_transport_start_reading(&exec_ctx, client_transport_, NULL);
+ grpc_channel* channel = grpc_channel_create(
+ "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_);
+ grpc_chttp2_transport_start_reading(client_transport_, nullptr, nullptr);
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
virtual ~EndpointPairFixture() {
- server_->Shutdown();
+ server_->Shutdown(gpr_inf_past(GPR_CLOCK_MONOTONIC));
cq_->Shutdown();
void* tag;
bool ok;
@@ -245,7 +241,7 @@ class SockPair : public EndpointPairFixture {
SockPair(Service* service, const FixtureConfiguration& fixture_configuration =
FixtureConfiguration())
: EndpointPairFixture(service,
- grpc_iomgr_create_endpoint_pair("test", NULL),
+ grpc_iomgr_create_endpoint_pair("test", nullptr),
fixture_configuration) {}
};
@@ -259,7 +255,8 @@ class InProcessCHTTP2 : public EndpointPairFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
EndpointPairFixture::AddToLabel(out, state);
out << " writes/iter:"
- << (double)stats_.num_writes / (double)state.iterations();
+ << static_cast<double>(gpr_atm_no_barrier_load(&stats_.num_writes)) /
+ static_cast<double>(state.iterations());
}
private:
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
index 6df044f344..0763d07855 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
@@ -278,7 +278,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
void* t;
bool ok;
- int need_tags;
+ int expect_tags = 0;
// Send 'max_ping_pongs' number of ping pong messages
int ping_pong_cnt = 0;
@@ -289,7 +289,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
request_rw->Write(send_request, tag(2)); // Start client send
}
- need_tags = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5);
+ int await_tags = (1 << 2);
if (ping_pong_cnt == 0) {
// wait for the server call structure (call_hook, etc.) to be
@@ -301,8 +301,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// In some cases tag:2 comes before tag:0 (write tag comes out
// first), this while loop is to make sure get tag:0.
int i = (int)(intptr_t)t;
- GPR_ASSERT(need_tags & (1 << i));
- need_tags &= ~(1 << i);
+ GPR_ASSERT(await_tags & (1 << i));
+ await_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
}
}
@@ -310,7 +310,11 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
response_rw.Read(&recv_request, tag(3)); // Start server recv
request_rw->Read(&recv_response, tag(4)); // Start client recv
- while (need_tags) {
+ await_tags |= (1 << 3) | (1 << 4);
+ expect_tags = await_tags;
+ await_tags |= (1 << 5);
+
+ while (await_tags != 0) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
int i = (int)(intptr_t)t;
@@ -321,34 +325,39 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
if (write_and_finish == 1) {
response_rw.WriteAndFinish(send_response, WriteOptions(),
Status::OK, tag(5));
+ expect_tags |= (1 << 5);
} else {
response_rw.WriteLast(send_response, WriteOptions(), tag(5));
- // WriteLast buffers the write, so neither server write op nor
- // client read op will finish inside the while loop.
- need_tags &= ~(1 << 4);
- need_tags &= ~(1 << 5);
+ // WriteLast buffers the write, so it's possible neither server
+ // write op nor client read op will finish inside the while
+ // loop.
+ await_tags &= ~(1 << 4);
+ await_tags &= ~(1 << 5);
+ expect_tags |= (1 << 5);
}
} else {
response_rw.Write(send_response, tag(5));
+ expect_tags |= (1 << 5);
}
}
- GPR_ASSERT(need_tags & (1 << i));
- need_tags &= ~(1 << i);
+ GPR_ASSERT(expect_tags & (1 << i));
+ expect_tags &= ~(1 << i);
+ await_tags &= ~(1 << i);
}
ping_pong_cnt++;
}
if (max_ping_pongs == 0) {
- need_tags = (1 << 6) | (1 << 7) | (1 << 8);
+ expect_tags |= (1 << 6) | (1 << 7) | (1 << 8);
} else {
if (write_and_finish == 1) {
- need_tags = (1 << 8);
+ expect_tags |= (1 << 8);
} else {
// server's buffered write and the client's read of the buffered write
// tags should come up.
- need_tags = (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8);
+ expect_tags |= (1 << 7) | (1 << 8);
}
}
@@ -360,8 +369,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
while ((int)(intptr_t)t != 0) {
int i = (int)(intptr_t)t;
- GPR_ASSERT(need_tags & (1 << i));
- need_tags &= ~(1 << i);
+ GPR_ASSERT(expect_tags & (1 << i));
+ expect_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
}
response_rw.Finish(Status::OK, tag(7));
@@ -374,11 +383,11 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
Status recv_status;
request_rw->Finish(&recv_status, tag(8));
- while (need_tags) {
+ while (expect_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
int i = (int)(intptr_t)t;
- GPR_ASSERT(need_tags & (1 << i));
- need_tags &= ~(1 << i);
+ GPR_ASSERT(expect_tags & (1 << i));
+ expect_tags &= ~(1 << i);
}
GPR_ASSERT(recv_status.ok());
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index b0caa48cd0..a4c0a3a0ce 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -16,10 +16,15 @@
*
*/
+#include <string.h>
+
#include "test/cpp/microbenchmarks/helpers.h"
-void TrackCounters::Finish(benchmark::State &state) {
+void TrackCounters::Finish(benchmark::State& state) {
std::ostringstream out;
+ for (const auto& l : labels_) {
+ out << l << ' ';
+ }
AddToLabel(out, state);
std::string label = out.str();
if (label.length() && label[0] == ' ') {
@@ -28,7 +33,11 @@ void TrackCounters::Finish(benchmark::State &state) {
state.SetLabel(label.c_str());
}
-void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
+void TrackCounters::AddLabel(const grpc::string& label) {
+ labels_.push_back(label);
+}
+
+void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) {
grpc_stats_data stats_end;
grpc_stats_collect(&stats_end);
grpc_stats_data stats;
@@ -38,16 +47,21 @@ void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
<< "/iter:" << ((double)stats.counters[i] / (double)state.iterations());
}
for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
- out << " " << grpc_stats_histogram_name[i] << "-median:"
- << grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 50.0)
- << " " << grpc_stats_histogram_name[i] << "-99p:"
- << grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 99.0);
+ std::ostringstream median_ss;
+ median_ss << grpc_stats_histogram_name[i] << "-median";
+ state.counters[median_ss.str()] = benchmark::Counter(
+ grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 50.0));
+ std::ostringstream tail_ss;
+ tail_ss << grpc_stats_histogram_name[i] << "-99p";
+ state.counters[tail_ss.str()] = benchmark::Counter(
+ grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 99.0));
}
#ifdef GPR_LOW_LEVEL_COUNTERS
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
- out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) -
- mu_locks_at_start_) /
- (double)state.iterations())
+ out << " locks/iter:"
+ << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) -
+ mu_locks_at_start_) /
+ (double)state.iterations())
<< " atm_cas/iter:"
<< ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_cas) -
atm_cas_at_start_) /
diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h
index 07dd611709..afa3e0f3ca 100644
--- a/test/cpp/microbenchmarks/helpers.h
+++ b/test/cpp/microbenchmarks/helpers.h
@@ -20,12 +20,11 @@
#define TEST_CPP_MICROBENCHMARKS_COUNTERS_H
#include <sstream>
+#include <vector>
-extern "C" {
#include <grpc/support/port_platform.h>
#include "src/core/lib/debug/stats.h"
#include "test/core/util/memory_counters.h"
-}
#include <benchmark/benchmark.h>
#include <grpc++/impl/grpc_library.h>
@@ -55,20 +54,22 @@ class Library {
};
#ifdef GPR_LOW_LEVEL_COUNTERS
-extern "C" gpr_atm gpr_mu_locks;
-extern "C" gpr_atm gpr_counter_atm_cas;
-extern "C" gpr_atm gpr_counter_atm_add;
-extern "C" gpr_atm gpr_now_call_count;
+extern gpr_atm gpr_mu_locks;
+extern gpr_atm gpr_counter_atm_cas;
+extern gpr_atm gpr_counter_atm_add;
+extern gpr_atm gpr_now_call_count;
#endif
class TrackCounters {
public:
TrackCounters() { grpc_stats_collect(&stats_begin_); }
virtual void Finish(benchmark::State& state);
+ virtual void AddLabel(const grpc::string& label);
virtual void AddToLabel(std::ostream& out, benchmark::State& state);
private:
grpc_stats_data stats_begin_;
+ std::vector<grpc::string> labels_;
#ifdef GPR_LOW_LEVEL_COUNTERS
const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&gpr_mu_locks);
const size_t atm_cas_at_start_ =
diff --git a/test/cpp/naming/README.md b/test/cpp/naming/README.md
new file mode 100644
index 0000000000..e0dd208465
--- /dev/null
+++ b/test/cpp/naming/README.md
@@ -0,0 +1,43 @@
+# Resolver Tests
+
+This directory has tests and infrastructure for unit tests and GCE
+integration tests of gRPC resolver functionality.
+
+There are two different tests here:
+
+## Resolver unit tests (resolver "component" tests)
+
+These tests run per-change, along with the rest of the grpc unit tests.
+They query a local testing DNS server.
+
+## GCE integration tests
+
+These tests use the same test binary and the same test records
+as the unit tests, but they run against GCE DNS (this is done by
+running the test on a GCE instance and not specifying an authority
+in uris). These tests run in a background job, which needs to be
+actively monitored.
+
+## Making changes to test records
+
+After making a change to `resolver_test_record_groups.yaml`:
+
+1. Increment the "version number" in the `resolver_tests_common_zone_name`
+ DNS zone (this is a yaml field at the top
+ of `resolver_test_record_groups.yaml`).
+
+2. Regenerate projects.
+
+3. From the repo root, run:
+
+```
+$ test/cpp/naming/create_private_dns_zone.sh
+$ test/cpp/naming/private_dns_zone_init.sh
+```
+
+Note that these commands must be ran in environment that
+has access to the grpc-testing GCE project.
+
+If everything runs smoothly, then once the change is merged,
+the GCE DNS integration testing job will transition to the
+new records and continue passing.
diff --git a/tools/run_tests/helper_scripts/run_node_electron.sh b/test/cpp/naming/create_private_dns_zone.sh
index 7d436b02cb..55a4cfe36e 100755
--- a/tools/run_tests/helper_scripts/run_node_electron.sh
+++ b/test/cpp/naming/create_private_dns_zone.sh
@@ -13,18 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-source ~/.nvm/nvm.sh
+# This file is auto-generated
-nvm use 8
set -ex
-# change to grpc repo root
cd $(dirname $0)/../../..
-test_directory='src/node/test'
-timeout=8000
-
-JUNIT_REPORT_PATH=src/node/report.xml JUNIT_REPORT_STACK=1 \
- ./node_modules/.bin/xvfb-maybe \
- ./node_modules/.bin/electron-mocha --timeout $timeout \
- --reporter mocha-jenkins-reporter $test_directory
+gcloud alpha dns managed-zones create \
+ resolver-tests-version-4-grpctestingexp-zone-id \
+ --dns-name=resolver-tests-version-4.grpctestingexp. \
+ --description="GCE-DNS-private-zone-for-GRPC-testing" \
+ --visibility=private \
+ --networks=default
diff --git a/test/cpp/naming/gen_build_yaml.py b/test/cpp/naming/gen_build_yaml.py
index 3a51fef7a0..91718156e9 100755
--- a/test/cpp/naming/gen_build_yaml.py
+++ b/test/cpp/naming/gen_build_yaml.py
@@ -24,6 +24,12 @@ import json
_LOCAL_DNS_SERVER_ADDRESS = '127.0.0.1:15353'
+_TARGET_RECORDS_TO_SKIP_AGAINST_GCE = [
+ # TODO: enable this once able to upload the very large TXT record
+ # in this group to GCE DNS.
+ 'ipv4-config-causing-fallback-to-tcp',
+]
+
def _append_zone_name(name, zone_name):
return '%s.%s' % (name, zone_name)
@@ -33,21 +39,107 @@ def _build_expected_addrs_cmd_arg(expected_addrs):
out.append('%s,%s' % (addr['address'], str(addr['is_balancer'])))
return ';'.join(out)
+def _data_for_type(r_type, r_data, common_zone_name):
+ if r_type in ['A', 'AAAA']:
+ return ' '.join(map(lambda x: '\"%s\"' % x, r_data))
+ if r_type == 'SRV':
+ assert len(r_data) == 1
+ target = r_data[0].split(' ')[3]
+ uploadable_target = '%s.%s' % (target, common_zone_name)
+ uploadable = r_data[0].split(' ')
+ uploadable[3] = uploadable_target
+ return '\"%s\"' % ' '.join(uploadable)
+ if r_type == 'TXT':
+ assert len(r_data) == 1
+ chunks = []
+ all_data = r_data[0]
+ cur = 0
+ # Split TXT records that span more than 255 characters (the single
+ # string length-limit in DNS) into multiple strings. Each string
+ # needs to be wrapped with double-quotes, and all inner double-quotes
+ # are escaped. The wrapping double-quotes and inner backslashes can be
+ # counted towards the 255 character length limit (as observed with gcloud),
+ # so make sure all strings fit within that limit.
+ while len(all_data[cur:]) > 0:
+ next_chunk = '\"'
+ while len(next_chunk) < 254 and len(all_data[cur:]) > 0:
+ if all_data[cur] == '\"':
+ if len(next_chunk) < 253:
+ next_chunk += '\\\"'
+ else:
+ break
+ else:
+ next_chunk += all_data[cur]
+ cur += 1
+ next_chunk += '\"'
+ if len(next_chunk) > 255:
+ raise Exception('Bug: next chunk is too long.')
+ chunks.append(next_chunk)
+ # Wrap the whole record in single quotes to make sure all strings
+ # are associated with the same TXT record (to make it one bash token for
+ # gcloud)
+ return '\'%s\'' % ' '.join(chunks)
+
+# Convert DNS records from their "within a test group" format
+# of the yaml file to an easier form for the templates to use.
+def _gcloud_uploadable_form(test_cases, common_zone_name):
+ out = []
+ for group in test_cases:
+ if group['record_to_resolve'] in _TARGET_RECORDS_TO_SKIP_AGAINST_GCE:
+ continue
+ for record_name in group['records'].keys():
+ r_ttl = None
+ all_r_data = {}
+ for r_data in group['records'][record_name]:
+ # enforce records have the same TTL only for simplicity
+ if r_ttl is None:
+ r_ttl = r_data['TTL']
+ assert r_ttl == r_data['TTL'], '%s and %s differ' % (r_ttl, r_data['TTL'])
+ r_type = r_data['type']
+ if all_r_data.get(r_type) is None:
+ all_r_data[r_type] = []
+ all_r_data[r_type].append(r_data['data'])
+ for r_type in all_r_data.keys():
+ for r in out:
+ assert r['name'] != record_name or r['type'] != r_type, 'attempt to add a duplicate record'
+ out.append({
+ 'name': record_name,
+ 'ttl': r_ttl,
+ 'type': r_type,
+ 'data': _data_for_type(r_type, all_r_data[r_type], common_zone_name)
+ })
+ return out
+
+def _gce_dns_zone_id(resolver_component_data):
+ dns_name = resolver_component_data['resolver_tests_common_zone_name']
+ return dns_name.replace('.', '-') + 'zone-id'
+
+def _resolver_test_cases(resolver_component_data, records_to_skip):
+ out = []
+ for test_case in resolver_component_data['resolver_component_tests']:
+ if test_case['record_to_resolve'] in records_to_skip:
+ continue
+ out.append({
+ 'target_name': _append_zone_name(test_case['record_to_resolve'],
+ resolver_component_data['resolver_tests_common_zone_name']),
+ 'expected_addrs': _build_expected_addrs_cmd_arg(test_case['expected_addrs']),
+ 'expected_chosen_service_config': (test_case['expected_chosen_service_config'] or ''),
+ 'expected_lb_policy': (test_case['expected_lb_policy'] or ''),
+ })
+ return out
+
def main():
resolver_component_data = ''
with open('test/cpp/naming/resolver_test_record_groups.yaml') as f:
resolver_component_data = yaml.load(f)
json = {
- 'resolver_component_test_cases': [
- {
- 'target_name': _append_zone_name(test_case['record_to_resolve'],
- resolver_component_data['resolver_component_tests_common_zone_name']),
- 'expected_addrs': _build_expected_addrs_cmd_arg(test_case['expected_addrs']),
- 'expected_chosen_service_config': (test_case['expected_chosen_service_config'] or ''),
- 'expected_lb_policy': (test_case['expected_lb_policy'] or ''),
- } for test_case in resolver_component_data['resolver_component_tests']
- ],
+ 'resolver_tests_common_zone_name': resolver_component_data['resolver_tests_common_zone_name'],
+ 'resolver_gce_integration_tests_zone_id': _gce_dns_zone_id(resolver_component_data),
+ 'all_integration_test_records': _gcloud_uploadable_form(resolver_component_data['resolver_component_tests'],
+ resolver_component_data['resolver_tests_common_zone_name']),
+ 'resolver_gce_integration_test_cases': _resolver_test_cases(resolver_component_data, _TARGET_RECORDS_TO_SKIP_AGAINST_GCE),
+ 'resolver_component_test_cases': _resolver_test_cases(resolver_component_data, []),
'targets': [
{
'name': 'resolver_component_test' + unsecure_build_config_suffix,
diff --git a/test/cpp/naming/private_dns_zone_init.sh b/test/cpp/naming/private_dns_zone_init.sh
new file mode 100755
index 0000000000..8fa5a8a475
--- /dev/null
+++ b/test/cpp/naming/private_dns_zone_init.sh
@@ -0,0 +1,215 @@
+#!/bin/bash
+# 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.
+
+# This file is auto-generated
+
+set -ex
+
+cd $(dirname $0)/../../..
+
+gcloud dns record-sets transaction start -z=resolver-tests-version-4-grpctestingexp-zone-id
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 ipv4-single-target.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-single-target.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 ipv4-multi-target.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-multi-target.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.5" "1.2.3.6" "1.2.3.7"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 ipv6-single-target.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv6-single-target.resolver-tests-version-4.grpctestingexp. \
+ --type=AAAA \
+ --ttl=2100 \
+ "2607:f8b0:400a:801::1001"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 ipv6-multi-target.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv6-multi-target.resolver-tests-version-4.grpctestingexp. \
+ --type=AAAA \
+ --ttl=2100 \
+ "2607:f8b0:400a:801::1002" "2607:f8b0:400a:801::1003" "2607:f8b0:400a:801::1004"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpc_config.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
+ --type=TXT \
+ --ttl=2100 \
+ '"grpc_config=[{\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"SimpleService\",\"waitForReady\":true}]}]}}]"'
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpc_config.ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. \
+ --type=TXT \
+ --ttl=2100 \
+ '"grpc_config=[{\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"NoSrvSimpleService\",\"waitForReady\":true}]}]}}]"'
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpc_config.ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. \
+ --type=TXT \
+ --ttl=2100 \
+ '"grpc_config=[{\"clientLanguage\":[\"python\"],\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"PythonService\",\"waitForReady\":true}]}]}}]"'
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpc_config.ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. \
+ --type=TXT \
+ --ttl=2100 \
+ '"grpc_config=[{\"percentage\":0,\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"CppService\",\"waitForReady\":true}]}]}}]"'
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpc_config.ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. \
+ --type=TXT \
+ --ttl=2100 \
+ '"grpc_config=[{\"clientLanguage\":[\"go\"],\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"GoService\",\"waitForReady\":true}]}]}},{\"clientLanguage\":[\"c++\"],\"serviceConfig\":{" "\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"CppService\",\"waitForReady\":true}]}]}}]"'
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpc_config.ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. \
+ --type=TXT \
+ --ttl=2100 \
+ '"grpc_config=[{\"percentage\":0,\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"NeverPickedService\",\"waitForReady\":true}]}]}},{\"percentage\":100,\"serviceConfig\":{\"loadBalanc" "ingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"AlwaysPickedService\",\"waitForReady\":true}]}]}}]"'
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
+ --ttl=2100 \
+ "1.2.3.4"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=_grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
+ --type=SRV \
+ --ttl=2100 \
+ "0 0 1234 balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp."
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
+ --type=AAAA \
+ --ttl=2100 \
+ "2607:f8b0:400a:801::1002"
+
+gcloud dns record-sets transaction add \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
+ --type=AAAA \
+ --ttl=2100 \
+ "2607:f8b0:400a:801::1002"
+
+gcloud dns record-sets transaction describe -z=resolver-tests-version-4-grpctestingexp-zone-id
+gcloud dns record-sets transaction execute -z=resolver-tests-version-4-grpctestingexp-zone-id
+gcloud dns record-sets list -z=resolver-tests-version-4-grpctestingexp-zone-id
diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc
index cc851ca9d5..8b5523f01a 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -32,25 +32,23 @@
#include "test/cpp/util/subprocess.h"
#include "test/cpp/util/test_config.h"
-extern "C" {
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/resolver.h"
#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/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-}
-using std::vector;
using grpc::SubProcess;
+using std::vector;
using testing::UnorderedElementsAreArray;
// Hack copied from "test/cpp/end2end/server_crash_test_client.cc"!
@@ -85,12 +83,12 @@ class GrpcLBAddress final {
GrpcLBAddress(std::string address, bool is_balancer)
: is_balancer(is_balancer), address(address) {}
- bool operator==(const GrpcLBAddress &other) const {
+ bool operator==(const GrpcLBAddress& other) const {
return this->is_balancer == other.is_balancer &&
this->address == other.address;
}
- bool operator!=(const GrpcLBAddress &other) const {
+ bool operator!=(const GrpcLBAddress& other) const {
return !(*this == other);
}
@@ -141,42 +139,43 @@ gpr_timespec TestDeadline(void) {
struct ArgsStruct {
gpr_event ev;
gpr_atm done_atm;
- gpr_mu *mu;
- grpc_pollset *pollset;
- grpc_pollset_set *pollset_set;
- grpc_combiner *lock;
- grpc_channel_args *channel_args;
+ gpr_mu* mu;
+ grpc_pollset* pollset;
+ grpc_pollset_set* pollset_set;
+ grpc_combiner* lock;
+ grpc_channel_args* channel_args;
vector<GrpcLBAddress> expected_addrs;
std::string expected_service_config_string;
std::string expected_lb_policy;
};
-void ArgsInit(grpc_exec_ctx *exec_ctx, ArgsStruct *args) {
+void ArgsInit(ArgsStruct* args) {
gpr_event_init(&args->ev);
- args->pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
+ args->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->lock = grpc_combiner_create();
gpr_atm_rel_store(&args->done_atm, 0);
- args->channel_args = NULL;
+ args->channel_args = nullptr;
}
-void DoNothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+void DoNothing(void* arg, grpc_error* error) {}
-void ArgsFinish(grpc_exec_ctx *exec_ctx, ArgsStruct *args) {
+void ArgsFinish(ArgsStruct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, TestDeadline()));
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure DoNothing_cb;
- GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, NULL, grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &DoNothing_cb);
+ GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(args->pollset, &DoNothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_channel_args_destroy(exec_ctx, args->channel_args);
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_channel_args_destroy(args->channel_args);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
- GRPC_COMBINER_UNREF(exec_ctx, args->lock, NULL);
+ GRPC_COMBINER_UNREF(args->lock, nullptr);
}
gpr_timespec NSecondDeadline(int seconds) {
@@ -184,7 +183,7 @@ gpr_timespec NSecondDeadline(int seconds) {
gpr_time_from_seconds(seconds, GPR_TIMESPAN));
}
-void PollPollsetUntilRequestDone(ArgsStruct *args) {
+void PollPollsetUntilRequestDone(ArgsStruct* args) {
gpr_timespec deadline = NSecondDeadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
@@ -196,63 +195,61 @@ void PollPollsetUntilRequestDone(ArgsStruct *args) {
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done,
time_left.tv_sec, time_left.tv_nsec);
GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0);
- grpc_pollset_worker *worker = NULL;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_worker* worker = nullptr;
+ grpc_core::ExecCtx exec_ctx;
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- gpr_now(GPR_CLOCK_REALTIME), NSecondDeadline(1)));
+ GRPC_LOG_IF_ERROR("pollset_work",
+ grpc_pollset_work(args->pollset, &worker,
+ grpc_timespec_to_millis_round_up(
+ NSecondDeadline(1))));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
- gpr_event_set(&args->ev, (void *)1);
+ gpr_event_set(&args->ev, (void*)1);
}
-void CheckServiceConfigResultLocked(grpc_channel_args *channel_args,
- ArgsStruct *args) {
- const grpc_arg *service_config_arg =
+void CheckServiceConfigResultLocked(grpc_channel_args* channel_args,
+ ArgsStruct* args) {
+ const grpc_arg* service_config_arg =
grpc_channel_args_find(channel_args, GRPC_ARG_SERVICE_CONFIG);
if (args->expected_service_config_string != "") {
- GPR_ASSERT(service_config_arg != NULL);
+ GPR_ASSERT(service_config_arg != nullptr);
GPR_ASSERT(service_config_arg->type == GRPC_ARG_STRING);
EXPECT_EQ(service_config_arg->value.string,
args->expected_service_config_string);
} else {
- GPR_ASSERT(service_config_arg == NULL);
+ GPR_ASSERT(service_config_arg == nullptr);
}
}
-void CheckLBPolicyResultLocked(grpc_channel_args *channel_args,
- ArgsStruct *args) {
- const grpc_arg *lb_policy_arg =
+void CheckLBPolicyResultLocked(grpc_channel_args* channel_args,
+ ArgsStruct* args) {
+ const grpc_arg* lb_policy_arg =
grpc_channel_args_find(channel_args, GRPC_ARG_LB_POLICY_NAME);
if (args->expected_lb_policy != "") {
- GPR_ASSERT(lb_policy_arg != NULL);
+ GPR_ASSERT(lb_policy_arg != nullptr);
GPR_ASSERT(lb_policy_arg->type == GRPC_ARG_STRING);
EXPECT_EQ(lb_policy_arg->value.string, args->expected_lb_policy);
} else {
- GPR_ASSERT(lb_policy_arg == NULL);
+ GPR_ASSERT(lb_policy_arg == nullptr);
}
}
-void CheckResolverResultLocked(grpc_exec_ctx *exec_ctx, void *argsp,
- grpc_error *err) {
- ArgsStruct *args = (ArgsStruct *)argsp;
- grpc_channel_args *channel_args = args->channel_args;
- const grpc_arg *channel_arg =
+void CheckResolverResultLocked(void* argsp, grpc_error* err) {
+ ArgsStruct* args = (ArgsStruct*)argsp;
+ grpc_channel_args* channel_args = args->channel_args;
+ const grpc_arg* channel_arg =
grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES);
- GPR_ASSERT(channel_arg != NULL);
+ GPR_ASSERT(channel_arg != nullptr);
GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER);
- grpc_lb_addresses *addresses =
- (grpc_lb_addresses *)channel_arg->value.pointer.p;
+ grpc_lb_addresses* addresses =
+ (grpc_lb_addresses*)channel_arg->value.pointer.p;
gpr_log(GPR_INFO, "num addrs found: %" PRIdPTR ". expected %" PRIdPTR,
addresses->num_addresses, args->expected_addrs.size());
GPR_ASSERT(addresses->num_addresses == args->expected_addrs.size());
std::vector<GrpcLBAddress> found_lb_addrs;
for (size_t i = 0; i < addresses->num_addresses; i++) {
grpc_lb_address addr = addresses->addresses[i];
- char *str;
+ char* str;
grpc_sockaddr_to_string(&str, &addr.address, 1 /* normalize */);
gpr_log(GPR_INFO, "%s", str);
found_lb_addrs.emplace_back(
@@ -260,8 +257,9 @@ void CheckResolverResultLocked(grpc_exec_ctx *exec_ctx, void *argsp,
gpr_free(str);
}
if (args->expected_addrs.size() != found_lb_addrs.size()) {
- gpr_log(GPR_DEBUG, "found lb addrs size is: %" PRIdPTR
- ". expected addrs size is %" PRIdPTR,
+ gpr_log(GPR_DEBUG,
+ "found lb addrs size is: %" PRIdPTR
+ ". expected addrs size is %" PRIdPTR,
found_lb_addrs.size(), args->expected_addrs.size());
abort();
}
@@ -272,42 +270,40 @@ void CheckResolverResultLocked(grpc_exec_ctx *exec_ctx, void *argsp,
}
gpr_atm_rel_store(&args->done_atm, 1);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, NULL));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
ArgsStruct args;
- ArgsInit(&exec_ctx, &args);
+ ArgsInit(&args);
args.expected_addrs = ParseExpectedAddrs(FLAGS_expected_addrs);
args.expected_service_config_string = FLAGS_expected_chosen_service_config;
args.expected_lb_policy = FLAGS_expected_lb_policy;
// maybe build the address with an authority
- char *whole_uri = NULL;
+ char* whole_uri = nullptr;
GPR_ASSERT(asprintf(&whole_uri, "dns://%s/%s",
FLAGS_local_dns_server_address.c_str(),
FLAGS_target_name.c_str()));
// create resolver and resolve
- grpc_resolver *resolver = grpc_resolver_create(&exec_ctx, whole_uri, NULL,
- args.pollset_set, args.lock);
+ grpc_resolver* resolver =
+ grpc_resolver_create(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(&exec_ctx, resolver, &args.channel_args,
+ (void*)&args, grpc_combiner_scheduler(args.lock));
+ grpc_resolver_next_locked(resolver, &args.channel_args,
&on_resolver_result_changed);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
PollPollsetUntilRequestDone(&args);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, NULL);
- ArgsFinish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, nullptr);
+ ArgsFinish(&args);
}
} // namespace
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_init();
grpc_test_init(argc, argv);
::testing::InitGoogleTest(&argc, argv);
diff --git a/test/cpp/naming/resolver_component_tests_runner.sh b/test/cpp/naming/resolver_component_tests_runner.sh
index cf71c9dcf9..11a45d72ce 100755
--- a/test/cpp/naming/resolver_component_tests_runner.sh
+++ b/test/cpp/naming/resolver_component_tests_runner.sh
@@ -73,7 +73,7 @@ EXIT_CODE=0
# in the resolver.
$FLAGS_test_bin_path \
- --target_name='srv-ipv4-single-target.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:1234,True' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -81,7 +81,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='srv-ipv4-multi-target.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -89,7 +89,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='srv-ipv6-single-target.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='[2607:f8b0:400a:801::1001]:1234,True' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -97,7 +97,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='srv-ipv6-multi-target.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -105,7 +105,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='srv-ipv4-simple-service-config.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:1234,True' \
--expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' \
--expected_lb_policy='round_robin' \
@@ -113,7 +113,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='ipv4-no-srv-simple-service-config.resolver-tests.grpctestingexp.' \
+ --target_name='ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:443,False' \
--expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}' \
--expected_lb_policy='round_robin' \
@@ -121,7 +121,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='ipv4-no-config-for-cpp.resolver-tests.grpctestingexp.' \
+ --target_name='ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:443,False' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -129,7 +129,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='ipv4-cpp-config-has-zero-percentage.resolver-tests.grpctestingexp.' \
+ --target_name='ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:443,False' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -137,7 +137,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='ipv4-second-language-is-cpp.resolver-tests.grpctestingexp.' \
+ --target_name='ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:443,False' \
--expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}' \
--expected_lb_policy='round_robin' \
@@ -145,7 +145,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='ipv4-config-with-percentages.resolver-tests.grpctestingexp.' \
+ --target_name='ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:443,False' \
--expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}' \
--expected_lb_policy='round_robin' \
@@ -153,7 +153,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='srv-ipv4-target-has-backend-and-balancer.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:1234,True;1.2.3.4:443,False' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -161,7 +161,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='srv-ipv6-target-has-backend-and-balancer.resolver-tests.grpctestingexp.' \
+ --target_name='srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False' \
--expected_chosen_service_config='' \
--expected_lb_policy='' \
@@ -169,7 +169,7 @@ $FLAGS_test_bin_path \
wait $! || EXIT_CODE=1
$FLAGS_test_bin_path \
- --target_name='ipv4-config-causing-fallback-to-tcp.resolver-tests.grpctestingexp.' \
+ --target_name='ipv4-config-causing-fallback-to-tcp.resolver-tests-version-4.grpctestingexp.' \
--expected_addrs='1.2.3.4:443,False' \
--expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}' \
--expected_lb_policy='' \
diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
index b14391284d..65f11243fe 100644
--- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc
+++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
@@ -32,10 +32,8 @@
#include "test/cpp/util/subprocess.h"
#include "test/cpp/util/test_config.h"
-extern "C" {
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "test/core/util/port.h"
-}
DEFINE_bool(
running_under_bazel, false,
@@ -62,16 +60,16 @@ static void register_sighandler() {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = sighandler;
- sigaction(SIGINT, &act, NULL);
- sigaction(SIGTERM, &act, NULL);
+ sigaction(SIGINT, &act, nullptr);
+ sigaction(SIGTERM, &act, nullptr);
}
namespace {
const int kTestTimeoutSeconds = 60 * 2;
-void RunSigHandlingThread(SubProcess *test_driver, gpr_mu *test_driver_mu,
- gpr_cv *test_driver_cv, int *test_driver_done) {
+void RunSigHandlingThread(SubProcess* test_driver, gpr_mu* test_driver_mu,
+ gpr_cv* test_driver_cv, int* test_driver_done) {
gpr_timespec overall_deadline =
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(kTestTimeoutSeconds, GPR_TIMESPAN));
@@ -94,7 +92,7 @@ void RunSigHandlingThread(SubProcess *test_driver, gpr_mu *test_driver_mu,
test_driver->Interrupt();
return;
}
-}
+} // namespace
namespace grpc {
@@ -106,7 +104,7 @@ void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path,
std::string records_config_path) {
int test_dns_server_port = grpc_pick_unused_port_or_die();
- SubProcess *test_driver = new SubProcess(
+ SubProcess* test_driver = new SubProcess(
{test_runner_bin_path, "--test_bin_path=" + test_bin_path,
"--dns_server_bin_path=" + dns_server_bin_path,
"--records_config_path=" + records_config_path,
@@ -153,7 +151,7 @@ void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path,
} // namespace grpc
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
grpc_init();
GPR_ASSERT(FLAGS_test_bin_name != "");
diff --git a/test/cpp/naming/resolver_gce_integration_tests_runner.sh b/test/cpp/naming/resolver_gce_integration_tests_runner.sh
new file mode 100755
index 0000000000..091f9efbbd
--- /dev/null
+++ b/test/cpp/naming/resolver_gce_integration_tests_runner.sh
@@ -0,0 +1,359 @@
+#!/bin/bash
+# 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.
+
+# This file is auto-generated
+
+set -ex
+
+if [[ "$GRPC_DNS_RESOLVER" == "" ]]; then
+ export GRPC_DNS_RESOLVER=ares
+elif [[ "$GRPC_DNS_RESOLVER" != ares ]]; then
+ echo "Unexpected: GRPC_DNS_RESOLVER=$GRPC_DNS_RESOLVER. This test only works with c-ares resolver"
+ exit 1
+fi
+
+cd $(dirname $0)/../../..
+
+if [[ "$CONFIG" == "" ]]; then
+ export CONFIG=opt
+fi
+make resolver_component_test
+echo "Sanity check DNS records are resolveable with dig:"
+EXIT_CODE=0
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig AAAA ipv6-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig AAAA ipv6-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig AAAA ipv6-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig AAAA ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig TXT _grpc_config.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig TXT _grpc_config.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig TXT _grpc_config.ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig TXT _grpc_config.ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig TXT _grpc_config.ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig TXT _grpc_config.ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig TXT _grpc_config.ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig TXT _grpc_config.ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig TXT _grpc_config.ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig TXT _grpc_config.ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig TXT _grpc_config.ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig TXT _grpc_config.ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig A srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig A srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig SRV _grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig AAAA balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig AAAA balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+ONE_FAILED=0
+dig AAAA srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Sanity check: dig AAAA srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ exit 1
+fi
+
+echo "Sanity check PASSED. Run resolver tests:"
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:1234,True' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='[2607:f8b0:400a:801::1001]:1234,True' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:1234,True' \
+ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' \
+ --expected_lb_policy='round_robin' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:443,False' \
+ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}' \
+ --expected_lb_policy='round_robin' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:443,False' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:443,False' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:443,False' \
+ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}' \
+ --expected_lb_policy='round_robin' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:443,False' \
+ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}' \
+ --expected_lb_policy='round_robin' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='1.2.3.4:1234,True;1.2.3.4:443,False' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+ONE_FAILED=0
+bins/$CONFIG/resolver_component_test \
+ --target_name='srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \
+ --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False' \
+ --expected_chosen_service_config='' \
+ --expected_lb_policy='' || ONE_FAILED=1
+if [[ "$ONE_FAILED" != 0 ]]; then
+ echo "Test based on target record: srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
+ EXIT_CODE=1
+fi
+
+exit $EXIT_CODE
diff --git a/test/cpp/naming/resolver_test_record_groups.yaml b/test/cpp/naming/resolver_test_record_groups.yaml
index 33d774ca70..6c4f89d09b 100644
--- a/test/cpp/naming/resolver_test_record_groups.yaml
+++ b/test/cpp/naming/resolver_test_record_groups.yaml
@@ -1,4 +1,4 @@
-resolver_component_tests_common_zone_name: resolver-tests.grpctestingexp.
+resolver_tests_common_zone_name: resolver-tests-version-4.grpctestingexp.
resolver_component_tests:
- expected_addrs:
- {address: '1.2.3.4:1234', is_balancer: true}
@@ -58,7 +58,7 @@ resolver_component_tests:
- {TTL: '2100', data: 0 0 1234 ipv4-simple-service-config, type: SRV}
ipv4-simple-service-config:
- {TTL: '2100', data: 1.2.3.4, type: A}
- srv-ipv4-simple-service-config:
+ _grpc_config.srv-ipv4-simple-service-config:
- {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}}]',
type: TXT}
- expected_addrs:
@@ -69,6 +69,7 @@ resolver_component_tests:
records:
ipv4-no-srv-simple-service-config:
- {TTL: '2100', data: 1.2.3.4, type: A}
+ _grpc_config.ipv4-no-srv-simple-service-config:
- {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}}]',
type: TXT}
- expected_addrs:
@@ -79,6 +80,7 @@ resolver_component_tests:
records:
ipv4-no-config-for-cpp:
- {TTL: '2100', data: 1.2.3.4, type: A}
+ _grpc_config.ipv4-no-config-for-cpp:
- {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["python"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"PythonService","waitForReady":true}]}]}}]',
type: TXT}
- expected_addrs:
@@ -89,6 +91,7 @@ resolver_component_tests:
records:
ipv4-cpp-config-has-zero-percentage:
- {TTL: '2100', data: 1.2.3.4, type: A}
+ _grpc_config.ipv4-cpp-config-has-zero-percentage:
- {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]',
type: TXT}
- expected_addrs:
@@ -99,6 +102,7 @@ resolver_component_tests:
records:
ipv4-second-language-is-cpp:
- {TTL: '2100', data: 1.2.3.4, type: A}
+ _grpc_config.ipv4-second-language-is-cpp:
- {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService","waitForReady":true}]}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]',
type: TXT}
- expected_addrs:
@@ -109,6 +113,7 @@ resolver_component_tests:
records:
ipv4-config-with-percentages:
- {TTL: '2100', data: 1.2.3.4, type: A}
+ _grpc_config.ipv4-config-with-percentages:
- {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NeverPickedService","waitForReady":true}]}]}},{"percentage":100,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}}]',
type: TXT}
- expected_addrs:
@@ -145,5 +150,6 @@ resolver_component_tests:
records:
ipv4-config-causing-fallback-to-tcp:
- {TTL: '2100', data: 1.2.3.4, type: A}
+ _grpc_config.ipv4-config-causing-fallback-to-tcp:
- {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}}]',
type: TXT}
diff --git a/test/cpp/naming/test_dns_server.py b/test/cpp/naming/test_dns_server.py
index 9d4b89cffb..9f42f65ee6 100755
--- a/test/cpp/naming/test_dns_server.py
+++ b/test/cpp/naming/test_dns_server.py
@@ -66,7 +66,7 @@ def start_local_dns_server(args):
with open(args.records_config_path) as config:
test_records_config = yaml.load(config)
- common_zone_name = test_records_config['resolver_component_tests_common_zone_name']
+ common_zone_name = test_records_config['resolver_tests_common_zone_name']
for group in test_records_config['resolver_component_tests']:
for name in group['records'].keys():
for record in group['records'][name]:
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index f4f794cb88..0b9dc83f2b 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -26,7 +26,6 @@
#include <grpc/support/log.h>
#include <gtest/gtest.h>
-extern "C" {
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/endpoint.h"
@@ -38,7 +37,7 @@ extern "C" {
#include "src/core/lib/surface/server.h"
#include "test/core/util/passthru_endpoint.h"
#include "test/core/util/port.h"
-}
+
#include "src/cpp/client/create_channel_internal.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/test_config.h"
@@ -83,26 +82,26 @@ class EndpointPairFixture {
ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
/* add server endpoint to server_ */
{
const grpc_channel_args* server_args =
grpc_server_get_channel_args(server_->c_server());
grpc_transport* transport = grpc_create_chttp2_transport(
- &exec_ctx, server_args, endpoints.server, 0 /* is_client */);
+ server_args, endpoints.server, false /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]);
+ grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport,
- NULL, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_server_setup_transport(server_->c_server(), transport, nullptr,
+ server_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
}
/* create channel */
@@ -113,16 +112,14 @@ class EndpointPairFixture {
grpc_channel_args c_args = args.c_channel_args();
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_create_chttp2_transport(&c_args, endpoints.client, true);
GPR_ASSERT(transport);
grpc_channel* channel = grpc_channel_create(
- &exec_ctx, "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
virtual ~EndpointPairFixture() {
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index 3352269517..f1abb19e64 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -106,7 +106,19 @@ grpc_cc_library(
"histogram.h",
"stats.h",
],
- deps = ["//:gpr"],
+ deps = ["//test/core/util:grpc_test_util"],
+)
+
+grpc_cc_test(
+ name = "inproc_sync_unary_ping_pong_test",
+ srcs = ["inproc_sync_unary_ping_pong_test.cc"],
+ deps = [
+ ":benchmark_config",
+ ":driver_impl",
+ "//:grpc++",
+ "//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
+ ],
)
grpc_cc_library(
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 7fbaf63492..82c6361abd 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -37,10 +37,14 @@
#include "src/cpp/util/core_stats.h"
#include "test/cpp/qps/histogram.h"
#include "test/cpp/qps/interarrival.h"
+#include "test/cpp/qps/qps_worker.h"
+#include "test/cpp/qps/server.h"
#include "test/cpp/qps/usage_timer.h"
#include "test/cpp/util/create_test_channel.h"
#include "test/cpp/util/test_credentials_provider.h"
+#define INPROC_NAME_PREFIX "qpsinproc:"
+
namespace grpc {
namespace testing {
@@ -226,7 +230,6 @@ class Client {
}
virtual void DestroyMultithreading() = 0;
- virtual bool ThreadFunc(HistogramEntry* histogram, size_t thread_idx) = 0;
void SetupLoadTest(const ClientConfig& config, size_t num_threads) {
// Set up the load distribution based on the number of threads
@@ -274,7 +277,6 @@ class Client {
: std::bind(&Client::NextIssueTime, this, thread_idx);
}
- private:
class Thread {
public:
Thread(Client* client, size_t idx)
@@ -294,39 +296,33 @@ class Client {
MergeStatusHistogram(statuses_, s);
}
+ void UpdateHistogram(HistogramEntry* entry) {
+ std::lock_guard<std::mutex> g(mu_);
+ if (entry->value_used()) {
+ histogram_.Add(entry->value());
+ }
+ if (entry->status_used()) {
+ statuses_[entry->status()]++;
+ }
+ }
+
private:
Thread(const Thread&);
Thread& operator=(const Thread&);
void ThreadFunc() {
+ int wait_loop = 0;
while (!gpr_event_wait(
&client_->start_requests_,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(1, GPR_TIMESPAN)))) {
- gpr_log(GPR_INFO, "Waiting for benchmark to start");
+ gpr_time_from_seconds(20, GPR_TIMESPAN)))) {
+ gpr_log(GPR_INFO, "%" PRIdPTR ": Waiting for benchmark to start (%d)",
+ idx_, wait_loop);
+ wait_loop++;
}
- for (;;) {
- // run the loop body
- HistogramEntry entry;
- const bool thread_still_ok = client_->ThreadFunc(&entry, idx_);
- // lock, update histogram if needed and see if we're done
- std::lock_guard<std::mutex> g(mu_);
- if (entry.value_used()) {
- histogram_.Add(entry.value());
- }
- if (entry.status_used()) {
- statuses_[entry.status()]++;
- }
- if (!thread_still_ok) {
- gpr_log(GPR_ERROR, "Finishing client thread due to RPC error");
- }
- if (!thread_still_ok ||
- static_cast<bool>(gpr_atm_acq_load(&client_->thread_pool_done_))) {
- client_->CompleteThread();
- return;
- }
- }
+ client_->ThreadFunc(idx_, this);
+ client_->CompleteThread();
}
std::mutex mu_;
@@ -337,6 +333,12 @@ class Client {
std::thread impl_;
};
+ bool ThreadCompleted() {
+ return static_cast<bool>(gpr_atm_acq_load(&thread_pool_done_));
+ }
+
+ virtual void ThreadFunc(size_t thread_idx, Client::Thread* t) = 0;
+
std::vector<std::unique_ptr<Thread>> threads_;
std::unique_ptr<UsageTimer> timer_;
@@ -380,6 +382,13 @@ class ClientImpl : public Client {
config.server_targets(i % config.server_targets_size()), config,
create_stub_, i);
}
+ std::vector<std::unique_ptr<std::thread>> connecting_threads;
+ for (auto& c : channels_) {
+ connecting_threads.emplace_back(c.WaitForReady());
+ }
+ for (auto& t : connecting_threads) {
+ t->join();
+ }
ClientRequestCreator<RequestType> create_req(&request_,
config.payload_config());
@@ -409,19 +418,36 @@ class ClientImpl : public Client {
type = config.security_params().cred_type();
}
- channel_ = CreateTestChannel(
- target, type, config.security_params().server_host_override(),
- !config.security_params().use_test_ca(),
- std::shared_ptr<CallCredentials>(), args);
- gpr_log(GPR_INFO, "Connecting to %s", target.c_str());
- GPR_ASSERT(channel_->WaitForConnected(
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(300, GPR_TIMESPAN))));
+ grpc::string inproc_pfx(INPROC_NAME_PREFIX);
+ if (target.find(inproc_pfx) != 0) {
+ channel_ = CreateTestChannel(
+ target, type, config.security_params().server_host_override(),
+ !config.security_params().use_test_ca(),
+ std::shared_ptr<CallCredentials>(), args);
+ gpr_log(GPR_INFO, "Connecting to %s", target.c_str());
+ is_inproc_ = false;
+ } else {
+ grpc::string tgt = target;
+ tgt.erase(0, inproc_pfx.length());
+ int srv_num = std::stoi(tgt);
+ channel_ = (*g_inproc_servers)[srv_num]->InProcessChannel(args);
+ is_inproc_ = true;
+ }
stub_ = create_stub(channel_);
}
Channel* get_channel() { return channel_.get(); }
StubType* get_stub() { return stub_.get(); }
+ std::unique_ptr<std::thread> WaitForReady() {
+ return std::unique_ptr<std::thread>(new std::thread([this]() {
+ if (!is_inproc_) {
+ GPR_ASSERT(channel_->WaitForConnected(
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(10, GPR_TIMESPAN))));
+ }
+ }));
+ }
+
private:
void set_channel_args(const ClientConfig& config, ChannelArguments* args) {
for (auto channel_arg : config.channel_args()) {
@@ -437,6 +463,7 @@ class ClientImpl : public Client {
std::shared_ptr<Channel> channel_;
std::unique_ptr<StubType> stub_;
+ bool is_inproc_;
};
std::vector<ClientChannelInfo> channels_;
std::function<std::unique_ptr<StubType>(const std::shared_ptr<Channel>&)>
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index f5807da81e..e3fba36a7a 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -82,6 +82,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
prepare_req_(prepare_req) {}
~ClientRpcContextUnaryImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
+ GPR_ASSERT(!config.use_coalesce_api()); // not supported.
StartInternal(cq);
}
bool RunNextState(bool ok, HistogramEntry* entry) override {
@@ -149,9 +150,9 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
// Specify which protected members we are using since there is no
// member name resolution until the template types are fully resolved
public:
+ using Client::NextIssuer;
using Client::SetupLoadTest;
using Client::closed_loop_;
- using Client::NextIssuer;
using ClientImpl<StubType, RequestType>::cores_;
using ClientImpl<StubType, RequestType>::channels_;
using ClientImpl<StubType, RequestType>::request_;
@@ -236,31 +237,57 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
this->EndThreads(); // this needed for resolution
}
- bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override final {
- void* got_tag;
- bool ok;
-
- if (cli_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) {
- // Got a regular event, so process it
- ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
- // Proceed while holding a lock to make sure that
- // this thread isn't supposed to shut down
- std::lock_guard<std::mutex> l(shutdown_state_[thread_idx]->mutex);
- if (shutdown_state_[thread_idx]->shutdown) {
+ ClientRpcContext* ProcessTag(size_t thread_idx, void* tag) {
+ ClientRpcContext* ctx = ClientRpcContext::detag(tag);
+ if (shutdown_state_[thread_idx]->shutdown) {
+ ctx->TryCancel();
+ delete ctx;
+ bool ok;
+ while (cli_cqs_[cq_[thread_idx]]->Next(&tag, &ok)) {
+ ctx = ClientRpcContext::detag(tag);
ctx->TryCancel();
delete ctx;
- return true;
}
- if (!ctx->RunNextState(ok, entry)) {
- // The RPC and callback are done, so clone the ctx
- // and kickstart the new one
- ctx->StartNewClone(cli_cqs_[cq_[thread_idx]].get());
- delete ctx;
+ return nullptr;
+ }
+ return ctx;
+ }
+
+ void ThreadFunc(size_t thread_idx, Client::Thread* t) override final {
+ void* got_tag;
+ bool ok;
+
+ HistogramEntry entry;
+ HistogramEntry* entry_ptr = &entry;
+ if (!cli_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) {
+ return;
+ }
+ std::mutex* shutdown_mu = &shutdown_state_[thread_idx]->mutex;
+ shutdown_mu->lock();
+ ClientRpcContext* ctx = ProcessTag(thread_idx, got_tag);
+ if (ctx == nullptr) {
+ shutdown_mu->unlock();
+ return;
+ }
+ while (cli_cqs_[cq_[thread_idx]]->DoThenAsyncNext(
+ [&, ctx, ok, entry_ptr, shutdown_mu]() {
+ if (!ctx->RunNextState(ok, entry_ptr)) {
+ // The RPC and callback are done, so clone the ctx
+ // and kickstart the new one
+ ctx->StartNewClone(cli_cqs_[cq_[thread_idx]].get());
+ delete ctx;
+ }
+ shutdown_mu->unlock();
+ },
+ &got_tag, &ok, gpr_inf_future(GPR_CLOCK_REALTIME))) {
+ t->UpdateHistogram(entry_ptr);
+ entry = HistogramEntry();
+ shutdown_mu->lock();
+ ctx = ProcessTag(thread_idx, got_tag);
+ if (ctx == nullptr) {
+ shutdown_mu->unlock();
+ return;
}
- return true;
- } else {
- // queue is shutting down, so we must be done
- return true;
}
}
@@ -323,10 +350,11 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext {
next_state_(State::INVALID),
callback_(on_done),
next_issue_(next_issue),
- prepare_req_(prepare_req) {}
+ prepare_req_(prepare_req),
+ coalesce_(false) {}
~ClientRpcContextStreamingPingPongImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
- StartInternal(cq, config.messages_per_stream());
+ StartInternal(cq, config.messages_per_stream(), config.use_coalesce_api());
}
bool RunNextState(bool ok, HistogramEntry* entry) override {
while (true) {
@@ -349,7 +377,12 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext {
}
start_ = UsageTimer::Now();
next_state_ = State::WRITE_DONE;
- stream_->Write(req_, ClientRpcContext::tag(this));
+ if (coalesce_ && messages_issued_ == messages_per_stream_ - 1) {
+ stream_->WriteLast(req_, WriteOptions(),
+ ClientRpcContext::tag(this));
+ } else {
+ stream_->Write(req_, ClientRpcContext::tag(this));
+ }
return true;
case State::WRITE_DONE:
if (!ok) {
@@ -365,6 +398,11 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext {
if ((messages_per_stream_ != 0) &&
(++messages_issued_ >= messages_per_stream_)) {
next_state_ = State::WRITES_DONE_DONE;
+ if (coalesce_) {
+ // WritesDone should have been called on the last Write.
+ // loop around to call Finish.
+ break;
+ }
stream_->WritesDone(ClientRpcContext::tag(this));
return true;
}
@@ -387,7 +425,7 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext {
void StartNewClone(CompletionQueue* cq) override {
auto* clone = new ClientRpcContextStreamingPingPongImpl(
stub_, req_, next_issue_, prepare_req_, callback_);
- clone->StartInternal(cq, messages_per_stream_);
+ clone->StartInternal(cq, messages_per_stream_, coalesce_);
}
void TryCancel() override { context_.TryCancel(); }
@@ -423,14 +461,27 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext {
// Allow a limit on number of messages in a stream
int messages_per_stream_;
int messages_issued_;
+ // Whether to use coalescing API.
+ bool coalesce_;
- void StartInternal(CompletionQueue* cq, int messages_per_stream) {
+ void StartInternal(CompletionQueue* cq, int messages_per_stream,
+ bool coalesce) {
cq_ = cq;
messages_per_stream_ = messages_per_stream;
messages_issued_ = 0;
+ coalesce_ = coalesce;
+ if (coalesce_) {
+ GPR_ASSERT(messages_per_stream_ != 0);
+ context_.set_initial_metadata_corked(true);
+ }
stream_ = prepare_req_(stub_, &context_, cq);
next_state_ = State::STREAM_IDLE;
stream_->StartCall(ClientRpcContext::tag(this));
+ if (coalesce_) {
+ // When the intial metadata is corked, the tag will not come back and we
+ // need to manually drive the state machine.
+ RunNextState(true, nullptr);
+ }
}
};
@@ -486,6 +537,7 @@ class ClientRpcContextStreamingFromClientImpl : public ClientRpcContext {
prepare_req_(prepare_req) {}
~ClientRpcContextStreamingFromClientImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
+ GPR_ASSERT(!config.use_coalesce_api()); // not supported yet.
StartInternal(cq);
}
bool RunNextState(bool ok, HistogramEntry* entry) override {
@@ -615,6 +667,7 @@ class ClientRpcContextStreamingFromServerImpl : public ClientRpcContext {
prepare_req_(prepare_req) {}
~ClientRpcContextStreamingFromServerImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
+ GPR_ASSERT(!config.use_coalesce_api()); // not supported
StartInternal(cq);
}
bool RunNextState(bool ok, HistogramEntry* entry) override {
@@ -727,6 +780,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
prepare_req_(prepare_req) {}
~ClientRpcContextGenericStreamingImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
+ GPR_ASSERT(!config.use_coalesce_api()); // not supported yet.
StartInternal(cq, config.messages_per_stream());
}
bool RunNextState(bool ok, HistogramEntry* entry) override {
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index 5d212f1acc..a2ddbeb508 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -60,7 +60,25 @@ class SynchronousClient
SetupLoadTest(config, num_threads_);
}
- virtual ~SynchronousClient(){};
+ virtual ~SynchronousClient() {}
+
+ virtual bool InitThreadFuncImpl(size_t thread_idx) = 0;
+ virtual bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) = 0;
+
+ void ThreadFunc(size_t thread_idx, Thread* t) override {
+ if (!InitThreadFuncImpl(thread_idx)) {
+ return;
+ }
+ for (;;) {
+ // run the loop body
+ HistogramEntry entry;
+ const bool thread_still_ok = ThreadFuncImpl(&entry, thread_idx);
+ t->UpdateHistogram(&entry);
+ if (!thread_still_ok || ThreadCompleted()) {
+ return;
+ }
+ }
+ }
protected:
// WaitToIssue returns false if we realize that we need to break out
@@ -90,9 +108,6 @@ class SynchronousClient
size_t num_threads_;
std::vector<SimpleResponse> responses_;
-
- private:
- void DestroyMultithreading() override final { EndThreads(); }
};
class SynchronousUnaryClient final : public SynchronousClient {
@@ -103,7 +118,9 @@ class SynchronousUnaryClient final : public SynchronousClient {
}
~SynchronousUnaryClient() {}
- bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override {
+ bool InitThreadFuncImpl(size_t thread_idx) override { return true; }
+
+ bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
if (!WaitToIssue(thread_idx)) {
return true;
}
@@ -119,6 +136,9 @@ class SynchronousUnaryClient final : public SynchronousClient {
entry->set_status(s.error_code());
return true;
}
+
+ private:
+ void DestroyMultithreading() override final { EndThreads(); }
};
template <class StreamType>
@@ -128,31 +148,30 @@ class SynchronousStreamingClient : public SynchronousClient {
: SynchronousClient(config),
context_(num_threads_),
stream_(num_threads_),
+ stream_mu_(num_threads_),
+ shutdown_(num_threads_),
messages_per_stream_(config.messages_per_stream()),
messages_issued_(num_threads_) {
StartThreads(num_threads_);
}
virtual ~SynchronousStreamingClient() {
- std::vector<std::thread> cleanup_threads;
- for (size_t i = 0; i < num_threads_; i++) {
- cleanup_threads.emplace_back([this, i]() {
- auto stream = &stream_[i];
- if (*stream) {
- // forcibly cancel the streams, then finish
- context_[i].TryCancel();
- (*stream)->Finish().IgnoreError();
- // don't log any error message on !ok since this was canceled
- }
- });
- }
- for (auto& th : cleanup_threads) {
- th.join();
- }
+ CleanupAllStreams([this](size_t thread_idx) {
+ // Don't log any kind of error since we may have canceled this
+ stream_[thread_idx]->Finish().IgnoreError();
+ });
}
protected:
std::vector<grpc::ClientContext> context_;
std::vector<std::unique_ptr<StreamType>> stream_;
+ // stream_mu_ is only needed when changing an element of stream_ or context_
+ std::vector<std::mutex> stream_mu_;
+ // use struct Bool rather than bool because vector<bool> is not concurrent
+ struct Bool {
+ bool val;
+ Bool() : val(false) {}
+ };
+ std::vector<Bool> shutdown_;
const int messages_per_stream_;
std::vector<int> messages_issued_;
@@ -161,33 +180,26 @@ class SynchronousStreamingClient : public SynchronousClient {
// don't set the value since the stream is failed and shouldn't be timed
entry->set_status(s.error_code());
if (!s.ok()) {
- gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", thread_idx,
- s.error_message().c_str());
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
+ gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s",
+ thread_idx, s.error_message().c_str());
+ }
}
+ // Lock the stream_mu_ now because the client context could change
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
context_[thread_idx].~ClientContext();
new (&context_[thread_idx]) ClientContext();
}
-};
-class SynchronousStreamingPingPongClient final
- : public SynchronousStreamingClient<
- grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>> {
- public:
- SynchronousStreamingPingPongClient(const ClientConfig& config)
- : SynchronousStreamingClient(config) {
- for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) {
- auto* stub = channels_[thread_idx % channels_.size()].get_stub();
- stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]);
- messages_issued_[thread_idx] = 0;
- }
- }
- ~SynchronousStreamingPingPongClient() {
+ void CleanupAllStreams(std::function<void(size_t)> cleaner) {
std::vector<std::thread> cleanup_threads;
for (size_t i = 0; i < num_threads_; i++) {
- cleanup_threads.emplace_back([this, i]() {
- auto stream = &stream_[i];
- if (*stream) {
- (*stream)->WritesDone();
+ cleanup_threads.emplace_back([this, i, cleaner] {
+ std::lock_guard<std::mutex> l(stream_mu_[i]);
+ shutdown_[i].val = true;
+ if (stream_[i]) {
+ cleaner(i);
}
});
}
@@ -196,7 +208,39 @@ class SynchronousStreamingPingPongClient final
}
}
- bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override {
+ private:
+ void DestroyMultithreading() override final {
+ CleanupAllStreams(
+ [this](size_t thread_idx) { context_[thread_idx].TryCancel(); });
+ EndThreads();
+ }
+};
+
+class SynchronousStreamingPingPongClient final
+ : public SynchronousStreamingClient<
+ grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>> {
+ public:
+ SynchronousStreamingPingPongClient(const ClientConfig& config)
+ : SynchronousStreamingClient(config) {}
+ ~SynchronousStreamingPingPongClient() {
+ CleanupAllStreams(
+ [this](size_t thread_idx) { stream_[thread_idx]->WritesDone(); });
+ }
+
+ private:
+ bool InitThreadFuncImpl(size_t thread_idx) override {
+ auto* stub = channels_[thread_idx % channels_.size()].get_stub();
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
+ stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]);
+ } else {
+ return false;
+ }
+ messages_issued_[thread_idx] = 0;
+ return true;
+ }
+
+ bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
if (!WaitToIssue(thread_idx)) {
return true;
}
@@ -218,7 +262,13 @@ class SynchronousStreamingPingPongClient final
stream_[thread_idx]->WritesDone();
FinishStream(entry, thread_idx);
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
- stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]);
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
+ stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]);
+ } else {
+ stream_[thread_idx].reset();
+ return false;
+ }
messages_issued_[thread_idx] = 0;
return true;
}
@@ -228,30 +278,29 @@ class SynchronousStreamingFromClientClient final
: public SynchronousStreamingClient<grpc::ClientWriter<SimpleRequest>> {
public:
SynchronousStreamingFromClientClient(const ClientConfig& config)
- : SynchronousStreamingClient(config), last_issue_(num_threads_) {
- for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) {
- auto* stub = channels_[thread_idx % channels_.size()].get_stub();
+ : SynchronousStreamingClient(config), last_issue_(num_threads_) {}
+ ~SynchronousStreamingFromClientClient() {
+ CleanupAllStreams(
+ [this](size_t thread_idx) { stream_[thread_idx]->WritesDone(); });
+ }
+
+ private:
+ std::vector<double> last_issue_;
+
+ bool InitThreadFuncImpl(size_t thread_idx) override {
+ auto* stub = channels_[thread_idx % channels_.size()].get_stub();
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
stream_[thread_idx] = stub->StreamingFromClient(&context_[thread_idx],
&responses_[thread_idx]);
- last_issue_[thread_idx] = UsageTimer::Now();
- }
- }
- ~SynchronousStreamingFromClientClient() {
- std::vector<std::thread> cleanup_threads;
- for (size_t i = 0; i < num_threads_; i++) {
- cleanup_threads.emplace_back([this, i]() {
- auto stream = &stream_[i];
- if (*stream) {
- (*stream)->WritesDone();
- }
- });
- }
- for (auto& th : cleanup_threads) {
- th.join();
+ } else {
+ return false;
}
+ last_issue_[thread_idx] = UsageTimer::Now();
+ return true;
}
- bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override {
+ bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
// Figure out how to make histogram sensible if this is rate-paced
if (!WaitToIssue(thread_idx)) {
return true;
@@ -266,28 +315,42 @@ class SynchronousStreamingFromClientClient final
stream_[thread_idx]->WritesDone();
FinishStream(entry, thread_idx);
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
- stream_[thread_idx] = stub->StreamingFromClient(&context_[thread_idx],
- &responses_[thread_idx]);
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
+ stream_[thread_idx] = stub->StreamingFromClient(&context_[thread_idx],
+ &responses_[thread_idx]);
+ } else {
+ stream_[thread_idx].reset();
+ return false;
+ }
return true;
}
-
- private:
- std::vector<double> last_issue_;
};
class SynchronousStreamingFromServerClient final
: public SynchronousStreamingClient<grpc::ClientReader<SimpleResponse>> {
public:
SynchronousStreamingFromServerClient(const ClientConfig& config)
- : SynchronousStreamingClient(config), last_recv_(num_threads_) {
- for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) {
- auto* stub = channels_[thread_idx % channels_.size()].get_stub();
+ : SynchronousStreamingClient(config), last_recv_(num_threads_) {}
+ ~SynchronousStreamingFromServerClient() {}
+
+ private:
+ std::vector<double> last_recv_;
+
+ bool InitThreadFuncImpl(size_t thread_idx) override {
+ auto* stub = channels_[thread_idx % channels_.size()].get_stub();
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
stream_[thread_idx] =
stub->StreamingFromServer(&context_[thread_idx], request_);
- last_recv_[thread_idx] = UsageTimer::Now();
+ } else {
+ return false;
}
+ last_recv_[thread_idx] = UsageTimer::Now();
+ return true;
}
- bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override {
+
+ bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
GPR_TIMER_SCOPE("SynchronousStreamingFromServerClient::ThreadFunc", 0);
if (stream_[thread_idx]->Read(&responses_[thread_idx])) {
double now = UsageTimer::Now();
@@ -297,13 +360,16 @@ class SynchronousStreamingFromServerClient final
}
FinishStream(entry, thread_idx);
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
- stream_[thread_idx] =
- stub->StreamingFromServer(&context_[thread_idx], request_);
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
+ stream_[thread_idx] =
+ stub->StreamingFromServer(&context_[thread_idx], request_);
+ } else {
+ stream_[thread_idx].reset();
+ return false;
+ }
return true;
}
-
- private:
- std::vector<double> last_recv_;
};
class SynchronousStreamingBothWaysClient final
@@ -311,34 +377,32 @@ class SynchronousStreamingBothWaysClient final
grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>> {
public:
SynchronousStreamingBothWaysClient(const ClientConfig& config)
- : SynchronousStreamingClient(config) {
- for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) {
- auto* stub = channels_[thread_idx % channels_.size()].get_stub();
- stream_[thread_idx] = stub->StreamingBothWays(&context_[thread_idx]);
- }
- }
+ : SynchronousStreamingClient(config) {}
~SynchronousStreamingBothWaysClient() {
- std::vector<std::thread> cleanup_threads;
- for (size_t i = 0; i < num_threads_; i++) {
- cleanup_threads.emplace_back([this, i]() {
- auto stream = &stream_[i];
- if (*stream) {
- (*stream)->WritesDone();
- }
- });
- }
- for (auto& th : cleanup_threads) {
- th.join();
+ CleanupAllStreams(
+ [this](size_t thread_idx) { stream_[thread_idx]->WritesDone(); });
+ }
+
+ private:
+ bool InitThreadFuncImpl(size_t thread_idx) override {
+ auto* stub = channels_[thread_idx % channels_.size()].get_stub();
+ std::lock_guard<std::mutex> l(stream_mu_[thread_idx]);
+ if (!shutdown_[thread_idx].val) {
+ stream_[thread_idx] = stub->StreamingBothWays(&context_[thread_idx]);
+ } else {
+ return false;
}
+ return true;
}
- bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override {
+ bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
// TODO (vjpai): Do this
return true;
}
};
std::unique_ptr<Client> CreateSynchronousClient(const ClientConfig& config) {
+ GPR_ASSERT(!config.use_coalesce_api()); // not supported yet.
switch (config.rpc_type()) {
case UNARY:
return std::unique_ptr<Client>(new SynchronousUnaryClient(config));
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 4458e389e7..a809a27e3c 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -31,21 +31,21 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/env.h"
-#include "src/proto/grpc/testing/services.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
+#include "test/cpp/qps/client.h"
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/histogram.h"
#include "test/cpp/qps/qps_worker.h"
#include "test/cpp/qps/stats.h"
#include "test/cpp/util/test_credentials_provider.h"
+using std::deque;
using std::list;
using std::thread;
using std::unique_ptr;
-using std::deque;
using std::vector;
namespace grpc {
@@ -63,11 +63,11 @@ static std::string get_host(const std::string& worker) {
}
static deque<string> get_workers(const string& env_name) {
+ deque<string> out;
char* env = gpr_getenv(env_name.c_str());
if (!env) {
env = gpr_strdup("");
}
- deque<string> out;
char* p = env;
if (strlen(env) != 0) {
for (;;) {
@@ -146,9 +146,8 @@ static void postprocess_scenario_result(ScenarioResult* result) {
result->mutable_summary()->set_server_cpu_usage(0);
} else {
auto server_cpu_usage =
- 100 -
- 100 * average(result->server_stats(), ServerIdleCpuTime) /
- average(result->server_stats(), ServerTotalCpuTime);
+ 100 - 100 * average(result->server_stats(), ServerIdleCpuTime) /
+ average(result->server_stats(), ServerTotalCpuTime);
result->mutable_summary()->set_server_cpu_usage(server_cpu_usage);
}
@@ -187,12 +186,17 @@ static void postprocess_scenario_result(ScenarioResult* result) {
client_queries_per_cpu_sec);
}
+std::vector<grpc::testing::Server*>* g_inproc_servers = nullptr;
+
std::unique_ptr<ScenarioResult> RunScenario(
const ClientConfig& initial_client_config, size_t num_clients,
const ServerConfig& initial_server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count,
const grpc::string& qps_server_target_override,
- const grpc::string& credential_type) {
+ const grpc::string& credential_type, bool run_inproc) {
+ if (run_inproc) {
+ g_inproc_servers = new std::vector<grpc::testing::Server*>;
+ }
// Log everything from the driver
gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
@@ -210,8 +214,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
ClientConfig result_client_config;
const ServerConfig result_server_config = initial_server_config;
- // Get client, server lists
- auto workers = get_workers("QPS_WORKERS");
+ // Get client, server lists; ignore if inproc test
+ auto workers = (!run_inproc) ? get_workers("QPS_WORKERS") : deque<string>();
ClientConfig client_config = initial_client_config;
// Spawn some local workers if desired
@@ -227,9 +231,10 @@ std::unique_ptr<ScenarioResult> RunScenario(
called_init = true;
}
- int driver_port = grpc_pick_unused_port_or_die();
- local_workers.emplace_back(new QpsWorker(driver_port, 0, credential_type));
char addr[256];
+ // we use port # of -1 to indicate inproc
+ int driver_port = (!run_inproc) ? grpc_pick_unused_port_or_die() : -1;
+ local_workers.emplace_back(new QpsWorker(driver_port, 0, credential_type));
sprintf(addr, "localhost:%d", driver_port);
if (spawn_local_worker_count < 0) {
workers.push_front(addr);
@@ -265,9 +270,14 @@ std::unique_ptr<ScenarioResult> RunScenario(
for (size_t i = 0; i < num_servers; i++) {
gpr_log(GPR_INFO, "Starting server on %s (worker #%" PRIuPTR ")",
workers[i].c_str(), i);
- servers[i].stub = WorkerService::NewStub(CreateChannel(
- workers[i], GetCredentialsProvider()->GetChannelCredentials(
- credential_type, &channel_args)));
+ if (!run_inproc) {
+ servers[i].stub = WorkerService::NewStub(CreateChannel(
+ workers[i], GetCredentialsProvider()->GetChannelCredentials(
+ credential_type, &channel_args)));
+ } else {
+ servers[i].stub = WorkerService::NewStub(
+ local_workers[i]->InProcessChannel(channel_args));
+ }
ServerConfig server_config = initial_server_config;
if (server_config.core_limit() != 0) {
@@ -289,6 +299,10 @@ std::unique_ptr<ScenarioResult> RunScenario(
// overriding the qps server target only works if there is 1 server
GPR_ASSERT(num_servers == 1);
client_config.add_server_targets(qps_server_target_override);
+ } else if (run_inproc) {
+ std::string cli_target(INPROC_NAME_PREFIX);
+ cli_target += std::to_string(i);
+ client_config.add_server_targets(cli_target);
} else {
std::string host;
char* cli_target;
@@ -312,9 +326,14 @@ std::unique_ptr<ScenarioResult> RunScenario(
const auto& worker = workers[i + num_servers];
gpr_log(GPR_INFO, "Starting client on %s (worker #%" PRIuPTR ")",
worker.c_str(), i + num_servers);
- clients[i].stub = WorkerService::NewStub(
- CreateChannel(worker, GetCredentialsProvider()->GetChannelCredentials(
- credential_type, &channel_args)));
+ if (!run_inproc) {
+ clients[i].stub = WorkerService::NewStub(
+ CreateChannel(worker, GetCredentialsProvider()->GetChannelCredentials(
+ credential_type, &channel_args)));
+ } else {
+ clients[i].stub = WorkerService::NewStub(
+ local_workers[i + num_servers]->InProcessChannel(channel_args));
+ }
ClientConfig per_client_config = client_config;
if (initial_client_config.core_limit() != 0) {
@@ -495,6 +514,9 @@ std::unique_ptr<ScenarioResult> RunScenario(
}
}
+ if (g_inproc_servers != nullptr) {
+ delete g_inproc_servers;
+ }
postprocess_scenario_result(result.get());
return result;
}
diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h
index 29f2776d79..fede4d8045 100644
--- a/test/cpp/qps/driver.h
+++ b/test/cpp/qps/driver.h
@@ -32,7 +32,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
const grpc::testing::ServerConfig& server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count,
const grpc::string& qps_server_target_override,
- const grpc::string& credential_type);
+ const grpc::string& credential_type, bool run_inproc);
bool RunQuit(const grpc::string& credential_type);
} // namespace testing
diff --git a/test/cpp/qps/gen_build_yaml.py b/test/cpp/qps/gen_build_yaml.py
index a3ccbcf576..bd40d0a5a2 100755
--- a/test/cpp/qps/gen_build_yaml.py
+++ b/test/cpp/qps/gen_build_yaml.py
@@ -77,28 +77,50 @@ print yaml.dump({
'defaults': 'boringssl',
'cpu_cost': guess_cpu(scenario_json, False),
'exclude_configs': ['tsan', 'asan'],
- 'timeout_seconds': 6*60,
- 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', [])
+ 'timeout_seconds': 2*60,
+ 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
+ 'auto_timeout_scaling': False
}
for scenario_json in scenario_config.CXXLanguage().scenarios()
if 'scalable' in scenario_json.get('CATEGORIES', [])
] + [
{
- 'name': 'json_run_localhost',
- 'shortname': 'json_run_localhost:%s_low_thread_count' % scenario_json['name'],
- 'args': ['--scenarios_json', _scenario_json_string(scenario_json, True)],
+ 'name': 'qps_json_driver',
+ 'shortname': 'qps_json_driver:inproc_%s' % scenario_json['name'],
+ 'args': ['--run_inproc', '--scenarios_json', _scenario_json_string(scenario_json, False)],
'ci_platforms': ['linux'],
'platforms': ['linux'],
'flaky': False,
'language': 'c++',
'boringssl': True,
'defaults': 'boringssl',
- 'cpu_cost': guess_cpu(scenario_json, True),
- 'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')),
+ 'cpu_cost': guess_cpu(scenario_json, False),
+ 'exclude_configs': ['tsan', 'asan'],
'timeout_seconds': 6*60,
'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', [])
- }
+ }
for scenario_json in scenario_config.CXXLanguage().scenarios()
- if 'scalable' in scenario_json.get('CATEGORIES', [])
+ if 'inproc' in scenario_json.get('CATEGORIES', [])
]
+ # Disabled until https://github.com/grpc/grpc/issues/13122 is resolved.
+ # + [
+ # {
+ # 'name': 'json_run_localhost',
+ # 'shortname': 'json_run_localhost:%s_low_thread_count' % scenario_json['name'],
+ # 'args': ['--scenarios_json', _scenario_json_string(scenario_json, True)],
+ # 'ci_platforms': ['linux'],
+ # 'platforms': ['linux'],
+ # 'flaky': False,
+ # 'language': 'c++',
+ # 'boringssl': True,
+ # 'defaults': 'boringssl',
+ # 'cpu_cost': guess_cpu(scenario_json, True),
+ # 'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')),
+ # 'timeout_seconds': 10*60,
+ # 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
+ # 'auto_timeout_scaling': False
+ # }
+ # for scenario_json in scenario_config.CXXLanguage().scenarios()
+ # if 'scalable' in scenario_json.get('CATEGORIES', [])
+ # ]
})
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index 3d04ee57da..ba72b5b332 100644
--- a/test/cpp/qps/histogram.h
+++ b/test/cpp/qps/histogram.h
@@ -19,8 +19,8 @@
#ifndef TEST_QPS_HISTOGRAM_H
#define TEST_QPS_HISTOGRAM_H
-#include <grpc/support/histogram.h>
#include "src/proto/grpc/testing/stats.pb.h"
+#include "test/core/util/histogram.h"
namespace grpc {
namespace testing {
@@ -29,36 +29,36 @@ class Histogram {
public:
// TODO: look into making histogram params not hardcoded for C++
Histogram()
- : impl_(gpr_histogram_create(default_resolution(),
- default_max_possible())) {}
+ : impl_(grpc_histogram_create(default_resolution(),
+ default_max_possible())) {}
~Histogram() {
- if (impl_) gpr_histogram_destroy(impl_);
+ if (impl_) grpc_histogram_destroy(impl_);
}
Histogram(Histogram&& other) : impl_(other.impl_) { other.impl_ = nullptr; }
- void Merge(const Histogram& h) { gpr_histogram_merge(impl_, h.impl_); }
- void Add(double value) { gpr_histogram_add(impl_, value); }
+ void Merge(const Histogram& h) { grpc_histogram_merge(impl_, h.impl_); }
+ void Add(double value) { grpc_histogram_add(impl_, value); }
double Percentile(double pctile) const {
- return gpr_histogram_percentile(impl_, pctile);
+ return grpc_histogram_percentile(impl_, pctile);
}
- double Count() const { return gpr_histogram_count(impl_); }
+ double Count() const { return grpc_histogram_count(impl_); }
void Swap(Histogram* other) { std::swap(impl_, other->impl_); }
void FillProto(HistogramData* p) {
size_t n;
- const auto* data = gpr_histogram_get_contents(impl_, &n);
+ const auto* data = grpc_histogram_get_contents(impl_, &n);
for (size_t i = 0; i < n; i++) {
p->add_bucket(data[i]);
}
- p->set_min_seen(gpr_histogram_minimum(impl_));
- p->set_max_seen(gpr_histogram_maximum(impl_));
- p->set_sum(gpr_histogram_sum(impl_));
- p->set_sum_of_squares(gpr_histogram_sum_of_squares(impl_));
- p->set_count(gpr_histogram_count(impl_));
+ p->set_min_seen(grpc_histogram_minimum(impl_));
+ p->set_max_seen(grpc_histogram_maximum(impl_));
+ p->set_sum(grpc_histogram_sum(impl_));
+ p->set_sum_of_squares(grpc_histogram_sum_of_squares(impl_));
+ p->set_count(grpc_histogram_count(impl_));
}
void MergeProto(const HistogramData& p) {
- gpr_histogram_merge_contents(impl_, &*p.bucket().begin(), p.bucket_size(),
- p.min_seen(), p.max_seen(), p.sum(),
- p.sum_of_squares(), p.count());
+ grpc_histogram_merge_contents(impl_, &*p.bucket().begin(), p.bucket_size(),
+ p.min_seen(), p.max_seen(), p.sum(),
+ p.sum_of_squares(), p.count());
}
static double default_resolution() { return 0.01; }
@@ -68,9 +68,9 @@ class Histogram {
Histogram(const Histogram&);
Histogram& operator=(const Histogram&);
- gpr_histogram* impl_;
+ grpc_histogram* impl_;
};
-}
-}
+} // namespace testing
+} // namespace grpc
#endif /* TEST_QPS_HISTOGRAM_H */
diff --git a/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc b/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
new file mode 100644
index 0000000000..f2e977d48b
--- /dev/null
+++ b/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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 <set>
+
+#include <grpc/support/log.h>
+
+#include "test/cpp/qps/benchmark_config.h"
+#include "test/cpp/qps/driver.h"
+#include "test/cpp/qps/report.h"
+#include "test/cpp/qps/server.h"
+#include "test/cpp/util/test_config.h"
+#include "test/cpp/util/test_credentials_provider.h"
+
+namespace grpc {
+namespace testing {
+
+static const int WARMUP = 5;
+static const int BENCHMARK = 5;
+
+static void RunSynchronousUnaryPingPong() {
+ gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong");
+
+ ClientConfig client_config;
+ client_config.set_client_type(SYNC_CLIENT);
+ client_config.set_outstanding_rpcs_per_channel(1);
+ client_config.set_client_channels(1);
+ client_config.set_rpc_type(UNARY);
+ client_config.mutable_load_params()->mutable_closed_loop();
+
+ ServerConfig server_config;
+ server_config.set_server_type(SYNC_SERVER);
+
+ const auto result =
+ RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
+ kInsecureCredentialsType, true);
+
+ GetReporter()->ReportQPS(*result);
+ GetReporter()->ReportLatency(*result);
+}
+
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc::testing::InitTest(&argc, &argv, true);
+
+ grpc::testing::RunSynchronousUnaryPingPong();
+
+ return 0;
+}
diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h
index 1fa310c209..9c48066c9c 100644
--- a/test/cpp/qps/interarrival.h
+++ b/test/cpp/qps/interarrival.h
@@ -102,7 +102,7 @@ class InterarrivalTimer {
std::vector<time_table::const_iterator> thread_posns_;
time_table random_table_;
};
-}
-}
+} // namespace testing
+} // namespace grpc
#endif
diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc
index 1d394b216f..948c3088e6 100644
--- a/test/cpp/qps/json_run_localhost.cc
+++ b/test/cpp/qps/json_run_localhost.cc
@@ -26,7 +26,7 @@
#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "test/core/util/port.h"
#include "test/cpp/util/subprocess.h"
@@ -46,7 +46,7 @@ std::string as_string(const T& val) {
static void sighandler(int sig) {
const int errno_saved = errno;
- if (g_driver != NULL) g_driver->Interrupt();
+ if (g_driver != nullptr) g_driver->Interrupt();
for (int i = 0; i < kNumWorkers; ++i) {
if (g_workers[i]) g_workers[i]->Interrupt();
}
@@ -58,8 +58,8 @@ static void register_sighandler() {
memset(&act, 0, sizeof(act));
act.sa_handler = sighandler;
- sigaction(SIGINT, &act, NULL);
- sigaction(SIGTERM, &act, NULL);
+ sigaction(SIGINT, &act, nullptr);
+ sigaction(SIGTERM, &act, nullptr);
}
static void LogStatus(int status, const char* label) {
@@ -117,8 +117,14 @@ int main(int argc, char** argv) {
}
}
- delete g_driver;
- g_driver = NULL;
- for (int i = 0; i < kNumWorkers; ++i) delete g_workers[i];
+ if (g_driver != nullptr) {
+ delete g_driver;
+ }
+ g_driver = nullptr;
+ for (int i = 0; i < kNumWorkers; ++i) {
+ if (g_workers[i] != nullptr) {
+ delete g_workers[i];
+ }
+ }
GPR_ASSERT(driver_join_status == 0);
}
diff --git a/test/cpp/qps/parse_json.cc b/test/cpp/qps/parse_json.cc
index 343e073f3f..a98ae394db 100644
--- a/test/cpp/qps/parse_json.cc
+++ b/test/cpp/qps/parse_json.cc
@@ -61,5 +61,5 @@ grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg,
return json_string;
}
-} // testing
-} // grpc
+} // namespace testing
+} // namespace grpc
diff --git a/test/cpp/qps/parse_json.h b/test/cpp/qps/parse_json.h
index b320d26c1a..f2fffb52d4 100644
--- a/test/cpp/qps/parse_json.h
+++ b/test/cpp/qps/parse_json.h
@@ -31,7 +31,7 @@ void ParseJson(const grpc::string& json, const grpc::string& type,
grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg,
const grpc::string& type);
-} // testing
-} // grpc
+} // namespace testing
+} // namespace grpc
#endif // TEST_QPS_PARSE_JSON_H
diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc
index 87f09e8c5f..625b7db426 100644
--- a/test/cpp/qps/qps_interarrival_test.cc
+++ b/test/cpp/qps/qps_interarrival_test.cc
@@ -20,37 +20,37 @@
#include <iostream>
// Use the C histogram rather than C++ to avoid depending on proto
-#include <grpc/support/histogram.h>
+#include "test/core/util/histogram.h"
#include "test/cpp/qps/interarrival.h"
#include "test/cpp/util/test_config.h"
-using grpc::testing::RandomDistInterface;
using grpc::testing::InterarrivalTimer;
+using grpc::testing::RandomDistInterface;
-static void RunTest(RandomDistInterface &&r, int threads, std::string title) {
+static void RunTest(RandomDistInterface&& r, int threads, std::string title) {
InterarrivalTimer timer;
timer.init(r, threads);
- gpr_histogram *h(gpr_histogram_create(0.01, 60e9));
+ grpc_histogram* h(grpc_histogram_create(0.01, 60e9));
for (int i = 0; i < 10000000; i++) {
for (int j = 0; j < threads; j++) {
- gpr_histogram_add(h, timer.next(j));
+ grpc_histogram_add(h, timer.next(j));
}
}
std::cout << title << " Distribution" << std::endl;
std::cout << "Value, Percentile" << std::endl;
for (double pct = 0.0; pct < 100.0; pct += 1.0) {
- std::cout << gpr_histogram_percentile(h, pct) << "," << pct << std::endl;
+ std::cout << grpc_histogram_percentile(h, pct) << "," << pct << std::endl;
}
- gpr_histogram_destroy(h);
+ grpc_histogram_destroy(h);
}
using grpc::testing::ExpDist;
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
RunTest(ExpDist(10.0), 5, std::string("Exponential(10)"));
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index cca59f64d8..b2449da69c 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -30,6 +30,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/parse_json.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/qps/server.h"
#include "test/cpp/util/test_config.h"
#include "test/cpp/util/test_credentials_provider.h"
@@ -64,6 +65,7 @@ DEFINE_string(json_file_out, "", "File to write the JSON output to.");
DEFINE_string(credential_type, grpc::testing::kInsecureCredentialsType,
"Credential type for communication with workers");
+DEFINE_bool(run_inproc, false, "Perform an in-process transport test");
namespace grpc {
namespace testing {
@@ -75,8 +77,9 @@ static std::unique_ptr<ScenarioResult> RunAndReport(const Scenario& scenario,
RunScenario(scenario.client_config(), scenario.num_clients(),
scenario.server_config(), scenario.num_servers(),
scenario.warmup_seconds(), scenario.benchmark_seconds(),
- scenario.spawn_local_worker_count(),
- FLAGS_qps_server_target_override, FLAGS_credential_type);
+ !FLAGS_run_inproc ? scenario.spawn_local_worker_count() : -2,
+ FLAGS_qps_server_target_override, FLAGS_credential_type,
+ FLAGS_run_inproc);
// Amend the result with scenario config. Eventually we should adjust
// RunScenario contract so we don't need to touch the result here.
@@ -178,7 +181,7 @@ static bool QpsDriver() {
if (scfile) {
// Read the json data from disk
FILE* json_file = fopen(FLAGS_scenarios_file.c_str(), "r");
- GPR_ASSERT(json_file != NULL);
+ GPR_ASSERT(json_file != nullptr);
fseek(json_file, 0, SEEK_END);
long len = ftell(json_file);
char* data = new char[len];
diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc
index 069b3fa076..df929b9811 100644
--- a/test/cpp/qps/qps_openloop_test.cc
+++ b/test/cpp/qps/qps_openloop_test.cc
@@ -24,6 +24,7 @@
#include "test/cpp/qps/benchmark_config.h"
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/qps/server.h"
#include "test/cpp/util/test_config.h"
#include "test/cpp/util/test_credentials_provider.h"
@@ -49,8 +50,9 @@ static void RunQPS() {
server_config.set_server_type(ASYNC_SERVER);
server_config.set_async_server_threads(8);
- const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP,
- BENCHMARK, -2, "", kInsecureCredentialsType);
+ const auto result =
+ RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
+ kInsecureCredentialsType, false);
GetReporter()->ReportQPSPerCore(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc
index d20bc1b074..4c9ab0ea43 100644
--- a/test/cpp/qps/qps_worker.cc
+++ b/test/cpp/qps/qps_worker.cc
@@ -32,12 +32,12 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include "src/proto/grpc/testing/services.pb.h"
#include "test/core/util/grpc_profiler.h"
+#include "test/core/util/histogram.h"
#include "test/cpp/qps/client.h"
#include "test/cpp/qps/server.h"
#include "test/cpp/util/create_test_channel.h"
@@ -225,11 +225,14 @@ class WorkerServiceImpl final : public WorkerService::Service {
if (!args.has_setup()) {
return Status(StatusCode::INVALID_ARGUMENT, "Bad server creation args");
}
- if (server_port_ != 0) {
+ if (server_port_ > 0) {
args.mutable_setup()->set_port(server_port_);
}
gpr_log(GPR_INFO, "RunServerBody: about to create server");
auto server = CreateServer(args.setup());
+ if (g_inproc_servers != nullptr) {
+ g_inproc_servers->push_back(server.get());
+ }
if (!server) {
return Status(StatusCode::INVALID_ARGUMENT, "Couldn't create server");
}
@@ -269,17 +272,17 @@ QpsWorker::QpsWorker(int driver_port, int server_port,
impl_.reset(new WorkerServiceImpl(server_port, this));
gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0));
- char* server_address = NULL;
- gpr_join_host_port(&server_address, "::", driver_port);
-
ServerBuilder builder;
- builder.AddListeningPort(
- server_address,
- GetCredentialsProvider()->GetServerCredentials(credential_type));
+ if (driver_port >= 0) {
+ char* server_address = nullptr;
+ gpr_join_host_port(&server_address, "::", driver_port);
+ builder.AddListeningPort(
+ server_address,
+ GetCredentialsProvider()->GetServerCredentials(credential_type));
+ gpr_free(server_address);
+ }
builder.RegisterService(impl_.get());
- gpr_free(server_address);
-
server_ = builder.BuildAndStart();
}
diff --git a/test/cpp/qps/qps_worker.h b/test/cpp/qps/qps_worker.h
index 360125fb17..a5167426d0 100644
--- a/test/cpp/qps/qps_worker.h
+++ b/test/cpp/qps/qps_worker.h
@@ -21,17 +21,21 @@
#include <memory>
+#include <grpc++/server.h>
+#include <grpc++/support/channel_arguments.h>
#include <grpc++/support/config.h>
#include <grpc/support/atm.h>
-namespace grpc {
+#include "test/cpp/qps/server.h"
-class Server;
+namespace grpc {
namespace testing {
class WorkerServiceImpl;
+extern std::vector<grpc::testing::Server*>* g_inproc_servers;
+
class QpsWorker {
public:
explicit QpsWorker(int driver_port, int server_port,
@@ -41,9 +45,13 @@ class QpsWorker {
bool Done() const;
void MarkDone();
+ std::shared_ptr<Channel> InProcessChannel(const ChannelArguments& args) {
+ return server_->InProcessChannel(args);
+ }
+
private:
std::unique_ptr<WorkerServiceImpl> impl_;
- std::unique_ptr<Server> server_;
+ std::unique_ptr<grpc::Server> server_;
gpr_atm done_;
};
diff --git a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
index 137b33ee25..bb415e9d63 100644
--- a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
@@ -23,6 +23,7 @@
#include "test/cpp/qps/benchmark_config.h"
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
+#include "test/cpp/qps/server.h"
#include "test/cpp/util/test_config.h"
#include "test/cpp/util/test_credentials_provider.h"
@@ -52,8 +53,9 @@ static void RunSynchronousUnaryPingPong() {
client_config.mutable_security_params()->CopyFrom(security);
server_config.mutable_security_params()->CopyFrom(security);
- const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP,
- BENCHMARK, -2, "", kInsecureCredentialsType);
+ const auto result =
+ RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
+ kInsecureCredentialsType, false);
GetReporter()->ReportQPS(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 16d101d5e6..9da33566dd 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -42,10 +42,9 @@ class Server {
explicit Server(const ServerConfig& config)
: timer_(new UsageTimer), last_reset_poll_count_(0) {
cores_ = gpr_cpu_num_cores();
- if (config.port()) {
+ if (config.port()) { // positive for a fixed port, negative for inproc
port_ = config.port();
-
- } else {
+ } else { // zero for dynamic port
port_ = grpc_pick_unused_port_or_die();
}
}
@@ -115,6 +114,9 @@ class Server {
return 0;
}
+ virtual std::shared_ptr<Channel> InProcessChannel(
+ const ChannelArguments& args) = 0;
+
protected:
static void ApplyConfigToBuilder(const ServerConfig& config,
ServerBuilder* builder) {
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 4a82f98199..72ae772147 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -48,40 +48,43 @@ template <class RequestType, class ResponseType, class ServiceType,
class AsyncQpsServerTest final : public grpc::testing::Server {
public:
AsyncQpsServerTest(
- const ServerConfig &config,
- std::function<void(ServerBuilder *, ServiceType *)> register_service,
- std::function<void(ServiceType *, ServerContextType *, RequestType *,
- ServerAsyncResponseWriter<ResponseType> *,
- CompletionQueue *, ServerCompletionQueue *, void *)>
+ const ServerConfig& config,
+ std::function<void(ServerBuilder*, ServiceType*)> register_service,
+ std::function<void(ServiceType*, ServerContextType*, RequestType*,
+ ServerAsyncResponseWriter<ResponseType>*,
+ CompletionQueue*, ServerCompletionQueue*, void*)>
request_unary_function,
- std::function<void(ServiceType *, ServerContextType *,
- ServerAsyncReaderWriter<ResponseType, RequestType> *,
- CompletionQueue *, ServerCompletionQueue *, void *)>
+ std::function<void(ServiceType*, ServerContextType*,
+ ServerAsyncReaderWriter<ResponseType, RequestType>*,
+ CompletionQueue*, ServerCompletionQueue*, void*)>
request_streaming_function,
- std::function<void(ServiceType *, ServerContextType *,
- ServerAsyncReader<ResponseType, RequestType> *,
- CompletionQueue *, ServerCompletionQueue *, void *)>
+ std::function<void(ServiceType*, ServerContextType*,
+ ServerAsyncReader<ResponseType, RequestType>*,
+ CompletionQueue*, ServerCompletionQueue*, void*)>
request_streaming_from_client_function,
- std::function<void(ServiceType *, ServerContextType *, RequestType *,
- ServerAsyncWriter<ResponseType> *, CompletionQueue *,
- ServerCompletionQueue *, void *)>
+ std::function<void(ServiceType*, ServerContextType*, RequestType*,
+ ServerAsyncWriter<ResponseType>*, CompletionQueue*,
+ ServerCompletionQueue*, void*)>
request_streaming_from_server_function,
- std::function<void(ServiceType *, ServerContextType *,
- ServerAsyncReaderWriter<ResponseType, RequestType> *,
- CompletionQueue *, ServerCompletionQueue *, void *)>
+ std::function<void(ServiceType*, ServerContextType*,
+ ServerAsyncReaderWriter<ResponseType, RequestType>*,
+ CompletionQueue*, ServerCompletionQueue*, void*)>
request_streaming_both_ways_function,
- std::function<grpc::Status(const PayloadConfig &, const RequestType *,
- ResponseType *)>
+ std::function<grpc::Status(const PayloadConfig&, RequestType*,
+ ResponseType*)>
process_rpc)
: Server(config) {
- char *server_address = NULL;
-
- gpr_join_host_port(&server_address, "::", port());
-
ServerBuilder builder;
- builder.AddListeningPort(server_address,
- Server::CreateServerCredentials(config));
- gpr_free(server_address);
+
+ auto port_num = port();
+ // Negative port number means inproc server, so no listen port needed
+ if (port_num >= 0) {
+ char* server_address = nullptr;
+ gpr_join_host_port(&server_address, "::", port_num);
+ builder.AddListeningPort(server_address,
+ Server::CreateServerCredentials(config));
+ gpr_free(server_address);
+ }
register_service(&builder, &async_service_);
@@ -168,7 +171,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
}
for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); ++cq) {
bool ok;
- void *got_tag;
+ void* got_tag;
while ((*cq)->Next(&got_tag, &ok))
;
}
@@ -183,6 +186,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
return count;
}
+ std::shared_ptr<Channel> InProcessChannel(
+ const ChannelArguments& args) override {
+ return server_->InProcessChannel(args);
+ }
+
private:
void ShutdownThreadFunc() {
// TODO (vpai): Remove this deadline and allow Shutdown to finish properly
@@ -193,24 +201,32 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
void ThreadFunc(int thread_idx) {
// Wait until work is available or we are shutting down
bool ok;
- void *got_tag;
- while (srv_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) {
- ServerRpcContext *ctx = detag(got_tag);
+ void* got_tag;
+ if (!srv_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) {
+ return;
+ }
+ ServerRpcContext* ctx;
+ std::mutex* mu_ptr = &shutdown_state_[thread_idx]->mutex;
+ do {
+ ctx = detag(got_tag);
// The tag is a pointer to an RPC context to invoke
// Proceed while holding a lock to make sure that
// this thread isn't supposed to shut down
- std::lock_guard<std::mutex> l(shutdown_state_[thread_idx]->mutex);
+ mu_ptr->lock();
if (shutdown_state_[thread_idx]->shutdown) {
+ mu_ptr->unlock();
return;
}
- std::lock_guard<ServerRpcContext> l2(*ctx);
- const bool still_going = ctx->RunNextState(ok);
- // if this RPC context is done, refresh it
- if (!still_going) {
- ctx->Reset();
- }
- }
- return;
+ } while (srv_cqs_[cq_[thread_idx]]->DoThenAsyncNext(
+ [&, ctx, ok, mu_ptr]() {
+ ctx->lock();
+ if (!ctx->RunNextState(ok)) {
+ ctx->Reset();
+ }
+ ctx->unlock();
+ mu_ptr->unlock();
+ },
+ &got_tag, &ok, gpr_inf_future(GPR_CLOCK_REALTIME)));
}
class ServerRpcContext {
@@ -224,22 +240,21 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
private:
std::mutex mu_;
};
- static void *tag(ServerRpcContext *func) {
- return reinterpret_cast<void *>(func);
+ static void* tag(ServerRpcContext* func) {
+ return reinterpret_cast<void*>(func);
}
- static ServerRpcContext *detag(void *tag) {
- return reinterpret_cast<ServerRpcContext *>(tag);
+ static ServerRpcContext* detag(void* tag) {
+ return reinterpret_cast<ServerRpcContext*>(tag);
}
class ServerRpcContextUnaryImpl final : public ServerRpcContext {
public:
ServerRpcContextUnaryImpl(
- std::function<void(ServerContextType *, RequestType *,
- grpc::ServerAsyncResponseWriter<ResponseType> *,
- void *)>
+ std::function<void(ServerContextType*, RequestType*,
+ grpc::ServerAsyncResponseWriter<ResponseType>*,
+ void*)>
request_method,
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method)
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method)
: srv_ctx_(new ServerContextType),
next_state_(&ServerRpcContextUnaryImpl::invoker),
request_method_(request_method),
@@ -281,11 +296,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
RequestType req_;
ResponseType response_;
bool (ServerRpcContextUnaryImpl::*next_state_)(bool);
- std::function<void(ServerContextType *, RequestType *,
- grpc::ServerAsyncResponseWriter<ResponseType> *, void *)>
+ std::function<void(ServerContextType*, RequestType*,
+ grpc::ServerAsyncResponseWriter<ResponseType>*, void*)>
request_method_;
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method_;
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_;
grpc::ServerAsyncResponseWriter<ResponseType> response_writer_;
};
@@ -293,11 +307,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
public:
ServerRpcContextStreamingImpl(
std::function<void(
- ServerContextType *,
- grpc::ServerAsyncReaderWriter<ResponseType, RequestType> *, void *)>
+ ServerContextType*,
+ grpc::ServerAsyncReaderWriter<ResponseType, RequestType>*, void*)>
request_method,
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method)
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method)
: srv_ctx_(new ServerContextType),
next_state_(&ServerRpcContextStreamingImpl::request_done),
request_method_(request_method),
@@ -361,11 +374,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
ResponseType response_;
bool (ServerRpcContextStreamingImpl::*next_state_)(bool);
std::function<void(
- ServerContextType *,
- grpc::ServerAsyncReaderWriter<ResponseType, RequestType> *, void *)>
+ ServerContextType*,
+ grpc::ServerAsyncReaderWriter<ResponseType, RequestType>*, void*)>
request_method_;
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method_;
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_;
grpc::ServerAsyncReaderWriter<ResponseType, RequestType> stream_;
};
@@ -373,12 +385,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
: public ServerRpcContext {
public:
ServerRpcContextStreamingFromClientImpl(
- std::function<void(ServerContextType *,
- grpc::ServerAsyncReader<ResponseType, RequestType> *,
- void *)>
+ std::function<void(ServerContextType*,
+ grpc::ServerAsyncReader<ResponseType, RequestType>*,
+ void*)>
request_method,
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method)
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method)
: srv_ctx_(new ServerContextType),
next_state_(&ServerRpcContextStreamingFromClientImpl::request_done),
request_method_(request_method),
@@ -431,12 +442,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
RequestType req_;
ResponseType response_;
bool (ServerRpcContextStreamingFromClientImpl::*next_state_)(bool);
- std::function<void(ServerContextType *,
- grpc::ServerAsyncReader<ResponseType, RequestType> *,
- void *)>
+ std::function<void(ServerContextType*,
+ grpc::ServerAsyncReader<ResponseType, RequestType>*,
+ void*)>
request_method_;
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method_;
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_;
grpc::ServerAsyncReader<ResponseType, RequestType> stream_;
};
@@ -444,11 +454,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
: public ServerRpcContext {
public:
ServerRpcContextStreamingFromServerImpl(
- std::function<void(ServerContextType *, RequestType *,
- grpc::ServerAsyncWriter<ResponseType> *, void *)>
+ std::function<void(ServerContextType*, RequestType*,
+ grpc::ServerAsyncWriter<ResponseType>*, void*)>
request_method,
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method)
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method)
: srv_ctx_(new ServerContextType),
next_state_(&ServerRpcContextStreamingFromServerImpl::request_done),
request_method_(request_method),
@@ -501,11 +510,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
RequestType req_;
ResponseType response_;
bool (ServerRpcContextStreamingFromServerImpl::*next_state_)(bool);
- std::function<void(ServerContextType *, RequestType *,
- grpc::ServerAsyncWriter<ResponseType> *, void *)>
+ std::function<void(ServerContextType*, RequestType*,
+ grpc::ServerAsyncWriter<ResponseType>*, void*)>
request_method_;
- std::function<grpc::Status(const RequestType *, ResponseType *)>
- invoke_method_;
+ std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_;
grpc::ServerAsyncWriter<ResponseType> stream_;
};
@@ -525,30 +533,34 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
std::vector<std::unique_ptr<PerThreadShutdownState>> shutdown_state_;
};
-static void RegisterBenchmarkService(ServerBuilder *builder,
- BenchmarkService::AsyncService *service) {
+static void RegisterBenchmarkService(ServerBuilder* builder,
+ BenchmarkService::AsyncService* service) {
builder->RegisterService(service);
}
-static void RegisterGenericService(ServerBuilder *builder,
- grpc::AsyncGenericService *service) {
+static void RegisterGenericService(ServerBuilder* builder,
+ grpc::AsyncGenericService* service) {
builder->RegisterAsyncGenericService(service);
}
-static Status ProcessSimpleRPC(const PayloadConfig &,
- const SimpleRequest *request,
- SimpleResponse *response) {
+static Status ProcessSimpleRPC(const PayloadConfig&, SimpleRequest* request,
+ SimpleResponse* response) {
if (request->response_size() > 0) {
if (!Server::SetPayload(request->response_type(), request->response_size(),
response->mutable_payload())) {
return Status(grpc::StatusCode::INTERNAL, "Error creating payload.");
}
}
+ // We are done using the request. Clear it to reduce working memory.
+ // This proves to reduce cache misses in large message size cases.
+ request->Clear();
return Status::OK;
}
-static Status ProcessGenericRPC(const PayloadConfig &payload_config,
- const ByteBuffer *request,
- ByteBuffer *response) {
+static Status ProcessGenericRPC(const PayloadConfig& payload_config,
+ ByteBuffer* request, ByteBuffer* response) {
+ // We are done using the request. Clear it to reduce working memory.
+ // This proves to reduce cache misses in large message size cases.
+ request->Clear();
int resp_size = payload_config.bytebuf_params().resp_size();
std::unique_ptr<char[]> buf(new char[resp_size]);
Slice slice(buf.get(), resp_size);
@@ -556,7 +568,7 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config,
return Status::OK;
}
-std::unique_ptr<Server> CreateAsyncServer(const ServerConfig &config) {
+std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config) {
return std::unique_ptr<Server>(
new AsyncQpsServerTest<SimpleRequest, SimpleResponse,
BenchmarkService::AsyncService,
@@ -569,7 +581,7 @@ std::unique_ptr<Server> CreateAsyncServer(const ServerConfig &config) {
&BenchmarkService::AsyncService::RequestStreamingBothWays,
ProcessSimpleRPC));
}
-std::unique_ptr<Server> CreateAsyncGenericServer(const ServerConfig &config) {
+std::unique_ptr<Server> CreateAsyncGenericServer(const ServerConfig& config) {
return std::unique_ptr<Server>(
new AsyncQpsServerTest<ByteBuffer, ByteBuffer, grpc::AsyncGenericService,
grpc::GenericServerContext>(
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index 9954e2c0bf..ea89a30e2e 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -156,12 +156,15 @@ class SynchronousServer final : public grpc::testing::Server {
explicit SynchronousServer(const ServerConfig& config) : Server(config) {
ServerBuilder builder;
- char* server_address = NULL;
-
- gpr_join_host_port(&server_address, "::", port());
- builder.AddListeningPort(server_address,
- Server::CreateServerCredentials(config));
- gpr_free(server_address);
+ auto port_num = port();
+ // Negative port number means inproc server, so no listen port needed
+ if (port_num >= 0) {
+ char* server_address = nullptr;
+ gpr_join_host_port(&server_address, "::", port_num);
+ builder.AddListeningPort(server_address,
+ Server::CreateServerCredentials(config));
+ gpr_free(server_address);
+ }
ApplyConfigToBuilder(config, &builder);
@@ -170,6 +173,11 @@ class SynchronousServer final : public grpc::testing::Server {
impl_ = builder.BuildAndStart();
}
+ std::shared_ptr<Channel> InProcessChannel(
+ const ChannelArguments& args) override {
+ return impl_->InProcessChannel(args);
+ }
+
private:
BenchmarkServiceImpl service_;
std::unique_ptr<grpc::Server> impl_;
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index 27010b7315..38287464d9 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -20,6 +20,7 @@
#include <chrono>
#include <thread>
+#include <vector>
#include <gflags/gflags.h>
#include <grpc/grpc.h>
@@ -41,6 +42,8 @@ static void sigint_handler(int x) { got_sigint = true; }
namespace grpc {
namespace testing {
+std::vector<grpc::testing::Server*>* g_inproc_servers = nullptr;
+
static void RunServer() {
QpsWorker worker(FLAGS_driver_port, FLAGS_server_port, FLAGS_credential_type);
diff --git a/test/cpp/server/server_builder_test.cc b/test/cpp/server/server_builder_test.cc
index d18459cec9..694ce549c0 100644
--- a/test/cpp/server/server_builder_test.cc
+++ b/test/cpp/server/server_builder_test.cc
@@ -22,6 +22,8 @@
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
+#include <grpc/grpc.h>
+
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@@ -77,5 +79,8 @@ TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ grpc_init();
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
}
diff --git a/test/cpp/test/server_context_test_spouse_test.cc b/test/cpp/test/server_context_test_spouse_test.cc
index c1ddb0019b..d1dc9d7cac 100644
--- a/test/cpp/test/server_context_test_spouse_test.cc
+++ b/test/cpp/test/server_context_test_spouse_test.cc
@@ -87,7 +87,7 @@ TEST(ServerContextTestSpouseTest, TrailingMetadata) {
ASSERT_EQ(metadata, spouse.GetTrailingMetadata());
}
-} // namespace
+} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc
index 85e58f466e..8282d46694 100644
--- a/test/cpp/thread_manager/thread_manager_test.cc
+++ b/test/cpp/thread_manager/thread_manager_test.cc
@@ -37,8 +37,8 @@ class ThreadManagerTest final : public grpc::ThreadManager {
num_poll_for_work_(0),
num_work_found_(0) {}
- grpc::ThreadManager::WorkStatus PollForWork(void **tag, bool *ok) override;
- void DoWork(void *tag, bool ok) override;
+ grpc::ThreadManager::WorkStatus PollForWork(void** tag, bool* ok) override;
+ void DoWork(void* tag, bool ok) override;
void PerformTest();
private:
@@ -65,8 +65,8 @@ void ThreadManagerTest::SleepForMs(int duration_ms) {
gpr_sleep_until(sleep_time);
}
-grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void **tag,
- bool *ok) {
+grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void** tag,
+ bool* ok) {
int call_num = gpr_atm_no_barrier_fetch_add(&num_poll_for_work_, 1);
if (call_num >= kMaxNumPollForWork) {
@@ -89,7 +89,7 @@ grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void **tag,
}
}
-void ThreadManagerTest::DoWork(void *tag, bool ok) {
+void ThreadManagerTest::DoWork(void* tag, bool ok) {
gpr_atm_no_barrier_fetch_add(&num_do_work_, 1);
SleepForMs(kDoWorkDurationMsec); // Simulate doing work by sleeping
}
@@ -110,8 +110,8 @@ void ThreadManagerTest::PerformTest() {
}
} // namespace grpc
-int main(int argc, char **argv) {
- std::srand(std::time(NULL));
+int main(int argc, char** argv) {
+ std::srand(std::time(nullptr));
grpc::testing::InitTest(&argc, &argv, true);
grpc::ThreadManagerTest test_rpc_manager;
diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD
index 2559c18c32..19e15b1adf 100644
--- a/test/cpp/util/BUILD
+++ b/test/cpp/util/BUILD
@@ -43,6 +43,7 @@ grpc_cc_library(
"proto_reflection_descriptor_database.h",
],
deps = [
+ "//:grpc++",
"//:grpc++_config_proto",
"//src/proto/grpc/reflection/v1alpha:reflection_proto",
],
@@ -135,6 +136,105 @@ grpc_cc_library(
)
grpc_cc_test(
+ name = "grpc_tool_test",
+ srcs = [
+ "grpc_tool_test.cc",
+ ],
+ deps = [
+ ":grpc_cli_libs",
+ ":test_util",
+ "//:grpc++_reflection",
+ "//src/proto/grpc/testing:echo_proto",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//test/core/util:grpc_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "byte_buffer_test",
+ srcs = [
+ "byte_buffer_test.cc",
+ ],
+ deps = [
+ ":test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "slice_test",
+ srcs = [
+ "slice_test.cc",
+ ],
+ deps = [
+ ":test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "string_ref_test",
+ srcs = [
+ "string_ref_test.cc",
+ ],
+ deps = [
+ "//:grpc++",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "time_test",
+ srcs = [
+ "time_test.cc",
+ ],
+ deps = [
+ ":test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "status_test",
+ srcs = [
+ "status_test.cc",
+ ],
+ deps = [
+ ":test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "cli_call_test",
+ srcs = [
+ "cli_call_test.cc",
+ ],
+ deps = [
+ ":grpc_cli_libs",
+ ":test_util",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/core/util:grpc_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
name = "error_details_test",
srcs = [
"error_details_test.cc",
diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc
index 8fb51bc663..d603b289c8 100644
--- a/test/cpp/util/byte_buffer_test.cc
+++ b/test/cpp/util/byte_buffer_test.cc
@@ -22,6 +22,7 @@
#include <vector>
#include <grpc++/support/slice.h>
+#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <gtest/gtest.h>
@@ -109,5 +110,8 @@ TEST_F(ByteBufferTest, SerializationMakesCopy) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ grpc_init();
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
}
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index c3220efa54..4f1a20c727 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -126,7 +126,7 @@ void CliCall::WriteAndWait(const grpc::string& request) {
call_->Write(send_buffer, tag(2));
write_done_ = false;
while (!write_done_) {
- gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&write_mu_);
}
@@ -136,7 +136,7 @@ void CliCall::WritesDoneAndWait() {
call_->WritesDone(tag(4));
write_done_ = false;
while (!write_done_) {
- gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&write_mu_);
}
diff --git a/test/cpp/util/cli_credentials.cc b/test/cpp/util/cli_credentials.cc
index f1f43f8ae0..aa4eafb756 100644
--- a/test/cpp/util/cli_credentials.cc
+++ b/test/cpp/util/cli_credentials.cc
@@ -22,27 +22,43 @@
DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls.");
DEFINE_bool(use_auth, false, "Whether to create default google credentials.");
+DEFINE_string(
+ access_token, "",
+ "The access token that will be sent to the server to authenticate RPCs.");
namespace grpc {
namespace testing {
std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials()
const {
- if (!FLAGS_enable_ssl) {
- return grpc::InsecureChannelCredentials();
- } else {
+ if (!FLAGS_access_token.empty()) {
if (FLAGS_use_auth) {
- return grpc::GoogleDefaultCredentials();
- } else {
- return grpc::SslCredentials(grpc::SslCredentialsOptions());
+ fprintf(stderr,
+ "warning: use_auth is ignored when access_token is provided.");
}
+
+ return grpc::CompositeChannelCredentials(
+ grpc::SslCredentials(grpc::SslCredentialsOptions()),
+ grpc::AccessTokenCredentials(FLAGS_access_token));
+ }
+
+ if (FLAGS_use_auth) {
+ return grpc::GoogleDefaultCredentials();
}
+
+ if (FLAGS_enable_ssl) {
+ return grpc::SslCredentials(grpc::SslCredentialsOptions());
+ }
+
+ return grpc::InsecureChannelCredentials();
}
const grpc::string CliCredentials::GetCredentialUsage() const {
return " --enable_ssl ; Set whether to use tls\n"
" --use_auth ; Set whether to create default google"
- " credentials\n";
+ " credentials\n"
+ " --access_token ; Set the access token in metadata,"
+ " overrides --use_auth\n";
}
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index 34b6d60d01..4d047473b9 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -74,7 +74,7 @@ std::shared_ptr<Channel> CreateTestChannel(
ChannelArguments channel_args(args);
std::shared_ptr<ChannelCredentials> channel_creds;
if (cred_type.empty()) {
- return CreateChannel(server, InsecureChannelCredentials());
+ return CreateCustomChannel(server, InsecureChannelCredentials(), args);
} else if (cred_type == testing::kTlsCredentialsType) { // cred_type == "ssl"
if (use_prod_roots) {
gpr_once_init(&g_once_init_add_prod_ssl_provider, &AddProdSslType);
@@ -101,7 +101,7 @@ std::shared_ptr<Channel> CreateTestChannel(
cred_type, &channel_args);
GPR_ASSERT(channel_creds != nullptr);
- return CreateChannel(server, channel_creds);
+ return CreateCustomChannel(server, channel_creds, args);
}
}
diff --git a/test/cpp/util/error_details_test.cc b/test/cpp/util/error_details_test.cc
index 69a6876a3f..16a00fb201 100644
--- a/test/cpp/util/error_details_test.cc
+++ b/test/cpp/util/error_details_test.cc
@@ -82,7 +82,7 @@ TEST(SetTest, NullInput) {
TEST(SetTest, OutOfScopeErrorCode) {
google::rpc::Status expected;
- expected.set_code(20); // Out of scope (DATA_LOSS is 15).
+ expected.set_code(17); // Out of scope (UNAUTHENTICATED is 16).
expected.set_message("I am an error message");
testing::EchoRequest expected_details;
expected_details.set_message(grpc::string(100, '\0'));
@@ -96,6 +96,24 @@ TEST(SetTest, OutOfScopeErrorCode) {
EXPECT_EQ(expected.SerializeAsString(), to.error_details());
}
+TEST(SetTest, ValidScopeErrorCode) {
+ for (int c = StatusCode::OK; c <= StatusCode::UNAUTHENTICATED; c++) {
+ google::rpc::Status expected;
+ expected.set_code(c);
+ expected.set_message("I am an error message");
+ testing::EchoRequest expected_details;
+ expected_details.set_message(grpc::string(100, '\0'));
+ expected.add_details()->PackFrom(expected_details);
+
+ Status to;
+ Status s = SetErrorDetails(expected, &to);
+ EXPECT_TRUE(s.ok());
+ EXPECT_EQ(c, to.error_code());
+ EXPECT_EQ(expected.message(), to.error_message());
+ EXPECT_EQ(expected.SerializeAsString(), to.error_details());
+ }
+}
+
} // namespace
} // namespace grpc
diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index bb6f878020..30c43b206f 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -58,6 +58,11 @@ DEFINE_string(protofiles, "", "Name of the proto file.");
DEFINE_bool(binary_input, false, "Input in binary format");
DEFINE_bool(binary_output, false, "Output in binary format");
DEFINE_string(infile, "", "Input file (default is stdin)");
+DEFINE_bool(batch, false,
+ "Input contains multiple requests. Please do not use this to send "
+ "more than a few RPCs. gRPC CLI has very different performance "
+ "characteristics compared with normal RPC calls which make it "
+ "unsuitable for loadtesting or significant production traffic.");
namespace {
@@ -119,13 +124,32 @@ void ParseMetadataFlag(
return;
}
std::vector<grpc::string> fields;
- const char* delim = ":";
- size_t cur, next = -1;
- do {
- cur = next + 1;
- next = FLAGS_metadata.find_first_of(delim, cur);
- fields.push_back(FLAGS_metadata.substr(cur, next - cur));
- } while (next != grpc::string::npos);
+ const char delim = ':';
+ const char escape = '\\';
+ size_t cur = -1;
+ std::stringstream ss;
+ while (++cur < FLAGS_metadata.length()) {
+ switch (FLAGS_metadata.at(cur)) {
+ case escape:
+ if (cur < FLAGS_metadata.length() - 1) {
+ char c = FLAGS_metadata.at(++cur);
+ if (c == delim || c == escape) {
+ ss << c;
+ continue;
+ }
+ }
+ fprintf(stderr, "Failed to parse metadata flag.\n");
+ exit(1);
+ case delim:
+ fields.push_back(ss.str());
+ ss.str("");
+ ss.clear();
+ break;
+ default:
+ ss << FLAGS_metadata.at(cur);
+ }
+ }
+ fields.push_back(ss.str());
if (fields.size() % 2) {
fprintf(stderr, "Failed to parse metadata flag.\n");
exit(1);
@@ -225,7 +249,7 @@ const Command* FindCommand(const grpc::string& name) {
return &ops[i];
}
}
- return NULL;
+ return nullptr;
}
} // namespace
@@ -240,13 +264,13 @@ int GrpcToolMainLib(int argc, const char** argv, const CliCredentials& cred,
argv += 2;
const Command* cmd = FindCommand(command);
- if (cmd != NULL) {
+ if (cmd != nullptr) {
GrpcTool grpc_tool;
if (argc < cmd->min_args || argc > cmd->max_args) {
// Force the command to print its usage message
fprintf(stderr, "\nWrong number of arguments for %s\n", command.c_str());
grpc_tool.SetPrintCommandMode(1);
- return cmd->function(&grpc_tool, -1, NULL, cred, callback);
+ return cmd->function(&grpc_tool, -1, nullptr, cred, callback);
}
const bool ok = cmd->function(&grpc_tool, argc, argv, cred, callback);
return ok ? 0 : 1;
@@ -276,11 +300,11 @@ bool GrpcTool::Help(int argc, const char** argv, const CliCredentials& cred,
Usage("");
} else {
const Command* cmd = FindCommand(argv[0]);
- if (cmd == NULL) {
+ if (cmd == nullptr) {
Usage("Unknown command '" + grpc::string(argv[0]) + "'");
}
SetPrintCommandMode(0);
- cmd->function(this, -1, NULL, cred, callback);
+ cmd->function(this, -1, nullptr, cred, callback);
}
return true;
}
@@ -460,12 +484,17 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
return false;
}
+ if (argc == 3) {
+ request_text = argv[2];
+ }
+
if (parser->IsStreaming(method_name, true /* is_request */)) {
std::istream* input_stream;
std::ifstream input_file;
- if (argc == 3) {
- request_text = argv[2];
+ if (FLAGS_batch) {
+ fprintf(stderr, "Batch mode for streaming RPC is not supported.\n");
+ return false;
}
std::multimap<grpc::string, grpc::string> client_metadata;
@@ -549,8 +578,115 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
}
} else { // parser->IsStreaming(method_name, true /* is_request */)
+ if (FLAGS_batch) {
+ if (parser->IsStreaming(method_name, false /* is_request */)) {
+ fprintf(stderr, "Batch mode for streaming RPC is not supported.\n");
+ return false;
+ }
+
+ std::istream* input_stream;
+ std::ifstream input_file;
+
+ if (FLAGS_infile.empty()) {
+ if (isatty(fileno(stdin))) {
+ print_mode = true;
+ fprintf(stderr, "reading request messages from stdin...\n");
+ }
+ input_stream = &std::cin;
+ } else {
+ input_file.open(FLAGS_infile, std::ios::in | std::ios::binary);
+ input_stream = &input_file;
+ }
+
+ std::multimap<grpc::string, grpc::string> client_metadata;
+ ParseMetadataFlag(&client_metadata);
+ if (print_mode) {
+ PrintMetadata(client_metadata, "Sending client initial metadata:");
+ }
+
+ std::stringstream request_ss;
+ grpc::string line;
+ while (!request_text.empty() ||
+ (!input_stream->eof() && getline(*input_stream, line))) {
+ if (!request_text.empty()) {
+ if (FLAGS_binary_input) {
+ serialized_request_proto = request_text;
+ request_text.clear();
+ } else {
+ serialized_request_proto = parser->GetSerializedProtoFromMethod(
+ method_name, request_text, true /* is_request */);
+ request_text.clear();
+ if (parser->HasError()) {
+ if (print_mode) {
+ fprintf(stderr, "Failed to parse request.\n");
+ }
+ continue;
+ }
+ }
+
+ grpc::string serialized_response_proto;
+ std::multimap<grpc::string_ref, grpc::string_ref>
+ server_initial_metadata, server_trailing_metadata;
+ CliCall call(channel, formatted_method_name, client_metadata);
+ call.Write(serialized_request_proto);
+ call.WritesDone();
+ if (!call.Read(&serialized_response_proto,
+ &server_initial_metadata)) {
+ fprintf(stderr, "Failed to read response.\n");
+ }
+ Status status = call.Finish(&server_trailing_metadata);
+
+ if (status.ok()) {
+ if (print_mode) {
+ fprintf(stderr, "Rpc succeeded with OK status.\n");
+ PrintMetadata(server_initial_metadata,
+ "Received initial metadata from server:");
+ PrintMetadata(server_trailing_metadata,
+ "Received trailing metadata from server:");
+ }
+
+ if (FLAGS_binary_output) {
+ if (!callback(serialized_response_proto)) {
+ break;
+ }
+ } else {
+ grpc::string response_text = parser->GetTextFormatFromMethod(
+ method_name, serialized_response_proto,
+ false /* is_request */);
+ if (parser->HasError() && print_mode) {
+ fprintf(stderr, "Failed to parse response.\n");
+ } else {
+ if (!callback(response_text)) {
+ break;
+ }
+ }
+ }
+ } else {
+ if (print_mode) {
+ fprintf(stderr,
+ "Rpc failed with status code %d, error message: %s\n",
+ status.error_code(), status.error_message().c_str());
+ }
+ }
+ } else {
+ if (line.length() == 0) {
+ request_text = request_ss.str();
+ request_ss.str(grpc::string());
+ request_ss.clear();
+ } else {
+ request_ss << line << ' ';
+ }
+ }
+ }
+
+ if (input_file.is_open()) {
+ input_file.close();
+ }
+
+ return true;
+ }
+
if (argc == 3) {
- request_text = argv[2];
if (!FLAGS_infile.empty()) {
fprintf(stderr, "warning: request given in argv, ignoring --infile\n");
}
@@ -571,9 +707,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
if (FLAGS_binary_input) {
serialized_request_proto = request_text;
- // formatted_method_name = method_name;
} else {
- // formatted_method_name = parser->GetFormattedMethodName(method_name);
serialized_request_proto = parser->GetSerializedProtoFromMethod(
method_name, request_text, true /* is_request */);
if (parser->HasError()) {
diff --git a/test/cpp/util/grpc_tool.h b/test/cpp/util/grpc_tool.h
index 076ce530d9..a10422f882 100644
--- a/test/cpp/util/grpc_tool.h
+++ b/test/cpp/util/grpc_tool.h
@@ -28,9 +28,9 @@
namespace grpc {
namespace testing {
-typedef std::function<bool(const grpc::string &)> GrpcToolOutputCallback;
+typedef std::function<bool(const grpc::string&)> GrpcToolOutputCallback;
-int GrpcToolMainLib(int argc, const char **argv, const CliCredentials &cred,
+int GrpcToolMainLib(int argc, const char** argv, const CliCredentials& cred,
GrpcToolOutputCallback callback);
} // namespace testing
diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc
index dd00581f2b..0b599f4eeb 100644
--- a/test/cpp/util/grpc_tool_test.cc
+++ b/test/cpp/util/grpc_tool_test.cc
@@ -84,6 +84,9 @@ namespace testing {
DECLARE_bool(binary_input);
DECLARE_bool(binary_output);
DECLARE_bool(l);
+DECLARE_bool(batch);
+DECLARE_string(metadata);
+DECLARE_string(protofiles);
namespace {
@@ -394,11 +397,65 @@ TEST_F(GrpcToolTest, CallCommand) {
std::bind(PrintStream, &output_stream,
std::placeholders::_1)));
// Expected output: "message: \"Hello\""
- EXPECT_TRUE(NULL !=
+ EXPECT_TRUE(nullptr !=
strstr(output_stream.str().c_str(), "message: \"Hello\""));
ShutdownServer();
}
+TEST_F(GrpcToolTest, CallCommandBatch) {
+ // Test input "grpc_cli call Echo"
+ std::stringstream output_stream;
+
+ const grpc::string server_address = SetUpServer();
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
+ "message: 'Hello0'"};
+
+ // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n"
+ std::streambuf* orig = std::cin.rdbuf();
+ std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n");
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_batch = false;
+
+ // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
+ // "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0\"\nmessage: "
+ "\"Hello1\"\nmessage: \"Hello2\"\n"));
+ std::cin.rdbuf(orig);
+ ShutdownServer();
+}
+
+TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) {
+ // Test input "grpc_cli call Echo"
+ std::stringstream output_stream;
+
+ const grpc::string server_address = SetUpServer();
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
+ "message: 'Hello0'"};
+
+ // Mock std::cin input "message: 1\n\n message: 'Hello2'\n\n"
+ std::streambuf* orig = std::cin.rdbuf();
+ std::istringstream ss("message: 1\n\n message: 'Hello2'\n\n");
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_batch = false;
+
+ // Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0\"\nmessage: \"Hello2\"\n"));
+ std::cin.rdbuf(orig);
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, CallCommandRequestStream) {
// Test input: grpc_cli call localhost:<port> RequestStream "message:
// 'Hello0'"
@@ -418,8 +475,8 @@ TEST_F(GrpcToolTest, CallCommandRequestStream) {
std::placeholders::_1)));
// Expected output: "message: \"Hello0Hello1Hello2\""
- EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(),
- "message: \"Hello0Hello1Hello2\""));
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0Hello1Hello2\""));
std::cin.rdbuf(orig);
ShutdownServer();
}
@@ -443,7 +500,7 @@ TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequest) {
std::placeholders::_1)));
// Expected output: "message: \"Hello0Hello2\""
- EXPECT_TRUE(NULL !=
+ EXPECT_TRUE(nullptr !=
strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\""));
std::cin.rdbuf(orig);
ShutdownServer();
@@ -466,8 +523,8 @@ TEST_F(GrpcToolTest, CallCommandResponseStream) {
for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) {
grpc::string expected_response_text =
"message: \"Hello" + grpc::to_string(i) + "\"\n";
- EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(),
- expected_response_text.c_str()));
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ expected_response_text.c_str()));
}
ShutdownServer();
@@ -492,9 +549,9 @@ TEST_F(GrpcToolTest, CallCommandBidiStream) {
// Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage:
// \"Hello2\"\n\n"
- EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(),
- "message: \"Hello0\"\nmessage: "
- "\"Hello1\"\nmessage: \"Hello2\"\n"));
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0\"\nmessage: "
+ "\"Hello1\"\nmessage: \"Hello2\"\n"));
std::cin.rdbuf(orig);
ShutdownServer();
}
@@ -518,8 +575,8 @@ TEST_F(GrpcToolTest, CallCommandBidiStreamWithBadRequest) {
// Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage:
// \"Hello2\"\n\n"
- EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(),
- "message: \"Hello0\"\nmessage: \"Hello2\"\n"));
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0\"\nmessage: \"Hello2\"\n"));
std::cin.rdbuf(orig);
ShutdownServer();
@@ -563,6 +620,8 @@ TEST_F(GrpcToolTest, ParseCommand) {
// Expected output: ECHO_RESPONSE_MESSAGE
EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), ECHO_RESPONSE_MESSAGE));
+ FLAGS_binary_input = false;
+ FLAGS_binary_output = false;
ShutdownServer();
}
@@ -597,6 +656,84 @@ TEST_F(GrpcToolTest, TooManyArguments) {
EXPECT_TRUE(0 == output_stream.tellp());
}
+TEST_F(GrpcToolTest, CallCommandWithMetadata) {
+ // Test input "grpc_cli call localhost:<port> Echo "message: 'Hello'"
+ const grpc::string server_address = SetUpServer();
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
+ "message: 'Hello'"};
+
+ {
+ std::stringstream output_stream;
+ FLAGS_metadata = "key0:val0:key1:valq:key2:val2";
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv,
+ TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ // Expected output: "message: \"Hello\""
+ EXPECT_TRUE(nullptr !=
+ strstr(output_stream.str().c_str(), "message: \"Hello\""));
+ }
+
+ {
+ std::stringstream output_stream;
+ FLAGS_metadata = "key:val\\:val";
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv,
+ TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ // Expected output: "message: \"Hello\""
+ EXPECT_TRUE(nullptr !=
+ strstr(output_stream.str().c_str(), "message: \"Hello\""));
+ }
+
+ {
+ std::stringstream output_stream;
+ FLAGS_metadata = "key:val\\\\val";
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv,
+ TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ // Expected output: "message: \"Hello\""
+ EXPECT_TRUE(nullptr !=
+ strstr(output_stream.str().c_str(), "message: \"Hello\""));
+ }
+
+ FLAGS_metadata = "";
+ ShutdownServer();
+}
+
+TEST_F(GrpcToolTest, CallCommandWithBadMetadata) {
+ // Test input "grpc_cli call localhost:10000 Echo "message: 'Hello'"
+ const char* argv[] = {"grpc_cli", "call", "localhost:10000", "Echo",
+ "message: 'Hello'"};
+ FLAGS_protofiles = "src/proto/grpc/testing/echo.proto";
+
+ {
+ std::stringstream output_stream;
+ FLAGS_metadata = "key0:val0:key1";
+ // Exit with 1
+ EXPECT_EXIT(
+ GrpcToolMainLib(
+ ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream, std::placeholders::_1)),
+ ::testing::ExitedWithCode(1), ".*Failed to parse metadata flag.*");
+ }
+
+ {
+ std::stringstream output_stream;
+ FLAGS_metadata = "key:val\\val";
+ // Exit with 1
+ EXPECT_EXIT(
+ GrpcToolMainLib(
+ ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream, std::placeholders::_1)),
+ ::testing::ExitedWithCode(1), ".*Failed to parse metadata flag.*");
+ }
+
+ FLAGS_metadata = "";
+ FLAGS_protofiles = "";
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc
index 184828c7b6..0f77934672 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -22,11 +22,11 @@
#include <grpc/support/log.h>
+using grpc::reflection::v1alpha::ErrorResponse;
+using grpc::reflection::v1alpha::ListServiceResponse;
using grpc::reflection::v1alpha::ServerReflection;
using grpc::reflection::v1alpha::ServerReflectionRequest;
using grpc::reflection::v1alpha::ServerReflectionResponse;
-using grpc::reflection::v1alpha::ListServiceResponse;
-using grpc::reflection::v1alpha::ErrorResponse;
namespace grpc {
diff --git a/test/cpp/util/service_describer.h b/test/cpp/util/service_describer.h
index b7a8c9207f..b7ab7578b4 100644
--- a/test/cpp/util/service_describer.h
+++ b/test/cpp/util/service_describer.h
@@ -36,7 +36,7 @@ grpc::string SummarizeService(const grpc::protobuf::ServiceDescriptor* service);
grpc::string SummarizeMethod(const grpc::protobuf::MethodDescriptor* method);
-} // namespase testing
+} // namespace testing
} // namespace grpc
#endif // GRPC_TEST_CPP_UTIL_SERVICE_DESCRIBER_H
diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc
index 8a8962d7ee..c2e55f3374 100644
--- a/test/cpp/util/slice_test.cc
+++ b/test/cpp/util/slice_test.cc
@@ -18,6 +18,7 @@
#include <grpc++/support/slice.h>
+#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <gtest/gtest.h>
@@ -127,5 +128,8 @@ TEST_F(SliceTest, Cslice) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ grpc_init();
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
}
diff --git a/test/cpp/util/test_config_cc.cc b/test/cpp/util/test_config_cc.cc
index f7e034253e..e4b6886335 100644
--- a/test/cpp/util/test_config_cc.cc
+++ b/test/cpp/util/test_config_cc.cc
@@ -16,8 +16,8 @@
*
*/
-#include "test/cpp/util/test_config.h"
#include <gflags/gflags.h>
+#include "test/cpp/util/test_config.h"
// In some distros, gflags is in the namespace google, and in some others,
// in gflags. This hack is enabling us to find both.
diff --git a/test/distrib/cpp/run_distrib_test_cmake.bat b/test/distrib/cpp/run_distrib_test_cmake.bat
new file mode 100644
index 0000000000..f920768ae3
--- /dev/null
+++ b/test/distrib/cpp/run_distrib_test_cmake.bat
@@ -0,0 +1,75 @@
+@rem Copyright 2016 gRPC authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+
+@rem enter this directory
+cd /d %~dp0\..\..\..
+
+@rem TODO(jtattermusch): Kokoro has pre-installed protoc.exe in C:\Program Files\ProtoC and that directory
+@rem is on PATH. To avoid picking up the older version protoc.exe, we change the path to something non-existent.
+set PATH=%PATH:ProtoC=DontPickupProtoC%
+
+@rem Install into ./testinstall, but use absolute path and foward slashes
+set INSTALL_DIR=%cd:\=/%/testinstall
+
+@rem Download OpenSSL-Win32 originally installed from https://slproweb.com/products/Win32OpenSSL.html
+powershell -Command "(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/grpc-testing.appspot.com/OpenSSL-Win32-1_1_0g.zip', 'OpenSSL-Win32.zip')"
+powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('OpenSSL-Win32.zip', '.');"
+
+@rem set absolute path to OpenSSL with forward slashes
+set OPENSSL_DIR=%cd:\=/%/OpenSSL-Win32
+
+cd third_party/zlib
+mkdir cmake
+cd cmake
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..
+cmake --build . --config Release --target install || goto :error
+cd ../../..
+
+cd third_party/protobuf/cmake
+mkdir build
+cd build
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF ..
+cmake --build . --config Release --target install || goto :error
+cd ../../../..
+
+cd third_party/cares/cares
+mkdir cmake
+cd cmake
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..
+cmake --build . --config Release --target install || goto :error
+cd ../../../..
+
+@rem OpenSSL-Win32 and OpenSSL-Win64 can be downloaded from https://slproweb.com/products/Win32OpenSSL.html
+cd cmake
+mkdir build
+cd build
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%/include -DZLIB_LIBRARY=%INSTALL_DIR%/lib/zlibstatic.lib -DZLIB_INCLUDE_DIR=%INSTALL_DIR%/include -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ../.. || goto :error
+cmake --build . --config Release --target install || goto :error
+cd ../..
+
+@rem Build helloworld example using cmake
+cd examples/cpp/helloworld
+mkdir cmake
+cd cmake
+mkdir build
+cd build
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%/include ../.. || goto :error
+cmake --build . --config Release || goto :error
+cd ../../../../..
+
+goto :EOF
+
+:error
+echo Failed!
+exit /b %errorlevel%
diff --git a/test/distrib/cpp/run_distrib_test_cmake.sh b/test/distrib/cpp/run_distrib_test_cmake.sh
index ead8cc10bc..a9c081c2f5 100755
--- a/test/distrib/cpp/run_distrib_test_cmake.sh
+++ b/test/distrib/cpp/run_distrib_test_cmake.sh
@@ -19,7 +19,6 @@ cd $(dirname $0)/../../..
echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list
apt-get update
-#apt-get install -t jessie-backports -y libc-ares-dev # we need specifically version 1.12
apt-get install -t jessie-backports -y libssl-dev
# Install c-ares
diff --git a/test/distrib/node/distrib_test.js b/test/distrib/node/distrib_test.js
deleted file mode 100755
index 62191f0ff2..0000000000
--- a/test/distrib/node/distrib_test.js
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env node
-/*
- *
- * 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.
- *
- */
-
-var grpc = require('grpc');
-
-function identity(x) {
- return x;
-}
-
-var Client = grpc.makeGenericClientConstructor({
- 'echo' : {
- path: '/buffer/echo',
- requestStream: false,
- responseStream: false,
- requestSerialize: identity,
- requestDeserialize: identity,
- responseSerialize: identity,
- responseDeserialize: identity
- }
-});
-
-var client = new Client("localhost:1000", grpc.credentials.createInsecure());
-
-client.$channel.close();
-
-console.log("Success!");
diff --git a/test/distrib/node/package.json b/test/distrib/node/package.json
deleted file mode 100644
index b02a796c97..0000000000
--- a/test/distrib/node/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "grpc-distrib-test",
- "version": "0.0.1",
- "dependencies": {
- "grpc": "*"
- }
-}
diff --git a/test/distrib/node/run_distrib_test.sh b/test/distrib/node/run_distrib_test.sh
deleted file mode 100755
index a806f84f7c..0000000000
--- a/test/distrib/node/run_distrib_test.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-# 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.
-
-function finish() {
- rv=$?
- kill $STATIC_PID || true
- curl "localhost:32767/drop/$STATIC_PORT" || true
- exit $rv
-}
-
-trap finish EXIT
-
-NODE_VERSION=$1
-source ~/.nvm/nvm.sh
-
-cd $(dirname $0)
-
-nvm install $NODE_VERSION
-set -ex
-
-npm install -g node-static
-
-STATIC_SERVER=127.0.0.1
-# If port_server is running, get port from that. Otherwise, assume we're in
-# docker and use 12345
-STATIC_PORT=$(curl 'localhost:32767/get' || echo '12345')
-
-# Serves the input_artifacts directory statically at localhost:
-static "$EXTERNAL_GIT_ROOT/input_artifacts" -a $STATIC_SERVER -p $STATIC_PORT &
-STATIC_PID=$!
-
-STATIC_URL="http://$STATIC_SERVER:$STATIC_PORT/"
-
-npm install --unsafe-perm $STATIC_URL/grpc.tgz --grpc_node_binary_host_mirror=$STATIC_URL
-
-./distrib_test.js
diff --git a/test/distrib/ruby/distribtest.gemspec b/test/distrib/ruby/distribtest.gemspec
index d72892f46c..f11f5218d5 100644
--- a/test/distrib/ruby/distribtest.gemspec
+++ b/test/distrib/ruby/distribtest.gemspec
@@ -14,6 +14,8 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.add_dependency 'grpc', '>=0'
+ s.add_dependency 'public_suffix', '< 3.0'
+ s.add_dependency 'jwt', '< 2.0'
s.add_development_dependency 'bundler', '~> 1.7'
end
diff --git a/test/distrib/ruby/run_distrib_test.sh b/test/distrib/ruby/run_distrib_test.sh
index 0c214e38f2..d74f4cd76d 100755
--- a/test/distrib/ruby/run_distrib_test.sh
+++ b/test/distrib/ruby/run_distrib_test.sh
@@ -17,10 +17,16 @@ set -ex
cd $(dirname $0)
+ARCH=$1
+PLATFORM=$2
# Create an indexed local gem source with gRPC gems to test
GEM_SOURCE=../../../gem_source
mkdir -p ${GEM_SOURCE}/gems
-cp -r $EXTERNAL_GIT_ROOT/input_artifacts/*.gem ${GEM_SOURCE}/gems
+cp $EXTERNAL_GIT_ROOT/input_artifacts/grpc-*$ARCH-$PLATFORM.gem ${GEM_SOURCE}/gems
+if [[ "$(ls ${GEM_SOURCE}/gems | grep grpc | wc -l)" != 1 ]]; then
+ echo "Sanity check failed. Copied over more than one grpc gem into the gem source directory."
+ exit 1
+fi;
gem install builder
gem generate_index --directory ${GEM_SOURCE}
diff --git a/third_party/BUILD b/third_party/BUILD
new file mode 100644
index 0000000000..dea1229684
--- /dev/null
+++ b/third_party/BUILD
@@ -0,0 +1,6 @@
+exports_files([
+ "benchmark.BUILD",
+ "gtest.BUILD",
+ "objective_c/Cronet/bidirectional_stream_c.h",
+ "zlib.BUILD",
+])
diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp
new file mode 160000
+Subproject cc4bed2d74f7c8717e31f9579214ab52a9c9c61
diff --git a/third_party/benchmark b/third_party/benchmark
-Subproject 44c25c892a6229b20db7cd9dc05584ea865896d
+Subproject 5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f
diff --git a/third_party/bloaty b/third_party/bloaty
new file mode 160000
+Subproject 73594cde8c9a52a102c4341c244c833aa61b9c0
diff --git a/third_party/cares/BUILD b/third_party/cares/BUILD
new file mode 100644
index 0000000000..ad27d93c0f
--- /dev/null
+++ b/third_party/cares/BUILD
@@ -0,0 +1,9 @@
+exports_files([
+ "ares_build.h",
+ "cares.BUILD",
+ "config_android/ares_config.h",
+ "config_darwin/ares_config.h",
+ "config_freebsd/ares_config.h",
+ "config_linux/ares_config.h",
+ "config_openbsd/ares_config.h",
+])
diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD
index 978e9b1ed9..3ac02875e6 100644
--- a/third_party/cares/cares.BUILD
+++ b/third_party/cares/cares.BUILD
@@ -3,97 +3,137 @@ config_setting(
values = {"cpu": "darwin"},
)
+# Android is not officially supported through C++.
+# This just helps with the build for now.
+config_setting(
+ name = "android",
+ values = {
+ "crosstool_top": "//external:android/crosstool",
+ },
+)
+
+# iOS is not officially supported through C++.
+# This just helps with the build for now.
+config_setting(
+ name = "ios_x86_64",
+ values = {"cpu": "ios_x86_64"},
+)
+
+config_setting(
+ name = "ios_armv7",
+ values = {"cpu": "ios_armv7"},
+)
+
+config_setting(
+ name = "ios_armv7s",
+ values = {"cpu": "ios_armv7s"},
+)
+
+config_setting(
+ name = "ios_arm64",
+ values = {"cpu": "ios_arm64"},
+)
+
+genrule(
+ name = "ares_build_h",
+ srcs = ["@com_github_grpc_grpc//third_party/cares:ares_build.h"],
+ outs = ["ares_build.h"],
+ cmd = "cat $< > $@",
+)
+
+genrule(
+ name = "ares_config_h",
+ srcs = select({
+ ":ios_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
+ ":ios_armv7": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
+ ":ios_armv7s": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
+ ":ios_arm64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
+ ":darwin": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"],
+ ":android": ["@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h"],
+ "//conditions:default": ["@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h"],
+ }),
+ outs = ["ares_config.h"],
+ cmd = "cat $< > $@",
+)
+
cc_library(
name = "ares",
srcs = [
- "cares/ares__close_sockets.c",
- "cares/ares__get_hostent.c",
- "cares/ares__read_line.c",
- "cares/ares__timeval.c",
- "cares/ares_cancel.c",
- "cares/ares_create_query.c",
- "cares/ares_data.c",
- "cares/ares_destroy.c",
- "cares/ares_expand_name.c",
- "cares/ares_expand_string.c",
- "cares/ares_fds.c",
- "cares/ares_free_hostent.c",
- "cares/ares_free_string.c",
- "cares/ares_getenv.c",
- "cares/ares_gethostbyaddr.c",
- "cares/ares_gethostbyname.c",
- "cares/ares_getnameinfo.c",
- "cares/ares_getopt.c",
- "cares/ares_getsock.c",
- "cares/ares_init.c",
- "cares/ares_library_init.c",
- "cares/ares_llist.c",
- "cares/ares_mkquery.c",
- "cares/ares_nowarn.c",
- "cares/ares_options.c",
- "cares/ares_parse_a_reply.c",
- "cares/ares_parse_aaaa_reply.c",
- "cares/ares_parse_mx_reply.c",
- "cares/ares_parse_naptr_reply.c",
- "cares/ares_parse_ns_reply.c",
- "cares/ares_parse_ptr_reply.c",
- "cares/ares_parse_soa_reply.c",
- "cares/ares_parse_srv_reply.c",
- "cares/ares_parse_txt_reply.c",
- "cares/ares_platform.c",
- "cares/ares_process.c",
- "cares/ares_query.c",
- "cares/ares_search.c",
- "cares/ares_send.c",
- "cares/ares_strcasecmp.c",
- "cares/ares_strdup.c",
- "cares/ares_strerror.c",
- "cares/ares_timeout.c",
- "cares/ares_version.c",
- "cares/ares_writev.c",
- "cares/bitncmp.c",
- "cares/inet_net_pton.c",
- "cares/inet_ntop.c",
- "cares/windows_port.c",
+ "ares__close_sockets.c",
+ "ares__get_hostent.c",
+ "ares__read_line.c",
+ "ares__timeval.c",
+ "ares_cancel.c",
+ "ares_create_query.c",
+ "ares_data.c",
+ "ares_destroy.c",
+ "ares_expand_name.c",
+ "ares_expand_string.c",
+ "ares_fds.c",
+ "ares_free_hostent.c",
+ "ares_free_string.c",
+ "ares_getenv.c",
+ "ares_gethostbyaddr.c",
+ "ares_gethostbyname.c",
+ "ares_getnameinfo.c",
+ "ares_getopt.c",
+ "ares_getsock.c",
+ "ares_init.c",
+ "ares_library_init.c",
+ "ares_llist.c",
+ "ares_mkquery.c",
+ "ares_nowarn.c",
+ "ares_options.c",
+ "ares_parse_a_reply.c",
+ "ares_parse_aaaa_reply.c",
+ "ares_parse_mx_reply.c",
+ "ares_parse_naptr_reply.c",
+ "ares_parse_ns_reply.c",
+ "ares_parse_ptr_reply.c",
+ "ares_parse_soa_reply.c",
+ "ares_parse_srv_reply.c",
+ "ares_parse_txt_reply.c",
+ "ares_platform.c",
+ "ares_process.c",
+ "ares_query.c",
+ "ares_search.c",
+ "ares_send.c",
+ "ares_strcasecmp.c",
+ "ares_strdup.c",
+ "ares_strerror.c",
+ "ares_timeout.c",
+ "ares_version.c",
+ "ares_writev.c",
+ "bitncmp.c",
+ "inet_net_pton.c",
+ "inet_ntop.c",
+ "windows_port.c",
],
hdrs = [
+ "ares.h",
"ares_build.h",
- "cares/ares.h",
- "cares/ares_data.h",
- "cares/ares_dns.h",
- "cares/ares_getenv.h",
- "cares/ares_getopt.h",
- "cares/ares_inet_net_pton.h",
- "cares/ares_iphlpapi.h",
- "cares/ares_ipv6.h",
- "cares/ares_library_init.h",
- "cares/ares_llist.h",
- "cares/ares_nowarn.h",
- "cares/ares_platform.h",
- "cares/ares_private.h",
- "cares/ares_rules.h",
- "cares/ares_setup.h",
- "cares/ares_strcasecmp.h",
- "cares/ares_strdup.h",
- "cares/ares_version.h",
- "cares/bitncmp.h",
- "cares/config-win32.h",
- "cares/nameser.h",
- "cares/setup_once.h",
- ] + select({
- ":darwin": ["config_darwin/ares_config.h"],
- "//conditions:default": ["config_linux/ares_config.h"],
- }),
- includes = [
- ".",
- "cares"
- ] + select({
- ":darwin": ["config_darwin"],
- "//conditions:default": ["config_linux"],
- }),
- linkstatic = 1,
- visibility = [
- "//visibility:public",
+ "ares_config.h",
+ "ares_data.h",
+ "ares_dns.h",
+ "ares_getenv.h",
+ "ares_getopt.h",
+ "ares_inet_net_pton.h",
+ "ares_iphlpapi.h",
+ "ares_ipv6.h",
+ "ares_library_init.h",
+ "ares_llist.h",
+ "ares_nowarn.h",
+ "ares_platform.h",
+ "ares_private.h",
+ "ares_rules.h",
+ "ares_setup.h",
+ "ares_strcasecmp.h",
+ "ares_strdup.h",
+ "ares_version.h",
+ "bitncmp.h",
+ "config-win32.h",
+ "nameser.h",
+ "setup_once.h",
],
copts = [
"-D_GNU_SOURCE",
@@ -101,4 +141,9 @@ cc_library(
"-DNOMINMAX",
"-DHAVE_CONFIG_H",
],
+ includes = ["."],
+ linkstatic = 1,
+ visibility = [
+ "//visibility:public",
+ ],
)
diff --git a/third_party/cares/config_android/ares_config.h b/third_party/cares/config_android/ares_config.h
new file mode 100644
index 0000000000..2caf1b396e
--- /dev/null
+++ b/third_party/cares/config_android/ares_config.h
@@ -0,0 +1,458 @@
+/* Generated from ares_config.h.cmake*/
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* define this if ares is built for a big endian system */
+#undef ARES_BIG_ENDIAN
+
+/* when building as static part of libcurl */
+#undef BUILDING_LIBCURL
+
+/* Defined for build that exposes internal static functions for testing. */
+#undef CARES_EXPOSE_STATICS
+
+/* Defined for build with symbol hiding. */
+#undef CARES_SYMBOL_HIDING
+
+/* Definition to make a library symbol externally visible. */
+#undef CARES_SYMBOL_SCOPE_EXTERN
+
+/* Use resolver library to configure cares */
+/* #undef CARES_USE_LIBRESOLV */
+
+/* if a /etc/inet dir is being used */
+#undef ETC_INET
+
+/* Define to the type of arg 2 for gethostname. */
+#define GETHOSTNAME_TYPE_ARG2 size_t
+
+/* Define to the type qualifier of arg 1 for getnameinfo. */
+#define GETNAMEINFO_QUAL_ARG1
+
+/* Define to the type of arg 1 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
+
+/* Define to the type of arg 2 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG2 socklen_t
+
+/* Define to the type of args 4 and 6 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG46 socklen_t
+
+/* Define to the type of arg 7 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG7 int
+
+/* Specifies the number of arguments to getservbyport_r */
+#define GETSERVBYPORT_R_ARGS
+
+/* Define to 1 if you have AF_INET6. */
+#define HAVE_AF_INET6
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H
+
+/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
+#define HAVE_ARPA_NAMESER_COMPAT_H
+
+/* Define to 1 if you have the <arpa/nameser.h> header file. */
+#define HAVE_ARPA_NAMESER_H
+
+/* Define to 1 if you have the <assert.h> header file. */
+#define HAVE_ASSERT_H
+
+/* Define to 1 if you have the `bitncmp' function. */
+/* #undef HAVE_BITNCMP */
+
+/* Define to 1 if bool is an available type. */
+#define HAVE_BOOL_T
+
+/* Define HAVE_CLOCK_GETTIME_MONOTONIC if you have the clock_gettime
+ * function and monotonic timer.
+ *
+ * IMPORTANT: gRPC MANUAL EDIT HERE!
+ * Note: setting HAVE_CLOCK_GETTIME_MONOTONIC causes use of the clock_gettime
+ * function from glibc, don't set it to support glibc < 2.17 */
+#ifndef GPR_BACKWARDS_COMPATIBILITY_MODE
+ #define HAVE_CLOCK_GETTIME_MONOTONIC
+#endif
+
+/* Define to 1 if you have the closesocket function. */
+/* #undef HAVE_CLOSESOCKET */
+
+/* Define to 1 if you have the CloseSocket camel case function. */
+/* #undef HAVE_CLOSESOCKET_CAMEL */
+
+/* Define to 1 if you have the connect function. */
+#define HAVE_CONNECT
+
+/* define if the compiler supports basic C++11 syntax */
+/* #undef HAVE_CXX11 */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H
+
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK
+
+/* Define to 1 if you have the freeaddrinfo function. */
+#define HAVE_FREEADDRINFO
+
+/* Define to 1 if you have a working getaddrinfo function. */
+#define HAVE_GETADDRINFO
+
+/* Define to 1 if the getaddrinfo function is threadsafe. */
+/* #undef HAVE_GETADDRINFO_THREADSAFE */
+
+/* Define to 1 if you have the getenv function. */
+#define HAVE_GETENV
+
+/* Define to 1 if you have the gethostbyaddr function. */
+#define HAVE_GETHOSTBYADDR
+
+/* Define to 1 if you have the gethostbyname function. */
+#define HAVE_GETHOSTBYNAME
+
+/* Define to 1 if you have the gethostname function. */
+#define HAVE_GETHOSTNAME
+
+/* Define to 1 if you have the getnameinfo function. */
+#define HAVE_GETNAMEINFO
+
+/* Define to 1 if you have the getservbyport_r function. */
+/* #undef HAVE_GETSERVBYPORT_R */
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the `if_indextoname' function. */
+#define HAVE_IF_INDEXTONAME
+
+/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */
+/* #undef HAVE_INET_NET_PTON */
+
+/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
+#define HAVE_INET_NTOP
+
+/* Define to 1 if you have a IPv6 capable working inet_pton function. */
+#define HAVE_INET_PTON
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H
+
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL
+
+/* Define to 1 if you have the ioctlsocket function. */
+/* #undef HAVE_IOCTLSOCKET */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
+ */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
+
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO
+
+/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
+#define HAVE_IOCTL_SIOCGIFADDR
+
+/* Define to 1 if you have the `resolve' library (-lresolve). */
+/* #undef HAVE_LIBRESOLV */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H
+
+/* if your compiler supports LL */
+#define HAVE_LL
+
+/* Define to 1 if the compiler supports the 'long long' data type. */
+#define HAVE_LONGLONG
+
+/* Define to 1 if you have the malloc.h header file. */
+#define HAVE_MALLOC_H
+
+/* Define to 1 if you have the memory.h header file. */
+#define HAVE_MEMORY_H
+
+/* Define to 1 if you have the MSG_NOSIGNAL flag. */
+#define HAVE_MSG_NOSIGNAL
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+#define HAVE_NETINET_TCP_H
+
+/* Define to 1 if you have the <net/if.h> header file. */
+#define HAVE_NET_IF_H
+
+/* Define to 1 if you have PF_INET6. */
+#define HAVE_PF_INET6
+
+/* Define to 1 if you have the recv function. */
+#define HAVE_RECV
+
+/* Define to 1 if you have the recvfrom function. */
+#define HAVE_RECVFROM
+
+/* Define to 1 if you have the send function. */
+#define HAVE_SEND
+
+/* Define to 1 if you have the setsockopt function. */
+#define HAVE_SETSOCKOPT
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H
+
+/* Define to 1 if sig_atomic_t is an available typedef. */
+#define HAVE_SIG_ATOMIC_T
+
+/* Define to 1 if sig_atomic_t is already defined as volatile. */
+/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
+
+/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
+#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
+
+/* Define to 1 if you have the socket function. */
+#define HAVE_SOCKET
+
+/* Define to 1 if you have the <socket.h> header file. */
+/* #undef HAVE_SOCKET_H */
+
+/* Define to 1 if you have the <stdbool.h> header file. */
+#define HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H
+
+/* Define to 1 if you have the strcasecmp function. */
+#define HAVE_STRCASECMP
+
+/* Define to 1 if you have the strcmpi function. */
+/* #undef HAVE_STRCMPI */
+
+/* Define to 1 if you have the strdup function. */
+#define HAVE_STRDUP
+
+/* Define to 1 if you have the stricmp function. */
+/* #undef HAVE_STRICMP */
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H
+
+/* Define to 1 if you have the strncasecmp function. */
+#define HAVE_STRNCASECMP
+
+/* Define to 1 if you have the strncmpi function. */
+/* #undef HAVE_STRNCMPI */
+
+/* Define to 1 if you have the strnicmp function. */
+/* #undef HAVE_STRNICMP */
+
+/* Define to 1 if you have the <stropts.h> header file. */
+#define HAVE_STROPTS_H
+
+/* Define to 1 if you have struct addrinfo. */
+#define HAVE_STRUCT_ADDRINFO
+
+/* Define to 1 if you have struct in6_addr. */
+#define HAVE_STRUCT_IN6_ADDR
+
+/* Define to 1 if you have struct sockaddr_in6. */
+#define HAVE_STRUCT_SOCKADDR_IN6
+
+/* if struct sockaddr_storage is defined */
+#define HAVE_STRUCT_SOCKADDR_STORAGE
+
+/* Define to 1 if you have the timeval struct. */
+#define HAVE_STRUCT_TIMEVAL
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#define HAVE_SYS_UIO_H
+
+/* Define to 1 if you have the <time.h> header file. */
+#define HAVE_TIME_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H
+
+/* Define to 1 if you have the windows.h header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* Define to 1 if you have the winsock2.h header file. */
+/* #undef HAVE_WINSOCK2_H */
+
+/* Define to 1 if you have the winsock.h header file. */
+/* #undef HAVE_WINSOCK_H */
+
+/* Define to 1 if you have the writev function. */
+#define HAVE_WRITEV
+
+/* Define to 1 if you have the ws2tcpip.h header file. */
+/* #undef HAVE_WS2TCPIP_H */
+
+/* Define to 1 if you need the malloc.h header file even with stdlib.h */
+/* #undef NEED_MALLOC_H */
+
+/* Define to 1 if you need the memory.h header file even with stdlib.h */
+/* #undef NEED_MEMORY_H */
+
+/* a suitable file/device to read random data from */
+/* #undef RANDOM_FILE */
+
+/* Define to the type qualifier pointed by arg 5 for recvfrom. */
+#define RECVFROM_QUAL_ARG5
+
+/* Define to the type of arg 1 for recvfrom. */
+#define RECVFROM_TYPE_ARG1 int
+
+/* Define to the type pointed by arg 2 for recvfrom. */
+#define RECVFROM_TYPE_ARG2 void *
+
+/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
+#define RECVFROM_TYPE_ARG2_IS_VOID 0
+
+/* Define to the type of arg 3 for recvfrom. */
+#define RECVFROM_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for recvfrom. */
+#define RECVFROM_TYPE_ARG4 int
+
+/* Define to the type pointed by arg 5 for recvfrom. */
+#define RECVFROM_TYPE_ARG5 struct sockaddr *
+
+/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
+#define RECVFROM_TYPE_ARG5_IS_VOID 0
+
+/* Define to the type pointed by arg 6 for recvfrom. */
+#define RECVFROM_TYPE_ARG6 socklen_t *
+
+/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
+#define RECVFROM_TYPE_ARG6_IS_VOID 0
+
+/* Define to the function return type for recvfrom. */
+#define RECVFROM_TYPE_RETV ssize_t
+
+/* Define to the type of arg 1 for recv. */
+#define RECV_TYPE_ARG1 int
+
+/* Define to the type of arg 2 for recv. */
+#define RECV_TYPE_ARG2 void *
+
+/* Define to the type of arg 3 for recv. */
+#define RECV_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for recv. */
+#define RECV_TYPE_ARG4 int
+
+/* Define to the function return type for recv. */
+#define RECV_TYPE_RETV ssize_t
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE
+
+/* Define to the type qualifier of arg 2 for send. */
+#define SEND_QUAL_ARG2
+
+/* Define to the type of arg 1 for send. */
+#define SEND_TYPE_ARG1 int
+
+/* Define to the type of arg 2 for send. */
+#define SEND_TYPE_ARG2 void *
+
+/* Define to the type of arg 3 for send. */
+#define SEND_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for send. */
+#define SEND_TYPE_ARG4 int
+
+/* Define to the function return type for send. */
+#define SEND_TYPE_RETV ssize_t
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME
+
+/* Define to disable non-blocking sockets. */
+#undef USE_BLOCKING_SOCKETS
+
+/* Define to avoid automatic inclusion of winsock.h */
+#undef WIN32_LEAN_AND_MEAN
+
+/* Type to use in place of in_addr_t when system does not provide it. */
+#undef in_addr_t
+
+#ifdef GPR_BACKWARDS_COMPATIBILITY_MODE
+ /* IMPORTANT: gRPC MANUAL EDIT HERE!
+ * Redefine the fd_set macros for GLIBC < 2.15 support.
+ * This is a backwards compatibility hack. At version 2.15, GLIBC introduces
+ * the __fdelt_chk function, and starts using it within its fd_set macros
+ * (which c-ares uses). For compatibility with GLIBC < 2.15, we need to redefine
+ * the fd_set macros to not use __fdelt_chk. */
+ #include <sys/select.h>
+ #undef FD_SET
+ #undef FD_CLR
+ #undef FD_ISSET
+ /* 'FD_ZERO' doesn't use __fdelt_chk, no need to redefine. */
+
+ #ifdef __FDS_BITS
+ #define GRPC_CARES_FDS_BITS(set) __FDS_BITS(set)
+ #else
+ #define GRPC_CARES_FDS_BITS(set) ((set)->fds_bits)
+ #endif
+
+ #define GRPC_CARES_FD_MASK(d) ((long int)(1UL << (d) % NFDBITS))
+
+ #define FD_SET(d, set) \
+ ((void) (GRPC_CARES_FDS_BITS (set)[ (d) / NFDBITS ] |= GRPC_CARES_FD_MASK(d)))
+ #define FD_CLR(d, set) \
+ ((void) (GRPC_CARES_FDS_BITS (set)[ (d) / NFDBITS ] &= ~GRPC_CARES_FD_MASK(d)))
+ #define FD_ISSET(d, set) \
+ ((GRPC_CARES_FDS_BITS (set)[ (d) / NFDBITS ] & GRPC_CARES_FD_MASK(d)) != 0)
+#endif /* GPR_BACKWARDS_COMPATIBILITY_MODE */
diff --git a/third_party/cares/config_openbsd/ares_config.h b/third_party/cares/config_openbsd/ares_config.h
new file mode 100644
index 0000000000..3b3320db8f
--- /dev/null
+++ b/third_party/cares/config_openbsd/ares_config.h
@@ -0,0 +1,502 @@
+/* ares_config.h. Generated from ares_config.h.in by configure. */
+/* ares_config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* define this if ares is built for a big endian system */
+/* #undef ARES_BIG_ENDIAN */
+
+/* when building as static part of libcurl */
+/* #undef BUILDING_LIBCURL */
+
+/* Defined for build that exposes internal static functions for testing. */
+/* #undef CARES_EXPOSE_STATICS */
+
+/* Defined for build with symbol hiding. */
+#define CARES_SYMBOL_HIDING 1
+
+/* Definition to make a library symbol externally visible. */
+#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((__visibility__ ("default")))
+
+/* the signed version of size_t */
+#define CARES_TYPEOF_ARES_SSIZE_T ssize_t
+
+/* Use resolver library to configure cares */
+/* #undef CARES_USE_LIBRESOLV */
+
+/* if a /etc/inet dir is being used */
+/* #undef ETC_INET */
+
+/* Define to the type of arg 2 for gethostname. */
+#define GETHOSTNAME_TYPE_ARG2 size_t
+
+/* Define to the type qualifier of arg 1 for getnameinfo. */
+#define GETNAMEINFO_QUAL_ARG1 const
+
+/* Define to the type of arg 1 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
+
+/* Define to the type of arg 2 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG2 socklen_t
+
+/* Define to the type of args 4 and 6 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG46 size_t
+
+/* Define to the type of arg 7 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG7 int
+
+/* Specifies the number of arguments to getservbyport_r */
+#define GETSERVBYPORT_R_ARGS 4
+
+/* Specifies the size of the buffer to pass to getservbyport_r */
+#define GETSERVBYPORT_R_BUFSIZE sizeof(struct servent_data)
+
+/* Define to 1 if you have AF_INET6. */
+#define HAVE_AF_INET6 1
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
+/* #undef HAVE_ARPA_NAMESER_COMPAT_H */
+
+/* Define to 1 if you have the <arpa/nameser.h> header file. */
+#define HAVE_ARPA_NAMESER_H 1
+
+/* Define to 1 if you have the <assert.h> header file. */
+#define HAVE_ASSERT_H 1
+
+/* Define to 1 if you have the `bitncmp' function. */
+/* #undef HAVE_BITNCMP */
+
+/* Define to 1 if bool is an available type. */
+#define HAVE_BOOL_T 1
+
+/* Define to 1 if you have the clock_gettime function and monotonic timer. */
+#define HAVE_CLOCK_GETTIME_MONOTONIC 1
+
+/* Define to 1 if you have the closesocket function. */
+/* #undef HAVE_CLOSESOCKET */
+
+/* Define to 1 if you have the CloseSocket camel case function. */
+/* #undef HAVE_CLOSESOCKET_CAMEL */
+
+/* Define to 1 if you have the connect function. */
+#define HAVE_CONNECT 1
+
+/* define if the compiler supports basic C++11 syntax */
+/* #undef HAVE_CXX11 */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK 1
+
+/* Define to 1 if you have the freeaddrinfo function. */
+#define HAVE_FREEADDRINFO 1
+
+/* Define to 1 if you have a working getaddrinfo function. */
+#define HAVE_GETADDRINFO 1
+
+/* Define to 1 if the getaddrinfo function is threadsafe. */
+/* #undef HAVE_GETADDRINFO_THREADSAFE */
+
+/* Define to 1 if you have the getenv function. */
+#define HAVE_GETENV 1
+
+/* Define to 1 if you have the gethostbyaddr function. */
+#define HAVE_GETHOSTBYADDR 1
+
+/* Define to 1 if you have the gethostbyname function. */
+#define HAVE_GETHOSTBYNAME 1
+
+/* Define to 1 if you have the gethostname function. */
+#define HAVE_GETHOSTNAME 1
+
+/* Define to 1 if you have the getnameinfo function. */
+#define HAVE_GETNAMEINFO 1
+
+/* Define to 1 if you have the getservbyport_r function. */
+#define HAVE_GETSERVBYPORT_R 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the `if_indextoname' function. */
+#define HAVE_IF_INDEXTONAME 1
+
+/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */
+/* #undef HAVE_INET_NET_PTON */
+
+/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
+#define HAVE_INET_NTOP 1
+
+/* Define to 1 if you have a IPv6 capable working inet_pton function. */
+#define HAVE_INET_PTON 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define to 1 if you have the ioctlsocket function. */
+/* #undef HAVE_IOCTLSOCKET */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
+ */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
+
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO 1
+
+/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
+#define HAVE_IOCTL_SIOCGIFADDR 1
+
+/* Define to 1 if you have the `resolve' library (-lresolve). */
+/* #undef HAVE_LIBRESOLVE */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* if your compiler supports LL */
+#define HAVE_LL 1
+
+/* Define to 1 if the compiler supports the 'long long' data type. */
+#define HAVE_LONGLONG 1
+
+/* Define to 1 if you have the malloc.h header file. */
+/* #undef HAVE_MALLOC_H */
+
+/* Define to 1 if you have the memory.h header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the MSG_NOSIGNAL flag. */
+#define HAVE_MSG_NOSIGNAL 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+#define HAVE_NETINET_TCP_H 1
+
+/* Define to 1 if you have the <net/if.h> header file. */
+#define HAVE_NET_IF_H 1
+
+/* Define to 1 if you have PF_INET6. */
+#define HAVE_PF_INET6 1
+
+/* Define to 1 if you have the recv function. */
+#define HAVE_RECV 1
+
+/* Define to 1 if you have the recvfrom function. */
+#define HAVE_RECVFROM 1
+
+/* Define to 1 if you have the send function. */
+#define HAVE_SEND 1
+
+/* Define to 1 if you have the setsockopt function. */
+#define HAVE_SETSOCKOPT 1
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if sig_atomic_t is an available typedef. */
+#define HAVE_SIG_ATOMIC_T 1
+
+/* Define to 1 if sig_atomic_t is already defined as volatile. */
+/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
+
+/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
+#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
+
+/* Define to 1 if you have the socket function. */
+#define HAVE_SOCKET 1
+
+/* Define to 1 if you have the <socket.h> header file. */
+/* #undef HAVE_SOCKET_H */
+
+/* Define to 1 if you have the <stdbool.h> header file. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the strcasecmp function. */
+#define HAVE_STRCASECMP 1
+
+/* Define to 1 if you have the strcmpi function. */
+/* #undef HAVE_STRCMPI */
+
+/* Define to 1 if you have the strdup function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the stricmp function. */
+/* #undef HAVE_STRICMP */
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the strncasecmp function. */
+#define HAVE_STRNCASECMP 1
+
+/* Define to 1 if you have the strncmpi function. */
+/* #undef HAVE_STRNCMPI */
+
+/* Define to 1 if you have the strnicmp function. */
+/* #undef HAVE_STRNICMP */
+
+/* Define to 1 if you have the <stropts.h> header file. */
+/* #undef HAVE_STROPTS_H */
+
+/* Define to 1 if you have struct addrinfo. */
+#define HAVE_STRUCT_ADDRINFO 1
+
+/* Define to 1 if you have struct in6_addr. */
+#define HAVE_STRUCT_IN6_ADDR 1
+
+/* Define to 1 if you have struct sockaddr_in6. */
+#define HAVE_STRUCT_SOCKADDR_IN6 1
+
+/* if struct sockaddr_storage is defined */
+#define HAVE_STRUCT_SOCKADDR_STORAGE 1
+
+/* Define to 1 if you have the timeval struct. */
+#define HAVE_STRUCT_TIMEVAL 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#define HAVE_SYS_UIO_H 1
+
+/* Define to 1 if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the windows.h header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* Define to 1 if you have the winsock2.h header file. */
+/* #undef HAVE_WINSOCK2_H */
+
+/* Define to 1 if you have the winsock.h header file. */
+/* #undef HAVE_WINSOCK_H */
+
+/* Define to 1 if you have the writev function. */
+#define HAVE_WRITEV 1
+
+/* Define to 1 if you have the ws2tcpip.h header file. */
+/* #undef HAVE_WS2TCPIP_H */
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if you need the malloc.h header file even with stdlib.h */
+/* #undef NEED_MALLOC_H */
+
+/* Define to 1 if you need the memory.h header file even with stdlib.h */
+/* #undef NEED_MEMORY_H */
+
+/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
+/* #undef NEED_REENTRANT */
+
+/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
+/* #undef NEED_THREAD_SAFE */
+
+/* cpu-machine-OS */
+#define OS "x86_64-unknown-openbsd6.2"
+
+/* Name of package */
+#define PACKAGE "c-ares"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "c-ares"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "c-ares 1.13.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "c-ares"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.13.0"
+
+/* a suitable file/device to read random data from */
+#define RANDOM_FILE "/dev/urandom"
+
+/* Define to the type qualifier pointed by arg 5 for recvfrom. */
+#define RECVFROM_QUAL_ARG5
+
+/* Define to the type of arg 1 for recvfrom. */
+#define RECVFROM_TYPE_ARG1 int
+
+/* Define to the type pointed by arg 2 for recvfrom. */
+#define RECVFROM_TYPE_ARG2 void
+
+/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
+#define RECVFROM_TYPE_ARG2_IS_VOID 1
+
+/* Define to the type of arg 3 for recvfrom. */
+#define RECVFROM_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for recvfrom. */
+#define RECVFROM_TYPE_ARG4 int
+
+/* Define to the type pointed by arg 5 for recvfrom. */
+#define RECVFROM_TYPE_ARG5 struct sockaddr
+
+/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
+/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
+
+/* Define to the type pointed by arg 6 for recvfrom. */
+#define RECVFROM_TYPE_ARG6 socklen_t
+
+/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
+/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
+
+/* Define to the function return type for recvfrom. */
+#define RECVFROM_TYPE_RETV ssize_t
+
+/* Define to the type of arg 1 for recv. */
+#define RECV_TYPE_ARG1 int
+
+/* Define to the type of arg 2 for recv. */
+#define RECV_TYPE_ARG2 void *
+
+/* Define to the type of arg 3 for recv. */
+#define RECV_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for recv. */
+#define RECV_TYPE_ARG4 int
+
+/* Define to the function return type for recv. */
+#define RECV_TYPE_RETV ssize_t
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define to the type qualifier of arg 2 for send. */
+#define SEND_QUAL_ARG2 const
+
+/* Define to the type of arg 1 for send. */
+#define SEND_TYPE_ARG1 int
+
+/* Define to the type of arg 2 for send. */
+#define SEND_TYPE_ARG2 void *
+
+/* Define to the type of arg 3 for send. */
+#define SEND_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for send. */
+#define SEND_TYPE_ARG4 int
+
+/* Define to the function return type for send. */
+#define SEND_TYPE_RETV ssize_t
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define to disable non-blocking sockets. */
+/* #undef USE_BLOCKING_SOCKETS */
+
+/* Version number of package */
+#define VERSION "1.13.0"
+
+/* Define to avoid automatic inclusion of winsock.h */
+/* #undef WIN32_LEAN_AND_MEAN */
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* # undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Define to 1 if OS is AIX. */
+#ifndef _ALL_SOURCE
+/* # undef _ALL_SOURCE */
+#endif
+
+/* Enable large inode numbers on Mac OS X 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Type to use in place of in_addr_t when system does not provide it. */
+/* #undef in_addr_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
diff --git a/third_party/protobuf b/third_party/protobuf
-Subproject 80a37e0782d2d702d52234b62dd4b9ec74fd2c9
+Subproject 2761122b810fe8861004ae785cc3ab39f384d34
diff --git a/third_party/rake-compiler-dock/Dockerfile b/third_party/rake-compiler-dock/Dockerfile
index b4a5158535..06c721c39b 100644
--- a/third_party/rake-compiler-dock/Dockerfile
+++ b/third_party/rake-compiler-dock/Dockerfile
@@ -1,182 +1,4 @@
-FROM ubuntu:17.04
-
-RUN apt-get -y update && \
- apt-get install -y curl git-core xz-utils build-essential wget unzip sudo gpg dirmngr
-
-# Add "rvm" as system group, to avoid conflicts with host GIDs typically starting with 1000
-RUN groupadd -r rvm && useradd -r -g rvm -G sudo -p "" --create-home rvm && \
- echo "source /etc/profile.d/rvm.sh" >> /etc/rubybashrc
-
-USER root
-RUN apt-get -y update && \
- apt-get install -y gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 g++-mingw-w64-x86-64 g++-mingw-w64-i686 \
- gcc-multilib moreutils
-USER rvm
-
-# install rvm, RVM 1.26.0+ has signed releases, source rvm for usage outside of package scripts
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 && \
- (curl -L http://get.rvm.io | sudo bash -s stable) && \
- bash -c " \
- source /etc/rubybashrc && \
- rvmsudo rvm cleanup all "
-
-# Regenerate the following using build.sh if the build folder changes.
-RUN echo \\
-H4sIANslcFgAA+08a3fbxo75uvwVqOxTSbFIidTDVhKnTW0n8d28ju2ku6fO5R2RQ4kVRXJnSMve\
-OPe3LzAk9f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BRNovV9+cYSSiihhBJKKKGEEkoooYQSSiihhBJK\
-KKGEEkoooYQSSiihhBJKKKGEEkoooYQSSiihhH9H+D9i0BbqAHgAAA==\
-| base64 -d | tar xzC /tmp
-
-# Import patch files for ruby and gems
-RUN cp -r /tmp/build/patches /home/rvm/patches/
-ENV BASH_ENV /etc/rubybashrc
-
-# install rubies and fix permissions on
-RUN bash -c " \
- export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
- echo 'about to install patches for ruby 2.4.0 from:' && \
- ls -r ~/patches && \
- for v in 2.4.0 ; do \
- rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
- done && \
- rvm cleanup all && \
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
-
-# Install rake-compiler and typical gems in all Rubies
-# do not generate documentation for gems
-RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
- bash -c " \
- rvm all do gem install bundler rake-compiler hoe mini_portile rubygems-tasks && \
- rvm 2.4.0 do gem install mini_portile2 && \
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
-
-RUN bash -c "gem env"
-RUN bash -c "gem list rake-compiler"
-
-# Install rake-compiler's cross rubies in global dir instead of /root
-RUN sudo mkdir -p /usr/local/rake-compiler && \
- sudo chown rvm.rvm /usr/local/rake-compiler && \
- ln -s /usr/local/rake-compiler ~/.rake-compiler
-
-# Patch rake-compiler to avoid build of ruby extensions
-RUN cd /usr/local/rvm/gems/ruby-2.4.0/gems/rake-compiler-0.9.5 && git apply /home/rvm/patches/rake-compiler-0.9.5/*.diff ; \
- true
-
-RUN bash -c "rvm use 2.4.0 --default && \
- export MAKE=\"make -j`nproc`\" CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
- rake-compiler cross-ruby VERSION=2.4.0 HOST=i686-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.4.0 HOST=x86_64-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.4.0 HOST=x86_64-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.3.0 HOST=i686-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.3.0 HOST=x86_64-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.3.0 HOST=x86_64-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.1.5 HOST=i686-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.1.5 HOST=x86_64-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.1.5 HOST=x86_64-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-w64-mingw32 && \
- rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-linux-gnu && \
- rm -rf ~/.rake-compiler/tmp/builds ~/.rake-compiler/sources && \
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
-
-RUN bash -c "rvm use 2.4.0 --default && \
- export MAKE=\"make -j`nproc`\" CFLAGS='-m32 -s -O1 -fno-omit-frame-pointer -fno-fast-math' LDFLAGS='-m32' && \
- rake-compiler cross-ruby VERSION=2.4.0 HOST=i686-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.3.0 HOST=i686-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.1.5 HOST=i686-linux-gnu && \
- rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-linux-gnu && \
- rm -rf ~/.rake-compiler/tmp/builds ~/.rake-compiler/sources && \
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
-
-RUN bash -c " \
- rvm alias create 2.4 2.4.0 "
-
-USER root
-
-# Fix paths in rake-compiler/config.yml and add rvm and mingw-tools to the global bashrc
-RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml && \
- echo "source /etc/profile.d/rvm.sh" >> /etc/bash.bashrc && \
- echo "export PATH=\$PATH:/opt/mingw/mingw32/bin" >> /etc/bash.bashrc && \
- echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/bash.bashrc
-
-# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
-RUN cp /tmp/build/strip_wrapper /root/
-RUN sudo chmod +rx /root/strip_wrapper
-RUN mv /usr/bin/i686-w64-mingw32-strip /usr/bin/i686-w64-mingw32-strip.bin && \
- mv /usr/bin/x86_64-w64-mingw32-strip /usr/bin/x86_64-w64-mingw32-strip.bin && \
- ln /root/strip_wrapper /usr/bin/i686-w64-mingw32-strip && \
- ln /root/strip_wrapper /usr/bin/x86_64-w64-mingw32-strip
+FROM larskanis/rake-compiler-dock:0.6.2
RUN find / -name rbconfig.rb | while read f ; do sed -i 's/0x0501/0x0600/' $f ; done
RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done
@@ -184,26 +6,6 @@ RUN sed -i 's/defined.__MINGW64__.$/1/' /usr/local/rake-compiler/ruby/i686-w64-m
RUN find / -name libwinpthread.dll.a | xargs rm
RUN find / -name libwinpthread-1.dll | xargs rm
RUN find / -name *msvcrt-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
-RUN find /usr/local/rake-compiler/ruby -name libruby.so | xargs rm
-RUN find /usr/local/rake-compiler/ruby -name libruby-static.a | while read f ; do ar t $f | xargs ar d $f ; done
-RUN find /usr/local/rake-compiler/ruby -name libruby-static.a | while read f ; do mv $f `echo $f | sed s/-static//` ; done
-
-# Install SIGINT forwarder
-RUN cp /tmp/build/sigfw.c /root/
-RUN gcc $HOME/sigfw.c -o /usr/local/bin/sigfw
-
-# Install user mapper
-RUN cp /tmp/build/runas /usr/local/bin/
-
-# Install sudoers configuration
-RUN cp /tmp/build/sudoers /etc/sudoers.d/rake-compiler-dock
-
-# Fixup Ruby 2.4 'static' compilation issue.
-RUN echo '!<arch>' > /usr/local/rake-compiler/ruby/x86_64-linux-gnu/ruby-2.4.0/lib/libruby.a
-RUN echo '!<arch>' > /usr/local/rake-compiler/ruby/i686-linux-gnu/ruby-2.4.0/lib/libruby.a
-
-ENV RUBY_CC_VERSION 2.4.0:2.3.0:2.2.2:2.1.5:2.0.0
-
RUN apt-get install -y g++-multilib
CMD bash
diff --git a/third_party/rake-compiler-dock/build.sh b/third_party/rake-compiler-dock/build.sh
deleted file mode 100755
index ca01fa6d4d..0000000000
--- a/third_party/rake-compiler-dock/build.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# Run this to produce the snipplet of data to insert in the Dockerfile.
-
-echo 'RUN echo \\'
-tar cz build | base64 | sed 's/$/\\/'
-echo '| base64 -d | tar xzC /tmp'
diff --git a/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff b/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff
deleted file mode 100644
index ea22bd928e..0000000000
--- a/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff
+++ /dev/null
@@ -1,105 +0,0 @@
-From 41f834449fc4323b2f995e8715aa5842d9fd9334 Mon Sep 17 00:00:00 2001
-From: Lars Kanis <lars@greiz-reinsdorf.de>
-Date: Sat, 30 Jan 2016 08:08:07 +0100
-Subject: [PATCH] Change the fake mechanism to be compatible with bundler.
-
-The previous fake mechanism worked by hooking onto the
-"require 'rbconfig'" call.
-This is problematic because bundler internally requires rbconfig, but doesn't
-work corretly in a faked environment.
-It then fails to load gems that are also part of the standard library, like
-json and rdoc.
-This results in issues like https://github.com/rake-compiler/rake-compiler-dock/issues/8
-
-The fake mechanism is now changed to hook onto the "require 'mkrb'" call,
-which is typically part of the extconf file, and it is where the faked platform
-values are actually needed.
-That way it is loaded after bundler/setup, so that the library paths are
-set according to the Gemfile.lock, to the native Linux libraries, before
-the fake environment is active.
-
-Please note, that the build directory of a given gem needs to be cleared,
-in order to get updated fake files. So do a "rm tmp pkg -rf".
----
- lib/rake/extensiontask.rb | 35 ++++++++++++++---------------------
- 1 file changed, 14 insertions(+), 21 deletions(-)
-
-diff --git a/lib/rake/extensiontask.rb b/lib/rake/extensiontask.rb
-index 030af96..f914919 100644
---- a/lib/rake/extensiontask.rb
-+++ b/lib/rake/extensiontask.rb
-@@ -169,8 +169,8 @@ Java extension should be preferred.
- # now add the extconf script
- cmd << abs_extconf.relative_path_from(abs_tmp_path)
-
-- # rbconfig.rb will be present if we are cross compiling
-- if t.prerequisites.include?("#{tmp_path}/rbconfig.rb") then
-+ # fake.rb will be present if we are cross compiling
-+ if t.prerequisites.include?("#{tmp_path}/fake.rb") then
- options.push(*cross_config_options(platf))
- end
-
-@@ -365,39 +365,30 @@ Java extension should be preferred.
- # define compilation tasks for cross platform!
- define_compile_tasks(for_platform, ruby_ver)
-
-- # chain fake.rb, rbconfig.rb and mkmf.rb to Makefile generation
-+ # chain fake.rb and mkmf.rb to Makefile generation
- file "#{tmp_path}/Makefile" => ["#{tmp_path}/fake.rb",
-- "#{tmp_path}/rbconfig.rb",
- "#{tmp_path}/mkmf.rb"]
-
-- # copy the file from the cross-ruby location
-- file "#{tmp_path}/rbconfig.rb" => [rbconfig_file] do |t|
-+ # copy the rbconfig from the cross-ruby location and
-+ # genearte fake.rb for different ruby versions
-+ file "#{tmp_path}/fake.rb" => [rbconfig_file] do |t|
- File.open(t.name, 'w') do |f|
-- f.write "require 'fake.rb'\n\n"
-+ f.write fake_rb(for_platform, ruby_ver)
- f.write File.read(t.prerequisites.first)
- end
- end
-
- # copy mkmf from cross-ruby location
- file "#{tmp_path}/mkmf.rb" => [mkmf_file] do |t|
-- cp t.prerequisites.first, t.name
-- if ruby_ver < "1.9" && "1.9" <= RUBY_VERSION
-- File.open(t.name, 'r+t') do |f|
-- content = f.read
-+ File.open(t.name, 'w') do |f|
-+ content = File.read(t.prerequisites.first)
-+ content.sub!(/^(require ')rbconfig(')$/, '\\1fake\\2')
-+ if ruby_ver < "1.9" && "1.9" <= RUBY_VERSION
- content.sub!(/^( break )\*(defaults)$/, '\\1\\2.first')
- content.sub!(/^( return )\*(defaults)$/, '\\1\\2.first')
- content.sub!(/^( mfile\.)print( configuration\(srcprefix\))$/, '\\1puts\\2')
-- f.rewind
-- f.write content
-- f.truncate(f.tell)
- end
-- end
-- end
--
-- # genearte fake.rb for different ruby versions
-- file "#{tmp_path}/fake.rb" do |t|
-- File.open(t.name, 'w') do |f|
-- f.write fake_rb(for_platform, ruby_ver)
-+ f.write content
- end
- end
-
-@@ -495,8 +486,10 @@ Java extension should be preferred.
- # "cannot load such file -- win32/resolv" when it is required later on.
- # See also: https://github.com/tjschuck/rake-compiler-dev-box/issues/5
- require 'resolv'
-+ require 'rbconfig'
-
- class Object
-+ remove_const :RbConfig
- remove_const :RUBY_PLATFORM
- remove_const :RUBY_VERSION
- remove_const :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
---
-2.5.0.windows.1
-
diff --git a/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/without-exts.diff b/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/without-exts.diff
deleted file mode 100644
index 07739d33ec..0000000000
--- a/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/without-exts.diff
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/tasks/bin/cross-ruby.rake b/tasks/bin/cross-ruby.rake
-index 6acc816..6aa2a49 100644
---- a/tasks/bin/cross-ruby.rake
-+++ b/tasks/bin/cross-ruby.rake
-@@ -135,8 +135,7 @@ file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile" => ["#{USER
- "--build=#{RUBY_BUILD}",
- '--enable-shared',
- '--disable-install-doc',
-- '--without-tk',
-- '--without-tcl'
-+ '--with-ext='
- ]
-
- # Force Winsock2 for Ruby 1.8, 1.9 defaults to it
diff --git a/third_party/rake-compiler-dock/build/patches/ruby-1.8.7-p374/nop.patch b/third_party/rake-compiler-dock/build/patches/ruby-1.8.7-p374/nop.patch
deleted file mode 100644
index fac8525da6..0000000000
--- a/third_party/rake-compiler-dock/build/patches/ruby-1.8.7-p374/nop.patch
+++ /dev/null
@@ -1,2 +0,0 @@
-diff --git a/configure b/configure
-index 55157af..6630eba 100755
diff --git a/third_party/rake-compiler-dock/build/patches/ruby-1.9.3/no_sendfile.patch b/third_party/rake-compiler-dock/build/patches/ruby-1.9.3/no_sendfile.patch
deleted file mode 100644
index d8f339e814..0000000000
--- a/third_party/rake-compiler-dock/build/patches/ruby-1.9.3/no_sendfile.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/configure b/configure
-index 898730c..cfe6253 100755
---- a/configure
-+++ b/configure
-@@ -14695,7 +14695,7 @@ for ac_func in fmod killpg wait4 waitpid fork spawnv syscall __syscall chroot ge
- setsid telldir seekdir fchmod cosh sinh tanh log2 round\
- setuid setgid daemon select_large_fdset setenv unsetenv\
- mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
-- pread sendfile shutdown sigaltstack dl_iterate_phdr
-+ pread shutdown sigaltstack dl_iterate_phdr
- do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
- ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/third_party/rake-compiler-dock/build/patches/ruby-1.9.3/nop.patch b/third_party/rake-compiler-dock/build/patches/ruby-1.9.3/nop.patch
deleted file mode 100644
index fac8525da6..0000000000
--- a/third_party/rake-compiler-dock/build/patches/ruby-1.9.3/nop.patch
+++ /dev/null
@@ -1,2 +0,0 @@
-diff --git a/configure b/configure
-index 55157af..6630eba 100755
diff --git a/third_party/rake-compiler-dock/build/patches/ruby-2.3.0/no_sendfile.patch b/third_party/rake-compiler-dock/build/patches/ruby-2.3.0/no_sendfile.patch
deleted file mode 100644
index 915fc7b790..0000000000
--- a/third_party/rake-compiler-dock/build/patches/ruby-2.3.0/no_sendfile.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/configure b/configure
-index ebe3d8c..a336b73 100755
---- a/configure
-+++ b/configure
-@@ -18943,7 +18943,6 @@ do :
- ac_fn_c_check_func "$LINENO" "sendfile" "ac_cv_func_sendfile"
- if test "x$ac_cv_func_sendfile" = xyes; then :
- cat >>confdefs.h <<_ACEOF
--#define HAVE_SENDFILE 1
- _ACEOF
-
- fi
diff --git a/third_party/rake-compiler-dock/build/patches/ruby-2.4.0/no_sendfile.patch b/third_party/rake-compiler-dock/build/patches/ruby-2.4.0/no_sendfile.patch
deleted file mode 100644
index 915fc7b790..0000000000
--- a/third_party/rake-compiler-dock/build/patches/ruby-2.4.0/no_sendfile.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/configure b/configure
-index ebe3d8c..a336b73 100755
---- a/configure
-+++ b/configure
-@@ -18943,7 +18943,6 @@ do :
- ac_fn_c_check_func "$LINENO" "sendfile" "ac_cv_func_sendfile"
- if test "x$ac_cv_func_sendfile" = xyes; then :
- cat >>confdefs.h <<_ACEOF
--#define HAVE_SENDFILE 1
- _ACEOF
-
- fi
diff --git a/third_party/rake-compiler-dock/build/runas b/third_party/rake-compiler-dock/build/runas
deleted file mode 100755
index b29ce31fcc..0000000000
--- a/third_party/rake-compiler-dock/build/runas
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-groupadd -g "$GID" "$GROUP"
-mkdir -p /tmp/home
-useradd -g "$GID" -u "$UID" -G rvm,sudo -p "" -b /tmp/home -m "$USER"
-
-HOME=$(bash <<< "echo ~$USER")
-ln -s /usr/local/rake-compiler "$HOME"/.rake-compiler
-
-sudo -u "$USER" --set-home \
- BASH_ENV=/etc/rubybashrc \
- -- "$@"
diff --git a/third_party/rake-compiler-dock/build/sigfw.c b/third_party/rake-compiler-dock/build/sigfw.c
deleted file mode 100644
index 291d76cec8..0000000000
--- a/third_party/rake-compiler-dock/build/sigfw.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This program handles SIGINT and forwards it to another process.
- * It is intended to be run as PID 1.
- *
- * Docker starts processes with "docker run" as PID 1.
- * On Linux, the default signal handler for PID 1 ignores any signals.
- * Therefore Ctrl-C aka SIGINT is ignored per default.
- */
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-int pid = 0;
-
-void
-handle_sigint (int signum)
-{
- if(pid)
- kill(pid, SIGINT);
-}
-
-int main(int argc, char *argv[]){
- struct sigaction new_action;
- int status = -1;
-
- /* Set up the structure to specify the new action. */
- new_action.sa_handler = handle_sigint;
- sigemptyset (&new_action.sa_mask);
- new_action.sa_flags = 0;
-
- sigaction (SIGINT, &new_action, (void*)0);
-
- pid = fork();
- if(pid){
- wait(&status);
- return WEXITSTATUS(status);
- }else{
- status = execvp(argv[1], &argv[1]);
- perror("exec");
- return status;
- }
-}
diff --git a/third_party/rake-compiler-dock/build/strip_wrapper b/third_party/rake-compiler-dock/build/strip_wrapper
deleted file mode 100755
index 7f8a1346a1..0000000000
--- a/third_party/rake-compiler-dock/build/strip_wrapper
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env ruby
-
-# Strip file on local folder instead of a Virtualbox shared folder
-# to work around this bug: https://www.virtualbox.org/ticket/8463
-
-require 'tempfile'
-require 'fileutils'
-
-strip = "#{File.basename($0)}.bin"
-
-files = ARGV.reject{|f| f=~/^-/ }.map do |arg|
- tmp = Tempfile.new 'strip'
- tmp.close
- FileUtils.cp arg, tmp.path
- [tmp, arg]
-end
-
-options = ARGV.select{|f| f=~/^-/ } + files.map{|t,o| t.path }
-
-unless system( strip, *options )
- exit 127
-end
-code = $?.exitstatus
-
-files.each do |tmp, orig|
- FileUtils.rm orig
- FileUtils.cp tmp.path, orig
-end
-
-exit code
diff --git a/third_party/rake-compiler-dock/build/sudoers b/third_party/rake-compiler-dock/build/sudoers
deleted file mode 100644
index f9f9b97c95..0000000000
--- a/third_party/rake-compiler-dock/build/sudoers
+++ /dev/null
@@ -1 +0,0 @@
-Defaults env_keep += "http_proxy https_proxy ftp_proxy RCD_HOST_RUBY_PLATFORM RCD_HOST_RUBY_VERSION RCD_IMAGE RUBY_CC_VERSION"
diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD
index 7879a81c68..a71c85fa98 100644
--- a/third_party/zlib.BUILD
+++ b/third_party/zlib.BUILD
@@ -27,7 +27,7 @@ cc_library(
"zutil.h",
],
includes = [
- "include",
+ ".",
],
linkstatic = 1,
visibility = [
diff --git a/tools/bazel.rc b/tools/bazel.rc
new file mode 100644
index 0000000000..8af2fc981d
--- /dev/null
+++ b/tools/bazel.rc
@@ -0,0 +1,49 @@
+build --client_env=CC=clang
+build --copt -DGRPC_BAZEL_BUILD
+
+build:asan --strip=never
+build:asan --copt -fsanitize-coverage=edge
+build:asan --copt -fsanitize=address
+build:asan --copt -O0
+build:asan --copt -fno-omit-frame-pointer
+build:asan --copt -DGPR_NO_DIRECT_SYSCALLS
+build:asan --linkopt -fsanitize=address
+build:asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always
+build:asan --action_env=LSAN_OPTIONS=suppressions=lsan_suppressions.txt:report_objects=1
+
+build:msan --strip=never
+build:msan --copt -fsanitize-coverage=edge
+build:msan --copt -fsanitize=memory
+build:msan --copt -O0
+build:msan --copt -fsanitize-memory-track-origins
+build:msan --copt -fsanitize-memory-use-after-dtor
+build:msan --copt -fno-omit-frame-pointer
+build:msan --copt -fPIE
+build:msan --copt -DGPR_NO_DIRECT_SYSCALLS
+build:msan --linkopt -fsanitize=memory
+build:msan --linkopt -fPIE
+build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1
+
+build:tsan --strip=never
+build:tsan --copt -fsanitize=thread
+build:tsan --copt -fno-omit-frame-pointer
+build:tsan --copt -DGPR_NO_DIRECT_SYSCALLS
+build:tsan --copt -DGRPC_TSAN
+build:tsan --linkopt -fsanitize=thread
+build:tsan --action_env=TSAN_OPTIONS=suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1
+
+build:ubsan --strip=never
+build:ubsan --copt -fsanitize-coverage=edge
+build:ubsan --copt -fsanitize=undefined
+build:ubsan --copt -fno-omit-frame-pointer
+build:ubsan --copt -DGRPC_UBSAN
+build:ubsan --copt -DNDEBUG
+build:ubsan --copt -fno-sanitize=function,vptr
+build:ubsan --linkopt -fsanitize=undefined
+build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt
+
+build:basicprof --strip=never
+build:basicprof --copt -DNDEBUG
+build:basicprof --copt -O2
+build:basicprof --copt -DGRPC_BASIC_PROFILER
+build:basicprof --copt -DGRPC_TIMERS_RDTSC
diff --git a/tools/buildgen/build-cleaner.py b/tools/buildgen/build-cleaner.py
index 7b42844f75..a6b86fb242 100755
--- a/tools/buildgen/build-cleaner.py
+++ b/tools/buildgen/build-cleaner.py
@@ -22,65 +22,65 @@ import yaml
TEST = (os.environ.get('TEST', 'false') == 'true')
-_TOP_LEVEL_KEYS = ['settings', 'proto_deps', 'filegroups', 'libs', 'targets', 'vspackages']
+_TOP_LEVEL_KEYS = [
+ 'settings', 'proto_deps', 'filegroups', 'libs', 'targets', 'vspackages'
+]
_ELEM_KEYS = [
- 'name',
- 'gtest',
- 'cpu_cost',
- 'flaky',
- 'build',
- 'run',
- 'language',
- 'public_headers',
- 'headers',
- 'src',
- 'deps']
+ 'name', 'gtest', 'cpu_cost', 'flaky', 'build', 'run', 'language',
+ 'public_headers', 'headers', 'src', 'deps'
+]
+
def repr_ordered_dict(dumper, odict):
- return dumper.represent_mapping(u'tag:yaml.org,2002:map', odict.items())
+ return dumper.represent_mapping(u'tag:yaml.org,2002:map', odict.items())
+
yaml.add_representer(collections.OrderedDict, repr_ordered_dict)
+
def rebuild_as_ordered_dict(indict, special_keys):
- outdict = collections.OrderedDict()
- for key in sorted(indict.keys()):
- if '#' in key:
- outdict[key] = indict[key]
- for key in special_keys:
- if key in indict:
- outdict[key] = indict[key]
- for key in sorted(indict.keys()):
- if key in special_keys: continue
- if '#' in key: continue
- outdict[key] = indict[key]
- return outdict
+ outdict = collections.OrderedDict()
+ for key in sorted(indict.keys()):
+ if '#' in key:
+ outdict[key] = indict[key]
+ for key in special_keys:
+ if key in indict:
+ outdict[key] = indict[key]
+ for key in sorted(indict.keys()):
+ if key in special_keys: continue
+ if '#' in key: continue
+ outdict[key] = indict[key]
+ return outdict
+
def clean_elem(indict):
- for name in ['public_headers', 'headers', 'src']:
- if name not in indict: continue
- inlist = indict[name]
- protos = list(x for x in inlist if os.path.splitext(x)[1] == '.proto')
- others = set(x for x in inlist if x not in protos)
- indict[name] = protos + sorted(others)
- return rebuild_as_ordered_dict(indict, _ELEM_KEYS)
+ for name in ['public_headers', 'headers', 'src']:
+ if name not in indict: continue
+ inlist = indict[name]
+ protos = list(x for x in inlist if os.path.splitext(x)[1] == '.proto')
+ others = set(x for x in inlist if x not in protos)
+ indict[name] = protos + sorted(others)
+ return rebuild_as_ordered_dict(indict, _ELEM_KEYS)
+
for filename in sys.argv[1:]:
- with open(filename) as f:
- js = yaml.load(f)
- js = rebuild_as_ordered_dict(js, _TOP_LEVEL_KEYS)
- for grp in ['filegroups', 'libs', 'targets']:
- if grp not in js: continue
- js[grp] = sorted([clean_elem(x) for x in js[grp]],
- key=lambda x: (x.get('language', '_'), x['name']))
- output = yaml.dump(js, indent=2, width=80, default_flow_style=False)
- # massage out trailing whitespace
- lines = []
- for line in output.splitlines():
- lines.append(line.rstrip() + '\n')
- output = ''.join(lines)
- if TEST:
with open(filename) as f:
- assert f.read() == output
- else:
- with open(filename, 'w') as f:
- f.write(output)
+ js = yaml.load(f)
+ js = rebuild_as_ordered_dict(js, _TOP_LEVEL_KEYS)
+ for grp in ['filegroups', 'libs', 'targets']:
+ if grp not in js: continue
+ js[grp] = sorted(
+ [clean_elem(x) for x in js[grp]],
+ key=lambda x: (x.get('language', '_'), x['name']))
+ output = yaml.dump(js, indent=2, width=80, default_flow_style=False)
+ # massage out trailing whitespace
+ lines = []
+ for line in output.splitlines():
+ lines.append(line.rstrip() + '\n')
+ output = ''.join(lines)
+ if TEST:
+ with open(filename) as f:
+ assert f.read() == output
+ else:
+ with open(filename, 'w') as f:
+ f.write(output)
diff --git a/tools/buildgen/bunch.py b/tools/buildgen/bunch.py
index 813051ad60..f3bfc81102 100755
--- a/tools/buildgen/bunch.py
+++ b/tools/buildgen/bunch.py
@@ -11,43 +11,43 @@
# 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.
-
"""Allows dot-accessible dictionaries."""
class Bunch(dict):
- def __init__(self, d):
- dict.__init__(self, d)
- self.__dict__.update(d)
+ def __init__(self, d):
+ dict.__init__(self, d)
+ self.__dict__.update(d)
# Converts any kind of variable to a Bunch
def to_bunch(var):
- if isinstance(var, list):
- return [to_bunch(i) for i in var]
- if isinstance(var, dict):
- ret = {}
- for k, v in var.items():
- if isinstance(v, (list, dict)):
- v = to_bunch(v)
- ret[k] = v
- return Bunch(ret)
- else:
- return var
+ if isinstance(var, list):
+ return [to_bunch(i) for i in var]
+ if isinstance(var, dict):
+ ret = {}
+ for k, v in var.items():
+ if isinstance(v, (list, dict)):
+ v = to_bunch(v)
+ ret[k] = v
+ return Bunch(ret)
+ else:
+ return var
# Merges JSON 'add' into JSON 'dst'
def merge_json(dst, add):
- if isinstance(dst, dict) and isinstance(add, dict):
- for k, v in add.items():
- if k in dst:
- if k == '#': continue
- merge_json(dst[k], v)
- else:
- dst[k] = v
- elif isinstance(dst, list) and isinstance(add, list):
- dst.extend(add)
- else:
- raise Exception('Tried to merge incompatible objects %s %s\n\n%r\n\n%r' % (type(dst).__name__, type(add).__name__, dst, add))
-
+ if isinstance(dst, dict) and isinstance(add, dict):
+ for k, v in add.items():
+ if k in dst:
+ if k == '#': continue
+ merge_json(dst[k], v)
+ else:
+ dst[k] = v
+ elif isinstance(dst, list) and isinstance(add, list):
+ dst.extend(add)
+ else:
+ raise Exception(
+ 'Tried to merge incompatible objects %s %s\n\n%r\n\n%r' %
+ (type(dst).__name__, type(add).__name__, dst, add))
diff --git a/tools/buildgen/generate_projects.py b/tools/buildgen/generate_projects.py
index d29cd02152..bb5de9c42b 100755
--- a/tools/buildgen/generate_projects.py
+++ b/tools/buildgen/generate_projects.py
@@ -21,7 +21,9 @@ import shutil
import sys
import tempfile
import multiprocessing
-sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', 'run_tests', 'python_utils'))
+sys.path.append(
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', 'run_tests', 'python_utils'))
assert sys.argv[1:], 'run generate_projects.sh instead of this directly'
@@ -45,57 +47,58 @@ plugins = sorted(glob.glob('tools/buildgen/plugins/*.py'))
templates = args.templates
if not templates:
- for root, dirs, files in os.walk('templates'):
- for f in files:
- templates.append(os.path.join(root, f))
+ for root, dirs, files in os.walk('templates'):
+ for f in files:
+ templates.append(os.path.join(root, f))
pre_jobs = []
base_cmd = ['python2.7', 'tools/buildgen/mako_renderer.py']
cmd = base_cmd[:]
for plugin in plugins:
- cmd.append('-p')
- cmd.append(plugin)
+ cmd.append('-p')
+ cmd.append(plugin)
for js in json:
- cmd.append('-d')
- cmd.append(js)
+ cmd.append('-d')
+ cmd.append(js)
cmd.append('-w')
preprocessed_build = '.preprocessed_build'
cmd.append(preprocessed_build)
if args.output_merged is not None:
- cmd.append('-M')
- cmd.append(args.output_merged)
-pre_jobs.append(jobset.JobSpec(cmd, shortname='preprocess', timeout_seconds=None))
+ cmd.append('-M')
+ cmd.append(args.output_merged)
+pre_jobs.append(
+ jobset.JobSpec(cmd, shortname='preprocess', timeout_seconds=None))
jobs = []
for template in reversed(sorted(templates)):
- root, f = os.path.split(template)
- if os.path.splitext(f)[1] == '.template':
- out_dir = args.base + root[len('templates'):]
- out = out_dir + '/' + os.path.splitext(f)[0]
- if not os.path.exists(out_dir):
- os.makedirs(out_dir)
- cmd = base_cmd[:]
- cmd.append('-P')
- cmd.append(preprocessed_build)
- cmd.append('-o')
- if test is None:
- cmd.append(out)
- else:
- tf = tempfile.mkstemp()
- test[out] = tf[1]
- os.close(tf[0])
- cmd.append(test[out])
- cmd.append(args.base + '/' + root + '/' + f)
- jobs.append(jobset.JobSpec(cmd, shortname=out, timeout_seconds=None))
+ root, f = os.path.split(template)
+ if os.path.splitext(f)[1] == '.template':
+ out_dir = args.base + root[len('templates'):]
+ out = out_dir + '/' + os.path.splitext(f)[0]
+ if not os.path.exists(out_dir):
+ os.makedirs(out_dir)
+ cmd = base_cmd[:]
+ cmd.append('-P')
+ cmd.append(preprocessed_build)
+ cmd.append('-o')
+ if test is None:
+ cmd.append(out)
+ else:
+ tf = tempfile.mkstemp()
+ test[out] = tf[1]
+ os.close(tf[0])
+ cmd.append(test[out])
+ cmd.append(args.base + '/' + root + '/' + f)
+ jobs.append(jobset.JobSpec(cmd, shortname=out, timeout_seconds=None))
jobset.run(pre_jobs, maxjobs=args.jobs)
jobset.run(jobs, maxjobs=args.jobs)
if test is not None:
- for s, g in test.iteritems():
- if os.path.isfile(g):
- assert 0 == os.system('diff %s %s' % (s, g)), s
- os.unlink(g)
- else:
- assert 0 == os.system('diff -r %s %s' % (s, g)), s
- shutil.rmtree(g, ignore_errors=True)
+ for s, g in test.iteritems():
+ if os.path.isfile(g):
+ assert 0 == os.system('diff %s %s' % (s, g)), s
+ os.unlink(g)
+ else:
+ assert 0 == os.system('diff -r %s %s' % (s, g)), s
+ shutil.rmtree(g, ignore_errors=True)
diff --git a/tools/buildgen/mako_renderer.py b/tools/buildgen/mako_renderer.py
index 7738053003..acd72bd2e3 100755
--- a/tools/buildgen/mako_renderer.py
+++ b/tools/buildgen/mako_renderer.py
@@ -12,8 +12,6 @@
# 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.
-
-
"""Simple Mako renderer.
Just a wrapper around the mako rendering library.
@@ -27,7 +25,6 @@ import cPickle as pickle
import shutil
import sys
-
from mako.lookup import TemplateLookup
from mako.runtime import Context
from mako.template import Template
@@ -37,151 +34,158 @@ import yaml
# Imports a plugin
def import_plugin(name):
- _, base_ex = os.path.split(name)
- base, _ = os.path.splitext(base_ex)
+ _, base_ex = os.path.split(name)
+ base, _ = os.path.splitext(base_ex)
- with open(name, 'r') as plugin_file:
- plugin_code = plugin_file.read()
- plugin_module = imp.new_module(base)
- exec plugin_code in plugin_module.__dict__
- return plugin_module
+ with open(name, 'r') as plugin_file:
+ plugin_code = plugin_file.read()
+ plugin_module = imp.new_module(base)
+ exec plugin_code in plugin_module.__dict__
+ return plugin_module
def out(msg):
- print >> sys.stderr, msg
+ print >> sys.stderr, msg
def showhelp():
- out('mako-renderer.py [-o out] [-m cache] [-P preprocessed_input] [-d dict] [-d dict...]'
- ' [-t template] [-w preprocessed_output]')
+ out('mako-renderer.py [-o out] [-m cache] [-P preprocessed_input] [-d dict] [-d dict...]'
+ ' [-t template] [-w preprocessed_output]')
def main(argv):
- got_input = False
- module_directory = None
- preprocessed_output = None
- dictionary = {}
- json_dict = {}
- got_output = False
- plugins = []
- output_name = None
- got_preprocessed_input = False
- output_merged = None
-
- try:
- opts, args = getopt.getopt(argv, 'hM:m:d:o:p:t:P:w:')
- except getopt.GetoptError:
- out('Unknown option')
- showhelp()
- sys.exit(2)
-
- for opt, arg in opts:
- if opt == '-h':
- out('Displaying showhelp')
- showhelp()
- sys.exit()
- elif opt == '-o':
- if got_output:
- out('Got more than one output')
+ got_input = False
+ module_directory = None
+ preprocessed_output = None
+ dictionary = {}
+ json_dict = {}
+ got_output = False
+ plugins = []
+ output_name = None
+ got_preprocessed_input = False
+ output_merged = None
+
+ try:
+ opts, args = getopt.getopt(argv, 'hM:m:d:o:p:t:P:w:')
+ except getopt.GetoptError:
+ out('Unknown option')
showhelp()
- sys.exit(3)
- got_output = True
- output_name = arg
- elif opt == '-m':
- if module_directory is not None:
- out('Got more than one cache directory')
+ sys.exit(2)
+
+ for opt, arg in opts:
+ if opt == '-h':
+ out('Displaying showhelp')
+ showhelp()
+ sys.exit()
+ elif opt == '-o':
+ if got_output:
+ out('Got more than one output')
+ showhelp()
+ sys.exit(3)
+ got_output = True
+ output_name = arg
+ elif opt == '-m':
+ if module_directory is not None:
+ out('Got more than one cache directory')
+ showhelp()
+ sys.exit(4)
+ module_directory = arg
+ elif opt == '-M':
+ if output_merged is not None:
+ out('Got more than one output merged path')
+ showhelp()
+ sys.exit(5)
+ output_merged = arg
+ elif opt == '-P':
+ assert not got_preprocessed_input
+ assert json_dict == {}
+ sys.path.insert(0,
+ os.path.abspath(
+ os.path.join(
+ os.path.dirname(sys.argv[0]), 'plugins')))
+ with open(arg, 'r') as dict_file:
+ dictionary = pickle.load(dict_file)
+ got_preprocessed_input = True
+ elif opt == '-d':
+ assert not got_preprocessed_input
+ with open(arg, 'r') as dict_file:
+ bunch.merge_json(json_dict, yaml.load(dict_file.read()))
+ elif opt == '-p':
+ plugins.append(import_plugin(arg))
+ elif opt == '-w':
+ preprocessed_output = arg
+
+ if not got_preprocessed_input:
+ for plugin in plugins:
+ plugin.mako_plugin(json_dict)
+ if output_merged:
+ with open(output_merged, 'w') as yaml_file:
+ yaml_file.write(yaml.dump(json_dict))
+ for k, v in json_dict.items():
+ dictionary[k] = bunch.to_bunch(v)
+
+ if preprocessed_output:
+ with open(preprocessed_output, 'w') as dict_file:
+ pickle.dump(dictionary, dict_file)
+
+ cleared_dir = False
+ for arg in args:
+ got_input = True
+ with open(arg) as f:
+ srcs = list(yaml.load_all(f.read()))
+ for src in srcs:
+ if isinstance(src, basestring):
+ assert len(srcs) == 1
+ template = Template(
+ src,
+ filename=arg,
+ module_directory=module_directory,
+ lookup=TemplateLookup(directories=['.']))
+ with open(output_name, 'w') as output_file:
+ template.render_context(Context(output_file, **dictionary))
+ else:
+ # we have optional control data: this template represents
+ # a directory
+ if not cleared_dir:
+ if not os.path.exists(output_name):
+ pass
+ elif os.path.isfile(output_name):
+ os.unlink(output_name)
+ else:
+ shutil.rmtree(output_name, ignore_errors=True)
+ cleared_dir = True
+ items = []
+ if 'foreach' in src:
+ for el in dictionary[src['foreach']]:
+ if 'cond' in src:
+ args = dict(dictionary)
+ args['selected'] = el
+ if not eval(src['cond'], {}, args):
+ continue
+ items.append(el)
+ assert items
+ else:
+ items = [None]
+ for item in items:
+ args = dict(dictionary)
+ args['selected'] = item
+ item_output_name = os.path.join(
+ output_name,
+ Template(src['output_name']).render(**args))
+ if not os.path.exists(os.path.dirname(item_output_name)):
+ os.makedirs(os.path.dirname(item_output_name))
+ template = Template(
+ src['template'],
+ filename=arg,
+ module_directory=module_directory,
+ lookup=TemplateLookup(directories=['.']))
+ with open(item_output_name, 'w') as output_file:
+ template.render_context(Context(output_file, **args))
+
+ if not got_input and not preprocessed_output:
+ out('Got nothing to do')
showhelp()
- sys.exit(4)
- module_directory = arg
- elif opt == '-M':
- if output_merged is not None:
- out('Got more than one output merged path')
- showhelp()
- sys.exit(5)
- output_merged = arg
- elif opt == '-P':
- assert not got_preprocessed_input
- assert json_dict == {}
- sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), 'plugins')))
- with open(arg, 'r') as dict_file:
- dictionary = pickle.load(dict_file)
- got_preprocessed_input = True
- elif opt == '-d':
- assert not got_preprocessed_input
- with open(arg, 'r') as dict_file:
- bunch.merge_json(json_dict, yaml.load(dict_file.read()))
- elif opt == '-p':
- plugins.append(import_plugin(arg))
- elif opt == '-w':
- preprocessed_output = arg
-
- if not got_preprocessed_input:
- for plugin in plugins:
- plugin.mako_plugin(json_dict)
- if output_merged:
- with open(output_merged, 'w') as yaml_file:
- yaml_file.write(yaml.dump(json_dict))
- for k, v in json_dict.items():
- dictionary[k] = bunch.to_bunch(v)
-
- if preprocessed_output:
- with open(preprocessed_output, 'w') as dict_file:
- pickle.dump(dictionary, dict_file)
-
- cleared_dir = False
- for arg in args:
- got_input = True
- with open(arg) as f:
- srcs = list(yaml.load_all(f.read()))
- for src in srcs:
- if isinstance(src, basestring):
- assert len(srcs) == 1
- template = Template(src,
- filename=arg,
- module_directory=module_directory,
- lookup=TemplateLookup(directories=['.']))
- with open(output_name, 'w') as output_file:
- template.render_context(Context(output_file, **dictionary))
- else:
- # we have optional control data: this template represents
- # a directory
- if not cleared_dir:
- if not os.path.exists(output_name):
- pass
- elif os.path.isfile(output_name):
- os.unlink(output_name)
- else:
- shutil.rmtree(output_name, ignore_errors=True)
- cleared_dir = True
- items = []
- if 'foreach' in src:
- for el in dictionary[src['foreach']]:
- if 'cond' in src:
- args = dict(dictionary)
- args['selected'] = el
- if not eval(src['cond'], {}, args):
- continue
- items.append(el)
- assert items
- else:
- items = [None]
- for item in items:
- args = dict(dictionary)
- args['selected'] = item
- item_output_name = os.path.join(
- output_name, Template(src['output_name']).render(**args))
- if not os.path.exists(os.path.dirname(item_output_name)):
- os.makedirs(os.path.dirname(item_output_name))
- template = Template(src['template'],
- filename=arg,
- module_directory=module_directory,
- lookup=TemplateLookup(directories=['.']))
- with open(item_output_name, 'w') as output_file:
- template.render_context(Context(output_file, **args))
-
- if not got_input and not preprocessed_output:
- out('Got nothing to do')
- showhelp()
+
if __name__ == '__main__':
- main(sys.argv[1:])
+ main(sys.argv[1:])
diff --git a/tools/buildgen/plugins/expand_bin_attrs.py b/tools/buildgen/plugins/expand_bin_attrs.py
index 6ad6e9cb3d..d5acd8d06c 100755
--- a/tools/buildgen/plugins/expand_bin_attrs.py
+++ b/tools/buildgen/plugins/expand_bin_attrs.py
@@ -11,7 +11,6 @@
# 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.
-
"""Buildgen expand binary attributes plugin.
This fills in any optional attributes.
@@ -20,7 +19,7 @@ This fills in any optional attributes.
def mako_plugin(dictionary):
- """The exported plugin code for expand_filegroups.
+ """The exported plugin code for expand_filegroups.
The list of libs in the build.yaml file can contain "filegroups" tags.
These refer to the filegroups in the root object. We will expand and
@@ -28,20 +27,20 @@ def mako_plugin(dictionary):
"""
- targets = dictionary.get('targets')
- default_platforms = ['windows', 'posix', 'linux', 'mac']
-
- for tgt in targets:
- tgt['flaky'] = tgt.get('flaky', False)
- tgt['platforms'] = sorted(tgt.get('platforms', default_platforms))
- tgt['ci_platforms'] = sorted(tgt.get('ci_platforms', tgt['platforms']))
- tgt['boringssl'] = tgt.get('boringssl', False)
- tgt['zlib'] = tgt.get('zlib', False)
- tgt['ares'] = tgt.get('ares', False)
- tgt['gtest'] = tgt.get('gtest', False)
-
- libs = dictionary.get('libs')
- for lib in libs:
- lib['boringssl'] = lib.get('boringssl', False)
- lib['zlib'] = lib.get('zlib', False)
- lib['ares'] = lib.get('ares', False)
+ targets = dictionary.get('targets')
+ default_platforms = ['windows', 'posix', 'linux', 'mac']
+
+ for tgt in targets:
+ tgt['flaky'] = tgt.get('flaky', False)
+ tgt['platforms'] = sorted(tgt.get('platforms', default_platforms))
+ tgt['ci_platforms'] = sorted(tgt.get('ci_platforms', tgt['platforms']))
+ tgt['boringssl'] = tgt.get('boringssl', False)
+ tgt['zlib'] = tgt.get('zlib', False)
+ tgt['ares'] = tgt.get('ares', False)
+ tgt['gtest'] = tgt.get('gtest', False)
+
+ libs = dictionary.get('libs')
+ for lib in libs:
+ lib['boringssl'] = lib.get('boringssl', False)
+ lib['zlib'] = lib.get('zlib', False)
+ lib['ares'] = lib.get('ares', False)
diff --git a/tools/buildgen/plugins/expand_filegroups.py b/tools/buildgen/plugins/expand_filegroups.py
index dc073d72b8..99d9463b3f 100755
--- a/tools/buildgen/plugins/expand_filegroups.py
+++ b/tools/buildgen/plugins/expand_filegroups.py
@@ -11,7 +11,6 @@
# 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.
-
"""Buildgen expand filegroups plugin.
This takes the list of libs from our yaml dictionary,
@@ -21,132 +20,134 @@ and expands any and all filegroup.
def excluded(filename, exclude_res):
- for r in exclude_res:
- if r.search(filename):
- return True
- return False
+ for r in exclude_res:
+ if r.search(filename):
+ return True
+ return False
def uniquify(lst):
- out = []
- for el in lst:
- if el not in out:
- out.append(el)
- return out
+ out = []
+ for el in lst:
+ if el not in out:
+ out.append(el)
+ return out
FILEGROUP_LISTS = ['src', 'headers', 'public_headers', 'deps']
-
FILEGROUP_DEFAULTS = {
- 'language': 'c',
- 'boringssl': False,
- 'zlib': False,
- 'ares': False,
+ 'language': 'c',
+ 'boringssl': False,
+ 'zlib': False,
+ 'ares': False,
}
def mako_plugin(dictionary):
- """The exported plugin code for expand_filegroups.
+ """The exported plugin code for expand_filegroups.
The list of libs in the build.yaml file can contain "filegroups" tags.
These refer to the filegroups in the root object. We will expand and
merge filegroups on the src, headers and public_headers properties.
"""
- libs = dictionary.get('libs')
- targets = dictionary.get('targets')
- filegroups_list = dictionary.get('filegroups')
- filegroups = {}
-
- for fg in filegroups_list:
- for lst in FILEGROUP_LISTS:
- fg[lst] = fg.get(lst, [])
- fg['own_%s' % lst] = list(fg[lst])
- for attr, val in FILEGROUP_DEFAULTS.iteritems():
- if attr not in fg:
- fg[attr] = val
-
- todo = list(filegroups_list)
- skips = 0
-
- while todo:
- assert skips != len(todo), "infinite loop in filegroup uses clauses: %r" % [t['name'] for t in todo]
- # take the first element of the todo list
- cur = todo[0]
- todo = todo[1:]
- # check all uses filegroups are present (if no, skip and come back later)
- skip = False
- for uses in cur.get('uses', []):
- if uses not in filegroups:
- skip = True
- if skip:
- skips += 1
- todo.append(cur)
- else:
- skips = 0
- assert 'plugins' not in cur
- plugins = []
- for uses in cur.get('uses', []):
- for plugin in filegroups[uses]['plugins']:
- if plugin not in plugins:
- plugins.append(plugin)
+ libs = dictionary.get('libs')
+ targets = dictionary.get('targets')
+ filegroups_list = dictionary.get('filegroups')
+ filegroups = {}
+
+ for fg in filegroups_list:
for lst in FILEGROUP_LISTS:
- vals = cur.get(lst, [])
- vals.extend(filegroups[uses].get(lst, []))
- cur[lst] = vals
- cur_plugin_name = cur.get('plugin')
- if cur_plugin_name:
- plugins.append(cur_plugin_name)
- cur['plugins'] = plugins
- filegroups[cur['name']] = cur
-
- # build reverse dependency map
- things = {}
- for thing in dictionary['libs'] + dictionary['targets'] + dictionary['filegroups']:
- things[thing['name']] = thing
- thing['used_by'] = []
- thing_deps = lambda t: t.get('uses', []) + t.get('filegroups', []) + t.get('deps', [])
- for thing in things.itervalues():
- done = set()
- todo = thing_deps(thing)
+ fg[lst] = fg.get(lst, [])
+ fg['own_%s' % lst] = list(fg[lst])
+ for attr, val in FILEGROUP_DEFAULTS.iteritems():
+ if attr not in fg:
+ fg[attr] = val
+
+ todo = list(filegroups_list)
+ skips = 0
+
while todo:
- cur = todo[0]
- todo = todo[1:]
- if cur in done: continue
- things[cur]['used_by'].append(thing['name'])
- todo.extend(thing_deps(things[cur]))
- done.add(cur)
-
- # the above expansion can introduce duplicate filenames: contract them here
- for fg in filegroups.itervalues():
- for lst in FILEGROUP_LISTS:
- fg[lst] = uniquify(fg.get(lst, []))
-
- for tgt in dictionary['targets']:
- for lst in FILEGROUP_LISTS:
- tgt[lst] = tgt.get(lst, [])
- tgt['own_%s' % lst] = list(tgt[lst])
-
- for lib in libs + targets:
- assert 'plugins' not in lib
- plugins = []
- for lst in FILEGROUP_LISTS:
- vals = lib.get(lst, [])
- lib[lst] = list(vals)
- lib['own_%s' % lst] = list(vals)
- for fg_name in lib.get('filegroups', []):
- fg = filegroups[fg_name]
- for plugin in fg['plugins']:
- if plugin not in plugins:
- plugins.append(plugin)
- for lst in FILEGROUP_LISTS:
- vals = lib.get(lst, [])
- vals.extend(fg.get(lst, []))
- lib[lst] = vals
- lib['plugins'] = plugins
- if lib.get('generate_plugin_registry', False):
- lib['src'].append('src/core/plugin_registry/%s_plugin_registry.c' %
- lib['name'])
- for lst in FILEGROUP_LISTS:
- lib[lst] = uniquify(lib.get(lst, []))
+ assert skips != len(
+ todo), "infinite loop in filegroup uses clauses: %r" % [
+ t['name'] for t in todo
+ ]
+ # take the first element of the todo list
+ cur = todo[0]
+ todo = todo[1:]
+ # check all uses filegroups are present (if no, skip and come back later)
+ skip = False
+ for uses in cur.get('uses', []):
+ if uses not in filegroups:
+ skip = True
+ if skip:
+ skips += 1
+ todo.append(cur)
+ else:
+ skips = 0
+ assert 'plugins' not in cur
+ plugins = []
+ for uses in cur.get('uses', []):
+ for plugin in filegroups[uses]['plugins']:
+ if plugin not in plugins:
+ plugins.append(plugin)
+ for lst in FILEGROUP_LISTS:
+ vals = cur.get(lst, [])
+ vals.extend(filegroups[uses].get(lst, []))
+ cur[lst] = vals
+ cur_plugin_name = cur.get('plugin')
+ if cur_plugin_name:
+ plugins.append(cur_plugin_name)
+ cur['plugins'] = plugins
+ filegroups[cur['name']] = cur
+
+ # build reverse dependency map
+ things = {}
+ for thing in dictionary['libs'] + dictionary['targets'] + dictionary['filegroups']:
+ things[thing['name']] = thing
+ thing['used_by'] = []
+ thing_deps = lambda t: t.get('uses', []) + t.get('filegroups', []) + t.get('deps', [])
+ for thing in things.itervalues():
+ done = set()
+ todo = thing_deps(thing)
+ while todo:
+ cur = todo[0]
+ todo = todo[1:]
+ if cur in done: continue
+ things[cur]['used_by'].append(thing['name'])
+ todo.extend(thing_deps(things[cur]))
+ done.add(cur)
+
+ # the above expansion can introduce duplicate filenames: contract them here
+ for fg in filegroups.itervalues():
+ for lst in FILEGROUP_LISTS:
+ fg[lst] = uniquify(fg.get(lst, []))
+
+ for tgt in dictionary['targets']:
+ for lst in FILEGROUP_LISTS:
+ tgt[lst] = tgt.get(lst, [])
+ tgt['own_%s' % lst] = list(tgt[lst])
+
+ for lib in libs + targets:
+ assert 'plugins' not in lib
+ plugins = []
+ for lst in FILEGROUP_LISTS:
+ vals = lib.get(lst, [])
+ lib[lst] = list(vals)
+ lib['own_%s' % lst] = list(vals)
+ for fg_name in lib.get('filegroups', []):
+ fg = filegroups[fg_name]
+ for plugin in fg['plugins']:
+ if plugin not in plugins:
+ plugins.append(plugin)
+ for lst in FILEGROUP_LISTS:
+ vals = lib.get(lst, [])
+ vals.extend(fg.get(lst, []))
+ lib[lst] = vals
+ lib['plugins'] = plugins
+ if lib.get('generate_plugin_registry', False):
+ lib['src'].append(
+ 'src/core/plugin_registry/%s_plugin_registry.cc' % lib['name'])
+ for lst in FILEGROUP_LISTS:
+ lib[lst] = uniquify(lib.get(lst, []))
diff --git a/tools/buildgen/plugins/expand_version.py b/tools/buildgen/plugins/expand_version.py
index d602e3421b..facf349b0c 100755
--- a/tools/buildgen/plugins/expand_version.py
+++ b/tools/buildgen/plugins/expand_version.py
@@ -11,7 +11,6 @@
# 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.
-
"""Buildgen package version plugin
This parses the list of targets from the yaml build file, and creates
@@ -19,85 +18,97 @@ a custom version string for each language's package.
"""
-
import re
LANGUAGES = [
- 'core',
- 'cpp',
- 'csharp',
- 'node',
- 'objc',
- 'php',
- 'python',
- 'ruby',
- ]
+ 'core',
+ 'cpp',
+ 'csharp',
+ 'objc',
+ 'php',
+ 'python',
+ 'ruby',
+]
+
class Version:
- def __init__(self, s):
- self.tag = None
- if '-' in s:
- s, self.tag = s.split('-')
- self.major, self.minor, self.patch = [int(x) for x in s.split('.')]
-
- def __str__(self):
- """Version string in a somewhat idiomatic style for most languages"""
- s = '%d.%d.%d' % (self.major, self.minor, self.patch)
- if self.tag:
- s += '-%s' % self.tag
- return s
-
- def pep440(self):
- """Version string in Python PEP440 style"""
- s = '%d.%d.%d' % (self.major, self.minor, self.patch)
- if self.tag:
- # we need to translate from grpc version tags to pep440 version
- # tags; this code is likely to be a little ad-hoc
- if self.tag == 'dev':
- s += '.dev0'
- elif len(self.tag) >= 3 and self.tag[0:3] == 'pre':
- s += 'rc%d' % int(self.tag[3:])
- else:
- raise Exception('Don\'t know how to translate version tag "%s" to pep440' % self.tag)
- return s
-
- def ruby(self):
- """Version string in Ruby style"""
- if self.tag:
- return '%d.%d.%d.%s' % (self.major, self.minor, self.patch, self.tag)
- else:
- return '%d.%d.%d' % (self.major, self.minor, self.patch)
-
- def php(self):
- """Version string for PHP PECL package"""
- s = '%d.%d.%d' % (self.major, self.minor, self.patch)
- if self.tag:
- if self.tag == 'dev':
- s += 'dev'
- elif len(self.tag) >= 3 and self.tag[0:3] == 'pre':
- s += 'RC%d' % int(self.tag[3:])
- else:
- raise Exception('Don\'t know how to translate version tag "%s" to PECL version' % self.tag)
- return s
-
- def php_composer(self):
- """Version string for PHP Composer package"""
- return '%d.%d.%d' % (self.major, self.minor, self.patch)
-
+ def __init__(self, s):
+ self.tag = None
+ if '-' in s:
+ s, self.tag = s.split('-')
+ self.major, self.minor, self.patch = [int(x) for x in s.split('.')]
+
+ def __str__(self):
+ """Version string in a somewhat idiomatic style for most languages"""
+ s = '%d.%d.%d' % (self.major, self.minor, self.patch)
+ if self.tag:
+ s += '-%s' % self.tag
+ return s
+
+ def pep440(self):
+ """Version string in Python PEP440 style"""
+ s = '%d.%d.%d' % (self.major, self.minor, self.patch)
+ if self.tag:
+ # we need to translate from grpc version tags to pep440 version
+ # tags; this code is likely to be a little ad-hoc
+ if self.tag == 'dev':
+ s += '.dev0'
+ elif len(self.tag) >= 3 and self.tag[0:3] == 'pre':
+ s += 'rc%d' % int(self.tag[3:])
+ else:
+ raise Exception(
+ 'Don\'t know how to translate version tag "%s" to pep440' %
+ self.tag)
+ return s
+
+ def ruby(self):
+ """Version string in Ruby style"""
+ if self.tag:
+ return '%d.%d.%d.%s' % (self.major, self.minor, self.patch,
+ self.tag)
+ else:
+ return '%d.%d.%d' % (self.major, self.minor, self.patch)
+
+ def php(self):
+ """Version string for PHP PECL package"""
+ s = '%d.%d.%d' % (self.major, self.minor, self.patch)
+ if self.tag:
+ if self.tag == 'dev':
+ s += 'dev'
+ elif len(self.tag) >= 3 and self.tag[0:3] == 'pre':
+ s += 'RC%d' % int(self.tag[3:])
+ else:
+ raise Exception(
+ 'Don\'t know how to translate version tag "%s" to PECL version'
+ % self.tag)
+ return s
+
+ def php_stability(self):
+ """stability string for PHP PECL package.xml file"""
+ if self.tag:
+ return 'beta'
+ else:
+ return 'stable'
+
+ def php_composer(self):
+ """Version string for PHP Composer package"""
+ return '%d.%d.%d' % (self.major, self.minor, self.patch)
+
+
def mako_plugin(dictionary):
- """Expand version numbers:
+ """Expand version numbers:
- for each language, ensure there's a language_version tag in
settings (defaulting to the master version tag)
- expand version strings to major, minor, patch, and tag
"""
- settings = dictionary['settings']
- master_version = Version(settings['version'])
- settings['version'] = master_version
- for language in LANGUAGES:
- version_tag = '%s_version' % language
- if version_tag in settings:
- settings[version_tag] = Version(settings[version_tag])
- else:
- settings[version_tag] = master_version
+ settings = dictionary['settings']
+ master_version = Version(settings['version'])
+ settings['version'] = master_version
+ for language in LANGUAGES:
+ version_tag = '%s_version' % language
+ if version_tag in settings:
+ settings[version_tag] = Version(settings[version_tag])
+ else:
+ settings[version_tag] = master_version
diff --git a/tools/buildgen/plugins/generate_vsprojects.py b/tools/buildgen/plugins/generate_vsprojects.py
index 06755f62f5..f7ef49288f 100755
--- a/tools/buildgen/plugins/generate_vsprojects.py
+++ b/tools/buildgen/plugins/generate_vsprojects.py
@@ -11,7 +11,6 @@
# 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.
-
"""Buildgen vsprojects plugin.
This parses the list of libraries, and generates globals "vsprojects"
@@ -19,62 +18,68 @@ and "vsproject_dict", to be used by the visual studio generators.
"""
-
import hashlib
import re
def mako_plugin(dictionary):
- """The exported plugin code for generate_vsprojeccts
+ """The exported plugin code for generate_vsprojeccts
We want to help the work of the visual studio generators.
"""
- libs = dictionary.get('libs', [])
- targets = dictionary.get('targets', [])
-
- for lib in libs:
- lib['is_library'] = True
- for target in targets:
- target['is_library'] = False
-
- projects = []
- projects.extend(libs)
- projects.extend(targets)
- for target in projects:
- if 'build' in target and target['build'] == 'test':
- default_test_dir = 'test'
- else:
- default_test_dir = '.'
- if 'vs_config_type' not in target:
- if 'build' in target and target['build'] == 'test':
- target['vs_config_type'] = 'Application'
- else:
- target['vs_config_type'] = 'StaticLibrary'
- if 'vs_packages' not in target:
- target['vs_packages'] = []
- if 'vs_props' not in target:
- target['vs_props'] = []
- target['vs_proj_dir'] = target.get('vs_proj_dir', default_test_dir)
- if target.get('vs_project_guid', None) is None and 'windows' in target.get('platforms', ['windows']):
- name = target['name']
- guid = re.sub('(........)(....)(....)(....)(.*)',
- r'{\1-\2-\3-\4-\5}',
- hashlib.md5(name).hexdigest())
- target['vs_project_guid'] = guid.upper()
- # Exclude projects without a visual project guid, such as the tests.
- projects = [project for project in projects
- if project.get('vs_project_guid', None)]
-
- projects = [project for project in projects
- if project['language'] != 'c++' or project['build'] == 'all' or project['build'] == 'protoc' or (project['language'] == 'c++' and (project['build'] == 'test' or project['build'] == 'private'))]
-
- project_dict = dict([(p['name'], p) for p in projects])
-
- packages = dictionary.get('vspackages', [])
- packages_dict = dict([(p['name'], p) for p in packages])
-
- dictionary['vsprojects'] = projects
- dictionary['vsproject_dict'] = project_dict
- dictionary['vspackages_dict'] = packages_dict
+ libs = dictionary.get('libs', [])
+ targets = dictionary.get('targets', [])
+
+ for lib in libs:
+ lib['is_library'] = True
+ for target in targets:
+ target['is_library'] = False
+
+ projects = []
+ projects.extend(libs)
+ projects.extend(targets)
+ for target in projects:
+ if 'build' in target and target['build'] == 'test':
+ default_test_dir = 'test'
+ else:
+ default_test_dir = '.'
+ if 'vs_config_type' not in target:
+ if 'build' in target and target['build'] == 'test':
+ target['vs_config_type'] = 'Application'
+ else:
+ target['vs_config_type'] = 'StaticLibrary'
+ if 'vs_packages' not in target:
+ target['vs_packages'] = []
+ if 'vs_props' not in target:
+ target['vs_props'] = []
+ target['vs_proj_dir'] = target.get('vs_proj_dir', default_test_dir)
+ if target.get('vs_project_guid',
+ None) is None and 'windows' in target.get(
+ 'platforms', ['windows']):
+ name = target['name']
+ guid = re.sub('(........)(....)(....)(....)(.*)',
+ r'{\1-\2-\3-\4-\5}',
+ hashlib.md5(name).hexdigest())
+ target['vs_project_guid'] = guid.upper()
+ # Exclude projects without a visual project guid, such as the tests.
+ projects = [
+ project for project in projects if project.get('vs_project_guid', None)
+ ]
+
+ projects = [
+ project for project in projects
+ if project['language'] != 'c++' or project['build'] == 'all' or
+ project['build'] == 'protoc' or (project['language'] == 'c++' and (
+ project['build'] == 'test' or project['build'] == 'private'))
+ ]
+
+ project_dict = dict([(p['name'], p) for p in projects])
+
+ packages = dictionary.get('vspackages', [])
+ packages_dict = dict([(p['name'], p) for p in packages])
+
+ dictionary['vsprojects'] = projects
+ dictionary['vsproject_dict'] = project_dict
+ dictionary['vspackages_dict'] = packages_dict
diff --git a/tools/buildgen/plugins/list_api.py b/tools/buildgen/plugins/list_api.py
index bed98dafe3..f7ecb97666 100755
--- a/tools/buildgen/plugins/list_api.py
+++ b/tools/buildgen/plugins/list_api.py
@@ -21,44 +21,47 @@ import re
import sys
import yaml
-
_RE_API = r'(?:GPRAPI|GRPCAPI|CENSUSAPI)([^;]*);'
def list_c_apis(filenames):
- for filename in filenames:
- with open(filename, 'r') as f:
- text = f.read()
- for m in re.finditer(_RE_API, text):
- api_declaration = re.sub('[ \r\n\t]+', ' ', m.group(1))
- type_and_name, args_and_close = api_declaration.split('(', 1)
- args = args_and_close[:args_and_close.rfind(')')].strip()
- last_space = type_and_name.rfind(' ')
- last_star = type_and_name.rfind('*')
- type_end = max(last_space, last_star)
- return_type = type_and_name[0:type_end+1].strip()
- name = type_and_name[type_end+1:].strip()
- yield {'return_type': return_type, 'name': name, 'arguments': args, 'header': filename}
+ for filename in filenames:
+ with open(filename, 'r') as f:
+ text = f.read()
+ for m in re.finditer(_RE_API, text):
+ api_declaration = re.sub('[ \r\n\t]+', ' ', m.group(1))
+ type_and_name, args_and_close = api_declaration.split('(', 1)
+ args = args_and_close[:args_and_close.rfind(')')].strip()
+ last_space = type_and_name.rfind(' ')
+ last_star = type_and_name.rfind('*')
+ type_end = max(last_space, last_star)
+ return_type = type_and_name[0:type_end + 1].strip()
+ name = type_and_name[type_end + 1:].strip()
+ yield {
+ 'return_type': return_type,
+ 'name': name,
+ 'arguments': args,
+ 'header': filename
+ }
def headers_under(directory):
- for root, dirnames, filenames in os.walk(directory):
- for filename in fnmatch.filter(filenames, '*.h'):
- yield os.path.join(root, filename)
+ for root, dirnames, filenames in os.walk(directory):
+ for filename in fnmatch.filter(filenames, '*.h'):
+ yield os.path.join(root, filename)
def mako_plugin(dictionary):
- apis = []
- headers = []
+ apis = []
+ headers = []
- for lib in dictionary['libs']:
- if lib['name'] in ['grpc', 'gpr']:
- headers.extend(lib['public_headers'])
+ for lib in dictionary['libs']:
+ if lib['name'] in ['grpc', 'gpr']:
+ headers.extend(lib['public_headers'])
- apis.extend(list_c_apis(sorted(set(headers))))
- dictionary['c_apis'] = apis
+ apis.extend(list_c_apis(sorted(set(headers))))
+ dictionary['c_apis'] = apis
if __name__ == '__main__':
- print yaml.dump([api for api in list_c_apis(headers_under('include/grpc'))])
-
+ print yaml.dump([api for api in list_c_apis(headers_under('include/grpc'))])
diff --git a/tools/buildgen/plugins/list_protos.py b/tools/buildgen/plugins/list_protos.py
index 07a860c8af..0aa5fe55d2 100755
--- a/tools/buildgen/plugins/list_protos.py
+++ b/tools/buildgen/plugins/list_protos.py
@@ -11,7 +11,6 @@
# 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.
-
"""Buildgen .proto files list plugin.
This parses the list of targets from the yaml build file, and creates
@@ -19,12 +18,11 @@ a list called "protos" that contains all of the proto file names.
"""
-
import re
def mako_plugin(dictionary):
- """The exported plugin code for list_protos.
+ """The exported plugin code for list_protos.
Some projects generators may want to get the full list of unique .proto files
that are being included in a project. This code extracts all files referenced
@@ -33,23 +31,23 @@ def mako_plugin(dictionary):
"""
- libs = dictionary.get('libs', [])
- targets = dictionary.get('targets', [])
+ libs = dictionary.get('libs', [])
+ targets = dictionary.get('targets', [])
- proto_re = re.compile('(.*)\\.proto')
+ proto_re = re.compile('(.*)\\.proto')
- protos = set()
- for lib in libs:
- for src in lib.get('src', []):
- m = proto_re.match(src)
- if m:
- protos.add(m.group(1))
- for tgt in targets:
- for src in tgt.get('src', []):
- m = proto_re.match(src)
- if m:
- protos.add(m.group(1))
+ protos = set()
+ for lib in libs:
+ for src in lib.get('src', []):
+ m = proto_re.match(src)
+ if m:
+ protos.add(m.group(1))
+ for tgt in targets:
+ for src in tgt.get('src', []):
+ m = proto_re.match(src)
+ if m:
+ protos.add(m.group(1))
- protos = sorted(protos)
+ protos = sorted(protos)
- dictionary['protos'] = protos
+ dictionary['protos'] = protos
diff --git a/tools/buildgen/plugins/make_fuzzer_tests.py b/tools/buildgen/plugins/make_fuzzer_tests.py
index 6d318fe831..f644a7c272 100644
--- a/tools/buildgen/plugins/make_fuzzer_tests.py
+++ b/tools/buildgen/plugins/make_fuzzer_tests.py
@@ -11,35 +11,37 @@
# 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.
-
"""Create tests for each fuzzer"""
import copy
import glob
+
def mako_plugin(dictionary):
- targets = dictionary['targets']
- tests = dictionary['tests']
- for tgt in targets:
- if tgt['build'] == 'fuzzer':
- new_target = copy.deepcopy(tgt)
- new_target['build'] = 'test'
- new_target['name'] += '_one_entry'
- new_target['run'] = False
- new_target['src'].append('test/core/util/one_corpus_entry_fuzzer.c')
- new_target['own_src'].append('test/core/util/one_corpus_entry_fuzzer.c')
- targets.append(new_target)
- for corpus in new_target['corpus_dirs']:
- for fn in sorted(glob.glob('%s/*' % corpus)):
- tests.append({
- 'name': new_target['name'],
- 'args': [fn],
- 'exclude_iomgrs': ['uv'],
- 'exclude_configs': ['tsan'],
- 'uses_polling': False,
- 'platforms': ['mac', 'linux'],
- 'ci_platforms': ['linux'],
- 'flaky': False,
- 'language': 'c',
- 'cpu_cost': 0.1,
- })
+ targets = dictionary['targets']
+ tests = dictionary['tests']
+ for tgt in targets:
+ if tgt['build'] == 'fuzzer':
+ new_target = copy.deepcopy(tgt)
+ new_target['build'] = 'test'
+ new_target['name'] += '_one_entry'
+ new_target['run'] = False
+ new_target['src'].append(
+ 'test/core/util/one_corpus_entry_fuzzer.cc')
+ new_target['own_src'].append(
+ 'test/core/util/one_corpus_entry_fuzzer.cc')
+ targets.append(new_target)
+ for corpus in new_target['corpus_dirs']:
+ for fn in sorted(glob.glob('%s/*' % corpus)):
+ tests.append({
+ 'name': new_target['name'],
+ 'args': [fn],
+ 'exclude_iomgrs': ['uv'],
+ 'exclude_configs': ['tsan'],
+ 'uses_polling': False,
+ 'platforms': ['mac', 'linux'],
+ 'ci_platforms': ['linux'],
+ 'flaky': False,
+ 'language': 'c',
+ 'cpu_cost': 0.1,
+ })
diff --git a/tools/buildgen/plugins/transitive_dependencies.py b/tools/buildgen/plugins/transitive_dependencies.py
index 5f37ed13a1..258e10bff5 100644
--- a/tools/buildgen/plugins/transitive_dependencies.py
+++ b/tools/buildgen/plugins/transitive_dependencies.py
@@ -11,7 +11,6 @@
# 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.
-
"""Buildgen transitive dependencies
This takes the list of libs, node_modules, and targets from our
@@ -20,36 +19,40 @@ of the list of dependencies.
"""
+
def get_lib(libs, name):
- try:
- return next(lib for lib in libs if lib['name']==name)
- except StopIteration:
- return None
+ try:
+ return next(lib for lib in libs if lib['name'] == name)
+ except StopIteration:
+ return None
+
def transitive_deps(lib, libs):
- if lib is not None and 'deps' in lib:
- # Recursively call transitive_deps on each dependency, and take the union
- return set.union(set(lib['deps']),
- *[set(transitive_deps(get_lib(libs, dep), libs))
- for dep in lib['deps']])
- else:
- return set()
+ if lib is not None and 'deps' in lib:
+ # Recursively call transitive_deps on each dependency, and take the union
+ return set.union(
+ set(lib['deps']), *[
+ set(transitive_deps(get_lib(libs, dep), libs))
+ for dep in lib['deps']
+ ])
+ else:
+ return set()
+
def mako_plugin(dictionary):
- """The exported plugin code for transitive_dependencies.
+ """The exported plugin code for transitive_dependencies.
- Each item in libs, node_modules, and targets can have a deps list.
- We add a transitive_deps property to each with the transitive closure
- of those dependency lists.
+ Iterate over each list and check each item for a deps list. We add a
+ transitive_deps property to each with the transitive closure of those
+ dependency lists.
"""
- libs = dictionary.get('libs')
- node_modules = dictionary.get('node_modules')
- targets = dictionary.get('targets')
+ libs = dictionary.get('libs')
- for target_list in (libs, targets, node_modules):
- for target in target_list:
- target['transitive_deps'] = transitive_deps(target, libs)
+ for target_name, target_list in dictionary.items():
+ for target in target_list:
+ if isinstance(target, dict) and 'deps' in target:
+ target['transitive_deps'] = transitive_deps(target, libs)
- python_dependencies = dictionary.get('python_dependencies')
- python_dependencies['transitive_deps'] = (
- transitive_deps(python_dependencies, libs))
+ python_dependencies = dictionary.get('python_dependencies')
+ python_dependencies['transitive_deps'] = (transitive_deps(
+ python_dependencies, libs))
diff --git a/tools/codegen/core/gen_header_frame.py b/tools/codegen/core/gen_header_frame.py
index 5375c14fd6..7219d4dd86 100755
--- a/tools/codegen/core/gen_header_frame.py
+++ b/tools/codegen/core/gen_header_frame.py
@@ -13,7 +13,6 @@
# 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.
-
"""Read from stdin a set of colon separated http headers:
:path: /foo/bar
content-type: application/grpc
@@ -24,109 +23,118 @@ import json
import sys
import argparse
+
def append_never_indexed(payload_line, n, count, key, value):
- payload_line.append(0x10)
- assert(len(key) <= 126)
- payload_line.append(len(key))
- payload_line.extend(ord(c) for c in key)
- assert(len(value) <= 126)
- payload_line.append(len(value))
- payload_line.extend(ord(c) for c in value)
+ payload_line.append(0x10)
+ assert (len(key) <= 126)
+ payload_line.append(len(key))
+ payload_line.extend(ord(c) for c in key)
+ assert (len(value) <= 126)
+ payload_line.append(len(value))
+ payload_line.extend(ord(c) for c in value)
+
def append_inc_indexed(payload_line, n, count, key, value):
- payload_line.append(0x40)
- assert(len(key) <= 126)
- payload_line.append(len(key))
- payload_line.extend(ord(c) for c in key)
- assert(len(value) <= 126)
- payload_line.append(len(value))
- payload_line.extend(ord(c) for c in value)
+ payload_line.append(0x40)
+ assert (len(key) <= 126)
+ payload_line.append(len(key))
+ payload_line.extend(ord(c) for c in key)
+ assert (len(value) <= 126)
+ payload_line.append(len(value))
+ payload_line.extend(ord(c) for c in value)
+
def append_pre_indexed(payload_line, n, count, key, value):
- payload_line.append(0x80 + 61 + count - n)
+ payload_line.append(0x80 + 61 + count - n)
+
_COMPRESSORS = {
- 'never': append_never_indexed,
- 'inc': append_inc_indexed,
- 'pre': append_pre_indexed,
+ 'never': append_never_indexed,
+ 'inc': append_inc_indexed,
+ 'pre': append_pre_indexed,
}
argp = argparse.ArgumentParser('Generate header frames')
-argp.add_argument('--set_end_stream', default=False, action='store_const', const=True)
-argp.add_argument('--no_framing', default=False, action='store_const', const=True)
-argp.add_argument('--compression', choices=sorted(_COMPRESSORS.keys()), default='never')
+argp.add_argument(
+ '--set_end_stream', default=False, action='store_const', const=True)
+argp.add_argument(
+ '--no_framing', default=False, action='store_const', const=True)
+argp.add_argument(
+ '--compression', choices=sorted(_COMPRESSORS.keys()), default='never')
argp.add_argument('--hex', default=False, action='store_const', const=True)
args = argp.parse_args()
# parse input, fill in vals
vals = []
for line in sys.stdin:
- line = line.strip()
- if line == '': continue
- if line[0] == '#': continue
- key_tail, value = line[1:].split(':')
- key = (line[0] + key_tail).strip()
- value = value.strip()
- vals.append((key, value))
+ line = line.strip()
+ if line == '': continue
+ if line[0] == '#': continue
+ key_tail, value = line[1:].split(':')
+ key = (line[0] + key_tail).strip()
+ value = value.strip()
+ vals.append((key, value))
# generate frame payload binary data
payload_bytes = []
if not args.no_framing:
- payload_bytes.append([]) # reserve space for header
+ payload_bytes.append([]) # reserve space for header
payload_len = 0
n = 0
for key, value in vals:
- payload_line = []
- _COMPRESSORS[args.compression](payload_line, n, len(vals), key, value)
- n += 1
- payload_len += len(payload_line)
- payload_bytes.append(payload_line)
+ payload_line = []
+ _COMPRESSORS[args.compression](payload_line, n, len(vals), key, value)
+ n += 1
+ payload_len += len(payload_line)
+ payload_bytes.append(payload_line)
# fill in header
if not args.no_framing:
- flags = 0x04 # END_HEADERS
- if args.set_end_stream:
- flags |= 0x01 # END_STREAM
- payload_bytes[0].extend([
- (payload_len >> 16) & 0xff,
- (payload_len >> 8) & 0xff,
- (payload_len) & 0xff,
- # header frame
- 0x01,
- # flags
- flags,
- # stream id
- 0x00,
- 0x00,
- 0x00,
- 0x01
- ])
+ flags = 0x04 # END_HEADERS
+ if args.set_end_stream:
+ flags |= 0x01 # END_STREAM
+ payload_bytes[0].extend([
+ (payload_len >> 16) & 0xff,
+ (payload_len >> 8) & 0xff,
+ (payload_len) & 0xff,
+ # header frame
+ 0x01,
+ # flags
+ flags,
+ # stream id
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x01
+ ])
hex_bytes = [ord(c) for c in "abcdefABCDEF0123456789"]
+
def esc_c(line):
- out = "\""
- last_was_hex = False
- for c in line:
- if 32 <= c < 127:
- if c in hex_bytes and last_was_hex:
- out += "\"\""
- if c != ord('"'):
- out += chr(c)
- else:
- out += "\\\""
- last_was_hex = False
- else:
- out += "\\x%02x" % c
- last_was_hex = True
- return out + "\""
+ out = "\""
+ last_was_hex = False
+ for c in line:
+ if 32 <= c < 127:
+ if c in hex_bytes and last_was_hex:
+ out += "\"\""
+ if c != ord('"'):
+ out += chr(c)
+ else:
+ out += "\\\""
+ last_was_hex = False
+ else:
+ out += "\\x%02x" % c
+ last_was_hex = True
+ return out + "\""
+
# dump bytes
if args.hex:
- all_bytes = []
- for line in payload_bytes:
- all_bytes.extend(line)
- print '{%s}' % ', '.join('0x%02x' % c for c in all_bytes)
+ all_bytes = []
+ for line in payload_bytes:
+ all_bytes.extend(line)
+ print '{%s}' % ', '.join('0x%02x' % c for c in all_bytes)
else:
- for line in payload_bytes:
- print esc_c(line)
+ for line in payload_bytes:
+ print esc_c(line)
diff --git a/tools/codegen/core/gen_hpack_tables.c b/tools/codegen/core/gen_hpack_tables.cc
index 73dfa9fbd6..0e7a7b80d8 100644
--- a/tools/codegen/core/gen_hpack_tables.c
+++ b/tools/codegen/core/gen_hpack_tables.cc
@@ -16,7 +16,7 @@
*
*/
-/* generates constant tables for hpack.c */
+/* generates constant tables for hpack.cc */
#include <assert.h>
#include <stddef.h>
diff --git a/tools/codegen/core/gen_legal_metadata_characters.c b/tools/codegen/core/gen_legal_metadata_characters.cc
index 5e292abb3b..fbabd2464f 100644
--- a/tools/codegen/core/gen_legal_metadata_characters.c
+++ b/tools/codegen/core/gen_legal_metadata_characters.cc
@@ -16,7 +16,7 @@
*
*/
-/* generates constant table for metadata.c */
+/* generates constant table for metadata.cc */
#include <stdio.h>
#include <string.h>
diff --git a/tools/codegen/core/gen_nano_proto.sh b/tools/codegen/core/gen_nano_proto.sh
index db00bd937f..4246840173 100755
--- a/tools/codegen/core/gen_nano_proto.sh
+++ b/tools/codegen/core/gen_nano_proto.sh
@@ -68,7 +68,7 @@ popd
# this should be the same version as the submodule we compile against
# ideally we'd update this as a template to ensure that
-pip install protobuf==3.2.0
+pip install protobuf==3.5.0.post1
pushd "$(dirname $INPUT_PROTO)" > /dev/null
diff --git a/tools/codegen/core/gen_percent_encoding_tables.c b/tools/codegen/core/gen_percent_encoding_tables.cc
index 49ea5ea53b..a99024e5ed 100644
--- a/tools/codegen/core/gen_percent_encoding_tables.c
+++ b/tools/codegen/core/gen_percent_encoding_tables.cc
@@ -16,7 +16,7 @@
*
*/
-/* generates constant table for metadata.c */
+/* generates constant table for metadata.cc */
#include <stdio.h>
#include <string.h>
diff --git a/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py b/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
index 8b5b618e8e..fa87c974f9 100755
--- a/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
+++ b/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
@@ -14,48 +14,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
def esc_c(line):
- out = "\""
- last_was_hex = False
- for c in line:
- if 32 <= c < 127:
- if c in hex_bytes and last_was_hex:
- out += "\"\""
- if c != ord('"'):
- out += chr(c)
- else:
- out += "\\\""
- last_was_hex = False
- else:
- out += "\\x%02x" % c
- last_was_hex = True
- return out + "\""
+ out = "\""
+ last_was_hex = False
+ for c in line:
+ if 32 <= c < 127:
+ if c in hex_bytes and last_was_hex:
+ out += "\"\""
+ if c != ord('"'):
+ out += chr(c)
+ else:
+ out += "\\\""
+ last_was_hex = False
+ else:
+ out += "\\x%02x" % c
+ last_was_hex = True
+ return out + "\""
+
done = set()
for message_length in range(0, 3):
- for send_message_length in range(0, message_length + 1):
- payload = [
- 0,
- (message_length >> 24) & 0xff,
- (message_length >> 16) & 0xff,
- (message_length >> 8) & 0xff,
- (message_length) & 0xff
- ] + send_message_length * [0]
- for frame_length in range(0, len(payload) + 1):
- is_end = frame_length == len(payload) and send_message_length == message_length
- frame = [
- (frame_length >> 16) & 0xff,
- (frame_length >> 8) & 0xff,
- (frame_length) & 0xff,
- 0,
- 1 if is_end else 0,
- 0, 0, 0, 1
- ] + payload[0:frame_length]
- text = esc_c(frame)
- if text not in done:
- print 'GRPC_RUN_BAD_CLIENT_TEST(verifier_%s, PFX_STR %s, %s);' % (
- 'succeeds' if is_end else 'fails',
- text,
- '0' if is_end else 'GRPC_BAD_CLIENT_DISCONNECT')
- done.add(text)
+ for send_message_length in range(0, message_length + 1):
+ payload = [
+ 0, (message_length >> 24) & 0xff, (message_length >> 16) & 0xff,
+ (message_length >> 8) & 0xff, (message_length) & 0xff
+ ] + send_message_length * [0]
+ for frame_length in range(0, len(payload) + 1):
+ is_end = frame_length == len(
+ payload) and send_message_length == message_length
+ frame = [(frame_length >> 16) & 0xff, (frame_length >> 8) & 0xff,
+ (frame_length) & 0xff, 0, 1
+ if is_end else 0, 0, 0, 0, 1] + payload[0:frame_length]
+ text = esc_c(frame)
+ if text not in done:
+ print 'GRPC_RUN_BAD_CLIENT_TEST(verifier_%s, PFX_STR %s, %s);' % (
+ 'succeeds' if is_end else 'fails', text, '0'
+ if is_end else 'GRPC_BAD_CLIENT_DISCONNECT')
+ done.add(text)
diff --git a/tools/codegen/core/gen_settings_ids.py b/tools/codegen/core/gen_settings_ids.py
index 481c4216a3..5c3f066b15 100755
--- a/tools/codegen/core/gen_settings_ids.py
+++ b/tools/codegen/core/gen_settings_ids.py
@@ -24,92 +24,114 @@ Setting = collections.namedtuple('Setting', 'id default min max on_error')
OnError = collections.namedtuple('OnError', 'behavior code')
clamp_invalid_value = OnError('CLAMP_INVALID_VALUE', 'PROTOCOL_ERROR')
disconnect_on_invalid_value = lambda e: OnError('DISCONNECT_ON_INVALID_VALUE', e)
-DecoratedSetting = collections.namedtuple('DecoratedSetting', 'enum name setting')
+DecoratedSetting = collections.namedtuple('DecoratedSetting',
+ 'enum name setting')
_SETTINGS = {
- 'HEADER_TABLE_SIZE': Setting(1, 4096, 0, 0xffffffff, clamp_invalid_value),
- 'ENABLE_PUSH': Setting(2, 1, 0, 1, disconnect_on_invalid_value('PROTOCOL_ERROR')),
- 'MAX_CONCURRENT_STREAMS': Setting(3, 0xffffffff, 0, 0xffffffff, disconnect_on_invalid_value('PROTOCOL_ERROR')),
- 'INITIAL_WINDOW_SIZE': Setting(4, 65535, 0, 0x7fffffff, disconnect_on_invalid_value('FLOW_CONTROL_ERROR')),
- 'MAX_FRAME_SIZE': Setting(5, 16384, 16384, 16777215, disconnect_on_invalid_value('PROTOCOL_ERROR')),
- 'MAX_HEADER_LIST_SIZE': Setting(6, _MAX_HEADER_LIST_SIZE, 0, _MAX_HEADER_LIST_SIZE, clamp_invalid_value),
- 'GRPC_ALLOW_TRUE_BINARY_METADATA': Setting(0xfe03, 0, 0, 1, clamp_invalid_value),
+ 'HEADER_TABLE_SIZE':
+ Setting(1, 4096, 0, 0xffffffff, clamp_invalid_value),
+ 'ENABLE_PUSH':
+ Setting(2, 1, 0, 1, disconnect_on_invalid_value('PROTOCOL_ERROR')),
+ 'MAX_CONCURRENT_STREAMS':
+ Setting(3, 0xffffffff, 0, 0xffffffff,
+ disconnect_on_invalid_value('PROTOCOL_ERROR')),
+ 'INITIAL_WINDOW_SIZE':
+ Setting(4, 65535, 0, 0x7fffffff,
+ disconnect_on_invalid_value('FLOW_CONTROL_ERROR')),
+ 'MAX_FRAME_SIZE':
+ Setting(5, 16384, 16384, 16777215,
+ disconnect_on_invalid_value('PROTOCOL_ERROR')),
+ 'MAX_HEADER_LIST_SIZE':
+ Setting(6, _MAX_HEADER_LIST_SIZE, 0, _MAX_HEADER_LIST_SIZE,
+ clamp_invalid_value),
+ 'GRPC_ALLOW_TRUE_BINARY_METADATA':
+ Setting(0xfe03, 0, 0, 1, clamp_invalid_value),
}
H = open('src/core/ext/transport/chttp2/transport/http2_settings.h', 'w')
C = open('src/core/ext/transport/chttp2/transport/http2_settings.c', 'w')
+
# utility: print a big comment block into a set of files
def put_banner(files, banner):
- for f in files:
- print >>f, '/*'
- for line in banner:
- print >>f, ' * %s' % line
- print >>f, ' */'
- print >>f
+ for f in files:
+ print >> f, '/*'
+ for line in banner:
+ print >> f, ' * %s' % line
+ print >> f, ' */'
+ print >> f
+
# copy-paste copyright notice from this file
with open(sys.argv[0]) as my_source:
- copyright = []
- for line in my_source:
- if line[0] != '#': break
- for line in my_source:
- if line[0] == '#':
- copyright.append(line)
- break
- for line in my_source:
- if line[0] != '#':
- break
- copyright.append(line)
- put_banner([H,C], [line[2:].rstrip() for line in copyright])
-
-put_banner([H,C], ["Automatically generated by tools/codegen/core/gen_settings_ids.py"])
-
-print >>H, "#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H"
-print >>H, "#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H"
-print >>H
-print >>H, "#include <stdint.h>"
-print >>H, "#include <stdbool.h>"
-print >>H
-
-print >>C, "#include \"src/core/ext/transport/chttp2/transport/http2_settings.h\""
-print >>C
-print >>C, "#include <grpc/support/useful.h>"
-print >>C, "#include \"src/core/lib/transport/http2_errors.h\""
-print >>C
+ copyright = []
+ for line in my_source:
+ if line[0] != '#': break
+ for line in my_source:
+ if line[0] == '#':
+ copyright.append(line)
+ break
+ for line in my_source:
+ if line[0] != '#':
+ break
+ copyright.append(line)
+ put_banner([H, C], [line[2:].rstrip() for line in copyright])
+
+put_banner(
+ [H, C],
+ ["Automatically generated by tools/codegen/core/gen_settings_ids.py"])
+
+print >> H, "#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H"
+print >> H, "#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H"
+print >> H
+print >> H, "#include <stdint.h>"
+print >> H, "#include <stdbool.h>"
+print >> H
+
+print >> C, "#include \"src/core/ext/transport/chttp2/transport/http2_settings.h\""
+print >> C
+print >> C, "#include <grpc/support/useful.h>"
+print >> C, "#include \"src/core/lib/transport/http2_errors.h\""
+print >> C
p = perfection.hash_parameters(sorted(x.id for x in _SETTINGS.values()))
print p
+
def hash(i):
- i += p.offset
- x = i % p.t
- y = i / p.t
- return x + p.r[y]
+ i += p.offset
+ x = i % p.t
+ y = i / p.t
+ return x + p.r[y]
+
-decorated_settings = [DecoratedSetting(hash(setting.id), name, setting)
- for name, setting in _SETTINGS.iteritems()]
+decorated_settings = [
+ DecoratedSetting(hash(setting.id), name, setting)
+ for name, setting in _SETTINGS.iteritems()
+]
-print >>H, 'typedef enum {'
+print >> H, 'typedef enum {'
for decorated_setting in sorted(decorated_settings):
- print >>H, ' GRPC_CHTTP2_SETTINGS_%s = %d, /* wire id %d */' % (
- decorated_setting.name, decorated_setting.enum, decorated_setting.setting.id)
-print >>H, '} grpc_chttp2_setting_id;'
-print >>H
-print >>H, '#define GRPC_CHTTP2_NUM_SETTINGS %d' % (max(x.enum for x in decorated_settings) + 1)
-
-print >>H, 'extern const uint16_t grpc_setting_id_to_wire_id[];'
-print >>C, 'const uint16_t grpc_setting_id_to_wire_id[] = {%s};' % ','.join(
+ print >> H, ' GRPC_CHTTP2_SETTINGS_%s = %d, /* wire id %d */' % (
+ decorated_setting.name, decorated_setting.enum,
+ decorated_setting.setting.id)
+print >> H, '} grpc_chttp2_setting_id;'
+print >> H
+print >> H, '#define GRPC_CHTTP2_NUM_SETTINGS %d' % (
+ max(x.enum for x in decorated_settings) + 1)
+
+print >> H, 'extern const uint16_t grpc_setting_id_to_wire_id[];'
+print >> C, 'const uint16_t grpc_setting_id_to_wire_id[] = {%s};' % ','.join(
'%d' % s for s in p.slots)
-print >>H
-print >>H, "bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out);"
+print >> H
+print >> H, "bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out);"
cgargs = {
- 'r': ','.join('%d' % (r if r is not None else 0) for r in p.r),
- 't': p.t,
- 'offset': abs(p.offset),
- 'offset_sign': '+' if p.offset > 0 else '-'
- }
-print >>C, """
+ 'r': ','.join('%d' % (r if r is not None else 0) for r in p.r),
+ 't': p.t,
+ 'offset': abs(p.offset),
+ 'offset_sign': '+' if p.offset > 0 else '-'
+}
+print >> C, """
bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) {
uint32_t i = wire_id %(offset_sign)s %(offset)d;
uint32_t x = i %% %(t)d;
@@ -118,17 +140,17 @@ bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) {
switch (y) {
""" % cgargs
for i, r in enumerate(p.r):
- if not r: continue
- if r < 0: print >>C, 'case %d: h -= %d; break;' % (i, -r)
- else: print >>C, 'case %d: h += %d; break;' % (i, r)
-print >>C, """
+ if not r: continue
+ if r < 0: print >> C, 'case %d: h -= %d; break;' % (i, -r)
+ else: print >> C, 'case %d: h += %d; break;' % (i, r)
+print >> C, """
}
*out = (grpc_chttp2_setting_id)h;
return h < GPR_ARRAY_SIZE(grpc_setting_id_to_wire_id) && grpc_setting_id_to_wire_id[h] == wire_id;
}
""" % cgargs
-print >>H, """
+print >> H, """
typedef enum {
GRPC_CHTTP2_CLAMP_INVALID_VALUE,
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE
@@ -145,25 +167,25 @@ typedef struct {
extern const grpc_chttp2_setting_parameters grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
"""
-print >>C, "const grpc_chttp2_setting_parameters grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = {"
+print >> C, "const grpc_chttp2_setting_parameters grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = {"
i = 0
for decorated_setting in sorted(decorated_settings):
- while i < decorated_setting.enum:
- print >>C, "{NULL, 0, 0, 0, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},"
+ while i < decorated_setting.enum:
+ print >> C, "{NULL, 0, 0, 0, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},"
+ i += 1
+ print >> C, "{\"%s\", %du, %du, %du, GRPC_CHTTP2_%s, GRPC_HTTP2_%s}," % (
+ decorated_setting.name,
+ decorated_setting.setting.default,
+ decorated_setting.setting.min,
+ decorated_setting.setting.max,
+ decorated_setting.setting.on_error.behavior,
+ decorated_setting.setting.on_error.code,
+ )
i += 1
- print >>C, "{\"%s\", %du, %du, %du, GRPC_CHTTP2_%s, GRPC_HTTP2_%s}," % (
- decorated_setting.name,
- decorated_setting.setting.default,
- decorated_setting.setting.min,
- decorated_setting.setting.max,
- decorated_setting.setting.on_error.behavior,
- decorated_setting.setting.on_error.code,
- )
- i += 1
-print >>C, "};"
-
-print >>H
-print >>H, "#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */"
+print >> C, "};"
+
+print >> H
+print >> H, "#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */"
H.close()
C.close()
diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py
index af7521da36..d4c0052b28 100755
--- a/tools/codegen/core/gen_static_metadata.py
+++ b/tools/codegen/core/gen_static_metadata.py
@@ -53,6 +53,10 @@ CONFIG = [
'grpc.max_response_message_bytes',
# well known method names
'/grpc.lb.v1.LoadBalancer/BalanceLoad',
+ # compression algorithm names
+ 'message/deflate',
+ 'message/gzip',
+ 'stream/gzip',
# metadata elements
('grpc-status', '0'),
('grpc-status', '1'),
@@ -172,65 +176,66 @@ STREAM_COMPRESSION_ALGORITHMS = [
'gzip',
]
+
# utility: mangle the name of a config
def mangle(elem, name=None):
- xl = {
- '-': '_',
- ':': '',
- '/': 'slash',
- '.': 'dot',
- ',': 'comma',
- ' ': '_',
- }
+ xl = {
+ '-': '_',
+ ':': '',
+ '/': 'slash',
+ '.': 'dot',
+ ',': 'comma',
+ ' ': '_',
+ }
- def m0(x):
- if not x:
- return 'empty'
- r = ''
- for c in x:
- put = xl.get(c, c.lower())
- if not put:
- continue
- last_is_underscore = r[-1] == '_' if r else True
- if last_is_underscore and put == '_':
- continue
- elif len(put) > 1:
- if not last_is_underscore:
- r += '_'
- r += put
- r += '_'
- else:
- r += put
- if r[-1] == '_':
- r = r[:-1]
- return r
-
- def n(default, name=name):
- if name is None:
- return 'grpc_%s_' % default
- if name == '':
- return ''
- return 'grpc_%s_' % name
-
- if isinstance(elem, tuple):
- return '%s%s_%s' % (n('mdelem'), m0(elem[0]), m0(elem[1]))
- else:
- return '%s%s' % (n('mdstr'), m0(elem))
+ def m0(x):
+ if not x:
+ return 'empty'
+ r = ''
+ for c in x:
+ put = xl.get(c, c.lower())
+ if not put:
+ continue
+ last_is_underscore = r[-1] == '_' if r else True
+ if last_is_underscore and put == '_':
+ continue
+ elif len(put) > 1:
+ if not last_is_underscore:
+ r += '_'
+ r += put
+ r += '_'
+ else:
+ r += put
+ if r[-1] == '_':
+ r = r[:-1]
+ return r
+
+ def n(default, name=name):
+ if name is None:
+ return 'grpc_%s_' % default
+ if name == '':
+ return ''
+ return 'grpc_%s_' % name
+
+ if isinstance(elem, tuple):
+ return '%s%s_%s' % (n('mdelem'), m0(elem[0]), m0(elem[1]))
+ else:
+ return '%s%s' % (n('mdstr'), m0(elem))
# utility: generate some hash value for a string
def fake_hash(elem):
- return hashlib.md5(elem).hexdigest()[0:8]
+ return hashlib.md5(elem).hexdigest()[0:8]
# utility: print a big comment block into a set of files
def put_banner(files, banner):
- for f in files:
- print >> f, '/*'
- for line in banner:
- print >> f, ' * %s' % line
- print >> f, ' */'
- print >> f
+ for f in files:
+ print >> f, '/*'
+ for line in banner:
+ print >> f, ' * %s' % line
+ print >> f, ' */'
+ print >> f
# build a list of all the strings we need
@@ -240,43 +245,43 @@ static_userdata = {}
# put metadata batch callouts first, to make the check of if a static metadata
# string is a callout trivial
for elem, _ in METADATA_BATCH_CALLOUTS:
- if elem not in all_strs:
- all_strs.append(elem)
-for elem in CONFIG:
- if isinstance(elem, tuple):
- if elem[0] not in all_strs:
- all_strs.append(elem[0])
- if elem[1] not in all_strs:
- all_strs.append(elem[1])
- if elem not in all_elems:
- all_elems.append(elem)
- else:
if elem not in all_strs:
- all_strs.append(elem)
+ all_strs.append(elem)
+for elem in CONFIG:
+ if isinstance(elem, tuple):
+ if elem[0] not in all_strs:
+ all_strs.append(elem[0])
+ if elem[1] not in all_strs:
+ all_strs.append(elem[1])
+ if elem not in all_elems:
+ all_elems.append(elem)
+ else:
+ if elem not in all_strs:
+ all_strs.append(elem)
compression_elems = []
for mask in range(1, 1 << len(COMPRESSION_ALGORITHMS)):
- val = ','.join(COMPRESSION_ALGORITHMS[alg]
- for alg in range(0, len(COMPRESSION_ALGORITHMS))
- if (1 << alg) & mask)
- elem = ('grpc-accept-encoding', val)
- if val not in all_strs:
- all_strs.append(val)
- if elem not in all_elems:
- all_elems.append(elem)
- compression_elems.append(elem)
- static_userdata[elem] = 1 + (mask | 1)
+ val = ','.join(COMPRESSION_ALGORITHMS[alg]
+ for alg in range(0, len(COMPRESSION_ALGORITHMS))
+ if (1 << alg) & mask)
+ elem = ('grpc-accept-encoding', val)
+ if val not in all_strs:
+ all_strs.append(val)
+ if elem not in all_elems:
+ all_elems.append(elem)
+ compression_elems.append(elem)
+ static_userdata[elem] = 1 + (mask | 1)
stream_compression_elems = []
for mask in range(1, 1 << len(STREAM_COMPRESSION_ALGORITHMS)):
- val = ','.join(STREAM_COMPRESSION_ALGORITHMS[alg]
- for alg in range(0, len(STREAM_COMPRESSION_ALGORITHMS))
- if (1 << alg) & mask)
- elem = ('accept-encoding', val)
- if val not in all_strs:
- all_strs.append(val)
- if elem not in all_elems:
- all_elems.append(elem)
- stream_compression_elems.append(elem)
- static_userdata[elem] = 1 + (mask | 1)
+ val = ','.join(STREAM_COMPRESSION_ALGORITHMS[alg]
+ for alg in range(0, len(STREAM_COMPRESSION_ALGORITHMS))
+ if (1 << alg) & mask)
+ elem = ('accept-encoding', val)
+ if val not in all_strs:
+ all_strs.append(val)
+ if elem not in all_elems:
+ all_elems.append(elem)
+ stream_compression_elems.append(elem)
+ static_userdata[elem] = 1 + (mask | 1)
# output configuration
args = sys.argv[1:]
@@ -284,62 +289,62 @@ H = None
C = None
D = None
if args:
- if 'header' in args:
- H = sys.stdout
- else:
- H = open('/dev/null', 'w')
- if 'source' in args:
- C = sys.stdout
- else:
- C = open('/dev/null', 'w')
- if 'dictionary' in args:
- D = sys.stdout
- else:
- D = open('/dev/null', 'w')
+ if 'header' in args:
+ H = sys.stdout
+ else:
+ H = open('/dev/null', 'w')
+ if 'source' in args:
+ C = sys.stdout
+ else:
+ C = open('/dev/null', 'w')
+ if 'dictionary' in args:
+ D = sys.stdout
+ else:
+ D = open('/dev/null', 'w')
else:
- H = open(
- os.path.join(
- os.path.dirname(sys.argv[0]),
- '../../../src/core/lib/transport/static_metadata.h'), 'w')
- C = open(
- os.path.join(
- os.path.dirname(sys.argv[0]),
- '../../../src/core/lib/transport/static_metadata.c'), 'w')
- D = open(
- os.path.join(
- os.path.dirname(sys.argv[0]),
- '../../../test/core/end2end/fuzzers/hpack.dictionary'), 'w')
+ H = open(
+ os.path.join(
+ os.path.dirname(sys.argv[0]),
+ '../../../src/core/lib/transport/static_metadata.h'), 'w')
+ C = open(
+ os.path.join(
+ os.path.dirname(sys.argv[0]),
+ '../../../src/core/lib/transport/static_metadata.cc'), 'w')
+ D = open(
+ os.path.join(
+ os.path.dirname(sys.argv[0]),
+ '../../../test/core/end2end/fuzzers/hpack.dictionary'), 'w')
# copy-paste copyright notice from this file
with open(sys.argv[0]) as my_source:
- copyright = []
- for line in my_source:
- if line[0] != '#':
- break
- for line in my_source:
- if line[0] == '#':
- copyright.append(line)
- break
- for line in my_source:
- if line[0] != '#':
- break
- copyright.append(line)
- put_banner([H, C], [line[2:].rstrip() for line in copyright])
+ copyright = []
+ for line in my_source:
+ if line[0] != '#':
+ break
+ for line in my_source:
+ if line[0] == '#':
+ copyright.append(line)
+ break
+ for line in my_source:
+ if line[0] != '#':
+ break
+ copyright.append(line)
+ put_banner([H, C], [line[2:].rstrip() for line in copyright])
hex_bytes = [ord(c) for c in 'abcdefABCDEF0123456789']
def esc_dict(line):
- out = "\""
- for c in line:
- if 32 <= c < 127:
- if c != ord('"'):
- out += chr(c)
- else:
- out += "\\\""
- else:
- out += '\\x%02X' % c
- return out + "\""
+ out = "\""
+ for c in line:
+ if 32 <= c < 127:
+ if c != ord('"'):
+ out += chr(c)
+ else:
+ out += "\\\""
+ else:
+ out += '\\x%02X' % c
+ return out + "\""
put_banner([H, C], """WARNING: Auto-generated code.
@@ -347,7 +352,7 @@ put_banner([H, C], """WARNING: Auto-generated code.
To make changes to this file, change
tools/codegen/core/gen_static_metadata.py, and then re-run it.
-See metadata.h for an explanation of the interface here, and metadata.c for
+See metadata.h for an explanation of the interface here, and metadata.cc for
an explanation of what's going on.
""".splitlines())
@@ -365,33 +370,32 @@ print >> C
str_ofs = 0
id2strofs = {}
for i, elem in enumerate(all_strs):
- id2strofs[i] = str_ofs
- str_ofs += len(elem)
+ id2strofs[i] = str_ofs
+ str_ofs += len(elem)
def slice_def(i):
- return ('{&grpc_static_metadata_refcounts[%d],'
- ' {{g_bytes+%d, %d}}}') % (
- i, id2strofs[i], len(all_strs[i]))
+ return ('{&grpc_static_metadata_refcounts[%d],'
+ ' {{g_bytes+%d, %d}}}') % (i, id2strofs[i], len(all_strs[i]))
# validate configuration
for elem, _ in METADATA_BATCH_CALLOUTS:
- assert elem in all_strs
+ assert elem in all_strs
print >> H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs)
print >> H, ('extern const grpc_slice '
'grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];')
for i, elem in enumerate(all_strs):
- print >> H, '/* "%s" */' % elem
- print >> H, '#define %s (grpc_static_slice_table[%d])' % (
- mangle(elem).upper(), i)
+ print >> H, '/* "%s" */' % elem
+ print >> H, '#define %s (grpc_static_slice_table[%d])' % (
+ mangle(elem).upper(), i)
print >> H
-print >> C, 'static uint8_t g_bytes[] = {%s};' % (
- ','.join('%d' % ord(c) for c in ''.join(all_strs)))
+print >> C, 'static uint8_t g_bytes[] = {%s};' % (','.join(
+ '%d' % ord(c) for c in ''.join(all_strs)))
print >> C
print >> C, 'static void static_ref(void *unused) {}'
-print >> C, 'static void static_unref(grpc_exec_ctx *exec_ctx, void *unused) {}'
+print >> C, 'static void static_unref(void *unused) {}'
print >> C, ('static const grpc_slice_refcount_vtable static_sub_vtable = '
'{static_ref, static_unref, grpc_slice_default_eq_impl, '
'grpc_slice_default_hash_impl};')
@@ -407,7 +411,7 @@ print >> H, ('extern grpc_slice_refcount '
print >> C, ('grpc_slice_refcount '
'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = {')
for i, elem in enumerate(all_strs):
- print >> C, ' {&grpc_static_metadata_vtable, &static_sub_refcnt},'
+ print >> C, ' {&grpc_static_metadata_vtable, &static_sub_refcnt},'
print >> C, '};'
print >> C
print >> H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\'
@@ -417,7 +421,7 @@ print >> H
print >> C, ('const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]'
' = {')
for i, elem in enumerate(all_strs):
- print >> C, slice_def(i) + ','
+ print >> C, slice_def(i) + ','
print >> C, '};'
print >> C
print >> H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\'
@@ -427,10 +431,10 @@ print >> H
print >> D, '# hpack fuzzing dictionary'
for i, elem in enumerate(all_strs):
- print >> D, '%s' % (esc_dict([len(elem)] + [ord(c) for c in elem]))
+ print >> D, '%s' % (esc_dict([len(elem)] + [ord(c) for c in elem]))
for i, elem in enumerate(all_elems):
- print >> D, '%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] +
- [len(elem[1])] + [ord(c) for c in elem[1]]))
+ print >> D, '%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] +
+ [len(elem[1])] + [ord(c) for c in elem[1]]))
print >> H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems)
print >> H, ('extern grpc_mdelem_data '
@@ -438,56 +442,51 @@ print >> H, ('extern grpc_mdelem_data '
print >> H, ('extern uintptr_t '
'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];')
for i, elem in enumerate(all_elems):
- print >> H, '/* "%s": "%s" */' % elem
- print >> H, ('#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d], '
- 'GRPC_MDELEM_STORAGE_STATIC))') % (
- mangle(elem).upper(), i)
+ print >> H, '/* "%s": "%s" */' % elem
+ print >> H, ('#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d], '
+ 'GRPC_MDELEM_STORAGE_STATIC))') % (mangle(elem).upper(), i)
print >> H
print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] '
'= {')
-print >> C, ' %s' % ','.join('%d' % static_userdata.get(elem, 0)
- for elem in all_elems)
+print >> C, ' %s' % ','.join(
+ '%d' % static_userdata.get(elem, 0) for elem in all_elems)
print >> C, '};'
print >> C
def str_idx(s):
- for i, s2 in enumerate(all_strs):
- if s == s2:
- return i
+ for i, s2 in enumerate(all_strs):
+ if s == s2:
+ return i
def md_idx(m):
- for i, m2 in enumerate(all_elems):
- if m == m2:
- return i
+ for i, m2 in enumerate(all_elems):
+ if m == m2:
+ return i
def offset_trials(mink):
- yield 0
- for i in range(1, 100):
- for mul in [-1, 1]:
- yield mul * i
+ yield 0
+ for i in range(1, 100):
+ for mul in [-1, 1]:
+ yield mul * i
def perfect_hash(keys, name):
- p = perfection.hash_parameters(keys)
-
- def f(i, p=p):
- i += p.offset
- x = i % p.t
- y = i / p.t
- return x + p.r[y]
-
- return {
- 'PHASHRANGE':
- p.t - 1 + max(p.r),
- 'PHASHNKEYS':
- len(p.slots),
- 'pyfunc':
- f,
- 'code':
- """
+ p = perfection.hash_parameters(keys)
+
+ def f(i, p=p):
+ i += p.offset
+ x = i % p.t
+ y = i / p.t
+ return x + p.r[y]
+
+ return {
+ 'PHASHRANGE': p.t - 1 + max(p.r),
+ 'PHASHNKEYS': len(p.slots),
+ 'pyfunc': f,
+ 'code': """
static const int8_t %(name)s_r[] = {%(r)s};
static uint32_t %(name)s_phash(uint32_t i) {
i %(offset_sign)s= %(offset)d;
@@ -501,13 +500,13 @@ static uint32_t %(name)s_phash(uint32_t i) {
return h;
}
""" % {
- 'name': name,
- 'r': ','.join('%d' % (r if r is not None else 0) for r in p.r),
- 't': p.t,
- 'offset': abs(p.offset),
- 'offset_sign': '+' if p.offset > 0 else '-'
+ 'name': name,
+ 'r': ','.join('%d' % (r if r is not None else 0) for r in p.r),
+ 't': p.t,
+ 'offset': abs(p.offset),
+ 'offset_sign': '+' if p.offset > 0 else '-'
+ }
}
- }
elem_keys = [
@@ -519,10 +518,10 @@ print >> C, elem_hash['code']
keys = [0] * int(elem_hash['PHASHRANGE'])
idxs = [255] * int(elem_hash['PHASHNKEYS'])
for i, k in enumerate(elem_keys):
- h = elem_hash['pyfunc'](k)
- assert keys[h] == 0
- keys[h] = k
- idxs[h] = i
+ h = elem_hash['pyfunc'](k)
+ assert keys[h] == 0
+ keys[h] = k
+ idxs[h] = i
print >> C, 'static const uint16_t elem_keys[] = {%s};' % ','.join(
'%d' % k for k in keys)
print >> C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join(
@@ -540,12 +539,12 @@ print >> C
print >> C, 'grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {'
for a, b in all_elems:
- print >> C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b)))
+ print >> C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b)))
print >> C, '};'
print >> H, 'typedef enum {'
for elem, _ in METADATA_BATCH_CALLOUTS:
- print >> H, ' %s,' % mangle(elem, 'batch').upper()
+ print >> H, ' %s,' % mangle(elem, 'batch').upper()
print >> H, ' GRPC_BATCH_CALLOUTS_COUNT'
print >> H, '} grpc_metadata_batch_callouts_index;'
print >> H
@@ -553,7 +552,7 @@ print >> H, 'typedef union {'
print >> H, ' struct grpc_linked_mdelem *array[GRPC_BATCH_CALLOUTS_COUNT];'
print >> H, ' struct {'
for elem, _ in METADATA_BATCH_CALLOUTS:
- print >> H, ' struct grpc_linked_mdelem *%s;' % mangle(elem, '').lower()
+ print >> H, ' struct grpc_linked_mdelem *%s;' % mangle(elem, '').lower()
print >> H, ' } named;'
print >> H, '} grpc_metadata_batch_callouts;'
print >> H
@@ -565,7 +564,7 @@ print >> H, ('extern bool grpc_static_callout_is_default['
print >> H
print >> C, 'bool grpc_static_callout_is_default[GRPC_BATCH_CALLOUTS_COUNT] = {'
for elem, is_default in METADATA_BATCH_CALLOUTS:
- print >> C, ' %s, // %s' % (str(is_default).lower(), elem)
+ print >> C, ' %s, // %s' % (str(is_default).lower(), elem)
print >> C, '};'
print >> C
@@ -584,7 +583,8 @@ print >> H, 'extern const uint8_t grpc_static_accept_stream_encoding_metadata[%d
1 << len(STREAM_COMPRESSION_ALGORITHMS))
print >> C, 'const uint8_t grpc_static_accept_stream_encoding_metadata[%d] = {' % (
1 << len(STREAM_COMPRESSION_ALGORITHMS))
-print >> C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in stream_compression_elems)
+print >> C, '0,%s' % ','.join(
+ '%d' % md_idx(elem) for elem in stream_compression_elems)
print >> C, '};'
print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))'
diff --git a/tools/codegen/core/gen_stats_data.py b/tools/codegen/core/gen_stats_data.py
index 10ad0cc831..5c9d9e5ea5 100755
--- a/tools/codegen/core/gen_stats_data.py
+++ b/tools/codegen/core/gen_stats_data.py
@@ -22,27 +22,31 @@ import yaml
import json
with open('src/core/lib/debug/stats_data.yaml') as f:
- attrs = yaml.load(f.read())
+ attrs = yaml.load(f.read())
REQUIRED_FIELDS = ['name', 'doc']
+
def make_type(name, fields):
- return (collections.namedtuple(name, ' '.join(list(set(REQUIRED_FIELDS + fields)))), [])
+ return (collections.namedtuple(name, ' '.join(
+ list(set(REQUIRED_FIELDS + fields)))), [])
+
def c_str(s, encoding='ascii'):
- if isinstance(s, unicode):
- s = s.encode(encoding)
- result = ''
- for c in s:
- if not (32 <= ord(c) < 127) or c in ('\\', '"'):
- result += '\\%03o' % ord(c)
- else:
- result += c
- return '"' + result + '"'
+ if isinstance(s, unicode):
+ s = s.encode(encoding)
+ result = ''
+ for c in s:
+ if not (32 <= ord(c) < 127) or c in ('\\', '"'):
+ result += '\\%03o' % ord(c)
+ else:
+ result += c
+ return '"' + result + '"'
+
types = (
- make_type('Counter', []),
- make_type('Histogram', ['max', 'buckets']),
+ make_type('Counter', []),
+ make_type('Histogram', ['max', 'buckets']),
)
inst_map = dict((t[0].__name__, t[1]) for t in types)
@@ -50,361 +54,407 @@ inst_map = dict((t[0].__name__, t[1]) for t in types)
stats = []
for attr in attrs:
- found = False
- for t, lst in types:
- t_name = t.__name__.lower()
- if t_name in attr:
- name = attr[t_name]
- del attr[t_name]
- lst.append(t(name=name, **attr))
- found = True
- break
- assert found, "Bad decl: %s" % attr
+ found = False
+ for t, lst in types:
+ t_name = t.__name__.lower()
+ if t_name in attr:
+ name = attr[t_name]
+ del attr[t_name]
+ lst.append(t(name=name, **attr))
+ found = True
+ break
+ assert found, "Bad decl: %s" % attr
+
def dbl2u64(d):
- return ctypes.c_ulonglong.from_buffer(ctypes.c_double(d)).value
+ return ctypes.c_ulonglong.from_buffer(ctypes.c_double(d)).value
+
def shift_works_until(mapped_bounds, shift_bits):
- for i, ab in enumerate(zip(mapped_bounds, mapped_bounds[1:])):
- a, b = ab
- if (a >> shift_bits) == (b >> shift_bits):
- return i
- return len(mapped_bounds)
+ for i, ab in enumerate(zip(mapped_bounds, mapped_bounds[1:])):
+ a, b = ab
+ if (a >> shift_bits) == (b >> shift_bits):
+ return i
+ return len(mapped_bounds)
+
def find_ideal_shift(mapped_bounds, max_size):
- best = None
- for shift_bits in reversed(range(0,64)):
- n = shift_works_until(mapped_bounds, shift_bits)
- if n == 0: continue
- table_size = mapped_bounds[n-1] >> shift_bits
- if table_size > max_size: continue
- if table_size > 65535: continue
- if best is None:
- best = (shift_bits, n, table_size)
- elif best[1] < n:
- best = (shift_bits, n, table_size)
- print best
- return best
+ best = None
+ for shift_bits in reversed(range(0, 64)):
+ n = shift_works_until(mapped_bounds, shift_bits)
+ if n == 0: continue
+ table_size = mapped_bounds[n - 1] >> shift_bits
+ if table_size > max_size: continue
+ if table_size > 65535: continue
+ if best is None:
+ best = (shift_bits, n, table_size)
+ elif best[1] < n:
+ best = (shift_bits, n, table_size)
+ print best
+ return best
+
def gen_map_table(mapped_bounds, shift_data):
- tbl = []
- cur = 0
- print mapped_bounds
- mapped_bounds = [x >> shift_data[0] for x in mapped_bounds]
- print mapped_bounds
- for i in range(0, mapped_bounds[shift_data[1]-1]):
- while i > mapped_bounds[cur]:
- cur += 1
- tbl.append(cur)
- return tbl
+ tbl = []
+ cur = 0
+ print mapped_bounds
+ mapped_bounds = [x >> shift_data[0] for x in mapped_bounds]
+ print mapped_bounds
+ for i in range(0, mapped_bounds[shift_data[1] - 1]):
+ while i > mapped_bounds[cur]:
+ cur += 1
+ tbl.append(cur)
+ return tbl
+
static_tables = []
+
def decl_static_table(values, type):
- global static_tables
- v = (type, values)
- for i, vp in enumerate(static_tables):
- if v == vp: return i
- print "ADD TABLE: %s %r" % (type, values)
- r = len(static_tables)
- static_tables.append(v)
- return r
+ global static_tables
+ v = (type, values)
+ for i, vp in enumerate(static_tables):
+ if v == vp: return i
+ print "ADD TABLE: %s %r" % (type, values)
+ r = len(static_tables)
+ static_tables.append(v)
+ return r
+
def type_for_uint_table(table):
- mv = max(table)
- if mv < 2**8:
- return 'uint8_t'
- elif mv < 2**16:
- return 'uint16_t'
- elif mv < 2**32:
- return 'uint32_t'
- else:
- return 'uint64_t'
+ mv = max(table)
+ if mv < 2**8:
+ return 'uint8_t'
+ elif mv < 2**16:
+ return 'uint16_t'
+ elif mv < 2**32:
+ return 'uint32_t'
+ else:
+ return 'uint64_t'
+
def gen_bucket_code(histogram):
- bounds = [0, 1]
- done_trivial = False
- done_unmapped = False
- first_nontrivial = None
- first_unmapped = None
- while len(bounds) < histogram.buckets + 1:
- if len(bounds) == histogram.buckets:
- nextb = int(histogram.max)
+ bounds = [0, 1]
+ done_trivial = False
+ done_unmapped = False
+ first_nontrivial = None
+ first_unmapped = None
+ while len(bounds) < histogram.buckets + 1:
+ if len(bounds) == histogram.buckets:
+ nextb = int(histogram.max)
+ else:
+ mul = math.pow(
+ float(histogram.max) / bounds[-1],
+ 1.0 / (histogram.buckets + 1 - len(bounds)))
+ nextb = int(math.ceil(bounds[-1] * mul))
+ if nextb <= bounds[-1] + 1:
+ nextb = bounds[-1] + 1
+ elif not done_trivial:
+ done_trivial = True
+ first_nontrivial = len(bounds)
+ bounds.append(nextb)
+ bounds_idx = decl_static_table(bounds, 'int')
+ if done_trivial:
+ first_nontrivial_code = dbl2u64(first_nontrivial)
+ code_bounds = [dbl2u64(x) - first_nontrivial_code for x in bounds]
+ shift_data = find_ideal_shift(code_bounds[first_nontrivial:],
+ 256 * histogram.buckets)
+ #print first_nontrivial, shift_data, bounds
+ #if shift_data is not None: print [hex(x >> shift_data[0]) for x in code_bounds[first_nontrivial:]]
+ code = 'value = GPR_CLAMP(value, 0, %d);\n' % histogram.max
+ map_table = gen_map_table(code_bounds[first_nontrivial:], shift_data)
+ if first_nontrivial is None:
+ code += ('GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, value);\n' %
+ histogram.name.upper())
else:
- mul = math.pow(float(histogram.max) / bounds[-1],
- 1.0 / (histogram.buckets + 1 - len(bounds)))
- nextb = int(math.ceil(bounds[-1] * mul))
- if nextb <= bounds[-1] + 1:
- nextb = bounds[-1] + 1
- elif not done_trivial:
- done_trivial = True
- first_nontrivial = len(bounds)
- bounds.append(nextb)
- bounds_idx = decl_static_table(bounds, 'int')
- if done_trivial:
- first_nontrivial_code = dbl2u64(first_nontrivial)
- code_bounds = [dbl2u64(x) - first_nontrivial_code for x in bounds]
- shift_data = find_ideal_shift(code_bounds[first_nontrivial:], 256 * histogram.buckets)
- #print first_nontrivial, shift_data, bounds
- #if shift_data is not None: print [hex(x >> shift_data[0]) for x in code_bounds[first_nontrivial:]]
- code = '\n/* Automatically generated by tools/codegen/core/gen_stats_data.py */\n'
- code += 'value = GPR_CLAMP(value, 0, %d);\n' % histogram.max
- map_table = gen_map_table(code_bounds[first_nontrivial:], shift_data)
- if first_nontrivial is None:
- code += ('GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, value);\n'
- % histogram.name.upper())
- else:
- code += 'if (value < %d) {\n' % first_nontrivial
- code += ('GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, value);\n'
- % histogram.name.upper())
- code += 'return;\n'
- code += '}'
- first_nontrivial_code = dbl2u64(first_nontrivial)
- if shift_data is not None:
- map_table_idx = decl_static_table(map_table, type_for_uint_table(map_table))
- code += 'union { double dbl; uint64_t uint; } _val, _bkt;\n'
- code += '_val.dbl = value;\n'
- code += 'if (_val.uint < %dull) {\n' % ((map_table[-1] << shift_data[0]) + first_nontrivial_code)
- code += 'int bucket = '
- code += 'grpc_stats_table_%d[((_val.uint - %dull) >> %d)] + %d;\n' % (map_table_idx, first_nontrivial_code, shift_data[0], first_nontrivial)
- code += '_bkt.dbl = grpc_stats_table_%d[bucket];\n' % bounds_idx
- code += 'bucket -= (_val.uint < _bkt.uint);\n'
- code += 'GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, bucket);\n' % histogram.name.upper()
- code += 'return;\n'
- code += '}\n'
- code += 'GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, '% histogram.name.upper()
- code += 'grpc_stats_histo_find_bucket_slow((exec_ctx), value, grpc_stats_table_%d, %d));\n' % (bounds_idx, histogram.buckets)
- return (code, bounds_idx)
+ code += 'if (value < %d) {\n' % first_nontrivial
+ code += ('GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, value);\n' %
+ histogram.name.upper())
+ code += 'return;\n'
+ code += '}'
+ first_nontrivial_code = dbl2u64(first_nontrivial)
+ if shift_data is not None:
+ map_table_idx = decl_static_table(map_table,
+ type_for_uint_table(map_table))
+ code += 'union { double dbl; uint64_t uint; } _val, _bkt;\n'
+ code += '_val.dbl = value;\n'
+ code += 'if (_val.uint < %dull) {\n' % (
+ (map_table[-1] << shift_data[0]) + first_nontrivial_code)
+ code += 'int bucket = '
+ code += 'grpc_stats_table_%d[((_val.uint - %dull) >> %d)] + %d;\n' % (
+ map_table_idx, first_nontrivial_code, shift_data[0],
+ first_nontrivial)
+ code += '_bkt.dbl = grpc_stats_table_%d[bucket];\n' % bounds_idx
+ code += 'bucket -= (_val.uint < _bkt.uint);\n'
+ code += 'GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, bucket);\n' % histogram.name.upper(
+ )
+ code += 'return;\n'
+ code += '}\n'
+ code += 'GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, ' % histogram.name.upper(
+ )
+ code += 'grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_%d, %d));\n' % (
+ bounds_idx, histogram.buckets)
+ return (code, bounds_idx)
+
# utility: print a big comment block into a set of files
def put_banner(files, banner):
- for f in files:
- print >>f, '/*'
- for line in banner:
- print >>f, ' * %s' % line
- print >>f, ' */'
- print >>f
+ for f in files:
+ print >> f, '/*'
+ for line in banner:
+ print >> f, ' * %s' % line
+ print >> f, ' */'
+ print >> f
+
with open('src/core/lib/debug/stats_data.h', 'w') as H:
- # copy-paste copyright notice from this file
- with open(sys.argv[0]) as my_source:
- copyright = []
- for line in my_source:
- if line[0] != '#': break
- for line in my_source:
- if line[0] == '#':
- copyright.append(line)
- break
- for line in my_source:
- if line[0] != '#':
- break
- copyright.append(line)
- put_banner([H], [line[2:].rstrip() for line in copyright])
-
- put_banner([H], ["Automatically generated by tools/codegen/core/gen_stats_data.py"])
-
- print >>H, "#ifndef GRPC_CORE_LIB_DEBUG_STATS_DATA_H"
- print >>H, "#define GRPC_CORE_LIB_DEBUG_STATS_DATA_H"
- print >>H
- print >>H, "#include <inttypes.h>"
- print >>H, "#include \"src/core/lib/iomgr/exec_ctx.h\""
- print >>H
-
- for typename, instances in sorted(inst_map.items()):
- print >>H, "typedef enum {"
- for inst in instances:
- print >>H, " GRPC_STATS_%s_%s," % (typename.upper(), inst.name.upper())
- print >>H, " GRPC_STATS_%s_COUNT" % (typename.upper())
- print >>H, "} grpc_stats_%ss;" % (typename.lower())
- print >>H, "extern const char *grpc_stats_%s_name[GRPC_STATS_%s_COUNT];" % (
- typename.lower(), typename.upper())
- print >>H, "extern const char *grpc_stats_%s_doc[GRPC_STATS_%s_COUNT];" % (
- typename.lower(), typename.upper())
-
- histo_start = []
- histo_buckets = []
- histo_bucket_boundaries = []
-
- print >>H, "typedef enum {"
- first_slot = 0
- for histogram in inst_map['Histogram']:
- histo_start.append(first_slot)
- histo_buckets.append(histogram.buckets)
- print >>H, " GRPC_STATS_HISTOGRAM_%s_FIRST_SLOT = %d," % (histogram.name.upper(), first_slot)
- print >>H, " GRPC_STATS_HISTOGRAM_%s_BUCKETS = %d," % (histogram.name.upper(), histogram.buckets)
- first_slot += histogram.buckets
- print >>H, " GRPC_STATS_HISTOGRAM_BUCKETS = %d" % first_slot
- print >>H, "} grpc_stats_histogram_constants;"
-
- for ctr in inst_map['Counter']:
- print >>H, ("#define GRPC_STATS_INC_%s(exec_ctx) " +
- "GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_%s)") % (
- ctr.name.upper(), ctr.name.upper())
- for histogram in inst_map['Histogram']:
- print >>H, "#define GRPC_STATS_INC_%s(exec_ctx, value) grpc_stats_inc_%s((exec_ctx), (int)(value))" % (
- histogram.name.upper(), histogram.name.lower())
- print >>H, "void grpc_stats_inc_%s(grpc_exec_ctx *exec_ctx, int x);" % histogram.name.lower()
-
- for i, tbl in enumerate(static_tables):
- print >>H, "extern const %s grpc_stats_table_%d[%d];" % (tbl[0], i, len(tbl[1]))
-
- print >>H, "extern const int grpc_stats_histo_buckets[%d];" % len(inst_map['Histogram'])
- print >>H, "extern const int grpc_stats_histo_start[%d];" % len(inst_map['Histogram'])
- print >>H, "extern const int *const grpc_stats_histo_bucket_boundaries[%d];" % len(inst_map['Histogram'])
- print >>H, "extern void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, int x);" % len(inst_map['Histogram'])
-
- print >>H
- print >>H, "#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */"
-
-with open('src/core/lib/debug/stats_data.c', 'w') as C:
- # copy-paste copyright notice from this file
- with open(sys.argv[0]) as my_source:
- copyright = []
- for line in my_source:
- if line[0] != '#': break
- for line in my_source:
- if line[0] == '#':
- copyright.append(line)
- break
- for line in my_source:
- if line[0] != '#':
- break
- copyright.append(line)
- put_banner([C], [line[2:].rstrip() for line in copyright])
-
- put_banner([C], ["Automatically generated by tools/codegen/core/gen_stats_data.py"])
-
- print >>C, "#include \"src/core/lib/debug/stats_data.h\""
- print >>C, "#include \"src/core/lib/debug/stats.h\""
- print >>C, "#include \"src/core/lib/iomgr/exec_ctx.h\""
- print >>C, "#include <grpc/support/useful.h>"
-
- histo_code = []
- for histogram in inst_map['Histogram']:
- code, bounds_idx = gen_bucket_code(histogram)
- histo_bucket_boundaries.append(bounds_idx)
- histo_code.append(code)
-
- for typename, instances in sorted(inst_map.items()):
- print >>C, "const char *grpc_stats_%s_name[GRPC_STATS_%s_COUNT] = {" % (
- typename.lower(), typename.upper())
- for inst in instances:
- print >>C, " %s," % c_str(inst.name)
- print >>C, "};"
- print >>C, "const char *grpc_stats_%s_doc[GRPC_STATS_%s_COUNT] = {" % (
- typename.lower(), typename.upper())
- for inst in instances:
- print >>C, " %s," % c_str(inst.doc)
- print >>C, "};"
-
- for i, tbl in enumerate(static_tables):
- print >>C, "const %s grpc_stats_table_%d[%d] = {%s};" % (
- tbl[0], i, len(tbl[1]), ','.join('%s' % x for x in tbl[1]))
-
- for histogram, code in zip(inst_map['Histogram'], histo_code):
- print >>C, ("void grpc_stats_inc_%s(grpc_exec_ctx *exec_ctx, int value) {%s}") % (
- histogram.name.lower(),
- code)
-
- print >>C, "const int grpc_stats_histo_buckets[%d] = {%s};" % (
- len(inst_map['Histogram']), ','.join('%s' % x for x in histo_buckets))
- print >>C, "const int grpc_stats_histo_start[%d] = {%s};" % (
- len(inst_map['Histogram']), ','.join('%s' % x for x in histo_start))
- print >>C, "const int *const grpc_stats_histo_bucket_boundaries[%d] = {%s};" % (
- len(inst_map['Histogram']), ','.join('grpc_stats_table_%d' % x for x in histo_bucket_boundaries))
- print >>C, "void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, int x) = {%s};" % (
- len(inst_map['Histogram']), ','.join('grpc_stats_inc_%s' % histogram.name.lower() for histogram in inst_map['Histogram']))
+ # copy-paste copyright notice from this file
+ with open(sys.argv[0]) as my_source:
+ copyright = []
+ for line in my_source:
+ if line[0] != '#': break
+ for line in my_source:
+ if line[0] == '#':
+ copyright.append(line)
+ break
+ for line in my_source:
+ if line[0] != '#':
+ break
+ copyright.append(line)
+ put_banner([H], [line[2:].rstrip() for line in copyright])
+
+ put_banner(
+ [H],
+ ["Automatically generated by tools/codegen/core/gen_stats_data.py"])
+
+ print >> H, "#ifndef GRPC_CORE_LIB_DEBUG_STATS_DATA_H"
+ print >> H, "#define GRPC_CORE_LIB_DEBUG_STATS_DATA_H"
+ print >> H
+ print >> H, "#include <inttypes.h>"
+ print >> H, "#include \"src/core/lib/iomgr/exec_ctx.h\""
+ print >> H
+ print >> H, "#ifdef __cplusplus"
+ print >> H, "extern \"C\" {"
+ print >> H, "#endif"
+ print >> H
+
+ for typename, instances in sorted(inst_map.items()):
+ print >> H, "typedef enum {"
+ for inst in instances:
+ print >> H, " GRPC_STATS_%s_%s," % (typename.upper(),
+ inst.name.upper())
+ print >> H, " GRPC_STATS_%s_COUNT" % (typename.upper())
+ print >> H, "} grpc_stats_%ss;" % (typename.lower())
+ print >> H, "extern const char *grpc_stats_%s_name[GRPC_STATS_%s_COUNT];" % (
+ typename.lower(), typename.upper())
+ print >> H, "extern const char *grpc_stats_%s_doc[GRPC_STATS_%s_COUNT];" % (
+ typename.lower(), typename.upper())
+
+ histo_start = []
+ histo_buckets = []
+ histo_bucket_boundaries = []
+
+ print >> H, "typedef enum {"
+ first_slot = 0
+ for histogram in inst_map['Histogram']:
+ histo_start.append(first_slot)
+ histo_buckets.append(histogram.buckets)
+ print >> H, " GRPC_STATS_HISTOGRAM_%s_FIRST_SLOT = %d," % (
+ histogram.name.upper(), first_slot)
+ print >> H, " GRPC_STATS_HISTOGRAM_%s_BUCKETS = %d," % (
+ histogram.name.upper(), histogram.buckets)
+ first_slot += histogram.buckets
+ print >> H, " GRPC_STATS_HISTOGRAM_BUCKETS = %d" % first_slot
+ print >> H, "} grpc_stats_histogram_constants;"
+
+ for ctr in inst_map['Counter']:
+ print >> H, ("#define GRPC_STATS_INC_%s() " +
+ "GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_%s)") % (
+ ctr.name.upper(), ctr.name.upper())
+ for histogram in inst_map['Histogram']:
+ print >> H, "#define GRPC_STATS_INC_%s(value) grpc_stats_inc_%s( (int)(value))" % (
+ histogram.name.upper(), histogram.name.lower())
+ print >> H, "void grpc_stats_inc_%s(int x);" % histogram.name.lower()
+
+ for i, tbl in enumerate(static_tables):
+ print >> H, "extern const %s grpc_stats_table_%d[%d];" % (tbl[0], i,
+ len(tbl[1]))
+
+ print >> H, "extern const int grpc_stats_histo_buckets[%d];" % len(
+ inst_map['Histogram'])
+ print >> H, "extern const int grpc_stats_histo_start[%d];" % len(
+ inst_map['Histogram'])
+ print >> H, "extern const int *const grpc_stats_histo_bucket_boundaries[%d];" % len(
+ inst_map['Histogram'])
+ print >> H, "extern void (*const grpc_stats_inc_histogram[%d])(int x);" % len(
+ inst_map['Histogram'])
+
+ print >> H
+ print >> H, "#ifdef __cplusplus"
+ print >> H, "}"
+ print >> H, "#endif"
+ print >> H
+ print >> H, "#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */"
+
+with open('src/core/lib/debug/stats_data.cc', 'w') as C:
+ # copy-paste copyright notice from this file
+ with open(sys.argv[0]) as my_source:
+ copyright = []
+ for line in my_source:
+ if line[0] != '#': break
+ for line in my_source:
+ if line[0] == '#':
+ copyright.append(line)
+ break
+ for line in my_source:
+ if line[0] != '#':
+ break
+ copyright.append(line)
+ put_banner([C], [line[2:].rstrip() for line in copyright])
+
+ put_banner(
+ [C],
+ ["Automatically generated by tools/codegen/core/gen_stats_data.py"])
+
+ print >> C, "#include \"src/core/lib/debug/stats_data.h\""
+ print >> C, "#include \"src/core/lib/debug/stats.h\""
+ print >> C, "#include \"src/core/lib/iomgr/exec_ctx.h\""
+ print >> C, "#include <grpc/support/useful.h>"
+
+ histo_code = []
+ for histogram in inst_map['Histogram']:
+ code, bounds_idx = gen_bucket_code(histogram)
+ histo_bucket_boundaries.append(bounds_idx)
+ histo_code.append(code)
+
+ for typename, instances in sorted(inst_map.items()):
+ print >> C, "const char *grpc_stats_%s_name[GRPC_STATS_%s_COUNT] = {" % (
+ typename.lower(), typename.upper())
+ for inst in instances:
+ print >> C, " %s," % c_str(inst.name)
+ print >> C, "};"
+ print >> C, "const char *grpc_stats_%s_doc[GRPC_STATS_%s_COUNT] = {" % (
+ typename.lower(), typename.upper())
+ for inst in instances:
+ print >> C, " %s," % c_str(inst.doc)
+ print >> C, "};"
+
+ for i, tbl in enumerate(static_tables):
+ print >> C, "const %s grpc_stats_table_%d[%d] = {%s};" % (
+ tbl[0], i, len(tbl[1]), ','.join('%s' % x for x in tbl[1]))
+
+ for histogram, code in zip(inst_map['Histogram'], histo_code):
+ print >> C, ("void grpc_stats_inc_%s(int value) {%s}") % (
+ histogram.name.lower(), code)
+
+ print >> C, "const int grpc_stats_histo_buckets[%d] = {%s};" % (
+ len(inst_map['Histogram']), ','.join('%s' % x for x in histo_buckets))
+ print >> C, "const int grpc_stats_histo_start[%d] = {%s};" % (
+ len(inst_map['Histogram']), ','.join('%s' % x for x in histo_start))
+ print >> C, "const int *const grpc_stats_histo_bucket_boundaries[%d] = {%s};" % (
+ len(inst_map['Histogram']), ','.join(
+ 'grpc_stats_table_%d' % x for x in histo_bucket_boundaries))
+ print >> C, "void (*const grpc_stats_inc_histogram[%d])(int x) = {%s};" % (
+ len(inst_map['Histogram']), ','.join(
+ 'grpc_stats_inc_%s' % histogram.name.lower()
+ for histogram in inst_map['Histogram']))
# patch qps_test bigquery schema
RECORD_EXPLICIT_PERCENTILES = [50, 95, 99]
with open('tools/run_tests/performance/scenario_result_schema.json', 'r') as f:
- qps_schema = json.loads(f.read())
+ qps_schema = json.loads(f.read())
+
def FindNamed(js, name):
- for el in js:
- if el['name'] == name:
- return el
+ for el in js:
+ if el['name'] == name:
+ return el
+
def RemoveCoreFields(js):
- new_fields = []
- for field in js['fields']:
- if not field['name'].startswith('core_'):
- new_fields.append(field)
- js['fields'] = new_fields
+ new_fields = []
+ for field in js['fields']:
+ if not field['name'].startswith('core_'):
+ new_fields.append(field)
+ js['fields'] = new_fields
+
RemoveCoreFields(FindNamed(qps_schema, 'clientStats'))
RemoveCoreFields(FindNamed(qps_schema, 'serverStats'))
+
def AddCoreFields(js):
- for counter in inst_map['Counter']:
- js['fields'].append({
- 'name': 'core_%s' % counter.name,
- 'type': 'INTEGER',
- 'mode': 'NULLABLE'
- })
- for histogram in inst_map['Histogram']:
- js['fields'].append({
- 'name': 'core_%s' % histogram.name,
- 'type': 'STRING',
- 'mode': 'NULLABLE'
- })
- js['fields'].append({
- 'name': 'core_%s_bkts' % histogram.name,
- 'type': 'STRING',
- 'mode': 'NULLABLE'
- })
- for pctl in RECORD_EXPLICIT_PERCENTILES:
- js['fields'].append({
- 'name': 'core_%s_%dp' % (histogram.name, pctl),
- 'type': 'FLOAT',
- 'mode': 'NULLABLE'
- })
+ for counter in inst_map['Counter']:
+ js['fields'].append({
+ 'name': 'core_%s' % counter.name,
+ 'type': 'INTEGER',
+ 'mode': 'NULLABLE'
+ })
+ for histogram in inst_map['Histogram']:
+ js['fields'].append({
+ 'name': 'core_%s' % histogram.name,
+ 'type': 'STRING',
+ 'mode': 'NULLABLE'
+ })
+ js['fields'].append({
+ 'name': 'core_%s_bkts' % histogram.name,
+ 'type': 'STRING',
+ 'mode': 'NULLABLE'
+ })
+ for pctl in RECORD_EXPLICIT_PERCENTILES:
+ js['fields'].append({
+ 'name': 'core_%s_%dp' % (histogram.name, pctl),
+ 'type': 'FLOAT',
+ 'mode': 'NULLABLE'
+ })
+
AddCoreFields(FindNamed(qps_schema, 'clientStats'))
AddCoreFields(FindNamed(qps_schema, 'serverStats'))
with open('tools/run_tests/performance/scenario_result_schema.json', 'w') as f:
- f.write(json.dumps(qps_schema, indent=2, sort_keys=True))
+ f.write(json.dumps(qps_schema, indent=2, sort_keys=True))
# and generate a helper script to massage scenario results into the format we'd
# like to query
with open('tools/run_tests/performance/massage_qps_stats.py', 'w') as P:
- with open(sys.argv[0]) as my_source:
- for line in my_source:
- if line[0] != '#': break
- for line in my_source:
- if line[0] == '#':
- print >>P, line.rstrip()
- break
- for line in my_source:
- if line[0] != '#':
- break
- print >>P, line.rstrip()
-
- print >>P
- print >>P, '# Autogenerated by tools/codegen/core/gen_stats_data.py'
- print >>P
-
- print >>P, 'import massage_qps_stats_helpers'
-
- print >>P, 'def massage_qps_stats(scenario_result):'
- print >>P, ' for stats in scenario_result["serverStats"] + scenario_result["clientStats"]:'
- print >>P, ' if "coreStats" not in stats: return'
- print >>P, ' core_stats = stats["coreStats"]'
- print >>P, ' del stats["coreStats"]'
- for counter in inst_map['Counter']:
- print >>P, ' stats["core_%s"] = massage_qps_stats_helpers.counter(core_stats, "%s")' % (counter.name, counter.name)
- for i, histogram in enumerate(inst_map['Histogram']):
- print >>P, ' h = massage_qps_stats_helpers.histogram(core_stats, "%s")' % histogram.name
- print >>P, ' stats["core_%s"] = ",".join("%%f" %% x for x in h.buckets)' % histogram.name
- print >>P, ' stats["core_%s_bkts"] = ",".join("%%f" %% x for x in h.boundaries)' % histogram.name
- for pctl in RECORD_EXPLICIT_PERCENTILES:
- print >>P, ' stats["core_%s_%dp"] = massage_qps_stats_helpers.percentile(h.buckets, %d, h.boundaries)' % (
- histogram.name, pctl, pctl)
+ with open(sys.argv[0]) as my_source:
+ for line in my_source:
+ if line[0] != '#': break
+ for line in my_source:
+ if line[0] == '#':
+ print >> P, line.rstrip()
+ break
+ for line in my_source:
+ if line[0] != '#':
+ break
+ print >> P, line.rstrip()
+
+ print >> P
+ print >> P, '# Autogenerated by tools/codegen/core/gen_stats_data.py'
+ print >> P
+
+ print >> P, 'import massage_qps_stats_helpers'
+
+ print >> P, 'def massage_qps_stats(scenario_result):'
+ print >> P, ' for stats in scenario_result["serverStats"] + scenario_result["clientStats"]:'
+ print >> P, ' if "coreStats" not in stats: return'
+ print >> P, ' core_stats = stats["coreStats"]'
+ print >> P, ' del stats["coreStats"]'
+ for counter in inst_map['Counter']:
+ print >> P, ' stats["core_%s"] = massage_qps_stats_helpers.counter(core_stats, "%s")' % (
+ counter.name, counter.name)
+ for i, histogram in enumerate(inst_map['Histogram']):
+ print >> P, ' h = massage_qps_stats_helpers.histogram(core_stats, "%s")' % histogram.name
+ print >> P, ' stats["core_%s"] = ",".join("%%f" %% x for x in h.buckets)' % histogram.name
+ print >> P, ' stats["core_%s_bkts"] = ",".join("%%f" %% x for x in h.boundaries)' % histogram.name
+ for pctl in RECORD_EXPLICIT_PERCENTILES:
+ print >> P, ' stats["core_%s_%dp"] = massage_qps_stats_helpers.percentile(h.buckets, %d, h.boundaries)' % (
+ histogram.name, pctl, pctl)
with open('src/core/lib/debug/stats_data_bq_schema.sql', 'w') as S:
- columns = []
- for counter in inst_map['Counter']:
- columns.append(('%s_per_iteration' % counter.name, 'FLOAT'))
- print >>S, ',\n'.join('%s:%s' % x for x in columns)
+ columns = []
+ for counter in inst_map['Counter']:
+ columns.append(('%s_per_iteration' % counter.name, 'FLOAT'))
+ print >> S, ',\n'.join('%s:%s' % x for x in columns)
diff --git a/tools/debug/core/chttp2_ref_leak.py b/tools/debug/core/chttp2_ref_leak.py
new file mode 100755
index 0000000000..a6a5448775
--- /dev/null
+++ b/tools/debug/core/chttp2_ref_leak.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python2.7
+# 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.
+
+# Reads stdin to find chttp2_refcount log lines, and prints reference leaks
+# to stdout
+
+import collections
+import sys
+import re
+
+
+def new_obj():
+ return ['destroy']
+
+
+outstanding = collections.defaultdict(new_obj)
+
+# Sample log line:
+# chttp2:unref:0x629000005200 2->1 destroy [src/core/ext/transport/chttp2/transport/chttp2_transport.c:599]
+
+for line in sys.stdin:
+ m = re.search(
+ r'chttp2:( ref|unref):0x([a-fA-F0-9]+) [^ ]+ ([^[]+) \[(.*)\]', line)
+ if m:
+ if m.group(1) == ' ref':
+ outstanding[m.group(2)].append(m.group(3))
+ else:
+ outstanding[m.group(2)].remove(m.group(3))
+
+for obj, remaining in outstanding.items():
+ if remaining:
+ print 'LEAKED: %s %r' % (obj, remaining)
diff --git a/tools/debug/core/error_ref_leak.py b/tools/debug/core/error_ref_leak.py
new file mode 100644
index 0000000000..7e206c26b2
--- /dev/null
+++ b/tools/debug/core/error_ref_leak.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python2.7
+#
+# 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.
+
+# Reads stdin to find error_refcount log lines, and prints reference leaks
+# to stdout
+
+# usege: python error_ref_leak < logfile.txt
+
+import sys
+import re
+
+data = sys.stdin.readlines()
+
+errs = []
+for line in data:
+ # if we care about the line
+ if re.search(r'error.cc', line):
+ # str manip to cut off left part of log line
+ line = line.partition('error.cc:')[-1]
+ line = re.sub(r'\d+] ', r'', line)
+ line = line.strip().split()
+ err = line[0].strip(":")
+ if line[1] == "create":
+ assert (err not in errs)
+ errs.append(err)
+ elif line[0] == "realloc":
+ errs.remove(line[1])
+ errs.append(line[3])
+ # explicitly look for the last dereference
+ elif line[1] == "1" and line[3] == "0":
+ assert (err in errs)
+ errs.remove(err)
+
+print "leaked:", errs
diff --git a/tools/distrib/build_ruby_environment_macos.sh b/tools/distrib/build_ruby_environment_macos.sh
index c2240ce976..4a388a0e5c 100644
--- a/tools/distrib/build_ruby_environment_macos.sh
+++ b/tools/distrib/build_ruby_environment_macos.sh
@@ -17,13 +17,14 @@ set -ex
rm -rf ~/.rake-compiler
-CROSS_RUBY=`mktemp tmpfile.XXXXXXXX`
+CROSS_RUBY=$(mktemp tmpfile.XXXXXXXX)
-curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.0.3/tasks/bin/cross-ruby.rake > $CROSS_RUBY
+curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.0.3/tasks/bin/cross-ruby.rake > "$CROSS_RUBY"
-patch $CROSS_RUBY << EOF
---- cross-ruby.rake 2016-02-05 16:26:53.000000000 -0800
-+++ cross-ruby.rake.patched 2016-02-05 16:27:33.000000000 -0800
+# See https://github.com/grpc/grpc/issues/12161 for verconf.h patch details
+patch "$CROSS_RUBY" << EOF
+--- cross-ruby.rake 2017-09-27 16:46:00.311020325 +0200
++++ patched 2017-09-27 16:49:46.127016895 +0200
@@ -133,7 +133,8 @@
"--host=#{MINGW_HOST}",
"--target=#{MINGW_TARGET}",
@@ -32,16 +33,25 @@ patch $CROSS_RUBY << EOF
+ '--enable-static',
+ '--disable-shared',
'--disable-install-doc',
- '--without-tk',
- '--without-tcl'
+ '--with-ext='
+ ]
+@@ -151,6 +152,7 @@
+ # make
+ file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
+ chdir File.dirname(t.prerequisites.first) do
++ sh "test -s verconf.h || rm -f verconf.h" # if verconf.h has size 0, make sure it gets re-built by make
+ sh MAKE
+ end
+ end
EOF
MAKE="make -j8"
-for v in 2.4.0 2.3.0 2.2.2 2.1.5 2.0.0-p645 ; do
+for v in 2.5.0 2.4.0 2.3.0 2.2.2 2.1.6 2.0.0-p645 ; do
ccache -c
- rake -f $CROSS_RUBY cross-ruby VERSION=$v HOST=x86_64-darwin11
+ rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
done
-sed 's/x86_64-darwin-11/universal-darwin/' ~/.rake-compiler/config.yml > $CROSS_RUBY
-mv $CROSS_RUBY ~/.rake-compiler/config.yml
+sed 's/x86_64-darwin-11/universal-darwin/' ~/.rake-compiler/config.yml > "$CROSS_RUBY"
+mv "$CROSS_RUBY" ~/.rake-compiler/config.yml
+
diff --git a/tools/distrib/c-ish/check_documentation.py b/tools/distrib/c-ish/check_documentation.py
index 24da0051ad..fef8f4ee5d 100755
--- a/tools/distrib/c-ish/check_documentation.py
+++ b/tools/distrib/c-ish/check_documentation.py
@@ -22,24 +22,15 @@ import sys
# where do we run
_TARGET_DIRS = [
- 'include/grpc',
- 'include/grpc++',
- 'src/core',
- 'src/cpp',
- 'test/core',
- 'test/cpp'
+ 'include/grpc', 'include/grpc++', 'src/core', 'src/cpp', 'test/core',
+ 'test/cpp'
]
# which file extensions do we care about
-_INTERESTING_EXTENSIONS = [
- '.c',
- '.h',
- '.cc'
-]
+_INTERESTING_EXTENSIONS = ['.c', '.h', '.cc']
# find our home
-_ROOT = os.path.abspath(
- os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
+_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
os.chdir(_ROOT)
errors = 0
@@ -47,30 +38,30 @@ errors = 0
# walk directories, find things
printed_banner = False
for target_dir in _TARGET_DIRS:
- for root, dirs, filenames in os.walk(target_dir):
- if 'README.md' not in filenames:
- if not printed_banner:
- print 'Missing README.md'
- print '================='
- printed_banner = True
- print root
- errors += 1
+ for root, dirs, filenames in os.walk(target_dir):
+ if 'README.md' not in filenames:
+ if not printed_banner:
+ print 'Missing README.md'
+ print '================='
+ printed_banner = True
+ print root
+ errors += 1
if printed_banner: print
printed_banner = False
for target_dir in _TARGET_DIRS:
- for root, dirs, filenames in os.walk(target_dir):
- for filename in filenames:
- if os.path.splitext(filename)[1] not in _INTERESTING_EXTENSIONS:
- continue
- path = os.path.join(root, filename)
- with open(path) as f:
- contents = f.read()
- if '\\file' not in contents:
- if not printed_banner:
- print 'Missing \\file comment'
- print '======================'
- printed_banner = True
- print path
- errors += 1
+ for root, dirs, filenames in os.walk(target_dir):
+ for filename in filenames:
+ if os.path.splitext(filename)[1] not in _INTERESTING_EXTENSIONS:
+ continue
+ path = os.path.join(root, filename)
+ with open(path) as f:
+ contents = f.read()
+ if '\\file' not in contents:
+ if not printed_banner:
+ print 'Missing \\file comment'
+ print '======================'
+ printed_banner = True
+ print path
+ errors += 1
assert errors == 0, 'error count = %d' % errors
diff --git a/tools/distrib/check_copyright.py b/tools/distrib/check_copyright.py
index 6ecacede71..0eb2cbe1a2 100755
--- a/tools/distrib/check_copyright.py
+++ b/tools/distrib/check_copyright.py
@@ -22,149 +22,138 @@ import sys
import subprocess
# find our home
-ROOT = os.path.abspath(
- os.path.join(os.path.dirname(sys.argv[0]), '../..'))
+ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
os.chdir(ROOT)
# parse command line
argp = argparse.ArgumentParser(description='copyright checker')
-argp.add_argument('-o', '--output',
- default='details',
- choices=['list', 'details'])
-argp.add_argument('-s', '--skips',
- default=0,
- action='store_const',
- const=1)
-argp.add_argument('-a', '--ancient',
- default=0,
- action='store_const',
- const=1)
-argp.add_argument('--precommit',
- default=False,
- action='store_true')
+argp.add_argument(
+ '-o', '--output', default='details', choices=['list', 'details'])
+argp.add_argument('-s', '--skips', default=0, action='store_const', const=1)
+argp.add_argument('-a', '--ancient', default=0, action='store_const', const=1)
+argp.add_argument('--precommit', default=False, action='store_true')
args = argp.parse_args()
# open the license text
with open('NOTICE.txt') as f:
- LICENSE_NOTICE = f.read().splitlines()
-
+ LICENSE_NOTICE = f.read().splitlines()
# license format by file extension
# key is the file extension, value is a format string
# that given a line of license text, returns what should
# be in the file
LICENSE_PREFIX = {
- '.bat': r'@rem\s*',
- '.c': r'\s*(?://|\*)\s*',
- '.cc': r'\s*(?://|\*)\s*',
- '.h': r'\s*(?://|\*)\s*',
- '.m': r'\s*\*\s*',
- '.php': r'\s*\*\s*',
- '.js': r'\s*\*\s*',
- '.py': r'#\s*',
- '.pyx': r'#\s*',
- '.pxd': r'#\s*',
- '.pxi': r'#\s*',
- '.rb': r'#\s*',
- '.sh': r'#\s*',
- '.proto': r'//\s*',
- '.cs': r'//\s*',
- '.mak': r'#\s*',
- 'Makefile': r'#\s*',
- 'Dockerfile': r'#\s*',
- 'BUILD': r'#\s*',
+ '.bat': r'@rem\s*',
+ '.c': r'\s*(?://|\*)\s*',
+ '.cc': r'\s*(?://|\*)\s*',
+ '.h': r'\s*(?://|\*)\s*',
+ '.m': r'\s*\*\s*',
+ '.mm': r'\s*\*\s*',
+ '.php': r'\s*\*\s*',
+ '.js': r'\s*\*\s*',
+ '.py': r'#\s*',
+ '.pyx': r'#\s*',
+ '.pxd': r'#\s*',
+ '.pxi': r'#\s*',
+ '.rb': r'#\s*',
+ '.sh': r'#\s*',
+ '.proto': r'//\s*',
+ '.cs': r'//\s*',
+ '.mak': r'#\s*',
+ 'Makefile': r'#\s*',
+ 'Dockerfile': r'#\s*',
+ 'BUILD': r'#\s*',
}
_EXEMPT = frozenset((
- # Generated protocol compiler output.
- 'examples/python/helloworld/helloworld_pb2.py',
- 'examples/python/helloworld/helloworld_pb2_grpc.py',
- 'examples/python/multiplex/helloworld_pb2.py',
- 'examples/python/multiplex/helloworld_pb2_grpc.py',
- 'examples/python/multiplex/route_guide_pb2.py',
- 'examples/python/multiplex/route_guide_pb2_grpc.py',
- 'examples/python/route_guide/route_guide_pb2.py',
- 'examples/python/route_guide/route_guide_pb2_grpc.py',
-
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
- 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
- 'src/cpp/server/health/health.pb.h',
- 'src/cpp/server/health/health.pb.c',
-
- # An older file originally from outside gRPC.
- 'src/php/tests/bootstrap.php',
- # census.proto copied from github
- 'tools/grpcz/census.proto',
- # status.proto copied from googleapis
- 'src/proto/grpc/status/status.proto',
+ # Generated protocol compiler output.
+ 'examples/python/helloworld/helloworld_pb2.py',
+ 'examples/python/helloworld/helloworld_pb2_grpc.py',
+ 'examples/python/multiplex/helloworld_pb2.py',
+ 'examples/python/multiplex/helloworld_pb2_grpc.py',
+ 'examples/python/multiplex/route_guide_pb2.py',
+ 'examples/python/multiplex/route_guide_pb2_grpc.py',
+ 'examples/python/route_guide/route_guide_pb2.py',
+ 'examples/python/route_guide/route_guide_pb2_grpc.py',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
+ 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
+ 'src/cpp/server/health/health.pb.h',
+ 'src/cpp/server/health/health.pb.c',
+
+ # An older file originally from outside gRPC.
+ 'src/php/tests/bootstrap.php',
+ # census.proto copied from github
+ 'tools/grpcz/census.proto',
+ # status.proto copied from googleapis
+ 'src/proto/grpc/status/status.proto',
))
-
RE_YEAR = r'Copyright (?P<first_year>[0-9]+\-)?(?P<last_year>[0-9]+) gRPC authors.'
RE_LICENSE = dict(
- (k, r'\n'.join(
- LICENSE_PREFIX[k] +
- (RE_YEAR if re.search(RE_YEAR, line) else re.escape(line))
- for line in LICENSE_NOTICE))
- for k, v in LICENSE_PREFIX.iteritems())
+ (k, r'\n'.join(LICENSE_PREFIX[k] +
+ (RE_YEAR if re.search(RE_YEAR, line) else re.escape(line))
+ for line in LICENSE_NOTICE))
+ for k, v in LICENSE_PREFIX.iteritems())
if args.precommit:
- FILE_LIST_COMMAND = 'git status -z | grep -Poz \'(?<=^[MARC][MARCD ] )[^\s]+\''
+ FILE_LIST_COMMAND = 'git status -z | grep -Poz \'(?<=^[MARC][MARCD ] )[^\s]+\''
else:
- FILE_LIST_COMMAND = 'git ls-tree -r --name-only -r HEAD | ' \
- 'grep -v ^third_party/ |' \
- 'grep -v "\(ares_config.h\|ares_build.h\)"'
+ FILE_LIST_COMMAND = 'git ls-tree -r --name-only -r HEAD | ' \
+ 'grep -v ^third_party/ |' \
+ 'grep -v "\(ares_config.h\|ares_build.h\)"'
+
def load(name):
- with open(name) as f:
- return f.read()
+ with open(name) as f:
+ return f.read()
+
def save(name, text):
- with open(name, 'w') as f:
- f.write(text)
+ with open(name, 'w') as f:
+ f.write(text)
-assert(re.search(RE_LICENSE['Makefile'], load('Makefile')))
+assert (re.search(RE_LICENSE['Makefile'], load('Makefile')))
def log(cond, why, filename):
- if not cond: return
- if args.output == 'details':
- print '%s: %s' % (why, filename)
- else:
- print filename
+ if not cond: return
+ if args.output == 'details':
+ print '%s: %s' % (why, filename)
+ else:
+ print filename
# scan files, validate the text
ok = True
filename_list = []
try:
- filename_list = subprocess.check_output(FILE_LIST_COMMAND,
- shell=True).splitlines()
+ filename_list = subprocess.check_output(
+ FILE_LIST_COMMAND, shell=True).splitlines()
except subprocess.CalledProcessError:
- sys.exit(0)
+ sys.exit(0)
for filename in filename_list:
- if filename in _EXEMPT:
- continue
- ext = os.path.splitext(filename)[1]
- base = os.path.basename(filename)
- if ext in RE_LICENSE:
- re_license = RE_LICENSE[ext]
- elif base in RE_LICENSE:
- re_license = RE_LICENSE[base]
- else:
- log(args.skips, 'skip', filename)
- continue
- try:
- text = load(filename)
- except:
- continue
- m = re.search(re_license, text)
- if m:
- pass
- elif 'DO NOT EDIT' not in text and filename != 'src/boringssl/err_data.c':
- log(1, 'copyright missing', filename)
- ok = False
+ if filename in _EXEMPT:
+ continue
+ ext = os.path.splitext(filename)[1]
+ base = os.path.basename(filename)
+ if ext in RE_LICENSE:
+ re_license = RE_LICENSE[ext]
+ elif base in RE_LICENSE:
+ re_license = RE_LICENSE[base]
+ else:
+ log(args.skips, 'skip', filename)
+ continue
+ try:
+ text = load(filename)
+ except:
+ continue
+ m = re.search(re_license, text)
+ if m:
+ pass
+ elif 'DO NOT EDIT' not in text and filename != 'src/boringssl/err_data.c':
+ log(1, 'copyright missing', filename)
+ ok = False
sys.exit(0 if ok else 1)
diff --git a/tools/distrib/check_include_guards.py b/tools/distrib/check_include_guards.py
index e46f1c9f4c..6fc606f2ef 100755
--- a/tools/distrib/check_include_guards.py
+++ b/tools/distrib/check_include_guards.py
@@ -23,136 +23,136 @@ import subprocess
def build_valid_guard(fpath):
- prefix = 'GRPC_' if not fpath.startswith('include/') else ''
- return prefix + '_'.join(fpath.replace('++', 'XX').replace('.', '_').upper().split('/')[1:])
+ prefix = 'GRPC_' if not fpath.startswith('include/') else ''
+ return prefix + '_'.join(
+ fpath.replace('++', 'XX').replace('.', '_').upper().split('/')[1:])
def load(fpath):
- with open(fpath, 'r') as f:
- return f.read()
+ with open(fpath, 'r') as f:
+ return f.read()
def save(fpath, contents):
- with open(fpath, 'w') as f:
- f.write(contents)
+ with open(fpath, 'w') as f:
+ f.write(contents)
class GuardValidator(object):
- def __init__(self):
- self.ifndef_re = re.compile(r'#ifndef ([A-Z][A-Z_1-9]*)')
- self.define_re = re.compile(r'#define ([A-Z][A-Z_1-9]*)')
- self.endif_c_re = re.compile(r'#endif /\* ([A-Z][A-Z_1-9]*) (?:\\ *\n *)?\*/')
- self.endif_cpp_re = re.compile(r'#endif // ([A-Z][A-Z_1-9]*)')
- self.failed = False
-
- def fail(self, fpath, regexp, fcontents, match_txt, correct, fix):
- cpp_header = 'grpc++' in fpath
- self.failed = True
- invalid_guards_msg_template = (
- '{0}: Missing preprocessor guards (RE {1}). '
- 'Please wrap your code around the following guards:\n'
- '#ifndef {2}\n'
- '#define {2}\n'
- '...\n'
- '... epic code ...\n'
- '...\n') + ('#endif // {2}' if cpp_header else '#endif /* {2} */')
- if not match_txt:
- print invalid_guards_msg_template.format(fpath, regexp.pattern,
- build_valid_guard(fpath))
- return fcontents
-
- print ('{}: Wrong preprocessor guards (RE {}):'
- '\n\tFound {}, expected {}').format(
- fpath, regexp.pattern, match_txt, correct)
- if fix:
- print 'Fixing {}...\n'.format(fpath)
- fixed_fcontents = re.sub(match_txt, correct, fcontents)
- if fixed_fcontents:
+
+ def __init__(self):
+ self.ifndef_re = re.compile(r'#ifndef ([A-Z][A-Z_1-9]*)')
+ self.define_re = re.compile(r'#define ([A-Z][A-Z_1-9]*)')
+ self.endif_c_re = re.compile(
+ r'#endif /\* ([A-Z][A-Z_1-9]*) (?:\\ *\n *)?\*/')
+ self.endif_cpp_re = re.compile(r'#endif // ([A-Z][A-Z_1-9]*)')
self.failed = False
- return fixed_fcontents
- else:
- print
- return fcontents
-
- def check(self, fpath, fix):
- cpp_header = 'grpc++' in fpath
- valid_guard = build_valid_guard(fpath)
-
- fcontents = load(fpath)
-
- match = self.ifndef_re.search(fcontents)
- if not match:
- print 'something drastically wrong with: %s' % fpath
- return False # failed
- if match.lastindex is None:
- # No ifndef. Request manual addition with hints
- self.fail(fpath, match.re, match.string, '', '', False)
- return False # failed
-
- # Does the guard end with a '_H'?
- running_guard = match.group(1)
- if not running_guard.endswith('_H'):
- fcontents = self.fail(fpath, match.re, match.string, match.group(1),
- valid_guard, fix)
- if fix: save(fpath, fcontents)
-
- # Is it the expected one based on the file path?
- if running_guard != valid_guard:
- fcontents = self.fail(fpath, match.re, match.string, match.group(1),
- valid_guard, fix)
- if fix: save(fpath, fcontents)
-
- # Is there a #define? Is it the same as the #ifndef one?
- match = self.define_re.search(fcontents)
- if match.lastindex is None:
- # No define. Request manual addition with hints
- self.fail(fpath, match.re, match.string, '', '', False)
- return False # failed
-
- # Is the #define guard the same as the #ifndef guard?
- if match.group(1) != running_guard:
- fcontents = self.fail(fpath, match.re, match.string, match.group(1),
- valid_guard, fix)
- if fix: save(fpath, fcontents)
-
- # Is there a properly commented #endif?
- endif_re = self.endif_cpp_re if cpp_header else self.endif_c_re
- flines = fcontents.rstrip().splitlines()
- match = endif_re.search('\n'.join(flines[-2:]))
- if not match:
- # No endif. Check if we have the last line as just '#endif' and if so
- # replace it with a properly commented one.
- if flines[-1] == '#endif':
- flines[-1] = ('#endif' +
- (' // {}\n'.format(valid_guard) if cpp_header
- else ' /* {} */\n'.format(valid_guard)))
+
+ def fail(self, fpath, regexp, fcontents, match_txt, correct, fix):
+ cpp_header = 'grpc++' in fpath
+ self.failed = True
+ invalid_guards_msg_template = (
+ '{0}: Missing preprocessor guards (RE {1}). '
+ 'Please wrap your code around the following guards:\n'
+ '#ifndef {2}\n'
+ '#define {2}\n'
+ '...\n'
+ '... epic code ...\n'
+ '...\n') + ('#endif // {2}' if cpp_header else '#endif /* {2} */')
+ if not match_txt:
+ print invalid_guards_msg_template.format(fpath, regexp.pattern,
+ build_valid_guard(fpath))
+ return fcontents
+
+ print('{}: Wrong preprocessor guards (RE {}):'
+ '\n\tFound {}, expected {}').format(fpath, regexp.pattern,
+ match_txt, correct)
if fix:
- fcontents = '\n'.join(flines)
- save(fpath, fcontents)
- else:
- # something else is wrong, bail out
- self.fail(fpath, endif_re, flines[-1], '', '', False)
- elif match.group(1) != running_guard:
- # Is the #endif guard the same as the #ifndef and #define guards?
- fcontents = self.fail(fpath, endif_re, fcontents, match.group(1),
- valid_guard, fix)
- if fix: save(fpath, fcontents)
-
- return not self.failed # Did the check succeed? (ie, not failed)
+ print 'Fixing {}...\n'.format(fpath)
+ fixed_fcontents = re.sub(match_txt, correct, fcontents)
+ if fixed_fcontents:
+ self.failed = False
+ return fixed_fcontents
+ else:
+ print
+ return fcontents
+
+ def check(self, fpath, fix):
+ cpp_header = 'grpc++' in fpath
+ valid_guard = build_valid_guard(fpath)
+
+ fcontents = load(fpath)
+
+ match = self.ifndef_re.search(fcontents)
+ if not match:
+ print 'something drastically wrong with: %s' % fpath
+ return False # failed
+ if match.lastindex is None:
+ # No ifndef. Request manual addition with hints
+ self.fail(fpath, match.re, match.string, '', '', False)
+ return False # failed
+
+ # Does the guard end with a '_H'?
+ running_guard = match.group(1)
+ if not running_guard.endswith('_H'):
+ fcontents = self.fail(fpath, match.re, match.string, match.group(1),
+ valid_guard, fix)
+ if fix: save(fpath, fcontents)
+
+ # Is it the expected one based on the file path?
+ if running_guard != valid_guard:
+ fcontents = self.fail(fpath, match.re, match.string, match.group(1),
+ valid_guard, fix)
+ if fix: save(fpath, fcontents)
+
+ # Is there a #define? Is it the same as the #ifndef one?
+ match = self.define_re.search(fcontents)
+ if match.lastindex is None:
+ # No define. Request manual addition with hints
+ self.fail(fpath, match.re, match.string, '', '', False)
+ return False # failed
+
+ # Is the #define guard the same as the #ifndef guard?
+ if match.group(1) != running_guard:
+ fcontents = self.fail(fpath, match.re, match.string, match.group(1),
+ valid_guard, fix)
+ if fix: save(fpath, fcontents)
+
+ # Is there a properly commented #endif?
+ endif_re = self.endif_cpp_re if cpp_header else self.endif_c_re
+ flines = fcontents.rstrip().splitlines()
+ match = endif_re.search('\n'.join(flines[-2:]))
+ if not match:
+ # No endif. Check if we have the last line as just '#endif' and if so
+ # replace it with a properly commented one.
+ if flines[-1] == '#endif':
+ flines[-1] = (
+ '#endif' +
+ (' // {}\n'.format(valid_guard)
+ if cpp_header else ' /* {} */\n'.format(valid_guard)))
+ if fix:
+ fcontents = '\n'.join(flines)
+ save(fpath, fcontents)
+ else:
+ # something else is wrong, bail out
+ self.fail(fpath, endif_re, flines[-1], '', '', False)
+ elif match.group(1) != running_guard:
+ # Is the #endif guard the same as the #ifndef and #define guards?
+ fcontents = self.fail(fpath, endif_re, fcontents, match.group(1),
+ valid_guard, fix)
+ if fix: save(fpath, fcontents)
+
+ return not self.failed # Did the check succeed? (ie, not failed)
+
# find our home
-ROOT = os.path.abspath(
- os.path.join(os.path.dirname(sys.argv[0]), '../..'))
+ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
os.chdir(ROOT)
# parse command line
argp = argparse.ArgumentParser(description='include guard checker')
-argp.add_argument('-f', '--fix',
- default=False,
- action='store_true');
-argp.add_argument('--precommit',
- default=False,
- action='store_true')
+argp.add_argument('-f', '--fix', default=False, action='store_true')
+argp.add_argument('--precommit', default=False, action='store_true')
args = argp.parse_args()
KNOWN_BAD = set([
@@ -161,12 +161,11 @@ KNOWN_BAD = set([
'include/grpc++/ext/reflection.pb.h',
])
-
grep_filter = r"grep -E '^(include|src/core)/.*\.h$'"
if args.precommit:
- git_command = 'git diff --name-only HEAD'
+ git_command = 'git diff --name-only HEAD'
else:
- git_command = 'git ls-tree -r --name-only -r HEAD'
+ git_command = 'git ls-tree -r --name-only -r HEAD'
FILE_LIST_COMMAND = ' | '.join((git_command, grep_filter))
@@ -174,17 +173,17 @@ FILE_LIST_COMMAND = ' | '.join((git_command, grep_filter))
ok = True
filename_list = []
try:
- filename_list = subprocess.check_output(FILE_LIST_COMMAND,
- shell=True).splitlines()
- # Filter out non-existent files (ie, file removed or renamed)
- filename_list = (f for f in filename_list if os.path.isfile(f))
+ filename_list = subprocess.check_output(
+ FILE_LIST_COMMAND, shell=True).splitlines()
+ # Filter out non-existent files (ie, file removed or renamed)
+ filename_list = (f for f in filename_list if os.path.isfile(f))
except subprocess.CalledProcessError:
- sys.exit(0)
+ sys.exit(0)
validator = GuardValidator()
for filename in filename_list:
- if filename in KNOWN_BAD: continue
- ok = ok and validator.check(filename, args.fix)
+ if filename in KNOWN_BAD: continue
+ ok = ok and validator.check(filename, args.fix)
sys.exit(0 if ok else 1)
diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh
index 81a04cbf57..a30b73f689 100755
--- a/tools/distrib/check_nanopb_output.sh
+++ b/tools/distrib/check_nanopb_output.sh
@@ -51,7 +51,7 @@ readonly LOAD_BALANCER_GRPC_OUTPUT_PATH='src/core/ext/filters/client_channel/lb_
"$LOAD_BALANCER_GRPC_OUTPUT_PATH"
# compare outputs to checked compiled code
-if ! diff -r $NANOPB_TMP_OUTPUT src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1; then
+if ! diff -r "$NANOPB_TMP_OUTPUT" src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1; then
echo "Outputs differ: $NANOPB_TMP_OUTPUT vs $LOAD_BALANCER_GRPC_OUTPUT_PATH"
exit 2
fi
diff --git a/tools/distrib/check_windows_dlls.sh b/tools/distrib/check_windows_dlls.sh
index 9b03e8bf3e..c25091edfd 100755
--- a/tools/distrib/check_windows_dlls.sh
+++ b/tools/distrib/check_windows_dlls.sh
@@ -16,7 +16,7 @@
set -ex
# change to root directory
-cd $(dirname $0)/../..
+cd "$(dirname "$0")/../.."
bundle
rake dlls
diff --git a/tools/distrib/clang_tidy_code.sh b/tools/distrib/clang_tidy_code.sh
new file mode 100755
index 0000000000..5da86aa277
--- /dev/null
+++ b/tools/distrib/clang_tidy_code.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# 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.
+
+echo "NOTE: to automagically apply fixes, invoke with --fix"
+
+set -ex
+
+# change to root directory
+cd $(dirname $0)/../..
+REPO_ROOT=$(pwd)
+
+if [ "$CLANG_TIDY_SKIP_DOCKER" == "" ]
+then
+ # build clang-tidy docker image
+ docker build -t grpc_clang_tidy tools/dockerfile/grpc_clang_tidy
+
+ # run clang-tidy against the checked out codebase
+ docker run -e TEST=$TEST -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_TIDY_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code -t grpc_clang_tidy /clang_tidy_all_the_things.sh "$@"
+else
+ CLANG_TIDY_ROOT="${REPO_ROOT}" tools/dockerfile/grpc_clang_tidy/clang_tidy_all_the_things.sh "$@"
+fi
diff --git a/tools/distrib/pull_requests_interval.sh b/tools/distrib/pull_requests_interval.sh
new file mode 100755
index 0000000000..7a6c702daa
--- /dev/null
+++ b/tools/distrib/pull_requests_interval.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+# 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.
+
+if [ "x$1" = "x" ] ; then
+ echo "Usage: $0 <first ref> [second ref]"
+ exit 1
+else
+ first=$1
+fi
+
+if [ -n $2 ] ; then
+ second=HEAD
+fi
+
+if [ -e ~/github-credentials.vars ] ; then
+ . ~/github-credentials.vars
+fi
+
+if [ "x$github_client_id" = "x" ] || [ "x$github_client_secret" = "x" ] ; then
+ echo "Warning: you don't have github credentials set."
+ echo
+ echo "You may end up exceeding guest quota quickly."
+ echo "You can create an application for yourself,"
+ echo "and get its credentials. Go to"
+ echo
+ echo " https://github.com/settings/developers"
+ echo
+ echo "and click 'Register a new application'."
+ echo
+ echo "From the application's information, copy/paste"
+ echo "its Client ID and Client Secret, into the file"
+ echo
+ echo " ~/github-credentials.vars"
+ echo
+ echo "with the following format:"
+ echo
+ echo "github_client_id=0123456789abcdef0123"
+ echo "github_client_secret=0123456789abcdef0123456789abcdef"
+ echo
+ echo
+ addendum=""
+else
+ addendum="?client_id=$github_client_id&client_secret=$github_client_secret"
+fi
+
+unset notfirst
+echo "["
+git log --pretty=oneline $1..$2 |
+ grep '[^ ]\+ Merge pull request #[0-9]\{4,6\} ' |
+ cut -f 2 -d# |
+ cut -f 1 -d\ |
+ sort -u |
+ while read id ; do
+ if [ "x$notfirst" = "x" ] ; then
+ notfirst=true
+ else
+ echo ","
+ fi
+ echo -n " {\"url\": \"https://github.com/grpc/grpc/pull/$id\","
+ out=`mktemp`
+ curl -s "https://api.github.com/repos/grpc/grpc/pulls/$id$addendum" > $out
+ echo -n " "`grep '"title"' $out`
+ echo -n " "`grep '"login"' $out | head -1`
+ echo -n " \"pr\": $id }"
+ rm $out
+ done
+echo
+echo "]"
diff --git a/tools/distrib/pylint_code.sh b/tools/distrib/pylint_code.sh
index 3c9235b548..7175f1e15b 100755
--- a/tools/distrib/pylint_code.sh
+++ b/tools/distrib/pylint_code.sh
@@ -29,7 +29,7 @@ VIRTUALENV=python_pylint_venv
virtualenv $VIRTUALENV
PYTHON=$(realpath $VIRTUALENV/bin/python)
-$PYTHON -m pip install --upgrade pip
+$PYTHON -m pip install --upgrade pip==9.0.1
$PYTHON -m pip install pylint==1.6.5
for dir in "${DIRS[@]}"; do
diff --git a/tools/distrib/python/check_grpcio_tools.py b/tools/distrib/python/check_grpcio_tools.py
index c5afa713e6..2363017113 100755
--- a/tools/distrib/python/check_grpcio_tools.py
+++ b/tools/distrib/python/check_grpcio_tools.py
@@ -14,17 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import cStringIO
-
-import make_grpcio_tools as make
+import make_grpcio_tools as _make
OUT_OF_DATE_MESSAGE = """file {} is out of date
Have you called tools/distrib/python/make_grpcio_tools.py since upgrading protobuf?"""
-check_protoc_lib_deps_content = make.get_deps()
+submodule_commit_hash = _make.protobuf_submodule_commit_hash()
+
+with open(_make.GRPC_PYTHON_PROTOC_LIB_DEPS, 'r') as _protoc_lib_deps_file:
+ content = _protoc_lib_deps_file.read().splitlines()
+
+testString = (
+ _make.COMMIT_HASH_PREFIX + submodule_commit_hash + _make.COMMIT_HASH_SUFFIX)
-with open(make.GRPC_PYTHON_PROTOC_LIB_DEPS, 'r') as protoc_lib_deps_file:
- if protoc_lib_deps_file.read() != check_protoc_lib_deps_content:
- print(OUT_OF_DATE_MESSAGE.format(make.GRPC_PYTHON_PROTOC_LIB_DEPS))
+if testString not in content:
+ print(OUT_OF_DATE_MESSAGE.format(_make.GRPC_PYTHON_PROTOC_LIB_DEPS))
raise SystemExit(1)
diff --git a/tools/distrib/python/docgen.py b/tools/distrib/python/docgen.py
index 6f6d43c7d9..4d6fcb5d65 100755
--- a/tools/distrib/python/docgen.py
+++ b/tools/distrib/python/docgen.py
@@ -24,14 +24,20 @@ import sys
import tempfile
parser = argparse.ArgumentParser()
-parser.add_argument('--config', metavar='c', type=str, nargs=1,
- help='GRPC/GPR libraries build configuration',
- default='opt')
+parser.add_argument(
+ '--config',
+ metavar='c',
+ type=str,
+ nargs=1,
+ help='GRPC/GPR libraries build configuration',
+ default='opt')
parser.add_argument('--submit', action='store_true')
parser.add_argument('--gh-user', type=str, help='GitHub user to push as.')
-parser.add_argument('--gh-repo-owner', type=str,
- help=('Owner of the GitHub repository to be pushed; '
- 'defaults to --gh-user.'))
+parser.add_argument(
+ '--gh-repo-owner',
+ type=str,
+ help=('Owner of the GitHub repository to be pushed; '
+ 'defaults to --gh-user.'))
parser.add_argument('--doc-branch', type=str)
args = parser.parse_args()
@@ -59,60 +65,75 @@ environment.update({
})
subprocess_arguments_list = [
- {'args': ['virtualenv', VIRTUALENV_DIR], 'env': environment},
- {'args': [VIRTUALENV_PIP_PATH, 'install', '--upgrade', 'pip'],
- 'env': environment},
- {'args': [VIRTUALENV_PIP_PATH, 'install', '-r', REQUIREMENTS_PATH],
- 'env': environment},
- {'args': [VIRTUALENV_PYTHON_PATH, SETUP_PATH, 'build'], 'env': environment},
- {'args': [VIRTUALENV_PYTHON_PATH, SETUP_PATH, 'doc'], 'env': environment},
+ {
+ 'args': ['virtualenv', VIRTUALENV_DIR],
+ 'env': environment
+ },
+ {
+ 'args': [VIRTUALENV_PIP_PATH, 'install', '--upgrade', 'pip==9.0.1'],
+ 'env': environment
+ },
+ {
+ 'args': [VIRTUALENV_PIP_PATH, 'install', '-r', REQUIREMENTS_PATH],
+ 'env': environment
+ },
+ {
+ 'args': [VIRTUALENV_PYTHON_PATH, SETUP_PATH, 'build'],
+ 'env': environment
+ },
+ {
+ 'args': [VIRTUALENV_PYTHON_PATH, SETUP_PATH, 'doc'],
+ 'env': environment
+ },
]
for subprocess_arguments in subprocess_arguments_list:
- print('Running command: {}'.format(subprocess_arguments['args']))
- subprocess.check_call(**subprocess_arguments)
+ print('Running command: {}'.format(subprocess_arguments['args']))
+ subprocess.check_call(**subprocess_arguments)
if args.submit:
- assert args.gh_user
- assert args.doc_branch
- github_user = args.gh_user
- github_repository_owner = (
- args.gh_repo_owner if args.gh_repo_owner else args.gh_user)
- # Create a temporary directory out of tree, checkout gh-pages from the
- # specified repository, edit it, and push it. It's up to the user to then go
- # onto GitHub and make a PR against grpc/grpc:gh-pages.
- repo_parent_dir = tempfile.mkdtemp()
- print('Documentation parent directory: {}'.format(repo_parent_dir))
- repo_dir = os.path.join(repo_parent_dir, 'grpc')
- python_doc_dir = os.path.join(repo_dir, 'python')
- doc_branch = args.doc_branch
+ assert args.gh_user
+ assert args.doc_branch
+ github_user = args.gh_user
+ github_repository_owner = (args.gh_repo_owner
+ if args.gh_repo_owner else args.gh_user)
+ # Create a temporary directory out of tree, checkout gh-pages from the
+ # specified repository, edit it, and push it. It's up to the user to then go
+ # onto GitHub and make a PR against grpc/grpc:gh-pages.
+ repo_parent_dir = tempfile.mkdtemp()
+ print('Documentation parent directory: {}'.format(repo_parent_dir))
+ repo_dir = os.path.join(repo_parent_dir, 'grpc')
+ python_doc_dir = os.path.join(repo_dir, 'python')
+ doc_branch = args.doc_branch
- print('Cloning your repository...')
- subprocess.check_call([
- 'git', 'clone', 'https://{}@github.com/{}/grpc'.format(
- github_user, github_repository_owner)
- ], cwd=repo_parent_dir)
- subprocess.check_call([
- 'git', 'remote', 'add', 'upstream', 'https://github.com/grpc/grpc'
- ], cwd=repo_dir)
- subprocess.check_call(['git', 'fetch', 'upstream'], cwd=repo_dir)
- subprocess.check_call([
- 'git', 'checkout', 'upstream/gh-pages', '-b', doc_branch
- ], cwd=repo_dir)
- print('Updating documentation...')
- shutil.rmtree(python_doc_dir, ignore_errors=True)
- shutil.copytree(DOC_PATH, python_doc_dir)
- print('Attempting to push documentation...')
- try:
- subprocess.check_call(['git', 'add', '--all'], cwd=repo_dir)
- subprocess.check_call([
- 'git', 'commit', '-m', 'Auto-update Python documentation'
- ], cwd=repo_dir)
- subprocess.check_call([
- 'git', 'push', '--set-upstream', 'origin', doc_branch
- ], cwd=repo_dir)
- except subprocess.CalledProcessError:
- print('Failed to push documentation. Examine this directory and push '
- 'manually: {}'.format(repo_parent_dir))
- sys.exit(1)
- shutil.rmtree(repo_parent_dir)
+ print('Cloning your repository...')
+ subprocess.check_call(
+ [
+ 'git', 'clone', 'https://{}@github.com/{}/grpc'.format(
+ github_user, github_repository_owner)
+ ],
+ cwd=repo_parent_dir)
+ subprocess.check_call(
+ ['git', 'remote', 'add', 'upstream', 'https://github.com/grpc/grpc'],
+ cwd=repo_dir)
+ subprocess.check_call(['git', 'fetch', 'upstream'], cwd=repo_dir)
+ subprocess.check_call(
+ ['git', 'checkout', 'upstream/gh-pages', '-b', doc_branch],
+ cwd=repo_dir)
+ print('Updating documentation...')
+ shutil.rmtree(python_doc_dir, ignore_errors=True)
+ shutil.copytree(DOC_PATH, python_doc_dir)
+ print('Attempting to push documentation...')
+ try:
+ subprocess.check_call(['git', 'add', '--all'], cwd=repo_dir)
+ subprocess.check_call(
+ ['git', 'commit', '-m', 'Auto-update Python documentation'],
+ cwd=repo_dir)
+ subprocess.check_call(
+ ['git', 'push', '--set-upstream', 'origin', doc_branch],
+ cwd=repo_dir)
+ except subprocess.CalledProcessError:
+ print('Failed to push documentation. Examine this directory and push '
+ 'manually: {}'.format(repo_parent_dir))
+ sys.exit(1)
+ shutil.rmtree(repo_parent_dir)
diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst
index fb44cfaf80..32873b291f 100644
--- a/tools/distrib/python/grpcio_tools/README.rst
+++ b/tools/distrib/python/grpcio_tools/README.rst
@@ -61,7 +61,7 @@ GCC-like stuff, but you may end up having a bad time.
$ python ../make_grpcio_tools.py
# For the next command do `sudo pip install` if you get permission-denied errors
- $ pip install .
+ $ GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
You cannot currently install Python from source on Windows. Things might work
out for you in MSYS2 (follow the Linux instructions), but it isn't officially
diff --git a/tools/distrib/python/grpcio_tools/grpc_tools/__init__.py b/tools/distrib/python/grpcio_tools/grpc_tools/__init__.py
index 1454b678e1..5772620b60 100644
--- a/tools/distrib/python/grpcio_tools/grpc_tools/__init__.py
+++ b/tools/distrib/python/grpcio_tools/grpc_tools/__init__.py
@@ -11,4 +11,3 @@
# 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.
-
diff --git a/tools/distrib/python/grpcio_tools/grpc_tools/command.py b/tools/distrib/python/grpcio_tools/grpc_tools/command.py
index 28be137045..7ede05f140 100644
--- a/tools/distrib/python/grpcio_tools/grpc_tools/command.py
+++ b/tools/distrib/python/grpcio_tools/grpc_tools/command.py
@@ -22,43 +22,44 @@ from grpc_tools import protoc
def build_package_protos(package_root):
- proto_files = []
- inclusion_root = os.path.abspath(package_root)
- for root, _, files in os.walk(inclusion_root):
- for filename in files:
- if filename.endswith('.proto'):
- proto_files.append(os.path.abspath(os.path.join(root, filename)))
+ proto_files = []
+ inclusion_root = os.path.abspath(package_root)
+ for root, _, files in os.walk(inclusion_root):
+ for filename in files:
+ if filename.endswith('.proto'):
+ proto_files.append(
+ os.path.abspath(os.path.join(root, filename)))
- well_known_protos_include = pkg_resources.resource_filename(
- 'grpc_tools', '_proto')
+ well_known_protos_include = pkg_resources.resource_filename(
+ 'grpc_tools', '_proto')
- for proto_file in proto_files:
- command = [
- 'grpc_tools.protoc',
- '--proto_path={}'.format(inclusion_root),
- '--proto_path={}'.format(well_known_protos_include),
- '--python_out={}'.format(inclusion_root),
- '--grpc_python_out={}'.format(inclusion_root),
- ] + [proto_file]
- if protoc.main(command) != 0:
- sys.stderr.write('warning: {} failed'.format(command))
+ for proto_file in proto_files:
+ command = [
+ 'grpc_tools.protoc',
+ '--proto_path={}'.format(inclusion_root),
+ '--proto_path={}'.format(well_known_protos_include),
+ '--python_out={}'.format(inclusion_root),
+ '--grpc_python_out={}'.format(inclusion_root),
+ ] + [proto_file]
+ if protoc.main(command) != 0:
+ sys.stderr.write('warning: {} failed'.format(command))
class BuildPackageProtos(setuptools.Command):
- """Command to generate project *_pb2.py modules from proto files."""
+ """Command to generate project *_pb2.py modules from proto files."""
- description = 'build grpc protobuf modules'
- user_options = []
+ description = 'build grpc protobuf modules'
+ user_options = []
- def initialize_options(self):
- pass
+ def initialize_options(self):
+ pass
- def finalize_options(self):
- pass
+ def finalize_options(self):
+ pass
- def run(self):
- # due to limitations of the proto generator, we require that only *one*
- # directory is provided as an 'include' directory. We assume it's the '' key
- # to `self.distribution.package_dir` (and get a key error if it's not
- # there).
- build_package_protos(self.distribution.package_dir[''])
+ def run(self):
+ # due to limitations of the proto generator, we require that only *one*
+ # directory is provided as an 'include' directory. We assume it's the '' key
+ # to `self.distribution.package_dir` (and get a key error if it's not
+ # there).
+ build_package_protos(self.distribution.package_dir[''])
diff --git a/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py b/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py
index efad51e07b..582cba0e39 100644
--- a/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py
+++ b/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py
@@ -19,16 +19,18 @@ import sys
from grpc_tools import _protoc_compiler
+
def main(command_arguments):
- """Run the protocol buffer compiler with the given command-line arguments.
+ """Run the protocol buffer compiler with the given command-line arguments.
Args:
command_arguments: a list of strings representing command line arguments to
`protoc`.
"""
- command_arguments = [argument.encode() for argument in command_arguments]
- return _protoc_compiler.run_main(command_arguments)
+ command_arguments = [argument.encode() for argument in command_arguments]
+ return _protoc_compiler.run_main(command_arguments)
+
if __name__ == '__main__':
- proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')
- sys.exit(main(sys.argv + ['-I{}'.format(proto_include)]))
+ proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')
+ sys.exit(main(sys.argv + ['-I{}'.format(proto_include)]))
diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py
index a4178a58c1..5caa1d1078 100644
--- a/tools/distrib/python/grpcio_tools/grpc_version.py
+++ b/tools/distrib/python/grpcio_tools/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!!
-VERSION='1.7.0.dev0'
+VERSION = '1.10.0.dev0'
diff --git a/tools/distrib/python/grpcio_tools/protoc_lib_deps.py b/tools/distrib/python/grpcio_tools/protoc_lib_deps.py
index 18470d59d5..2c65fca628 100644
--- a/tools/distrib/python/grpcio_tools/protoc_lib_deps.py
+++ b/tools/distrib/python/grpcio_tools/protoc_lib_deps.py
@@ -1,5 +1,5 @@
-# Copyright 2016 gRPC authors.
+# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,8 +14,10 @@
# limitations under the License.
# AUTO-GENERATED BY make_grpcio_tools.py!
-CC_FILES=['google/protobuf/compiler/zip_writer.cc', 'google/protobuf/compiler/subprocess.cc', 'google/protobuf/compiler/ruby/ruby_generator.cc', 'google/protobuf/compiler/python/python_generator.cc', 'google/protobuf/compiler/plugin.pb.cc', 'google/protobuf/compiler/plugin.cc', 'google/protobuf/compiler/php/php_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_primitive_field.cc', 'google/protobuf/compiler/objectivec/objectivec_oneof.cc', 'google/protobuf/compiler/objectivec/objectivec_message_field.cc', 'google/protobuf/compiler/objectivec/objectivec_message.cc', 'google/protobuf/compiler/objectivec/objectivec_map_field.cc', 'google/protobuf/compiler/objectivec/objectivec_helpers.cc', 'google/protobuf/compiler/objectivec/objectivec_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_file.cc', 'google/protobuf/compiler/objectivec/objectivec_field.cc', 'google/protobuf/compiler/objectivec/objectivec_extension.cc', 'google/protobuf/compiler/objectivec/objectivec_enum_field.cc', 'google/protobuf/compiler/objectivec/objectivec_enum.cc', 'google/protobuf/compiler/js/well_known_types_embed.cc', 'google/protobuf/compiler/js/js_generator.cc', 'google/protobuf/compiler/javanano/javanano_primitive_field.cc', 'google/protobuf/compiler/javanano/javanano_message_field.cc', 'google/protobuf/compiler/javanano/javanano_message.cc', 'google/protobuf/compiler/javanano/javanano_map_field.cc', 'google/protobuf/compiler/javanano/javanano_helpers.cc', 'google/protobuf/compiler/javanano/javanano_generator.cc', 'google/protobuf/compiler/javanano/javanano_file.cc', 'google/protobuf/compiler/javanano/javanano_field.cc', 'google/protobuf/compiler/javanano/javanano_extension.cc', 'google/protobuf/compiler/javanano/javanano_enum_field.cc', 'google/protobuf/compiler/javanano/javanano_enum.cc', 'google/protobuf/compiler/java/java_string_field_lite.cc', 'google/protobuf/compiler/java/java_string_field.cc', 'google/protobuf/compiler/java/java_shared_code_generator.cc', 'google/protobuf/compiler/java/java_service.cc', 'google/protobuf/compiler/java/java_primitive_field_lite.cc', 'google/protobuf/compiler/java/java_primitive_field.cc', 'google/protobuf/compiler/java/java_name_resolver.cc', 'google/protobuf/compiler/java/java_message_lite.cc', 'google/protobuf/compiler/java/java_message_field_lite.cc', 'google/protobuf/compiler/java/java_message_field.cc', 'google/protobuf/compiler/java/java_message_builder_lite.cc', 'google/protobuf/compiler/java/java_message_builder.cc', 'google/protobuf/compiler/java/java_message.cc', 'google/protobuf/compiler/java/java_map_field_lite.cc', 'google/protobuf/compiler/java/java_map_field.cc', 'google/protobuf/compiler/java/java_lazy_message_field_lite.cc', 'google/protobuf/compiler/java/java_lazy_message_field.cc', 'google/protobuf/compiler/java/java_helpers.cc', 'google/protobuf/compiler/java/java_generator_factory.cc', 'google/protobuf/compiler/java/java_generator.cc', 'google/protobuf/compiler/java/java_file.cc', 'google/protobuf/compiler/java/java_field.cc', 'google/protobuf/compiler/java/java_extension_lite.cc', 'google/protobuf/compiler/java/java_extension.cc', 'google/protobuf/compiler/java/java_enum_lite.cc', 'google/protobuf/compiler/java/java_enum_field_lite.cc', 'google/protobuf/compiler/java/java_enum_field.cc', 'google/protobuf/compiler/java/java_enum.cc', 'google/protobuf/compiler/java/java_doc_comment.cc', 'google/protobuf/compiler/java/java_context.cc', 'google/protobuf/compiler/csharp/csharp_wrapper_field.cc', 'google/protobuf/compiler/csharp/csharp_source_generator_base.cc', 'google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_message_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_reflection_class.cc', 'google/protobuf/compiler/csharp/csharp_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_message_field.cc', 'google/protobuf/compiler/csharp/csharp_message.cc', 'google/protobuf/compiler/csharp/csharp_map_field.cc', 'google/protobuf/compiler/csharp/csharp_helpers.cc', 'google/protobuf/compiler/csharp/csharp_generator.cc', 'google/protobuf/compiler/csharp/csharp_field_base.cc', 'google/protobuf/compiler/csharp/csharp_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_enum.cc', 'google/protobuf/compiler/csharp/csharp_doc_comment.cc', 'google/protobuf/compiler/cpp/cpp_string_field.cc', 'google/protobuf/compiler/cpp/cpp_service.cc', 'google/protobuf/compiler/cpp/cpp_primitive_field.cc', 'google/protobuf/compiler/cpp/cpp_message_field.cc', 'google/protobuf/compiler/cpp/cpp_message.cc', 'google/protobuf/compiler/cpp/cpp_map_field.cc', 'google/protobuf/compiler/cpp/cpp_helpers.cc', 'google/protobuf/compiler/cpp/cpp_generator.cc', 'google/protobuf/compiler/cpp/cpp_file.cc', 'google/protobuf/compiler/cpp/cpp_field.cc', 'google/protobuf/compiler/cpp/cpp_extension.cc', 'google/protobuf/compiler/cpp/cpp_enum_field.cc', 'google/protobuf/compiler/cpp/cpp_enum.cc', 'google/protobuf/compiler/command_line_interface.cc', 'google/protobuf/compiler/code_generator.cc', 'google/protobuf/wrappers.pb.cc', 'google/protobuf/wire_format.cc', 'google/protobuf/util/type_resolver_util.cc', 'google/protobuf/util/time_util.cc', 'google/protobuf/util/message_differencer.cc', 'google/protobuf/util/json_util.cc', 'google/protobuf/util/internal/utility.cc', 'google/protobuf/util/internal/type_info_test_helper.cc', 'google/protobuf/util/internal/type_info.cc', 'google/protobuf/util/internal/protostream_objectwriter.cc', 'google/protobuf/util/internal/protostream_objectsource.cc', 'google/protobuf/util/internal/proto_writer.cc', 'google/protobuf/util/internal/object_writer.cc', 'google/protobuf/util/internal/json_stream_parser.cc', 'google/protobuf/util/internal/json_objectwriter.cc', 'google/protobuf/util/internal/json_escaping.cc', 'google/protobuf/util/internal/field_mask_utility.cc', 'google/protobuf/util/internal/error_listener.cc', 'google/protobuf/util/internal/default_value_objectwriter.cc', 'google/protobuf/util/internal/datapiece.cc', 'google/protobuf/util/field_mask_util.cc', 'google/protobuf/util/field_comparator.cc', 'google/protobuf/util/delimited_message_util.cc', 'google/protobuf/unknown_field_set.cc', 'google/protobuf/type.pb.cc', 'google/protobuf/timestamp.pb.cc', 'google/protobuf/text_format.cc', 'google/protobuf/stubs/substitute.cc', 'google/protobuf/stubs/mathlimits.cc', 'google/protobuf/struct.pb.cc', 'google/protobuf/source_context.pb.cc', 'google/protobuf/service.cc', 'google/protobuf/reflection_ops.cc', 'google/protobuf/message.cc', 'google/protobuf/map_field.cc', 'google/protobuf/io/zero_copy_stream_impl.cc', 'google/protobuf/io/tokenizer.cc', 'google/protobuf/io/strtod.cc', 'google/protobuf/io/printer.cc', 'google/protobuf/io/gzip_stream.cc', 'google/protobuf/generated_message_table_driven.cc', 'google/protobuf/generated_message_reflection.cc', 'google/protobuf/field_mask.pb.cc', 'google/protobuf/extension_set_heavy.cc', 'google/protobuf/empty.pb.cc', 'google/protobuf/dynamic_message.cc', 'google/protobuf/duration.pb.cc', 'google/protobuf/descriptor_database.cc', 'google/protobuf/descriptor.pb.cc', 'google/protobuf/descriptor.cc', 'google/protobuf/compiler/parser.cc', 'google/protobuf/compiler/importer.cc', 'google/protobuf/api.pb.cc', 'google/protobuf/any.pb.cc', 'google/protobuf/any.cc', 'google/protobuf/wire_format_lite.cc', 'google/protobuf/stubs/time.cc', 'google/protobuf/stubs/strutil.cc', 'google/protobuf/stubs/structurally_valid.cc', 'google/protobuf/stubs/stringprintf.cc', 'google/protobuf/stubs/stringpiece.cc', 'google/protobuf/stubs/statusor.cc', 'google/protobuf/stubs/status.cc', 'google/protobuf/stubs/once.cc', 'google/protobuf/stubs/io_win32.cc', 'google/protobuf/stubs/int128.cc', 'google/protobuf/stubs/common.cc', 'google/protobuf/stubs/bytestream.cc', 'google/protobuf/stubs/atomicops_internals_x86_msvc.cc', 'google/protobuf/stubs/atomicops_internals_x86_gcc.cc', 'google/protobuf/repeated_field.cc', 'google/protobuf/message_lite.cc', 'google/protobuf/io/zero_copy_stream_impl_lite.cc', 'google/protobuf/io/zero_copy_stream.cc', 'google/protobuf/io/coded_stream.cc', 'google/protobuf/generated_message_util.cc', 'google/protobuf/generated_message_table_driven_lite.cc', 'google/protobuf/extension_set.cc', 'google/protobuf/arenastring.cc', 'google/protobuf/arena.cc', 'google/protobuf/compiler/js/embed.cc']
+CC_FILES=['google/protobuf/compiler/zip_writer.cc', 'google/protobuf/compiler/subprocess.cc', 'google/protobuf/compiler/ruby/ruby_generator.cc', 'google/protobuf/compiler/python/python_generator.cc', 'google/protobuf/compiler/plugin.pb.cc', 'google/protobuf/compiler/plugin.cc', 'google/protobuf/compiler/php/php_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_primitive_field.cc', 'google/protobuf/compiler/objectivec/objectivec_oneof.cc', 'google/protobuf/compiler/objectivec/objectivec_message_field.cc', 'google/protobuf/compiler/objectivec/objectivec_message.cc', 'google/protobuf/compiler/objectivec/objectivec_map_field.cc', 'google/protobuf/compiler/objectivec/objectivec_helpers.cc', 'google/protobuf/compiler/objectivec/objectivec_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_file.cc', 'google/protobuf/compiler/objectivec/objectivec_field.cc', 'google/protobuf/compiler/objectivec/objectivec_extension.cc', 'google/protobuf/compiler/objectivec/objectivec_enum_field.cc', 'google/protobuf/compiler/objectivec/objectivec_enum.cc', 'google/protobuf/compiler/js/well_known_types_embed.cc', 'google/protobuf/compiler/js/js_generator.cc', 'google/protobuf/compiler/javanano/javanano_primitive_field.cc', 'google/protobuf/compiler/javanano/javanano_message_field.cc', 'google/protobuf/compiler/javanano/javanano_message.cc', 'google/protobuf/compiler/javanano/javanano_map_field.cc', 'google/protobuf/compiler/javanano/javanano_helpers.cc', 'google/protobuf/compiler/javanano/javanano_generator.cc', 'google/protobuf/compiler/javanano/javanano_file.cc', 'google/protobuf/compiler/javanano/javanano_field.cc', 'google/protobuf/compiler/javanano/javanano_extension.cc', 'google/protobuf/compiler/javanano/javanano_enum_field.cc', 'google/protobuf/compiler/javanano/javanano_enum.cc', 'google/protobuf/compiler/java/java_string_field_lite.cc', 'google/protobuf/compiler/java/java_string_field.cc', 'google/protobuf/compiler/java/java_shared_code_generator.cc', 'google/protobuf/compiler/java/java_service.cc', 'google/protobuf/compiler/java/java_primitive_field_lite.cc', 'google/protobuf/compiler/java/java_primitive_field.cc', 'google/protobuf/compiler/java/java_name_resolver.cc', 'google/protobuf/compiler/java/java_message_lite.cc', 'google/protobuf/compiler/java/java_message_field_lite.cc', 'google/protobuf/compiler/java/java_message_field.cc', 'google/protobuf/compiler/java/java_message_builder_lite.cc', 'google/protobuf/compiler/java/java_message_builder.cc', 'google/protobuf/compiler/java/java_message.cc', 'google/protobuf/compiler/java/java_map_field_lite.cc', 'google/protobuf/compiler/java/java_map_field.cc', 'google/protobuf/compiler/java/java_lazy_message_field_lite.cc', 'google/protobuf/compiler/java/java_lazy_message_field.cc', 'google/protobuf/compiler/java/java_helpers.cc', 'google/protobuf/compiler/java/java_generator_factory.cc', 'google/protobuf/compiler/java/java_generator.cc', 'google/protobuf/compiler/java/java_file.cc', 'google/protobuf/compiler/java/java_field.cc', 'google/protobuf/compiler/java/java_extension_lite.cc', 'google/protobuf/compiler/java/java_extension.cc', 'google/protobuf/compiler/java/java_enum_lite.cc', 'google/protobuf/compiler/java/java_enum_field_lite.cc', 'google/protobuf/compiler/java/java_enum_field.cc', 'google/protobuf/compiler/java/java_enum.cc', 'google/protobuf/compiler/java/java_doc_comment.cc', 'google/protobuf/compiler/java/java_context.cc', 'google/protobuf/compiler/csharp/csharp_wrapper_field.cc', 'google/protobuf/compiler/csharp/csharp_source_generator_base.cc', 'google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_message_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_reflection_class.cc', 'google/protobuf/compiler/csharp/csharp_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_message_field.cc', 'google/protobuf/compiler/csharp/csharp_message.cc', 'google/protobuf/compiler/csharp/csharp_map_field.cc', 'google/protobuf/compiler/csharp/csharp_helpers.cc', 'google/protobuf/compiler/csharp/csharp_generator.cc', 'google/protobuf/compiler/csharp/csharp_field_base.cc', 'google/protobuf/compiler/csharp/csharp_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_enum.cc', 'google/protobuf/compiler/csharp/csharp_doc_comment.cc', 'google/protobuf/compiler/cpp/cpp_string_field.cc', 'google/protobuf/compiler/cpp/cpp_service.cc', 'google/protobuf/compiler/cpp/cpp_primitive_field.cc', 'google/protobuf/compiler/cpp/cpp_padding_optimizer.cc', 'google/protobuf/compiler/cpp/cpp_message_field.cc', 'google/protobuf/compiler/cpp/cpp_message.cc', 'google/protobuf/compiler/cpp/cpp_map_field.cc', 'google/protobuf/compiler/cpp/cpp_helpers.cc', 'google/protobuf/compiler/cpp/cpp_generator.cc', 'google/protobuf/compiler/cpp/cpp_file.cc', 'google/protobuf/compiler/cpp/cpp_field.cc', 'google/protobuf/compiler/cpp/cpp_extension.cc', 'google/protobuf/compiler/cpp/cpp_enum_field.cc', 'google/protobuf/compiler/cpp/cpp_enum.cc', 'google/protobuf/compiler/command_line_interface.cc', 'google/protobuf/compiler/code_generator.cc', 'google/protobuf/wrappers.pb.cc', 'google/protobuf/wire_format.cc', 'google/protobuf/util/type_resolver_util.cc', 'google/protobuf/util/time_util.cc', 'google/protobuf/util/message_differencer.cc', 'google/protobuf/util/json_util.cc', 'google/protobuf/util/internal/utility.cc', 'google/protobuf/util/internal/type_info_test_helper.cc', 'google/protobuf/util/internal/type_info.cc', 'google/protobuf/util/internal/protostream_objectwriter.cc', 'google/protobuf/util/internal/protostream_objectsource.cc', 'google/protobuf/util/internal/proto_writer.cc', 'google/protobuf/util/internal/object_writer.cc', 'google/protobuf/util/internal/json_stream_parser.cc', 'google/protobuf/util/internal/json_objectwriter.cc', 'google/protobuf/util/internal/json_escaping.cc', 'google/protobuf/util/internal/field_mask_utility.cc', 'google/protobuf/util/internal/error_listener.cc', 'google/protobuf/util/internal/default_value_objectwriter.cc', 'google/protobuf/util/internal/datapiece.cc', 'google/protobuf/util/field_mask_util.cc', 'google/protobuf/util/field_comparator.cc', 'google/protobuf/util/delimited_message_util.cc', 'google/protobuf/unknown_field_set.cc', 'google/protobuf/type.pb.cc', 'google/protobuf/timestamp.pb.cc', 'google/protobuf/text_format.cc', 'google/protobuf/stubs/substitute.cc', 'google/protobuf/stubs/mathlimits.cc', 'google/protobuf/struct.pb.cc', 'google/protobuf/source_context.pb.cc', 'google/protobuf/service.cc', 'google/protobuf/reflection_ops.cc', 'google/protobuf/message.cc', 'google/protobuf/map_field.cc', 'google/protobuf/io/zero_copy_stream_impl.cc', 'google/protobuf/io/tokenizer.cc', 'google/protobuf/io/strtod.cc', 'google/protobuf/io/printer.cc', 'google/protobuf/io/gzip_stream.cc', 'google/protobuf/generated_message_table_driven.cc', 'google/protobuf/generated_message_reflection.cc', 'google/protobuf/field_mask.pb.cc', 'google/protobuf/extension_set_heavy.cc', 'google/protobuf/empty.pb.cc', 'google/protobuf/dynamic_message.cc', 'google/protobuf/duration.pb.cc', 'google/protobuf/descriptor_database.cc', 'google/protobuf/descriptor.pb.cc', 'google/protobuf/descriptor.cc', 'google/protobuf/compiler/parser.cc', 'google/protobuf/compiler/importer.cc', 'google/protobuf/api.pb.cc', 'google/protobuf/any.pb.cc', 'google/protobuf/any.cc', 'google/protobuf/wire_format_lite.cc', 'google/protobuf/stubs/time.cc', 'google/protobuf/stubs/strutil.cc', 'google/protobuf/stubs/structurally_valid.cc', 'google/protobuf/stubs/stringprintf.cc', 'google/protobuf/stubs/stringpiece.cc', 'google/protobuf/stubs/statusor.cc', 'google/protobuf/stubs/status.cc', 'google/protobuf/stubs/once.cc', 'google/protobuf/stubs/io_win32.cc', 'google/protobuf/stubs/int128.cc', 'google/protobuf/stubs/common.cc', 'google/protobuf/stubs/bytestream.cc', 'google/protobuf/stubs/atomicops_internals_x86_msvc.cc', 'google/protobuf/stubs/atomicops_internals_x86_gcc.cc', 'google/protobuf/repeated_field.cc', 'google/protobuf/message_lite.cc', 'google/protobuf/io/zero_copy_stream_impl_lite.cc', 'google/protobuf/io/zero_copy_stream.cc', 'google/protobuf/io/coded_stream.cc', 'google/protobuf/generated_message_util.cc', 'google/protobuf/generated_message_table_driven_lite.cc', 'google/protobuf/extension_set.cc', 'google/protobuf/arenastring.cc', 'google/protobuf/arena.cc', 'google/protobuf/compiler/js/embed.cc']
PROTO_FILES=['google/protobuf/wrappers.proto', 'google/protobuf/type.proto', 'google/protobuf/timestamp.proto', 'google/protobuf/struct.proto', 'google/protobuf/source_context.proto', 'google/protobuf/field_mask.proto', 'google/protobuf/empty.proto', 'google/protobuf/duration.proto', 'google/protobuf/descriptor.proto', 'google/protobuf/compiler/plugin.proto', 'google/protobuf/api.proto', 'google/protobuf/any.proto']
CC_INCLUDE='third_party/protobuf/src'
PROTO_INCLUDE='third_party/protobuf/src'
+
+PROTOBUF_SUBMODULE_VERSION="2761122b810fe8861004ae785cc3ab39f384d342"
diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py
index e0e9226211..c6bcee497f 100644
--- a/tools/distrib/python/grpcio_tools/setup.py
+++ b/tools/distrib/python/grpcio_tools/setup.py
@@ -66,42 +66,42 @@ BUILD_WITH_CYTHON = os.environ.get('GRPC_PYTHON_BUILD_WITH_CYTHON', False)
EXTRA_ENV_COMPILE_ARGS = os.environ.get('GRPC_PYTHON_CFLAGS', None)
EXTRA_ENV_LINK_ARGS = os.environ.get('GRPC_PYTHON_LDFLAGS', None)
if EXTRA_ENV_COMPILE_ARGS is None:
- EXTRA_ENV_COMPILE_ARGS = '-std=c++11'
- if 'win32' in sys.platform:
- if sys.version_info < (3, 5):
- # We use define flags here and don't directly add to DEFINE_MACROS below to
- # ensure that the expert user/builder has a way of turning it off (via the
- # envvars) without adding yet more GRPC-specific envvars.
- # See https://sourceforge.net/p/mingw-w64/bugs/363/
- if '32' in platform.architecture()[0]:
- EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime32 -D_timeb=__timeb32 -D_ftime_s=_ftime32_s -D_hypot=hypot'
- else:
- EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime64 -D_timeb=__timeb64 -D_hypot=hypot'
- else:
- # We need to statically link the C++ Runtime, only the C runtime is
- # available dynamically
- EXTRA_ENV_COMPILE_ARGS += ' /MT'
- elif "linux" in sys.platform or "darwin" in sys.platform:
- EXTRA_ENV_COMPILE_ARGS += ' -fno-wrapv -frtti'
+ EXTRA_ENV_COMPILE_ARGS = '-std=c++11'
+ if 'win32' in sys.platform:
+ if sys.version_info < (3, 5):
+ # We use define flags here and don't directly add to DEFINE_MACROS below to
+ # ensure that the expert user/builder has a way of turning it off (via the
+ # envvars) without adding yet more GRPC-specific envvars.
+ # See https://sourceforge.net/p/mingw-w64/bugs/363/
+ if '32' in platform.architecture()[0]:
+ EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime32 -D_timeb=__timeb32 -D_ftime_s=_ftime32_s -D_hypot=hypot'
+ else:
+ EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime64 -D_timeb=__timeb64 -D_hypot=hypot'
+ else:
+ # We need to statically link the C++ Runtime, only the C runtime is
+ # available dynamically
+ EXTRA_ENV_COMPILE_ARGS += ' /MT'
+ elif "linux" in sys.platform or "darwin" in sys.platform:
+ EXTRA_ENV_COMPILE_ARGS += ' -fno-wrapv -frtti'
if EXTRA_ENV_LINK_ARGS is None:
- EXTRA_ENV_LINK_ARGS = ''
- if "linux" in sys.platform or "darwin" in sys.platform:
- EXTRA_ENV_LINK_ARGS += ' -lpthread'
- elif "win32" in sys.platform and sys.version_info < (3, 5):
- msvcr = cygwinccompiler.get_msvcr()[0]
- # TODO(atash) sift through the GCC specs to see if libstdc++ can have any
- # influence on the linkage outcome on MinGW for non-C++ programs.
- EXTRA_ENV_LINK_ARGS += (
- ' -static-libgcc -static-libstdc++ -mcrtdll={msvcr} '
- '-static'.format(msvcr=msvcr))
+ EXTRA_ENV_LINK_ARGS = ''
+ if "linux" in sys.platform or "darwin" in sys.platform:
+ EXTRA_ENV_LINK_ARGS += ' -lpthread'
+ elif "win32" in sys.platform and sys.version_info < (3, 5):
+ msvcr = cygwinccompiler.get_msvcr()[0]
+ # TODO(atash) sift through the GCC specs to see if libstdc++ can have any
+ # influence on the linkage outcome on MinGW for non-C++ programs.
+ EXTRA_ENV_LINK_ARGS += (
+ ' -static-libgcc -static-libstdc++ -mcrtdll={msvcr} '
+ '-static'.format(msvcr=msvcr))
EXTRA_COMPILE_ARGS = shlex.split(EXTRA_ENV_COMPILE_ARGS)
EXTRA_LINK_ARGS = shlex.split(EXTRA_ENV_LINK_ARGS)
-CC_FILES = [
- os.path.normpath(cc_file) for cc_file in protoc_lib_deps.CC_FILES]
+CC_FILES = [os.path.normpath(cc_file) for cc_file in protoc_lib_deps.CC_FILES]
PROTO_FILES = [
- os.path.normpath(proto_file) for proto_file in protoc_lib_deps.PROTO_FILES]
+ os.path.normpath(proto_file) for proto_file in protoc_lib_deps.PROTO_FILES
+]
CC_INCLUDE = os.path.normpath(protoc_lib_deps.CC_INCLUDE)
PROTO_INCLUDE = os.path.normpath(protoc_lib_deps.PROTO_INCLUDE)
@@ -110,107 +110,116 @@ GRPC_PYTHON_PROTO_RESOURCES_NAME = '_proto'
DEFINE_MACROS = ()
if "win32" in sys.platform:
- DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1),)
- if '64bit' in platform.architecture()[0]:
- DEFINE_MACROS += (('MS_WIN64', 1),)
+ DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1),)
+ if '64bit' in platform.architecture()[0]:
+ DEFINE_MACROS += (('MS_WIN64', 1),)
elif "linux" in sys.platform or "darwin" in sys.platform:
- DEFINE_MACROS += (('HAVE_PTHREAD', 1),)
+ DEFINE_MACROS += (('HAVE_PTHREAD', 1),)
# By default, Python3 distutils enforces compatibility of
# c plugins (.so files) with the OSX version Python3 was built with.
# For Python3.4, this is OSX 10.6, but we need Thread Local Support (__thread)
if 'darwin' in sys.platform and PY3:
- mac_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
- if mac_target and (pkg_resources.parse_version(mac_target) <
- pkg_resources.parse_version('10.9.0')):
- os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
- os.environ['_PYTHON_HOST_PLATFORM'] = re.sub(
- r'macosx-[0-9]+\.[0-9]+-(.+)',
- r'macosx-10.9-\1',
- util.get_platform())
+ mac_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
+ if mac_target and (pkg_resources.parse_version(mac_target) <
+ pkg_resources.parse_version('10.9.0')):
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
+ os.environ['_PYTHON_HOST_PLATFORM'] = re.sub(
+ r'macosx-[0-9]+\.[0-9]+-(.+)', r'macosx-10.9-\1',
+ util.get_platform())
+
def package_data():
- tools_path = GRPC_PYTHON_TOOLS_PACKAGE.replace('.', os.path.sep)
- proto_resources_path = os.path.join(tools_path,
- GRPC_PYTHON_PROTO_RESOURCES_NAME)
- proto_files = []
- for proto_file in PROTO_FILES:
- source = os.path.join(PROTO_INCLUDE, proto_file)
- target = os.path.join(proto_resources_path, proto_file)
- relative_target = os.path.join(GRPC_PYTHON_PROTO_RESOURCES_NAME, proto_file)
- try:
- os.makedirs(os.path.dirname(target))
- except OSError as error:
- if error.errno == errno.EEXIST:
- pass
- else:
- raise
- shutil.copy(source, target)
- proto_files.append(relative_target)
- return {GRPC_PYTHON_TOOLS_PACKAGE: proto_files}
+ tools_path = GRPC_PYTHON_TOOLS_PACKAGE.replace('.', os.path.sep)
+ proto_resources_path = os.path.join(tools_path,
+ GRPC_PYTHON_PROTO_RESOURCES_NAME)
+ proto_files = []
+ for proto_file in PROTO_FILES:
+ source = os.path.join(PROTO_INCLUDE, proto_file)
+ target = os.path.join(proto_resources_path, proto_file)
+ relative_target = os.path.join(GRPC_PYTHON_PROTO_RESOURCES_NAME,
+ proto_file)
+ try:
+ os.makedirs(os.path.dirname(target))
+ except OSError as error:
+ if error.errno == errno.EEXIST:
+ pass
+ else:
+ raise
+ shutil.copy(source, target)
+ proto_files.append(relative_target)
+ return {GRPC_PYTHON_TOOLS_PACKAGE: proto_files}
+
def extension_modules():
- if BUILD_WITH_CYTHON:
- plugin_sources = [os.path.join('grpc_tools', '_protoc_compiler.pyx')]
- else:
- plugin_sources = [os.path.join('grpc_tools', '_protoc_compiler.cpp')]
-
- plugin_sources += [
- os.path.join('grpc_tools', 'main.cc'),
- os.path.join('grpc_root', 'src', 'compiler', 'python_generator.cc')]
-
- #HACK: Substitute the embed.cc, which is a JS to C++
- # preprocessor with the generated code.
- # The generated code should not be material
- # to the parts of protoc we use (it affects
- # the JavaScript code generator, supposedly),
- # but we need to be cautious about it.
- cc_files_clone = list(CC_FILES)
- embed_cc_file = os.path.normpath('google/protobuf/compiler/js/embed.cc')
- well_known_types_file = os.path.normpath(
- 'google/protobuf/compiler/js/well_known_types_embed.cc')
- if embed_cc_file in cc_files_clone:
- cc_files_clone.remove(embed_cc_file)
- if well_known_types_file in cc_files_clone:
- cc_files_clone.remove(well_known_types_file)
- plugin_sources += [os.path.join('grpc_tools', 'protobuf_generated_well_known_types_embed.cc')]
- plugin_sources += [os.path.join(CC_INCLUDE, cc_file) for cc_file in cc_files_clone]
-
- plugin_ext = extension.Extension(
- name='grpc_tools._protoc_compiler',
- sources=plugin_sources,
- include_dirs=[
- '.',
- 'grpc_root',
- os.path.join('grpc_root', 'include'),
- CC_INCLUDE,
- ],
- language='c++',
- define_macros=list(DEFINE_MACROS),
- extra_compile_args=list(EXTRA_COMPILE_ARGS),
- extra_link_args=list(EXTRA_LINK_ARGS),
- )
- extensions = [plugin_ext]
- if BUILD_WITH_CYTHON:
- from Cython import Build
- return Build.cythonize(extensions)
- else:
- return extensions
+ if BUILD_WITH_CYTHON:
+ plugin_sources = [os.path.join('grpc_tools', '_protoc_compiler.pyx')]
+ else:
+ plugin_sources = [os.path.join('grpc_tools', '_protoc_compiler.cpp')]
+
+ plugin_sources += [
+ os.path.join('grpc_tools', 'main.cc'),
+ os.path.join('grpc_root', 'src', 'compiler', 'python_generator.cc')
+ ]
+
+ #HACK: Substitute the embed.cc, which is a JS to C++
+ # preprocessor with the generated code.
+ # The generated code should not be material
+ # to the parts of protoc we use (it affects
+ # the JavaScript code generator, supposedly),
+ # but we need to be cautious about it.
+ cc_files_clone = list(CC_FILES)
+ embed_cc_file = os.path.normpath('google/protobuf/compiler/js/embed.cc')
+ well_known_types_file = os.path.normpath(
+ 'google/protobuf/compiler/js/well_known_types_embed.cc')
+ if embed_cc_file in cc_files_clone:
+ cc_files_clone.remove(embed_cc_file)
+ if well_known_types_file in cc_files_clone:
+ cc_files_clone.remove(well_known_types_file)
+ plugin_sources += [
+ os.path.join('grpc_tools',
+ 'protobuf_generated_well_known_types_embed.cc')
+ ]
+ plugin_sources += [
+ os.path.join(CC_INCLUDE, cc_file) for cc_file in cc_files_clone
+ ]
+
+ plugin_ext = extension.Extension(
+ name='grpc_tools._protoc_compiler',
+ sources=plugin_sources,
+ include_dirs=[
+ '.',
+ 'grpc_root',
+ os.path.join('grpc_root', 'include'),
+ CC_INCLUDE,
+ ],
+ language='c++',
+ define_macros=list(DEFINE_MACROS),
+ extra_compile_args=list(EXTRA_COMPILE_ARGS),
+ extra_link_args=list(EXTRA_LINK_ARGS),
+ )
+ extensions = [plugin_ext]
+ if BUILD_WITH_CYTHON:
+ from Cython import Build
+ return Build.cythonize(extensions)
+ else:
+ return extensions
+
setuptools.setup(
- name='grpcio-tools',
- version=grpc_version.VERSION,
- description='Protobuf code generator for gRPC',
- author='The gRPC Authors',
- author_email='grpc-io@googlegroups.com',
- url='https://grpc.io',
- license='Apache License 2.0',
- classifiers=CLASSIFIERS,
- ext_modules=extension_modules(),
- packages=setuptools.find_packages('.'),
- install_requires=[
- 'protobuf>=3.3.0',
- 'grpcio>={version}'.format(version=grpc_version.VERSION),
- ],
- package_data=package_data(),
+ name='grpcio-tools',
+ version=grpc_version.VERSION,
+ description='Protobuf code generator for gRPC',
+ author='The gRPC Authors',
+ author_email='grpc-io@googlegroups.com',
+ url='https://grpc.io',
+ license='Apache License 2.0',
+ classifiers=CLASSIFIERS,
+ ext_modules=extension_modules(),
+ packages=setuptools.find_packages('.'),
+ install_requires=[
+ 'protobuf>=3.5.0.post1',
+ 'grpcio>={version}'.format(version=grpc_version.VERSION),
+ ],
+ package_data=package_data(),
)
diff --git a/tools/distrib/python/make_grpcio_tools.py b/tools/distrib/python/make_grpcio_tools.py
index 5bc07ff360..4847233217 100755
--- a/tools/distrib/python/make_grpcio_tools.py
+++ b/tools/distrib/python/make_grpcio_tools.py
@@ -27,8 +27,8 @@ import sys
import traceback
import uuid
-DEPS_FILE_CONTENT="""
-# Copyright 2016 gRPC authors.
+DEPS_FILE_CONTENT = """
+# 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.
@@ -48,21 +48,28 @@ PROTO_FILES={proto_files}
CC_INCLUDE={cc_include}
PROTO_INCLUDE={proto_include}
+
+{commit_hash}
"""
+COMMIT_HASH_PREFIX = 'PROTOBUF_SUBMODULE_VERSION="'
+COMMIT_HASH_SUFFIX = '"'
+
# Bazel query result prefix for expected source files in protobuf.
PROTOBUF_CC_PREFIX = '//:src/'
PROTOBUF_PROTO_PREFIX = '//:src/'
GRPC_ROOT = os.path.abspath(
- os.path.join(os.path.dirname(os.path.abspath(__file__)),
- '..', '..', '..'))
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..'))
-GRPC_PYTHON_ROOT = os.path.join(GRPC_ROOT, 'tools', 'distrib',
- 'python', 'grpcio_tools')
+GRPC_PYTHON_ROOT = os.path.join(GRPC_ROOT, 'tools', 'distrib', 'python',
+ 'grpcio_tools')
-GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT = os.path.join('third_party', 'protobuf', 'src')
+GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT = os.path.join('third_party', 'protobuf',
+ 'src')
GRPC_PROTOBUF = os.path.join(GRPC_ROOT, GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT)
+GRPC_PROTOBUF_SUBMODULE_ROOT = os.path.join(GRPC_ROOT, 'third_party',
+ 'protobuf')
GRPC_PROTOC_PLUGINS = os.path.join(GRPC_ROOT, 'src', 'compiler')
GRPC_PYTHON_PROTOBUF = os.path.join(GRPC_PYTHON_ROOT, 'third_party', 'protobuf',
'src')
@@ -74,71 +81,93 @@ GRPC_PYTHON_PROTOC_LIB_DEPS = os.path.join(GRPC_PYTHON_ROOT,
GRPC_INCLUDE = os.path.join(GRPC_ROOT, 'include')
GRPC_PYTHON_INCLUDE = os.path.join(GRPC_PYTHON_ROOT, 'grpc_root', 'include')
-BAZEL_DEPS = os.path.join(GRPC_ROOT, 'tools', 'distrib', 'python', 'bazel_deps.sh')
+BAZEL_DEPS = os.path.join(GRPC_ROOT, 'tools', 'distrib', 'python',
+ 'bazel_deps.sh')
BAZEL_DEPS_PROTOC_LIB_QUERY = '//:protoc_lib'
BAZEL_DEPS_COMMON_PROTOS_QUERY = '//:well_known_protos'
+def protobuf_submodule_commit_hash():
+ """Gets the commit hash for the HEAD of the protobuf submodule currently
+ checked out."""
+ cwd = os.getcwd()
+ os.chdir(GRPC_PROTOBUF_SUBMODULE_ROOT)
+ output = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
+ os.chdir(cwd)
+ return output.splitlines()[0].strip()
+
+
def bazel_query(query):
- output = subprocess.check_output([BAZEL_DEPS, query])
- return output.splitlines()
+ output = subprocess.check_output([BAZEL_DEPS, query])
+ return output.splitlines()
+
def get_deps():
- """Write the result of the bazel query `query` against protobuf to
+ """Write the result of the bazel query `query` against protobuf to
`out_file`."""
- cc_files_output = bazel_query(BAZEL_DEPS_PROTOC_LIB_QUERY)
- cc_files = [
- name[len(PROTOBUF_CC_PREFIX):] for name in cc_files_output
- if name.endswith('.cc') and name.startswith(PROTOBUF_CC_PREFIX)]
- proto_files_output = bazel_query(BAZEL_DEPS_COMMON_PROTOS_QUERY)
- proto_files = [
- name[len(PROTOBUF_PROTO_PREFIX):] for name in proto_files_output
- if name.endswith('.proto') and name.startswith(PROTOBUF_PROTO_PREFIX)]
- deps_file_content = DEPS_FILE_CONTENT.format(
- cc_files=cc_files,
- proto_files=proto_files,
- cc_include=repr(GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT),
- proto_include=repr(GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT))
- return deps_file_content
+ cc_files_output = bazel_query(BAZEL_DEPS_PROTOC_LIB_QUERY)
+ cc_files = [
+ name[len(PROTOBUF_CC_PREFIX):]
+ for name in cc_files_output
+ if name.endswith('.cc') and name.startswith(PROTOBUF_CC_PREFIX)
+ ]
+ proto_files_output = bazel_query(BAZEL_DEPS_COMMON_PROTOS_QUERY)
+ proto_files = [
+ name[len(PROTOBUF_PROTO_PREFIX):]
+ for name in proto_files_output
+ if name.endswith('.proto') and name.startswith(PROTOBUF_PROTO_PREFIX)
+ ]
+ commit_hash = protobuf_submodule_commit_hash()
+ deps_file_content = DEPS_FILE_CONTENT.format(
+ cc_files=cc_files,
+ proto_files=proto_files,
+ cc_include=repr(GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT),
+ proto_include=repr(GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT),
+ commit_hash=COMMIT_HASH_PREFIX + commit_hash + COMMIT_HASH_SUFFIX)
+ return deps_file_content
+
def long_path(path):
- if os.name == 'nt':
- return '\\\\?\\' + path
- else:
- return path
+ if os.name == 'nt':
+ return '\\\\?\\' + path
+ else:
+ return path
+
def main():
- os.chdir(GRPC_ROOT)
-
- for source, target in [
- (GRPC_PROTOBUF, GRPC_PYTHON_PROTOBUF),
- (GRPC_PROTOC_PLUGINS, GRPC_PYTHON_PROTOC_PLUGINS),
- (GRPC_INCLUDE, GRPC_PYTHON_INCLUDE)]:
- for source_dir, _, files in os.walk(source):
- target_dir = os.path.abspath(os.path.join(target, os.path.relpath(source_dir, source)))
- try:
- os.makedirs(target_dir)
- except OSError as error:
- if error.errno != errno.EEXIST:
- raise
- for relative_file in files:
- source_file = os.path.abspath(os.path.join(source_dir, relative_file))
- target_file = os.path.abspath(os.path.join(target_dir, relative_file))
- shutil.copyfile(source_file, target_file)
-
- try:
- protoc_lib_deps_content = get_deps()
- except Exception as error:
- # We allow this script to succeed even if we couldn't get the dependencies,
- # as then we can assume that even without a successful bazel run the
- # dependencies currently in source control are 'good enough'.
- sys.stderr.write("Got non-fatal error:\n")
- traceback.print_exc(file=sys.stderr)
- return
- # If we successfully got the dependencies, truncate and rewrite the deps file.
- with open(GRPC_PYTHON_PROTOC_LIB_DEPS, 'w') as deps_file:
- deps_file.write(protoc_lib_deps_content)
+ os.chdir(GRPC_ROOT)
+
+ for source, target in [(GRPC_PROTOBUF, GRPC_PYTHON_PROTOBUF),
+ (GRPC_PROTOC_PLUGINS, GRPC_PYTHON_PROTOC_PLUGINS),
+ (GRPC_INCLUDE, GRPC_PYTHON_INCLUDE)]:
+ for source_dir, _, files in os.walk(source):
+ target_dir = os.path.abspath(
+ os.path.join(target, os.path.relpath(source_dir, source)))
+ try:
+ os.makedirs(target_dir)
+ except OSError as error:
+ if error.errno != errno.EEXIST:
+ raise
+ for relative_file in files:
+ source_file = os.path.abspath(
+ os.path.join(source_dir, relative_file))
+ target_file = os.path.abspath(
+ os.path.join(target_dir, relative_file))
+ shutil.copyfile(source_file, target_file)
+
+ try:
+ protoc_lib_deps_content = get_deps()
+ except Exception as error:
+ # We allow this script to succeed even if we couldn't get the dependencies,
+ # as then we can assume that even without a successful bazel run the
+ # dependencies currently in source control are 'good enough'.
+ sys.stderr.write("Got non-fatal error:\n")
+ traceback.print_exc(file=sys.stderr)
+ return
+ # If we successfully got the dependencies, truncate and rewrite the deps file.
+ with open(GRPC_PYTHON_PROTOC_LIB_DEPS, 'w') as deps_file:
+ deps_file.write(protoc_lib_deps_content)
-if __name__ == '__main__':
- main()
+if __name__ == '__main__':
+ main()
diff --git a/tools/distrib/python/submit.py b/tools/distrib/python/submit.py
index 92eab5ad65..aff71b5eb1 100755
--- a/tools/distrib/python/submit.py
+++ b/tools/distrib/python/submit.py
@@ -21,43 +21,52 @@ import subprocess
parser = argparse.ArgumentParser(
description='Submit the package to a PyPI repository.')
parser.add_argument(
- '--repository', '-r', metavar='r', type=str, default='pypi',
+ '--repository',
+ '-r',
+ metavar='r',
+ type=str,
+ default='pypi',
help='The repository to push the package to. '
- 'Ensure the value appears in your .pypirc file. '
- 'Defaults to "pypi".'
-)
+ 'Ensure the value appears in your .pypirc file. '
+ 'Defaults to "pypi".')
parser.add_argument(
- '--identity', '-i', metavar='i', type=str,
- help='GPG identity to sign the files with.'
-)
+ '--identity',
+ '-i',
+ metavar='i',
+ type=str,
+ help='GPG identity to sign the files with.')
parser.add_argument(
- '--username', '-u', metavar='u', type=str,
+ '--username',
+ '-u',
+ metavar='u',
+ type=str,
help='Username to authenticate with the repository. Not needed if you have '
- 'configured your .pypirc to include your username.'
-)
+ 'configured your .pypirc to include your username.')
parser.add_argument(
- '--password', '-p', metavar='p', type=str,
+ '--password',
+ '-p',
+ metavar='p',
+ type=str,
help='Password to authenticate with the repository. Not needed if you have '
- 'configured your .pypirc to include your password.'
-)
+ 'configured your .pypirc to include your password.')
parser.add_argument(
- '--bdist', '-b', action='store_true',
- help='Generate a binary distribution (wheel) for the current OS.'
-)
+ '--bdist',
+ '-b',
+ action='store_true',
+ help='Generate a binary distribution (wheel) for the current OS.')
parser.add_argument(
- '--dist-args', type=str,
- help='Additional arguments to pass to the *dist setup.py command.'
-)
+ '--dist-args',
+ type=str,
+ help='Additional arguments to pass to the *dist setup.py command.')
args = parser.parse_args()
# Move to the root directory of Python GRPC.
-pkgdir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- '../../../')
+pkgdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../')
# Remove previous distributions; they somehow confuse twine.
try:
- shutil.rmtree(os.path.join(pkgdir, 'dist/'))
+ shutil.rmtree(os.path.join(pkgdir, 'dist/'))
except:
- pass
+ pass
# Build the Cython C files
build_env = os.environ.copy()
@@ -67,20 +76,20 @@ subprocess.call(cmd, cwd=pkgdir, env=build_env)
# Make the push.
if args.bdist:
- cmd = ['python', 'setup.py', 'bdist_wheel']
+ cmd = ['python', 'setup.py', 'bdist_wheel']
else:
- cmd = ['python', 'setup.py', 'sdist']
+ cmd = ['python', 'setup.py', 'sdist']
if args.dist_args:
- cmd += args.dist_args.split()
+ cmd += args.dist_args.split()
subprocess.call(cmd, cwd=pkgdir)
cmd = ['twine', 'upload', '-r', args.repository]
if args.identity is not None:
- cmd.extend(['-i', args.identity])
+ cmd.extend(['-i', args.identity])
if args.username is not None:
- cmd.extend(['-u', args.username])
+ cmd.extend(['-u', args.username])
if args.password is not None:
- cmd.extend(['-p', args.password])
+ cmd.extend(['-p', args.password])
cmd.append('dist/*')
subprocess.call(cmd, cwd=pkgdir)
diff --git a/tools/distrib/run_clang_tidy.py b/tools/distrib/run_clang_tidy.py
new file mode 100755
index 0000000000..337e6b43c8
--- /dev/null
+++ b/tools/distrib/run_clang_tidy.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python2.7
+# Copyright 2017 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+import os
+import subprocess
+import argparse
+import multiprocessing
+
+sys.path.append(
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', 'run_tests', 'python_utils'))
+import jobset
+
+GRPC_CHECKS = [
+ 'modernize-use-nullptr',
+ 'google-build-namespaces',
+ 'google-build-explicit-make-pair',
+]
+
+extra_args = [
+ '-x',
+ 'c++',
+ '-std=c++11',
+]
+with open('.clang_complete') as f:
+ for line in f:
+ line = line.strip()
+ if line.startswith('-I'):
+ extra_args.append(line)
+
+clang_tidy = os.environ.get('CLANG_TIDY', 'clang-tidy')
+
+argp = argparse.ArgumentParser(description='Run clang-tidy against core')
+argp.add_argument('files', nargs='+', help='Files to tidy')
+argp.add_argument('--fix', dest='fix', action='store_true')
+argp.add_argument(
+ '-j',
+ '--jobs',
+ type=int,
+ default=multiprocessing.cpu_count(),
+ help='Number of CPUs to use')
+argp.set_defaults(fix=False)
+args = argp.parse_args()
+
+cmdline = [
+ clang_tidy,
+ '--checks=-*,%s' % ','.join(GRPC_CHECKS),
+ '--warnings-as-errors=%s' % ','.join(GRPC_CHECKS)
+] + ['--extra-arg-before=%s' % arg for arg in extra_args]
+
+if args.fix:
+ cmdline.append('--fix')
+
+jobs = []
+for filename in args.files:
+ jobs.append(jobset.JobSpec(
+ cmdline + [filename],
+ shortname=filename,
+ )) #verbose_success=True))
+
+num_fails, res_set = jobset.run(jobs, maxjobs=args.jobs)
+sys.exit(num_fails)
diff --git a/tools/distrib/yapf_code.sh b/tools/distrib/yapf_code.sh
index dbb6b5c41f..d188a0242c 100755
--- a/tools/distrib/yapf_code.sh
+++ b/tools/distrib/yapf_code.sh
@@ -19,23 +19,22 @@ set -ex
cd "$(dirname "${0}")/../.."
DIRS=(
+ 'examples/python'
'src/python'
+ 'tools'
)
EXCLUSIONS=(
- 'grpcio/grpc_*.py'
- 'grpcio_health_checking/grpc_*.py'
- 'grpcio_reflection/grpc_*.py'
- 'grpcio_testing/grpc_*.py'
- 'grpcio_tests/grpc_*.py'
+ '*protoc_lib_deps.py' # this file is auto-generated
+ '*_pb2*.py' # no need to format protoc generated files
)
VIRTUALENV=yapf_virtual_environment
virtualenv $VIRTUALENV
PYTHON=$(realpath "${VIRTUALENV}/bin/python")
-$PYTHON -m pip install --upgrade pip
+$PYTHON -m pip install --upgrade pip==9.0.1
$PYTHON -m pip install --upgrade futures
-$PYTHON -m pip install yapf==0.16.0
+$PYTHON -m pip install yapf==0.20.0
yapf() {
local exclusion exclusion_args=()
@@ -55,7 +54,7 @@ else
tempdir=$(mktemp -d)
cp -RT "${dir}" "${tempdir}"
yapf "${tempdir}"
- diff -ru "${dir}" "${tempdir}" || ok=no
+ diff -x '*.pyc' -ru "${dir}" "${tempdir}" || ok=no
rm -rf "${tempdir}"
done
if [[ ${ok} == no ]]; then
diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile
new file mode 100644
index 0000000000..ff43c92c9e
--- /dev/null
+++ b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile
@@ -0,0 +1,40 @@
+# Copyright 2015 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM debian:jessie
+
+# Install Git and basic packages.
+RUN apt-get update && apt-get install -y \
+ curl \
+ gcc && apt-get clean
+
+#==================
+# Ruby dependencies
+
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN \curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.1
+RUN /bin/bash -l -c "rvm install ruby-2.0"
+RUN /bin/bash -l -c "rvm use --default ruby-2.0"
+RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.0' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+
+RUN mkdir /var/local/jenkins
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/grpc_clang_format/Dockerfile b/tools/dockerfile/grpc_clang_format/Dockerfile
index dff07feeb6..8801315bc9 100644
--- a/tools/dockerfile/grpc_clang_format/Dockerfile
+++ b/tools/dockerfile/grpc_clang_format/Dockerfile
@@ -14,11 +14,13 @@
FROM debian:jessie
-RUN apt-get update && apt-get -y install wget
-RUN echo "deb http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main" >> /etc/apt/sources.list
-RUN echo "deb-src http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main" >> /etc/apt/sources.list
-RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add -
-RUN apt-get update && apt-get -y install clang-format-3.8
+RUN apt-get update && apt-get -y install wget xz-utils
+RUN wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN tar xf clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-format /usr/local/bin/clang-format
+ENV CLANG_FORMAT=clang-format
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-tidy /usr/local/bin/clang-tidy
+ENV CLANG_TIDY=clang-tidy
ADD clang_format_all_the_things.sh /
CMD ["echo 'Run with tools/distrib/clang_format_code.sh'"]
diff --git a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
index c471344157..72471994ee 100755
--- a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
+++ b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
@@ -16,20 +16,20 @@
set -e
# directories to run against
-DIRS="src/core/lib src/core/tsi src/core/ext src/cpp test/core test/cpp include src/compiler src/node src/csharp src/ruby"
+DIRS="src/core/lib src/core/tsi src/core/ext src/cpp test/core test/cpp include src/compiler src/csharp src/ruby"
# file matching patterns to check
GLOB="*.h *.c *.cc"
# clang format command
-CLANG_FORMAT=clang-format-3.8
+CLANG_FORMAT=${CLANG_FORMAT:-clang-format-5.0}
files=
for dir in $DIRS
do
for glob in $GLOB
do
- files="$files `find ${CLANG_FORMAT_ROOT}/$dir -name $glob -and -not -name *.generated.* -and -not -name *.pb.h -and -not -name *.pb.c -and -not -name *.pb.cc -and -not -name end2end_tests.c -and -not -name end2end_nosec_tests.c`"
+ files="$files `find ${CLANG_FORMAT_ROOT}/$dir -name $glob -and -not -name '*.generated.*' -and -not -name '*.pb.h' -and -not -name '*.pb.c' -and -not -name '*.pb.cc' -and -not -name end2end_tests.cc -and -not -name end2end_nosec_tests.cc -and -not -name public_headers_must_be_c89.c`"
done
done
diff --git a/tools/dockerfile/grpc_clang_tidy/Dockerfile b/tools/dockerfile/grpc_clang_tidy/Dockerfile
new file mode 100644
index 0000000000..9d9d70185b
--- /dev/null
+++ b/tools/dockerfile/grpc_clang_tidy/Dockerfile
@@ -0,0 +1,41 @@
+# Copyright 2015 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM debian:jessie
+
+RUN apt-get update && apt-get -y install wget xz-utils
+RUN wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN tar xf clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-format /usr/local/bin/clang-format
+ENV CLANG_FORMAT=clang-format
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-tidy /usr/local/bin/clang-tidy
+ENV CLANG_TIDY=clang-tidy
+
+#====================
+# Python dependencies
+
+# Install dependencies
+
+RUN apt-get update && apt-get install -y \
+ python-all-dev \
+ python3-all-dev \
+ python-pip
+
+# Install Python packages from PyPI
+RUN pip install --upgrade pip==9.0.1
+RUN pip install virtualenv
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
+
+ADD clang_tidy_all_the_things.sh /
+CMD ["echo 'Run with tools/distrib/clang_tidy_code.sh'"]
diff --git a/tools/dockerfile/grpc_clang_tidy/clang_tidy_all_the_things.sh b/tools/dockerfile/grpc_clang_tidy/clang_tidy_all_the_things.sh
new file mode 100755
index 0000000000..e1932ed0bf
--- /dev/null
+++ b/tools/dockerfile/grpc_clang_tidy/clang_tidy_all_the_things.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# 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.
+
+set -ex
+
+# clang format command
+CLANG_TIDY=${CLANG_TIDY:-clang-tidy-5.0}
+
+cd ${CLANG_TIDY_ROOT}
+
+find src/core src/cpp test/core test/cpp -name '*.h' -print0 -or -name '*.cc' -print0 \
+ | xargs -0 tools/distrib/run_clang_tidy.py "$@"
diff --git a/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile
index dbf58023c5..af2ab90b76 100644
--- a/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile
@@ -60,9 +60,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#================
# C# dependencies
diff --git a/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile
index 4ccfbc43c3..af2ab90b76 100644
--- a/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile
@@ -22,6 +22,7 @@ RUN apt-get update && apt-get install -y \
bzip2 \
ccache \
curl \
+ dnsutils \
gcc \
gcc-multilib \
git \
@@ -59,9 +60,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#================
# C# dependencies
diff --git a/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh
index bd01eacb15..1c25ab32fa 100755..100644
--- a/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh
+++ b/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/build_interop.sh
@@ -29,4 +29,4 @@ cp -r /var/local/jenkins/service_account $HOME || true
cd /var/local/git/grpc
# build C# interop client & server
-tools/run_tests/run_tests.py -l csharp -c dbg --compiler coreclr --build_only
+tools/run_tests/run_tests.py -l csharp -c dbg --build_only
diff --git a/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile
index 7cfe98cbc8..ec5338b4fc 100644
--- a/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile
@@ -60,9 +60,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# C++ dependencies
diff --git a/tools/dockerfile/interoptest/grpc_interop_go/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_go/Dockerfile
index febe2fa251..a775961ff7 100644
--- a/tools/dockerfile/interoptest/grpc_interop_go/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_go/Dockerfile
@@ -28,9 +28,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Define the default command.
CMD ["bash"]
diff --git a/tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile
index 3a516cbb62..c296c8c674 100644
--- a/tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile
@@ -28,9 +28,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Define the default command.
CMD ["bash"]
diff --git a/tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile
index acb640a81d..9ac0b97341 100644
--- a/tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile
@@ -28,9 +28,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Define the default command.
CMD ["bash"]
diff --git a/tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile
index 354b7bfdb5..92a2faa605 100644
--- a/tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile
@@ -28,9 +28,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
RUN pip install twisted h2==2.6.1 hyper
diff --git a/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile
index 92a542ff76..34b4e39df4 100644
--- a/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile
@@ -43,9 +43,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Trigger download of as many Gradle artifacts as possible.
diff --git a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile
index 92a542ff76..34b4e39df4 100644
--- a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile
@@ -43,9 +43,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Trigger download of as many Gradle artifacts as possible.
diff --git a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile
index 4343d56cb4..17671a384e 100644
--- a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile
@@ -60,9 +60,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#==================
# Node dependencies
diff --git a/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh
index 93aab402aa..c16efc1d35 100755
--- a/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh
+++ b/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh
@@ -17,17 +17,18 @@
set -e
mkdir -p /var/local/git
-git clone /var/local/jenkins/grpc /var/local/git/grpc
+git clone /var/local/jenkins/grpc-node /var/local/git/grpc-node
# clone gRPC submodules, use data from locally cloned submodules where possible
-(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
-&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
+(cd /var/local/jenkins/grpc-node/ && git submodule foreach 'cd /var/local/git/grpc-node \
+&& git submodule update --init --recursive --reference /var/local/jenkins/grpc-node/${name} \
${name}')
# copy service account keys if available
cp -r /var/local/jenkins/service_account $HOME || true
-cd /var/local/git/grpc
+cd /var/local/git/grpc-node
# build Node interop client & server
-npm install -g node-gyp
-npm install --unsafe-perm --build-from-source
+npm install -g node-gyp gulp
+npm install
+gulp setup
diff --git a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile
index 271c6e75e9..07f419f880 100644
--- a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile
@@ -60,9 +60,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Prepare ccache
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc
diff --git a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
index 7bcada68e0..543e207c64 100644
--- a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
@@ -60,9 +60,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#==================
# Ruby dependencies
diff --git a/tools/dockerfile/push_testing_images.sh b/tools/dockerfile/push_testing_images.sh
index e9151303f7..b76ceea8f6 100755
--- a/tools/dockerfile/push_testing_images.sh
+++ b/tools/dockerfile/push_testing_images.sh
@@ -29,7 +29,7 @@ cd -
DOCKERHUB_ORGANIZATION=grpctesting
-for DOCKERFILE_DIR in tools/dockerfile/test/* tools/dockerfile/grpc_artifact_* tools/dockerfile/interoptest/* third_party/rake-compiler-dock
+for DOCKERFILE_DIR in tools/dockerfile/test/* tools/dockerfile/grpc_artifact_* tools/dockerfile/interoptest/* tools/dockerfile/distribtest/cpp_jessie_x64 third_party/rake-compiler-dock
do
# Generate image name based on Dockerfile checksum. That works well as long
# as can count on dockerfiles being written in a way that changing the logical
diff --git a/tools/dockerfile/test/csharp_jessie_x64/Dockerfile b/tools/dockerfile/test/csharp_jessie_x64/Dockerfile
index 40d46fcf58..0fae21de63 100644
--- a/tools/dockerfile/test/csharp_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/csharp_jessie_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#================
# C# dependencies
diff --git a/tools/dockerfile/test/cxx_alpine_x64/Dockerfile b/tools/dockerfile/test/cxx_alpine_x64/Dockerfile
index 1ae50c106f..13a0ea1002 100644
--- a/tools/dockerfile/test/cxx_alpine_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_alpine_x64/Dockerfile
@@ -36,9 +36,9 @@ RUN apk update && apk add \
zip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0
# Google Cloud platform API libraries
RUN pip install --upgrade google-api-python-client
diff --git a/tools/dockerfile/test/cxx_jessie_x64/Dockerfile b/tools/dockerfile/test/cxx_jessie_x64/Dockerfile
index 888a37baca..dff4c96e9a 100644
--- a/tools/dockerfile/test/cxx_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_jessie_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# C++ dependencies
diff --git a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile
index 319f1e1889..ea1d645628 100644
--- a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile
+++ b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# C++ dependencies
diff --git a/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile
index 61f005d9da..990dac9128 100644
--- a/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# C++ dependencies
diff --git a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
index f35247eccb..c8943cada9 100644
--- a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# C++ dependencies
diff --git a/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile b/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile
new file mode 100644
index 0000000000..11aca1766e
--- /dev/null
+++ b/tools/dockerfile/test/cxx_ubuntu1710_x64/Dockerfile
@@ -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.
+
+FROM ubuntu:17.10
+
+# Install Git and basic packages.
+RUN apt-get update && apt-get install -y \
+ autoconf \
+ autotools-dev \
+ build-essential \
+ bzip2 \
+ ccache \
+ curl \
+ dnsutils \
+ gcc \
+ gcc-multilib \
+ git \
+ golang \
+ gyp \
+ lcov \
+ libc6 \
+ libc6-dbg \
+ libc6-dev \
+ libgtest-dev \
+ libtool \
+ make \
+ perl \
+ strace \
+ python-dev \
+ python-setuptools \
+ python-yaml \
+ telnet \
+ unzip \
+ wget \
+ zip && apt-get clean
+
+#================
+# Build profiling
+RUN apt-get update && apt-get install -y time && apt-get clean
+
+# Google Cloud platform API libraries
+RUN apt-get update && apt-get install -y python-pip && apt-get clean
+RUN pip install --upgrade google-api-python-client
+
+#====================
+# Python dependencies
+
+# Install dependencies
+
+RUN apt-get update && apt-get install -y \
+ python-all-dev \
+ python3-all-dev \
+ python-pip
+
+# Install Python packages from PyPI
+RUN pip install --upgrade pip==9.0.1
+RUN pip install virtualenv
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
+
+#=================
+# C++ dependencies
+RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean
+
+# Prepare ccache
+RUN ln -s /usr/bin/ccache /usr/local/bin/gcc
+RUN ln -s /usr/bin/ccache /usr/local/bin/g++
+RUN ln -s /usr/bin/ccache /usr/local/bin/cc
+RUN ln -s /usr/bin/ccache /usr/local/bin/c++
+RUN ln -s /usr/bin/ccache /usr/local/bin/clang
+RUN ln -s /usr/bin/ccache /usr/local/bin/clang++
+
+
+RUN mkdir /var/local/jenkins
+
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/test/fuzzer/Dockerfile b/tools/dockerfile/test/fuzzer/Dockerfile
index ce1badfeb1..52666eab99 100644
--- a/tools/dockerfile/test/fuzzer/Dockerfile
+++ b/tools/dockerfile/test/fuzzer/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# C++ dependencies
diff --git a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile
index 59fe4d8f93..362c061f6d 100644
--- a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile
@@ -71,6 +71,24 @@ RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y \
RUN nuget update -self
+# Install dotnet SDK based on https://www.microsoft.com/net/core#debian
+RUN apt-get update && apt-get install -y curl libunwind8 gettext
+# dotnet-dev-1.0.0-preview2-003131
+RUN curl -sSL -o dotnet100.tar.gz https://go.microsoft.com/fwlink/?LinkID=827530
+RUN mkdir -p /opt/dotnet && tar zxf dotnet100.tar.gz -C /opt/dotnet
+# dotnet-dev-1.0.1
+RUN curl -sSL -o dotnet101.tar.gz https://go.microsoft.com/fwlink/?LinkID=843453
+RUN mkdir -p /opt/dotnet && tar zxf dotnet101.tar.gz -C /opt/dotnet
+RUN ln -s /opt/dotnet/dotnet /usr/local/bin
+
+# Trigger the population of the local package cache
+ENV NUGET_XMLDOC_MODE skip
+RUN mkdir warmup \
+ && cd warmup \
+ && dotnet new \
+ && cd .. \
+ && rm -rf warmup
+
#=================
# C++ dependencies
RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean
@@ -121,9 +139,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Install coverage for Python test coverage reporting
RUN pip install coverage
diff --git a/tools/dockerfile/test/node_jessie_x64/Dockerfile b/tools/dockerfile/test/node_jessie_x64/Dockerfile
index 103be8412b..9f19e76bf5 100644
--- a/tools/dockerfile/test/node_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile
@@ -75,9 +75,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#==================
# Node dependencies
@@ -102,5 +102,8 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/clang++
RUN mkdir /var/local/jenkins
+# Install Mako to generate files in grpc/grpc-node
+RUN pip install Mako
+
# Define the default command.
CMD ["bash"]
diff --git a/tools/dockerfile/test/php7_jessie_x64/Dockerfile b/tools/dockerfile/test/php7_jessie_x64/Dockerfile
index f6d426bcd6..865bf695fe 100644
--- a/tools/dockerfile/test/php7_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/php7_jessie_x64/Dockerfile
@@ -75,9 +75,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Prepare ccache
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc
diff --git a/tools/dockerfile/test/php_jessie_x64/Dockerfile b/tools/dockerfile/test/php_jessie_x64/Dockerfile
index ae82a8d99f..fb653d365a 100644
--- a/tools/dockerfile/test/php_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/php_jessie_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#=================
# PHP dependencies
diff --git a/tools/dockerfile/test/python_alpine_x64/Dockerfile b/tools/dockerfile/test/python_alpine_x64/Dockerfile
index 7bd11d7407..87acef9cb6 100644
--- a/tools/dockerfile/test/python_alpine_x64/Dockerfile
+++ b/tools/dockerfile/test/python_alpine_x64/Dockerfile
@@ -36,9 +36,9 @@ RUN apk update && apk add \
zip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0
# Google Cloud platform API libraries
RUN pip install --upgrade google-api-python-client
diff --git a/tools/dockerfile/test/python_jessie_x64/Dockerfile b/tools/dockerfile/test/python_jessie_x64/Dockerfile
index d5d781cd1a..914e343373 100644
--- a/tools/dockerfile/test/python_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/python_jessie_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Prepare ccache
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc
diff --git a/tools/dockerfile/test/python_pyenv_x64/Dockerfile b/tools/dockerfile/test/python_pyenv_x64/Dockerfile
index 3b4ad12b6d..379f26ad91 100644
--- a/tools/dockerfile/test/python_pyenv_x64/Dockerfile
+++ b/tools/dockerfile/test/python_pyenv_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
# Install dependencies for pyenv
RUN apt-get update && apt-get install -y \
diff --git a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
index 3d879bb0c9..63e42fd2da 100644
--- a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
@@ -64,9 +64,9 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
#==================
# Ruby dependencies
diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile
index dff979dc37..7a8e1c09b1 100644
--- a/tools/dockerfile/test/sanity/Dockerfile
+++ b/tools/dockerfile/test/sanity/Dockerfile
@@ -64,9 +64,13 @@ RUN apt-get update && apt-get install -y \
python-pip
# Install Python packages from PyPI
-RUN pip install pip --upgrade
+RUN pip install --upgrade pip==9.0.1
RUN pip install virtualenv
-RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 twisted==17.5.0
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0
+
+#=================
+# C++ dependencies
+RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean
#========================
# Sanity test dependencies
@@ -77,7 +81,8 @@ RUN apt-get update && apt-get install -y \
libtool \
curl \
python-virtualenv \
- python-lxml
+ python-lxml \
+ shellcheck
RUN pip install simplejson mako
#======================================
@@ -100,11 +105,13 @@ RUN curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/0.4.4/ba
RUN chmod +x ./bazel-0.4.4-installer-linux-x86_64.sh
RUN ./bazel-0.4.4-installer-linux-x86_64.sh
-RUN apt-get update && apt-get -y install wget
-RUN echo "deb http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main" >> /etc/apt/sources.list
-RUN echo "deb-src http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main" >> /etc/apt/sources.list
-RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add -
-RUN apt-get update && apt-get -y install clang-format-3.8
+RUN apt-get update && apt-get -y install wget xz-utils
+RUN wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN tar xf clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-format /usr/local/bin/clang-format
+ENV CLANG_FORMAT=clang-format
+RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-tidy /usr/local/bin/clang-tidy
+ENV CLANG_TIDY=clang-tidy
# Prepare ccache
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index d81b7b4d11..6873256dcd 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.7.0-dev
+PROJECT_NUMBER = 1.10.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
@@ -875,6 +875,8 @@ include/grpc++/support/time.h \
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 \
include/grpc/grpc_security_constants.h \
@@ -886,7 +888,7 @@ include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
-include/grpc/impl/codegen/exec_ctx_fwd.h \
+include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/grpc_types.h \
@@ -911,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/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index eacb40c212..2c6505ddad 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.7.0-dev
+PROJECT_NUMBER = 1.10.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
@@ -876,6 +876,8 @@ include/grpc++/support/time.h \
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 \
include/grpc/grpc_security_constants.h \
@@ -887,7 +889,7 @@ include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
-include/grpc/impl/codegen/exec_ctx_fwd.h \
+include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/grpc_types.h \
@@ -912,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/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -933,6 +934,7 @@ 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 \
src/core/lib/channel/channel_args.h \
src/core/lib/channel/channel_stack.h \
src/core/lib/channel/channel_stack_builder.h \
@@ -942,6 +944,7 @@ src/core/lib/channel/handshaker.h \
src/core/lib/channel/handshaker_factory.h \
src/core/lib/channel/handshaker_registry.h \
src/core/lib/compression/algorithm_metadata.h \
+src/core/lib/compression/compression_internal.h \
src/core/lib/compression/message_compress.h \
src/core/lib/compression/stream_compression.h \
src/core/lib/compression/stream_compression_gzip.h \
@@ -949,9 +952,32 @@ src/core/lib/compression/stream_compression_identity.h \
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/env.h \
+src/core/lib/gpr/fork.h \
+src/core/lib/gpr/mpscq.h \
+src/core/lib/gpr/murmur_hash.h \
+src/core/lib/gpr/spinlock.h \
+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/tmpfile.h \
+src/core/lib/gprpp/abstract.h \
+src/core/lib/gprpp/atomic.h \
+src/core/lib/gprpp/atomic_with_atm.h \
+src/core/lib/gprpp/atomic_with_std.h \
+src/core/lib/gprpp/debug_location.h \
+src/core/lib/gprpp/inlined_vector.h \
+src/core/lib/gprpp/manual_constructor.h \
+src/core/lib/gprpp/memory.h \
+src/core/lib/gprpp/orphanable.h \
+src/core/lib/gprpp/ref_counted.h \
+src/core/lib/gprpp/ref_counted_ptr.h \
src/core/lib/http/format_request.h \
src/core/lib/http/httpcli.h \
src/core/lib/http/parser.h \
+src/core/lib/iomgr/block_annotate.h \
src/core/lib/iomgr/call_combiner.h \
src/core/lib/iomgr/closure.h \
src/core/lib/iomgr/combiner.h \
@@ -1024,22 +1050,6 @@ src/core/lib/slice/percent_encoding.h \
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/support/arena.h \
-src/core/lib/support/atomic.h \
-src/core/lib/support/atomic_with_atm.h \
-src/core/lib/support/atomic_with_std.h \
-src/core/lib/support/backoff.h \
-src/core/lib/support/block_annotate.h \
-src/core/lib/support/env.h \
-src/core/lib/support/memory.h \
-src/core/lib/support/mpscq.h \
-src/core/lib/support/murmur_hash.h \
-src/core/lib/support/spinlock.h \
-src/core/lib/support/stack_lockfree.h \
-src/core/lib/support/string.h \
-src/core/lib/support/string_windows.h \
-src/core/lib/support/time_precise.h \
-src/core/lib/support/tmpfile.h \
src/core/lib/surface/alarm_internal.h \
src/core/lib/surface/api_trace.h \
src/core/lib/surface/call.h \
diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core
index b8514fe311..e2ccc78f56 100644
--- a/tools/doxygen/Doxyfile.core
+++ b/tools/doxygen/Doxyfile.core
@@ -772,7 +772,9 @@ doc/connection-backoff-interop-test-description.md \
doc/connection-backoff.md \
doc/connectivity-semantics-and-api.md \
doc/core/grpc-error.md \
+doc/core/moving-to-c++.md \
doc/core/pending_api_cleanups.md \
+doc/core/transport_explainer.md \
doc/cpp-style-guide.md \
doc/environment_variables.md \
doc/epoll-polling-engine.md \
@@ -799,6 +801,8 @@ include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/census.h \
include/grpc/compression.h \
+include/grpc/compression_ruby.h \
+include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security.h \
@@ -815,7 +819,8 @@ include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
-include/grpc/impl/codegen/exec_ctx_fwd.h \
+include/grpc/impl/codegen/fork.h \
+include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
@@ -848,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/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 33cafacdde..365c80cde9 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -772,7 +772,9 @@ doc/connection-backoff-interop-test-description.md \
doc/connection-backoff.md \
doc/connectivity-semantics-and-api.md \
doc/core/grpc-error.md \
+doc/core/moving-to-c++.md \
doc/core/pending_api_cleanups.md \
+doc/core/transport_explainer.md \
doc/cpp-style-guide.md \
doc/environment_variables.md \
doc/epoll-polling-engine.md \
@@ -799,6 +801,8 @@ include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/census.h \
include/grpc/compression.h \
+include/grpc/compression_ruby.h \
+include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security.h \
@@ -815,7 +819,8 @@ include/grpc/impl/codegen/byte_buffer.h \
include/grpc/impl/codegen/byte_buffer_reader.h \
include/grpc/impl/codegen/compression_types.h \
include/grpc/impl/codegen/connectivity_state.h \
-include/grpc/impl/codegen/exec_ctx_fwd.h \
+include/grpc/impl/codegen/fork.h \
+include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
@@ -848,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/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -870,567 +874,551 @@ include/grpc/support/useful.h \
include/grpc/support/workaround_list.h \
src/core/README.md \
src/core/ext/README.md \
-src/core/ext/census/README.md \
-src/core/ext/census/aggregation.h \
-src/core/ext/census/base_resources.c \
-src/core/ext/census/base_resources.h \
-src/core/ext/census/census_interface.h \
-src/core/ext/census/census_rpc_stats.h \
-src/core/ext/census/context.c \
-src/core/ext/census/gen/README.md \
-src/core/ext/census/gen/census.pb.c \
-src/core/ext/census/gen/census.pb.h \
-src/core/ext/census/gen/trace_context.pb.c \
-src/core/ext/census/gen/trace_context.pb.h \
-src/core/ext/census/grpc_context.c \
-src/core/ext/census/grpc_filter.c \
-src/core/ext/census/grpc_filter.h \
-src/core/ext/census/grpc_plugin.c \
-src/core/ext/census/initialize.c \
-src/core/ext/census/intrusive_hash_map.c \
-src/core/ext/census/intrusive_hash_map.h \
-src/core/ext/census/intrusive_hash_map_internal.h \
-src/core/ext/census/mlog.c \
-src/core/ext/census/mlog.h \
-src/core/ext/census/operation.c \
-src/core/ext/census/placeholders.c \
-src/core/ext/census/resource.c \
-src/core/ext/census/resource.h \
-src/core/ext/census/rpc_metric_id.h \
-src/core/ext/census/trace_context.c \
-src/core/ext/census/trace_context.h \
-src/core/ext/census/trace_label.h \
-src/core/ext/census/trace_propagation.h \
-src/core/ext/census/trace_status.h \
-src/core/ext/census/trace_string.h \
-src/core/ext/census/tracing.c \
-src/core/ext/census/tracing.h \
+src/core/ext/census/grpc_context.cc \
src/core/ext/filters/client_channel/README.md \
-src/core/ext/filters/client_channel/channel_connectivity.c \
-src/core/ext/filters/client_channel/client_channel.c \
+src/core/ext/filters/client_channel/backup_poller.cc \
+src/core/ext/filters/client_channel/backup_poller.h \
+src/core/ext/filters/client_channel/channel_connectivity.cc \
+src/core/ext/filters/client_channel/client_channel.cc \
src/core/ext/filters/client_channel/client_channel.h \
-src/core/ext/filters/client_channel/client_channel_factory.c \
+src/core/ext/filters/client_channel/client_channel_factory.cc \
src/core/ext/filters/client_channel/client_channel_factory.h \
-src/core/ext/filters/client_channel/client_channel_plugin.c \
-src/core/ext/filters/client_channel/connector.c \
+src/core/ext/filters/client_channel/client_channel_plugin.cc \
+src/core/ext/filters/client_channel/connector.cc \
src/core/ext/filters/client_channel/connector.h \
-src/core/ext/filters/client_channel/http_connect_handshaker.c \
+src/core/ext/filters/client_channel/http_connect_handshaker.cc \
src/core/ext/filters/client_channel/http_connect_handshaker.h \
-src/core/ext/filters/client_channel/http_proxy.c \
+src/core/ext/filters/client_channel/http_proxy.cc \
src/core/ext/filters/client_channel/http_proxy.h \
-src/core/ext/filters/client_channel/lb_policy.c \
+src/core/ext/filters/client_channel/lb_policy.cc \
src/core/ext/filters/client_channel/lb_policy.h \
-src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
+src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h \
-src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
+src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h \
-src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
-src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
+src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \
+src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h \
-src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
+src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \
src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h \
-src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c \
-src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c \
-src/core/ext/filters/client_channel/lb_policy_factory.c \
+src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \
+src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \
+src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc \
+src/core/ext/filters/client_channel/lb_policy/subchannel_list.h \
+src/core/ext/filters/client_channel/lb_policy_factory.cc \
src/core/ext/filters/client_channel/lb_policy_factory.h \
-src/core/ext/filters/client_channel/lb_policy_registry.c \
+src/core/ext/filters/client_channel/lb_policy_registry.cc \
src/core/ext/filters/client_channel/lb_policy_registry.h \
-src/core/ext/filters/client_channel/parse_address.c \
+src/core/ext/filters/client_channel/parse_address.cc \
src/core/ext/filters/client_channel/parse_address.h \
-src/core/ext/filters/client_channel/proxy_mapper.c \
+src/core/ext/filters/client_channel/proxy_mapper.cc \
src/core/ext/filters/client_channel/proxy_mapper.h \
-src/core/ext/filters/client_channel/proxy_mapper_registry.c \
+src/core/ext/filters/client_channel/proxy_mapper_registry.cc \
src/core/ext/filters/client_channel/proxy_mapper_registry.h \
-src/core/ext/filters/client_channel/resolver.c \
+src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver.h \
src/core/ext/filters/client_channel/resolver/README.md \
-src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \
+src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \
-src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \
-src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \
+src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
+src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \
-src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c \
+src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
src/core/ext/filters/client_channel/resolver/dns/native/README.md \
-src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \
-src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \
+src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
+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.c \
-src/core/ext/filters/client_channel/resolver_factory.c \
+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.c \
+src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/resolver_registry.h \
-src/core/ext/filters/client_channel/retry_throttle.c \
+src/core/ext/filters/client_channel/retry_throttle.cc \
src/core/ext/filters/client_channel/retry_throttle.h \
-src/core/ext/filters/client_channel/subchannel.c \
+src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel.h \
-src/core/ext/filters/client_channel/subchannel_index.c \
+src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/subchannel_index.h \
-src/core/ext/filters/client_channel/uri_parser.c \
+src/core/ext/filters/client_channel/uri_parser.cc \
src/core/ext/filters/client_channel/uri_parser.h \
-src/core/ext/filters/deadline/deadline_filter.c \
+src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/deadline/deadline_filter.h \
-src/core/ext/filters/http/client/http_client_filter.c \
+src/core/ext/filters/http/client/http_client_filter.cc \
src/core/ext/filters/http/client/http_client_filter.h \
-src/core/ext/filters/http/http_filters_plugin.c \
-src/core/ext/filters/http/message_compress/message_compress_filter.c \
+src/core/ext/filters/http/http_filters_plugin.cc \
+src/core/ext/filters/http/message_compress/message_compress_filter.cc \
src/core/ext/filters/http/message_compress/message_compress_filter.h \
-src/core/ext/filters/http/server/http_server_filter.c \
+src/core/ext/filters/http/server/http_server_filter.cc \
src/core/ext/filters/http/server/http_server_filter.h \
-src/core/ext/filters/load_reporting/server_load_reporting_filter.c \
+src/core/ext/filters/load_reporting/server_load_reporting_filter.cc \
src/core/ext/filters/load_reporting/server_load_reporting_filter.h \
-src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \
+src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc \
src/core/ext/filters/load_reporting/server_load_reporting_plugin.h \
-src/core/ext/filters/max_age/max_age_filter.c \
+src/core/ext/filters/max_age/max_age_filter.cc \
src/core/ext/filters/max_age/max_age_filter.h \
-src/core/ext/filters/message_size/message_size_filter.c \
+src/core/ext/filters/message_size/message_size_filter.cc \
src/core/ext/filters/message_size/message_size_filter.h \
-src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c \
+src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \
src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h \
-src/core/ext/filters/workarounds/workaround_utils.c \
+src/core/ext/filters/workarounds/workaround_utils.cc \
src/core/ext/filters/workarounds/workaround_utils.h \
src/core/ext/transport/README.md \
src/core/ext/transport/chttp2/README.md \
-src/core/ext/transport/chttp2/alpn/alpn.c \
+src/core/ext/transport/chttp2/alpn/alpn.cc \
src/core/ext/transport/chttp2/alpn/alpn.h \
-src/core/ext/transport/chttp2/client/chttp2_connector.c \
+src/core/ext/transport/chttp2/client/chttp2_connector.cc \
src/core/ext/transport/chttp2/client/chttp2_connector.h \
src/core/ext/transport/chttp2/client/insecure/README.md \
-src/core/ext/transport/chttp2/client/insecure/channel_create.c \
-src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
+src/core/ext/transport/chttp2/client/insecure/channel_create.cc \
+src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
src/core/ext/transport/chttp2/client/secure/README.md \
-src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \
-src/core/ext/transport/chttp2/server/chttp2_server.c \
+src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc \
+src/core/ext/transport/chttp2/server/chttp2_server.cc \
src/core/ext/transport/chttp2/server/chttp2_server.h \
src/core/ext/transport/chttp2/server/insecure/README.md \
-src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \
-src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
+src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc \
+src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc \
src/core/ext/transport/chttp2/server/secure/README.md \
-src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \
+src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc \
src/core/ext/transport/chttp2/transport/README.md \
-src/core/ext/transport/chttp2/transport/bin_decoder.c \
+src/core/ext/transport/chttp2/transport/bin_decoder.cc \
src/core/ext/transport/chttp2/transport/bin_decoder.h \
-src/core/ext/transport/chttp2/transport/bin_encoder.c \
+src/core/ext/transport/chttp2/transport/bin_encoder.cc \
src/core/ext/transport/chttp2/transport/bin_encoder.h \
-src/core/ext/transport/chttp2/transport/chttp2_plugin.c \
-src/core/ext/transport/chttp2/transport/chttp2_transport.c \
+src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \
+src/core/ext/transport/chttp2/transport/chttp2_transport.cc \
src/core/ext/transport/chttp2/transport/chttp2_transport.h \
-src/core/ext/transport/chttp2/transport/flow_control.c \
+src/core/ext/transport/chttp2/transport/flow_control.cc \
+src/core/ext/transport/chttp2/transport/flow_control.h \
src/core/ext/transport/chttp2/transport/frame.h \
-src/core/ext/transport/chttp2/transport/frame_data.c \
+src/core/ext/transport/chttp2/transport/frame_data.cc \
src/core/ext/transport/chttp2/transport/frame_data.h \
-src/core/ext/transport/chttp2/transport/frame_goaway.c \
+src/core/ext/transport/chttp2/transport/frame_goaway.cc \
src/core/ext/transport/chttp2/transport/frame_goaway.h \
-src/core/ext/transport/chttp2/transport/frame_ping.c \
+src/core/ext/transport/chttp2/transport/frame_ping.cc \
src/core/ext/transport/chttp2/transport/frame_ping.h \
-src/core/ext/transport/chttp2/transport/frame_rst_stream.c \
+src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \
src/core/ext/transport/chttp2/transport/frame_rst_stream.h \
-src/core/ext/transport/chttp2/transport/frame_settings.c \
+src/core/ext/transport/chttp2/transport/frame_settings.cc \
src/core/ext/transport/chttp2/transport/frame_settings.h \
-src/core/ext/transport/chttp2/transport/frame_window_update.c \
+src/core/ext/transport/chttp2/transport/frame_window_update.cc \
src/core/ext/transport/chttp2/transport/frame_window_update.h \
-src/core/ext/transport/chttp2/transport/hpack_encoder.c \
+src/core/ext/transport/chttp2/transport/hpack_encoder.cc \
src/core/ext/transport/chttp2/transport/hpack_encoder.h \
-src/core/ext/transport/chttp2/transport/hpack_parser.c \
+src/core/ext/transport/chttp2/transport/hpack_parser.cc \
src/core/ext/transport/chttp2/transport/hpack_parser.h \
-src/core/ext/transport/chttp2/transport/hpack_table.c \
+src/core/ext/transport/chttp2/transport/hpack_table.cc \
src/core/ext/transport/chttp2/transport/hpack_table.h \
-src/core/ext/transport/chttp2/transport/http2_settings.c \
+src/core/ext/transport/chttp2/transport/http2_settings.cc \
src/core/ext/transport/chttp2/transport/http2_settings.h \
-src/core/ext/transport/chttp2/transport/huffsyms.c \
+src/core/ext/transport/chttp2/transport/huffsyms.cc \
src/core/ext/transport/chttp2/transport/huffsyms.h \
-src/core/ext/transport/chttp2/transport/incoming_metadata.c \
+src/core/ext/transport/chttp2/transport/incoming_metadata.cc \
src/core/ext/transport/chttp2/transport/incoming_metadata.h \
src/core/ext/transport/chttp2/transport/internal.h \
-src/core/ext/transport/chttp2/transport/parsing.c \
-src/core/ext/transport/chttp2/transport/stream_lists.c \
-src/core/ext/transport/chttp2/transport/stream_map.c \
+src/core/ext/transport/chttp2/transport/parsing.cc \
+src/core/ext/transport/chttp2/transport/stream_lists.cc \
+src/core/ext/transport/chttp2/transport/stream_map.cc \
src/core/ext/transport/chttp2/transport/stream_map.h \
-src/core/ext/transport/chttp2/transport/varint.c \
+src/core/ext/transport/chttp2/transport/varint.cc \
src/core/ext/transport/chttp2/transport/varint.h \
-src/core/ext/transport/chttp2/transport/writing.c \
-src/core/ext/transport/inproc/inproc_plugin.c \
-src/core/ext/transport/inproc/inproc_transport.c \
+src/core/ext/transport/chttp2/transport/writing.cc \
+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/backoff/backoff.cc \
+src/core/lib/backoff/backoff.h \
src/core/lib/channel/README.md \
-src/core/lib/channel/channel_args.c \
+src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_args.h \
-src/core/lib/channel/channel_stack.c \
+src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack.h \
-src/core/lib/channel/channel_stack_builder.c \
+src/core/lib/channel/channel_stack_builder.cc \
src/core/lib/channel/channel_stack_builder.h \
-src/core/lib/channel/connected_channel.c \
+src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/connected_channel.h \
src/core/lib/channel/context.h \
-src/core/lib/channel/handshaker.c \
+src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker.h \
-src/core/lib/channel/handshaker_factory.c \
+src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_factory.h \
-src/core/lib/channel/handshaker_registry.c \
+src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/handshaker_registry.h \
src/core/lib/compression/algorithm_metadata.h \
-src/core/lib/compression/compression.c \
-src/core/lib/compression/message_compress.c \
+src/core/lib/compression/compression.cc \
+src/core/lib/compression/compression_internal.cc \
+src/core/lib/compression/compression_internal.h \
+src/core/lib/compression/compression_ruby.cc \
+src/core/lib/compression/message_compress.cc \
src/core/lib/compression/message_compress.h \
-src/core/lib/compression/stream_compression.c \
+src/core/lib/compression/stream_compression.cc \
src/core/lib/compression/stream_compression.h \
-src/core/lib/compression/stream_compression_gzip.c \
+src/core/lib/compression/stream_compression_gzip.cc \
src/core/lib/compression/stream_compression_gzip.h \
-src/core/lib/compression/stream_compression_identity.c \
+src/core/lib/compression/stream_compression_identity.cc \
src/core/lib/compression/stream_compression_identity.h \
-src/core/lib/debug/stats.c \
+src/core/lib/debug/stats.cc \
src/core/lib/debug/stats.h \
-src/core/lib/debug/stats_data.c \
+src/core/lib/debug/stats_data.cc \
src/core/lib/debug/stats_data.h \
-src/core/lib/debug/trace.c \
+src/core/lib/debug/trace.cc \
src/core/lib/debug/trace.h \
-src/core/lib/http/format_request.c \
+src/core/lib/gpr/README.md \
+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/cmdline.cc \
+src/core/lib/gpr/cpu_iphone.cc \
+src/core/lib/gpr/cpu_linux.cc \
+src/core/lib/gpr/cpu_posix.cc \
+src/core/lib/gpr/cpu_windows.cc \
+src/core/lib/gpr/env.h \
+src/core/lib/gpr/env_linux.cc \
+src/core/lib/gpr/env_posix.cc \
+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/log.cc \
+src/core/lib/gpr/log_android.cc \
+src/core/lib/gpr/log_linux.cc \
+src/core/lib/gpr/log_posix.cc \
+src/core/lib/gpr/log_windows.cc \
+src/core/lib/gpr/mpscq.cc \
+src/core/lib/gpr/mpscq.h \
+src/core/lib/gpr/murmur_hash.cc \
+src/core/lib/gpr/murmur_hash.h \
+src/core/lib/gpr/spinlock.h \
+src/core/lib/gpr/string.cc \
+src/core/lib/gpr/string.h \
+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 \
+src/core/lib/gpr/thd.cc \
+src/core/lib/gpr/thd_internal.h \
+src/core/lib/gpr/thd_posix.cc \
+src/core/lib/gpr/thd_windows.cc \
+src/core/lib/gpr/time.cc \
+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_pthread.cc \
+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/wrap_memcpy.cc \
+src/core/lib/gprpp/README.md \
+src/core/lib/gprpp/abstract.h \
+src/core/lib/gprpp/atomic.h \
+src/core/lib/gprpp/atomic_with_atm.h \
+src/core/lib/gprpp/atomic_with_std.h \
+src/core/lib/gprpp/debug_location.h \
+src/core/lib/gprpp/inlined_vector.h \
+src/core/lib/gprpp/manual_constructor.h \
+src/core/lib/gprpp/memory.h \
+src/core/lib/gprpp/orphanable.h \
+src/core/lib/gprpp/ref_counted.h \
+src/core/lib/gprpp/ref_counted_ptr.h \
+src/core/lib/http/format_request.cc \
src/core/lib/http/format_request.h \
-src/core/lib/http/httpcli.c \
+src/core/lib/http/httpcli.cc \
src/core/lib/http/httpcli.h \
-src/core/lib/http/httpcli_security_connector.c \
-src/core/lib/http/parser.c \
+src/core/lib/http/httpcli_security_connector.cc \
+src/core/lib/http/parser.cc \
src/core/lib/http/parser.h \
src/core/lib/iomgr/README.md \
-src/core/lib/iomgr/call_combiner.c \
+src/core/lib/iomgr/block_annotate.h \
+src/core/lib/iomgr/call_combiner.cc \
src/core/lib/iomgr/call_combiner.h \
-src/core/lib/iomgr/closure.c \
src/core/lib/iomgr/closure.h \
-src/core/lib/iomgr/combiner.c \
+src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/combiner.h \
-src/core/lib/iomgr/endpoint.c \
+src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint.h \
src/core/lib/iomgr/endpoint_pair.h \
-src/core/lib/iomgr/endpoint_pair_posix.c \
-src/core/lib/iomgr/endpoint_pair_uv.c \
-src/core/lib/iomgr/endpoint_pair_windows.c \
-src/core/lib/iomgr/error.c \
+src/core/lib/iomgr/endpoint_pair_posix.cc \
+src/core/lib/iomgr/endpoint_pair_uv.cc \
+src/core/lib/iomgr/endpoint_pair_windows.cc \
+src/core/lib/iomgr/error.cc \
src/core/lib/iomgr/error.h \
src/core/lib/iomgr/error_internal.h \
-src/core/lib/iomgr/ev_epoll1_linux.c \
+src/core/lib/iomgr/ev_epoll1_linux.cc \
src/core/lib/iomgr/ev_epoll1_linux.h \
-src/core/lib/iomgr/ev_epollex_linux.c \
+src/core/lib/iomgr/ev_epollex_linux.cc \
src/core/lib/iomgr/ev_epollex_linux.h \
-src/core/lib/iomgr/ev_epollsig_linux.c \
+src/core/lib/iomgr/ev_epollsig_linux.cc \
src/core/lib/iomgr/ev_epollsig_linux.h \
-src/core/lib/iomgr/ev_poll_posix.c \
+src/core/lib/iomgr/ev_poll_posix.cc \
src/core/lib/iomgr/ev_poll_posix.h \
-src/core/lib/iomgr/ev_posix.c \
+src/core/lib/iomgr/ev_posix.cc \
src/core/lib/iomgr/ev_posix.h \
-src/core/lib/iomgr/ev_windows.c \
-src/core/lib/iomgr/exec_ctx.c \
+src/core/lib/iomgr/ev_windows.cc \
+src/core/lib/iomgr/exec_ctx.cc \
src/core/lib/iomgr/exec_ctx.h \
-src/core/lib/iomgr/executor.c \
+src/core/lib/iomgr/executor.cc \
src/core/lib/iomgr/executor.h \
+src/core/lib/iomgr/fork_posix.cc \
+src/core/lib/iomgr/fork_windows.cc \
src/core/lib/iomgr/gethostname.h \
-src/core/lib/iomgr/gethostname_fallback.c \
-src/core/lib/iomgr/gethostname_host_name_max.c \
-src/core/lib/iomgr/gethostname_sysconf.c \
-src/core/lib/iomgr/iocp_windows.c \
+src/core/lib/iomgr/gethostname_fallback.cc \
+src/core/lib/iomgr/gethostname_host_name_max.cc \
+src/core/lib/iomgr/gethostname_sysconf.cc \
+src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iocp_windows.h \
-src/core/lib/iomgr/iomgr.c \
+src/core/lib/iomgr/iomgr.cc \
src/core/lib/iomgr/iomgr.h \
src/core/lib/iomgr/iomgr_internal.h \
-src/core/lib/iomgr/iomgr_posix.c \
+src/core/lib/iomgr/iomgr_posix.cc \
src/core/lib/iomgr/iomgr_posix.h \
-src/core/lib/iomgr/iomgr_uv.c \
+src/core/lib/iomgr/iomgr_uv.cc \
src/core/lib/iomgr/iomgr_uv.h \
-src/core/lib/iomgr/iomgr_windows.c \
-src/core/lib/iomgr/is_epollexclusive_available.c \
+src/core/lib/iomgr/iomgr_windows.cc \
+src/core/lib/iomgr/is_epollexclusive_available.cc \
src/core/lib/iomgr/is_epollexclusive_available.h \
-src/core/lib/iomgr/load_file.c \
+src/core/lib/iomgr/load_file.cc \
src/core/lib/iomgr/load_file.h \
-src/core/lib/iomgr/lockfree_event.c \
+src/core/lib/iomgr/lockfree_event.cc \
src/core/lib/iomgr/lockfree_event.h \
src/core/lib/iomgr/nameser.h \
-src/core/lib/iomgr/network_status_tracker.c \
+src/core/lib/iomgr/network_status_tracker.cc \
src/core/lib/iomgr/network_status_tracker.h \
-src/core/lib/iomgr/polling_entity.c \
+src/core/lib/iomgr/polling_entity.cc \
src/core/lib/iomgr/polling_entity.h \
src/core/lib/iomgr/pollset.h \
src/core/lib/iomgr/pollset_set.h \
-src/core/lib/iomgr/pollset_set_uv.c \
-src/core/lib/iomgr/pollset_set_windows.c \
+src/core/lib/iomgr/pollset_set_uv.cc \
+src/core/lib/iomgr/pollset_set_windows.cc \
src/core/lib/iomgr/pollset_set_windows.h \
-src/core/lib/iomgr/pollset_uv.c \
+src/core/lib/iomgr/pollset_uv.cc \
src/core/lib/iomgr/pollset_uv.h \
-src/core/lib/iomgr/pollset_windows.c \
+src/core/lib/iomgr/pollset_windows.cc \
src/core/lib/iomgr/pollset_windows.h \
src/core/lib/iomgr/port.h \
src/core/lib/iomgr/resolve_address.h \
-src/core/lib/iomgr/resolve_address_posix.c \
-src/core/lib/iomgr/resolve_address_uv.c \
-src/core/lib/iomgr/resolve_address_windows.c \
-src/core/lib/iomgr/resource_quota.c \
+src/core/lib/iomgr/resolve_address_posix.cc \
+src/core/lib/iomgr/resolve_address_uv.cc \
+src/core/lib/iomgr/resolve_address_windows.cc \
+src/core/lib/iomgr/resource_quota.cc \
src/core/lib/iomgr/resource_quota.h \
src/core/lib/iomgr/sockaddr.h \
src/core/lib/iomgr/sockaddr_posix.h \
-src/core/lib/iomgr/sockaddr_utils.c \
+src/core/lib/iomgr/sockaddr_utils.cc \
src/core/lib/iomgr/sockaddr_utils.h \
src/core/lib/iomgr/sockaddr_windows.h \
-src/core/lib/iomgr/socket_factory_posix.c \
+src/core/lib/iomgr/socket_factory_posix.cc \
src/core/lib/iomgr/socket_factory_posix.h \
-src/core/lib/iomgr/socket_mutator.c \
+src/core/lib/iomgr/socket_mutator.cc \
src/core/lib/iomgr/socket_mutator.h \
src/core/lib/iomgr/socket_utils.h \
-src/core/lib/iomgr/socket_utils_common_posix.c \
-src/core/lib/iomgr/socket_utils_linux.c \
-src/core/lib/iomgr/socket_utils_posix.c \
+src/core/lib/iomgr/socket_utils_common_posix.cc \
+src/core/lib/iomgr/socket_utils_linux.cc \
+src/core/lib/iomgr/socket_utils_posix.cc \
src/core/lib/iomgr/socket_utils_posix.h \
-src/core/lib/iomgr/socket_utils_uv.c \
-src/core/lib/iomgr/socket_utils_windows.c \
-src/core/lib/iomgr/socket_windows.c \
+src/core/lib/iomgr/socket_utils_uv.cc \
+src/core/lib/iomgr/socket_utils_windows.cc \
+src/core/lib/iomgr/socket_windows.cc \
src/core/lib/iomgr/socket_windows.h \
src/core/lib/iomgr/sys_epoll_wrapper.h \
src/core/lib/iomgr/tcp_client.h \
-src/core/lib/iomgr/tcp_client_posix.c \
+src/core/lib/iomgr/tcp_client_posix.cc \
src/core/lib/iomgr/tcp_client_posix.h \
-src/core/lib/iomgr/tcp_client_uv.c \
-src/core/lib/iomgr/tcp_client_windows.c \
-src/core/lib/iomgr/tcp_posix.c \
+src/core/lib/iomgr/tcp_client_uv.cc \
+src/core/lib/iomgr/tcp_client_windows.cc \
+src/core/lib/iomgr/tcp_posix.cc \
src/core/lib/iomgr/tcp_posix.h \
src/core/lib/iomgr/tcp_server.h \
-src/core/lib/iomgr/tcp_server_posix.c \
+src/core/lib/iomgr/tcp_server_posix.cc \
src/core/lib/iomgr/tcp_server_utils_posix.h \
-src/core/lib/iomgr/tcp_server_utils_posix_common.c \
-src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c \
-src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c \
-src/core/lib/iomgr/tcp_server_uv.c \
-src/core/lib/iomgr/tcp_server_windows.c \
-src/core/lib/iomgr/tcp_uv.c \
+src/core/lib/iomgr/tcp_server_utils_posix_common.cc \
+src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \
+src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \
+src/core/lib/iomgr/tcp_server_uv.cc \
+src/core/lib/iomgr/tcp_server_windows.cc \
+src/core/lib/iomgr/tcp_uv.cc \
src/core/lib/iomgr/tcp_uv.h \
-src/core/lib/iomgr/tcp_windows.c \
+src/core/lib/iomgr/tcp_windows.cc \
src/core/lib/iomgr/tcp_windows.h \
-src/core/lib/iomgr/time_averaged_stats.c \
+src/core/lib/iomgr/time_averaged_stats.cc \
src/core/lib/iomgr/time_averaged_stats.h \
src/core/lib/iomgr/timer.h \
-src/core/lib/iomgr/timer_generic.c \
+src/core/lib/iomgr/timer_generic.cc \
src/core/lib/iomgr/timer_generic.h \
-src/core/lib/iomgr/timer_heap.c \
+src/core/lib/iomgr/timer_heap.cc \
src/core/lib/iomgr/timer_heap.h \
-src/core/lib/iomgr/timer_manager.c \
+src/core/lib/iomgr/timer_manager.cc \
src/core/lib/iomgr/timer_manager.h \
-src/core/lib/iomgr/timer_uv.c \
+src/core/lib/iomgr/timer_uv.cc \
src/core/lib/iomgr/timer_uv.h \
-src/core/lib/iomgr/udp_server.c \
+src/core/lib/iomgr/udp_server.cc \
src/core/lib/iomgr/udp_server.h \
-src/core/lib/iomgr/unix_sockets_posix.c \
+src/core/lib/iomgr/unix_sockets_posix.cc \
src/core/lib/iomgr/unix_sockets_posix.h \
-src/core/lib/iomgr/unix_sockets_posix_noop.c \
-src/core/lib/iomgr/wakeup_fd_cv.c \
+src/core/lib/iomgr/unix_sockets_posix_noop.cc \
+src/core/lib/iomgr/wakeup_fd_cv.cc \
src/core/lib/iomgr/wakeup_fd_cv.h \
-src/core/lib/iomgr/wakeup_fd_eventfd.c \
-src/core/lib/iomgr/wakeup_fd_nospecial.c \
-src/core/lib/iomgr/wakeup_fd_pipe.c \
+src/core/lib/iomgr/wakeup_fd_eventfd.cc \
+src/core/lib/iomgr/wakeup_fd_nospecial.cc \
+src/core/lib/iomgr/wakeup_fd_pipe.cc \
src/core/lib/iomgr/wakeup_fd_pipe.h \
-src/core/lib/iomgr/wakeup_fd_posix.c \
+src/core/lib/iomgr/wakeup_fd_posix.cc \
src/core/lib/iomgr/wakeup_fd_posix.h \
-src/core/lib/json/json.c \
+src/core/lib/json/json.cc \
src/core/lib/json/json.h \
src/core/lib/json/json_common.h \
-src/core/lib/json/json_reader.c \
+src/core/lib/json/json_reader.cc \
src/core/lib/json/json_reader.h \
-src/core/lib/json/json_string.c \
-src/core/lib/json/json_writer.c \
+src/core/lib/json/json_string.cc \
+src/core/lib/json/json_writer.cc \
src/core/lib/json/json_writer.h \
-src/core/lib/profiling/basic_timers.c \
-src/core/lib/profiling/stap_timers.c \
+src/core/lib/profiling/basic_timers.cc \
+src/core/lib/profiling/stap_timers.cc \
src/core/lib/profiling/timers.h \
-src/core/lib/security/context/security_context.c \
+src/core/lib/security/context/security_context.cc \
src/core/lib/security/context/security_context.h \
-src/core/lib/security/credentials/composite/composite_credentials.c \
+src/core/lib/security/credentials/composite/composite_credentials.cc \
src/core/lib/security/credentials/composite/composite_credentials.h \
-src/core/lib/security/credentials/credentials.c \
+src/core/lib/security/credentials/credentials.cc \
src/core/lib/security/credentials/credentials.h \
-src/core/lib/security/credentials/credentials_metadata.c \
-src/core/lib/security/credentials/fake/fake_credentials.c \
+src/core/lib/security/credentials/credentials_metadata.cc \
+src/core/lib/security/credentials/fake/fake_credentials.cc \
src/core/lib/security/credentials/fake/fake_credentials.h \
-src/core/lib/security/credentials/google_default/credentials_generic.c \
-src/core/lib/security/credentials/google_default/google_default_credentials.c \
+src/core/lib/security/credentials/google_default/credentials_generic.cc \
+src/core/lib/security/credentials/google_default/google_default_credentials.cc \
src/core/lib/security/credentials/google_default/google_default_credentials.h \
-src/core/lib/security/credentials/iam/iam_credentials.c \
+src/core/lib/security/credentials/iam/iam_credentials.cc \
src/core/lib/security/credentials/iam/iam_credentials.h \
-src/core/lib/security/credentials/jwt/json_token.c \
+src/core/lib/security/credentials/jwt/json_token.cc \
src/core/lib/security/credentials/jwt/json_token.h \
-src/core/lib/security/credentials/jwt/jwt_credentials.c \
+src/core/lib/security/credentials/jwt/jwt_credentials.cc \
src/core/lib/security/credentials/jwt/jwt_credentials.h \
-src/core/lib/security/credentials/jwt/jwt_verifier.c \
+src/core/lib/security/credentials/jwt/jwt_verifier.cc \
src/core/lib/security/credentials/jwt/jwt_verifier.h \
-src/core/lib/security/credentials/oauth2/oauth2_credentials.c \
+src/core/lib/security/credentials/oauth2/oauth2_credentials.cc \
src/core/lib/security/credentials/oauth2/oauth2_credentials.h \
-src/core/lib/security/credentials/plugin/plugin_credentials.c \
+src/core/lib/security/credentials/plugin/plugin_credentials.cc \
src/core/lib/security/credentials/plugin/plugin_credentials.h \
-src/core/lib/security/credentials/ssl/ssl_credentials.c \
+src/core/lib/security/credentials/ssl/ssl_credentials.cc \
src/core/lib/security/credentials/ssl/ssl_credentials.h \
src/core/lib/security/transport/auth_filters.h \
-src/core/lib/security/transport/client_auth_filter.c \
-src/core/lib/security/transport/lb_targets_info.c \
+src/core/lib/security/transport/client_auth_filter.cc \
+src/core/lib/security/transport/lb_targets_info.cc \
src/core/lib/security/transport/lb_targets_info.h \
-src/core/lib/security/transport/secure_endpoint.c \
+src/core/lib/security/transport/secure_endpoint.cc \
src/core/lib/security/transport/secure_endpoint.h \
-src/core/lib/security/transport/security_connector.c \
+src/core/lib/security/transport/security_connector.cc \
src/core/lib/security/transport/security_connector.h \
-src/core/lib/security/transport/security_handshaker.c \
+src/core/lib/security/transport/security_handshaker.cc \
src/core/lib/security/transport/security_handshaker.h \
-src/core/lib/security/transport/server_auth_filter.c \
-src/core/lib/security/transport/tsi_error.c \
+src/core/lib/security/transport/server_auth_filter.cc \
+src/core/lib/security/transport/tsi_error.cc \
src/core/lib/security/transport/tsi_error.h \
-src/core/lib/security/util/json_util.c \
+src/core/lib/security/util/json_util.cc \
src/core/lib/security/util/json_util.h \
-src/core/lib/slice/b64.c \
+src/core/lib/slice/b64.cc \
src/core/lib/slice/b64.h \
-src/core/lib/slice/percent_encoding.c \
+src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/percent_encoding.h \
-src/core/lib/slice/slice.c \
-src/core/lib/slice/slice_buffer.c \
-src/core/lib/slice/slice_hash_table.c \
+src/core/lib/slice/slice.cc \
+src/core/lib/slice/slice_buffer.cc \
+src/core/lib/slice/slice_hash_table.cc \
src/core/lib/slice/slice_hash_table.h \
-src/core/lib/slice/slice_intern.c \
+src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_internal.h \
-src/core/lib/slice/slice_string_helpers.c \
+src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
-src/core/lib/support/alloc.c \
-src/core/lib/support/arena.c \
-src/core/lib/support/arena.h \
-src/core/lib/support/atm.c \
-src/core/lib/support/atomic.h \
-src/core/lib/support/atomic_with_atm.h \
-src/core/lib/support/atomic_with_std.h \
-src/core/lib/support/avl.c \
-src/core/lib/support/backoff.c \
-src/core/lib/support/backoff.h \
-src/core/lib/support/block_annotate.h \
-src/core/lib/support/cmdline.c \
-src/core/lib/support/cpu_iphone.c \
-src/core/lib/support/cpu_linux.c \
-src/core/lib/support/cpu_posix.c \
-src/core/lib/support/cpu_windows.c \
-src/core/lib/support/env.h \
-src/core/lib/support/env_linux.c \
-src/core/lib/support/env_posix.c \
-src/core/lib/support/env_windows.c \
-src/core/lib/support/histogram.c \
-src/core/lib/support/host_port.c \
-src/core/lib/support/log.c \
-src/core/lib/support/log_android.c \
-src/core/lib/support/log_linux.c \
-src/core/lib/support/log_posix.c \
-src/core/lib/support/log_windows.c \
-src/core/lib/support/memory.h \
-src/core/lib/support/mpscq.c \
-src/core/lib/support/mpscq.h \
-src/core/lib/support/murmur_hash.c \
-src/core/lib/support/murmur_hash.h \
-src/core/lib/support/spinlock.h \
-src/core/lib/support/stack_lockfree.c \
-src/core/lib/support/stack_lockfree.h \
-src/core/lib/support/string.c \
-src/core/lib/support/string.h \
-src/core/lib/support/string_posix.c \
-src/core/lib/support/string_util_windows.c \
-src/core/lib/support/string_windows.c \
-src/core/lib/support/string_windows.h \
-src/core/lib/support/subprocess_posix.c \
-src/core/lib/support/subprocess_windows.c \
-src/core/lib/support/sync.c \
-src/core/lib/support/sync_posix.c \
-src/core/lib/support/sync_windows.c \
-src/core/lib/support/thd.c \
-src/core/lib/support/thd_posix.c \
-src/core/lib/support/thd_windows.c \
-src/core/lib/support/time.c \
-src/core/lib/support/time_posix.c \
-src/core/lib/support/time_precise.c \
-src/core/lib/support/time_precise.h \
-src/core/lib/support/time_windows.c \
-src/core/lib/support/tls_pthread.c \
-src/core/lib/support/tmpfile.h \
-src/core/lib/support/tmpfile_msys.c \
-src/core/lib/support/tmpfile_posix.c \
-src/core/lib/support/tmpfile_windows.c \
-src/core/lib/support/wrap_memcpy.c \
src/core/lib/surface/README.md \
-src/core/lib/surface/alarm.c \
+src/core/lib/surface/alarm.cc \
src/core/lib/surface/alarm_internal.h \
-src/core/lib/surface/api_trace.c \
+src/core/lib/surface/api_trace.cc \
src/core/lib/surface/api_trace.h \
-src/core/lib/surface/byte_buffer.c \
-src/core/lib/surface/byte_buffer_reader.c \
-src/core/lib/surface/call.c \
+src/core/lib/surface/byte_buffer.cc \
+src/core/lib/surface/byte_buffer_reader.cc \
+src/core/lib/surface/call.cc \
src/core/lib/surface/call.h \
-src/core/lib/surface/call_details.c \
-src/core/lib/surface/call_log_batch.c \
+src/core/lib/surface/call_details.cc \
+src/core/lib/surface/call_log_batch.cc \
src/core/lib/surface/call_test_only.h \
-src/core/lib/surface/channel.c \
+src/core/lib/surface/channel.cc \
src/core/lib/surface/channel.h \
-src/core/lib/surface/channel_init.c \
+src/core/lib/surface/channel_init.cc \
src/core/lib/surface/channel_init.h \
-src/core/lib/surface/channel_ping.c \
-src/core/lib/surface/channel_stack_type.c \
+src/core/lib/surface/channel_ping.cc \
+src/core/lib/surface/channel_stack_type.cc \
src/core/lib/surface/channel_stack_type.h \
-src/core/lib/surface/completion_queue.c \
+src/core/lib/surface/completion_queue.cc \
src/core/lib/surface/completion_queue.h \
-src/core/lib/surface/completion_queue_factory.c \
+src/core/lib/surface/completion_queue_factory.cc \
src/core/lib/surface/completion_queue_factory.h \
-src/core/lib/surface/event_string.c \
+src/core/lib/surface/event_string.cc \
src/core/lib/surface/event_string.h \
-src/core/lib/surface/init.c \
+src/core/lib/surface/init.cc \
src/core/lib/surface/init.h \
-src/core/lib/surface/init_secure.c \
+src/core/lib/surface/init_secure.cc \
src/core/lib/surface/lame_client.cc \
src/core/lib/surface/lame_client.h \
-src/core/lib/surface/metadata_array.c \
-src/core/lib/surface/server.c \
+src/core/lib/surface/metadata_array.cc \
+src/core/lib/surface/server.cc \
src/core/lib/surface/server.h \
-src/core/lib/surface/validate_metadata.c \
+src/core/lib/surface/validate_metadata.cc \
src/core/lib/surface/validate_metadata.h \
-src/core/lib/surface/version.c \
+src/core/lib/surface/version.cc \
src/core/lib/transport/README.md \
-src/core/lib/transport/bdp_estimator.c \
+src/core/lib/transport/bdp_estimator.cc \
src/core/lib/transport/bdp_estimator.h \
-src/core/lib/transport/byte_stream.c \
+src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/byte_stream.h \
-src/core/lib/transport/connectivity_state.c \
+src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/connectivity_state.h \
-src/core/lib/transport/error_utils.c \
+src/core/lib/transport/error_utils.cc \
src/core/lib/transport/error_utils.h \
src/core/lib/transport/http2_errors.h \
-src/core/lib/transport/metadata.c \
+src/core/lib/transport/metadata.cc \
src/core/lib/transport/metadata.h \
-src/core/lib/transport/metadata_batch.c \
+src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/metadata_batch.h \
-src/core/lib/transport/pid_controller.c \
+src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/pid_controller.h \
-src/core/lib/transport/service_config.c \
+src/core/lib/transport/service_config.cc \
src/core/lib/transport/service_config.h \
-src/core/lib/transport/static_metadata.c \
+src/core/lib/transport/static_metadata.cc \
src/core/lib/transport/static_metadata.h \
-src/core/lib/transport/status_conversion.c \
+src/core/lib/transport/status_conversion.cc \
src/core/lib/transport/status_conversion.h \
-src/core/lib/transport/timeout_encoding.c \
+src/core/lib/transport/timeout_encoding.cc \
src/core/lib/transport/timeout_encoding.h \
-src/core/lib/transport/transport.c \
+src/core/lib/transport/transport.cc \
src/core/lib/transport/transport.h \
src/core/lib/transport/transport_impl.h \
-src/core/lib/transport/transport_op_string.c \
-src/core/plugin_registry/grpc_plugin_registry.c \
+src/core/lib/transport/transport_op_string.cc \
+src/core/plugin_registry/grpc_plugin_registry.cc \
src/core/tsi/README.md \
-src/core/tsi/fake_transport_security.c \
+src/core/tsi/alts_transport_security.cc \
+src/core/tsi/alts_transport_security.h \
+src/core/tsi/fake_transport_security.cc \
src/core/tsi/fake_transport_security.h \
-src/core/tsi/gts_transport_security.c \
-src/core/tsi/gts_transport_security.h \
-src/core/tsi/ssl_transport_security.c \
+src/core/tsi/ssl_transport_security.cc \
src/core/tsi/ssl_transport_security.h \
src/core/tsi/ssl_types.h \
-src/core/tsi/transport_security.c \
+src/core/tsi/transport_security.cc \
src/core/tsi/transport_security.h \
-src/core/tsi/transport_security_adapter.c \
+src/core/tsi/transport_security_adapter.cc \
src/core/tsi/transport_security_adapter.h \
-src/core/tsi/transport_security_grpc.c \
+src/core/tsi/transport_security_grpc.cc \
src/core/tsi/transport_security_grpc.h \
src/core/tsi/transport_security_interface.h \
third_party/nanopb/pb.h \
diff --git a/tools/failures/detect_new_failures.py b/tools/failures/detect_new_failures.py
new file mode 100644
index 0000000000..4063978fce
--- /dev/null
+++ b/tools/failures/detect_new_failures.py
@@ -0,0 +1,309 @@
+#!/usr/bin/env python
+# 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.
+"""Detect new flakes and create issues for them"""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import datetime
+import json
+import logging
+import os
+import pprint
+import sys
+import urllib
+import urllib2
+from collections import namedtuple
+
+gcp_utils_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../gcp/utils'))
+sys.path.append(gcp_utils_dir)
+
+import big_query_utils
+
+GH_ISSUE_CREATION_URL = 'https://api.github.com/repos/grpc/grpc/issues'
+GH_ISSUE_SEARCH_URL = 'https://api.github.com/search/issues'
+KOKORO_BASE_URL = 'https://kokoro2.corp.google.com/job/'
+
+
+def gh(url, data=None):
+ request = urllib2.Request(url, data=data)
+ assert TOKEN
+ request.add_header('Authorization', 'token {}'.format(TOKEN))
+ if data:
+ request.add_header('Content-type', 'application/json')
+ response = urllib2.urlopen(request)
+ if 200 <= response.getcode() < 300:
+ return json.loads(response.read())
+ else:
+ raise ValueError('Error ({}) accessing {}'.format(
+ response.getcode(), response.geturl()))
+
+
+def search_gh_issues(search_term, status='open'):
+ params = ' '.join((search_term, 'is:issue', 'is:open', 'repo:grpc/grpc'))
+ qargs = urllib.urlencode({'q': params})
+ url = '?'.join((GH_ISSUE_SEARCH_URL, qargs))
+ response = gh(url)
+ return response
+
+
+def create_gh_issue(title, body, labels, assignees=[]):
+ params = {'title': title, 'body': body, 'labels': labels}
+ if assignees:
+ params['assignees'] = assignees
+ data = json.dumps(params)
+ response = gh(GH_ISSUE_CREATION_URL, data)
+ issue_url = response['html_url']
+ print('Created issue {} for {}'.format(issue_url, title))
+
+
+def build_kokoro_url(job_name, build_id):
+ job_path = '{}/{}'.format('/job/'.join(job_name.split('/')), build_id)
+ return KOKORO_BASE_URL + job_path
+
+
+def create_issues(new_flakes, always_create):
+ for test_name, results_row in new_flakes.items():
+ poll_strategy, job_name, build_id, timestamp = results_row
+ # TODO(dgq): the Kokoro URL has a limited lifetime. The permanent and ideal
+ # URL would be the sponge one, but there's currently no easy way to retrieve
+ # it.
+ url = build_kokoro_url(job_name, build_id)
+ title = 'New Failure: ' + test_name
+ body = '- Test: {}\n- Poll Strategy: {}\n- URL: {}'.format(
+ test_name, poll_strategy, url)
+ labels = ['infra/New Failure']
+ if always_create:
+ proceed = True
+ else:
+ preexisting_issues = search_gh_issues(test_name)
+ if preexisting_issues['total_count'] > 0:
+ print('\nFound {} issues for "{}":'.format(
+ preexisting_issues['total_count'], test_name))
+ for issue in preexisting_issues['items']:
+ print('\t"{}" ; URL: {}'.format(issue['title'],
+ issue['html_url']))
+ else:
+ print(
+ '\nNo preexisting issues found for "{}"'.format(test_name))
+ proceed = raw_input(
+ 'Create issue for:\nTitle: {}\nBody: {}\n[Y/n] '.format(
+ title, body)) in ('y', 'Y', '')
+ if proceed:
+ assignees_str = raw_input(
+ 'Asignees? (comma-separated, leave blank for unassigned): ')
+ assignees = [
+ assignee.strip() for assignee in assignees_str.split(',')
+ ]
+ create_gh_issue(title, body, labels, assignees)
+
+
+def print_table(table, format):
+ first_time = True
+ for test_name, results_row in table.items():
+ poll_strategy, job_name, build_id, timestamp = results_row
+ full_kokoro_url = build_kokoro_url(job_name, build_id)
+ if format == 'human':
+ print("\t- Test: {}, Polling: {}, Timestamp: {}, url: {}".format(
+ test_name, poll_strategy, timestamp, full_kokoro_url))
+ else:
+ assert (format == 'csv')
+ if first_time:
+ print('test,timestamp,url')
+ first_time = False
+ print("{},{},{}".format(test_name, timestamp, full_kokoro_url))
+
+
+Row = namedtuple('Row', ['poll_strategy', 'job_name', 'build_id', 'timestamp'])
+
+
+def get_new_failures(dates):
+ bq = big_query_utils.create_big_query()
+ this_script_path = os.path.join(os.path.dirname(__file__))
+ sql_script = os.path.join(this_script_path, 'sql/new_failures_24h.sql')
+ with open(sql_script) as query_file:
+ query = query_file.read().format(
+ calibration_begin=dates['calibration']['begin'],
+ calibration_end=dates['calibration']['end'],
+ reporting_begin=dates['reporting']['begin'],
+ reporting_end=dates['reporting']['end'])
+ logging.debug("Query:\n%s", query)
+ query_job = big_query_utils.sync_query_job(bq, 'grpc-testing', query)
+ page = bq.jobs().getQueryResults(
+ pageToken=None, **query_job['jobReference']).execute(num_retries=3)
+ rows = page.get('rows')
+ if rows:
+ return {
+ row['f'][0]['v']: Row(
+ poll_strategy=row['f'][1]['v'],
+ job_name=row['f'][2]['v'],
+ build_id=row['f'][3]['v'],
+ timestamp=row['f'][4]['v'])
+ for row in rows
+ }
+ else:
+ return {}
+
+
+def parse_isodate(date_str):
+ return datetime.datetime.strptime(date_str, "%Y-%m-%d").date()
+
+
+def get_new_flakes(args):
+ """The from_date_str argument marks the beginning of the "calibration", used
+ to establish the set of pre-existing flakes, which extends over
+ "calibration_days". After the calibration period, "reporting_days" is the
+ length of time during which new flakes will be reported.
+
+from
+date
+ |--------------------|---------------|
+ ^____________________^_______________^
+ calibration reporting
+ days days
+ """
+ dates = process_date_args(args)
+ new_failures = get_new_failures(dates)
+ logging.info('|new failures| = %d', len(new_failures))
+ return new_failures
+
+
+def build_args_parser():
+ import argparse, datetime
+ parser = argparse.ArgumentParser()
+ today = datetime.date.today()
+ a_week_ago = today - datetime.timedelta(days=7)
+ parser.add_argument(
+ '--calibration_days',
+ type=int,
+ default=7,
+ help='How many days to consider for pre-existing flakes.')
+ parser.add_argument(
+ '--reporting_days',
+ type=int,
+ default=1,
+ help='How many days to consider for the detection of new flakes.')
+ parser.add_argument(
+ '--count_only',
+ dest='count_only',
+ action='store_true',
+ help='Display only number of new flakes.')
+ parser.set_defaults(count_only=False)
+ parser.add_argument(
+ '--create_issues',
+ dest='create_issues',
+ action='store_true',
+ help='Create issues for all new flakes.')
+ parser.set_defaults(create_issues=False)
+ parser.add_argument(
+ '--always_create_issues',
+ dest='always_create_issues',
+ action='store_true',
+ help='Always create issues for all new flakes. Otherwise,'
+ ' interactively prompt for every issue.')
+ parser.set_defaults(always_create_issues=False)
+ parser.add_argument(
+ '--token',
+ type=str,
+ default='',
+ help='GitHub token to use its API with a higher rate limit')
+ parser.add_argument(
+ '--format',
+ type=str,
+ choices=['human', 'csv'],
+ default='human',
+ help='Output format: are you a human or a machine?')
+ parser.add_argument(
+ '--loglevel',
+ type=str,
+ choices=['INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'],
+ default='WARNING',
+ help='Logging level.')
+ return parser
+
+
+def process_date_args(args):
+ calibration_begin = (
+ datetime.date.today() - datetime.timedelta(days=args.calibration_days) -
+ datetime.timedelta(days=args.reporting_days))
+ calibration_end = calibration_begin + datetime.timedelta(
+ days=args.calibration_days)
+ reporting_begin = calibration_end
+ reporting_end = reporting_begin + datetime.timedelta(
+ days=args.reporting_days)
+ return {
+ 'calibration': {
+ 'begin': calibration_begin,
+ 'end': calibration_end
+ },
+ 'reporting': {
+ 'begin': reporting_begin,
+ 'end': reporting_end
+ }
+ }
+
+
+def main():
+ global TOKEN
+ args_parser = build_args_parser()
+ args = args_parser.parse_args()
+ if args.create_issues and not args.token:
+ raise ValueError(
+ 'Missing --token argument, needed to create GitHub issues')
+ TOKEN = args.token
+
+ logging_level = getattr(logging, args.loglevel)
+ logging.basicConfig(format='%(asctime)s %(message)s', level=logging_level)
+ new_flakes = get_new_flakes(args)
+
+ dates = process_date_args(args)
+
+ dates_info_string = 'from {} until {} (calibrated from {} until {})'.format(
+ dates['reporting']['begin'].isoformat(),
+ dates['reporting']['end'].isoformat(),
+ dates['calibration']['begin'].isoformat(),
+ dates['calibration']['end'].isoformat())
+
+ if args.format == 'human':
+ if args.count_only:
+ print(len(new_flakes), dates_info_string)
+ elif new_flakes:
+ found_msg = 'Found {} new flakes {}'.format(
+ len(new_flakes), dates_info_string)
+ print(found_msg)
+ print('*' * len(found_msg))
+ print_table(new_flakes, 'human')
+ if args.create_issues:
+ create_issues(new_flakes, args.always_create_issues)
+ else:
+ print('No new flakes found '.format(len(new_flakes)),
+ dates_info_string)
+ elif args.format == 'csv':
+ if args.count_only:
+ print('from_date,to_date,count')
+ print('{},{},{}'.format(dates['reporting']['begin'].isoformat(),
+ dates['reporting']['end'].isoformat(),
+ len(new_flakes)))
+ else:
+ print_table(new_flakes, 'csv')
+ else:
+ raise ValueError('Invalid argument for --format: {}'.format(
+ args.format))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/failures/sql/new_failures_24h.sql b/tools/failures/sql/new_failures_24h.sql
new file mode 100644
index 0000000000..6ce0c5ddc5
--- /dev/null
+++ b/tools/failures/sql/new_failures_24h.sql
@@ -0,0 +1,62 @@
+#standardSQL
+WITH calibration AS (
+ SELECT
+ RTRIM(LTRIM(REGEXP_REPLACE(filtered_test_name, r'(/\d+)|(bins/.+/)|(cmake/.+/.+/)', ''))) AS test_binary,
+ REGEXP_EXTRACT(test_name, r'GRPC_POLL_STRATEGY=(\w+)') AS poll_strategy,
+ job_name,
+ build_id
+ FROM (
+ SELECT
+ REGEXP_REPLACE(test_name, r'(/\d+)|(GRPC_POLL_STRATEGY=.+)', '') AS filtered_test_name,
+ test_name,
+ job_name,
+ build_id,
+ timestamp
+ FROM
+ `grpc-testing.jenkins_test_results.aggregate_results`
+ WHERE
+ timestamp > TIMESTAMP(DATETIME("{calibration_begin} 00:00:00", "America/Los_Angeles"))
+ AND timestamp <= TIMESTAMP(DATETIME("{calibration_end} 23:59:59", "America/Los_Angeles"))
+ AND NOT REGEXP_CONTAINS(job_name,
+ 'portability')
+ AND result != 'PASSED'
+ AND result != 'SKIPPED' )),
+ reporting AS (
+ SELECT
+ RTRIM(LTRIM(REGEXP_REPLACE(filtered_test_name, r'(/\d+)|(bins/.+/)|(cmake/.+/.+/)', ''))) AS test_binary,
+ REGEXP_EXTRACT(test_name, r'GRPC_POLL_STRATEGY=(\w+)') AS poll_strategy,
+ job_name,
+ build_id,
+ timestamp
+ FROM (
+ SELECT
+ REGEXP_REPLACE(test_name, r'(/\d+)|(GRPC_POLL_STRATEGY=.+)', '') AS filtered_test_name,
+ test_name,
+ job_name,
+ build_id,
+ timestamp
+ FROM
+ `grpc-testing.jenkins_test_results.aggregate_results`
+ WHERE
+ timestamp > TIMESTAMP(DATETIME("{reporting_begin} 00:00:00", "America/Los_Angeles"))
+ AND timestamp <= TIMESTAMP(DATETIME("{reporting_end} 23:59:59", "America/Los_Angeles"))
+ AND NOT REGEXP_CONTAINS(job_name,
+ 'portability')
+ AND result != 'PASSED'
+ AND result != 'SKIPPED' ))
+SELECT
+ reporting.test_binary,
+ reporting.poll_strategy,
+ reporting.job_name,
+ reporting.build_id,
+ STRING(reporting.timestamp, "America/Los_Angeles") as timestamp_MTV
+FROM
+ reporting
+LEFT JOIN
+ calibration
+ON
+ reporting.test_binary = calibration.test_binary
+WHERE
+ calibration.test_binary IS NULL
+ORDER BY
+ timestamp DESC;
diff --git a/tools/flakes/detect_flakes.py b/tools/flakes/detect_flakes.py
deleted file mode 100644
index c5c7f61771..0000000000
--- a/tools/flakes/detect_flakes.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-# 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.
-
-"""Detect new flakes introduced in the last 24h hours with respect to the
-previous six days"""
-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-import datetime
-import os
-import sys
-import logging
-logging.basicConfig(format='%(asctime)s %(message)s')
-
-gcp_utils_dir = os.path.abspath(
- os.path.join(os.path.dirname(__file__), '../gcp/utils'))
-sys.path.append(gcp_utils_dir)
-
-import big_query_utils
-
-def print_table(table):
- kokoro_base_url = 'https://kokoro.corp.google.com/job/'
- for k, v in table.items():
- job_name = v[0]
- build_id = v[1]
- ts = int(float(v[2]))
- # TODO(dgq): timezone handling is wrong. We need to determine the timezone
- # of the computer running this script.
- human_ts = datetime.datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S PDT')
- job_path = '{}/{}'.format('/job/'.join(job_name.split('/')), build_id)
- full_kokoro_url = kokoro_base_url + job_path
- print("Test: {}, Timestamp: {}, url: {}\n".format(k, human_ts, full_kokoro_url))
-
-
-def get_flaky_tests(days_lower_bound, days_upper_bound, limit=None):
- """ period is one of "WEEK", "DAY", etc.
- (see https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#date_add). """
-
- bq = big_query_utils.create_big_query()
- query = """
-SELECT
- REGEXP_REPLACE(test_name, r'/\d+', '') AS filtered_test_name,
- job_name,
- build_id,
- timestamp
-FROM
- [grpc-testing:jenkins_test_results.aggregate_results]
-WHERE
- timestamp > DATE_ADD(CURRENT_DATE(), {days_lower_bound}, "DAY")
- AND timestamp <= DATE_ADD(CURRENT_DATE(), {days_upper_bound}, "DAY")
- AND NOT REGEXP_MATCH(job_name, '.*portability.*')
- AND result != 'PASSED' AND result != 'SKIPPED'
-ORDER BY timestamp desc
-""".format(days_lower_bound=days_lower_bound, days_upper_bound=days_upper_bound)
- if limit:
- query += '\n LIMIT {}'.format(limit)
- query_job = big_query_utils.sync_query_job(bq, 'grpc-testing', query)
- page = bq.jobs().getQueryResults(
- pageToken=None, **query_job['jobReference']).execute(num_retries=3)
- rows = page.get('rows')
- if rows:
- return {row['f'][0]['v']:
- (row['f'][1]['v'], row['f'][2]['v'], row['f'][3]['v'])
- for row in rows}
- else:
- return {}
-
-
-def get_new_flakes():
- last_week_sans_yesterday = get_flaky_tests(-14, -1)
- last_24 = get_flaky_tests(0, +1)
- last_week_sans_yesterday_names = set(last_week_sans_yesterday.keys())
- last_24_names = set(last_24.keys())
- logging.debug('|last_week_sans_yesterday| =', len(last_week_sans_yesterday_names))
- logging.debug('|last_24_names| =', len(last_24_names))
- new_flakes = last_24_names - last_week_sans_yesterday_names
- logging.debug('|new_flakes| = ', len(new_flakes))
- return {k: last_24[k] for k in new_flakes}
-
-
-def main():
- new_flakes = get_new_flakes()
- if new_flakes:
- print("Found {} new flakes:".format(len(new_flakes)))
- print_table(new_flakes)
- else:
- print("No new flakes found!")
-
-
-if __name__ == '__main__':
- main()
diff --git a/tools/gce/create_linux_kokoro_performance_worker.sh b/tools/gce/create_linux_kokoro_performance_worker.sh
new file mode 100755
index 0000000000..a25cc5b6a3
--- /dev/null
+++ b/tools/gce/create_linux_kokoro_performance_worker.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# 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.
+
+# Creates a performance worker on GCE to be used on Kokoro.
+
+set -ex
+
+cd $(dirname $0)
+
+CLOUD_PROJECT=grpc-testing
+ZONE=us-central1-b # this zone allows 32core machines
+
+INSTANCE_NAME="${1:-grpc-kokoro-performance-server1}"
+MACHINE_TYPE=n1-standard-32
+
+gcloud compute instances create $INSTANCE_NAME \
+ --project="$CLOUD_PROJECT" \
+ --zone "$ZONE" \
+ --machine-type $MACHINE_TYPE \
+ --image-project ubuntu-os-cloud \
+ --image-family ubuntu-1710 \
+ --boot-disk-size 300 \
+ --scopes https://www.googleapis.com/auth/bigquery \
+ --tags=allow-ssh
+
+echo 'Created GCE instance, waiting 60 seconds for it to come online.'
+sleep 60
+
+gcloud compute copy-files \
+ --project="$CLOUD_PROJECT" \
+ --zone "$ZONE" \
+ kokoro_performance.pub linux_kokoro_performance_worker_init.sh kbuilder@${INSTANCE_NAME}:~
+
+gcloud compute ssh \
+ --project="$CLOUD_PROJECT" \
+ --zone "$ZONE" \
+ kbuilder@${INSTANCE_NAME} --command "./linux_kokoro_performance_worker_init.sh"
diff --git a/tools/gce/create_linux_performance_worker.sh b/tools/gce/create_linux_performance_worker.sh
index 4270f5cbfb..e3bc1d577d 100755
--- a/tools/gce/create_linux_performance_worker.sh
+++ b/tools/gce/create_linux_performance_worker.sh
@@ -34,7 +34,7 @@ gcloud compute instances create $INSTANCE_NAME \
--zone "$ZONE" \
--machine-type $MACHINE_TYPE \
--image-project ubuntu-os-cloud \
- --image-family ubuntu-1704 \
+ --image-family ubuntu-1710 \
--boot-disk-size 300 \
--scopes https://www.googleapis.com/auth/bigquery \
--tags=allow-ssh
diff --git a/tools/gce/create_windows_debug_worker.sh b/tools/gce/create_windows_debug_worker.sh
new file mode 100755
index 0000000000..da8050be4b
--- /dev/null
+++ b/tools/gce/create_windows_debug_worker.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+# 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.
+
+# Creates a worker for debugging/experiments.
+# The worker will have all the prerequisites that are installed on kokoro
+# windows workers.
+
+set -ex
+
+cd $(dirname $0)
+
+CLOUD_PROJECT=grpc-testing
+ZONE=us-central1-b
+
+if [ "$1" != "" ]
+then
+ INSTANCE_NAME="$1"
+else
+ INSTANCE_NAME="${USER}-windows-kokoro-debug1"
+fi
+
+MACHINE_TYPE=n1-standard-8
+TMP_DISK_NAME="$INSTANCE_NAME-temp-disk"
+
+gcloud compute disks create $TMP_DISK_NAME \
+ --project="$CLOUD_PROJECT" \
+ --zone "$ZONE" \
+ --image-project google.com:kokoro \
+ --image empty-100g-image \
+ --type pd-ssd
+
+echo 'Created scratch disk, waiting for it to become available.'
+sleep 15
+
+gcloud compute instances create $INSTANCE_NAME \
+ --project="$CLOUD_PROJECT" \
+ --zone "$ZONE" \
+ --machine-type $MACHINE_TYPE \
+ --image-project google.com:kokoro \
+ --image kokoro-win7build-v9-prod-debug \
+ --boot-disk-size 500 \
+ --boot-disk-type pd-ssd \
+ --tags=allow-ssh \
+ --disk auto-delete=yes,boot=no,name=$TMP_DISK_NAME
diff --git a/tools/gce/kokoro_performance.pub b/tools/gce/kokoro_performance.pub
new file mode 100644
index 0000000000..1154debe78
--- /dev/null
+++ b/tools/gce/kokoro_performance.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKQ5UEX4AFefec9BKICupFS7x9Hoq4ZyLKy+QX0J31I49ew9mG2AJlr3sp8ql15eX+A2Ml9MKJkmgZGHpJtw+SfvmI94SmomSyiCLAK92sQ85NMzaRdo4b9e30E9nhXnAvAaemvIEQbgCMYFvzk0C8AtXj6+htCrN4jFaLqTCPISJhX3ETc4TgX1qaHQHyl31tdaXHYlITvBDsfokcGcZQnhmCUDtD8wyaSC8GFk9gZbXshkfaYCuuLPPA0vwWGBw+YPbonHsFCsOog1IYSzYPCkIjq8dt6evsusK6Kaoyw/Z+l2kYty2FKTj+wU3l06QMoxwcfNT4WxdhcnVbY71r kbuilder@kokoro-performance-driver
diff --git a/tools/gce/linux_kokoro_performance_worker_init.sh b/tools/gce/linux_kokoro_performance_worker_init.sh
new file mode 100755
index 0000000000..460f639f9f
--- /dev/null
+++ b/tools/gce/linux_kokoro_performance_worker_init.sh
@@ -0,0 +1,194 @@
+#!/bin/bash
+# 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.
+
+# Initializes a fresh GCE VM to become a Kokoro Linux performance worker.
+# You shouldn't run this script on your own,
+# use create_linux_kokoro_performance_worker.sh instead.
+
+set -ex
+
+sudo apt-get update
+
+# Install Java 8 JDK (to build gRPC Java)
+sudo apt-get install -y openjdk-8-jdk
+sudo apt-get install -y unzip lsof
+
+sudo apt-get install -y \
+ autoconf \
+ autotools-dev \
+ build-essential \
+ bzip2 \
+ ccache \
+ curl \
+ gcc \
+ gcc-multilib \
+ git \
+ gyp \
+ lcov \
+ libc6 \
+ libc6-dbg \
+ libc6-dev \
+ libcurl4-openssl-dev \
+ libgtest-dev \
+ libreadline-dev \
+ libssl-dev \
+ libtool \
+ make \
+ strace \
+ pypy \
+ python-dev \
+ python-pip \
+ python-setuptools \
+ python-yaml \
+ python3-dev \
+ python3-pip \
+ python3-setuptools \
+ python3-yaml \
+ telnet \
+ unzip \
+ wget \
+ zip \
+ zlib1g-dev
+
+# perftools
+sudo apt-get install -y google-perftools libgoogle-perftools-dev
+
+# netperf
+sudo apt-get install -y netperf
+
+# C++ dependencies
+sudo apt-get install -y libgflags-dev libgtest-dev libc++-dev clang
+
+# Python dependencies
+sudo pip install --upgrade pip==9.0.1
+sudo pip install tabulate
+sudo pip install google-api-python-client
+sudo pip install virtualenv
+
+# Building gRPC Python depends on python3.4 being installed, but python3.4
+# is not available on Ubuntu 16.10, so install from source
+curl -O https://www.python.org/ftp/python/3.4.6/Python-3.4.6.tgz
+tar xzvf Python-3.4.6.tgz
+cd Python-3.4.6
+./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"
+sudo make altinstall
+cd ..
+rm Python-3.4.6.tgz
+
+curl -O https://bootstrap.pypa.io/get-pip.py
+sudo pypy get-pip.py
+sudo pypy -m pip install tabulate
+sudo pip install google-api-python-client
+
+# Node dependencies (nvm has to be installed under user kbuilder)
+touch .profile
+curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
+source ~/.nvm/nvm.sh
+nvm install 0.12 && npm config set cache /tmp/npm-cache
+nvm install 4 && npm config set cache /tmp/npm-cache
+nvm install 5 && npm config set cache /tmp/npm-cache
+nvm alias default 4
+
+# C# mono dependencies (http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives)
+sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
+sudo apt-get update
+sudo apt-get install -y mono-devel nuget
+
+# C# .NET Core dependencies (https://www.microsoft.com/net/core#ubuntu)
+sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ yakkety main" > /etc/apt/sources.list.d/dotnetdev.list'
+sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
+sudo apt-get update
+sudo apt-get install -y dotnet-dev-1.0.0-preview2.1-003155
+sudo apt-get install -y dotnet-dev-1.0.1
+
+# C# 1.0.4 SDK
+curl -O https://download.microsoft.com/download/2/4/A/24A06858-E8AC-469B-8AE6-D0CEC9BA982A/dotnet-ubuntu.16.04-x64.1.0.5.tar.gz
+sudo mkdir -p /opt/dotnet
+sudo tar zxf dotnet-ubuntu.16.04-x64.1.0.5.tar.gz -C /opt/dotnet
+sudo ln -s /opt/dotnet/dotnet /usr/local/bin
+
+# C# .NET dependencies
+wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu52_52.1-8ubuntu0.2_amd64.deb
+sudo dpkg -i libicu52_52.1-8ubuntu0.2_amd64.deb
+wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.3_amd64.deb
+sudo dpkg -i libicu55_55.1-7ubuntu0.3_amd64.deb
+sudo apt-get update && sudo apt-get install -y libicu55
+
+# Ruby dependencies
+gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+curl -sSL https://get.rvm.io | bash -s stable --ruby
+source ~/.rvm/scripts/rvm
+
+git clone https://github.com/rbenv/rbenv.git ~/.rbenv
+export PATH="$HOME/.rbenv/bin:$PATH"
+eval "$(rbenv init -)"
+
+git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
+export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
+
+rbenv install 2.4.0
+rbenv global 2.4.0
+ruby -v
+
+# Install bundler (prerequisite for gRPC Ruby)
+gem install bundler
+
+# PHP dependencies
+sudo apt-get install -y php php-dev phpunit php-pear unzip zlib1g-dev
+curl -sS https://getcomposer.org/installer | php
+sudo mv composer.phar /usr/local/bin/composer
+
+# Java dependencies - nothing as we already have Java JDK 8
+
+# Go dependencies
+# Currently, the golang package available via apt-get doesn't have the latest go.
+# Significant performance improvements with grpc-go have been observed after
+# upgrading from go 1.5 to a later version, so a later go version is preferred.
+# Following go install instructions from https://golang.org/doc/install
+GO_VERSION=1.8
+OS=linux
+ARCH=amd64
+curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.${OS}-${ARCH}.tar.gz
+sudo tar -C /usr/local -xzf go$GO_VERSION.$OS-$ARCH.tar.gz
+# Put go on the PATH, keep the usual installation dir
+sudo ln -s /usr/local/go/bin/go /usr/bin/go
+rm go$GO_VERSION.$OS-$ARCH.tar.gz
+
+# Install perf, to profile benchmarks. (need to get the right linux-tools-<> for kernel version)
+sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r`
+# see http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar
+echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
+# see http://stackoverflow.com/questions/21284906/perf-couldnt-record-kernel-reference-relocation-symbol
+echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
+
+# qps workers under perf appear to need a lot of mmap pages under certain scenarios and perf args in
+# order to not lose perf events or time out
+echo 4096 | sudo tee /proc/sys/kernel/perf_event_mlock_kb
+
+# Fetch scripts to generate flame graphs from perf data collected
+# on benchmarks
+git clone -v https://github.com/brendangregg/FlameGraph ~/FlameGraph
+
+# Install scipy and numpy for benchmarking scripts
+sudo apt-get install -y python-scipy python-numpy
+
+# Add pubkey of Kokoro driver VM to allow SSH
+cat kokoro_performance.pub | sudo tee --append ~kbuilder/.ssh/authorized_keys
+
+# Restart for VM to pick up kernel update
+echo 'Successfully initialized the linux worker, going for reboot in 10 seconds'
+sleep 10
+sudo reboot
diff --git a/tools/gce/linux_performance_worker_init.sh b/tools/gce/linux_performance_worker_init.sh
index 88d8de7402..8d900f1d16 100755
--- a/tools/gce/linux_performance_worker_init.sh
+++ b/tools/gce/linux_performance_worker_init.sh
@@ -72,6 +72,7 @@ sudo apt-get install -y netperf
sudo apt-get install -y libgflags-dev libgtest-dev libc++-dev clang
# Python dependencies
+sudo pip install --upgrade pip==9.0.1
sudo pip install tabulate
sudo pip install google-api-python-client
sudo pip install virtualenv
diff --git a/tools/gcp/utils/big_query_utils.py b/tools/gcp/utils/big_query_utils.py
index 77a5f5691e..3e811ca2bf 100755
--- a/tools/gcp/utils/big_query_utils.py
+++ b/tools/gcp/utils/big_query_utils.py
@@ -28,154 +28,174 @@ NUM_RETRIES = 3
def create_big_query():
- """Authenticates with cloud platform and gets a BiqQuery service object
+ """Authenticates with cloud platform and gets a BiqQuery service object
"""
- creds = GoogleCredentials.get_application_default()
- return discovery.build('bigquery', 'v2', credentials=creds, cache_discovery=False)
+ creds = GoogleCredentials.get_application_default()
+ return discovery.build(
+ 'bigquery', 'v2', credentials=creds, cache_discovery=False)
def create_dataset(biq_query, project_id, dataset_id):
- is_success = True
- body = {
- 'datasetReference': {
- 'projectId': project_id,
- 'datasetId': dataset_id
- }
- }
-
- try:
- dataset_req = biq_query.datasets().insert(projectId=project_id, body=body)
- dataset_req.execute(num_retries=NUM_RETRIES)
- except HttpError as http_error:
- if http_error.resp.status == 409:
- print 'Warning: The dataset %s already exists' % dataset_id
- else:
- # Note: For more debugging info, print "http_error.content"
- print 'Error in creating dataset: %s. Err: %s' % (dataset_id, http_error)
- is_success = False
- return is_success
+ is_success = True
+ body = {
+ 'datasetReference': {
+ 'projectId': project_id,
+ 'datasetId': dataset_id
+ }
+ }
+
+ try:
+ dataset_req = biq_query.datasets().insert(
+ projectId=project_id, body=body)
+ dataset_req.execute(num_retries=NUM_RETRIES)
+ except HttpError as http_error:
+ if http_error.resp.status == 409:
+ print 'Warning: The dataset %s already exists' % dataset_id
+ else:
+ # Note: For more debugging info, print "http_error.content"
+ print 'Error in creating dataset: %s. Err: %s' % (dataset_id,
+ http_error)
+ is_success = False
+ return is_success
def create_table(big_query, project_id, dataset_id, table_id, table_schema,
description):
- fields = [{'name': field_name,
- 'type': field_type,
- 'description': field_description
- } for (field_name, field_type, field_description) in table_schema]
- return create_table2(big_query, project_id, dataset_id, table_id,
- fields, description)
-
-
-def create_partitioned_table(big_query, project_id, dataset_id, table_id, table_schema,
- description, partition_type='DAY', expiration_ms=_EXPIRATION_MS):
- """Creates a partitioned table. By default, a date-paritioned table is created with
+ fields = [{
+ 'name': field_name,
+ 'type': field_type,
+ 'description': field_description
+ } for (field_name, field_type, field_description) in table_schema]
+ return create_table2(big_query, project_id, dataset_id, table_id, fields,
+ description)
+
+
+def create_partitioned_table(big_query,
+ project_id,
+ dataset_id,
+ table_id,
+ table_schema,
+ description,
+ partition_type='DAY',
+ expiration_ms=_EXPIRATION_MS):
+ """Creates a partitioned table. By default, a date-paritioned table is created with
each partition lasting 30 days after it was last modified.
"""
- fields = [{'name': field_name,
- 'type': field_type,
- 'description': field_description
- } for (field_name, field_type, field_description) in table_schema]
- return create_table2(big_query, project_id, dataset_id, table_id,
- fields, description, partition_type, expiration_ms)
-
-
-def create_table2(big_query, project_id, dataset_id, table_id, fields_schema,
- description, partition_type=None, expiration_ms=None):
- is_success = True
-
- body = {
- 'description': description,
- 'schema': {
- 'fields': fields_schema
- },
- 'tableReference': {
- 'datasetId': dataset_id,
- 'projectId': project_id,
- 'tableId': table_id
- }
- }
-
- if partition_type and expiration_ms:
- body["timePartitioning"] = {
- "type": partition_type,
- "expirationMs": expiration_ms
+ fields = [{
+ 'name': field_name,
+ 'type': field_type,
+ 'description': field_description
+ } for (field_name, field_type, field_description) in table_schema]
+ return create_table2(big_query, project_id, dataset_id, table_id, fields,
+ description, partition_type, expiration_ms)
+
+
+def create_table2(big_query,
+ project_id,
+ dataset_id,
+ table_id,
+ fields_schema,
+ description,
+ partition_type=None,
+ expiration_ms=None):
+ is_success = True
+
+ body = {
+ 'description': description,
+ 'schema': {
+ 'fields': fields_schema
+ },
+ 'tableReference': {
+ 'datasetId': dataset_id,
+ 'projectId': project_id,
+ 'tableId': table_id
+ }
}
- try:
- table_req = big_query.tables().insert(projectId=project_id,
- datasetId=dataset_id,
- body=body)
- res = table_req.execute(num_retries=NUM_RETRIES)
- print 'Successfully created %s "%s"' % (res['kind'], res['id'])
- except HttpError as http_error:
- if http_error.resp.status == 409:
- print 'Warning: Table %s already exists' % table_id
- else:
- print 'Error in creating table: %s. Err: %s' % (table_id, http_error)
- is_success = False
- return is_success
+ if partition_type and expiration_ms:
+ body["timePartitioning"] = {
+ "type": partition_type,
+ "expirationMs": expiration_ms
+ }
+
+ try:
+ table_req = big_query.tables().insert(
+ projectId=project_id, datasetId=dataset_id, body=body)
+ res = table_req.execute(num_retries=NUM_RETRIES)
+ print 'Successfully created %s "%s"' % (res['kind'], res['id'])
+ except HttpError as http_error:
+ if http_error.resp.status == 409:
+ print 'Warning: Table %s already exists' % table_id
+ else:
+ print 'Error in creating table: %s. Err: %s' % (table_id,
+ http_error)
+ is_success = False
+ return is_success
def patch_table(big_query, project_id, dataset_id, table_id, fields_schema):
- is_success = True
-
- body = {
- 'schema': {
- 'fields': fields_schema
- },
- 'tableReference': {
- 'datasetId': dataset_id,
- 'projectId': project_id,
- 'tableId': table_id
- }
- }
-
- try:
- table_req = big_query.tables().patch(projectId=project_id,
- datasetId=dataset_id,
- tableId=table_id,
- body=body)
- res = table_req.execute(num_retries=NUM_RETRIES)
- print 'Successfully patched %s "%s"' % (res['kind'], res['id'])
- except HttpError as http_error:
- print 'Error in creating table: %s. Err: %s' % (table_id, http_error)
- is_success = False
- return is_success
+ is_success = True
+
+ body = {
+ 'schema': {
+ 'fields': fields_schema
+ },
+ 'tableReference': {
+ 'datasetId': dataset_id,
+ 'projectId': project_id,
+ 'tableId': table_id
+ }
+ }
+
+ try:
+ table_req = big_query.tables().patch(
+ projectId=project_id,
+ datasetId=dataset_id,
+ tableId=table_id,
+ body=body)
+ res = table_req.execute(num_retries=NUM_RETRIES)
+ print 'Successfully patched %s "%s"' % (res['kind'], res['id'])
+ except HttpError as http_error:
+ print 'Error in creating table: %s. Err: %s' % (table_id, http_error)
+ is_success = False
+ return is_success
def insert_rows(big_query, project_id, dataset_id, table_id, rows_list):
- is_success = True
- body = {'rows': rows_list}
- try:
- insert_req = big_query.tabledata().insertAll(projectId=project_id,
- datasetId=dataset_id,
- tableId=table_id,
- body=body)
- res = insert_req.execute(num_retries=NUM_RETRIES)
- if res.get('insertErrors', None):
- print 'Error inserting rows! Response: %s' % res
- is_success = False
- except HttpError as http_error:
- print 'Error inserting rows to the table %s' % table_id
- is_success = False
-
- return is_success
+ is_success = True
+ body = {'rows': rows_list}
+ try:
+ insert_req = big_query.tabledata().insertAll(
+ projectId=project_id,
+ datasetId=dataset_id,
+ tableId=table_id,
+ body=body)
+ res = insert_req.execute(num_retries=NUM_RETRIES)
+ if res.get('insertErrors', None):
+ print 'Error inserting rows! Response: %s' % res
+ is_success = False
+ except HttpError as http_error:
+ print 'Error inserting rows to the table %s' % table_id
+ is_success = False
+
+ return is_success
def sync_query_job(big_query, project_id, query, timeout=5000):
- query_data = {'query': query, 'timeoutMs': timeout}
- query_job = None
- try:
- query_job = big_query.jobs().query(
- projectId=project_id,
- body=query_data).execute(num_retries=NUM_RETRIES)
- except HttpError as http_error:
- print 'Query execute job failed with error: %s' % http_error
- print http_error.content
- return query_job
-
- # List of (column name, column type, description) tuples
+ query_data = {'query': query, 'timeoutMs': timeout}
+ query_job = None
+ try:
+ query_job = big_query.jobs().query(
+ projectId=project_id,
+ body=query_data).execute(num_retries=NUM_RETRIES)
+ except HttpError as http_error:
+ print 'Query execute job failed with error: %s' % http_error
+ print http_error.content
+ return query_job
+
+
+ # List of (column name, column type, description) tuples
def make_row(unique_row_id, row_values_dict):
- """row_values_dict is a dictionary of column name and column value.
+ """row_values_dict is a dictionary of column name and column value.
"""
- return {'insertId': unique_row_id, 'json': row_values_dict}
+ return {'insertId': unique_row_id, 'json': row_values_dict}
diff --git a/tools/github/pr_latency.py b/tools/github/pr_latency.py
new file mode 100644
index 0000000000..34870a5326
--- /dev/null
+++ b/tools/github/pr_latency.py
@@ -0,0 +1,203 @@
+#!/usr/bin/env python
+# 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.
+"""Measure the time between PR creation and completion of all tests.
+
+You'll need a github API token to avoid being rate-limited. See
+https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
+
+This script goes over the most recent 100 pull requests. For PRs with a single
+commit, it uses the PR's creation as the initial time; othewise, it uses the
+date of the last commit. This is somewhat fragile, and imposed by the fact that
+GitHub reports a PR's updated timestamp for any event that modifies the PR (e.g.
+comments), not just the addition of new commits.
+
+In addition, it ignores latencies greater than five hours, as that's likely due
+to a manual re-run of tests.
+"""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import json
+import logging
+import pprint
+import urllib2
+
+from datetime import datetime, timedelta
+
+logging.basicConfig(format='%(asctime)s %(message)s')
+
+PRS = 'https://api.github.com/repos/grpc/grpc/pulls?state=open&per_page=100'
+COMMITS = 'https://api.github.com/repos/grpc/grpc/pulls/{pr_number}/commits'
+
+
+def gh(url):
+ request = urllib2.Request(url)
+ if TOKEN:
+ request.add_header('Authorization', 'token {}'.format(TOKEN))
+ response = urllib2.urlopen(request)
+ return response.read()
+
+
+def print_csv_header():
+ print('pr,base_time,test_time,latency_seconds,successes,failures,errors')
+
+
+def output(pr,
+ base_time,
+ test_time,
+ diff_time,
+ successes,
+ failures,
+ errors,
+ mode='human'):
+ if mode == 'human':
+ print(
+ "PR #{} base time: {} UTC, Tests completed at: {} UTC. Latency: {}."
+ "\n\tSuccesses: {}, Failures: {}, Errors: {}".format(
+ pr, base_time, test_time, diff_time, successes, failures,
+ errors))
+ elif mode == 'csv':
+ print(','.join([
+ str(pr),
+ str(base_time),
+ str(test_time),
+ str(int((test_time - base_time).total_seconds())),
+ str(successes),
+ str(failures),
+ str(errors)
+ ]))
+
+
+def parse_timestamp(datetime_str):
+ return datetime.strptime(datetime_str, '%Y-%m-%dT%H:%M:%SZ')
+
+
+def to_posix_timestamp(dt):
+ return str((dt - datetime(1970, 1, 1)).total_seconds())
+
+
+def get_pr_data():
+ latest_prs = json.loads(gh(PRS))
+ res = [{
+ 'number': pr['number'],
+ 'created_at': parse_timestamp(pr['created_at']),
+ 'updated_at': parse_timestamp(pr['updated_at']),
+ 'statuses_url': pr['statuses_url']
+ } for pr in latest_prs]
+ return res
+
+
+def get_commits_data(pr_number):
+ commits = json.loads(gh(COMMITS.format(pr_number=pr_number)))
+ return {
+ 'num_commits': len(commits),
+ 'most_recent_date':
+ parse_timestamp(commits[-1]['commit']['author']['date'])
+ }
+
+
+def get_status_data(statuses_url, system):
+ status_url = statuses_url.replace('statuses', 'status')
+ statuses = json.loads(gh(status_url + '?per_page=100'))
+ successes = 0
+ failures = 0
+ errors = 0
+ latest_datetime = None
+ if not statuses: return None
+ if system == 'kokoro': string_in_target_url = 'kokoro'
+ elif system == 'jenkins': string_in_target_url = 'grpc-testing'
+ for status in statuses['statuses']:
+ if not status['target_url'] or string_in_target_url not in status['target_url']:
+ continue # Ignore jenkins
+ if status['state'] == 'pending': return None
+ elif status['state'] == 'success': successes += 1
+ elif status['state'] == 'failure': failures += 1
+ elif status['state'] == 'error': errors += 1
+ if not latest_datetime:
+ latest_datetime = parse_timestamp(status['updated_at'])
+ else:
+ latest_datetime = max(latest_datetime,
+ parse_timestamp(status['updated_at']))
+ # First status is the most recent one.
+ if any([successes, failures, errors
+ ]) and sum([successes, failures, errors]) > 15:
+ return {
+ 'latest_datetime': latest_datetime,
+ 'successes': successes,
+ 'failures': failures,
+ 'errors': errors
+ }
+ else:
+ return None
+
+
+def build_args_parser():
+ import argparse
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '--format',
+ type=str,
+ choices=['human', 'csv'],
+ default='human',
+ help='Output format: are you a human or a machine?')
+ parser.add_argument(
+ '--system',
+ type=str,
+ choices=['jenkins', 'kokoro'],
+ required=True,
+ help='Consider only the given CI system')
+ parser.add_argument(
+ '--token',
+ type=str,
+ default='',
+ help='GitHub token to use its API with a higher rate limit')
+ return parser
+
+
+def main():
+ import sys
+ global TOKEN
+ args_parser = build_args_parser()
+ args = args_parser.parse_args()
+ TOKEN = args.token
+ if args.format == 'csv': print_csv_header()
+ for pr_data in get_pr_data():
+ commit_data = get_commits_data(pr_data['number'])
+ # PR with a single commit -> use the PRs creation time.
+ # else -> use the latest commit's date.
+ base_timestamp = pr_data['updated_at']
+ if commit_data['num_commits'] > 1:
+ base_timestamp = commit_data['most_recent_date']
+ else:
+ base_timestamp = pr_data['created_at']
+ last_status = get_status_data(pr_data['statuses_url'], args.system)
+ if last_status:
+ diff = last_status['latest_datetime'] - base_timestamp
+ if diff < timedelta(hours=5):
+ output(
+ pr_data['number'],
+ base_timestamp,
+ last_status['latest_datetime'],
+ diff,
+ last_status['successes'],
+ last_status['failures'],
+ last_status['errors'],
+ mode=args.format)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/internal_ci/helper_scripts/gen_report_index.sh b/tools/internal_ci/helper_scripts/gen_report_index.sh
index 0af89c331c..576ff67d54 100755
--- a/tools/internal_ci/helper_scripts/gen_report_index.sh
+++ b/tools/internal_ci/helper_scripts/gen_report_index.sh
@@ -26,7 +26,7 @@ mkdir -p reports
echo '<html><head></head><body>' > reports/kokoro_index.html
echo '<h1>'${KOKORO_JOB_NAME}', build '#${KOKORO_BUILD_NUMBER}'</h1>' >> reports/kokoro_index.html
-echo '<h2><a href="https://kokoro.corp.google.com/job/'${KOKORO_JOB_PATH}'/'${KOKORO_BUILD_NUMBER}'/">Kokoro build dashboard (internal only)</a></h2>' >> reports/kokoro_index.html
+echo '<h2><a href="https://kokoro2.corp.google.com/job/'${KOKORO_JOB_PATH}'/'${KOKORO_BUILD_NUMBER}'/">Kokoro build dashboard (internal only)</a></h2>' >> reports/kokoro_index.html
echo '<h2><a href="https://sponge.corp.google.com/invocation?id='${KOKORO_BUILD_ID}'&searchFor=">Test result dashboard (internal only)</a></h2>' >> reports/kokoro_index.html
echo '<h2><a href="test_report.html">HTML test report (Not available yet)</a></h2>' >> reports/kokoro_index.html
echo '<h2><a href="test_log.txt">Test log (Not available yet)</a></h2>' >> reports/kokoro_index.html
diff --git a/tools/internal_ci/helper_scripts/prepare_build_interop_rc b/tools/internal_ci/helper_scripts/prepare_build_interop_rc
index 859ce621f9..db978c8b3f 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_interop_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_interop_rc
@@ -26,6 +26,7 @@ git submodule update --init
# Set up gRPC-Go and gRPC-Java to test
git clone --recursive https://github.com/grpc/grpc-go ./../grpc-go
git clone --recursive https://github.com/grpc/grpc-java ./../grpc-java
+git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node
# Download json file.
mkdir ~/service_account
diff --git a/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc b/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc
new file mode 100644
index 0000000000..f1031aedf3
--- /dev/null
+++ b/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc
@@ -0,0 +1,40 @@
+#!/bin/bash
+# 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.
+
+# Source this rc script to prepare the environment for linux perf builds
+
+# Need to increase open files limit and size for perf test
+ulimit -n 32768
+ulimit -c unlimited
+
+# Download non-core gRPC repos
+git clone --recursive https://github.com/grpc/grpc-go ./../grpc-go
+git clone --recursive https://github.com/grpc/grpc-java ./../grpc-java
+git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node
+
+sudo pip install tabulate
+
+# Set up Ruby
+export PATH="$HOME/.rbenv/bin:$PATH"
+eval "$(rbenv init -)"
+gem list bundler
+gem install bundler --no-ri --no-rdoc
+
+# Allow SSH to Kokoro performance workers without explicit key verification
+gsutil cp gs://grpc-testing-secrets/grpc_kokoro_performance_ssh_keys/id_rsa ~/.ssh
+echo -e 'Host grpc-kokoro-performance*\n\tStrictHostKeyChecking no' >> ~/.ssh/config
+chmod 600 ~/.ssh/id_rsa ~/.ssh/config
+
+git submodule update --init
diff --git a/tools/internal_ci/helper_scripts/prepare_build_linux_rc b/tools/internal_ci/helper_scripts/prepare_build_linux_rc
index 2ade8dac51..8715d6c8e0 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_linux_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_linux_rc
@@ -22,6 +22,9 @@ ulimit -n 32768
# Move docker's storage location to scratch disk so we don't run out of space.
echo 'DOCKER_OPTS="${DOCKER_OPTS} --graph=/tmpfs/docker"' | sudo tee --append /etc/default/docker
+# Use container registry mirror for pulling docker images (should make downloads faster)
+# See https://cloud.google.com/container-registry/docs/using-dockerhub-mirroring
+echo 'DOCKER_OPTS="${DOCKER_OPTS} --registry-mirror=https://mirror.gcr.io"' | sudo tee --append /etc/default/docker
sudo service docker restart
# Populate xdg-cache-home to workaround https://github.com/grpc/grpc/issues/11968
@@ -32,11 +35,4 @@ PYTHONWARNINGS=ignore XDG_CACHE_HOME=/tmp/xdg-cache-home sudo -E pip install cov
# Download Docker images from DockerHub
export DOCKERHUB_ORGANIZATION=grpctesting
-# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
-if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then
- sudo apt-get install -y jq
- ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
- export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch"
-fi
-
git submodule update --init
diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_interop_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_interop_rc
index f467ac006a..6ecf51dd3f 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_macos_interop_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_macos_interop_rc
@@ -25,11 +25,13 @@ cp -R ./ /Users/kbuilder/workspace/grpc
cd /Users/kbuilder/workspace/grpc
# Needed for identifying Docker image sha1
+brew update
brew install md5sha1sum
# Set up gRPC-Go and gRPC-Java to test
git clone --recursive https://github.com/grpc/grpc-go ./../grpc-go
git clone --recursive https://github.com/grpc/grpc-java ./../grpc-java
+git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node
# Set up Docker for Mac
docker-machine create -d virtualbox --virtualbox-share-folder "/Users/kbuilder/workspace:" default
diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc
index bec529f85e..3a09701a30 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc
@@ -27,12 +27,21 @@ ulimit -n 10000
# show current limits
ulimit -a
+# synchronize the clock
+date
+sudo systemsetup -setusingnetworktime off
+sudo systemsetup -setnetworktimeserver "$( ipconfig getoption en0 server_identifier )"
+sudo systemsetup -settimezone America/Los_Angeles
+sudo systemsetup -setusingnetworktime on
+date
+
# Add GCP credentials for BQ access
pip install google-api-python-client --user python
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json
# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then
+ brew update
brew install jq
ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch"
@@ -41,7 +50,11 @@ fi
set +ex # rvm script is very verbose and exits with errorcode
source $HOME/.rvm/scripts/rvm
set -e # rvm commands are very verbose
-rvm use ruby-2.4
+time rvm install 2.5.0
+rvm use 2.5.0 --default
+gem install bundler --no-ri --no-doc
+gem install cocoapods --version 1.3.1 --no-ri --no-doc
+gem install rake-compiler --no-ri --no-doc
rvm osx-ssl-certs status all
rvm osx-ssl-certs update all
set -ex
@@ -51,12 +64,14 @@ export LANG=en_US.UTF-8
pod repo update # needed by python
# python
-brew install coreutils # we need grealpath
pip install virtualenv --user python
-pip install -U six tox setuptools twisted pyyaml --user python
+pip install -U Mako six tox setuptools twisted pyyaml --user python
export PYTHONPATH=/Library/Python/3.4/site-packages
# set xcode version for Obj-C tests
sudo xcode-select -switch /Applications/Xcode_8.2.1.app/Contents/Developer
+# TODO(jtattermusch): better debugging of clock skew, remove once not needed
+date
+
git submodule update --init
diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry_dbg.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry_dbg.sh
new file mode 100644
index 0000000000..57699c62e7
--- /dev/null
+++ b/tools/internal_ci/linux/grpc_bazel_on_foundry_dbg.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+# 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.
+
+set -ex
+
+# A temporary solution to give Kokoro credentials.
+# The file name 4321_grpc-testing-service needs to match auth_credential in
+# the build config.
+mkdir -p ${KOKORO_KEYSTORE_DIR}
+cp ${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json ${KOKORO_KEYSTORE_DIR}/4321_grpc-testing-service
+
+mkdir -p /tmpfs/tmp/bazel-canary
+ln -f "${KOKORO_GFILE_DIR}/bazel-canary" /tmpfs/tmp/bazel-canary/bazel
+chmod 755 "${KOKORO_GFILE_DIR}/bazel-canary"
+export PATH="/tmpfs/tmp/bazel-canary:${PATH}"
+# This should show /tmpfs/tmp/bazel-canary/bazel
+which bazel
+chmod +x "${KOKORO_GFILE_DIR}/bazel_wrapper.py"
+
+# change to grpc repo root
+cd $(dirname $0)/../../..
+
+source tools/internal_ci/helper_scripts/prepare_build_linux_rc
+
+"${KOKORO_GFILE_DIR}/bazel_wrapper.py" \
+ --host_jvm_args=-Dbazel.DigestFunction=SHA256 \
+ test --jobs="50" \
+ --test_timeout="300,450,1200,3600" \
+ --test_output=errors \
+ --verbose_failures=true \
+ --keep_going \
+ --remote_accept_cached=true \
+ --spawn_strategy=remote \
+ --remote_local_fallback=false \
+ --remote_timeout=3600 \
+ --strategy=Javac=remote \
+ --strategy=Closure=remote \
+ --genrule_strategy=remote \
+ --experimental_strict_action_env=true \
+ --experimental_remote_platform_override='properties:{name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:496193842f61c9494be68bd624e47c74d706cabf19a693c4653ffe96a97e43e3" }' \
+ --crosstool_top=@com_github_bazelbuild_bazeltoolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \
+ --define GRPC_PORT_ISOLATED_RUNTIME=1 \
+ -c dbg \
+ -- //test/...
diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry_opt.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry_opt.sh
new file mode 100644
index 0000000000..1c635c839a
--- /dev/null
+++ b/tools/internal_ci/linux/grpc_bazel_on_foundry_opt.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+# 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.
+
+set -ex
+
+# A temporary solution to give Kokoro credentials.
+# The file name 4321_grpc-testing-service needs to match auth_credential in
+# the build config.
+mkdir -p ${KOKORO_KEYSTORE_DIR}
+cp ${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json ${KOKORO_KEYSTORE_DIR}/4321_grpc-testing-service
+
+mkdir -p /tmpfs/tmp/bazel-canary
+ln -f "${KOKORO_GFILE_DIR}/bazel-canary" /tmpfs/tmp/bazel-canary/bazel
+chmod 755 "${KOKORO_GFILE_DIR}/bazel-canary"
+export PATH="/tmpfs/tmp/bazel-canary:${PATH}"
+# This should show /tmpfs/tmp/bazel-canary/bazel
+which bazel
+chmod +x "${KOKORO_GFILE_DIR}/bazel_wrapper.py"
+
+# change to grpc repo root
+cd $(dirname $0)/../../..
+
+source tools/internal_ci/helper_scripts/prepare_build_linux_rc
+
+"${KOKORO_GFILE_DIR}/bazel_wrapper.py" \
+ --host_jvm_args=-Dbazel.DigestFunction=SHA256 \
+ test --jobs="50" \
+ --test_timeout="300,450,1200,3600" \
+ --test_output=errors \
+ --verbose_failures=true \
+ --keep_going \
+ --remote_accept_cached=true \
+ --spawn_strategy=remote \
+ --remote_local_fallback=false \
+ --remote_timeout=3600 \
+ --strategy=Javac=remote \
+ --strategy=Closure=remote \
+ --genrule_strategy=remote \
+ --experimental_strict_action_env=true \
+ --experimental_remote_platform_override='properties:{name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:496193842f61c9494be68bd624e47c74d706cabf19a693c4653ffe96a97e43e3" }' \
+ --crosstool_top=@com_github_bazelbuild_bazeltoolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \
+ --define GRPC_PORT_ISOLATED_RUNTIME=1 \
+ -c opt \
+ -- //test/...
diff --git a/tools/internal_ci/linux/grpc_build_submodule_at_head.sh b/tools/internal_ci/linux/grpc_build_submodule_at_head.sh
index b67b030361..e203a62b08 100755
--- a/tools/internal_ci/linux/grpc_build_submodule_at_head.sh
+++ b/tools/internal_ci/linux/grpc_build_submodule_at_head.sh
@@ -27,5 +27,5 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc
tools/buildgen/generate_projects.sh
git -c user.name='foo' -c user.email='foo@google.com' commit -a -m 'Update submodule'
-tools/run_tests/run_tests_matrix.py -f linux --internal_ci --build_only
+tools/run_tests/run_tests_matrix.py -f linux --inner_jobs 4 -j 4 --internal_ci --build_only
diff --git a/tools/internal_ci/linux/grpc_interop_badserver_java.cfg b/tools/internal_ci/linux/grpc_coverage.cfg
index dc2114273e..56b7745b21 100644
--- a/tools/internal_ci/linux/grpc_interop_badserver_java.cfg
+++ b/tools/internal_ci/linux/grpc_coverage.cfg
@@ -15,12 +15,10 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
-build_file: "grpc/tools/internal_ci/linux/grpc_interop_badserver_java.sh"
-# grpc_interop tests can take 6+ hours to complete.
-timeout_mins: 480
+build_file: "grpc/tools/internal_ci/linux/grpc_coverage.sh"
+timeout_mins: 420
action {
define_artifacts {
- regex: "**/report.xml"
regex: "github/grpc/reports/**"
}
}
diff --git a/tools/internal_ci/linux/grpc_interop_badserver_python.sh b/tools/internal_ci/linux/grpc_coverage.sh
index c2bd4e79ac..12181f0133 100755
--- a/tools/internal_ci/linux/grpc_interop_badserver_python.sh
+++ b/tools/internal_ci/linux/grpc_coverage.sh
@@ -15,13 +15,16 @@
set -ex
-export LANG=en_US.UTF-8
-
# Enter the gRPC repo root
cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
-source tools/internal_ci/helper_scripts/prepare_build_interop_rc
-
-tools/run_tests/run_interop_tests.py -l python --use_docker --http2_server_interop
+python tools/run_tests/run_tests.py \
+ --use_docker \
+ -t \
+ -l all \
+ -c gcov \
+ -x report.xml \
+ -j 16
+
diff --git a/tools/internal_ci/linux/grpc_interop_badserver_python.cfg b/tools/internal_ci/linux/grpc_distribtests_standalone.cfg
index ec738fcf74..bc6c8e8f80 100644
--- a/tools/internal_ci/linux/grpc_interop_badserver_python.cfg
+++ b/tools/internal_ci/linux/grpc_distribtests_standalone.cfg
@@ -15,12 +15,12 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
-build_file: "grpc/tools/internal_ci/linux/grpc_interop_badserver_python.sh"
-# grpc_interop tests can take 6+ hours to complete.
-timeout_mins: 480
+build_file: "grpc/tools/internal_ci/linux/grpc_distribtests_standalone.sh"
+timeout_mins: 120
action {
define_artifacts {
- regex: "**/report.xml"
+ regex: "**/*sponge_log.xml"
regex: "github/grpc/reports/**"
+ regex: "github/grpc/artifacts/**"
}
}
diff --git a/tools/internal_ci/linux/grpc_interop_tocloud.sh b/tools/internal_ci/linux/grpc_distribtests_standalone.sh
index e3ba25af5d..084daa9bc6 100755
--- a/tools/internal_ci/linux/grpc_interop_tocloud.sh
+++ b/tools/internal_ci/linux/grpc_distribtests_standalone.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/bash
# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,12 +15,9 @@
set -ex
-export LANG=en_US.UTF-8
-
-# Enter the gRPC repo root
+# change to grpc repo root
cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
-source tools/internal_ci/helper_scripts/prepare_build_interop_rc
-tools/run_tests/run_interop_tests.py -l all -s all --use_docker --http2_interop --internal_ci -t -j 12 $@
+tools/run_tests/task_runner.py -f distribtest linux cpp -j 6
diff --git a/tools/internal_ci/linux/grpc_full_performance_master.cfg b/tools/internal_ci/linux/grpc_full_performance_master.cfg
new file mode 100644
index 0000000000..8852130a13
--- /dev/null
+++ b/tools/internal_ci/linux/grpc_full_performance_master.cfg
@@ -0,0 +1,25 @@
+# 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.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/linux/grpc_full_performance_master.sh"
+timeout_mins: 600
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ regex: "**/perf_reports/**"
+ }
+}
diff --git a/tools/internal_ci/linux/grpc_full_performance_master.sh b/tools/internal_ci/linux/grpc_full_performance_master.sh
new file mode 100755
index 0000000000..18468395f6
--- /dev/null
+++ b/tools/internal_ci/linux/grpc_full_performance_master.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+# 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.
+set -ex
+
+# Enter the gRPC repo root
+cd $(dirname $0)/../../..
+
+source tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc
+
+# run 8core client vs 8core server
+tools/run_tests/run_performance_tests.py \
+ -l c++ csharp ruby java python go php7 php7_protobuf_c \
+ --netperf \
+ --category scalable \
+ --remote_worker_host grpc-kokoro-performance-server-8core grpc-kokoro-performance-client-8core grpc-kokoro-performance-client2-8core \
+ -u kbuilder \
+ --bq_result_table performance_test.kokoro_performance_experiment \
+ --xml_report reports/8core/sponge_log.xml \
+ || EXIT_CODE=1
+
+# prevent pushing leftover build files to remote hosts in the next step.
+git clean -fdxq -e reports
+
+# scalability with 32cores (and upload to a different BQ table)
+tools/run_tests/run_performance_tests.py \
+ -l c++ java csharp go \
+ --netperf \
+ --category scalable \
+ --remote_worker_host grpc-kokoro-performance-server-32core grpc-kokoro-performance-client-32core grpc-kokoro-performance-client2-32core \
+ -u kbuilder \
+ --bq_result_table performance_test.kokoro_performance_experiment_32core \
+ --xml_report reports/32core/sponge_log.xml \
+ || EXIT_CODE=1
+
+# prevent pushing leftover build files to remote hosts in the next step.
+git clean -fdxq -e reports
+
+# selected scenarios on Windows
+tools/run_tests/run_performance_tests.py \
+ -l csharp \
+ --category scalable \
+ --remote_worker_host grpc-kokoro-performance-windows1 grpc-kokoro-performance-windows2 \
+ --bq_result_table performance_test.kokoro_performance_experiment_windows \
+ --xml_report reports/windows/sponge_log.xml \
+ || EXIT_CODE=1
+
+exit $EXIT_CODE
diff --git a/tools/internal_ci/linux/grpc_interop_matrix.cfg b/tools/internal_ci/linux/grpc_interop_matrix.cfg
index a7fd479a73..71e930e0b0 100644
--- a/tools/internal_ci/linux/grpc_interop_matrix.cfg
+++ b/tools/internal_ci/linux/grpc_interop_matrix.cfg
@@ -17,7 +17,7 @@
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_interop_matrix.sh"
# grpc_interop tests can take 1 hours to complete.
-timeout_mins: 60
+timeout_mins: 120
action {
define_artifacts {
regex: "**/sponge_log.xml"
diff --git a/tools/internal_ci/linux/grpc_interop_matrix.sh b/tools/internal_ci/linux/grpc_interop_matrix.sh
index e199d48931..4c24c43488 100755
--- a/tools/internal_ci/linux/grpc_interop_matrix.sh
+++ b/tools/internal_ci/linux/grpc_interop_matrix.sh
@@ -22,4 +22,4 @@ cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
-tools/interop_matrix/run_interop_matrix_tests.py --language=all --release=all --report_file=sponge_log.xml $@
+tools/interop_matrix/run_interop_matrix_tests.py --language=all --release=all --allow_flakes --report_file=sponge_log.xml --bq_result_table interop_results $@
diff --git a/tools/internal_ci/linux/grpc_interop_tocloud.cfg b/tools/internal_ci/linux/grpc_interop_tocloud.cfg
index 2803616007..13aec15770 100644
--- a/tools/internal_ci/linux/grpc_interop_tocloud.cfg
+++ b/tools/internal_ci/linux/grpc_interop_tocloud.cfg
@@ -15,8 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
-build_file: "grpc/tools/internal_ci/linux/grpc_interop_tocloud.sh"
-# grpc_interop tests can take 6+ hours to complete.
+build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh"
timeout_mins: 60
action {
define_artifacts {
@@ -24,3 +23,8 @@ action {
regex: "github/grpc/reports/**"
}
}
+
+env_vars {
+ key: "RUN_TESTS_FLAGS"
+ value: "-l all -s all --use_docker --http2_interop --internal_ci -t -j 12 --bq_result_table interop_results"
+}
diff --git a/tools/internal_ci/linux/grpc_interop_toprod.cfg b/tools/internal_ci/linux/grpc_interop_toprod.cfg
index 903480a3d1..ff7a98f44e 100644
--- a/tools/internal_ci/linux/grpc_interop_toprod.cfg
+++ b/tools/internal_ci/linux/grpc_interop_toprod.cfg
@@ -15,8 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
-build_file: "grpc/tools/internal_ci/linux/grpc_interop_toprod.sh"
-# grpc_interop tests can take 6+ hours to complete.
+build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh"
timeout_mins: 60
action {
define_artifacts {
@@ -25,3 +24,7 @@ action {
}
}
+env_vars {
+ key: "RUN_TESTS_FLAGS"
+ value: "-l all --cloud_to_prod --cloud_to_prod_auth --prod_servers default gateway_v4 cloud_gateway cloud_gateway_v4 --use_docker --internal_ci -t -j 12 --bq_result_table interop_results"
+}
diff --git a/tools/internal_ci/linux/grpc_interop_toprod.sh b/tools/internal_ci/linux/grpc_interop_toprod.sh
deleted file mode 100755
index 3d06185406..0000000000
--- a/tools/internal_ci/linux/grpc_interop_toprod.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env bash
-# 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.
-
-set -ex
-
-export LANG=en_US.UTF-8
-
-# Enter the gRPC repo root
-cd $(dirname $0)/../../..
-
-source tools/internal_ci/helper_scripts/prepare_build_linux_rc
-source tools/internal_ci/helper_scripts/prepare_build_interop_rc
-
-tools/run_tests/run_interop_tests.py \
- -l all \
- --cloud_to_prod \
- --cloud_to_prod_auth \
- --prod_servers default gateway_v4 \
- --use_docker --internal_ci -t -j 12 $@
-
diff --git a/tools/internal_ci/linux/grpc_microbenchmark_diff.sh b/tools/internal_ci/linux/grpc_microbenchmark_diff.sh
index 58ffcf336b..45add1b02d 100755
--- a/tools/internal_ci/linux/grpc_microbenchmark_diff.sh
+++ b/tools/internal_ci/linux/grpc_microbenchmark_diff.sh
@@ -25,6 +25,8 @@ cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc
tools/run_tests/start_port_server.py
+tools/jenkins/run_c_cpp_test.sh tools/profiling/bloat/bloat_diff.py \
+ -d origin/$ghprbTargetBranch || FAILED="true"
tools/jenkins/run_c_cpp_test.sh tools/profiling/microbenchmarks/bm_diff/bm_main.py \
-d origin/$ghprbTargetBranch \
-b $BENCHMARKS_TO_RUN || FAILED="true"
diff --git a/tools/internal_ci/linux/grpc_performance_profile_daily.sh b/tools/internal_ci/linux/grpc_performance_profile_daily.sh
index 25523e21b8..34d41bc04c 100755
--- a/tools/internal_ci/linux/grpc_performance_profile_daily.sh
+++ b/tools/internal_ci/linux/grpc_performance_profile_daily.sh
@@ -22,6 +22,8 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc
CPUS=`python -c 'import multiprocessing; print multiprocessing.cpu_count()'`
+./tools/run_tests/start_port_server.py || true
+
make CONFIG=opt memory_profile_test memory_profile_client memory_profile_server -j $CPUS
bins/opt/memory_profile_test
bq load microbenchmarks.memory memory_usage.csv
diff --git a/tools/internal_ci/linux/grpc_portability_build_only.cfg b/tools/internal_ci/linux/grpc_portability_build_only.cfg
index 501223c0c7..4acd9353fb 100644
--- a/tools/internal_ci/linux/grpc_portability_build_only.cfg
+++ b/tools/internal_ci/linux/grpc_portability_build_only.cfg
@@ -26,5 +26,5 @@ action {
env_vars {
key: "RUN_TESTS_FLAGS"
- value: "-f portability linux --internal_ci --build_only"
+ value: "-f portability linux --inner_jobs 4 -j 4 --internal_ci --build_only"
}
diff --git a/tools/internal_ci/linux/grpc_interop_badserver_java.sh b/tools/internal_ci/linux/grpc_run_interop_tests.sh
index d25845ca50..1f4eda2d52 100755
--- a/tools/internal_ci/linux/grpc_interop_badserver_java.sh
+++ b/tools/internal_ci/linux/grpc_run_interop_tests.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/bash
# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,5 +23,4 @@ cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
source tools/internal_ci/helper_scripts/prepare_build_interop_rc
-tools/run_tests/run_interop_tests.py -l java --use_docker --http2_server_interop
-
+tools/run_tests/run_interop_tests.py $RUN_TESTS_FLAGS
diff --git a/tools/internal_ci/linux/grpc_run_tests_matrix.sh b/tools/internal_ci/linux/grpc_run_tests_matrix.sh
index bd1430b741..1018708f96 100755
--- a/tools/internal_ci/linux/grpc_run_tests_matrix.sh
+++ b/tools/internal_ci/linux/grpc_run_tests_matrix.sh
@@ -20,6 +20,13 @@ cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
+# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
+if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then
+ sudo apt-get install -y jq
+ ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
+ export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch"
+fi
+
tools/run_tests/run_tests_matrix.py $RUN_TESTS_FLAGS || FAILED="true"
# Reveal leftover processes that might be left behind by the build
diff --git a/tools/internal_ci/linux/grpc_sanity.cfg b/tools/internal_ci/linux/grpc_sanity.cfg
index 24e7984f3a..e06a2f4241 100644
--- a/tools/internal_ci/linux/grpc_sanity.cfg
+++ b/tools/internal_ci/linux/grpc_sanity.cfg
@@ -16,7 +16,7 @@
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh"
-timeout_mins: 20
+timeout_mins: 40
action {
define_artifacts {
regex: "**/*sponge_log.xml"
diff --git a/tools/internal_ci/linux/grpc_tsan_on_foundry.sh b/tools/internal_ci/linux/grpc_tsan_on_foundry.sh
new file mode 100644
index 0000000000..7da537ce49
--- /dev/null
+++ b/tools/internal_ci/linux/grpc_tsan_on_foundry.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+# 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.
+
+set -ex
+
+# A temporary solution to give Kokoro credentials.
+# The file name 4321_grpc-testing-service needs to match auth_credential in
+# the build config.
+# TODO: Use keystore.
+mkdir -p ${KOKORO_KEYSTORE_DIR}
+cp ${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json ${KOKORO_KEYSTORE_DIR}/4321_grpc-testing-service
+
+mkdir -p /tmpfs/tmp/bazel-canary
+ln -f "${KOKORO_GFILE_DIR}/bazel-canary" /tmpfs/tmp/bazel-canary/bazel
+chmod 755 "${KOKORO_GFILE_DIR}/bazel-canary"
+export PATH="/tmpfs/tmp/bazel-canary:${PATH}"
+# This should show /tmpfs/tmp/bazel-canary/bazel
+which bazel
+chmod +x "${KOKORO_GFILE_DIR}/bazel_wrapper.py"
+
+# change to grpc repo root
+cd $(dirname $0)/../../..
+
+source tools/internal_ci/helper_scripts/prepare_build_linux_rc
+
+"${KOKORO_GFILE_DIR}/bazel_wrapper.py" \
+ --host_jvm_args=-Dbazel.DigestFunction=SHA256 \
+ test --jobs="50" \
+ --test_timeout="1500,1500,1500,3600" \
+ --test_output=errors \
+ --verbose_failures=true \
+ --keep_going \
+ --remote_accept_cached=true \
+ --spawn_strategy=remote \
+ --remote_local_fallback=false \
+ --remote_timeout=3600 \
+ --strategy=Javac=remote \
+ --strategy=Closure=remote \
+ --genrule_strategy=remote \
+ --experimental_strict_action_env=true \
+ --experimental_remote_platform_override='properties:{name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:496193842f61c9494be68bd624e47c74d706cabf19a693c4653ffe96a97e43e3" }' \
+ --crosstool_top=@com_github_bazelbuild_bazeltoolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \
+ --define GRPC_PORT_ISOLATED_RUNTIME=1 \
+ --copt=-gmlt \
+ --strip=never \
+ --copt=-fsanitize=thread \
+ --linkopt=-fsanitize=thread \
+ --test_verbose_timeout_warnings \
+ -- //test/...
diff --git a/tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg b/tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg
new file mode 100644
index 0000000000..cb18e8e868
--- /dev/null
+++ b/tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg
@@ -0,0 +1,30 @@
+# 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.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh"
+timeout_mins: 60
+action {
+ define_artifacts {
+ regex: "**/sponge_log.xml"
+ regex: "github/grpc/reports/**"
+ }
+}
+
+env_vars {
+ key: "RUN_TESTS_FLAGS"
+ value: "-l all -s all --use_docker --http2_interop --internal_ci -t -j 12"
+}
diff --git a/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg b/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg
new file mode 100644
index 0000000000..e141d9f648
--- /dev/null
+++ b/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg
@@ -0,0 +1,30 @@
+# 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.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh"
+timeout_mins: 60
+action {
+ define_artifacts {
+ regex: "**/sponge_log.xml"
+ regex: "github/grpc/reports/**"
+ }
+}
+
+env_vars {
+ key: "RUN_TESTS_FLAGS"
+ value: "-l all --allow_flakes --cloud_to_prod --cloud_to_prod_auth --prod_servers default gateway_v4 --use_docker --internal_ci -t -j 12"
+}
diff --git a/tools/internal_ci/macos/grpc_build_artifacts.sh b/tools/internal_ci/macos/grpc_build_artifacts.sh
index 09784e3bb4..eb4568c32b 100755
--- a/tools/internal_ci/macos/grpc_build_artifacts.sh
+++ b/tools/internal_ci/macos/grpc_build_artifacts.sh
@@ -27,8 +27,7 @@ python3.5 -m pip install cython setuptools wheel
python3.6 -m pip install cython setuptools wheel
# needed to build ruby artifacts
-wget https://raw.githubusercontent.com/grpc/grpc/master/tools/distrib/build_ruby_environment_macos.sh
-bash build_ruby_environment_macos.sh
+time bash tools/distrib/build_ruby_environment_macos.sh
gem install rubygems-update
update_rubygems
diff --git a/tools/internal_ci/macos/grpc_run_tests_matrix.sh b/tools/internal_ci/macos/grpc_run_tests_matrix.sh
index 8e7fd54a62..6e0c2bb487 100755
--- a/tools/internal_ci/macos/grpc_run_tests_matrix.sh
+++ b/tools/internal_ci/macos/grpc_run_tests_matrix.sh
@@ -28,6 +28,9 @@ ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9
# Reveal leftover processes that might be left behind by the build
ps aux | grep -i kbuilder
+# TODO(jtattermusch): better debugging of clock skew, remove once not needed
+date
+
echo 'Exiting gRPC main test script.'
if [ "$FAILED" != "" ]
diff --git a/tools/internal_ci/windows/grpc_basictests_dbg.cfg b/tools/internal_ci/windows/grpc_basictests_dbg.cfg
new file mode 100644
index 0000000000..28d53cdc7b
--- /dev/null
+++ b/tools/internal_ci/windows/grpc_basictests_dbg.cfg
@@ -0,0 +1,30 @@
+# 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.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat"
+timeout_mins: 240
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ regex: "github/grpc/reports/**"
+ }
+}
+
+env_vars {
+ key: "RUN_TESTS_FLAGS"
+ value: "-f basictests windows dbg -j 1 --inner_jobs 8 --internal_ci --bq_result_table aggregate_results"
+}
diff --git a/tools/internal_ci/windows/grpc_basictests_opt.cfg b/tools/internal_ci/windows/grpc_basictests_opt.cfg
new file mode 100644
index 0000000000..4b7a965977
--- /dev/null
+++ b/tools/internal_ci/windows/grpc_basictests_opt.cfg
@@ -0,0 +1,30 @@
+# 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.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat"
+timeout_mins: 240
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ regex: "github/grpc/reports/**"
+ }
+}
+
+env_vars {
+ key: "RUN_TESTS_FLAGS"
+ value: "-f basictests windows opt -j 1 --inner_jobs 8 --internal_ci --bq_result_table aggregate_results"
+}
diff --git a/tools/run_tests/helper_scripts/build_node.bat b/tools/internal_ci/windows/grpc_distribtests_standalone.bat
index 8986239b04..3eb33b1548 100644
--- a/tools/run_tests/helper_scripts/build_node.bat
+++ b/tools/internal_ci/windows/grpc_distribtests_standalone.bat
@@ -1,4 +1,4 @@
-@rem Copyright 2016 gRPC authors.
+@rem Copyright 2017 gRPC authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@@ -12,18 +12,20 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
-set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm
+@rem Move python installation from _32bit to _32bits where they are expected by python artifact builder
+@rem TODO(jtattermusch): get rid of this hack
+rename C:\Python27_32bit Python27_32bits
+rename C:\Python34_32bit Python34_32bits
+rename C:\Python35_32bit Python35_32bits
+rename C:\Python36_32bit Python36_32bits
-del /f /q BUILD || rmdir build /s /q
+@rem enter repo root
+cd /d %~dp0\..\..\..
-call npm install --build-from-source
+call tools/internal_ci/helper_scripts/prepare_build_windows.bat
-@rem delete the redundant openssl headers
-for /f "delims=v" %%v in ('node --version') do (
- rmdir "%USERPROFILE%\.node-gyp\%%v\include\node\openssl" /S /Q
-)
+python tools/run_tests/task_runner.py -f distribtest windows cpp -j 4 || goto :error
+goto :EOF
-
-
-@rem rebuild, because it probably failed the first time
-call npm install --build-from-source %*
+:error
+exit /b %errorlevel%
diff --git a/tools/internal_ci/windows/grpc_distribtests_standalone.cfg b/tools/internal_ci/windows/grpc_distribtests_standalone.cfg
new file mode 100644
index 0000000000..33a50fdc45
--- /dev/null
+++ b/tools/internal_ci/windows/grpc_distribtests_standalone.cfg
@@ -0,0 +1,26 @@
+# 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.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/windows/grpc_distribtests_standalone.bat"
+timeout_mins: 120
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ regex: "github/grpc/reports/**"
+ regex: "github/grpc/artifacts/**"
+ }
+}
diff --git a/tools/interop_matrix/README.md b/tools/interop_matrix/README.md
index f92dc690e2..40c02a1bc7 100644
--- a/tools/interop_matrix/README.md
+++ b/tools/interop_matrix/README.md
@@ -5,22 +5,26 @@ This directory contains scripts that facilitate building and running gRPC tests
The setup builds gRPC docker images for each language/runtime and upload it to Google Container Registry (GCR). These images, encapsulating gRPC stack
from specific releases/tag, are used to test version compatiblity between gRPC release versions.
-## Instructions for creating GCR images
-- Edit `./client_matrix.py` to include desired gRPC release.
-- Run `tools/interop_matrix/create_matrix_images.py`. Useful options:
- - `--git_checkout` enables git checkout grpc release branch/tag.
- - `--release` specifies a git release tag. Make sure it is a valid tag in the grpc github rep.
- - `--language` specifies a language.
- For example, To build all languages for all gRPC releases across all runtimes, do `tools/interop_matrix/create_matrix_images.py --git_checkout --release=all`.
-- Verify the newly created docker images are uploaded to GCR. For example:
+## Step-by-step instructions for adding a GCR image for a new release for compatibility test
+We have continuous nightly test setup to test gRPC backward compatibility between old clients and latest server. When a gRPC developer creates a new gRPC release, s/he is also responsible to add the just-released gRPC client to the nightly test. The steps are:
+- Add (or update) an entry in `./client_matrix.py` file to reference the github tag for the release.
+- Build new client docker image(s). For example, for C and wrapper languages release `v1.9.9`, do
+ - `tools/interop_matrix/create_matrix_images.py --git_checkout --release=v1.9.9 --language cxx csharp python ruby php`
+- Verify that the new docker image was built successfully and uploaded to GCR. For example,
- `gcloud beta container images list --repository gcr.io/grpc-testing` shows image repos.
- - `gcloud beta container images list-tags gcr.io/grpc-testing/grpc_interop_go1.7` show tags for a image repo.
+ - `gcloud beta container images list-tags gcr.io/grpc-testing/grpc_interop_java_oracle8` should show an image entry with tag `v1.9.9`.
+- Verify the just-created docker client image would pass backward compatibility test (it should). For example,
+ - `gcloud docker -- pull gcr.io/grpc-testing/grpc_interop_java_oracle8:v1.9.9` followed by
+ - `docker_image=gcr.io/grpc-testing/grpc_interop_java_oracle8:v1.9.9 tools/interop_matrix/testcases/java__master`
+- git commit the change and merge it to upstream/master.
+- (Optional) clean up the tmp directory to where grpc source is cloned at `/export/hda3/tmp/grpc_matrix/`.
+For more details on each step, refer to sections below.
## Instructions for adding new language/runtimes*
- Create new `Dockerfile.template`, `build_interop.sh.template` for the language/runtime under `template/tools/dockerfile/`.
- Run `tools/buildgen/generate_projects.sh` to create corresponding files under `tools/dockerfile/`.
- Add language/runtimes to `client_matrix.py` following existing language/runtimes examples.
-- Run `tools/interop_matrix/create_matrix_images.py` which will build and upload images to GCR. Unless you are also building images for a gRPC release, make sure not to set `--gcr_tag` (the default tag 'master' is used for testing).
+- Run `tools/interop_matrix/create_matrix_images.py` which will build and upload images to GCR. Unless you are also building images for a gRPC release, make sure not to set `--release` (the default release 'master' is used for testing).
*: Please delete your docker images at https://pantheon.corp.google.com/gcr/images/grpc-testing?project=grpc-testing afterwards. Permissions to access GrpcTesting project is required for this step.
@@ -32,7 +36,7 @@ from specific releases/tag, are used to test version compatiblity between gRPC r
## Instructions for running test cases against GCR images
- Run `tools/interop_matrix/run_interop_matrix_tests.py`. Useful options:
- - `--release` specifies a git release tag. Defaults to `--release=master`. Make sure the GCR images with the tag have been created using `create_matrix_images.py` above.
+ - `--release` specifies a git release tag. Defaults to `--release=all`. Make sure the GCR images with the tag have been created using `create_matrix_images.py` above.
- `--language` specifies a language. Defaults to `--language=all`.
For example, To test all languages for all gRPC releases across all runtimes, do `tools/interop_matrix/run_interop_matrix_test.py --release=all`.
- The output for all the test cases is recorded in a junit style xml file (default to 'report.xml').
@@ -45,3 +49,4 @@ For example:
Note:
- File path starting with `tools/` or `template/` are relative to the grpc repo root dir. File path starting with `./` are relative to current directory (`tools/interop_matrix`).
+- Creating and referencing images in GCR require read and write permission to Google Container Registry path gcr.io/grpc-testing.
diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py
index 4d1b5f0169..5de705a52a 100644
--- a/tools/interop_matrix/client_matrix.py
+++ b/tools/interop_matrix/client_matrix.py
@@ -15,42 +15,259 @@
# Dictionaries used for client matrix testing.
+
def get_github_repo(lang):
- return {
- 'go': 'git@github.com:grpc/grpc-go.git',
- 'java': 'git@github.com:grpc/grpc-java.git',
- # all other languages use the grpc.git repo.
- }.get(lang, 'git@github.com:grpc/grpc.git')
+ return {
+ 'go': 'git@github.com:grpc/grpc-go.git',
+ 'java': 'git@github.com:grpc/grpc-java.git',
+ 'node': 'git@github.com:grpc/grpc-node.git',
+ # all other languages use the grpc.git repo.
+ }.get(lang, 'git@github.com:grpc/grpc.git')
+
+
+def get_release_tags(lang):
+ return map(lambda r: get_release_tag_name(r), LANG_RELEASE_MATRIX[lang])
+
+
+def get_release_tag_name(release_info):
+ assert len(release_info.keys()) == 1
+ return release_info.keys()[0]
+
+
+def should_build_docker_interop_image_from_release_tag(lang):
+ if lang in ['go', 'java', 'node']:
+ return False
+ return True
+
# Dictionary of runtimes per language
LANG_RUNTIME_MATRIX = {
- 'cxx': ['cxx'], # This is actually debian8.
+ 'cxx': ['cxx'], # This is actually debian8.
'go': ['go1.7', 'go1.8'],
'java': ['java_oracle8'],
+ 'python': ['python'],
+ 'node': ['node'],
+ 'ruby': ['ruby'],
+ 'php': ['php', 'php7'],
+ 'csharp': ['csharp', 'csharpcoreclr'],
}
# Dictionary of releases per language. For each language, we need to provide
# a release tag pointing to the latest build of the branch.
LANG_RELEASE_MATRIX = {
'cxx': [
- 'v1.0.1',
- 'v1.1.4',
- 'v1.2.5',
- 'v1.3.9',
- 'v1.4.2',
+ {
+ 'v1.0.1': None
+ },
+ {
+ 'v1.1.4': None
+ },
+ {
+ 'v1.2.5': None
+ },
+ {
+ 'v1.3.9': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.6.6': None
+ },
+ {
+ 'v1.7.2': None
+ },
+ {
+ 'v1.8.0': None
+ },
],
'go': [
- 'v1.0.5',
- 'v1.2.1',
- 'v1.3.0',
- 'v1.4.2',
+ {
+ 'v1.0.5': None
+ },
+ {
+ 'v1.2.1': None
+ },
+ {
+ 'v1.3.0': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.5.2': None
+ },
+ {
+ 'v1.6.0': None
+ },
+ {
+ 'v1.7.4': None
+ },
+ {
+ 'v1.8.2': None
+ },
+ {
+ 'v1.9.2': None
+ },
],
'java': [
- 'v1.0.3',
- 'v1.1.2',
- 'v1.2.0',
- 'v1.3.1',
- 'v1.4.0',
- 'v1.5.0',
+ {
+ 'v1.0.3': None
+ },
+ {
+ 'v1.1.2': None
+ },
+ {
+ 'v1.2.0': None
+ },
+ {
+ 'v1.3.1': None
+ },
+ {
+ 'v1.4.0': None
+ },
+ {
+ 'v1.5.0': None
+ },
+ {
+ 'v1.6.1': None
+ },
+ {
+ 'v1.7.0': None
+ },
+ {
+ 'v1.8.0': None
+ },
+ {
+ 'v1.9.0': None
+ },
+ ],
+ 'python': [
+ {
+ 'v1.0.x': None
+ },
+ {
+ 'v1.1.4': None
+ },
+ {
+ 'v1.2.5': None
+ },
+ {
+ 'v1.3.9': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.6.6': None
+ },
+ {
+ 'v1.7.2': None
+ },
+ {
+ 'v1.8.1': None # first python 1.8 release is 1.8.1
+ },
+ ],
+ 'node': [
+ {
+ 'v1.0.1': None
+ },
+ {
+ 'v1.1.4': None
+ },
+ {
+ 'v1.2.5': None
+ },
+ {
+ 'v1.3.9': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.6.6': None
+ },
+ #{'v1.7.1': None}, Failing tests
+ ],
+ 'ruby': [
+ {
+ 'v1.0.1': {
+ 'patch': [
+ 'tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile',
+ 'tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh',
+ ]
+ }
+ },
+ {
+ 'v1.1.4': None
+ },
+ {
+ 'v1.2.5': None
+ },
+ {
+ 'v1.3.9': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.6.6': None
+ },
+ {
+ 'v1.7.2': None
+ },
+ {
+ 'v1.8.0': None
+ },
+ ],
+ 'php': [
+ {
+ 'v1.0.1': None
+ },
+ {
+ 'v1.1.4': None
+ },
+ {
+ 'v1.2.5': None
+ },
+ {
+ 'v1.3.9': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.6.6': None
+ },
+ {
+ 'v1.7.2': None
+ },
+ {
+ 'v1.8.0': None
+ },
+ ],
+ 'csharp': [
+ #{'v1.0.1': None},
+ {
+ 'v1.1.4': None
+ },
+ {
+ 'v1.2.5': None
+ },
+ {
+ 'v1.3.9': None
+ },
+ {
+ 'v1.4.2': None
+ },
+ {
+ 'v1.6.6': None
+ },
+ {
+ 'v1.7.2': None
+ },
+ {
+ 'v1.8.0': None
+ },
],
}
diff --git a/tools/interop_matrix/create_matrix_images.py b/tools/interop_matrix/create_matrix_images.py
index 119cbd2e88..ef9f6a5990 100755
--- a/tools/interop_matrix/create_matrix_images.py
+++ b/tools/interop_matrix/create_matrix_images.py
@@ -12,7 +12,6 @@
# 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.
-
"""Build and upload docker images to Google Container Registry per matrix."""
from __future__ import print_function
@@ -29,8 +28,8 @@ import tempfile
# Langauage Runtime Matrix
import client_matrix
-python_util_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../run_tests/python_utils'))
+python_util_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../run_tests/python_utils'))
sys.path.append(python_util_dir)
import dockerjob
import jobset
@@ -38,219 +37,305 @@ import jobset
_IMAGE_BUILDER = 'tools/run_tests/dockerize/build_interop_image.sh'
_LANGUAGES = client_matrix.LANG_RUNTIME_MATRIX.keys()
# All gRPC release tags, flattened, deduped and sorted.
-_RELEASES = sorted(list(set(
- i for l in client_matrix.LANG_RELEASE_MATRIX.values() for i in l)))
+_RELEASES = sorted(
+ list(
+ set(
+ client_matrix.get_release_tag_name(info)
+ for lang in client_matrix.LANG_RELEASE_MATRIX.values()
+ for info in lang)))
# Destination directory inside docker image to keep extra info from build time.
_BUILD_INFO = '/var/local/build_info'
argp = argparse.ArgumentParser(description='Run interop tests.')
-argp.add_argument('--gcr_path',
- default='gcr.io/grpc-testing',
- help='Path of docker images in Google Container Registry')
-
-argp.add_argument('--release',
- default='master',
- choices=['all', 'master'] + _RELEASES,
- help='github commit tag to checkout. When building all '
- 'releases defined in client_matrix.py, use "all". Valid only '
- 'with --git_checkout.')
-
-argp.add_argument('-l', '--language',
- choices=['all'] + sorted(_LANGUAGES),
- nargs='+',
- default=['all'],
- help='Test languages to build docker images for.')
-
-argp.add_argument('--git_checkout',
- action='store_true',
- help='Use a separate git clone tree for building grpc stack. '
- 'Required when using --release flag. By default, current'
- 'tree and the sibling will be used for building grpc stack.')
-
-argp.add_argument('--git_checkout_root',
- default='/export/hda3/tmp/grpc_matrix',
- help='Directory under which grpc-go/java/main repo will be '
- 'cloned. Valid only with --git_checkout.')
-
-argp.add_argument('--keep',
- action='store_true',
- help='keep the created local images after uploading to GCR')
-
+argp.add_argument(
+ '--gcr_path',
+ default='gcr.io/grpc-testing',
+ help='Path of docker images in Google Container Registry')
+
+argp.add_argument(
+ '--release',
+ default='master',
+ choices=['all', 'master'] + _RELEASES,
+ help='github commit tag to checkout. When building all '
+ 'releases defined in client_matrix.py, use "all". Valid only '
+ 'with --git_checkout.')
+
+argp.add_argument(
+ '-l',
+ '--language',
+ choices=['all'] + sorted(_LANGUAGES),
+ nargs='+',
+ default=['all'],
+ help='Test languages to build docker images for.')
+
+argp.add_argument(
+ '--git_checkout',
+ action='store_true',
+ help='Use a separate git clone tree for building grpc stack. '
+ 'Required when using --release flag. By default, current'
+ 'tree and the sibling will be used for building grpc stack.')
+
+argp.add_argument(
+ '--git_checkout_root',
+ default='/export/hda3/tmp/grpc_matrix',
+ help='Directory under which grpc-go/java/main repo will be '
+ 'cloned. Valid only with --git_checkout.')
+
+argp.add_argument(
+ '--keep',
+ action='store_true',
+ help='keep the created local images after uploading to GCR')
+
+argp.add_argument(
+ '--reuse_git_root',
+ default=False,
+ action='store_const',
+ const=True,
+ help='reuse the repo dir. If False, the existing git root '
+ 'directory will removed before a clean checkout, because '
+ 'reusing the repo can cause git checkout error if you switch '
+ 'between releases.')
args = argp.parse_args()
+
def add_files_to_image(image, with_files, label=None):
- """Add files to a docker image.
+ """Add files to a docker image.
image: docker image name, i.e. grpc_interop_java:26328ad8
with_files: additional files to include in the docker image.
label: label string to attach to the image.
"""
- tag_idx = image.find(':')
- if tag_idx == -1:
- jobset.message('FAILED', 'invalid docker image %s' % image, do_newline=True)
- sys.exit(1)
- orig_tag = '%s_' % image
- subprocess.check_output(['docker', 'tag', image, orig_tag])
-
- lines = ['FROM ' + orig_tag]
- if label:
- lines.append('LABEL %s' % label)
-
- temp_dir = tempfile.mkdtemp()
- atexit.register(lambda: subprocess.call(['rm', '-rf', temp_dir]))
-
- # Copy with_files inside the tmp directory, which will be the docker build
- # context.
- for f in with_files:
- shutil.copy(f, temp_dir)
- lines.append('COPY %s %s/' % (os.path.basename(f), _BUILD_INFO))
-
- # Create a Dockerfile.
- with open(os.path.join(temp_dir, 'Dockerfile'), 'w') as f:
- f.write('\n'.join(lines))
-
- jobset.message('START', 'Repackaging %s' % image, do_newline=True)
- build_cmd = ['docker', 'build', '--rm', '--tag', image, temp_dir]
- subprocess.check_output(build_cmd)
- dockerjob.remove_image(orig_tag, skip_nonexistent=True)
-
-def build_image_jobspec(runtime, env, gcr_tag):
- """Build interop docker image for a language with runtime.
+ tag_idx = image.find(':')
+ if tag_idx == -1:
+ jobset.message(
+ 'FAILED', 'invalid docker image %s' % image, do_newline=True)
+ sys.exit(1)
+ orig_tag = '%s_' % image
+ subprocess.check_output(['docker', 'tag', image, orig_tag])
+
+ lines = ['FROM ' + orig_tag]
+ if label:
+ lines.append('LABEL %s' % label)
+
+ temp_dir = tempfile.mkdtemp()
+ atexit.register(lambda: subprocess.call(['rm', '-rf', temp_dir]))
+
+ # Copy with_files inside the tmp directory, which will be the docker build
+ # context.
+ for f in with_files:
+ shutil.copy(f, temp_dir)
+ lines.append('COPY %s %s/' % (os.path.basename(f), _BUILD_INFO))
+
+ # Create a Dockerfile.
+ with open(os.path.join(temp_dir, 'Dockerfile'), 'w') as f:
+ f.write('\n'.join(lines))
+
+ jobset.message('START', 'Repackaging %s' % image, do_newline=True)
+ build_cmd = ['docker', 'build', '--rm', '--tag', image, temp_dir]
+ subprocess.check_output(build_cmd)
+ dockerjob.remove_image(orig_tag, skip_nonexistent=True)
+
+
+def build_image_jobspec(runtime, env, gcr_tag, stack_base):
+ """Build interop docker image for a language with runtime.
runtime: a <lang><version> string, for example go1.8.
env: dictionary of env to passed to the build script.
gcr_tag: the tag for the docker image (i.e. v1.3.0).
+ stack_base: the local gRPC repo path.
"""
- basename = 'grpc_interop_%s' % runtime
- tag = '%s/%s:%s' % (args.gcr_path, basename, gcr_tag)
- build_env = {
- 'INTEROP_IMAGE': tag,
- 'BASE_NAME': basename,
- 'TTY_FLAG': '-t'
- }
- build_env.update(env)
- build_job = jobset.JobSpec(
- cmdline=[_IMAGE_BUILDER],
- environ=build_env,
- shortname='build_docker_%s' % runtime,
- timeout_seconds=30*60)
- build_job.tag = tag
- return build_job
+ basename = 'grpc_interop_%s' % runtime
+ tag = '%s/%s:%s' % (args.gcr_path, basename, gcr_tag)
+ build_env = {'INTEROP_IMAGE': tag, 'BASE_NAME': basename, 'TTY_FLAG': '-t'}
+ build_env.update(env)
+ image_builder_path = _IMAGE_BUILDER
+ if client_matrix.should_build_docker_interop_image_from_release_tag(lang):
+ image_builder_path = os.path.join(stack_base, _IMAGE_BUILDER)
+ build_job = jobset.JobSpec(
+ cmdline=[image_builder_path],
+ environ=build_env,
+ shortname='build_docker_%s' % runtime,
+ timeout_seconds=30 * 60)
+ build_job.tag = tag
+ return build_job
+
def build_all_images_for_lang(lang):
- """Build all docker images for a language across releases and runtimes."""
- if not args.git_checkout:
- if args.release != 'master':
- print('WARNING: --release is set but will be ignored\n')
- releases = ['master']
- else:
- if args.release == 'all':
- releases = client_matrix.LANG_RELEASE_MATRIX[lang]
+ """Build all docker images for a language across releases and runtimes."""
+ if not args.git_checkout:
+ if args.release != 'master':
+ print('WARNING: --release is set but will be ignored\n')
+ releases = ['master']
else:
- # Build a particular release.
- if args.release not in ['master'] + client_matrix.LANG_RELEASE_MATRIX[lang]:
- jobset.message('SKIPPED',
- '%s for %s is not defined' % (args.release, lang),
- do_newline=True)
- return []
- releases = [args.release]
-
- images = []
- for release in releases:
- images += build_all_images_for_release(lang, release)
- jobset.message('SUCCESS',
- 'All docker images built for %s at %s.' % (lang, releases),
- do_newline=True)
- return images
+ if args.release == 'all':
+ releases = client_matrix.get_release_tags(lang)
+ else:
+ # Build a particular release.
+ if args.release not in ['master'
+ ] + client_matrix.get_release_tags(lang):
+ jobset.message(
+ 'SKIPPED',
+ '%s for %s is not defined' % (args.release, lang),
+ do_newline=True)
+ return []
+ releases = [args.release]
+
+ images = []
+ for release in releases:
+ images += build_all_images_for_release(lang, release)
+ jobset.message(
+ 'SUCCESS',
+ 'All docker images built for %s at %s.' % (lang, releases),
+ do_newline=True)
+ return images
+
def build_all_images_for_release(lang, release):
- """Build all docker images for a release across all runtimes."""
- docker_images = []
- build_jobs = []
-
- env = {}
- # If we not using current tree or the sibling for grpc stack, do checkout.
- if args.git_checkout:
- stack_base = checkout_grpc_stack(lang, release)
- var ={'go': 'GRPC_GO_ROOT', 'java': 'GRPC_JAVA_ROOT'}.get(lang, 'GRPC_ROOT')
- env[var] = stack_base
-
- for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]:
- job = build_image_jobspec(runtime, env, release)
- docker_images.append(job.tag)
- build_jobs.append(job)
-
- jobset.message('START', 'Building interop docker images.', do_newline=True)
- print('Jobs to run: \n%s\n' % '\n'.join(str(j) for j in build_jobs))
-
- num_failures, _ = jobset.run(
- build_jobs, newline_on_success=True, maxjobs=multiprocessing.cpu_count())
- if num_failures:
- jobset.message('FAILED', 'Failed to build interop docker images.',
- do_newline=True)
- docker_images_cleanup.extend(docker_images)
- sys.exit(1)
-
- jobset.message('SUCCESS',
- 'All docker images built for %s at %s.' % (lang, release),
- do_newline=True)
-
- if release != 'master':
- commit_log = os.path.join(stack_base, 'commit_log')
- if os.path.exists(commit_log):
- for image in docker_images:
- add_files_to_image(image, [commit_log], 'release=%s' % release)
- return docker_images
+ """Build all docker images for a release across all runtimes."""
+ docker_images = []
+ build_jobs = []
+
+ env = {}
+ # If we not using current tree or the sibling for grpc stack, do checkout.
+ stack_base = ''
+ if args.git_checkout:
+ stack_base = checkout_grpc_stack(lang, release)
+ var = {
+ 'go': 'GRPC_GO_ROOT',
+ 'java': 'GRPC_JAVA_ROOT',
+ 'node': 'GRPC_NODE_ROOT'
+ }.get(lang, 'GRPC_ROOT')
+ env[var] = stack_base
+
+ for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]:
+ job = build_image_jobspec(runtime, env, release, stack_base)
+ docker_images.append(job.tag)
+ build_jobs.append(job)
+
+ jobset.message('START', 'Building interop docker images.', do_newline=True)
+ print('Jobs to run: \n%s\n' % '\n'.join(str(j) for j in build_jobs))
+
+ num_failures, _ = jobset.run(
+ build_jobs,
+ newline_on_success=True,
+ maxjobs=multiprocessing.cpu_count())
+ if num_failures:
+ jobset.message(
+ 'FAILED', 'Failed to build interop docker images.', do_newline=True)
+ docker_images_cleanup.extend(docker_images)
+ sys.exit(1)
+
+ jobset.message(
+ 'SUCCESS',
+ 'All docker images built for %s at %s.' % (lang, release),
+ do_newline=True)
+
+ if release != 'master':
+ commit_log = os.path.join(stack_base, 'commit_log')
+ if os.path.exists(commit_log):
+ for image in docker_images:
+ add_files_to_image(image, [commit_log], 'release=%s' % release)
+ return docker_images
+
def cleanup():
- if not args.keep:
- for image in docker_images_cleanup:
- dockerjob.remove_image(image, skip_nonexistent=True)
+ if not args.keep:
+ for image in docker_images_cleanup:
+ dockerjob.remove_image(image, skip_nonexistent=True)
+
docker_images_cleanup = []
atexit.register(cleanup)
+
+def maybe_apply_patches_on_git_tag(stack_base, lang, release):
+ files_to_patch = []
+ for release_info in client_matrix.LANG_RELEASE_MATRIX[lang]:
+ if client_matrix.get_release_tag_name(release_info) == release:
+ if release_info[release] is not None:
+ files_to_patch = release_info[release].get('patch')
+ break
+ if not files_to_patch:
+ return
+ patch_file_relative_path = 'patches/%s_%s/git_repo.patch' % (lang, release)
+ patch_file = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), patch_file_relative_path))
+ if not os.path.exists(patch_file):
+ jobset.message('FAILED',
+ 'expected patch file |%s| to exist' % patch_file)
+ sys.exit(1)
+ subprocess.check_output(
+ ['git', 'apply', patch_file], cwd=stack_base, stderr=subprocess.STDOUT)
+ for repo_relative_path in files_to_patch:
+ subprocess.check_output(
+ ['git', 'add', repo_relative_path],
+ cwd=stack_base,
+ stderr=subprocess.STDOUT)
+ subprocess.check_output(
+ [
+ 'git', 'commit', '-m',
+ ('Hack performed on top of %s git '
+ 'tag in order to build and run the %s '
+ 'interop tests on that tag.' % (lang, release))
+ ],
+ cwd=stack_base,
+ stderr=subprocess.STDOUT)
+
+
def checkout_grpc_stack(lang, release):
- """Invokes 'git check' for the lang/release and returns directory created."""
- assert args.git_checkout and args.git_checkout_root
-
- if not os.path.exists(args.git_checkout_root):
- os.makedirs(args.git_checkout_root)
-
- repo = client_matrix.get_github_repo(lang)
- # Get the subdir name part of repo
- # For example, 'git@github.com:grpc/grpc-go.git' should use 'grpc-go'.
- repo_dir = os.path.splitext(os.path.basename(repo))[0]
- stack_base = os.path.join(args.git_checkout_root, repo_dir)
-
- # Assume the directory is reusable for git checkout.
- if not os.path.exists(stack_base):
- subprocess.check_call(['git', 'clone', '--recursive', repo],
- cwd=os.path.dirname(stack_base))
-
- # git checkout.
- jobset.message('START', 'git checkout %s from %s' % (release, stack_base),
- do_newline=True)
- # We should NEVER do checkout on current tree !!!
- assert not os.path.dirname(__file__).startswith(stack_base)
- output = subprocess.check_output(
- ['git', 'checkout', release], cwd=stack_base, stderr=subprocess.STDOUT)
- commit_log = subprocess.check_output(['git', 'log', '-1'], cwd=stack_base)
- jobset.message('SUCCESS', 'git checkout', output + commit_log, do_newline=True)
-
- # Write git log to commit_log so it can be packaged with the docker image.
- with open(os.path.join(stack_base, 'commit_log'), 'w') as f:
- f.write(commit_log)
- return stack_base
+ """Invokes 'git check' for the lang/release and returns directory created."""
+ assert args.git_checkout and args.git_checkout_root
+
+ if not os.path.exists(args.git_checkout_root):
+ os.makedirs(args.git_checkout_root)
+
+ repo = client_matrix.get_github_repo(lang)
+ # Get the subdir name part of repo
+ # For example, 'git@github.com:grpc/grpc-go.git' should use 'grpc-go'.
+ repo_dir = os.path.splitext(os.path.basename(repo))[0]
+ stack_base = os.path.join(args.git_checkout_root, repo_dir)
+
+ # Clean up leftover repo dir if necessary.
+ if not args.reuse_git_root and os.path.exists(stack_base):
+ jobset.message('START', 'Removing git checkout root.', do_newline=True)
+ shutil.rmtree(stack_base)
+
+ if not os.path.exists(stack_base):
+ subprocess.check_call(
+ ['git', 'clone', '--recursive', repo],
+ cwd=os.path.dirname(stack_base))
+
+ # git checkout.
+ jobset.message(
+ 'START',
+ 'git checkout %s from %s' % (release, stack_base),
+ do_newline=True)
+ # We should NEVER do checkout on current tree !!!
+ assert not os.path.dirname(__file__).startswith(stack_base)
+ output = subprocess.check_output(
+ ['git', 'checkout', release], cwd=stack_base, stderr=subprocess.STDOUT)
+ maybe_apply_patches_on_git_tag(stack_base, lang, release)
+ commit_log = subprocess.check_output(['git', 'log', '-1'], cwd=stack_base)
+ jobset.message(
+ 'SUCCESS',
+ 'git checkout',
+ '%s: %s' % (str(output), commit_log),
+ do_newline=True)
+
+ # Write git log to commit_log so it can be packaged with the docker image.
+ with open(os.path.join(stack_base, 'commit_log'), 'w') as f:
+ f.write(commit_log)
+ return stack_base
+
languages = args.language if args.language != ['all'] else _LANGUAGES
for lang in languages:
- docker_images = build_all_images_for_lang(lang)
- for image in docker_images:
- jobset.message('START', 'Uploading %s' % image, do_newline=True)
- # docker image name must be in the format <gcr_path>/<image>:<gcr_tag>
- assert image.startswith(args.gcr_path) and image.find(':') != -1
+ docker_images = build_all_images_for_lang(lang)
+ for image in docker_images:
+ jobset.message('START', 'Uploading %s' % image, do_newline=True)
+ # docker image name must be in the format <gcr_path>/<image>:<gcr_tag>
+ assert image.startswith(args.gcr_path) and image.find(':') != -1
- subprocess.call(['gcloud', 'docker', '--', 'push', image])
+ subprocess.call(['gcloud', 'docker', '--', 'push', image])
diff --git a/tools/interop_matrix/create_testcases.sh b/tools/interop_matrix/create_testcases.sh
index d06fb34ff9..fa33fa4615 100755
--- a/tools/interop_matrix/create_testcases.sh
+++ b/tools/interop_matrix/create_testcases.sh
@@ -31,10 +31,6 @@ TESTCASES_DIR=${GRPC_ROOT}/tools/interop_matrix/testcases
echo "Create '$LANG' test cases for gRPC release '${RELEASE:=master}'"
-# Invoke run_interop_test in manual mode.
-${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $LANG --use_docker \
- --cloud_to_prod --manual_run
-
# Clean up
function cleanup {
[ -z "$testcase" ] && testcase=$CMDS_SH
@@ -51,12 +47,28 @@ function cleanup {
fi
[ -e "$CMDS_SH" ] && rm $CMDS_SH
}
+
+function createtests {
+# Invoke run_interop_test in manual mode.
+# TODO(adelez): Add cloud_gateways when we figure out how to skip them if not
+# running in GCE.
+if [ $1 == "cxx" ]; then
+client_lang="c++"
+else
+client_lang=$1
+fi
+echo $client_lang
+
+${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $client_lang --use_docker \
+ --cloud_to_prod --prod_servers default gateway_v4 --manual_run
+
trap cleanup EXIT
+# TODO(adelez): add test auth tests but do not run if not testing on GCE.
# Running the testcases as sanity unless we are asked to skip.
[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH)
mkdir -p $TESTCASES_DIR
-testcase=$TESTCASES_DIR/${LANG}__$RELEASE
+testcase=$TESTCASES_DIR/$1__$RELEASE
if [ -e $testcase ]; then
echo "Updating: $testcase"
diff $testcase $CMDS_SH || true
@@ -64,3 +76,11 @@ fi
mv $CMDS_SH $testcase
chmod a+x $testcase
echo "Test cases created: $testcase"
+}
+
+if [ $LANG == "csharp" ]; then
+createtests "csharp"
+createtests "csharpcoreclr"
+else
+createtests $LANG
+fi
diff --git a/tools/interop_matrix/patches/README.md b/tools/interop_matrix/patches/README.md
new file mode 100644
index 0000000000..0c0893f6f2
--- /dev/null
+++ b/tools/interop_matrix/patches/README.md
@@ -0,0 +1,38 @@
+# Patches to grpc repo tags for the backwards compatibility interop tests
+
+This directory has patch files that can be applied to different tags
+of the grpc git repo in order to run the interop tests for a specific
+language based on that tag.
+
+For example, because the ruby interop tests do not run on the v1.0.1 tag out
+of the box, but we still want to test compatibility of the 1.0.1 ruby release
+with other versions, we can apply a patch to the v1.0.1 tag from this directory
+that makes the necessary changes that are needed to run the ruby interop tests
+from that tag. We can then use that patch to build the docker image for the
+ruby v1.0.1 interop tests.
+
+## How to add a new patch to this directory
+
+Patch files in this directory are meant to be applied to a git tag
+with a `git apply` command.
+
+1. Under the `patches` directory, create a new subdirectory
+titled `<language>_<git_tag>` for the git tag being modified.
+
+2. `git checkout <git_tag>`
+
+3. Make necessary modifications to the git repo at that tag.
+
+4.
+
+```
+git diff > ~/git_repo.patch
+git checkout <current working branch>
+cp ~/git_repo.patch tools/interop_matrix/patches/<language>_<git_tag>/
+```
+
+5. Edit the `LANGUAGE_RELEASE_MATRIX` in `client_matrix.py` for your language/tag
+and add a `'patch': [<files>,....]` entry to it's `dictionary`.
+
+After doing this, the interop image creation script can apply that patch to the
+tag with `git apply` before uploading to the test image repo.
diff --git a/tools/interop_matrix/patches/ruby_v1.0.1/git_repo.patch b/tools/interop_matrix/patches/ruby_v1.0.1/git_repo.patch
new file mode 100644
index 0000000000..0cd92d691d
--- /dev/null
+++ b/tools/interop_matrix/patches/ruby_v1.0.1/git_repo.patch
@@ -0,0 +1,34 @@
+diff --git a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
+index 88b5130..7ae9f7d 100644
+--- a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
++++ b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
+@@ -70,12 +70,12 @@ RUN apt-get update && apt-get install -y time && apt-get clean
+ RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+ RUN \curl -sSL https://get.rvm.io | bash -s stable
+
+-# Install Ruby 2.1
+-RUN /bin/bash -l -c "rvm install ruby-2.1"
+-RUN /bin/bash -l -c "rvm use --default ruby-2.1"
++# Install Ruby 2.1.8
++RUN /bin/bash -l -c "rvm install ruby-2.1.8"
++RUN /bin/bash -l -c "rvm use --default ruby-2.1.8"
+ RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
+ RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+-RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
++RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1.8' >> ~/.bashrc"
+ RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+
+ # Prepare ccache
+diff --git a/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh
+index 97b3860..cec046d 100755
+--- a/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh
++++ b/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh
+@@ -38,7 +38,7 @@ git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
+ cp -r /var/local/jenkins/service_account $HOME || true
+
+ cd /var/local/git/grpc
+-rvm --default use ruby-2.1
++rvm --default use ruby-2.1.8
+
+ # build Ruby interop client and server
+ (cd src/ruby && gem update bundler && bundle && rake compile)
diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py
index 4315c8277d..3391ef51cc 100755
--- a/tools/interop_matrix/run_interop_matrix_tests.py
+++ b/tools/interop_matrix/run_interop_matrix_tests.py
@@ -12,7 +12,6 @@
# 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.
-
"""Run tests using docker images in Google Container Registry per matrix."""
from __future__ import print_function
@@ -30,159 +29,221 @@ import uuid
# Langauage Runtime Matrix
import client_matrix
-python_util_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../run_tests/python_utils'))
+python_util_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../run_tests/python_utils'))
sys.path.append(python_util_dir)
import dockerjob
import jobset
import report_utils
+import upload_test_results
_LANGUAGES = client_matrix.LANG_RUNTIME_MATRIX.keys()
# All gRPC release tags, flattened, deduped and sorted.
-_RELEASES = sorted(list(set(
- i for l in client_matrix.LANG_RELEASE_MATRIX.values() for i in l)))
+_RELEASES = sorted(
+ list(
+ set(
+ client_matrix.get_release_tag_name(info)
+ for lang in client_matrix.LANG_RELEASE_MATRIX.values()
+ for info in lang)))
_TEST_TIMEOUT = 30
argp = argparse.ArgumentParser(description='Run interop tests.')
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
-argp.add_argument('--gcr_path',
- default='gcr.io/grpc-testing',
- help='Path of docker images in Google Container Registry')
-
-argp.add_argument('--release',
- default='master',
- choices=['all', 'master'] + _RELEASES,
- help='Release tags to test. When testing all '
- 'releases defined in client_matrix.py, use "all".')
-
-argp.add_argument('-l', '--language',
- choices=['all'] + sorted(_LANGUAGES),
- nargs='+',
- default=['all'],
- help='Languages to test')
-
-argp.add_argument('--keep',
- action='store_true',
- help='keep the created local images after finishing the tests.')
-
-argp.add_argument('--report_file',
- default='report.xml',
- help='The result file to create.')
+argp.add_argument(
+ '--gcr_path',
+ default='gcr.io/grpc-testing',
+ help='Path of docker images in Google Container Registry')
+argp.add_argument(
+ '--release',
+ default='all',
+ choices=['all', 'master'] + _RELEASES,
+ help='Release tags to test. When testing all '
+ 'releases defined in client_matrix.py, use "all".')
+
+argp.add_argument(
+ '-l',
+ '--language',
+ choices=['all'] + sorted(_LANGUAGES),
+ nargs='+',
+ default=['all'],
+ help='Languages to test')
+
+argp.add_argument(
+ '--keep',
+ action='store_true',
+ help='keep the created local images after finishing the tests.')
+
+argp.add_argument(
+ '--report_file', default='report.xml', help='The result file to create.')
+
+argp.add_argument(
+ '--allow_flakes',
+ default=False,
+ action='store_const',
+ const=True,
+ help=('Allow flaky tests to show as passing (re-runs failed '
+ 'tests up to five times)'))
+argp.add_argument(
+ '--bq_result_table',
+ default='',
+ type=str,
+ nargs='?',
+ help='Upload test results to a specified BQ table.')
args = argp.parse_args()
+print(str(args))
+
def find_all_images_for_lang(lang):
- """Find docker images for a language across releases and runtimes.
+ """Find docker images for a language across releases and runtimes.
Returns dictionary of list of (<tag>, <image-full-path>) keyed by runtime.
"""
- # Find all defined releases.
- if args.release == 'all':
- releases = ['master'] + client_matrix.LANG_RELEASE_MATRIX[lang]
- else:
- # Look for a particular release.
- if args.release not in ['master'] + client_matrix.LANG_RELEASE_MATRIX[lang]:
- jobset.message('SKIPPED',
- '%s for %s is not defined' % (args.release, lang),
- do_newline=True)
- return []
- releases = [args.release]
-
- # Images tuples keyed by runtime.
- images = {}
- for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]:
- image_path = '%s/grpc_interop_%s' % (args.gcr_path, runtime)
- output = subprocess.check_output(['gcloud', 'beta', 'container', 'images',
- 'list-tags', '--format=json', image_path])
- docker_image_list = json.loads(output)
- # All images should have a single tag or no tag.
- tags = [i['tags'][0] for i in docker_image_list if i['tags']]
- jobset.message('START', 'Found images for %s: %s' % (image_path, tags),
- do_newline=True)
- skipped = len(docker_image_list) - len(tags)
- jobset.message('START', 'Skipped images (no-tag/unknown-tag): %d' % skipped,
- do_newline=True)
- # Filter tags based on the releases.
- images[runtime] = [(tag,'%s:%s' % (image_path,tag)) for tag in tags if
- tag in releases]
- return images
+ # Find all defined releases.
+ if args.release == 'all':
+ releases = ['master'] + client_matrix.get_release_tags(lang)
+ else:
+ # Look for a particular release.
+ if args.release not in ['master'
+ ] + client_matrix.get_release_tags(lang):
+ jobset.message(
+ 'SKIPPED',
+ '%s for %s is not defined' % (args.release, lang),
+ do_newline=True)
+ return {}
+ releases = [args.release]
+
+ # Images tuples keyed by runtime.
+ images = {}
+ for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]:
+ image_path = '%s/grpc_interop_%s' % (args.gcr_path, runtime)
+ output = subprocess.check_output([
+ 'gcloud', 'beta', 'container', 'images', 'list-tags',
+ '--format=json', image_path
+ ])
+ docker_image_list = json.loads(output)
+ # All images should have a single tag or no tag.
+ # TODO(adelez): Remove tagless images.
+ tags = [i['tags'][0] for i in docker_image_list if i['tags']]
+ jobset.message(
+ 'START',
+ 'Found images for %s: %s' % (image_path, tags),
+ do_newline=True)
+ skipped = len(docker_image_list) - len(tags)
+ jobset.message(
+ 'SKIPPED',
+ 'Skipped images (no-tag/unknown-tag): %d' % skipped,
+ do_newline=True)
+ # Filter tags based on the releases.
+ images[runtime] = [(tag, '%s:%s' % (image_path, tag))
+ for tag in tags
+ if tag in releases]
+ return images
+
# caches test cases (list of JobSpec) loaded from file. Keyed by lang and runtime.
-_loaded_testcases = {}
-def find_test_cases(lang, release):
- """Returns the list of test cases from testcase files per lang/release."""
- file_tmpl = os.path.join(os.path.dirname(__file__), 'testcases/%s__%s')
- if not os.path.exists(file_tmpl % (lang, release)):
- release = 'master'
- testcases = file_tmpl % (lang, release)
- if lang in _loaded_testcases.keys() and release in _loaded_testcases[lang].keys():
- return _loaded_testcases[lang][release]
-
- job_spec_list=[]
- try:
- with open(testcases) as f:
- # Only line start with 'docker run' are test cases.
- for line in f.readlines():
- if line.startswith('docker run'):
- m = re.search('--test_case=(.*)"', line)
- shortname = m.group(1) if m else 'unknown_test'
- spec = jobset.JobSpec(cmdline=line,
- shortname=shortname,
- timeout_seconds=_TEST_TIMEOUT,
- shell=True)
- job_spec_list.append(spec)
- jobset.message('START',
- 'Loaded %s tests from %s' % (len(job_spec_list), testcases),
- do_newline=True)
- except IOError as err:
- jobset.message('FAILED', err, do_newline=True)
- if lang not in _loaded_testcases.keys():
- _loaded_testcases[lang] = {}
- _loaded_testcases[lang][release]=job_spec_list
- return job_spec_list
+def find_test_cases(lang, runtime, release, suite_name):
+ """Returns the list of test cases from testcase files per lang/release."""
+ file_tmpl = os.path.join(os.path.dirname(__file__), 'testcases/%s__%s')
+ testcase_release = release
+ filename_prefix = lang
+ if lang == 'csharp':
+ filename_prefix = runtime
+ if not os.path.exists(file_tmpl % (filename_prefix, release)):
+ testcase_release = 'master'
+ testcases = file_tmpl % (filename_prefix, testcase_release)
+
+ job_spec_list = []
+ try:
+ with open(testcases) as f:
+ # Only line start with 'docker run' are test cases.
+ for line in f.readlines():
+ if line.startswith('docker run'):
+ m = re.search('--test_case=(.*)"', line)
+ shortname = m.group(1) if m else 'unknown_test'
+ m = re.search(
+ '--server_host_override=(.*).sandbox.googleapis.com',
+ line)
+ server = m.group(1) if m else 'unknown_server'
+ spec = jobset.JobSpec(
+ cmdline=line,
+ shortname='%s:%s:%s:%s' % (suite_name, lang, server,
+ shortname),
+ timeout_seconds=_TEST_TIMEOUT,
+ shell=True,
+ flake_retries=5 if args.allow_flakes else 0)
+ job_spec_list.append(spec)
+ jobset.message(
+ 'START',
+ 'Loaded %s tests from %s' % (len(job_spec_list), testcases),
+ do_newline=True)
+ except IOError as err:
+ jobset.message('FAILED', err, do_newline=True)
+ return job_spec_list
+
_xml_report_tree = report_utils.new_junit_xml_tree()
+
+
def run_tests_for_lang(lang, runtime, images):
- """Find and run all test cases for a language.
+ """Find and run all test cases for a language.
images is a list of (<release-tag>, <image-full-path>) tuple.
"""
- for image_tuple in images:
- release, image = image_tuple
- jobset.message('START', 'Testing %s' % image, do_newline=True)
- # Download the docker image before running each test case.
- subprocess.check_call(['gcloud', 'docker', '--', 'pull', image])
- _docker_images_cleanup.append(image)
- job_spec_list = find_test_cases(lang,release)
- num_failures, resultset = jobset.run(job_spec_list,
- newline_on_success=True,
- add_env={'docker_image':image},
- maxjobs=args.jobs)
- if num_failures:
- jobset.message('FAILED', 'Some tests failed', do_newline=True)
- else:
- jobset.message('SUCCESS', 'All tests passed', do_newline=True)
-
- report_utils.append_junit_xml_results(
- _xml_report_tree,
- resultset,
- 'grpc_interop_matrix',
- '%s__%s %s'%(lang,runtime,release),
- str(uuid.uuid4()))
+ total_num_failures = 0
+ for image_tuple in images:
+ release, image = image_tuple
+ jobset.message('START', 'Testing %s' % image, do_newline=True)
+ # Download the docker image before running each test case.
+ subprocess.check_call(['gcloud', 'docker', '--', 'pull', image])
+ suite_name = '%s__%s_%s' % (lang, runtime, release)
+ job_spec_list = find_test_cases(lang, runtime, release, suite_name)
+
+ if not job_spec_list:
+ jobset.message(
+ 'FAILED', 'No test cases were found.', do_newline=True)
+ return 1
+
+ num_failures, resultset = jobset.run(
+ job_spec_list,
+ newline_on_success=True,
+ add_env={'docker_image': image},
+ maxjobs=args.jobs)
+ if args.bq_result_table and resultset:
+ upload_test_results.upload_interop_results_to_bq(
+ resultset, args.bq_result_table, args)
+ if num_failures:
+ jobset.message('FAILED', 'Some tests failed', do_newline=True)
+ total_num_failures += num_failures
+ else:
+ jobset.message('SUCCESS', 'All tests passed', do_newline=True)
+
+ report_utils.append_junit_xml_results(_xml_report_tree, resultset,
+ 'grpc_interop_matrix', suite_name,
+ str(uuid.uuid4()))
+
+ if not args.keep:
+ cleanup(image)
+
+ return total_num_failures
+
+
+def cleanup(image):
+ jobset.message('START', 'Cleanup docker image %s' % image, do_newline=True)
+ dockerjob.remove_image(image, skip_nonexistent=True)
-_docker_images_cleanup = []
-def cleanup():
- if not args.keep:
- for image in _docker_images_cleanup:
- dockerjob.remove_image(image, skip_nonexistent=True)
-
-atexit.register(cleanup)
languages = args.language if args.language != ['all'] else _LANGUAGES
+total_num_failures = 0
for lang in languages:
- docker_images = find_all_images_for_lang(lang)
- for runtime in sorted(docker_images.keys()):
- run_tests_for_lang(lang, runtime, docker_images[runtime])
+ docker_images = find_all_images_for_lang(lang)
+ for runtime in sorted(docker_images.keys()):
+ total_num_failures += run_tests_for_lang(lang, runtime,
+ docker_images[runtime])
report_utils.create_xml_report_file(_xml_report_tree, args.report_file)
+
+if total_num_failures:
+ sys.exit(1)
+sys.exit(0)
diff --git a/tools/interop_matrix/testcases/csharp__master b/tools/interop_matrix/testcases/csharp__master
new file mode 100644
index 0000000000..32f6b38041
--- /dev/null
+++ b/tools/interop_matrix/testcases/csharp__master
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_csharp:a95229ca-d387-4127-ad48-69a7464e23b8}"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/csharp__v1.1.4 b/tools/interop_matrix/testcases/csharp__v1.1.4
new file mode 100644
index 0000000000..19da788c12
--- /dev/null
+++ b/tools/interop_matrix/testcases/csharp__v1.1.4
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_csharp:a95229ca-d387-4127-ad48-69a7464e23b8}"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/csharp__v1.2.5 b/tools/interop_matrix/testcases/csharp__v1.2.5
new file mode 100644
index 0000000000..19da788c12
--- /dev/null
+++ b/tools/interop_matrix/testcases/csharp__v1.2.5
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_csharp:a95229ca-d387-4127-ad48-69a7464e23b8}"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/csharpcoreclr__master b/tools/interop_matrix/testcases/csharpcoreclr__master
new file mode 100644
index 0000000000..37e45989b2
--- /dev/null
+++ b/tools/interop_matrix/testcases/csharpcoreclr__master
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_csharpcoreclr:c7fbed09-e4c1-4aab-8dd9-1285b2c9598e}"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/cxx__master b/tools/interop_matrix/testcases/cxx__master
index ccd2859530..e0fed53f08 100755
--- a/tools/interop_matrix/testcases/cxx__master
+++ b/tools/interop_matrix/testcases/cxx__master
@@ -1,5 +1,5 @@
#!/bin/bash
-echo "Testing ${docker_image:=grpc_interop_cxx:1423f288-ac00-4f3a-9885-771258eecae3}"
+echo "Testing ${docker_image:=grpc_interop_cxx:78de6f80-524d-4bc9-bfb2-f00c24ceafed}"
docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
@@ -9,3 +9,12 @@ docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c
docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/go__master b/tools/interop_matrix/testcases/go__master
index 2624c7f92c..33b25d6a16 100755
--- a/tools/interop_matrix/testcases/go__master
+++ b/tools/interop_matrix/testcases/go__master
@@ -1,5 +1,5 @@
#!/bin/bash
-echo "Testing ${docker_image:=grpc_interop_go:41fffd01-a6c8-41b6-8136-c0aaa1ec2437}"
+echo "Testing ${docker_image:=grpc_interop_go:dd8fbf3a-4964-4387-9997-5dadeea09835}"
docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
@@ -9,3 +9,12 @@ docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=h
docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/java__master b/tools/interop_matrix/testcases/java__master
index cf431646e9..dbd87279a6 100755
--- a/tools/interop_matrix/testcases/java__master
+++ b/tools/interop_matrix/testcases/java__master
@@ -1,5 +1,5 @@
#!/bin/bash
-echo "Testing ${docker_image:=grpc_interop_java:ea528843-be34-4ff3-a136-e4609424e061}"
+echo "Testing ${docker_image:=grpc_interop_java:a764b50c-1788-4387-9b9e-5cfa93927006}"
docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
@@ -9,3 +9,12 @@ docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_i
docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/node__master b/tools/interop_matrix/testcases/node__master
new file mode 100755
index 0000000000..99ea2f0bc4
--- /dev/null
+++ b/tools/interop_matrix/testcases/node__master
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_node:1415ecbf-5d0f-423e-8c2c-e0cb6d154e73}"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/node__v1.0.1 b/tools/interop_matrix/testcases/node__v1.0.1
new file mode 100644
index 0000000000..6faf321391
--- /dev/null
+++ b/tools/interop_matrix/testcases/node__v1.0.1
@@ -0,0 +1,21 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_node:a53aa5e3-b548-4566-b5a8-6d15c1315b32}"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_00c688f2-57da-4023-89f3-46b1f7b5869f $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_d86705d8-14ea-4024-90b6-de74d6e8d19c $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_ebaafacd-1d82-4a75-bea1-a5c64e01fcaf $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_5125241a-fbf6-4c1c-895b-026a5a41f02f $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_3d5e5b82-7205-4eba-b775-8122f05a4760 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_16fa0b49-2083-4932-8f26-79cfdffec940 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_23cee670-2d8d-4f5c-8893-c3c43da8b03a $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_7b6a9454-e3b6-4993-b542-468e268930aa $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_5a7109ed-c065-4b62-98f4-b3ed8f385762 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_1e0ba8dd-4dc1-431b-b202-529e7ace5d1d $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_649de56a-e722-4a59-b265-e9c0e871f068 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_8be512a2-5e1c-4858-8cfc-82f99b678b76 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_d19b6333-e528-48b5-8421-2ae3f7ce9dab $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_4749c80a-21c5-4d81-9df5-3c46ba6480cd $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_b7bee545-4857-4269-a1f2-9553dfc7e4b8 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_4e96db87-6f48-426d-a7f0-97f3a5b6b3f4 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_31a1d58c-f8bf-460a-af60-28969ecaaf80 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_ce64b147-bcfa-44b2-a2f7-4a485380ce30 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+
diff --git a/tools/interop_matrix/testcases/php__master b/tools/interop_matrix/testcases/php__master
new file mode 100755
index 0000000000..bce1d30550
--- /dev/null
+++ b/tools/interop_matrix/testcases/php__master
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_php:b290f404-9940-4968-8fc2-19f5291c8eb7}"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/python__master b/tools/interop_matrix/testcases/python__master
new file mode 100755
index 0000000000..4a63eae89d
--- /dev/null
+++ b/tools/interop_matrix/testcases/python__master
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_python:797ca293-94e8-48d4-92e9-a4d52fcfcca9}"
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response\""
+docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server\""
diff --git a/tools/interop_matrix/testcases/ruby__master b/tools/interop_matrix/testcases/ruby__master
new file mode 100755
index 0000000000..07bfd05866
--- /dev/null
+++ b/tools/interop_matrix/testcases/ruby__master
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_ruby:6bd1f0eb-51a4-4ad8-861c-1cbd7a929f33}"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/interop_matrix/testcases/ruby__v1.0.1 b/tools/interop_matrix/testcases/ruby__v1.0.1
new file mode 100755
index 0000000000..effbef1d18
--- /dev/null
+++ b/tools/interop_matrix/testcases/ruby__v1.0.1
@@ -0,0 +1,20 @@
+#!/bin/bash
+echo "Testing ${docker_image:=grpc_interop_ruby:6bd1f0eb-51a4-4ad8-861c-1cbd7a929f33}"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response"
+docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server"
diff --git a/tools/jenkins/run_full_performance.sh b/tools/jenkins/run_full_performance.sh
index a9661c7e26..8657cc9a73 100755
--- a/tools/jenkins/run_full_performance.sh
+++ b/tools/jenkins/run_full_performance.sh
@@ -21,7 +21,7 @@ cd $(dirname $0)/../..
# run 8core client vs 8core server
tools/run_tests/run_performance_tests.py \
- -l c++ csharp node ruby java python go node_express php \
+ -l c++ csharp ruby java python go php7 php7_protobuf_c \
--netperf \
--category scalable \
--bq_result_table performance_test.performance_experiment \
diff --git a/tools/jenkins/run_performance_profile_daily.sh b/tools/jenkins/run_performance_profile_daily.sh
index 04a2464aee..48d82a9b7f 100755
--- a/tools/jenkins/run_performance_profile_daily.sh
+++ b/tools/jenkins/run_performance_profile_daily.sh
@@ -29,4 +29,6 @@ fi
BENCHMARKS_TO_RUN="bm_fullstack_unary_ping_pong bm_fullstack_streaming_ping_pong bm_fullstack_streaming_pump bm_closure bm_cq bm_call_create bm_error bm_chttp2_hpack bm_chttp2_transport bm_pollset bm_metadata"
+./tools/run_tests/start_port_server.py || true
+
$PYTHON tools/run_tests/run_microbenchmark.py --collect summary perf latency -b $BENCHMARKS_TO_RUN
diff --git a/tools/line_count/collect-history.py b/tools/line_count/collect-history.py
index 3f030fbb8f..c8e33c9ed2 100755
--- a/tools/line_count/collect-history.py
+++ b/tools/line_count/collect-history.py
@@ -19,20 +19,24 @@ import datetime
# this script is only of historical interest: it's the script that was used to
# bootstrap the dataset
+
def daterange(start, end):
- for n in range(int((end - start).days)):
- yield start + datetime.timedelta(n)
+ for n in range(int((end - start).days)):
+ yield start + datetime.timedelta(n)
+
start_date = datetime.date(2017, 3, 26)
end_date = datetime.date(2017, 3, 29)
for dt in daterange(start_date, end_date):
- dmy = dt.strftime('%Y-%m-%d')
- sha1 = subprocess.check_output(['git', 'rev-list', '-n', '1',
- '--before=%s' % dmy,
- 'master']).strip()
- subprocess.check_call(['git', 'checkout', sha1])
- subprocess.check_call(['git', 'submodule', 'update'])
- subprocess.check_call(['git', 'clean', '-f', '-x', '-d'])
- subprocess.check_call(['cloc', '--vcs=git', '--by-file', '--yaml', '--out=../count/%s.yaml' % dmy, '.'])
-
+ dmy = dt.strftime('%Y-%m-%d')
+ sha1 = subprocess.check_output(
+ ['git', 'rev-list', '-n', '1',
+ '--before=%s' % dmy, 'master']).strip()
+ subprocess.check_call(['git', 'checkout', sha1])
+ subprocess.check_call(['git', 'submodule', 'update'])
+ subprocess.check_call(['git', 'clean', '-f', '-x', '-d'])
+ subprocess.check_call([
+ 'cloc', '--vcs=git', '--by-file', '--yaml',
+ '--out=../count/%s.yaml' % dmy, '.'
+ ])
diff --git a/tools/line_count/summarize-history.py b/tools/line_count/summarize-history.py
index d2ef7ec324..4a085999a5 100755
--- a/tools/line_count/summarize-history.py
+++ b/tools/line_count/summarize-history.py
@@ -13,22 +13,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
import subprocess
import datetime
# this script is only of historical interest: it's the script that was used to
# bootstrap the dataset
+
def daterange(start, end):
- for n in range(int((end - start).days)):
- yield start + datetime.timedelta(n)
+ for n in range(int((end - start).days)):
+ yield start + datetime.timedelta(n)
+
start_date = datetime.date(2017, 3, 26)
end_date = datetime.date(2017, 3, 29)
for dt in daterange(start_date, end_date):
- dmy = dt.strftime('%Y-%m-%d')
- print dmy
- subprocess.check_call(['tools/line_count/yaml2csv.py', '-i', '../count/%s.yaml' % dmy, '-d', dmy, '-o', '../count/%s.csv' % dmy])
-
+ dmy = dt.strftime('%Y-%m-%d')
+ print dmy
+ subprocess.check_call([
+ 'tools/line_count/yaml2csv.py', '-i',
+ '../count/%s.yaml' % dmy, '-d', dmy, '-o',
+ '../count/%s.csv' % dmy
+ ])
diff --git a/tools/line_count/yaml2csv.py b/tools/line_count/yaml2csv.py
index 2a38a12c80..dd2e92b360 100755
--- a/tools/line_count/yaml2csv.py
+++ b/tools/line_count/yaml2csv.py
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
import yaml
import argparse
import datetime
@@ -21,18 +20,22 @@ import csv
argp = argparse.ArgumentParser(description='Convert cloc yaml to bigquery csv')
argp.add_argument('-i', '--input', type=str)
-argp.add_argument('-d', '--date', type=str, default=datetime.date.today().strftime('%Y-%m-%d'))
+argp.add_argument(
+ '-d',
+ '--date',
+ type=str,
+ default=datetime.date.today().strftime('%Y-%m-%d'))
argp.add_argument('-o', '--output', type=str, default='out.csv')
args = argp.parse_args()
data = yaml.load(open(args.input).read())
with open(args.output, 'w') as outf:
- writer = csv.DictWriter(outf, ['date', 'name', 'language', 'code', 'comment', 'blank'])
- for key, value in data.iteritems():
- if key == 'header': continue
- if key == 'SUM': continue
- if key.startswith('third_party/'): continue
- row = {'name': key, 'date': args.date}
- row.update(value)
- writer.writerow(row)
-
+ writer = csv.DictWriter(
+ outf, ['date', 'name', 'language', 'code', 'comment', 'blank'])
+ for key, value in data.iteritems():
+ if key == 'header': continue
+ if key == 'SUM': continue
+ if key.startswith('third_party/'): continue
+ row = {'name': key, 'date': args.date}
+ row.update(value)
+ writer.writerow(row)
diff --git a/tools/mkowners/mkowners.py b/tools/mkowners/mkowners.py
index e0ad998bdc..2ea7265f88 100755
--- a/tools/mkowners/mkowners.py
+++ b/tools/mkowners/mkowners.py
@@ -24,10 +24,8 @@ import subprocess
# Find the root of the git tree
#
-git_root = (subprocess
- .check_output(['git', 'rev-parse', '--show-toplevel'])
- .decode('utf-8')
- .strip())
+git_root = (subprocess.check_output(['git', 'rev-parse', '--show-toplevel'])
+ .decode('utf-8').strip())
#
# Parse command line arguments
@@ -36,19 +34,23 @@ git_root = (subprocess
default_out = os.path.join(git_root, '.github', 'CODEOWNERS')
argp = argparse.ArgumentParser('Generate .github/CODEOWNERS file')
-argp.add_argument('--out', '-o',
- type=str,
- default=default_out,
- help='Output file (default %s)' % default_out)
+argp.add_argument(
+ '--out',
+ '-o',
+ type=str,
+ default=default_out,
+ help='Output file (default %s)' % default_out)
args = argp.parse_args()
#
# Walk git tree to locate all OWNERS files
#
-owners_files = [os.path.join(root, 'OWNERS')
- for root, dirs, files in os.walk(git_root)
- if 'OWNERS' in files]
+owners_files = [
+ os.path.join(root, 'OWNERS')
+ for root, dirs, files in os.walk(git_root)
+ if 'OWNERS' in files
+]
#
# Parse owners files
@@ -57,39 +59,40 @@ owners_files = [os.path.join(root, 'OWNERS')
Owners = collections.namedtuple('Owners', 'parent directives dir')
Directive = collections.namedtuple('Directive', 'who globs')
+
def parse_owners(filename):
- with open(filename) as f:
- src = f.read().splitlines()
- parent = True
- directives = []
- for line in src:
- line = line.strip()
- # line := directive | comment
- if not line: continue
- if line[0] == '#': continue
- # it's a directive
- directive = None
- if line == 'set noparent':
- parent = False
- elif line == '*':
- directive = Directive(who='*', globs=[])
- elif ' ' in line:
- (who, globs) = line.split(' ', 1)
- globs_list = [glob
- for glob in globs.split(' ')
- if glob]
- directive = Directive(who=who, globs=globs_list)
- else:
- directive = Directive(who=line, globs=[])
- if directive:
- directives.append(directive)
- return Owners(parent=parent,
- directives=directives,
- dir=os.path.relpath(os.path.dirname(filename), git_root))
-
-owners_data = sorted([parse_owners(filename)
- for filename in owners_files],
- key=operator.attrgetter('dir'))
+ with open(filename) as f:
+ src = f.read().splitlines()
+ parent = True
+ directives = []
+ for line in src:
+ line = line.strip()
+ # line := directive | comment
+ if not line: continue
+ if line[0] == '#': continue
+ # it's a directive
+ directive = None
+ if line == 'set noparent':
+ parent = False
+ elif line == '*':
+ directive = Directive(who='*', globs=[])
+ elif ' ' in line:
+ (who, globs) = line.split(' ', 1)
+ globs_list = [glob for glob in globs.split(' ') if glob]
+ directive = Directive(who=who, globs=globs_list)
+ else:
+ directive = Directive(who=line, globs=[])
+ if directive:
+ directives.append(directive)
+ return Owners(
+ parent=parent,
+ directives=directives,
+ dir=os.path.relpath(os.path.dirname(filename), git_root))
+
+
+owners_data = sorted(
+ [parse_owners(filename) for filename in owners_files],
+ key=operator.attrgetter('dir'))
#
# Modify owners so that parented OWNERS files point to the actual
@@ -98,24 +101,24 @@ owners_data = sorted([parse_owners(filename)
new_owners_data = []
for owners in owners_data:
- if owners.parent == True:
- best_parent = None
- best_parent_score = None
- for possible_parent in owners_data:
- if possible_parent is owners: continue
- rel = os.path.relpath(owners.dir, possible_parent.dir)
- # '..' ==> we had to walk up from possible_parent to get to owners
- # ==> not a parent
- if '..' in rel: continue
- depth = len(rel.split(os.sep))
- if not best_parent or depth < best_parent_score:
- best_parent = possible_parent
- best_parent_score = depth
- if best_parent:
- owners = owners._replace(parent = best_parent.dir)
- else:
- owners = owners._replace(parent = None)
- new_owners_data.append(owners)
+ if owners.parent == True:
+ best_parent = None
+ best_parent_score = None
+ for possible_parent in owners_data:
+ if possible_parent is owners: continue
+ rel = os.path.relpath(owners.dir, possible_parent.dir)
+ # '..' ==> we had to walk up from possible_parent to get to owners
+ # ==> not a parent
+ if '..' in rel: continue
+ depth = len(rel.split(os.sep))
+ if not best_parent or depth < best_parent_score:
+ best_parent = possible_parent
+ best_parent_score = depth
+ if best_parent:
+ owners = owners._replace(parent=best_parent.dir)
+ else:
+ owners = owners._replace(parent=None)
+ new_owners_data.append(owners)
owners_data = new_owners_data
#
@@ -123,106 +126,114 @@ owners_data = new_owners_data
# a CODEOWNERS file for GitHub
#
+
def full_dir(rules_dir, sub_path):
- return os.path.join(rules_dir, sub_path) if rules_dir != '.' else sub_path
+ return os.path.join(rules_dir, sub_path) if rules_dir != '.' else sub_path
+
# glob using git
gg_cache = {}
+
+
def git_glob(glob):
- global gg_cache
- if glob in gg_cache: return gg_cache[glob]
- r = set(subprocess
- .check_output(['git', 'ls-files', os.path.join(git_root, glob)])
- .decode('utf-8')
- .strip()
- .splitlines())
- gg_cache[glob] = r
- return r
+ global gg_cache
+ if glob in gg_cache: return gg_cache[glob]
+ r = set(
+ subprocess.check_output(
+ ['git', 'ls-files', os.path.join(git_root, glob)]).decode('utf-8')
+ .strip().splitlines())
+ gg_cache[glob] = r
+ return r
+
def expand_directives(root, directives):
- globs = collections.OrderedDict()
- # build a table of glob --> owners
- for directive in directives:
- for glob in directive.globs or ['**']:
- if glob not in globs:
- globs[glob] = []
- if directive.who not in globs[glob]:
- globs[glob].append(directive.who)
- # expand owners for intersecting globs
- sorted_globs = sorted(globs.keys(),
- key=lambda g: len(git_glob(full_dir(root, g))),
- reverse=True)
- out_globs = collections.OrderedDict()
- for glob_add in sorted_globs:
- who_add = globs[glob_add]
- pre_items = [i for i in out_globs.items()]
- out_globs[glob_add] = who_add.copy()
- for glob_have, who_have in pre_items:
- files_add = git_glob(full_dir(root, glob_add))
- files_have = git_glob(full_dir(root, glob_have))
- intersect = files_have.intersection(files_add)
- if intersect:
- for f in sorted(files_add): # sorted to ensure merge stability
- if f not in intersect:
- out_globs[os.path.relpath(f, start=root)] = who_add
- for who in who_have:
- if who not in out_globs[glob_add]:
- out_globs[glob_add].append(who)
- return out_globs
+ globs = collections.OrderedDict()
+ # build a table of glob --> owners
+ for directive in directives:
+ for glob in directive.globs or ['**']:
+ if glob not in globs:
+ globs[glob] = []
+ if directive.who not in globs[glob]:
+ globs[glob].append(directive.who)
+ # expand owners for intersecting globs
+ sorted_globs = sorted(
+ globs.keys(),
+ key=lambda g: len(git_glob(full_dir(root, g))),
+ reverse=True)
+ out_globs = collections.OrderedDict()
+ for glob_add in sorted_globs:
+ who_add = globs[glob_add]
+ pre_items = [i for i in out_globs.items()]
+ out_globs[glob_add] = who_add.copy()
+ for glob_have, who_have in pre_items:
+ files_add = git_glob(full_dir(root, glob_add))
+ files_have = git_glob(full_dir(root, glob_have))
+ intersect = files_have.intersection(files_add)
+ if intersect:
+ for f in sorted(files_add): # sorted to ensure merge stability
+ if f not in intersect:
+ out_globs[os.path.relpath(f, start=root)] = who_add
+ for who in who_have:
+ if who not in out_globs[glob_add]:
+ out_globs[glob_add].append(who)
+ return out_globs
+
def add_parent_to_globs(parent, globs, globs_dir):
- if not parent: return
- for owners in owners_data:
- if owners.dir == parent:
- owners_globs = expand_directives(owners.dir, owners.directives)
- for oglob, oglob_who in owners_globs.items():
- for gglob, gglob_who in globs.items():
- files_parent = git_glob(full_dir(owners.dir, oglob))
- files_child = git_glob(full_dir(globs_dir, gglob))
- intersect = files_parent.intersection(files_child)
- gglob_who_orig = gglob_who.copy()
- if intersect:
- for f in sorted(files_child): # sorted to ensure merge stability
- if f not in intersect:
- who = gglob_who_orig.copy()
- globs[os.path.relpath(f, start=globs_dir)] = who
- for who in oglob_who:
- if who not in gglob_who:
- gglob_who.append(who)
- add_parent_to_globs(owners.parent, globs, globs_dir)
- return
- assert(False)
+ if not parent: return
+ for owners in owners_data:
+ if owners.dir == parent:
+ owners_globs = expand_directives(owners.dir, owners.directives)
+ for oglob, oglob_who in owners_globs.items():
+ for gglob, gglob_who in globs.items():
+ files_parent = git_glob(full_dir(owners.dir, oglob))
+ files_child = git_glob(full_dir(globs_dir, gglob))
+ intersect = files_parent.intersection(files_child)
+ gglob_who_orig = gglob_who.copy()
+ if intersect:
+ for f in sorted(files_child
+ ): # sorted to ensure merge stability
+ if f not in intersect:
+ who = gglob_who_orig.copy()
+ globs[os.path.relpath(f, start=globs_dir)] = who
+ for who in oglob_who:
+ if who not in gglob_who:
+ gglob_who.append(who)
+ add_parent_to_globs(owners.parent, globs, globs_dir)
+ return
+ assert (False)
+
todo = owners_data.copy()
done = set()
with open(args.out, 'w') as out:
- out.write('# Auto-generated by the tools/mkowners/mkowners.py tool\n')
- out.write('# Uses OWNERS files in different modules throughout the\n')
- out.write('# repository as the source of truth for module ownership.\n')
- written_globs = []
- while todo:
- head, *todo = todo
- if head.parent and not head.parent in done:
- todo.append(head)
- continue
- globs = expand_directives(head.dir, head.directives)
- add_parent_to_globs(head.parent, globs, head.dir)
- for glob, owners in globs.items():
- skip = False
- for glob1, owners1, dir1 in reversed(written_globs):
- files = git_glob(full_dir(head.dir, glob))
- files1 = git_glob(full_dir(dir1, glob1))
- intersect = files.intersection(files1)
- if files == intersect:
- if sorted(owners) == sorted(owners1):
- skip = True # nothing new in this rule
- break
- elif intersect:
- # continuing would cause a semantic change since some files are
- # affected differently by this rule and CODEOWNERS is order dependent
- break
- if not skip:
- out.write('/%s %s\n' % (
- full_dir(head.dir, glob), ' '.join(owners)))
- written_globs.append((glob, owners, head.dir))
- done.add(head.dir)
+ out.write('# Auto-generated by the tools/mkowners/mkowners.py tool\n')
+ out.write('# Uses OWNERS files in different modules throughout the\n')
+ out.write('# repository as the source of truth for module ownership.\n')
+ written_globs = []
+ while todo:
+ head, *todo = todo
+ if head.parent and not head.parent in done:
+ todo.append(head)
+ continue
+ globs = expand_directives(head.dir, head.directives)
+ add_parent_to_globs(head.parent, globs, head.dir)
+ for glob, owners in globs.items():
+ skip = False
+ for glob1, owners1, dir1 in reversed(written_globs):
+ files = git_glob(full_dir(head.dir, glob))
+ files1 = git_glob(full_dir(dir1, glob1))
+ intersect = files.intersection(files1)
+ if files == intersect:
+ if sorted(owners) == sorted(owners1):
+ skip = True # nothing new in this rule
+ break
+ elif intersect:
+ # continuing would cause a semantic change since some files are
+ # affected differently by this rule and CODEOWNERS is order dependent
+ break
+ if not skip:
+ out.write('/%s %s\n' % (full_dir(head.dir, glob),
+ ' '.join(owners)))
+ written_globs.append((glob, owners, head.dir))
+ done.add(head.dir)
diff --git a/tools/profiling/bloat/bloat_diff.py b/tools/profiling/bloat/bloat_diff.py
new file mode 100755
index 0000000000..91611c2ca4
--- /dev/null
+++ b/tools/profiling/bloat/bloat_diff.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python2.7
+#
+# Copyright 2017 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import argparse
+import glob
+import multiprocessing
+import os
+import shutil
+import subprocess
+import sys
+
+sys.path.append(
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
+import comment_on_pr
+
+argp = argparse.ArgumentParser(description='Perform diff on microbenchmarks')
+
+argp.add_argument(
+ '-d',
+ '--diff_base',
+ type=str,
+ help='Commit or branch to compare the current one to')
+
+argp.add_argument('-j', '--jobs', type=int, default=multiprocessing.cpu_count())
+
+args = argp.parse_args()
+
+LIBS = [
+ 'libgrpc.so',
+ 'libgrpc++.so',
+]
+
+
+def build(where):
+ subprocess.check_call('make -j%d' % args.jobs, shell=True, cwd='.')
+ shutil.rmtree('bloat_diff_%s' % where, ignore_errors=True)
+ os.rename('libs', 'bloat_diff_%s' % where)
+
+
+build('new')
+
+if args.diff_base:
+ old = 'old'
+ where_am_i = subprocess.check_output(
+ ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
+ subprocess.check_call(['git', 'checkout', args.diff_base])
+ subprocess.check_call(['git', 'submodule', 'update'])
+ try:
+ try:
+ build('old')
+ except subprocess.CalledProcessError, e:
+ subprocess.check_call(['make', 'clean'])
+ build('old')
+ finally:
+ subprocess.check_call(['git', 'checkout', where_am_i])
+ subprocess.check_call(['git', 'submodule', 'update'])
+
+subprocess.check_call(
+ 'make -j%d' % args.jobs, shell=True, cwd='third_party/bloaty')
+
+text = ''
+for lib in LIBS:
+ text += '****************************************************************\n\n'
+ text += lib + '\n\n'
+ old_version = glob.glob('bloat_diff_old/opt/%s' % lib)
+ new_version = glob.glob('bloat_diff_new/opt/%s' % lib)
+ assert len(new_version) == 1
+ cmd = 'third_party/bloaty/bloaty -d compileunits,symbols'
+ if old_version:
+ assert len(old_version) == 1
+ text += subprocess.check_output(
+ '%s %s -- %s' % (cmd, new_version[0], old_version[0]), shell=True)
+ else:
+ text += subprocess.check_output(
+ '%s %s' % (cmd, new_version[0]), shell=True)
+ text += '\n\n'
+
+print text
+comment_on_pr.comment_on_pr('```\n%s\n```' % text)
diff --git a/tools/profiling/latency_profile/profile_analyzer.py b/tools/profiling/latency_profile/profile_analyzer.py
index 8a19afb761..e3d33574c2 100755
--- a/tools/profiling/latency_profile/profile_analyzer.py
+++ b/tools/profiling/latency_profile/profile_analyzer.py
@@ -23,7 +23,6 @@ import sys
import tabulate
import time
-
SELF_TIME = object()
TIME_FROM_SCOPE_START = object()
TIME_TO_SCOPE_END = object()
@@ -31,124 +30,129 @@ TIME_FROM_STACK_START = object()
TIME_TO_STACK_END = object()
TIME_FROM_LAST_IMPORTANT = object()
-
-argp = argparse.ArgumentParser(description='Process output of basic_prof builds')
+argp = argparse.ArgumentParser(
+ description='Process output of basic_prof builds')
argp.add_argument('--source', default='latency_trace.txt', type=str)
argp.add_argument('--fmt', choices=tabulate.tabulate_formats, default='simple')
argp.add_argument('--out', default='-', type=str)
args = argp.parse_args()
+
class LineItem(object):
- def __init__(self, line, indent):
- self.tag = line['tag']
- self.indent = indent
- self.start_time = line['t']
- self.end_time = None
- self.important = line['imp']
- self.filename = line['file']
- self.fileline = line['line']
- self.times = {}
+ def __init__(self, line, indent):
+ self.tag = line['tag']
+ self.indent = indent
+ self.start_time = line['t']
+ self.end_time = None
+ self.important = line['imp']
+ self.filename = line['file']
+ self.fileline = line['line']
+ self.times = {}
class ScopeBuilder(object):
- def __init__(self, call_stack_builder, line):
- self.call_stack_builder = call_stack_builder
- self.indent = len(call_stack_builder.stk)
- self.top_line = LineItem(line, self.indent)
- call_stack_builder.lines.append(self.top_line)
- self.first_child_pos = len(call_stack_builder.lines)
-
- def mark(self, line):
- line_item = LineItem(line, self.indent + 1)
- line_item.end_time = line_item.start_time
- self.call_stack_builder.lines.append(line_item)
-
- def finish(self, line):
- assert line['tag'] == self.top_line.tag, (
- 'expected %s, got %s; thread=%s; t0=%f t1=%f' %
- (self.top_line.tag, line['tag'], line['thd'], self.top_line.start_time,
- line['t']))
- final_time_stamp = line['t']
- assert self.top_line.end_time is None
- self.top_line.end_time = final_time_stamp
- self.top_line.important = self.top_line.important or line['imp']
- assert SELF_TIME not in self.top_line.times
- self.top_line.times[SELF_TIME] = final_time_stamp - self.top_line.start_time
- for line in self.call_stack_builder.lines[self.first_child_pos:]:
- if TIME_FROM_SCOPE_START not in line.times:
- line.times[TIME_FROM_SCOPE_START] = line.start_time - self.top_line.start_time
- line.times[TIME_TO_SCOPE_END] = final_time_stamp - line.end_time
+ def __init__(self, call_stack_builder, line):
+ self.call_stack_builder = call_stack_builder
+ self.indent = len(call_stack_builder.stk)
+ self.top_line = LineItem(line, self.indent)
+ call_stack_builder.lines.append(self.top_line)
+ self.first_child_pos = len(call_stack_builder.lines)
+
+ def mark(self, line):
+ line_item = LineItem(line, self.indent + 1)
+ line_item.end_time = line_item.start_time
+ self.call_stack_builder.lines.append(line_item)
+
+ def finish(self, line):
+ assert line['tag'] == self.top_line.tag, (
+ 'expected %s, got %s; thread=%s; t0=%f t1=%f' %
+ (self.top_line.tag, line['tag'], line['thd'],
+ self.top_line.start_time, line['t']))
+ final_time_stamp = line['t']
+ assert self.top_line.end_time is None
+ self.top_line.end_time = final_time_stamp
+ self.top_line.important = self.top_line.important or line['imp']
+ assert SELF_TIME not in self.top_line.times
+ self.top_line.times[
+ SELF_TIME] = final_time_stamp - self.top_line.start_time
+ for line in self.call_stack_builder.lines[self.first_child_pos:]:
+ if TIME_FROM_SCOPE_START not in line.times:
+ line.times[
+ TIME_FROM_SCOPE_START] = line.start_time - self.top_line.start_time
+ line.times[TIME_TO_SCOPE_END] = final_time_stamp - line.end_time
class CallStackBuilder(object):
- def __init__(self):
- self.stk = []
- self.signature = hashlib.md5()
- self.lines = []
-
- def finish(self):
- start_time = self.lines[0].start_time
- end_time = self.lines[0].end_time
- self.signature = self.signature.hexdigest()
- last_important = start_time
- for line in self.lines:
- line.times[TIME_FROM_STACK_START] = line.start_time - start_time
- line.times[TIME_TO_STACK_END] = end_time - line.end_time
- line.times[TIME_FROM_LAST_IMPORTANT] = line.start_time - last_important
- if line.important:
- last_important = line.end_time
- last_important = end_time
-
- def add(self, line):
- line_type = line['type']
- self.signature.update(line_type)
- self.signature.update(line['tag'])
- if line_type == '{':
- self.stk.append(ScopeBuilder(self, line))
- return False
- elif line_type == '}':
- assert self.stk, (
- 'expected non-empty stack for closing %s; thread=%s; t=%f' %
- (line['tag'], line['thd'], line['t']))
- self.stk.pop().finish(line)
- if not self.stk:
- self.finish()
- return True
- return False
- elif line_type == '.' or line_type == '!':
- self.stk[-1].mark(line)
- return False
- else:
- raise Exception('Unknown line type: \'%s\'' % line_type)
+ def __init__(self):
+ self.stk = []
+ self.signature = hashlib.md5()
+ self.lines = []
+
+ def finish(self):
+ start_time = self.lines[0].start_time
+ end_time = self.lines[0].end_time
+ self.signature = self.signature.hexdigest()
+ last_important = start_time
+ for line in self.lines:
+ line.times[TIME_FROM_STACK_START] = line.start_time - start_time
+ line.times[TIME_TO_STACK_END] = end_time - line.end_time
+ line.times[
+ TIME_FROM_LAST_IMPORTANT] = line.start_time - last_important
+ if line.important:
+ last_important = line.end_time
+ last_important = end_time
+
+ def add(self, line):
+ line_type = line['type']
+ self.signature.update(line_type)
+ self.signature.update(line['tag'])
+ if line_type == '{':
+ self.stk.append(ScopeBuilder(self, line))
+ return False
+ elif line_type == '}':
+ assert self.stk, (
+ 'expected non-empty stack for closing %s; thread=%s; t=%f' %
+ (line['tag'], line['thd'], line['t']))
+ self.stk.pop().finish(line)
+ if not self.stk:
+ self.finish()
+ return True
+ return False
+ elif line_type == '.' or line_type == '!':
+ self.stk[-1].mark(line)
+ return False
+ else:
+ raise Exception('Unknown line type: \'%s\'' % line_type)
class CallStack(object):
- def __init__(self, initial_call_stack_builder):
- self.count = 1
- self.signature = initial_call_stack_builder.signature
- self.lines = initial_call_stack_builder.lines
- for line in self.lines:
- for key, val in line.times.items():
- line.times[key] = [val]
-
- def add(self, call_stack_builder):
- assert self.signature == call_stack_builder.signature
- self.count += 1
- assert len(self.lines) == len(call_stack_builder.lines)
- for lsum, line in itertools.izip(self.lines, call_stack_builder.lines):
- assert lsum.tag == line.tag
- assert lsum.times.keys() == line.times.keys()
- for k, lst in lsum.times.iteritems():
- lst.append(line.times[k])
-
- def finish(self):
- for line in self.lines:
- for lst in line.times.itervalues():
- lst.sort()
+ def __init__(self, initial_call_stack_builder):
+ self.count = 1
+ self.signature = initial_call_stack_builder.signature
+ self.lines = initial_call_stack_builder.lines
+ for line in self.lines:
+ for key, val in line.times.items():
+ line.times[key] = [val]
+
+ def add(self, call_stack_builder):
+ assert self.signature == call_stack_builder.signature
+ self.count += 1
+ assert len(self.lines) == len(call_stack_builder.lines)
+ for lsum, line in itertools.izip(self.lines, call_stack_builder.lines):
+ assert lsum.tag == line.tag
+ assert lsum.times.keys() == line.times.keys()
+ for k, lst in lsum.times.iteritems():
+ lst.append(line.times[k])
+
+ def finish(self):
+ for line in self.lines:
+ for lst in line.times.itervalues():
+ lst.sort()
+
builder = collections.defaultdict(CallStackBuilder)
call_stacks = collections.defaultdict(CallStack)
@@ -156,26 +160,28 @@ call_stacks = collections.defaultdict(CallStack)
lines = 0
start = time.time()
with open(args.source) as f:
- for line in f:
- lines += 1
- inf = json.loads(line)
- thd = inf['thd']
- cs = builder[thd]
- if cs.add(inf):
- if cs.signature in call_stacks:
- call_stacks[cs.signature].add(cs)
- else:
- call_stacks[cs.signature] = CallStack(cs)
- del builder[thd]
+ for line in f:
+ lines += 1
+ inf = json.loads(line)
+ thd = inf['thd']
+ cs = builder[thd]
+ if cs.add(inf):
+ if cs.signature in call_stacks:
+ call_stacks[cs.signature].add(cs)
+ else:
+ call_stacks[cs.signature] = CallStack(cs)
+ del builder[thd]
time_taken = time.time() - start
-call_stacks = sorted(call_stacks.values(), key=lambda cs: cs.count, reverse=True)
+call_stacks = sorted(
+ call_stacks.values(), key=lambda cs: cs.count, reverse=True)
total_stacks = 0
for cs in call_stacks:
- total_stacks += cs.count
- cs.finish()
+ total_stacks += cs.count
+ cs.finish()
+
-def percentile(N, percent, key=lambda x:x):
+def percentile(N, percent, key=lambda x: x):
"""
Find the percentile of a list of values.
@@ -187,80 +193,83 @@ def percentile(N, percent, key=lambda x:x):
"""
if not N:
return None
- k = (len(N)-1) * percent
+ k = (len(N) - 1) * percent
f = math.floor(k)
c = math.ceil(k)
if f == c:
return key(N[int(k)])
- d0 = key(N[int(f)]) * (c-k)
- d1 = key(N[int(c)]) * (k-f)
- return d0+d1
+ d0 = key(N[int(f)]) * (c - k)
+ d1 = key(N[int(c)]) * (k - f)
+ return d0 + d1
+
def tidy_tag(tag):
- if tag[0:10] == 'GRPC_PTAG_':
- return tag[10:]
- return tag
+ if tag[0:10] == 'GRPC_PTAG_':
+ return tag[10:]
+ return tag
+
def time_string(values):
- num_values = len(values)
- return '%.1f/%.1f/%.1f' % (
- 1e6 * percentile(values, 0.5),
- 1e6 * percentile(values, 0.9),
- 1e6 * percentile(values, 0.99))
+ num_values = len(values)
+ return '%.1f/%.1f/%.1f' % (1e6 * percentile(values, 0.5),
+ 1e6 * percentile(values, 0.9),
+ 1e6 * percentile(values, 0.99))
+
def time_format(idx):
- def ent(line, idx=idx):
- if idx in line.times:
- return time_string(line.times[idx])
- return ''
- return ent
-BANNER = {
- 'simple': 'Count: %(count)d',
- 'html': '<h1>Count: %(count)d</h1>'
-}
+ def ent(line, idx=idx):
+ if idx in line.times:
+ return time_string(line.times[idx])
+ return ''
+
+ return ent
+
+
+BANNER = {'simple': 'Count: %(count)d', 'html': '<h1>Count: %(count)d</h1>'}
FORMAT = [
- ('TAG', lambda line: '..'*line.indent + tidy_tag(line.tag)),
- ('LOC', lambda line: '%s:%d' % (line.filename[line.filename.rfind('/')+1:], line.fileline)),
- ('IMP', lambda line: '*' if line.important else ''),
- ('FROM_IMP', time_format(TIME_FROM_LAST_IMPORTANT)),
- ('FROM_STACK_START', time_format(TIME_FROM_STACK_START)),
- ('SELF', time_format(SELF_TIME)),
- ('TO_STACK_END', time_format(TIME_TO_STACK_END)),
- ('FROM_SCOPE_START', time_format(TIME_FROM_SCOPE_START)),
- ('SELF', time_format(SELF_TIME)),
- ('TO_SCOPE_END', time_format(TIME_TO_SCOPE_END)),
+ ('TAG', lambda line: '..' * line.indent + tidy_tag(line.tag)),
+ ('LOC',
+ lambda line: '%s:%d' % (line.filename[line.filename.rfind('/') + 1:], line.fileline)
+ ),
+ ('IMP', lambda line: '*' if line.important else ''),
+ ('FROM_IMP', time_format(TIME_FROM_LAST_IMPORTANT)),
+ ('FROM_STACK_START', time_format(TIME_FROM_STACK_START)),
+ ('SELF', time_format(SELF_TIME)),
+ ('TO_STACK_END', time_format(TIME_TO_STACK_END)),
+ ('FROM_SCOPE_START', time_format(TIME_FROM_SCOPE_START)),
+ ('SELF', time_format(SELF_TIME)),
+ ('TO_SCOPE_END', time_format(TIME_TO_SCOPE_END)),
]
out = sys.stdout
if args.out != '-':
- out = open(args.out, 'w')
+ out = open(args.out, 'w')
if args.fmt == 'html':
- print >>out, '<html>'
- print >>out, '<head>'
- print >>out, '<title>Profile Report</title>'
- print >>out, '</head>'
+ print >> out, '<html>'
+ print >> out, '<head>'
+ print >> out, '<title>Profile Report</title>'
+ print >> out, '</head>'
accounted_for = 0
for cs in call_stacks:
- if args.fmt in BANNER:
- print >>out, BANNER[args.fmt] % {
- 'count': cs.count,
- }
- header, _ = zip(*FORMAT)
- table = []
- for line in cs.lines:
- fields = []
- for _, fn in FORMAT:
- fields.append(fn(line))
- table.append(fields)
- print >>out, tabulate.tabulate(table, header, tablefmt=args.fmt)
- accounted_for += cs.count
- if accounted_for > .99 * total_stacks:
- break
+ if args.fmt in BANNER:
+ print >> out, BANNER[args.fmt] % {
+ 'count': cs.count,
+ }
+ header, _ = zip(*FORMAT)
+ table = []
+ for line in cs.lines:
+ fields = []
+ for _, fn in FORMAT:
+ fields.append(fn(line))
+ table.append(fields)
+ print >> out, tabulate.tabulate(table, header, tablefmt=args.fmt)
+ accounted_for += cs.count
+ if accounted_for > .99 * total_stacks:
+ break
if args.fmt == 'html':
- print '</html>'
-
+ print '</html>'
diff --git a/tools/profiling/microbenchmarks/bm2bq.py b/tools/profiling/microbenchmarks/bm2bq.py
index 9f9b672f75..e084e28dcf 100755
--- a/tools/profiling/microbenchmarks/bm2bq.py
+++ b/tools/profiling/microbenchmarks/bm2bq.py
@@ -28,37 +28,38 @@ import subprocess
columns = []
for row in json.loads(
- subprocess.check_output([
- 'bq','--format=json','show','microbenchmarks.microbenchmarks']))['schema']['fields']:
- columns.append((row['name'], row['type'].lower()))
+ subprocess.check_output(
+ ['bq', '--format=json', 'show',
+ 'microbenchmarks.microbenchmarks']))['schema']['fields']:
+ columns.append((row['name'], row['type'].lower()))
SANITIZE = {
- 'integer': int,
- 'float': float,
- 'boolean': bool,
- 'string': str,
- 'timestamp': str,
+ 'integer': int,
+ 'float': float,
+ 'boolean': bool,
+ 'string': str,
+ 'timestamp': str,
}
if sys.argv[1] == '--schema':
- print ',\n'.join('%s:%s' % (k, t.upper()) for k, t in columns)
- sys.exit(0)
+ print ',\n'.join('%s:%s' % (k, t.upper()) for k, t in columns)
+ sys.exit(0)
with open(sys.argv[1]) as f:
- js = json.loads(f.read())
+ js = json.loads(f.read())
if len(sys.argv) > 2:
- with open(sys.argv[2]) as f:
- js2 = json.loads(f.read())
+ with open(sys.argv[2]) as f:
+ js2 = json.loads(f.read())
else:
- js2 = None
+ js2 = None
-writer = csv.DictWriter(sys.stdout, [c for c,t in columns])
+writer = csv.DictWriter(sys.stdout, [c for c, t in columns])
for row in bm_json.expand_json(js, js2):
- sane_row = {}
- for name, sql_type in columns:
- if name in row:
- if row[name] == '': continue
- sane_row[name] = SANITIZE[sql_type](row[name])
- writer.writerow(sane_row)
+ sane_row = {}
+ for name, sql_type in columns:
+ if name in row:
+ if row[name] == '': continue
+ sane_row[name] = SANITIZE[sql_type](row[name])
+ writer.writerow(sane_row)
diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_build.py b/tools/profiling/microbenchmarks/bm_diff/bm_build.py
index ce62c09d72..4197ba3632 100755
--- a/tools/profiling/microbenchmarks/bm_diff/bm_build.py
+++ b/tools/profiling/microbenchmarks/bm_diff/bm_build.py
@@ -13,7 +13,6 @@
# 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.
-
""" Python utility to build opt and counters benchmarks """
import bm_constants
@@ -26,55 +25,57 @@ import shutil
def _args():
- argp = argparse.ArgumentParser(description='Builds microbenchmarks')
- argp.add_argument(
- '-b',
- '--benchmarks',
- nargs='+',
- choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- help='Which benchmarks to build')
- argp.add_argument(
- '-j',
- '--jobs',
- type=int,
- default=multiprocessing.cpu_count(),
- help='How many CPUs to dedicate to this task')
- argp.add_argument(
- '-n',
- '--name',
- type=str,
- help='Unique name of this build. To be used as a handle to pass to the other bm* scripts'
- )
- argp.add_argument('--counters', dest='counters', action='store_true')
- argp.add_argument('--no-counters', dest='counters', action='store_false')
- argp.set_defaults(counters=True)
- args = argp.parse_args()
- assert args.name
- return args
+ argp = argparse.ArgumentParser(description='Builds microbenchmarks')
+ argp.add_argument(
+ '-b',
+ '--benchmarks',
+ nargs='+',
+ choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ help='Which benchmarks to build')
+ argp.add_argument(
+ '-j',
+ '--jobs',
+ type=int,
+ default=multiprocessing.cpu_count(),
+ help='How many CPUs to dedicate to this task')
+ argp.add_argument(
+ '-n',
+ '--name',
+ type=str,
+ help=
+ 'Unique name of this build. To be used as a handle to pass to the other bm* scripts'
+ )
+ argp.add_argument('--counters', dest='counters', action='store_true')
+ argp.add_argument('--no-counters', dest='counters', action='store_false')
+ argp.set_defaults(counters=True)
+ args = argp.parse_args()
+ assert args.name
+ return args
def _make_cmd(cfg, benchmarks, jobs):
- return ['make'] + benchmarks + ['CONFIG=%s' % cfg, '-j', '%d' % jobs]
+ return ['make'] + benchmarks + ['CONFIG=%s' % cfg, '-j', '%d' % jobs]
def build(name, benchmarks, jobs, counters):
- shutil.rmtree('bm_diff_%s' % name, ignore_errors=True)
- subprocess.check_call(['git', 'submodule', 'update'])
- try:
- subprocess.check_call(_make_cmd('opt', benchmarks, jobs))
- if counters:
- subprocess.check_call(_make_cmd('counters', benchmarks, jobs))
- except subprocess.CalledProcessError, e:
- subprocess.check_call(['make', 'clean'])
- subprocess.check_call(_make_cmd('opt', benchmarks, jobs))
- if counters:
- subprocess.check_call(_make_cmd('counters', benchmarks, jobs))
- os.rename(
- 'bins',
- 'bm_diff_%s' % name,)
+ shutil.rmtree('bm_diff_%s' % name, ignore_errors=True)
+ subprocess.check_call(['git', 'submodule', 'update'])
+ try:
+ subprocess.check_call(_make_cmd('opt', benchmarks, jobs))
+ if counters:
+ subprocess.check_call(_make_cmd('counters', benchmarks, jobs))
+ except subprocess.CalledProcessError, e:
+ subprocess.check_call(['make', 'clean'])
+ subprocess.check_call(_make_cmd('opt', benchmarks, jobs))
+ if counters:
+ subprocess.check_call(_make_cmd('counters', benchmarks, jobs))
+ os.rename(
+ 'bins',
+ 'bm_diff_%s' % name,
+ )
if __name__ == '__main__':
- args = _args()
- build(args.name, args.benchmarks, args.jobs, args.counters)
+ args = _args()
+ build(args.name, args.benchmarks, args.jobs, args.counters)
diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_constants.py b/tools/profiling/microbenchmarks/bm_diff/bm_constants.py
index f8989b17fc..5719e42620 100644
--- a/tools/profiling/microbenchmarks/bm_diff/bm_constants.py
+++ b/tools/profiling/microbenchmarks/bm_diff/bm_constants.py
@@ -13,19 +13,21 @@
# 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.
-
""" Configurable constants for the bm_*.py family """
_AVAILABLE_BENCHMARK_TESTS = [
- 'bm_fullstack_unary_ping_pong', 'bm_fullstack_streaming_ping_pong',
- 'bm_fullstack_streaming_pump', 'bm_closure', 'bm_cq', 'bm_call_create',
- 'bm_error', 'bm_chttp2_hpack', 'bm_chttp2_transport', 'bm_pollset',
- 'bm_metadata', 'bm_fullstack_trickle'
+ 'bm_fullstack_unary_ping_pong', 'bm_fullstack_streaming_ping_pong',
+ 'bm_fullstack_streaming_pump', 'bm_closure', 'bm_cq', 'bm_call_create',
+ 'bm_error', 'bm_chttp2_hpack', 'bm_chttp2_transport', 'bm_pollset',
+ 'bm_metadata', 'bm_fullstack_trickle'
]
-_INTERESTING = ('cpu_time', 'real_time', 'locks_per_iteration',
- 'allocs_per_iteration', 'writes_per_iteration',
- 'atm_cas_per_iteration', 'atm_add_per_iteration',
- 'nows_per_iteration', 'cli_transport_stalls_per_iteration',
- 'cli_stream_stalls_per_iteration', 'svr_transport_stalls_per_iteration',
- 'svr_stream_stalls_per_iteration', 'http2_pings_sent_per_iteration')
+_INTERESTING = ('cpu_time', 'real_time', 'call_initial_size-median',
+ 'locks_per_iteration', 'allocs_per_iteration',
+ 'writes_per_iteration', 'atm_cas_per_iteration',
+ 'atm_add_per_iteration', 'nows_per_iteration',
+ 'cli_transport_stalls_per_iteration',
+ 'cli_stream_stalls_per_iteration',
+ 'svr_transport_stalls_per_iteration',
+ 'svr_stream_stalls_per_iteration',
+ 'http2_pings_sent_per_iteration')
diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_diff.py b/tools/profiling/microbenchmarks/bm_diff/bm_diff.py
index a41d0f0552..f975a8b402 100755
--- a/tools/profiling/microbenchmarks/bm_diff/bm_diff.py
+++ b/tools/profiling/microbenchmarks/bm_diff/bm_diff.py
@@ -34,190 +34,196 @@ verbose = False
def _median(ary):
- assert (len(ary))
- ary = sorted(ary)
- n = len(ary)
- if n % 2 == 0:
- return (ary[(n - 1) / 2] + ary[(n - 1) / 2 + 1]) / 2.0
- else:
- return ary[n / 2]
+ assert (len(ary))
+ ary = sorted(ary)
+ n = len(ary)
+ if n % 2 == 0:
+ return (ary[(n - 1) / 2] + ary[(n - 1) / 2 + 1]) / 2.0
+ else:
+ return ary[n / 2]
def _args():
- argp = argparse.ArgumentParser(
- description='Perform diff on microbenchmarks')
- argp.add_argument(
- '-t',
- '--track',
- choices=sorted(bm_constants._INTERESTING),
- nargs='+',
- default=sorted(bm_constants._INTERESTING),
- help='Which metrics to track')
- argp.add_argument(
- '-b',
- '--benchmarks',
- nargs='+',
- choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- help='Which benchmarks to run')
- argp.add_argument(
- '-l',
- '--loops',
- type=int,
- default=20,
- help='Number of times to loops the benchmarks. Must match what was passed to bm_run.py'
- )
- argp.add_argument(
- '-r',
- '--regex',
- type=str,
- default="",
- help='Regex to filter benchmarks run')
- argp.add_argument('--counters', dest='counters', action='store_true')
- argp.add_argument('--no-counters', dest='counters', action='store_false')
- argp.set_defaults(counters=True)
- argp.add_argument('-n', '--new', type=str, help='New benchmark name')
- argp.add_argument('-o', '--old', type=str, help='Old benchmark name')
- argp.add_argument(
- '-v', '--verbose', type=bool, help='Print details of before/after')
- args = argp.parse_args()
- global verbose
- if args.verbose: verbose = True
- assert args.new
- assert args.old
- return args
+ argp = argparse.ArgumentParser(
+ description='Perform diff on microbenchmarks')
+ argp.add_argument(
+ '-t',
+ '--track',
+ choices=sorted(bm_constants._INTERESTING),
+ nargs='+',
+ default=sorted(bm_constants._INTERESTING),
+ help='Which metrics to track')
+ argp.add_argument(
+ '-b',
+ '--benchmarks',
+ nargs='+',
+ choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ help='Which benchmarks to run')
+ argp.add_argument(
+ '-l',
+ '--loops',
+ type=int,
+ default=20,
+ help=
+ 'Number of times to loops the benchmarks. Must match what was passed to bm_run.py'
+ )
+ argp.add_argument(
+ '-r',
+ '--regex',
+ type=str,
+ default="",
+ help='Regex to filter benchmarks run')
+ argp.add_argument('--counters', dest='counters', action='store_true')
+ argp.add_argument('--no-counters', dest='counters', action='store_false')
+ argp.set_defaults(counters=True)
+ argp.add_argument('-n', '--new', type=str, help='New benchmark name')
+ argp.add_argument('-o', '--old', type=str, help='Old benchmark name')
+ argp.add_argument(
+ '-v', '--verbose', type=bool, help='Print details of before/after')
+ args = argp.parse_args()
+ global verbose
+ if args.verbose: verbose = True
+ assert args.new
+ assert args.old
+ return args
def _maybe_print(str):
- if verbose: print str
+ if verbose: print str
class Benchmark:
- def __init__(self):
- self.samples = {
- True: collections.defaultdict(list),
- False: collections.defaultdict(list)
- }
- self.final = {}
-
- def add_sample(self, track, data, new):
- for f in track:
- if f in data:
- self.samples[new][f].append(float(data[f]))
-
- def process(self, track, new_name, old_name):
- for f in sorted(track):
- new = self.samples[True][f]
- old = self.samples[False][f]
- if not new or not old: continue
- mdn_diff = abs(_median(new) - _median(old))
- _maybe_print('%s: %s=%r %s=%r mdn_diff=%r' %
- (f, new_name, new, old_name, old, mdn_diff))
- s = bm_speedup.speedup(new, old, 1e-5)
- if abs(s) > 3:
- if mdn_diff > 0.5 or 'trickle' in f:
- self.final[f] = '%+d%%' % s
- return self.final.keys()
-
- def skip(self):
- return not self.final
-
- def row(self, flds):
- return [self.final[f] if f in self.final else '' for f in flds]
+ def __init__(self):
+ self.samples = {
+ True: collections.defaultdict(list),
+ False: collections.defaultdict(list)
+ }
+ self.final = {}
+
+ def add_sample(self, track, data, new):
+ for f in track:
+ if f in data:
+ self.samples[new][f].append(float(data[f]))
+
+ def process(self, track, new_name, old_name):
+ for f in sorted(track):
+ new = self.samples[True][f]
+ old = self.samples[False][f]
+ if not new or not old: continue
+ mdn_diff = abs(_median(new) - _median(old))
+ _maybe_print('%s: %s=%r %s=%r mdn_diff=%r' %
+ (f, new_name, new, old_name, old, mdn_diff))
+ s = bm_speedup.speedup(new, old, 1e-5)
+ if abs(s) > 3:
+ if mdn_diff > 0.5 or 'trickle' in f:
+ self.final[f] = '%+d%%' % s
+ return self.final.keys()
+
+ def skip(self):
+ return not self.final
+
+ def row(self, flds):
+ return [self.final[f] if f in self.final else '' for f in flds]
def _read_json(filename, badjson_files, nonexistant_files):
- stripped = ".".join(filename.split(".")[:-2])
- try:
- with open(filename) as f:
- r = f.read();
- return json.loads(r)
- except IOError, e:
- if stripped in nonexistant_files:
- nonexistant_files[stripped] += 1
- else:
- nonexistant_files[stripped] = 1
- return None
- except ValueError, e:
- print r
- if stripped in badjson_files:
- badjson_files[stripped] += 1
- else:
- badjson_files[stripped] = 1
- return None
+ stripped = ".".join(filename.split(".")[:-2])
+ try:
+ with open(filename) as f:
+ r = f.read()
+ return json.loads(r)
+ except IOError, e:
+ if stripped in nonexistant_files:
+ nonexistant_files[stripped] += 1
+ else:
+ nonexistant_files[stripped] = 1
+ return None
+ except ValueError, e:
+ print r
+ if stripped in badjson_files:
+ badjson_files[stripped] += 1
+ else:
+ badjson_files[stripped] = 1
+ return None
+
def fmt_dict(d):
- return ''.join([" " + k + ": " + str(d[k]) + "\n" for k in d])
+ return ''.join([" " + k + ": " + str(d[k]) + "\n" for k in d])
+
def diff(bms, loops, regex, track, old, new, counters):
- benchmarks = collections.defaultdict(Benchmark)
-
- badjson_files = {}
- nonexistant_files = {}
- for bm in bms:
- for loop in range(0, loops):
- for line in subprocess.check_output(
- ['bm_diff_%s/opt/%s' % (old, bm),
- '--benchmark_list_tests',
- '--benchmark_filter=%s' % regex]).splitlines():
- stripped_line = line.strip().replace("/", "_").replace(
- "<", "_").replace(">", "_").replace(", ", "_")
- js_new_opt = _read_json('%s.%s.opt.%s.%d.json' %
- (bm, stripped_line, new, loop),
- badjson_files, nonexistant_files)
- js_old_opt = _read_json('%s.%s.opt.%s.%d.json' %
- (bm, stripped_line, old, loop),
- badjson_files, nonexistant_files)
- if counters:
- js_new_ctr = _read_json('%s.%s.counters.%s.%d.json' %
- (bm, stripped_line, new, loop),
- badjson_files, nonexistant_files)
- js_old_ctr = _read_json('%s.%s.counters.%s.%d.json' %
- (bm, stripped_line, old, loop),
- badjson_files, nonexistant_files)
+ benchmarks = collections.defaultdict(Benchmark)
+
+ badjson_files = {}
+ nonexistant_files = {}
+ for bm in bms:
+ for loop in range(0, loops):
+ for line in subprocess.check_output([
+ 'bm_diff_%s/opt/%s' % (old, bm), '--benchmark_list_tests',
+ '--benchmark_filter=%s' % regex
+ ]).splitlines():
+ stripped_line = line.strip().replace("/", "_").replace(
+ "<", "_").replace(">", "_").replace(", ", "_")
+ js_new_opt = _read_json('%s.%s.opt.%s.%d.json' %
+ (bm, stripped_line, new, loop),
+ badjson_files, nonexistant_files)
+ js_old_opt = _read_json('%s.%s.opt.%s.%d.json' %
+ (bm, stripped_line, old, loop),
+ badjson_files, nonexistant_files)
+ if counters:
+ js_new_ctr = _read_json('%s.%s.counters.%s.%d.json' %
+ (bm, stripped_line, new, loop),
+ badjson_files, nonexistant_files)
+ js_old_ctr = _read_json('%s.%s.counters.%s.%d.json' %
+ (bm, stripped_line, old, loop),
+ badjson_files, nonexistant_files)
+ else:
+ js_new_ctr = None
+ js_old_ctr = None
+
+ for row in bm_json.expand_json(js_new_ctr, js_new_opt):
+ name = row['cpp_name']
+ if name.endswith('_mean') or name.endswith('_stddev'):
+ continue
+ benchmarks[name].add_sample(track, row, True)
+ for row in bm_json.expand_json(js_old_ctr, js_old_opt):
+ name = row['cpp_name']
+ if name.endswith('_mean') or name.endswith('_stddev'):
+ continue
+ benchmarks[name].add_sample(track, row, False)
+
+ really_interesting = set()
+ for name, bm in benchmarks.items():
+ _maybe_print(name)
+ really_interesting.update(bm.process(track, new, old))
+ fields = [f for f in track if f in really_interesting]
+
+ headers = ['Benchmark'] + fields
+ rows = []
+ for name in sorted(benchmarks.keys()):
+ if benchmarks[name].skip(): continue
+ rows.append([name] + benchmarks[name].row(fields))
+ note = None
+ if len(badjson_files):
+ note = 'Corrupt JSON data (indicates timeout or crash): \n%s' % fmt_dict(
+ badjson_files)
+ if len(nonexistant_files):
+ if note:
+ note += '\n\nMissing files (indicates new benchmark): \n%s' % fmt_dict(
+ nonexistant_files)
else:
- js_new_ctr = None
- js_old_ctr = None
-
- for row in bm_json.expand_json(js_new_ctr, js_new_opt):
- name = row['cpp_name']
- if name.endswith('_mean') or name.endswith('_stddev'):
- continue
- benchmarks[name].add_sample(track, row, True)
- for row in bm_json.expand_json(js_old_ctr, js_old_opt):
- name = row['cpp_name']
- if name.endswith('_mean') or name.endswith('_stddev'):
- continue
- benchmarks[name].add_sample(track, row, False)
-
- really_interesting = set()
- for name, bm in benchmarks.items():
- _maybe_print(name)
- really_interesting.update(bm.process(track, new, old))
- fields = [f for f in track if f in really_interesting]
-
- headers = ['Benchmark'] + fields
- rows = []
- for name in sorted(benchmarks.keys()):
- if benchmarks[name].skip(): continue
- rows.append([name] + benchmarks[name].row(fields))
- note = None
- if len(badjson_files):
- note = 'Corrupt JSON data (indicates timeout or crash): \n%s' % fmt_dict(badjson_files)
- if len(nonexistant_files):
- if note:
- note += '\n\nMissing files (indicates new benchmark): \n%s' % fmt_dict(nonexistant_files)
+ note = '\n\nMissing files (indicates new benchmark): \n%s' % fmt_dict(
+ nonexistant_files)
+ if rows:
+ return tabulate.tabulate(rows, headers=headers, floatfmt='+.2f'), note
else:
- note = '\n\nMissing files (indicates new benchmark): \n%s' % fmt_dict(nonexistant_files)
- if rows:
- return tabulate.tabulate(rows, headers=headers, floatfmt='+.2f'), note
- else:
- return None, note
+ return None, note
if __name__ == '__main__':
- args = _args()
- diff, note = diff(args.benchmarks, args.loops, args.regex, args.track, args.old,
- args.new, args.counters)
- print('%s\n%s' % (note, diff if diff else "No performance differences"))
+ args = _args()
+ diff, note = diff(args.benchmarks, args.loops, args.regex, args.track,
+ args.old, args.new, args.counters)
+ print('%s\n%s' % (note, diff if diff else "No performance differences"))
diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_main.py b/tools/profiling/microbenchmarks/bm_diff/bm_main.py
index 5aa11ac391..96c63ba060 100755
--- a/tools/profiling/microbenchmarks/bm_diff/bm_main.py
+++ b/tools/profiling/microbenchmarks/bm_diff/bm_main.py
@@ -13,7 +13,6 @@
# 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.
-
""" Runs the entire bm_*.py pipeline, and possible comments on the PR """
import bm_constants
@@ -23,123 +22,139 @@ import bm_diff
import sys
import os
+import random
import argparse
import multiprocessing
import subprocess
sys.path.append(
- os.path.join(
- os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
import comment_on_pr
+sys.path.append(
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', '..', '..', 'run_tests',
+ 'python_utils'))
+import jobset
+
def _args():
- argp = argparse.ArgumentParser(
- description='Perform diff on microbenchmarks')
- argp.add_argument(
- '-t',
- '--track',
- choices=sorted(bm_constants._INTERESTING),
- nargs='+',
- default=sorted(bm_constants._INTERESTING),
- help='Which metrics to track')
- argp.add_argument(
- '-b',
- '--benchmarks',
- nargs='+',
- choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- help='Which benchmarks to run')
- argp.add_argument(
- '-d',
- '--diff_base',
- type=str,
- help='Commit or branch to compare the current one to')
- argp.add_argument(
- '-o',
- '--old',
- default='old',
- type=str,
- help='Name of baseline run to compare to. Ususally just called "old"')
- argp.add_argument(
- '-r',
- '--regex',
- type=str,
- default="",
- help='Regex to filter benchmarks run')
- argp.add_argument(
- '-l',
- '--loops',
- type=int,
- default=20,
- help='Number of times to loops the benchmarks. More loops cuts down on noise'
- )
- argp.add_argument(
- '-j',
- '--jobs',
- type=int,
- default=multiprocessing.cpu_count(),
- help='Number of CPUs to use')
- argp.add_argument(
- '--pr_comment_name',
- type=str,
- default="microbenchmarks",
- help='Name that Jenkins will use to commen on the PR')
- argp.add_argument('--counters', dest='counters', action='store_true')
- argp.add_argument('--no-counters', dest='counters', action='store_false')
- argp.set_defaults(counters=True)
- args = argp.parse_args()
- assert args.diff_base or args.old, "One of diff_base or old must be set!"
- if args.loops < 3:
- print "WARNING: This run will likely be noisy. Increase loops."
- return args
+ argp = argparse.ArgumentParser(
+ description='Perform diff on microbenchmarks')
+ argp.add_argument(
+ '-t',
+ '--track',
+ choices=sorted(bm_constants._INTERESTING),
+ nargs='+',
+ default=sorted(bm_constants._INTERESTING),
+ help='Which metrics to track')
+ argp.add_argument(
+ '-b',
+ '--benchmarks',
+ nargs='+',
+ choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ help='Which benchmarks to run')
+ argp.add_argument(
+ '-d',
+ '--diff_base',
+ type=str,
+ help='Commit or branch to compare the current one to')
+ argp.add_argument(
+ '-o',
+ '--old',
+ default='old',
+ type=str,
+ help='Name of baseline run to compare to. Ususally just called "old"')
+ argp.add_argument(
+ '-r',
+ '--regex',
+ type=str,
+ default="",
+ help='Regex to filter benchmarks run')
+ argp.add_argument(
+ '-l',
+ '--loops',
+ type=int,
+ default=10,
+ help=
+ 'Number of times to loops the benchmarks. More loops cuts down on noise'
+ )
+ argp.add_argument(
+ '-j',
+ '--jobs',
+ type=int,
+ default=multiprocessing.cpu_count(),
+ help='Number of CPUs to use')
+ argp.add_argument(
+ '--pr_comment_name',
+ type=str,
+ default="microbenchmarks",
+ help='Name that Jenkins will use to commen on the PR')
+ argp.add_argument('--counters', dest='counters', action='store_true')
+ argp.add_argument('--no-counters', dest='counters', action='store_false')
+ argp.set_defaults(counters=True)
+ args = argp.parse_args()
+ assert args.diff_base or args.old, "One of diff_base or old must be set!"
+ if args.loops < 3:
+ print "WARNING: This run will likely be noisy. Increase loops."
+ return args
def eintr_be_gone(fn):
- """Run fn until it doesn't stop because of EINTR"""
+ """Run fn until it doesn't stop because of EINTR"""
- def inner(*args):
- while True:
- try:
- return fn(*args)
- except IOError, e:
- if e.errno != errno.EINTR:
- raise
+ def inner(*args):
+ while True:
+ try:
+ return fn(*args)
+ except IOError, e:
+ if e.errno != errno.EINTR:
+ raise
- return inner
+ return inner
def main(args):
- bm_build.build('new', args.benchmarks, args.jobs, args.counters)
-
- old = args.old
- if args.diff_base:
- old = 'old'
- where_am_i = subprocess.check_output(
- ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
- subprocess.check_call(['git', 'checkout', args.diff_base])
- try:
- bm_build.build(old, args.benchmarks, args.jobs, args.counters)
- finally:
- subprocess.check_call(['git', 'checkout', where_am_i])
- subprocess.check_call(['git', 'submodule', 'update'])
-
- bm_run.run('new', args.benchmarks, args.jobs, args.loops, args.regex, args.counters)
- bm_run.run(old, args.benchmarks, args.jobs, args.loops, args.regex, args.counters)
-
- diff, note = bm_diff.diff(args.benchmarks, args.loops, args.regex, args.track, old,
- 'new', args.counters)
- if diff:
- text = '[%s] Performance differences noted:\n%s' % (args.pr_comment_name, diff)
- else:
- text = '[%s] No significant performance differences' % args.pr_comment_name
- if note:
- text = note + '\n\n' + text
- print('%s' % text)
- comment_on_pr.comment_on_pr('```\n%s\n```' % text)
+ bm_build.build('new', args.benchmarks, args.jobs, args.counters)
+
+ old = args.old
+ if args.diff_base:
+ old = 'old'
+ where_am_i = subprocess.check_output(
+ ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
+ subprocess.check_call(['git', 'checkout', args.diff_base])
+ try:
+ bm_build.build(old, args.benchmarks, args.jobs, args.counters)
+ finally:
+ subprocess.check_call(['git', 'checkout', where_am_i])
+ subprocess.check_call(['git', 'submodule', 'update'])
+
+ jobs_list = []
+ jobs_list += bm_run.create_jobs('new', args.benchmarks, args.loops,
+ args.regex, args.counters)
+ jobs_list += bm_run.create_jobs(old, args.benchmarks, args.loops,
+ args.regex, args.counters)
+
+ # shuffle all jobs to eliminate noise from GCE CPU drift
+ random.shuffle(jobs_list, random.SystemRandom().random)
+ jobset.run(jobs_list, maxjobs=args.jobs)
+
+ diff, note = bm_diff.diff(args.benchmarks, args.loops, args.regex,
+ args.track, old, 'new', args.counters)
+ if diff:
+ text = '[%s] Performance differences noted:\n%s' % (
+ args.pr_comment_name, diff)
+ else:
+ text = '[%s] No significant performance differences' % args.pr_comment_name
+ if note:
+ text = note + '\n\n' + text
+ print('%s' % text)
+ comment_on_pr.comment_on_pr('```\n%s\n```' % text)
if __name__ == '__main__':
- args = _args()
- main(args)
+ args = _args()
+ main(args)
diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_run.py b/tools/profiling/microbenchmarks/bm_diff/bm_run.py
index 206f7c5845..dfb9b178fa 100755
--- a/tools/profiling/microbenchmarks/bm_diff/bm_run.py
+++ b/tools/profiling/microbenchmarks/bm_diff/bm_run.py
@@ -13,7 +13,6 @@
# 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.
-
""" Python utility to run opt and counters benchmarks and save json output """
import bm_constants
@@ -27,90 +26,99 @@ import sys
import os
sys.path.append(
- os.path.join(
- os.path.dirname(sys.argv[0]), '..', '..', '..', 'run_tests',
- 'python_utils'))
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', '..', '..', 'run_tests',
+ 'python_utils'))
import jobset
def _args():
- argp = argparse.ArgumentParser(description='Runs microbenchmarks')
- argp.add_argument(
- '-b',
- '--benchmarks',
- nargs='+',
- choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- help='Benchmarks to run')
- argp.add_argument(
- '-j',
- '--jobs',
- type=int,
- default=multiprocessing.cpu_count(),
- help='Number of CPUs to use')
- argp.add_argument(
- '-n',
- '--name',
- type=str,
- help='Unique name of the build to run. Needs to match the handle passed to bm_build.py'
- )
- argp.add_argument(
- '-r',
- '--regex',
- type=str,
- default="",
- help='Regex to filter benchmarks run')
- argp.add_argument(
- '-l',
- '--loops',
- type=int,
- default=20,
- help='Number of times to loops the benchmarks. More loops cuts down on noise'
- )
- argp.add_argument('--counters', dest='counters', action='store_true')
- argp.add_argument('--no-counters', dest='counters', action='store_false')
- argp.set_defaults(counters=True)
- args = argp.parse_args()
- assert args.name
- if args.loops < 3:
- print "WARNING: This run will likely be noisy. Increase loops to at least 3."
- return args
+ argp = argparse.ArgumentParser(description='Runs microbenchmarks')
+ argp.add_argument(
+ '-b',
+ '--benchmarks',
+ nargs='+',
+ choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ help='Benchmarks to run')
+ argp.add_argument(
+ '-j',
+ '--jobs',
+ type=int,
+ default=multiprocessing.cpu_count(),
+ help='Number of CPUs to use')
+ argp.add_argument(
+ '-n',
+ '--name',
+ type=str,
+ help=
+ 'Unique name of the build to run. Needs to match the handle passed to bm_build.py'
+ )
+ argp.add_argument(
+ '-r',
+ '--regex',
+ type=str,
+ default="",
+ help='Regex to filter benchmarks run')
+ argp.add_argument(
+ '-l',
+ '--loops',
+ type=int,
+ default=20,
+ help=
+ 'Number of times to loops the benchmarks. More loops cuts down on noise'
+ )
+ argp.add_argument('--counters', dest='counters', action='store_true')
+ argp.add_argument('--no-counters', dest='counters', action='store_false')
+ argp.set_defaults(counters=True)
+ args = argp.parse_args()
+ assert args.name
+ if args.loops < 3:
+ print "WARNING: This run will likely be noisy. Increase loops to at least 3."
+ return args
def _collect_bm_data(bm, cfg, name, regex, idx, loops):
- jobs_list = []
- for line in subprocess.check_output(
- ['bm_diff_%s/%s/%s' % (name, cfg, bm),
- '--benchmark_list_tests', '--benchmark_filter=%s' % regex]).splitlines():
- stripped_line = line.strip().replace("/", "_").replace(
- "<", "_").replace(">", "_").replace(", ", "_")
- cmd = [
- 'bm_diff_%s/%s/%s' % (name, cfg, bm), '--benchmark_filter=^%s$' %
- line, '--benchmark_out=%s.%s.%s.%s.%d.json' %
- (bm, stripped_line, cfg, name, idx), '--benchmark_out_format=json',
- ]
- jobs_list.append(
- jobset.JobSpec(
- cmd,
- shortname='%s %s %s %s %d/%d' % (bm, line, cfg, name, idx + 1,
- loops),
- verbose_success=True,
- timeout_seconds=60 * 60)) # one hour
- return jobs_list
+ jobs_list = []
+ for line in subprocess.check_output([
+ 'bm_diff_%s/%s/%s' % (name, cfg, bm), '--benchmark_list_tests',
+ '--benchmark_filter=%s' % regex
+ ]).splitlines():
+ stripped_line = line.strip().replace("/",
+ "_").replace("<", "_").replace(
+ ">", "_").replace(", ", "_")
+ cmd = [
+ 'bm_diff_%s/%s/%s' % (name, cfg, bm),
+ '--benchmark_filter=^%s$' % line,
+ '--benchmark_out=%s.%s.%s.%s.%d.json' % (bm, stripped_line, cfg,
+ name, idx),
+ '--benchmark_out_format=json',
+ ]
+ jobs_list.append(
+ jobset.JobSpec(
+ cmd,
+ shortname='%s %s %s %s %d/%d' % (bm, line, cfg, name, idx + 1,
+ loops),
+ verbose_success=True,
+ cpu_cost=2,
+ timeout_seconds=60 * 60)) # one hour
+ return jobs_list
-def run(name, benchmarks, jobs, loops, regex, counters):
- jobs_list = []
- for loop in range(0, loops):
- for bm in benchmarks:
- jobs_list += _collect_bm_data(bm, 'opt', name, regex, loop, loops)
- if counters:
- jobs_list += _collect_bm_data(bm, 'counters', name, regex, loop,
- loops)
- random.shuffle(jobs_list, random.SystemRandom().random)
- jobset.run(jobs_list, maxjobs=jobs)
+def create_jobs(name, benchmarks, loops, regex, counters):
+ jobs_list = []
+ for loop in range(0, loops):
+ for bm in benchmarks:
+ jobs_list += _collect_bm_data(bm, 'opt', name, regex, loop, loops)
+ if counters:
+ jobs_list += _collect_bm_data(bm, 'counters', name, regex, loop,
+ loops)
+ random.shuffle(jobs_list, random.SystemRandom().random)
+ return jobs_list
if __name__ == '__main__':
- args = _args()
- run(args.name, args.benchmarks, args.jobs, args.loops, args.regex, args.counters)
+ args = _args()
+ jobs_list = create_jobs(args.name, args.benchmarks, args.loops, args.regex,
+ args.counters)
+ jobset.run(jobs_list, maxjobs=args.jobs)
diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_speedup.py b/tools/profiling/microbenchmarks/bm_diff/bm_speedup.py
index 63e691af02..2a77040360 100755
--- a/tools/profiling/microbenchmarks/bm_diff/bm_speedup.py
+++ b/tools/profiling/microbenchmarks/bm_diff/bm_speedup.py
@@ -19,40 +19,41 @@ import math
_DEFAULT_THRESHOLD = 1e-10
+
def scale(a, mul):
- return [x * mul for x in a]
+ return [x * mul for x in a]
def cmp(a, b):
- return stats.ttest_ind(a, b)
-
-
-def speedup(new, old, threshold = _DEFAULT_THRESHOLD):
- if (len(set(new))) == 1 and new == old: return 0
- s0, p0 = cmp(new, old)
- if math.isnan(p0): return 0
- if s0 == 0: return 0
- if p0 > threshold: return 0
- if s0 < 0:
- pct = 1
- while pct < 100:
- sp, pp = cmp(new, scale(old, 1 - pct / 100.0))
- if sp > 0: break
- if pp > threshold: break
- pct += 1
- return -(pct - 1)
- else:
- pct = 1
- while pct < 10000:
- sp, pp = cmp(new, scale(old, 1 + pct / 100.0))
- if sp < 0: break
- if pp > threshold: break
- pct += 1
- return pct - 1
+ return stats.ttest_ind(a, b)
+
+
+def speedup(new, old, threshold=_DEFAULT_THRESHOLD):
+ if (len(set(new))) == 1 and new == old: return 0
+ s0, p0 = cmp(new, old)
+ if math.isnan(p0): return 0
+ if s0 == 0: return 0
+ if p0 > threshold: return 0
+ if s0 < 0:
+ pct = 1
+ while pct < 100:
+ sp, pp = cmp(new, scale(old, 1 - pct / 100.0))
+ if sp > 0: break
+ if pp > threshold: break
+ pct += 1
+ return -(pct - 1)
+ else:
+ pct = 1
+ while pct < 10000:
+ sp, pp = cmp(new, scale(old, 1 + pct / 100.0))
+ if sp < 0: break
+ if pp > threshold: break
+ pct += 1
+ return pct - 1
if __name__ == "__main__":
- new = [0.0, 0.0, 0.0, 0.0]
- old = [2.96608e-06, 3.35076e-06, 3.45384e-06, 3.34407e-06]
- print speedup(new, old, 1e-5)
- print speedup(old, new, 1e-5)
+ new = [0.0, 0.0, 0.0, 0.0]
+ old = [2.96608e-06, 3.35076e-06, 3.45384e-06, 3.34407e-06]
+ print speedup(new, old, 1e-5)
+ print speedup(old, new, 1e-5)
diff --git a/tools/profiling/microbenchmarks/bm_json.py b/tools/profiling/microbenchmarks/bm_json.py
index f6082fe7b4..497d7ca813 100644
--- a/tools/profiling/microbenchmarks/bm_json.py
+++ b/tools/profiling/microbenchmarks/bm_json.py
@@ -15,184 +15,197 @@
import os
_BM_SPECS = {
- 'BM_UnaryPingPong': {
- 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
- 'dyn': ['request_size', 'response_size'],
- },
- 'BM_PumpStreamClientToServer': {
- 'tpl': ['fixture'],
- 'dyn': ['request_size'],
- },
- 'BM_PumpStreamServerToClient': {
- 'tpl': ['fixture'],
- 'dyn': ['request_size'],
- },
- 'BM_StreamingPingPong': {
- 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
- 'dyn': ['request_size', 'request_count'],
- },
- 'BM_StreamingPingPongMsgs': {
- 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
- 'dyn': ['request_size'],
- },
- 'BM_PumpStreamServerToClient_Trickle': {
- 'tpl': [],
- 'dyn': ['request_size', 'bandwidth_kilobits'],
- },
- 'BM_PumpUnbalancedUnary_Trickle': {
- 'tpl': [],
- 'dyn': ['cli_req_size', 'svr_req_size', 'bandwidth_kilobits'],
- },
- 'BM_ErrorStringOnNewError': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_ErrorStringRepeatedly': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_ErrorGetStatus': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_ErrorGetStatusCode': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_ErrorHttpError': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_HasClearGrpcStatus': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_IsolatedFilter': {
- 'tpl': ['fixture', 'client_mutator'],
- 'dyn': [],
- },
- 'BM_HpackEncoderEncodeHeader': {
- 'tpl': ['fixture'],
- 'dyn': ['end_of_stream', 'request_size'],
- },
- 'BM_HpackParserParseHeader': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_CallCreateDestroy': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_Zalloc': {
- 'tpl': [],
- 'dyn': ['request_size'],
- },
- 'BM_PollEmptyPollset_SpeedOfLight': {
- 'tpl': [],
- 'dyn': ['request_size', 'request_count'],
- },
- 'BM_StreamCreateSendInitialMetadataDestroy': {
- 'tpl': ['fixture'],
- 'dyn': [],
- },
- 'BM_TransportStreamSend': {
- 'tpl': [],
- 'dyn': ['request_size'],
- },
- 'BM_TransportStreamRecv': {
- 'tpl': [],
- 'dyn': ['request_size'],
- },
- 'BM_StreamingPingPongWithCoalescingApi': {
- 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
- 'dyn': ['request_size', 'request_count', 'end_of_stream'],
- },
- 'BM_Base16SomeStuff': {
- 'tpl': [],
- 'dyn': ['request_size'],
- }
+ 'BM_UnaryPingPong': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size', 'response_size'],
+ },
+ 'BM_PumpStreamClientToServer': {
+ 'tpl': ['fixture'],
+ 'dyn': ['request_size'],
+ },
+ 'BM_PumpStreamServerToClient': {
+ 'tpl': ['fixture'],
+ 'dyn': ['request_size'],
+ },
+ 'BM_StreamingPingPong': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size', 'request_count'],
+ },
+ 'BM_StreamingPingPongMsgs': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size'],
+ },
+ 'BM_PumpStreamServerToClient_Trickle': {
+ 'tpl': [],
+ 'dyn': ['request_size', 'bandwidth_kilobits'],
+ },
+ 'BM_PumpUnbalancedUnary_Trickle': {
+ 'tpl': [],
+ 'dyn': ['cli_req_size', 'svr_req_size', 'bandwidth_kilobits'],
+ },
+ 'BM_ErrorStringOnNewError': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_ErrorStringRepeatedly': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_ErrorGetStatus': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_ErrorGetStatusCode': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_ErrorHttpError': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_HasClearGrpcStatus': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_IsolatedFilter': {
+ 'tpl': ['fixture', 'client_mutator'],
+ 'dyn': [],
+ },
+ 'BM_HpackEncoderEncodeHeader': {
+ 'tpl': ['fixture'],
+ 'dyn': ['end_of_stream', 'request_size'],
+ },
+ 'BM_HpackParserParseHeader': {
+ 'tpl': ['fixture', 'on_header'],
+ 'dyn': [],
+ },
+ 'BM_CallCreateDestroy': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_Zalloc': {
+ 'tpl': [],
+ 'dyn': ['request_size'],
+ },
+ 'BM_PollEmptyPollset_SpeedOfLight': {
+ 'tpl': [],
+ 'dyn': ['request_size', 'request_count'],
+ },
+ 'BM_StreamCreateSendInitialMetadataDestroy': {
+ 'tpl': ['fixture'],
+ 'dyn': [],
+ },
+ 'BM_TransportStreamSend': {
+ 'tpl': [],
+ 'dyn': ['request_size'],
+ },
+ 'BM_TransportStreamRecv': {
+ 'tpl': [],
+ 'dyn': ['request_size'],
+ },
+ 'BM_StreamingPingPongWithCoalescingApi': {
+ 'tpl': ['fixture', 'client_mutator', 'server_mutator'],
+ 'dyn': ['request_size', 'request_count', 'end_of_stream'],
+ },
+ 'BM_Base16SomeStuff': {
+ 'tpl': [],
+ 'dyn': ['request_size'],
+ }
}
+
def numericalize(s):
- if not s: return ''
- if s[-1] == 'k':
- return float(s[:-1]) * 1024
- if s[-1] == 'M':
- return float(s[:-1]) * 1024 * 1024
- if 0 <= (ord(s[-1]) - ord('0')) <= 9:
- return float(s)
- assert 'not a number: %s' % s
+ if not s: return ''
+ if s[-1] == 'k':
+ return float(s[:-1]) * 1024
+ if s[-1] == 'M':
+ return float(s[:-1]) * 1024 * 1024
+ if 0 <= (ord(s[-1]) - ord('0')) <= 9:
+ return float(s)
+ assert 'not a number: %s' % s
+
def parse_name(name):
- cpp_name = name
- if '<' not in name and '/' not in name and name not in _BM_SPECS:
- return {'name': name, 'cpp_name': name}
- rest = name
- out = {}
- tpl_args = []
- dyn_args = []
- if '<' in rest:
- tpl_bit = rest[rest.find('<') + 1 : rest.rfind('>')]
- arg = ''
- nesting = 0
- for c in tpl_bit:
- if c == '<':
- nesting += 1
- arg += c
- elif c == '>':
- nesting -= 1
- arg += c
- elif c == ',':
- if nesting == 0:
- tpl_args.append(arg.strip())
- arg = ''
- else:
- arg += c
- else:
- arg += c
- tpl_args.append(arg.strip())
- rest = rest[:rest.find('<')] + rest[rest.rfind('>') + 1:]
- if '/' in rest:
- s = rest.split('/')
- rest = s[0]
- dyn_args = s[1:]
- name = rest
- assert name in _BM_SPECS, '_BM_SPECS needs to be expanded for %s' % name
- assert len(dyn_args) == len(_BM_SPECS[name]['dyn'])
- assert len(tpl_args) == len(_BM_SPECS[name]['tpl'])
- out['name'] = name
- out['cpp_name'] = cpp_name
- out.update(dict((k, numericalize(v)) for k, v in zip(_BM_SPECS[name]['dyn'], dyn_args)))
- out.update(dict(zip(_BM_SPECS[name]['tpl'], tpl_args)))
- return out
+ cpp_name = name
+ if '<' not in name and '/' not in name and name not in _BM_SPECS:
+ return {'name': name, 'cpp_name': name}
+ rest = name
+ out = {}
+ tpl_args = []
+ dyn_args = []
+ if '<' in rest:
+ tpl_bit = rest[rest.find('<') + 1:rest.rfind('>')]
+ arg = ''
+ nesting = 0
+ for c in tpl_bit:
+ if c == '<':
+ nesting += 1
+ arg += c
+ elif c == '>':
+ nesting -= 1
+ arg += c
+ elif c == ',':
+ if nesting == 0:
+ tpl_args.append(arg.strip())
+ arg = ''
+ else:
+ arg += c
+ else:
+ arg += c
+ tpl_args.append(arg.strip())
+ rest = rest[:rest.find('<')] + rest[rest.rfind('>') + 1:]
+ if '/' in rest:
+ s = rest.split('/')
+ rest = s[0]
+ dyn_args = s[1:]
+ name = rest
+ print(name)
+ print(dyn_args, _BM_SPECS[name]['dyn'])
+ print(tpl_args, _BM_SPECS[name]['tpl'])
+ assert name in _BM_SPECS, '_BM_SPECS needs to be expanded for %s' % name
+ assert len(dyn_args) == len(_BM_SPECS[name]['dyn'])
+ assert len(tpl_args) == len(_BM_SPECS[name]['tpl'])
+ out['name'] = name
+ out['cpp_name'] = cpp_name
+ out.update(
+ dict((k, numericalize(v))
+ for k, v in zip(_BM_SPECS[name]['dyn'], dyn_args)))
+ out.update(dict(zip(_BM_SPECS[name]['tpl'], tpl_args)))
+ return out
-def expand_json(js, js2 = None):
- if not js and not js2: raise StopIteration()
- if not js: js = js2
- for bm in js['benchmarks']:
- if bm['name'].endswith('_stddev') or bm['name'].endswith('_mean'): continue
- context = js['context']
- if 'label' in bm:
- labels_list = [s.split(':') for s in bm['label'].strip().split(' ') if len(s) and s[0] != '#']
- for el in labels_list:
- el[0] = el[0].replace('/iter', '_per_iteration')
- labels = dict(labels_list)
- else:
- labels = {}
- row = {
- 'jenkins_build': os.environ.get('BUILD_NUMBER', ''),
- 'jenkins_job': os.environ.get('JOB_NAME', ''),
- }
- row.update(context)
- row.update(bm)
- row.update(parse_name(row['name']))
- row.update(labels)
- if js2:
- for bm2 in js2['benchmarks']:
- if bm['name'] == bm2['name'] and 'already_used' not in bm2:
- row['cpu_time'] = bm2['cpu_time']
- row['real_time'] = bm2['real_time']
- row['iterations'] = bm2['iterations']
- bm2['already_used'] = True
- break
- yield row
+
+def expand_json(js, js2=None):
+ if not js and not js2: raise StopIteration()
+ if not js: js = js2
+ for bm in js['benchmarks']:
+ if bm['name'].endswith('_stddev') or bm['name'].endswith('_mean'):
+ continue
+ context = js['context']
+ if 'label' in bm:
+ labels_list = [
+ s.split(':')
+ for s in bm['label'].strip().split(' ')
+ if len(s) and s[0] != '#'
+ ]
+ for el in labels_list:
+ el[0] = el[0].replace('/iter', '_per_iteration')
+ labels = dict(labels_list)
+ else:
+ labels = {}
+ row = {
+ 'jenkins_build': os.environ.get('BUILD_NUMBER', ''),
+ 'jenkins_job': os.environ.get('JOB_NAME', ''),
+ }
+ row.update(context)
+ row.update(bm)
+ row.update(parse_name(row['name']))
+ row.update(labels)
+ if js2:
+ for bm2 in js2['benchmarks']:
+ if bm['name'] == bm2['name'] and 'already_used' not in bm2:
+ row['cpu_time'] = bm2['cpu_time']
+ row['real_time'] = bm2['real_time']
+ row['iterations'] = bm2['iterations']
+ bm2['already_used'] = True
+ break
+ yield row
diff --git a/tools/profiling/qps/qps_diff.py b/tools/profiling/qps/qps_diff.py
index 0654f45666..393f862b4d 100755
--- a/tools/profiling/qps/qps_diff.py
+++ b/tools/profiling/qps/qps_diff.py
@@ -26,144 +26,147 @@ import sys
import tabulate
sys.path.append(
- os.path.join(
- os.path.dirname(sys.argv[0]), '..', 'microbenchmarks', 'bm_diff'))
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', 'microbenchmarks', 'bm_diff'))
import bm_speedup
sys.path.append(
- os.path.join(
- os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
import comment_on_pr
def _args():
- argp = argparse.ArgumentParser(
- description='Perform diff on QPS Driver')
- argp.add_argument(
- '-d',
- '--diff_base',
- type=str,
- help='Commit or branch to compare the current one to')
- argp.add_argument(
- '-l',
- '--loops',
- type=int,
- default=4,
- help='Number of loops for each benchmark. More loops cuts down on noise'
- )
- argp.add_argument(
- '-j',
- '--jobs',
- type=int,
- default=multiprocessing.cpu_count(),
- help='Number of CPUs to use')
- args = argp.parse_args()
- assert args.diff_base, "diff_base must be set"
- return args
+ argp = argparse.ArgumentParser(description='Perform diff on QPS Driver')
+ argp.add_argument(
+ '-d',
+ '--diff_base',
+ type=str,
+ help='Commit or branch to compare the current one to')
+ argp.add_argument(
+ '-l',
+ '--loops',
+ type=int,
+ default=4,
+ help='Number of loops for each benchmark. More loops cuts down on noise'
+ )
+ argp.add_argument(
+ '-j',
+ '--jobs',
+ type=int,
+ default=multiprocessing.cpu_count(),
+ help='Number of CPUs to use')
+ args = argp.parse_args()
+ assert args.diff_base, "diff_base must be set"
+ return args
def _make_cmd(jobs):
- return ['make', '-j', '%d' % jobs, 'qps_json_driver', 'qps_worker']
+ return ['make', '-j', '%d' % jobs, 'qps_json_driver', 'qps_worker']
def build(name, jobs):
- shutil.rmtree('qps_diff_%s' % name, ignore_errors=True)
- subprocess.check_call(['git', 'submodule', 'update'])
- try:
- subprocess.check_call(_make_cmd(jobs))
- except subprocess.CalledProcessError, e:
- subprocess.check_call(['make', 'clean'])
- subprocess.check_call(_make_cmd(jobs))
- os.rename('bins', 'qps_diff_%s' % name)
+ shutil.rmtree('qps_diff_%s' % name, ignore_errors=True)
+ subprocess.check_call(['git', 'submodule', 'update'])
+ try:
+ subprocess.check_call(_make_cmd(jobs))
+ except subprocess.CalledProcessError, e:
+ subprocess.check_call(['make', 'clean'])
+ subprocess.check_call(_make_cmd(jobs))
+ os.rename('bins', 'qps_diff_%s' % name)
def _run_cmd(name, scenario, fname):
- return ['qps_diff_%s/opt/qps_json_driver' % name, '--scenarios_json', scenario, '--json_file_out', fname]
+ return [
+ 'qps_diff_%s/opt/qps_json_driver' % name, '--scenarios_json', scenario,
+ '--json_file_out', fname
+ ]
def run(name, scenarios, loops):
- for sn in scenarios:
- for i in range(0, loops):
- fname = "%s.%s.%d.json" % (sn, name, i)
- subprocess.check_call(_run_cmd(name, scenarios[sn], fname))
+ for sn in scenarios:
+ for i in range(0, loops):
+ fname = "%s.%s.%d.json" % (sn, name, i)
+ subprocess.check_call(_run_cmd(name, scenarios[sn], fname))
def _load_qps(fname):
- try:
- with open(fname) as f:
- return json.loads(f.read())['qps']
- except IOError, e:
- print("IOError occurred reading file: %s" % fname)
- return None
- except ValueError, e:
- print("ValueError occurred reading file: %s" % fname)
- return None
+ try:
+ with open(fname) as f:
+ return json.loads(f.read())['qps']
+ except IOError, e:
+ print("IOError occurred reading file: %s" % fname)
+ return None
+ except ValueError, e:
+ print("ValueError occurred reading file: %s" % fname)
+ return None
def _median(ary):
- assert (len(ary))
- ary = sorted(ary)
- n = len(ary)
- if n % 2 == 0:
- return (ary[(n - 1) / 2] + ary[(n - 1) / 2 + 1]) / 2.0
- else:
- return ary[n / 2]
+ assert (len(ary))
+ ary = sorted(ary)
+ n = len(ary)
+ if n % 2 == 0:
+ return (ary[(n - 1) / 2] + ary[(n - 1) / 2 + 1]) / 2.0
+ else:
+ return ary[n / 2]
def diff(scenarios, loops, old, new):
- old_data = {}
- new_data = {}
-
- # collect data
- for sn in scenarios:
- old_data[sn] = []
- new_data[sn] = []
- for i in range(loops):
- old_data[sn].append(_load_qps("%s.%s.%d.json" % (sn, old, i)))
- new_data[sn].append(_load_qps("%s.%s.%d.json" % (sn, new, i)))
-
- # crunch data
- headers = ['Benchmark', 'qps']
- rows = []
- for sn in scenarios:
- mdn_diff = abs(_median(new_data[sn]) - _median(old_data[sn]))
- print('%s: %s=%r %s=%r mdn_diff=%r' % (sn, new, new_data[sn], old, old_data[sn], mdn_diff))
- s = bm_speedup.speedup(new_data[sn], old_data[sn], 10e-5)
- if abs(s) > 3 and mdn_diff > 0.5:
- rows.append([sn, '%+d%%' % s])
-
- if rows:
- return tabulate.tabulate(rows, headers=headers, floatfmt='+.2f')
- else:
- return None
+ old_data = {}
+ new_data = {}
+
+ # collect data
+ for sn in scenarios:
+ old_data[sn] = []
+ new_data[sn] = []
+ for i in range(loops):
+ old_data[sn].append(_load_qps("%s.%s.%d.json" % (sn, old, i)))
+ new_data[sn].append(_load_qps("%s.%s.%d.json" % (sn, new, i)))
+
+ # crunch data
+ headers = ['Benchmark', 'qps']
+ rows = []
+ for sn in scenarios:
+ mdn_diff = abs(_median(new_data[sn]) - _median(old_data[sn]))
+ print('%s: %s=%r %s=%r mdn_diff=%r' % (sn, new, new_data[sn], old,
+ old_data[sn], mdn_diff))
+ s = bm_speedup.speedup(new_data[sn], old_data[sn], 10e-5)
+ if abs(s) > 3 and mdn_diff > 0.5:
+ rows.append([sn, '%+d%%' % s])
+
+ if rows:
+ return tabulate.tabulate(rows, headers=headers, floatfmt='+.2f')
+ else:
+ return None
def main(args):
- build('new', args.jobs)
+ build('new', args.jobs)
- if args.diff_base:
- where_am_i = subprocess.check_output(
- ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
- subprocess.check_call(['git', 'checkout', args.diff_base])
- try:
- build('old', args.jobs)
- finally:
- subprocess.check_call(['git', 'checkout', where_am_i])
- subprocess.check_call(['git', 'submodule', 'update'])
+ if args.diff_base:
+ where_am_i = subprocess.check_output(
+ ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
+ subprocess.check_call(['git', 'checkout', args.diff_base])
+ try:
+ build('old', args.jobs)
+ finally:
+ subprocess.check_call(['git', 'checkout', where_am_i])
+ subprocess.check_call(['git', 'submodule', 'update'])
- run('new', qps_scenarios._SCENARIOS, args.loops)
- run('old', qps_scenarios._SCENARIOS, args.loops)
+ run('new', qps_scenarios._SCENARIOS, args.loops)
+ run('old', qps_scenarios._SCENARIOS, args.loops)
- diff_output = diff(qps_scenarios._SCENARIOS, args.loops, 'old', 'new')
+ diff_output = diff(qps_scenarios._SCENARIOS, args.loops, 'old', 'new')
- if diff_output:
- text = '[qps] Performance differences noted:\n%s' % diff_output
- else:
- text = '[qps] No significant performance differences'
- print('%s' % text)
- comment_on_pr.comment_on_pr('```\n%s\n```' % text)
+ if diff_output:
+ text = '[qps] Performance differences noted:\n%s' % diff_output
+ else:
+ text = '[qps] No significant performance differences'
+ print('%s' % text)
+ comment_on_pr.comment_on_pr('```\n%s\n```' % text)
if __name__ == '__main__':
- args = _args()
- main(args)
+ args = _args()
+ main(args)
diff --git a/tools/profiling/qps/qps_scenarios.py b/tools/profiling/qps/qps_scenarios.py
index 4fbbdefc4d..532acc915c 100644
--- a/tools/profiling/qps/qps_scenarios.py
+++ b/tools/profiling/qps/qps_scenarios.py
@@ -14,6 +14,8 @@
""" QPS Scenarios to run """
_SCENARIOS = {
- 'large-message-throughput': '{"scenarios":[{"name":"large-message-throughput", "spawn_local_worker_count": -2, "warmup_seconds": 30, "benchmark_seconds": 270, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": null, "server_type": "ASYNC_SERVER"}, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"max_possible": 60000000000.0, "resolution": 0.01}}}]}',
- 'multi-channel-64-KiB': '{"scenarios":[{"name":"multi-channel-64-KiB", "spawn_local_worker_count": -3, "warmup_seconds": 30, "benchmark_seconds": 270, "num_servers": 1, "server_config": {"async_server_threads": 31, "security_params": null, "server_type": "ASYNC_SERVER"}, "num_clients": 2, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "payload_config": {"simple_params": {"resp_size": 65536, "req_size": 65536}}, "client_channels": 32, "async_client_threads": 31, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"max_possible": 60000000000.0, "resolution": 0.01}}}]}'
+ 'large-message-throughput':
+ '{"scenarios":[{"name":"large-message-throughput", "spawn_local_worker_count": -2, "warmup_seconds": 30, "benchmark_seconds": 270, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": null, "server_type": "ASYNC_SERVER"}, "num_clients": 1, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"max_possible": 60000000000.0, "resolution": 0.01}}}]}',
+ 'multi-channel-64-KiB':
+ '{"scenarios":[{"name":"multi-channel-64-KiB", "spawn_local_worker_count": -3, "warmup_seconds": 30, "benchmark_seconds": 270, "num_servers": 1, "server_config": {"async_server_threads": 31, "security_params": null, "server_type": "ASYNC_SERVER"}, "num_clients": 2, "client_config": {"client_type": "ASYNC_CLIENT", "security_params": null, "payload_config": {"simple_params": {"resp_size": 65536, "req_size": 65536}}, "client_channels": 32, "async_client_threads": 31, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"max_possible": 60000000000.0, "resolution": 0.01}}}]}'
}
diff --git a/tools/run_tests/artifacts/artifact_targets.py b/tools/run_tests/artifacts/artifact_targets.py
index 2cc0dfceab..efc4ca0d8a 100644
--- a/tools/run_tests/artifacts/artifact_targets.py
+++ b/tools/run_tests/artifacts/artifact_targets.py
@@ -12,7 +12,6 @@
# 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.
-
"""Definition of targets to build artifacts."""
import os.path
@@ -24,360 +23,352 @@ sys.path.insert(0, os.path.abspath('..'))
import python_utils.jobset as jobset
-def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
- flake_retries=0, timeout_retries=0, timeout_seconds=30*60,
- docker_base_image=None, extra_docker_args=None):
- """Creates jobspec for a task running under docker."""
- environ = environ.copy()
- environ['RUN_COMMAND'] = shell_command
- environ['ARTIFACTS_OUT'] = 'artifacts/%s' % name
-
- docker_args=[]
- for k,v in environ.items():
- docker_args += ['-e', '%s=%s' % (k, v)]
- docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
- 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
- 'OUTPUT_DIR': 'artifacts'}
-
- if docker_base_image is not None:
- docker_env['DOCKER_BASE_IMAGE'] = docker_base_image
- if extra_docker_args is not None:
- docker_env['EXTRA_DOCKER_ARGS'] = extra_docker_args
- jobspec = jobset.JobSpec(
- cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args,
- environ=docker_env,
- shortname='build_artifact.%s' % (name),
- timeout_seconds=timeout_seconds,
- flake_retries=flake_retries,
- timeout_retries=timeout_retries)
- return jobspec
-
-
-def create_jobspec(name, cmdline, environ={}, shell=False,
- flake_retries=0, timeout_retries=0, timeout_seconds=30*60,
+def create_docker_jobspec(name,
+ dockerfile_dir,
+ shell_command,
+ environ={},
+ flake_retries=0,
+ timeout_retries=0,
+ timeout_seconds=30 * 60,
+ docker_base_image=None,
+ extra_docker_args=None):
+ """Creates jobspec for a task running under docker."""
+ environ = environ.copy()
+ environ['RUN_COMMAND'] = shell_command
+ environ['ARTIFACTS_OUT'] = 'artifacts/%s' % name
+
+ docker_args = []
+ for k, v in environ.items():
+ docker_args += ['-e', '%s=%s' % (k, v)]
+ docker_env = {
+ 'DOCKERFILE_DIR': dockerfile_dir,
+ 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
+ 'OUTPUT_DIR': 'artifacts'
+ }
+
+ if docker_base_image is not None:
+ docker_env['DOCKER_BASE_IMAGE'] = docker_base_image
+ if extra_docker_args is not None:
+ docker_env['EXTRA_DOCKER_ARGS'] = extra_docker_args
+ jobspec = jobset.JobSpec(
+ cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] +
+ docker_args,
+ environ=docker_env,
+ shortname='build_artifact.%s' % (name),
+ timeout_seconds=timeout_seconds,
+ flake_retries=flake_retries,
+ timeout_retries=timeout_retries)
+ return jobspec
+
+
+def create_jobspec(name,
+ cmdline,
+ environ={},
+ shell=False,
+ flake_retries=0,
+ timeout_retries=0,
+ timeout_seconds=30 * 60,
use_workspace=False,
cpu_cost=1.0):
- """Creates jobspec."""
- environ = environ.copy()
- if use_workspace:
- environ['WORKSPACE_NAME'] = 'workspace_%s' % name
- environ['ARTIFACTS_OUT'] = os.path.join('..', 'artifacts', name)
- cmdline = ['bash',
- 'tools/run_tests/artifacts/run_in_workspace.sh'] + cmdline
- else:
- environ['ARTIFACTS_OUT'] = os.path.join('artifacts', name)
-
- jobspec = jobset.JobSpec(
- cmdline=cmdline,
- environ=environ,
- shortname='build_artifact.%s' % (name),
- timeout_seconds=timeout_seconds,
- flake_retries=flake_retries,
- timeout_retries=timeout_retries,
- shell=shell,
- cpu_cost=cpu_cost)
- return jobspec
+ """Creates jobspec."""
+ environ = environ.copy()
+ if use_workspace:
+ environ['WORKSPACE_NAME'] = 'workspace_%s' % name
+ environ['ARTIFACTS_OUT'] = os.path.join('..', 'artifacts', name)
+ cmdline = ['bash', 'tools/run_tests/artifacts/run_in_workspace.sh'
+ ] + cmdline
+ else:
+ environ['ARTIFACTS_OUT'] = os.path.join('artifacts', name)
+
+ jobspec = jobset.JobSpec(
+ cmdline=cmdline,
+ environ=environ,
+ shortname='build_artifact.%s' % (name),
+ timeout_seconds=timeout_seconds,
+ flake_retries=flake_retries,
+ timeout_retries=timeout_retries,
+ shell=shell,
+ cpu_cost=cpu_cost)
+ return jobspec
_MACOS_COMPAT_FLAG = '-mmacosx-version-min=10.7'
-_ARCH_FLAG_MAP = {
- 'x86': '-m32',
- 'x64': '-m64'
-}
+_ARCH_FLAG_MAP = {'x86': '-m32', 'x64': '-m64'}
class PythonArtifact:
- """Builds Python artifacts."""
-
- def __init__(self, platform, arch, py_version):
- self.name = 'python_%s_%s_%s' % (platform, arch, py_version)
- self.platform = platform
- self.arch = arch
- self.labels = ['artifact', 'python', platform, arch, py_version]
- self.py_version = py_version
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- environ = {}
- if self.platform == 'linux_extra':
- # Raspberry Pi build
- environ['PYTHON'] = '/usr/local/bin/python{}'.format(self.py_version)
- environ['PIP'] = '/usr/local/bin/pip{}'.format(self.py_version)
- # https://github.com/resin-io-projects/armv7hf-debian-qemu/issues/9
- # A QEMU bug causes submodule update to hang, so we copy directly
- environ['RELATIVE_COPY_PATH'] = '.'
- extra_args = ' --entrypoint=/usr/bin/qemu-arm-static '
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch),
- 'tools/run_tests/artifacts/build_artifact_python.sh',
- environ=environ,
- timeout_seconds=60*60*5,
- docker_base_image='quay.io/grpc/raspbian_{}'.format(self.arch),
- extra_docker_args=extra_args)
- elif self.platform == 'linux':
- if self.arch == 'x86':
- environ['SETARCH_CMD'] = 'linux32'
- # Inside the manylinux container, the python installations are located in
- # special places...
- environ['PYTHON'] = '/opt/python/{}/bin/python'.format(self.py_version)
- environ['PIP'] = '/opt/python/{}/bin/pip'.format(self.py_version)
- # Platform autodetection for the manylinux1 image breaks so we set the
- # defines ourselves.
- # TODO(atash) get better platform-detection support in core so we don't
- # need to do this manually...
- environ['CFLAGS'] = '-DGPR_MANYLINUX1=1'
- environ['GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS'] = 'TRUE'
- environ['GRPC_BUILD_MANYLINUX_WHEEL'] = 'TRUE'
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/grpc_artifact_python_manylinux_%s' % self.arch,
- 'tools/run_tests/artifacts/build_artifact_python.sh',
- environ=environ,
- timeout_seconds=60*60,
- docker_base_image='quay.io/pypa/manylinux1_i686' if self.arch == 'x86' else 'quay.io/pypa/manylinux1_x86_64')
- elif self.platform == 'windows':
- if 'Python27' in self.py_version or 'Python34' in self.py_version:
- environ['EXT_COMPILER'] = 'mingw32'
- else:
- environ['EXT_COMPILER'] = 'msvc'
- # For some reason, the batch script %random% always runs with the same
- # seed. We create a random temp-dir here
- dir = ''.join(random.choice(string.ascii_uppercase) for _ in range(10))
- return create_jobspec(self.name,
- ['tools\\run_tests\\artifacts\\build_artifact_python.bat',
- self.py_version,
- '32' if self.arch == 'x86' else '64'],
- environ=environ,
- timeout_seconds=45*60,
- use_workspace=True)
- else:
- environ['PYTHON'] = self.py_version
- environ['SKIP_PIP_INSTALL'] = 'TRUE'
- return create_jobspec(self.name,
- ['tools/run_tests/artifacts/build_artifact_python.sh'],
- environ=environ,
- timeout_seconds=60*60,
- use_workspace=True)
-
- def __str__(self):
- return self.name
+ """Builds Python artifacts."""
+
+ def __init__(self, platform, arch, py_version):
+ self.name = 'python_%s_%s_%s' % (platform, arch, py_version)
+ self.platform = platform
+ self.arch = arch
+ self.labels = ['artifact', 'python', platform, arch, py_version]
+ self.py_version = py_version
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ environ = {}
+ if self.platform == 'linux_extra':
+ # Raspberry Pi build
+ environ['PYTHON'] = '/usr/local/bin/python{}'.format(
+ self.py_version)
+ environ['PIP'] = '/usr/local/bin/pip{}'.format(self.py_version)
+ # https://github.com/resin-io-projects/armv7hf-debian-qemu/issues/9
+ # A QEMU bug causes submodule update to hang, so we copy directly
+ environ['RELATIVE_COPY_PATH'] = '.'
+ extra_args = ' --entrypoint=/usr/bin/qemu-arm-static '
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch),
+ 'tools/run_tests/artifacts/build_artifact_python.sh',
+ environ=environ,
+ timeout_seconds=60 * 60 * 5,
+ docker_base_image='quay.io/grpc/raspbian_{}'.format(self.arch),
+ extra_docker_args=extra_args)
+ elif self.platform == 'linux':
+ if self.arch == 'x86':
+ environ['SETARCH_CMD'] = 'linux32'
+ # Inside the manylinux container, the python installations are located in
+ # special places...
+ environ['PYTHON'] = '/opt/python/{}/bin/python'.format(
+ self.py_version)
+ environ['PIP'] = '/opt/python/{}/bin/pip'.format(self.py_version)
+ # Platform autodetection for the manylinux1 image breaks so we set the
+ # defines ourselves.
+ # TODO(atash) get better platform-detection support in core so we don't
+ # need to do this manually...
+ environ['CFLAGS'] = '-DGPR_MANYLINUX1=1'
+ environ['GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS'] = 'TRUE'
+ environ['GRPC_BUILD_MANYLINUX_WHEEL'] = 'TRUE'
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/grpc_artifact_python_manylinux_%s' %
+ self.arch,
+ 'tools/run_tests/artifacts/build_artifact_python.sh',
+ environ=environ,
+ timeout_seconds=60 * 60,
+ docker_base_image='quay.io/pypa/manylinux1_i686'
+ if self.arch == 'x86' else 'quay.io/pypa/manylinux1_x86_64')
+ elif self.platform == 'windows':
+ if 'Python27' in self.py_version or 'Python34' in self.py_version:
+ environ['EXT_COMPILER'] = 'mingw32'
+ else:
+ environ['EXT_COMPILER'] = 'msvc'
+ # For some reason, the batch script %random% always runs with the same
+ # seed. We create a random temp-dir here
+ dir = ''.join(
+ random.choice(string.ascii_uppercase) for _ in range(10))
+ return create_jobspec(
+ self.name, [
+ 'tools\\run_tests\\artifacts\\build_artifact_python.bat',
+ self.py_version, '32' if self.arch == 'x86' else '64'
+ ],
+ environ=environ,
+ timeout_seconds=45 * 60,
+ use_workspace=True)
+ else:
+ environ['PYTHON'] = self.py_version
+ environ['SKIP_PIP_INSTALL'] = 'TRUE'
+ return create_jobspec(
+ self.name,
+ ['tools/run_tests/artifacts/build_artifact_python.sh'],
+ environ=environ,
+ timeout_seconds=60 * 60,
+ use_workspace=True)
+
+ def __str__(self):
+ return self.name
class RubyArtifact:
- """Builds ruby native gem."""
+ """Builds ruby native gem."""
- def __init__(self, platform, arch):
- self.name = 'ruby_native_gem_%s_%s' % (platform, arch)
- self.platform = platform
- self.arch = arch
- self.labels = ['artifact', 'ruby', platform, arch]
+ def __init__(self, platform, arch):
+ self.name = 'ruby_native_gem_%s_%s' % (platform, arch)
+ self.platform = platform
+ self.arch = arch
+ self.labels = ['artifact', 'ruby', platform, arch]
- def pre_build_jobspecs(self):
- return []
+ def pre_build_jobspecs(self):
+ return []
- def build_jobspec(self):
- # Ruby build uses docker internally and docker cannot be nested.
- # We are using a custom workspace instead.
- return create_jobspec(self.name,
- ['tools/run_tests/artifacts/build_artifact_ruby.sh'],
- use_workspace=True,
- timeout_seconds=45*60)
+ def build_jobspec(self):
+ # Ruby build uses docker internally and docker cannot be nested.
+ # We are using a custom workspace instead.
+ return create_jobspec(
+ self.name, ['tools/run_tests/artifacts/build_artifact_ruby.sh'],
+ use_workspace=True,
+ timeout_seconds=45 * 60)
class CSharpExtArtifact:
- """Builds C# native extension library"""
-
- def __init__(self, platform, arch):
- self.name = 'csharp_ext_%s_%s' % (platform, arch)
- self.platform = platform
- self.arch = arch
- self.labels = ['artifact', 'csharp', platform, arch]
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform == 'windows':
- cmake_arch_option = 'Win32' if self.arch == 'x86' else self.arch
- return create_jobspec(self.name,
- ['tools\\run_tests\\artifacts\\build_artifact_csharp.bat',
- cmake_arch_option],
- use_workspace=True)
- else:
- environ = {'CONFIG': 'opt',
- 'EMBED_OPENSSL': 'true',
- 'EMBED_ZLIB': 'true',
- 'CFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE',
- 'CXXFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE',
- 'LDFLAGS': ''}
- if self.platform == 'linux':
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch,
- 'tools/run_tests/artifacts/build_artifact_csharp.sh',
- environ=environ)
- else:
- archflag = _ARCH_FLAG_MAP[self.arch]
- environ['CFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG)
- environ['CXXFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG)
- environ['LDFLAGS'] += ' %s' % archflag
- return create_jobspec(self.name,
- ['tools/run_tests/artifacts/build_artifact_csharp.sh'],
- environ=environ,
- use_workspace=True)
-
- def __str__(self):
- return self.name
-
-
-node_gyp_arch_map = {
- 'x86': 'ia32',
- 'x64': 'x64'
-}
-
-class NodeExtArtifact:
- """Builds Node native extension"""
-
- def __init__(self, platform, arch):
- self.name = 'node_ext_{0}_{1}'.format(platform, arch)
- self.platform = platform
- self.arch = arch
- self.gyp_arch = node_gyp_arch_map[arch]
- self.labels = ['artifact', 'node', platform, arch]
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform == 'windows':
- # Simultaneous builds of node on the same windows machine are flaky.
- # Set x86 build as exclusive to make sure there is only one node build
- # at a time. See https://github.com/grpc/grpc/issues/8293
- cpu_cost = 1e6 if self.arch != 'x64' else 1.0
- return create_jobspec(self.name,
- ['tools\\run_tests\\artifacts\\build_artifact_node.bat',
- self.gyp_arch],
- use_workspace=True,
- timeout_seconds=45*60,
- cpu_cost=cpu_cost)
- else:
- if self.platform == 'linux':
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch),
- 'tools/run_tests/artifacts/build_artifact_node.sh {} {}'.format(
- self.gyp_arch, self.platform))
- else:
- return create_jobspec(self.name,
- ['tools/run_tests/artifacts/build_artifact_node.sh',
- self.gyp_arch, self.platform],
- use_workspace=True)
+ """Builds C# native extension library"""
+
+ def __init__(self, platform, arch):
+ self.name = 'csharp_ext_%s_%s' % (platform, arch)
+ self.platform = platform
+ self.arch = arch
+ self.labels = ['artifact', 'csharp', platform, arch]
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ if self.platform == 'windows':
+ cmake_arch_option = 'Win32' if self.arch == 'x86' else self.arch
+ return create_jobspec(
+ self.name, [
+ 'tools\\run_tests\\artifacts\\build_artifact_csharp.bat',
+ cmake_arch_option
+ ],
+ use_workspace=True)
+ else:
+ environ = {
+ 'CONFIG': 'opt',
+ 'EMBED_OPENSSL': 'true',
+ 'EMBED_ZLIB': 'true',
+ 'CFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE',
+ 'CXXFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE',
+ 'LDFLAGS': ''
+ }
+ if self.platform == 'linux':
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch,
+ 'tools/run_tests/artifacts/build_artifact_csharp.sh',
+ environ=environ)
+ else:
+ archflag = _ARCH_FLAG_MAP[self.arch]
+ environ['CFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG)
+ environ['CXXFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG)
+ environ['LDFLAGS'] += ' %s' % archflag
+ return create_jobspec(
+ self.name,
+ ['tools/run_tests/artifacts/build_artifact_csharp.sh'],
+ environ=environ,
+ use_workspace=True)
+
+ def __str__(self):
+ return self.name
+
class PHPArtifact:
- """Builds PHP PECL package"""
-
- def __init__(self, platform, arch):
- self.name = 'php_pecl_package_{0}_{1}'.format(platform, arch)
- self.platform = platform
- self.arch = arch
- self.labels = ['artifact', 'php', platform, arch]
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform == 'linux':
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch),
- 'tools/run_tests/artifacts/build_artifact_php.sh')
- else:
- return create_jobspec(self.name,
- ['tools/run_tests/artifacts/build_artifact_php.sh'],
- use_workspace=True)
+ """Builds PHP PECL package"""
-class ProtocArtifact:
- """Builds protoc and protoc-plugin artifacts"""
-
- def __init__(self, platform, arch):
- self.name = 'protoc_%s_%s' % (platform, arch)
- self.platform = platform
- self.arch = arch
- self.labels = ['artifact', 'protoc', platform, arch]
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform != 'windows':
- cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch]
- ldflags = '%s' % _ARCH_FLAG_MAP[self.arch]
- if self.platform != 'macos':
- ldflags += ' -static-libgcc -static-libstdc++ -s'
- environ={'CONFIG': 'opt',
- 'CXXFLAGS': cxxflags,
- 'LDFLAGS': ldflags,
- 'PROTOBUF_LDFLAGS_EXTRA': ldflags}
- if self.platform == 'linux':
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/grpc_artifact_protoc',
- 'tools/run_tests/artifacts/build_artifact_protoc.sh',
- environ=environ)
- else:
- environ['CXXFLAGS'] += ' -std=c++11 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG
- return create_jobspec(self.name,
- ['tools/run_tests/artifacts/build_artifact_protoc.sh'],
- environ=environ,
- use_workspace=True)
- else:
- generator = 'Visual Studio 14 2015 Win64' if self.arch == 'x64' else 'Visual Studio 14 2015'
- return create_jobspec(self.name,
- ['tools\\run_tests\\artifacts\\build_artifact_protoc.bat'],
- environ={'generator': generator},
- use_workspace=True)
+ def __init__(self, platform, arch):
+ self.name = 'php_pecl_package_{0}_{1}'.format(platform, arch)
+ self.platform = platform
+ self.arch = arch
+ self.labels = ['artifact', 'php', platform, arch]
+
+ def pre_build_jobspecs(self):
+ return []
- def __str__(self):
- return self.name
+ def build_jobspec(self):
+ if self.platform == 'linux':
+ return create_docker_jobspec(
+ self.name, 'tools/dockerfile/grpc_artifact_linux_{}'.format(
+ self.arch),
+ 'tools/run_tests/artifacts/build_artifact_php.sh')
+ else:
+ return create_jobspec(
+ self.name, ['tools/run_tests/artifacts/build_artifact_php.sh'],
+ use_workspace=True)
+
+
+class ProtocArtifact:
+ """Builds protoc and protoc-plugin artifacts"""
+
+ def __init__(self, platform, arch):
+ self.name = 'protoc_%s_%s' % (platform, arch)
+ self.platform = platform
+ self.arch = arch
+ self.labels = ['artifact', 'protoc', platform, arch]
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ if self.platform != 'windows':
+ cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch]
+ ldflags = '%s' % _ARCH_FLAG_MAP[self.arch]
+ if self.platform != 'macos':
+ ldflags += ' -static-libgcc -static-libstdc++ -s'
+ environ = {
+ 'CONFIG': 'opt',
+ 'CXXFLAGS': cxxflags,
+ 'LDFLAGS': ldflags,
+ 'PROTOBUF_LDFLAGS_EXTRA': ldflags
+ }
+ if self.platform == 'linux':
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/grpc_artifact_protoc',
+ 'tools/run_tests/artifacts/build_artifact_protoc.sh',
+ environ=environ)
+ else:
+ environ[
+ 'CXXFLAGS'] += ' -std=c++11 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG
+ return create_jobspec(
+ self.name,
+ ['tools/run_tests/artifacts/build_artifact_protoc.sh'],
+ environ=environ,
+ use_workspace=True)
+ else:
+ generator = 'Visual Studio 14 2015 Win64' if self.arch == 'x64' else 'Visual Studio 14 2015'
+ return create_jobspec(
+ self.name,
+ ['tools\\run_tests\\artifacts\\build_artifact_protoc.bat'],
+ environ={'generator': generator},
+ use_workspace=True)
+
+ def __str__(self):
+ return self.name
def targets():
- """Gets list of supported targets"""
- return ([Cls(platform, arch)
- for Cls in (CSharpExtArtifact, NodeExtArtifact, ProtocArtifact)
- for platform in ('linux', 'macos', 'windows')
- for arch in ('x86', 'x64')] +
- [PythonArtifact('linux', 'x86', 'cp27-cp27m'),
- PythonArtifact('linux', 'x86', 'cp27-cp27mu'),
- PythonArtifact('linux', 'x86', 'cp34-cp34m'),
- PythonArtifact('linux', 'x86', 'cp35-cp35m'),
- PythonArtifact('linux', 'x86', 'cp36-cp36m'),
- PythonArtifact('linux_extra', 'armv7', '2.7'),
- PythonArtifact('linux_extra', 'armv7', '3.4'),
- PythonArtifact('linux_extra', 'armv7', '3.5'),
- PythonArtifact('linux_extra', 'armv7', '3.6'),
- PythonArtifact('linux_extra', 'armv6', '2.7'),
- PythonArtifact('linux_extra', 'armv6', '3.4'),
- PythonArtifact('linux_extra', 'armv6', '3.5'),
- PythonArtifact('linux_extra', 'armv6', '3.6'),
- PythonArtifact('linux', 'x64', 'cp27-cp27m'),
- PythonArtifact('linux', 'x64', 'cp27-cp27mu'),
- PythonArtifact('linux', 'x64', 'cp34-cp34m'),
- PythonArtifact('linux', 'x64', 'cp35-cp35m'),
- PythonArtifact('linux', 'x64', 'cp36-cp36m'),
- PythonArtifact('macos', 'x64', 'python2.7'),
- PythonArtifact('macos', 'x64', 'python3.4'),
- PythonArtifact('macos', 'x64', 'python3.5'),
- PythonArtifact('macos', 'x64', 'python3.6'),
- PythonArtifact('windows', 'x86', 'Python27_32bits'),
- PythonArtifact('windows', 'x86', 'Python34_32bits'),
- PythonArtifact('windows', 'x86', 'Python35_32bits'),
- PythonArtifact('windows', 'x86', 'Python36_32bits'),
- PythonArtifact('windows', 'x64', 'Python27'),
- PythonArtifact('windows', 'x64', 'Python34'),
- PythonArtifact('windows', 'x64', 'Python35'),
- PythonArtifact('windows', 'x64', 'Python36'),
- RubyArtifact('linux', 'x64'),
- RubyArtifact('macos', 'x64'),
- PHPArtifact('linux', 'x64'),
- PHPArtifact('macos', 'x64')])
+ """Gets list of supported targets"""
+ return ([
+ Cls(platform, arch)
+ for Cls in (CSharpExtArtifact, ProtocArtifact)
+ for platform in ('linux', 'macos', 'windows') for arch in ('x86', 'x64')
+ ] + [
+ PythonArtifact('linux', 'x86', 'cp27-cp27m'),
+ PythonArtifact('linux', 'x86', 'cp27-cp27mu'),
+ PythonArtifact('linux', 'x86', 'cp34-cp34m'),
+ PythonArtifact('linux', 'x86', 'cp35-cp35m'),
+ PythonArtifact('linux', 'x86', 'cp36-cp36m'),
+ PythonArtifact('linux_extra', 'armv7', '2.7'),
+ PythonArtifact('linux_extra', 'armv7', '3.4'),
+ PythonArtifact('linux_extra', 'armv7', '3.5'),
+ PythonArtifact('linux_extra', 'armv7', '3.6'),
+ PythonArtifact('linux_extra', 'armv6', '2.7'),
+ PythonArtifact('linux_extra', 'armv6', '3.4'),
+ PythonArtifact('linux_extra', 'armv6', '3.5'),
+ PythonArtifact('linux_extra', 'armv6', '3.6'),
+ PythonArtifact('linux', 'x64', 'cp27-cp27m'),
+ PythonArtifact('linux', 'x64', 'cp27-cp27mu'),
+ PythonArtifact('linux', 'x64', 'cp34-cp34m'),
+ PythonArtifact('linux', 'x64', 'cp35-cp35m'),
+ PythonArtifact('linux', 'x64', 'cp36-cp36m'),
+ PythonArtifact('macos', 'x64', 'python2.7'),
+ PythonArtifact('macos', 'x64', 'python3.4'),
+ PythonArtifact('macos', 'x64', 'python3.5'),
+ PythonArtifact('macos', 'x64', 'python3.6'),
+ PythonArtifact('windows', 'x86', 'Python27_32bits'),
+ PythonArtifact('windows', 'x86', 'Python34_32bits'),
+ PythonArtifact('windows', 'x86', 'Python35_32bits'),
+ PythonArtifact('windows', 'x86', 'Python36_32bits'),
+ PythonArtifact('windows', 'x64', 'Python27'),
+ PythonArtifact('windows', 'x64', 'Python34'),
+ PythonArtifact('windows', 'x64', 'Python35'),
+ PythonArtifact('windows', 'x64', 'Python36'),
+ RubyArtifact('linux', 'x64'),
+ RubyArtifact('macos', 'x64'),
+ PHPArtifact('linux', 'x64'),
+ PHPArtifact('macos', 'x64')
+ ])
diff --git a/tools/run_tests/artifacts/build_artifact_csharp.sh b/tools/run_tests/artifacts/build_artifact_csharp.sh
index 0884a9e5d6..d65340261d 100755
--- a/tools/run_tests/artifacts/build_artifact_csharp.sh
+++ b/tools/run_tests/artifacts/build_artifact_csharp.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
make grpc_csharp_ext
diff --git a/tools/run_tests/artifacts/build_artifact_node.bat b/tools/run_tests/artifacts/build_artifact_node.bat
deleted file mode 100644
index 7f1d1aad23..0000000000
--- a/tools/run_tests/artifacts/build_artifact_node.bat
+++ /dev/null
@@ -1,48 +0,0 @@
-@rem Copyright 2016 gRPC authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-
-set node_versions=4.0.0 5.0.0 6.0.0 7.0.0 8.0.0
-
-set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0
-
-set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm
-
-del /f /q BUILD || rmdir build /s /q
-
-call npm update || goto :error
-
-mkdir -p %ARTIFACTS_OUT%
-
-for %%v in (%node_versions%) do (
- call .\node_modules\.bin\node-pre-gyp.cmd configure build --target=%%v --target_arch=%1
-
-@rem Try again after removing openssl headers
- rmdir "%USERPROFILE%\.node-gyp\%%v\include\node\openssl" /S /Q
- rmdir "%USERPROFILE%\.node-gyp\iojs-%%v\include\node\openssl" /S /Q
- call .\node_modules\.bin\node-pre-gyp.cmd build package --target=%%v --target_arch=%1 || goto :error
-
- xcopy /Y /I /S build\stage\* %ARTIFACTS_OUT%\ || goto :error
-)
-
-for %%v in (%electron_versions%) do (
- cmd /V /C "set "HOME=%USERPROFILE%\electron-gyp" && call .\node_modules\.bin\node-pre-gyp.cmd configure rebuild package --runtime=electron --target=%%v --target_arch=%1 --disturl=https://atom.io/download/electron" || goto :error
-
- xcopy /Y /I /S build\stage\* %ARTIFACTS_OUT%\ || goto :error
-)
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-goto :EOF
-
-:error
-exit /b 1
diff --git a/tools/run_tests/artifacts/build_artifact_node.sh b/tools/run_tests/artifacts/build_artifact_node.sh
deleted file mode 100755
index 628d880f16..0000000000
--- a/tools/run_tests/artifacts/build_artifact_node.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-# 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.
-
-NODE_TARGET_ARCH=$1
-NODE_TARGET_OS=$2
-source ~/.nvm/nvm.sh
-
-nvm use 8
-set -ex
-
-cd $(dirname $0)/../../..
-
-rm -rf build || true
-
-mkdir -p "${ARTIFACTS_OUT}"
-
-npm update
-
-node_versions=( 4.0.0 5.0.0 6.0.0 7.0.0 8.0.0 )
-
-electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 )
-
-for version in ${node_versions[@]}
-do
- ./node_modules/.bin/node-pre-gyp configure rebuild package --target=$version --target_arch=$NODE_TARGET_ARCH --grpc_alpine=true
- cp -r build/stage/* "${ARTIFACTS_OUT}"/
- if [ "$NODE_TARGET_ARCH" == 'x64' ] && [ "$NODE_TARGET_OS" == 'linux' ]
- then
- # Cross compile for ARM on x64
- CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ LD=arm-linux-gnueabihf-g++ ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=arm
- cp -r build/stage/* "${ARTIFACTS_OUT}"/
- fi
-done
-
-for version in ${electron_versions[@]}
-do
- HOME=~/.electron-gyp ./node_modules/.bin/node-pre-gyp configure rebuild package --runtime=electron --target=$version --target_arch=$NODE_TARGET_ARCH --disturl=https://atom.io/download/electron
- cp -r build/stage/* "${ARTIFACTS_OUT}"/
-done
diff --git a/tools/run_tests/artifacts/build_artifact_php.sh b/tools/run_tests/artifacts/build_artifact_php.sh
index bfba956f05..9372dc9b6b 100755
--- a/tools/run_tests/artifacts/build_artifact_php.sh
+++ b/tools/run_tests/artifacts/build_artifact_php.sh
@@ -13,10 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-PHP_TARGET_ARCH=$1
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
mkdir -p "${ARTIFACTS_OUT}"
diff --git a/tools/run_tests/artifacts/build_artifact_protoc.sh b/tools/run_tests/artifacts/build_artifact_protoc.sh
index 5c5ab7d78f..b531fc9a5d 100755
--- a/tools/run_tests/artifacts/build_artifact_protoc.sh
+++ b/tools/run_tests/artifacts/build_artifact_protoc.sh
@@ -18,7 +18,7 @@ source scl_source enable devtoolset-1.1
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
make plugins
diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh
index ab5bce04f9..10d8211e23 100755
--- a/tools/run_tests/artifacts/build_artifact_python.sh
+++ b/tools/run_tests/artifacts/build_artifact_python.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
export GRPC_PYTHON_USE_CUSTOM_BDIST=0
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
@@ -29,30 +29,30 @@ ARTIFACT_DIR="$PWD/${ARTIFACTS_OUT}"
# Build the source distribution first because MANIFEST.in cannot override
# exclusion of built shared objects among package resources (for some
# inexplicable reason).
-${SETARCH_CMD} ${PYTHON} setup.py sdist
+${SETARCH_CMD} "${PYTHON}" setup.py sdist
# Wheel has a bug where directories don't get excluded.
# https://bitbucket.org/pypa/wheel/issues/99/cannot-exclude-directory
-${SETARCH_CMD} ${PYTHON} setup.py bdist_wheel
+${SETARCH_CMD} "${PYTHON}" setup.py bdist_wheel
# Build gRPC tools package distribution
-${PYTHON} tools/distrib/python/make_grpcio_tools.py
+"${PYTHON}" tools/distrib/python/make_grpcio_tools.py
# Build gRPC tools package source distribution
-${SETARCH_CMD} ${PYTHON} tools/distrib/python/grpcio_tools/setup.py sdist
+${SETARCH_CMD} "${PYTHON}" tools/distrib/python/grpcio_tools/setup.py sdist
# Build gRPC tools package binary distribution
-${SETARCH_CMD} ${PYTHON} tools/distrib/python/grpcio_tools/setup.py bdist_wheel
+${SETARCH_CMD} "${PYTHON}" tools/distrib/python/grpcio_tools/setup.py bdist_wheel
if [ "$GRPC_BUILD_MANYLINUX_WHEEL" != "" ]
then
for wheel in dist/*.whl; do
- ${AUDITWHEEL} repair $wheel -w "$ARTIFACT_DIR"
- rm $wheel
+ "${AUDITWHEEL}" repair "$wheel" -w "$ARTIFACT_DIR"
+ rm "$wheel"
done
for wheel in tools/distrib/python/grpcio_tools/dist/*.whl; do
- ${AUDITWHEEL} repair $wheel -w "$ARTIFACT_DIR"
- rm $wheel
+ "${AUDITWHEEL}" repair "$wheel" -w "$ARTIFACT_DIR"
+ rm "$wheel"
done
fi
@@ -62,17 +62,17 @@ fi
# are in a docker image or in a virtualenv.
if [ "$GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS" != "" ]
then
- ${PIP} install -rrequirements.txt
- ${PIP} install grpcio --no-index --find-links "file://$ARTIFACT_DIR/"
- ${PIP} install grpcio-tools --no-index --find-links "file://$ARTIFACT_DIR/"
+ "${PIP}" install -rrequirements.txt
+ "${PIP}" install grpcio --no-index --find-links "file://$ARTIFACT_DIR/"
+ "${PIP}" install grpcio-tools --no-index --find-links "file://$ARTIFACT_DIR/"
# Build gRPC health-checking source distribution
- ${SETARCH_CMD} ${PYTHON} src/python/grpcio_health_checking/setup.py \
+ ${SETARCH_CMD} "${PYTHON}" src/python/grpcio_health_checking/setup.py \
preprocess build_package_protos sdist
cp -r src/python/grpcio_health_checking/dist/* "$ARTIFACT_DIR"
# Build gRPC reflection source distribution
- ${SETARCH_CMD} ${PYTHON} src/python/grpcio_reflection/setup.py \
+ ${SETARCH_CMD} "${PYTHON}" src/python/grpcio_reflection/setup.py \
preprocess build_package_protos sdist
cp -r src/python/grpcio_reflection/dist/* "$ARTIFACT_DIR"
fi
diff --git a/tools/run_tests/artifacts/build_artifact_ruby.sh b/tools/run_tests/artifacts/build_artifact_ruby.sh
index 993aaaedbd..5ab4cf21b4 100755
--- a/tools/run_tests/artifacts/build_artifact_ruby.sh
+++ b/tools/run_tests/artifacts/build_artifact_ruby.sh
@@ -14,9 +14,9 @@
# limitations under the License.
set -ex
-SYSTEM=`uname | cut -f 1 -d_`
+SYSTEM=$(uname | cut -f 1 -d_)
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
set +ex
[[ -s /etc/profile.d/rvm.sh ]] && . /etc/profile.d/rvm.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
@@ -42,10 +42,13 @@ tools/run_tests/helper_scripts/bundle_install_wrapper.sh
set -ex
+export DOCKERHUB_ORGANIZATION=grpctesting
rake gem:native
if [ "$SYSTEM" == "Darwin" ] ; then
- rm `ls pkg/*.gem | grep -v darwin`
+ # TODO: consider rewriting this to pass shellcheck
+ # shellcheck disable=SC2046,SC2010
+ rm $(ls pkg/*.gem | grep -v darwin)
fi
mkdir -p "${ARTIFACTS_OUT}"
diff --git a/tools/run_tests/artifacts/build_package_node.sh b/tools/run_tests/artifacts/build_package_node.sh
deleted file mode 100755
index 2860f68bc4..0000000000
--- a/tools/run_tests/artifacts/build_package_node.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-# 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.
-
-source ~/.nvm/nvm.sh
-
-nvm use 8
-set -ex
-
-cd $(dirname $0)/../../..
-
-base=$(pwd)
-
-artifacts=$base/artifacts
-
-mkdir -p $artifacts
-cp -r $EXTERNAL_GIT_ROOT/platform={windows,linux,macos}/artifacts/node_ext_*/* $artifacts/ || true
-
-npm update
-npm pack
-
-cp grpc-*.tgz $artifacts/grpc.tgz
-
-mkdir -p bin
-
-cd $base/src/node/health_check
-npm pack
-cp grpc-health-check-*.tgz $artifacts/
-
-cd $base/src/node/tools
-npm update
-npm pack
-cp grpc-tools-*.tgz $artifacts/
-tools_version=$(npm list | grep -oP '(?<=grpc-tools@)\S+')
-
-output_dir=$artifacts/grpc-precompiled-binaries/node/grpc-tools/v$tools_version
-mkdir -p $output_dir
-
-well_known_protos=( any api compiler/plugin descriptor duration empty field_mask source_context struct timestamp type wrappers )
-
-for arch in {x86,x64}; do
- case $arch in
- x86)
- node_arch=ia32
- ;;
- *)
- node_arch=$arch
- ;;
- esac
- for plat in {windows,linux,macos}; do
- case $plat in
- windows)
- node_plat=win32
- ;;
- macos)
- node_plat=darwin
- ;;
- *)
- node_plat=$plat
- ;;
- esac
- rm -r bin/*
- input_dir="$EXTERNAL_GIT_ROOT/platform=${plat}/artifacts/protoc_${plat}_${arch}"
- cp $input_dir/protoc* bin/
- cp $input_dir/grpc_node_plugin* bin/
- mkdir -p bin/google/protobuf
- mkdir -p bin/google/protobuf/compiler # needed for plugin.proto
- for proto in "${well_known_protos[@]}"; do
- cp $base/third_party/protobuf/src/google/protobuf/$proto.proto bin/google/protobuf/$proto.proto
- done
- tar -czf $output_dir/$node_plat-$node_arch.tar.gz bin/
- done
-done
diff --git a/tools/run_tests/artifacts/build_package_php.sh b/tools/run_tests/artifacts/build_package_php.sh
index d2d1e8d459..85e4dda40a 100755
--- a/tools/run_tests/artifacts/build_package_php.sh
+++ b/tools/run_tests/artifacts/build_package_php.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
mkdir -p artifacts/
-cp -r $EXTERNAL_GIT_ROOT/platform={windows,linux,macos}/artifacts/php_*/* artifacts/ || true
+cp -r "$EXTERNAL_GIT_ROOT"/platform={windows,linux,macos}/artifacts/php_*/* artifacts/ || true
diff --git a/tools/run_tests/artifacts/build_package_python.sh b/tools/run_tests/artifacts/build_package_python.sh
index 1d9d04e3c0..d596e35000 100755
--- a/tools/run_tests/artifacts/build_package_python.sh
+++ b/tools/run_tests/artifacts/build_package_python.sh
@@ -15,13 +15,13 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
mkdir -p artifacts/
# All the python packages have been built in the artifact phase already
# and we only collect them here to deliver them to the distribtest phase.
-cp -r $EXTERNAL_GIT_ROOT/platform={windows,linux,macos}/artifacts/python_*/* artifacts/ || true
+cp -r "$EXTERNAL_GIT_ROOT"/platform={windows,linux,macos}/artifacts/python_*/* artifacts/ || true
# TODO: all the artifact builder configurations generate a grpcio-VERSION.tar.gz
# source distribution package, and only one of them will end up
diff --git a/tools/run_tests/artifacts/build_package_ruby.sh b/tools/run_tests/artifacts/build_package_ruby.sh
index b7e0965ffe..0283c43843 100755
--- a/tools/run_tests/artifacts/build_package_ruby.sh
+++ b/tools/run_tests/artifacts/build_package_ruby.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
base=$(pwd)
@@ -23,7 +23,7 @@ mkdir -p artifacts/
# All the ruby packages have been built in the artifact phase already
# and we only collect them here to deliver them to the distribtest phase.
-cp -r $EXTERNAL_GIT_ROOT/platform={windows,linux,macos}/artifacts/ruby_native_gem_*/* artifacts/ || true
+cp -r "$EXTERNAL_GIT_ROOT"/platform={windows,linux,macos}/artifacts/ruby_native_gem_*/* artifacts/ || true
well_known_protos=( any api compiler/plugin descriptor duration empty field_mask source_context struct timestamp type wrappers )
@@ -43,16 +43,16 @@ for arch in {x86,x64}; do
for plat in {windows,linux,macos}; do
input_dir="$EXTERNAL_GIT_ROOT/platform=${plat}/artifacts/protoc_${plat}_${arch}"
output_dir="$base/src/ruby/tools/bin/${ruby_arch}-${plat}"
- mkdir -p $output_dir/google/protobuf
- mkdir -p $output_dir/google/protobuf/compiler # needed for plugin.proto
- cp $input_dir/protoc* $output_dir/
- cp $input_dir/grpc_ruby_plugin* $output_dir/
+ mkdir -p "$output_dir"/google/protobuf
+ mkdir -p "$output_dir"/google/protobuf/compiler # needed for plugin.proto
+ cp "$input_dir"/protoc* "$output_dir"/
+ cp "$input_dir"/grpc_ruby_plugin* "$output_dir"/
for proto in "${well_known_protos[@]}"; do
- cp $base/third_party/protobuf/src/google/protobuf/$proto.proto $output_dir/google/protobuf/$proto.proto
+ cp "$base/third_party/protobuf/src/google/protobuf/$proto.proto" "$output_dir/google/protobuf/$proto.proto"
done
done
done
-cd $base/src/ruby/tools
+cd "$base/src/ruby/tools"
gem build grpc-tools.gemspec
-cp ./grpc-tools*.gem $base/artifacts/
+cp ./grpc-tools*.gem "$base/artifacts/"
diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py
index 797ed51c7f..fdf094cd01 100644
--- a/tools/run_tests/artifacts/distribtest_targets.py
+++ b/tools/run_tests/artifacts/distribtest_targets.py
@@ -12,7 +12,6 @@
# 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.
-
"""Definition of targets run distribution package tests."""
import os.path
@@ -22,321 +21,317 @@ sys.path.insert(0, os.path.abspath('..'))
import python_utils.jobset as jobset
-def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
- flake_retries=0, timeout_retries=0,
- copy_rel_path=None):
- """Creates jobspec for a task running under docker."""
- environ = environ.copy()
- environ['RUN_COMMAND'] = shell_command
- # the entire repo will be cloned if copy_rel_path is not set.
- if copy_rel_path:
- environ['RELATIVE_COPY_PATH'] = copy_rel_path
-
- docker_args=[]
- for k,v in environ.items():
- docker_args += ['-e', '%s=%s' % (k, v)]
- docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
- 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh'}
- jobspec = jobset.JobSpec(
- cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args,
- environ=docker_env,
- shortname='distribtest.%s' % (name),
- timeout_seconds=30*60,
- flake_retries=flake_retries,
- timeout_retries=timeout_retries)
- return jobspec
-
-
-def create_jobspec(name, cmdline, environ=None, shell=False,
- flake_retries=0, timeout_retries=0,
- use_workspace=False):
- """Creates jobspec."""
- environ = environ.copy()
- if use_workspace:
- environ['WORKSPACE_NAME'] = 'workspace_%s' % name
- cmdline = ['bash',
- 'tools/run_tests/artifacts/run_in_workspace.sh'] + cmdline
- jobspec = jobset.JobSpec(
- cmdline=cmdline,
- environ=environ,
- shortname='distribtest.%s' % (name),
- timeout_seconds=10*60,
- flake_retries=flake_retries,
- timeout_retries=timeout_retries,
- shell=shell)
- return jobspec
+def create_docker_jobspec(name,
+ dockerfile_dir,
+ shell_command,
+ environ={},
+ flake_retries=0,
+ timeout_retries=0,
+ copy_rel_path=None):
+ """Creates jobspec for a task running under docker."""
+ environ = environ.copy()
+ environ['RUN_COMMAND'] = shell_command
+ # the entire repo will be cloned if copy_rel_path is not set.
+ if copy_rel_path:
+ environ['RELATIVE_COPY_PATH'] = copy_rel_path
+
+ docker_args = []
+ for k, v in environ.items():
+ docker_args += ['-e', '%s=%s' % (k, v)]
+ docker_env = {
+ 'DOCKERFILE_DIR': dockerfile_dir,
+ 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh'
+ }
+ jobspec = jobset.JobSpec(
+ cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] +
+ docker_args,
+ environ=docker_env,
+ shortname='distribtest.%s' % (name),
+ timeout_seconds=30 * 60,
+ flake_retries=flake_retries,
+ timeout_retries=timeout_retries)
+ return jobspec
+
+
+def create_jobspec(name,
+ cmdline,
+ environ=None,
+ shell=False,
+ flake_retries=0,
+ timeout_retries=0,
+ use_workspace=False,
+ timeout_seconds=10 * 60):
+ """Creates jobspec."""
+ environ = environ.copy()
+ if use_workspace:
+ environ['WORKSPACE_NAME'] = 'workspace_%s' % name
+ cmdline = ['bash', 'tools/run_tests/artifacts/run_in_workspace.sh'
+ ] + cmdline
+ jobspec = jobset.JobSpec(
+ cmdline=cmdline,
+ environ=environ,
+ shortname='distribtest.%s' % (name),
+ timeout_seconds=timeout_seconds,
+ flake_retries=flake_retries,
+ timeout_retries=timeout_retries,
+ shell=shell)
+ return jobspec
class CSharpDistribTest(object):
- """Tests C# NuGet package"""
-
- def __init__(self, platform, arch, docker_suffix=None, use_dotnet_cli=False):
- self.name = 'csharp_%s_%s' % (platform, arch)
- self.platform = platform
- self.arch = arch
- self.docker_suffix = docker_suffix
- self.labels = ['distribtest', 'csharp', platform, arch]
- self.script_suffix = ''
- if docker_suffix:
- self.name += '_%s' % docker_suffix
- self.labels.append(docker_suffix)
- if use_dotnet_cli:
- self.name += '_dotnetcli'
- self.script_suffix = '_dotnetcli'
- self.labels.append('dotnetcli')
- else:
- self.labels.append('olddotnet')
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform == 'linux':
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/distribtest/csharp_%s_%s' % (
- self.docker_suffix,
- self.arch),
- 'test/distrib/csharp/run_distrib_test%s.sh' % self.script_suffix,
- copy_rel_path='test/distrib')
- elif self.platform == 'macos':
- return create_jobspec(self.name,
- ['test/distrib/csharp/run_distrib_test%s.sh' % self.script_suffix],
- environ={'EXTERNAL_GIT_ROOT': '../../../..'},
- use_workspace=True)
- elif self.platform == 'windows':
- if self.arch == 'x64':
- # Use double leading / as the first occurence gets removed by msys bash
- # when invoking the .bat file (side-effect of posix path conversion)
- environ={'MSBUILD_EXTRA_ARGS': '//p:Platform=x64',
- 'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\x64\\Debug'}
- else:
- environ={'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\Debug'}
- return create_jobspec(self.name,
- ['test\\distrib\\csharp\\run_distrib_test%s.bat' % self.script_suffix],
- environ=environ,
- use_workspace=True)
- else:
- raise Exception("Not supported yet.")
-
- def __str__(self):
- return self.name
-
-class NodeDistribTest(object):
- """Tests Node package"""
-
- def __init__(self, platform, arch, docker_suffix, node_version):
- self.name = 'node_npm_%s_%s_%s' % (platform, arch, node_version)
- self.platform = platform
- self.arch = arch
- self.node_version = node_version
- self.labels = ['distribtest', 'node', platform, arch,
- 'node-%s' % node_version]
- if docker_suffix is not None:
- self.name += '_%s' % docker_suffix
- self.docker_suffix = docker_suffix
- self.labels.append(docker_suffix)
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform == 'linux':
- linux32 = ''
- if self.arch == 'x86':
- linux32 = 'linux32'
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/distribtest/node_%s_%s' % (
- self.docker_suffix,
- self.arch),
- '%s test/distrib/node/run_distrib_test.sh %s' % (
- linux32,
- self.node_version),
- copy_rel_path='test/distrib')
- elif self.platform == 'macos':
- return create_jobspec(self.name,
- ['test/distrib/node/run_distrib_test.sh',
- str(self.node_version)],
- environ={'EXTERNAL_GIT_ROOT': '../../../..'},
- use_workspace=True)
- else:
- raise Exception("Not supported yet.")
+ """Tests C# NuGet package"""
+
+ def __init__(self, platform, arch, docker_suffix=None,
+ use_dotnet_cli=False):
+ self.name = 'csharp_%s_%s' % (platform, arch)
+ self.platform = platform
+ self.arch = arch
+ self.docker_suffix = docker_suffix
+ self.labels = ['distribtest', 'csharp', platform, arch]
+ self.script_suffix = ''
+ if docker_suffix:
+ self.name += '_%s' % docker_suffix
+ self.labels.append(docker_suffix)
+ if use_dotnet_cli:
+ self.name += '_dotnetcli'
+ self.script_suffix = '_dotnetcli'
+ self.labels.append('dotnetcli')
+ else:
+ self.labels.append('olddotnet')
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ if self.platform == 'linux':
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/distribtest/csharp_%s_%s' %
+ (self.docker_suffix, self.arch),
+ 'test/distrib/csharp/run_distrib_test%s.sh' %
+ self.script_suffix,
+ copy_rel_path='test/distrib')
+ elif self.platform == 'macos':
+ return create_jobspec(
+ self.name, [
+ 'test/distrib/csharp/run_distrib_test%s.sh' %
+ self.script_suffix
+ ],
+ environ={'EXTERNAL_GIT_ROOT': '../../../..'},
+ use_workspace=True)
+ elif self.platform == 'windows':
+ if self.arch == 'x64':
+ # Use double leading / as the first occurence gets removed by msys bash
+ # when invoking the .bat file (side-effect of posix path conversion)
+ environ = {
+ 'MSBUILD_EXTRA_ARGS': '//p:Platform=x64',
+ 'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\x64\\Debug'
+ }
+ else:
+ environ = {'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\Debug'}
+ return create_jobspec(
+ self.name, [
+ 'test\\distrib\\csharp\\run_distrib_test%s.bat' %
+ self.script_suffix
+ ],
+ environ=environ,
+ use_workspace=True)
+ else:
+ raise Exception("Not supported yet.")
def __str__(self):
- return self.name
+ return self.name
class PythonDistribTest(object):
- """Tests Python package"""
+ """Tests Python package"""
- def __init__(self, platform, arch, docker_suffix):
- self.name = 'python_%s_%s_%s' % (platform, arch, docker_suffix)
- self.platform = platform
- self.arch = arch
- self.docker_suffix = docker_suffix
- self.labels = ['distribtest', 'python', platform, arch, docker_suffix]
+ def __init__(self, platform, arch, docker_suffix):
+ self.name = 'python_%s_%s_%s' % (platform, arch, docker_suffix)
+ self.platform = platform
+ self.arch = arch
+ self.docker_suffix = docker_suffix
+ self.labels = ['distribtest', 'python', platform, arch, docker_suffix]
- def pre_build_jobspecs(self):
- return []
+ def pre_build_jobspecs(self):
+ return []
- def build_jobspec(self):
- if not self.platform == 'linux':
- raise Exception("Not supported yet.")
+ def build_jobspec(self):
+ if not self.platform == 'linux':
+ raise Exception("Not supported yet.")
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/distribtest/python_%s_%s' % (
- self.docker_suffix,
- self.arch),
- 'test/distrib/python/run_distrib_test.sh',
- copy_rel_path='test/distrib')
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/distribtest/python_%s_%s' % (self.docker_suffix,
+ self.arch),
+ 'test/distrib/python/run_distrib_test.sh',
+ copy_rel_path='test/distrib')
- def __str__(self):
- return self.name
+ def __str__(self):
+ return self.name
class RubyDistribTest(object):
- """Tests Ruby package"""
-
- def __init__(self, platform, arch, docker_suffix):
- self.name = 'ruby_%s_%s_%s' % (platform, arch, docker_suffix)
- self.platform = platform
- self.arch = arch
- self.docker_suffix = docker_suffix
- self.labels = ['distribtest', 'ruby', platform, arch, docker_suffix]
-
- def pre_build_jobspecs(self):
- return []
+ """Tests Ruby package"""
+
+ def __init__(self, platform, arch, docker_suffix, ruby_version=None):
+ self.name = 'ruby_%s_%s_%s_version_%s' % (platform, arch, docker_suffix,
+ ruby_version or 'unspecified')
+ self.platform = platform
+ self.arch = arch
+ self.docker_suffix = docker_suffix
+ self.ruby_version = ruby_version
+ self.labels = ['distribtest', 'ruby', platform, arch, docker_suffix]
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ arch_to_gem_arch = {
+ 'x64': 'x86_64',
+ 'x86': 'x86',
+ }
+ if not self.platform == 'linux':
+ raise Exception("Not supported yet.")
+
+ dockerfile_name = 'tools/dockerfile/distribtest/ruby_%s_%s' % (
+ self.docker_suffix, self.arch)
+ if self.ruby_version is not None:
+ dockerfile_name += '_%s' % self.ruby_version
+ return create_docker_jobspec(
+ self.name,
+ dockerfile_name,
+ 'test/distrib/ruby/run_distrib_test.sh %s %s' %
+ (arch_to_gem_arch[self.arch], self.platform),
+ copy_rel_path='test/distrib')
- def build_jobspec(self):
- if not self.platform == 'linux':
- raise Exception("Not supported yet.")
-
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/distribtest/ruby_%s_%s' % (
- self.docker_suffix,
- self.arch),
- 'test/distrib/ruby/run_distrib_test.sh',
- copy_rel_path='test/distrib')
-
- def __str__(self):
- return self.name
+ def __str__(self):
+ return self.name
class PHPDistribTest(object):
- """Tests PHP package"""
-
- def __init__(self, platform, arch, docker_suffix=None):
- self.name = 'php_%s_%s_%s' % (platform, arch, docker_suffix)
- self.platform = platform
- self.arch = arch
- self.docker_suffix = docker_suffix
- self.labels = ['distribtest', 'php', platform, arch, docker_suffix]
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.platform == 'linux':
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/distribtest/php_%s_%s' % (
- self.docker_suffix,
- self.arch),
- 'test/distrib/php/run_distrib_test.sh',
- copy_rel_path='test/distrib')
- elif self.platform == 'macos':
- return create_jobspec(self.name,
- ['test/distrib/php/run_distrib_test.sh'],
- environ={'EXTERNAL_GIT_ROOT': '../../../..'},
- use_workspace=True)
- else:
- raise Exception("Not supported yet.")
-
- def __str__(self):
- return self.name
+ """Tests PHP package"""
+
+ def __init__(self, platform, arch, docker_suffix=None):
+ self.name = 'php_%s_%s_%s' % (platform, arch, docker_suffix)
+ self.platform = platform
+ self.arch = arch
+ self.docker_suffix = docker_suffix
+ self.labels = ['distribtest', 'php', platform, arch, docker_suffix]
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ if self.platform == 'linux':
+ return create_docker_jobspec(
+ self.name,
+ 'tools/dockerfile/distribtest/php_%s_%s' % (self.docker_suffix,
+ self.arch),
+ 'test/distrib/php/run_distrib_test.sh',
+ copy_rel_path='test/distrib')
+ elif self.platform == 'macos':
+ return create_jobspec(
+ self.name, ['test/distrib/php/run_distrib_test.sh'],
+ environ={'EXTERNAL_GIT_ROOT': '../../../..'},
+ use_workspace=True)
+ else:
+ raise Exception("Not supported yet.")
+ def __str__(self):
+ return self.name
-class CppDistribTest(object):
- """Tests Cpp make intall by building examples."""
-
- def __init__(self, platform, arch, docker_suffix=None, testcase=None):
- self.name = 'cpp_%s_%s_%s_%s' % (platform, arch, docker_suffix, testcase)
- self.platform = platform
- self.arch = arch
- self.docker_suffix = docker_suffix
- self.testcase = testcase
- self.labels = ['distribtest', 'cpp', platform, arch, docker_suffix, testcase]
-
- def pre_build_jobspecs(self):
- return []
- def build_jobspec(self):
- if self.platform == 'linux':
- return create_docker_jobspec(self.name,
- 'tools/dockerfile/distribtest/cpp_%s_%s' % (
- self.docker_suffix,
- self.arch),
- 'test/distrib/cpp/run_distrib_test_%s.sh' % self.testcase)
- else:
- raise Exception("Not supported yet.")
+class CppDistribTest(object):
+ """Tests Cpp make intall by building examples."""
+
+ def __init__(self, platform, arch, docker_suffix=None, testcase=None):
+ if platform == 'linux':
+ self.name = 'cpp_%s_%s_%s_%s' % (platform, arch, docker_suffix,
+ testcase)
+ else:
+ self.name = 'cpp_%s_%s_%s' % (platform, arch, testcase)
+ self.platform = platform
+ self.arch = arch
+ self.docker_suffix = docker_suffix
+ self.testcase = testcase
+ self.labels = [
+ 'distribtest', 'cpp', platform, arch, docker_suffix, testcase
+ ]
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ if self.platform == 'linux':
+ return create_docker_jobspec(
+ self.name, 'tools/dockerfile/distribtest/cpp_%s_%s' %
+ (self.docker_suffix, self.arch),
+ 'test/distrib/cpp/run_distrib_test_%s.sh' % self.testcase)
+ elif self.platform == 'windows':
+ return create_jobspec(
+ self.name,
+ ['test\\distrib\\cpp\\run_distrib_test_%s.bat' % self.testcase],
+ environ={},
+ timeout_seconds=30 * 60,
+ use_workspace=True)
+ else:
+ raise Exception("Not supported yet.")
- def __str__(self):
- return self.name
+ def __str__(self):
+ return self.name
def targets():
- """Gets list of supported targets"""
- return [CppDistribTest('linux', 'x64', 'jessie', 'routeguide'),
- CppDistribTest('linux', 'x64', 'jessie', 'cmake'),
- CSharpDistribTest('linux', 'x64', 'wheezy'),
- CSharpDistribTest('linux', 'x64', 'jessie'),
- CSharpDistribTest('linux', 'x86', 'jessie'),
- CSharpDistribTest('linux', 'x64', 'centos7'),
- CSharpDistribTest('linux', 'x64', 'ubuntu1404'),
- CSharpDistribTest('linux', 'x64', 'ubuntu1504'),
- CSharpDistribTest('linux', 'x64', 'ubuntu1510'),
- CSharpDistribTest('linux', 'x64', 'ubuntu1604'),
- CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True),
- CSharpDistribTest('macos', 'x86'),
- CSharpDistribTest('windows', 'x86'),
- CSharpDistribTest('windows', 'x64'),
- PythonDistribTest('linux', 'x64', 'wheezy'),
- PythonDistribTest('linux', 'x64', 'jessie'),
- PythonDistribTest('linux', 'x86', 'jessie'),
- PythonDistribTest('linux', 'x64', 'centos6'),
- PythonDistribTest('linux', 'x64', 'centos7'),
- PythonDistribTest('linux', 'x64', 'fedora20'),
- PythonDistribTest('linux', 'x64', 'fedora21'),
- PythonDistribTest('linux', 'x64', 'fedora22'),
- PythonDistribTest('linux', 'x64', 'fedora23'),
- PythonDistribTest('linux', 'x64', 'opensuse'),
- PythonDistribTest('linux', 'x64', 'arch'),
- PythonDistribTest('linux', 'x64', 'ubuntu1204'),
- PythonDistribTest('linux', 'x64', 'ubuntu1404'),
- PythonDistribTest('linux', 'x64', 'ubuntu1504'),
- PythonDistribTest('linux', 'x64', 'ubuntu1510'),
- PythonDistribTest('linux', 'x64', 'ubuntu1604'),
- RubyDistribTest('linux', 'x64', 'wheezy'),
- RubyDistribTest('linux', 'x64', 'jessie'),
- RubyDistribTest('linux', 'x86', 'jessie'),
- RubyDistribTest('linux', 'x64', 'centos6'),
- RubyDistribTest('linux', 'x64', 'centos7'),
- RubyDistribTest('linux', 'x64', 'fedora20'),
- RubyDistribTest('linux', 'x64', 'fedora21'),
- RubyDistribTest('linux', 'x64', 'fedora22'),
- RubyDistribTest('linux', 'x64', 'fedora23'),
- RubyDistribTest('linux', 'x64', 'opensuse'),
- RubyDistribTest('linux', 'x64', 'ubuntu1204'),
- RubyDistribTest('linux', 'x64', 'ubuntu1404'),
- RubyDistribTest('linux', 'x64', 'ubuntu1504'),
- RubyDistribTest('linux', 'x64', 'ubuntu1510'),
- RubyDistribTest('linux', 'x64', 'ubuntu1604'),
- NodeDistribTest('macos', 'x64', None, '4'),
- NodeDistribTest('macos', 'x64', None, '5'),
- NodeDistribTest('linux', 'x86', 'jessie', '4'),
- PHPDistribTest('linux', 'x64', 'jessie'),
- PHPDistribTest('macos', 'x64'),
- ] + [
- NodeDistribTest('linux', 'x64', os, version)
- for os in ('wheezy', 'jessie', 'ubuntu1204', 'ubuntu1404',
- 'ubuntu1504', 'ubuntu1510', 'ubuntu1604')
- for version in ('4', '5')
- ]
+ """Gets list of supported targets"""
+ return [
+ CppDistribTest('linux', 'x64', 'jessie', 'routeguide'),
+ CppDistribTest('linux', 'x64', 'jessie', 'cmake'),
+ CppDistribTest('windows', 'x86', testcase='cmake'),
+ CSharpDistribTest('linux', 'x64', 'wheezy'),
+ CSharpDistribTest('linux', 'x64', 'jessie'),
+ CSharpDistribTest('linux', 'x86', 'jessie'),
+ CSharpDistribTest('linux', 'x64', 'centos7'),
+ CSharpDistribTest('linux', 'x64', 'ubuntu1404'),
+ CSharpDistribTest('linux', 'x64', 'ubuntu1504'),
+ CSharpDistribTest('linux', 'x64', 'ubuntu1510'),
+ CSharpDistribTest('linux', 'x64', 'ubuntu1604'),
+ CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True),
+ CSharpDistribTest('macos', 'x86'),
+ CSharpDistribTest('windows', 'x86'),
+ CSharpDistribTest('windows', 'x64'),
+ PythonDistribTest('linux', 'x64', 'wheezy'),
+ PythonDistribTest('linux', 'x64', 'jessie'),
+ PythonDistribTest('linux', 'x86', 'jessie'),
+ PythonDistribTest('linux', 'x64', 'centos6'),
+ PythonDistribTest('linux', 'x64', 'centos7'),
+ PythonDistribTest('linux', 'x64', 'fedora20'),
+ PythonDistribTest('linux', 'x64', 'fedora21'),
+ PythonDistribTest('linux', 'x64', 'fedora22'),
+ PythonDistribTest('linux', 'x64', 'fedora23'),
+ PythonDistribTest('linux', 'x64', 'opensuse'),
+ PythonDistribTest('linux', 'x64', 'arch'),
+ PythonDistribTest('linux', 'x64', 'ubuntu1204'),
+ PythonDistribTest('linux', 'x64', 'ubuntu1404'),
+ PythonDistribTest('linux', 'x64', 'ubuntu1504'),
+ PythonDistribTest('linux', 'x64', 'ubuntu1510'),
+ PythonDistribTest('linux', 'x64', 'ubuntu1604'),
+ RubyDistribTest('linux', 'x64', 'wheezy'),
+ RubyDistribTest('linux', 'x64', 'jessie'),
+ RubyDistribTest('linux', 'x86', 'jessie'),
+ RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_0_0'),
+ RubyDistribTest('linux', 'x64', 'centos6'),
+ RubyDistribTest('linux', 'x64', 'centos7'),
+ RubyDistribTest('linux', 'x64', 'fedora20'),
+ RubyDistribTest('linux', 'x64', 'fedora21'),
+ RubyDistribTest('linux', 'x64', 'fedora22'),
+ RubyDistribTest('linux', 'x64', 'fedora23'),
+ RubyDistribTest('linux', 'x64', 'opensuse'),
+ RubyDistribTest('linux', 'x64', 'ubuntu1204'),
+ RubyDistribTest('linux', 'x64', 'ubuntu1404'),
+ RubyDistribTest('linux', 'x64', 'ubuntu1504'),
+ RubyDistribTest('linux', 'x64', 'ubuntu1510'),
+ RubyDistribTest('linux', 'x64', 'ubuntu1604'),
+ PHPDistribTest('linux', 'x64', 'jessie'),
+ PHPDistribTest('macos', 'x64'),
+ ]
diff --git a/tools/run_tests/artifacts/package_targets.py b/tools/run_tests/artifacts/package_targets.py
index 671d0f7b45..abf1b5ebed 100644
--- a/tools/run_tests/artifacts/package_targets.py
+++ b/tools/run_tests/artifacts/package_targets.py
@@ -12,7 +12,6 @@
# 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.
-
"""Definition of targets to build distribution packages."""
import os.path
@@ -22,147 +21,140 @@ sys.path.insert(0, os.path.abspath('..'))
import python_utils.jobset as jobset
-def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
- flake_retries=0, timeout_retries=0):
- """Creates jobspec for a task running under docker."""
- environ = environ.copy()
- environ['RUN_COMMAND'] = shell_command
-
- docker_args=[]
- for k,v in environ.items():
- docker_args += ['-e', '%s=%s' % (k, v)]
- docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
- 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
- 'OUTPUT_DIR': 'artifacts'}
- jobspec = jobset.JobSpec(
- cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args,
- environ=docker_env,
- shortname='build_package.%s' % (name),
- timeout_seconds=30*60,
- flake_retries=flake_retries,
- timeout_retries=timeout_retries)
- return jobspec
-
-def create_jobspec(name, cmdline, environ=None, cwd=None, shell=False,
- flake_retries=0, timeout_retries=0):
- """Creates jobspec."""
- jobspec = jobset.JobSpec(
- cmdline=cmdline,
- environ=environ,
- cwd=cwd,
- shortname='build_package.%s' % (name),
- timeout_seconds=10*60,
- flake_retries=flake_retries,
- timeout_retries=timeout_retries,
- shell=shell)
- return jobspec
+def create_docker_jobspec(name,
+ dockerfile_dir,
+ shell_command,
+ environ={},
+ flake_retries=0,
+ timeout_retries=0):
+ """Creates jobspec for a task running under docker."""
+ environ = environ.copy()
+ environ['RUN_COMMAND'] = shell_command
+
+ docker_args = []
+ for k, v in environ.items():
+ docker_args += ['-e', '%s=%s' % (k, v)]
+ docker_env = {
+ 'DOCKERFILE_DIR': dockerfile_dir,
+ 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
+ 'OUTPUT_DIR': 'artifacts'
+ }
+ jobspec = jobset.JobSpec(
+ cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] +
+ docker_args,
+ environ=docker_env,
+ shortname='build_package.%s' % (name),
+ timeout_seconds=30 * 60,
+ flake_retries=flake_retries,
+ timeout_retries=timeout_retries)
+ return jobspec
+
+
+def create_jobspec(name,
+ cmdline,
+ environ=None,
+ cwd=None,
+ shell=False,
+ flake_retries=0,
+ timeout_retries=0):
+ """Creates jobspec."""
+ jobspec = jobset.JobSpec(
+ cmdline=cmdline,
+ environ=environ,
+ cwd=cwd,
+ shortname='build_package.%s' % (name),
+ timeout_seconds=10 * 60,
+ flake_retries=flake_retries,
+ timeout_retries=timeout_retries,
+ shell=shell)
+ return jobspec
class CSharpPackage:
- """Builds C# nuget packages."""
-
- def __init__(self, linux=False):
- self.linux = linux
- self.labels = ['package', 'csharp']
- if linux:
- self.name = 'csharp_package_dotnetcli_linux'
- self.labels += ['linux']
- else:
- self.name = 'csharp_package_dotnetcli_windows'
- self.labels += ['windows']
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- if self.linux:
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/test/csharp_jessie_x64',
- 'src/csharp/build_packages_dotnetcli.sh')
- else:
- return create_jobspec(self.name,
- ['build_packages_dotnetcli.bat'],
- cwd='src\\csharp',
- shell=True)
-
- def __str__(self):
- return self.name
-
-
-class NodePackage:
- """Builds Node NPM package and collects precompiled binaries"""
-
- def __init__(self):
- self.name = 'node_package'
- self.labels = ['package', 'node', 'linux']
-
- def pre_build_jobspecs(self):
- return []
-
- def build_jobspec(self):
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/grpc_artifact_linux_x64',
- 'tools/run_tests/artifacts/build_package_node.sh')
+ """Builds C# nuget packages."""
+
+ def __init__(self, linux=False):
+ self.linux = linux
+ self.labels = ['package', 'csharp']
+ if linux:
+ self.name = 'csharp_package_dotnetcli_linux'
+ self.labels += ['linux']
+ else:
+ self.name = 'csharp_package_dotnetcli_windows'
+ self.labels += ['windows']
+
+ def pre_build_jobspecs(self):
+ return []
+
+ def build_jobspec(self):
+ if self.linux:
+ return create_docker_jobspec(
+ self.name, 'tools/dockerfile/test/csharp_jessie_x64',
+ 'src/csharp/build_packages_dotnetcli.sh')
+ else:
+ return create_jobspec(
+ self.name, ['build_packages_dotnetcli.bat'],
+ cwd='src\\csharp',
+ shell=True)
+
+ def __str__(self):
+ return self.name
class RubyPackage:
- """Collects ruby gems created in the artifact phase"""
+ """Collects ruby gems created in the artifact phase"""
- def __init__(self):
- self.name = 'ruby_package'
- self.labels = ['package', 'ruby', 'linux']
+ def __init__(self):
+ self.name = 'ruby_package'
+ self.labels = ['package', 'ruby', 'linux']
- def pre_build_jobspecs(self):
- return []
+ def pre_build_jobspecs(self):
+ return []
- def build_jobspec(self):
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/grpc_artifact_linux_x64',
- 'tools/run_tests/artifacts/build_package_ruby.sh')
+ def build_jobspec(self):
+ return create_docker_jobspec(
+ self.name, 'tools/dockerfile/grpc_artifact_linux_x64',
+ 'tools/run_tests/artifacts/build_package_ruby.sh')
class PythonPackage:
- """Collects python eggs and wheels created in the artifact phase"""
+ """Collects python eggs and wheels created in the artifact phase"""
- def __init__(self):
- self.name = 'python_package'
- self.labels = ['package', 'python', 'linux']
+ def __init__(self):
+ self.name = 'python_package'
+ self.labels = ['package', 'python', 'linux']
- def pre_build_jobspecs(self):
- return []
+ def pre_build_jobspecs(self):
+ return []
- def build_jobspec(self):
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/grpc_artifact_linux_x64',
- 'tools/run_tests/artifacts/build_package_python.sh')
+ def build_jobspec(self):
+ return create_docker_jobspec(
+ self.name, 'tools/dockerfile/grpc_artifact_linux_x64',
+ 'tools/run_tests/artifacts/build_package_python.sh')
class PHPPackage:
- """Copy PHP PECL package artifact"""
+ """Copy PHP PECL package artifact"""
- def __init__(self):
- self.name = 'php_package'
- self.labels = ['package', 'php', 'linux']
+ def __init__(self):
+ self.name = 'php_package'
+ self.labels = ['package', 'php', 'linux']
- def pre_build_jobspecs(self):
- return []
+ def pre_build_jobspecs(self):
+ return []
- def build_jobspec(self):
- return create_docker_jobspec(
- self.name,
- 'tools/dockerfile/grpc_artifact_linux_x64',
- 'tools/run_tests/artifacts/build_package_php.sh')
+ def build_jobspec(self):
+ return create_docker_jobspec(
+ self.name, 'tools/dockerfile/grpc_artifact_linux_x64',
+ 'tools/run_tests/artifacts/build_package_php.sh')
def targets():
- """Gets list of supported targets"""
- return [CSharpPackage(),
- CSharpPackage(linux=True),
- NodePackage(),
- RubyPackage(),
- PythonPackage(),
- PHPPackage()]
+ """Gets list of supported targets"""
+ return [
+ CSharpPackage(),
+ CSharpPackage(linux=True),
+ RubyPackage(),
+ PythonPackage(),
+ PHPPackage()
+ ]
diff --git a/tools/run_tests/artifacts/run_in_workspace.sh b/tools/run_tests/artifacts/run_in_workspace.sh
index 5b8af6ab53..20181e077c 100755
--- a/tools/run_tests/artifacts/run_in_workspace.sh
+++ b/tools/run_tests/artifacts/run_in_workspace.sh
@@ -18,15 +18,19 @@
# All cmdline args will be executed as a command.
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
export repo_root=$(pwd)
+# TODO: fix file to pass shellcheck
+
rm -rf "${WORKSPACE_NAME}"
git clone . "${WORKSPACE_NAME}"
# clone gRPC submodules, use data from locally cloned submodules where possible
+# shellcheck disable=SC1004,SC2016
git submodule foreach 'cd "${repo_root}/${WORKSPACE_NAME}" \
&& git submodule update --init --reference ${repo_root}/${name} ${name}'
echo "Running in workspace ${WORKSPACE_NAME}"
-cd ${WORKSPACE_NAME}
+cd "${WORKSPACE_NAME}"
+# shellcheck disable=SC2068
$@
diff --git a/tools/run_tests/dockerize/build_and_run_docker.sh b/tools/run_tests/dockerize/build_and_run_docker.sh
index 80aec82c3d..b8f0a55025 100755
--- a/tools/run_tests/dockerize/build_and_run_docker.sh
+++ b/tools/run_tests/dockerize/build_and_run_docker.sh
@@ -18,7 +18,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
git_root=$(pwd)
cd -
@@ -31,36 +31,38 @@ cd -
# $@ - Extra args to pass to docker run
# Use image name based on Dockerfile location checksum
-DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
+DOCKER_IMAGE_NAME=$(basename "$DOCKERFILE_DIR")_$(sha1sum "$DOCKERFILE_DIR/Dockerfile" | cut -f1 -d\ )
# Pull the base image to force an update
if [ "$DOCKER_BASE_IMAGE" != "" ]
then
- docker pull $DOCKER_BASE_IMAGE
+ time docker pull "$DOCKER_BASE_IMAGE"
fi
if [ "$DOCKERHUB_ORGANIZATION" != "" ]
then
DOCKER_IMAGE_NAME=$DOCKERHUB_ORGANIZATION/$DOCKER_IMAGE_NAME
- docker pull $DOCKER_IMAGE_NAME
+ time docker pull "$DOCKER_IMAGE_NAME"
else
# Make sure docker image has been built. Should be instantaneous if so.
- docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
+ docker build -t "$DOCKER_IMAGE_NAME" "$DOCKERFILE_DIR"
fi
# Choose random name for docker container
CONTAINER_NAME="build_and_run_docker_$(uuidgen)"
# Run command inside docker
+# TODO: use a proper array instead of $EXTRA_DOCKER_ARGS
+# shellcheck disable=SC2086
docker run \
"$@" \
-e EXTERNAL_GIT_ROOT="/var/local/jenkins/grpc" \
-e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \
-v "$git_root:/var/local/jenkins/grpc:ro" \
-w /var/local/git/grpc \
- --name=$CONTAINER_NAME \
+ --name="$CONTAINER_NAME" \
$EXTRA_DOCKER_ARGS \
- $DOCKER_IMAGE_NAME \
+ "$DOCKER_IMAGE_NAME" \
/bin/bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || FAILED="true"
# Copy output artifacts
@@ -70,7 +72,7 @@ then
fi
# remove the container, possibly killing it first
-docker rm -f $CONTAINER_NAME || true
+docker rm -f "$CONTAINER_NAME" || true
if [ "$FAILED" != "" ]
then
diff --git a/tools/run_tests/dockerize/build_docker_and_run_tests.sh b/tools/run_tests/dockerize/build_docker_and_run_tests.sh
index eea00da821..8dca05ea35 100755
--- a/tools/run_tests/dockerize/build_docker_and_run_tests.sh
+++ b/tools/run_tests/dockerize/build_docker_and_run_tests.sh
@@ -18,7 +18,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
git_root=$(pwd)
cd -
@@ -35,15 +35,15 @@ mkdir -p /tmp/xdg-cache-home
# DOCKERHUB_ORGANIZATION - If set, pull a prebuilt image from given dockerhub org.
# Use image name based on Dockerfile location checksum
-DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
+DOCKER_IMAGE_NAME=$(basename "$DOCKERFILE_DIR")_$(sha1sum "$DOCKERFILE_DIR/Dockerfile" | cut -f1 -d\ )
if [ "$DOCKERHUB_ORGANIZATION" != "" ]
then
DOCKER_IMAGE_NAME=$DOCKERHUB_ORGANIZATION/$DOCKER_IMAGE_NAME
- docker pull $DOCKER_IMAGE_NAME
+ time docker pull "$DOCKER_IMAGE_NAME"
else
# Make sure docker image has been built. Should be instantaneous if so.
- docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
+ docker build -t "$DOCKER_IMAGE_NAME" "$DOCKERFILE_DIR"
fi
# Choose random name for docker container
@@ -54,6 +54,8 @@ docker_instance_git_root=/var/local/jenkins/grpc
# Run tests inside docker
DOCKER_EXIT_CODE=0
+# TODO: silence complaint about $TTY_FLAG expansion in some other way
+# shellcheck disable=SC2086
docker run \
-e "RUN_TESTS_COMMAND=$RUN_TESTS_COMMAND" \
-e "config=$config" \
@@ -61,15 +63,17 @@ docker run \
-e CCACHE_DIR=/tmp/ccache \
-e XDG_CACHE_HOME=/tmp/xdg-cache-home \
-e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \
- -e HOST_GIT_ROOT=$git_root \
+ -e HOST_GIT_ROOT="$git_root" \
-e LOCAL_GIT_ROOT=$docker_instance_git_root \
-e "BUILD_ID=$BUILD_ID" \
-e "BUILD_URL=$BUILD_URL" \
-e "JOB_BASE_NAME=$JOB_BASE_NAME" \
+ -e "KOKORO_BUILD_ID=$KOKORO_BUILD_ID" \
-e "KOKORO_BUILD_NUMBER=$KOKORO_BUILD_NUMBER" \
-e "KOKORO_BUILD_URL=$KOKORO_BUILD_URL" \
-e "KOKORO_JOB_NAME=$KOKORO_JOB_NAME" \
- -i $TTY_FLAG \
+ -i \
+ $TTY_FLAG \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
-v ~/.config/gcloud:/root/.config/gcloud \
-v "$git_root:$docker_instance_git_root" \
@@ -77,18 +81,18 @@ docker run \
-v /tmp/npm-cache:/tmp/npm-cache \
-v /tmp/xdg-cache-home:/tmp/xdg-cache-home \
-w /var/local/git/grpc \
- --name=$CONTAINER_NAME \
- $DOCKER_IMAGE_NAME \
+ --name="$CONTAINER_NAME" \
+ "$DOCKER_IMAGE_NAME" \
bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || DOCKER_EXIT_CODE=$?
# use unique name for reports.zip to prevent clash between concurrent
# run_tests.py runs
-TEMP_REPORTS_ZIP=`mktemp`
-docker cp "$CONTAINER_NAME:/var/local/git/grpc/reports.zip" ${TEMP_REPORTS_ZIP} || true
-unzip -o ${TEMP_REPORTS_ZIP} -d $git_root || true
-rm -f ${TEMP_REPORTS_ZIP}
+TEMP_REPORTS_ZIP=$(mktemp)
+docker cp "$CONTAINER_NAME:/var/local/git/grpc/reports.zip" "${TEMP_REPORTS_ZIP}" || true
+unzip -o "${TEMP_REPORTS_ZIP}" -d "$git_root" || true
+rm -f "${TEMP_REPORTS_ZIP}"
# remove the container, possibly killing it first
-docker rm -f $CONTAINER_NAME || true
+docker rm -f "$CONTAINER_NAME" || true
exit $DOCKER_EXIT_CODE
diff --git a/tools/run_tests/dockerize/build_interop_image.sh b/tools/run_tests/dockerize/build_interop_image.sh
index 9d8ad5325c..90605d9463 100755
--- a/tools/run_tests/dockerize/build_interop_image.sh
+++ b/tools/run_tests/dockerize/build_interop_image.sh
@@ -28,7 +28,7 @@ set -x
# GRPC_GO_ROOT - grpc-go base directory, default to '$GRPC_ROOT/../grpc-go'
# GRPC_JAVA_ROOT - grpc-java base directory, default to '$GRPC_ROOT/../grpc-java'
-cd `dirname $0`/../../..
+cd "$(dirname "$0")/../../.."
echo "GRPC_ROOT: ${GRPC_ROOT:=$(pwd)}"
MOUNT_ARGS="-v $GRPC_ROOT:/var/local/jenkins/grpc:ro"
@@ -48,12 +48,20 @@ else
echo "WARNING: grpc-go not found, it won't be mounted to the docker container."
fi
+echo "GRPC_NODE_ROOT: ${GRPC_NODE_ROOT:=$(cd ../grpc-node && pwd)}"
+if [ -n "$GRPC_NODE_ROOT" ]
+then
+ MOUNT_ARGS+=" -v $GRPC_NODE_ROOT:/var/local/jenkins/grpc-node:ro"
+else
+ echo "WARNING: grpc-node not found, it won't be mounted to the docker container."
+fi
+
mkdir -p /tmp/ccache
# Mount service account dir if available.
# If service_directory does not contain the service account JSON file,
# some of the tests will fail.
-if [ -e $HOME/service_account ]
+if [ -e "$HOME/service_account" ]
then
MOUNT_ARGS+=" -v $HOME/service_account:/var/local/jenkins/service_account:ro"
fi
@@ -62,18 +70,18 @@ fi
# on OSX use md5 instead of sha1sum
if which sha1sum > /dev/null;
then
- BASE_IMAGE=${BASE_NAME}_`sha1sum tools/dockerfile/interoptest/$BASE_NAME/Dockerfile | cut -f1 -d\ `
+ BASE_IMAGE=${BASE_NAME}_$(sha1sum "tools/dockerfile/interoptest/$BASE_NAME/Dockerfile" | cut -f1 -d\ )
else
- BASE_IMAGE=${BASE_NAME}_`md5 -r tools/dockerfile/interoptest/$BASE_NAME/Dockerfile | cut -f1 -d\ `
+ BASE_IMAGE=${BASE_NAME}_$(md5 -r "tools/dockerfile/interoptest/$BASE_NAME/Dockerfile" | cut -f1 -d\ )
fi
if [ "$DOCKERHUB_ORGANIZATION" != "" ]
then
BASE_IMAGE=$DOCKERHUB_ORGANIZATION/$BASE_IMAGE
- docker pull $BASE_IMAGE
+ time docker pull "$BASE_IMAGE"
else
# Make sure docker image has been built. Should be instantaneous if so.
- docker build -t $BASE_IMAGE --force-rm=true tools/dockerfile/interoptest/$BASE_NAME || exit $?
+ docker build -t "$BASE_IMAGE" --force-rm=true "tools/dockerfile/interoptest/$BASE_NAME" || exit $?
fi
# Create a local branch so the child Docker script won't complain
@@ -82,22 +90,28 @@ git branch -f jenkins-docker
CONTAINER_NAME="build_${BASE_NAME}_$(uuidgen)"
# Prepare image for interop tests, commit it on success.
+# TODO: Figure out if is safe to eliminate the suppression. It's currently here
+# because $MOUNT_ARGS and $BUILD_INTEROP_DOCKER_EXTRA_ARGS can have legitimate
+# spaces, but the "correct" way to do this is to utilize proper arrays.
+# Same for $TTY_FLAG
+# shellcheck disable=SC2086
(docker run \
-e CCACHE_DIR=/tmp/ccache \
-e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \
-e THIS_IS_REALLY_NEEDED_ONCE_AGAIN='For issue 4835. See https://github.com/docker/docker/issues/14203 for why docker is awful' \
- -i $TTY_FLAG \
+ -i \
+ $TTY_FLAG \
$MOUNT_ARGS \
$BUILD_INTEROP_DOCKER_EXTRA_ARGS \
-v /tmp/ccache:/tmp/ccache \
- --name=$CONTAINER_NAME \
- $BASE_IMAGE \
- bash -l /var/local/jenkins/grpc/tools/dockerfile/interoptest/$BASE_NAME/build_interop.sh \
- && docker commit $CONTAINER_NAME $INTEROP_IMAGE \
+ --name="$CONTAINER_NAME" \
+ "$BASE_IMAGE" \
+ bash -l "/var/local/jenkins/grpc/tools/dockerfile/interoptest/$BASE_NAME/build_interop.sh" \
+ && docker commit "$CONTAINER_NAME" "$INTEROP_IMAGE" \
&& echo "Successfully built image $INTEROP_IMAGE")
EXITCODE=$?
# remove intermediate container, possibly killing it first
-docker rm -f $CONTAINER_NAME
+docker rm -f "$CONTAINER_NAME"
exit $EXITCODE
diff --git a/tools/run_tests/dockerize/docker_run.sh b/tools/run_tests/dockerize/docker_run.sh
index 992e4f25b7..ac0d09c28b 100755
--- a/tools/run_tests/dockerize/docker_run.sh
+++ b/tools/run_tests/dockerize/docker_run.sh
@@ -21,9 +21,11 @@ set -ex
if [ "$RELATIVE_COPY_PATH" == "" ]
then
mkdir -p /var/local/git
- git clone $EXTERNAL_GIT_ROOT /var/local/git/grpc
+ git clone "$EXTERNAL_GIT_ROOT" /var/local/git/grpc
# clone gRPC submodules, use data from locally cloned submodules where possible
- (cd ${EXTERNAL_GIT_ROOT} && git submodule foreach 'cd /var/local/git/grpc \
+ # TODO: figure out a way to eliminate this following shellcheck suppressions
+ # shellcheck disable=SC2016,SC1004
+ (cd "${EXTERNAL_GIT_ROOT}" && git submodule foreach 'cd /var/local/git/grpc \
&& git submodule update --init --reference ${EXTERNAL_GIT_ROOT}/${name} \
${name}')
else
diff --git a/tools/run_tests/dockerize/docker_run_tests.sh b/tools/run_tests/dockerize/docker_run_tests.sh
index 15d703962c..df9d3d1ca2 100755
--- a/tools/run_tests/dockerize/docker_run_tests.sh
+++ b/tools/run_tests/dockerize/docker_run_tests.sh
@@ -24,11 +24,13 @@ export PATH=$PATH:/usr/bin/llvm-symbolizer
# Ensure that programs depending on current-user-ownership of cache directories
# are satisfied (it's being mounted from outside the image).
-chown $(whoami) $XDG_CACHE_HOME
+chown "$(whoami)" "$XDG_CACHE_HOME"
mkdir -p /var/local/git
git clone /var/local/jenkins/grpc /var/local/git/grpc
# clone gRPC submodules, use data from locally cloned submodules where possible
+# TODO: figure out a way to eliminate this shellcheck suppression:
+# shellcheck disable=SC2016,SC1004
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
${name}')
@@ -52,8 +54,8 @@ echo '</body></html>' >> index.html
cd ..
zip -r reports.zip reports
-find . -name report.xml | xargs -r zip reports.zip
-find . -name sponge_log.xml | xargs -r zip reports.zip
-find . -name 'report_*.xml' | xargs -r zip reports.zip
+find . -name report.xml -print0 | xargs -0 -r zip reports.zip
+find . -name sponge_log.xml -print0 | xargs -0 -r zip reports.zip
+find . -name 'report_*.xml' -print0 | xargs -0 -r zip reports.zip
exit $exit_code
diff --git a/tools/run_tests/generated/configs.json b/tools/run_tests/generated/configs.json
index abbe76d60c..a14340cb7b 100644
--- a/tools/run_tests/generated/configs.json
+++ b/tools/run_tests/generated/configs.json
@@ -20,7 +20,10 @@
}
},
{
- "config": "msan"
+ "config": "msan",
+ "environ": {
+ "MSAN_OPTIONS": "poison_in_dtor=1"
+ }
},
{
"config": "basicprof"
@@ -39,7 +42,7 @@
}
},
{
- "config": "c++-compat"
+ "config": "noexcept"
},
{
"config": "ubsan",
@@ -71,6 +74,9 @@
"config": "lto"
},
{
+ "config": "c++-compat"
+ },
+ {
"config": "mutrace"
},
{
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index c46eb726c8..11c37233d5 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -13,7 +13,7 @@
"language": "c",
"name": "alarm_test",
"src": [
- "test/core/surface/alarm_test.c"
+ "test/core/surface/alarm_test.cc"
],
"third_party": false,
"type": "target"
@@ -30,7 +30,7 @@
"language": "c",
"name": "algorithm_test",
"src": [
- "test/core/compression/algorithm_test.c"
+ "test/core/compression/algorithm_test.cc"
],
"third_party": false,
"type": "target"
@@ -45,7 +45,7 @@
"language": "c",
"name": "alloc_test",
"src": [
- "test/core/support/alloc_test.c"
+ "test/core/gpr/alloc_test.cc"
],
"third_party": false,
"type": "target"
@@ -62,7 +62,7 @@
"language": "c",
"name": "alpn_test",
"src": [
- "test/core/transport/chttp2/alpn_test.c"
+ "test/core/transport/chttp2/alpn_test.cc"
],
"third_party": false,
"type": "target"
@@ -79,7 +79,7 @@
"language": "c",
"name": "api_fuzzer",
"src": [
- "test/core/end2end/fuzzers/api_fuzzer.c"
+ "test/core/end2end/fuzzers/api_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -94,7 +94,7 @@
"language": "c",
"name": "arena_test",
"src": [
- "test/core/support/arena_test.c"
+ "test/core/gpr/arena_test.cc"
],
"third_party": false,
"type": "target"
@@ -112,24 +112,7 @@
"language": "c",
"name": "bad_server_response_test",
"src": [
- "test/core/end2end/bad_server_response_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "bdp_estimator_test",
- "src": [
- "test/core/transport/bdp_estimator_test.c"
+ "test/core/end2end/bad_server_response_test.cc"
],
"third_party": false,
"type": "target"
@@ -144,7 +127,7 @@
"language": "c",
"name": "bin_decoder_test",
"src": [
- "test/core/transport/chttp2/bin_decoder_test.c"
+ "test/core/transport/chttp2/bin_decoder_test.cc"
],
"third_party": false,
"type": "target"
@@ -159,7 +142,7 @@
"language": "c",
"name": "bin_encoder_test",
"src": [
- "test/core/transport/chttp2/bin_encoder_test.c"
+ "test/core/transport/chttp2/bin_encoder_test.cc"
],
"third_party": false,
"type": "target"
@@ -176,75 +159,7 @@
"language": "c",
"name": "byte_stream_test",
"src": [
- "test/core/transport/byte_stream_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "census_context_test",
- "src": [
- "test/core/census/context_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "census_intrusive_hash_map_test",
- "src": [
- "test/core/census/intrusive_hash_map_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "census_resource_test",
- "src": [
- "test/core/census/resource_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "census_trace_context_test",
- "src": [
- "test/core/census/trace_context_test.c"
+ "test/core/transport/byte_stream_test.cc"
],
"third_party": false,
"type": "target"
@@ -261,7 +176,7 @@
"language": "c",
"name": "channel_create_test",
"src": [
- "test/core/surface/channel_create_test.c"
+ "test/core/surface/channel_create_test.cc"
],
"third_party": false,
"type": "target"
@@ -293,7 +208,7 @@
"language": "c",
"name": "chttp2_hpack_encoder_test",
"src": [
- "test/core/transport/chttp2/hpack_encoder_test.c"
+ "test/core/transport/chttp2/hpack_encoder_test.cc"
],
"third_party": false,
"type": "target"
@@ -310,7 +225,7 @@
"language": "c",
"name": "chttp2_stream_map_test",
"src": [
- "test/core/transport/chttp2/stream_map_test.c"
+ "test/core/transport/chttp2/stream_map_test.cc"
],
"third_party": false,
"type": "target"
@@ -327,7 +242,7 @@
"language": "c",
"name": "chttp2_varint_test",
"src": [
- "test/core/transport/chttp2/varint_test.c"
+ "test/core/transport/chttp2/varint_test.cc"
],
"third_party": false,
"type": "target"
@@ -344,7 +259,7 @@
"language": "c",
"name": "client_fuzzer",
"src": [
- "test/core/end2end/fuzzers/client_fuzzer.c"
+ "test/core/end2end/fuzzers/client_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -361,7 +276,7 @@
"language": "c",
"name": "combiner_test",
"src": [
- "test/core/iomgr/combiner_test.c"
+ "test/core/iomgr/combiner_test.cc"
],
"third_party": false,
"type": "target"
@@ -378,7 +293,7 @@
"language": "c",
"name": "compression_test",
"src": [
- "test/core/compression/compression_test.c"
+ "test/core/compression/compression_test.cc"
],
"third_party": false,
"type": "target"
@@ -395,7 +310,7 @@
"language": "c",
"name": "concurrent_connectivity_test",
"src": [
- "test/core/surface/concurrent_connectivity_test.c"
+ "test/core/surface/concurrent_connectivity_test.cc"
],
"third_party": false,
"type": "target"
@@ -412,7 +327,7 @@
"language": "c",
"name": "connection_refused_test",
"src": [
- "test/core/end2end/connection_refused_test.c"
+ "test/core/end2end/connection_refused_test.cc"
],
"third_party": false,
"type": "target"
@@ -429,7 +344,7 @@
"language": "c",
"name": "dns_resolver_connectivity_test",
"src": [
- "test/core/client_channel/resolvers/dns_resolver_connectivity_test.c"
+ "test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc"
],
"third_party": false,
"type": "target"
@@ -446,7 +361,7 @@
"language": "c",
"name": "dns_resolver_test",
"src": [
- "test/core/client_channel/resolvers/dns_resolver_test.c"
+ "test/core/client_channel/resolvers/dns_resolver_test.cc"
],
"third_party": false,
"type": "target"
@@ -463,7 +378,7 @@
"language": "c",
"name": "dualstack_socket_test",
"src": [
- "test/core/end2end/dualstack_socket_test.c"
+ "test/core/end2end/dualstack_socket_test.cc"
],
"third_party": false,
"type": "target"
@@ -480,7 +395,7 @@
"language": "c",
"name": "endpoint_pair_test",
"src": [
- "test/core/iomgr/endpoint_pair_test.c"
+ "test/core/iomgr/endpoint_pair_test.cc"
],
"third_party": false,
"type": "target"
@@ -497,7 +412,7 @@
"language": "c",
"name": "error_test",
"src": [
- "test/core/iomgr/error_test.c"
+ "test/core/iomgr/error_test.cc"
],
"third_party": false,
"type": "target"
@@ -514,7 +429,7 @@
"language": "c",
"name": "ev_epollsig_linux_test",
"src": [
- "test/core/iomgr/ev_epollsig_linux_test.c"
+ "test/core/iomgr/ev_epollsig_linux_test.cc"
],
"third_party": false,
"type": "target"
@@ -531,7 +446,7 @@
"language": "c",
"name": "fake_resolver_test",
"src": [
- "test/core/client_channel/resolvers/fake_resolver_test.c"
+ "test/core/client_channel/resolvers/fake_resolver_test.cc"
],
"third_party": false,
"type": "target"
@@ -548,7 +463,7 @@
"language": "c",
"name": "fake_transport_security_test",
"src": [
- "test/core/tsi/fake_transport_security_test.c"
+ "test/core/tsi/fake_transport_security_test.cc"
],
"third_party": false,
"type": "target"
@@ -565,7 +480,7 @@
"language": "c",
"name": "fd_conservation_posix_test",
"src": [
- "test/core/iomgr/fd_conservation_posix_test.c"
+ "test/core/iomgr/fd_conservation_posix_test.cc"
],
"third_party": false,
"type": "target"
@@ -582,7 +497,7 @@
"language": "c",
"name": "fd_posix_test",
"src": [
- "test/core/iomgr/fd_posix_test.c"
+ "test/core/iomgr/fd_posix_test.cc"
],
"third_party": false,
"type": "target"
@@ -599,7 +514,7 @@
"language": "c",
"name": "fling_client",
"src": [
- "test/core/fling/client.c"
+ "test/core/fling/client.cc"
],
"third_party": false,
"type": "target"
@@ -616,7 +531,7 @@
"language": "c",
"name": "fling_server",
"src": [
- "test/core/fling/server.c"
+ "test/core/fling/server.cc"
],
"third_party": false,
"type": "target"
@@ -633,7 +548,7 @@
"language": "c",
"name": "fling_stream_test",
"src": [
- "test/core/fling/fling_stream_test.c"
+ "test/core/fling/fling_stream_test.cc"
],
"third_party": false,
"type": "target"
@@ -650,46 +565,7 @@
"language": "c",
"name": "fling_test",
"src": [
- "test/core/fling/fling_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "grpc"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "gen_hpack_tables",
- "src": [
- "tools/codegen/core/gen_hpack_tables.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "gen_legal_metadata_characters",
- "src": [
- "tools/codegen/core/gen_legal_metadata_characters.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "gen_percent_encoding_tables",
- "src": [
- "tools/codegen/core/gen_percent_encoding_tables.c"
+ "test/core/fling/fling_test.cc"
],
"third_party": false,
"type": "target"
@@ -706,7 +582,7 @@
"language": "c",
"name": "goaway_server_test",
"src": [
- "test/core/end2end/goaway_server_test.c"
+ "test/core/end2end/goaway_server_test.cc"
],
"third_party": false,
"type": "target"
@@ -721,22 +597,7 @@
"language": "c",
"name": "gpr_avl_test",
"src": [
- "test/core/support/avl_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "gpr_backoff_test",
- "src": [
- "test/core/support/backoff_test.c"
+ "test/core/gpr/avl_test.cc"
],
"third_party": false,
"type": "target"
@@ -751,7 +612,7 @@
"language": "c",
"name": "gpr_cmdline_test",
"src": [
- "test/core/support/cmdline_test.c"
+ "test/core/gpr/cmdline_test.cc"
],
"third_party": false,
"type": "target"
@@ -766,7 +627,7 @@
"language": "c",
"name": "gpr_cpu_test",
"src": [
- "test/core/support/cpu_test.c"
+ "test/core/gpr/cpu_test.cc"
],
"third_party": false,
"type": "target"
@@ -781,22 +642,7 @@
"language": "c",
"name": "gpr_env_test",
"src": [
- "test/core/support/env_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "gpr_histogram_test",
- "src": [
- "test/core/support/histogram_test.c"
+ "test/core/gpr/env_test.cc"
],
"third_party": false,
"type": "target"
@@ -811,7 +657,7 @@
"language": "c",
"name": "gpr_host_port_test",
"src": [
- "test/core/support/host_port_test.c"
+ "test/core/gpr/host_port_test.cc"
],
"third_party": false,
"type": "target"
@@ -826,7 +672,7 @@
"language": "c",
"name": "gpr_log_test",
"src": [
- "test/core/support/log_test.c"
+ "test/core/gpr/log_test.cc"
],
"third_party": false,
"type": "target"
@@ -839,9 +685,9 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_mpscq_test",
+ "name": "gpr_manual_constructor_test",
"src": [
- "test/core/support/mpscq_test.c"
+ "test/core/gprpp/manual_constructor_test.cc"
],
"third_party": false,
"type": "target"
@@ -854,9 +700,9 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_spinlock_test",
+ "name": "gpr_mpscq_test",
"src": [
- "test/core/support/spinlock_test.c"
+ "test/core/gpr/mpscq_test.cc"
],
"third_party": false,
"type": "target"
@@ -869,9 +715,9 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_stack_lockfree_test",
+ "name": "gpr_spinlock_test",
"src": [
- "test/core/support/stack_lockfree_test.c"
+ "test/core/gpr/spinlock_test.cc"
],
"third_party": false,
"type": "target"
@@ -886,7 +732,7 @@
"language": "c",
"name": "gpr_string_test",
"src": [
- "test/core/support/string_test.c"
+ "test/core/gpr/string_test.cc"
],
"third_party": false,
"type": "target"
@@ -901,7 +747,7 @@
"language": "c",
"name": "gpr_sync_test",
"src": [
- "test/core/support/sync_test.c"
+ "test/core/gpr/sync_test.cc"
],
"third_party": false,
"type": "target"
@@ -916,7 +762,7 @@
"language": "c",
"name": "gpr_thd_test",
"src": [
- "test/core/support/thd_test.c"
+ "test/core/gpr/thd_test.cc"
],
"third_party": false,
"type": "target"
@@ -931,7 +777,7 @@
"language": "c",
"name": "gpr_time_test",
"src": [
- "test/core/support/time_test.c"
+ "test/core/gpr/time_test.cc"
],
"third_party": false,
"type": "target"
@@ -946,7 +792,7 @@
"language": "c",
"name": "gpr_tls_test",
"src": [
- "test/core/support/tls_test.c"
+ "test/core/gpr/tls_test.cc"
],
"third_party": false,
"type": "target"
@@ -961,7 +807,7 @@
"language": "c",
"name": "gpr_useful_test",
"src": [
- "test/core/support/useful_test.c"
+ "test/core/gpr/useful_test.cc"
],
"third_party": false,
"type": "target"
@@ -978,7 +824,7 @@
"language": "c",
"name": "grpc_auth_context_test",
"src": [
- "test/core/security/auth_context_test.c"
+ "test/core/security/auth_context_test.cc"
],
"third_party": false,
"type": "target"
@@ -995,7 +841,7 @@
"language": "c",
"name": "grpc_b64_test",
"src": [
- "test/core/slice/b64_test.c"
+ "test/core/slice/b64_test.cc"
],
"third_party": false,
"type": "target"
@@ -1012,7 +858,7 @@
"language": "c",
"name": "grpc_byte_buffer_reader_test",
"src": [
- "test/core/surface/byte_buffer_reader_test.c"
+ "test/core/surface/byte_buffer_reader_test.cc"
],
"third_party": false,
"type": "target"
@@ -1029,7 +875,7 @@
"language": "c",
"name": "grpc_channel_args_test",
"src": [
- "test/core/channel/channel_args_test.c"
+ "test/core/channel/channel_args_test.cc"
],
"third_party": false,
"type": "target"
@@ -1046,7 +892,7 @@
"language": "c",
"name": "grpc_channel_stack_builder_test",
"src": [
- "test/core/channel/channel_stack_builder_test.c"
+ "test/core/channel/channel_stack_builder_test.cc"
],
"third_party": false,
"type": "target"
@@ -1063,7 +909,7 @@
"language": "c",
"name": "grpc_channel_stack_test",
"src": [
- "test/core/channel/channel_stack_test.c"
+ "test/core/channel/channel_stack_test.cc"
],
"third_party": false,
"type": "target"
@@ -1080,7 +926,7 @@
"language": "c",
"name": "grpc_completion_queue_test",
"src": [
- "test/core/surface/completion_queue_test.c"
+ "test/core/surface/completion_queue_test.cc"
],
"third_party": false,
"type": "target"
@@ -1097,7 +943,7 @@
"language": "c",
"name": "grpc_completion_queue_threading_test",
"src": [
- "test/core/surface/completion_queue_threading_test.c"
+ "test/core/surface/completion_queue_threading_test.cc"
],
"third_party": false,
"type": "target"
@@ -1112,7 +958,7 @@
"language": "c",
"name": "grpc_create_jwt",
"src": [
- "test/core/security/create_jwt.c"
+ "test/core/security/create_jwt.cc"
],
"third_party": false,
"type": "target"
@@ -1129,7 +975,7 @@
"language": "c",
"name": "grpc_credentials_test",
"src": [
- "test/core/security/credentials_test.c"
+ "test/core/security/credentials_test.cc"
],
"third_party": false,
"type": "target"
@@ -1146,7 +992,7 @@
"language": "c",
"name": "grpc_fetch_oauth2",
"src": [
- "test/core/security/fetch_oauth2.c"
+ "test/core/security/fetch_oauth2.cc"
],
"third_party": false,
"type": "target"
@@ -1163,7 +1009,7 @@
"language": "c",
"name": "grpc_invalid_channel_args_test",
"src": [
- "test/core/surface/invalid_channel_args_test.c"
+ "test/core/surface/invalid_channel_args_test.cc"
],
"third_party": false,
"type": "target"
@@ -1180,7 +1026,7 @@
"language": "c",
"name": "grpc_json_token_test",
"src": [
- "test/core/security/json_token_test.c"
+ "test/core/security/json_token_test.cc"
],
"third_party": false,
"type": "target"
@@ -1197,7 +1043,7 @@
"language": "c",
"name": "grpc_jwt_verifier_test",
"src": [
- "test/core/security/jwt_verifier_test.c"
+ "test/core/security/jwt_verifier_test.cc"
],
"third_party": false,
"type": "target"
@@ -1212,7 +1058,7 @@
"language": "c",
"name": "grpc_print_google_default_creds_token",
"src": [
- "test/core/security/print_google_default_creds_token.c"
+ "test/core/security/print_google_default_creds_token.cc"
],
"third_party": false,
"type": "target"
@@ -1229,7 +1075,24 @@
"language": "c",
"name": "grpc_security_connector_test",
"src": [
- "test/core/security/security_connector_test.c"
+ "test/core/security/security_connector_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c",
+ "name": "grpc_ssl_credentials_test",
+ "src": [
+ "test/core/security/ssl_credentials_test.cc"
],
"third_party": false,
"type": "target"
@@ -1244,7 +1107,7 @@
"language": "c",
"name": "grpc_verify_jwt",
"src": [
- "test/core/security/verify_jwt.c"
+ "test/core/security/verify_jwt.cc"
],
"third_party": false,
"type": "target"
@@ -1261,7 +1124,7 @@
"language": "c",
"name": "handshake_client",
"src": [
- "test/core/handshake/client_ssl.c"
+ "test/core/handshake/client_ssl.cc"
],
"third_party": false,
"type": "target"
@@ -1273,12 +1136,52 @@
"grpc",
"grpc_test_util"
],
- "headers": [],
+ "headers": [
+ "test/core/handshake/server_ssl_common.h"
+ ],
"is_filegroup": false,
"language": "c",
"name": "handshake_server",
"src": [
- "test/core/handshake/server_ssl.c"
+ "test/core/handshake/server_ssl.cc",
+ "test/core/handshake/server_ssl_common.cc",
+ "test/core/handshake/server_ssl_common.h"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [
+ "test/core/handshake/server_ssl_common.h"
+ ],
+ "is_filegroup": false,
+ "language": "c",
+ "name": "handshake_server_with_readahead_handshaker",
+ "src": [
+ "test/core/handshake/readahead_handshaker_server_ssl.cc",
+ "test/core/handshake/server_ssl_common.cc",
+ "test/core/handshake/server_ssl_common.h"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c",
+ "name": "histogram_test",
+ "src": [
+ "test/core/util/histogram_test.cc"
],
"third_party": false,
"type": "target"
@@ -1295,7 +1198,7 @@
"language": "c",
"name": "hpack_parser_fuzzer_test",
"src": [
- "test/core/transport/chttp2/hpack_parser_fuzzer_test.c"
+ "test/core/transport/chttp2/hpack_parser_fuzzer_test.cc"
],
"third_party": false,
"type": "target"
@@ -1312,7 +1215,7 @@
"language": "c",
"name": "hpack_parser_test",
"src": [
- "test/core/transport/chttp2/hpack_parser_test.c"
+ "test/core/transport/chttp2/hpack_parser_test.cc"
],
"third_party": false,
"type": "target"
@@ -1329,7 +1232,7 @@
"language": "c",
"name": "hpack_table_test",
"src": [
- "test/core/transport/chttp2/hpack_table_test.c"
+ "test/core/transport/chttp2/hpack_table_test.cc"
],
"third_party": false,
"type": "target"
@@ -1346,7 +1249,7 @@
"language": "c",
"name": "http_parser_test",
"src": [
- "test/core/http/parser_test.c"
+ "test/core/http/parser_test.cc"
],
"third_party": false,
"type": "target"
@@ -1363,7 +1266,7 @@
"language": "c",
"name": "http_request_fuzzer_test",
"src": [
- "test/core/http/request_fuzzer.c"
+ "test/core/http/request_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -1380,7 +1283,7 @@
"language": "c",
"name": "http_response_fuzzer_test",
"src": [
- "test/core/http/response_fuzzer.c"
+ "test/core/http/response_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -1397,7 +1300,7 @@
"language": "c",
"name": "httpcli_format_request_test",
"src": [
- "test/core/http/format_request_test.c"
+ "test/core/http/format_request_test.cc"
],
"third_party": false,
"type": "target"
@@ -1414,7 +1317,7 @@
"language": "c",
"name": "httpcli_test",
"src": [
- "test/core/http/httpcli_test.c"
+ "test/core/http/httpcli_test.cc"
],
"third_party": false,
"type": "target"
@@ -1431,7 +1334,7 @@
"language": "c",
"name": "httpscli_test",
"src": [
- "test/core/http/httpscli_test.c"
+ "test/core/http/httpscli_test.cc"
],
"third_party": false,
"type": "target"
@@ -1448,7 +1351,7 @@
"language": "c",
"name": "init_test",
"src": [
- "test/core/surface/init_test.c"
+ "test/core/surface/init_test.cc"
],
"third_party": false,
"type": "target"
@@ -1465,7 +1368,7 @@
"language": "c",
"name": "invalid_call_argument_test",
"src": [
- "test/core/end2end/invalid_call_argument_test.c"
+ "test/core/end2end/invalid_call_argument_test.cc"
],
"third_party": false,
"type": "target"
@@ -1482,7 +1385,7 @@
"language": "c",
"name": "json_fuzzer_test",
"src": [
- "test/core/json/fuzzer.c"
+ "test/core/json/fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -1497,7 +1400,7 @@
"language": "c",
"name": "json_rewrite",
"src": [
- "test/core/json/json_rewrite.c"
+ "test/core/json/json_rewrite.cc"
],
"third_party": false,
"type": "target"
@@ -1514,7 +1417,7 @@
"language": "c",
"name": "json_rewrite_test",
"src": [
- "test/core/json/json_rewrite_test.c"
+ "test/core/json/json_rewrite_test.cc"
],
"third_party": false,
"type": "target"
@@ -1531,7 +1434,7 @@
"language": "c",
"name": "json_stream_error_test",
"src": [
- "test/core/json/json_stream_error_test.c"
+ "test/core/json/json_stream_error_test.cc"
],
"third_party": false,
"type": "target"
@@ -1548,7 +1451,7 @@
"language": "c",
"name": "json_test",
"src": [
- "test/core/json/json_test.c"
+ "test/core/json/json_test.cc"
],
"third_party": false,
"type": "target"
@@ -1565,7 +1468,7 @@
"language": "c",
"name": "lame_client_test",
"src": [
- "test/core/surface/lame_client_test.c"
+ "test/core/surface/lame_client_test.cc"
],
"third_party": false,
"type": "target"
@@ -1582,7 +1485,7 @@
"language": "c",
"name": "lb_policies_test",
"src": [
- "test/core/client_channel/lb_policies_test.c"
+ "test/core/client_channel/lb_policies_test.cc"
],
"third_party": false,
"type": "target"
@@ -1599,7 +1502,7 @@
"language": "c",
"name": "load_file_test",
"src": [
- "test/core/iomgr/load_file_test.c"
+ "test/core/iomgr/load_file_test.cc"
],
"third_party": false,
"type": "target"
@@ -1616,7 +1519,7 @@
"language": "c",
"name": "low_level_ping_pong_benchmark",
"src": [
- "test/core/network_benchmarks/low_level_ping_pong.c"
+ "test/core/network_benchmarks/low_level_ping_pong.cc"
],
"third_party": false,
"type": "target"
@@ -1633,7 +1536,7 @@
"language": "c",
"name": "memory_profile_client",
"src": [
- "test/core/memory_usage/client.c"
+ "test/core/memory_usage/client.cc"
],
"third_party": false,
"type": "target"
@@ -1650,7 +1553,7 @@
"language": "c",
"name": "memory_profile_server",
"src": [
- "test/core/memory_usage/server.c"
+ "test/core/memory_usage/server.cc"
],
"third_party": false,
"type": "target"
@@ -1667,7 +1570,7 @@
"language": "c",
"name": "memory_profile_test",
"src": [
- "test/core/memory_usage/memory_usage_test.c"
+ "test/core/memory_usage/memory_usage_test.cc"
],
"third_party": false,
"type": "target"
@@ -1684,7 +1587,7 @@
"language": "c",
"name": "message_compress_test",
"src": [
- "test/core/compression/message_compress_test.c"
+ "test/core/compression/message_compress_test.cc"
],
"third_party": false,
"type": "target"
@@ -1701,24 +1604,7 @@
"language": "c",
"name": "minimal_stack_is_minimal_test",
"src": [
- "test/core/channel/minimal_stack_is_minimal_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "mlog_test",
- "src": [
- "test/core/census/mlog_test.c"
+ "test/core/channel/minimal_stack_is_minimal_test.cc"
],
"third_party": false,
"type": "target"
@@ -1735,7 +1621,7 @@
"language": "c",
"name": "multiple_server_queues_test",
"src": [
- "test/core/end2end/multiple_server_queues_test.c"
+ "test/core/end2end/multiple_server_queues_test.cc"
],
"third_party": false,
"type": "target"
@@ -1750,7 +1636,7 @@
"language": "c",
"name": "murmur_hash_test",
"src": [
- "test/core/support/murmur_hash_test.c"
+ "test/core/gpr/murmur_hash_test.cc"
],
"third_party": false,
"type": "target"
@@ -1767,7 +1653,7 @@
"language": "c",
"name": "nanopb_fuzzer_response_test",
"src": [
- "test/core/nanopb/fuzzer_response.c"
+ "test/core/nanopb/fuzzer_response.cc"
],
"third_party": false,
"type": "target"
@@ -1784,7 +1670,7 @@
"language": "c",
"name": "nanopb_fuzzer_serverlist_test",
"src": [
- "test/core/nanopb/fuzzer_serverlist.c"
+ "test/core/nanopb/fuzzer_serverlist.cc"
],
"third_party": false,
"type": "target"
@@ -1801,7 +1687,7 @@
"language": "c",
"name": "no_server_test",
"src": [
- "test/core/end2end/no_server_test.c"
+ "test/core/end2end/no_server_test.cc"
],
"third_party": false,
"type": "target"
@@ -1818,7 +1704,7 @@
"language": "c",
"name": "num_external_connectivity_watchers_test",
"src": [
- "test/core/surface/num_external_connectivity_watchers_test.c"
+ "test/core/surface/num_external_connectivity_watchers_test.cc"
],
"third_party": false,
"type": "target"
@@ -1835,7 +1721,7 @@
"language": "c",
"name": "parse_address_test",
"src": [
- "test/core/client_channel/parse_address_test.c"
+ "test/core/client_channel/parse_address_test.cc"
],
"third_party": false,
"type": "target"
@@ -1852,7 +1738,7 @@
"language": "c",
"name": "percent_decode_fuzzer",
"src": [
- "test/core/slice/percent_decode_fuzzer.c"
+ "test/core/slice/percent_decode_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -1869,7 +1755,7 @@
"language": "c",
"name": "percent_encode_fuzzer",
"src": [
- "test/core/slice/percent_encode_fuzzer.c"
+ "test/core/slice/percent_encode_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -1886,7 +1772,7 @@
"language": "c",
"name": "percent_encoding_test",
"src": [
- "test/core/slice/percent_encoding_test.c"
+ "test/core/slice/percent_encoding_test.cc"
],
"third_party": false,
"type": "target"
@@ -1903,7 +1789,7 @@
"language": "c",
"name": "pollset_set_test",
"src": [
- "test/core/iomgr/pollset_set_test.c"
+ "test/core/iomgr/pollset_set_test.cc"
],
"third_party": false,
"type": "target"
@@ -1920,7 +1806,7 @@
"language": "c",
"name": "resolve_address_posix_test",
"src": [
- "test/core/iomgr/resolve_address_posix_test.c"
+ "test/core/iomgr/resolve_address_posix_test.cc"
],
"third_party": false,
"type": "target"
@@ -1937,7 +1823,7 @@
"language": "c",
"name": "resolve_address_test",
"src": [
- "test/core/iomgr/resolve_address_test.c"
+ "test/core/iomgr/resolve_address_test.cc"
],
"third_party": false,
"type": "target"
@@ -1954,7 +1840,7 @@
"language": "c",
"name": "resource_quota_test",
"src": [
- "test/core/iomgr/resource_quota_test.c"
+ "test/core/iomgr/resource_quota_test.cc"
],
"third_party": false,
"type": "target"
@@ -1971,7 +1857,7 @@
"language": "c",
"name": "secure_channel_create_test",
"src": [
- "test/core/surface/secure_channel_create_test.c"
+ "test/core/surface/secure_channel_create_test.cc"
],
"third_party": false,
"type": "target"
@@ -1988,7 +1874,7 @@
"language": "c",
"name": "secure_endpoint_test",
"src": [
- "test/core/security/secure_endpoint_test.c"
+ "test/core/security/secure_endpoint_test.cc"
],
"third_party": false,
"type": "target"
@@ -2005,7 +1891,7 @@
"language": "c",
"name": "sequential_connectivity_test",
"src": [
- "test/core/surface/sequential_connectivity_test.c"
+ "test/core/surface/sequential_connectivity_test.cc"
],
"third_party": false,
"type": "target"
@@ -2022,7 +1908,7 @@
"language": "c",
"name": "server_chttp2_test",
"src": [
- "test/core/surface/server_chttp2_test.c"
+ "test/core/surface/server_chttp2_test.cc"
],
"third_party": false,
"type": "target"
@@ -2039,7 +1925,7 @@
"language": "c",
"name": "server_fuzzer",
"src": [
- "test/core/end2end/fuzzers/server_fuzzer.c"
+ "test/core/end2end/fuzzers/server_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -2056,7 +1942,7 @@
"language": "c",
"name": "server_test",
"src": [
- "test/core/surface/server_test.c"
+ "test/core/surface/server_test.cc"
],
"third_party": false,
"type": "target"
@@ -2073,7 +1959,7 @@
"language": "c",
"name": "slice_buffer_test",
"src": [
- "test/core/slice/slice_buffer_test.c"
+ "test/core/slice/slice_buffer_test.cc"
],
"third_party": false,
"type": "target"
@@ -2090,7 +1976,7 @@
"language": "c",
"name": "slice_hash_table_test",
"src": [
- "test/core/slice/slice_hash_table_test.c"
+ "test/core/slice/slice_hash_table_test.cc"
],
"third_party": false,
"type": "target"
@@ -2107,7 +1993,7 @@
"language": "c",
"name": "slice_string_helpers_test",
"src": [
- "test/core/slice/slice_string_helpers_test.c"
+ "test/core/slice/slice_string_helpers_test.cc"
],
"third_party": false,
"type": "target"
@@ -2124,7 +2010,7 @@
"language": "c",
"name": "slice_test",
"src": [
- "test/core/slice/slice_test.c"
+ "test/core/slice/slice_test.cc"
],
"third_party": false,
"type": "target"
@@ -2141,7 +2027,7 @@
"language": "c",
"name": "sockaddr_resolver_test",
"src": [
- "test/core/client_channel/resolvers/sockaddr_resolver_test.c"
+ "test/core/client_channel/resolvers/sockaddr_resolver_test.cc"
],
"third_party": false,
"type": "target"
@@ -2158,7 +2044,7 @@
"language": "c",
"name": "sockaddr_utils_test",
"src": [
- "test/core/iomgr/sockaddr_utils_test.c"
+ "test/core/iomgr/sockaddr_utils_test.cc"
],
"third_party": false,
"type": "target"
@@ -2175,7 +2061,7 @@
"language": "c",
"name": "socket_utils_test",
"src": [
- "test/core/iomgr/socket_utils_test.c"
+ "test/core/iomgr/socket_utils_test.cc"
],
"third_party": false,
"type": "target"
@@ -2192,7 +2078,7 @@
"language": "c",
"name": "ssl_server_fuzzer",
"src": [
- "test/core/security/ssl_server_fuzzer.c"
+ "test/core/security/ssl_server_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -2209,7 +2095,7 @@
"language": "c",
"name": "ssl_transport_security_test",
"src": [
- "test/core/tsi/ssl_transport_security_test.c"
+ "test/core/tsi/ssl_transport_security_test.cc"
],
"third_party": false,
"type": "target"
@@ -2226,7 +2112,7 @@
"language": "c",
"name": "status_conversion_test",
"src": [
- "test/core/transport/status_conversion_test.c"
+ "test/core/transport/status_conversion_test.cc"
],
"third_party": false,
"type": "target"
@@ -2243,7 +2129,7 @@
"language": "c",
"name": "stream_compression_test",
"src": [
- "test/core/compression/stream_compression_test.c"
+ "test/core/compression/stream_compression_test.cc"
],
"third_party": false,
"type": "target"
@@ -2260,7 +2146,7 @@
"language": "c",
"name": "stream_owned_slice_test",
"src": [
- "test/core/transport/stream_owned_slice_test.c"
+ "test/core/transport/stream_owned_slice_test.cc"
],
"third_party": false,
"type": "target"
@@ -2277,7 +2163,7 @@
"language": "c",
"name": "tcp_client_posix_test",
"src": [
- "test/core/iomgr/tcp_client_posix_test.c"
+ "test/core/iomgr/tcp_client_posix_test.cc"
],
"third_party": false,
"type": "target"
@@ -2294,7 +2180,7 @@
"language": "c",
"name": "tcp_client_uv_test",
"src": [
- "test/core/iomgr/tcp_client_uv_test.c"
+ "test/core/iomgr/tcp_client_uv_test.cc"
],
"third_party": false,
"type": "target"
@@ -2311,7 +2197,7 @@
"language": "c",
"name": "tcp_posix_test",
"src": [
- "test/core/iomgr/tcp_posix_test.c"
+ "test/core/iomgr/tcp_posix_test.cc"
],
"third_party": false,
"type": "target"
@@ -2328,7 +2214,7 @@
"language": "c",
"name": "tcp_server_posix_test",
"src": [
- "test/core/iomgr/tcp_server_posix_test.c"
+ "test/core/iomgr/tcp_server_posix_test.cc"
],
"third_party": false,
"type": "target"
@@ -2345,7 +2231,7 @@
"language": "c",
"name": "tcp_server_uv_test",
"src": [
- "test/core/iomgr/tcp_server_uv_test.c"
+ "test/core/iomgr/tcp_server_uv_test.cc"
],
"third_party": false,
"type": "target"
@@ -2362,7 +2248,7 @@
"language": "c",
"name": "time_averaged_stats_test",
"src": [
- "test/core/iomgr/time_averaged_stats_test.c"
+ "test/core/iomgr/time_averaged_stats_test.cc"
],
"third_party": false,
"type": "target"
@@ -2379,7 +2265,7 @@
"language": "c",
"name": "timeout_encoding_test",
"src": [
- "test/core/transport/timeout_encoding_test.c"
+ "test/core/transport/timeout_encoding_test.cc"
],
"third_party": false,
"type": "target"
@@ -2396,7 +2282,7 @@
"language": "c",
"name": "timer_heap_test",
"src": [
- "test/core/iomgr/timer_heap_test.c"
+ "test/core/iomgr/timer_heap_test.cc"
],
"third_party": false,
"type": "target"
@@ -2413,7 +2299,7 @@
"language": "c",
"name": "timer_list_test",
"src": [
- "test/core/iomgr/timer_list_test.c"
+ "test/core/iomgr/timer_list_test.cc"
],
"third_party": false,
"type": "target"
@@ -2430,7 +2316,7 @@
"language": "c",
"name": "transport_connectivity_state_test",
"src": [
- "test/core/transport/connectivity_state_test.c"
+ "test/core/transport/connectivity_state_test.cc"
],
"third_party": false,
"type": "target"
@@ -2447,24 +2333,7 @@
"language": "c",
"name": "transport_metadata_test",
"src": [
- "test/core/transport/metadata_test.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "transport_pid_controller_test",
- "src": [
- "test/core/transport/pid_controller_test.c"
+ "test/core/transport/metadata_test.cc"
],
"third_party": false,
"type": "target"
@@ -2481,7 +2350,7 @@
"language": "c",
"name": "transport_security_test",
"src": [
- "test/core/tsi/transport_security_test.c"
+ "test/core/tsi/transport_security_test.cc"
],
"third_party": false,
"type": "target"
@@ -2498,7 +2367,7 @@
"language": "c",
"name": "udp_server_test",
"src": [
- "test/core/iomgr/udp_server_test.c"
+ "test/core/iomgr/udp_server_test.cc"
],
"third_party": false,
"type": "target"
@@ -2515,7 +2384,7 @@
"language": "c",
"name": "uri_fuzzer_test",
"src": [
- "test/core/client_channel/uri_fuzzer_test.c"
+ "test/core/client_channel/uri_fuzzer_test.cc"
],
"third_party": false,
"type": "target"
@@ -2532,7 +2401,7 @@
"language": "c",
"name": "uri_parser_test",
"src": [
- "test/core/client_channel/uri_parser_test.c"
+ "test/core/client_channel/uri_parser_test.cc"
],
"third_party": false,
"type": "target"
@@ -2549,7 +2418,7 @@
"language": "c",
"name": "wakeup_fd_cv_test",
"src": [
- "test/core/iomgr/wakeup_fd_cv_test.c"
+ "test/core/iomgr/wakeup_fd_cv_test.cc"
],
"third_party": false,
"type": "target"
@@ -2613,6 +2482,42 @@
},
{
"deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "backoff_test",
+ "src": [
+ "test/core/backoff/backoff_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "bdp_estimator_test",
+ "src": [
+ "test/core/transport/bdp_estimator_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
"benchmark",
"gpr",
"gpr_test_util",
@@ -2952,6 +2857,23 @@
"gpr",
"gpr_test_util",
"grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "chttp2_settings_timeout_test",
+ "src": [
+ "test/core/transport/chttp2/settings_timeout_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
"grpc++",
"grpc++_test_util",
"grpc_cli_libs",
@@ -2976,6 +2898,29 @@
"grpc++_test_util",
"grpc_test_util"
],
+ "headers": [
+ "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h",
+ "src/proto/grpc/lb/v1/load_balancer.pb.h",
+ "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h"
+ ],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "client_channel_stress_test",
+ "src": [
+ "test/cpp/client/client_channel_stress_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
+ ],
"headers": [],
"is_filegroup": false,
"language": "c++",
@@ -3227,6 +3172,25 @@
"headers": [],
"is_filegroup": false,
"language": "c++",
+ "name": "exception_test",
+ "src": [
+ "test/cpp/end2end/exception_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
"name": "filter_end2end_test",
"src": [
"test/cpp/end2end/filter_end2end_test.cc"
@@ -3493,6 +3457,28 @@
"gpr_test_util",
"grpc",
"grpc++",
+ "grpc++_test",
+ "grpc_test_util"
+ ],
+ "headers": [
+ "test/core/end2end/end2end_tests.h"
+ ],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "h2_ssl_cert_test",
+ "src": [
+ "test/core/end2end/end2end_tests.h",
+ "test/core/end2end/h2_ssl_cert_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
"grpc++_test_util",
"grpc_test_util"
],
@@ -3548,6 +3534,47 @@
"gpr_test_util",
"grpc",
"grpc++",
+ "grpc++_test",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "inlined_vector_test",
+ "src": [
+ "test/core/gprpp/inlined_vector_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_core_stats",
+ "grpc++_test_config",
+ "grpc++_test_util",
+ "grpc_test_util",
+ "qps"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "inproc_sync_unary_ping_pong_test",
+ "src": [
+ "test/cpp/qps/inproc_sync_unary_ping_pong_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
"grpc++_test_config",
"grpc++_test_util",
"grpc_test_util",
@@ -3635,7 +3662,7 @@
"language": "c++",
"name": "memory_test",
"src": [
- "test/core/support/memory_test.cc"
+ "test/core/gprpp/memory_test.cc"
],
"third_party": false,
"type": "target"
@@ -3705,6 +3732,25 @@
"gpr_test_util",
"grpc",
"grpc++",
+ "grpc++_test",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "orphanable_test",
+ "src": [
+ "test/core/gprpp/orphanable_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
"grpc++_proto_reflection_desc_db",
"grpc++_reflection",
"grpc++_test_util",
@@ -3897,6 +3943,44 @@
"gpr_test_util",
"grpc",
"grpc++",
+ "grpc++_test",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "ref_counted_ptr_test",
+ "src": [
+ "test/core/gprpp/ref_counted_ptr_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_test",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "ref_counted_test",
+ "src": [
+ "test/core/gprpp/ref_counted_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
"grpc++_test_util",
"grpc_test_util"
],
@@ -4038,6 +4122,25 @@
"deps": [
"gpr",
"gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "server_early_return_test",
+ "src": [
+ "test/cpp/end2end/server_early_return_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
"grpc++_test_util_unsecure",
"grpc++_unsecure",
"grpc_test_util_unsecure",
@@ -4228,6 +4331,25 @@
"headers": [],
"is_filegroup": false,
"language": "c++",
+ "name": "transport_pid_controller_test",
+ "src": [
+ "test/core/transport/pid_controller_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_test_util",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
"name": "writes_per_rpc_test",
"src": [
"test/cpp/performance/writes_per_rpc_test.cc"
@@ -4252,6 +4374,45 @@
},
{
"deps": [
+ "gpr",
+ "grpc"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "cc",
+ "name": "gen_hpack_tables",
+ "src": [
+ "tools/codegen/core/gen_hpack_tables.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "cc",
+ "name": "gen_legal_metadata_characters",
+ "src": [
+ "tools/codegen/core/gen_legal_metadata_characters.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "cc",
+ "name": "gen_percent_encoding_tables",
+ "src": [
+ "tools/codegen/core/gen_percent_encoding_tables.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
"boringssl",
"boringssl_aes_test_lib",
"boringssl_test_util"
@@ -4795,7 +4956,7 @@
"language": "c",
"name": "badreq_bad_client_test",
"src": [
- "test/core/bad_client/tests/badreq.c"
+ "test/core/bad_client/tests/badreq.cc"
],
"third_party": false,
"type": "target"
@@ -4813,7 +4974,7 @@
"language": "c",
"name": "connection_prefix_bad_client_test",
"src": [
- "test/core/bad_client/tests/connection_prefix.c"
+ "test/core/bad_client/tests/connection_prefix.cc"
],
"third_party": false,
"type": "target"
@@ -4831,7 +4992,7 @@
"language": "c",
"name": "head_of_line_blocking_bad_client_test",
"src": [
- "test/core/bad_client/tests/head_of_line_blocking.c"
+ "test/core/bad_client/tests/head_of_line_blocking.cc"
],
"third_party": false,
"type": "target"
@@ -4849,7 +5010,7 @@
"language": "c",
"name": "headers_bad_client_test",
"src": [
- "test/core/bad_client/tests/headers.c"
+ "test/core/bad_client/tests/headers.cc"
],
"third_party": false,
"type": "target"
@@ -4867,25 +5028,7 @@
"language": "c",
"name": "initial_settings_frame_bad_client_test",
"src": [
- "test/core/bad_client/tests/initial_settings_frame.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "bad_client_test",
- "gpr",
- "gpr_test_util",
- "grpc_test_util_unsecure",
- "grpc_unsecure"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "large_metadata_bad_client_test",
- "src": [
- "test/core/bad_client/tests/large_metadata.c"
+ "test/core/bad_client/tests/initial_settings_frame.cc"
],
"third_party": false,
"type": "target"
@@ -4903,7 +5046,7 @@
"language": "c",
"name": "server_registered_method_bad_client_test",
"src": [
- "test/core/bad_client/tests/server_registered_method.c"
+ "test/core/bad_client/tests/server_registered_method.cc"
],
"third_party": false,
"type": "target"
@@ -4921,7 +5064,7 @@
"language": "c",
"name": "simple_request_bad_client_test",
"src": [
- "test/core/bad_client/tests/simple_request.c"
+ "test/core/bad_client/tests/simple_request.cc"
],
"third_party": false,
"type": "target"
@@ -4939,7 +5082,7 @@
"language": "c",
"name": "unknown_frame_bad_client_test",
"src": [
- "test/core/bad_client/tests/unknown_frame.c"
+ "test/core/bad_client/tests/unknown_frame.cc"
],
"third_party": false,
"type": "target"
@@ -4957,7 +5100,7 @@
"language": "c",
"name": "window_overflow_bad_client_test",
"src": [
- "test/core/bad_client/tests/window_overflow.c"
+ "test/core/bad_client/tests/window_overflow.cc"
],
"third_party": false,
"type": "target"
@@ -4975,7 +5118,7 @@
"language": "c",
"name": "bad_ssl_cert_server",
"src": [
- "test/core/bad_ssl/servers/cert.c"
+ "test/core/bad_ssl/servers/cert.cc"
],
"third_party": false,
"type": "target"
@@ -4992,7 +5135,7 @@
"language": "c",
"name": "bad_ssl_cert_test",
"src": [
- "test/core/bad_ssl/bad_ssl_test.c"
+ "test/core/bad_ssl/bad_ssl_test.cc"
],
"third_party": false,
"type": "target"
@@ -5010,7 +5153,7 @@
"language": "c",
"name": "h2_census_test",
"src": [
- "test/core/end2end/fixtures/h2_census.c"
+ "test/core/end2end/fixtures/h2_census.cc"
],
"third_party": false,
"type": "target"
@@ -5028,7 +5171,7 @@
"language": "c",
"name": "h2_compress_test",
"src": [
- "test/core/end2end/fixtures/h2_compress.c"
+ "test/core/end2end/fixtures/h2_compress.cc"
],
"third_party": false,
"type": "target"
@@ -5046,7 +5189,7 @@
"language": "c",
"name": "h2_fakesec_test",
"src": [
- "test/core/end2end/fixtures/h2_fakesec.c"
+ "test/core/end2end/fixtures/h2_fakesec.cc"
],
"third_party": false,
"type": "target"
@@ -5064,7 +5207,7 @@
"language": "c",
"name": "h2_fd_test",
"src": [
- "test/core/end2end/fixtures/h2_fd.c"
+ "test/core/end2end/fixtures/h2_fd.cc"
],
"third_party": false,
"type": "target"
@@ -5082,7 +5225,7 @@
"language": "c",
"name": "h2_full_test",
"src": [
- "test/core/end2end/fixtures/h2_full.c"
+ "test/core/end2end/fixtures/h2_full.cc"
],
"third_party": false,
"type": "target"
@@ -5100,7 +5243,7 @@
"language": "c",
"name": "h2_full+pipe_test",
"src": [
- "test/core/end2end/fixtures/h2_full+pipe.c"
+ "test/core/end2end/fixtures/h2_full+pipe.cc"
],
"third_party": false,
"type": "target"
@@ -5118,7 +5261,7 @@
"language": "c",
"name": "h2_full+trace_test",
"src": [
- "test/core/end2end/fixtures/h2_full+trace.c"
+ "test/core/end2end/fixtures/h2_full+trace.cc"
],
"third_party": false,
"type": "target"
@@ -5136,7 +5279,7 @@
"language": "c",
"name": "h2_full+workarounds_test",
"src": [
- "test/core/end2end/fixtures/h2_full+workarounds.c"
+ "test/core/end2end/fixtures/h2_full+workarounds.cc"
],
"third_party": false,
"type": "target"
@@ -5154,7 +5297,7 @@
"language": "c",
"name": "h2_http_proxy_test",
"src": [
- "test/core/end2end/fixtures/h2_http_proxy.c"
+ "test/core/end2end/fixtures/h2_http_proxy.cc"
],
"third_party": false,
"type": "target"
@@ -5172,7 +5315,7 @@
"language": "c",
"name": "h2_load_reporting_test",
"src": [
- "test/core/end2end/fixtures/h2_load_reporting.c"
+ "test/core/end2end/fixtures/h2_load_reporting.cc"
],
"third_party": false,
"type": "target"
@@ -5190,7 +5333,7 @@
"language": "c",
"name": "h2_oauth2_test",
"src": [
- "test/core/end2end/fixtures/h2_oauth2.c"
+ "test/core/end2end/fixtures/h2_oauth2.cc"
],
"third_party": false,
"type": "target"
@@ -5208,7 +5351,7 @@
"language": "c",
"name": "h2_proxy_test",
"src": [
- "test/core/end2end/fixtures/h2_proxy.c"
+ "test/core/end2end/fixtures/h2_proxy.cc"
],
"third_party": false,
"type": "target"
@@ -5226,7 +5369,7 @@
"language": "c",
"name": "h2_sockpair_test",
"src": [
- "test/core/end2end/fixtures/h2_sockpair.c"
+ "test/core/end2end/fixtures/h2_sockpair.cc"
],
"third_party": false,
"type": "target"
@@ -5244,7 +5387,7 @@
"language": "c",
"name": "h2_sockpair+trace_test",
"src": [
- "test/core/end2end/fixtures/h2_sockpair+trace.c"
+ "test/core/end2end/fixtures/h2_sockpair+trace.cc"
],
"third_party": false,
"type": "target"
@@ -5262,7 +5405,7 @@
"language": "c",
"name": "h2_sockpair_1byte_test",
"src": [
- "test/core/end2end/fixtures/h2_sockpair_1byte.c"
+ "test/core/end2end/fixtures/h2_sockpair_1byte.cc"
],
"third_party": false,
"type": "target"
@@ -5280,25 +5423,7 @@
"language": "c",
"name": "h2_ssl_test",
"src": [
- "test/core/end2end/fixtures/h2_ssl.c"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "end2end_tests",
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "src": [
- "test/core/end2end/fixtures/h2_ssl_cert.c"
+ "test/core/end2end/fixtures/h2_ssl.cc"
],
"third_party": false,
"type": "target"
@@ -5316,7 +5441,7 @@
"language": "c",
"name": "h2_ssl_proxy_test",
"src": [
- "test/core/end2end/fixtures/h2_ssl_proxy.c"
+ "test/core/end2end/fixtures/h2_ssl_proxy.cc"
],
"third_party": false,
"type": "target"
@@ -5334,7 +5459,7 @@
"language": "c",
"name": "h2_uds_test",
"src": [
- "test/core/end2end/fixtures/h2_uds.c"
+ "test/core/end2end/fixtures/h2_uds.cc"
],
"third_party": false,
"type": "target"
@@ -5352,7 +5477,7 @@
"language": "c",
"name": "inproc_test",
"src": [
- "test/core/end2end/fixtures/inproc.c"
+ "test/core/end2end/fixtures/inproc.cc"
],
"third_party": false,
"type": "target"
@@ -5370,7 +5495,7 @@
"language": "c",
"name": "h2_census_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_census.c"
+ "test/core/end2end/fixtures/h2_census.cc"
],
"third_party": false,
"type": "target"
@@ -5388,7 +5513,7 @@
"language": "c",
"name": "h2_compress_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_compress.c"
+ "test/core/end2end/fixtures/h2_compress.cc"
],
"third_party": false,
"type": "target"
@@ -5406,7 +5531,7 @@
"language": "c",
"name": "h2_fd_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_fd.c"
+ "test/core/end2end/fixtures/h2_fd.cc"
],
"third_party": false,
"type": "target"
@@ -5424,7 +5549,7 @@
"language": "c",
"name": "h2_full_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_full.c"
+ "test/core/end2end/fixtures/h2_full.cc"
],
"third_party": false,
"type": "target"
@@ -5442,7 +5567,7 @@
"language": "c",
"name": "h2_full+pipe_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_full+pipe.c"
+ "test/core/end2end/fixtures/h2_full+pipe.cc"
],
"third_party": false,
"type": "target"
@@ -5460,7 +5585,7 @@
"language": "c",
"name": "h2_full+trace_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_full+trace.c"
+ "test/core/end2end/fixtures/h2_full+trace.cc"
],
"third_party": false,
"type": "target"
@@ -5478,7 +5603,7 @@
"language": "c",
"name": "h2_full+workarounds_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_full+workarounds.c"
+ "test/core/end2end/fixtures/h2_full+workarounds.cc"
],
"third_party": false,
"type": "target"
@@ -5496,7 +5621,7 @@
"language": "c",
"name": "h2_http_proxy_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_http_proxy.c"
+ "test/core/end2end/fixtures/h2_http_proxy.cc"
],
"third_party": false,
"type": "target"
@@ -5514,7 +5639,7 @@
"language": "c",
"name": "h2_load_reporting_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_load_reporting.c"
+ "test/core/end2end/fixtures/h2_load_reporting.cc"
],
"third_party": false,
"type": "target"
@@ -5532,7 +5657,7 @@
"language": "c",
"name": "h2_proxy_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_proxy.c"
+ "test/core/end2end/fixtures/h2_proxy.cc"
],
"third_party": false,
"type": "target"
@@ -5550,7 +5675,7 @@
"language": "c",
"name": "h2_sockpair_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_sockpair.c"
+ "test/core/end2end/fixtures/h2_sockpair.cc"
],
"third_party": false,
"type": "target"
@@ -5568,7 +5693,7 @@
"language": "c",
"name": "h2_sockpair+trace_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_sockpair+trace.c"
+ "test/core/end2end/fixtures/h2_sockpair+trace.cc"
],
"third_party": false,
"type": "target"
@@ -5586,7 +5711,7 @@
"language": "c",
"name": "h2_sockpair_1byte_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_sockpair_1byte.c"
+ "test/core/end2end/fixtures/h2_sockpair_1byte.cc"
],
"third_party": false,
"type": "target"
@@ -5604,7 +5729,7 @@
"language": "c",
"name": "h2_uds_nosec_test",
"src": [
- "test/core/end2end/fixtures/h2_uds.c"
+ "test/core/end2end/fixtures/h2_uds.cc"
],
"third_party": false,
"type": "target"
@@ -5622,7 +5747,7 @@
"language": "c",
"name": "inproc_nosec_test",
"src": [
- "test/core/end2end/fixtures/inproc.c"
+ "test/core/end2end/fixtures/inproc.cc"
],
"third_party": false,
"type": "target"
@@ -5719,8 +5844,8 @@
"language": "c",
"name": "api_fuzzer_one_entry",
"src": [
- "test/core/end2end/fuzzers/api_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/end2end/fuzzers/api_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5737,8 +5862,8 @@
"language": "c",
"name": "client_fuzzer_one_entry",
"src": [
- "test/core/end2end/fuzzers/client_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/end2end/fuzzers/client_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5755,8 +5880,8 @@
"language": "c",
"name": "hpack_parser_fuzzer_test_one_entry",
"src": [
- "test/core/transport/chttp2/hpack_parser_fuzzer_test.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/transport/chttp2/hpack_parser_fuzzer_test.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5773,8 +5898,8 @@
"language": "c",
"name": "http_request_fuzzer_test_one_entry",
"src": [
- "test/core/http/request_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/http/request_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5791,8 +5916,8 @@
"language": "c",
"name": "http_response_fuzzer_test_one_entry",
"src": [
- "test/core/http/response_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/http/response_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5809,8 +5934,8 @@
"language": "c",
"name": "json_fuzzer_test_one_entry",
"src": [
- "test/core/json/fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/json/fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5827,8 +5952,8 @@
"language": "c",
"name": "nanopb_fuzzer_response_test_one_entry",
"src": [
- "test/core/nanopb/fuzzer_response.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/nanopb/fuzzer_response.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5845,8 +5970,8 @@
"language": "c",
"name": "nanopb_fuzzer_serverlist_test_one_entry",
"src": [
- "test/core/nanopb/fuzzer_serverlist.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/nanopb/fuzzer_serverlist.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5863,8 +5988,8 @@
"language": "c",
"name": "percent_decode_fuzzer_one_entry",
"src": [
- "test/core/slice/percent_decode_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/slice/percent_decode_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5881,8 +6006,8 @@
"language": "c",
"name": "percent_encode_fuzzer_one_entry",
"src": [
- "test/core/slice/percent_encode_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/slice/percent_encode_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5899,8 +6024,8 @@
"language": "c",
"name": "server_fuzzer_one_entry",
"src": [
- "test/core/end2end/fuzzers/server_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/end2end/fuzzers/server_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5917,8 +6042,8 @@
"language": "c",
"name": "ssl_server_fuzzer_one_entry",
"src": [
- "test/core/security/ssl_server_fuzzer.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/security/ssl_server_fuzzer.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5935,8 +6060,8 @@
"language": "c",
"name": "uri_fuzzer_test_one_entry",
"src": [
- "test/core/client_channel/uri_fuzzer_test.c",
- "test/core/util/one_corpus_entry_fuzzer.c"
+ "test/core/client_channel/uri_fuzzer_test.cc",
+ "test/core/util/one_corpus_entry_fuzzer.cc"
],
"third_party": false,
"type": "target"
@@ -5964,7 +6089,7 @@
"language": "c",
"name": "gpr_test_util",
"src": [
- "test/core/util/test_config.c",
+ "test/core/util/test_config.cc",
"test/core/util/test_config.h"
],
"third_party": false,
@@ -6000,7 +6125,7 @@
"language": "c",
"name": "grpc",
"src": [
- "src/core/lib/surface/init.c"
+ "src/core/lib/surface/init.cc"
],
"third_party": false,
"type": "lib"
@@ -6018,7 +6143,7 @@
"language": "c",
"name": "grpc_cronet",
"src": [
- "src/core/lib/surface/init.c"
+ "src/core/lib/surface/init.cc"
],
"third_party": false,
"type": "lib"
@@ -6051,12 +6176,12 @@
"language": "c",
"name": "grpc_test_util",
"src": [
- "test/core/end2end/data/client_certs.c",
- "test/core/end2end/data/server1_cert.c",
- "test/core/end2end/data/server1_key.c",
+ "test/core/end2end/data/client_certs.cc",
+ "test/core/end2end/data/server1_cert.cc",
+ "test/core/end2end/data/server1_key.cc",
"test/core/end2end/data/ssl_test_data.h",
- "test/core/end2end/data/test_root_cert.c",
- "test/core/security/oauth2_utils.c",
+ "test/core/end2end/data/test_root_cert.cc",
+ "test/core/security/oauth2_utils.cc",
"test/core/security/oauth2_utils.h"
],
"third_party": false,
@@ -6104,8 +6229,8 @@
"language": "c",
"name": "grpc_unsecure",
"src": [
- "src/core/lib/surface/init.c",
- "src/core/lib/surface/init_unsecure.c"
+ "src/core/lib/surface/init.cc",
+ "src/core/lib/surface/init_unsecure.cc"
],
"third_party": false,
"type": "lib"
@@ -6125,7 +6250,7 @@
"language": "c",
"name": "reconnect_server",
"src": [
- "test/core/util/reconnect_server.c",
+ "test/core/util/reconnect_server.cc",
"test/core/util/reconnect_server.h"
],
"third_party": false,
@@ -6145,7 +6270,7 @@
"language": "c",
"name": "test_tcp_server",
"src": [
- "test/core/util/test_tcp_server.c",
+ "test/core/util/test_tcp_server.cc",
"test/core/util/test_tcp_server.h"
],
"third_party": false,
@@ -7403,7 +7528,6 @@
"headers": [
"third_party/benchmark/include/benchmark/benchmark.h",
"third_party/benchmark/include/benchmark/benchmark_api.h",
- "third_party/benchmark/include/benchmark/macros.h",
"third_party/benchmark/include/benchmark/reporter.h",
"third_party/benchmark/src/arraysize.h",
"third_party/benchmark/src/benchmark_api_internal.h",
@@ -7411,6 +7535,7 @@
"third_party/benchmark/src/colorprint.h",
"third_party/benchmark/src/commandlineflags.h",
"third_party/benchmark/src/complexity.h",
+ "third_party/benchmark/src/counter.h",
"third_party/benchmark/src/cycleclock.h",
"third_party/benchmark/src/internal_macros.h",
"third_party/benchmark/src/log.h",
@@ -7477,7 +7602,9 @@
"third_party/cares/cares/config-win32.h",
"third_party/cares/cares/setup_once.h",
"third_party/cares/config_darwin/ares_config.h",
- "third_party/cares/config_linux/ares_config.h"
+ "third_party/cares/config_freebsd/ares_config.h",
+ "third_party/cares/config_linux/ares_config.h",
+ "third_party/cares/config_openbsd/ares_config.h"
],
"is_filegroup": false,
"language": "c",
@@ -7500,7 +7627,7 @@
"language": "c",
"name": "bad_client_test",
"src": [
- "test/core/bad_client/bad_client.c",
+ "test/core/bad_client/bad_client.cc",
"test/core/bad_client/bad_client.h"
],
"third_party": false,
@@ -7520,7 +7647,7 @@
"language": "c",
"name": "bad_ssl_test_server",
"src": [
- "test/core/bad_ssl/server_common.c",
+ "test/core/bad_ssl/server_common.cc",
"test/core/bad_ssl/server_common.h"
],
"third_party": false,
@@ -7541,69 +7668,70 @@
"language": "c",
"name": "end2end_tests",
"src": [
- "test/core/end2end/end2end_test_utils.c",
- "test/core/end2end/end2end_tests.c",
+ "test/core/end2end/end2end_test_utils.cc",
+ "test/core/end2end/end2end_tests.cc",
"test/core/end2end/end2end_tests.h",
- "test/core/end2end/tests/authority_not_supported.c",
- "test/core/end2end/tests/bad_hostname.c",
- "test/core/end2end/tests/bad_ping.c",
- "test/core/end2end/tests/binary_metadata.c",
- "test/core/end2end/tests/call_creds.c",
- "test/core/end2end/tests/cancel_after_accept.c",
- "test/core/end2end/tests/cancel_after_client_done.c",
- "test/core/end2end/tests/cancel_after_invoke.c",
- "test/core/end2end/tests/cancel_after_round_trip.c",
- "test/core/end2end/tests/cancel_before_invoke.c",
- "test/core/end2end/tests/cancel_in_a_vacuum.c",
+ "test/core/end2end/tests/authority_not_supported.cc",
+ "test/core/end2end/tests/bad_hostname.cc",
+ "test/core/end2end/tests/bad_ping.cc",
+ "test/core/end2end/tests/binary_metadata.cc",
+ "test/core/end2end/tests/call_creds.cc",
+ "test/core/end2end/tests/cancel_after_accept.cc",
+ "test/core/end2end/tests/cancel_after_client_done.cc",
+ "test/core/end2end/tests/cancel_after_invoke.cc",
+ "test/core/end2end/tests/cancel_after_round_trip.cc",
+ "test/core/end2end/tests/cancel_before_invoke.cc",
+ "test/core/end2end/tests/cancel_in_a_vacuum.cc",
"test/core/end2end/tests/cancel_test_helpers.h",
- "test/core/end2end/tests/cancel_with_status.c",
- "test/core/end2end/tests/compressed_payload.c",
- "test/core/end2end/tests/connectivity.c",
- "test/core/end2end/tests/default_host.c",
- "test/core/end2end/tests/disappearing_server.c",
- "test/core/end2end/tests/empty_batch.c",
- "test/core/end2end/tests/filter_call_init_fails.c",
- "test/core/end2end/tests/filter_causes_close.c",
- "test/core/end2end/tests/filter_latency.c",
- "test/core/end2end/tests/graceful_server_shutdown.c",
- "test/core/end2end/tests/high_initial_seqno.c",
- "test/core/end2end/tests/hpack_size.c",
- "test/core/end2end/tests/idempotent_request.c",
- "test/core/end2end/tests/invoke_large_request.c",
- "test/core/end2end/tests/keepalive_timeout.c",
- "test/core/end2end/tests/large_metadata.c",
- "test/core/end2end/tests/load_reporting_hook.c",
- "test/core/end2end/tests/max_concurrent_streams.c",
- "test/core/end2end/tests/max_connection_age.c",
- "test/core/end2end/tests/max_connection_idle.c",
- "test/core/end2end/tests/max_message_length.c",
- "test/core/end2end/tests/negative_deadline.c",
- "test/core/end2end/tests/network_status_change.c",
- "test/core/end2end/tests/no_logging.c",
- "test/core/end2end/tests/no_op.c",
- "test/core/end2end/tests/payload.c",
- "test/core/end2end/tests/ping.c",
- "test/core/end2end/tests/ping_pong_streaming.c",
- "test/core/end2end/tests/proxy_auth.c",
- "test/core/end2end/tests/registered_call.c",
- "test/core/end2end/tests/request_with_flags.c",
- "test/core/end2end/tests/request_with_payload.c",
- "test/core/end2end/tests/resource_quota_server.c",
- "test/core/end2end/tests/server_finishes_request.c",
- "test/core/end2end/tests/shutdown_finishes_calls.c",
- "test/core/end2end/tests/shutdown_finishes_tags.c",
- "test/core/end2end/tests/simple_cacheable_request.c",
- "test/core/end2end/tests/simple_delayed_request.c",
- "test/core/end2end/tests/simple_metadata.c",
- "test/core/end2end/tests/simple_request.c",
- "test/core/end2end/tests/stream_compression_compressed_payload.c",
- "test/core/end2end/tests/stream_compression_payload.c",
- "test/core/end2end/tests/stream_compression_ping_pong_streaming.c",
- "test/core/end2end/tests/streaming_error_response.c",
- "test/core/end2end/tests/trailing_metadata.c",
- "test/core/end2end/tests/workaround_cronet_compression.c",
- "test/core/end2end/tests/write_buffering.c",
- "test/core/end2end/tests/write_buffering_at_end.c"
+ "test/core/end2end/tests/cancel_with_status.cc",
+ "test/core/end2end/tests/compressed_payload.cc",
+ "test/core/end2end/tests/connectivity.cc",
+ "test/core/end2end/tests/default_host.cc",
+ "test/core/end2end/tests/disappearing_server.cc",
+ "test/core/end2end/tests/empty_batch.cc",
+ "test/core/end2end/tests/filter_call_init_fails.cc",
+ "test/core/end2end/tests/filter_causes_close.cc",
+ "test/core/end2end/tests/filter_latency.cc",
+ "test/core/end2end/tests/filter_status_code.cc",
+ "test/core/end2end/tests/graceful_server_shutdown.cc",
+ "test/core/end2end/tests/high_initial_seqno.cc",
+ "test/core/end2end/tests/hpack_size.cc",
+ "test/core/end2end/tests/idempotent_request.cc",
+ "test/core/end2end/tests/invoke_large_request.cc",
+ "test/core/end2end/tests/keepalive_timeout.cc",
+ "test/core/end2end/tests/large_metadata.cc",
+ "test/core/end2end/tests/load_reporting_hook.cc",
+ "test/core/end2end/tests/max_concurrent_streams.cc",
+ "test/core/end2end/tests/max_connection_age.cc",
+ "test/core/end2end/tests/max_connection_idle.cc",
+ "test/core/end2end/tests/max_message_length.cc",
+ "test/core/end2end/tests/negative_deadline.cc",
+ "test/core/end2end/tests/network_status_change.cc",
+ "test/core/end2end/tests/no_logging.cc",
+ "test/core/end2end/tests/no_op.cc",
+ "test/core/end2end/tests/payload.cc",
+ "test/core/end2end/tests/ping.cc",
+ "test/core/end2end/tests/ping_pong_streaming.cc",
+ "test/core/end2end/tests/proxy_auth.cc",
+ "test/core/end2end/tests/registered_call.cc",
+ "test/core/end2end/tests/request_with_flags.cc",
+ "test/core/end2end/tests/request_with_payload.cc",
+ "test/core/end2end/tests/resource_quota_server.cc",
+ "test/core/end2end/tests/server_finishes_request.cc",
+ "test/core/end2end/tests/shutdown_finishes_calls.cc",
+ "test/core/end2end/tests/shutdown_finishes_tags.cc",
+ "test/core/end2end/tests/simple_cacheable_request.cc",
+ "test/core/end2end/tests/simple_delayed_request.cc",
+ "test/core/end2end/tests/simple_metadata.cc",
+ "test/core/end2end/tests/simple_request.cc",
+ "test/core/end2end/tests/stream_compression_compressed_payload.cc",
+ "test/core/end2end/tests/stream_compression_payload.cc",
+ "test/core/end2end/tests/stream_compression_ping_pong_streaming.cc",
+ "test/core/end2end/tests/streaming_error_response.cc",
+ "test/core/end2end/tests/trailing_metadata.cc",
+ "test/core/end2end/tests/workaround_cronet_compression.cc",
+ "test/core/end2end/tests/write_buffering.cc",
+ "test/core/end2end/tests/write_buffering_at_end.cc"
],
"third_party": false,
"type": "lib"
@@ -7623,68 +7751,69 @@
"language": "c",
"name": "end2end_nosec_tests",
"src": [
- "test/core/end2end/end2end_nosec_tests.c",
- "test/core/end2end/end2end_test_utils.c",
+ "test/core/end2end/end2end_nosec_tests.cc",
+ "test/core/end2end/end2end_test_utils.cc",
"test/core/end2end/end2end_tests.h",
- "test/core/end2end/tests/authority_not_supported.c",
- "test/core/end2end/tests/bad_hostname.c",
- "test/core/end2end/tests/bad_ping.c",
- "test/core/end2end/tests/binary_metadata.c",
- "test/core/end2end/tests/cancel_after_accept.c",
- "test/core/end2end/tests/cancel_after_client_done.c",
- "test/core/end2end/tests/cancel_after_invoke.c",
- "test/core/end2end/tests/cancel_after_round_trip.c",
- "test/core/end2end/tests/cancel_before_invoke.c",
- "test/core/end2end/tests/cancel_in_a_vacuum.c",
+ "test/core/end2end/tests/authority_not_supported.cc",
+ "test/core/end2end/tests/bad_hostname.cc",
+ "test/core/end2end/tests/bad_ping.cc",
+ "test/core/end2end/tests/binary_metadata.cc",
+ "test/core/end2end/tests/cancel_after_accept.cc",
+ "test/core/end2end/tests/cancel_after_client_done.cc",
+ "test/core/end2end/tests/cancel_after_invoke.cc",
+ "test/core/end2end/tests/cancel_after_round_trip.cc",
+ "test/core/end2end/tests/cancel_before_invoke.cc",
+ "test/core/end2end/tests/cancel_in_a_vacuum.cc",
"test/core/end2end/tests/cancel_test_helpers.h",
- "test/core/end2end/tests/cancel_with_status.c",
- "test/core/end2end/tests/compressed_payload.c",
- "test/core/end2end/tests/connectivity.c",
- "test/core/end2end/tests/default_host.c",
- "test/core/end2end/tests/disappearing_server.c",
- "test/core/end2end/tests/empty_batch.c",
- "test/core/end2end/tests/filter_call_init_fails.c",
- "test/core/end2end/tests/filter_causes_close.c",
- "test/core/end2end/tests/filter_latency.c",
- "test/core/end2end/tests/graceful_server_shutdown.c",
- "test/core/end2end/tests/high_initial_seqno.c",
- "test/core/end2end/tests/hpack_size.c",
- "test/core/end2end/tests/idempotent_request.c",
- "test/core/end2end/tests/invoke_large_request.c",
- "test/core/end2end/tests/keepalive_timeout.c",
- "test/core/end2end/tests/large_metadata.c",
- "test/core/end2end/tests/load_reporting_hook.c",
- "test/core/end2end/tests/max_concurrent_streams.c",
- "test/core/end2end/tests/max_connection_age.c",
- "test/core/end2end/tests/max_connection_idle.c",
- "test/core/end2end/tests/max_message_length.c",
- "test/core/end2end/tests/negative_deadline.c",
- "test/core/end2end/tests/network_status_change.c",
- "test/core/end2end/tests/no_logging.c",
- "test/core/end2end/tests/no_op.c",
- "test/core/end2end/tests/payload.c",
- "test/core/end2end/tests/ping.c",
- "test/core/end2end/tests/ping_pong_streaming.c",
- "test/core/end2end/tests/proxy_auth.c",
- "test/core/end2end/tests/registered_call.c",
- "test/core/end2end/tests/request_with_flags.c",
- "test/core/end2end/tests/request_with_payload.c",
- "test/core/end2end/tests/resource_quota_server.c",
- "test/core/end2end/tests/server_finishes_request.c",
- "test/core/end2end/tests/shutdown_finishes_calls.c",
- "test/core/end2end/tests/shutdown_finishes_tags.c",
- "test/core/end2end/tests/simple_cacheable_request.c",
- "test/core/end2end/tests/simple_delayed_request.c",
- "test/core/end2end/tests/simple_metadata.c",
- "test/core/end2end/tests/simple_request.c",
- "test/core/end2end/tests/stream_compression_compressed_payload.c",
- "test/core/end2end/tests/stream_compression_payload.c",
- "test/core/end2end/tests/stream_compression_ping_pong_streaming.c",
- "test/core/end2end/tests/streaming_error_response.c",
- "test/core/end2end/tests/trailing_metadata.c",
- "test/core/end2end/tests/workaround_cronet_compression.c",
- "test/core/end2end/tests/write_buffering.c",
- "test/core/end2end/tests/write_buffering_at_end.c"
+ "test/core/end2end/tests/cancel_with_status.cc",
+ "test/core/end2end/tests/compressed_payload.cc",
+ "test/core/end2end/tests/connectivity.cc",
+ "test/core/end2end/tests/default_host.cc",
+ "test/core/end2end/tests/disappearing_server.cc",
+ "test/core/end2end/tests/empty_batch.cc",
+ "test/core/end2end/tests/filter_call_init_fails.cc",
+ "test/core/end2end/tests/filter_causes_close.cc",
+ "test/core/end2end/tests/filter_latency.cc",
+ "test/core/end2end/tests/filter_status_code.cc",
+ "test/core/end2end/tests/graceful_server_shutdown.cc",
+ "test/core/end2end/tests/high_initial_seqno.cc",
+ "test/core/end2end/tests/hpack_size.cc",
+ "test/core/end2end/tests/idempotent_request.cc",
+ "test/core/end2end/tests/invoke_large_request.cc",
+ "test/core/end2end/tests/keepalive_timeout.cc",
+ "test/core/end2end/tests/large_metadata.cc",
+ "test/core/end2end/tests/load_reporting_hook.cc",
+ "test/core/end2end/tests/max_concurrent_streams.cc",
+ "test/core/end2end/tests/max_connection_age.cc",
+ "test/core/end2end/tests/max_connection_idle.cc",
+ "test/core/end2end/tests/max_message_length.cc",
+ "test/core/end2end/tests/negative_deadline.cc",
+ "test/core/end2end/tests/network_status_change.cc",
+ "test/core/end2end/tests/no_logging.cc",
+ "test/core/end2end/tests/no_op.cc",
+ "test/core/end2end/tests/payload.cc",
+ "test/core/end2end/tests/ping.cc",
+ "test/core/end2end/tests/ping_pong_streaming.cc",
+ "test/core/end2end/tests/proxy_auth.cc",
+ "test/core/end2end/tests/registered_call.cc",
+ "test/core/end2end/tests/request_with_flags.cc",
+ "test/core/end2end/tests/request_with_payload.cc",
+ "test/core/end2end/tests/resource_quota_server.cc",
+ "test/core/end2end/tests/server_finishes_request.cc",
+ "test/core/end2end/tests/shutdown_finishes_calls.cc",
+ "test/core/end2end/tests/shutdown_finishes_tags.cc",
+ "test/core/end2end/tests/simple_cacheable_request.cc",
+ "test/core/end2end/tests/simple_delayed_request.cc",
+ "test/core/end2end/tests/simple_metadata.cc",
+ "test/core/end2end/tests/simple_request.cc",
+ "test/core/end2end/tests/stream_compression_compressed_payload.cc",
+ "test/core/end2end/tests/stream_compression_payload.cc",
+ "test/core/end2end/tests/stream_compression_ping_pong_streaming.cc",
+ "test/core/end2end/tests/streaming_error_response.cc",
+ "test/core/end2end/tests/trailing_metadata.cc",
+ "test/core/end2end/tests/workaround_cronet_compression.cc",
+ "test/core/end2end/tests/write_buffering.cc",
+ "test/core/end2end/tests/write_buffering_at_end.cc"
],
"third_party": false,
"type": "lib"
@@ -7696,64 +7825,14 @@
"nanopb"
],
"headers": [
- "include/grpc/census.h",
- "src/core/ext/census/aggregation.h",
- "src/core/ext/census/base_resources.h",
- "src/core/ext/census/census_interface.h",
- "src/core/ext/census/census_rpc_stats.h",
- "src/core/ext/census/gen/census.pb.h",
- "src/core/ext/census/gen/trace_context.pb.h",
- "src/core/ext/census/grpc_filter.h",
- "src/core/ext/census/intrusive_hash_map.h",
- "src/core/ext/census/intrusive_hash_map_internal.h",
- "src/core/ext/census/mlog.h",
- "src/core/ext/census/resource.h",
- "src/core/ext/census/rpc_metric_id.h",
- "src/core/ext/census/trace_context.h",
- "src/core/ext/census/trace_label.h",
- "src/core/ext/census/trace_propagation.h",
- "src/core/ext/census/trace_status.h",
- "src/core/ext/census/trace_string.h",
- "src/core/ext/census/tracing.h"
+ "include/grpc/census.h"
],
"is_filegroup": true,
"language": "c",
"name": "census",
"src": [
"include/grpc/census.h",
- "src/core/ext/census/aggregation.h",
- "src/core/ext/census/base_resources.c",
- "src/core/ext/census/base_resources.h",
- "src/core/ext/census/census_interface.h",
- "src/core/ext/census/census_rpc_stats.h",
- "src/core/ext/census/context.c",
- "src/core/ext/census/gen/census.pb.c",
- "src/core/ext/census/gen/census.pb.h",
- "src/core/ext/census/gen/trace_context.pb.c",
- "src/core/ext/census/gen/trace_context.pb.h",
- "src/core/ext/census/grpc_context.c",
- "src/core/ext/census/grpc_filter.c",
- "src/core/ext/census/grpc_filter.h",
- "src/core/ext/census/grpc_plugin.c",
- "src/core/ext/census/initialize.c",
- "src/core/ext/census/intrusive_hash_map.c",
- "src/core/ext/census/intrusive_hash_map.h",
- "src/core/ext/census/intrusive_hash_map_internal.h",
- "src/core/ext/census/mlog.c",
- "src/core/ext/census/mlog.h",
- "src/core/ext/census/operation.c",
- "src/core/ext/census/placeholders.c",
- "src/core/ext/census/resource.c",
- "src/core/ext/census/resource.h",
- "src/core/ext/census/rpc_metric_id.h",
- "src/core/ext/census/trace_context.c",
- "src/core/ext/census/trace_context.h",
- "src/core/ext/census/trace_label.h",
- "src/core/ext/census/trace_propagation.h",
- "src/core/ext/census/trace_status.h",
- "src/core/ext/census/trace_string.h",
- "src/core/ext/census/tracing.c",
- "src/core/ext/census/tracing.h"
+ "src/core/ext/census/grpc_context.cc"
],
"third_party": false,
"type": "filegroup"
@@ -7767,52 +7846,50 @@
"language": "c",
"name": "gpr_base",
"src": [
- "src/core/lib/profiling/basic_timers.c",
- "src/core/lib/profiling/stap_timers.c",
- "src/core/lib/support/alloc.c",
- "src/core/lib/support/arena.c",
- "src/core/lib/support/atm.c",
- "src/core/lib/support/avl.c",
- "src/core/lib/support/backoff.c",
- "src/core/lib/support/cmdline.c",
- "src/core/lib/support/cpu_iphone.c",
- "src/core/lib/support/cpu_linux.c",
- "src/core/lib/support/cpu_posix.c",
- "src/core/lib/support/cpu_windows.c",
- "src/core/lib/support/env_linux.c",
- "src/core/lib/support/env_posix.c",
- "src/core/lib/support/env_windows.c",
- "src/core/lib/support/histogram.c",
- "src/core/lib/support/host_port.c",
- "src/core/lib/support/log.c",
- "src/core/lib/support/log_android.c",
- "src/core/lib/support/log_linux.c",
- "src/core/lib/support/log_posix.c",
- "src/core/lib/support/log_windows.c",
- "src/core/lib/support/mpscq.c",
- "src/core/lib/support/murmur_hash.c",
- "src/core/lib/support/stack_lockfree.c",
- "src/core/lib/support/string.c",
- "src/core/lib/support/string_posix.c",
- "src/core/lib/support/string_util_windows.c",
- "src/core/lib/support/string_windows.c",
- "src/core/lib/support/subprocess_posix.c",
- "src/core/lib/support/subprocess_windows.c",
- "src/core/lib/support/sync.c",
- "src/core/lib/support/sync_posix.c",
- "src/core/lib/support/sync_windows.c",
- "src/core/lib/support/thd.c",
- "src/core/lib/support/thd_posix.c",
- "src/core/lib/support/thd_windows.c",
- "src/core/lib/support/time.c",
- "src/core/lib/support/time_posix.c",
- "src/core/lib/support/time_precise.c",
- "src/core/lib/support/time_windows.c",
- "src/core/lib/support/tls_pthread.c",
- "src/core/lib/support/tmpfile_msys.c",
- "src/core/lib/support/tmpfile_posix.c",
- "src/core/lib/support/tmpfile_windows.c",
- "src/core/lib/support/wrap_memcpy.c"
+ "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",
+ "src/core/lib/gpr/cpu_posix.cc",
+ "src/core/lib/gpr/cpu_windows.cc",
+ "src/core/lib/gpr/env_linux.cc",
+ "src/core/lib/gpr/env_posix.cc",
+ "src/core/lib/gpr/env_windows.cc",
+ "src/core/lib/gpr/fork.cc",
+ "src/core/lib/gpr/host_port.cc",
+ "src/core/lib/gpr/log.cc",
+ "src/core/lib/gpr/log_android.cc",
+ "src/core/lib/gpr/log_linux.cc",
+ "src/core/lib/gpr/log_posix.cc",
+ "src/core/lib/gpr/log_windows.cc",
+ "src/core/lib/gpr/mpscq.cc",
+ "src/core/lib/gpr/murmur_hash.cc",
+ "src/core/lib/gpr/string.cc",
+ "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",
+ "src/core/lib/gpr/thd.cc",
+ "src/core/lib/gpr/thd_posix.cc",
+ "src/core/lib/gpr/thd_windows.cc",
+ "src/core/lib/gpr/time.cc",
+ "src/core/lib/gpr/time_posix.cc",
+ "src/core/lib/gpr/time_precise.cc",
+ "src/core/lib/gpr/time_windows.cc",
+ "src/core/lib/gpr/tls_pthread.cc",
+ "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/wrap_memcpy.cc",
+ "src/core/lib/profiling/basic_timers.cc",
+ "src/core/lib/profiling/stap_timers.cc"
],
"third_party": false,
"type": "filegroup"
@@ -7830,7 +7907,6 @@
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
- "include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
@@ -7849,23 +7925,24 @@
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
- "src/core/lib/profiling/timers.h",
- "src/core/lib/support/arena.h",
- "src/core/lib/support/atomic.h",
- "src/core/lib/support/atomic_with_atm.h",
- "src/core/lib/support/atomic_with_std.h",
- "src/core/lib/support/backoff.h",
- "src/core/lib/support/block_annotate.h",
- "src/core/lib/support/env.h",
- "src/core/lib/support/memory.h",
- "src/core/lib/support/mpscq.h",
- "src/core/lib/support/murmur_hash.h",
- "src/core/lib/support/spinlock.h",
- "src/core/lib/support/stack_lockfree.h",
- "src/core/lib/support/string.h",
- "src/core/lib/support/string_windows.h",
- "src/core/lib/support/time_precise.h",
- "src/core/lib/support/tmpfile.h"
+ "src/core/lib/gpr/arena.h",
+ "src/core/lib/gpr/env.h",
+ "src/core/lib/gpr/fork.h",
+ "src/core/lib/gpr/mpscq.h",
+ "src/core/lib/gpr/murmur_hash.h",
+ "src/core/lib/gpr/spinlock.h",
+ "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/tmpfile.h",
+ "src/core/lib/gprpp/abstract.h",
+ "src/core/lib/gprpp/atomic.h",
+ "src/core/lib/gprpp/atomic_with_atm.h",
+ "src/core/lib/gprpp/atomic_with_std.h",
+ "src/core/lib/gprpp/manual_constructor.h",
+ "src/core/lib/gprpp/memory.h",
+ "src/core/lib/profiling/timers.h"
],
"is_filegroup": true,
"language": "c",
@@ -7879,7 +7956,6 @@
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
- "include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
@@ -7898,23 +7974,24 @@
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
- "src/core/lib/profiling/timers.h",
- "src/core/lib/support/arena.h",
- "src/core/lib/support/atomic.h",
- "src/core/lib/support/atomic_with_atm.h",
- "src/core/lib/support/atomic_with_std.h",
- "src/core/lib/support/backoff.h",
- "src/core/lib/support/block_annotate.h",
- "src/core/lib/support/env.h",
- "src/core/lib/support/memory.h",
- "src/core/lib/support/mpscq.h",
- "src/core/lib/support/murmur_hash.h",
- "src/core/lib/support/spinlock.h",
- "src/core/lib/support/stack_lockfree.h",
- "src/core/lib/support/string.h",
- "src/core/lib/support/string_windows.h",
- "src/core/lib/support/time_precise.h",
- "src/core/lib/support/tmpfile.h"
+ "src/core/lib/gpr/arena.h",
+ "src/core/lib/gpr/env.h",
+ "src/core/lib/gpr/fork.h",
+ "src/core/lib/gpr/mpscq.h",
+ "src/core/lib/gpr/murmur_hash.h",
+ "src/core/lib/gpr/spinlock.h",
+ "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/tmpfile.h",
+ "src/core/lib/gprpp/abstract.h",
+ "src/core/lib/gprpp/atomic.h",
+ "src/core/lib/gprpp/atomic_with_atm.h",
+ "src/core/lib/gprpp/atomic_with_std.h",
+ "src/core/lib/gprpp/manual_constructor.h",
+ "src/core/lib/gprpp/memory.h",
+ "src/core/lib/profiling/timers.h"
],
"third_party": false,
"type": "filegroup"
@@ -7926,6 +8003,7 @@
"include/grpc/impl/codegen/atm_gcc_atomic.h",
"include/grpc/impl/codegen/atm_gcc_sync.h",
"include/grpc/impl/codegen/atm_windows.h",
+ "include/grpc/impl/codegen/fork.h",
"include/grpc/impl/codegen/gpr_slice.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/port_platform.h",
@@ -7943,6 +8021,7 @@
"include/grpc/impl/codegen/atm_gcc_atomic.h",
"include/grpc/impl/codegen/atm_gcc_sync.h",
"include/grpc/impl/codegen/atm_windows.h",
+ "include/grpc/impl/codegen/fork.h",
"include/grpc/impl/codegen/gpr_slice.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/port_platform.h",
@@ -7997,137 +8076,141 @@
"language": "c",
"name": "grpc_base",
"src": [
- "src/core/lib/channel/channel_args.c",
- "src/core/lib/channel/channel_stack.c",
- "src/core/lib/channel/channel_stack_builder.c",
- "src/core/lib/channel/connected_channel.c",
- "src/core/lib/channel/handshaker.c",
- "src/core/lib/channel/handshaker_factory.c",
- "src/core/lib/channel/handshaker_registry.c",
- "src/core/lib/compression/compression.c",
- "src/core/lib/compression/message_compress.c",
- "src/core/lib/compression/stream_compression.c",
- "src/core/lib/compression/stream_compression_gzip.c",
- "src/core/lib/compression/stream_compression_identity.c",
- "src/core/lib/debug/stats.c",
- "src/core/lib/debug/stats_data.c",
- "src/core/lib/http/format_request.c",
- "src/core/lib/http/httpcli.c",
- "src/core/lib/http/parser.c",
- "src/core/lib/iomgr/call_combiner.c",
- "src/core/lib/iomgr/closure.c",
- "src/core/lib/iomgr/combiner.c",
- "src/core/lib/iomgr/endpoint.c",
- "src/core/lib/iomgr/endpoint_pair_posix.c",
- "src/core/lib/iomgr/endpoint_pair_uv.c",
- "src/core/lib/iomgr/endpoint_pair_windows.c",
- "src/core/lib/iomgr/error.c",
- "src/core/lib/iomgr/ev_epoll1_linux.c",
- "src/core/lib/iomgr/ev_epollex_linux.c",
- "src/core/lib/iomgr/ev_epollsig_linux.c",
- "src/core/lib/iomgr/ev_poll_posix.c",
- "src/core/lib/iomgr/ev_posix.c",
- "src/core/lib/iomgr/ev_windows.c",
- "src/core/lib/iomgr/exec_ctx.c",
- "src/core/lib/iomgr/executor.c",
- "src/core/lib/iomgr/gethostname_fallback.c",
- "src/core/lib/iomgr/gethostname_host_name_max.c",
- "src/core/lib/iomgr/gethostname_sysconf.c",
- "src/core/lib/iomgr/iocp_windows.c",
- "src/core/lib/iomgr/iomgr.c",
- "src/core/lib/iomgr/iomgr_posix.c",
- "src/core/lib/iomgr/iomgr_uv.c",
- "src/core/lib/iomgr/iomgr_windows.c",
- "src/core/lib/iomgr/is_epollexclusive_available.c",
- "src/core/lib/iomgr/load_file.c",
- "src/core/lib/iomgr/lockfree_event.c",
- "src/core/lib/iomgr/network_status_tracker.c",
- "src/core/lib/iomgr/polling_entity.c",
- "src/core/lib/iomgr/pollset_set_uv.c",
- "src/core/lib/iomgr/pollset_set_windows.c",
- "src/core/lib/iomgr/pollset_uv.c",
- "src/core/lib/iomgr/pollset_windows.c",
- "src/core/lib/iomgr/resolve_address_posix.c",
- "src/core/lib/iomgr/resolve_address_uv.c",
- "src/core/lib/iomgr/resolve_address_windows.c",
- "src/core/lib/iomgr/resource_quota.c",
- "src/core/lib/iomgr/sockaddr_utils.c",
- "src/core/lib/iomgr/socket_factory_posix.c",
- "src/core/lib/iomgr/socket_mutator.c",
- "src/core/lib/iomgr/socket_utils_common_posix.c",
- "src/core/lib/iomgr/socket_utils_linux.c",
- "src/core/lib/iomgr/socket_utils_posix.c",
- "src/core/lib/iomgr/socket_utils_uv.c",
- "src/core/lib/iomgr/socket_utils_windows.c",
- "src/core/lib/iomgr/socket_windows.c",
- "src/core/lib/iomgr/tcp_client_posix.c",
- "src/core/lib/iomgr/tcp_client_uv.c",
- "src/core/lib/iomgr/tcp_client_windows.c",
- "src/core/lib/iomgr/tcp_posix.c",
- "src/core/lib/iomgr/tcp_server_posix.c",
- "src/core/lib/iomgr/tcp_server_utils_posix_common.c",
- "src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c",
- "src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c",
- "src/core/lib/iomgr/tcp_server_uv.c",
- "src/core/lib/iomgr/tcp_server_windows.c",
- "src/core/lib/iomgr/tcp_uv.c",
- "src/core/lib/iomgr/tcp_windows.c",
- "src/core/lib/iomgr/time_averaged_stats.c",
- "src/core/lib/iomgr/timer_generic.c",
- "src/core/lib/iomgr/timer_heap.c",
- "src/core/lib/iomgr/timer_manager.c",
- "src/core/lib/iomgr/timer_uv.c",
- "src/core/lib/iomgr/udp_server.c",
- "src/core/lib/iomgr/unix_sockets_posix.c",
- "src/core/lib/iomgr/unix_sockets_posix_noop.c",
- "src/core/lib/iomgr/wakeup_fd_cv.c",
- "src/core/lib/iomgr/wakeup_fd_eventfd.c",
- "src/core/lib/iomgr/wakeup_fd_nospecial.c",
- "src/core/lib/iomgr/wakeup_fd_pipe.c",
- "src/core/lib/iomgr/wakeup_fd_posix.c",
- "src/core/lib/json/json.c",
- "src/core/lib/json/json_reader.c",
- "src/core/lib/json/json_string.c",
- "src/core/lib/json/json_writer.c",
- "src/core/lib/slice/b64.c",
- "src/core/lib/slice/percent_encoding.c",
- "src/core/lib/slice/slice.c",
- "src/core/lib/slice/slice_buffer.c",
- "src/core/lib/slice/slice_hash_table.c",
- "src/core/lib/slice/slice_intern.c",
- "src/core/lib/slice/slice_string_helpers.c",
- "src/core/lib/surface/alarm.c",
- "src/core/lib/surface/api_trace.c",
- "src/core/lib/surface/byte_buffer.c",
- "src/core/lib/surface/byte_buffer_reader.c",
- "src/core/lib/surface/call.c",
- "src/core/lib/surface/call_details.c",
- "src/core/lib/surface/call_log_batch.c",
- "src/core/lib/surface/channel.c",
- "src/core/lib/surface/channel_init.c",
- "src/core/lib/surface/channel_ping.c",
- "src/core/lib/surface/channel_stack_type.c",
- "src/core/lib/surface/completion_queue.c",
- "src/core/lib/surface/completion_queue_factory.c",
- "src/core/lib/surface/event_string.c",
+ "src/core/lib/backoff/backoff.cc",
+ "src/core/lib/channel/channel_args.cc",
+ "src/core/lib/channel/channel_stack.cc",
+ "src/core/lib/channel/channel_stack_builder.cc",
+ "src/core/lib/channel/connected_channel.cc",
+ "src/core/lib/channel/handshaker.cc",
+ "src/core/lib/channel/handshaker_factory.cc",
+ "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",
+ "src/core/lib/compression/stream_compression_identity.cc",
+ "src/core/lib/debug/stats.cc",
+ "src/core/lib/debug/stats_data.cc",
+ "src/core/lib/http/format_request.cc",
+ "src/core/lib/http/httpcli.cc",
+ "src/core/lib/http/parser.cc",
+ "src/core/lib/iomgr/call_combiner.cc",
+ "src/core/lib/iomgr/combiner.cc",
+ "src/core/lib/iomgr/endpoint.cc",
+ "src/core/lib/iomgr/endpoint_pair_posix.cc",
+ "src/core/lib/iomgr/endpoint_pair_uv.cc",
+ "src/core/lib/iomgr/endpoint_pair_windows.cc",
+ "src/core/lib/iomgr/error.cc",
+ "src/core/lib/iomgr/ev_epoll1_linux.cc",
+ "src/core/lib/iomgr/ev_epollex_linux.cc",
+ "src/core/lib/iomgr/ev_epollsig_linux.cc",
+ "src/core/lib/iomgr/ev_poll_posix.cc",
+ "src/core/lib/iomgr/ev_posix.cc",
+ "src/core/lib/iomgr/ev_windows.cc",
+ "src/core/lib/iomgr/exec_ctx.cc",
+ "src/core/lib/iomgr/executor.cc",
+ "src/core/lib/iomgr/fork_posix.cc",
+ "src/core/lib/iomgr/fork_windows.cc",
+ "src/core/lib/iomgr/gethostname_fallback.cc",
+ "src/core/lib/iomgr/gethostname_host_name_max.cc",
+ "src/core/lib/iomgr/gethostname_sysconf.cc",
+ "src/core/lib/iomgr/iocp_windows.cc",
+ "src/core/lib/iomgr/iomgr.cc",
+ "src/core/lib/iomgr/iomgr_posix.cc",
+ "src/core/lib/iomgr/iomgr_uv.cc",
+ "src/core/lib/iomgr/iomgr_windows.cc",
+ "src/core/lib/iomgr/is_epollexclusive_available.cc",
+ "src/core/lib/iomgr/load_file.cc",
+ "src/core/lib/iomgr/lockfree_event.cc",
+ "src/core/lib/iomgr/network_status_tracker.cc",
+ "src/core/lib/iomgr/polling_entity.cc",
+ "src/core/lib/iomgr/pollset_set_uv.cc",
+ "src/core/lib/iomgr/pollset_set_windows.cc",
+ "src/core/lib/iomgr/pollset_uv.cc",
+ "src/core/lib/iomgr/pollset_windows.cc",
+ "src/core/lib/iomgr/resolve_address_posix.cc",
+ "src/core/lib/iomgr/resolve_address_uv.cc",
+ "src/core/lib/iomgr/resolve_address_windows.cc",
+ "src/core/lib/iomgr/resource_quota.cc",
+ "src/core/lib/iomgr/sockaddr_utils.cc",
+ "src/core/lib/iomgr/socket_factory_posix.cc",
+ "src/core/lib/iomgr/socket_mutator.cc",
+ "src/core/lib/iomgr/socket_utils_common_posix.cc",
+ "src/core/lib/iomgr/socket_utils_linux.cc",
+ "src/core/lib/iomgr/socket_utils_posix.cc",
+ "src/core/lib/iomgr/socket_utils_uv.cc",
+ "src/core/lib/iomgr/socket_utils_windows.cc",
+ "src/core/lib/iomgr/socket_windows.cc",
+ "src/core/lib/iomgr/tcp_client_posix.cc",
+ "src/core/lib/iomgr/tcp_client_uv.cc",
+ "src/core/lib/iomgr/tcp_client_windows.cc",
+ "src/core/lib/iomgr/tcp_posix.cc",
+ "src/core/lib/iomgr/tcp_server_posix.cc",
+ "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
+ "src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc",
+ "src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc",
+ "src/core/lib/iomgr/tcp_server_uv.cc",
+ "src/core/lib/iomgr/tcp_server_windows.cc",
+ "src/core/lib/iomgr/tcp_uv.cc",
+ "src/core/lib/iomgr/tcp_windows.cc",
+ "src/core/lib/iomgr/time_averaged_stats.cc",
+ "src/core/lib/iomgr/timer_generic.cc",
+ "src/core/lib/iomgr/timer_heap.cc",
+ "src/core/lib/iomgr/timer_manager.cc",
+ "src/core/lib/iomgr/timer_uv.cc",
+ "src/core/lib/iomgr/udp_server.cc",
+ "src/core/lib/iomgr/unix_sockets_posix.cc",
+ "src/core/lib/iomgr/unix_sockets_posix_noop.cc",
+ "src/core/lib/iomgr/wakeup_fd_cv.cc",
+ "src/core/lib/iomgr/wakeup_fd_eventfd.cc",
+ "src/core/lib/iomgr/wakeup_fd_nospecial.cc",
+ "src/core/lib/iomgr/wakeup_fd_pipe.cc",
+ "src/core/lib/iomgr/wakeup_fd_posix.cc",
+ "src/core/lib/json/json.cc",
+ "src/core/lib/json/json_reader.cc",
+ "src/core/lib/json/json_string.cc",
+ "src/core/lib/json/json_writer.cc",
+ "src/core/lib/slice/b64.cc",
+ "src/core/lib/slice/percent_encoding.cc",
+ "src/core/lib/slice/slice.cc",
+ "src/core/lib/slice/slice_buffer.cc",
+ "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",
+ "src/core/lib/surface/call.cc",
+ "src/core/lib/surface/call_details.cc",
+ "src/core/lib/surface/call_log_batch.cc",
+ "src/core/lib/surface/channel.cc",
+ "src/core/lib/surface/channel_init.cc",
+ "src/core/lib/surface/channel_ping.cc",
+ "src/core/lib/surface/channel_stack_type.cc",
+ "src/core/lib/surface/completion_queue.cc",
+ "src/core/lib/surface/completion_queue_factory.cc",
+ "src/core/lib/surface/event_string.cc",
"src/core/lib/surface/lame_client.cc",
- "src/core/lib/surface/metadata_array.c",
- "src/core/lib/surface/server.c",
- "src/core/lib/surface/validate_metadata.c",
- "src/core/lib/surface/version.c",
- "src/core/lib/transport/bdp_estimator.c",
- "src/core/lib/transport/byte_stream.c",
- "src/core/lib/transport/connectivity_state.c",
- "src/core/lib/transport/error_utils.c",
- "src/core/lib/transport/metadata.c",
- "src/core/lib/transport/metadata_batch.c",
- "src/core/lib/transport/pid_controller.c",
- "src/core/lib/transport/service_config.c",
- "src/core/lib/transport/static_metadata.c",
- "src/core/lib/transport/status_conversion.c",
- "src/core/lib/transport/timeout_encoding.c",
- "src/core/lib/transport/transport.c",
- "src/core/lib/transport/transport_op_string.c"
+ "src/core/lib/surface/metadata_array.cc",
+ "src/core/lib/surface/server.cc",
+ "src/core/lib/surface/validate_metadata.cc",
+ "src/core/lib/surface/version.cc",
+ "src/core/lib/transport/bdp_estimator.cc",
+ "src/core/lib/transport/byte_stream.cc",
+ "src/core/lib/transport/connectivity_state.cc",
+ "src/core/lib/transport/error_utils.cc",
+ "src/core/lib/transport/metadata.cc",
+ "src/core/lib/transport/metadata_batch.cc",
+ "src/core/lib/transport/pid_controller.cc",
+ "src/core/lib/transport/service_config.cc",
+ "src/core/lib/transport/static_metadata.cc",
+ "src/core/lib/transport/status_conversion.cc",
+ "src/core/lib/transport/timeout_encoding.cc",
+ "src/core/lib/transport/transport.cc",
+ "src/core/lib/transport/transport_op_string.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8142,6 +8225,8 @@
"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",
"include/grpc/grpc_security_constants.h",
@@ -8150,6 +8235,7 @@
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
"include/grpc/support/workaround_list.h",
+ "src/core/lib/backoff/backoff.h",
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
"src/core/lib/channel/channel_stack_builder.h",
@@ -8159,15 +8245,22 @@
"src/core/lib/channel/handshaker_factory.h",
"src/core/lib/channel/handshaker_registry.h",
"src/core/lib/compression/algorithm_metadata.h",
+ "src/core/lib/compression/compression_internal.h",
"src/core/lib/compression/message_compress.h",
"src/core/lib/compression/stream_compression.h",
"src/core/lib/compression/stream_compression_gzip.h",
"src/core/lib/compression/stream_compression_identity.h",
"src/core/lib/debug/stats.h",
"src/core/lib/debug/stats_data.h",
+ "src/core/lib/gprpp/debug_location.h",
+ "src/core/lib/gprpp/inlined_vector.h",
+ "src/core/lib/gprpp/orphanable.h",
+ "src/core/lib/gprpp/ref_counted.h",
+ "src/core/lib/gprpp/ref_counted_ptr.h",
"src/core/lib/http/format_request.h",
"src/core/lib/http/httpcli.h",
"src/core/lib/http/parser.h",
+ "src/core/lib/iomgr/block_annotate.h",
"src/core/lib/iomgr/call_combiner.h",
"src/core/lib/iomgr/closure.h",
"src/core/lib/iomgr/combiner.h",
@@ -8275,6 +8368,8 @@
"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",
"include/grpc/grpc_security_constants.h",
@@ -8283,6 +8378,7 @@
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
"include/grpc/support/workaround_list.h",
+ "src/core/lib/backoff/backoff.h",
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
"src/core/lib/channel/channel_stack_builder.h",
@@ -8292,15 +8388,22 @@
"src/core/lib/channel/handshaker_factory.h",
"src/core/lib/channel/handshaker_registry.h",
"src/core/lib/compression/algorithm_metadata.h",
+ "src/core/lib/compression/compression_internal.h",
"src/core/lib/compression/message_compress.h",
"src/core/lib/compression/stream_compression.h",
"src/core/lib/compression/stream_compression_gzip.h",
"src/core/lib/compression/stream_compression_identity.h",
"src/core/lib/debug/stats.h",
"src/core/lib/debug/stats_data.h",
+ "src/core/lib/gprpp/debug_location.h",
+ "src/core/lib/gprpp/inlined_vector.h",
+ "src/core/lib/gprpp/orphanable.h",
+ "src/core/lib/gprpp/ref_counted.h",
+ "src/core/lib/gprpp/ref_counted_ptr.h",
"src/core/lib/http/format_request.h",
"src/core/lib/http/httpcli.h",
"src/core/lib/http/parser.h",
+ "src/core/lib/iomgr/block_annotate.h",
"src/core/lib/iomgr/call_combiner.h",
"src/core/lib/iomgr/closure.h",
"src/core/lib/iomgr/combiner.h",
@@ -8411,6 +8514,7 @@
"grpc_deadline_filter"
],
"headers": [
+ "src/core/ext/filters/client_channel/backup_poller.h",
"src/core/ext/filters/client_channel/client_channel.h",
"src/core/ext/filters/client_channel/client_channel_factory.h",
"src/core/ext/filters/client_channel/connector.h",
@@ -8434,43 +8538,45 @@
"language": "c",
"name": "grpc_client_channel",
"src": [
- "src/core/ext/filters/client_channel/channel_connectivity.c",
- "src/core/ext/filters/client_channel/client_channel.c",
+ "src/core/ext/filters/client_channel/backup_poller.cc",
+ "src/core/ext/filters/client_channel/backup_poller.h",
+ "src/core/ext/filters/client_channel/channel_connectivity.cc",
+ "src/core/ext/filters/client_channel/client_channel.cc",
"src/core/ext/filters/client_channel/client_channel.h",
- "src/core/ext/filters/client_channel/client_channel_factory.c",
+ "src/core/ext/filters/client_channel/client_channel_factory.cc",
"src/core/ext/filters/client_channel/client_channel_factory.h",
- "src/core/ext/filters/client_channel/client_channel_plugin.c",
- "src/core/ext/filters/client_channel/connector.c",
+ "src/core/ext/filters/client_channel/client_channel_plugin.cc",
+ "src/core/ext/filters/client_channel/connector.cc",
"src/core/ext/filters/client_channel/connector.h",
- "src/core/ext/filters/client_channel/http_connect_handshaker.c",
+ "src/core/ext/filters/client_channel/http_connect_handshaker.cc",
"src/core/ext/filters/client_channel/http_connect_handshaker.h",
- "src/core/ext/filters/client_channel/http_proxy.c",
+ "src/core/ext/filters/client_channel/http_proxy.cc",
"src/core/ext/filters/client_channel/http_proxy.h",
- "src/core/ext/filters/client_channel/lb_policy.c",
+ "src/core/ext/filters/client_channel/lb_policy.cc",
"src/core/ext/filters/client_channel/lb_policy.h",
- "src/core/ext/filters/client_channel/lb_policy_factory.c",
+ "src/core/ext/filters/client_channel/lb_policy_factory.cc",
"src/core/ext/filters/client_channel/lb_policy_factory.h",
- "src/core/ext/filters/client_channel/lb_policy_registry.c",
+ "src/core/ext/filters/client_channel/lb_policy_registry.cc",
"src/core/ext/filters/client_channel/lb_policy_registry.h",
- "src/core/ext/filters/client_channel/parse_address.c",
+ "src/core/ext/filters/client_channel/parse_address.cc",
"src/core/ext/filters/client_channel/parse_address.h",
- "src/core/ext/filters/client_channel/proxy_mapper.c",
+ "src/core/ext/filters/client_channel/proxy_mapper.cc",
"src/core/ext/filters/client_channel/proxy_mapper.h",
- "src/core/ext/filters/client_channel/proxy_mapper_registry.c",
+ "src/core/ext/filters/client_channel/proxy_mapper_registry.cc",
"src/core/ext/filters/client_channel/proxy_mapper_registry.h",
- "src/core/ext/filters/client_channel/resolver.c",
+ "src/core/ext/filters/client_channel/resolver.cc",
"src/core/ext/filters/client_channel/resolver.h",
- "src/core/ext/filters/client_channel/resolver_factory.c",
+ "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.c",
+ "src/core/ext/filters/client_channel/resolver_registry.cc",
"src/core/ext/filters/client_channel/resolver_registry.h",
- "src/core/ext/filters/client_channel/retry_throttle.c",
+ "src/core/ext/filters/client_channel/retry_throttle.cc",
"src/core/ext/filters/client_channel/retry_throttle.h",
- "src/core/ext/filters/client_channel/subchannel.c",
+ "src/core/ext/filters/client_channel/subchannel.cc",
"src/core/ext/filters/client_channel/subchannel.h",
- "src/core/ext/filters/client_channel/subchannel_index.c",
+ "src/core/ext/filters/client_channel/subchannel_index.cc",
"src/core/ext/filters/client_channel/subchannel_index.h",
- "src/core/ext/filters/client_channel/uri_parser.c",
+ "src/core/ext/filters/client_channel/uri_parser.cc",
"src/core/ext/filters/client_channel/uri_parser.h"
],
"third_party": false,
@@ -8485,7 +8591,6 @@
"include/grpc/impl/codegen/byte_buffer_reader.h",
"include/grpc/impl/codegen/compression_types.h",
"include/grpc/impl/codegen/connectivity_state.h",
- "include/grpc/impl/codegen/exec_ctx_fwd.h",
"include/grpc/impl/codegen/grpc_types.h",
"include/grpc/impl/codegen/propagation_bits.h",
"include/grpc/impl/codegen/slice.h",
@@ -8499,7 +8604,6 @@
"include/grpc/impl/codegen/byte_buffer_reader.h",
"include/grpc/impl/codegen/compression_types.h",
"include/grpc/impl/codegen/connectivity_state.h",
- "include/grpc/impl/codegen/exec_ctx_fwd.h",
"include/grpc/impl/codegen/grpc_types.h",
"include/grpc/impl/codegen/propagation_bits.h",
"include/grpc/impl/codegen/slice.h",
@@ -8520,7 +8624,7 @@
"language": "c",
"name": "grpc_deadline_filter",
"src": [
- "src/core/ext/filters/deadline/deadline_filter.c",
+ "src/core/ext/filters/deadline/deadline_filter.cc",
"src/core/ext/filters/deadline/deadline_filter.h"
],
"third_party": false,
@@ -8540,12 +8644,12 @@
"language": "c",
"name": "grpc_http_filters",
"src": [
- "src/core/ext/filters/http/client/http_client_filter.c",
+ "src/core/ext/filters/http/client/http_client_filter.cc",
"src/core/ext/filters/http/client/http_client_filter.h",
- "src/core/ext/filters/http/http_filters_plugin.c",
- "src/core/ext/filters/http/message_compress/message_compress_filter.c",
+ "src/core/ext/filters/http/http_filters_plugin.cc",
+ "src/core/ext/filters/http/message_compress/message_compress_filter.cc",
"src/core/ext/filters/http/message_compress/message_compress_filter.h",
- "src/core/ext/filters/http/server/http_server_filter.c",
+ "src/core/ext/filters/http/server/http_server_filter.cc",
"src/core/ext/filters/http/server/http_server_filter.h"
],
"third_party": false,
@@ -8571,15 +8675,15 @@
"language": "c",
"name": "grpc_lb_policy_grpclb",
"src": [
- "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
@@ -8608,15 +8712,15 @@
"language": "c",
"name": "grpc_lb_policy_grpclb_secure",
"src": [
- "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h",
- "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c",
+ "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc",
"src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
@@ -8628,14 +8732,15 @@
"deps": [
"gpr",
"grpc_base",
- "grpc_client_channel"
+ "grpc_client_channel",
+ "grpc_lb_subchannel_list"
],
"headers": [],
"is_filegroup": true,
"language": "c",
"name": "grpc_lb_policy_pick_first",
"src": [
- "src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c"
+ "src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8644,14 +8749,34 @@
"deps": [
"gpr",
"grpc_base",
- "grpc_client_channel"
+ "grpc_client_channel",
+ "grpc_lb_subchannel_list"
],
"headers": [],
"is_filegroup": true,
"language": "c",
"name": "grpc_lb_policy_round_robin",
"src": [
- "src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c"
+ "src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc"
+ ],
+ "third_party": false,
+ "type": "filegroup"
+ },
+ {
+ "deps": [
+ "gpr",
+ "grpc_base",
+ "grpc_client_channel"
+ ],
+ "headers": [
+ "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
+ ],
+ "is_filegroup": true,
+ "language": "c",
+ "name": "grpc_lb_subchannel_list",
+ "src": [
+ "src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc",
+ "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
],
"third_party": false,
"type": "filegroup"
@@ -8668,7 +8793,7 @@
"language": "c",
"name": "grpc_max_age_filter",
"src": [
- "src/core/ext/filters/max_age/max_age_filter.c",
+ "src/core/ext/filters/max_age/max_age_filter.cc",
"src/core/ext/filters/max_age/max_age_filter.h"
],
"third_party": false,
@@ -8686,7 +8811,7 @@
"language": "c",
"name": "grpc_message_size_filter",
"src": [
- "src/core/ext/filters/message_size/message_size_filter.c",
+ "src/core/ext/filters/message_size/message_size_filter.cc",
"src/core/ext/filters/message_size/message_size_filter.h"
],
"third_party": false,
@@ -8706,12 +8831,12 @@
"language": "c",
"name": "grpc_resolver_dns_ares",
"src": [
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h",
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c",
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc",
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h",
- "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c"
+ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8727,7 +8852,7 @@
"language": "c",
"name": "grpc_resolver_dns_native",
"src": [
- "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c"
+ "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8745,7 +8870,7 @@
"language": "c",
"name": "grpc_resolver_fake",
"src": [
- "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c",
+ "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc",
"src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
],
"third_party": false,
@@ -8762,7 +8887,7 @@
"language": "c",
"name": "grpc_resolver_sockaddr",
"src": [
- "src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c"
+ "src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8801,49 +8926,49 @@
"name": "grpc_secure",
"src": [
"include/grpc/grpc_security.h",
- "src/core/lib/http/httpcli_security_connector.c",
- "src/core/lib/security/context/security_context.c",
+ "src/core/lib/http/httpcli_security_connector.cc",
+ "src/core/lib/security/context/security_context.cc",
"src/core/lib/security/context/security_context.h",
- "src/core/lib/security/credentials/composite/composite_credentials.c",
+ "src/core/lib/security/credentials/composite/composite_credentials.cc",
"src/core/lib/security/credentials/composite/composite_credentials.h",
- "src/core/lib/security/credentials/credentials.c",
+ "src/core/lib/security/credentials/credentials.cc",
"src/core/lib/security/credentials/credentials.h",
- "src/core/lib/security/credentials/credentials_metadata.c",
- "src/core/lib/security/credentials/fake/fake_credentials.c",
+ "src/core/lib/security/credentials/credentials_metadata.cc",
+ "src/core/lib/security/credentials/fake/fake_credentials.cc",
"src/core/lib/security/credentials/fake/fake_credentials.h",
- "src/core/lib/security/credentials/google_default/credentials_generic.c",
- "src/core/lib/security/credentials/google_default/google_default_credentials.c",
+ "src/core/lib/security/credentials/google_default/credentials_generic.cc",
+ "src/core/lib/security/credentials/google_default/google_default_credentials.cc",
"src/core/lib/security/credentials/google_default/google_default_credentials.h",
- "src/core/lib/security/credentials/iam/iam_credentials.c",
+ "src/core/lib/security/credentials/iam/iam_credentials.cc",
"src/core/lib/security/credentials/iam/iam_credentials.h",
- "src/core/lib/security/credentials/jwt/json_token.c",
+ "src/core/lib/security/credentials/jwt/json_token.cc",
"src/core/lib/security/credentials/jwt/json_token.h",
- "src/core/lib/security/credentials/jwt/jwt_credentials.c",
+ "src/core/lib/security/credentials/jwt/jwt_credentials.cc",
"src/core/lib/security/credentials/jwt/jwt_credentials.h",
- "src/core/lib/security/credentials/jwt/jwt_verifier.c",
+ "src/core/lib/security/credentials/jwt/jwt_verifier.cc",
"src/core/lib/security/credentials/jwt/jwt_verifier.h",
- "src/core/lib/security/credentials/oauth2/oauth2_credentials.c",
+ "src/core/lib/security/credentials/oauth2/oauth2_credentials.cc",
"src/core/lib/security/credentials/oauth2/oauth2_credentials.h",
- "src/core/lib/security/credentials/plugin/plugin_credentials.c",
+ "src/core/lib/security/credentials/plugin/plugin_credentials.cc",
"src/core/lib/security/credentials/plugin/plugin_credentials.h",
- "src/core/lib/security/credentials/ssl/ssl_credentials.c",
+ "src/core/lib/security/credentials/ssl/ssl_credentials.cc",
"src/core/lib/security/credentials/ssl/ssl_credentials.h",
"src/core/lib/security/transport/auth_filters.h",
- "src/core/lib/security/transport/client_auth_filter.c",
- "src/core/lib/security/transport/lb_targets_info.c",
+ "src/core/lib/security/transport/client_auth_filter.cc",
+ "src/core/lib/security/transport/lb_targets_info.cc",
"src/core/lib/security/transport/lb_targets_info.h",
- "src/core/lib/security/transport/secure_endpoint.c",
+ "src/core/lib/security/transport/secure_endpoint.cc",
"src/core/lib/security/transport/secure_endpoint.h",
- "src/core/lib/security/transport/security_connector.c",
+ "src/core/lib/security/transport/security_connector.cc",
"src/core/lib/security/transport/security_connector.h",
- "src/core/lib/security/transport/security_handshaker.c",
+ "src/core/lib/security/transport/security_handshaker.cc",
"src/core/lib/security/transport/security_handshaker.h",
- "src/core/lib/security/transport/server_auth_filter.c",
- "src/core/lib/security/transport/tsi_error.c",
+ "src/core/lib/security/transport/server_auth_filter.cc",
+ "src/core/lib/security/transport/tsi_error.cc",
"src/core/lib/security/transport/tsi_error.h",
- "src/core/lib/security/util/json_util.c",
+ "src/core/lib/security/util/json_util.cc",
"src/core/lib/security/util/json_util.h",
- "src/core/lib/surface/init_secure.c"
+ "src/core/lib/surface/init_secure.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8860,7 +8985,7 @@
"language": "c",
"name": "grpc_server_backward_compatibility",
"src": [
- "src/core/ext/filters/workarounds/workaround_utils.c",
+ "src/core/ext/filters/workarounds/workaround_utils.cc",
"src/core/ext/filters/workarounds/workaround_utils.h"
],
"third_party": false,
@@ -8879,9 +9004,9 @@
"language": "c",
"name": "grpc_server_load_reporting",
"src": [
- "src/core/ext/filters/load_reporting/server_load_reporting_filter.c",
+ "src/core/ext/filters/load_reporting/server_load_reporting_filter.cc",
"src/core/ext/filters/load_reporting/server_load_reporting_filter.h",
- "src/core/ext/filters/load_reporting/server_load_reporting_plugin.c",
+ "src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc",
"src/core/ext/filters/load_reporting/server_load_reporting_plugin.h"
],
"third_party": false,
@@ -8903,6 +9028,7 @@
"test/core/iomgr/endpoint_tests.h",
"test/core/util/debugger_macros.h",
"test/core/util/grpc_profiler.h",
+ "test/core/util/histogram.h",
"test/core/util/memory_counters.h",
"test/core/util/mock_endpoint.h",
"test/core/util/parse_hexstring.h",
@@ -8910,41 +9036,47 @@
"test/core/util/port.h",
"test/core/util/port_server_client.h",
"test/core/util/slice_splitter.h",
+ "test/core/util/tracer_util.h",
"test/core/util/trickle_endpoint.h"
],
"is_filegroup": true,
"language": "c",
"name": "grpc_test_util_base",
"src": [
- "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c",
+ "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc",
"src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h",
- "test/core/end2end/cq_verifier.c",
+ "test/core/end2end/cq_verifier.cc",
"test/core/end2end/cq_verifier.h",
- "test/core/end2end/fixtures/http_proxy_fixture.c",
+ "test/core/end2end/fixtures/http_proxy_fixture.cc",
"test/core/end2end/fixtures/http_proxy_fixture.h",
- "test/core/end2end/fixtures/proxy.c",
+ "test/core/end2end/fixtures/proxy.cc",
"test/core/end2end/fixtures/proxy.h",
- "test/core/iomgr/endpoint_tests.c",
+ "test/core/iomgr/endpoint_tests.cc",
"test/core/iomgr/endpoint_tests.h",
- "test/core/util/debugger_macros.c",
+ "test/core/util/debugger_macros.cc",
"test/core/util/debugger_macros.h",
- "test/core/util/grpc_profiler.c",
+ "test/core/util/grpc_profiler.cc",
"test/core/util/grpc_profiler.h",
- "test/core/util/memory_counters.c",
+ "test/core/util/histogram.cc",
+ "test/core/util/histogram.h",
+ "test/core/util/memory_counters.cc",
"test/core/util/memory_counters.h",
- "test/core/util/mock_endpoint.c",
+ "test/core/util/mock_endpoint.cc",
"test/core/util/mock_endpoint.h",
- "test/core/util/parse_hexstring.c",
+ "test/core/util/parse_hexstring.cc",
"test/core/util/parse_hexstring.h",
- "test/core/util/passthru_endpoint.c",
+ "test/core/util/passthru_endpoint.cc",
"test/core/util/passthru_endpoint.h",
- "test/core/util/port.c",
+ "test/core/util/port.cc",
"test/core/util/port.h",
- "test/core/util/port_server_client.c",
+ "test/core/util/port_isolated_runtime_environment.cc",
+ "test/core/util/port_server_client.cc",
"test/core/util/port_server_client.h",
- "test/core/util/slice_splitter.c",
+ "test/core/util/slice_splitter.cc",
"test/core/util/slice_splitter.h",
- "test/core/util/trickle_endpoint.c",
+ "test/core/util/tracer_util.cc",
+ "test/core/util/tracer_util.h",
+ "test/core/util/trickle_endpoint.cc",
"test/core/util/trickle_endpoint.h"
],
"third_party": false,
@@ -8953,6 +9085,7 @@
{
"deps": [
"gpr",
+ "grpc_base_headers",
"grpc_trace_headers"
],
"headers": [],
@@ -8960,7 +9093,7 @@
"language": "c",
"name": "grpc_trace",
"src": [
- "src/core/lib/debug/trace.c"
+ "src/core/lib/debug/trace.cc"
],
"third_party": false,
"type": "filegroup"
@@ -8992,6 +9125,7 @@
"src/core/ext/transport/chttp2/transport/bin_decoder.h",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
+ "src/core/ext/transport/chttp2/transport/flow_control.h",
"src/core/ext/transport/chttp2/transport/frame.h",
"src/core/ext/transport/chttp2/transport/frame_data.h",
"src/core/ext/transport/chttp2/transport/frame_goaway.h",
@@ -9013,47 +9147,48 @@
"language": "c",
"name": "grpc_transport_chttp2",
"src": [
- "src/core/ext/transport/chttp2/transport/bin_decoder.c",
+ "src/core/ext/transport/chttp2/transport/bin_decoder.cc",
"src/core/ext/transport/chttp2/transport/bin_decoder.h",
- "src/core/ext/transport/chttp2/transport/bin_encoder.c",
+ "src/core/ext/transport/chttp2/transport/bin_encoder.cc",
"src/core/ext/transport/chttp2/transport/bin_encoder.h",
- "src/core/ext/transport/chttp2/transport/chttp2_plugin.c",
- "src/core/ext/transport/chttp2/transport/chttp2_transport.c",
+ "src/core/ext/transport/chttp2/transport/chttp2_plugin.cc",
+ "src/core/ext/transport/chttp2/transport/chttp2_transport.cc",
"src/core/ext/transport/chttp2/transport/chttp2_transport.h",
- "src/core/ext/transport/chttp2/transport/flow_control.c",
+ "src/core/ext/transport/chttp2/transport/flow_control.cc",
+ "src/core/ext/transport/chttp2/transport/flow_control.h",
"src/core/ext/transport/chttp2/transport/frame.h",
- "src/core/ext/transport/chttp2/transport/frame_data.c",
+ "src/core/ext/transport/chttp2/transport/frame_data.cc",
"src/core/ext/transport/chttp2/transport/frame_data.h",
- "src/core/ext/transport/chttp2/transport/frame_goaway.c",
+ "src/core/ext/transport/chttp2/transport/frame_goaway.cc",
"src/core/ext/transport/chttp2/transport/frame_goaway.h",
- "src/core/ext/transport/chttp2/transport/frame_ping.c",
+ "src/core/ext/transport/chttp2/transport/frame_ping.cc",
"src/core/ext/transport/chttp2/transport/frame_ping.h",
- "src/core/ext/transport/chttp2/transport/frame_rst_stream.c",
+ "src/core/ext/transport/chttp2/transport/frame_rst_stream.cc",
"src/core/ext/transport/chttp2/transport/frame_rst_stream.h",
- "src/core/ext/transport/chttp2/transport/frame_settings.c",
+ "src/core/ext/transport/chttp2/transport/frame_settings.cc",
"src/core/ext/transport/chttp2/transport/frame_settings.h",
- "src/core/ext/transport/chttp2/transport/frame_window_update.c",
+ "src/core/ext/transport/chttp2/transport/frame_window_update.cc",
"src/core/ext/transport/chttp2/transport/frame_window_update.h",
- "src/core/ext/transport/chttp2/transport/hpack_encoder.c",
+ "src/core/ext/transport/chttp2/transport/hpack_encoder.cc",
"src/core/ext/transport/chttp2/transport/hpack_encoder.h",
- "src/core/ext/transport/chttp2/transport/hpack_parser.c",
+ "src/core/ext/transport/chttp2/transport/hpack_parser.cc",
"src/core/ext/transport/chttp2/transport/hpack_parser.h",
- "src/core/ext/transport/chttp2/transport/hpack_table.c",
+ "src/core/ext/transport/chttp2/transport/hpack_table.cc",
"src/core/ext/transport/chttp2/transport/hpack_table.h",
- "src/core/ext/transport/chttp2/transport/http2_settings.c",
+ "src/core/ext/transport/chttp2/transport/http2_settings.cc",
"src/core/ext/transport/chttp2/transport/http2_settings.h",
- "src/core/ext/transport/chttp2/transport/huffsyms.c",
+ "src/core/ext/transport/chttp2/transport/huffsyms.cc",
"src/core/ext/transport/chttp2/transport/huffsyms.h",
- "src/core/ext/transport/chttp2/transport/incoming_metadata.c",
+ "src/core/ext/transport/chttp2/transport/incoming_metadata.cc",
"src/core/ext/transport/chttp2/transport/incoming_metadata.h",
"src/core/ext/transport/chttp2/transport/internal.h",
- "src/core/ext/transport/chttp2/transport/parsing.c",
- "src/core/ext/transport/chttp2/transport/stream_lists.c",
- "src/core/ext/transport/chttp2/transport/stream_map.c",
+ "src/core/ext/transport/chttp2/transport/parsing.cc",
+ "src/core/ext/transport/chttp2/transport/stream_lists.cc",
+ "src/core/ext/transport/chttp2/transport/stream_map.cc",
"src/core/ext/transport/chttp2/transport/stream_map.h",
- "src/core/ext/transport/chttp2/transport/varint.c",
+ "src/core/ext/transport/chttp2/transport/varint.cc",
"src/core/ext/transport/chttp2/transport/varint.h",
- "src/core/ext/transport/chttp2/transport/writing.c"
+ "src/core/ext/transport/chttp2/transport/writing.cc"
],
"third_party": false,
"type": "filegroup"
@@ -9069,7 +9204,7 @@
"language": "c",
"name": "grpc_transport_chttp2_alpn",
"src": [
- "src/core/ext/transport/chttp2/alpn/alpn.c",
+ "src/core/ext/transport/chttp2/alpn/alpn.cc",
"src/core/ext/transport/chttp2/alpn/alpn.h"
],
"third_party": false,
@@ -9089,7 +9224,7 @@
"language": "c",
"name": "grpc_transport_chttp2_client_connector",
"src": [
- "src/core/ext/transport/chttp2/client/chttp2_connector.c",
+ "src/core/ext/transport/chttp2/client/chttp2_connector.cc",
"src/core/ext/transport/chttp2/client/chttp2_connector.h"
],
"third_party": false,
@@ -9108,8 +9243,8 @@
"language": "c",
"name": "grpc_transport_chttp2_client_insecure",
"src": [
- "src/core/ext/transport/chttp2/client/insecure/channel_create.c",
- "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c"
+ "src/core/ext/transport/chttp2/client/insecure/channel_create.cc",
+ "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc"
],
"third_party": false,
"type": "filegroup"
@@ -9128,7 +9263,7 @@
"language": "c",
"name": "grpc_transport_chttp2_client_secure",
"src": [
- "src/core/ext/transport/chttp2/client/secure/secure_channel_create.c"
+ "src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc"
],
"third_party": false,
"type": "filegroup"
@@ -9146,7 +9281,7 @@
"language": "c",
"name": "grpc_transport_chttp2_server",
"src": [
- "src/core/ext/transport/chttp2/server/chttp2_server.c",
+ "src/core/ext/transport/chttp2/server/chttp2_server.cc",
"src/core/ext/transport/chttp2/server/chttp2_server.h"
],
"third_party": false,
@@ -9164,8 +9299,8 @@
"language": "c",
"name": "grpc_transport_chttp2_server_insecure",
"src": [
- "src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
- "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c"
+ "src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc",
+ "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc"
],
"third_party": false,
"type": "filegroup"
@@ -9183,7 +9318,7 @@
"language": "c",
"name": "grpc_transport_chttp2_server_secure",
"src": [
- "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c"
+ "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc"
],
"third_party": false,
"type": "filegroup"
@@ -9208,9 +9343,9 @@
"include/grpc/grpc_cronet.h",
"include/grpc/grpc_security.h",
"include/grpc/grpc_security_constants.h",
- "src/core/ext/transport/cronet/client/secure/cronet_channel_create.c",
- "src/core/ext/transport/cronet/transport/cronet_api_dummy.c",
- "src/core/ext/transport/cronet/transport/cronet_transport.c",
+ "src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc",
+ "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc",
+ "src/core/ext/transport/cronet/transport/cronet_transport.cc",
"src/core/ext/transport/cronet/transport/cronet_transport.h"
],
"third_party": false,
@@ -9227,8 +9362,8 @@
"language": "c",
"name": "grpc_transport_inproc",
"src": [
- "src/core/ext/transport/inproc/inproc_plugin.c",
- "src/core/ext/transport/inproc/inproc_transport.c"
+ "src/core/ext/transport/inproc/inproc_plugin.cc",
+ "src/core/ext/transport/inproc/inproc_transport.cc"
],
"third_party": false,
"type": "filegroup"
@@ -9263,7 +9398,7 @@
"language": "c",
"name": "grpc_workaround_cronet_compression_filter",
"src": [
- "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c",
+ "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc",
"src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h"
],
"third_party": false,
@@ -9307,7 +9442,7 @@
"language": "c",
"name": "transport_security_test_lib",
"src": [
- "test/core/tsi/transport_security_test_lib.c",
+ "test/core/tsi/transport_security_test_lib.cc",
"test/core/tsi/transport_security_test_lib.h"
],
"third_party": false,
@@ -9321,8 +9456,8 @@
"tsi_interface"
],
"headers": [
+ "src/core/tsi/alts_transport_security.h",
"src/core/tsi/fake_transport_security.h",
- "src/core/tsi/gts_transport_security.h",
"src/core/tsi/ssl_transport_security.h",
"src/core/tsi/ssl_types.h",
"src/core/tsi/transport_security_grpc.h"
@@ -9331,14 +9466,14 @@
"language": "c",
"name": "tsi",
"src": [
- "src/core/tsi/fake_transport_security.c",
+ "src/core/tsi/alts_transport_security.cc",
+ "src/core/tsi/alts_transport_security.h",
+ "src/core/tsi/fake_transport_security.cc",
"src/core/tsi/fake_transport_security.h",
- "src/core/tsi/gts_transport_security.c",
- "src/core/tsi/gts_transport_security.h",
- "src/core/tsi/ssl_transport_security.c",
+ "src/core/tsi/ssl_transport_security.cc",
"src/core/tsi/ssl_transport_security.h",
"src/core/tsi/ssl_types.h",
- "src/core/tsi/transport_security_grpc.c",
+ "src/core/tsi/transport_security_grpc.cc",
"src/core/tsi/transport_security_grpc.h"
],
"third_party": false,
@@ -9358,9 +9493,9 @@
"language": "c",
"name": "tsi_interface",
"src": [
- "src/core/tsi/transport_security.c",
+ "src/core/tsi/transport_security.cc",
"src/core/tsi/transport_security.h",
- "src/core/tsi/transport_security_adapter.c",
+ "src/core/tsi/transport_security_adapter.cc",
"src/core/tsi/transport_security_adapter.h",
"src/core/tsi/transport_security_interface.h"
],
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 72dfbc0b98..866e2c3280 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -3,6 +3,7 @@
[
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -21,10 +22,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -43,10 +46,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -65,10 +70,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -87,10 +94,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -109,10 +118,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -133,32 +144,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "bdp_estimator_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -177,54 +168,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "bin_encoder_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "byte_stream_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -237,38 +186,18 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "census_context_test",
+ "name": "bin_encoder_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "census_intrusive_hash_map_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -281,38 +210,18 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "census_resource_test",
+ "name": "byte_stream_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "census_trace_context_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -331,10 +240,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -353,10 +264,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -375,10 +288,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -397,10 +312,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -419,10 +336,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -441,10 +360,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -465,10 +386,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -487,10 +410,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -511,10 +436,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -533,10 +460,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -555,10 +484,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -579,10 +510,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -601,10 +534,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -619,10 +554,12 @@
"name": "ev_epollsig_linux_test",
"platforms": [
"linux"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -641,10 +578,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -661,10 +600,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -683,10 +624,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -705,10 +648,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -725,10 +670,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -745,10 +692,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -767,10 +716,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -789,32 +740,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "gpr_backoff_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -833,10 +764,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -855,10 +788,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -877,10 +812,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -893,16 +830,18 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "gpr_histogram_test",
+ "name": "gpr_host_port_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -915,38 +854,42 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "gpr_host_port_test",
+ "name": "gpr_log_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
- "cpu_cost": 1.0,
+ "cpu_cost": 3,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
- "name": "gpr_log_test",
+ "name": "gpr_manual_constructor_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -965,10 +908,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -987,32 +932,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 7,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "gpr_stack_lockfree_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1031,10 +956,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1053,10 +980,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1075,10 +1004,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1097,10 +1028,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1119,10 +1052,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1141,10 +1076,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1163,10 +1100,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1185,10 +1124,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1207,10 +1148,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1229,10 +1172,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1251,10 +1196,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1273,10 +1220,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1295,10 +1244,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1319,10 +1270,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1341,10 +1294,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1363,10 +1318,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1383,10 +1340,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1405,10 +1364,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1427,10 +1388,36 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "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": "grpc_ssl_credentials_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1445,10 +1432,12 @@
"name": "handshake_client",
"platforms": [
"linux"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1463,10 +1452,56 @@
"name": "handshake_server",
"platforms": [
"linux"
- ]
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "gtest": false,
+ "language": "c",
+ "name": "handshake_server_with_readahead_handshaker",
+ "platforms": [
+ "linux"
+ ],
+ "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": "histogram_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1485,10 +1520,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1507,10 +1544,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1529,10 +1568,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1551,10 +1592,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1571,10 +1614,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1587,10 +1632,12 @@
"name": "httpscli_test",
"platforms": [
"linux"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1609,10 +1656,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1631,10 +1680,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1653,10 +1704,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1675,10 +1728,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1697,10 +1752,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1719,10 +1776,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1741,10 +1800,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1761,10 +1822,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1783,10 +1846,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1805,32 +1870,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": true,
- "gtest": false,
- "language": "c",
- "name": "mlog_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1849,10 +1894,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1871,10 +1918,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1893,10 +1942,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1917,10 +1968,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1939,10 +1992,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1961,10 +2016,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1979,10 +2036,12 @@
"name": "pollset_set_test",
"platforms": [
"linux"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2001,10 +2060,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2023,10 +2084,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2045,10 +2108,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2067,10 +2132,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2091,10 +2158,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2115,10 +2184,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2137,10 +2208,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2159,10 +2232,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2181,10 +2256,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2203,10 +2280,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2225,10 +2304,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2247,10 +2328,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2269,10 +2352,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2291,10 +2376,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2313,10 +2400,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2333,10 +2422,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2355,10 +2446,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2377,10 +2470,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2399,10 +2494,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2421,10 +2518,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2445,10 +2544,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2467,10 +2568,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2489,10 +2592,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2513,10 +2618,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2535,10 +2642,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2557,10 +2666,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2581,10 +2692,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2605,10 +2718,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2627,10 +2742,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2649,32 +2766,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "transport_pid_controller_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2691,10 +2788,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2713,10 +2812,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2735,10 +2836,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2757,10 +2860,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2779,10 +2884,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2801,10 +2908,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2823,12 +2932,60 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
- "args": [
- "--benchmark_min_time=0"
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": false,
+ "language": "c++",
+ "name": "backoff_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "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": "bdp_estimator_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
],
+ "uses_polling": false
+ },
+ {
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2845,12 +3002,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": false
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2867,12 +3024,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": false
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2889,12 +3046,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": false
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2911,12 +3068,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2933,12 +3090,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2955,12 +3112,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=4"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2977,12 +3134,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2999,12 +3156,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": false
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3026,12 +3183,12 @@
"mac",
"posix"
],
- "timeout_seconds": 1200
+ "timeout_seconds": 1200,
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3053,19 +3210,21 @@
"mac",
"posix"
],
- "timeout_seconds": 1200
+ "timeout_seconds": 1200,
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
- "exclude_configs": [],
+ "exclude_configs": [
+ "tsan"
+ ],
"exclude_iomgrs": [],
"excluded_poll_engines": [
"poll",
@@ -3080,12 +3239,12 @@
"mac",
"posix"
],
- "timeout_seconds": 1200
+ "timeout_seconds": 1200,
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3107,12 +3266,12 @@
"mac",
"posix"
],
- "timeout_seconds": 1200
+ "timeout_seconds": 1200,
+ "uses_polling": true
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3129,12 +3288,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": false
},
{
- "args": [
- "--benchmark_min_time=0"
- ],
+ "args": [],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3151,10 +3310,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3173,10 +3334,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3195,10 +3358,36 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "chttp2_settings_timeout_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3217,10 +3406,36 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "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": "client_channel_stress_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3237,10 +3452,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3250,10 +3467,6 @@
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
- "excluded_poll_engines": [
- "poll",
- "poll-cv"
- ],
"flaky": false,
"gtest": true,
"language": "c++",
@@ -3263,10 +3476,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3285,10 +3500,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3307,10 +3524,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3329,10 +3548,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3351,10 +3572,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3373,10 +3596,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3395,10 +3620,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3417,10 +3644,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3439,10 +3668,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3461,10 +3692,36 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "exception_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3483,10 +3740,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3505,12 +3764,14 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [
"--generated_file_path=gens/src/proto/grpc/testing/"
],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3529,10 +3790,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3551,10 +3814,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3573,10 +3838,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3586,10 +3853,6 @@
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
- "excluded_poll_engines": [
- "poll",
- "poll-cv"
- ],
"flaky": false,
"gtest": true,
"language": "c++",
@@ -3599,10 +3862,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3612,10 +3877,6 @@
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
- "excluded_poll_engines": [
- "poll",
- "poll-cv"
- ],
"flaky": false,
"gtest": false,
"language": "c++",
@@ -3625,10 +3886,36 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "h2_ssl_cert_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3647,10 +3934,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3669,10 +3958,58 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "inlined_vector_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": false,
+ "language": "c++",
+ "name": "inproc_sync_unary_ping_pong_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3689,10 +4026,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3711,10 +4050,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3733,10 +4074,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3755,10 +4098,36 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "orphanable_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3777,10 +4146,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3799,10 +4170,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3819,10 +4192,60 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "ref_counted_ptr_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "ref_counted_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3841,10 +4264,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3861,10 +4286,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3883,10 +4310,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3905,10 +4334,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3927,10 +4358,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3947,10 +4380,36 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "server_early_return_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3969,10 +4428,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3991,10 +4452,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4002,7 +4465,9 @@
"windows"
],
"cpu_cost": 1.0,
- "exclude_configs": [],
+ "exclude_configs": [
+ "tsan"
+ ],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
@@ -4013,10 +4478,13 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "timeout_seconds": 1200,
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4035,10 +4503,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": false
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4055,10 +4525,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4077,10 +4549,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4100,10 +4574,35 @@
"posix",
"windows"
],
- "timeout_seconds": 1200
+ "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": "transport_pid_controller_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4120,10 +4619,12 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4142,10 +4643,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4166,10 +4669,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4190,10 +4695,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4214,10 +4721,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4238,10 +4747,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4262,34 +4773,12 @@
"mac",
"posix",
"windows"
- ]
- },
- {
- "args": [],
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "gtest": false,
- "language": "c",
- "name": "large_metadata_bad_client_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ]
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4310,10 +4799,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4334,10 +4825,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4358,10 +4851,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4382,10 +4877,12 @@
"mac",
"posix",
"windows"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4402,13 +4899,15 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [
"--test_bin_name=resolver_component_test_unsecure",
"--running_under_bazel=false"
],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4425,13 +4924,15 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [
"--test_bin_name=resolver_component_test",
"--running_under_bazel=false"
],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4448,7 +4949,8 @@
"linux",
"mac",
"posix"
- ]
+ ],
+ "uses_polling": true
},
{
"args": [
@@ -6393,6 +6895,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_census_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -7731,6 +8256,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_compress_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -9026,6 +9574,28 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fakesec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -10232,6 +10802,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fd_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -11499,6 +12092,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -12755,6 +13371,25 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+pipe_test",
+ "platforms": [
+ "linux"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -13939,6 +14574,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+trace_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -15231,6 +15889,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+workarounds_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -16587,6 +17268,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_http_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -17985,6 +18690,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_load_reporting_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -19341,6 +20069,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_oauth2_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -20661,6 +21413,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -21765,6 +22541,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -22989,6 +23789,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair+trace_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -24173,6 +24997,32 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [
+ "msan"
+ ],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_1byte_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -25519,6 +26369,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -26400,1344 +27273,6 @@
"ci_platforms": [
"windows",
"linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "bad_hostname"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "bad_ping"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "binary_metadata"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "call_creds"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_after_accept"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_after_client_done"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_after_invoke"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_after_round_trip"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_before_invoke"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_in_a_vacuum"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "cancel_with_status"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "compressed_payload"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "connectivity"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "default_host"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "disappearing_server"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": true,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "empty_batch"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "filter_call_init_fails"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "filter_causes_close"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "filter_latency"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "graceful_server_shutdown"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "high_initial_seqno"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "hpack_size"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "idempotent_request"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "invoke_large_request"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "keepalive_timeout"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "large_metadata"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "load_reporting_hook"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "max_concurrent_streams"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "max_connection_age"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "max_connection_idle"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [
- "uv"
- ],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "max_message_length"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "negative_deadline"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "network_status_change"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "no_logging"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "no_op"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "payload"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "ping"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "ping_pong_streaming"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "registered_call"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "request_with_flags"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "request_with_payload"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "resource_quota_server"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "server_finishes_request"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "shutdown_finishes_calls"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "shutdown_finishes_tags"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "simple_cacheable_request"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "simple_delayed_request"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "simple_metadata"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "simple_request"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "stream_compression_compressed_payload"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "stream_compression_payload"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "stream_compression_ping_pong_streaming"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "streaming_error_response"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "trailing_metadata"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "workaround_cronet_compression"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "write_buffering"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "write_buffering_at_end"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "h2_ssl_cert_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "authority_not_supported"
- ],
- "ci_platforms": [
- "windows",
- "linux",
"posix"
],
"cpu_cost": 1.0,
@@ -28141,6 +27676,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -29298,6 +28857,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_uds_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -30494,6 +30076,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "inproc_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"high_initial_seqno"
],
"ci_platforms": [
@@ -31092,52 +30697,6 @@
},
{
"args": [
- "write_buffering"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "inproc_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "write_buffering_at_end"
- ],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "inproc_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
"authority_not_supported"
],
"ci_platforms": [
@@ -31577,6 +31136,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_census_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -32892,6 +32474,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_compress_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -34090,6 +33695,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fd_nosec_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -35334,6 +34962,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -36571,6 +36222,25 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+pipe_nosec_test",
+ "platforms": [
+ "linux"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -37732,6 +37402,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+trace_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -39001,6 +38694,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+workarounds_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -40333,6 +40049,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_http_proxy_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -41708,6 +41448,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_load_reporting_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -42968,6 +42731,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_proxy_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -44048,6 +43835,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -45248,6 +45059,30 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair+trace_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -46406,6 +46241,32 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [
+ "msan"
+ ],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_sockpair_1byte_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -47704,6 +47565,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_uds_nosec_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"graceful_server_shutdown"
],
"ci_platforms": [
@@ -48877,6 +48761,29 @@
},
{
"args": [
+ "filter_status_code"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "inproc_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"high_initial_seqno"
],
"ci_platforms": [
@@ -49475,55 +49382,36 @@
},
{
"args": [
- "write_buffering"
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_1channel_100rpcs_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
"ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "language": "c",
- "name": "inproc_nosec_test",
- "platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
- },
- {
- "args": [
- "write_buffering_at_end"
+ "linux"
],
- "ci_platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
],
- "cpu_cost": 0.1,
- "exclude_configs": [],
- "exclude_iomgrs": [],
+ "excluded_poll_engines": [],
"flaky": false,
- "language": "c",
- "name": "inproc_nosec_test",
+ "language": "c++",
+ "name": "json_run_localhost",
"platforms": [
- "windows",
- "linux",
- "mac",
- "posix"
- ]
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_protobuf_async_unary_1channel_100rpcs_1MB",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_1channel_100rpcs_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_1channel_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49541,14 +49429,15 @@
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_1channel_100rpcs_1MB",
- "timeout_seconds": 360
+ "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_1channel_1MB",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_1channel_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 16, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 1, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 50, \"req_size\": 300}}, \"client_channels\": 300, \"threads_per_cq\": 0, \"load_params\": {\"poisson\": {\"offered_load\": 37500}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49566,14 +49455,15 @@
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_1channel_1MB",
- "timeout_seconds": 360
+ "shortname": "json_run_localhost:cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49592,13 +49482,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49617,13 +49508,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49642,13 +49534,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_1mps_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_10mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49667,13 +49560,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_10mps_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_1channel_1MBmsg_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49692,13 +49586,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_1channel_1MBmsg_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49717,13 +49612,40 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
+ },
+ {
+ "args": [
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1cq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 1000000}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ ],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
+ ],
+ "excluded_poll_engines": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "json_run_localhost",
+ "platforms": [
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_1cq_secure",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 2}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49742,13 +49664,40 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
+ },
+ {
+ "args": [
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1cq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 1000000, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ ],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
+ ],
+ "excluded_poll_engines": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "json_run_localhost",
+ "platforms": [
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_1cq_secure",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49767,13 +49716,40 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
+ },
+ {
+ "args": [
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_1cq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 1000000, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ ],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
+ ],
+ "excluded_poll_engines": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "json_run_localhost",
+ "platforms": [
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_1cq_secure",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49792,13 +49768,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_one_server_core_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49817,13 +49794,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_one_server_core_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49844,13 +49822,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 8388608, \"req_size\": 128}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49869,13 +49848,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49896,13 +49876,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_secure_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49921,13 +49902,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_secure_1MB",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49946,13 +49928,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_unary_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49971,13 +49954,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_unary_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -49996,13 +49980,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50021,13 +50006,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50046,13 +50032,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50071,13 +50058,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50096,13 +50084,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50121,13 +50110,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50146,13 +50136,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50171,13 +50162,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50196,13 +50188,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50221,13 +50214,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50246,13 +50240,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50271,13 +50266,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50296,13 +50292,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50321,13 +50318,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50346,13 +50344,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50371,13 +50370,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50396,13 +50396,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_ping_pong_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50421,13 +50422,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_qps_unconstrained_secure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50446,13 +50448,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50471,13 +50474,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50496,13 +50500,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_1mps_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50521,13 +50526,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_10mps_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50546,13 +50552,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50571,13 +50578,40 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
+ },
+ {
+ "args": [
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1cq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 1000000}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ ],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
+ ],
+ "excluded_poll_engines": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "json_run_localhost",
+ "platforms": [
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_1cq_insecure",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 2}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50596,13 +50630,40 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
+ },
+ {
+ "args": [
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 1000000, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ ],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
+ ],
+ "excluded_poll_engines": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "json_run_localhost",
+ "platforms": [
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50621,13 +50682,40 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
+ },
+ {
+ "args": [
+ "--scenarios_json",
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 1000000, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ ],
+ "auto_timeout_scaling": false,
+ "boringssl": true,
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": "capacity",
+ "defaults": "boringssl",
+ "exclude_configs": [
+ "tsan",
+ "asan"
+ ],
+ "excluded_poll_engines": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "json_run_localhost",
+ "platforms": [
+ "linux"
+ ],
+ "shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure",
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50646,13 +50734,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_one_server_core_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50671,13 +50760,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_generic_async_streaming_qps_one_server_core_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50698,13 +50788,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 8388608, \"req_size\": 128}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50723,13 +50814,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50750,13 +50842,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_insecure_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50775,13 +50868,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_insecure_1MB",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50800,13 +50894,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_unary_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50825,13 +50920,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_unary_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50850,13 +50946,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50875,13 +50972,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50900,13 +50998,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50925,13 +51024,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50950,13 +51050,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -50975,13 +51076,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51000,13 +51102,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51025,13 +51128,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51050,13 +51154,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51075,13 +51180,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51100,13 +51206,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51125,13 +51232,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51150,13 +51258,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51175,13 +51284,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51200,13 +51310,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51225,13 +51336,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51250,13 +51362,14 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_ping_pong_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
+ "auto_timeout_scaling": false,
"boringssl": true,
"ci_platforms": [
"linux"
@@ -51275,10 +51388,11 @@
"linux"
],
"shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure",
- "timeout_seconds": 360
+ "timeout_seconds": 120
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_1channel_100rpcs_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -51289,34 +51403,22 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_1channel_100rpcs_1MB_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_unary_1channel_100rpcs_1MB",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_1channel_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -51327,1104 +51429,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_1channel_1MB_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_1mps_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_10mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_10mps_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_1channel_1MBmsg_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_1channel_1MBmsg_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 2}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_one_server_core_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_one_server_core_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 10, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [
- "poll-cv"
- ],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 8388608, \"req_size\": 128}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 10, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [
- "poll-cv"
- ],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_secure_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_secure_1MB_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_unary_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_unary_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": "capacity",
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_from_client_1channel_1MB",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52433,36 +51455,24 @@
"cpu_cost": 2,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_ping_pong_secure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_ping_pong_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52471,150 +51481,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_ping_pong_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_ping_pong_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_ping_pong_secure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_qps_unconstrained_secure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": {\"use_test_ca\": true, \"server_host_override\": \"foo.test.google.fr\"}, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52623,74 +51507,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_qps_unconstrained_secure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_ping_pong_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_unconstrained_1mps_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52699,36 +51533,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_unconstrained_10mps_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52737,36 +51559,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_1mps_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52775,36 +51585,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_10mps_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_1cq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 1000000}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52813,36 +51611,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_unconstrained_1cq_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 65536, \"req_size\": 65536}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 2}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52851,36 +51637,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 2}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 1000000, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52889,34 +51663,22 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -52927,36 +51689,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 1000000, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 1000000, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -52965,36 +51715,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_generic_async_streaming_qps_one_server_core_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"server_type\": \"ASYNC_GENERIC_SERVER\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"security_params\": null, \"threads_per_cq\": 0}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 13, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"bytebuf_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"security_params\": null, \"threads_per_cq\": 2, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 2, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -53003,36 +51741,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_generic_async_streaming_qps_one_server_core_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 10, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -53041,36 +51767,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [
"poll-cv"
],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 8388608, \"req_size\": 128}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53081,36 +51795,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 10, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_servers\": 1, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
@@ -53119,36 +51821,24 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [
"poll-cv"
],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_insecure_1MB\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 1048576, \"req_size\": 1048576}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53159,148 +51849,48 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_insecure_1MB_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_unary_ping_pong_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_unary_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_unary_ping_pong_insecure_1MB",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
"linux"
],
- "cpu_cost": 2,
+ "cpu_cost": 1024,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_ping_pong_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_sync_unary_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_unary_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"UNARY\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53311,224 +51901,100 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_unary_qps_unconstrained_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_ping_pong_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_unary_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
"linux"
],
- "cpu_cost": 64,
+ "cpu_cost": 1024,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_sync_streaming_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
"linux"
],
- "cpu_cost": 64,
+ "cpu_cost": 1024,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
"linux"
],
- "cpu_cost": 2,
+ "cpu_cost": 1024,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_ping_pong_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53539,34 +52005,22 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 1, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53577,34 +52031,22 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING\", \"messages_per_stream\": 10, \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53615,148 +52057,48 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_ping_pong_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
"linux"
],
- "cpu_cost": 2,
+ "cpu_cost": 1024,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_ping_pong_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_CLIENT\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53767,148 +52109,48 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 2,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
- ],
- "excluded_poll_engines": [],
- "flaky": false,
- "language": "c++",
- "name": "json_run_localhost",
- "platforms": [
- "linux"
- ],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_ping_pong_insecure_low_thread_count",
- "timeout_seconds": 360
- },
- {
- "args": [
- "--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
- ],
- "boringssl": true,
- "ci_platforms": [
- "linux"
- ],
- "cpu_cost": 64,
- "defaults": "boringssl",
- "exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
- "{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_ping_pong_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 1, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 0, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 1, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"latency\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 1, \"outstanding_rpcs_per_channel\": 1, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 1, \"threads_per_cq\": 0, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
+ "{\"scenarios\": [{\"name\": \"cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"SYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 16, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"SYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
"boringssl": true,
"ci_platforms": [
"linux"
],
- "cpu_cost": 2,
+ "cpu_cost": 1024,
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_ping_pong_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
"args": [
+ "--run_inproc",
"--scenarios_json",
"{\"scenarios\": [{\"name\": \"cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure\", \"warmup_seconds\": 0, \"benchmark_seconds\": 1, \"num_servers\": 1, \"server_config\": {\"async_server_threads\": 0, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"security_params\": null, \"threads_per_cq\": 3, \"server_type\": \"ASYNC_SERVER\"}, \"num_clients\": 0, \"client_config\": {\"security_params\": null, \"channel_args\": [{\"str_value\": \"throughput\", \"name\": \"grpc.optimization_target\"}, {\"int_value\": 1, \"name\": \"grpc.minimal_stack\"}], \"async_client_threads\": 0, \"outstanding_rpcs_per_channel\": 100, \"rpc_type\": \"STREAMING_FROM_SERVER\", \"payload_config\": {\"simple_params\": {\"resp_size\": 0, \"req_size\": 0}}, \"client_channels\": 64, \"threads_per_cq\": 3, \"load_params\": {\"closed_loop\": {}}, \"client_type\": \"ASYNC_CLIENT\", \"histogram_params\": {\"max_possible\": 60000000000.0, \"resolution\": 0.01}}}]}"
],
@@ -53919,30 +52161,17 @@
"cpu_cost": "capacity",
"defaults": "boringssl",
"exclude_configs": [
- "asan-noleaks",
- "asan-trace-cmp",
- "basicprof",
- "c++-compat",
- "counters",
- "dbg",
- "gcov",
- "helgrind",
- "lto",
- "memcheck",
- "msan",
- "mutrace",
- "opt",
- "stapprof",
- "ubsan"
+ "tsan",
+ "asan"
],
"excluded_poll_engines": [],
"flaky": false,
"language": "c++",
- "name": "json_run_localhost",
+ "name": "qps_json_driver",
"platforms": [
"linux"
],
- "shortname": "json_run_localhost:cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure_low_thread_count",
+ "shortname": "qps_json_driver:inproc_cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure",
"timeout_seconds": 360
},
{
@@ -107238,6 +105467,29 @@
},
{
"args": [
+ "test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 0.1,
+ "exclude_configs": [
+ "tsan"
+ ],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "api_fuzzer_one_entry",
+ "platforms": [
+ "mac",
+ "linux"
+ ],
+ "uses_polling": false
+ },
+ {
+ "args": [
"test/core/end2end/fuzzers/api_fuzzer_corpus/poc-c726ee220e980ed6ad17809fd9efe2844ee61555ac08e4f88afd8901cc2dd53a"
],
"ci_platforms": [
diff --git a/tools/run_tests/helper_scripts/build_csharp.sh b/tools/run_tests/helper_scripts/build_csharp.sh
index ec0a441f56..c6bee82b44 100755
--- a/tools/run_tests/helper_scripts/build_csharp.sh
+++ b/tools/run_tests/helper_scripts/build_csharp.sh
@@ -15,12 +15,12 @@
set -ex
-cd $(dirname $0)/../../../src/csharp
+cd "$(dirname "$0")/../../../src/csharp"
if [ "$CONFIG" == "gcov" ]
then
# overriding NativeDependenciesConfigurationUnix makes C# project pick up the gcov flavor of grpc_csharp_ext
- dotnet build --configuration $MSBUILD_CONFIG /p:NativeDependenciesConfigurationUnix=gcov Grpc.sln
+ dotnet build --configuration "$MSBUILD_CONFIG" /p:NativeDependenciesConfigurationUnix=gcov Grpc.sln
else
- dotnet build --configuration $MSBUILD_CONFIG Grpc.sln
+ dotnet build --configuration "$MSBUILD_CONFIG" Grpc.sln
fi
diff --git a/tools/run_tests/helper_scripts/build_php.sh b/tools/run_tests/helper_scripts/build_php.sh
index 856e5b6865..443be34fa0 100755
--- a/tools/run_tests/helper_scripts/build_php.sh
+++ b/tools/run_tests/helper_scripts/build_php.sh
@@ -18,9 +18,9 @@ set -ex
CONFIG=${CONFIG:-opt}
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
-root=`pwd`
+root=$(pwd)
export GRPC_LIB_SUBDIR=libs/$CONFIG
export CFLAGS="-Wno-parentheses-equality"
@@ -30,8 +30,8 @@ cd src/php
cd ext/grpc
phpize
if [ "$CONFIG" != "gcov" ] ; then
- ./configure --enable-grpc=$root
+ ./configure --enable-grpc="$root"
else
- ./configure --enable-grpc=$root --enable-coverage
+ ./configure --enable-grpc="$root" --enable-coverage
fi
make
diff --git a/tools/run_tests/helper_scripts/build_python.sh b/tools/run_tests/helper_scripts/build_python.sh
index be650553dc..b809fe012f 100755
--- a/tools/run_tests/helper_scripts/build_python.sh
+++ b/tools/run_tests/helper_scripts/build_python.sh
@@ -16,13 +16,13 @@
set -ex
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
##########################
# Portability operations #
##########################
-PLATFORM=`uname -s`
+PLATFORM=$(uname -s)
function is_msys() {
if [ "${PLATFORM/MSYS}" != "$PLATFORM" ]; then
@@ -64,7 +64,7 @@ function venv() {
# Path to python executable within a virtual environment depending on the
# system.
function venv_relative_python() {
- if [ $(is_mingw) ]; then
+ if [ "$(is_mingw)" ]; then
echo 'Scripts/python.exe'
else
echo 'bin/python'
@@ -73,7 +73,7 @@ function venv_relative_python() {
# Distutils toolchain to use depending on the system.
function toolchain() {
- if [ $(is_mingw) ]; then
+ if [ "$(is_mingw)" ]; then
echo 'mingw32'
else
echo 'unix'
@@ -97,17 +97,17 @@ function script_realpath() {
####################
PYTHON=${1:-python2.7}
-VENV=${2:-$(venv $PYTHON)}
+VENV=${2:-$(venv "$PYTHON")}
VENV_RELATIVE_PYTHON=${3:-$(venv_relative_python)}
TOOLCHAIN=${4:-$(toolchain)}
-if [ $(is_msys) ]; then
+if [ "$(is_msys)" ]; then
echo "MSYS doesn't directly provide the right compiler(s);"
echo "switch to a MinGW shell."
exit 1
fi
-ROOT=`pwd`
+ROOT=$(pwd)
export CFLAGS="-I$ROOT/include -std=gnu99 -fno-wrapv $CFLAGS"
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
export LANG=en_US.UTF-8
@@ -117,7 +117,7 @@ export LANG=en_US.UTF-8
HOST_PYTHON=${HOST_PYTHON:-python}
# If ccache is available on Linux, use it.
-if [ $(is_linux) ]; then
+if [ "$(is_linux)" ]; then
# We're not on Darwin (Mac OS X)
if [ -x "$(command -v ccache)" ]; then
if [ -x "$(command -v gcc)" ]; then
@@ -137,46 +137,46 @@ fi
# it's possible that the virtualenv is still usable and we trust the tester to
# be able to 'figure it out' instead of us e.g. doing potentially expensive and
# unnecessary error recovery by `rm -rf`ing the virtualenv.
-($PYTHON -m virtualenv $VENV ||
- $HOST_PYTHON -m virtualenv -p $PYTHON $VENV ||
+($PYTHON -m virtualenv "$VENV" ||
+ $HOST_PYTHON -m virtualenv -p "$PYTHON" "$VENV" ||
true)
-VENV_PYTHON=`script_realpath "$VENV/$VENV_RELATIVE_PYTHON"`
+VENV_PYTHON=$(script_realpath "$VENV/$VENV_RELATIVE_PYTHON")
# pip-installs the directory specified. Used because on MSYS the vanilla Windows
# Python gets confused when parsing paths.
pip_install_dir() {
- PWD=`pwd`
- cd $1
- ($VENV_PYTHON setup.py build_ext -c $TOOLCHAIN || true)
+ PWD=$(pwd)
+ cd "$1"
+ ($VENV_PYTHON setup.py build_ext -c "$TOOLCHAIN" || true)
$VENV_PYTHON -m pip install --no-deps .
- cd $PWD
+ cd "$PWD"
}
-$VENV_PYTHON -m pip install --upgrade pip
+$VENV_PYTHON -m pip install --upgrade pip==9.0.1
$VENV_PYTHON -m pip install setuptools
$VENV_PYTHON -m pip install cython
$VENV_PYTHON -m pip install six enum34 protobuf futures
-pip_install_dir $ROOT
+pip_install_dir "$ROOT"
-$VENV_PYTHON $ROOT/tools/distrib/python/make_grpcio_tools.py
-pip_install_dir $ROOT/tools/distrib/python/grpcio_tools
+$VENV_PYTHON "$ROOT/tools/distrib/python/make_grpcio_tools.py"
+pip_install_dir "$ROOT/tools/distrib/python/grpcio_tools"
# Build/install health checking
-$VENV_PYTHON $ROOT/src/python/grpcio_health_checking/setup.py preprocess
-$VENV_PYTHON $ROOT/src/python/grpcio_health_checking/setup.py build_package_protos
-pip_install_dir $ROOT/src/python/grpcio_health_checking
+$VENV_PYTHON "$ROOT/src/python/grpcio_health_checking/setup.py" preprocess
+$VENV_PYTHON "$ROOT/src/python/grpcio_health_checking/setup.py" build_package_protos
+pip_install_dir "$ROOT/src/python/grpcio_health_checking"
# Build/install reflection
-$VENV_PYTHON $ROOT/src/python/grpcio_reflection/setup.py preprocess
-$VENV_PYTHON $ROOT/src/python/grpcio_reflection/setup.py build_package_protos
-pip_install_dir $ROOT/src/python/grpcio_reflection
+$VENV_PYTHON "$ROOT/src/python/grpcio_reflection/setup.py" preprocess
+$VENV_PYTHON "$ROOT/src/python/grpcio_reflection/setup.py" build_package_protos
+pip_install_dir "$ROOT/src/python/grpcio_reflection"
# Install testing
-pip_install_dir $ROOT/src/python/grpcio_testing
+pip_install_dir "$ROOT/src/python/grpcio_testing"
# Build/install tests
$VENV_PYTHON -m pip install coverage==4.4 oauth2client==4.1.0 \
google-auth==1.0.0 requests==2.14.2
-$VENV_PYTHON $ROOT/src/python/grpcio_tests/setup.py preprocess
-$VENV_PYTHON $ROOT/src/python/grpcio_tests/setup.py build_package_protos
-pip_install_dir $ROOT/src/python/grpcio_tests
+$VENV_PYTHON "$ROOT/src/python/grpcio_tests/setup.py" preprocess
+$VENV_PYTHON "$ROOT/src/python/grpcio_tests/setup.py" build_package_protos
+pip_install_dir "$ROOT/src/python/grpcio_tests"
diff --git a/tools/run_tests/helper_scripts/build_python_msys2.sh b/tools/run_tests/helper_scripts/build_python_msys2.sh
index 4c54f1c472..f388b4bf96 100644
--- a/tools/run_tests/helper_scripts/build_python_msys2.sh
+++ b/tools/run_tests/helper_scripts/build_python_msys2.sh
@@ -15,7 +15,7 @@
set -ex
-BUILD_PYTHON=`realpath "$(dirname $0)/build_python.sh"`
+BUILD_PYTHON=$(realpath "$(dirname "$0")/build_python.sh")
export MSYSTEM=$1
shift 1
-bash --login $BUILD_PYTHON "$@"
+bash --login "$BUILD_PYTHON" "$@"
diff --git a/tools/run_tests/helper_scripts/build_ruby.sh b/tools/run_tests/helper_scripts/build_ruby.sh
index a9267e10f0..b15a8639d9 100755
--- a/tools/run_tests/helper_scripts/build_ruby.sh
+++ b/tools/run_tests/helper_scripts/build_ruby.sh
@@ -19,7 +19,7 @@ set -ex
export GRPC_CONFIG=${CONFIG:-opt}
# change to grpc's ruby directory
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
rm -rf ./tmp
rake compile
diff --git a/tools/run_tests/helper_scripts/bundle_install_wrapper.sh b/tools/run_tests/helper_scripts/bundle_install_wrapper.sh
index 27b8fced7b..ab31dd5c80 100755
--- a/tools/run_tests/helper_scripts/bundle_install_wrapper.sh
+++ b/tools/run_tests/helper_scripts/bundle_install_wrapper.sh
@@ -17,9 +17,9 @@
set -ex
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
-SYSTEM=`uname | cut -f 1 -d_`
+SYSTEM=$(uname | cut -f 1 -d_)
if [ "$SYSTEM" == "Darwin" ] ; then
# Workaround for crash during bundle install
diff --git a/tools/run_tests/helper_scripts/post_tests_c.sh b/tools/run_tests/helper_scripts/post_tests_c.sh
index a4a8f44dca..e4ab203543 100755
--- a/tools/run_tests/helper_scripts/post_tests_c.sh
+++ b/tools/run_tests/helper_scripts/post_tests_c.sh
@@ -17,14 +17,14 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi
-root=$(readlink -f $(dirname $0)/../../..)
+root=$(readlink -f "$(dirname "$0")/../../..")
out=$root/reports/c_cxx_coverage
tmp1=$(mktemp)
tmp2=$(mktemp)
-cd $root
-lcov --capture --directory . --output-file $tmp1
-lcov --extract $tmp1 "$root/src/*" "$root/include/*" --output-file $tmp2
-genhtml $tmp2 --output-directory $out
-rm $tmp2
-rm $tmp1
+cd "$root"
+lcov --capture --directory . --output-file "$tmp1"
+lcov --extract "$tmp1" "$root/src/*" "$root/include/*" --output-file "$tmp2"
+genhtml "$tmp2" --output-directory "$out"
+rm "$tmp2"
+rm "$tmp1"
diff --git a/tools/run_tests/helper_scripts/post_tests_csharp.sh b/tools/run_tests/helper_scripts/post_tests_csharp.sh
index f92ea00293..6473dfd015 100755
--- a/tools/run_tests/helper_scripts/post_tests_csharp.sh
+++ b/tools/run_tests/helper_scripts/post_tests_csharp.sh
@@ -18,7 +18,7 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi
# change to gRPC repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
# Generate the csharp extension coverage report
gcov objs/gcov/src/csharp/ext/*.o
diff --git a/tools/run_tests/helper_scripts/post_tests_php.sh b/tools/run_tests/helper_scripts/post_tests_php.sh
index 8ebc1e4fae..b23e4bd113 100755
--- a/tools/run_tests/helper_scripts/post_tests_php.sh
+++ b/tools/run_tests/helper_scripts/post_tests_php.sh
@@ -17,15 +17,15 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi
-root=$(readlink -f $(dirname $0)/../../..)
+root=$(readlink -f "$(dirname "$0")/../../..")
out=$root/reports/php_ext_coverage
tmp1=$(mktemp)
tmp2=$(mktemp)
-cd $root
-lcov --capture --directory . --output-file $tmp1
-lcov --extract $tmp1 "$root/src/php/ext/grpc/*" --output-file $tmp2
-genhtml $tmp2 --output-directory $out
-rm $tmp2
-rm $tmp1
+cd "$root"
+lcov --capture --directory . --output-file "$tmp1"
+lcov --extract "$tmp1" "$root/src/php/ext/grpc/*" --output-file "$tmp2"
+genhtml "$tmp2" --output-directory "$out"
+rm "$tmp2"
+rm "$tmp1"
# todo(mattkwong): generate coverage report for php and copy to reports/php
diff --git a/tools/run_tests/helper_scripts/post_tests_python.sh b/tools/run_tests/helper_scripts/post_tests_python.sh
index 071e81af7d..bca9b20ecc 100755
--- a/tools/run_tests/helper_scripts/post_tests_python.sh
+++ b/tools/run_tests/helper_scripts/post_tests_python.sh
@@ -18,7 +18,7 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi
# change to directory of Python coverage files
-cd $(dirname $0)/../../../src/python/grpcio_tests/
+cd "$(dirname "$0")/../../../src/python/grpcio_tests/"
coverage combine .
coverage html -i -d ./../../../reports/python
diff --git a/tools/run_tests/helper_scripts/post_tests_ruby.sh b/tools/run_tests/helper_scripts/post_tests_ruby.sh
index a0b0736f53..f086001524 100755
--- a/tools/run_tests/helper_scripts/post_tests_ruby.sh
+++ b/tools/run_tests/helper_scripts/post_tests_ruby.sh
@@ -17,15 +17,15 @@ set -ex
if [ "$CONFIG" != "gcov" ] ; then exit ; fi
-root=$(readlink -f $(dirname $0)/../../..)
+root=$(readlink -f "$(dirname "$0")/../../..")
out=$root/reports/ruby_ext_coverage
tmp1=$(mktemp)
tmp2=$(mktemp)
-cd $root
-lcov --capture --directory . --output-file $tmp1
-lcov --extract $tmp1 "$root/src/ruby/*" --output-file $tmp2
-genhtml $tmp2 --output-directory $out
-rm $tmp2
-rm $tmp1
+cd "$root"
+lcov --capture --directory . --output-file "$tmp1"
+lcov --extract "$tmp1" "$root/src/ruby/*" --output-file "$tmp2"
+genhtml "$tmp2" --output-directory "$out"
+rm "$tmp2"
+rm "$tmp1"
-cp -rv $root/coverage $root/reports/ruby
+cp -rv "$root/coverage" "$root/reports/ruby"
diff --git a/tools/run_tests/helper_scripts/pre_build_cmake.sh b/tools/run_tests/helper_scripts/pre_build_cmake.sh
index 0300cd8a55..bb36588bcc 100755
--- a/tools/run_tests/helper_scripts/pre_build_cmake.sh
+++ b/tools/run_tests/helper_scripts/pre_build_cmake.sh
@@ -15,10 +15,10 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
mkdir -p cmake/build
cd cmake/build
# MSBUILD_CONFIG's values are suitable for cmake as well
-cmake -DgRPC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${MSBUILD_CONFIG} ../..
+cmake -DgRPC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE="${MSBUILD_CONFIG}" ../..
diff --git a/tools/run_tests/helper_scripts/pre_build_csharp.sh b/tools/run_tests/helper_scripts/pre_build_csharp.sh
index e2aeddcd7a..f9f5440a61 100755
--- a/tools/run_tests/helper_scripts/pre_build_csharp.sh
+++ b/tools/run_tests/helper_scripts/pre_build_csharp.sh
@@ -16,6 +16,6 @@
set -ex
# cd to gRPC csharp directory
-cd $(dirname $0)/../../../src/csharp
+cd "$(dirname "$0")/../../../src/csharp"
dotnet restore Grpc.sln
diff --git a/tools/run_tests/helper_scripts/pre_build_node.bat b/tools/run_tests/helper_scripts/pre_build_node.bat
deleted file mode 100644
index ececc5755d..0000000000
--- a/tools/run_tests/helper_scripts/pre_build_node.bat
+++ /dev/null
@@ -1,20 +0,0 @@
-@rem Copyright 2016 gRPC authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-
-set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm
-
-@rem Update npm to at least version 5
-call npm update -g npm
-
-call npm update --prefer-online
diff --git a/tools/run_tests/helper_scripts/pre_build_ruby.sh b/tools/run_tests/helper_scripts/pre_build_ruby.sh
index d68f7e9ff5..b5740963ee 100755
--- a/tools/run_tests/helper_scripts/pre_build_ruby.sh
+++ b/tools/run_tests/helper_scripts/pre_build_ruby.sh
@@ -19,6 +19,6 @@ set -ex
export GRPC_CONFIG=${CONFIG:-opt}
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
tools/run_tests/helper_scripts/bundle_install_wrapper.sh
diff --git a/tools/run_tests/helper_scripts/run_grpc-node.sh b/tools/run_tests/helper_scripts/run_grpc-node.sh
new file mode 100755
index 0000000000..747aae7fd5
--- /dev/null
+++ b/tools/run_tests/helper_scripts/run_grpc-node.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# 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.
+#
+# This script runs grpc/grpc-node tests with their grpc submodule updated
+# to this reference
+
+# cd to gRPC root directory
+cd "$(dirname "$0")/../../.."
+
+CURRENT_COMMIT="$(git rev-parse --verify HEAD)"
+
+rm -rf ./../grpc-node
+git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node
+cd ./../grpc-node
+
+./test-grpc-submodule.sh "$CURRENT_COMMIT"
diff --git a/tools/run_tests/helper_scripts/run_lcov.sh b/tools/run_tests/helper_scripts/run_lcov.sh
index c7b2cfea62..9d8b6793fc 100755
--- a/tools/run_tests/helper_scripts/run_lcov.sh
+++ b/tools/run_tests/helper_scripts/run_lcov.sh
@@ -15,17 +15,17 @@
set -ex
-out=$(readlink -f ${1:-coverage})
+out=$(readlink -f "${1:-coverage}")
-root=$(readlink -f $(dirname $0)/../../..)
+root=$(readlink -f "$(dirname "$0")/../../..")
shift || true
tmp=$(mktemp)
-cd $root
-tools/run_tests/run_tests.py -c gcov -l c c++ $@ || true
-lcov --capture --directory . --output-file $tmp
-genhtml $tmp --output-directory $out
-rm $tmp
+cd "$root"
+tools/run_tests/run_tests.py -c gcov -l c c++ "$@" || true
+lcov --capture --directory . --output-file "$tmp"
+genhtml "$tmp" --output-directory "$out"
+rm "$tmp"
if which xdg-open > /dev/null
then
- xdg-open file://$out/index.html
+ xdg-open "file://$out/index.html"
fi
diff --git a/tools/run_tests/helper_scripts/run_node.bat b/tools/run_tests/helper_scripts/run_node.bat
deleted file mode 100644
index 26f0628a95..0000000000
--- a/tools/run_tests/helper_scripts/run_node.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@rem Copyright 2016 gRPC authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-
-set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm
-set JUNIT_REPORT_PATH=src\node\report.xml
-set JUNIT_REPORT_STACK=1
-.\node_modules\.bin\mocha.cmd --reporter mocha-jenkins-reporter --timeout 8000 src\node\test \ No newline at end of file
diff --git a/tools/run_tests/helper_scripts/run_node.sh b/tools/run_tests/helper_scripts/run_node.sh
deleted file mode 100755
index 35640047ca..0000000000
--- a/tools/run_tests/helper_scripts/run_node.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-# 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.
-
-NODE_VERSION=$1
-source ~/.nvm/nvm.sh
-
-nvm use $NODE_VERSION
-set -ex
-
-CONFIG=${CONFIG:-opt}
-
-# change to grpc repo root
-cd $(dirname $0)/../../..
-
-root=`pwd`
-
-test_directory='src/node/test'
-timeout=8000
-
-if [ "$CONFIG" = "gcov" ]
-then
- ./node_modules/.bin/istanbul cover --dir reports/node_coverage \
- -x **/interop/* ./node_modules/.bin/_mocha -- --timeout $timeout $test_directory
- cp -r reports/node_coverage/lcov-report/* reports/node_coverage/
- cd build
- gcov Release/obj.target/grpc/ext/*.o
- lcov --base-directory . --directory . -c -o coverage.info
- lcov -e coverage.info '**/src/node/ext/*' -o coverage.info
- genhtml -o ../reports/node_ext_coverage --num-spaces 2 \
- -t 'Node gRPC test coverage' coverage.info --rc genhtml_hi_limit=95 \
- --rc genhtml_med_limit=80 --no-prefix
-else
- JUNIT_REPORT_PATH=src/node/report.xml JUNIT_REPORT_STACK=1 \
- ./node_modules/.bin/mocha --timeout $timeout \
- --reporter mocha-jenkins-reporter $test_directory
-fi
diff --git a/tools/run_tests/helper_scripts/run_python.sh b/tools/run_tests/helper_scripts/run_python.sh
index 90f28c8ba8..bcfe3a6577 100755
--- a/tools/run_tests/helper_scripts/run_python.sh
+++ b/tools/run_tests/helper_scripts/run_python.sh
@@ -16,15 +16,15 @@
set -ex
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
-PYTHON=`realpath "${1:-py27/bin/python}"`
+PYTHON=$(realpath "${1:-py27/bin/python}")
-ROOT=`pwd`
+ROOT=$(pwd)
-$PYTHON $ROOT/src/python/grpcio_tests/setup.py test_lite
+$PYTHON "$ROOT/src/python/grpcio_tests/setup.py" test_lite
-mkdir -p $ROOT/reports
-rm -rf $ROOT/reports/python-coverage
-(mv -T $ROOT/htmlcov $ROOT/reports/python-coverage) || true
+mkdir -p "$ROOT/reports"
+rm -rf "$ROOT/reports/python-coverage"
+(mv -T "$ROOT/htmlcov" "$ROOT/reports/python-coverage") || true
diff --git a/tools/run_tests/helper_scripts/run_ruby.sh b/tools/run_tests/helper_scripts/run_ruby.sh
index 4bd7d743c1..4e9c212877 100755
--- a/tools/run_tests/helper_scripts/run_ruby.sh
+++ b/tools/run_tests/helper_scripts/run_ruby.sh
@@ -16,6 +16,6 @@
set -ex
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
rake
diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
index 7914b0e29a..195544200a 100755
--- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
+++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
@@ -16,7 +16,7 @@
set -ex
# change to grpc repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
EXIT_CODE=0
ruby src/ruby/end2end/sig_handling_driver.rb || EXIT_CODE=1
@@ -27,4 +27,5 @@ ruby src/ruby/end2end/killed_client_thread_driver.rb || EXIT_CODE=1
ruby src/ruby/end2end/forking_client_driver.rb || EXIT_CODE=1
ruby src/ruby/end2end/grpc_class_init_driver.rb || EXIT_CODE=1
ruby src/ruby/end2end/multiple_killed_watching_threads_driver.rb || EXIT_CODE=1
+ruby src/ruby/end2end/load_grpc_with_gc_stress_driver.rb || EXIT_CODE=1
exit $EXIT_CODE
diff --git a/tools/run_tests/helper_scripts/run_tests_in_workspace.sh b/tools/run_tests/helper_scripts/run_tests_in_workspace.sh
index 529dc0444a..790c041881 100755
--- a/tools/run_tests/helper_scripts/run_tests_in_workspace.sh
+++ b/tools/run_tests/helper_scripts/run_tests_in_workspace.sh
@@ -19,15 +19,15 @@
# newly created workspace)
set -ex
-cd $(dirname $0)/../../..
-export repo_root=$(pwd)
+cd "$(dirname "$0")/../../.."
+export repo_root="$(pwd)"
rm -rf "${WORKSPACE_NAME}"
git clone . "${WORKSPACE_NAME}"
# clone gRPC submodules, use data from locally cloned submodules where possible
+# shellcheck disable=SC2016,SC1004
git submodule foreach 'cd "${repo_root}/${WORKSPACE_NAME}" \
&& git submodule update --init --reference ${repo_root}/${name} ${name}'
echo "Running run_tests.py in workspace ${WORKSPACE_NAME}"
-python "${WORKSPACE_NAME}/tools/run_tests/run_tests.py" $@
-
+python "${WORKSPACE_NAME}/tools/run_tests/run_tests.py" "$@"
diff --git a/tools/run_tests/interop/android/android_interop_helper.sh b/tools/run_tests/interop/android/android_interop_helper.sh
index 9c0d18fba3..116549b83e 100755
--- a/tools/run_tests/interop/android/android_interop_helper.sh
+++ b/tools/run_tests/interop/android/android_interop_helper.sh
@@ -18,7 +18,7 @@
SERVICE_KEY=$1
-gcloud auth activate-service-account --key-file=$SERVICE_KEY || exit 1
+gcloud auth activate-service-account --key-file="$SERVICE_KEY" || exit 1
gcloud config set project grpc-testing || exit 1
rm -rf grpc-java
diff --git a/tools/run_tests/interop/android/run_android_tests_on_firebase.sh b/tools/run_tests/interop/android/run_android_tests_on_firebase.sh
index 0b4811355c..f6472eba55 100755
--- a/tools/run_tests/interop/android/run_android_tests_on_firebase.sh
+++ b/tools/run_tests/interop/android/run_android_tests_on_firebase.sh
@@ -21,7 +21,7 @@ DOCKER_TAG=android_interop_test
SERVICE_KEY=~/android-interops-service-key.json
HELPER=$(pwd)/tools/run_tests/interop/android/android_interop_helper.sh
-docker build -t $DOCKER_TAG -f $DOCKERFILE .
+docker build -t "$DOCKER_TAG" -f "$DOCKERFILE" .
docker run --interactive --rm \
--volume="$SERVICE_KEY":/service-key.json:ro \
diff --git a/tools/run_tests/interop/with_nvm.sh b/tools/run_tests/interop/with_nvm.sh
index a1c3f3e0a6..887f9f6a9f 100755
--- a/tools/run_tests/interop/with_nvm.sh
+++ b/tools/run_tests/interop/with_nvm.sh
@@ -16,4 +16,4 @@
# Makes sure NVM is loaded before executing the command passed as an argument
source ~/.nvm/nvm.sh
-$@
+"$@"
diff --git a/tools/run_tests/interop/with_rvm.sh b/tools/run_tests/interop/with_rvm.sh
index c3e2882330..41e6efcb56 100755
--- a/tools/run_tests/interop/with_rvm.sh
+++ b/tools/run_tests/interop/with_rvm.sh
@@ -16,4 +16,4 @@
# Makes sure RVM is loaded before executing the command passed as an argument
source /usr/local/rvm/scripts/rvm
-$@
+"$@"
diff --git a/tools/run_tests/performance/OWNERS b/tools/run_tests/performance/OWNERS
new file mode 100644
index 0000000000..98c81529f3
--- /dev/null
+++ b/tools/run_tests/performance/OWNERS
@@ -0,0 +1,9 @@
+set noparent
+
+# These owners are in place to ensure that scenario_result_schema.json is not
+# modified without also running tools/run_tests/performance/patch_scenario_results_schema.py
+# to update the BigQuery schema
+
+@ncteisen
+@matt-kwong
+@ctiller
diff --git a/tools/run_tests/performance/bq_upload_result.py b/tools/run_tests/performance/bq_upload_result.py
index 31819d6159..6702587557 100755
--- a/tools/run_tests/performance/bq_upload_result.py
+++ b/tools/run_tests/performance/bq_upload_result.py
@@ -26,146 +26,161 @@ import time
import uuid
import massage_qps_stats
-
-gcp_utils_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../../gcp/utils'))
+gcp_utils_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../../gcp/utils'))
sys.path.append(gcp_utils_dir)
import big_query_utils
-
-_PROJECT_ID='grpc-testing'
+_PROJECT_ID = 'grpc-testing'
def _upload_netperf_latency_csv_to_bigquery(dataset_id, table_id, result_file):
- with open(result_file, 'r') as f:
- (col1, col2, col3) = f.read().split(',')
- latency50 = float(col1.strip()) * 1000
- latency90 = float(col2.strip()) * 1000
- latency99 = float(col3.strip()) * 1000
-
- scenario_result = {
- 'scenario': {
- 'name': 'netperf_tcp_rr'
- },
- 'summary': {
- 'latency50': latency50,
- 'latency90': latency90,
- 'latency99': latency99
+ with open(result_file, 'r') as f:
+ (col1, col2, col3) = f.read().split(',')
+ latency50 = float(col1.strip()) * 1000
+ latency90 = float(col2.strip()) * 1000
+ latency99 = float(col3.strip()) * 1000
+
+ scenario_result = {
+ 'scenario': {
+ 'name': 'netperf_tcp_rr'
+ },
+ 'summary': {
+ 'latency50': latency50,
+ 'latency90': latency90,
+ 'latency99': latency99
+ }
}
- }
- bq = big_query_utils.create_big_query()
- _create_results_table(bq, dataset_id, table_id)
+ bq = big_query_utils.create_big_query()
+ _create_results_table(bq, dataset_id, table_id)
- if not _insert_result(bq, dataset_id, table_id, scenario_result, flatten=False):
- print('Error uploading result to bigquery.')
- sys.exit(1)
+ if not _insert_result(
+ bq, dataset_id, table_id, scenario_result, flatten=False):
+ print('Error uploading result to bigquery.')
+ sys.exit(1)
def _upload_scenario_result_to_bigquery(dataset_id, table_id, result_file):
- with open(result_file, 'r') as f:
- scenario_result = json.loads(f.read())
+ with open(result_file, 'r') as f:
+ scenario_result = json.loads(f.read())
- bq = big_query_utils.create_big_query()
- _create_results_table(bq, dataset_id, table_id)
+ bq = big_query_utils.create_big_query()
+ _create_results_table(bq, dataset_id, table_id)
- if not _insert_result(bq, dataset_id, table_id, scenario_result):
- print('Error uploading result to bigquery.')
- sys.exit(1)
+ if not _insert_result(bq, dataset_id, table_id, scenario_result):
+ print('Error uploading result to bigquery.')
+ sys.exit(1)
def _insert_result(bq, dataset_id, table_id, scenario_result, flatten=True):
- if flatten:
- _flatten_result_inplace(scenario_result)
- _populate_metadata_inplace(scenario_result)
- row = big_query_utils.make_row(str(uuid.uuid4()), scenario_result)
- return big_query_utils.insert_rows(bq,
- _PROJECT_ID,
- dataset_id,
- table_id,
- [row])
+ if flatten:
+ _flatten_result_inplace(scenario_result)
+ _populate_metadata_inplace(scenario_result)
+ row = big_query_utils.make_row(str(uuid.uuid4()), scenario_result)
+ return big_query_utils.insert_rows(bq, _PROJECT_ID, dataset_id, table_id,
+ [row])
def _create_results_table(bq, dataset_id, table_id):
- with open(os.path.dirname(__file__) + '/scenario_result_schema.json', 'r') as f:
- table_schema = json.loads(f.read())
- desc = 'Results of performance benchmarks.'
- return big_query_utils.create_table2(bq, _PROJECT_ID, dataset_id,
- table_id, table_schema, desc)
+ with open(os.path.dirname(__file__) + '/scenario_result_schema.json',
+ 'r') as f:
+ table_schema = json.loads(f.read())
+ desc = 'Results of performance benchmarks.'
+ return big_query_utils.create_table2(bq, _PROJECT_ID, dataset_id, table_id,
+ table_schema, desc)
def _flatten_result_inplace(scenario_result):
- """Bigquery is not really great for handling deeply nested data
+ """Bigquery is not really great for handling deeply nested data
and repeated fields. To maintain values of some fields while keeping
the schema relatively simple, we artificially leave some of the fields
as JSON strings.
"""
- scenario_result['scenario']['clientConfig'] = json.dumps(scenario_result['scenario']['clientConfig'])
- scenario_result['scenario']['serverConfig'] = json.dumps(scenario_result['scenario']['serverConfig'])
- scenario_result['latencies'] = json.dumps(scenario_result['latencies'])
- scenario_result['serverCpuStats'] = []
- for stats in scenario_result['serverStats']:
- scenario_result['serverCpuStats'].append(dict())
- scenario_result['serverCpuStats'][-1]['totalCpuTime'] = stats.pop('totalCpuTime', None)
- scenario_result['serverCpuStats'][-1]['idleCpuTime'] = stats.pop('idleCpuTime', None)
- for stats in scenario_result['clientStats']:
- stats['latencies'] = json.dumps(stats['latencies'])
- stats.pop('requestResults', None)
- scenario_result['serverCores'] = json.dumps(scenario_result['serverCores'])
- scenario_result['clientSuccess'] = json.dumps(scenario_result['clientSuccess'])
- scenario_result['serverSuccess'] = json.dumps(scenario_result['serverSuccess'])
- scenario_result['requestResults'] = json.dumps(scenario_result.get('requestResults', []))
- scenario_result['serverCpuUsage'] = scenario_result['summary'].pop('serverCpuUsage', None)
- scenario_result['summary'].pop('successfulRequestsPerSecond', None)
- scenario_result['summary'].pop('failedRequestsPerSecond', None)
- massage_qps_stats.massage_qps_stats(scenario_result)
+ scenario_result['scenario']['clientConfig'] = json.dumps(
+ scenario_result['scenario']['clientConfig'])
+ scenario_result['scenario']['serverConfig'] = json.dumps(
+ scenario_result['scenario']['serverConfig'])
+ scenario_result['latencies'] = json.dumps(scenario_result['latencies'])
+ scenario_result['serverCpuStats'] = []
+ for stats in scenario_result['serverStats']:
+ scenario_result['serverCpuStats'].append(dict())
+ scenario_result['serverCpuStats'][-1]['totalCpuTime'] = stats.pop(
+ 'totalCpuTime', None)
+ scenario_result['serverCpuStats'][-1]['idleCpuTime'] = stats.pop(
+ 'idleCpuTime', None)
+ for stats in scenario_result['clientStats']:
+ stats['latencies'] = json.dumps(stats['latencies'])
+ stats.pop('requestResults', None)
+ scenario_result['serverCores'] = json.dumps(scenario_result['serverCores'])
+ scenario_result['clientSuccess'] = json.dumps(
+ scenario_result['clientSuccess'])
+ scenario_result['serverSuccess'] = json.dumps(
+ scenario_result['serverSuccess'])
+ scenario_result['requestResults'] = json.dumps(
+ scenario_result.get('requestResults', []))
+ scenario_result['serverCpuUsage'] = scenario_result['summary'].pop(
+ 'serverCpuUsage', None)
+ scenario_result['summary'].pop('successfulRequestsPerSecond', None)
+ scenario_result['summary'].pop('failedRequestsPerSecond', None)
+ massage_qps_stats.massage_qps_stats(scenario_result)
def _populate_metadata_inplace(scenario_result):
- """Populates metadata based on environment variables set by Jenkins."""
- # NOTE: Grabbing the Jenkins environment variables will only work if the
- # driver is running locally on the same machine where Jenkins has started
- # the job. For our setup, this is currently the case, so just assume that.
- build_number = os.getenv('BUILD_NUMBER')
- build_url = os.getenv('BUILD_URL')
- job_name = os.getenv('JOB_NAME')
- git_commit = os.getenv('GIT_COMMIT')
- # actual commit is the actual head of PR that is getting tested
- git_actual_commit = os.getenv('ghprbActualCommit')
-
- utc_timestamp = str(calendar.timegm(time.gmtime()))
- metadata = {'created': utc_timestamp}
-
- if build_number:
- metadata['buildNumber'] = build_number
- if build_url:
- metadata['buildUrl'] = build_url
- if job_name:
- metadata['jobName'] = job_name
- if git_commit:
- metadata['gitCommit'] = git_commit
- if git_actual_commit:
- metadata['gitActualCommit'] = git_actual_commit
-
- scenario_result['metadata'] = metadata
+ """Populates metadata based on environment variables set by Jenkins."""
+ # NOTE: Grabbing the Jenkins environment variables will only work if the
+ # driver is running locally on the same machine where Jenkins has started
+ # the job. For our setup, this is currently the case, so just assume that.
+ build_number = os.getenv('BUILD_NUMBER')
+ build_url = os.getenv('BUILD_URL')
+ job_name = os.getenv('JOB_NAME')
+ git_commit = os.getenv('GIT_COMMIT')
+ # actual commit is the actual head of PR that is getting tested
+ git_actual_commit = os.getenv('ghprbActualCommit')
+
+ utc_timestamp = str(calendar.timegm(time.gmtime()))
+ metadata = {'created': utc_timestamp}
+
+ if build_number:
+ metadata['buildNumber'] = build_number
+ if build_url:
+ metadata['buildUrl'] = build_url
+ if job_name:
+ metadata['jobName'] = job_name
+ if git_commit:
+ metadata['gitCommit'] = git_commit
+ if git_actual_commit:
+ metadata['gitActualCommit'] = git_actual_commit
+
+ scenario_result['metadata'] = metadata
argp = argparse.ArgumentParser(description='Upload result to big query.')
-argp.add_argument('--bq_result_table', required=True, default=None, type=str,
- help='Bigquery "dataset.table" to upload results to.')
-argp.add_argument('--file_to_upload', default='scenario_result.json', type=str,
- help='Report file to upload.')
-argp.add_argument('--file_format',
- choices=['scenario_result','netperf_latency_csv'],
- default='scenario_result',
- help='Format of the file to upload.')
+argp.add_argument(
+ '--bq_result_table',
+ required=True,
+ default=None,
+ type=str,
+ help='Bigquery "dataset.table" to upload results to.')
+argp.add_argument(
+ '--file_to_upload',
+ default='scenario_result.json',
+ type=str,
+ help='Report file to upload.')
+argp.add_argument(
+ '--file_format',
+ choices=['scenario_result', 'netperf_latency_csv'],
+ default='scenario_result',
+ help='Format of the file to upload.')
args = argp.parse_args()
dataset_id, table_id = args.bq_result_table.split('.', 2)
if args.file_format == 'netperf_latency_csv':
- _upload_netperf_latency_csv_to_bigquery(dataset_id, table_id, args.file_to_upload)
+ _upload_netperf_latency_csv_to_bigquery(dataset_id, table_id,
+ args.file_to_upload)
else:
- _upload_scenario_result_to_bigquery(dataset_id, table_id, args.file_to_upload)
+ _upload_scenario_result_to_bigquery(dataset_id, table_id,
+ args.file_to_upload)
print('Successfully uploaded %s to BigQuery.\n' % args.file_to_upload)
diff --git a/tools/run_tests/performance/build_performance.sh b/tools/run_tests/performance/build_performance.sh
index e46d4e0040..22e0ca9fa0 100755
--- a/tools/run_tests/performance/build_performance.sh
+++ b/tools/run_tests/performance/build_performance.sh
@@ -16,7 +16,7 @@
source ~/.rvm/scripts/rvm
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
CONFIG=${CONFIG:-opt}
@@ -28,10 +28,11 @@ then
# TODO(jtattermusch): not embedding OpenSSL breaks the C# build because
# grpc_csharp_ext needs OpenSSL embedded and some intermediate files from
# this build will be reused.
- make CONFIG=${CONFIG} EMBED_OPENSSL=true EMBED_ZLIB=true qps_worker qps_json_driver -j8
+ make CONFIG="${CONFIG}" EMBED_OPENSSL=true EMBED_ZLIB=true qps_worker qps_json_driver -j8
fi
-for language in $@
+PHP_ALREADY_BUILT=""
+for language in "$@"
do
case "$language" in
"c++")
@@ -43,11 +44,19 @@ do
"go")
tools/run_tests/performance/build_performance_go.sh
;;
+ "php7"|"php7_protobuf_c")
+ if [ -n "$PHP_ALREADY_BUILT" ]; then
+ echo "Skipping PHP build as already built by $PHP_ALREADY_BUILT"
+ else
+ PHP_ALREADY_BUILT=$language
+ tools/run_tests/performance/build_performance_php7.sh
+ fi
+ ;;
"csharp")
- python tools/run_tests/run_tests.py -l $language -c $CONFIG --build_only -j 8 --compiler coreclr
+ python tools/run_tests/run_tests.py -l "$language" -c "$CONFIG" --build_only -j 8 --compiler coreclr
;;
*)
- python tools/run_tests/run_tests.py -l $language -c $CONFIG --build_only -j 8
+ python tools/run_tests/run_tests.py -l "$language" -c "$CONFIG" --build_only -j 8
;;
esac
done
diff --git a/tools/run_tests/performance/build_performance_go.sh b/tools/run_tests/performance/build_performance_go.sh
index 5e97fb68d3..812728d4ce 100755
--- a/tools/run_tests/performance/build_performance_go.sh
+++ b/tools/run_tests/performance/build_performance_go.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
export GOPATH=$(pwd)/../gopath
@@ -24,6 +24,6 @@ go get google.golang.org/grpc
rm -rf "${GOPATH}/src/google.golang.org/grpc"
# Get the revision of grpc-go we want to test
-git clone --recursive ../grpc-go ${GOPATH}/src/google.golang.org/grpc
+git clone --recursive ../grpc-go "${GOPATH}/src/google.golang.org/grpc"
-(cd ${GOPATH}/src/google.golang.org/grpc/benchmark/worker && go install)
+(cd "${GOPATH}/src/google.golang.org/grpc/benchmark/worker" && go install)
diff --git a/tools/run_tests/helper_scripts/build_node.sh b/tools/run_tests/performance/build_performance_php7.sh
index adae4a1e0f..37ca9ee877 100755
--- a/tools/run_tests/helper_scripts/build_node.sh
+++ b/tools/run_tests/performance/build_performance_php7.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-
-# Copyright 2015 gRPC authors.
+# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,21 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-NODE_VERSION=$1
-source ~/.nvm/nvm.sh
-
-nvm use $NODE_VERSION
set -ex
+cd "$(dirname "$0")/../../.."
CONFIG=${CONFIG:-opt}
+python tools/run_tests/run_tests.py -l php7 -c "$CONFIG" --build_only -j 8
-# change to grpc repo root
-cd $(dirname $0)/../../..
-
-case "$CONFIG" in
- 'dbg') config_flags='--debug' ;;
- 'gcov') config_flags="--debug --grpc_gcov=true" ;;
- *) config_flag='--release' ;;
-esac
+# Set up all dependences needed for PHP QPS test
+cd src/php/tests/qps
+composer install
+# Install protobuf C-extension for php
+cd vendor/google/protobuf/php/ext/google/protobuf
+phpize
+./configure
+make
-npm install --unsafe-perm --build-from-source $config_flag
diff --git a/tools/run_tests/performance/kill_workers.sh b/tools/run_tests/performance/kill_workers.sh
index dd17eea5f2..95a5bf5dcb 100755
--- a/tools/run_tests/performance/kill_workers.sh
+++ b/tools/run_tests/performance/kill_workers.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
# Make sure there are no pre-existing QPS workers around before starting
# the performance test suite
@@ -24,16 +24,17 @@ cd $(dirname $0)/../../..
killall -9 qps_worker || true
# C#
+# shellcheck disable=SC2009
ps -C mono -o pid=,cmd= | grep QpsWorker | awk '{print $1}' | xargs kill -9 || true
+# shellcheck disable=SC2009
ps -C dotnet -o pid=,cmd= | grep QpsWorker | awk '{print $1}' | xargs kill -9 || true
# Ruby
+# shellcheck disable=SC2009
ps -C ruby -o pid=,cmd= | grep 'qps/worker.rb' | awk '{print $1}' | xargs kill -9 || true
-# Node
-ps -C node -o pid=,cmd= | grep 'performance/worker.js' | awk '{print $1}' | xargs kill -9 || true
-
# Python
+# shellcheck disable=SC2009
ps -C python -o pid=,cmd= | grep 'qps_worker.py' | awk '{print $1}' | xargs kill -9 || true
# Java
diff --git a/tools/run_tests/performance/massage_qps_stats.py b/tools/run_tests/performance/massage_qps_stats.py
index e1620adad2..790202c43e 100644
--- a/tools/run_tests/performance/massage_qps_stats.py
+++ b/tools/run_tests/performance/massage_qps_stats.py
@@ -15,182 +15,455 @@
# Autogenerated by tools/codegen/core/gen_stats_data.py
import massage_qps_stats_helpers
+
+
def massage_qps_stats(scenario_result):
- for stats in scenario_result["serverStats"] + scenario_result["clientStats"]:
- if "coreStats" not in stats: return
- core_stats = stats["coreStats"]
- del stats["coreStats"]
- stats["core_client_calls_created"] = massage_qps_stats_helpers.counter(core_stats, "client_calls_created")
- stats["core_server_calls_created"] = massage_qps_stats_helpers.counter(core_stats, "server_calls_created")
- stats["core_cqs_created"] = massage_qps_stats_helpers.counter(core_stats, "cqs_created")
- stats["core_client_channels_created"] = massage_qps_stats_helpers.counter(core_stats, "client_channels_created")
- stats["core_client_subchannels_created"] = massage_qps_stats_helpers.counter(core_stats, "client_subchannels_created")
- stats["core_server_channels_created"] = massage_qps_stats_helpers.counter(core_stats, "server_channels_created")
- stats["core_syscall_poll"] = massage_qps_stats_helpers.counter(core_stats, "syscall_poll")
- stats["core_syscall_wait"] = massage_qps_stats_helpers.counter(core_stats, "syscall_wait")
- stats["core_pollset_kick"] = massage_qps_stats_helpers.counter(core_stats, "pollset_kick")
- stats["core_pollset_kicked_without_poller"] = massage_qps_stats_helpers.counter(core_stats, "pollset_kicked_without_poller")
- stats["core_pollset_kicked_again"] = massage_qps_stats_helpers.counter(core_stats, "pollset_kicked_again")
- stats["core_pollset_kick_wakeup_fd"] = massage_qps_stats_helpers.counter(core_stats, "pollset_kick_wakeup_fd")
- stats["core_pollset_kick_wakeup_cv"] = massage_qps_stats_helpers.counter(core_stats, "pollset_kick_wakeup_cv")
- stats["core_pollset_kick_own_thread"] = massage_qps_stats_helpers.counter(core_stats, "pollset_kick_own_thread")
- stats["core_histogram_slow_lookups"] = massage_qps_stats_helpers.counter(core_stats, "histogram_slow_lookups")
- stats["core_syscall_write"] = massage_qps_stats_helpers.counter(core_stats, "syscall_write")
- stats["core_syscall_read"] = massage_qps_stats_helpers.counter(core_stats, "syscall_read")
- stats["core_tcp_backup_pollers_created"] = massage_qps_stats_helpers.counter(core_stats, "tcp_backup_pollers_created")
- stats["core_tcp_backup_poller_polls"] = massage_qps_stats_helpers.counter(core_stats, "tcp_backup_poller_polls")
- stats["core_http2_op_batches"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_batches")
- stats["core_http2_op_cancel"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_cancel")
- stats["core_http2_op_send_initial_metadata"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_send_initial_metadata")
- stats["core_http2_op_send_message"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_send_message")
- stats["core_http2_op_send_trailing_metadata"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_send_trailing_metadata")
- stats["core_http2_op_recv_initial_metadata"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_recv_initial_metadata")
- stats["core_http2_op_recv_message"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_recv_message")
- stats["core_http2_op_recv_trailing_metadata"] = massage_qps_stats_helpers.counter(core_stats, "http2_op_recv_trailing_metadata")
- stats["core_http2_settings_writes"] = massage_qps_stats_helpers.counter(core_stats, "http2_settings_writes")
- stats["core_http2_pings_sent"] = massage_qps_stats_helpers.counter(core_stats, "http2_pings_sent")
- stats["core_http2_writes_begun"] = massage_qps_stats_helpers.counter(core_stats, "http2_writes_begun")
- stats["core_http2_writes_offloaded"] = massage_qps_stats_helpers.counter(core_stats, "http2_writes_offloaded")
- stats["core_http2_writes_continued"] = massage_qps_stats_helpers.counter(core_stats, "http2_writes_continued")
- stats["core_http2_partial_writes"] = massage_qps_stats_helpers.counter(core_stats, "http2_partial_writes")
- stats["core_http2_initiate_write_due_to_initial_write"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_initial_write")
- stats["core_http2_initiate_write_due_to_start_new_stream"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_start_new_stream")
- stats["core_http2_initiate_write_due_to_send_message"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_send_message")
- stats["core_http2_initiate_write_due_to_send_initial_metadata"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_send_initial_metadata")
- stats["core_http2_initiate_write_due_to_send_trailing_metadata"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_send_trailing_metadata")
- stats["core_http2_initiate_write_due_to_retry_send_ping"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_retry_send_ping")
- stats["core_http2_initiate_write_due_to_continue_pings"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_continue_pings")
- stats["core_http2_initiate_write_due_to_goaway_sent"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_goaway_sent")
- stats["core_http2_initiate_write_due_to_rst_stream"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_rst_stream")
- stats["core_http2_initiate_write_due_to_close_from_api"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_close_from_api")
- stats["core_http2_initiate_write_due_to_stream_flow_control"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_stream_flow_control")
- stats["core_http2_initiate_write_due_to_transport_flow_control"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_transport_flow_control")
- stats["core_http2_initiate_write_due_to_send_settings"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_send_settings")
- stats["core_http2_initiate_write_due_to_bdp_estimator_ping"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_bdp_estimator_ping")
- stats["core_http2_initiate_write_due_to_flow_control_unstalled_by_setting"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_flow_control_unstalled_by_setting")
- stats["core_http2_initiate_write_due_to_flow_control_unstalled_by_update"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_flow_control_unstalled_by_update")
- stats["core_http2_initiate_write_due_to_application_ping"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_application_ping")
- stats["core_http2_initiate_write_due_to_keepalive_ping"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_keepalive_ping")
- stats["core_http2_initiate_write_due_to_transport_flow_control_unstalled"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_transport_flow_control_unstalled")
- stats["core_http2_initiate_write_due_to_ping_response"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_ping_response")
- stats["core_http2_initiate_write_due_to_force_rst_stream"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_force_rst_stream")
- stats["core_hpack_recv_indexed"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_indexed")
- stats["core_hpack_recv_lithdr_incidx"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_lithdr_incidx")
- stats["core_hpack_recv_lithdr_incidx_v"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_lithdr_incidx_v")
- stats["core_hpack_recv_lithdr_notidx"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_lithdr_notidx")
- stats["core_hpack_recv_lithdr_notidx_v"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_lithdr_notidx_v")
- stats["core_hpack_recv_lithdr_nvridx"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_lithdr_nvridx")
- stats["core_hpack_recv_lithdr_nvridx_v"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_lithdr_nvridx_v")
- stats["core_hpack_recv_uncompressed"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_uncompressed")
- stats["core_hpack_recv_huffman"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_huffman")
- stats["core_hpack_recv_binary"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_binary")
- stats["core_hpack_recv_binary_base64"] = massage_qps_stats_helpers.counter(core_stats, "hpack_recv_binary_base64")
- stats["core_hpack_send_indexed"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_indexed")
- stats["core_hpack_send_lithdr_incidx"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_lithdr_incidx")
- stats["core_hpack_send_lithdr_incidx_v"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_lithdr_incidx_v")
- stats["core_hpack_send_lithdr_notidx"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_lithdr_notidx")
- stats["core_hpack_send_lithdr_notidx_v"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_lithdr_notidx_v")
- stats["core_hpack_send_lithdr_nvridx"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_lithdr_nvridx")
- stats["core_hpack_send_lithdr_nvridx_v"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_lithdr_nvridx_v")
- stats["core_hpack_send_uncompressed"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_uncompressed")
- stats["core_hpack_send_huffman"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_huffman")
- stats["core_hpack_send_binary"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_binary")
- stats["core_hpack_send_binary_base64"] = massage_qps_stats_helpers.counter(core_stats, "hpack_send_binary_base64")
- stats["core_combiner_locks_initiated"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_initiated")
- stats["core_combiner_locks_scheduled_items"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_scheduled_items")
- stats["core_combiner_locks_scheduled_final_items"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_scheduled_final_items")
- stats["core_combiner_locks_offloaded"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_offloaded")
- stats["core_executor_scheduled_short_items"] = massage_qps_stats_helpers.counter(core_stats, "executor_scheduled_short_items")
- stats["core_executor_scheduled_long_items"] = massage_qps_stats_helpers.counter(core_stats, "executor_scheduled_long_items")
- stats["core_executor_scheduled_to_self"] = massage_qps_stats_helpers.counter(core_stats, "executor_scheduled_to_self")
- stats["core_executor_wakeup_initiated"] = massage_qps_stats_helpers.counter(core_stats, "executor_wakeup_initiated")
- stats["core_executor_queue_drained"] = massage_qps_stats_helpers.counter(core_stats, "executor_queue_drained")
- stats["core_executor_push_retries"] = massage_qps_stats_helpers.counter(core_stats, "executor_push_retries")
- stats["core_executor_threads_created"] = massage_qps_stats_helpers.counter(core_stats, "executor_threads_created")
- stats["core_executor_threads_used"] = massage_qps_stats_helpers.counter(core_stats, "executor_threads_used")
- stats["core_server_requested_calls"] = massage_qps_stats_helpers.counter(core_stats, "server_requested_calls")
- stats["core_server_slowpath_requests_queued"] = massage_qps_stats_helpers.counter(core_stats, "server_slowpath_requests_queued")
- h = massage_qps_stats_helpers.histogram(core_stats, "call_initial_size")
- stats["core_call_initial_size"] = ",".join("%f" % x for x in h.buckets)
- stats["core_call_initial_size_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_call_initial_size_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_call_initial_size_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_call_initial_size_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "poll_events_returned")
- stats["core_poll_events_returned"] = ",".join("%f" % x for x in h.buckets)
- stats["core_poll_events_returned_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_poll_events_returned_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_poll_events_returned_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_poll_events_returned_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "tcp_write_size")
- stats["core_tcp_write_size"] = ",".join("%f" % x for x in h.buckets)
- stats["core_tcp_write_size_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_tcp_write_size_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_tcp_write_size_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_tcp_write_size_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "tcp_write_iov_size")
- stats["core_tcp_write_iov_size"] = ",".join("%f" % x for x in h.buckets)
- stats["core_tcp_write_iov_size_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_tcp_write_iov_size_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_tcp_write_iov_size_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_tcp_write_iov_size_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "tcp_read_size")
- stats["core_tcp_read_size"] = ",".join("%f" % x for x in h.buckets)
- stats["core_tcp_read_size_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_tcp_read_size_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_tcp_read_size_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_tcp_read_size_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "tcp_read_offer")
- stats["core_tcp_read_offer"] = ",".join("%f" % x for x in h.buckets)
- stats["core_tcp_read_offer_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_tcp_read_offer_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_tcp_read_offer_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_tcp_read_offer_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "tcp_read_offer_iov_size")
- stats["core_tcp_read_offer_iov_size"] = ",".join("%f" % x for x in h.buckets)
- stats["core_tcp_read_offer_iov_size_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_tcp_read_offer_iov_size_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_tcp_read_offer_iov_size_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_tcp_read_offer_iov_size_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "http2_send_message_size")
- stats["core_http2_send_message_size"] = ",".join("%f" % x for x in h.buckets)
- stats["core_http2_send_message_size_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_http2_send_message_size_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_http2_send_message_size_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_http2_send_message_size_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "http2_send_initial_metadata_per_write")
- stats["core_http2_send_initial_metadata_per_write"] = ",".join("%f" % x for x in h.buckets)
- stats["core_http2_send_initial_metadata_per_write_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_http2_send_initial_metadata_per_write_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_http2_send_initial_metadata_per_write_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_http2_send_initial_metadata_per_write_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "http2_send_message_per_write")
- stats["core_http2_send_message_per_write"] = ",".join("%f" % x for x in h.buckets)
- stats["core_http2_send_message_per_write_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_http2_send_message_per_write_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_http2_send_message_per_write_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_http2_send_message_per_write_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "http2_send_trailing_metadata_per_write")
- stats["core_http2_send_trailing_metadata_per_write"] = ",".join("%f" % x for x in h.buckets)
- stats["core_http2_send_trailing_metadata_per_write_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_http2_send_trailing_metadata_per_write_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_http2_send_trailing_metadata_per_write_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_http2_send_trailing_metadata_per_write_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "http2_send_flowctl_per_write")
- stats["core_http2_send_flowctl_per_write"] = ",".join("%f" % x for x in h.buckets)
- stats["core_http2_send_flowctl_per_write_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_http2_send_flowctl_per_write_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_http2_send_flowctl_per_write_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_http2_send_flowctl_per_write_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "executor_closures_per_wakeup")
- stats["core_executor_closures_per_wakeup"] = ",".join("%f" % x for x in h.buckets)
- stats["core_executor_closures_per_wakeup_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_executor_closures_per_wakeup_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_executor_closures_per_wakeup_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_executor_closures_per_wakeup_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
- h = massage_qps_stats_helpers.histogram(core_stats, "server_cqs_checked")
- stats["core_server_cqs_checked"] = ",".join("%f" % x for x in h.buckets)
- stats["core_server_cqs_checked_bkts"] = ",".join("%f" % x for x in h.boundaries)
- stats["core_server_cqs_checked_50p"] = massage_qps_stats_helpers.percentile(h.buckets, 50, h.boundaries)
- stats["core_server_cqs_checked_95p"] = massage_qps_stats_helpers.percentile(h.buckets, 95, h.boundaries)
- stats["core_server_cqs_checked_99p"] = massage_qps_stats_helpers.percentile(h.buckets, 99, h.boundaries)
+ for stats in scenario_result["serverStats"] + scenario_result["clientStats"]:
+ if "coreStats" not in stats: return
+ core_stats = stats["coreStats"]
+ del stats["coreStats"]
+ stats["core_client_calls_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "client_calls_created")
+ stats["core_server_calls_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "server_calls_created")
+ stats["core_cqs_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "cqs_created")
+ stats[
+ "core_client_channels_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "client_channels_created")
+ stats[
+ "core_client_subchannels_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "client_subchannels_created")
+ stats[
+ "core_server_channels_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "server_channels_created")
+ stats["core_syscall_poll"] = massage_qps_stats_helpers.counter(
+ core_stats, "syscall_poll")
+ stats["core_syscall_wait"] = massage_qps_stats_helpers.counter(
+ core_stats, "syscall_wait")
+ stats["core_pollset_kick"] = massage_qps_stats_helpers.counter(
+ core_stats, "pollset_kick")
+ stats[
+ "core_pollset_kicked_without_poller"] = massage_qps_stats_helpers.counter(
+ core_stats, "pollset_kicked_without_poller")
+ stats["core_pollset_kicked_again"] = massage_qps_stats_helpers.counter(
+ core_stats, "pollset_kicked_again")
+ stats[
+ "core_pollset_kick_wakeup_fd"] = massage_qps_stats_helpers.counter(
+ core_stats, "pollset_kick_wakeup_fd")
+ stats[
+ "core_pollset_kick_wakeup_cv"] = massage_qps_stats_helpers.counter(
+ core_stats, "pollset_kick_wakeup_cv")
+ stats[
+ "core_pollset_kick_own_thread"] = massage_qps_stats_helpers.counter(
+ core_stats, "pollset_kick_own_thread")
+ stats[
+ "core_histogram_slow_lookups"] = massage_qps_stats_helpers.counter(
+ core_stats, "histogram_slow_lookups")
+ stats["core_syscall_write"] = massage_qps_stats_helpers.counter(
+ core_stats, "syscall_write")
+ stats["core_syscall_read"] = massage_qps_stats_helpers.counter(
+ core_stats, "syscall_read")
+ stats[
+ "core_tcp_backup_pollers_created"] = massage_qps_stats_helpers.counter(
+ core_stats, "tcp_backup_pollers_created")
+ stats[
+ "core_tcp_backup_poller_polls"] = massage_qps_stats_helpers.counter(
+ core_stats, "tcp_backup_poller_polls")
+ stats["core_http2_op_batches"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_batches")
+ stats["core_http2_op_cancel"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_cancel")
+ stats[
+ "core_http2_op_send_initial_metadata"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_send_initial_metadata")
+ stats["core_http2_op_send_message"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_send_message")
+ stats[
+ "core_http2_op_send_trailing_metadata"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_send_trailing_metadata")
+ stats[
+ "core_http2_op_recv_initial_metadata"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_recv_initial_metadata")
+ stats["core_http2_op_recv_message"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_recv_message")
+ stats[
+ "core_http2_op_recv_trailing_metadata"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_op_recv_trailing_metadata")
+ stats["core_http2_settings_writes"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_settings_writes")
+ stats["core_http2_pings_sent"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_pings_sent")
+ stats["core_http2_writes_begun"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_writes_begun")
+ stats[
+ "core_http2_writes_offloaded"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_writes_offloaded")
+ stats[
+ "core_http2_writes_continued"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_writes_continued")
+ stats["core_http2_partial_writes"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_partial_writes")
+ stats[
+ "core_http2_initiate_write_due_to_initial_write"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_initial_write")
+ stats[
+ "core_http2_initiate_write_due_to_start_new_stream"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_start_new_stream")
+ stats[
+ "core_http2_initiate_write_due_to_send_message"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_send_message")
+ stats[
+ "core_http2_initiate_write_due_to_send_initial_metadata"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_send_initial_metadata")
+ stats[
+ "core_http2_initiate_write_due_to_send_trailing_metadata"] = massage_qps_stats_helpers.counter(
+ core_stats,
+ "http2_initiate_write_due_to_send_trailing_metadata")
+ stats[
+ "core_http2_initiate_write_due_to_retry_send_ping"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_retry_send_ping")
+ stats[
+ "core_http2_initiate_write_due_to_continue_pings"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_continue_pings")
+ stats[
+ "core_http2_initiate_write_due_to_goaway_sent"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_goaway_sent")
+ stats[
+ "core_http2_initiate_write_due_to_rst_stream"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_rst_stream")
+ stats[
+ "core_http2_initiate_write_due_to_close_from_api"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_close_from_api")
+ stats[
+ "core_http2_initiate_write_due_to_stream_flow_control"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_stream_flow_control")
+ stats[
+ "core_http2_initiate_write_due_to_transport_flow_control"] = massage_qps_stats_helpers.counter(
+ core_stats,
+ "http2_initiate_write_due_to_transport_flow_control")
+ stats[
+ "core_http2_initiate_write_due_to_send_settings"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_send_settings")
+ stats[
+ "core_http2_initiate_write_due_to_bdp_estimator_ping"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_bdp_estimator_ping")
+ stats[
+ "core_http2_initiate_write_due_to_flow_control_unstalled_by_setting"] = massage_qps_stats_helpers.counter(
+ core_stats,
+ "http2_initiate_write_due_to_flow_control_unstalled_by_setting")
+ stats[
+ "core_http2_initiate_write_due_to_flow_control_unstalled_by_update"] = massage_qps_stats_helpers.counter(
+ core_stats,
+ "http2_initiate_write_due_to_flow_control_unstalled_by_update")
+ stats[
+ "core_http2_initiate_write_due_to_application_ping"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_application_ping")
+ stats[
+ "core_http2_initiate_write_due_to_keepalive_ping"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_keepalive_ping")
+ stats[
+ "core_http2_initiate_write_due_to_transport_flow_control_unstalled"] = massage_qps_stats_helpers.counter(
+ core_stats,
+ "http2_initiate_write_due_to_transport_flow_control_unstalled")
+ stats[
+ "core_http2_initiate_write_due_to_ping_response"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_ping_response")
+ stats[
+ "core_http2_initiate_write_due_to_force_rst_stream"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_initiate_write_due_to_force_rst_stream")
+ stats[
+ "core_http2_spurious_writes_begun"] = massage_qps_stats_helpers.counter(
+ core_stats, "http2_spurious_writes_begun")
+ stats["core_hpack_recv_indexed"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_indexed")
+ stats[
+ "core_hpack_recv_lithdr_incidx"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_lithdr_incidx")
+ stats[
+ "core_hpack_recv_lithdr_incidx_v"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_lithdr_incidx_v")
+ stats[
+ "core_hpack_recv_lithdr_notidx"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_lithdr_notidx")
+ stats[
+ "core_hpack_recv_lithdr_notidx_v"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_lithdr_notidx_v")
+ stats[
+ "core_hpack_recv_lithdr_nvridx"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_lithdr_nvridx")
+ stats[
+ "core_hpack_recv_lithdr_nvridx_v"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_lithdr_nvridx_v")
+ stats[
+ "core_hpack_recv_uncompressed"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_uncompressed")
+ stats["core_hpack_recv_huffman"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_huffman")
+ stats["core_hpack_recv_binary"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_binary")
+ stats[
+ "core_hpack_recv_binary_base64"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_recv_binary_base64")
+ stats["core_hpack_send_indexed"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_indexed")
+ stats[
+ "core_hpack_send_lithdr_incidx"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_lithdr_incidx")
+ stats[
+ "core_hpack_send_lithdr_incidx_v"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_lithdr_incidx_v")
+ stats[
+ "core_hpack_send_lithdr_notidx"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_lithdr_notidx")
+ stats[
+ "core_hpack_send_lithdr_notidx_v"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_lithdr_notidx_v")
+ stats[
+ "core_hpack_send_lithdr_nvridx"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_lithdr_nvridx")
+ stats[
+ "core_hpack_send_lithdr_nvridx_v"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_lithdr_nvridx_v")
+ stats[
+ "core_hpack_send_uncompressed"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_uncompressed")
+ stats["core_hpack_send_huffman"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_huffman")
+ stats["core_hpack_send_binary"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_binary")
+ stats[
+ "core_hpack_send_binary_base64"] = massage_qps_stats_helpers.counter(
+ core_stats, "hpack_send_binary_base64")
+ stats[
+ "core_combiner_locks_initiated"] = massage_qps_stats_helpers.counter(
+ core_stats, "combiner_locks_initiated")
+ stats[
+ "core_combiner_locks_scheduled_items"] = massage_qps_stats_helpers.counter(
+ core_stats, "combiner_locks_scheduled_items")
+ stats[
+ "core_combiner_locks_scheduled_final_items"] = massage_qps_stats_helpers.counter(
+ core_stats, "combiner_locks_scheduled_final_items")
+ stats[
+ "core_combiner_locks_offloaded"] = massage_qps_stats_helpers.counter(
+ core_stats, "combiner_locks_offloaded")
+ stats[
+ "core_call_combiner_locks_initiated"] = massage_qps_stats_helpers.counter(
+ core_stats, "call_combiner_locks_initiated")
+ stats[
+ "core_call_combiner_locks_scheduled_items"] = massage_qps_stats_helpers.counter(
+ core_stats, "call_combiner_locks_scheduled_items")
+ stats[
+ "core_call_combiner_set_notify_on_cancel"] = massage_qps_stats_helpers.counter(
+ core_stats, "call_combiner_set_notify_on_cancel")
+ stats[
+ "core_call_combiner_cancelled"] = massage_qps_stats_helpers.counter(
+ core_stats, "call_combiner_cancelled")
+ stats[
+ "core_executor_scheduled_short_items"] = massage_qps_stats_helpers.counter(
+ core_stats, "executor_scheduled_short_items")
+ stats[
+ "core_executor_scheduled_long_items"] = massage_qps_stats_helpers.counter(
+ core_stats, "executor_scheduled_long_items")
+ stats[
+ "core_executor_scheduled_to_self"] = massage_qps_stats_helpers.counter(
+ core_stats, "executor_scheduled_to_self")
+ stats[
+ "core_executor_wakeup_initiated"] = massage_qps_stats_helpers.counter(
+ core_stats, "executor_wakeup_initiated")
+ stats[
+ "core_executor_queue_drained"] = massage_qps_stats_helpers.counter(
+ core_stats, "executor_queue_drained")
+ stats["core_executor_push_retries"] = massage_qps_stats_helpers.counter(
+ core_stats, "executor_push_retries")
+ stats[
+ "core_server_requested_calls"] = massage_qps_stats_helpers.counter(
+ core_stats, "server_requested_calls")
+ stats[
+ "core_server_slowpath_requests_queued"] = massage_qps_stats_helpers.counter(
+ core_stats, "server_slowpath_requests_queued")
+ stats[
+ "core_cq_ev_queue_trylock_failures"] = massage_qps_stats_helpers.counter(
+ core_stats, "cq_ev_queue_trylock_failures")
+ stats[
+ "core_cq_ev_queue_trylock_successes"] = massage_qps_stats_helpers.counter(
+ core_stats, "cq_ev_queue_trylock_successes")
+ stats[
+ "core_cq_ev_queue_transient_pop_failures"] = massage_qps_stats_helpers.counter(
+ core_stats, "cq_ev_queue_transient_pop_failures")
+ h = massage_qps_stats_helpers.histogram(core_stats, "call_initial_size")
+ stats["core_call_initial_size"] = ",".join("%f" % x for x in h.buckets)
+ stats["core_call_initial_size_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_call_initial_size_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_call_initial_size_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_call_initial_size_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "poll_events_returned")
+ stats["core_poll_events_returned"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_poll_events_returned_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_poll_events_returned_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_poll_events_returned_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_poll_events_returned_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats, "tcp_write_size")
+ stats["core_tcp_write_size"] = ",".join("%f" % x for x in h.buckets)
+ stats["core_tcp_write_size_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats["core_tcp_write_size_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats["core_tcp_write_size_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats["core_tcp_write_size_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "tcp_write_iov_size")
+ stats["core_tcp_write_iov_size"] = ",".join("%f" % x for x in h.buckets)
+ stats["core_tcp_write_iov_size_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_tcp_write_iov_size_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_tcp_write_iov_size_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_tcp_write_iov_size_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats, "tcp_read_size")
+ stats["core_tcp_read_size"] = ",".join("%f" % x for x in h.buckets)
+ stats["core_tcp_read_size_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats["core_tcp_read_size_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats["core_tcp_read_size_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats["core_tcp_read_size_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats, "tcp_read_offer")
+ stats["core_tcp_read_offer"] = ",".join("%f" % x for x in h.buckets)
+ stats["core_tcp_read_offer_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats["core_tcp_read_offer_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats["core_tcp_read_offer_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats["core_tcp_read_offer_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "tcp_read_offer_iov_size")
+ stats["core_tcp_read_offer_iov_size"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_tcp_read_offer_iov_size_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_tcp_read_offer_iov_size_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_tcp_read_offer_iov_size_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_tcp_read_offer_iov_size_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "http2_send_message_size")
+ stats["core_http2_send_message_size"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_http2_send_message_size_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_http2_send_message_size_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_http2_send_message_size_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_http2_send_message_size_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(
+ core_stats, "http2_send_initial_metadata_per_write")
+ stats["core_http2_send_initial_metadata_per_write"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_http2_send_initial_metadata_per_write_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_http2_send_initial_metadata_per_write_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_http2_send_initial_metadata_per_write_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_http2_send_initial_metadata_per_write_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "http2_send_message_per_write")
+ stats["core_http2_send_message_per_write"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_http2_send_message_per_write_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_http2_send_message_per_write_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_http2_send_message_per_write_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_http2_send_message_per_write_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(
+ core_stats, "http2_send_trailing_metadata_per_write")
+ stats["core_http2_send_trailing_metadata_per_write"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_http2_send_trailing_metadata_per_write_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_http2_send_trailing_metadata_per_write_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_http2_send_trailing_metadata_per_write_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_http2_send_trailing_metadata_per_write_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "http2_send_flowctl_per_write")
+ stats["core_http2_send_flowctl_per_write"] = ",".join(
+ "%f" % x for x in h.buckets)
+ stats["core_http2_send_flowctl_per_write_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_http2_send_flowctl_per_write_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_http2_send_flowctl_per_write_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_http2_send_flowctl_per_write_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
+ h = massage_qps_stats_helpers.histogram(core_stats,
+ "server_cqs_checked")
+ stats["core_server_cqs_checked"] = ",".join("%f" % x for x in h.buckets)
+ stats["core_server_cqs_checked_bkts"] = ",".join(
+ "%f" % x for x in h.boundaries)
+ stats[
+ "core_server_cqs_checked_50p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 50, h.boundaries)
+ stats[
+ "core_server_cqs_checked_95p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 95, h.boundaries)
+ stats[
+ "core_server_cqs_checked_99p"] = massage_qps_stats_helpers.percentile(
+ h.buckets, 99, h.boundaries)
diff --git a/tools/run_tests/performance/massage_qps_stats_helpers.py b/tools/run_tests/performance/massage_qps_stats_helpers.py
index a2fe4ae6c3..108451cd55 100644
--- a/tools/run_tests/performance/massage_qps_stats_helpers.py
+++ b/tools/run_tests/performance/massage_qps_stats_helpers.py
@@ -14,44 +14,49 @@
import collections
+
def _threshold_for_count_below(buckets, boundaries, count_below):
- count_so_far = 0
- for lower_idx in range(0, len(buckets)):
- count_so_far += buckets[lower_idx]
- if count_so_far >= count_below:
- break
- if count_so_far == count_below:
- # this bucket hits the threshold exactly... we should be midway through
- # any run of zero values following the bucket
- for upper_idx in range(lower_idx + 1, len(buckets)):
- if buckets[upper_idx] != 0:
- break
- return (boundaries[lower_idx] + boundaries[upper_idx]) / 2.0
- else:
- # treat values as uniform throughout the bucket, and find where this value
- # should lie
- lower_bound = boundaries[lower_idx]
- upper_bound = boundaries[lower_idx + 1]
- return (upper_bound -
- (upper_bound - lower_bound) * (count_so_far - count_below) /
- float(buckets[lower_idx]))
+ count_so_far = 0
+ for lower_idx in range(0, len(buckets)):
+ count_so_far += buckets[lower_idx]
+ if count_so_far >= count_below:
+ break
+ if count_so_far == count_below:
+ # this bucket hits the threshold exactly... we should be midway through
+ # any run of zero values following the bucket
+ for upper_idx in range(lower_idx + 1, len(buckets)):
+ if buckets[upper_idx] != 0:
+ break
+ return (boundaries[lower_idx] + boundaries[upper_idx]) / 2.0
+ else:
+ # treat values as uniform throughout the bucket, and find where this value
+ # should lie
+ lower_bound = boundaries[lower_idx]
+ upper_bound = boundaries[lower_idx + 1]
+ return (upper_bound - (upper_bound - lower_bound) *
+ (count_so_far - count_below) / float(buckets[lower_idx]))
+
def percentile(buckets, pctl, boundaries):
- return _threshold_for_count_below(
- buckets, boundaries, sum(buckets) * pctl / 100.0)
+ return _threshold_for_count_below(buckets, boundaries,
+ sum(buckets) * pctl / 100.0)
+
def counter(core_stats, name):
- for stat in core_stats['metrics']:
- if stat['name'] == name:
- return int(stat.get('count', 0))
+ for stat in core_stats['metrics']:
+ if stat['name'] == name:
+ return int(stat.get('count', 0))
+
Histogram = collections.namedtuple('Histogram', 'buckets boundaries')
+
+
def histogram(core_stats, name):
- for stat in core_stats['metrics']:
- if stat['name'] == name:
- buckets = []
- boundaries = []
- for b in stat['histogram']['buckets']:
- buckets.append(int(b.get('count', 0)))
- boundaries.append(int(b.get('start', 0)))
- return Histogram(buckets=buckets, boundaries=boundaries)
+ for stat in core_stats['metrics']:
+ if stat['name'] == name:
+ buckets = []
+ boundaries = []
+ for b in stat['histogram']['buckets']:
+ buckets.append(int(b.get('count', 0)))
+ boundaries.append(int(b.get('start', 0)))
+ return Histogram(buckets=buckets, boundaries=boundaries)
diff --git a/tools/run_tests/performance/patch_scenario_results_schema.py b/tools/run_tests/performance/patch_scenario_results_schema.py
index 81ba5381b3..2a2aadc242 100755
--- a/tools/run_tests/performance/patch_scenario_results_schema.py
+++ b/tools/run_tests/performance/patch_scenario_results_schema.py
@@ -25,27 +25,32 @@ import sys
import time
import uuid
-
-gcp_utils_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../../gcp/utils'))
+gcp_utils_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../../gcp/utils'))
sys.path.append(gcp_utils_dir)
import big_query_utils
+_PROJECT_ID = 'grpc-testing'
-_PROJECT_ID='grpc-testing'
def _patch_results_table(dataset_id, table_id):
- bq = big_query_utils.create_big_query()
- with open(os.path.dirname(__file__) + '/scenario_result_schema.json', 'r') as f:
- table_schema = json.loads(f.read())
- desc = 'Results of performance benchmarks.'
- return big_query_utils.patch_table(bq, _PROJECT_ID, dataset_id,
- table_id, table_schema)
-
-
-argp = argparse.ArgumentParser(description='Patch schema of scenario results table.')
-argp.add_argument('--bq_result_table', required=True, default=None, type=str,
- help='Bigquery "dataset.table" to patch.')
+ bq = big_query_utils.create_big_query()
+ with open(os.path.dirname(__file__) + '/scenario_result_schema.json',
+ 'r') as f:
+ table_schema = json.loads(f.read())
+ desc = 'Results of performance benchmarks.'
+ return big_query_utils.patch_table(bq, _PROJECT_ID, dataset_id, table_id,
+ table_schema)
+
+
+argp = argparse.ArgumentParser(
+ description='Patch schema of scenario results table.')
+argp.add_argument(
+ '--bq_result_table',
+ required=True,
+ default=None,
+ type=str,
+ help='Bigquery "dataset.table" to patch.')
args = argp.parse_args()
diff --git a/tools/run_tests/performance/process_local_perf_flamegraphs.sh b/tools/run_tests/performance/process_local_perf_flamegraphs.sh
index d0c22f2070..ccb5b19f2a 100755
--- a/tools/run_tests/performance/process_local_perf_flamegraphs.sh
+++ b/tools/run_tests/performance/process_local_perf_flamegraphs.sh
@@ -13,13 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-mkdir -p $OUTPUT_DIR
+mkdir -p "$OUTPUT_DIR"
-PERF_DATA_FILE=${PERF_BASE_NAME}-perf.data
-PERF_SCRIPT_OUTPUT=${PERF_BASE_NAME}-out.perf
+PERF_DATA_FILE="${PERF_BASE_NAME}-perf.data"
+PERF_SCRIPT_OUTPUT="${PERF_BASE_NAME}-out.perf"
# Generate Flame graphs
echo "running perf script on $PERF_DATA_FILE"
-perf script -i $PERF_DATA_FILE > $PERF_SCRIPT_OUTPUT
+perf script -i "$PERF_DATA_FILE" > "$PERF_SCRIPT_OUTPUT"
-~/FlameGraph/stackcollapse-perf.pl $PERF_SCRIPT_OUTPUT | ~/FlameGraph/flamegraph.pl > ${OUTPUT_DIR}/${OUTPUT_FILENAME}.svg
+~/FlameGraph/stackcollapse-perf.pl "$PERF_SCRIPT_OUTPUT" | ~/FlameGraph/flamegraph.pl > "${OUTPUT_DIR}/${OUTPUT_FILENAME}.svg"
diff --git a/tools/run_tests/performance/process_remote_perf_flamegraphs.sh b/tools/run_tests/performance/process_remote_perf_flamegraphs.sh
index a0c4f6ff32..2ea6b4f2a6 100755
--- a/tools/run_tests/performance/process_remote_perf_flamegraphs.sh
+++ b/tools/run_tests/performance/process_remote_perf_flamegraphs.sh
@@ -13,17 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-mkdir -p $OUTPUT_DIR
+mkdir -p "$OUTPUT_DIR"
-PERF_DATA_FILE=${PERF_BASE_NAME}-perf.data
-PERF_SCRIPT_OUTPUT=${PERF_BASE_NAME}-out.perf
+PERF_DATA_FILE="${PERF_BASE_NAME}-perf.data"
+PERF_SCRIPT_OUTPUT="${PERF_BASE_NAME}-out.perf"
# Generate Flame graphs
echo "running perf script on $USER_AT_HOST with perf.data"
-ssh $USER_AT_HOST "cd ~/performance_workspace/grpc && perf script -i $PERF_DATA_FILE | gzip > ${PERF_SCRIPT_OUTPUT}.gz"
+# shellcheck disable=SC2029
+ssh "$USER_AT_HOST" "cd ~/performance_workspace/grpc && perf script -i $PERF_DATA_FILE | gzip > ${PERF_SCRIPT_OUTPUT}.gz"
-scp $USER_AT_HOST:~/performance_workspace/grpc/$PERF_SCRIPT_OUTPUT.gz .
+scp "$USER_AT_HOST:~/performance_workspace/grpc/$PERF_SCRIPT_OUTPUT.gz" .
-gzip -d -f $PERF_SCRIPT_OUTPUT.gz
+gzip -d -f "$PERF_SCRIPT_OUTPUT.gz"
-~/FlameGraph/stackcollapse-perf.pl --kernel $PERF_SCRIPT_OUTPUT | ~/FlameGraph/flamegraph.pl --color=java --hash > ${OUTPUT_DIR}/${OUTPUT_FILENAME}.svg
+~/FlameGraph/stackcollapse-perf.pl --kernel "$PERF_SCRIPT_OUTPUT" | ~/FlameGraph/flamegraph.pl --color=java --hash > "${OUTPUT_DIR}/${OUTPUT_FILENAME}.svg"
diff --git a/tools/run_tests/performance/remote_host_build.sh b/tools/run_tests/performance/remote_host_build.sh
index 75352e9220..862bd6c05f 100755
--- a/tools/run_tests/performance/remote_host_build.sh
+++ b/tools/run_tests/performance/remote_host_build.sh
@@ -15,7 +15,8 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
# execute the build script remotely
+# shellcheck disable=SC2029
ssh "${USER_AT_HOST}" "CONFIG=${CONFIG} ~/performance_workspace/grpc/tools/run_tests/performance/build_performance.sh $*"
diff --git a/tools/run_tests/performance/remote_host_prepare.sh b/tools/run_tests/performance/remote_host_prepare.sh
index bf91acbddf..d69c85b40e 100755
--- a/tools/run_tests/performance/remote_host_prepare.sh
+++ b/tools/run_tests/performance/remote_host_prepare.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
# TODO(jtattermusch): To be sure there are no running processes that would
# mess with the results, be rough and reboot the slave here
@@ -24,7 +24,7 @@ ssh "${USER_AT_HOST}" "killall -9 qps_worker dotnet mono node ruby worker || tru
# On Windows, killall is not supported & we need to kill all pending workers
# before attempting to delete the workspace
-ssh "${USER_AT_HOST}" "ps -e | egrep 'qps_worker|dotnet' | awk '{print $1}' | xargs kill -9 || true"
+ssh "${USER_AT_HOST}" "ps -e | egrep 'qps_worker|dotnet' | awk '{print \$1}' | xargs kill -9 || true"
# cleanup after previous builds
ssh "${USER_AT_HOST}" "rm -rf ~/performance_workspace && mkdir -p ~/performance_workspace"
@@ -36,4 +36,5 @@ scp ../grpc.tar "${USER_AT_HOST}:~/performance_workspace"
ssh "${USER_AT_HOST}" "tar -xf ~/performance_workspace/grpc.tar -C ~/performance_workspace || tar -xf ~/performance_workspace/grpc.tar -C ~/performance_workspace"
# For consistency with local run, invoke the kill_workers script remotely.
+# shellcheck disable=SC2088
ssh "${USER_AT_HOST}" "~/performance_workspace/grpc/tools/run_tests/performance/kill_workers.sh"
diff --git a/tools/run_tests/performance/run_netperf.sh b/tools/run_tests/performance/run_netperf.sh
index b415ede529..2a32051dac 100755
--- a/tools/run_tests/performance/run_netperf.sh
+++ b/tools/run_tests/performance/run_netperf.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
netperf >netperf_latency.txt -P 0 -t TCP_RR -H "$NETPERF_SERVER_HOST" -- -r 1,1 -o P50_LATENCY,P90_LATENCY,P99_LATENCY
diff --git a/tools/run_tests/performance/run_qps_driver.sh b/tools/run_tests/performance/run_qps_driver.sh
index 1851632da1..2d9e310dec 100755
--- a/tools/run_tests/performance/run_qps_driver.sh
+++ b/tools/run_tests/performance/run_qps_driver.sh
@@ -15,7 +15,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
bins/opt/qps_json_driver "$@"
diff --git a/tools/run_tests/performance/run_worker_csharp.sh b/tools/run_tests/performance/run_worker_csharp.sh
index e2e941f34a..6546d6010b 100755
--- a/tools/run_tests/performance/run_worker_csharp.sh
+++ b/tools/run_tests/performance/run_worker_csharp.sh
@@ -15,9 +15,9 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
# needed to correctly locate testca
cd src/csharp/Grpc.IntegrationTesting.QpsWorker/bin/Release/netcoreapp1.0
-dotnet exec Grpc.IntegrationTesting.QpsWorker.dll $@
+dotnet exec Grpc.IntegrationTesting.QpsWorker.dll "$@"
diff --git a/tools/run_tests/performance/run_worker_go.sh b/tools/run_tests/performance/run_worker_go.sh
index 6d8abb4147..f8e821a265 100755
--- a/tools/run_tests/performance/run_worker_go.sh
+++ b/tools/run_tests/performance/run_worker_go.sh
@@ -15,8 +15,8 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
export GOPATH=$(pwd)/../gopath
-${GOPATH}/bin/worker $@
+"${GOPATH}/bin/worker" "$@"
diff --git a/tools/run_tests/performance/run_worker_java.sh b/tools/run_tests/performance/run_worker_java.sh
index 039a9618e1..cff6faf680 100755
--- a/tools/run_tests/performance/run_worker_java.sh
+++ b/tools/run_tests/performance/run_worker_java.sh
@@ -16,9 +16,9 @@
set -ex
# Enter repo root
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
# Enter the grpc-java repo root (expected to be next to grpc repo root)
cd ../grpc-java
-benchmarks/build/install/grpc-benchmarks/bin/benchmark_worker $@
+benchmarks/build/install/grpc-benchmarks/bin/benchmark_worker "$@"
diff --git a/tools/run_tests/performance/run_worker_php.sh b/tools/run_tests/performance/run_worker_php.sh
index 5d0c4fa4fd..2fe2493e60 100755
--- a/tools/run_tests/performance/run_worker_php.sh
+++ b/tools/run_tests/performance/run_worker_php.sh
@@ -16,13 +16,8 @@
source ~/.rvm/scripts/rvm
set -ex
-repo=$(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
-# First set up all dependences needed for PHP QPS test
-cd $repo
-cd src/php/tests/qps
-composer install
# The proxy worker for PHP is implemented in Ruby
-cd ../../../..
-ruby src/ruby/qps/proxy-worker.rb $@
+ruby src/ruby/qps/proxy-worker.rb "$@"
diff --git a/tools/run_tests/performance/run_worker_python.sh b/tools/run_tests/performance/run_worker_python.sh
index cd7d0ebbae..01241c8296 100755
--- a/tools/run_tests/performance/run_worker_python.sh
+++ b/tools/run_tests/performance/run_worker_python.sh
@@ -15,6 +15,6 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
-PYTHONPATH=src/python/grpcio_tests:src/python/gens py27/bin/python src/python/grpcio_tests/tests/qps/qps_worker.py $@
+PYTHONPATH=src/python/grpcio_tests:src/python/gens py27/bin/python src/python/grpcio_tests/tests/qps/qps_worker.py "$@"
diff --git a/tools/run_tests/performance/run_worker_ruby.sh b/tools/run_tests/performance/run_worker_ruby.sh
index db8a7d8cd6..729c5cec97 100755
--- a/tools/run_tests/performance/run_worker_ruby.sh
+++ b/tools/run_tests/performance/run_worker_ruby.sh
@@ -16,6 +16,6 @@
source ~/.rvm/scripts/rvm
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
-ruby src/ruby/qps/worker.rb $@
+ruby src/ruby/qps/worker.rb "$@"
diff --git a/tools/run_tests/performance/scenario_config.py b/tools/run_tests/performance/scenario_config.py
index 5efc9f5648..f05753154e 100644
--- a/tools/run_tests/performance/scenario_config.py
+++ b/tools/run_tests/performance/scenario_config.py
@@ -16,65 +16,64 @@
import math
-WARMUP_SECONDS=5
-JAVA_WARMUP_SECONDS=15 # Java needs more warmup time for JIT to kick in.
-BENCHMARK_SECONDS=30
-
-SMOKETEST='smoketest'
-SCALABLE='scalable'
-SWEEP='sweep'
-DEFAULT_CATEGORIES=[SCALABLE, SMOKETEST]
-
-SECURE_SECARGS = {'use_test_ca': True,
- 'server_host_override': 'foo.test.google.fr'}
+WARMUP_SECONDS = 5
+JAVA_WARMUP_SECONDS = 15 # Java needs more warmup time for JIT to kick in.
+BENCHMARK_SECONDS = 30
+
+SMOKETEST = 'smoketest'
+SCALABLE = 'scalable'
+INPROC = 'inproc'
+SWEEP = 'sweep'
+DEFAULT_CATEGORIES = [SCALABLE, SMOKETEST]
+
+SECURE_SECARGS = {
+ 'use_test_ca': True,
+ 'server_host_override': 'foo.test.google.fr'
+}
HISTOGRAM_PARAMS = {
- 'resolution': 0.01,
- 'max_possible': 60e9,
+ 'resolution': 0.01,
+ 'max_possible': 60e9,
}
# target number of RPCs outstanding on across all client channels in
# non-ping-pong tests (since we can only specify per-channel numbers, the
# actual target will be slightly higher)
-OUTSTANDING_REQUESTS={
- 'async': 6400,
- 'async-limited': 800,
- 'sync': 1000
-}
+OUTSTANDING_REQUESTS = {'async': 6400, 'async-limited': 800, 'sync': 1000}
# wide is the number of client channels in multi-channel tests (1 otherwise)
-WIDE=64
+WIDE = 64
def _get_secargs(is_secure):
- if is_secure:
- return SECURE_SECARGS
- else:
- return None
+ if is_secure:
+ return SECURE_SECARGS
+ else:
+ return None
def remove_nonproto_fields(scenario):
- """Remove special-purpose that contains some extra info about the scenario
+ """Remove special-purpose that contains some extra info about the scenario
but don't belong to the ScenarioConfig protobuf message"""
- scenario.pop('CATEGORIES', None)
- scenario.pop('CLIENT_LANGUAGE', None)
- scenario.pop('SERVER_LANGUAGE', None)
- scenario.pop('EXCLUDED_POLL_ENGINES', None)
- return scenario
+ scenario.pop('CATEGORIES', None)
+ scenario.pop('CLIENT_LANGUAGE', None)
+ scenario.pop('SERVER_LANGUAGE', None)
+ scenario.pop('EXCLUDED_POLL_ENGINES', None)
+ return scenario
def geometric_progression(start, stop, step):
- n = start
- while n < stop:
- yield int(round(n))
- n *= step
+ n = start
+ while n < stop:
+ yield int(round(n))
+ n *= step
def _payload_type(use_generic_payload, req_size, resp_size):
r = {}
sizes = {
- 'req_size': req_size,
- 'resp_size': resp_size,
+ 'req_size': req_size,
+ 'resp_size': resp_size,
}
if use_generic_payload:
r['bytebuf_params'] = sizes
@@ -82,21 +81,36 @@ def _payload_type(use_generic_payload, req_size, resp_size):
r['simple_params'] = sizes
return r
+
+def _load_params(offered_load):
+ r = {}
+ if offered_load is None:
+ r['closed_loop'] = {}
+ else:
+ load = {}
+ load['offered_load'] = offered_load
+ r['poisson'] = load
+ return r
+
+
def _add_channel_arg(config, key, value):
- if 'channel_args' in config:
- channel_args = config['channel_args']
- else:
- channel_args = []
- config['channel_args'] = channel_args
- arg = {'name': key}
- if isinstance(value, int):
- arg['int_value'] = value
- else:
- arg['str_value'] = value
- channel_args.append(arg)
-
-def _ping_pong_scenario(name, rpc_type,
- client_type, server_type,
+ if 'channel_args' in config:
+ channel_args = config['channel_args']
+ else:
+ channel_args = []
+ config['channel_args'] = channel_args
+ arg = {'name': key}
+ if isinstance(value, int):
+ arg['int_value'] = value
+ else:
+ arg['str_value'] = value
+ channel_args.append(arg)
+
+
+def _ping_pong_scenario(name,
+ rpc_type,
+ client_type,
+ server_type,
secure=True,
use_generic_payload=False,
req_size=0,
@@ -115,917 +129,1035 @@ def _ping_pong_scenario(name, rpc_type,
resource_quota_size=None,
messages_per_stream=None,
excluded_poll_engines=[],
- minimal_stack=False):
- """Creates a basic ping pong scenario."""
- scenario = {
- 'name': name,
- 'num_servers': 1,
- 'num_clients': 1,
- 'client_config': {
- 'client_type': client_type,
- 'security_params': _get_secargs(secure),
- 'outstanding_rpcs_per_channel': 1,
- 'client_channels': 1,
- 'async_client_threads': 1,
- 'threads_per_cq': client_threads_per_cq,
- 'rpc_type': rpc_type,
- 'load_params': {
- 'closed_loop': {}
- },
- 'histogram_params': HISTOGRAM_PARAMS,
- 'channel_args': [],
- },
- 'server_config': {
- 'server_type': server_type,
- 'security_params': _get_secargs(secure),
- 'async_server_threads': async_server_threads,
- 'threads_per_cq': server_threads_per_cq,
- 'channel_args': [],
- },
- 'warmup_seconds': warmup_seconds,
- 'benchmark_seconds': BENCHMARK_SECONDS
- }
- if resource_quota_size:
- scenario['server_config']['resource_quota_size'] = resource_quota_size
- if use_generic_payload:
- if server_type != 'ASYNC_GENERIC_SERVER':
- raise Exception('Use ASYNC_GENERIC_SERVER for generic payload.')
- scenario['server_config']['payload_config'] = _payload_type(use_generic_payload, req_size, resp_size)
-
- scenario['client_config']['payload_config'] = _payload_type(use_generic_payload, req_size, resp_size)
-
- # Optimization target of 'throughput' does not work well with epoll1 polling
- # engine. Use the default value of 'blend'
- optimization_target = 'throughput'
-
- if unconstrained_client:
- outstanding_calls = outstanding if outstanding is not None else OUTSTANDING_REQUESTS[unconstrained_client]
- # clamp buffer usage to something reasonable (16 gig for now)
- MAX_MEMORY_USE = 16 * 1024 * 1024 * 1024
- if outstanding_calls * max(req_size, resp_size) > MAX_MEMORY_USE:
- outstanding_calls = max(1, MAX_MEMORY_USE / max(req_size, resp_size))
- wide = channels if channels is not None else WIDE
- deep = int(math.ceil(1.0 * outstanding_calls / wide))
-
- scenario['num_clients'] = num_clients if num_clients is not None else 0 # use as many clients as available.
- scenario['client_config']['outstanding_rpcs_per_channel'] = deep
- scenario['client_config']['client_channels'] = wide
- scenario['client_config']['async_client_threads'] = 0
- else:
- scenario['client_config']['outstanding_rpcs_per_channel'] = 1
- scenario['client_config']['client_channels'] = 1
- scenario['client_config']['async_client_threads'] = 1
- optimization_target = 'latency'
-
- optimization_channel_arg = {
- 'name': 'grpc.optimization_target',
- 'str_value': optimization_target
- }
- scenario['client_config']['channel_args'].append(optimization_channel_arg)
- scenario['server_config']['channel_args'].append(optimization_channel_arg)
-
- if minimal_stack:
- _add_channel_arg(scenario['client_config'], 'grpc.minimal_stack', 1)
- _add_channel_arg(scenario['server_config'], 'grpc.minimal_stack', 1)
-
- if messages_per_stream:
- scenario['client_config']['messages_per_stream'] = messages_per_stream
- if client_language:
- # the CLIENT_LANGUAGE field is recognized by run_performance_tests.py
- scenario['CLIENT_LANGUAGE'] = client_language
- if server_language:
- # the SERVER_LANGUAGE field is recognized by run_performance_tests.py
- scenario['SERVER_LANGUAGE'] = server_language
- if categories:
- scenario['CATEGORIES'] = categories
- if len(excluded_poll_engines):
- # The polling engines for which this scenario is excluded
- scenario['EXCLUDED_POLL_ENGINES'] = excluded_poll_engines
- return scenario
+ minimal_stack=False,
+ offered_load=None):
+ """Creates a basic ping pong scenario."""
+ scenario = {
+ 'name': name,
+ 'num_servers': 1,
+ 'num_clients': 1,
+ 'client_config': {
+ 'client_type': client_type,
+ 'security_params': _get_secargs(secure),
+ 'outstanding_rpcs_per_channel': 1,
+ 'client_channels': 1,
+ 'async_client_threads': 1,
+ 'threads_per_cq': client_threads_per_cq,
+ 'rpc_type': rpc_type,
+ 'histogram_params': HISTOGRAM_PARAMS,
+ 'channel_args': [],
+ },
+ 'server_config': {
+ 'server_type': server_type,
+ 'security_params': _get_secargs(secure),
+ 'async_server_threads': async_server_threads,
+ 'threads_per_cq': server_threads_per_cq,
+ 'channel_args': [],
+ },
+ 'warmup_seconds': warmup_seconds,
+ 'benchmark_seconds': BENCHMARK_SECONDS
+ }
+ if resource_quota_size:
+ scenario['server_config']['resource_quota_size'] = resource_quota_size
+ if use_generic_payload:
+ if server_type != 'ASYNC_GENERIC_SERVER':
+ raise Exception('Use ASYNC_GENERIC_SERVER for generic payload.')
+ scenario['server_config']['payload_config'] = _payload_type(
+ use_generic_payload, req_size, resp_size)
+
+ scenario['client_config']['payload_config'] = _payload_type(
+ use_generic_payload, req_size, resp_size)
+
+ # Optimization target of 'throughput' does not work well with epoll1 polling
+ # engine. Use the default value of 'blend'
+ optimization_target = 'throughput'
+
+ if unconstrained_client:
+ outstanding_calls = outstanding if outstanding is not None else OUTSTANDING_REQUESTS[
+ unconstrained_client]
+ # clamp buffer usage to something reasonable (16 gig for now)
+ MAX_MEMORY_USE = 16 * 1024 * 1024 * 1024
+ if outstanding_calls * max(req_size, resp_size) > MAX_MEMORY_USE:
+ outstanding_calls = max(1,
+ MAX_MEMORY_USE / max(req_size, resp_size))
+ wide = channels if channels is not None else WIDE
+ deep = int(math.ceil(1.0 * outstanding_calls / wide))
+
+ scenario[
+ 'num_clients'] = num_clients if num_clients is not None else 0 # use as many clients as available.
+ scenario['client_config']['outstanding_rpcs_per_channel'] = deep
+ scenario['client_config']['client_channels'] = wide
+ scenario['client_config']['async_client_threads'] = 0
+ if offered_load is not None:
+ optimization_target = 'latency'
+ else:
+ scenario['client_config']['outstanding_rpcs_per_channel'] = 1
+ scenario['client_config']['client_channels'] = 1
+ scenario['client_config']['async_client_threads'] = 1
+ optimization_target = 'latency'
+
+ scenario['client_config']['load_params'] = _load_params(offered_load)
+
+ optimization_channel_arg = {
+ 'name': 'grpc.optimization_target',
+ 'str_value': optimization_target
+ }
+ scenario['client_config']['channel_args'].append(optimization_channel_arg)
+ scenario['server_config']['channel_args'].append(optimization_channel_arg)
+
+ if minimal_stack:
+ _add_channel_arg(scenario['client_config'], 'grpc.minimal_stack', 1)
+ _add_channel_arg(scenario['server_config'], 'grpc.minimal_stack', 1)
+
+ if messages_per_stream:
+ scenario['client_config']['messages_per_stream'] = messages_per_stream
+ if client_language:
+ # the CLIENT_LANGUAGE field is recognized by run_performance_tests.py
+ scenario['CLIENT_LANGUAGE'] = client_language
+ if server_language:
+ # the SERVER_LANGUAGE field is recognized by run_performance_tests.py
+ scenario['SERVER_LANGUAGE'] = server_language
+ if categories:
+ scenario['CATEGORIES'] = categories
+ if len(excluded_poll_engines):
+ # The polling engines for which this scenario is excluded
+ scenario['EXCLUDED_POLL_ENGINES'] = excluded_poll_engines
+ return scenario
class CXXLanguage:
- def __init__(self):
- self.safename = 'cxx'
-
- def worker_cmdline(self):
- return ['bins/opt/qps_worker']
-
- def worker_port_offset(self):
- return 0
-
- def scenarios(self):
- # TODO(ctiller): add 70% load latency test
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_unary_1channel_100rpcs_1MB', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- unconstrained_client='async', outstanding=100, channels=1,
- num_clients=1,
- secure=False,
- categories=[SMOKETEST] + [SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_streaming_from_client_1channel_1MB', rpc_type='STREAMING_FROM_CLIENT',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- unconstrained_client='async', outstanding=1, channels=1,
- num_clients=1,
- secure=False,
- categories=[SMOKETEST] + [SCALABLE])
-
- for secure in [True, False]:
- secstr = 'secure' if secure else 'insecure'
- smoketest_categories = ([SMOKETEST] if secure else []) + [SCALABLE]
-
- yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_ping_pong_%s' % secstr,
- rpc_type='STREAMING',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- use_generic_payload=True, async_server_threads=1,
- secure=secure,
- categories=smoketest_categories)
-
- yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_unconstrained_%s' % secstr,
- rpc_type='STREAMING',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories+[SCALABLE])
-
- for mps in geometric_progression(1, 20, 10):
+ def __init__(self):
+ self.safename = 'cxx'
+
+ def worker_cmdline(self):
+ return ['bins/opt/qps_worker']
+
+ def worker_port_offset(self):
+ return 0
+
+ def scenarios(self):
+ # TODO(ctiller): add 70% load latency test
yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_unconstrained_%smps_%s' % (mps, secstr),
- rpc_type='STREAMING',
+ 'cpp_protobuf_async_unary_1channel_100rpcs_1MB',
+ rpc_type='UNARY',
client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure, messages_per_stream=mps,
- minimal_stack=not secure,
- categories=smoketest_categories+[SCALABLE])
+ server_type='ASYNC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ unconstrained_client='async',
+ outstanding=100,
+ channels=1,
+ num_clients=1,
+ secure=False,
+ categories=[SMOKETEST] + [INPROC] + [SCALABLE])
- for mps in geometric_progression(1, 200, math.sqrt(10)):
yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_unconstrained_%smps_%s' % (mps, secstr),
- rpc_type='STREAMING',
+ 'cpp_protobuf_async_streaming_from_client_1channel_1MB',
+ rpc_type='STREAMING_FROM_CLIENT',
client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure, messages_per_stream=mps,
- minimal_stack=not secure,
- categories=[SWEEP])
-
- yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_1channel_1MBmsg_%s' % secstr,
- rpc_type='STREAMING',
- req_size=1024*1024,
- resp_size=1024*1024,
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories+[SCALABLE],
- channels=1, outstanding=100)
-
- yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_unconstrained_64KBmsg_%s' % secstr,
- rpc_type='STREAMING',
- req_size=64*1024,
- resp_size=64*1024,
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories+[SCALABLE])
-
- # TODO(https://github.com/grpc/grpc/issues/11500) Re-enable this test
- #yield _ping_pong_scenario(
- # 'cpp_generic_async_streaming_qps_unconstrained_1cq_%s' % secstr,
- # rpc_type='STREAMING',
- # client_type='ASYNC_CLIENT',
- # server_type='ASYNC_GENERIC_SERVER',
- # unconstrained_client='async-limited', use_generic_payload=True,
- # secure=secure,
- # client_threads_per_cq=1000000, server_threads_per_cq=1000000,
- # categories=smoketest_categories+[SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_%s' % secstr,
- rpc_type='STREAMING',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure,
- client_threads_per_cq=2, server_threads_per_cq=2,
- categories=smoketest_categories+[SCALABLE])
-
- #yield _ping_pong_scenario(
- # 'cpp_protobuf_async_streaming_qps_unconstrained_1cq_%s' % secstr,
- # rpc_type='STREAMING',
- # client_type='ASYNC_CLIENT',
- # server_type='ASYNC_SERVER',
- # unconstrained_client='async-limited',
- # secure=secure,
- # client_threads_per_cq=1000000, server_threads_per_cq=1000000,
- # categories=smoketest_categories+[SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_%s' % secstr,
- rpc_type='STREAMING',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_SERVER',
- unconstrained_client='async',
- secure=secure,
- client_threads_per_cq=2, server_threads_per_cq=2,
- categories=smoketest_categories+[SCALABLE])
-
- #yield _ping_pong_scenario(
- # 'cpp_protobuf_async_unary_qps_unconstrained_1cq_%s' % secstr,
- # rpc_type='UNARY',
- # client_type='ASYNC_CLIENT',
- # server_type='ASYNC_SERVER',
- # unconstrained_client='async-limited',
- # secure=secure,
- # client_threads_per_cq=1000000, server_threads_per_cq=1000000,
- # categories=smoketest_categories+[SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_%s' % secstr,
- rpc_type='UNARY',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_SERVER',
- unconstrained_client='async',
- secure=secure,
- client_threads_per_cq=2, server_threads_per_cq=2,
- categories=smoketest_categories+[SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_generic_async_streaming_qps_one_server_core_%s' % secstr,
- rpc_type='STREAMING',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async-limited', use_generic_payload=True,
- async_server_threads=1,
- minimal_stack=not secure,
- secure=secure)
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_%s' %
- (secstr),
- rpc_type='UNARY',
- client_type='ASYNC_CLIENT',
- server_type='SYNC_SERVER',
- unconstrained_client='async',
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories + [SCALABLE],
- excluded_poll_engines = ['poll-cv'])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_%s' %
- (secstr),
- rpc_type='UNARY',
- client_type='ASYNC_CLIENT',
- server_type='ASYNC_SERVER',
- channels=1,
- outstanding=64,
- req_size=128,
- resp_size=8*1024*1024,
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories + [SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_%s' % secstr,
- rpc_type='STREAMING',
- client_type='ASYNC_CLIENT',
- server_type='SYNC_SERVER',
- unconstrained_client='async',
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories+[SCALABLE],
- excluded_poll_engines = ['poll-cv'])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_async_unary_ping_pong_%s_1MB' % secstr, rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- secure=secure,
- minimal_stack=not secure,
- categories=smoketest_categories + [SCALABLE])
-
- for rpc_type in ['unary', 'streaming', 'streaming_from_client', 'streaming_from_server']:
- for synchronicity in ['sync', 'async']:
- yield _ping_pong_scenario(
- 'cpp_protobuf_%s_%s_ping_pong_%s' % (synchronicity, rpc_type, secstr),
- rpc_type=rpc_type.upper(),
- client_type='%s_CLIENT' % synchronicity.upper(),
- server_type='%s_SERVER' % synchronicity.upper(),
- async_server_threads=1,
- minimal_stack=not secure,
- secure=secure)
-
- for size in geometric_progression(1, 1024*1024*1024+1, 8):
- yield _ping_pong_scenario(
- 'cpp_protobuf_%s_%s_qps_unconstrained_%s_%db' % (synchronicity, rpc_type, secstr, size),
- rpc_type=rpc_type.upper(),
- req_size=size,
- resp_size=size,
- client_type='%s_CLIENT' % synchronicity.upper(),
- server_type='%s_SERVER' % synchronicity.upper(),
- unconstrained_client=synchronicity,
- secure=secure,
- minimal_stack=not secure,
- categories=[SWEEP])
-
- yield _ping_pong_scenario(
- 'cpp_protobuf_%s_%s_qps_unconstrained_%s' % (synchronicity, rpc_type, secstr),
- rpc_type=rpc_type.upper(),
- client_type='%s_CLIENT' % synchronicity.upper(),
- server_type='%s_SERVER' % synchronicity.upper(),
- unconstrained_client=synchronicity,
- secure=secure,
- minimal_stack=not secure,
- server_threads_per_cq=3,
- client_threads_per_cq=3,
- categories=smoketest_categories+[SCALABLE])
-
- # TODO(vjpai): Re-enable this test. It has a lot of timeouts
- # and hasn't yet been conclusively identified as a test failure
- # or race in the library
- # yield _ping_pong_scenario(
- # 'cpp_protobuf_%s_%s_qps_unconstrained_%s_500kib_resource_quota' % (synchronicity, rpc_type, secstr),
- # rpc_type=rpc_type.upper(),
- # client_type='%s_CLIENT' % synchronicity.upper(),
- # server_type='%s_SERVER' % synchronicity.upper(),
- # unconstrained_client=synchronicity,
- # secure=secure,
- # categories=smoketest_categories+[SCALABLE],
- # resource_quota_size=500*1024)
-
- if rpc_type == 'streaming':
+ server_type='ASYNC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ unconstrained_client='async',
+ outstanding=1,
+ channels=1,
+ num_clients=1,
+ secure=False,
+ categories=[SMOKETEST] + [INPROC] + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp',
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ req_size=300,
+ resp_size=50,
+ unconstrained_client='async',
+ outstanding=30000,
+ channels=300,
+ offered_load=37500,
+ secure=False,
+ async_server_threads=16,
+ server_threads_per_cq=1,
+ categories=[SMOKETEST] + [SCALABLE])
+
+ for secure in [True, False]:
+ secstr = 'secure' if secure else 'insecure'
+ smoketest_categories = ([SMOKETEST]
+ if secure else [INPROC]) + [SCALABLE]
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_ping_pong_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ use_generic_payload=True,
+ async_server_threads=1,
+ secure=secure,
+ categories=smoketest_categories)
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_unconstrained_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE])
+
for mps in geometric_progression(1, 20, 10):
- yield _ping_pong_scenario(
- 'cpp_protobuf_%s_%s_qps_unconstrained_%smps_%s' % (synchronicity, rpc_type, mps, secstr),
- rpc_type=rpc_type.upper(),
- client_type='%s_CLIENT' % synchronicity.upper(),
- server_type='%s_SERVER' % synchronicity.upper(),
- unconstrained_client=synchronicity,
- secure=secure, messages_per_stream=mps,
- minimal_stack=not secure,
- categories=smoketest_categories+[SCALABLE])
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_unconstrained_%smps_%s' %
+ (mps, secstr),
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ messages_per_stream=mps,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE])
for mps in geometric_progression(1, 200, math.sqrt(10)):
- yield _ping_pong_scenario(
- 'cpp_protobuf_%s_%s_qps_unconstrained_%smps_%s' % (synchronicity, rpc_type, mps, secstr),
- rpc_type=rpc_type.upper(),
- client_type='%s_CLIENT' % synchronicity.upper(),
- server_type='%s_SERVER' % synchronicity.upper(),
- unconstrained_client=synchronicity,
- secure=secure, messages_per_stream=mps,
- minimal_stack=not secure,
- categories=[SWEEP])
-
- for channels in geometric_progression(1, 20000, math.sqrt(10)):
- for outstanding in geometric_progression(1, 200000, math.sqrt(10)):
- if synchronicity == 'sync' and outstanding > 1200: continue
- if outstanding < channels: continue
yield _ping_pong_scenario(
- 'cpp_protobuf_%s_%s_qps_unconstrained_%s_%d_channels_%d_outstanding' % (synchronicity, rpc_type, secstr, channels, outstanding),
- rpc_type=rpc_type.upper(),
- client_type='%s_CLIENT' % synchronicity.upper(),
- server_type='%s_SERVER' % synchronicity.upper(),
- unconstrained_client=synchronicity, secure=secure,
+ 'cpp_generic_async_streaming_qps_unconstrained_%smps_%s' %
+ (mps, secstr),
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ messages_per_stream=mps,
minimal_stack=not secure,
- categories=[SWEEP], channels=channels, outstanding=outstanding)
-
- def __str__(self):
- return 'c++'
+ categories=[SWEEP])
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_1channel_1MBmsg_%s' % secstr,
+ rpc_type='STREAMING',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE],
+ channels=1,
+ outstanding=100)
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_unconstrained_64KBmsg_%s' %
+ secstr,
+ rpc_type='STREAMING',
+ req_size=64 * 1024,
+ resp_size=64 * 1024,
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_unconstrained_1cq_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async-limited',
+ use_generic_payload=True,
+ secure=secure,
+ client_threads_per_cq=1000000,
+ server_threads_per_cq=1000000,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_%s'
+ % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ client_threads_per_cq=2,
+ server_threads_per_cq=2,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_streaming_qps_unconstrained_1cq_%s' %
+ secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async-limited',
+ secure=secure,
+ client_threads_per_cq=1000000,
+ server_threads_per_cq=1000000,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_%s'
+ % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ client_threads_per_cq=2,
+ server_threads_per_cq=2,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_unary_qps_unconstrained_1cq_%s' % secstr,
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async-limited',
+ secure=secure,
+ client_threads_per_cq=1000000,
+ server_threads_per_cq=1000000,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_%s' %
+ secstr,
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ client_threads_per_cq=2,
+ server_threads_per_cq=2,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_generic_async_streaming_qps_one_server_core_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async-limited',
+ use_generic_payload=True,
+ async_server_threads=1,
+ minimal_stack=not secure,
+ secure=secure)
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_%s'
+ % (secstr),
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE],
+ excluded_poll_engines=['poll-cv'])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_%s'
+ % (secstr),
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ channels=1,
+ outstanding=64,
+ req_size=128,
+ resp_size=8 * 1024 * 1024,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_%s'
+ % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE],
+ excluded_poll_engines=['poll-cv'])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_async_unary_ping_pong_%s_1MB' % secstr,
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE])
+
+ for rpc_type in [
+ 'unary', 'streaming', 'streaming_from_client',
+ 'streaming_from_server'
+ ]:
+ for synchronicity in ['sync', 'async']:
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_%s_%s_ping_pong_%s' % (synchronicity,
+ rpc_type, secstr),
+ rpc_type=rpc_type.upper(),
+ client_type='%s_CLIENT' % synchronicity.upper(),
+ server_type='%s_SERVER' % synchronicity.upper(),
+ async_server_threads=1,
+ minimal_stack=not secure,
+ secure=secure)
+
+ for size in geometric_progression(1, 1024 * 1024 * 1024 + 1,
+ 8):
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_%s_%s_qps_unconstrained_%s_%db' %
+ (synchronicity, rpc_type, secstr, size),
+ rpc_type=rpc_type.upper(),
+ req_size=size,
+ resp_size=size,
+ client_type='%s_CLIENT' % synchronicity.upper(),
+ server_type='%s_SERVER' % synchronicity.upper(),
+ unconstrained_client=synchronicity,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=[SWEEP])
+
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_%s_%s_qps_unconstrained_%s' %
+ (synchronicity, rpc_type, secstr),
+ rpc_type=rpc_type.upper(),
+ client_type='%s_CLIENT' % synchronicity.upper(),
+ server_type='%s_SERVER' % synchronicity.upper(),
+ unconstrained_client=synchronicity,
+ secure=secure,
+ minimal_stack=not secure,
+ server_threads_per_cq=3,
+ client_threads_per_cq=3,
+ categories=smoketest_categories + [SCALABLE])
+
+ # TODO(vjpai): Re-enable this test. It has a lot of timeouts
+ # and hasn't yet been conclusively identified as a test failure
+ # or race in the library
+ # yield _ping_pong_scenario(
+ # 'cpp_protobuf_%s_%s_qps_unconstrained_%s_500kib_resource_quota' % (synchronicity, rpc_type, secstr),
+ # rpc_type=rpc_type.upper(),
+ # client_type='%s_CLIENT' % synchronicity.upper(),
+ # server_type='%s_SERVER' % synchronicity.upper(),
+ # unconstrained_client=synchronicity,
+ # secure=secure,
+ # categories=smoketest_categories+[SCALABLE],
+ # resource_quota_size=500*1024)
+
+ if rpc_type == 'streaming':
+ for mps in geometric_progression(1, 20, 10):
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_%s_%s_qps_unconstrained_%smps_%s'
+ % (synchronicity, rpc_type, mps, secstr),
+ rpc_type=rpc_type.upper(),
+ client_type='%s_CLIENT' % synchronicity.upper(),
+ server_type='%s_SERVER' % synchronicity.upper(),
+ unconstrained_client=synchronicity,
+ secure=secure,
+ messages_per_stream=mps,
+ minimal_stack=not secure,
+ categories=smoketest_categories + [SCALABLE])
+
+ for mps in geometric_progression(1, 200, math.sqrt(10)):
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_%s_%s_qps_unconstrained_%smps_%s'
+ % (synchronicity, rpc_type, mps, secstr),
+ rpc_type=rpc_type.upper(),
+ client_type='%s_CLIENT' % synchronicity.upper(),
+ server_type='%s_SERVER' % synchronicity.upper(),
+ unconstrained_client=synchronicity,
+ secure=secure,
+ messages_per_stream=mps,
+ minimal_stack=not secure,
+ categories=[SWEEP])
+
+ for channels in geometric_progression(
+ 1, 20000, math.sqrt(10)):
+ for outstanding in geometric_progression(
+ 1, 200000, math.sqrt(10)):
+ if synchronicity == 'sync' and outstanding > 1200:
+ continue
+ if outstanding < channels: continue
+ yield _ping_pong_scenario(
+ 'cpp_protobuf_%s_%s_qps_unconstrained_%s_%d_channels_%d_outstanding'
+ % (synchronicity, rpc_type, secstr, channels,
+ outstanding),
+ rpc_type=rpc_type.upper(),
+ client_type='%s_CLIENT' % synchronicity.upper(),
+ server_type='%s_SERVER' % synchronicity.upper(),
+ unconstrained_client=synchronicity,
+ secure=secure,
+ minimal_stack=not secure,
+ categories=[SWEEP],
+ channels=channels,
+ outstanding=outstanding)
+
+ def __str__(self):
+ return 'c++'
class CSharpLanguage:
- def __init__(self):
- self.safename = str(self)
-
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_csharp.sh']
-
- def worker_port_offset(self):
- return 100
-
- def scenarios(self):
- yield _ping_pong_scenario(
- 'csharp_generic_async_streaming_ping_pong', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- use_generic_payload=True,
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_generic_async_streaming_ping_pong_insecure_1MB', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- use_generic_payload=True,
- secure=False,
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_generic_async_streaming_qps_unconstrained_insecure', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=False,
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_protobuf_async_streaming_ping_pong', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER')
-
- yield _ping_pong_scenario(
- 'csharp_protobuf_async_unary_ping_pong', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_protobuf_sync_to_async_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER')
-
- yield _ping_pong_scenario(
- 'csharp_protobuf_async_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async',
- categories=[SMOKETEST,SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_protobuf_async_streaming_qps_unconstrained', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async',
- categories=[SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_to_cpp_protobuf_sync_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- server_language='c++', async_server_threads=1,
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_to_cpp_protobuf_async_streaming_ping_pong', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- server_language='c++', async_server_threads=1)
-
- yield _ping_pong_scenario(
- 'csharp_to_cpp_protobuf_async_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async', server_language='c++',
- categories=[SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_to_cpp_protobuf_sync_to_async_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='sync', server_language='c++',
- categories=[SCALABLE])
-
- yield _ping_pong_scenario(
- 'cpp_to_csharp_protobuf_async_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async', client_language='c++',
- categories=[SCALABLE])
-
- yield _ping_pong_scenario(
- 'csharp_protobuf_async_unary_ping_pong_1MB', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- categories=[SMOKETEST, SCALABLE])
-
- def __str__(self):
- return 'csharp'
-
-
-class NodeLanguage:
-
- def __init__(self):
- pass
- self.safename = str(self)
-
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_node.sh',
- '--benchmark_impl=grpc']
-
- def worker_port_offset(self):
- return 200
-
- def scenarios(self):
- # TODO(jtattermusch): make this scenario work
- yield _ping_pong_scenario(
- 'node_generic_streaming_ping_pong', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- use_generic_payload=True)
-
- yield _ping_pong_scenario(
- 'node_protobuf_streaming_ping_pong', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER')
-
- yield _ping_pong_scenario(
- 'node_protobuf_unary_ping_pong', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- categories=[SCALABLE, SMOKETEST])
-
- yield _ping_pong_scenario(
- 'cpp_to_node_unary_ping_pong', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- client_language='c++')
-
- yield _ping_pong_scenario(
- 'node_protobuf_unary_ping_pong_1MB', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- categories=[SCALABLE])
-
- sizes = [('1B', 1), ('1KB', 1024), ('10KB', 10 * 1024),
- ('1MB', 1024 * 1024), ('10MB', 10 * 1024 * 1024),
- ('100MB', 100 * 1024 * 1024)]
-
- for size_name, size in sizes:
- for secure in (True, False):
+ def __init__(self):
+ self.safename = str(self)
+
+ def worker_cmdline(self):
+ return ['tools/run_tests/performance/run_worker_csharp.sh']
+
+ def worker_port_offset(self):
+ return 100
+
+ def scenarios(self):
+ yield _ping_pong_scenario(
+ 'csharp_generic_async_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ use_generic_payload=True,
+ categories=[SMOKETEST, SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_generic_async_streaming_ping_pong_insecure_1MB',
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ use_generic_payload=True,
+ secure=False,
+ categories=[SMOKETEST, SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_generic_async_streaming_qps_unconstrained_insecure',
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=False,
+ categories=[SMOKETEST, SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_protobuf_async_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER')
+
yield _ping_pong_scenario(
- 'node_protobuf_unary_ping_pong_%s_resp_%s' %
- (size_name, 'secure' if secure else 'insecure'),
+ 'csharp_protobuf_async_unary_ping_pong',
rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=0, resp_size=size,
- secure=secure,
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ categories=[SMOKETEST, SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_protobuf_sync_to_async_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER')
+
+ yield _ping_pong_scenario(
+ 'csharp_protobuf_async_unary_qps_unconstrained',
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ categories=[SMOKETEST, SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_protobuf_async_streaming_qps_unconstrained',
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
categories=[SCALABLE])
- yield _ping_pong_scenario(
- 'node_protobuf_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async',
- categories=[SCALABLE, SMOKETEST])
+ yield _ping_pong_scenario(
+ 'csharp_to_cpp_protobuf_sync_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1,
+ categories=[SMOKETEST, SCALABLE])
- yield _ping_pong_scenario(
- 'node_protobuf_streaming_qps_unconstrained', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async')
+ yield _ping_pong_scenario(
+ 'csharp_to_cpp_protobuf_async_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1)
- yield _ping_pong_scenario(
- 'node_to_cpp_protobuf_async_unary_ping_pong', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- server_language='c++', async_server_threads=1)
+ yield _ping_pong_scenario(
+ 'csharp_to_cpp_protobuf_async_unary_qps_unconstrained',
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ server_language='c++',
+ categories=[SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_to_cpp_protobuf_sync_to_async_unary_qps_unconstrained',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='sync',
+ server_language='c++',
+ categories=[SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'cpp_to_csharp_protobuf_async_unary_qps_unconstrained',
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ client_language='c++',
+ categories=[SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'csharp_protobuf_async_unary_ping_pong_1MB',
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ categories=[SMOKETEST, SCALABLE])
- yield _ping_pong_scenario(
- 'node_to_cpp_protobuf_async_streaming_ping_pong', rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- server_language='c++', async_server_threads=1)
+ def __str__(self):
+ return 'csharp'
- def __str__(self):
- return 'node'
class PythonLanguage:
- def __init__(self):
- self.safename = 'python'
-
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_python.sh']
-
- def worker_port_offset(self):
- return 500
-
- def scenarios(self):
- yield _ping_pong_scenario(
- 'python_generic_sync_streaming_ping_pong', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- use_generic_payload=True,
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'python_protobuf_sync_streaming_ping_pong', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER')
-
- yield _ping_pong_scenario(
- 'python_protobuf_async_unary_ping_pong', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER')
-
- yield _ping_pong_scenario(
- 'python_protobuf_sync_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'python_protobuf_sync_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='sync')
-
- yield _ping_pong_scenario(
- 'python_protobuf_sync_streaming_qps_unconstrained', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='sync')
-
- yield _ping_pong_scenario(
- 'python_to_cpp_protobuf_sync_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- server_language='c++', async_server_threads=1,
- categories=[SMOKETEST, SCALABLE])
-
- yield _ping_pong_scenario(
- 'python_to_cpp_protobuf_sync_streaming_ping_pong', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- server_language='c++', async_server_threads=1)
-
- yield _ping_pong_scenario(
- 'python_protobuf_sync_unary_ping_pong_1MB', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- categories=[SMOKETEST, SCALABLE])
-
- def __str__(self):
- return 'python'
+ def __init__(self):
+ self.safename = 'python'
-class RubyLanguage:
+ def worker_cmdline(self):
+ return ['tools/run_tests/performance/run_worker_python.sh']
- def __init__(self):
- pass
- self.safename = str(self)
+ def worker_port_offset(self):
+ return 500
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_ruby.sh']
+ def scenarios(self):
+ yield _ping_pong_scenario(
+ 'python_generic_sync_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ use_generic_payload=True,
+ categories=[SMOKETEST, SCALABLE])
- def worker_port_offset(self):
- return 300
+ yield _ping_pong_scenario(
+ 'python_protobuf_sync_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER')
- def scenarios(self):
- yield _ping_pong_scenario(
- 'ruby_protobuf_sync_streaming_ping_pong', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- categories=[SMOKETEST, SCALABLE])
+ yield _ping_pong_scenario(
+ 'python_protobuf_async_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER')
- yield _ping_pong_scenario(
- 'ruby_protobuf_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- categories=[SMOKETEST, SCALABLE])
+ yield _ping_pong_scenario(
+ 'python_protobuf_sync_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ categories=[SMOKETEST, SCALABLE])
- yield _ping_pong_scenario(
- 'ruby_protobuf_sync_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- unconstrained_client='sync')
+ yield _ping_pong_scenario(
+ 'python_protobuf_sync_unary_qps_unconstrained',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='sync')
- yield _ping_pong_scenario(
- 'ruby_protobuf_sync_streaming_qps_unconstrained', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- unconstrained_client='sync')
+ yield _ping_pong_scenario(
+ 'python_protobuf_sync_streaming_qps_unconstrained',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='sync')
- yield _ping_pong_scenario(
- 'ruby_to_cpp_protobuf_sync_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- server_language='c++', async_server_threads=1)
+ yield _ping_pong_scenario(
+ 'python_to_cpp_protobuf_sync_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1,
+ categories=[SMOKETEST, SCALABLE])
- yield _ping_pong_scenario(
- 'ruby_to_cpp_protobuf_sync_streaming_ping_pong', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- server_language='c++', async_server_threads=1)
+ yield _ping_pong_scenario(
+ 'python_to_cpp_protobuf_sync_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1)
- yield _ping_pong_scenario(
- 'ruby_protobuf_unary_ping_pong_1MB', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- req_size=1024*1024, resp_size=1024*1024,
- categories=[SMOKETEST, SCALABLE])
+ yield _ping_pong_scenario(
+ 'python_protobuf_sync_unary_ping_pong_1MB',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ categories=[SMOKETEST, SCALABLE])
- def __str__(self):
- return 'ruby'
+ def __str__(self):
+ return 'python'
-class PhpLanguage:
+class RubyLanguage:
- def __init__(self):
- pass
- self.safename = str(self)
+ def __init__(self):
+ pass
+ self.safename = str(self)
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_php.sh']
+ def worker_cmdline(self):
+ return ['tools/run_tests/performance/run_worker_ruby.sh']
- def worker_port_offset(self):
- return 800
+ def worker_port_offset(self):
+ return 300
- def scenarios(self):
- yield _ping_pong_scenario(
- 'php_to_cpp_protobuf_sync_unary_ping_pong', rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- server_language='c++', async_server_threads=1)
+ def scenarios(self):
+ yield _ping_pong_scenario(
+ 'ruby_protobuf_sync_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ categories=[SMOKETEST, SCALABLE])
- yield _ping_pong_scenario(
- 'php_to_cpp_protobuf_sync_streaming_ping_pong', rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- server_language='c++', async_server_threads=1)
+ yield _ping_pong_scenario(
+ 'ruby_protobuf_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ categories=[SMOKETEST, SCALABLE])
- def __str__(self):
- return 'php'
+ yield _ping_pong_scenario(
+ 'ruby_protobuf_sync_unary_qps_unconstrained',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ unconstrained_client='sync')
+ yield _ping_pong_scenario(
+ 'ruby_protobuf_sync_streaming_qps_unconstrained',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ unconstrained_client='sync')
-class JavaLanguage:
+ yield _ping_pong_scenario(
+ 'ruby_to_cpp_protobuf_sync_unary_ping_pong',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1)
- def __init__(self):
- pass
- self.safename = str(self)
-
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_java.sh']
-
- def worker_port_offset(self):
- return 400
-
- def scenarios(self):
- for secure in [True, False]:
- secstr = 'secure' if secure else 'insecure'
- smoketest_categories = ([SMOKETEST] if secure else []) + [SCALABLE]
-
- yield _ping_pong_scenario(
- 'java_generic_async_streaming_ping_pong_%s' % secstr, rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- use_generic_payload=True, async_server_threads=1,
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS,
- categories=smoketest_categories)
-
- yield _ping_pong_scenario(
- 'java_protobuf_async_streaming_ping_pong_%s' % secstr, rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- async_server_threads=1,
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS)
-
- yield _ping_pong_scenario(
- 'java_protobuf_async_unary_ping_pong_%s' % secstr, rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- async_server_threads=1,
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS,
- categories=smoketest_categories)
-
- yield _ping_pong_scenario(
- 'java_protobuf_unary_ping_pong_%s' % secstr, rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- async_server_threads=1,
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS)
-
- yield _ping_pong_scenario(
- 'java_protobuf_async_unary_qps_unconstrained_%s' % secstr, rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async',
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS,
- categories=smoketest_categories+[SCALABLE])
-
- yield _ping_pong_scenario(
- 'java_protobuf_async_streaming_qps_unconstrained_%s' % secstr, rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async',
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS,
- categories=[SCALABLE])
-
- yield _ping_pong_scenario(
- 'java_generic_async_streaming_qps_unconstrained_%s' % secstr, rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS,
- categories=[SCALABLE])
-
- yield _ping_pong_scenario(
- 'java_generic_async_streaming_qps_one_server_core_%s' % secstr, rpc_type='STREAMING',
- client_type='ASYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async-limited', use_generic_payload=True,
- async_server_threads=1,
- secure=secure, warmup_seconds=JAVA_WARMUP_SECONDS)
-
- # TODO(jtattermusch): add scenarios java vs C++
-
- def __str__(self):
- return 'java'
+ yield _ping_pong_scenario(
+ 'ruby_to_cpp_protobuf_sync_streaming_ping_pong',
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1)
+ yield _ping_pong_scenario(
+ 'ruby_protobuf_unary_ping_pong_1MB',
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ req_size=1024 * 1024,
+ resp_size=1024 * 1024,
+ categories=[SMOKETEST, SCALABLE])
-class GoLanguage:
+ def __str__(self):
+ return 'ruby'
+
+
+class Php7Language:
+
+ def __init__(self, php7_protobuf_c=False):
+ pass
+ self.php7_protobuf_c = php7_protobuf_c
+ self.safename = str(self)
+
+ def worker_cmdline(self):
+ if self.php7_protobuf_c:
+ return [
+ 'tools/run_tests/performance/run_worker_php.sh',
+ '--use_protobuf_c_extension'
+ ]
+ return ['tools/run_tests/performance/run_worker_php.sh']
+
+ def worker_port_offset(self):
+ if self.php7_protobuf_c:
+ return 900
+ return 800
+
+ def scenarios(self):
+ php7_extension_mode = 'php7_protobuf_php_extension'
+ if self.php7_protobuf_c:
+ php7_extension_mode = 'php7_protobuf_c_extension'
- def __init__(self):
- pass
- self.safename = str(self)
-
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_go.sh']
-
- def worker_port_offset(self):
- return 600
-
- def scenarios(self):
- for secure in [True, False]:
- secstr = 'secure' if secure else 'insecure'
- smoketest_categories = ([SMOKETEST] if secure else []) + [SCALABLE]
-
- # ASYNC_GENERIC_SERVER for Go actually uses a sync streaming server,
- # but that's mostly because of lack of better name of the enum value.
- yield _ping_pong_scenario(
- 'go_generic_sync_streaming_ping_pong_%s' % secstr, rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- use_generic_payload=True, async_server_threads=1,
- secure=secure,
- categories=smoketest_categories)
-
- yield _ping_pong_scenario(
- 'go_protobuf_sync_streaming_ping_pong_%s' % secstr, rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- async_server_threads=1,
- secure=secure)
-
- yield _ping_pong_scenario(
- 'go_protobuf_sync_unary_ping_pong_%s' % secstr, rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- async_server_threads=1,
- secure=secure,
- categories=smoketest_categories)
-
- # unconstrained_client='async' is intended (client uses goroutines)
- yield _ping_pong_scenario(
- 'go_protobuf_sync_unary_qps_unconstrained_%s' % secstr, rpc_type='UNARY',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- unconstrained_client='async',
- secure=secure,
- categories=smoketest_categories+[SCALABLE])
-
- # unconstrained_client='async' is intended (client uses goroutines)
- yield _ping_pong_scenario(
- 'go_protobuf_sync_streaming_qps_unconstrained_%s' % secstr, rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='SYNC_SERVER',
- unconstrained_client='async',
- secure=secure,
- categories=[SCALABLE])
-
- # unconstrained_client='async' is intended (client uses goroutines)
- # ASYNC_GENERIC_SERVER for Go actually uses a sync streaming server,
- # but that's mostly because of lack of better name of the enum value.
- yield _ping_pong_scenario(
- 'go_generic_sync_streaming_qps_unconstrained_%s' % secstr, rpc_type='STREAMING',
- client_type='SYNC_CLIENT', server_type='ASYNC_GENERIC_SERVER',
- unconstrained_client='async', use_generic_payload=True,
- secure=secure,
- categories=[SCALABLE])
-
- # TODO(jtattermusch): add scenarios go vs C++
-
- def __str__(self):
- return 'go'
-
-class NodeExpressLanguage:
-
- def __init__(self):
- pass
- self.safename = str(self)
-
- def worker_cmdline(self):
- return ['tools/run_tests/performance/run_worker_node.sh',
- '--benchmark_impl=express']
-
- def worker_port_offset(self):
- return 700
-
- def scenarios(self):
- yield _ping_pong_scenario(
- 'node_express_json_unary_ping_pong', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- categories=[SCALABLE, SMOKETEST])
-
- yield _ping_pong_scenario(
- 'node_express_json_async_unary_qps_unconstrained', rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- unconstrained_client='async',
- categories=[SCALABLE, SMOKETEST])
-
- sizes = [('1B', 1), ('1KB', 1024), ('10KB', 10 * 1024),
- ('1MB', 1024 * 1024), ('10MB', 10 * 1024 * 1024),
- ('100MB', 100 * 1024 * 1024)]
-
- for size_name, size in sizes:
- for secure in (True, False):
yield _ping_pong_scenario(
- 'node_express_json_unary_ping_pong_%s_resp_%s' %
- (size_name, 'secure' if secure else 'insecure'),
+ '%s_to_cpp_protobuf_sync_unary_ping_pong' % php7_extension_mode,
rpc_type='UNARY',
- client_type='ASYNC_CLIENT', server_type='ASYNC_SERVER',
- req_size=0, resp_size=size,
- secure=secure,
- categories=[SCALABLE])
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1)
+
+ yield _ping_pong_scenario(
+ '%s_to_cpp_protobuf_sync_streaming_ping_pong' % php7_extension_mode,
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ server_language='c++',
+ async_server_threads=1)
+
+ # TODO(ddyihai): Investigate why when async_server_threads=1/CPU usage 340%, the QPS performs
+ # better than async_server_threads=0/CPU usage 490%.
+ yield _ping_pong_scenario(
+ '%s_to_cpp_protobuf_sync_unary_qps_unconstrained' %
+ php7_extension_mode,
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ server_language='c++',
+ outstanding=1,
+ async_server_threads=1,
+ unconstrained_client='sync')
+
+ yield _ping_pong_scenario(
+ '%s_to_cpp_protobuf_sync_streaming_qps_unconstrained' %
+ php7_extension_mode,
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ server_language='c++',
+ outstanding=1,
+ async_server_threads=1,
+ unconstrained_client='sync')
+
+ def __str__(self):
+ if self.php7_protobuf_c:
+ return 'php7_protobuf_c'
+ return 'php7'
+
+
+class JavaLanguage:
+
+ def __init__(self):
+ pass
+ self.safename = str(self)
+
+ def worker_cmdline(self):
+ return ['tools/run_tests/performance/run_worker_java.sh']
+
+ def worker_port_offset(self):
+ return 400
+
+ def scenarios(self):
+ for secure in [True, False]:
+ secstr = 'secure' if secure else 'insecure'
+ smoketest_categories = ([SMOKETEST] if secure else []) + [SCALABLE]
+
+ yield _ping_pong_scenario(
+ 'java_generic_async_streaming_ping_pong_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ use_generic_payload=True,
+ async_server_threads=1,
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS,
+ categories=smoketest_categories)
+
+ yield _ping_pong_scenario(
+ 'java_protobuf_async_streaming_ping_pong_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ async_server_threads=1,
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS)
+
+ yield _ping_pong_scenario(
+ 'java_protobuf_async_unary_ping_pong_%s' % secstr,
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ async_server_threads=1,
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS,
+ categories=smoketest_categories)
+
+ yield _ping_pong_scenario(
+ 'java_protobuf_unary_ping_pong_%s' % secstr,
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ async_server_threads=1,
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS)
+
+ yield _ping_pong_scenario(
+ 'java_protobuf_async_unary_qps_unconstrained_%s' % secstr,
+ rpc_type='UNARY',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS,
+ categories=smoketest_categories + [SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'java_protobuf_async_streaming_qps_unconstrained_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS,
+ categories=[SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'java_generic_async_streaming_qps_unconstrained_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS,
+ categories=[SCALABLE])
+
+ yield _ping_pong_scenario(
+ 'java_generic_async_streaming_qps_one_server_core_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='ASYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async-limited',
+ use_generic_payload=True,
+ async_server_threads=1,
+ secure=secure,
+ warmup_seconds=JAVA_WARMUP_SECONDS)
+
+ # TODO(jtattermusch): add scenarios java vs C++
+
+ def __str__(self):
+ return 'java'
+
+
+class GoLanguage:
- def __str__(self):
- return 'node_express'
+ def __init__(self):
+ pass
+ self.safename = str(self)
+
+ def worker_cmdline(self):
+ return ['tools/run_tests/performance/run_worker_go.sh']
+
+ def worker_port_offset(self):
+ return 600
+
+ def scenarios(self):
+ for secure in [True, False]:
+ secstr = 'secure' if secure else 'insecure'
+ smoketest_categories = ([SMOKETEST] if secure else []) + [SCALABLE]
+
+ # ASYNC_GENERIC_SERVER for Go actually uses a sync streaming server,
+ # but that's mostly because of lack of better name of the enum value.
+ yield _ping_pong_scenario(
+ 'go_generic_sync_streaming_ping_pong_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ use_generic_payload=True,
+ async_server_threads=1,
+ secure=secure,
+ categories=smoketest_categories)
+
+ yield _ping_pong_scenario(
+ 'go_protobuf_sync_streaming_ping_pong_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ async_server_threads=1,
+ secure=secure)
+
+ yield _ping_pong_scenario(
+ 'go_protobuf_sync_unary_ping_pong_%s' % secstr,
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ async_server_threads=1,
+ secure=secure,
+ categories=smoketest_categories)
+
+ # unconstrained_client='async' is intended (client uses goroutines)
+ yield _ping_pong_scenario(
+ 'go_protobuf_sync_unary_qps_unconstrained_%s' % secstr,
+ rpc_type='UNARY',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ categories=smoketest_categories + [SCALABLE])
+
+ # unconstrained_client='async' is intended (client uses goroutines)
+ yield _ping_pong_scenario(
+ 'go_protobuf_sync_streaming_qps_unconstrained_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='SYNC_SERVER',
+ unconstrained_client='async',
+ secure=secure,
+ categories=[SCALABLE])
+
+ # unconstrained_client='async' is intended (client uses goroutines)
+ # ASYNC_GENERIC_SERVER for Go actually uses a sync streaming server,
+ # but that's mostly because of lack of better name of the enum value.
+ yield _ping_pong_scenario(
+ 'go_generic_sync_streaming_qps_unconstrained_%s' % secstr,
+ rpc_type='STREAMING',
+ client_type='SYNC_CLIENT',
+ server_type='ASYNC_GENERIC_SERVER',
+ unconstrained_client='async',
+ use_generic_payload=True,
+ secure=secure,
+ categories=[SCALABLE])
+
+ # TODO(jtattermusch): add scenarios go vs C++
+
+ def __str__(self):
+ return 'go'
LANGUAGES = {
- 'c++' : CXXLanguage(),
- 'csharp' : CSharpLanguage(),
- 'node' : NodeLanguage(),
- 'node_express': NodeExpressLanguage(),
- 'ruby' : RubyLanguage(),
- 'php' : PhpLanguage(),
- 'java' : JavaLanguage(),
- 'python' : PythonLanguage(),
- 'go' : GoLanguage(),
+ 'c++': CXXLanguage(),
+ 'csharp': CSharpLanguage(),
+ 'ruby': RubyLanguage(),
+ 'php7': Php7Language(),
+ 'php7_protobuf_c': Php7Language(php7_protobuf_c=True),
+ 'java': JavaLanguage(),
+ 'python': PythonLanguage(),
+ 'go': GoLanguage(),
}
diff --git a/tools/run_tests/performance/scenario_result_schema.json b/tools/run_tests/performance/scenario_result_schema.json
index c7b1904bd1..b00c2eed16 100644
--- a/tools/run_tests/performance/scenario_result_schema.json
+++ b/tools/run_tests/performance/scenario_result_schema.json
@@ -382,6 +382,11 @@
},
{
"mode": "NULLABLE",
+ "name": "core_http2_spurious_writes_begun",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
"name": "core_hpack_recv_indexed",
"type": "INTEGER"
},
@@ -512,6 +517,26 @@
},
{
"mode": "NULLABLE",
+ "name": "core_call_combiner_locks_initiated",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_call_combiner_locks_scheduled_items",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_call_combiner_set_notify_on_cancel",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_call_combiner_cancelled",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
"name": "core_executor_scheduled_short_items",
"type": "INTEGER"
},
@@ -542,22 +567,27 @@
},
{
"mode": "NULLABLE",
- "name": "core_executor_threads_created",
+ "name": "core_server_requested_calls",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
- "name": "core_executor_threads_used",
+ "name": "core_server_slowpath_requests_queued",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
- "name": "core_server_requested_calls",
+ "name": "core_cq_ev_queue_trylock_failures",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
- "name": "core_server_slowpath_requests_queued",
+ "name": "core_cq_ev_queue_trylock_successes",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_cq_ev_queue_transient_pop_failures",
"type": "INTEGER"
},
{
@@ -862,31 +892,6 @@
},
{
"mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup",
- "type": "STRING"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_bkts",
- "type": "STRING"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_50p",
- "type": "FLOAT"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_95p",
- "type": "FLOAT"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_99p",
- "type": "FLOAT"
- },
- {
- "mode": "NULLABLE",
"name": "core_server_cqs_checked",
"type": "STRING"
},
@@ -1209,6 +1214,11 @@
},
{
"mode": "NULLABLE",
+ "name": "core_http2_spurious_writes_begun",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
"name": "core_hpack_recv_indexed",
"type": "INTEGER"
},
@@ -1339,6 +1349,26 @@
},
{
"mode": "NULLABLE",
+ "name": "core_call_combiner_locks_initiated",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_call_combiner_locks_scheduled_items",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_call_combiner_set_notify_on_cancel",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_call_combiner_cancelled",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
"name": "core_executor_scheduled_short_items",
"type": "INTEGER"
},
@@ -1369,22 +1399,27 @@
},
{
"mode": "NULLABLE",
- "name": "core_executor_threads_created",
+ "name": "core_server_requested_calls",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
- "name": "core_executor_threads_used",
+ "name": "core_server_slowpath_requests_queued",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
- "name": "core_server_requested_calls",
+ "name": "core_cq_ev_queue_trylock_failures",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
- "name": "core_server_slowpath_requests_queued",
+ "name": "core_cq_ev_queue_trylock_successes",
+ "type": "INTEGER"
+ },
+ {
+ "mode": "NULLABLE",
+ "name": "core_cq_ev_queue_transient_pop_failures",
"type": "INTEGER"
},
{
@@ -1689,31 +1724,6 @@
},
{
"mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup",
- "type": "STRING"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_bkts",
- "type": "STRING"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_50p",
- "type": "FLOAT"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_95p",
- "type": "FLOAT"
- },
- {
- "mode": "NULLABLE",
- "name": "core_executor_closures_per_wakeup_99p",
- "type": "FLOAT"
- },
- {
- "mode": "NULLABLE",
"name": "core_server_cqs_checked",
"type": "STRING"
},
diff --git a/tools/run_tests/python_utils/antagonist.py b/tools/run_tests/python_utils/antagonist.py
index 0d79ce0986..a928a4cb00 100755
--- a/tools/run_tests/python_utils/antagonist.py
+++ b/tools/run_tests/python_utils/antagonist.py
@@ -12,8 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""This is used by run_tests.py to create cpu load on a machine"""
while True:
- pass
+ pass
diff --git a/tools/run_tests/python_utils/comment_on_pr.py b/tools/run_tests/python_utils/comment_on_pr.py
index 21b9bb7085..399c996d4d 100644
--- a/tools/run_tests/python_utils/comment_on_pr.py
+++ b/tools/run_tests/python_utils/comment_on_pr.py
@@ -16,19 +16,22 @@ import os
import json
import urllib2
+
def comment_on_pr(text):
- if 'JENKINS_OAUTH_TOKEN' not in os.environ:
- print 'Missing JENKINS_OAUTH_TOKEN env var: not commenting'
- return
- if 'ghprbPullId' not in os.environ:
- print 'Missing ghprbPullId env var: not commenting'
- return
- req = urllib2.Request(
- url = 'https://api.github.com/repos/grpc/grpc/issues/%s/comments' %
- os.environ['ghprbPullId'],
- data = json.dumps({'body': text}),
- headers = {
- 'Authorization': 'token %s' % os.environ['JENKINS_OAUTH_TOKEN'],
- 'Content-Type': 'application/json',
- })
- print urllib2.urlopen(req).read()
+ if 'JENKINS_OAUTH_TOKEN' not in os.environ:
+ print 'Missing JENKINS_OAUTH_TOKEN env var: not commenting'
+ return
+ if 'ghprbPullId' not in os.environ:
+ print 'Missing ghprbPullId env var: not commenting'
+ return
+ req = urllib2.Request(
+ url='https://api.github.com/repos/grpc/grpc/issues/%s/comments' %
+ os.environ['ghprbPullId'],
+ data=json.dumps({
+ 'body': text
+ }),
+ headers={
+ 'Authorization': 'token %s' % os.environ['JENKINS_OAUTH_TOKEN'],
+ 'Content-Type': 'application/json',
+ })
+ print urllib2.urlopen(req).read()
diff --git a/tools/run_tests/python_utils/dockerjob.py b/tools/run_tests/python_utils/dockerjob.py
index 2f5285b26c..2d22dc13a0 100755
--- a/tools/run_tests/python_utils/dockerjob.py
+++ b/tools/run_tests/python_utils/dockerjob.py
@@ -11,7 +11,6 @@
# 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.
-
"""Helpers to run docker instances as jobs."""
from __future__ import print_function
@@ -28,102 +27,109 @@ _DEVNULL = open(os.devnull, 'w')
def random_name(base_name):
- """Randomizes given base name."""
- return '%s_%s' % (base_name, uuid.uuid4())
+ """Randomizes given base name."""
+ return '%s_%s' % (base_name, uuid.uuid4())
def docker_kill(cid):
- """Kills a docker container. Returns True if successful."""
- return subprocess.call(['docker','kill', str(cid)],
- stdin=subprocess.PIPE,
- stdout=_DEVNULL,
- stderr=subprocess.STDOUT) == 0
+ """Kills a docker container. Returns True if successful."""
+ return subprocess.call(
+ ['docker', 'kill', str(cid)],
+ stdin=subprocess.PIPE,
+ stdout=_DEVNULL,
+ stderr=subprocess.STDOUT) == 0
def docker_mapped_port(cid, port, timeout_seconds=15):
- """Get port mapped to internal given internal port for given container."""
- started = time.time()
- while time.time() - started < timeout_seconds:
- try:
- output = subprocess.check_output('docker port %s %s' % (cid, port),
- stderr=_DEVNULL,
- shell=True)
- return int(output.split(':', 2)[1])
- except subprocess.CalledProcessError as e:
- pass
- raise Exception('Failed to get exposed port %s for container %s.' %
- (port, cid))
+ """Get port mapped to internal given internal port for given container."""
+ started = time.time()
+ while time.time() - started < timeout_seconds:
+ try:
+ output = subprocess.check_output(
+ 'docker port %s %s' % (cid, port), stderr=_DEVNULL, shell=True)
+ return int(output.split(':', 2)[1])
+ except subprocess.CalledProcessError as e:
+ pass
+ raise Exception('Failed to get exposed port %s for container %s.' % (port,
+ cid))
def wait_for_healthy(cid, shortname, timeout_seconds):
- """Wait timeout_seconds for the container to become healthy"""
- started = time.time()
- while time.time() - started < timeout_seconds:
- try:
- output = subprocess.check_output(
- ['docker', 'inspect', '--format="{{.State.Health.Status}}"', cid],
- stderr=_DEVNULL)
- if output.strip('\n') == 'healthy':
- return
- except subprocess.CalledProcessError as e:
- pass
- time.sleep(1)
- raise Exception('Timed out waiting for %s (%s) to pass health check' %
- (shortname, cid))
+ """Wait timeout_seconds for the container to become healthy"""
+ started = time.time()
+ while time.time() - started < timeout_seconds:
+ try:
+ output = subprocess.check_output(
+ [
+ 'docker', 'inspect', '--format="{{.State.Health.Status}}"',
+ cid
+ ],
+ stderr=_DEVNULL)
+ if output.strip('\n') == 'healthy':
+ return
+ except subprocess.CalledProcessError as e:
+ pass
+ time.sleep(1)
+ raise Exception('Timed out waiting for %s (%s) to pass health check' %
+ (shortname, cid))
def finish_jobs(jobs):
- """Kills given docker containers and waits for corresponding jobs to finish"""
- for job in jobs:
- job.kill(suppress_failure=True)
+ """Kills given docker containers and waits for corresponding jobs to finish"""
+ for job in jobs:
+ job.kill(suppress_failure=True)
- while any(job.is_running() for job in jobs):
- time.sleep(1)
+ while any(job.is_running() for job in jobs):
+ time.sleep(1)
def image_exists(image):
- """Returns True if given docker image exists."""
- return subprocess.call(['docker','inspect', image],
- stdin=subprocess.PIPE,
- stdout=_DEVNULL,
- stderr=subprocess.STDOUT) == 0
+ """Returns True if given docker image exists."""
+ return subprocess.call(
+ ['docker', 'inspect', image],
+ stdin=subprocess.PIPE,
+ stdout=_DEVNULL,
+ stderr=subprocess.STDOUT) == 0
def remove_image(image, skip_nonexistent=False, max_retries=10):
- """Attempts to remove docker image with retries."""
- if skip_nonexistent and not image_exists(image):
- return True
- for attempt in range(0, max_retries):
- if subprocess.call(['docker','rmi', '-f', image],
- stdin=subprocess.PIPE,
- stdout=_DEVNULL,
- stderr=subprocess.STDOUT) == 0:
- return True
- time.sleep(2)
- print('Failed to remove docker image %s' % image)
- return False
+ """Attempts to remove docker image with retries."""
+ if skip_nonexistent and not image_exists(image):
+ return True
+ for attempt in range(0, max_retries):
+ if subprocess.call(
+ ['docker', 'rmi', '-f', image],
+ stdin=subprocess.PIPE,
+ stdout=_DEVNULL,
+ stderr=subprocess.STDOUT) == 0:
+ return True
+ time.sleep(2)
+ print('Failed to remove docker image %s' % image)
+ return False
class DockerJob:
- """Encapsulates a job"""
-
- def __init__(self, spec):
- self._spec = spec
- self._job = jobset.Job(spec, newline_on_success=True, travis=True, add_env={})
- self._container_name = spec.container_name
-
- def mapped_port(self, port):
- return docker_mapped_port(self._container_name, port)
-
- def wait_for_healthy(self, timeout_seconds):
- wait_for_healthy(self._container_name, self._spec.shortname, timeout_seconds)
-
- def kill(self, suppress_failure=False):
- """Sends kill signal to the container."""
- if suppress_failure:
- self._job.suppress_failure_message()
- return docker_kill(self._container_name)
-
- def is_running(self):
- """Polls a job and returns True if given job is still running."""
- return self._job.state() == jobset._RUNNING
+ """Encapsulates a job"""
+
+ def __init__(self, spec):
+ self._spec = spec
+ self._job = jobset.Job(
+ spec, newline_on_success=True, travis=True, add_env={})
+ self._container_name = spec.container_name
+
+ def mapped_port(self, port):
+ return docker_mapped_port(self._container_name, port)
+
+ def wait_for_healthy(self, timeout_seconds):
+ wait_for_healthy(self._container_name, self._spec.shortname,
+ timeout_seconds)
+
+ def kill(self, suppress_failure=False):
+ """Sends kill signal to the container."""
+ if suppress_failure:
+ self._job.suppress_failure_message()
+ return docker_kill(self._container_name)
+
+ def is_running(self):
+ """Polls a job and returns True if given job is still running."""
+ return self._job.state() == jobset._RUNNING
diff --git a/tools/run_tests/python_utils/filter_pull_request_tests.py b/tools/run_tests/python_utils/filter_pull_request_tests.py
index f99143fdd7..4c09b3414e 100644
--- a/tools/run_tests/python_utils/filter_pull_request_tests.py
+++ b/tools/run_tests/python_utils/filter_pull_request_tests.py
@@ -12,7 +12,6 @@
# 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.
-
"""Filter out tests based on file differences compared to merge target branch"""
from __future__ import print_function
@@ -23,31 +22,32 @@ from subprocess import check_output
class TestSuite:
- """
+ """
Contains label to identify job as belonging to this test suite and
triggers to identify if changed files are relevant
"""
- def __init__(self, labels):
- """
+
+ def __init__(self, labels):
+ """
Build TestSuite to group tests based on labeling
:param label: strings that should match a jobs's platform, config, language, or test group
"""
- self.triggers = []
- self.labels = labels
+ self.triggers = []
+ self.labels = labels
- def add_trigger(self, trigger):
- """
+ def add_trigger(self, trigger):
+ """
Add a regex to list of triggers that determine if a changed file should run tests
:param trigger: regex matching file relevant to tests
"""
- self.triggers.append(trigger)
+ self.triggers.append(trigger)
# Create test suites
_CORE_TEST_SUITE = TestSuite(['c'])
_CPP_TEST_SUITE = TestSuite(['c++'])
_CSHARP_TEST_SUITE = TestSuite(['csharp'])
-_NODE_TEST_SUITE = TestSuite(['node'])
+_NODE_TEST_SUITE = TestSuite(['grpc-node'])
_OBJC_TEST_SUITE = TestSuite(['objc'])
_PHP_TEST_SUITE = TestSuite(['php', 'php7'])
_PYTHON_TEST_SUITE = TestSuite(['python'])
@@ -55,10 +55,11 @@ _RUBY_TEST_SUITE = TestSuite(['ruby'])
_LINUX_TEST_SUITE = TestSuite(['linux'])
_WINDOWS_TEST_SUITE = TestSuite(['windows'])
_MACOS_TEST_SUITE = TestSuite(['macos'])
-_ALL_TEST_SUITES = [_CORE_TEST_SUITE, _CPP_TEST_SUITE, _CSHARP_TEST_SUITE,
- _NODE_TEST_SUITE, _OBJC_TEST_SUITE, _PHP_TEST_SUITE,
- _PYTHON_TEST_SUITE, _RUBY_TEST_SUITE, _LINUX_TEST_SUITE,
- _WINDOWS_TEST_SUITE, _MACOS_TEST_SUITE]
+_ALL_TEST_SUITES = [
+ _CORE_TEST_SUITE, _CPP_TEST_SUITE, _CSHARP_TEST_SUITE, _NODE_TEST_SUITE,
+ _OBJC_TEST_SUITE, _PHP_TEST_SUITE, _PYTHON_TEST_SUITE, _RUBY_TEST_SUITE,
+ _LINUX_TEST_SUITE, _WINDOWS_TEST_SUITE, _MACOS_TEST_SUITE
+]
# Dictionary of whitelistable files where the key is a regex matching changed files
# and the value is a list of tests that should be run. An empty list means that
@@ -66,49 +67,46 @@ _ALL_TEST_SUITES = [_CORE_TEST_SUITE, _CPP_TEST_SUITE, _CSHARP_TEST_SUITE,
# match any of these regexes will trigger all tests
# DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU ARE DOING (be careful even if you do)
_WHITELIST_DICT = {
- '^doc/': [],
- '^examples/': [],
- '^include/grpc\+\+/': [_CPP_TEST_SUITE],
- '^summerofcode/': [],
- '^src/cpp/': [_CPP_TEST_SUITE],
- '^src/csharp/': [_CSHARP_TEST_SUITE],
- '^src/node/': [_NODE_TEST_SUITE],
- '^src/objective\-c/': [_OBJC_TEST_SUITE],
- '^src/php/': [_PHP_TEST_SUITE],
- '^src/python/': [_PYTHON_TEST_SUITE],
- '^src/ruby/': [_RUBY_TEST_SUITE],
- '^templates/': [],
- '^test/core/': [_CORE_TEST_SUITE],
- '^test/cpp/': [_CPP_TEST_SUITE],
- '^test/distrib/cpp/': [_CPP_TEST_SUITE],
- '^test/distrib/csharp/': [_CSHARP_TEST_SUITE],
- '^test/distrib/node/': [_NODE_TEST_SUITE],
- '^test/distrib/php/': [_PHP_TEST_SUITE],
- '^test/distrib/python/': [_PYTHON_TEST_SUITE],
- '^test/distrib/ruby/': [_RUBY_TEST_SUITE],
- '^vsprojects/': [_WINDOWS_TEST_SUITE],
- 'binding\.gyp$': [_NODE_TEST_SUITE],
- 'composer\.json$': [_PHP_TEST_SUITE],
- 'config\.m4$': [_PHP_TEST_SUITE],
- 'CONTRIBUTING\.md$': [],
- 'Gemfile$': [_RUBY_TEST_SUITE],
- 'grpc\.def$': [_WINDOWS_TEST_SUITE],
- 'grpc\.gemspec$': [_RUBY_TEST_SUITE],
- 'gRPC\.podspec$': [_OBJC_TEST_SUITE],
- 'gRPC\-Core\.podspec$': [_OBJC_TEST_SUITE],
- 'gRPC\-ProtoRPC\.podspec$': [_OBJC_TEST_SUITE],
- 'gRPC\-RxLibrary\.podspec$': [_OBJC_TEST_SUITE],
- 'INSTALL\.md$': [],
- 'LICENSE$': [],
- 'MANIFEST\.md$': [],
- 'package\.json$': [_PHP_TEST_SUITE],
- 'package\.xml$': [_PHP_TEST_SUITE],
- 'PATENTS$': [],
- 'PYTHON\-MANIFEST\.in$': [_PYTHON_TEST_SUITE],
- 'README\.md$': [],
- 'requirements\.txt$': [_PYTHON_TEST_SUITE],
- 'setup\.cfg$': [_PYTHON_TEST_SUITE],
- 'setup\.py$': [_PYTHON_TEST_SUITE]
+ '^doc/': [],
+ '^examples/': [],
+ '^include/grpc\+\+/': [_CPP_TEST_SUITE],
+ '^summerofcode/': [],
+ '^src/cpp/': [_CPP_TEST_SUITE],
+ '^src/csharp/': [_CSHARP_TEST_SUITE],
+ '^src/objective\-c/': [_OBJC_TEST_SUITE],
+ '^src/php/': [_PHP_TEST_SUITE],
+ '^src/python/': [_PYTHON_TEST_SUITE],
+ '^src/ruby/': [_RUBY_TEST_SUITE],
+ '^templates/': [],
+ '^test/core/': [_CORE_TEST_SUITE, _CPP_TEST_SUITE],
+ '^test/cpp/': [_CPP_TEST_SUITE],
+ '^test/distrib/cpp/': [_CPP_TEST_SUITE],
+ '^test/distrib/csharp/': [_CSHARP_TEST_SUITE],
+ '^test/distrib/php/': [_PHP_TEST_SUITE],
+ '^test/distrib/python/': [_PYTHON_TEST_SUITE],
+ '^test/distrib/ruby/': [_RUBY_TEST_SUITE],
+ '^vsprojects/': [_WINDOWS_TEST_SUITE],
+ 'composer\.json$': [_PHP_TEST_SUITE],
+ 'config\.m4$': [_PHP_TEST_SUITE],
+ 'CONTRIBUTING\.md$': [],
+ 'Gemfile$': [_RUBY_TEST_SUITE],
+ 'grpc\.def$': [_WINDOWS_TEST_SUITE],
+ 'grpc\.gemspec$': [_RUBY_TEST_SUITE],
+ 'gRPC\.podspec$': [_OBJC_TEST_SUITE],
+ 'gRPC\-Core\.podspec$': [_OBJC_TEST_SUITE],
+ 'gRPC\-ProtoRPC\.podspec$': [_OBJC_TEST_SUITE],
+ 'gRPC\-RxLibrary\.podspec$': [_OBJC_TEST_SUITE],
+ 'INSTALL\.md$': [],
+ 'LICENSE$': [],
+ 'MANIFEST\.md$': [],
+ 'package\.json$': [_PHP_TEST_SUITE],
+ 'package\.xml$': [_PHP_TEST_SUITE],
+ 'PATENTS$': [],
+ 'PYTHON\-MANIFEST\.in$': [_PYTHON_TEST_SUITE],
+ 'README\.md$': [],
+ 'requirements\.txt$': [_PYTHON_TEST_SUITE],
+ 'setup\.cfg$': [_PYTHON_TEST_SUITE],
+ 'setup\.py$': [_PYTHON_TEST_SUITE]
}
# Regex that combines all keys in _WHITELIST_DICT
@@ -116,83 +114,88 @@ _ALL_TRIGGERS = "(" + ")|(".join(_WHITELIST_DICT.keys()) + ")"
# Add all triggers to their respective test suites
for trigger, test_suites in six.iteritems(_WHITELIST_DICT):
- for test_suite in test_suites:
- test_suite.add_trigger(trigger)
+ for test_suite in test_suites:
+ test_suite.add_trigger(trigger)
def _get_changed_files(base_branch):
- """
+ """
Get list of changed files between current branch and base of target merge branch
"""
- # Get file changes between branch and merge-base of specified branch
- # Not combined to be Windows friendly
- base_commit = check_output(["git", "merge-base", base_branch, "HEAD"]).rstrip()
- return check_output(["git", "diff", base_commit, "--name-only", "HEAD"]).splitlines()
+ # Get file changes between branch and merge-base of specified branch
+ # Not combined to be Windows friendly
+ base_commit = check_output(["git", "merge-base", base_branch,
+ "HEAD"]).rstrip()
+ return check_output(["git", "diff", base_commit, "--name-only",
+ "HEAD"]).splitlines()
def _can_skip_tests(file_names, triggers):
- """
+ """
Determines if tests are skippable based on if all files do not match list of regexes
:param file_names: list of changed files generated by _get_changed_files()
:param triggers: list of regexes matching file name that indicates tests should be run
:return: safe to skip tests
"""
- for file_name in file_names:
- if any(re.match(trigger, file_name) for trigger in triggers):
- return False
- return True
+ for file_name in file_names:
+ if any(re.match(trigger, file_name) for trigger in triggers):
+ return False
+ return True
def _remove_irrelevant_tests(tests, skippable_labels):
- """
+ """
Filters out tests by config or language - will not remove sanitizer tests
:param tests: list of all tests generated by run_tests_matrix.py
:param skippable_labels: list of languages and platforms with skippable tests
:return: list of relevant tests
"""
- # test.labels[0] is platform and test.labels[2] is language
- # We skip a test if both are considered safe to skip
- return [test for test in tests if test.labels[0] not in skippable_labels or \
- test.labels[2] not in skippable_labels]
+ # test.labels[0] is platform and test.labels[2] is language
+ # We skip a test if both are considered safe to skip
+ return [test for test in tests if test.labels[0] not in skippable_labels or \
+ test.labels[2] not in skippable_labels]
def affects_c_cpp(base_branch):
- """
+ """
Determines if a pull request's changes affect C/C++. This function exists because
there are pull request tests that only test C/C++ code
:param base_branch: branch that a pull request is requesting to merge into
:return: boolean indicating whether C/C++ changes are made in pull request
"""
- changed_files = _get_changed_files(base_branch)
- # Run all tests if any changed file is not in the whitelist dictionary
- for changed_file in changed_files:
- if not re.match(_ALL_TRIGGERS, changed_file):
- return True
- return not _can_skip_tests(changed_files, _CPP_TEST_SUITE.triggers + _CORE_TEST_SUITE.triggers)
+ changed_files = _get_changed_files(base_branch)
+ # Run all tests if any changed file is not in the whitelist dictionary
+ for changed_file in changed_files:
+ if not re.match(_ALL_TRIGGERS, changed_file):
+ return True
+ return not _can_skip_tests(
+ changed_files, _CPP_TEST_SUITE.triggers + _CORE_TEST_SUITE.triggers)
def filter_tests(tests, base_branch):
- """
+ """
Filters out tests that are safe to ignore
:param tests: list of all tests generated by run_tests_matrix.py
:return: list of relevant tests
"""
- print('Finding file differences between gRPC %s branch and pull request...\n' % base_branch)
- changed_files = _get_changed_files(base_branch)
- for changed_file in changed_files:
- print(' %s' % changed_file)
- print('')
-
- # Run all tests if any changed file is not in the whitelist dictionary
- for changed_file in changed_files:
- if not re.match(_ALL_TRIGGERS, changed_file):
- return(tests)
- # Figure out which language and platform tests to run
- skippable_labels = []
- for test_suite in _ALL_TEST_SUITES:
- if _can_skip_tests(changed_files, test_suite.triggers):
- for label in test_suite.labels:
- print(' %s tests safe to skip' % label)
- skippable_labels.append(label)
- tests = _remove_irrelevant_tests(tests, skippable_labels)
- return tests
+ print(
+ 'Finding file differences between gRPC %s branch and pull request...\n'
+ % base_branch)
+ changed_files = _get_changed_files(base_branch)
+ for changed_file in changed_files:
+ print(' %s' % changed_file)
+ print('')
+
+ # Run all tests if any changed file is not in the whitelist dictionary
+ for changed_file in changed_files:
+ if not re.match(_ALL_TRIGGERS, changed_file):
+ return (tests)
+ # Figure out which language and platform tests to run
+ skippable_labels = []
+ for test_suite in _ALL_TEST_SUITES:
+ if _can_skip_tests(changed_files, test_suite.triggers):
+ for label in test_suite.labels:
+ print(' %s tests safe to skip' % label)
+ skippable_labels.append(label)
+ tests = _remove_irrelevant_tests(tests, skippable_labels)
+ return tests
diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py
index 062c79a0de..6a3391337e 100755
--- a/tools/run_tests/python_utils/jobset.py
+++ b/tools/run_tests/python_utils/jobset.py
@@ -11,7 +11,6 @@
# 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.
-
"""Run a group of subprocesses and then finish."""
from __future__ import print_function
@@ -28,11 +27,9 @@ import tempfile
import time
import errno
-
# cpu cost measurement
measure_cpu_costs = False
-
_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
_MAX_RESULT_SIZE = 8192
@@ -42,63 +39,60 @@ _MAX_RESULT_SIZE = 8192
# characters to the PR description, which leak into the environment here
# and cause failures.
def strip_non_ascii_chars(s):
- return ''.join(c for c in s if ord(c) < 128)
+ return ''.join(c for c in s if ord(c) < 128)
def sanitized_environment(env):
- sanitized = {}
- for key, value in env.items():
- sanitized[strip_non_ascii_chars(key)] = strip_non_ascii_chars(value)
- return sanitized
+ sanitized = {}
+ for key, value in env.items():
+ sanitized[strip_non_ascii_chars(key)] = strip_non_ascii_chars(value)
+ return sanitized
def platform_string():
- if platform.system() == 'Windows':
- return 'windows'
- elif platform.system()[:7] == 'MSYS_NT':
- return 'windows'
- elif platform.system() == 'Darwin':
- return 'mac'
- elif platform.system() == 'Linux':
- return 'linux'
- else:
- return 'posix'
+ if platform.system() == 'Windows':
+ return 'windows'
+ elif platform.system()[:7] == 'MSYS_NT':
+ return 'windows'
+ elif platform.system() == 'Darwin':
+ return 'mac'
+ elif platform.system() == 'Linux':
+ return 'linux'
+ else:
+ return 'posix'
# setup a signal handler so that signal.pause registers 'something'
# when a child finishes
# not using futures and threading to avoid a dependency on subprocess32
if platform_string() == 'windows':
- pass
-else:
- def alarm_handler(unused_signum, unused_frame):
pass
+else:
- signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None)
- signal.signal(signal.SIGALRM, alarm_handler)
+ def alarm_handler(unused_signum, unused_frame):
+ pass
+ signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None)
+ signal.signal(signal.SIGALRM, alarm_handler)
_SUCCESS = object()
_FAILURE = object()
_RUNNING = object()
_KILLED = object()
-
_COLORS = {
- 'red': [ 31, 0 ],
- 'green': [ 32, 0 ],
- 'yellow': [ 33, 0 ],
- 'lightgray': [ 37, 0],
- 'gray': [ 30, 1 ],
- 'purple': [ 35, 0 ],
- 'cyan': [ 36, 0 ]
- }
-
+ 'red': [31, 0],
+ 'green': [32, 0],
+ 'yellow': [33, 0],
+ 'lightgray': [37, 0],
+ 'gray': [30, 1],
+ 'purple': [35, 0],
+ 'cyan': [36, 0]
+}
_BEGINNING_OF_LINE = '\x1b[0G'
_CLEAR_LINE = '\x1b[2K'
-
_TAG_COLOR = {
'FAILED': 'red',
'FLAKE': 'purple',
@@ -111,386 +105,443 @@ _TAG_COLOR = {
'SUCCESS': 'green',
'IDLE': 'gray',
'SKIPPED': 'cyan'
- }
+}
_FORMAT = '%(asctime)-15s %(message)s'
logging.basicConfig(level=logging.INFO, format=_FORMAT)
def eintr_be_gone(fn):
- """Run fn until it doesn't stop because of EINTR"""
- while True:
- try:
- return fn()
- except IOError, e:
- if e.errno != errno.EINTR:
- raise
-
+ """Run fn until it doesn't stop because of EINTR"""
+ while True:
+ try:
+ return fn()
+ except IOError, e:
+ if e.errno != errno.EINTR:
+ raise
def message(tag, msg, explanatory_text=None, do_newline=False):
- if message.old_tag == tag and message.old_msg == msg and not explanatory_text:
- return
- message.old_tag = tag
- message.old_msg = msg
- while True:
- try:
- if platform_string() == 'windows' or not sys.stdout.isatty():
- if explanatory_text:
- logging.info(explanatory_text)
- logging.info('%s: %s', tag, msg)
- else:
- sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % (
- _BEGINNING_OF_LINE,
- _CLEAR_LINE,
- '\n%s' % explanatory_text if explanatory_text is not None else '',
- _COLORS[_TAG_COLOR[tag]][1],
- _COLORS[_TAG_COLOR[tag]][0],
- tag,
- msg,
- '\n' if do_newline or explanatory_text is not None else ''))
- sys.stdout.flush()
- return
- except IOError, e:
- if e.errno != errno.EINTR:
- raise
+ if message.old_tag == tag and message.old_msg == msg and not explanatory_text:
+ return
+ message.old_tag = tag
+ message.old_msg = msg
+ while True:
+ try:
+ if platform_string() == 'windows' or not sys.stdout.isatty():
+ if explanatory_text:
+ logging.info(explanatory_text)
+ logging.info('%s: %s', tag, msg)
+ else:
+ sys.stdout.write(
+ '%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' %
+ (_BEGINNING_OF_LINE, _CLEAR_LINE, '\n%s' % explanatory_text
+ if explanatory_text is not None else '',
+ _COLORS[_TAG_COLOR[tag]][1], _COLORS[_TAG_COLOR[tag]][0],
+ tag, msg, '\n'
+ if do_newline or explanatory_text is not None else ''))
+ sys.stdout.flush()
+ return
+ except IOError, e:
+ if e.errno != errno.EINTR:
+ raise
+
message.old_tag = ''
message.old_msg = ''
+
def which(filename):
- if '/' in filename:
- return filename
- for path in os.environ['PATH'].split(os.pathsep):
- if os.path.exists(os.path.join(path, filename)):
- return os.path.join(path, filename)
- raise Exception('%s not found' % filename)
+ if '/' in filename:
+ return filename
+ for path in os.environ['PATH'].split(os.pathsep):
+ if os.path.exists(os.path.join(path, filename)):
+ return os.path.join(path, filename)
+ raise Exception('%s not found' % filename)
class JobSpec(object):
- """Specifies what to run for a job."""
-
- def __init__(self, cmdline, shortname=None, environ=None,
- cwd=None, shell=False, timeout_seconds=5*60, flake_retries=0,
- timeout_retries=0, kill_handler=None, cpu_cost=1.0,
- verbose_success=False):
- """
+ """Specifies what to run for a job."""
+
+ def __init__(self,
+ cmdline,
+ shortname=None,
+ environ=None,
+ cwd=None,
+ shell=False,
+ timeout_seconds=5 * 60,
+ flake_retries=0,
+ timeout_retries=0,
+ kill_handler=None,
+ cpu_cost=1.0,
+ verbose_success=False):
+ """
Arguments:
cmdline: a list of arguments to pass as the command line
environ: a dictionary of environment variables to set in the child process
kill_handler: a handler that will be called whenever job.kill() is invoked
cpu_cost: number of cores per second this job needs
"""
- if environ is None:
- environ = {}
- self.cmdline = cmdline
- self.environ = environ
- self.shortname = cmdline[0] if shortname is None else shortname
- self.cwd = cwd
- self.shell = shell
- self.timeout_seconds = timeout_seconds
- self.flake_retries = flake_retries
- self.timeout_retries = timeout_retries
- self.kill_handler = kill_handler
- self.cpu_cost = cpu_cost
- self.verbose_success = verbose_success
-
- def identity(self):
- return '%r %r' % (self.cmdline, self.environ)
-
- def __hash__(self):
- return hash(self.identity())
-
- def __cmp__(self, other):
- return self.identity() == other.identity()
-
- def __repr__(self):
- return 'JobSpec(shortname=%s, cmdline=%s)' % (self.shortname, self.cmdline)
-
- def __str__(self):
- return '%s: %s %s' % (self.shortname,
- ' '.join('%s=%s' % kv for kv in self.environ.items()),
- ' '.join(self.cmdline))
+ if environ is None:
+ environ = {}
+ self.cmdline = cmdline
+ self.environ = environ
+ self.shortname = cmdline[0] if shortname is None else shortname
+ self.cwd = cwd
+ self.shell = shell
+ self.timeout_seconds = timeout_seconds
+ self.flake_retries = flake_retries
+ self.timeout_retries = timeout_retries
+ self.kill_handler = kill_handler
+ self.cpu_cost = cpu_cost
+ self.verbose_success = verbose_success
+
+ def identity(self):
+ return '%r %r' % (self.cmdline, self.environ)
+
+ def __hash__(self):
+ return hash(self.identity())
+
+ def __cmp__(self, other):
+ return self.identity() == other.identity()
+
+ def __repr__(self):
+ return 'JobSpec(shortname=%s, cmdline=%s)' % (self.shortname,
+ self.cmdline)
+
+ def __str__(self):
+ return '%s: %s %s' % (self.shortname, ' '.join(
+ '%s=%s' % kv for kv in self.environ.items()),
+ ' '.join(self.cmdline))
class JobResult(object):
- def __init__(self):
- self.state = 'UNKNOWN'
- self.returncode = -1
- self.elapsed_time = 0
- self.num_failures = 0
- self.retries = 0
- self.message = ''
- self.cpu_estimated = 1
- self.cpu_measured = 1
+
+ def __init__(self):
+ self.state = 'UNKNOWN'
+ self.returncode = -1
+ self.elapsed_time = 0
+ self.num_failures = 0
+ self.retries = 0
+ self.message = ''
+ self.cpu_estimated = 1
+ self.cpu_measured = 1
def read_from_start(f):
- f.seek(0)
- return f.read()
+ f.seek(0)
+ return f.read()
class Job(object):
- """Manages one job."""
-
- def __init__(self, spec, newline_on_success, travis, add_env,
- quiet_success=False):
- self._spec = spec
- self._newline_on_success = newline_on_success
- self._travis = travis
- self._add_env = add_env.copy()
- self._retries = 0
- self._timeout_retries = 0
- self._suppress_failure_message = False
- self._quiet_success = quiet_success
- if not self._quiet_success:
- message('START', spec.shortname, do_newline=self._travis)
- self.result = JobResult()
- self.start()
-
- def GetSpec(self):
- return self._spec
-
- def start(self):
- self._tempfile = tempfile.TemporaryFile()
- env = dict(os.environ)
- env.update(self._spec.environ)
- env.update(self._add_env)
- env = sanitized_environment(env)
- self._start = time.time()
- cmdline = self._spec.cmdline
- # The Unix time command is finicky when used with MSBuild, so we don't use it
- # with jobs that run MSBuild.
- global measure_cpu_costs
- if measure_cpu_costs and not 'vsprojects\\build' in cmdline[0]:
- cmdline = ['time', '-p'] + cmdline
- else:
- measure_cpu_costs = False
- try_start = lambda: subprocess.Popen(args=cmdline,
- stderr=subprocess.STDOUT,
- stdout=self._tempfile,
- cwd=self._spec.cwd,
- shell=self._spec.shell,
- env=env)
- delay = 0.3
- for i in range(0, 4):
- try:
- self._process = try_start()
- break
- except OSError:
- message('WARNING', 'Failed to start %s, retrying in %f seconds' % (self._spec.shortname, delay))
- time.sleep(delay)
- delay *= 2
- else:
- self._process = try_start()
- self._state = _RUNNING
-
- def state(self):
- """Poll current state of the job. Prints messages at completion."""
- def stdout(self=self):
- stdout = read_from_start(self._tempfile)
- self.result.message = stdout[-_MAX_RESULT_SIZE:]
- return stdout
- if self._state == _RUNNING and self._process.poll() is not None:
- elapsed = time.time() - self._start
- self.result.elapsed_time = elapsed
- if self._process.returncode != 0:
- if self._retries < self._spec.flake_retries:
- message('FLAKE', '%s [ret=%d, pid=%d]' % (
- self._spec.shortname, self._process.returncode, self._process.pid),
- stdout(), do_newline=True)
- self._retries += 1
- self.result.num_failures += 1
- self.result.retries = self._timeout_retries + self._retries
- self.start()
- else:
- self._state = _FAILURE
- if not self._suppress_failure_message:
- message('FAILED', '%s [ret=%d, pid=%d]' % (
- self._spec.shortname, self._process.returncode, self._process.pid),
- stdout(), do_newline=True)
- self.result.state = 'FAILED'
- self.result.num_failures += 1
- self.result.returncode = self._process.returncode
- else:
- self._state = _SUCCESS
- measurement = ''
- if measure_cpu_costs:
- m = re.search(r'real\s+([0-9.]+)\nuser\s+([0-9.]+)\nsys\s+([0-9.]+)', stdout())
- real = float(m.group(1))
- user = float(m.group(2))
- sys = float(m.group(3))
- if real > 0.5:
- cores = (user + sys) / real
- self.result.cpu_measured = float('%.01f' % cores)
- self.result.cpu_estimated = float('%.01f' % self._spec.cpu_cost)
- measurement = '; cpu_cost=%.01f; estimated=%.01f' % (self.result.cpu_measured, self.result.cpu_estimated)
+ """Manages one job."""
+
+ def __init__(self,
+ spec,
+ newline_on_success,
+ travis,
+ add_env,
+ quiet_success=False):
+ self._spec = spec
+ self._newline_on_success = newline_on_success
+ self._travis = travis
+ self._add_env = add_env.copy()
+ self._retries = 0
+ self._timeout_retries = 0
+ self._suppress_failure_message = False
+ self._quiet_success = quiet_success
if not self._quiet_success:
- message('PASSED', '%s [time=%.1fsec; retries=%d:%d%s]' % (
- self._spec.shortname, elapsed, self._retries, self._timeout_retries, measurement),
- stdout() if self._spec.verbose_success else None,
- do_newline=self._newline_on_success or self._travis)
- self.result.state = 'PASSED'
- elif (self._state == _RUNNING and
- self._spec.timeout_seconds is not None and
- time.time() - self._start > self._spec.timeout_seconds):
- if self._timeout_retries < self._spec.timeout_retries:
- message('TIMEOUT_FLAKE', '%s [pid=%d]' % (self._spec.shortname, self._process.pid), stdout(), do_newline=True)
- self._timeout_retries += 1
- self.result.num_failures += 1
- self.result.retries = self._timeout_retries + self._retries
- if self._spec.kill_handler:
- self._spec.kill_handler(self)
- self._process.terminate()
+ message('START', spec.shortname, do_newline=self._travis)
+ self.result = JobResult()
self.start()
- else:
- message('TIMEOUT', '%s [pid=%d]' % (self._spec.shortname, self._process.pid), stdout(), do_newline=True)
- self.kill()
- self.result.state = 'TIMEOUT'
- self.result.num_failures += 1
- return self._state
- def kill(self):
- if self._state == _RUNNING:
- self._state = _KILLED
- if self._spec.kill_handler:
- self._spec.kill_handler(self)
- self._process.terminate()
-
- def suppress_failure_message(self):
- self._suppress_failure_message = True
+ def GetSpec(self):
+ return self._spec
+
+ def start(self):
+ self._tempfile = tempfile.TemporaryFile()
+ env = dict(os.environ)
+ env.update(self._spec.environ)
+ env.update(self._add_env)
+ env = sanitized_environment(env)
+ self._start = time.time()
+ cmdline = self._spec.cmdline
+ # The Unix time command is finicky when used with MSBuild, so we don't use it
+ # with jobs that run MSBuild.
+ global measure_cpu_costs
+ if measure_cpu_costs and not 'vsprojects\\build' in cmdline[0]:
+ cmdline = ['time', '-p'] + cmdline
+ else:
+ measure_cpu_costs = False
+ try_start = lambda: subprocess.Popen(args=cmdline,
+ stderr=subprocess.STDOUT,
+ stdout=self._tempfile,
+ cwd=self._spec.cwd,
+ shell=self._spec.shell,
+ env=env)
+ delay = 0.3
+ for i in range(0, 4):
+ try:
+ self._process = try_start()
+ break
+ except OSError:
+ message('WARNING',
+ 'Failed to start %s, retrying in %f seconds' %
+ (self._spec.shortname, delay))
+ time.sleep(delay)
+ delay *= 2
+ else:
+ self._process = try_start()
+ self._state = _RUNNING
+
+ def state(self):
+ """Poll current state of the job. Prints messages at completion."""
+
+ def stdout(self=self):
+ stdout = read_from_start(self._tempfile)
+ self.result.message = stdout[-_MAX_RESULT_SIZE:]
+ return stdout
+
+ if self._state == _RUNNING and self._process.poll() is not None:
+ elapsed = time.time() - self._start
+ self.result.elapsed_time = elapsed
+ if self._process.returncode != 0:
+ if self._retries < self._spec.flake_retries:
+ message(
+ 'FLAKE',
+ '%s [ret=%d, pid=%d]' %
+ (self._spec.shortname, self._process.returncode,
+ self._process.pid),
+ stdout(),
+ do_newline=True)
+ self._retries += 1
+ self.result.num_failures += 1
+ self.result.retries = self._timeout_retries + self._retries
+ # NOTE: job is restarted regardless of jobset's max_time setting
+ self.start()
+ else:
+ self._state = _FAILURE
+ if not self._suppress_failure_message:
+ message(
+ 'FAILED',
+ '%s [ret=%d, pid=%d, time=%.1fsec]' %
+ (self._spec.shortname, self._process.returncode,
+ self._process.pid, elapsed),
+ stdout(),
+ do_newline=True)
+ self.result.state = 'FAILED'
+ self.result.num_failures += 1
+ self.result.returncode = self._process.returncode
+ else:
+ self._state = _SUCCESS
+ measurement = ''
+ if measure_cpu_costs:
+ m = re.search(
+ r'real\s+([0-9.]+)\nuser\s+([0-9.]+)\nsys\s+([0-9.]+)',
+ stdout())
+ real = float(m.group(1))
+ user = float(m.group(2))
+ sys = float(m.group(3))
+ if real > 0.5:
+ cores = (user + sys) / real
+ self.result.cpu_measured = float('%.01f' % cores)
+ self.result.cpu_estimated = float(
+ '%.01f' % self._spec.cpu_cost)
+ measurement = '; cpu_cost=%.01f; estimated=%.01f' % (
+ self.result.cpu_measured, self.result.cpu_estimated)
+ if not self._quiet_success:
+ message(
+ 'PASSED',
+ '%s [time=%.1fsec, retries=%d:%d%s]' %
+ (self._spec.shortname, elapsed, self._retries,
+ self._timeout_retries, measurement),
+ stdout() if self._spec.verbose_success else None,
+ do_newline=self._newline_on_success or self._travis)
+ self.result.state = 'PASSED'
+ elif (self._state == _RUNNING and
+ self._spec.timeout_seconds is not None and
+ time.time() - self._start > self._spec.timeout_seconds):
+ elapsed = time.time() - self._start
+ self.result.elapsed_time = elapsed
+ if self._timeout_retries < self._spec.timeout_retries:
+ message(
+ 'TIMEOUT_FLAKE',
+ '%s [pid=%d]' % (self._spec.shortname, self._process.pid),
+ stdout(),
+ do_newline=True)
+ self._timeout_retries += 1
+ self.result.num_failures += 1
+ self.result.retries = self._timeout_retries + self._retries
+ if self._spec.kill_handler:
+ self._spec.kill_handler(self)
+ self._process.terminate()
+ # NOTE: job is restarted regardless of jobset's max_time setting
+ self.start()
+ else:
+ message(
+ 'TIMEOUT',
+ '%s [pid=%d, time=%.1fsec]' % (self._spec.shortname,
+ self._process.pid, elapsed),
+ stdout(),
+ do_newline=True)
+ self.kill()
+ self.result.state = 'TIMEOUT'
+ self.result.num_failures += 1
+ return self._state
+
+ def kill(self):
+ if self._state == _RUNNING:
+ self._state = _KILLED
+ if self._spec.kill_handler:
+ self._spec.kill_handler(self)
+ self._process.terminate()
+
+ def suppress_failure_message(self):
+ self._suppress_failure_message = True
class Jobset(object):
- """Manages one run of jobs."""
-
- def __init__(self, check_cancelled, maxjobs, newline_on_success, travis,
- stop_on_failure, add_env, quiet_success, max_time):
- self._running = set()
- self._check_cancelled = check_cancelled
- self._cancelled = False
- self._failures = 0
- self._completed = 0
- self._maxjobs = maxjobs
- self._newline_on_success = newline_on_success
- self._travis = travis
- self._stop_on_failure = stop_on_failure
- self._add_env = add_env
- self._quiet_success = quiet_success
- self._max_time = max_time
- self.resultset = {}
- self._remaining = None
- self._start_time = time.time()
-
- def set_remaining(self, remaining):
- self._remaining = remaining
-
- def get_num_failures(self):
- return self._failures
-
- def cpu_cost(self):
- c = 0
- for job in self._running:
- c += job._spec.cpu_cost
- return c
-
- def start(self, spec):
- """Start a job. Return True on success, False on failure."""
- while True:
- if self._max_time > 0 and time.time() - self._start_time > self._max_time:
- skipped_job_result = JobResult()
- skipped_job_result.state = 'SKIPPED'
- message('SKIPPED', spec.shortname, do_newline=True)
- self.resultset[spec.shortname] = [skipped_job_result]
+ """Manages one run of jobs."""
+
+ def __init__(self, check_cancelled, maxjobs, maxjobs_cpu_agnostic,
+ newline_on_success, travis, stop_on_failure, add_env,
+ quiet_success, max_time):
+ self._running = set()
+ self._check_cancelled = check_cancelled
+ self._cancelled = False
+ self._failures = 0
+ self._completed = 0
+ self._maxjobs = maxjobs
+ self._maxjobs_cpu_agnostic = maxjobs_cpu_agnostic
+ self._newline_on_success = newline_on_success
+ self._travis = travis
+ self._stop_on_failure = stop_on_failure
+ self._add_env = add_env
+ self._quiet_success = quiet_success
+ self._max_time = max_time
+ self.resultset = {}
+ self._remaining = None
+ self._start_time = time.time()
+
+ def set_remaining(self, remaining):
+ self._remaining = remaining
+
+ def get_num_failures(self):
+ return self._failures
+
+ def cpu_cost(self):
+ c = 0
+ for job in self._running:
+ c += job._spec.cpu_cost
+ return c
+
+ def start(self, spec):
+ """Start a job. Return True on success, False on failure."""
+ while True:
+ if self._max_time > 0 and time.time(
+ ) - self._start_time > self._max_time:
+ skipped_job_result = JobResult()
+ skipped_job_result.state = 'SKIPPED'
+ message('SKIPPED', spec.shortname, do_newline=True)
+ self.resultset[spec.shortname] = [skipped_job_result]
+ return True
+ if self.cancelled(): return False
+ current_cpu_cost = self.cpu_cost()
+ if current_cpu_cost == 0: break
+ if current_cpu_cost + spec.cpu_cost <= self._maxjobs:
+ if len(self._running) < self._maxjobs_cpu_agnostic:
+ break
+ self.reap(spec.shortname, spec.cpu_cost)
+ if self.cancelled(): return False
+ job = Job(spec, self._newline_on_success, self._travis, self._add_env,
+ self._quiet_success)
+ self._running.add(job)
+ if job.GetSpec().shortname not in self.resultset:
+ self.resultset[job.GetSpec().shortname] = []
return True
- if self.cancelled(): return False
- current_cpu_cost = self.cpu_cost()
- if current_cpu_cost == 0: break
- if current_cpu_cost + spec.cpu_cost <= self._maxjobs: break
- self.reap()
- if self.cancelled(): return False
- job = Job(spec,
- self._newline_on_success,
- self._travis,
- self._add_env,
- self._quiet_success)
- self._running.add(job)
- if job.GetSpec().shortname not in self.resultset:
- self.resultset[job.GetSpec().shortname] = []
- return True
-
- def reap(self):
- """Collect the dead jobs."""
- while self._running:
- dead = set()
- for job in self._running:
- st = eintr_be_gone(lambda: job.state())
- if st == _RUNNING: continue
- if st == _FAILURE or st == _KILLED:
- self._failures += 1
- if self._stop_on_failure:
- self._cancelled = True
+
+ def reap(self, waiting_for=None, waiting_for_cost=None):
+ """Collect the dead jobs."""
+ while self._running:
+ dead = set()
for job in self._running:
- job.kill()
- dead.add(job)
- break
- for job in dead:
- self._completed += 1
- if not self._quiet_success or job.result.state != 'PASSED':
- self.resultset[job.GetSpec().shortname].append(job.result)
- self._running.remove(job)
- if dead: return
- if not self._travis and platform_string() != 'windows':
- rstr = '' if self._remaining is None else '%d queued, ' % self._remaining
- if self._remaining is not None and self._completed > 0:
- now = time.time()
- sofar = now - self._start_time
- remaining = sofar / self._completed * (self._remaining + len(self._running))
- rstr = 'ETA %.1f sec; %s' % (remaining, rstr)
- message('WAITING', '%s%d jobs running, %d complete, %d failed' % (
- rstr, len(self._running), self._completed, self._failures))
- if platform_string() == 'windows':
- time.sleep(0.1)
- else:
- signal.alarm(10)
- signal.pause()
-
- def cancelled(self):
- """Poll for cancellation."""
- if self._cancelled: return True
- if not self._check_cancelled(): return False
- for job in self._running:
- job.kill()
- self._cancelled = True
- return True
-
- def finish(self):
- while self._running:
- if self.cancelled(): pass # poll cancellation
- self.reap()
- if platform_string() != 'windows':
- signal.alarm(0)
- return not self.cancelled() and self._failures == 0
+ st = eintr_be_gone(lambda: job.state())
+ if st == _RUNNING: continue
+ if st == _FAILURE or st == _KILLED:
+ self._failures += 1
+ if self._stop_on_failure:
+ self._cancelled = True
+ for job in self._running:
+ job.kill()
+ dead.add(job)
+ break
+ for job in dead:
+ self._completed += 1
+ if not self._quiet_success or job.result.state != 'PASSED':
+ self.resultset[job.GetSpec().shortname].append(job.result)
+ self._running.remove(job)
+ if dead: return
+ if not self._travis and platform_string() != 'windows':
+ rstr = '' if self._remaining is None else '%d queued, ' % self._remaining
+ if self._remaining is not None and self._completed > 0:
+ now = time.time()
+ sofar = now - self._start_time
+ remaining = sofar / self._completed * (
+ self._remaining + len(self._running))
+ rstr = 'ETA %.1f sec; %s' % (remaining, rstr)
+ if waiting_for is not None:
+ wstr = ' next: %s @ %.2f cpu' % (waiting_for,
+ waiting_for_cost)
+ else:
+ wstr = ''
+ message(
+ 'WAITING',
+ '%s%d jobs running, %d complete, %d failed (load %.2f)%s' %
+ (rstr, len(self._running), self._completed, self._failures,
+ self.cpu_cost(), wstr))
+ if platform_string() == 'windows':
+ time.sleep(0.1)
+ else:
+ signal.alarm(10)
+ signal.pause()
+
+ def cancelled(self):
+ """Poll for cancellation."""
+ if self._cancelled: return True
+ if not self._check_cancelled(): return False
+ for job in self._running:
+ job.kill()
+ self._cancelled = True
+ return True
+
+ def finish(self):
+ while self._running:
+ if self.cancelled(): pass # poll cancellation
+ self.reap()
+ if platform_string() != 'windows':
+ signal.alarm(0)
+ return not self.cancelled() and self._failures == 0
def _never_cancelled():
- return False
+ return False
def tag_remaining(xs):
- staging = []
- for x in xs:
- staging.append(x)
- if len(staging) > 5000:
- yield (staging.pop(0), None)
- n = len(staging)
- for i, x in enumerate(staging):
- yield (x, n - i - 1)
+ staging = []
+ for x in xs:
+ staging.append(x)
+ if len(staging) > 5000:
+ yield (staging.pop(0), None)
+ n = len(staging)
+ for i, x in enumerate(staging):
+ yield (x, n - i - 1)
def run(cmdlines,
check_cancelled=_never_cancelled,
maxjobs=None,
+ maxjobs_cpu_agnostic=None,
newline_on_success=False,
travis=False,
infinite_runs=False,
@@ -499,22 +550,23 @@ def run(cmdlines,
skip_jobs=False,
quiet_success=False,
max_time=-1):
- if skip_jobs:
- resultset = {}
- skipped_job_result = JobResult()
- skipped_job_result.state = 'SKIPPED'
- for job in cmdlines:
- message('SKIPPED', job.shortname, do_newline=True)
- resultset[job.shortname] = [skipped_job_result]
- return 0, resultset
- js = Jobset(check_cancelled,
- maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS,
- newline_on_success, travis, stop_on_failure, add_env,
- quiet_success, max_time)
- for cmdline, remaining in tag_remaining(cmdlines):
- if not js.start(cmdline):
- break
- if remaining is not None:
- js.set_remaining(remaining)
- js.finish()
- return js.get_num_failures(), js.resultset
+ if skip_jobs:
+ resultset = {}
+ skipped_job_result = JobResult()
+ skipped_job_result.state = 'SKIPPED'
+ for job in cmdlines:
+ message('SKIPPED', job.shortname, do_newline=True)
+ resultset[job.shortname] = [skipped_job_result]
+ return 0, resultset
+ js = Jobset(check_cancelled, maxjobs if maxjobs is not None else
+ _DEFAULT_MAX_JOBS, maxjobs_cpu_agnostic
+ if maxjobs_cpu_agnostic is not None else _DEFAULT_MAX_JOBS,
+ newline_on_success, travis, stop_on_failure, add_env,
+ quiet_success, max_time)
+ for cmdline, remaining in tag_remaining(cmdlines):
+ if not js.start(cmdline):
+ break
+ if remaining is not None:
+ js.set_remaining(remaining)
+ js.finish()
+ return js.get_num_failures(), js.resultset
diff --git a/tools/run_tests/python_utils/port_server.py b/tools/run_tests/python_utils/port_server.py
index 4fb5ca0e94..83e09c09d0 100755
--- a/tools/run_tests/python_utils/port_server.py
+++ b/tools/run_tests/python_utils/port_server.py
@@ -12,7 +12,6 @@
# 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.
-
"""Manage TCP ports for unit tests; started by run_tests.py"""
import argparse
@@ -27,17 +26,14 @@ from SocketServer import ThreadingMixIn
import threading
import platform
-
# increment this number whenever making a change to ensure that
# the changes are picked up by running CI servers
# note that all changes must be backwards compatible
_MY_VERSION = 20
-
if len(sys.argv) == 2 and sys.argv[1] == 'dump_version':
- print _MY_VERSION
- sys.exit(0)
-
+ print _MY_VERSION
+ sys.exit(0)
argp = argparse.ArgumentParser(description='Server for httpcli_test')
argp.add_argument('-p', '--port', default=12345, type=int)
@@ -45,11 +41,11 @@ argp.add_argument('-l', '--logfile', default=None, type=str)
args = argp.parse_args()
if args.logfile is not None:
- sys.stdin.close()
- sys.stderr.close()
- sys.stdout.close()
- sys.stderr = open(args.logfile, 'w')
- sys.stdout = sys.stderr
+ sys.stdin.close()
+ sys.stderr.close()
+ sys.stdout.close()
+ sys.stderr = open(args.logfile, 'w')
+ sys.stdout = sys.stderr
print 'port server running on port %d' % args.port
@@ -57,67 +53,85 @@ pool = []
in_use = {}
mu = threading.Lock()
+# Cronet restricts the following ports to be used (see
+# https://cs.chromium.org/chromium/src/net/base/port_util.cc). When one of these
+# ports is used in a Cronet test, the test would fail (see issue #12149). These
+# ports must be excluded from pool.
+cronet_restricted_ports = [
+ 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87,
+ 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139,
+ 143, 179, 389, 465, 512, 513, 514, 515, 526, 530, 531, 532, 540, 556, 563,
+ 587, 601, 636, 993, 995, 2049, 3659, 4045, 6000, 6665, 6666, 6667, 6668,
+ 6669, 6697
+]
+
+
def can_connect(port):
- # this test is only really useful on unices where SO_REUSE_PORT is available
- # so on Windows, where this test is expensive, skip it
- if platform.system() == 'Windows': return False
- s = socket.socket()
- try:
- s.connect(('localhost', port))
- return True
- except socket.error, e:
- return False
- finally:
- s.close()
+ # this test is only really useful on unices where SO_REUSE_PORT is available
+ # so on Windows, where this test is expensive, skip it
+ if platform.system() == 'Windows': return False
+ s = socket.socket()
+ try:
+ s.connect(('localhost', port))
+ return True
+ except socket.error, e:
+ return False
+ finally:
+ s.close()
+
def can_bind(port, proto):
- s = socket.socket(proto, socket.SOCK_STREAM)
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- try:
- s.bind(('localhost', port))
- return True
- except socket.error, e:
- return False
- finally:
- s.close()
+ s = socket.socket(proto, socket.SOCK_STREAM)
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ try:
+ s.bind(('localhost', port))
+ return True
+ except socket.error, e:
+ return False
+ finally:
+ s.close()
def refill_pool(max_timeout, req):
- """Scan for ports not marked for being in use"""
- chk = list(range(1025, 32766))
- random.shuffle(chk)
- for i in chk:
- if len(pool) > 100: break
- if i in in_use:
- age = time.time() - in_use[i]
- if age < max_timeout:
- continue
- req.log_message("kill old request %d" % i)
- del in_use[i]
- if can_bind(i, socket.AF_INET) and can_bind(i, socket.AF_INET6) and not can_connect(i):
- req.log_message("found available port %d" % i)
- pool.append(i)
+ """Scan for ports not marked for being in use"""
+ chk = [
+ port for port in list(range(1025, 32766))
+ if port not in cronet_restricted_ports
+ ]
+ random.shuffle(chk)
+ for i in chk:
+ if len(pool) > 100: break
+ if i in in_use:
+ age = time.time() - in_use[i]
+ if age < max_timeout:
+ continue
+ req.log_message("kill old request %d" % i)
+ del in_use[i]
+ if can_bind(i, socket.AF_INET) and can_bind(
+ i, socket.AF_INET6) and not can_connect(i):
+ req.log_message("found available port %d" % i)
+ pool.append(i)
def allocate_port(req):
- global pool
- global in_use
- global mu
- mu.acquire()
- max_timeout = 600
- while not pool:
- refill_pool(max_timeout, req)
- if not pool:
- req.log_message("failed to find ports: retrying soon")
- mu.release()
- time.sleep(1)
- mu.acquire()
- max_timeout /= 2
- port = pool[0]
- pool = pool[1:]
- in_use[port] = time.time()
- mu.release()
- return port
+ global pool
+ global in_use
+ global mu
+ mu.acquire()
+ max_timeout = 600
+ while not pool:
+ refill_pool(max_timeout, req)
+ if not pool:
+ req.log_message("failed to find ports: retrying soon")
+ mu.release()
+ time.sleep(1)
+ mu.acquire()
+ max_timeout /= 2
+ port = pool[0]
+ pool = pool[1:]
+ in_use[port] = time.time()
+ mu.release()
+ return port
keep_running = True
@@ -125,61 +139,68 @@ keep_running = True
class Handler(BaseHTTPRequestHandler):
- def setup(self):
- # If the client is unreachable for 5 seconds, close the connection
- self.timeout = 5
- BaseHTTPRequestHandler.setup(self)
+ def setup(self):
+ # If the client is unreachable for 5 seconds, close the connection
+ self.timeout = 5
+ BaseHTTPRequestHandler.setup(self)
+
+ def do_GET(self):
+ global keep_running
+ global mu
+ if self.path == '/get':
+ # allocate a new port, it will stay bound for ten minutes and until
+ # it's unused
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/plain')
+ self.end_headers()
+ p = allocate_port(self)
+ self.log_message('allocated port %d' % p)
+ self.wfile.write('%d' % p)
+ elif self.path[0:6] == '/drop/':
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/plain')
+ self.end_headers()
+ p = int(self.path[6:])
+ mu.acquire()
+ if p in in_use:
+ del in_use[p]
+ pool.append(p)
+ k = 'known'
+ else:
+ k = 'unknown'
+ mu.release()
+ self.log_message('drop %s port %d' % (k, p))
+ elif self.path == '/version_number':
+ # fetch a version string and the current process pid
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/plain')
+ self.end_headers()
+ self.wfile.write(_MY_VERSION)
+ elif self.path == '/dump':
+ # yaml module is not installed on Macs and Windows machines by default
+ # so we import it lazily (/dump action is only used for debugging)
+ import yaml
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/plain')
+ self.end_headers()
+ mu.acquire()
+ now = time.time()
+ out = yaml.dump({
+ 'pool':
+ pool,
+ 'in_use':
+ dict((k, now - v) for k, v in in_use.items())
+ })
+ mu.release()
+ self.wfile.write(out)
+ elif self.path == '/quitquitquit':
+ self.send_response(200)
+ self.end_headers()
+ self.server.shutdown()
- def do_GET(self):
- global keep_running
- global mu
- if self.path == '/get':
- # allocate a new port, it will stay bound for ten minutes and until
- # it's unused
- self.send_response(200)
- self.send_header('Content-Type', 'text/plain')
- self.end_headers()
- p = allocate_port(self)
- self.log_message('allocated port %d' % p)
- self.wfile.write('%d' % p)
- elif self.path[0:6] == '/drop/':
- self.send_response(200)
- self.send_header('Content-Type', 'text/plain')
- self.end_headers()
- p = int(self.path[6:])
- mu.acquire()
- if p in in_use:
- del in_use[p]
- pool.append(p)
- k = 'known'
- else:
- k = 'unknown'
- mu.release()
- self.log_message('drop %s port %d' % (k, p))
- elif self.path == '/version_number':
- # fetch a version string and the current process pid
- self.send_response(200)
- self.send_header('Content-Type', 'text/plain')
- self.end_headers()
- self.wfile.write(_MY_VERSION)
- elif self.path == '/dump':
- # yaml module is not installed on Macs and Windows machines by default
- # so we import it lazily (/dump action is only used for debugging)
- import yaml
- self.send_response(200)
- self.send_header('Content-Type', 'text/plain')
- self.end_headers()
- mu.acquire()
- now = time.time()
- out = yaml.dump({'pool': pool, 'in_use': dict((k, now - v) for k, v in in_use.items())})
- mu.release()
- self.wfile.write(out)
- elif self.path == '/quitquitquit':
- self.send_response(200)
- self.end_headers()
- self.server.shutdown()
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
- """Handle requests in a separate thread"""
+ """Handle requests in a separate thread"""
+
ThreadedHTTPServer(('', args.port), Handler).serve_forever()
diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py
index a3867808b5..e4fddb8a7d 100644
--- a/tools/run_tests/python_utils/report_utils.py
+++ b/tools/run_tests/python_utils/report_utils.py
@@ -11,17 +11,16 @@
# 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.
-
"""Generate XML and HTML test reports."""
from __future__ import print_function
try:
- from mako.runtime import Context
- from mako.template import Template
- from mako import exceptions
+ from mako.runtime import Context
+ from mako.template import Template
+ from mako import exceptions
except (ImportError):
- pass # Mako not installed but it is ok.
+ pass # Mako not installed but it is ok.
import datetime
import os
import string
@@ -30,111 +29,127 @@ import six
def _filter_msg(msg, output_format):
- """Filters out nonprintable and illegal characters from the message."""
- if output_format in ['XML', 'HTML']:
- # keep whitespaces but remove formfeed and vertical tab characters
- # that make XML report unparseable.
- filtered_msg = filter(
- lambda x: x in string.printable and x != '\f' and x != '\v',
- msg.decode('UTF-8', 'ignore'))
- if output_format == 'HTML':
- filtered_msg = filtered_msg.replace('"', '&quot;')
- return filtered_msg
- else:
- return msg
+ """Filters out nonprintable and illegal characters from the message."""
+ if output_format in ['XML', 'HTML']:
+ # keep whitespaces but remove formfeed and vertical tab characters
+ # that make XML report unparseable.
+ filtered_msg = filter(
+ lambda x: x in string.printable and x != '\f' and x != '\v',
+ msg.decode('UTF-8', 'ignore'))
+ if output_format == 'HTML':
+ filtered_msg = filtered_msg.replace('"', '&quot;')
+ return filtered_msg
+ else:
+ return msg
def new_junit_xml_tree():
- return ET.ElementTree(ET.Element('testsuites'))
+ return ET.ElementTree(ET.Element('testsuites'))
+
-def render_junit_xml_report(resultset, report_file, suite_package='grpc',
+def render_junit_xml_report(resultset,
+ report_file,
+ suite_package='grpc',
suite_name='tests'):
- """Generate JUnit-like XML report."""
- tree = new_junit_xml_tree()
- append_junit_xml_results(tree, resultset, suite_package, suite_name, '1')
- create_xml_report_file(tree, report_file)
+ """Generate JUnit-like XML report."""
+ tree = new_junit_xml_tree()
+ append_junit_xml_results(tree, resultset, suite_package, suite_name, '1')
+ create_xml_report_file(tree, report_file)
+
def create_xml_report_file(tree, report_file):
- """Generate JUnit-like report file from xml tree ."""
- # ensure the report directory exists
- report_dir = os.path.dirname(os.path.abspath(report_file))
- if not os.path.exists(report_dir):
- os.makedirs(report_dir)
- tree.write(report_file, encoding='UTF-8')
+ """Generate JUnit-like report file from xml tree ."""
+ # ensure the report directory exists
+ report_dir = os.path.dirname(os.path.abspath(report_file))
+ if not os.path.exists(report_dir):
+ os.makedirs(report_dir)
+ tree.write(report_file, encoding='UTF-8')
+
def append_junit_xml_results(tree, resultset, suite_package, suite_name, id):
- """Append a JUnit-like XML report tree with test results as a new suite."""
- testsuite = ET.SubElement(tree.getroot(), 'testsuite',
- id=id, package=suite_package, name=suite_name,
- timestamp=datetime.datetime.now().isoformat())
- failure_count = 0
- error_count = 0
- for shortname, results in six.iteritems(resultset):
- for result in results:
- xml_test = ET.SubElement(testsuite, 'testcase', name=shortname)
- if result.elapsed_time:
- xml_test.set('time', str(result.elapsed_time))
- filtered_msg = _filter_msg(result.message, 'XML')
- if result.state == 'FAILED':
- ET.SubElement(xml_test, 'failure', message='Failure').text = filtered_msg
- failure_count += 1
- elif result.state == 'TIMEOUT':
- ET.SubElement(xml_test, 'error', message='Timeout').text = filtered_msg
- error_count += 1
- elif result.state == 'SKIPPED':
- ET.SubElement(xml_test, 'skipped', message='Skipped')
- testsuite.set('failures', str(failure_count))
- testsuite.set('errors', str(error_count))
-
-def render_interop_html_report(
- client_langs, server_langs, test_cases, auth_test_cases, http2_cases,
- http2_server_cases, resultset,
- num_failures, cloud_to_prod, prod_servers, http2_interop):
- """Generate HTML report for interop tests."""
- template_file = 'tools/run_tests/interop/interop_html_report.template'
- try:
- mytemplate = Template(filename=template_file, format_exceptions=True)
- except NameError:
- print('Mako template is not installed. Skipping HTML report generation.')
- return
- except IOError as e:
- print('Failed to find the template %s: %s' % (template_file, e))
- return
-
- sorted_test_cases = sorted(test_cases)
- sorted_auth_test_cases = sorted(auth_test_cases)
- sorted_http2_cases = sorted(http2_cases)
- sorted_http2_server_cases = sorted(http2_server_cases)
- sorted_client_langs = sorted(client_langs)
- sorted_server_langs = sorted(server_langs)
- sorted_prod_servers = sorted(prod_servers)
-
- args = {'client_langs': sorted_client_langs,
- 'server_langs': sorted_server_langs,
- 'test_cases': sorted_test_cases,
- 'auth_test_cases': sorted_auth_test_cases,
- 'http2_cases': sorted_http2_cases,
- 'http2_server_cases': sorted_http2_server_cases,
- 'resultset': resultset,
- 'num_failures': num_failures,
- 'cloud_to_prod': cloud_to_prod,
- 'prod_servers': sorted_prod_servers,
- 'http2_interop': http2_interop}
-
- html_report_out_dir = 'reports'
- if not os.path.exists(html_report_out_dir):
- os.mkdir(html_report_out_dir)
- html_file_path = os.path.join(html_report_out_dir, 'index.html')
- try:
- with open(html_file_path, 'w') as output_file:
- mytemplate.render_context(Context(output_file, **args))
- except:
- print(exceptions.text_error_template().render())
- raise
+ """Append a JUnit-like XML report tree with test results as a new suite."""
+ testsuite = ET.SubElement(
+ tree.getroot(),
+ 'testsuite',
+ id=id,
+ package=suite_package,
+ name=suite_name,
+ timestamp=datetime.datetime.now().isoformat())
+ failure_count = 0
+ error_count = 0
+ for shortname, results in six.iteritems(resultset):
+ for result in results:
+ xml_test = ET.SubElement(testsuite, 'testcase', name=shortname)
+ if result.elapsed_time:
+ xml_test.set('time', str(result.elapsed_time))
+ filtered_msg = _filter_msg(result.message, 'XML')
+ if result.state == 'FAILED':
+ ET.SubElement(
+ xml_test, 'failure', message='Failure').text = filtered_msg
+ failure_count += 1
+ elif result.state == 'TIMEOUT':
+ ET.SubElement(
+ xml_test, 'error', message='Timeout').text = filtered_msg
+ error_count += 1
+ elif result.state == 'SKIPPED':
+ ET.SubElement(xml_test, 'skipped', message='Skipped')
+ testsuite.set('failures', str(failure_count))
+ testsuite.set('errors', str(error_count))
+
+
+def render_interop_html_report(client_langs, server_langs, test_cases,
+ auth_test_cases, http2_cases, http2_server_cases,
+ resultset, num_failures, cloud_to_prod,
+ prod_servers, http2_interop):
+ """Generate HTML report for interop tests."""
+ template_file = 'tools/run_tests/interop/interop_html_report.template'
+ try:
+ mytemplate = Template(filename=template_file, format_exceptions=True)
+ except NameError:
+ print(
+ 'Mako template is not installed. Skipping HTML report generation.')
+ return
+ except IOError as e:
+ print('Failed to find the template %s: %s' % (template_file, e))
+ return
+
+ sorted_test_cases = sorted(test_cases)
+ sorted_auth_test_cases = sorted(auth_test_cases)
+ sorted_http2_cases = sorted(http2_cases)
+ sorted_http2_server_cases = sorted(http2_server_cases)
+ sorted_client_langs = sorted(client_langs)
+ sorted_server_langs = sorted(server_langs)
+ sorted_prod_servers = sorted(prod_servers)
+
+ args = {
+ 'client_langs': sorted_client_langs,
+ 'server_langs': sorted_server_langs,
+ 'test_cases': sorted_test_cases,
+ 'auth_test_cases': sorted_auth_test_cases,
+ 'http2_cases': sorted_http2_cases,
+ 'http2_server_cases': sorted_http2_server_cases,
+ 'resultset': resultset,
+ 'num_failures': num_failures,
+ 'cloud_to_prod': cloud_to_prod,
+ 'prod_servers': sorted_prod_servers,
+ 'http2_interop': http2_interop
+ }
+
+ html_report_out_dir = 'reports'
+ if not os.path.exists(html_report_out_dir):
+ os.mkdir(html_report_out_dir)
+ html_file_path = os.path.join(html_report_out_dir, 'index.html')
+ try:
+ with open(html_file_path, 'w') as output_file:
+ mytemplate.render_context(Context(output_file, **args))
+ except:
+ print(exceptions.text_error_template().render())
+ raise
+
def render_perf_profiling_results(output_filepath, profile_names):
- with open(output_filepath, 'w') as output_file:
- output_file.write('<ul>\n')
- for name in profile_names:
- output_file.write('<li><a href=%s>%s</a></li>\n' % (name, name))
- output_file.write('</ul>\n')
+ with open(output_filepath, 'w') as output_file:
+ output_file.write('<ul>\n')
+ for name in profile_names:
+ output_file.write('<li><a href=%s>%s</a></li>\n' % (name, name))
+ output_file.write('</ul>\n')
diff --git a/tools/run_tests/python_utils/start_port_server.py b/tools/run_tests/python_utils/start_port_server.py
index 786103ccdf..37995acbdf 100644
--- a/tools/run_tests/python_utils/start_port_server.py
+++ b/tools/run_tests/python_utils/start_port_server.py
@@ -22,10 +22,10 @@ import sys
import tempfile
import time
-
# must be synchronized with test/core/utils/port_server_client.h
_PORT_SERVER_PORT = 32766
+
def start_port_server():
# check if a compatible port server is running
# if incompatible (version mismatch) ==> start a new one
@@ -33,9 +33,8 @@ def start_port_server():
# otherwise, leave it up
try:
version = int(
- urllib.urlopen(
- 'http://localhost:%d/version_number' %
- _PORT_SERVER_PORT).read())
+ urllib.urlopen('http://localhost:%d/version_number' %
+ _PORT_SERVER_PORT).read())
logging.info('detected port server running version %d', version)
running = True
except Exception as e:
@@ -44,16 +43,16 @@ def start_port_server():
if running:
current_version = int(
subprocess.check_output([
- sys.executable, os.path.abspath(
- 'tools/run_tests/python_utils/port_server.py'),
+ sys.executable,
+ os.path.abspath('tools/run_tests/python_utils/port_server.py'),
'dump_version'
]))
logging.info('my port server is version %d', current_version)
running = (version >= current_version)
if not running:
logging.info('port_server version mismatch: killing the old one')
- urllib.urlopen('http://localhost:%d/quitquitquit' %
- _PORT_SERVER_PORT).read()
+ urllib.urlopen(
+ 'http://localhost:%d/quitquitquit' % _PORT_SERVER_PORT).read()
time.sleep(1)
if not running:
fd, logfile = tempfile.mkstemp()
@@ -62,7 +61,8 @@ def start_port_server():
args = [
sys.executable,
os.path.abspath('tools/run_tests/python_utils/port_server.py'),
- '-p', '%d' % _PORT_SERVER_PORT, '-l', logfile
+ '-p',
+ '%d' % _PORT_SERVER_PORT, '-l', logfile
]
env = dict(os.environ)
env['BUILD_ID'] = 'pleaseDontKillMeJenkins'
diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py
index 580e7f7d81..a2dd1c66cf 100644
--- a/tools/run_tests/python_utils/upload_test_results.py
+++ b/tools/run_tests/python_utils/upload_test_results.py
@@ -12,7 +12,6 @@
# 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.
-
"""Helper to upload Jenkins test results to BQ"""
from __future__ import print_function
@@ -23,8 +22,8 @@ import sys
import time
import uuid
-gcp_utils_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../../gcp/utils'))
+gcp_utils_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../../gcp/utils'))
sys.path.append(gcp_utils_dir)
import big_query_utils
@@ -35,42 +34,60 @@ _EXPIRATION_MS = 90 * 24 * 60 * 60 * 1000
_PARTITION_TYPE = 'DAY'
_PROJECT_ID = 'grpc-testing'
_RESULTS_SCHEMA = [
- ('job_name', 'STRING', 'Name of Jenkins job'),
- ('build_id', 'INTEGER', 'Build ID of Jenkins job'),
- ('build_url', 'STRING', 'URL of Jenkins job'),
- ('test_name', 'STRING', 'Individual test name'),
- ('language', 'STRING', 'Language of test'),
- ('platform', 'STRING', 'Platform used for test'),
- ('config', 'STRING', 'Config used for test'),
- ('compiler', 'STRING', 'Compiler used for test'),
- ('iomgr_platform', 'STRING', 'Iomgr used for test'),
- ('result', 'STRING', 'Test result: PASSED, TIMEOUT, FAILED, or SKIPPED'),
- ('timestamp', 'TIMESTAMP', 'Timestamp of test run'),
- ('elapsed_time', 'FLOAT', 'How long test took to run'),
- ('cpu_estimated', 'FLOAT', 'Estimated CPU usage of test'),
- ('cpu_measured', 'FLOAT', 'Actual CPU usage of test'),
- ('return_code', 'INTEGER', 'Exit code of test'),
+ ('job_name', 'STRING', 'Name of Jenkins job'),
+ ('build_id', 'INTEGER', 'Build ID of Jenkins job'),
+ ('build_url', 'STRING', 'URL of Jenkins job'),
+ ('test_name', 'STRING', 'Individual test name'),
+ ('language', 'STRING', 'Language of test'),
+ ('platform', 'STRING', 'Platform used for test'),
+ ('config', 'STRING', 'Config used for test'),
+ ('compiler', 'STRING', 'Compiler used for test'),
+ ('iomgr_platform', 'STRING', 'Iomgr used for test'),
+ ('result', 'STRING', 'Test result: PASSED, TIMEOUT, FAILED, or SKIPPED'),
+ ('timestamp', 'TIMESTAMP', 'Timestamp of test run'),
+ ('elapsed_time', 'FLOAT', 'How long test took to run'),
+ ('cpu_estimated', 'FLOAT', 'Estimated CPU usage of test'),
+ ('cpu_measured', 'FLOAT', 'Actual CPU usage of test'),
+ ('return_code', 'INTEGER', 'Exit code of test'),
+]
+_INTEROP_RESULTS_SCHEMA = [
+ ('job_name', 'STRING', 'Name of Jenkins/Kokoro job'),
+ ('build_id', 'INTEGER', 'Build ID of Jenkins/Kokoro job'),
+ ('build_url', 'STRING', 'URL of Jenkins/Kokoro job'),
+ ('test_name', 'STRING',
+ 'Unique test name combining client, server, and test_name'),
+ ('suite', 'STRING',
+ 'Test suite: cloud_to_cloud, cloud_to_prod, or cloud_to_prod_auth'),
+ ('client', 'STRING', 'Client language'),
+ ('server', 'STRING', 'Server host name'),
+ ('test_case', 'STRING', 'Name of test case'),
+ ('result', 'STRING', 'Test result: PASSED, TIMEOUT, FAILED, or SKIPPED'),
+ ('timestamp', 'TIMESTAMP', 'Timestamp of test run'),
+ ('elapsed_time', 'FLOAT', 'How long test took to run'),
]
def _get_build_metadata(test_results):
- """Add Jenkins/Kokoro build metadata to test_results based on environment
+ """Add Jenkins/Kokoro build metadata to test_results based on environment
variables set by Jenkins/Kokoro.
"""
- build_id = os.getenv('BUILD_ID') or os.getenv('KOKORO_BUILD_NUMBER')
- build_url = os.getenv('BUILD_URL') or os.getenv('KOKORO_BUILD_URL')
- job_name = os.getenv('JOB_BASE_NAME') or os.getenv('KOKORO_JOB_NAME')
+ build_id = os.getenv('BUILD_ID') or os.getenv('KOKORO_BUILD_NUMBER')
+ build_url = os.getenv('BUILD_URL')
+ if os.getenv('KOKORO_BUILD_ID'):
+ build_url = 'https://sponge.corp.google.com/invocation?id=%s' % os.getenv(
+ 'KOKORO_BUILD_ID')
+ job_name = os.getenv('JOB_BASE_NAME') or os.getenv('KOKORO_JOB_NAME')
- if build_id:
- test_results['build_id'] = build_id
- if build_url:
- test_results['build_url'] = build_url
- if job_name:
- test_results['job_name'] = job_name
+ if build_id:
+ test_results['build_id'] = build_id
+ if build_url:
+ test_results['build_url'] = build_url
+ if job_name:
+ test_results['job_name'] = job_name
def upload_results_to_bq(resultset, bq_table, args, platform):
- """Upload test results to a BQ table.
+ """Upload test results to a BQ table.
Args:
resultset: dictionary generated by jobset.run
@@ -78,30 +95,97 @@ def upload_results_to_bq(resultset, bq_table, args, platform):
args: args in run_tests.py, generated by argparse
platform: string name of platform tests were run on
"""
- bq = big_query_utils.create_big_query()
- big_query_utils.create_partitioned_table(bq, _PROJECT_ID, _DATASET_ID, bq_table, _RESULTS_SCHEMA, _DESCRIPTION,
- partition_type=_PARTITION_TYPE, expiration_ms= _EXPIRATION_MS)
-
- for shortname, results in six.iteritems(resultset):
- for result in results:
- test_results = {}
- _get_build_metadata(test_results)
- test_results['compiler'] = args.compiler
- test_results['config'] = args.config
- test_results['cpu_estimated'] = result.cpu_estimated
- test_results['cpu_measured'] = result.cpu_measured
- test_results['elapsed_time'] = '%.2f' % result.elapsed_time
- test_results['iomgr_platform'] = args.iomgr_platform
- # args.language is a list, but will always have one element in the contexts
- # this function is used.
- test_results['language'] = args.language[0]
- test_results['platform'] = platform
- test_results['result'] = result.state
- test_results['return_code'] = result.returncode
- test_results['test_name'] = shortname
- test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S')
-
- row = big_query_utils.make_row(str(uuid.uuid4()), test_results)
- if not big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, bq_table, [row]):
- print('Error uploading result to bigquery.')
- sys.exit(1)
+ bq = big_query_utils.create_big_query()
+ big_query_utils.create_partitioned_table(
+ bq,
+ _PROJECT_ID,
+ _DATASET_ID,
+ bq_table,
+ _RESULTS_SCHEMA,
+ _DESCRIPTION,
+ partition_type=_PARTITION_TYPE,
+ expiration_ms=_EXPIRATION_MS)
+
+ for shortname, results in six.iteritems(resultset):
+ for result in results:
+ test_results = {}
+ _get_build_metadata(test_results)
+ test_results['compiler'] = args.compiler
+ test_results['config'] = args.config
+ test_results['cpu_estimated'] = result.cpu_estimated
+ test_results['cpu_measured'] = result.cpu_measured
+ test_results['elapsed_time'] = '%.2f' % result.elapsed_time
+ test_results['iomgr_platform'] = args.iomgr_platform
+ # args.language is a list, but will always have one element in the contexts
+ # this function is used.
+ test_results['language'] = args.language[0]
+ test_results['platform'] = platform
+ test_results['result'] = result.state
+ test_results['return_code'] = result.returncode
+ test_results['test_name'] = shortname
+ test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S')
+
+ row = big_query_utils.make_row(str(uuid.uuid4()), test_results)
+
+ # TODO(jtattermusch): rows are inserted one by one, very inefficient
+ max_retries = 3
+ for attempt in range(max_retries):
+ if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID,
+ bq_table, [row]):
+ break
+ else:
+ if attempt < max_retries - 1:
+ print('Error uploading result to bigquery, will retry.')
+ else:
+ print(
+ 'Error uploading result to bigquery, all attempts failed.'
+ )
+ sys.exit(1)
+
+
+def upload_interop_results_to_bq(resultset, bq_table, args):
+ """Upload interop test results to a BQ table.
+
+ Args:
+ resultset: dictionary generated by jobset.run
+ bq_table: string name of table to create/upload results to in BQ
+ args: args in run_interop_tests.py, generated by argparse
+ """
+ bq = big_query_utils.create_big_query()
+ big_query_utils.create_partitioned_table(
+ bq,
+ _PROJECT_ID,
+ _DATASET_ID,
+ bq_table,
+ _INTEROP_RESULTS_SCHEMA,
+ _DESCRIPTION,
+ partition_type=_PARTITION_TYPE,
+ expiration_ms=_EXPIRATION_MS)
+
+ for shortname, results in six.iteritems(resultset):
+ for result in results:
+ test_results = {}
+ _get_build_metadata(test_results)
+ test_results['elapsed_time'] = '%.2f' % result.elapsed_time
+ test_results['result'] = result.state
+ test_results['test_name'] = shortname
+ test_results['suite'] = shortname.split(':')[0]
+ test_results['client'] = shortname.split(':')[1]
+ test_results['server'] = shortname.split(':')[2]
+ test_results['test_case'] = shortname.split(':')[3]
+ test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S')
+ row = big_query_utils.make_row(str(uuid.uuid4()), test_results)
+ # TODO(jtattermusch): rows are inserted one by one, very inefficient
+ max_retries = 3
+ for attempt in range(max_retries):
+ if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID,
+ bq_table, [row]):
+ break
+ else:
+ if attempt < max_retries - 1:
+ print('Error uploading result to bigquery, will retry.')
+ else:
+ print(
+ 'Error uploading result to bigquery, all attempts failed.'
+ )
+ sys.exit(1)
diff --git a/tools/run_tests/python_utils/watch_dirs.py b/tools/run_tests/python_utils/watch_dirs.py
index 7bd085efaf..d2ad303a07 100755
--- a/tools/run_tests/python_utils/watch_dirs.py
+++ b/tools/run_tests/python_utils/watch_dirs.py
@@ -11,7 +11,6 @@
# 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.
-
"""Helper to watch a (set) of directories for modifications."""
import os
@@ -19,42 +18,42 @@ import time
class DirWatcher(object):
- """Helper to watch a (set) of directories for modifications."""
-
- def __init__(self, paths):
- if isinstance(paths, basestring):
- paths = [paths]
- self._done = False
- self.paths = list(paths)
- self.lastrun = time.time()
- self._cache = self._calculate()
-
- def _calculate(self):
- """Walk over all subscribed paths, check most recent mtime."""
- most_recent_change = None
- for path in self.paths:
- if not os.path.exists(path):
- continue
- if not os.path.isdir(path):
- continue
- for root, _, files in os.walk(path):
- for f in files:
- if f and f[0] == '.': continue
- try:
- st = os.stat(os.path.join(root, f))
- except OSError as e:
- if e.errno == os.errno.ENOENT:
- continue
- raise
- if most_recent_change is None:
- most_recent_change = st.st_mtime
- else:
- most_recent_change = max(most_recent_change, st.st_mtime)
- return most_recent_change
-
- def most_recent_change(self):
- if time.time() - self.lastrun > 1:
- self._cache = self._calculate()
- self.lastrun = time.time()
- return self._cache
-
+ """Helper to watch a (set) of directories for modifications."""
+
+ def __init__(self, paths):
+ if isinstance(paths, basestring):
+ paths = [paths]
+ self._done = False
+ self.paths = list(paths)
+ self.lastrun = time.time()
+ self._cache = self._calculate()
+
+ def _calculate(self):
+ """Walk over all subscribed paths, check most recent mtime."""
+ most_recent_change = None
+ for path in self.paths:
+ if not os.path.exists(path):
+ continue
+ if not os.path.isdir(path):
+ continue
+ for root, _, files in os.walk(path):
+ for f in files:
+ if f and f[0] == '.': continue
+ try:
+ st = os.stat(os.path.join(root, f))
+ except OSError as e:
+ if e.errno == os.errno.ENOENT:
+ continue
+ raise
+ if most_recent_change is None:
+ most_recent_change = st.st_mtime
+ else:
+ most_recent_change = max(most_recent_change,
+ st.st_mtime)
+ return most_recent_change
+
+ def most_recent_change(self):
+ if time.time() - self.lastrun > 1:
+ self._cache = self._calculate()
+ self.lastrun = time.time()
+ return self._cache
diff --git a/tools/run_tests/run_build_statistics.py b/tools/run_tests/run_build_statistics.py
index 1e957b6677..405533279e 100755
--- a/tools/run_tests/run_build_statistics.py
+++ b/tools/run_tests/run_build_statistics.py
@@ -12,7 +12,6 @@
# 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.
-
"""Tool to get build statistics from Jenkins and upload to BigQuery."""
from __future__ import print_function
@@ -27,43 +26,42 @@ import re
import sys
import urllib
-
-gcp_utils_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../gcp/utils'))
+gcp_utils_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../gcp/utils'))
sys.path.append(gcp_utils_dir)
import big_query_utils
-
_PROJECT_ID = 'grpc-testing'
_HAS_MATRIX = True
-_BUILDS = {'gRPC_interop_master': not _HAS_MATRIX,
- 'gRPC_master_linux': not _HAS_MATRIX,
- 'gRPC_master_macos': not _HAS_MATRIX,
- 'gRPC_master_windows': not _HAS_MATRIX,
- 'gRPC_performance_master': not _HAS_MATRIX,
- 'gRPC_portability_master_linux': not _HAS_MATRIX,
- 'gRPC_portability_master_windows': not _HAS_MATRIX,
- 'gRPC_master_asanitizer_c': not _HAS_MATRIX,
- 'gRPC_master_asanitizer_cpp': not _HAS_MATRIX,
- 'gRPC_master_msan_c': not _HAS_MATRIX,
- 'gRPC_master_tsanitizer_c': not _HAS_MATRIX,
- 'gRPC_master_tsan_cpp': not _HAS_MATRIX,
- 'gRPC_interop_pull_requests': not _HAS_MATRIX,
- 'gRPC_performance_pull_requests': not _HAS_MATRIX,
- 'gRPC_portability_pull_requests_linux': not _HAS_MATRIX,
- 'gRPC_portability_pr_win': not _HAS_MATRIX,
- 'gRPC_pull_requests_linux': not _HAS_MATRIX,
- 'gRPC_pull_requests_macos': not _HAS_MATRIX,
- 'gRPC_pr_win': not _HAS_MATRIX,
- 'gRPC_pull_requests_asan_c': not _HAS_MATRIX,
- 'gRPC_pull_requests_asan_cpp': not _HAS_MATRIX,
- 'gRPC_pull_requests_msan_c': not _HAS_MATRIX,
- 'gRPC_pull_requests_tsan_c': not _HAS_MATRIX,
- 'gRPC_pull_requests_tsan_cpp': not _HAS_MATRIX,
+_BUILDS = {
+ 'gRPC_interop_master': not _HAS_MATRIX,
+ 'gRPC_master_linux': not _HAS_MATRIX,
+ 'gRPC_master_macos': not _HAS_MATRIX,
+ 'gRPC_master_windows': not _HAS_MATRIX,
+ 'gRPC_performance_master': not _HAS_MATRIX,
+ 'gRPC_portability_master_linux': not _HAS_MATRIX,
+ 'gRPC_portability_master_windows': not _HAS_MATRIX,
+ 'gRPC_master_asanitizer_c': not _HAS_MATRIX,
+ 'gRPC_master_asanitizer_cpp': not _HAS_MATRIX,
+ 'gRPC_master_msan_c': not _HAS_MATRIX,
+ 'gRPC_master_tsanitizer_c': not _HAS_MATRIX,
+ 'gRPC_master_tsan_cpp': not _HAS_MATRIX,
+ 'gRPC_interop_pull_requests': not _HAS_MATRIX,
+ 'gRPC_performance_pull_requests': not _HAS_MATRIX,
+ 'gRPC_portability_pull_requests_linux': not _HAS_MATRIX,
+ 'gRPC_portability_pr_win': not _HAS_MATRIX,
+ 'gRPC_pull_requests_linux': not _HAS_MATRIX,
+ 'gRPC_pull_requests_macos': not _HAS_MATRIX,
+ 'gRPC_pr_win': not _HAS_MATRIX,
+ 'gRPC_pull_requests_asan_c': not _HAS_MATRIX,
+ 'gRPC_pull_requests_asan_cpp': not _HAS_MATRIX,
+ 'gRPC_pull_requests_msan_c': not _HAS_MATRIX,
+ 'gRPC_pull_requests_tsan_c': not _HAS_MATRIX,
+ 'gRPC_pull_requests_tsan_cpp': not _HAS_MATRIX,
}
_URL_BASE = 'https://grpc-testing.appspot.com/job'
-# This is a dynamic list where known and active issues should be added.
+# This is a dynamic list where known and active issues should be added.
# Fixed ones should be removed.
# Also try not to add multiple messages from the same failure.
_KNOWN_ERRORS = [
@@ -99,147 +97,156 @@ _DATASET_ID = 'build_statistics'
def _scrape_for_known_errors(html):
- error_list = []
- for known_error in _KNOWN_ERRORS:
- errors = re.findall(known_error, html)
- this_error_count = len(errors)
- if this_error_count > 0:
- error_list.append({'description': known_error,
- 'count': this_error_count})
- print('====> %d failures due to %s' % (this_error_count, known_error))
- return error_list
+ error_list = []
+ for known_error in _KNOWN_ERRORS:
+ errors = re.findall(known_error, html)
+ this_error_count = len(errors)
+ if this_error_count > 0:
+ error_list.append({
+ 'description': known_error,
+ 'count': this_error_count
+ })
+ print('====> %d failures due to %s' % (this_error_count,
+ known_error))
+ return error_list
def _no_report_files_found(html):
- return _NO_REPORT_FILES_FOUND_ERROR in html
+ return _NO_REPORT_FILES_FOUND_ERROR in html
def _get_last_processed_buildnumber(build_name):
- query = 'SELECT max(build_number) FROM [%s:%s.%s];' % (
- _PROJECT_ID, _DATASET_ID, build_name)
- query_job = big_query_utils.sync_query_job(bq, _PROJECT_ID, query)
- page = bq.jobs().getQueryResults(
- pageToken=None,
- **query_job['jobReference']).execute(num_retries=3)
- if page['rows'][0]['f'][0]['v']:
- return int(page['rows'][0]['f'][0]['v'])
- return 0
+ query = 'SELECT max(build_number) FROM [%s:%s.%s];' % (_PROJECT_ID,
+ _DATASET_ID,
+ build_name)
+ query_job = big_query_utils.sync_query_job(bq, _PROJECT_ID, query)
+ page = bq.jobs().getQueryResults(
+ pageToken=None, **query_job['jobReference']).execute(num_retries=3)
+ if page['rows'][0]['f'][0]['v']:
+ return int(page['rows'][0]['f'][0]['v'])
+ return 0
def _process_matrix(build, url_base):
- matrix_list = []
- for matrix in build.get_matrix_runs():
- matrix_str = re.match('.*\\xc2\\xbb ((?:[^,]+,?)+) #.*',
- matrix.name).groups()[0]
- matrix_tuple = matrix_str.split(',')
- json_url = '%s/config=%s,language=%s,platform=%s/testReport/api/json' % (
- url_base, matrix_tuple[0], matrix_tuple[1], matrix_tuple[2])
- console_url = '%s/config=%s,language=%s,platform=%s/consoleFull' % (
- url_base, matrix_tuple[0], matrix_tuple[1], matrix_tuple[2])
- matrix_dict = {'name': matrix_str,
- 'duration': matrix.get_duration().total_seconds()}
- matrix_dict.update(_process_build(json_url, console_url))
- matrix_list.append(matrix_dict)
-
- return matrix_list
+ matrix_list = []
+ for matrix in build.get_matrix_runs():
+ matrix_str = re.match('.*\\xc2\\xbb ((?:[^,]+,?)+) #.*',
+ matrix.name).groups()[0]
+ matrix_tuple = matrix_str.split(',')
+ json_url = '%s/config=%s,language=%s,platform=%s/testReport/api/json' % (
+ url_base, matrix_tuple[0], matrix_tuple[1], matrix_tuple[2])
+ console_url = '%s/config=%s,language=%s,platform=%s/consoleFull' % (
+ url_base, matrix_tuple[0], matrix_tuple[1], matrix_tuple[2])
+ matrix_dict = {
+ 'name': matrix_str,
+ 'duration': matrix.get_duration().total_seconds()
+ }
+ matrix_dict.update(_process_build(json_url, console_url))
+ matrix_list.append(matrix_dict)
+
+ return matrix_list
def _process_build(json_url, console_url):
- build_result = {}
- error_list = []
- try:
- html = urllib.urlopen(json_url).read()
- test_result = json.loads(html)
- print('====> Parsing result from %s' % json_url)
- failure_count = test_result['failCount']
- build_result['pass_count'] = test_result['passCount']
- build_result['failure_count'] = failure_count
- # This means Jenkins failure occurred.
- build_result['no_report_files_found'] = _no_report_files_found(html)
- # Only check errors if Jenkins failure occurred.
- if build_result['no_report_files_found']:
- error_list = _scrape_for_known_errors(html)
- except Exception as e:
- print('====> Got exception for %s: %s.' % (json_url, str(e)))
- print('====> Parsing errors from %s.' % console_url)
- html = urllib.urlopen(console_url).read()
- build_result['pass_count'] = 0
- build_result['failure_count'] = 1
- # In this case, the string doesn't exist in the result html but the fact
- # that we fail to parse the result html indicates Jenkins failure and hence
- # no report files were generated.
- build_result['no_report_files_found'] = True
- error_list = _scrape_for_known_errors(html)
-
- if error_list:
- build_result['error'] = error_list
- elif build_result['no_report_files_found']:
- build_result['error'] = [{'description': _UNKNOWN_ERROR, 'count': 1}]
- else:
- build_result['error'] = [{'description': '', 'count': 0}]
-
- return build_result
+ build_result = {}
+ error_list = []
+ try:
+ html = urllib.urlopen(json_url).read()
+ test_result = json.loads(html)
+ print('====> Parsing result from %s' % json_url)
+ failure_count = test_result['failCount']
+ build_result['pass_count'] = test_result['passCount']
+ build_result['failure_count'] = failure_count
+ # This means Jenkins failure occurred.
+ build_result['no_report_files_found'] = _no_report_files_found(html)
+ # Only check errors if Jenkins failure occurred.
+ if build_result['no_report_files_found']:
+ error_list = _scrape_for_known_errors(html)
+ except Exception as e:
+ print('====> Got exception for %s: %s.' % (json_url, str(e)))
+ print('====> Parsing errors from %s.' % console_url)
+ html = urllib.urlopen(console_url).read()
+ build_result['pass_count'] = 0
+ build_result['failure_count'] = 1
+ # In this case, the string doesn't exist in the result html but the fact
+ # that we fail to parse the result html indicates Jenkins failure and hence
+ # no report files were generated.
+ build_result['no_report_files_found'] = True
+ error_list = _scrape_for_known_errors(html)
+
+ if error_list:
+ build_result['error'] = error_list
+ elif build_result['no_report_files_found']:
+ build_result['error'] = [{'description': _UNKNOWN_ERROR, 'count': 1}]
+ else:
+ build_result['error'] = [{'description': '', 'count': 0}]
+
+ return build_result
# parse command line
argp = argparse.ArgumentParser(description='Get build statistics.')
argp.add_argument('-u', '--username', default='jenkins')
-argp.add_argument('-b', '--builds',
- choices=['all'] + sorted(_BUILDS.keys()),
- nargs='+',
- default=['all'])
+argp.add_argument(
+ '-b',
+ '--builds',
+ choices=['all'] + sorted(_BUILDS.keys()),
+ nargs='+',
+ default=['all'])
args = argp.parse_args()
J = Jenkins('https://grpc-testing.appspot.com', args.username, 'apiToken')
bq = big_query_utils.create_big_query()
for build_name in _BUILDS.keys() if 'all' in args.builds else args.builds:
- print('====> Build: %s' % build_name)
- # Since get_last_completed_build() always fails due to malformatted string
- # error, we use get_build_metadata() instead.
- job = None
- try:
- job = J[build_name]
- except Exception as e:
- print('====> Failed to get build %s: %s.' % (build_name, str(e)))
- continue
- last_processed_build_number = _get_last_processed_buildnumber(build_name)
- last_complete_build_number = job.get_last_completed_buildnumber()
- # To avoid processing all builds for a project never looked at. In this case,
- # only examine 10 latest builds.
- starting_build_number = max(last_processed_build_number+1,
- last_complete_build_number-9)
- for build_number in xrange(starting_build_number,
- last_complete_build_number+1):
- print('====> Processing %s build %d.' % (build_name, build_number))
- build = None
+ print('====> Build: %s' % build_name)
+ # Since get_last_completed_build() always fails due to malformatted string
+ # error, we use get_build_metadata() instead.
+ job = None
try:
- build = job.get_build_metadata(build_number)
- print('====> Build status: %s.' % build.get_status())
- if build.get_status() == 'ABORTED':
+ job = J[build_name]
+ except Exception as e:
+ print('====> Failed to get build %s: %s.' % (build_name, str(e)))
continue
- # If any build is still running, stop processing this job. Next time, we
- # start from where it was left so that all builds are processed
- # sequentially.
- if build.is_running():
- print('====> Build %d is still running.' % build_number)
- break
- except KeyError:
- print('====> Build %s is missing. Skip.' % build_number)
- continue
- build_result = {'build_number': build_number,
- 'timestamp': str(build.get_timestamp())}
- url_base = json_url = '%s/%s/%d' % (_URL_BASE, build_name, build_number)
- if _BUILDS[build_name]: # The build has matrix, such as gRPC_master.
- build_result['matrix'] = _process_matrix(build, url_base)
- else:
- json_url = '%s/testReport/api/json' % url_base
- console_url = '%s/consoleFull' % url_base
- build_result['duration'] = build.get_duration().total_seconds()
- build_stat = _process_build(json_url, console_url)
- build_result.update(build_stat)
- rows = [big_query_utils.make_row(build_number, build_result)]
- if not big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, build_name,
- rows):
- print('====> Error uploading result to bigquery.')
- sys.exit(1)
+ last_processed_build_number = _get_last_processed_buildnumber(build_name)
+ last_complete_build_number = job.get_last_completed_buildnumber()
+ # To avoid processing all builds for a project never looked at. In this case,
+ # only examine 10 latest builds.
+ starting_build_number = max(last_processed_build_number + 1,
+ last_complete_build_number - 9)
+ for build_number in xrange(starting_build_number,
+ last_complete_build_number + 1):
+ print('====> Processing %s build %d.' % (build_name, build_number))
+ build = None
+ try:
+ build = job.get_build_metadata(build_number)
+ print('====> Build status: %s.' % build.get_status())
+ if build.get_status() == 'ABORTED':
+ continue
+ # If any build is still running, stop processing this job. Next time, we
+ # start from where it was left so that all builds are processed
+ # sequentially.
+ if build.is_running():
+ print('====> Build %d is still running.' % build_number)
+ break
+ except KeyError:
+ print('====> Build %s is missing. Skip.' % build_number)
+ continue
+ build_result = {
+ 'build_number': build_number,
+ 'timestamp': str(build.get_timestamp())
+ }
+ url_base = json_url = '%s/%s/%d' % (_URL_BASE, build_name, build_number)
+ if _BUILDS[build_name]: # The build has matrix, such as gRPC_master.
+ build_result['matrix'] = _process_matrix(build, url_base)
+ else:
+ json_url = '%s/testReport/api/json' % url_base
+ console_url = '%s/consoleFull' % url_base
+ build_result['duration'] = build.get_duration().total_seconds()
+ build_stat = _process_build(json_url, console_url)
+ build_result.update(build_stat)
+ rows = [big_query_utils.make_row(build_number, build_result)]
+ if not big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID,
+ build_name, rows):
+ print('====> Error uploading result to bigquery.')
+ sys.exit(1)
diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py
index 1537641aee..44a6ec26e8 100755
--- a/tools/run_tests/run_interop_tests.py
+++ b/tools/run_tests/run_interop_tests.py
@@ -12,7 +12,6 @@
# 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.
-
"""Run interop (cross-language) tests in parallel."""
from __future__ import print_function
@@ -35,6 +34,11 @@ import traceback
import python_utils.dockerjob as dockerjob
import python_utils.jobset as jobset
import python_utils.report_utils as report_utils
+# It's ok to not import because this is only necessary to upload results to BQ.
+try:
+ from python_utils.upload_test_results import upload_interop_results_to_bq
+except ImportError as e:
+ print(e)
# Docker doesn't clean up after itself, so we do it on exit.
atexit.register(lambda: subprocess.call(['stty', 'echo']))
@@ -42,22 +46,24 @@ atexit.register(lambda: subprocess.call(['stty', 'echo']))
ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
os.chdir(ROOT)
-_DEFAULT_SERVER_PORT=8080
+_DEFAULT_SERVER_PORT = 8080
-_SKIP_CLIENT_COMPRESSION = ['client_compressed_unary',
- 'client_compressed_streaming']
+_SKIP_CLIENT_COMPRESSION = [
+ 'client_compressed_unary', 'client_compressed_streaming'
+]
-_SKIP_SERVER_COMPRESSION = ['server_compressed_unary',
- 'server_compressed_streaming']
+_SKIP_SERVER_COMPRESSION = [
+ 'server_compressed_unary', 'server_compressed_streaming'
+]
_SKIP_COMPRESSION = _SKIP_CLIENT_COMPRESSION + _SKIP_SERVER_COMPRESSION
-_SKIP_ADVANCED = ['status_code_and_message',
- 'custom_metadata',
- 'unimplemented_method',
- 'unimplemented_service']
+_SKIP_ADVANCED = [
+ 'status_code_and_message', 'custom_metadata', 'unimplemented_method',
+ 'unimplemented_service'
+]
-_TEST_TIMEOUT = 3*60
+_TEST_TIMEOUT = 3 * 60
# disable this test on core-based languages,
# see https://github.com/grpc/grpc/issues/9779
@@ -72,969 +78,1059 @@ _XML_REPORT = 'report.xml'
class CXXLanguage:
- def __init__(self):
- self.client_cwd = None
- self.server_cwd = None
- self.http2_cwd = None
- self.safename = 'cxx'
+ def __init__(self):
+ self.client_cwd = None
+ self.server_cwd = None
+ self.http2_cwd = None
+ self.safename = 'cxx'
- def client_cmd(self, args):
- return ['bins/opt/interop_client'] + args
+ def client_cmd(self, args):
+ return ['bins/opt/interop_client'] + args
- def client_cmd_http2interop(self, args):
- return ['bins/opt/http2_client'] + args
+ def client_cmd_http2interop(self, args):
+ return ['bins/opt/http2_client'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def server_cmd(self, args):
- return ['bins/opt/interop_server'] + args
+ def server_cmd(self, args):
+ return ['bins/opt/interop_server'] + args
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return []
+ def unimplemented_test_cases_server(self):
+ return []
- def __str__(self):
- return 'c++'
+ def __str__(self):
+ return 'c++'
class CSharpLanguage:
- def __init__(self):
- self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45'
- self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug/net45'
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45'
+ self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug/net45'
+ self.safename = str(self)
- def client_cmd(self, args):
- return ['mono', 'Grpc.IntegrationTesting.Client.exe'] + args
+ def client_cmd(self, args):
+ return ['mono', 'Grpc.IntegrationTesting.Client.exe'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def server_cmd(self, args):
- return ['mono', 'Grpc.IntegrationTesting.Server.exe'] + args
+ def server_cmd(self, args):
+ return ['mono', 'Grpc.IntegrationTesting.Server.exe'] + args
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_SERVER_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _SKIP_SERVER_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
- def __str__(self):
- return 'csharp'
+ def __str__(self):
+ return 'csharp'
class CSharpCoreCLRLanguage:
- def __init__(self):
- self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0'
- self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug/netcoreapp1.0'
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0'
+ self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug/netcoreapp1.0'
+ self.safename = str(self)
- def client_cmd(self, args):
- return ['dotnet', 'exec', 'Grpc.IntegrationTesting.Client.dll'] + args
+ def client_cmd(self, args):
+ return ['dotnet', 'exec', 'Grpc.IntegrationTesting.Client.dll'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def server_cmd(self, args):
- return ['dotnet', 'exec', 'Grpc.IntegrationTesting.Server.dll'] + args
+ def server_cmd(self, args):
+ return ['dotnet', 'exec', 'Grpc.IntegrationTesting.Server.dll'] + args
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_SERVER_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _SKIP_SERVER_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
- def __str__(self):
- return 'csharpcoreclr'
+ def __str__(self):
+ return 'csharpcoreclr'
class JavaLanguage:
- def __init__(self):
- self.client_cwd = '../grpc-java'
- self.server_cwd = '../grpc-java'
- self.http2_cwd = '../grpc-java'
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = '../grpc-java'
+ self.server_cwd = '../grpc-java'
+ self.http2_cwd = '../grpc-java'
+ self.safename = str(self)
- def client_cmd(self, args):
- return ['./run-test-client.sh'] + args
+ def client_cmd(self, args):
+ return ['./run-test-client.sh'] + args
- def client_cmd_http2interop(self, args):
- return ['./interop-testing/build/install/grpc-interop-testing/bin/http2-client'] + args
+ def client_cmd_http2interop(self, args):
+ return [
+ './interop-testing/build/install/grpc-interop-testing/bin/http2-client'
+ ] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def server_cmd(self, args):
- return ['./run-test-server.sh'] + args
+ def server_cmd(self, args):
+ return ['./run-test-server.sh'] + args
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return []
+ def unimplemented_test_cases(self):
+ return []
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
- def __str__(self):
- return 'java'
+ def __str__(self):
+ return 'java'
class JavaOkHttpClient:
- def __init__(self):
- self.client_cwd = '../grpc-java'
- self.safename = 'java'
+ def __init__(self):
+ self.client_cwd = '../grpc-java'
+ self.safename = 'java'
- def client_cmd(self, args):
- return ['./run-test-client.sh', '--use_okhttp=true'] + args
+ def client_cmd(self, args):
+ return ['./run-test-client.sh', '--use_okhttp=true'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _SKIP_DATA_FRAME_PADDING
- def __str__(self):
- return 'javaokhttp'
+ def __str__(self):
+ return 'javaokhttp'
class GoLanguage:
- def __init__(self):
- # TODO: this relies on running inside docker
- self.client_cwd = '/go/src/google.golang.org/grpc/interop/client'
- self.server_cwd = '/go/src/google.golang.org/grpc/interop/server'
- self.http2_cwd = '/go/src/google.golang.org/grpc/interop/http2'
- self.safename = str(self)
+ def __init__(self):
+ # TODO: this relies on running inside docker
+ self.client_cwd = '/go/src/google.golang.org/grpc/interop/client'
+ self.server_cwd = '/go/src/google.golang.org/grpc/interop/server'
+ self.http2_cwd = '/go/src/google.golang.org/grpc/interop/http2'
+ self.safename = str(self)
- def client_cmd(self, args):
- return ['go', 'run', 'client.go'] + args
+ def client_cmd(self, args):
+ return ['go', 'run', 'client.go'] + args
- def client_cmd_http2interop(self, args):
- return ['go', 'run', 'negative_http2_client.go'] + args
+ def client_cmd_http2interop(self, args):
+ return ['go', 'run', 'negative_http2_client.go'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def server_cmd(self, args):
- return ['go', 'run', 'server.go'] + args
+ def server_cmd(self, args):
+ return ['go', 'run', 'server.go'] + args
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases(self):
+ return _SKIP_COMPRESSION
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
+
+ def __str__(self):
+ return 'go'
- def __str__(self):
- return 'go'
class Http2Server:
- """Represents the HTTP/2 Interop Test server
+ """Represents the HTTP/2 Interop Test server
This pretends to be a language in order to be built and run, but really it
isn't.
"""
- def __init__(self):
- self.server_cwd = None
- self.safename = str(self)
- def server_cmd(self, args):
- return ['python test/http2_test/http2_test_server.py']
+ def __init__(self):
+ self.server_cwd = None
+ self.safename = str(self)
+
+ def server_cmd(self, args):
+ return ['python test/http2_test/http2_test_server.py']
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _TEST_CASES + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _TEST_CASES + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return _TEST_CASES
+ def unimplemented_test_cases_server(self):
+ return _TEST_CASES
+
+ def __str__(self):
+ return 'http2'
- def __str__(self):
- return 'http2'
class Http2Client:
- """Represents the HTTP/2 Interop Test
+ """Represents the HTTP/2 Interop Test
This pretends to be a language in order to be built and run, but really it
isn't.
"""
- def __init__(self):
- self.client_cwd = None
- self.safename = str(self)
- def client_cmd(self, args):
- return ['tools/http2_interop/http2_interop.test', '-test.v'] + args
+ def __init__(self):
+ self.client_cwd = None
+ self.safename = str(self)
+
+ def client_cmd(self, args):
+ return ['tools/http2_interop/http2_interop.test', '-test.v'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _TEST_CASES
+ def unimplemented_test_cases(self):
+ return _TEST_CASES
- def unimplemented_test_cases_server(self):
- return _TEST_CASES
+ def unimplemented_test_cases_server(self):
+ return _TEST_CASES
+
+ def __str__(self):
+ return 'http2'
- def __str__(self):
- return 'http2'
class NodeLanguage:
- def __init__(self):
- self.client_cwd = None
- self.server_cwd = None
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = '../grpc-node'
+ self.server_cwd = '../grpc-node'
+ self.safename = str(self)
- def client_cmd(self, args):
- return ['tools/run_tests/interop/with_nvm.sh',
- 'node', 'src/node/interop/interop_client.js'] + args
+ def client_cmd(self, args):
+ return [
+ 'packages/grpc-native-core/deps/grpc/tools/run_tests/interop/with_nvm.sh',
+ 'node', '--require', './test/fixtures/native_native',
+ 'test/interop/interop_client.js'
+ ] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def server_cmd(self, args):
- return ['tools/run_tests/interop/with_nvm.sh',
- 'node', 'src/node/interop/interop_server.js'] + args
+ def server_cmd(self, args):
+ return [
+ 'packages/grpc-native-core/deps/grpc/tools/run_tests/interop/with_nvm.sh',
+ 'node', '--require', './test/fixtures/native_native',
+ 'test/interop/interop_server.js'
+ ] + args
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
- def __str__(self):
- return 'node'
+ def __str__(self):
+ return 'node'
class PHPLanguage:
- def __init__(self):
- self.client_cwd = None
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = None
+ self.safename = str(self)
- def client_cmd(self, args):
- return ['src/php/bin/interop_client.sh'] + args
+ def client_cmd(self, args):
+ return ['src/php/bin/interop_client.sh'] + args
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return []
+ def unimplemented_test_cases_server(self):
+ return []
- def __str__(self):
- return 'php'
+ def __str__(self):
+ return 'php'
class PHP7Language:
- def __init__(self):
- self.client_cwd = None
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = None
+ self.safename = str(self)
+
+ def client_cmd(self, args):
+ return ['src/php/bin/interop_client.sh'] + args
- def client_cmd(self, args):
- return ['src/php/bin/interop_client.sh'] + args
+ def cloud_to_prod_env(self):
+ return {}
- def cloud_to_prod_env(self):
- return {}
+ def global_env(self):
+ return {}
- def global_env(self):
- return {}
+ def unimplemented_test_cases(self):
+ return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases(self):
- return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases_server(self):
+ return []
- def unimplemented_test_cases_server(self):
- return []
+ def __str__(self):
+ return 'php7'
- def __str__(self):
- return 'php7'
class ObjcLanguage:
- def __init__(self):
- self.client_cwd = 'src/objective-c/tests'
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = 'src/objective-c/tests'
+ self.safename = str(self)
- def client_cmd(self, args):
- # from args, extract the server port and craft xcodebuild command out of it
- for arg in args:
- port = re.search('--server_port=(\d+)', arg)
- if port:
- portnum = port.group(1)
- cmdline = 'pod install && xcodebuild -workspace Tests.xcworkspace -scheme InteropTestsLocalSSL -destination name="iPhone 6" HOST_PORT_LOCALSSL=localhost:%s test'%portnum
- return [cmdline]
+ def client_cmd(self, args):
+ # from args, extract the server port and craft xcodebuild command out of it
+ for arg in args:
+ port = re.search('--server_port=(\d+)', arg)
+ if port:
+ portnum = port.group(1)
+ cmdline = 'pod install && xcodebuild -workspace Tests.xcworkspace -scheme InteropTestsLocalSSL -destination name="iPhone 6" HOST_PORT_LOCALSSL=localhost:%s test' % portnum
+ return [cmdline]
- def cloud_to_prod_env(self):
- return {}
+ def cloud_to_prod_env(self):
+ return {}
- def global_env(self):
- return {}
+ def global_env(self):
+ return {}
- def unimplemented_test_cases(self):
- # ObjC test runs all cases with the same command. It ignores the testcase
- # cmdline argument. Here we return all but one test cases as unimplemented,
- # and depend upon ObjC test's behavior that it runs all cases even when
- # we tell it to run just one.
- return _TEST_CASES[1:] + _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases(self):
+ # ObjC test runs all cases with the same command. It ignores the testcase
+ # cmdline argument. Here we return all but one test cases as unimplemented,
+ # and depend upon ObjC test's behavior that it runs all cases even when
+ # we tell it to run just one.
+ return _TEST_CASES[1:] + _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
+
+ def __str__(self):
+ return 'objc'
- def __str__(self):
- return 'objc'
class RubyLanguage:
- def __init__(self):
- self.client_cwd = None
- self.server_cwd = None
- self.safename = str(self)
+ def __init__(self):
+ self.client_cwd = None
+ self.server_cwd = None
+ self.safename = str(self)
+
+ def client_cmd(self, args):
+ return [
+ 'tools/run_tests/interop/with_rvm.sh', 'ruby',
+ 'src/ruby/pb/test/client.rb'
+ ] + args
- def client_cmd(self, args):
- return ['tools/run_tests/interop/with_rvm.sh',
- 'ruby', 'src/ruby/pb/test/client.rb'] + args
+ def cloud_to_prod_env(self):
+ return {}
- def cloud_to_prod_env(self):
- return {}
+ def server_cmd(self, args):
+ return [
+ 'tools/run_tests/interop/with_rvm.sh', 'ruby',
+ 'src/ruby/pb/test/server.rb'
+ ] + args
- def server_cmd(self, args):
- return ['tools/run_tests/interop/with_rvm.sh',
- 'ruby', 'src/ruby/pb/test/server.rb'] + args
+ def global_env(self):
+ return {}
- def global_env(self):
- return {}
+ def unimplemented_test_cases(self):
+ return _SKIP_SERVER_COMPRESSION + _SKIP_DATA_FRAME_PADDING
- def unimplemented_test_cases(self):
- return _SKIP_SERVER_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def __str__(self):
+ return 'ruby'
- def __str__(self):
- return 'ruby'
class PythonLanguage:
- def __init__(self):
- self.client_cwd = None
- self.server_cwd = None
- self.http2_cwd = None
- self.safename = str(self)
-
- def client_cmd(self, args):
- return [
- 'py27/bin/python',
- 'src/python/grpcio_tests/setup.py',
- 'run_interop',
- '--client',
- '--args="{}"'.format(' '.join(args))
- ]
+ def __init__(self):
+ self.client_cwd = None
+ self.server_cwd = None
+ self.http2_cwd = None
+ self.safename = str(self)
- def client_cmd_http2interop(self, args):
- return [ 'py27/bin/python',
- 'src/python/grpcio_tests/tests/http2/negative_http2_client.py',
- ] + args
-
- def cloud_to_prod_env(self):
- return {}
-
- def server_cmd(self, args):
- return [
- 'py27/bin/python',
- 'src/python/grpcio_tests/setup.py',
- 'run_interop',
- '--server',
- '--args="{}"'.format(' '.join(args))
- ]
+ def client_cmd(self, args):
+ return [
+ 'py27/bin/python', 'src/python/grpcio_tests/setup.py',
+ 'run_interop', '--client', '--args="{}"'.format(' '.join(args))
+ ]
- def global_env(self):
- return {'LD_LIBRARY_PATH': '{}/libs/opt'.format(DOCKER_WORKDIR_ROOT),
- 'PYTHONPATH': '{}/src/python/gens'.format(DOCKER_WORKDIR_ROOT)}
+ def client_cmd_http2interop(self, args):
+ return [
+ 'py27/bin/python',
+ 'src/python/grpcio_tests/tests/http2/negative_http2_client.py',
+ ] + args
- def unimplemented_test_cases(self):
- return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+ def cloud_to_prod_env(self):
+ return {}
- def unimplemented_test_cases_server(self):
- return _SKIP_COMPRESSION
+ def server_cmd(self, args):
+ return [
+ 'py27/bin/python', 'src/python/grpcio_tests/setup.py',
+ 'run_interop', '--server', '--args="{}"'.format(' '.join(args))
+ ]
- def __str__(self):
- return 'python'
+ def global_env(self):
+ return {
+ 'LD_LIBRARY_PATH': '{}/libs/opt'.format(DOCKER_WORKDIR_ROOT),
+ 'PYTHONPATH': '{}/src/python/gens'.format(DOCKER_WORKDIR_ROOT)
+ }
+
+ def unimplemented_test_cases(self):
+ return _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
+
+ def unimplemented_test_cases_server(self):
+ return _SKIP_COMPRESSION
+
+ def __str__(self):
+ return 'python'
_LANGUAGES = {
- 'c++' : CXXLanguage(),
- 'csharp' : CSharpLanguage(),
- 'csharpcoreclr' : CSharpCoreCLRLanguage(),
- 'go' : GoLanguage(),
- 'java' : JavaLanguage(),
- 'javaokhttp' : JavaOkHttpClient(),
- 'node' : NodeLanguage(),
- 'php' : PHPLanguage(),
- 'php7' : PHP7Language(),
- 'objc' : ObjcLanguage(),
- 'ruby' : RubyLanguage(),
- 'python' : PythonLanguage(),
+ 'c++': CXXLanguage(),
+ 'csharp': CSharpLanguage(),
+ 'csharpcoreclr': CSharpCoreCLRLanguage(),
+ 'go': GoLanguage(),
+ 'java': JavaLanguage(),
+ 'javaokhttp': JavaOkHttpClient(),
+ 'node': NodeLanguage(),
+ 'php': PHPLanguage(),
+ 'php7': PHP7Language(),
+ 'objc': ObjcLanguage(),
+ 'ruby': RubyLanguage(),
+ 'python': PythonLanguage(),
}
# languages supported as cloud_to_cloud servers
-_SERVERS = ['c++', 'node', 'csharp', 'csharpcoreclr', 'java', 'go', 'ruby', 'python']
-
-_TEST_CASES = ['large_unary', 'empty_unary', 'ping_pong',
- 'empty_stream', 'client_streaming', 'server_streaming',
- 'cancel_after_begin', 'cancel_after_first_response',
- 'timeout_on_sleeping_server', 'custom_metadata',
- 'status_code_and_message', 'unimplemented_method',
- 'client_compressed_unary', 'server_compressed_unary',
- 'client_compressed_streaming', 'server_compressed_streaming',
- 'unimplemented_service']
-
-_AUTH_TEST_CASES = ['compute_engine_creds', 'jwt_token_creds',
- 'oauth2_auth_token', 'per_rpc_creds']
+_SERVERS = [
+ 'c++', 'node', 'csharp', 'csharpcoreclr', 'java', 'go', 'ruby', 'python'
+]
+
+_TEST_CASES = [
+ 'large_unary', 'empty_unary', 'ping_pong', 'empty_stream',
+ 'client_streaming', 'server_streaming', 'cancel_after_begin',
+ 'cancel_after_first_response', 'timeout_on_sleeping_server',
+ 'custom_metadata', 'status_code_and_message', 'unimplemented_method',
+ 'client_compressed_unary', 'server_compressed_unary',
+ 'client_compressed_streaming', 'server_compressed_streaming',
+ 'unimplemented_service'
+]
+
+_AUTH_TEST_CASES = [
+ 'compute_engine_creds', 'jwt_token_creds', 'oauth2_auth_token',
+ 'per_rpc_creds'
+]
_HTTP2_TEST_CASES = ['tls', 'framing']
-_HTTP2_SERVER_TEST_CASES = ['rst_after_header', 'rst_after_data', 'rst_during_data',
- 'goaway', 'ping', 'max_streams', 'data_frame_padding', 'no_df_padding_sanity_test']
+_HTTP2_SERVER_TEST_CASES = [
+ 'rst_after_header', 'rst_after_data', 'rst_during_data', 'goaway', 'ping',
+ 'max_streams', 'data_frame_padding', 'no_df_padding_sanity_test'
+]
-_GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES = { 'data_frame_padding': 'large_unary', 'no_df_padding_sanity_test': 'large_unary' }
+_GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES = {
+ 'data_frame_padding': 'large_unary',
+ 'no_df_padding_sanity_test': 'large_unary'
+}
-_HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS = _GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES.keys()
+_HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS = _GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES.keys(
+)
-_LANGUAGES_WITH_HTTP2_CLIENTS_FOR_HTTP2_SERVER_TEST_CASES = ['java', 'go', 'python', 'c++']
+_LANGUAGES_WITH_HTTP2_CLIENTS_FOR_HTTP2_SERVER_TEST_CASES = [
+ 'java', 'go', 'python', 'c++'
+]
DOCKER_WORKDIR_ROOT = '/var/local/git/grpc'
+
def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None):
- """Wraps given cmdline array to create 'docker run' cmdline from it."""
- docker_cmdline = ['docker', 'run', '-i', '--rm=true']
+ """Wraps given cmdline array to create 'docker run' cmdline from it."""
+ docker_cmdline = ['docker', 'run', '-i', '--rm=true']
- # turn environ into -e docker args
- if environ:
- for k,v in environ.items():
- docker_cmdline += ['-e', '%s=%s' % (k,v)]
+ # turn environ into -e docker args
+ if environ:
+ for k, v in environ.items():
+ docker_cmdline += ['-e', '%s=%s' % (k, v)]
- # set working directory
- workdir = DOCKER_WORKDIR_ROOT
- if cwd:
- workdir = os.path.join(workdir, cwd)
- docker_cmdline += ['-w', workdir]
+ # set working directory
+ workdir = DOCKER_WORKDIR_ROOT
+ if cwd:
+ workdir = os.path.join(workdir, cwd)
+ docker_cmdline += ['-w', workdir]
- docker_cmdline += docker_args + [image] + cmdline
- return docker_cmdline
+ docker_cmdline += docker_args + [image] + cmdline
+ return docker_cmdline
def manual_cmdline(docker_cmdline, docker_image):
- """Returns docker cmdline adjusted for manual invocation."""
- print_cmdline = []
- for item in docker_cmdline:
- if item.startswith('--name='):
- continue
- if item == docker_image:
- item = "$docker_image"
- # add quotes when necessary
- if any(character.isspace() for character in item):
- item = "\"%s\"" % item
- print_cmdline.append(item)
- return ' '.join(print_cmdline)
+ """Returns docker cmdline adjusted for manual invocation."""
+ print_cmdline = []
+ for item in docker_cmdline:
+ if item.startswith('--name='):
+ continue
+ if item == docker_image:
+ item = "$docker_image"
+ item = item.replace('"', '\\"')
+ # add quotes when necessary
+ if any(character.isspace() for character in item):
+ item = "\"%s\"" % item
+ print_cmdline.append(item)
+ return ' '.join(print_cmdline)
def write_cmdlog_maybe(cmdlog, filename):
- """Returns docker cmdline adjusted for manual invocation."""
- if cmdlog:
- with open(filename, 'w') as logfile:
- logfile.write('#!/bin/bash\n')
- logfile.writelines("%s\n" % line for line in cmdlog)
- print('Command log written to file %s' % filename)
+ """Returns docker cmdline adjusted for manual invocation."""
+ if cmdlog:
+ with open(filename, 'w') as logfile:
+ logfile.write('#!/bin/bash\n')
+ logfile.writelines("%s\n" % line for line in cmdlog)
+ print('Command log written to file %s' % filename)
def bash_cmdline(cmdline):
- """Creates bash -c cmdline from args list."""
- # Use login shell:
- # * makes error messages clearer if executables are missing
- return ['bash', '-c', ' '.join(cmdline)]
+ """Creates bash -c cmdline from args list."""
+ # Use login shell:
+ # * makes error messages clearer if executables are missing
+ return ['bash', '-c', ' '.join(cmdline)]
def auth_options(language, test_case):
- """Returns (cmdline, env) tuple with cloud_to_prod_auth test options."""
+ """Returns (cmdline, env) tuple with cloud_to_prod_auth test options."""
- language = str(language)
- cmdargs = []
- env = {}
+ language = str(language)
+ cmdargs = []
+ env = {}
- # TODO(jtattermusch): this file path only works inside docker
- key_filepath = '/root/service_account/GrpcTesting-726eb1347f15.json'
- oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo'
- key_file_arg = '--service_account_key_file=%s' % key_filepath
- default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com'
+ # TODO(jtattermusch): this file path only works inside docker
+ key_filepath = '/root/service_account/GrpcTesting-726eb1347f15.json'
+ oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo'
+ key_file_arg = '--service_account_key_file=%s' % key_filepath
+ default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com'
- if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']:
- if language in ['csharp', 'csharpcoreclr', 'node', 'php', 'php7', 'python', 'ruby']:
- env['GOOGLE_APPLICATION_CREDENTIALS'] = key_filepath
- else:
- cmdargs += [key_file_arg]
+ if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']:
+ if language in [
+ 'csharp', 'csharpcoreclr', 'node', 'php', 'php7', 'python',
+ 'ruby'
+ ]:
+ env['GOOGLE_APPLICATION_CREDENTIALS'] = key_filepath
+ else:
+ cmdargs += [key_file_arg]
- if test_case in ['per_rpc_creds', 'oauth2_auth_token']:
- cmdargs += [oauth_scope_arg]
+ if test_case in ['per_rpc_creds', 'oauth2_auth_token']:
+ cmdargs += [oauth_scope_arg]
- if test_case == 'oauth2_auth_token' and language == 'c++':
- # C++ oauth2 test uses GCE creds and thus needs to know the default account
- cmdargs += [default_account_arg]
+ if test_case == 'oauth2_auth_token' and language == 'c++':
+ # C++ oauth2 test uses GCE creds and thus needs to know the default account
+ cmdargs += [default_account_arg]
- if test_case == 'compute_engine_creds':
- cmdargs += [oauth_scope_arg, default_account_arg]
+ if test_case == 'compute_engine_creds':
+ cmdargs += [oauth_scope_arg, default_account_arg]
- return (cmdargs, env)
+ return (cmdargs, env)
def _job_kill_handler(job):
- if job._spec.container_name:
- dockerjob.docker_kill(job._spec.container_name)
- # When the job times out and we decide to kill it,
- # we need to wait a before restarting the job
- # to prevent "container name already in use" error.
- # TODO(jtattermusch): figure out a cleaner way to to this.
- time.sleep(2)
-
-
-def cloud_to_prod_jobspec(language, test_case, server_host_name,
- server_host_detail, docker_image=None, auth=False,
+ if job._spec.container_name:
+ dockerjob.docker_kill(job._spec.container_name)
+ # When the job times out and we decide to kill it,
+ # we need to wait a before restarting the job
+ # to prevent "container name already in use" error.
+ # TODO(jtattermusch): figure out a cleaner way to to this.
+ time.sleep(2)
+
+
+def cloud_to_prod_jobspec(language,
+ test_case,
+ server_host_name,
+ server_host_detail,
+ docker_image=None,
+ auth=False,
manual_cmd_log=None):
- """Creates jobspec for cloud-to-prod interop test"""
- container_name = None
- cmdargs = [
- '--server_host=%s' % server_host_detail[0],
- '--server_host_override=%s' % server_host_detail[1],
- '--server_port=443',
- '--use_tls=true',
- '--test_case=%s' % test_case]
- environ = dict(language.cloud_to_prod_env(), **language.global_env())
- if auth:
- auth_cmdargs, auth_env = auth_options(language, test_case)
- cmdargs += auth_cmdargs
- environ.update(auth_env)
- cmdline = bash_cmdline(language.client_cmd(cmdargs))
- cwd = language.client_cwd
-
- if docker_image:
- container_name = dockerjob.random_name('interop_client_%s' %
- language.safename)
- cmdline = docker_run_cmdline(cmdline,
- image=docker_image,
- cwd=cwd,
- environ=environ,
- docker_args=['--net=host',
- '--name=%s' % container_name])
- if manual_cmd_log is not None:
- if manual_cmd_log == []:
- manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' % docker_image)
- manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
- cwd = None
- environ = None
-
- suite_name='cloud_to_prod_auth' if auth else 'cloud_to_prod'
- test_job = jobset.JobSpec(
- cmdline=cmdline,
- cwd=cwd,
- environ=environ,
- shortname='%s:%s:%s:%s' % (suite_name, server_host_name, language,
- test_case),
- timeout_seconds=_TEST_TIMEOUT,
- flake_retries=5 if args.allow_flakes else 0,
- timeout_retries=2 if args.allow_flakes else 0,
- kill_handler=_job_kill_handler)
- if docker_image:
- test_job.container_name = container_name
- return test_job
-
-
-def cloud_to_cloud_jobspec(language, test_case, server_name, server_host,
- server_port, docker_image=None, insecure=False,
- manual_cmd_log=None):
- """Creates jobspec for cloud-to-cloud interop test"""
- interop_only_options = [
- '--server_host_override=foo.test.google.fr',
- '--use_tls=%s' % ('false' if insecure else 'true'),
- '--use_test_ca=true',
- ]
-
- client_test_case = test_case
- if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
- client_test_case = _GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES[test_case]
- if client_test_case in language.unimplemented_test_cases():
- print('asking client %s to run unimplemented test case %s' % (repr(language), client_test_case))
- sys.exit(1)
+ """Creates jobspec for cloud-to-prod interop test"""
+ container_name = None
+ cmdargs = [
+ '--server_host=%s' % server_host_detail[0],
+ '--server_host_override=%s' % server_host_detail[1],
+ '--server_port=443', '--use_tls=true',
+ '--test_case=%s' % test_case
+ ]
+ environ = dict(language.cloud_to_prod_env(), **language.global_env())
+ if auth:
+ auth_cmdargs, auth_env = auth_options(language, test_case)
+ cmdargs += auth_cmdargs
+ environ.update(auth_env)
+ cmdline = bash_cmdline(language.client_cmd(cmdargs))
+ cwd = language.client_cwd
- common_options = [
- '--test_case=%s' % client_test_case,
- '--server_host=%s' % server_host,
- '--server_port=%s' % server_port,
- ]
+ if docker_image:
+ container_name = dockerjob.random_name(
+ 'interop_client_%s' % language.safename)
+ cmdline = docker_run_cmdline(
+ cmdline,
+ image=docker_image,
+ cwd=cwd,
+ environ=environ,
+ docker_args=['--net=host',
+ '--name=%s' % container_name])
+ if manual_cmd_log is not None:
+ if manual_cmd_log == []:
+ manual_cmd_log.append(
+ 'echo "Testing ${docker_image:=%s}"' % docker_image)
+ manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
+ cwd = None
+ environ = None
+
+ suite_name = 'cloud_to_prod_auth' if auth else 'cloud_to_prod'
+ test_job = jobset.JobSpec(
+ cmdline=cmdline,
+ cwd=cwd,
+ environ=environ,
+ shortname='%s:%s:%s:%s' % (suite_name, language, server_host_name,
+ test_case),
+ timeout_seconds=_TEST_TIMEOUT,
+ flake_retries=4 if args.allow_flakes else 0,
+ timeout_retries=2 if args.allow_flakes else 0,
+ kill_handler=_job_kill_handler)
+ if docker_image:
+ test_job.container_name = container_name
+ return test_job
+
+
+def cloud_to_cloud_jobspec(language,
+ test_case,
+ server_name,
+ server_host,
+ server_port,
+ docker_image=None,
+ insecure=False,
+ manual_cmd_log=None):
+ """Creates jobspec for cloud-to-cloud interop test"""
+ interop_only_options = [
+ '--server_host_override=foo.test.google.fr',
+ '--use_tls=%s' % ('false' if insecure else 'true'),
+ '--use_test_ca=true',
+ ]
- if test_case in _HTTP2_SERVER_TEST_CASES:
+ client_test_case = test_case
if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
- client_options = interop_only_options + common_options
- cmdline = bash_cmdline(language.client_cmd(client_options))
- cwd = language.client_cwd
- else:
- cmdline = bash_cmdline(language.client_cmd_http2interop(common_options))
- cwd = language.http2_cwd
- else:
- cmdline = bash_cmdline(language.client_cmd(common_options+interop_only_options))
- cwd = language.client_cwd
+ client_test_case = _GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES[
+ test_case]
+ if client_test_case in language.unimplemented_test_cases():
+ print('asking client %s to run unimplemented test case %s' %
+ (repr(language), client_test_case))
+ sys.exit(1)
+
+ common_options = [
+ '--test_case=%s' % client_test_case,
+ '--server_host=%s' % server_host,
+ '--server_port=%s' % server_port,
+ ]
- environ = language.global_env()
- if docker_image and language.safename != 'objc':
- # we can't run client in docker for objc.
- container_name = dockerjob.random_name('interop_client_%s' % language.safename)
- cmdline = docker_run_cmdline(cmdline,
- image=docker_image,
- environ=environ,
- cwd=cwd,
- docker_args=['--net=host',
- '--name=%s' % container_name])
- if manual_cmd_log is not None:
- if manual_cmd_log == []:
- manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' % docker_image)
- manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
- cwd = None
-
- test_job = jobset.JobSpec(
- cmdline=cmdline,
- cwd=cwd,
- environ=environ,
- shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name,
- test_case),
- timeout_seconds=_TEST_TIMEOUT,
- flake_retries=5 if args.allow_flakes else 0,
- timeout_retries=2 if args.allow_flakes else 0,
- kill_handler=_job_kill_handler)
- if docker_image:
- test_job.container_name = container_name
- return test_job
+ if test_case in _HTTP2_SERVER_TEST_CASES:
+ if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
+ client_options = interop_only_options + common_options
+ cmdline = bash_cmdline(language.client_cmd(client_options))
+ cwd = language.client_cwd
+ else:
+ cmdline = bash_cmdline(
+ language.client_cmd_http2interop(common_options))
+ cwd = language.http2_cwd
+ else:
+ cmdline = bash_cmdline(
+ language.client_cmd(common_options + interop_only_options))
+ cwd = language.client_cwd
+
+ environ = language.global_env()
+ if docker_image and language.safename != 'objc':
+ # we can't run client in docker for objc.
+ container_name = dockerjob.random_name(
+ 'interop_client_%s' % language.safename)
+ cmdline = docker_run_cmdline(
+ cmdline,
+ image=docker_image,
+ environ=environ,
+ cwd=cwd,
+ docker_args=['--net=host',
+ '--name=%s' % container_name])
+ if manual_cmd_log is not None:
+ if manual_cmd_log == []:
+ manual_cmd_log.append(
+ 'echo "Testing ${docker_image:=%s}"' % docker_image)
+ manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
+ cwd = None
+
+ test_job = jobset.JobSpec(
+ cmdline=cmdline,
+ cwd=cwd,
+ environ=environ,
+ shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name,
+ test_case),
+ timeout_seconds=_TEST_TIMEOUT,
+ flake_retries=4 if args.allow_flakes else 0,
+ timeout_retries=2 if args.allow_flakes else 0,
+ kill_handler=_job_kill_handler)
+ if docker_image:
+ test_job.container_name = container_name
+ return test_job
def server_jobspec(language, docker_image, insecure=False, manual_cmd_log=None):
- """Create jobspec for running a server"""
- container_name = dockerjob.random_name('interop_server_%s' % language.safename)
- cmdline = bash_cmdline(
- language.server_cmd(['--port=%s' % _DEFAULT_SERVER_PORT,
- '--use_tls=%s' % ('false' if insecure else 'true')]))
- environ = language.global_env()
- docker_args = ['--name=%s' % container_name]
- if language.safename == 'http2':
- # we are running the http2 interop server. Open next N ports beginning
- # with the server port. These ports are used for http2 interop test
- # (one test case per port).
- docker_args += list(
- itertools.chain.from_iterable(('-p', str(_DEFAULT_SERVER_PORT + i))
- for i in range(
- len(_HTTP2_SERVER_TEST_CASES))))
- # Enable docker's healthcheck mechanism.
- # This runs a Python script inside the container every second. The script
- # pings the http2 server to verify it is ready. The 'health-retries' flag
- # specifies the number of consecutive failures before docker will report
- # the container's status as 'unhealthy'. Prior to the first 'health_retries'
- # failures or the first success, the status will be 'starting'. 'docker ps'
- # or 'docker inspect' can be used to see the health of the container on the
- # command line.
- docker_args += [
- '--health-cmd=python test/http2_test/http2_server_health_check.py '
- '--server_host=%s --server_port=%d'
- % ('localhost', _DEFAULT_SERVER_PORT),
- '--health-interval=1s',
- '--health-retries=5',
- '--health-timeout=10s',
- ]
+ """Create jobspec for running a server"""
+ container_name = dockerjob.random_name(
+ 'interop_server_%s' % language.safename)
+ cmdline = bash_cmdline(
+ language.server_cmd([
+ '--port=%s' % _DEFAULT_SERVER_PORT,
+ '--use_tls=%s' % ('false' if insecure else 'true')
+ ]))
+ environ = language.global_env()
+ docker_args = ['--name=%s' % container_name]
+ if language.safename == 'http2':
+ # we are running the http2 interop server. Open next N ports beginning
+ # with the server port. These ports are used for http2 interop test
+ # (one test case per port).
+ docker_args += list(
+ itertools.chain.from_iterable(
+ ('-p', str(_DEFAULT_SERVER_PORT + i))
+ for i in range(len(_HTTP2_SERVER_TEST_CASES))))
+ # Enable docker's healthcheck mechanism.
+ # This runs a Python script inside the container every second. The script
+ # pings the http2 server to verify it is ready. The 'health-retries' flag
+ # specifies the number of consecutive failures before docker will report
+ # the container's status as 'unhealthy'. Prior to the first 'health_retries'
+ # failures or the first success, the status will be 'starting'. 'docker ps'
+ # or 'docker inspect' can be used to see the health of the container on the
+ # command line.
+ docker_args += [
+ '--health-cmd=python test/http2_test/http2_server_health_check.py '
+ '--server_host=%s --server_port=%d' % ('localhost',
+ _DEFAULT_SERVER_PORT),
+ '--health-interval=1s',
+ '--health-retries=5',
+ '--health-timeout=10s',
+ ]
- else:
- docker_args += ['-p', str(_DEFAULT_SERVER_PORT)]
-
- docker_cmdline = docker_run_cmdline(cmdline,
- image=docker_image,
- cwd=language.server_cwd,
- environ=environ,
- docker_args=docker_args)
- if manual_cmd_log is not None:
- if manual_cmd_log == []:
- manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' % docker_image)
- manual_cmd_log.append(manual_cmdline(docker_cmdline, docker_image))
- server_job = jobset.JobSpec(
- cmdline=docker_cmdline,
- environ=environ,
- shortname='interop_server_%s' % language,
- timeout_seconds=30*60)
- server_job.container_name = container_name
- return server_job
+ else:
+ docker_args += ['-p', str(_DEFAULT_SERVER_PORT)]
+
+ docker_cmdline = docker_run_cmdline(
+ cmdline,
+ image=docker_image,
+ cwd=language.server_cwd,
+ environ=environ,
+ docker_args=docker_args)
+ if manual_cmd_log is not None:
+ if manual_cmd_log == []:
+ manual_cmd_log.append(
+ 'echo "Testing ${docker_image:=%s}"' % docker_image)
+ manual_cmd_log.append(manual_cmdline(docker_cmdline, docker_image))
+ server_job = jobset.JobSpec(
+ cmdline=docker_cmdline,
+ environ=environ,
+ shortname='interop_server_%s' % language,
+ timeout_seconds=30 * 60)
+ server_job.container_name = container_name
+ return server_job
def build_interop_image_jobspec(language, tag=None):
- """Creates jobspec for building interop docker image for a language"""
- if not tag:
- tag = 'grpc_interop_%s:%s' % (language.safename, uuid.uuid4())
- env = {'INTEROP_IMAGE': tag,
- 'BASE_NAME': 'grpc_interop_%s' % language.safename}
- if not args.travis:
- env['TTY_FLAG'] = '-t'
- # This env variable is used to get around the github rate limit
- # error when running the PHP `composer install` command
- host_file = '%s/.composer/auth.json' % os.environ['HOME']
- if language.safename == 'php' and os.path.exists(host_file):
- env['BUILD_INTEROP_DOCKER_EXTRA_ARGS'] = \
- '-v %s:/root/.composer/auth.json:ro' % host_file
- build_job = jobset.JobSpec(
- cmdline=['tools/run_tests/dockerize/build_interop_image.sh'],
- environ=env,
- shortname='build_docker_%s' % (language),
- timeout_seconds=30*60)
- build_job.tag = tag
- return build_job
+ """Creates jobspec for building interop docker image for a language"""
+ if not tag:
+ tag = 'grpc_interop_%s:%s' % (language.safename, uuid.uuid4())
+ env = {
+ 'INTEROP_IMAGE': tag,
+ 'BASE_NAME': 'grpc_interop_%s' % language.safename
+ }
+ if not args.travis:
+ env['TTY_FLAG'] = '-t'
+ # This env variable is used to get around the github rate limit
+ # error when running the PHP `composer install` command
+ host_file = '%s/.composer/auth.json' % os.environ['HOME']
+ if language.safename == 'php' and os.path.exists(host_file):
+ env['BUILD_INTEROP_DOCKER_EXTRA_ARGS'] = \
+ '-v %s:/root/.composer/auth.json:ro' % host_file
+ build_job = jobset.JobSpec(
+ cmdline=['tools/run_tests/dockerize/build_interop_image.sh'],
+ environ=env,
+ shortname='build_docker_%s' % (language),
+ timeout_seconds=30 * 60)
+ build_job.tag = tag
+ return build_job
def aggregate_http2_results(stdout):
- match = re.search(r'\{"cases[^\]]*\]\}', stdout)
- if not match:
- return None
-
- results = json.loads(match.group(0))
- skipped = 0
- passed = 0
- failed = 0
- failed_cases = []
- for case in results['cases']:
- if case.get('skipped', False):
- skipped += 1
- else:
- if case.get('passed', False):
- passed += 1
- else:
- failed += 1
- failed_cases.append(case.get('name', "NONAME"))
- return {
- 'passed': passed,
- 'failed': failed,
- 'skipped': skipped,
- 'failed_cases': ', '.join(failed_cases),
- 'percent': 1.0 * passed / (passed + failed)
- }
+ match = re.search(r'\{"cases[^\]]*\]\}', stdout)
+ if not match:
+ return None
+
+ results = json.loads(match.group(0))
+ skipped = 0
+ passed = 0
+ failed = 0
+ failed_cases = []
+ for case in results['cases']:
+ if case.get('skipped', False):
+ skipped += 1
+ else:
+ if case.get('passed', False):
+ passed += 1
+ else:
+ failed += 1
+ failed_cases.append(case.get('name', "NONAME"))
+ return {
+ 'passed': passed,
+ 'failed': failed,
+ 'skipped': skipped,
+ 'failed_cases': ', '.join(failed_cases),
+ 'percent': 1.0 * passed / (passed + failed)
+ }
+
# A dictionary of prod servers to test.
# Format: server_name: (server_host, server_host_override, errors_allowed)
# TODO(adelez): implement logic for errors_allowed where if the indicated tests
# fail, they don't impact the overall test result.
prod_servers = {
- 'default': ('216.239.32.254',
- 'grpc-test.sandbox.googleapis.com', False),
- 'gateway_v2': ('216.239.32.254',
- 'grpc-test2.sandbox.googleapis.com', True),
+ 'default': ('216.239.32.254', 'grpc-test.sandbox.googleapis.com', False),
+ 'gateway_v2': ('216.239.32.254', 'grpc-test2.sandbox.googleapis.com', True),
'cloud_gateway': ('216.239.32.255', 'grpc-test.sandbox.googleapis.com',
False),
'cloud_gateway_v2': ('216.239.32.255', 'grpc-test2.sandbox.googleapis.com',
True),
- 'gateway_v4': ('216.239.32.254',
- 'grpc-test4.sandbox.googleapis.com', True),
+ 'gateway_v4': ('216.239.32.254', 'grpc-test4.sandbox.googleapis.com', True),
'cloud_gateway_v4': ('216.239.32.255', 'grpc-test4.sandbox.googleapis.com',
True),
}
argp = argparse.ArgumentParser(description='Run interop tests.')
-argp.add_argument('-l', '--language',
- choices=['all'] + sorted(_LANGUAGES),
- nargs='+',
- default=['all'],
- help='Clients to run. Objc client can be only run on OSX.')
+argp.add_argument(
+ '-l',
+ '--language',
+ choices=['all'] + sorted(_LANGUAGES),
+ nargs='+',
+ default=['all'],
+ help='Clients to run. Objc client can be only run on OSX.')
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
-argp.add_argument('--cloud_to_prod',
- default=False,
- action='store_const',
- const=True,
- help='Run cloud_to_prod tests.')
-argp.add_argument('--cloud_to_prod_auth',
- default=False,
- action='store_const',
- const=True,
- help='Run cloud_to_prod_auth tests.')
-argp.add_argument('--prod_servers',
- choices=prod_servers.keys(),
- default=['default'],
- nargs='+',
- help=('The servers to run cloud_to_prod and '
- 'cloud_to_prod_auth tests against.'))
-argp.add_argument('-s', '--server',
- choices=['all'] + sorted(_SERVERS),
- nargs='+',
- help='Run cloud_to_cloud servers in a separate docker ' +
- 'image. Servers can only be started automatically if ' +
- '--use_docker option is enabled.',
- default=[])
-argp.add_argument('--override_server',
- action='append',
- type=lambda kv: kv.split('='),
- help='Use servername=HOST:PORT to explicitly specify a server. E.g. csharp=localhost:50000',
- default=[])
-argp.add_argument('-t', '--travis',
- default=False,
- action='store_const',
- const=True)
-argp.add_argument('-v', '--verbose',
- default=False,
- action='store_const',
- const=True)
-argp.add_argument('--use_docker',
- default=False,
- action='store_const',
- const=True,
- help='Run all the interop tests under docker. That provides ' +
- 'additional isolation and prevents the need to install ' +
- 'language specific prerequisites. Only available on Linux.')
-argp.add_argument('--allow_flakes',
- default=False,
- action='store_const',
- const=True,
- help='Allow flaky tests to show as passing (re-runs failed tests up to five times)')
-argp.add_argument('--manual_run',
- default=False,
- action='store_const',
- const=True,
- help='Prepare things for running interop tests manually. ' +
- 'Preserve docker images after building them and skip '
- 'actually running the tests. Only print commands to run by ' +
- 'hand.')
-argp.add_argument('--http2_interop',
- default=False,
- action='store_const',
- const=True,
- help='Enable HTTP/2 client edge case testing. (Bad client, good server)')
-argp.add_argument('--http2_server_interop',
- default=False,
- action='store_const',
- const=True,
- help='Enable HTTP/2 server edge case testing. (Includes positive and negative tests')
-argp.add_argument('--insecure',
- default=False,
- action='store_const',
- const=True,
- help='Whether to use secure channel.')
-argp.add_argument('--internal_ci',
- default=False,
- action='store_const',
- const=True,
- help=('Put reports into subdirectories to improve '
- 'presentation of results by Internal CI.'))
+argp.add_argument(
+ '--cloud_to_prod',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run cloud_to_prod tests.')
+argp.add_argument(
+ '--cloud_to_prod_auth',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run cloud_to_prod_auth tests.')
+argp.add_argument(
+ '--prod_servers',
+ choices=prod_servers.keys(),
+ default=['default'],
+ nargs='+',
+ help=('The servers to run cloud_to_prod and '
+ 'cloud_to_prod_auth tests against.'))
+argp.add_argument(
+ '-s',
+ '--server',
+ choices=['all'] + sorted(_SERVERS),
+ nargs='+',
+ help='Run cloud_to_cloud servers in a separate docker ' +
+ 'image. Servers can only be started automatically if ' +
+ '--use_docker option is enabled.',
+ default=[])
+argp.add_argument(
+ '--override_server',
+ action='append',
+ type=lambda kv: kv.split('='),
+ help=
+ 'Use servername=HOST:PORT to explicitly specify a server. E.g. csharp=localhost:50000',
+ default=[])
+argp.add_argument(
+ '-t', '--travis', default=False, action='store_const', const=True)
+argp.add_argument(
+ '-v', '--verbose', default=False, action='store_const', const=True)
+argp.add_argument(
+ '--use_docker',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run all the interop tests under docker. That provides ' +
+ 'additional isolation and prevents the need to install ' +
+ 'language specific prerequisites. Only available on Linux.')
+argp.add_argument(
+ '--allow_flakes',
+ default=False,
+ action='store_const',
+ const=True,
+ help=
+ 'Allow flaky tests to show as passing (re-runs failed tests up to five times)'
+)
+argp.add_argument(
+ '--manual_run',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Prepare things for running interop tests manually. ' +
+ 'Preserve docker images after building them and skip '
+ 'actually running the tests. Only print commands to run by ' + 'hand.')
+argp.add_argument(
+ '--http2_interop',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Enable HTTP/2 client edge case testing. (Bad client, good server)')
+argp.add_argument(
+ '--http2_server_interop',
+ default=False,
+ action='store_const',
+ const=True,
+ help=
+ 'Enable HTTP/2 server edge case testing. (Includes positive and negative tests'
+)
+argp.add_argument(
+ '--insecure',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Whether to use secure channel.')
+argp.add_argument(
+ '--internal_ci',
+ default=False,
+ action='store_const',
+ const=True,
+ help=('Put reports into subdirectories to improve '
+ 'presentation of results by Internal CI.'))
+argp.add_argument(
+ '--bq_result_table',
+ default='',
+ type=str,
+ nargs='?',
+ help='Upload test results to a specified BQ table.')
args = argp.parse_args()
-servers = set(s for s in itertools.chain.from_iterable(_SERVERS
- if x == 'all' else [x]
- for x in args.server))
+servers = set(
+ s
+ for s in itertools.chain.from_iterable(
+ _SERVERS if x == 'all' else [x] for x in args.server))
if args.use_docker:
- if not args.travis:
- print('Seen --use_docker flag, will run interop tests under docker.')
- print('')
- print('IMPORTANT: The changes you are testing need to be locally committed')
- print('because only the committed changes in the current branch will be')
- print('copied to the docker environment.')
- time.sleep(5)
+ if not args.travis:
+ print('Seen --use_docker flag, will run interop tests under docker.')
+ print('')
+ print(
+ 'IMPORTANT: The changes you are testing need to be locally committed'
+ )
+ print(
+ 'because only the committed changes in the current branch will be')
+ print('copied to the docker environment.')
+ time.sleep(5)
if args.manual_run and not args.use_docker:
- print('--manual_run is only supported with --use_docker option enabled.')
- sys.exit(1)
+ print('--manual_run is only supported with --use_docker option enabled.')
+ sys.exit(1)
if not args.use_docker and servers:
- print('Running interop servers is only supported with --use_docker option enabled.')
- sys.exit(1)
-
+ print(
+ 'Running interop servers is only supported with --use_docker option enabled.'
+ )
+ sys.exit(1)
# we want to include everything but objc in 'all'
# because objc won't run on non-mac platforms
all_but_objc = set(six.iterkeys(_LANGUAGES)) - set(['objc'])
languages = set(_LANGUAGES[l]
for l in itertools.chain.from_iterable(
- all_but_objc if x == 'all' else [x]
- for x in args.language))
+ all_but_objc if x == 'all' else [x] for x in args.language))
languages_http2_clients_for_http2_server_interop = set()
if args.http2_server_interop:
- languages_http2_clients_for_http2_server_interop = set(
- _LANGUAGES[l] for l in _LANGUAGES_WITH_HTTP2_CLIENTS_FOR_HTTP2_SERVER_TEST_CASES
- if 'all' in args.language or l in args.language)
+ languages_http2_clients_for_http2_server_interop = set(
+ _LANGUAGES[l]
+ for l in _LANGUAGES_WITH_HTTP2_CLIENTS_FOR_HTTP2_SERVER_TEST_CASES
+ if 'all' in args.language or l in args.language)
http2Interop = Http2Client() if args.http2_interop else None
http2InteropServer = Http2Server() if args.http2_server_interop else None
-docker_images={}
+docker_images = {}
if args.use_docker:
- # languages for which to build docker images
- languages_to_build = set(
- _LANGUAGES[k] for k in set([str(l) for l in languages] + [s for s in servers]))
- languages_to_build = languages_to_build | languages_http2_clients_for_http2_server_interop
-
- if args.http2_interop:
- languages_to_build.add(http2Interop)
-
- if args.http2_server_interop:
- languages_to_build.add(http2InteropServer)
-
- build_jobs = []
- for l in languages_to_build:
- if str(l) == 'objc':
- # we don't need to build a docker image for objc
- continue
- job = build_interop_image_jobspec(l)
- docker_images[str(l)] = job.tag
- build_jobs.append(job)
-
- if build_jobs:
- jobset.message('START', 'Building interop docker images.', do_newline=True)
- if args.verbose:
- print('Jobs to run: \n%s\n' % '\n'.join(str(j) for j in build_jobs))
+ # languages for which to build docker images
+ languages_to_build = set(
+ _LANGUAGES[k]
+ for k in set([str(l) for l in languages] + [s for s in servers]))
+ languages_to_build = languages_to_build | languages_http2_clients_for_http2_server_interop
- num_failures, _ = jobset.run(
- build_jobs, newline_on_success=True, maxjobs=args.jobs)
- if num_failures == 0:
- jobset.message('SUCCESS', 'All docker images built successfully.',
- do_newline=True)
- else:
- jobset.message('FAILED', 'Failed to build interop docker images.',
- do_newline=True)
- for image in six.itervalues(docker_images):
- dockerjob.remove_image(image, skip_nonexistent=True)
- sys.exit(1)
+ if args.http2_interop:
+ languages_to_build.add(http2Interop)
+
+ if args.http2_server_interop:
+ languages_to_build.add(http2InteropServer)
+
+ build_jobs = []
+ for l in languages_to_build:
+ if str(l) == 'objc':
+ # we don't need to build a docker image for objc
+ continue
+ job = build_interop_image_jobspec(l)
+ docker_images[str(l)] = job.tag
+ build_jobs.append(job)
+
+ if build_jobs:
+ jobset.message(
+ 'START', 'Building interop docker images.', do_newline=True)
+ if args.verbose:
+ print('Jobs to run: \n%s\n' % '\n'.join(str(j) for j in build_jobs))
+
+ num_failures, _ = jobset.run(
+ build_jobs, newline_on_success=True, maxjobs=args.jobs)
+ if num_failures == 0:
+ jobset.message(
+ 'SUCCESS',
+ 'All docker images built successfully.',
+ do_newline=True)
+ else:
+ jobset.message(
+ 'FAILED',
+ 'Failed to build interop docker images.',
+ do_newline=True)
+ for image in six.itervalues(docker_images):
+ dockerjob.remove_image(image, skip_nonexistent=True)
+ sys.exit(1)
server_manual_cmd_log = [] if args.manual_run else None
client_manual_cmd_log = [] if args.manual_run else None
@@ -1043,212 +1139,236 @@ client_manual_cmd_log = [] if args.manual_run else None
server_jobs = {}
server_addresses = {}
try:
- for s in servers:
- lang = str(s)
- spec = server_jobspec(_LANGUAGES[lang], docker_images.get(lang),
- args.insecure, manual_cmd_log=server_manual_cmd_log)
- if not args.manual_run:
- job = dockerjob.DockerJob(spec)
- server_jobs[lang] = job
- server_addresses[lang] = ('localhost', job.mapped_port(_DEFAULT_SERVER_PORT))
- else:
- # don't run the server, set server port to a placeholder value
- server_addresses[lang] = ('localhost', '${SERVER_PORT}')
-
- http2_server_job = None
- if args.http2_server_interop:
- # launch a HTTP2 server emulator that creates edge cases
- lang = str(http2InteropServer)
- spec = server_jobspec(http2InteropServer, docker_images.get(lang),
- manual_cmd_log=server_manual_cmd_log)
- if not args.manual_run:
- http2_server_job = dockerjob.DockerJob(spec)
- server_jobs[lang] = http2_server_job
+ for s in servers:
+ lang = str(s)
+ spec = server_jobspec(
+ _LANGUAGES[lang],
+ docker_images.get(lang),
+ args.insecure,
+ manual_cmd_log=server_manual_cmd_log)
+ if not args.manual_run:
+ job = dockerjob.DockerJob(spec)
+ server_jobs[lang] = job
+ server_addresses[lang] = ('localhost',
+ job.mapped_port(_DEFAULT_SERVER_PORT))
+ else:
+ # don't run the server, set server port to a placeholder value
+ server_addresses[lang] = ('localhost', '${SERVER_PORT}')
+
+ http2_server_job = None
+ if args.http2_server_interop:
+ # launch a HTTP2 server emulator that creates edge cases
+ lang = str(http2InteropServer)
+ spec = server_jobspec(
+ http2InteropServer,
+ docker_images.get(lang),
+ manual_cmd_log=server_manual_cmd_log)
+ if not args.manual_run:
+ http2_server_job = dockerjob.DockerJob(spec)
+ server_jobs[lang] = http2_server_job
+ else:
+ # don't run the server, set server port to a placeholder value
+ server_addresses[lang] = ('localhost', '${SERVER_PORT}')
+
+ jobs = []
+ if args.cloud_to_prod:
+ if args.insecure:
+ print('TLS is always enabled for cloud_to_prod scenarios.')
+ for server_host_name in args.prod_servers:
+ for language in languages:
+ for test_case in _TEST_CASES:
+ if not test_case in language.unimplemented_test_cases():
+ if not test_case in _SKIP_ADVANCED + _SKIP_COMPRESSION:
+ test_job = cloud_to_prod_jobspec(
+ language,
+ test_case,
+ server_host_name,
+ prod_servers[server_host_name],
+ docker_image=docker_images.get(str(language)),
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+
+ if args.http2_interop:
+ for test_case in _HTTP2_TEST_CASES:
+ test_job = cloud_to_prod_jobspec(
+ http2Interop,
+ test_case,
+ server_host_name,
+ prod_servers[server_host_name],
+ docker_image=docker_images.get(str(http2Interop)),
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+
+ if args.cloud_to_prod_auth:
+ if args.insecure:
+ print('TLS is always enabled for cloud_to_prod scenarios.')
+ for server_host_name in args.prod_servers:
+ for language in languages:
+ for test_case in _AUTH_TEST_CASES:
+ if not test_case in language.unimplemented_test_cases():
+ test_job = cloud_to_prod_jobspec(
+ language,
+ test_case,
+ server_host_name,
+ prod_servers[server_host_name],
+ docker_image=docker_images.get(str(language)),
+ auth=True,
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+
+ for server in args.override_server:
+ server_name = server[0]
+ (server_host, server_port) = server[1].split(':')
+ server_addresses[server_name] = (server_host, server_port)
+
+ for server_name, server_address in server_addresses.items():
+ (server_host, server_port) = server_address
+ server_language = _LANGUAGES.get(server_name, None)
+ skip_server = [] # test cases unimplemented by server
+ if server_language:
+ skip_server = server_language.unimplemented_test_cases_server()
+ for language in languages:
+ for test_case in _TEST_CASES:
+ if not test_case in language.unimplemented_test_cases():
+ if not test_case in skip_server:
+ test_job = cloud_to_cloud_jobspec(
+ language,
+ test_case,
+ server_name,
+ server_host,
+ server_port,
+ docker_image=docker_images.get(str(language)),
+ insecure=args.insecure,
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+
+ if args.http2_interop:
+ for test_case in _HTTP2_TEST_CASES:
+ if server_name == "go":
+ # TODO(carl-mastrangelo): Reenable after https://github.com/grpc/grpc-go/issues/434
+ continue
+ test_job = cloud_to_cloud_jobspec(
+ http2Interop,
+ test_case,
+ server_name,
+ server_host,
+ server_port,
+ docker_image=docker_images.get(str(http2Interop)),
+ insecure=args.insecure,
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+
+ if args.http2_server_interop:
+ if not args.manual_run:
+ http2_server_job.wait_for_healthy(timeout_seconds=600)
+ for language in languages_http2_clients_for_http2_server_interop:
+ for test_case in set(_HTTP2_SERVER_TEST_CASES) - set(
+ _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS):
+ offset = sorted(_HTTP2_SERVER_TEST_CASES).index(test_case)
+ server_port = _DEFAULT_SERVER_PORT + offset
+ if not args.manual_run:
+ server_port = http2_server_job.mapped_port(server_port)
+ test_job = cloud_to_cloud_jobspec(
+ language,
+ test_case,
+ str(http2InteropServer),
+ 'localhost',
+ server_port,
+ docker_image=docker_images.get(str(language)),
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+ for language in languages:
+ # HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS is a subset of
+ # HTTP_SERVER_TEST_CASES, in which clients use their gRPC interop clients rather
+ # than specialized http2 clients, reusing existing test implementations.
+ # For example, in the "data_frame_padding" test, use language's gRPC
+ # interop clients and make them think that theyre running "large_unary"
+ # test case. This avoids implementing a new test case in each language.
+ for test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
+ if test_case not in language.unimplemented_test_cases():
+ offset = sorted(_HTTP2_SERVER_TEST_CASES).index(test_case)
+ server_port = _DEFAULT_SERVER_PORT + offset
+ if not args.manual_run:
+ server_port = http2_server_job.mapped_port(server_port)
+ if not args.insecure:
+ print((
+ 'Creating grpc cient to http2 server test case with insecure connection, even though'
+ ' args.insecure is False. Http2 test server only supports insecure connections.'
+ ))
+ test_job = cloud_to_cloud_jobspec(
+ language,
+ test_case,
+ str(http2InteropServer),
+ 'localhost',
+ server_port,
+ docker_image=docker_images.get(str(language)),
+ insecure=True,
+ manual_cmd_log=client_manual_cmd_log)
+ jobs.append(test_job)
+
+ if not jobs:
+ print('No jobs to run.')
+ for image in six.itervalues(docker_images):
+ dockerjob.remove_image(image, skip_nonexistent=True)
+ sys.exit(1)
+
+ if args.manual_run:
+ print('All tests will skipped --manual_run option is active.')
+
+ if args.verbose:
+ print('Jobs to run: \n%s\n' % '\n'.join(str(job) for job in jobs))
+
+ num_failures, resultset = jobset.run(
+ jobs,
+ newline_on_success=True,
+ maxjobs=args.jobs,
+ skip_jobs=args.manual_run)
+ if args.bq_result_table and resultset:
+ upload_interop_results_to_bq(resultset, args.bq_result_table, args)
+ if num_failures:
+ jobset.message('FAILED', 'Some tests failed', do_newline=True)
else:
- # don't run the server, set server port to a placeholder value
- server_addresses[lang] = ('localhost', '${SERVER_PORT}')
-
- jobs = []
- if args.cloud_to_prod:
- if args.insecure:
- print('TLS is always enabled for cloud_to_prod scenarios.')
- for server_host_name in args.prod_servers:
- for language in languages:
- for test_case in _TEST_CASES:
- if not test_case in language.unimplemented_test_cases():
- if not test_case in _SKIP_ADVANCED + _SKIP_COMPRESSION:
- test_job = cloud_to_prod_jobspec(
- language, test_case, server_host_name,
- prod_servers[server_host_name],
- docker_image=docker_images.get(str(language)),
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
-
- if args.http2_interop:
- for test_case in _HTTP2_TEST_CASES:
- test_job = cloud_to_prod_jobspec(
- http2Interop, test_case, server_host_name,
- prod_servers[server_host_name],
- docker_image=docker_images.get(str(http2Interop)),
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
-
- if args.cloud_to_prod_auth:
- if args.insecure:
- print('TLS is always enabled for cloud_to_prod scenarios.')
- for server_host_name in args.prod_servers:
- for language in languages:
- for test_case in _AUTH_TEST_CASES:
- if not test_case in language.unimplemented_test_cases():
- test_job = cloud_to_prod_jobspec(
- language, test_case, server_host_name,
- prod_servers[server_host_name],
- docker_image=docker_images.get(str(language)), auth=True,
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
-
- for server in args.override_server:
- server_name = server[0]
- (server_host, server_port) = server[1].split(':')
- server_addresses[server_name] = (server_host, server_port)
-
- for server_name, server_address in server_addresses.items():
- (server_host, server_port) = server_address
- server_language = _LANGUAGES.get(server_name, None)
- skip_server = [] # test cases unimplemented by server
- if server_language:
- skip_server = server_language.unimplemented_test_cases_server()
- for language in languages:
- for test_case in _TEST_CASES:
- if not test_case in language.unimplemented_test_cases():
- if not test_case in skip_server:
- test_job = cloud_to_cloud_jobspec(language,
- test_case,
- server_name,
- server_host,
- server_port,
- docker_image=docker_images.get(str(language)),
- insecure=args.insecure,
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
+ jobset.message('SUCCESS', 'All tests passed', do_newline=True)
- if args.http2_interop:
- for test_case in _HTTP2_TEST_CASES:
- if server_name == "go":
- # TODO(carl-mastrangelo): Reenable after https://github.com/grpc/grpc-go/issues/434
- continue
- test_job = cloud_to_cloud_jobspec(http2Interop,
- test_case,
- server_name,
- server_host,
- server_port,
- docker_image=docker_images.get(str(http2Interop)),
- insecure=args.insecure,
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
-
- if args.http2_server_interop:
- if not args.manual_run:
- http2_server_job.wait_for_healthy(timeout_seconds=600)
- for language in languages_http2_clients_for_http2_server_interop:
- for test_case in set(_HTTP2_SERVER_TEST_CASES) - set(_HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS):
- offset = sorted(_HTTP2_SERVER_TEST_CASES).index(test_case)
- server_port = _DEFAULT_SERVER_PORT+offset
- if not args.manual_run:
- server_port = http2_server_job.mapped_port(server_port)
- test_job = cloud_to_cloud_jobspec(language,
- test_case,
- str(http2InteropServer),
- 'localhost',
- server_port,
- docker_image=docker_images.get(str(language)),
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
- for language in languages:
- # HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS is a subset of
- # HTTP_SERVER_TEST_CASES, in which clients use their gRPC interop clients rather
- # than specialized http2 clients, reusing existing test implementations.
- # For example, in the "data_frame_padding" test, use language's gRPC
- # interop clients and make them think that theyre running "large_unary"
- # test case. This avoids implementing a new test case in each language.
- for test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
- if test_case not in language.unimplemented_test_cases():
- offset = sorted(_HTTP2_SERVER_TEST_CASES).index(test_case)
- server_port = _DEFAULT_SERVER_PORT+offset
- if not args.manual_run:
- server_port = http2_server_job.mapped_port(server_port)
- if not args.insecure:
- print(('Creating grpc cient to http2 server test case with insecure connection, even though'
- ' args.insecure is False. Http2 test server only supports insecure connections.'))
- test_job = cloud_to_cloud_jobspec(language,
- test_case,
- str(http2InteropServer),
- 'localhost',
- server_port,
- docker_image=docker_images.get(str(language)),
- insecure=True,
- manual_cmd_log=client_manual_cmd_log)
- jobs.append(test_job)
-
- if not jobs:
- print('No jobs to run.')
- for image in six.itervalues(docker_images):
- dockerjob.remove_image(image, skip_nonexistent=True)
- sys.exit(1)
+ write_cmdlog_maybe(server_manual_cmd_log, 'interop_server_cmds.sh')
+ write_cmdlog_maybe(client_manual_cmd_log, 'interop_client_cmds.sh')
- if args.manual_run:
- print('All tests will skipped --manual_run option is active.')
-
- if args.verbose:
- print('Jobs to run: \n%s\n' % '\n'.join(str(job) for job in jobs))
-
- num_failures, resultset = jobset.run(jobs, newline_on_success=True,
- maxjobs=args.jobs,
- skip_jobs=args.manual_run)
- if num_failures:
- jobset.message('FAILED', 'Some tests failed', do_newline=True)
- else:
- jobset.message('SUCCESS', 'All tests passed', do_newline=True)
-
- write_cmdlog_maybe(server_manual_cmd_log, 'interop_server_cmds.sh')
- write_cmdlog_maybe(client_manual_cmd_log, 'interop_client_cmds.sh')
-
- xml_report_name = _XML_REPORT
- if args.internal_ci:
- xml_report_name = _INTERNAL_CL_XML_REPORT
- report_utils.render_junit_xml_report(resultset, xml_report_name)
-
- for name, job in resultset.items():
- if "http2" in name:
- job[0].http2results = aggregate_http2_results(job[0].message)
-
- http2_server_test_cases = (
- _HTTP2_SERVER_TEST_CASES if args.http2_server_interop else [])
-
- report_utils.render_interop_html_report(
- set([str(l) for l in languages]), servers, _TEST_CASES, _AUTH_TEST_CASES,
- _HTTP2_TEST_CASES, http2_server_test_cases, resultset, num_failures,
- args.cloud_to_prod_auth or args.cloud_to_prod, args.prod_servers,
- args.http2_interop)
-
- if num_failures:
- sys.exit(1)
- else:
- sys.exit(0)
+ xml_report_name = _XML_REPORT
+ if args.internal_ci:
+ xml_report_name = _INTERNAL_CL_XML_REPORT
+ report_utils.render_junit_xml_report(resultset, xml_report_name)
+
+ for name, job in resultset.items():
+ if "http2" in name:
+ job[0].http2results = aggregate_http2_results(job[0].message)
+
+ http2_server_test_cases = (_HTTP2_SERVER_TEST_CASES
+ if args.http2_server_interop else [])
+
+ report_utils.render_interop_html_report(
+ set([str(l) for l in languages]), servers, _TEST_CASES,
+ _AUTH_TEST_CASES, _HTTP2_TEST_CASES, http2_server_test_cases, resultset,
+ num_failures, args.cloud_to_prod_auth or args.cloud_to_prod,
+ args.prod_servers, args.http2_interop)
+
+ if num_failures:
+ sys.exit(1)
+ else:
+ sys.exit(0)
except Exception as e:
- print('exception occurred:')
- traceback.print_exc(file=sys.stdout)
+ print('exception occurred:')
+ traceback.print_exc(file=sys.stdout)
finally:
- # Check if servers are still running.
- for server, job in server_jobs.items():
- if not job.is_running():
- print('Server "%s" has exited prematurely.' % server)
+ # Check if servers are still running.
+ for server, job in server_jobs.items():
+ if not job.is_running():
+ print('Server "%s" has exited prematurely.' % server)
- dockerjob.finish_jobs([j for j in six.itervalues(server_jobs)])
+ dockerjob.finish_jobs([j for j in six.itervalues(server_jobs)])
- for image in six.itervalues(docker_images):
- if not args.manual_run:
- print('Removing docker image %s' % image)
- dockerjob.remove_image(image)
- else:
- print('Preserving docker image: %s' % image)
+ for image in six.itervalues(docker_images):
+ if not args.manual_run:
+ print('Removing docker image %s' % image)
+ dockerjob.remove_image(image)
+ else:
+ print('Preserving docker image: %s' % image)
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index c136af58cb..4e4d05cdcd 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -23,26 +23,31 @@ import argparse
import python_utils.jobset as jobset
import python_utils.start_port_server as start_port_server
-sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', 'profiling', 'microbenchmarks', 'bm_diff'))
+sys.path.append(
+ os.path.join(
+ os.path.dirname(sys.argv[0]), '..', 'profiling', 'microbenchmarks',
+ 'bm_diff'))
import bm_constants
flamegraph_dir = os.path.join(os.path.expanduser('~'), 'FlameGraph')
os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
if not os.path.exists('reports'):
- os.makedirs('reports')
+ os.makedirs('reports')
start_port_server.start_port_server()
+
def fnize(s):
- out = ''
- for c in s:
- if c in '<>, /':
- if len(out) and out[-1] == '_': continue
- out += '_'
- else:
- out += c
- return out
+ out = ''
+ for c in s:
+ if c in '<>, /':
+ if len(out) and out[-1] == '_': continue
+ out += '_'
+ else:
+ out += c
+ return out
+
# index html
index_html = """
@@ -53,169 +58,210 @@ index_html = """
<body>
"""
+
def heading(name):
- global index_html
- index_html += "<h1>%s</h1>\n" % name
+ global index_html
+ index_html += "<h1>%s</h1>\n" % name
+
def link(txt, tgt):
- global index_html
- index_html += "<p><a href=\"%s\">%s</a></p>\n" % (
- cgi.escape(tgt, quote=True), cgi.escape(txt))
+ global index_html
+ index_html += "<p><a href=\"%s\">%s</a></p>\n" % (
+ cgi.escape(tgt, quote=True), cgi.escape(txt))
+
def text(txt):
- global index_html
- index_html += "<p><pre>%s</pre></p>\n" % cgi.escape(txt)
+ global index_html
+ index_html += "<p><pre>%s</pre></p>\n" % cgi.escape(txt)
+
def collect_latency(bm_name, args):
- """generate latency profiles"""
- benchmarks = []
- profile_analysis = []
- cleanup = []
-
- heading('Latency Profiles: %s' % bm_name)
- subprocess.check_call(
- ['make', bm_name,
- 'CONFIG=basicprof', '-j', '%d' % multiprocessing.cpu_count()])
- for line in subprocess.check_output(['bins/basicprof/%s' % bm_name,
- '--benchmark_list_tests']).splitlines():
- link(line, '%s.txt' % fnize(line))
- benchmarks.append(
- jobset.JobSpec(['bins/basicprof/%s' % bm_name,
- '--benchmark_filter=^%s$' % line,
- '--benchmark_min_time=0.05'],
- environ={'LATENCY_TRACE': '%s.trace' % fnize(line)},
- shortname='profile-%s' % fnize(line)))
- profile_analysis.append(
- jobset.JobSpec([sys.executable,
- 'tools/profiling/latency_profile/profile_analyzer.py',
- '--source', '%s.trace' % fnize(line), '--fmt', 'simple',
- '--out', 'reports/%s.txt' % fnize(line)], timeout_seconds=20*60,
- shortname='analyze-%s' % fnize(line)))
- cleanup.append(jobset.JobSpec(['rm', '%s.trace' % fnize(line)]))
- # periodically flush out the list of jobs: profile_analysis jobs at least
- # consume upwards of five gigabytes of ram in some cases, and so analysing
- # hundreds of them at once is impractical -- but we want at least some
- # concurrency or the work takes too long
- if len(benchmarks) >= min(16, multiprocessing.cpu_count()):
- # run up to half the cpu count: each benchmark can use up to two cores
- # (one for the microbenchmark, one for the data flush)
- jobset.run(benchmarks, maxjobs=max(1, multiprocessing.cpu_count()/2))
- jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
- jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
- benchmarks = []
- profile_analysis = []
- cleanup = []
- # run the remaining benchmarks that weren't flushed
- if len(benchmarks):
- jobset.run(benchmarks, maxjobs=max(1, multiprocessing.cpu_count()/2))
- jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
- jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+ """generate latency profiles"""
+ benchmarks = []
+ profile_analysis = []
+ cleanup = []
+
+ heading('Latency Profiles: %s' % bm_name)
+ subprocess.check_call([
+ 'make', bm_name, 'CONFIG=basicprof', '-j',
+ '%d' % multiprocessing.cpu_count()
+ ])
+ for line in subprocess.check_output(
+ ['bins/basicprof/%s' % bm_name, '--benchmark_list_tests']).splitlines():
+ link(line, '%s.txt' % fnize(line))
+ benchmarks.append(
+ jobset.JobSpec(
+ [
+ 'bins/basicprof/%s' % bm_name,
+ '--benchmark_filter=^%s$' % line,
+ '--benchmark_min_time=0.05'
+ ],
+ environ={'LATENCY_TRACE': '%s.trace' % fnize(line)},
+ shortname='profile-%s' % fnize(line)))
+ profile_analysis.append(
+ jobset.JobSpec(
+ [
+ sys.executable,
+ 'tools/profiling/latency_profile/profile_analyzer.py',
+ '--source',
+ '%s.trace' % fnize(line), '--fmt', 'simple', '--out',
+ 'reports/%s.txt' % fnize(line)
+ ],
+ timeout_seconds=20 * 60,
+ shortname='analyze-%s' % fnize(line)))
+ cleanup.append(jobset.JobSpec(['rm', '%s.trace' % fnize(line)]))
+ # periodically flush out the list of jobs: profile_analysis jobs at least
+ # consume upwards of five gigabytes of ram in some cases, and so analysing
+ # hundreds of them at once is impractical -- but we want at least some
+ # concurrency or the work takes too long
+ if len(benchmarks) >= min(16, multiprocessing.cpu_count()):
+ # run up to half the cpu count: each benchmark can use up to two cores
+ # (one for the microbenchmark, one for the data flush)
+ jobset.run(
+ benchmarks, maxjobs=max(1,
+ multiprocessing.cpu_count() / 2))
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+ benchmarks = []
+ profile_analysis = []
+ cleanup = []
+ # run the remaining benchmarks that weren't flushed
+ if len(benchmarks):
+ jobset.run(benchmarks, maxjobs=max(1, multiprocessing.cpu_count() / 2))
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+
def collect_perf(bm_name, args):
- """generate flamegraphs"""
- heading('Flamegraphs: %s' % bm_name)
- subprocess.check_call(
- ['make', bm_name,
- 'CONFIG=mutrace', '-j', '%d' % multiprocessing.cpu_count()])
- benchmarks = []
- profile_analysis = []
- cleanup = []
- for line in subprocess.check_output(['bins/mutrace/%s' % bm_name,
- '--benchmark_list_tests']).splitlines():
- link(line, '%s.svg' % fnize(line))
- benchmarks.append(
- jobset.JobSpec(['perf', 'record', '-o', '%s-perf.data' % fnize(line),
- '-g', '-F', '997',
- 'bins/mutrace/%s' % bm_name,
- '--benchmark_filter=^%s$' % line,
- '--benchmark_min_time=10'],
- shortname='perf-%s' % fnize(line)))
- profile_analysis.append(
- jobset.JobSpec(['tools/run_tests/performance/process_local_perf_flamegraphs.sh'],
- environ = {
- 'PERF_BASE_NAME': fnize(line),
- 'OUTPUT_DIR': 'reports',
- 'OUTPUT_FILENAME': fnize(line),
- },
- shortname='flame-%s' % fnize(line)))
- cleanup.append(jobset.JobSpec(['rm', '%s-perf.data' % fnize(line)]))
- cleanup.append(jobset.JobSpec(['rm', '%s-out.perf' % fnize(line)]))
- # periodically flush out the list of jobs: temporary space required for this
- # processing is large
- if len(benchmarks) >= 20:
- # run up to half the cpu count: each benchmark can use up to two cores
- # (one for the microbenchmark, one for the data flush)
- jobset.run(benchmarks, maxjobs=1)
- jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
- jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
- benchmarks = []
- profile_analysis = []
- cleanup = []
- # run the remaining benchmarks that weren't flushed
- if len(benchmarks):
- jobset.run(benchmarks, maxjobs=1)
- jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
- jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+ """generate flamegraphs"""
+ heading('Flamegraphs: %s' % bm_name)
+ subprocess.check_call([
+ 'make', bm_name, 'CONFIG=mutrace', '-j',
+ '%d' % multiprocessing.cpu_count()
+ ])
+ benchmarks = []
+ profile_analysis = []
+ cleanup = []
+ for line in subprocess.check_output(
+ ['bins/mutrace/%s' % bm_name, '--benchmark_list_tests']).splitlines():
+ link(line, '%s.svg' % fnize(line))
+ benchmarks.append(
+ jobset.JobSpec(
+ [
+ 'perf', 'record', '-o',
+ '%s-perf.data' % fnize(line), '-g', '-F', '997',
+ 'bins/mutrace/%s' % bm_name,
+ '--benchmark_filter=^%s$' % line, '--benchmark_min_time=10'
+ ],
+ shortname='perf-%s' % fnize(line)))
+ profile_analysis.append(
+ jobset.JobSpec(
+ [
+ 'tools/run_tests/performance/process_local_perf_flamegraphs.sh'
+ ],
+ environ={
+ 'PERF_BASE_NAME': fnize(line),
+ 'OUTPUT_DIR': 'reports',
+ 'OUTPUT_FILENAME': fnize(line),
+ },
+ shortname='flame-%s' % fnize(line)))
+ cleanup.append(jobset.JobSpec(['rm', '%s-perf.data' % fnize(line)]))
+ cleanup.append(jobset.JobSpec(['rm', '%s-out.perf' % fnize(line)]))
+ # periodically flush out the list of jobs: temporary space required for this
+ # processing is large
+ if len(benchmarks) >= 20:
+ # run up to half the cpu count: each benchmark can use up to two cores
+ # (one for the microbenchmark, one for the data flush)
+ jobset.run(benchmarks, maxjobs=1)
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+ benchmarks = []
+ profile_analysis = []
+ cleanup = []
+ # run the remaining benchmarks that weren't flushed
+ if len(benchmarks):
+ jobset.run(benchmarks, maxjobs=1)
+ jobset.run(profile_analysis, maxjobs=multiprocessing.cpu_count())
+ jobset.run(cleanup, maxjobs=multiprocessing.cpu_count())
+
def run_summary(bm_name, cfg, base_json_name):
- subprocess.check_call(
- ['make', bm_name,
- 'CONFIG=%s' % cfg, '-j', '%d' % multiprocessing.cpu_count()])
- cmd = ['bins/%s/%s' % (cfg, bm_name),
- '--benchmark_out=%s.%s.json' % (base_json_name, cfg),
- '--benchmark_out_format=json']
- if args.summary_time is not None:
- cmd += ['--benchmark_min_time=%d' % args.summary_time]
- return subprocess.check_output(cmd)
+ subprocess.check_call([
+ 'make', bm_name,
+ 'CONFIG=%s' % cfg, '-j',
+ '%d' % multiprocessing.cpu_count()
+ ])
+ cmd = [
+ 'bins/%s/%s' % (cfg, bm_name),
+ '--benchmark_out=%s.%s.json' % (base_json_name, cfg),
+ '--benchmark_out_format=json'
+ ]
+ if args.summary_time is not None:
+ cmd += ['--benchmark_min_time=%d' % args.summary_time]
+ return subprocess.check_output(cmd)
+
def collect_summary(bm_name, args):
- heading('Summary: %s [no counters]' % bm_name)
- text(run_summary(bm_name, 'opt', bm_name))
- heading('Summary: %s [with counters]' % bm_name)
- text(run_summary(bm_name, 'counters', bm_name))
- if args.bigquery_upload:
- with open('%s.csv' % bm_name, 'w') as f:
- f.write(subprocess.check_output(['tools/profiling/microbenchmarks/bm2bq.py',
- '%s.counters.json' % bm_name,
- '%s.opt.json' % bm_name]))
- subprocess.check_call(['bq', 'load', 'microbenchmarks.microbenchmarks', '%s.csv' % bm_name])
+ heading('Summary: %s [no counters]' % bm_name)
+ text(run_summary(bm_name, 'opt', bm_name))
+ heading('Summary: %s [with counters]' % bm_name)
+ text(run_summary(bm_name, 'counters', bm_name))
+ if args.bigquery_upload:
+ with open('%s.csv' % bm_name, 'w') as f:
+ f.write(
+ subprocess.check_output([
+ 'tools/profiling/microbenchmarks/bm2bq.py',
+ '%s.counters.json' % bm_name,
+ '%s.opt.json' % bm_name
+ ]))
+ subprocess.check_call([
+ 'bq', 'load', 'microbenchmarks.microbenchmarks',
+ '%s.csv' % bm_name
+ ])
+
collectors = {
- 'latency': collect_latency,
- 'perf': collect_perf,
- 'summary': collect_summary,
+ 'latency': collect_latency,
+ 'perf': collect_perf,
+ 'summary': collect_summary,
}
argp = argparse.ArgumentParser(description='Collect data from microbenchmarks')
-argp.add_argument('-c', '--collect',
- choices=sorted(collectors.keys()),
- nargs='*',
- default=sorted(collectors.keys()),
- help='Which collectors should be run against each benchmark')
-argp.add_argument('-b', '--benchmarks',
- choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
- nargs='+',
- type=str,
- help='Which microbenchmarks should be run')
-argp.add_argument('--bigquery_upload',
- default=False,
- action='store_const',
- const=True,
- help='Upload results from summary collection to bigquery')
-argp.add_argument('--summary_time',
- default=None,
- type=int,
- help='Minimum time to run benchmarks for the summary collection')
+argp.add_argument(
+ '-c',
+ '--collect',
+ choices=sorted(collectors.keys()),
+ nargs='*',
+ default=sorted(collectors.keys()),
+ help='Which collectors should be run against each benchmark')
+argp.add_argument(
+ '-b',
+ '--benchmarks',
+ choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
+ nargs='+',
+ type=str,
+ help='Which microbenchmarks should be run')
+argp.add_argument(
+ '--bigquery_upload',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Upload results from summary collection to bigquery')
+argp.add_argument(
+ '--summary_time',
+ default=None,
+ type=int,
+ help='Minimum time to run benchmarks for the summary collection')
args = argp.parse_args()
try:
- for collect in args.collect:
- for bm_name in args.benchmarks:
- collectors[collect](bm_name, args)
+ for collect in args.collect:
+ for bm_name in args.benchmarks:
+ collectors[collect](bm_name, args)
finally:
- if not os.path.exists('reports'):
- os.makedirs('reports')
- index_html += "</body>\n</html>\n"
- with open('reports/index.html', 'w') as f:
- f.write(index_html)
+ if not os.path.exists('reports'):
+ os.makedirs('reports')
+ index_html += "</body>\n</html>\n"
+ with open('reports/index.html', 'w') as f:
+ f.write(index_html)
diff --git a/tools/run_tests/run_performance_tests.py b/tools/run_tests/run_performance_tests.py
index 1bbab9e894..9a9f74e9e5 100755
--- a/tools/run_tests/run_performance_tests.py
+++ b/tools/run_tests/run_performance_tests.py
@@ -12,7 +12,6 @@
# 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.
-
"""Run performance tests locally or remotely."""
from __future__ import print_function
@@ -37,558 +36,670 @@ import performance.scenario_config as scenario_config
import python_utils.jobset as jobset
import python_utils.report_utils as report_utils
-
_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
os.chdir(_ROOT)
-
_REMOTE_HOST_USERNAME = 'jenkins'
class QpsWorkerJob:
- """Encapsulates a qps worker server job."""
-
- def __init__(self, spec, language, host_and_port, perf_file_base_name=None):
- self._spec = spec
- self.language = language
- self.host_and_port = host_and_port
- self._job = None
- self.perf_file_base_name = perf_file_base_name
-
- def start(self):
- self._job = jobset.Job(self._spec, newline_on_success=True, travis=True, add_env={})
-
- def is_running(self):
- """Polls a job and returns True if given job is still running."""
- return self._job and self._job.state() == jobset._RUNNING
-
- def kill(self):
- if self._job:
- self._job.kill()
- self._job = None
-
-
-def create_qpsworker_job(language, shortname=None, port=10000, remote_host=None, perf_cmd=None):
- cmdline = (language.worker_cmdline() + ['--driver_port=%s' % port])
-
- if remote_host:
- host_and_port='%s:%s' % (remote_host, port)
- else:
- host_and_port='localhost:%s' % port
-
- perf_file_base_name = None
- if perf_cmd:
- perf_file_base_name = '%s-%s' % (host_and_port, shortname)
- # specify -o output file so perf.data gets collected when worker stopped
- cmdline = perf_cmd + ['-o', '%s-perf.data' % perf_file_base_name] + cmdline
-
- worker_timeout = 3 * 60
- if remote_host:
- user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
- ssh_cmd = ['ssh']
- cmdline = ['timeout', '%s' % (worker_timeout + 30)] + cmdline
- ssh_cmd.extend([str(user_at_host), 'cd ~/performance_workspace/grpc/ && python tools/run_tests/start_port_server.py && %s' % ' '.join(cmdline)])
- cmdline = ssh_cmd
-
- jobspec = jobset.JobSpec(
- cmdline=cmdline,
- shortname=shortname,
- timeout_seconds=worker_timeout, # workers get restarted after each scenario
- verbose_success=True)
- return QpsWorkerJob(jobspec, language, host_and_port, perf_file_base_name)
-
-
-def create_scenario_jobspec(scenario_json, workers, remote_host=None,
- bq_result_table=None, server_cpu_load=0):
- """Runs one scenario using QPS driver."""
- # setting QPS_WORKERS env variable here makes sure it works with SSH too.
- cmd = 'QPS_WORKERS="%s" ' % ','.join(workers)
- if bq_result_table:
- cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
- cmd += 'tools/run_tests/performance/run_qps_driver.sh '
- cmd += '--scenarios_json=%s ' % pipes.quote(json.dumps({'scenarios': [scenario_json]}))
- cmd += '--scenario_result_file=scenario_result.json '
- if server_cpu_load != 0:
- cmd += '--search_param=offered_load --initial_search_value=1000 --targeted_cpu_load=%d --stride=500 --error_tolerance=0.01' % server_cpu_load
- if remote_host:
- user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
- cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (user_at_host, pipes.quote(cmd))
-
- return jobset.JobSpec(
- cmdline=[cmd],
- shortname='qps_json_driver.%s' % scenario_json['name'],
- timeout_seconds=12*60,
- shell=True,
- verbose_success=True)
+ """Encapsulates a qps worker server job."""
+
+ def __init__(self, spec, language, host_and_port, perf_file_base_name=None):
+ self._spec = spec
+ self.language = language
+ self.host_and_port = host_and_port
+ self._job = None
+ self.perf_file_base_name = perf_file_base_name
+
+ def start(self):
+ self._job = jobset.Job(
+ self._spec, newline_on_success=True, travis=True, add_env={})
+
+ def is_running(self):
+ """Polls a job and returns True if given job is still running."""
+ return self._job and self._job.state() == jobset._RUNNING
+
+ def kill(self):
+ if self._job:
+ self._job.kill()
+ self._job = None
+
+
+def create_qpsworker_job(language,
+ shortname=None,
+ port=10000,
+ remote_host=None,
+ perf_cmd=None):
+ cmdline = (language.worker_cmdline() + ['--driver_port=%s' % port])
+
+ if remote_host:
+ host_and_port = '%s:%s' % (remote_host, port)
+ else:
+ host_and_port = 'localhost:%s' % port
+
+ perf_file_base_name = None
+ if perf_cmd:
+ perf_file_base_name = '%s-%s' % (host_and_port, shortname)
+ # specify -o output file so perf.data gets collected when worker stopped
+ cmdline = perf_cmd + ['-o', '%s-perf.data' % perf_file_base_name
+ ] + cmdline
+
+ worker_timeout = 3 * 60
+ if remote_host:
+ user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
+ ssh_cmd = ['ssh']
+ cmdline = ['timeout', '%s' % (worker_timeout + 30)] + cmdline
+ ssh_cmd.extend([
+ str(user_at_host),
+ 'cd ~/performance_workspace/grpc/ && python tools/run_tests/start_port_server.py && %s'
+ % ' '.join(cmdline)
+ ])
+ cmdline = ssh_cmd
+
+ jobspec = jobset.JobSpec(
+ cmdline=cmdline,
+ shortname=shortname,
+ timeout_seconds=
+ worker_timeout, # workers get restarted after each scenario
+ verbose_success=True)
+ return QpsWorkerJob(jobspec, language, host_and_port, perf_file_base_name)
+
+
+def create_scenario_jobspec(scenario_json,
+ workers,
+ remote_host=None,
+ bq_result_table=None,
+ server_cpu_load=0):
+ """Runs one scenario using QPS driver."""
+ # setting QPS_WORKERS env variable here makes sure it works with SSH too.
+ cmd = 'QPS_WORKERS="%s" ' % ','.join(workers)
+ if bq_result_table:
+ cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
+ cmd += 'tools/run_tests/performance/run_qps_driver.sh '
+ cmd += '--scenarios_json=%s ' % pipes.quote(
+ json.dumps({
+ 'scenarios': [scenario_json]
+ }))
+ cmd += '--scenario_result_file=scenario_result.json '
+ if server_cpu_load != 0:
+ cmd += '--search_param=offered_load --initial_search_value=1000 --targeted_cpu_load=%d --stride=500 --error_tolerance=0.01' % server_cpu_load
+ if remote_host:
+ user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
+ cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (
+ user_at_host, pipes.quote(cmd))
+
+ return jobset.JobSpec(
+ cmdline=[cmd],
+ shortname='qps_json_driver.%s' % scenario_json['name'],
+ timeout_seconds=12 * 60,
+ shell=True,
+ verbose_success=True)
def create_quit_jobspec(workers, remote_host=None):
- """Runs quit using QPS driver."""
- # setting QPS_WORKERS env variable here makes sure it works with SSH too.
- cmd = 'QPS_WORKERS="%s" bins/opt/qps_json_driver --quit' % ','.join(w.host_and_port for w in workers)
- if remote_host:
- user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
- cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (user_at_host, pipes.quote(cmd))
-
- return jobset.JobSpec(
- cmdline=[cmd],
- shortname='qps_json_driver.quit',
- timeout_seconds=3*60,
- shell=True,
- verbose_success=True)
-
-
-def create_netperf_jobspec(server_host='localhost', client_host=None,
+ """Runs quit using QPS driver."""
+ # setting QPS_WORKERS env variable here makes sure it works with SSH too.
+ cmd = 'QPS_WORKERS="%s" bins/opt/qps_json_driver --quit' % ','.join(
+ w.host_and_port for w in workers)
+ if remote_host:
+ user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
+ cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (
+ user_at_host, pipes.quote(cmd))
+
+ return jobset.JobSpec(
+ cmdline=[cmd],
+ shortname='qps_json_driver.quit',
+ timeout_seconds=3 * 60,
+ shell=True,
+ verbose_success=True)
+
+
+def create_netperf_jobspec(server_host='localhost',
+ client_host=None,
bq_result_table=None):
- """Runs netperf benchmark."""
- cmd = 'NETPERF_SERVER_HOST="%s" ' % server_host
- if bq_result_table:
- cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
- if client_host:
- # If netperf is running remotely, the env variables populated by Jenkins
- # won't be available on the client, but we need them for uploading results
- # to BigQuery.
- jenkins_job_name = os.getenv('JOB_NAME')
- if jenkins_job_name:
- cmd += 'JOB_NAME="%s" ' % jenkins_job_name
- jenkins_build_number = os.getenv('BUILD_NUMBER')
- if jenkins_build_number:
- cmd += 'BUILD_NUMBER="%s" ' % jenkins_build_number
-
- cmd += 'tools/run_tests/performance/run_netperf.sh'
- if client_host:
- user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, client_host)
- cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (user_at_host, pipes.quote(cmd))
-
- return jobset.JobSpec(
- cmdline=[cmd],
- shortname='netperf',
- timeout_seconds=60,
- shell=True,
- verbose_success=True)
+ """Runs netperf benchmark."""
+ cmd = 'NETPERF_SERVER_HOST="%s" ' % server_host
+ if bq_result_table:
+ cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
+ if client_host:
+ # If netperf is running remotely, the env variables populated by Jenkins
+ # won't be available on the client, but we need them for uploading results
+ # to BigQuery.
+ jenkins_job_name = os.getenv('JOB_NAME')
+ if jenkins_job_name:
+ cmd += 'JOB_NAME="%s" ' % jenkins_job_name
+ jenkins_build_number = os.getenv('BUILD_NUMBER')
+ if jenkins_build_number:
+ cmd += 'BUILD_NUMBER="%s" ' % jenkins_build_number
+
+ cmd += 'tools/run_tests/performance/run_netperf.sh'
+ if client_host:
+ user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, client_host)
+ cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (
+ user_at_host, pipes.quote(cmd))
+
+ return jobset.JobSpec(
+ cmdline=[cmd],
+ shortname='netperf',
+ timeout_seconds=60,
+ shell=True,
+ verbose_success=True)
def archive_repo(languages):
- """Archives local version of repo including submodules."""
- cmdline=['tar', '-cf', '../grpc.tar', '../grpc/']
- if 'java' in languages:
- cmdline.append('../grpc-java')
- if 'go' in languages:
- cmdline.append('../grpc-go')
-
- archive_job = jobset.JobSpec(
- cmdline=cmdline,
- shortname='archive_repo',
- timeout_seconds=3*60)
-
- jobset.message('START', 'Archiving local repository.', do_newline=True)
- num_failures, _ = jobset.run(
- [archive_job], newline_on_success=True, maxjobs=1)
- if num_failures == 0:
- jobset.message('SUCCESS',
- 'Archive with local repository created successfully.',
- do_newline=True)
- else:
- jobset.message('FAILED', 'Failed to archive local repository.',
- do_newline=True)
- sys.exit(1)
+ """Archives local version of repo including submodules."""
+ cmdline = ['tar', '-cf', '../grpc.tar', '../grpc/']
+ if 'java' in languages:
+ cmdline.append('../grpc-java')
+ if 'go' in languages:
+ cmdline.append('../grpc-go')
+
+ archive_job = jobset.JobSpec(
+ cmdline=cmdline, shortname='archive_repo', timeout_seconds=3 * 60)
+
+ jobset.message('START', 'Archiving local repository.', do_newline=True)
+ num_failures, _ = jobset.run(
+ [archive_job], newline_on_success=True, maxjobs=1)
+ if num_failures == 0:
+ jobset.message(
+ 'SUCCESS',
+ 'Archive with local repository created successfully.',
+ do_newline=True)
+ else:
+ jobset.message(
+ 'FAILED', 'Failed to archive local repository.', do_newline=True)
+ sys.exit(1)
def prepare_remote_hosts(hosts, prepare_local=False):
- """Prepares remote hosts (and maybe prepare localhost as well)."""
- prepare_timeout = 5*60
- prepare_jobs = []
- for host in hosts:
- user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
- prepare_jobs.append(
- jobset.JobSpec(
- cmdline=['tools/run_tests/performance/remote_host_prepare.sh'],
- shortname='remote_host_prepare.%s' % host,
- environ = {'USER_AT_HOST': user_at_host},
- timeout_seconds=prepare_timeout))
- if prepare_local:
- # Prepare localhost as well
- prepare_jobs.append(
- jobset.JobSpec(
- cmdline=['tools/run_tests/performance/kill_workers.sh'],
- shortname='local_prepare',
- timeout_seconds=prepare_timeout))
- jobset.message('START', 'Preparing hosts.', do_newline=True)
- num_failures, _ = jobset.run(
- prepare_jobs, newline_on_success=True, maxjobs=10)
- if num_failures == 0:
- jobset.message('SUCCESS',
- 'Prepare step completed successfully.',
- do_newline=True)
- else:
- jobset.message('FAILED', 'Failed to prepare remote hosts.',
- do_newline=True)
- sys.exit(1)
-
-
-def build_on_remote_hosts(hosts, languages=scenario_config.LANGUAGES.keys(), build_local=False):
- """Builds performance worker on remote hosts (and maybe also locally)."""
- build_timeout = 15*60
- build_jobs = []
- for host in hosts:
- user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
- build_jobs.append(
- jobset.JobSpec(
- cmdline=['tools/run_tests/performance/remote_host_build.sh'] + languages,
- shortname='remote_host_build.%s' % host,
- environ = {'USER_AT_HOST': user_at_host, 'CONFIG': 'opt'},
- timeout_seconds=build_timeout))
- if build_local:
- # Build locally as well
- build_jobs.append(
- jobset.JobSpec(
- cmdline=['tools/run_tests/performance/build_performance.sh'] + languages,
- shortname='local_build',
- environ = {'CONFIG': 'opt'},
- timeout_seconds=build_timeout))
- jobset.message('START', 'Building.', do_newline=True)
- num_failures, _ = jobset.run(
- build_jobs, newline_on_success=True, maxjobs=10)
- if num_failures == 0:
- jobset.message('SUCCESS',
- 'Built successfully.',
- do_newline=True)
- else:
- jobset.message('FAILED', 'Build failed.',
- do_newline=True)
- sys.exit(1)
+ """Prepares remote hosts (and maybe prepare localhost as well)."""
+ prepare_timeout = 10 * 60
+ prepare_jobs = []
+ for host in hosts:
+ user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
+ prepare_jobs.append(
+ jobset.JobSpec(
+ cmdline=['tools/run_tests/performance/remote_host_prepare.sh'],
+ shortname='remote_host_prepare.%s' % host,
+ environ={'USER_AT_HOST': user_at_host},
+ timeout_seconds=prepare_timeout))
+ if prepare_local:
+ # Prepare localhost as well
+ prepare_jobs.append(
+ jobset.JobSpec(
+ cmdline=['tools/run_tests/performance/kill_workers.sh'],
+ shortname='local_prepare',
+ timeout_seconds=prepare_timeout))
+ jobset.message('START', 'Preparing hosts.', do_newline=True)
+ num_failures, _ = jobset.run(
+ prepare_jobs, newline_on_success=True, maxjobs=10)
+ if num_failures == 0:
+ jobset.message(
+ 'SUCCESS', 'Prepare step completed successfully.', do_newline=True)
+ else:
+ jobset.message(
+ 'FAILED', 'Failed to prepare remote hosts.', do_newline=True)
+ sys.exit(1)
+
+
+def build_on_remote_hosts(hosts,
+ languages=scenario_config.LANGUAGES.keys(),
+ build_local=False):
+ """Builds performance worker on remote hosts (and maybe also locally)."""
+ build_timeout = 15 * 60
+ # Kokoro VMs (which are local only) do not have caching, so they need more time to build
+ local_build_timeout = 30 * 60
+ build_jobs = []
+ for host in hosts:
+ user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
+ build_jobs.append(
+ jobset.JobSpec(
+ cmdline=['tools/run_tests/performance/remote_host_build.sh'] +
+ languages,
+ shortname='remote_host_build.%s' % host,
+ environ={'USER_AT_HOST': user_at_host,
+ 'CONFIG': 'opt'},
+ timeout_seconds=build_timeout))
+ if build_local:
+ # Build locally as well
+ build_jobs.append(
+ jobset.JobSpec(
+ cmdline=['tools/run_tests/performance/build_performance.sh'] +
+ languages,
+ shortname='local_build',
+ environ={'CONFIG': 'opt'},
+ timeout_seconds=local_build_timeout))
+ jobset.message('START', 'Building.', do_newline=True)
+ num_failures, _ = jobset.run(
+ build_jobs, newline_on_success=True, maxjobs=10)
+ if num_failures == 0:
+ jobset.message('SUCCESS', 'Built successfully.', do_newline=True)
+ else:
+ jobset.message('FAILED', 'Build failed.', do_newline=True)
+ sys.exit(1)
def create_qpsworkers(languages, worker_hosts, perf_cmd=None):
- """Creates QPS workers (but does not start them)."""
- if not worker_hosts:
- # run two workers locally (for each language)
- workers=[(None, 10000), (None, 10010)]
- elif len(worker_hosts) == 1:
- # run two workers on the remote host (for each language)
- workers=[(worker_hosts[0], 10000), (worker_hosts[0], 10010)]
- else:
- # run one worker per each remote host (for each language)
- workers=[(worker_host, 10000) for worker_host in worker_hosts]
-
- return [create_qpsworker_job(language,
- shortname= 'qps_worker_%s_%s' % (language,
- worker_idx),
- port=worker[1] + language.worker_port_offset(),
- remote_host=worker[0],
- perf_cmd=perf_cmd)
- for language in languages
- for worker_idx, worker in enumerate(workers)]
-
-
-def perf_report_processor_job(worker_host, perf_base_name, output_filename, flame_graph_reports):
- print('Creating perf report collection job for %s' % worker_host)
- cmd = ''
- if worker_host != 'localhost':
- user_at_host = "%s@%s" % (_REMOTE_HOST_USERNAME, worker_host)
- cmd = "USER_AT_HOST=%s OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%s\
- tools/run_tests/performance/process_remote_perf_flamegraphs.sh" \
- % (user_at_host, output_filename, flame_graph_reports, perf_base_name)
- else:
- cmd = "OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%s\
- tools/run_tests/performance/process_local_perf_flamegraphs.sh" \
- % (output_filename, flame_graph_reports, perf_base_name)
-
- return jobset.JobSpec(cmdline=cmd,
- timeout_seconds=3*60,
- shell=True,
- verbose_success=True,
- shortname='process perf report')
+ """Creates QPS workers (but does not start them)."""
+ if not worker_hosts:
+ # run two workers locally (for each language)
+ workers = [(None, 10000), (None, 10010)]
+ elif len(worker_hosts) == 1:
+ # run two workers on the remote host (for each language)
+ workers = [(worker_hosts[0], 10000), (worker_hosts[0], 10010)]
+ else:
+ # run one worker per each remote host (for each language)
+ workers = [(worker_host, 10000) for worker_host in worker_hosts]
+
+ return [
+ create_qpsworker_job(
+ language,
+ shortname='qps_worker_%s_%s' % (language, worker_idx),
+ port=worker[1] + language.worker_port_offset(),
+ remote_host=worker[0],
+ perf_cmd=perf_cmd)
+ for language in languages
+ for worker_idx, worker in enumerate(workers)
+ ]
+
+
+def perf_report_processor_job(worker_host, perf_base_name, output_filename,
+ flame_graph_reports):
+ print('Creating perf report collection job for %s' % worker_host)
+ cmd = ''
+ if worker_host != 'localhost':
+ user_at_host = "%s@%s" % (_REMOTE_HOST_USERNAME, worker_host)
+ cmd = "USER_AT_HOST=%s OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%stools/run_tests/performance/process_remote_perf_flamegraphs.sh" % (
+ user_at_host, output_filename, flame_graph_reports, perf_base_name)
+ else:
+ cmd = "OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%stools/run_tests/performance/process_local_perf_flamegraphs.sh" % (
+ output_filename, flame_graph_reports, perf_base_name)
+
+ return jobset.JobSpec(
+ cmdline=cmd,
+ timeout_seconds=3 * 60,
+ shell=True,
+ verbose_success=True,
+ shortname='process perf report')
Scenario = collections.namedtuple('Scenario', 'jobspec workers name')
-def create_scenarios(languages, workers_by_lang, remote_host=None, regex='.*',
- category='all', bq_result_table=None,
- netperf=False, netperf_hosts=[], server_cpu_load=0):
- """Create jobspecs for scenarios to run."""
- all_workers = [worker
- for workers in workers_by_lang.values()
- for worker in workers]
- scenarios = []
- _NO_WORKERS = []
-
- if netperf:
- if not netperf_hosts:
- netperf_server='localhost'
- netperf_client=None
- elif len(netperf_hosts) == 1:
- netperf_server=netperf_hosts[0]
- netperf_client=netperf_hosts[0]
- else:
- netperf_server=netperf_hosts[0]
- netperf_client=netperf_hosts[1]
- scenarios.append(Scenario(
- create_netperf_jobspec(server_host=netperf_server,
- client_host=netperf_client,
- bq_result_table=bq_result_table),
- _NO_WORKERS, 'netperf'))
-
- for language in languages:
- for scenario_json in language.scenarios():
- if re.search(regex, scenario_json['name']):
- categories = scenario_json.get('CATEGORIES', ['scalable', 'smoketest'])
- if category in categories or category == 'all':
- workers = workers_by_lang[str(language)][:]
- # 'SERVER_LANGUAGE' is an indicator for this script to pick
- # a server in different language.
- custom_server_lang = scenario_json.get('SERVER_LANGUAGE', None)
- custom_client_lang = scenario_json.get('CLIENT_LANGUAGE', None)
- scenario_json = scenario_config.remove_nonproto_fields(scenario_json)
- if custom_server_lang and custom_client_lang:
- raise Exception('Cannot set both custom CLIENT_LANGUAGE and SERVER_LANGUAGE'
+def create_scenarios(languages,
+ workers_by_lang,
+ remote_host=None,
+ regex='.*',
+ category='all',
+ bq_result_table=None,
+ netperf=False,
+ netperf_hosts=[],
+ server_cpu_load=0):
+ """Create jobspecs for scenarios to run."""
+ all_workers = [
+ worker for workers in workers_by_lang.values() for worker in workers
+ ]
+ scenarios = []
+ _NO_WORKERS = []
+
+ if netperf:
+ if not netperf_hosts:
+ netperf_server = 'localhost'
+ netperf_client = None
+ elif len(netperf_hosts) == 1:
+ netperf_server = netperf_hosts[0]
+ netperf_client = netperf_hosts[0]
+ else:
+ netperf_server = netperf_hosts[0]
+ netperf_client = netperf_hosts[1]
+ scenarios.append(
+ Scenario(
+ create_netperf_jobspec(
+ server_host=netperf_server,
+ client_host=netperf_client,
+ bq_result_table=bq_result_table), _NO_WORKERS, 'netperf'))
+
+ for language in languages:
+ for scenario_json in language.scenarios():
+ if re.search(regex, scenario_json['name']):
+ categories = scenario_json.get('CATEGORIES',
+ ['scalable', 'smoketest'])
+ if category in categories or category == 'all':
+ workers = workers_by_lang[str(language)][:]
+ # 'SERVER_LANGUAGE' is an indicator for this script to pick
+ # a server in different language.
+ custom_server_lang = scenario_json.get(
+ 'SERVER_LANGUAGE', None)
+ custom_client_lang = scenario_json.get(
+ 'CLIENT_LANGUAGE', None)
+ scenario_json = scenario_config.remove_nonproto_fields(
+ scenario_json)
+ if custom_server_lang and custom_client_lang:
+ raise Exception(
+ 'Cannot set both custom CLIENT_LANGUAGE and SERVER_LANGUAGE'
'in the same scenario')
- if custom_server_lang:
- if not workers_by_lang.get(custom_server_lang, []):
- print('Warning: Skipping scenario %s as' % scenario_json['name'])
- print('SERVER_LANGUAGE is set to %s yet the language has '
- 'not been selected with -l' % custom_server_lang)
- continue
- for idx in range(0, scenario_json['num_servers']):
- # replace first X workers by workers of a different language
- workers[idx] = workers_by_lang[custom_server_lang][idx]
- if custom_client_lang:
- if not workers_by_lang.get(custom_client_lang, []):
- print('Warning: Skipping scenario %s as' % scenario_json['name'])
- print('CLIENT_LANGUAGE is set to %s yet the language has '
- 'not been selected with -l' % custom_client_lang)
- continue
- for idx in range(scenario_json['num_servers'], len(workers)):
- # replace all client workers by workers of a different language,
- # leave num_server workers as they are server workers.
- workers[idx] = workers_by_lang[custom_client_lang][idx]
- scenario = Scenario(
- create_scenario_jobspec(scenario_json,
- [w.host_and_port for w in workers],
- remote_host=remote_host,
- bq_result_table=bq_result_table,
- server_cpu_load=server_cpu_load),
- workers,
- scenario_json['name'])
- scenarios.append(scenario)
-
- return scenarios
+ if custom_server_lang:
+ if not workers_by_lang.get(custom_server_lang, []):
+ print('Warning: Skipping scenario %s as' %
+ scenario_json['name'])
+ print(
+ 'SERVER_LANGUAGE is set to %s yet the language has '
+ 'not been selected with -l' %
+ custom_server_lang)
+ continue
+ for idx in range(0, scenario_json['num_servers']):
+ # replace first X workers by workers of a different language
+ workers[idx] = workers_by_lang[custom_server_lang][
+ idx]
+ if custom_client_lang:
+ if not workers_by_lang.get(custom_client_lang, []):
+ print('Warning: Skipping scenario %s as' %
+ scenario_json['name'])
+ print(
+ 'CLIENT_LANGUAGE is set to %s yet the language has '
+ 'not been selected with -l' %
+ custom_client_lang)
+ continue
+ for idx in range(scenario_json['num_servers'],
+ len(workers)):
+ # replace all client workers by workers of a different language,
+ # leave num_server workers as they are server workers.
+ workers[idx] = workers_by_lang[custom_client_lang][
+ idx]
+ scenario = Scenario(
+ create_scenario_jobspec(
+ scenario_json, [w.host_and_port for w in workers],
+ remote_host=remote_host,
+ bq_result_table=bq_result_table,
+ server_cpu_load=server_cpu_load), workers,
+ scenario_json['name'])
+ scenarios.append(scenario)
+
+ return scenarios
def finish_qps_workers(jobs, qpsworker_jobs):
- """Waits for given jobs to finish and eventually kills them."""
- retries = 0
- num_killed = 0
- while any(job.is_running() for job in jobs):
- for job in qpsworker_jobs:
- if job.is_running():
- print('QPS worker "%s" is still running.' % job.host_and_port)
- if retries > 10:
- print('Killing all QPS workers.')
- for job in jobs:
- job.kill()
- num_killed += 1
- retries += 1
- time.sleep(3)
- print('All QPS workers finished.')
- return num_killed
+ """Waits for given jobs to finish and eventually kills them."""
+ retries = 0
+ num_killed = 0
+ while any(job.is_running() for job in jobs):
+ for job in qpsworker_jobs:
+ if job.is_running():
+ print('QPS worker "%s" is still running.' % job.host_and_port)
+ if retries > 10:
+ print('Killing all QPS workers.')
+ for job in jobs:
+ job.kill()
+ num_killed += 1
+ retries += 1
+ time.sleep(3)
+ print('All QPS workers finished.')
+ return num_killed
+
profile_output_files = []
+
# Collect perf text reports and flamegraphs if perf_cmd was used
# Note the base names of perf text reports are used when creating and processing
# perf data. The scenario name uniqifies the output name in the final
# perf reports directory.
# Alos, the perf profiles need to be fetched and processed after each scenario
# in order to avoid clobbering the output files.
-def run_collect_perf_profile_jobs(hosts_and_base_names, scenario_name, flame_graph_reports):
- perf_report_jobs = []
- global profile_output_files
- for host_and_port in hosts_and_base_names:
- perf_base_name = hosts_and_base_names[host_and_port]
- output_filename = '%s-%s' % (scenario_name, perf_base_name)
- # from the base filename, create .svg output filename
- host = host_and_port.split(':')[0]
- profile_output_files.append('%s.svg' % output_filename)
- perf_report_jobs.append(perf_report_processor_job(host, perf_base_name, output_filename, flame_graph_reports))
-
- jobset.message('START', 'Collecting perf reports from qps workers', do_newline=True)
- failures, _ = jobset.run(perf_report_jobs, newline_on_success=True, maxjobs=1)
- jobset.message('END', 'Collecting perf reports from qps workers', do_newline=True)
- return failures
+def run_collect_perf_profile_jobs(hosts_and_base_names, scenario_name,
+ flame_graph_reports):
+ perf_report_jobs = []
+ global profile_output_files
+ for host_and_port in hosts_and_base_names:
+ perf_base_name = hosts_and_base_names[host_and_port]
+ output_filename = '%s-%s' % (scenario_name, perf_base_name)
+ # from the base filename, create .svg output filename
+ host = host_and_port.split(':')[0]
+ profile_output_files.append('%s.svg' % output_filename)
+ perf_report_jobs.append(
+ perf_report_processor_job(host, perf_base_name, output_filename,
+ flame_graph_reports))
+
+ jobset.message(
+ 'START', 'Collecting perf reports from qps workers', do_newline=True)
+ failures, _ = jobset.run(
+ perf_report_jobs, newline_on_success=True, maxjobs=1)
+ jobset.message(
+ 'END', 'Collecting perf reports from qps workers', do_newline=True)
+ return failures
+
def main():
- argp = argparse.ArgumentParser(description='Run performance tests.')
- argp.add_argument('-l', '--language',
- choices=['all'] + sorted(scenario_config.LANGUAGES.keys()),
- nargs='+',
- required=True,
- help='Languages to benchmark.')
- argp.add_argument('--remote_driver_host',
- default=None,
- help='Run QPS driver on given host. By default, QPS driver is run locally.')
- argp.add_argument('--remote_worker_host',
- nargs='+',
- default=[],
- help='Worker hosts where to start QPS workers.')
- argp.add_argument('--dry_run',
- default=False,
- action='store_const',
- const=True,
- help='Just list scenarios to be run, but don\'t run them.')
- argp.add_argument('-r', '--regex', default='.*', type=str,
- help='Regex to select scenarios to run.')
- argp.add_argument('--bq_result_table', default=None, type=str,
- help='Bigquery "dataset.table" to upload results to.')
- argp.add_argument('--category',
- choices=['smoketest','all','scalable','sweep'],
- default='all',
- help='Select a category of tests to run.')
- argp.add_argument('--netperf',
- default=False,
- action='store_const',
- const=True,
- help='Run netperf benchmark as one of the scenarios.')
- argp.add_argument('--server_cpu_load',
- default=0, type=int,
- help='Select a targeted server cpu load to run. 0 means ignore this flag')
- argp.add_argument('-x', '--xml_report', default='report.xml', type=str,
- help='Name of XML report file to generate.')
- argp.add_argument('--perf_args',
- help=('Example usage: "--perf_args=record -F 99 -g". '
- 'Wrap QPS workers in a perf command '
- 'with the arguments to perf specified here. '
- '".svg" flame graph profiles will be '
- 'created for each Qps Worker on each scenario. '
- 'Files will output to "<repo_root>/<args.flame_graph_reports>" '
- 'directory. Output files from running the worker '
- 'under perf are saved in the repo root where its ran. '
- 'Note that the perf "-g" flag is necessary for '
- 'flame graphs generation to work (assuming the binary '
- 'being profiled uses frame pointers, check out '
- '"--call-graph dwarf" option using libunwind otherwise.) '
- 'Also note that the entire "--perf_args=<arg(s)>" must '
- 'be wrapped in quotes as in the example usage. '
- 'If the "--perg_args" is unspecified, "perf" will '
- 'not be used at all. '
- 'See http://www.brendangregg.com/perf.html '
- 'for more general perf examples.'))
- argp.add_argument('--skip_generate_flamegraphs',
- default=False,
- action='store_const',
- const=True,
- help=('Turn flame graph generation off. '
- 'May be useful if "perf_args" arguments do not make sense for '
- 'generating flamegraphs (e.g., "--perf_args=stat ...")'))
- argp.add_argument('-f', '--flame_graph_reports', default='perf_reports', type=str,
- help='Name of directory to output flame graph profiles to, if any are created.')
-
- args = argp.parse_args()
-
- languages = set(scenario_config.LANGUAGES[l]
- for l in itertools.chain.from_iterable(
- six.iterkeys(scenario_config.LANGUAGES) if x == 'all'
- else [x] for x in args.language))
-
-
- # Put together set of remote hosts where to run and build
- remote_hosts = set()
- if args.remote_worker_host:
- for host in args.remote_worker_host:
- remote_hosts.add(host)
- if args.remote_driver_host:
- remote_hosts.add(args.remote_driver_host)
-
- if not args.dry_run:
- if remote_hosts:
- archive_repo(languages=[str(l) for l in languages])
- prepare_remote_hosts(remote_hosts, prepare_local=True)
- else:
- prepare_remote_hosts([], prepare_local=True)
-
- build_local = False
- if not args.remote_driver_host:
- build_local = True
- if not args.dry_run:
- build_on_remote_hosts(remote_hosts, languages=[str(l) for l in languages], build_local=build_local)
-
- perf_cmd = None
- if args.perf_args:
- print('Running workers under perf profiler')
- # Expect /usr/bin/perf to be installed here, as is usual
- perf_cmd = ['/usr/bin/perf']
- perf_cmd.extend(re.split('\s+', args.perf_args))
-
- qpsworker_jobs = create_qpsworkers(languages, args.remote_worker_host, perf_cmd=perf_cmd)
-
- # get list of worker addresses for each language.
- workers_by_lang = dict([(str(language), []) for language in languages])
- for job in qpsworker_jobs:
- workers_by_lang[str(job.language)].append(job)
-
- scenarios = create_scenarios(languages,
- workers_by_lang=workers_by_lang,
- remote_host=args.remote_driver_host,
- regex=args.regex,
- category=args.category,
- bq_result_table=args.bq_result_table,
- netperf=args.netperf,
- netperf_hosts=args.remote_worker_host,
- server_cpu_load=args.server_cpu_load)
-
- if not scenarios:
- raise Exception('No scenarios to run')
-
- total_scenario_failures = 0
- qps_workers_killed = 0
- merged_resultset = {}
- perf_report_failures = 0
-
- for scenario in scenarios:
- if args.dry_run:
- print(scenario.name)
- else:
- scenario_failures = 0
- try:
- for worker in scenario.workers:
- worker.start()
- jobs = [scenario.jobspec]
- if scenario.workers:
- jobs.append(create_quit_jobspec(scenario.workers, remote_host=args.remote_driver_host))
- scenario_failures, resultset = jobset.run(jobs, newline_on_success=True, maxjobs=1)
- total_scenario_failures += scenario_failures
- merged_resultset = dict(itertools.chain(six.iteritems(merged_resultset),
- six.iteritems(resultset)))
- finally:
- # Consider qps workers that need to be killed as failures
- qps_workers_killed += finish_qps_workers(scenario.workers, qpsworker_jobs)
-
- if perf_cmd and scenario_failures == 0 and not args.skip_generate_flamegraphs:
- workers_and_base_names = {}
- for worker in scenario.workers:
- if not worker.perf_file_base_name:
- raise Exception('using perf buf perf report filename is unspecified')
- workers_and_base_names[worker.host_and_port] = worker.perf_file_base_name
- perf_report_failures += run_collect_perf_profile_jobs(workers_and_base_names, scenario.name, args.flame_graph_reports)
-
-
- # Still write the index.html even if some scenarios failed.
- # 'profile_output_files' will only have names for scenarios that passed
- if perf_cmd and not args.skip_generate_flamegraphs:
- # write the index fil to the output dir, with all profiles from all scenarios/workers
- report_utils.render_perf_profiling_results('%s/index.html' % args.flame_graph_reports, profile_output_files)
-
- report_utils.render_junit_xml_report(merged_resultset, args.xml_report,
- suite_name='benchmarks')
-
- if total_scenario_failures > 0 or qps_workers_killed > 0:
- print('%s scenarios failed and %s qps worker jobs killed' % (total_scenario_failures, qps_workers_killed))
- sys.exit(1)
-
- if perf_report_failures > 0:
- print('%s perf profile collection jobs failed' % perf_report_failures)
- sys.exit(1)
+ argp = argparse.ArgumentParser(description='Run performance tests.')
+ argp.add_argument(
+ '-l',
+ '--language',
+ choices=['all'] + sorted(scenario_config.LANGUAGES.keys()),
+ nargs='+',
+ required=True,
+ help='Languages to benchmark.')
+ argp.add_argument(
+ '--remote_driver_host',
+ default=None,
+ help=
+ 'Run QPS driver on given host. By default, QPS driver is run locally.')
+ argp.add_argument(
+ '--remote_worker_host',
+ nargs='+',
+ default=[],
+ help='Worker hosts where to start QPS workers.')
+ argp.add_argument(
+ '--dry_run',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Just list scenarios to be run, but don\'t run them.')
+ argp.add_argument(
+ '-r',
+ '--regex',
+ default='.*',
+ type=str,
+ help='Regex to select scenarios to run.')
+ argp.add_argument(
+ '--bq_result_table',
+ default=None,
+ type=str,
+ help='Bigquery "dataset.table" to upload results to.')
+ argp.add_argument(
+ '--category',
+ choices=['smoketest', 'all', 'scalable', 'sweep'],
+ default='all',
+ help='Select a category of tests to run.')
+ argp.add_argument(
+ '--netperf',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run netperf benchmark as one of the scenarios.')
+ argp.add_argument(
+ '--server_cpu_load',
+ default=0,
+ type=int,
+ help='Select a targeted server cpu load to run. 0 means ignore this flag'
+ )
+ argp.add_argument(
+ '-x',
+ '--xml_report',
+ default='report.xml',
+ type=str,
+ help='Name of XML report file to generate.')
+ argp.add_argument(
+ '--perf_args',
+ help=('Example usage: "--perf_args=record -F 99 -g". '
+ 'Wrap QPS workers in a perf command '
+ 'with the arguments to perf specified here. '
+ '".svg" flame graph profiles will be '
+ 'created for each Qps Worker on each scenario. '
+ 'Files will output to "<repo_root>/<args.flame_graph_reports>" '
+ 'directory. Output files from running the worker '
+ 'under perf are saved in the repo root where its ran. '
+ 'Note that the perf "-g" flag is necessary for '
+ 'flame graphs generation to work (assuming the binary '
+ 'being profiled uses frame pointers, check out '
+ '"--call-graph dwarf" option using libunwind otherwise.) '
+ 'Also note that the entire "--perf_args=<arg(s)>" must '
+ 'be wrapped in quotes as in the example usage. '
+ 'If the "--perg_args" is unspecified, "perf" will '
+ 'not be used at all. '
+ 'See http://www.brendangregg.com/perf.html '
+ 'for more general perf examples.'))
+ argp.add_argument(
+ '--skip_generate_flamegraphs',
+ default=False,
+ action='store_const',
+ const=True,
+ help=('Turn flame graph generation off. '
+ 'May be useful if "perf_args" arguments do not make sense for '
+ 'generating flamegraphs (e.g., "--perf_args=stat ...")'))
+ argp.add_argument(
+ '-f',
+ '--flame_graph_reports',
+ default='perf_reports',
+ type=str,
+ help=
+ 'Name of directory to output flame graph profiles to, if any are created.'
+ )
+ argp.add_argument(
+ '-u',
+ '--remote_host_username',
+ default='',
+ type=str,
+ help='Use a username that isn\'t "Jenkins" to SSH into remote workers.')
+
+ args = argp.parse_args()
+
+ global _REMOTE_HOST_USERNAME
+ if args.remote_host_username:
+ _REMOTE_HOST_USERNAME = args.remote_host_username
+
+ languages = set(
+ scenario_config.LANGUAGES[l]
+ for l in itertools.chain.from_iterable(
+ six.iterkeys(scenario_config.LANGUAGES) if x == 'all' else [x]
+ for x in args.language))
+
+ # Put together set of remote hosts where to run and build
+ remote_hosts = set()
+ if args.remote_worker_host:
+ for host in args.remote_worker_host:
+ remote_hosts.add(host)
+ if args.remote_driver_host:
+ remote_hosts.add(args.remote_driver_host)
+
+ if not args.dry_run:
+ if remote_hosts:
+ archive_repo(languages=[str(l) for l in languages])
+ prepare_remote_hosts(remote_hosts, prepare_local=True)
+ else:
+ prepare_remote_hosts([], prepare_local=True)
+
+ build_local = False
+ if not args.remote_driver_host:
+ build_local = True
+ if not args.dry_run:
+ build_on_remote_hosts(
+ remote_hosts,
+ languages=[str(l) for l in languages],
+ build_local=build_local)
+
+ perf_cmd = None
+ if args.perf_args:
+ print('Running workers under perf profiler')
+ # Expect /usr/bin/perf to be installed here, as is usual
+ perf_cmd = ['/usr/bin/perf']
+ perf_cmd.extend(re.split('\s+', args.perf_args))
+
+ qpsworker_jobs = create_qpsworkers(
+ languages, args.remote_worker_host, perf_cmd=perf_cmd)
+
+ # get list of worker addresses for each language.
+ workers_by_lang = dict([(str(language), []) for language in languages])
+ for job in qpsworker_jobs:
+ workers_by_lang[str(job.language)].append(job)
+
+ scenarios = create_scenarios(
+ languages,
+ workers_by_lang=workers_by_lang,
+ remote_host=args.remote_driver_host,
+ regex=args.regex,
+ category=args.category,
+ bq_result_table=args.bq_result_table,
+ netperf=args.netperf,
+ netperf_hosts=args.remote_worker_host,
+ server_cpu_load=args.server_cpu_load)
+
+ if not scenarios:
+ raise Exception('No scenarios to run')
+
+ total_scenario_failures = 0
+ qps_workers_killed = 0
+ merged_resultset = {}
+ perf_report_failures = 0
+
+ for scenario in scenarios:
+ if args.dry_run:
+ print(scenario.name)
+ else:
+ scenario_failures = 0
+ try:
+ for worker in scenario.workers:
+ worker.start()
+ jobs = [scenario.jobspec]
+ if scenario.workers:
+ jobs.append(
+ create_quit_jobspec(
+ scenario.workers,
+ remote_host=args.remote_driver_host))
+ scenario_failures, resultset = jobset.run(
+ jobs, newline_on_success=True, maxjobs=1)
+ total_scenario_failures += scenario_failures
+ merged_resultset = dict(
+ itertools.chain(
+ six.iteritems(merged_resultset),
+ six.iteritems(resultset)))
+ finally:
+ # Consider qps workers that need to be killed as failures
+ qps_workers_killed += finish_qps_workers(
+ scenario.workers, qpsworker_jobs)
+
+ if perf_cmd and scenario_failures == 0 and not args.skip_generate_flamegraphs:
+ workers_and_base_names = {}
+ for worker in scenario.workers:
+ if not worker.perf_file_base_name:
+ raise Exception(
+ 'using perf buf perf report filename is unspecified'
+ )
+ workers_and_base_names[
+ worker.host_and_port] = worker.perf_file_base_name
+ perf_report_failures += run_collect_perf_profile_jobs(
+ workers_and_base_names, scenario.name,
+ args.flame_graph_reports)
+
+ # Still write the index.html even if some scenarios failed.
+ # 'profile_output_files' will only have names for scenarios that passed
+ if perf_cmd and not args.skip_generate_flamegraphs:
+ # write the index fil to the output dir, with all profiles from all scenarios/workers
+ report_utils.render_perf_profiling_results(
+ '%s/index.html' % args.flame_graph_reports, profile_output_files)
+
+ report_utils.render_junit_xml_report(
+ merged_resultset, args.xml_report, suite_name='benchmarks')
+
+ if total_scenario_failures > 0 or qps_workers_killed > 0:
+ print('%s scenarios failed and %s qps worker jobs killed' %
+ (total_scenario_failures, qps_workers_killed))
+ sys.exit(1)
+
+ if perf_report_failures > 0:
+ print('%s perf profile collection jobs failed' % perf_report_failures)
+ sys.exit(1)
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index b38108d456..b751bf9714 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -12,7 +12,6 @@
# 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.
-
"""Run tests in parallel."""
from __future__ import print_function
@@ -46,37 +45,34 @@ import python_utils.report_utils as report_utils
import python_utils.watch_dirs as watch_dirs
import python_utils.start_port_server as start_port_server
try:
- from python_utils.upload_test_results import upload_results_to_bq
+ from python_utils.upload_test_results import upload_results_to_bq
except (ImportError):
- pass # It's ok to not import because this is only necessary to upload results to BQ.
+ pass # It's ok to not import because this is only necessary to upload results to BQ.
-gcp_utils_dir = os.path.abspath(os.path.join(
- os.path.dirname(__file__), '../gcp/utils'))
+gcp_utils_dir = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '../gcp/utils'))
sys.path.append(gcp_utils_dir)
_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
os.chdir(_ROOT)
-
_FORCE_ENVIRON_FOR_WRAPPERS = {
- 'GRPC_VERBOSITY': 'DEBUG',
+ 'GRPC_VERBOSITY': 'DEBUG',
}
_POLLING_STRATEGIES = {
- 'linux': ['epollsig', 'epoll1', 'poll', 'poll-cv'],
-# TODO(ctiller, sreecha): enable epollex, epoll-thread-pool
- 'mac': ['poll'],
+ 'linux': ['epollex', 'epollsig', 'epoll1', 'poll', 'poll-cv'],
+ 'mac': ['poll'],
}
-
BigQueryTestData = collections.namedtuple('BigQueryTestData', 'name flaky cpu')
def get_bqtest_data(limit=None):
- import big_query_utils
+ import big_query_utils
- bq = big_query_utils.create_big_query()
- query = """
+ bq = big_query_utils.create_big_query()
+ query = """
SELECT
filtered_test_name,
SUM(result != 'PASSED' AND result != 'SKIPPED') > 0 as flaky,
@@ -89,1042 +85,1153 @@ SELECT
[grpc-testing:jenkins_test_results.aggregate_results]
WHERE
timestamp >= DATE_ADD(CURRENT_DATE(), -1, "WEEK")
- AND platform = '"""+platform_string()+"""'
+ AND platform = '""" + platform_string() + """'
AND NOT REGEXP_MATCH(job_name, '.*portability.*') )
GROUP BY
filtered_test_name"""
- if limit:
- query += " limit {}".format(limit)
- query_job = big_query_utils.sync_query_job(bq, 'grpc-testing', query)
- page = bq.jobs().getQueryResults(
- pageToken=None,
- **query_job['jobReference']).execute(num_retries=3)
- test_data = [BigQueryTestData(row['f'][0]['v'], row['f'][1]['v'] == 'true', float(row['f'][2]['v'])) for row in page['rows']]
- return test_data
+ if limit:
+ query += " limit {}".format(limit)
+ query_job = big_query_utils.sync_query_job(bq, 'grpc-testing', query)
+ page = bq.jobs().getQueryResults(
+ pageToken=None, **query_job['jobReference']).execute(num_retries=3)
+ test_data = [
+ BigQueryTestData(row['f'][0]['v'], row['f'][1]['v'] == 'true',
+ float(row['f'][2]['v'])) for row in page['rows']
+ ]
+ return test_data
def platform_string():
- return jobset.platform_string()
+ return jobset.platform_string()
_DEFAULT_TIMEOUT_SECONDS = 5 * 60
+
def run_shell_command(cmd, env=None, cwd=None):
- try:
- subprocess.check_output(cmd, shell=True, env=env, cwd=cwd)
- except subprocess.CalledProcessError as e:
- logging.exception("Error while running command '%s'. Exit status %d. Output:\n%s",
- e.cmd, e.returncode, e.output)
- raise
+ try:
+ subprocess.check_output(cmd, shell=True, env=env, cwd=cwd)
+ except subprocess.CalledProcessError as e:
+ logging.exception(
+ "Error while running command '%s'. Exit status %d. Output:\n%s",
+ e.cmd, e.returncode, e.output)
+ raise
+
+
+def max_parallel_tests_for_current_platform():
+ # Too much test parallelization has only been seen to be a problem
+ # so far on windows.
+ if jobset.platform_string() == 'windows':
+ return 64
+ return 1024
+
# SimpleConfig: just compile with CONFIG=config, and run the binary to test
class Config(object):
- def __init__(self, config, environ=None, timeout_multiplier=1, tool_prefix=[], iomgr_platform='native'):
- if environ is None:
- environ = {}
- self.build_config = config
- self.environ = environ
- self.environ['CONFIG'] = config
- self.tool_prefix = tool_prefix
- self.timeout_multiplier = timeout_multiplier
- self.iomgr_platform = iomgr_platform
-
- def job_spec(self, cmdline, timeout_seconds=_DEFAULT_TIMEOUT_SECONDS,
- shortname=None, environ={}, cpu_cost=1.0, flaky=False):
- """Construct a jobset.JobSpec for a test under this config
+ def __init__(self,
+ config,
+ environ=None,
+ timeout_multiplier=1,
+ tool_prefix=[],
+ iomgr_platform='native'):
+ if environ is None:
+ environ = {}
+ self.build_config = config
+ self.environ = environ
+ self.environ['CONFIG'] = config
+ self.tool_prefix = tool_prefix
+ self.timeout_multiplier = timeout_multiplier
+ self.iomgr_platform = iomgr_platform
+
+ def job_spec(self,
+ cmdline,
+ timeout_seconds=_DEFAULT_TIMEOUT_SECONDS,
+ shortname=None,
+ environ={},
+ cpu_cost=1.0,
+ flaky=False):
+ """Construct a jobset.JobSpec for a test under this config
Args:
cmdline: a list of strings specifying the command line the test
would like to run
"""
- actual_environ = self.environ.copy()
- for k, v in environ.items():
- actual_environ[k] = v
- if not flaky and shortname and shortname in flaky_tests:
- print('Setting %s to flaky' % shortname)
- flaky = True
- if shortname in shortname_to_cpu:
- print('Update CPU cost for %s: %f -> %f' % (shortname, cpu_cost, shortname_to_cpu[shortname]))
- cpu_cost = shortname_to_cpu[shortname]
- return jobset.JobSpec(cmdline=self.tool_prefix + cmdline,
- shortname=shortname,
- environ=actual_environ,
- cpu_cost=cpu_cost,
- timeout_seconds=(self.timeout_multiplier * timeout_seconds if timeout_seconds else None),
- flake_retries=5 if flaky or args.allow_flakes else 0,
- timeout_retries=3 if flaky or args.allow_flakes else 0)
-
-
-def get_c_tests(travis, test_lang) :
- out = []
- platforms_str = 'ci_platforms' if travis else 'platforms'
- with open('tools/run_tests/generated/tests.json') as f:
- js = json.load(f)
- return [tgt
- for tgt in js
- if tgt['language'] == test_lang and
- platform_string() in tgt[platforms_str] and
- not (travis and tgt['flaky'])]
+ actual_environ = self.environ.copy()
+ for k, v in environ.items():
+ actual_environ[k] = v
+ if not flaky and shortname and shortname in flaky_tests:
+ flaky = True
+ if shortname in shortname_to_cpu:
+ cpu_cost = shortname_to_cpu[shortname]
+ return jobset.JobSpec(
+ cmdline=self.tool_prefix + cmdline,
+ shortname=shortname,
+ environ=actual_environ,
+ cpu_cost=cpu_cost,
+ timeout_seconds=(self.timeout_multiplier * timeout_seconds
+ if timeout_seconds else None),
+ flake_retries=4 if flaky or args.allow_flakes else 0,
+ timeout_retries=1 if flaky or args.allow_flakes else 0)
+
+
+def get_c_tests(travis, test_lang):
+ out = []
+ platforms_str = 'ci_platforms' if travis else 'platforms'
+ with open('tools/run_tests/generated/tests.json') as f:
+ js = json.load(f)
+ return [
+ tgt for tgt in js
+ if tgt['language'] == test_lang and platform_string() in
+ tgt[platforms_str] and not (travis and tgt['flaky'])
+ ]
def _check_compiler(compiler, supported_compilers):
- if compiler not in supported_compilers:
- raise Exception('Compiler %s not supported (on this platform).' % compiler)
+ if compiler not in supported_compilers:
+ raise Exception(
+ 'Compiler %s not supported (on this platform).' % compiler)
def _check_arch(arch, supported_archs):
- if arch not in supported_archs:
- raise Exception('Architecture %s not supported.' % arch)
+ if arch not in supported_archs:
+ raise Exception('Architecture %s not supported.' % arch)
def _is_use_docker_child():
- """Returns True if running running as a --use_docker child."""
- return True if os.getenv('RUN_TESTS_COMMAND') else False
+ """Returns True if running running as a --use_docker child."""
+ return True if os.getenv('RUN_TESTS_COMMAND') else False
-_PythonConfigVars = collections.namedtuple(
- '_ConfigVars', ['shell', 'builder', 'builder_prefix_arguments',
- 'venv_relative_python', 'toolchain', 'runner'])
+_PythonConfigVars = collections.namedtuple('_ConfigVars', [
+ 'shell', 'builder', 'builder_prefix_arguments', 'venv_relative_python',
+ 'toolchain', 'runner'
+])
def _python_config_generator(name, major, minor, bits, config_vars):
- return PythonConfig(
- name,
- config_vars.shell + config_vars.builder + config_vars.builder_prefix_arguments + [
- _python_pattern_function(major=major, minor=minor, bits=bits)] + [
- name] + config_vars.venv_relative_python + config_vars.toolchain,
- config_vars.shell + config_vars.runner + [
- os.path.join(name, config_vars.venv_relative_python[0])])
+ return PythonConfig(
+ name, config_vars.shell + config_vars.builder +
+ config_vars.builder_prefix_arguments + [
+ _python_pattern_function(major=major, minor=minor, bits=bits)
+ ] + [name] + config_vars.venv_relative_python + config_vars.toolchain,
+ config_vars.shell + config_vars.runner +
+ [os.path.join(name, config_vars.venv_relative_python[0])])
def _pypy_config_generator(name, major, config_vars):
- return PythonConfig(
- name,
- config_vars.shell + config_vars.builder + config_vars.builder_prefix_arguments + [
- _pypy_pattern_function(major=major)] + [
- name] + config_vars.venv_relative_python + config_vars.toolchain,
- config_vars.shell + config_vars.runner + [
- os.path.join(name, config_vars.venv_relative_python[0])])
+ return PythonConfig(
+ name,
+ config_vars.shell + config_vars.builder +
+ config_vars.builder_prefix_arguments + [
+ _pypy_pattern_function(major=major)
+ ] + [name] + config_vars.venv_relative_python + config_vars.toolchain,
+ config_vars.shell + config_vars.runner +
+ [os.path.join(name, config_vars.venv_relative_python[0])])
def _python_pattern_function(major, minor, bits):
- # Bit-ness is handled by the test machine's environment
- if os.name == "nt":
- if bits == "64":
- return '/c/Python{major}{minor}/python.exe'.format(
- major=major, minor=minor, bits=bits)
+ # Bit-ness is handled by the test machine's environment
+ if os.name == "nt":
+ if bits == "64":
+ return '/c/Python{major}{minor}/python.exe'.format(
+ major=major, minor=minor, bits=bits)
+ else:
+ return '/c/Python{major}{minor}_{bits}bits/python.exe'.format(
+ major=major, minor=minor, bits=bits)
else:
- return '/c/Python{major}{minor}_{bits}bits/python.exe'.format(
- major=major, minor=minor, bits=bits)
- else:
- return 'python{major}.{minor}'.format(major=major, minor=minor)
+ return 'python{major}.{minor}'.format(major=major, minor=minor)
def _pypy_pattern_function(major):
- if major == '2':
- return 'pypy'
- elif major == '3':
- return 'pypy3'
- else:
- raise ValueError("Unknown PyPy major version")
+ if major == '2':
+ return 'pypy'
+ elif major == '3':
+ return 'pypy3'
+ else:
+ raise ValueError("Unknown PyPy major version")
class CLanguage(object):
- def __init__(self, make_target, test_lang):
- self.make_target = make_target
- self.platform = platform_string()
- self.test_lang = test_lang
-
- def configure(self, config, args):
- self.config = config
- self.args = args
- if self.platform == 'windows':
- _check_compiler(self.args.compiler, ['default', 'cmake', 'cmake_vs2015',
- 'cmake_vs2017'])
- _check_arch(self.args.arch, ['default', 'x64', 'x86'])
- self._cmake_generator_option = 'Visual Studio 15 2017' if self.args.compiler == 'cmake_vs2017' else 'Visual Studio 14 2015'
- self._cmake_arch_option = 'x64' if self.args.arch == 'x64' else 'Win32'
- self._use_cmake = True
- self._make_options = []
- elif self.args.compiler == 'cmake':
- _check_arch(self.args.arch, ['default'])
- self._use_cmake = True
- self._docker_distro = 'jessie'
- self._make_options = []
- else:
- self._use_cmake = False
- self._docker_distro, self._make_options = self._compiler_options(self.args.use_docker,
- self.args.compiler)
- if args.iomgr_platform == "uv":
- cflags = '-DGRPC_UV -DGRPC_UV_THREAD_CHECK'
- try:
- cflags += subprocess.check_output(['pkg-config', '--cflags', 'libuv']).strip() + ' '
- except (subprocess.CalledProcessError, OSError):
- pass
- try:
- ldflags = subprocess.check_output(['pkg-config', '--libs', 'libuv']).strip() + ' '
- except (subprocess.CalledProcessError, OSError):
- ldflags = '-luv '
- self._make_options += ['EXTRA_CPPFLAGS={}'.format(cflags),
- 'EXTRA_LDLIBS={}'.format(ldflags)]
-
- def test_specs(self):
- out = []
- binaries = get_c_tests(self.args.travis, self.test_lang)
- for target in binaries:
- if self._use_cmake and target.get('boringssl', False):
- # cmake doesn't build boringssl tests
- continue
- polling_strategies = (_POLLING_STRATEGIES.get(self.platform, ['all'])
- if target.get('uses_polling', True)
- else ['all'])
- if self.args.iomgr_platform == 'uv':
- polling_strategies = ['all']
- for polling_strategy in polling_strategies:
- env={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
- _ROOT + '/src/core/tsi/test_creds/ca.pem',
- 'GRPC_POLL_STRATEGY': polling_strategy,
- 'GRPC_VERBOSITY': 'DEBUG'}
- resolver = os.environ.get('GRPC_DNS_RESOLVER', None);
- if resolver:
- env['GRPC_DNS_RESOLVER'] = resolver
- shortname_ext = '' if polling_strategy=='all' else ' GRPC_POLL_STRATEGY=%s' % polling_strategy
- timeout_scaling = 1
- if polling_strategy == 'poll-cv':
- timeout_scaling *= 5
-
- if polling_strategy in target.get('excluded_poll_engines', []):
- continue
-
- # Scale overall test timeout if running under various sanitizers.
- config = self.args.config
- if ('asan' in config
- or config == 'msan'
- or config == 'tsan'
- or config == 'ubsan'
- or config == 'helgrind'
- or config == 'memcheck'):
- timeout_scaling *= 20
-
- if self.config.build_config in target['exclude_configs']:
- continue
- if self.args.iomgr_platform in target.get('exclude_iomgrs', []):
- continue
+ def __init__(self, make_target, test_lang):
+ self.make_target = make_target
+ self.platform = platform_string()
+ self.test_lang = test_lang
+
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
if self.platform == 'windows':
- binary = 'cmake/build/%s/%s.exe' % (_MSBUILD_CONFIG[self.config.build_config], target['name'])
+ _check_compiler(
+ self.args.compiler,
+ ['default', 'cmake', 'cmake_vs2015', 'cmake_vs2017'])
+ _check_arch(self.args.arch, ['default', 'x64', 'x86'])
+ self._cmake_generator_option = 'Visual Studio 15 2017' if self.args.compiler == 'cmake_vs2017' else 'Visual Studio 14 2015'
+ self._cmake_arch_option = 'x64' if self.args.arch == 'x64' else 'Win32'
+ self._use_cmake = True
+ self._make_options = []
+ elif self.args.compiler == 'cmake':
+ _check_arch(self.args.arch, ['default'])
+ self._use_cmake = True
+ self._docker_distro = 'jessie'
+ self._make_options = []
else:
- if self._use_cmake:
- binary = 'cmake/build/%s' % target['name']
- else:
- binary = 'bins/%s/%s' % (self.config.build_config, target['name'])
- cpu_cost = target['cpu_cost']
- if cpu_cost == 'capacity':
- cpu_cost = multiprocessing.cpu_count()
- if os.path.isfile(binary):
- if 'gtest' in target and target['gtest']:
- # here we parse the output of --gtest_list_tests to build up a
- # complete list of the tests contained in a binary
- # for each test, we then add a job to run, filtering for just that
- # test
- with open(os.devnull, 'w') as fnull:
- tests = subprocess.check_output([binary, '--gtest_list_tests'],
- stderr=fnull)
- base = None
- for line in tests.split('\n'):
- i = line.find('#')
- if i >= 0: line = line[:i]
- if not line: continue
- if line[0] != ' ':
- base = line.strip()
- else:
- assert base is not None
- assert line[1] == ' '
- test = base + line.strip()
- cmdline = [binary, '--gtest_filter=%s' % test] + target['args']
- out.append(self.config.job_spec(cmdline,
- shortname='%s %s' % (' '.join(cmdline), shortname_ext),
- cpu_cost=cpu_cost,
- timeout_seconds=_DEFAULT_TIMEOUT_SECONDS * timeout_scaling,
- environ=env))
- else:
- cmdline = [binary] + target['args']
- shortname = target.get('shortname', ' '.join(
- pipes.quote(arg)
- for arg in cmdline))
- shortname += shortname_ext
- out.append(self.config.job_spec(cmdline,
- shortname=shortname,
- cpu_cost=cpu_cost,
- flaky=target.get('flaky', False),
- timeout_seconds=target.get('timeout_seconds', _DEFAULT_TIMEOUT_SECONDS) * timeout_scaling,
- environ=env))
- elif self.args.regex == '.*' or self.platform == 'windows':
- print('\nWARNING: binary not found, skipping', binary)
- return sorted(out)
-
- def make_targets(self):
- if self.platform == 'windows':
- # don't build tools on windows just yet
- return ['buildtests_%s' % self.make_target]
- return ['buildtests_%s' % self.make_target, 'tools_%s' % self.make_target,
- 'check_epollexclusive']
-
- def make_options(self):
- return self._make_options
-
- def pre_build_steps(self):
- if self.platform == 'windows':
- return [['tools\\run_tests\\helper_scripts\\pre_build_cmake.bat',
- self._cmake_generator_option,
- self._cmake_arch_option]]
- elif self._use_cmake:
- return [['tools/run_tests/helper_scripts/pre_build_cmake.sh']]
- else:
- return []
+ self._use_cmake = False
+ self._docker_distro, self._make_options = self._compiler_options(
+ self.args.use_docker, self.args.compiler)
+ if args.iomgr_platform == "uv":
+ cflags = '-DGRPC_UV -DGRPC_UV_THREAD_CHECK'
+ try:
+ cflags += subprocess.check_output(
+ ['pkg-config', '--cflags', 'libuv']).strip() + ' '
+ except (subprocess.CalledProcessError, OSError):
+ pass
+ try:
+ ldflags = subprocess.check_output(
+ ['pkg-config', '--libs', 'libuv']).strip() + ' '
+ except (subprocess.CalledProcessError, OSError):
+ ldflags = '-luv '
+ self._make_options += [
+ 'EXTRA_CPPFLAGS={}'.format(cflags),
+ 'EXTRA_LDLIBS={}'.format(ldflags)
+ ]
+
+ def test_specs(self):
+ out = []
+ binaries = get_c_tests(self.args.travis, self.test_lang)
+ for target in binaries:
+ if self._use_cmake and target.get('boringssl', False):
+ # cmake doesn't build boringssl tests
+ continue
+ auto_timeout_scaling = target.get('auto_timeout_scaling', True)
+ polling_strategies = (_POLLING_STRATEGIES.get(
+ self.platform, ['all']) if target.get('uses_polling', True) else
+ ['none'])
+ if self.args.iomgr_platform == 'uv':
+ polling_strategies = ['all']
+ for polling_strategy in polling_strategies:
+ env = {
+ 'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
+ _ROOT + '/src/core/tsi/test_creds/ca.pem',
+ 'GRPC_POLL_STRATEGY':
+ polling_strategy,
+ 'GRPC_VERBOSITY':
+ 'DEBUG'
+ }
+ resolver = os.environ.get('GRPC_DNS_RESOLVER', None)
+ if resolver:
+ env['GRPC_DNS_RESOLVER'] = resolver
+ shortname_ext = '' if polling_strategy == 'all' else ' GRPC_POLL_STRATEGY=%s' % polling_strategy
+ if polling_strategy in target.get('excluded_poll_engines', []):
+ continue
+
+ timeout_scaling = 1
+ if auto_timeout_scaling:
+ config = self.args.config
+ if ('asan' in config or config == 'msan' or
+ config == 'tsan' or config == 'ubsan' or
+ config == 'helgrind' or config == 'memcheck'):
+ # Scale overall test timeout if running under various sanitizers.
+ # scaling value is based on historical data analysis
+ timeout_scaling *= 3
+ elif polling_strategy == 'poll-cv':
+ # scale test timeout if running with poll-cv
+ # sanitizer and poll-cv scaling is not cumulative to ensure
+ # reasonable timeout values.
+ # TODO(jtattermusch): based on historical data and 5min default
+ # test timeout poll-cv scaling is currently not useful.
+ # Leaving here so it can be reintroduced if the default test timeout
+ # is decreased in the future.
+ timeout_scaling *= 1
+
+ if self.config.build_config in target['exclude_configs']:
+ continue
+ if self.args.iomgr_platform in target.get('exclude_iomgrs', []):
+ continue
+ if self.platform == 'windows':
+ binary = 'cmake/build/%s/%s.exe' % (
+ _MSBUILD_CONFIG[self.config.build_config],
+ target['name'])
+ else:
+ if self._use_cmake:
+ binary = 'cmake/build/%s' % target['name']
+ else:
+ binary = 'bins/%s/%s' % (self.config.build_config,
+ target['name'])
+ cpu_cost = target['cpu_cost']
+ if cpu_cost == 'capacity':
+ cpu_cost = multiprocessing.cpu_count()
+ if os.path.isfile(binary):
+ list_test_command = None
+ filter_test_command = None
+
+ # these are the flag defined by gtest and benchmark framework to list
+ # and filter test runs. We use them to split each individual test
+ # into its own JobSpec, and thus into its own process.
+ if 'benchmark' in target and target['benchmark']:
+ with open(os.devnull, 'w') as fnull:
+ tests = subprocess.check_output(
+ [binary, '--benchmark_list_tests'],
+ stderr=fnull)
+ for line in tests.split('\n'):
+ test = line.strip()
+ if not test: continue
+ cmdline = [binary,
+ '--benchmark_filter=%s$' % test
+ ] + target['args']
+ out.append(
+ self.config.job_spec(
+ cmdline,
+ shortname='%s %s' % (' '.join(cmdline),
+ shortname_ext),
+ cpu_cost=cpu_cost,
+ timeout_seconds=target.get(
+ 'timeout_seconds',
+ _DEFAULT_TIMEOUT_SECONDS) *
+ timeout_scaling,
+ environ=env))
+ elif 'gtest' in target and target['gtest']:
+ # here we parse the output of --gtest_list_tests to build up a complete
+ # list of the tests contained in a binary for each test, we then
+ # add a job to run, filtering for just that test.
+ with open(os.devnull, 'w') as fnull:
+ tests = subprocess.check_output(
+ [binary, '--gtest_list_tests'], stderr=fnull)
+ base = None
+ for line in tests.split('\n'):
+ i = line.find('#')
+ if i >= 0: line = line[:i]
+ if not line: continue
+ if line[0] != ' ':
+ base = line.strip()
+ else:
+ assert base is not None
+ assert line[1] == ' '
+ test = base + line.strip()
+ cmdline = [binary,
+ '--gtest_filter=%s' % test
+ ] + target['args']
+ out.append(
+ self.config.job_spec(
+ cmdline,
+ shortname='%s %s' % (' '.join(cmdline),
+ shortname_ext),
+ cpu_cost=cpu_cost,
+ timeout_seconds=target.get(
+ 'timeout_seconds',
+ _DEFAULT_TIMEOUT_SECONDS) *
+ timeout_scaling,
+ environ=env))
+ else:
+ cmdline = [binary] + target['args']
+ shortname = target.get('shortname', ' '.join(
+ pipes.quote(arg) for arg in cmdline))
+ shortname += shortname_ext
+ out.append(
+ self.config.job_spec(
+ cmdline,
+ shortname=shortname,
+ cpu_cost=cpu_cost,
+ flaky=target.get('flaky', False),
+ timeout_seconds=target.get(
+ 'timeout_seconds', _DEFAULT_TIMEOUT_SECONDS)
+ * timeout_scaling,
+ environ=env))
+ elif self.args.regex == '.*' or self.platform == 'windows':
+ print('\nWARNING: binary not found, skipping', binary)
+ return sorted(out)
+
+ def make_targets(self):
+ if self.platform == 'windows':
+ # don't build tools on windows just yet
+ return ['buildtests_%s' % self.make_target]
+ return [
+ 'buildtests_%s' % self.make_target,
+ 'tools_%s' % self.make_target, 'check_epollexclusive'
+ ]
- def build_steps(self):
- return []
+ def make_options(self):
+ return self._make_options
- def post_tests_steps(self):
- if self.platform == 'windows':
- return []
- else:
- return [['tools/run_tests/helper_scripts/post_tests_c.sh']]
+ def pre_build_steps(self):
+ if self.platform == 'windows':
+ return [[
+ 'tools\\run_tests\\helper_scripts\\pre_build_cmake.bat',
+ self._cmake_generator_option, self._cmake_arch_option
+ ]]
+ elif self._use_cmake:
+ return [['tools/run_tests/helper_scripts/pre_build_cmake.sh']]
+ else:
+ return []
- def makefile_name(self):
- if self._use_cmake:
- return 'cmake/build/Makefile'
- else:
- return 'Makefile'
+ def build_steps(self):
+ return []
+
+ def post_tests_steps(self):
+ if self.platform == 'windows':
+ return []
+ else:
+ return [['tools/run_tests/helper_scripts/post_tests_c.sh']]
- def _clang_make_options(self, version_suffix=''):
- return ['CC=clang%s' % version_suffix,
+ def makefile_name(self):
+ if self._use_cmake:
+ return 'cmake/build/Makefile'
+ else:
+ return 'Makefile'
+
+ def _clang_make_options(self, version_suffix=''):
+ return [
+ 'CC=clang%s' % version_suffix,
'CXX=clang++%s' % version_suffix,
'LD=clang%s' % version_suffix,
- 'LDXX=clang++%s' % version_suffix]
+ 'LDXX=clang++%s' % version_suffix
+ ]
- def _gcc_make_options(self, version_suffix):
- return ['CC=gcc%s' % version_suffix,
+ def _gcc_make_options(self, version_suffix):
+ return [
+ 'CC=gcc%s' % version_suffix,
'CXX=g++%s' % version_suffix,
'LD=gcc%s' % version_suffix,
- 'LDXX=g++%s' % version_suffix]
-
- def _compiler_options(self, use_docker, compiler):
- """Returns docker distro and make options to use for given compiler."""
- if not use_docker and not _is_use_docker_child():
- _check_compiler(compiler, ['default'])
-
- if compiler == 'gcc4.9' or compiler == 'default':
- return ('jessie', [])
- elif compiler == 'gcc4.8':
- return ('jessie', self._gcc_make_options(version_suffix='-4.8'))
- elif compiler == 'gcc5.3':
- return ('ubuntu1604', [])
- elif compiler == 'gcc_musl':
- return ('alpine', [])
- elif compiler == 'clang3.4':
- # on ubuntu1404, clang-3.4 alias doesn't exist, just use 'clang'
- return ('ubuntu1404', self._clang_make_options())
- elif compiler == 'clang3.5':
- return ('jessie', self._clang_make_options(version_suffix='-3.5'))
- elif compiler == 'clang3.6':
- return ('ubuntu1604', self._clang_make_options(version_suffix='-3.6'))
- elif compiler == 'clang3.7':
- return ('ubuntu1604', self._clang_make_options(version_suffix='-3.7'))
- else:
- raise Exception('Compiler %s not supported.' % compiler)
+ 'LDXX=g++%s' % version_suffix
+ ]
+
+ def _compiler_options(self, use_docker, compiler):
+ """Returns docker distro and make options to use for given compiler."""
+ if not use_docker and not _is_use_docker_child():
+ _check_compiler(compiler, ['default'])
+
+ if compiler == 'gcc4.9' or compiler == 'default':
+ return ('jessie', [])
+ elif compiler == 'gcc4.8':
+ return ('jessie', self._gcc_make_options(version_suffix='-4.8'))
+ elif compiler == 'gcc5.3':
+ return ('ubuntu1604', [])
+ elif compiler == 'gcc7.2':
+ return ('ubuntu1710', [])
+ elif compiler == 'gcc_musl':
+ return ('alpine', [])
+ elif compiler == 'clang3.4':
+ # on ubuntu1404, clang-3.4 alias doesn't exist, just use 'clang'
+ return ('ubuntu1404', self._clang_make_options())
+ elif compiler == 'clang3.5':
+ return ('jessie', self._clang_make_options(version_suffix='-3.5'))
+ elif compiler == 'clang3.6':
+ return ('ubuntu1604',
+ self._clang_make_options(version_suffix='-3.6'))
+ elif compiler == 'clang3.7':
+ return ('ubuntu1604',
+ self._clang_make_options(version_suffix='-3.7'))
+ else:
+ raise Exception('Compiler %s not supported.' % compiler)
+
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/cxx_%s_%s' % (
+ self._docker_distro, _docker_arch_suffix(self.args.arch))
+
+ def __str__(self):
+ return self.make_target
+
+
+# This tests Node on grpc/grpc-node and will become the standard for Node testing
+class RemoteNodeLanguage(object):
+
+ def __init__(self):
+ self.platform = platform_string()
+
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ # Note: electron ABI only depends on major and minor version, so that's all
+ # we should specify in the compiler argument
+ _check_compiler(self.args.compiler, [
+ 'default', 'node0.12', 'node4', 'node5', 'node6', 'node7', 'node8',
+ 'electron1.3', 'electron1.6'
+ ])
+ if self.args.compiler == 'default':
+ self.runtime = 'node'
+ self.node_version = '8'
+ else:
+ if self.args.compiler.startswith('electron'):
+ self.runtime = 'electron'
+ self.node_version = self.args.compiler[8:]
+ else:
+ self.runtime = 'node'
+ # Take off the word "node"
+ self.node_version = self.args.compiler[4:]
+
+ # TODO: update with Windows/electron scripts when available for grpc/grpc-node
+ def test_specs(self):
+ if self.platform == 'windows':
+ return [
+ self.config.job_spec(
+ ['tools\\run_tests\\helper_scripts\\run_node.bat'])
+ ]
+ else:
+ return [
+ self.config.job_spec(
+ ['tools/run_tests/helper_scripts/run_grpc-node.sh'],
+ None,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS)
+ ]
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/cxx_%s_%s' % (self._docker_distro,
- _docker_arch_suffix(self.args.arch))
+ def pre_build_steps(self):
+ return []
- def __str__(self):
- return self.make_target
+ def make_targets(self):
+ return []
+ def make_options(self):
+ return []
-class NodeLanguage(object):
+ def build_steps(self):
+ return []
- def __init__(self):
- self.platform = platform_string()
+ def post_tests_steps(self):
+ return []
- def configure(self, config, args):
- self.config = config
- self.args = args
- # Note: electron ABI only depends on major and minor version, so that's all
- # we should specify in the compiler argument
- _check_compiler(self.args.compiler, ['default', 'node0.12',
- 'node4', 'node5', 'node6',
- 'node7', 'node8',
- 'electron1.3', 'electron1.6'])
- if self.args.compiler == 'default':
- self.runtime = 'node'
- self.node_version = '8'
- else:
- if self.args.compiler.startswith('electron'):
- self.runtime = 'electron'
- self.node_version = self.args.compiler[8:]
- else:
- self.runtime = 'node'
- # Take off the word "node"
- self.node_version = self.args.compiler[4:]
-
- def test_specs(self):
- if self.platform == 'windows':
- return [self.config.job_spec(['tools\\run_tests\\helper_scripts\\run_node.bat'])]
- else:
- run_script = 'run_node'
- if self.runtime == 'electron':
- run_script += '_electron'
- return [self.config.job_spec(['tools/run_tests/helper_scripts/{}.sh'.format(run_script),
- self.node_version],
- None,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS)]
-
- def pre_build_steps(self):
- if self.platform == 'windows':
- return [['tools\\run_tests\\helper_scripts\\pre_build_node.bat']]
- else:
- build_script = 'pre_build_node'
- if self.runtime == 'electron':
- build_script += '_electron'
- return [['tools/run_tests/helper_scripts/{}.sh'.format(build_script),
- self.node_version]]
-
- def make_targets(self):
- return []
-
- def make_options(self):
- return []
-
- def build_steps(self):
- if self.platform == 'windows':
- if self.config == 'dbg':
- config_flag = '--debug'
- else:
- config_flag = '--release'
- return [['tools\\run_tests\\helper_scripts\\build_node.bat',
- config_flag]]
- else:
- build_script = 'build_node'
- if self.runtime == 'electron':
- build_script += '_electron'
- # building for electron requires a patch version
- self.node_version += '.0'
- return [['tools/run_tests/helper_scripts/{}.sh'.format(build_script),
- self.node_version]]
+ def makefile_name(self):
+ return 'Makefile'
- def post_tests_steps(self):
- return []
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/node_jessie_%s' % _docker_arch_suffix(
+ self.args.arch)
- def makefile_name(self):
- return 'Makefile'
-
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/node_jessie_%s' % _docker_arch_suffix(self.args.arch)
-
- def __str__(self):
- return 'node'
+ def __str__(self):
+ return 'grpc-node'
class PhpLanguage(object):
- def configure(self, config, args):
- self.config = config
- self.args = args
- _check_compiler(self.args.compiler, ['default'])
- self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true']
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ _check_compiler(self.args.compiler, ['default'])
+ self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true']
- def test_specs(self):
- return [self.config.job_spec(['src/php/bin/run_tests.sh'],
- environ=_FORCE_ENVIRON_FOR_WRAPPERS)]
+ def test_specs(self):
+ return [
+ self.config.job_spec(
+ ['src/php/bin/run_tests.sh'],
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS)
+ ]
- def pre_build_steps(self):
- return []
+ def pre_build_steps(self):
+ return []
- def make_targets(self):
- return ['static_c', 'shared_c']
+ def make_targets(self):
+ return ['static_c', 'shared_c']
- def make_options(self):
- return self._make_options;
+ def make_options(self):
+ return self._make_options
- def build_steps(self):
- return [['tools/run_tests/helper_scripts/build_php.sh']]
+ def build_steps(self):
+ return [['tools/run_tests/helper_scripts/build_php.sh']]
- def post_tests_steps(self):
- return [['tools/run_tests/helper_scripts/post_tests_php.sh']]
+ def post_tests_steps(self):
+ return [['tools/run_tests/helper_scripts/post_tests_php.sh']]
- def makefile_name(self):
- return 'Makefile'
+ def makefile_name(self):
+ return 'Makefile'
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/php_jessie_%s' % _docker_arch_suffix(self.args.arch)
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/php_jessie_%s' % _docker_arch_suffix(
+ self.args.arch)
- def __str__(self):
- return 'php'
+ def __str__(self):
+ return 'php'
class Php7Language(object):
- def configure(self, config, args):
- self.config = config
- self.args = args
- _check_compiler(self.args.compiler, ['default'])
- self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true']
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ _check_compiler(self.args.compiler, ['default'])
+ self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true']
- def test_specs(self):
- return [self.config.job_spec(['src/php/bin/run_tests.sh'],
- environ=_FORCE_ENVIRON_FOR_WRAPPERS)]
+ def test_specs(self):
+ return [
+ self.config.job_spec(
+ ['src/php/bin/run_tests.sh'],
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS)
+ ]
- def pre_build_steps(self):
- return []
+ def pre_build_steps(self):
+ return []
- def make_targets(self):
- return ['static_c', 'shared_c']
+ def make_targets(self):
+ return ['static_c', 'shared_c']
- def make_options(self):
- return self._make_options;
+ def make_options(self):
+ return self._make_options
- def build_steps(self):
- return [['tools/run_tests/helper_scripts/build_php.sh']]
+ def build_steps(self):
+ return [['tools/run_tests/helper_scripts/build_php.sh']]
- def post_tests_steps(self):
- return [['tools/run_tests/helper_scripts/post_tests_php.sh']]
+ def post_tests_steps(self):
+ return [['tools/run_tests/helper_scripts/post_tests_php.sh']]
- def makefile_name(self):
- return 'Makefile'
+ def makefile_name(self):
+ return 'Makefile'
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/php7_jessie_%s' % _docker_arch_suffix(self.args.arch)
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/php7_jessie_%s' % _docker_arch_suffix(
+ self.args.arch)
- def __str__(self):
- return 'php7'
+ def __str__(self):
+ return 'php7'
-class PythonConfig(collections.namedtuple('PythonConfig', [
- 'name', 'build', 'run'])):
- """Tuple of commands (named s.t. 'what it says on the tin' applies)"""
+class PythonConfig(
+ collections.namedtuple('PythonConfig', ['name', 'build', 'run'])):
+ """Tuple of commands (named s.t. 'what it says on the tin' applies)"""
+
class PythonLanguage(object):
- def configure(self, config, args):
- self.config = config
- self.args = args
- self.pythons = self._get_pythons(self.args)
-
- def test_specs(self):
- # load list of known test suites
- with open('src/python/grpcio_tests/tests/tests.json') as tests_json_file:
- tests_json = json.load(tests_json_file)
- environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS)
- return [self.config.job_spec(
- config.run,
- timeout_seconds=5*60,
- environ=dict(list(environment.items()) +
- [('GRPC_PYTHON_TESTRUNNER_FILTER', str(suite_name))]),
- shortname='%s.test.%s' % (config.name, suite_name),)
- for suite_name in tests_json
- for config in self.pythons]
-
- def pre_build_steps(self):
- return []
-
- def make_targets(self):
- return []
-
- def make_options(self):
- return []
-
- def build_steps(self):
- return [config.build for config in self.pythons]
-
- def post_tests_steps(self):
- if self.config != 'gcov':
- return []
- else:
- return [['tools/run_tests/helper_scripts/post_tests_python.sh']]
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ self.pythons = self._get_pythons(self.args)
+
+ def test_specs(self):
+ # load list of known test suites
+ with open(
+ 'src/python/grpcio_tests/tests/tests.json') as tests_json_file:
+ tests_json = json.load(tests_json_file)
+ environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS)
+ return [
+ self.config.job_spec(
+ config.run,
+ timeout_seconds=5 * 60,
+ environ=dict(
+ list(environment.items()) + [(
+ 'GRPC_PYTHON_TESTRUNNER_FILTER', str(suite_name))]),
+ shortname='%s.test.%s' % (config.name, suite_name),
+ ) for suite_name in tests_json for config in self.pythons
+ ]
+
+ def pre_build_steps(self):
+ return []
+
+ def make_targets(self):
+ return []
+
+ def make_options(self):
+ return []
+
+ def build_steps(self):
+ return [config.build for config in self.pythons]
+
+ def post_tests_steps(self):
+ if self.config.build_config != 'gcov':
+ return []
+ else:
+ return [['tools/run_tests/helper_scripts/post_tests_python.sh']]
- def makefile_name(self):
- return 'Makefile'
+ def makefile_name(self):
+ return 'Makefile'
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/python_%s_%s' % (self.python_manager_name(), _docker_arch_suffix(self.args.arch))
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/python_%s_%s' % (
+ self.python_manager_name(), _docker_arch_suffix(self.args.arch))
- def python_manager_name(self):
- if self.args.compiler in ['python3.5', 'python3.6']:
- return 'pyenv'
- elif self.args.compiler == 'python_alpine':
- return 'alpine'
- else:
- return 'jessie'
+ def python_manager_name(self):
+ if self.args.compiler in ['python3.5', 'python3.6']:
+ return 'pyenv'
+ elif self.args.compiler == 'python_alpine':
+ return 'alpine'
+ else:
+ return 'jessie'
- def _get_pythons(self, args):
- if args.arch == 'x86':
- bits = '32'
- else:
- bits = '64'
-
- if os.name == 'nt':
- shell = ['bash']
- builder = [os.path.abspath('tools/run_tests/helper_scripts/build_python_msys2.sh')]
- builder_prefix_arguments = ['MINGW{}'.format(bits)]
- venv_relative_python = ['Scripts/python.exe']
- toolchain = ['mingw32']
- else:
- shell = []
- builder = [os.path.abspath('tools/run_tests/helper_scripts/build_python.sh')]
- builder_prefix_arguments = []
- venv_relative_python = ['bin/python']
- toolchain = ['unix']
-
- runner = [os.path.abspath('tools/run_tests/helper_scripts/run_python.sh')]
- config_vars = _PythonConfigVars(shell, builder, builder_prefix_arguments,
- venv_relative_python, toolchain, runner)
- python27_config = _python_config_generator(name='py27', major='2',
- minor='7', bits=bits,
- config_vars=config_vars)
- python34_config = _python_config_generator(name='py34', major='3',
- minor='4', bits=bits,
- config_vars=config_vars)
- python35_config = _python_config_generator(name='py35', major='3',
- minor='5', bits=bits,
- config_vars=config_vars)
- python36_config = _python_config_generator(name='py36', major='3',
- minor='6', bits=bits,
- config_vars=config_vars)
- pypy27_config = _pypy_config_generator(name='pypy', major='2',
- config_vars=config_vars)
- pypy32_config = _pypy_config_generator(name='pypy3', major='3',
- config_vars=config_vars)
-
- if args.compiler == 'default':
- if os.name == 'nt':
- return (python35_config,)
- else:
- return (python27_config, python34_config,)
- elif args.compiler == 'python2.7':
- return (python27_config,)
- elif args.compiler == 'python3.4':
- return (python34_config,)
- elif args.compiler == 'python3.5':
- return (python35_config,)
- elif args.compiler == 'python3.6':
- return (python36_config,)
- elif args.compiler == 'pypy':
- return (pypy27_config,)
- elif args.compiler == 'pypy3':
- return (pypy32_config,)
- elif args.compiler == 'python_alpine':
- return (python27_config,)
- else:
- raise Exception('Compiler %s not supported.' % args.compiler)
+ def _get_pythons(self, args):
+ if args.arch == 'x86':
+ bits = '32'
+ else:
+ bits = '64'
+
+ if os.name == 'nt':
+ shell = ['bash']
+ builder = [
+ os.path.abspath(
+ 'tools/run_tests/helper_scripts/build_python_msys2.sh')
+ ]
+ builder_prefix_arguments = ['MINGW{}'.format(bits)]
+ venv_relative_python = ['Scripts/python.exe']
+ toolchain = ['mingw32']
+ else:
+ shell = []
+ builder = [
+ os.path.abspath(
+ 'tools/run_tests/helper_scripts/build_python.sh')
+ ]
+ builder_prefix_arguments = []
+ venv_relative_python = ['bin/python']
+ toolchain = ['unix']
+
+ runner = [
+ os.path.abspath('tools/run_tests/helper_scripts/run_python.sh')
+ ]
+ config_vars = _PythonConfigVars(shell, builder,
+ builder_prefix_arguments,
+ venv_relative_python, toolchain, runner)
+ python27_config = _python_config_generator(
+ name='py27',
+ major='2',
+ minor='7',
+ bits=bits,
+ config_vars=config_vars)
+ python34_config = _python_config_generator(
+ name='py34',
+ major='3',
+ minor='4',
+ bits=bits,
+ config_vars=config_vars)
+ python35_config = _python_config_generator(
+ name='py35',
+ major='3',
+ minor='5',
+ bits=bits,
+ config_vars=config_vars)
+ python36_config = _python_config_generator(
+ name='py36',
+ major='3',
+ minor='6',
+ bits=bits,
+ config_vars=config_vars)
+ pypy27_config = _pypy_config_generator(
+ name='pypy', major='2', config_vars=config_vars)
+ pypy32_config = _pypy_config_generator(
+ name='pypy3', major='3', config_vars=config_vars)
+
+ if args.compiler == 'default':
+ if os.name == 'nt':
+ return (python35_config,)
+ else:
+ return (
+ python27_config,
+ python34_config,
+ )
+ elif args.compiler == 'python2.7':
+ return (python27_config,)
+ elif args.compiler == 'python3.4':
+ return (python34_config,)
+ elif args.compiler == 'python3.5':
+ return (python35_config,)
+ elif args.compiler == 'python3.6':
+ return (python36_config,)
+ elif args.compiler == 'pypy':
+ return (pypy27_config,)
+ elif args.compiler == 'pypy3':
+ return (pypy32_config,)
+ elif args.compiler == 'python_alpine':
+ return (python27_config,)
+ elif args.compiler == 'all_the_cpythons':
+ return (
+ python27_config,
+ python34_config,
+ python35_config,
+ python36_config,
+ )
+ else:
+ raise Exception('Compiler %s not supported.' % args.compiler)
- def __str__(self):
- return 'python'
+ def __str__(self):
+ return 'python'
class RubyLanguage(object):
- def configure(self, config, args):
- self.config = config
- self.args = args
- _check_compiler(self.args.compiler, ['default'])
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ _check_compiler(self.args.compiler, ['default'])
- def test_specs(self):
- tests = [self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby.sh'],
- timeout_seconds=10*60,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS)]
- tests.append(self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh'],
- timeout_seconds=10*60,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS))
- return tests
+ def test_specs(self):
+ tests = [
+ self.config.job_spec(
+ ['tools/run_tests/helper_scripts/run_ruby.sh'],
+ timeout_seconds=10 * 60,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS)
+ ]
+ tests.append(
+ self.config.job_spec(
+ ['tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh'],
+ timeout_seconds=10 * 60,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS))
+ return tests
- def pre_build_steps(self):
- return [['tools/run_tests/helper_scripts/pre_build_ruby.sh']]
+ def pre_build_steps(self):
+ return [['tools/run_tests/helper_scripts/pre_build_ruby.sh']]
- def make_targets(self):
- return []
+ def make_targets(self):
+ return []
- def make_options(self):
- return []
+ def make_options(self):
+ return []
- def build_steps(self):
- return [['tools/run_tests/helper_scripts/build_ruby.sh']]
+ def build_steps(self):
+ return [['tools/run_tests/helper_scripts/build_ruby.sh']]
- def post_tests_steps(self):
- return [['tools/run_tests/helper_scripts/post_tests_ruby.sh']]
+ def post_tests_steps(self):
+ return [['tools/run_tests/helper_scripts/post_tests_ruby.sh']]
- def makefile_name(self):
- return 'Makefile'
+ def makefile_name(self):
+ return 'Makefile'
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/ruby_jessie_%s' % _docker_arch_suffix(self.args.arch)
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/ruby_jessie_%s' % _docker_arch_suffix(
+ self.args.arch)
- def __str__(self):
- return 'ruby'
+ def __str__(self):
+ return 'ruby'
class CSharpLanguage(object):
- def __init__(self):
- self.platform = platform_string()
-
- def configure(self, config, args):
- self.config = config
- self.args = args
- if self.platform == 'windows':
- _check_compiler(self.args.compiler, ['coreclr', 'default'])
- _check_arch(self.args.arch, ['default'])
- self._cmake_arch_option = 'x64'
- self._make_options = []
- else:
- _check_compiler(self.args.compiler, ['default', 'coreclr'])
- self._docker_distro = 'jessie'
-
- if self.platform == 'mac':
- # TODO(jtattermusch): EMBED_ZLIB=true currently breaks the mac build
- self._make_options = ['EMBED_OPENSSL=true']
- if self.args.compiler != 'coreclr':
- # On Mac, official distribution of mono is 32bit.
- self._make_options += ['ARCH_FLAGS=-m32', 'LDFLAGS=-m32']
- else:
- self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true']
-
- def test_specs(self):
- with open('src/csharp/tests.json') as f:
- tests_by_assembly = json.load(f)
+ def __init__(self):
+ self.platform = platform_string()
- msbuild_config = _MSBUILD_CONFIG[self.config.build_config]
- nunit_args = ['--labels=All', '--noresult', '--workers=1']
- assembly_subdir = 'bin/%s' % msbuild_config
- assembly_extension = '.exe'
-
- if self.args.compiler == 'coreclr':
- assembly_subdir += '/netcoreapp1.0'
- runtime_cmd = ['dotnet', 'exec']
- assembly_extension = '.dll'
- else:
- assembly_subdir += '/net45'
- if self.platform == 'windows':
- runtime_cmd = []
- else:
- runtime_cmd = ['mono']
-
- specs = []
- for assembly in six.iterkeys(tests_by_assembly):
- assembly_file = 'src/csharp/%s/%s/%s%s' % (assembly,
- assembly_subdir,
- assembly,
- assembly_extension)
- if self.config.build_config != 'gcov' or self.platform != 'windows':
- # normally, run each test as a separate process
- for test in tests_by_assembly[assembly]:
- cmdline = runtime_cmd + [assembly_file, '--test=%s' % test] + nunit_args
- specs.append(self.config.job_spec(cmdline,
- shortname='csharp.%s' % test,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS))
- else:
- # For C# test coverage, run all tests from the same assembly at once
- # using OpenCover.Console (only works on Windows).
- cmdline = ['src\\csharp\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe',
- '-target:%s' % assembly_file,
- '-targetdir:src\\csharp',
- '-targetargs:%s' % ' '.join(nunit_args),
- '-filter:+[Grpc.Core]*',
- '-register:user',
- '-output:src\\csharp\\coverage_csharp_%s.xml' % assembly]
-
- # set really high cpu_cost to make sure instances of OpenCover.Console run exclusively
- # to prevent problems with registering the profiler.
- run_exclusive = 1000000
- specs.append(self.config.job_spec(cmdline,
- shortname='csharp.coverage.%s' % assembly,
- cpu_cost=run_exclusive,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS))
- return specs
-
- def pre_build_steps(self):
- if self.platform == 'windows':
- return [['tools\\run_tests\\helper_scripts\\pre_build_csharp.bat', self._cmake_arch_option]]
- else:
- return [['tools/run_tests/helper_scripts/pre_build_csharp.sh']]
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ if self.platform == 'windows':
+ _check_compiler(self.args.compiler, ['coreclr', 'default'])
+ _check_arch(self.args.arch, ['default'])
+ self._cmake_arch_option = 'x64'
+ self._make_options = []
+ else:
+ _check_compiler(self.args.compiler, ['default', 'coreclr'])
+ self._docker_distro = 'jessie'
+
+ if self.platform == 'mac':
+ # TODO(jtattermusch): EMBED_ZLIB=true currently breaks the mac build
+ self._make_options = ['EMBED_OPENSSL=true']
+ if self.args.compiler != 'coreclr':
+ # On Mac, official distribution of mono is 32bit.
+ self._make_options += ['ARCH_FLAGS=-m32', 'LDFLAGS=-m32']
+ else:
+ self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true']
+
+ def test_specs(self):
+ with open('src/csharp/tests.json') as f:
+ tests_by_assembly = json.load(f)
+
+ msbuild_config = _MSBUILD_CONFIG[self.config.build_config]
+ nunit_args = ['--labels=All', '--noresult', '--workers=1']
+ assembly_subdir = 'bin/%s' % msbuild_config
+ assembly_extension = '.exe'
+
+ if self.args.compiler == 'coreclr':
+ assembly_subdir += '/netcoreapp1.0'
+ runtime_cmd = ['dotnet', 'exec']
+ assembly_extension = '.dll'
+ else:
+ assembly_subdir += '/net45'
+ if self.platform == 'windows':
+ runtime_cmd = []
+ else:
+ runtime_cmd = ['mono']
+
+ specs = []
+ for assembly in six.iterkeys(tests_by_assembly):
+ assembly_file = 'src/csharp/%s/%s/%s%s' % (assembly,
+ assembly_subdir,
+ assembly,
+ assembly_extension)
+ if self.config.build_config != 'gcov' or self.platform != 'windows':
+ # normally, run each test as a separate process
+ for test in tests_by_assembly[assembly]:
+ cmdline = runtime_cmd + [assembly_file,
+ '--test=%s' % test] + nunit_args
+ specs.append(
+ self.config.job_spec(
+ cmdline,
+ shortname='csharp.%s' % test,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS))
+ else:
+ # For C# test coverage, run all tests from the same assembly at once
+ # using OpenCover.Console (only works on Windows).
+ cmdline = [
+ 'src\\csharp\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe',
+ '-target:%s' % assembly_file, '-targetdir:src\\csharp',
+ '-targetargs:%s' % ' '.join(nunit_args),
+ '-filter:+[Grpc.Core]*', '-register:user',
+ '-output:src\\csharp\\coverage_csharp_%s.xml' % assembly
+ ]
+
+ # set really high cpu_cost to make sure instances of OpenCover.Console run exclusively
+ # to prevent problems with registering the profiler.
+ run_exclusive = 1000000
+ specs.append(
+ self.config.job_spec(
+ cmdline,
+ shortname='csharp.coverage.%s' % assembly,
+ cpu_cost=run_exclusive,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS))
+ return specs
+
+ def pre_build_steps(self):
+ if self.platform == 'windows':
+ return [[
+ 'tools\\run_tests\\helper_scripts\\pre_build_csharp.bat',
+ self._cmake_arch_option
+ ]]
+ else:
+ return [['tools/run_tests/helper_scripts/pre_build_csharp.sh']]
- def make_targets(self):
- return ['grpc_csharp_ext']
+ def make_targets(self):
+ return ['grpc_csharp_ext']
- def make_options(self):
- return self._make_options;
+ def make_options(self):
+ return self._make_options
- def build_steps(self):
- if self.platform == 'windows':
- return [['tools\\run_tests\\helper_scripts\\build_csharp.bat']]
- else:
- return [['tools/run_tests/helper_scripts/build_csharp.sh']]
+ def build_steps(self):
+ if self.platform == 'windows':
+ return [['tools\\run_tests\\helper_scripts\\build_csharp.bat']]
+ else:
+ return [['tools/run_tests/helper_scripts/build_csharp.sh']]
- def post_tests_steps(self):
- if self.platform == 'windows':
- return [['tools\\run_tests\\helper_scripts\\post_tests_csharp.bat']]
- else:
- return [['tools/run_tests/helper_scripts/post_tests_csharp.sh']]
+ def post_tests_steps(self):
+ if self.platform == 'windows':
+ return [['tools\\run_tests\\helper_scripts\\post_tests_csharp.bat']]
+ else:
+ return [['tools/run_tests/helper_scripts/post_tests_csharp.sh']]
- def makefile_name(self):
- if self.platform == 'windows':
- return 'cmake/build/%s/Makefile' % self._cmake_arch_option
- else:
- return 'Makefile'
+ def makefile_name(self):
+ if self.platform == 'windows':
+ return 'cmake/build/%s/Makefile' % self._cmake_arch_option
+ else:
+ return 'Makefile'
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/csharp_%s_%s' % (self._docker_distro,
- _docker_arch_suffix(self.args.arch))
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/csharp_%s_%s' % (
+ self._docker_distro, _docker_arch_suffix(self.args.arch))
- def __str__(self):
- return 'csharp'
+ def __str__(self):
+ return 'csharp'
class ObjCLanguage(object):
- def configure(self, config, args):
- self.config = config
- self.args = args
- _check_compiler(self.args.compiler, ['default'])
-
- def test_specs(self):
- return [
- self.config.job_spec(['src/objective-c/tests/run_tests.sh'],
- timeout_seconds=60*60,
- shortname='objc-tests',
- cpu_cost=1e6,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS),
- self.config.job_spec(['src/objective-c/tests/run_plugin_tests.sh'],
- timeout_seconds=60*60,
- shortname='objc-plugin-tests',
- cpu_cost=1e6,
- environ=_FORCE_ENVIRON_FOR_WRAPPERS),
- self.config.job_spec(['src/objective-c/tests/build_one_example.sh'],
- timeout_seconds=10*60,
- shortname='objc-build-example-helloworld',
- cpu_cost=1e6,
- environ={'SCHEME': 'HelloWorld',
- 'EXAMPLE_PATH': 'examples/objective-c/helloworld'}),
- self.config.job_spec(['src/objective-c/tests/build_one_example.sh'],
- timeout_seconds=10*60,
- shortname='objc-build-example-routeguide',
- cpu_cost=1e6,
- environ={'SCHEME': 'RouteGuideClient',
- 'EXAMPLE_PATH': 'examples/objective-c/route_guide'}),
- self.config.job_spec(['src/objective-c/tests/build_one_example.sh'],
- timeout_seconds=10*60,
- shortname='objc-build-example-authsample',
- cpu_cost=1e6,
- environ={'SCHEME': 'AuthSample',
- 'EXAMPLE_PATH': 'examples/objective-c/auth_sample'}),
- self.config.job_spec(['src/objective-c/tests/build_one_example.sh'],
- timeout_seconds=10*60,
- shortname='objc-build-example-sample',
- cpu_cost=1e6,
- environ={'SCHEME': 'Sample',
- 'EXAMPLE_PATH': 'src/objective-c/examples/Sample'}),
- self.config.job_spec(['src/objective-c/tests/build_one_example.sh'],
- timeout_seconds=10*60,
- shortname='objc-build-example-sample-frameworks',
- cpu_cost=1e6,
- environ={'SCHEME': 'Sample',
- 'EXAMPLE_PATH': 'src/objective-c/examples/Sample',
- 'FRAMEWORKS': 'YES'}),
- self.config.job_spec(['src/objective-c/tests/build_one_example.sh'],
- timeout_seconds=10*60,
- shortname='objc-build-example-switftsample',
- cpu_cost=1e6,
- environ={'SCHEME': 'SwiftSample',
- 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample'}),
- ]
-
- def pre_build_steps(self):
- return []
-
- def make_targets(self):
- return ['interop_server']
-
- def make_options(self):
- return []
-
- def build_steps(self):
- return [['src/objective-c/tests/build_tests.sh']]
-
- def post_tests_steps(self):
- return []
-
- def makefile_name(self):
- return 'Makefile'
-
- def dockerfile_dir(self):
- return None
-
- def __str__(self):
- return 'objc'
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ _check_compiler(self.args.compiler, ['default'])
+
+ def test_specs(self):
+ return [
+ self.config.job_spec(
+ ['src/objective-c/tests/run_tests.sh'],
+ timeout_seconds=60 * 60,
+ shortname='objc-tests',
+ cpu_cost=1e6,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS),
+ self.config.job_spec(
+ ['src/objective-c/tests/run_plugin_tests.sh'],
+ timeout_seconds=60 * 60,
+ shortname='objc-plugin-tests',
+ cpu_cost=1e6,
+ environ=_FORCE_ENVIRON_FOR_WRAPPERS),
+ self.config.job_spec(
+ ['src/objective-c/tests/build_one_example.sh'],
+ timeout_seconds=10 * 60,
+ shortname='objc-build-example-helloworld',
+ cpu_cost=1e6,
+ environ={
+ 'SCHEME': 'HelloWorld',
+ 'EXAMPLE_PATH': 'examples/objective-c/helloworld'
+ }),
+ self.config.job_spec(
+ ['src/objective-c/tests/build_one_example.sh'],
+ timeout_seconds=10 * 60,
+ shortname='objc-build-example-routeguide',
+ cpu_cost=1e6,
+ environ={
+ 'SCHEME': 'RouteGuideClient',
+ 'EXAMPLE_PATH': 'examples/objective-c/route_guide'
+ }),
+ self.config.job_spec(
+ ['src/objective-c/tests/build_one_example.sh'],
+ timeout_seconds=10 * 60,
+ shortname='objc-build-example-authsample',
+ cpu_cost=1e6,
+ environ={
+ 'SCHEME': 'AuthSample',
+ 'EXAMPLE_PATH': 'examples/objective-c/auth_sample'
+ }),
+ self.config.job_spec(
+ ['src/objective-c/tests/build_one_example.sh'],
+ timeout_seconds=10 * 60,
+ shortname='objc-build-example-sample',
+ cpu_cost=1e6,
+ environ={
+ 'SCHEME': 'Sample',
+ 'EXAMPLE_PATH': 'src/objective-c/examples/Sample'
+ }),
+ self.config.job_spec(
+ ['src/objective-c/tests/build_one_example.sh'],
+ timeout_seconds=10 * 60,
+ shortname='objc-build-example-sample-frameworks',
+ cpu_cost=1e6,
+ environ={
+ 'SCHEME': 'Sample',
+ 'EXAMPLE_PATH': 'src/objective-c/examples/Sample',
+ 'FRAMEWORKS': 'YES'
+ }),
+ self.config.job_spec(
+ ['src/objective-c/tests/build_one_example.sh'],
+ timeout_seconds=10 * 60,
+ shortname='objc-build-example-switftsample',
+ cpu_cost=1e6,
+ environ={
+ 'SCHEME': 'SwiftSample',
+ 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample'
+ }),
+ ]
+
+ def pre_build_steps(self):
+ return []
+
+ def make_targets(self):
+ return ['interop_server']
+
+ def make_options(self):
+ return []
+
+ def build_steps(self):
+ return [['src/objective-c/tests/build_tests.sh']]
+
+ def post_tests_steps(self):
+ return []
+
+ def makefile_name(self):
+ return 'Makefile'
+
+ def dockerfile_dir(self):
+ return None
+
+ def __str__(self):
+ return 'objc'
class Sanity(object):
- def configure(self, config, args):
- self.config = config
- self.args = args
- _check_compiler(self.args.compiler, ['default'])
-
- def test_specs(self):
- import yaml
- with open('tools/run_tests/sanity/sanity_tests.yaml', 'r') as f:
- environ={'TEST': 'true'}
- if _is_use_docker_child():
- environ['CLANG_FORMAT_SKIP_DOCKER'] = 'true'
- return [self.config.job_spec(cmd['script'].split(),
- timeout_seconds=30*60,
- environ=environ,
- cpu_cost=cmd.get('cpu_cost', 1))
- for cmd in yaml.load(f)]
-
- def pre_build_steps(self):
- return []
-
- def make_targets(self):
- return ['run_dep_checks']
-
- def make_options(self):
- return []
-
- def build_steps(self):
- return []
-
- def post_tests_steps(self):
- return []
-
- def makefile_name(self):
- return 'Makefile'
-
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/sanity'
-
- def __str__(self):
- return 'sanity'
-
-class NodeExpressLanguage(object):
- """Dummy Node express test target to enable running express performance
- benchmarks"""
-
- def __init__(self):
- self.platform = platform_string()
-
- def configure(self, config, args):
- self.config = config
- self.args = args
- _check_compiler(self.args.compiler, ['default', 'node0.12',
- 'node4', 'node5', 'node6'])
- if self.args.compiler == 'default':
- self.node_version = '4'
- else:
- # Take off the word "node"
- self.node_version = self.args.compiler[4:]
+ def configure(self, config, args):
+ self.config = config
+ self.args = args
+ _check_compiler(self.args.compiler, ['default'])
- def test_specs(self):
- return []
+ def test_specs(self):
+ import yaml
+ with open('tools/run_tests/sanity/sanity_tests.yaml', 'r') as f:
+ environ = {'TEST': 'true'}
+ if _is_use_docker_child():
+ environ['CLANG_FORMAT_SKIP_DOCKER'] = 'true'
+ environ['CLANG_TIDY_SKIP_DOCKER'] = 'true'
+ return [
+ self.config.job_spec(
+ cmd['script'].split(),
+ timeout_seconds=30 * 60,
+ environ=environ,
+ cpu_cost=cmd.get('cpu_cost', 1)) for cmd in yaml.load(f)
+ ]
- def pre_build_steps(self):
- if self.platform == 'windows':
- return [['tools\\run_tests\\helper_scripts\\pre_build_node.bat']]
- else:
- return [['tools/run_tests/helper_scripts/pre_build_node.sh', self.node_version]]
+ def pre_build_steps(self):
+ return []
+
+ def make_targets(self):
+ return ['run_dep_checks']
- def make_targets(self):
- return []
+ def make_options(self):
+ return []
- def make_options(self):
- return []
+ def build_steps(self):
+ return []
- def build_steps(self):
- return []
+ def post_tests_steps(self):
+ return []
- def post_tests_steps(self):
- return []
+ def makefile_name(self):
+ return 'Makefile'
- def makefile_name(self):
- return 'Makefile'
+ def dockerfile_dir(self):
+ return 'tools/dockerfile/test/sanity'
- def dockerfile_dir(self):
- return 'tools/dockerfile/test/node_jessie_%s' % _docker_arch_suffix(self.args.arch)
+ def __str__(self):
+ return 'sanity'
- def __str__(self):
- return 'node_express'
# different configurations we can run under
with open('tools/run_tests/generated/configs.json') as f:
- _CONFIGS = dict((cfg['config'], Config(**cfg)) for cfg in ast.literal_eval(f.read()))
-
+ _CONFIGS = dict(
+ (cfg['config'], Config(**cfg)) for cfg in ast.literal_eval(f.read()))
_LANGUAGES = {
'c++': CLanguage('cxx', 'c++'),
'c': CLanguage('c', 'c'),
- 'node': NodeLanguage(),
- 'node_express': NodeExpressLanguage(),
+ 'grpc-node': RemoteNodeLanguage(),
'php': PhpLanguage(),
'php7': Php7Language(),
'python': PythonLanguage(),
'ruby': RubyLanguage(),
'csharp': CSharpLanguage(),
- 'objc' : ObjCLanguage(),
+ 'objc': ObjCLanguage(),
'sanity': Sanity()
- }
-
+}
_MSBUILD_CONFIG = {
'dbg': 'Debug',
'opt': 'Release',
'gcov': 'Debug',
- }
+}
def _windows_arch_option(arch):
- """Returns msbuild cmdline option for selected architecture."""
- if arch == 'default' or arch == 'x86':
- return '/p:Platform=Win32'
- elif arch == 'x64':
- return '/p:Platform=x64'
- else:
- print('Architecture %s not supported.' % arch)
- sys.exit(1)
+ """Returns msbuild cmdline option for selected architecture."""
+ if arch == 'default' or arch == 'x86':
+ return '/p:Platform=Win32'
+ elif arch == 'x64':
+ return '/p:Platform=x64'
+ else:
+ print('Architecture %s not supported.' % arch)
+ sys.exit(1)
def _check_arch_option(arch):
- """Checks that architecture option is valid."""
- if platform_string() == 'windows':
- _windows_arch_option(arch)
- elif platform_string() == 'linux':
- # On linux, we need to be running under docker with the right architecture.
- runtime_arch = platform.architecture()[0]
- if arch == 'default':
- return
- elif runtime_arch == '64bit' and arch == 'x64':
- return
- elif runtime_arch == '32bit' and arch == 'x86':
- return
+ """Checks that architecture option is valid."""
+ if platform_string() == 'windows':
+ _windows_arch_option(arch)
+ elif platform_string() == 'linux':
+ # On linux, we need to be running under docker with the right architecture.
+ runtime_arch = platform.architecture()[0]
+ if arch == 'default':
+ return
+ elif runtime_arch == '64bit' and arch == 'x64':
+ return
+ elif runtime_arch == '32bit' and arch == 'x86':
+ return
+ else:
+ print('Architecture %s does not match current runtime architecture.'
+ % arch)
+ sys.exit(1)
else:
- print('Architecture %s does not match current runtime architecture.' % arch)
- sys.exit(1)
- else:
- if args.arch != 'default':
- print('Architecture %s not supported on current platform.' % args.arch)
- sys.exit(1)
+ if args.arch != 'default':
+ print('Architecture %s not supported on current platform.' %
+ args.arch)
+ sys.exit(1)
def _docker_arch_suffix(arch):
- """Returns suffix to dockerfile dir to use."""
- if arch == 'default' or arch == 'x64':
- return 'x64'
- elif arch == 'x86':
- return 'x86'
- else:
- print('Architecture %s not supported with current settings.' % arch)
- sys.exit(1)
+ """Returns suffix to dockerfile dir to use."""
+ if arch == 'default' or arch == 'x64':
+ return 'x64'
+ elif arch == 'x86':
+ return 'x86'
+ else:
+ print('Architecture %s not supported with current settings.' % arch)
+ sys.exit(1)
def runs_per_test_type(arg_str):
@@ -1149,476 +1256,591 @@ def runs_per_test_type(arg_str):
def percent_type(arg_str):
- pct = float(arg_str)
- if pct > 100 or pct < 0:
- raise argparse.ArgumentTypeError(
- "'%f' is not a valid percentage in the [0, 100] range" % pct)
- return pct
+ pct = float(arg_str)
+ if pct > 100 or pct < 0:
+ raise argparse.ArgumentTypeError(
+ "'%f' is not a valid percentage in the [0, 100] range" % pct)
+ return pct
+
# This is math.isclose in python >= 3.5
def isclose(a, b, rel_tol=1e-09, abs_tol=0.0):
- return abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)
+ return abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)
# parse command line
argp = argparse.ArgumentParser(description='Run grpc tests.')
-argp.add_argument('-c', '--config',
- choices=sorted(_CONFIGS.keys()),
- default='opt')
-argp.add_argument('-n', '--runs_per_test', default=1, type=runs_per_test_type,
- help='A positive integer or "inf". If "inf", all tests will run in an '
- 'infinite loop. Especially useful in combination with "-f"')
+argp.add_argument(
+ '-c', '--config', choices=sorted(_CONFIGS.keys()), default='opt')
+argp.add_argument(
+ '-n',
+ '--runs_per_test',
+ default=1,
+ type=runs_per_test_type,
+ help='A positive integer or "inf". If "inf", all tests will run in an '
+ 'infinite loop. Especially useful in combination with "-f"')
argp.add_argument('-r', '--regex', default='.*', type=str)
argp.add_argument('--regex_exclude', default='', type=str)
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
argp.add_argument('-s', '--slowdown', default=1.0, type=float)
-argp.add_argument('-p', '--sample_percent', default=100.0, type=percent_type,
- help='Run a random sample with that percentage of tests')
-argp.add_argument('-f', '--forever',
- default=False,
- action='store_const',
- const=True)
-argp.add_argument('-t', '--travis',
- default=False,
- action='store_const',
- const=True)
-argp.add_argument('--newline_on_success',
- default=False,
- action='store_const',
- const=True)
-argp.add_argument('-l', '--language',
- choices=['all'] + sorted(_LANGUAGES.keys()),
- nargs='+',
- default=['all'])
-argp.add_argument('-S', '--stop_on_failure',
- default=False,
- action='store_const',
- const=True)
-argp.add_argument('--use_docker',
- default=False,
- action='store_const',
- const=True,
- help='Run all the tests under docker. That provides ' +
- 'additional isolation and prevents the need to install ' +
- 'language specific prerequisites. Only available on Linux.')
-argp.add_argument('--allow_flakes',
- default=False,
- action='store_const',
- const=True,
- help='Allow flaky tests to show as passing (re-runs failed tests up to five times)')
-argp.add_argument('--arch',
- choices=['default', 'x86', 'x64'],
- default='default',
- help='Selects architecture to target. For some platforms "default" is the only supported choice.')
-argp.add_argument('--compiler',
- choices=['default',
- 'gcc4.4', 'gcc4.6', 'gcc4.8', 'gcc4.9', 'gcc5.3', 'gcc_musl',
- 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7',
- 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'pypy', 'pypy3', 'python_alpine',
- 'node0.12', 'node4', 'node5', 'node6', 'node7', 'node8',
- 'electron1.3', 'electron1.6',
- 'coreclr',
- 'cmake', 'cmake_vs2015', 'cmake_vs2017'],
- default='default',
- help='Selects compiler to use. Allowed values depend on the platform and language.')
-argp.add_argument('--iomgr_platform',
- choices=['native', 'uv'],
- default='native',
- help='Selects iomgr platform to build on')
-argp.add_argument('--build_only',
- default=False,
- action='store_const',
- const=True,
- help='Perform all the build steps but don\'t run any tests.')
-argp.add_argument('--measure_cpu_costs', default=False, action='store_const', const=True,
- help='Measure the cpu costs of tests')
-argp.add_argument('--update_submodules', default=[], nargs='*',
- help='Update some submodules before building. If any are updated, also run generate_projects. ' +
- 'Submodules are specified as SUBMODULE_NAME:BRANCH; if BRANCH is omitted, master is assumed.')
+argp.add_argument(
+ '-p',
+ '--sample_percent',
+ default=100.0,
+ type=percent_type,
+ help='Run a random sample with that percentage of tests')
+argp.add_argument(
+ '-f', '--forever', default=False, action='store_const', const=True)
+argp.add_argument(
+ '-t', '--travis', default=False, action='store_const', const=True)
+argp.add_argument(
+ '--newline_on_success', default=False, action='store_const', const=True)
+argp.add_argument(
+ '-l',
+ '--language',
+ choices=['all'] + sorted(_LANGUAGES.keys()),
+ nargs='+',
+ default=['all'])
+argp.add_argument(
+ '-S', '--stop_on_failure', default=False, action='store_const', const=True)
+argp.add_argument(
+ '--use_docker',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run all the tests under docker. That provides ' +
+ 'additional isolation and prevents the need to install ' +
+ 'language specific prerequisites. Only available on Linux.')
+argp.add_argument(
+ '--allow_flakes',
+ default=False,
+ action='store_const',
+ const=True,
+ help=
+ 'Allow flaky tests to show as passing (re-runs failed tests up to five times)'
+)
+argp.add_argument(
+ '--arch',
+ choices=['default', 'x86', 'x64'],
+ default='default',
+ help=
+ 'Selects architecture to target. For some platforms "default" is the only supported choice.'
+)
+argp.add_argument(
+ '--compiler',
+ choices=[
+ 'default', 'gcc4.4', 'gcc4.6', 'gcc4.8', 'gcc4.9', 'gcc5.3', 'gcc7.2',
+ 'gcc_musl', 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7', 'python2.7',
+ 'python3.4', 'python3.5', 'python3.6', 'pypy', 'pypy3', 'python_alpine',
+ 'all_the_cpythons', 'electron1.3', 'electron1.6', 'coreclr', 'cmake',
+ 'cmake_vs2015', 'cmake_vs2017'
+ ],
+ default='default',
+ help=
+ 'Selects compiler to use. Allowed values depend on the platform and language.'
+)
+argp.add_argument(
+ '--iomgr_platform',
+ choices=['native', 'uv'],
+ default='native',
+ help='Selects iomgr platform to build on')
+argp.add_argument(
+ '--build_only',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Perform all the build steps but don\'t run any tests.')
+argp.add_argument(
+ '--measure_cpu_costs',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Measure the cpu costs of tests')
+argp.add_argument(
+ '--update_submodules',
+ default=[],
+ nargs='*',
+ help=
+ 'Update some submodules before building. If any are updated, also run generate_projects. '
+ +
+ 'Submodules are specified as SUBMODULE_NAME:BRANCH; if BRANCH is omitted, master is assumed.'
+)
argp.add_argument('-a', '--antagonists', default=0, type=int)
-argp.add_argument('-x', '--xml_report', default=None, type=str,
- help='Generates a JUnit-compatible XML report')
-argp.add_argument('--report_suite_name', default='tests', type=str,
- help='Test suite name to use in generated JUnit XML report')
-argp.add_argument('--quiet_success',
- default=False,
- action='store_const',
- const=True,
- help='Don\'t print anything when a test passes. Passing tests also will not be reported in XML report. ' +
- 'Useful when running many iterations of each test (argument -n).')
-argp.add_argument('--force_default_poller', default=False, action='store_const', const=True,
- help='Don\'t try to iterate over many polling strategies when they exist')
-argp.add_argument('--force_use_pollers', default=None, type=str,
- help='Only use the specified comma-delimited list of polling engines. '
- 'Example: --force_use_pollers epollsig,poll '
- ' (This flag has no effect if --force_default_poller flag is also used)')
-argp.add_argument('--max_time', default=-1, type=int, help='Maximum test runtime in seconds')
-argp.add_argument('--bq_result_table',
- default='',
- type=str,
- nargs='?',
- help='Upload test results to a specified BQ table.')
-argp.add_argument('--disable_auto_set_flakes', default=False, const=True, action='store_const',
- help='Disable rerunning historically flaky tests')
+argp.add_argument(
+ '-x',
+ '--xml_report',
+ default=None,
+ type=str,
+ help='Generates a JUnit-compatible XML report')
+argp.add_argument(
+ '--report_suite_name',
+ default='tests',
+ type=str,
+ help='Test suite name to use in generated JUnit XML report')
+argp.add_argument(
+ '--quiet_success',
+ default=False,
+ action='store_const',
+ const=True,
+ help=
+ 'Don\'t print anything when a test passes. Passing tests also will not be reported in XML report. '
+ + 'Useful when running many iterations of each test (argument -n).')
+argp.add_argument(
+ '--force_default_poller',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Don\'t try to iterate over many polling strategies when they exist')
+argp.add_argument(
+ '--force_use_pollers',
+ default=None,
+ type=str,
+ help='Only use the specified comma-delimited list of polling engines. '
+ 'Example: --force_use_pollers epollsig,poll '
+ ' (This flag has no effect if --force_default_poller flag is also used)')
+argp.add_argument(
+ '--max_time', default=-1, type=int, help='Maximum test runtime in seconds')
+argp.add_argument(
+ '--bq_result_table',
+ default='',
+ type=str,
+ nargs='?',
+ help='Upload test results to a specified BQ table.')
+argp.add_argument(
+ '--disable_auto_set_flakes',
+ default=False,
+ const=True,
+ action='store_const',
+ help='Disable rerunning historically flaky tests')
args = argp.parse_args()
flaky_tests = set()
shortname_to_cpu = {}
if not args.disable_auto_set_flakes:
- try:
- for test in get_bqtest_data():
- if test.flaky: flaky_tests.add(test.name)
- if test.cpu > 0: shortname_to_cpu[test.name] = test.cpu
- except:
- print("Unexpected error getting flaky tests:", sys.exc_info()[0])
+ try:
+ for test in get_bqtest_data():
+ if test.flaky: flaky_tests.add(test.name)
+ if test.cpu > 0: shortname_to_cpu[test.name] = test.cpu
+ except:
+ print(
+ "Unexpected error getting flaky tests: %s" % traceback.format_exc())
if args.force_default_poller:
- _POLLING_STRATEGIES = {}
+ _POLLING_STRATEGIES = {}
elif args.force_use_pollers:
- _POLLING_STRATEGIES[platform_string()] = args.force_use_pollers.split(',')
+ _POLLING_STRATEGIES[platform_string()] = args.force_use_pollers.split(',')
jobset.measure_cpu_costs = args.measure_cpu_costs
# update submodules if necessary
need_to_regenerate_projects = False
for spec in args.update_submodules:
- spec = spec.split(':', 1)
- if len(spec) == 1:
- submodule = spec[0]
- branch = 'master'
- elif len(spec) == 2:
- submodule = spec[0]
- branch = spec[1]
- cwd = 'third_party/%s' % submodule
- def git(cmd, cwd=cwd):
- print('in %s: git %s' % (cwd, cmd))
- run_shell_command('git %s' % cmd, cwd=cwd)
- git('fetch')
- git('checkout %s' % branch)
- git('pull origin %s' % branch)
- if os.path.exists('src/%s/gen_build_yaml.py' % submodule):
- need_to_regenerate_projects = True
+ spec = spec.split(':', 1)
+ if len(spec) == 1:
+ submodule = spec[0]
+ branch = 'master'
+ elif len(spec) == 2:
+ submodule = spec[0]
+ branch = spec[1]
+ cwd = 'third_party/%s' % submodule
+
+ def git(cmd, cwd=cwd):
+ print('in %s: git %s' % (cwd, cmd))
+ run_shell_command('git %s' % cmd, cwd=cwd)
+
+ git('fetch')
+ git('checkout %s' % branch)
+ git('pull origin %s' % branch)
+ if os.path.exists('src/%s/gen_build_yaml.py' % submodule):
+ need_to_regenerate_projects = True
if need_to_regenerate_projects:
- if jobset.platform_string() == 'linux':
- run_shell_command('tools/buildgen/generate_projects.sh')
- else:
- print('WARNING: may need to regenerate projects, but since we are not on')
- print(' Linux this step is being skipped. Compilation MAY fail.')
-
+ if jobset.platform_string() == 'linux':
+ run_shell_command('tools/buildgen/generate_projects.sh')
+ else:
+ print(
+ 'WARNING: may need to regenerate projects, but since we are not on')
+ print(
+ ' Linux this step is being skipped. Compilation MAY fail.')
# grab config
run_config = _CONFIGS[args.config]
build_config = run_config.build_config
if args.travis:
- _FORCE_ENVIRON_FOR_WRAPPERS = {'GRPC_TRACE': 'api'}
+ _FORCE_ENVIRON_FOR_WRAPPERS = {'GRPC_TRACE': 'api'}
if 'all' in args.language:
- lang_list = _LANGUAGES.keys()
+ lang_list = _LANGUAGES.keys()
else:
- lang_list = args.language
+ lang_list = args.language
# We don't support code coverage on some languages
if 'gcov' in args.config:
- for bad in ['objc', 'sanity']:
- if bad in lang_list:
- lang_list.remove(bad)
+ for bad in ['objc', 'sanity']:
+ if bad in lang_list:
+ lang_list.remove(bad)
languages = set(_LANGUAGES[l] for l in lang_list)
for l in languages:
- l.configure(run_config, args)
+ l.configure(run_config, args)
-language_make_options=[]
+language_make_options = []
if any(language.make_options() for language in languages):
- if not 'gcov' in args.config and len(languages) != 1:
- print('languages with custom make options cannot be built simultaneously with other languages')
- sys.exit(1)
- else:
- # Combining make options is not clean and just happens to work. It allows C/C++ and C# to build
- # together, and is only used under gcov. All other configs should build languages individually.
- language_make_options = list(set([make_option for lang in languages for make_option in lang.make_options()]))
+ if not 'gcov' in args.config and len(languages) != 1:
+ print(
+ 'languages with custom make options cannot be built simultaneously with other languages'
+ )
+ sys.exit(1)
+ else:
+ # Combining make options is not clean and just happens to work. It allows C/C++ and C# to build
+ # together, and is only used under gcov. All other configs should build languages individually.
+ language_make_options = list(
+ set([
+ make_option
+ for lang in languages
+ for make_option in lang.make_options()
+ ]))
if args.use_docker:
- if not args.travis:
- print('Seen --use_docker flag, will run tests under docker.')
- print('')
- print('IMPORTANT: The changes you are testing need to be locally committed')
- print('because only the committed changes in the current branch will be')
- print('copied to the docker environment.')
- time.sleep(5)
-
- dockerfile_dirs = set([l.dockerfile_dir() for l in languages])
- if len(dockerfile_dirs) > 1:
- if 'gcov' in args.config:
- dockerfile_dir = 'tools/dockerfile/test/multilang_jessie_x64'
- print ('Using multilang_jessie_x64 docker image for code coverage for '
- 'all languages.')
+ if not args.travis:
+ print('Seen --use_docker flag, will run tests under docker.')
+ print('')
+ print(
+ 'IMPORTANT: The changes you are testing need to be locally committed'
+ )
+ print(
+ 'because only the committed changes in the current branch will be')
+ print('copied to the docker environment.')
+ time.sleep(5)
+
+ dockerfile_dirs = set([l.dockerfile_dir() for l in languages])
+ if len(dockerfile_dirs) > 1:
+ if 'gcov' in args.config:
+ dockerfile_dir = 'tools/dockerfile/test/multilang_jessie_x64'
+ print(
+ 'Using multilang_jessie_x64 docker image for code coverage for '
+ 'all languages.')
+ else:
+ print(
+ 'Languages to be tested require running under different docker '
+ 'images.')
+ sys.exit(1)
else:
- print ('Languages to be tested require running under different docker '
- 'images.')
- sys.exit(1)
- else:
- dockerfile_dir = next(iter(dockerfile_dirs))
-
- child_argv = [ arg for arg in sys.argv if not arg == '--use_docker' ]
- run_tests_cmd = 'python tools/run_tests/run_tests.py %s' % ' '.join(child_argv[1:])
-
- env = os.environ.copy()
- env['RUN_TESTS_COMMAND'] = run_tests_cmd
- env['DOCKERFILE_DIR'] = dockerfile_dir
- env['DOCKER_RUN_SCRIPT'] = 'tools/run_tests/dockerize/docker_run_tests.sh'
- if args.xml_report:
- env['XML_REPORT'] = args.xml_report
- if not args.travis:
- env['TTY_FLAG'] = '-t' # enables Ctrl-C when not on Jenkins.
-
- subprocess.check_call('tools/run_tests/dockerize/build_docker_and_run_tests.sh',
- shell=True,
- env=env)
- sys.exit(0)
+ dockerfile_dir = next(iter(dockerfile_dirs))
+
+ child_argv = [arg for arg in sys.argv if not arg == '--use_docker']
+ run_tests_cmd = 'python tools/run_tests/run_tests.py %s' % ' '.join(
+ child_argv[1:])
+
+ env = os.environ.copy()
+ env['RUN_TESTS_COMMAND'] = run_tests_cmd
+ env['DOCKERFILE_DIR'] = dockerfile_dir
+ env['DOCKER_RUN_SCRIPT'] = 'tools/run_tests/dockerize/docker_run_tests.sh'
+ if args.xml_report:
+ env['XML_REPORT'] = args.xml_report
+ if not args.travis:
+ env['TTY_FLAG'] = '-t' # enables Ctrl-C when not on Jenkins.
+
+ subprocess.check_call(
+ 'tools/run_tests/dockerize/build_docker_and_run_tests.sh',
+ shell=True,
+ env=env)
+ sys.exit(0)
_check_arch_option(args.arch)
+
def make_jobspec(cfg, targets, makefile='Makefile'):
- if platform_string() == 'windows':
- return [jobset.JobSpec(['cmake', '--build', '.',
- '--target', '%s' % target,
- '--config', _MSBUILD_CONFIG[cfg]],
- cwd=os.path.dirname(makefile),
- timeout_seconds=None) for target in targets]
- else:
- if targets and makefile.startswith('cmake/build/'):
- # With cmake, we've passed all the build configuration in the pre-build step already
- return [jobset.JobSpec([os.getenv('MAKE', 'make'),
- '-j', '%d' % args.jobs] +
- targets,
- cwd='cmake/build',
- timeout_seconds=None)]
- if targets:
- return [jobset.JobSpec([os.getenv('MAKE', 'make'),
- '-f', makefile,
- '-j', '%d' % args.jobs,
- 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % args.slowdown,
- 'CONFIG=%s' % cfg,
- 'Q='] +
- language_make_options +
- ([] if not args.travis else ['JENKINS_BUILD=1']) +
- targets,
- timeout_seconds=None)]
+ if platform_string() == 'windows':
+ return [
+ jobset.JobSpec(
+ [
+ 'cmake', '--build', '.', '--target',
+ '%s' % target, '--config', _MSBUILD_CONFIG[cfg]
+ ],
+ cwd=os.path.dirname(makefile),
+ timeout_seconds=None) for target in targets
+ ]
else:
- return []
+ if targets and makefile.startswith('cmake/build/'):
+ # With cmake, we've passed all the build configuration in the pre-build step already
+ return [
+ jobset.JobSpec(
+ [os.getenv('MAKE', 'make'), '-j',
+ '%d' % args.jobs] + targets,
+ cwd='cmake/build',
+ timeout_seconds=None)
+ ]
+ if targets:
+ return [
+ jobset.JobSpec(
+ [
+ os.getenv('MAKE', 'make'), '-f', makefile, '-j',
+ '%d' % args.jobs,
+ 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' %
+ args.slowdown,
+ 'CONFIG=%s' % cfg, 'Q='
+ ] + language_make_options +
+ ([] if not args.travis else ['JENKINS_BUILD=1']) + targets,
+ timeout_seconds=None)
+ ]
+ else:
+ return []
+
make_targets = {}
for l in languages:
- makefile = l.makefile_name()
- make_targets[makefile] = make_targets.get(makefile, set()).union(
- set(l.make_targets()))
+ makefile = l.makefile_name()
+ make_targets[makefile] = make_targets.get(makefile, set()).union(
+ set(l.make_targets()))
+
def build_step_environ(cfg):
- environ = {'CONFIG': cfg}
- msbuild_cfg = _MSBUILD_CONFIG.get(cfg)
- if msbuild_cfg:
- environ['MSBUILD_CONFIG'] = msbuild_cfg
- return environ
-
-build_steps = list(set(
- jobset.JobSpec(cmdline, environ=build_step_environ(build_config), flake_retries=5)
- for l in languages
- for cmdline in l.pre_build_steps()))
+ environ = {'CONFIG': cfg}
+ msbuild_cfg = _MSBUILD_CONFIG.get(cfg)
+ if msbuild_cfg:
+ environ['MSBUILD_CONFIG'] = msbuild_cfg
+ return environ
+
+
+build_steps = list(
+ set(
+ jobset.JobSpec(
+ cmdline, environ=build_step_environ(build_config), flake_retries=2)
+ for l in languages
+ for cmdline in l.pre_build_steps()))
if make_targets:
- make_commands = itertools.chain.from_iterable(make_jobspec(build_config, list(targets), makefile) for (makefile, targets) in make_targets.items())
- build_steps.extend(set(make_commands))
-build_steps.extend(set(
- jobset.JobSpec(cmdline, environ=build_step_environ(build_config), timeout_seconds=None)
- for l in languages
- for cmdline in l.build_steps()))
-
-post_tests_steps = list(set(
- jobset.JobSpec(cmdline, environ=build_step_environ(build_config))
- for l in languages
- for cmdline in l.post_tests_steps()))
+ make_commands = itertools.chain.from_iterable(
+ make_jobspec(build_config, list(targets), makefile)
+ for (makefile, targets) in make_targets.items())
+ build_steps.extend(set(make_commands))
+build_steps.extend(
+ set(
+ jobset.JobSpec(
+ cmdline,
+ environ=build_step_environ(build_config),
+ timeout_seconds=None)
+ for l in languages
+ for cmdline in l.build_steps()))
+
+post_tests_steps = list(
+ set(
+ jobset.JobSpec(cmdline, environ=build_step_environ(build_config))
+ for l in languages
+ for cmdline in l.post_tests_steps()))
runs_per_test = args.runs_per_test
forever = args.forever
def _shut_down_legacy_server(legacy_server_port):
- try:
- version = int(urllib.request.urlopen(
- 'http://localhost:%d/version_number' % legacy_server_port,
- timeout=10).read())
- except:
- pass
- else:
- urllib.request.urlopen(
- 'http://localhost:%d/quitquitquit' % legacy_server_port).read()
+ try:
+ version = int(
+ urllib.request.urlopen(
+ 'http://localhost:%d/version_number' % legacy_server_port,
+ timeout=10).read())
+ except:
+ pass
+ else:
+ urllib.request.urlopen(
+ 'http://localhost:%d/quitquitquit' % legacy_server_port).read()
def _calculate_num_runs_failures(list_of_results):
- """Caculate number of runs and failures for a particular test.
+ """Caculate number of runs and failures for a particular test.
Args:
list_of_results: (List) of JobResult object.
Returns:
A tuple of total number of runs and failures.
"""
- num_runs = len(list_of_results) # By default, there is 1 run per JobResult.
- num_failures = 0
- for jobresult in list_of_results:
- if jobresult.retries > 0:
- num_runs += jobresult.retries
- if jobresult.num_failures > 0:
- num_failures += jobresult.num_failures
- return num_runs, num_failures
+ num_runs = len(list_of_results) # By default, there is 1 run per JobResult.
+ num_failures = 0
+ for jobresult in list_of_results:
+ if jobresult.retries > 0:
+ num_runs += jobresult.retries
+ if jobresult.num_failures > 0:
+ num_failures += jobresult.num_failures
+ return num_runs, num_failures
# _build_and_run results
class BuildAndRunError(object):
- BUILD = object()
- TEST = object()
- POST_TEST = object()
+ BUILD = object()
+ TEST = object()
+ POST_TEST = object()
def _has_epollexclusive():
- try:
- subprocess.check_call('bins/%s/check_epollexclusive' % args.config)
- return True
- except subprocess.CalledProcessError, e:
- return False
- except OSError, e:
- # For languages other than C and Windows the binary won't exist
- return False
+ binary = 'bins/%s/check_epollexclusive' % args.config
+ if not os.path.exists(binary):
+ return False
+ try:
+ subprocess.check_call(binary)
+ return True
+ except subprocess.CalledProcessError, e:
+ return False
+ except OSError, e:
+ # For languages other than C and Windows the binary won't exist
+ return False
# returns a list of things that failed (or an empty list on success)
-def _build_and_run(
- check_cancelled, newline_on_success, xml_report=None, build_only=False):
- """Do one pass of building & running tests."""
- # build latest sequentially
- num_failures, resultset = jobset.run(
- build_steps, maxjobs=1, stop_on_failure=True,
- newline_on_success=newline_on_success, travis=args.travis)
- if num_failures:
- return [BuildAndRunError.BUILD]
-
- if build_only:
- if xml_report:
- report_utils.render_junit_xml_report(resultset, xml_report,
- suite_name=args.report_suite_name)
- return []
-
- if not args.travis and not _has_epollexclusive() and platform_string() in _POLLING_STRATEGIES and 'epollex' in _POLLING_STRATEGIES[platform_string()]:
- print('\n\nOmitting EPOLLEXCLUSIVE tests\n\n')
- _POLLING_STRATEGIES[platform_string()].remove('epollex')
-
- # start antagonists
- antagonists = [subprocess.Popen(['tools/run_tests/python_utils/antagonist.py'])
- for _ in range(0, args.antagonists)]
- start_port_server.start_port_server()
- resultset = None
- num_test_failures = 0
- try:
- infinite_runs = runs_per_test == 0
- one_run = set(
- spec
- for language in languages
- for spec in language.test_specs()
- if (re.search(args.regex, spec.shortname) and
- (args.regex_exclude == '' or
- not re.search(args.regex_exclude, spec.shortname))))
- # When running on travis, we want out test runs to be as similar as possible
- # for reproducibility purposes.
- if args.travis and args.max_time <= 0:
- massaged_one_run = sorted(one_run, key=lambda x: x.cpu_cost)
- else:
- # whereas otherwise, we want to shuffle things up to give all tests a
- # chance to run.
- massaged_one_run = list(one_run) # random.sample needs an indexable seq.
- num_jobs = len(massaged_one_run)
- # for a random sample, get as many as indicated by the 'sample_percent'
- # argument. By default this arg is 100, resulting in a shuffle of all
- # jobs.
- sample_size = int(num_jobs * args.sample_percent/100.0)
- massaged_one_run = random.sample(massaged_one_run, sample_size)
- if not isclose(args.sample_percent, 100.0):
- assert args.runs_per_test == 1, "Can't do sampling (-p) over multiple runs (-n)."
- print("Running %d tests out of %d (~%d%%)" %
- (sample_size, num_jobs, args.sample_percent))
- if infinite_runs:
- assert len(massaged_one_run) > 0, 'Must have at least one test for a -n inf run'
- runs_sequence = (itertools.repeat(massaged_one_run) if infinite_runs
- else itertools.repeat(massaged_one_run, runs_per_test))
- all_runs = itertools.chain.from_iterable(runs_sequence)
-
- if args.quiet_success:
- jobset.message('START', 'Running tests quietly, only failing tests will be reported', do_newline=True)
- num_test_failures, resultset = jobset.run(
- all_runs, check_cancelled, newline_on_success=newline_on_success,
- travis=args.travis, maxjobs=args.jobs,
- stop_on_failure=args.stop_on_failure,
- quiet_success=args.quiet_success, max_time=args.max_time)
- if resultset:
- for k, v in sorted(resultset.items()):
- num_runs, num_failures = _calculate_num_runs_failures(v)
- if num_failures > 0:
- if num_failures == num_runs: # what about infinite_runs???
- jobset.message('FAILED', k, do_newline=True)
- else:
+def _build_and_run(check_cancelled,
+ newline_on_success,
+ xml_report=None,
+ build_only=False):
+ """Do one pass of building & running tests."""
+ # build latest sequentially
+ num_failures, resultset = jobset.run(
+ build_steps,
+ maxjobs=1,
+ stop_on_failure=True,
+ newline_on_success=newline_on_success,
+ travis=args.travis)
+ if num_failures:
+ return [BuildAndRunError.BUILD]
+
+ if build_only:
+ if xml_report:
+ report_utils.render_junit_xml_report(
+ resultset, xml_report, suite_name=args.report_suite_name)
+ return []
+
+ if not args.travis and not _has_epollexclusive() and platform_string(
+ ) in _POLLING_STRATEGIES and 'epollex' in _POLLING_STRATEGIES[platform_string(
+ )]:
+ print('\n\nOmitting EPOLLEXCLUSIVE tests\n\n')
+ _POLLING_STRATEGIES[platform_string()].remove('epollex')
+
+ # start antagonists
+ antagonists = [
+ subprocess.Popen(['tools/run_tests/python_utils/antagonist.py'])
+ for _ in range(0, args.antagonists)
+ ]
+ start_port_server.start_port_server()
+ resultset = None
+ num_test_failures = 0
+ try:
+ infinite_runs = runs_per_test == 0
+ one_run = set(
+ spec for language in languages for spec in language.test_specs()
+ if (re.search(args.regex, spec.shortname) and
+ (args.regex_exclude == '' or
+ not re.search(args.regex_exclude, spec.shortname))))
+ # When running on travis, we want out test runs to be as similar as possible
+ # for reproducibility purposes.
+ if args.travis and args.max_time <= 0:
+ massaged_one_run = sorted(one_run, key=lambda x: x.cpu_cost)
+ else:
+ # whereas otherwise, we want to shuffle things up to give all tests a
+ # chance to run.
+ massaged_one_run = list(
+ one_run) # random.sample needs an indexable seq.
+ num_jobs = len(massaged_one_run)
+ # for a random sample, get as many as indicated by the 'sample_percent'
+ # argument. By default this arg is 100, resulting in a shuffle of all
+ # jobs.
+ sample_size = int(num_jobs * args.sample_percent / 100.0)
+ massaged_one_run = random.sample(massaged_one_run, sample_size)
+ if not isclose(args.sample_percent, 100.0):
+ assert args.runs_per_test == 1, "Can't do sampling (-p) over multiple runs (-n)."
+ print("Running %d tests out of %d (~%d%%)" %
+ (sample_size, num_jobs, args.sample_percent))
+ if infinite_runs:
+ assert len(massaged_one_run
+ ) > 0, 'Must have at least one test for a -n inf run'
+ runs_sequence = (itertools.repeat(massaged_one_run)
+ if infinite_runs else itertools.repeat(
+ massaged_one_run, runs_per_test))
+ all_runs = itertools.chain.from_iterable(runs_sequence)
+
+ if args.quiet_success:
jobset.message(
- 'FLAKE', '%s [%d/%d runs flaked]' % (k, num_failures, num_runs),
+ 'START',
+ 'Running tests quietly, only failing tests will be reported',
do_newline=True)
- finally:
- for antagonist in antagonists:
- antagonist.kill()
- if args.bq_result_table and resultset:
- upload_results_to_bq(resultset, args.bq_result_table, args, platform_string())
- if xml_report and resultset:
- report_utils.render_junit_xml_report(resultset, xml_report,
- suite_name=args.report_suite_name)
+ num_test_failures, resultset = jobset.run(
+ all_runs,
+ check_cancelled,
+ newline_on_success=newline_on_success,
+ travis=args.travis,
+ maxjobs=args.jobs,
+ maxjobs_cpu_agnostic=max_parallel_tests_for_current_platform(),
+ stop_on_failure=args.stop_on_failure,
+ quiet_success=args.quiet_success,
+ max_time=args.max_time)
+ if resultset:
+ for k, v in sorted(resultset.items()):
+ num_runs, num_failures = _calculate_num_runs_failures(v)
+ if num_failures > 0:
+ if num_failures == num_runs: # what about infinite_runs???
+ jobset.message('FAILED', k, do_newline=True)
+ else:
+ jobset.message(
+ 'FLAKE',
+ '%s [%d/%d runs flaked]' % (k, num_failures,
+ num_runs),
+ do_newline=True)
+ finally:
+ for antagonist in antagonists:
+ antagonist.kill()
+ if args.bq_result_table and resultset:
+ upload_results_to_bq(resultset, args.bq_result_table, args,
+ platform_string())
+ if xml_report and resultset:
+ report_utils.render_junit_xml_report(
+ resultset, xml_report, suite_name=args.report_suite_name)
+
+ number_failures, _ = jobset.run(
+ post_tests_steps,
+ maxjobs=1,
+ stop_on_failure=False,
+ newline_on_success=newline_on_success,
+ travis=args.travis)
- number_failures, _ = jobset.run(
- post_tests_steps, maxjobs=1, stop_on_failure=True,
- newline_on_success=newline_on_success, travis=args.travis)
-
- out = []
- if number_failures:
- out.append(BuildAndRunError.POST_TEST)
- if num_test_failures:
- out.append(BuildAndRunError.TEST)
+ out = []
+ if number_failures:
+ out.append(BuildAndRunError.POST_TEST)
+ if num_test_failures:
+ out.append(BuildAndRunError.TEST)
- return out
+ return out
if forever:
- success = True
- while True:
- dw = watch_dirs.DirWatcher(['src', 'include', 'test', 'examples'])
- initial_time = dw.most_recent_change()
- have_files_changed = lambda: dw.most_recent_change() != initial_time
- previous_success = success
- errors = _build_and_run(check_cancelled=have_files_changed,
- newline_on_success=False,
- build_only=args.build_only) == 0
- if not previous_success and not errors:
- jobset.message('SUCCESS',
- 'All tests are now passing properly',
- do_newline=True)
- jobset.message('IDLE', 'No change detected')
- while not have_files_changed():
- time.sleep(1)
+ success = True
+ while True:
+ dw = watch_dirs.DirWatcher(['src', 'include', 'test', 'examples'])
+ initial_time = dw.most_recent_change()
+ have_files_changed = lambda: dw.most_recent_change() != initial_time
+ previous_success = success
+ errors = _build_and_run(
+ check_cancelled=have_files_changed,
+ newline_on_success=False,
+ build_only=args.build_only) == 0
+ if not previous_success and not errors:
+ jobset.message(
+ 'SUCCESS',
+ 'All tests are now passing properly',
+ do_newline=True)
+ jobset.message('IDLE', 'No change detected')
+ while not have_files_changed():
+ time.sleep(1)
else:
- errors = _build_and_run(check_cancelled=lambda: False,
- newline_on_success=args.newline_on_success,
- xml_report=args.xml_report,
- build_only=args.build_only)
- if not errors:
- jobset.message('SUCCESS', 'All tests passed', do_newline=True)
- else:
- jobset.message('FAILED', 'Some tests failed', do_newline=True)
- exit_code = 0
- if BuildAndRunError.BUILD in errors:
- exit_code |= 1
- if BuildAndRunError.TEST in errors:
- exit_code |= 2
- if BuildAndRunError.POST_TEST in errors:
- exit_code |= 4
- sys.exit(exit_code)
+ errors = _build_and_run(
+ check_cancelled=lambda: False,
+ newline_on_success=args.newline_on_success,
+ xml_report=args.xml_report,
+ build_only=args.build_only)
+ if not errors:
+ jobset.message('SUCCESS', 'All tests passed', do_newline=True)
+ else:
+ jobset.message('FAILED', 'Some tests failed', do_newline=True)
+ exit_code = 0
+ if BuildAndRunError.BUILD in errors:
+ exit_code |= 1
+ if BuildAndRunError.TEST in errors:
+ exit_code |= 2
+ if BuildAndRunError.POST_TEST in errors:
+ exit_code |= 4
+ sys.exit(exit_code)
diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py
index 2417c5ae55..433137a9bc 100755
--- a/tools/run_tests/run_tests_matrix.py
+++ b/tools/run_tests/run_tests_matrix.py
@@ -12,7 +12,6 @@
# 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.
-
"""Run test matrix."""
from __future__ import print_function
@@ -29,14 +28,14 @@ from python_utils.filter_pull_request_tests import filter_tests
_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
os.chdir(_ROOT)
-_DEFAULT_RUNTESTS_TIMEOUT = 1*60*60
+_DEFAULT_RUNTESTS_TIMEOUT = 1 * 60 * 60
# Set the timeout high to allow enough time for sanitizers and pre-building
# clang docker.
-_CPP_RUNTESTS_TIMEOUT = 4*60*60
+_CPP_RUNTESTS_TIMEOUT = 4 * 60 * 60
# C++ TSAN takes longer than other sanitizers
-_CPP_TSAN_RUNTESTS_TIMEOUT = 8*60*60
+_CPP_TSAN_RUNTESTS_TIMEOUT = 8 * 60 * 60
# Number of jobs assigned to each run_tests.py instance
_DEFAULT_INNER_JOBS = 2
@@ -45,485 +44,537 @@ _DEFAULT_INNER_JOBS = 2
_REPORT_SUFFIX = 'sponge_log.xml'
+def _safe_report_name(name):
+ """Reports with '+' in target name won't show correctly in ResultStore"""
+ return name.replace('+', 'p')
+
+
def _report_filename(name):
- """Generates report file name"""
- return 'report_%s_%s' % (name, _REPORT_SUFFIX)
+ """Generates report file name"""
+ return 'report_%s_%s' % (_safe_report_name(name), _REPORT_SUFFIX)
def _report_filename_internal_ci(name):
- """Generates report file name that leads to better presentation by internal CI"""
- return '%s/%s' % (name, _REPORT_SUFFIX)
+ """Generates report file name that leads to better presentation by internal CI"""
+ return '%s/%s' % (_safe_report_name(name), _REPORT_SUFFIX)
-def _docker_jobspec(name, runtests_args=[], runtests_envs={},
+def _docker_jobspec(name,
+ runtests_args=[],
+ runtests_envs={},
inner_jobs=_DEFAULT_INNER_JOBS,
timeout_seconds=None):
- """Run a single instance of run_tests.py in a docker container"""
- if not timeout_seconds:
- timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
- test_job = jobset.JobSpec(
- cmdline=['python', 'tools/run_tests/run_tests.py',
- '--use_docker',
- '-t',
- '-j', str(inner_jobs),
- '-x', _report_filename(name),
- '--report_suite_name', '%s' % name] + runtests_args,
- environ=runtests_envs,
- shortname='run_tests_%s' % name,
- timeout_seconds=timeout_seconds)
- return test_job
-
-
-def _workspace_jobspec(name, runtests_args=[], workspace_name=None,
- runtests_envs={}, inner_jobs=_DEFAULT_INNER_JOBS,
+ """Run a single instance of run_tests.py in a docker container"""
+ if not timeout_seconds:
+ timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
+ test_job = jobset.JobSpec(
+ cmdline=[
+ 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t',
+ '-j',
+ str(inner_jobs), '-x',
+ _report_filename(name), '--report_suite_name',
+ '%s' % _safe_report_name(name)
+ ] + runtests_args,
+ environ=runtests_envs,
+ shortname='run_tests_%s' % name,
+ timeout_seconds=timeout_seconds)
+ return test_job
+
+
+def _workspace_jobspec(name,
+ runtests_args=[],
+ workspace_name=None,
+ runtests_envs={},
+ inner_jobs=_DEFAULT_INNER_JOBS,
timeout_seconds=None):
- """Run a single instance of run_tests.py in a separate workspace"""
- if not workspace_name:
- workspace_name = 'workspace_%s' % name
- if not timeout_seconds:
- timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
- env = {'WORKSPACE_NAME': workspace_name}
- env.update(runtests_envs)
- test_job = jobset.JobSpec(
- cmdline=['bash',
- 'tools/run_tests/helper_scripts/run_tests_in_workspace.sh',
- '-t',
- '-j', str(inner_jobs),
- '-x', '../%s' % _report_filename(name),
- '--report_suite_name', '%s' % name] + runtests_args,
- environ=env,
- shortname='run_tests_%s' % name,
- timeout_seconds=timeout_seconds)
- return test_job
-
-
-def _generate_jobs(languages, configs, platforms, iomgr_platform = 'native',
- arch=None, compiler=None,
- labels=[], extra_args=[], extra_envs={},
- inner_jobs=_DEFAULT_INNER_JOBS,
- timeout_seconds=None):
- result = []
- for language in languages:
- for platform in platforms:
- for config in configs:
- name = '%s_%s_%s_%s' % (language, platform, config, iomgr_platform)
- runtests_args = ['-l', language,
- '-c', config,
- '--iomgr_platform', iomgr_platform]
- if arch or compiler:
- name += '_%s_%s' % (arch, compiler)
- runtests_args += ['--arch', arch,
- '--compiler', compiler]
- if '--build_only' in extra_args:
- name += '_buildonly'
- for extra_env in extra_envs:
- name += '_%s_%s' % (extra_env, extra_envs[extra_env])
-
- runtests_args += extra_args
- if platform == 'linux':
- job = _docker_jobspec(name=name, runtests_args=runtests_args,
- runtests_envs=extra_envs, inner_jobs=inner_jobs,
- timeout_seconds=timeout_seconds)
- else:
- job = _workspace_jobspec(name=name, runtests_args=runtests_args,
- runtests_envs=extra_envs, inner_jobs=inner_jobs,
- timeout_seconds=timeout_seconds)
-
- job.labels = [platform, config, language, iomgr_platform] + labels
- result.append(job)
- return result
+ """Run a single instance of run_tests.py in a separate workspace"""
+ if not workspace_name:
+ workspace_name = 'workspace_%s' % name
+ if not timeout_seconds:
+ timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
+ env = {'WORKSPACE_NAME': workspace_name}
+ env.update(runtests_envs)
+ test_job = jobset.JobSpec(
+ cmdline=[
+ 'bash', 'tools/run_tests/helper_scripts/run_tests_in_workspace.sh',
+ '-t', '-j',
+ str(inner_jobs), '-x',
+ '../%s' % _report_filename(name), '--report_suite_name',
+ '%s' % _safe_report_name(name)
+ ] + runtests_args,
+ environ=env,
+ shortname='run_tests_%s' % name,
+ timeout_seconds=timeout_seconds)
+ return test_job
+
+
+def _generate_jobs(languages,
+ configs,
+ platforms,
+ iomgr_platform='native',
+ arch=None,
+ compiler=None,
+ labels=[],
+ extra_args=[],
+ extra_envs={},
+ inner_jobs=_DEFAULT_INNER_JOBS,
+ timeout_seconds=None):
+ result = []
+ for language in languages:
+ for platform in platforms:
+ for config in configs:
+ name = '%s_%s_%s_%s' % (language, platform, config,
+ iomgr_platform)
+ runtests_args = [
+ '-l', language, '-c', config, '--iomgr_platform',
+ iomgr_platform
+ ]
+ if arch or compiler:
+ name += '_%s_%s' % (arch, compiler)
+ runtests_args += ['--arch', arch, '--compiler', compiler]
+ if '--build_only' in extra_args:
+ name += '_buildonly'
+ for extra_env in extra_envs:
+ name += '_%s_%s' % (extra_env, extra_envs[extra_env])
+
+ runtests_args += extra_args
+ if platform == 'linux':
+ job = _docker_jobspec(
+ name=name,
+ runtests_args=runtests_args,
+ runtests_envs=extra_envs,
+ inner_jobs=inner_jobs,
+ timeout_seconds=timeout_seconds)
+ else:
+ job = _workspace_jobspec(
+ name=name,
+ runtests_args=runtests_args,
+ runtests_envs=extra_envs,
+ inner_jobs=inner_jobs,
+ timeout_seconds=timeout_seconds)
+
+ job.labels = [platform, config, language, iomgr_platform
+ ] + labels
+ result.append(job)
+ return result
def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS):
- test_jobs = []
- # supported on linux only
- test_jobs += _generate_jobs(languages=['sanity', 'php7'],
- configs=['dbg', 'opt'],
- platforms=['linux'],
- labels=['basictests', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- # supported on all platforms.
- test_jobs += _generate_jobs(languages=['c'],
- configs=['dbg', 'opt'],
- platforms=['linux', 'macos', 'windows'],
- labels=['basictests', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
-
- test_jobs += _generate_jobs(languages=['csharp', 'node', 'python'],
- configs=['dbg', 'opt'],
- platforms=['linux', 'macos', 'windows'],
- labels=['basictests', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- # supported on linux and mac.
- test_jobs += _generate_jobs(languages=['c++'],
- configs=['dbg', 'opt'],
- platforms=['linux', 'macos'],
- labels=['basictests', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
-
- test_jobs += _generate_jobs(languages=['ruby', 'php'],
- configs=['dbg', 'opt'],
- platforms=['linux', 'macos'],
- labels=['basictests', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- # supported on mac only.
- test_jobs += _generate_jobs(languages=['objc'],
- configs=['dbg', 'opt'],
- platforms=['macos'],
- labels=['basictests', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- # sanitizers
- test_jobs += _generate_jobs(languages=['c'],
- configs=['msan', 'asan', 'tsan', 'ubsan'],
- platforms=['linux'],
- labels=['sanitizers', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
- test_jobs += _generate_jobs(languages=['c++'],
- configs=['asan'],
- platforms=['linux'],
- labels=['sanitizers', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
- test_jobs += _generate_jobs(languages=['c++'],
- configs=['tsan'],
- platforms=['linux'],
- labels=['sanitizers', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_TSAN_RUNTESTS_TIMEOUT)
-
- return test_jobs
-
-
-def _create_portability_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS):
- test_jobs = []
- # portability C x86
- test_jobs += _generate_jobs(languages=['c'],
- configs=['dbg'],
- platforms=['linux'],
- arch='x86',
- compiler='default',
- labels=['portability', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- # portability C and C++ on x64
- for compiler in ['gcc4.8', 'gcc5.3', 'gcc_musl',
- 'clang3.5', 'clang3.6', 'clang3.7']:
- test_jobs += _generate_jobs(languages=['c', 'c++'],
- configs=['dbg'],
- platforms=['linux'],
- arch='x64',
- compiler=compiler,
- labels=['portability', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
-
- # portability C on Windows 64-bit (x86 is the default)
- test_jobs += _generate_jobs(languages=['c'],
- configs=['dbg'],
- platforms=['windows'],
- arch='x64',
- compiler='default',
- labels=['portability', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- # portability C++ on Windows
- # TODO(jtattermusch): some of the tests are failing, so we force --build_only
- test_jobs += _generate_jobs(languages=['c++'],
- configs=['dbg'],
- platforms=['windows'],
- arch='default',
- compiler='default',
- labels=['portability', 'corelang'],
- extra_args=extra_args + ['--build_only'],
- inner_jobs=inner_jobs)
-
- # portability C and C++ on Windows using VS2017 (build only)
- # TODO(jtattermusch): some of the tests are failing, so we force --build_only
- test_jobs += _generate_jobs(languages=['c', 'c++'],
- configs=['dbg'],
- platforms=['windows'],
- arch='x64',
- compiler='cmake_vs2017',
- labels=['portability', 'corelang'],
- extra_args=extra_args + ['--build_only'],
- inner_jobs=inner_jobs)
-
- # C and C++ with the c-ares DNS resolver on Linux
- test_jobs += _generate_jobs(languages=['c', 'c++'],
- configs=['dbg'], platforms=['linux'],
- labels=['portability', 'corelang'],
- extra_args=extra_args,
- extra_envs={'GRPC_DNS_RESOLVER': 'ares'},
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
-
- # TODO(zyc): Turn on this test after adding c-ares support on windows.
- # C with the c-ares DNS resolver on Windows
- # test_jobs += _generate_jobs(languages=['c'],
- # configs=['dbg'], platforms=['windows'],
- # labels=['portability', 'corelang'],
- # extra_args=extra_args,
- # extra_envs={'GRPC_DNS_RESOLVER': 'ares'})
-
- # C and C++ build with cmake on Linux
- # TODO(jtattermusch): some of the tests are failing, so we force --build_only
- # to make sure it's buildable at least.
- test_jobs += _generate_jobs(languages=['c', 'c++'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='cmake',
- labels=['portability', 'corelang'],
- extra_args=extra_args + ['--build_only'],
- inner_jobs=inner_jobs)
-
- test_jobs += _generate_jobs(languages=['python'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='python_alpine',
- labels=['portability', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- test_jobs += _generate_jobs(languages=['csharp'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='coreclr',
- labels=['portability', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- test_jobs += _generate_jobs(languages=['c'],
- configs=['dbg'],
- platforms=['linux'],
- iomgr_platform='uv',
- labels=['portability', 'corelang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs,
- timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
-
- test_jobs += _generate_jobs(languages=['node'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='electron1.6',
- labels=['portability', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- test_jobs += _generate_jobs(languages=['node'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='node4',
- labels=['portability', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- test_jobs += _generate_jobs(languages=['node'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='node6',
- labels=['portability', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- test_jobs += _generate_jobs(languages=['node'],
- configs=['dbg'],
- platforms=['linux'],
- arch='default',
- compiler='node7',
- labels=['portability', 'multilang'],
- extra_args=extra_args,
- inner_jobs=inner_jobs)
-
- return test_jobs
+ test_jobs = []
+ # supported on linux only
+ test_jobs += _generate_jobs(
+ languages=['sanity', 'php7'],
+ configs=['dbg', 'opt'],
+ platforms=['linux'],
+ labels=['basictests', 'multilang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ # supported on all platforms.
+ test_jobs += _generate_jobs(
+ languages=['c'],
+ configs=['dbg', 'opt'],
+ platforms=['linux', 'macos', 'windows'],
+ labels=['basictests', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+
+ test_jobs += _generate_jobs(
+ languages=['csharp', 'python'],
+ configs=['dbg', 'opt'],
+ platforms=['linux', 'macos', 'windows'],
+ labels=['basictests', 'multilang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ # supported on linux and mac.
+ test_jobs += _generate_jobs(
+ languages=['c++'],
+ configs=['dbg', 'opt'],
+ platforms=['linux', 'macos'],
+ labels=['basictests', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+
+ test_jobs += _generate_jobs(
+ languages=['grpc-node', 'ruby', 'php'],
+ configs=['dbg', 'opt'],
+ platforms=['linux', 'macos'],
+ labels=['basictests', 'multilang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ # supported on mac only.
+ test_jobs += _generate_jobs(
+ languages=['objc'],
+ configs=['dbg', 'opt'],
+ platforms=['macos'],
+ labels=['basictests', 'multilang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ # sanitizers
+ test_jobs += _generate_jobs(
+ languages=['c'],
+ configs=['msan', 'asan', 'tsan', 'ubsan'],
+ platforms=['linux'],
+ labels=['sanitizers', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+ test_jobs += _generate_jobs(
+ languages=['c++'],
+ configs=['asan'],
+ platforms=['linux'],
+ labels=['sanitizers', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+ test_jobs += _generate_jobs(
+ languages=['c++'],
+ configs=['tsan'],
+ platforms=['linux'],
+ labels=['sanitizers', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_TSAN_RUNTESTS_TIMEOUT)
+
+ return test_jobs
+
+
+def _create_portability_test_jobs(extra_args=[],
+ inner_jobs=_DEFAULT_INNER_JOBS):
+ test_jobs = []
+ # portability C x86
+ test_jobs += _generate_jobs(
+ languages=['c'],
+ configs=['dbg'],
+ platforms=['linux'],
+ arch='x86',
+ compiler='default',
+ labels=['portability', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ # portability C and C++ on x64
+ for compiler in [
+ 'gcc4.8', 'gcc5.3', 'gcc7.2', 'gcc_musl', 'clang3.5', 'clang3.6',
+ 'clang3.7'
+ ]:
+ test_jobs += _generate_jobs(
+ languages=['c', 'c++'],
+ configs=['dbg'],
+ platforms=['linux'],
+ arch='x64',
+ compiler=compiler,
+ labels=['portability', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+
+ # portability C on Windows 64-bit (x86 is the default)
+ test_jobs += _generate_jobs(
+ languages=['c'],
+ configs=['dbg'],
+ platforms=['windows'],
+ arch='x64',
+ compiler='default',
+ labels=['portability', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ # portability C++ on Windows
+ # TODO(jtattermusch): some of the tests are failing, so we force --build_only
+ test_jobs += _generate_jobs(
+ languages=['c++'],
+ configs=['dbg'],
+ platforms=['windows'],
+ arch='default',
+ compiler='default',
+ labels=['portability', 'corelang'],
+ extra_args=extra_args + ['--build_only'],
+ inner_jobs=inner_jobs)
+
+ # portability C and C++ on Windows using VS2017 (build only)
+ # TODO(jtattermusch): some of the tests are failing, so we force --build_only
+ test_jobs += _generate_jobs(
+ languages=['c', 'c++'],
+ configs=['dbg'],
+ platforms=['windows'],
+ arch='x64',
+ compiler='cmake_vs2017',
+ labels=['portability', 'corelang'],
+ extra_args=extra_args + ['--build_only'],
+ inner_jobs=inner_jobs)
+
+ # C and C++ with the c-ares DNS resolver on Linux
+ test_jobs += _generate_jobs(
+ languages=['c', 'c++'],
+ configs=['dbg'],
+ platforms=['linux'],
+ labels=['portability', 'corelang'],
+ extra_args=extra_args,
+ extra_envs={'GRPC_DNS_RESOLVER': 'ares'},
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+
+ # C and C++ with no-exceptions on Linux
+ test_jobs += _generate_jobs(
+ languages=['c', 'c++'],
+ configs=['noexcept'],
+ platforms=['linux'],
+ labels=['portability', 'corelang'],
+ extra_args=extra_args,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+
+ # TODO(zyc): Turn on this test after adding c-ares support on windows.
+ # C with the c-ares DNS resolver on Windows
+ # test_jobs += _generate_jobs(languages=['c'],
+ # configs=['dbg'], platforms=['windows'],
+ # labels=['portability', 'corelang'],
+ # extra_args=extra_args,
+ # extra_envs={'GRPC_DNS_RESOLVER': 'ares'})
+
+ # C and C++ build with cmake on Linux
+ # TODO(jtattermusch): some of the tests are failing, so we force --build_only
+ # to make sure it's buildable at least.
+ test_jobs += _generate_jobs(
+ languages=['c', 'c++'],
+ configs=['dbg'],
+ platforms=['linux'],
+ arch='default',
+ compiler='cmake',
+ labels=['portability', 'corelang'],
+ extra_args=extra_args + ['--build_only'],
+ inner_jobs=inner_jobs)
+
+ test_jobs += _generate_jobs(
+ languages=['python'],
+ configs=['dbg'],
+ platforms=['linux'],
+ arch='default',
+ compiler='python_alpine',
+ labels=['portability', 'multilang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ test_jobs += _generate_jobs(
+ languages=['csharp'],
+ configs=['dbg'],
+ platforms=['linux'],
+ arch='default',
+ compiler='coreclr',
+ labels=['portability', 'multilang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
+
+ test_jobs += _generate_jobs(
+ languages=['c'],
+ configs=['dbg'],
+ platforms=['linux'],
+ iomgr_platform='uv',
+ labels=['portability', 'corelang'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs,
+ timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
+
+ return test_jobs
def _allowed_labels():
- """Returns a list of existing job labels."""
- all_labels = set()
- for job in _create_test_jobs() + _create_portability_test_jobs():
- for label in job.labels:
- all_labels.add(label)
- return sorted(all_labels)
+ """Returns a list of existing job labels."""
+ all_labels = set()
+ for job in _create_test_jobs() + _create_portability_test_jobs():
+ for label in job.labels:
+ all_labels.add(label)
+ return sorted(all_labels)
def _runs_per_test_type(arg_str):
- """Auxiliary function to parse the "runs_per_test" flag."""
- try:
- n = int(arg_str)
- if n <= 0: raise ValueError
- return n
- except:
- msg = '\'{}\' is not a positive integer'.format(arg_str)
- raise argparse.ArgumentTypeError(msg)
+ """Auxiliary function to parse the "runs_per_test" flag."""
+ try:
+ n = int(arg_str)
+ if n <= 0: raise ValueError
+ return n
+ except:
+ msg = '\'{}\' is not a positive integer'.format(arg_str)
+ raise argparse.ArgumentTypeError(msg)
if __name__ == "__main__":
- argp = argparse.ArgumentParser(description='Run a matrix of run_tests.py tests.')
- argp.add_argument('-j', '--jobs',
- default=multiprocessing.cpu_count()/_DEFAULT_INNER_JOBS,
- type=int,
- help='Number of concurrent run_tests.py instances.')
- argp.add_argument('-f', '--filter',
- choices=_allowed_labels(),
- nargs='+',
- default=[],
- help='Filter targets to run by label with AND semantics.')
- argp.add_argument('--exclude',
- choices=_allowed_labels(),
- nargs='+',
- default=[],
- help='Exclude targets with any of given labels.')
- argp.add_argument('--build_only',
- default=False,
- action='store_const',
- const=True,
- help='Pass --build_only flag to run_tests.py instances.')
- argp.add_argument('--force_default_poller', default=False, action='store_const', const=True,
- help='Pass --force_default_poller to run_tests.py instances.')
- argp.add_argument('--dry_run',
- default=False,
- action='store_const',
- const=True,
- help='Only print what would be run.')
- argp.add_argument('--filter_pr_tests',
- default=False,
- action='store_const',
- const=True,
- help='Filters out tests irrelevant to pull request changes.')
- argp.add_argument('--base_branch',
- default='origin/master',
- type=str,
- help='Branch that pull request is requesting to merge into')
- argp.add_argument('--inner_jobs',
- default=_DEFAULT_INNER_JOBS,
- type=int,
- help='Number of jobs in each run_tests.py instance')
- argp.add_argument('-n', '--runs_per_test', default=1, type=_runs_per_test_type,
- help='How many times to run each tests. >1 runs implies ' +
- 'omitting passing test from the output & reports.')
- argp.add_argument('--max_time', default=-1, type=int,
- help='Maximum amount of time to run tests for' +
- '(other tests will be skipped)')
- argp.add_argument('--internal_ci',
- default=False,
- action='store_const',
- const=True,
- help='Put reports into subdirectories to improve presentation of '
- 'results by Internal CI.')
- argp.add_argument('--bq_result_table',
- default='',
- type=str,
- nargs='?',
- help='Upload test results to a specified BQ table.')
- args = argp.parse_args()
-
- if args.internal_ci:
- _report_filename = _report_filename_internal_ci # override the function
-
- extra_args = []
- if args.build_only:
- extra_args.append('--build_only')
- if args.force_default_poller:
- extra_args.append('--force_default_poller')
- if args.runs_per_test > 1:
- extra_args.append('-n')
- extra_args.append('%s' % args.runs_per_test)
- extra_args.append('--quiet_success')
- if args.max_time > 0:
- extra_args.extend(('--max_time', '%d' % args.max_time))
- if args.bq_result_table:
- extra_args.append('--bq_result_table')
- extra_args.append('%s' % args.bq_result_table)
- extra_args.append('--measure_cpu_costs')
- extra_args.append('--disable_auto_set_flakes')
-
- all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \
- _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs)
-
- jobs = []
- for job in all_jobs:
- if not args.filter or all(filter in job.labels for filter in args.filter):
- if not any(exclude_label in job.labels for exclude_label in args.exclude):
- jobs.append(job)
-
- if not jobs:
- jobset.message('FAILED', 'No test suites match given criteria.',
- do_newline=True)
- sys.exit(1)
-
- print('IMPORTANT: The changes you are testing need to be locally committed')
- print('because only the committed changes in the current branch will be')
- print('copied to the docker environment or into subworkspaces.')
-
- skipped_jobs = []
-
- if args.filter_pr_tests:
- print('Looking for irrelevant tests to skip...')
- relevant_jobs = filter_tests(jobs, args.base_branch)
- if len(relevant_jobs) == len(jobs):
- print('No tests will be skipped.')
- else:
- print('These tests will be skipped:')
- skipped_jobs = list(set(jobs) - set(relevant_jobs))
- # Sort by shortnames to make printing of skipped tests consistent
- skipped_jobs.sort(key=lambda job: job.shortname)
- for job in list(skipped_jobs):
- print(' %s' % job.shortname)
- jobs = relevant_jobs
-
- print('Will run these tests:')
- for job in jobs:
+ argp = argparse.ArgumentParser(
+ description='Run a matrix of run_tests.py tests.')
+ argp.add_argument(
+ '-j',
+ '--jobs',
+ default=multiprocessing.cpu_count() / _DEFAULT_INNER_JOBS,
+ type=int,
+ help='Number of concurrent run_tests.py instances.')
+ argp.add_argument(
+ '-f',
+ '--filter',
+ choices=_allowed_labels(),
+ nargs='+',
+ default=[],
+ help='Filter targets to run by label with AND semantics.')
+ argp.add_argument(
+ '--exclude',
+ choices=_allowed_labels(),
+ nargs='+',
+ default=[],
+ help='Exclude targets with any of given labels.')
+ argp.add_argument(
+ '--build_only',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Pass --build_only flag to run_tests.py instances.')
+ argp.add_argument(
+ '--force_default_poller',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Pass --force_default_poller to run_tests.py instances.')
+ argp.add_argument(
+ '--dry_run',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Only print what would be run.')
+ argp.add_argument(
+ '--filter_pr_tests',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Filters out tests irrelevant to pull request changes.')
+ argp.add_argument(
+ '--base_branch',
+ default='origin/master',
+ type=str,
+ help='Branch that pull request is requesting to merge into')
+ argp.add_argument(
+ '--inner_jobs',
+ default=_DEFAULT_INNER_JOBS,
+ type=int,
+ help='Number of jobs in each run_tests.py instance')
+ argp.add_argument(
+ '-n',
+ '--runs_per_test',
+ default=1,
+ type=_runs_per_test_type,
+ help='How many times to run each tests. >1 runs implies ' +
+ 'omitting passing test from the output & reports.')
+ argp.add_argument(
+ '--max_time',
+ default=-1,
+ type=int,
+ help='Maximum amount of time to run tests for' +
+ '(other tests will be skipped)')
+ argp.add_argument(
+ '--internal_ci',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Put reports into subdirectories to improve presentation of '
+ 'results by Internal CI.')
+ argp.add_argument(
+ '--bq_result_table',
+ default='',
+ type=str,
+ nargs='?',
+ help='Upload test results to a specified BQ table.')
+ args = argp.parse_args()
+
+ if args.internal_ci:
+ _report_filename = _report_filename_internal_ci # override the function
+
+ extra_args = []
+ if args.build_only:
+ extra_args.append('--build_only')
+ if args.force_default_poller:
+ extra_args.append('--force_default_poller')
+ if args.runs_per_test > 1:
+ extra_args.append('-n')
+ extra_args.append('%s' % args.runs_per_test)
+ extra_args.append('--quiet_success')
+ if args.max_time > 0:
+ extra_args.extend(('--max_time', '%d' % args.max_time))
+ if args.bq_result_table:
+ extra_args.append('--bq_result_table')
+ extra_args.append('%s' % args.bq_result_table)
+ extra_args.append('--measure_cpu_costs')
+ extra_args.append('--disable_auto_set_flakes')
+
+ all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \
+ _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs)
+
+ jobs = []
+ for job in all_jobs:
+ if not args.filter or all(
+ filter in job.labels for filter in args.filter):
+ if not any(exclude_label in job.labels
+ for exclude_label in args.exclude):
+ jobs.append(job)
+
+ if not jobs:
+ jobset.message(
+ 'FAILED', 'No test suites match given criteria.', do_newline=True)
+ sys.exit(1)
+
+ print('IMPORTANT: The changes you are testing need to be locally committed')
+ print('because only the committed changes in the current branch will be')
+ print('copied to the docker environment or into subworkspaces.')
+
+ skipped_jobs = []
+
+ if args.filter_pr_tests:
+ print('Looking for irrelevant tests to skip...')
+ relevant_jobs = filter_tests(jobs, args.base_branch)
+ if len(relevant_jobs) == len(jobs):
+ print('No tests will be skipped.')
+ else:
+ print('These tests will be skipped:')
+ skipped_jobs = list(set(jobs) - set(relevant_jobs))
+ # Sort by shortnames to make printing of skipped tests consistent
+ skipped_jobs.sort(key=lambda job: job.shortname)
+ for job in list(skipped_jobs):
+ print(' %s' % job.shortname)
+ jobs = relevant_jobs
+
+ print('Will run these tests:')
+ for job in jobs:
+ if args.dry_run:
+ print(' %s: "%s"' % (job.shortname, ' '.join(job.cmdline)))
+ else:
+ print(' %s' % job.shortname)
+ print
+
if args.dry_run:
- print(' %s: "%s"' % (job.shortname, ' '.join(job.cmdline)))
+ print('--dry_run was used, exiting')
+ sys.exit(1)
+
+ jobset.message('START', 'Running test matrix.', do_newline=True)
+ num_failures, resultset = jobset.run(
+ jobs, newline_on_success=True, travis=True, maxjobs=args.jobs)
+ # Merge skipped tests into results to show skipped tests on report.xml
+ if skipped_jobs:
+ ignored_num_skipped_failures, skipped_results = jobset.run(
+ skipped_jobs, skip_jobs=True)
+ resultset.update(skipped_results)
+ report_utils.render_junit_xml_report(
+ resultset,
+ _report_filename('aggregate_tests'),
+ suite_name='aggregate_tests')
+
+ if num_failures == 0:
+ jobset.message(
+ 'SUCCESS',
+ 'All run_tests.py instance finished successfully.',
+ do_newline=True)
else:
- print(' %s' % job.shortname)
- print
-
- if args.dry_run:
- print('--dry_run was used, exiting')
- sys.exit(1)
-
- jobset.message('START', 'Running test matrix.', do_newline=True)
- num_failures, resultset = jobset.run(jobs,
- newline_on_success=True,
- travis=True,
- maxjobs=args.jobs)
- # Merge skipped tests into results to show skipped tests on report.xml
- if skipped_jobs:
- ignored_num_skipped_failures, skipped_results = jobset.run(
- skipped_jobs, skip_jobs=True)
- resultset.update(skipped_results)
- report_utils.render_junit_xml_report(resultset, _report_filename('aggregate_tests'),
- suite_name='aggregate_tests')
-
- if num_failures == 0:
- jobset.message('SUCCESS', 'All run_tests.py instance finished successfully.',
- do_newline=True)
- else:
- jobset.message('FAILED', 'Some run_tests.py instance have failed.',
- do_newline=True)
- sys.exit(1)
+ jobset.message(
+ 'FAILED',
+ 'Some run_tests.py instance have failed.',
+ do_newline=True)
+ sys.exit(1)
diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py
new file mode 100755
index 0000000000..62a6229c5d
--- /dev/null
+++ b/tools/run_tests/sanity/check_bazel_workspace.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+
+# 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.
+
+from __future__ import print_function
+
+import ast
+import os
+import re
+import subprocess
+import sys
+
+os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
+
+git_hash_pattern = re.compile('[0-9a-f]{40}')
+
+# Parse git hashes from submodules
+git_submodules = subprocess.check_output(
+ 'git submodule', shell=True).strip().split('\n')
+git_submodule_hashes = {
+ re.search(git_hash_pattern, s).group()
+ for s in git_submodules
+}
+
+_BAZEL_TOOLCHAINS_DEP_NAME = 'com_github_bazelbuild_bazeltoolchains'
+
+_GRPC_DEP_NAMES = [
+ 'boringssl',
+ 'com_github_madler_zlib',
+ 'com_google_protobuf',
+ 'com_github_google_googletest',
+ 'com_github_gflags_gflags',
+ 'com_github_google_benchmark',
+ 'com_github_cares_cares',
+ 'com_google_absl',
+ _BAZEL_TOOLCHAINS_DEP_NAME,
+]
+
+
+class BazelEvalState(object):
+
+ def __init__(self, names_and_urls, overridden_name=None):
+ self.names_and_urls = names_and_urls
+ self.overridden_name = overridden_name
+
+ def http_archive(self, **args):
+ self.archive(**args)
+
+ def new_http_archive(self, **args):
+ self.archive(**args)
+
+ def bind(self, **args):
+ pass
+
+ def existing_rules(self):
+ if self.overridden_name:
+ return [self.overridden_name]
+ return []
+
+ def archive(self, **args):
+ if args['name'] == _BAZEL_TOOLCHAINS_DEP_NAME:
+ self.names_and_urls[args['name']] = 'dont care'
+ return
+ self.names_and_urls[args['name']] = args['url']
+
+
+# Parse git hashes from bazel/grpc_deps.bzl {new_}http_archive rules
+with open(os.path.join('bazel', 'grpc_deps.bzl'), 'r') as f:
+ names_and_urls = {}
+ eval_state = BazelEvalState(names_and_urls)
+ bazel_file = f.read()
+
+# grpc_deps.bzl only defines 'grpc_deps', add this to call it
+bazel_file += '\ngrpc_deps()\n'
+build_rules = {
+ 'native': eval_state,
+}
+exec bazel_file in build_rules
+for name in _GRPC_DEP_NAMES:
+ assert name in names_and_urls.keys()
+assert len(_GRPC_DEP_NAMES) == len(names_and_urls.keys())
+
+# bazeltoolschains is an exception to this sanity check,
+# we don't require that there is a corresponding git module.
+names_without_bazeltoolchains = names_and_urls.keys()
+names_without_bazeltoolchains.remove(_BAZEL_TOOLCHAINS_DEP_NAME)
+archive_urls = [names_and_urls[name] for name in names_without_bazeltoolchains]
+workspace_git_hashes = {
+ re.search(git_hash_pattern, url).group()
+ for url in archive_urls
+}
+if len(workspace_git_hashes) == 0:
+ print("(Likely) parse error, did not find any bazel git dependencies.")
+ sys.exit(1)
+
+# Validate the equivalence of the git submodules and Bazel git dependencies. The
+# condition we impose is that there is a git submodule for every dependency in
+# the workspace, but not necessarily conversely. E.g. Bloaty is a dependency
+# not used by any of the targets built by Bazel.
+if len(workspace_git_hashes - git_submodule_hashes) > 0:
+ print(
+ "Found discrepancies between git submodules and Bazel WORKSPACE dependencies"
+ )
+ sys.exit(1)
+
+# Also check that we can override each dependency
+for name in _GRPC_DEP_NAMES:
+ names_and_urls_with_overridden_name = {}
+ state = BazelEvalState(
+ names_and_urls_with_overridden_name, overridden_name=name)
+ rules = {
+ 'native': state,
+ }
+ exec bazel_file in rules
+ assert name not in names_and_urls_with_overridden_name.keys()
+
+sys.exit(0)
diff --git a/tools/run_tests/sanity/check_owners.sh b/tools/run_tests/sanity/check_owners.sh
index b681fed1bb..de0e092578 100755
--- a/tools/run_tests/sanity/check_owners.sh
+++ b/tools/run_tests/sanity/check_owners.sh
@@ -18,12 +18,12 @@ set -e
export TEST=true
-cd `dirname $0`/../../..
+cd "$(dirname "$0")/../../.."
owners=.github/CODEOWNERS
-want_owners=`mktemp /tmp/submXXXXXX`
+want_owners=$(mktemp /tmp/submXXXXXX)
-tools/mkowners/mkowners.py -o $want_owners
-diff -u $owners $want_owners
+tools/mkowners/mkowners.py -o "$want_owners"
+diff -u "$owners" "$want_owners"
-rm $want_owners
+rm "$want_owners"
diff --git a/tools/run_tests/sanity/check_shellcheck.sh b/tools/run_tests/sanity/check_shellcheck.sh
new file mode 100755
index 0000000000..64f59cb40e
--- /dev/null
+++ b/tools/run_tests/sanity/check_shellcheck.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# 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.
+
+
+set -e
+
+ROOT="$(dirname "$0")/../../.."
+
+DIRS=(
+ 'tools/run_tests'
+)
+
+for dir in "${DIRS[@]}"; do
+ find "$ROOT/$dir/" -name "*.sh" -type f -print0 | xargs -n1 -0 shellcheck
+done
diff --git a/tools/run_tests/sanity/check_sources_and_headers.py b/tools/run_tests/sanity/check_sources_and_headers.py
index c27a0b79e9..57ae5c5acc 100755
--- a/tools/run_tests/sanity/check_sources_and_headers.py
+++ b/tools/run_tests/sanity/check_sources_and_headers.py
@@ -21,70 +21,106 @@ import re
import sys
root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
-with open(os.path.join(root, 'tools', 'run_tests', 'generated', 'sources_and_headers.json')) as f:
- js = json.loads(f.read())
+with open(
+ os.path.join(root, 'tools', 'run_tests', 'generated',
+ 'sources_and_headers.json')) as f:
+ js = json.loads(f.read())
re_inc1 = re.compile(r'^#\s*include\s*"([^"]*)"')
assert re_inc1.match('#include "foo"').group(1) == 'foo'
re_inc2 = re.compile(r'^#\s*include\s*<((grpc|grpc\+\+)/[^"]*)>')
assert re_inc2.match('#include <grpc++/foo>').group(1) == 'grpc++/foo'
+
def get_target(name):
- for target in js:
- if target['name'] == name:
- return target
- assert False, 'no target %s' % name
+ for target in js:
+ if target['name'] == name:
+ return target
+ assert False, 'no target %s' % name
+
+
+def get_headers_transitive():
+ """Computes set of headers transitively provided by each target"""
+ target_headers_transitive = {}
+ for target in js:
+ target_name = target['name']
+ assert not target_headers_transitive.has_key(target_name)
+ target_headers_transitive[target_name] = set(target['headers'])
+
+ # Make sure each target's transitive headers contain those
+ # of their dependencies. If not, add them and continue doing
+ # so until we get a full pass over all targets without any updates.
+ closure_changed = True
+ while closure_changed:
+ closure_changed = False
+ for target in js:
+ target_name = target['name']
+ for dep in target['deps']:
+ headers = target_headers_transitive[target_name]
+ old_count = len(headers)
+ headers.update(target_headers_transitive[dep])
+ if old_count != len(headers):
+ closure_changed = True
+ return target_headers_transitive
+
+
+# precompute transitive closure of headers provided by each target
+target_headers_transitive = get_headers_transitive()
+
def target_has_header(target, name):
- # print target['name'], name
- if name in target['headers']:
- return True
- for dep in target['deps']:
- if target_has_header(get_target(dep), name):
- return True
- if name in ['src/core/lib/profiling/stap_probes.h',
- 'src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h']:
- return True
- return False
+ if name in target_headers_transitive[target['name']]:
+ return True
+ if name.startswith('absl/'):
+ return True
+ if name in [
+ 'src/core/lib/profiling/stap_probes.h',
+ 'src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h'
+ ]:
+ return True
+ return False
+
def produces_object(name):
- return os.path.splitext(name)[1] in ['.c', '.cc']
+ return os.path.splitext(name)[1] in ['.c', '.cc']
+
c_ish = {}
obj_producer_to_source = {'c': c_ish, 'c++': c_ish, 'csharp': {}}
errors = 0
for target in js:
- if not target['third_party']:
- for fn in target['src']:
- with open(os.path.join(root, fn)) as f:
- src = f.read().splitlines()
- for line in src:
- m = re_inc1.match(line)
- if m:
- if not target_has_header(target, m.group(1)):
- print (
- 'target %s (%s) does not name header %s as a dependency' % (
- target['name'], fn, m.group(1)))
- errors += 1
- m = re_inc2.match(line)
- if m:
- if not target_has_header(target, 'include/' + m.group(1)):
- print (
- 'target %s (%s) does not name header %s as a dependency' % (
- target['name'], fn, m.group(1)))
- errors += 1
- if target['type'] in ['lib', 'filegroup']:
- for fn in target['src']:
- language = target['language']
- if produces_object(fn):
- obj_base = os.path.splitext(os.path.basename(fn))[0]
- if obj_base in obj_producer_to_source[language]:
- if obj_producer_to_source[language][obj_base] != fn:
- print (
- 'target %s (%s) produces an aliased object file with %s' % (
- target['name'], fn, obj_producer_to_source[language][obj_base]))
- else:
- obj_producer_to_source[language][obj_base] = fn
+ if not target['third_party']:
+ for fn in target['src']:
+ with open(os.path.join(root, fn)) as f:
+ src = f.read().splitlines()
+ for line in src:
+ m = re_inc1.match(line)
+ if m:
+ if not target_has_header(target, m.group(1)):
+ print(
+ 'target %s (%s) does not name header %s as a dependency'
+ % (target['name'], fn, m.group(1)))
+ errors += 1
+ m = re_inc2.match(line)
+ if m:
+ if not target_has_header(target, 'include/' + m.group(1)):
+ print(
+ 'target %s (%s) does not name header %s as a dependency'
+ % (target['name'], fn, m.group(1)))
+ errors += 1
+ if target['type'] in ['lib', 'filegroup']:
+ for fn in target['src']:
+ language = target['language']
+ if produces_object(fn):
+ obj_base = os.path.splitext(os.path.basename(fn))[0]
+ if obj_base in obj_producer_to_source[language]:
+ if obj_producer_to_source[language][obj_base] != fn:
+ print(
+ 'target %s (%s) produces an aliased object file with %s'
+ % (target['name'], fn,
+ obj_producer_to_source[language][obj_base]))
+ else:
+ obj_producer_to_source[language][obj_base] = fn
assert errors == 0
diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh
index 7c934b1ba7..ca604c6e52 100755
--- a/tools/run_tests/sanity/check_submodules.sh
+++ b/tools/run_tests/sanity/check_submodules.sh
@@ -19,23 +19,25 @@ set -e
export TEST=true
-cd `dirname $0`/../../..
+cd "$(dirname "$0")/../../.."
-submodules=`mktemp /tmp/submXXXXXX`
-want_submodules=`mktemp /tmp/submXXXXXX`
+submodules=$(mktemp /tmp/submXXXXXX)
+want_submodules=$(mktemp /tmp/submXXXXXX)
-git submodule | awk '{ print $1 }' | sort > $submodules
-cat << EOF | awk '{ print $1 }' | sort > $want_submodules
- 44c25c892a6229b20db7cd9dc05584ea865896de third_party/benchmark (v0.1.0-343-g44c25c8)
+git submodule | awk '{ print $1 }' | sort > "$submodules"
+cat << EOF | awk '{ print $1 }' | sort > "$want_submodules"
+ 5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8 third_party/benchmark (v1.2.0)
be2ee342d3781ddb954f91f8a7e660c6f59e87e5 third_party/boringssl (heads/chromium-stable)
886e7d75368e3f4fab3f4d0d3584e4abfc557755 third_party/boringssl-with-bazel (version_for_cocoapods_7.0-857-g886e7d7)
30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e third_party/gflags (v2.2.0)
ec44c6c1675c25b9827aacd08c02433cccde7780 third_party/googletest (release-1.8.0)
- 80a37e0782d2d702d52234b62dd4b9ec74fd2c95 third_party/protobuf (v3.4.0)
+ 2761122b810fe8861004ae785cc3ab39f384d342 third_party/protobuf (v3.5.0)
cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11)
3be1924221e1326df520f8498d704a5c4c8d0cce third_party/cares/cares (cares-1_13_0)
+ 73594cde8c9a52a102c4341c244c833aa61b9c06 third_party/bloaty
+ cc4bed2d74f7c8717e31f9579214ab52a9c9c610 third_party/abseil-cpp
EOF
-diff -u $submodules $want_submodules
+diff -u "$submodules" "$want_submodules"
-rm $submodules $want_submodules
+rm "$submodules" "$want_submodules"
diff --git a/tools/run_tests/sanity/check_test_filtering.py b/tools/run_tests/sanity/check_test_filtering.py
index bea8125fb9..ebbb1a93b3 100755
--- a/tools/run_tests/sanity/check_test_filtering.py
+++ b/tools/run_tests/sanity/check_test_filtering.py
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
import os
import sys
import unittest
@@ -25,110 +24,139 @@ sys.path.insert(0, os.path.abspath('tools/run_tests/'))
from run_tests_matrix import _create_test_jobs, _create_portability_test_jobs
import python_utils.filter_pull_request_tests as filter_pull_request_tests
-_LIST_OF_LANGUAGE_LABELS = ['c', 'c++', 'csharp', 'node', 'objc', 'php', 'php7', 'python', 'ruby']
+_LIST_OF_LANGUAGE_LABELS = [
+ 'c', 'c++', 'csharp', 'grpc-node', 'objc', 'php', 'php7', 'python', 'ruby'
+]
_LIST_OF_PLATFORM_LABELS = ['linux', 'macos', 'windows']
+
class TestFilteringTest(unittest.TestCase):
- def generate_all_tests(self):
- all_jobs = _create_test_jobs() + _create_portability_test_jobs()
- self.assertIsNotNone(all_jobs)
- return all_jobs
+ def generate_all_tests(self):
+ all_jobs = _create_test_jobs() + _create_portability_test_jobs()
+ self.assertIsNotNone(all_jobs)
+ return all_jobs
- def test_filtering(self, changed_files=[], labels=_LIST_OF_LANGUAGE_LABELS):
- """
+ def test_filtering(self, changed_files=[], labels=_LIST_OF_LANGUAGE_LABELS):
+ """
Default args should filter no tests because changed_files is empty and
default labels should be able to match all jobs
:param changed_files: mock list of changed_files from pull request
:param labels: list of job labels that should be skipped
"""
- all_jobs = self.generate_all_tests()
- # Replacing _get_changed_files function to allow specifying changed files in filter_tests function
- def _get_changed_files(foo):
- return changed_files
- filter_pull_request_tests._get_changed_files = _get_changed_files
- print()
- filtered_jobs = filter_pull_request_tests.filter_tests(all_jobs, "test")
-
- # Make sure sanity tests aren't being filtered out
- sanity_tests_in_all_jobs = 0
- sanity_tests_in_filtered_jobs = 0
- for job in all_jobs:
- if "sanity" in job.labels:
- sanity_tests_in_all_jobs += 1
- all_jobs = [job for job in all_jobs if "sanity" not in job.labels]
- for job in filtered_jobs:
- if "sanity" in job.labels:
- sanity_tests_in_filtered_jobs += 1
- filtered_jobs = [job for job in filtered_jobs if "sanity" not in job.labels]
- self.assertEquals(sanity_tests_in_all_jobs, sanity_tests_in_filtered_jobs)
-
- for label in labels:
- for job in filtered_jobs:
- self.assertNotIn(label, job.labels)
-
- jobs_matching_labels = 0
- for label in labels:
- for job in all_jobs:
- if (label in job.labels):
- jobs_matching_labels += 1
- self.assertEquals(len(filtered_jobs), len(all_jobs) - jobs_matching_labels)
-
- def test_individual_language_filters(self):
- # Changing unlisted file should trigger all languages
- self.test_filtering(['ffffoo/bar.baz'], [_LIST_OF_LANGUAGE_LABELS])
- # Changing core should trigger all tests
- self.test_filtering(['src/core/foo.bar'], [_LIST_OF_LANGUAGE_LABELS])
- # Testing individual languages
- self.test_filtering(['test/core/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CORE_TEST_SUITE.labels])
- self.test_filtering(['src/cpp/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CPP_TEST_SUITE.labels])
- self.test_filtering(['src/csharp/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CSHARP_TEST_SUITE.labels])
- self.test_filtering(['src/node/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._NODE_TEST_SUITE.labels])
- self.test_filtering(['src/objective-c/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._OBJC_TEST_SUITE.labels])
- self.test_filtering(['src/php/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._PHP_TEST_SUITE.labels])
- self.test_filtering(['src/python/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._PYTHON_TEST_SUITE.labels])
- self.test_filtering(['src/ruby/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._RUBY_TEST_SUITE.labels])
-
- def test_combined_language_filters(self):
- self.test_filtering(['src/cpp/foo.bar', 'test/core/foo.bar'],
- [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CPP_TEST_SUITE.labels and label not in
- filter_pull_request_tests._CORE_TEST_SUITE.labels])
- self.test_filtering(['src/node/foo.bar', 'src/cpp/foo.bar', "src/csharp/foo.bar"],
- [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._NODE_TEST_SUITE.labels and label not in
- filter_pull_request_tests._CPP_TEST_SUITE.labels and label not in
- filter_pull_request_tests._CSHARP_TEST_SUITE.labels])
- self.test_filtering(['src/objective-c/foo.bar', 'src/php/foo.bar', "src/python/foo.bar", "src/ruby/foo.bar"],
- [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._OBJC_TEST_SUITE.labels and label not in
- filter_pull_request_tests._PHP_TEST_SUITE.labels and label not in
- filter_pull_request_tests._PYTHON_TEST_SUITE.labels and label not in
- filter_pull_request_tests._RUBY_TEST_SUITE.labels])
-
- def test_platform_filter(self):
- self.test_filtering(['vsprojects/foo.bar'], [label for label in _LIST_OF_PLATFORM_LABELS if label not in
- filter_pull_request_tests._WINDOWS_TEST_SUITE.labels])
-
- def test_whitelist(self):
- whitelist = filter_pull_request_tests._WHITELIST_DICT
- files_that_should_trigger_all_tests = ['src/core/foo.bar',
- 'some_file_not_on_the_white_list',
- 'BUILD',
- 'etc/roots.pem',
- 'Makefile',
- 'tools/foo']
- for key in whitelist.keys():
- for file_name in files_that_should_trigger_all_tests:
- self.assertFalse(re.match(key, file_name))
+ all_jobs = self.generate_all_tests()
+
+ # Replacing _get_changed_files function to allow specifying changed files in filter_tests function
+ def _get_changed_files(foo):
+ return changed_files
+
+ filter_pull_request_tests._get_changed_files = _get_changed_files
+ print()
+ filtered_jobs = filter_pull_request_tests.filter_tests(all_jobs, "test")
+
+ # Make sure sanity tests aren't being filtered out
+ sanity_tests_in_all_jobs = 0
+ sanity_tests_in_filtered_jobs = 0
+ for job in all_jobs:
+ if "sanity" in job.labels:
+ sanity_tests_in_all_jobs += 1
+ all_jobs = [job for job in all_jobs if "sanity" not in job.labels]
+ for job in filtered_jobs:
+ if "sanity" in job.labels:
+ sanity_tests_in_filtered_jobs += 1
+ filtered_jobs = [
+ job for job in filtered_jobs if "sanity" not in job.labels
+ ]
+ self.assertEquals(sanity_tests_in_all_jobs,
+ sanity_tests_in_filtered_jobs)
+
+ for label in labels:
+ for job in filtered_jobs:
+ self.assertNotIn(label, job.labels)
+
+ jobs_matching_labels = 0
+ for label in labels:
+ for job in all_jobs:
+ if (label in job.labels):
+ jobs_matching_labels += 1
+ self.assertEquals(
+ len(filtered_jobs),
+ len(all_jobs) - jobs_matching_labels)
+
+ def test_individual_language_filters(self):
+ # Changing unlisted file should trigger all languages
+ self.test_filtering(['ffffoo/bar.baz'], [_LIST_OF_LANGUAGE_LABELS])
+ # Changing core should trigger all tests
+ self.test_filtering(['src/core/foo.bar'], [_LIST_OF_LANGUAGE_LABELS])
+ # Testing individual languages
+ self.test_filtering(['test/core/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CORE_TEST_SUITE.labels +
+ filter_pull_request_tests._CPP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/cpp/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CPP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/csharp/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CSHARP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/objective-c/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._OBJC_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/php/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._PHP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/python/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._PYTHON_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/ruby/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._RUBY_TEST_SUITE.labels
+ ])
+
+ def test_combined_language_filters(self):
+ self.test_filtering(['src/cpp/foo.bar', 'test/core/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CPP_TEST_SUITE.labels and
+ label not in filter_pull_request_tests._CORE_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/cpp/foo.bar', "src/csharp/foo.bar"], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CPP_TEST_SUITE.labels and
+ label not in filter_pull_request_tests._CSHARP_TEST_SUITE.labels
+ ])
+ self.test_filtering([
+ 'src/objective-c/foo.bar', 'src/php/foo.bar', "src/python/foo.bar",
+ "src/ruby/foo.bar"
+ ], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._OBJC_TEST_SUITE.labels
+ and label not in filter_pull_request_tests._PHP_TEST_SUITE.labels
+ and label not in filter_pull_request_tests._PYTHON_TEST_SUITE.labels
+ and label not in filter_pull_request_tests._RUBY_TEST_SUITE.labels
+ ])
+
+ def test_platform_filter(self):
+ self.test_filtering(['vsprojects/foo.bar'], [
+ label for label in _LIST_OF_PLATFORM_LABELS
+ if label not in filter_pull_request_tests._WINDOWS_TEST_SUITE.labels
+ ])
+
+ def test_whitelist(self):
+ whitelist = filter_pull_request_tests._WHITELIST_DICT
+ files_that_should_trigger_all_tests = [
+ 'src/core/foo.bar', 'some_file_not_on_the_white_list', 'BUILD',
+ 'etc/roots.pem', 'Makefile', 'tools/foo'
+ ]
+ for key in whitelist.keys():
+ for file_name in files_that_should_trigger_all_tests:
+ self.assertFalse(re.match(key, file_name))
+
if __name__ == '__main__':
- unittest.main(verbosity=2)
+ unittest.main(verbosity=2)
diff --git a/tools/run_tests/sanity/check_tracer_sanity.py b/tools/run_tests/sanity/check_tracer_sanity.py
index 997ec79d02..c4c76530de 100755
--- a/tools/run_tests/sanity/check_tracer_sanity.py
+++ b/tools/run_tests/sanity/check_tracer_sanity.py
@@ -26,21 +26,22 @@ errors = 0
tracers = []
pattern = re.compile("GRPC_TRACER_INITIALIZER\((true|false), \"(.*)\"\)")
for root, dirs, files in os.walk('src/core'):
- for filename in files:
- path = os.path.join(root, filename)
- if os.path.splitext(path)[1] != '.c': continue
- with open(path) as f:
- text = f.read()
- for o in pattern.findall(text):
- tracers.append(o[1])
+ for filename in files:
+ path = os.path.join(root, filename)
+ if os.path.splitext(path)[1] != '.c': continue
+ with open(path) as f:
+ text = f.read()
+ for o in pattern.findall(text):
+ tracers.append(o[1])
with open('doc/environment_variables.md') as f:
- text = f.read()
+ text = f.read()
for t in tracers:
if t not in text:
- print("ERROR: tracer \"%s\" is not mentioned in doc/environment_variables.md" % t)
+ print(
+ "ERROR: tracer \"%s\" is not mentioned in doc/environment_variables.md"
+ % t)
errors += 1
-
assert errors == 0
diff --git a/tools/run_tests/sanity/check_unsecure.sh b/tools/run_tests/sanity/check_unsecure.sh
new file mode 100755
index 0000000000..cca1235479
--- /dev/null
+++ b/tools/run_tests/sanity/check_unsecure.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# 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.
+
+set -e
+
+# Make sure that there is no path from known unsecure libraries and targets
+# to an SSL library. Any failure among these will make the script fail.
+
+test "$(bazel query 'somepath("//:grpc_unsecure", "//external:libssl")' 2>/dev/null | wc -l)" -eq 0 || exit 1
+test "$(bazel query 'somepath("//:grpc++_unsecure", "//external:libssl")' 2>/dev/null | wc -l)" -eq 0 || exit 1
+test "$(bazel query 'somepath("//:grpc++_codegen_proto", "//external:libssl")' 2>/dev/null | wc -l)" -eq 0 || exit 1
+test "$(bazel query 'somepath("//test/cpp/microbenchmarks:helpers", "//external:libssl")' 2>/dev/null | wc -l)" -eq 0 || exit 1
+
+exit 0
+
diff --git a/tools/run_tests/sanity/check_version.py b/tools/run_tests/sanity/check_version.py
index b9b6bab26d..6154b2603e 100755
--- a/tools/run_tests/sanity/check_version.py
+++ b/tools/run_tests/sanity/check_version.py
@@ -31,56 +31,56 @@ sys.path.insert(0, os.path.abspath('tools/buildgen/plugins'))
from expand_version import Version
try:
- branch_name = subprocess.check_output(
- 'git rev-parse --abbrev-ref HEAD',
- shell=True)
+ branch_name = subprocess.check_output(
+ 'git rev-parse --abbrev-ref HEAD', shell=True)
except:
- print('WARNING: not a git repository')
- branch_name = None
+ print('WARNING: not a git repository')
+ branch_name = None
if branch_name is not None:
- m = re.match(r'^release-([0-9]+)_([0-9]+)$', branch_name)
- if m:
- print('RELEASE branch')
- # version number should align with the branched version
- check_version = lambda version: (
- version.major == int(m.group(1)) and
- version.minor == int(m.group(2)))
- warning = 'Version key "%%s" value "%%s" should have a major version %s and minor version %s' % (m.group(1), m.group(2))
- elif re.match(r'^debian/.*$', branch_name):
- # no additional version checks for debian branches
- check_version = lambda version: True
- else:
- # all other branches should have a -dev tag
- check_version = lambda version: version.tag == 'dev'
- warning = 'Version key "%s" value "%s" should have a -dev tag'
+ m = re.match(r'^release-([0-9]+)_([0-9]+)$', branch_name)
+ if m:
+ print('RELEASE branch')
+ # version number should align with the branched version
+ check_version = lambda version: (
+ version.major == int(m.group(1)) and
+ version.minor == int(m.group(2)))
+ warning = 'Version key "%%s" value "%%s" should have a major version %s and minor version %s' % (
+ m.group(1), m.group(2))
+ elif re.match(r'^debian/.*$', branch_name):
+ # no additional version checks for debian branches
+ check_version = lambda version: True
+ else:
+ # all other branches should have a -dev tag
+ check_version = lambda version: version.tag == 'dev'
+ warning = 'Version key "%s" value "%s" should have a -dev tag'
else:
- check_version = lambda version: True
+ check_version = lambda version: True
with open('build.yaml', 'r') as f:
- build_yaml = yaml.load(f.read())
+ build_yaml = yaml.load(f.read())
settings = build_yaml['settings']
top_version = Version(settings['version'])
if not check_version(top_version):
- errors += 1
- print(warning % ('version', top_version))
+ errors += 1
+ print(warning % ('version', top_version))
for tag, value in settings.iteritems():
- if re.match(r'^[a-z]+_version$', tag):
- value = Version(value)
- if tag != 'core_version':
- if value.major != top_version.major:
- errors += 1
- print('major version mismatch on %s: %d vs %d' % (tag, value.major,
- top_version.major))
- if value.minor != top_version.minor:
- errors += 1
- print('minor version mismatch on %s: %d vs %d' % (tag, value.minor,
- top_version.minor))
- if not check_version(value):
- errors += 1
- print(warning % (tag, value))
+ if re.match(r'^[a-z]+_version$', tag):
+ value = Version(value)
+ if tag != 'core_version':
+ if value.major != top_version.major:
+ errors += 1
+ print('major version mismatch on %s: %d vs %d' %
+ (tag, value.major, top_version.major))
+ if value.minor != top_version.minor:
+ errors += 1
+ print('minor version mismatch on %s: %d vs %d' %
+ (tag, value.minor, top_version.minor))
+ if not check_version(value):
+ errors += 1
+ print(warning % (tag, value))
sys.exit(errors)
diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py
index 1f13905484..989990542e 100755
--- a/tools/run_tests/sanity/core_banned_functions.py
+++ b/tools/run_tests/sanity/core_banned_functions.py
@@ -36,26 +36,28 @@ BANNED_EXCEPT = {
'grpc_wsa_error(': ['src/core/lib/iomgr/error.c'],
'grpc_log_if_error(': ['src/core/lib/iomgr/error.c'],
'grpc_slice_malloc(': ['src/core/lib/slice/slice.c'],
- 'grpc_closure_create(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_init(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_sched(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_run(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_list_sched(' : ['src/core/lib/iomgr/closure.c'],
- 'gpr_getenv_silent(' : ['src/core/lib/support/log.c', 'src/core/lib/support/env_linux.c',
- 'src/core/lib/support/env_posix.c', 'src/core/lib/support/env_windows.c'],
+ 'grpc_closure_create(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_init(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_sched(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_run(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_list_sched(': ['src/core/lib/iomgr/closure.c'],
+ 'gpr_getenv_silent(': [
+ 'src/core/lib/gpr/log.c', 'src/core/lib/gpr/env_linux.c',
+ 'src/core/lib/gpr/env_posix.c', 'src/core/lib/gpr/env_windows.c'
+ ],
}
errors = 0
for root, dirs, files in os.walk('src/core'):
- for filename in files:
- path = os.path.join(root, filename)
- if os.path.splitext(path)[1] != '.c': continue
- with open(path) as f:
- text = f.read()
- for banned, exceptions in BANNED_EXCEPT.items():
- if path in exceptions: continue
- if banned in text:
- print('Illegal use of "%s" in %s' % (banned, path))
- errors += 1
+ for filename in files:
+ path = os.path.join(root, filename)
+ if os.path.splitext(path)[1] != '.c': continue
+ with open(path) as f:
+ text = f.read()
+ for banned, exceptions in BANNED_EXCEPT.items():
+ if path in exceptions: continue
+ if banned in text:
+ print('Illegal use of "%s" in %s' % (banned, path))
+ errors += 1
assert errors == 0
diff --git a/tools/run_tests/sanity/core_untyped_structs.sh b/tools/run_tests/sanity/core_untyped_structs.sh
index 792dd68fdd..af319096fd 100755
--- a/tools/run_tests/sanity/core_untyped_structs.sh
+++ b/tools/run_tests/sanity/core_untyped_structs.sh
@@ -15,7 +15,7 @@
set -e
-cd `dirname $0`/../../..
+cd "$(dirname "$0")/../../.."
#
# Make sure that all core struct/unions have a name or are typedef'ed
diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml
index 4bc4b7c56f..efdb4d84b5 100644
--- a/tools/run_tests/sanity/sanity_tests.yaml
+++ b/tools/run_tests/sanity/sanity_tests.yaml
@@ -1,20 +1,24 @@
# a set of tests that are run in parallel for sanity tests
+- script: tools/run_tests/sanity/check_bazel_workspace.py
- script: tools/run_tests/sanity/check_cache_mk.sh
- script: tools/run_tests/sanity/check_owners.sh
- script: tools/run_tests/sanity/check_sources_and_headers.py
+- script: tools/run_tests/sanity/check_shellcheck.sh
- script: tools/run_tests/sanity/check_submodules.sh
- script: tools/run_tests/sanity/check_test_filtering.py
- script: tools/run_tests/sanity/check_tracer_sanity.py
+- script: tools/run_tests/sanity/check_unsecure.sh
- script: tools/run_tests/sanity/core_banned_functions.py
- script: tools/run_tests/sanity/core_untyped_structs.sh
- script: tools/buildgen/generate_projects.sh -j 3
cpu_cost: 3
- script: tools/distrib/check_copyright.py
- script: tools/distrib/clang_format_code.sh
+- script: tools/distrib/clang_tidy_code.sh
- script: tools/distrib/check_trailing_newlines.sh
- script: tools/distrib/check_nanopb_output.sh
- script: tools/distrib/check_include_guards.py
- script: tools/distrib/pylint_code.sh
- script: tools/distrib/yapf_code.sh
- script: tools/distrib/python/check_grpcio_tools.py
-
+ cpu_cost: 1000
diff --git a/tools/run_tests/start_port_server.py b/tools/run_tests/start_port_server.py
index 362875036f..0eeceb4ce9 100755
--- a/tools/run_tests/start_port_server.py
+++ b/tools/run_tests/start_port_server.py
@@ -13,7 +13,6 @@
# 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.
-
"""
Wrapper around port server starting code.
diff --git a/tools/run_tests/task_runner.py b/tools/run_tests/task_runner.py
index a065bb84cb..794db6e1be 100755
--- a/tools/run_tests/task_runner.py
+++ b/tools/run_tests/task_runner.py
@@ -12,7 +12,6 @@
# 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.
-
"""Runs selected gRPC test/build tasks."""
from __future__ import print_function
@@ -32,52 +31,54 @@ _TARGETS += artifact_targets.targets()
_TARGETS += distribtest_targets.targets()
_TARGETS += package_targets.targets()
+
def _create_build_map():
- """Maps task names and labels to list of tasks to be built."""
- target_build_map = dict([(target.name, [target])
- for target in _TARGETS])
- if len(_TARGETS) > len(target_build_map.keys()):
- raise Exception('Target names need to be unique')
-
- label_build_map = {}
- label_build_map['all'] = [t for t in _TARGETS] # to build all targets
- for target in _TARGETS:
- for label in target.labels:
- if label in label_build_map:
- label_build_map[label].append(target)
- else:
- label_build_map[label] = [target]
-
- if set(target_build_map.keys()).intersection(label_build_map.keys()):
- raise Exception('Target names need to be distinct from label names')
- return dict( target_build_map.items() + label_build_map.items())
+ """Maps task names and labels to list of tasks to be built."""
+ target_build_map = dict([(target.name, [target]) for target in _TARGETS])
+ if len(_TARGETS) > len(target_build_map.keys()):
+ raise Exception('Target names need to be unique')
+
+ label_build_map = {}
+ label_build_map['all'] = [t for t in _TARGETS] # to build all targets
+ for target in _TARGETS:
+ for label in target.labels:
+ if label in label_build_map:
+ label_build_map[label].append(target)
+ else:
+ label_build_map[label] = [target]
+
+ if set(target_build_map.keys()).intersection(label_build_map.keys()):
+ raise Exception('Target names need to be distinct from label names')
+ return dict(target_build_map.items() + label_build_map.items())
_BUILD_MAP = _create_build_map()
argp = argparse.ArgumentParser(description='Runs build/test targets.')
-argp.add_argument('-b', '--build',
- choices=sorted(_BUILD_MAP.keys()),
- nargs='+',
- default=['all'],
- help='Target name or target label to build.')
-argp.add_argument('-f', '--filter',
- choices=sorted(_BUILD_MAP.keys()),
- nargs='+',
- default=[],
- help='Filter targets to build with AND semantics.')
+argp.add_argument(
+ '-b',
+ '--build',
+ choices=sorted(_BUILD_MAP.keys()),
+ nargs='+',
+ default=['all'],
+ help='Target name or target label to build.')
+argp.add_argument(
+ '-f',
+ '--filter',
+ choices=sorted(_BUILD_MAP.keys()),
+ nargs='+',
+ default=[],
+ help='Filter targets to build with AND semantics.')
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
-argp.add_argument('-t', '--travis',
- default=False,
- action='store_const',
- const=True)
+argp.add_argument(
+ '-t', '--travis', default=False, action='store_const', const=True)
args = argp.parse_args()
# Figure out which targets to build
targets = []
for label in args.build:
- targets += _BUILD_MAP[label]
+ targets += _BUILD_MAP[label]
# Among targets selected by -b, filter out those that don't match the filter
targets = [t for t in targets if all(f in t.labels for f in args.filter)]
@@ -86,30 +87,29 @@ targets = sorted(set(targets))
# Execute pre-build phase
prebuild_jobs = []
for target in targets:
- prebuild_jobs += target.pre_build_jobspecs()
+ prebuild_jobs += target.pre_build_jobspecs()
if prebuild_jobs:
- num_failures, _ = jobset.run(
- prebuild_jobs, newline_on_success=True, maxjobs=args.jobs)
- if num_failures != 0:
- jobset.message('FAILED', 'Pre-build phase failed.', do_newline=True)
- sys.exit(1)
+ num_failures, _ = jobset.run(
+ prebuild_jobs, newline_on_success=True, maxjobs=args.jobs)
+ if num_failures != 0:
+ jobset.message('FAILED', 'Pre-build phase failed.', do_newline=True)
+ sys.exit(1)
build_jobs = []
for target in targets:
- build_jobs.append(target.build_jobspec())
+ build_jobs.append(target.build_jobspec())
if not build_jobs:
- print('Nothing to build.')
- sys.exit(1)
+ print('Nothing to build.')
+ sys.exit(1)
jobset.message('START', 'Building targets.', do_newline=True)
num_failures, resultset = jobset.run(
build_jobs, newline_on_success=True, maxjobs=args.jobs)
-report_utils.render_junit_xml_report(resultset, 'report_taskrunner_sponge_log.xml',
- suite_name='tasks')
+report_utils.render_junit_xml_report(
+ resultset, 'report_taskrunner_sponge_log.xml', suite_name='tasks')
if num_failures == 0:
- jobset.message('SUCCESS', 'All targets built successfully.',
- do_newline=True)
+ jobset.message(
+ 'SUCCESS', 'All targets built successfully.', do_newline=True)
else:
- jobset.message('FAILED', 'Failed to build targets.',
- do_newline=True)
- sys.exit(1)
+ jobset.message('FAILED', 'Failed to build targets.', do_newline=True)
+ sys.exit(1)
diff --git a/tools/ubsan_suppressions.txt b/tools/ubsan_suppressions.txt
index 6ccc306cf0..2268adc169 100644
--- a/tools/ubsan_suppressions.txt
+++ b/tools/ubsan_suppressions.txt
@@ -9,3 +9,9 @@ alignment:poly1305_block_copy
nonnull-attribute:google::protobuf::*
alignment:google::protobuf::*
nonnull-attribute:_tr_stored_block
+# The following 5 suppressors should be removed as part of C++ cleanup
+enum:client_fuzzer_one_entry
+enum:message_compress_test
+enum:transport_security_test
+enum:algorithm_test
+alignment:transport_security_test